@objectstack/console 11.3.0 → 11.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/{AdapterProvider-BiTdGDAR.js → AdapterProvider-DPeLrdd0.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-pA6WQiJs.js → AiPendingActionsPage-CK0MN4fG.js} +1 -1
- package/dist/assets/{ApiConsolePage-C2RUq2a1.js → ApiConsolePage-BmQiYn3w.js} +1 -1
- package/dist/assets/{AppDocsIndex-4jDRVpod.js → AppDocsIndex-BZTtsBDk.js} +1 -1
- package/dist/assets/{AppManagementPage-D4Qdfc-k.js → AppManagementPage-JurgDSH0.js} +1 -1
- package/dist/assets/{ApprovalsInboxPage-97ofFRyB.js → ApprovalsInboxPage-C9iYBMLT.js} +1 -1
- package/dist/assets/{AuditLogPage-CE9VainX.js → AuditLogPage-DL7PJi-M.js} +1 -1
- package/dist/assets/{ComponentNavView-HWYwp2J3.js → ComponentNavView-DKxGXsn4.js} +1 -1
- package/dist/assets/{ConsoleFloatingChatbot-CYQ0DGQS.js → ConsoleFloatingChatbot-C2nsKCCe.js} +1 -1
- package/dist/assets/{DashboardView-_v1xyHY7.js → DashboardView-B7b14P2Q.js} +1 -1
- package/dist/assets/{DashboardWidgetInspector-CagpzDS6.js → DashboardWidgetInspector-C34BJd1Y.js} +1 -1
- package/dist/assets/{DeveloperHubPage-BSqHoM6g.js → DeveloperHubPage-L2d7wuq1.js} +1 -1
- package/dist/assets/{ExpressionProvider-BeRnSjp4.js → ExpressionProvider-1HR1mriH.js} +1 -1
- package/dist/assets/{FlowRunsPage-dzQVp59a.js → FlowRunsPage-BjOtW_pQ.js} +1 -1
- package/dist/assets/{IntegrationsPage-COUMVn63.js → IntegrationsPage-DAdLb-sn.js} +1 -1
- package/dist/assets/{InterfaceListPage-DyRkCp_l.js → InterfaceListPage-DqCSKUiZ.js} +1 -1
- package/dist/assets/{ManagedByBadge-CorAI3gR.js → ManagedByBadge-DbBdqwy6.js} +1 -1
- package/dist/assets/{MarketplaceAccessDenied-BQ6-NcgV.js → MarketplaceAccessDenied-D5Q4tCaN.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-CUPRsl4f.js → MarketplaceInstalledPage-DVJsLTJz.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-CiSZE5lH.js → MarketplacePackagePage-BAmq5XCe.js} +1 -1
- package/dist/assets/{MarketplacePage-CzTXmemx.js → MarketplacePage-DEHHowk4.js} +1 -1
- package/dist/assets/MetadataInspector-B-6wYdsG.js +1 -0
- package/dist/assets/{MetadataProvider-CkIT9awy.js → MetadataProvider-BWz_wO6c.js} +1 -1
- package/dist/assets/{PageView-B82BdAMg.js → PageView-Cpr2xKrz.js} +1 -1
- package/dist/assets/{ProfilePage-BbTxTg63.js → ProfilePage-DqnQIsPE.js} +1 -1
- package/dist/assets/{PublicFormsPage-CHmoVuOC.js → PublicFormsPage-31yNJEQI.js} +1 -1
- package/dist/assets/{RecordDetailView-Bo53OY-a.js → RecordDetailView-BQ_3CT6r.js} +2 -2
- package/dist/assets/{RecordFormPage-BXLWOLOE.js → RecordFormPage-BlwecW-b.js} +1 -1
- package/dist/assets/{ReportDefaultInspector-BxP74HM2.js → ReportDefaultInspector-CN7-euct.js} +2 -2
- package/dist/assets/{ReportView-BWv6u_ys.js → ReportView-sIfQGnUd.js} +1 -1
- package/dist/assets/{SearchResultsPage-DvvT6E4h.js → SearchResultsPage-tqhQY_2e.js} +1 -1
- package/dist/assets/{SettingsHub-CDaz4A8F.js → SettingsHub-DxYP6XPZ.js} +1 -1
- package/dist/assets/{SettingsView-CkL3YJNr.js → SettingsView-BozW36Q1.js} +1 -1
- package/dist/assets/{SystemHubPage-DRMrwvla.js → SystemHubPage-BWj_QRhg.js} +1 -1
- package/dist/assets/{data-adapter-B9YoyoUW.js → data-adapter-ByjA1NUo.js} +1 -1
- package/dist/assets/{framework-BGQ7DoWM.js → framework-DxDZ_zWg.js} +7 -7
- package/dist/assets/{highlighted-body-OFNGDK62-D9Y-fWz-.js → highlighted-body-OFNGDK62-Dd_tKU0d.js} +1 -1
- package/dist/assets/{index-BzqR5LGR.js → index-BOAOy2Kf.js} +1 -1
- package/dist/assets/index-D77Ldu25.css +2 -0
- package/dist/assets/mermaid-GHXKKRXX-C3IUIOL6.js +1 -0
- package/dist/assets/{metadata-admin-CWGl9yQd.js → metadata-admin-D-7GOz4f.js} +5 -5
- package/dist/assets/{plugin-calendar-Bvz5MlbF.js → plugin-calendar-BcvpxKiE.js} +1 -1
- package/dist/assets/plugin-charts-CDte3Ehs.js +7 -0
- package/dist/assets/{plugin-chatbot-C7dKmmA6.js → plugin-chatbot-DniX3Bvt.js} +5 -5
- package/dist/assets/{plugin-dashboard-CWaZph1r.js → plugin-dashboard-o2MA7Ifu.js} +3 -3
- package/dist/assets/{plugin-form-B73E4Mbd.js → plugin-form-DZ4onNeM.js} +1 -1
- package/dist/assets/{plugin-gantt-Bf38rZLK.js → plugin-gantt-AilsJyD3.js} +2 -2
- package/dist/assets/{plugin-grid-a4T-OeTY.js → plugin-grid-3YqjO8MI.js} +4 -4
- package/dist/assets/{plugin-kanban-Co4jnw0I.js → plugin-kanban-CLMCf7aa.js} +1 -1
- package/dist/assets/{plugin-map-Cr2T-pjl.js → plugin-map-CWL5OAIS.js} +1 -1
- package/dist/assets/{plugin-markdown-PeIRJlRw.js → plugin-markdown-Bb6EtX1b.js} +1 -1
- package/dist/assets/{plugin-report-DacHRf4i.js → plugin-report-B8k3qnd6.js} +3 -3
- package/dist/assets/{plugin-timeline-ueCjCHSY.js → plugin-timeline-CHfJ8XYZ.js} +1 -1
- package/dist/assets/{plugin-tree-KBPNkKuR.js → plugin-tree-DabKEfvM.js} +1 -1
- package/dist/assets/{plugin-view-CbNN954o.js → plugin-view-c3Puf0-v.js} +1 -1
- package/dist/assets/plugins-views-BFmfVAkr.js +4 -0
- package/dist/assets/{skeletons-CZdepTdC.js → skeletons-Cct3--c-.js} +1 -1
- package/dist/assets/src-BM-XgFqH.js +2 -0
- package/dist/assets/src-BvIm_4jD.js +135 -0
- package/dist/assets/{src-DzNV76wU.js → src-f2cvKHyo.js} +1 -1
- package/dist/assets/{types-CoZkCf64.js → types-eEPSTWZr.js} +1 -1
- package/dist/assets/ui-components-BDy7soRa.js +42 -0
- package/dist/assets/{ui-layout-DQDnaREz.js → ui-layout-tBg9Ny6m.js} +1 -1
- package/dist/assets/{useActionModal-DI7oaRiK.js → useActionModal-Cd50Dc4Y.js} +1 -1
- package/dist/assets/{useOpenRecordList-pMYhKC_q.js → useOpenRecordList-CKVQ3oer.js} +1 -1
- package/dist/assets/{useReconcileOnError-p9SZCLMb.js → useReconcileOnError-D8Uet4j6.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/MetadataInspector-Ci4IEXl6.js +0 -1
- package/dist/assets/index-0xh0t0SY.css +0 -2
- package/dist/assets/mermaid-GHXKKRXX-DfINr0ix.js +0 -1
- package/dist/assets/plugin-charts-BQs_--tP.js +0 -7
- package/dist/assets/plugins-views-C-R-Gk81.js +0 -4
- package/dist/assets/src-DRWgP_lu.js +0 -2
- package/dist/assets/ui-components-J75dr3Ae.js +0 -42
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as e}from"./plugin-chatbot-C7dKmmA6.js";export{e as Mermaid};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,m as r,t as i}from"./vendor-react-slxo-5GC.js";import{V as a,Y as o,Z as s,b as c,ct as l,dt as u,ft as d,gt as f,ht as p,jt as m,kt as h,mt as ee,n as te,ot as ne,pt as g,st as re,ut as ie}from"./framework-BGQ7DoWM.js";import{A as _,B as v,C as y,D as b,E as ae,F as x,I as oe,L as se,M as S,N as C,O as w,P as ce,R as le,T,V as E,_ as ue,dt as D,g as O,h as de,j as k,k as fe,m as A,p as j,ut as M,v as N,w as P,y as F,z as pe}from"./vendor-charts-DVOdzzh2.js";import{B as me,Jn as he,Kt as ge,Ls as I,Qn as _e,Sc as L,Tr as R,Ut as ve,V as ye,Vt as z,Wt as be,Zn as xe,qn as B,qt as Se,zc as Ce}from"./ui-components-J75dr3Ae.js";var V=e(n(),1),H=i(),U=(...e)=>e.filter(Boolean).join(` `),we={light:``,dark:`.dark`},W=V.createContext(null);function Te(){let e=V.useContext(W);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function G({id:e,className:t,children:n,config:r,...i}){let a=V.useId(),o=`chart-${e||a.replace(/:/g,``)}`;return(0,H.jsx)(W.Provider,{value:{config:r},children:(0,H.jsxs)(`div`,{"data-slot":`chart`,"data-chart":o,className:U(`block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground`,t),style:{minHeight:280,minWidth:0,...i.style},...i,children:[(0,H.jsx)(Ee,{id:o,config:r}),(0,H.jsx)(D,{width:`100%`,height:`100%`,children:n})]})})}var Ee=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme||e.color);return n.length?(0,H.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(we).map(([t,r])=>`
|
|
2
|
-
${r} [data-chart=${e}] {
|
|
3
|
-
${n.map(([e,n])=>{let r=n.theme?.[t]||n.color;return r?` --color-${e}: ${r};`:null}).join(`
|
|
4
|
-
`)}
|
|
5
|
-
}
|
|
6
|
-
`).join(`
|
|
7
|
-
`)}}):null},K=E;function q({active:e,payload:t,className:n,indicator:r=`dot`,hideLabel:i=!1,hideIndicator:a=!1,label:o,labelFormatter:s,labelClassName:c,formatter:l,color:u,nameKey:d,labelKey:f}){let{config:p}=Te(),m=V.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,n=X(p,e,`${f||e?.dataKey||e?.name||`value`}`),r=!f&&typeof o==`string`?p[o]?.label||o:n?.label;return s?(0,H.jsx)(`div`,{className:U(`font-medium`,c),children:s(r,t)}):r?(0,H.jsx)(`div`,{className:U(`font-medium`,c),children:r}):null},[o,s,t,i,c,p,f]);if(!e||!t?.length)return null;let h=t.length===1&&r!==`dot`;return(0,H.jsxs)(`div`,{className:U(`border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl`,n),children:[h?null:m,(0,H.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=X(p,e,`${d||e.name||e.dataKey||`value`}`),i=u||e.payload.fill||e.color;return(0,H.jsx)(`div`,{className:U(`[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5`,r===`dot`?`items-center`:``),children:l&&e?.value!==void 0&&e.name?l(e.value,e.name,e,t,e.payload):(0,H.jsxs)(H.Fragment,{children:[n?.icon?(0,H.jsx)(n.icon,{}):!a&&(0,H.jsx)(`div`,{className:U(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,r===`dot`?`h-2.5 w-2.5`:``,r===`line`?`w-1`:``,r===`dashed`?`w-0 border-[1.5px] border-dashed bg-transparent`:``,h&&r===`dashed`?`my-0.5`:``),style:{"--color-bg":i,"--color-border":i}}),(0,H.jsxs)(`div`,{className:U(`flex flex-1 justify-between leading-none`,h?`items-end`:`items-center`),children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[h?m:null,(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:n?.label||e.name})]}),e.value&&(0,H.jsx)(`span`,{className:`text-foreground font-mono font-medium tabular-nums`,children:e.value.toLocaleString()})]})]})},e.dataKey)})})]})}var J=M;function Y({className:e,hideIcon:t=!1,payload:n,verticalAlign:r=`bottom`,nameKey:i}){let{config:a}=Te();return n?.length?(0,H.jsx)(`div`,{className:U(`flex items-center justify-center gap-4`,r===`top`?`pb-3`:`pt-3`,e),children:n.filter(e=>e.type!==`none`).map(e=>{let n=X(a,e,`${i||e.dataKey||`value`}`);return(0,H.jsxs)(`div`,{className:U(`[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3`),children:[n?.icon&&!t?(0,H.jsx)(n.icon,{}):(0,H.jsx)(`div`,{className:`h-2 w-2 shrink-0 rounded-[2px]`,style:{backgroundColor:e.color}}),n?.label]},e.value)})}):null}function X(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return n in t&&typeof t[n]==`string`?i=t[n]:r&&n in r&&typeof r[n]==`string`&&(i=r[n]),i in e?e[i]:e[n]}function De(e){return e?.[0]?.dataKey||`value`}function Oe(e,t,n){if(!e)return null;let r=e.payload??e,i=r?.[t];if(i==null)return null;let a=De(n);return{category:String(i),series:a,value:typeof r?.[a]==`number`?r[a]:void 0}}function ke(e,t){if(!e)return null;let n=e.name??e.payload?.name??e.root?.name;if(n==null)return null;let r=e.value??e.size??e.payload?.size;return{category:String(n),series:De(t),value:typeof r==`number`?r:void 0}}function Ae(e,t){if(!e)return null;let n=e.payload??e,r=n?.name;return r==null||n?.depth===0?null:{category:String(r),series:De(t),value:typeof n?.value==`number`?n.value:void 0}}var je=t({default:()=>Pe}),Me=`hsl(var(--primary))`,Ne={slate:`#64748b`,gray:`#6b7280`,zinc:`#71717a`,neutral:`#737373`,stone:`#78716c`,red:`#ef4444`,orange:`#f97316`,amber:`#f59e0b`,yellow:`#eab308`,lime:`#84cc16`,green:`#22c55e`,emerald:`#10b981`,teal:`#14b8a6`,cyan:`#06b6d4`,sky:`#0ea5e9`,blue:`#3b82f6`,indigo:`#6366f1`,violet:`#8b5cf6`,purple:`#a855f7`,fuchsia:`#d946ef`,pink:`#ec4899`,rose:`#f43f5e`},Z=e=>Ne[e]||e,Q=(e,t)=>e?.variant===`comparison`?{strokeOpacity:typeof e.opacity==`number`?e.opacity:t===`line`||t===`scatter`?.5:.6,fillOpacity:typeof e.opacity==`number`?e.opacity:t===`bar`?.4:t===`area`?.2:.5,strokeDasharray:e.dashArray??(t===`line`||t===`area`?`4 4`:void 0)}:null;function Pe({chartType:e=`bar`,data:t=[],config:n={},xAxisKey:r=`name`,series:i=[],className:a=``,colors:o,categoryColors:s,onChartClick:c,isAnimationActive:l}){let u=e===`column`?`bar`:e,d=Array.isArray(t)?t:[],f=l===!1?{isAnimationActive:!1}:{},[p,m]=V.useState(!1),h=V.useCallback(e=>{if(!c||!e)return;let t=Array.isArray(e.activePayload)?e.activePayload[0]:void 0;c({category:e.activeLabel==null?void 0:String(e.activeLabel),series:t?.dataKey?String(t.dataKey):void 0,value:typeof t?.value==`number`?t.value:void 0})},[c]),ee=V.useCallback(e=>{if(!c||!e)return;let t=e.payload?.[r],n=i[0]?.dataKey||`value`;c({category:t==null?void 0:String(t),series:n,value:typeof e.payload?.[n]==`number`?e.payload[n]:void 0})},[c,r,i]),te=c?{onClick:h,style:{cursor:`pointer`}}:{},ne=c?{onClick:ee,style:{cursor:`pointer`}}:{},g=V.useCallback((e,t,n)=>s&&s[e==null?``:String(e)]||n[t%n.length],[s]),re=V.useCallback(e=>{if(!c)return;let t=Oe(e,r,i);t&&c(t)},[c,r,i]),ie=V.useCallback(e=>{if(!c)return;let t=ke(e,i);t&&c(t)},[c,i]),D=V.useCallback(e=>{if(!c)return;let t=Ae(e,i);t&&c(t)},[c,i]),M=c?{onClick:re,cursor:`pointer`}:{},me=c?{onClick:ie,style:{cursor:`pointer`}}:{},he=c?{onClick:D,style:{cursor:`pointer`}}:{};V.useEffect(()=>{let e=()=>m(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let ge={bar:P,"horizontal-bar":P,line:T,area:de,pie:y,donut:y,radar:ue,scatter:O,funnel:j,combo:P,treemap:P,sankey:P}[u]||P,I=V.useCallback(e=>{if(e==null||e===``)return``;let t=typeof e==`string`?e:String(e);if(/^\d{4}-\d{2}-\d{2}/.test(t)){let e=new Date(t);if(!Number.isNaN(e.getTime())){let t=(d.length>1?Math.abs(new Date(String(d[d.length-1][r]??``)).getTime()-new Date(String(d[0][r]??``)).getTime()):0)/(1e3*60*60*24);try{return t<=62?e.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):e.toLocaleDateString(void 0,{month:`short`,year:`numeric`})}catch{return e.toISOString().slice(0,10)}}}return p&&t.length>8?t.slice(0,8)+`…`:t},[d,r,p]),_e=V.useMemo(()=>d.some(e=>String(e[r]||``).length>5),[d,r]),L=()=>Array.isArray(o)&&o.length>0?o:[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],R=V.useCallback(e=>{if(e==null||e===``)return``;let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t))return String(e);try{return new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(t)}catch{return String(t)}},[]),ve=V.useMemo(()=>({tickLine:!1,tickMargin:10,axisLine:!1,interval:`preserveStartEnd`,minTickGap:p?32:48,tickFormatter:I,...!p&&_e&&{angle:-35,textAnchor:`end`,height:60}}),[p,_e,I]);if(u===`pie`||u===`donut`){let e=u===`donut`?`52%`:0,t=L(),o={...n};return d.forEach((e,n)=>{let i=e?.[r];if(i==null||i===``)return;let a=String(i);o[a]||(o[a]={label:a,color:g(i,n,t)})}),(0,H.jsx)(G,{config:o,className:a,children:(0,H.jsxs)(y,{children:[(0,H.jsx)(K,{cursor:!1,content:(0,H.jsx)(q,{hideLabel:!0})}),(0,H.jsx)(x,{data:d,dataKey:i[0]?.dataKey||`value`,nameKey:r||`name`,innerRadius:e,strokeWidth:5,paddingAngle:2,outerRadius:`85%`,...f,...ne,children:d.map((e,n)=>(0,H.jsx)(v,{fill:Z(g(e?.[r],n,t))},`cell-${n}`))}),(0,H.jsx)(J,{verticalAlign:`bottom`,wrapperStyle:{fontSize:p?`11px`:`12px`,paddingTop:`8px`},content:(0,H.jsx)(Y,{nameKey:r,className:`flex-wrap`})})]})})}if(u===`funnel`){let e=i[0]?.dataKey||`value`,t=L(),o=c?t=>{t&&c({category:t?.payload?.[r]??t?.[r],value:t?.payload?.[e]??t?.[e]})}:void 0,s=o?{onClick:o,style:{cursor:`pointer`}}:{},l=[...d].sort((t,n)=>{let r=Number(t?.[e]??0);return Number(n?.[e]??0)-r});return(0,H.jsx)(G,{config:n,className:a,children:(0,H.jsxs)(j,{children:[(0,H.jsx)(K,{content:(0,H.jsx)(q,{})}),(0,H.jsxs)(A,{dataKey:e,data:l,nameKey:r,isAnimationActive:!0,...s,children:[(0,H.jsx)(pe,{position:`right`,fill:`hsl(var(--foreground))`,stroke:`none`,dataKey:r}),l.map((e,n)=>(0,H.jsx)(v,{fill:Z(t[n%t.length])},`funnel-cell-${n}`))]})]})})}if(u===`treemap`){let e=i[0]?.dataKey||`value`,t=L(),o=d.map((n,i)=>({name:String(n?.[r]??``),size:Number(n?.[e])||0,fill:Z(t[i%t.length])}));return(0,H.jsx)(G,{config:n,className:a,children:(0,H.jsx)(F,{data:o,dataKey:`size`,nameKey:`name`,isAnimationActive:!0,content:(0,H.jsx)(e=>{let{x:t,y:n,width:r,height:i,name:a,fill:o}=e;return r<=0||i<=0?null:(0,H.jsxs)(`g`,{children:[(0,H.jsx)(`rect`,{x:t,y:n,width:r,height:i,fill:o,stroke:`hsl(var(--background))`,strokeWidth:2}),r>48&&i>18?(0,H.jsx)(`text`,{x:t+6,y:n+18,fill:`#fff`,fontSize:12,className:`pointer-events-none`,children:a}):null]})},{}),...me,children:(0,H.jsx)(E,{})})})}if(u===`sankey`){let e=i[0]?.dataKey||`value`,t=i[0]?.label||e,o=d.filter(t=>(Number(t?.[e])||0)>0),s=[{name:t},...o.map(e=>({name:String(e?.[r]??``)}))],c=o.map((t,n)=>({source:0,target:n+1,value:Number(t?.[e])||0}));return c.length===0?(0,H.jsx)(`div`,{className:a}):(0,H.jsx)(G,{config:n,className:a,children:(0,H.jsx)(N,{data:{nodes:s,links:c},nodePadding:24,link:{stroke:`hsl(var(--muted-foreground))`,strokeOpacity:.25},node:{fill:`hsl(var(--chart-1))`},...he,children:(0,H.jsx)(E,{})})})}if(u===`radar`)return(0,H.jsx)(G,{config:n,className:a,children:(0,H.jsxs)(ue,{data:d,children:[(0,H.jsx)(le,{}),(0,H.jsx)(oe,{dataKey:r}),(0,H.jsx)(se,{}),(0,H.jsx)(K,{content:(0,H.jsx)(q,{})}),(0,H.jsx)(J,{content:(0,H.jsx)(Y,{}),...p&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map(e=>{let t=Z(n[e.dataKey]?.color||Me);return(0,H.jsx)(ce,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:.6},e.dataKey)})]})});if(u===`scatter`)return(0,H.jsx)(G,{config:n,className:a,children:(0,H.jsxs)(O,{children:[(0,H.jsx)(C,{vertical:!1}),(0,H.jsx)(w,{type:`number`,dataKey:r,name:String(n[r]?.label||r),tickLine:!1,axisLine:!1,minTickGap:p?32:48}),(0,H.jsx)(b,{type:`number`,dataKey:i[0]?.dataKey||`value`,name:String(n[i[0]?.dataKey]?.label||i[0]?.dataKey),tickLine:!1,axisLine:!1,tickFormatter:R,width:48}),(0,H.jsx)(ae,{type:`number`,range:[60,400]}),(0,H.jsx)(K,{content:(0,H.jsx)(q,{})}),(0,H.jsx)(J,{content:(0,H.jsx)(Y,{}),...p&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map((e,t)=>{let r=L(),i=Z(n[e.dataKey]?.color||r[t%r.length]),a=Q(e,`scatter`);return(0,H.jsx)(fe,{name:n[e.dataKey]?.label||e.dataKey,data:d,fill:i,fillOpacity:a?.fillOpacity,...M},e.dataKey)})]})});if(u===`combo`)return(0,H.jsx)(G,{config:n,className:a,children:(0,H.jsxs)(P,{data:d,children:[(0,H.jsx)(C,{vertical:!1}),(0,H.jsx)(w,{dataKey:r,...ve}),(0,H.jsx)(b,{yAxisId:`left`,tickLine:!1,axisLine:!1,tickFormatter:R,width:48}),(0,H.jsx)(b,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:R,width:48}),(0,H.jsx)(K,{content:(0,H.jsx)(q,{})}),(0,H.jsx)(J,{content:(0,H.jsx)(Y,{}),...p&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map((e,t)=>{let r=Z(n[e.dataKey]?.color||Me),i=e.chartType||(t===0?`bar`:`line`),a=i===`bar`?`left`:`right`,o=Q(e,i);return i===`line`?(0,H.jsx)(S,{yAxisId:a,type:`monotone`,dataKey:e.dataKey,stroke:r,strokeWidth:2,dot:!1,strokeOpacity:o?.strokeOpacity,strokeDasharray:o?.strokeDasharray,...f},e.dataKey):i===`area`?(0,H.jsx)(k,{yAxisId:a,type:`monotone`,dataKey:e.dataKey,fill:r,stroke:r,fillOpacity:o?.fillOpacity??.4,strokeOpacity:o?.strokeOpacity,strokeDasharray:o?.strokeDasharray,...f},e.dataKey):(0,H.jsx)(_,{yAxisId:a,dataKey:e.dataKey,fill:r,radius:4,fillOpacity:o?.fillOpacity,...f},e.dataKey)})]})});let ye=u===`horizontal-bar`,z=L(),be=s?Object.values(s).map(e=>Z(String(e))):[],xe=Array.from(new Set([...z,...be,...i.map((e,t)=>Z(n[e.dataKey]?.color||z[t%z.length]||Me))])),B=e=>`g`+e.replace(/[^a-zA-Z0-9]/g,``);return(0,H.jsx)(G,{config:n,className:a,children:(0,H.jsxs)(ge,{data:d,layout:ye?`vertical`:`horizontal`,...te,children:[(0,H.jsx)(`defs`,{children:xe.map(e=>(0,H.jsxs)(V.Fragment,{children:[(0,H.jsxs)(`linearGradient`,{id:`bg-${B(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.95}),(0,H.jsx)(`stop`,{offset:`100%`,style:{stopColor:e},stopOpacity:.5})]}),(0,H.jsxs)(`linearGradient`,{id:`ag-${B(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,H.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.5}),(0,H.jsx)(`stop`,{offset:`95%`,style:{stopColor:e},stopOpacity:.05})]})]},B(e)))}),(0,H.jsx)(C,{vertical:!1}),ye?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(w,{type:`number`,tickLine:!1,axisLine:!1,tickFormatter:R}),(0,H.jsx)(b,{type:`category`,dataKey:r,tickLine:!1,axisLine:!1,width:Math.min(140,Math.max(60,Math.max(...d.map(e=>String(e[r]??``).length))*7)),tickFormatter:I})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(w,{dataKey:r,...ve}),(0,H.jsx)(b,{tickLine:!1,axisLine:!1,tickFormatter:R,width:48})]}),(0,H.jsx)(K,{content:(0,H.jsx)(q,{})}),(0,H.jsx)(J,{content:(0,H.jsx)(Y,{}),...p&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map((e,t)=>{let a=L(),o=e.variant===`comparison`,s=o?i.slice(0,t).find(e=>e.variant!==`comparison`)||i[0]:e,c=o?i.indexOf(s):t,l=Z(n[s.dataKey]?.color||a[c%a.length]||Me);if(u===`bar`||u===`horizontal-bar`){let t=i.filter(e=>e.variant!==`comparison`).length===1&&!o&&i.length===1&&d.length>1,n=Q(e,`bar`);return(0,H.jsx)(_,{dataKey:e.dataKey,fill:`url(#bg-${B(l)})`,radius:4,fillOpacity:n?.fillOpacity,...f,children:t&&d.map((e,t)=>(0,H.jsx)(v,{fill:`url(#bg-${B(Z(g(e?.[r],t,a)))})`},`cell-${t}`))},e.dataKey)}if(u===`line`){let t=Q(e,`line`);return(0,H.jsx)(S,{type:`monotone`,dataKey:e.dataKey,stroke:l,strokeWidth:2,dot:!1,strokeOpacity:t?.strokeOpacity,strokeDasharray:t?.strokeDasharray,...f},e.dataKey)}if(u===`area`){let t=Q(e,`area`);return(0,H.jsx)(k,{type:`monotone`,dataKey:e.dataKey,fill:`url(#ag-${B(l)})`,stroke:l,strokeWidth:2,fillOpacity:t?.fillOpacity??1,strokeOpacity:t?.strokeOpacity,strokeDasharray:t?.strokeDasharray,...f},e.dataKey)}return null})]})})}var Fe=t({default:()=>Re});function Ie(e,t=14){return e.length>t?`${e.slice(0,t-1)}…`:e}function Le({x:e,y:t,payload:n}){let r=String(n?.value??``),i=Ie(r);return(0,H.jsx)(`g`,{transform:`translate(${e},${t})`,children:(0,H.jsxs)(`text`,{dy:10,textAnchor:`end`,transform:`rotate(-32)`,fill:`hsl(var(--muted-foreground))`,fontSize:11,fontFamily:`monospace`,children:[r!==i&&(0,H.jsx)(`title`,{children:r}),i]})})}function Re({data:e=[],dataKey:t=`value`,xAxisKey:n=`name`,height:r=400,className:i=``,color:a=`hsl(var(--primary))`}){let o=e.map(e=>String(e?.[n]??``)),s=o.length>4||o.some(e=>e.length>8);return(0,H.jsx)(`div`,{className:`p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${i}`,children:(0,H.jsx)(D,{width:`100%`,height:r,children:(0,H.jsxs)(P,{data:e,margin:{top:10,right:10,left:10,bottom:s?24:5},children:[(0,H.jsxs)(`defs`,{children:[(0,H.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,H.jsx)(`stop`,{offset:`0%`,stopColor:a,stopOpacity:1}),(0,H.jsx)(`stop`,{offset:`90%`,stopColor:a,stopOpacity:.6}),(0,H.jsx)(`stop`,{offset:`100%`,stopColor:a,stopOpacity:.3})]}),(0,H.jsxs)(`filter`,{id:`glow`,height:`130%`,children:[(0,H.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`3`,result:`blur`}),(0,H.jsx)(`feOffset`,{in:`blur`,dx:`0`,dy:`0`,result:`offsetBlur`}),(0,H.jsx)(`feFlood`,{floodColor:a,floodOpacity:`0.5`,result:`offsetColor`}),(0,H.jsx)(`feComposite`,{in:`offsetColor`,in2:`offsetBlur`,operator:`in`,result:`offsetBlur`}),(0,H.jsxs)(`feMerge`,{children:[(0,H.jsx)(`feMergeNode`,{in:`offsetBlur`}),(0,H.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]})]}),(0,H.jsx)(C,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,H.jsx)(w,{dataKey:n,tick:s?(0,H.jsx)(Le,{}):{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:{stroke:`hsl(var(--border))`},interval:s?0:`preserveStartEnd`,height:s?56:void 0,dy:s?void 0:10}),(0,H.jsx)(b,{tick:{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:!1}),(0,H.jsx)(E,{cursor:{fill:`hsl(var(--muted))`,opacity:.2},contentStyle:{backgroundColor:`hsl(var(--popover))`,borderColor:`hsl(var(--border))`,color:`hsl(var(--popover-foreground))`,borderRadius:`8px`,fontFamily:`monospace`,boxShadow:`0 4px 6px -1px rgb(0 0 0 / 0.1)`},itemStyle:{color:`hsl(var(--primary))`}}),(0,H.jsx)(M,{wrapperStyle:{paddingTop:`20px`,fontFamily:`monospace`}}),(0,H.jsx)(_,{dataKey:t,fill:`url(#barGradient)`,radius:[4,4,0,0],filter:`url(#glow)`,animationDuration:1500})]})})})}var ze=V.lazy(()=>r(()=>Promise.resolve().then(()=>Fe),void 0,import.meta.url)),Be=V.lazy(()=>r(()=>Promise.resolve().then(()=>je),void 0,import.meta.url)),Ve=({schema:e})=>(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(z,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,H.jsx)(ze,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),$=({schema:e,onChartClick:t})=>{let n=V.useMemo(()=>{let t=e.series,n=e.xAxisKey,r=e.config;if(n||(e.index?n=e.index:e.category&&(n=e.category)),t||(e.categories?t=e.categories.map(e=>({dataKey:e})):e.value&&(t=[{dataKey:e.value}])),!r&&t){let n=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],i={};t.forEach((e,t)=>{i[e.dataKey]={label:e.label||e.dataKey,color:n[t%n.length]}}),r=i}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:r,xAxisKey:n,series:t,className:e.className}},[e]);return(0,H.jsx)(V.Suspense,{fallback:(0,H.jsx)(z,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,H.jsx)(Be,{chartType:n.chartType,data:n.data,config:n.config,xAxisKey:n.xAxisKey,series:n.series,className:n.className,colors:Array.isArray(e.colors)?e.colors:void 0,categoryColors:e.categoryColors,isAnimationActive:e.isAnimationActive,onChartClick:t})})};function He(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Ue(e,t){let{field:n,function:r,groupBy:i}=t,a={};for(let t of e){let e=String(t[i]??`Unknown`);a[e]||(a[e]=[]),a[e].push(t)}return Object.entries(a).map(([e,t])=>{let a=t.map(e=>Number(e[n])||0),o;switch(r){case`count`:o=t.length;break;case`avg`:o=a.length>0?a.reduce((e,t)=>e+t,0)/a.length:0;break;case`min`:o=a.length>0?Math.min(...a):0;break;case`max`:o=a.length>0?Math.max(...a):0;break;default:o=a.reduce((e,t)=>e+t,0);break}return{[i]:e,[n]:o}})}async function We(e,t,n,r,i){if(!e.length||!t)return e;let a=i||((e,t)=>t),o=`__raw_${t}`,s=n?.fields?.[t];if(!s){let n=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[t],i=String(r??``),s=n.test(i)?i:He(i);return{...e,[t]:a(i,s),[o]:r}})}let c=s.type;if(c===`select`||c===`picklist`||c===`dropdown`){let n=s.options||[];if(n.length===0)return e.map(e=>{let n=e[t],r=String(n??``),i=He(r);return{...e,[t]:a(r,i),[o]:n}});let r={};for(let e of n)typeof e==`string`?r[e]=e:e&&typeof e==`object`&&(r[String(e.value)]=e.label||String(e.value));return e.map(e=>{let n=e[t],i=String(n??``),s=r[i]||He(i);return{...e,[t]:a(i,s),[o]:n}})}if(c===`lookup`||c===`master_detail`){let n=s.reference_to||s.reference;if(!n||!r||typeof r.find!=`function`)return e.map(e=>({...e,[o]:e[t]}));let i=[...new Set(e.map(e=>e[t]).filter(e=>e!=null))];if(i.length===0)return e.map(e=>({...e,[o]:e[t]}));let a=s.id_field||`id`;try{let c=h(await r.find(n,{$filter:{[a]:{$in:i}},$top:i.length})),l=s.reference_field||s.display_field||`name`,u={};for(let e of c){let t=String(e[a]??e.id??e._id??``),n=e[l]||e.name||e.label||e.title||t;t&&(u[t]=String(n))}return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:u[r]||r,[o]:n}})}catch(n){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,n),e.map(e=>({...e,[o]:e[t]}))}}if(c===`date`||c===`datetime`||c===`date_time`||c===`timestamp`||c===`time`)return e.map(e=>({...e,[o]:e[t]}));let l=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:l.test(r)?r:He(r),[o]:n}})}var Ge=e=>{let{schema:t}=e,n=e.onSegmentClick,r=(0,V.useContext)(o),i=e.dataSource||r?.dataSource,m=s(t.bind),{fieldOptionLabel:_}=Ce(),v=(0,V.useRef)(_);(0,V.useEffect)(()=>{v.current=_},[_]);let[y,b]=(0,V.useState)([]),[ae,x]=(0,V.useState)(()=>!(Array.isArray(t.data)&&t.data.length>0)&&(!!t.objectName||!!t.dataset)),[oe,se]=(0,V.useState)(null),[S,C]=(0,V.useState)(null),[w,ce]=(0,V.useState)(null),[le,T]=(0,V.useState)(null),{openRecordList:E}=c(),ue=te(),D=(0,V.useMemo)(()=>t.aggregate?JSON.stringify(t.aggregate):``,[t.aggregate]),O=(0,V.useMemo)(()=>t.filter?JSON.stringify(t.filter):``,[t.filter]),de=(0,V.useMemo)(()=>t.compareTo?JSON.stringify(t.compareTo):``,[t.compareTo]),k=(0,V.useMemo)(()=>t.dataset?JSON.stringify({d:t.dataset,dim:t.dimensions??[],val:t.values??[]}):``,[t.dataset,t.dimensions,t.values]),fe=e=>e!==`pie`&&e!==`donut`&&e!==`funnel`;(0,V.useEffect)(()=>{let e=!1;return(async()=>{try{let n={headers:{accept:`application/json`},credentials:`include`},r=t.objectName,i,a=null,o=t.aggregate?.groupBy;if(r)i=o&&typeof o==`object`&&!Array.isArray(o)?o.field:typeof o==`string`?o:t.xAxisKey;else if(t.dataset){let e=Array.isArray(t.dimensions)&&t.dimensions.length?t.dimensions[0]:void 0,o=await(await fetch(`/api/v1/meta/dataset/${encodeURIComponent(t.dataset)}`,n)).json().catch(()=>null);a=o?.item??o?.data??o,r=a?.object,i=((a?.dimensions||[]).find(t=>t?.name===e)??(a?.dimensions||[])[0])?.field??e}if(!r||!i){e||(ce(null),T(null));return}let s=await(await fetch(`/api/v1/meta/object/${encodeURIComponent(r)}`,n)).json().catch(()=>null),c=s?.item??s?.data??s,u=l(c?.fields?.[i]?.options),d=null;if(t.dataset&&Array.isArray(t.dimensions)){let e={};for(let n of t.dimensions){let t=(a?.dimensions||[]).find(e=>e?.name===n)?.field??n,r=re(c?.fields?.[t]?.options);r&&(e[n]=r)}Object.keys(e).length>0&&(d=e)}e||(ce(u),T(d))}catch{e||(ce(null),T(null))}})(),()=>{e=!0}},[t.objectName,t.dataset,k,D,t.xAxisKey]);let A=(0,V.useCallback)(async(e,n)=>{if(t.aggregate&&typeof e.aggregate==`function`){let r=t.aggregate.groupBy;if(r&&typeof r==`object`&&!Array.isArray(r)){let i=t.aggregate.field,a=t.aggregate.function,o={function:a,alias:i||a};a!==`count`&&i&&(o.field=i);let s=await e.aggregate(t.objectName,{groupBy:[r],aggregations:[o],where:n});return Array.isArray(s)?s:[]}let i=await e.aggregate(t.objectName,{field:t.aggregate.field,function:t.aggregate.function,groupBy:r,filter:n});return Array.isArray(i)?i:[]}if(typeof e.find==`function`){let r=h(await e.find(t.objectName,{$filter:n}));return t.aggregate&&r.length>0&&(r=Ue(r,t.aggregate)),r}return[]},[t.objectName,D]),j=(0,V.useCallback)(async(e,n)=>{if(!e||!t.objectName&&!t.dataset){n.current&&x(!1);return}n.current&&(x(!0),se(null));try{if(t.dataset&&typeof e.queryDataset==`function`){let r=g(t.filter),i=await e.queryDataset(t.dataset,{dimensions:Array.isArray(t.dimensions)?t.dimensions:[],measures:Array.isArray(t.values)?t.values:[],...r?{runtimeFilter:r}:{}});n.current&&b(Array.isArray(i?.rows)?i.rows:[]);return}let r=g(t.filter),i=t.compareTo,a=!!i&&fe(t.chartType),o=a?d(t.filter,i):null,[s,c]=await Promise.all([A(e,r),o?A(e,o):Promise.resolve([])]),l=s,u=t.aggregate?.groupBy,f=u&&typeof u==`object`&&!Array.isArray(u)?u.alias||u.field:u||t.xAxisKey;if(a&&c.length>0&&t.aggregate){let e=t.aggregate.field,n=t.aggregate.function,r=t=>{if(t==null)return null;let r=`${e}_${n}`;return r in t?Number(t[r]):n===`count`&&`${e}_count`in t?Number(t[`${e}_count`]):e in t?Number(t[e]):`value`in t?Number(t.value):`count`in t?Number(t.count):null},i=`${e}__comparison`,a=f;if(a&&l.some(e=>e[a]!=null)&&c.some(e=>e[a]!=null)){let e=new Map;for(let t of c){let n=String(t[a]??``);e.set(n,r(t))}l=l.map(t=>{let n=String(t[a]??``),r=e.get(n);return r==null?t:{...t,[i]:r}});let t=new Set(l.map(e=>String(e[a]??``)));for(let e of c){let n=String(e[a]??``);t.has(n)||l.push({[a]:n,[i]:r(e)})}}else{let e=Math.max(l.length,c.length),t=[];for(let n=0;n<e;n++){let e=l[n]||{},a=c[n];t.push(a?{...e,[i]:r(a)}:e)}l=t}}if(f&&typeof e.getObjectSchema==`function`)try{let n=await e.getObjectSchema(t.objectName);l=await We(l,f,n,e,(e,n)=>v.current(t.objectName,f,e,n))}catch{}n.current&&b(l)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&se(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&x(!1)}},[t.objectName,k,D,O,de,t.xAxisKey,t.chartType,A]);(0,V.useEffect)(()=>{let e={current:!0};return(t.objectName||t.dataset)&&!m&&!t.data?j(i,e):e.current&&x(!1),()=>{e.current=!1}},[t.objectName,k,i,m,t.data,O,D,de,j]);let M=m||t.data||y,N=Array.isArray(M)?M:[],P=t.drillDown,F=t.aggregate?.groupBy||t.xAxisKey,pe=(0,V.useMemo)(()=>{if(!F)return new Map;let e=new Map,t=`__raw_${F}`;for(let n of N){let r=n?.[F];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[N,F]),z=t.compareTo,U=!!z&&fe(t.chartType)&&!!t.aggregate&&N.some(e=>e[`${t.aggregate.field}__comparison`]!=null),we=(0,V.useMemo)(()=>{let e=Array.isArray(t.series)?t.series:null;if(!U)return e;let n=e||[{dataKey:t.aggregate.field}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[u(z,t.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:`${t.aggregate.field}__comparison`,label:r,variant:`comparison`}]},[U,t.series,t.aggregate,t.filter,z]),W=t.dataset?ne(ie(N,le),t.dimensions,t.values):null,Te=W?{...t,data:W.data,xAxisKey:W.xAxisKey,series:W.series}:{...t,data:N,...we?{series:we}:{}},G=t.colors&&!Array.isArray(t.colors)&&typeof t.colors==`object`?t.colors:null,Ee=Array.isArray(t.colors)?t.colors:void 0,K=w||G?{...w||{},...G||{}}:void 0,q={...Te,colors:Ee,...K?{categoryColors:K}:{}};if(ae&&N.length===0)return(0,H.jsxs)(`div`,{className:`p-2 `+(t.className||``),"data-testid":`chart-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,H.jsx)(`span`,{className:`sr-only`,children:`Loading chart data…`}),(0,H.jsx)(ye,{className:`h-full`})]});if(oe)return(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(t.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,H.jsx)(I,{className:`h-6 w-6 text-destructive opacity-60`}),(0,H.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:oe})]});if(!i&&t.objectName&&N.length===0)return(0,H.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(t.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,t.objectName,`”`]});let J=p(P)?e=>{let t=e.category,n=t!=null&&pe.has(String(t))?pe.get(String(t)):t;C({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,Y=n??J,X=!n&&S&&t.objectName?(()=>{let e=ee(P,S,{groupByField:F}),n={...t.filter||{},...e},r=f(P,S,t.title||`Details`),o=P?.target??`drawer`,s=(0,H.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,H.jsx)(a,{schema:{type:`object-data-table`,objectName:t.objectName,filter:n,pagination:!0,pageSize:P?.maxRows,columns:P?.columns?.map(e=>({accessorKey:e,header:e})),drillDown:{enabled:!0,mode:`record`,target:`dialog`}},dataSource:i})}),c=E&&t.objectName?(0,H.jsxs)(R,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{E(t.objectName,n),C(null)},children:[ue(`dashboard.openInList`,`Open in list`),(0,H.jsx)(L,{className:`ml-1 h-3.5 w-3.5`})]}):null;return o===`dialog`?(0,H.jsx)(B,{open:!0,onOpenChange:e=>!e&&C(null),children:(0,H.jsxs)(he,{className:`max-w-4xl`,children:[(0,H.jsxs)(xe,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,H.jsx)(_e,{children:r}),c]}),s]})}):(0,H.jsx)(ve,{open:!0,onOpenChange:e=>!e&&C(null),children:(0,H.jsxs)(be,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,H.jsxs)(ge,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,H.jsx)(Se,{children:r}),c]}),(0,H.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:s})]})})})():null;return(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(me,{active:ae&&N.length>0}),(0,H.jsx)($,{...e,schema:q,onChartClick:Y}),X]})};m.register(`object-chart`,Ge,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`data`,type:`array`,label:`Data`,description:`Optional static data`},{name:`filter`,type:`array`,label:`Filter`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`}]});var Ke=t({ChartBarRenderer:()=>Ve,ChartRenderer:()=>$,ObjectChart:()=>Ge,chartComponents:()=>qe}),qe={"bar-chart":Ve,chart:$};m.register(`bar-chart`,Ve,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,label:`Data`,required:!0},{name:`dataKey`,type:`string`,label:`Data Key`,defaultValue:`value`},{name:`xAxisKey`,type:`string`,label:`X-Axis Key`,defaultValue:`name`},{name:`height`,type:`number`,label:`Height`,defaultValue:400},{name:`color`,type:`color`,label:`Color`,defaultValue:`#8884d8`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),m.register(`chart`,Ge,{namespace:`view`,category:`view`,label:`Chart`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`type`,type:`string`,label:`Chart Type`},{name:`categoryField`,type:`string`,label:`Category Field`},{name:`valueField`,type:`string`,label:`Value Field`}]}),m.register(`chart`,$,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,label:`Chart Type`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}],defaultValue:`bar`},{name:`data`,type:`code`,label:`Data (JSON)`,required:!0},{name:`config`,type:`code`,label:`Config (JSON)`},{name:`xAxisKey`,type:`string`,label:`X Axis Key`,defaultValue:`name`},{name:`series`,type:`code`,label:`Series (JSON Array)`,required:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),m.register(`chart:bar`,$,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),m.register(`pie-chart`,$,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),m.register(`donut-chart`,$,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),m.register(`radar-chart`,$,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),m.register(`scatter-chart`,$,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}});export{Ke as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,r as i,t as a}from"./vendor-react-slxo-5GC.js";import{n as o,t as s}from"./infrastructure-BySW-NB0.js";import{$ as c,D as l,E as u,K as d,M as f,Ot as p,S as m,T as h,V as g,Y as _,Z as v,_ as y,et as b,i as x,jt as S,m as C,q as w,z as T}from"./framework-BGQ7DoWM.js";import{$a as E,$i as D,$n as O,$t as k,Ai as A,As as j,B as M,Bt as N,Cc as ee,Cr as P,D as F,Dr as te,E as I,Ec as ne,Er as L,Fo as re,G as R,Ga as ie,Gs as ae,Ha as oe,Ht as se,Ic as ce,Ii as le,Jo as z,Jr as B,Ks as V,Kt as ue,La as de,Li as fe,Lt as H,Ma as U,Mc as W,Mi as pe,Mr as me,O as he,Oi as G,Pc as K,Qt as ge,Rc as _e,Ri as q,Ro as ve,Rt as J,S as ye,Sr as be,Tc as xe,Tr as Y,U as Se,Ua as Ce,Us as we,Ut as Te,Vt as Ee,Wa as De,Wr as Oe,Ws as ke,Wt as Ae,Xi as je,Xo as Me,Xt as X,Yo as Ne,Yt as Pe,Zo as Fe,Zr as Ie,Zt as Le,_ as Re,_c as ze,_i as Be,_r as Ve,at as He,bi as Ue,bo as We,br as Ge,ca as Ke,cn as qe,dn as Je,do as Ye,dr as Xe,ds as Ze,dt as Qe,ec as $e,er as et,et as tt,f as nt,fa as rt,fi as it,fr as at,ft as ot,gr as st,h as ct,hc as lt,hi as ut,hr as dt,hs as ft,ia as pt,ir as mt,jc as ht,ji as gt,jr as _t,k as vt,ln as yt,lo as bt,lr as xt,ma as St,mc as Ct,mr as wt,mt as Tt,n as Et,na as Dt,nc as Ot,nt as kt,or as At,pr as jt,pt as Mt,qt as Nt,rr as Pt,so as Ft,sr as It,tr as Lt,ts as Rt,tt as zt,un as Bt,uo as Vt,ur as Ht,vi as Ut,vo as Wt,vr as Gt,wc as Kt,xi as qt,xr as Jt,ya as Yt,yc as Xt,yr as Zt,z as Qt,za as $t,zc as en,zi as tn,zt as nn}from"./ui-components-J75dr3Ae.js";import{a as rn}from"./plugin-grid-a4T-OeTY.js";var Z=e(n(),1),Q=a(),an={grid:(0,Q.jsx)(We,{className:`h-4 w-4`}),kanban:(0,Q.jsx)(E,{className:`h-4 w-4`}),gallery:(0,Q.jsx)(Vt,{className:`h-4 w-4`}),calendar:(0,Q.jsx)(Ot,{className:`h-4 w-4`}),timeline:(0,Q.jsx)(ht,{className:`h-4 w-4`}),gantt:(0,Q.jsx)(Ut,{className:`h-4 w-4`}),map:(0,Q.jsx)(de,{className:`h-4 w-4`}),chart:(0,Q.jsx)($e,{className:`h-4 w-4`}),tree:(0,Q.jsx)(ie,{className:`h-4 w-4`})},on={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`,chart:`Chart`,tree:`Tree`},sn=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:n,className:r,animated:i=!0})=>{let[a,o]=Z.useState(!1),s=Z.useCallback(t=>{o(!1),t!==e&&(i&&typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>n(t)):n(t))},[i,e,n]);return t.length>=2&&t.length<=4?(0,Q.jsx)(`div`,{role:`tablist`,"data-testid":`view-switcher-segmented`,className:W(`inline-flex items-center gap-0.5 rounded-lg bg-muted p-0.5 oui-view-switcher`,r),children:t.map(t=>{let n=t===e;return(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n,"aria-label":on[t],title:on[t],"data-state":n?`on`:`off`,onClick:()=>s(t),className:W(`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-[7px] text-xs font-medium transition-all duration-150`,n?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[an[t],(0,Q.jsx)(`span`,{className:`hidden sm:inline-block`,children:on[t]})]},t)})}):(0,Q.jsxs)(qe,{open:a,onOpenChange:o,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":on[e],className:W(`inline-flex items-center gap-1.5 h-7 px-2 rounded-md text-xs font-medium transition-colors oui-view-switcher`,a?`text-foreground bg-muted`:`text-muted-foreground hover:text-foreground`,r),children:[an[e],(0,Q.jsx)(`span`,{className:`hidden sm:inline-block`,children:on[e]}),(0,Q.jsx)(ae,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(yt,{align:`end`,className:`w-44 p-1`,children:t.map(t=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(t),"data-state":t===e?`on`:`off`,className:W(`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-xs transition-colors hover:bg-muted`,t===e?`text-foreground font-medium`:`text-muted-foreground`),children:[an[t],(0,Q.jsx)(`span`,{className:`flex-1 text-left`,children:on[t]}),t===e&&(0,Q.jsx)(V,{className:`h-3.5 w-3.5`})]},t))})]})};function cn({title:e,badge:t,onClear:n,clearLabel:r,defaultOpen:i=!0,children:a}){let[o,s]=Z.useState(i);return(0,Q.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 text-xs font-medium text-foreground/80 hover:text-foreground`,children:[(0,Q.jsx)(ae,{className:W(`h-3.5 w-3.5 transition-transform`,!o&&`-rotate-90`)}),e,typeof t==`number`&&t>0&&(0,Q.jsx)(`span`,{className:`ml-1 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 px-1 text-[10px] text-primary tabular-nums`,children:t})]}),n&&(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:r})]}),o&&(0,Q.jsx)(`div`,{className:`px-3 pb-3`,children:a})]})}function ln(e){let{t,allFields:n,showGroup:r,groupingConfig:i,setGroupingConfig:a,showColor:o,rowColorConfig:s,setRowColorConfig:c,showDensity:l,density:u,showHideFields:d,hiddenFields:f,updateHiddenFields:p}=e,[m,h]=Z.useState(!1),g=[!!i?.fields?.length,!!s?.field,u&&u.mode!==`compact`,(f?.size??0)>0].filter(Boolean).length,_=u?.mode===`compact`?le:u?.mode===`comfortable`?q:fe,v=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,Q.jsxs)(qe,{open:m,onOpenChange:h,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,"aria-label":v,title:v,className:W(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,g>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,Q.jsx)(A,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v}),g>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:g})]})}),(0,Q.jsxs)(yt,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold`,children:v}),(0,Q.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields.`})})]}),r&&a&&(0,Q.jsx)(cn,{title:t(`list.group`,{defaultValue:`Group`}),badge:i?.fields?.length||0,onClear:i?()=>a(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),children:(0,Q.jsx)(Se,{value:i,fieldOptions:n.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:t(`list.addGroup`,`Add group field`),collapseTitle:t(`list.collapsedByDefault`,`Collapsed by default`),removeTitle:t(`list.removeGroup`,`Remove`)},onChange:e=>a(e)})}),o&&c&&(0,Q.jsxs)(cn,{title:t(`list.color`,{defaultValue:`Row color`}),onClear:s?()=>c(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!s,children:[(0,Q.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,Q.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:s?.field||``,onChange:e=>{let t=e.target.value;c(t?{field:t,colors:s?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,Q.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),n.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),l&&u&&(0,Q.jsx)(cn,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:u.mode!==`compact`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:u.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,Q.jsx)(_,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`text-xs`,children:u.mode===`compact`?t(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):u.mode===`comfortable`?t(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):t(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`})})]}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),d&&f&&p&&(0,Q.jsx)(cn,{title:t(`list.hideFieldsTitle`,{defaultValue:`Hide fields`}),badge:f.size,onClear:f.size>0?()=>p(new Set):void 0,clearLabel:t(`list.showAll`,{defaultValue:`Show all`}),defaultOpen:f.size>0,children:(0,Q.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:n.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!f.has(e.name),onChange:()=>{let t=new Set(f);t.has(e.name)?t.delete(e.name):t.add(e.name),p(t)},className:`rounded border-input`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function un(){try{let{t:e}=x(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}catch{return`More`}}var dn=new Set([`lookup`,`master_detail`,`user`,`owner`]);function fn(e){switch(e){case void 0:case`equals`:case`eq`:return`=`;case`not_equals`:case`ne`:case`neq`:return`!=`;case`gte`:return`>=`;case`lte`:return`<=`;case`gt`:return`>`;case`lt`:return`<`;case`not_in`:case`nin`:return`not in`;default:return e}}function pn(e){return(e||[]).filter(e=>e&&(e.id||e.name)).map(e=>({id:e.id??e.name,label:typeof e.label==`string`?e.label:e.label?.toString?.()??e.id??e.name,filters:Array.isArray(e.filters)?e.filters:Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>[e.field,fn(e.operator),e.value]):[],default:e.default??e.isDefault}))}function mn({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){switch(e.element){case`dropdown`:return(0,Q.jsx)(gn,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s});case`tabs`:return(0,Q.jsx)(_n,{tabs:pn(e.tabs||[]),showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a,initialTab:typeof o?._tab?.[0]==`string`?o._tab[0]:void 0,onSelectionsChange:s});default:return null}}function hn(e,t,n,r){return e.map(e=>{let i=e.options?[...e.options]:[],a=e.type,o,s,c;if(t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n&&(a||=n.type,o=n.reference_to??n.reference,s=n.display_field??n.reference_field,c=n.id_field,i.length===0&&n.options&&(i=Array.isArray(n.options)?n.options.map(e=>({label:e.label??String(e.value??e),value:e.value??e,color:e.color})):Object.entries(n.options).map(([e,t])=>({label:t?.label||e,value:e,color:t?.color}))))}i.length===0&&a===`boolean`&&(i=[{label:`True`,value:!0},{label:`False`,value:!1}]),e.showCount&&n.length>0&&(i=i.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length})));let l=e.label;return r?.objectName&&(i=r.translateOptions(r.objectName,e.field,i),l=r.fieldLabel(r.objectName,e.field,e.label||e.field)),{...e,label:l,type:a,options:i,referenceTo:o,displayField:s,idField:c}})}function gn({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){let{fieldLabel:c,translateOptions:l}=en(),u=un(),d=t?.name,[f,p]=Z.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues);let n=o?.[e.field];n&&n.length>0&&(t[e.field]=n)}),t}),m=Z.useRef({}),h=Z.useMemo(()=>hn(e,t,n,{objectName:d,fieldLabel:c,translateOptions:l}).map(e=>{if(!e.showCount)return e;if((f[e.field]||[]).length===0)return m.current[e.field]=new Map(e.options.map(e=>[String(e.value),e.count??0])),e;let t=m.current[e.field];return t?{...e,options:e.options.map(e=>({...e,count:t.get(String(e.value))??e.count}))}:e}),[e,t,n,d,c,l,f]),g=Z.useCallback(e=>{r(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[r]),_=(e,t)=>{let n={...f,[e]:t};p(n),g(n),s?.(n)};Z.useEffect(()=>{let e=f,t={},n=!1;for(let[r,i]of Object.entries(e)){let e=h.find(e=>e.field===r),a=i.map(t=>{if(!e||typeof t!=`string`)return t;let n=e.options.find(e=>String(e.value)===t);return n&&n.value!==t?n.value:e.type===`boolean`&&(t===`true`||t===`false`)?t===`true`:t});t[r]=a,a.some((e,t)=>e!==i[t])&&(n=!0)}n&&(p(t),e=t),Object.values(e).some(e=>e.length>0)&&g(e)},[]);let v=i!==void 0&&i<h.length?h.slice(0,i):h,y=i!==void 0&&i<h.length?h.slice(i):[],b=e=>{let t=f[e.field]||[],n=t.length>0,r=dn.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`||e.type===`owner`),i=r?`w-72`:`w-56`;return(0,Q.jsxs)(qe,{children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:W(`inline-flex items-center gap-1 h-7 px-2 text-xs transition-colors shrink-0 rounded-md`,n?`text-foreground font-medium`:`text-muted-foreground hover:text-foreground`),children:[(0,Q.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),n&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:t.length}),n?(0,Q.jsx)(me,{className:`h-3 w-3 opacity-60 hover:opacity-100`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),_(e.field,[])}}):(0,Q.jsx)(ae,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(yt,{align:`start`,className:W(i,`p-2`),children:r?(0,Q.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,Q.jsx)(kt,{field:{value:e.field,label:e.label||e.field,type:e.type,referenceTo:e.referenceTo,displayField:e.displayField,idField:e.idField},value:t,multiple:!0,onChange:t=>{let n=Array.isArray(t)?t:t==null||t===``?[]:[t];_(e.field,n)}})}):(0,Q.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-0.5`,"data-testid":`filter-options-${e.field}`,children:e.options.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-3 text-center text-xs text-muted-foreground`,children:`No options`}):e.options.map(n=>(0,Q.jsxs)(`label`,{className:W(`flex items-center gap-2 text-sm py-1.5 px-2 rounded cursor-pointer`,t.includes(n.value)?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:t.includes(n.value),onChange:()=>{let r=t.includes(n.value)?t.filter(e=>e!==n.value):[...t,n.value];_(e.field,r)},className:`rounded border-input`}),n.color&&(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,Q.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,Q.jsx)(`div`,{className:W(`flex items-center gap-0.5 overflow-x-auto`,a),"data-testid":`user-filters-dropdown`,children:h.length===0?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,Q.jsxs)(Q.Fragment,{children:[v.map(b),y.length>0&&(0,Q.jsxs)(qe,{children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(`button`,{"data-testid":`user-filters-more`,className:`inline-flex items-center gap-1 h-7 px-2 text-xs text-muted-foreground hover:text-foreground transition-colors shrink-0 rounded-md`,children:[(0,Q.jsx)(`span`,{children:u}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/80 tabular-nums`,children:y.length}),(0,Q.jsx)(ae,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(yt,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,Q.jsx)(`div`,{className:`space-y-1`,children:y.map(b)})})]})]})})}function _n({tabs:e,showAllRecords:t,allowAddTab:n,onFilterChange:r,className:i,initialTab:a,onSelectionsChange:o}){let[s,c]=Z.useState(()=>a&&(a===`__all__`||e.some(e=>e.id===a))?a:e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),l=Z.useCallback(t=>{c(t),r(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[]),o?.({_tab:[t]})},[e,r,o]),u=Z.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return Z.useEffect(()=>{if(s&&s!==`__all__`){let t=e.find(e=>e.id===s);t&&r(t.filters||[])}},[]),(0,Q.jsxs)(`div`,{className:W(`flex items-center gap-0.5 overflow-x-auto`,i),"data-testid":`user-filters-tabs`,children:[u.map(e=>{let t=e.id??e.name??``;return(0,Q.jsx)(`button`,{"data-testid":`filter-tab-${t}`,onClick:()=>l(t),className:W(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,s===t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},t)}),n&&(0,Q.jsx)(`button`,{className:`inline-flex items-center justify-center h-7 w-7 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted shrink-0`,"data-testid":`filter-tab-add`,title:`Add filter tab`,children:(0,Q.jsx)(D,{className:`h-3.5 w-3.5`})})]})}function vn(e){switch(e){case`equals`:case`eq`:return`=`;case`notEquals`:case`not_equals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`notContains`:case`notcontains`:return`notcontains`;case`greaterThan`:case`gt`:return`>`;case`greaterOrEqual`:case`gte`:return`>=`;case`lessThan`:case`lt`:return`<`;case`lessOrEqual`:case`lte`:return`<=`;case`in`:return`in`;case`notIn`:case`not_in`:case`nin`:return`not in`;case`before`:return`<`;case`after`:return`>`;default:return e}}function yn(e){if(!Array.isArray(e)||e.length<3)return e;let[t,n,r]=e;return typeof t==`string`&&(t===`and`||t===`or`)?[t,...e.slice(1).map(e=>Array.isArray(e)?yn(e):e)]:n===`in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`=`,r[0]]:[`or`,...r.map(e=>[t,`=`,e])]:n===`not in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`!=`,r[0]]:[`and`,...r.map(e=>[t,`!=`,e])]:e}function bn(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function xn(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?yn(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function Sn(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=xn(e.conditions.map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,vn(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var Cn={"list.recordCount":`{{count}} records`,"list.recordCountOne":`{{count}} record`,"list.noItems":`No items found`,"list.noItemsMessage":`There are no records to display. Try adjusting your filters or adding new data.`,"list.firstRunTitle":`Nothing here yet`,"list.firstRunMessage":`Create your first record to get started.`,"list.noMatches":`No matching records`,"list.noMatchesMessage":`No records match your current filters or search. Try adjusting or clearing them.`,"list.loading":`Loading records…`,"list.loadErrorTitle":`Couldn’t load records`,"list.loadErrorMessage":`Something went wrong while loading this data. Check your connection and try again.`,"list.retry":`Retry`,"list.search":`Search`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.group":`Group`,"list.groupBy":`Group By`,"list.export":`Export`,"list.exportAs":`Export as {{format}}`,"list.color":`Color`,"list.rowColor":`Row Color`,"list.colorByField":`Color by field`,"list.clear":`Clear`,"list.none":`None`,"list.hideFields":`Hide fields`,"list.showAll":`Show all`,"list.pullToRefresh":`Pull to refresh`,"list.refreshing":`Refreshing…`,"list.dataLimitReached":`Showing first {{limit}} records. More data may be available.`,"list.addRecord":`Add record`,"list.tabs":`Tabs`,"list.allRecords":`All Records`,"list.share":`Share`,"list.print":`Print`,"list.hideFieldsTitle":`Hide Fields`,"table.rowsPerPage":`Rows per page`,"grid.toolbar.densityMode":`Density`,"grid.toolbar.densityCompact":`Compact`,"grid.toolbar.densityComfortable":`Comfortable`,"grid.toolbar.densitySpacious":`Spacious`,"grid.toolbar.densityCycleHint":`{{label}} (click to cycle)`,"grid.toolbar.densityCycleShortHint":`Click to cycle`,"list.viewSettings":`View settings`,"list.viewSettingsHint":`Grouping, color, density, and visible fields.`},wn=(e,t,n)=>n,Tn=(e,t)=>{let n=Cn[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n};function En(){try{let e=x();return e.t(`list.recordCount`)===`list.recordCount`?{t:Tn}:{t:e.t}}catch{return{t:Tn}}}function Dn(){try{let{fieldLabel:e,actionLabel:t}=_e();return{fieldLabel:e,actionLabel:t}}catch{return{fieldLabel:wn,actionLabel:void 0}}}var On=Z.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onHiddenFieldsChange:s,onColumnStateChange:c,onRowClick:l,showViewSwitcher:u,userFilterSelections:d,onUserFilterSelectionsChange:f,...m},h)=>{let _=u??e?.showViewSwitcher??!1,{t:v}=En(),{fieldLabel:b,actionLabel:x}=Dn(),{translateOptions:S}=en(),C=Z.useMemo(()=>e.viewType&&e.viewType!==`list`?e:{...e,viewType:`grid`},[e]),w=Z.useCallback((e,t)=>C.objectName?b(C.objectName,e,t):t,[C.objectName,b]),E=Z.useCallback(e=>{let t=bn(e);return C.objectName&&typeof x==`function`?x(C.objectName,e,t):t},[C.objectName,x]),O=Z.useMemo(()=>{let e=C.userActions,t=C.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?C.showSearch!==!1:e.search,showSort:e?.sort===void 0?C.showSort!==!1:e.sort,showFilters:e?.filter===void 0?C.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?C.showDensity!==!1:e.rowHeight,showHideFields:C.showHideFields===!0,showGroup:C.showGroup!==!1,showColor:C.showColor===!0,compactToolbar:C.compactToolbar===!0,showAddRecord:t,addRecordPosition:C.addRecord?.position===`bottom`?`bottom`:`top`}},[C.userActions,C.showSearch,C.showSort,C.showFilters,C.showDensity,C.showHideFields,C.showGroup,C.showColor,C.compactToolbar,C.addRecord,C.userActions?.addRecordForm]),[k,A]=Z.useState(C.viewType),[j,N]=Z.useState(``),[P,F]=Z.useState(!1),[I,ne]=Z.useState(!1),[L,re]=Z.useState(()=>C.sort&&C.sort.length>0?C.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}}):[]),ie=Z.useMemo(()=>JSON.stringify(C.sort||[]),[C.sort]);Z.useEffect(()=>{C.sort&&C.sort.length>0?re(C.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}})):re([])},[ie]);let[ae,oe]=Z.useState(!1),[se,ce]=Z.useState({id:`root`,logic:`and`,conditions:[]}),z=m.dataSource,[V,ue]=Z.useState([]),[de,H]=Z.useState(null),[U,he]=Z.useState(()=>!(Array.isArray(C.data)||C.data&&typeof C.data==`object`&&C.data.provider===`value`&&Array.isArray(C.data.items))),[K,ge]=Z.useState(null),[_e,ve]=Z.useState(!1),[J,ye]=Z.useState(0),[be,xe]=Z.useState(!1);Z.useImperativeHandle(h,()=>({refresh:()=>ye(e=>e+1)}),[]),Z.useEffect(()=>{if(!(!z?.onMutation||!C.objectName||C.refreshTrigger))return z.onMutation(e=>{e.resource===C.objectName&&ye(e=>e+1)})},[z,C.objectName,C.refreshTrigger]);let[Ce,we]=Z.useState(void 0),Te=Ce??C.pagination?.pageSize??100,[Ee,De]=Z.useState(1),[Oe,ke]=Z.useState(null),Ae=Z.useMemo(()=>{if(C.grouping?.fields?.length)return C.grouping;let e=typeof C.groupBy==`string`?C.groupBy.trim():``,t=typeof C.groupBy2==`string`?C.groupBy2.trim():``,n=[];return e&&n.push({field:e,order:`asc`,collapsed:!1}),t&&t!==e&&n.push({field:t,order:`asc`,collapsed:!1}),n.length>0?{fields:n}:void 0},[C.grouping,C.groupBy,C.groupBy2]),[X,Ne]=Z.useState(Ae),[Pe,Fe]=Z.useState(!1),Le=Z.useRef(Ae);Z.useEffect(()=>{Le.current!==Ae&&(Le.current=Ae,Ne(Ae))},[Ae]);let[Re,ze]=Z.useState(C.rowColor),[Ve,He]=Z.useState(!1),[Ue,We]=Z.useState([]),Ge=Z.useRef(0),[Ke,Ye]=Z.useState([]),Xe=Z.useMemo(()=>{let e=C.userFilters;if(!e)return;if(e.element===`tabs`||e.fields&&e.fields.length>0||!K?.fields)return e;let t=new Set([`select`,`multi-select`,`boolean`]),n=[],r=Array.isArray(K.fields)?K.fields.map(e=>[e.name,e]):Object.entries(K.fields);for(let[e,i]of r)(t.has(i.type)||i.options&&!i.type)&&n.push({field:e,label:w(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[C.userFilters,K,w]),[Ze,Qe]=Z.useState(()=>new Set(C.hiddenFields||[])),$e=Z.useMemo(()=>JSON.stringify(C.hiddenFields||[]),[C.hiddenFields]);Z.useEffect(()=>{Qe(new Set(C.hiddenFields||[]))},[$e]);let et=Z.useCallback(e=>{Qe(e),s?.(Array.from(e))},[s]),[nt,rt]=Z.useState(!1),[it,at]=Z.useState(!1),ot=Z.useMemo(()=>{if(C.exportOptions)return Array.isArray(C.exportOptions)?{formats:C.exportOptions}:C.exportOptions},[C.exportOptions]),st=y(Z.useMemo(()=>C.densityMode?C.densityMode:C.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[C.rowHeight]||`comfortable`:`compact`,[C.densityMode,C.rowHeight]),{onChange:C.onDensityChange}),ct=Z.useMemo(()=>`objectui:gallery:density:${C.objectName??`default`}`,[C.objectName]),[lt,ut]=Z.useState(()=>{if(typeof window>`u`)return C.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(ct);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return C.gallery?.cardSize??`medium`}),dt=Z.useCallback(()=>{ut(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(ct,t)}catch{}return t})},[ct]),{ref:ft,isRefreshing:pt,pullDistance:mt}=rn({onRefresh:Z.useCallback(async()=>{ye(e=>e+1)},[]),enabled:!!z&&!!C.objectName}),ht=Z.useMemo(()=>C.id?`listview-${C.objectName}-${C.id}-view`:`listview-${C.objectName}-view`,[C.objectName,C.id]);Z.useEffect(()=>{let e=!0;return ve(!1),ge(null),(async()=>{if(!z||!C.objectName){ve(!0);return}if(typeof z.getObjectSchema!=`function`){ve(!0);return}try{let t=await z.getObjectSchema(C.objectName);e&&ge(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&ve(!0)}})(),()=>{e=!1}},[C.objectName,z]);let gt=Z.useMemo(()=>{let e=Array.isArray(C.fields)?C.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=new Set(e),n=e=>{if(!e)return;let n=[e.groupField,e.groupBy,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.subtitleField,e.swimlaneField,e.valueField,...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of n)typeof e==`string`&&e&&t.add(e)};n(C.kanban),n(C.options?.kanban),n(C.calendar),n(C.options?.calendar),n(C.gallery),n(C.options?.gallery),n(C.timeline),n(C.options?.timeline),n(C.gantt),n(C.options?.gantt);let r=t.size>0?Array.from(t):void 0;return p(K?.fields,r)},[K?.fields,C.fields,C.kanban,C.calendar,C.gallery,C.timeline,C.gantt,C.options]),_t=o();Z.useEffect(()=>{let e=!0,t=++Ge.current;if(C.data&&typeof C.data==`object`&&!Array.isArray(C.data)){let e=C.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(j){let e=j.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}ue(t),he(!1),xe(!1);return}}if(Array.isArray(C.data)){let e=C.data;if(j){let t=j.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}ue(e),he(!1),xe(!1);return}return _e?((async()=>{if(!z||!C.objectName){he(!1);return}he(!0),H(null);try{let n=[],r=C.filters||[],i=Sn(se),a=xn(Ke),o=[...r.length>0?[r]:[],...i.length>0?[i]:[],...a].filter(e=>Array.isArray(e)&&e.length>0);o.length>1?n=[`and`,...o]:o.length===1&&(n=o[0]);let s=L.length>0?L.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,c=(()=>{let e=Array.isArray(C.fields)?C.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=_t?.isLoaded&&C.objectName?e.filter(e=>_t.checkField(C.objectName,e,`read`)):e;if(t.length===0)return;let n=new Set([`id`]);for(let e of t)n.add(e);for(let e of gt)n.add(e);let r=(()=>{let e=K?.fields;if(!e)return null;let t=Array.isArray(e)?e.map(e=>e?.name).filter(e=>typeof e==`string`):Object.keys(e),n=new Set(t);return n.add(`id`),n.add(`created_at`),n.add(`updated_at`),n})(),i=e=>{typeof e!=`string`||!e||(!r||r.has(e))&&n.add(e)},a=e=>{if(!e)return;let t=[e.groupField,e.groupBy,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.subtitleField,e.swimlaneField,e.valueField,...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[],...Array.isArray(e.metaFields)?e.metaFields:[]];for(let e of t)i(e)};a(C.kanban),a(C.options?.kanban),a(C.calendar),a(C.options?.calendar),a(C.gallery),a(C.options?.gallery),a(C.timeline),a(C.options?.timeline);{let e=C.timeline??C.options?.timeline;e&&!Array.isArray(e.metaFields)&&(i(`status`),i(`priority`))}return a(C.gantt),a(C.options?.gantt),Array.from(n)})(),l=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,u=k===`grid`&&!X?.fields?.length,d=u?(Ee-1)*Te:0,f=await z.find(C.objectName,{...l?{$filter:n}:{},$orderby:s,$top:Te,...d>0?{$skip:d}:{},...c?{$select:c}:{},...gt.length>0?{$expand:gt}:{},...j?{$search:j,...C.searchableFields&&C.searchableFields.length>0?{$searchFields:C.searchableFields}:{}}:{}});if(!e||t!==Ge.current)return;let p=[];Array.isArray(f)?p=f:f&&typeof f==`object`&&(Array.isArray(f.data)?p=f.data:Array.isArray(f.records)?p=f.records:Array.isArray(f.value)&&(p=f.value)),ue(p);let m=f&&typeof f==`object`?f.total??f.count:void 0,h=typeof m==`number`?m:null;ke(u?h:null),xe(!(u&&h!=null)&&p.length>=Te)}catch(e){t===Ge.current&&(console.error(`ListView data fetch error:`,e),ue([]),H(e?.message?String(e.message):String(e??`Unknown error`)))}finally{e&&t===Ge.current&&he(!1)}})(),()=>{e=!1}):void 0},[C.objectName,C.data,z,C.filters,Te,L,se,Ke,J,j,C.searchableFields,gt,_e,C.refreshTrigger,_t,Ee,k,X]);let vt=JSON.stringify([C.objectName,C.filters,Te,L,se,Ke,j,k,X]),xt=Z.useRef(vt);Z.useEffect(()=>{xt.current!==vt&&(xt.current=vt,De(1))},[vt]);let St=Z.useMemo(()=>{let e=[`grid`];(C.kanban?.groupByField||C.kanban?.groupField||C.options?.kanban?.groupField)&&e.push(`kanban`),(C.gallery?.coverField||C.gallery?.imageField||C.options?.gallery?.imageField)&&e.push(`gallery`),(C.calendar?.startDateField||C.options?.calendar?.startDateField)&&e.push(`calendar`),(C.timeline?.startDateField||C.options?.timeline?.startDateField||C.options?.timeline?.dateField||C.options?.calendar?.startDateField)&&e.push(`timeline`),(C.gantt?.startDateField||C.options?.gantt?.startDateField)&&e.push(`gantt`),(C.options?.map?.locationField||C.options?.map?.latitudeField&&C.options?.map?.longitudeField)&&e.push(`map`),(C.tree?.parentField||C.options?.tree?.parentField||C.viewType===`tree`)&&e.push(`tree`),C.viewType&&!e.includes(C.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`,`tree`].includes(C.viewType)&&e.push(C.viewType);let t=C.appearance?.allowedVisualizations;if(Array.isArray(t)&&t.length>0){let n=t.filter(t=>e.includes(t));return n.length>0?n:[`grid`]}return e},[C.options,C.viewType,C.kanban,C.calendar,C.gantt,C.gallery,C.timeline,C.tree,C.appearance?.allowedVisualizations]);Z.useEffect(()=>{C.viewType&&A(C.viewType)},[C.viewType]);let Ct=Z.useCallback(e=>{A(e);try{localStorage.setItem(ht,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[ht,n]),wt=Z.useCallback(e=>{N(e),a?.(e)},[a]),Tt=T({navigation:C.navigation,objectName:C.objectName,onNavigate:C.onNavigate,onRowClick:l}),Et=Z.useMemo(()=>{let e=C.fields||[];if(Array.isArray(e)||(e=[]),_t?.isLoaded&&C.objectName&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t?_t.checkField(C.objectName,t,`read`):!0})),Ze.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!Ze.has(t)})),C.fieldOrder&&C.fieldOrder.length>0){let t=new Map(C.fieldOrder.map((e,t)=>[e,t]));e=[...e].sort((e,n)=>{let r=typeof e==`string`?e:e?.name||e?.fieldName||e?.field,i=typeof n==`string`?n:n?.name||n?.fieldName||n?.field;return(t.get(r)??1/0)-(t.get(i)??1/0)})}return e},[C.fields,C.objectName,Ze,C.fieldOrder,_t]),Dt=Z.useMemo(()=>{let e=st.mode===`compact`?`compact`:st.mode===`spacious`?`tall`:`medium`,t={objectName:C.objectName,fields:Et,filters:C.filters,sort:L,className:`h-full w-full`,showSearch:!1,onRowClick:Tt.handleClick,rowHeight:e,hideRowHeightToggle:!0,...C.striped==null?{}:{striped:C.striped},...C.bordered==null?{}:{bordered:C.bordered},...c?{onColumnStateChange:c}:{},...C.columnState?{columnState:C.columnState}:{}};switch(k){default:case`grid`:return{type:`object-grid`,...t,columns:Et,...C.conditionalFormatting?{conditionalFormatting:C.conditionalFormatting}:{},...C.inlineEdit==null?{}:{editable:C.inlineEdit},...C.wrapHeaders==null?{}:{wrapHeaders:C.wrapHeaders},...C.virtualScroll==null?{}:{virtualScroll:C.virtualScroll},...C.resizable==null?{}:{resizable:C.resizable},...C.selection?{selection:C.selection}:{},...C.pagination?{pagination:C.pagination}:{},...X?{grouping:X}:{},...Re?{rowColor:Re}:{},...C.rowActions?{rowActions:C.rowActions}:{},...C.rowActionDefs?{rowActionDefs:C.rowActionDefs}:{},...C.bulkActions?{batchActions:C.bulkActions}:{},...C.bulkActionDefs?{bulkActionDefs:C.bulkActionDefs}:{},...C.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...t,groupBy:C.kanban?.groupField||C.options?.kanban?.groupField||`status`,groupField:C.kanban?.groupField||C.options?.kanban?.groupField||`status`,...C.kanban?.titleField||C.options?.kanban?.titleField?{titleField:C.kanban?.titleField||C.options?.kanban?.titleField}:{},cardFields:C.kanban?.cardFields||Et||[],...X?{grouping:X}:{},...C.options?.kanban||{},...C.kanban||{}};case`calendar`:return{type:`object-calendar`,...t,startDateField:C.calendar?.startDateField||C.options?.calendar?.startDateField||`start_date`,endDateField:C.calendar?.endDateField||C.options?.calendar?.endDateField||`end_date`,...C.calendar?.titleField||C.options?.calendar?.titleField?{titleField:C.calendar?.titleField||C.options?.calendar?.titleField}:{},...C.calendar?.defaultView?{defaultView:C.calendar.defaultView}:{},...C.options?.calendar||{},...C.calendar||{}};case`gallery`:{let e={...C.options?.gallery||{},...C.gallery||{},cardSize:lt};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:C.gallery?.coverField||C.gallery?.imageField||C.options?.gallery?.imageField,titleField:C.gallery?.titleField||C.options?.gallery?.titleField||`name`,subtitleField:C.gallery?.subtitleField||C.options?.gallery?.subtitleField,...X?{grouping:X}:{}}}case`timeline`:{let e={...C.options?.timeline||{},...C.timeline||{}};return{type:`object-timeline`,...t,timeline:Object.keys(e).length>0?e:void 0,startDateField:C.timeline?.startDateField||C.options?.timeline?.startDateField||C.options?.timeline?.dateField||`created_at`,titleField:C.timeline?.titleField||C.options?.timeline?.titleField||`name`,...C.timeline?.endDateField?{endDateField:C.timeline.endDateField}:{},...C.timeline?.groupByField?{groupByField:C.timeline.groupByField}:{},...C.timeline?.colorField?{colorField:C.timeline.colorField}:{},...C.timeline?.scale?{scale:C.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,startDateField:C.gantt?.startDateField||C.options?.gantt?.startDateField||`start_date`,endDateField:C.gantt?.endDateField||C.options?.gantt?.endDateField||`end_date`,progressField:C.gantt?.progressField||C.options?.gantt?.progressField||`progress`,dependenciesField:C.gantt?.dependenciesField||C.options?.gantt?.dependenciesField||`dependencies`,...C.gantt?.titleField?{titleField:C.gantt.titleField}:{},...C.options?.gantt||{},...C.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:C.options?.map?.locationField||`location`,...C.options?.map||{}};case`tree`:{let e=C.tree||C.options?.tree||{};return{type:`object-tree`,...t,parentField:e.parentField,labelField:e.labelField||e.titleField||`name`,fields:e.fields||Et,defaultExpandedDepth:e.defaultExpandedDepth,...e}}case`chart`:{let e=C.chart||C.options?.chart||{};if(e.dataset){let t=Array.isArray(e.dimensions)?e.dimensions:[],n=Array.isArray(e.values)?e.values:[];return{type:`object-chart`,dataset:e.dataset,dimensions:t,values:n,chartType:e.chartType||`bar`,xAxisKey:t[0],series:n.map(e=>({dataKey:e,label:e})),className:`h-[400px] w-full`}}let t=Array.isArray(e.yAxisFields)&&e.yAxisFields[0]||e.valueField||`value`,n=e.xAxisField||e.categoryField||`name`;return{type:`object-chart`,objectName:C.objectName,chartType:e.chartType||`bar`,filters:C.filters,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[k,C,L,Et,X,Re,Tt.handleClick,st.mode,lt]),Ot=se.conditions&&se.conditions.length>0,kt=Z.useMemo(()=>{let e,t=(e,t)=>{if(!t)return;let n=Array.isArray(t)?t.map(e=>({value:e?.value??e,label:e?.label??String(e?.value??e),...e&&typeof e==`object`?e:{}})):Object.entries(t).map(([e,t])=>({value:e,label:t?.label||e,...t}));return C.objectName?S(C.objectName,e,n):n};if(e=K?.fields?Object.entries(K.fields).map(([e,n])=>({value:e,label:w(e,n.label||e),type:n.type||`text`,options:t(e,n.options),referenceTo:n.reference_to||n.reference,displayField:n.display_field||n.reference_field,idField:n.id_field})):(C.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let n=e.name||e.fieldName;return{value:n,label:w(n,e.label||e.name),type:e.type||`text`,options:t(n,e.options),referenceTo:e.reference_to||e.reference,displayField:e.display_field||e.reference_field,idField:e.id_field}}),C.filterableFields&&C.filterableFields.length>0){let t=new Set(C.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[K,C.fields,C.filterableFields,C.objectName,w,S]),At=Z.useCallback(e=>{let t=ot,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||C.objectName||`export`,a=n>0?V.slice(0,n):V;if(e===`csv`){let e=Et.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];r&&t.push(e.join(`,`)),a.forEach(n=>{t.push(e.map(e=>{let t=n[e],r;return r=t==null?``:Array.isArray(t)?t.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof t==`object`?JSON.stringify(t):String(t),r.includes(`,`)||r.includes(`"`)||r.includes(`
|
|
2
|
-
`)||r.includes(`\r`)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`))});let n=new Blob([t.join(`
|
|
3
|
-
`)],{type:`text/csv;charset=utf-8;`}),o=URL.createObjectURL(n),s=document.createElement(`a`);s.href=o,s.download=`${i}.csv`,s.click(),URL.revokeObjectURL(o)}else if(e===`json`){let e=new Blob([JSON.stringify(a,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${i}.json`,n.click(),URL.revokeObjectURL(t)}at(!1)},[V,Et,ot,C.objectName]),jt=Z.useMemo(()=>(C.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:w(e,e)};let t=e.name||e.fieldName||e.field;return{name:t,label:w(t,e.label||e.name||e.field)}}),[C.fields,w]);return(0,Q.jsxs)(`div`,{ref:ft,className:W(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,t),...C.aria?.label?{"aria-label":C.aria.label}:{},...C.aria?.describedBy?{"aria-describedby":C.aria.describedBy}:{},...C.aria?.live?{"aria-live":C.aria.live}:{},role:`region`,"aria-busy":U||void 0,"data-state":U?`loading`:`idle`,children:[mt>0&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:mt},children:v(pt?`list.refreshing`:`list.pullToRefresh`)}),C.description&&C.appearance?.showDescription!==!1&&(0,Q.jsx)(`div`,{className:`px-4 pt-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:typeof C.description==`string`?C.description:``}),(0,Q.jsxs)(`div`,{className:`border-b px-2 sm:px-4 py-1.5 flex items-center justify-between gap-1 sm:gap-2 bg-background`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:Xe&&(0,Q.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,Q.jsx)(mn,{config:Xe,objectDef:K,data:V,onFilterChange:Ye,maxVisible:3,initialSelections:d,onSelectionsChange:f})})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0 shrink-0 rounded-lg border border-border bg-muted/40 p-0.5 shadow-sm`,children:[_&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(sn,{currentView:k,availableViews:St,onViewChange:Ct}),(0,Q.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),O.showHideFields&&!O.compactToolbar&&(0,Q.jsxs)(qe,{open:nt,onOpenChange:rt,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:W(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Ze.size>0&&`text-primary`),children:[(0,Q.jsx)(Me,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.hideFields`)}),Ze.size>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:Ze.size})]})}),(0,Q.jsx)(yt,{align:`start`,className:`w-64 p-3`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:v(`list.hideFieldsTitle`)}),Ze.size>0&&(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>et(new Set),children:v(`list.showAll`)})]}),(0,Q.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:jt.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!Ze.has(e.name),onChange:()=>{let t=new Set(Ze);t.has(e.name)?t.delete(e.name):t.add(e.name),et(t)},className:`rounded border-input`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),O.showHideFields&&!O.compactToolbar&&(O.showFilters||O.showSort||O.showGroup)&&(0,Q.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),O.showFilters&&(0,Q.jsxs)(qe,{open:ae,onOpenChange:oe,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:W(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Ot&&`text-foreground font-medium`),children:[(0,Q.jsx)(qt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.filter`)}),Ot&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:se.conditions?.length||0})]})}),(0,Q.jsx)(yt,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:v(`list.filterRecords`)})}),(0,Q.jsx)(zt,{fields:kt,value:se,onChange:e=>{ce(e),r&&r(e)}})]})})]}),O.showGroup&&!O.compactToolbar&&(0,Q.jsxs)(qe,{open:Pe,onOpenChange:Fe,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:W(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,X&&`text-foreground font-medium`),children:[(0,Q.jsx)(Wt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.group`)}),X&&X.fields?.length>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:X.fields.length})]})}),(0,Q.jsx)(yt,{align:`start`,className:`w-72 p-3`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:v(`list.groupBy`)}),X&&(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ne(void 0),"data-testid":`clear-grouping`,children:v(`list.clear`)})]}),(0,Q.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,Q.jsx)(Se,{value:X,fieldOptions:jt.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:v(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:v(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:v(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>Ne(e)})})]})})]}),O.showSort&&(0,Q.jsxs)(qe,{open:I,onOpenChange:ne,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:W(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,L.length>0&&`text-foreground font-medium`),children:[(0,Q.jsx)(ee,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.sort`)}),L.length>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:L.length})]})}),(0,Q.jsx)(yt,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:v(`list.sortRecords`)})}),(0,Q.jsx)(tt,{fields:kt,value:L,onChange:e=>{re(e),i&&i(e)}})]})})]}),!O.compactToolbar&&(O.showFilters||O.showSort||O.showGroup)&&(O.showColor||O.showDensity)&&(0,Q.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),O.showColor&&!O.compactToolbar&&(0,Q.jsxs)(qe,{open:Ve,onOpenChange:He,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:W(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Re&&`text-foreground font-medium`),children:[(0,Q.jsx)(Yt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.color`)})]})}),(0,Q.jsx)(yt,{align:`start`,className:`w-64 p-3`,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,Q.jsx)(`h4`,{className:`font-medium text-sm`,children:v(`list.rowColor`)}),Re&&(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>ze(void 0),"data-testid":`clear-row-color`,children:v(`list.clear`)})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:v(`list.colorByField`)}),(0,Q.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:Re?.field||``,onChange:e=>{let t=e.target.value;ze(t?{field:t,colors:Re?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,Q.jsx)(`option`,{value:``,children:v(`list.none`)}),jt.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),O.showDensity&&!O.compactToolbar&&k!==`gallery`&&(()=>{let e=st.mode===`compact`?le:st.mode===`comfortable`?q:fe,t=st.mode===`compact`?v(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):st.mode===`comfortable`?v(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):v(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${v(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=v(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,"aria-label":n,className:W(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,st.mode!==`compact`&&`text-foreground font-medium`),onClick:st.cycle,title:r,children:(0,Q.jsx)(e,{className:`h-3.5 w-3.5`})})})(),O.showDensity&&!O.compactToolbar&&k===`gallery`&&(()=>{let e=lt===`small`?le:lt===`medium`?q:fe,t=lt===`small`?v(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):lt===`medium`?v(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):v(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${v(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=v(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,"aria-label":n,className:W(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,lt!==`small`&&`text-foreground font-medium`),onClick:dt,title:r,children:(0,Q.jsx)(e,{className:`h-3.5 w-3.5`})})})(),O.compactToolbar&&(O.showGroup||O.showColor||O.showDensity||O.showHideFields)&&(0,Q.jsx)(ln,{t:v,allFields:jt,showGroup:O.showGroup,groupingConfig:X,setGroupingConfig:Ne,showColor:O.showColor,rowColorConfig:Re,setRowColorConfig:ze,showDensity:O.showDensity,density:st,showHideFields:O.showHideFields,hiddenFields:Ze,updateHiddenFields:et}),(O.showColor||O.showDensity||O.compactToolbar)&&ot&&C.allowExport!==!1&&(0,Q.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),ot&&C.allowExport!==!1&&(0,Q.jsxs)(qe,{open:it,onOpenChange:at,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,children:[(0,Q.jsx)(Rt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.export`)})]})}),(0,Q.jsx)(yt,{align:`start`,className:`w-48 p-2`,children:(0,Q.jsx)(`div`,{className:`space-y-1`,children:(ot.formats||[`csv`,`json`]).map(e=>(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,onClick:()=>At(e),children:[(0,Q.jsx)(Rt,{className:`h-3.5 w-3.5 mr-2`}),v(`list.exportAs`,{format:e.toUpperCase()})]},e))})})]}),(C.sharing?.enabled||C.sharing?.type)&&(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${C.sharing?.visibility||C.sharing?.type||`private`}`,"data-testid":`share-button`,children:[(0,Q.jsx)(G,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.share`)})]}),C.allowPrinting&&(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,onClick:()=>window.print(),"data-testid":`print-button`,children:[(0,Q.jsx)(je,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.print`)})]}),(()=>{let e=C.allowPrinting||C.sharing?.enabled||C.sharing?.type||ot&&C.allowExport!==!1;return O.showSearch&&e?(0,Q.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),O.showSearch&&(0,Q.jsxs)(qe,{open:P,onOpenChange:F,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:W(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,j&&`text-foreground font-medium`),"data-testid":`search-icon-button`,title:v(`list.search`),children:(0,Q.jsx)(pe,{className:`h-3.5 w-3.5`})})}),(0,Q.jsx)(yt,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(pe,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Q.jsx)(Je,{placeholder:v(`list.search`)+`...`,value:j,onChange:e=>wt(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),j&&(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`absolute right-0.5 top-1/2 -translate-y-1/2 h-5 w-5 p-0 hover:bg-muted-foreground/20`,onClick:()=>wt(``),children:(0,Q.jsx)(me,{className:`h-3 w-3`})})]})})]}),O.showAddRecord&&O.addRecordPosition===`top`&&(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>m.onAddRecord?.(),children:[(0,Q.jsx)(D,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.addRecord`)})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:[(0,Q.jsx)(M,{active:U&&V.length>0}),de&&V.length===0?(0,Q.jsx)(Qt,{"data-testid":`list-error-state`,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:(0,Q.jsx)(B,{className:`h-12 w-12 text-destructive/60`}),iconWrapperClassName:`mb-3`,title:v(`list.loadErrorTitle`),description:v(`list.loadErrorMessage`),action:(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,"data-testid":`list-error-retry`,onClick:()=>ye(e=>e+1),children:[(0,Q.jsx)(tn,{className:`h-4 w-4 mr-1.5`}),v(`list.retry`)]})}):U&&V.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col h-full min-h-[200px] p-4 gap-2`,"data-testid":`list-loading`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:v(`list.loading`)}),[0,1,2,3,4,5].map(e=>(0,Q.jsx)(`div`,{className:`h-9 rounded bg-muted/60 animate-pulse`,style:{opacity:Math.max(.25,1-e*.12)}},e))]}):!U&&V.length===0&&k===`grid`?(()=>{let e=C.emptyState?.icon,t=e?te[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??bt:bt,n=!!(j&&j.trim())||Array.isArray(Ke)&&Ke.length>0||Array.isArray(se?.conditions)&&se.conditions.length>0,r=(typeof C.emptyState?.title==`string`?C.emptyState.title:void 0)??v(n?`list.noMatches`:`list.firstRunTitle`),i=(typeof C.emptyState?.message==`string`?C.emptyState.message:void 0)??v(n?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,Q.jsx)(Qt,{"data-testid":`empty-state`,className:`h-full min-h-[200px] p-8 gap-1 [&>h3]:text-lg [&>h3]:font-medium [&>h3]:text-foreground [&>p]:max-w-md`,icon:(0,Q.jsx)(t,{className:`h-12 w-12 text-muted-foreground/50`}),iconWrapperClassName:`mb-3`,title:r,description:i,action:O.showAddRecord?(0,Q.jsxs)(Y,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>m.onAddRecord?.(),children:[(0,Q.jsx)(D,{className:`h-4 w-4 mr-1.5`}),v(`list.addRecord`)]}):void 0})})():(0,Q.jsx)(g,{schema:Dt,...m,data:V,loading:U,onRowSelect:We,...k===`grid`&&!X?.fields?.length&&Oe!=null?{manualPagination:!0,rowCount:Oe,page:Ee,pageSize:Te,onPageChange:e=>De(e),onPageSizeChange:e=>{we(e),De(1)}}:{}})]},k),O.showAddRecord&&O.addRecordPosition===`bottom`&&(0,Q.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>m.onAddRecord?.(),children:[(0,Q.jsx)(D,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`list.addRecord`)})]})}),C.bulkActions&&C.bulkActions.length>0&&Ue.length>0&&k!==`grid`&&(0,Q.jsxs)(`div`,{className:`border-t border-primary/30 px-4 py-2 flex items-center gap-2 text-xs bg-primary/10 text-foreground shrink-0 shadow-sm`,role:`region`,"aria-label":`Bulk actions`,"data-testid":`bulk-actions-bar`,children:[(0,Q.jsx)(Be,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[Ue.length,` `,Ue.length===1?`item`:`items`,` selected`]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:C.bulkActions.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),r=n?Ie:null;return(0,Q.jsxs)(Y,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>m.onBulkAction?.(e,Ue),"data-testid":`bulk-action-${e}`,children:[r&&(0,Q.jsx)(r,{className:`h-3 w-3`}),E(e)]},e)})}),(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>We([]),children:[(0,Q.jsx)(me,{className:`h-3 w-3`}),`Clear`]})]}),!U&&V.length>0&&C.showRecordCount!==!1&&(0,Q.jsxs)(`div`,{className:`border-t px-4 py-2 flex items-center gap-3 text-xs text-muted-foreground bg-background shrink-0`,"data-testid":`record-count-bar`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground/80`,children:V.length===1?v(`list.recordCountOne`,{count:V.length}):v(`list.recordCount`,{count:V.length})}),be&&(0,Q.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:v(`list.dataLimitReached`,{limit:Te})}),k!==`grid`&&C.pagination?.pageSizeOptions&&C.pagination.pageSizeOptions.length>0&&(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:v(`table.rowsPerPage`,{defaultValue:`Rows per page`})}),(0,Q.jsx)(`select`,{"data-testid":`page-size-selector`,className:`h-7 w-[72px] px-2 py-1 text-xs rounded-md border border-input bg-background`,value:String(Te),onChange:e=>{let t=Number(e.target.value);we(t),m.onPageSizeChange&&m.onPageSizeChange(t)},children:C.pagination.pageSizeOptions.map(e=>(0,Q.jsx)(`option`,{value:String(e),children:e},e))})]})]}),Tt.isOverlay&&(0,Q.jsx)(R,{...Tt,title:C.label?`${C.label} Detail`:C.objectName?`${C.objectName.charAt(0).toUpperCase()+C.objectName.slice(1)} Detail`:`Record Detail`,children:e=>(0,Q.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Q.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});On.displayName=`ListView`;var kn={small:`grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6`,medium:`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,large:`grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3`},An={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},jn=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),Mn=[{bg:`from-indigo-500/15 via-indigo-500/5 to-purple-500/10`,ring:`ring-indigo-500/15`,text:`text-indigo-600/70 dark:text-indigo-300/70`},{bg:`from-sky-500/15 via-sky-500/5 to-cyan-500/10`,ring:`ring-sky-500/15`,text:`text-sky-600/70 dark:text-sky-300/70`},{bg:`from-emerald-500/15 via-emerald-500/5 to-teal-500/10`,ring:`ring-emerald-500/15`,text:`text-emerald-600/70 dark:text-emerald-300/70`},{bg:`from-amber-500/15 via-amber-500/5 to-orange-500/10`,ring:`ring-amber-500/15`,text:`text-amber-600/70 dark:text-amber-300/70`},{bg:`from-rose-500/15 via-rose-500/5 to-pink-500/10`,ring:`ring-rose-500/15`,text:`text-rose-600/70 dark:text-rose-300/70`},{bg:`from-violet-500/15 via-violet-500/5 to-fuchsia-500/10`,ring:`ring-violet-500/15`,text:`text-violet-600/70 dark:text-violet-300/70`}];function Nn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return Mn[Math.abs(t)%Mn.length]}var Pn=({imageUrl:e,title:t,coverFit:n,aspectClass:r,placeholder:i,hidden:a})=>{let[o,s]=(0,Z.useState)(!1),c=!!e&&!o;return(0,Q.jsx)(`div`,{className:W(`w-full overflow-hidden relative`,r),hidden:a,children:c?n===`contain`?(0,Q.jsx)(`div`,{className:W(`flex h-full w-full items-center justify-center bg-gradient-to-br`,i.bg),children:(0,Q.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>s(!0),className:`h-1/2 w-1/2 max-h-24 max-w-24 object-contain transition-transform duration-300 ease-out group-hover:scale-[1.08]`})}):(0,Q.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>s(!0),className:`h-full w-full object-cover transition-transform duration-300 ease-out group-hover:scale-[1.04]`}):(0,Q.jsx)(`div`,{className:W(`flex h-full w-full items-center justify-center bg-gradient-to-br ring-1 ring-inset`,i.bg,i.ring),children:(0,Q.jsx)(`span`,{className:W(`text-5xl font-semibold tracking-tight opacity-90`,i.text),children:t[0]?.toUpperCase()})})})},Fn=({imageUrl:e,title:t,placeholder:n})=>{let[r,i]=(0,Z.useState)(!1),a=!!e&&!r;return(0,Q.jsx)(`div`,{className:W(`flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br ring-1 ring-inset`,n.bg,n.ring),children:a?(0,Q.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:()=>i(!0),className:`h-6 w-6 object-contain transition-transform duration-300 ease-out group-hover:scale-110`}):(0,Q.jsx)(`span`,{className:W(`text-base font-semibold`,n.text),children:t[0]?.toUpperCase()})})};S.register(`object-gallery`,e=>{let{schema:t}=e,n=(0,Z.useContext)(_),r=e.dataSource||n?.dataSource,i=v(t.bind),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),d=T({navigation:t.navigation,objectName:t.objectName,onRowClick:e.onRowClick??e.onCardClick}),f=t.gallery,m=f?.coverField??t.imageField??`image`,h=f?.coverFit??`cover`,g=f?.cardSize??`medium`,y=f?.titleField??t.titleField,x=f?.visibleFields,{fieldLabel:S,fieldOptionLabel:C}=en(),w=(0,Z.useCallback)(e=>{let n=l?.fields?.[e],r={name:e};if(n){n.type&&(r.type=n.type),n.label&&(r.label=n.label),n.options&&(r.options=n.options),n.currency&&(r.currency=n.currency),n.precision!==void 0&&(r.precision=n.precision),n.format&&(r.format=n.format);let e=n.reference_to||n.reference;e&&(r.reference_to=e),n.reference_field&&(r.reference_field=n.reference_field)}if(t.objectName){let n=String(r.label??e);r.label=S(t.objectName,e,n)}return t.objectName&&Array.isArray(r.options)&&(r.options=r.options.map(n=>{let r=String(n?.value??n),i=String(n?.label??r);return{...n,value:r,label:C(t.objectName,e,r,i)}})),r},[l,t.objectName,S,C]);(0,Z.useEffect)(()=>{let e=!0;return(async()=>{if(!(!r||typeof r.getObjectSchema!=`function`||!t.objectName))try{let n=await r.getObjectSchema(t.objectName);e&&u(n)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[t.objectName,r]),(0,Z.useEffect)(()=>{let n=!0;if(e.data&&Array.isArray(e.data)){o(e.data);return}return t.objectName&&!i&&!t.data&&!e.data&&(async()=>{if(!(!r||typeof r.find!=`function`||!t.objectName)){n&&c(!0);try{let e=p(l?.fields),i=await r.find(t.objectName,{$filter:t.filter,...e.length>0?{$expand:e}:{}}),a=[];if(Array.isArray(i))a=i;else if(i&&typeof i==`object`){let e=i;Array.isArray(e.records)?a=e.records:Array.isArray(e.data)&&(a=e.data)}n&&o(a)}catch(e){console.error(`[ObjectGallery] Fetch error:`,e)}finally{n&&c(!1)}}})(),()=>{n=!1}},[t.objectName,r,i,t.data,t.filter,e.data,l]);let E=e.data||i||t.data||a||[],D=(0,Z.useMemo)(()=>E.some(e=>typeof e[m]==`string`&&!!e[m]),[E,m]),O=t.grouping?.fields,k=!!(O&&O.length>0),[A,j]=(0,Z.useState)({}),M=(0,Z.useMemo)(()=>O?O.some(e=>e.collapsed):!1,[O]),N=(0,Z.useCallback)(e=>{j(t=>({...t,[e]:t[e]===void 0?!M:!t[e]}))},[M]),ee=(0,Z.useMemo)(()=>{if(!k||!O)return[];let e=new Map,t=[];for(let n of E){let r=O.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=O.map(e=>{let t=n[e.field];return t!=null&&t!==``?String(t):`(empty)`}).join(` / `);e.set(r,{label:i,items:[]}),t.push(r)}e.get(r).items.push(n)}let n=O[0]?.order??`asc`;return t.sort((e,t)=>{let r=e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`});return n===`desc`?-r:r}),t.map(t=>{let n=e.get(t),r=t in A?A[t]:M;return{key:t,label:n.label,items:n.items,collapsed:r}})},[E,O,k,A,M]);if(s&&!E.length)return(0,Q.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!E.length)return(0,Q.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let P=e=>!x||x.length===0?null:(0,Q.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:x.map(t=>{let n=e[t];if(n==null||n===``)return null;let r=w(t),i=Re(r)||r.type||`text`,a=nt(i),o=r?.label&&String(r.label).trim()?String(r.label):void 0,s=o!=null&&jn.has(i);return(0,Q.jsxs)(`div`,{className:W(`text-xs text-muted-foreground truncate [&_*]:!text-xs`,s&&`flex items-baseline gap-1.5`),onClick:e=>{e.target.closest(`a,button`)&&e.stopPropagation()},children:[s&&(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground/70 tabular-nums`,children:o}),(0,Q.jsx)(a,{value:n,field:r})]},t)})}),F=(n,r)=>{let i=n.id??n._id??r,a=(y!=null&&n[y]!=null&&n[y]!==``?String(n[y]):void 0)??b(l,n),o=n[m],s=Nn(String(i)+`|`+a),c=W(`group relative overflow-hidden border-border/60 bg-card`,`transition-all duration-200 ease-out`,`hover:shadow-lg hover:border-border hover:-translate-y-0.5`,(e.onCardClick||e.onRowClick||t.navigation)&&`cursor-pointer`);return D&&h===`contain`?(0,Q.jsxs)(Pt,{role:`listitem`,className:c,onClick:e=>d.handleClick(n,e),children:[(0,Q.jsx)(`div`,{"aria-hidden":!0,className:W(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,Q.jsx)(mt,{className:`p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Fn,{imageUrl:o,title:a,placeholder:s}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:a,children:a}),P(n)]})]})})]},i):(0,Q.jsxs)(Pt,{role:`listitem`,className:c,onClick:e=>d.handleClick(n,e),children:[!D&&(0,Q.jsx)(`div`,{"aria-hidden":!0,className:W(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,Q.jsx)(Pn,{imageUrl:o,title:a,coverFit:h,aspectClass:An[g],placeholder:s,hidden:!D}),(0,Q.jsxs)(mt,{className:W(`p-3`,D&&`border-t border-border/60`),children:[(0,Q.jsx)(`h3`,{className:`font-semibold tracking-tight truncate text-sm leading-tight text-foreground`,title:a,children:a}),P(n)]})]},i)},te=e=>(0,Q.jsx)(`div`,{className:W(`grid gap-4 p-4 auto-rows-min content-start`,kn[g],t.className),role:`list`,children:e.map((e,t)=>F(e,t))});return(0,Q.jsxs)(Q.Fragment,{children:[k?(0,Q.jsx)(`div`,{className:`space-y-2`,children:ee.map(e=>(0,Q.jsxs)(`div`,{className:`border rounded-md`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>N(e.key),children:[e.collapsed?(0,Q.jsx)(we,{className:`h-4 w-4 shrink-0`}):(0,Q.jsx)(ae,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`span`,{children:e.label}),(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&te(e.items)]},e.key))}):te(E),d.isOverlay&&(0,Q.jsx)(R,{...d,title:`Gallery Item`,children:e=>(0,Q.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Q.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},{namespace:`plugin-list`,label:`Gallery View`,category:`view`}),S.register(`list-view`,On,{namespace:`plugin-list`,label:`List View`,category:`Views`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}],defaultProps:{objectName:``,viewType:`grid`,fields:[],filters:[],sort:[],options:{}}}),S.register(`list`,On,{namespace:`view`,skipFallback:!0,category:`view`,label:`List`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}]});var In=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function Ln(e){return In.has(e)}function Rn(e,t){let n;return n=e<=3?1:2,t!==void 0&&t<640?Math.min(n,1):n}function zn(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&Ln(e.type)?{...e,span:t}:e)}function Bn(e,t,n){if(t!==void 0)return{fields:zn(e,t),columns:t};let r=Rn(e.length,n);return{fields:zn(e,r),columns:r}}function Vn(e,t){return function(){try{let n=x();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var $=Vn({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.cancel":`Cancel`,"detail.cancelEdit":`Discard changes`,"detail.openInNewTab":`Open in new tab`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.noValue":`No value`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter...`,"detail.highlightFields":`Key Fields`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.createdBy":`Created by`,"detail.updatedBy":`Updated by`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCountPlural":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.sendComment":`Send`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.showEmptyRelated_one":`+ {{count}} empty`,"detail.showEmptyRelated_other":`+ {{count}} empty`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.viewSource":`View source`,"detail.replyCount":`{{count}} reply`,"detail.replyCountPlural":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`,"detail.concurrentUpdateTitle":`This record was modified by someone else`,"detail.concurrentUpdateDescription":`Another user saved a newer version of {{field}} while you were editing. To prevent silently overwriting their change, please choose how to resolve the conflict.`,"detail.concurrentUpdateYourEdit":`Your edit`,"detail.concurrentUpdateCurrentValue":`Current value`,"detail.concurrentUpdateUpdatedBy":`Updated by {{name}}`,"detail.concurrentUpdateUpdatedAt":`Updated at {{when}}`,"detail.concurrentUpdateReload":`Reload latest`,"detail.concurrentUpdateOverwrite":`Overwrite anyway`,"detail.concurrentUpdateCancel":`Cancel`},`detail.back`);function Hn(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``}var Un=new Set([`formula`,`summary`,`rollup`,`auto_number`]);function Wn(e){if(e==null)return e;if(Array.isArray(e))return e.map(Wn);if(typeof e==`object`){let t=e;return t.id??t._id??t.value??``}return e}var Gn=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,dataSource:s,virtualScroll:c})=>{let[l,u]=Z.useState(e.defaultCollapsed??!1),[d,f]=Z.useState(null),[p,m]=Z.useState(void 0),[h,_]=Z.useState(!1),{t:v}=$(),{fieldLabel:y,translateOptions:b}=en(),x=Z.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{f(e),setTimeout(()=>f(null),2e3)})},[]),S=Z.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),C=Z.useMemo(()=>e.fields.filter(S).length,[e.fields,S]),w=se(),T=w?3:4,E=w?.2:.25,D=e.fields.length-C,k=!e.hideEmpty&&!a&&e.fields.length>=T&&C/e.fields.length>=E&&D>0,A=!h&&(e.hideEmpty||k)?e.fields.filter(e=>!S(e)):e.fields;if(A.length===0&&C===e.fields.length)return null;let{fields:j,columns:M}=Bn(A,e.columns),ee=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,Q.jsx)(g,{schema:e.render,data:{...t,value:n}});let c=Hn(e.span,M),l=r?.fields?.[e.name],u={...e};if(l){!e.type&&l.type&&(u.type=l.type),l.options&&!u.options&&(u.options=l.options),l.currency&&!u.currency&&(u.currency=l.currency),l.precision!==void 0&&u.precision===void 0&&(u.precision=l.precision),l.format&&!u.format&&(u.format=l.format);let t=l.reference_to||l.reference;t&&!u.reference_to&&(u.reference_to=t),l.reference_field&&!u.reference_field&&(u.reference_field=l.reference_field)}i&&Array.isArray(u.options)&&u.options.length>0&&(u.options=b(i,e.name,u.options));let f=(()=>{if(n==null||n===``)return(0,Q.jsx)(`span`,{className:`text-muted-foreground/60 text-sm select-none`,"aria-label":v(`detail.noValue`,{defaultValue:`No value`}),title:v(`detail.noValue`,{defaultValue:`No value`}),children:`—`});let t=Re(u)||e.type;if(t){let e=nt(t);if(e)return(0,Q.jsx)(e,{value:n,field:u})}return String(n)})(),p=n!=null&&n!==``,m=d===e.name,h=y(i||``,e.name,e.label||e.name);return w&&!(a&&!e.readonly)?(0,Q.jsxs)(`div`,{className:W(`flex items-baseline justify-between gap-4 py-2.5 min-h-[44px] group`,p&&`cursor-pointer active:bg-muted/40 transition-colors`),onClick:p?()=>x(e.name,n):void 0,onKeyDown:p?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),x(e.name,n))}:void 0,role:p?`button`:void 0,tabIndex:p?0:void 0,children:[(0,Q.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:h}),(0,Q.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:f})]},e.name):(0,Q.jsxs)(`div`,{className:W(`space-y-1.5 group`,c),children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:y(i||``,e.name,e.label||e.name)}),a&&!e.readonly?(0,Q.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(()=>{let t=u.type||e.type;if(t===`select`&&Array.isArray(u.options)&&u.options.length>0)return(0,Q.jsx)(he,{field:u,value:n==null?``:String(n),onChange:t=>o?.(e.name,t)});if(t===`boolean`)return(0,Q.jsx)(vt,{field:u,value:!!n,onChange:t=>o?.(e.name,t)});let r=t===`user`||t===`owner`,i=t===`lookup`||t===`master_detail`||t===`tree`||!!u.reference_to&&!Un.has(t);if(r||i)return(0,Q.jsx)(r?ye:I,{field:u,value:Wn(n),onChange:t=>o?.(e.name,t),dataSource:s});let a=t===`date`||t===`datetime`;return(0,Q.jsx)(`input`,{type:t===`number`?`number`:a?`date`:`text`,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:n==null?``:a?(()=>{let e=String(n);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleDateString(`en-CA`)})():String(typeof n==`object`?Et(n)??``:n),onChange:t=>{let n=t.target.value;if(a&&n){let t=new Date(n+`T00:00:00`).toISOString();o?.(e.name,t)}else o?.(e.name,n)}})})()}):(0,Q.jsxs)(`div`,{className:W(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,p&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:p?()=>x(e.name,n):void 0,onKeyDown:p?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),x(e.name,n))}:void 0,role:p?`button`:void 0,tabIndex:p?0:void 0,children:[(0,Q.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:f}),p&&(0,Q.jsx)(nn,{children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),x(e.name,n)},children:m?(0,Q.jsx)(V,{className:`h-3 w-3 text-green-600`}):(0,Q.jsx)(Ze,{className:`h-3 w-3`})})}),(0,Q.jsx)(J,{children:v(m?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},P=c?.enabled===!0,F=c?.batchSize??20;Z.useEffect(()=>{if(!P){m(void 0);return}if(j.length<=F){m(void 0);return}m(F);let e=setTimeout(()=>m(void 0),100);return()=>clearTimeout(e)},[P,j.length,F]);let te=p===void 0?j:j.slice(0,p),ne=C>0&&(e.hideEmpty||k),L=(0,Q.jsxs)(Q.Fragment,{children:[w?(0,Q.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:te.map(ee)}):(0,Q.jsx)(`div`,{className:W(`grid gap-3 sm:gap-4`,M===1?`grid-cols-1`:M===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:te.map(ee)}),ne&&(0,Q.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>_(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[h?(0,Q.jsx)(Me,{className:`h-3.5 w-3.5 mr-1.5`}):(0,Q.jsx)(Ne,{className:`h-3.5 w-3.5 mr-1.5`}),h?v(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):v(`detail.showEmptyFields`,{count:C,defaultValue:`Show ${C} empty field${C===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,Q.jsx)(`div`,{className:W(n),children:L}):e.collapsible?(0,Q.jsx)(O,{open:!l,onOpenChange:e=>u(!e),className:n,children:(0,Q.jsxs)(Pt,{children:[(0,Q.jsx)(Lt,{asChild:!0,children:(0,Q.jsxs)(At,{className:W(`py-3 px-4 sm:py-4 sm:px-6 cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,Q.jsxs)(It,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsx)(`span`,{children:e.title})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:l?(0,Q.jsx)(we,{className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(ae,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!l&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,Q.jsx)(et,{children:(0,Q.jsx)(mt,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:L})})]})}):(0,Q.jsxs)(Pt,{className:W(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,Q.jsxs)(At,{className:W(`py-3 px-4 sm:py-4 sm:px-6`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,Q.jsx)(It,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsx)(`span`,{children:e.title})]})}),e.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,Q.jsx)(mt,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:L})]})},Kn=({tabs:e,data:t,className:n})=>{let[r,i]=Z.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,Q.jsxs)(Qe,{value:r,onValueChange:i,className:n,children:[(0,Q.jsx)(Mt,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,Q.jsx)(Tt,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,Q.jsx)(`span`,{children:e.icon}),(0,Q.jsx)(`span`,{children:e.label}),e.badge&&(0,Q.jsx)(xt,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,Q.jsx)(ot,{value:e.key,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,Q.jsx)(Z.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,Q.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,Q.jsx)(g,{schema:e,data:t},n))}):(0,Q.jsx)(g,{schema:e.content,data:t})})},e.key))]})};function qn(e){return e&&te[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||bt}var Jn=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:s,dataSource:c,objectName:l,onNew:u,onViewAll:d,onRowEdit:f,onRowDelete:p,onRowClick:m,add:h,maxColumns:_=6,pageSize:v,sortable:y=!1,filterable:b=!1,collapsible:x=!1,defaultCollapsed:S=!1,referenceField:C,parentId:w,icon:T})=>{let E=r!==void 0,O=r??[],[k,A]=Z.useState(O),[j,M]=Z.useState(()=>!!n&&!E),[N,te]=Z.useState(0),[I,ne]=Z.useState(null),[L,re]=Z.useState(`asc`),[R,ie]=Z.useState(``),[oe,ce]=Z.useState(null),[le,z]=Z.useState(S),[B,V]=Z.useState(!1),[ue,de]=Z.useState(!1),[fe,H]=Z.useState(null),[U,pe]=Z.useState(0),[me,he]=Z.useState({}),{t:G}=$(),{fieldLabel:K}=en();Z.useEffect(()=>{E&&A(r??[])},[r,E]),Z.useEffect(()=>{n&&c?.getObjectSchema&&c.getObjectSchema(n).then(ce).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,c]),Z.useEffect(()=>{if(n&&!E){if(!(C&&w!=null&&w!==``)){n&&(w==null||w===``)&&!C&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),A([]),M(!1);return}M(!0);let e={[C]:w};if(c&&typeof c.find==`function`)c.find(n,{$filter:e}).then(e=>{A(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),M(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),M(!1)});else{let e=new URLSearchParams({[`filter[${C}]`]:String(w)}).toString();fetch(`${n}?${e}`).then(e=>e.json()).then(e=>{A(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>M(!1))}}},[n,E,c,C,w,U]),Z.useEffect(()=>{if(!c?.find||!oe?.fields||!k.length)return;let e=oe.fields,t=[];for(let[n,r]of Object.entries(e)){if(!r||r.type!==`lookup`&&r.type!==`master_detail`)continue;let e=r.reference_to||r.reference;if(!e)continue;let i=new Set;for(let e of k){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=me[n]||{},o=Array.from(i).filter(e=>!(e in a));o.length>0&&t.push({fieldName:n,target:e,ids:o})}if(t.length===0)return;let n=!1;return Promise.all(t.map(({fieldName:e,target:t,ids:n})=>c.find(t,{$filter:{id:{$in:n}},$top:n.length}).then(t=>{let n=Array.isArray(t)?t:t?.data||[],r={};for(let e of n){let t=e?.id||e?._id;t&&(r[String(t)]=e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||e?.email||String(t))}return{fieldName:e,map:r}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{n||he(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[c,oe,k]);let ge=Z.useMemo(()=>{if(!R)return k;let e=R.toLowerCase();return k.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[k,R]),_e=Z.useMemo(()=>I?[...ge].sort((e,t)=>{let n=e[I],r=t[I];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return L===`asc`?i:-i}):ge,[ge,I,L]),q=v&&v>0?v:0,ve=q?Math.max(1,Math.ceil(_e.length/q)):1,J=q?_e.slice(N*q,(N+1)*q):_e;Z.useEffect(()=>{te(0)},[R,I,L]);let ye=Z.useCallback(e=>{I===e?re(e=>e===`asc`?`desc`:`asc`):(ne(e),re(`asc`))},[I]),[xe,Se]=Z.useState(null),Ce=Z.useCallback(e=>{Se(e)},[]),Te=Z.useCallback(async()=>{if(xe)try{await p?.(xe),pe(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}Se(null)},[xe,p]),Ee=Z.useCallback(async e=>{if(!h||!c||!n||C==null||w==null)return;let t=h.picker.valueField||`id`;de(!0),H(null);try{for(let r of e||[]){let e=r?.[t]??r?.id;e!=null&&(h.linkField?await c.create?.(n,{[C]:w,[h.linkField]:e}):await c.update?.(h.picker.object,String(e),{[C]:w}))}pe(e=>e+1)}catch(e){let t=e?.body?.error??e?.error??e?.message??String(e);H(typeof t==`string`?t:`Failed to add`)}finally{de(!1),V(!1)}},[h,c,n,C,w]),De=o(),Oe=Z.useMemo(()=>{let e=l||n||``,t=t=>!De?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||t?.field||t?.name;return n?De.checkField(e,String(n),`read`):!0}),r=e=>C?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==C):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>k.length?e.filter(e=>{let t=e?.accessorKey||e?.field||e?.name;return t?k.some(e=>!i(e?.[t])):!0}):e,s=(e,t)=>{if(!t?.type)return;let n=nt(Re({type:t.type,format:t.format})||t.type);if(!n)return;let r=t.type===`lookup`||t.type===`master_detail`?me[e]:void 0,i=r&&Object.keys(r).length>0?Object.entries(r).map(([e,t])=>({value:e,label:t})):void 0,a={name:e,label:t.label||e,type:t.type,...(i||t.options)&&{options:i||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.format&&{format:t.format},...(t.reference_to||t.reference)&&{reference_to:t.reference_to||t.reference},...t.reference_field&&{reference_field:t.reference_field}};return e=>e==null?Z.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):Z.createElement(n,{value:e,field:a})},c=t=>{if(typeof t!=`string`){let e=t?.accessorKey||t?.field||t?.name;if(t&&!t.cell&&!t.render&&e){let n=oe?.fields?.[e],r=n?s(String(e),n):void 0;if(r)return{...t,cell:r}}return t}let n=oe?.fields?.[t],r={accessorKey:t,header:n?.label||K(e,t,n)||t,fieldDef:n,fieldType:n?.type},i=n?s(t,n):void 0;return i&&(r.cell=i),r};if(a&&a.length>0)return o(t(r(a.map(c))));if(!oe?.fields)return[];let u=e,d=new Set([`image`,`file`,`attachment`,`rich_text`,`html`,`json`]),f=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],p=Object.entries(oe.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===C||t?.hidden||t?.type&&d.has(t.type)||De?.isLoaded&&u&&!De.checkField(u,e,`read`))),m=new Set([`created_at`,`updated_at`,`created_by`,`updated_by`,`owner_id`,`organization_id`]);return p.sort(([e,t],[n,r])=>{let i=m.has(e);if(i!==m.has(n))return i?1:-1;let a=f.indexOf(e),o=f.indexOf(n),s=a>=0?a:100,c=o>=0?o:100;if(s!==c)return s-c;let l=t?.type===`select`||e.includes(`status`);return l===(r?.type===`select`||n.includes(`status`))?0:l?-1:1}),o(p.map(([e,t])=>{let n={accessorKey:e,header:K(u,e,t.label||e)};if(t.type){let r=s(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,_))},[a,oe,l,n,K,C,k,_,me,De]),Ae=!!f||!!p,je=se(),Me=Z.useMemo(()=>{if(i)return i;if(je&&(t===`grid`||t===`table`)){let e=Oe[0]?.accessorKey||Oe[0]?.field||Oe[0]?.name,t=Oe.slice(1,4).map(e=>e.accessorKey||e.field||e.name).filter(Boolean);return{type:`object-gallery`,data:J,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,cardSize:`medium`},onRowClick:m}}switch(t){case`grid`:case`table`:return{type:`data-table`,data:J,columns:Oe,pagination:!1,pageSize:q||10,searchable:!1,exportable:!1,rowActions:Ae,onRowEdit:f,onRowDelete:p?Ce:void 0,onRowClick:m};case`list`:return{type:`data-list`,data:J};default:return{type:`div`,children:`No view configured`}}},[t,J,Oe,i,q,Ae,f,p,Ce,m,je,n]),X=x?`cursor-pointer select-none`:void 0,Ne=x?()=>z(e=>!e):void 0,Pe=qn(T),Ie=!j&&k.length===0,Le=b;return(0,Q.jsxs)(Pt,{className:W(`shadow-none border-border/60 bg-transparent`,Ie&&`bg-muted/10`,s),children:[(0,Q.jsx)(At,{className:W(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,X),onClick:Ne,children:(0,Q.jsxs)(It,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[x&&(le?(0,Q.jsx)(we,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Q.jsx)(ae,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,Q.jsx)(Pe,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:W(`truncate`,Ie&&`text-muted-foreground font-medium`),children:e}),(0,Q.jsx)(xt,{variant:`secondary`,className:W(`text-xs font-normal h-5 px-1.5`,k.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${k.length} records`,children:k.length}),Ie&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:G(`detail.noRelatedRecords`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[h&&(0,Q.jsxs)(Y,{variant:Ie?`ghost`:`outline`,size:`sm`,disabled:ue,onClick:e=>{e.stopPropagation(),H(null),V(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,Q.jsx)(D,{className:`h-3.5 w-3.5`}),h.label||G(`detail.add`,{defaultValue:`Add`})]}),u&&(0,Q.jsxs)(Y,{variant:Ie?`ghost`:`outline`,size:`sm`,onClick:e=>{e.stopPropagation(),u()},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,Q.jsx)(D,{className:`h-3.5 w-3.5`}),G(`detail.new`)]})]})]})}),!le&&!Ie&&(0,Q.jsxs)(mt,{className:W(`pt-0 pb-4 px-4`),children:[Le&&(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(Je,{placeholder:G(`detail.filterPlaceholder`),value:R,onChange:e=>ie(e.target.value),className:`h-8 text-sm`})}),y&&Oe&&Oe.length>0&&k.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:Oe.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,r=I===t;return(0,Q.jsxs)(Y,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>ye(t),children:[(0,Q.jsx)(ee,{className:`h-3 w-3`}),n,r&&(L===`asc`?` ↑`:` ↓`)]},t)})}),j?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:G(`detail.loading`)}):(0,Q.jsx)(g,{schema:Me}),q>0&&_e.length>q&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:N===0,onClick:()=>te(e=>Math.max(0,e-1)),children:[(0,Q.jsx)(ke,{className:`h-3 w-3`}),G(`detail.previousPage`)]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:G(`detail.pageOf`,{current:N+1,total:ve})}),(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:N>=ve-1,onClick:()=>te(e=>Math.min(ve-1,e+1)),children:[G(`detail.nextPage`),(0,Q.jsx)(we,{className:`h-3 w-3`})]})]}),d&&!Ie&&q>0&&_e.length>q&&(0,Q.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),d()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[G(`detail.viewAll`),(0,Q.jsx)(Fe,{className:`h-3 w-3`})]})})]}),(0,Q.jsx)(st,{open:xe!==null,onOpenChange:e=>{e||Se(null)},children:(0,Q.jsxs)(Zt,{children:[(0,Q.jsxs)(be,{children:[(0,Q.jsx)(P,{children:G(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,Q.jsx)(Ge,{children:G(`detail.deleteRowConfirmation`)})]}),(0,Q.jsxs)(Jt,{children:[(0,Q.jsx)(Gt,{children:G(`detail.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsx)(Ve,{onClick:Te,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:G(`detail.delete`,{defaultValue:`Delete`})})]})]})}),fe&&(0,Q.jsx)(`div`,{className:`mx-4 mb-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,role:`alert`,children:fe}),h&&c&&(0,Q.jsx)(F,{open:B,onOpenChange:e=>V(e),multiple:!0,dataSource:c,objectName:h.picker.object,title:h.label||G(`detail.add`,{defaultValue:`Add`}),onSelect:()=>{},onSelectRecords:e=>{Ee(e)}})]})},Yn=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,dataSource:s})=>{let c=e.collapsible??!0,[l,u]=Z.useState(e.defaultCollapsed??!1),d=(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,Q.jsx)(Gn,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o,dataSource:s},n))});return c?(0,Q.jsxs)(O,{open:!l,onOpenChange:e=>u(!e),className:n,children:[(0,Q.jsx)(Lt,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[l?(0,Q.jsx)(we,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(ae,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!l&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,Q.jsx)(et,{children:(0,Q.jsx)(`div`,{className:`mt-3`,children:d})})]}):(0,Q.jsxs)(`div`,{className:W(`space-y-3`,n),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),d]})},Xn=({fields:e,data:t,className:n,objectName:r,objectSchema:i})=>{let{fieldLabel:a}=en();if(!e.length||!t)return null;let o=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return o.length===0?null:(0,Q.jsx)(`section`,{className:W(`@container border-b border-border/60 pb-4`,n),"aria-label":`Record highlights`,children:(0,Q.jsx)(`div`,{className:W(`flex flex-wrap gap-x-8 gap-y-3`),children:o.map(e=>{let n=t[e.name],o=i?.fields?.[e.name],s=e.type||o?.type,c={name:e.name,label:e.label,type:s||`text`,...o?.options&&{options:o.options},...o?.currency&&{currency:o.currency},...o?.precision!==void 0&&{precision:o.precision},...o?.format&&{format:o.format}},l=nt(Re(c)||s||`text`),u=s===`number`||s===`integer`||s===`currency`||s===`percent`||s===`decimal`,d=s===`email`||s===`url`||s===`textarea`,f=s===`boolean`;return(0,Q.jsxs)(`div`,{className:W(`flex flex-col gap-1 min-w-[8rem] basis-[10rem]`,d?`max-w-[24rem] basis-[16rem]`:`max-w-[16rem]`),children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:a(r||``,e.name,e.label)}),f?n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-600 ring-1 ring-inset ring-emerald-500/30 dark:text-emerald-400`,children:[(0,Q.jsx)(V,{className:`h-3 w-3`,"aria-hidden":!0}),`Yes`]}):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-amber-500/10 px-2 py-0.5 text-xs font-medium text-amber-700 ring-1 ring-inset ring-amber-500/30 dark:text-amber-400`,children:[(0,Q.jsx)(me,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):(0,Q.jsx)(`span`,{className:W(`block min-w-0 truncate`,u?`text-xl md:text-2xl font-semibold leading-tight tabular-nums tracking-tight`:`text-sm font-semibold`),children:(0,Q.jsx)(l,{value:n,field:c})})]},e.name)})})})};function Zn(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var Qn=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=$(),[o,s]=Z.useState(``),[c,l]=Z.useState(!1),[u,d]=Z.useState(``),f=Z.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=Z.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=Z.useMemo(()=>[...u.trim()?e.filter(e=>{let t=u.trim().toLowerCase();return e.text.toLowerCase().includes(t)||e.author.toLowerCase().includes(t)}):e].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:0),[e,u]);return(0,Q.jsxs)(Pt,{className:W(``,i),children:[(0,Q.jsx)(At,{children:(0,Q.jsxs)(It,{className:`flex items-center gap-2 text-base`,children:[(0,Q.jsx)(U,{className:`h-4 w-4`}),a(`detail.comments`),(0,Q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,Q.jsxs)(mt,{className:`space-y-4`,children:[r&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(`div`,{className:`relative flex-1`,children:[(0,Q.jsx)(pe,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Q.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.searchComments`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`detail.searchComments`)}),u&&(0,Q.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>d(``),"aria-label":a(`detail.clearSearch`),type:`button`,children:(0,Q.jsx)(me,{className:`h-3.5 w-3.5`})})]})}),t&&(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:a(`detail.addCommentPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:p,disabled:c}),(0,Q.jsx)(Y,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,Q.jsx)(gt,{className:`h-4 w-4`})})]}),m.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,Q.jsxs)(`div`,{className:W(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,Q.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,Q.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,Q.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Zn(e.createdAt)}),e.pinned&&(0,Q.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,Q.jsx)(Dt,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,Q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,Q.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>n(e.id),"aria-label":e.pinned?a(`detail.unpin`):a(`detail.pin`),children:[(0,Q.jsx)(Dt,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},$n={field_change:ut,create:j,delete:Ie,comment:U,status_change:xe},er={field_change:`bg-blue-100 text-blue-600`,create:`bg-green-100 text-green-600`,delete:`bg-red-100 text-red-600`,comment:`bg-purple-100 text-purple-600`,status_change:`bg-amber-100 text-amber-600`};function tr(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function nr(e){return e.description?e.description:e.type===`field_change`&&e.field?`Changed ${e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `)} from "${e.oldValue==null?`(empty)`:String(e.oldValue)}" to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:e.type===`create`?`Created this record`:e.type===`delete`?`Deleted this record`:e.type===`status_change`&&e.field?`Changed status to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:`Updated record`}var rr={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},ir=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let[i,a]=Z.useState(n),o=Z.useMemo(()=>i===`all`?e:e.filter(e=>e.type===i),[e,i]);return(0,Q.jsxs)(Pt,{className:W(``,r),children:[(0,Q.jsx)(At,{children:(0,Q.jsxs)(It,{className:`flex items-center gap-2 text-base`,children:[(0,Q.jsx)(ht,{className:`h-4 w-4`}),`Activity`,(0,Q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,Q.jsxs)(mt,{children:[t&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(rr).map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:W(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,i===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>a(e),"aria-pressed":i===e,children:[e!==`all`&&Z.createElement($n[e]||ut,{className:`h-3 w-3`}),rr[e]]},e))}),o.length===0?(0,Q.jsx)(Qt,{title:`No activity recorded`,className:`py-6`}):(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:o.map(e=>{let t=$n[e.type]||ut;return(0,Q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,Q.jsx)(`div`,{className:W(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,er[e.type]||`bg-gray-100 text-gray-600`),children:(0,Q.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:nr(e)})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:tr(e.timestamp)})]})]},e.id)})})]})]})]})},ar={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`};function or(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var sr=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function cr(e,t){if(!e)return``;let n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return String(e);let r=(n.getTime()-Date.now())/1e3;for(let[n,i]of sr){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return or(e)}r/=n}return or(e)}function lr(e){if(!e)return`?`;let t=e.trim().split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?`?`:t.map(e=>e.charAt(0).toUpperCase()).join(``)}function ur(e){if(e==null||e===``)return`—`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function dr({entries:e,loading:t,emptyText:n,className:r,locale:i}){return t?(0,Q.jsx)(`div`,{className:W(`space-y-3`,r),children:Array.from({length:4}).map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Ee,{className:`h-8 w-8 rounded-full`}),(0,Q.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Q.jsx)(Ee,{className:`h-4 w-1/3`}),(0,Q.jsx)(Ee,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,Q.jsx)(`div`,{className:W(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,r),children:n??`No history yet`}):(0,Q.jsx)(nn,{delayDuration:150,children:(0,Q.jsx)(`ol`,{className:W(`space-y-4`,r),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),r=ar[n]??`outline`,a=typeof e.user_name==`string`&&e.user_name.trim()||`Unknown user`,o=or(e.created_at),s=cr(e.created_at,i),c=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,Q.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(Ht,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[c?(0,Q.jsx)(at,{src:c,alt:a}):null,(0,Q.jsx)(Xe,{className:`text-[10px] font-medium`,children:lr(e.user_name)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:a}),e.action&&(0,Q.jsx)(xt,{variant:r,className:`text-[10px] uppercase tracking-wide`,children:e.action}),o&&(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":o,children:s||o})}),(0,Q.jsx)(J,{children:o})]})]}),e.summary&&(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,Q.jsxs)(`details`,{className:`mt-1 group`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer list-none text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 select-none`,children:[(0,Q.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,Q.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,Q.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,Q.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,Q.jsx)(`span`,{className:`text-foreground`,children:ur(e.to)})]},e.field))})]}):(0,Q.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,Q.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,Q.jsx)(`span`,{className:`line-through opacity-70`,children:ur(e.from)}),` → `,(0,Q.jsx)(`span`,{className:`text-foreground`,children:ur(e.to)})]},e.field))}))]})]},e.id??t)})})})}var fr={createdAt:`created_at`,createdBy:`created_by`,updatedAt:`updated_at`,updatedBy:`updated_by`};function pr(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function mr(e,t){let n=Date.now()-e.getTime(),r=Math.max(0,Math.floor(n/1e3));if(r<60)return t(`detail.justNow`);let i=Math.floor(r/60);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?t(`detail.hoursAgo`,{count:a}):t(`detail.daysAgo`,{count:Math.floor(a/24)})}function hr(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var gr=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference_to||r?.reference,a={name:n,type:r?.type||(i?`lookup`:`text`),...i&&{reference_to:i},...r?.reference_field&&{reference_field:r.reference_field}},o=Re(a)||a.type;if(o){let t=nt(o);if(t)return(0,Q.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:(0,Q.jsx)(t,{value:e,field:a})})}return(0,Q.jsx)(`span`,{children:String(e)})},_r=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,Q.jsx)(nn,{delayDuration:200,children:(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:mr(n,a)})}),(0,Q.jsx)(J,{side:`top`,children:hr(n)})]})}):null;return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,Q.jsx)(gr,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},vr=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=$();if(!e)return null;let a=pr(e[fr.createdAt]),o=pr(e[fr.updatedAt]),s=e[fr.createdBy],c=e[fr.updatedBy],l=!!(a||s),u=a&&o&&Math.abs(o.getTime()-a.getTime())<2e3,d=!!(o||c)&&!(u&&(s!=null&&c!=null&&String(s)===String(c)||!c));return!l&&!d?null:(0,Q.jsxs)(`div`,{className:W(`mt-6 pt-3 border-t border-border/40`,`flex flex-wrap items-center gap-x-4 gap-y-1`,`text-xs text-muted-foreground`,r),"data-testid":`record-meta-footer`,children:[l&&(0,Q.jsx)(_r,{label:i(`detail.createdBy`),user:s,date:a,objectSchema:t,userField:fr.createdBy,t:i}),d&&(0,Q.jsx)(_r,{label:i(`detail.updatedBy`),user:c,date:o,objectSchema:t,userField:fr.updatedBy,t:i})]})},yr=5;function br(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=c(n?.titleFormat,e);if(r)return r}if(e&&typeof e==`object`){let t=e.id??e._id,r=b(n,e,{deriveFromRecordKeys:!1});if(!(r===`Untitled`||t!=null&&r===`Record #${t}`))return r}if(t.title)return t.title;if(e&&typeof e==`object`){let t=e.id??e._id;if(t!=null&&String(t).trim()!==``)return`Record #${t}`}return r}var xr=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:s=!1,onFieldSave:c,discussionSlot:l,rightRail:u,objectLabel:d,onDataLoaded:f,isFavorite:m,onToggleFavorite:h})=>{let[_,v]=Z.useState(e.data),[y,b]=Z.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[x,S]=Z.useState(!1),C=m??x,[w,T]=Z.useState(!1),[E,D]=Z.useState({}),[O,k]=Z.useState(!1),[A,j]=Z.useState(null),[M,ee]=Z.useState(null),[P,F]=Z.useState(!1),[te,I]=Z.useState(0),[L,re]=Z.useState(!1),{t:R}=$(),{currency:ie}=ce(),{fieldOptionLabel:ae}=en(),le=se(),z=o(),B=Z.useMemo(()=>{if(!z?.isLoaded||!e.objectName)return e;let t=t=>z.checkField(e.objectName,t,`read`),n=e=>e&&e.filter(e=>{let n=typeof e==`string`?e:e?.name;return!n||t(n)});return{...e,fields:n(e.fields),sections:e.sections?.map(e=>({...e,fields:n(e.fields)})),summaryFields:n(e.summaryFields)}},[e,z]);Z.useEffect(()=>{_&&f&&f(_)},[_,f]);let ue=Z.useMemo(()=>{if(B.summaryFields&&B.summaryFields.length>0)return[];let e=[...B.sections?.flatMap(e=>e.fields)||[],...B.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(M?.fields)for(let[e,n]of Object.entries(M.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>_?.[e]!==void 0&&_?.[e]!==null&&_?.[e]!==``,r=[],i=[`status`,`stage`,`state`,`phase`].find(e=>t[e]&&n(e))||Object.keys(t).find(e=>t[e]?.type===`select`&&n(e));i&&r.push(i);let a=Object.keys(t).find(e=>(t[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&n(e));a&&!r.includes(a)&&r.push(a);let o=Object.keys(t).find(e=>(t[e]?.type===`date`||t[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&n(e));return o&&!r.includes(o)&&r.push(o),r},[B.summaryFields,B.sections,B.fields,M,_]),de=B.summaryFields&&B.summaryFields.length>0?B.summaryFields:ue,fe=Z.useCallback(()=>{B.resourceId&&navigator.clipboard.writeText(String(B.resourceId)).then(()=>{F(!0),setTimeout(()=>F(!1),1500)})},[B.resourceId]);Z.useEffect(()=>{let e=!0;if(B.data)return v(B.data),b(!1),t?.getObjectSchema&&B.objectName&&t.getObjectSchema(B.objectName).then(t=>{e&&ee(t)}).catch(()=>{}),()=>{e=!1};if(t&&B.objectName&&B.resourceId){b(!0),ee(null),v(null);let n=B.objectName,r=B.resourceId,i=`${n}-`,a=[...B.sections?.flatMap(e=>e.fields)||[],...B.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;ee(o);let s=p(o?.fields,a),c=s.length>0?{$expand:s}:void 0,l=c?t.findOne(n,r,c):t.findOne(n,r),u=()=>{let a=String(r),o=a.startsWith(i)?a.slice(i.length):`${i}${a}`;return(c?t.findOne(n,o,c):t.findOne(n,o)).then(t=>{e&&(v(t),b(!1))}).catch(()=>{e&&(v(null),b(!1))})};return l.catch(()=>null).then(t=>{if(e){if(t){v(t),b(!1);return}return u()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),b(!1))})}else B.api&&B.resourceId&&(b(!0),fetch(`${B.api}/${B.resourceId}`).then(e=>e.json()).then(t=>{e&&v(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&b(!1)}));return()=>{e=!1}},[B.api,B.resourceId,B.objectName,t,B.sections,B.fields,te]);let U=Z.useCallback(()=>{if(a)a();else if(B.onNavigate){let e=B.backUrl||(B.objectName?`/${B.objectName}`:`/`);B.onNavigate(e,{replace:!0})}else B.backUrl?window.location.href=B.backUrl:window.history.back()},[a,B]),pe=Z.useCallback(()=>{r?r():B.onNavigate&&B.editUrl?B.onNavigate(B.editUrl):B.onNavigate&&B.objectName&&B.resourceId?B.onNavigate(`/${B.objectName}/${B.resourceId}/edit`):B.editUrl&&(window.location.href=B.editUrl)},[r,B]),he=Z.useCallback(async()=>{if(!t?.cancelPendingApproval||!B.objectName||!B.resourceId){j(R(`detail.cancelApprovalUnavailable`));return}re(!0),j(null);try{if(await t.cancelPendingApproval(String(B.objectName),String(B.resourceId)),t.findOne)try{let e=await t.findOne(String(B.objectName),String(B.resourceId));e&&v(e)}catch{}I(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(B.objectName),recordId:String(B.resourceId),reason:`approval-recalled`}}))}catch{}}catch(e){let t=(e?.message||e?.error||String(e??`Cancel failed`)).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``);j(`${R(`detail.cancelApprovalFailed`)}: ${t}`)}finally{re(!1)}},[t,B.objectName,B.resourceId,R]),G=Z.useCallback(()=>{let e=B.deleteConfirmation||R(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),B.onNavigate&&B.objectName&&B.onNavigate(`/${B.objectName}`,{replace:!0}))},[i,B]),ge=Z.useCallback(()=>{navigator.share&&B.objectName&&B.resourceId?navigator.share({title:B.title||R(`detail.details`),text:`${B.objectName} #${B.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[B]),_e=Z.useCallback(()=>{let e=!C;h&&h(e),m===void 0&&S(e)},[C,m,h]),q=Z.useCallback(async()=>{if(w){let e=Object.entries(E);if(e.length>0){let t=_,n={..._,...E};v(n),j(null),k(!0);try{if(c)for(let[t,r]of e)await c(t,r,n);D({}),T(!1)}catch(e){v(t),j((e?.message||e?.error||String(e??`Save failed`)).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``))}finally{k(!1)}return}D({})}T(!w),j(null)},[w,E,_,c]),ve=Z.useCallback(()=>{D({}),T(!1),j(null)},[]),ye=Z.useCallback((e,t)=>{D(n=>({...n,[e]:t}))},[]);Z.useEffect(()=>{if(!B.recordNavigation)return;let e=B.recordNavigation,t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable||(t.key===`ArrowLeft`&&e.currentIndex>0?(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex-1])):t.key===`ArrowRight`&&e.currentIndex<e.recordIds.length-1&&(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex+1])))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[B.recordNavigation]),Z.useEffect(()=>{if(!s||B.showHeader!==!1)return;let e=`objectui:record:inline-edit-toggle`,t=e=>{let t=e.detail;t?.recordId&&B.recordId&&t.recordId!==B.recordId||t?.objectName&&B.objectName&&t.objectName!==B.objectName||q()};return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[s,B.showHeader,B.recordId,B.objectName,q]);let be=Z.useMemo(()=>B.related??[],[B.related]),xe=Z.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:R(`detail.share`),icon:`share-2`,type:`script`,onClick:ge}),B.showEdit&&e.push({name:`sys_edit_mobile`,label:R(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:pe}),s&&e.push({name:`sys_toggle_inline_edit_mobile`,label:R(w?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:q}),B.showDelete&&e.push({name:`sys_delete`,label:R(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:G}),e},[R,B.showEdit,B.showDelete,s,w,ge,pe,q,G]),Se=Z.useMemo(()=>{let e=B.actions??[];if(xe.length===0)return e;let t=!1,n=e.map(e=>{let n=e;if(n&&typeof n==`object`&&n.type===`action:bar`&&(!n.location||n.location===`record_header`)){t=!0;let e=Array.isArray(n.systemActions)?n.systemActions:[];return{...n,systemActions:[...e,...xe]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:xe}),n},[B.actions,xe]);return y||B.loading?(0,Q.jsxs)(`div`,{className:W(`space-y-4`,n),children:[(0,Q.jsx)(Ee,{className:`h-10 w-full`}),(0,Q.jsx)(Ee,{className:`h-64 w-full`}),(0,Q.jsx)(Ee,{className:`h-48 w-full`})]}):!_&&!B.data?(0,Q.jsxs)(`div`,{className:W(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,Q.jsx)(`p`,{className:`text-lg font-semibold`,children:R(`detail.recordNotFound`)}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:R(`detail.recordNotFoundDescription`)}),(B.showBack??!0)&&(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:U,className:`mt-4 gap-2`,children:[(0,Q.jsx)(ne,{className:`h-4 w-4`}),R(`detail.goBack`)]})]}):(0,Q.jsx)(nn,{children:(0,Q.jsxs)(`div`,{className:W(`space-y-6`,n),children:[B.showHeader!==!1&&(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(B.showBack??!0)&&(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,onClick:U,className:`shrink-0 mt-1`,children:(0,Q.jsx)(ne,{className:`h-4 w-4`})})}),(0,Q.jsx)(J,{children:R(`detail.back`)})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:br(_,B,M,R(`detail.details`))}),de.map(e=>{let t=_?.[e];if(t==null||t===``)return null;let n=(B.sections||[]).flatMap(e=>e.fields).concat(B.fields||[]).find(t=>t.name===e),r=M?.fields?.[e],i=n?.type||r?.type,a=String(t),o=null;try{if(i===`currency`){let e=Number(t);if(!Number.isNaN(e)){let t=K({...r,...n},ie);a=t?new Intl.NumberFormat(void 0,{style:`currency`,currency:t,maximumFractionDigits:0}).format(e):new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)}}else if(i===`date`||i===`datetime`){let e=new Date(t);Number.isNaN(e.getTime())||(a=i===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(i===`percent`){let e=Number(t);if(!Number.isNaN(e)){a=`${e}%`;let t=e<=1?e*100:e;o=Math.max(0,Math.min(100,t))}}else if(i===`select`||i===`status`||i===`multiselect`){let i=n?.options||r?.options,o=String(t);if(Array.isArray(i)){let e=i.find(e=>String(e?.value??e)===String(t));e?.label&&(o=e.label)}else if(i&&typeof i==`object`){let e=i[String(t)];e?.label&&(o=e.label)}a=B.objectName?ae(B.objectName,e,String(t),o):o}}catch{}return o===null?(0,Q.jsx)(xt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${e}: ${a}`,children:a},e):(0,Q.jsxs)(xt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15 gap-1.5 pl-2 pr-2`,"aria-label":`${e}: ${a}`,children:[(0,Q.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,Q.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${o}%`}})}),a]},e)}),(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:_e,"aria-label":R(C?`detail.removeFromFavorites`:`detail.addToFavorites`),children:C?(0,Q.jsx)(it,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,Q.jsx)(it,{className:`h-4 w-4 text-muted-foreground`})})}),(0,Q.jsx)(J,{children:R(C?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),B.objectName&&(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:d||B.objectName}),B.resourceId&&(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:fe,"aria-label":R(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:P?(0,Q.jsx)(V,{className:`h-3 w-3 text-green-600`}):(0,Q.jsx)(Ze,{className:`h-3 w-3`})})}),(0,Q.jsx)(J,{children:P?R(`detail.copied`,{defaultValue:`Copied`}):R(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[B.recordNavigation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:B.recordNavigation.currentIndex<=0,onClick:()=>{let e=B.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,Q.jsx)(ke,{className:`h-4 w-4`})})}),(0,Q.jsx)(J,{children:R(`detail.previousRecord`)})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:R(`detail.recordOf`,{current:B.recordNavigation.currentIndex+1,total:B.recordNavigation.recordIds.length})}),(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:B.recordNavigation.currentIndex>=B.recordNavigation.recordIds.length-1,onClick:()=>{let e=B.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,Q.jsx)(we,{className:`h-4 w-4`})})}),(0,Q.jsx)(J,{children:R(`detail.nextRecord`)})]})]}),s&&(0,Q.jsxs)(Q.Fragment,{children:[w&&(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:ve,className:`gap-2 hidden sm:inline-flex`,children:[(0,Q.jsx)(me,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:R(`detail.cancel`)})]})}),(0,Q.jsx)(J,{children:R(`detail.cancelEdit`)})]}),(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsx)(Y,{variant:w?`default`:`outline`,size:`sm`,onClick:q,className:`gap-2 hidden sm:inline-flex`,children:w?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:R(`detail.save`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ut,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:R(`detail.editInline`)})]})})}),(0,Q.jsx)(J,{children:R(w?`detail.saveChanges`:`detail.editFieldsInline`)})]})]}),B.showEdit&&(0,Q.jsxs)(H,{children:[(0,Q.jsx)(N,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`default`,onClick:pe,className:`gap-2 hidden sm:inline-flex`,children:[(0,Q.jsx)(ut,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:R(`detail.edit`)})]})}),(0,Q.jsx)(J,{children:R(`detail.editRecord`)})]}),Se.map((e,t)=>(0,Q.jsx)(g,{schema:e,data:_},`header-action-${t}`))]})]}),B.header&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(g,{schema:B.header,data:_})}),B.highlightFields&&B.highlightFields.length>0&&(0,Q.jsx)(Xn,{fields:B.highlightFields,data:_,objectName:B.objectName,objectSchema:M}),s&&B.showHeader===!1&&(()=>{let e=_?.approval_status,n=e===`pending`||e===`in_approval`;return!w&&!O&&!A&&!n?null:(0,Q.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[n&&!w&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{role:`status`,className:`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`,title:R(`detail.lockedTooltip`),children:[(0,Q.jsx)(oe,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:R(`detail.lockedByApproval`)})]}),t?.cancelPendingApproval&&(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:he,disabled:L,className:`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`,title:R(`detail.cancelApprovalTooltip`),children:[(0,Q.jsx)(me,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:R(L?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),w&&(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:ve,className:`gap-2`,disabled:O,children:[(0,Q.jsx)(me,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:R(`detail.cancel`)})]}),(0,Q.jsxs)(Y,{variant:w?`default`:`outline`,size:`sm`,onClick:q,className:`gap-2`,disabled:O||n&&!w,title:n&&!w?R(`detail.lockedTooltip`):void 0,children:[w?(0,Q.jsx)(V,{className:`h-4 w-4`}):(0,Q.jsx)(ut,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:R(O?`detail.saving`:w?`detail.save`:`detail.editFieldsInline`)})]})]}),A&&(0,Q.jsx)(`div`,{role:`alert`,className:`text-xs text-destructive bg-destructive/10 border border-destructive/20 rounded-md px-2 py-1 max-w-md text-right`,children:A})]})})(),B.autoTabs&&!B.tabs?.length?(()=>{let e=be.length>0,n=!!B.activities&&B.activities.length>0,r=!!l,i=!!B.history,a=(0,Q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[B.sectionGroups&&B.sectionGroups.length>0&&B.sectionGroups.map((e,n)=>(0,Q.jsx)(Yn,{group:e,data:{..._,...E},objectSchema:M,objectName:B.objectName,isEditing:w,onFieldChange:ye,dataSource:t},n)),B.sections&&B.sections.length>0&&B.sections.map((e,n)=>(0,Q.jsx)(Gn,{section:e,data:{..._,...E},objectSchema:M,objectName:B.objectName,isEditing:w,onFieldChange:ye,dataSource:t},n)),B.fields&&B.fields.length>0&&!B.sections?.length&&(0,Q.jsx)(Gn,{section:{fields:B.fields,columns:B.columns},data:{..._,...E},objectSchema:M,objectName:B.objectName,isEditing:w,onFieldChange:ye,dataSource:t}),B.comments&&(0,Q.jsx)(Qn,{comments:B.comments,onAddComment:B.onAddComment})]});return!e&&!n&&!r&&!i?(0,Q.jsx)(`div`,{className:`mt-2`,children:a}):(0,Q.jsxs)(Qe,{defaultValue:`details`,className:`w-full`,children:[(0,Q.jsxs)(Mt,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,Q.jsx)(Tt,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:R(`detail.details`)}),e&&(0,Q.jsx)(Tt,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[R(`detail.related`),(0,Q.jsx)(xt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:be.length})]})}),n&&(0,Q.jsx)(Tt,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[R(`detail.activity`),(0,Q.jsx)(xt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:B.activities.length})]})}),r&&(0,Q.jsx)(Tt,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:R(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,Q.jsx)(Tt,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[R(`detail.history`,{defaultValue:`History`}),!B.history.loading&&B.history.entries.length>0&&(0,Q.jsx)(xt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:B.history.entries.length})]})})]}),(0,Q.jsx)(ot,{value:`details`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:a}),e&&(0,Q.jsx)(ot,{value:`related`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,Q.jsx)(`div`,{className:`space-y-3`,children:be.map((e,n)=>(0,Q.jsx)(Jn,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:le&&n>0,pageSize:yr},n))})}),n&&(0,Q.jsx)(ot,{value:`activity`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,Q.jsx)(ir,{activities:B.activities})}),r&&(0,Q.jsx)(ot,{value:`discussion`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:l}),i&&(0,Q.jsx)(ot,{value:`history`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:(0,Q.jsx)(dr,{entries:B.history.entries,loading:B.history.loading,emptyText:B.history.emptyText??R(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,Q.jsxs)(Q.Fragment,{children:[B.sectionGroups&&B.sectionGroups.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:B.sectionGroups.map((e,n)=>(0,Q.jsx)(Yn,{group:e,data:{..._,...E},objectSchema:M,objectName:B.objectName,isEditing:w,onFieldChange:ye,dataSource:t},n))}),B.sections&&B.sections.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:B.sections.map((e,n)=>(0,Q.jsx)(Gn,{section:e,data:{..._,...E},objectSchema:M,objectName:B.objectName,isEditing:w,onFieldChange:ye,dataSource:t},n))}),B.fields&&B.fields.length>0&&!B.sections?.length&&(0,Q.jsx)(Gn,{section:{fields:B.fields,columns:B.columns},data:{..._,...E},objectSchema:M,objectName:B.objectName,isEditing:w,onFieldChange:ye,dataSource:t}),B.tabs&&B.tabs.length>0&&(0,Q.jsx)(Kn,{tabs:B.tabs,data:_}),be.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:R(`detail.related`)}),be.map((e,n)=>(0,Q.jsx)(Jn,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,defaultCollapsed:le&&n>0,pageSize:yr},n))]}),B.comments&&(0,Q.jsx)(Qn,{comments:B.comments,onAddComment:B.onAddComment}),B.activities&&B.activities.length>0&&(0,Q.jsx)(ir,{activities:B.activities})]}),(0,Q.jsx)(vr,{data:{..._,...E},objectSchema:M,objectName:B.objectName}),B.footer&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(g,{schema:B.footer,data:_})})]})})},Sr=e=>{if(e==null)return`—`;if(typeof e==`string`)return e.length>0?e:`""`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}},Cr=e=>{if(typeof e!=`string`||e.length===0)return null;let t=/\d{4}-\d{2}-\d{2}[ T]/.test(e)?e.replace(` `,`T`):e,n=new Date(t);if(Number.isNaN(n.getTime()))return null;try{return n.toLocaleString()}catch{return n.toISOString()}},wr=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=$(),s=t?.label||t?.field||``,c=t?Sr(t.pendingValue):``,l=t?Sr(t.currentValue):``,u=t?.currentRecord??{},d=(()=>{let e=[u.updated_by_name,u.updated_by_label];for(let t of e)if(typeof t==`string`&&t.length>0)return t;let t=u.updated_by;return typeof t!=`string`||t.length===0||t.length>=16&&!/\s/.test(t)&&/^[A-Za-z0-9_-]+$/.test(t)?null:t})(),f=Cr(u.updated_at??t?.currentVersion),[p,m]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,Q.jsx)(st,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,Q.jsxs)(Zt,{className:`max-w-lg`,children:[(0,Q.jsx)(be,{children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{className:`inline-flex h-9 w-9 flex-none items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300`,"aria-hidden":`true`,children:(0,Q.jsx)(B,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(P,{children:o(`detail.concurrentUpdateTitle`)}),(0,Q.jsxs)(Ge,{className:`mt-1`,children:[p,(0,Q.jsx)(`strong`,{className:`font-semibold`,children:s}),m]})]})]})}),(0,Q.jsxs)(`div`,{className:`space-y-2 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`rounded-md border border-amber-200/70 bg-amber-50/60 p-3 dark:border-amber-500/30 dark:bg-amber-500/10`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-amber-800 dark:text-amber-300`,children:o(`detail.concurrentUpdateYourEdit`)}),(0,Q.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:c})]}),(0,Q.jsxs)(`div`,{className:`rounded-md border border-sky-200/70 bg-sky-50/60 p-3 dark:border-sky-500/30 dark:bg-sky-500/10`,children:[(0,Q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-wide text-sky-800 dark:text-sky-300`,children:o(`detail.concurrentUpdateCurrentValue`)}),(d||f)&&(0,Q.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[d&&(0,Q.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedBy`,{name:d})}),d&&f&&(0,Q.jsx)(`span`,{children:` · `}),f&&(0,Q.jsx)(`span`,{children:o(`detail.concurrentUpdateUpdatedAt`,{when:f})})]})]}),(0,Q.jsx)(`div`,{className:`mt-1 break-all font-mono text-foreground`,children:l})]})]}),(0,Q.jsxs)(Jt,{className:`gap-2 sm:gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:W(L({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:W(L({variant:`outline`}),`mt-2 sm:mt-0 text-destructive border-destructive/40 hover:bg-destructive/10 hover:text-destructive`),children:o(`detail.concurrentUpdateOverwrite`)}),(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:n,autoFocus:!0,className:W(L({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function Tr(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}var Er=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name)||null,Dr=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Or=({schema:e={},className:t,...n})=>{let r=u(),{designer:i}=Dr(n);if(!r)return(0,Q.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:details — bind a record to preview`})});let a=e.layout===`inline`||e.layout===`compact`?`horizontal`:`vertical`,c=r.objectName||``,l=o(),{readableFields:d}=s(c),{sectionLabel:f}=en(),p=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(p.length>0&&c&&!p.every(e=>l.can(c,e)))return(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let m=e.enforceFieldSecurity===!0,g=Array.isArray(e.redactFields)?e.redactFields:[],_=e=>{if(!e||!m&&g.length===0)return e;let t=e.map(Er).filter(e=>!!e),n=new Set((m&&c?d(t):t).filter(e=>!g.includes(e)));return e.filter(e=>{let t=Er(e);return t?n.has(t):!0})},v=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,y=e=>Array.isArray(e)?e.map(v):e,b=h(),x=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:Er(e)).filter(e=>!!e));for(let e of b)x.add(e);let S=r.objectSchema,C=r.data??{},w=[S?.primaryField,`name`,`full_name`,`title`,`subject`,`display_name`,`label`].filter(e=>typeof e==`string`&&e.length>0);for(let e of w)if(C[e]!==void 0&&C[e]!==null&&C[e]!==``){x.add(e);break}let T=e=>!e||x.size===0?e:e.filter(e=>{let t=Er(e);return t?!x.has(t):!0}),E=T(y(_(e.fields))),D=Array.isArray(e.sections)?e.sections.map(e=>{let t=e.title??e.label,n=e.name&&c?f(c,e.name,t??e.name):t;return{...e,title:n,showBorder:e.showBorder??!!n,hideEmpty:e.hideEmpty??!0,fields:T(y(_(e.fields)))}}):e.sections,O=e.inlineEdit??!0,[k,A]=Z.useState(null),[j,M]=Z.useState(!1),N=Z.useCallback(t=>{let n=[...Array.isArray(e.fields)?e.fields:[],...(Array.isArray(e.sections)?e.sections:[]).flatMap(e=>Array.isArray(e?.fields)?e.fields:[])];for(let e of n)if((typeof e==`string`?e:e?.name||e?.field)===t)return typeof e==`object`?e?.label:void 0},[e.fields,e.sections]),ee=Z.useCallback(async(e,t)=>{let n=r.dataSource,i=r.recordId,a=r.objectName;if(!n||!i||!a)return;let o=typeof r.data?.updated_at==`string`?r.data.updated_at:void 0,s=o?{ifMatch:o}:void 0;try{if(typeof n.update==`function`)await n.update(a,i,{[e]:t},s);else if(typeof n.updateOne==`function`)await n.updateOne(a,i,{[e]:t},s);else if(typeof n.patch==`function`)await n.patch(a,i,{[e]:t},s);else{console.warn(`[record:details] DataSource exposes no update/updateOne/patch method; cannot persist inline edit`);return}typeof r.refresh==`function`&&await r.refresh()}catch(n){if(Tr(n)){let r=n.currentRecord??null;throw A({field:e,label:N(e),pendingValue:t,currentValue:r?r[e]:void 0,currentVersion:n.currentVersion,currentRecord:r}),n}throw console.error(`[record:details] Inline-edit save failed`,n),n}},[r.dataSource,r.recordId,r.objectName,r.data,r.refresh,N]),P=Z.useCallback(()=>{A(null),M(!1)},[]),F=Z.useCallback(async()=>{M(!0);try{typeof r.refresh==`function`&&await r.refresh()}finally{P()}},[r.refresh,P]),te=Z.useCallback(async()=>{if(!k){P();return}let e=r.dataSource,t=r.recordId,n=r.objectName;if(!e||!t||!n){P();return}M(!0);try{let i=k.currentVersion?{ifMatch:k.currentVersion}:void 0;typeof e.update==`function`?await e.update(n,t,{[k.field]:k.pendingValue},i):typeof e.updateOne==`function`?await e.updateOne(n,t,{[k.field]:k.pendingValue},i):typeof e.patch==`function`&&await e.patch(n,t,{[k.field]:k.pendingValue},i),typeof r.refresh==`function`&&await r.refresh()}catch(e){console.error(`[record:details] Overwrite-on-conflict failed`,e)}finally{P()}},[k,r.dataSource,r.recordId,r.objectName,r.refresh,P]),I={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:a,columns:e.columns,sections:D,fields:E,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:O};return(0,Q.jsxs)(`div`,{className:t,...i,children:[(0,Q.jsx)(xr,{schema:I,dataSource:r.dataSource,inlineEdit:O,onFieldSave:ee}),(0,Q.jsx)(wr,{open:!!k,conflict:k,busy:j,onCancel:P,onReload:F,onOverwrite:te})]})},kr=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name||e.key)||null,Ar=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},jr=({schema:e={},className:t,...n})=>{let r=u(),{designer:i}=Ar(n),a=en(),c=e.objectName,l=c&&a.objectLabel?a.objectLabel({name:c,label:ct(c)}):c?ct(c):``,d=e.title||l||`Related`;if(!c)return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});let f=o(),{readableFields:p}=s(c),m=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(m.length>0&&!m.every(e=>f.can(c,e)))return(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let h=e.enforceFieldSecurity===!0,g=Array.isArray(e.redactFields)?e.redactFields:[],_=Array.isArray(e.columns)?e.columns:[],v=_;if(h||g.length>0){let e=_.map(kr).filter(e=>!!e),t=new Set((h?p(e):e).filter(e=>!g.includes(e)));v=_.filter(e=>{let n=kr(e);return n?t.has(n):!0})}return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(Jn,{title:d,type:`table`,api:c,objectName:c,referenceField:e.relationshipField,parentId:r?.recordId,columns:v,pageSize:e.limit,dataSource:r?.dataSource,add:e.add,onRowDelete:e.add&&r?.dataSource?async e=>{let t=e?.id??e?._id;t!=null&&await r.dataSource.delete?.(c,String(t))}:void 0})})},Mr=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Nr=({schema:e={},className:t,...n})=>{let r=u(),{designer:i}=Mr(n),a=r?.objectName||``,c=o(),{readableFields:d}=s(a),f=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(f.length>0&&a&&!f.every(e=>c.can(a,e)))return(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})});let p=(Array.isArray(e.fields)?e.fields:[]).map(e=>typeof e==`string`?{name:e}:{name:e?.name,label:e?.label,icon:e?.icon,type:e?.type}).filter(e=>typeof e.name==`string`&&e.name.length>0),m=e.enforceFieldSecurity===!0,h=Array.isArray(e.redactFields)?e.redactFields:[],g=m&&a?new Set(d(p.map(e=>e.name))):null,_=p.filter(e=>!(h.includes(e.name)||g&&!g.has(e.name)));return l(Z.useId(),_.map(e=>e.name)),(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(Xn,{fields:_,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema})})},Pr=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),r=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),i=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,Q.jsxs)(`div`,{className:W(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,Q.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,Q.jsx)(Kt,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:i})]})},Fr=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],Ir=({reactions:e,onToggleReaction:t,emojiOptions:n=Fr,className:r})=>{let[i,a]=Z.useState(!1),o=Z.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,Q.jsxs)(`div`,{className:W(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:W(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>o(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,Q.jsx)(`span`,{children:e.emoji}),(0,Q.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,Q.jsx)(Ue,{className:`h-3.5 w-3.5`})}),i&&(0,Q.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:n.map(t=>(0,Q.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>o(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function Lr(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}var Rr=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=$(),[o,s]=Z.useState(!1),[c,l]=Z.useState(``),[u,d]=Z.useState(!1),f=Z.useCallback(async()=>{let t=c.trim();if(!(!t||!n)){d(!0);try{await n(e.id,t),l(``)}finally{d(!1)}}},[c,n,e.id]),p=Z.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,Q.jsxs)(`div`,{className:W(`ml-10 mt-1`,i),children:[t.length>0&&(0,Q.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>s(!o),"aria-expanded":o,children:[o?(0,Q.jsx)(ae,{className:`h-3 w-3`}):(0,Q.jsx)(we,{className:`h-3 w-3`}),(0,Q.jsx)(U,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,Q.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,Q.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,Q.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Lr(e.createdAt,a)})]}),(0,Q.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,Q.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,Q.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.replyPlaceholder`),value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:u}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,Q.jsx)(gt,{className:`h-3 w-3`})})]})]})},zr=({subscription:e,onToggle:t,className:n})=>{let{t:r}=$(),[i,a]=Z.useState(!1),o=Z.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:W(`h-8 w-8`,n),onClick:o,disabled:i||!t,"aria-label":e.subscribed?r(`detail.unsubscribeAriaLabel`):r(`detail.subscribeAriaLabel`),title:e.subscribed?r(`detail.subscribedTooltip`):r(`detail.unsubscribedTooltip`),children:e.subscribed?(0,Q.jsx)(lt,{className:`h-4 w-4 text-primary`}):(0,Q.jsx)(ze,{className:`h-4 w-4 text-muted-foreground`})})};function Br(e){let t=e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/```([\s\S]*?)```/g,`<pre class="bg-muted rounded p-2 text-xs font-mono my-1 overflow-x-auto">$1</pre>`).replace(/`([^`]+)`/g,`<code class="bg-muted rounded px-1 py-0.5 text-xs font-mono">$1</code>`).replace(/\*\*(.+?)\*\*/g,`<strong>$1</strong>`).replace(/\*(.+?)\*/g,`<em>$1</em>`).replace(/@(\w+)/g,`<span class="text-primary font-medium">@$1</span>`).replace(/^- (.+)$/gm,`<li class="ml-4 list-disc">$1</li>`).replace(/\n/g,`<br/>`);return t=t.replace(/(<li[^>]*>.*?<\/li>(?:<br\/>)?)+/g,e=>`<ul class="my-1">${e.replace(/<br\/>/g,``)}</ul>`),t}var Vr=({value:e,onChange:t,onSubmit:n,mentionSuggestions:r=[],placeholder:i,className:a,disabled:o=!1,extraSlot:s,canSubmitEmpty:c=!1})=>{let{t:l}=$(),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),[m,h]=Z.useState(``),[g,_]=Z.useState(0),v=Z.useRef(null),y=Z.useMemo(()=>{if(!m)return r;let e=m.toLowerCase();return r.filter(t=>t.label.toLowerCase().includes(e))},[m,r]),b=Z.useCallback((n,r=``)=>{let i=v.current;if(!i)return;let a=i.selectionStart,o=i.selectionEnd,s=e.slice(a,o);t(e.slice(0,a)+n+s+r+e.slice(o)),requestAnimationFrame(()=>{i.focus();let e=a+n.length+s.length;i.setSelectionRange(e,e)})},[e,t]),x=Z.useCallback(()=>b(`**`,`**`),[b]),S=Z.useCallback(()=>b(`*`,`*`),[b]),C=Z.useCallback(()=>b(`
|
|
4
|
-
- `,``),[b]),w=Z.useCallback(()=>b("`","`"),[b]),T=Z.useCallback(()=>{b(`@`,``),p(!0),h(``),_(0)},[b]),E=Z.useCallback(n=>{let r=v.current;if(!r)return;let i=r.selectionStart,a=e.slice(0,i).lastIndexOf(`@`);a!==-1&&t(e.slice(0,a)+`@${n.label} `+e.slice(i)),p(!1),h(``),requestAnimationFrame(()=>r.focus())},[e,t]),D=Z.useCallback(e=>{let n=e.target.value;t(n);let r=e.target.selectionStart,i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a!==-1){let e=i.slice(a+1),t=a>0?i[a-1]:` `;if(/\s/.test(t)&&!/\s/.test(e)){p(!0),h(e),_(0);return}}p(!1)},[t]),O=Z.useCallback(e=>{if(f&&y.length>0){if(e.key===`ArrowDown`){e.preventDefault(),_(e=>e<y.length-1?e+1:0);return}if(e.key===`ArrowUp`){e.preventDefault(),_(e=>e>0?e-1:y.length-1);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),E(y[g]);return}if(e.key===`Escape`){p(!1);return}}e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),n?.())},[f,y,g,E,n]);return(0,Q.jsxs)(`div`,{className:W(`border rounded-md`,a),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30`,children:[(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,Q.jsx)(Ct,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,Q.jsx)(Ft,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,Q.jsx)(De,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.inlineCode`),children:(0,Q.jsx)(ft,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,Q.jsx)(Xt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:u?(0,Q.jsx)(ut,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Ne,{className:`h-3.5 w-3.5`})}),n&&(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,Q.jsx)(gt,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`relative`,children:u?(0,Q.jsx)(`div`,{className:`min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:Br(e)}}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`textarea`,{ref:v,className:`w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground`,placeholder:i??l(`detail.writeComment`),value:e,onChange:D,onKeyDown:O,disabled:o}),f&&y.length>0&&(0,Q.jsx)(`div`,{className:`absolute left-2 bottom-full mb-1 w-56 bg-popover border rounded-md shadow-md z-50 max-h-40 overflow-y-auto`,children:y.map((e,t)=>(0,Q.jsxs)(`button`,{type:`button`,className:W(`w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors`,t===g&&`bg-accent`),onMouseDown:t=>{t.preventDefault(),E(e)},children:[e.avatarUrl?(0,Q.jsx)(`img`,{src:e.avatarUrl,alt:e.label,className:`h-5 w-5 rounded-full object-cover`}):(0,Q.jsx)(`div`,{className:`h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium`,children:e.label.charAt(0).toUpperCase()}),(0,Q.jsx)(`span`,{children:e.label})]},e.id))})]})}),s&&(0,Q.jsx)(`div`,{className:`border-t px-2 py-2 bg-muted/20`,children:s})]})};function Hr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ur(e){return e.startsWith(`image/`)}function Wr(e){return Ur(e)?Ye:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?ve:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?z:re}var Gr=({attachments:e,onUpload:t,onRemove:n,className:r,readOnly:i=!1})=>{let{t:a}=$(),[o,s]=Z.useState(!1),c=Z.useRef(null),l=Z.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!0)},[]),u=Z.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1)},[]),d=Z.useCallback(e=>{e.preventDefault(),e.stopPropagation(),s(!1),t&&e.dataTransfer.files.length>0&&t(e.dataTransfer.files)},[t]),f=Z.useCallback(e=>{t&&e.target.files&&e.target.files.length>0&&(t(e.target.files),e.target.value=``)},[t]);return(0,Q.jsxs)(`div`,{className:W(`space-y-2`,r),children:[t&&!i&&(0,Q.jsxs)(`div`,{className:W(`border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer`,o?`border-primary bg-primary/5`:`border-muted-foreground/25 hover:border-muted-foreground/40`),onDragOver:l,onDragLeave:u,onDrop:d,onClick:()=>c.current?.click(),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c.current?.click())},children:[(0,Q.jsx)(Oe,{className:`h-5 w-5 mx-auto text-muted-foreground mb-1`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`detail.dropFilesToUpload`)}),(0,Q.jsx)(`input`,{ref:c,type:`file`,multiple:!0,className:`hidden`,onChange:f})]}),e.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Ke,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:e.length===1?a(`detail.attachmentCount`,{count:e.length}):a(`detail.attachmentCountPlural`,{count:e.length})})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>{let t=Ur(e.type),r=Wr(e.type);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-2.5 py-2 bg-muted/30 group`,children:[t&&(e.thumbnailUrl||e.url)?(0,Q.jsx)(`img`,{src:e.thumbnailUrl||e.url,alt:e.name,className:`h-10 w-10 rounded object-cover shrink-0`}):(0,Q.jsx)(`div`,{className:`h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0`,children:(0,Q.jsx)(r,{className:`h-5 w-5 text-muted-foreground`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium truncate`,children:e.name}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:Hr(e.size)})]}),n&&!i&&(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,onClick:()=>n(e.id),title:a(`detail.removeAttachment`),children:(0,Q.jsx)(me,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},Kr={comment:U,field_change:ut,task:Be,event:Ot,system:_t,email:$t,call:pt},qr={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function Jr(e){return[{value:`all`,label:e(`detail.allActivity`)},{value:`comments_only`,label:e(`detail.commentsOnly`)},{value:`changes_only`,label:e(`detail.fieldChangesFilter`)},{value:`tasks_only`,label:e(`detail.tasksOnly`)}]}function Yr(e,t){try{let n=new Date(e),r=new Date().getTime()-n.getTime(),i=Math.floor(r/6e4);if(i<1)return t(`detail.justNow`);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);if(a<24)return t(`detail.hoursAgo`,{count:a});let o=Math.floor(a/24);return o<7?t(`detail.daysAgo`,{count:o}):n.toLocaleDateString()}catch{return e}}function Xr(e,t){switch(t){case`comments_only`:return e.filter(e=>e.type===`comment`);case`changes_only`:return e.filter(e=>e.type===`field_change`);case`tasks_only`:return e.filter(e=>e.type===`task`);default:return e}}var Zr=({items:e,config:t,filterMode:n,onFilterChange:r,hasMore:i=!1,onLoadMore:a,loading:o=!1,onAddComment:s,onAddReply:c,onToggleReaction:l,subscription:u,onToggleSubscription:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,titleLabel:h,emptyLabel:g,className:_})=>{let{t:v}=$(),[y,b]=Z.useState(`all`),[x,S]=Z.useState(``),[C,w]=Z.useState(!1),[T,E]=Z.useState(!1),[D,O]=Z.useState([]),[A,j]=Z.useState(!1),M=n??y,N=t?.showFilterToggle!==!1,ee=t?.showCommentInput!==!1&&!!s,P=t?.enableReactions??!1,F=t?.enableThreading??!1,te=t?.showSubscriptionToggle??!1,I=Z.useMemo(()=>Xr(e,M),[e,M]),ne=Z.useMemo(()=>F?I.filter(e=>!e.parentId):I,[I,F]),L=Z.useMemo(()=>{if(!F)return new Map;let e=new Map;for(let t of I)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[I,F]),re=Z.useCallback(e=>{r?r(e):b(e)},[r]),R=Z.useCallback(async()=>{let e=x.trim();if(s&&!(!e&&D.length===0)){w(!0);try{await s(e,D.length>0?D:void 0),S(``),O([])}finally{w(!1)}}},[x,D,s]),ie=Z.useCallback(async e=>{if(!(!m||e.length===0)){j(!0);try{let t=await m(e);Array.isArray(t)&&t.length>0&&O(e=>[...e,...t])}finally{j(!1)}}},[m]),oe=Z.useCallback(e=>{O(t=>t.filter(t=>t.id!==e))},[]),se=Z.useCallback(async()=>{if(a){E(!0);try{await a()}finally{E(!1)}}},[a]);return(0,Q.jsxs)(`section`,{className:W(`border-t border-border/60 pt-5`,_),"aria-label":`Discussion`,children:[(0,Q.jsx)(`header`,{className:`mb-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`h2`,{className:`flex items-center gap-2 text-base font-semibold leading-none tracking-tight`,children:[(0,Q.jsx)(ht,{className:`h-4 w-4`}),h??v(`detail.activity`),(0,Q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,I.length,`)`]})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:te&&u&&(0,Q.jsx)(zr,{subscription:u,onToggle:d})})]})}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[N&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(Pe,{value:M,onValueChange:e=>re(e),children:[(0,Q.jsx)(ge,{"aria-label":v(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,Q.jsx)(k,{})}),(0,Q.jsx)(X,{children:Jr(v).map(e=>(0,Q.jsx)(Le,{value:e.value,children:e.label},e.value))})]})}),ee&&(0,Q.jsx)(Vr,{value:x,onChange:S,onSubmit:R,mentionSuggestions:p,placeholder:v(`detail.leaveCommentPlaceholder`),disabled:C,canSubmitEmpty:D.length>0,extraSlot:m?(0,Q.jsx)(Gr,{attachments:D,onUpload:ie,onRemove:oe,readOnly:C||A}):D.length>0?(0,Q.jsx)(Gr,{attachments:D,onRemove:oe,readOnly:C}):void 0}),I.length===0?f?null:(0,Q.jsx)(Qt,{title:g??v(`detail.noActivity`),className:`py-6`}):(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:ne.map(e=>{let t=Kr[e.type]||_t,n=qr[e.type]||`bg-gray-100 text-gray-600`,r=L.get(e.id)??[];return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,Q.jsx)(`div`,{className:W(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,Q.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,Q.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:v(`detail.via`,{source:e.source})}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Yr(e.createdAt,v)}),e.edited&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:v(`detail.edited`)}),e.pinned&&(0,Q.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,v(`detail.pinned`)]})]}),e.body&&(0,Q.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.sourceObject&&e.sourceId!=null&&(0,Q.jsxs)(`a`,{href:`/objects/${e.sourceObject}/${e.sourceId}`,className:`mt-1 inline-flex items-center gap-1 text-xs text-primary hover:underline`,"data-testid":`activity-source-link`,children:[v(`detail.viewSource`),(0,Q.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),e.type===`field_change`&&e.fieldChanges&&(0,Q.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,Q.jsx)(Pr,{change:e},t))}),P&&e.reactions&&e.reactions.length>0&&(0,Q.jsx)(`div`,{className:`mt-1.5`,children:(0,Q.jsx)(Ir,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),P&&(!e.reactions||e.reactions.length===0)&&l&&(0,Q.jsx)(`div`,{className:`mt-1.5`,children:(0,Q.jsx)(Ir,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),F&&(e.replyCount??0)>0&&(0,Q.jsx)(Rr,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,Q.jsx)(`div`,{className:`text-center pt-2`,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:se,disabled:T,"aria-label":v(`detail.loadMore`),children:[T?(0,Q.jsx)(Ce,{className:`h-4 w-4 animate-spin mr-1`}):(0,Q.jsx)(ae,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},Qr=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},$r=({schema:e={},className:t,...n})=>{u();let{designer:r}=Qr(n);return(0,Q.jsx)(`div`,{className:t,...r,children:(0,Q.jsx)(Zr,{items:[],config:e})})},ei=({config:e,items:t,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f=!1,mentionSuggestions:p,onUploadAttachments:m,className:h})=>{let g=e?.position??`right`,_=e?.width??`360px`,v=e?.collapsible??!0,y=f&&t.length===0||(e?.defaultCollapsed??!1),{t:b}=$(),[x,S]=Z.useState(y);return g===`right`||g===`left`?x&&v?(0,Q.jsx)(`div`,{className:W(`flex items-start pt-4`,g===`right`?`border-l`:`border-r`,h),children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>S(!1),"aria-label":b(`detail.openDiscussion`),children:(0,Q.jsx)(rt,{className:`h-4 w-4`})})}):(0,Q.jsxs)(`div`,{className:W(`flex flex-col overflow-hidden`,g===`right`?`border-l`:`border-r`,h),style:{width:_,minWidth:_},children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(U,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:b(`detail.discussion`)})]}),v&&(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.closeDiscussion`),children:(0,Q.jsx)(me,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,Q.jsx)(Zr,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`),className:`border-0 shadow-none`})})]}):(0,Q.jsx)(`div`,{className:W(``,h),children:v&&x?(0,Q.jsxs)(Y,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>S(!1),"aria-label":b(`detail.showDiscussion`,{count:t.length}),children:[(0,Q.jsx)(U,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:b(`detail.showDiscussion`,{count:t.length})})]}):(0,Q.jsxs)(`div`,{children:[v&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,Q.jsx)(U,{className:`h-4 w-4`}),b(`detail.discussion`)]}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.hideDiscussion`),children:(0,Q.jsx)(St,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(Zr,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,mentionSuggestions:p,onUploadAttachments:m,titleLabel:b(`detail.discussion`),emptyLabel:b(`detail.noCommentsYet`)})]})})},ti=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},ni=({schema:e={},className:t,...n})=>{u();let r=m(),{designer:i}=ti(n),a={position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0},...e};return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(ei,{items:r?.items||[],config:a,onAddComment:r?.onAddComment,onAddReply:r?.onAddReply,onToggleReaction:r?.onToggleReaction,mentionSuggestions:r?.mentionSuggestions,onUploadAttachments:r?.onUploadAttachments})})},ri=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},ii=({schema:e={},className:t,...n})=>{let r=u(),{translateOptions:i}=en(),{designer:a}=ri(n),o=Array.isArray(e.stages)?e.stages:[],s=e.statusField,c=Z.useMemo(()=>{if(o.length===0||!s||!r?.objectName)return o;let e=i(r.objectName,s,o);return Array.isArray(e)&&e.length===o.length?o.map((t,n)=>({...t,label:e[n]?.label??t.label})):o},[o,s,r?.objectName,i]),l=s&&r?.data?r.data[s]:void 0,d=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,f=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,p=c.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(d.test(t))return`lost`;if(f.test(t))return`won`}),m=p.findIndex(e=>e===`lost`),h=m===-1?c:c.slice(0,m),g=m===-1?[]:c.slice(m),_=m===-1?p:p.slice(0,m),v=c.findIndex(e=>e.value===l);v<0&&(v=-1);let y=m!==-1&&v>=m;if(c.length===0)return(0,Q.jsx)(`div`,{className:t,...a,children:(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:path — no stages configured`})});let b=h.length-1;return(0,Q.jsxs)(`div`,{className:W(`w-full`,t),...a,children:[(0,Q.jsxs)(`div`,{className:`hidden sm:flex w-full items-stretch gap-2`,role:`list`,"aria-label":e.aria?.label||`Record path`,children:[(0,Q.jsx)(`div`,{className:`flex flex-1 items-stretch gap-1.5`,children:h.map((e,t)=>{let n=!y&&v>=0&&t<v,r=!y&&t===v,i=_[t]===`won`&&t===b;return(0,Q.jsx)(`div`,{role:`listitem`,"aria-current":r?`step`:void 0,className:W(`relative flex-1 min-w-0 px-4 py-2 text-xs font-medium text-center rounded-xl`,r&&`bg-primary text-primary-foreground shadow-sm`,n&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`,!r&&!n&&i&&`bg-emerald-500/10 text-emerald-700/85 dark:text-emerald-300/85`,!r&&!n&&!i&&`bg-muted text-muted-foreground`),children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center justify-center gap-1.5 truncate`,children:[n&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),i&&!r&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`🏆`}),e.label]})},`${e.value}-${t}`)})}),g.length>0&&(0,Q.jsx)(`div`,{className:`flex items-stretch gap-1 pl-2 border-l border-border/40`,"aria-label":`Alternative terminal stages`,children:g.map((e,t)=>{let n=m+t===v;return(0,Q.jsx)(`div`,{role:`listitem`,"aria-current":n?`step`:void 0,className:W(`shrink-0 px-3 py-2 text-xs font-medium rounded-md border whitespace-nowrap`,n&&`bg-destructive text-destructive-foreground border-destructive shadow-sm ring-1 ring-destructive/40`,!n&&`bg-destructive/5 text-destructive/85 border-destructive/20`),children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),e.label]})},`${e.value}-lost-${t}`)})})]}),(0,Q.jsx)(`div`,{className:`flex sm:hidden w-full items-stretch gap-1 overflow-x-auto pb-1 -mx-1 px-1 [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,role:`list`,"aria-label":e.aria?.label||`Record path`,children:c.map((e,t)=>{let n=p[t]===`lost`,r=!n&&!y&&v>=0&&t<v,i=t===v;return(0,Q.jsx)(`div`,{role:`listitem`,"aria-current":i?`step`:void 0,className:W(`shrink-0 px-3 py-1.5 rounded-full text-xs font-medium border whitespace-nowrap`,n&&i&&`bg-destructive text-destructive-foreground border-destructive shadow-sm`,n&&!i&&`bg-destructive/5 text-destructive/85 border-destructive/20`,!n&&i&&`bg-primary text-primary-foreground border-primary shadow-sm ring-1 ring-primary/40`,!n&&r&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200 border-emerald-500/30`,!n&&!i&&!r&&`bg-background text-foreground/85 border-border/60`),children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[n&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`✗`}),!n&&r&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`text-emerald-600 dark:text-emerald-400 font-semibold`,children:`✓`}),e.label]})},`${e.value}-${t}-m`)})})]})},ai=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},oi=({schema:e={},className:t,...n})=>{let r=u(),{designer:i}=ai(n),a=o(),s=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],c=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:[],l=r?.objectName||``,d=c.length>0?c:Array.isArray(s)&&s.every(e=>typeof e==`string`)?s:[],p=d.length>0&&!!l,{item:m}=f(`object`,p?l:null),h=p?(()=>{let e=Array.isArray(m?.actions)?m.actions:[],t=new Map(e.map(e=>[e.name,e]));return d.map(e=>t.get(e)).filter(e=>!!e)})():Array.isArray(s)?s:[],g=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(g.length>0&&l&&!g.every(e=>a.can(l,e)))return(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let _=e.location||`record_header`,{getActionsForLocation:v,executeAction:y}=C({actions:h,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}}),b=h.length>0?v(_):[];if(b.length===0)return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:quick_actions — no actions configured`})});let x=e.align||`end`,S=x===`start`?`justify-start`:x===`center`?`justify-center`:`justify-end`;return(0,Q.jsx)(`div`,{className:W(`flex flex-wrap items-center gap-2`,_===`record_header`&&!e.inline&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,S,t),role:`toolbar`,"aria-label":e.aria?.label||`Quick actions`,...i,children:b.map((t,n)=>(0,Q.jsx)(si,{action:t,record:r?.data,variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,label:t.label||t.name||`Action ${n+1}`,onRun:async()=>{typeof t.onClick==`function`?await t.onClick():t.name&&await y(t.name)}},t.name||`qa-${n}`))})};function si({action:e,record:t,variant:n,size:r,label:i,onRun:a}){let[o,s]=Z.useState(!1),c=Z.useMemo(()=>({record:t||{}}),[t]),l=d(e.disabled),u=w(typeof l==`string`?l:void 0,c);return(0,Q.jsxs)(Y,{variant:n,size:r,disabled:(typeof l==`string`?u:l===!0)||o,onClick:async()=>{s(!0);try{await a()}finally{s(!1)}},children:[o&&(0,Q.jsx)(Ce,{className:`mr-2 h-4 w-4 animate-spin`}),i]})}var ci=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},li=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),ui=({schema:e={},className:t,...n})=>{let{designer:r}=ci(n),i=u(),a=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:void 0,o=e.loading??e.properties?.loading,s=e.emptyText??e.properties?.emptyText,c=Number(e.limit??e.properties?.limit??50)||50,l=i?.objectName,d=i?.data?.id??i?.data?._id??i?.recordId,f=i?.dataSource,p=a===void 0&&!!f?.find&&!!l&&d!=null,[m,h]=Z.useState(null),[g,_]=Z.useState(!1);Z.useEffect(()=>{if(!p)return;let e=!1;return _(!0),Promise.resolve(f.find(`sys_activity`,{$filter:{object_name:l,record_id:d},$orderby:{timestamp:`desc`},$top:Math.max(1,c)})).then(t=>{e||h((t?.data??t?.records??[]).filter(e=>li.has(e?.type)).map(e=>{let t=e.timestamp;return(!t||t===`NOW()`||Number.isNaN(Date.parse(t)))&&(t=e.created_at),{id:e.id,created_at:t,action:e.type,user_name:e.actor_name??null,user_avatar:e.actor_avatar_url??null,summary:e.summary??null}}))}).catch(()=>{e||h([])}).finally(()=>{e||_(!1)}),()=>{e=!0}},[p,f,l,d,c]);let v=a??m??[],y=o??(p&&m===null?g||!0:!1);return(0,Q.jsx)(`div`,{className:t,...r,children:(0,Q.jsx)(dr,{entries:v,loading:y,emptyText:s})})},di=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},fi=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),pi=(e,t)=>t&&e?.[t]!=null&&e[t]!==``?String(e[t]):e?.name||e?.title||e?.subject||e?.label||e?.email||e?.username||e?.code||e?.slug||e?.provider_id||e?.user_agent||e?.ip_address||e?.id||`—`,mi=({schema:e={},className:t,...n})=>{let a=u(),o=en(),{t:s}=$(),{designer:c}=di(n),l=r().appName,d=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],f=a?.recordId,p=a?.dataSource,[m,h]=Z.useState({}),g=Z.useRef(null),[_,v]=Z.useState(!1),y=Z.useRef(!0);Z.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]);let b=Z.useRef(``);Z.useEffect(()=>{if(_)return;let e=g.current;if(!e||typeof IntersectionObserver>`u`){v(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&v(!0)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[_]);let x=JSON.stringify(d.map(e=>`${e.objectName}:${e.relationshipField}:${e.limit??3}`));if(Z.useEffect(()=>{if(!_||!p?.find||!f||d.length===0)return;let e=`${f}::${x}`;if(b.current===e)return;b.current=e,h(e=>{let t={...e};for(let n of d)t[n.objectName]={loading:!0,total:0,items:e[n.objectName]?.items||[]};return t});let t=async e=>{let t=e.objectName;try{let n=await p.find(e.objectName,{$filter:{[e.relationshipField]:f},$top:e.limit??3,$count:!0});if(!y.current)return;let r=Array.isArray(n)?n:n?.data||[],i=typeof n?.total==`number`?n.total:typeof n?.count==`number`?n.count:r.length;h(e=>({...e,[t]:{loading:!1,total:i,items:r}}))}catch(e){if(!y.current)return;h(n=>({...n,[t]:{loading:!1,total:0,items:[],error:String(e?.message||e)}}))}},n=[...d],r=async()=>{for(;y.current;){let e=n.shift();if(!e)return;await t(e)}},i=Array.from({length:Math.min(3,n.length)},()=>r());Promise.all(i)},[_,p,f,x]),d.length===0)return null;let S=e.hideEmpty!==!1,[C,w]=Z.useState(!1),T=new Set(d.filter(e=>{let t=m[e.objectName];return S&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),E=d.filter(e=>C||!T.has(e.objectName)),D=d.filter(e=>T.has(e.objectName)).map(e=>e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:fi(e.objectName)}):fi(e.objectName)));return(0,Q.jsxs)(`div`,{ref:g,className:W(`flex flex-col gap-3`,e.className,t),...c,children:[E.map(e=>{let t=e.objectName,n=m[t]||{loading:!0,total:0,items:[]};return(0,Q.jsxs)(Pt,{className:`overflow-hidden`,children:[(0,Q.jsxs)(At,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,Q.jsx)(It,{className:`text-sm font-semibold tracking-tight truncate`,children:e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:fi(e.objectName)}):fi(e.objectName))}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!n.loading&&(0,Q.jsx)(xt,{variant:`secondary`,className:`tabular-nums`,children:n.total}),l&&f&&(0,Q.jsx)(i,{to:`/apps/${l}/${e.objectName}?filter%5B${e.relationshipField}%5D=${encodeURIComponent(String(f))}`,className:`text-[11px] font-medium text-muted-foreground hover:text-foreground transition-colors`,title:s(`detail.viewAll`,{defaultValue:`View all`}),children:s(`detail.viewAll`,{defaultValue:`View all`})})]})]}),(0,Q.jsx)(mt,{className:`p-0`,children:n.loading?(0,Q.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,Q.jsx)(Ee,{className:`h-3.5 w-4/5`}),(0,Q.jsx)(Ee,{className:`h-3.5 w-3/5`}),(0,Q.jsx)(Ee,{className:`h-3.5 w-2/3`})]}):n.items.length===0?(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:s(`detail.noRecords`)}):(0,Q.jsx)(`ul`,{className:`divide-y`,children:n.items.map(t=>{let n=t.id||t._id,r=pi(t,e.displayField),a=n?`../${e.objectName}/record/${encodeURIComponent(String(n))}`:void 0;return(0,Q.jsx)(`li`,{className:`px-4 py-2`,children:a?(0,Q.jsxs)(i,{to:a,className:`group flex items-center justify-between gap-2 text-xs hover:text-foreground text-muted-foreground transition-colors`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:r}),(0,Q.jsx)(we,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,Q.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})},String(n||r))})})})]},t)}),!C&&D.length>0&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>w(!0),className:`self-start inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors px-2.5 py-1 rounded-md border border-dashed border-border/60 hover:border-border bg-background`,title:D.join(` · `),children:[(0,Q.jsx)(`span`,{children:s(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:D.length})}),(0,Q.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,D.join(` · `),`)`]})]})]})},hi={info:{wrap:`border-blue-300/60 bg-blue-50 text-blue-900 dark:border-blue-700/40 dark:bg-blue-950/30 dark:text-blue-100 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-300`,icon:`Info`},warning:{wrap:`border-amber-300/60 bg-amber-50 text-amber-900 dark:border-amber-700/40 dark:bg-amber-950/30 dark:text-amber-100 [&>svg]:text-amber-600 dark:[&>svg]:text-amber-300`,icon:`AlertTriangle`},error:{wrap:`border-destructive/60 bg-destructive/10 text-destructive dark:bg-destructive/20 [&>svg]:text-destructive`,icon:`AlertCircle`},success:{wrap:`border-emerald-300/60 bg-emerald-50 text-emerald-900 dark:border-emerald-700/40 dark:bg-emerald-950/30 dark:text-emerald-100 [&>svg]:text-emerald-600 dark:[&>svg]:text-emerald-300`,icon:`CheckCircle2`}};function gi(e){let t=e?.properties??{};return{...e,...t}}var _i=({schema:e={},className:t})=>{let n=gi(e),r=u(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,s=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,c=hi[s],l=n.icon||c.icon,p=d(n.visible),m=w(p,{record:i}),h=Z.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||n.title||s;return`os.record-alert:${a}:${o??`_`}:${e}`},[n.dismissible,n.dismissKey,n.title,s,a,o]),[g,_]=Z.useState(()=>{if(!h||typeof window>`u`)return!1;try{return window.localStorage.getItem(h)===`1`}catch{return!1}}),v=n.action?.actionName,{item:y}=f(`object`,v&&a?a:null),b=Z.useMemo(()=>{if(!(!v||!y?.actions))return y.actions.find(e=>e.name===v)},[v,y]),{executeAction:x}=C({actions:Z.useMemo(()=>b?[b]:[],[b]),context:{record:i,recordId:o,objectName:a}});return g||!i||Object.keys(i).length===0||p!==void 0&&!m?null:(0,Q.jsxs)(jt,{className:W(`relative pr-12`,c.wrap,t),role:s===`error`?`alert`:`status`,"aria-live":s===`error`?`assertive`:`polite`,children:[(0,Q.jsx)(He,{name:l,className:`h-4 w-4`,"aria-hidden":`true`}),n.title?(0,Q.jsx)(dt,{children:n.title}):null,n.body||b?(0,Q.jsxs)(wt,{children:[n.body?(0,Q.jsx)(`p`,{className:`mb-2 last:mb-0`,children:n.body}):null,b?(0,Q.jsx)(Y,{size:`sm`,variant:n.action?.variant||(s===`error`?`destructive`:`default`),onClick:()=>{b?.name&&x(b.name)},children:n.action?.label||b.label||b.name}):null]}):null,n.dismissible?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{if(_(!0),h)try{window.localStorage.setItem(h,`1`)}catch{}},"aria-label":`Dismiss`,className:`absolute right-3 top-3 inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/80 hover:bg-foreground/5 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,children:(0,Q.jsx)(He,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},vi=new Set([`id`,`_id`,`__v`,`created_at`,`updated_at`,`createdAt`,`updatedAt`,`created_by`,`updated_by`,`organization_id`,`tenant_id`,`owner_id`,`deleted_at`,`is_deleted`]),yi=480,bi=95;function xi({open:e,onClose:t,title:n,record:r,objectName:i,recordId:a,dataSource:o,objectSchema:s,width:c=`min(960px, 60vw)`,columns:l=2,systemFields:u=vi,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=$(),g=`objectui.drawerWidth.${i}`,[_,v]=Z.useState(()=>{if(typeof window>`u`||!p)return null;try{let e=window.localStorage.getItem(g);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=yi)return t}}catch{}return null}),y=Z.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),b=y?{width:y,maxWidth:y}:void 0,x=Z.useRef(null),S=Z.useCallback(e=>{if(!p)return;e.preventDefault();let t=_??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);x.current={startX:e.clientX,startWidth:t};let n=e=>{let t=x.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*bi/100:1600,i=Math.min(r,Math.max(yi,t.startWidth+n));v(Math.round(i))},r=()=>{x.current,x.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{v(e=>(e!=null&&window.localStorage.setItem(g,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[p,_,g]),C=s?.fields??{},w=(Object.keys(C).length?Object.keys(C):Object.keys(r)).filter(e=>!u.has(e)&&!e.startsWith(`__`)).filter(e=>e in r).filter(e=>!C[e]?.hidden).map(e=>{let t=C[e]||{},n=t.type===`lookup`||t.type===`master_detail`||t.type===`reference`;return{name:e,label:t.label,type:t.type,readonly:!!t.readonly||n,options:t.options,currency:t.currency,precision:t.precision,format:t.format,reference_to:t.reference_to??t.referenceTo??t.target,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}});return(0,Q.jsx)(Te,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(Ae,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:b,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize drawer`,onPointerDown:S,className:`hidden sm:block absolute left-0 top-0 h-full w-1.5 cursor-col-resize select-none bg-transparent hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`}),(0,Q.jsx)(ue,{className:`sr-only`,children:(0,Q.jsx)(Nt,{children:n})}),(0,Q.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,Q.jsx)(xr,{dataSource:o,inlineEdit:!0,schema:{type:`detail-view`,objectName:i,resourceId:String(a),data:r,showDelete:!0,columns:l,fields:w,actions:m?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:h(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(m,`_blank`,`noopener`)}]}]:void 0},onFieldSave:async(e,t)=>{try{await d?.(e,t)}catch(e){console.error(`[RecordDetailDrawer] inline field save failed:`,e)}},onDelete:async()=>{try{await f?.(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}})})]})})}function Si(e,t){if(typeof window>`u`)return null;let n=window.location.pathname,r=`/${e}`,i=n.indexOf(r);return`${i>=0?n.slice(0,i):n.replace(/\/$/,``)}/${e}/record/${encodeURIComponent(String(t))}`}function Ci(e,t){if(!e||!t.length)return[];let n=[...t].sort((e,t)=>t.label.length-e.label.length),r=e,i=new Set;for(let e of n){if(!e.label)continue;let t=e.label.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),n=RegExp(`@${t}(?![\\p{L}\\p{N}_])`,`gu`);n.test(r)&&(i.add(e.id),r=r.replace(n,e=>` `.repeat(e.length)))}return[...i]}function wi(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function Ti(e){if(!e)return null;if(e.stageField)return e.stageField;let t=e.fields||{};for(let e of[`status`,`stage`,`state`,`phase`])if(e in t)return e;for(let[e,n]of Object.entries(t)){let t=(n?.type||``).toLowerCase();if(t===`status`||t===`stage`)return e}return null}function Ei(e,t){if(!e||!t)return null;let n=e.fields?.[t]?.options;return!Array.isArray(n)||n.length===0?null:n.map(e=>({value:e.value,label:e.label}))}function Di(e,t,n=4){if(!e)return[];if(Array.isArray(e.highlightFields)&&e.highlightFields.length>0)return e.highlightFields.slice(0,n);let r=new Set([`id`,`_id`,`created_at`,`updated_at`,`deleted_at`,`created_by`,`updated_by`,`deleted_by`,`organization_id`,`workspace_id`,`tenant_id`,`org_id`]);t&&r.add(t),e.primaryField&&r.add(e.primaryField);for(let t of[`name`,`full_name`,`title`,`subject`,`display_name`])t in(e.fields||{})&&r.add(t);let i=[`owner`,`owner_id`,`amount`,`rating`,`source`,`priority`,`industry`,`phone`,`email`,`close_date`,`due_date`,`start_date`,`expected_close_date`,`account`,`account_id`,`contact`,`contact_id`],a=new Set([`currency`,`number`,`integer`,`decimal`,`percent`,`date`,`datetime`,`time`,`reference`,`lookup`,`user`,`owner`,`select`,`enum`,`multiselect`,`status`,`email`,`phone`,`url`,`text`,`string`]),o=[],s=e.fields||{};for(let e of i)if(e in s&&!r.has(e)&&o.push(e),o.length>=n)return o;for(let e of Object.keys(s)){if(o.includes(e)||r.has(e))continue;let t=s[e]?.type;if(!(t&&!a.has(t))&&(o.push(e),o.length>=n))break}return o}function Oi(e,t={}){return{type:`page:header`,recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}}}function ki(e,t={}){let n=t.statusField??Ti(e),r=t.stages??(n?Ei(e,n):null),i=t.highlightFields??Di(e,n),a=[];return!t.hideHighlights&&i.length>0&&a.push({type:`record:highlights`,fields:i}),!t.hidePath&&n&&r&&r.length>0&&a.push({type:`record:path`,statusField:n,stages:r}),a}function Ai(e,t,n){return{type:`record:details`,sections:t,...n&&n.length>0?{hideFields:n}:{}}}function ji(e,t={}){let n=t.statusField??Ti(e),r=t.highlightFields??Di(e,n),i=[{label:`Details`,children:[Ai(e,t.sections,r)]}];if(!t.hideRelatedTab&&Array.isArray(t.related)&&t.related.length>0){let e=e=>({type:`record:related_list`,title:e.title,objectName:e.objectName,relationshipField:e.relationshipField,...e.columns?{columns:e.columns}:{},...e.limit?{limit:e.limit}:{},...e.icon?{icon:e.icon}:{}});if(t.relatedLayout===`tabs`)for(let n of t.related)i.push({label:n.title||n.objectName,...n.icon?{icon:n.icon}:{},children:[e(n)]});else i.push({label:`Related`,children:t.related.map(e)})}return t.showActivity&&i.push({label:`Activity`,children:[{type:`record:activity`}]}),t.history&&i.push({label:`History`,children:[{type:`record:history`,entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText}]}),{type:`page:tabs`,items:i}}function Mi(){return{type:`record:discussion`}}function Ni(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...wi(n.header)):r.push(Oi(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...wi(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...wi(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...wi(n.highlights)):r.push(...ki(e,{highlightFields:t.highlightFields,statusField:t.statusField,stages:t.stages,hideHighlights:t.hideHighlights,hidePath:t.hidePath}));let i=t.showReferenceRail===!0&&!t.hideReferenceRail&&Array.isArray(t.related)&&t.related.length>=2,a=t.hideRelatedTab??i;if(`tabs`in n&&n.tabs!==void 0)r.push(...wi(n.tabs));else if(`details`in n&&n.details!==void 0){let i=wi(n.details),o=ji(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a,relatedLayout:t.relatedLayout});Array.isArray(o.items)&&o.items.length>0&&(o.items[0]={...o.items[0],children:i}),r.push(o)}else r.push(ji(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a,relatedLayout:t.relatedLayout}));`discussion`in n&&n.discussion!==void 0?r.push(...wi(n.discussion)):t.hideDiscussion||r.push(Mi());let o=[{name:`main`,width:`full`,components:r}],s=wi(n.rightRail);if(i||s.length>0){let e=[];i&&e.push({type:`record:reference_rail`,entries:t.related.map(e=>({objectName:e.objectName,relationshipField:e.relationshipField,title:e.title,icon:e.icon,displayField:e.displayField,limit:3}))}),s.length>0&&e.push(...s),o.push({name:`aside`,width:`small`,className:`hidden xl:flex flex-col gap-4`,components:e})}return{type:`record`,pageType:`record`,object:e?.name,template:`full-width`,regions:o}}var Pi=t({DetailSection:()=>Gn,DetailView:()=>xr,RecordActivityRenderer:()=>$r,RecordAlertRenderer:()=>_i,RecordChatterRenderer:()=>ni,RecordDetailsRenderer:()=>Or,RecordHighlightsRenderer:()=>Nr,RecordHistoryRenderer:()=>ui,RecordPathRenderer:()=>ii,RecordQuickActionsRenderer:()=>oi,RecordReferenceRailRenderer:()=>mi,RecordRelatedListRenderer:()=>jr,RelatedList:()=>Jn,buildDefaultPageSchema:()=>Ni});S.register(`detail-view`,xr,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`resourceId`,type:`string`,label:`Resource ID`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`object`,label:`Data`},{name:`layout`,type:`enum`,label:`Layout Mode`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`,label:`Grid Columns`},{name:`sections`,type:`array`,label:`Sections`},{name:`fields`,type:`array`,label:`Fields`},{name:`tabs`,type:`array`,label:`Tabs`},{name:`related`,type:`array`,label:`Related Lists`},{name:`actions`,type:`array`,label:`Actions`},{name:`showBack`,type:`boolean`,label:`Show Back Button`,defaultValue:!0},{name:`backUrl`,type:`string`,label:`Back URL`},{name:`showEdit`,type:`boolean`,label:`Show Edit Button`,defaultValue:!1},{name:`editUrl`,type:`string`,label:`Edit URL`},{name:`showDelete`,type:`boolean`,label:`Show Delete Button`,defaultValue:!1},{name:`deleteConfirmation`,type:`string`,label:`Delete Confirmation Message`},{name:`loading`,type:`boolean`,label:`Show Loading State`},{name:`header`,type:`object`,label:`Custom Header`},{name:`footer`,type:`object`,label:`Custom Footer`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[],related:[]}}),S.register(`detail-section`,Gn,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Default Collapsed`,defaultValue:!1},{name:`columns`,type:`number`,label:`Columns`,defaultValue:2},{name:`showBorder`,type:`boolean`,label:`Show Border`,defaultValue:!0},{name:`headerColor`,type:`string`,label:`Header Color`}]}),S.register(`related-list`,Jn,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`,required:!0},{name:`type`,type:`enum`,label:`Type`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}],defaultValue:`table`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`array`,label:`Data`},{name:`columns`,type:`array`,label:`Columns`}]}),S.register(`detail`,xr,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`recordId`,type:`string`,label:`Record ID`},{name:`fields`,type:`array`,label:`Fields`}]}),S.register(`record:details`,Or,{namespace:`record`,category:`record`,label:`Record Details`,icon:`FileText`}),S.register(`record:related_list`,jr,{namespace:`record`,category:`record`,label:`Related List`,icon:`List`}),S.register(`record:highlights`,Nr,{namespace:`record`,category:`record`,label:`Highlights Panel`,icon:`Star`}),S.register(`record:activity`,$r,{namespace:`record`,category:`record`,label:`Activity Timeline`,icon:`Activity`}),S.register(`record:chatter`,ni,{namespace:`record`,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`}),S.register(`record:discussion`,ni,{namespace:`record`,category:`record`,label:`Discussion`,icon:`MessageSquare`}),S.register(`record:path`,ii,{namespace:`record`,category:`record`,label:`Path / Stepper`,icon:`GitBranch`}),S.register(`record:quick_actions`,oi,{namespace:`record`,category:`record`,label:`Quick Actions`,icon:`Zap`}),S.register(`record:history`,ui,{namespace:`record`,category:`record`,label:`History Timeline`,icon:`Clock`}),S.register(`record:reference_rail`,mi,{namespace:`record`,category:`record`,label:`Reference Rail`,icon:`PanelRight`}),S.register(`record:alert`,_i,{namespace:`record`,category:`record`,label:`Alert Banner`,icon:`AlertTriangle`});export{Si as a,On as c,xi as i,Ni as n,ei as o,Ci as r,xr as s,Pi as t};
|