@objectstack/console 9.4.0 → 9.5.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 (155) hide show
  1. package/dist/assets/{AdapterProvider-BNNEwHx0.js → AdapterProvider-SUUXFZyj.js} +1 -1
  2. package/dist/assets/{AiPendingActionsPage-DOSHy962.js → AiPendingActionsPage-CO8ZvJjv.js} +1 -1
  3. package/dist/assets/{ApiConsolePage-CruwU0Up.js → ApiConsolePage-Lut37HSM.js} +1 -1
  4. package/dist/assets/AppDocsIndex-pApFrxYy.js +1 -0
  5. package/dist/assets/{AppManagementPage-BohnYqad.js → AppManagementPage-02_IDuK5.js} +1 -1
  6. package/dist/assets/{ApprovalsInboxPage-BGmv2uNL.js → ApprovalsInboxPage-jrOq7K_-.js} +1 -1
  7. package/dist/assets/{AuditLogPage-KrpMMNiw.js → AuditLogPage-dNTjEy4d.js} +1 -1
  8. package/dist/assets/{ComponentNavView-JMyYlvFq.js → ComponentNavView-DZTCPZQw.js} +1 -1
  9. package/dist/assets/{ConsoleFloatingChatbot-C7wdj16w.js → ConsoleFloatingChatbot-aVi2RipX.js} +1 -1
  10. package/dist/assets/{DashboardView-DUqOAEyx.js → DashboardView-tRpQP3s_.js} +1 -1
  11. package/dist/assets/{DashboardWidgetInspector-Dhe9hv9A.js → DashboardWidgetInspector-BZXT2waT.js} +1 -1
  12. package/dist/assets/{DeveloperHubPage-D4ErhCeD.js → DeveloperHubPage-D1Gr8nhZ.js} +1 -1
  13. package/dist/assets/{ExpressionProvider-Cj6XEnZF.js → ExpressionProvider-w-i3oDR9.js} +1 -1
  14. package/dist/assets/{FlowRunsPage-CJsr4xgF.js → FlowRunsPage-CntX-tGf.js} +1 -1
  15. package/dist/assets/{IntegrationsPage-zbcGFqxM.js → IntegrationsPage-BoWdvbMh.js} +1 -1
  16. package/dist/assets/{InterfaceListPage-BJRTel_h.js → InterfaceListPage-CtbkRAlr.js} +1 -1
  17. package/dist/assets/{ManagedByBadge-DOMbPlbf.js → ManagedByBadge-BYezQxs4.js} +1 -1
  18. package/dist/assets/{MarketplaceInstalledPage-CSgqJuot.js → MarketplaceInstalledPage-CuPkbetm.js} +1 -1
  19. package/dist/assets/{MarketplacePackagePage-0TU_eJIx.js → MarketplacePackagePage-CKJ_NEnI.js} +1 -1
  20. package/dist/assets/{MarketplacePage-YO75QMEO.js → MarketplacePage-BTGE5DuS.js} +1 -1
  21. package/dist/assets/{MetadataInspector-CamKLf7x.js → MetadataInspector-eUKibp4P.js} +1 -1
  22. package/dist/assets/{MetadataProvider-Bxendsnd.js → MetadataProvider-DVGxIr-Y.js} +1 -1
  23. package/dist/assets/{PageView-z1PfFaQS.js → PageView-CoZhWVVc.js} +1 -1
  24. package/dist/assets/{ProfilePage-5QuBSV4z.js → ProfilePage-qRetxYIs.js} +1 -1
  25. package/dist/assets/{PublicFormsPage-CMTz6MfD.js → PublicFormsPage-Cpy38W-9.js} +1 -1
  26. package/dist/assets/{RecordDetailView-DOcGflPY.js → RecordDetailView-CD05ObAk.js} +1 -1
  27. package/dist/assets/{RecordFormPage-C1M3jdnG.js → RecordFormPage-OOn5fyVq.js} +1 -1
  28. package/dist/assets/{ReportDefaultInspector-DDBJTAYx.js → ReportDefaultInspector--g5afStS.js} +1 -1
  29. package/dist/assets/{ReportView-CItKDFSn.js → ReportView-w6a1FyHp.js} +1 -1
  30. package/dist/assets/{RuntimeDraftBar-QF3pF8K2.js → RuntimeDraftBar-e5TgPCLp.js} +1 -1
  31. package/dist/assets/{SearchResultsPage-Mdphx8Ca.js → SearchResultsPage-B2D6vns1.js} +1 -1
  32. package/dist/assets/{SettingsHub-CtfOIqOJ.js → SettingsHub-Bi06edK0.js} +1 -1
  33. package/dist/assets/{SettingsView-One2JiPG.js → SettingsView-zJInYHeN.js} +1 -1
  34. package/dist/assets/{SystemHubPage-Dzi5_s3T.js → SystemHubPage-DV53wHHA.js} +1 -1
  35. package/dist/assets/architecture-7EHR7CIX-BdMnUPE0.js +1 -0
  36. package/dist/assets/architectureDiagram-3BPJPVTR-SscyJlk0.js +36 -0
  37. package/dist/assets/blockDiagram-GPEHLZMM-D6-9deBJ.js +132 -0
  38. package/dist/assets/c4Diagram-AAUBKEIU-VLeNt7tD.js +10 -0
  39. package/dist/assets/channel-ByUUDCyR.js +1 -0
  40. package/dist/assets/chunk-2J33WTMH-DyXQVMuc.js +1 -0
  41. package/dist/assets/chunk-3OPIFGDE-3g0dk_di.js +62 -0
  42. package/dist/assets/chunk-4BX2VUAB-BpAZJ7ZC.js +1 -0
  43. package/dist/assets/chunk-55IACEB6-BhOjfCrn.js +1 -0
  44. package/dist/assets/chunk-5ZQYHXKU-DG12s6lW.js +2 -0
  45. package/dist/assets/chunk-727SXJPM-DwSFE_v-.js +206 -0
  46. package/dist/assets/chunk-AQP2D5EJ-DWgSztUW.js +231 -0
  47. package/dist/assets/chunk-BSJP7CBP-okvguKD4.js +1 -0
  48. package/dist/assets/chunk-CSCIHK7Q-DfSAlgJl.js +124 -0
  49. package/dist/assets/chunk-FMBD7UC4-CZzqt4RW.js +15 -0
  50. package/dist/assets/chunk-KSCS5N6A-IxEh4Ag5.js +10 -0
  51. package/dist/assets/chunk-L5ZTLDWV-DW1lPBoG.js +1 -0
  52. package/dist/assets/chunk-LZXEDZCA-C_-aaYcd.js +1 -0
  53. package/dist/assets/chunk-ND2GUHAM-C1toj0H3.js +1 -0
  54. package/dist/assets/chunk-NNHCCRGN-Ud6GGuM7.js +159 -0
  55. package/dist/assets/chunk-NZK2D7GU-H2MwBqQV.js +1 -0
  56. package/dist/assets/chunk-O5CBEL6O-BzyWPZhZ.js +70 -0
  57. package/dist/assets/chunk-QZHKN3VN-ujroCBCz.js +1 -0
  58. package/dist/assets/chunk-WU5MYG2G-DwQt8tuZ.js +1 -0
  59. package/dist/assets/chunk-XPW4576I-DPNxFY7Q.js +32 -0
  60. package/dist/assets/classDiagram-4FO5ZUOK-B7mTyEXp.js +1 -0
  61. package/dist/assets/classDiagram-v2-Q7XG4LA2-B7mTyEXp.js +1 -0
  62. package/dist/assets/cose-bilkent-S5V4N54A-HKJWDQRL.js +1 -0
  63. package/dist/assets/cytoscape.esm-h6BdjjI9.js +321 -0
  64. package/dist/assets/dagre-BM42HDAG-CU8nx02l.js +4 -0
  65. package/dist/assets/dagre-Bx709z4p.js +1 -0
  66. package/dist/assets/{data-adapter-Dl2IvbPC.js → data-adapter-BEs3zHWP.js} +1 -1
  67. package/dist/assets/diagram-2AECGRRQ-CormMz8j.js +43 -0
  68. package/dist/assets/diagram-5GNKFQAL-Dh1SagBx.js +10 -0
  69. package/dist/assets/diagram-KO2AKTUF-DcG6Z05V.js +3 -0
  70. package/dist/assets/diagram-LMA3HP47-DrVLZ6ZE.js +24 -0
  71. package/dist/assets/diagram-OG6HWLK6-C4_MMUc2.js +24 -0
  72. package/dist/assets/dist-Cna34lZe.js +1 -0
  73. package/dist/assets/erDiagram-TEJ5UH35-BZH_OrBL.js +85 -0
  74. package/dist/assets/eventmodeling-FCH6USID-CFiyy8DS.js +1 -0
  75. package/dist/assets/flowDiagram-I6XJVG4X-CnjHQUK0.js +162 -0
  76. package/dist/assets/{framework-D7UWfRl4.js → framework-BSpP7C0B.js} +11 -11
  77. package/dist/assets/ganttDiagram-6RSMTGT7-rVbHlqzo.js +292 -0
  78. package/dist/assets/gitGraph-WXDBUCRP-9vsQCBlr.js +1 -0
  79. package/dist/assets/gitGraphDiagram-PVQCEYII-CH2LgClA.js +106 -0
  80. package/dist/assets/graphlib-B8gBHxth.js +1 -0
  81. package/dist/assets/{highlighted-body-OFNGDK62-Dgcl8-h_.js → highlighted-body-OFNGDK62-BgGi60U1.js} +1 -1
  82. package/dist/assets/index-QQUFI17s.js +4 -0
  83. package/dist/assets/index-mrmp6qU6.css +2 -0
  84. package/dist/assets/info-J43DQDTF-CfWeH1Bg.js +1 -0
  85. package/dist/assets/infoDiagram-5YYISTIA-CRC7ojj-.js +2 -0
  86. package/dist/assets/ishikawaDiagram-YF4QCWOH-8v73fBR1.js +70 -0
  87. package/dist/assets/journeyDiagram-JHISSGLW-DbRK-WaU.js +139 -0
  88. package/dist/assets/kanban-definition-UN3LZRKU-BggLxHvZ.js +89 -0
  89. package/dist/assets/katex-Vhh-h91d.js +257 -0
  90. package/dist/assets/{marketplaceApi-Do90JxGv.js → marketplaceApi-C2Xs-8x9.js} +1 -1
  91. package/dist/assets/mergeServerFields-C7bGC7hp.js +7 -0
  92. package/dist/assets/mermaid-GHXKKRXX-DpdgSEiY.js +1 -0
  93. package/dist/assets/mermaid-parser.core-iuxcj-n_.js +3 -0
  94. package/dist/assets/mermaid.core-C41Aiku8.js +8 -0
  95. package/dist/assets/metadata-admin-B5BnMMNz.js +19 -0
  96. package/dist/assets/mindmap-definition-RKZ34NQL-kqhi9XCR.js +96 -0
  97. package/dist/assets/packet-YPE3B663-C0xexAqH.js +1 -0
  98. package/dist/assets/pie-LRSECV5Y-DbQVOiyX.js +1 -0
  99. package/dist/assets/pieDiagram-4H26LBE5-9fHcPmFE.js +30 -0
  100. package/dist/assets/{plugin-calendar-DSvXqOQV.js → plugin-calendar-DqouTXvx.js} +1 -1
  101. package/dist/assets/plugin-charts-Bg-32_xO.js +7 -0
  102. package/dist/assets/{plugin-chatbot-D6s22V14.js → plugin-chatbot-1Bip2OCu.js} +7 -7
  103. package/dist/assets/{plugin-dashboard-PEMuLOVn.js → plugin-dashboard-bF8okIBS.js} +1 -1
  104. package/dist/assets/plugin-form-DkI3TvRN.js +1 -0
  105. package/dist/assets/{plugin-gantt-CB1bbY8J.js → plugin-gantt-iFmeqHwf.js} +1 -1
  106. package/dist/assets/plugin-grid-KSDSYH4h.js +6 -0
  107. package/dist/assets/{plugin-kanban-BxxI6fit.js → plugin-kanban-CecteZ3L.js} +1 -1
  108. package/dist/assets/{plugin-map-B-TiJAz8.js → plugin-map-DD9uSXB0.js} +1 -1
  109. package/dist/assets/plugin-markdown-BR56zxrV.js +113 -0
  110. package/dist/assets/{plugin-report-jQPIUbaf.js → plugin-report-KJw4u9x7.js} +1 -1
  111. package/dist/assets/{plugin-timeline-BNRp2sKQ.js → plugin-timeline-D8Lkn6Qk.js} +1 -1
  112. package/dist/assets/{plugin-view-BeiRMGis.js → plugin-view-DJrJBUdE.js} +1 -1
  113. package/dist/assets/{plugins-views-D0zS0yz2.js → plugins-views-BhPRkeWo.js} +1 -1
  114. package/dist/assets/quadrantDiagram-W4KKPZXB-CaMxia_k.js +7 -0
  115. package/dist/assets/radar-GUYGQ44K-DapGfmwo.js +1 -0
  116. package/dist/assets/requirementDiagram-4Y6WPE33-CXwY4Gdd.js +84 -0
  117. package/dist/assets/{resolveActionParams-eRBdMG9b.js → resolveActionParams-C1HIbU1j.js} +1 -1
  118. package/dist/assets/rough.esm-CSKSodPl.js +1 -0
  119. package/dist/assets/runtime-config-BeHVOPm3.js +1 -0
  120. package/dist/assets/sankeyDiagram-5OEKKPKP-KEb3hSPZ.js +40 -0
  121. package/dist/assets/sequenceDiagram-3UESZ5HK-BfbOOh3M.js +162 -0
  122. package/dist/assets/{skeletons-DNzeXHI1.js → skeletons-qACAXjbp.js} +1 -1
  123. package/dist/assets/src-CVz7aDdY.js +1 -0
  124. package/dist/assets/{src-LBsSMdO2.js → src-CZAP7E6v.js} +1 -1
  125. package/dist/assets/stateDiagram-AJRCARHV-BLJI6xj_.js +1 -0
  126. package/dist/assets/stateDiagram-v2-BHNVJYJU-DPQJ1_JB.js +1 -0
  127. package/dist/assets/timeline-definition-PNZ67QCA-aiklZXLq.js +120 -0
  128. package/dist/assets/treeView-BLDUP644-Byr_7ESV.js +1 -0
  129. package/dist/assets/treemap-LRROVOQU-B6DiJnlo.js +1 -0
  130. package/dist/assets/{types-D2P-aXxM.js → types-CW2d8LfD.js} +1 -1
  131. package/dist/assets/ui-components-D7IOmcqZ.js +42 -0
  132. package/dist/assets/{ui-layout-DYMEUX5t.js → ui-layout-toYvxCNh.js} +1 -1
  133. package/dist/assets/{useActionModal-VGsmP3uO.js → useActionModal-yawBu4nr.js} +1 -1
  134. package/dist/assets/vendor-charts-fo4ZbB_t.js +39 -0
  135. package/dist/assets/vendor-i18n-Bz5UncqE.js +1 -0
  136. package/dist/assets/{vendor-markdown-BXE1apAC.js → vendor-markdown-DIJxJfmj.js} +3 -3
  137. package/dist/assets/vennDiagram-CIIHVFJN-DsKC4yvC.js +34 -0
  138. package/dist/assets/wardley-L42UT6IY-f1iiSYpj.js +1 -0
  139. package/dist/assets/wardleyDiagram-YWT4CUSO-DbrUmWlY.js +78 -0
  140. package/dist/assets/xychartDiagram-2RQKCTM6-B4biX1Sz.js +7 -0
  141. package/dist/index.html +4 -4
  142. package/package.json +1 -1
  143. package/dist/assets/index-BjfDho4T.js +0 -4
  144. package/dist/assets/index-CJFqfWpW.css +0 -2
  145. package/dist/assets/mergeServerFields-Co1NIO7_.js +0 -7
  146. package/dist/assets/mermaid-GHXKKRXX-BY4z2Mh6.js +0 -1
  147. package/dist/assets/metadata-admin-B-99o4dC.js +0 -19
  148. package/dist/assets/plugin-charts-EoSn84Ag.js +0 -7
  149. package/dist/assets/plugin-form-MXrWd_1Z.js +0 -1
  150. package/dist/assets/plugin-grid-D9HjQh3d.js +0 -6
  151. package/dist/assets/plugin-markdown-BUIHw2kZ.js +0 -113
  152. package/dist/assets/runtime-config-ir5bt3TX.js +0 -1
  153. package/dist/assets/ui-components-Clv7N77v.js +0 -42
  154. package/dist/assets/vendor-charts-DAigH0Ti.js +0 -39
  155. package/dist/assets/vendor-i18n-CdF5ccW5.js +0 -1
