@object-ui/console 3.1.5 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/assets/AdapterProvider-Cd4HYb7q.js +1 -0
- package/dist/assets/AdvancedChartImpl-AY6sVw1n.js +7 -0
- package/dist/assets/AppManagementPage-6l5ZKnv5.js +1 -0
- package/dist/assets/ChartImpl-DiKY5voi.js +1 -0
- package/dist/assets/DashboardView-BnX2k5Kx.js +1 -0
- package/dist/assets/KanbanEnhanced-BKCx2XIr.js +1 -0
- package/dist/assets/KanbanImpl-e9jzV-UD.js +1 -0
- package/dist/assets/MarkdownImpl-B-r7jSIS.js +1 -0
- package/dist/assets/MetadataDetailPage--3o8VI1T.js +1 -0
- package/dist/assets/MetadataFormDialog-Cy7k0Y55.js +1 -0
- package/dist/assets/MetadataInspector-DVtCDQtx.js +1 -0
- package/dist/assets/MetadataManagerPage-CYfvXG6X.js +1 -0
- package/dist/assets/MetadataProvider-Dvc9BxbC.js +1 -0
- package/dist/assets/PageView-CUDEz8Xo.js +2 -0
- package/dist/assets/ProfilePage-B0BXoAus.js +1 -0
- package/dist/assets/RecordDetailView-CYgcTNQp.js +1 -0
- package/dist/assets/ReportView-ovWyjJsZ.js +1 -0
- package/dist/assets/SearchResultsPage-B-NchFoJ.js +1 -0
- package/dist/assets/SystemHubPage-D8S1hN1a.js +1 -0
- package/dist/assets/data-adapter-v22lWuhc.js +39 -0
- package/dist/assets/framework-BW6KsEI0.js +2 -0
- package/dist/assets/getIcon-N5xWCMJy.js +1 -0
- package/dist/assets/index-DATdOX6r.js +59 -0
- package/dist/assets/index-nwlbpqhl.css +2 -0
- package/dist/assets/infrastructure-94fpO8jL.js +3 -0
- package/dist/assets/maplibre-gl-BR3qC6SX.js +748 -0
- package/dist/assets/plugins-core-B5ROGaJH.css +1 -0
- package/dist/assets/plugins-core-Ccvbi6db.js +105 -0
- package/dist/assets/plugins-views-CbLIJkBs.js +62 -0
- package/dist/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
- package/dist/assets/{skeletons-DcGqw3b1.js → skeletons-CIQE_YYE.js} +1 -1
- package/dist/assets/src-BGoL_8qF.js +1 -0
- package/dist/assets/ui-layout-CYz0tyDf.js +3 -0
- package/dist/assets/vendor-charts-D1AP0-EV.js +33 -0
- package/dist/assets/vendor-icons-CrSf7tAH.js +1 -0
- package/dist/assets/vendor-objectstack-Dhrq31KF.js +1 -0
- package/dist/assets/{vendor-react-BwtAzZZ3.js → vendor-react-ryfytPb-.js} +2 -2
- package/dist/assets/vendor-zod-Dfb8LXKF.js +64 -0
- package/dist/index.html +26 -15
- package/package.json +48 -64
- package/plugin.js +2 -2
- package/plugin.ts +2 -2
- package/dist/assets/AddressField-BLYuFwUv.js +0 -1
- package/dist/assets/AdvancedChartImpl-Dvg6YIfN.js +0 -7
- package/dist/assets/AppManagementPage-C5q5QBar.js +0 -1
- package/dist/assets/AuditLogPage-BpLFTD-b.js +0 -1
- package/dist/assets/AuthPageLayout-DDjJTsQ6.js +0 -1
- package/dist/assets/AutoNumberField-DLmi_0fk.js +0 -1
- package/dist/assets/AvatarField-BfoEDA_D.js +0 -1
- package/dist/assets/BooleanField-W3_x7RAZ.js +0 -1
- package/dist/assets/ChartImpl-Cwo6IWnY.js +0 -1
- package/dist/assets/CodeField-BWFqblAU.js +0 -1
- package/dist/assets/ColorField-Y8WM1wXE.js +0 -1
- package/dist/assets/CreateAppPage-A-VfItcx.js +0 -1
- package/dist/assets/CurrencyField-BeuE1bRa.js +0 -1
- package/dist/assets/DashboardDesignPage-N8NL-jkM.js +0 -1
- package/dist/assets/DashboardView-Dy0d2kFj.js +0 -1
- package/dist/assets/DateField-2Lf9jstN.js +0 -1
- package/dist/assets/DateTimeField-BkMuhOZJ.js +0 -1
- package/dist/assets/EditAppPage-B6HL4COW.js +0 -1
- package/dist/assets/EmailField-CP_O7tmo.js +0 -1
- package/dist/assets/FileField-CcczwlRk.js +0 -1
- package/dist/assets/ForgotPasswordPage-Slo6CHvD.js +0 -1
- package/dist/assets/FormulaField-DLdg1ImO.js +0 -1
- package/dist/assets/GeolocationField-DqeMjnyo.js +0 -1
- package/dist/assets/GridField-DaWMYyuc.js +0 -1
- package/dist/assets/ImageField-DAn05d1y.js +0 -1
- package/dist/assets/KanbanEnhanced-Dj7Qccu2.js +0 -1
- package/dist/assets/KanbanImpl-D9BbG_RT.js +0 -1
- package/dist/assets/LocationField-DYHVF_gq.js +0 -1
- package/dist/assets/LoginPage-D2CqpSi0.js +0 -1
- package/dist/assets/LookupField-BF9vCmht.js +0 -1
- package/dist/assets/MarkdownImpl-B0Iew7iJ.js +0 -29
- package/dist/assets/MasterDetailField-Dw4RRQ5W.js +0 -1
- package/dist/assets/NumberField-BKuVHBrN.js +0 -1
- package/dist/assets/ObjectField-z00gmFEc.js +0 -1
- package/dist/assets/OrgManagementPage-BqtqRi_6.js +0 -1
- package/dist/assets/PageDesignPage-BzIL8o0u.js +0 -1
- package/dist/assets/PageView-eCi7zkJr.js +0 -2
- package/dist/assets/PasswordField-B_rXL4g9.js +0 -1
- package/dist/assets/PercentField-Bn_SIbNe.js +0 -1
- package/dist/assets/PermissionManagementPage-BmI-0QXt.js +0 -1
- package/dist/assets/PhoneField-DuheMaUR.js +0 -1
- package/dist/assets/ProfilePage-CUo-xIgl.js +0 -1
- package/dist/assets/QRCodeField-IPS2Rpmi.js +0 -1
- package/dist/assets/RatingField-M6qZlpA4.js +0 -1
- package/dist/assets/RecordDetailView-CFVPmfrM.js +0 -1
- package/dist/assets/RegisterPage-D7PJIabW.js +0 -1
- package/dist/assets/ReportView-DNOPIpWM.js +0 -1
- package/dist/assets/RichTextField-CDGy9V9x.js +0 -1
- package/dist/assets/RoleManagementPage-DwtqyfDW.js +0 -1
- package/dist/assets/SearchResultsPage-BxzOkRnL.js +0 -1
- package/dist/assets/SelectField-F6UDlyvf.js +0 -1
- package/dist/assets/SignatureField-CHN7xBII.js +0 -1
- package/dist/assets/SliderField-BOfEMQyU.js +0 -1
- package/dist/assets/SummaryField-CZ8KzmBZ.js +0 -1
- package/dist/assets/SystemHubPage-RFiJSMgW.js +0 -1
- package/dist/assets/TextAreaField-1E39zZ_x.js +0 -1
- package/dist/assets/TextField-CwuU0Crc.js +0 -1
- package/dist/assets/TimeField-CEWXxhLE.js +0 -1
- package/dist/assets/UrlField-BtUImn9B.js +0 -1
- package/dist/assets/UserField-DSSEoy5L.js +0 -1
- package/dist/assets/UserManagementPage-BBS1vYGa.js +0 -1
- package/dist/assets/VectorField-BjfQeTZT.js +0 -1
- package/dist/assets/data-adapter-wZ81OFjZ.js +0 -39
- package/dist/assets/framework-DJlDX9E6.js +0 -1
- package/dist/assets/index-D9-L0QBO.css +0 -2
- package/dist/assets/index-DDpLaQOV.js +0 -8
- package/dist/assets/infrastructure-C6Ph6Ug0.js +0 -3
- package/dist/assets/maplibre-gl-DsUGuDud.js +0 -756
- package/dist/assets/plugins-core-Cfhp_BXE.css +0 -2
- package/dist/assets/plugins-core-PiAAytWV.js +0 -136
- package/dist/assets/plugins-views-CE0VP3vl.js +0 -62
- package/dist/assets/rolldown-runtime-Dw2cE7zH.js +0 -1
- package/dist/assets/src-oeWLmiqa.js +0 -1
- package/dist/assets/systemObjects-5--4zaiX.js +0 -1
- package/dist/assets/ui-layout-DdDX0gzI.js +0 -3
- package/dist/assets/vendor-charts-Bl5l0H2K.js +0 -3
- package/dist/assets/vendor-objectstack-BtztJIHv.js +0 -1
- package/dist/mockServiceWorker.js +0 -349
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-Dw2cE7zH.js";import{A as n,M as r,N as i,O as a,S as o,b as s,c,h as l,j as u,k as d,p as f,s as p,v as m,w as h}from"./framework-DJlDX9E6.js";import{$c as g,An as _,Bs as v,Bt as y,Cl as b,Co as x,Cs as S,Dc as C,Ec as w,Eo as T,Es as E,Gc as D,Hc as O,Hs as k,Ht as A,Ic as j,Jc as M,Jo as N,Js as ee,Lc as te,Ls as P,Ms as F,Oc as I,On as ne,Os as re,Po as ie,Ps as L,Qs as ae,Rc as oe,Sc as R,Sl as z,So as B,Tc as V,To as H,Ts as U,Ut as W,Vt as se,Ws as ce,Xo as le,Zo as ue,_c as G,_l as K,_t as q,a as de,an as fe,cc as pe,cn as me,dc as he,dl as J,dn as Y,ds as ge,dt as _e,el as ve,es as ye,fl as be,ft as xe,gc as Se,gl as Ce,gt as we,hl as Te,ic as Ee,in as De,it as Oe,jc as ke,jn as Ae,js as je,kn as Me,ks as Ne,ln as Pe,ml as Fe,mn as Ie,ms as Le,mt as Re,nl as ze,oc as Be,on as Ve,ot as He,pl as Ue,pn as We,pt as Ge,qs as Ke,rc as qe,rn as Je,sl as Ye,sn as X,tl as Xe,ts as Ze,ul as Qe,ut as $e,vl as et,vs as tt,vt as nt,wo as rt,ws as it,x as at,xc as ot,xs as st,yl as Z,ys as ct,yt as lt,zc as ut,zs as dt,zt as ft}from"./plugins-core-PiAAytWV.js";import{d as pt,p as mt,u as ht}from"./infrastructure-C6Ph6Ug0.js";var Q=e(i(),1),$=h(),gt={grid:(0,$.jsx)(I,{className:`h-4 w-4`}),kanban:(0,$.jsx)(Se,{className:`h-4 w-4`}),gallery:(0,$.jsx)(R,{className:`h-4 w-4`}),calendar:(0,$.jsx)(Ye,{className:`h-4 w-4`}),timeline:(0,$.jsx)(et,{className:`h-4 w-4`}),gantt:(0,$.jsx)(it,{className:`h-4 w-4`}),map:(0,$.jsx)(Be,{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:Z(`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:Z(`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?ue[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:Z(`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)(N,{variant:`ghost`,size:`sm`,className:Z(`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)(Je,{children:[(0,$.jsx)(fe,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:Z(`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)(Ze,{className:`h-3 w-3 opacity-60`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),u(e.field,[])}}):(0,$.jsx)(Xe,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(De,{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:Z(`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:Z(`flex items-center gap-1 overflow-x-auto`,a),"data-testid":`user-filters-dropdown`,children:[(0,$.jsx)(E,{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)(Je,{children:[(0,$.jsx)(fe,{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)(Xe,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(De,{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:Z(`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:Z(`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)(v,{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:Z(`flex items-center gap-1 overflow-x-auto`,n),"data-testid":`user-filters-toggle`,children:e.map(e=>(0,$.jsx)(N,{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=mt();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}=ht();return{fieldLabel:e}}catch{return{fieldLabel:(e,t,n)=>n}}}var Ft=({schema:e,className:t,onViewChange:r,onFilterChange:i,onSortChange:o,onSearchChange:s,onRowClick:c,showViewSwitcher:d=!1,...p})=>{let{t:h}=Nt(),{fieldLabel:g}=Pt(),_=Q.useMemo(()=>({...e,viewType:e.viewType||`grid`}),[e]),y=Q.useCallback((e,t)=>_.objectName?g(_.objectName,e,t):t,[_.objectName,g]),b=Q.useMemo(()=>{let e=_.userActions,t=_.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?_.showSearch!==!1:e.search,showSort:e?.sort===void 0?_.showSort!==!1:e.sort,showFilters:e?.filter===void 0?_.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?_.showDensity===!0:e.rowHeight,showHideFields:_.showHideFields===!0,showGroup:_.showGroup!==!1,showColor:_.showColor===!0,showAddRecord:t,addRecordPosition:_.addRecord?.position===`bottom`?`bottom`:`top`}},[_.userActions,_.showSearch,_.showSort,_.showFilters,_.showDensity,_.showHideFields,_.showGroup,_.showColor,_.addRecord,_.userActions?.addRecordForm]),[x,S]=Q.useState(_.viewType),[C,T]=Q.useState(``),[D,O]=Q.useState(!1),[k,A]=Q.useState(!1),[M,ee]=Q.useState(()=>_.sort&&_.sort.length>0?_.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`}}):[]),[te,P]=Q.useState(!1),[I,ne]=Q.useState({id:`root`,logic:`and`,conditions:[]}),[ie,L]=Q.useState(()=>{if(!(!_.tabs||_.tabs.length===0))return _.tabs.find(e=>e.isDefault)?.name??_.tabs[0]?.name}),oe=Q.useCallback(e=>{if(L(e.name),e.filter){let t={id:`tab-filter-${e.name}`,logic:e.filter.logic||`and`,conditions:e.filter.conditions||[]};ne(t),i?.(t)}else{let e={id:`root`,logic:`and`,conditions:[]};ne(e),i?.(e)}},[i]),R=p.dataSource,[z,B]=Q.useState([]),[V,H]=Q.useState(!1),[U,W]=Q.useState(null),[se,ce]=Q.useState(!1),[le,G]=Q.useState(0),[K,q]=Q.useState(!1),[pe,me]=Q.useState(void 0),he=pe??_.pagination?.pageSize??100,[J,Y]=Q.useState(_.grouping),[ge,ve]=Q.useState(!1),[ye,be]=Q.useState(_.rowColor),[Se,Ce]=Q.useState(!1),[we,Te]=Q.useState([]),Ee=Q.useRef(0),[Oe,ke]=Q.useState(()=>{let e=new Set;return _.quickFilters?.forEach(t=>{let r=n(t);r.defaultActive&&e.add(r.id)}),e}),[Ae,je]=Q.useState([]),Me=Q.useMemo(()=>{if(_.userFilters)return _.userFilters;if(!U?.fields)return;let e=new Set([`select`,`multi-select`,`boolean`]),t=[],n=Array.isArray(U.fields)?U.fields.map(e=>[e.name,e]):Object.entries(U.fields);for(let[r,i]of n)(e.has(i.type)||i.options&&!i.type)&&t.push({field:r,label:y(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}},[_.userFilters,U]),[Ne,Pe]=Q.useState(()=>new Set(_.hiddenFields||[])),[Fe,Ie]=Q.useState(!1),[Re,ze]=Q.useState(!1),Be=Q.useMemo(()=>u(_.quickFilters),[_.quickFilters]),We=Q.useMemo(()=>{if(_.exportOptions)return Array.isArray(_.exportOptions)?{formats:_.exportOptions}:_.exportOptions},[_.exportOptions]),Ge=f(Q.useMemo(()=>_.densityMode?_.densityMode:_.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[_.rowHeight]||`comfortable`:`compact`,[_.densityMode,_.rowHeight])),{ref:Ke,isRefreshing:qe,pullDistance:Ye}=de({onRefresh:Q.useCallback(async()=>{G(e=>e+1)},[]),enabled:!!R&&!!_.objectName}),X=Q.useMemo(()=>_.id?`listview-${_.objectName}-${_.id}-view`:`listview-${_.objectName}-view`,[_.objectName,_.id]);Q.useEffect(()=>{let e=!0;return ce(!1),W(null),(async()=>{if(!R||!_.objectName){ce(!0);return}try{let t=await R.getObjectSchema(_.objectName);e&&W(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&ce(!0)}})(),()=>{e=!1}},[_.objectName,R]);let Xe=Q.useMemo(()=>a(U?.fields,_.fields),[U?.fields,_.fields]);Q.useEffect(()=>{let e=!0,t=++Ee.current;if(_.data&&typeof _.data==`object`&&!Array.isArray(_.data)){let e=_.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)))}B(t),H(!1),q(!1);return}}if(Array.isArray(_.data)){let e=_.data;if(C){let t=C.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}B(e),H(!1),q(!1);return}return se?((async()=>{if(!(!R||!_.objectName)){H(!0);try{let n=[],r=_.filters||[],i=jt(I),a=[];Be&&Oe.size>0&&Be.forEach(e=>{Oe.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=M.length>0?M.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,l=await R.find(_.objectName,{$filter:n,$orderby:c,$top:he,...Xe.length>0?{$expand:Xe}:{},...C?{$search:C,..._.searchableFields&&_.searchableFields.length>0?{$searchFields:_.searchableFields}:{}}:{}});if(!e||t!==Ee.current)return;let u=[];Array.isArray(l)?u=l:l&&typeof l==`object`&&(Array.isArray(l.data)?u=l.data:Array.isArray(l.records)?u=l.records:Array.isArray(l.value)&&(u=l.value)),B(u),q(u.length>=he)}catch(e){t===Ee.current&&console.error(`ListView data fetch error:`,e)}finally{e&&t===Ee.current&&H(!1)}}})(),()=>{e=!1}):void 0},[_.objectName,_.data,R,_.filters,he,M,I,Oe,Be,Ae,le,C,_.searchableFields,Xe,se]);let Qe=Q.useMemo(()=>{if(_.appearance?.allowedVisualizations&&_.appearance.allowedVisualizations.length>0)return _.appearance.allowedVisualizations.filter(e=>[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`].includes(e));let e=[`grid`];return(_.kanban?.groupField||_.options?.kanban?.groupField)&&e.push(`kanban`),(_.gallery?.coverField||_.gallery?.imageField||_.options?.gallery?.imageField)&&e.push(`gallery`),(_.calendar?.startDateField||_.options?.calendar?.startDateField)&&e.push(`calendar`),(_.timeline?.startDateField||_.options?.timeline?.startDateField||_.options?.timeline?.dateField||_.options?.calendar?.startDateField)&&e.push(`timeline`),(_.gantt?.startDateField||_.options?.gantt?.startDateField)&&e.push(`gantt`),(_.options?.map?.locationField||_.options?.map?.latitudeField&&_.options?.map?.longitudeField)&&e.push(`map`),_.viewType&&!e.includes(_.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`].includes(_.viewType)&&e.push(_.viewType),e},[_.options,_.viewType,_.kanban,_.calendar,_.gantt,_.gallery,_.timeline,_.appearance?.allowedVisualizations]);Q.useEffect(()=>{_.viewType&&S(_.viewType)},[_.viewType]);let $e=Q.useCallback(e=>{S(e);try{localStorage.setItem(X,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}r?.(e)},[X,r]),et=Q.useCallback(e=>{T(e),s?.(e)},[s]),tt=l({navigation:_.navigation,objectName:_.objectName,onNavigate:_.onNavigate,onRowClick:c}),nt=Q.useMemo(()=>{let e=_.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)})),_.fieldOrder&&_.fieldOrder.length>0){let t=new Map(_.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},[_.fields,Ne,_.fieldOrder]),rt=Q.useMemo(()=>{let e={objectName:_.objectName,fields:nt,filters:_.filters,sort:M,className:`h-full w-full`,showSearch:!1,onRowClick:tt.handleClick,..._.striped==null?{}:{striped:_.striped},..._.bordered==null?{}:{bordered:_.bordered}};switch(x){case`grid`:return{type:`object-grid`,...e,columns:nt,..._.conditionalFormatting?{conditionalFormatting:_.conditionalFormatting}:{},..._.inlineEdit==null?{}:{editable:_.inlineEdit},..._.wrapHeaders==null?{}:{wrapHeaders:_.wrapHeaders},..._.virtualScroll==null?{}:{virtualScroll:_.virtualScroll},..._.resizable==null?{}:{resizable:_.resizable},..._.selection?{selection:_.selection}:{},..._.pagination?{pagination:_.pagination}:{},...J?{grouping:J}:{},...ye?{rowColor:ye}:{},..._.rowActions?{rowActions:_.rowActions}:{},..._.bulkActions?{batchActions:_.bulkActions}:{},..._.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...e,groupBy:_.kanban?.groupField||_.options?.kanban?.groupField||`status`,groupField:_.kanban?.groupField||_.options?.kanban?.groupField||`status`,titleField:_.kanban?.titleField||_.options?.kanban?.titleField||`name`,cardFields:_.kanban?.cardFields||nt||[],...J?{grouping:J}:{},..._.options?.kanban||{},..._.kanban||{}};case`calendar`:return{type:`object-calendar`,...e,startDateField:_.calendar?.startDateField||_.options?.calendar?.startDateField||`start_date`,endDateField:_.calendar?.endDateField||_.options?.calendar?.endDateField||`end_date`,titleField:_.calendar?.titleField||_.options?.calendar?.titleField||`name`,..._.calendar?.defaultView?{defaultView:_.calendar.defaultView}:{},..._.options?.calendar||{},..._.calendar||{}};case`gallery`:{let t={..._.options?.gallery||{},..._.gallery||{}};return{type:`object-gallery`,...e,gallery:Object.keys(t).length>0?t:void 0,imageField:_.gallery?.coverField||_.gallery?.imageField||_.options?.gallery?.imageField,titleField:_.gallery?.titleField||_.options?.gallery?.titleField||`name`,subtitleField:_.gallery?.subtitleField||_.options?.gallery?.subtitleField,...J?{grouping:J}:{}}}case`timeline`:{let t={..._.options?.timeline||{},..._.timeline||{}};return{type:`object-timeline`,...e,timeline:Object.keys(t).length>0?t:void 0,startDateField:_.timeline?.startDateField||_.options?.timeline?.startDateField||_.options?.timeline?.dateField||`created_at`,titleField:_.timeline?.titleField||_.options?.timeline?.titleField||`name`,..._.timeline?.endDateField?{endDateField:_.timeline.endDateField}:{},..._.timeline?.groupByField?{groupByField:_.timeline.groupByField}:{},..._.timeline?.colorField?{colorField:_.timeline.colorField}:{},..._.timeline?.scale?{scale:_.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...e,startDateField:_.gantt?.startDateField||_.options?.gantt?.startDateField||`start_date`,endDateField:_.gantt?.endDateField||_.options?.gantt?.endDateField||`end_date`,progressField:_.gantt?.progressField||_.options?.gantt?.progressField||`progress`,dependenciesField:_.gantt?.dependenciesField||_.options?.gantt?.dependenciesField||`dependencies`,..._.gantt?.titleField?{titleField:_.gantt.titleField}:{},..._.options?.gantt||{},..._.gantt||{}};case`map`:return{type:`object-map`,...e,locationField:_.options?.map?.locationField||`location`,..._.options?.map||{}};default:return e}},[x,_,M,nt,J,ye,tt.handleClick]),it=I.conditions&&I.conditions.length>0,at=Q.useMemo(()=>{let e;if(e=U?.fields?Object.entries(U.fields).map(([e,t])=>({value:e,label:y(e,t.label||e),type:t.type||`text`,options:t.options})):(_.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let t=e.name||e.fieldName;return{value:t,label:y(t,e.label||e.name),type:e.type||`text`,options:e.options}}),_.filterableFields&&_.filterableFields.length>0){let t=new Set(_.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[U,_.fields,_.filterableFields]),st=Q.useCallback(e=>{ke(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ct=Q.useCallback(e=>{let t=We,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||_.objectName||`export`,a=n>0?z.slice(0,n):z;if(e===`csv`){let e=nt.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];r&&t.push(e.join(`,`)),a.forEach(n=>{t.push(e.map(e=>{let t=n[e],r;return r=t==null?``:Array.isArray(t)?t.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof t==`object`?JSON.stringify(t):String(t),r.includes(`,`)||r.includes(`"`)||r.includes(`
|
|
2
|
-
`)||r.includes(`\r`)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`))});let n=new Blob([t.join(`
|
|
3
|
-
`)],{type:`text/csv;charset=utf-8;`}),o=URL.createObjectURL(n),s=document.createElement(`a`);s.href=o,s.download=`${i}.csv`,s.click(),URL.revokeObjectURL(o)}else if(e===`json`){let e=new Blob([JSON.stringify(a,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${i}.json`,n.click(),URL.revokeObjectURL(t)}ze(!1)},[z,nt,We,_.objectName]),lt=Q.useMemo(()=>(_.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:y(e,e)};let t=e.name||e.fieldName||e.field;return{name:t,label:y(t,e.label||e.name||e.field)}}),[_.fields,y]);return(0,$.jsxs)(`div`,{ref:Ke,className:Z(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,t),..._.aria?.label?{"aria-label":_.aria.label}:{},..._.aria?.describedBy?{"aria-describedby":_.aria.describedBy}:{},..._.aria?.live?{"aria-live":_.aria.live}:{},role:`region`,children:[Ye>0&&(0,$.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Ye},children:h(qe?`list.refreshing`:`list.pullToRefresh`)}),d&&(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})}),_.tabs&&_.tabs.length>0&&(0,$.jsx)(xt,{tabs:_.tabs,activeTab:ie,onTabChange:oe}),_.description&&_.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 _.description==`string`?_.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:U,data:z,onFilterChange:je,maxVisible:3})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[b.showHideFields&&(0,$.jsxs)(Je,{open:Fe,onOpenChange:Ie,children:[(0,$.jsx)(fe,{asChild:!0,children:(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:Z(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Ne.size>0&&`text-primary`),children:[(0,$.jsx)(j,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`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)(De,{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:h(`list.hideFieldsTitle`)}),Ne.size>0&&(0,$.jsx)(N,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Pe(new Set),children:h(`list.showAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:lt.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)(Je,{open:te,onOpenChange:P,children:[(0,$.jsx)(fe,{asChild:!0,children:(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:Z(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,it&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`list.filter`)}),it&&(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:I.conditions?.length||0})]})}),(0,$.jsx)(De,{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:h(`list.filterRecords`)})}),(0,$.jsx)(xe,{fields:at,value:I,onChange:e=>{ne(e),i&&i(e)}})]})})]}),b.showGroup&&(0,$.jsxs)(Je,{open:ge,onOpenChange:ve,children:[(0,$.jsx)(fe,{asChild:!0,children:(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:Z(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,J&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(w,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`list.group`)}),J&&J.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:J.fields.length})]})}),(0,$.jsx)(De,{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:h(`list.groupBy`)}),J&&(0,$.jsx)(N,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Y(void 0),"data-testid":`clear-grouping`,children:h(`list.clear`)})]}),(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,"data-testid":`group-field-list`,children:lt.map(e=>{let t=J?.fields?.some(t=>t.field===e.name);return(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:!!t,onChange:()=>{if(t){let t=(J?.fields||[]).filter(t=>t.field!==e.name);Y(t.length>0?{fields:t}:void 0)}else Y({fields:[...J?.fields||[],{field:e.name,order:`asc`,collapsed:!1}]})},className:`rounded border-input`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name)})})]})})]}),b.showSort&&(0,$.jsxs)(Je,{open:k,onOpenChange:A,children:[(0,$.jsx)(fe,{asChild:!0,children:(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:Z(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,M.length>0&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(Ue,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`list.sort`)}),M.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:M.length})]})}),(0,$.jsx)(De,{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:h(`list.sortRecords`)})}),(0,$.jsx)(_e,{fields:at,value:M,onChange:e=>{ee(e),o&&o(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)(Je,{open:Se,onOpenChange:Ce,children:[(0,$.jsx)(fe,{asChild:!0,children:(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:Z(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,ye&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(ae,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`list.color`)})]})}),(0,$.jsx)(De,{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:h(`list.rowColor`)}),ye&&(0,$.jsx)(N,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>be(void 0),"data-testid":`clear-row-color`,children:h(`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:h(`list.colorByField`)}),(0,$.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:ye?.field||``,onChange:e=>{let t=e.target.value;be(t?{field:t,colors:ye?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,$.jsx)(`option`,{value:``,children:h(`list.none`)}),lt.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),b.showDensity&&(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:Z(`h-7 px-2 text-muted-foreground hover:text-primary text-xs hidden lg:flex transition-colors duration-150`,Ge.mode!==`compact`&&`bg-primary/10 border border-primary/20 text-primary`),onClick:Ge.cycle,title:`Density: ${Ge.mode}`,children:[(0,$.jsx)(Le,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline capitalize`,children:Ge.mode})]}),(b.showColor||b.showDensity)&&We&&_.allowExport!==!1&&(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5 shrink-0`}),We&&_.allowExport!==!1&&(0,$.jsxs)(Je,{open:Re,onOpenChange:ze,children:[(0,$.jsx)(fe,{asChild:!0,children:(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,children:[(0,$.jsx)(ut,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`list.export`)})]})}),(0,$.jsx)(De,{align:`start`,className:`w-48 p-2`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:(We.formats||[`csv`,`json`]).map(e=>(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,onClick:()=>ct(e),children:[(0,$.jsx)(ut,{className:`h-3.5 w-3.5 mr-2`}),h(`list.exportAs`,{format:e.toUpperCase()})]},e))})})]}),(_.sharing?.enabled||_.sharing?.type)&&(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${_.sharing?.visibility||_.sharing?.type||`private`}`,"data-testid":`share-button`,children:[(0,$.jsx)(re,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`list.share`)})]}),_.allowPrinting&&(0,$.jsxs)(N,{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)(dt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`list.print`)})]}),(()=>{let e=_.allowPrinting||_.sharing?.enabled||_.sharing?.type||We&&_.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)(Je,{open:D,onOpenChange:O,children:[(0,$.jsx)(fe,{asChild:!0,children:(0,$.jsx)(N,{variant:`ghost`,size:`sm`,className:Z(`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:h(`list.search`),children:(0,$.jsx)(F,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(De,{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)(F,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(Ve,{placeholder:h(`list.search`)+`...`,value:C,onChange:e=>et(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),C&&(0,$.jsx)(N,{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:()=>et(``),children:(0,$.jsx)(Ze,{className:`h-3 w-3`})})]})})]}),b.showAddRecord&&b.addRecordPosition===`top`&&(0,$.jsxs)(N,{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:()=>p.onAddRecord?.(),children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`list.addRecord`)})]})]})]}),Be&&Be.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:Be.map(e=>{let t=Oe.has(e.id),n=e.icon?ue[e.icon.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null;return(0,$.jsxs)(N,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs`,onClick:()=>st(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:!V&&z.length===0?(()=>{let e=_.emptyState?.icon,t=e?ue[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??ot:ot;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)(t,{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 _.emptyState?.title==`string`?_.emptyState.title:void 0)??`No items found`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:(typeof _.emptyState?.message==`string`?_.emptyState.message:void 0)??`There are no records to display. Try adjusting your filters or adding new data.`})]})})():(0,$.jsx)(m,{schema:rt,...p,data:z,loading:V,onRowSelect:Te})},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)(N,{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:()=>p.onAddRecord?.(),children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:h(`list.addRecord`)})]})}),_.bulkActions&&_.bulkActions.length>0&&we.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:[we.length,` selected`]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 ml-2`,children:_.bulkActions.map(e=>(0,$.jsx)(N,{variant:`outline`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>p.onBulkAction?.(e,we),"data-testid":`bulk-action-${e}`,children:kt(e)},e))}),(0,$.jsx)(N,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs ml-auto`,onClick:()=>Te([]),children:`Clear`})]}),!V&&z.length>0&&_.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:z.length===1?h(`list.recordCountOne`,{count:z.length}):h(`list.recordCount`,{count:z.length})}),K&&(0,$.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:h(`list.dataLimitReached`,{limit:he})}),_.pagination?.pageSizeOptions&&_.pagination.pageSizeOptions.length>0&&(0,$.jsx)(`select`,{className:`ml-auto h-6 rounded border border-input bg-background px-1 text-xs`,value:he,onChange:e=>{let t=Number(e.target.value);me(t),p.onPageSizeChange&&p.onPageSizeChange(t)},"data-testid":`page-size-selector`,children:_.pagination.pageSizeOptions.map(e=>(0,$.jsxs)(`option`,{value:e,children:[e,` / page`]},e))})]}),tt.isOverlay&&(0,$.jsx)(He,{...tt,title:_.label?`${_.label} Detail`:_.objectName?`${_.objectName.charAt(0).toUpperCase()+_.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))})})]})},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]`};r.register(`object-gallery`,e=>{let{schema:t}=e,n=(0,Q.useContext)(s),r=e.dataSource||n?.dataSource,i=o(t.bind),[c,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),h=l({navigation:t.navigation,objectName:t.objectName,onRowClick:e.onRowClick??e.onCardClick}),_=t.gallery,v=_?.coverField??t.imageField??`image`,y=_?.coverFit??`cover`,b=_?.cardSize??`medium`,S=_?.titleField??t.titleField??`name`,C=_?.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&&m(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)){u(e.data);return}return t.objectName&&!i&&!t.data&&!e.data&&(async()=>{if(!(!r||typeof r.find!=`function`||!t.objectName)){n&&f(!0);try{let e=a(p?.fields),i=await r.find(t.objectName,{$filter:t.filter,...e.length>0?{$expand:e}:{}}),o=[];if(Array.isArray(i))o=i;else if(i&&typeof i==`object`){let e=i;Array.isArray(e.records)?o=e.records:Array.isArray(e.data)&&(o=e.data)}n&&u(o)}catch(e){console.error(`[ObjectGallery] Fetch error:`,e)}finally{n&&f(!1)}}})(),()=>{n=!1}},[t.objectName,r,i,t.data,t.filter,e.data,p]);let w=e.data||i||t.data||c||[],T=t.grouping?.fields,E=!!(T&&T.length>0),[D,O]=(0,Q.useState)({}),k=(0,Q.useMemo)(()=>T?T.some(e=>e.collapsed):!1,[T]),A=(0,Q.useCallback)(e=>{O(t=>({...t,[e]:t[e]===void 0?!k:!t[e]}))},[k]),j=(0,Q.useMemo)(()=>{if(!E||!T)return[];let e=new Map,t=[];for(let n of w){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 D?D[t]:k;return{key:t,label:n.label,items:n.items,collapsed:r}})},[w,T,E,D,k]);if(d&&!w.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!w.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let M=(n,r)=>{let i=n.id??n._id??r,a=String(n[S]??`Untitled`),o=n[v];return(0,$.jsxs)(B,{role:`listitem`,className:Z(`group overflow-hidden transition-all hover:shadow-md`,(e.onCardClick||e.onRowClick||t.navigation)&&`cursor-pointer`),onClick:()=>h.handleClick(n),children:[(0,$.jsx)(`div`,{className:Z(`w-full overflow-hidden bg-muted relative`,Lt[b]),children:o?(0,$.jsx)(`img`,{src:o,alt:a,className:Z(`h-full w-full transition-transform group-hover:scale-105`,y===`cover`&&`object-cover`,y===`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)(x,{className:`p-3 border-t`,children:[(0,$.jsx)(`h3`,{className:`font-medium truncate text-sm`,title:a,children:a}),C&&C.length>0&&(0,$.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:C.map(e=>{let t=n[e];return t==null?null:(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:String(t)},e)})})]})]},i)},N=e=>(0,$.jsx)(`div`,{className:Z(`grid gap-4 p-4`,It[b],t.className),role:`list`,children:e.map((e,t)=>M(e,t))});return(0,$.jsxs)($.Fragment,{children:[E?(0,$.jsx)(`div`,{className:`space-y-2`,children:j.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:()=>A(e.key),children:[e.collapsed?(0,$.jsx)(g,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Xe,{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&&N(e.items)]},e.key))}):N(w),h.isOverlay&&(0,$.jsx)(He,{...h,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`}),r.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:{}}}),r.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=mt();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.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.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:s})=>{let[c,l]=Q.useState(e.defaultCollapsed??!1),[u,d]=Q.useState(null),[f,p]=Q.useState(void 0),{t:h}=Wt(),{fieldLabel:v}=pt(),b=Q.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{d(e),setTimeout(()=>d(null),2e3)})},[]),S=e.hideEmpty?e.fields.filter(e=>{let n=t?.[e.name]??e.value;return n!=null&&n!==``}):e.fields;if(S.length===0)return null;let{fields:C,columns:w}=Ht(S,e.columns),E=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,$.jsx)(m,{schema:e.render,data:{...t,value:n}});let s=Gt(e.span,w),c=(()=>{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=at(i);if(e)return(0,$.jsx)(e,{value:n,field:a})}return String(n)})(),l=n!=null&&n!==``,d=u===e.name;return(0,$.jsxs)(`div`,{className:Z(`space-y-1.5 group`,s),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:Z(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,l&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:l?()=>b(e.name,n):void 0,onKeyDown:l?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),b(e.name,n))}:void 0,role:l?`button`:void 0,tabIndex:l?0:void 0,children:[(0,$.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:c}),l&&(0,$.jsx)(se,{children:(0,$.jsxs)(ft,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(N,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),b(e.name,n)},children:d?(0,$.jsx)(ze,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(O,{className:`h-3 w-3`})})}),(0,$.jsx)(y,{children:h(d?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},D=s?.enabled===!0,k=s?.batchSize??20;Q.useEffect(()=>{if(!D){p(void 0);return}if(C.length<=k){p(void 0);return}p(k);let e=setTimeout(()=>p(void 0),100);return()=>clearTimeout(e)},[D,C.length,k]);let j=f===void 0?C:C.slice(0,f),M=(0,$.jsx)(`div`,{className:Z(`grid gap-3 sm:gap-4`,w===1?`grid-cols-1`:w===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:j.map(E)});return e.collapsible?(0,$.jsx)(ne,{open:!c,onOpenChange:e=>l(!e),className:n,children:(0,$.jsxs)(B,{children:[(0,$.jsx)(_,{asChild:!0,children:(0,$.jsxs)(H,{className:Z(`cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsxs)(T,{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)(ie,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:c?(0,$.jsx)(g,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Xe,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!c&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]})}),(0,$.jsx)(Me,{children:(0,$.jsx)(x,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:M})})]})}):(0,$.jsxs)(B,{className:Z(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,$.jsxs)(H,{className:Z(e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsx)(T,{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)(ie,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]})}),e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]}),(0,$.jsx)(x,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:M})]})},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)(we,{value:r,onValueChange:i,className:n,children:[(0,$.jsx)(nt,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,$.jsx)(lt,{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)(ie,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,$.jsx)(q,{value:e.key,className:`mt-4`,children:Array.isArray(e.content)?(0,$.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,$.jsx)(m,{schema:e,data:t},n))}):(0,$.jsx)(m,{schema:e.content,data:t})},e.key))]})},Jt=({title:e,type:t,api:n,data:r=[],schema:i,columns:a,className:o,dataSource:s,objectName:c,onNew:l,onViewAll:u,onRowEdit:d,onRowDelete:f,pageSize:p,sortable:h=!1,filterable:_=!1,collapsible:y=!1,defaultCollapsed:b=!1})=>{let[S,C]=Q.useState(r),[w,E]=Q.useState(!1),[D,O]=Q.useState(0),[k,A]=Q.useState(null),[j,M]=Q.useState(`asc`),[ee,P]=Q.useState(``),[F,I]=Q.useState(null),[ne,re]=Q.useState(b),{t:L}=Wt(),{fieldLabel:ae}=pt();Q.useEffect(()=>{C(r)},[r]),Q.useEffect(()=>{n&&s?.getObjectSchema&&!a?.length&&s.getObjectSchema(n).then(I).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,s,a]),Q.useEffect(()=>{n&&!r.length&&(E(!0),s&&typeof s.find==`function`?s.find(n).then(e=>{C(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),E(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),E(!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(()=>E(!1)))},[n,r,s]);let oe=Q.useMemo(()=>{if(!ee)return S;let e=ee.toLowerCase();return S.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[S,ee]),R=Q.useMemo(()=>k?[...oe].sort((e,t)=>{let n=e[k],r=t[k];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 j===`asc`?i:-i}):oe,[oe,k,j]),z=p&&p>0?p:0,V=z?Math.max(1,Math.ceil(R.length/z)):1,U=z?R.slice(D*z,(D+1)*z):R;Q.useEffect(()=>{O(0)},[ee,k,j]);let W=Q.useCallback(e=>{k===e?M(e=>e===`asc`?`desc`:`asc`):(A(e),M(`asc`))},[k]),se=Q.useCallback(e=>{window.confirm(L(`detail.deleteRowConfirmation`))&&f?.(e)},[f,L]),ce=Q.useMemo(()=>{if(a&&a.length>0)return a;if(!F?.fields)return[];let e=c||n||``;return Object.entries(F.fields).filter(([e])=>!e.startsWith(`_`)&&e!==`id`).map(([t,n])=>{let r={accessorKey:t,header:ae(e,t,n.label||t)};if(n.type){let e=at(n.type);if(e){let i={name:t,label:n.label||t,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=t=>t==null?Q.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):Q.createElement(e,{value:t,field:i})}}return r})},[a,F,c,n,ae]),le=Q.useMemo(()=>{if(i)return i;switch(t){case`grid`:case`table`:return{type:`data-table`,data:U,columns:ce,pagination:!1,pageSize:z||10};case`list`:return{type:`data-list`,data:U};default:return{type:`div`,children:`No view configured`}}},[t,U,ce,i,z]),ue=!!d||!!f;return(0,$.jsxs)(B,{className:o,children:[(0,$.jsx)(H,{className:y?`cursor-pointer select-none`:void 0,onClick:y?()=>re(e=>!e):void 0,children:(0,$.jsxs)(T,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[y&&(ne?(0,$.jsx)(g,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Xe,{className:`h-4 w-4 text-muted-foreground`})),(0,$.jsx)(`span`,{children:e}),(0,$.jsx)(ie,{variant:`secondary`,className:`text-xs font-normal`,"aria-label":`${S.length} records`,children:S.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[l&&(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),l()},className:`gap-1 h-7 text-xs`,children:[(0,$.jsx)(v,{className:`h-3.5 w-3.5`}),L(`detail.new`)]}),u&&(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),u()},className:`gap-1 h-7 text-xs`,children:[L(`detail.viewAll`),(0,$.jsx)(te,{className:`h-3 w-3`})]})]})]})}),!ne&&(0,$.jsxs)(x,{children:[_&&S.length>0&&(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(Ve,{placeholder:L(`detail.filterPlaceholder`),value:ee,onChange:e=>P(e.target.value),className:`h-8 text-sm`})}),h&&ce&&ce.length>0&&S.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:ce.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,r=k===t;return(0,$.jsxs)(N,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>W(t),children:[(0,$.jsx)(Ue,{className:`h-3 w-3`}),n,r&&(j===`asc`?` ↑`:` ↓`)]},t)})}),w?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground`,children:L(`detail.loading`)}):S.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:L(`detail.noRelatedRecords`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(m,{schema:le}),ue&&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:[d&&(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2`,onClick:()=>d(e),children:[(0,$.jsx)(st,{className:`h-3 w-3`}),L(`detail.editRow`)]}),f&&(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2 text-destructive hover:text-destructive`,onClick:()=>se(e),children:[(0,$.jsx)(ge,{className:`h-3 w-3`}),L(`detail.deleteRow`)]})]})]},e.id||t))})]}),z>0&&R.length>z&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,$.jsxs)(N,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:D===0,onClick:()=>O(e=>Math.max(0,e-1)),children:[(0,$.jsx)(ve,{className:`h-3 w-3`}),L(`detail.previousPage`)]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:L(`detail.pageOf`,{current:D+1,total:V})}),(0,$.jsxs)(N,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:D>=V-1,onClick:()=>O(e=>Math.min(V-1,e+1)),children:[L(`detail.nextPage`),(0,$.jsx)(g,{className:`h-3 w-3`})]})]})]})]})},Yt=({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)(ne,{open:!c,onOpenChange:e=>l(!e),className:n,children:[(0,$.jsx)(_,{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)(g,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,$.jsx)(Xe,{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)(Me,{children:(0,$.jsx)(`div`,{className:`mt-3`,children:u})})]}):(0,$.jsxs)(`div`,{className:Z(`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]})},Xt=({fields:e,data:t,className:n,objectName:r,objectSchema:i})=>{let{fieldLabel:a}=pt();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)(B,{className:Z(`bg-muted/30 border-dashed`,n),children:(0,$.jsx)(x,{className:`py-3 px-4`,children:(0,$.jsx)(`div`,{className:Z(`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=at(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 Zt(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 Qt=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let[a,o]=Q.useState(``),[s,c]=Q.useState(!1),[l,u]=Q.useState(``),d=Q.useCallback(async()=>{let e=a.trim();if(!(!e||!t)){c(!0);try{await t(e),o(``)}finally{c(!1)}}},[a,t]),f=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),d())},[d]),p=Q.useMemo(()=>[...l.trim()?e.filter(e=>{let t=l.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,l]);return(0,$.jsxs)(B,{className:Z(``,i),children:[(0,$.jsx)(H,{children:(0,$.jsxs)(T,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(Ee,{className:`h-4 w-4`}),`Comments`,(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,$.jsxs)(x,{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)(F,{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:`Search comments…`,value:l,onChange:e=>u(e.target.value),"aria-label":`Search comments`}),l&&(0,$.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>u(``),"aria-label":`Clear search`,type:`button`,children:(0,$.jsx)(Ze,{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:`Add a comment… (Ctrl+Enter to submit)`,value:a,onChange:e=>o(e.target.value),onKeyDown:f,disabled:s}),(0,$.jsx)(N,{size:`icon`,variant:`default`,onClick:d,disabled:!a.trim()||s,className:`shrink-0 self-end`,children:(0,$.jsx)(je,{className:`h-4 w-4`})})]}),p.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:l.trim()?`No matching comments`:`No comments yet`}):(0,$.jsx)(`div`,{className:`space-y-3`,children:p.map(e=>(0,$.jsxs)(`div`,{className:Z(`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:Zt(e.createdAt)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,$.jsx)(k,{className:`h-3 w-3`}),`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?`Unpin comment`:`Pin comment`,children:[(0,$.jsx)(k,{className:`h-3 w-3`}),e.pinned?`Unpin`:`Pin`]})]})]},e.id))})]})]})},$t={field_change:st,create:M,delete:ge,comment:Ee,status_change:Te},en={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 tn(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 nn(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 rn={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},an=({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)(B,{className:Z(``,r),children:[(0,$.jsx)(H,{children:(0,$.jsxs)(T,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(et,{className:`h-4 w-4`}),`Activity`,(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,$.jsxs)(x,{children:[t&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(rn).map(e=>(0,$.jsxs)(`button`,{type:`button`,className:Z(`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($t[e]||st,{className:`h-3 w-3`}),rn[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=$t[e.type]||st;return(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:Z(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,en[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:nn(e)})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:tn(e.timestamp)})]})]},e.id)})})]})]})]})},on=5,sn=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:o,inlineEdit:s=!1,onFieldSave:c})=>{let[l,u]=Q.useState(e.data),[d,f]=Q.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[p,h]=Q.useState(!1),[_,v]=Q.useState(!1),[b,x]=Q.useState({}),[S,C]=Q.useState(null),{t:w}=Wt();Q.useEffect(()=>{let n=!0;if(e.data){u(e.data),f(!1);return}if(t&&e.objectName&&e.resourceId){f(!0),C(null),u(null);let r=e.objectName,i=e.resourceId,o=`${r}-`,s=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]];(t.getObjectSchema?t.getObjectSchema(r).catch(()=>null):Promise.resolve(null)).then(e=>{if(!n)return;C(e);let c=a(e?.fields,s),l=c.length>0?{$expand:c}:void 0,d=l?t.findOne(r,i,l):t.findOne(r,i),p=()=>{let e=String(i),a=e.startsWith(o)?e.slice(o.length):`${o}${e}`;return(l?t.findOne(r,a,l):t.findOne(r,a)).then(e=>{n&&(u(e),f(!1))}).catch(()=>{n&&(u(null),f(!1))})};return d.catch(()=>null).then(e=>{if(n){if(e){u(e),f(!1);return}return p()}})}).catch(e=>{n&&(console.error(`Failed to fetch detail data:`,e),f(!1))})}else e.api&&e.resourceId&&(f(!0),fetch(`${e.api}/${e.resourceId}`).then(e=>e.json()).then(e=>{n&&u(e?.data||e)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{n&&f(!1)}));return()=>{n=!1}},[e.api,e.resourceId,e.objectName,t,e.sections,e.fields]);let T=Q.useCallback(()=>{if(o)o();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()},[o,e]),E=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]),D=Q.useCallback(()=>{let t=e.deleteConfirmation||w(`detail.deleteConfirmation`);window.confirm(t)&&(i?.(),e.onNavigate&&e.objectName&&e.onNavigate(`/${e.objectName}`,{replace:!0}))},[i,e]),k=Q.useCallback(()=>{navigator.share&&e.objectName&&e.resourceId?navigator.share({title:e.title||w(`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]),j=Q.useCallback(()=>{console.log(`Duplicate record:`,l)},[l]),M=Q.useCallback(()=>{console.log(`Export record:`,l)},[l]),ee=Q.useCallback(()=>{console.log(`View history for record:`,e.resourceId)},[e]),te=Q.useCallback(()=>{h(!p)},[p]),P=Q.useCallback(()=>{if(_){let e=Object.entries(b);if(e.length>0){let t={...l,...b};u(t),e.forEach(([e,n])=>{c?.(e,n,t)})}x({})}v(!_)},[_,b,l,c]),F=Q.useCallback((e,t)=>{x(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 I=Q.useMemo(()=>{if(!e.autoDiscoverRelated||!S?.fields||e.related&&e.related.length>0)return[];let t=[],n=S.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,S]),ne=Q.useMemo(()=>e.related&&e.related.length>0?e.related:I.map(e=>({title:e.title,type:e.type,api:e.objectName,data:[]})),[e.related,I]);return d||e.loading?(0,$.jsxs)(`div`,{className:Z(`space-y-4`,n),children:[(0,$.jsx)(W,{className:`h-10 w-full`}),(0,$.jsx)(W,{className:`h-64 w-full`}),(0,$.jsx)(W,{className:`h-48 w-full`})]}):!l&&!e.data?(0,$.jsxs)(`div`,{className:Z(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold`,children:w(`detail.recordNotFound`)}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:w(`detail.recordNotFoundDescription`)}),(e.showBack??!0)&&(0,$.jsxs)(N,{variant:`outline`,size:`sm`,onClick:T,className:`mt-4 gap-2`,children:[(0,$.jsx)(Ce,{className:`h-4 w-4`}),w(`detail.goBack`)]})]}):(0,$.jsx)(se,{children:(0,$.jsxs)(`div`,{className:Z(`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)(ft,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(N,{variant:`ghost`,size:`icon`,onClick:T,className:`shrink-0 mt-1`,children:(0,$.jsx)(Ce,{className:`h-4 w-4`})})}),(0,$.jsx)(y,{children:w(`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:e.primaryField&&l?.[e.primaryField]||e.title||w(`detail.details`)}),e.summaryFields?.map(e=>{let t=l?.[e];return t==null||t===``?null:(0,$.jsx)(ie,{variant:`secondary`,className:`text-xs`,"aria-label":`${e}: ${t}`,children:String(t)},e)}),(0,$.jsxs)(ft,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(N,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:te,children:p?(0,$.jsx)(tt,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,$.jsx)(ct,{className:`h-4 w-4 text-muted-foreground`})})}),(0,$.jsx)(y,{children:w(p?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),e.objectName&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.objectName}),(0,$.jsx)(`span`,{className:`text-muted-foreground/60`,children:`•`}),(0,$.jsxs)(`span`,{children:[`#`,e.resourceId]})]})]})]}),(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)(ft,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(N,{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)(ve,{className:`h-4 w-4`})})}),(0,$.jsx)(y,{children:w(`detail.previousRecord`)})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:w(`detail.recordOf`,{current:e.recordNavigation.currentIndex+1,total:e.recordNavigation.recordIds.length})}),(0,$.jsxs)(ft,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(N,{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)(g,{className:`h-4 w-4`})})}),(0,$.jsx)(y,{children:w(`detail.nextRecord`)})]})]}),e.actions?.map((e,t)=>(0,$.jsx)(m,{schema:e,data:l},t)),s&&(0,$.jsxs)(ft,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(N,{variant:_?`default`:`outline`,size:`sm`,onClick:P,className:`gap-2 hidden sm:inline-flex`,children:_?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ze,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:w(`detail.save`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(st,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:w(`detail.editInline`)})]})})}),(0,$.jsx)(y,{children:w(_?`detail.saveChanges`:`detail.editFieldsInline`)})]}),(0,$.jsxs)(ft,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(N,{variant:`outline`,size:`icon`,onClick:k,className:`hidden sm:inline-flex`,children:(0,$.jsx)(re,{className:`h-4 w-4`})})}),(0,$.jsx)(y,{children:w(`detail.share`)})]}),e.showEdit&&(0,$.jsxs)(ft,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsxs)(N,{variant:`default`,onClick:E,className:`gap-2 hidden sm:inline-flex`,children:[(0,$.jsx)(st,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:w(`detail.edit`)})]})}),(0,$.jsx)(y,{children:w(`detail.editRecord`)})]}),(0,$.jsxs)(me,{children:[(0,$.jsxs)(ft,{children:[(0,$.jsx)(A,{asChild:!0,children:(0,$.jsx)(Ie,{asChild:!0,children:(0,$.jsx)(N,{variant:`ghost`,size:`icon`,children:(0,$.jsx)(oe,{className:`h-4 w-4`})})})}),(0,$.jsx)(y,{children:w(`detail.moreActions`)})]}),(0,$.jsxs)(Pe,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-48 max-h-[60vh] overflow-y-auto`,children:[(0,$.jsxs)(Y,{onClick:k,className:`sm:hidden`,children:[(0,$.jsx)(re,{className:`h-4 w-4 mr-2`}),w(`detail.share`)]}),e.showEdit&&(0,$.jsxs)(Y,{onClick:E,className:`sm:hidden`,children:[(0,$.jsx)(st,{className:`h-4 w-4 mr-2`}),w(`detail.edit`)]}),s&&(0,$.jsxs)(Y,{onClick:P,className:`sm:hidden`,children:[(0,$.jsx)(st,{className:`h-4 w-4 mr-2`}),w(_?`detail.save`:`detail.editInline`)]}),(0,$.jsx)(We,{className:`sm:hidden`}),(0,$.jsxs)(Y,{onClick:j,children:[(0,$.jsx)(O,{className:`h-4 w-4 mr-2`}),w(`detail.duplicate`)]}),(0,$.jsxs)(Y,{onClick:M,children:[(0,$.jsx)(ut,{className:`h-4 w-4 mr-2`}),w(`detail.export`)]}),(0,$.jsxs)(Y,{onClick:ee,children:[(0,$.jsx)(V,{className:`h-4 w-4 mr-2`}),w(`detail.viewHistory`)]}),e.showDelete&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(We,{}),(0,$.jsxs)(Y,{onClick:D,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(ge,{className:`h-4 w-4 mr-2`}),w(`detail.delete`)]})]})]})]})]})]}),e.header&&(0,$.jsx)(`div`,{children:(0,$.jsx)(m,{schema:e.header,data:l})}),e.highlightFields&&e.highlightFields.length>0&&(0,$.jsx)(Xt,{fields:e.highlightFields,data:l,objectName:e.objectName,objectSchema:S}),e.autoTabs&&!e.tabs?.length?(0,$.jsxs)(we,{defaultValue:`details`,className:`w-full`,children:[(0,$.jsxs)(nt,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,$.jsx)(lt,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:w(`detail.details`)}),ne.length>0&&(0,$.jsx)(lt,{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:[w(`detail.related`),(0,$.jsx)(ie,{variant:`secondary`,className:`text-xs`,children:ne.length})]})}),e.activities&&e.activities.length>0&&(0,$.jsx)(lt,{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:[w(`detail.activity`),(0,$.jsx)(ie,{variant:`secondary`,className:`text-xs`,children:e.activities.length})]})})]}),(0,$.jsx)(q,{value:`details`,className:`mt-4`,children:(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)(Yt,{group:t,data:{...l,...b},objectSchema:S,objectName:e.objectName,isEditing:_,onFieldChange:F},n)),e.sections&&e.sections.length>0&&e.sections.map((t,n)=>(0,$.jsx)(Kt,{section:t,data:{...l,...b},objectSchema:S,objectName:e.objectName,isEditing:_,onFieldChange:F},n)),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,$.jsx)(Kt,{section:{fields:e.fields,columns:e.columns},data:{...l,...b},objectSchema:S,objectName:e.objectName,isEditing:_,onFieldChange:F}),e.comments&&(0,$.jsx)(Qt,{comments:e.comments,onAddComment:e.onAddComment})]})}),ne.length>0&&(0,$.jsx)(q,{value:`related`,className:`mt-4`,children:(0,$.jsx)(`div`,{className:`space-y-4`,children:ne.map((e,n)=>(0,$.jsx)(Jt,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,collapsible:!0,pageSize:on},n))})}),e.activities&&e.activities.length>0&&(0,$.jsx)(q,{value:`activity`,className:`mt-4`,children:(0,$.jsx)(an,{activities:e.activities})})]}):(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)(Yt,{group:t,data:{...l,...b},objectSchema:S,objectName:e.objectName,isEditing:_,onFieldChange:F},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:{...l,...b},objectSchema:S,objectName:e.objectName,isEditing:_,onFieldChange:F},n))}),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,$.jsx)(Kt,{section:{fields:e.fields,columns:e.columns},data:{...l,...b},objectSchema:S,objectName:e.objectName,isEditing:_,onFieldChange:F}),e.tabs&&e.tabs.length>0&&(0,$.jsx)(qt,{tabs:e.tabs,data:l}),ne.length>0&&(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`h2`,{className:`text-xl font-semibold`,children:w(`detail.related`)}),ne.map((e,n)=>(0,$.jsx)(Jt,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,collapsible:!0,pageSize:on},n))]}),e.comments&&(0,$.jsx)(Qt,{comments:e.comments,onAddComment:e.onAddComment}),e.activities&&e.activities.length>0&&(0,$.jsx)(an,{activities:e.activities})]}),e.footer&&(0,$.jsx)(`div`,{children:(0,$.jsx)(m,{schema:e.footer,data:l})})]})})},cn=({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:Z(`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)(Fe,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`text-foreground`,children:i})]})},ln=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],un=({reactions:e,onToggleReaction:t,emojiOptions:n=ln,className:r})=>{let[i,a]=Q.useState(!1),o=Q.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,$.jsxs)(`div`,{className:Z(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:Z(`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)(N,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,$.jsx)(U,{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 dn(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 fn=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let[a,o]=Q.useState(!1),[s,c]=Q.useState(``),[l,u]=Q.useState(!1),d=Q.useCallback(async()=>{let t=s.trim();if(!(!t||!n)){u(!0);try{await n(e.id,t),c(``)}finally{u(!1)}}},[s,n,e.id]),f=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),d())},[d]);return t.length===0&&!r?null:(0,$.jsxs)(`div`,{className:Z(`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:()=>o(!a),"aria-expanded":a,children:[a?(0,$.jsx)(Xe,{className:`h-3 w-3`}):(0,$.jsx)(g,{className:`h-3 w-3`}),(0,$.jsx)(Ee,{className:`h-3 w-3`}),(0,$.jsxs)(`span`,{children:[t.length,` `,t.length===1?`reply`:`replies`]})]}),a&&(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:dn(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:`Reply…`,value:s,onChange:e=>c(e.target.value),onKeyDown:f,disabled:l}),(0,$.jsx)(N,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:d,disabled:!s.trim()||l,"aria-label":`Send reply`,children:(0,$.jsx)(je,{className:`h-3 w-3`})})]})]})},pn=({subscription:e,onToggle:t,className:n})=>{let[r,i]=Q.useState(!1),a=Q.useCallback(async()=>{if(t){i(!0);try{await t(!e.subscribed)}finally{i(!1)}}},[t,e.subscribed]);return(0,$.jsx)(N,{variant:`ghost`,size:`icon`,className:Z(`h-8 w-8`,n),onClick:a,disabled:r||!t,"aria-label":e.subscribed?`Unsubscribe from notifications`:`Subscribe to notifications`,title:e.subscribed?`Subscribed — click to unsubscribe`:`Subscribe to notifications`,children:e.subscribed?(0,$.jsx)(Qe,{className:`h-4 w-4 text-primary`}):(0,$.jsx)(J,{className:`h-4 w-4 text-muted-foreground`})})},mn={comment:Ee,field_change:st,task:S,event:Ye,system:ye,email:pe,call:ce},hn={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`},gn=[{value:`all`,label:`All Activity`},{value:`comments_only`,label:`Comments Only`},{value:`changes_only`,label:`Field Changes`},{value:`tasks_only`,label:`Tasks Only`}];function _n(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 vn(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 yn=({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[m,h]=Q.useState(`all`),[g,_]=Q.useState(``),[v,y]=Q.useState(!1),[b,S]=Q.useState(!1),C=n??m,w=t?.showFilterToggle!==!1,E=t?.showCommentInput!==!1&&!!s,D=t?.enableReactions??!1,O=t?.enableThreading??!1,k=t?.showSubscriptionToggle??!1,A=Q.useMemo(()=>vn(e,C),[e,C]),j=Q.useMemo(()=>O?A.filter(e=>!e.parentId):A,[A,O]),M=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]),ee=Q.useCallback(e=>{r?r(e):h(e)},[r]),te=Q.useCallback(async()=>{let e=g.trim();if(!(!e||!s)){y(!0);try{await s(e),_(``)}finally{y(!1)}}},[g,s]),P=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),te())},[te]),F=Q.useCallback(async()=>{if(a){S(!0);try{await a()}finally{S(!1)}}},[a]);return(0,$.jsxs)(B,{className:Z(``,p),children:[(0,$.jsx)(H,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(T,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(et,{className:`h-4 w-4`}),`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)(pn,{subscription:u,onToggle:d})})]})}),(0,$.jsxs)(x,{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=>ee(e.target.value),"aria-label":`Filter activity`,children:gn.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),E&&(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:`Leave a comment… (Ctrl+Enter to submit)`,value:g,onChange:e=>_(e.target.value),onKeyDown:P,disabled:v}),(0,$.jsx)(N,{size:`icon`,variant:`default`,onClick:te,disabled:!g.trim()||v,className:`shrink-0 self-end`,"aria-label":`Submit comment`,children:(0,$.jsx)(Ee,{className:`h-4 w-4`})})]}),A.length===0?f?null:(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:j.map(e=>{let t=mn[e.type]||ye,n=hn[e.type]||`bg-gray-100 text-gray-600`,r=M.get(e.id)??[];return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:Z(`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,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`via `,e.source]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_n(e.createdAt)}),e.edited&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:`(edited)`}),e.pinned&&(0,$.jsx)(`span`,{className:`text-xs text-amber-600`,children:`📌 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)(cn,{change:e},t))}),D&&e.reactions&&e.reactions.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(un,{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)(un,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),O&&(e.replyCount??0)>0&&(0,$.jsx)(fn,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,$.jsx)(`div`,{className:`text-center pt-2`,children:(0,$.jsxs)(N,{variant:`ghost`,size:`sm`,onClick:F,disabled:b,"aria-label":`Load more activity`,children:[b?(0,$.jsx)(he,{className:`h-4 w-4 animate-spin mr-1`}):(0,$.jsx)(Xe,{className:`h-4 w-4 mr-1`}),`Load more`]})})]})]})},bn=({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),[v,y]=Q.useState(_);return m===`right`||m===`left`?v&&g?(0,$.jsx)(`div`,{className:Z(`flex items-start pt-4`,m===`right`?`border-l`:`border-r`,p),children:(0,$.jsx)(N,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>y(!1),"aria-label":`Open discussion panel`,children:(0,$.jsx)(Ke,{className:`h-4 w-4`})})}):(0,$.jsxs)(`div`,{className:Z(`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)(Ee,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:`Discussion`})]}),g&&(0,$.jsx)(N,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>y(!0),"aria-label":`Close discussion panel`,children:(0,$.jsx)(Ze,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,$.jsx)(yn,{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:Z(``,p),children:g&&v?(0,$.jsxs)(N,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>y(!1),"aria-label":`Show discussion`,children:[(0,$.jsx)(Ee,{className:`h-4 w-4`}),(0,$.jsxs)(`span`,{children:[`Show Discussion (`,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)(Ee,{className:`h-4 w-4`}),`Discussion`]}),(0,$.jsx)(N,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>y(!0),"aria-label":`Hide discussion`,children:(0,$.jsx)(ee,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(yn,{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})]})})};r.register(`detail-view`,sn,{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:[]}}),r.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`}]}),r.register(`related-list`,Jt,{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`}]}),r.register(`detail`,sn,{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 xn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function Sn(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var Cn=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],wn=(0,Q.forwardRef)(({schema:e,className:t,dataSource:n,onRefresh:r,recordCount:i,userActions:a,designMode:o,selectedWidgetId:s,onWidgetClick:c,...l},u)=>{let d=e.columns||4,f=e.gap||4,[p,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!1),v=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let e=()=>_(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let y=(0,Q.useCallback)(()=>{r&&(h(!0),r(),setTimeout(()=>h(!1),600))},[r]);(0,Q.useEffect)(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!r))return v.current=setInterval(y,e.refreshInterval*1e3),()=>{v.current&&clearInterval(v.current)}},[e.refreshInterval,r,y]);let b=(0,Q.useCallback)((e,t)=>{!o||!c||!t||(e.stopPropagation(),c(t))},[o,c]),S=(0,Q.useCallback)((t,n,r)=>{if(!o||!c)return;let i=e.widgets||[];if(t.key===`Enter`||t.key===` `)t.preventDefault(),c(n??null);else if(t.key===`ArrowRight`||t.key===`ArrowDown`){t.preventDefault();let e=r+1<i.length?i[r+1]:null;e?.id&&c(e.id)}else if(t.key===`ArrowLeft`||t.key===`ArrowUp`){t.preventDefault();let e=r-1>=0?i[r-1]:null;e?.id&&c(e.id)}else t.key===`Escape`&&(t.preventDefault(),c(null))},[o,c,e.widgets]),C=(0,Q.useCallback)(e=>{!o||!c||e.target===e.currentTarget&&c(null)},[o,c]),w=(e,t,n)=>{let r=e.layout?{...e.layout,w:Math.min(e.layout.w,d)}:void 0,i=(()=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`bar`||t===`line`||t===`area`||t===`pie`||t===`donut`||t===`scatter`){let r=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(xn(r)){let n=r.aggregate,o=n?{field:e.valueField||n.field,function:e.aggregate||n.function,groupBy:e.categoryField||n.groupBy}:void 0,s=o?.field||a;return{type:`object-chart`,chartType:t,objectName:e.object||r.object,aggregate:o,xAxisKey:i,series:[{dataKey:s}],colors:Cn,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(!r&&e.object){let n=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0;return{type:`object-chart`,chartType:t,objectName:e.object,aggregate:n,xAxisKey:i,series:[{dataKey:e.valueField||`value`}],colors:Cn,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}return{type:`chart`,chartType:t,data:Array.isArray(r)?r:r?.items||[],xAxisKey:i,series:[{dataKey:a}],colors:Cn,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(t===`table`){let t=e.data||n.data;if(xn(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(xn(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}})(),a=e.type===`metric`,c=Sn(e.title),l=Sn(e.description),u=e.id||c||`widget-${t}`,f=o&&s===e.id,p=o?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":f,"aria-label":`Widget: ${c||`Widget ${t+1}`}`,onClick:t=>b(t,e.id),onKeyDown:n=>S(n,e.id,t)}:{},h=o?Z(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,f?`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 a?(0,$.jsxs)(`div`,{className:Z(`h-full w-full`,o&&`relative`,h),style:!g&&r?{gridColumn:`span ${r.w}`,gridRow:`span ${r.h}`}:void 0,...p,children:[(0,$.jsx)(m,{schema:i,className:Z(`h-full w-full`,o&&`pointer-events-none`)}),o&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]},u):(0,$.jsxs)(B,{className:Z(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,n&&`w-full`,o&&`relative`,h),style:!g&&r?{gridColumn:`span ${r.w}`,gridRow:`span ${r.h}`}:void 0,...p,children:[c&&(0,$.jsxs)(H,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,$.jsx)(T,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:c,children:c}),l&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:l})]}),(0,$.jsx)(x,{className:`p-0`,children:(0,$.jsx)(`div`,{className:Z(`h-full w-full`,`p-3 sm:p-4 md:p-6`,o&&`pointer-events-none`),children:(0,$.jsx)(m,{schema:i})})}),o&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]},u)},E=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:Sn(e.title)}),e.header.showDescription!==!1&&e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:Sn(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)=>(0,$.jsx)(N,{variant:`outline`,size:`sm`,children:e.label},t))})]}),D=i!==void 0&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.toLocaleString(),` records`]}),O=a?JSON.stringify(a):void 0,k=r&&(0,$.jsxs)(`div`,{className:Z(`flex items-center justify-end gap-3 mb-2`,!g&&`col-span-full`),children:[D,(0,$.jsxs)(N,{variant:`outline`,size:`sm`,onClick:y,disabled:p,"aria-label":`Refresh dashboard`,children:[(0,$.jsx)(P,{className:Z(`h-4 w-4 mr-2`,p&&`animate-spin`)}),p?`Refreshing…`:`Refresh All`]})]});if(g){let n=e.widgets?.filter(e=>e.type===`metric`)||[],r=e.widgets?.filter(e=>e.type!==`metric`)||[];return(0,$.jsxs)(`div`,{ref:u,className:Z(`flex flex-col gap-4 px-4`,t),"data-user-actions":O,onClick:C,...l,children:[E,k,n.length>0&&(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:C,children:n.map((e,t)=>w(e,t))}),r.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:C,children:r.map((e,t)=>w(e,t,!0))})]})}return(0,$.jsxs)(`div`,{ref:u,className:Z(`grid auto-rows-min`,`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,t),style:{...d>4&&{gridTemplateColumns:`repeat(${d}, minmax(0, 1fr))`},gap:`${f*.25}rem`},"data-user-actions":O,onClick:C,...l,children:[E,k,e.widgets?.map((e,t)=>w(e,t))]})});function Tn(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function En(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function Dn(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=Tn(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=En(r,u,s[0]),f=En(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 On(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=Tn(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=jn(d,0,s-r),f=jn(f,0,l-i),{x:d,y:f}}function kn(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=Tn(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function An(e,t,n){let{margin:r,rowHeight:i}=e,a=Tn(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 jn(e,t,n){return Math.max(Math.min(e,n),t)}function Mn(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 Nn(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&Mn(r,t))return r}}function Pn(e,t){return e.filter(e=>Mn(e,t))}function Fn(e,t){return t===`horizontal`?Ln(e):t===`vertical`||t===`wrap`?In(e):[...e]}function In(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function Ln(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function Rn(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 zn(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&r.i===t)return r}}function Bn(e){return e.filter(e=>e.static===!0)}function Vn(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 Hn(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t[n]=Vn(r))}return t}function Un(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 Wn(e,t,n){let r=zn(e,t);return r?(r=n(Vn(r)),[Un(e,r),r]):[[...e],null]}function Gn(e,t){let n=Bn(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(;Nn(n,i);)i.y++}return e}function Kn(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=Fn(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=Pn(d,t),p=f.length>0;if(p&&c)return Hn(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?qn(m,n,t,i,o):qn(m,t,n,i,o)))}return m}function qn(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=Nn(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 Kn(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return Kn(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 Kn(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]:Kn(e,n,l,u,r,c,i)}function Jn(e,t,n){return Math.max(t,Math.min(n,e))}var Yn=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:Jn(t,0,Math.max(0,r-e.w)),y:Jn(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:Jn(t,1,Math.max(1,o)),h:Jn(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:Jn(t,e.minW??1,e.maxW??1/0),h:Jn(n,e.minH??1,e.maxH??1/0)}}}];function Xn(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 Zn(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 Qn({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 $n({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function er(e){return e*100+`%`}function tr(e,t,n,r){return e+n>r?t:n}function nr(e,t,n){return e<0?t:n}function rr(e){return Math.max(0,e)}function ir(e){return Math.max(0,e)}var ar=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:nr(o,e.height,i),top:ir(o)}},or=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:tr(e.left,e.width,o,n),left:rr(i)}},sr=(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:ir(r),left:0}:{height:i,width:a,top:ir(r),left:o}},cr=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:nr(r,e.height,a),top:ir(r)}},lr={n:ar,ne:(e,t,n)=>ar(e,or(e,t,n)),e:or,se:(e,t,n)=>cr(e,or(e,t,n)),s:cr,sw:(e,t,n)=>cr(e,sr(e,t)),w:sr,nw:(e,t,n)=>ar(e,sr(e,t))};function ur(e,t,n,r){let i=lr[e];return i?i(t,{...t,...n},r):n}var dr={type:`transform`,scale:1,calcStyle(e){return Qn(e)}},fr={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},pr={enabled:!0,bounded:!1,threshold:3},mr={enabled:!0,handles:[`se`]},hr={enabled:!1,defaultItem:{w:1,h:1}};function gr(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??Bn(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;Mn(t,o)&&gr(e,o,n+t[a],r,s)}}t[r]=n}function _r(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&&!Nn(e,t);)t.y--;let i;for(;(i=Nn(e,t))!==void 0;)gr(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function vr(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!Nn(e,t);)t.x--;let i;for(;(i=Nn(e,t))!==void 0;)if(gr(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!Nn(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var yr={type:`vertical`,allowOverlap:!1,compact(e,t){let n=Bn(e),r=Rn(n),i=In(e),a=Array(e.length);for(let t=0;t<i.length;t++){let o=i[t];if(o===void 0)continue;let s=Vn(o);s.static||(s=_r(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}},br={type:`horizontal`,allowOverlap:!1,compact(e,t){let n=Bn(e),r=Ln(e),i=Array(e.length);for(let a=0;a<r.length;a++){let o=r[a];if(o===void 0)continue;let s=Vn(o);s.static||(s=vr(n,s,t,r),n.push(s));let c=e.indexOf(o);i[c]=s,s.moved=!1}return i}},xr={type:null,allowOverlap:!1,compact(e,t){return Hn(e)}},Sr={...yr,allowOverlap:!0,compact(e,t){return Hn(e)}},Cr={...br,allowOverlap:!0,compact(e,t){return Hn(e)}},wr={...xr,allowOverlap:!0};function Tr(e,t=!1,n=!1){let r;return r=t?e===`vertical`?Sr:e===`horizontal`?Cr:wr:e===`vertical`?yr:e===`horizontal`?br:xr,n?{...r,preventCollision:n}:r}function Er(e){return Object.keys(e).sort((t,n)=>e[t]-e[n])}function Dr(e,t){let n=Er(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 Or(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function kr(e,t,n,r,i,a){let o=e[n];if(o)return Hn(o);let s=e[r],c=Er(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=Gn(Hn(s||[]),{cols:i});return(typeof a==`object`&&a?a:Tr(a)).compact(u,i)}function Ar(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 jr=t(((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 ee=_(r(A,{createIsNestedEqual:function(){return o}}));function te(e,t){return ee(e,t,void 0)}var P=_(j);function F(e,t){return P(e,t,new WeakMap)}var I=_(r(j,{createIsNestedEqual:function(){return o}}));function ne(e,t){return I(e,t,new WeakMap)}function re(e){return _(r(A,e(A)))}function ie(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=F,e.circularShallowEqual=ne,e.createCustomCircularEqual=ie,e.createCustomEqual=re,e.deepEqual=N,e.sameValueZeroEqual=o,e.shallowEqual=te,Object.defineProperty(e,`__esModule`,{value:!0})}))}));function Mr(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)return l(),typeof ResizeObserver<`u`&&(c.current=new ResizeObserver(e=>{let t=e[0];if(t){let e=t.contentRect.width;i(e)}}),c.current.observe(e)),()=>{c.current&&=(c.current.disconnect(),null)}},[l]),{width:r,mounted:a,containerRef:s,measureWidth:l}}var Nr=t(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Pr=t(((e,t)=>{var n=Nr();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}})),Fr=t(((e,t)=>{t.exports=Pr()()})),Ir=t(((e,t)=>{function n(e){var t,r,i=``;if(typeof e==`string`||typeof e==`number`)i+=e;else if(typeof e==`object`)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=n(e[t]))&&(i&&(i+=` `),i+=r)}else for(r in e)e[r]&&(i&&(i+=` `),i+=r);return i}function r(){for(var e,t,r=0,i=``,a=arguments.length;r<a;r++)(e=arguments[r])&&(t=n(e))&&(i&&(i+=` `),i+=t);return i}t.exports=r,t.exports.clsx=r})),Lr=t((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.`)}})),Rr=t((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()})),zr=t((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=Lr(),n=r(Rr());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
|
-
`,t.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
|
|
5
|
-
`,e.getElementsByTagName(`head`)[0].appendChild(t)),e.body&&S(e.body,`react-draggable-transparent-selection`)}function b(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{x(e)}):x(e)}function x(e){if(e)try{if(e.body&&C(e.body,`react-draggable-transparent-selection`),e.selection)e.selection.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function S(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function C(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}})),Br=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.canDragX=a,e.canDragY=o,e.createCoreData=c,e.createDraggableData=l,e.getBoundPosition=r,e.getControlPosition=s,e.snapToGrid=i;var t=Lr(),n=zr();function r(e,r,i){if(!e.props.bounds)return[r,i];let{bounds:a}=e.props;a=typeof a==`string`?a:u(a);let o=d(e);if(typeof a==`string`){let{ownerDocument:e}=o,r=e.defaultView,i;if(i=a===`parent`?o.parentNode:o.getRootNode().querySelector(a),!(i instanceof r.HTMLElement))throw Error(`Bounds selector "`+a+`" could not find an element.`);let s=i,c=r.getComputedStyle(o),l=r.getComputedStyle(s);a={left:-o.offsetLeft+(0,t.int)(l.paddingLeft)+(0,t.int)(c.marginLeft),top:-o.offsetTop+(0,t.int)(l.paddingTop)+(0,t.int)(c.marginTop),right:(0,n.innerWidth)(s)-(0,n.outerWidth)(o)-o.offsetLeft+(0,t.int)(l.paddingRight)-(0,t.int)(c.marginRight),bottom:(0,n.innerHeight)(s)-(0,n.outerHeight)(o)-o.offsetTop+(0,t.int)(l.paddingBottom)-(0,t.int)(c.marginBottom)}}return(0,t.isNum)(a.right)&&(r=Math.min(r,a.right)),(0,t.isNum)(a.bottom)&&(i=Math.min(i,a.bottom)),(0,t.isNum)(a.left)&&(r=Math.max(r,a.left)),(0,t.isNum)(a.top)&&(i=Math.max(i,a.top)),[r,i]}function i(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function a(e){return e.props.axis===`both`||e.props.axis===`x`}function o(e){return e.props.axis===`both`||e.props.axis===`y`}function s(e,t,r){let i=typeof t==`number`?(0,n.getTouch)(e,t):null;if(typeof t==`number`&&!i)return null;let a=d(r),o=r.props.offsetParent||a.offsetParent||a.ownerDocument.body;return(0,n.offsetXYFromParent)(i||e,o,r.props.scale)}function c(e,n,r){let i=!(0,t.isNum)(e.lastX),a=d(e);return i?{node:a,deltaX:0,deltaY:0,lastX:n,lastY:r,x:n,y:r}:{node:a,deltaX:n-e.lastX,deltaY:r-e.lastY,lastX:e.lastX,lastY:e.lastY,x:n,y:r}}function l(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function u(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function d(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}})),Vr=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=t;function t(){}})),Hr=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var t=u(i()),n=l(Fr()),r=l(b()),a=zr(),o=Br(),s=Lr(),c=l(Vr());function l(e){return e&&e.__esModule?e:{default:e}}function u(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(u=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function d(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){var t=p(e,`string`);return typeof t==`symbol`?t:t+``}function p(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var m={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},h=m.mouse,g=class extends t.Component{constructor(){super(...arguments),d(this,`dragging`,!1),d(this,`lastX`,NaN),d(this,`lastY`,NaN),d(this,`touchIdentifier`,null),d(this,`mounted`,!1),d(this,`handleDragStart`,e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&typeof e.button==`number`&&e.button!==0)return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!(0,a.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,a.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=(0,a.getTouchIdentifier)(e);this.touchIdentifier=r;let i=(0,o.getControlPosition)(e,r,this);if(i==null)return;let{x:s,y:l}=i,u=(0,o.createCoreData)(this,s,l);(0,c.default)(`DraggableCore: handleDragStart: %j`,u),(0,c.default)(`calling`,this.props.onStart),!(this.props.onStart(e,u)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,a.addUserSelectStyles)(n),this.dragging=!0,this.lastX=s,this.lastY=l,(0,a.addEvent)(n,h.move,this.handleDrag),(0,a.addEvent)(n,h.stop,this.handleDragStop))}),d(this,`handleDrag`,e=>{let t=(0,o.getControlPosition)(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=(0,o.snapToGrid)(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=(0,o.createCoreData)(this,n,r);if((0,c.default)(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}return}this.lastX=n,this.lastY=r}),d(this,`handleDragStop`,e=>{if(!this.dragging)return;let t=(0,o.getControlPosition)(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=(0,o.snapToGrid)(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=(0,o.createCoreData)(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let s=this.findDOMNode();s&&this.props.enableUserSelectHack&&(0,a.scheduleRemoveUserSelectStyles)(s.ownerDocument),(0,c.default)(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,s&&((0,c.default)(`DraggableCore: Removing handlers`),(0,a.removeEvent)(s.ownerDocument,h.move,this.handleDrag),(0,a.removeEvent)(s.ownerDocument,h.stop,this.handleDragStop))}),d(this,`onMouseDown`,e=>(h=m.mouse,this.handleDragStart(e))),d(this,`onMouseUp`,e=>(h=m.mouse,this.handleDragStop(e))),d(this,`onTouchStart`,e=>(h=m.touch,this.handleDragStart(e))),d(this,`onTouchEnd`,e=>(h=m.touch,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&(0,a.addEvent)(e,m.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;(0,a.removeEvent)(t,m.mouse.move,this.handleDrag),(0,a.removeEvent)(t,m.touch.move,this.handleDrag),(0,a.removeEvent)(t,m.mouse.stop,this.handleDragStop),(0,a.removeEvent)(t,m.touch.stop,this.handleDragStop),(0,a.removeEvent)(e,m.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,a.scheduleRemoveUserSelectStyles)(t)}}findDOMNode(){return this.props?.nodeRef?this.props?.nodeRef?.current:r.default.findDOMNode(this)}render(){return t.cloneElement(t.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};e.default=g,d(g,`displayName`,`DraggableCore`),d(g,`propTypes`,{allowAnyClick:n.default.bool,allowMobileScroll:n.default.bool,children:n.default.node.isRequired,disabled:n.default.bool,enableUserSelectHack:n.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:n.default.arrayOf(n.default.number),handle:n.default.string,cancel:n.default.string,nodeRef:n.default.object,onStart:n.default.func,onDrag:n.default.func,onStop:n.default.func,onMouseDown:n.default.func,scale:n.default.number,className:s.dontSetMe,style:s.dontSetMe,transform:s.dontSetMe}),d(g,`defaultProps`,{allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1})})),Ur=t((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),Object.defineProperty(e,`DraggableCore`,{enumerable:!0,get:function(){return l.default}}),e.default=void 0;var t=f(i()),n=d(Fr()),r=d(b()),a=Ir(),o=zr(),s=Br(),c=Lr(),l=d(Hr()),u=d(Vr());function d(e){return e&&e.__esModule?e:{default:e}}function f(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(f=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},p.apply(null,arguments)}function m(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e){var t=g(e,`string`);return typeof t==`symbol`?t:t+``}function g(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var _=class extends t.Component{static getDerivedStateFromProps(e,t){let{position:n}=e,{prevPropsPosition:r}=t;return n&&(!r||n.x!==r.x||n.y!==r.y)?((0,u.default)(`Draggable: getDerivedStateFromProps %j`,{position:n,prevPropsPosition:r}),{x:n.x,y:n.y,prevPropsPosition:{...n}}):null}constructor(e){super(e),m(this,`onDragStart`,(e,t)=>{if((0,u.default)(`Draggable: onDragStart: %j`,t),this.props.onStart(e,(0,s.createDraggableData)(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),m(this,`onDrag`,(e,t)=>{if(!this.state.dragging)return!1;(0,u.default)(`Draggable: onDrag: %j`,t);let n=(0,s.createDraggableData)(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=(0,s.getBoundPosition)(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)}),m(this,`onDragStop`,(e,t)=>{if(!this.state.dragging||this.props.onStop(e,(0,s.createDraggableData)(this,t))===!1)return!1;(0,u.default)(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)}),this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){return this.props?.nodeRef?.current??r.default.findDOMNode(this)}render(){let{axis:e,bounds:n,children:r,defaultPosition:i,defaultClassName:c,defaultClassNameDragging:u,defaultClassNameDragged:d,position:f,positionOffset:m,scale:h,...g}=this.props,_={},v=null,y=!f||this.state.dragging,b=f||i,x={x:(0,s.canDragX)(this)&&y?this.state.x:b.x,y:(0,s.canDragY)(this)&&y?this.state.y:b.y};this.state.isElementSVG?v=(0,o.createSVGTransform)(x,m):_=(0,o.createCSSTransform)(x,m);let S=(0,a.clsx)(r.props.className||``,c,{[u]:this.state.dragging,[d]:this.state.dragged});return t.createElement(l.default,p({},g,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(r),{className:S,style:{...r.props.style,..._},transform:v}))}};e.default=_,m(_,`displayName`,`Draggable`),m(_,`propTypes`,{...l.default.propTypes,axis:n.default.oneOf([`both`,`x`,`y`,`none`]),bounds:n.default.oneOfType([n.default.shape({left:n.default.number,right:n.default.number,top:n.default.number,bottom:n.default.number}),n.default.string,n.default.oneOf([!1])]),defaultClassName:n.default.string,defaultClassNameDragging:n.default.string,defaultClassNameDragged:n.default.string,defaultPosition:n.default.shape({x:n.default.number,y:n.default.number}),positionOffset:n.default.shape({x:n.default.oneOfType([n.default.number,n.default.string]),y:n.default.oneOfType([n.default.number,n.default.string])}),position:n.default.shape({x:n.default.number,y:n.default.number}),className:c.dontSetMe,style:c.dontSetMe,transform:c.dontSetMe}),m(_,`defaultProps`,{...l.default.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1})})),Wr=t(((e,t)=>{var{default:n,DraggableCore:r}=Ur();t.exports=n,t.exports.default=n,t.exports.DraggableCore=r})),Gr=t((e=>{e.__esModule=!0,e.cloneElement=l;var t=n(i());function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?r(Object(n),!0).forEach(function(t){o(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){var t=c(e,`string`);return typeof t==`symbol`?t:t+``}function c(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e,n){return n.style&&e.props.style&&(n.style=a(a({},e.props.style),n.style)),n.className&&e.props.className&&(n.className=`${e.props.className} ${n.className}`),t.default.cloneElement(e,n)}})),Kr=t((e=>{e.__esModule=!0,e.resizableProps=void 0;var t=n(Fr());Wr();function n(e){return e&&e.__esModule?e:{default:e}}e.resizableProps={axis:t.default.oneOf([`both`,`x`,`y`,`none`]),className:t.default.string,children:t.default.element.isRequired,draggableOpts:t.default.shape({allowAnyClick:t.default.bool,cancel:t.default.string,children:t.default.node,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:typeof Element<`u`?t.default.instanceOf(Element):t.default.any,grid:t.default.arrayOf(t.default.number),handle:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number}),height:function(){var e=[...arguments];let[n]=e;return n.axis===`both`||n.axis===`y`?t.default.number.isRequired(...e):t.default.number(...e)},handle:t.default.oneOfType([t.default.node,t.default.func]),handleSize:t.default.arrayOf(t.default.number),lockAspectRatio:t.default.bool,maxConstraints:t.default.arrayOf(t.default.number),minConstraints:t.default.arrayOf(t.default.number),onResizeStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,resizeHandles:t.default.arrayOf(t.default.oneOf([`s`,`w`,`e`,`n`,`sw`,`nw`,`se`,`ne`])),transformScale:t.default.number,width:function(){var e=[...arguments];let[n]=e;return n.axis===`both`||n.axis===`x`?t.default.number.isRequired(...e):t.default.number(...e)}}})),qr=t((e=>{e.__esModule=!0,e.default=void 0;var t=s(i()),n=Wr(),r=Gr(),a=Kr(),o=[`children`,`className`,`draggableOpts`,`width`,`height`,`handle`,`handleSize`,`lockAspectRatio`,`axis`,`minConstraints`,`maxConstraints`,`onResize`,`onResizeStop`,`onResizeStart`,`resizeHandles`,`transformScale`];function s(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(s=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(null,arguments)}function l(e,t){if(e==null)return{};var n,r,i=u(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function u(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function f(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?d(Object(n),!0).forEach(function(t){p(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function p(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){var t=h(e,`string`);return typeof t==`symbol`?t:t+``}function h(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var g=class extends t.Component{constructor(){super(...arguments),this.handleRefs={},this.lastHandleRect=null,this.slack=null,this.lastSize=null}componentWillUnmount(){this.resetData()}resetData(){this.lastHandleRect=this.slack=this.lastSize=null}runConstraints(e,t){let{minConstraints:n,maxConstraints:r,lockAspectRatio:i}=this.props;if(!n&&!r&&!i)return[e,t];if(i){let n=this.props.width/this.props.height,r=e-this.props.width,i=t-this.props.height;Math.abs(r)>Math.abs(i*n)?t=e/n:e=t*n}let[a,o]=[e,t],[s,c]=this.slack||[0,0];return e+=s,t+=c,n&&(e=Math.max(n[0],e),t=Math.max(n[1],t)),r&&(e=Math.min(r[0],e),t=Math.min(r[1],t)),this.slack=[s+(a-e),c+(o-t)],[e,t]}resizeHandler(e,t){return(n,r)=>{let{node:i,deltaX:a,deltaY:o}=r;e===`onResizeStart`&&this.resetData();let s=(this.props.axis===`both`||this.props.axis===`x`)&&t!==`n`&&t!==`s`,c=(this.props.axis===`both`||this.props.axis===`y`)&&t!==`e`&&t!==`w`;if(!s&&!c)return;let l=t[0],u=t[t.length-1],d=i.getBoundingClientRect();if(this.lastHandleRect!=null){if(u===`w`){let e=d.left-this.lastHandleRect.left;a+=e}if(l===`n`){let e=d.top-this.lastHandleRect.top;o+=e}}this.lastHandleRect=d,u===`w`&&(a=-a),l===`n`&&(o=-o);let f=this.props.width+(s?a/this.props.transformScale:0),p=this.props.height+(c?o/this.props.transformScale:0);[f,p]=this.runConstraints(f,p),e===`onResizeStop`&&this.lastSize&&({width:f,height:p}=this.lastSize);let m=f!==this.props.width||p!==this.props.height;e!==`onResizeStop`&&(this.lastSize={width:f,height:p});let h=typeof this.props[e]==`function`?this.props[e]:null;h&&!(e===`onResize`&&!m)&&(n.persist?.(),h(n,{node:i,size:{width:f,height:p},handle:t})),e===`onResizeStop`&&this.resetData()}}renderResizeHandle(e,n){let{handle:r}=this.props;if(!r)return t.createElement(`span`,{className:`react-resizable-handle react-resizable-handle-${e}`,ref:n});if(typeof r==`function`)return r(e,n);let i=typeof r.type==`string`,a=f({ref:n},i?{}:{handleAxis:e});return t.cloneElement(r,a)}render(){let e=this.props,{children:i,className:a,draggableOpts:s,width:u,height:d,handle:p,handleSize:m,lockAspectRatio:h,axis:g,minConstraints:_,maxConstraints:v,onResize:y,onResizeStop:b,onResizeStart:x,resizeHandles:S,transformScale:C}=e,w=l(e,o);return(0,r.cloneElement)(i,f(f({},w),{},{className:`${a?`${a} `:``}react-resizable`,children:[...t.Children.toArray(i.props.children),...S.map(e=>{let r=this.handleRefs[e]??(this.handleRefs[e]=t.createRef());return t.createElement(n.DraggableCore,c({},s,{nodeRef:r,key:`resizableHandle-${e}`,onStop:this.resizeHandler(`onResizeStop`,e),onStart:this.resizeHandler(`onResizeStart`,e),onDrag:this.resizeHandler(`onResize`,e)}),this.renderResizeHandle(e,r))})]}))}};e.default=g,g.propTypes=a.resizableProps,g.defaultProps={axis:`both`,handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:[`se`],transformScale:1}})),Jr=t((e=>{e.__esModule=!0,e.default=void 0;var t=c(i()),n=s(Fr()),r=s(qr()),a=Kr(),o=[`handle`,`handleSize`,`onResize`,`onResizeStart`,`onResizeStop`,`draggableOpts`,`minConstraints`,`maxConstraints`,`lockAspectRatio`,`axis`,`width`,`height`,`resizeHandles`,`style`,`transformScale`];function s(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(c=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l.apply(null,arguments)}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=m(e,`string`);return typeof t==`symbol`?t:t+``}function m(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e,t){if(e==null)return{};var n,r,i=g(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function g(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var _=class extends t.Component{constructor(){super(...arguments),this.state={width:this.props.width,height:this.props.height,propsWidth:this.props.width,propsHeight:this.props.height},this.onResize=(e,t)=>{let{size:n}=t;this.props.onResize?(e.persist?.(),this.setState(n,()=>this.props.onResize&&this.props.onResize(e,t))):this.setState(n)}}static getDerivedStateFromProps(e,t){return t.propsWidth!==e.width||t.propsHeight!==e.height?{width:e.width,height:e.height,propsWidth:e.width,propsHeight:e.height}:null}render(){let e=this.props,{handle:n,handleSize:i,onResize:a,onResizeStart:s,onResizeStop:c,draggableOpts:u,minConstraints:f,maxConstraints:p,lockAspectRatio:m,axis:g,width:_,height:v,resizeHandles:y,style:b,transformScale:x}=e,S=h(e,o);return t.createElement(r.default,{axis:g,draggableOpts:u,handle:n,handleSize:i,height:this.state.height,lockAspectRatio:m,maxConstraints:p,minConstraints:f,onResizeStart:s,onResize:this.onResize,onResizeStop:c,resizeHandles:y,transformScale:x,width:this.state.width},t.createElement(`div`,l({},S,{style:d(d({},b),{},{width:this.state.width+`px`,height:this.state.height+`px`})})))}};e.default=_,_.propTypes=d(d({},a.resizableProps),{},{children:n.default.element})})),Yr=t(((e,t)=>{t.exports=function(){throw Error(`Don't instantiate Resizable directly! Use require('react-resizable').Resizable`)},t.exports.Resizable=qr().default,t.exports.ResizableBox=Jr().default})),Xr=Wr(),Zr=Yr(),Qr=jr();function $r(e){let{children:t,cols:n,containerWidth:r,margin:i,containerPadding:a,rowHeight:o,maxRows:s,isDraggable:c,isResizable:l,isBounded:u,static:d,useCSSTransforms:f=!0,usePercentages:p=!1,transformScale:m=1,positionStrategy:h,dragThreshold:g=0,droppingPosition:_,className:v=``,style:y,handle:b=``,cancel:x=``,x:S,y:C,w,h:T,minW:E=1,maxW:D=1/0,minH:O=1,maxH:k=1/0,i:A,resizeHandles:j,resizeHandle:M,constraints:N=Yn,layoutItem:ee,layout:te=[],onDragStart:P,onDrag:F,onDragStop:I,onResizeStart:ne,onResize:re,onResizeStop:ie}=e,[L,ae]=(0,Q.useState)(!1),[oe,R]=(0,Q.useState)(!1),B=(0,Q.useRef)(null),V=(0,Q.useRef)({left:0,top:0}),H=(0,Q.useRef)({top:0,left:0,width:0,height:0}),U=(0,Q.useRef)(void 0),W=(0,Q.useRef)(te);W.current=te;let se=(0,Q.useRef)(null),ce=(0,Q.useRef)(null),le=(0,Q.useRef)(!1),ue=(0,Q.useRef)({x:0,y:0}),G=(0,Q.useRef)(!1),K=(0,Q.useMemo)(()=>({cols:n,containerPadding:a,containerWidth:r,margin:i,maxRows:s,rowHeight:o}),[n,a,r,i,s,o]),q=(0,Q.useMemo)(()=>({cols:n,maxRows:s,containerWidth:r,containerHeight:0,rowHeight:o,margin:i,layout:[]}),[n,s,r,o,i]),de=(0,Q.useCallback)(()=>({...q,layout:W.current}),[q]),fe=(0,Q.useMemo)(()=>ee??{i:A,x:S,y:C,w,h:T,minW:E,maxW:D,minH:O,maxH:k},[ee,A,S,C,w,T,E,D,O,k]),pe=(0,Q.useCallback)(e=>{if(h?.calcStyle)return h.calcStyle(e);if(f)return Qn(e);let t=$n(e);return p?{...t,left:er(e.left/r),width:er(e.width/r)}:t},[h,f,p,r]),me=(0,Q.useCallback)((e,{node:t})=>{if(!P)return;let{offsetParent:n}=t;if(!n)return;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=i.left/m,o=r.left/m,s=i.top/m,c=r.top/m,l;if(h?.calcDragPosition){let t=e;l=h.calcDragPosition(t.clientX,t.clientY,t.clientX-i.left,t.clientY-i.top)}else l={left:a-o+n.scrollLeft,top:s-c+n.scrollTop};if(V.current=l,g>0){let t=e;ue.current={x:t.clientX,y:t.clientY},le.current=!0,G.current=!1,ae(!0);return}ae(!0);let u=kn(K,l.top,l.left),{x:d,y:f}=Xn(N,fe,u.x,u.y,de());P(A,d,f,{e,node:t,newPosition:l})},[P,m,K,h,g,N,fe,de,A]),he=(0,Q.useCallback)((e,{node:t,deltaX:n,deltaY:a})=>{if(!F||!L)return;let s=e;if(le.current&&!G.current){let n=s.clientX-ue.current.x,r=s.clientY-ue.current.y;if(Math.hypot(n,r)<g)return;if(G.current=!0,le.current=!1,P){let n=kn(K,V.current.top,V.current.left),{x:r,y:i}=Xn(N,fe,n.x,n.y,de());P(A,r,i,{e,node:t,newPosition:V.current})}}let c=V.current.top+a,l=V.current.left+n;if(u){let{offsetParent:e}=t;if(e){let t=e.clientHeight-En(T,o,i[1]);c=jn(c,0,t);let n=r-En(w,Tn(K),i[0]);l=jn(l,0,n)}}let d={top:c,left:l};V.current=d;let f=kn(K,c,l),{x:p,y:m}=Xn(N,fe,f.x,f.y,de());F(A,p,m,{e,node:t,newPosition:d})},[F,P,L,g,u,T,o,i,K,r,w,A,N,fe,de]),J=(0,Q.useCallback)((e,{node:t})=>{if(!I||!L)return;let n=le.current;if(le.current=!1,G.current=!1,ue.current={x:0,y:0},n){ae(!1),V.current={left:0,top:0};return}let{left:r,top:i}=V.current,a={top:i,left:r};ae(!1),V.current={left:0,top:0};let o=kn(K,i,r),{x:s,y:c}=Xn(N,fe,o.x,o.y,de());I(A,s,c,{e,node:t,newPosition:a})},[I,L,K,N,fe,de,A]);se.current=me,ce.current=he;let Y=(0,Q.useCallback)((e,{node:t,size:n,handle:i},a,o)=>{let s=o===`onResizeStart`?ne:o===`onResize`?re:ie;if(!s)return;let c;c=t?ur(i,a,n,r):{...n,top:a.top,left:a.left},H.current=c;let l=An(K,c.width,c.height),{w:u,h:d}=Zn(N,fe,l.w,l.h,i,de());s(A,u,d,{e:e.nativeEvent,node:t,size:c,handle:i})},[ne,re,ie,r,K,A,N,fe,de]),ge=(0,Q.useCallback)((e,t)=>{R(!0);let n=Dn(K,S,C,w,T);Y(e,{...t,handle:t.handle},n,`onResizeStart`)},[Y,K,S,C,w,T]),_e=(0,Q.useCallback)((e,t)=>{let n=Dn(K,S,C,w,T);Y(e,{...t,handle:t.handle},n,`onResize`)},[Y,K,S,C,w,T]),ve=(0,Q.useCallback)((e,t)=>{R(!1),H.current={top:0,left:0,width:0,height:0};let n=Dn(K,S,C,w,T);Y(e,{...t,handle:t.handle},n,`onResizeStop`)},[Y,K,S,C,w,T]);(0,Q.useEffect)(()=>{if(!_)return;let e=B.current;if(!e)return;let t=U.current||{left:0,top:0},n=L&&(_.left!==t.left||_.top!==t.top);if(!L){let t={node:e,deltaX:_.left,deltaY:_.top,lastX:0,lastY:0,x:_.left,y:_.top};se.current?.(_.e,t)}else if(n){let t={node:e,deltaX:_.left-V.current.left,deltaY:_.top-V.current.top,lastX:V.current.left,lastY:V.current.top,x:_.left,y:_.top};ce.current?.(_.e,t)}U.current=_},[_,L,A]);let ye=Dn(K,S,C,w,T,L?V.current:null,oe?H.current:null),be=Q.Children.only(t),xe=Dn(K,0,0,1,1),Se=[xe.width,xe.height],Ce=[1/0,1/0],we=be.props,Te=we.className,Ee=we.style,De=Q.cloneElement(be,{ref:B,className:z(`react-grid-item`,Te,v,{static:d,resizing:oe,"react-draggable":c,"react-draggable-dragging":L,dropping:!!_,cssTransforms:f}),style:{...y,...Ee,...pe(ye)}}),Oe=M;return De=(0,$.jsx)(Zr.Resizable,{draggableOpts:{disabled:!l},className:l?void 0:`react-resizable-hide`,width:ye.width,height:ye.height,minConstraints:Se,maxConstraints:Ce,onResizeStart:ge,onResize:_e,onResizeStop:ve,transformScale:m,resizeHandles:j,handle:Oe,children:De}),De=(0,$.jsx)(Xr.DraggableCore,{disabled:!c,onStart:me,onDrag:he,onStop:J,handle:b,cancel:`.react-resizable-handle`+(x?`,`+x:``),scale:m,nodeRef:B,children:De}),De}var ei=()=>{},ti=`react-grid-layout`,ni=!1;try{ni=/firefox/i.test(navigator.userAgent)}catch{}function ri(e,t){let n=Q.Children.toArray(e),r=Q.Children.toArray(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t?.key!==i?.key)return!1}return!0}function ii(e,t,n,r){let i=[],a=new Set;Q.Children.forEach(t,t=>{if(!Q.isValidElement(t)||t.key===null)return;let n=String(t.key);a.add(n);let r=e.find(e=>e.i===n);if(r)i.push(Vn(r));else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Rn(i),w:1,h:1})}});let o=Gn(i,{cols:n});return r.compact(o,n)}function ai(e){let{children:t,width:n,gridConfig:r,dragConfig:i,resizeConfig:a,dropConfig:o,positionStrategy:s=dr,compactor:c,constraints:l=Yn,layout:u=[],droppingItem:d,autoSize:f=!0,className:p=``,style:m={},innerRef:h,onLayoutChange:g=ei,onDragStart:_=ei,onDrag:v=ei,onDragStop:y=ei,onResizeStart:b=ei,onResize:x=ei,onResizeStop:S=ei,onDrop:C=ei,onDropDragOver:w=ei}=e,T=(0,Q.useMemo)(()=>({...fr,...r}),[r]),E=(0,Q.useMemo)(()=>({...pr,...i}),[i]),D=(0,Q.useMemo)(()=>({...mr,...a}),[a]),O=(0,Q.useMemo)(()=>({...hr,...o}),[o]),{cols:k,rowHeight:A,maxRows:j,margin:M,containerPadding:N}=T,{enabled:ee,bounded:te,handle:P,cancel:F,threshold:I}=E,{enabled:ne,handles:re,handleComponent:ie}=D,{enabled:L,defaultItem:ae,onDragOver:oe}=O,R=c??Tr(`vertical`),B=R.type,V=R.allowOverlap,H=R.preventCollision??!1,U=(0,Q.useMemo)(()=>d??{i:`__dropping-elem__`,...ae},[d,ae]),W=s.type===`transform`,se=s.scale,ce=N??M,[le,ue]=(0,Q.useState)(!1),[G,K]=(0,Q.useState)(()=>ii(u,t,k,R)),[q,de]=(0,Q.useState)(null),[fe,pe]=(0,Q.useState)(!1),[me,he]=(0,Q.useState)(null),[J,Y]=(0,Q.useState)(),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(0),be=(0,Q.useRef)(G),xe=(0,Q.useRef)(u),Se=(0,Q.useRef)(t),Ce=(0,Q.useRef)(B),we=(0,Q.useRef)(G);we.current=G,(0,Q.useEffect)(()=>{ue(!0),(0,Qr.deepEqual)(G,u)||g(G)},[]),(0,Q.useEffect)(()=>{if(q||me)return;let e=!(0,Qr.deepEqual)(u,xe.current),n=!ri(t,Se.current),r=B!==Ce.current;if(e||n||r){let n=ii(e?u:G,t,k,R);(0,Qr.deepEqual)(n,G)||K(n)}xe.current=u,Se.current=t,Ce.current=B},[u,t,k,B,R,q,me,G]),(0,Q.useEffect)(()=>{!q&&!(0,Qr.deepEqual)(G,be.current)&&(be.current=G,g(G.filter(e=>e.i!==U.i)))},[G,q,g,U.i]);let Te=(0,Q.useMemo)(()=>{if(!f)return;let e=Rn(G),t=ce[1];return e*A+(e-1)*M[1]+t*2+`px`},[f,G,A,M,ce]),Ee=(0,Q.useCallback)((e,t,n,r)=>{let i=we.current,a=zn(i,e);if(!a)return;let o={w:a.w,h:a.h,x:a.x,y:a.y,i:e};ge.current=Vn(a),ve.current=i,de(o),_(i,a,a,null,r.e,r.node)},[_]),De=(0,Q.useCallback)((e,t,n,r)=>{let i=we.current,a=ge.current,o=zn(i,e);if(!o)return;let s={w:o.w,h:o.h,x:o.x,y:o.y,i:e},c=Kn(i,o,t,n,!0,H,B,k,V);v(c,a,o,s,r.e,r.node),K(R.compact(c,k)),de(s)},[H,B,k,V,R,v]),Oe=(0,Q.useCallback)((e,t,n,r)=>{if(!q)return;let i=we.current,a=ge.current,o=zn(i,e);if(!o)return;let s=Kn(i,o,t,n,!0,H,B,k,V),c=R.compact(s,k);y(c,a,o,null,r.e,r.node);let l=ve.current;ge.current=null,ve.current=null,de(null),K(c),l&&!(0,Qr.deepEqual)(l,c)&&g(c)},[q,H,B,k,V,R,y,g]),ke=(0,Q.useCallback)((e,t,n,r)=>{let i=we.current,a=zn(i,e);a&&(_e.current=Vn(a),ve.current=i,pe(!0),b(i,a,a,null,r.e,r.node))},[b]),Ae=(0,Q.useCallback)((e,t,n,r)=>{let i=we.current,a=_e.current,{handle:o}=r,s=!1,c,l,[u,d]=Wn(i,e,e=>(c=e.x,l=e.y,[`sw`,`w`,`nw`,`n`,`ne`].includes(o)&&([`sw`,`nw`,`w`].includes(o)&&(c=e.x+(e.w-t),t=e.x!==c&&c<0?e.w:t,c=c<0?0:c),[`ne`,`n`,`nw`].includes(o)&&(l=e.y+(e.h-n),n=e.y!==l&&l<0?e.h:n,l=l<0?0:l),s=!0),H&&!V&&Pn(i,{...e,w:t,h:n,x:c??e.x,y:l??e.y}).filter(t=>t.i!==e.i).length>0&&(l=e.y,n=e.h,c=e.x,t=e.w,s=!1),e.w=t,e.h=n,e));if(!d)return;let f=u;s&&c!==void 0&&l!==void 0&&(f=Kn(u,d,c,l,!0,H,B,k,V));let p={w:d.w,h:d.h,x:d.x,y:d.y,i:e,static:!0};x(f,a,d,p,r.e,r.node),K(R.compact(f,k)),de(p)},[H,B,k,V,R,x]),je=(0,Q.useCallback)((e,t,n,r)=>{let i=we.current,a=_e.current,o=zn(i,e),s=R.compact(i,k);S(s,a,o??null,null,r.e,r.node);let c=ve.current;_e.current=null,ve.current=null,de(null),pe(!1),K(s),c&&!(0,Qr.deepEqual)(c,s)&&g(s)},[k,R,S,g]),Me=(0,Q.useCallback)(()=>{let e=we.current;if(!e.some(e=>e.i===U.i)){he(null),de(null),Y(void 0);return}K(R.compact(e.filter(e=>e.i!==U.i),k)),he(null),de(null),Y(void 0)},[U.i,k,R]),Ne=(0,Q.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),ni&&!e.nativeEvent.target?.classList.contains(ti))return!1;let t=oe?oe(e.nativeEvent):w(e);if(t===!1)return me&&Me(),!1;let{dragOffsetX:r=0,dragOffsetY:i=0,...a}=t??{},o={...U,...a},s=e.currentTarget.getBoundingClientRect(),c={cols:k,margin:M,maxRows:j,rowHeight:A,containerWidth:n,containerPadding:ce},l=Tn(c),u=En(o.w,l,M[0]),d=En(o.h,A,M[1]),f=u/2,p=d/2,m=e.clientX-s.left+r-f,h=e.clientY-s.top+i-p,g=Math.max(0,m),_=Math.max(0,h),v={left:g/se,top:_/se,e:e.nativeEvent};if(me)J&&(J.left!==v.left||J.top!==v.top)&&Y(v);else{let e=On(c,_,g,o.w,o.h);he((0,$.jsx)(`div`,{},o.i)),Y(v),K([...we.current,{...o,x:e.x,y:e.y,static:!1,isDraggable:!0}])}},[me,J,U,oe,w,Me,se,k,M,j,A,n,ce]),Pe=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),ye.current--,ye.current<0&&(ye.current=0),ye.current===0&&Me()},[Me]),Fe=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),ye.current++},[]),Ie=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=we.current,n=t.find(e=>e.i===U.i);ye.current=0,Me(),C(t,n,e.nativeEvent)},[U.i,Me,C]),Le=(0,Q.useCallback)((e,t)=>{if(!e||!e.key)return null;let r=zn(G,String(e.key));if(!r)return null;let i=typeof r.isDraggable==`boolean`?r.isDraggable:!r.static&&ee,a=typeof r.isResizable==`boolean`?r.isResizable:!r.static&&ne,o=r.resizeHandles||[...re],c=i&&te&&r.isBounded!==!1,u=ie;return(0,$.jsx)($r,{containerWidth:n,cols:k,margin:M,containerPadding:ce,maxRows:j,rowHeight:A,cancel:F,handle:P,onDragStart:Ee,onDrag:De,onDragStop:Oe,onResizeStart:ke,onResize:Ae,onResizeStop:je,isDraggable:i,isResizable:a,isBounded:c,useCSSTransforms:W&&le,usePercentages:!le,transformScale:se,positionStrategy:s,dragThreshold:I,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:t?J:void 0,resizeHandles:o,resizeHandle:u,constraints:l,layoutItem:r,layout:G,children:e},r.i)},[G,n,k,M,ce,j,A,F,P,Ee,De,Oe,ke,Ae,je,ee,ne,te,W,le,se,s,I,J,re,ie,l]),Re=()=>q?(0,$.jsx)($r,{w:q.w,h:q.h,x:q.x,y:q.y,i:q.i,className:`react-grid-placeholder ${fe?`placeholder-resizing`:``}`,containerWidth:n,cols:k,margin:M,containerPadding:ce,maxRows:j,rowHeight:A,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:W,transformScale:se,constraints:l,layout:G,children:(0,$.jsx)(`div`,{})}):null;return(0,$.jsxs)(`div`,{ref:h,className:z(ti,p),style:{height:Te,...m},onDrop:L?Ie:void 0,onDragLeave:L?Pe:void 0,onDragEnter:L?Fe:void 0,onDragOver:L?Ne:void 0,children:[Q.Children.map(t,e=>Q.isValidElement(e)?Le(e):null),L&&me&&Le(me,!0),Re()]})}var oi={lg:1200,md:996,sm:768,xs:480,xxs:0},si={lg:12,md:10,sm:6,xs:4,xxs:2},ci=()=>{};function li(e,t,n,r){let i=[];Q.Children.forEach(t,t=>{if(!Q.isValidElement(t)||t.key===null)return;let n=String(t.key),r=e.find(e=>e.i===n);if(r)i.push({...r,i:n});else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Rn(i),w:1,h:1})}});let a=Gn(i,{cols:n});return r.compact(a,n)}function ui(e){let{children:t,width:n,breakpoint:r,breakpoints:i=oi,cols:a=si,layouts:o={},rowHeight:s=150,maxRows:c=1/0,margin:l=[10,10],containerPadding:u=null,compactor:d,onBreakpointChange:f=ci,onLayoutChange:p=ci,onWidthChange:m=ci,...h}=e,g=d??Tr(`vertical`),_=g.type,v=g.allowOverlap,y=(0,Q.useMemo)(()=>r??Dr(i,n),[]),b=(0,Q.useMemo)(()=>Or(y,a),[y,a]),x=(0,Q.useMemo)(()=>kr(o,i,y,y,b,_),[]),[S,C]=(0,Q.useState)(y),[w,T]=(0,Q.useState)(b),[E,D]=(0,Q.useState)(x),[O,k]=(0,Q.useState)(o),A=(0,Q.useRef)(n),j=(0,Q.useRef)(r),M=(0,Q.useRef)(i),N=(0,Q.useRef)(a),ee=(0,Q.useRef)(o),te=(0,Q.useRef)(_),P=(0,Q.useRef)(O);(0,Q.useEffect)(()=>{P.current=O},[O]);let F=(0,Q.useMemo)(()=>(0,Qr.deepEqual)(o,ee.current)?null:kr(o,i,S,S,w,g),[o,i,S,w,g]),I=F??E;(0,Q.useEffect)(()=>{F!==null&&(D(F),k(o),P.current=o,ee.current=o)},[F,o]),(0,Q.useEffect)(()=>{if(_!==te.current){let e=g.compact(Hn(I),w),t={...P.current,[S]:e};D(e),k(t),P.current=t,p(e,t),te.current=_}},[_,g,I,w,v,S,p]),(0,Q.useEffect)(()=>{let e=n!==A.current,o=r!==j.current,s=!(0,Qr.deepEqual)(i,M.current),c=!(0,Qr.deepEqual)(a,N.current);if(e||o||s||c){let e=r??Dr(i,n),o=Or(e,a),d=S;if(d!==e||s||c){let n={...P.current};n[d]||(n[d]=Hn(E));let r=kr(n,i,e,d,o,g);r=li(r,t,o,g),n[e]=r,C(e),T(o),D(r),k(n),P.current=n,f(e,o),p(r,n)}m(n,Ar(l,e),o,u?Ar(u,e):null),A.current=n,j.current=r,M.current=i,N.current=a}},[n,r,i,a,S,w,E,t,g,_,v,l,u,f,p,m]);let ne=(0,Q.useCallback)(e=>{let t={...P.current,[S]:e};D(e),k(t),P.current=t,p(e,t)},[S,p]),re=(0,Q.useMemo)(()=>Ar(l,S),[l,S]),ie=(0,Q.useMemo)(()=>u===null?null:Ar(u,S),[u,S]),L=(0,Q.useMemo)(()=>({cols:w,rowHeight:s,maxRows:c,margin:re,containerPadding:ie}),[w,s,c,re,ie]);return(0,$.jsx)(ai,{...h,width:n,gridConfig:L,compactor:g,onLayoutChange:ne,layout:I,children:t})}function di({editMode:e}){let t=p();return Q.useEffect(()=>{if(e)return t.startDrag({id:`dashboard-layout`,type:`dashboard-widget`,data:{}}),()=>{t.endDrag()};t.endDrag(`dashboard`)},[e,t]),null}var fi=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],pi=({schema:e,className:t,onLayoutChange:n,persistLayoutKey:r=`dashboard-layout`,onRefresh:i})=>{let{width:a,containerRef:o,mounted:s}=Mr(),[l,u]=Q.useState(!1),[d,f]=Q.useState(!1),p=c(),h=Q.useRef(null),g=Q.useCallback(()=>{i&&(f(!0),i(),setTimeout(()=>f(!1),600))},[i]);Q.useEffect(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!i))return h.current=setInterval(g,e.refreshInterval*1e3),()=>{h.current&&clearInterval(h.current)}},[e.refreshInterval,i,g]);let[_,v]=Q.useState(()=>{if(typeof window<`u`&&r){let e=localStorage.getItem(r);if(e)try{return JSON.parse(e)}catch(e){console.error(`Failed to parse saved layout:`,e)}}return{lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x||t%4*3,y:e.layout?.y||Math.floor(t/4)*4,w:e.layout?.w||3,h:e.layout?.h||4}))||[]}}),y=Q.useCallback((e,t)=>{v(t),n?.(e)},[n]),b=Q.useCallback(()=>{typeof window<`u`&&r&&localStorage.setItem(r,JSON.stringify(_)),u(!1)},[_,r]),S=Q.useCallback(()=>{v({lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x||t%4*3,y:e.layout?.y||Math.floor(t/4)*4,w:e.layout?.w||3,h:e.layout?.h||4}))||[]}),typeof window<`u`&&r&&localStorage.removeItem(r)},[e.widgets,r]),w=Q.useCallback(e=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`bar`||t===`line`||t===`area`||t===`pie`||t===`donut`||t===`scatter`){let r=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(xn(r)){let n=r.aggregate,o=n?{field:e.valueField||n.field,function:e.aggregate||n.function,groupBy:e.categoryField||n.groupBy}:void 0,s=o?.field||a;return{type:`object-chart`,chartType:t,objectName:e.object||r.object,aggregate:o,xAxisKey:i,series:[{dataKey:s}],colors:fi,className:`h-full`}}if(!r&&e.object){let n=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0;return{type:`object-chart`,chartType:t,objectName:e.object,aggregate:n,xAxisKey:i,series:[{dataKey:e.valueField||`value`}],colors:fi,className:`h-full`}}return{type:`chart`,chartType:t,data:Array.isArray(r)?r:r?.items||[],xAxisKey:i,series:[{dataKey:a}],colors:fi,className:`h-full`}}if(t===`table`){let t=e.data||n.data;if(xn(t)){let{data:r,...i}=n;return{type:`data-table`,...i,objectName:e.object||t.object,dataProvider:t,data:[],searchable:!1,pagination:!1,className:`border-0`}}return!t&&e.object?{type:`data-table`,...n,objectName:e.object,data:[],searchable:!1,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(xn(t)){let{data:r,...i}=n;return{type:`pivot`,...i,objectName:e.object||t.object,dataProvider:t,data:[]}}return{type:`pivot`,...n,data:Array.isArray(t)?t:t?.items||[]}}return{...e,...n}},[]);return(0,$.jsxs)(`div`,{ref:o,className:Z(`w-full`,t),"data-testid":`grid-layout`,children:[p&&(0,$.jsx)(di,{editMode:l}),(0,$.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,$.jsx)(`h2`,{className:`text-2xl font-bold`,children:e.title||`Dashboard`}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(N,{onClick:b,size:`sm`,variant:`default`,children:[(0,$.jsx)(L,{className:`h-4 w-4 mr-2`}),`Save Layout`]}),(0,$.jsxs)(N,{onClick:S,size:`sm`,variant:`outline`,children:[(0,$.jsx)(Ze,{className:`h-4 w-4 mr-2`}),`Reset`]}),(0,$.jsx)(N,{onClick:()=>u(!1),size:`sm`,variant:`ghost`,children:`Cancel`})]}):(0,$.jsxs)($.Fragment,{children:[i&&(0,$.jsxs)(N,{onClick:g,size:`sm`,variant:`outline`,disabled:d,"aria-label":`Refresh dashboard`,children:[(0,$.jsx)(P,{className:Z(`h-4 w-4 mr-2`,d&&`animate-spin`)}),d?`Refreshing…`:`Refresh All`]}),(0,$.jsxs)(N,{onClick:()=>u(!0),size:`sm`,variant:`outline`,children:[(0,$.jsx)(st,{className:`h-4 w-4 mr-2`}),`Edit Layout`]})]})})]}),s&&(0,$.jsx)(ui,{className:`layout`,width:a,layouts:_,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},rowHeight:60,dragConfig:{enabled:l,handle:`.drag-handle`},resizeConfig:{enabled:l},onLayoutChange:y,children:e.widgets?.map((e,t)=>{let n=e.id||`widget-${t}`,r=w(e);return(0,$.jsx)(`div`,{className:`h-full`,children:e.type===`metric`?(0,$.jsxs)(`div`,{className:`h-full w-full relative`,children:[l&&(0,$.jsx)(`div`,{className:`drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border`,children:(0,$.jsx)(C,{className:`h-4 w-4`})}),(0,$.jsx)(m,{schema:r,className:`h-full w-full`})]}):(0,$.jsxs)(B,{className:Z(`h-full overflow-hidden border-border/50 shadow-sm transition-all`,`bg-card/50 backdrop-blur-sm`,l&&`ring-2 ring-primary/20`),children:[e.title&&(0,$.jsxs)(H,{className:`pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between`,children:[(0,$.jsx)(T,{className:`text-base font-medium tracking-tight truncate`,title:e.title,children:e.title}),l&&(0,$.jsx)(`div`,{className:`drag-handle cursor-move p-1 hover:bg-muted/40 rounded`,children:(0,$.jsx)(C,{className:`h-4 w-4`})})]}),(0,$.jsx)(x,{className:`p-0 h-full`,children:(0,$.jsx)(`div`,{className:Z(`h-full w-full overflow-auto p-4`),children:(0,$.jsx)(m,{schema:r})})})]})},n)})})]})};function mi(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var hi=({label:e,value:t,trend:n,icon:r,className:i,description:a,...o})=>{let s=(0,Q.useMemo)(()=>{if(typeof r==`string`){let e=le[r];return e?(0,$.jsx)(e,{className:`h-4 w-4 text-muted-foreground`}):null}return r},[r]);return(0,$.jsxs)(B,{className:Z(`h-full overflow-hidden`,i),...o,children:[(0,$.jsxs)(H,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,$.jsx)(T,{className:`text-sm font-medium truncate`,children:mi(e)}),s&&(0,$.jsx)(`div`,{className:`h-4 w-4 text-muted-foreground shrink-0`,children:s})]}),(0,$.jsxs)(x,{children:[(0,$.jsx)(`div`,{className:`text-2xl font-bold truncate`,children:t}),(n||a)&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1 truncate`,children:[n&&(0,$.jsxs)(`span`,{className:Z(`flex items-center mr-2 shrink-0`,n.direction===`up`&&`text-green-500`,n.direction===`down`&&`text-red-500`,n.direction===`neutral`&&`text-yellow-500`),children:[n.direction===`up`&&(0,$.jsx)(be,{className:`h-3 w-3 mr-1`}),n.direction===`down`&&(0,$.jsx)(K,{className:`h-3 w-3 mr-1`}),n.direction===`neutral`&&(0,$.jsx)(qe,{className:`h-3 w-3 mr-1`}),n.value,`%`]}),(0,$.jsx)(`span`,{className:`truncate`,children:mi(a)||mi(n?.label)})]})]})]})};function gi(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var _i=({title:e,value:t,icon:n,trend:r,trendValue:i,description:a,className:o,...s})=>{let c=n&&le[n];return(0,$.jsxs)(B,{className:Z(`h-full`,o),...s,children:[(0,$.jsxs)(H,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,$.jsx)(T,{className:`text-sm font-medium`,children:gi(e)}),c&&(0,$.jsx)(c,{className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsxs)(x,{children:[(0,$.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),(r||i||a)&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1`,children:[r&&i&&(0,$.jsxs)(`span`,{className:Z(`flex items-center mr-2`,r===`up`&&`text-green-500`,r===`down`&&`text-red-500`,r===`neutral`&&`text-yellow-500`),children:[r===`up`&&(0,$.jsx)(be,{className:`h-3 w-3 mr-1`}),r===`down`&&(0,$.jsx)(K,{className:`h-3 w-3 mr-1`}),r===`neutral`&&(0,$.jsx)(qe,{className:`h-3 w-3 mr-1`}),i]}),gi(a)]})]})]})};function vi(e,t){if(!t)return String(e);let n=``,r=``,i=!1,a,o=t,s=o.match(/^([^0-9.,#]*)/);if(s&&s[1]){let e=s[1];n=e.replace(`,`,``),e.includes(`,`)&&(i=!0),o=o.slice(s[1].length)}o.includes(`,`)&&(i=!0,o=o.replace(/,/g,``));let c=o.match(/\.(\d+)f?/);c&&(a=Number(c[1]),o=o.slice(c[0].length)),r=o.replace(/[0-9#.f]/g,``);let l=a===void 0?String(e):e.toFixed(a);if(i){let[e,t]=l.split(`.`),i=e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`);return n+(t===void 0?i:`${i}.${t}`)+r}return n+l+r}function yi(e,t){if(e.length===0)return 0;switch(t){case`sum`:return e.reduce((e,t)=>e+t,0);case`count`:return e.length;case`avg`:return e.reduce((e,t)=>e+t,0)/e.length;case`min`:return Math.min(...e);case`max`:return Math.max(...e);default:return e.reduce((e,t)=>e+t,0)}}var bi=({schema:e,className:t})=>{let{title:n,rowField:r,columnField:i,valueField:a,aggregation:o=`sum`,data:s=[],showRowTotals:c=!1,showColumnTotals:l=!1,format:u,columnColors:d}=e,f=Array.isArray(s)?s:[],{rowKeys:p,colKeys:m,matrix:h,rowTotals:g,colTotals:_,grandTotal:v}=(0,Q.useMemo)(()=>{let e=new Map,t=new Map,n={};for(let o of f){let s=String(o[r]??``),c=String(o[i]??``),l=Number(o[a])||0;e.set(s,!0),t.set(c,!0),n[s]||(n[s]={}),n[s][c]||(n[s][c]=[]),n[s][c].push(l)}let s=Array.from(e.keys()),c=Array.from(t.keys()),l={},u={},d={};for(let e of s){l[e]={};let t=[];for(let r of c){let i=n[e]?.[r]??[],a=yi(i,o);l[e][r]=a,t.push(...i),!d[r]&&d[r]}u[e]=yi(t,o)}for(let e of c){let t=[];for(let r of s){let i=n[r]?.[e]??[];t.push(...i)}d[e]=yi(t,o)}let p=[];for(let e of f)p.push(Number(e[a])||0);return{rowKeys:s,colKeys:c,matrix:l,rowTotals:u,colTotals:d,grandTotal:yi(p,o)}},[f,r,i,a,o]),y=e=>vi(e,u);return f.length===0?(0,$.jsxs)(`div`,{className:Z(`overflow-auto`,t),children:[n&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,"data-testid":`pivot-empty-state`,children:[(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`}),(0,$.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`}),(0,$.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`}),(0,$.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:`No data available`})]})]}):(0,$.jsxs)(`div`,{className:Z(`overflow-auto`,t),children:[n&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:n}),(0,$.jsxs)(`table`,{className:`w-full text-sm border-collapse`,role:`table`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,$.jsx)(`th`,{className:`text-left p-2 font-medium text-muted-foreground`,children:r}),m.map(e=>(0,$.jsx)(`th`,{className:Z(`text-right p-2 font-medium`,d?.[e]??`text-muted-foreground`),children:e},e)),c&&(0,$.jsx)(`th`,{className:`text-right p-2 font-semibold text-muted-foreground bg-muted/20`,children:`Total`})]})}),(0,$.jsx)(`tbody`,{children:p.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/30`,children:[(0,$.jsx)(`td`,{className:`p-2 font-medium`,children:e}),m.map(t=>(0,$.jsx)(`td`,{className:Z(`text-right p-2 tabular-nums`,d?.[t]),children:y(h[e]?.[t]??0)},t)),c&&(0,$.jsx)(`td`,{className:`text-right p-2 font-semibold tabular-nums bg-muted/20`,children:y(g[e]??0)})]},e))}),l&&(0,$.jsx)(`tfoot`,{children:(0,$.jsxs)(`tr`,{className:`border-t-2 border-border font-semibold bg-muted/40`,children:[(0,$.jsx)(`td`,{className:`p-2`,children:`Total`}),m.map(e=>(0,$.jsx)(`td`,{className:`text-right p-2 tabular-nums`,children:y(_[e]??0)},e)),c&&(0,$.jsx)(`td`,{className:`text-right p-2 tabular-nums font-bold`,children:y(v)})]})})]})]})},xi=({schema:e,dataSource:t,className:n})=>{let r=(0,Q.useContext)(s),i=t||r?.dataSource,a=o(e.bind),[c,l]=(0,Q.useState)([]),[u,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let t=!0;return e.objectName&&!a&&(!e.data||e.data.length===0)&&(async()=>{if(!(!i||!e.objectName)){t&&(f(!0),m(null));try{let n;if(typeof i.find==`function`)n=d(await i.find(e.objectName,{$filter:e.filter}));else return;t&&l(n)}catch(e){console.error(`[ObjectPivotTable] Fetch error:`,e),t&&m(e instanceof Error?e.message:`Failed to load data`)}finally{t&&f(!1)}}})(),()=>{t=!1}},[e.objectName,i,a,e.data,e.filter]);let h=a||e.data||c,g=Array.isArray(h)?h:[];return u&&g.length===0?(0,$.jsxs)(`div`,{className:Z(`overflow-auto`,n),"data-testid":`pivot-loading`,children:[e.title&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,$.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(W,{className:`h-6 w-24`}),(0,$.jsx)(W,{className:`h-6 w-20`}),(0,$.jsx)(W,{className:`h-6 w-20`}),(0,$.jsx)(W,{className:`h-6 w-20`})]}),[1,2,3].map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(W,{className:`h-5 w-24`}),(0,$.jsx)(W,{className:`h-5 w-20`}),(0,$.jsx)(W,{className:`h-5 w-20`}),(0,$.jsx)(W,{className:`h-5 w-20`})]},e))]})]}):p?(0,$.jsxs)(`div`,{className:Z(`overflow-auto`,n),"data-testid":`pivot-error`,children:[e.title&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`pivot-error-message`,children:[(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,$.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,$.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:p})]})]}):!i&&e.objectName&&g.length===0?(0,$.jsxs)(`div`,{className:Z(`overflow-auto`,n),children:[e.title&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,$.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,$.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})]}):(0,$.jsx)(bi,{schema:{...e,data:g},className:n})};function Si(e){return e.map(e=>typeof e==`string`?{header:e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().replace(/\b\w/g,e=>e.toUpperCase()),accessorKey:e}:e)}var Ci=({schema:e,dataSource:t,className:n})=>{let r=(0,Q.useContext)(s),i=t||r?.dataSource,a=o(e.bind),[c,l]=(0,Q.useState)([]),[u,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let t=!0;return e.objectName&&!a&&(!e.data||e.data.length===0)&&(async()=>{if(!(!i||!e.objectName)){t&&(f(!0),h(null));try{let n;if(typeof i.find==`function`)n=d(await i.find(e.objectName,{$filter:e.filter}));else return;t&&l(n)}catch(e){console.error(`[ObjectDataTable] Fetch error:`,e),t&&h(e instanceof Error?e.message:`Failed to load data`)}finally{t&&f(!1)}}})(),()=>{t=!1}},[e.objectName,i,a,e.data,e.filter]);let g=a||e.data||c,_=Array.isArray(g)?g:[],v=(0,Q.useMemo)(()=>e.columns&&e.columns.length>0?Si(e.columns):_.length===0?[]:Object.keys(_[0]).filter(e=>!e.startsWith(`_`)).map(e=>({header:e.charAt(0).toUpperCase()+e.slice(1).replace(/([A-Z])/g,` $1`),accessorKey:e})),[e.columns,_]);return u&&_.length===0?(0,$.jsx)(`div`,{className:Z(`overflow-auto`,n),"data-testid":`table-loading`,children:(0,$.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(W,{className:`h-6 w-1/4`}),(0,$.jsx)(W,{className:`h-6 w-1/4`}),(0,$.jsx)(W,{className:`h-6 w-1/4`}),(0,$.jsx)(W,{className:`h-6 w-1/4`})]}),[1,2,3,4].map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(W,{className:`h-5 w-1/4`}),(0,$.jsx)(W,{className:`h-5 w-1/4`}),(0,$.jsx)(W,{className:`h-5 w-1/4`}),(0,$.jsx)(W,{className:`h-5 w-1/4`})]},e))]})}):p?(0,$.jsx)(`div`,{className:Z(`overflow-auto`,n),"data-testid":`table-error`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`table-error-message`,children:[(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,$.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,$.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:p})]})}):!i&&e.objectName&&_.length===0?(0,$.jsx)(`div`,{className:Z(`overflow-auto`,n),children:(0,$.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,$.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})}):_.length===0?(0,$.jsx)(`div`,{className:Z(`overflow-auto`,n),"data-testid":`table-empty-state`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,$.jsx)(`line`,{x1:`3`,y1:`9`,x2:`21`,y2:`9`}),(0,$.jsx)(`line`,{x1:`9`,y1:`21`,x2:`9`,y2:`9`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:`No data available`})]})}):(0,$.jsx)(m,{schema:{...e,type:`data-table`,data:_,columns:v},className:n})},wi={breadcrumb:[`Dashboard`,`Configuration`],sections:[{key:`layout`,title:`Layout`,fields:[{key:`columns`,label:`Columns`,type:`slider`,defaultValue:3,min:1,max:12,step:1},{key:`gap`,label:`Gap`,type:`slider`,defaultValue:4,min:0,max:16,step:1},{key:`rowHeight`,label:`Row height`,type:`input`,defaultValue:`120`,placeholder:`e.g. 120`}]},{key:`data`,title:`Data`,collapsible:!0,fields:[{key:`refreshInterval`,label:`Refresh interval`,type:`select`,defaultValue:`0`,options:[{value:`0`,label:`Manual`},{value:`30`,label:`30s`},{value:`60`,label:`1 min`},{value:`300`,label:`5 min`}]}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Dashboard title`},{key:`showDescription`,label:`Show description`,type:`switch`,defaultValue:!0},{key:`theme`,label:`Theme`,type:`select`,defaultValue:`auto`,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`auto`,label:`Auto`}]}]}]};function Ti({open:e,onClose:t,config:n,onSave:r,onFieldChange:i}){let{draft:a,isDirty:o,updateField:s,discard:c}=Oe(n,{onUpdate:i});return(0,$.jsx)($e,{open:e,onClose:t,schema:wi,draft:a,isDirty:o,onFieldChange:s,onSave:()=>r(a),onDiscard:c})}var Ei=[{value:`metric`,label:`Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`donut`,label:`Donut Chart`},{value:`area`,label:`Area Chart`},{value:`scatter`,label:`Scatter Plot`},{value:`table`,label:`Table`},{value:`pivot`,label:`Pivot Table`},{value:`list`,label:`List`},{value:`custom`,label:`Custom`}],Di=[{value:`default`,label:`Default`},{value:`blue`,label:`Blue`},{value:`teal`,label:`Teal`},{value:`orange`,label:`Orange`},{value:`purple`,label:`Purple`},{value:`success`,label:`Success`},{value:`warning`,label:`Warning`},{value:`danger`,label:`Danger`}],Oi=[{value:`count`,label:`Count`},{value:`sum`,label:`Sum`},{value:`avg`,label:`Average`},{value:`min`,label:`Min`},{value:`max`,label:`Max`}],ki=[`bar`,`line`,`area`,`pie`,`donut`,`scatter`];function Ai(e){return!!e&&ki.includes(e)}var ji=[{value:`group`,label:`Group`},{value:`value`,label:`Value`}],Mi=[{value:`asc`,label:`↑`},{value:`desc`,label:`↓`}];function Ni(e,t,n,r){return{key:e,label:t,type:`custom`,render:(i,a,o)=>(0,$.jsx)(Ge,{label:t,children:(0,$.jsx)(`div`,{"data-testid":`config-field-${e}`,children:(0,$.jsx)(Re,{options:r??[],value:i??``,onValueChange:a,placeholder:n,searchPlaceholder:`Search fields…`,emptyText:`No fields found.`,className:`h-7 w-32 text-xs`,disabled:!o.object})})})}}function Pi(e,t,n){let r=e&&e.length>0,i=r?{key:`object`,label:`Data source`,type:`custom`,render:(t,n)=>(0,$.jsx)(Ge,{label:`Data source`,children:(0,$.jsx)(`div`,{"data-testid":`config-field-object`,children:(0,$.jsx)(Re,{options:e,value:t??``,onValueChange:n,placeholder:`Select object…`,searchPlaceholder:`Search objects…`,emptyText:`No objects found.`,className:`h-7 w-32 text-xs`})})})}:{key:`object`,label:`Data source`,type:`input`,placeholder:`Object name`},a=r?Ni(`categoryField`,`Category field`,`Select field…`,t):{key:`categoryField`,label:`Category field`,type:`input`,placeholder:`e.g. status`},o=r?Ni(`valueField`,`Value field`,`Select field…`,t):{key:`valueField`,label:`Value field`,type:`input`,placeholder:`e.g. amount`},s=r?Ni(`rowField`,`Field`,`Select row field…`,t):{key:`rowField`,label:`Field`,type:`input`,placeholder:`e.g. owner`},c=r?Ni(`columnField`,`Field`,`Select column field…`,t):{key:`columnField`,label:`Field`,type:`input`,placeholder:`e.g. stage`},l=r?Ni(`pivotValueField`,`Field`,`Select value field…`,t):{key:`pivotValueField`,label:`Field`,type:`input`,placeholder:`e.g. amount`};return{breadcrumb:[`Dashboard`,{pivot:`Pivot table`,table:`Table`}[n??``]??(Ai(n)?`Chart`:`Widget`)],sections:[{key:`general`,title:`General`,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Widget title`},{key:`description`,label:`Description`,type:`input`,placeholder:`Widget description`},{key:`type`,label:`Widget type`,type:`select`,options:Ei,defaultValue:`metric`}]},{key:`data`,title:`Data Binding`,collapsible:!0,visibleWhen:e=>e.type!==`pivot`,fields:[i,a,o,{key:`aggregate`,label:`Aggregation`,type:`select`,options:Oi,defaultValue:`count`}]},{key:`pivot-data`,title:`Data`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[i]},{key:`pivot-rows`,title:`Rows`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[s,{key:`rowSortBy`,label:`Sort by`,type:`icon-group`,options:ji,defaultValue:`group`},{key:`rowSortOrder`,label:`Sort order`,type:`icon-group`,options:Mi,defaultValue:`asc`},{key:`showRowLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showRowTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-columns`,title:`Columns`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[c,{key:`columnSortBy`,label:`Sort by`,type:`icon-group`,options:ji,defaultValue:`group`},{key:`columnSortOrder`,label:`Sort order`,type:`icon-group`,options:Mi,defaultValue:`asc`},{key:`showColumnLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showColumnTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-values`,title:`Values`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[l,{key:`aggregation`,label:`Aggregation`,type:`select`,options:Oi,defaultValue:`sum`},{key:`format`,label:`Number format`,type:`input`,placeholder:`e.g. $,.2f`}]},{key:`chart-axis`,title:`Axis & Series`,collapsible:!0,visibleWhen:e=>Ai(e.type),fields:[{key:`xAxisLabel`,label:`X-axis label`,type:`input`,placeholder:`e.g. Month`},{key:`yAxisLabel`,label:`Y-axis label`,type:`input`,placeholder:`e.g. Revenue`},{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`table-columns`,title:`Columns`,collapsible:!0,visibleWhen:e=>e.type===`table`,fields:[{key:`searchable`,label:`Searchable`,type:`switch`,defaultValue:!1},{key:`pagination`,label:`Pagination`,type:`switch`,defaultValue:!1}]},{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`layoutW`,label:`Width (columns)`,type:`slider`,min:1,max:12,step:1,defaultValue:1},{key:`layoutH`,label:`Height (rows)`,type:`slider`,min:1,max:6,step:1,defaultValue:1}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`colorVariant`,label:`Color variant`,type:`select`,options:Di,defaultValue:`default`},{key:`actionUrl`,label:`Action URL`,type:`input`,placeholder:`https://...`}]}]}}function Fi(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;return t.defaultValue||t.key||``}return String(e)}function Ii({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,headerExtra:a,availableObjects:o,availableFields:s}){let{draft:c,isDirty:l,updateField:u,discard:d}=Oe(Q.useMemo(()=>({...n,title:typeof n.title==`object`?Fi(n.title):n.title,description:typeof n.description==`object`?Fi(n.description):n.description}),[n]),{onUpdate:i});return(0,$.jsx)($e,{open:e,onClose:t,schema:Q.useMemo(()=>Pi(o,s,c.type),[o,s,c.type]),draft:c,isDirty:l,onFieldChange:u,onSave:()=>r(c),onDiscard:d,headerExtra:a})}r.register(`dashboard`,wn,{namespace:`view`,label:`Dashboard`,category:`Complex`,icon:`layout-dashboard`,inputs:[{name:`columns`,type:`number`,label:`Columns`,defaultValue:3},{name:`gap`,type:`number`,label:`Gap`,defaultValue:4},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:3,widgets:[]}}),r.register(`metric`,hi,{namespace:`plugin-dashboard`,label:`Metric Widget`,category:`Dashboard`,inputs:[{name:`label`,type:`string`,label:`Label`},{name:`value`,type:`string`,label:`Value`}]}),r.register(`metric-card`,_i,{namespace:`plugin-dashboard`,label:`Metric Card`,category:`Dashboard`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`value`,type:`string`,label:`Value`,required:!0},{name:`icon`,type:`string`,label:`Icon (Lucide name)`},{name:`trend`,type:`enum`,label:`Trend`,enum:[{label:`Up`,value:`up`},{label:`Down`,value:`down`},{label:`Neutral`,value:`neutral`}]},{name:`trendValue`,type:`string`,label:`Trend Value (e.g., +12%)`},{name:`description`,type:`string`,label:`Description`}],defaultProps:{title:`Metric`,value:`0`}}),r.register(`pivot`,bi,{namespace:`plugin-dashboard`,label:`Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`,data:[]}}),r.register(`object-pivot`,xi,{namespace:`plugin-dashboard`,label:`Object Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`filter`,type:`array`,label:`Filter`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`}}),r.register(`dashboard-grid`,pi,{namespace:`plugin-dashboard`,label:`Dashboard Grid (Editable)`,category:`Complex`,icon:`layout-grid`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`persistLayoutKey`,type:`string`,label:`Layout Storage Key`,defaultValue:`dashboard-layout`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{title:`Dashboard`,widgets:[],persistLayoutKey:`dashboard-layout`}}),r.register(`object-data-table`,Ci,{namespace:`plugin-dashboard`,label:`Object Data Table`,category:`Dashboard`,icon:`table`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`searchable`,type:`boolean`,label:`Searchable`},{name:`pagination`,type:`boolean`,label:`Pagination`}],defaultProps:{searchable:!1,pagination:!1}});var Li=({schema:e})=>{let{title:t,description:n,data:i,columns:a}=e;e.chart?.type;let o=!!e.chart;return(0,$.jsxs)(B,{className:`h-full flex flex-col ${e.className||``}`,children:[(0,$.jsxs)(H,{children:[t&&(0,$.jsx)(T,{children:t}),n&&(0,$.jsx)(rt,{children:n})]}),(0,$.jsxs)(x,{className:`flex-1 overflow-auto space-y-4`,children:[o&&(()=>{let t=e.chart?.type,n=t?r.get(t):null;return n||=r.get(`chart`),n?(0,$.jsx)(`div`,{className:`min-h-[300px] border rounded-lg p-4 bg-background/50`,children:(0,$.jsx)(n,{schema:{...e.chart,data:e.chart.data||i}})}):(0,$.jsxs)(`div`,{className:`min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center`,children:[`Unknown component type: `,t||`chart`]})})(),i&&i.length>0&&(0,$.jsx)(`div`,{className:`border rounded-lg`,children:(()=>{let e=r.get(`aggrid`)||r.get(`table`);return e?(0,$.jsx)(e,{schema:{type:`aggrid`,rowData:i,columnDefs:a,domLayout:`autoHeight`}}):(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm text-left`,children:[(0,$.jsx)(`thead`,{className:`text-xs uppercase bg-muted`,children:(0,$.jsx)(`tr`,{children:a?.map(e=>(0,$.jsx)(`th`,{className:`px-6 py-3`,children:e.headerName||e.label||e.field},e.field))})}),(0,$.jsx)(`tbody`,{children:i.map((e,t)=>(0,$.jsx)(`tr`,{className:`bg-background border-b`,children:a?.map(t=>(0,$.jsx)(`td`,{className:`px-6 py-4`,children:e[t.field]},t.field))},t))})]})})})()})]})]})};function Ri(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=Gi(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
6
|
-
`))?`"${n.replace(/"/g,`""`)}"`:n??``}));Ji([...n?.includeHeaders===!1?[]:[i.join(`,`)],...a.map(e=>e.join(`,`))].join(`
|
|
7
|
-
`),n?.filename||`${e.title||`report`}.csv`,`text/csv`)}function zi(e,t,n){let r={title:e.title,description:e.description,generatedAt:new Date().toISOString(),data:t};Ji(JSON.stringify(r,null,2),n?.filename||`${e.title||`report`}.json`,`application/json`)}function Bi(e,t,n){let r=e.fields||[],i=qi(n?.orientation),a=Ki(n?.pageSize);Ji(`<!DOCTYPE html>
|
|
8
|
-
<html>
|
|
9
|
-
<head>
|
|
10
|
-
<meta charset="utf-8">
|
|
11
|
-
<title>${Wi(e.title||`Report`)}</title>
|
|
12
|
-
<style>
|
|
13
|
-
@page { size: ${a} ${i}; margin: 20mm; }
|
|
14
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
15
|
-
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
16
|
-
.description { color: #666; margin-bottom: 24px; }
|
|
17
|
-
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
18
|
-
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
19
|
-
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
20
|
-
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
21
|
-
tr:nth-child(even) { background: #fafafa; }
|
|
22
|
-
</style>
|
|
23
|
-
</head>
|
|
24
|
-
<body>
|
|
25
|
-
<h1>${Wi(e.title||`Report`)}</h1>
|
|
26
|
-
${e.description?`<p class="description">${Wi(e.description)}</p>`:``}
|
|
27
|
-
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
28
|
-
<table>
|
|
29
|
-
<thead><tr>${r.map(e=>`<th>${Wi(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
30
|
-
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${Wi(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
31
|
-
</table>
|
|
32
|
-
</body>
|
|
33
|
-
</html>`,n?.filename||`${e.title||`report`}.html`,`text/html`)}function Vi(e,t,n){let r=e.fields||[],i=qi(n?.orientation),a=Ki(n?.pageSize),o=window.open(``,`_blank`);if(!o){Bi(e,t,{...n,format:`html`,filename:n?.filename?.replace(/\.pdf$/,`.html`)||`${e.title||`report`}.html`});return}o.document.write(`<!DOCTYPE html>
|
|
34
|
-
<html>
|
|
35
|
-
<head>
|
|
36
|
-
<meta charset="utf-8">
|
|
37
|
-
<title>${Wi(e.title||`Report`)}</title>
|
|
38
|
-
<style>
|
|
39
|
-
@page { size: ${a} ${i}; margin: 20mm; }
|
|
40
|
-
@media print { .no-print { display: none; } }
|
|
41
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
42
|
-
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
43
|
-
.description { color: #666; margin-bottom: 24px; }
|
|
44
|
-
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
45
|
-
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
46
|
-
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
47
|
-
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
48
|
-
tr:nth-child(even) { background: #fafafa; }
|
|
49
|
-
</style>
|
|
50
|
-
</head>
|
|
51
|
-
<body>
|
|
52
|
-
<h1>${Wi(e.title||`Report`)}</h1>
|
|
53
|
-
${e.description?`<p class="description">${Wi(e.description)}</p>`:``}
|
|
54
|
-
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
55
|
-
<table>
|
|
56
|
-
<thead><tr>${r.map(e=>`<th>${Wi(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
57
|
-
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${Wi(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
58
|
-
</table>
|
|
59
|
-
</body>
|
|
60
|
-
</html>`),o.document.close(),o.onload=()=>{o.print()}}function Hi(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=Gi(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
61
|
-
`)||n.includes(` `))?`"${n.replace(/"/g,`""`)}"`:n??``}));Ji(``+[...n?.includeHeaders===!1?[]:[i.join(` `)],...a.map(e=>e.join(` `))].join(`
|
|
62
|
-
`),n?.filename||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function Ui(e,t,n,r){switch(e){case`csv`:Ri(t,n,r);break;case`json`:zi(t,n,r);break;case`html`:Bi(t,n,r);break;case`pdf`:Vi(t,n,r);break;case`excel`:Hi(t,n,r);break;default:console.warn(`Unsupported export format: ${e}`)}}function Wi(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Gi(e){if(typeof e==`string`&&e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`\t${e}`}return e}function Ki(e){return[`A4`,`A3`,`Letter`,`Legal`].includes(e||``)?e:`A4`}function qi(e){return e===`landscape`?`landscape`:`portrait`}function Ji(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function Yi(e,t){if(e==null||e===``)return``;let n=t?.type,r=t?.format;if(n===`date`||r===`date`||Xi(e))return Zi(e);if(n===`number`||typeof e==`number`){let t=typeof e==`number`?e:Number(e);return isNaN(t)?String(e):r===`currency`||r===`currency_cny`?`¥${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`currency_usd`?`$${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`percent`?`${t.toLocaleString(`en-US`,{minimumFractionDigits:1,maximumFractionDigits:1})}%`:t.toLocaleString(`en-US`)}return String(e)}function Xi(e){return typeof e==`string`?/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e):!1}function Zi(e){try{let t=new Date(e);return isNaN(t.getTime())?String(e):`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}catch{return String(e)}}function Qi(e,t){if(!t||t.length===0||!e||e.length===0)return null;let n=t[0],r=n.field,i=new Map;for(let t of e){let e=String(t[r]??`(empty)`);i.has(e)||i.set(e,[]),i.get(e).push(t)}let a=[];for(let[e,t]of i)a.push({key:e,label:`${n.label||r}: ${e}`,rows:t});let o=n.sort===`desc`?-1:1;return a.sort((e,t)=>e.key.localeCompare(t.key)*o),a}var $i=({schema:e,onRefresh:t})=>{let{report:n,data:i,showToolbar:a=!0,allowExport:o=!0,allowPrint:s=!0,loading:c=!1}=e,l=e=>{if(!n){console.warn(`ReportViewer: Cannot export, no report defined`);return}Ui(e,n,i||[],n.exportConfigs?.[e])},u=()=>{window.print()},d=()=>{t?.()},f=(e,t)=>{if(!i)return 0;let n=i.map(t=>Number(t[e])||0);switch(t){case`count`:return i.length;case`sum`:return n.reduce((e,t)=>e+t,0);case`avg`:return n.length>0?(n.reduce((e,t)=>e+t,0)/n.length).toFixed(2):0;case`min`:return n.length>0?Math.min(...n):0;case`max`:return n.length>0?Math.max(...n):0;default:return``}},p=(e,t)=>{let r=n?.conditionalFormatting;if(!(!r||!Array.isArray(r)))for(let n of r){if(n.field!==e)continue;let r=String(t??``),i=String(n.value??``),a=!1;switch(n.operator){case`equals`:a=r===i;break;case`not_equals`:a=r!==i;break;case`contains`:a=r.includes(i);break;case`greater_than`:a=Number(t)>Number(n.value);break;case`less_than`:a=Number(t)<Number(n.value);break}if(a){let e={};return n.backgroundColor&&(e.backgroundColor=n.backgroundColor),n.textColor&&(e.color=n.textColor),e}}},h=(e,t)=>e==null||e===``?``:t.renderAs===`badge`?(0,$.jsx)(ie,{className:t.colorMap?.[String(e)]||``,children:String(e)}):Yi(e,t);return n?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[a&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-4 bg-card rounded-lg border`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:n.title}),n.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.refreshInterval&&(0,$.jsxs)(N,{variant:`outline`,size:`sm`,onClick:d,children:[(0,$.jsx)(P,{className:`h-4 w-4 mr-2`}),`Refresh`]}),s&&(0,$.jsxs)(N,{variant:`outline`,size:`sm`,onClick:u,children:[(0,$.jsx)(dt,{className:`h-4 w-4 mr-2`}),`Print`]}),o&&n.showExportButtons&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>l(`pdf`),children:[(0,$.jsx)(ut,{className:`h-4 w-4 mr-2`}),`PDF`]}),(0,$.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>l(`excel`),children:[(0,$.jsx)(ut,{className:`h-4 w-4 mr-2`}),`Excel`]}),(0,$.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>l(`csv`),children:[(0,$.jsx)(ut,{className:`h-4 w-4 mr-2`}),`CSV`]})]})]})]}),(0,$.jsxs)(B,{children:[(0,$.jsxs)(H,{children:[!a&&n.title&&(0,$.jsx)(T,{children:n.title}),!a&&n.description&&(0,$.jsx)(rt,{children:n.description})]}),(0,$.jsxs)(x,{className:`space-y-6`,children:[c&&(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[1,2,3].map(e=>(0,$.jsx)(B,{children:(0,$.jsxs)(x,{className:`p-4 space-y-2`,children:[(0,$.jsx)(W,{className:`h-4 w-20`}),(0,$.jsx)(W,{className:`h-8 w-28`})]})},e))}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(W,{className:`h-10 w-full`}),[1,2,3,4,5].map(e=>(0,$.jsx)(W,{className:`h-8 w-full`},e))]})]}),!c&&n.sections?.map((e,t)=>e.visible===!1?null:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[e.title&&e.type!==`header`&&(0,$.jsx)(`h3`,{className:`text-lg font-semibold border-b pb-2`,children:e.title}),e.type===`header`&&e.title&&(0,$.jsx)(`div`,{className:`text-2xl font-bold py-4`,children:e.title}),e.type===`summary`&&(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:n.fields?.filter(e=>e.showInSummary).map((e,t)=>(0,$.jsx)(B,{children:(0,$.jsxs)(x,{className:`p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.label||e.name}),(0,$.jsx)(`div`,{className:`text-2xl font-bold`,children:Yi(f(e.name,e.aggregation),e)})]})},t))}),e.type===`chart`&&e.chart&&(0,$.jsx)(`div`,{className:`min-h-[300px]`,children:(()=>{let t=e.chart.type,n=!!e.chart.chartType;!t&&n&&(t=`chart`),t&&r.get(t)||(t=`chart`);let a=t===`chart`?{xAxisKey:e.chart.xAxisKey||e.chart.xAxisField||`name`,series:e.chart.series||(e.chart.yAxisFields?e.chart.yAxisFields.map(e=>({dataKey:e})):[]),chartType:e.chart.chartType||`bar`}:{};return(0,$.jsx)(m,{schema:{...e.chart,type:t,...a,data:i||e.chart.data,className:e.chart.className||`w-full h-[350px]`}})})()}),e.type===`table`&&(0,$.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,$.jsx)(`thead`,{className:`bg-muted`,children:(0,$.jsx)(`tr`,{children:e.columns?.map((e,t)=>(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,$.jsx)(`tbody`,{children:(()=>{let t=Qi(i||[],n.groupBy||[]);return t?t.map(t=>(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(`tr`,{className:`bg-muted/60`,children:(0,$.jsxs)(`td`,{colSpan:e.columns?.length||1,className:`px-4 py-2 font-semibold text-sm`,children:[t.label,` (`,t.rows.length,`)`]})}),t.rows.map((t,n)=>(0,$.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,$.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:p(e.name,t[e.name]),children:h(t[e.name],e)},n))},n))]},t.key)):i?.map((t,n)=>(0,$.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,$.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:p(e.name,t[e.name]),children:h(t[e.name],e)},n))},n))})()})]})}),e.type===`text`&&e.text&&(0,$.jsx)(`div`,{className:`prose max-w-none`,children:(0,$.jsx)(`p`,{children:e.text})}),e.type===`page-break`&&(0,$.jsx)(`div`,{className:`border-t-2 border-dashed my-8 print:page-break-after-always`}),e.content&&(0,$.jsx)(m,{schema:e.content})]},t)),!n.sections&&i&&i.length>0&&(0,$.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,$.jsx)(`thead`,{className:`bg-muted`,children:(0,$.jsx)(`tr`,{children:n.fields?.map((e,t)=>(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,$.jsx)(`tbody`,{children:i.map((e,t)=>(0,$.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:n.fields?.map((t,n)=>(0,$.jsx)(`td`,{className:`px-4 py-2 ${t.type===`number`?`text-right tabular-nums`:``}`,style:p(t.name,e[t.name]),children:h(e[t.name],t)},n))},t))})]})})]})]})]}):(0,$.jsx)(B,{children:(0,$.jsx)(x,{className:`p-8 text-center text-muted-foreground`,children:`No report to display`})})},ea=({schedule:e,onChange:t})=>{let[n,r]=(0,Q.useState)(e||{enabled:!1,frequency:`weekly`,time:`09:00`,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,recipients:[],formats:[`pdf`]}),i=e=>{let i={...n,...e};r(i),t?.(i)};return(0,$.jsxs)(B,{children:[(0,$.jsx)(H,{children:(0,$.jsxs)(T,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ye,{className:`h-5 w-5`}),`Schedule Configuration`]})}),(0,$.jsxs)(x,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`schedule-enabled`,checked:n.enabled||!1,onChange:e=>i({enabled:e.target.checked}),className:`rounded`}),(0,$.jsx)(X,{htmlFor:`schedule-enabled`,children:`Enable Scheduled Report`})]}),n.enabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Frequency`}),(0,$.jsx)(`select`,{className:`w-full border rounded-md p-2 bg-background`,value:n.frequency||`weekly`,onChange:e=>i({frequency:e.target.value}),children:[{value:`once`,label:`Once`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`},{value:`quarterly`,label:`Quarterly`},{value:`yearly`,label:`Yearly`}].map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),n.frequency===`weekly`&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Day of Week`}),(0,$.jsx)(`select`,{className:`w-full border rounded-md p-2 bg-background`,value:n.dayOfWeek??1,onChange:e=>i({dayOfWeek:Number(e.target.value)}),children:[{value:0,label:`Sunday`},{value:1,label:`Monday`},{value:2,label:`Tuesday`},{value:3,label:`Wednesday`},{value:4,label:`Thursday`},{value:5,label:`Friday`},{value:6,label:`Saturday`}].map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),n.frequency===`monthly`&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Day of Month`}),(0,$.jsx)(Ve,{type:`number`,min:1,max:31,value:n.dayOfMonth??1,onChange:e=>i({dayOfMonth:Number(e.target.value)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(X,{className:`flex items-center gap-2`,children:[(0,$.jsx)(D,{className:`h-4 w-4`}),`Time`]}),(0,$.jsx)(Ve,{type:`time`,value:n.time||`09:00`,onChange:e=>i({time:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Timezone`}),(0,$.jsx)(Ve,{value:n.timezone||``,onChange:e=>i({timezone:e.target.value}),placeholder:`e.g. America/New_York`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Export Formats`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[{value:`pdf`,label:`PDF`},{value:`excel`,label:`Excel`},{value:`csv`,label:`CSV`},{value:`html`,label:`HTML`}].map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 px-3 py-1.5 border rounded-md cursor-pointer hover:bg-muted/50`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n.formats?.includes(e.value)||!1,onChange:t=>{let r=n.formats||[];i({formats:t.target.checked?[...r,e.value]:r.filter(t=>t!==e.value)})},className:`rounded`}),(0,$.jsx)(`span`,{className:`text-sm`,children:e.label})]},e.value))})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(X,{className:`flex items-center gap-2`,children:[(0,$.jsx)(pe,{className:`h-4 w-4`}),`Email Recipients`]}),(0,$.jsx)(Ve,{placeholder:`email1@example.com, email2@example.com`,value:n.recipients?.join(`, `)||``,onChange:e=>i({recipients:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Email Subject`}),(0,$.jsx)(Ve,{value:n.subject||``,onChange:e=>i({subject:e.target.value}),placeholder:`Scheduled Report: {report_title}`})]})]})]})]})},ta=({schema:e})=>{let{report:t,dataSources:n=[],availableFields:r=[],showPreview:i=!0,onSave:a,onCancel:o}=e,[s,c]=(0,Q.useState)(t||{type:`report`,title:`New Report`,fields:[],filters:[],groupBy:[],sections:[],showExportButtons:!0,showPrintButton:!0}),[l,u]=(0,Q.useState)(s.fields||[]),[d,f]=(0,Q.useState)(s.filters||[]),[p,m]=(0,Q.useState)(s.groupBy||[]),[h,g]=(0,Q.useState)(s.sections||[]),_=()=>{if(r.length>0&&l.length<r.length){let e=r.find(e=>!l.some(t=>t.name===e.name));if(e){let t=[...l,e];u(t),c({...s,fields:t})}}},y=e=>{let t=l.filter((t,n)=>n!==e);u(t),c({...s,fields:t})},b=(e,t)=>{let n=[...l];n[e]=t,u(n),c({...s,fields:n})},S=()=>{let e={field:r[0]?.name||``,operator:`equals`,value:``},t=[...d,e];f(t),c({...s,filters:t})},C=e=>{let t=d.filter((t,n)=>n!==e);f(t),c({...s,filters:t})},w=(e,t)=>{let n=[...d];n[e]=t,f(n),c({...s,filters:n})},E=()=>{let e={field:r[0]?.name||``,sort:`asc`},t=[...p,e];m(t),c({...s,groupBy:t})},D=e=>{let t=p.filter((t,n)=>n!==e);m(t),c({...s,groupBy:t})},O=(e,t)=>{let n=[...p];n[e]=t,m(n),c({...s,groupBy:n})},k=e=>{let t={type:e,title:`New ${e} Section`},n=[...h,t];g(n),c({...s,sections:n})},A=e=>{let t=h.filter((t,n)=>n!==e);g(t),c({...s,sections:t})},j=(e,t)=>{let n=[...h];n[e]=t,g(n),c({...s,sections:n})};return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(B,{children:[(0,$.jsxs)(H,{children:[(0,$.jsx)(T,{children:`Report Builder`}),(0,$.jsx)(rt,{children:`Configure your report settings, fields, filters, and sections`})]}),(0,$.jsxs)(x,{children:[(0,$.jsxs)(we,{defaultValue:`basic`,className:`w-full`,children:[(0,$.jsxs)(nt,{className:`grid w-full grid-cols-6`,children:[(0,$.jsxs)(lt,{value:`basic`,children:[(0,$.jsx)(Ne,{className:`h-4 w-4 mr-2`}),`Basic`]}),(0,$.jsxs)(lt,{value:`fields`,children:[(0,$.jsx)(G,{className:`h-4 w-4 mr-2`}),`Fields`]}),(0,$.jsxs)(lt,{value:`filters`,children:[(0,$.jsx)(ke,{className:`h-4 w-4 mr-2`}),`Filters`]}),(0,$.jsxs)(lt,{value:`grouping`,children:[(0,$.jsx)(G,{className:`h-4 w-4 mr-2`}),`Group By`]}),(0,$.jsxs)(lt,{value:`sections`,children:[(0,$.jsx)(G,{className:`h-4 w-4 mr-2`}),`Sections`]}),(0,$.jsxs)(lt,{value:`schedule`,children:[(0,$.jsx)(Ye,{className:`h-4 w-4 mr-2`}),`Schedule`]})]}),(0,$.jsx)(q,{value:`basic`,className:`space-y-4 mt-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{htmlFor:`report-title`,children:`Report Title`}),(0,$.jsx)(Ve,{id:`report-title`,value:s.title||``,onChange:e=>c({...s,title:e.target.value}),placeholder:`Enter report title`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{htmlFor:`report-description`,children:`Description`}),(0,$.jsx)(Ve,{id:`report-description`,value:s.description||``,onChange:e=>c({...s,description:e.target.value}),placeholder:`Enter report description`})]}),n.length>0&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Data Source`}),(0,$.jsxs)(`select`,{className:`w-full border rounded-md p-2`,children:[(0,$.jsx)(`option`,{value:``,children:`Select a data source`}),n.map((e,t)=>(0,$.jsxs)(`option`,{value:t,children:[`Data Source `,t+1]},t))]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Export Options`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:s.showExportButtons||!1,onChange:e=>c({...s,showExportButtons:e.target.checked})}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Show Export Buttons`})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:s.showPrintButton||!1,onChange:e=>c({...s,showPrintButton:e.target.checked})}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Show Print Button`})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{htmlFor:`export-format`,children:`Default Export Format`}),(0,$.jsxs)(`select`,{id:`export-format`,className:`w-full border rounded-md p-2`,value:s.defaultExportFormat||`pdf`,onChange:e=>c({...s,defaultExportFormat:e.target.value}),children:[(0,$.jsx)(`option`,{value:`pdf`,children:`PDF`}),(0,$.jsx)(`option`,{value:`excel`,children:`Excel`}),(0,$.jsx)(`option`,{value:`csv`,children:`CSV`}),(0,$.jsx)(`option`,{value:`json`,children:`JSON`}),(0,$.jsx)(`option`,{value:`html`,children:`HTML`})]})]})]})}),(0,$.jsxs)(q,{value:`fields`,className:`space-y-4 mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(X,{children:`Report Fields`}),(0,$.jsxs)(N,{size:`sm`,variant:`outline`,onClick:_,disabled:l.length>=r.length,children:[(0,$.jsx)(v,{className:`h-4 w-4 mr-2`}),`Add Field`]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[l.map((e,t)=>(0,$.jsx)(`div`,{className:`flex items-center gap-2 p-3 border rounded-lg`,children:(0,$.jsxs)(`div`,{className:`flex-1 grid grid-cols-4 gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Field Name`}),(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:e.name})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Label`}),(0,$.jsx)(Ve,{className:`h-8 text-sm`,value:e.label||e.name,onChange:n=>b(t,{...e,label:n.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Aggregation`}),(0,$.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.aggregation||``,onChange:n=>b(t,{...e,aggregation:n.target.value}),children:[(0,$.jsx)(`option`,{value:``,children:`None`}),(0,$.jsx)(`option`,{value:`sum`,children:`Sum`}),(0,$.jsx)(`option`,{value:`count`,children:`Count`}),(0,$.jsx)(`option`,{value:`avg`,children:`Average`}),(0,$.jsx)(`option`,{value:`min`,children:`Min`}),(0,$.jsx)(`option`,{value:`max`,children:`Max`})]})]}),(0,$.jsx)(`div`,{className:`flex items-end justify-end`,children:(0,$.jsx)(N,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50`,onClick:()=>y(t),children:(0,$.jsx)(ge,{className:`h-4 w-4`})})})]})},t)),l.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No fields selected. Click "Add Field" to begin.`})]})]}),(0,$.jsxs)(q,{value:`filters`,className:`space-y-4 mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(X,{children:`Report Filters`}),(0,$.jsxs)(N,{size:`sm`,variant:`outline`,onClick:S,children:[(0,$.jsx)(v,{className:`h-4 w-4 mr-2`}),`Add Filter`]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[d.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border rounded-lg`,children:[(0,$.jsxs)(`div`,{className:`flex-1 grid grid-cols-3 gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Field`}),(0,$.jsx)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.field,onChange:n=>w(t,{...e,field:n.target.value}),children:r.map((e,t)=>(0,$.jsx)(`option`,{value:e.name,children:e.label||e.name},t))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Operator`}),(0,$.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.operator,onChange:n=>w(t,{...e,operator:n.target.value}),children:[(0,$.jsx)(`option`,{value:`equals`,children:`Equals`}),(0,$.jsx)(`option`,{value:`contains`,children:`Contains`}),(0,$.jsx)(`option`,{value:`gt`,children:`Greater Than`}),(0,$.jsx)(`option`,{value:`lt`,children:`Less Than`}),(0,$.jsx)(`option`,{value:`between`,children:`Between`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Value`}),(0,$.jsx)(Ve,{className:`h-8 text-sm`,value:String(e.value),onChange:n=>w(t,{...e,value:n.target.value})})]})]}),(0,$.jsx)(N,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50 self-end`,onClick:()=>C(t),children:(0,$.jsx)(ge,{className:`h-4 w-4`})})]},t)),d.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No filters defined.`})]})]}),(0,$.jsxs)(q,{value:`grouping`,className:`space-y-4 mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(X,{children:`Grouping Rules`}),(0,$.jsxs)(N,{size:`sm`,variant:`outline`,onClick:E,children:[(0,$.jsx)(v,{className:`h-4 w-4 mr-2`}),`Add Group`]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[p.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border rounded-lg`,children:[(0,$.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Field`}),(0,$.jsx)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.field,onChange:n=>O(t,{...e,field:n.target.value}),children:r.map((e,t)=>(0,$.jsx)(`option`,{value:e.name,children:e.label||e.name},t))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Sort Order`}),(0,$.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.sort||`asc`,onChange:n=>O(t,{...e,sort:n.target.value}),children:[(0,$.jsx)(`option`,{value:`asc`,children:`Ascending`}),(0,$.jsx)(`option`,{value:`desc`,children:`Descending`})]})]})]}),(0,$.jsx)(N,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50 self-end`,onClick:()=>D(t),children:(0,$.jsx)(ge,{className:`h-4 w-4`})})]},t)),p.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No grouping rules applied.`})]})]}),(0,$.jsxs)(q,{value:`sections`,className:`space-y-4 mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(X,{children:`Report Sections`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(N,{size:`sm`,variant:`outline`,onClick:()=>k(`header`),children:[(0,$.jsx)(v,{className:`h-4 w-4 mr-2`}),`Header`]}),(0,$.jsxs)(N,{size:`sm`,variant:`outline`,onClick:()=>k(`chart`),children:[(0,$.jsx)(v,{className:`h-4 w-4 mr-2`}),`Chart`]}),(0,$.jsxs)(N,{size:`sm`,variant:`outline`,onClick:()=>k(`table`),children:[(0,$.jsx)(v,{className:`h-4 w-4 mr-2`}),`Table`]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[h.map((e,t)=>(0,$.jsxs)(`div`,{className:`p-3 border rounded-lg space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`font-medium flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs bg-muted px-2 py-0.5 rounded uppercase`,children:e.type}),e.title]}),(0,$.jsx)(N,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50`,onClick:()=>A(t),children:(0,$.jsx)(ge,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Title`}),(0,$.jsx)(Ve,{className:`h-8 text-sm`,value:e.title||``,onChange:n=>j(t,{...e,title:n.target.value})})]}),e.type===`text`&&(0,$.jsxs)(`div`,{className:`col-span-2`,children:[(0,$.jsx)(X,{className:`text-xs`,children:`Content`}),(0,$.jsx)(Ve,{className:`h-8 text-sm`,value:e.text||``,onChange:n=>j(t,{...e,text:n.target.value})})]}),e.type===`chart`&&(0,$.jsxs)(`div`,{className:`col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded`,children:[(0,$.jsx)(`div`,{className:`col-span-2`,children:(0,$.jsx)(X,{className:`text-xs font-semibold`,children:`Chart Configuration`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Chart Type`}),(0,$.jsxs)(`select`,{className:`flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,value:e.chart?.chartType||`bar`,onChange:n=>j(t,{...e,chart:{...e.chart,type:`chart`,chartType:n.target.value}}),children:[(0,$.jsx)(`option`,{value:`bar`,children:`Bar`}),(0,$.jsx)(`option`,{value:`line`,children:`Line`}),(0,$.jsx)(`option`,{value:`area`,children:`Area`}),(0,$.jsx)(`option`,{value:`pie`,children:`Pie`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`X-Axis Field`}),(0,$.jsxs)(`select`,{className:`flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,value:e.chart?.xAxisField||``,onChange:n=>j(t,{...e,chart:{...e.chart,type:`chart`,xAxisField:n.target.value}}),children:[(0,$.jsx)(`option`,{value:``,children:`Select Field...`}),r.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name)),r.length===0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`option`,{value:`name`,children:`Name`}),(0,$.jsx)(`option`,{value:`month`,children:`Month`})]})]})]}),(0,$.jsxs)(`div`,{className:`col-span-2`,children:[(0,$.jsx)(X,{className:`text-xs`,children:`Y-Axis Fields (comma separated)`}),(0,$.jsx)(Ve,{className:`h-8 text-sm`,placeholder:`e.g. value, count`,value:e.chart?.yAxisFields?.join(`, `)||``,onChange:n=>j(t,{...e,chart:{...e.chart,type:`chart`,yAxisFields:n.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}})})]})]})]})]},t)),h.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No customized sections. The default report layout will be used.`})]})]}),(0,$.jsx)(q,{value:`schedule`,className:`space-y-4 mt-4`,children:(0,$.jsx)(ea,{schedule:s.schedule,onChange:e=>c({...s,schedule:e})})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 mt-6 pt-4 border-t`,children:[(0,$.jsx)(N,{variant:`outline`,onClick:()=>{o&&console.log(`Report cancelled:`,o)},children:`Cancel`}),(0,$.jsxs)(N,{onClick:()=>{console.log(`Saving report:`,s),a&&alert(`Report saved! (Handler: `+a+`)`)},children:[(0,$.jsx)(L,{className:`h-4 w-4 mr-2`}),`Save Report`]})]})]})]}),i&&(0,$.jsxs)(B,{className:`mt-8 border-2 border-blue-100`,children:[(0,$.jsx)(H,{className:`bg-blue-50/50`,children:(0,$.jsx)(T,{className:`text-blue-900 text-sm uppercase tracking-wide`,children:`Live Preview`})}),(0,$.jsx)(x,{className:`pt-6`,children:(0,$.jsx)($i,{schema:{type:`report-viewer`,report:{...s,fields:l,filters:d,groupBy:p,sections:h},data:[{id:1,name:`Sample Item A`,value:100,status:`New`},{id:2,name:`Sample Item B`,value:250,status:`Active`},{id:3,name:`Sample Item C`,value:75,status:`Closed`}]}})})]})]})},na=[{value:``,label:`None`},{value:`sum`,label:`Sum`},{value:`count`,label:`Count`},{value:`avg`,label:`Average`},{value:`min`,label:`Min`},{value:`max`,label:`Max`}];function ra({availableFields:e,value:t,onChange:n}){let r=Array.isArray(t)?t.map(e=>typeof e==`string`?{name:e,label:e,type:`string`}:{name:e.name||e.field||e.value,label:e.label||e.name||``,type:e.type||`string`,aggregation:e.aggregation}):[],i=r.map(e=>e.name),a=t=>{let a=i.includes(t),o;if(a)o=r.filter(e=>e.name!==t);else{let n=e.find(e=>e.value===t);o=[...r,{name:t,label:n?.label||t,type:n?.type||`string`}]}n(o)},o=(e,t)=>{n(r.map(n=>n.name===e?{...n,aggregation:t||void 0,showInSummary:!!t}:n))};return e.length===0?(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground py-2`,"data-testid":`field-picker-empty`,children:`No fields available`}):(0,$.jsx)(`div`,{className:`space-y-1 py-1`,"data-testid":`field-picker`,children:e.map(e=>{let t=i.includes(e.value),n=r.find(t=>t.name===e.value);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 rounded hover:bg-muted/50 text-xs`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 flex-1 cursor-pointer`,children:[(0,$.jsx)(Ae,{checked:t,onCheckedChange:()=>a(e.value),"data-testid":`field-picker-${e.value}`}),(0,$.jsx)(`span`,{className:`flex-1`,children:e.label}),e.type&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.type})]}),t&&(0,$.jsx)(`select`,{className:`h-5 text-[10px] border rounded px-1 bg-background`,value:n?.aggregation||``,onChange:t=>o(e.value,t.target.value),"data-testid":`field-agg-${e.value}`,children:na.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]},e.value)})})}var ia=[{value:``,label:`None`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`area`,label:`Area Chart`},{value:`donut`,label:`Donut Chart`},{value:`scatter`,label:`Scatter Plot`}];function aa({availableFields:e,value:t,onChange:n}){let r=t||{},i=e=>n({...r,...e});return(0,$.jsxs)(`div`,{className:`space-y-2 py-1`,"data-testid":`chart-config`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:`Chart type`}),(0,$.jsx)(`select`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:r.chartType||``,onChange:e=>i({chartType:e.target.value||void 0}),"data-testid":`chart-type-select`,children:ia.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),r.chartType&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:`X-axis field`}),(0,$.jsxs)(`select`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:r.xAxisField||``,onChange:e=>i({xAxisField:e.target.value||void 0}),"data-testid":`chart-x-field`,children:[(0,$.jsx)(`option`,{value:``,children:`Select field…`}),e.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:`Y-axis field`}),(0,$.jsxs)(`select`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:r.yAxisFields?.[0]||``,onChange:e=>i({yAxisFields:e.target.value?[e.target.value]:[]}),"data-testid":`chart-y-field`,children:[(0,$.jsx)(`option`,{value:``,children:`Select field…`}),e.filter(e=>e.type===`number`).map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]})]})]})}var oa=[{value:`equals`,label:`=`},{value:`not_equals`,label:`≠`},{value:`greater_than`,label:`>`},{value:`less_than`,label:`<`},{value:`contains`,label:`Contains`}];function sa({availableFields:e,value:t,onChange:n}){let r=Array.isArray(t)?t:[],i=()=>{n([...r,{field:e[0]?.value||``,operator:`equals`,value:``,backgroundColor:`#fef9c3`,textColor:``}])},a=e=>{n(r.filter((t,n)=>n!==e))},o=(e,t)=>{n(r.map((n,r)=>r===e?{...n,...t}:n))};return(0,$.jsxs)(`div`,{className:`space-y-2 py-1`,"data-testid":`conditional-format-rules`,children:[r.map((t,n)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] p-1 border rounded bg-muted/20`,children:[(0,$.jsx)(`select`,{className:`h-5 text-[10px] border rounded px-1 bg-background flex-1`,value:t.field,onChange:e=>o(n,{field:e.target.value}),"data-testid":`cf-rule-field-${n}`,children:e.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,$.jsx)(`select`,{className:`h-5 text-[10px] border rounded px-1 bg-background w-12`,value:t.operator,onChange:e=>o(n,{operator:e.target.value}),children:oa.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,$.jsx)(`input`,{className:`h-5 text-[10px] border rounded px-1 bg-background w-16`,value:t.value,placeholder:`value`,onChange:e=>o(n,{value:e.target.value}),"data-testid":`cf-rule-value-${n}`}),(0,$.jsx)(`input`,{type:`color`,className:`h-5 w-5 rounded border cursor-pointer`,value:t.backgroundColor||`#fef9c3`,onChange:e=>o(n,{backgroundColor:e.target.value}),title:`Background color`}),(0,$.jsx)(N,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0`,onClick:()=>a(n),"data-testid":`cf-rule-remove-${n}`,children:(0,$.jsx)(ge,{className:`h-3 w-3`})})]},n)),(0,$.jsxs)(N,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 text-[10px] w-full`,onClick:i,"data-testid":`cf-add-rule`,children:[(0,$.jsx)(v,{className:`h-3 w-3 mr-1`}),`Add Rule`]})]})}var ca=[{value:`header`,label:`Header`},{value:`summary`,label:`Summary`},{value:`table`,label:`Table`},{value:`chart`,label:`Chart`},{value:`text`,label:`Text`}];function la({value:e,onChange:t}){let n=Array.isArray(e)?e:[],r=e=>{t([...n,{type:e,title:`New ${e}`,visible:!0}])},i=e=>{t(n.filter((t,n)=>n!==e))},a=(e,r)=>{t(n.map((t,n)=>n===e?{...t,...r}:t))},o=(e,r)=>{let i=e+r;if(i<0||i>=n.length)return;let a=[...n];[a[e],a[i]]=[a[i],a[e]],t(a)};return(0,$.jsxs)(`div`,{className:`space-y-2 py-1`,"data-testid":`section-manager`,children:[n.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] p-1.5 border rounded bg-muted/20`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 mr-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:t===0,onClick:()=>o(t,-1),"data-testid":`section-up-${t}`,children:`▲`}),(0,$.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:t===n.length-1,onClick:()=>o(t,1),"data-testid":`section-down-${t}`,children:`▼`})]}),(0,$.jsx)(`span`,{className:`text-[9px] bg-muted px-1.5 py-0.5 rounded uppercase font-medium shrink-0`,children:e.type}),(0,$.jsx)(`input`,{className:`h-5 text-[10px] border rounded px-1 bg-background flex-1 min-w-0`,value:e.title||``,placeholder:`Section title`,onChange:e=>a(t,{title:e.target.value}),"data-testid":`section-title-${t}`}),(0,$.jsx)(N,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:()=>i(t),"data-testid":`section-remove-${t}`,children:(0,$.jsx)(ge,{className:`h-3 w-3`})})]},t)),(0,$.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:ca.map(e=>(0,$.jsxs)(N,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 text-[10px]`,onClick:()=>r(e.value),"data-testid":`section-add-${e.value}`,children:[(0,$.jsx)(v,{className:`h-3 w-3 mr-0.5`}),e.label]},e.value))})]})}function ua(e=[]){return{breadcrumb:[`Report`,`Configuration`],sections:[{key:`basic`,title:`Basic`,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Report title`},{key:`description`,label:`Description`,type:`input`,placeholder:`Report description`},{key:`reportType`,label:`Report type`,type:`select`,defaultValue:`tabular`,options:[{value:`tabular`,label:`Tabular`},{value:`summary`,label:`Summary`},{value:`matrix`,label:`Matrix`}],helpText:`Tabular: flat table. Summary: grouped with subtotals. Matrix: pivot table (planned).`}]},{key:`data`,title:`Data`,collapsible:!0,fields:[{key:`objectName`,label:`Data source`,type:`input`,placeholder:`e.g. opportunity`,helpText:`Object name to query data from`},{key:`limit`,label:`Row limit`,type:`input`,defaultValue:`100`,placeholder:`e.g. 100`}]},{key:`columns`,title:`Columns`,collapsible:!0,hint:`Select fields to display as report columns. Set aggregation per column for summary reports.`,fields:[{key:`fields`,label:`Report columns`,type:`custom`,render:(t,n)=>(0,$.jsx)(ra,{availableFields:e,value:t,onChange:n})}]},{key:`filters`,title:`Filters`,collapsible:!0,hint:`Define filter conditions for the report data`,fields:[{key:`filters`,label:`Conditions`,type:`filter`,fields:e}]},{key:`groupBy`,title:`Group By`,collapsible:!0,hint:`Group report data and compute aggregations`,fields:[{key:`groupBy`,label:`Grouping`,type:`sort`,fields:e}]},{key:`chart`,title:`Chart`,collapsible:!0,hint:`Add a chart visualization to the report`,fields:[{key:`chartConfig`,label:`Chart`,type:`custom`,render:(t,n)=>(0,$.jsx)(aa,{availableFields:e,value:t,onChange:n})}]},{key:`conditionalFormatting`,title:`Conditional Format`,collapsible:!0,defaultCollapsed:!0,hint:`Highlight cells based on field value conditions`,fields:[{key:`conditionalFormatting`,label:`Rules`,type:`custom`,render:(t,n)=>(0,$.jsx)(sa,{availableFields:e,value:t,onChange:n})}]},{key:`sections`,title:`Sections`,collapsible:!0,defaultCollapsed:!0,hint:`Manage report layout blocks (header, table, chart, summary)`,fields:[{key:`sections`,label:`Report sections`,type:`custom`,render:(e,t)=>(0,$.jsx)(la,{value:e,onChange:t})}]},{key:`export`,title:`Export`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`showExportButtons`,label:`Show export buttons`,type:`switch`,defaultValue:!0},{key:`showPrintButton`,label:`Show print button`,type:`switch`,defaultValue:!0},{key:`defaultExportFormat`,label:`Default export format`,type:`select`,defaultValue:`pdf`,options:[{value:`pdf`,label:`PDF`},{value:`excel`,label:`Excel`},{value:`csv`,label:`CSV`},{value:`json`,label:`JSON`},{value:`html`,label:`HTML`}]}]},{key:`schedule`,title:`Schedule`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`schedule`,label:`Schedule`,type:`custom`,render:(e,t)=>(0,$.jsx)(ea,{schedule:e,onChange:t})}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`showToolbar`,label:`Show toolbar`,type:`switch`,defaultValue:!0},{key:`refreshInterval`,label:`Refresh interval`,type:`select`,defaultValue:`0`,options:[{value:`0`,label:`Manual`},{value:`30`,label:`30s`},{value:`60`,label:`1 min`},{value:`300`,label:`5 min`}]}]}]}}function da({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,availableFields:a}){let{draft:o,isDirty:s,updateField:c,discard:l,undo:u,redo:d,canUndo:f,canRedo:p}=Oe(n,{onUpdate:i});return(0,$.jsx)($e,{open:e,onClose:t,schema:Q.useMemo(()=>ua(a),[a]),draft:o,isDirty:s,onFieldChange:c,onSave:()=>r(o),onDiscard:l,onUndo:u,onRedo:d,canUndo:f,canRedo:p})}r.register(`report`,Li,{namespace:`report`,label:`Report`,category:`Report`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`chart`,type:`code`,label:`Chart Configuration`}]}),r.register(`report-viewer`,$i,{namespace:`report`,label:`Report Viewer`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Report Definition`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`}]}),r.register(`report-builder`,ta,{namespace:`report`,label:`Report Builder`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Initial Report`}]});export{wn as a,Ft as c,Ti as i,$i as n,bn as o,Ii as r,sn as s,da as t};
|