@objectstack/console 15.1.0 → 16.0.0-rc.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.
Files changed (120) hide show
  1. package/dist/.objectui-sha +1 -1
  2. package/dist/assets/{AdapterProvider-BFaddpzn.js → AdapterProvider-DaQhp5MR.js} +1 -1
  3. package/dist/assets/{AiPendingActionsPage-CvBOdCmI.js → AiPendingActionsPage-9UZ4_qZW.js} +1 -1
  4. package/dist/assets/ApiConsolePage-DVnQPvbh.js +1 -0
  5. package/dist/assets/{AppDocsIndex-BYY7DwDn.js → AppDocsIndex-RWbVdvGq.js} +1 -1
  6. package/dist/assets/{AppManagementPage-ct829ZDs.js → AppManagementPage-JlGIV3AH.js} +1 -1
  7. package/dist/assets/ApprovalsInboxPage-DMfSM-B7.js +1 -0
  8. package/dist/assets/AuditLogPage-C6SMCaHa.js +1 -0
  9. package/dist/assets/ComponentNavView-DpWz8z8w.js +1 -0
  10. package/dist/assets/{CreateViewDialog-C1plmcyi.js → CreateViewDialog-DQqqIAwO.js} +1 -1
  11. package/dist/assets/DashboardView-BTS9ygDI.js +1 -0
  12. package/dist/assets/{DeveloperHubPage-Cv1WYOxY.js → DeveloperHubPage-CX3urxAq.js} +1 -1
  13. package/dist/assets/{DocShell-CLtiW77i.js → DocShell-CXBgEZhg.js} +1 -1
  14. package/dist/assets/{ExpressionProvider-E8d0a2zy.js → ExpressionProvider-C26LCaQj.js} +1 -1
  15. package/dist/assets/FlowRunsPage-DKnUh_Ec.js +1 -0
  16. package/dist/assets/{IntegrationsPage-3Mmj9WPX.js → IntegrationsPage-BvyX5vIh.js} +2 -2
  17. package/dist/assets/InterfaceListPage-D00ihpcS.js +1 -0
  18. package/dist/assets/ManagedByBadge-B4O4Jy3c.js +1 -0
  19. package/dist/assets/{MarketplaceAccessDenied-BBrk9Zzt.js → MarketplaceAccessDenied-DFaKQ3Ws.js} +1 -1
  20. package/dist/assets/{MarketplaceInstalledPage-Baul16n9.js → MarketplaceInstalledPage-CKmxuBaG.js} +1 -1
  21. package/dist/assets/MarketplacePackagePage-BjhnLR61.js +4 -0
  22. package/dist/assets/{MarketplacePage-CIiUcu2P.js → MarketplacePage-BWLFbDxW.js} +1 -1
  23. package/dist/assets/{MetadataInspector-Ty_bVFlI.js → MetadataInspector-B9z7wtJS.js} +1 -1
  24. package/dist/assets/{MetadataProvider-Dw6hFBw2.js → MetadataProvider-Dq7I7eh-.js} +1 -1
  25. package/dist/assets/ObjectDataPage-Bm9tSz-w.js +1 -0
  26. package/dist/assets/PageView-BTHYu8Z9.js +1 -0
  27. package/dist/assets/ProfilePage-DAkDEioN.js +1 -0
  28. package/dist/assets/{PublicFormsPage-DIXBuC2U.js → PublicFormsPage-CRNSj35t.js} +1 -1
  29. package/dist/assets/RecordDetailView-C6UiMORv.js +9 -0
  30. package/dist/assets/RecordFormPage-Cye1lcxq.js +1 -0
  31. package/dist/assets/ReportDefaultInspector-B0nTPIZ8.js +3 -0
  32. package/dist/assets/ReportView-BeL2GZLl.js +2 -0
  33. package/dist/assets/{SearchResultsPage-BXtahiUa.js → SearchResultsPage-XP2cdAyq.js} +1 -1
  34. package/dist/assets/{SettingsHub-Cbb36Ak1.js → SettingsHub-yoHgXGvm.js} +1 -1
  35. package/dist/assets/{SettingsView-MqDu9fQ0.js → SettingsView-BO0qYMbW.js} +1 -1
  36. package/dist/assets/{SystemHubPage-CRlHp6zs.js → SystemHubPage-qOFiW2Jq.js} +1 -1
  37. package/dist/assets/data-adapter-CS4onYGf.js +9 -0
  38. package/dist/assets/drillUrlFilters-BL8PeMrH.js +1 -0
  39. package/dist/assets/framework-Oi7uo_kE.js +8 -0
  40. package/dist/assets/getIcon-CBdepA3t.js +1 -0
  41. package/dist/assets/{highlighted-body-OFNGDK62-CmEyqxRh.js → highlighted-body-OFNGDK62-CYfwZSTb.js} +1 -1
  42. package/dist/assets/i18n-grFi0A0v.js +9 -0
  43. package/dist/assets/index-D3TWmLHH.css +2 -0
  44. package/dist/assets/index-D_-Sh_Rw.js +2 -0
  45. package/dist/assets/infrastructure-CQFJ5N6p.js +3 -0
  46. package/dist/assets/mermaid-GHXKKRXX-DtO0m-Vl.js +1 -0
  47. package/dist/assets/metadata-admin-D3yD8v_g.js +25 -0
  48. package/dist/assets/plugin-calendar-Bm0-Kkhu.js +1 -0
  49. package/dist/assets/plugin-charts-BHxVdXp7.js +7 -0
  50. package/dist/assets/plugin-chatbot-BRbgUPLw.js +120 -0
  51. package/dist/assets/plugin-dashboard-ARn_CaB3.js +6 -0
  52. package/dist/assets/plugin-form-C969LzWi.js +1 -0
  53. package/dist/assets/plugin-gantt-DrEbvyAE.js +63 -0
  54. package/dist/assets/plugin-grid-CnxMz-9O.js +8 -0
  55. package/dist/assets/plugin-kanban-C-mR5I0H.js +1 -0
  56. package/dist/assets/plugin-map-fMpIp7jh.js +1 -0
  57. package/dist/assets/{plugin-markdown-CeSEfSMe.js → plugin-markdown-wZpqyjok.js} +1 -1
  58. package/dist/assets/plugin-report-kGtO0FOF.js +59 -0
  59. package/dist/assets/plugin-timeline-DZNEy3Y1.js +1 -0
  60. package/dist/assets/plugin-tree-CZRX9ChE.js +1 -0
  61. package/dist/assets/plugin-view-BhPeq9o5.js +1 -0
  62. package/dist/assets/plugins-views-DCG6qMPm.js +4 -0
  63. package/dist/assets/{skeletons-DGSWW9zt.js → skeletons-CX6Ch5Lg.js} +1 -1
  64. package/dist/assets/src-CB6vSDbd.js +19 -0
  65. package/dist/assets/src-CIr5NcaF.js +1 -0
  66. package/dist/assets/{src-2Uisncjb.js → src-DNd8fJOE.js} +1 -1
  67. package/dist/assets/{types-C7NHW0h6.js → types-C0F-S2Id.js} +1 -1
  68. package/dist/assets/ui-components-BluZyuZX.js +72 -0
  69. package/dist/assets/ui-layout-CmmmekN3.js +1 -0
  70. package/dist/assets/{use-book-data-BwZnHc4z.js → use-book-data-DyDHAzga.js} +1 -1
  71. package/dist/assets/{useMetadata-IV9x2kG3.js → useMetadata-BMHVJNxp.js} +1 -1
  72. package/dist/assets/useOpenRecordList-BfKYZKMn.js +1 -0
  73. package/dist/assets/vendor-objectstack-DxPvmbmF.js +114 -0
  74. package/dist/index.html +4 -4
  75. package/package.json +1 -1
  76. package/dist/assets/ApiConsolePage-BETRFRmt.js +0 -1
  77. package/dist/assets/ApprovalsInboxPage-CLRfOCfN.js +0 -1
  78. package/dist/assets/AuditLogPage-DrVbfMwo.js +0 -1
  79. package/dist/assets/ComponentNavView-BdBCf414.js +0 -1
  80. package/dist/assets/DashboardView-YwIvqU1F.js +0 -1
  81. package/dist/assets/FlowRunsPage-Kk2pQjuI.js +0 -1
  82. package/dist/assets/InterfaceListPage-BEv_Whkh.js +0 -1
  83. package/dist/assets/ManagedByBadge-h6zYSYEw.js +0 -1
  84. package/dist/assets/MarketplacePackagePage-C4BoxM9O.js +0 -4
  85. package/dist/assets/ObjectDataPage-C0VN22jG.js +0 -1
  86. package/dist/assets/PageView-9Qd343Y8.js +0 -1
  87. package/dist/assets/ProfilePage-DotFPbJV.js +0 -1
  88. package/dist/assets/RecordDetailView-WbRO9Qfl.js +0 -2
  89. package/dist/assets/RecordFormPage-CVM9R6n6.js +0 -1
  90. package/dist/assets/ReportDefaultInspector-Dfj5Pq4K.js +0 -3
  91. package/dist/assets/ReportView-BuAo4KRU.js +0 -2
  92. package/dist/assets/data-adapter-BaT0fWzy.js +0 -9
  93. package/dist/assets/framework-CavAJOoG.js +0 -6
  94. package/dist/assets/getIcon-CJv2JJRu.js +0 -1
  95. package/dist/assets/i18n--Ef6MgVx.js +0 -9
  96. package/dist/assets/index-DwHOkKSZ.css +0 -2
  97. package/dist/assets/index-sUYxMYg4.js +0 -2
  98. package/dist/assets/infrastructure-1EBA2wrr.js +0 -3
  99. package/dist/assets/mermaid-GHXKKRXX-B608OHDp.js +0 -1
  100. package/dist/assets/metadata-admin-CaWsYPuu.js +0 -25
  101. package/dist/assets/plugin-calendar-lTyyzuqa.js +0 -1
  102. package/dist/assets/plugin-charts-CXDDqZeY.js +0 -7
  103. package/dist/assets/plugin-chatbot-CGYrsTXi.js +0 -120
  104. package/dist/assets/plugin-dashboard-oozFEUjN.js +0 -6
  105. package/dist/assets/plugin-form-Hw4-ReuX.js +0 -1
  106. package/dist/assets/plugin-gantt-DIrw5DOt.js +0 -102
  107. package/dist/assets/plugin-grid-QB7O_mff.js +0 -8
  108. package/dist/assets/plugin-kanban-C3U_tMs4.js +0 -1
  109. package/dist/assets/plugin-map-Lz3zZGqA.js +0 -1
  110. package/dist/assets/plugin-report-CMTOJSLw.js +0 -59
  111. package/dist/assets/plugin-timeline-CKcNCEwi.js +0 -1
  112. package/dist/assets/plugin-tree-BLG1qg4e.js +0 -1
  113. package/dist/assets/plugin-view-CwV64XEY.js +0 -1
  114. package/dist/assets/plugins-views-CoEgR96I.js +0 -4
  115. package/dist/assets/src-1qbKZhoo.js +0 -1
  116. package/dist/assets/src-DXuM24AK.js +0 -18
  117. package/dist/assets/ui-components-CHaxvtjc.js +0 -72
  118. package/dist/assets/ui-layout-BLgfeXIq.js +0 -1
  119. package/dist/assets/useOpenRecordList-C75NAaDm.js +0 -1
  120. package/dist/assets/vendor-objectstack-BTM1m7k5.js +0 -104