@@ -1,4 +1,4 @@
1
- import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,r as i,t as a}from"./vendor-react-DR370ovB.js";import{n as o,t as s}from"./infrastructure-ckitl7Ev.js";import{B as c,D as l,E as u,F as d,H as f,M as p,R as m,W as h,_ as g,dt as _,f as v,ft as y,g as b,h as x,lt as S,mt as C,r as w,z as T}from"./framework-D7UWfRl4.js";import{$n as E,$t as D,Aa as O,At as k,Bt as A,C as j,Cs as M,Da as N,Di as P,Ei as F,Fo as ee,Ft as te,G as ne,Gn as re,Gs as ie,Hi as ae,Ht as oe,I,Ja as se,Jn as L,Jo as ce,Js as le,K as R,Ka as ue,Ki as z,Ks as de,Lt as fe,M as pe,Ma as B,Mo as me,Mt as V,N as he,No as H,Ns as U,Nt as ge,Oi as _e,Ot as W,P as ve,Po as G,Pr as ye,Pt as K,Rr as be,Rt as xe,S as Se,Si as Ce,So as we,Sr as Te,Ss as Ee,Ta as De,Un as Oe,Ut as ke,Vr as Ae,Vt as je,Wn as Me,Wt as Ne,X as q,Xa as Pe,Xn as Fe,Xs as Ie,Ya as Le,Zi as Re,Zn as ze,Zo as Be,_r as Ve,ai as He,ar as Ue,at as We,bi as Ge,br as Ke,ca as qe,cc as Je,ci as Ye,cn as Xe,cr as Ze,d as Qe,dc as $e,di as et,dr as tt,ds as nt,ec as rt,en as it,er as at,fc as ot,fr as st,g as ct,gn as lt,gr as ut,hr as J,io as dt,ir as ft,it as pt,ja as mt,js as ht,jt as gt,kt as _t,lc as Y,lr as vt,m as yt,nc as bt,ni as xt,nn as St,no as Ct,nr as wt,nt as Tt,or as Et,pr as Dt,q as Ot,qi as kt,qn as X,ra as At,rc as jt,rr as Mt,rt as Nt,si as Pt,sn as Ft,sr as It,ta as Lt,tc as Rt,tn as zt,tr as Bt,ui as Vt,un as Ht,ur as Ut,vi as Wt,ws as Gt,xa as Kt,xi as qt,xs as Jt,yo as Yt,za as Xt,zi as Zt,zo as Qt}from"./ui-components-Clv7N77v.js";import{a as $t}from"./plugin-grid-D9HjQh3d.js";var Z=e(n(),1),Q=a(),en={grid:(0,Q.jsx)(dt,{className:`h-4 w-4`}),kanban:(0,Q.jsx)(Xt,{className:`h-4 w-4`}),gallery:(0,Q.jsx)(Le,{className:`h-4 w-4`}),calendar:(0,Q.jsx)(U,{className:`h-4 w-4`}),timeline:(0,Q.jsx)(Je,{className:`h-4 w-4`}),gantt:(0,Q.jsx)(Ye,{className:`h-4 w-4`}),map:(0,Q.jsx)(De,{className:`h-4 w-4`}),chart:(0,Q.jsx)(ht,{className:`h-4 w-4`})},tn={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`,chart:`Chart`},nn=({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(0,Q.jsxs)(D,{open:a,onOpenChange:o,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":tn[e],className:Y(`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:[en[e],(0,Q.jsx)(`span`,{className:`hidden sm:inline-block`,children:tn[e]}),(0,Q.jsx)(M,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(it,{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:Y(`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:[en[t],(0,Q.jsx)(`span`,{className:`flex-1 text-left`,children:tn[t]}),t===e&&(0,Q.jsx)(Gt,{className:`h-3.5 w-3.5`})]},t))})]})};function rn(e){return e?Ve[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function an(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}var on=({tabs:e,activeTab:t,onTabChange:n,className:r})=>{let i=Z.useMemo(()=>an(e),[e]),a=Z.useMemo(()=>i.find(e=>e.isDefault)?.name??i[0]?.name,[i]),[o,s]=Z.useState(a),c=t??o,l=Z.useCallback(e=>{s(e.name),n?.(e)},[n]);return i.length===0?null:(0,Q.jsx)(`div`,{className:Y(`px-2 sm:px-4 py-1 flex items-center gap-0.5 bg-background`,r),"data-testid":`view-tabs`,role:`tablist`,children:i.map(e=>{let t=rn(e.icon),n=c===e.name;return(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`h-7 px-2.5 py-1 text-xs rounded-md transition-colors duration-150`,n?`font-medium text-foreground bg-muted`:`text-muted-foreground hover:text-foreground hover:bg-transparent`),"data-testid":`view-tab-${e.name}`,role:`tab`,"aria-selected":n,onClick:()=>l(e),children:[t&&(0,Q.jsx)(t,{className:`h-3 w-3 mr-1.5`}),e.label]},e.name)})})},sn=({tabs:e,activeTab:t,onTabChange:n,className:r})=>{let i=Z.useMemo(()=>an(e),[e]),a=Z.useMemo(()=>i.find(e=>e.isDefault)?.name??i[0]?.name,[i]),[o,s]=Z.useState(a),c=t??o,l=Z.useMemo(()=>i.find(e=>e.name===c)??i[0],[i,c]),u=Z.useCallback(e=>{s(e.name),n?.(e)},[n]);if(i.length===0)return null;let d=rn(l?.icon);return(0,Q.jsx)(`div`,{className:Y(`px-2 py-1`,r),"data-testid":`view-tabs-select`,children:(0,Q.jsxs)(Ft,{children:[(0,Q.jsx)(lt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs font-medium text-foreground gap-1.5 max-w-[60vw] truncate`,"aria-label":`Switch view`,children:[d&&(0,Q.jsx)(d,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:l?.label??``}),(0,Q.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Xe,{align:`start`,className:`w-56 max-h-72 overflow-y-auto`,children:i.map(e=>{let t=rn(e.icon);return(0,Q.jsxs)(Ht,{onClick:()=>u(e),className:Y(`text-sm`,c===e.name&&`font-medium bg-muted`),"data-testid":`view-tab-select-${e.name}`,children:[t&&(0,Q.jsx)(t,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name)})})]})})};function cn({title:e,badge:t,onClear:n,clearLabel:r,defaultOpen:i=!0,children:a}){let[o,s]=Z.useState(i);return(0,Q.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 text-xs font-medium text-foreground/80 hover:text-foreground`,children:[(0,Q.jsx)(M,{className:Y(`h-3.5 w-3.5 transition-transform`,!o&&`-rotate-90`)}),e,typeof t==`number`&&t>0&&(0,Q.jsx)(`span`,{className:`ml-1 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 px-1 text-[10px] text-primary tabular-nums`,children:t})]}),n&&(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:r})]}),o&&(0,Q.jsx)(`div`,{className:`px-3 pb-3`,children:a})]})}function ln(e){let{t,allFields:n,showGroup:r,groupingConfig:i,setGroupingConfig:a,showColor:o,rowColorConfig:s,setRowColorConfig:c,showDensity:l,density:u,showHideFields:d,hiddenFields:f,updateHiddenFields:p}=e,[m,h]=Z.useState(!1),g=[!!i?.fields?.length,!!s?.field,u&&u.mode!==`compact`,(f?.size??0)>0].filter(Boolean).length,_=u?.mode===`compact`?F:u?.mode===`comfortable`?P:_e,v=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,Q.jsxs)(D,{open:m,onOpenChange:h,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,"aria-label":v,title:v,className:Y(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,g>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v}),g>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:g})]})}),(0,Q.jsxs)(it,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold`,children:v}),(0,Q.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields.`})})]}),r&&a&&(0,Q.jsx)(cn,{title:t(`list.group`,{defaultValue:`Group`}),badge:i?.fields?.length||0,onClear:i?()=>a(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),children:(0,Q.jsx)(ve,{value:i,fieldOptions:n.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:t(`list.addGroup`,`Add group field`),collapseTitle:t(`list.collapsedByDefault`,`Collapsed by default`),removeTitle:t(`list.removeGroup`,`Remove`)},onChange:e=>a(e)})}),o&&c&&(0,Q.jsxs)(cn,{title:t(`list.color`,{defaultValue:`Row color`}),onClear:s?()=>c(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!s,children:[(0,Q.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,Q.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:s?.field||``,onChange:e=>{let t=e.target.value;c(t?{field:t,colors:s?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,Q.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),n.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),l&&u&&(0,Q.jsx)(cn,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:u.mode!==`compact`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:u.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,Q.jsx)(_,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`text-xs`,children:u.mode===`compact`?t(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):u.mode===`comfortable`?t(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):t(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`})})]}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),d&&f&&p&&(0,Q.jsx)(cn,{title:t(`list.hideFieldsTitle`,{defaultValue:`Hide fields`}),badge:f.size,onClear:f.size>0?()=>p(new Set):void 0,clearLabel:t(`list.showAll`,{defaultValue:`Show all`}),defaultOpen:f.size>0,children:(0,Q.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:n.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!f.has(e.name),onChange:()=>{let t=new Set(f);t.has(e.name)?t.delete(e.name):t.add(e.name),p(t)},className:`rounded border-input`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function un(){try{let{t:e}=w(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}catch{return`More`}}var dn=new Set([`lookup`,`master_detail`,`user`,`owner`]);function fn(e){switch(e){case void 0:case`equals`:case`eq`:return`=`;case`not_equals`:case`ne`:case`neq`:return`!=`;case`gte`:return`>=`;case`lte`:return`<=`;case`gt`:return`>`;case`lt`:return`<`;case`not_in`:case`nin`:return`not in`;default:return e}}function pn(e){return(e||[]).filter(e=>e&&(e.id||e.name)).map(e=>({id:e.id??e.name,label:typeof e.label==`string`?e.label:e.label?.toString?.()??e.id??e.name,filters:Array.isArray(e.filters)?e.filters:Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>[e.field,fn(e.operator),e.value]):[],default:e.default??e.isDefault}))}function mn({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){switch(e.element){case`dropdown`:return(0,Q.jsx)(gn,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s});case`tabs`:return(0,Q.jsx)(_n,{tabs:pn(e.tabs||[]),showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a,initialTab:typeof o?._tab?.[0]==`string`?o._tab[0]:void 0,onSelectionsChange:s});case`toggle`:return(0,Q.jsx)(vn,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function hn(e,t,n,r){return e.map(e=>{let i=e.options?[...e.options]:[],a=e.type,o,s,c;if(t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n&&(a||=n.type,o=n.reference_to??n.reference,s=n.display_field??n.reference_field,c=n.id_field,i.length===0&&n.options&&(i=Array.isArray(n.options)?n.options.map(e=>({label:e.label??String(e.value??e),value:e.value??e,color:e.color})):Object.entries(n.options).map(([e,t])=>({label:t?.label||e,value:e,color:t?.color}))))}i.length===0&&a===`boolean`&&(i=[{label:`True`,value:!0},{label:`False`,value:!1}]),e.showCount&&n.length>0&&(i=i.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length})));let l=e.label;return r?.objectName&&(i=r.translateOptions(r.objectName,e.field,i),l=r.fieldLabel(r.objectName,e.field,e.label||e.field)),{...e,label:l,type:a,options:i,referenceTo:o,displayField:s,idField:c}})}function gn({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){let{fieldLabel:c,translateOptions:l}=ot(),u=un(),d=t?.name,[f,p]=Z.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues);let n=o?.[e.field];n&&n.length>0&&(t[e.field]=n)}),t}),m=Z.useRef({}),h=Z.useMemo(()=>hn(e,t,n,{objectName:d,fieldLabel:c,translateOptions:l}).map(e=>{if(!e.showCount)return e;if((f[e.field]||[]).length===0)return m.current[e.field]=new Map(e.options.map(e=>[String(e.value),e.count??0])),e;let t=m.current[e.field];return t?{...e,options:e.options.map(e=>({...e,count:t.get(String(e.value))??e.count}))}:e}),[e,t,n,d,c,l,f]),g=Z.useCallback(e=>{r(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[r]),_=(e,t)=>{let n={...f,[e]:t};p(n),g(n),s?.(n)};Z.useEffect(()=>{let e=f,t={},n=!1;for(let[r,i]of Object.entries(e)){let e=h.find(e=>e.field===r),a=i.map(t=>{if(!e||typeof t!=`string`)return t;let n=e.options.find(e=>String(e.value)===t);return n&&n.value!==t?n.value:e.type===`boolean`&&(t===`true`||t===`false`)?t===`true`:t});t[r]=a,a.some((e,t)=>e!==i[t])&&(n=!0)}n&&(p(t),e=t),Object.values(e).some(e=>e.length>0)&&g(e)},[]);let v=i!==void 0&&i<h.length?h.slice(0,i):h,y=i!==void 0&&i<h.length?h.slice(i):[],b=e=>{let t=f[e.field]||[],n=t.length>0,r=dn.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`||e.type===`owner`),i=r?`w-72`:`w-56`;return(0,Q.jsxs)(D,{children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:Y(`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)(Te,{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)(M,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(it,{align:`start`,className:Y(i,`p-2`),children:r?(0,Q.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,Q.jsx)(Ot,{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:Y(`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:Y(`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)(D,{children:[(0,Q.jsx)(zt,{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)(M,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(it,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,Q.jsx)(`div`,{className:`space-y-1`,children:y.map(b)})})]})]})})}function _n({tabs:e,showAllRecords:t,allowAddTab:n,onFilterChange:r,className:i,initialTab:a,onSelectionsChange:o}){let[s,c]=Z.useState(()=>a&&(a===`__all__`||e.some(e=>e.id===a))?a:e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),l=Z.useCallback(t=>{c(t),r(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[]),o?.({_tab:[t]})},[e,r,o]),u=Z.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return Z.useEffect(()=>{if(s&&s!==`__all__`){let t=e.find(e=>e.id===s);t&&r(t.filters||[])}},[]),(0,Q.jsxs)(`div`,{className:Y(`flex items-center gap-0.5 overflow-x-auto`,i),"data-testid":`user-filters-tabs`,children:[u.map(e=>(0,Q.jsx)(`button`,{"data-testid":`filter-tab-${e.id}`,onClick:()=>l(e.id),className:Y(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,s===e.id?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},e.id)),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)(ae,{className:`h-3.5 w-3.5`})})]})}function vn({fields:e,onFilterChange:t,className:n}){let[r,i]=Z.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),a=Z.useCallback(n=>{t(Array.from(n).map(t=>{let n=e.find(e=>e.field===t);return n?.defaultValues?[t,`in`,n.defaultValues]:[t,`!=`,null]}))},[e,t]),o=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),a(n),n})};return Z.useEffect(()=>{r.size>0&&a(r)},[]),(0,Q.jsx)(`div`,{className:Y(`flex items-center gap-1 overflow-x-auto`,n),"data-testid":`user-filters-toggle`,children:e.map(e=>(0,Q.jsx)(J,{variant:r.has(e.field)?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs shrink-0`,"data-testid":`filter-toggle-${e.field}`,onClick:()=>o(e.field),children:e.label||e.field},e.field))})}function yn(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 bn(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)?bn(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 xn(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Sn(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?bn(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function Cn(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=Sn(e.conditions.map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,yn(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var wn={"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.search":`Search`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.group":`Group`,"list.groupBy":`Group By`,"list.export":`Export`,"list.exportAs":`Export as {{format}}`,"list.color":`Color`,"list.rowColor":`Row Color`,"list.colorByField":`Color by field`,"list.clear":`Clear`,"list.none":`None`,"list.hideFields":`Hide fields`,"list.showAll":`Show all`,"list.pullToRefresh":`Pull to refresh`,"list.refreshing":`Refreshing…`,"list.dataLimitReached":`Showing first {{limit}} records. More data may be available.`,"list.addRecord":`Add record`,"list.tabs":`Tabs`,"list.allRecords":`All Records`,"list.share":`Share`,"list.print":`Print`,"list.hideFieldsTitle":`Hide Fields`,"table.rowsPerPage":`Rows per page`,"grid.toolbar.densityMode":`Density`,"grid.toolbar.densityCompact":`Compact`,"grid.toolbar.densityComfortable":`Comfortable`,"grid.toolbar.densitySpacious":`Spacious`,"grid.toolbar.densityCycleHint":`{{label}} (click to cycle)`,"grid.toolbar.densityCycleShortHint":`Click to cycle`,"list.viewSettings":`View settings`,"list.viewSettingsHint":`Grouping, color, density, and visible fields.`},Tn=(e,t,n)=>n,En=(e,t)=>{let n=wn[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n};function Dn(){try{let e=w();return e.t(`list.recordCount`)===`list.recordCount`?{t:En}:{t:e.t}}catch{return{t:En}}}function On(){try{let{fieldLabel:e,actionLabel:t}=$e();return{fieldLabel:e,actionLabel:t}}catch{return{fieldLabel:Tn,actionLabel:void 0}}}var kn=Z.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onHiddenFieldsChange:s,onColumnStateChange:l,onRowClick:u,showViewSwitcher:f,userFilterSelections:m,onUserFilterSelectionsChange:h,...g},v)=>{let b=f??e?.showViewSwitcher??!1,{t:x}=Dn(),{fieldLabel:C,actionLabel:w}=On(),{translateOptions:T}=ot(),E=Z.useMemo(()=>e.viewType&&e.viewType!==`list`?e:{...e,viewType:`grid`},[e]),O=Z.useCallback((e,t)=>E.objectName?C(E.objectName,e,t):t,[E.objectName,C]),k=Z.useCallback(e=>{let t=xn(e);return E.objectName&&typeof w==`function`?w(E.objectName,e,t):t},[E.objectName,w]),A=Z.useMemo(()=>{let e=E.userActions,t=E.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?E.showSearch!==!1:e.search,showSort:e?.sort===void 0?E.showSort!==!1:e.sort,showFilters:e?.filter===void 0?E.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?E.showDensity!==!1:e.rowHeight,showHideFields:E.showHideFields===!0,showGroup:E.showGroup!==!1,showColor:E.showColor===!0,compactToolbar:E.compactToolbar===!0,showAddRecord:t,addRecordPosition:E.addRecord?.position===`bottom`?`bottom`:`top`}},[E.userActions,E.showSearch,E.showSort,E.showFilters,E.showDensity,E.showHideFields,E.showGroup,E.showColor,E.compactToolbar,E.addRecord,E.userActions?.addRecordForm]),[j,M]=Z.useState(E.viewType),[N,ee]=Z.useState(``),[te,re]=Z.useState(!1),[ie,oe]=Z.useState(!1),[L,ce]=Z.useState(()=>E.sort&&E.sort.length>0?E.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}}):[]),le=Z.useMemo(()=>JSON.stringify(E.sort||[]),[E.sort]);Z.useEffect(()=>{E.sort&&E.sort.length>0?ce(E.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}})):ce([])},[le]);let[ue,z]=Z.useState(!1),[de,fe]=Z.useState({id:`root`,logic:`and`,conditions:[]}),[B,me]=Z.useState(()=>{if(!E.tabs||E.tabs.length===0)return;let e=m?._tab?.[0];return typeof e==`string`&&E.tabs.some(t=>t.name===e)?e:E.tabs.find(e=>e.isDefault)?.name??E.tabs[0]?.name});Z.useEffect(()=>{let e=E.tabs?.find(e=>e.name===B);if(e&&Array.isArray(e.filter)&&e.filter.length>0){let t=e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>({field:e.field,operator:e.operator??`equals`,value:e.value}));fe({id:`tab-filter-${e.name}`,logic:`and`,conditions:t})}},[]);let V=Z.useCallback(e=>{if(me(e.name),h?.({_tab:[e.name]}),e.filter){let t=Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>({field:e.field,operator:e.operator??`equals`,value:e.value})):e.filter.conditions||[],n={id:`tab-filter-${e.name}`,logic:!Array.isArray(e.filter)&&e.filter.logic||`and`,conditions:t};fe(n),r?.(n)}else{let e={id:`root`,logic:`and`,conditions:[]};fe(e),r?.(e)}},[r,h]),H=g.dataSource,[U,ge]=Z.useState([]),[W,ye]=Z.useState(()=>!(Array.isArray(E.data)||E.data&&typeof E.data==`object`&&E.data.provider===`value`&&Array.isArray(E.data.items))),[K,be]=Z.useState(null),[xe,Se]=Z.useState(!1),[we,Ee]=Z.useState(0),[De,Oe]=Z.useState(!1);Z.useImperativeHandle(v,()=>({refresh:()=>Ee(e=>e+1)}),[]),Z.useEffect(()=>{if(!(!H?.onMutation||!E.objectName||E.refreshTrigger))return H.onMutation(e=>{e.resource===E.objectName&&Ee(e=>e+1)})},[H,E.objectName,E.refreshTrigger]);let[ke,je]=Z.useState(void 0),Me=ke??E.pagination?.pageSize??100,Ne=Z.useMemo(()=>{if(E.grouping?.fields?.length)return E.grouping;let e=typeof E.groupBy==`string`?E.groupBy.trim():``,t=typeof E.groupBy2==`string`?E.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},[E.grouping,E.groupBy,E.groupBy2]),[q,Pe]=Z.useState(Ne),[Fe,Ie]=Z.useState(!1),Le=Z.useRef(Ne);Z.useEffect(()=>{Le.current!==Ne&&(Le.current=Ne,Pe(Ne))},[Ne]);let[Re,ze]=Z.useState(E.rowColor),[Be,He]=Z.useState(!1),[Ue,We]=Z.useState([]),Ge=Z.useRef(0),[Ke,Je]=Z.useState(()=>{let e=new Set;return E.quickFilters?.forEach(t=>{let n=_(t);n.defaultActive&&e.add(n.id)}),e}),[Ye,Xe]=Z.useState([]),Ze=Z.useMemo(()=>{let e=E.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:O(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[E.userFilters,K,O]),Qe=E.tabs&&E.tabs.length>0?void 0:Ze,[$e,tt]=Z.useState(()=>new Set(E.hiddenFields||[])),nt=Z.useMemo(()=>JSON.stringify(E.hiddenFields||[]),[E.hiddenFields]);Z.useEffect(()=>{tt(new Set(E.hiddenFields||[]))},[nt]);let at=Z.useCallback(e=>{tt(e),s?.(Array.from(e))},[s]),[st,ct]=Z.useState(!1),[lt,ut]=Z.useState(!1),dt=Z.useMemo(()=>y(E.quickFilters),[E.quickFilters]),ft=Z.useMemo(()=>{if(E.exportOptions)return Array.isArray(E.exportOptions)?{formats:E.exportOptions}:E.exportOptions},[E.exportOptions]),pt=p(Z.useMemo(()=>E.densityMode?E.densityMode:E.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[E.rowHeight]||`comfortable`:`compact`,[E.densityMode,E.rowHeight]),{onChange:E.onDensityChange}),mt=Z.useMemo(()=>`objectui:gallery:density:${E.objectName??`default`}`,[E.objectName]),[ht,gt]=Z.useState(()=>{if(typeof window>`u`)return E.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(mt);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return E.gallery?.cardSize??`medium`}),_t=Z.useCallback(()=>{gt(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(mt,t)}catch{}return t})},[mt]),{ref:vt,isRefreshing:yt,pullDistance:bt}=$t({onRefresh:Z.useCallback(async()=>{Ee(e=>e+1)},[]),enabled:!!H&&!!E.objectName}),xt=Z.useMemo(()=>E.id?`listview-${E.objectName}-${E.id}-view`:`listview-${E.objectName}-view`,[E.objectName,E.id]);Z.useEffect(()=>{let e=!0;return Se(!1),be(null),(async()=>{if(!H||!E.objectName){Se(!0);return}if(typeof H.getObjectSchema!=`function`){Se(!0);return}try{let t=await H.getObjectSchema(E.objectName);e&&be(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&Se(!0)}})(),()=>{e=!1}},[E.objectName,H]);let wt=Z.useMemo(()=>{let e=Array.isArray(E.fields)?E.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(E.kanban),n(E.options?.kanban),n(E.calendar),n(E.options?.calendar),n(E.gallery),n(E.options?.gallery),n(E.timeline),n(E.options?.timeline),n(E.gantt),n(E.options?.gantt);let r=t.size>0?Array.from(t):void 0;return S(K?.fields,r)},[K?.fields,E.fields,E.kanban,E.calendar,E.gallery,E.timeline,E.gantt,E.options]),Tt=o();Z.useEffect(()=>{let e=!0,t=++Ge.current;if(E.data&&typeof E.data==`object`&&!Array.isArray(E.data)){let e=E.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(N){let e=N.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}ge(t),ye(!1),Oe(!1);return}}if(Array.isArray(E.data)){let e=E.data;if(N){let t=N.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}ge(e),ye(!1),Oe(!1);return}return xe?((async()=>{if(!H||!E.objectName){ye(!1);return}ye(!0);try{let n=[],r=E.filters||[],i=Cn(de),a=[];dt&&Ke.size>0&&dt.forEach(e=>{Ke.has(e.id)&&e.filters&&e.filters.length>0&&a.push(e.filters)});let o=Sn(Ye),s=[...r.length>0?[r]:[],...i.length>0?[i]:[],...a,...o].filter(e=>Array.isArray(e)&&e.length>0);s.length>1?n=[`and`,...s]:s.length===1&&(n=s[0]);let c=L.length>0?L.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,l=(()=>{let e=Array.isArray(E.fields)?E.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=Tt?.isLoaded&&E.objectName?e.filter(e=>Tt.checkField(E.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 wt)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(E.kanban),a(E.options?.kanban),a(E.calendar),a(E.options?.calendar),a(E.gallery),a(E.options?.gallery),a(E.timeline),a(E.options?.timeline);{let e=E.timeline??E.options?.timeline;e&&!Array.isArray(e.metaFields)&&(i(`status`),i(`priority`))}return a(E.gantt),a(E.options?.gantt),Array.from(n)})(),u=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,d=await H.find(E.objectName,{...u?{$filter:n}:{},$orderby:c,$top:Me,...l?{$select:l}:{},...wt.length>0?{$expand:wt}:{},...N?{$search:N,...E.searchableFields&&E.searchableFields.length>0?{$searchFields:E.searchableFields}:{}}:{}});if(!e||t!==Ge.current)return;let f=[];Array.isArray(d)?f=d:d&&typeof d==`object`&&(Array.isArray(d.data)?f=d.data:Array.isArray(d.records)?f=d.records:Array.isArray(d.value)&&(f=d.value)),ge(f),Oe(f.length>=Me)}catch(e){t===Ge.current&&console.error(`ListView data fetch error:`,e)}finally{e&&t===Ge.current&&ye(!1)}})(),()=>{e=!1}):void 0},[E.objectName,E.data,H,E.filters,Me,L,de,Ke,dt,Ye,we,N,E.searchableFields,wt,xe,E.refreshTrigger,Tt]);let Et=Z.useMemo(()=>{let e=[`grid`];(E.kanban?.groupByField||E.kanban?.groupField||E.options?.kanban?.groupField)&&e.push(`kanban`),(E.gallery?.coverField||E.gallery?.imageField||E.options?.gallery?.imageField)&&e.push(`gallery`),(E.calendar?.startDateField||E.options?.calendar?.startDateField)&&e.push(`calendar`),(E.timeline?.startDateField||E.options?.timeline?.startDateField||E.options?.timeline?.dateField||E.options?.calendar?.startDateField)&&e.push(`timeline`),(E.gantt?.startDateField||E.options?.gantt?.startDateField)&&e.push(`gantt`),(E.options?.map?.locationField||E.options?.map?.latitudeField&&E.options?.map?.longitudeField)&&e.push(`map`),E.viewType&&!e.includes(E.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`].includes(E.viewType)&&e.push(E.viewType);let t=E.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},[E.options,E.viewType,E.kanban,E.calendar,E.gantt,E.gallery,E.timeline,E.appearance?.allowedVisualizations]);Z.useEffect(()=>{E.viewType&&M(E.viewType)},[E.viewType]);let Dt=Z.useCallback(e=>{M(e);try{localStorage.setItem(xt,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[xt,n]),Ot=Z.useCallback(e=>{ee(e),a?.(e)},[a]),kt=d({navigation:E.navigation,objectName:E.objectName,onNavigate:E.onNavigate,onRowClick:u}),X=Z.useMemo(()=>{let e=E.fields||[];if(Array.isArray(e)||(e=[]),Tt?.isLoaded&&E.objectName&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t?Tt.checkField(E.objectName,t,`read`):!0})),$e.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!$e.has(t)})),E.fieldOrder&&E.fieldOrder.length>0){let t=new Map(E.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},[E.fields,E.objectName,$e,E.fieldOrder,Tt]),At=Z.useMemo(()=>{let e=pt.mode===`compact`?`compact`:pt.mode===`spacious`?`tall`:`medium`,t={objectName:E.objectName,fields:X,filters:E.filters,sort:L,className:`h-full w-full`,showSearch:!1,onRowClick:kt.handleClick,rowHeight:e,hideRowHeightToggle:!0,...E.striped==null?{}:{striped:E.striped},...E.bordered==null?{}:{bordered:E.bordered},...l?{onColumnStateChange:l}:{},...E.columnState?{columnState:E.columnState}:{}};switch(j){default:case`grid`:return{type:`object-grid`,...t,columns:X,...E.conditionalFormatting?{conditionalFormatting:E.conditionalFormatting}:{},...E.inlineEdit==null?{}:{editable:E.inlineEdit},...E.wrapHeaders==null?{}:{wrapHeaders:E.wrapHeaders},...E.virtualScroll==null?{}:{virtualScroll:E.virtualScroll},...E.resizable==null?{}:{resizable:E.resizable},...E.selection?{selection:E.selection}:{},...E.pagination?{pagination:E.pagination}:{},...q?{grouping:q}:{},...Re?{rowColor:Re}:{},...E.rowActions?{rowActions:E.rowActions}:{},...E.rowActionDefs?{rowActionDefs:E.rowActionDefs}:{},...E.bulkActions?{batchActions:E.bulkActions}:{},...E.bulkActionDefs?{bulkActionDefs:E.bulkActionDefs}:{},...E.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...t,groupBy:E.kanban?.groupField||E.options?.kanban?.groupField||`status`,groupField:E.kanban?.groupField||E.options?.kanban?.groupField||`status`,...E.kanban?.titleField||E.options?.kanban?.titleField?{titleField:E.kanban?.titleField||E.options?.kanban?.titleField}:{},cardFields:E.kanban?.cardFields||X||[],...q?{grouping:q}:{},...E.options?.kanban||{},...E.kanban||{}};case`calendar`:return{type:`object-calendar`,...t,startDateField:E.calendar?.startDateField||E.options?.calendar?.startDateField||`start_date`,endDateField:E.calendar?.endDateField||E.options?.calendar?.endDateField||`end_date`,...E.calendar?.titleField||E.options?.calendar?.titleField?{titleField:E.calendar?.titleField||E.options?.calendar?.titleField}:{},...E.calendar?.defaultView?{defaultView:E.calendar.defaultView}:{},...E.options?.calendar||{},...E.calendar||{}};case`gallery`:{let e={...E.options?.gallery||{},...E.gallery||{},cardSize:ht};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:E.gallery?.coverField||E.gallery?.imageField||E.options?.gallery?.imageField,titleField:E.gallery?.titleField||E.options?.gallery?.titleField||`name`,subtitleField:E.gallery?.subtitleField||E.options?.gallery?.subtitleField,...q?{grouping:q}:{}}}case`timeline`:{let e={...E.options?.timeline||{},...E.timeline||{}};return{type:`object-timeline`,...t,timeline:Object.keys(e).length>0?e:void 0,startDateField:E.timeline?.startDateField||E.options?.timeline?.startDateField||E.options?.timeline?.dateField||`created_at`,titleField:E.timeline?.titleField||E.options?.timeline?.titleField||`name`,...E.timeline?.endDateField?{endDateField:E.timeline.endDateField}:{},...E.timeline?.groupByField?{groupByField:E.timeline.groupByField}:{},...E.timeline?.colorField?{colorField:E.timeline.colorField}:{},...E.timeline?.scale?{scale:E.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,startDateField:E.gantt?.startDateField||E.options?.gantt?.startDateField||`start_date`,endDateField:E.gantt?.endDateField||E.options?.gantt?.endDateField||`end_date`,progressField:E.gantt?.progressField||E.options?.gantt?.progressField||`progress`,dependenciesField:E.gantt?.dependenciesField||E.options?.gantt?.dependenciesField||`dependencies`,...E.gantt?.titleField?{titleField:E.gantt.titleField}:{},...E.options?.gantt||{},...E.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:E.options?.map?.locationField||`location`,...E.options?.map||{}};case`chart`:{let e=E.chart||E.options?.chart||{},t=Array.isArray(e.yAxisFields)&&e.yAxisFields[0]||e.valueField||`value`,n=e.xAxisField||e.categoryField||`name`;return{type:`object-chart`,objectName:E.objectName,chartType:e.chartType||`bar`,filters:E.filters,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[j,E,L,X,q,Re,kt.handleClick,pt.mode,ht]),jt=de.conditions&&de.conditions.length>0,Mt=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 E.objectName?T(E.objectName,e,n):n};if(e=K?.fields?Object.entries(K.fields).map(([e,n])=>({value:e,label:O(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})):(E.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let n=e.name||e.fieldName;return{value:n,label:O(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}}),E.filterableFields&&E.filterableFields.length>0){let t=new Set(E.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[K,E.fields,E.filterableFields,E.objectName,O,T]),Nt=Z.useCallback(e=>{Je(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Ft=Z.useCallback(e=>{let t=ft,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||E.objectName||`export`,a=n>0?U.slice(0,n):U;if(e===`csv`){let e=X.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];r&&t.push(e.join(`,`)),a.forEach(n=>{t.push(e.map(e=>{let t=n[e],r;return r=t==null?``:Array.isArray(t)?t.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof t==`object`?JSON.stringify(t):String(t),r.includes(`,`)||r.includes(`"`)||r.includes(`
1
+ import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,r as i,t as a}from"./vendor-react-DR370ovB.js";import{n as o,t as s}from"./infrastructure-ckitl7Ev.js";import{B as c,D as l,E as u,F as d,H as f,M as p,R as m,W as h,_ as g,dt as _,f as v,ft as y,g as b,h as x,lt as S,mt as C,r as w,z as T}from"./framework-BSpP7C0B.js";import{$n as E,$t as D,Aa as O,At as k,Bt as A,C as j,Cs as M,Da as N,Di as P,Ei as F,Fo as ee,Ft as te,G as ne,Gn as re,Gs as ie,Hi as ae,Ht as oe,I,Ja as se,Jn as L,Jo as ce,Js as le,K as R,Ka as ue,Ki as z,Ks as de,Lt as fe,M as pe,Ma as B,Mo as me,Mt as V,N as he,No as H,Ns as U,Nt as ge,Oi as _e,Ot as W,P as ve,Po as G,Pr as ye,Pt as K,Rr as be,Rt as xe,S as Se,Si as Ce,So as we,Sr as Te,Ss as Ee,Ta as De,Un as Oe,Ut as ke,Vr as Ae,Vt as je,Wn as Me,Wt as Ne,X as q,Xa as Pe,Xn as Fe,Xs as Ie,Ya as Le,Zi as Re,Zn as ze,Zo as Be,_r as Ve,ai as He,ar as Ue,at as We,bi as Ge,br as Ke,ca as qe,cc as Je,ci as Ye,cn as Xe,cr as Ze,d as Qe,dc as $e,di as et,dr as tt,ds as nt,ec as rt,en as it,er as at,fc as ot,fr as st,g as ct,gn as lt,gr as ut,hr as J,io as dt,ir as ft,it as pt,ja as mt,js as ht,jt as gt,kt as _t,lc as Y,lr as vt,m as yt,nc as bt,ni as xt,nn as St,no as Ct,nr as wt,nt as Tt,or as Et,pr as Dt,q as Ot,qi as kt,qn as X,ra as At,rc as jt,rr as Mt,rt as Nt,si as Pt,sn as Ft,sr as It,ta as Lt,tc as Rt,tn as zt,tr as Bt,ui as Vt,un as Ht,ur as Ut,vi as Wt,ws as Gt,xa as Kt,xi as qt,xs as Jt,yo as Yt,za as Xt,zi as Zt,zo as Qt}from"./ui-components-D7IOmcqZ.js";import{a as $t}from"./plugin-grid-KSDSYH4h.js";var Z=e(n(),1),Q=a(),en={grid:(0,Q.jsx)(dt,{className:`h-4 w-4`}),kanban:(0,Q.jsx)(Xt,{className:`h-4 w-4`}),gallery:(0,Q.jsx)(Le,{className:`h-4 w-4`}),calendar:(0,Q.jsx)(U,{className:`h-4 w-4`}),timeline:(0,Q.jsx)(Je,{className:`h-4 w-4`}),gantt:(0,Q.jsx)(Ye,{className:`h-4 w-4`}),map:(0,Q.jsx)(De,{className:`h-4 w-4`}),chart:(0,Q.jsx)(ht,{className:`h-4 w-4`})},tn={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`,chart:`Chart`},nn=({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(0,Q.jsxs)(D,{open:a,onOpenChange:o,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`view-switcher-dropdown`,"aria-label":tn[e],className:Y(`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:[en[e],(0,Q.jsx)(`span`,{className:`hidden sm:inline-block`,children:tn[e]}),(0,Q.jsx)(M,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(it,{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:Y(`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:[en[t],(0,Q.jsx)(`span`,{className:`flex-1 text-left`,children:tn[t]}),t===e&&(0,Q.jsx)(Gt,{className:`h-3.5 w-3.5`})]},t))})]})};function rn(e){return e?Ve[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function an(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}var on=({tabs:e,activeTab:t,onTabChange:n,className:r})=>{let i=Z.useMemo(()=>an(e),[e]),a=Z.useMemo(()=>i.find(e=>e.isDefault)?.name??i[0]?.name,[i]),[o,s]=Z.useState(a),c=t??o,l=Z.useCallback(e=>{s(e.name),n?.(e)},[n]);return i.length===0?null:(0,Q.jsx)(`div`,{className:Y(`px-2 sm:px-4 py-1 flex items-center gap-0.5 bg-background`,r),"data-testid":`view-tabs`,role:`tablist`,children:i.map(e=>{let t=rn(e.icon),n=c===e.name;return(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`h-7 px-2.5 py-1 text-xs rounded-md transition-colors duration-150`,n?`font-medium text-foreground bg-muted`:`text-muted-foreground hover:text-foreground hover:bg-transparent`),"data-testid":`view-tab-${e.name}`,role:`tab`,"aria-selected":n,onClick:()=>l(e),children:[t&&(0,Q.jsx)(t,{className:`h-3 w-3 mr-1.5`}),e.label]},e.name)})})},sn=({tabs:e,activeTab:t,onTabChange:n,className:r})=>{let i=Z.useMemo(()=>an(e),[e]),a=Z.useMemo(()=>i.find(e=>e.isDefault)?.name??i[0]?.name,[i]),[o,s]=Z.useState(a),c=t??o,l=Z.useMemo(()=>i.find(e=>e.name===c)??i[0],[i,c]),u=Z.useCallback(e=>{s(e.name),n?.(e)},[n]);if(i.length===0)return null;let d=rn(l?.icon);return(0,Q.jsx)(`div`,{className:Y(`px-2 py-1`,r),"data-testid":`view-tabs-select`,children:(0,Q.jsxs)(Ft,{children:[(0,Q.jsx)(lt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs font-medium text-foreground gap-1.5 max-w-[60vw] truncate`,"aria-label":`Switch view`,children:[d&&(0,Q.jsx)(d,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:l?.label??``}),(0,Q.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Xe,{align:`start`,className:`w-56 max-h-72 overflow-y-auto`,children:i.map(e=>{let t=rn(e.icon);return(0,Q.jsxs)(Ht,{onClick:()=>u(e),className:Y(`text-sm`,c===e.name&&`font-medium bg-muted`),"data-testid":`view-tab-select-${e.name}`,children:[t&&(0,Q.jsx)(t,{className:`h-3.5 w-3.5 mr-2 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name)})})]})})};function cn({title:e,badge:t,onClear:n,clearLabel:r,defaultOpen:i=!0,children:a}){let[o,s]=Z.useState(i);return(0,Q.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 text-xs font-medium text-foreground/80 hover:text-foreground`,children:[(0,Q.jsx)(M,{className:Y(`h-3.5 w-3.5 transition-transform`,!o&&`-rotate-90`)}),e,typeof t==`number`&&t>0&&(0,Q.jsx)(`span`,{className:`ml-1 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 px-1 text-[10px] text-primary tabular-nums`,children:t})]}),n&&(0,Q.jsx)(`button`,{type:`button`,onClick:n,className:`text-[11px] text-muted-foreground hover:text-foreground`,children:r})]}),o&&(0,Q.jsx)(`div`,{className:`px-3 pb-3`,children:a})]})}function ln(e){let{t,allFields:n,showGroup:r,groupingConfig:i,setGroupingConfig:a,showColor:o,rowColorConfig:s,setRowColorConfig:c,showDensity:l,density:u,showHideFields:d,hiddenFields:f,updateHiddenFields:p}=e,[m,h]=Z.useState(!1),g=[!!i?.fields?.length,!!s?.field,u&&u.mode!==`compact`,(f?.size??0)>0].filter(Boolean).length,_=u?.mode===`compact`?F:u?.mode===`comfortable`?P:_e,v=t(`list.viewSettings`,{defaultValue:`View settings`});return(0,Q.jsxs)(D,{open:m,onOpenChange:h,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,"aria-label":v,title:v,className:Y(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,g>0&&`text-foreground font-medium`),"data-testid":`view-settings-trigger`,children:[(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5 sm:mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v}),g>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:g})]})}),(0,Q.jsxs)(it,{align:`end`,className:`w-80 p-0`,"data-testid":`view-settings-content`,children:[(0,Q.jsxs)(`div`,{className:`px-3 py-2 border-b`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold`,children:v}),(0,Q.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:t(`list.viewSettingsHint`,{defaultValue:`Grouping, color, density, and visible fields.`})})]}),r&&a&&(0,Q.jsx)(cn,{title:t(`list.group`,{defaultValue:`Group`}),badge:i?.fields?.length||0,onClear:i?()=>a(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),children:(0,Q.jsx)(ve,{value:i,fieldOptions:n.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:t(`list.addGroup`,`Add group field`),collapseTitle:t(`list.collapsedByDefault`,`Collapsed by default`),removeTitle:t(`list.removeGroup`,`Remove`)},onChange:e=>a(e)})}),o&&c&&(0,Q.jsxs)(cn,{title:t(`list.color`,{defaultValue:`Row color`}),onClear:s?()=>c(void 0):void 0,clearLabel:t(`list.clear`,{defaultValue:`Clear`}),defaultOpen:!!s,children:[(0,Q.jsx)(`label`,{className:`block text-[11px] text-muted-foreground mb-1`,children:t(`list.colorByField`,{defaultValue:`Color by field`})}),(0,Q.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:s?.field||``,onChange:e=>{let t=e.target.value;c(t?{field:t,colors:s?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,Q.jsx)(`option`,{value:``,children:t(`list.none`,{defaultValue:`None`})}),n.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name))]})]}),l&&u&&(0,Q.jsx)(cn,{title:t(`grid.toolbar.densityMode`,{defaultValue:`Density`}),defaultOpen:u.mode!==`compact`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`h-7 gap-1.5`,onClick:u.cycle,"data-testid":`view-settings-density-cycle`,children:[(0,Q.jsx)(_,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`text-xs`,children:u.mode===`compact`?t(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):u.mode===`comfortable`?t(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):t(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`})})]}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:t(`grid.toolbar.densityCycleShortHint`,{defaultValue:`Click to cycle`})})]})}),d&&f&&p&&(0,Q.jsx)(cn,{title:t(`list.hideFieldsTitle`,{defaultValue:`Hide fields`}),badge:f.size,onClear:f.size>0?()=>p(new Set):void 0,clearLabel:t(`list.showAll`,{defaultValue:`Show all`}),defaultOpen:f.size>0,children:(0,Q.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-0.5`,children:n.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!f.has(e.name),onChange:()=>{let t=new Set(f);t.has(e.name)?t.delete(e.name):t.add(e.name),p(t)},className:`rounded border-input`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label||e.name})]},e.name))})})]})]})}function un(){try{let{t:e}=w(),t=e(`common.more`);return!t||t===`common.more`?`More`:t}catch{return`More`}}var dn=new Set([`lookup`,`master_detail`,`user`,`owner`]);function fn(e){switch(e){case void 0:case`equals`:case`eq`:return`=`;case`not_equals`:case`ne`:case`neq`:return`!=`;case`gte`:return`>=`;case`lte`:return`<=`;case`gt`:return`>`;case`lt`:return`<`;case`not_in`:case`nin`:return`not in`;default:return e}}function pn(e){return(e||[]).filter(e=>e&&(e.id||e.name)).map(e=>({id:e.id??e.name,label:typeof e.label==`string`?e.label:e.label?.toString?.()??e.id??e.name,filters:Array.isArray(e.filters)?e.filters:Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>[e.field,fn(e.operator),e.value]):[],default:e.default??e.isDefault}))}function mn({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){switch(e.element){case`dropdown`:return(0,Q.jsx)(gn,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s});case`tabs`:return(0,Q.jsx)(_n,{tabs:pn(e.tabs||[]),showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a,initialTab:typeof o?._tab?.[0]==`string`?o._tab[0]:void 0,onSelectionsChange:s});case`toggle`:return(0,Q.jsx)(vn,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function hn(e,t,n,r){return e.map(e=>{let i=e.options?[...e.options]:[],a=e.type,o,s,c;if(t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n&&(a||=n.type,o=n.reference_to??n.reference,s=n.display_field??n.reference_field,c=n.id_field,i.length===0&&n.options&&(i=Array.isArray(n.options)?n.options.map(e=>({label:e.label??String(e.value??e),value:e.value??e,color:e.color})):Object.entries(n.options).map(([e,t])=>({label:t?.label||e,value:e,color:t?.color}))))}i.length===0&&a===`boolean`&&(i=[{label:`True`,value:!0},{label:`False`,value:!1}]),e.showCount&&n.length>0&&(i=i.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length})));let l=e.label;return r?.objectName&&(i=r.translateOptions(r.objectName,e.field,i),l=r.fieldLabel(r.objectName,e.field,e.label||e.field)),{...e,label:l,type:a,options:i,referenceTo:o,displayField:s,idField:c}})}function gn({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a,initialSelections:o,onSelectionsChange:s}){let{fieldLabel:c,translateOptions:l}=ot(),u=un(),d=t?.name,[f,p]=Z.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues);let n=o?.[e.field];n&&n.length>0&&(t[e.field]=n)}),t}),m=Z.useRef({}),h=Z.useMemo(()=>hn(e,t,n,{objectName:d,fieldLabel:c,translateOptions:l}).map(e=>{if(!e.showCount)return e;if((f[e.field]||[]).length===0)return m.current[e.field]=new Map(e.options.map(e=>[String(e.value),e.count??0])),e;let t=m.current[e.field];return t?{...e,options:e.options.map(e=>({...e,count:t.get(String(e.value))??e.count}))}:e}),[e,t,n,d,c,l,f]),g=Z.useCallback(e=>{r(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[r]),_=(e,t)=>{let n={...f,[e]:t};p(n),g(n),s?.(n)};Z.useEffect(()=>{let e=f,t={},n=!1;for(let[r,i]of Object.entries(e)){let e=h.find(e=>e.field===r),a=i.map(t=>{if(!e||typeof t!=`string`)return t;let n=e.options.find(e=>String(e.value)===t);return n&&n.value!==t?n.value:e.type===`boolean`&&(t===`true`||t===`false`)?t===`true`:t});t[r]=a,a.some((e,t)=>e!==i[t])&&(n=!0)}n&&(p(t),e=t),Object.values(e).some(e=>e.length>0)&&g(e)},[]);let v=i!==void 0&&i<h.length?h.slice(0,i):h,y=i!==void 0&&i<h.length?h.slice(i):[],b=e=>{let t=f[e.field]||[],n=t.length>0,r=dn.has(e.type||``)&&e.options.length===0&&(e.referenceTo||e.type===`user`||e.type===`owner`),i=r?`w-72`:`w-56`;return(0,Q.jsxs)(D,{children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:Y(`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)(Te,{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)(M,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(it,{align:`start`,className:Y(i,`p-2`),children:r?(0,Q.jsx)(`div`,{"data-testid":`filter-lookup-${e.field}`,children:(0,Q.jsx)(Ot,{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:Y(`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:Y(`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)(D,{children:[(0,Q.jsx)(zt,{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)(M,{className:`h-3 w-3 opacity-60`})]})}),(0,Q.jsx)(it,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,Q.jsx)(`div`,{className:`space-y-1`,children:y.map(b)})})]})]})})}function _n({tabs:e,showAllRecords:t,allowAddTab:n,onFilterChange:r,className:i,initialTab:a,onSelectionsChange:o}){let[s,c]=Z.useState(()=>a&&(a===`__all__`||e.some(e=>e.id===a))?a:e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),l=Z.useCallback(t=>{c(t),r(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[]),o?.({_tab:[t]})},[e,r,o]),u=Z.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return Z.useEffect(()=>{if(s&&s!==`__all__`){let t=e.find(e=>e.id===s);t&&r(t.filters||[])}},[]),(0,Q.jsxs)(`div`,{className:Y(`flex items-center gap-0.5 overflow-x-auto`,i),"data-testid":`user-filters-tabs`,children:[u.map(e=>(0,Q.jsx)(`button`,{"data-testid":`filter-tab-${e.id}`,onClick:()=>l(e.id),className:Y(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,s===e.id?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},e.id)),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)(ae,{className:`h-3.5 w-3.5`})})]})}function vn({fields:e,onFilterChange:t,className:n}){let[r,i]=Z.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),a=Z.useCallback(n=>{t(Array.from(n).map(t=>{let n=e.find(e=>e.field===t);return n?.defaultValues?[t,`in`,n.defaultValues]:[t,`!=`,null]}))},[e,t]),o=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),a(n),n})};return Z.useEffect(()=>{r.size>0&&a(r)},[]),(0,Q.jsx)(`div`,{className:Y(`flex items-center gap-1 overflow-x-auto`,n),"data-testid":`user-filters-toggle`,children:e.map(e=>(0,Q.jsx)(J,{variant:r.has(e.field)?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs shrink-0`,"data-testid":`filter-toggle-${e.field}`,onClick:()=>o(e.field),children:e.label||e.field},e.field))})}function yn(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 bn(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)?bn(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 xn(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Sn(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?bn(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function Cn(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=Sn(e.conditions.map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,yn(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var wn={"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.search":`Search`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.group":`Group`,"list.groupBy":`Group By`,"list.export":`Export`,"list.exportAs":`Export as {{format}}`,"list.color":`Color`,"list.rowColor":`Row Color`,"list.colorByField":`Color by field`,"list.clear":`Clear`,"list.none":`None`,"list.hideFields":`Hide fields`,"list.showAll":`Show all`,"list.pullToRefresh":`Pull to refresh`,"list.refreshing":`Refreshing…`,"list.dataLimitReached":`Showing first {{limit}} records. More data may be available.`,"list.addRecord":`Add record`,"list.tabs":`Tabs`,"list.allRecords":`All Records`,"list.share":`Share`,"list.print":`Print`,"list.hideFieldsTitle":`Hide Fields`,"table.rowsPerPage":`Rows per page`,"grid.toolbar.densityMode":`Density`,"grid.toolbar.densityCompact":`Compact`,"grid.toolbar.densityComfortable":`Comfortable`,"grid.toolbar.densitySpacious":`Spacious`,"grid.toolbar.densityCycleHint":`{{label}} (click to cycle)`,"grid.toolbar.densityCycleShortHint":`Click to cycle`,"list.viewSettings":`View settings`,"list.viewSettingsHint":`Grouping, color, density, and visible fields.`},Tn=(e,t,n)=>n,En=(e,t)=>{let n=wn[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n};function Dn(){try{let e=w();return e.t(`list.recordCount`)===`list.recordCount`?{t:En}:{t:e.t}}catch{return{t:En}}}function On(){try{let{fieldLabel:e,actionLabel:t}=$e();return{fieldLabel:e,actionLabel:t}}catch{return{fieldLabel:Tn,actionLabel:void 0}}}var kn=Z.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onHiddenFieldsChange:s,onColumnStateChange:l,onRowClick:u,showViewSwitcher:f,userFilterSelections:m,onUserFilterSelectionsChange:h,...g},v)=>{let b=f??e?.showViewSwitcher??!1,{t:x}=Dn(),{fieldLabel:C,actionLabel:w}=On(),{translateOptions:T}=ot(),E=Z.useMemo(()=>e.viewType&&e.viewType!==`list`?e:{...e,viewType:`grid`},[e]),O=Z.useCallback((e,t)=>E.objectName?C(E.objectName,e,t):t,[E.objectName,C]),k=Z.useCallback(e=>{let t=xn(e);return E.objectName&&typeof w==`function`?w(E.objectName,e,t):t},[E.objectName,w]),A=Z.useMemo(()=>{let e=E.userActions,t=E.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?E.showSearch!==!1:e.search,showSort:e?.sort===void 0?E.showSort!==!1:e.sort,showFilters:e?.filter===void 0?E.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?E.showDensity!==!1:e.rowHeight,showHideFields:E.showHideFields===!0,showGroup:E.showGroup!==!1,showColor:E.showColor===!0,compactToolbar:E.compactToolbar===!0,showAddRecord:t,addRecordPosition:E.addRecord?.position===`bottom`?`bottom`:`top`}},[E.userActions,E.showSearch,E.showSort,E.showFilters,E.showDensity,E.showHideFields,E.showGroup,E.showColor,E.compactToolbar,E.addRecord,E.userActions?.addRecordForm]),[j,M]=Z.useState(E.viewType),[N,ee]=Z.useState(``),[te,re]=Z.useState(!1),[ie,oe]=Z.useState(!1),[L,ce]=Z.useState(()=>E.sort&&E.sort.length>0?E.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}}):[]),le=Z.useMemo(()=>JSON.stringify(E.sort||[]),[E.sort]);Z.useEffect(()=>{E.sort&&E.sort.length>0?ce(E.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}})):ce([])},[le]);let[ue,z]=Z.useState(!1),[de,fe]=Z.useState({id:`root`,logic:`and`,conditions:[]}),[B,me]=Z.useState(()=>{if(!E.tabs||E.tabs.length===0)return;let e=m?._tab?.[0];return typeof e==`string`&&E.tabs.some(t=>t.name===e)?e:E.tabs.find(e=>e.isDefault)?.name??E.tabs[0]?.name});Z.useEffect(()=>{let e=E.tabs?.find(e=>e.name===B);if(e&&Array.isArray(e.filter)&&e.filter.length>0){let t=e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>({field:e.field,operator:e.operator??`equals`,value:e.value}));fe({id:`tab-filter-${e.name}`,logic:`and`,conditions:t})}},[]);let V=Z.useCallback(e=>{if(me(e.name),h?.({_tab:[e.name]}),e.filter){let t=Array.isArray(e.filter)?e.filter.filter(e=>e&&typeof e.field==`string`).map(e=>({field:e.field,operator:e.operator??`equals`,value:e.value})):e.filter.conditions||[],n={id:`tab-filter-${e.name}`,logic:!Array.isArray(e.filter)&&e.filter.logic||`and`,conditions:t};fe(n),r?.(n)}else{let e={id:`root`,logic:`and`,conditions:[]};fe(e),r?.(e)}},[r,h]),H=g.dataSource,[U,ge]=Z.useState([]),[W,ye]=Z.useState(()=>!(Array.isArray(E.data)||E.data&&typeof E.data==`object`&&E.data.provider===`value`&&Array.isArray(E.data.items))),[K,be]=Z.useState(null),[xe,Se]=Z.useState(!1),[we,Ee]=Z.useState(0),[De,Oe]=Z.useState(!1);Z.useImperativeHandle(v,()=>({refresh:()=>Ee(e=>e+1)}),[]),Z.useEffect(()=>{if(!(!H?.onMutation||!E.objectName||E.refreshTrigger))return H.onMutation(e=>{e.resource===E.objectName&&Ee(e=>e+1)})},[H,E.objectName,E.refreshTrigger]);let[ke,je]=Z.useState(void 0),Me=ke??E.pagination?.pageSize??100,Ne=Z.useMemo(()=>{if(E.grouping?.fields?.length)return E.grouping;let e=typeof E.groupBy==`string`?E.groupBy.trim():``,t=typeof E.groupBy2==`string`?E.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},[E.grouping,E.groupBy,E.groupBy2]),[q,Pe]=Z.useState(Ne),[Fe,Ie]=Z.useState(!1),Le=Z.useRef(Ne);Z.useEffect(()=>{Le.current!==Ne&&(Le.current=Ne,Pe(Ne))},[Ne]);let[Re,ze]=Z.useState(E.rowColor),[Be,He]=Z.useState(!1),[Ue,We]=Z.useState([]),Ge=Z.useRef(0),[Ke,Je]=Z.useState(()=>{let e=new Set;return E.quickFilters?.forEach(t=>{let n=_(t);n.defaultActive&&e.add(n.id)}),e}),[Ye,Xe]=Z.useState([]),Ze=Z.useMemo(()=>{let e=E.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:O(e,i.label||e),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});return n.length===0?e:{...e,fields:n}},[E.userFilters,K,O]),Qe=E.tabs&&E.tabs.length>0?void 0:Ze,[$e,tt]=Z.useState(()=>new Set(E.hiddenFields||[])),nt=Z.useMemo(()=>JSON.stringify(E.hiddenFields||[]),[E.hiddenFields]);Z.useEffect(()=>{tt(new Set(E.hiddenFields||[]))},[nt]);let at=Z.useCallback(e=>{tt(e),s?.(Array.from(e))},[s]),[st,ct]=Z.useState(!1),[lt,ut]=Z.useState(!1),dt=Z.useMemo(()=>y(E.quickFilters),[E.quickFilters]),ft=Z.useMemo(()=>{if(E.exportOptions)return Array.isArray(E.exportOptions)?{formats:E.exportOptions}:E.exportOptions},[E.exportOptions]),pt=p(Z.useMemo(()=>E.densityMode?E.densityMode:E.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[E.rowHeight]||`comfortable`:`compact`,[E.densityMode,E.rowHeight]),{onChange:E.onDensityChange}),mt=Z.useMemo(()=>`objectui:gallery:density:${E.objectName??`default`}`,[E.objectName]),[ht,gt]=Z.useState(()=>{if(typeof window>`u`)return E.gallery?.cardSize??`medium`;try{let e=window.localStorage.getItem(mt);if(e===`small`||e===`medium`||e===`large`)return e}catch{}return E.gallery?.cardSize??`medium`}),_t=Z.useCallback(()=>{gt(e=>{let t=e===`large`?`medium`:e===`medium`?`small`:`large`;try{window.localStorage.setItem(mt,t)}catch{}return t})},[mt]),{ref:vt,isRefreshing:yt,pullDistance:bt}=$t({onRefresh:Z.useCallback(async()=>{Ee(e=>e+1)},[]),enabled:!!H&&!!E.objectName}),xt=Z.useMemo(()=>E.id?`listview-${E.objectName}-${E.id}-view`:`listview-${E.objectName}-view`,[E.objectName,E.id]);Z.useEffect(()=>{let e=!0;return Se(!1),be(null),(async()=>{if(!H||!E.objectName){Se(!0);return}if(typeof H.getObjectSchema!=`function`){Se(!0);return}try{let t=await H.getObjectSchema(E.objectName);e&&be(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&Se(!0)}})(),()=>{e=!1}},[E.objectName,H]);let wt=Z.useMemo(()=>{let e=Array.isArray(E.fields)?E.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(E.kanban),n(E.options?.kanban),n(E.calendar),n(E.options?.calendar),n(E.gallery),n(E.options?.gallery),n(E.timeline),n(E.options?.timeline),n(E.gantt),n(E.options?.gantt);let r=t.size>0?Array.from(t):void 0;return S(K?.fields,r)},[K?.fields,E.fields,E.kanban,E.calendar,E.gallery,E.timeline,E.gantt,E.options]),Tt=o();Z.useEffect(()=>{let e=!0,t=++Ge.current;if(E.data&&typeof E.data==`object`&&!Array.isArray(E.data)){let e=E.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(N){let e=N.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}ge(t),ye(!1),Oe(!1);return}}if(Array.isArray(E.data)){let e=E.data;if(N){let t=N.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}ge(e),ye(!1),Oe(!1);return}return xe?((async()=>{if(!H||!E.objectName){ye(!1);return}ye(!0);try{let n=[],r=E.filters||[],i=Cn(de),a=[];dt&&Ke.size>0&&dt.forEach(e=>{Ke.has(e.id)&&e.filters&&e.filters.length>0&&a.push(e.filters)});let o=Sn(Ye),s=[...r.length>0?[r]:[],...i.length>0?[i]:[],...a,...o].filter(e=>Array.isArray(e)&&e.length>0);s.length>1?n=[`and`,...s]:s.length===1&&(n=s[0]);let c=L.length>0?L.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,l=(()=>{let e=Array.isArray(E.fields)?E.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[],t=Tt?.isLoaded&&E.objectName?e.filter(e=>Tt.checkField(E.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 wt)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(E.kanban),a(E.options?.kanban),a(E.calendar),a(E.options?.calendar),a(E.gallery),a(E.options?.gallery),a(E.timeline),a(E.options?.timeline);{let e=E.timeline??E.options?.timeline;e&&!Array.isArray(e.metaFields)&&(i(`status`),i(`priority`))}return a(E.gantt),a(E.options?.gantt),Array.from(n)})(),u=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,d=await H.find(E.objectName,{...u?{$filter:n}:{},$orderby:c,$top:Me,...l?{$select:l}:{},...wt.length>0?{$expand:wt}:{},...N?{$search:N,...E.searchableFields&&E.searchableFields.length>0?{$searchFields:E.searchableFields}:{}}:{}});if(!e||t!==Ge.current)return;let f=[];Array.isArray(d)?f=d:d&&typeof d==`object`&&(Array.isArray(d.data)?f=d.data:Array.isArray(d.records)?f=d.records:Array.isArray(d.value)&&(f=d.value)),ge(f),Oe(f.length>=Me)}catch(e){t===Ge.current&&console.error(`ListView data fetch error:`,e)}finally{e&&t===Ge.current&&ye(!1)}})(),()=>{e=!1}):void 0},[E.objectName,E.data,H,E.filters,Me,L,de,Ke,dt,Ye,we,N,E.searchableFields,wt,xe,E.refreshTrigger,Tt]);let Et=Z.useMemo(()=>{let e=[`grid`];(E.kanban?.groupByField||E.kanban?.groupField||E.options?.kanban?.groupField)&&e.push(`kanban`),(E.gallery?.coverField||E.gallery?.imageField||E.options?.gallery?.imageField)&&e.push(`gallery`),(E.calendar?.startDateField||E.options?.calendar?.startDateField)&&e.push(`calendar`),(E.timeline?.startDateField||E.options?.timeline?.startDateField||E.options?.timeline?.dateField||E.options?.calendar?.startDateField)&&e.push(`timeline`),(E.gantt?.startDateField||E.options?.gantt?.startDateField)&&e.push(`gantt`),(E.options?.map?.locationField||E.options?.map?.latitudeField&&E.options?.map?.longitudeField)&&e.push(`map`),E.viewType&&!e.includes(E.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`,`chart`].includes(E.viewType)&&e.push(E.viewType);let t=E.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},[E.options,E.viewType,E.kanban,E.calendar,E.gantt,E.gallery,E.timeline,E.appearance?.allowedVisualizations]);Z.useEffect(()=>{E.viewType&&M(E.viewType)},[E.viewType]);let Dt=Z.useCallback(e=>{M(e);try{localStorage.setItem(xt,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[xt,n]),Ot=Z.useCallback(e=>{ee(e),a?.(e)},[a]),kt=d({navigation:E.navigation,objectName:E.objectName,onNavigate:E.onNavigate,onRowClick:u}),X=Z.useMemo(()=>{let e=E.fields||[];if(Array.isArray(e)||(e=[]),Tt?.isLoaded&&E.objectName&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t?Tt.checkField(E.objectName,t,`read`):!0})),$e.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!$e.has(t)})),E.fieldOrder&&E.fieldOrder.length>0){let t=new Map(E.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},[E.fields,E.objectName,$e,E.fieldOrder,Tt]),At=Z.useMemo(()=>{let e=pt.mode===`compact`?`compact`:pt.mode===`spacious`?`tall`:`medium`,t={objectName:E.objectName,fields:X,filters:E.filters,sort:L,className:`h-full w-full`,showSearch:!1,onRowClick:kt.handleClick,rowHeight:e,hideRowHeightToggle:!0,...E.striped==null?{}:{striped:E.striped},...E.bordered==null?{}:{bordered:E.bordered},...l?{onColumnStateChange:l}:{},...E.columnState?{columnState:E.columnState}:{}};switch(j){default:case`grid`:return{type:`object-grid`,...t,columns:X,...E.conditionalFormatting?{conditionalFormatting:E.conditionalFormatting}:{},...E.inlineEdit==null?{}:{editable:E.inlineEdit},...E.wrapHeaders==null?{}:{wrapHeaders:E.wrapHeaders},...E.virtualScroll==null?{}:{virtualScroll:E.virtualScroll},...E.resizable==null?{}:{resizable:E.resizable},...E.selection?{selection:E.selection}:{},...E.pagination?{pagination:E.pagination}:{},...q?{grouping:q}:{},...Re?{rowColor:Re}:{},...E.rowActions?{rowActions:E.rowActions}:{},...E.rowActionDefs?{rowActionDefs:E.rowActionDefs}:{},...E.bulkActions?{batchActions:E.bulkActions}:{},...E.bulkActionDefs?{bulkActionDefs:E.bulkActionDefs}:{},...E.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...t,groupBy:E.kanban?.groupField||E.options?.kanban?.groupField||`status`,groupField:E.kanban?.groupField||E.options?.kanban?.groupField||`status`,...E.kanban?.titleField||E.options?.kanban?.titleField?{titleField:E.kanban?.titleField||E.options?.kanban?.titleField}:{},cardFields:E.kanban?.cardFields||X||[],...q?{grouping:q}:{},...E.options?.kanban||{},...E.kanban||{}};case`calendar`:return{type:`object-calendar`,...t,startDateField:E.calendar?.startDateField||E.options?.calendar?.startDateField||`start_date`,endDateField:E.calendar?.endDateField||E.options?.calendar?.endDateField||`end_date`,...E.calendar?.titleField||E.options?.calendar?.titleField?{titleField:E.calendar?.titleField||E.options?.calendar?.titleField}:{},...E.calendar?.defaultView?{defaultView:E.calendar.defaultView}:{},...E.options?.calendar||{},...E.calendar||{}};case`gallery`:{let e={...E.options?.gallery||{},...E.gallery||{},cardSize:ht};return{type:`object-gallery`,...t,gallery:Object.keys(e).length>0?e:void 0,imageField:E.gallery?.coverField||E.gallery?.imageField||E.options?.gallery?.imageField,titleField:E.gallery?.titleField||E.options?.gallery?.titleField||`name`,subtitleField:E.gallery?.subtitleField||E.options?.gallery?.subtitleField,...q?{grouping:q}:{}}}case`timeline`:{let e={...E.options?.timeline||{},...E.timeline||{}};return{type:`object-timeline`,...t,timeline:Object.keys(e).length>0?e:void 0,startDateField:E.timeline?.startDateField||E.options?.timeline?.startDateField||E.options?.timeline?.dateField||`created_at`,titleField:E.timeline?.titleField||E.options?.timeline?.titleField||`name`,...E.timeline?.endDateField?{endDateField:E.timeline.endDateField}:{},...E.timeline?.groupByField?{groupByField:E.timeline.groupByField}:{},...E.timeline?.colorField?{colorField:E.timeline.colorField}:{},...E.timeline?.scale?{scale:E.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...t,startDateField:E.gantt?.startDateField||E.options?.gantt?.startDateField||`start_date`,endDateField:E.gantt?.endDateField||E.options?.gantt?.endDateField||`end_date`,progressField:E.gantt?.progressField||E.options?.gantt?.progressField||`progress`,dependenciesField:E.gantt?.dependenciesField||E.options?.gantt?.dependenciesField||`dependencies`,...E.gantt?.titleField?{titleField:E.gantt.titleField}:{},...E.options?.gantt||{},...E.gantt||{}};case`map`:return{type:`object-map`,...t,locationField:E.options?.map?.locationField||`location`,...E.options?.map||{}};case`chart`:{let e=E.chart||E.options?.chart||{},t=Array.isArray(e.yAxisFields)&&e.yAxisFields[0]||e.valueField||`value`,n=e.xAxisField||e.categoryField||`name`;return{type:`object-chart`,objectName:E.objectName,chartType:e.chartType||`bar`,filters:E.filters,aggregate:{field:t,function:e.aggregation||`count`,groupBy:n},xAxisKey:n,series:[{dataKey:t,label:t}],className:`h-[400px] w-full`}}}},[j,E,L,X,q,Re,kt.handleClick,pt.mode,ht]),jt=de.conditions&&de.conditions.length>0,Mt=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 E.objectName?T(E.objectName,e,n):n};if(e=K?.fields?Object.entries(K.fields).map(([e,n])=>({value:e,label:O(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})):(E.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let n=e.name||e.fieldName;return{value:n,label:O(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}}),E.filterableFields&&E.filterableFields.length>0){let t=new Set(E.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[K,E.fields,E.filterableFields,E.objectName,O,T]),Nt=Z.useCallback(e=>{Je(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Ft=Z.useCallback(e=>{let t=ft,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||E.objectName||`export`,a=n>0?U.slice(0,n):U;if(e===`csv`){let e=X.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];r&&t.push(e.join(`,`)),a.forEach(n=>{t.push(e.map(e=>{let t=n[e],r;return r=t==null?``:Array.isArray(t)?t.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof t==`object`?JSON.stringify(t):String(t),r.includes(`,`)||r.includes(`"`)||r.includes(`
2
2
  `)||r.includes(`\r`)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`))});let n=new Blob([t.join(`
3
3
  `)],{type:`text/csv;charset=utf-8;`}),o=URL.createObjectURL(n),s=document.createElement(`a`);s.href=o,s.download=`${i}.csv`,s.click(),URL.revokeObjectURL(o)}else if(e===`json`){let e=new Blob([JSON.stringify(a,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${i}.json`,n.click(),URL.revokeObjectURL(t)}ut(!1)},[U,X,ft,E.objectName]),It=Z.useMemo(()=>(E.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:O(e,e)};let t=e.name||e.fieldName||e.field;return{name:t,label:O(t,e.label||e.name||e.field)}}),[E.fields,O]);return(0,Q.jsxs)(`div`,{ref:vt,className:Y(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,t),...E.aria?.label?{"aria-label":E.aria.label}:{},...E.aria?.describedBy?{"aria-describedby":E.aria.describedBy}:{},...E.aria?.live?{"aria-live":E.aria.live}:{},role:`region`,children:[bt>0&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:bt},children:x(yt?`list.refreshing`:`list.pullToRefresh`)}),E.description&&E.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 E.description==`string`?E.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.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto min-w-0`,children:[E.tabs&&E.tabs.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`hidden sm:block shrink-0`,children:(0,Q.jsx)(on,{tabs:E.tabs,activeTab:B,onTabChange:V,className:`!px-0 !py-0`})}),(0,Q.jsx)(`div`,{className:`sm:hidden shrink-0`,children:(0,Q.jsx)(sn,{tabs:E.tabs,activeTab:B,onTabChange:V,className:`!px-0 !py-0`})})]}),Qe&&(0,Q.jsx)(`div`,{className:`shrink-0 min-w-0 overflow-x-auto`,"data-testid":`user-filters`,children:(0,Q.jsx)(mn,{config:Qe,objectDef:K,data:U,onFilterChange:Xe,maxVisible:3,initialSelections:m,onSelectionsChange:h})})]}),(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:[b&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(nn,{currentView:j,availableViews:Et,onViewChange:Dt}),(0,Q.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5`})]}),A.showHideFields&&!A.compactToolbar&&(0,Q.jsxs)(D,{open:st,onOpenChange:ct,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,$e.size>0&&`text-primary`),children:[(0,Q.jsx)(G,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.hideFields`)}),$e.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:$e.size})]})}),(0,Q.jsx)(it,{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:x(`list.hideFieldsTitle`)}),$e.size>0&&(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>at(new Set),children:x(`list.showAll`)})]}),(0,Q.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:It.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:!$e.has(e.name),onChange:()=>{let t=new Set($e);t.has(e.name)?t.delete(e.name):t.add(e.name),at(t)},className:`rounded border-input`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),A.showHideFields&&!A.compactToolbar&&(A.showFilters||A.showSort||A.showGroup)&&(0,Q.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),A.showFilters&&(0,Q.jsxs)(D,{open:ue,onOpenChange:z,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,jt&&`text-foreground font-medium`),children:[(0,Q.jsx)(et,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.filter`)}),jt&&(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:de.conditions?.length||0})]})}),(0,Q.jsx)(it,{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:x(`list.filterRecords`)})}),(0,Q.jsx)(R,{fields:Mt,value:de,onChange:e=>{fe(e),r&&r(e)}})]})})]}),A.showGroup&&!A.compactToolbar&&(0,Q.jsxs)(D,{open:Fe,onOpenChange:Ie,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,q&&`text-foreground font-medium`),children:[(0,Q.jsx)(Ct,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.group`)}),q&&q.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:q.fields.length})]})}),(0,Q.jsx)(it,{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:x(`list.groupBy`)}),q&&(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Pe(void 0),"data-testid":`clear-grouping`,children:x(`list.clear`)})]}),(0,Q.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,Q.jsx)(ve,{value:q,fieldOptions:It.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:x(`list.addGroup`,{defaultValue:`Add group field`}),collapseTitle:x(`list.collapsedByDefault`,{defaultValue:`Collapsed by default`}),removeTitle:x(`list.removeGroup`,{defaultValue:`Remove`})},onChange:e=>Pe(e)})})]})})]}),A.showSort&&(0,Q.jsxs)(D,{open:ie,onOpenChange:oe,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,L.length>0&&`text-foreground font-medium`),children:[(0,Q.jsx)(rt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.sort`)}),L.length>0&&(0,Q.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center text-[10px] font-medium text-muted-foreground tabular-nums`,children:L.length})]})}),(0,Q.jsx)(it,{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:x(`list.sortRecords`)})}),(0,Q.jsx)(ne,{fields:Mt,value:L,onChange:e=>{ce(e),i&&i(e)}})]})})]}),!A.compactToolbar&&(A.showFilters||A.showSort||A.showGroup)&&(A.showColor||A.showDensity)&&(0,Q.jsx)(`div`,{className:`hidden sm:block h-5 w-px bg-border/50 mx-1 shrink-0`}),A.showColor&&!A.compactToolbar&&(0,Q.jsxs)(D,{open:Be,onOpenChange:He,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:Y(`hidden sm:inline-flex h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Re&&`text-foreground font-medium`),children:[(0,Q.jsx)(qe,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.color`)})]})}),(0,Q.jsx)(it,{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:x(`list.rowColor`)}),Re&&(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>ze(void 0),"data-testid":`clear-row-color`,children:x(`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:x(`list.colorByField`)}),(0,Q.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:Re?.field||``,onChange:e=>{let t=e.target.value;ze(t?{field:t,colors:Re?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,Q.jsx)(`option`,{value:``,children:x(`list.none`)}),It.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),A.showDensity&&!A.compactToolbar&&j!==`gallery`&&(()=>{let e=pt.mode===`compact`?F:pt.mode===`comfortable`?P:_e,t=pt.mode===`compact`?x(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):pt.mode===`comfortable`?x(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):x(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${x(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=x(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,"aria-label":n,className:Y(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,pt.mode!==`compact`&&`text-foreground font-medium`),onClick:pt.cycle,title:r,children:(0,Q.jsx)(e,{className:`h-3.5 w-3.5`})})})(),A.showDensity&&!A.compactToolbar&&j===`gallery`&&(()=>{let e=ht===`small`?F:ht===`medium`?P:_e,t=ht===`small`?x(`grid.toolbar.densityCompact`,{defaultValue:`Compact`}):ht===`medium`?x(`grid.toolbar.densityComfortable`,{defaultValue:`Comfortable`}):x(`grid.toolbar.densitySpacious`,{defaultValue:`Spacious`}),n=`${x(`grid.toolbar.densityMode`,{defaultValue:`Density`})}: ${t}`,r=x(`grid.toolbar.densityCycleHint`,{defaultValue:`{{label}} (click to cycle)`,label:n});return(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,"aria-label":n,className:Y(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary transition-colors duration-150`,ht!==`small`&&`text-foreground font-medium`),onClick:_t,title:r,children:(0,Q.jsx)(e,{className:`h-3.5 w-3.5`})})})(),A.compactToolbar&&(A.showGroup||A.showColor||A.showDensity||A.showHideFields)&&(0,Q.jsx)(ln,{t:x,allFields:It,showGroup:A.showGroup,groupingConfig:q,setGroupingConfig:Pe,showColor:A.showColor,rowColorConfig:Re,setRowColorConfig:ze,showDensity:A.showDensity,density:pt,showHideFields:A.showHideFields,hiddenFields:$e,updateHiddenFields:at}),(A.showColor||A.showDensity||A.compactToolbar)&&ft&&E.allowExport!==!1&&(0,Q.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}),ft&&E.allowExport!==!1&&(0,Q.jsxs)(D,{open:lt,onOpenChange:ut,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsxs)(J,{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)(Qt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.export`)})]})}),(0,Q.jsx)(it,{align:`start`,className:`w-48 p-2`,children:(0,Q.jsx)(`div`,{className:`space-y-1`,children:(ft.formats||[`csv`,`json`]).map(e=>(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,onClick:()=>Ft(e),children:[(0,Q.jsx)(Qt,{className:`h-3.5 w-3.5 mr-2`}),x(`list.exportAs`,{format:e.toUpperCase()})]},e))})})]}),(E.sharing?.enabled||E.sharing?.type)&&(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${E.sharing?.visibility||E.sharing?.type||`private`}`,"data-testid":`share-button`,children:[(0,Q.jsx)(Wt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.share`)})]}),E.allowPrinting&&(0,Q.jsxs)(J,{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)(Zt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.print`)})]}),(()=>{let e=E.allowPrinting||E.sharing?.enabled||E.sharing?.type||ft&&E.allowExport!==!1;return A.showSearch&&e?(0,Q.jsx)(`div`,{className:`h-5 w-px bg-border/50 mx-1 shrink-0`}):null})(),A.showSearch&&(0,Q.jsxs)(D,{open:te,onOpenChange:re,children:[(0,Q.jsx)(zt,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`sm`,className:Y(`hidden sm:inline-flex h-7 w-7 p-0 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,N&&`text-foreground font-medium`),"data-testid":`search-icon-button`,title:x(`list.search`),children:(0,Q.jsx)(Ce,{className:`h-3.5 w-3.5`})})}),(0,Q.jsx)(it,{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)(Ce,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,Q.jsx)(St,{placeholder:x(`list.search`)+`...`,value:N,onChange:e=>Ot(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),N&&(0,Q.jsx)(J,{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:()=>Ot(``),children:(0,Q.jsx)(Te,{className:`h-3 w-3`})})]})})]}),A.showAddRecord&&A.addRecordPosition===`top`&&(0,Q.jsxs)(J,{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:()=>g.onAddRecord?.(),children:[(0,Q.jsx)(ae,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.addRecord`)})]})]})]}),dt&&dt.length>0&&(0,Q.jsx)(`div`,{className:`hidden sm:flex border-b px-2 sm:px-4 py-1 items-center gap-1 flex-wrap bg-background`,"data-testid":`quick-filters`,children:dt.map(e=>{let t=Ke.has(e.id),n=e.icon?Ve[e.icon.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null;return(0,Q.jsxs)(J,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs`,onClick:()=>Nt(e.id),children:[n&&(0,Q.jsx)(n,{className:`h-3 w-3 mr-1.5`}),e.label]},e.id)})}),(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)(he,{active:W&&U.length>0}),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:x(`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&&j===`grid`?(()=>{let e=E.emptyState?.icon,t=e?Ve[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??se:se,n=!!(N&&N.trim())||Array.isArray(Ye)&&Ye.length>0||Ke.size>0||Array.isArray(de?.conditions)&&de.conditions.length>0,r=(typeof E.emptyState?.title==`string`?E.emptyState.title:void 0)??x(n?`list.noMatches`:`list.firstRunTitle`),i=(typeof E.emptyState?.message==`string`?E.emptyState.message:void 0)??x(n?`list.noMatchesMessage`:`list.firstRunMessage`);return(0,Q.jsx)(pe,{"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:A.showAddRecord?(0,Q.jsxs)(J,{variant:`default`,size:`sm`,"data-testid":`empty-state-add-record`,onClick:()=>g.onAddRecord?.(),children:[(0,Q.jsx)(ae,{className:`h-4 w-4 mr-1.5`}),x(`list.addRecord`)]}):void 0})})():(0,Q.jsx)(c,{schema:At,...g,data:U,loading:W,onRowSelect:We})]},j),A.showAddRecord&&A.addRecordPosition===`bottom`&&(0,Q.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,Q.jsxs)(J,{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:()=>g.onAddRecord?.(),children:[(0,Q.jsx)(ae,{className:`h-3.5 w-3.5 mr-1.5`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:x(`list.addRecord`)})]})}),E.bulkActions&&E.bulkActions.length>0&&Ue.length>0&&j!==`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)(Pt,{className:`h-3.5 w-3.5 text-primary shrink-0`}),(0,Q.jsxs)(`span`,{className:`font-medium`,children:[Ue.length,` `,Ue.length===1?`item`:`items`,` selected`]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 ml-3`,children:E.bulkActions.map(e=>{let t=String(e).toLowerCase(),n=t.includes(`delete`)||t.includes(`remove`)||t.includes(`destroy`),r=n?Ae:null;return(0,Q.jsxs)(J,{variant:n?`destructive`:`outline`,size:`sm`,className:`h-7 px-2.5 text-xs gap-1.5`,onClick:()=>g.onBulkAction?.(e,Ue),"data-testid":`bulk-action-${e}`,children:[r&&(0,Q.jsx)(r,{className:`h-3 w-3`}),k(e)]},e)})}),(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-xs ml-auto gap-1`,onClick:()=>We([]),children:[(0,Q.jsx)(Te,{className:`h-3 w-3`}),`Clear`]})]}),!W&&U.length>0&&E.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?x(`list.recordCountOne`,{count:U.length}):x(`list.recordCount`,{count:U.length})}),De&&(0,Q.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:x(`list.dataLimitReached`,{limit:Me})}),E.pagination?.pageSizeOptions&&E.pagination.pageSizeOptions.length>0&&(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{children:x(`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),g.onPageSizeChange&&g.onPageSizeChange(t)},children:E.pagination.pageSizeOptions.map(e=>(0,Q.jsx)(`option`,{value:String(e),children:e},e))})]})]}),kt.isOverlay&&(0,Q.jsx)(I,{...kt,title:E.label?`${E.label} Detail`:E.objectName?`${E.objectName.charAt(0).toUpperCase()+E.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))})})]})});kn.displayName=`ListView`;var An={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`},jn={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`},Mn=new Set([`number`,`currency`,`percent`,`integer`,`decimal`]),Nn=[{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 Pn(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return Nn[Math.abs(t)%Nn.length]}var Fn=({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:Y(`w-full overflow-hidden relative`,r),hidden:a,children:c?n===`contain`?(0,Q.jsx)(`div`,{className:Y(`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:Y(`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:Y(`text-5xl font-semibold tracking-tight opacity-90`,i.text),children:t[0]?.toUpperCase()})})})},In=({imageUrl:e,title:t,placeholder:n})=>{let[r,i]=(0,Z.useState)(!1),a=!!e&&!r;return(0,Q.jsx)(`div`,{className:Y(`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:Y(`text-base font-semibold`,n.text),children:t[0]?.toUpperCase()})})};C.register(`object-gallery`,e=>{let{schema:t}=e,n=(0,Z.useContext)(f),r=e.dataSource||n?.dataSource,i=h(t.bind),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),p=d({navigation:t.navigation,objectName:t.objectName,onRowClick:e.onRowClick??e.onCardClick}),m=t.gallery,g=m?.coverField??t.imageField??`image`,_=m?.coverFit??`cover`,v=m?.cardSize??`medium`,y=m?.titleField??t.titleField??`name`,b=m?.visibleFields,{fieldLabel:x,fieldOptionLabel:C}=ot(),w=(0,Z.useCallback)(e=>{let n=l?.fields?.[e],r={name:e};if(n){n.type&&(r.type=n.type),n.label&&(r.label=n.label),n.options&&(r.options=n.options),n.currency&&(r.currency=n.currency),n.precision!==void 0&&(r.precision=n.precision),n.format&&(r.format=n.format);let e=n.reference_to||n.reference;e&&(r.reference_to=e),n.reference_field&&(r.reference_field=n.reference_field)}if(t.objectName){let n=String(r.label??e);r.label=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},[l,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&&u(n)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[t.objectName,r]),(0,Z.useEffect)(()=>{let n=!0;if(e.data&&Array.isArray(e.data)){o(e.data);return}return t.objectName&&!i&&!t.data&&!e.data&&(async()=>{if(!(!r||typeof r.find!=`function`||!t.objectName)){n&&c(!0);try{let e=S(l?.fields),i=await r.find(t.objectName,{$filter:t.filter,...e.length>0?{$expand:e}:{}}),a=[];if(Array.isArray(i))a=i;else if(i&&typeof i==`object`){let e=i;Array.isArray(e.records)?a=e.records:Array.isArray(e.data)&&(a=e.data)}n&&o(a)}catch(e){console.error(`[ObjectGallery] Fetch error:`,e)}finally{n&&c(!1)}}})(),()=>{n=!1}},[t.objectName,r,i,t.data,t.filter,e.data,l]);let T=e.data||i||t.data||a||[],E=(0,Z.useMemo)(()=>T.some(e=>typeof e[g]==`string`&&!!e[g]),[T,g]),D=t.grouping?.fields,O=!!(D&&D.length>0),[k,A]=(0,Z.useState)({}),j=(0,Z.useMemo)(()=>D?D.some(e=>e.collapsed):!1,[D]),N=(0,Z.useCallback)(e=>{A(t=>({...t,[e]:t[e]===void 0?!j:!t[e]}))},[j]),P=(0,Z.useMemo)(()=>{if(!O||!D)return[];let e=new Map,t=[];for(let n of T){let r=D.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=D.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=D[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,D,O,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 F=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=ct(r)||r.type||`text`,a=Qe(i),o=r?.label&&String(r.label).trim()?String(r.label):void 0,s=o!=null&&Mn.has(i);return(0,Q.jsxs)(`div`,{className:Y(`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)})}),ee=(n,r)=>{let i=n.id??n._id??r,a=String(n[y]??`Untitled`),o=n[g],s=Pn(String(i)+`|`+a),c=Y(`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 E&&_===`contain`?(0,Q.jsxs)(X,{role:`listitem`,className:c,onClick:e=>p.handleClick(n,e),children:[(0,Q.jsx)(`div`,{"aria-hidden":!0,className:Y(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,Q.jsx)(L,{className:`p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(In,{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}),F(n)]})]})})]},i):(0,Q.jsxs)(X,{role:`listitem`,className:c,onClick:e=>p.handleClick(n,e),children:[!E&&(0,Q.jsx)(`div`,{"aria-hidden":!0,className:Y(`absolute inset-x-0 top-0 h-[3px] bg-gradient-to-r`,s.bg)}),(0,Q.jsx)(Fn,{imageUrl:o,title:a,coverFit:_,aspectClass:jn[v],placeholder:s,hidden:!E}),(0,Q.jsxs)(L,{className:Y(`p-3`,E&&`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}),F(n)]})]},i)},te=e=>(0,Q.jsx)(`div`,{className:Y(`grid gap-4 p-4 auto-rows-min content-start`,An[v],t.className),role:`list`,children:e.map((e,t)=>ee(e,t))});return(0,Q.jsxs)(Q.Fragment,{children:[O?(0,Q.jsx)(`div`,{className:`space-y-2`,children:P.map(e=>(0,Q.jsxs)(`div`,{className:`border rounded-md`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>N(e.key),children:[e.collapsed?(0,Q.jsx)(Jt,{className:`h-4 w-4 shrink-0`}):(0,Q.jsx)(M,{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),p.isOverlay&&(0,Q.jsx)(I,{...p,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`}),C.register(`list-view`,kn,{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:{}}}),C.register(`list`,kn,{namespace:`view`,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 Ln=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function Rn(e){return Ln.has(e)}function zn(e,t){let n;return n=e<=3?1:2,t!==void 0&&t<640?Math.min(n,1):n}function Bn(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&Rn(e.type)?{...e,span:t}:e)}function Vn(e,t,n){if(t!==void 0)return{fields:Bn(e,t),columns:t};let r=zn(e.length,n);return{fields:Bn(e,r),columns:r}}function Hn(e,t){return function(){try{let n=w();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 $=Hn({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.cancel":`Cancel`,"detail.cancelEdit":`Discard changes`,"detail.openInNewTab":`Open in new tab`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.noValue":`No value`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter...`,"detail.highlightFields":`Key Fields`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.createdBy":`Created by`,"detail.updatedBy":`Updated by`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCountPlural":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.sendComment":`Send`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.showEmptyRelated_one":`+ {{count}} empty`,"detail.showEmptyRelated_other":`+ {{count}} empty`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.replyCount":`{{count}} reply`,"detail.replyCountPlural":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`,"detail.concurrentUpdateTitle":`This record was modified by someone else`,"detail.concurrentUpdateDescription":`Another user saved a newer version of {{field}} while you were editing. To prevent silently overwriting their change, please choose how to resolve the conflict.`,"detail.concurrentUpdateYourEdit":`Your edit`,"detail.concurrentUpdateCurrentValue":`Current value`,"detail.concurrentUpdateUpdatedBy":`Updated by {{name}}`,"detail.concurrentUpdateUpdatedAt":`Updated at {{when}}`,"detail.concurrentUpdateReload":`Reload latest`,"detail.concurrentUpdateOverwrite":`Overwrite anyway`,"detail.concurrentUpdateCancel":`Cancel`},`detail.back`);function Un(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``}var Wn=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,virtualScroll:s})=>{let[l,u]=Z.useState(e.defaultCollapsed??!1),[d,f]=Z.useState(null),[p,m]=Z.useState(void 0),[h,g]=Z.useState(!1),{t:_}=$(),{fieldLabel:v,translateOptions:y}=ot(),b=Z.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{f(e),setTimeout(()=>f(null),2e3)})},[]),x=Z.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),S=Z.useMemo(()=>e.fields.filter(x).length,[e.fields,x]),C=ge(),w=C?3:4,T=C?.2:.25,E=e.fields.length-S,D=!e.hideEmpty&&!a&&e.fields.length>=w&&S/e.fields.length>=T&&E>0,O=!h&&(e.hideEmpty||D)?e.fields.filter(e=>!x(e)):e.fields;if(O.length===0&&S===e.fields.length)return null;let{fields:A,columns:N}=Vn(O,e.columns),P=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,Q.jsx)(c,{schema:e.render,data:{...t,value:n}});let s=Un(e.span,N),l=r?.fields?.[e.name],u={...e};if(l){!e.type&&l.type&&(u.type=l.type),l.options&&!u.options&&(u.options=l.options),l.currency&&!u.currency&&(u.currency=l.currency),l.precision!==void 0&&u.precision===void 0&&(u.precision=l.precision),l.format&&!u.format&&(u.format=l.format);let t=l.reference_to||l.reference;t&&!u.reference_to&&(u.reference_to=t),l.reference_field&&!u.reference_field&&(u.reference_field=l.reference_field)}i&&Array.isArray(u.options)&&u.options.length>0&&(u.options=y(i,e.name,u.options));let f=(()=>{if(n==null||n===``)return(0,Q.jsx)(`span`,{className:`text-muted-foreground/60 text-sm select-none`,"aria-label":_(`detail.noValue`,{defaultValue:`No value`}),title:_(`detail.noValue`,{defaultValue:`No value`}),children:`—`});let t=ct(u)||e.type;if(t){let e=Qe(t);if(e)return(0,Q.jsx)(e,{value:n,field:u})}return String(n)})(),p=n!=null&&n!==``,m=d===e.name;return(0,Q.jsxs)(`div`,{className:Y(`space-y-1.5 group`,s),children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:v(i||``,e.name,e.label||e.name)}),a&&!e.readonly?(0,Q.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(()=>{let t=u.type||e.type;if(t===`select`&&Array.isArray(u.options)&&u.options.length>0)return(0,Q.jsx)(Se,{field:u,value:n==null?``:String(n),onChange:t=>o?.(e.name,t)});if(t===`boolean`)return(0,Q.jsx)(j,{field:u,value:!!n,onChange:t=>o?.(e.name,t)});let r=t===`date`||t===`datetime`;return(0,Q.jsx)(`input`,{type:t===`number`?`number`:r?`date`:`text`,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:n==null?``:r?(()=>{let e=String(n);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleDateString(`en-CA`)})():String(n),onChange:t=>{let n=t.target.value;if(r&&n){let t=new Date(n+`T00:00:00`).toISOString();o?.(e.name,t)}else o?.(e.name,n)}})})()}):(0,Q.jsxs)(`div`,{className:Y(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,p&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:p?()=>b(e.name,n):void 0,onKeyDown:p?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),b(e.name,n))}:void 0,role:p?`button`:void 0,tabIndex:p?0:void 0,children:[(0,Q.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:f}),p&&(0,Q.jsx)(k,{children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),b(e.name,n)},children:m?(0,Q.jsx)(Gt,{className:`h-3 w-3 text-green-600`}):(0,Q.jsx)(ce,{className:`h-3 w-3`})})}),(0,Q.jsx)(_t,{children:_(m?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},F=s?.enabled===!0,ee=s?.batchSize??20;Z.useEffect(()=>{if(!F){m(void 0);return}if(A.length<=ee){m(void 0);return}m(ee);let e=setTimeout(()=>m(void 0),100);return()=>clearTimeout(e)},[F,A.length,ee]);let te=p===void 0?A:A.slice(0,p),ne=S>0&&(e.hideEmpty||D),ie=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:Y(`grid gap-3 sm:gap-4`,N===1?`grid-cols-1`:N===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:te.map(P)}),ne&&(0,Q.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,Q.jsxs)(J,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>g(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[h?(0,Q.jsx)(G,{className:`h-3.5 w-3.5 mr-1.5`}):(0,Q.jsx)(H,{className:`h-3.5 w-3.5 mr-1.5`}),h?_(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):_(`detail.showEmptyFields`,{count:S,defaultValue:`Show ${S} empty field${S===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,Q.jsx)(`div`,{className:Y(n),children:ie}):e.collapsible?(0,Q.jsx)(Oe,{open:!l,onOpenChange:e=>u(!e),className:n,children:(0,Q.jsxs)(X,{children:[(0,Q.jsx)(re,{asChild:!0,children:(0,Q.jsxs)(Fe,{className:Y(`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)(ze,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsx)(`span`,{children:e.title})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:l?(0,Q.jsx)(Jt,{className:`h-4 w-4 text-muted-foreground`}):(0,Q.jsx)(M,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!l&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]})}),(0,Q.jsx)(Me,{children:(0,Q.jsx)(L,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ie})})]})}):(0,Q.jsxs)(X,{className:Y(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,Q.jsxs)(Fe,{className:Y(`py-3 px-4 sm:py-4 sm:px-6`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,Q.jsx)(ze,{className:`flex items-center justify-between text-base font-semibold tracking-tight`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,Q.jsx)(`span`,{children:e.title})]})}),e.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.description})]}),(0,Q.jsx)(L,{className:`pt-3 sm:pt-4 px-3 sm:px-6 pb-4 sm:pb-5`,children:ie})]})},Gn=({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)(Tt,{value:r,onValueChange:i,className:n,children:[(0,Q.jsx)(pt,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,Q.jsx)(We,{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)(E,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,Q.jsx)(Nt,{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)(c,{schema:e,data:t},n))}):(0,Q.jsx)(c,{schema:e.content,data:t})})},e.key))]})};function Kn(e){return e&&Ve[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||se}var qn=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:s,dataSource:l,objectName:u,onNew:d,onViewAll:f,onRowEdit:p,onRowDelete:m,onRowClick:h,maxColumns:g=6,pageSize:_,sortable:v=!1,filterable:y=!1,collapsible:b=!1,defaultCollapsed:x=!1,referenceField:S,parentId:C,icon:w})=>{let T=r!==void 0,D=r??[],[O,k]=Z.useState(D),[A,j]=Z.useState(()=>!!n&&!T),[N,P]=Z.useState(0),[F,te]=Z.useState(null),[ne,re]=Z.useState(`asc`),[ie,oe]=Z.useState(``),[I,se]=Z.useState(null),[ce,le]=Z.useState(x),[R,ue]=Z.useState({}),{t:z}=$(),{fieldLabel:de}=ot();Z.useEffect(()=>{T&&k(r??[])},[r,T]),Z.useEffect(()=>{n&&l?.getObjectSchema&&l.getObjectSchema(n).then(se).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,l]),Z.useEffect(()=>{if(n&&!T){if(!(S&&C!=null&&C!==``)){n&&(C==null||C===``)&&!S&&console.warn(`[RelatedList] "${n}" has no referenceField/parentId — refusing to fetch all rows. Pass relationshipField + parentId to scope the query.`),k([]),j(!1);return}j(!0);let e={[S]:C};if(l&&typeof l.find==`function`)l.find(n,{$filter:e}).then(e=>{k(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),j(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),j(!1)});else{let e=new URLSearchParams({[`filter[${S}]`]:String(C)}).toString();fetch(`${n}?${e}`).then(e=>e.json()).then(e=>{k(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>j(!1))}}},[n,T,l,S,C]),Z.useEffect(()=>{if(!l?.find||!I?.fields||!O.length)return;let e=I.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 O){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=R[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})=>l.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||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||ue(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[l,I,O]);let fe=Z.useMemo(()=>{if(!ie)return O;let e=ie.toLowerCase();return O.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[O,ie]),pe=Z.useMemo(()=>F?[...fe].sort((e,t)=>{let n=e[F],r=t[F];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 ne===`asc`?i:-i}):fe,[fe,F,ne]),B=_&&_>0?_:0,me=B?Math.max(1,Math.ceil(pe.length/B)):1,V=B?pe.slice(N*B,(N+1)*B):pe;Z.useEffect(()=>{P(0)},[ie,F,ne]);let he=Z.useCallback(e=>{F===e?re(e=>e===`asc`?`desc`:`asc`):(te(e),re(`asc`))},[F]),[H,U]=Z.useState(null),_e=Z.useCallback(e=>{U(e)},[]),W=Z.useCallback(()=>{H&&m?.(H),U(null)},[H,m]),ve=o(),G=Z.useMemo(()=>{let e=u||n||``,t=t=>!ve?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||t?.field||t?.name;return n?ve.checkField(e,String(n),`read`):!0}),r=e=>S?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==S):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>O.length?e.filter(e=>{let t=e?.accessorKey||e?.field||e?.name;return t?O.some(e=>!i(e?.[t])):!0}):e,s=(e,t)=>{if(!t?.type)return;let n=Qe(ct({type:t.type,format:t.format})||t.type);if(!n)return;let r=t.type===`lookup`||t.type===`master_detail`?R[e]:void 0,i=r&&Object.keys(r).length>0?Object.entries(r).map(([e,t])=>({value:e,label:t})):void 0,a={name:e,label:t.label||e,type:t.type,...(i||t.options)&&{options:i||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.format&&{format:t.format},...(t.reference_to||t.reference)&&{reference_to:t.reference_to||t.reference},...t.reference_field&&{reference_field:t.reference_field}};return e=>e==null?Z.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):Z.createElement(n,{value:e,field:a})},c=t=>{if(typeof t!=`string`){let e=t?.accessorKey||t?.field||t?.name;if(t&&!t.cell&&!t.render&&e){let n=I?.fields?.[e],r=n?s(String(e),n):void 0;if(r)return{...t,cell:r}}return t}let n=I?.fields?.[t],r={accessorKey:t,header:n?.label||de(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(!I?.fields)return[];let l=e,d=new Set([`image`,`file`,`attachment`,`rich_text`,`html`,`json`]),f=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],p=Object.entries(I.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===S||t?.hidden||t?.type&&d.has(t.type)||ve?.isLoaded&&l&&!ve.checkField(l,e,`read`)));return p.sort(([e,t],[n,r])=>{let i=f.indexOf(e),a=f.indexOf(n),o=i>=0?i:100,s=a>=0?a:100;if(o!==s)return o-s;let c=t?.type===`select`||e.includes(`status`);return c===(r?.type===`select`||n.includes(`status`))?0:c?-1:1}),o(p.map(([e,t])=>{let n={accessorKey:e,header:de(l,e,t.label||e)};if(t.type){let r=s(e,t);r&&(n.cell=r)}return n})).slice(0,Math.max(1,g))},[a,I,u,n,de,S,O,g,R,ve]),ye=!!p||!!m,K=ge(),be=Z.useMemo(()=>{if(i)return i;if(K&&(t===`grid`||t===`table`)){let e=G[0]?.accessorKey||G[0]?.field||G[0]?.name,t=G.slice(1,4).map(e=>e.accessorKey||e.field||e.name).filter(Boolean);return{type:`object-gallery`,data:V,objectName:n,gallery:{titleField:e||`name`,visibleFields:t,cardSize:`medium`},onRowClick:h}}switch(t){case`grid`:case`table`:return{type:`data-table`,data:V,columns:G,pagination:!1,pageSize:B||10,searchable:!1,exportable:!1,rowActions:ye,onRowEdit:p,onRowDelete:m?_e:void 0,onRowClick:h};case`list`:return{type:`data-list`,data:V};default:return{type:`div`,children:`No view configured`}}},[t,V,G,i,B,ye,p,m,_e,h,K,n]),xe=b?`cursor-pointer select-none`:void 0,Se=b?()=>le(e=>!e):void 0,Ce=Kn(w),we=!A&&O.length===0,Te=y;return(0,Q.jsxs)(X,{className:Y(`shadow-none border-border/60 bg-transparent`,we&&`bg-muted/10`,s),children:[(0,Q.jsx)(Fe,{className:Y(`py-3 px-4 sm:py-3 min-h-12 sm:min-h-0`,xe),onClick:Se,children:(0,Q.jsxs)(ze,{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:[b&&(ce?(0,Q.jsx)(Jt,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,Q.jsx)(M,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,Q.jsx)(Ce,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:Y(`truncate`,we&&`text-muted-foreground font-medium`),children:e}),(0,Q.jsx)(E,{variant:`secondary`,className:Y(`text-xs font-normal h-5 px-1.5`,O.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${O.length} records`,children:O.length}),we&&(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground/70 italic ml-1 truncate`,children:z(`detail.noRelatedRecords`)})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:d&&(0,Q.jsxs)(J,{variant:we?`ghost`:`outline`,size:`sm`,onClick:e=>{e.stopPropagation(),d()},className:`gap-1 h-9 sm:h-7 text-xs shadow-none`,children:[(0,Q.jsx)(ae,{className:`h-3.5 w-3.5`}),z(`detail.new`)]})})]})}),!ce&&!we&&(0,Q.jsxs)(L,{className:Y(`pt-0 pb-4 px-4`),children:[Te&&(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(St,{placeholder:z(`detail.filterPlaceholder`),value:ie,onChange:e=>oe(e.target.value),className:`h-8 text-sm`})}),v&&G&&G.length>0&&O.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:G.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,r=F===t;return(0,Q.jsxs)(J,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>he(t),children:[(0,Q.jsx)(rt,{className:`h-3 w-3`}),n,r&&(ne===`asc`?` ↑`:` ↓`)]},t)})}),A?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:z(`detail.loading`)}):(0,Q.jsx)(c,{schema:be}),B>0&&pe.length>B&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:N===0,onClick:()=>P(e=>Math.max(0,e-1)),children:[(0,Q.jsx)(Ee,{className:`h-3 w-3`}),z(`detail.previousPage`)]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:z(`detail.pageOf`,{current:N+1,total:me})}),(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:N>=me-1,onClick:()=>P(e=>Math.min(me-1,e+1)),children:[z(`detail.nextPage`),(0,Q.jsx)(Jt,{className:`h-3 w-3`})]})]}),f&&!we&&B>0&&pe.length>B&&(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:[z(`detail.viewAll`),(0,Q.jsx)(ee,{className:`h-3 w-3`})]})})]}),(0,Q.jsx)(Et,{open:H!==null,onOpenChange:e=>{e||U(null)},children:(0,Q.jsxs)(vt,{children:[(0,Q.jsxs)(st,{children:[(0,Q.jsx)(Dt,{children:z(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,Q.jsx)(Ut,{children:z(`detail.deleteRowConfirmation`)})]}),(0,Q.jsxs)(tt,{children:[(0,Q.jsx)(Ze,{children:z(`detail.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsx)(It,{onClick:W,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:z(`detail.delete`,{defaultValue:`Delete`})})]})]})})]})},Jn=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o})=>{let s=e.collapsible??!0,[c,l]=Z.useState(e.defaultCollapsed??!1),u=(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,Q.jsx)(Wn,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o},n))});return s?(0,Q.jsxs)(Oe,{open:!c,onOpenChange:e=>l(!e),className:n,children:[(0,Q.jsx)(re,{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:[c?(0,Q.jsx)(Jt,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,Q.jsx)(M,{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&&!c&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,Q.jsx)(Me,{children:(0,Q.jsx)(`div`,{className:`mt-3`,children:u})})]}):(0,Q.jsxs)(`div`,{className:Y(`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}),u]})},Yn=({fields:e,data:t,className:n,objectName:r,objectSchema:i})=>{let{fieldLabel:a}=ot();if(!e.length||!t)return null;let o=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return o.length===0?null:(0,Q.jsx)(`section`,{className:Y(`@container border-b border-border/60 pb-4`,n),"aria-label":`Record highlights`,children:(0,Q.jsx)(`div`,{className:Y(`flex flex-wrap gap-x-8 gap-y-3`),children:o.map(e=>{let n=t[e.name],o=i?.fields?.[e.name],s=e.type||o?.type,c={name:e.name,label:e.label,type:s||`text`,...o?.options&&{options:o.options},...o?.currency&&{currency:o.currency},...o?.precision!==void 0&&{precision:o.precision},...o?.format&&{format:o.format}},l=Qe(ct(c)||s||`text`),u=s===`number`||s===`integer`||s===`currency`||s===`percent`||s===`decimal`,d=s===`email`||s===`url`||s===`textarea`,f=s===`boolean`;return(0,Q.jsxs)(`div`,{className:Y(`flex flex-col gap-1 min-w-[8rem] basis-[10rem]`,d?`max-w-[24rem] basis-[16rem]`:`max-w-[16rem]`),children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:a(r||``,e.name,e.label)}),f?n?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-600 ring-1 ring-inset ring-emerald-500/30 dark:text-emerald-400`,children:[(0,Q.jsx)(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)(Te,{className:`h-3 w-3`,"aria-hidden":!0}),`No`]}):(0,Q.jsx)(`span`,{className:Y(`block min-w-0 truncate`,u?`text-xl md:text-2xl font-semibold leading-tight tabular-nums tracking-tight`:`text-sm font-semibold`),children:(0,Q.jsx)(l,{value:n,field:c})})]},e.name)})})})};function Xn(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 Zn=({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)(X,{className:Y(``,i),children:[(0,Q.jsx)(Fe,{children:(0,Q.jsxs)(ze,{className:`flex items-center gap-2 text-base`,children:[(0,Q.jsx)(Kt,{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)(L,{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)(Ce,{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)(Te,{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)(J,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,Q.jsx)(qt,{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:Y(`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:Xn(e.createdAt)}),e.pinned&&(0,Q.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,Q.jsx)(z,{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)(z,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},Qn={field_change:He,create:nt,delete:Ae,comment:Kt,status_change:bt},$n={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 er(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 tr(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 nr={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},rr=({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)(X,{className:Y(``,r),children:[(0,Q.jsx)(Fe,{children:(0,Q.jsxs)(ze,{className:`flex items-center gap-2 text-base`,children:[(0,Q.jsx)(Je,{className:`h-4 w-4`}),`Activity`,(0,Q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,Q.jsxs)(L,{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(nr).map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:Y(`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(Qn[e]||He,{className:`h-3 w-3`}),nr[e]]},e))}),o.length===0?(0,Q.jsx)(pe,{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=Qn[e.type]||He;return(0,Q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,Q.jsx)(`div`,{className:Y(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,$n[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:tr(e)})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:er(e.timestamp)})]})]},e.id)})})]})]})]})},ir={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`};function ar(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var or=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function sr(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 or){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return ar(e)}r/=n}return ar(e)}function cr(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 lr(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 ur({entries:e,loading:t,emptyText:n,className:r,locale:i}){return t?(0,Q.jsx)(`div`,{className:Y(`space-y-3`,r),children:Array.from({length:4}).map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(V,{className:`h-8 w-8 rounded-full`}),(0,Q.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,Q.jsx)(V,{className:`h-4 w-1/3`}),(0,Q.jsx)(V,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,Q.jsx)(`div`,{className:Y(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,r),children:n??`No history yet`}):(0,Q.jsx)(k,{delayDuration:150,children:(0,Q.jsx)(`ol`,{className:Y(`space-y-4`,r),children:e.map((e,t)=>{let n=(e.action??``).toLowerCase(),r=ir[n]??`outline`,a=typeof e.user_name==`string`&&e.user_name.trim()||`Unknown user`,o=ar(e.created_at),s=sr(e.created_at,i),c=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,Q.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(at,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[c?(0,Q.jsx)(wt,{src:c,alt:a}):null,(0,Q.jsx)(Bt,{className:`text-[10px] font-medium`,children:cr(e.user_name)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:a}),e.action&&(0,Q.jsx)(E,{variant:r,className:`text-[10px] uppercase tracking-wide`,children:e.action}),o&&(0,Q.jsxs)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":o,children:s||o})}),(0,Q.jsx)(_t,{children:o})]})]}),e.summary&&(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(n===`create`?(0,Q.jsxs)(`details`,{className:`mt-1 group`,children:[(0,Q.jsxs)(`summary`,{className:`cursor-pointer list-none text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 select-none`,children:[(0,Q.jsx)(`span`,{className:`transition-transform group-open:rotate-90`,children:`▸`}),(0,Q.jsx)(`span`,{children:e.changes.length===1?`1 field populated`:`${e.changes.length} fields populated`})]}),(0,Q.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground pl-4`,children:e.changes.map(e=>(0,Q.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,Q.jsx)(`span`,{className:`text-foreground`,children:lr(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:lr(e.from)}),` → `,(0,Q.jsx)(`span`,{className:`text-foreground`,children:lr(e.to)})]},e.field))}))]})]},e.id??t)})})})}var dr={createdAt:`created_at`,createdBy:`created_by`,updatedAt:`updated_at`,updatedBy:`updated_by`};function fr(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 mr(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var hr=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference_to||r?.reference,a={name:n,type:r?.type||(i?`lookup`:`text`),...i&&{reference_to:i},...r?.reference_field&&{reference_field:r.reference_field}},o=ct(a)||a.type;if(o){let t=Qe(o);if(t)return(0,Q.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:(0,Q.jsx)(t,{value:e,field:a})})}return(0,Q.jsx)(`span`,{children:String(e)})},gr=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,Q.jsx)(k,{delayDuration:200,children:(0,Q.jsxs)(W,{children:[(0,Q.jsx)(gt,{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)(_t,{side:`top`,children:mr(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)(hr,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,Q.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},_r=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=$();if(!e)return null;let a=fr(e[dr.createdAt]),o=fr(e[dr.updatedAt]),s=e[dr.createdBy],c=e[dr.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:Y(`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)(gr,{label:i(`detail.createdBy`),user:s,date:a,objectSchema:t,userField:dr.createdBy,t:i}),d&&(0,Q.jsx)(gr,{label:i(`detail.updatedBy`),user:c,date:o,objectSchema:t,userField:dr.updatedBy,t:i})]})},vr=5;function yr(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,i=typeof r==`string`?r:r&&typeof r==`object`&&typeof r.source==`string`?r.source:void 0;if(i){let t=`[-\\u2013\\u2014|/·,:]`,n=!1,r=i.replace(/\{([^{}]+)\}/g,(t,r)=>{let i=String(r).trim().split(`.`),a=e;for(let e of i){if(a==null)break;a=a[e]}if(a&&typeof a==`object`){let e=a,t=e.name??e.full_name??e.display_name??e.label??e.title??e.subject??null;(t==null||typeof t==`string`&&!t.trim())&&(t=[e.salutation,e.first_name,e.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e.email==`string`&&e.email.trim()?e.email.trim():null)),a=t}return a!=null&&a!==``?(n=!0,String(a)):`\0`});if(n){let e=r.replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim();if(e)return e}}}if(t.title)return t.title;if(e&&typeof e==`object`)for(let t of[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(n!=null&&n!==``)return String(n)}return r}var br=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:s=!1,onFieldSave:l,discussionSlot:u,rightRail:d,objectLabel:f,onDataLoaded:p,isFavorite:m,onToggleFavorite:h})=>{let[g,_]=Z.useState(e.data),[v,y]=Z.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[b,x]=Z.useState(!1),C=m??b,[w,T]=Z.useState(!1),[D,A]=Z.useState({}),[j,M]=Z.useState(!1),[N,P]=Z.useState(null),[F,ee]=Z.useState(null),[te,ne]=Z.useState(!1),[re,ie]=Z.useState(0),[ae,oe]=Z.useState(!1),{t:I}=$(),{fieldOptionLabel:se}=ot(),L=ge(),le=o(),R=Z.useMemo(()=>{if(!le?.isLoaded||!e.objectName)return e;let t=t=>le.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,le]);Z.useEffect(()=>{g&&p&&p(g)},[g,p]);let ue=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(F?.fields)for(let[e,n]of Object.entries(F.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>g?.[e]!==void 0&&g?.[e]!==null&&g?.[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,F,g]),z=R.summaryFields&&R.summaryFields.length>0?R.summaryFields:ue,de=Z.useCallback(()=>{R.resourceId&&navigator.clipboard.writeText(String(R.resourceId)).then(()=>{ne(!0),setTimeout(()=>ne(!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&&ee(t)}).catch(()=>{}),()=>{e=!1};if(t&&R.objectName&&R.resourceId){y(!0),ee(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;ee(o);let s=S(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,re]);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]),pe=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]),B=Z.useCallback(async()=>{if(!t?.cancelPendingApproval||!R.objectName||!R.resourceId){P(I(`detail.cancelApprovalUnavailable`));return}oe(!0),P(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{}ie(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*/,``);P(`${I(`detail.cancelApprovalFailed`)}: ${t}`)}finally{oe(!1)}},[t,R.objectName,R.resourceId,I]),me=Z.useCallback(()=>{let e=R.deleteConfirmation||I(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),R.onNavigate&&R.objectName&&R.onNavigate(`/${R.objectName}`,{replace:!0}))},[i,R]),he=Z.useCallback(()=>{navigator.share&&R.objectName&&R.resourceId?navigator.share({title:R.title||I(`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]),H=Z.useCallback(()=>{let e=!C;h&&h(e),m===void 0&&x(e)},[C,m,h]),U=Z.useCallback(async()=>{if(w){let e=Object.entries(D);if(e.length>0){let t=g,n={...g,...D};_(n),P(null),M(!0);try{if(l)for(let[t,r]of e)await l(t,r,n);A({}),T(!1)}catch(e){_(t),P((e?.message||e?.error||String(e??`Save failed`)).replace(/^\[[^\]]+\]\s*/,``).replace(/^[A-Z][A-Z0-9_]+:\s*/,``))}finally{M(!1)}return}A({})}T(!w),P(null)},[w,D,g,l]),_e=Z.useCallback(()=>{A({}),T(!1),P(null)},[]),ve=Z.useCallback((e,t)=>{A(n=>({...n,[e]:t}))},[]);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]),Z.useEffect(()=>{if(!s||R.showHeader!==!1)return;let e=`objectui:record:inline-edit-toggle`,t=e=>{let t=e.detail;t?.recordId&&R.recordId&&t.recordId!==R.recordId||t?.objectName&&R.objectName&&t.objectName!==R.objectName||U()};return window.addEventListener(e,t),()=>window.removeEventListener(e,t)},[s,R.showHeader,R.recordId,R.objectName,U]);let G=Z.useMemo(()=>R.related??[],[R.related]),ye=Z.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:I(`detail.share`),icon:`share-2`,type:`script`,onClick:he}),R.showEdit&&e.push({name:`sys_edit_mobile`,label:I(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:pe}),s&&e.push({name:`sys_toggle_inline_edit_mobile`,label:I(w?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:U}),R.showDelete&&e.push({name:`sys_delete`,label:I(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:me}),e},[I,R.showEdit,R.showDelete,s,w,he,pe,U,me]),K=Z.useMemo(()=>{let e=R.actions??[];if(ye.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,...ye]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:ye}),n},[R.actions,ye]);return v||R.loading?(0,Q.jsxs)(`div`,{className:Y(`space-y-4`,n),children:[(0,Q.jsx)(V,{className:`h-10 w-full`}),(0,Q.jsx)(V,{className:`h-64 w-full`}),(0,Q.jsx)(V,{className:`h-48 w-full`})]}):!g&&!R.data?(0,Q.jsxs)(`div`,{className:Y(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,Q.jsx)(`p`,{className:`text-lg font-semibold`,children:I(`detail.recordNotFound`)}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:I(`detail.recordNotFoundDescription`)}),(R.showBack??!0)&&(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:fe,className:`mt-4 gap-2`,children:[(0,Q.jsx)(jt,{className:`h-4 w-4`}),I(`detail.goBack`)]})]}):(0,Q.jsx)(k,{children:(0,Q.jsxs)(`div`,{className:Y(`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)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,onClick:fe,className:`shrink-0 mt-1`,children:(0,Q.jsx)(jt,{className:`h-4 w-4`})})}),(0,Q.jsx)(_t,{children:I(`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:yr(g,R,F,I(`detail.details`))}),z.map(e=>{let t=g?.[e];if(t==null||t===``)return null;let n=(R.sections||[]).flatMap(e=>e.fields).concat(R.fields||[]).find(t=>t.name===e),r=F?.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=n?.currency||r?.currency;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?se(R.objectName,e,String(t),o):o}}catch{}return o===null?(0,Q.jsx)(E,{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)(E,{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)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:H,"aria-label":I(C?`detail.removeFromFavorites`:`detail.addToFavorites`),children:C?(0,Q.jsx)(xt,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,Q.jsx)(xt,{className:`h-4 w-4 text-muted-foreground`})})}),(0,Q.jsx)(_t,{children:I(C?`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:f||R.objectName}),R.resourceId&&(0,Q.jsxs)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:de,"aria-label":I(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:te?(0,Q.jsx)(Gt,{className:`h-3 w-3 text-green-600`}):(0,Q.jsx)(ce,{className:`h-3 w-3`})})}),(0,Q.jsx)(_t,{children:te?I(`detail.copied`,{defaultValue:`Copied`}):I(`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)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsx)(J,{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)(Ee,{className:`h-4 w-4`})})}),(0,Q.jsx)(_t,{children:I(`detail.previousRecord`)})]}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:I(`detail.recordOf`,{current:R.recordNavigation.currentIndex+1,total:R.recordNavigation.recordIds.length})}),(0,Q.jsxs)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsx)(J,{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)(Jt,{className:`h-4 w-4`})})}),(0,Q.jsx)(_t,{children:I(`detail.nextRecord`)})]})]}),s&&(0,Q.jsxs)(Q.Fragment,{children:[w&&(0,Q.jsxs)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:_e,className:`gap-2 hidden sm:inline-flex`,children:[(0,Q.jsx)(Te,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:I(`detail.cancel`)})]})}),(0,Q.jsx)(_t,{children:I(`detail.cancelEdit`)})]}),(0,Q.jsxs)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsx)(J,{variant:w?`default`:`outline`,size:`sm`,onClick:U,className:`gap-2 hidden sm:inline-flex`,children:w?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Gt,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:I(`detail.save`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(He,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:I(`detail.editInline`)})]})})}),(0,Q.jsx)(_t,{children:I(w?`detail.saveChanges`:`detail.editFieldsInline`)})]})]}),R.showEdit&&(0,Q.jsxs)(W,{children:[(0,Q.jsx)(gt,{asChild:!0,children:(0,Q.jsxs)(J,{variant:`default`,onClick:pe,className:`gap-2 hidden sm:inline-flex`,children:[(0,Q.jsx)(He,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:I(`detail.edit`)})]})}),(0,Q.jsx)(_t,{children:I(`detail.editRecord`)})]}),K.map((e,t)=>(0,Q.jsx)(c,{schema:e,data:g},`header-action-${t}`))]})]}),R.header&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(c,{schema:R.header,data:g})}),R.highlightFields&&R.highlightFields.length>0&&(0,Q.jsx)(Yn,{fields:R.highlightFields,data:g,objectName:R.objectName,objectSchema:F}),s&&R.showHeader===!1&&(()=>{let e=g?.approval_status,n=e===`pending`||e===`in_approval`;return!w&&!j&&!N&&!n?null:(0,Q.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[n&&!w&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{role:`status`,className:`inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2 py-1 text-xs text-amber-800`,title:I(`detail.lockedTooltip`),children:[(0,Q.jsx)(O,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:I(`detail.lockedByApproval`)})]}),t?.cancelPendingApproval&&(0,Q.jsxs)(J,{variant:`outline`,size:`sm`,onClick:B,disabled:ae,className:`gap-2 border-amber-300 text-amber-800 hover:bg-amber-50`,title:I(`detail.cancelApprovalTooltip`),children:[(0,Q.jsx)(Te,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:I(ae?`detail.cancelApprovalInFlight`:`detail.cancelApproval`)})]})]}),w&&(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:_e,className:`gap-2`,disabled:j,children:[(0,Q.jsx)(Te,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:I(`detail.cancel`)})]}),(0,Q.jsxs)(J,{variant:w?`default`:`outline`,size:`sm`,onClick:U,className:`gap-2`,disabled:j||n&&!w,title:n&&!w?I(`detail.lockedTooltip`):void 0,children:[w?(0,Q.jsx)(Gt,{className:`h-4 w-4`}):(0,Q.jsx)(He,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:I(j?`detail.saving`:w?`detail.save`:`detail.editFieldsInline`)})]})]}),N&&(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:N})]})})(),R.autoTabs&&!R.tabs?.length?(()=>{let e=G.length>0,n=!!R.activities&&R.activities.length>0,r=!!u,i=!!R.history,a=(0,Q.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[R.sectionGroups&&R.sectionGroups.length>0&&R.sectionGroups.map((e,t)=>(0,Q.jsx)(Jn,{group:e,data:{...g,...D},objectSchema:F,objectName:R.objectName,isEditing:w,onFieldChange:ve},t)),R.sections&&R.sections.length>0&&R.sections.map((e,t)=>(0,Q.jsx)(Wn,{section:e,data:{...g,...D},objectSchema:F,objectName:R.objectName,isEditing:w,onFieldChange:ve},t)),R.fields&&R.fields.length>0&&!R.sections?.length&&(0,Q.jsx)(Wn,{section:{fields:R.fields,columns:R.columns},data:{...g,...D},objectSchema:F,objectName:R.objectName,isEditing:w,onFieldChange:ve}),R.comments&&(0,Q.jsx)(Zn,{comments:R.comments,onAddComment:R.onAddComment})]});return!e&&!n&&!r&&!i?(0,Q.jsx)(`div`,{className:`mt-2`,children:a}):(0,Q.jsxs)(Tt,{defaultValue:`details`,className:`w-full`,children:[(0,Q.jsxs)(pt,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,Q.jsx)(We,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:I(`detail.details`)}),e&&(0,Q.jsx)(We,{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:[I(`detail.related`),(0,Q.jsx)(E,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:G.length})]})}),n&&(0,Q.jsx)(We,{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:[I(`detail.activity`),(0,Q.jsx)(E,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:R.activities.length})]})}),r&&(0,Q.jsx)(We,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:I(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,Q.jsx)(We,{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:[I(`detail.history`,{defaultValue:`History`}),!R.history.loading&&R.history.entries.length>0&&(0,Q.jsx)(E,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:R.history.entries.length})]})})]}),(0,Q.jsx)(Nt,{value:`details`,className:`mt-4 motion-safe:data-[state=active]:animate-in motion-safe:data-[state=active]:fade-in-0 motion-safe:duration-150`,children:a}),e&&(0,Q.jsx)(Nt,{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:G.map((e,n)=>(0,Q.jsx)(qn,{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:L&&n>0,pageSize:vr},n))})}),n&&(0,Q.jsx)(Nt,{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)(rr,{activities:R.activities})}),r&&(0,Q.jsx)(Nt,{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:u}),i&&(0,Q.jsx)(Nt,{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)(ur,{entries:R.history.entries,loading:R.history.loading,emptyText:R.history.emptyText??I(`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,t)=>(0,Q.jsx)(Jn,{group:e,data:{...g,...D},objectSchema:F,objectName:R.objectName,isEditing:w,onFieldChange:ve},t))}),R.sections&&R.sections.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:R.sections.map((e,t)=>(0,Q.jsx)(Wn,{section:e,data:{...g,...D},objectSchema:F,objectName:R.objectName,isEditing:w,onFieldChange:ve},t))}),R.fields&&R.fields.length>0&&!R.sections?.length&&(0,Q.jsx)(Wn,{section:{fields:R.fields,columns:R.columns},data:{...g,...D},objectSchema:F,objectName:R.objectName,isEditing:w,onFieldChange:ve}),R.tabs&&R.tabs.length>0&&(0,Q.jsx)(Gn,{tabs:R.tabs,data:g}),G.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:I(`detail.related`)}),G.map((e,n)=>(0,Q.jsx)(qn,{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:L&&n>0,pageSize:vr},n))]}),R.comments&&(0,Q.jsx)(Zn,{comments:R.comments,onAddComment:R.onAddComment}),R.activities&&R.activities.length>0&&(0,Q.jsx)(rr,{activities:R.activities})]}),(0,Q.jsx)(_r,{data:{...g,...D},objectSchema:F,objectName:R.objectName}),R.footer&&(0,Q.jsx)(`div`,{children:(0,Q.jsx)(c,{schema:R.footer,data:g})})]})})},xr=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)}},Sr=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()}},Cr=({open:e,conflict:t,onReload:n,onOverwrite:r,onCancel:i,busy:a=!1})=>{let{t:o}=$(),s=t?.label||t?.field||``,c=t?xr(t.pendingValue):``,l=t?xr(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=Sr(u.updated_at??t?.currentVersion),[p,m]=o(`detail.concurrentUpdateDescription`,{field:`{{field}}`}).split(`{{field}}`);return(0,Q.jsx)(Et,{open:e,onOpenChange:e=>{!e&&!a&&i()},children:(0,Q.jsxs)(vt,{className:`max-w-lg`,children:[(0,Q.jsx)(st,{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)(be,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`flex-1`,children:[(0,Q.jsx)(Dt,{children:o(`detail.concurrentUpdateTitle`)}),(0,Q.jsxs)(Ut,{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)(tt,{className:`gap-2 sm:gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:Y(ut({variant:`ghost`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateCancel`)}),(0,Q.jsx)(`button`,{type:`button`,disabled:a,onClick:r,className:Y(ut({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:Y(ut({variant:`default`}),`mt-2 sm:mt-0`),children:o(`detail.concurrentUpdateReload`)})]})]})})};function wr(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`CONCURRENT_UPDATE`||t.name===`ConcurrentUpdateError`}var Tr=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name)||null,Er=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}},Dr=({schema:e={},className:t,...n})=>{let r=b(),{designer:i}=Er(n);if(!r)return(0,Q.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:details — bind a record to preview`})});let a=e.layout===`inline`||e.layout===`compact`?`horizontal`:`vertical`,c=r.objectName||``,l=o(),{readableFields:u}=s(c),{sectionLabel:d}=ot(),f=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(f.length>0&&c&&!f.every(e=>l.can(c,e)))return(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let p=e.enforceFieldSecurity===!0,m=Array.isArray(e.redactFields)?e.redactFields:[],h=e=>{if(!e||!p&&m.length===0)return e;let t=e.map(Tr).filter(e=>!!e),n=new Set((p&&c?u(t):t).filter(e=>!m.includes(e)));return e.filter(e=>{let t=Tr(e);return t?n.has(t):!0})},g=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,_=e=>Array.isArray(e)?e.map(g):e,v=x(),y=new Set((Array.isArray(e.hideFields)?e.hideFields:[]).map(e=>typeof e==`string`?e:Tr(e)).filter(e=>!!e));for(let e of v)y.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]!==``){y.add(e);break}let T=e=>!e||y.size===0?e:e.filter(e=>{let t=Tr(e);return t?!y.has(t):!0}),E=T(_(h(e.fields))),D=Array.isArray(e.sections)?e.sections.map(e=>{let t=e.title??e.label,n=e.name&&c?d(c,e.name,t??e.name):t;return{...e,title:n,showBorder:e.showBorder??!!n,hideEmpty:e.hideEmpty??!0,fields:T(_(h(e.fields)))}}):e.sections,O=e.inlineEdit??!0,[k,A]=Z.useState(null),[j,M]=Z.useState(!1),N=Z.useCallback(t=>{let n=[...Array.isArray(e.fields)?e.fields:[],...(Array.isArray(e.sections)?e.sections:[]).flatMap(e=>Array.isArray(e?.fields)?e.fields:[])];for(let e of n)if((typeof e==`string`?e:e?.name||e?.field)===t)return typeof e==`object`?e?.label:void 0},[e.fields,e.sections]),P=Z.useCallback(async(e,t)=>{let n=r.dataSource,i=r.recordId,a=r.objectName;if(!n||!i||!a)return;let o=typeof r.data?.updated_at==`string`?r.data.updated_at:void 0,s=o?{ifMatch:o}:void 0;try{if(typeof n.update==`function`)await n.update(a,i,{[e]:t},s);else if(typeof n.updateOne==`function`)await n.updateOne(a,i,{[e]:t},s);else if(typeof n.patch==`function`)await n.patch(a,i,{[e]:t},s);else{console.warn(`[record:details] DataSource exposes no update/updateOne/patch method; cannot persist inline edit`);return}typeof r.refresh==`function`&&await r.refresh()}catch(n){if(wr(n)){let r=n.currentRecord??null;throw A({field:e,label:N(e),pendingValue:t,currentValue:r?r[e]:void 0,currentVersion:n.currentVersion,currentRecord:r}),n}throw console.error(`[record:details] Inline-edit save failed`,n),n}},[r.dataSource,r.recordId,r.objectName,r.data,r.refresh,N]),F=Z.useCallback(()=>{A(null),M(!1)},[]),ee=Z.useCallback(async()=>{M(!0);try{typeof r.refresh==`function`&&await r.refresh()}finally{F()}},[r.refresh,F]),te=Z.useCallback(async()=>{if(!k){F();return}let e=r.dataSource,t=r.recordId,n=r.objectName;if(!e||!t||!n){F();return}M(!0);try{let i=k.currentVersion?{ifMatch:k.currentVersion}:void 0;typeof e.update==`function`?await e.update(n,t,{[k.field]:k.pendingValue},i):typeof e.updateOne==`function`?await e.updateOne(n,t,{[k.field]:k.pendingValue},i):typeof e.patch==`function`&&await e.patch(n,t,{[k.field]:k.pendingValue},i),typeof r.refresh==`function`&&await r.refresh()}catch(e){console.error(`[record:details] Overwrite-on-conflict failed`,e)}finally{F()}},[k,r.dataSource,r.recordId,r.objectName,r.refresh,F]),ne={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:a,columns:e.columns,sections:D,fields:E,showBack:!1,showHeader:e.showHeader??!1,inlineEdit:O};return(0,Q.jsxs)(`div`,{className:t,...i,children:[(0,Q.jsx)(br,{schema:ne,dataSource:r.dataSource,inlineEdit:O,onFieldSave:P}),(0,Q.jsx)(Cr,{open:!!k,conflict:k,busy:j,onCancel:F,onReload:ee,onOverwrite:te})]})},Or=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name||e.key)||null,kr=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}},Ar=({schema:e={},className:t,...n})=>{let r=b(),{designer:i}=kr(n),a=ot(),c=e.objectName,l=c&&a.objectLabel?a.objectLabel({name:c,label:yt(c)}):c?yt(c):``,u=e.title||l||`Related`;if(!c)return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});let d=o(),{readableFields:f}=s(c),p=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(p.length>0&&!p.every(e=>d.can(c,e)))return(0,Q.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let m=e.enforceFieldSecurity===!0,h=Array.isArray(e.redactFields)?e.redactFields:[],g=Array.isArray(e.columns)?e.columns:[],_=g;if(m||h.length>0){let e=g.map(Or).filter(e=>!!e),t=new Set((m?f(e):e).filter(e=>!h.includes(e)));_=g.filter(e=>{let n=Or(e);return n?t.has(n):!0})}return(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(qn,{title:u,type:`table`,api:c,objectName:c,referenceField:e.relationshipField,parentId:r?.recordId,columns:_,pageSize:e.limit,dataSource:r?.dataSource})})},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}},Mr=({schema:e={},className:t,...n})=>{let r=b(),{designer:i}=jr(n),a=r?.objectName||``,c=o(),{readableFields:l}=s(a),u=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(u.length>0&&a&&!u.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 d=(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),f=e.enforceFieldSecurity===!0,p=Array.isArray(e.redactFields)?e.redactFields:[],m=f&&a?new Set(l(d.map(e=>e.name))):null,h=d.filter(e=>!(p.includes(e.name)||m&&!m.has(e.name)));return g(Z.useId(),h.map(e=>e.name)),(0,Q.jsx)(`div`,{className:t,...i,children:(0,Q.jsx)(Yn,{fields:h,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema})})},Nr=({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:Y(`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)(Rt,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`text-foreground`,children:i})]})},Pr=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],Fr=({reactions:e,onToggleReaction:t,emojiOptions:n=Pr,className:r})=>{let[i,a]=Z.useState(!1),o=Z.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,Q.jsxs)(`div`,{className:Y(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,Q.jsxs)(`button`,{type:`button`,className:Y(`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)(J,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,Q.jsx)(Vt,{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 Ir(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 Lr=({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:Y(`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)(M,{className:`h-3 w-3`}):(0,Q.jsx)(Jt,{className:`h-3 w-3`}),(0,Q.jsx)(Kt,{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:Ir(e.createdAt)})]}),(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)(J,{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)(qt,{className:`h-3 w-3`})})]})]})},Rr=({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)(J,{variant:`ghost`,size:`icon`,className:Y(`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)(de,{className:`h-4 w-4 text-primary`}):(0,Q.jsx)(le,{className:`h-4 w-4 text-muted-foreground`})})};function zr(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 Br=({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
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:Y(`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)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:x,disabled:o||u,title:l(`detail.bold`),children:(0,Q.jsx)(ie,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:S,disabled:o||u,title:l(`detail.italic`),children:(0,Q.jsx)(ue,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:C,disabled:o||u,title:l(`detail.listFormat`),children:(0,Q.jsx)(B,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:w,disabled:o||u,title:l(`detail.inlineCode`),children:(0,Q.jsx)(Be,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:T,disabled:o||u,title:l(`detail.mentionSomeone`),children:(0,Q.jsx)(Ie,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>d(!u),title:l(u?`detail.edit`:`detail.preview`),children:u?(0,Q.jsx)(He,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(H,{className:`h-3.5 w-3.5`})}),n&&(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:n,disabled:o||!c&&!e.trim(),title:l(`detail.submitComment`),children:(0,Q.jsx)(qt,{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:zr(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:Y(`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 Vr(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Hr(e){return e.startsWith(`image/`)}function Ur(e){return Hr(e)?Pe:e.includes(`pdf`)||e.includes(`document`)||e.includes(`text`)?we:e.includes(`zip`)||e.includes(`archive`)||e.includes(`compressed`)?me:Yt}var Wr=({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:Y(`space-y-2`,r),children:[t&&!i&&(0,Q.jsxs)(`div`,{className:Y(`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)(ye,{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)(Re,{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=Hr(e.type),r=Ur(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:Vr(e.size)})]}),n&&!i&&(0,Q.jsx)(J,{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)(Te,{className:`h-3.5 w-3.5`})})]},e.id)})})]})]})},Gr={comment:Kt,field_change:He,task:Pt,event:U,system:Ke,email:N,call:kt},Kr={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 qr(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 Jr(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 Yr(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 Xr=({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([]),[k,j]=Z.useState(!1),N=n??y,P=t?.showFilterToggle!==!1,F=t?.showCommentInput!==!1&&!!s,ee=t?.enableReactions??!1,te=t?.enableThreading??!1,ne=t?.showSubscriptionToggle??!1,re=Z.useMemo(()=>Yr(e,N),[e,N]),ie=Z.useMemo(()=>te?re.filter(e=>!e.parentId):re,[re,te]),ae=Z.useMemo(()=>{if(!te)return new Map;let e=new Map;for(let t of re)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[re,te]),I=Z.useCallback(e=>{r?r(e):b(e)},[r]),se=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]),L=Z.useCallback(async e=>{if(!(!m||e.length===0)){j(!0);try{let t=await m(e);Array.isArray(t)&&t.length>0&&O(e=>[...e,...t])}finally{j(!1)}}},[m]),ce=Z.useCallback(e=>{O(t=>t.filter(t=>t.id!==e))},[]),le=Z.useCallback(async()=>{if(a){E(!0);try{await a()}finally{E(!1)}}},[a]);return(0,Q.jsxs)(`section`,{className:Y(`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)(Je,{className:`h-4 w-4`}),h??v(`detail.activity`),(0,Q.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,re.length,`)`]})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:ne&&u&&(0,Q.jsx)(Rr,{subscription:u,onToggle:d})})]})}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[P&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(A,{value:N,onValueChange:e=>I(e),children:[(0,Q.jsx)(ke,{"aria-label":v(`detail.filterActivity`),className:`h-8 w-auto min-w-[140px] py-1 text-sm`,children:(0,Q.jsx)(Ne,{})}),(0,Q.jsx)(je,{children:qr(v).map(e=>(0,Q.jsx)(oe,{value:e.value,children:e.label},e.value))})]})}),F&&(0,Q.jsx)(Br,{value:x,onChange:S,onSubmit:se,mentionSuggestions:p,placeholder:v(`detail.leaveCommentPlaceholder`),disabled:C,canSubmitEmpty:D.length>0,extraSlot:m?(0,Q.jsx)(Wr,{attachments:D,onUpload:L,onRemove:ce,readOnly:C||k}):D.length>0?(0,Q.jsx)(Wr,{attachments:D,onRemove:ce,readOnly:C}):void 0}),re.length===0?f?null:(0,Q.jsx)(pe,{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:ie.map(e=>{let t=Gr[e.type]||Ke,n=Kr[e.type]||`bg-gray-100 text-gray-600`,r=ae.get(e.id)??[];return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,Q.jsx)(`div`,{className:Y(`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:Jr(e.createdAt)}),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.type===`field_change`&&e.fieldChanges&&(0,Q.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,Q.jsx)(Nr,{change:e},t))}),ee&&e.reactions&&e.reactions.length>0&&(0,Q.jsx)(`div`,{className:`mt-1.5`,children:(0,Q.jsx)(Fr,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),ee&&(!e.reactions||e.reactions.length===0)&&l&&(0,Q.jsx)(`div`,{className:`mt-1.5`,children:(0,Q.jsx)(Fr,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),te&&(e.replyCount??0)>0&&(0,Q.jsx)(Lr,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,Q.jsx)(`div`,{className:`text-center pt-2`,children:(0,Q.jsxs)(J,{variant:`ghost`,size:`sm`,onClick:le,disabled:T,"aria-label":v(`detail.loadMore`),children:[T?(0,Q.jsx)(mt,{className:`h-4 w-4 animate-spin mr-1`}):(0,Q.jsx)(M,{className:`h-4 w-4 mr-1`}),v(`detail.loadMore`)]})})]})]})},Zr=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}},Qr=({schema:e={},className:t,...n})=>{b();let{designer:r}=Zr(n);return(0,Q.jsx)(`div`,{className:t,...r,children:(0,Q.jsx)(Xr,{items:[],config:e})})},$r=({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:Y(`flex items-start pt-4`,g===`right`?`border-l`:`border-r`,h),children:(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>S(!1),"aria-label":b(`detail.openDiscussion`),children:(0,Q.jsx)(Lt,{className:`h-4 w-4`})})}):(0,Q.jsxs)(`div`,{className:Y(`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)(Kt,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:b(`detail.discussion`)})]}),v&&(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.closeDiscussion`),children:(0,Q.jsx)(Te,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,Q.jsx)(Xr,{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:Y(``,h),children:v&&x?(0,Q.jsxs)(J,{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)(Kt,{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)(Kt,{className:`h-4 w-4`}),b(`detail.discussion`)]}),(0,Q.jsx)(J,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>S(!0),"aria-label":b(`detail.hideDiscussion`),children:(0,Q.jsx)(At,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(Xr,{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`)})]})})},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}},ti=({schema:e={},className:t,...n})=>{b();let r=v(),{designer:i}=ei(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)($r,{items:r?.items||[],config:a,onAddComment:r?.onAddComment,onAddReply:r?.onAddReply,onToggleReaction:r?.onToggleReaction,mentionSuggestions:r?.mentionSuggestions,onUploadAttachments:r?.onUploadAttachments})})},ni=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}},ri=({schema:e={},className:t,...n})=>{let r=b(),{translateOptions:i}=ot(),{designer:a}=ni(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`),m=p===-1?c:c.slice(0,p),h=p===-1?[]:c.slice(p),g=p===-1?f:f.slice(0,p),_=c.findIndex(e=>e.value===l);_<0&&(_=-1);let v=p!==-1&&_>=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 y=(e,t)=>{if(c.length!==1)return e===0?`polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%)`:e===t?`polygon(0 0, 100% 0, 100% 100%, 0 100%, 14px 50%)`:`polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%, 14px 50%)`},x=m.length-1;return(0,Q.jsxs)(`div`,{className:Y(`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`,children:m.map((e,t)=>{let n=!v&&_>=0&&t<_,r=!v&&t===_,i=g[t]===`won`&&t===x,a=y(t,x);return(0,Q.jsx)(`div`,{role:`listitem`,"aria-current":r?`step`:void 0,style:a?{clipPath:a,WebkitClipPath:a}:void 0,className:Y(`relative flex-1 min-w-0 px-5 py-2 text-xs font-medium text-center`,t>0&&`-ml-2`,m.length===1&&`rounded-md border`,r&&`bg-primary text-primary-foreground shadow-sm ring-1 ring-primary/40`,n&&`bg-emerald-500/15 text-emerald-800 dark:text-emerald-200`,!r&&!n&&i&&`bg-emerald-500/5 text-emerald-700/85 dark:text-emerald-300/85 border border-emerald-500/20`,!r&&!n&&!i&&`bg-background text-foreground/85 border border-border/60`),children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 truncate`,style:{paddingLeft:t===0?0:`${14/2}px`,paddingRight:t===x?0:`${14/2}px`},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}`)})}),h.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:h.map((e,t)=>{let n=p+t===_;return(0,Q.jsx)(`div`,{role:`listitem`,"aria-current":n?`step`:void 0,className:Y(`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&&!v&&_>=0&&t<_,i=t===_;return(0,Q.jsx)(`div`,{role:`listitem`,"aria-current":i?`step`:void 0,className:Y(`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`)})})]})},ii=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=({schema:e={},className:t,...n})=>{let r=b(),{designer:i}=ii(n),a=o(),s=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],c=Array.isArray(e.actionNames)?e.actionNames:Array.isArray(e.properties?.actionNames)?e.properties.actionNames:[],d=r?.objectName||``,f=c.length>0?c:Array.isArray(s)&&s.every(e=>typeof e==`string`)?s:[],p=f.length>0&&!!d,{item:m}=u(`object`,p?d:null),h=p?(()=>{let e=Array.isArray(m?.actions)?m.actions:[],t=new Map(e.map(e=>[e.name,e]));return f.map(e=>t.get(e)).filter(e=>!!e)})():Array.isArray(s)?s:[],g=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(g.length>0&&d&&!g.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 _=e.location||`record_header`,{getActionsForLocation:v,executeAction:y}=l({actions:h,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}}),x=h.length>0?v(_):[];if(x.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 S=e.align||`end`,C=S===`start`?`justify-start`:S===`center`?`justify-center`:`justify-end`;return(0,Q.jsx)(`div`,{className:Y(`flex flex-wrap items-center gap-2`,_===`record_header`&&!e.inline&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,C,t),role:`toolbar`,"aria-label":e.aria?.label||`Quick actions`,...i,children:x.map((t,n)=>{let r=t.label||t.name||`Action ${n+1}`;return(0,Q.jsx)(J,{variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,disabled:typeof t.disabled==`boolean`?t.disabled:void 0,onClick:()=>{if(typeof t.onClick==`function`){t.onClick();return}t.name&&y(t.name)},children:r},t.name||`qa-${n}`)})})},oi=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{designer:r}=oi(n),i=Array.isArray(e.entries)?e.entries:Array.isArray(e.properties?.entries)?e.properties.entries:[],a=e.loading??e.properties?.loading??!1,o=e.emptyText??e.properties?.emptyText;return(0,Q.jsx)(`div`,{className:t,...r,children:(0,Q.jsx)(ur,{entries:i,loading:a,emptyText:o})})},ci=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},li=e=>e.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase()).trim(),ui=(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||`—`,di=({schema:e={},className:t,...n})=>{let a=b(),o=ot(),{t:s}=$(),{designer:c}=ci(n),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,m]=Z.useState({}),h=Z.useRef(null),[g,_]=Z.useState(!1),v=Z.useRef(!0);Z.useEffect(()=>(v.current=!0,()=>{v.current=!1}),[]);let y=Z.useRef(``);Z.useEffect(()=>{if(g)return;let e=h.current;if(!e||typeof IntersectionObserver>`u`){_(!0);return}let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&_(!0)},{rootMargin:`200px`});return t.observe(e),()=>t.disconnect()},[g]);let x=JSON.stringify(u.map(e=>`${e.objectName}:${e.relationshipField}:${e.limit??3}`));if(Z.useEffect(()=>{if(!g||!f?.find||!d||u.length===0)return;let e=`${d}::${x}`;if(y.current===e)return;y.current=e,m(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(!v.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;m(e=>({...e,[t]:{loading:!1,total:i,items:r}}))}catch(e){if(!v.current)return;m(n=>({...n,[t]:{loading:!1,total:0,items:[],error:String(e?.message||e)}}))}},n=[...u],r=async()=>{for(;v.current;){let e=n.shift();if(!e)return;await t(e)}},i=Array.from({length:Math.min(3,n.length)},()=>r());Promise.all(i)},[g,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)),D=u.filter(e=>C||!T.has(e.objectName)),O=u.filter(e=>T.has(e.objectName)).map(e=>e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:li(e.objectName)}):li(e.objectName)));return(0,Q.jsxs)(`div`,{ref:h,className:Y(`flex flex-col gap-3`,e.className,t),...c,children:[D.map(e=>{let t=e.objectName,n=p[t]||{loading:!0,total:0,items:[]};return(0,Q.jsxs)(X,{className:`overflow-hidden`,children:[(0,Q.jsxs)(Fe,{className:`flex flex-row items-center justify-between gap-2 py-3 px-4 space-y-0 border-b`,children:[(0,Q.jsx)(ze,{className:`text-sm font-semibold tracking-tight truncate`,children:e.title||(o?.objectLabel?o.objectLabel({name:e.objectName,label:li(e.objectName)}):li(e.objectName))}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[!n.loading&&(0,Q.jsx)(E,{variant:`secondary`,className:`tabular-nums`,children:n.total}),l&&d&&(0,Q.jsx)(i,{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)(L,{className:`p-0`,children:n.loading?(0,Q.jsxs)(`div`,{className:`space-y-1.5 p-3`,children:[(0,Q.jsx)(V,{className:`h-3.5 w-4/5`}),(0,Q.jsx)(V,{className:`h-3.5 w-3/5`}),(0,Q.jsx)(V,{className:`h-3.5 w-2/3`})]}):n.items.length===0?(0,Q.jsx)(`p`,{className:`px-4 py-3 text-xs text-muted-foreground`,children:s(`detail.noRecords`)}):(0,Q.jsx)(`ul`,{className:`divide-y`,children:n.items.map(t=>{let n=t.id||t._id,r=ui(t,e.displayField),a=n?`../${e.objectName}/record/${encodeURIComponent(String(n))}`:void 0;return(0,Q.jsx)(`li`,{className:`px-4 py-2`,children:a?(0,Q.jsxs)(i,{to:a,className:`group flex items-center justify-between gap-2 text-xs hover:text-foreground text-muted-foreground transition-colors`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:r}),(0,Q.jsx)(Jt,{className:`h-3 w-3 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity`})]}):(0,Q.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:r})},String(n||r))})})})]},t)}),!C&&O.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:O.join(` · `),children:[(0,Q.jsx)(`span`,{children:s(`detail.showEmptyRelated`,{defaultValue:`+ {{count}} empty`,count:O.length})}),(0,Q.jsxs)(`span`,{className:`truncate max-w-[180px] text-muted-foreground/70`,children:[`(`,O.join(` · `),`)`]})]})]})},fi={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 mi=({schema:e={},className:t})=>{let n=pi(e),r=b(),i=r?.data,a=r?.objectName||``,o=r?.recordId??i?.id,s=[`info`,`warning`,`error`,`success`].includes(n.severity)?n.severity:`info`,c=fi[s],d=n.icon||c.icon,f=m(n.visible),p=T(f,{record:i}),h=Z.useMemo(()=>{if(!n.dismissible)return null;let e=n.dismissKey||n.title||s;return`os.record-alert:${a}:${o??`_`}:${e}`},[n.dismissible,n.dismissKey,n.title,s,a,o]),[g,_]=Z.useState(()=>{if(!h||typeof window>`u`)return!1;try{return window.localStorage.getItem(h)===`1`}catch{return!1}}),v=n.action?.actionName,{item:y}=u(`object`,v&&a?a:null),x=Z.useMemo(()=>{if(!(!v||!y?.actions))return y.actions.find(e=>e.name===v)},[v,y]),{executeAction:S}=l({actions:Z.useMemo(()=>x?[x]:[],[x]),context:{record:i,recordId:o,objectName:a}});return g||!i||Object.keys(i).length===0||f!==void 0&&!p?null:(0,Q.jsxs)(Mt,{className:Y(`relative pr-12`,c.wrap,t),role:s===`error`?`alert`:`status`,"aria-live":s===`error`?`assertive`:`polite`,children:[(0,Q.jsx)(q,{name:d,className:`h-4 w-4`,"aria-hidden":`true`}),n.title?(0,Q.jsx)(Ue,{children:n.title}):null,n.body||x?(0,Q.jsxs)(ft,{children:[n.body?(0,Q.jsx)(`p`,{className:`mb-2 last:mb-0`,children:n.body}):null,x?(0,Q.jsx)(J,{size:`sm`,variant:n.action?.variant||(s===`error`?`destructive`:`default`),onClick:()=>{x?.name&&S(x.name)},children:n.action?.label||x.label||x.name}):null]}):null,n.dismissible?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{if(_(!0),h)try{window.localStorage.setItem(h,`1`)}catch{}},"aria-label":`Dismiss`,className:`absolute right-3 top-3 inline-flex h-6 w-6 items-center justify-center rounded-md text-muted-foreground/80 hover:bg-foreground/5 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-ring`,children:(0,Q.jsx)(q,{name:`X`,className:`h-4 w-4`,"aria-hidden":`true`})}):null]})},hi=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`]),gi=480,_i=95;function vi({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=hi,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=$(),g=`objectui.drawerWidth.${i}`,[_,v]=Z.useState(()=>{if(typeof window>`u`||!p)return null;try{let e=window.localStorage.getItem(g);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=gi)return t}}catch{}return null}),y=Z.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),b=y?{width:y,maxWidth:y}:void 0,x=Z.useRef(null),S=Z.useCallback(e=>{if(!p)return;e.preventDefault();let t=_??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);x.current={startX:e.clientX,startWidth:t};let n=e=>{let t=x.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*_i/100:1600,i=Math.min(r,Math.max(gi,t.startWidth+n));v(Math.round(i))},r=()=>{x.current,x.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{v(e=>(e!=null&&window.localStorage.setItem(g,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[p,_,g]),C=s?.fields??{},w=(Object.keys(C).length?Object.keys(C):Object.keys(r)).filter(e=>!u.has(e)&&!e.startsWith(`__`)).filter(e=>e in r).filter(e=>!C[e]?.hidden).map(e=>{let t=C[e]||{},n=t.type===`lookup`||t.type===`master_detail`||t.type===`reference`;return{name:e,label:t.label,type:t.type,readonly:!!t.readonly||n,options:t.options,currency:t.currency,precision:t.precision,format:t.format,reference_to:t.reference_to??t.referenceTo??t.target,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}});return(0,Q.jsx)(K,{open:e,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(te,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:b,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize drawer`,onPointerDown:S,className:`hidden sm:block absolute left-0 top-0 h-full w-1.5 cursor-col-resize select-none bg-transparent hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`}),(0,Q.jsx)(fe,{className:`sr-only`,children:(0,Q.jsx)(xe,{children:n})}),(0,Q.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,Q.jsx)(br,{dataSource:o,inlineEdit:!0,schema:{type:`detail-view`,objectName:i,resourceId:String(a),data:r,showDelete:!0,columns:l,fields:w,actions:m?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:h(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(m,`_blank`,`noopener`)}]}]:void 0},onFieldSave:async(e,t)=>{try{await d?.(e,t)}catch(e){console.error(`[RecordDetailDrawer] inline field save failed:`,e)}},onDelete:async()=>{try{await f?.(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}})})]})})}function yi(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 bi(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 xi(e){return e==null?[]:Array.isArray(e)?e.filter(e=>e!=null):[e]}function Si(e){if(!e)return null;if(e.stageField)return e.stageField;let t=e.fields||{};for(let e of[`status`,`stage`,`state`,`phase`])if(e in t)return e;for(let[e,n]of Object.entries(t)){let t=(n?.type||``).toLowerCase();if(t===`status`||t===`stage`)return e}return null}function Ci(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 wi(e,t,n=4){if(!e)return[];if(Array.isArray(e.highlightFields)&&e.highlightFields.length>0)return e.highlightFields.slice(0,n);let r=new Set([`id`,`_id`,`created_at`,`updated_at`,`deleted_at`,`created_by`,`updated_by`,`deleted_by`,`organization_id`,`workspace_id`,`tenant_id`,`org_id`]);t&&r.add(t),e.primaryField&&r.add(e.primaryField);for(let t of[`name`,`full_name`,`title`,`subject`,`display_name`])t in(e.fields||{})&&r.add(t);let i=[`owner`,`owner_id`,`amount`,`rating`,`source`,`priority`,`industry`,`phone`,`email`,`close_date`,`due_date`,`start_date`,`expected_close_date`,`account`,`account_id`,`contact`,`contact_id`],a=new Set([`currency`,`number`,`integer`,`decimal`,`percent`,`date`,`datetime`,`time`,`reference`,`lookup`,`user`,`owner`,`select`,`enum`,`multiselect`,`status`,`email`,`phone`,`url`,`text`,`string`]),o=[],s=e.fields||{};for(let e of i)if(e in s&&!r.has(e)&&o.push(e),o.length>=n)return o;for(let e of Object.keys(s)){if(o.includes(e)||r.has(e))continue;let t=s[e]?.type;if(!(t&&!a.has(t))&&(o.push(e),o.length>=n))break}return o}function Ti(e,t={}){return{type:`page:header`,recordChrome:t.recordChrome!==!1,...Array.isArray(t.actions)&&t.actions.length>0?{actions:t.actions}:{}}}function Ei(e,t={}){let n=t.statusField??Si(e),r=t.stages??(n?Ci(e,n):null),i=t.highlightFields??wi(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 Di(e,t,n){return{type:`record:details`,sections:t,...n&&n.length>0?{hideFields:n}:{}}}function Oi(e,t={}){let n=t.statusField??Si(e),r=t.highlightFields??wi(e,n),i=[{label:`Details`,children:[Di(e,t.sections,r)]}];return!t.hideRelatedTab&&Array.isArray(t.related)&&t.related.length>0&&i.push({label:`Related`,children:t.related.map(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}:{}}))}),t.showActivity&&i.push({label:`Activity`,children:[{type:`record:activity`}]}),t.history&&i.push({label:`History`,children:[{type:`record:history`,entries:t.history.entries,loading:t.history.loading,emptyText:t.history.emptyText}]}),{type:`page:tabs`,items:i}}function ki(){return{type:`record:discussion`}}function Ai(e,t={}){let n=t.slots||{},r=[];`header`in n&&n.header!==void 0?r.push(...xi(n.header)):r.push(Ti(e,{recordChrome:t.recordChrome,actions:t.headerActions})),`actions`in n&&n.actions!==void 0&&r.push(...xi(n.actions)),`alerts`in n&&n.alerts!==void 0&&r.push(...xi(n.alerts)),`highlights`in n&&n.highlights!==void 0?r.push(...xi(n.highlights)):r.push(...Ei(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(...xi(n.tabs));else if(`details`in n&&n.details!==void 0){let i=xi(n.details),o=Oi(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a});Array.isArray(o.items)&&o.items.length>0&&(o.items[0]={...o.items[0],children:i}),r.push(o)}else r.push(Oi(e,{sections:t.sections,related:t.related,showActivity:t.showActivity,history:t.history,highlightFields:t.highlightFields,statusField:t.statusField,hideRelatedTab:a}));`discussion`in n&&n.discussion!==void 0?r.push(...xi(n.discussion)):t.hideDiscussion||r.push(ki());let o=[{name:`main`,width:`full`,components:r}],s=xi(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 ji=t({DetailSection:()=>Wn,DetailView:()=>br,RecordActivityRenderer:()=>Qr,RecordAlertRenderer:()=>mi,RecordChatterRenderer:()=>ti,RecordDetailsRenderer:()=>Dr,RecordHighlightsRenderer:()=>Mr,RecordHistoryRenderer:()=>si,RecordPathRenderer:()=>ri,RecordQuickActionsRenderer:()=>ai,RecordReferenceRailRenderer:()=>di,RecordRelatedListRenderer:()=>Ar,RelatedList:()=>qn,buildDefaultPageSchema:()=>Ai});C.register(`detail-view`,br,{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:[]}}),C.register(`detail-section`,Wn,{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`}]}),C.register(`related-list`,qn,{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`}]}),C.register(`detail`,br,{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`}]}),C.register(`record:details`,Dr,{namespace:`record`,category:`record`,label:`Record Details`,icon:`FileText`}),C.register(`record:related_list`,Ar,{namespace:`record`,category:`record`,label:`Related List`,icon:`List`}),C.register(`record:highlights`,Mr,{namespace:`record`,category:`record`,label:`Highlights Panel`,icon:`Star`}),C.register(`record:activity`,Qr,{namespace:`record`,category:`record`,label:`Activity Timeline`,icon:`Activity`}),C.register(`record:chatter`,ti,{namespace:`record`,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`}),C.register(`record:discussion`,ti,{namespace:`record`,category:`record`,label:`Discussion`,icon:`MessageSquare`}),C.register(`record:path`,ri,{namespace:`record`,category:`record`,label:`Path / Stepper`,icon:`GitBranch`}),C.register(`record:quick_actions`,ai,{namespace:`record`,category:`record`,label:`Quick Actions`,icon:`Zap`}),C.register(`record:history`,si,{namespace:`record`,category:`record`,label:`History Timeline`,icon:`Clock`}),C.register(`record:reference_rail`,di,{namespace:`record`,category:`record`,label:`Reference Rail`,icon:`PanelRight`}),C.register(`record:alert`,mi,{namespace:`record`,category:`record`,label:`Alert Banner`,icon:`AlertTriangle`});export{yi as a,kn as c,vi as i,Ai as n,$r as o,bi as r,br as s,ji as t};