@object-ui/console 4.0.1 → 4.0.4

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 (47) hide show
  1. package/dist/assets/{AppManagementPage-Da4DphqI.js → AppManagementPage-ynJLzxVY.js} +1 -1
  2. package/dist/assets/ConsoleFloatingChatbot-C2rFxE3n.js +1 -0
  3. package/dist/assets/DashboardView-x75VLMQW.js +1 -0
  4. package/dist/assets/MetadataDetailPage-B9EzoQgu.js +1 -0
  5. package/dist/assets/{MetadataFormDialog-CSuCo9Qt.js → MetadataFormDialog-BebGlAr3.js} +1 -1
  6. package/dist/assets/{MetadataManagerPage-DJ2ZjoVP.js → MetadataManagerPage-B0xfI-4w.js} +1 -1
  7. package/dist/assets/{PageView-CJFNRux1.js → PageView-C2GS-SQP.js} +1 -1
  8. package/dist/assets/{ProfilePage-CK0mmAvw.js → ProfilePage-BO3TRbTV.js} +1 -1
  9. package/dist/assets/RecordDetailView-Clze41HE.js +1 -0
  10. package/dist/assets/RecordFormPage-B6mEBKMB.js +1 -0
  11. package/dist/assets/{ReportView-B6tHCvDV.js → ReportView-B16PsGer.js} +1 -1
  12. package/dist/assets/{SearchResultsPage-CDUPn8G4.js → SearchResultsPage-932jfRUX.js} +1 -1
  13. package/dist/assets/{SystemHubPage-CVOYNpyU.js → SystemHubPage-CqrYgpYf.js} +1 -1
  14. package/dist/assets/{data-adapter-DBWF2sV-.js → data-adapter-BwfAq_h0.js} +1 -1
  15. package/dist/assets/{getIcon-CWhoWdFA.js → getIcon-DF6zJOtU.js} +1 -1
  16. package/dist/assets/index-CPatxDwz.js +2 -0
  17. package/dist/assets/index-vbGrAsEJ.css +2 -0
  18. package/dist/assets/{plugin-calendar-DBrkXKZq.js → plugin-calendar-D1bCBBwe.js} +1 -1
  19. package/dist/assets/{plugin-charts-BHH2XtQC.js → plugin-charts-x_9Q2-i_.js} +1 -1
  20. package/dist/assets/{plugin-chatbot-Cdf-WJAv.js → plugin-chatbot-CgNZnFch.js} +6 -6
  21. package/dist/assets/{plugin-form-CKcMp4d_.js → plugin-form-DOfn-uRa.js} +1 -1
  22. package/dist/assets/{plugin-gantt-DwFZiNye.js → plugin-gantt-CHZ4HLjh.js} +1 -1
  23. package/dist/assets/{plugin-grid-CQS8zk9l.js → plugin-grid-Cn_T_wpz.js} +1 -1
  24. package/dist/assets/{plugin-kanban-CaM_pxR_.js → plugin-kanban-BsgjJQam.js} +1 -1
  25. package/dist/assets/{plugin-map-BFlwDcr7.js → plugin-map-DZdVR1tc.js} +1 -1
  26. package/dist/assets/{plugin-markdown-PR8tBwTD.js → plugin-markdown-BlHuacDq.js} +1 -1
  27. package/dist/assets/{plugin-timeline-B-vzj0Pe.js → plugin-timeline-OEB0nyvd.js} +1 -1
  28. package/dist/assets/{plugin-view-djqft75T.js → plugin-view-CJFsgQ9v.js} +1 -1
  29. package/dist/assets/{plugins-views-BDVYhbx4.js → plugins-views-DqZMtAOw.js} +1 -1
  30. package/dist/assets/{src-D1MGEpQM.js → src-D5NTzWsi.js} +1 -1
  31. package/dist/assets/{ui-components-3HVEceOY.js → ui-components-B7mlp0en.js} +1 -1
  32. package/dist/assets/{ui-layout-_xO4eFwD.js → ui-layout-jqAD528v.js} +1 -1
  33. package/dist/assets/utils-DMMB8Xfh.js +1 -0
  34. package/dist/assets/{vendor-charts-DHZsyaJw.js → vendor-charts-D0g2ZI3F.js} +1 -1
  35. package/dist/index.html +3 -3
  36. package/package.json +30 -30
  37. package/dist/assets/ConsoleFloatingChatbot-BWbRwcSc.js +0 -1
  38. package/dist/assets/DashboardView-l8ACItY-.js +0 -1
  39. package/dist/assets/MetadataDetailPage-D7yDeoSe.js +0 -1
  40. package/dist/assets/RecordDetailView-BfzfI4-e.js +0 -1
  41. package/dist/assets/index-BimUnPgZ.js +0 -2
  42. package/dist/assets/index-DoG5QbE6.css +0 -2
  43. /package/dist/assets/{maplibre-gl-ChgVR8ni.js → maplibre-gl-CKvz_wTN.js} +0 -0
  44. /package/dist/assets/{vendor-dndkit-BGB4qgc3.js → vendor-dndkit-BfOuYFuz.js} +0 -0
  45. /package/dist/assets/{vendor-icons-core-s9WPLoP3.js → vendor-icons-core-BA-_NHij.js} +0 -0
  46. /package/dist/assets/{vendor-markdown-D-LpQJes.js → vendor-markdown-Cdqza44B.js} +0 -0
  47. /package/dist/assets/{vendor-ui-utils-AywTz3cM.js → vendor-ui-utils-Dyl9EYZi.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{n as e,r as t,t as n}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as r,g as i,t as a}from"./vendor-react-B1k2FF9f.js";import{B as o,D as s,H as c,L as l,R as u,a as d,h as f,j as p,k as m,m as h,v as g,w as _,x as v,z as y}from"./framework-CoXA0nY6.js";import{d as b,f as x}from"./infrastructure-Djv3I7gr.js";import{i as S,t as C}from"./vendor-ui-utils-AywTz3cM.js";import{$A as w,$k as T,$n as E,BF as D,Bt as O,CP as k,C_ as A,Cd as j,Cy as M,DP as N,El as P,FC as ee,FS as F,Hh as te,Ht as ne,IA as I,MS as L,Nd as R,OL as re,Ol as z,PL as B,Pm as V,Qn as H,RS as U,Rd as W,Tu as ie,Ut as G,Vr as ae,Vt as oe,Wt as se,X as ce,XF as le,Xn as K,Xv as q,Yn as ue,Yp as de,Z as fe,ZA as pe,Zc as me,Zn as he,_c as ge,_t as _e,ar as ve,bd as ye,br as be,c as xe,cE as Se,cI as Ce,cn as we,ct as Te,dn as J,dt as Ee,er as Y,fI as De,ff as Oe,fn as X,ft as ke,gt as Ae,hc as je,ht as Me,iI as Ne,kv as Pe,ln as Fe,ls as Ie,lt as Le,mM as Re,mo as ze,mt as Be,nO as Ve,nr as He,op as Ue,pE as We,pj as Ge,px as Ke,qE as qe,rj as Je,rk as Ye,rr as Xe,rt as Ze,tI as Qe,tr as $e,tt as et,uE as tt,um as nt,un as rt,ut as it,ux as at,vu as ot,wb as st,wh as ct,xh as lt,xm as ut,yb as dt,yr as Z,z_ as ft,zr as pt,zt as mt}from"./ui-components-3HVEceOY.js";import{i as ht}from"./plugin-grid-CQS8zk9l.js";var Q=t(r(),1),$=a(),gt={grid:(0,$.jsx)(U,{className:`h-4 w-4`}),kanban:(0,$.jsx)(dt,{className:`h-4 w-4`}),gallery:(0,$.jsx)(Ke,{className:`h-4 w-4`}),calendar:(0,$.jsx)(Re,{className:`h-4 w-4`}),timeline:(0,$.jsx)(re,{className:`h-4 w-4`}),gantt:(0,$.jsx)(z,{className:`h-4 w-4`}),map:(0,$.jsx)(Pe,{className:`h-4 w-4`})},_t={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`},vt=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:n,className:r,animated:i=!0})=>{let a=Q.useCallback(t=>{if(!i||t===e){n(t);return}typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>n(t)):n(t)},[i,e,n]);return(0,$.jsx)(`div`,{className:B(`flex items-center gap-1 bg-transparent oui-view-switcher`,r),children:t.map(t=>{let n=e===t;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(t),"aria-label":_t[t],title:_t[t],"aria-pressed":n,"data-state":n?`on`:`off`,className:B(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,`hover:bg-muted hover:text-muted-foreground`,`gap-2 px-3 py-2`,`data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm border-transparent border data-[state=on]:border-border/50`),children:[gt[t],(0,$.jsx)(`span`,{className:`hidden sm:inline-block text-xs font-medium`,children:_t[t]})]},t)})})};function yt(e){return e?be[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function bt(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}var xt=({tabs:e,activeTab:t,onTabChange:n,className:r})=>{let i=Q.useMemo(()=>bt(e),[e]),a=Q.useMemo(()=>i.find(e=>e.isDefault)?.name??i[0]?.name,[i]),[o,s]=Q.useState(a),c=t??o,l=Q.useCallback(e=>{s(e.name),n?.(e)},[n]);return i.length===0?null:(0,$.jsx)(`div`,{className:B(`border-b 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=yt(e.icon),n=c===e.name;return(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-3 py-1.5 text-xs rounded-none transition-colors duration-150`,n?`border-b-2 border-primary font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),"data-testid":`view-tab-${e.name}`,role:`tab`,"aria-selected":n,onClick:()=>l(e),children:[t&&(0,$.jsx)(t,{className:`h-3 w-3 mr-1.5`}),e.label]},e.name)})})};function St({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a}){switch(e.element){case`dropdown`:return(0,$.jsx)(wt,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a});case`tabs`:return(0,$.jsx)(Tt,{tabs:e.tabs||[],showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a});case`toggle`:return(0,$.jsx)(Et,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function Ct(e,t,n){return e.map(e=>{let r=e.options?[...e.options]:[];if(r.length===0&&t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n?.options&&(r=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})))}return e.showCount&&n.length>0&&(r=r.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length}))),{...e,options:r}})}function wt({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a}){let[o,s]=Q.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues)}),t}),c=Q.useMemo(()=>Ct(e,t,n),[e,t,n]),l=Q.useCallback(e=>{r(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[r]),u=(e,t)=>{let n={...o,[e]:t};s(n),l(n)};Q.useEffect(()=>{Object.values(o).some(e=>e.length>0)&&l(o)},[]);let d=i!==void 0&&i<c.length?c.slice(0,i):c,f=i!==void 0&&i<c.length?c.slice(i):[],p=e=>{let t=o[e.field]||[],n=t.length>0;return(0,$.jsxs)(we,{children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:B(`inline-flex items-center gap-1 rounded-full border h-7 px-2.5 text-xs font-medium transition-colors shrink-0`,n?`border-primary/30 bg-primary/5 text-primary`:`border-border bg-background hover:bg-accent text-foreground`),children:[(0,$.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),n&&(0,$.jsx)(`span`,{className:`flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px]`,children:t.length}),n?(0,$.jsx)(ae,{className:`h-3 w-3 opacity-60`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),u(e.field,[])}}):(0,$.jsx)(Je,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-56 p-2`,children:(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-0.5`,"data-testid":`filter-options-${e.field}`,children:e.options.map(n=>(0,$.jsxs)(`label`,{className:B(`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,$.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];u(e.field,r)},className:`rounded border-input`}),n.color&&(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,$.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,$.jsxs)(`div`,{className:B(`flex items-center gap-1 overflow-x-auto`,a),"data-testid":`user-filters-dropdown`,children:[(0,$.jsx)(ie,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),c.length===0?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,$.jsxs)($.Fragment,{children:[d.map(p),f.length>0&&(0,$.jsxs)(we,{children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`user-filters-more`,className:`inline-flex items-center gap-1 rounded-full border border-border bg-background hover:bg-accent text-foreground h-7 px-2.5 text-xs font-medium transition-colors shrink-0`,children:[(0,$.jsx)(`span`,{children:`More`}),(0,$.jsx)(`span`,{className:`flex h-4 min-w-[16px] items-center justify-center rounded-full bg-muted text-[10px] font-medium`,children:f.length}),(0,$.jsx)(Je,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:f.map(p)})})]})]})]})}function Tt({tabs:e,showAllRecords:t,allowAddTab:n,onFilterChange:r,className:i}){let[a,o]=Q.useState(()=>e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),s=Q.useCallback(t=>{o(t),r(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[])},[e,r]),c=Q.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return Q.useEffect(()=>{let t=e.find(e=>e.default);t&&r(t.filters||[])},[]),(0,$.jsxs)(`div`,{className:B(`flex items-center gap-0.5 overflow-x-auto`,i),"data-testid":`user-filters-tabs`,children:[c.map(e=>(0,$.jsx)(`button`,{"data-testid":`filter-tab-${e.id}`,onClick:()=>s(e.id),className:B(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,a===e.id?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},e.id)),n&&(0,$.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,$.jsx)(nt,{className:`h-3.5 w-3.5`})})]})}function Et({fields:e,onFilterChange:t,className:n}){let[r,i]=Q.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),a=Q.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 Q.useEffect(()=>{r.size>0&&a(r)},[]),(0,$.jsx)(`div`,{className:B(`flex items-center gap-1 overflow-x-auto`,n),"data-testid":`user-filters-toggle`,children:e.map(e=>(0,$.jsx)(Z,{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 Dt(e){switch(e){case`equals`:case`eq`:return`=`;case`notEquals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;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`:return`not in`;case`before`:return`<`;case`after`:return`>`;default:return e}}function Ot(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)?Ot(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 kt(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function At(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?Ot(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function jt(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=At(e.conditions.map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,Dt(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var Mt={"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.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`};function Nt(){try{let e=d();return e.t(`list.recordCount`)===`list.recordCount`?{t:(e,t)=>{let n=Mt[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}}:{t:e.t}}catch{return{t:(e,t)=>{let n=Mt[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}}}}function Pt(){try{let{fieldLabel:e}=b();return{fieldLabel:e}}catch{return{fieldLabel:(e,t,n)=>n}}}var Ft=Q.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onRowClick:c,showViewSwitcher:u=!1,...d},f)=>{let{t:p}=Nt(),{fieldLabel:m}=Pt(),h=Q.useMemo(()=>({...e,viewType:e.viewType||`grid`}),[e]),g=Q.useCallback((e,t)=>h.objectName?m(h.objectName,e,t):t,[h.objectName,m]),b=Q.useMemo(()=>{let e=h.userActions,t=h.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?h.showSearch!==!1:e.search,showSort:e?.sort===void 0?h.showSort!==!1:e.sort,showFilters:e?.filter===void 0?h.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?h.showDensity===!0:e.rowHeight,showHideFields:h.showHideFields===!0,showGroup:h.showGroup!==!1,showColor:h.showColor===!0,showAddRecord:t,addRecordPosition:h.addRecord?.position===`bottom`?`bottom`:`top`}},[h.userActions,h.showSearch,h.showSort,h.showFilters,h.showDensity,h.showHideFields,h.showGroup,h.showColor,h.addRecord,h.userActions?.addRecordForm]),[x,S]=Q.useState(h.viewType),[C,w]=Q.useState(``),[T,E]=Q.useState(!1),[D,O]=Q.useState(!1),[k,A]=Q.useState(()=>h.sort&&h.sort.length>0?h.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`}}):[]),[j,M]=Q.useState(!1),[N,P]=Q.useState({id:`root`,logic:`and`,conditions:[]}),[ee,F]=Q.useState(()=>{if(!(!h.tabs||h.tabs.length===0))return h.tabs.find(e=>e.isDefault)?.name??h.tabs[0]?.name}),ne=Q.useCallback(e=>{if(F(e.name),e.filter){let t={id:`tab-filter-${e.name}`,logic:e.filter.logic||`and`,conditions:e.filter.conditions||[]};P(t),r?.(t)}else{let e={id:`root`,logic:`and`,conditions:[]};P(e),r?.(e)}},[r]),I=d.dataSource,[R,re]=Q.useState([]),[z,V]=Q.useState(!1),[H,U]=Q.useState(null),[G,oe]=Q.useState(!1),[se,ce]=Q.useState(0),[K,q]=Q.useState(!1);Q.useImperativeHandle(f,()=>({refresh:()=>ce(e=>e+1)}),[]),Q.useEffect(()=>{if(!(!I?.onMutation||!h.objectName||h.refreshTrigger))return I.onMutation(e=>{e.resource===h.objectName&&ce(e=>e+1)})},[I,h.objectName,h.refreshTrigger]);let[ue,fe]=Q.useState(void 0),pe=ue??h.pagination?.pageSize??100,me=Q.useMemo(()=>{if(h.grouping?.fields?.length)return h.grouping;let e=typeof h.groupBy==`string`?h.groupBy.trim():``,t=typeof h.groupBy2==`string`?h.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},[h.grouping,h.groupBy,h.groupBy2]),[he,ge]=Q.useState(me),[_e,ve]=Q.useState(!1),xe=Q.useRef(me);Q.useEffect(()=>{xe.current!==me&&(xe.current=me,ge(me))},[me]);let[Se,Ce]=Q.useState(h.rowColor),[Te,Ee]=Q.useState(!1),[Y,De]=Q.useState([]),Oe=Q.useRef(0),[X,ke]=Q.useState(()=>{let e=new Set;return h.quickFilters?.forEach(t=>{let n=y(t);n.defaultActive&&e.add(n.id)}),e}),[Ae,je]=Q.useState([]),Me=Q.useMemo(()=>{if(h.userFilters)return h.userFilters;if(!H?.fields)return;let e=new Set([`select`,`multi-select`,`boolean`]),t=[],n=Array.isArray(H.fields)?H.fields.map(e=>[e.name,e]):Object.entries(H.fields);for(let[r,i]of n)(e.has(i.type)||i.options&&!i.type)&&t.push({field:r,label:g(r,i.label||r),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});if(t.length!==0)return{element:`dropdown`,fields:t}},[h.userFilters,H]),[Ne,Pe]=Q.useState(()=>new Set(h.hiddenFields||[])),[Re,ze]=Q.useState(!1),[Be,Ve]=Q.useState(!1),He=Q.useMemo(()=>o(h.quickFilters),[h.quickFilters]),Ue=Q.useMemo(()=>{if(h.exportOptions)return Array.isArray(h.exportOptions)?{formats:h.exportOptions}:h.exportOptions},[h.exportOptions]),We=v(Q.useMemo(()=>h.densityMode?h.densityMode:h.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[h.rowHeight]||`comfortable`:`compact`,[h.densityMode,h.rowHeight])),{ref:Ge,isRefreshing:Ke,pullDistance:Je}=ht({onRefresh:Q.useCallback(async()=>{ce(e=>e+1)},[]),enabled:!!I&&!!h.objectName}),Ye=Q.useMemo(()=>h.id?`listview-${h.objectName}-${h.id}-view`:`listview-${h.objectName}-view`,[h.objectName,h.id]);Q.useEffect(()=>{let e=!0;return oe(!1),U(null),(async()=>{if(!I||!h.objectName){oe(!0);return}if(typeof I.getObjectSchema!=`function`){oe(!0);return}try{let t=await I.getObjectSchema(h.objectName);e&&U(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&oe(!0)}})(),()=>{e=!1}},[h.objectName,I]);let Xe=Q.useMemo(()=>l(H?.fields,h.fields),[H?.fields,h.fields]);Q.useEffect(()=>{let e=!0,t=++Oe.current;if(h.data&&typeof h.data==`object`&&!Array.isArray(h.data)){let e=h.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(C){let e=C.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}re(t),V(!1),q(!1);return}}if(Array.isArray(h.data)){let e=h.data;if(C){let t=C.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}re(e),V(!1),q(!1);return}return G?((async()=>{if(!(!I||!h.objectName)){V(!0);try{let n=[],r=h.filters||[],i=jt(N),a=[];He&&X.size>0&&He.forEach(e=>{X.has(e.id)&&e.filters&&e.filters.length>0&&a.push(e.filters)});let o=At(Ae),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=k.length>0?k.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,l=(()=>{let e=Array.isArray(h.fields)?h.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[];if(e.length===0)return;let t=new Set([`id`]);for(let n of e)t.add(n);for(let e of Xe)t.add(e);let 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:[]];for(let e of n)typeof e==`string`&&e&&t.add(e)};return n(h.kanban),n(h.options?.kanban),n(h.calendar),n(h.options?.calendar),n(h.gallery),n(h.options?.gallery),n(h.timeline),n(h.options?.timeline),n(h.gantt),n(h.options?.gantt),Array.from(t)})(),u=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,d=await I.find(h.objectName,{...u?{$filter:n}:{},$orderby:c,$top:pe,...l?{$select:l}:{},...Xe.length>0?{$expand:Xe}:{},...C?{$search:C,...h.searchableFields&&h.searchableFields.length>0?{$searchFields:h.searchableFields}:{}}:{}});if(!e||t!==Oe.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)),re(f),q(f.length>=pe)}catch(e){t===Oe.current&&console.error(`ListView data fetch error:`,e)}finally{e&&t===Oe.current&&V(!1)}}})(),()=>{e=!1}):void 0},[h.objectName,h.data,I,h.filters,pe,k,N,X,He,Ae,se,C,h.searchableFields,Xe,G,h.refreshTrigger]);let Qe=Q.useMemo(()=>{if(h.appearance?.allowedVisualizations&&h.appearance.allowedVisualizations.length>0)return h.appearance.allowedVisualizations.filter(e=>[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`].includes(e));let e=[`grid`];return(h.kanban?.groupField||h.options?.kanban?.groupField)&&e.push(`kanban`),(h.gallery?.coverField||h.gallery?.imageField||h.options?.gallery?.imageField)&&e.push(`gallery`),(h.calendar?.startDateField||h.options?.calendar?.startDateField)&&e.push(`calendar`),(h.timeline?.startDateField||h.options?.timeline?.startDateField||h.options?.timeline?.dateField||h.options?.calendar?.startDateField)&&e.push(`timeline`),(h.gantt?.startDateField||h.options?.gantt?.startDateField)&&e.push(`gantt`),(h.options?.map?.locationField||h.options?.map?.latitudeField&&h.options?.map?.longitudeField)&&e.push(`map`),h.viewType&&!e.includes(h.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`].includes(h.viewType)&&e.push(h.viewType),e},[h.options,h.viewType,h.kanban,h.calendar,h.gantt,h.gallery,h.timeline,h.appearance?.allowedVisualizations]);Q.useEffect(()=>{h.viewType&&S(h.viewType)},[h.viewType]);let $e=Q.useCallback(e=>{S(e);try{localStorage.setItem(Ye,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[Ye,n]),ot=Q.useCallback(e=>{w(e),a?.(e)},[a]),st=_({navigation:h.navigation,objectName:h.objectName,onNavigate:h.onNavigate,onRowClick:c}),ct=Q.useMemo(()=>{let e=h.fields||[];if(Array.isArray(e)||(e=[]),Ne.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!Ne.has(t)})),h.fieldOrder&&h.fieldOrder.length>0){let t=new Map(h.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},[h.fields,Ne,h.fieldOrder]),lt=Q.useMemo(()=>{let e={objectName:h.objectName,fields:ct,filters:h.filters,sort:k,className:`h-full w-full`,showSearch:!1,onRowClick:st.handleClick,...h.striped==null?{}:{striped:h.striped},...h.bordered==null?{}:{bordered:h.bordered}};switch(x){case`grid`:return{type:`object-grid`,...e,columns:ct,...h.conditionalFormatting?{conditionalFormatting:h.conditionalFormatting}:{},...h.inlineEdit==null?{}:{editable:h.inlineEdit},...h.wrapHeaders==null?{}:{wrapHeaders:h.wrapHeaders},...h.virtualScroll==null?{}:{virtualScroll:h.virtualScroll},...h.resizable==null?{}:{resizable:h.resizable},...h.selection?{selection:h.selection}:{},...h.pagination?{pagination:h.pagination}:{},...he?{grouping:he}:{},...Se?{rowColor:Se}:{},...h.rowActions?{rowActions:h.rowActions}:{},...h.bulkActions?{batchActions:h.bulkActions}:{},...h.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...e,groupBy:h.kanban?.groupField||h.options?.kanban?.groupField||`status`,groupField:h.kanban?.groupField||h.options?.kanban?.groupField||`status`,...h.kanban?.titleField||h.options?.kanban?.titleField?{titleField:h.kanban?.titleField||h.options?.kanban?.titleField}:{},cardFields:h.kanban?.cardFields||ct||[],...he?{grouping:he}:{},...h.options?.kanban||{},...h.kanban||{}};case`calendar`:return{type:`object-calendar`,...e,startDateField:h.calendar?.startDateField||h.options?.calendar?.startDateField||`start_date`,endDateField:h.calendar?.endDateField||h.options?.calendar?.endDateField||`end_date`,...h.calendar?.titleField||h.options?.calendar?.titleField?{titleField:h.calendar?.titleField||h.options?.calendar?.titleField}:{},...h.calendar?.defaultView?{defaultView:h.calendar.defaultView}:{},...h.options?.calendar||{},...h.calendar||{}};case`gallery`:{let t={...h.options?.gallery||{},...h.gallery||{}};return{type:`object-gallery`,...e,gallery:Object.keys(t).length>0?t:void 0,imageField:h.gallery?.coverField||h.gallery?.imageField||h.options?.gallery?.imageField,titleField:h.gallery?.titleField||h.options?.gallery?.titleField||`name`,subtitleField:h.gallery?.subtitleField||h.options?.gallery?.subtitleField,...he?{grouping:he}:{}}}case`timeline`:{let t={...h.options?.timeline||{},...h.timeline||{}};return{type:`object-timeline`,...e,timeline:Object.keys(t).length>0?t:void 0,startDateField:h.timeline?.startDateField||h.options?.timeline?.startDateField||h.options?.timeline?.dateField||`created_at`,titleField:h.timeline?.titleField||h.options?.timeline?.titleField||`name`,...h.timeline?.endDateField?{endDateField:h.timeline.endDateField}:{},...h.timeline?.groupByField?{groupByField:h.timeline.groupByField}:{},...h.timeline?.colorField?{colorField:h.timeline.colorField}:{},...h.timeline?.scale?{scale:h.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...e,startDateField:h.gantt?.startDateField||h.options?.gantt?.startDateField||`start_date`,endDateField:h.gantt?.endDateField||h.options?.gantt?.endDateField||`end_date`,progressField:h.gantt?.progressField||h.options?.gantt?.progressField||`progress`,dependenciesField:h.gantt?.dependenciesField||h.options?.gantt?.dependenciesField||`dependencies`,...h.gantt?.titleField?{titleField:h.gantt.titleField}:{},...h.options?.gantt||{},...h.gantt||{}};case`map`:return{type:`object-map`,...e,locationField:h.options?.map?.locationField||`location`,...h.options?.map||{}};default:return e}},[x,h,k,ct,he,Se,st.handleClick]),ut=N.conditions&&N.conditions.length>0,dt=Q.useMemo(()=>{let e;if(e=H?.fields?Object.entries(H.fields).map(([e,t])=>({value:e,label:g(e,t.label||e),type:t.type||`text`,options:t.options})):(h.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let t=e.name||e.fieldName;return{value:t,label:g(t,e.label||e.name),type:e.type||`text`,options:e.options}}),h.filterableFields&&h.filterableFields.length>0){let t=new Set(h.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[H,h.fields,h.filterableFields]),ft=Q.useCallback(e=>{ke(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),pt=Q.useCallback(e=>{let t=Ue,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||h.objectName||`export`,a=n>0?R.slice(0,n):R;if(e===`csv`){let e=ct.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{n as e,r as t,t as n}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as r,g as i,t as a}from"./vendor-react-B1k2FF9f.js";import{B as o,D as s,H as c,L as l,R as u,a as d,h as f,j as p,k as m,m as h,v as g,w as _,x as v,z as y}from"./framework-CoXA0nY6.js";import{d as b,f as x}from"./infrastructure-Djv3I7gr.js";import{i as S,t as C}from"./vendor-ui-utils-Dyl9EYZi.js";import{$A as w,$k as T,$n as E,BF as D,Bt as O,CP as k,C_ as A,Cd as j,Cy as M,DP as N,El as P,FC as ee,FS as F,Hh as te,Ht as ne,IA as I,MS as L,Nd as R,OL as re,Ol as z,PL as B,Pm as V,Qn as H,RS as U,Rd as W,Tu as ie,Ut as G,Vr as ae,Vt as oe,Wt as se,X as ce,XF as le,Xn as K,Xv as q,Yn as ue,Yp as de,Z as fe,ZA as pe,Zc as me,Zn as he,_c as ge,_t as _e,ar as ve,bd as ye,br as be,c as xe,cE as Se,cI as Ce,cn as we,ct as Te,dn as J,dt as Ee,er as Y,fI as De,ff as Oe,fn as X,ft as ke,gt as Ae,hc as je,ht as Me,iI as Ne,kv as Pe,ln as Fe,ls as Ie,lt as Le,mM as Re,mo as ze,mt as Be,nO as Ve,nr as He,op as Ue,pE as We,pj as Ge,px as Ke,qE as qe,rj as Je,rk as Ye,rr as Xe,rt as Ze,tI as Qe,tr as $e,tt as et,uE as tt,um as nt,un as rt,ut as it,ux as at,vu as ot,wb as st,wh as ct,xh as lt,xm as ut,yb as dt,yr as Z,z_ as ft,zr as pt,zt as mt}from"./ui-components-B7mlp0en.js";import{i as ht}from"./plugin-grid-Cn_T_wpz.js";var Q=t(r(),1),$=a(),gt={grid:(0,$.jsx)(U,{className:`h-4 w-4`}),kanban:(0,$.jsx)(dt,{className:`h-4 w-4`}),gallery:(0,$.jsx)(Ke,{className:`h-4 w-4`}),calendar:(0,$.jsx)(Re,{className:`h-4 w-4`}),timeline:(0,$.jsx)(re,{className:`h-4 w-4`}),gantt:(0,$.jsx)(z,{className:`h-4 w-4`}),map:(0,$.jsx)(Pe,{className:`h-4 w-4`})},_t={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`},vt=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:n,className:r,animated:i=!0})=>{let a=Q.useCallback(t=>{if(!i||t===e){n(t);return}typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>n(t)):n(t)},[i,e,n]);return(0,$.jsx)(`div`,{className:B(`flex items-center gap-1 bg-transparent oui-view-switcher`,r),children:t.map(t=>{let n=e===t;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(t),"aria-label":_t[t],title:_t[t],"aria-pressed":n,"data-state":n?`on`:`off`,className:B(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,`hover:bg-muted hover:text-muted-foreground`,`gap-2 px-3 py-2`,`data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm border-transparent border data-[state=on]:border-border/50`),children:[gt[t],(0,$.jsx)(`span`,{className:`hidden sm:inline-block text-xs font-medium`,children:_t[t]})]},t)})})};function yt(e){return e?be[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function bt(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}var xt=({tabs:e,activeTab:t,onTabChange:n,className:r})=>{let i=Q.useMemo(()=>bt(e),[e]),a=Q.useMemo(()=>i.find(e=>e.isDefault)?.name??i[0]?.name,[i]),[o,s]=Q.useState(a),c=t??o,l=Q.useCallback(e=>{s(e.name),n?.(e)},[n]);return i.length===0?null:(0,$.jsx)(`div`,{className:B(`border-b 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=yt(e.icon),n=c===e.name;return(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-3 py-1.5 text-xs rounded-none transition-colors duration-150`,n?`border-b-2 border-primary font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),"data-testid":`view-tab-${e.name}`,role:`tab`,"aria-selected":n,onClick:()=>l(e),children:[t&&(0,$.jsx)(t,{className:`h-3 w-3 mr-1.5`}),e.label]},e.name)})})};function St({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a}){switch(e.element){case`dropdown`:return(0,$.jsx)(wt,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a});case`tabs`:return(0,$.jsx)(Tt,{tabs:e.tabs||[],showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a});case`toggle`:return(0,$.jsx)(Et,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function Ct(e,t,n){return e.map(e=>{let r=e.options?[...e.options]:[];if(r.length===0&&t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n?.options&&(r=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})))}return e.showCount&&n.length>0&&(r=r.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length}))),{...e,options:r}})}function wt({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a}){let[o,s]=Q.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues)}),t}),c=Q.useMemo(()=>Ct(e,t,n),[e,t,n]),l=Q.useCallback(e=>{r(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[r]),u=(e,t)=>{let n={...o,[e]:t};s(n),l(n)};Q.useEffect(()=>{Object.values(o).some(e=>e.length>0)&&l(o)},[]);let d=i!==void 0&&i<c.length?c.slice(0,i):c,f=i!==void 0&&i<c.length?c.slice(i):[],p=e=>{let t=o[e.field]||[],n=t.length>0;return(0,$.jsxs)(we,{children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:B(`inline-flex items-center gap-1 rounded-full border h-7 px-2.5 text-xs font-medium transition-colors shrink-0`,n?`border-primary/30 bg-primary/5 text-primary`:`border-border bg-background hover:bg-accent text-foreground`),children:[(0,$.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),n&&(0,$.jsx)(`span`,{className:`flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px]`,children:t.length}),n?(0,$.jsx)(ae,{className:`h-3 w-3 opacity-60`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),u(e.field,[])}}):(0,$.jsx)(Je,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-56 p-2`,children:(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-0.5`,"data-testid":`filter-options-${e.field}`,children:e.options.map(n=>(0,$.jsxs)(`label`,{className:B(`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,$.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];u(e.field,r)},className:`rounded border-input`}),n.color&&(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,$.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,$.jsxs)(`div`,{className:B(`flex items-center gap-1 overflow-x-auto`,a),"data-testid":`user-filters-dropdown`,children:[(0,$.jsx)(ie,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),c.length===0?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,$.jsxs)($.Fragment,{children:[d.map(p),f.length>0&&(0,$.jsxs)(we,{children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`user-filters-more`,className:`inline-flex items-center gap-1 rounded-full border border-border bg-background hover:bg-accent text-foreground h-7 px-2.5 text-xs font-medium transition-colors shrink-0`,children:[(0,$.jsx)(`span`,{children:`More`}),(0,$.jsx)(`span`,{className:`flex h-4 min-w-[16px] items-center justify-center rounded-full bg-muted text-[10px] font-medium`,children:f.length}),(0,$.jsx)(Je,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:f.map(p)})})]})]})]})}function Tt({tabs:e,showAllRecords:t,allowAddTab:n,onFilterChange:r,className:i}){let[a,o]=Q.useState(()=>e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),s=Q.useCallback(t=>{o(t),r(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[])},[e,r]),c=Q.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return Q.useEffect(()=>{let t=e.find(e=>e.default);t&&r(t.filters||[])},[]),(0,$.jsxs)(`div`,{className:B(`flex items-center gap-0.5 overflow-x-auto`,i),"data-testid":`user-filters-tabs`,children:[c.map(e=>(0,$.jsx)(`button`,{"data-testid":`filter-tab-${e.id}`,onClick:()=>s(e.id),className:B(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,a===e.id?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},e.id)),n&&(0,$.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,$.jsx)(nt,{className:`h-3.5 w-3.5`})})]})}function Et({fields:e,onFilterChange:t,className:n}){let[r,i]=Q.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),a=Q.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 Q.useEffect(()=>{r.size>0&&a(r)},[]),(0,$.jsx)(`div`,{className:B(`flex items-center gap-1 overflow-x-auto`,n),"data-testid":`user-filters-toggle`,children:e.map(e=>(0,$.jsx)(Z,{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 Dt(e){switch(e){case`equals`:case`eq`:return`=`;case`notEquals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;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`:return`not in`;case`before`:return`<`;case`after`:return`>`;default:return e}}function Ot(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)?Ot(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 kt(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function At(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?Ot(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function jt(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=At(e.conditions.map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,Dt(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var Mt={"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.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`};function Nt(){try{let e=d();return e.t(`list.recordCount`)===`list.recordCount`?{t:(e,t)=>{let n=Mt[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}}:{t:e.t}}catch{return{t:(e,t)=>{let n=Mt[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}}}}function Pt(){try{let{fieldLabel:e}=b();return{fieldLabel:e}}catch{return{fieldLabel:(e,t,n)=>n}}}var Ft=Q.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onRowClick:c,showViewSwitcher:u=!1,...d},f)=>{let{t:p}=Nt(),{fieldLabel:m}=Pt(),h=Q.useMemo(()=>({...e,viewType:e.viewType||`grid`}),[e]),g=Q.useCallback((e,t)=>h.objectName?m(h.objectName,e,t):t,[h.objectName,m]),b=Q.useMemo(()=>{let e=h.userActions,t=h.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?h.showSearch!==!1:e.search,showSort:e?.sort===void 0?h.showSort!==!1:e.sort,showFilters:e?.filter===void 0?h.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?h.showDensity===!0:e.rowHeight,showHideFields:h.showHideFields===!0,showGroup:h.showGroup!==!1,showColor:h.showColor===!0,showAddRecord:t,addRecordPosition:h.addRecord?.position===`bottom`?`bottom`:`top`}},[h.userActions,h.showSearch,h.showSort,h.showFilters,h.showDensity,h.showHideFields,h.showGroup,h.showColor,h.addRecord,h.userActions?.addRecordForm]),[x,S]=Q.useState(h.viewType),[C,w]=Q.useState(``),[T,E]=Q.useState(!1),[D,O]=Q.useState(!1),[k,A]=Q.useState(()=>h.sort&&h.sort.length>0?h.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`}}):[]),[j,M]=Q.useState(!1),[N,P]=Q.useState({id:`root`,logic:`and`,conditions:[]}),[ee,F]=Q.useState(()=>{if(!(!h.tabs||h.tabs.length===0))return h.tabs.find(e=>e.isDefault)?.name??h.tabs[0]?.name}),ne=Q.useCallback(e=>{if(F(e.name),e.filter){let t={id:`tab-filter-${e.name}`,logic:e.filter.logic||`and`,conditions:e.filter.conditions||[]};P(t),r?.(t)}else{let e={id:`root`,logic:`and`,conditions:[]};P(e),r?.(e)}},[r]),I=d.dataSource,[R,re]=Q.useState([]),[z,V]=Q.useState(!1),[H,U]=Q.useState(null),[G,oe]=Q.useState(!1),[se,ce]=Q.useState(0),[K,q]=Q.useState(!1);Q.useImperativeHandle(f,()=>({refresh:()=>ce(e=>e+1)}),[]),Q.useEffect(()=>{if(!(!I?.onMutation||!h.objectName||h.refreshTrigger))return I.onMutation(e=>{e.resource===h.objectName&&ce(e=>e+1)})},[I,h.objectName,h.refreshTrigger]);let[ue,fe]=Q.useState(void 0),pe=ue??h.pagination?.pageSize??100,me=Q.useMemo(()=>{if(h.grouping?.fields?.length)return h.grouping;let e=typeof h.groupBy==`string`?h.groupBy.trim():``,t=typeof h.groupBy2==`string`?h.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},[h.grouping,h.groupBy,h.groupBy2]),[he,ge]=Q.useState(me),[_e,ve]=Q.useState(!1),xe=Q.useRef(me);Q.useEffect(()=>{xe.current!==me&&(xe.current=me,ge(me))},[me]);let[Se,Ce]=Q.useState(h.rowColor),[Te,Ee]=Q.useState(!1),[Y,De]=Q.useState([]),Oe=Q.useRef(0),[X,ke]=Q.useState(()=>{let e=new Set;return h.quickFilters?.forEach(t=>{let n=y(t);n.defaultActive&&e.add(n.id)}),e}),[Ae,je]=Q.useState([]),Me=Q.useMemo(()=>{if(h.userFilters)return h.userFilters;if(!H?.fields)return;let e=new Set([`select`,`multi-select`,`boolean`]),t=[],n=Array.isArray(H.fields)?H.fields.map(e=>[e.name,e]):Object.entries(H.fields);for(let[r,i]of n)(e.has(i.type)||i.options&&!i.type)&&t.push({field:r,label:g(r,i.label||r),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});if(t.length!==0)return{element:`dropdown`,fields:t}},[h.userFilters,H]),[Ne,Pe]=Q.useState(()=>new Set(h.hiddenFields||[])),[Re,ze]=Q.useState(!1),[Be,Ve]=Q.useState(!1),He=Q.useMemo(()=>o(h.quickFilters),[h.quickFilters]),Ue=Q.useMemo(()=>{if(h.exportOptions)return Array.isArray(h.exportOptions)?{formats:h.exportOptions}:h.exportOptions},[h.exportOptions]),We=v(Q.useMemo(()=>h.densityMode?h.densityMode:h.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[h.rowHeight]||`comfortable`:`compact`,[h.densityMode,h.rowHeight])),{ref:Ge,isRefreshing:Ke,pullDistance:Je}=ht({onRefresh:Q.useCallback(async()=>{ce(e=>e+1)},[]),enabled:!!I&&!!h.objectName}),Ye=Q.useMemo(()=>h.id?`listview-${h.objectName}-${h.id}-view`:`listview-${h.objectName}-view`,[h.objectName,h.id]);Q.useEffect(()=>{let e=!0;return oe(!1),U(null),(async()=>{if(!I||!h.objectName){oe(!0);return}if(typeof I.getObjectSchema!=`function`){oe(!0);return}try{let t=await I.getObjectSchema(h.objectName);e&&U(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&oe(!0)}})(),()=>{e=!1}},[h.objectName,I]);let Xe=Q.useMemo(()=>l(H?.fields,h.fields),[H?.fields,h.fields]);Q.useEffect(()=>{let e=!0,t=++Oe.current;if(h.data&&typeof h.data==`object`&&!Array.isArray(h.data)){let e=h.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(C){let e=C.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}re(t),V(!1),q(!1);return}}if(Array.isArray(h.data)){let e=h.data;if(C){let t=C.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}re(e),V(!1),q(!1);return}return G?((async()=>{if(!(!I||!h.objectName)){V(!0);try{let n=[],r=h.filters||[],i=jt(N),a=[];He&&X.size>0&&He.forEach(e=>{X.has(e.id)&&e.filters&&e.filters.length>0&&a.push(e.filters)});let o=At(Ae),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=k.length>0?k.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,l=(()=>{let e=Array.isArray(h.fields)?h.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[];if(e.length===0)return;let t=new Set([`id`]);for(let n of e)t.add(n);for(let e of Xe)t.add(e);let 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:[]];for(let e of n)typeof e==`string`&&e&&t.add(e)};return n(h.kanban),n(h.options?.kanban),n(h.calendar),n(h.options?.calendar),n(h.gallery),n(h.options?.gallery),n(h.timeline),n(h.options?.timeline),n(h.gantt),n(h.options?.gantt),Array.from(t)})(),u=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,d=await I.find(h.objectName,{...u?{$filter:n}:{},$orderby:c,$top:pe,...l?{$select:l}:{},...Xe.length>0?{$expand:Xe}:{},...C?{$search:C,...h.searchableFields&&h.searchableFields.length>0?{$searchFields:h.searchableFields}:{}}:{}});if(!e||t!==Oe.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)),re(f),q(f.length>=pe)}catch(e){t===Oe.current&&console.error(`ListView data fetch error:`,e)}finally{e&&t===Oe.current&&V(!1)}}})(),()=>{e=!1}):void 0},[h.objectName,h.data,I,h.filters,pe,k,N,X,He,Ae,se,C,h.searchableFields,Xe,G,h.refreshTrigger]);let Qe=Q.useMemo(()=>{if(h.appearance?.allowedVisualizations&&h.appearance.allowedVisualizations.length>0)return h.appearance.allowedVisualizations.filter(e=>[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`].includes(e));let e=[`grid`];return(h.kanban?.groupField||h.options?.kanban?.groupField)&&e.push(`kanban`),(h.gallery?.coverField||h.gallery?.imageField||h.options?.gallery?.imageField)&&e.push(`gallery`),(h.calendar?.startDateField||h.options?.calendar?.startDateField)&&e.push(`calendar`),(h.timeline?.startDateField||h.options?.timeline?.startDateField||h.options?.timeline?.dateField||h.options?.calendar?.startDateField)&&e.push(`timeline`),(h.gantt?.startDateField||h.options?.gantt?.startDateField)&&e.push(`gantt`),(h.options?.map?.locationField||h.options?.map?.latitudeField&&h.options?.map?.longitudeField)&&e.push(`map`),h.viewType&&!e.includes(h.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`].includes(h.viewType)&&e.push(h.viewType),e},[h.options,h.viewType,h.kanban,h.calendar,h.gantt,h.gallery,h.timeline,h.appearance?.allowedVisualizations]);Q.useEffect(()=>{h.viewType&&S(h.viewType)},[h.viewType]);let $e=Q.useCallback(e=>{S(e);try{localStorage.setItem(Ye,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[Ye,n]),ot=Q.useCallback(e=>{w(e),a?.(e)},[a]),st=_({navigation:h.navigation,objectName:h.objectName,onNavigate:h.onNavigate,onRowClick:c}),ct=Q.useMemo(()=>{let e=h.fields||[];if(Array.isArray(e)||(e=[]),Ne.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!Ne.has(t)})),h.fieldOrder&&h.fieldOrder.length>0){let t=new Map(h.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},[h.fields,Ne,h.fieldOrder]),lt=Q.useMemo(()=>{let e={objectName:h.objectName,fields:ct,filters:h.filters,sort:k,className:`h-full w-full`,showSearch:!1,onRowClick:st.handleClick,...h.striped==null?{}:{striped:h.striped},...h.bordered==null?{}:{bordered:h.bordered}};switch(x){case`grid`:return{type:`object-grid`,...e,columns:ct,...h.conditionalFormatting?{conditionalFormatting:h.conditionalFormatting}:{},...h.inlineEdit==null?{}:{editable:h.inlineEdit},...h.wrapHeaders==null?{}:{wrapHeaders:h.wrapHeaders},...h.virtualScroll==null?{}:{virtualScroll:h.virtualScroll},...h.resizable==null?{}:{resizable:h.resizable},...h.selection?{selection:h.selection}:{},...h.pagination?{pagination:h.pagination}:{},...he?{grouping:he}:{},...Se?{rowColor:Se}:{},...h.rowActions?{rowActions:h.rowActions}:{},...h.bulkActions?{batchActions:h.bulkActions}:{},...h.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...e,groupBy:h.kanban?.groupField||h.options?.kanban?.groupField||`status`,groupField:h.kanban?.groupField||h.options?.kanban?.groupField||`status`,...h.kanban?.titleField||h.options?.kanban?.titleField?{titleField:h.kanban?.titleField||h.options?.kanban?.titleField}:{},cardFields:h.kanban?.cardFields||ct||[],...he?{grouping:he}:{},...h.options?.kanban||{},...h.kanban||{}};case`calendar`:return{type:`object-calendar`,...e,startDateField:h.calendar?.startDateField||h.options?.calendar?.startDateField||`start_date`,endDateField:h.calendar?.endDateField||h.options?.calendar?.endDateField||`end_date`,...h.calendar?.titleField||h.options?.calendar?.titleField?{titleField:h.calendar?.titleField||h.options?.calendar?.titleField}:{},...h.calendar?.defaultView?{defaultView:h.calendar.defaultView}:{},...h.options?.calendar||{},...h.calendar||{}};case`gallery`:{let t={...h.options?.gallery||{},...h.gallery||{}};return{type:`object-gallery`,...e,gallery:Object.keys(t).length>0?t:void 0,imageField:h.gallery?.coverField||h.gallery?.imageField||h.options?.gallery?.imageField,titleField:h.gallery?.titleField||h.options?.gallery?.titleField||`name`,subtitleField:h.gallery?.subtitleField||h.options?.gallery?.subtitleField,...he?{grouping:he}:{}}}case`timeline`:{let t={...h.options?.timeline||{},...h.timeline||{}};return{type:`object-timeline`,...e,timeline:Object.keys(t).length>0?t:void 0,startDateField:h.timeline?.startDateField||h.options?.timeline?.startDateField||h.options?.timeline?.dateField||`created_at`,titleField:h.timeline?.titleField||h.options?.timeline?.titleField||`name`,...h.timeline?.endDateField?{endDateField:h.timeline.endDateField}:{},...h.timeline?.groupByField?{groupByField:h.timeline.groupByField}:{},...h.timeline?.colorField?{colorField:h.timeline.colorField}:{},...h.timeline?.scale?{scale:h.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...e,startDateField:h.gantt?.startDateField||h.options?.gantt?.startDateField||`start_date`,endDateField:h.gantt?.endDateField||h.options?.gantt?.endDateField||`end_date`,progressField:h.gantt?.progressField||h.options?.gantt?.progressField||`progress`,dependenciesField:h.gantt?.dependenciesField||h.options?.gantt?.dependenciesField||`dependencies`,...h.gantt?.titleField?{titleField:h.gantt.titleField}:{},...h.options?.gantt||{},...h.gantt||{}};case`map`:return{type:`object-map`,...e,locationField:h.options?.map?.locationField||`location`,...h.options?.map||{}};default:return e}},[x,h,k,ct,he,Se,st.handleClick]),ut=N.conditions&&N.conditions.length>0,dt=Q.useMemo(()=>{let e;if(e=H?.fields?Object.entries(H.fields).map(([e,t])=>({value:e,label:g(e,t.label||e),type:t.type||`text`,options:t.options})):(h.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let t=e.name||e.fieldName;return{value:t,label:g(t,e.label||e.name),type:e.type||`text`,options:e.options}}),h.filterableFields&&h.filterableFields.length>0){let t=new Set(h.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[H,h.fields,h.filterableFields]),ft=Q.useCallback(e=>{ke(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),pt=Q.useCallback(e=>{let t=Ue,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||h.objectName||`export`,a=n>0?R.slice(0,n):R;if(e===`csv`){let e=ct.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)}Ve(!1)},[R,ct,Ue,h.objectName]),mt=Q.useMemo(()=>(h.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:g(e,e)};let t=e.name||e.fieldName||e.field;return{name:t,label:g(t,e.label||e.name||e.field)}}),[h.fields,g]);return(0,$.jsxs)(`div`,{ref:Ge,className:B(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,t),...h.aria?.label?{"aria-label":h.aria.label}:{},...h.aria?.describedBy?{"aria-describedby":h.aria.describedBy}:{},...h.aria?.live?{"aria-live":h.aria.live}:{},role:`region`,children:[Je>0&&(0,$.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Je},children:p(Ke?`list.refreshing`:`list.pullToRefresh`)}),u&&(0,$.jsx)(`div`,{className:`border-b px-4 py-1 flex items-center bg-background`,children:(0,$.jsx)(vt,{currentView:x,availableViews:Qe,onViewChange:$e})}),h.tabs&&h.tabs.length>0&&(0,$.jsx)(xt,{tabs:h.tabs,activeTab:ee,onTabChange:ne}),h.description&&h.appearance?.showDescription!==!1&&(0,$.jsx)(`div`,{className:`border-b px-4 py-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:typeof h.description==`string`?h.description:``}),(0,$.jsxs)(`div`,{className:`border-b px-2 sm:px-4 py-1 flex items-center justify-between gap-1 sm:gap-2 bg-background`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto min-w-0`,children:Me&&(0,$.jsx)(`div`,{className:`shrink-0 min-w-0`,"data-testid":`user-filters`,children:(0,$.jsx)(St,{config:Me,objectDef:H,data:R,onFilterChange:je,maxVisible:3})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[b.showHideFields&&(0,$.jsxs)(we,{open:Re,onOpenChange:ze,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Ne.size>0&&`text-primary`),children:[(0,$.jsx)(tt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.hideFields`)}),Ne.size>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-medium text-primary`,children:Ne.size})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-64 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.hideFieldsTitle`)}),Ne.size>0&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Pe(new Set),children:p(`list.showAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:mt.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!Ne.has(e.name),onChange:()=>{Pe(t=>{let n=new Set(t);return n.has(e.name)?n.delete(e.name):n.add(e.name),n})},className:`rounded border-input`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),b.showHideFields&&(b.showFilters||b.showSort||b.showGroup)&&(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5 shrink-0`}),b.showFilters&&(0,$.jsxs)(we,{open:j,onOpenChange:M,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,ut&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(ie,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.filter`)}),ut&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-medium text-primary`,children:N.conditions?.length||0})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.filterRecords`)})}),(0,$.jsx)(it,{fields:dt,value:N,onChange:e=>{P(e),r&&r(e)}})]})})]}),b.showGroup&&(0,$.jsxs)(we,{open:_e,onOpenChange:ve,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,he&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(L,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.group`)}),he&&he.fields?.length>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-medium text-primary`,children:he.fields.length})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-72 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.groupBy`)}),he&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>ge(void 0),"data-testid":`clear-grouping`,children:p(`list.clear`)})]}),(0,$.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,$.jsx)(et,{value:he,fieldOptions:mt.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:p(`list.addGroup`,`Add group field`),collapseTitle:p(`list.collapsedByDefault`,`Collapsed by default`),removeTitle:p(`list.removeGroup`,`Remove`)},onChange:e=>ge(e)})})]})})]}),b.showSort&&(0,$.jsxs)(we,{open:D,onOpenChange:O,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,k.length>0&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(le,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.sort`)}),k.length>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-medium text-primary`,children:k.length})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.sortRecords`)})}),(0,$.jsx)(Le,{fields:dt,value:k,onChange:e=>{A(e),i&&i(e)}})]})})]}),(b.showFilters||b.showSort||b.showGroup)&&(b.showColor||b.showDensity)&&(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5 shrink-0`}),b.showColor&&(0,$.jsxs)(we,{open:Te,onOpenChange:Ee,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Se&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(te,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.color`)})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-64 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.rowColor`)}),Se&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ce(void 0),"data-testid":`clear-row-color`,children:p(`list.clear`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:p(`list.colorByField`)}),(0,$.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:Se?.field||``,onChange:e=>{let t=e.target.value;Ce(t?{field:t,colors:Se?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,$.jsx)(`option`,{value:``,children:p(`list.none`)}),mt.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),b.showDensity&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs hidden lg:flex transition-colors duration-150`,We.mode!==`compact`&&`bg-primary/10 border border-primary/20 text-primary`),onClick:We.cycle,title:`Density: ${We.mode}`,children:[(0,$.jsx)(Ie,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline capitalize`,children:We.mode})]}),(b.showColor||b.showDensity)&&Ue&&h.allowExport!==!1&&(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5 shrink-0`}),Ue&&h.allowExport!==!1&&(0,$.jsxs)(we,{open:Be,onOpenChange:Ve,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,children:[(0,$.jsx)(qe,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.export`)})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-48 p-2`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:(Ue.formats||[`csv`,`json`]).map(e=>(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,onClick:()=>pt(e),children:[(0,$.jsx)(qe,{className:`h-3.5 w-3.5 mr-2`}),p(`list.exportAs`,{format:e.toUpperCase()})]},e))})})]}),(h.sharing?.enabled||h.sharing?.type)&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${h.sharing?.visibility||h.sharing?.type||`private`}`,"data-testid":`share-button`,children:[(0,$.jsx)(ye,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.share`)})]}),h.allowPrinting&&(0,$.jsxs)(Z,{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,$.jsx)(de,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.print`)})]}),(()=>{let e=h.allowPrinting||h.sharing?.enabled||h.sharing?.type||Ue&&h.allowExport!==!1;return b.showSearch&&e?(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5 shrink-0`}):null})(),b.showSearch&&(0,$.jsxs)(we,{open:T,onOpenChange:E,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 w-7 p-0 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,C&&`bg-primary/10 border border-primary/20 text-primary`),"data-testid":`search-icon-button`,title:p(`list.search`),children:(0,$.jsx)(W,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Fe,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(W,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(J,{placeholder:p(`list.search`)+`...`,value:C,onChange:e=>ot(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),C&&(0,$.jsx)(Z,{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,$.jsx)(ae,{className:`h-3 w-3`})})]})})]}),b.showAddRecord&&b.addRecordPosition===`top`&&(0,$.jsxs)(Z,{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:()=>d.onAddRecord?.(),children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.addRecord`)})]})]})]}),He&&He.length>0&&(0,$.jsx)(`div`,{className:`border-b px-2 sm:px-4 py-1 flex items-center gap-1 flex-wrap bg-background`,"data-testid":`quick-filters`,children:He.map(e=>{let t=X.has(e.id),n=e.icon?be[e.icon.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null;return(0,$.jsxs)(Z,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs`,onClick:()=>ft(e.id),children:[n&&(0,$.jsx)(n,{className:`h-3 w-3 mr-1.5`}),e.label]},e.id)})}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:!z&&R.length===0?(()=>{let e=h.emptyState?.icon;return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full min-h-[200px] text-center p-8`,"data-testid":`empty-state`,children:[(0,$.jsx)(e?be[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??at:at,{className:`h-12 w-12 text-muted-foreground/50 mb-4`}),(0,$.jsx)(`h3`,{className:`text-lg font-medium text-foreground mb-1`,children:(typeof h.emptyState?.title==`string`?h.emptyState.title:void 0)??`No items found`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:(typeof h.emptyState?.message==`string`?h.emptyState.message:void 0)??`There are no records to display. Try adjusting your filters or adding new data.`}),b.showAddRecord&&(0,$.jsxs)(Z,{variant:`default`,size:`sm`,className:`mt-4`,"data-testid":`empty-state-add-record`,onClick:()=>d.onAddRecord?.(),children:[(0,$.jsx)(nt,{className:`h-4 w-4 mr-1.5`}),p(`list.addRecord`)]})]})})():(0,$.jsx)(s,{schema:lt,...d,data:R,loading:z,onRowSelect:De})},x),b.showAddRecord&&b.addRecordPosition===`bottom`&&(0,$.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,$.jsxs)(Z,{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:()=>d.onAddRecord?.(),children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.addRecord`)})]})}),h.bulkActions&&h.bulkActions.length>0&&Y.length>0&&x!==`grid`&&(0,$.jsxs)(`div`,{className:`border-t px-4 py-1.5 flex items-center gap-2 text-xs bg-primary/5 shrink-0`,"data-testid":`bulk-actions-bar`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground font-medium`,children:[Y.length,` selected`]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 ml-2`,children:h.bulkActions.map(e=>(0,$.jsx)(Z,{variant:`outline`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>d.onBulkAction?.(e,Y),"data-testid":`bulk-action-${e}`,children:kt(e)},e))}),(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs ml-auto`,onClick:()=>De([]),children:`Clear`})]}),!z&&R.length>0&&h.showRecordCount!==!1&&(0,$.jsxs)(`div`,{className:`border-t px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground bg-background shrink-0`,"data-testid":`record-count-bar`,children:[(0,$.jsx)(`span`,{children:R.length===1?p(`list.recordCountOne`,{count:R.length}):p(`list.recordCount`,{count:R.length})}),K&&(0,$.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:p(`list.dataLimitReached`,{limit:pe})}),h.pagination?.pageSizeOptions&&h.pagination.pageSizeOptions.length>0&&(0,$.jsx)(`select`,{className:`ml-auto h-6 rounded border border-input bg-background px-1 text-xs`,value:pe,onChange:e=>{let t=Number(e.target.value);fe(t),d.onPageSizeChange&&d.onPageSizeChange(t)},"data-testid":`page-size-selector`,children:h.pagination.pageSizeOptions.map(e=>(0,$.jsxs)(`option`,{value:e,children:[e,` / page`]},e))})]}),st.isOverlay&&(0,$.jsx)(Ze,{...st,title:h.label?`${h.label} Detail`:h.objectName?`${h.objectName.charAt(0).toUpperCase()+h.objectName.slice(1)} Detail`:`Record Detail`,children:e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,$.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});Ft.displayName=`ListView`;var It={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`},Lt={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`};c.register(`object-gallery`,e=>{let{schema:t}=e,n=(0,Q.useContext)(m),r=e.dataSource||n?.dataSource,i=p(t.bind),[a,o]=(0,Q.useState)([]),[s,c]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f=_({navigation:t.navigation,objectName:t.objectName,onRowClick:e.onRowClick??e.onCardClick}),h=t.gallery,g=h?.coverField??t.imageField??`image`,v=h?.coverFit??`cover`,y=h?.cardSize??`medium`,b=h?.titleField??t.titleField??`name`,x=h?.visibleFields;(0,Q.useEffect)(()=>{let e=!0;return(async()=>{if(!(!r||typeof r.getObjectSchema!=`function`||!t.objectName))try{let n=await r.getObjectSchema(t.objectName);e&&d(n)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[t.objectName,r]),(0,Q.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=l(u?.fields),i=await r.find(t.objectName,{$filter:t.filter,...e.length>0?{$expand:e}:{}}),a=[];if(Array.isArray(i))a=i;else if(i&&typeof i==`object`){let e=i;Array.isArray(e.records)?a=e.records:Array.isArray(e.data)&&(a=e.data)}n&&o(a)}catch(e){console.error(`[ObjectGallery] Fetch error:`,e)}finally{n&&c(!1)}}})(),()=>{n=!1}},[t.objectName,r,i,t.data,t.filter,e.data,u]);let S=e.data||i||t.data||a||[],C=(0,Q.useMemo)(()=>S.some(e=>typeof e[g]==`string`&&!!e[g]),[S,g]),w=!!h?.coverField||C,T=t.grouping?.fields,D=!!(T&&T.length>0),[O,k]=(0,Q.useState)({}),A=(0,Q.useMemo)(()=>T?T.some(e=>e.collapsed):!1,[T]),j=(0,Q.useCallback)(e=>{k(t=>({...t,[e]:t[e]===void 0?!A:!t[e]}))},[A]),M=(0,Q.useMemo)(()=>{if(!D||!T)return[];let e=new Map,t=[];for(let n of S){let r=T.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=T.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=T[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 O?O[t]:A;return{key:t,label:n.label,items:n.items,collapsed:r}})},[S,T,D,O,A]);if(s&&!S.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!S.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let N=(n,r)=>{let i=n.id??n._id??r,a=String(n[b]??`Untitled`),o=n[g];return(0,$.jsxs)(E,{role:`listitem`,className:B(`group overflow-hidden transition-all hover:shadow-md`,(e.onCardClick||e.onRowClick||t.navigation)&&`cursor-pointer`),onClick:()=>f.handleClick(n),children:[(0,$.jsx)(`div`,{className:B(`w-full overflow-hidden bg-muted relative`,Lt[y]),hidden:!w,children:o?(0,$.jsx)(`img`,{src:o,alt:a,className:B(`h-full w-full transition-transform group-hover:scale-105`,v===`cover`&&`object-cover`,v===`contain`&&`object-contain`)}):(0,$.jsx)(`div`,{className:`flex h-full w-full items-center justify-center bg-secondary/50 text-muted-foreground`,children:(0,$.jsx)(`span`,{className:`text-4xl font-light opacity-20`,children:a[0]?.toUpperCase()})})}),(0,$.jsxs)(Y,{className:B(`p-3`,w&&`border-t`),children:[(0,$.jsx)(`h3`,{className:`font-medium truncate text-sm`,title:a,children:a}),x&&x.length>0&&(0,$.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:x.map(e=>{let t=n[e];return t==null||t===``?null:(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:typeof t==`object`?t.label??t.name??t.id??JSON.stringify(t):String(t)},e)})})]})]},i)},P=e=>(0,$.jsx)(`div`,{className:B(`grid gap-4 p-4 auto-rows-min content-start`,It[y],t.className),role:`list`,children:e.map((e,t)=>N(e,t))});return(0,$.jsxs)($.Fragment,{children:[D?(0,$.jsx)(`div`,{className:`space-y-2`,children:M.map(e=>(0,$.jsxs)(`div`,{className:`border rounded-md`,children:[(0,$.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:()=>j(e.key),children:[e.collapsed?(0,$.jsx)(pe,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Je,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&P(e.items)]},e.key))}):P(S),f.isOverlay&&(0,$.jsx)(Ze,{...f,title:`Gallery Item`,children:e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,$.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},{namespace:`plugin-list`,label:`Gallery View`,category:`view`}),c.register(`list-view`,Ft,{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`,Ft,{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 Rt=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function zt(e){return Rt.has(e)}function Bt(e,t){let n;if(n=e<=3?1:e<=10?2:3,t!==void 0){if(t<640)return Math.min(n,1);if(t<900)return Math.min(n,2)}return n}function Vt(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&zt(e.type)?{...e,span:t}:e)}function Ht(e,t,n){if(t!==void 0)return{fields:Vt(e,t),columns:t};let r=Bt(e.length,n);return{fields:Vt(e,r),columns:r}}function Ut(e,t){return function(){try{let n=d();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 Wt=Ut({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit inline`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"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.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.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.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.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.back`);function Gt(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 Kt=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,virtualScroll:c})=>{let[l,u]=Q.useState(e.defaultCollapsed??!1),[d,f]=Q.useState(null),[p,m]=Q.useState(void 0),[h,g]=Q.useState(!1),{t:_}=Wt(),{fieldLabel:v}=x(),y=Q.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{f(e),setTimeout(()=>f(null),2e3)})},[]),b=Q.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),S=Q.useMemo(()=>e.fields.filter(b).length,[e.fields,b]),C=se(),w=C?3:6,T=C?.2:.5,D=e.fields.length-S,k=!e.hideEmpty&&!a&&e.fields.length>=w&&S/e.fields.length>=T&&D>0,A=!h&&(e.hideEmpty||k)?e.fields.filter(e=>!b(e)):e.fields;if(A.length===0&&S===e.fields.length)return null;let{fields:j,columns:M}=Ht(A,e.columns),N=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,$.jsx)(s,{schema:e.render,data:{...t,value:n}});let c=Gt(e.span,M),l=(()=>{if(n==null)return(0,$.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`});let t=r?.fields?.[e.name],i=e.type||t?.type,a={...e};if(t){!e.type&&t.type&&(a.type=t.type),t.options&&!a.options&&(a.options=t.options),t.currency&&!a.currency&&(a.currency=t.currency),t.precision!==void 0&&a.precision===void 0&&(a.precision=t.precision),t.format&&!a.format&&(a.format=t.format);let n=t.reference_to||t.reference;n&&!a.reference_to&&(a.reference_to=n),t.reference_field&&!a.reference_field&&(a.reference_field=t.reference_field)}if(i){let e=xe(i);if(e)return(0,$.jsx)(e,{value:n,field:a})}return String(n)})(),u=n!=null&&n!==``,f=d===e.name;return(0,$.jsxs)(`div`,{className:B(`space-y-1.5 group`,c),children:[(0,$.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,$.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,$.jsx)(`input`,{type:e.type===`number`?`number`:e.type===`date`?`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?``:String(n),onChange:t=>o?.(e.name,t.target.value)})}):(0,$.jsxs)(`div`,{className:B(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,u&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:u?()=>y(e.name,n):void 0,onKeyDown:u?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),y(e.name,n))}:void 0,role:u?`button`:void 0,tabIndex:u?0:void 0,children:[(0,$.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:l}),u&&(0,$.jsx)(oe,{children:(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),y(e.name,n)},children:f?(0,$.jsx)(Ge,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(Ve,{className:`h-3 w-3`})})}),(0,$.jsx)(O,{children:_(f?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},P=c?.enabled===!0,ee=c?.batchSize??20;Q.useEffect(()=>{if(!P){m(void 0);return}if(j.length<=ee){m(void 0);return}m(ee);let e=setTimeout(()=>m(void 0),100);return()=>clearTimeout(e)},[P,j.length,ee]);let F=p===void 0?j:j.slice(0,p),te=S>0&&(e.hideEmpty||k),I=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:B(`grid gap-3 sm:gap-4`,M===1?`grid-cols-1`:M===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:F.map(N)}),te&&(0,$.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,$.jsxs)(Z,{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,$.jsx)(tt,{className:`h-3.5 w-3.5 mr-1.5`}):(0,$.jsx)(Se,{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,$.jsx)(`div`,{className:B(n),children:I}):e.collapsible?(0,$.jsx)(ue,{open:!l,onOpenChange:e=>u(!e),className:n,children:(0,$.jsxs)(E,{children:[(0,$.jsx)(he,{asChild:!0,children:(0,$.jsxs)(He,{className:B(`cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsxs)(Xe,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`span`,{children:e.title}),e.fields&&(0,$.jsx)(ve,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:l?(0,$.jsx)(pe,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Je,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!l&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]})}),(0,$.jsx)(K,{children:(0,$.jsx)(Y,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:I})})]})}):(0,$.jsxs)(E,{className:B(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,$.jsxs)(He,{className:B(e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsx)(Xe,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`span`,{children:e.title})]})}),e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]}),(0,$.jsx)(Y,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:I})]})},qt=({tabs:e,data:t,className:n})=>{let[r,i]=Q.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,$.jsxs)(Be,{value:r,onValueChange:i,className:n,children:[(0,$.jsx)(Ae,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,$.jsx)(_e,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{children:e.icon}),(0,$.jsx)(`span`,{children:e.label}),e.badge&&(0,$.jsx)(ve,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,$.jsx)(Me,{value:e.key,className:`mt-4`,children:(0,$.jsx)(Q.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,$.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,$.jsx)(s,{schema:e,data:t},n))}):(0,$.jsx)(s,{schema:e.content,data:t})})},e.key))]})};function Jt(e){return e&&be[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||at}var Yt=({title:e,type:t,api:n,data:r=[],schema:i,columns:a,className:o,dataSource:c,objectName:l,onNew:u,onViewAll:d,onRowEdit:f,onRowDelete:p,pageSize:m,sortable:h=!1,filterable:g=!1,collapsible:_=!1,defaultCollapsed:v=!1,referenceField:y,icon:b})=>{let[S,C]=Q.useState(r),[T,D]=Q.useState(!1),[O,k]=Q.useState(0),[A,j]=Q.useState(null),[M,N]=Q.useState(`asc`),[P,ee]=Q.useState(``),[F,te]=Q.useState(null),[ne,I]=Q.useState(v),{t:L}=Wt(),{fieldLabel:R}=x();Q.useEffect(()=>{C(r)},[r]),Q.useEffect(()=>{n&&c?.getObjectSchema&&!a?.length&&c.getObjectSchema(n).then(te).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,c,a]),Q.useEffect(()=>{n&&!r.length&&(D(!0),c&&typeof c.find==`function`?c.find(n).then(e=>{C(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),D(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),D(!1)}):fetch(n).then(e=>e.json()).then(e=>{C(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>D(!1)))},[n,r,c]);let re=Q.useMemo(()=>{if(!P)return S;let e=P.toLowerCase();return S.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[S,P]),z=Q.useMemo(()=>A?[...re].sort((e,t)=>{let n=e[A],r=t[A];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 M===`asc`?i:-i}):re,[re,A,M]),V=m&&m>0?m:0,H=V?Math.max(1,Math.ceil(z.length/V)):1,U=V?z.slice(O*V,(O+1)*V):z;Q.useEffect(()=>{k(0)},[P,A,M]);let W=Q.useCallback(e=>{A===e?N(e=>e===`asc`?`desc`:`asc`):(j(e),N(`asc`))},[A]),ie=Q.useCallback(e=>{window.confirm(L(`detail.deleteRowConfirmation`))&&p?.(e)},[p,L]),G=Q.useMemo(()=>{let e=e=>y?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==y):e;if(a&&a.length>0)return e(a);if(!F?.fields)return[];let t=l||n||``;return Object.entries(F.fields).filter(([e])=>!e.startsWith(`_`)&&e!==`id`&&e!==y).map(([e,n])=>{let r={accessorKey:e,header:R(t,e,n.label||e)};if(n.type){let t=xe(n.type);if(t){let i={name:e,label:n.label||e,type:n.type,...n.options&&{options:n.options},...n.currency&&{currency:n.currency},...n.precision!==void 0&&{precision:n.precision},...n.format&&{format:n.format},...(n.reference_to||n.reference)&&{reference_to:n.reference_to||n.reference},...n.reference_field&&{reference_field:n.reference_field}};r.cell=e=>e==null?Q.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):Q.createElement(t,{value:e,field:i})}}return r})},[a,F,l,n,R,y]),ae=Q.useMemo(()=>{if(i)return i;switch(t){case`grid`:case`table`:return{type:`data-table`,data:U,columns:G,pagination:!1,pageSize:V||10,searchable:!1,exportable:!1};case`list`:return{type:`data-list`,data:U};default:return{type:`div`,children:`No view configured`}}},[t,U,G,i,V]),oe=!!f||!!p,se=_?`cursor-pointer select-none`:void 0,ce=_?()=>I(e=>!e):void 0,K=Jt(b),q=!T&&S.length===0,ue=g;return(0,$.jsxs)(E,{className:B(`shadow-none`,q&&`bg-muted/20`,o),children:[(0,$.jsx)(He,{className:B(`py-3 px-4`,se),onClick:ce,children:(0,$.jsxs)(Xe,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[_&&(ne?(0,$.jsx)(pe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,$.jsx)(Je,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,$.jsx)(K,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e}),(0,$.jsx)(ve,{variant:`secondary`,className:B(`text-xs font-normal h-5 px-1.5`,S.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${S.length} records`,children:S.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[u&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),u()},className:`gap-1 h-7 text-xs`,children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5`}),L(`detail.new`)]}),d&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),d()},className:`gap-1 h-7 text-xs`,children:[L(`detail.viewAll`),(0,$.jsx)(We,{className:`h-3 w-3`})]})]})]})}),!ne&&(0,$.jsxs)(Y,{className:B(`pt-0`,q?`pb-3 px-4`:`pb-4 px-4`),children:[ue&&(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(J,{placeholder:L(`detail.filterPlaceholder`),value:P,onChange:e=>ee(e.target.value),className:`h-8 text-sm`})}),h&&G&&G.length>0&&S.length>0&&(0,$.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=A===t;return(0,$.jsxs)(Z,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>W(t),children:[(0,$.jsx)(le,{className:`h-3 w-3`}),n,r&&(M===`asc`?` ↑`:` ↓`)]},t)})}),T?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:L(`detail.loading`)}):q?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground italic`,children:L(`detail.noRelatedRecords`)}),u===void 0&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(s,{schema:ae}),oe&&U.length>0&&(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,"data-testid":`row-actions`,children:U.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 text-xs border-b last:border-b-0`,children:[(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.name||e.title||e.id||`Row ${t+1}`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[f&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2`,onClick:()=>f(e),children:[(0,$.jsx)(me,{className:`h-3 w-3`}),L(`detail.editRow`)]}),p&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2 text-destructive hover:text-destructive`,onClick:()=>ie(e),children:[(0,$.jsx)(ze,{className:`h-3 w-3`}),L(`detail.deleteRow`)]})]})]},e.id||t))})]}),V>0&&z.length>V&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:O===0,onClick:()=>k(e=>Math.max(0,e-1)),children:[(0,$.jsx)(w,{className:`h-3 w-3`}),L(`detail.previousPage`)]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:L(`detail.pageOf`,{current:O+1,total:H})}),(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:O>=H-1,onClick:()=>k(e=>Math.min(H-1,e+1)),children:[L(`detail.nextPage`),(0,$.jsx)(pe,{className:`h-3 w-3`})]})]})]})]})},Xt=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o})=>{let s=e.collapsible??!0,[c,l]=Q.useState(e.defaultCollapsed??!1),u=(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,$.jsx)(Kt,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o},n))});return s?(0,$.jsxs)(ue,{open:!c,onOpenChange:e=>l(!e),className:n,children:[(0,$.jsx)(he,{asChild:!0,children:(0,$.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,$.jsx)(pe,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,$.jsx)(Je,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!c&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,$.jsx)(K,{children:(0,$.jsx)(`div`,{className:`mt-3`,children:u})})]}):(0,$.jsxs)(`div`,{className:B(`space-y-3`,n),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),u]})},Zt=({fields:e,data:t,className:n,objectName:r,objectSchema:i})=>{let{fieldLabel:a}=x();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,$.jsx)(E,{className:B(`bg-muted/30 border-dashed`,n),children:(0,$.jsx)(Y,{className:`py-3 px-4`,children:(0,$.jsx)(`div`,{className:B(`grid gap-4`,o.length===1?`grid-cols-1`:o.length===2?`grid-cols-2`:o.length===3?`grid-cols-3`:`grid-cols-2 md:grid-cols-4`),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=xe(s||`text`);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[e.icon&&(0,$.jsx)(`span`,{className:`mr-1`,children:e.icon}),a(r||``,e.name,e.label)]}),(0,$.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:(0,$.jsx)(l,{value:n,field:c})})]},e.name)})})})})};function Qt(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 $t=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=Wt(),[o,s]=Q.useState(``),[c,l]=Q.useState(!1),[u,d]=Q.useState(``),f=Q.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=Q.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,$.jsxs)(E,{className:B(``,i),children:[(0,$.jsx)(He,{children:(0,$.jsxs)(Xe,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(ft,{className:`h-4 w-4`}),a(`detail.comments`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,$.jsxs)(Y,{className:`space-y-4`,children:[r&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(W,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.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,$.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,$.jsx)(ae,{className:`h-3.5 w-3.5`})})]})}),t&&(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.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,$.jsx)(Z,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,$.jsx)(R,{className:`h-4 w-4`})})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,$.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,$.jsxs)(`div`,{className:B(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,$.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,$.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,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Qt(e.createdAt)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,$.jsx)(ut,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,$.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,$.jsx)(ut,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},en={field_change:me,create:T,delete:ze,comment:ft,status_change:Ne},tn={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 nn(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 rn(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 an={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},on=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let[i,a]=Q.useState(n),o=Q.useMemo(()=>i===`all`?e:e.filter(e=>e.type===i),[e,i]);return(0,$.jsxs)(E,{className:B(``,r),children:[(0,$.jsx)(He,{children:(0,$.jsxs)(Xe,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(re,{className:`h-4 w-4`}),`Activity`,(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,$.jsxs)(Y,{children:[t&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(an).map(e=>(0,$.jsxs)(`button`,{type:`button`,className:B(`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`&&Q.createElement(en[e]||me,{className:`h-3 w-3`}),an[e]]},e))}),o.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No activity recorded`}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:o.map(e=>{let t=en[e.type]||me;return(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:B(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,tn[e.type]||`bg-gray-100 text-gray-600`),children:(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:rn(e)})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:nn(e.timestamp)})]})]},e.id)})})]})]})]})},sn=5;function cn(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;if(r){let t=`[-\\u2013\\u2014|/·,:]`,n=!1,i=r.replace(/\{([^{}]+)\}/g,(t,r)=>{let i=e[r.trim()];return i!=null&&i!==``?(n=!0,String(i)):`\0`});if(n){let e=i.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 ln=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:o=!1,onFieldSave:c,discussionSlot:u,rightRail:d,objectLabel:f,onDataLoaded:p})=>{let[m,h]=Q.useState(e.data),[g,_]=Q.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[v,y]=Q.useState(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState({}),[T,E]=Q.useState(null),[D,k]=Q.useState(!1),{t:A}=Wt();Q.useEffect(()=>{m&&p&&p(m)},[m,p]);let j=Q.useMemo(()=>{if(e.summaryFields&&e.summaryFields.length>0)return[];let t=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]],n={};for(let e of t)n[e.name]||(n[e.name]=e);if(T?.fields)for(let[e,t]of Object.entries(T.fields))n[e]={...n[e]||{},...t,name:e};let r=e=>m?.[e]!==void 0&&m?.[e]!==null&&m?.[e]!==``,i=[],a=[`status`,`stage`,`state`,`phase`].find(e=>n[e]&&r(e))||Object.keys(n).find(e=>n[e]?.type===`select`&&r(e));a&&i.push(a);let o=Object.keys(n).find(e=>(n[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&r(e));o&&!i.includes(o)&&i.push(o);let s=Object.keys(n).find(e=>(n[e]?.type===`date`||n[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&r(e));return s&&!i.includes(s)&&i.push(s),i},[e.summaryFields,e.sections,e.fields,T,m]),M=e.summaryFields&&e.summaryFields.length>0?e.summaryFields:j,N=Q.useCallback(()=>{e.resourceId&&navigator.clipboard.writeText(String(e.resourceId)).then(()=>{k(!0),setTimeout(()=>k(!1),1500)})},[e.resourceId]);Q.useEffect(()=>{let n=!0;if(e.data){h(e.data),_(!1);return}if(t&&e.objectName&&e.resourceId){_(!0),E(null),h(null);let r=e.objectName,i=e.resourceId,a=`${r}-`,o=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]];(t.getObjectSchema?t.getObjectSchema(r).catch(()=>null):Promise.resolve(null)).then(e=>{if(!n)return;E(e);let s=l(e?.fields,o),c=s.length>0?{$expand:s}:void 0,u=c?t.findOne(r,i,c):t.findOne(r,i),d=()=>{let e=String(i),o=e.startsWith(a)?e.slice(a.length):`${a}${e}`;return(c?t.findOne(r,o,c):t.findOne(r,o)).then(e=>{n&&(h(e),_(!1))}).catch(()=>{n&&(h(null),_(!1))})};return u.catch(()=>null).then(e=>{if(n){if(e){h(e),_(!1);return}return d()}})}).catch(e=>{n&&(console.error(`Failed to fetch detail data:`,e),_(!1))})}else e.api&&e.resourceId&&(_(!0),fetch(`${e.api}/${e.resourceId}`).then(e=>e.json()).then(e=>{n&&h(e?.data||e)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{n&&_(!1)}));return()=>{n=!1}},[e.api,e.resourceId,e.objectName,t,e.sections,e.fields]);let P=Q.useCallback(()=>{if(a)a();else if(e.onNavigate){let t=e.backUrl||(e.objectName?`/${e.objectName}`:`/`);e.onNavigate(t,{replace:!0})}else e.backUrl?window.location.href=e.backUrl:window.history.back()},[a,e]),ee=Q.useCallback(()=>{r?r():e.onNavigate&&e.editUrl?e.onNavigate(e.editUrl):e.onNavigate&&e.objectName&&e.resourceId?e.onNavigate(`/${e.objectName}/${e.resourceId}/edit`):e.editUrl&&(window.location.href=e.editUrl)},[r,e]),F=Q.useCallback(()=>{let t=e.deleteConfirmation||A(`detail.deleteConfirmation`);window.confirm(t)&&(i?.(),e.onNavigate&&e.objectName&&e.onNavigate(`/${e.objectName}`,{replace:!0}))},[i,e]),te=Q.useCallback(()=>{navigator.share&&e.objectName&&e.resourceId?navigator.share({title:e.title||A(`detail.details`),text:`${e.objectName} #${e.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`)})},[e]),I=Q.useCallback(()=>{console.log(`Duplicate record:`,m)},[m]),L=Q.useCallback(()=>{console.log(`Export record:`,m)},[m]),R=Q.useCallback(()=>{console.log(`View history for record:`,e.resourceId)},[e]),re=Q.useCallback(()=>{y(!v)},[v]),z=Q.useCallback(()=>{if(b){let e=Object.entries(S);if(e.length>0){let t={...m,...S};h(t),e.forEach(([e,n])=>{c?.(e,n,t)})}C({})}x(!b)},[b,S,m,c]),V=Q.useCallback((e,t)=>{C(n=>({...n,[e]:t}))},[]);Q.useEffect(()=>{if(!e.recordNavigation)return;let t=e.recordNavigation,n=e=>{let n=e.target?.tagName;n===`INPUT`||n===`TEXTAREA`||e.target?.isContentEditable||(e.key===`ArrowLeft`&&t.currentIndex>0?(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex-1])):e.key===`ArrowRight`&&t.currentIndex<t.recordIds.length-1&&(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex+1])))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e.recordNavigation]);let H=Q.useMemo(()=>{if(!e.autoDiscoverRelated||!T?.fields||e.related&&e.related.length>0)return[];let t=[],n=T.fields;for(let[e,r]of Object.entries(n)){let n=r?.reference_to||r?.reference;r&&(r.type===`lookup`||r.type===`master_detail`)&&n&&t.push({title:r.label||e.charAt(0).toUpperCase()+e.slice(1),type:`table`,objectName:n,referenceField:e})}return t},[e.autoDiscoverRelated,e.related,T]),U=Q.useMemo(()=>e.related&&e.related.length>0?e.related:H.map(e=>({title:e.title,type:e.type,api:e.objectName,data:[],referenceField:e.referenceField})),[e.related,H]),W=Q.useMemo(()=>{let t=[];t.push({name:`sys_share`,label:A(`detail.share`),icon:`share-2`,type:`script`,onClick:te}),e.showEdit&&t.push({name:`sys_edit_mobile`,label:A(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:ee}),o&&t.push({name:`sys_toggle_inline_edit_mobile`,label:A(b?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:z});let n=t.length>0?[`separator-before`]:void 0;return t.push({name:`sys_duplicate`,label:A(`detail.duplicate`),icon:`copy`,type:`script`,...n&&{tags:n},onClick:I}),t.push({name:`sys_export`,label:A(`detail.export`),icon:`download`,type:`script`,onClick:L}),t.push({name:`sys_view_history`,label:A(`detail.viewHistory`),icon:`history`,type:`script`,onClick:R}),e.showDelete&&t.push({name:`sys_delete`,label:A(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:F}),t},[A,e.showEdit,e.showDelete,o,b,te,ee,z,I,L,R,F]),ie=Q.useMemo(()=>{let t=e.actions??[];if(W.length===0)return t;let n=!1,r=t.map(e=>{let t=e;if(t&&typeof t==`object`&&t.type===`action:bar`&&(!t.location||t.location===`record_header`)){n=!0;let e=Array.isArray(t.systemActions)?t.systemActions:[];return{...t,systemActions:[...e,...W]}}return e});return n||r.push({type:`action:bar`,location:`record_header`,systemActions:W}),r},[e.actions,W]);return g||e.loading?(0,$.jsxs)(`div`,{className:B(`space-y-4`,n),children:[(0,$.jsx)(G,{className:`h-10 w-full`}),(0,$.jsx)(G,{className:`h-64 w-full`}),(0,$.jsx)(G,{className:`h-48 w-full`})]}):!m&&!e.data?(0,$.jsxs)(`div`,{className:B(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold`,children:A(`detail.recordNotFound`)}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:A(`detail.recordNotFoundDescription`)}),(e.showBack??!0)&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:P,className:`mt-4 gap-2`,children:[(0,$.jsx)(Ce,{className:`h-4 w-4`}),A(`detail.goBack`)]})]}):(0,$.jsx)(oe,{children:(0,$.jsxs)(`div`,{className:B(`space-y-6`,n),children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(e.showBack??!0)&&(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,onClick:P,className:`shrink-0 mt-1`,children:(0,$.jsx)(Ce,{className:`h-4 w-4`})})}),(0,$.jsx)(O,{children:A(`detail.back`)})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,$.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:cn(m,e,T,A(`detail.details`))}),M.map(t=>{let n=m?.[t];if(n==null||n===``)return null;let r=(e.sections||[]).flatMap(e=>e.fields).concat(e.fields||[]).find(e=>e.name===t),i=T?.fields?.[t],a=r?.type||i?.type,o=String(n),s=null;try{if(a===`currency`){let e=Number(n);Number.isNaN(e)||(o=new Intl.NumberFormat(void 0,{style:`currency`,currency:r?.currency||i?.currency||`USD`,maximumFractionDigits:0}).format(e))}else if(a===`date`||a===`datetime`){let e=new Date(n);Number.isNaN(e.getTime())||(o=a===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(a===`percent`){let e=Number(n);if(!Number.isNaN(e)){o=`${e}%`;let t=e<=1?e*100:e;s=Math.max(0,Math.min(100,t))}}}catch{}return s===null?(0,$.jsx)(ve,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${t}: ${o}`,children:o},t):(0,$.jsxs)(ve,{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":`${t}: ${o}`,children:[(0,$.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,$.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${s}%`}})}),o]},t)}),(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:re,"aria-label":A(v?`detail.removeFromFavorites`:`detail.addToFavorites`),children:v?(0,$.jsx)(je,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,$.jsx)(ge,{className:`h-4 w-4 text-muted-foreground`})})}),(0,$.jsx)(O,{children:A(v?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),e.objectName&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:f||e.objectName}),e.resourceId&&(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:N,"aria-label":A(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:D?(0,$.jsx)(Ge,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(Ve,{className:`h-3 w-3`})})}),(0,$.jsx)(O,{children:D?A(`detail.copied`,{defaultValue:`Copied`}):A(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[e.recordNavigation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex<=0,onClick:()=>{let t=e.recordNavigation;t.currentIndex>0&&t.onNavigate(t.recordIds[t.currentIndex-1])},children:(0,$.jsx)(w,{className:`h-4 w-4`})})}),(0,$.jsx)(O,{children:A(`detail.previousRecord`)})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:A(`detail.recordOf`,{current:e.recordNavigation.currentIndex+1,total:e.recordNavigation.recordIds.length})}),(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex>=e.recordNavigation.recordIds.length-1,onClick:()=>{let t=e.recordNavigation;t.currentIndex<t.recordIds.length-1&&t.onNavigate(t.recordIds[t.currentIndex+1])},children:(0,$.jsx)(pe,{className:`h-4 w-4`})})}),(0,$.jsx)(O,{children:A(`detail.nextRecord`)})]})]}),ie.map((e,t)=>(0,$.jsx)(s,{schema:e,data:m},t)),o&&(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:b?`default`:`outline`,size:`sm`,onClick:z,className:`gap-2 hidden sm:inline-flex`,children:b?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ge,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:A(`detail.save`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(me,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:A(`detail.editInline`)})]})})}),(0,$.jsx)(O,{children:A(b?`detail.saveChanges`:`detail.editFieldsInline`)})]}),e.showEdit&&(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`default`,onClick:ee,className:`gap-2 hidden sm:inline-flex`,children:[(0,$.jsx)(me,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:A(`detail.edit`)})]})}),(0,$.jsx)(O,{children:A(`detail.editRecord`)})]})]})]}),e.header&&(0,$.jsx)(`div`,{children:(0,$.jsx)(s,{schema:e.header,data:m})}),e.highlightFields&&e.highlightFields.length>0&&(0,$.jsx)(Zt,{fields:e.highlightFields,data:m,objectName:e.objectName,objectSchema:T}),e.autoTabs&&!e.tabs?.length?(()=>{let n=U.length>0,r=!!e.activities&&e.activities.length>0,i=!!u,a=(0,$.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[e.sectionGroups&&e.sectionGroups.length>0&&e.sectionGroups.map((t,n)=>(0,$.jsx)(Xt,{group:t,data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V},n)),e.sections&&e.sections.length>0&&e.sections.map((t,n)=>(0,$.jsx)(Kt,{section:t,data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V},n)),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,$.jsx)(Kt,{section:{fields:e.fields,columns:e.columns},data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V}),e.comments&&(0,$.jsx)($t,{comments:e.comments,onAddComment:e.onAddComment})]});return!n&&!r&&!i?(0,$.jsx)(`div`,{className:`mt-2`,children:a}):(0,$.jsxs)(Be,{defaultValue:`details`,className:`w-full`,children:[(0,$.jsxs)(Ae,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,$.jsx)(_e,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:A(`detail.details`)}),n&&(0,$.jsx)(_e,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[A(`detail.related`),(0,$.jsx)(ve,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:U.length})]})}),r&&(0,$.jsx)(_e,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[A(`detail.activity`),(0,$.jsx)(ve,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:e.activities.length})]})}),i&&(0,$.jsx)(_e,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:A(`detail.discussion`,{defaultValue:`Discussion`})})]}),(0,$.jsx)(Me,{value:`details`,className:`mt-4`,children:a}),n&&(0,$.jsx)(Me,{value:`related`,className:`mt-4`,children:(0,$.jsx)(`div`,{className:`space-y-3`,children:U.map((e,n)=>(0,$.jsx)(Yt,{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,collapsible:!0,pageSize:sn},n))})}),r&&(0,$.jsx)(Me,{value:`activity`,className:`mt-4`,children:(0,$.jsx)(on,{activities:e.activities})}),i&&(0,$.jsx)(Me,{value:`discussion`,className:`mt-4`,children:u})]})})():(0,$.jsxs)($.Fragment,{children:[e.sectionGroups&&e.sectionGroups.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sectionGroups.map((t,n)=>(0,$.jsx)(Xt,{group:t,data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V},n))}),e.sections&&e.sections.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((t,n)=>(0,$.jsx)(Kt,{section:t,data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V},n))}),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,$.jsx)(Kt,{section:{fields:e.fields,columns:e.columns},data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V}),e.tabs&&e.tabs.length>0&&(0,$.jsx)(qt,{tabs:e.tabs,data:m}),U.length>0&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:A(`detail.related`)}),U.map((e,n)=>(0,$.jsx)(Yt,{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,collapsible:!0,pageSize:sn},n))]}),e.comments&&(0,$.jsx)($t,{comments:e.comments,onAddComment:e.onAddComment}),e.activities&&e.activities.length>0&&(0,$.jsx)(on,{activities:e.activities})]}),e.footer&&(0,$.jsx)(`div`,{children:(0,$.jsx)(s,{schema:e.footer,data:m})})]})})},un=({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,$.jsxs)(`div`,{className:B(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,$.jsx)(Qe,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`text-foreground`,children:i})]})},dn=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],fn=({reactions:e,onToggleReaction:t,emojiOptions:n=dn,className:r})=>{let[i,a]=Q.useState(!1),o=Q.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,$.jsxs)(`div`,{className:B(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:B(`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,$.jsx)(`span`,{children:e.emoji}),(0,$.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,$.jsx)(ot,{className:`h-3.5 w-3.5`})}),i&&(0,$.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,$.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 pn(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 mn=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=Wt(),[o,s]=Q.useState(!1),[c,l]=Q.useState(``),[u,d]=Q.useState(!1),f=Q.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=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,$.jsxs)(`div`,{className:B(`ml-10 mt-1`,i),children:[t.length>0&&(0,$.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,$.jsx)(Je,{className:`h-3 w-3`}):(0,$.jsx)(pe,{className:`h-3 w-3`}),(0,$.jsx)(ft,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,$.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,$.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,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:pn(e.createdAt)})]}),(0,$.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,$.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,$.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,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,$.jsx)(R,{className:`h-3 w-3`})})]})]})},hn=({subscription:e,onToggle:t,className:n})=>{let{t:r}=Wt(),[i,a]=Q.useState(!1),o=Q.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:B(`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,$.jsx)(k,{className:`h-4 w-4 text-primary`}):(0,$.jsx)(N,{className:`h-4 w-4 text-muted-foreground`})})},gn={comment:ft,field_change:me,task:P,event:Re,system:pt,email:q,call:V},_n={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 vn(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 yn(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 bn(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 xn=({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,className:p})=>{let{t:m}=Wt(),[h,g]=Q.useState(`all`),[_,v]=Q.useState(``),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),C=n??h,w=t?.showFilterToggle!==!1,T=t?.showCommentInput!==!1&&!!s,D=t?.enableReactions??!1,O=t?.enableThreading??!1,k=t?.showSubscriptionToggle??!1,A=Q.useMemo(()=>bn(e,C),[e,C]),j=Q.useMemo(()=>O?A.filter(e=>!e.parentId):A,[A,O]),N=Q.useMemo(()=>{if(!O)return new Map;let e=new Map;for(let t of A)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[A,O]),P=Q.useCallback(e=>{r?r(e):g(e)},[r]),ee=Q.useCallback(async()=>{let e=_.trim();if(!(!e||!s)){b(!0);try{await s(e),v(``)}finally{b(!1)}}},[_,s]),F=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),ee())},[ee]),te=Q.useCallback(async()=>{if(a){S(!0);try{await a()}finally{S(!1)}}},[a]);return(0,$.jsxs)(E,{className:B(``,p),children:[(0,$.jsx)(He,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(Xe,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(re,{className:`h-4 w-4`}),m(`detail.activity`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,A.length,`)`]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:k&&u&&(0,$.jsx)(hn,{subscription:u,onToggle:d})})]})}),(0,$.jsxs)(Y,{className:`space-y-4`,children:[w&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2.5 py-1.5 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:C,onChange:e=>P(e.target.value),"aria-label":m(`detail.filterActivity`),children:vn(m).map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),T&&(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.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:m(`detail.leaveCommentPlaceholder`),value:_,onChange:e=>v(e.target.value),onKeyDown:F,disabled:y}),(0,$.jsx)(Z,{size:`icon`,variant:`default`,onClick:ee,disabled:!_.trim()||y,className:`shrink-0 self-end`,"aria-label":m(`detail.submitComment`),children:(0,$.jsx)(ft,{className:`h-4 w-4`})})]}),A.length===0?f?null:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:m(`detail.noActivity`)}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:j.map(e=>{let t=gn[e.type]||pt,n=_n[e.type]||`bg-gray-100 text-gray-600`,r=N.get(e.id)??[];return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:B(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m(`detail.via`,{source:e.source})}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:yn(e.createdAt)}),e.edited&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:m(`detail.edited`)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,m(`detail.pinned`)]})]}),e.body&&(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.type===`field_change`&&e.fieldChanges&&(0,$.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,$.jsx)(un,{change:e},t))}),D&&e.reactions&&e.reactions.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(fn,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),D&&(!e.reactions||e.reactions.length===0)&&l&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(fn,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),O&&(e.replyCount??0)>0&&(0,$.jsx)(mn,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,$.jsx)(`div`,{className:`text-center pt-2`,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:te,disabled:x,"aria-label":m(`detail.loadMore`),children:[x?(0,$.jsx)(M,{className:`h-4 w-4 animate-spin mr-1`}):(0,$.jsx)(Je,{className:`h-4 w-4 mr-1`}),m(`detail.loadMore`)]})})]})]})},Sn=({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,className:p})=>{let m=e?.position??`right`,h=e?.width??`360px`,g=e?.collapsible??!0,_=f&&t.length===0||(e?.defaultCollapsed??!1),{t:v}=Wt(),[y,b]=Q.useState(_);return m===`right`||m===`left`?y&&g?(0,$.jsx)(`div`,{className:B(`flex items-start pt-4`,m===`right`?`border-l`:`border-r`,p),children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>b(!1),"aria-label":v(`detail.openDiscussion`),children:(0,$.jsx)(lt,{className:`h-4 w-4`})})}):(0,$.jsxs)(`div`,{className:B(`flex flex-col overflow-hidden`,m===`right`?`border-l`:`border-r`,p),style:{width:h,minWidth:h},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ft,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:v(`detail.discussion`)})]}),g&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>b(!0),"aria-label":v(`detail.closeDiscussion`),children:(0,$.jsx)(ae,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,$.jsx)(xn,{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,className:`border-0 shadow-none`})})]}):(0,$.jsx)(`div`,{className:B(``,p),children:g&&y?(0,$.jsxs)(Z,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>b(!1),"aria-label":v(`detail.showDiscussion`,{count:t.length}),children:[(0,$.jsx)(ft,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:v(`detail.showDiscussion`,{count:t.length})})]}):(0,$.jsxs)(`div`,{children:[g&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(ft,{className:`h-4 w-4`}),v(`detail.discussion`)]}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>b(!0),"aria-label":v(`detail.hideDiscussion`),children:(0,$.jsx)(ct,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(xn,{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})]})})};c.register(`detail-view`,ln,{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`,Kt,{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`,Yt,{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`,ln,{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`}]});function Cn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function wn(e){return e?fe(e):null}function Tn(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var En=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],Dn=(0,Q.forwardRef)(({schema:e,className:t,dataSource:n,onRefresh:r,recordCount:i,userActions:a,designMode:o,selectedWidgetId:c,onWidgetClick:l,modalHandler:u,scriptHandlers:d,...f},p)=>{let m=(()=>{if(e.columns!=null)return e.columns;let t=e.widgets??[],n=0;for(let e of t){let t=(e.layout?.x??0)+(e.layout?.w??0);t>n&&(n=t),(e.layout?.w??0)>n&&(n=e.layout.w)}return n>4?12:4})(),h=m,_=e.gap||4,[v,y]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),C=(0,Q.useRef)(null),{executeAction:w,engine:T}=g({actions:(0,Q.useMemo)(()=>(e.header?.actions??[]).map(e=>({name:e.actionUrl||e.label,type:e.actionType||`url`,target:e.actionUrl,label:e.label})),[e.header?.actions])}),{dashboardLabel:D,dashboardDescription:O,dashboardActionLabel:k,widgetTitle:A,widgetDescription:j,fieldLabel:M}=b(),N=e.name,P=(0,Q.useCallback)(e=>N?k(N,e.actionUrl||e.label,e.label):e.label,[N,k]),ee=(0,Q.useCallback)(e=>{let t=Tn(e.title);return!N||!e.id||t===void 0?t:A(N,e.id,t)},[N,A]),F=(0,Q.useCallback)(e=>{let t=Tn(e.description);return!N||!e.id?t:j(N,e.id,t)},[N,j]);(0,Q.useEffect)(()=>{let e=T.getRunner();if(u&&e.setModalHandler(u),d)for(let[t,n]of Object.entries(d))e.registerScript(t,n)},[T,u,d]),(0,Q.useEffect)(()=>{let e=()=>S(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let te=(0,Q.useCallback)(()=>{r&&(y(!0),r(),setTimeout(()=>y(!1),600))},[r]);(0,Q.useEffect)(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!r))return C.current=setInterval(te,e.refreshInterval*1e3),()=>{C.current&&clearInterval(C.current)}},[e.refreshInterval,r,te]);let ne=(0,Q.useCallback)((e,t)=>{!o||!l||!t||(e.stopPropagation(),l(t))},[o,l]),I=(0,Q.useCallback)((t,n,r)=>{if(!o||!l)return;let i=e.widgets||[];if(t.key===`Enter`||t.key===` `)t.preventDefault(),l(n??null);else if(t.key===`ArrowRight`||t.key===`ArrowDown`){t.preventDefault();let e=r+1<i.length?i[r+1]:null;e?.id&&l(e.id)}else if(t.key===`ArrowLeft`||t.key===`ArrowUp`){t.preventDefault();let e=r-1>=0?i[r-1]:null;e?.id&&l(e.id)}else t.key===`Escape`&&(t.preventDefault(),l(null))},[o,l,e.widgets]),L=(0,Q.useCallback)(e=>{!o||!l||e.target===e.currentTarget&&l(null)},[o,l]),R=(e,t,r)=>{let i=e.layout?{...e.layout,w:Math.min(e.layout.w,h)}:void 0,a=(()=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`metric`&&e.object){let t=n.data,r=Cn(t)&&t.aggregate?{field:e.valueField||t.aggregate.field,function:e.aggregate||t.aggregate.function,groupBy:e.categoryField??t.aggregate.groupBy??`_all`}:e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object||(Cn(t)?t.object:void 0),aggregate:r,filter:(Cn(t)?t.filter:void 0)||e.filter,label:n.label||ee(e)||``,fallbackValue:n.value,trend:n.trend,icon:n.icon,description:n.description,colorVariant:e.colorVariant}}if((t===`gauge`||t===`solid-gauge`)&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object,aggregate:t,filter:e.filter,label:n.label||ee(e)||``,fallbackValue:n.fallbackValue??n.value,icon:n.icon,description:n.description}}let r={funnel:`bar`,"horizontal-bar":`bar`}[t]||t;if(r===`bar`||r===`line`||r===`area`||r===`pie`||r===`donut`||r===`scatter`){let t=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(Cn(t)){let n=t.aggregate,o=n?{field:e.valueField||n.field,function:e.aggregate||n.function,groupBy:e.categoryField||n.groupBy}:void 0,s=o?.field||a,c=e.object||t.object;return{type:`object-chart`,chartType:r,objectName:c,aggregate:o,xAxisKey:i,series:[{dataKey:s,label:c?M(c,s,s):s}],colors:En,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(!t&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0,n=e.valueField||`value`;return{type:`object-chart`,chartType:r,objectName:e.object,aggregate:t,xAxisKey:i,series:[{dataKey:n,label:M(e.object,n,n)}],colors:En,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}return{type:`chart`,chartType:r,data:Array.isArray(t)?t:t?.items||[],xAxisKey:i,series:[{dataKey:a,label:e.object?M(e.object,a,a):a}],colors:En,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(t===`table`){let t=e.data||n.data;if(Cn(t)){let{data:r,...i}=n;return{type:`object-data-table`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data;if(Cn(t)){let{data:r,...i}=n;return{type:`object-pivot`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter}}return!t&&e.object?{type:`object-pivot`,...n,objectName:e.object,filter:e.filter}:{type:`pivot`,...n,data:Array.isArray(t)?t:t?.items||[]}}return{...e,...n}})(),l=e.type===`metric`,u=ee(e),d=F(e),f=e.id||u||`widget-${t}`,p=o&&c===e.id,m=o?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":p,"aria-label":`Widget: ${u||`Widget ${t+1}`}`,onClick:t=>ne(t,e.id),onKeyDown:n=>I(n,e.id,t)}:{},g=o?B(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,p?`ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10`:`hover:ring-2 hover:ring-primary/40 hover:shadow-sm`):void 0;return l?(0,$.jsxs)(`div`,{className:B(`h-full w-full`,o&&`relative`,g),style:!x&&i?{gridColumn:`span ${i.w}`,gridRow:`span ${i.h}`}:void 0,...m,children:[(0,$.jsx)(s,{schema:a,className:B(`h-full w-full`,o&&`pointer-events-none`),dataSource:n}),o&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]},f):(0,$.jsxs)(E,{className:B(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,r&&`w-full`,o&&`relative`,g),style:!x&&i?{gridColumn:`span ${i.w}`,gridRow:`span ${i.h}`}:void 0,...m,children:[u&&(0,$.jsxs)(He,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,$.jsx)(Xe,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:u,children:u}),d&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:d})]}),(0,$.jsx)(Y,{className:`p-0`,children:(0,$.jsx)(`div`,{className:B(`h-full w-full`,`p-3 sm:p-4 md:p-6`,o&&`pointer-events-none`),children:(0,$.jsx)(s,{schema:a,dataSource:n})})}),o&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]},f)},re=e.header&&(0,$.jsxs)(`div`,{className:`col-span-full mb-4`,children:[e.header.showTitle!==!1&&e.title&&(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:N?D({name:N,label:Tn(e.title)}):Tn(e.title)}),e.header.showDescription!==!1&&e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:N?O({name:N,description:Tn(e.description)}):Tn(e.description)}),e.header.actions&&e.header.actions.length>0&&(0,$.jsx)(`div`,{className:`flex gap-2 mt-3`,children:e.header.actions.map((e,t)=>{let n=wn(e.icon);return(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:async()=>{let{actionType:t,actionUrl:n,label:r}=e;if(!t||!n){console.warn(`[DashboardRenderer] Header action missing actionType/actionUrl:`,e);return}if(t===`url`){/^https?:\/\//.test(n)||n.startsWith(`//`)?window.location.assign(n):(window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)));return}if(t===`modal`||t===`script`){let e=await w(n||r);e?.success||console.warn(`[DashboardRenderer] action failed`,e?.error);return}console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`)},children:[n&&(0,$.jsx)(n,{className:`w-4 h-4 mr-1.5`}),P(e)]},t)})})]}),z=i!==void 0&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.toLocaleString(),` records`]}),V=a?JSON.stringify(a):void 0,H=r&&(0,$.jsxs)(`div`,{className:B(`flex items-center justify-end gap-3 mb-2`,!x&&`col-span-full`),children:[z,(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:te,disabled:v,"aria-label":`Refresh dashboard`,children:[(0,$.jsx)(Ue,{className:B(`h-4 w-4 mr-2`,v&&`animate-spin`)}),v?`Refreshing…`:`Refresh All`]})]});if(x){let n=e.widgets?.filter(e=>e.type===`metric`)||[],r=e.widgets?.filter(e=>e.type!==`metric`)||[];return(0,$.jsxs)(`div`,{ref:p,className:B(`flex flex-col gap-4 px-4`,t),"data-user-actions":V,onClick:L,...f,children:[re,H,n.length>0&&(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:L,children:n.map((e,t)=>R(e,t))}),r.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:L,children:r.map((e,t)=>R(e,t,!0))})]})}let U=e.columns!=null||m!==4;return(0,$.jsxs)(`div`,{ref:p,className:B(`grid auto-rows-min`,!U&&`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,t),style:{...U&&{gridTemplateColumns:`repeat(${h}, minmax(0, 1fr))`},gap:`${_*.25}rem`},"data-user-actions":V,onClick:L,...f,children:[re,H,e.widgets?.map((e,t)=>R(e,t))]})});function On(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function kn(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function An(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=On(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=kn(r,u,s[0]),f=kn(i,l,s[1])),a?(p=Math.round(a.top),m=Math.round(a.left)):o?(p=Math.round(o.top),m=Math.round(o.left)):(p=Math.round((l+s[1])*n+c[1]),m=Math.round((u+s[0])*t+c[0])),!a&&!o){if(Number.isFinite(r)){let e=Math.round((u+s[0])*(t+r)+c[0])-m-d;e!==s[0]&&(d+=e-s[0])}if(Number.isFinite(i)){let e=Math.round((l+s[1])*(n+i)+c[1])-p-f;e!==s[1]&&(f+=e-s[1])}}return{top:p,left:m,width:d,height:f}}function jn(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=On(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=Pn(d,0,s-r),f=Pn(f,0,l-i),{x:d,y:f}}function Mn(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=On(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function Nn(e,t,n){let{margin:r,rowHeight:i}=e,a=On(e);return{w:Math.max(1,Math.round((t+r[0])/(a+r[0]))),h:Math.max(1,Math.round((n+r[1])/(i+r[1])))}}function Pn(e,t,n){return Math.max(Math.min(e,n),t)}function Fn(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function In(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&Fn(r,t))return r}}function Ln(e,t){return e.filter(e=>Fn(e,t))}function Rn(e,t){return t===`horizontal`?Bn(e):t===`vertical`||t===`wrap`?zn(e):[...e]}function zn(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function Bn(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function Vn(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=r.y+r.h;e>t&&(t=e)}}return t}function Hn(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&r.i===t)return r}}function Un(e){return e.filter(e=>e.static===!0)}function Wn(e){return{i:e.i,x:e.x,y:e.y,w:e.w,h:e.h,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,constraints:e.constraints,isBounded:e.isBounded}}function Gn(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t[n]=Wn(r))}return t}function Kn(e,t){let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];i!==void 0&&(t.i===i.i?n[r]=t:n[r]=i)}return n}function qn(e,t,n){let r=Hn(e,t);return r?(r=n(Wn(r)),[Kn(e,r),r]):[[...e],null]}function Jn(e,t){let n=Un(e);for(let r=0;r<e.length;r++){let i=e[r];if(i!==void 0)if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;In(n,i);)i.y++}return e}function Yn(e,t,n,r,i,a,o,s,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return[...e];let l=t.x,u=t.y;typeof n==`number`&&(t.x=n),typeof r==`number`&&(t.y=r),t.moved=!0;let d=Rn(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=Ln(d,t),p=f.length>0;if(p&&c)return Gn(e);if(p&&a)return t.x=l,t.y=u,t.moved=!1,e;let m=[...e];for(let e=0;e<f.length;e++){let n=f[e];n!==void 0&&(n.moved||(m=n.static?Xn(m,n,t,i,o):Xn(m,t,n,i,o)))}return m}function Xn(e,t,n,r,i,a){let o=i===`horizontal`,s=i===`vertical`,c=t.static;if(r){r=!1;let a={x:o?Math.max(t.x-n.w,0):n.x,y:s?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:`-1`},l=In(e,a),u=l!==void 0&&l.y+l.h>t.y,d=l!==void 0&&t.x+t.w>l.x;if(!l)return Yn(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return Yn(e,n,void 0,n.y+1,r,c,i);if(u&&i===null)return t.y=n.y,n.y+=n.h,[...e];if(d&&o)return Yn(e,t,n.x,void 0,r,c,i)}let l=o?n.x+1:void 0,u=s?n.y+1:void 0;return l===void 0&&u===void 0?[...e]:Yn(e,n,l,u,r,c,i)}function Zn(e,t,n){return Math.max(t,Math.min(n,e))}var Qn=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:Zn(t,0,Math.max(0,r-e.w)),y:Zn(n,0,Math.max(0,i-e.h))}},constrainSize(e,t,n,r,{cols:i,maxRows:a}){let o=r===`w`||r===`nw`||r===`sw`?e.x+e.w:i-e.x,s=r===`n`||r===`nw`||r===`ne`?e.y+e.h:a-e.y;return{w:Zn(t,1,Math.max(1,o)),h:Zn(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:Zn(t,e.minW??1,e.maxW??1/0),h:Zn(n,e.minH??1,e.maxH??1/0)}}}];function $n(e,t,n,r,i){let a={x:n,y:r};for(let n of e)n.constrainPosition&&(a=n.constrainPosition(t,a.x,a.y,i));if(t.constraints)for(let e of t.constraints)e.constrainPosition&&(a=e.constrainPosition(t,a.x,a.y,i));return a}function er(e,t,n,r,i,a){let o={w:n,h:r};for(let n of e)n.constrainSize&&(o=n.constrainSize(t,o.w,o.h,i,a));if(t.constraints)for(let e of t.constraints)e.constrainSize&&(o=e.constrainSize(t,o.w,o.h,i,a));return o}function tr({top:e,left:t,width:n,height:r}){let i=`translate(${t}px,${e}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${n}px`,height:`${r}px`,position:`absolute`}}function nr({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function rr(e){return e*100+`%`}function ir(e,t,n,r){return e+n>r?t:n}function ar(e,t,n){return e<0?t:n}function or(e){return Math.max(0,e)}function sr(e){return Math.max(0,e)}var cr=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:ar(o,e.height,i),top:sr(o)}},lr=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:ir(e.left,e.width,o,n),left:or(i)}},ur=(e,t,n)=>{let{top:r,height:i,width:a}=t,o=e.left+e.width-a;return o<0?{height:i,width:e.left+e.width,top:sr(r),left:0}:{height:i,width:a,top:sr(r),left:o}},dr=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:ar(r,e.height,a),top:sr(r)}},fr={n:cr,ne:(e,t,n)=>cr(e,lr(e,t,n)),e:lr,se:(e,t,n)=>dr(e,lr(e,t,n)),s:dr,sw:(e,t,n)=>dr(e,ur(e,t)),w:ur,nw:(e,t,n)=>cr(e,ur(e,t))};function pr(e,t,n,r){let i=fr[e];return i?i(t,{...t,...n},r):n}var mr={type:`transform`,scale:1,calcStyle(e){return tr(e)}},hr={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},gr={enabled:!0,bounded:!1,threshold:3},_r={enabled:!0,handles:[`se`]},vr={enabled:!1,defaultItem:{w:1,h:1}};function yr(e,t,n,r,i){let a=r===`x`?`w`:`h`;t[r]+=1;let o=e.findIndex(e=>e.i===t.i),s=i??Un(e).length>0;for(let i=o+1;i<e.length;i++){let o=e[i];if(o!==void 0&&!o.static){if(!s&&o.y>t.y+t.h)break;Fn(t,o)&&yr(e,o,n+t[a],r,s)}}t[r]=n}function br(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0),t.y=Math.min(r,t.y);t.y>0&&!In(e,t);)t.y--;let i;for(;(i=In(e,t))!==void 0;)yr(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function xr(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!In(e,t);)t.x--;let i;for(;(i=In(e,t))!==void 0;)if(yr(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!In(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var Sr={type:`vertical`,allowOverlap:!1,compact(e,t){let n=Un(e),r=Vn(n),i=zn(e),a=Array(e.length);for(let t=0;t<i.length;t++){let o=i[t];if(o===void 0)continue;let s=Wn(o);s.static||(s=br(n,s,i,r),r=Math.max(r,s.y+s.h),n.push(s));let c=e.indexOf(o);a[c]=s,s.moved=!1}return a}},Cr={type:`horizontal`,allowOverlap:!1,compact(e,t){let n=Un(e),r=Bn(e),i=Array(e.length);for(let a=0;a<r.length;a++){let o=r[a];if(o===void 0)continue;let s=Wn(o);s.static||(s=xr(n,s,t,r),n.push(s));let c=e.indexOf(o);i[c]=s,s.moved=!1}return i}},wr={type:null,allowOverlap:!1,compact(e,t){return Gn(e)}},Tr={...Sr,allowOverlap:!0,compact(e,t){return Gn(e)}},Er={...Cr,allowOverlap:!0,compact(e,t){return Gn(e)}},Dr={...wr,allowOverlap:!0};function Or(e,t=!1,n=!1){let r;return r=t?e===`vertical`?Tr:e===`horizontal`?Er:Dr:e===`vertical`?Sr:e===`horizontal`?Cr:wr,n?{...r,preventCollision:n}:r}function kr(e){return Object.keys(e).sort((t,n)=>e[t]-e[n])}function Ar(e,t){let n=kr(e),r=n[0];if(r===void 0)throw Error(`No breakpoints defined`);for(let i=1;i<n.length;i++){let a=n[i];a!==void 0&&t>e[a]&&(r=a)}return r}function jr(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function Mr(e,t,n,r,i,a){let o=e[n];if(o)return Gn(o);let s=e[r],c=kr(t),l=c.slice(c.indexOf(n));for(let t=0;t<l.length;t++){let n=l[t];if(n===void 0)continue;let r=e[n];if(r){s=r;break}}let u=Jn(Gn(s||[]),{cols:i});return(typeof a==`object`&&a?a:Or(a)).compact(u,i)}function Nr(e,t){if(Array.isArray(e))return e;let n=e,r=n[t];if(r!==void 0)return r;let i=Object.keys(n);for(let e of i){let t=n[e];if(t!==void 0)return t}return[10,10]}var Pr=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n[`fast-equals`]={}))})(e,(function(e){function t(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function n(e){return function(t,n,r,i){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r,i);var a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);var s=e(t,n,r,i);return i.delete(t),i.delete(n),s}}function r(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e){return e.constructor===Object||e.constructor==null}function a(e){return typeof e.then==`function`}function o(e,t){return e===t||e!==e&&t!==t}var s=`[object Arguments]`,c=`[object Boolean]`,l=`[object Date]`,u=`[object RegExp]`,d=`[object Map]`,f=`[object Number]`,p=`[object Object]`,m=`[object Set]`,h=`[object String]`,g=Object.prototype.toString;function _(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areMapsEqual,_=e.areObjectsEqual,v=e.areRegExpsEqual,y=e.areSetsEqual,b=e.createIsNestedEqual,x=b(S);function S(e,b,S){if(e===b)return!0;if(!e||!b||typeof e!=`object`||typeof b!=`object`)return e!==e&&b!==b;if(i(e)&&i(b))return _(e,b,x,S);var C=Array.isArray(e),w=Array.isArray(b);if(C||w)return C===w&&t(e,b,x,S);var T=g.call(e);return T===g.call(b)?T===l?n(e,b,x,S):T===u?v(e,b,x,S):T===d?r(e,b,x,S):T===m?y(e,b,x,S):T===p||T===s?a(e)||a(b)?!1:_(e,b,x,S):T===c||T===f||T===h?o(e.valueOf(),b.valueOf()):!1:!1}return S}function v(e,t,n,r){var i=e.length;if(t.length!==i)return!1;for(;i-- >0;)if(!n(e[i],t[i],i,i,e,t,r))return!1;return!0}var y=n(v);function b(e,t){return o(e.valueOf(),t.valueOf())}function x(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={},o=0;return e.forEach(function(s,c){if(i){var l=!1,u=0;t.forEach(function(i,d){!l&&!a[u]&&(l=n(c,d,o,u,e,t,r)&&n(s,i,c,d,e,t,r))&&(a[u]=!0),u++}),o++,i=l}}),i}var S=n(x),C=`_owner`,w=Object.prototype.hasOwnProperty;function T(e,t,n,r){var i=Object.keys(e),a=i.length;if(Object.keys(t).length!==a)return!1;for(var o;a-- >0;){if(o=i[a],o===C){var s=!!e.$$typeof,c=!!t.$$typeof;if((s||c)&&s!==c)return!1}if(!w.call(t,o)||!n(e[o],t[o],o,o,e,t,r))return!1}return!0}var E=n(T);function D(e,t){return e.source===t.source&&e.flags===t.flags}function O(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={};return e.forEach(function(o,s){if(i){var c=!1,l=0;t.forEach(function(i,u){!c&&!a[l]&&(c=n(o,i,s,u,e,t,r))&&(a[l]=!0),l++}),i=c}}),i}var k=n(O),A=Object.freeze({areArraysEqual:v,areDatesEqual:b,areMapsEqual:x,areObjectsEqual:T,areRegExpsEqual:D,areSetsEqual:O,createIsNestedEqual:t}),j=Object.freeze({areArraysEqual:y,areDatesEqual:b,areMapsEqual:S,areObjectsEqual:E,areRegExpsEqual:D,areSetsEqual:k,createIsNestedEqual:t}),M=_(A);function N(e,t){return M(e,t,void 0)}var P=_(r(A,{createIsNestedEqual:function(){return o}}));function ee(e,t){return P(e,t,void 0)}var F=_(j);function te(e,t){return F(e,t,new WeakMap)}var ne=_(r(j,{createIsNestedEqual:function(){return o}}));function I(e,t){return ne(e,t,new WeakMap)}function L(e){return _(r(A,e(A)))}function R(e){var t=_(r(j,e(j)));return(function(e,n,r){return r===void 0&&(r=new WeakMap),t(e,n,r)})}e.circularDeepEqual=te,e.circularShallowEqual=I,e.createCustomCircularEqual=R,e.createCustomEqual=L,e.deepEqual=N,e.sameValueZeroEqual=o,e.shallowEqual=ee,Object.defineProperty(e,`__esModule`,{value:!0})}))}));function Fr(e={}){let{measureBeforeMount:t=!1,initialWidth:n=1280}=e,[r,i]=(0,Q.useState)(n),[a,o]=(0,Q.useState)(!t),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useCallback)(()=>{let e=s.current;if(e){let t=e.offsetWidth;i(t),a||o(!0)}},[a]);return(0,Q.useEffect)(()=>{let e=s.current;if(e){if(l(),typeof ResizeObserver<`u`){let t=null;return c.current=new ResizeObserver(e=>{let n=e[0];if(n){let e=n.contentRect.width;t!==null&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{i(e),t=null})}}),c.current.observe(e),()=>{t!==null&&cancelAnimationFrame(t),c.current&&=(c.current.disconnect(),null)}}return()=>{c.current&&=(c.current.disconnect(),null)}}},[l]),{width:r,mounted:a,containerRef:s,measureWidth:l}}var Ir=n(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Lr=n(((e,t)=>{var n=Ir();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Rr=n(((e,t)=>{t.exports=Lr()()})),zr=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.dontSetMe=a,e.findInArray=t,e.int=i,e.isFunction=n,e.isNum=r;function t(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function n(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function r(e){return typeof e==`number`&&!isNaN(e)}function i(e){return parseInt(e,10)}function a(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}})),Br=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.browserPrefixToKey=r,e.browserPrefixToStyle=i,e.default=void 0,e.getPrefix=n;var t=[`Moz`,`Webkit`,`O`,`ms`];function n(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`transform`;if(typeof window>`u`)return``;let n=window.document?.documentElement?.style;if(!n||e in n)return``;for(let i=0;i<t.length;i++)if(r(e,t[i])in n)return t[i];return``}function r(e,t){return t?`${t}${a(e)}`:e}function i(e,t){return t?`-${t.toLowerCase()}-${e}`:e}function a(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}e.default=n()})),Vr=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.addClassName=S,e.addEvent=s,e.addUserSelectStyles=y,e.createCSSTransform=m,e.createSVGTransform=h,e.getTouch=_,e.getTouchIdentifier=v,e.getTranslation=g,e.innerHeight=d,e.innerWidth=f,e.matchesSelector=a,e.matchesSelectorAndParentsTo=o,e.offsetXYFromParent=p,e.outerHeight=l,e.outerWidth=u,e.removeClassName=C,e.removeEvent=c,e.scheduleRemoveUserSelectStyles=b;var t=zr(),n=r(Br());function r(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,i=new WeakMap;return(r=function(e,t){if(!t&&e&&e.__esModule)return e;var r,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(r=t?i:n){if(r.has(e))return r.get(e);r.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?r(o,t,a):o[t]=e[t]);return o})(e,t)}var i=``;function a(e,n){return i||=(0,t.findInArray)([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(n){return(0,t.isFunction)(e[n])}),(0,t.isFunction)(e[i])?e[i](n):!1}function o(e,t,n){let r=e;do{if(a(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function s(e,t,n,r){if(!e)return;let i={capture:!0,...r};e.addEventListener?e.addEventListener(t,n,i):e.attachEvent?e.attachEvent(`on`+t,n):e[`on`+t]=n}function c(e,t,n,r){if(!e)return;let i={capture:!0,...r};e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent?e.detachEvent(`on`+t,n):e[`on`+t]=null}function l(e){let n=e.clientHeight,r=e.ownerDocument.defaultView.getComputedStyle(e);return n+=(0,t.int)(r.borderTopWidth),n+=(0,t.int)(r.borderBottomWidth),n}function u(e){let n=e.clientWidth,r=e.ownerDocument.defaultView.getComputedStyle(e);return n+=(0,t.int)(r.borderLeftWidth),n+=(0,t.int)(r.borderRightWidth),n}function d(e){let n=e.clientHeight,r=e.ownerDocument.defaultView.getComputedStyle(e);return n-=(0,t.int)(r.paddingTop),n-=(0,t.int)(r.paddingBottom),n}function f(e){let n=e.clientWidth,r=e.ownerDocument.defaultView.getComputedStyle(e);return n-=(0,t.int)(r.paddingLeft),n-=(0,t.int)(r.paddingRight),n}function p(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function m(e,t){let r=g(e,t,`px`);return{[(0,n.browserPrefixToKey)(`transform`,n.default)]:r}}function h(e,t){return g(e,t,``)}function g(e,t,n){let{x:r,y:i}=e,a=`translate(${r}${n},${i}${n})`;return t&&(a=`translate(${`${typeof t.x==`string`?t.x:t.x+n}`}, ${`${typeof t.y==`string`?t.y:t.y+n}`})`+a),a}function _(e,n){return e.targetTouches&&(0,t.findInArray)(e.targetTouches,e=>n===e.identifier)||e.changedTouches&&(0,t.findInArray)(e.changedTouches,e=>n===e.identifier)}function v(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function y(e){if(!e)return;let t=e.getElementById(`react-draggable-style-el`);t||(t=e.createElement(`style`),t.type=`text/css`,t.id=`react-draggable-style-el`,t.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
4
4
  `,t.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}