@@ -0,0 +1,4 @@
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{a as n,m as r,r as i,y as a}from"./vendor-react-BKSb6vFP.js";import{n as o,t as s}from"./infrastructure-CQFJ5N6p.js";import{B as c,Bt as l,E as u,H as d,J as f,Q as p,T as m,Y as h,Zt as g,at as _,b as v,c as y,d as b,en as x,et as S,h as C,i as w,j as T,ot as E,rt as D,w as O,x as ee,y as k}from"./framework-Oi7uo_kE.js";import{p as A}from"./vendor-objectstack-DxPvmbmF.js";import{$o as j,$t as M,A as N,Ar as P,Bi as F,C as te,Ca as I,Cc as ne,Ci as L,Cr as re,D as ie,Ec as ae,Er as oe,F as se,Fi as R,Fr as z,Gs as ce,Gt as le,H as ue,Hi as de,Ho as fe,Ht as B,Ia as V,Ic as pe,Ii as me,J as he,Ja as H,Jt as U,K as ge,Ka as _e,Ks as ve,Kt as ye,Lc as W,M as be,Mc as G,Mi as xe,N as K,Nr as Se,O as Ce,Or as q,P as we,Pc as Te,Pi as Ee,Qo as De,Rc as Oe,So as ke,Sr as Ae,Tc as je,Tr as Me,U as Ne,Ua as Pe,Uc as Fe,Ui as Ie,Ut as Le,Va as Re,Vi as ze,Vt as J,Ws as Y,Wt as X,Xt as Be,Ya as Ve,Zr as He,Zt as Ue,_ as We,_a as Ge,_c as Ke,_r as qe,_t as Je,as as Ye,at as Xe,bi as Ze,br as Qe,ca as $e,d as et,dn as tt,do as nt,ea as rt,ei as it,en as at,es as ot,fa as st,fn as ct,fr as lt,fs as ut,ga as dt,gc as ft,gr as pt,gt as mt,h as ht,hc as gt,hi as _t,ho as vt,hr as yt,hs as bt,ht as xt,ir as St,it as Ct,j as wt,jc as Tt,js as Et,k as Dt,kr as Ot,lr as kt,lt as At,mn as jt,mo as Mt,mr as Nt,n as Pt,nn as Ft,nr as It,oa as Lt,or as Rt,ot as zt,pn as Bt,po as Vt,pr as Ht,qa as Ut,qr as Wt,qs as Gt,qt as Kt,ra as qt,rc as Jt,rn as Yt,ro as Xt,rr as Zt,sr as Qt,tc as $t,tn as en,ts as tn,ua as nn,ur as rn,vi as an,vr as on,vt as sn,wc as cn,wi as ln,wo as un,wr as dn,xi as fn,xr as pn,yc as mn,yr as hn,zc as gn,zo as _n}from"./ui-components-BluZyuZX.js";import{s as vn}from"./plugin-grid-CnxMz-9O.js";var Z=e(a(),1),Q=i(),yn={grid:(0,Q.jsx)(un,{className:`h-4 w-4`}),kanban:(0,Q.jsx)(Xt,{className:`h-4 w-4`}),gallery:(0,Q.jsx)(Mt,{className:`h-4 w-4`}),calendar:(0,Q.jsx)(Jt,{className:`h-4 w-4`}),timeline:(0,Q.jsx)(Tt,{className:`h-4 w-4`}),gantt:(0,Q.jsx)(fn,{className:`h-4 w-4`}),map:(0,Q.jsx)(Re,{className:`h-4 w-4`}),chart:(0,Q.jsx)($t,{className:`h-4 w-4`}),tree:(0,Q.jsx)(Ve,{className:`h-4 w-4`})},bn={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`,chart:`Chart`,tree:`Tree`},xn=({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:G(`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":bn[t],title:bn[t],"data-state":n?`on`:`off`,onClick:()=>s(t),className:G(`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:[yn[t],(0,Q.jsx)(`span`,{className:`hidden sm:inline-block`,children:bn[t]})]},t)})}):(0,Q.jsxs)(tt,{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":bn[e],className:G(`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:[yn[e],(0,Q.jsx)(`span`,{className:`hidden sm:inline-block`,children:bn[e]}),(0,Q.jsx)(ce,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(ct,{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:G(`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:[yn[t],(0,Q.jsx)(`span`,{className:`flex-1 text-left`,children:bn[t]}),t===e&&(0,Q.jsx)(Gt,{className:`h-3.5 w-3.5`})]},t))})]})};function Sn({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)(ce,{className:G(`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 Cn(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,showInlineEdit:m,inlineEdit:h,setInlineEdit:g}=e,[_,v]=Z.useState(!1),y=[!!i?.fields?.length,!!s?.field,u&&u.mode!==`compact`,(f?.size??0)>0,!!h].filter(Boolean).length,b=u?.mode===`compact`?F:u?.mode===`comfortable`?ze:de,x=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,Q.jsxs)(tt,{open:_,onOpenChange:v,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,"aria-label":x,title:x,className:G(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,y>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,Q.jsx)(Ee,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x}),y>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:y})]})}),(0,Q.jsxs)(ct,{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:x}),(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)(Sn,{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)(ge,{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)(Sn,{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)(Sn,{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)(q,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:u.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,Q.jsx)(b,{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`})})]})}),m&&g&&(0,Q.jsx)(Sn,{title:t(`list.recordEditingTitle`,{defaultValue:`Record editing`}),defaultOpen:!!h,children:(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:!!h,onChange:()=>g(!h),className:`rounded border-input`,"data-testid":`view-settings-inline-edit`}),(0,Q.jsx)(`span`,{children:t(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`})})]})}),d&&f&&p&&(0,Q.jsx)(Sn,{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 wn(){try{let{t:e}=Fe(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}catch{return`More`}}var Tn=new Set([`lookup`,`master_detail`,`user`,`owner`]);function En(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 Dn(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,En(e.operator),e.value]):[],default:e.default??e.isDefault}))}function On({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)(An,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s});case`tabs`:return(0,Q.jsx)(jn,{tabs:Dn(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 kn(e,t,n,r){return e.map(e=>{let i=e.options?[...e.options]:[],a=e.type,o,s,c,l;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,l=n.label,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 u=e.label??l;if(r?.objectName){i=r.translateOptions(r.objectName,e.field,i);let t=e.label||l,n=r.fieldLabel(r.objectName,e.field,t||e.field);u=n===e.field&&t?t:n}return{...e,label:u,type:a,options:i,referenceTo:o,displayField:s,idField:c}})}function An({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){let{fieldLabel:c,translateOptions:l}=gn(),u=wn(),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(()=>kn(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=Tn.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)(tt,{children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:G(`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)(z,{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)(ce,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(ct,{align:`start`,className:G(i,`p-2`),children:r?(0,Q.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,Q.jsx)(zt,{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:G(`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:G(`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)(tt,{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)(ce,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(ct,{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 jn({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:G(`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:G(`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)(qt,{className:`h-3.5 w-3.5`})})]})}function Mn(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 Nn(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)?Nn(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 Pn(e){let t=typeof e==`string`?[e]:Array.isArray(e)?e:[],n=[];for(let e of t)if(typeof e==`string`){let t=e.trim().split(/\s+/);if(!t[0])continue;n.push({id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`})}else e&&typeof e==`object`&&typeof e.field==`string`&&n.push({id:crypto.randomUUID(),field:e.field,order:e.order||`asc`});return n}function Fn(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function In(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?Nn(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function Ln(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=In(e.conditions.filter(e=>{if(e.operator===`isEmpty`||e.operator===`isNotEmpty`)return!0;let t=e.value;return!(t==null||t===``||Array.isArray(t)&&t.length===0)}).map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,Mn(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var Rn={"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.refresh":`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.`},zn=(e,t)=>{let n=Rn[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n};function Bn(){try{let e=Fe();return e.t(`list.recordCount`)===`list.recordCount`?{t:zn}:{t:e.t}}catch{return{t:zn}}}function Vn(){let{fieldLabel:e,actionLabel:t,objectLabel:n}=Oe();return{fieldLabel:e,actionLabel:t,objectLabel:n}}var Hn=Z.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onHiddenFieldsChange:s,onInlineEditChange:u,onColumnStateChange:f,onRowClick:p,showViewSwitcher:m,userFilterSelections:h,onUserFilterSelectionsChange:_,initialFilters:v,initialSearchTerm:y,...x},S)=>{let C=m??e?.showViewSwitcher??!1,{t:w}=Bn(),{fieldLabel:T,actionLabel:E,objectLabel:O}=Vn(),{translateOptions:ee}=gn(),k=Z.useMemo(()=>e.viewType&&e.viewType!==`list`?e:{...e,viewType:`grid`},[e]),A=Z.useCallback((e,t)=>k.objectName?T(k.objectName,e,t):t,[k.objectName,T]),j=Z.useCallback(e=>{let t=Fn(e);return k.objectName&&typeof E==`function`?E(k.objectName,e,t):t},[k.objectName,E]),M=Z.useMemo(()=>{let e=k.userActions,t=k.addRecord?.enabled===!0&&e?.addRecordForm!==!1,n=e?.refresh;return{showSearch:e?.search===void 0?k.showSearch!==!1:e.search,showSort:e?.sort===void 0?k.showSort!==!1:e.sort,showFilters:e?.filter===void 0?k.showFilters!==!1:e.filter,showRefresh:n===void 0||n,showDensity:e?.rowHeight===void 0?k.showDensity!==!1:e.rowHeight,showHideFields:k.showHideFields===!0,showGroup:k.showGroup!==!1,showColor:k.showColor===!0,compactToolbar:k.compactToolbar===!0,showAddRecord:t,addRecordPosition:k.addRecord?.position===`bottom`?`bottom`:`top`}},[k.userActions,k.showSearch,k.showSort,k.showFilters,k.showDensity,k.showHideFields,k.showGroup,k.showColor,k.compactToolbar,k.addRecord,k.userActions?.addRecordForm]),[N,te]=Z.useState(k.viewType),[L,re]=Z.useState(()=>y??``),[ie,ae]=Z.useState(!1),[oe,se]=Z.useState(!1),[R,ce]=Z.useState(()=>Pn(k.sort)),le=Z.useMemo(()=>JSON.stringify(k.sort||[]),[k.sort]);Z.useEffect(()=>{ce(Pn(k.sort))},[le]);let[fe,B]=Z.useState(!1),[V,pe]=Z.useState(()=>v&&Array.isArray(v.conditions)?v:{id:`root`,logic:`and`,conditions:[]}),H=x.dataSource,[U,_e]=Z.useState([]),[ve,ye]=Z.useState(null),[W,be]=Z.useState(()=>!(Array.isArray(k.data)||k.data&&typeof k.data==`object`&&k.data.provider===`value`&&Array.isArray(k.data.items)||k.viewType===`gantt`&&k.data&&typeof k.data==`object`&&!Array.isArray(k.data)&&k.data.provider===`api`)),[K,Se]=Z.useState(null),[Ce,we]=Z.useState(!1),[Te,Ee]=Z.useState(0),[De,Oe]=Z.useState(!1);Z.useImperativeHandle(S,()=>({refresh:()=>Ee(e=>e+1)}),[]),Z.useEffect(()=>{if(!(!H?.onMutation||!k.objectName))return H.onMutation(e=>{e.resource===k.objectName&&Ee(e=>e+1)})},[H,k.objectName]);let[Ae,je]=Z.useState(void 0),Me=Ae??k.pagination?.pageSize??100,[Pe,Fe]=Z.useState(1),[Le,Re]=Z.useState(null),J=Z.useMemo(()=>{if(k.grouping?.fields?.length)return k.grouping;let e=typeof k.groupBy==`string`?k.groupBy.trim():``,t=typeof k.groupBy2==`string`?k.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},[k.grouping,k.groupBy,k.groupBy2]),[Y,X]=Z.useState(J),[Be,Ve]=Z.useState(!1),Ue=Z.useRef(J);Z.useEffect(()=>{Ue.current!==J&&(Ue.current=J,X(J))},[J]);let[We,Ge]=Z.useState(k.rowColor),[Ke,qe]=Z.useState(!1),[Je,Qe]=Z.useState([]),$e=Z.useRef(0),[et,nt]=Z.useState([]),at=Z.useMemo(()=>{let e=k.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:A(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[k.userFilters,K,A]),[st,lt]=Z.useState(()=>new Set(k.hiddenFields||[])),ut=Z.useMemo(()=>JSON.stringify(k.hiddenFields||[]),[k.hiddenFields]);Z.useEffect(()=>{lt(new Set(k.hiddenFields||[]))},[ut]);let dt=Z.useCallback(e=>{lt(e),s?.(Array.from(e))},[s]),[ft,pt]=Z.useState(!1),[mt,ht]=Z.useState(()=>!!k.inlineEdit);Z.useEffect(()=>{ht(!!k.inlineEdit)},[k.inlineEdit]);let gt=Z.useCallback(e=>{ht(e),u?.(e)},[u]),[_t,vt]=Z.useState(!1),[yt,bt]=Z.useState(!1),[xt,St]=Z.useState(null),wt=k.allowExport!==!1&&k.operations?.export!==!1,Tt=Z.useMemo(()=>{if(k.exportOptions)return Array.isArray(k.exportOptions)?{formats:k.exportOptions}:k.exportOptions},[k.exportOptions]),Et=b(Z.useMemo(()=>k.densityMode?k.densityMode:k.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[k.rowHeight]||`comfortable`:`compact`,[k.densityMode,k.rowHeight]),{onChange:k.onDensityChange}),Dt=Z.useMemo(()=>`objectui:gallery:density:${k.objectName??`default`}`,[k.objectName]),[Ot,kt]=Z.useState(()=>{if(typeof window>`u`)return k.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(Dt);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return k.gallery?.cardSize??`medium`}),At=Z.useCallback(()=>{kt(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(Dt,t)}catch{}return t})},[Dt]),{ref:Mt,isRefreshing:Nt,pullDistance:Pt}=vn({onRefresh:Z.useCallback(async()=>{Ee(e=>e+1)},[]),enabled:!!H&&!!k.objectName}),Ft=Z.useMemo(()=>k.id?`listview-${k.objectName}-${k.id}-view`:`listview-${k.objectName}-view`,[k.objectName,k.id]);Z.useEffect(()=>{let e=!0;return we(!1),Se(null),(async()=>{if(!H||!k.objectName){we(!0);return}if(typeof H.getObjectSchema!=`function`){we(!0);return}try{let t=await H.getObjectSchema(k.objectName);e&&Se(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&we(!0)}})(),()=>{e=!1}},[k.objectName,H]);let It=Z.useMemo(()=>{let e=Array.isArray(k.fields)?k.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(k.kanban),n(k.options?.kanban),n(k.calendar),n(k.options?.calendar),n(k.gallery),n(k.options?.gallery),n(k.timeline),n(k.options?.timeline),n(k.gantt),n(k.options?.gantt);let r=t.size>0?Array.from(t):void 0;return g(K?.fields,r)},[K?.fields,k.fields,k.kanban,k.calendar,k.gallery,k.timeline,k.gantt,k.options]),Lt=o(),Rt=N===`gantt`&&!!k.data&&typeof k.data==`object`&&!Array.isArray(k.data)&&k.data.provider===`api`;Z.useEffect(()=>{let e=!0,t=++$e.current;if(k.data&&typeof k.data==`object`&&!Array.isArray(k.data)){let e=k.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(L){let e=L.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}_e(t),be(!1),Oe(!1);return}}if(Array.isArray(k.data)){let e=k.data;if(L){let t=L.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}_e(e),be(!1),Oe(!1);return}if(Rt){be(!1),Oe(!1);return}return Ce?((async()=>{if(!H||!k.objectName){be(!1);return}be(!0),ye(null);try{let n=[],r=k.filters||[],i=Ln(V),a=In(et),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=R.length>0?R.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,c=(()=>{let e=Array.isArray(k.fields)?k.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=Lt?.isLoaded&&k.objectName?e.filter(e=>Lt.checkField(k.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 It)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(k.kanban),a(k.options?.kanban),a(k.calendar),a(k.options?.calendar),a(k.gallery),a(k.options?.gallery),a(k.timeline),a(k.options?.timeline);{let e=k.timeline??k.options?.timeline;e&&!Array.isArray(e.metaFields)&&(i(`status`),i(`priority`))}return a(k.gantt),a(k.options?.gantt),Array.from(n)})(),l=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,u=N===`grid`&&!Y?.fields?.length,d=u?(Pe-1)*Me:0,f=await H.find(k.objectName,{...l?{$filter:n}:{},$orderby:s,$top:Me,...d>0?{$skip:d}:{},...c?{$select:c}:{},...It.length>0?{$expand:It}:{},...L?{$search:L,...k.searchableFields&&k.searchableFields.length>0?{$searchFields:k.searchableFields}:{}}:{}});if(!e||t!==$e.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)),_e(p);let m=f&&typeof f==`object`?f.total??f.count:void 0,h=typeof m==`number`?m:null;Re(u?h:null),Oe(!(u&&h!=null)&&p.length>=Me)}catch(e){t===$e.current&&(console.error(`ListView data fetch error:`,e),_e([]),ye(e?.message?String(e.message):String(e??`Unknown error`)))}finally{e&&t===$e.current&&be(!1)}})(),()=>{e=!1}):void 0},[k.objectName,k.data,H,k.filters,Me,R,V,et,Te,L,k.searchableFields,It,Ce,k.refreshTrigger,Lt,Pe,N,Y,Rt]);let zt=JSON.stringify([k.objectName,k.filters,Me,R,V,et,L,N,Y]),Ht=Z.useRef(zt);Z.useEffect(()=>{Ht.current!==zt&&(Ht.current=zt,Fe(1))},[zt]);let Wt=Z.useMemo(()=>{let e=[`grid`];(k.kanban?.groupByField||k.kanban?.groupField||k.options?.kanban?.groupField)&&e.push(`kanban`),(k.gallery?.coverField||k.gallery?.imageField||k.options?.gallery?.imageField)&&e.push(`gallery`),(k.calendar?.startDateField||k.options?.calendar?.startDateField)&&e.push(`calendar`),(k.timeline?.startDateField||k.options?.timeline?.startDateField||k.options?.timeline?.dateField||k.options?.calendar?.startDateField)&&e.push(`timeline`),(k.gantt?.startDateField||k.options?.gantt?.startDateField)&&e.push(`gantt`),(k.options?.map?.locationField||k.options?.map?.latitudeField&&k.options?.map?.longitudeField)&&e.push(`map`),(k.tree?.parentField||k.options?.tree?.parentField||k.viewType===`tree`)&&e.push(`tree`),k.viewType&&!e.includes(k.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`,`tree`].includes(k.viewType)&&e.push(k.viewType);let t=k.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},[k.options,k.viewType,k.kanban,k.calendar,k.gantt,k.gallery,k.timeline,k.tree,k.appearance?.allowedVisualizations]);Z.useEffect(()=>{k.viewType&&te(k.viewType)},[k.viewType]);let Gt=Z.useCallback(e=>{te(e);try{localStorage.setItem(Ft,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[Ft,n]),Kt=Z.useCallback(e=>{re(e),a?.(e)},[a]),Jt=c({navigation:k.navigation,objectName:k.objectName,onNavigate:k.onNavigate,onRowClick:p}),Yt=Z.useMemo(()=>{let e=k.fields||[];if(Array.isArray(e)||(e=[]),Lt?.isLoaded&&k.objectName&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return!t||Lt.checkField(k.objectName,t,`read`)})),st.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!st.has(t)})),k.fieldOrder&&k.fieldOrder.length>0){let t=new Map(k.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},[k.fields,k.objectName,st,k.fieldOrder,Lt]),Xt=Z.useMemo(()=>{let e=Et.mode===`compact`?`compact`:Et.mode===`spacious`?`tall`:`medium`,t={objectName:k.objectName,fields:Yt,filters:k.filters,sort:R,className:`h-full w-full`,showSearch:!1,onRowClick:Jt.handleClick,rowHeight:e,hideRowHeightToggle:!0,...k.striped==null?{}:{striped:k.striped},...k.bordered==null?{}:{bordered:k.bordered},...f?{onColumnStateChange:f}:{},...k.columnState?{columnState:k.columnState}:{}};switch(N){default:case`grid`:return{type:`object-grid`,...t,columns:Yt,...k.conditionalFormatting?{conditionalFormatting:k.conditionalFormatting}:{},editable:mt,...k.wrapHeaders==null?{}:{wrapHeaders:k.wrapHeaders},...k.virtualScroll==null?{}:{virtualScroll:k.virtualScroll},...k.resizable==null?{}:{resizable:k.resizable},...k.selection?{selection:k.selection}:{},...k.pagination?{pagination:k.pagination}:{},...Y?{grouping:Y}:{},...We?{rowColor:We}:{},...k.rowActions?{rowActions:k.rowActions}:{},...k.rowActionDefs?{rowActionDefs:k.rowActionDefs}:{},...k.bulkActions?{batchActions:k.bulkActions}:{},...k.bulkActionDefs?{bulkActionDefs:k.bulkActionDefs}:{},...k.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...t,groupBy:k.kanban?.groupField||k.options?.kanban?.groupField||l(K)||void 0,groupField:k.kanban?.groupField||k.options?.kanban?.groupField||l(K)||void 0,...k.kanban?.titleField||k.options?.kanban?.titleField?{titleField:k.kanban?.titleField||k.options?.kanban?.titleField}:{},cardFields:k.kanban?.cardFields||Yt||[],...Y?{grouping:Y}:{},...k.options?.kanban||{},...k.kanban||{}};case`calendar`:return{type:`object-calendar`,...t,startDateField:k.calendar?.startDateField||k.options?.calendar?.startDateField||`start_date`,endDateField:k.calendar?.endDateField||k.options?.calendar?.endDateField||`end_date`,...k.calendar?.titleField||k.options?.calendar?.titleField?{titleField:k.calendar?.titleField||k.options?.calendar?.titleField}:{},...k.calendar?.defaultView?{defaultView:k.calendar.defaultView}:{},...k.options?.calendar||{},...k.calendar||{}};case`gallery`:{let e={...k.options?.gallery||{},...k.gallery||{},cardSize:Ot};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:k.gallery?.coverField||k.gallery?.imageField||k.options?.gallery?.imageField,titleField:k.gallery?.titleField||k.options?.gallery?.titleField||`name`,subtitleField:k.gallery?.subtitleField||k.options?.gallery?.subtitleField,...Y?{grouping:Y}:{}}}case`timeline`:{let e={...k.options?.timeline||{},...k.timeline||{}};return{type:`object-timeline`,...t,timeline:Object.keys(e).length>0?e:void 0,startDateField:k.timeline?.startDateField||k.options?.timeline?.startDateField||k.options?.timeline?.dateField||`created_at`,titleField:k.timeline?.titleField||k.options?.timeline?.titleField||`name`,...k.timeline?.endDateField?{endDateField:k.timeline.endDateField}:{},...k.timeline?.groupByField?{groupByField:k.timeline.groupByField}:{},...k.timeline?.colorField?{colorField:k.timeline.colorField}:{},...k.timeline?.scale?{scale:k.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,...k.data?{data:k.data}:{},startDateField:k.gantt?.startDateField||k.options?.gantt?.startDateField||`start_date`,endDateField:k.gantt?.endDateField||k.options?.gantt?.endDateField||`end_date`,progressField:k.gantt?.progressField||k.options?.gantt?.progressField||`progress`,dependenciesField:k.gantt?.dependenciesField||k.options?.gantt?.dependenciesField||`dependencies`,...k.gantt?.titleField?{titleField:k.gantt.titleField}:{},...k.options?.gantt||{},...k.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:k.options?.map?.locationField||`location`,...k.options?.map||{}};case`tree`:{let e=k.tree||k.options?.tree||{};return{type:`object-tree`,...t,parentField:e.parentField,labelField:e.labelField||e.titleField||`name`,fields:e.fields||Yt,defaultExpandedDepth:e.defaultExpandedDepth,...e}}case`chart`:{let e=k.chart||k.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:k.objectName,chartType:e.chartType||`bar`,filters:k.filters,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[N,k,R,Yt,Y,We,Jt.handleClick,Et.mode,Ot,mt,K]),Zt=V.conditions&&V.conditions.length>0,Qt=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 k.objectName?ee(k.objectName,e,n):n};if(e=K?.fields?Object.entries(K.fields).map(([e,n])=>({value:e,label:A(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})):(k.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let n=e.name||e.fieldName;return{value:n,label:A(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}}),k.filterableFields&&k.filterableFields.length>0){let t=new Set(k.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[K,k.fields,k.filterableFields,k.objectName,A,ee]),$t=Z.useCallback(e=>{if(!wt)return;let t=Tt,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=K?.label&&K?.name&&typeof O==`function`?O(K):K?.label,a=e=>D(e,{prefix:t?.fileNamePrefix,label:i,objectName:k.objectName,viewLabel:k.label||k.title});if((e===`csv`||e===`xlsx`||e===`json`)&&typeof H?.exportDownload==`function`&&k.objectName&&t?.streaming!==!1){let t=Yt.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field).filter(Boolean),i=k.filters||[],o=Ln(V),s=In(et),c=[...i.length>0?[i]:[],...o.length>0?[o]:[],...s].filter(e=>Array.isArray(e)&&e.length>0),l=c.length>1?[`and`,...c]:c.length===1?c[0]:void 0,u=R.length>0?R.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})):void 0;St(null),bt(!0),(async()=>{try{let i=await H.exportDownload(k.objectName,{format:e,fields:t.length?t:void 0,filter:l,sort:u,includeHeaders:r,limit:n>0?n:void 0}),o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a(e),s.rel=`noopener`,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o),vt(!1)}catch(e){console.error(`ListView export failed:`,e),St(e instanceof Error?e.message:String(e))}finally{bt(!1)}})();return}let o=n>0?U.slice(0,n):U;if(e===`csv`){let e=Yt.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];r&&t.push(e.join(`,`)),o.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;`}),i=URL.createObjectURL(n),s=document.createElement(`a`);s.href=i,s.download=a(`csv`),s.click(),URL.revokeObjectURL(i)}else if(e===`json`){let e=new Blob([JSON.stringify(o,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=a(`json`),n.click(),URL.revokeObjectURL(t)}vt(!1)},[U,Yt,Tt,k.objectName,k.filters,wt,H,V,et,R,K,O]),en=Z.useMemo(()=>(k.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:A(e,e)};let t=e.name||e.fieldName||e.field,n=e.label||e.name||e.field;return{name:t,label:A(t,n)}}),[k.fields,A]);return(0,Q.jsxs)(`div`,{ref:Mt,className:G(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,t),...k.aria?.label?{"aria-label":k.aria.label}:{},...k.aria?.describedBy?{"aria-describedby":k.aria.describedBy}:{},...k.aria?.live?{"aria-live":k.aria.live}:{},role:`region`,"aria-busy":W||void 0,"data-state":W?`loading`:`idle`,children:[Pt>0&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Pt},children:w(Nt?`list.refreshing`:`list.pullToRefresh`)}),k.description&&k.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 k.description==`string`?k.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:at&&(0,Q.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,Q.jsx)(On,{config:at,objectDef:K,data:U,onFilterChange:nt,maxVisible:3,initialSelections:h,onSelectionsChange:_})})}),(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:[C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xn,{currentView:N,availableViews:Wt,onViewChange:Gt}),(0,Q.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),N===`grid`&&u&&!M.compactToolbar&&(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>gt(!mt),className:G(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,mt&&`text-primary`),title:w(`list.inlineEditLabel`,{defaultValue:`Edit records inline (click a cell to edit)`}),"data-testid":`toolbar-inline-edit-toggle`,children:[(0,Q.jsx)(nn,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.inlineEditShort`,{defaultValue:`Edit inline`})})]}),M.showHideFields&&!M.compactToolbar&&(0,Q.jsxs)(tt,{open:ft,onOpenChange:pt,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:G(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,st.size>0&&`text-primary`),children:[(0,Q.jsx)(ot,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.hideFields`)}),st.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:st.size})]})}),(0,Q.jsx)(ct,{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:w(`list.hideFieldsTitle`)}),st.size>0&&(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>dt(new Set),children:w(`list.showAll`)})]}),(0,Q.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:en.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:!st.has(e.name),onChange:()=>{let t=new Set(st);t.has(e.name)?t.delete(e.name):t.add(e.name),dt(t)},className:`rounded border-input`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),M.showHideFields&&!M.compactToolbar&&(M.showFilters||M.showSort||M.showGroup)&&(0,Q.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),M.showFilters&&(0,Q.jsxs)(tt,{open:fe,onOpenChange:B,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:G(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Zt&&`text-foreground font-medium`),children:[(0,Q.jsx)(ln,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.filter`)}),Zt&&(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:V.conditions?.length||0})]})}),(0,Q.jsx)(ct,{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:w(`list.filterRecords`)})}),(0,Q.jsx)(Xe,{fields:Qt,value:V,onChange:e=>{pe(e),r&&r(e)}})]})})]}),M.showGroup&&!M.compactToolbar&&(0,Q.jsxs)(tt,{open:Be,onOpenChange:Ve,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:G(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Y&&`text-foreground font-medium`),children:[(0,Q.jsx)(ke,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.group`)}),Y&&Y.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:Y.fields.length})]})}),(0,Q.jsx)(ct,{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:w(`list.groupBy`)}),Y&&(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>X(void 0),"data-testid":`clear-grouping`,children:w(`list.clear`)})]}),(0,Q.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,Q.jsx)(ge,{value:Y,fieldOptions:en.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:w(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:w(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:w(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>X(e)})})]})})]}),M.showSort&&(0,Q.jsxs)(tt,{open:oe,onOpenChange:se,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:G(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,R.length>0&&`text-foreground font-medium`),children:[(0,Q.jsx)(ne,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.sort`)}),R.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:R.length})]})}),(0,Q.jsx)(ct,{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:w(`list.sortRecords`)})}),(0,Q.jsx)(Ct,{fields:Qt,value:R,onChange:e=>{ce(e),i&&i(e)}})]})})]}),!M.compactToolbar&&(M.showFilters||M.showSort||M.showGroup)&&(M.showColor||M.showDensity)&&(0,Q.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),M.showColor&&!M.compactToolbar&&(0,Q.jsxs)(tt,{open:Ke,onOpenChange:qe,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:G(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,We&&`text-foreground font-medium`),children:[(0,Q.jsx)(I,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.color`)})]})}),(0,Q.jsx)(ct,{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:w(`list.rowColor`)}),We&&(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ge(void 0),"data-testid":`clear-row-color`,children:w(`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:w(`list.colorByField`)}),(0,Q.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:We?.field||``,onChange:e=>{let t=e.target.value;Ge(t?{field:t,colors:We?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,Q.jsx)(`option`,{value:``,children:w(`list.none`)}),en.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),M.showDensity&&!M.compactToolbar&&N!==`gallery`&&(()=>{let e=Et.mode===`compact`?F:Et.mode===`comfortable`?ze:de,t=Et.mode===`compact`?w(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Et.mode===`comfortable`?w(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):w(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${w(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=w(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,"aria-label":n,className:G(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,Et.mode!==`compact`&&`text-foreground font-medium`),onClick:Et.cycle,title:r,children:(0,Q.jsx)(e,{className:`h-3.5 w-3.5`})})})(),M.showDensity&&!M.compactToolbar&&N===`gallery`&&(()=>{let e=Ot===`small`?F:Ot===`medium`?ze:de,t=Ot===`small`?w(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):Ot===`medium`?w(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):w(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${w(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=w(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,"aria-label":n,className:G(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,Ot!==`small`&&`text-foreground font-medium`),onClick:At,title:r,children:(0,Q.jsx)(e,{className:`h-3.5 w-3.5`})})})(),M.compactToolbar&&(M.showGroup||M.showColor||M.showDensity||M.showHideFields)&&(0,Q.jsx)(Cn,{t:w,allFields:en,showGroup:M.showGroup,groupingConfig:Y,setGroupingConfig:X,showColor:M.showColor,rowColorConfig:We,setRowColorConfig:Ge,showDensity:M.showDensity,density:Et,showHideFields:M.showHideFields,hiddenFields:st,updateHiddenFields:dt,showInlineEdit:N===`grid`,inlineEdit:mt,setInlineEdit:gt}),(M.showColor||M.showDensity||M.compactToolbar)&&Tt&&wt&&(0,Q.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),M.showRefresh&&(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,onClick:()=>Ee(e=>e+1),disabled:W,title:w(`list.refresh`),"aria-label":w(`list.refresh`),"data-testid":`refresh-button`,children:(0,Q.jsx)(Ie,{className:G(`h-3.5 w-3.5`,W&&`animate-spin`)})}),Tt&&wt&&(0,Q.jsxs)(tt,{open:_t,onOpenChange:vt,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(q,{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)(Ye,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.export`)})]})}),(0,Q.jsx)(ct,{align:`start`,className:`w-48 p-2`,children:(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(Tt.formats||[`csv`,`json`]).map(e=>(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,disabled:yt,onClick:()=>$t(e),children:[yt?(0,Q.jsx)(Ut,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5 mr-2`}),w(`list.exportAs`,{format:e.toUpperCase()})]},e)),xt&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-xs`,style:{color:`var(--destructive, #ef4444)`},role:`alert`,children:xt})]})})]}),(k.sharing?.enabled||k.sharing?.type)&&(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${k.sharing?.visibility||k.sharing?.type||`private`}`,"data-testid":`share-button`,children:[(0,Q.jsx)(xe,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.share`)})]}),k.allowPrinting&&(0,Q.jsxs)(q,{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)(rt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.print`)})]}),(()=>{let e=k.allowPrinting||k.sharing?.enabled||k.sharing?.type||Tt&&wt;return M.showSearch&&e?(0,Q.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),M.showSearch&&(0,Q.jsxs)(tt,{open:ie,onOpenChange:ae,children:[(0,Q.jsx)(Bt,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:G(`hidden sm:inline-flex h-7 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,L?`px-2 text-foreground font-medium`:`w-7 p-0`),"data-testid":`search-icon-button`,title:L?`${w(`list.search`)}: ${L}`:w(`list.search`),children:[(0,Q.jsx)(me,{className:`h-3.5 w-3.5`}),L&&(0,Q.jsx)(`span`,{className:`ml-1.5 max-w-[8rem] truncate text-[11px]`,"data-testid":`search-active-keyword`,children:L})]})}),(0,Q.jsx)(ct,{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)(me,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Q.jsx)(jt,{placeholder:w(`list.search`)+`...`,value:L,onChange:e=>Kt(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),L&&(0,Q.jsx)(q,{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:()=>Kt(``),children:(0,Q.jsx)(z,{className:`h-3 w-3`})})]})})]}),M.showAddRecord&&M.addRecordPosition===`top`&&(0,Q.jsxs)(q,{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:()=>x.onAddRecord?.(),children:[(0,Q.jsx)(qt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`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)(Ne,{active:W&&U.length>0}),ve&&U.length===0?(0,Q.jsx)(ue,{"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)(He,{className:`h-12 w-12 text-destructive/60`}),iconWrapperClassName:`mb-3`,title:w(`list.loadErrorTitle`),description:w(`list.loadErrorMessage`),action:(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,"data-testid":`list-error-retry`,onClick:()=>Ee(e=>e+1),children:[(0,Q.jsx)(Ie,{className:`h-4 w-4 mr-1.5`}),w(`list.retry`)]})}):W&&U.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:w(`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))]}):!W&&U.length===0&&N===`grid`?(()=>{let e=k.emptyState?.icon,t=e?P[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??Vt:Vt,n=!!(L&&L.trim())||Array.isArray(et)&&et.length>0||Array.isArray(V?.conditions)&&V.conditions.length>0,r=(typeof k.emptyState?.title==`string`?k.emptyState.title:void 0)??w(n?`list.noMatches`:`list.firstRunTitle`),i=(typeof k.emptyState?.message==`string`?k.emptyState.message:void 0)??w(n?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,Q.jsx)(ue,{"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:M.showAddRecord?(0,Q.jsxs)(q,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>x.onAddRecord?.(),children:[(0,Q.jsx)(qt,{className:`h-4 w-4 mr-1.5`}),w(`list.addRecord`)]}):void 0})})():(0,Q.jsx)(d,{schema:Xt,...x,...Rt?{}:{data:U},loading:W,onRowSelect:Qe,...N===`grid`&&!Y?.fields?.length&&Le!=null?{manualPagination:!0,rowCount:Le,page:Pe,pageSize:Me,onPageChange:e=>Fe(e),onPageSizeChange:e=>{je(e),Fe(1)}}:{}})]},N),M.showAddRecord&&M.addRecordPosition===`bottom`&&(0,Q.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,Q.jsxs)(q,{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:()=>x.onAddRecord?.(),children:[(0,Q.jsx)(qt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:w(`list.addRecord`)})]})}),k.bulkActions&&k.bulkActions.length>0&&Je.length>0&&N!==`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)(Ze,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[Je.length,` `,Je.length===1?`item`:`items`,` selected`]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:k.bulkActions.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),r=n?it:null;return(0,Q.jsxs)(q,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>x.onBulkAction?.(e,Je),"data-testid":`bulk-action-${e}`,children:[r&&(0,Q.jsx)(r,{className:`h-3 w-3`}),j(e)]},e)})}),(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>Qe([]),children:[(0,Q.jsx)(z,{className:`h-3 w-3`}),`Clear`]})]}),!W&&U.length>0&&k.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:U.length===1?w(`list.recordCountOne`,{count:U.length}):w(`list.recordCount`,{count:U.length})}),De&&(0,Q.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:w(`list.dataLimitReached`,{limit:Me})}),N!==`grid`&&k.pagination?.pageSizeOptions&&k.pagination.pageSizeOptions.length>0&&(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:w(`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(Me),onChange:e=>{let t=Number(e.target.value);je(t),x.onPageSizeChange&&x.onPageSizeChange(t)},children:k.pagination.pageSizeOptions.map(e=>(0,Q.jsx)(`option`,{value:String(e),children:e},e))})]})]}),Jt.isOverlay&&(0,Q.jsx)(he,{...Jt,title:k.label?`${k.label} Detail`:k.objectName?`${k.objectName.charAt(0).toUpperCase()+k.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))})})]})});Hn.displayName=`ListView`;var Un={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`},Wn={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},Gn=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),Kn=[{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 qn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return Kn[Math.abs(t)%Kn.length]}var Jn=({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:G(`w-full overflow-hidden relative`,r),hidden:a,children:c?n===`contain`?(0,Q.jsx)(`div`,{className:G(`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:G(`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:G(`text-5xl font-semibold tracking-tight opacity-90`,i.text),children:t[0]?.toUpperCase()})})})},Yn=({imageUrl:e,title:t,placeholder:n})=>{let[r,i]=(0,Z.useState)(!1),a=!!e&&!r;return(0,Q.jsx)(`div`,{className:G(`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:G(`text-base font-semibold`,n.text),children:t[0]?.toUpperCase()})})};x.register(`object-gallery`,e=>{let{schema:t}=e,n=(0,Z.useContext)(p),r=e.dataSource||n?.dataSource,i=S(t.bind),[a,o]=(0,Z.useState)([]),[s,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),f=c({navigation:t.navigation,objectName:t.objectName,onRowClick:e.onRowClick??e.onCardClick}),m=t.gallery,h=m?.coverField??t.imageField??`image`,_=m?.coverFit??`cover`,v=m?.cardSize??`medium`,y=m?.titleField??t.titleField,b=m?.visibleFields,{fieldLabel:x,fieldOptionLabel:C}=gn(),w=(0,Z.useCallback)(e=>{let n=u?.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=x(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},[u,t.objectName,x,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&&d(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&&l(!0);try{let e=g(u?.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&&l(!1)}}})(),()=>{n=!1}},[t.objectName,r,i,t.data,t.filter,e.data,u]);let T=e.data||i||t.data||a||[],D=(0,Z.useMemo)(()=>T.some(e=>typeof e[h]==`string`&&!!e[h]),[T,h]),O=t.grouping?.fields,ee=!!(O&&O.length>0),[k,A]=(0,Z.useState)({}),j=(0,Z.useMemo)(()=>O?O.some(e=>e.collapsed):!1,[O]),M=(0,Z.useCallback)(e=>{A(t=>({...t,[e]:t[e]===void 0?!j:!t[e]}))},[j]),N=(0,Z.useMemo)(()=>{if(!ee||!O)return[];let e=new Map,t=[];for(let n of T){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 k?k[t]:j;return{key:t,label:n.label,items:n.items,collapsed:r}})},[T,O,ee,k,j]);if(s&&!T.length)return(0,Q.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!T.length)return(0,Q.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let P=e=>!b||b.length===0?null:(0,Q.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:b.map(t=>{let n=e[t];if(n==null||n===``)return null;let r=w(t),i=We(r)||r.type||`text`,a=et(i),o=r?.label&&String(r.label).trim()?String(r.label):void 0,s=o!=null&&Gn.has(i);return(0,Q.jsxs)(`div`,{className:G(`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)??E(u,n),o=n[h],s=qn(String(i)+`|`+a),c=G(`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&&_===`contain`?(0,Q.jsxs)(Rt,{role:`listitem`,className:c,onClick:e=>f.handleClick(n,e),children:[(0,Q.jsx)(`div`,{"aria-hidden":!0,className:G(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,Q.jsx)(Qt,{className:`p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Yn,{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)(Rt,{role:`listitem`,className:c,onClick:e=>f.handleClick(n,e),children:[!D&&(0,Q.jsx)(`div`,{"aria-hidden":!0,className:G(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,Q.jsx)(Jn,{imageUrl:o,title:a,coverFit:_,aspectClass:Wn[v],placeholder:s,hidden:!D}),(0,Q.jsxs)(Qt,{className:G(`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:G(`grid gap-4 p-4 auto-rows-min content-start`,Un[v],t.className),role:`list`,children:e.map((e,t)=>F(e,t))});return(0,Q.jsxs)(Q.Fragment,{children:[ee?(0,Q.jsx)(`div`,{className:`space-y-2`,children:N.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:()=>M(e.key),children:[e.collapsed?(0,Q.jsx)(Y,{className:`h-4 w-4 shrink-0`}):(0,Q.jsx)(ce,{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(T),f.isOverlay&&(0,Q.jsx)(he,{...f,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`}),x.register(`list-view`,Hn,{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:{}}}),x.register(`list`,Hn,{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 Xn=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function Zn(e){return Xn.has(e)}function Qn(e,t){let n;return n=e<=3?1:e<=8?2:e<=15?3:4,t!==void 0&&t<640?Math.min(n,1):n}function $n(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&Zn(e.type)?{...e,span:t}:e)}function er(e,t,n){if(t!==void 0)return{fields:$n(e,t),columns:t};let r=Qn(e.length,n);return{fields:$n(e,r),columns:r}}function tr(e,t){return function(){try{let n=Fe();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 $=tr({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.editInlineHint":`Double-click to edit`,"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.created":`Created`,"detail.updated":`Updated`,"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.lockedByApproval":`Locked for approval`,"detail.lockedTooltip":`This record has a pending approval request; editing is locked`,"detail.cancelApproval":`Recall approval`,"detail.cancelApprovalInFlight":`Recalling…`,"detail.cancelApprovalTooltip":`Recall the pending approval request to unlock this record`,"detail.cancelApprovalFailed":`Failed to recall approval`,"detail.cancelApprovalUnavailable":`Recalling approvals is not supported on this data source`},`detail.back`);function nr(e){if(typeof e==`string`){let t=e.trim();if(!t)return null;try{return JSON.parse(t)}catch{return t}}return e??null}function rr(e){let t=nr(e);return t==null||t===``?0:Array.isArray(t)?t.length:typeof t==`object`?Object.keys(t).length:1}function ir({value:e,field:t}){let{t:i}=$(),a=m(),{appName:o}=r(),s=t?.name||``,c=a?.data?.name,l=o&&c?`/apps/${o}/metadata/permission/${encodeURIComponent(String(c))}`:null,u=rr(e),d=u===0;return(0,Q.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-1 text-sm`,children:[(()=>{if(d)return(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:i(`perm.facet.none`,{defaultValue:`None`})});if(s===`system_permissions`){let t=Dt(e),n=t.slice(0,6),r=t.length-n.length;return(0,Q.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-1`,children:[n.map(e=>(0,Q.jsx)(lt,{variant:`outline`,children:e},e)),r>0&&(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:i(`perm.facet.more`,{count:r,defaultValue:`+${r} more`})})]})}return(0,Q.jsx)(`span`,{className:`text-foreground`,children:(()=>{switch(s){case`object_permissions`:return i(`perm.facet.objects`,{count:u,defaultValue:`${u} object${u===1?``:`s`}`});case`field_permissions`:return i(`perm.facet.fields`,{count:u,defaultValue:`${u} field rule${u===1?``:`s`}`});case`row_level_security`:return i(`perm.facet.rls`,{count:u,defaultValue:`${u} RLS polic${u===1?`y`:`ies`}`});case`tab_permissions`:return i(`perm.facet.tabs`,{count:u,defaultValue:`${u} tab rule${u===1?``:`s`}`});case`admin_scope`:return i(`perm.facet.adminScope`,{defaultValue:`Delegated admin configured`});default:return String(u)}})()})})(),l?(0,Q.jsx)(n,{to:l,className:`text-primary hover:underline whitespace-nowrap`,children:i(`perm.facet.designInStudio`,{defaultValue:`Design in Studio →`})}):(0,Q.jsx)(`span`,{className:`text-muted-foreground/60 whitespace-nowrap`,children:i(`perm.facet.designInStudioHint`,{defaultValue:`Design in Studio`})})]})}var ar=new Set([`id`,`_id`,`__v`,`created`,`created_at`,`createdAt`,`created_by`,`modified`,`modified_by`,`updated_at`,`updatedAt`,`updated_by`,`deleted_at`,`is_deleted`,`deleted`,`instance_state`]),or=new Set([`formula`,`summary`,`rollup`,`auto_number`]),sr=({field:e,value:t,onChange:n,dataSource:r,autoFocus:i})=>{let a=e.type,o=e.widget;if(o===`permission-facet-link`)return(0,Q.jsx)(ir,{value:t,field:e});if(o===`capability-multiselect`)return(0,Q.jsx)(Ce,{value:t,onChange:e=>n(e),field:e,dataSource:r});if(a===`select`&&Array.isArray(e.options)&&e.options.length>0)return(0,Q.jsx)(K,{field:e,value:t==null?``:String(t),onChange:e=>n(e)});if(a===`boolean`)return(0,Q.jsx)(we,{field:e,value:!!t,onChange:e=>n(e)});let s=a===`user`||a===`owner`,c=a===`lookup`||a===`master_detail`||a===`tree`||!!e.reference_to&&!or.has(a);if(s||c)return(0,Q.jsx)(s?te:N,{field:e,value:t,onChange:e=>n(e),dataSource:r});if(a===`number`)return(0,Q.jsx)(se,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`currency`)return(0,Q.jsx)(be,{field:e,value:t,onChange:e=>n(e),autoFocus:i});if(a===`percent`)return(0,Q.jsx)(ie,{field:e,value:t,onChange:e=>n(e),autoFocus:i});let l=a===`date`||a===`datetime`;return(0,Q.jsx)(`input`,{type:l?`date`:`text`,autoFocus:i,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:t==null?``:l?(()=>{let e=String(t);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let n=new Date(e);return isNaN(n.getTime())?``:n.toLocaleDateString(`en-CA`)})():String(typeof t==`object`?Pt(t)??``:t),onChange:e=>{let t=e.target.value;n(l&&t?new Date(t+`T00:00:00`).toISOString():t)}})},cr=({name:e})=>/^[a-z0-9][a-z0-9-]*$/i.test(e)?(0,Q.jsx)(At,{name:e,className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e});function lr(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:t===3?e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``:e===2?`md:col-span-2`:e===3?`md:col-span-2 lg:col-span-3`:e>=4?`md:col-span-2 lg:col-span-3 xl:col-span-4`:``}var ur=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l,virtualScroll:u})=>{let[f,p]=Z.useState(e.defaultCollapsed??!1),[m,h]=Z.useState(null),[g,_]=Z.useState(void 0),[v,y]=Z.useState(!1),{t:b}=$(),{fieldLabel:x,translateOptions:S}=gn(),C=Z.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{h(e),setTimeout(()=>h(null),2e3)})},[]),w=Z.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),T=Z.useMemo(()=>e.fields.filter(w).length,[e.fields,w]),E=ye(),D=E?3:4,O=E?.2:.25,ee=e.fields.length-T,k=!e.hideEmpty&&!a&&e.fields.length>=D&&T/e.fields.length>=O&&ee>0,A=!v&&(e.hideEmpty||k)?e.fields.filter(e=>!w(e)):e.fields,{fields:M,columns:N}=er(A,e.columns),P=Math.min(N,Math.max(1,A.length)),F=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,Q.jsx)(d,{schema:e.render,data:{...t,value:n}});let u=lr(e.span,P),f=r?.fields?.[e.name],p={...e};if(f){!e.type&&f.type&&(p.type=f.type),f.options&&!p.options&&(p.options=f.options),f.currency&&!p.currency&&(p.currency=f.currency),f.precision!==void 0&&p.precision===void 0&&(p.precision=f.precision),f.scale!==void 0&&p.scale===void 0&&(p.scale=f.scale),f.min!==void 0&&p.min===void 0&&(p.min=f.min),f.max!==void 0&&p.max===void 0&&(p.max=f.max),f.step!==void 0&&p.step===void 0&&(p.step=f.step),f.format&&!p.format&&(p.format=f.format),f.widget&&!p.widget&&(p.widget=f.widget);let t=f.reference_to||f.reference;t&&!p.reference_to&&(p.reference_to=t),f.reference_field&&!p.reference_field&&(p.reference_field=f.reference_field),f.dueLike!==void 0&&p.dueLike===void 0&&(p.dueLike=f.dueLike)}i&&Array.isArray(p.options)&&p.options.length>0&&(p.options=S(i,e.name,p.options));let h=p.type||e.type,g=or.has(h),_=e.readonly===!0||f?.readonly===!0,v=ar.has(e.name),y=!_&&!g&&!v,w=y&&!!s,T=(()=>{if((p.widget||e.widget)===`permission-facet-link`)return(0,Q.jsx)(ir,{value:n,field:p});if(n==null||n===``)return(0,Q.jsx)(`span`,{className:`text-muted-foreground/60 text-sm select-none`,"aria-label":b(`detail.noValue`,{defaultValue:`No value`}),title:b(`detail.noValue`,{defaultValue:`No value`}),children:`—`});let t=We(p)||e.type;if(t){let e=et(t);if(e)return(0,Q.jsx)(e,{value:n,field:p})}return String(n)})(),D=n!=null&&n!==``,O=D&&!w,ee=m===e.name,k=x(i||``,e.name,e.label||e.name);return E&&!(a&&y)?(0,Q.jsxs)(`div`,{className:G(`flex items-baseline justify-between gap-4 py-2.5 min-h-[44px] group`,D&&`cursor-pointer active:bg-muted/40 transition-colors`),onClick:D?()=>C(e.name,n):void 0,onKeyDown:D?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),C(e.name,n))}:void 0,role:D?`button`:void 0,tabIndex:D?0:void 0,children:[(0,Q.jsx)(`span`,{className:`text-[15px] text-muted-foreground shrink-0`,children:k}),(0,Q.jsx)(`span`,{className:`text-[15px] text-foreground text-right break-words min-w-0 leading-snug`,children:T})]},e.name):(0,Q.jsxs)(`div`,{className:G(`space-y-1.5 group min-w-0`,u),children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:x(i||``,e.name,e.label||e.name)}),a&&y?(0,Q.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,Q.jsx)(sr,{field:p,value:n,onChange:t=>o?.(e.name,t),dataSource:l,autoFocus:c===e.name})}):(0,Q.jsxs)(`div`,{className:G(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,O&&`cursor-pointer active:bg-muted/60 transition-colors`,w&&`cursor-pointer hover:bg-muted/40 transition-colors -mx-1.5 px-1.5`),onClick:O?()=>C(e.name,n):void 0,onDoubleClick:w?()=>s?.(e.name):void 0,onKeyDown:O?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),C(e.name,n))}:void 0,role:O?`button`:void 0,tabIndex:O?0:void 0,title:w?b(`detail.editInlineHint`):void 0,children:[(0,Q.jsx)(`div`,{className:`text-sm flex-1 min-w-0 break-words py-1`,children:T}),w?(0,Q.jsx)(Le,{children:(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,"aria-label":b(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),s?.(e.name)},children:(0,Q.jsx)(nn,{className:`h-3 w-3`})})}),(0,Q.jsx)(B,{children:b(`detail.editInlineHint`)})]})}):D?(0,Q.jsx)(Le,{children:(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),C(e.name,n)},children:ee?(0,Q.jsx)(Gt,{className:`h-3 w-3 text-green-600`}):(0,Q.jsx)(ut,{className:`h-3 w-3`})})}),(0,Q.jsx)(B,{children:b(ee?`detail.copied`:`detail.copyToClipboard`)})]})}):null]})]},e.name)},te=u?.enabled===!0,I=u?.batchSize??20;if(Z.useEffect(()=>{if(!te){_(void 0);return}if(M.length<=I){_(void 0);return}_(I);let e=setTimeout(()=>_(void 0),100);return()=>clearTimeout(e)},[te,M.length,I]),A.length===0&&T===e.fields.length)return null;let ne=g===void 0?M:M.slice(0,g),L=T>0&&(e.hideEmpty||k),re=(0,Q.jsxs)(Q.Fragment,{children:[E?(0,Q.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60`,children:ne.map(F)}):(0,Q.jsx)(`div`,{className:G(`grid gap-3 sm:gap-4`,P===1?`grid-cols-1`:P===2?`grid-cols-1 md:grid-cols-2`:P===3?`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`),children:ne.map(F)}),L&&(0,Q.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,Q.jsxs)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>y(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[v?(0,Q.jsx)(ot,{className:`h-3.5 w-3.5 mr-1.5`}):(0,Q.jsx)(j,{className:`h-3.5 w-3.5 mr-1.5`}),v?b(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):b(`detail.showEmptyFields`,{count:T,defaultValue:`Show ${T} empty field${T===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,Q.jsx)(`div`,{className:G(n),children:re}):e.collapsible?(0,Q.jsx)(It,{open:!f,onOpenChange:e=>p(!e),className:n,children:(0,Q.jsxs)(Rt,{children:[(0,Q.jsx)(St,{asChild:!0,children:(0,Q.jsxs)(kt,{className:G(`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)(rn,{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)(cr,{name:e.icon}),(0,Q.jsx)(`span`,{children:e.title})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:f?(0,Q.jsx)(Y,{className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(ce,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!f&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,Q.jsx)(Zt,{children:(0,Q.jsx)(Qt,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:re})})]})}):(0,Q.jsxs)(Rt,{className:G(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,Q.jsxs)(kt,{className:G(`py-3 px-4 sm:py-4 sm:px-6`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,Q.jsx)(rn,{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)(cr,{name: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)(Qt,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:re})]})},dr=({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)(xt,{value:r,onValueChange:i,className:n,children:[(0,Q.jsx)(Je,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,Q.jsx)(sn,{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)(lt,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,Q.jsx)(mt,{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)(d,{schema:e,data:t},n))}):(0,Q.jsx)(d,{schema:e.content,data:t})})},e.key))]})};function fr(e){return e&&P[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||Vt}var pr=({action:e,onToolbarAction:t})=>{let n=e.visible,r=h(f(n));if(n&&!r)return null;let i=e.icon?fr(e.icon):null;return(0,Q.jsxs)(q,{variant:e.variant===`primary`?`default`:`outline`,size:`sm`,onClick:n=>{n.stopPropagation(),t(e)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,"data-testid":`related-toolbar-action-${e.name}`,children:[i&&(0,Q.jsx)(i,{className:`h-3.5 w-3.5`}),e.label||e.name]})},mr=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:s,dataSource:c,objectName:l,onNew:u,onViewAll:f,onRowEdit:p,onRowDelete:m,onRowClick:h,rowActions:g,onRowAction:_,toolbarActions:v,onToolbarAction:y,add:b,maxColumns:x=6,pageSize:S,sortable:C=!1,filterable:w=!1,collapsible:T=!1,defaultCollapsed:E=!1,referenceField:D,parentId:O,icon:ee})=>{let k=r!==void 0,A=r??[],[j,M]=Z.useState(A),[N,P]=Z.useState(()=>!!n&&!k),[F,te]=Z.useState(0),[I,L]=Z.useState(null),[ie,ae]=Z.useState(`asc`),[se,R]=Z.useState(``),[z,le]=Z.useState(null),[ue,de]=Z.useState(E),[fe,B]=Z.useState(!1),[V,pe]=Z.useState(!1),[me,he]=Z.useState(null),[H,U]=Z.useState(0),[ge,_e]=Z.useState({}),{t:W}=$(),{fieldLabel:be}=gn();Z.useEffect(()=>{k&&M(r??[])},[r,k]),Z.useEffect(()=>{n&&c?.getObjectSchema&&c.getObjectSchema(n).then(le).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,c]),Z.useEffect(()=>{if(n&&!k){if(!(D&&O!=null&&O!==``)){n&&(O==null||O===``)&&!D&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),M([]),P(!1);return}P(!0);let e={[D]:O};if(c&&typeof c.find==`function`)c.find(n,{$filter:e}).then(e=>{let t=Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[];M(t),P(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),P(!1)});else{let e=new URLSearchParams({[`filter[${D}]`]:String(O)}).toString();fetch(`${n}?${e}`).then(e=>e.json()).then(e=>{let t=Array.isArray(e)?e:e?.data||[];M(t)}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>P(!1))}}},[n,k,c,D,O,H]),Z.useEffect(()=>{if(!n||k)return;let e=e=>{let t=e.detail||{};t.objectName&&t.objectName!==n||U(e=>e+1)};return window.addEventListener(`objectui:related-changed`,e),()=>window.removeEventListener(`objectui:related-changed`,e)},[n,k]),Z.useEffect(()=>{if(!c?.find||!z?.fields||!j.length)return;let e=z.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 j){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=ge[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||_e(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[c,z,j]);let xe=Z.useMemo(()=>{if(!se)return j;let e=se.toLowerCase();return j.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[j,se]),K=Z.useMemo(()=>I?[...xe].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 ie===`asc`?i:-i}):xe,[xe,I,ie]),Se=S&&S>0?S:0,Ce=Se?Math.max(1,Math.ceil(K.length/Se)):1,we=Se?K.slice(F*Se,(F+1)*Se):K;Z.useEffect(()=>{te(0)},[se,I,ie]);let Te=Z.useCallback(e=>{I===e?ae(e=>e===`asc`?`desc`:`asc`):(L(e),ae(`asc`))},[I]),[Ee,De]=Z.useState(null),Oe=Z.useCallback(e=>{De(e)},[]),ke=Z.useCallback(async()=>{if(Ee)try{await m?.(Ee),U(e=>e+1)}catch(e){console.error(`[RelatedList] remove failed`,e)}De(null)},[Ee,m]),je=Z.useCallback(async e=>{if(!b||!c||!n||D==null||O==null)return;let t=b.picker.valueField||`id`;pe(!0),he(null);try{for(let r of e||[]){let e=r?.[t]??r?.id;e!=null&&(b.linkField?await c.create?.(n,{[D]:O,[b.linkField]:e}):await c.update?.(b.picker.object,String(e),{[D]:O}))}U(e=>e+1)}catch(e){let t=e?.body?.error??e?.error??e?.message??String(e);he(typeof t==`string`?t:`Failed to add`)}finally{pe(!1),B(!1)}},[b,c,n,D,O]),Ne=o(),Pe=Z.useMemo(()=>{let e=l||n||``,t=t=>!Ne?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||t?.field||t?.name;return!n||Ne.checkField(e,String(n),`read`)}),r=e=>D?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==D):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>j.length?e.filter(e=>{let t=e?.accessorKey||e?.field||e?.name;return!t||j.some(e=>!i(e?.[t]))}):e,s=(e,t)=>{if(!t?.type)return;let n=et(We({type:t.type,format:t.format})||t.type);if(!n)return;let r=t.type===`lookup`||t.type===`master_detail`?ge[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.scale!==void 0&&{scale:t.scale},...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=z?.fields?.[e],r=n?s(String(e),n):void 0;if(r)return{...t,cell:r}}return t}let n=z?.fields?.[t],r={accessorKey:t,header:n?.label||be(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(!z?.fields)return[];let u=Array.isArray(z.highlightFields)?z.highlightFields.filter(e=>typeof e==`string`&&e.length>0):[];if(u.length>0){let e=o(t(r(u.map(c))));if(e.length>0)return e.slice(0,Math.max(1,x))}let d=e,f=new Set([`rich_text`,`html`,`json`]),p=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],m=Object.entries(z.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===D||t?.hidden||t?.type&&f.has(t.type)||Ne?.isLoaded&&d&&!Ne.checkField(d,e,`read`))),h=new Set([`created_at`,`updated_at`,`created_by`,`updated_by`,`owner_id`,`organization_id`]);return m.sort(([e,t],[n,r])=>{let i=h.has(e);if(i!==h.has(n))return i?1:-1;let a=p.indexOf(e),o=p.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(m.map(([e,t])=>{let n={accessorKey:e,header:be(d,e,t.label||e)};if(t.type){let r=s(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,x))},[a,z,l,n,be,D,j,x,ge,Ne]),Fe=Array.isArray(g)&&g.length>0,Ie=!!p||!!m||Fe,Le=ye(),Re=Z.useMemo(()=>{if(i)return i;if(Le&&(t===`grid`||t===`table`)){let e=Pe[0]?.accessorKey||Pe[0]?.field||Pe[0]?.name,t=Pe.slice(1,4).map(e=>e.accessorKey||e.field||e.name).filter(Boolean);return{type:`object-gallery`,data:we,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,cardSize:`medium`},onRowClick:h}}let e=z?.userActions?.edit,r=z?.userActions?.delete,a=e=>typeof e==`object`&&e&&(e.visibleWhen!=null||e.disabledWhen!=null)?{visibleWhen:e.visibleWhen??void 0,disabledWhen:e.disabledWhen??void 0}:void 0;switch(t){case`grid`:case`table`:return{type:`data-table`,data:we,columns:Pe,pagination:!1,pageSize:Se||10,searchable:!1,exportable:!1,rowActions:Ie,onRowEdit:p,onRowDelete:m?Oe:void 0,rowEditPredicates:a(e),rowDeletePredicates:a(r),onRowClick:h,rowActionDefs:Fe?g:void 0,onRowActionDef:Fe?_:void 0};case`list`:return{type:`data-list`,data:we};default:return{type:`div`,children:`No view configured`}}},[t,we,Pe,i,Se,Ie,Fe,g,_,p,m,Oe,h,Le,n,z]),ze=T?`cursor-pointer select-none`:void 0,J=T?()=>de(e=>!e):void 0,X=fr(ee),Be=!N&&j.length===0,Ve=w;return(0,Q.jsxs)(Rt,{className:G(`shadow-none border-border/60 bg-transparent`,Be&&`bg-muted/10`,s),children:[(0,Q.jsx)(kt,{className:G(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,ze),onClick:J,children:(0,Q.jsxs)(rn,{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:[T&&(ue?(0,Q.jsx)(Y,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Q.jsx)(ce,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,Q.jsx)(X,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:G(`truncate`,Be&&`text-muted-foreground font-medium`),children:e}),(0,Q.jsx)(lt,{variant:`secondary`,className:G(`text-xs font-normal h-5 px-1.5`,j.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${j.length} records`,children:j.length}),Be&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:W(`detail.noRelatedRecords`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[y&&(v??[]).map(e=>(0,Q.jsx)(pr,{action:e,onToolbarAction:y},e.name)),b&&(0,Q.jsxs)(q,{variant:Be?`ghost`:`outline`,size:`sm`,disabled:V,onClick:e=>{e.stopPropagation(),he(null),B(!0)},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,Q.jsx)(qt,{className:`h-3.5 w-3.5`}),b.label||W(`detail.add`,{defaultValue:`Add`})]}),u&&(0,Q.jsxs)(q,{variant:Be?`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)(qt,{className:`h-3.5 w-3.5`}),W(`detail.new`)]})]})]})}),!ue&&!Be&&(0,Q.jsxs)(Qt,{className:G(`pt-0 pb-4 px-4`),children:[Ve&&(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(jt,{placeholder:W(`detail.filterPlaceholder`),value:se,onChange:e=>R(e.target.value),className:`h-8 text-sm`})}),C&&Pe&&Pe.length>0&&j.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:Pe.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)(q,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>Te(t),children:[(0,Q.jsx)(ne,{className:`h-3 w-3`}),n,r&&(ie===`asc`?` ↑`:` ↓`)]},t)})}),N?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:W(`detail.loading`)}):(0,Q.jsx)(d,{schema:Re}),Se>0&&K.length>Se&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:F===0,onClick:()=>te(e=>Math.max(0,e-1)),children:[(0,Q.jsx)(ve,{className:`h-3 w-3`}),W(`detail.previousPage`)]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:W(`detail.pageOf`,{current:F+1,total:Ce})}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:F>=Ce-1,onClick:()=>te(e=>Math.min(Ce-1,e+1)),children:[W(`detail.nextPage`),(0,Q.jsx)(Y,{className:`h-3 w-3`})]})]}),f&&!Be&&Se>0&&K.length>Se&&(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(),f()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[W(`detail.viewAll`),(0,Q.jsx)(tn,{className:`h-3 w-3`})]})})]}),(0,Q.jsx)(hn,{open:Ee!==null,onOpenChange:e=>{e||De(null)},children:(0,Q.jsxs)(Ae,{children:[(0,Q.jsxs)(Me,{children:[(0,Q.jsx)(oe,{children:W(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,Q.jsx)(re,{children:W(`detail.deleteRowConfirmation`)})]}),(0,Q.jsxs)(dn,{children:[(0,Q.jsx)(pn,{children:W(`detail.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsx)(Qe,{onClick:ke,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:W(`detail.delete`,{defaultValue:`Delete`})})]})]})}),me&&(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:me}),b&&c&&(0,Q.jsx)(wt,{open:fe,onOpenChange:e=>B(e),multiple:!0,dataSource:c,objectName:b.picker.object,title:b.label||W(`detail.add`,{defaultValue:`Add`}),onSelect:()=>{},onSelectRecords:e=>{je(e)}})]})},hr=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l})=>{let u=e.collapsible??!0,[d,f]=Z.useState(e.defaultCollapsed??!1),p=(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,Q.jsx)(ur,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o,onEnterInlineEdit:s,autoFocusField:c,dataSource:l},n))});return u?(0,Q.jsxs)(It,{open:!d,onOpenChange:e=>f(!e),className:n,children:[(0,Q.jsx)(St,{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:[d?(0,Q.jsx)(Y,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(ce,{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&&!d&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,Q.jsx)(Zt,{children:(0,Q.jsx)(`div`,{className:`mt-3`,children:p})})]}):(0,Q.jsxs)(`div`,{className:G(`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}),p]})},gr=({fields:e,data:t,className:n,objectName:r,objectSchema:i,dataSource:a})=>{let{fieldLabel:o}=gn(),{t:s}=$(),c=ee(),l=c?.editing??!1,u=c?.canEdit??!1;if(!e.length||!t)return null;let d=l?e:e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return d.length===0?null:(0,Q.jsx)(Le,{children:(0,Q.jsx)(`section`,{className:G(`@container border-b border-border/60 pb-4`,n),"aria-label":`Record highlights`,children:(0,Q.jsx)(`div`,{className:G(`flex flex-wrap gap-y-4`),children:d.map(e=>{let n=t[e.name],d=i?.fields?.[e.name],f=e.type||d?.type,p=d?.reference_to||d?.reference,m={name:e.name,label:e.label,type:f||`text`,...d?.options&&{options:d.options},...d?.currency&&{currency:d.currency},...d?.currencyConfig&&{currencyConfig:d.currencyConfig},...d?.precision!==void 0&&{precision:d.precision},...d?.scale!==void 0&&{scale:d.scale},...d?.min!==void 0&&{min:d.min},...d?.max!==void 0&&{max:d.max},...d?.step!==void 0&&{step:d.step},...d?.format&&{format:d.format},...p&&{reference_to:p},...d?.reference_field&&{reference_field:d.reference_field},...d?.widget&&{widget:d.widget}},h=c?.draft?.[e.name],g=h===void 0?n:h,_=or.has(f),v=e.readonly===!0||d?.readonly===!0,y=ar.has(e.name),b=u&&!_&&!v&&!y,x=l&&b,S=et(We(m)||f||`text`),C=f===`number`||f===`integer`||f===`currency`||f===`percent`||f===`decimal`,w=f===`email`||f===`url`||f===`textarea`||f===`reference`||f===`lookup`||f===`master_detail`,T=f===`boolean`,E=g==null||g===``;return(0,Q.jsxs)(`div`,{className:G(`group flex flex-col gap-1 min-w-[7rem] px-5 border-l border-border/60 first:border-l-0 first:pl-0`,w||x?`basis-[16rem] max-w-[24rem]`:`basis-[9rem] max-w-[16rem]`),children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:o(r||``,e.name,e.label)}),x?(0,Q.jsx)(sr,{field:m,value:g,onChange:t=>c.setField(e.name,t),dataSource:a,autoFocus:c.autoFocusField===e.name}):(0,Q.jsxs)(`div`,{className:G(`flex items-start justify-between gap-1`,b&&`cursor-pointer rounded-md -mx-1.5 px-1.5 hover:bg-muted/40 transition-colors`),onDoubleClick:b?()=>c.enter(e.name):void 0,title:b?s(`detail.editInlineHint`):void 0,children:[(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:T?g?(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)(Gt,{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)(z,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):E?(0,Q.jsx)(`span`,{className:`block text-sm text-muted-foreground/60 select-none`,"aria-label":s(`detail.noValue`,{defaultValue:`No value`}),children:`—`}):(0,Q.jsx)(`span`,{title:(Array.isArray(m.options)?m.options.find(e=>e?.value===g)?.label:void 0)??(typeof g==`string`||typeof g==`number`?String(g):void 0),className:G(`block min-w-0 truncate text-sm font-semibold`,C&&`tabular-nums tracking-tight`),children:(0,Q.jsx)(S,{value:g,field:m})})}),b&&(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`,"aria-label":s(`detail.editInlineHint`),onClick:t=>{t.stopPropagation(),c.enter(e.name)},children:(0,Q.jsx)(nn,{className:`h-3 w-3`})})}),(0,Q.jsx)(B,{children:s(`detail.editInlineHint`)})]})]})]},e.name)})})})})};function _r(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 vr=({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)(Rt,{className:G(``,i),children:[(0,Q.jsx)(kt,{children:(0,Q.jsxs)(rn,{className:`flex items-center gap-2 text-base`,children:[(0,Q.jsx)(V,{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)(Qt,{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)(me,{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)(z,{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)(q,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,Q.jsx)(R,{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:G(`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:_r(e.createdAt)}),e.pinned&&(0,Q.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,Q.jsx)(Lt,{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)(Lt,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},yr={field_change:an,create:Et,delete:it,comment:V,status_change:je},br={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 xr(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 Sr(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 Cr={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},wr=({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)(Rt,{className:G(``,r),children:[(0,Q.jsx)(kt,{children:(0,Q.jsxs)(rn,{className:`flex items-center gap-2 text-base`,children:[(0,Q.jsx)(Tt,{className:`h-4 w-4`}),`Activity`,(0,Q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,Q.jsxs)(Qt,{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(Cr).map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:G(`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(yr[e]||an,{className:`h-3 w-3`}),Cr[e]]},e))}),o.length===0?(0,Q.jsx)(ue,{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=yr[e.type]||an;return(0,Q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,Q.jsx)(`div`,{className:G(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,br[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:Sr(e)})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:xr(e.timestamp)})]})]},e.id)})})]})]})]})},Tr={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`};function Er(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var Dr=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function Or(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 Dr){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return Er(e)}r/=n}return Er(e)}function kr(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 Ar(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 jr({entries:e,loading:t,emptyText:n,unknownUserText:r,className:i,locale:a}){return t?(0,Q.jsx)(`div`,{className:G(`space-y-3`,i),children:Array.from({length:4}).map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(le,{className:`h-8 w-8 rounded-full`}),(0,Q.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Q.jsx)(le,{className:`h-4 w-1/3`}),(0,Q.jsx)(le,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,Q.jsx)(`div`,{className:G(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,i),children:n??`No history yet`}):(0,Q.jsx)(Le,{delayDuration:150,children:(0,Q.jsx)(`ol`,{className:G(`space-y-4`,i),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),i=Tr[n]??`outline`,o=typeof e.user_name==`string`&&e.user_name.trim()||r||`Unknown user`,s=Er(e.created_at),c=Or(e.created_at,a),l=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:[l?(0,Q.jsx)(yt,{src:l,alt:o}):null,(0,Q.jsx)(Nt,{className:`text-[10px] font-medium`,children:kr(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:o}),e.action&&(0,Q.jsx)(lt,{variant:i,className:`text-[10px] uppercase tracking-wide`,children:e.action}),s&&(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":s,children:c||s})}),(0,Q.jsx)(B,{children:s})]})]}),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:Ar(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:Ar(e.from)}),` → `,(0,Q.jsx)(`span`,{className:`text-foreground`,children:Ar(e.to)})]},e.field))}))]})]},e.id??t)})})})}var Mr={createdAt:`created_at`,createdBy:`created_by`,updatedAt:`updated_at`,updatedBy:`updated_by`};function Nr(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 Pr(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 Fr(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var Ir=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference_to||r?.reference||`sys_user`,a={name:n,type:r?.type||`lookup`,reference_to:i,...r?.reference_field&&{reference_field:r.reference_field}},o=We(a)||a.type;if(o){let t=et(o);if(t)return(0,Q.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:Z.createElement(t,{value:e,field:a})})}return(0,Q.jsx)(`span`,{children:String(e)})},Lr=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,Q.jsx)(Le,{delayDuration:200,children:(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:Pr(n,a)})}),(0,Q.jsx)(B,{side:`top`,children:Fr(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)(Ir,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},Rr=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=$();if(!e)return null;let a=Nr(e[Mr.createdAt]),o=Nr(e[Mr.updatedAt]),s=e[Mr.createdBy],c=e[Mr.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:G(`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)(Lr,{label:i(s?`detail.createdBy`:`detail.created`),user:s,date:a,objectSchema:t,userField:Mr.createdBy,t:i}),d&&(0,Q.jsx)(Lr,{label:i(c?`detail.updatedBy`:`detail.updated`),user:c,date:o,objectSchema:t,userField:Mr.updatedBy,t:i})]})},zr=5,Br={};function Vr(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=_(n?.titleFormat,e);if(r)return r}if(e&&typeof e==`object`){let t=e.id??e._id,r=E(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,r=E(n,e);if(!(r===`Untitled`||t!=null&&r===`Record #${t}`))return r}if(e&&typeof e==`object`){let t=e.id??e._id;if(t!=null&&String(t).trim()!==``)return`Record #${t}`}return r}var Hr=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:s=!1,discussionSlot:c,rightRail:l,objectLabel:u,onDataLoaded:f,isFavorite:p,onToggleFavorite:m})=>{let[h,_]=Z.useState(e.data),[v,y]=Z.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[b,x]=Z.useState(!1),S=p??b,C=ee(),T=C?.editing??!1,E=C?.draft??Br,D=C?.autoFocusField??null,[O,k]=Z.useState(null),[A,j]=Z.useState(null),[M,N]=Z.useState(!1),[P,F]=Z.useState(0),te=w(e.objectName||void 0,e.resourceId==null?void 0:String(e.resourceId)),[I,ne]=Z.useState(!1),{t:L}=$(),{currency:re}=pe(),{fieldOptionLabel:ie}=gn(),oe=ye(),se=o(),R=Z.useMemo(()=>{if(!se?.isLoaded||!e.objectName)return e;let t=t=>se.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,se]);Z.useEffect(()=>{h&&f&&f(h)},[h,f]);let ce=Z.useMemo(()=>{if(R.summaryFields&&R.summaryFields.length>0)return[];let e=[...R.sections?.flatMap(e=>e.fields)||[],...R.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(A?.fields)for(let[e,n]of Object.entries(A.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>h?.[e]!==void 0&&h?.[e]!==null&&h?.[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},[R.summaryFields,R.sections,R.fields,A,h]),ue=R.summaryFields&&R.summaryFields.length>0?R.summaryFields:ce,de=Z.useCallback(()=>{R.resourceId&&navigator.clipboard.writeText(String(R.resourceId)).then(()=>{N(!0),setTimeout(()=>N(!1),1500)})},[R.resourceId]);Z.useEffect(()=>{let e=!0;if(R.data)return _(R.data),y(!1),t?.getObjectSchema&&R.objectName&&t.getObjectSchema(R.objectName).then(t=>{e&&j(t)}).catch(()=>{}),()=>{e=!1};if(t&&R.objectName&&R.resourceId){y(!0),j(null),_(null);let n=R.objectName,r=R.resourceId,i=`${n}-`,a=[...R.sections?.flatMap(e=>e.fields)||[],...R.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;j(o);let s=g(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&&(_(t),y(!1))}).catch(()=>{e&&(_(null),y(!1))})};return l.catch(()=>null).then(t=>{if(e){if(t){_(t),y(!1);return}return u()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),y(!1))})}else R.api&&R.resourceId&&(y(!0),fetch(`${R.api}/${R.resourceId}`).then(e=>e.json()).then(t=>{e&&_(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&y(!1)}));return()=>{e=!1}},[R.api,R.resourceId,R.objectName,t,R.sections,R.fields,P,te]);let fe=Z.useCallback(()=>{if(a)a();else if(R.onNavigate){let e=R.backUrl||(R.objectName?`/${R.objectName}`:`/`);R.onNavigate(e,{replace:!0})}else R.backUrl?window.location.href=R.backUrl:window.history.back()},[a,R]),V=Z.useCallback(()=>{r?r():R.onNavigate&&R.editUrl?R.onNavigate(R.editUrl):R.onNavigate&&R.objectName&&R.resourceId?R.onNavigate(`/${R.objectName}/${R.resourceId}/edit`):R.editUrl&&(window.location.href=R.editUrl)},[r,R]),me=Z.useCallback(async()=>{if(!t?.cancelPendingApproval||!R.objectName||!R.resourceId){k(L(`detail.cancelApprovalUnavailable`));return}ne(!0),k(null);try{if(await t.cancelPendingApproval(String(R.objectName),String(R.resourceId)),t.findOne)try{let e=await t.findOne(String(R.objectName),String(R.resourceId));e&&_(e)}catch{}F(e=>e+1);try{window.dispatchEvent(new CustomEvent(`objectui:record-changed`,{detail:{objectName:String(R.objectName),recordId:String(R.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*/,``);k(`${L(`detail.cancelApprovalFailed`)}: ${t}`)}finally{ne(!1)}},[t,R.objectName,R.resourceId,L]),he=Z.useCallback(()=>{let e=R.deleteConfirmation||L(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),R.onNavigate&&R.objectName&&R.onNavigate(`/${R.objectName}`,{replace:!0}))},[i,R]),H=Z.useCallback(()=>{navigator.share&&R.objectName&&R.resourceId?navigator.share({title:R.title||L(`detail.details`),text:`${R.objectName} #${R.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`)})},[R]),U=Z.useCallback(()=>{let e=!S;m&&m(e),p===void 0&&x(e)},[S,p,m]),ge=C?.setField,W=C&&C.canEdit?C.enter:void 0;Z.useEffect(()=>{if(!R.recordNavigation)return;let e=R.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)},[R.recordNavigation]);let be=Z.useMemo(()=>R.related??[],[R.related]),xe=Z.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:L(`detail.share`),icon:`share-2`,type:`script`,onClick:H}),R.showEdit&&e.push({name:`sys_edit_mobile`,label:L(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:V}),R.showDelete&&e.push({name:`sys_delete`,label:L(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:he}),e},[L,R.showEdit,R.showDelete,H,V,he]),K=Z.useMemo(()=>{let e=R.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},[R.actions,xe]);return v||R.loading?(0,Q.jsxs)(`div`,{className:G(`space-y-4`,n),children:[(0,Q.jsx)(le,{className:`h-10 w-full`}),(0,Q.jsx)(le,{className:`h-64 w-full`}),(0,Q.jsx)(le,{className:`h-48 w-full`})]}):!h&&!R.data?(0,Q.jsxs)(`div`,{className:G(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,Q.jsx)(`p`,{className:`text-lg font-semibold`,children:L(`detail.recordNotFound`)}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:L(`detail.recordNotFoundDescription`)}),(R.showBack??!0)&&(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:fe,className:`mt-4 gap-2`,children:[(0,Q.jsx)(ae,{className:`h-4 w-4`}),L(`detail.goBack`)]})]}):(0,Q.jsx)(Le,{children:(0,Q.jsxs)(`div`,{className:G(`space-y-6`,n),children:[R.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:[(R.showBack??!0)&&(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,onClick:fe,className:`shrink-0 mt-1`,children:(0,Q.jsx)(ae,{className:`h-4 w-4`})})}),(0,Q.jsx)(B,{children:L(`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:Vr(h,R,A,L(`detail.details`))}),ue.map(e=>{let t=h?.[e];if(t==null||t===``)return null;let n=(R.sections||[]).flatMap(e=>e.fields).concat(R.fields||[]).find(t=>t.name===e),r=A?.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=Te({...r,...n},re);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=R.objectName?ie(R.objectName,e,String(t),o):o}}catch{}return o===null?(0,Q.jsx)(lt,{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)(lt,{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)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:U,"aria-label":L(S?`detail.removeFromFavorites`:`detail.addToFavorites`),children:S?(0,Q.jsx)(_t,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,Q.jsx)(_t,{className:`h-4 w-4 text-muted-foreground`})})}),(0,Q.jsx)(B,{children:L(S?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),R.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:u||R.objectName}),R.resourceId&&(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:de,"aria-label":L(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:M?(0,Q.jsx)(Gt,{className:`h-3 w-3 text-green-600`}):(0,Q.jsx)(ut,{className:`h-3 w-3`})})}),(0,Q.jsx)(B,{children:M?L(`detail.copied`,{defaultValue:`Copied`}):L(`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:[R.recordNavigation&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(q,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:R.recordNavigation.currentIndex<=0,onClick:()=>{let e=R.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,Q.jsx)(ve,{className:`h-4 w-4`})})}),(0,Q.jsx)(B,{children:L(`detail.previousRecord`)})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:L(`detail.recordOf`,{current:R.recordNavigation.currentIndex+1,total:R.recordNavigation.recordIds.length})}),(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsx)(q,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:R.recordNavigation.currentIndex>=R.recordNavigation.recordIds.length-1,onClick:()=>{let e=R.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,Q.jsx)(Y,{className:`h-4 w-4`})})}),(0,Q.jsx)(B,{children:L(`detail.nextRecord`)})]})]}),R.showEdit&&(0,Q.jsxs)(J,{children:[(0,Q.jsx)(X,{asChild:!0,children:(0,Q.jsxs)(q,{variant:`default`,onClick:V,className:`gap-2 hidden sm:inline-flex`,children:[(0,Q.jsx)(an,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:L(`detail.edit`)})]})}),(0,Q.jsx)(B,{children:L(`detail.editRecord`)})]}),K.map((e,t)=>(0,Q.jsx)(d,{schema:e,data:h},`header-action-${t}`))]})]}),R.header&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(d,{schema:R.header,data:h})}),R.highlightFields&&R.highlightFields.length>0&&(0,Q.jsx)(gr,{fields:R.highlightFields,data:h,objectName:R.objectName,objectSchema:A}),s&&R.showHeader===!1&&(()=>{let e=h?.approval_status,n=(C?.locked??!1)||e===`pending`||e===`in_approval`;return!n&&!O?null:(0,Q.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[n&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,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:C?.lockedReason??L(`detail.lockedTooltip`),children:[(0,Q.jsx)(_e,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:L(`detail.lockedByApproval`)})]}),t?.cancelPendingApproval&&(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:me,disabled:I,className:`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`,title:L(`detail.cancelApprovalTooltip`),children:[(0,Q.jsx)(z,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:L(I?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),O&&(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:O})]})})(),R.autoTabs&&!R.tabs?.length?(()=>{let e=be.length>0,n=!!R.activities&&R.activities.length>0,r=!!c,i=!!R.history,a=[`details`,...e?[`related`]:[],...n?[`activity`]:[],...r?[`discussion`]:[],...i?[`history`]:[]],o=R.defaultTab,l=o&&a.includes(o)?o:`details`,u=R.onTabChange,d=(0,Q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[R.sectionGroups&&R.sectionGroups.length>0&&R.sectionGroups.map((e,n)=>(0,Q.jsx)(hr,{group:e,data:{...h,...E},objectSchema:A,objectName:R.objectName,isEditing:T,onFieldChange:ge,onEnterInlineEdit:s?W:void 0,autoFocusField:D,dataSource:t},n)),R.sections&&R.sections.length>0&&R.sections.map((e,n)=>(0,Q.jsx)(ur,{section:e,data:{...h,...E},objectSchema:A,objectName:R.objectName,isEditing:T,onFieldChange:ge,onEnterInlineEdit:s?W:void 0,autoFocusField:D,dataSource:t},n)),R.fields&&R.fields.length>0&&!R.sections?.length&&(0,Q.jsx)(ur,{section:{fields:R.fields,columns:R.columns},data:{...h,...E},objectSchema:A,objectName:R.objectName,isEditing:T,onFieldChange:ge,onEnterInlineEdit:s?W:void 0,autoFocusField:D,dataSource:t}),R.comments&&(0,Q.jsx)(vr,{comments:R.comments,onAddComment:R.onAddComment})]});return!e&&!n&&!r&&!i?(0,Q.jsx)(`div`,{className:`mt-2`,children:d}):(0,Q.jsxs)(xt,{defaultValue:l,onValueChange:u,className:`w-full`,children:[(0,Q.jsxs)(Je,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,Q.jsx)(sn,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:L(`detail.details`)}),e&&(0,Q.jsx)(sn,{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:[L(`detail.related`),(0,Q.jsx)(lt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:be.length})]})}),n&&(0,Q.jsx)(sn,{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:[L(`detail.activity`),(0,Q.jsx)(lt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:R.activities.length})]})}),r&&(0,Q.jsx)(sn,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:L(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,Q.jsx)(sn,{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:[L(`detail.history`,{defaultValue:`History`}),!R.history.loading&&R.history.entries.length>0&&(0,Q.jsx)(lt,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:R.history.entries.length})]})})]}),(0,Q.jsx)(mt,{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:d}),e&&(0,Q.jsx)(mt,{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)(mr,{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:oe&&n>0,pageSize:zr},n))})}),n&&(0,Q.jsx)(mt,{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)(wr,{activities:R.activities})}),r&&(0,Q.jsx)(mt,{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:c}),i&&(0,Q.jsx)(mt,{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)(jr,{entries:R.history.entries,loading:R.history.loading,emptyText:R.history.emptyText??L(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,Q.jsxs)(Q.Fragment,{children:[R.sectionGroups&&R.sectionGroups.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:R.sectionGroups.map((e,n)=>(0,Q.jsx)(hr,{group:e,data:{...h,...E},objectSchema:A,objectName:R.objectName,isEditing:T,onFieldChange:ge,onEnterInlineEdit:s?W:void 0,autoFocusField:D,dataSource:t},n))}),R.sections&&R.sections.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:R.sections.map((e,n)=>(0,Q.jsx)(ur,{section:e,data:{...h,...E},objectSchema:A,objectName:R.objectName,isEditing:T,onFieldChange:ge,onEnterInlineEdit:s?W:void 0,autoFocusField:D,dataSource:t},n))}),R.fields&&R.fields.length>0&&!R.sections?.length&&(0,Q.jsx)(ur,{section:{fields:R.fields,columns:R.columns},data:{...h,...E},objectSchema:A,objectName:R.objectName,isEditing:T,onFieldChange:ge,onEnterInlineEdit:s?W:void 0,autoFocusField:D,dataSource:t}),R.tabs&&R.tabs.length>0&&(0,Q.jsx)(dr,{tabs:R.tabs,data:h}),be.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:L(`detail.related`)}),be.map((e,n)=>(0,Q.jsx)(mr,{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:oe&&n>0,pageSize:zr},n))]}),R.comments&&(0,Q.jsx)(vr,{comments:R.comments,onAddComment:R.onAddComment}),R.activities&&R.activities.length>0&&(0,Q.jsx)(wr,{activities:R.activities})]}),(0,Q.jsx)(Rr,{data:{...h,...E},objectSchema:A,objectName:R.objectName}),R.footer&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(d,{schema:R.footer,data:h})})]})})},Ur=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name)||null,Wr=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}},Gr=({schema:e={},className:t,...n})=>{let r=m(),{designer:i}=Wr(n),a=r?.objectName||``,c=o(),{readableFields:l}=s(a),{sectionLabel:u}=gn(),{language:d}=Fe(),f=O();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 p=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(p.length>0&&a&&!p.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 details.`})});let h=e.layout===`inline`||e.layout===`compact`?`horizontal`:`vertical`,g=e.enforceFieldSecurity===!0,_=Array.isArray(e.redactFields)?e.redactFields:[],v=e=>{if(!e||!g&&_.length===0)return e;let t=e.map(Ur).filter(e=>!!e),n=new Set((g&&a?l(t):t).filter(e=>!_.includes(e)));return e.filter(e=>{let t=Ur(e);return!t||n.has(t)})},y=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,b=e=>Array.isArray(e)?e.map(y):e,x=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:Ur(e)).filter(e=>!!e));for(let e of f)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=Ur(e);return!t||!x.has(t)}),E=T(b(v(e.fields))),D=Array.isArray(e.sections)?e.sections.map(e=>{let t=e.title??e.label,n=t==null?void 0:W(t,d),r=e.name&&a?u(a,e.name,n??e.name):n;return{...e,title:r,showBorder:e.showBorder??!!r,hideEmpty:e.hideEmpty??!0,fields:T(b(v(e.fields)))}}):e.sections,ee=new Set([`system`,`append-only`,`better-auth`]),k=S?.managedBy,A=S?.userActions?.edit,j=(typeof A==`object`&&A?A.enabled:A)??!(k!=null&&ee.has(k)),M=(e.inlineEdit??!0)&&j,N={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:h,columns:e.columns,sections:D,fields:E,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:M};return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(Hr,{schema:N,dataSource:r.dataSource,inlineEdit:M})})},Kr=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name||e.key)||null,qr=e=>e?.id??e?._id??null,Jr=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}},Yr=({schema:e={},className:t,...n})=>{let r=m(),{designer:i}=Jr(n),a=gn(),{language:c}=Fe(),l=e.objectName,u=l&&a.objectLabel?a.objectLabel({name:l,label:ht(l)}):l?ht(l):``,d=W(e.title,c)||u||`Related`;if(!l)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(l),h=e.relationshipValueField||`id`,g=h===`id`?r?.recordId??null:r?.data?.[h]??null,_=C(),v=Z.useMemo(()=>_?.resolve({objectName:l,relationshipField:e.relationshipField,parentId:g})??null,[_,l,e.relationshipField,g]);if(f.isLoaded&&!f.can(l,`read`))return null;let y=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(y.length>0&&!y.every(e=>f.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 related list.`})});let b=e.enforceFieldSecurity===!0,x=Array.isArray(e.redactFields)?e.redactFields:[],S=Array.isArray(e.columns)?e.columns:[],w=S;if(b||x.length>0){let e=S.map(Kr).filter(e=>!!e),t=new Set((b?p(e):e).filter(e=>!x.includes(e)));w=S.filter(e=>{let n=Kr(e);return!n||t.has(n)})}return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(mr,{title:d,type:`table`,api:l,objectName:l,referenceField:e.relationshipField,parentId:g,columns:w,pageSize:e.limit,dataSource:r?.dataSource,add:e.add?{...e.add,label:W(e.add.label,c)||void 0}:void 0,rowActions:v?.rowActions,onRowAction:v?.onRowAction,toolbarActions:v?.toolbarActions,onToolbarAction:v?.onToolbarAction,onNew:v?.onCreate,onRowClick:v?.onView?e=>{let t=qr(e);t!=null&&v.onView(t,e)}:void 0,onRowEdit:v?.onEdit?e=>{let t=qr(e);t!=null&&v.onEdit(t,e)}:void 0,onRowDelete:v?.onDelete?e=>{let t=qr(e);if(t!=null)return v.onDelete(t,e)}:e.add&&r?.dataSource?async e=>{let t=e?.id??e?._id;t!=null&&await r.dataSource.delete?.(l,String(t))}:void 0})})},Xr=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}},Zr=({schema:e={},className:t,...n})=>{let r=m(),{designer:i}=Xr(n),a=r?.objectName||``,c=o(),{readableFields:l}=s(a),d=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(d.length>0&&a&&!d.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 f=(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),p=e.enforceFieldSecurity===!0,h=Array.isArray(e.redactFields)?e.redactFields:[],g=p&&a?new Set(l(f.map(e=>e.name))):null,_=f.filter(e=>!(h.includes(e.name)||g&&!g.has(e.name)));return u(Z.useId(),_.map(e=>e.name)),(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(gr,{fields:_,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema,dataSource:r?.dataSource})})},Qr=({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:G(`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)(cn,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:i})]})},$r=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],ei=({reactions:e,onToggleReaction:t,emojiOptions:n=$r,className:r})=>{let[i,a]=Z.useState(!1),o=Z.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:G(`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)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,Q.jsx)(L,{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 ti(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 ni=({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:G(`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)(ce,{className:`h-3 w-3`}):(0,Q.jsx)(Y,{className:`h-3 w-3`}),(0,Q.jsx)(V,{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:ti(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)(q,{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)(R,{className:`h-3 w-3`})})]})]})},ri=({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)(q,{variant:`ghost`,size:`icon`,className:G(`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)(ft,{className:`h-4 w-4 text-primary`}):(0,Q.jsx)(Ke,{className:`h-4 w-4 text-muted-foreground`})})};function ii(e){let t=e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).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 ai=({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:G(`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)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,Q.jsx)(gt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,Q.jsx)(nt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,Q.jsx)(H,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.inlineCode`),children:(0,Q.jsx)(bt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,Q.jsx)(mn,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:u?(0,Q.jsx)(an,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(j,{className:`h-3.5 w-3.5`})}),n&&(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,Q.jsx)(R,{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:ii(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:G(`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 oi(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function si(e){return e.startsWith(`image/`)}function ci(e){return si(e)?vt:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?fe:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?De:_n}var li=({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:G(`space-y-2`,r),children:[t&&!i&&(0,Q.jsxs)(`div`,{className:G(`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)(Wt,{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)(st,{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=si(e.type),r=ci(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:oi(e.size)})]}),n&&!i&&(0,Q.jsx)(q,{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)(z,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},ui={comment:V,field_change:an,task:Ze,event:Jt,system:Se,email:Pe,call:$e},di={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 fi(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 pi(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 mi(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 hi=({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([]),[ee,k]=Z.useState(!1),A=n??y,j=t?.showFilterToggle!==!1,N=t?.showCommentInput!==!1&&!!s,P=t?.enableReactions??!1,F=t?.enableThreading??!1,te=t?.showSubscriptionToggle??!1,I=Z.useMemo(()=>mi(e,A),[e,A]),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]),ie=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]),ae=Z.useCallback(async e=>{if(!(!m||e.length===0)){k(!0);try{let t=await m(e);Array.isArray(t)&&t.length>0&&O(e=>[...e,...t])}finally{k(!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:G(`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)(Tt,{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)(ri,{subscription:u,onToggle:d})})]})}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[j&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(M,{value:A,onValueChange:e=>re(e),children:[(0,Q.jsx)(Ft,{"aria-label":v(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,Q.jsx)(Yt,{})}),(0,Q.jsx)(at,{children:fi(v).map(e=>(0,Q.jsx)(en,{value:e.value,children:e.label},e.value))})]})}),N&&(0,Q.jsx)(ai,{value:x,onChange:S,onSubmit:ie,mentionSuggestions:p,placeholder:v(`detail.leaveCommentPlaceholder`),disabled:C,canSubmitEmpty:D.length>0,extraSlot:m?(0,Q.jsx)(li,{attachments:D,onUpload:ae,onRemove:oe,readOnly:C||ee}):D.length>0?(0,Q.jsx)(li,{attachments:D,onRemove:oe,readOnly:C}):void 0}),I.length===0?f?null:(0,Q.jsx)(ue,{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=ui[e.type]||Se,n=di[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:G(`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:pi(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)(Qr,{change:e},t))}),P&&e.reactions&&e.reactions.length>0&&(0,Q.jsx)(`div`,{className:`mt-1.5`,children:(0,Q.jsx)(ei,{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)(ei,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),F&&(e.replyCount??0)>0&&(0,Q.jsx)(ni,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,Q.jsx)(`div`,{className:`text-center pt-2`,children:(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:se,disabled:T,"aria-label":v(`detail.loadMore`),children:[T?(0,Q.jsx)(Ut,{className:`h-4 w-4 animate-spin mr-1`}):(0,Q.jsx)(ce,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},gi=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}},_i=({schema:e={},className:t,...n})=>{m();let{designer:r}=gi(n);return(0,Q.jsx)(`div`,{className:t,...r,children:(0,Q.jsx)(hi,{items:[],config:e})})},vi=({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:G(`flex items-start pt-4`,g===`right`?`border-l`:`border-r`,h),children:(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>S(!1),"aria-label":b(`detail.openDiscussion`),children:(0,Q.jsx)(dt,{className:`h-4 w-4`})})}):(0,Q.jsxs)(`div`,{className:G(`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)(V,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:b(`detail.discussion`)})]}),v&&(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.closeDiscussion`),children:(0,Q.jsx)(z,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,Q.jsx)(hi,{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:G(``,h),children:v&&x?(0,Q.jsxs)(q,{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)(V,{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)(V,{className:`h-4 w-4`}),b(`detail.discussion`)]}),(0,Q.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.hideDiscussion`),children:(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(hi,{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`)})]})})},yi=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}},bi=({schema:e={},className:t,...n})=>{m();let r=k(),{designer:i}=yi(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)(vi,{items:r?.items||[],config:a,onAddComment:r?.onAddComment,onAddReply:r?.onAddReply,onToggleReaction:r?.onToggleReaction,mentionSuggestions:r?.mentionSuggestions,onUploadAttachments:r?.onUploadAttachments})})},xi=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}},Si=({schema:e={},className:t,...n})=>{let r=m(),{translateOptions:i}=gn(),{designer:a}=xi(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,u=/(^|[_-\s])(closed_)?(lost|failed?|cancell?ed|失败|流失|丢单|败)([_-\s]|$)/i,d=/(^|[_-\s])(closed_)?(won|success|成交|赢|完成)([_-\s]|$)/i,f=c.map(e=>{if(e.terminal)return e.terminal;let t=`${String(e.value??``)} ${String(e.label??``)}`;if(u.test(t))return`lost`;if(d.test(t))return`won`}),p=f.findIndex(e=>e===`lost`),h=p===-1?c:c.slice(0,p),g=p===-1?[]:c.slice(p),_=p===-1?f:f.slice(0,p),v=c.findIndex(e=>e.value===l);v<0&&(v=-1);let y=p!==-1&&v>=p;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:G(`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:G(`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=p+t===v;return(0,Q.jsx)(`div`,{role:`listitem`,"aria-current":n?`step`:void 0,className:G(`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=f[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:G(`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`)})})]})},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}},wi=({schema:e={},className:t,...n})=>{let r=m(),{designer:i}=Ci(n),a=o(),{language:s}=Fe(),c=gn(),l=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],u=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:[],d=r?.objectName||``,f=u.length>0?u:Array.isArray(l)&&l.every(e=>typeof e==`string`)?l:[],p=f.length>0&&!!d,{item:h}=T(`object`,p?d:null),g=p?(()=>{let e=Array.isArray(h?.actions)?h.actions:[],t=new Map(e.map(e=>[e.name,e]));return f.map(e=>t.get(e)).filter(e=>!!e)})():Array.isArray(l)?l:[],_=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(_.length>0&&d&&!_.every(e=>a.can(d,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 v=e.location||`record_header`,{getActionsForLocation:b,executeAction:x}=y({actions:g,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}}),S=g.length>0?b(v):[];if(S.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 C=e.align||`end`,w=C===`start`?`justify-start`:C===`center`?`justify-center`:`justify-end`;return(0,Q.jsx)(`div`,{className:G(`flex flex-wrap items-center gap-2`,v===`record_header`&&!e.inline&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,w,t),role:`toolbar`,"aria-label":e.aria?.label||`Quick actions`,...i,children:S.map((t,n)=>(0,Q.jsx)(Ti,{action:t,record:r?.data,variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,label:(()=>{let e=W(t.label,s)||t.name||`Action ${n+1}`;return t.name?c.actionLabel(d||void 0,t.name,e):e})(),onRun:async()=>{typeof t.onClick==`function`?await t.onClick():t.name&&await x(t.name)}},t.name||`qa-${n}`))})};function Ti({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=f(e.disabled),u=h(typeof l==`string`?l:void 0,c);return(0,Q.jsxs)(q,{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)(Ut,{className:`mr-2 h-4 w-4 animate-spin`}),i]})}var Ei=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}},Di=new Set([`created`,`updated`,`assigned`,`shared`,`deleted`]),Oi=({schema:e={},className:t,...n})=>{let{designer:r}=Ei(n),i=m(),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=e.unknownUserText??e.properties?.unknownUserText,l=Number(e.limit??e.properties?.limit??50)||50,u=i?.objectName,d=i?.data?.id??i?.data?._id??i?.recordId,f=i?.dataSource,p=a===void 0&&!!f?.find&&!!u&&d!=null,[h,g]=Z.useState(null),[_,v]=Z.useState(!1);Z.useEffect(()=>{if(!p)return;let e=!1;return v(!0),Promise.resolve(f.find(`sys_activity`,{$filter:{object_name:u,record_id:d},$orderby:{timestamp:`desc`},$top:Math.max(1,l)})).then(t=>{if(e)return;let n=(t?.data??t?.records??[]).filter(e=>Di.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}});g(n)}).catch(()=>{e||g([])}).finally(()=>{e||v(!1)}),()=>{e=!0}},[p,f,u,d,l]);let y=a??h??[],b=o??(p&&h===null?_||!0:!1);return(0,Q.jsx)(`div`,{className:t,...r,children:(0,Q.jsx)(jr,{entries:y,loading:b,emptyText:s,unknownUserText:c})})},ki=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}},Ai=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),ji=(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,...i})=>{let a=m(),o=gn(),{t:s}=$(),{designer:c}=ki(i),l=r().appName,u=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],d=a?.recordId,f=a?.dataSource,[p,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(u.map(e=>`${e.objectName}:${e.relationshipField}:${e.limit??3}`));if(Z.useEffect(()=>{if(!_||!f?.find||!d||u.length===0)return;let e=`${d}::${x}`;if(b.current===e)return;b.current=e,h(e=>{let t={...e};for(let n of u)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 f.find(e.objectName,{$filter:{[e.relationshipField]:d},$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=[...u],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)},[_,f,d,x]),u.length===0)return null;let S=e.hideEmpty!==!1,[C,w]=Z.useState(!1),T=new Set(u.filter(e=>{let t=p[e.objectName];return S&&t&&!t.loading&&!t.error&&t.total===0}).map(e=>e.objectName)),E=u.filter(e=>C||!T.has(e.objectName)),D=u.filter(e=>T.has(e.objectName)).map(e=>e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:Ai(e.objectName)}):Ai(e.objectName)));return(0,Q.jsxs)(`div`,{ref:g,className:G(`flex flex-col gap-3`,e.className,t),...c,children:[E.map(e=>{let t=e.objectName,r=p[t]||{loading:!0,total:0,items:[]};return(0,Q.jsxs)(Rt,{className:`overflow-hidden`,children:[(0,Q.jsxs)(kt,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,Q.jsx)(rn,{className:`text-sm font-semibold tracking-tight truncate`,children:e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:Ai(e.objectName)}):Ai(e.objectName))}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!r.loading&&(0,Q.jsx)(lt,{variant:`secondary`,className:`tabular-nums`,children:r.total}),l&&d&&(0,Q.jsx)(n,{to:`/apps/${l}/${e.objectName}?filter%5B${e.relationshipField}%5D=${encodeURIComponent(String(d))}`,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)(Qt,{className:`p-0`,children:r.loading?(0,Q.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,Q.jsx)(le,{className:`h-3.5 w-4/5`}),(0,Q.jsx)(le,{className:`h-3.5 w-3/5`}),(0,Q.jsx)(le,{className:`h-3.5 w-2/3`})]}):r.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:r.items.map(t=>{let r=t.id||t._id,i=ji(t,e.displayField),a=r?`../${e.objectName}/record/${encodeURIComponent(String(r))}`:void 0;return(0,Q.jsx)(`li`,{className:`px-4 py-2`,children:a?(0,Q.jsxs)(n,{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:i}),(0,Q.jsx)(Y,{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:i})},String(r||i))})})})]},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(` · `),`)`]})]})]})},Ni={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 Pi(e){let t=e?.properties??{};return{...e,...t}}var Fi=({schema:e={},className:t})=>{let n=Pi(e),r=m(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,{language:s}=Fe(),c=W(n.title,s),l=W(n.body,s),u=W(n.action?.label,s),d=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,p=Ni[d],g=n.icon||p.icon,_=f(n.visible),v=h(_,{record:i}),b=Z.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||W(n.title,`en`)||d;return`os.record-alert:${a}:${o??`_`}:${e}`},[n.dismissible,n.dismissKey,n.title,d,a,o]),[x,S]=Z.useState(()=>{if(!b||typeof window>`u`)return!1;try{return window.localStorage.getItem(b)===`1`}catch{return!1}}),C=n.action?.actionName,{item:w}=T(`object`,C&&a?a:null),E=Z.useMemo(()=>{if(!(!C||!w?.actions))return w.actions.find(e=>e.name===C)},[C,w]),{executeAction:D}=y({actions:Z.useMemo(()=>E?[E]:[],[E]),context:{record:i,recordId:o,objectName:a}});return x||!i||Object.keys(i).length===0||_!==void 0&&!v?null:(0,Q.jsxs)(pt,{className:G(`relative pr-12`,p.wrap,t),role:d===`error`?`alert`:`status`,"aria-live":d===`error`?`assertive`:`polite`,children:[(0,Q.jsx)(At,{name:g,className:`h-4 w-4`,"aria-hidden":`true`}),c?(0,Q.jsx)(on,{children:c}):null,l||E?(0,Q.jsxs)(qe,{children:[l?(0,Q.jsx)(`p`,{className:`mb-2 last:mb-0`,children:l}):null,E?(0,Q.jsx)(q,{size:`sm`,variant:n.action?.variant||(d===`error`?`destructive`:`default`),onClick:()=>{E?.name&&D(E.name)},children:u||E.label||E.name}):null]}):null,n.dismissible?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{if(S(!0),b)try{window.localStorage.setItem(b,`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)(At,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},Ii=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)}},Li=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()}},Ri=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=$(),s=t?.label||t?.field||``,c=t?Ii(t.pendingValue):``,l=t?Ii(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=Li(u.updated_at??t?.currentVersion),[p,m]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,Q.jsx)(hn,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,Q.jsxs)(Ae,{className:`max-w-lg`,children:[(0,Q.jsx)(Me,{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)(He,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(oe,{children:o(`detail.concurrentUpdateTitle`)}),(0,Q.jsxs)(re,{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)(dn,{className:`gap-2 sm:gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:G(Ot({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:G(Ot({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:G(Ot({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function zi(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}function Bi(e){let t=e?.message||e?.error||String(e??`Save failed`);return String(t).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``)}async function Vi(e,t,n,r,i){if(typeof e?.update==`function`)await e.update(t,n,r,i);else if(typeof e?.updateOne==`function`)await e.updateOne(t,n,r,i);else if(typeof e?.patch==`function`)await e.patch(t,n,r,i);else throw Error(`[InlineEditSaveBar] DataSource exposes no update/updateOne/patch method; cannot persist inline edit`)}var Hi=({dataSource:e,objectName:t,recordId:n,data:r,refresh:i,fieldLabelFor:a,onFieldSave:o,locked:s=!1,lockedHint:c,className:l})=>{let{t:u}=$(),d=ee(),[f,p]=Z.useState(null),[m,h]=Z.useState(!1),g=!!e&&!!t&&n!=null,_=Z.useCallback((e,t)=>{let n=Object.keys(e),r=t?.currentRecord??null;if(n.length===1){let i=n[0];return{field:i,label:a?.(i),pendingValue:e[i],currentValue:r?r[i]:void 0,currentVersion:t?.currentVersion,currentRecord:r}}let i=r?Object.fromEntries(n.map(e=>[e,r[e]])):void 0;return{field:n.join(`, `),label:u(`detail.concurrentUpdateRecordLabel`,{defaultValue:`this record`}),pendingValue:e,currentValue:i,currentVersion:t?.currentVersion,currentRecord:r}},[a,u]),v=Z.useCallback(async()=>{if(!d)return;let a=d.draft,s=Object.entries(a);if(s.length===0){d.reset();return}d.setSaving(!0),d.setError(null);try{if(o)for(let[e,t]of s)await o(e,t);else if(g){let o=typeof r?.updated_at==`string`?r.updated_at:void 0;await Vi(e,t,n,a,o?{ifMatch:o}:void 0),await i?.()}d.reset()}catch(e){zi(e)&&g?p(_(a,e)):d.setError(Bi(e))}finally{d.setSaving(!1)}},[d,o,g,r,e,t,n,i,_]),y=Z.useCallback(()=>{p(null),h(!1)},[]),b=Z.useCallback(async()=>{h(!0);try{await i?.()}finally{d?.reset(),y()}},[i,d,y]),x=Z.useCallback(async()=>{if(!f||!g){y();return}h(!0);try{await Vi(e,t,n,d?.draft??{},f.currentVersion?{ifMatch:f.currentVersion}:void 0),await i?.(),d?.reset()}catch(e){d?.setError(Bi(e))}finally{y()}},[f,g,d,e,t,n,i,y]),S=!!d?.editing,C=!!d?.saving,w=d?.cancel,T=!!f;return Z.useEffect(()=>{if(!S)return;let e=e=>{if(e.key===`Enter`&&(e.metaKey||e.ctrlKey)){if(C||s||T)return;e.preventDefault(),v();return}if(e.key===`Escape`){if(e.defaultPrevented||C||T||document.querySelector(`[data-radix-popper-content-wrapper], [role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`))return;e.preventDefault(),w?.()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[S,C,s,T,v,w]),!d||!d.editing?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:G(`sticky bottom-0 z-30 mt-4 flex flex-wrap items-center justify-end gap-2 rounded-md border bg-background/95 px-3 py-2 shadow-sm backdrop-blur supports-[backdrop-filter]:bg-background/80`,l),role:`region`,"aria-label":u(`detail.editFieldsInline`),children:[d.error&&(0,Q.jsx)(`div`,{role:`alert`,className:`mr-auto max-w-md rounded-md border border-destructive/20 bg-destructive/10 px-2 py-1 text-xs text-destructive`,children:d.error}),(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:d.cancel,disabled:d.saving,className:`gap-2`,children:[(0,Q.jsx)(z,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:u(`detail.cancel`)})]}),(0,Q.jsxs)(q,{variant:`default`,size:`sm`,onClick:v,disabled:d.saving||s,className:`gap-2`,title:s?c:void 0,children:[d.saving?(0,Q.jsx)(Ut,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(Gt,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:d.saving?u(`detail.saving`):u(`detail.save`)})]})]}),(0,Q.jsx)(Ri,{open:!!f,conflict:f,busy:m,onCancel:y,onReload:b,onOverwrite:x})]})},Ui=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`]),Wi=480,Gi=95;function Ki({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=Ui,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=$(),g=`objectui.drawerWidth.${i}`,[_,y]=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>=Wi)return t}}catch{}return null}),b=Z.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),x=b?{width:b,maxWidth:b}:void 0,S=Z.useRef(null),C=Z.useCallback(e=>{if(!p)return;e.preventDefault();let t=_??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);S.current={startX:e.clientX,startWidth:t};let n=e=>{let t=S.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*Gi/100:1600,i=Math.min(r,Math.max(Wi,t.startWidth+n));y(Math.round(i))},r=()=>{S.current,S.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{y(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]),w=s?.fields??{},T=(Object.keys(w).length?Object.keys(w):Object.keys(r)).filter(e=>!u.has(e)&&!e.startsWith(`__`)).filter(e=>e in r).filter(e=>!w[e]?.hidden).map(e=>{let t=w[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,scale:t.scale,format:t.format,reference_to:t.reference_to??t.reference??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)(Kt,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(U,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:x,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize drawer`,onPointerDown:C,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)(Be,{className:`sr-only`,children:(0,Q.jsx)(Ue,{children:n})}),(0,Q.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,Q.jsxs)(v,{canEdit:!!d,children:[(0,Q.jsx)(Hr,{dataSource:o,inlineEdit:!!d,schema:{type:`detail-view`,objectName:i,resourceId:String(a),data:r,showDelete:!!f,columns:l,fields:T,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},onDelete:f?async()=>{try{await f(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}:void 0}),(0,Q.jsx)(Hi,{onFieldSave:d?async(e,t)=>{try{await d(e,t)}catch(e){throw console.error(`[RecordDetailDrawer] inline field save failed:`,e),e}}:void 0})]})})]})})}function qi(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 Ji(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 Yi(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function Xi(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 Zi(e){if(!e)return null;let t=e.fields||{};for(let n of[e.primaryField,e.nameField,e.displayNameField])if(typeof n==`string`&&n.length>0&&n in t)return n;for(let e of[`name`,`full_name`,`title`,`subject`,`display_name`])if(e in t)return e;return null}function Qi(e,t,n=4){if(!e)return[];let r=Array.isArray(e.highlightFields)&&e.highlightFields.length>0?e.highlightFields:null;if(r){let t=Zi(e);return r.filter(e=>typeof e==`string`&&e.length>0&&e!==t).slice(0,n)}let i=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&&i.add(t),e.primaryField&&i.add(e.primaryField),e.nameField&&i.add(e.nameField),e.displayNameField&&i.add(e.displayNameField);for(let t of[`name`,`full_name`,`title`,`subject`,`display_name`])t in(e.fields||{})&&i.add(t);let a=[`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`],o=new Set([`currency`,`number`,`integer`,`decimal`,`percent`,`date`,`datetime`,`time`,`reference`,`lookup`,`user`,`owner`,`select`,`enum`,`multiselect`,`status`,`email`,`phone`,`url`,`text`,`string`]),s=[],c=e.fields||{};for(let e of a)if(e in c&&!i.has(e)&&s.push(e),s.length>=n)return s;for(let e of Object.keys(c)){if(s.includes(e)||i.has(e))continue;let t=c[e]?.type;if(!(t&&!o.has(t))&&(s.push(e),s.length>=n))break}return s}function $i(e,t={}){return{type:`page:header`,recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}}}function ea(e,t={}){let n=t.statusField??l(e),r=t.stages??(n?Xi(e,n):null),i=t.highlightFields??Qi(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 ta(e){if(!e)return null;let t=A(e);if(!t)return null;let n=e.fields||{},r=e=>{let t=n[e]||{};return{name:e,label:t.label||e,type:t.type||`text`,...t.options?{options:t.options}:{},...t.reference_to||t.reference?{reference_to:t.reference_to||t.reference}:{},...t.reference_field?{reference_field:t.reference_field}:{},...t.currency?{currency:t.currency}:{},...t.currencyConfig?{currencyConfig:t.currencyConfig}:{}}},i=Qn(t.reduce((e,t)=>e+t.fields.length,0));return t.map(e=>({...e.key===void 0?{}:{name:e.key,title:e.label??e.key},...e.icon?{icon:e.icon}:{},...e.description?{description:e.description}:{},...e.collapse===`none`?{}:{collapsible:!0},...e.collapse===`collapsed`?{defaultCollapsed:!0}:{},columns:i,fields:e.fields.map(r)}))}function na(e,t){return Array.isArray(t)&&t.length>0?t:ta(e)??void 0}function ra(e,t,n){return{type:`record:details`,sections:na(e,t),...n&&n.length>0?{hideFields:n}:{}}}function ia(e,t={}){let n=t.statusField??l(e),r=t.highlightFields??Qi(e,n),i=[{label:`Details`,value:`details`,children:[ra(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}:{}}),n=t=>({label:t.title||t.objectName,value:`related:${t.objectName}`,...t.icon?{icon:t.icon}:{},children:[e(t)]});if(t.relatedLayout===`tabs`)for(let e of t.related)i.push(n(e));else if(t.relatedLayout===`stack`)i.push({label:`Related`,value:`related`,children:t.related.map(e)});else{let r=t.related.filter(e=>e.isPrimary),a=t.related.filter(e=>!e.isPrimary);for(let e of r)i.push(n(e));a.length>0&&i.push({label:`Related`,value:`related`,children:a.map(e)})}}return t.showActivity&&i.push({label:`Activity`,value:`activity`,children:[{type:`record:activity`}]}),t.history&&i.push({label:`History`,value:`history`,children:[{type:`record:history`,entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText,unknownUserText:t.history.unknownUserText}]}),{type:`page:tabs`,items:i}}function aa(){return{type:`record:discussion`}}function oa(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...Yi(n.header)):r.push($i(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...Yi(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...Yi(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...Yi(n.highlights)):r.push(...ea(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(...Yi(n.tabs));else if(`details`in n&&n.details!==void 0){let i=Yi(n.details),o=ia(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(ia(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(...Yi(n.discussion)):t.hideDiscussion||r.push(aa());let o=[{name:`main`,width:`full`,components:r}],s=Yi(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 sa=t({DetailSection:()=>ur,DetailView:()=>Hr,RecordActivityRenderer:()=>_i,RecordAlertRenderer:()=>Fi,RecordChatterRenderer:()=>bi,RecordDetailsRenderer:()=>Gr,RecordHighlightsRenderer:()=>Zr,RecordHistoryRenderer:()=>Oi,RecordPathRenderer:()=>Si,RecordQuickActionsRenderer:()=>wi,RecordReferenceRailRenderer:()=>Mi,RecordRelatedListRenderer:()=>Yr,RelatedList:()=>mr,buildDefaultPageSchema:()=>oa});x.register(`detail-view`,Hr,{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:[]}}),x.register(`detail-section`,ur,{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`}]}),x.register(`related-list`,mr,{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`}]}),x.register(`detail`,Hr,{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`}]}),x.register(`record:details`,Gr,{namespace:`record`,category:`record`,label:`Record Details`,icon:`FileText`,inputs:[{name:`columns`,type:`enum`,label:`Columns`,enum:[`1`,`2`,`3`,`4`],defaultValue:`2`,description:`Number of columns for field layout (1-4)`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`auto`,`custom`],defaultValue:`auto`,description:`auto uses the object highlightFields; custom uses explicit sections`},{name:`sections`,type:`array`,label:`Sections`,description:`Section IDs to show (required when layout is "custom")`},{name:`fields`,type:`array`,label:`Fields`,description:`Explicit field list (overrides highlightFields)`}]}),x.register(`record:related_list`,Yr,{namespace:`record`,category:`record`,label:`Related List`,icon:`List`,inputs:[{name:`objectName`,type:`string`,label:`Related Object`,required:!0,description:`Related object name (e.g. "task")`},{name:`relationshipField`,type:`string`,label:`Relationship Field`,required:!0,description:`Field on the related object pointing back to this record`},{name:`columns`,type:`array`,label:`Columns`,required:!0,description:`Fields to display in the related list`},{name:`sort`,type:`array`,label:`Sort`},{name:`limit`,type:`number`,label:`Limit`,defaultValue:5,description:`Records to display initially`},{name:`filter`,type:`array`,label:`Filter`,description:`Additional filter criteria`},{name:`title`,type:`string`,label:`Title`},{name:`showViewAll`,type:`boolean`,label:`Show "View All"`,defaultValue:!0},{name:`actions`,type:`array`,label:`Actions`,description:`Action IDs available for related records`}]}),x.register(`record:highlights`,Zr,{namespace:`record`,category:`record`,label:`Highlights Panel`,icon:`Star`,inputs:[{name:`fields`,type:`array`,label:`Fields`,required:!0,description:`Key fields to highlight (1-7), bare names or {name,label?,icon?,type?}`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`horizontal`,`vertical`],defaultValue:`horizontal`,description:`Layout orientation for highlight fields`}]}),x.register(`record:activity`,_i,{namespace:`record`,category:`record`,label:`Activity Timeline`,icon:`Activity`}),x.register(`record:chatter`,bi,{namespace:`record`,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`}),x.register(`record:discussion`,bi,{namespace:`record`,category:`record`,label:`Discussion`,icon:`MessageSquare`}),x.register(`record:path`,Si,{namespace:`record`,category:`record`,label:`Path / Stepper`,icon:`GitBranch`,inputs:[{name:`statusField`,type:`string`,label:`Status Field`,required:!0,description:`Field representing the current status/stage`},{name:`stages`,type:`array`,label:`Stages`,description:`Explicit stage definitions [{ value, label }] (else derived from field metadata)`}]}),x.register(`record:quick_actions`,wi,{namespace:`record`,category:`record`,label:`Quick Actions`,icon:`Zap`}),x.register(`record:history`,Oi,{namespace:`record`,category:`record`,label:`History Timeline`,icon:`Clock`}),x.register(`record:reference_rail`,Mi,{namespace:`record`,category:`record`,label:`Reference Rail`,icon:`PanelRight`}),x.register(`record:alert`,Fi,{namespace:`record`,category:`record`,label:`Alert Banner`,icon:`AlertTriangle`}),x.register(`permission-facet-link`,ir,{namespace:`field`,skipFallback:!0});export{Ji as a,Hi as c,Hn as d,Zi as i,vi as l,oa as n,Ki as o,ta as r,qi as s,sa as t,li as u};
@@ -1 +1 @@
1
- import{r as e}from"./vendor-react-BKSb6vFP.js";import{Ut as t}from"./ui-components-CHaxvtjc.js";var n=e();function r({cards:e=6}){return(0,n.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-7 w-56`}),(0,n.jsx)(t,{className:`h-4 w-80`})]}),(0,n.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:Array.from({length:4}).map((e,r)=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-2`,children:[(0,n.jsx)(t,{className:`h-4 w-20`}),(0,n.jsx)(t,{className:`h-8 w-24`}),(0,n.jsx)(t,{className:`h-3 w-16`})]},`stat-${r}`))}),(0,n.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:e}).map((e,r)=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-3`,children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,n.jsx)(t,{className:`h-5 w-32`}),(0,n.jsx)(t,{className:`h-5 w-5 rounded-full`})]}),(0,n.jsx)(t,{className:`h-40 w-full`}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(t,{className:`h-3 w-16`}),(0,n.jsx)(t,{className:`h-3 w-12`})]})]},`widget-${r}`))})]})}function i({fields:e=8,columns:r=2}){return(0,n.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,n.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,n.jsx)(t,{className:`h-8 w-8 rounded`}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-6 w-48`}),(0,n.jsx)(t,{className:`h-4 w-32`})]})]}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(t,{className:`h-9 w-20`}),(0,n.jsx)(t,{className:`h-9 w-20`})]})]}),(0,n.jsx)(t,{className:`h-5 w-24`}),(0,n.jsx)(`div`,{className:`grid grid-cols-1 ${r===2?`md:grid-cols-2`:``} gap-4`,children:Array.from({length:e}).map((e,r)=>(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-4 w-24`}),(0,n.jsx)(t,{className:`h-9 w-full`})]},`field-${r}`))}),(0,n.jsxs)(`div`,{className:`space-y-3 pt-4 border-t`,children:[(0,n.jsx)(t,{className:`h-5 w-32`}),(0,n.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,r)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,n.jsx)(t,{className:`h-8 w-8 rounded-full`}),(0,n.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,n.jsx)(t,{className:`h-4 w-40`}),(0,n.jsx)(t,{className:`h-3 w-24`})]})]},`related-${r}`))})]})]})}export{r as n,i as t};
1
+ import{r as e}from"./vendor-react-BKSb6vFP.js";import{Gt as t}from"./ui-components-BluZyuZX.js";var n=e();function r({cards:e=6}){return(0,n.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-7 w-56`}),(0,n.jsx)(t,{className:`h-4 w-80`})]}),(0,n.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:Array.from({length:4}).map((e,r)=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-2`,children:[(0,n.jsx)(t,{className:`h-4 w-20`}),(0,n.jsx)(t,{className:`h-8 w-24`}),(0,n.jsx)(t,{className:`h-3 w-16`})]},`stat-${r}`))}),(0,n.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:e}).map((e,r)=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-3`,children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,n.jsx)(t,{className:`h-5 w-32`}),(0,n.jsx)(t,{className:`h-5 w-5 rounded-full`})]}),(0,n.jsx)(t,{className:`h-40 w-full`}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(t,{className:`h-3 w-16`}),(0,n.jsx)(t,{className:`h-3 w-12`})]})]},`widget-${r}`))})]})}function i({fields:e=8,columns:r=2}){return(0,n.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,n.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,n.jsx)(t,{className:`h-8 w-8 rounded`}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-6 w-48`}),(0,n.jsx)(t,{className:`h-4 w-32`})]})]}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(t,{className:`h-9 w-20`}),(0,n.jsx)(t,{className:`h-9 w-20`})]})]}),(0,n.jsx)(t,{className:`h-5 w-24`}),(0,n.jsx)(`div`,{className:`grid grid-cols-1 ${r===2?`md:grid-cols-2`:``} gap-4`,children:Array.from({length:e}).map((e,r)=>(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-4 w-24`}),(0,n.jsx)(t,{className:`h-9 w-full`})]},`field-${r}`))}),(0,n.jsxs)(`div`,{className:`space-y-3 pt-4 border-t`,children:[(0,n.jsx)(t,{className:`h-5 w-32`}),(0,n.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,r)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,n.jsx)(t,{className:`h-8 w-8 rounded-full`}),(0,n.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,n.jsx)(t,{className:`h-4 w-40`}),(0,n.jsx)(t,{className:`h-3 w-24`})]})]},`related-${r}`))})]})]})}export{r as n,i as t};