@object-ui/console 3.3.1 → 3.4.0
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-CLr3paaF.js +1 -0
- package/dist/assets/ConsoleFloatingChatbot-C_ClJ2NU.js +1 -0
- package/dist/assets/DashboardView-CODdYLuL.js +1 -0
- package/dist/assets/MetadataDetailPage-C1sWJhl2.js +1 -0
- package/dist/assets/MetadataFormDialog-Cje6P_Wf.js +1 -0
- package/dist/assets/MetadataManagerPage-DobP393N.js +1 -0
- package/dist/assets/PageView-DZHuurne.js +2 -0
- package/dist/assets/ProfilePage-6u6k00rh.js +1 -0
- package/dist/assets/RecordDetailView-cFSCvmx3.js +1 -0
- package/dist/assets/ReportView-oYVEbfYq.js +2 -0
- package/dist/assets/SearchResultsPage-BjAVc5rm.js +1 -0
- package/dist/assets/SystemHubPage-D08IDX3M.js +1 -0
- package/dist/assets/data-adapter-CleWpyQH.js +1 -0
- package/dist/assets/framework-CoXA0nY6.js +2 -0
- package/dist/assets/getIcon-vBP44wSb.js +1 -0
- package/dist/assets/index-98Lfd5ty.js +2 -0
- package/dist/assets/index-C162ArSl.css +2 -0
- package/dist/assets/{infrastructure-94fpO8jL.js → infrastructure-Djv3I7gr.js} +2 -2
- package/dist/assets/plugin-calendar-DX_UWouT.js +1 -0
- package/dist/assets/plugin-charts-BvZ1cSiZ.js +7 -0
- package/dist/assets/plugin-chatbot-DeSEtutf.js +24 -0
- package/dist/assets/plugin-form-BhbVu8jO.js +1 -0
- package/dist/assets/plugin-gantt-BG1WaV_b.js +1 -0
- package/dist/assets/plugin-grid-DwpWK0E8.js +8 -0
- package/dist/assets/plugin-kanban-Dzjqra5U.js +1 -0
- package/dist/assets/plugin-map-B7EfyDsf.js +1 -0
- package/dist/assets/plugin-map-CsMXqW6n.css +1 -0
- package/dist/assets/plugin-markdown-CiHluuxA.js +7 -0
- package/dist/assets/plugin-timeline-D8_YFDQQ.js +1 -0
- package/dist/assets/plugin-view-CXAFUa14.js +1 -0
- package/dist/assets/plugins-views-C5gstDGy.js +63 -0
- package/dist/assets/src-iMF4J4F7.js +1 -0
- package/dist/assets/ui-components-BCmPcwhR.js +36 -0
- package/dist/assets/ui-layout-BLl7ARoe.js +1 -0
- package/dist/assets/vendor-charts-DHZsyaJw.js +36 -0
- package/dist/assets/vendor-dndkit-BGB4qgc3.js +5 -0
- package/dist/assets/vendor-i18n-D3W5EAHR.js +1 -0
- package/dist/assets/vendor-icons-core-s9WPLoP3.js +1 -0
- package/dist/assets/vendor-markdown-D-LpQJes.js +29 -0
- package/dist/assets/vendor-objectstack-CBpPY_xk.js +39 -0
- package/dist/assets/vendor-radix-Bj7uHNWN.js +56 -0
- package/dist/assets/vendor-react-B1k2FF9f.js +11 -0
- package/dist/assets/vendor-ui-utils-AywTz3cM.js +1 -0
- package/dist/index.html +7 -26
- package/package.json +33 -33
- package/dist/assets/AdapterProvider-Cd4HYb7q.js +0 -1
- package/dist/assets/AdvancedChartImpl-AY6sVw1n.js +0 -7
- package/dist/assets/AppManagementPage-6l5ZKnv5.js +0 -1
- package/dist/assets/ChartImpl-DiKY5voi.js +0 -1
- package/dist/assets/DashboardView-BnX2k5Kx.js +0 -1
- package/dist/assets/KanbanEnhanced-BKCx2XIr.js +0 -1
- package/dist/assets/KanbanImpl-e9jzV-UD.js +0 -1
- package/dist/assets/MarkdownImpl-B-r7jSIS.js +0 -1
- package/dist/assets/MetadataDetailPage--3o8VI1T.js +0 -1
- package/dist/assets/MetadataFormDialog-Cy7k0Y55.js +0 -1
- package/dist/assets/MetadataInspector-DVtCDQtx.js +0 -1
- package/dist/assets/MetadataManagerPage-CYfvXG6X.js +0 -1
- package/dist/assets/MetadataProvider-Dvc9BxbC.js +0 -1
- package/dist/assets/PageView-CUDEz8Xo.js +0 -2
- package/dist/assets/ProfilePage-B0BXoAus.js +0 -1
- package/dist/assets/RecordDetailView-CYgcTNQp.js +0 -1
- package/dist/assets/ReportView-ovWyjJsZ.js +0 -1
- package/dist/assets/SearchResultsPage-B-NchFoJ.js +0 -1
- package/dist/assets/SystemHubPage-D8S1hN1a.js +0 -1
- package/dist/assets/data-adapter-v22lWuhc.js +0 -39
- package/dist/assets/framework-BW6KsEI0.js +0 -2
- package/dist/assets/getIcon-N5xWCMJy.js +0 -1
- package/dist/assets/index-DATdOX6r.js +0 -59
- package/dist/assets/index-nwlbpqhl.css +0 -2
- package/dist/assets/plugins-core-Ccvbi6db.js +0 -105
- package/dist/assets/plugins-views-CbLIJkBs.js +0 -62
- package/dist/assets/skeletons-CIQE_YYE.js +0 -1
- package/dist/assets/src-BGoL_8qF.js +0 -1
- package/dist/assets/ui-layout-CYz0tyDf.js +0 -3
- package/dist/assets/vendor-charts-D1AP0-EV.js +0 -33
- package/dist/assets/vendor-icons-CrSf7tAH.js +0 -1
- package/dist/assets/vendor-objectstack-Dhrq31KF.js +0 -1
- package/dist/assets/vendor-react-ryfytPb-.js +0 -9
- /package/dist/assets/{maplibre-gl-BR3qC6SX.js → maplibre-gl-ChgVR8ni.js} +0 -0
- /package/dist/assets/{plugins-core-B5ROGaJH.css → ui-components-B5ROGaJH.css} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t,t as n,u as r}from"./vendor-react-B1k2FF9f.js";import{p as i}from"./framework-CoXA0nY6.js";import{o as a}from"./vendor-ui-utils-AywTz3cM.js";import{DD as o,Q as s,Sy as c}from"./ui-components-BCmPcwhR.js";import{r as l}from"./src-iMF4J4F7.js";import{n as u,r as d,t as f}from"./index-98Lfd5ty.js";function p(e,t){let n=t?.label||e,r=t?.description||e,i=[{type:`object-detail-tabs`,id:`${e}-tabs`,objectName:e}];return{type:`page`,name:`object-detail-${e}`,title:n,description:r,icon:`database`,pageType:`record_detail`,object:e,body:i}}var m=e(t(),1),h=n();function g({basePath:e,metadataType:t}){let n=r(),{objects:o,refresh:s}=i(),p=d(),g=(0,m.useMemo)(()=>(o||[]).map(u),[o]),[_,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(!1),x=_??g,S=(0,m.useRef)(x),C=(0,m.useCallback)(r=>{n(`${e}/system/metadata/${t}/${r.name}`)},[n,e,t]),w=(0,m.useCallback)(async e=>{let t=S.current;if(v(e),S.current=e,!p){a.error(`Service unavailable — changes saved locally only`);return}let n=f.diffObjects(t,e);b(!0);try{if(n)n.type===`delete`?await p.deleteObject(n.object.name):await p.saveObject(n.object);else for(let t of e)await p.saveObject(t);await s();let t=n?n.type===`create`?`Object "${n.object.label||n.object.name}" created`:n.type===`update`?`Object "${n.object.label||n.object.name}" updated`:`Object "${n.object.label||n.object.name}" deleted`:`Object definitions updated`;a.success(t)}catch(e){v(t),S.current=t,a.error(e?.message||`Failed to save object changes`)}finally{b(!1)}},[p,s]);return(0,h.jsxs)(h.Fragment,{children:[y&&(0,h.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`object-saving-indicator`,children:[(0,h.jsx)(c,{className:`h-4 w-4 animate-spin`}),`Saving object changes…`]}),(0,h.jsx)(l,{objects:x,onObjectsChange:w,onSelectObject:C,showSystemObjects:!0})]})}var _=[{type:`app`,label:`Application`,pluralLabel:`Applications`,description:`Manage all configured applications`,icon:`layout-grid`,customRoute:`/system/apps`,countSource:`metadata`},{type:`object`,label:`Object`,pluralLabel:`Object Manager`,description:`Manage object definitions and field configurations`,icon:`database`,countSource:`metadata`,pageSchemaFactory:(e,t)=>p(e,t),listComponent:g},{type:`dashboard`,label:`Dashboard`,pluralLabel:`Dashboards`,description:`Manage dashboard layouts and widgets`,icon:`layout-dashboard`,columns:[{key:`name`,label:`Name`},{key:`label`,label:`Label`},{key:`description`,label:`Description`}],formFields:[{key:`name`,label:`Name`,required:!0,placeholder:`dashboard_name`,disabledOnEdit:!0},{key:`label`,label:`Label`,required:!0,placeholder:`My Dashboard`},{key:`description`,label:`Description`,type:`textarea`,placeholder:`Brief description`}]},{type:`page`,label:`Page`,pluralLabel:`Pages`,description:`Manage custom page definitions`,icon:`file-text`,columns:[{key:`name`,label:`Name`},{key:`label`,label:`Label`},{key:`description`,label:`Description`}],formFields:[{key:`name`,label:`Name`,required:!0,placeholder:`page_name`,disabledOnEdit:!0},{key:`label`,label:`Label`,required:!0,placeholder:`My Page`},{key:`description`,label:`Description`,type:`textarea`,placeholder:`Brief description`}]},{type:`report`,label:`Report`,pluralLabel:`Reports`,description:`Manage report configurations and templates`,icon:`bar-chart-3`,listMode:`grid`,columns:[{key:`name`,label:`Name`},{key:`label`,label:`Label`},{key:`description`,label:`Description`}],formFields:[{key:`name`,label:`Name`,required:!0,placeholder:`report_name`,disabledOnEdit:!0},{key:`label`,label:`Label`,required:!0,placeholder:`My Report`},{key:`description`,label:`Description`,type:`textarea`,placeholder:`Brief description`}]}];function v(e){return _.find(t=>t.type===e)}function y(){return _}var b=[{key:`name`,label:`Name`,required:!0,placeholder:`api_name`,disabledOnEdit:!0},{key:`label`,label:`Label`,required:!0,placeholder:`Display Label`},{key:`description`,label:`Description`,type:`textarea`,placeholder:`Brief description`}];function x(e){return e.includes(`-`)?e.toLowerCase():e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1-$2`).toLowerCase()}var S=new Map;function C(e){if(!e)return o;let t=S.get(e);if(t)return t;let n=x(e),r=e=>m.createElement(s,{name:n,fallback:o,...e});return r.displayName=`LucideIcon(${e})`,S.set(e,r),r}export{v as i,b as n,y as r,C as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ui-components-B5ROGaJH.css","assets/plugins-views-DnNKJB60.css","assets/plugin-map-CsMXqW6n.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t,a as n,c as r,d as i,f as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g}from"./vendor-react-B1k2FF9f.js";import{A as _,D as v,F as y,H as b,N as x,S,T as C,a as w,b as T,d as E,f as D,g as O,i as k,p as A,u as ee,w as te,y as ne}from"./framework-CoXA0nY6.js";import{a as j,c as M,d as re,i as ie,l as N,n as ae,o as P,r as F,s as oe,t as se,u as I}from"./infrastructure-Djv3I7gr.js";import{n as L,t as ce}from"./data-adapter-CleWpyQH.js";import{a as R,o as z}from"./vendor-ui-utils-AywTz3cM.js";import{a as le,c as B,i as V,n as ue,o as de,r as H,s as fe}from"./RecordDetailView-cFSCvmx3.js";import{$n as U,$t as pe,Aj as me,Bn as he,Br as ge,Cb as _e,DD as ve,DL as ye,Dl as W,Dt as be,Et as xe,FA as Se,Fn as Ce,GM as we,Gn as Te,Gt as Ee,Hn as De,Ht as G,If as Oe,In as ke,It as Ae,Jk as je,Jt as Me,Kn as Ne,Ld as Pe,Ln as Fe,Lt as Ie,Mt as Le,Mv as Re,NL as ze,Nt as Be,Ot as Ve,Ov as K,Ox as He,PC as Ue,Pt as We,Q as Ge,Qn as Ke,Qt as qe,R_ as Je,Rn as Ye,SA as Xe,SE as Ze,SO as Qe,SP as $e,Sd as et,Sy as q,Tt as tt,Un as nt,Vn as rt,Wb as it,Wn as at,Wt as ot,X as st,XA as ct,Xt as lt,YS as ut,Yt as dt,Yv as ft,Yy as pt,Zs as mt,Zt as ht,_n as gt,_r as _t,a_ as vt,ap as yt,ar as bt,at as xt,ax as St,bb as Ct,bj as wt,dn as Tt,dr as Et,ei as Dt,en as Ot,fN as kt,fd as At,fj as jt,fn as Mt,fr as Nt,ft as Pt,gb as Ft,gc as It,gn as Lt,gr as Rt,gt as zt,hn as J,hr as Bt,ht as Vt,hx as Ht,ig as Ut,ir as Wt,it as Gt,js as Kt,jt as qt,kt as Jt,lm as Yt,ly as Xt,mc as Zt,mh as Qt,mn as $t,mr as en,mt as tn,na as nn,nj as rn,nk as an,nt as on,ol as sn,or as cn,pM as ln,pn as un,po as dn,pr as fn,pt as pn,qm as mn,qn as hn,qt as gn,r_ as _n,rt as vn,sI as yn,sT as bn,sr as xn,st as Sn,tO as Cn,tn as wn,to as Tn,tt as En,un as Y,ur as Dn,va as On,vb as kn,vr as X,wA as An,wd as jn,wt as Mn,xn as Nn,zk as Pn,zn as Fn}from"./ui-components-BCmPcwhR.js";import{n as In,t as Ln}from"./ui-layout-BLl7ARoe.js";import{n as Rn,r as Z}from"./DashboardView-CODdYLuL.js";import{a as zn,o as Bn,s as Vn}from"./plugins-views-C5gstDGy.js";import{r as Hn}from"./plugin-grid-DwpWK0E8.js";import{n as Un}from"./plugin-form-BhbVu8jO.js";import{a as Wn,c as Gn,i as Kn,n as qn,o as Jn,r as Yn,s as Xn,t as Zn}from"./plugin-view-CXAFUa14.js";import"./PageView-DZHuurne.js";import"./ReportView-oYVEbfYq.js";import"./SearchResultsPage-BjAVc5rm.js";import{n as Qn}from"./src-iMF4J4F7.js";var Q=e(t(),1),$n=e(o(),1),$=h();function er({children:e,adapter:t}){let[n,r]=(0,Q.useState)(t??null);return(0,Q.useEffect)(()=>{if(t){r(t);return}let e=!1;async function n(){try{let t=new ce({baseUrl:`https://demo.objectstack.ai`,fetch:I(),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,$.jsx)(ee.Provider,{value:n,children:e})}var tr=300*1e3,nr=[`app`,`view`],rr={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},ir=`objectui:metadata:`;function ar(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var or=ar();function sr(...e){or&&console.debug(`[MetadataProvider]`,...e)}function cr(e){return e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function lr(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function ur(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function dr(e,t){if(!e.length||!t.length)return e;let n={};for(let e of t){let t=e?.name||e?.list?.data?.object||e?.form?.data?.object;if(!t)continue;let r=n[t]||={};if(e.list){let t=e.list.name||`default`;r[t]=e.list}if(e.listViews&&typeof e.listViews==`object`)for(let[t,n]of Object.entries(e.listViews))r[t]=n}return e.map(e=>{let t=n[e.name];if(!t)return e;let r=e.listViews||e.list_views||{};return{...e,listViews:{...t,...r}}})}function fr(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function pr(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(ir+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function mr(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(ir+e,JSON.stringify(t))}catch{}}function hr({children:e,adapter:t,ttlMs:n=tr}){let r=(0,Q.useRef)(new Map),i=(0,Q.useRef)(new Map),a=(0,Q.useRef)(t);a.current=t;let[o,s]=(0,Q.useState)(0),c=(0,Q.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>s(e=>e+1)):Promise.resolve().then(()=>s(e=>e+1))},[]),l=(0,Q.useCallback)(e=>{let t=r.current.get(e);return t||(t=fr(),r.current.set(e,t)),t},[]),u=(0,Q.useCallback)(e=>{let t=l(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return sr(`cache hit (fresh) type=${e} items=${t.items.length}`),Promise.resolve(t.items);let r=Date.now();t.status=`loading`,t.error=null;let i=a.current.getClient().meta.getItems(e).then(n=>{let i=cr(n);t.items=i,t.status=`ready`,t.error=null,t.fetchedAt=Date.now(),t.promise=null,t.byName.clear();for(let e of i)ur(e)&&t.byName.set(e.name,e);return e===`app`&&mr(e,i),sr(`fetched type=${e} items=${i.length} in ${Date.now()-r}ms`),c(),i}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,sr(`fetch failed type=${e}`,r),c(),[]});return t.promise=i,i},[c,l,n]),d=(0,Q.useCallback)((e,t)=>{let n=l(e);if(n.byName.has(t))return sr(`item cache hit type=${e} name=${t}`),Promise.resolve(n.byName.get(t)??null);let r=i.current.get(e);r||(r=new Map,i.current.set(e,r));let o=r.get(t);if(o)return o;let s=Date.now(),c=a.current.getClient().meta.getItem(e,t).then(i=>{let a=lr(i);return a&&n.byName.set(t,a),sr(`fetched item type=${e} name=${t} in ${Date.now()-s}ms`),r.delete(t),a}).catch(n=>(r.delete(t),sr(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,c),c},[l]),f=(0,Q.useCallback)(async e=>{if(e){let t=l(e);t.fetchedAt=0,t.byName.clear(),await u(e);return}let t=Array.from(r.current.keys()).filter(e=>r.current.get(e).status!==`idle`);await Promise.all(t.map(e=>{let t=r.current.get(e);return t.fetchedAt=0,t.byName.clear(),u(e)}))},[u,l]),p=(0,Q.useCallback)((e,t)=>{let n=r.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),sr(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,sr(`invalidated type=${e}`)),c())},[c]),[m,h]=(0,Q.useState)(!0),[g,_]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=!1,t=pr(`app`);if(t){let e=l(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)ur(n)&&e.byName.set(n.name,n);c(),h(!1)}return(async()=>{for(let t of nr)try{await u(t),e||_(null)}catch(t){e||_(t instanceof Error?t:Error(String(t)))}e||h(!1)})(),()=>{e=!0}},[t,u,l,c]);let v=(0,Q.useMemo)(()=>{let e=e=>{let t=l(e);return t.status===`idle`&&u(e),t.items};return{apps:l(`app`).items,get objects(){let t=e(rr.objects),n=e(`view`);return n.length?dr(t,n):t},get dashboards(){return e(rr.dashboards)},get reports(){return e(rr.reports)},get pages(){return e(rr.pages)},loading:m,error:g??l(`app`).error,refresh:f,invalidate:p,ensureType:u,getItem:d,getItemsByType:t=>e(t)}},[o,m,g,u,d,l,f,p]);return(0,$.jsx)(E.Provider,{value:v,children:e})}var gr=(0,Q.createContext)(null);function _r({children:e,user:t={},app:n={},data:r={}}){let i=(0,Q.useMemo)(()=>({user:t,app:n,data:r,evaluator:new y({user:t,app:n,data:r})}),[t,n,r]);return(0,$.jsx)(gr.Provider,{value:i,children:e})}function vr(){let e=(0,Q.useContext)(gr);if(!e){let e={user:{},app:{},data:{}};return{...e,evaluator:new y(e)}}return e}function yr(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}function br({objectName:e,objectLabel:t,dataSource:n,onEdit:r,onRefresh:i}){let o=g(),{appName:s}=a(),c=`/apps/${s}`,{execute:l,loading:u,error:d,runner:f}=C({context:{objectName:e,objectLabel:t||e,baseUrl:c}});return(0,Q.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?.(),z.success(`${t||e} deleted successfully`),{success:!0,reload:!0}}catch(n){return z.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&&o(t.startsWith(`/`)?t:`${c}/${t}`),{success:!0}}),f.registerHandler(`refresh`,async()=>(i?.(),{success:!0,reload:!0}))},[f,e,n,r,i,o,c]),{execute:l,create:(0,Q.useCallback)(()=>{r?.(null)},[r]),deleteRecord:(0,Q.useCallback)(async e=>l({type:`delete`,confirmText:`Are you sure you want to delete this record?`,params:{recordId:e}}),[l]),navigateToView:(0,Q.useCallback)(t=>{o(`${c}/${e}/view/${t}`)},[o,c,e]),navigateToRecord:(0,Q.useCallback)(t=>{o(`${c}/${e}/record/${encodeURIComponent(t)}`)},[o,c,e]),loading:u,error:d}}var xr=`objectui-recent-items`,Sr=8;function Cr(){try{let e=localStorage.getItem(xr);return e?JSON.parse(e):[]}catch{return[]}}function wr(e){try{localStorage.setItem(xr,JSON.stringify(e))}catch{}}function Tr(){let[e,t]=(0,Q.useState)(Cr);return(0,Q.useEffect)(()=>{t(Cr())},[]),{recentItems:e,addRecentItem:(0,Q.useCallback)(e=>{t(t=>{let n=t.filter(t=>t.id!==e.id),r=[{...e,visitedAt:new Date().toISOString()},...n].slice(0,Sr);return wr(r),r})},[]),clearRecentItems:(0,Q.useCallback)(()=>{t([]),wr([])},[])}}var Er=`objectui-favorites`,Dr=20;function Or(){try{let e=localStorage.getItem(Er);return e?JSON.parse(e):[]}catch{return[]}}function kr(e){try{localStorage.setItem(Er,JSON.stringify(e))}catch{}}var Ar=(0,Q.createContext)(null);function jr({children:e}){let[t,n]=(0,Q.useState)(Or);(0,Q.useEffect)(()=>{n(Or())},[]);let r=(0,Q.useCallback)(e=>{n(t=>{if(t.some(t=>t.id===e.id))return t;let n=[{...e,favoritedAt:new Date().toISOString()},...t].slice(0,Dr);return kr(n),n})},[]),i=(0,Q.useCallback)(e=>{n(t=>{let n=t.filter(t=>t.id!==e);return kr(n),n})},[]),a=(0,Q.useCallback)(e=>{n(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,Dr);return kr(n),n})},[]),o=(0,Q.useCallback)(()=>{n([]),kr([])},[]),s=(0,Q.useMemo)(()=>({favorites:t,addFavorite:r,removeFavorite:i,toggleFavorite:a,isFavorite:e=>t.some(t=>t.id===e),clearFavorites:o}),[t,r,i,a,o]);return(0,$.jsx)(Ar.Provider,{value:s,children:e})}function Mr(){return(0,Q.useContext)(Ar)||{favorites:[],addFavorite:()=>{},removeFavorite:()=>{},toggleFavorite:()=>{},isFavorite:()=>!1,clearFavorites:()=>{}}}var Nr=(0,Q.createContext)({theme:`system`,setTheme:()=>null});function Pr({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`,...r}){let[i,a]=(0,Q.useState)(()=>localStorage.getItem(n)||t);(0,Q.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,$.jsx)(Nr.Provider,{...r,value:o,children:e})}var Fr=()=>{let e=(0,Q.useContext)(Nr);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function Ir(){return(0,$.jsx)(`div`,{className:`h-screen flex items-center justify-center text-sm text-muted-foreground`,children:`Loading…`})}function Lr({children:e}){return(0,$.jsx)(Pr,{defaultTheme:`system`,storageKey:`object-ui-theme`,children:(0,$.jsx)(fe,{children:(0,$.jsx)(jr,{children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Ir,{}),children:e})})})})}function Rr({children:e}){return(0,$.jsx)(er,{children:(0,$.jsx)(zr,{children:e})})}function zr({children:e}){let t=D();return t?(0,$.jsx)(hr,{adapter:t,children:e}):(0,$.jsx)(Ir,{})}function Br({children:e}){let{activeOrganization:t,organizations:r,isOrganizationsLoading:i}=M();return i?(0,$.jsx)(Ir,{}):((r??[]).length>0||t)&&!t?(0,$.jsx)(n,{to:`/organizations`,replace:!0}):(0,$.jsx)($.Fragment,{children:e})}function Vr({children:e,requireOrganization:t=!0,loginPath:r=`/login`}){return(0,$.jsx)(oe,{fallback:(0,$.jsx)(n,{to:r}),loadingFallback:(0,$.jsx)(Ir,{}),children:(0,$.jsx)(Rr,{children:t?(0,$.jsx)(Br,{children:e}):e})})}function Hr(){let{loading:e}=A();return e?(0,$.jsx)(Ir,{}):(0,$.jsx)(n,{to:`/home`,replace:!0})}function Ur(){let e=c(),t=e.pathname.replace(/^\/system/,``);return(0,$.jsx)(n,{to:`${t?`/apps/setup/system${t}`:`/apps/setup`}${e.search}${e.hash}`,replace:!0})}function Wr(e){return e.includes(`-`)?e.toLowerCase():e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1-$2`).toLowerCase()}var Gr=new Map;function Kr(e){if(!e)return ve;let t=Gr.get(e);if(t)return t;let n=Wr(e),r=e=>Q.createElement(Ge,{name:n,fallback:ve,...e});return r.displayName=`LucideIcon(${e})`,Gr.set(e,r),r}var qr=`objectui-nav-pins`,Jr=20;function Yr(){try{let e=localStorage.getItem(qr);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Xr(e){try{localStorage.setItem(qr,JSON.stringify(e))}catch{}}function Zr(){let[e,t]=(0,Q.useState)(Yr);(0,Q.useEffect)(()=>{t(Yr())},[]);let n=(0,Q.useCallback)((e,n)=>{t(t=>{let r=t.filter(t=>t!==e),i=n?[...r,e].slice(0,Jr):r;return Xr(i),i})},[]),r=(0,Q.useCallback)(t=>e.includes(t),[e]),i=(0,Q.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,Q.useCallback)(()=>{t([]),Xr([])},[])}}function Qr(e){let t=`objectui-nav-order-${e}`,[n,r]=Q.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=Q.useCallback(e=>{r(e);try{localStorage.setItem(t,JSON.stringify(e))}catch{}},[t]);return{applyOrder:Q.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:Q.useCallback(e=>{let t=e.map(e=>e.id);i({...n,__root__:t})},[n,i])}}function $r({activeAppName:e}){let{isMobile:t}=Ie(),n=c(),{t:r}=w(),{objectLabel:i,dashboardLabel:a,navGroupLabel:o}=re(),{context:s,currentAppName:l}=B();Q.useEffect(()=>{let e=0,n=t=>{e=t.touches[0].clientX},r=n=>{let r=n.changedTouches[0].clientX-e;e<30&&r>50&&t&&document.querySelector(`[data-sidebar="trigger"]`)?.dispatchEvent(new MouseEvent(`click`,{bubbles:!0}))};return document.addEventListener(`touchstart`,n,{passive:!0}),document.addEventListener(`touchend`,r,{passive:!0}),()=>{document.removeEventListener(`touchstart`,n),document.removeEventListener(`touchend`,r)}},[t]);let{recentItems:u}=Tr(),{favorites:d,removeFavorite:f}=Mr(),{apps:m}=A(),h=(m||[]).filter(e=>e.active!==!1),g=h.find(t=>t.name===(e||l))||h[0],{applyOrder:_,handleReorder:v}=Qr(g?.name||`home`),{togglePin:y,applyPins:b}=Zr(),x=g?.areas||[],[S,C]=Q.useState(()=>x.length>0?x[0].id:null);Q.useEffect(()=>{x.length>0?C(e=>x.some(t=>t.id===e)?e:x[0].id):C(null)},[g?.name,x.length]);let T=x.find(e=>e.id===S)?.navigation||g?.navigation||[],E=Q.useMemo(()=>[{id:`home-dashboard`,label:r(`home.nav`,{defaultValue:`Home`}),type:`url`,url:`/home`,icon:`home`}],[r]),D=s===`home`?E:T,O=Q.useMemo(()=>b(_(D)),[D,_,b]),[k,ee]=Q.useState(!1),{evaluator:te}=vr(),ne=Q.useCallback(e=>yr(e,te),[te]),{can:j}=se(),M=Q.useCallback(e=>e.every(e=>{let t=e.split(`:`),[n,r]=t.length>=2?[t[0],t[1]]:[e,`read`];return j(n,r)}),[j]),ie=s===`app`&&g?`/apps/${g.name}`:``;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Mn,{collapsible:`icon`,className:`!top-14 !h-[calc(100svh-3.5rem)]`,children:[(0,$.jsx)(tt,{className:`pt-2`,children:(0,$.jsx)(`div`,{className:`transition-opacity duration-200 ease-in-out`,children:s===`app`&&g?(0,$.jsxs)($.Fragment,{children:[x.length>1&&(0,$.jsxs)(be,{children:[(0,$.jsxs)(Jt,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(_e,{className:`h-3.5 w-3.5`}),r(`sidebar.area`,{defaultValue:`Area`})]}),(0,$.jsx)(Ve,{children:(0,$.jsx)(qt,{children:x.map(e=>{let t=Kr(e.icon);return(0,$.jsx)(We,{children:(0,$.jsxs)(Be,{isActive:e.id===S,tooltip:e.label,onClick:()=>C(e.id),children:[(0,$.jsx)(t,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:e.label})]})},e.id)})})})]}),(0,$.jsx)(Ln,{items:O,basePath:ie,evaluateVisibility:ne,checkPermission:M,enablePinning:!t,onPinToggle:y,enableReorder:!t,onReorder:v,resolveObjectLabel:(e,t)=>i({name:e,label:t}),resolveDashboardLabel:(e,t)=>a({name:e,label:t}),resolveGroupLabel:g?(e,t)=>o(g.name,e,t):void 0,t:r}),u.length>0&&(0,$.jsxs)(be,{children:[(0,$.jsxs)(Jt,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:()=>ee(e=>!e),children:[(0,$.jsx)(ct,{className:`h-3 w-3 transition-transform duration-150 ${k?`rotate-90`:``}`}),(0,$.jsx)(an,{className:`h-3.5 w-3.5`}),r(`sidebar.recent`,{defaultValue:`Recent`})]}),k&&(0,$.jsx)(Ve,{children:(0,$.jsx)(qt,{children:u.slice(0,5).map(e=>(0,$.jsx)(We,{children:(0,$.jsx)(Be,{asChild:!0,tooltip:e.label,children:(0,$.jsxs)(p,{to:e.href,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.type===`dashboard`?`📊`:e.type===`report`?`📈`:`📄`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]})})},e.id))})})]}),d.length>0&&(0,$.jsxs)(be,{children:[(0,$.jsxs)(Jt,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Zt,{className:`h-3.5 w-3.5`}),r(`sidebar.favorites`,{defaultValue:`Favorites`})]}),(0,$.jsx)(Ve,{children:(0,$.jsx)(qt,{children:d.slice(0,8).map(e=>(0,$.jsxs)(We,{children:[(0,$.jsx)(Be,{asChild:!0,tooltip:e.label,children:(0,$.jsxs)(p,{to:e.href,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.type===`dashboard`?`📊`:e.type===`report`?`📈`:e.type===`page`?`📄`:`📋`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]})}),(0,$.jsx)(Le,{showOnHover:!0,onClick:t=>{t.stopPropagation(),f(e.id)},"aria-label":r(`sidebar.removeFromFavorites`,{defaultValue:`Remove {{name}} from favorites`,name:e.label}),children:(0,$.jsx)(It,{className:`h-3 w-3`})})]},e.id))})})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{children:(0,$.jsx)(Ve,{children:(0,$.jsx)(qt,{children:E.map(e=>{let t=Kr(e.icon),r=n.pathname===e.url;return(0,$.jsx)(We,{children:(0,$.jsx)(Be,{asChild:!0,tooltip:e.label,isActive:r,children:(0,$.jsxs)(p,{to:e.url||`/home`,children:[(0,$.jsx)(t,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:e.label})]})})},e.id)})})})}),d.filter(e=>e.type===`object`||e.type===`dashboard`||e.type===`page`).length>0&&(0,$.jsxs)(be,{children:[(0,$.jsxs)(Jt,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Zt,{className:`h-3.5 w-3.5`}),r(`sidebar.starred`,{defaultValue:`Starred`})]}),(0,$.jsx)(Ve,{children:(0,$.jsx)(qt,{children:d.filter(e=>e.type===`object`||e.type===`dashboard`||e.type===`page`).slice(0,8).map(e=>(0,$.jsxs)(We,{children:[(0,$.jsx)(Be,{asChild:!0,tooltip:e.label,children:(0,$.jsxs)(p,{to:e.href,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.type===`dashboard`?`📊`:e.type===`page`?`📄`:`📋`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]})}),(0,$.jsx)(Le,{showOnHover:!0,onClick:t=>{t.stopPropagation(),f(e.id)},"aria-label":r(`sidebar.removeFromFavorites`,{defaultValue:`Remove {{name}} from favorites`,name:e.label}),children:(0,$.jsx)(It,{className:`h-3 w-3`})})]},e.id))})})]})]})})}),(0,$.jsx)(xe,{className:`border-t p-1`,children:(0,$.jsx)(Ae,{className:`w-full justify-start pl-2 group-data-[state=collapsed]:justify-center group-data-[state=collapsed]:pl-0`})})]}),t&&s===`app`&&(0,$.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:O.filter(e=>e.type!==`group`).slice(0,5).map(e=>{let t=Kr(e.icon),n=e.url||`#`;return e.type===`object`?(n=`${ie}/${e.objectName}`,e.viewName&&(n+=`/view/${e.viewName}`)):e.type===`dashboard`?n=e.dashboardName?`${ie}/dashboard/${e.dashboardName}`:`#`:e.type===`page`&&(n=e.pageName?`${ie}/page/${e.pageName}`:`#`),(0,$.jsxs)(p,{to:n,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,$.jsx)(t,{className:`h-5 w-5`}),(0,$.jsx)(`span`,{className:`text-[10px] truncate max-w-[60px]`,children:Z(e.label,r)})]},e.id)})})]})}function ei(){let{theme:e,setTheme:t}=Fr(),{t:n}=w();return(0,$.jsxs)(Mt,{children:[(0,$.jsx)(Nn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:[(0,$.jsx)(mt,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),(0,$.jsx)(_n,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),(0,$.jsx)(`span`,{className:`sr-only`,children:n(`console.theme.toggle`)})]})}),(0,$.jsxs)(un,{align:`end`,children:[(0,$.jsxs)(J,{onClick:()=>t(`light`),className:`gap-2`,children:[(0,$.jsx)(mt,{className:`h-4 w-4`}),n(`console.theme.light`),e===`light`&&(0,$.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]}),(0,$.jsxs)(J,{onClick:()=>t(`dark`),className:`gap-2`,children:[(0,$.jsx)(_n,{className:`h-4 w-4`}),n(`console.theme.dark`),e===`dark`&&(0,$.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]}),(0,$.jsxs)(J,{onClick:()=>t(`system`),className:`gap-2`,children:[(0,$.jsx)(vt,{className:`h-4 w-4`}),n(`console.theme.system`),e===`system`&&(0,$.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]})]})]})}var ti=[{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 ni(){let{t:e,language:t,changeLanguage:n}=w();return(0,$.jsxs)(Mt,{children:[(0,$.jsx)(Nn,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:[(0,$.jsx)(ut,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`sr-only`,children:e(`console.localeSwitcher.label`)})]})}),(0,$.jsx)(un,{align:`end`,className:`max-h-72 overflow-y-auto`,children:ti.map(e=>(0,$.jsxs)(J,{onClick:()=>n(e.code),className:`gap-2`,children:[e.label,t===e.code&&(0,$.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]},e.code))})]})}var ri={connected:{label:`Connected`,color:`text-green-500`,icon:An},connecting:{label:`Connecting...`,color:`text-yellow-500`,icon:q},reconnecting:{label:`Reconnecting...`,color:`text-yellow-500`,icon:q},disconnected:{label:`Disconnected`,color:`text-muted-foreground`,icon:Dt},error:{label:`Connection Error`,color:`text-destructive`,icon:Dt}};function ii({state:e,className:t}){let n=ri[e],r=n.icon,[i,a]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(e===`connected`){a(!0);let e=setTimeout(()=>a(!1),2e3);return()=>clearTimeout(e)}a(!1)},[e]),e===`connected`&&!i?null:(0,$.jsxs)(`div`,{className:ze(`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,$.jsx)(r,{className:ze(`h-3.5 w-3.5`,(e===`connecting`||e===`reconnecting`)&&`animate-spin`)}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:n.label})]})}var ai={create:{icon:Yt,color:`text-green-500`},update:{icon:mn,color:`text-blue-500`},delete:{icon:dn,color:`text-red-500`},comment:{icon:Je,color:`text-amber-500`}};function oi(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 si({activities:e=[],className:t}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.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,$.jsxs)(ot,{open:n,onOpenChange:r,children:[(0,$.jsx)(dt,{asChild:!0,children:(0,$.jsxs)(X,{variant:`ghost`,size:`icon`,className:t??`h-8 w-8`,"aria-label":`Activity feed`,children:[(0,$.jsx)($e,{className:`h-4 w-4`}),e.length>0&&(0,$.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,$.jsxs)(Ee,{side:`right`,className:`w-80 sm:w-96`,children:[(0,$.jsx)(gn,{children:(0,$.jsxs)(Me,{className:`flex items-center justify-between`,children:[`Recent Activity`,(0,$.jsxs)(X,{variant:i?`secondary`:`ghost`,size:`sm`,className:`h-7 px-2`,onClick:()=>a(!i),children:[(0,$.jsx)(Ue,{className:`h-3.5 w-3.5 mr-1`}),`Filter`]})]})}),i&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-3 px-1`,children:Object.keys(ai).map(e=>{let{icon:t,color:n}=ai[e],r=o[e];return(0,$.jsxs)(Wt,{variant:r?`default`:`outline`,className:`cursor-pointer select-none gap-1 capitalize`,onClick:()=>c(e),children:[(0,$.jsx)(t,{className:`h-3 w-3 ${r?``:n}`}),e]},e)})}),l.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-16 text-muted-foreground`,children:[(0,$.jsx)($e,{className:`h-8 w-8 opacity-40`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No recent activity`})]}):(0,$.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}=ai[e.type];return(0,$.jsxs)(`li`,{className:`flex items-start gap-3 rounded-md px-2 py-2 hover:bg-muted/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 ${n}`,children:(0,$.jsx)(t,{className:`h-4 w-4`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-sm leading-snug`,children:e.description}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[e.user,` · `,oi(e.timestamp)]})]})]},e.id)})})]})]})}function ci({activeAppName:e,onAppChange:t}){let{apps:n}=A(),{t:r}=w(),{appLabel:i}=re(),a=(n||[]).filter(e=>e.active!==!1),o=a.find(t=>t.name===e)||a[0];return o?(0,$.jsxs)(Mt,{children:[(0,$.jsx)(Nn,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`flex items-center gap-1 rounded-md px-1.5 py-1 text-sm font-medium text-foreground/80 hover:bg-accent hover:text-foreground transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[i({name:o.name,label:Z(o.label,r)}),(0,$.jsx)(rn,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}),(0,$.jsxs)(un,{align:`start`,sideOffset:8,className:`w-60`,children:[(0,$.jsx)(Lt,{className:`text-xs text-muted-foreground font-normal`,children:`Switch Application`}),(0,$.jsx)(gt,{}),a.map(e=>{let n=Kr(e.icon),a=i({name:e.name,label:Z(e.label,r)}),s=o.name===e.name;return(0,$.jsxs)(J,{onClick:()=>t(e.name),className:`flex items-center gap-2.5 py-2`,children:[(0,$.jsx)(`div`,{className:`flex size-5 shrink-0 items-center justify-center rounded border bg-muted text-muted-foreground`,children:(0,$.jsx)(n,{className:`size-3`})}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:a}),s&&(0,$.jsx)(jt,{className:`size-3.5 text-primary shrink-0`})]},e.name)})]})]}):null}function li(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ui(){return(0,$.jsx)(`span`,{className:`select-none text-muted-foreground/40 mx-1.5 text-base font-light`,"aria-hidden":!0,children:`/`})}var di=[];function fi({variant:e,appName:t,objects:n,connectionState:r,presenceUsers:i,activities:o,activeAppName:s,onAppChange:l}){let u=e??(t?`app`:`home`),d=u===`app`,f=c(),m=a(),h=g(),{isOnline:_}=T(),{user:v,signOut:y,organizations:b,activeOrganization:x,isOrganizationsLoading:S}=M(),C=D(),{t:E}=w(),{objectLabel:O,dashboardLabel:k,pageLabel:ee,reportLabel:te}=re(),{apps:ne,dashboards:j,pages:ie,reports:N}=A(),{currentAppName:ae,recordTitle:P}=B(),[oe,se]=(0,Q.useState)(null),[I,L]=(0,Q.useState)(null),ce=(0,Q.useRef)(!1),R=(0,Q.useRef)(!1),z=(0,Q.useCallback)(async()=>{if(!C||!d)return;let e=ce.current?Promise.resolve({data:[]}):C.find(`sys_presence`).catch(e=>(e?.status===404&&(ce.current=!0),{data:[]})),t=R.current?Promise.resolve({data:[]}):C.find(`sys_activity`,{$orderby:{timestamp:`desc`},$top:20}).catch(e=>(e?.status===404&&(R.current=!0),{data:[]}));try{let[n,r]=await Promise.all([e,t]);if(n.data?.length){let e=n.data.filter(e=>typeof e.userId==`string`);e.length&&se(e)}if(r.data?.length){let e=r.data.filter(e=>typeof e.type==`string`);e.length&&L(e)}}catch{}},[C,d]);(0,Q.useEffect)(()=>{z()},[z]);let le=i??oe??di,ue=o??I??[],de=S||(b??[]).length>0||!!x,H=f.pathname.split(`/`).filter(Boolean),fe=m.appName||H[1],U=H[2],pe=`/apps/${fe}`,me=n??[],he=s||ae||fe,ge=(ne||[]).find(e=>e.name===he),_e=new Set,ve=e=>{for(let t of e||[])t.type===`object`&&t.objectName&&_e.add(t.objectName),t.children&&ve(t.children)};ve(ge?.navigation||[]);for(let e of ge?.areas||[])ve(e.navigation||[]);let ye=(_e.size>0?me.filter(e=>_e.has(e.name)):me.filter(e=>!e.name.startsWith(`sys_`)&&!e.name.startsWith(`auth_`))).map(e=>({label:O(e),href:`${pe}/${e.name}`})),W=[];if(d){if(U===`dashboard`){if(W.push({label:E(`console.breadcrumb.dashboards`),href:pe}),H[3]){let e=H[3],t=(j||[]).find(t=>t.name===e)?.label||li(e);W.push({label:k({name:e,label:t})})}}else if(U===`page`){if(W.push({label:E(`console.breadcrumb.pages`),href:pe}),H[3]){let e=H[3],t=(ie||[]).find(t=>t.name===e)?.label||li(e);W.push({label:ee({name:e,label:t})})}}else if(U===`report`){if(W.push({label:E(`console.breadcrumb.reports`),href:pe}),H[3]){let e=H[3],t=(N||[]).find(t=>t.name===e)?.label||li(e);W.push({label:te({name:e,label:t})})}}else if(U===`system`)W.push({label:E(`console.breadcrumb.system`)}),H[3]&&W.push({label:li(H[3])});else if(U){let e=me.find(e=>e.name===U);if(e)if(W.push({label:O(e),href:`${pe}/${U}`,siblings:ye}),H[3]===`record`&&H[4]){let e=H[4].length>12?`${H[4].slice(0,8)}…`:H[4],t=P?.trim(),n=t&&t.length>48?`${t.slice(0,45)}…`:t;W.push({label:n||`#${e}`})}else H[3]===`view`&&H[4]&&W.push({label:li(H[4])})}}let be=W[W.length-1]?.label||t||``;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between w-full h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center min-w-0 flex-1`,children:[(0,$.jsx)(p,{to:`/home`,className:`flex items-center justify-center h-7 w-7 shrink-0 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,title:`ObjectStack`,children:(0,$.jsx)(kt,{className:`h-4 w-4`})}),u===`home`&&(0,$.jsx)(`span`,{className:`hidden sm:inline ml-2 text-sm font-semibold tracking-tight`,children:`ObjectStack`}),u===`orgs`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ui,{}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80 px-1.5`,children:E(`organizations.title`,{defaultValue:`Organizations`})})]}),d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ae,{className:`md:hidden shrink-0 ml-1`}),s&&l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ui,{}),(0,$.jsx)(ci,{activeAppName:s,onAppChange:l})]}):t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ui,{}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-foreground/80 px-1.5`,children:t})]}):null,W.map((e,t)=>{let n=t===W.length-1;return(0,$.jsxs)(`span`,{className:`hidden sm:flex items-center min-w-0`,children:[(0,$.jsx)(ui,{}),e.siblings&&e.siblings.length>1?(0,$.jsxs)(Mt,{children:[(0,$.jsxs)(Nn,{className:`flex items-center gap-1 rounded-md px-1.5 py-1 text-sm font-medium transition-colors outline-none hover:bg-accent hover:text-foreground ${n?`text-foreground/80`:`text-foreground/60`}`,children:[e.label,(0,$.jsx)(rn,{className:`h-3.5 w-3.5 text-muted-foreground`})]}),(0,$.jsxs)(un,{align:`start`,sideOffset:8,className:`w-56 max-h-72 overflow-y-auto`,children:[(0,$.jsx)(Lt,{className:`text-xs text-muted-foreground font-normal`,children:`Switch Object`}),(0,$.jsx)(gt,{}),e.siblings.map(e=>(0,$.jsx)(J,{asChild:!0,children:(0,$.jsx)(p,{to:e.href,className:`w-full`,children:e.label})},e.href))]})]}):e.href?(0,$.jsx)(p,{to:e.href,className:`rounded-md px-1.5 py-1 text-sm font-medium transition-colors hover:bg-accent hover:text-foreground truncate max-w-[160px] ${n?`text-foreground/80`:`text-foreground/60`}`,children:e.label}):(0,$.jsx)(`span`,{className:`px-1.5 py-1 text-sm font-medium truncate max-w-[160px] ${n?`text-foreground/80`:`text-foreground/60`}`,children:e.label})]},t)}),(0,$.jsx)(`span`,{className:`text-sm font-medium sm:hidden truncate min-w-0 ml-1`,children:be})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 sm:gap-1 shrink-0 [&>*+*[data-topbar-group]]:ml-1 [&>[data-topbar-group]+[data-topbar-group]]:border-l [&>[data-topbar-group]+[data-topbar-group]]:border-border/60 [&>[data-topbar-group]+[data-topbar-group]]:pl-1 sm:[&>[data-topbar-group]+[data-topbar-group]]:pl-2 sm:[&>[data-topbar-group]+[data-topbar-group]]:ml-2`,children:[!_&&(0,$.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,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-yellow-500 animate-pulse`}),`Offline`]}),d&&r&&(0,$.jsx)(ii,{state:r}),d&&le.length>0&&(0,$.jsx)(`div`,{className:`hidden md:flex items-center shrink-0`,title:`Users currently online`,children:(0,$.jsx)(V,{users:le,size:`sm`,maxVisible:3,showStatus:!0})}),(0,$.jsxs)(`div`,{"data-topbar-group":!0,className:`flex items-center gap-0.5 sm:gap-1 shrink-0`,children:[(0,$.jsxs)(`button`,{onClick:()=>document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0})),className:`hidden lg:flex relative items-center gap-2 w-48 xl:w-64 h-8 px-3 text-sm rounded-md border bg-muted/50 text-muted-foreground hover:bg-muted transition-colors`,children:[(0,$.jsx)(Pe,{className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`flex-1 text-left text-xs`,children:E(`console.search`,{defaultValue:`Search...`})}),(0,$.jsxs)(`kbd`,{className:`pointer-events-none inline-flex h-5 items-center gap-0.5 rounded border bg-background px-1.5 text-[10px] font-medium text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`text-xs`,children:`⌘`}),`K`]})]}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`lg:hidden h-8 w-8 shrink-0`,onClick:()=>document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0})),"aria-label":E(`console.search`,{defaultValue:`Search...`}),children:(0,$.jsx)(Pe,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{"data-topbar-group":!0,className:`flex items-center gap-0.5 shrink-0`,children:[(0,$.jsx)(`div`,{className:`hidden sm:flex shrink-0`,children:(0,$.jsx)(si,{activities:ue})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8 hidden md:flex shrink-0`,asChild:!0,"aria-label":E(`sidebar.helpTooltip`,{defaultValue:`Help & Documentation`}),children:(0,$.jsx)(`a`,{href:`https://docs.objectstack.ai`,target:`_blank`,rel:`noopener noreferrer`,children:(0,$.jsx)(je,{className:`h-4 w-4`})})})]}),(0,$.jsxs)(`div`,{"data-topbar-group":!0,className:`flex items-center gap-0.5 shrink-0`,children:[(0,$.jsx)(`div`,{className:`hidden sm:flex shrink-0`,children:(0,$.jsx)(ei,{})}),(0,$.jsx)(`div`,{className:`hidden sm:flex shrink-0`,children:(0,$.jsx)(ni,{})}),(0,$.jsxs)(Mt,{children:[(0,$.jsx)(Nn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0 rounded-full`,children:(0,$.jsxs)(bt,{className:`h-7 w-7 rounded-full`,children:[(0,$.jsx)(xn,{src:v?.image,alt:v?.name??`User`}),(0,$.jsx)(cn,{className:`rounded-full bg-primary text-primary-foreground text-xs`,children:F(v)})]})})}),(0,$.jsxs)(un,{align:`end`,className:`min-w-64 rounded-lg`,sideOffset:4,children:[(0,$.jsx)(Lt,{className:`p-0 font-normal`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-2`,children:[(0,$.jsxs)(bt,{className:`h-8 w-8 rounded-lg`,children:[(0,$.jsx)(xn,{src:v?.image,alt:v?.name??`User`}),(0,$.jsx)(cn,{className:`rounded-lg bg-primary text-primary-foreground`,children:F(v)})]}),(0,$.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,$.jsx)(`span`,{className:`truncate font-semibold`,children:v?.name??`User`}),(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:v?.email??``})]})]})}),(0,$.jsx)(gt,{}),(0,$.jsxs)($t,{children:[de&&(0,$.jsxs)(J,{onClick:()=>h(`/organizations`),className:`cursor-pointer`,children:[(0,$.jsx)(kt,{className:`mr-2 h-4 w-4`}),E(`organizations.mine`,{defaultValue:`My Organizations`})]}),(0,$.jsxs)(J,{onClick:()=>h(`/apps/setup/system/profile`),children:[(0,$.jsx)(nn,{className:`mr-2 h-4 w-4`}),E(`user.profile`,{defaultValue:`Profile`})]}),(0,$.jsxs)(J,{onClick:()=>h(`/apps/setup`),children:[(0,$.jsx)(et,{className:`mr-2 h-4 w-4`}),E(`sidebar.settings`,{defaultValue:`Settings`})]})]}),(0,$.jsx)(gt,{}),(0,$.jsxs)(J,{className:`text-destructive focus:text-destructive`,onClick:()=>y(),children:[(0,$.jsx)(Xt,{className:`mr-2 h-4 w-4`}),E(`user.logout`,{defaultValue:`Log out`})]})]})]})]})]})]})}var pi=768,mi=1024;function hi(){let{setOpen:e,isMobile:t}=Ie();(0,Q.useEffect)(()=>{function t(){let t=window.innerWidth;t>=pi&&t<mi&&e(!1)}return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,t])}var gi=(0,Q.lazy)(()=>l(()=>import(`./ConsoleFloatingChatbot-C_ClJ2NU.js`),__vite__mapDeps([0])));function _i({children:e}){return hi(),(0,$.jsx)($.Fragment,{children:e})}function vi({children:e,activeAppName:t,activeApp:n,onAppChange:r,objects:i,connectionState:a}){let o=Z(n?.label)||t,{isAiEnabled:s}=S(),{setContext:c,setCurrentAppName:l}=B();return(0,Q.useEffect)(()=>{c(`app`),l(t)},[c,l,t]),(0,$.jsxs)(In,{sidebar:(0,$.jsx)($r,{activeAppName:t,onAppChange:r}),navbar:(0,$.jsx)(fi,{variant:`app`,appName:o,objects:i,connectionState:a,activeAppName:t,onAppChange:r}),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?`${Z(n.label)} — ObjectStack Console`:void 0}:void 0,children:[(0,$.jsx)(_i,{children:e}),s&&(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(gi,{appLabel:o,objects:i})})]})}function yi({apps:e,activeApp:t,objects:n,onAppChange:r}){let[i,o]=(0,Q.useState)(!1),s=g(),{appName:c}=a(),{setTheme:l}=Fr(),{evaluator:u}=vr(),{t:d}=w();(0,Q.useEffect)(()=>{let e=e=>{e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),o(e=>!e))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let f=`/apps/${c||t?.name}`,p=(0,Q.useCallback)(e=>{o(!1),e()},[]),m=bi(t?.navigation||[]).filter(e=>yr(e.visible??e.visibleOn,u));return(0,$.jsxs)(Ce,{open:i,onOpenChange:o,children:[(0,$.jsx)(Ye,{placeholder:d(`console.commandPalette.placeholder`)}),(0,$.jsxs)(he,{children:[(0,$.jsx)(ke,{children:d(`console.commandPalette.noResults`)}),m.filter(e=>e.type===`object`).length>0&&(0,$.jsx)(Fe,{heading:d(`console.commandPalette.objects`),children:m.filter(e=>e.type===`object`).map(e=>{let t=Kr(e.icon);return(0,$.jsxs)(Fn,{value:`object ${Z(e.label,d)} ${e.objectName}`,onSelect:()=>p(()=>s(`${f}/${e.objectName}`)),children:[(0,$.jsx)(t,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:Z(e.label,d)})]},e.id)})}),m.filter(e=>e.type===`dashboard`).length>0&&(0,$.jsx)(Fe,{heading:d(`console.commandPalette.dashboards`),children:m.filter(e=>e.type===`dashboard`).map(e=>(0,$.jsxs)(Fn,{value:`dashboard ${Z(e.label,d)} ${e.dashboardName}`,onSelect:()=>p(()=>s(`${f}/dashboard/${e.dashboardName}`)),children:[(0,$.jsx)(Ct,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:Z(e.label,d)})]},e.id))}),m.filter(e=>e.type===`page`).length>0&&(0,$.jsx)(Fe,{heading:d(`console.commandPalette.pages`),children:m.filter(e=>e.type===`page`).map(e=>(0,$.jsxs)(Fn,{value:`page ${Z(e.label,d)} ${e.pageName}`,onSelect:()=>p(()=>s(`${f}/page/${e.pageName}`)),children:[(0,$.jsx)(bn,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:Z(e.label,d)})]},e.id))}),m.filter(e=>e.type===`report`).length>0&&(0,$.jsx)(Fe,{heading:d(`console.commandPalette.reports`),children:m.filter(e=>e.type===`report`).map(e=>(0,$.jsxs)(Fn,{value:`report ${Z(e.label,d)} ${e.reportName}`,onSelect:()=>p(()=>s(`${f}/report/${e.reportName}`)),children:[(0,$.jsx)(me,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:Z(e.label,d)})]},e.id))}),e.filter(e=>e.active!==!1).length>1&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(rt,{}),(0,$.jsx)(Fe,{heading:d(`console.commandPalette.switchApp`),children:e.filter(e=>e.active!==!1).map(e=>{let n=Kr(e.icon);return(0,$.jsxs)(Fn,{value:`app ${Z(e.label,d)} ${e.name}`,onSelect:()=>p(()=>r(e.name)),children:[(0,$.jsx)(n,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:Z(e.label,d)}),e.name===t?.name&&(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:d(`console.commandPalette.current`)})]},e.name)})})]}),(0,$.jsx)(rt,{}),(0,$.jsxs)(Fe,{heading:d(`console.commandPalette.preferences`),children:[(0,$.jsxs)(Fn,{value:`theme light`,onSelect:()=>p(()=>l(`light`)),children:[(0,$.jsx)(mt,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:d(`console.commandPalette.lightTheme`)})]}),(0,$.jsxs)(Fn,{value:`theme dark`,onSelect:()=>p(()=>l(`dark`)),children:[(0,$.jsx)(_n,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:d(`console.commandPalette.darkTheme`)})]}),(0,$.jsxs)(Fn,{value:`theme system`,onSelect:()=>p(()=>l(`system`)),children:[(0,$.jsx)(vt,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:d(`console.commandPalette.systemTheme`)})]})]}),(0,$.jsx)(rt,{}),(0,$.jsxs)(Fe,{heading:d(`console.commandPalette.actions`),children:[(0,$.jsxs)(Fn,{value:`create new app application`,onSelect:()=>p(()=>s(`${f}/create-app`)),children:[(0,$.jsx)(Yt,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:d(`console.commandPalette.createApp`)})]}),(0,$.jsxs)(Fn,{value:`search all results full page`,onSelect:()=>p(()=>s(`${f}/search`)),children:[(0,$.jsx)(Pe,{className:`mr-2 h-4 w-4`}),(0,$.jsx)(`span`,{children:d(`console.commandPalette.openFullSearch`)})]})]})]})]})}function bi(e){let t=[];for(let n of e)n.type===`group`&&n.children?t.push(...bi(n.children)):t.push(n);return t}function xi(){let{t:e}=w(),[t,n]=(0,Q.useState)(!1),r=(0,Q.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,Q.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,$.jsx)(De,{open:t,onOpenChange:n,children:(0,$.jsxs)(nt,{className:`sm:max-w-lg max-h-[80vh] overflow-y-auto`,children:[(0,$.jsxs)(Ne,{children:[(0,$.jsx)(hn,{children:e(`console.shortcuts.title`)}),(0,$.jsx)(at,{children:e(`console.shortcuts.description`)})]}),(0,$.jsx)(`div`,{className:`space-y-6 pt-2`,children:r.map(e=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground mb-3`,children:e.title}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.shortcuts.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm`,children:e.description}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:e.keys.map((e,t)=>(0,$.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))})]})})}function Si(){return null}var Ci={title:`ObjectUI Console`,initializing:`Initializing…`,steps:{connecting:`Connecting to server`,loadingConfig:`Loading configuration`,preparingWorkspace:`Preparing workspace`},error:{connectionFailed:`Cannot connect to server`,checkServer:`Please check your network connection or that the backend is running.`},actions:{retry:`Retry`,retrying:`Retrying…`}};function wi({message:e,error:t,onRetry:n,retrying:r}){let[i,a]=(0,Q.useState)(0),o=(0,Q.useMemo)(()=>[Ci.steps.connecting,Ci.steps.loadingConfig,Ci.steps.preparingWorkspace],[]);return(0,Q.useEffect)(()=>{if(e||t)return;let n=setInterval(()=>{a(e=>Math.min(e+1,o.length-1))},1200);return()=>clearInterval(n)},[e,t,o.length]),(0,$.jsx)(`div`,{className:`flex flex-col items-center justify-center h-screen bg-background`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-6`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-primary/20 rounded-2xl blur-xl animate-pulse`}),(0,$.jsx)(`div`,{className:`relative bg-linear-to-br from-primary to-primary/80 p-4 rounded-2xl shadow-lg`,children:(0,$.jsx)(ve,{className:`h-10 w-10 text-primary-foreground`})})]}),(0,$.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,$.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:Ci.title}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Ci.initializing})]}),t?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-4 max-w-md w-full px-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-5 rounded-lg border border-destructive/30 bg-destructive/5 w-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-destructive`,children:[(0,$.jsx)(Se,{className:`h-5 w-5 shrink-0`}),(0,$.jsx)(`span`,{className:`text-sm font-semibold`,children:Ci.error.connectionFailed})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground text-center break-words`,children:t}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:Ci.error.checkServer})]}),n&&(0,$.jsx)(X,{onClick:n,disabled:r,variant:`default`,size:`sm`,className:`gap-2`,children:r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{className:`h-4 w-4 animate-spin`}),Ci.actions.retrying]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(yt,{className:`h-4 w-4`}),Ci.actions.retry]})})]}):e?(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 bg-muted/50 rounded-full`,children:[(0,$.jsx)(En,{className:`h-4 w-4 text-primary`}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e})]}):(0,$.jsx)(`div`,{className:`flex flex-col gap-2 w-64`,children:o.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 text-sm transition-opacity duration-300`,style:{opacity:t<=i?1:.3},children:[t<i?(0,$.jsx)(An,{className:`h-4 w-4 text-primary shrink-0`}):t===i?(0,$.jsx)(q,{className:`h-4 w-4 text-primary shrink-0 animate-spin`}):(0,$.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-muted-foreground/30 shrink-0`}),(0,$.jsx)(`span`,{className:t<=i?`text-foreground`:`text-muted-foreground`,children:e})]},e))})]})})}var Ti=1e4,Ei={timeout:`Connection timed out after 10 seconds.`,serverUnreachable:e=>`The server at ${e} is unreachable.`};function Di({children:e,authUrl:t}){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(void 0),[o,s]=(0,Q.useState)(!0),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(!1),f=(0,Q.useCallback)(async(e=!1)=>{e&&d(!0),l(null);let t=`https://demo.objectstack.ai`,n=`${t.replace(/\/$/,``)}/api/v1/discovery`;try{let e=await L(t,async()=>{let e=new AbortController,t=setTimeout(()=>e.abort(),Ti);try{let t=await fetch(n,{credentials:`include`,signal:e.signal});if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();return r&&typeof r.success==`boolean`&&`data`in r?r.data:r}catch(e){throw e.name===`AbortError`?Error(`timeout`):e}finally{clearTimeout(t)}});if(!e)throw Error(`empty discovery response`);e?.mode===`preview`?(a({autoLogin:e.previewMode?.autoLogin??!0,simulatedRole:e.previewMode?.simulatedRole??`admin`,simulatedUserName:e.previewMode?.simulatedUserName??`Preview User`,readOnly:e.previewMode?.readOnly??!1,expiresInSeconds:e.previewMode?.expiresInSeconds??0,bannerMessage:e.previewMode?.bannerMessage}),r(!1)):r(e?.services?.auth?.enabled??!0),s(!1)}catch(e){let t=e,r;r=t.message===`timeout`?Ei.timeout:t.message?.startsWith(`HTTP `)?`${Ei.serverUnreachable(n)} (${t.message})`:`${Ei.serverUnreachable(n)}${t.message?` (${t.message})`:``}`,console.warn(`[ConditionalAuthWrapper] Discovery failed:`,t),l(r),s(!0)}finally{d(!1)}},[]);return(0,Q.useEffect)(()=>{f()},[f]),o?(0,$.jsx)(wi,{error:c,onRetry:c?()=>f(!0):void 0,retrying:u}):i?(0,$.jsx)(N,{authUrl:t,previewMode:i,children:e}):n?(0,$.jsx)(N,{authUrl:t,children:e}):(0,$.jsx)(N,{authUrl:t,enabled:!1,children:e})}function Oi(e){let{theme:t=`system`}=Fr();return(0,$.jsx)(R,{theme:t,className:`toaster group`,icons:{success:(0,$.jsx)(An,{className:`h-4 w-4`}),info:(0,$.jsx)(St,{className:`h-4 w-4`}),warning:(0,$.jsx)(Tn,{className:`h-4 w-4`}),error:(0,$.jsx)(Ut,{className:`h-4 w-4`}),loading:(0,$.jsx)(q,{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})}function ki({error:e,onReset:t}){let{t:n}=w();return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-8`,children:(0,$.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,$.jsxs)(vn,{children:[(0,$.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10`,children:(0,$.jsx)(Tn,{className:`h-6 w-6 text-destructive`})}),(0,$.jsx)(xt,{children:n(`console.errors.somethingWentWrong`)}),(0,$.jsx)(Gt,{className:`mb-4`,children:e.message||n(`console.errors.unexpectedError`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,$.jsxs)(X,{variant:`outline`,size:`sm`,onClick:t,className:`gap-2`,children:[(0,$.jsx)(Oe,{className:`h-4 w-4`}),n(`console.errors.tryAgain`)]}),(0,$.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:()=>{window.location.href=`/`},className:`gap-2`,children:[(0,$.jsx)(He,{className:`h-4 w-4`}),n(`console.errors.goHome`)]})]})]}),!1]})})}var Ai=class extends Q.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,$.jsx)(ki,{error:this.state.error,onReset:this.resetErrorBoundary}):this.props.children}};function ji({sections:e,open:t}){if(!t)return null;let[n,r]=(0,Q.useState)([`0`]),[i,a]=(0,Q.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,$.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,$.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Metadata Inspector`}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:`JSON`})]}),(0,$.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,$.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,$.jsxs)(`button`,{onClick:()=>s(r),className:`flex-1 flex items-center justify-between text-left`,children:[(0,$.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),a?(0,$.jsx)(rn,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,$.jsx)(ct,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,$.jsx)(`button`,{onClick:()=>o(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:`Copy JSON`,children:c?(0,$.jsx)(jt,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(Cn,{className:`h-3 w-3 text-muted-foreground`})})]}),a&&(0,$.jsx)(`div`,{className:`px-4 pb-4`,children:(0,$.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,$.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 Mi(){let[e,t]=(0,Q.useState)((0,Q.useMemo)(()=>{try{return typeof window<`u`?x(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}function Ni({open:e,onClose:t,mode:n=`edit`,activeView:r,objectDef:i,onViewUpdate:a,onSave:o,onCreate:s}){let{t:c}=w(),l=(0,Q.useRef)(null),u=(0,Q.useMemo)(()=>({id:`view_${Date.now()}`,label:c(`console.objectView.newView`),type:`grid`,columns:[],filter:[],sort:[],showSearch:!0,showFilters:!0,showSort:!0}),[]),d=(0,Q.useMemo)(()=>({...r}),[n===`create`?`create`:r.id]),{draft:f,isDirty:p,updateField:m,discard:h,undo:g,redo:_,canUndo:v,canRedo:y}=st(n===`create`?u:d,{mode:n,onUpdate:a});(0,Q.useEffect)(()=>{e&&l.current&&l.current.focus()},[e]);let b=(0,Q.useMemo)(()=>Yn(i),[i.fields]),x=(0,Q.useMemo)(()=>Kn(f.filter),[f.filter]),S=(0,Q.useMemo)(()=>Wn(f.sort),[f.sort]),C=(0,Q.useMemo)(()=>Zn({t:c,fieldOptions:b,objectDef:i,updateField:m,filterGroupValue:x,sortItemsValue:S,essentialOnly:!0}),[c,b,i,m,x,S]),T=f.type||`grid`,E=(0,Q.useMemo)(()=>({...C,breadcrumb:[c(`console.objectView.page`),qn[T]||T]}),[C,c,T]),D=(0,Q.useCallback)(()=>{n===`create`?s?.(f):o?.(f),h()},[f,o,s,n,h]),O=(0,Q.useCallback)(()=>{if(n===`create`){t();return}h()},[h,n,t]),k=c(n===`create`?`console.objectView.createView`:`console.objectView.configureView`);return(0,$.jsx)(Sn,{open:e,onClose:t,schema:E,draft:f,isDirty:p,onFieldChange:m,onSave:D,onDiscard:O,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:k,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 Pi(e){return[{type:`grid`,icon:kn,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:sn,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:ln,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:Ht,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:an,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:W,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:K,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:me,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)}]}function Fi(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var Ii={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,filter:e=>e.type===`select`||e.type===`boolean`}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,filter:e=>e.type===`date`}],timeline:[{key:`dateField`,i18nKey:`console.objectView.dateField`,filter:e=>e.type===`date`}],gantt:[{key:`dateField`,i18nKey:`console.objectView.dateField`,filter:e=>e.type===`date`}],gallery:[{key:`imageField`,i18nKey:`console.objectView.imageField`}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,filter:e=>e.type===`number`},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,filter:e=>e.type===`number`}]};function Li({open:e,onOpenChange:t,onCreate:n,existingLabels:r,availableTypes:i,objectDef:a}){let{t:o}=w(),s=(0,Q.useMemo)(()=>Pi(o),[o]),c=(0,Q.useMemo)(()=>i&&i.length>0?s.filter(e=>i.includes(e.type)):s,[s,i]),l=(0,Q.useMemo)(()=>new Set(r??[]),[r]),u=(0,Q.useMemo)(()=>a?Yn(a):[],[a]),[d,f]=(0,Q.useState)(c[0]?.type??`grid`),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)({});(0,Q.useEffect)(()=>{e&&(f(c[0]?.type??`grid`),g(!1),v({}))},[e,c]),(0,Q.useEffect)(()=>{h||m(Fi(c.find(e=>e.type===d)?.label??`View`,l))},[d,h,c,l]);let y=Ii[d]??[],b=e=>_[`${d}.${e}`]??``,x=(e,t)=>v(n=>({...n,[`${d}.${e}`]:t})),S=p.trim(),C=S.length>0&&l.has(S),T=y.every(e=>b(e.key).length>0),E=S.length>0&&!C&&T;(0,Q.useEffect)(()=>{y.length===0||u.length===0||y.forEach(e=>{if(b(e.key).length>0)return;let t=e.filter?u.filter(e.filter):u;t.length===1&&x(e.key,t[0].value)})},[d,u]);let D=()=>{if(!E)return;let e={};y.forEach(t=>{let n=b(t.key);n&&(e[t.key]=n)});let r={type:d,label:S};Object.keys(e).length>0&&(r[d]=e),n(r),t(!1)};return(0,$.jsx)(De,{open:e,onOpenChange:t,children:(0,$.jsxs)(nt,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,$.jsxs)(Ne,{children:[(0,$.jsx)(hn,{children:o(`console.objectView.createView`)}),(0,$.jsx)(at,{children:o(`console.objectView.createViewDesc`)})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:c.map(({type:e,label:t,description:n,icon:r})=>{let i=e===d;return(0,$.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":i,onClick:()=>f(e),className:ze(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,`hover:border-primary/60 hover:bg-accent/40`,i?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`),children:[(0,$.jsx)(r,{className:ze(`h-5 w-5`,i?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,$.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,$.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:n})]},e)})}),y.length>0&&(0,$.jsx)(`div`,{className:`space-y-2 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:y.map(e=>{let t=b(e.key),n=e.filter?u.filter(e.filter):u,r=u.length>0&&n.length===0;return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[o(e.i18nKey),(0,$.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,$.jsxs)(`select`,{id:`create-view-required-${e.key}`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>x(e.key,t.target.value),disabled:r,className:ze(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,$.jsx)(`option`,{value:``,children:o(`console.objectView.selectField`)}),n.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),r&&(0,$.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,$.jsx)(Se,{className:`h-3 w-3`}),o(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[o(`console.objectView.title`),(0,$.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,$.jsx)(Y,{id:`create-view-name-input`,"data-testid":`create-view-name-input`,autoFocus:!0,value:p,onChange:e=>{m(e.target.value),g(!0)},onKeyDown:e=>{e.key===`Enter`&&E&&D()},placeholder:o(`console.objectView.newView`),className:`h-9`}),C&&(0,$.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:o(`console.objectView.duplicateViewName`)})]}),(0,$.jsxs)(Te,{className:`mt-2`,children:[(0,$.jsx)(X,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:o(`console.objectView.cancel`)}),(0,$.jsx)(X,{type:`button`,disabled:!E,onClick:D,"data-testid":`create-view-submit`,children:o(`console.objectView.create`)})]})]})})}var Ri=(0,Q.lazy)(()=>l(()=>import(`./plugin-charts-BvZ1cSiZ.js`).then(e=>e.t).then(e=>({default:e.ObjectChart})),__vite__mapDeps([0]))),zi={grid:Kt,kanban:sn,calendar:ln,gallery:kn,timeline:ye,gantt:wt,map:Re,chart:me},Bi={id:`current-user`,name:`Demo User`};function Vi({objectDef:e,recordId:t,dataSource:n,onEdit:r}){let{user:i}=M(),a=i?{id:i.id,name:i.name,avatar:i.image}:Bi,[o,s]=(0,Q.useState)([]);(0,Q.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,Q.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,Q.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,Q.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,$.jsxs)(`div`,{className:`h-full bg-background overflow-auto p-3 sm:p-4 lg:p-6`,children:[(0,$.jsx)(Bn,{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,$.jsx)(`div`,{className:`mt-6 border-t pt-6`,children:(0,$.jsx)(zn,{config:{position:`bottom`,collapsible:!0,defaultCollapsed:!0,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:o,onAddComment:c,onAddReply:l,onToggleReaction:u})})]})}function Hi({dataSource:e,objects:t,onEdit:n}){let r=g(),{objectName:i,viewId:o}=a(),[s,c]=f(),{showDebug:l}=Mi(),{t:u}=w(),{objectLabel:d,objectDescription:p}=re(),[m,h]=(0,Q.useState)(!1),[_,y]=(0,Q.useState)(`edit`),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),D=(0,Q.useCallback)(t=>{if(E(t),P(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]),k=(0,Q.useCallback)(async n=>{try{let a;if(e?.create){let r=t?.find?.(e=>e.name===i),o=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]),s=[];Array.isArray(r?.compactLayout)&&r.compactLayout.length>0?s=r.compactLayout.filter(e=>r.fields?.[e]):r?.fields&&(s=Object.entries(r.fields).filter(([e,t])=>t&&!t.hidden&&!o.has(e)).map(([e])=>e).slice(0,5));let c=Array.isArray(n.columns)&&n.columns.length>0?n.columns:s,l={objectName:i,...n,columns:c},u=await e.create(`sys_view`,l);a=u?.id??u?._id}h(!1),y(`edit`),P(e=>e+1),a&&(o?r(`../${a}`,{relative:`path`}):r(`view/${a}`))}catch(e){console.error(`[ViewConfigPanel] Failed to create view:`,e)}},[e,i,t,r,o]),[A,ee]=(0,Q.useState)(void 0),{user:ne}=M(),j=ne?.role===`admin`,{can:ie}=se(),N=t.find(e=>e.name===i);if(!N)return(0,$.jsx)(`div`,{className:`h-full p-4 flex items-center justify-center`,children:(0,$.jsxs)(vn,{children:[(0,$.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,$.jsx)(Kt,{className:`h-6 w-6 text-muted-foreground`})}),(0,$.jsx)(xt,{children:u(`console.objectView.objectNotFound`)}),(0,$.jsxs)(Gt,{children:[u(`console.objectView.objectNotFoundDescription`,{objectName:i}),` `,u(`console.objectView.objectNotFoundHint`)]})]})});let[ae,P]=(0,Q.useState)(0),[F,oe]=(0,Q.useState)([]);(0,Q.useEffect)(()=>{let t=!1;if(!e?.find||!i){oe([]);return}return e.find(`sys_view`,{$filter:[`objectName`,`=`,i],$orderby:[{field:`created_at`,order:`asc`}],$top:200}).then(e=>{t||oe((Array.isArray(e)?e:Array.isArray(e?.data)?e.data:Array.isArray(e?.records)?e.records:Array.isArray(e?.value)?e.value:[]).filter(e=>e&&e.objectName===i))}).catch(e=>{console.error(`[ObjectView] Failed to load sys_view records:`,e),t||oe([])}),()=>{t=!0}},[e,i,ae]);let L=(0,Q.useMemo)(()=>{let e=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]),t=()=>Array.isArray(N.compactLayout)&&N.compactLayout.length>0?N.compactLayout.filter(e=>N.fields?.[e]):N.fields?Object.entries(N.fields).filter(([t,n])=>!(!n||n.hidden||e.has(t))).map(([e])=>e).slice(0,5):[],n=N.listViews||N.list_views||{},r=Object.entries(n).map(([e,t])=>({id:e,...t,type:t.type||`grid`}));r.length===0&&r.push({id:`all`,label:u(`console.objectView.allRecords`),type:`grid`,columns:t()});let i=new Set(r.map(e=>e.id));for(let e of F){let t=e.id||e._id;if(!t)continue;let n={label:e.label||e.name||t,type:e.type||`grid`,columns:e.columns,filter:e.filter,sort:e.sort,showSearch:e.showSearch,showFilters:e.showFilters,showSort:e.showSort,isPinned:e.isPinned,isDefault:e.isDefault,visibility:e.visibility,sortOrder:e.sortOrder,...e,id:t};if(i.has(t)){let e=r.findIndex(e=>e.id===t);r[e]={...r[e],...n}}else r.push(n)}let a=new Set([`grid`,`list`,`table`]);for(let e of r)a.has(e.type)&&(!Array.isArray(e.columns)||e.columns.length===0)&&(e.columns=t());let o=new Map(r.map((e,t)=>[e.id,t])),s=[];try{let e=typeof window<`u`?window.localStorage?.getItem(`viewOrder:${N.name}`):null;e&&(s=JSON.parse(e))}catch{}let c=new Map(s.map((e,t)=>[e,t]));return r.sort((e,t)=>{let n=c.get(e.id),r=c.get(t.id);if(n!==void 0&&r!==void 0)return n-r;if(n!==void 0)return-1;if(r!==void 0)return 1;let i=F.find(t=>(t.id||t._id)===e.id),a=F.find(e=>(e.id||e._id)===t.id);if(!i&&!a)return(o.get(e.id)??0)-(o.get(t.id)??0);if(!i)return-1;if(!a)return 1;let s=typeof i.sortOrder==`number`?i.sortOrder:2**53-1,l=typeof a.sortOrder==`number`?a.sortOrder:2**53-1;return s===l?(i.created_at||``).localeCompare(a.created_at||``):s-l}),r},[N,F,u]),ce=(0,Q.useMemo)(()=>L.find(e=>e.isDefault)?.id,[L]),R=o||s.get(`view`)||ce||L[0]?.id,B=L.find(e=>e.id===R)||L[0],V=T&&T.id===B?.id?{...B,...T}:B,fe=(0,Q.useCallback)((e,t)=>{E(n=>({...n||{},id:B?.id,[e]:t}))},[B?.id]),U=e=>{let t=L.find(t=>t.id===e);t&&(t.id!==R&&h(!1),o?r(`../${t.id}`,{relative:`path`}):r(`view/${t.id}`))},pe=(0,Q.useCallback)(()=>{x(!0)},[]),me=(0,Q.useCallback)((e,t)=>{if(e===`settings`){let e=L.find(e=>e.type===t);e&&U(e.id),y(`edit`),h(!0)}},[L,U]),he=(0,Q.useCallback)(e=>F.some(t=>(t.id||t._id)===e),[F]),ge=(0,Q.useCallback)(async(t,n)=>{if(e?.update){if(!he(t)){z.error(u(`console.objectView.cannotEditMetaView`)||`Built-in views cannot be renamed.`);return}try{await e.update(`sys_view`,t,{label:n}),P(e=>e+1)}catch(e){console.error(`[ViewTabBar] Failed to rename view:`,e),z.error(`Failed to rename view`)}}},[e,he,u]),[_e,ve]=(0,Q.useState)({open:!1,message:``}),[ye,W]=(0,Q.useState)({open:!1,params:[]}),be=(0,Q.useCallback)((e,t)=>new Promise(n=>{ve({open:!0,message:e,options:t,resolve:n})}),[]),xe=(0,Q.useCallback)(e=>new Promise(t=>{W({open:!0,params:e,resolve:t})}),[]),Se=(0,Q.useCallback)(async t=>{if(!e?.delete)return;if(!he(t)){z.error(u(`console.objectView.cannotDeleteMetaView`)||`Built-in views cannot be deleted.`);return}let n=L.find(e=>e.id===t)?.label||t;if(await be(u(`console.objectView.deleteViewConfirm`,{name:n})||`Are you sure you want to delete the view "${n}"? This cannot be undone.`,{title:u(`console.objectView.deleteViewTitle`)||`Delete view`,confirmText:u(`console.objectView.delete`)||`Delete`,cancelText:u(`console.objectView.cancel`)||`Cancel`}))try{if(await e.delete(`sys_view`,t),t===R){let e=L.find(e=>e.id!==t);e&&r(o?`../${e.id}`:`view/${e.id}`,o?{relative:`path`}:void 0)}P(e=>e+1)}catch(e){console.error(`[ViewTabBar] Failed to delete view:`,e),z.error(`Failed to delete view`)}},[e,he,R,L,o,r,u,be]),Ce=(0,Q.useCallback)(async t=>{if(!e?.create)return;let n=L.find(e=>e.id===t);if(n)try{let{id:a,created_at:s,updated_at:c,...l}=n,u=`view_${Date.now()}`,d={...l,objectName:i,id:u,label:`${n.label||t} (Copy)`,isDefault:!1,isPinned:!1};await e.create(`sys_view`,d),P(e=>e+1),o?r(`../${u}`,{relative:`path`}):r(`view/${u}`)}catch(e){console.error(`[ViewTabBar] Failed to duplicate view:`,e),z.error(`Failed to duplicate view`)}},[e,L,i,r,o]),we=(0,Q.useCallback)(async(t,n)=>{if(e?.update){if(!he(t)){z.error(u(`console.objectView.cannotEditMetaView`)||`Built-in views cannot be pinned.`);return}try{await e.update(`sys_view`,t,{isPinned:n}),P(e=>e+1)}catch(e){console.error(`[ViewTabBar] Failed to pin view:`,e)}}},[e,he,u]),Te=(0,Q.useCallback)(async t=>{if(e?.update)try{let n=F.filter(e=>(e.id||e._id)!==t&&e.isDefault).map(t=>e.update(`sys_view`,t.id||t._id,{isDefault:!1}));he(t)&&n.push(e.update(`sys_view`,t,{isDefault:!0})),await Promise.all(n),P(e=>e+1)}catch(e){console.error(`[ViewTabBar] Failed to set default view:`,e),z.error(`Failed to set default view`)}},[e,F,he]),Ee=(0,Q.useCallback)(async t=>{try{typeof window<`u`&&window.localStorage?.setItem(`viewOrder:${i}`,JSON.stringify(t))}catch{}if(e?.update){let n=new Set(F.map(e=>e.id||e._id)),r=t.filter(e=>n.has(e)).map((t,n)=>e.update(`sys_view`,t,{sortOrder:n}));try{await Promise.all(r)}catch(e){console.error(`[ViewTabBar] Failed to reorder views:`,e)}}P(e=>e+1)},[e,F,i]),De=(0,Q.useCallback)(e=>{e!==R&&U(e),y(`edit`),h(!0)},[R,U]),G=(0,Q.useCallback)(()=>{x(!0)},[]),Oe=br({objectName:N.name,objectLabel:N.label,dataSource:e,onEdit:n,onRefresh:()=>P(e=>e+1)}),ke=ne?{id:ne.id,name:ne.name,avatar:ne.image}:Bi,Ae=(0,Q.useCallback)((e,t)=>{t?.type===`error`?z.error(e):z.success(e)},[]),je=(0,Q.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):r(e)},[r]),Me=(0,Q.useCallback)(async t=>{try{let n=t.target||t.name,r=t.params||{};typeof e.execute==`function`?await e.execute(N.name,n,r):r.recordId&&Object.keys(r).length>1&&typeof e.update==`function`&&await e.update(N.name,r.recordId,r);let i=t.refreshAfter!==!1;return i&&P(e=>e+1),{success:!0,reload:i}}catch(e){return{success:!1,error:e.message}}},[e,N.name]),Ne=(0,Q.useMemo)(()=>I(),[]),Pe=(0,Q.useCallback)(async e=>{let t=e.target||e.name;if(!t)return{success:!1,error:`No flow target provided for flow action`};try{let n=e.params||{},r=await Ne(`https://demo.objectstack.ai/api/v1/automation/${encodeURIComponent(t)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:n.recordId,objectName:N.name,params:n})}),i=await r.json().catch(()=>null);if(!r.ok||i&&i.success===!1)return{success:!1,error:i?.error||`Flow "${t}" failed (HTTP ${r.status})`};let a=e.refreshAfter!==!1;return a&&P(e=>e+1),{success:!0,data:i?.data,reload:a}}catch(e){return{success:!1,error:e.message}}},[Ne,N.name]),Fe=(0,Q.useCallback)(async e=>{let t=e.target||e.name;if(!t)return{success:!1,error:`No action target provided`};let n=e.params&&!Array.isArray(e.params)?e.params:{};try{let r=e.objectName||N.name||`global`,i=await Ne(`https://demo.objectstack.ai/api/v1/actions/${encodeURIComponent(r)}/${encodeURIComponent(t)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:n.recordId,params:n})}),a=await i.json().catch(()=>null);if(!i.ok||a&&a.success===!1)return{success:!1,error:a?.error||`Action "${t}" failed (HTTP ${i.status})`};let o=e.refreshAfter!==!1;return o&&P(e=>e+1),{success:!0,data:a?.data,reload:o}}catch(e){return{success:!1,error:e.message}}},[Ne,N.name]),{lastMessage:Ie}=de({channel:`object:${N.name}`}),{hasConflicts:Le,resolveAllConflicts:Re}=le(N.name?`user-${N.name}`:`current-user`);(0,Q.useEffect)(()=>{Ie&&(Le&&Re(`remote`),P(e=>e+1))},[Ie,Le,Re]),(0,Q.useEffect)(()=>{e?.find&&N.name&&e.find(N.name,{limit:0}).then(e=>{typeof e?.total==`number`?ee(e.total):Array.isArray(e?.data)?ee(e.data.length):Array.isArray(e)&&ee(e.length)}).catch(()=>{})},[e,N.name,ae]);let ze=(0,Q.useMemo)(()=>V?.navigation??N.navigation??{mode:`page`},[V?.navigation,N.navigation]),Be=s.get(`recordId`),Ve=(0,Q.useCallback)((e,t)=>{if(t===`new_window`){let t=window.location.pathname.replace(/\/view\/.*$/,``);window.open(`${t}/record/${encodeURIComponent(String(e))}`,`_blank`);return}o?r(`../../record/${encodeURIComponent(String(e))}`,{relative:`path`}):r(`record/${encodeURIComponent(String(e))}`)},[r,o]),K=te({navigation:ze,objectName:N.name,onNavigate:Ve}),He=()=>{K.close();let e=new URLSearchParams(s);e.delete(`recordId`),c(e)};(0,Q.useEffect)(()=>{Be&&!K.isOpen?K.open({id:Be}):!Be&&K.isOpen&&K.close()},[Be]);let Ue=(0,Q.useCallback)(({schema:e,dataSource:t,onEdit:n,className:r,refreshKey:a})=>{let o=ae+(a||0),s=`${i}-${V.id}-${o}`,c=V;if(c.type===`chart`){let e=c.chart||{};return(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading chart…`}),children:(0,$.jsx)(Ri,{dataSource:t,schema:{type:`object-chart`,objectName:N.name,chartType:e.chartType,xAxisField:e.xAxisField,yAxisFields:e.yAxisFields,aggregation:e.aggregation,series:e.series,config:e.config,filter:e.filter}})},s)}return(0,$.jsx)(Vn,{schema:{...e,rowHeight:c.rowHeight??e.rowHeight,densityMode:c.densityMode??e.densityMode,inlineEdit:c.inlineEdit??c.editRecordsInline??e.inlineEdit,appearance:c.showDescription==null?e.appearance:{showDescription:c.showDescription},showSearch:c.showSearch??e.showSearch,showSort:c.showSort??e.showSort,showFilters:c.showFilters??e.showFilters,showHideFields:c.showHideFields??e.showHideFields,showGroup:c.showGroup??e.showGroup,showColor:c.showColor??e.showColor,showDensity:c.showDensity??e.showDensity,allowExport:c.allowExport??e.allowExport,exportOptions:c.allowExport===!1?void 0:c.exportOptions??e.exportOptions,striped:c.striped??e.striped,bordered:c.bordered??e.bordered,color:c.color??e.color,wrapHeaders:c.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:c.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:c.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:c.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:c.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:c.fieldTextColor??e.fieldTextColor,prefixField:c.prefixField??e.prefixField,showDescription:c.showDescription??e.showDescription,navigation:c.navigation??e.navigation,selection:c.selection??e.selection,pagination:c.pagination??e.pagination,searchableFields:c.searchableFields??e.searchableFields,filterableFields:c.filterableFields??e.filterableFields,resizable:c.resizable??e.resizable,hiddenFields:c.hiddenFields??e.hiddenFields,rowActions:c.rowActions??e.rowActions,bulkActions:c.bulkActions??e.bulkActions,sharing:c.sharing??e.sharing,addRecord:c.addRecord??e.addRecord,conditionalFormatting:c.conditionalFormatting??e.conditionalFormatting,quickFilters:c.quickFilters??e.quickFilters,userFilters:c.userFilters??e.userFilters,showRecordCount:c.showRecordCount??e.showRecordCount,allowPrinting:c.allowPrinting??e.allowPrinting,virtualScroll:c.virtualScroll??e.virtualScroll,emptyState:c.emptyState??e.emptyState,aria:c.aria??e.aria,tabs:e.tabs,...c.filter?.length?{filters:c.filter}:{},...c.sort?.length?{sort:c.sort}:{},options:{kanban:{groupBy:c.kanban?.groupByField||c.kanban?.groupField||`status`,groupField:c.kanban?.groupByField||c.kanban?.groupField||`status`,titleField:c.kanban?.titleField||N.titleField||`name`,cardFields:c.kanban?.columns},calendar:{startDateField:c.calendar?.startDateField||`due_date`,endDateField:c.calendar?.endDateField,titleField:c.calendar?.titleField||`name`,colorField:c.calendar?.colorField,allDayField:c.calendar?.allDayField,defaultView:c.calendar?.defaultView},timeline:{dateField:c.timeline?.dateField||`due_date`,titleField:c.timeline?.titleField||N.titleField||`name`,descriptionField:c.timeline?.descriptionField},map:{locationField:c.map?.locationField,titleField:c.map?.titleField||N.titleField||`name`,latitudeField:c.map?.latitudeField,longitudeField:c.map?.longitudeField,zoom:c.map?.zoom,center:c.map?.center},gallery:{imageField:c.gallery?.imageField||`image`,titleField:c.gallery?.titleField||N.titleField||`name`,subtitleField:c.gallery?.subtitleField},gantt:{startDateField:c.gantt?.startDateField||`start_date`,endDateField:c.gantt?.endDateField||`end_date`,titleField:c.gantt?.titleField||`name`,progressField:c.gantt?.progressField,dependenciesField:c.gantt?.dependenciesField,colorField:c.gantt?.colorField},chart:{chartType:c.chart?.chartType,xAxisField:c.chart?.xAxisField,yAxisFields:c.chart?.yAxisFields,aggregation:c.chart?.aggregation,series:c.chart?.series,config:c.chart?.config}}},className:r,onEdit:n,onRowClick:e=>{K.handleClick(e)},dataSource:t},s)},[V,N,i,ae,K]),We=(0,Q.useMemo)(()=>L.map(e=>e.id===R&&T&&T.id===e.id?{...e,...T}:e),[L,R,T]),Ge=(0,Q.useMemo)(()=>({type:`object-view`,objectName:N.name,layout:`page`,showSearch:V?.showSearch!==!1,showFilters:V?.showFilters!==!1,showSort:V?.showSort!==!1,showCreate:!1,showRefresh:!0,allowCreateView:j,viewActions:j?[{type:`settings`},{type:`share`},{type:`duplicate`},{type:`delete`}]:[],onNavigate:(e,t)=>{t===`edit`?n?.({id:e}):t===`view`&&(o?r(`../../record/${encodeURIComponent(String(e))}`,{relative:`path`}):r(`record/${encodeURIComponent(String(e))}`))}}),[N.name,n,V?.showSearch,V?.showFilters,V?.showSort,r,o,j]);return(0,$.jsxs)(O,{context:{objectName:N.name,user:ke},onConfirm:be,onToast:Ae,onNavigate:je,onParamCollection:xe,handlers:{api:Me,flow:Pe,script:Fe,modal:Fe},children:[(0,$.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,children:[(0,$.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,$.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`bg-primary/10 p-1.5 sm:p-2 rounded-md shrink-0`,children:(0,$.jsx)(Kr(N?.icon),{className:`h-4 w-4 text-primary`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`text-base sm:text-lg font-semibold tracking-tight text-foreground truncate`,children:d(N)}),N.description&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground truncate hidden sm:block max-w-md`,children:p(N)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:[ie(N.name,`create`)&&(0,$.jsxs)(X,{size:`sm`,onClick:Oe.create,className:`shadow-none gap-1.5 sm:gap-2 h-8 sm:h-9`,children:[(0,$.jsx)(Yt,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:u(`console.objectView.new`)})]}),N.actions?.some(e=>e.locations?.includes(`list_toolbar`))&&(0,$.jsx)(v,{schema:{type:`action:bar`,location:`list_toolbar`,actions:N.actions,size:`sm`,variant:`outline`}})]})]}),L.length>=1&&(()=>{let e=L.map(e=>{let t=F.find(t=>(t.id||t._id)===e.id);return{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,isDefault:!!(t?.isDefault??e.isDefault),isPinned:!!(t?.isPinned??e.isPinned),visibility:t?.visibility??e.visibility}});return(0,$.jsxs)(`div`,{className:`border-b px-3 sm:px-4 bg-background overflow-x-auto shrink-0`,children:[(0,$.jsx)(Xn,{views:e,activeViewId:R,onViewChange:U,viewTypeIcons:zi,config:{reorderable:!1,showAddButton:j,showPinnedSection:!0,showVisibilityGroups:!0},onAddView:j?G:void 0,onRenameView:j?ge:void 0,onDeleteView:j?Se:void 0,onDuplicateView:j?Ce:void 0,onPinView:j?we:void 0,onSetDefaultView:j?Te:void 0,onConfigView:j?De:void 0,onManageViews:j?()=>C(!0):void 0}),j&&(0,$.jsx)(Jn,{open:S,onOpenChange:C,views:e,activeViewId:R,viewTypeIcons:zi,onRename:ge,onDelete:Se,onDuplicate:Ce,onSetDefault:Te,onSetPinned:we,onReorder:Ee,onAddView:G,onConfigView:De})]})})(),(0,$.jsxs)(`div`,{className:`flex-1 overflow-hidden relative flex flex-row`,children:[K.mode===`split`&&K.isOpen?(0,$.jsx)(on,{...K,setIsOpen:e=>{e||He()},title:d(N),mainContent:(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 relative h-full flex flex-col`,children:[(0,$.jsx)(`div`,{className:`flex-1 relative overflow-auto p-3 sm:p-4`,children:(0,$.jsx)(Gn,{schema:Ge,dataSource:e,views:We,activeViewId:R,onViewChange:U,onEdit:e=>n?.(e),onRowClick:e=>{K.handleClick(e)},renderListView:Ue,onCreateView:pe,onViewAction:me})}),typeof A==`number`&&(0,$.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:A})})]}),children:t=>(0,$.jsx)(Vi,{objectDef:N,recordId:t.id||t._id,dataSource:e,onEdit:n})}):(0,$.jsx)(`div`,{className:`flex-1 min-w-0 relative h-full flex flex-col`,children:(0,$.jsx)(`div`,{className:`flex-1 relative overflow-auto p-3 sm:p-4`,children:(0,$.jsx)(Gn,{schema:Ge,dataSource:e,views:We,activeViewId:R,onViewChange:U,onEdit:e=>n?.(e),onRowClick:e=>{K.handleClick(e)},renderListView:Ue,onCreateView:pe,onViewAction:me})})}),(0,$.jsx)(ji,{open:l&&j,sections:[{title:`View Configuration`,data:V},{title:`Object Definition`,data:N}]}),(0,$.jsx)(`div`,{"data-testid":`view-config-panel-wrapper`,className:`transition-[max-width,opacity] duration-300 ease-in-out overflow-hidden ${m&&j?`max-w-[280px] opacity-100`:`max-w-0 opacity-0`}`,children:(0,$.jsx)(Ni,{open:m&&j,onClose:()=>{h(!1),y(`edit`)},mode:_,activeView:V,objectDef:N,recordCount:A,onSave:D,onViewUpdate:fe,onCreate:k})}),(0,$.jsx)(Li,{open:b&&j,onOpenChange:x,existingLabels:L.map(e=>e.label).filter(Boolean),objectDef:N,onCreate:e=>k(e)})]}),K.mode!==`split`&&(0,$.jsx)(on,{...K,setIsOpen:e=>{e||He()},title:N.label,className:K.mode===`drawer`?`w-[90vw] sm:max-w-2xl p-0 overflow-hidden`:void 0,children:t=>(0,$.jsx)(Vi,{objectDef:N,recordId:t.id||t._id,dataSource:e,onEdit:n})})]}),(0,$.jsx)(H,{state:_e,onOpenChange:e=>{e||ve({open:!1,message:``})}}),(0,$.jsx)(ue,{state:ye,onOpenChange:e=>{e||W({open:!1,params:[]})}})]})}function Ui({cards:e=6}){return(0,$.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(G,{className:`h-7 w-56`}),(0,$.jsx)(G,{className:`h-4 w-80`})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:Array.from({length:4}).map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-2`,children:[(0,$.jsx)(G,{className:`h-4 w-20`}),(0,$.jsx)(G,{className:`h-8 w-24`}),(0,$.jsx)(G,{className:`h-3 w-16`})]},`stat-${t}`))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:e}).map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{className:`h-5 w-32`}),(0,$.jsx)(G,{className:`h-5 w-5 rounded-full`})]}),(0,$.jsx)(G,{className:`h-40 w-full`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(G,{className:`h-3 w-16`}),(0,$.jsx)(G,{className:`h-3 w-12`})]})]},`widget-${t}`))})]})}function Wi({fields:e=8,columns:t=2}){return(0,$.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(G,{className:`h-8 w-8 rounded`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(G,{className:`h-6 w-48`}),(0,$.jsx)(G,{className:`h-4 w-32`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(G,{className:`h-9 w-20`}),(0,$.jsx)(G,{className:`h-9 w-20`})]})]}),(0,$.jsx)(G,{className:`h-5 w-24`}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 ${t===2?`md:grid-cols-2`:``} gap-4`,children:Array.from({length:e}).map((e,t)=>(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(G,{className:`h-4 w-24`}),(0,$.jsx)(G,{className:`h-9 w-full`})]},`field-${t}`))}),(0,$.jsxs)(`div`,{className:`space-y-3 pt-4 border-t`,children:[(0,$.jsx)(G,{className:`h-5 w-32`}),(0,$.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,$.jsx)(G,{className:`h-8 w-8 rounded-full`}),(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsx)(G,{className:`h-4 w-40`}),(0,$.jsx)(G,{className:`h-3 w-24`})]})]},`related-${t}`))})]})]})}function Gi(e,t){return{name:e.name,label:e.label,pluralLabel:e.pluralLabel,description:e.description,icon:e.icon,group:e.group,sortOrder:e.sortOrder,enabled:e.enabled,fields:t,relationships:e.relationships}}function Ki(e){return{name:e.name,label:e.label,type:e.type,group:e.group,description:e.description,required:e.required,unique:e.unique,readonly:e.readonly,hidden:e.hidden,defaultValue:e.defaultValue,placeholder:e.placeholder,options:e.options,externalId:e.externalId,trackHistory:e.trackHistory,indexed:e.indexed,referenceTo:e.referenceTo,formula:e.formula,sortOrder:e.sortOrder}}var qi=class{constructor(e){this.adapter=e}async getItems(e){let t=await this.adapter.getClient().meta.getItems(e);return t&&typeof t==`object`&&`items`in t&&Array.isArray(t.items)?t.items:[]}async saveMetadataItem(e,t,n){await this.adapter.getClient().meta.saveItem(e,t,n),this.adapter.invalidateCache(`${e}:${t}`)}async deleteMetadataItem(e,t){await this.adapter.getClient().meta.saveItem(e,t,{name:t,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`${e}:${t}`)}async saveObject(e,t){let n=this.adapter.getClient(),r=Gi(e,t);await n.meta.saveItem(`object`,e.name,r),this.adapter.invalidateCache(`object:${e.name}`)}async deleteObject(e){await this.adapter.getClient().meta.saveItem(`object`,e,{name:e,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`object:${e}`)}async saveFields(e,t){let n=this.adapter.getClient(),r={};try{let t=await n.meta.getItem(`object`,e);r=t?.item??t??{}}catch{}let i={...r,name:e,fields:t.map(Ki)};await n.meta.saveItem(`object`,e,i),this.adapter.invalidateCache(`object:${e}`)}static diffObjects(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,object:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,object:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,object:t}}return null}static diffFields(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,field:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,field:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,field:t}}return null}};function Ji(){let e=D();return(0,Q.useMemo)(()=>e?new qi(e):null,[e])}var Yi=0;function Xi(e=`nav`){return`${e}_${Date.now()}_${++Yi}`}function Zi(e,t){return[...e,t]}function Qi(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:Qi(e.children,t,n)}:e)}function $i(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:$i(i.children,t,n,r)}:i})}function ea(e,t){return e.length===t.length?e===t?!0:JSON.stringify(e)===JSON.stringify(t):!1}function ta(){let e=D(),{apps:t,refresh:n}=A(),r=(0,Q.useRef)(e);r.current=e;let i=(0,Q.useRef)(n);i.current=n;let a=(0,Q.useCallback)(async(e,t)=>{let n=r.current?.getClient();n&&await n.meta.saveItem(`app`,e,t),await i.current?.()},[]),o=(0,Q.useCallback)(e=>t.find(t=>t.name===e),[t]),s=(0,Q.useCallback)(async(e,t,n)=>{let r=o(e);if(!r)return;let i=r.navigation??[],s=Zi(i,{id:Xi(`nav_page`),type:`page`,label:n||t,pageName:t,icon:`FileText`}),c={...r,navigation:s};try{await a(e,c),z.success(`Navigation updated: added page "${n||t}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...r,navigation:i}),z.info(`Navigation change undone`)}catch{z.error(`Failed to undo navigation change`)}}}})}catch{z.error(`Failed to update navigation`)}},[o,a]),c=(0,Q.useCallback)(async(e,t,n)=>{let r=o(e);if(!r)return;let i=r.navigation??[],s=Zi(i,{id:Xi(`nav_dash`),type:`dashboard`,label:n||t,dashboardName:t,icon:`LayoutDashboard`}),c={...r,navigation:s};try{await a(e,c),z.success(`Navigation updated: added dashboard "${n||t}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...r,navigation:i}),z.info(`Navigation change undone`)}catch{z.error(`Failed to undo navigation change`)}}}})}catch{z.error(`Failed to update navigation`)}},[o,a]),l=(0,Q.useCallback)(async(e,t)=>{let n=o(e);if(!n)return;let r=n.navigation??[],i=Qi(r,`page`,t);if(ea(i,r))return;let s={...n,navigation:i};try{await a(e,s),z.success(`Navigation updated: removed page "${t}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...n,navigation:r}),z.info(`Navigation change undone`)}catch{z.error(`Failed to undo navigation change`)}}}})}catch{z.error(`Failed to update navigation`)}},[o,a]),u=(0,Q.useCallback)(async(e,t)=>{let n=o(e);if(!n)return;let r=n.navigation??[],i=Qi(r,`dashboard`,t);if(ea(i,r))return;let s={...n,navigation:i};try{await a(e,s),z.success(`Navigation updated: removed dashboard "${t}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...n,navigation:r}),z.info(`Navigation change undone`)}catch{z.error(`Failed to undo navigation change`)}}}})}catch{z.error(`Failed to update navigation`)}},[o,a]),d=(0,Q.useCallback)(async(e,t,n)=>{let r=o(e);if(!r)return;let i=r.navigation??[],s=$i(i,`page`,t,n);if(ea(s,i))return;let c={...r,navigation:s};try{await a(e,c),z.success(`Navigation updated: renamed page "${t}" → "${n}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...r,navigation:i}),z.info(`Navigation change undone`)}catch{z.error(`Failed to undo navigation change`)}}}})}catch{z.error(`Failed to update navigation`)}},[o,a]),f=(0,Q.useCallback)(async(e,t,n)=>{let r=o(e);if(!r)return;let i=r.navigation??[],s=$i(i,`dashboard`,t,n);if(ea(s,i))return;let c={...r,navigation:s};try{await a(e,c),z.success(`Navigation updated: renamed dashboard "${t}" → "${n}"`,{action:{label:`Undo`,onClick:async()=>{try{await a(e,{...r,navigation:i}),z.info(`Navigation change undone`)}catch{z.error(`Failed to undo navigation change`)}}}})}catch{z.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,Q.useCallback)(async(e,n)=>{for(let r of t){let t=p(r);t&&await s(t,e,n)}},[t,s]),syncDashboardCreatedAllApps:(0,Q.useCallback)(async(e,n)=>{for(let r of t){let t=p(r);t&&await c(t,e,n)}},[t,c]),syncPageDeletedAllApps:(0,Q.useCallback)(async e=>{for(let n of t){let t=p(n);t&&await l(t,e)}},[t,l]),syncDashboardDeletedAllApps:(0,Q.useCallback)(async e=>{for(let n of t){let t=p(n);t&&await u(t,e)}},[t,u]),syncPageRenamedAllApps:(0,Q.useCallback)(async(e,n)=>{for(let r of t){let t=p(r);t&&await d(t,e,n)}},[t,d]),syncDashboardRenamedAllApps:(0,Q.useCallback)(async(e,n)=>{for(let r of t){let t=p(r);t&&await f(t,e,n)}},[t,f])}}function na(){let{pages:e,dashboards:t,apps:n}=A(),r=D(),i=(0,Q.useRef)(r);i.current=r;let{syncPageCreated:a,syncDashboardCreated:o,syncPageDeleted:s,syncDashboardDeleted:c}=ta(),l=(0,Q.useRef)(null),u=(0,Q.useRef)(null),d=(0,Q.useRef)(0),f=(0,Q.useRef)(!1),p=e=>e&&typeof e==`object`&&`name`in e?e.name:void 0;return(0,Q.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}var ra=(0,Q.lazy)(()=>l(()=>import(`./RecordDetailView-cFSCvmx3.js`).then(e=>e.t).then(e=>({default:e.RecordDetailView})),__vite__mapDeps([0,1]))),ia=(0,Q.lazy)(()=>l(()=>import(`./DashboardView-CODdYLuL.js`).then(e=>e.t).then(e=>({default:e.DashboardView})),__vite__mapDeps([0,1]))),aa=(0,Q.lazy)(()=>l(()=>import(`./PageView-DZHuurne.js`).then(e=>e.t).then(e=>({default:e.PageView})),__vite__mapDeps([0]))),oa=(0,Q.lazy)(()=>l(()=>import(`./ReportView-oYVEbfYq.js`).then(e=>e.t).then(e=>({default:e.ReportView})),__vite__mapDeps([0]))),sa=(0,Q.lazy)(()=>l(()=>import(`./SearchResultsPage-BjAVc5rm.js`).then(e=>e.t).then(e=>({default:e.SearchResultsPage})),__vite__mapDeps([0]))),ca=(0,Q.lazy)(()=>l(()=>import(`./src-iMF4J4F7.js`).then(e=>e.t).then(e=>({default:e.CreateAppPage})),__vite__mapDeps([0]))),la=(0,Q.lazy)(()=>l(()=>import(`./src-iMF4J4F7.js`).then(e=>e.t).then(e=>({default:e.EditAppPage})),__vite__mapDeps([0]))),ua=(0,Q.lazy)(()=>l(()=>import(`./src-iMF4J4F7.js`).then(e=>e.t).then(e=>({default:e.PageDesignPage})),__vite__mapDeps([0]))),da=(0,Q.lazy)(()=>l(()=>import(`./src-iMF4J4F7.js`).then(e=>e.t).then(e=>({default:e.DashboardDesignPage})),__vite__mapDeps([0])));function fa({extraRoutes:e,extraRoutesNoApp:t}={}){let[i,o]=(0,Q.useState)(`disconnected`),{user:s}=M(),l=D(),u=g(),d=c(),{appName:f}=a(),{apps:p,objects:h,loading:v,ensureType:b}=A(),{t:x}=w(),{objectLabel:S}=re(),[T,E]=(0,Q.useState)(!b);(0,Q.useEffect)(()=>{if(!b){E(!0);return}let e=!1;return Promise.all([b(`object`),b(`dashboard`),b(`report`),b(`page`)]).finally(()=>{e||E(!0)}),()=>{e=!0}},[b]);let O=p.filter(e=>e.active!==!1),k=p.find(e=>e.name===f)||O.find(e=>e.isDefault===!0)||O[0],[ee,te]=(0,Q.useState)(!1),[j,ie]=(0,Q.useState)(null),[N,ae]=(0,Q.useState)(0),{addRecentItem:P}=Tr(),{execute:F,runner:oe}=C();ne({dataSource:l??void 0,onUndo:e=>{z.info(`Undo: ${e.description}`,{duration:4e3}),ae(e=>e+1)},onRedo:e=>{z.info(`Redo: ${e.description}`,{duration:3e3}),ae(e=>e+1)}}),(0,Q.useEffect)(()=>{oe.registerHandler(`crud_success`,async e=>(te(!1),ae(e=>e+1),z.success(e.params?.message??`Record saved successfully`),{success:!0,reload:!0})),oe.registerHandler(`dialog_cancel`,async()=>(te(!1),{success:!0}))},[oe]),(0,Q.useEffect)(()=>{if(!l)return;let e=l.onConnectionStateChange(e=>{o(e.state),e.error&&console.error(`[Console] Connection error:`,e.error)});return o(l.getConnectionState()),e},[l]);let se=d.pathname.split(`/`).filter(Boolean)[2];(se===`view`||se===`record`||se===`page`||se===`dashboard`||se===`design`)&&(se=``);let I=h.find(e=>e.name===se),L=(0,Q.useCallback)(()=>{let e=I?S(I):x(`common.record`,{defaultValue:`Record`});F({type:`crud_success`,params:{message:j?x(`form.updateSuccess`,{object:e,defaultValue:`${e} updated successfully`}):x(`form.createSuccess`,{object:e,defaultValue:`${e} created successfully`})}})},[F,j,I,S,x]),ce=(0,Q.useCallback)(()=>{F({type:`dialog_cancel`})},[F]);(0,Q.useEffect)(()=>{if(!k)return;let e=d.pathname.split(`/`).filter(Boolean),t=e[2];(t===`view`||t===`record`||t===`page`||t===`dashboard`||t===`design`)&&(t=``);let n=`/apps/${k.name}`;if(t){let e=h.find(e=>e.name===t);e&&P({id:`object:${e.name}`,label:e.label||e.name,href:`${n}/${e.name}`,type:`object`})}else e[2]===`dashboard`&&e[3]?P({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]&&P({id:`report:${e[3]}`,label:e[3].replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),href:`${n}/report/${e[3]}`,type:`report`})},[d.pathname,P]);let R=e=>{ie(e),te(!0)},le=e=>{u(`/apps/${e}`)},B=(0,Q.useMemo)(()=>new y({user:s?{name:s.name,email:s.email,role:s.role??`user`}:{},app:k||{},data:j||{}}),[s,k,j]);if(!l||v||!T)return(0,$.jsx)(wi,{});let V=d.pathname.endsWith(`/create-app`),ue=d.pathname.includes(`/system`);return!k&&!V&&!ue?(0,$.jsx)(`div`,{className:`h-screen flex items-center justify-center`,children:(0,$.jsxs)(vn,{children:[(0,$.jsx)(xt,{children:`No Apps Configured`}),(0,$.jsx)(Gt,{children:`No applications have been registered. Create your first app or visit System Settings to configure your environment.`}),(0,$.jsxs)(`div`,{className:`mt-4 flex flex-col sm:flex-row items-center gap-3`,children:[(0,$.jsx)(X,{onClick:()=>u(`/create-app`),"data-testid":`create-first-app-btn`,children:`Create Your First App`}),(0,$.jsx)(X,{variant:`outline`,onClick:()=>u(`/apps/setup`),"data-testid":`go-to-settings-btn`,children:`System Settings`})]})]})}):!k&&(V||ue)?(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(wi,{}),children:(0,$.jsxs)(r,{children:[(0,$.jsx)(m,{path:`create-app`,element:(0,$.jsx)(ca,{})}),t]})}):(0,$.jsxs)(_r,{user:s?{name:s.name,email:s.email,role:s.role??`user`}:{name:`Anonymous`,email:``,role:`guest`},app:k,data:{},children:[(0,$.jsx)(na,{}),(0,$.jsxs)(vi,{activeAppName:k.name,activeApp:k,onAppChange:le,objects:h,connectionState:i,children:[(0,$.jsx)(yi,{apps:p,activeApp:k,objects:h,onAppChange:le}),(0,$.jsx)(xi,{}),(0,$.jsx)(Si,{}),(0,$.jsxs)(_,{dataSource:l||{},children:[(0,$.jsx)(Ai,{children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(wi,{}),children:(0,$.jsxs)(r,{children:[(0,$.jsx)(m,{path:`/`,element:(0,$.jsx)(n,{to:pa(k.navigation||[]),replace:!0})}),(0,$.jsx)(m,{path:`:objectName`,element:(0,$.jsx)(Hi,{dataSource:l,objects:h,onEdit:R})}),(0,$.jsx)(m,{path:`:objectName/view/:viewId`,element:(0,$.jsx)(Hi,{dataSource:l,objects:h,onEdit:R})}),(0,$.jsx)(m,{path:`:objectName/record/:recordId`,element:(0,$.jsx)(ra,{dataSource:l,objects:h,onEdit:R},N)}),(0,$.jsx)(m,{path:`dashboard/:dashboardName`,element:(0,$.jsx)(ia,{dataSource:l})}),(0,$.jsx)(m,{path:`report/:reportName`,element:(0,$.jsx)(oa,{dataSource:l})}),(0,$.jsx)(m,{path:`page/:pageName`,element:(0,$.jsx)(aa,{})}),(0,$.jsx)(m,{path:`design/page/:pageName`,element:(0,$.jsx)(ua,{})}),(0,$.jsx)(m,{path:`design/dashboard/:dashboardName`,element:(0,$.jsx)(da,{})}),(0,$.jsx)(m,{path:`search`,element:(0,$.jsx)(sa,{})}),(0,$.jsx)(m,{path:`create-app`,element:(0,$.jsx)(ca,{})}),(0,$.jsx)(m,{path:`edit-app/:editAppName`,element:(0,$.jsx)(la,{})}),e]})})}),I&&(0,$.jsx)(Un,{schema:{type:`object-form`,formType:`modal`,objectName:I.name,mode:j?`edit`:`create`,recordId:j?.id,title:x(j?`form.editTitle`:`form.createTitle`,{object:S(I)}),description:x(j?`form.editDescription`:`form.createDescription`,{object:S(I)}),open:ee,onOpenChange:te,layout:`vertical`,fields:I.fields?Array.isArray(I.fields)?I.fields.filter(e=>typeof e==`string`?!0:yr(e.visible,B)).map(e=>typeof e==`string`?e:e.name):Object.entries(I.fields).filter(([e,t])=>yr(t.visible,B)).map(([e])=>e):[],onSuccess:L,onCancel:ce,showSubmit:!0,showCancel:!0,submitText:x(`form.saveRecord`),cancelText:x(`common.cancel`)},dataSource:l},j?.id||`new`)]})]})]})}function pa(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=pa(t.children);if(e!==``)return e}}return``}function ma({children:e}){return(0,$.jsxs)(`div`,{className:`flex min-h-screen`,children:[(0,$.jsx)(`div`,{className:`hidden lg:flex lg:w-1/2 items-center justify-center bg-primary p-12`,children:(0,$.jsxs)(`div`,{className:`max-w-md space-y-6 text-primary-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`h-10 w-10`,role:`img`,"aria-label":`ObjectStack logo`,children:[(0,$.jsx)(`title`,{children:`ObjectStack`}),(0,$.jsx)(`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`})]}),(0,$.jsx)(`span`,{className:`text-2xl font-bold`,children:`ObjectStack`})]}),(0,$.jsx)(`h2`,{className:`text-3xl font-bold leading-tight`,children:`Build powerful business applications, faster.`}),(0,$.jsx)(`p`,{className:`text-lg opacity-90`,children:`The universal platform for enterprise data management, workflows, and analytics.`})]})}),(0,$.jsx)(`div`,{className:`flex w-full lg:w-1/2 items-center justify-center bg-background px-6 py-12`,children:e})]})}var ha=({href:e,className:t,children:n})=>(0,$.jsx)(p,{to:e,className:t,children:n});function ga(){let e=g(),{t}=w();return(0,$.jsx)(ma,{children:(0,$.jsx)(P,{onSuccess:()=>e(`/`),registerUrl:`/register`,forgotPasswordUrl:`/forgot-password`,title:t(`auth.login.title`),description:t(`auth.login.description`),linkComponent:ha,labels:{emailLabel:t(`auth.login.emailLabel`),emailPlaceholder:t(`auth.login.emailPlaceholder`),passwordLabel:t(`auth.login.passwordLabel`),passwordPlaceholder:t(`auth.login.passwordPlaceholder`),forgotPasswordText:t(`auth.login.forgotPasswordText`),submitButton:t(`auth.login.submitButton`),submittingButton:t(`auth.login.submittingButton`),noAccountText:t(`auth.login.noAccountText`),signUpText:t(`auth.login.signUpText`)}})})}var _a=({href:e,className:t,children:n})=>(0,$.jsx)(p,{to:e,className:t,children:n});function va(){let e=g(),{t}=w();return(0,$.jsx)(ma,{children:(0,$.jsx)(j,{onSuccess:()=>e(`/`),loginUrl:`/login`,title:t(`auth.register.title`),description:t(`auth.register.description`),linkComponent:_a,labels:{nameLabel:t(`auth.register.nameLabel`),namePlaceholder:t(`auth.register.namePlaceholder`),emailLabel:t(`auth.register.emailLabel`),emailPlaceholder:t(`auth.register.emailPlaceholder`),passwordLabel:t(`auth.register.passwordLabel`),passwordPlaceholder:t(`auth.register.passwordPlaceholder`),confirmPasswordLabel:t(`auth.register.confirmPasswordLabel`),confirmPasswordPlaceholder:t(`auth.register.confirmPasswordPlaceholder`),passwordMismatchError:t(`auth.register.passwordMismatchError`),passwordTooShortError:t(`auth.register.passwordTooShortError`),submitButton:t(`auth.register.submitButton`),submittingButton:t(`auth.register.submittingButton`),hasAccountText:t(`auth.register.hasAccountText`),signInText:t(`auth.register.signInText`)}})})}var ya=({href:e,className:t,children:n})=>(0,$.jsx)(p,{to:e,className:t,children:n});function ba(){let{t:e}=w();return(0,$.jsx)(ma,{children:(0,$.jsx)(ie,{loginUrl:`/login`,title:e(`auth.forgotPassword.title`),description:e(`auth.forgotPassword.description`),linkComponent:ya,labels:{emailLabel:e(`auth.forgotPassword.emailLabel`),emailPlaceholder:e(`auth.forgotPassword.emailPlaceholder`),submitButton:e(`auth.forgotPassword.submitButton`),submittingButton:e(`auth.forgotPassword.submittingButton`),successTitle:e(`auth.forgotPassword.successTitle`),successDescription:e(`auth.forgotPassword.successDescription`),backToSignInText:e(`auth.forgotPassword.backToSignInText`),rememberPasswordText:e(`auth.forgotPassword.rememberPasswordText`),signInText:e(`auth.forgotPassword.signInText`)}})})}function xa({children:e}){let{setContext:t}=B();return(0,Q.useEffect)(()=>{t(`home`)},[t]),(0,$.jsxs)(`div`,{className:`flex min-h-svh w-full flex-col bg-background`,"data-testid":`home-layout`,children:[(0,$.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:(0,$.jsx)(fi,{variant:`home`})}),(0,$.jsx)(`main`,{className:`flex-1 min-w-0 overflow-auto`,children:e})]})}function Sa(){let e=g(),{t}=w(),n=[{id:`create-app`,label:t(`home.quickActions.createApp`,{defaultValue:`Create App`}),description:t(`home.quickActions.createAppDesc`,{defaultValue:`Start with a new application`}),icon:Yt,href:`/create-app`,color:`text-blue-600 dark:text-blue-400`},{id:`manage-objects`,label:t(`home.quickActions.manageObjects`,{defaultValue:`Manage Objects`}),description:t(`home.quickActions.manageObjectsDesc`,{defaultValue:`Configure data models`}),icon:ve,href:`/apps/setup/system/metadata/object`,color:`text-purple-600 dark:text-purple-400`},{id:`system-settings`,label:t(`home.quickActions.systemSettings`,{defaultValue:`System Settings`}),description:t(`home.quickActions.systemSettingsDesc`,{defaultValue:`Configure your workspace`}),icon:et,href:`/apps/setup`,color:`text-gray-600 dark:text-gray-400`}];return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight mb-4`,children:t(`home.quickActions.title`,{defaultValue:`Quick Actions`})}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:n.map(t=>{let n=t.icon;return(0,$.jsx)(Ke,{className:`cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>e(t.href),"data-testid":`quick-action-${t.id}`,role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.href))},"aria-label":t.label,children:(0,$.jsx)(U,{className:`p-6`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,$.jsx)(`div`,{className:ze(`p-3 rounded-lg bg-muted`,t.color),children:(0,$.jsx)(n,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`h3`,{className:`font-semibold text-base mb-1`,children:t.label}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.description})]})]})})},t.id)})})]})}function Ca({app:e,onClick:t,isFavorite:n}){let{t:r}=w(),{appLabel:i,appDescription:a}=re(),{toggleFavorite:o}=Mr(),s=Kr(e.icon),c=i({name:e.name,label:Z(e.label,r)}),l=a({name:e.name,description:Z(e.description,r)}),u=e.branding?.primaryColor;return(0,$.jsx)(Ke,{className:`cursor-pointer hover:shadow-lg transition-all group relative`,onClick:t,"data-testid":`app-card-${e.name}`,children:(0,$.jsxs)(U,{className:`p-6`,children:[(0,$.jsx)(X,{variant:`ghost`,size:`sm`,className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity`,onClick:t=>{t.stopPropagation(),o({id:`app:${e.name}`,label:c,href:`/apps/${e.name}`,type:`object`})},"aria-label":n?r(`common.removeFromFavorites`,{defaultValue:`Remove from favorites`})+` — ${c}`:r(`common.addToFavorites`,{defaultValue:`Add to favorites`})+` — ${c}`,"aria-pressed":n,"data-testid":`favorite-btn-${e.name}`,children:n?(0,$.jsx)(Zt,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,$.jsx)(It,{className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:ze(`inline-flex p-3 rounded-lg mb-4`,u?``:`bg-primary/10`),style:u?{backgroundColor:`${u}20`}:{},children:(0,$.jsx)(s,{className:`h-8 w-8`,style:u?{color:u}:{}})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-semibold text-lg mb-1`,children:c}),l&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:l}),!l&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`home.appCard.noDescription`,{defaultValue:`No description`})})]}),e.isDefault&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(Wt,{variant:`secondary`,children:r(`home.appCard.default`,{defaultValue:`Default`})})})]})})}function wa({items:e}){let t=g(),{t:n}=w();return e.length===0?null:(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,$.jsx)(an,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:n(`home.recentApps.title`,{defaultValue:`Recently Accessed`})})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:e.map(e=>{let r=Kr(e.type),i=n(`home.recentApps.itemType.${e.type}`,{defaultValue:Rn(e.type)});return(0,$.jsx)(Ke,{className:`cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>t(e.href),"data-testid":`recent-item-${e.id}`,role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.href))},children:(0,$.jsx)(U,{className:`p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg bg-muted shrink-0`,children:(0,$.jsx)(r,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`h3`,{className:`font-medium text-sm truncate`,children:e.label}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i})]})]})})},e.id)})})]})}function Ta({items:e}){let t=g(),{t:n}=w();return e.length===0?null:(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,$.jsx)(Zt,{className:`h-5 w-5 text-yellow-500 fill-yellow-500`}),(0,$.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:n(`home.starredApps.title`,{defaultValue:`Starred`})})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:e.map(e=>{let n=Kr(e.type);return(0,$.jsx)(Ke,{className:`cursor-pointer hover:shadow-md transition-shadow`,onClick:()=>t(e.href),"data-testid":`starred-item-${e.id}`,role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.href))},children:(0,$.jsx)(U,{className:`p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg bg-muted shrink-0`,children:(0,$.jsx)(n,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`h3`,{className:`font-medium text-sm truncate`,children:e.label}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Rn(e.type)})]})]})})},e.id)})})]})}function Ea(){let e=g(),{t}=w(),{apps:n,loading:r}=A(),{recentItems:i}=Tr(),{favorites:a}=Mr(),o=n.filter(e=>e.active!==!1),s=i.filter(e=>e.type===`object`||e.type===`dashboard`||e.type===`page`).slice(0,6),c=a.filter(e=>e.type===`object`||e.type===`dashboard`||e.type===`page`).slice(0,8);return r?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-20`,children:(0,$.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading workspace...`})}):o.length===0?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6`,children:(0,$.jsxs)(vn,{children:[(0,$.jsx)(xt,{children:`Welcome to ObjectUI`}),(0,$.jsx)(Gt,{children:`Get started by creating your first application or configure your system settings.`}),(0,$.jsxs)(`div`,{className:`mt-6 flex flex-col sm:flex-row items-center gap-3`,children:[(0,$.jsxs)(X,{onClick:()=>e(`/create-app`),"data-testid":`create-first-app-btn`,children:[(0,$.jsx)(Yt,{className:`mr-2 h-4 w-4`}),`Create Your First App`]}),(0,$.jsxs)(X,{variant:`outline`,onClick:()=>e(`/apps/setup`),"data-testid":`go-to-settings-btn`,children:[(0,$.jsx)(et,{className:`mr-2 h-4 w-4`}),`System Settings`]})]})]})}):(0,$.jsxs)(`div`,{className:`bg-background`,children:[(0,$.jsxs)(`div`,{className:`px-4 sm:px-6 pt-6 pb-4`,children:[(0,$.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight`,children:t(`home.title`,{defaultValue:`Home`})}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:t(`home.subtitle`,{defaultValue:`Your workspace dashboard`})})]}),(0,$.jsxs)(`div`,{className:`px-4 sm:px-6 py-4 space-y-8`,children:[(0,$.jsx)(Sa,{}),c.length>0&&(0,$.jsx)(Ta,{items:c}),s.length>0&&(0,$.jsx)(wa,{items:s}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight mb-4`,children:t(`home.allApps`,{defaultValue:`All Applications`})}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:o.map(t=>(0,$.jsx)(Ca,{app:t,onClick:()=>e(`/apps/${t.name}`),isFavorite:a.some(e=>e.id===`app:${t.name}`)},t.name))})]})]})]})}function Da({children:e}){let{setContext:t}=B();return(0,Q.useEffect)(()=>{t(`home`)},[t]),(0,$.jsxs)(`div`,{className:`flex min-h-svh w-full flex-col bg-background`,"data-testid":`organizations-layout`,children:[(0,$.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:(0,$.jsx)(fi,{variant:`orgs`})}),(0,$.jsx)(`main`,{className:`flex-1 min-w-0 overflow-auto`,children:e})]})}function Oa(e){return e.toLowerCase().replace(/[^a-z0-9\s_-]/g,``).replace(/[\s_]+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,48)}function ka({open:e,onOpenChange:t,onCreated:n}){let{t:r}=w(),{createOrganization:i}=M(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null);return(0,Q.useEffect)(()=>{l||c(Oa(a))},[a,l]),(0,Q.useEffect)(()=>{e&&(o(``),c(``),u(!1),m(null))},[e]),(0,$.jsx)(De,{open:e,onOpenChange:t,children:(0,$.jsx)(nt,{className:`sm:max-w-[425px]`,"data-testid":`create-workspace-dialog`,children:(0,$.jsxs)(`form`,{onSubmit:(0,Q.useCallback)(async e=>{if(e.preventDefault(),!(!a.trim()||!s.trim())){f(!0),m(null);try{let e=await i({name:a.trim(),slug:s.trim()});n?.(e)}catch(e){m(e instanceof Error?e.message:`Failed to create workspace`)}finally{f(!1)}}},[a,s,i,n]),children:[(0,$.jsxs)(Ne,{children:[(0,$.jsx)(hn,{children:r(`workspace.createTitle`,{defaultValue:`Create a workspace`})}),(0,$.jsx)(at,{children:r(`workspace.createDescription`,{defaultValue:`A workspace is a shared space for your team to collaborate.`})})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(Tt,{htmlFor:`workspace-name`,children:r(`workspace.nameLabel`,{defaultValue:`Workspace name`})}),(0,$.jsx)(Y,{id:`workspace-name`,placeholder:r(`workspace.namePlaceholder`,{defaultValue:`e.g., Acme Inc`}),value:a,onChange:e=>o(e.target.value),autoFocus:!0,"data-testid":`workspace-name-input`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(Tt,{htmlFor:`workspace-slug`,children:r(`workspace.slugLabel`,{defaultValue:`URL slug`})}),(0,$.jsx)(Y,{id:`workspace-slug`,placeholder:`acme-inc`,value:s,onChange:e=>{c(e.target.value),u(!0)},"data-testid":`workspace-slug-input`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workspace.slugHint`,{defaultValue:`Used in URLs. Only lowercase letters, numbers, and hyphens.`})})]}),p&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,"data-testid":`workspace-create-error`,children:p})]}),(0,$.jsxs)(Te,{children:[(0,$.jsx)(X,{type:`button`,variant:`outline`,onClick:()=>t(!1),disabled:d,children:r(`common.cancel`,{defaultValue:`Cancel`})}),(0,$.jsxs)(X,{type:`submit`,disabled:d||!a.trim()||!s.trim(),"data-testid":`workspace-create-submit`,children:[d&&(0,$.jsx)(q,{className:`mr-2 h-4 w-4 animate-spin`}),r(`workspace.createButton`,{defaultValue:`Create workspace`})]})]})]})})})}function Aa(e){return e.split(/[\s_-]+/).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function ja(){let{t:e}=w(),t=g(),{organizations:n,activeOrganization:r,isOrganizationsLoading:i,switchOrganization:a}=M(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f=n??[],p=(0,Q.useMemo)(()=>{let e=o.trim().toLowerCase();return e?f.filter(t=>t.name.toLowerCase().includes(e)||t.slug?.toLowerCase().includes(e)):f},[f,o]),m=async e=>{d(e.id);try{e.id!==r?.id&&await a(e.id);let t=`/console/`,n=t.endsWith(`/`)?t:`${t}/`;window.location.href=`${window.location.origin}${n}home`}catch(e){console.error(`[OrganizationsPage] Failed to switch:`,e),d(null)}};return i?(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-20`,children:(0,$.jsx)(q,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-5xl px-4 sm:px-6 py-8 sm:py-12`,children:[(0,$.jsxs)(`div`,{className:`mb-8`,children:[(0,$.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight`,children:e(`organizations.heading`,{defaultValue:`Your Organizations`})}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e(`organizations.subtitle`,{defaultValue:`Select an organization to continue, or create a new one.`})})]}),(0,$.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`relative w-full sm:max-w-sm`,children:[(0,$.jsx)(Pe,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(Y,{value:o,onChange:e=>s(e.target.value),placeholder:e(`organizations.searchPlaceholder`,{defaultValue:`Search for an organization`}),className:`pl-9`,"data-testid":`organizations-search`})]}),(0,$.jsxs)(X,{onClick:()=>l(!0),"data-testid":`organizations-new`,children:[(0,$.jsx)(Yt,{className:`mr-2 h-4 w-4`}),e(`organizations.new`,{defaultValue:`New organization`})]})]}),f.length===0?(0,$.jsxs)(vn,{children:[(0,$.jsx)(xt,{children:e(`organizations.emptyTitle`,{defaultValue:`No organizations yet`})}),(0,$.jsx)(Gt,{children:e(`organizations.emptyDescription`,{defaultValue:`Create your first organization to get started.`})}),(0,$.jsxs)(X,{className:`mt-6`,onClick:()=>l(!0),children:[(0,$.jsx)(Yt,{className:`mr-2 h-4 w-4`}),e(`organizations.new`,{defaultValue:`New organization`})]})]}):p.length===0?(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e(`organizations.noMatches`,{defaultValue:`No organizations match your search.`})}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:p.map(n=>{let i=n.id===r?.id,a=u===n.id;return(0,$.jsxs)(`button`,{onClick:()=>m(n),disabled:a,className:`group flex items-center gap-3 rounded-lg border bg-card p-4 text-left transition-colors hover:border-primary/50 hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60`,"data-testid":`organization-card-${n.slug}`,children:[(0,$.jsxs)(bt,{className:`h-10 w-10 rounded-md shrink-0`,children:[n.logo&&(0,$.jsx)(xn,{src:n.logo,alt:n.name}),(0,$.jsx)(cn,{className:`rounded-md bg-primary/10 text-primary text-sm font-medium`,children:Aa(n.name)})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium`,children:n.name}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:i?e(`organizations.current`,{defaultValue:`Current organization`}):n.slug})]}),(0,$.jsx)(`span`,{className:`text-xs text-primary underline-offset-4 hover:underline shrink-0`,onClick:e=>{e.stopPropagation(),t(`/organizations/${n.slug}/members`)},children:e(`organizations.manage`,{defaultValue:`Manage`})}),a&&(0,$.jsx)(q,{className:`h-4 w-4 animate-spin text-muted-foreground`})]},n.id)})}),(0,$.jsx)(ka,{open:c,onOpenChange:l,onCreated:e=>{l(!1),m(e)}})]})}function Ma(){let{t:e}=w(),t=g(),{slug:n}=a(),{organizations:r,activeOrganization:i,isOrganizationsLoading:o,switchOrganization:c}=M(),{setContext:l}=B();(0,Q.useEffect)(()=>{l(`home`)},[l]);let u=(0,Q.useMemo)(()=>(r??[]).find(e=>e.slug===n)??null,[r,n]);if((0,Q.useEffect)(()=>{u&&i?.id!==u.id&&c(u.id).catch(e=>{console.error(`[OrganizationLayout] switch failed`,e)})},[u,i,c]),o)return(0,$.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center`,children:(0,$.jsx)(q,{className:`h-5 w-5 animate-spin text-muted-foreground`})});if(!u)return(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-12 text-center`,children:[(0,$.jsx)(`h1`,{className:`text-xl font-semibold`,children:e(`organization.notFound`,{defaultValue:`Organization not found`})}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e(`organization.notFoundDescription`,{defaultValue:`This organization does not exist or you do not have access.`})}),(0,$.jsx)(X,{className:`mt-6`,onClick:()=>t(`/organizations`),children:e(`organization.backToList`,{defaultValue:`Back to organizations`})})]});let f=[{to:`members`,label:e(`organization.tabs.members`,{defaultValue:`Members`})},{to:`invitations`,label:e(`organization.tabs.invitations`,{defaultValue:`Invitations`})},{to:`settings`,label:e(`organization.tabs.settings`,{defaultValue:`Settings`})}];return(0,$.jsxs)(`div`,{className:`flex min-h-svh w-full flex-col bg-background`,"data-testid":`organization-layout`,children:[(0,$.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:(0,$.jsx)(fi,{variant:`orgs`})}),(0,$.jsx)(`div`,{className:`border-b`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-5xl px-4 sm:px-6 pt-6`,children:[(0,$.jsxs)(`button`,{onClick:()=>t(`/organizations`),className:`mb-3 inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(yn,{className:`h-3.5 w-3.5`}),e(`organization.backToList`,{defaultValue:`Back to organizations`})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h1`,{className:`truncate text-2xl font-bold tracking-tight`,children:u.name}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u.slug})]})}),(0,$.jsx)(`nav`,{className:`mt-4 flex gap-1 -mb-px`,children:f.map(e=>(0,$.jsx)(s,{to:e.to,end:!0,className:({isActive:e})=>`border-b-2 px-3 py-2 text-sm font-medium transition-colors ${e?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e.label},e.to))})]})}),(0,$.jsx)(`main`,{className:`flex-1 min-w-0 overflow-auto`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-5xl px-4 sm:px-6 py-6`,children:(0,$.jsx)(d,{context:{org:u}})})})]})}function Na(){return i()}function Pa(e){let t=`/console/`,n=t.endsWith(`/`)?t:`${t}/`;return`${window.location.origin}${n}accept-invitation/${e}`}function Fa({organizationId:e,open:t,onOpenChange:n,onInvited:r}){let{t:i}=w(),{inviteMember:a}=M(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(`member`),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{t&&(s(``),l(`member`),p(null),h(null),_(!1))},[t]);let v=(0,Q.useCallback)(async t=>{if(t.preventDefault(),o.trim()){d(!0),p(null);try{let t=await a({organizationId:e,email:o.trim(),role:c});h(t),r?.(t)}catch(e){p(e instanceof Error?e.message:`Failed to invite member`)}finally{d(!1)}}},[o,c,e,a,r]),y=(0,Q.useCallback)(async()=>{if(!m)return;let e=Pa(m.id);try{await navigator.clipboard.writeText(e),_(!0),z.success(i(`organization.invitations.linkCopied`,{defaultValue:`Invitation link copied`})),setTimeout(()=>_(!1),2e3)}catch{z.error(i(`organization.invitations.copyFailed`,{defaultValue:`Failed to copy link`}))}},[m,i]);return(0,$.jsx)(De,{open:t,onOpenChange:n,children:(0,$.jsx)(nt,{className:`sm:max-w-[480px]`,"data-testid":`invite-member-dialog`,children:m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Ne,{children:[(0,$.jsx)(hn,{children:i(`organization.invitations.sentTitle`,{defaultValue:`Invitation created`})}),(0,$.jsx)(at,{children:i(`organization.invitations.sentDescription`,{defaultValue:`Share the link below with the invitee. They will need to sign in to accept.`})})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 py-4`,children:[(0,$.jsx)(Tt,{children:i(`organization.invitations.linkLabel`,{defaultValue:`Accept link`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{readOnly:!0,value:Pa(m.id),className:`font-mono text-xs`,onFocus:e=>e.currentTarget.select()}),(0,$.jsx)(X,{type:`button`,variant:`outline`,size:`icon`,onClick:y,"aria-label":`Copy`,children:g?(0,$.jsx)(jt,{className:`h-4 w-4`}):(0,$.jsx)(Cn,{className:`h-4 w-4`})})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`organization.invitations.invitedAs`,{defaultValue:`{{email}} invited as {{role}}`,email:m.email,role:m.role})})]}),(0,$.jsx)(Te,{children:(0,$.jsx)(X,{onClick:()=>n(!1),children:i(`common.done`,{defaultValue:`Done`})})})]}):(0,$.jsxs)(`form`,{onSubmit:v,children:[(0,$.jsxs)(Ne,{children:[(0,$.jsx)(hn,{children:i(`organization.invitations.inviteTitle`,{defaultValue:`Invite a member`})}),(0,$.jsx)(at,{children:i(`organization.invitations.inviteDescription`,{defaultValue:`They will receive an invitation to join this organization.`})})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(Tt,{htmlFor:`invite-email`,children:i(`organization.invitations.emailLabel`,{defaultValue:`Email`})}),(0,$.jsx)(Y,{id:`invite-email`,type:`email`,required:!0,placeholder:`user@example.com`,value:o,onChange:e=>s(e.target.value),autoFocus:!0,"data-testid":`invite-email-input`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(Tt,{htmlFor:`invite-role`,children:i(`organization.invitations.roleLabel`,{defaultValue:`Role`})}),(0,$.jsxs)(ht,{value:c,onValueChange:e=>l(e),children:[(0,$.jsx)(Ot,{id:`invite-role`,"data-testid":`invite-role-select`,children:(0,$.jsx)(wn,{})}),(0,$.jsxs)(qe,{children:[(0,$.jsx)(pe,{value:`member`,children:i(`organization.roles.member`,{defaultValue:`Member`})}),(0,$.jsx)(pe,{value:`admin`,children:i(`organization.roles.admin`,{defaultValue:`Admin`})}),(0,$.jsx)(pe,{value:`owner`,children:i(`organization.roles.owner`,{defaultValue:`Owner`})})]})]})]}),f&&(0,$.jsx)(`p`,{className:`text-sm text-destructive`,"data-testid":`invite-error`,children:f})]}),(0,$.jsxs)(Te,{children:[(0,$.jsx)(X,{type:`button`,variant:`outline`,onClick:()=>n(!1),disabled:u,children:i(`common.cancel`,{defaultValue:`Cancel`})}),(0,$.jsxs)(X,{type:`submit`,disabled:u||!o.trim(),"data-testid":`invite-submit`,children:[u&&(0,$.jsx)(q,{className:`mr-2 h-4 w-4 animate-spin`}),i(`organization.invitations.sendInvite`,{defaultValue:`Send invite`})]})]})]})})})}function Ia(e){return e?e.split(/[\s_-]+/).map(e=>e[0]).join(``).toUpperCase().slice(0,2):`?`}function La(){let{t:e}=w(),{org:t}=Na(),{getMembers:n,removeMember:r,updateMemberRole:i}=M(),[a,o]=(0,Q.useState)([]),[s,c]=(0,Q.useState)(!0),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),h=(0,Q.useCallback)(async()=>{c(!0),u(null);try{o(await n(t.id))}catch(e){u(e instanceof Error?e.message:`Failed to load members`)}finally{c(!1)}},[t.id,n]);(0,Q.useEffect)(()=>{h()},[h]);let g=async(n,r)=>{try{await i({organizationId:t.id,memberId:n.id,role:r}),z.success(e(`organization.members.roleUpdated`,{defaultValue:`Role updated`})),h()}catch(t){z.error(t instanceof Error?t.message:e(`organization.members.roleUpdateFailed`,{defaultValue:`Failed to update role`}))}};return s?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,$.jsx)(q,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):l?(0,$.jsxs)(`div`,{className:`rounded-lg border border-destructive/50 bg-destructive/10 p-6 text-center text-sm text-destructive`,children:[l,(0,$.jsx)(X,{variant:`outline`,size:`sm`,className:`ml-4`,onClick:h,children:e(`common.retry`,{defaultValue:`Retry`})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,"data-testid":`members-page`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`h2`,{className:`text-lg font-semibold`,children:[e(`organization.members.title`,{defaultValue:`Members`}),` (`,a.length,`)`]}),(0,$.jsx)(X,{onClick:()=>f(!0),"data-testid":`invite-member-btn`,children:e(`organization.members.inviteMember`,{defaultValue:`Invite member`})})]}),(0,$.jsx)(lt,{}),(0,$.jsx)(`div`,{className:`space-y-2`,children:a.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border bg-card p-3`,"data-testid":`member-row-${t.id}`,children:[(0,$.jsxs)(bt,{className:`h-9 w-9 shrink-0`,children:[t.user?.image&&(0,$.jsx)(xn,{src:t.user.image,alt:t.user.name}),(0,$.jsx)(cn,{className:`text-xs font-medium`,children:Ia(t.user?.name)})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium text-sm`,children:t.user?.name??`—`}),(0,$.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t.user?.email??`—`})]}),(0,$.jsx)(Wt,{variant:`outline`,className:`shrink-0 capitalize`,children:t.role}),t.createdAt&&(0,$.jsx)(`span`,{className:`hidden shrink-0 text-xs text-muted-foreground sm:block`,children:new Date(t.createdAt).toLocaleDateString()}),(0,$.jsxs)(Mt,{children:[(0,$.jsx)(Nn,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0`,"aria-label":`Member actions`,children:(0,$.jsx)(Ze,{className:`h-4 w-4`})})}),(0,$.jsxs)(un,{align:`end`,children:[(0,$.jsxs)(J,{onClick:()=>g(t,`owner`),disabled:t.role===`owner`,children:[(0,$.jsx)(At,{className:`mr-2 h-4 w-4`}),e(`organization.roles.owner`,{defaultValue:`Owner`})]}),(0,$.jsxs)(J,{onClick:()=>g(t,`admin`),disabled:t.role===`admin`,children:[(0,$.jsx)(At,{className:`mr-2 h-4 w-4`}),e(`organization.roles.admin`,{defaultValue:`Admin`})]}),(0,$.jsxs)(J,{onClick:()=>g(t,`member`),disabled:t.role===`member`,children:[(0,$.jsx)(At,{className:`mr-2 h-4 w-4`}),e(`organization.roles.member`,{defaultValue:`Member`})]}),(0,$.jsxs)(J,{className:`text-destructive focus:text-destructive`,onClick:()=>m(t),children:[(0,$.jsx)(On,{className:`mr-2 h-4 w-4`}),e(`organization.members.removeMember`,{defaultValue:`Remove member`})]})]})]})]},t.id))}),(0,$.jsx)(Dn,{open:!!p,onOpenChange:e=>!e&&m(null),children:(0,$.jsxs)(fn,{children:[(0,$.jsxs)(Rt,{children:[(0,$.jsx)(_t,{children:e(`organization.members.removeConfirmTitle`,{defaultValue:`Remove member?`})}),(0,$.jsx)(en,{children:e(`organization.members.removeConfirmDescription`,{defaultValue:`This will remove {{name}} from the organization. They will lose access immediately.`,name:p?.user?.name??p?.userId??``})})]}),(0,$.jsxs)(Bt,{children:[(0,$.jsx)(Nt,{children:e(`common.cancel`,{defaultValue:`Cancel`})}),(0,$.jsx)(Et,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:async()=>{if(p)try{await r({organizationId:t.id,memberIdOrUserId:p.id}),z.success(e(`organization.members.memberRemoved`,{defaultValue:`Member removed`})),m(null),h()}catch(t){z.error(t instanceof Error?t.message:e(`organization.members.removeFailed`,{defaultValue:`Failed to remove member`}))}},children:e(`organization.members.removeConfirmAction`,{defaultValue:`Remove`})})]})]})}),(0,$.jsx)(Fa,{organizationId:t.id,open:d,onOpenChange:f,onInvited:()=>h()})]})}function Ra(e){let t=`/console/`,n=t.endsWith(`/`)?t:`${t}/`;return`${window.location.origin}${n}accept-invitation/${e}`}function za(e){switch(e){case`pending`:return`outline`;case`accepted`:return`default`;case`rejected`:case`canceled`:return`destructive`;default:return`secondary`}}function Ba(){let{t:e}=w(),{org:t}=Na(),{listInvitations:n,cancelInvitation:r}=M(),[i,a]=(0,Q.useState)([]),[o,s]=(0,Q.useState)(!0),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(`all`),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)(null),g=(0,Q.useCallback)(async()=>{s(!0),l(null);try{a(await n(t.id))}catch(e){l(e instanceof Error?e.message:`Failed to load invitations`)}finally{s(!1)}},[t.id,n]);(0,Q.useEffect)(()=>{g()},[g]);let _=async t=>{let n=Ra(t.id);try{await navigator.clipboard.writeText(n),h(t.id),z.success(e(`organization.invitations.linkCopied`,{defaultValue:`Invitation link copied`})),setTimeout(()=>h(null),2e3)}catch{z.error(e(`organization.invitations.copyFailed`,{defaultValue:`Failed to copy link`}))}},v=async()=>{if(f)try{await r(f.id),z.success(e(`organization.invitations.canceled`,{defaultValue:`Invitation canceled`})),p(null),g()}catch(t){z.error(t instanceof Error?t.message:e(`organization.invitations.cancelFailed`,{defaultValue:`Failed to cancel invitation`}))}},y=u===`all`?i:i.filter(e=>e.status===u),b={all:i.length,pending:i.filter(e=>e.status===`pending`).length,accepted:i.filter(e=>e.status===`accepted`).length,rejected:i.filter(e=>e.status===`rejected`).length,canceled:i.filter(e=>e.status===`canceled`).length};return o?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,$.jsx)(q,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):c?(0,$.jsxs)(`div`,{className:`rounded-lg border border-destructive/50 bg-destructive/10 p-6 text-center text-sm text-destructive`,children:[c,(0,$.jsx)(X,{variant:`outline`,size:`sm`,className:`ml-4`,onClick:g,children:e(`common.retry`,{defaultValue:`Retry`})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,"data-testid":`invitations-page`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`organization.invitations.title`,{defaultValue:`Invitations`})})}),(0,$.jsx)(`div`,{className:`flex gap-1 border-b`,children:[`all`,`pending`,`accepted`,`rejected`,`canceled`].map(t=>(0,$.jsxs)(`button`,{onClick:()=>d(t),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors capitalize ${u===t?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[e(`organization.invitations.status.${t}`,{defaultValue:t}),b[t]>0&&(0,$.jsx)(`span`,{className:`ml-1.5 rounded-full bg-muted px-1.5 py-0.5 text-xs`,children:b[t]})]},t))}),(0,$.jsx)(lt,{}),y.length===0?(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e(`organization.invitations.empty`,{defaultValue:`No invitations found.`})}):(0,$.jsx)(`div`,{className:`space-y-2`,children:y.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border bg-card p-3`,"data-testid":`invitation-row-${t.id}`,children:[(0,$.jsx)(bt,{className:`h-9 w-9 shrink-0`,children:(0,$.jsx)(cn,{className:`text-xs`,children:(0,$.jsx)(ft,{className:`h-4 w-4`})})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium text-sm`,children:t.email}),t.expiresAt&&(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[e(`organization.invitations.expiresAt`,{defaultValue:`Expires`}),` `,new Date(t.expiresAt).toLocaleDateString()]})]}),(0,$.jsx)(Wt,{variant:`outline`,className:`shrink-0 capitalize`,children:t.role}),(0,$.jsx)(Wt,{variant:za(t.status),className:`shrink-0 capitalize`,children:e(`organization.invitations.status.${t.status}`,{defaultValue:t.status})}),t.status===`pending`&&(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>_(t),"aria-label":`Copy invitation link`,children:m===t.id?(0,$.jsx)(jt,{className:`h-4 w-4 text-green-600`}):(0,$.jsx)(Cn,{className:`h-4 w-4`})}),(0,$.jsx)(X,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-destructive hover:text-destructive`,onClick:()=>p(t),"aria-label":`Cancel invitation`,children:(0,$.jsx)(ge,{className:`h-4 w-4`})})]})]},t.id))}),(0,$.jsx)(Dn,{open:!!f,onOpenChange:e=>!e&&p(null),children:(0,$.jsxs)(fn,{children:[(0,$.jsxs)(Rt,{children:[(0,$.jsx)(_t,{children:e(`organization.invitations.cancelTitle`,{defaultValue:`Cancel invitation?`})}),(0,$.jsx)(en,{children:e(`organization.invitations.cancelDescription`,{defaultValue:`The invitation for {{email}} will be revoked.`,email:f?.email??``})})]}),(0,$.jsxs)(Bt,{children:[(0,$.jsx)(Nt,{children:e(`common.cancel`,{defaultValue:`Cancel`})}),(0,$.jsx)(Et,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:v,children:e(`organization.invitations.cancelAction`,{defaultValue:`Cancel invitation`})})]})]})})]})}function Va(){let{t:e}=w(),{org:t}=Na(),{user:n,getMembers:r,updateOrganization:i,deleteOrganization:a,leaveOrganization:o}=M(),s=g(),[c,l]=(0,Q.useState)(t.name),[u,d]=(0,Q.useState)(t.slug??``),[f,p]=(0,Q.useState)(t.logo??``),[m,h]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(!1),[C,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(``),[O,k]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{l(t.name),d(t.slug??``),p(t.logo??``)},[t]),(0,Q.useEffect)(()=>{let e=!1;return b(!0),r(t.id).then(t=>{e||v(t.find(e=>e.userId===n?.id)?.role===`owner`)}).catch(()=>{e||v(!1)}).finally(()=>{e||b(!1)}),()=>{e=!0}},[t.id,n?.id,r]);let A=(0,Q.useCallback)(async n=>{n.preventDefault(),h(!0);try{await i(t.id,{name:c.trim(),slug:u.trim()||void 0,logo:f.trim()||void 0}),z.success(e(`organization.settings.saved`,{defaultValue:`Settings saved`}))}catch(t){z.error(t instanceof Error?t.message:e(`organization.settings.saveFailed`,{defaultValue:`Failed to save settings`}))}finally{h(!1)}},[t.id,c,u,f,i,e]);return y?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,$.jsx)(q,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,$.jsxs)(`div`,{className:`space-y-8`,"data-testid":`settings-page`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`organization.settings.generalTitle`,{defaultValue:`General`})}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e(`organization.settings.generalDescription`,{defaultValue:`Update your organization information.`})}),(0,$.jsx)(lt,{className:`my-4`}),_?(0,$.jsxs)(`form`,{onSubmit:A,className:`space-y-4 max-w-md`,children:[(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(Tt,{htmlFor:`org-name`,children:e(`organization.settings.nameLabel`,{defaultValue:`Organization name`})}),(0,$.jsx)(Y,{id:`org-name`,value:c,onChange:e=>l(e.target.value),required:!0,"data-testid":`settings-name-input`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(Tt,{htmlFor:`org-slug`,children:e(`organization.settings.slugLabel`,{defaultValue:`Slug`})}),(0,$.jsx)(Y,{id:`org-slug`,value:u,onChange:e=>d(e.target.value),"data-testid":`settings-slug-input`})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(Tt,{htmlFor:`org-logo`,children:e(`organization.settings.logoLabel`,{defaultValue:`Logo URL (optional)`})}),(0,$.jsx)(Y,{id:`org-logo`,type:`url`,value:f,onChange:e=>p(e.target.value),placeholder:`https://example.com/logo.png`,"data-testid":`settings-logo-input`})]}),(0,$.jsxs)(X,{type:`submit`,disabled:m,"data-testid":`settings-save-btn`,children:[m&&(0,$.jsx)(q,{className:`mr-2 h-4 w-4 animate-spin`}),e(`organization.settings.save`,{defaultValue:`Save changes`})]})]}):(0,$.jsx)(`div`,{className:`rounded-lg border bg-muted/50 p-4 text-sm text-muted-foreground`,children:e(`organization.settings.readOnlyNote`,{defaultValue:`Only owners can change settings.`})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-destructive`,children:e(`organization.settings.dangerZone`,{defaultValue:`Danger zone`})}),(0,$.jsx)(lt,{className:`my-4`}),(0,$.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-destructive/50 bg-destructive/5 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-sm`,children:e(`organization.settings.leaveTitle`,{defaultValue:`Leave organization`})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`organization.settings.leaveDescription`,{defaultValue:`You will lose access to this organization.`})})]}),(0,$.jsx)(X,{variant:`destructive`,size:`sm`,onClick:()=>S(!0),children:e(`organization.settings.leaveAction`,{defaultValue:`Leave`})})]}),(0,$.jsx)(lt,{}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-sm`,children:e(`organization.settings.deleteTitle`,{defaultValue:`Delete organization`})}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`organization.settings.deleteDescription`,{defaultValue:`Permanently delete this organization and all its data.`})})]}),(0,$.jsx)(X,{variant:`destructive`,size:`sm`,onClick:()=>{D(``),T(!0)},disabled:!_,children:e(`organization.settings.deleteAction`,{defaultValue:`Delete`})})]})]})]}),(0,$.jsx)(Dn,{open:x,onOpenChange:S,children:(0,$.jsxs)(fn,{children:[(0,$.jsxs)(Rt,{children:[(0,$.jsx)(_t,{children:e(`organization.settings.leaveConfirmTitle`,{defaultValue:`Leave organization?`})}),(0,$.jsx)(en,{children:e(`organization.settings.leaveConfirmDescription`,{defaultValue:`Are you sure you want to leave {{name}}? You will lose access immediately.`,name:t.name})})]}),(0,$.jsxs)(Bt,{children:[(0,$.jsx)(Nt,{disabled:O,children:e(`common.cancel`,{defaultValue:`Cancel`})}),(0,$.jsxs)(Et,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:async()=>{k(!0);try{await o(t.id),z.success(e(`organization.settings.leftOrg`,{defaultValue:`You have left the organization`})),s(`/organizations`)}catch(t){z.error(t instanceof Error?t.message:e(`organization.settings.leaveFailed`,{defaultValue:`Failed to leave organization`}))}finally{k(!1)}},disabled:O,children:[O&&(0,$.jsx)(q,{className:`mr-2 h-4 w-4 animate-spin`}),e(`organization.settings.leaveConfirmAction`,{defaultValue:`Leave`})]})]})]})}),(0,$.jsx)(Dn,{open:C,onOpenChange:e=>{T(e),e||D(``)},children:(0,$.jsxs)(fn,{children:[(0,$.jsxs)(Rt,{children:[(0,$.jsx)(_t,{children:e(`organization.settings.deleteConfirmTitle`,{defaultValue:`Delete organization?`})}),(0,$.jsx)(en,{children:e(`organization.settings.deleteConfirmDescription`,{defaultValue:`This action is irreversible. All data will be permanently deleted. Type the organization slug to confirm.`})})]}),(0,$.jsxs)(`div`,{className:`px-6 pb-2`,children:[(0,$.jsx)(Tt,{htmlFor:`delete-confirm-slug`,className:`text-sm font-medium`,children:e(`organization.settings.deleteConfirmSlugLabel`,{defaultValue:`Type "{{slug}}" to confirm`,slug:t.slug})}),(0,$.jsx)(Y,{id:`delete-confirm-slug`,className:`mt-2`,value:E,onChange:e=>D(e.target.value),placeholder:t.slug,"data-testid":`delete-confirm-slug-input`})]}),(0,$.jsxs)(Bt,{children:[(0,$.jsx)(Nt,{disabled:O,children:e(`common.cancel`,{defaultValue:`Cancel`})}),(0,$.jsxs)(Et,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:async()=>{k(!0);try{await a(t.id),z.success(e(`organization.settings.deleted`,{defaultValue:`Organization deleted`})),s(`/organizations`)}catch(t){z.error(t instanceof Error?t.message:e(`organization.settings.deleteFailed`,{defaultValue:`Failed to delete organization`}))}finally{k(!1)}},disabled:O||E!==t.slug,children:[O&&(0,$.jsx)(q,{className:`mr-2 h-4 w-4 animate-spin`}),e(`organization.settings.deleteConfirmAction`,{defaultValue:`Delete organization`})]})]})]})})]})}function Ha(){let{t:e}=w(),t=g(),{invitationId:n}=a(),{isAuthenticated:r,isLoading:i,getInvitation:o,acceptInvitation:s,rejectInvitation:c,switchOrganization:l}=M(),[u,d]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(null),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{!i&&!r&&t(`/login?redirect=`+encodeURIComponent(window.location.pathname))},[r,i,t]),(0,Q.useEffect)(()=>{if(!n||!r)return;let e=!1;return p(!0),h(null),o(n).then(t=>{e||d(t)}).catch(t=>{e||h(t instanceof Error?t.message:`Invitation not found or expired`)}).finally(()=>{e||p(!1)}),()=>{e=!0}},[n,r,o]),i?(0,$.jsx)(`div`,{className:`flex min-h-svh items-center justify-center`,children:(0,$.jsx)(q,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):r?(0,$.jsx)(`div`,{className:`flex min-h-svh items-center justify-center px-4 py-12 bg-background`,children:(0,$.jsx)(`div`,{className:`w-full max-w-md rounded-xl border bg-card p-8 shadow-sm`,"data-testid":`accept-invitation-page`,children:f?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8`,children:[(0,$.jsx)(q,{className:`h-8 w-8 animate-spin text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`organization.accept.loading`,{defaultValue:`Loading invitation…`})})]}):m?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8 text-center`,children:[(0,$.jsx)(Pn,{className:`h-10 w-10 text-destructive`}),(0,$.jsx)(`h1`,{className:`text-xl font-semibold`,children:e(`organization.accept.errorTitle`,{defaultValue:`Invitation unavailable`})}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:m}),(0,$.jsx)(X,{variant:`outline`,onClick:()=>t(`/organizations`),children:e(`organization.accept.goToOrgs`,{defaultValue:`Go to organizations`})})]}):u?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-6 text-center`,children:[(0,$.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-primary/10`,children:(0,$.jsx)(we,{className:`h-7 w-7 text-primary`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-xl font-bold`,children:e(`organization.accept.title`,{defaultValue:`You have been invited`})}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e(`organization.accept.description`,{defaultValue:`You have been invited to join {{orgName}} as {{role}}.`,orgName:u.organizationName??u.organizationId,role:u.role})})]}),(0,$.jsxs)(`div`,{className:`w-full rounded-lg border bg-muted/50 p-4 text-left space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`organization.accept.organization`,{defaultValue:`Organization`})}),(0,$.jsx)(`span`,{className:`font-medium`,children:u.organizationName??u.organizationId})]}),(0,$.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`organization.accept.role`,{defaultValue:`Role`})}),(0,$.jsx)(`span`,{className:`font-medium capitalize`,children:u.role})]}),u.expiresAt&&(0,$.jsxs)(`div`,{className:`flex justify-between text-sm`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`organization.accept.expiresAt`,{defaultValue:`Expires`})}),(0,$.jsx)(`span`,{className:`font-medium`,children:new Date(u.expiresAt).toLocaleDateString()})]})]}),(0,$.jsxs)(`div`,{className:`flex w-full gap-3`,children:[(0,$.jsxs)(X,{variant:`outline`,className:`flex-1`,onClick:async()=>{if(n){b(!0);try{await c(n),z.success(e(`organization.accept.declined`,{defaultValue:`Invitation declined`})),t(`/organizations`)}catch(t){z.error(t instanceof Error?t.message:e(`organization.accept.declineFailed`,{defaultValue:`Failed to decline invitation`})),b(!1)}}},disabled:y||_,children:[y&&(0,$.jsx)(q,{className:`mr-2 h-4 w-4 animate-spin`}),e(`organization.accept.decline`,{defaultValue:`Decline`})]}),(0,$.jsxs)(X,{className:`flex-1`,onClick:async()=>{if(!(!u||!n)){v(!0);try{await s(n),await l(u.organizationId).catch(()=>null),z.success(e(`organization.accept.accepted`,{defaultValue:`Invitation accepted`})),t(`/home`)}catch(t){z.error(t instanceof Error?t.message:e(`organization.accept.acceptFailed`,{defaultValue:`Failed to accept invitation`})),v(!1)}}},disabled:_||y,children:[_&&(0,$.jsx)(q,{className:`mr-2 h-4 w-4 animate-spin`}),(0,$.jsx)(Xe,{className:`mr-2 h-4 w-4`}),e(`organization.accept.accept`,{defaultValue:`Accept invitation`})]})]})]}):null})}):null}var Ua=(0,Q.lazy)(()=>l(()=>import(`./SystemHubPage-D08IDX3M.js`).then(e=>({default:e.SystemHubPage})),__vite__mapDeps([0]))),Wa=(0,Q.lazy)(()=>l(()=>import(`./AppManagementPage-CLr3paaF.js`).then(e=>({default:e.AppManagementPage})),__vite__mapDeps([0]))),Ga=(0,Q.lazy)(()=>l(()=>import(`./ProfilePage-6u6k00rh.js`).then(e=>({default:e.ProfilePage})),__vite__mapDeps([0]))),Ka=!1;(0,Q.lazy)(()=>l(()=>import(`./MetadataManagerPage-DobP393N.js`).then(e=>({default:e.MetadataManagerPage})),__vite__mapDeps([0]))),(0,Q.lazy)(()=>l(()=>import(`./MetadataDetailPage-C1sWJhl2.js`).then(e=>({default:e.MetadataDetailPage})),__vite__mapDeps([0])));var qa=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{path:`system`,element:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(wi,{}),children:(0,$.jsx)(Ua,{})})}),(0,$.jsx)(m,{path:`system/apps`,element:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(wi,{}),children:(0,$.jsx)(Wa,{})})}),(0,$.jsx)(m,{path:`system/profile`,element:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(wi,{}),children:(0,$.jsx)(Ga,{})})}),Ka]});function Ja(){return(0,$.jsx)(fa,{extraRoutes:qa,extraRoutesNoApp:qa})}var Ya=(0,Q.lazy)(()=>l(()=>import(`./src-iMF4J4F7.js`).then(e=>e.t).then(e=>({default:e.CreateAppPage})),__vite__mapDeps([0]))),Xa=`/console/`?.replace(/\/$/,``)||`/`,Za=`https://demo.objectstack.ai/api/v1/auth`,Qa=({children:e})=>(0,$.jsx)(Di,{authUrl:Za,children:e});function $a(){return(0,$.jsxs)(Qa,{children:[(0,$.jsx)(ae,{}),(0,$.jsx)(u,{basename:Xa,children:(0,$.jsxs)(Lr,{children:[(0,$.jsx)(Oi,{position:`bottom-right`}),(0,$.jsxs)(r,{children:[(0,$.jsx)(m,{path:`/login`,element:(0,$.jsx)(ga,{})}),(0,$.jsx)(m,{path:`/register`,element:(0,$.jsx)(va,{})}),(0,$.jsx)(m,{path:`/forgot-password`,element:(0,$.jsx)(ba,{})}),(0,$.jsx)(m,{path:`/home`,element:(0,$.jsx)(Vr,{children:(0,$.jsx)(xa,{children:(0,$.jsx)(Ea,{})})})}),(0,$.jsx)(m,{path:`/organizations`,element:(0,$.jsx)(Vr,{requireOrganization:!1,children:(0,$.jsx)(Da,{children:(0,$.jsx)(ja,{})})})}),(0,$.jsxs)(m,{path:`/organizations/:slug`,element:(0,$.jsx)(Vr,{requireOrganization:!1,children:(0,$.jsx)(Ma,{})}),children:[(0,$.jsx)(m,{index:!0,element:(0,$.jsx)(n,{to:`members`,replace:!0})}),(0,$.jsx)(m,{path:`members`,element:(0,$.jsx)(La,{})}),(0,$.jsx)(m,{path:`invitations`,element:(0,$.jsx)(Ba,{})}),(0,$.jsx)(m,{path:`settings`,element:(0,$.jsx)(Va,{})})]}),(0,$.jsx)(m,{path:`/accept-invitation/:invitationId`,element:(0,$.jsx)(Ha,{})}),(0,$.jsx)(m,{path:`/system/*`,element:(0,$.jsx)(Ur,{})}),(0,$.jsx)(m,{path:`/create-app`,element:(0,$.jsx)(Vr,{requireOrganization:!1,children:(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(Ir,{}),children:(0,$.jsx)(Ya,{})})})}),(0,$.jsx)(m,{path:`/apps/:appName/*`,element:(0,$.jsx)(Vr,{children:(0,$.jsx)(Ja,{})})}),(0,$.jsx)(m,{path:`/`,element:(0,$.jsx)(Rr,{children:(0,$.jsx)(Hr,{})})}),(0,$.jsx)(m,{path:`*`,element:(0,$.jsx)(n,{to:`/`,replace:!0})})]})]})})]})}async function eo(e){try{let t=await fetch(`https://demo.objectstack.ai/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(),r;return r=n?.data?.translations&&typeof n.data.translations==`object`?n.data.translations:n,to(r)?no(r):r}catch(t){return console.warn(`[i18n] Failed to load translations for '${e}':`,t),{}}}function to(e){let t=e.objects;if(!t||typeof t!=`object`||Array.isArray(t))return!1;for(let e of Object.values(t))if(e&&typeof e==`object`&&!Array.isArray(e)&&`fields`in e)return!0;return!1}function no(e){let t={},n={},r={},i=e.objects;if(i)for(let[e,a]of Object.entries(i)){if(!a||typeof a!=`object`)continue;let i={label:a.label};if(a.pluralLabel&&(i.pluralLabel=a.pluralLabel),a.description&&(i.description=a.description),t[e]=i,a.fields&&typeof a.fields==`object`){n[e]={};for(let[t,i]of Object.entries(a.fields))i?.label&&(n[e][t]=i.label),i?.options&&typeof i.options==`object`&&Object.keys(i.options).length>0&&(r[e]||(r[e]={}),r[e][t]=i.options)}}let a={};return Object.keys(t).length>0&&(a.objects=t),Object.keys(n).length>0&&(a.fields=n),Object.keys(r).length>0&&(a.fieldOptions=r),e.apps&&(a.apps=e.apps),e.messages&&(a.messages=e.messages),e.validationMessages&&(a.validationMessages=e.validationMessages),e.dashboards&&(a.dashboards=e.dashboards),{app:a}}function ro(e,t){let n=Array.isArray(e.fields)?e.fields:Object.values(e.fields||{});return{id:e.name||`obj_${t}`,name:e.name||``,label:typeof e.label==`object`?e.label.defaultValue||e.label.key||``:e.label||e.name||``,pluralLabel:e.pluralLabel||e.plural_label||void 0,description:typeof e.description==`object`?e.description.defaultValue:e.description||void 0,icon:e.icon||void 0,group:e.name?.startsWith(`sys_`)?`System Objects`:`Custom Objects`,sortOrder:t,isSystem:e.name?.startsWith(`sys_`)||!1,enabled:e.enabled!==!1,fieldCount:n.length,relationships:Array.isArray(e.relationships)?e.relationships.map(e=>({relatedObject:e.object||e.relatedObject||``,type:e.type||`one-to-many`,label:e.label||e.name||void 0,foreignKey:e.foreign_key||e.foreignKey||void 0})):void 0}}function io(e,t){return{id:e.name||`fld_${t}`,name:e.name||``,label:typeof e.label==`object`?e.label.defaultValue||e.label.key||``:e.label||e.name||``,type:e.type||`text`,group:e.group||void 0,sortOrder:t,description:e.description||e.help||void 0,required:e.required||!1,unique:e.unique||!1,readonly:e.readonly||!1,hidden:e.hidden||!1,defaultValue:e.defaultValue||e.default_value||void 0,placeholder:e.placeholder||void 0,options:Array.isArray(e.options)?e.options.map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label||e.value,value:e.value,color:e.color}):void 0,isSystem:e.readonly===!0&&(e.name===`id`||e.name===`createdAt`||e.name===`updatedAt`),externalId:e.externalId||!1,trackHistory:e.trackHistory||e.track_history||!1,indexed:e.indexed||!1,referenceTo:e.reference_to||e.referenceTo||void 0,formula:e.formula||void 0}}function ao(e){let{objects:t}=A(),n=(0,Q.useMemo)(()=>(t||[]).find(t=>t.name===e),[t,e]);return{object:(0,Q.useMemo)(()=>n?ro(n,0):null,[n]),fields:(0,Q.useMemo)(()=>n?(Array.isArray(n.fields)?n.fields:Object.values(n.fields||{})).map(io):[],[n]),metadataObject:n}}function oo({label:e,value:t,onSave:n,multiline:r=!1,disabled:i=!1,placeholder:a}){let[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(t),[u,d]=(0,Q.useState)(!1),f=(0,Q.useRef)(null),p=()=>{l(t),s(!0),setTimeout(()=>f.current?.focus(),0)},m=(0,Q.useCallback)(async()=>{if(c===t){s(!1);return}d(!0);try{await n(c),s(!1)}catch{}finally{d(!1)}},[c,t,n]),h=()=>{l(t),s(!1)},g=e=>{e.key===`Enter`&&!r&&(e.preventDefault(),m()),e.key===`Escape`&&h()};return(0,$.jsxs)(`div`,{className:`space-y-1.5 group`,children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:e}),(0,$.jsx)(`dd`,{children:o?(0,$.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[r?(0,$.jsx)(Pt,{ref:f,value:c,onChange:e=>l(e.target.value),onKeyDown:g,placeholder:a,rows:3,className:`text-sm flex-1 min-w-0`,disabled:u}):(0,$.jsx)(Y,{ref:f,value:c,onChange:e=>l(e.target.value),onKeyDown:g,placeholder:a,className:`text-sm h-7 flex-1 min-w-0`,disabled:u}),(0,$.jsx)(`button`,{onClick:()=>void m(),disabled:u,className:`mt-0.5 p-1 rounded text-green-600 hover:bg-green-50 disabled:opacity-50 shrink-0`,"aria-label":`Save`,children:u?(0,$.jsx)(q,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(jt,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`button`,{onClick:h,disabled:u,className:`mt-0.5 p-1 rounded text-muted-foreground hover:bg-accent shrink-0`,"aria-label":`Cancel`,children:(0,$.jsx)(ge,{className:`h-3.5 w-3.5`})})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-h-7`,children:[(0,$.jsx)(`span`,{className:`text-sm flex-1 min-w-0 truncate`,children:t||(0,$.jsx)(`span`,{className:`text-muted-foreground italic`,children:a||`—`})}),!i&&(0,$.jsx)(`button`,{onClick:p,className:`p-1 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:bg-accent transition-opacity shrink-0`,"aria-label":`Edit ${e}`,children:(0,$.jsx)(mn,{className:`h-3 w-3`})})]})})]})}function so({schema:e}){let t=e.objectName,{object:n,fields:r,metadataObject:i}=ao(t),{refresh:a}=A(),o=Ji(),s=(0,Q.useCallback)(async(e,n)=>{if(!o||!i)return;let r={...i,[e]:n};try{await o.saveMetadataItem(`object`,t,r),await a(),z.success(`${e===`label`?`Display name`:`Field`} updated`)}catch(e){throw z.error(e?.message||`Failed to save`),e}},[o,i,t,a]);if(!n)return null;let c=n.isSystem;return(0,$.jsxs)(`div`,{className:`space-y-6`,"data-testid":`object-properties`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`基本信息`}),(0,$.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-5`,children:[(0,$.jsx)(oo,{label:`显示名称`,value:n.label,onSave:e=>s(`label`,e),placeholder:`输入显示名称`,disabled:c}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`API 名称`}),(0,$.jsx)(`dd`,{className:`text-sm font-mono bg-muted/50 rounded px-2 py-1 inline-block`,children:n.name})]}),(0,$.jsx)(oo,{label:`复数名称`,value:n.pluralLabel||``,onSave:e=>s(`pluralLabel`,e),placeholder:`例如:客户们`,disabled:c}),(0,$.jsx)(oo,{label:`分组`,value:n.group||``,onSave:e=>s(`group`,e),placeholder:`对象分组`,disabled:c}),(0,$.jsx)(`div`,{className:`sm:col-span-2`,children:(0,$.jsx)(oo,{label:`描述`,value:n.description||``,onSave:e=>s(`description`,e),multiline:!0,placeholder:`输入对象描述`,disabled:c})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`配置`}),(0,$.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`状态`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(Wt,{variant:n.enabled===!1?`secondary`:`default`,className:`font-normal`,children:n.enabled===!1?`已禁用`:`已启用`})})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`字段数量`}),(0,$.jsxs)(`dd`,{className:`text-sm font-medium`,children:[n.fieldCount??r.length,` 个字段`]})]}),c&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`类型`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(Wt,{variant:`secondary`,className:`font-normal`,children:`系统对象`})})]})]})]})]})}var co=[{label:`一对多`,value:`one-to-many`},{label:`多对多`,value:`many-to-many`},{label:`一对一`,value:`one-to-one`},{label:`多对一`,value:`many-to-one`}];function lo({schema:e}){let t=e.objectName,{object:n,metadataObject:r}=ao(t),{refresh:i}=A(),a=Ji(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)({relatedObject:``,type:`one-to-many`,label:``,foreignKey:``}),f=(0,Q.useCallback)(async()=>{if(!a||!r||!u.relatedObject.trim())return;let e={relatedObject:u.relatedObject.trim(),type:u.type,label:u.label.trim()||void 0,foreignKey:u.foreignKey.trim()||void 0},n={...r,relationships:[...Array.isArray(r.relationships)?r.relationships:[],e]};l(!0);try{await a.saveMetadataItem(`object`,t,n),await i(),z.success(`关联关系已添加`),s(!1),d({relatedObject:``,type:`one-to-many`,label:``,foreignKey:``})}catch(e){z.error(e?.message||`保存失败`)}finally{l(!1)}},[a,r,n,u,t,i]),p=(0,Q.useCallback)(async e=>{if(!a||!r)return;let n=Array.isArray(r.relationships)?[...r.relationships]:[];n.splice(e,1);let o={...r,relationships:n};l(!0);try{await a.saveMetadataItem(`object`,t,o),await i(),z.success(`关联关系已删除`)}catch(e){z.error(e?.message||`删除失败`)}finally{l(!1)}},[a,r,t,i]);if(!n)return null;let m=n.relationships&&n.relationships.length>0;return(0,$.jsx)(`div`,{className:`space-y-4`,"data-testid":`relationships-section`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`关联关系`}),!n.isSystem&&(0,$.jsxs)(X,{size:`sm`,variant:`outline`,onClick:()=>s(e=>!e),className:`h-7 text-xs`,children:[(0,$.jsx)(Yt,{className:`h-3 w-3 mr-1`}),`添加关联`]})]}),o&&(0,$.jsxs)(`div`,{className:`mb-4 p-4 border rounded-lg bg-muted/30 space-y-3`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-medium`,children:`新建关联关系`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`关联对象 *`}),(0,$.jsx)(Y,{value:u.relatedObject,onChange:e=>d(t=>({...t,relatedObject:e.target.value})),placeholder:`例如:account`,className:`h-7 text-xs`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`关联类型`}),(0,$.jsx)(`select`,{value:u.type,onChange:e=>d(t=>({...t,type:e.target.value})),className:`w-full h-7 text-xs rounded-md border border-input bg-background px-2`,children:co.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`显示名称`}),(0,$.jsx)(Y,{value:u.label,onChange:e=>d(t=>({...t,label:e.target.value})),placeholder:`可选`,className:`h-7 text-xs`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`外键字段`}),(0,$.jsx)(Y,{value:u.foreignKey,onChange:e=>d(t=>({...t,foreignKey:e.target.value})),placeholder:`例如:account_id`,className:`h-7 text-xs`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,$.jsx)(X,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>s(!1),disabled:c,children:`取消`}),(0,$.jsxs)(X,{size:`sm`,className:`h-7 text-xs`,onClick:()=>void f(),disabled:c||!u.relatedObject.trim(),children:[c?(0,$.jsx)(q,{className:`h-3 w-3 animate-spin mr-1`}):null,`保存`]})]})]}),m?(0,$.jsx)(`div`,{className:`space-y-2`,children:n.relationships?.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-start gap-4 p-3 rounded-lg border bg-card hover:bg-accent/30 transition-colors group`,children:[(0,$.jsx)(Wt,{variant:`outline`,className:`text-xs shrink-0 mt-0.5`,children:co.find(t=>t.value===e.type)?.label||e.type}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-sm`,children:e.label||e.relatedObject}),e.label&&e.label!==e.relatedObject&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`关联对象: `,(0,$.jsx)(`span`,{className:`font-mono`,children:e.relatedObject})]}),e.foreignKey&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`外键: `,(0,$.jsx)(`span`,{className:`font-mono`,children:e.foreignKey})]})]}),!n.isSystem&&(0,$.jsx)(`button`,{onClick:()=>void p(t),disabled:c,className:`p-1 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-destructive hover:bg-destructive/10 transition-all shrink-0`,"aria-label":`删除关联`,children:(0,$.jsx)(dn,{className:`h-3.5 w-3.5`})})]},t))}):!o&&(0,$.jsxs)(`div`,{className:`text-center py-8 px-4 border border-dashed rounded-lg`,children:[(0,$.jsx)(pt,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground opacity-40`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`暂无关联关系。`}),!n.isSystem&&(0,$.jsxs)(X,{size:`sm`,variant:`outline`,className:`mt-3 h-7 text-xs`,onClick:()=>s(!0),children:[(0,$.jsx)(Yt,{className:`h-3 w-3 mr-1`}),`添加关联`]})]})]})})}function uo({schema:e}){let t=e.objectName,{fields:n}=ao(t),r=(0,Q.useMemo)(()=>n.filter(e=>e.unique||e.name===`id`||e.externalId),[n]);return(0,$.jsx)(`div`,{className:`space-y-4`,"data-testid":`keys-section`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`唯一键`}),r.length>0?(0,$.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,$.jsxs)(`div`,{className:`flex items-start gap-4 p-3 rounded-lg border bg-card hover:bg-accent/30 transition-colors`,children:[(0,$.jsx)(Wt,{variant:e.name===`id`?`default`:`outline`,className:`text-xs shrink-0 mt-0.5`,children:e.name===`id`?`主键`:e.externalId?`外部 ID`:`唯一`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-sm`,children:e.label||e.name}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`类型: `,(0,$.jsx)(`span`,{className:`font-mono`,children:e.type})]})]})]},e.name))}):(0,$.jsxs)(`div`,{className:`text-center py-8 px-4 border border-dashed rounded-lg`,children:[(0,$.jsx)(it,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground opacity-40`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`未找到唯一键或主键。`})]})]})})}function fo(e){return(0,$.jsx)(`div`,{className:`space-y-4`,"data-testid":`data-experience-section`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`数据体验`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:`配置用户与此对象数据的交互方式`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,$.jsxs)(`div`,{className:`rounded-lg border p-5 text-center hover:bg-accent/30 transition-colors cursor-pointer`,"data-testid":`data-experience-forms`,children:[(0,$.jsx)(Qt,{className:`h-7 w-7 mx-auto mb-2.5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm font-semibold mb-1`,children:`表单`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`设计数据录入表单`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border p-5 text-center hover:bg-accent/30 transition-colors cursor-pointer`,"data-testid":`data-experience-views`,children:[(0,$.jsx)(Ft,{className:`h-7 w-7 mx-auto mb-2.5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm font-semibold mb-1`,children:`视图`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`配置列表和详情视图`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border p-5 text-center hover:bg-accent/30 transition-colors cursor-pointer`,"data-testid":`data-experience-dashboards`,children:[(0,$.jsx)(me,{className:`h-7 w-7 mx-auto mb-2.5 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`text-sm font-semibold mb-1`,children:`仪表盘`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`构建可视化仪表盘`})]})]})]})})}function po({schema:e}){let t=e.objectName,{object:n}=ao(t);return(0,$.jsx)(`div`,{className:`space-y-4`,"data-testid":`data-preview-section`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`数据预览`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:`查看此对象的示例记录`}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-dashed p-12 text-center`,children:[(0,$.jsx)(Kt,{className:`h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-40`}),(0,$.jsx)(`p`,{className:`text-sm font-medium mb-1`,children:`示例数据`}),(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`“`,n?.label||t,`” 的实时数据预览将在此处显示`]})]})]})})}function mo(e,t){return{name:e.name,label:e.label,pluralLabel:e.pluralLabel,description:e.description,icon:e.icon,group:e.group,sortOrder:e.sortOrder,enabled:e.enabled,fields:t,relationships:e.relationships}}function ho(e){return{name:e.name,label:e.label,type:e.type,group:e.group,description:e.description,required:e.required,unique:e.unique,readonly:e.readonly,hidden:e.hidden,defaultValue:e.defaultValue,placeholder:e.placeholder,options:e.options,externalId:e.externalId,trackHistory:e.trackHistory,indexed:e.indexed,referenceTo:e.referenceTo,formula:e.formula,sortOrder:e.sortOrder}}var go=class{constructor(e){this.adapter=e}async getItems(e){let t=await this.adapter.getClient().meta.getItems(e);return t&&typeof t==`object`&&`items`in t&&Array.isArray(t.items)?t.items:[]}async saveMetadataItem(e,t,n){await this.adapter.getClient().meta.saveItem(e,t,n),this.adapter.invalidateCache(`${e}:${t}`)}async deleteMetadataItem(e,t){await this.adapter.getClient().meta.saveItem(e,t,{name:t,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`${e}:${t}`)}async saveObject(e,t){let n=this.adapter.getClient(),r=mo(e,t);await n.meta.saveItem(`object`,e.name,r),this.adapter.invalidateCache(`object:${e.name}`)}async deleteObject(e){await this.adapter.getClient().meta.saveItem(`object`,e,{name:e,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`object:${e}`)}async saveFields(e,t){let n=this.adapter.getClient(),r={};try{let t=await n.meta.getItem(`object`,e);r=t?.item??t??{}}catch{}let i={...r,name:e,fields:t.map(ho)};await n.meta.saveItem(`object`,e,i),this.adapter.invalidateCache(`object:${e}`)}static diffObjects(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,object:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,object:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,object:t}}return null}static diffFields(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,field:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,field:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,field:t}}return null}};function _o({schema:e}){let t=e.objectName,{objects:n,refresh:r}=A(),i=Ji(),a=(0,Q.useMemo)(()=>(n||[]).find(e=>e.name===t),[n,t]),o=(0,Q.useMemo)(()=>a?(Array.isArray(a.fields)?a.fields:Object.values(a.fields||{})).map(io):[],[a]),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(!1),d=s??o,f=(0,Q.useRef)(d),p=(0,Q.useCallback)(async e=>{let n=f.current;if(c(e),f.current=e,!i){z.error(`Service unavailable — changes saved locally only`);return}let a=go.diffFields(n,e),o=a?a.type===`create`?`Field "${a.field.label||a.field.name}" created`:a.type===`update`?`Field "${a.field.label||a.field.name}" updated`:`Field "${a.field.label||a.field.name}" deleted`:`Field configuration updated`;u(!0);try{await i.saveFields(t,e),await r(),z.success(o)}catch(e){c(n),f.current=n,z.error(e?.message||`Failed to save field changes`)}finally{u(!1)}},[i,t,r]);return(0,$.jsxs)(`div`,{className:`space-y-3`,"data-testid":`field-management-section`,children:[l&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`field-saving-indicator`,children:[(0,$.jsx)(q,{className:`h-4 w-4 animate-spin`}),`Saving field changes…`]}),d.some(e=>e.isSystem)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground bg-muted/50 rounded-md px-3 py-2`,"data-testid":`system-field-hint`,children:[(0,$.jsx)(Se,{className:`h-3.5 w-3.5 shrink-0`}),`System fields (e.g. id, createdAt, updatedAt) are read-only and cannot be edited or deleted.`]}),(0,$.jsx)(Qn,{objectName:t,fields:d,onFieldsChange:p})]})}function vo({schema:e}){let t=e.objectName,[n,r]=(0,Q.useState)(`details`),i={type:`object-properties`,id:`${t}-properties`,objectName:t},a={type:`object-field-designer`,id:`${t}-field-designer`,objectName:t},o={type:`object-relationships`,id:`${t}-relationships`,objectName:t},s={type:`object-keys`,id:`${t}-keys`,objectName:t},c={type:`object-data-experience`,id:`${t}-data-experience`,objectName:t},l={type:`object-data-preview`,id:`${t}-data-preview`,objectName:t};return(0,$.jsx)(`div`,{className:`w-full`,"data-testid":`object-detail-tabs`,children:(0,$.jsxs)(pn,{value:n,onValueChange:r,className:`w-full`,children:[(0,$.jsxs)(Vt,{className:`w-full justify-start border-b rounded-none bg-transparent p-0 h-auto`,children:[(0,$.jsxs)(zt,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,$.jsx)(jn,{className:`h-4 w-4 mr-2`}),`详情`]}),(0,$.jsxs)(zt,{value:`fields`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,$.jsx)(Qe,{className:`h-4 w-4 mr-2`}),`字段`]}),(0,$.jsxs)(zt,{value:`relationships`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,$.jsx)(pt,{className:`h-4 w-4 mr-2`}),`关联关系`]}),(0,$.jsxs)(zt,{value:`data`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,$.jsx)(Kt,{className:`h-4 w-4 mr-2`}),`数据`]})]}),(0,$.jsx)(tn,{value:`details`,className:`mt-6`,children:(0,$.jsx)(`div`,{className:`space-y-6`,children:(0,$.jsx)(v,{schema:i})})}),(0,$.jsx)(tn,{value:`fields`,className:`mt-6`,children:(0,$.jsx)(`div`,{className:`space-y-6`,children:(0,$.jsx)(v,{schema:a})})}),(0,$.jsx)(tn,{value:`relationships`,className:`mt-6`,children:(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(v,{schema:o}),(0,$.jsx)(v,{schema:s})]})}),(0,$.jsx)(tn,{value:`data`,className:`mt-6`,children:(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(v,{schema:l}),(0,$.jsx)(v,{schema:c})]})})]})})}var yo={namespace:`console`,category:`system`};b.register(`object-detail-tabs`,vo,{...yo,label:`Object Detail Tabs`,icon:`LayoutDashboard`}),b.register(`object-properties`,so,{...yo,label:`Object Properties`,icon:`Settings2`}),b.register(`object-relationships`,lo,{...yo,label:`Object Relationships`,icon:`Link2`}),b.register(`object-keys`,uo,{...yo,label:`Object Keys`,icon:`KeyRound`}),b.register(`object-data-experience`,fo,{...yo,label:`Data Experience`,icon:`LayoutList`}),b.register(`object-data-preview`,po,{...yo,label:`Data Preview`,icon:`Table`}),b.register(`object-field-designer`,_o,{...yo,label:`Field Designer`,icon:`Columns`}),b.registerLazy(`object-map`,()=>l(()=>import(`./plugin-map-B7EfyDsf.js`).then(e=>e.t),__vite__mapDeps([0,2])),{namespace:`plugin-map`,category:`view`}),b.registerLazy(`map`,()=>l(()=>import(`./plugin-map-B7EfyDsf.js`).then(e=>e.t),__vite__mapDeps([0,2])),{namespace:`view`,category:`view`}),b.registerLazy(`chart`,()=>l(()=>import(`./plugin-charts-BvZ1cSiZ.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`plugin-charts`,category:`chart`});for(let e of[`object-chart`,`bar-chart`,`pie-chart`,`donut-chart`,`radar-chart`,`scatter-chart`,`line-chart`,`area-chart`,`advanced-chart`,`chart:bar`])b.registerLazy(e,()=>l(()=>import(`./plugin-charts-BvZ1cSiZ.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`plugin-charts`,category:`chart`});b.registerLazy(`object-gantt`,()=>l(()=>import(`./plugin-gantt-BG1WaV_b.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`plugin-gantt`,category:`view`}),b.registerLazy(`gantt`,()=>l(()=>import(`./plugin-gantt-BG1WaV_b.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`view`,category:`view`}),b.registerLazy(`markdown`,()=>l(()=>import(`./plugin-markdown-CiHluuxA.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`plugin-markdown`,category:`display`}),b.registerLazy(`object-timeline`,()=>l(()=>import(`./plugin-timeline-D8_YFDQQ.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`plugin-timeline`,category:`view`}),b.registerLazy(`timeline`,()=>l(()=>import(`./plugin-timeline-D8_YFDQQ.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`view`,category:`view`}),b.registerLazy(`object-calendar`,()=>l(()=>import(`./plugin-calendar-DX_UWouT.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`plugin-calendar`,category:`view`}),b.registerLazy(`calendar`,()=>l(()=>import(`./plugin-calendar-DX_UWouT.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`view`,category:`view`}),b.registerLazy(`calendar-view`,()=>l(()=>import(`./plugin-calendar-DX_UWouT.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`plugin-calendar`,category:`view`}),b.registerLazy(`object-kanban`,()=>l(()=>import(`./plugin-kanban-Dzjqra5U.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`plugin-kanban`,category:`view`}),b.registerLazy(`kanban`,()=>l(()=>import(`./plugin-kanban-Dzjqra5U.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`view`,category:`view`});for(let e of[`kanban-ui`,`kanban-enhanced`])b.registerLazy(e,()=>l(()=>import(`./plugin-kanban-Dzjqra5U.js`).then(e=>e.t),__vite__mapDeps([0])),{namespace:`plugin-kanban`,category:`view`});b.registerLazy(`report`,()=>l(()=>import(`./plugins-views-C5gstDGy.js`).then(e=>e.t),__vite__mapDeps([0,1])),{namespace:`plugin-report`,category:`view`});for(let e of[`report-viewer`,`report-builder`])b.registerLazy(e,()=>l(()=>import(`./plugins-views-C5gstDGy.js`).then(e=>e.t),__vite__mapDeps([0,1])),{namespace:`plugin-report`,category:`view`});$n.createRoot(document.getElementById(`root`)).render((0,$.jsx)(Q.StrictMode,{children:(0,$.jsx)(Hn,{pwa:{enabled:!0,name:`ObjectUI Console`,shortName:`Console`},children:(0,$.jsx)(k,{loadLanguage:eo,children:(0,$.jsx)($a,{})})})}));export{Ui as a,Wi as i,ro as n,ji as o,Ji as r,Mi as s,go as t};
|