@objectstack/console 7.0.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AiPendingActionsPage-DLWrcsds.js → AiPendingActionsPage-B6prPdE6.js} +1 -1
- package/dist/assets/{ApiConsolePage-BIBykAYj.js → ApiConsolePage-KLlXE_J-.js} +1 -1
- package/dist/assets/{AppManagementPage-BKE0rv8B.js → AppManagementPage-CSGa-1u0.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-BOY6Xpsn.js +1 -0
- package/dist/assets/{AuditLogPage-Bqlhi2ko.js → AuditLogPage-DzIHYkL6.js} +1 -1
- package/dist/assets/ComponentNavView-CZkyv2fY.js +1 -0
- package/dist/assets/{ConsoleFloatingChatbot-CBIXkoNS.js → ConsoleFloatingChatbot-Dfub90-W.js} +1 -1
- package/dist/assets/DeveloperHubPage-lLRr5-aY.js +1 -0
- package/dist/assets/FlowRunsPage-DV2m0d1l.js +1 -0
- package/dist/assets/MonacoImpl-DcAVOHcx.js +1 -0
- package/dist/assets/ProfilePage-B4ZMNend.js +1 -0
- package/dist/assets/PublicFormsPage-CHWj3DL5.js +1 -0
- package/dist/assets/RecentItemsProvider-Dt0K6V1V.js +1 -0
- package/dist/assets/{SettingsHub-BTNCNbjZ.js → SettingsHub-DrmQJKTl.js} +1 -1
- package/dist/assets/{SettingsView-BLXf7B7b.js → SettingsView-DQ4mtooC.js} +1 -1
- package/dist/assets/{SystemHubPage-CgN-8VKO.js → SystemHubPage-CjV_--P3.js} +1 -1
- package/dist/assets/data-adapter-CX0Tq3Q5.js +1 -0
- package/dist/assets/dist-Dal4BOHf.js +11 -0
- package/dist/assets/{framework-ClI3DbWX.js → framework-DpQcF_QW.js} +4 -4
- package/dist/assets/{highlighted-body-OFNGDK62-Dua_6VJ2.js → highlighted-body-OFNGDK62-BcbCsvGi.js} +1 -1
- package/dist/assets/index-DUV_YMtu.css +2 -0
- package/dist/assets/index-hBFJ6de4.js +33 -0
- package/dist/assets/infrastructure-IQKE4Vv8.js +3 -0
- package/dist/assets/mermaid-GHXKKRXX-DLb_WlhX.js +1 -0
- package/dist/assets/plugin-calendar-BGJsyv_O.js +1 -0
- package/dist/assets/{plugin-charts-C11LxM1X.js → plugin-charts-CRlZ01tc.js} +2 -2
- package/dist/assets/plugin-chatbot-BhnqfdW0.js +120 -0
- package/dist/assets/plugin-dashboard-CUH4Dbo1.js +3 -0
- package/dist/assets/{plugin-form-f39dp3V2.js → plugin-form-BzrcwmiI.js} +1 -1
- package/dist/assets/plugin-gantt-Dt2juPb1.js +1 -0
- package/dist/assets/plugin-grid-BHnAwQNY.js +6 -0
- package/dist/assets/plugin-kanban-lsYbj6Vr.js +1 -0
- package/dist/assets/plugin-map-BKE-4AVm.js +1 -0
- package/dist/assets/plugin-markdown-bkOWrh0-.js +7 -0
- package/dist/assets/plugin-report-CqzUFpeK.js +59 -0
- package/dist/assets/plugin-timeline-ZI65E7h4.js +1 -0
- package/dist/assets/plugin-view-CGR-rgKC.js +1 -0
- package/dist/assets/plugins-views-CzwBozRK.js +4 -0
- package/dist/assets/src-0fzF-kZX.js +2 -0
- package/dist/assets/{types-CuyLcCWX.js → types-C7d65SSU.js} +1 -1
- package/dist/assets/ui-components-CXy53m_o.js +41 -0
- package/dist/assets/ui-layout-BqvRQUkZ.js +1 -0
- package/dist/assets/{vendor-charts-vh1WJI0j.js → vendor-charts-Ba_-W-di.js} +3 -3
- package/dist/assets/{vendor-dndkit-0jp7h5ty.js → vendor-dndkit-CucFgdMa.js} +1 -1
- package/dist/assets/{vendor-i18n-CnFu8bdi.js → vendor-i18n-DPyFo2xM.js} +1 -1
- package/dist/assets/{vendor-icons-core-D5MicM14.js → vendor-icons-core-Cx2WYOuR.js} +1 -1
- package/dist/assets/{vendor-markdown-CvMSBmgq.js → vendor-markdown-B0mCB2Nu.js} +2 -2
- package/dist/assets/vendor-objectstack-DdIVmQL0.js +65 -0
- package/dist/assets/{vendor-radix-BNWIlSsV.js → vendor-radix-thTS_QfF.js} +1 -1
- package/dist/assets/vendor-react-CyVA1SE-.js +13 -0
- package/dist/assets/{vendor-sentry-D5yZpZ5X.js → vendor-sentry-DjMgMAaz.js} +1 -1
- package/dist/assets/{vendor-ui-utils-D3GsyZyi.js → vendor-ui-utils-BbOuugky.js} +1 -1
- package/dist/favicon.svg +11 -0
- package/dist/index.html +7 -7
- package/dist/logo.svg +15 -0
- package/dist/manifest.json +2 -2
- package/package.json +1 -1
- package/dist/assets/ApprovalsInboxPage-D7gF2CM8.js +0 -1
- package/dist/assets/ComponentNavView-DBMxrUvH.js +0 -1
- package/dist/assets/DeveloperHubPage-C3Ooh2Gg.js +0 -1
- package/dist/assets/FlowRunsPage-NjEPPv_e.js +0 -1
- package/dist/assets/MonacoImpl-CKoKq1tG.js +0 -11
- package/dist/assets/ObjectManagerListPage-DEPokJwV.js +0 -1
- package/dist/assets/ProfilePage-zYSeu2-d.js +0 -1
- package/dist/assets/PublicFormsPage-BrLPiHf1.js +0 -1
- package/dist/assets/data-adapter-Dn6-L_yI.js +0 -1
- package/dist/assets/index-Ca4KaljM.js +0 -23
- package/dist/assets/index-DsQwZDFr.css +0 -2
- package/dist/assets/infrastructure-ezj3FgNE.js +0 -3
- package/dist/assets/mermaid-GHXKKRXX-BvEKnLTo.js +0 -1
- package/dist/assets/plugin-calendar-Dnr7itgk.js +0 -1
- package/dist/assets/plugin-chatbot-COnH_NZC.js +0 -120
- package/dist/assets/plugin-dashboard-DvBectcr.js +0 -3
- package/dist/assets/plugin-gantt-7ui7uiVc.js +0 -1
- package/dist/assets/plugin-grid-DtceFt_J.js +0 -6
- package/dist/assets/plugin-kanban-q2UT5MlD.js +0 -1
- package/dist/assets/plugin-map-C6vgk2bJ.js +0 -1
- package/dist/assets/plugin-markdown-DPzm2nVd.js +0 -7
- package/dist/assets/plugin-report-BJM4LH87.js +0 -59
- package/dist/assets/plugin-timeline-lCaTr_4i.js +0 -1
- package/dist/assets/plugin-view-b7gS6gIn.js +0 -1
- package/dist/assets/plugins-views-Dvl7pQvR.js +0 -4
- package/dist/assets/src-Con14F4e.js +0 -2
- package/dist/assets/ui-components-ZN8XdmwJ.js +0 -41
- package/dist/assets/ui-layout-HiDSueut.js +0 -1
- package/dist/assets/vendor-objectstack-CwZ3saTl.js +0 -65
- package/dist/assets/vendor-react-CIpZOxG3.js +0 -13
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{g as n,p as r,r as i}from"./vendor-react-CIpZOxG3.js";import{H as a,M as o,V as s,at as c,g as l,h as u,ot as d,t as f,ut as p}from"./framework-ClI3DbWX.js";import{At as m,C as h,Jn as g,Kn as _,La as v,Qn as y,Ut as b,Xn as x,Yn as S,_o as C,bo as w,br as T,c as E,en as D,es as ee,jr as O,k as te,l as ne,m as k,mr as A,qn as j,wi as M,yo as N}from"./ui-components-ZN8XdmwJ.js";import{_ as P,c as F,d as I,f as re,g as ie,h as L,l as R,m as z,n as ae,o as B,s as V,t as H}from"./vendor-dndkit-0jp7h5ty.js";import{i as oe,r as se}from"./plugins-views-Dvl7pQvR.js";import{n as ce}from"./plugin-grid-DtceFt_J.js";var le=t({KanbanEnhanced:()=>me,default:()=>me}),U=e(n(),1),W=i(),G=(...e)=>e.filter(Boolean).join(` `);function ue(e,t){if(!t||t.length===0)return{};for(let n of t){let t=e[n.field];if(t==null)continue;let r=!1,i=String(t);switch(n.operator){case`equals`:r=i===String(n.value);break;case`not_equals`:r=i!==String(n.value);break;case`contains`:r=i.toLowerCase().includes(String(n.value).toLowerCase());break;case`in`:r=Array.isArray(n.value)&&n.value.includes(i);break}if(r)return{...n.backgroundColor?{backgroundColor:n.backgroundColor}:{},...n.borderColor?{borderColor:n.borderColor}:{}}}return{}}function K({card:e,conditionalFormatting:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=B({id:e.id}),c={transform:P.Transform.toString(a),transition:o,opacity:s?.5:void 0},l=ue(e,t);return(0,W.jsx)(`div`,{ref:i,style:c,...n,...r,children:(0,W.jsxs)(_,{className:`mb-2 cursor-grab active:cursor-grabbing border-border bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group`,style:l,children:[e.coverImage&&(0,W.jsx)(`div`,{className:`w-full h-32 overflow-hidden rounded-t-lg`,children:(0,W.jsx)(`img`,{src:e.coverImage,alt:``,className:`w-full h-full object-cover`,loading:`lazy`})}),(0,W.jsxs)(S,{className:`p-4`,children:[(0,W.jsx)(x,{className:`text-sm font-medium tracking-tight text-foreground group-hover:text-primary transition-colors`,children:e.title}),e.description&&(0,W.jsx)(g,{className:`text-xs text-muted-foreground`,children:e.description})]}),e.badges&&e.badges.length>0&&(0,W.jsx)(j,{className:`p-4 pt-0`,children:(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.badges.map((e,t)=>(0,W.jsx)(y,{variant:e.colorClass?`outline`:e.variant||`default`,className:G(`text-xs font-normal`,e.colorClass),children:e.label},t))})})]})})}function de({cards:e,parentRef:t,conditionalFormatting:n}){let r=ce({count:e.length,getScrollElement:()=>t.current,estimateSize:()=>120,overscan:5});return(0,W.jsx)(`div`,{style:{height:`${r.getTotalSize()}px`,width:`100%`,position:`relative`},children:r.getVirtualItems().map(t=>{let r=e[t.index];return(0,W.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${t.start}px)`},children:(0,W.jsx)(K,{card:r,conditionalFormatting:n})},r.id)})})}function fe({columnId:e,onAdd:t}){let[n,r]=U.useState(!1),[i,a]=U.useState(``),o=U.useRef(null),s=()=>{let n=i.trim();n&&(t(e,n),a(``)),r(!1)};return n?(0,W.jsx)(`div`,{className:`mt-2 space-y-2`,children:(0,W.jsx)(D,{ref:o,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s()):e.key===`Escape`&&(a(``),r(!1))},onBlur:s,placeholder:`Enter card title...`,className:`text-sm`,autoFocus:!0})}):(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground`,onClick:()=>{r(!0),setTimeout(()=>o.current?.focus(),0)},children:[(0,W.jsx)(M,{className:`h-4 w-4 mr-1`}),`Add Card`]})}function pe({column:e,cards:t,onToggle:n,enableVirtual:r,quickAdd:i,onQuickAdd:a,conditionalFormatting:o}){let s=t||[],c=U.useRef(null),{setNodeRef:l}=B({id:e.id,data:{type:`column`}}),u=e.limit&&s.length>=e.limit,d=e.limit&&s.length>=e.limit*.8;return(0,W.jsxs)(`div`,{ref:l,className:G(`flex flex-col shrink-0 rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl transition-all`,e.collapsed?`w-16`:`w-80`,e.className),children:[(0,W.jsxs)(`div`,{className:`p-4 border-b border-border/50 bg-muted/20 flex items-center justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,W.jsx)(A,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>n(!e.collapsed),children:e.collapsed?(0,W.jsx)(C,{className:`h-4 w-4`}):(0,W.jsx)(N,{className:`h-4 w-4`})}),!e.collapsed&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{className:` text-sm font-semibold tracking-wider text-primary/90 uppercase truncate`,children:e.title}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:G(` text-xs`,u?`text-destructive`:d?`text-yellow-500`:`text-muted-foreground`),children:[s.length,e.limit&&` / ${e.limit}`]}),u&&(0,W.jsx)(y,{variant:`destructive`,className:`text-xs`,children:`Full`}),d&&!u&&(0,W.jsx)(O,{className:`h-3 w-3 text-yellow-500`})]})]})]}),e.collapsed&&(0,W.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,W.jsx)(`span`,{className:` text-xs font-bold text-primary/90 [writing-mode:vertical-rl] rotate-180`,children:e.title}),(0,W.jsx)(y,{variant:`secondary`,className:`text-xs`,children:s.length})]})]}),!e.collapsed&&(0,W.jsxs)(`div`,{ref:c,className:`flex-1 p-4 overflow-y-auto`,style:{maxHeight:`600px`},children:[(0,W.jsx)(H,{items:s.map(e=>e.id),strategy:V,children:r?(0,W.jsx)(de,{cards:s,parentRef:c,conditionalFormatting:o}):(0,W.jsx)(`div`,{className:`space-y-2`,children:s.map(e=>(0,W.jsx)(K,{card:e,conditionalFormatting:o},e.id))})}),i&&a&&(0,W.jsx)(fe,{columnId:e.id,onAdd:a})]})]})}function me({columns:e,onCardMove:t,onColumnToggle:n,enableVirtualScrolling:r=!1,virtualScrollThreshold:i=50,className:a,quickAdd:o,onQuickAdd:s,conditionalFormatting:c}){let[l,u]=U.useState(null),d=U.useMemo(()=>(e||[]).map(e=>({...e,cards:e.cards||[]})),[e]),[f,p]=U.useState(d);U.useEffect(()=>{p(d)},[d]);let m=ie(L(I,{activationConstraint:{distance:8}})),h=e=>{let{active:t}=e;u(_(t.id))},g=e=>{let{active:n,over:r}=e;if(u(null),!r)return;let i=n.id,a=r.id;if(i===a)return;let o=v(i),s=v(a)||y(a);if(!(!o||!s))if(o.id===s.id){let e=[...o.cards],t=ae(e,e.findIndex(e=>e.id===i),e.findIndex(e=>e.id===a));p(e=>e.map(e=>e.id===o.id?{...e,cards:t}:e))}else{let e=[...o.cards],n=[...s.cards],r=e.findIndex(e=>e.id===i),c=a===s.id?n.length:n.findIndex(e=>e.id===a),[l]=e.splice(r,1);n.splice(c,0,l),p(t=>t.map(t=>t.id===o.id?{...t,cards:e}:t.id===s.id?{...t,cards:n}:t)),t&&t(i,o.id,s.id,c)}},_=U.useCallback(e=>{for(let t of f){let n=t.cards.find(t=>t.id===e);if(n)return n}return null},[f]),v=U.useCallback(e=>f.find(t=>t.cards.some(t=>t.id===e))||null,[f]),y=U.useCallback(e=>f.find(t=>t.id===e)||null,[f]),b=U.useCallback((e,t)=>{p(n=>n.map(n=>n.id===e?{...n,collapsed:t}:n)),n?.(e,t)},[n]);return(0,W.jsxs)(F,{sensors:m,collisionDetection:z,onDragStart:h,onDragEnd:g,children:[(0,W.jsx)(`div`,{className:G(`flex gap-4 overflow-x-auto p-4`,a),children:f.map(e=>{let t=r&&e.cards.length>i;return(0,W.jsx)(pe,{column:e,cards:e.cards,onToggle:t=>b(e.id,t),enableVirtual:t,quickAdd:o,onQuickAdd:s,conditionalFormatting:c},e.id)})}),(0,W.jsx)(R,{children:l?(0,W.jsx)(K,{card:l,conditionalFormatting:c}):null})]})}var he=t({default:()=>be}),q=(...e)=>e.filter(Boolean).join(` `),J=f({"kanban.addCard":`Add card`,"kanban.noCards":`No cards`,"kanban.cardTitlePlaceholder":`Enter card title...`},`kanban.noCards`),Y=`Uncategorized`;function ge(e,t){if(!t||t.length===0)return{};for(let n of t){let t=e[n.field];if(t==null)continue;let r=!1,i=String(t);switch(n.operator){case`equals`:r=i===String(n.value);break;case`not_equals`:r=i!==String(n.value);break;case`contains`:r=i.toLowerCase().includes(String(n.value).toLowerCase());break;case`in`:r=Array.isArray(n.value)&&n.value.includes(i);break}if(r)return{...n.backgroundColor?{backgroundColor:n.backgroundColor}:{},...n.borderColor?{borderColor:n.borderColor}:{}}}return{}}function X({card:e,onCardClick:t,conditionalFormatting:n}){let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s,isDragging:c}=B({id:e.id}),l={transform:P.Transform.toString(o),transition:s,opacity:c?.5:void 0},u=ge(e,n);return(0,W.jsx)(`div`,{ref:a,style:l,...r,...i,role:`listitem`,"aria-label":e.title,onClick:n=>t?.(e,n),children:(0,W.jsxs)(_,{className:`mb-2 cursor-grab active:cursor-grabbing border-border border-l-4 border-l-primary/40 bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group touch-manipulation`,style:u,children:[e.coverImage&&(0,W.jsx)(`div`,{className:`w-full h-32 overflow-hidden rounded-t-lg`,children:(0,W.jsx)(`img`,{src:e.coverImage,alt:``,className:`w-full h-full object-cover`,loading:`lazy`})}),(0,W.jsxs)(S,{className:`p-2 sm:p-4 pb-2`,children:[(0,W.jsx)(x,{className:`text-xs sm:text-sm font-semibold tracking-tight text-foreground group-hover:text-primary transition-colors leading-snug line-clamp-2`,children:e.title}),!(e.cardFieldCells&&e.cardFieldCells.length>0)&&(e.cardSubtitle??e.description)&&(0,W.jsx)(g,{className:`text-xs text-muted-foreground line-clamp-2 sm:line-clamp-none`,children:e.cardSubtitle??e.description})]}),(e.cardFieldCells&&e.cardFieldCells.length>0||e.badges&&e.badges.length>0)&&(0,W.jsxs)(j,{className:`p-2 sm:p-4 pt-0 space-y-1.5`,children:[e.cardFieldCells&&e.cardFieldCells.length>0&&(0,W.jsx)(`dl`,{className:`space-y-1 text-xs`,children:e.cardFieldCells.map(e=>(0,W.jsxs)(`div`,{className:`min-w-0 truncate text-foreground/85`,title:e.label||e.field,children:[(0,W.jsx)(`dt`,{className:`sr-only`,children:e.label||e.field}),(0,W.jsx)(`dd`,{className:`min-w-0 truncate`,children:e.node})]},e.field))}),e.badges&&e.badges.length>0&&(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.badges.map((e,t)=>(0,W.jsx)(y,{variant:e.colorClass?`outline`:e.variant||`default`,className:q(`text-xs font-normal`,e.colorClass),children:e.label},t))})]})]})})}function _e({columnId:e,onAdd:t}){let{t:n}=J(),[r,i]=U.useState(!1),[a,o]=U.useState(``),s=U.useRef(null),c=()=>{let n=a.trim();n&&(t(e,n),o(``)),i(!1)};return r?(0,W.jsx)(`div`,{className:`mt-2 space-y-2`,children:(0,W.jsx)(D,{ref:s,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),c()):e.key===`Escape`&&(o(``),i(!1))},onBlur:c,placeholder:n(`kanban.cardTitlePlaceholder`),className:`text-sm`,autoFocus:!0})}):(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground`,onClick:()=>{i(!0),setTimeout(()=>s.current?.focus(),0)},children:[(0,W.jsx)(M,{className:`h-4 w-4 mr-1`}),n(`kanban.addCard`)]})}function ve({column:e,cards:t,onCardClick:n,quickAdd:r,onQuickAdd:i,conditionalFormatting:a,columnStyle:o,suppressEmptyPlaceholder:s}){let{t:c}=J(),l=t||[],{setNodeRef:u,isOver:d}=B({id:e.id,data:{type:`column`}}),f=e.limit&&l.length>=e.limit,p=o&&o.width!=null?`shrink-0`:`w-[85vw] sm:w-80 shrink-0`;return(0,W.jsxs)(`div`,{ref:u,role:`group`,"aria-label":e.title,style:o,className:q(`relative flex flex-col rounded-xl border border-border/60 bg-muted/15 snap-start max-h-full min-h-0 transition-all duration-200 shadow-sm hover:shadow-md overflow-hidden`,p,d&&`ring-2 ring-primary/60 bg-primary/5`,e.className),children:[(0,W.jsx)(`div`,{className:`px-3 sm:px-4 pt-3 pb-2.5 border-b border-border/40`,children:(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`h3`,{id:`kanban-col-${e.id}`,className:`text-xs sm:text-[13px] font-semibold tracking-tight truncate text-foreground/85 uppercase`,children:e.title}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,W.jsxs)(`span`,{className:q(`inline-flex items-center justify-center min-w-[22px] h-[20px] px-1.5 rounded-md text-[11px] font-medium tabular-nums`,f?`bg-destructive/10 text-destructive ring-1 ring-inset ring-destructive/30`:`bg-muted/70 text-muted-foreground`),children:[l.length,e.limit&&(0,W.jsx)(`span`,{className:`text-muted-foreground/70 font-normal`,children:` / ${e.limit}`})]}),f&&(0,W.jsx)(y,{variant:`destructive`,className:`text-[10px] h-[20px] px-1.5`,children:`Full`})]})]})}),(0,W.jsxs)(b,{className:`flex-1 p-4`,children:[(0,W.jsx)(H,{items:l.map(e=>e.id),strategy:V,children:(0,W.jsxs)(`div`,{className:`space-y-2`,role:`list`,"aria-label":`${e.title} cards`,children:[l.length===0&&!s&&(0,W.jsxs)(`div`,{className:q(`flex flex-col items-center justify-center py-6 rounded-md border-2 border-dashed transition-colors gap-1`,d?`border-primary/60 bg-primary/10 text-primary`:`border-border/40 text-muted-foreground/60`),children:[!d&&r&&i&&(0,W.jsx)(M,{className:`h-3.5 w-3.5 opacity-60`,"aria-hidden":!0}),(0,W.jsxs)(`span`,{className:`text-xs`,children:[d?`↓ `:``,c(`kanban.noCards`)]})]}),l.map(e=>(0,W.jsx)(X,{card:e,onCardClick:n,conditionalFormatting:a},e.id))]})}),r&&i&&(0,W.jsx)(_e,{columnId:e.id,onAdd:i})]})]})}function ye({children:e}){return(0,W.jsx)(W.Fragment,{children:e(u())})}function be({columns:e,onCardMove:t,onCardClick:n,className:r,quickAdd:i,onQuickAdd:a,coverImageField:o,conditionalFormatting:s,swimlaneField:c}){return l()?(0,W.jsx)(ye,{children:l=>(0,W.jsx)(xe,{columns:e,onCardMove:t,onCardClick:n,className:r,dnd:l,quickAdd:i,onQuickAdd:a,coverImageField:o,conditionalFormatting:s,swimlaneField:c})}):(0,W.jsx)(xe,{columns:e,onCardMove:t,onCardClick:n,className:r,dnd:null,quickAdd:i,onQuickAdd:a,coverImageField:o,conditionalFormatting:s,swimlaneField:c})}function xe({columns:e,onCardMove:t,onCardClick:n,className:r,dnd:i,quickAdd:a,onQuickAdd:o,coverImageField:s,conditionalFormatting:c,swimlaneField:l}){let{t:u}=J(),[d,f]=U.useState(null),p=U.useRef(null),{width:m}=h(p),g=U.useMemo(()=>m?m<480?{width:Math.max(m-32,220)}:m<720?{width:280}:{width:320}:{},[m]),_=l?`objectui:kanban-collapsed:${l}`:null,[v,y]=U.useState(()=>{if(!_)return new Set;try{let e=localStorage.getItem(_);if(e){let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}}catch{}return new Set}),b=U.useMemo(()=>(e||[]).map(e=>({...e,cards:e.cards||[]})),[e]),[x,S]=U.useState(b);U.useEffect(()=>{S(b)},[b]);let C=U.useMemo(()=>{if(!l)return null;let e=x.flatMap(e=>e.cards),t=new Set;return e.forEach(e=>{let n=e[l];t.add(n==null?Y:String(n))}),Array.from(t).sort()},[x,l]),w=U.useCallback(e=>{y(t=>{let n=new Set(t);if(n.has(e)?n.delete(e):n.add(e),_)try{localStorage.setItem(_,JSON.stringify([...n]))}catch{}return n})},[_]),T=ie(L(I,{activationConstraint:{distance:5}}),L(re,{activationConstraint:{delay:200,tolerance:5}})),E=e=>{let{active:t}=e,n=ee(t.id);if(f(n),i&&n){let e=O(n.id);e&&i.startDrag({id:n.id,type:`kanban-card`,data:n,sourceId:e.id})}},D=e=>{let{active:n,over:r}=e;if(f(null),!r){i&&i.endDrag();return}let a=n.id,o=r.id;if(a===o){i&&i.endDrag();return}let s=O(a),c=O(o)||ne(o);if(!s||!c){i&&i.endDrag();return}if(s.id===c.id){let e=[...s.cards],t=ae(e,e.findIndex(e=>e.id===a),e.findIndex(e=>e.id===o));S(e=>e.map(e=>e.id===s.id?{...e,cards:t}:e))}else{let e=[...s.cards],n=[...c.cards],r=e.findIndex(e=>e.id===a),i=o===c.id?n.length:n.findIndex(e=>e.id===o),[l]=e.splice(r,1);n.splice(i,0,l),S(t=>t.map(t=>t.id===s.id?{...t,cards:e}:t.id===c.id?{...t,cards:n}:t)),t&&t(a,s.id,c.id,i)}i&&i.endDrag(c.id)},ee=U.useCallback(e=>{for(let t of x){let n=t.cards.find(t=>t.id===e);if(n)return n}return null},[x]),O=U.useCallback(e=>x.find(t=>t.cards.some(t=>t.id===e))||null,[x]),ne=U.useCallback(e=>x.find(t=>t.id===e)||null,[x]),k=U.useRef(null),[A,j]=U.useState(0);return U.useEffect(()=>{let e=k.current;if(!e)return;let t=()=>{let t=e.clientWidth;if(t<=0)return;let n=Math.round(e.scrollLeft/t);j(Math.max(0,Math.min(x.length-1,n)))};return t(),e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[x.length]),(0,W.jsxs)(F,{sensors:T,collisionDetection:z,onDragStart:E,onDragEnd:D,children:[(0,W.jsxs)(`div`,{ref:p,className:`flex flex-col min-w-0 min-h-0 h-full`,children:[x.length>1&&(0,W.jsx)(`div`,{className:`flex sm:hidden items-center justify-center gap-1.5 px-3 pb-2`,"aria-hidden":!0,children:x.map((e,t)=>(0,W.jsx)(`span`,{className:q(`h-1.5 rounded-full transition-all`,t===A?`w-4 bg-foreground/70`:`w-1.5 bg-muted-foreground/30`)},e.id))}),(()=>{let e=x.reduce((e,t)=>e+(t.cards?.length||0),0)===0&&x.length>1;return(0,W.jsxs)(W.Fragment,{children:[e&&(0,W.jsx)(`div`,{className:`px-4 sm:px-6 pt-3`,children:(0,W.jsx)(te,{role:`status`,"aria-live":`polite`,showIcon:!1,className:`rounded-lg border border-dashed border-border/60 bg-muted/10 py-8 gap-2 [&>h3]:text-sm [&>h3]:font-medium [&>h3]:text-foreground/80`,title:u(`kanban.noCards`),description:`${x.length} ${u(`kanban.columns`,{defaultValue:`columns`})}`})}),C?(0,W.jsxs)(`div`,{className:q(`flex flex-col gap-2 px-4 sm:px-6 py-3 sm:py-4 min-w-0 overflow-hidden`,r),role:`region`,"aria-label":`Kanban board with swimlanes`,children:[(0,W.jsx)(`div`,{className:`flex gap-3 sm:gap-4 pl-36 sm:pl-44 overflow-x-auto`,children:x.map(e=>(0,W.jsxs)(`div`,{className:`w-[85vw] sm:w-80 shrink-0 text-center`,children:[(0,W.jsx)(`span`,{className:` text-xs sm:text-sm font-semibold tracking-wider text-primary/90 uppercase`,children:e.title}),(0,W.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,e.cards.length,`)`]})]},e.id))}),C.map(e=>{let t=v.has(e),r=x.reduce((t,n)=>t+n.cards.filter(t=>(t[l]==null?Y:String(t[l]))===e).length,0);return(0,W.jsxs)(`div`,{className:`border rounded-lg bg-muted/10`,children:[(0,W.jsxs)(`button`,{className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-muted/30 transition-colors`,onClick:()=>w(e),"aria-expanded":!t,children:[(0,W.jsx)(`span`,{className:q(`transition-transform text-xs`,t?``:`rotate-90`),children:`▶`}),(0,W.jsx)(`span`,{className:` text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e}),(0,W.jsxs)(`span`,{className:` text-xs text-muted-foreground`,children:[`(`,r,`)`]})]}),!t&&(0,W.jsx)(`div`,{className:`flex gap-3 sm:gap-4 overflow-x-auto px-2 pb-3 pl-36 sm:pl-44`,children:x.map(t=>{let r=t.cards.filter(t=>(t[l]==null?Y:String(t[l]))===e);return(0,W.jsx)(`div`,{className:`w-[85vw] sm:w-80 shrink-0 min-h-[60px] rounded-md bg-card/20 p-2`,children:(0,W.jsx)(H,{items:r.map(e=>e.id),strategy:V,children:(0,W.jsx)(`div`,{className:`space-y-2`,role:`list`,"aria-label":`${t.title} - ${e} cards`,children:r.map(e=>(0,W.jsx)(X,{card:e,onCardClick:n,conditionalFormatting:c},e.id))})})},t.id)})})]},e)})]}):(0,W.jsx)(`div`,{ref:k,className:q(`flex gap-3 sm:gap-4 overflow-x-auto snap-x snap-mandatory px-4 sm:px-6 py-3 sm:py-4 [-webkit-overflow-scrolling:touch] min-w-0 min-h-0 h-full`,r),role:`region`,"aria-label":`Kanban board`,children:x.map(t=>(0,W.jsx)(ve,{column:t,cards:t.cards,onCardClick:n,quickAdd:a,onQuickAdd:o,conditionalFormatting:c,columnStyle:g,suppressEmptyPlaceholder:e},t.id))})]})})()]}),(0,W.jsx)(R,{dropAnimation:{duration:200,easing:`cubic-bezier(0.18, 0.67, 0.6, 1.22)`},children:(0,W.jsx)(`div`,{"aria-live":`assertive`,"aria-label":d?`Dragging ${d.title}`:void 0,className:q(d&&`motion-safe:rotate-2 motion-safe:scale-[1.03] motion-safe:transition-transform shadow-2xl shadow-primary/25 ring-1 ring-primary/40 rounded-xl cursor-grabbing`),children:d?(0,W.jsx)(X,{card:d,conditionalFormatting:c}):null})})]})}var Z=({schema:e,dataSource:t,className:n,data:r,loading:i,onRowClick:a,onCardClick:l,...u})=>{let{translateOptions:f,fieldLabel:p}=ee(),m=Array.isArray(r),[h,g]=(0,U.useState)([]),[_,v]=(0,U.useState)(null),[y,b]=(0,U.useState)(m?i??!1:!1),[x,S]=(0,U.useState)(null),[C,w]=(0,U.useState)(0),T=s(e.bind);(0,U.useEffect)(()=>{if(!m&&!(!t?.onMutation||!e.objectName))return t.onMutation(t=>{t.resource===e.objectName&&w(e=>e+1)})},[t,e.objectName,m]),(0,U.useEffect)(()=>{m&&i!==void 0&&b(i)},[i,m]),(0,U.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&v(r)}catch(e){console.warn(`Failed to fetch object def`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,U.useEffect)(()=>{if(m)return;let n=!0;return e.objectName&&!T&&!e.data&&(async()=>{if(!(!t||typeof t.find!=`function`||!e.objectName)){n&&b(!0);try{let r=c(_?.fields),i=d(await t.find(e.objectName,{options:{$top:100},$filter:e.filter,...r.length>0?{$expand:r}:{}}));n&&g(i)}catch(e){console.error(`[ObjectKanban] Fetch error:`,e),n&&S(e)}finally{n&&b(!1)}}})(),()=>{n=!1}},[e.objectName,t,T,e.data,e.filter,m,_,C]);let D=(m?r:void 0)||T||e.data||h,O=(0,U.useMemo)(()=>{if(!Array.isArray(D))return[];let t=e.cardTitle||e.titleField,n=[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`],r=_?.titleFormat,i=typeof r==`string`?r:r&&typeof r==`object`&&typeof r.source==`string`?r.source:void 0,a=_?.NAME_FIELD_KEY,o=(e,t)=>{let n=`[-\\u2013\\u2014|/·,:]`,r=!1,i=e.replace(/\{([^{}]+)\}/g,(e,n)=>{let i=t[n.trim()];return i!=null&&i!==``?(r=!0,String(i)):`\0`});return r?i.replace(RegExp(`\\s*${n}\\s*`,`g`),``).replace(RegExp(`\\s*${n}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim():``};return D.map(r=>{let s;if(t&&(s=r[t],typeof s==`string`&&(s=s.trim())),!s&&i){let e=o(i,r);e&&(s=e)}if(!s&&a){let e=r[a];typeof e==`string`?s=e.trim():e&&(s=e)}if(!s)for(let e of n){let t=r[e],n=typeof t==`string`?t.trim():t;if(n){s=n;break}}let c=e=>e>=1e6?`$${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e}`,l=/^[A-Za-z0-9_-]{12,32}$/,u=e=>{if(typeof e!=`string`||!l.test(e))return!1;let t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/[0-9_-]/.test(e);return t&&n||t&&r||n&&r},d=e=>{let t=r[e];if(t==null||t===``)return;if(typeof t==`object`){let e=t;for(let t of[`name`,`full_name`,`display_name`,`label`,`title`,`username`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return}if(typeof t!=`string`)return String(t);let n=_?.fields?.[e];if(!((n?.type===`lookup`||n?.type===`master_detail`||n?.type===`reference`)&&u(t))&&!u(t))return t},m=[],h=Array.isArray(e.cardFields)?e.cardFields:[],g=new Set([...t?[t]:[],...a?[a]:[],`name`,`full_name`,`title`,`subject`,`display_name`]),v=[],y=[];if(h.length>0)for(let t of h){if(g.has(t))continue;let n=_?.fields?.[t],i=r[t];if(!(i==null||i===``))if(n?.type===`picklist`||n?.type===`multipicklist`||Array.isArray(n?.options)&&n.options.length>0){let r=n?.options?.find(e=>String(e.value).toLowerCase()===String(i).toLowerCase()),a=r?.label||String(i),o=_?.name||e.objectName,s=o?f(o,t,[{value:String(r?.value??i),label:a}])[0]?.label??a:a,c=E(r?.color,i);v.push({label:s,colorClass:c})}else{let r=k(n??{type:`text`}),a=(0,W.jsx)(ne(r),{value:i,field:n??{name:t,type:r}});y.push({field:t,label:p(_?.name||e.objectName||``,t,n?.label||t),node:a})}}else{let e=[`amount`,`value`,`deal_value`,`expected_value`,`opportunity_value`].find(e=>typeof r[e]==`number`);e&&m.push(c(r[e]));let t=[`company`,`company_name`,`account`,`account_name`,`organization`],n;for(let e of t){let t=d(e);if(t){n=t;break}}n&&(!s||!String(s).includes(n))&&m.push(n);let i=[`owner`,`owner_name`,`assignee`,`assignee_name`],a;for(let e of i){let t=d(e);if(t){a=t;break}}a&&m.push(`@${a}`);for(let e of[`priority`,`severity`,`industry`,`rating`]){let t=r[e];if(t!=null&&t!==``){let n=(_?.fields?.[e])?.options?.find(e=>String(e.value).toLowerCase()===String(t).toLowerCase()),r=n?.label||String(t),i=E(n?.color,t);if(v.push({label:r,colorClass:i}),v.length>=2)break}}}let b=r.description,x=(b==null||b===``||typeof b==`string`&&u(b))&&m.length>0?m.join(` · `):void 0;return{...r,id:r.id||r._id,title:s||`Untitled`,...x?{cardSubtitle:x}:{},...y.length>0?{cardFieldCells:y}:{},...!Array.isArray(r.badges)&&v.length>0?{badges:v}:{}}})},[D,e,_]),te=(0,U.useMemo)(()=>{let t=t=>{if(!e.objectName||!e.groupBy)return t;let n=f(e.objectName,e.groupBy,[{value:String(t.id),label:t.title}])[0];return n?.label?{...t,title:n.label}:t};if(e.columns&&e.columns.length>0)if(typeof e.columns[0]==`string`){if(!e.groupBy)return e.columns.map(e=>({id:e,title:e}))}else return e.columns.map(t);if(e.groupBy&&_?.fields?.[e.groupBy]?.options){let t=_.fields[e.groupBy].options.map(e=>({value:e.value,label:e.label}));return(e.objectName?f(e.objectName,e.groupBy,t):t).map(e=>({id:e.value,title:e.label}))}if(e.groupBy&&O.length>0){let t=new Set(O.map(t=>t[e.groupBy]));return Array.from(t).map(e=>({id:String(e),title:String(e)}))}return[]},[e.columns,e.groupBy,e.objectName,O,_,f]),A=e.swimlaneField||e.grouping?.fields?.[0]?.field,j={...e,data:O,columns:te,className:n||e.className,...A?{swimlaneField:A}:{}},M=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},N=a??l;!N&&(M.mode===`drawer`||M.mode===`modal`||M.mode===`split`||M.mode);let P=o({navigation:M,objectName:e.objectName,onRowClick:N});if(x)return(0,W.jsxs)(`div`,{className:`p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive`,children:[`Error loading kanban data: `,x.message]});let F=e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1).replace(/_/g,` `)} Detail`:`Card Details`,I=U.useCallback(async(n,r,i,a)=>{let o=e.groupBy,s=e.objectName;if(!(!o||r===i)&&(m||g(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:i}:e)),!(!s||!t?.update)))try{await t.update(s,String(n),{[o]:i})}catch(e){console.warn(`[ObjectKanban] Failed to persist card move`,e),m||g(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:r}:e))}},[e.groupBy,e.objectName,t,m]);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Q,{schema:{...j,onCardClick:(e,t)=>{P.handleClick(e,t),l?.(e)},onCardMove:I}}),P.isOverlay&&P.isOpen&&P.selectedRecord&&(()=>{let n=e.objectName,r=P.selectedRecord,i=r.id??r._id;if(!n||i==null)return null;let a=e.cardTitle??e.titleField,o=a&&r[a]?String(r[a]):F;return(0,W.jsx)(se,{open:!0,onClose:P.close,title:o,record:r,objectName:n,recordId:i,dataSource:t,objectSchema:_,width:P.width??`min(960px, 60vw)`,fullPageHref:oe(n,i)??void 0,onFieldSave:async(e,r)=>{t?.update&&(await t.update(n,String(i),{[e]:r}),g(t=>t.map(t=>String(t.id??t._id)===String(i)?{...t,[e]:r}:t)))},onDelete:async()=>{t?.delete&&(await t.delete(n,String(i)),g(e=>e.filter(e=>String(e.id??e._id)!==String(i))))}})})()]})},Se=(...e)=>e.filter(Boolean).join(` `),Ce=({columnId:e,fields:t,onSubmit:n,onCancel:r,defaultValues:i})=>{let[a,o]=U.useState(()=>{let e={};for(let n of t)e[n.name]=i?.[n.name]??n.defaultValue??``;return e}),s=U.useRef(null);U.useEffect(()=>{let e=setTimeout(()=>s.current?.focus(),0);return()=>clearTimeout(e)},[]);let c=U.useCallback((e,t)=>{o(n=>({...n,[e]:t}))},[]),l=U.useCallback(()=>{Object.values(a).some(e=>typeof e==`string`?e.trim().length>0:e!=null)&&n(e,a)},[e,a,n]);return(0,W.jsxs)(`div`,{className:`mt-2 rounded-lg border border-primary/30 bg-card p-3 space-y-2 shadow-sm`,onKeyDown:U.useCallback(e=>{e.key===`Enter`?(e.preventDefault(),l()):e.key===`Escape`&&(e.preventDefault(),r())},[l,r]),role:`form`,"aria-label":`Quick add card`,children:[t.map((t,n)=>(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(`label`,{htmlFor:`qa-${e}-${t.name}`,className:`text-xs text-muted-foreground`,children:t.label??t.name}),we(t,a[t.name],c,n===0?s:void 0,`qa-${e}-${t.name}`)]},t.name)),(0,W.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,W.jsxs)(A,{type:`button`,size:`sm`,className:`h-7 text-xs gap-1`,onClick:l,children:[(0,W.jsx)(w,{className:`h-3 w-3`}),`Save`]}),(0,W.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 text-xs gap-1`,onClick:r,children:[(0,W.jsx)(T,{className:`h-3 w-3`}),`Cancel`]})]})]})};function we(e,t,n,r,i){let a=`text-sm h-8`;switch(e.type){case`select`:return(0,W.jsxs)(`select`,{ref:r,id:i,value:t??``,onChange:t=>n(e.name,t.target.value),className:Se(a,`w-full rounded-md border border-input bg-background px-2 py-1 text-sm ring-offset-background`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`),children:[(0,W.jsx)(`option`,{value:``,children:e.placeholder??`Select ${e.label??e.name}...`}),(e.options??[]).map(e=>(0,W.jsx)(`option`,{value:e.value,children:e.label},e.value))]});case`number`:return(0,W.jsx)(D,{ref:r,id:i,type:`number`,value:t??``,onChange:t=>n(e.name,t.target.value===``?``:Number(t.target.value)),placeholder:e.placeholder??`Enter ${e.label??e.name}...`,className:a});default:return(0,W.jsx)(D,{ref:r,id:i,type:`text`,value:t??``,onChange:t=>n(e.name,t.target.value),placeholder:e.placeholder??`Enter ${e.label??e.name}...`,className:a})}}var Te=(...e)=>e.filter(Boolean).join(` `),Ee=({templates:e,onSelect:t,columnId:n})=>{let[r,i]=U.useState(!1),a=U.useRef(null);return U.useEffect(()=>{if(!r)return;let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]),(0,W.jsxs)(`div`,{ref:a,className:`relative`,onKeyDown:U.useCallback(e=>{e.key===`Escape`&&i(!1)},[]),children:[(0,W.jsxs)(A,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground gap-1`,onClick:()=>i(e=>!e),"aria-haspopup":`listbox`,"aria-expanded":r,"aria-label":`Add card to ${n}`,children:[(0,W.jsx)(M,{className:`h-4 w-4`}),`Add Card`,(0,W.jsx)(N,{className:Te(`h-3 w-3 transition-transform`,r?`rotate-180`:``)})]}),r&&(0,W.jsxs)(`div`,{className:`absolute z-50 mt-1 w-full rounded-md border border-border bg-popover p-1 shadow-md`,role:`listbox`,"aria-label":`Card templates`,children:[(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground transition-colors`,role:`option`,"aria-selected":!1,onClick:()=>{t(null),i(!1)},children:[(0,W.jsx)(M,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`font-mono text-xs`,children:`Custom`})]}),e.length>0&&(0,W.jsx)(`div`,{className:`my-1 h-px bg-border`,role:`separator`}),e.map(e=>(0,W.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground transition-colors`,role:`option`,"aria-selected":!1,onClick:()=>{t(e),i(!1)},children:[(0,W.jsx)(v,{className:`h-4 w-4 text-muted-foreground`}),(0,W.jsx)(`span`,{className:`font-mono text-xs truncate`,children:e.name})]},e.id))]})]})},De=`objectui:kanban-column-widths`;function Oe(e){try{let t=localStorage.getItem(e);if(t){let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return e}}catch{}return{}}function ke(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function Ae({columns:e,defaultWidth:t=320,minWidth:n=200,maxWidth:r=600,storageKey:i}){let a=i?`${De}:${i}`:De,[o,s]=(0,U.useState)(()=>Oe(a)),c=(0,U.useCallback)(e=>Math.max(n,Math.min(r,e)),[n,r]);return{getColumnWidth:(0,U.useCallback)(e=>{let n=o[e];return n==null?t:c(n)},[o,t,c]),setColumnWidth:(0,U.useCallback)((e,t)=>{let n=c(t);s(t=>{let r={...t,[e]:n};return ke(a,r),r})},[c,a]),resetWidths:(0,U.useCallback)(()=>{s({});try{localStorage.removeItem(a)}catch{}},[a]),config:(0,U.useMemo)(()=>({defaultWidth:t,minWidth:n,maxWidth:r,overrides:{...o}}),[t,n,r,o])}}function je({swimlanes:e,onCardMove:t}){let[n,r]=(0,U.useState)(null),i=(0,U.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.id,n);return t},[e]),a=(0,U.useCallback)((e,t)=>{if(e===t)return!0;let n=i.get(t);return n?n.acceptFrom?n.acceptFrom.includes(e):!0:!1},[i]),o=(0,U.useCallback)((e,n,i,o)=>a(n,i)?(t?.({cardId:e,fromSwimlane:n,toSwimlane:i,columnId:o}),r(null),!0):!1,[a,t]),s=(0,U.useCallback)(e=>{r(e)},[]),c=(0,U.useCallback)(()=>{r(null)},[]);return{handleCrossSwimlaneMove:o,isDraggingAcrossSwimlanes:n!==null,startCrossSwimlaneDrag:s,endCrossSwimlaneDrag:c,canMoveTo:a}}function Me({cards:e,onReorderComplete:t}){let[n,r]=(0,U.useState)(e),[i,a]=(0,U.useState)(!1);!Ne(n,e)&&!i&&r(e);let o=(0,U.useCallback)(()=>{r(e),a(!1)},[e]);return{reorderedCards:n,onReorder:(0,U.useCallback)((e,t)=>{r(n=>{if(e<0||t<0||e>=n.length||t>=n.length)return n;let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r})},[]),isDragging:i,startDrag:(0,U.useCallback)(()=>{a(!0)},[]),endDrag:(0,U.useCallback)(()=>{a(!1),r(e=>(t?.(e),e))},[t]),reset:o}}function Ne(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].id!==t[n].id)return!1;return!0}var Pe=t({CardTemplates:()=>Ee,InlineQuickAdd:()=>Ce,KanbanRenderer:()=>Q,ObjectKanban:()=>Z,ObjectKanbanRenderer:()=>$,kanbanComponents:()=>Le,useColumnWidths:()=>Ae,useCrossSwimlaneMove:()=>je,useQuickAddReorder:()=>Me}),Fe=U.lazy(()=>r(()=>Promise.resolve().then(()=>he),void 0,import.meta.url)),Ie=U.lazy(()=>r(()=>Promise.resolve().then(()=>le),void 0,import.meta.url)),Q=({schema:e})=>{let t=U.useMemo(()=>{let{columns:t=[],data:n,groupBy:r,coverImageField:i}=e,a=e=>{if(!i)return e;let t=e[i];if(!t)return e;let n=typeof t==`string`?t:t?.url;return n?{...e,coverImage:n}:e};if(n&&r&&Array.isArray(n)){let e={};t.forEach(t=>{t.id&&(e[String(t.id).toLowerCase()]=t.id),t.title&&(e[String(t.title).toLowerCase()]=t.id)});let i=n.reduce((t,n)=>{let i=String(n[r]??``),o=e[i.toLowerCase()]??i;return t[o]||(t[o]=[]),t[o].push(a(n)),t},{});return t.map(e=>({...e,cards:[...(e.cards||[]).map(a),...i[e.id]||[]]}))}return t.map(e=>({...e,cards:(e.cards||[]).map(a)}))},[e]);return(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(m,{className:`w-full h-[600px]`}),children:(0,W.jsx)(Fe,{columns:t,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,coverImageField:e.coverImageField,conditionalFormatting:e.conditionalFormatting,swimlaneField:e.swimlaneField})})};p.register(`kanban-ui`,Q,{namespace:`plugin-kanban`,label:`Kanban Board`,icon:`LayoutDashboard`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,description:`Array of { id, title, cards, limit, className }`,required:!0},{name:`onCardMove`,type:`code`,label:`On Card Move`,description:`Callback when a card is moved`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[{id:`todo`,title:`To Do`,cards:[{id:`card-1`,title:`Task 1`,description:`This is the first task`,badges:[{label:`High Priority`,variant:`destructive`},{label:`Feature`,variant:`default`}]},{id:`card-2`,title:`Task 2`,description:`This is the second task`,badges:[{label:`Bug`,variant:`destructive`}]}]},{id:`in-progress`,title:`In Progress`,limit:3,cards:[{id:`card-3`,title:`Task 3`,description:`Currently working on this`,badges:[{label:`In Progress`,variant:`default`}]}]},{id:`done`,title:`Done`,cards:[{id:`card-4`,title:`Task 4`,description:`This task is completed`,badges:[{label:`Completed`,variant:`outline`}]},{id:`card-5`,title:`Task 5`,description:`Another completed task`,badges:[{label:`Completed`,variant:`outline`}]}]}],className:`w-full`}});var Le={kanban:Q,"kanban-enhanced":Ie,"object-kanban":Z};p.register(`kanban-enhanced`,({schema:e})=>{let t=U.useMemo(()=>{let{columns:t=[],data:n,groupBy:r}=e;if(n&&r&&Array.isArray(n)){let e=n.reduce((e,t)=>{let n=t[r];return e[n]||(e[n]=[]),e[n].push(t),e},{});return t.map(t=>({...t,cards:[...t.cards||[],...e[t.id]||[]]}))}return t},[e]);return(0,W.jsx)(U.Suspense,{fallback:(0,W.jsx)(m,{className:`w-full h-[600px]`}),children:(0,W.jsx)(Ie,{columns:t,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,conditionalFormatting:e.conditionalFormatting})})},{namespace:`plugin-kanban`,label:`Kanban Board (Enhanced)`,icon:`LayoutGrid`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,required:!0},{name:`enableVirtualScrolling`,type:`boolean`,label:`Virtual Scrolling`,defaultValue:!1},{name:`virtualScrollThreshold`,type:`number`,label:`Virtual Scroll Threshold`,defaultValue:50},{name:`onCardMove`,type:`code`,label:`On Card Move`,advanced:!0},{name:`onColumnToggle`,type:`code`,label:`On Column Toggle`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[],enableVirtualScrolling:!1,virtualScrollThreshold:50,className:`w-full`}});var $=({schema:e,...t})=>{let{dataSource:n}=a()||{};return(0,W.jsx)(Z,{schema:e,dataSource:n,...t})};p.register(`object-kanban`,$,{namespace:`plugin-kanban`,label:`Object Kanban`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]}),p.register(`kanban`,$,{namespace:`view`,label:`Kanban Board`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]});export{Pe as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{g as n,h as r,p as i,r as a}from"./vendor-react-CIpZOxG3.js";import{_ as o,m as s,p as c,v as l}from"./vendor-objectstack-CwZ3saTl.js";import{H as u,M as d,at as f,ot as p,ut as m}from"./framework-ClI3DbWX.js";import{N as h,Zo as g,jt as ee}from"./ui-components-ZN8XdmwJ.js";var _=e(n(),1),v=_.createContext(null);function y(e,t){let n=Array.isArray(e)?e[0]:e?e.x:0,r=Array.isArray(e)?e[1]:e?e.y:0,i=Array.isArray(t)?t[0]:t?t.x:0,a=Array.isArray(t)?t[1]:t?t.y:0;return n===i&&r===a}function b(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!b(e[n],t[n]))return!1;return!0}else if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!t.hasOwnProperty(r)||!b(e[r],t[r]))return!1;return!0}return!1}function x(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function S(e,t){let n=t.viewState||t,r={};if(`longitude`in n&&`latitude`in n&&(n.longitude!==e.center.lng||n.latitude!==e.center.lat)){let t=e.center.constructor;r.center=new t(n.longitude,n.latitude)}return`zoom`in n&&n.zoom!==e.zoom&&(r.zoom=n.zoom),`bearing`in n&&n.bearing!==e.bearing&&(r.bearing=n.bearing),`pitch`in n&&n.pitch!==e.pitch&&(r.pitch=n.pitch),n.padding&&e.padding&&!b(n.padding,e.padding)&&(r.padding=n.padding),r}var C=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function w(e){if(!e)return null;if(typeof e==`string`||(`toJS`in e&&(e=e.toJS()),!e.layers))return e;let t={};for(let n of e.layers)t[n.id]=n;let n=e.layers.map(e=>{let n=null;`interactive`in e&&(n=Object.assign({},e),delete n.interactive);let r=t[e.ref];if(r){n||=Object.assign({},e),delete n.ref;for(let e of C)e in r&&(n[e]=r[e])}return n||e});return{...e,layers:n}}var T={version:8,sources:{},layers:[]},E={minZoom:0,maxZoom:22,minPitch:0,maxPitch:85,maxBounds:[-180,-85.051129,180,85.051129],projection:`mercator`,renderWorldCopies:!0},D={mousedown:`onMouseDown`,mouseup:`onMouseUp`,mouseover:`onMouseOver`,mousemove:`onMouseMove`,click:`onClick`,dblclick:`onDblClick`,mouseenter:`onMouseEnter`,mouseleave:`onMouseLeave`,mouseout:`onMouseOut`,contextmenu:`onContextMenu`,touchstart:`onTouchStart`,touchend:`onTouchEnd`,touchmove:`onTouchMove`,touchcancel:`onTouchCancel`},O={movestart:`onMoveStart`,move:`onMove`,moveend:`onMoveEnd`,dragstart:`onDragStart`,drag:`onDrag`,dragend:`onDragEnd`,zoomstart:`onZoomStart`,zoom:`onZoom`,zoomend:`onZoomEnd`,rotatestart:`onRotateStart`,rotate:`onRotate`,rotateend:`onRotateEnd`,pitchstart:`onPitchStart`,pitch:`onPitch`,pitchend:`onPitchEnd`},k={wheel:`onWheel`,boxzoomstart:`onBoxZoomStart`,boxzoomend:`onBoxZoomEnd`,boxzoomcancel:`onBoxZoomCancel`,resize:`onResize`,load:`onLoad`,render:`onRender`,idle:`onIdle`,remove:`onRemove`,data:`onData`,styledata:`onStyleData`,sourcedata:`onSourceData`,error:`onError`},A=[`minZoom`,`maxZoom`,`minPitch`,`maxPitch`,`maxBounds`,`projection`,`renderWorldCopies`],j=[`scrollZoom`,`boxZoom`,`dragRotate`,`dragPan`,`keyboard`,`doubleClickZoom`,`touchZoomRotate`,`touchPitch`],M=class e{constructor(e,t,n){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=e=>{let t=this.props[k[e.type]];t?t(e):e.type===`error`&&console.error(e.error)},this._onCameraEvent=e=>{if(this._internalUpdate)return;e.viewState=this._propsedCameraUpdate||x(this._map.transform);let t=this.props[O[e.type]];t&&t(e)},this._onCameraUpdate=e=>this._internalUpdate?e:(this._propsedCameraUpdate=x(e),S(e,this.props)),this._onPointerEvent=e=>{(e.type===`mousemove`||e.type===`mouseout`)&&this._updateHover(e);let t=this.props[D[e.type]];t&&(this.props.interactiveLayerIds&&e.type!==`mouseover`&&e.type!==`mouseout`&&(e.features=this._hoveredFeatures||this._queryRenderedFeatures(e.point)),t(e),delete e.features)},this._MapClass=e,this.props=t,this._initialize(n)}get map(){return this._map}setProps(e){let t=this.props;this.props=e;let n=this._updateSettings(e,t),r=this._updateSize(e),i=this._updateViewState(e);this._updateStyle(e,t),this._updateStyleComponents(e),this._updateHandlers(e,t),(n||r||i&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){let r=e.savedMaps.pop();if(!r)return null;let i=r.map,a=i.getContainer();for(n.className=a.className;a.childNodes.length>0;)n.appendChild(a.childNodes[0]);i._container=n;let o=i._resizeObserver;o&&(o.disconnect(),o.observe(n)),r.setProps({...t,styleDiffing:!1}),i.resize();let{initialViewState:s}=t;return s&&(s.bounds?i.fitBounds(s.bounds,{...s.fitBoundsOptions,duration:0}):r._updateViewState(s)),i.isStyleLoaded()?i.fire(`load`):i.once(`style.load`,()=>i.fire(`load`)),i._update(),r}_initialize(e){let{props:t}=this,{mapStyle:n=T}=t,r={...t,...t.initialViewState,container:e,style:w(n)},i=r.initialViewState||r.viewState||r;if(Object.assign(r,{center:[i.longitude||0,i.latitude||0],zoom:i.zoom||0,pitch:i.pitch||0,bearing:i.bearing||0}),t.gl){let e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=e,t.gl)}let a=new this._MapClass(r);i.padding&&a.setPadding(i.padding),t.cursor&&(a.getCanvas().style.cursor=t.cursor),a.transformCameraUpdate=this._onCameraUpdate,a.on(`style.load`,()=>{this._styleComponents={light:a.getLight(),sky:a.getSky(),projection:a.getProjection?.(),terrain:a.getTerrain()},this._updateStyleComponents(this.props)}),a.on(`sourcedata`,()=>{this._updateStyleComponents(this.props)});for(let e in D)a.on(e,this._onPointerEvent);for(let e in O)a.on(e,this._onCameraEvent);for(let e in k)a.on(e,this._onEvent);this._map=a}recycle(){this.map.getContainer().querySelector(`[mapboxgl-children]`)?.remove(),e.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){let e=this._map;e.style&&(e._frame&&=(e._frame.cancel(),null),e._render())}_updateSize(e){let{viewState:t}=e;if(t){let e=this._map;if(t.width!==e.transform.width||t.height!==e.transform.height)return e.resize(),!0}return!1}_updateViewState(e){let t=this._map,n=t.transform;if(!t.isMoving()){let r=S(n,e);if(Object.keys(r).length>0)return this._internalUpdate=!0,t.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(e,t){let n=this._map,r=!1;for(let i of A)if((i in e||i in t)&&!b(e[i],t[i])){r=!0;let t=i in e?e[i]:E[i];n[`set${i[0].toUpperCase()}${i.slice(1)}`]?.call(n,t)}return r}_updateStyle(e,t){if(e.cursor!==t.cursor&&(this._map.getCanvas().style.cursor=e.cursor||``),e.mapStyle!==t.mapStyle){let{mapStyle:t=T,styleDiffing:n=!0}=e,r={diff:n};`localIdeographFontFamily`in e&&(r.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(w(t),r)}}_updateStyleComponents({light:e,projection:t,sky:n,terrain:r}){let i=this._map,a=this._styleComponents;i.style?._loaded&&(e&&!b(e,a.light)&&(a.light=e,i.setLight(e)),t&&!b(t,a.projection)&&t!==a.projection?.type&&(a.projection=typeof t==`string`?{type:t}:t,i.setProjection?.(a.projection)),n&&!b(n,a.sky)&&(a.sky=n,i.setSky(n)),r!==void 0&&!b(r,a.terrain)&&(!r||i.getSource(r.source))&&(a.terrain=r,i.setTerrain(r)))}_updateHandlers(e,t){let n=this._map;for(let r of j){let i=e[r]??!0;b(i,t[r]??!0)||(i?n[r].enable(i):n[r].disable())}}_queryRenderedFeatures(e){let t=this._map,{interactiveLayerIds:n=[]}=this.props;try{return t.queryRenderedFeatures(e,{layers:n.filter(t.getLayer.bind(t))})}catch{return[]}}_updateHover(e){let{props:t}=this;if(t.interactiveLayerIds&&(t.onMouseMove||t.onMouseEnter||t.onMouseLeave)){let t=e.type,n=this._hoveredFeatures?.length>0,r=this._queryRenderedFeatures(e.point),i=r.length>0;!i&&n&&(e.type=`mouseleave`,this._onPointerEvent(e)),this._hoveredFeatures=r,i&&!n&&(e.type=`mouseenter`,this._onPointerEvent(e)),e.type=t}else this._hoveredFeatures=null}};M.savedMaps=[];var N=[`setMaxBounds`,`setMinZoom`,`setMaxZoom`,`setMinPitch`,`setMaxPitch`,`setRenderWorldCopies`,`setProjection`,`setStyle`,`addSource`,`removeSource`,`addLayer`,`removeLayer`,`setLayerZoomRange`,`setFilter`,`setPaintProperty`,`setLayoutProperty`,`setLight`,`setTerrain`,`setFog`,`remove`];function P(e){if(!e)return null;let t=e.map,n={getMap:()=>t};for(let e of F(t))!(e in n)&&!N.includes(e)&&(n[e]=t[e].bind(t));return n}function F(e){let t=new Set,n=e;for(;n;){for(let r of Object.getOwnPropertyNames(n))r[0]!==`_`&&typeof e[r]==`function`&&r!==`fire`&&r!==`setEventedParent`&&t.add(r);n=Object.getPrototypeOf(n)}return Array.from(t)}var I=typeof document<`u`?_.useLayoutEffect:_.useEffect;function L(e,t){let{RTLTextPlugin:n,maxParallelImageRequests:r,workerCount:i,workerUrl:a}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()===`unavailable`){let{pluginUrl:t,lazy:r=!0}=typeof n==`string`?{pluginUrl:n}:n;e.setRTLTextPlugin(t,e=>{e&&console.error(e)},r)}r!==void 0&&e.setMaxParallelImageRequests(r),i!==void 0&&e.setWorkerCount(i),a!==void 0&&e.setWorkerUrl(a)}var R=_.createContext(null);function z(t,n){let r=(0,_.useContext)(v),[a,o]=(0,_.useState)(null),s=(0,_.useRef)(),{current:c}=(0,_.useRef)({mapLib:null,map:null});(0,_.useEffect)(()=>{let n=t.mapLib,a=!0,l;return Promise.resolve(n||i(()=>import(`./maplibre-gl-CoREonuK.js`).then(t=>e(t.default,1)),[],import.meta.url)).then(e=>{if(!a)return;if(!e)throw Error(`Invalid mapLib`);let n=`Map`in e?e:e.default;if(!n.Map)throw Error(`Invalid mapLib`);L(n,t),t.reuseMaps&&(l=M.reuse(t,s.current)),l||=new M(n.Map,t,s.current),c.map=P(l),c.mapLib=n,o(l),r?.onMapMount(c.map,t.id)}).catch(e=>{let{onError:n}=t;n?n({type:`error`,target:null,originalEvent:null,error:e}):console.error(e)}),()=>{a=!1,l&&(r?.onMapUnmount(t.id),t.reuseMaps?l.recycle():l.destroy())}},[]),I(()=>{a&&a.setProps(t)}),(0,_.useImperativeHandle)(n,()=>c.map,[a]);let l=(0,_.useMemo)(()=>({position:`relative`,width:`100%`,height:`100%`,...t.style}),[t.style]);return _.createElement(`div`,{id:t.id,ref:s,style:l},a&&_.createElement(R.Provider,{value:c},_.createElement(`div`,{"mapboxgl-children":``,style:{height:`100%`}},t.children)))}var te=_.forwardRef(z),B=e(r(),1),V=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function H(e,t){if(!e||!t)return;let n=e.style;for(let e in t){let r=t[e];Number.isFinite(r)&&!V.test(e)?n[e]=`${r}px`:n[e]=r}}function U(e,t){if(e===t)return null;let n=W(e),r=W(t),i=[];for(let e of r)n.has(e)||i.push(e);for(let e of n)r.has(e)||i.push(e);return i.length===0?null:i}function W(e){return new Set(e?e.trim().split(/\s+/):[])}var G=(0,_.memo)((0,_.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,_.useContext)(R),i=(0,_.useRef)({props:e}),a=(0,_.useMemo)(()=>{let t=!1;_.Children.forEach(e.children,e=>{e&&(t=!0)});let n={...e,element:t?document.createElement(`div`):void 0},o=new r.Marker(n);return o.setLngLat([e.longitude,e.latitude]),o.getElement().addEventListener(`click`,e=>{i.current.props.onClick?.({type:`click`,target:o,originalEvent:e})}),o.on(`dragstart`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragStart?.(t)}),o.on(`drag`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDrag?.(t)}),o.on(`dragend`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragEnd?.(t)}),o},[]);(0,_.useEffect)(()=>(a.addTo(n.getMap()),()=>{a.remove()}),[]);let{longitude:o,latitude:s,offset:c,style:l,draggable:u=!1,popup:d=null,rotation:f=0,rotationAlignment:p=`auto`,pitchAlignment:m=`auto`}=e;(0,_.useEffect)(()=>{H(a.getElement(),l)},[l]),(0,_.useImperativeHandle)(t,()=>a,[]);let h=i.current.props;(a.getLngLat().lng!==o||a.getLngLat().lat!==s)&&a.setLngLat([o,s]),c&&!y(a.getOffset(),c)&&a.setOffset(c),a.isDraggable()!==u&&a.setDraggable(u),a.getRotation()!==f&&a.setRotation(f),a.getRotationAlignment()!==p&&a.setRotationAlignment(p),a.getPitchAlignment()!==m&&a.setPitchAlignment(m),a.getPopup()!==d&&a.setPopup(d);let g=U(h.className,e.className);if(g)for(let e of g)a.toggleClassName(e);return i.current.props=e,(0,B.createPortal)(e.children,a.getElement())})),ne=(0,_.memo)((0,_.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,_.useContext)(R),i=(0,_.useMemo)(()=>document.createElement(`div`),[]),a=(0,_.useRef)({props:e}),o=(0,_.useMemo)(()=>{let t={...e},n=new r.Popup(t);return n.setLngLat([e.longitude,e.latitude]),n.once(`open`,e=>{a.current.props.onOpen?.(e)}),n},[]);if((0,_.useEffect)(()=>{let e=e=>{a.current.props.onClose?.(e)};return o.on(`close`,e),o.setDOMContent(i).addTo(n.getMap()),()=>{o.off(`close`,e),o.isOpen()&&o.remove()}},[]),(0,_.useEffect)(()=>{H(o.getElement(),e.style)},[e.style]),(0,_.useImperativeHandle)(t,()=>o,[]),o.isOpen()){let t=a.current.props;(o.getLngLat().lng!==e.longitude||o.getLngLat().lat!==e.latitude)&&o.setLngLat([e.longitude,e.latitude]),e.offset&&!b(t.offset,e.offset)&&o.setOffset(e.offset),(t.anchor!==e.anchor||t.maxWidth!==e.maxWidth)&&(o.options.anchor=e.anchor,o.setMaxWidth(e.maxWidth));let n=U(t.className,e.className);if(n)for(let e of n)o.toggleClassName(e);a.current.props=e}return(0,B.createPortal)(e.children,i)}));function K(e,t,n,r){let i=(0,_.useContext)(R),a=(0,_.useMemo)(()=>e(i),[]);return(0,_.useEffect)(()=>{let e=r||n||t,o=typeof t==`function`&&typeof n==`function`?t:null,s=typeof n==`function`?n:typeof t==`function`?t:null,{map:c}=i;return c.hasControl(a)||(c.addControl(a,e?.position),o&&o(i)),()=>{s&&s(i),c.hasControl(a)&&c.removeControl(a)}},[]),a}function q(e){let t=K(({mapLib:t})=>new t.AttributionControl(e),{position:e.position});return(0,_.useEffect)(()=>{H(t._container,e.style)},[e.style]),null}(0,_.memo)(q);function J(e){let t=K(({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return(0,_.useEffect)(()=>{H(t._controlContainer,e.style)},[e.style]),null}(0,_.memo)(J);function Y(e,t){let n=(0,_.useRef)({props:e}),r=K(({mapLib:t})=>{let r=new t.GeolocateControl(e),i=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||i()},r.on(`geolocate`,e=>{n.current.props.onGeolocate?.(e)}),r.on(`error`,e=>{n.current.props.onError?.(e)}),r.on(`outofmaxbounds`,e=>{n.current.props.onOutOfMaxBounds?.(e)}),r.on(`trackuserlocationstart`,e=>{n.current.props.onTrackUserLocationStart?.(e)}),r.on(`trackuserlocationend`,e=>{n.current.props.onTrackUserLocationEnd?.(e)}),r},{position:e.position});return n.current.props=e,(0,_.useImperativeHandle)(t,()=>r,[]),(0,_.useEffect)(()=>{H(r._container,e.style)},[e.style]),null}(0,_.memo)((0,_.forwardRef)(Y));function X(e){let t=K(({mapLib:t})=>new t.NavigationControl(e),{position:e.position});return(0,_.useEffect)(()=>{H(t._container,e.style)},[e.style]),null}var re=(0,_.memo)(X);function ie(e){let t=K(({mapLib:t})=>new t.ScaleControl(e),{position:e.position}),n=(0,_.useRef)(e),r=n.current;n.current=e;let{style:i}=e;return e.maxWidth!==void 0&&e.maxWidth!==r.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==r.unit&&t.setUnit(e.unit),(0,_.useEffect)(()=>{H(t._container,i)},[i]),null}(0,_.memo)(ie);function ae(e){let t=K(({mapLib:t})=>new t.TerrainControl(e),{position:e.position});return(0,_.useEffect)(()=>{H(t._container,e.style)},[e.style]),null}(0,_.memo)(ae);function oe(e){let t=K(({mapLib:t})=>new t.LogoControl(e),{position:e.position});return(0,_.useEffect)(()=>{H(t._container,e.style)},[e.style]),null}(0,_.memo)(oe);var Z=a(),se=s({latitudeField:o().optional(),longitudeField:o().optional(),locationField:o().optional(),titleField:o().optional(),descriptionField:o().optional(),zoom:c().optional(),center:l([c(),c()]).optional()});function ce(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function le(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function ue(e){if(e.locationField||e.latitudeField)return{locationField:e.locationField,latitudeField:e.latitudeField,longitudeField:e.longitudeField,titleField:e.titleField||`name`,descriptionField:e.descriptionField,zoom:e.zoom,center:e.center};let t=null;if(e.filter&&typeof e.filter==`object`&&`map`in e.filter?t=e.filter.map:e.map&&(t=e.map),t){let e=se.safeParse(t);return e.success||console.warn(`[ObjectMap] Invalid map configuration:`,e.error.format()),t}return{latitudeField:`latitude`,longitudeField:`longitude`,locationField:`location`,titleField:`name`,descriptionField:`description`,zoom:10,center:[0,0]}}function de(e,t){if(t.latitudeField&&t.longitudeField){let n=e[t.latitudeField],r=e[t.longitudeField];if(typeof n==`number`&&typeof r==`number`)return[n,r]}if(t.locationField){let n=e[t.locationField];if(typeof n==`object`&&n){let e=n.lat||n.latitude,t=n.lng||n.lon||n.longitude;if(typeof e==`number`&&typeof t==`number`)return[e,t]}if(typeof n==`string`){let e=n.split(`,`).map(e=>parseFloat(e.trim()));if(e.length===2&&!isNaN(e[0])&&!isNaN(e[1]))return[e[0],e[1]]}if(Array.isArray(n)&&n.length===2){let e=parseFloat(n[0]),t=parseFloat(n[1]);if(!isNaN(e)&&!isNaN(t))return[e,t]}}return null}function fe(e,t,n=50){if(e.length<=1||t>=15)return e.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1}));let r=n/2**t,i=new Map;e.forEach(e=>{let t=`${Math.floor(e.coordinates[0]/r)}:${Math.floor(e.coordinates[1]/r)}`;i.has(t)||i.set(t,[]),i.get(t).push(e)});let a=[];return i.forEach((e,t)=>{if(e.length===1)a.push({id:e[0].id,coordinates:e[0].coordinates,markers:e,isCluster:!1});else{let n=e.reduce((e,t)=>e+t.coordinates[0],0)/e.length,r=e.reduce((e,t)=>e+t.coordinates[1],0)/e.length;a.push({id:`cluster-${t}`,coordinates:[n,r],markers:e,isCluster:!0})}}),a}var Q=({schema:e,dataSource:t,className:n,onMarkerClick:r,onRowClick:i,onEdit:a,onDelete:o,enableClustering:s,clusterRadius:c=50,...l})=>{let[u,m]=(0,_.useState)([]),[v,y]=(0,_.useState)(!0),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(``),O=ee(),k=(0,_.useRef)(null),[A,j]=(0,_.useState)(null),[M,N]=(0,_.useState)(null),[P,F]=(0,_.useState)(!1),I=(0,_.useCallback)(()=>{if(typeof navigator>`u`||!navigator.geolocation){N(`Geolocation is not available in this browser.`);return}F(!0),N(null),navigator.geolocation.getCurrentPosition(e=>{let{longitude:t,latitude:n}=e.coords;j({lng:t,lat:n}),F(!1);try{k.current?.flyTo({center:[t,n],zoom:12,duration:800})}catch{}},e=>{F(!1),N(e.message||`Unable to retrieve location.`)},{enableHighAccuracy:!1,timeout:8e3,maximumAge:6e4})},[]),L=ce(e),R=(0,_.useMemo)(()=>L,[JSON.stringify(L)]),z=ue(e),B=R?.provider===`value`;(0,_.useEffect)(()=>{(async()=>{try{if(y(!0),l.data){let e=l.data;if(Array.isArray(e)){m(e),y(!1);return}}if(e.data){let t=e.data;if(Array.isArray(t)){m(t),y(!1);return}}if(B&&R?.provider===`value`){m(R.items),y(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(R?.provider===`object`){let n=R.object,r=f(S?.fields);m(p(await t.find(n,{$filter:e.filter,$orderby:le(e.sort),...r.length>0?{$expand:r}:{}})))}else R?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectMap`),m([]));y(!1)}catch(e){x(e),y(!1)}})()},[R,t,B,e.filter,e.sort,S]),(0,_.useEffect)(()=>{!B&&t&&(async()=>{try{if(!t)return;let n=R?.provider===`object`?R.object:e.objectName;if(!n)return;C(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,B,R]);let{markers:V,invalidCount:H}=(0,_.useMemo)(()=>{let e=0;return{markers:u.map((t,n)=>{let r=de(t,z);if(!r)return e++,null;let i=z.titleField?t[z.titleField]:`Marker`,a=z.descriptionField?t[z.descriptionField]:void 0,[o,s]=r;return!isFinite(o)||!isFinite(s)||o<-90||o>90||s<-180||s>180?(e++,null):{id:t.id||t._id||`marker-${n}`,title:i,description:a,coordinates:[s,o],data:t}}).filter(e=>e!==null),invalidCount:e}},[u,z]),U=(0,_.useMemo)(()=>V.find(e=>e.id===w),[V,w]),[W,K]=(0,_.useState)(z.zoom||3),q=d({navigation:e.navigation,objectName:e.objectName,onRowClick:i}),J=(0,_.useMemo)(()=>{if(!E.trim())return V;let e=E.toLowerCase();return V.filter(t=>t.title?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[V,E]),Y=(0,_.useMemo)(()=>s??(e.enableClustering||J.length>100)?fe(J,W,c):J.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1})),[J,W,s,c,e]),X=(0,_.useMemo)(()=>{if(!J.length)return{longitude:z.center?.[1]||0,latitude:z.center?.[0]||0,zoom:z.zoom||2};let e=J.map(e=>e.coordinates[0]),t=J.map(e=>e.coordinates[1]),n=Math.min(...e),r=Math.max(...e),i=Math.min(...t),a=Math.max(...t);return{longitude:(n+r)/2,latitude:(i+a)/2,zoom:z.zoom||3}},[J,z]);return v?(0,Z.jsx)(`div`,{className:g(`min-w-0 overflow-hidden`,n),children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Z.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading map...`})})}):b?(0,Z.jsx)(`div`,{className:g(`min-w-0 overflow-hidden`,n),children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Z.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,b.message]})})}):(0,Z.jsxs)(`div`,{className:g(`min-w-0 overflow-hidden`,n),children:[H>0&&(0,Z.jsx)(`div`,{className:`mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded`,children:`${H} record${H===1?``:`s`} with missing or invalid coordinates excluded from the map.`}),V.length>0&&(0,Z.jsx)(`div`,{className:`mb-2`,children:(0,Z.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`Search locations…`,className:`w-full px-3 py-2 text-sm border rounded-md bg-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})}),(0,Z.jsxs)(`div`,{className:`relative border rounded-lg overflow-hidden bg-muted h-[300px] sm:h-[400px] md:h-[500px] lg:h-[600px] w-full`,children:[(0,Z.jsxs)(te,{ref:e=>{k.current=e},initialViewState:X,style:{width:`100%`,height:`100%`},mapStyle:`https://demotiles.maplibre.org/style.json`,touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,onZoom:e=>K(Math.round(e.viewState.zoom)),children:[(0,Z.jsx)(re,{position:`top-right`,showCompass:!0,showZoom:!0}),(0,Z.jsx)(`button`,{type:`button`,onClick:I,disabled:P,className:`absolute top-2 left-2 z-10 inline-flex items-center justify-center size-9 rounded-md bg-background/95 border shadow-sm hover:bg-background disabled:opacity-50`,"aria-label":`Show my location`,"data-testid":`map-geolocate`,children:(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:P?`⏳`:`🧭`})}),A&&(0,Z.jsx)(G,{longitude:A.lng,latitude:A.lat,anchor:`center`,children:(0,Z.jsx)(`div`,{className:`size-3 rounded-full bg-blue-500 ring-4 ring-blue-500/30 shadow`,"aria-label":`Your location`,"data-testid":`map-user-location`})}),Y.map(e=>e.isCluster?(0,Z.jsx)(G,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`center`,onClick:t=>{t.originalEvent.stopPropagation();try{let t=Math.min(20,Math.max(W+2,8));k.current?.flyTo({center:[e.coordinates[0],e.coordinates[1]],zoom:t,duration:600})}catch{}},children:(0,Z.jsx)(`div`,{className:`flex items-center justify-center rounded-full bg-primary text-primary-foreground font-bold text-xs cursor-pointer hover:scale-110 transition-transform shadow-md`,style:{width:Math.min(48,24+e.markers.length*2),height:Math.min(48,24+e.markers.length*2)},title:`${e.markers.length} markers`,"data-testid":`map-cluster`,children:e.markers.length})},e.id):(0,Z.jsx)(G,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`bottom`,onClick:t=>{t.originalEvent.stopPropagation();let n=e.markers[0];T(n.id),q.handleClick(n.data),r?.(n.data)},children:(0,Z.jsx)(`div`,{className:`text-2xl cursor-pointer hover:scale-110 transition-transform`,children:`📍`})},e.id)),U&&!O&&(0,Z.jsx)(ne,{longitude:U.coordinates[0],latitude:U.coordinates[1],anchor:`top`,onClose:()=>T(null),closeOnClick:!1,children:(0,Z.jsxs)(`div`,{className:`p-2 min-w-[150px] sm:min-w-[200px]`,children:[(0,Z.jsx)(`h3`,{className:`font-bold text-sm mb-1`,children:U.title}),U.description&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:U.description}),(0,Z.jsxs)(`div`,{className:`mt-2 text-xs flex gap-2`,children:[a&&(0,Z.jsx)(`button`,{className:`text-blue-500 hover:underline`,onClick:()=>a(U.data),children:`Edit`}),o&&(0,Z.jsx)(`button`,{className:`text-red-500 hover:underline`,onClick:()=>o(U.data),children:`Delete`})]})]})})]}),U&&O&&(0,Z.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 z-30 bg-background border-t shadow-lg rounded-t-2xl p-4 pb-[max(env(safe-area-inset-bottom),1rem)]`,role:`dialog`,"aria-label":`Location details`,"data-testid":`map-mobile-record-sheet`,children:[(0,Z.jsx)(`div`,{className:`mx-auto mb-2 h-1 w-10 rounded-full bg-muted`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:U.title}),U.description&&(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground line-clamp-3`,children:U.description})]}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>T(null),className:`text-muted-foreground hover:text-foreground text-lg leading-none px-2`,"aria-label":`Close details`,"data-testid":`map-mobile-record-close`,children:`×`})]}),(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[a&&(0,Z.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border bg-card hover:bg-accent`,onClick:()=>a(U.data),children:`Edit`}),o&&(0,Z.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border border-destructive/30 text-destructive hover:bg-destructive/10`,onClick:()=>o(U.data),children:`Delete`})]})]}),M&&(0,Z.jsx)(`div`,{className:`absolute top-2 left-14 right-2 z-10 text-xs px-3 py-1.5 rounded-md bg-destructive/10 text-destructive border border-destructive/30`,children:M})]}),q.isOverlay&&(0,Z.jsx)(h,{...q,title:`Location Details`,children:e=>(0,Z.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Z.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},pe=t({ObjectMap:()=>Q,ObjectMapRenderer:()=>$}),$=({schema:e,...t})=>{let{dataSource:n}=u()||{};return(0,Z.jsx)(Q,{schema:e,dataSource:n,...t})};console.log(`Registering object-map...`),m.register(`object-map`,$,{namespace:`plugin-map`,label:`Object Map`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]}),m.register(`map`,$,{namespace:`view`,label:`Map View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]});export{pe as t};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{g as n,p as r,r as i}from"./vendor-react-CIpZOxG3.js";import{ut as a}from"./framework-ClI3DbWX.js";import{At as o}from"./ui-components-ZN8XdmwJ.js";import{c as s,l as c,t as l}from"./vendor-markdown-CvMSBmgq.js";var u=t({default:()=>p}),d=e(n(),1),f=i();function p({content:e,className:t}){return(0,f.jsx)(`div`,{"data-slot":`markdown`,className:((...e)=>e.filter(Boolean).join(` `))(`prose prose-sm dark:prose-invert max-w-none`,`prose-headings:font-semibold prose-headings:tracking-tight`,`prose-h1:text-3xl prose-h2:text-2xl prose-h3:text-xl`,`prose-p:leading-relaxed prose-p:text-foreground`,`prose-a:text-primary prose-a:no-underline hover:prose-a:underline`,`prose-code:text-foreground prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:before:content-none prose-code:after:content-none`,`prose-pre:bg-muted prose-pre:text-foreground prose-pre:border`,`prose-blockquote:border-l-primary prose-blockquote:text-muted-foreground`,`prose-strong:text-foreground prose-strong:font-semibold`,`prose-ul:list-disc prose-ol:list-decimal`,`prose-li:text-foreground prose-li:marker:text-muted-foreground`,`prose-table:border prose-th:border prose-th:bg-muted prose-td:border`,`prose-img:rounded-md prose-img:border`,t),children:(0,f.jsx)(l,{remarkPlugins:[s],rehypePlugins:[c],disallowedElements:[`script`,`style`,`iframe`,`object`,`embed`],unwrapDisallowed:!0,children:e})})}var m=t({MarkdownRenderer:()=>g,markdownComponents:()=>_}),h=d.lazy(()=>r(()=>Promise.resolve().then(()=>u),void 0,import.meta.url)),g=({schema:e})=>(0,f.jsx)(d.Suspense,{fallback:(0,f.jsx)(o,{className:`w-full h-[200px]`}),children:(0,f.jsx)(h,{content:e.content||``,className:e.className})});a.register(`markdown`,g,{namespace:`plugin-markdown`,label:`Markdown`,category:`plugin`,inputs:[{name:`content`,type:`string`,label:`Markdown Content`,required:!0,inputType:`textarea`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{content:`# Hello World
|
|
2
|
-
|
|
3
|
-
This is a **markdown** component with *formatting* support.
|
|
4
|
-
|
|
5
|
-
- Item 1
|
|
6
|
-
- Item 2
|
|
7
|
-
- Item 3`}});var _={markdown:g};export{m as t};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{g as n,r}from"./vendor-react-CIpZOxG3.js";import{$ as i,L as a,et as o,ut as s,z as c}from"./framework-ClI3DbWX.js";import{n as l}from"./vendor-i18n-CnFu8bdi.js";import{$ as u,$i as d,At as f,Bn as p,Bo as m,Fn as h,Gn as g,In as _,Jn as v,Kn as y,Ko as b,Ln as x,Na as S,Nr as C,Qn as w,Rn as T,Si as E,To as D,V as O,Vn as k,Xn as A,Yn as j,Zo as M,_o as N,en as P,es as F,et as I,fa as L,fi as ee,in as R,jr as z,l as B,li as te,m as ne,mr as V,nt as H,oi as re,qa as ie,qn as U,ro as ae,tt as oe,vi as se,w as ce,wi as W,yo as le,zn as ue}from"./ui-components-ZN8XdmwJ.js";import{r as de}from"./plugin-grid-DtceFt_J.js";var G=e(n(),1),K=r(),fe=({schema:e})=>{let{title:t,description:n,data:r,columns:i}=e;e.chart?.type;let a=!!e.chart;return(0,K.jsxs)(y,{className:`h-full flex flex-col ${e.className||``}`,children:[(0,K.jsxs)(j,{children:[t&&(0,K.jsx)(A,{children:t}),n&&(0,K.jsx)(v,{children:n})]}),(0,K.jsxs)(U,{className:`flex-1 overflow-auto space-y-4`,children:[a&&(()=>{let t=e.chart?.type,n=t?s.get(t):null;return n||=s.get(`chart`),n?(0,K.jsx)(`div`,{className:`min-h-[300px] border rounded-lg p-4 bg-background/50`,children:(0,K.jsx)(n,{schema:{...e.chart,data:e.chart.data||r}})}):(0,K.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`]})})(),r&&r.length>0&&(0,K.jsx)(`div`,{className:`border rounded-lg`,children:(()=>{let e=s.get(`grid`)||s.get(`table`);return e?(0,K.jsx)(e,{schema:{type:`grid`,rowData:r,columnDefs:i,domLayout:`autoHeight`}}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm text-left`,children:[(0,K.jsx)(`thead`,{className:`text-xs uppercase bg-muted`,children:(0,K.jsx)(`tr`,{children:i?.map(e=>(0,K.jsx)(`th`,{className:`px-6 py-3`,children:e.headerName||e.label||e.field},e.field))})}),(0,K.jsx)(`tbody`,{children:r.map((e,t)=>(0,K.jsx)(`tr`,{className:`bg-background border-b`,children:i?.map(t=>(0,K.jsx)(`td`,{className:`px-6 py-4`,children:e[t.field]},t.field))},t))})]})})})()})]})]})};function q(e){return e.aggregate?`${e.field}__${e.aggregate}`:e.field}function pe(e,t){if(e==null)return null;let n=e instanceof Date?e:new Date(String(e));if(Number.isNaN(n.getTime()))return null;let r=n.getUTCFullYear(),i=n.getUTCMonth(),a=n.getUTCDate();switch(t){case`year`:return String(r);case`quarter`:return`${r}-Q${Math.floor(i/3)+1}`;case`month`:return`${r}-${String(i+1).padStart(2,`0`)}`;case`week`:{let e=new Date(Date.UTC(r,i,a)),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);let n=new Date(Date.UTC(e.getUTCFullYear(),0,1)),o=Math.ceil(((e.getTime()-n.getTime())/864e5+1)/7);return`${e.getUTCFullYear()}-W${String(o).padStart(2,`0`)}`}case`day`:return`${r}-${String(i+1).padStart(2,`0`)}-${String(a).padStart(2,`0`)}`;default:return String(e)}}function J(e,t){let n=e[t.field];return t.dateGranularity?pe(n,t.dateGranularity)??`(empty)`:n==null||n===``?`(empty)`:String(n)}function Y(e,t){let n={};for(let r of t){if(!r.aggregate){let t=e.find(e=>e[r.field]!=null);n[q(r)]=t?t[r.field]:null;continue}let t=e.map(e=>e[r.field]);switch(r.aggregate){case`count`:n[q(r)]=t.length;break;case`unique`:{let e=new Set;for(let n of t)n!=null&&e.add(n);n[q(r)]=e.size;break}case`sum`:{let e=0;for(let n of t)e+=Number(n)||0;n[q(r)]=e;break}case`avg`:{let e=0,i=0;for(let n of t){if(n==null||n===``)continue;let t=Number(n);Number.isNaN(t)||(e+=t,i+=1)}n[q(r)]=i===0?null:e/i;break}case`min`:{let e=null;for(let n of t){if(n==null)continue;let t=Number(n);Number.isNaN(t)||(e===null||t<e)&&(e=t)}n[q(r)]=e;break}case`max`:{let e=null;for(let n of t){if(n==null)continue;let t=Number(n);Number.isNaN(t)||(e===null||t>e)&&(e=t)}n[q(r)]=e;break}default:n[q(r)]=null}}return n}function me(e,t,n,r={},i=[]){if(t.length===0)return[];let[a,...o]=t,s=new Map;for(let t of e){let e=J(t,a),n=s.get(e);n||(n=[],s.set(e,n)),n.push(t)}let c=[];for(let[e,t]of s){let s={...r,[a.field]:e},l=[...i,e],u=Y(t,n),d=o.length>0?me(t,o,n,s,l):void 0;c.push({groupKey:s,groupPath:l,values:u,count:t.length,children:d})}let l=a.sort===`desc`?-1:1;return c.sort((e,t)=>{let n=String(e.groupPath[e.groupPath.length-1]),r=String(t.groupPath[t.groupPath.length-1]);return n.localeCompare(r)*l}),typeof a.limit==`number`&&a.limit>0?c.slice(0,a.limit):c}function he(e,t,n,r){let i=ge(e,n),a=ge(e,r),o={},s={},c={};for(let c of i){o[c.id]={};let i=_e(e,c.key,n);s[c.id]=Y(i,t);for(let e of a){let n=_e(i,e.key,r);n.length!==0&&(o[c.id][e.id]=Y(n,t))}}for(let n of a){let i=_e(e,n.key,r);c[n.id]=Y(i,t)}return{rowHeaders:i,colHeaders:a,cells:o,rowTotals:s,colTotals:c,grandTotal:Y(e,t),columns:t,downGroupings:n,acrossGroupings:r}}function ge(e,t){if(t.length===0)return[{key:{},path:[],id:``}];let n=new Map;for(let r of e){let e=[],i={};for(let n of t){let t=J(r,n);e.push(t),i[n.field]=t}let a=e.join(``);n.has(a)||n.set(a,{key:i,path:e,id:a})}let r=Array.from(n.values());r.sort((e,n)=>{for(let r=0;r<t.length;r++){let i=t[r].sort===`desc`?-1:1,a=e.path[r].localeCompare(n.path[r])*i;if(a!==0)return a}return 0});let i=t[0].limit;if(typeof i==`number`&&i>0){let e=new Set;for(let t of r)e.size>=i&&!e.has(t.path[0])||e.add(t.path[0]);return r.filter(t=>e.has(t.path[0]))}return r}function _e(e,t,n){let r=Object.entries(t);if(r.length===0)return e;let i=new Map;for(let e of n)i.set(e.field,e);return e.filter(e=>{for(let[t,n]of r){let r=i.get(t);if((r?J(e,r):e[t]==null?`(null)`:String(e[t]))!==String(n))return!1}return!0})}function ve(e,t){let n={};for(let r of t){if(!r.aggregate)continue;let t=q(r),i=0,a=0,o=null,s=null;for(let n of e){let e=n[t];typeof e==`number`&&(i+=e,a+=1,(o==null||e<o)&&(o=e),(s==null||e>s)&&(s=e))}r.aggregate===`min`?n[t]=o:r.aggregate===`max`?n[t]=s:r.aggregate===`avg`?n[t]=a===0?null:i/a:n[t]=i}return n}function ye(e,t,n,r){let i=be(e,n),a=be(e,r),o={},s={},c={};for(let n of i){o[n.id]={};let r=e.filter(e=>xe(e,n.key));s[n.id]=ve(r,t);for(let e of a){let i=r.filter(t=>xe(t,e.key));if(i.length===0)continue;let a={};for(let e of t){if(!e.aggregate)continue;let t=q(e);a[t]=i[0][t]}o[n.id][e.id]=a}}for(let n of a){let r=e.filter(e=>xe(e,n.key));c[n.id]=ve(r,t)}return{rowHeaders:i,colHeaders:a,cells:o,rowTotals:s,colTotals:c,grandTotal:ve(e,t),columns:t,downGroupings:n,acrossGroupings:r}}function be(e,t){if(t.length===0)return[{key:{},path:[],id:``}];let n=new Map;for(let r of e){let e=[],i={};for(let n of t){let t=r[n.field],a=t==null?`(null)`:String(t);e.push(a),i[n.field]=a}let a=e.join(``);n.has(a)||n.set(a,{key:i,path:e,id:a})}let r=Array.from(n.values());return r.sort((e,n)=>{for(let r=0;r<t.length;r++){let i=t[r].sort===`desc`?-1:1,a=e.path[r].localeCompare(n.path[r])*i;if(a!==0)return a}return 0}),r}function xe(e,t){for(let[n,r]of Object.entries(t))if((e[n]==null?`(null)`:String(e[n]))!==String(r))return!1;return!0}function X(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(n&&r)return{$and:[e,t]};if(n)return e;if(r)return t}function Se(e){let t=new Set;for(let n of e.groupingsDown??[])t.add(n.field);for(let n of e.groupingsAcross??[])t.add(n.field);for(let n of e.columns??[])t.add(n.field);for(let n of e.sort??[])t.add(n.field);return Array.from(t)}function Ce(e,t,n){let r=[...e.groupingsDown??[],...e.groupingsAcross??[]],i=(e.columns??[]).filter(e=>!!e.aggregate);if(r.length===0&&i.length===0)return null;let a=r.map(e=>e.dateGranularity?{field:e.field,dateGranularity:e.dateGranularity}:e.field),o=i.map(e=>({function:e.aggregate===`unique`?`count_distinct`:e.aggregate,field:e.field,alias:q(e)})),s=X(e.filter,t),c={object:e.objectName,limit:n};return a.length>0&&(c.groupBy=a),o.length>0&&(c.aggregations=o),s&&(c.where=s),c}function we(e,t,n){for(let[r,i]of Object.entries(t)){let t=n.find(e=>e.field===r);if((t?J(e,t):String(e[r]??`(empty)`))!==String(i))return!1}return!0}var Z=[];function Te(e,t={}){let{dataSource:n,runtimeFilter:r,maxRows:i=5e3,enabled:a=!0,rows:o,preferServerAggregation:s=!0}=t,[c,l]=(0,G.useState)(o??Z),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(()=>o?!1:!!(e&&a&&n)),[m,h]=(0,G.useState)(null),g=(0,G.useRef)(0),_=(0,G.useCallback)(async()=>{if(!e||!a)return;if(o){l(o),d(!1);return}if(!n){l(Z);return}let t=++g.current;p(!0),h(null);try{let a=s?Ce(e,r,i):null;if(a&&typeof n.aggregate==`function`)try{let r=Ee(await n.aggregate(e.objectName,a));if(t!==g.current)return;l(r),d(!0);return}catch(e){typeof console<`u`&&console.warn&&console.warn(`[useReportData] dataSource.aggregate() failed, falling back to find():`,e)}if(typeof n.find!=`function`){l(Z),d(!1);return}let o=X(e.filter,r),c=Se(e),u={$top:i};o&&(u.$filter=o),c.length>0&&(u.$select=c),e.sort&&e.sort.length>0&&(u.$orderBy=e.sort.map(e=>`${e.field} ${e.direction??`asc`}`).join(`,`));let f=Ee(await n.find(e.objectName,u));if(t!==g.current)return;l(f),d(!1)}catch(e){if(t!==g.current)return;h(e instanceof Error?e:Error(String(e))),l(Z),d(!1)}finally{t===g.current&&p(!1)}},[e,a,o,n,r,i,s]);(0,G.useEffect)(()=>{_()},[_]);let{rows:v,totals:y,pivot:b}=(0,G.useMemo)(()=>{if(!e)return{rows:[],totals:{},pivot:null};let t=e.groupingsDown??[],n=e.groupingsAcross??[],r=e.columns??[],i=n.length>0;if(u){let e=[...t,...n],a=c.map(t=>{let n={},r=[];for(let i of e){let e=t[i.field];n[i.field]=e,r.push(e==null?`(null)`:String(e))}let i={...t};for(let t of e)delete i[t.field];return{groupKey:n,groupPath:r,values:i,count:1}}),o=ve(c,r),s=i?ye(c,r,t,n):null;return{rows:i&&s?s.rowHeaders.map(e=>({groupKey:e.key,groupPath:e.path,values:s.rowTotals[e.id]??{},count:1})):a,totals:o,pivot:s}}let a=i?t:[...t,...n];return{rows:a.length>0?me(c,a,r):c.map(e=>({groupKey:{},groupPath:[],values:r.length>0?Y([e],r):{...e},count:1})),totals:Y(c,r),pivot:i?he(c,r,t,n):null}},[e,c,u]);return{rows:v,rawRows:c,totals:y,pivot:b,serverAggregated:u,loading:f,error:m,refetch:_,drillDown:(0,G.useCallback)(t=>{if(!e)return[];let n=[...e.groupingsDown??[],...e.groupingsAcross??[]];return c.filter(e=>we(e,t,n))},[e,c])}}function Ee(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let t=e;if(Array.isArray(t.data))return t.data;if(Array.isArray(t.records))return t.records;if(Array.isArray(t.results))return t.results;if(Array.isArray(t.value))return t.value}return Z}function De(e){return e.aggregate?`${e.field}__${e.aggregate}`:e.field}function Oe(e){let t=[],n=e=>{e.children&&e.children.length>0?e.children.forEach(n):t.push(e)};return e.forEach(n),t}function ke({report:e,rows:t,labels:n}){let r=e.chart;if(!r||!r.type)return{schema:null};let i=e.groupingsDown??[],a=r.xAxis||(i.length>0?i[0]?.field:void 0);if(!a)return{schema:null,diagnostic:`chart.xAxis missing and no groupingsDown[0] to default to.`};let o=e.columns??[],s=r.yAxis,c=`count`,l=`Count`,u=!0;if(s){let e=o.find(e=>e.field===s&&e.aggregate);e?(c=De(e),l=n?.resolveColumnLabel?.(e)??(typeof e.label==`string`?e.label:`${e.aggregate}(${e.field})`),u=!1):(c=`count`,l=n?.resolveCountLabel?.(s)??`Count of ${s}`)}let d=Oe(t),f=new Map;for(let e of d){let t=e.groupKey[a];if(t===void 0)continue;let n=String(t??``),r=u?e.count:Number(e.values[c]??0),i=f.get(n);i?i.measure+=Number.isFinite(r)?r:0:f.set(n,{x:t,measure:Number.isFinite(r)?r:0})}let p=Array.from(f.values()).map(e=>{let t=n?.resolveAxisValue?.(a,e.x)??e.x??`(null)`;return{[a]:t,[c]:e.measure}});return(r.type===`pie`||r.type===`donut`||r.type===`funnel`)&&(p=[...p].sort((e,t)=>Number(t[c]??0)-Number(e[c]??0))),{schema:{type:`chart`,chartType:r.type,data:p,xAxisKey:a,series:[{dataKey:c,label:l}],title:r.title,showLegend:r.showLegend??!0,showDataLabels:r.showDataLabels??!1,className:`w-full h-[320px]`}}}function Ae(e,t,n={}){let r=X(X(e.filter,n.runtimeFilter),Object.keys(t).length>0?t:void 0);return{type:`drill`,name:`drill-${e.name}`,objectName:e.objectName,...r?{filter:r}:{},view:n.view??`list`,...n.recordId===void 0?{}:{recordId:n.recordId},openIn:n.openIn??`current`}}function je(e){return!!e&&e.type===`drill`}function Me(e){return async t=>{if(!je(t))return{success:!1,error:`drill handler invoked with non-drill action`};try{return await e.navigate({objectName:t.objectName,filter:t.filter,view:t.view,recordId:t.recordId,openIn:t.openIn}),{success:!0}}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}}function Ne(e,t){return e.registerHandler(`drill`,Me(t)),()=>e.unregisterHandler(`drill`)}function Pe(e){return e?e===`unique`?`count_distinct`:e:null}function Fe(e){if(!(!e||e.length===0))return{fields:e.map(e=>({field:e.field,order:e.sort??`asc`,collapsed:!1}))}}function Ie(e){return(e.columns??[]).map(e=>{let t={field:e.field};return e.label&&(t.label=typeof e.label==`string`?e.label:String(e.label)),e.format&&(t.format=e.format),e.width&&(t.width=e.width),t})}var Le={padding:`12px 16px`,border:`1px dashed rgb(203 213 225)`,borderRadius:8,color:`rgb(100 116 139)`,fontSize:14},Re=({report:e,dataSource:t,rows:n,runtimeFilter:r,onDrillDown:i,actionRunner:o,drillView:s,drillOpenIn:c,className:u})=>{let d=e.type??`tabular`,{t:f}=l(),{fieldLabel:p,translateOptions:m}=F(),[h,g]=G.useState(null);G.useEffect(()=>{let n=t;if(!n||typeof n.getObjectSchema!=`function`||!e.objectName)return;let r=!1;return n.getObjectSchema(e.objectName).then(e=>{r||g(e??null)}).catch(()=>{}),()=>{r=!0}},[t,e.objectName]);let _=G.useCallback(t=>{if(t.label)return String(t.label);let n=h?.fields?.[t.field]?.label??t.field,r=p(e.objectName,t.field,n);return t.aggregate?`${r} · ${f(`report.aggregate.${t.aggregate}`,t.aggregate)}`:r},[h,e.objectName,p,f]),v=G.useCallback((t,n)=>{if(n==null)return;let r=h?.fields?.[t];if(!r||!(r.type===`select`||r.type===`status`)||!Array.isArray(r.options)||r.options.length===0)return;let i=m(e.objectName,t,r.options),a=String(n);for(let e of i)if(e&&e.value!==void 0&&e.value!==null&&String(e.value)===a)return e.label==null?a:String(e.label)},[h,e.objectName,m]),{rawRows:y,rows:b,totals:x,serverAggregated:S,loading:C,error:w,drillDown:T}=Te(e,{dataSource:t,rows:n,runtimeFilter:r});if(d===`matrix`||d===`joined`)return(0,K.jsxs)(`div`,{className:u,style:Le,children:[`Report type `,(0,K.jsx)(`code`,{children:d}),` is not yet supported by SpecReportGrid. It will be rendered by a dedicated component in M2 (matrix) / M3 (joined).`]});let E=G.useMemo(()=>{if(S){let t=(e.groupingsDown??[]).map(e=>({field:e.field,label:e.field.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())})),n=(e.columns??[]).filter(e=>e.aggregate).map(e=>({field:q(e),label:`${(typeof e.label==`string`?e.label:null)??e.field} (${e.aggregate})`,...e.format?{format:e.format}:{}}));return{type:`object-grid`,objectName:e.objectName,columns:[...t,...n]}}let t=d===`summary`?Fe(e.groupingsDown):void 0,n=(e.columns??[]).map(e=>{let t=Pe(e.aggregate);return t?{field:e.field,type:t}:null}).filter(e=>e!==null);return{type:`object-grid`,objectName:e.objectName,columns:Ie(e),grouping:t,aggregations:n.length>0?n:void 0}},[e,d,S]),D=y,O=G.useCallback(t=>{let n=e.groupingsDown??[],a={};for(let e of n)a[e.field]=t[e.field];if(o){let t=Ae(e,a,{runtimeFilter:r,view:s,openIn:c});o.execute(t)}i&&i(a,T(a))},[o,T,c,s,i,e,r]),k=!!i||!!o,A=(e.columns??[]).filter(e=>e.aggregate),j=A.length>0&&x&&Object.keys(x).length>0,M=G.useMemo(()=>d!==`summary`||!e.chart||!e.chart.type?null:ke({report:e,rows:b,labels:{resolveColumnLabel:_,resolveCountLabel:t=>{let n=h?.fields?.[t]?.label??t;return`${p(e.objectName,t,n)} · ${f(`report.aggregate.count`,`Count`)}`},resolveAxisValue:v}}).schema,[e,b,d,_,v,h,p,f]);return(0,K.jsxs)(`div`,{className:u,"data-testid":`spec-report-grid`,"aria-busy":C||void 0,children:[w?(0,K.jsx)(`div`,{role:`alert`,style:{...Le,color:`rgb(190 18 60)`},children:w.message}):null,j?(0,K.jsxs)(`div`,{"data-testid":`spec-report-totals`,className:`mb-3 flex flex-wrap items-baseline gap-x-6 gap-y-1 rounded-md border bg-muted/40 px-3 py-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wide text-muted-foreground`,children:f(`report.totals`,`Totals`)}),A.map(e=>{let t=q(e),n=x[t],r=_(e),i=typeof n==`number`?n.toLocaleString(void 0,{maximumFractionDigits:2}):String(n??`—`);return(0,K.jsxs)(`span`,{"data-testid":`spec-report-total-${t}`,className:`inline-flex items-baseline gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[r,`:`]}),(0,K.jsx)(`span`,{className:`font-mono font-medium tabular-nums`,children:i})]},t)})]}):null,M?(0,K.jsx)(`div`,{className:`mb-4`,"data-testid":`spec-report-chart`,children:(0,K.jsx)(a,{schema:M})}):null,(0,K.jsx)(de,{schema:E,data:D,dataSource:t,onRowClick:k?O:void 0})]})};Re.displayName=`SpecReportGrid`;var ze=`—`;function Be(e){return e==null?ze:typeof e==`number`?e.toLocaleString():String(e)}function Ve(e,t,n){if(e==null||e===``||e===`(null)`)return n;let r=t?.options;if(r){let t=r.get(e);if(t!==void 0&&t!==``)return t}return e}function He({header:e,groupings:t,metaByField:n,fallback:r,emptyLabel:i}){return e.path.length===0?(0,K.jsx)(K.Fragment,{children:r}):(0,K.jsx)(K.Fragment,{children:e.path.map((e,r)=>{let a=t[r]?.field;return Ve(e,a?n.get(a):void 0,i)}).join(` / `)})}var Ue=({report:e,dataSource:t,rows:n,runtimeFilter:r,onCellClick:i,actionRunner:a,drillView:o,drillOpenIn:s,className:c,emptyCellText:u=ze})=>{let{pivot:d,loading:f,error:p}=Te(e,{dataSource:t,rows:n,runtimeFilter:r}),m=e.columns??[],h=m.length>1,{fieldLabel:g,translateOptions:_}=F(),{t:v}=l(),y=v(`report.emptyLabel`,`(Empty)`),b=v(`report.allLabel`,`(All)`),[x,S]=G.useState(null);G.useEffect(()=>{let n=t;if(!n||typeof n.getObjectSchema!=`function`||!e.objectName)return;let r=!1;return n.getObjectSchema(e.objectName).then(e=>{r||S(e??null)}).catch(()=>{}),()=>{r=!0}},[t,e.objectName]);let C=e.groupingsDown??[],w=e.groupingsAcross??[],T=G.useMemo(()=>{let t=new Map,n=x?.fields??{},r=[...C,...w];for(let i of r){let r=n[i.field],a=r?.label??i.field,o=g(e.objectName,i.field,a),s=r?.type===`select`||r?.type===`status`,c;if(s&&Array.isArray(r?.options)&&r.options.length>0){let t=_(e.objectName,i.field,r.options);c=new Map;for(let e of t)e&&e.value!==void 0&&e.value!==null&&c.set(String(e.value),e.label==null?String(e.value):String(e.label))}t.set(i.field,{fieldLabel:o,options:c})}return t},[x,C,w,e.objectName,g,_]),E=G.useMemo(()=>{let t=new Map,n=x?.fields??{};for(let r of m){let i=q(r);if(r.label){t.set(i,String(r.label));continue}let a=n[r.field]?.label??r.field,o=g(e.objectName,r.field,a);if(r.aggregate){let e=v(`report.aggregate.${r.aggregate}`,r.aggregate);t.set(i,`${o} · ${e}`)}else t.set(i,o)}return t},[m,x,e.objectName,g,v]),D=G.useCallback((t,n,c)=>{let l={...t.key,...n.key};if(a){let t=Ae(e,l,{runtimeFilter:r,view:o,openIn:s});a.execute(t)}i&&i({rowKey:t.key,colKey:n.key,combinedKey:l,values:c})},[a,s,o,i,e,r]);if(p)return(0,K.jsx)(`div`,{className:M(`rounded-md border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive`,c),role:`alert`,"data-testid":`matrix-error`,children:v(`report.failedToLoad`,`Failed to load matrix: {{message}}`,{message:p.message})});if(!d)return(0,K.jsx)(`div`,{className:M(`rounded-md border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-sm text-muted-foreground`,c),"aria-busy":f||void 0,"data-testid":`matrix-empty`,children:f?v(`report.loading`,`Loading…`):v(`report.needsAcross`,"Matrix report requires at least one `groupingsAcross` field.")});let O=!!i||!!a,k=C.map(e=>T.get(e.field)?.fieldLabel??e.field).join(` / `)||v(`report.rowsLabel`,`Row`),A=w.map(e=>T.get(e.field)?.fieldLabel??e.field).join(` / `)||v(`report.columnsLabel`,`Column`),j=m.length>0?q(m[0]):null,N=0;if(j)for(let e of d.rowHeaders)for(let t of d.colHeaders){let n=d.cells[e.id]?.[t.id]?.[j];typeof n==`number`&&n>N&&(N=n)}let P=e=>{if(!j||N<=0||!e)return 0;let t=e[j];return typeof t!=`number`||t<=0?0:Math.min(1,t/N)};return(0,K.jsx)(`div`,{className:M(`overflow-auto rounded-lg border border-border bg-card shadow-sm`,c),"data-testid":`matrix-renderer`,"aria-busy":f||void 0,children:(0,K.jsxs)(`table`,{role:`table`,className:`w-full border-separate border-spacing-0 text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsxs)(`th`,{scope:`col`,className:M(`sticky left-0 top-0 z-30 border-b border-r border-border bg-muted/60`,`px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-muted-foreground`),"aria-label":`${k} \u2192 ${A}`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground/70`,children:k}),(0,K.jsx)(`span`,{className:`mx-1 text-muted-foreground/40`,children:`\\`}),(0,K.jsx)(`span`,{className:`text-foreground/80`,children:A})]}),d.colHeaders.map(e=>(0,K.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-20 whitespace-nowrap border-b border-border bg-muted/60 px-3 py-2 text-right text-xs font-semibold text-foreground`,children:(0,K.jsx)(He,{header:e,groupings:w,metaByField:T,fallback:b,emptyLabel:y})},`col-${e.id}`)),(0,K.jsx)(`th`,{scope:`col`,className:`sticky top-0 z-20 whitespace-nowrap border-b border-l border-border bg-muted px-3 py-2 text-right text-xs font-semibold uppercase tracking-wide text-foreground`,children:v(`report.rowTotal`,`Row Total`)})]})}),(0,K.jsx)(`tbody`,{children:d.rowHeaders.map((e,t)=>(0,K.jsxs)(`tr`,{className:`group`,children:[(0,K.jsx)(`th`,{scope:`row`,className:M(`sticky left-0 z-10 whitespace-nowrap border-b border-r border-border bg-card px-3 py-2 text-left text-sm font-medium text-foreground`,`group-hover:bg-muted/50`,t===0&&`border-t-0`),children:(0,K.jsx)(He,{header:e,groupings:C,metaByField:T,fallback:b,emptyLabel:y})}),d.colHeaders.map(t=>{let n=d.cells[e.id]?.[t.id],r=!n,i=P(n);return(0,K.jsx)(`td`,{className:M(`border-b border-border px-3 py-2 text-right tabular-nums transition-colors`,r?`text-muted-foreground/40`:`text-foreground`,O&&!r&&`cursor-pointer hover:outline hover:outline-2 hover:-outline-offset-2 hover:outline-primary/50`,`group-hover:bg-muted/30`),style:i>0?{backgroundColor:`rgba(59, 130, 246, ${.06+i*.28})`}:void 0,onClick:O&&!r?()=>D(e,t,n):void 0,"data-row":e.id,"data-col":t.id,children:r?u:We(m,n,h,E)},`cell-${e.id}-${t.id}`)}),(0,K.jsx)(`td`,{className:M(`border-b border-l border-border bg-muted/40 px-3 py-2 text-right text-sm font-semibold tabular-nums text-foreground`,`group-hover:bg-muted/60`),children:We(m,d.rowTotals[e.id]??{},h,E)})]},`row-${e.id}`))}),(0,K.jsx)(`tfoot`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{scope:`row`,className:`sticky left-0 z-10 whitespace-nowrap border-t-2 border-r border-border bg-muted px-3 py-2 text-left text-xs font-semibold uppercase tracking-wide text-foreground`,children:v(`report.columnTotal`,`Column Total`)}),d.colHeaders.map(e=>(0,K.jsx)(`td`,{className:`border-t-2 border-border bg-muted/40 px-3 py-2 text-right text-sm font-semibold tabular-nums text-foreground`,children:We(m,d.colTotals[e.id]??{},h,E)},`coltotal-${e.id}`)),(0,K.jsx)(`td`,{className:`border-l border-t-2 border-border bg-primary/10 px-3 py-2 text-right text-sm font-bold tabular-nums text-foreground`,children:We(m,d.grandTotal,h,E)})]})})]})})};function We(e,t,n,r){return e.length?n?(0,K.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.map(e=>{let n=q(e);return(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r?.get(n)??e.label??n}),(0,K.jsx)(`span`,{className:`tabular-nums`,children:Be(t[n])})]},n)})}):Be(t[q(e[0])]):ze}function Ge(e,t){return e?typeof e==`string`?e:typeof e==`object`&&typeof e.default==`string`?e.default:t:t}function Ke(e,t){if(!t||Object.keys(t).length===0)return e;let n=X(t,e.filter);return{...e,filter:n}}var qe=({report:e,dataSource:t,runtimeFilter:n,actionRunner:r,drillView:a,drillOpenIn:o,className:s,renderBlock:c})=>{if(!i(e))return(0,K.jsxs)(`div`,{className:s,"data-testid":`joined-report-invalid`,style:{color:`var(--color-destructive, #b91c1c)`,fontSize:13,padding:12},children:[`JoinedReportRenderer requires a report with `,(0,K.jsx)(`code`,{children:`type: 'joined'`}),` and a `,(0,K.jsx)(`code`,{children:`blocks`}),` array.`]});let l=e.blocks??[],u=e.filter,d=e.objectName;return(0,K.jsx)(`div`,{className:s,"data-testid":`joined-report`,"data-report-name":e.name,style:{display:`flex`,flexDirection:`column`,gap:24},children:l.map((e,i)=>{let s=e.objectName??d??``,l=Ke({...e,objectName:s,type:e.type??`tabular`,columns:e.columns??[]},u),f=Ge(e.label,e.name),p=e.description?Ge(e.description,``):``,m=e.name??`block-${i}`,h=(0,K.jsxs)(`section`,{"data-testid":`joined-report-block`,"data-block-id":m,style:{display:`flex`,flexDirection:`column`,gap:8,border:`1px solid var(--color-border, #e4e4e7)`,borderRadius:8,padding:16,background:`var(--color-card, #ffffff)`},children:[(0,K.jsxs)(`header`,{style:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,K.jsx)(`h3`,{style:{margin:0,fontSize:16,fontWeight:600},children:f}),p?(0,K.jsx)(`p`,{style:{margin:0,fontSize:13,color:`var(--color-muted-foreground, #71717a)`},children:p}):null]}),(0,K.jsx)(Ye,{schema:l,dataSource:t,runtimeFilter:n,actionRunner:r,drillView:a,drillOpenIn:o})]},m);return c?c(e,i,h):h})})},Je={border:`1px dashed var(--color-border, #d4d4d8)`,borderRadius:8,padding:16,color:`var(--color-muted-foreground, #71717a)`,background:`var(--color-muted, #f4f4f5)`,fontSize:13},Ye=e=>{let{dataSource:t,rows:n,runtimeFilter:r,actionRunner:a,drillView:s,drillOpenIn:l,className:u}=e,d=G.useContext(c),f=t??d?.dataSource,p=e.schema;if(p&&typeof p==`object`&&p.type===`spec-report`&&p.report&&typeof p.report==`object`&&(p=p.report),o(p)){let e=p.type??`tabular`;return e===`matrix`?(0,K.jsx)(Ue,{report:p,dataSource:f,rows:n,runtimeFilter:r,actionRunner:a,drillView:s,drillOpenIn:l,className:u}):e===`joined`?i(p)?(0,K.jsx)(qe,{report:p,dataSource:f,runtimeFilter:r,actionRunner:a,drillView:s,drillOpenIn:l,className:u}):(0,K.jsxs)(`div`,{className:u,style:Je,"data-testid":`report-joined-placeholder`,children:[`Joined report (`,(0,K.jsx)(`code`,{children:p.name}),`) is missing a `,(0,K.jsx)(`code`,{children:`blocks`}),` array.`]}):(0,K.jsx)(Re,{report:p,dataSource:f,rows:n,runtimeFilter:r,actionRunner:a,drillView:s,drillOpenIn:l,className:u})}return(0,K.jsx)(fe,{schema:p})};function Xe(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=nt(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
2
|
-
`))?`"${n.replace(/"/g,`""`)}"`:n??``}));at([...n?.includeHeaders===!1?[]:[i.join(`,`)],...a.map(e=>e.join(`,`))].join(`
|
|
3
|
-
`),n?.filename||`${e.title||`report`}.csv`,`text/csv`)}function Ze(e,t,n){let r={title:e.title,description:e.description,generatedAt:new Date().toISOString(),data:t};at(JSON.stringify(r,null,2),n?.filename||`${e.title||`report`}.json`,`application/json`)}function Qe(e,t,n){let r=e.fields||[],i=it(n?.orientation),a=rt(n?.pageSize);at(`<!DOCTYPE html>
|
|
4
|
-
<html>
|
|
5
|
-
<head>
|
|
6
|
-
<meta charset="utf-8">
|
|
7
|
-
<title>${Q(e.title||`Report`)}</title>
|
|
8
|
-
<style>
|
|
9
|
-
@page { size: ${a} ${i}; margin: 20mm; }
|
|
10
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
11
|
-
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
12
|
-
.description { color: #666; margin-bottom: 24px; }
|
|
13
|
-
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
14
|
-
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
15
|
-
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
16
|
-
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
17
|
-
tr:nth-child(even) { background: #fafafa; }
|
|
18
|
-
</style>
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
<h1>${Q(e.title||`Report`)}</h1>
|
|
22
|
-
${e.description?`<p class="description">${Q(e.description)}</p>`:``}
|
|
23
|
-
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
24
|
-
<table>
|
|
25
|
-
<thead><tr>${r.map(e=>`<th>${Q(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
26
|
-
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${Q(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
27
|
-
</table>
|
|
28
|
-
</body>
|
|
29
|
-
</html>`,n?.filename||`${e.title||`report`}.html`,`text/html`)}function $e(e,t,n){let r=e.fields||[],i=it(n?.orientation),a=rt(n?.pageSize),o=window.open(``,`_blank`);if(!o){Qe(e,t,{...n,format:`html`,filename:n?.filename?.replace(/\.pdf$/,`.html`)||`${e.title||`report`}.html`});return}o.document.write(`<!DOCTYPE html>
|
|
30
|
-
<html>
|
|
31
|
-
<head>
|
|
32
|
-
<meta charset="utf-8">
|
|
33
|
-
<title>${Q(e.title||`Report`)}</title>
|
|
34
|
-
<style>
|
|
35
|
-
@page { size: ${a} ${i}; margin: 20mm; }
|
|
36
|
-
@media print { .no-print { display: none; } }
|
|
37
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
38
|
-
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
39
|
-
.description { color: #666; margin-bottom: 24px; }
|
|
40
|
-
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
41
|
-
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
42
|
-
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
43
|
-
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
44
|
-
tr:nth-child(even) { background: #fafafa; }
|
|
45
|
-
</style>
|
|
46
|
-
</head>
|
|
47
|
-
<body>
|
|
48
|
-
<h1>${Q(e.title||`Report`)}</h1>
|
|
49
|
-
${e.description?`<p class="description">${Q(e.description)}</p>`:``}
|
|
50
|
-
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
51
|
-
<table>
|
|
52
|
-
<thead><tr>${r.map(e=>`<th>${Q(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
53
|
-
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${Q(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
54
|
-
</table>
|
|
55
|
-
</body>
|
|
56
|
-
</html>`),o.document.close(),o.onload=()=>{o.print()}}function et(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=nt(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
57
|
-
`)||n.includes(` `))?`"${n.replace(/"/g,`""`)}"`:n??``}));at(``+[...n?.includeHeaders===!1?[]:[i.join(` `)],...a.map(e=>e.join(` `))].join(`
|
|
58
|
-
`),n?.filename||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function tt(e,t,n,r){switch(e){case`csv`:Xe(t,n,r);break;case`json`:Ze(t,n,r);break;case`html`:Qe(t,n,r);break;case`pdf`:$e(t,n,r);break;case`excel`:et(t,n,r);break;default:console.warn(`Unsupported export format: ${e}`)}}function Q(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function nt(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 rt(e){return[`A4`,`A3`,`Letter`,`Legal`].includes(e||``)?e:`A4`}function it(e){return e===`landscape`?`landscape`:`portrait`}function at(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 ot(e,t){if(e==null||e===``)return``;let n=t?.type,r=t?.format;if(n===`date`||r===`date`||st(e))return ct(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 st(e){return typeof e==`string`?/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e):!1}function ct(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 lt(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 ut=({schema:e,onRefresh:t})=>{let{report:n,data:r,showToolbar:i=!0,allowExport:o=!0,allowPrint:c=!0,loading:l=!1}=e,u=e=>{if(!n){console.warn(`ReportViewer: Cannot export, no report defined`);return}tt(e,n,r||[],n.exportConfigs?.[e])},d=()=>{window.print()},p=()=>{t?.()},m=(e,t)=>{if(!r)return 0;let n=r.map(t=>Number(t[e])||0);switch(t){case`count`:return r.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``}},h=(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}}},g=(e,t)=>{if(e==null||e===``)return``;if(t.renderAs===`badge`&&(!t.type||t.type===`string`||t.type===`text`))return(0,K.jsx)(w,{className:t.colorMap?.[String(e)]||``,children:String(e)});if(t.aggregation)return ot(e,t);if(t.type){let n={...t};return t.colorMap&&!n.options&&(n.options=Object.entries(t.colorMap).map(([e,t])=>({value:e,label:e,color:t}))),(0,K.jsx)(B(ne(n)),{value:e,field:n})}return ot(e,t)};return n?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[i&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-4 bg-card rounded-lg border`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:n.title}),n.description&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.refreshInterval&&(0,K.jsxs)(V,{variant:`outline`,size:`sm`,onClick:p,children:[(0,K.jsx)(se,{className:`h-4 w-4 mr-2`}),`Refresh`]}),c&&(0,K.jsxs)(V,{variant:`outline`,size:`sm`,onClick:d,children:[(0,K.jsx)(E,{className:`h-4 w-4 mr-2`}),`Print`]}),o&&n.showExportButtons&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(V,{variant:`outline`,size:`sm`,onClick:()=>u(`pdf`),children:[(0,K.jsx)(ie,{className:`h-4 w-4 mr-2`}),`PDF`]}),(0,K.jsxs)(V,{variant:`outline`,size:`sm`,onClick:()=>u(`excel`),children:[(0,K.jsx)(ie,{className:`h-4 w-4 mr-2`}),`Excel`]}),(0,K.jsxs)(V,{variant:`outline`,size:`sm`,onClick:()=>u(`csv`),children:[(0,K.jsx)(ie,{className:`h-4 w-4 mr-2`}),`CSV`]})]})]})]}),(0,K.jsxs)(y,{children:[(0,K.jsxs)(j,{children:[!i&&n.title&&(0,K.jsx)(A,{children:n.title}),!i&&n.description&&(0,K.jsx)(v,{children:n.description})]}),(0,K.jsxs)(U,{className:`space-y-6`,children:[l&&(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[1,2,3].map(e=>(0,K.jsx)(y,{children:(0,K.jsxs)(U,{className:`p-4 space-y-2`,children:[(0,K.jsx)(f,{className:`h-4 w-20`}),(0,K.jsx)(f,{className:`h-8 w-28`})]})},e))}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(f,{className:`h-10 w-full`}),[1,2,3,4,5].map(e=>(0,K.jsx)(f,{className:`h-8 w-full`},e))]})]}),!l&&n.sections?.map((e,t)=>e.visible===!1?null:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[e.title&&e.type!==`header`&&(0,K.jsx)(`h3`,{className:`text-lg font-semibold border-b pb-2`,children:e.title}),e.type===`header`&&e.title&&(0,K.jsx)(`div`,{className:`text-2xl font-bold py-4`,children:e.title}),e.type===`summary`&&(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:n.fields?.filter(e=>e.showInSummary).map((e,t)=>(0,K.jsx)(y,{children:(0,K.jsxs)(U,{className:`p-4`,children:[(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.label||e.name}),(0,K.jsx)(`div`,{className:`text-2xl font-bold`,children:ot(m(e.name,e.aggregation),e)})]})},t))}),e.type===`chart`&&e.chart&&(0,K.jsx)(`div`,{className:`min-h-[300px]`,children:(()=>{let t=e.chart.type,n=!!e.chart.chartType;!t&&n&&(t=`chart`),t&&s.get(t)||(t=`chart`);let i=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,K.jsx)(a,{schema:{...e.chart,type:t,...i,data:r||e.chart.data,className:e.chart.className||`w-full h-[350px]`}})})()}),e.type===`table`&&(0,K.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,K.jsx)(`thead`,{className:`bg-muted`,children:(0,K.jsx)(`tr`,{children:e.columns?.map((e,t)=>(0,K.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,K.jsx)(`tbody`,{children:(()=>{let t=lt(r||[],n.groupBy||[]);return t?t.map(t=>(0,K.jsxs)(G.Fragment,{children:[(0,K.jsx)(`tr`,{className:`bg-muted/60`,children:(0,K.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,K.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,K.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:h(e.name,t[e.name]),children:g(t[e.name],e)},n))},n))]},t.key)):r?.map((t,n)=>(0,K.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,K.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:h(e.name,t[e.name]),children:g(t[e.name],e)},n))},n))})()})]})}),e.type===`text`&&e.text&&(0,K.jsx)(`div`,{className:`prose max-w-none`,children:(0,K.jsx)(`p`,{children:e.text})}),e.type===`page-break`&&(0,K.jsx)(`div`,{className:`border-t-2 border-dashed my-8 print:page-break-after-always`}),e.content&&(0,K.jsx)(a,{schema:e.content})]},t)),!n.sections&&r&&r.length>0&&(0,K.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,K.jsx)(`thead`,{className:`bg-muted`,children:(0,K.jsx)(`tr`,{children:n.fields?.map((e,t)=>(0,K.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,K.jsx)(`tbody`,{children:r.map((e,t)=>(0,K.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:n.fields?.map((t,n)=>(0,K.jsx)(`td`,{className:`px-4 py-2 ${t.type===`number`?`text-right tabular-nums`:``}`,style:h(t.name,e[t.name]),children:g(e[t.name],t)},n))},t))})]})})]})]})]}):(0,K.jsx)(y,{children:(0,K.jsx)(U,{className:`p-8 text-center text-muted-foreground`,children:`No report to display`})})},dt=({schedule:e,onChange:t})=>{let[n,r]=(0,G.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,K.jsxs)(y,{children:[(0,K.jsx)(j,{children:(0,K.jsxs)(A,{className:`flex items-center gap-2`,children:[(0,K.jsx)(D,{className:`h-5 w-5`}),`Schedule Configuration`]})}),(0,K.jsxs)(U,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`schedule-enabled`,checked:n.enabled||!1,onChange:e=>i({enabled:e.target.checked}),className:`rounded`}),(0,K.jsx)(R,{htmlFor:`schedule-enabled`,children:`Enable Scheduled Report`})]}),n.enabled&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{children:`Frequency`}),(0,K.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,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),n.frequency===`weekly`&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{children:`Day of Week`}),(0,K.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,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),n.frequency===`monthly`&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{children:`Day of Month`}),(0,K.jsx)(P,{type:`number`,min:1,max:31,value:n.dayOfMonth??1,onChange:e=>i({dayOfMonth:Number(e.target.value)})})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(R,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ae,{className:`h-4 w-4`}),`Time`]}),(0,K.jsx)(P,{type:`time`,value:n.time||`09:00`,onChange:e=>i({time:e.target.value})})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{children:`Timezone`}),(0,K.jsx)(P,{value:n.timezone||``,onChange:e=>i({timezone:e.target.value}),placeholder:`e.g. America/New_York`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{children:`Export Formats`}),(0,K.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,K.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,K.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,K.jsx)(`span`,{className:`text-sm`,children:e.label})]},e.value))})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(R,{className:`flex items-center gap-2`,children:[(0,K.jsx)(d,{className:`h-4 w-4`}),`Email Recipients`]}),(0,K.jsx)(P,{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,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{children:`Email Subject`}),(0,K.jsx)(P,{value:n.subject||``,onChange:e=>i({subject:e.target.value}),placeholder:`Scheduled Report: {report_title}`})]})]})]})]})},ft=({schema:e})=>{let{report:t,dataSources:n=[],availableFields:r=[],showPreview:i=!0,onSave:a,onCancel:o}=e,[s,c]=(0,G.useState)(t||{type:`report`,title:`New Report`,fields:[],filters:[],groupBy:[],sections:[],showExportButtons:!0,showPrintButton:!0}),[l,d]=(0,G.useState)(s.fields||[]),[f,p]=(0,G.useState)(s.filters||[]),[m,h]=(0,G.useState)(s.groupBy||[]),[g,_]=(0,G.useState)(s.sections||[]),b=()=>{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];d(t),c({...s,fields:t})}}},x=e=>{let t=l.filter((t,n)=>n!==e);d(t),c({...s,fields:t})},w=(e,t)=>{let n=[...l];n[e]=t,d(n),c({...s,fields:n})},T=()=>{let e={field:r[0]?.name||``,operator:`equals`,value:``},t=[...f,e];p(t),c({...s,filters:t})},E=e=>{let t=f.filter((t,n)=>n!==e);p(t),c({...s,filters:t})},O=(e,t)=>{let n=[...f];n[e]=t,p(n),c({...s,filters:n})},k=()=>{let e={field:r[0]?.name||``,sort:`asc`},t=[...m,e];h(t),c({...s,groupBy:t})},M=e=>{let t=m.filter((t,n)=>n!==e);h(t),c({...s,groupBy:t})},N=(e,t)=>{let n=[...m];n[e]=t,h(n),c({...s,groupBy:n})},F=e=>{let t={type:e,title:`New ${e} Section`},n=[...g,t];_(n),c({...s,sections:n})},z=e=>{let t=g.filter((t,n)=>n!==e);_(t),c({...s,sections:t})},B=(e,t)=>{let n=[...g];n[e]=t,_(n),c({...s,sections:n})};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(y,{children:[(0,K.jsxs)(j,{children:[(0,K.jsx)(A,{children:`Report Builder`}),(0,K.jsx)(v,{children:`Configure your report settings, fields, filters, and sections`})]}),(0,K.jsxs)(U,{children:[(0,K.jsxs)(u,{defaultValue:`basic`,className:`w-full`,children:[(0,K.jsxs)(oe,{className:`grid w-full grid-cols-6`,children:[(0,K.jsxs)(H,{value:`basic`,children:[(0,K.jsx)(re,{className:`h-4 w-4 mr-2`}),`Basic`]}),(0,K.jsxs)(H,{value:`fields`,children:[(0,K.jsx)(L,{className:`h-4 w-4 mr-2`}),`Fields`]}),(0,K.jsxs)(H,{value:`filters`,children:[(0,K.jsx)(S,{className:`h-4 w-4 mr-2`}),`Filters`]}),(0,K.jsxs)(H,{value:`grouping`,children:[(0,K.jsx)(L,{className:`h-4 w-4 mr-2`}),`Group By`]}),(0,K.jsxs)(H,{value:`sections`,children:[(0,K.jsx)(L,{className:`h-4 w-4 mr-2`}),`Sections`]}),(0,K.jsxs)(H,{value:`schedule`,children:[(0,K.jsx)(D,{className:`h-4 w-4 mr-2`}),`Schedule`]})]}),(0,K.jsx)(I,{value:`basic`,className:`space-y-4 mt-4`,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{htmlFor:`report-title`,children:`Report Title`}),(0,K.jsx)(P,{id:`report-title`,value:s.title||``,onChange:e=>c({...s,title:e.target.value}),placeholder:`Enter report title`})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{htmlFor:`report-description`,children:`Description`}),(0,K.jsx)(P,{id:`report-description`,value:s.description||``,onChange:e=>c({...s,description:e.target.value}),placeholder:`Enter report description`})]}),n.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{children:`Data Source`}),(0,K.jsxs)(`select`,{className:`w-full border rounded-md p-2`,children:[(0,K.jsx)(`option`,{value:``,children:`Select a data source`}),n.map((e,t)=>(0,K.jsxs)(`option`,{value:t,children:[`Data Source `,t+1]},t))]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{children:`Export Options`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:s.showExportButtons||!1,onChange:e=>c({...s,showExportButtons:e.target.checked})}),(0,K.jsx)(`span`,{className:`text-sm`,children:`Show Export Buttons`})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:s.showPrintButton||!1,onChange:e=>c({...s,showPrintButton:e.target.checked})}),(0,K.jsx)(`span`,{className:`text-sm`,children:`Show Print Button`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(R,{htmlFor:`export-format`,children:`Default Export Format`}),(0,K.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,K.jsx)(`option`,{value:`pdf`,children:`PDF`}),(0,K.jsx)(`option`,{value:`excel`,children:`Excel`}),(0,K.jsx)(`option`,{value:`csv`,children:`CSV`}),(0,K.jsx)(`option`,{value:`json`,children:`JSON`}),(0,K.jsx)(`option`,{value:`html`,children:`HTML`})]})]})]})}),(0,K.jsxs)(I,{value:`fields`,className:`space-y-4 mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(R,{children:`Report Fields`}),(0,K.jsxs)(V,{size:`sm`,variant:`outline`,onClick:b,disabled:l.length>=r.length,children:[(0,K.jsx)(W,{className:`h-4 w-4 mr-2`}),`Add Field`]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[l.map((e,t)=>(0,K.jsx)(`div`,{className:`flex items-center gap-2 p-3 border rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex-1 grid grid-cols-4 gap-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Field Name`}),(0,K.jsx)(`div`,{className:`text-sm font-medium`,children:e.name})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Label`}),(0,K.jsx)(P,{className:`h-8 text-sm`,value:e.label||e.name,onChange:n=>w(t,{...e,label:n.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Aggregation`}),(0,K.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.aggregation||``,onChange:n=>w(t,{...e,aggregation:n.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:`None`}),(0,K.jsx)(`option`,{value:`sum`,children:`Sum`}),(0,K.jsx)(`option`,{value:`count`,children:`Count`}),(0,K.jsx)(`option`,{value:`avg`,children:`Average`}),(0,K.jsx)(`option`,{value:`min`,children:`Min`}),(0,K.jsx)(`option`,{value:`max`,children:`Max`})]})]}),(0,K.jsx)(`div`,{className:`flex items-end justify-end`,children:(0,K.jsx)(V,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50`,onClick:()=>x(t),children:(0,K.jsx)(C,{className:`h-4 w-4`})})})]})},t)),l.length===0&&(0,K.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,K.jsxs)(I,{value:`filters`,className:`space-y-4 mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(R,{children:`Report Filters`}),(0,K.jsxs)(V,{size:`sm`,variant:`outline`,onClick:T,children:[(0,K.jsx)(W,{className:`h-4 w-4 mr-2`}),`Add Filter`]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[f.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex-1 grid grid-cols-3 gap-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Field`}),(0,K.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,K.jsx)(`option`,{value:e.name,children:e.label||e.name},t))})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Operator`}),(0,K.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.operator,onChange:n=>O(t,{...e,operator:n.target.value}),children:[(0,K.jsx)(`option`,{value:`equals`,children:`Equals`}),(0,K.jsx)(`option`,{value:`contains`,children:`Contains`}),(0,K.jsx)(`option`,{value:`gt`,children:`Greater Than`}),(0,K.jsx)(`option`,{value:`lt`,children:`Less Than`}),(0,K.jsx)(`option`,{value:`between`,children:`Between`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Value`}),(0,K.jsx)(P,{className:`h-8 text-sm`,value:String(e.value),onChange:n=>O(t,{...e,value:n.target.value})})]})]}),(0,K.jsx)(V,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50 self-end`,onClick:()=>E(t),children:(0,K.jsx)(C,{className:`h-4 w-4`})})]},t)),f.length===0&&(0,K.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No filters defined.`})]})]}),(0,K.jsxs)(I,{value:`grouping`,className:`space-y-4 mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(R,{children:`Grouping Rules`}),(0,K.jsxs)(V,{size:`sm`,variant:`outline`,onClick:k,children:[(0,K.jsx)(W,{className:`h-4 w-4 mr-2`}),`Add Group`]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[m.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Field`}),(0,K.jsx)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.field,onChange:n=>N(t,{...e,field:n.target.value}),children:r.map((e,t)=>(0,K.jsx)(`option`,{value:e.name,children:e.label||e.name},t))})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Sort Order`}),(0,K.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.sort||`asc`,onChange:n=>N(t,{...e,sort:n.target.value}),children:[(0,K.jsx)(`option`,{value:`asc`,children:`Ascending`}),(0,K.jsx)(`option`,{value:`desc`,children:`Descending`})]})]})]}),(0,K.jsx)(V,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50 self-end`,onClick:()=>M(t),children:(0,K.jsx)(C,{className:`h-4 w-4`})})]},t)),m.length===0&&(0,K.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No grouping rules applied.`})]})]}),(0,K.jsxs)(I,{value:`sections`,className:`space-y-4 mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(R,{children:`Report Sections`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(V,{size:`sm`,variant:`outline`,onClick:()=>F(`header`),children:[(0,K.jsx)(W,{className:`h-4 w-4 mr-2`}),`Header`]}),(0,K.jsxs)(V,{size:`sm`,variant:`outline`,onClick:()=>F(`chart`),children:[(0,K.jsx)(W,{className:`h-4 w-4 mr-2`}),`Chart`]}),(0,K.jsxs)(V,{size:`sm`,variant:`outline`,onClick:()=>F(`table`),children:[(0,K.jsx)(W,{className:`h-4 w-4 mr-2`}),`Table`]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[g.map((e,t)=>(0,K.jsxs)(`div`,{className:`p-3 border rounded-lg space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`font-medium flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`text-xs bg-muted px-2 py-0.5 rounded uppercase`,children:e.type}),e.title]}),(0,K.jsx)(V,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50`,onClick:()=>z(t),children:(0,K.jsx)(C,{className:`h-4 w-4`})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Title`}),(0,K.jsx)(P,{className:`h-8 text-sm`,value:e.title||``,onChange:n=>B(t,{...e,title:n.target.value})})]}),e.type===`text`&&(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(R,{className:`text-xs`,children:`Content`}),(0,K.jsx)(P,{className:`h-8 text-sm`,value:e.text||``,onChange:n=>B(t,{...e,text:n.target.value})})]}),e.type===`chart`&&(0,K.jsxs)(`div`,{className:`col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded`,children:[(0,K.jsx)(`div`,{className:`col-span-2`,children:(0,K.jsx)(R,{className:`text-xs font-semibold`,children:`Chart Configuration`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`Chart Type`}),(0,K.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=>B(t,{...e,chart:{...e.chart,type:`chart`,chartType:n.target.value}}),children:[(0,K.jsx)(`option`,{value:`bar`,children:`Bar`}),(0,K.jsx)(`option`,{value:`line`,children:`Line`}),(0,K.jsx)(`option`,{value:`area`,children:`Area`}),(0,K.jsx)(`option`,{value:`pie`,children:`Pie`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(R,{className:`text-xs`,children:`X-Axis Field`}),(0,K.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=>B(t,{...e,chart:{...e.chart,type:`chart`,xAxisField:n.target.value}}),children:[(0,K.jsx)(`option`,{value:``,children:`Select Field...`}),r.map(e=>(0,K.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name)),r.length===0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`option`,{value:`name`,children:`Name`}),(0,K.jsx)(`option`,{value:`month`,children:`Month`})]})]})]}),(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(R,{className:`text-xs`,children:`Y-Axis Fields (comma separated)`}),(0,K.jsx)(P,{className:`h-8 text-sm`,placeholder:`e.g. value, count`,value:e.chart?.yAxisFields?.join(`, `)||``,onChange:n=>B(t,{...e,chart:{...e.chart,type:`chart`,yAxisFields:n.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}})})]})]})]})]},t)),g.length===0&&(0,K.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,K.jsx)(I,{value:`schedule`,className:`space-y-4 mt-4`,children:(0,K.jsx)(dt,{schedule:s.schedule,onChange:e=>c({...s,schedule:e})})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-2 mt-6 pt-4 border-t`,children:[(0,K.jsx)(V,{variant:`outline`,onClick:()=>{o&&console.log(`Report cancelled:`,o)},children:`Cancel`}),(0,K.jsxs)(V,{onClick:()=>{console.log(`Saving report:`,s),a&&alert(`Report saved! (Handler: `+a+`)`)},children:[(0,K.jsx)(ee,{className:`h-4 w-4 mr-2`}),`Save Report`]})]})]})]}),i&&(0,K.jsxs)(y,{className:`mt-8 border-2 border-blue-100`,children:[(0,K.jsx)(j,{className:`bg-blue-50/50`,children:(0,K.jsx)(A,{className:`text-blue-900 text-sm uppercase tracking-wide`,children:`Live Preview`})}),(0,K.jsx)(U,{className:`pt-6`,children:(0,K.jsx)(ut,{schema:{type:`report-viewer`,report:{...s,fields:l,filters:f,groupBy:m,sections:g},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`}]}})})]})]})},pt=[`tabular`,`summary`,`matrix`];function mt(e){let t=e.length+1,n=new Set(e.map(e=>e.name).filter(Boolean)),r=`block_${t}`;for(;n.has(r);)t+=1,r=`block_${t}`;return{name:r,type:`tabular`,columns:[]}}function ht(e){return typeof e.label==`string`?e.label:e.label&&typeof e.label==`object`?e.label.default??``:``}function gt(e){return typeof e.description==`string`?e.description:e.description&&typeof e.description==`object`?e.description.default??``:``}function _t({block:e,index:t,total:n,availableFields:r,t:i,duplicateName:a,onChange:o,onRemove:s,onMove:c}){let[l,u]=G.useState(t===0),d=e.type??`tabular`,f=d===`summary`,p=d===`matrix`,h=f||p,g=!e.name||!e.name.trim(),_=g||a,v=t=>o({...e,...t});return(0,K.jsxs)(`div`,{className:`border rounded-md bg-card text-card-foreground`,"data-testid":`joined-block-${t}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 p-1.5 border-b bg-muted/30`,children:[(0,K.jsx)(V,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0`,onClick:()=>u(e=>!e),"aria-label":l?`Collapse block`:`Expand block`,"aria-expanded":l,"data-testid":`joined-block-toggle-${t}`,children:l?(0,K.jsx)(le,{className:`h-3.5 w-3.5`}):(0,K.jsx)(N,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(`input`,{type:`text`,className:`h-6 text-xs border rounded px-1.5 bg-background flex-1 min-w-0 ${_?`border-destructive`:``}`,value:e.name??``,onChange:e=>v({name:e.target.value}),placeholder:i(`report.editor.blockNamePlaceholder`),"aria-label":i(`report.editor.blockName`),"aria-invalid":_,"data-testid":`joined-block-name-${t}`}),(0,K.jsx)(`select`,{className:`h-6 text-xs border rounded px-1 bg-background shrink-0`,value:d,onChange:e=>v({type:e.target.value}),"aria-label":i(`report.editor.type`),"data-testid":`joined-block-type-${t}`,children:pt.map(e=>(0,K.jsx)(`option`,{value:e,children:i(`report.editor.type${e.charAt(0).toUpperCase()}${e.slice(1)}`)},e))}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5 shrink-0`,children:[(0,K.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:t===0,onClick:()=>c(-1),"aria-label":`Move block up`,children:(0,K.jsx)(m,{className:`h-2.5 w-2.5`})}),(0,K.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:t===n-1,onClick:()=>c(1),"aria-label":`Move block down`,children:(0,K.jsx)(b,{className:`h-2.5 w-2.5`})})]}),(0,K.jsx)(V,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 w-6 p-0 shrink-0 text-destructive hover:text-destructive`,onClick:s,"aria-label":i(`report.editor.removeBlock`),"data-testid":`joined-block-remove-${t}`,children:(0,K.jsx)(C,{className:`h-3 w-3`})})]}),_&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 text-[10px] text-destructive bg-destructive/5 border-b`,children:[(0,K.jsx)(z,{className:`h-3 w-3`}),i(g?`report.editor.validationBlockNameRequired`:`report.editor.validationBlockNameDuplicate`)]}),l&&(0,K.jsxs)(`div`,{className:`p-2 space-y-2 text-xs`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`report.editor.blockLabel`)}),(0,K.jsx)(`input`,{type:`text`,className:`h-6 text-xs border rounded px-1.5 bg-background`,value:ht(e),onChange:e=>v({label:e.target.value||void 0}),placeholder:i(`report.editor.blockLabelPlaceholder`),"data-testid":`joined-block-label-${t}`})]}),(0,K.jsxs)(`label`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`report.editor.objectName`)}),(0,K.jsx)(`input`,{type:`text`,className:`h-6 text-xs border rounded px-1.5 bg-background`,value:e.objectName??``,onChange:e=>v({objectName:e.target.value||void 0}),placeholder:i(`report.editor.objectNamePlaceholder`),"data-testid":`joined-block-object-${t}`})]})]}),(0,K.jsxs)(`label`,{className:`flex flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`report.editor.blockDescription`)}),(0,K.jsx)(`textarea`,{className:`text-xs border rounded px-1.5 py-1 bg-background resize-y min-h-[2rem]`,rows:2,value:gt(e),onChange:e=>v({description:e.target.value||void 0}),placeholder:i(`report.editor.blockDescriptionPlaceholder`),"data-testid":`joined-block-description-${t}`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-0.5`,children:i(`report.editor.columns`)}),(0,K.jsx)(It,{availableFields:r,value:e.columns,onChange:e=>v({columns:e}),t:i})]}),(f||p)&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-0.5`,children:i(`report.editor.rows`)}),(0,K.jsx)(Lt,{availableFields:r,value:e.groupingsDown,onChange:e=>v({groupingsDown:e}),t:i})]}),p&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-0.5`,children:i(`report.editor.columnsAxis`)}),(0,K.jsx)(Lt,{availableFields:r,value:e.groupingsAcross,onChange:e=>v({groupingsAcross:e}),t:i})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-0.5`,children:i(`report.editor.filters`)}),(0,K.jsx)(kt,{availableFields:r,value:e.filter,onChange:e=>v({filter:e}),t:i})]}),h&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground mb-0.5`,children:i(`report.editor.chart`)}),(0,K.jsx)(Rt,{availableFields:r,columns:Ft(e.columns),value:e.chart,onChange:e=>v({chart:e}),t:i})]})]})]})}function vt(e){return Array.isArray(e)?e.map(e=>{let t=e??{};return{name:t.name??``,type:t.type??`tabular`,columns:Array.isArray(t.columns)?t.columns:[],...t}}):[]}function yt({value:e,onChange:t,availableFields:n,getFieldsForObject:r,containerObjectName:i,t:a}){let o=vt(e),s=e=>r?r(e.objectName??i)??n:n,c={};for(let e of o)e.name&&(c[e.name]=(c[e.name]??0)+1);let l=(e,n)=>{t(o.map((t,r)=>r===e?n:t))},u=e=>{t(o.filter((t,n)=>n!==e))},d=(e,n)=>{let r=e+n;if(r<0||r>=o.length)return;let i=[...o];[i[e],i[r]]=[i[r],i[e]],t(i)};return(0,K.jsxs)(`div`,{className:`space-y-2`,"data-testid":`joined-blocks-editor`,children:[o.length===0&&(0,K.jsx)(`div`,{className:`text-[10px] text-muted-foreground italic px-1`,children:a(`report.editor.validationJoinedNeedsBlocks`)}),o.map((e,t)=>(0,K.jsx)(_t,{block:e,index:t,total:o.length,availableFields:s(e),t:a,duplicateName:!!e.name&&(c[e.name]??0)>1,onChange:e=>l(t,e),onRemove:()=>u(t),onMove:e=>d(t,e)},t)),(0,K.jsxs)(V,{type:`button`,size:`sm`,variant:`outline`,className:`h-7 text-xs w-full`,onClick:()=>{t([...o,mt(o)])},"data-testid":`joined-block-add`,children:[(0,K.jsx)(W,{className:`h-3 w-3 mr-1`}),a(`report.editor.addBlock`)]})]})}function bt(e,t){let n=[];if(!Array.isArray(e)||e.length===0)return n.push(t(`report.editor.validationJoinedNeedsBlocks`)),n;let r=new Map,i=!1,a=!1,o=!1;for(let t of e){let e=t??{};if(!e.name||!String(e.name).trim())i=!0;else{let t=(r.get(e.name)??0)+1;r.set(e.name,t),t===2&&(a=!0)}(!Array.isArray(e.columns)||e.columns.length===0)&&(o=!0)}return i&&n.push(t(`report.editor.validationBlockNameRequired`)),a&&n.push(t(`report.editor.validationBlockNameDuplicate`)),o&&n.push(t(`report.editor.validationBlockNeedsColumns`)),n}var xt={$eq:`equals`,$ne:`notEquals`,$gt:`greaterThan`,$gte:`greaterOrEqual`,$lt:`lessThan`,$lte:`lessOrEqual`,$in:`in`,$nin:`notIn`,$contains:`contains`,$notContains:`notContains`,$exists:`isNotEmpty`},St={equals:`$eq`,notEquals:`$ne`,greaterThan:`$gt`,greaterOrEqual:`$gte`,lessThan:`$lt`,lessOrEqual:`$lte`,in:`$in`,notIn:`$nin`,contains:`$contains`,notContains:`$notContains`},Ct=()=>({id:`root`,logic:`and`,conditions:[]});function wt(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function $(){return Math.random().toString(36).slice(2,10)}function Tt(e,t){if(typeof t!=`object`||!t||Array.isArray(t))return[{id:$(),field:e,operator:Array.isArray(t)?`in`:`equals`,value:t}];let n=[];for(let[r,i]of Object.entries(t)){if(r===`$exists`){n.push({id:$(),field:e,operator:i===!1?`isEmpty`:`isNotEmpty`,value:``});continue}if(r===`$null`){n.push({id:$(),field:e,operator:i===!1?`isNotEmpty`:`isEmpty`,value:``});continue}let t=xt[r];if(!t||wt(i)&&`$field`in i)return null;n.push({id:$(),field:e,operator:t,value:i})}return n.length>0?n:null}function Et(e){if(e==null)return{group:Ct(),complex:!1};if(!wt(e))return{group:Ct(),complex:!0};let t=Object.keys(e);if(t.length===1&&(t[0]===`$and`||t[0]===`$or`)){let n=t[0]===`$or`?`or`:`and`,r=e[t[0]];if(!Array.isArray(r))return{group:Ct(),complex:!0};let i=[],a=!1;for(let e of r){if(!wt(e)){a=!0;continue}if(Object.keys(e).some(e=>e===`$and`||e===`$or`||e===`$not`)){a=!0;continue}for(let[t,n]of Object.entries(e)){let e=Tt(t,n);e?i.push(...e):a=!0}}return{group:{id:`root`,logic:n,conditions:i},complex:a}}if(t.includes(`$not`)||t.includes(`$and`)||t.includes(`$or`))return{group:Ct(),complex:!0};let n=[],r=!1;for(let[t,i]of Object.entries(e)){let e=Tt(t,i);e?n.push(...e):r=!0}return{group:{id:`root`,logic:`and`,conditions:n},complex:r}}function Dt(e){if(!e||!Array.isArray(e.conditions)||e.conditions.length===0)return;let t=e.conditions.filter(e=>e.field).map(e=>Ot(e));if(t.length!==0)return t.length===1?t[0]:{[e.logic===`or`?`$or`:`$and`]:t}}function Ot(e){let{field:t,operator:n,value:r}=e;if(n===`isEmpty`)return{[t]:{$exists:!1}};if(n===`isNotEmpty`)return{[t]:{$exists:!0}};if(n===`equals`)return{[t]:r};let i=St[n];return i?{[t]:{[i]:r}}:{[t]:r}}function kt({availableFields:e,value:t,onChange:n,t:r}){let i=G.useMemo(()=>JSON.stringify(t??null),[t]),a=G.useMemo(()=>Et(t),[i]),[o,s]=G.useState(a.group),c=G.useRef(i);G.useEffect(()=>{c.current!==i&&(s(a.group),c.current=i)},[i,a.group]);let l=e=>{s(e);let t=Dt(e);c.current=JSON.stringify(t??null),n(t)};if(a.complex)return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-2 rounded border border-amber-300 bg-amber-50 text-amber-900 text-[11px]`,children:[(0,K.jsx)(z,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:r(`report.editor.filtersComplex`)})]});let u=()=>{l({...o,conditions:[...o.conditions,{id:$(),field:e[0]?.value??``,operator:`equals`,value:``}]})},d=e=>{l({...o,conditions:o.conditions.filter(t=>t.id!==e)})},f=(e,t)=>{l({...o,conditions:o.conditions.map(n=>n.id===e?{...n,...t}:n)})},p=[{value:`equals`,label:`=`},{value:`notEquals`,label:`≠`},{value:`greaterThan`,label:`>`},{value:`greaterOrEqual`,label:`≥`},{value:`lessThan`,label:`<`},{value:`lessOrEqual`,label:`≤`},{value:`contains`,label:r(`report.editor.opContains`,`contains`)},{value:`in`,label:`in`},{value:`notIn`,label:`not in`},{value:`isEmpty`,label:r(`report.editor.opIsEmpty`,`is empty`)},{value:`isNotEmpty`,label:r(`report.editor.opIsNotEmpty`,`is not empty`)}];return(0,K.jsxs)(`div`,{className:`space-y-1.5 py-1`,"data-testid":`spec-filter-adapter`,children:[o.conditions.length>1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:r(`report.editor.combineLogic`,`Combine with`)}),(0,K.jsxs)(`select`,{className:`h-5 text-[10px] border rounded px-1 bg-background`,value:o.logic,onChange:e=>l({...o,logic:e.target.value}),"data-testid":`filter-logic-select`,children:[(0,K.jsx)(`option`,{value:`and`,children:`AND`}),(0,K.jsx)(`option`,{value:`or`,children:`OR`})]})]}),o.conditions.map(t=>(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] p-1 border rounded bg-muted/20`,children:[(0,K.jsx)(`select`,{className:`h-5 text-[10px] border rounded px-1 bg-background flex-1 min-w-0`,value:t.field,onChange:e=>f(t.id,{field:e.target.value}),"data-testid":`filter-field-${t.id}`,children:e.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,K.jsx)(`select`,{className:`h-5 text-[10px] border rounded px-1 bg-background w-20 shrink-0`,value:t.operator,onChange:e=>f(t.id,{operator:e.target.value}),"data-testid":`filter-op-${t.id}`,children:p.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}),t.operator!==`isEmpty`&&t.operator!==`isNotEmpty`&&(0,K.jsx)(`input`,{className:`h-5 text-[10px] border rounded px-1 bg-background w-24 shrink-0`,value:Array.isArray(t.value)?t.value.join(`,`):(t.value??``).toString(),placeholder:`value`,onChange:e=>{let n=e.target.value,r=t.operator===`in`||t.operator===`notIn`?n.split(`,`).map(e=>e.trim()).filter(Boolean):n;f(t.id,{value:r})},"data-testid":`filter-value-${t.id}`}),(0,K.jsx)(V,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:()=>d(t.id),"data-testid":`filter-remove-${t.id}`,children:(0,K.jsx)(C,{className:`h-3 w-3`})})]},t.id)),(0,K.jsxs)(V,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 text-[10px] w-full`,onClick:u,disabled:e.length===0,"data-testid":`filter-add`,children:[(0,K.jsx)(W,{className:`h-3 w-3 mr-1`}),r(`report.editor.addCondition`,`Add condition`)]})]})}var At=new Set([`date`,`datetime`,`time`]),jt=new Set([`number`,`currency`,`percent`,`rating`,`integer`]);function Mt({availableFields:e,selectedValues:t,onAdd:n,t:r,triggerLabel:i,title:a,description:o,testIdPrefix:s=`field-picker`,singleSelect:c=!1,commitOnSelect:l=!1,disabled:u=!1,triggerClassName:d,trigger:f}){let[m,v]=G.useState(!1),[y,b]=G.useState(``),[S,C]=G.useState(new Set),w=G.useMemo(()=>new Set(t),[t]);G.useEffect(()=>{m&&(b(``),C(new Set))},[m]);let E=y.trim().toLowerCase(),D=e.filter(e=>!w.has(e.value)),O=E?D.filter(e=>e.label.toLowerCase().includes(E)||e.value.toLowerCase().includes(E)):D,A=e=>{if(c&&l){n([e]),v(!1);return}C(t=>{let n=new Set(c?[]:t);return t.has(e)?n.delete(e):n.add(e),n})},j=()=>{if(S.size===0){v(!1);return}n(D.map(e=>e.value).filter(e=>S.has(e))),v(!1)},M=()=>{v(!1)},N=e.length===0,P=!N&&D.length===0,F=i??r(`report.editor.addColumns`,`Add fields`),I=a??r(`report.editor.fieldPickerTitle`,`Select fields`),L=o??r(`report.editor.fieldPickerDescription`,`Pick one or more fields to add. Use the search box to narrow the list.`);return(0,K.jsxs)(h,{open:m,onOpenChange:v,children:[(0,K.jsx)(k,{asChild:!0,children:f??(0,K.jsxs)(V,{type:`button`,variant:`outline`,size:`sm`,className:d??`h-8 gap-1.5`,disabled:u||N||P,"data-testid":`${s}-trigger`,children:[(0,K.jsx)(W,{className:`h-3.5 w-3.5`}),(0,K.jsx)(`span`,{children:F})]})}),(0,K.jsxs)(_,{className:`sm:max-w-md max-w-[92vw] gap-3`,"data-testid":`${s}-dialog`,children:[(0,K.jsxs)(ue,{children:[(0,K.jsx)(p,{children:I}),(0,K.jsx)(x,{children:L})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(te,{className:`pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,K.jsx)(`input`,{type:`text`,className:`h-9 w-full text-sm border rounded pl-7 pr-2 bg-background`,placeholder:r(`report.editor.searchFields`,`Search fields…`),value:y,onChange:e=>b(e.target.value),"data-testid":`${s}-search`,autoFocus:!0})]}),(0,K.jsxs)(`div`,{className:`text-[11px] text-muted-foreground flex items-center justify-between`,children:[(0,K.jsxs)(`span`,{children:[O.length,`/`,D.length,S.size>0?` · ${r(`report.editor.fieldPickerSelected`,`{n} selected`).replace(`{n}`,String(S.size))}`:``]}),S.size>0&&(0,K.jsx)(`button`,{type:`button`,className:`text-[11px] underline-offset-2 hover:underline text-muted-foreground`,onClick:()=>C(new Set),"data-testid":`${s}-clear`,children:r(`report.editor.fieldPickerClear`,`Clear selection`)})]}),(0,K.jsx)(`div`,{className:`max-h-72 overflow-auto border rounded bg-background/40 p-1 space-y-0.5`,"data-testid":`${s}-list`,children:N?(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground px-2 py-3 text-center`,children:r(`report.editor.noFields`,`No fields available — pick a data source first.`)}):P?(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground px-2 py-3 text-center`,children:r(`report.editor.noFieldsAvailable`,`All fields already added.`)}):O.length===0?(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground px-2 py-3 text-center`,children:r(`report.editor.noMatchingFields`,`No fields match your search.`)}):O.map(e=>{let t=S.has(e.value);return(0,K.jsxs)(`label`,{className:`flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 text-sm cursor-pointer`,"data-testid":`${s}-row-${e.value}`,children:[(0,K.jsx)(g,{checked:t,onCheckedChange:()=>A(e.value),"data-testid":`${s}-toggle-${e.value}`}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,title:e.label,children:e.label}),e.type&&(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:e.type})]},e.value)})}),!(c&&l)&&(0,K.jsxs)(T,{className:`gap-2 sm:gap-2`,children:[(0,K.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:M,"data-testid":`${s}-cancel`,children:r(`common.cancel`,`Cancel`)}),(0,K.jsx)(V,{type:`button`,size:`sm`,onClick:j,disabled:S.size===0,"data-testid":`${s}-confirm`,children:S.size>0?r(`report.editor.fieldPickerAddN`,`Add {n}`).replace(`{n}`,String(S.size)):r(`report.editor.fieldPickerAdd`,`Add`)})]})]})]})}function Nt(e){return[{value:``,label:e(`report.editor.noneOption`)},{value:`sum`,label:e(`report.aggregate.sum`)},{value:`count`,label:e(`report.aggregate.count`)},{value:`unique`,label:e(`report.aggregate.countDistinct`)},{value:`avg`,label:e(`report.aggregate.avg`)},{value:`min`,label:e(`report.aggregate.min`)},{value:`max`,label:e(`report.aggregate.max`)}]}function Pt(e){return[{value:``,label:e(`report.editor.formatAuto`,`Auto`)},{value:`currency`,label:e(`report.editor.formatCurrency`,`Currency`)},{value:`percent`,label:e(`report.editor.formatPercent`,`Percent`)},{value:`integer`,label:e(`report.editor.formatInteger`,`Integer`)},{value:`date`,label:e(`report.editor.formatDate`,`Date`)},{value:`datetime`,label:e(`report.editor.formatDatetime`,`Date & time`)}]}function Ft(e){return Array.isArray(e)?e.map(e=>typeof e==`string`?{field:e,label:e,type:`string`}:{field:e.field||e.name||e.value,label:e.label,type:e.type||`string`,aggregate:e.aggregate??e.aggregation,format:e.format}):[]}function It({availableFields:e,value:t,onChange:n,t:r}){let i=Ft(t),a=new Set(i.map(e=>e.field)),o=Nt(r),s=Pt(r),c=t=>{if(t.length===0)return;let r=t.filter(e=>!a.has(e)).map(t=>{let n=e.find(e=>e.value===t);return{field:t,label:n?.label,type:n?.type||`string`}});r.length!==0&&n([...i,...r])},l=e=>{n(i.filter(t=>t.field!==e))},u=(e,t)=>{n(i.map(n=>n.field===e?{...n,...t}:n))},d=(e,t)=>{let r=[...i],a=e+t;a<0||a>=r.length||([r[e],r[a]]=[r[a],r[e]],n(r))};return e.length===0?(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground py-2`,"data-testid":`columns-editor-empty`,children:r(`report.editor.noFields`,`No fields available — pick a data source first.`)}):(0,K.jsxs)(`div`,{className:`space-y-2 py-1`,"data-testid":`columns-editor`,children:[i.length>0&&(0,K.jsx)(`div`,{className:`space-y-1.5`,"data-testid":`columns-selected`,children:i.map((t,n)=>{let a=e.find(e=>e.value===t.field);return(0,K.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-1.5 p-1.5 border rounded bg-muted/30 text-xs`,"data-testid":`column-row-${t.field}`,children:[(0,K.jsxs)(`div`,{className:`row-span-2 flex flex-col items-center justify-center gap-0.5`,children:[(0,K.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:n===0,onClick:()=>d(n,-1),"aria-label":`Move up`,"data-testid":`column-up-${t.field}`,children:(0,K.jsx)(m,{className:`h-3 w-3`})}),(0,K.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:n===i.length-1,onClick:()=>d(n,1),"aria-label":`Move down`,"data-testid":`column-down-${t.field}`,children:(0,K.jsx)(b,{className:`h-3 w-3`})})]}),(0,K.jsx)(`input`,{className:`h-7 text-xs border rounded px-2 bg-background min-w-0 w-full`,value:t.label??``,placeholder:a?.label??t.field,onChange:e=>u(t.field,{label:e.target.value||void 0}),"data-testid":`column-label-${t.field}`,title:a?.label??t.field}),(0,K.jsx)(V,{type:`button`,size:`sm`,variant:`ghost`,className:`row-span-2 h-7 w-7 p-0 shrink-0 self-start`,onClick:()=>l(t.field),"data-testid":`column-remove-${t.field}`,"aria-label":`Remove column`,children:(0,K.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,K.jsxs)(`label`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide`,children:r(`report.editor.aggregateColumn`,`Aggregate`)}),(0,K.jsx)(`select`,{className:`h-7 text-xs border rounded px-1 bg-background w-full min-w-0`,value:t.aggregate??``,onChange:e=>u(t.field,{aggregate:e.target.value===``?void 0:e.target.value}),"data-testid":`column-agg-${t.field}`,children:o.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,K.jsxs)(`label`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide`,children:r(`report.editor.formatColumn`,`Format`)}),(0,K.jsx)(`select`,{className:`h-7 text-xs border rounded px-1 bg-background w-full min-w-0`,value:t.format??``,onChange:e=>u(t.field,{format:e.target.value===``?void 0:e.target.value}),"data-testid":`column-fmt-${t.field}`,children:s.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})]})]},t.field)})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[(0,K.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i.length>0?r(`report.editor.columnsCount`,`{n} column(s) selected`).replace(`{n}`,String(i.length)):r(`report.editor.columnsEmpty`,`No columns selected yet.`)}),(0,K.jsx)(Mt,{availableFields:e,selectedValues:i.map(e=>e.field),onAdd:c,t:r,testIdPrefix:`columns-picker`,triggerLabel:r(`report.editor.addColumns`,`Add fields`)})]})]})}function Lt({availableFields:e,value:t,onChange:n,t:r,testIdPrefix:i=`grouping`}){let a=Array.isArray(t)?t.map(e=>({field:e.field??``,sortOrder:e.sortOrder??e.sort??`asc`,dateGranularity:e.dateGranularity})):[],o=[{value:``,label:r(`report.editor.dateGranularityNone`)},{value:`day`,label:r(`report.editor.day`)},{value:`week`,label:r(`report.editor.week`)},{value:`month`,label:r(`report.editor.month`)},{value:`quarter`,label:r(`report.editor.quarter`)},{value:`year`,label:r(`report.editor.year`)}],s=a.map(e=>e.field).filter(Boolean),c=e=>{n(a.filter((t,n)=>n!==e))},l=(e,t)=>{n(a.map((n,r)=>r===e?{...n,...t}:n))},u=(e,t)=>{let r=[...a],i=e+t;i<0||i>=r.length||([r[e],r[i]]=[r[i],r[e]],n(r))},d=e=>{if(e.length===0)return;let t=e.map(e=>({field:e,sortOrder:`asc`}));n([...a,...t])},f=(t,n)=>{let r=n[0];if(!r)return;let i=e.find(e=>e.value===r);l(t,{field:r,dateGranularity:i&&At.has(i.type??``)?a[t]?.dateGranularity:void 0})};return(0,K.jsxs)(`div`,{className:`space-y-1.5 py-1`,"data-testid":`${i}s-builder`,children:[a.map((t,n)=>{let d=e.find(e=>e.value===t.field),p=d&&At.has(d.type??``),h=d?.label??t.field??r(`report.editor.fieldPickerEmpty`,`(pick field)`);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 p-1.5 border rounded bg-muted/20 text-xs`,"data-testid":`${i}-row-${n}`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-0.5 shrink-0`,children:[(0,K.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:n===0,onClick:()=>u(n,-1),"aria-label":`Move up`,"data-testid":`${i}-up-${n}`,children:(0,K.jsx)(m,{className:`h-3 w-3`})}),(0,K.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:n===a.length-1,onClick:()=>u(n,1),"aria-label":`Move down`,"data-testid":`${i}-down-${n}`,children:(0,K.jsx)(b,{className:`h-3 w-3`})})]}),(0,K.jsx)(Mt,{availableFields:e,selectedValues:s.filter(e=>e!==t.field),onAdd:e=>f(n,e),t:r,singleSelect:!0,commitOnSelect:!0,testIdPrefix:`${i}-field-picker-${n}`,title:r(`report.editor.fieldPickerChangeTitle`,`Change field`),trigger:(0,K.jsxs)(`button`,{type:`button`,className:`h-7 flex-1 min-w-0 text-left text-xs border rounded px-2 bg-background hover:bg-muted/40 inline-flex items-center justify-between gap-1.5`,"data-testid":`${i}-field-${n}`,title:h,children:[(0,K.jsx)(`span`,{className:`truncate`,children:h}),(0,K.jsx)(le,{className:`h-3 w-3 text-muted-foreground shrink-0`})]})}),(0,K.jsxs)(`select`,{className:`h-7 text-xs border rounded px-1.5 bg-background w-20 shrink-0`,value:t.sortOrder??`asc`,onChange:e=>l(n,{sortOrder:e.target.value}),"data-testid":`${i}-sort-${n}`,children:[(0,K.jsx)(`option`,{value:`asc`,children:r(`report.editor.sortAsc`)}),(0,K.jsx)(`option`,{value:`desc`,children:r(`report.editor.sortDesc`)})]}),p&&(0,K.jsx)(`select`,{className:`h-7 text-xs border rounded px-1.5 bg-background w-24 shrink-0`,value:t.dateGranularity??``,onChange:e=>l(n,{dateGranularity:e.target.value||void 0}),"data-testid":`${i}-granularity-${n}`,children:o.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,K.jsx)(V,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 shrink-0`,onClick:()=>c(n),"aria-label":`Remove grouping`,"data-testid":`${i}-remove-${n}`,children:(0,K.jsx)(C,{className:`h-3.5 w-3.5`})})]},n)}),(0,K.jsx)(Mt,{availableFields:e,selectedValues:s,onAdd:d,t:r,singleSelect:!0,commitOnSelect:!0,testIdPrefix:`${i}-add-picker`,triggerLabel:r(`report.editor.addGrouping`),title:r(`report.editor.fieldPickerAddGroupingTitle`,`Add grouping`),triggerClassName:`h-8 w-full justify-center gap-1.5`})]})}function Rt({availableFields:e,columns:t,value:n,onChange:r,t:i}){let a=n||{},o=a.type??a.chartType??``,s=a.xAxis??a.xAxisField??``,c=a.yAxis??a.yAxisFields?.[0]??``,l=e=>{let t={...a,...e};if(`type`in e&&delete t.chartType,`xAxis`in e&&delete t.xAxisField,`yAxis`in e&&delete t.yAxisFields,!e.type&&e.type===``)return r(void 0);r(t)},u=()=>r(void 0),d=[{value:``,label:i(`report.editor.chartNone`)},{value:`bar`,label:i(`report.editor.chartBar`)},{value:`line`,label:i(`report.editor.chartLine`)},{value:`area`,label:i(`report.editor.chartArea`)},{value:`pie`,label:i(`report.editor.chartPie`)},{value:`donut`,label:i(`report.editor.chartDonut`)},{value:`funnel`,label:i(`report.editor.chartFunnel`)}],f=t.filter(e=>e.aggregate).map(e=>e.field),p=e.filter(e=>jt.has(e.type??``)).map(e=>e.value),m=new Set([...f,...p]),h=e.filter(e=>m.has(e.value));return(0,K.jsxs)(`div`,{className:`space-y-2 py-1`,"data-testid":`chart-config`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:i(`report.editor.chartType`)}),(0,K.jsx)(`select`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:o,onChange:e=>{let t=e.target.value;t?l({type:t}):u()},"data-testid":`chart-type-select`,children:d.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),o&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:i(`report.editor.chartTitle`)}),(0,K.jsx)(`input`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:a.title??``,placeholder:i(`report.editor.chartTitlePlaceholder`),onChange:e=>l({title:e.target.value||void 0}),"data-testid":`chart-title`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:i(`report.editor.chartXAxis`)}),(0,K.jsxs)(`select`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:s,onChange:e=>l({xAxis:e.target.value||void 0}),"data-testid":`chart-x-field`,children:[(0,K.jsx)(`option`,{value:``,children:`—`}),e.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:i(`report.editor.chartYAxis`)}),(0,K.jsxs)(`select`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:c,onChange:e=>l({yAxis:e.target.value||void 0}),"data-testid":`chart-y-field`,children:[(0,K.jsx)(`option`,{value:``,children:`—`}),(h.length>0?h:e).map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-[10px]`,children:[(0,K.jsx)(g,{checked:a.showLegend!==!1,onCheckedChange:e=>l({showLegend:e===!0}),"data-testid":`chart-show-legend`}),(0,K.jsx)(`span`,{children:i(`report.editor.chartShowLegend`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-[10px]`,children:[(0,K.jsx)(g,{checked:!!a.showDataLabels,onCheckedChange:e=>l({showDataLabels:e===!0}),"data-testid":`chart-show-data-labels`}),(0,K.jsx)(`span`,{children:i(`report.editor.chartShowDataLabels`)})]})]})]})}function zt(e,t,n){let r=e=>e.type===`summary`,i=e=>e.type===`matrix`,a=e=>e.type===`summary`||e.type===`matrix`,o=[{key:`basic`,title:t(`report.editor.basic`),fields:[{key:`label`,label:t(`report.editor.title`),type:`input`,placeholder:t(`report.editor.titlePlaceholder`)},{key:`description`,label:t(`report.editor.description`),type:`textarea`,placeholder:t(`report.editor.descriptionPlaceholder`)},{key:`type`,label:t(`report.editor.type`),type:`select`,defaultValue:`tabular`,options:[{value:`tabular`,label:t(`report.editor.typeTabular`)},{value:`summary`,label:t(`report.editor.typeSummary`)},{value:`matrix`,label:t(`report.editor.typeMatrix`)},{value:`joined`,label:t(`report.editor.typeJoined`)}],helpText:t(`report.editor.typeHelp`)}]},{key:`data`,title:t(`report.editor.data`),collapsible:!0,fields:[{key:`objectName`,label:t(`report.editor.objectName`),type:`input`,placeholder:t(`report.editor.objectNamePlaceholder`),helpText:t(`report.editor.objectNameHelp`)},{key:`limit`,label:t(`report.editor.limit`),type:`input`,placeholder:t(`report.editor.limitPlaceholder`)}]},{key:`rows`,title:t(`report.editor.rows`),collapsible:!0,hint:t(`report.editor.rowsHint`),visibleWhen:e=>r(e)||i(e),fields:[{key:`groupingsDown`,label:t(`report.editor.grouping`),type:`custom`,render:(n,r)=>(0,K.jsx)(Lt,{availableFields:e,value:n,onChange:r,t,testIdPrefix:`rows-grouping`})}]},{key:`columnsAxis`,title:t(`report.editor.columnsAxis`),collapsible:!0,hint:t(`report.editor.columnsAxisHint`),visibleWhen:e=>i(e),fields:[{key:`groupingsAcross`,label:t(`report.editor.grouping`),type:`custom`,render:(n,r)=>(0,K.jsx)(Lt,{availableFields:e,value:n,onChange:r,t,testIdPrefix:`cols-grouping`})}]},{key:`tabular-columns`,title:t(`report.editor.columns`),collapsible:!0,hint:t(`report.editor.columnsHint`),visibleWhen:e=>e.type!==`joined`&&!r(e)&&!i(e),fields:[{key:`columns`,label:t(`report.editor.columns`),type:`custom`,render:(n,r)=>(0,K.jsx)(It,{availableFields:e,value:n,onChange:r,t})}]},{key:`values`,title:t(`report.editor.values`),collapsible:!0,hint:t(`report.editor.valuesHint`),visibleWhen:e=>r(e)||i(e),fields:[{key:`columns`,label:t(`report.editor.values`),type:`custom`,render:(n,r)=>(0,K.jsx)(It,{availableFields:e,value:n,onChange:r,t})}]},{key:`filters`,title:t(`report.editor.filters`),collapsible:!0,hint:t(`report.editor.filtersHint`),visibleWhen:e=>e.type!==`joined`,fields:[{key:`filter`,label:t(`report.editor.filters`),type:`custom`,render:(n,r)=>(0,K.jsx)(kt,{availableFields:e,value:n,onChange:r,t})}]},{key:`blocks`,title:t(`report.editor.blocks`),collapsible:!0,hint:t(`report.editor.blocksHint`),visibleWhen:e=>e.type===`joined`,fields:[{key:`blocks`,label:t(`report.editor.blocks`),type:`custom`,render:(r,i,a)=>(0,K.jsx)(yt,{value:r,onChange:i,availableFields:e,getFieldsForObject:n,containerObjectName:a?.objectName,t})}]},{key:`chart`,title:t(`report.editor.chart`),collapsible:!0,defaultCollapsed:!0,hint:t(`report.editor.chartHint`),visibleWhen:e=>a(e),fields:[{key:`chart`,label:t(`report.editor.chart`),type:`custom`,render:(n,r,i)=>(0,K.jsx)(Rt,{availableFields:e,columns:Ft(i.columns),value:n,onChange:r,t})}]}];return{breadcrumb:[t(`report.editor.breadcrumb`,`Configuration`)],sections:o}}function Bt(e,t){let n=[],r=e.type??`tabular`,i=Array.isArray(e.groupingsDown)?e.groupingsDown.length:0,a=Array.isArray(e.groupingsAcross)?e.groupingsAcross.length:0,o=Array.isArray(e.columns)?e.columns.length:0;if(e.objectName||n.push({level:o>0?`error`:`warning`,message:t(`report.editor.validationNeedsObject`)}),r===`matrix`&&(i===0||a===0)&&n.push({level:`error`,message:t(`report.editor.validationMatrixNeedsRowsCols`)}),r===`summary`&&i===0&&n.push({level:`error`,message:t(`report.editor.validationSummaryNeedsRows`)}),r===`joined`)for(let r of bt(e.blocks,t))n.push({level:`error`,message:r});return n}function Vt({problems:e}){return e.length===0?null:(0,K.jsx)(`div`,{className:`space-y-1 p-2 border-b`,"data-testid":`report-validation-banner`,children:e.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-[11px] rounded px-2 py-1 `+(e.level===`error`?`bg-red-50 border border-red-200 text-red-900`:`bg-amber-50 border border-amber-200 text-amber-900`),children:[(0,K.jsx)(z,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:e.message})]},t))})}function Ht({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,availableFields:a,getFieldsForObject:o}){let{t:s}=l(),c=G.useCallback((e,t,n)=>t===void 0?s(e,n):s(e,{defaultValue:t,...n||{}}),[s]),u=a??[],d=G.useMemo(()=>zt(u,c,o),[u,c,o]),{draft:f,isDirty:p,updateField:m,discard:h}=ce(G.useMemo(()=>n??{},[n])),g=G.useCallback((e,t)=>{m(e,t),i?.(e,t,{...f,[e]:t})},[m,i,f]),_=G.useCallback(()=>{r(f),t()},[f,r,t]),v=G.useMemo(()=>Bt(f,c),[f,c]);return e?(0,K.jsx)(O,{open:e,onClose:t,schema:d,draft:f,isDirty:p,onFieldChange:g,onSave:_,onDiscard:h,headerExtra:(0,K.jsx)(Vt,{problems:v}),style:{"--config-panel-width":`440px`}}):null}async function Ut(e,t){let{dataSource:n,resource:r,queryParams:i,format:a,exportConfig:o}=t,s=a||e.defaultExportFormat||`pdf`;try{let t=(await n.find(r,i)).data||[];return tt(s,e,t,{format:s,...e.exportConfigs?.[s],...o}),{success:!0,recordCount:t.length,format:s}}catch(e){return{success:!1,recordCount:0,format:s,error:e.message}}}function Wt(e,t,n={}){let{columns:r,filename:i,includeAggregationRow:a=!1}=n,o=r||(e.fields||[]).map(Kt),s=o.map(e=>e.header),c=t.map((e,t)=>o.map(n=>{if(n.formula)return n.formula.replace(/\{ROW\}/g,String(t+2));let r=e[n.name];return qt(r,n.numberFormat)}));if(a&&t.length>0){let n=o.map((n,r)=>{let i=(e.fields||[]).find(e=>e.name===n.name);if(i?.aggregation){let e=Yt(r),n=t.length+1;switch(i.aggregation){case`sum`:return`=SUM(${e}2:${e}${n})`;case`avg`:return`=AVERAGE(${e}2:${e}${n})`;case`count`:return`=COUNTA(${e}2:${e}${n})`;case`min`:return`=MIN(${e}2:${e}${n})`;case`max`:return`=MAX(${e}2:${e}${n})`;default:return``}}return``});c.push(n)}Zt(``+[s.join(` `),...c.map(e=>e.join(` `))].join(`
|
|
59
|
-
`),i||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function Gt(e,t,n,r){return async()=>{let i=e.schedule;if(!i?.enabled)return[];let a=i.formats||[e.defaultExportFormat||`pdf`],o=[];for(let r of a){let i=await Ut(e,{dataSource:t,resource:n,format:r});o.push(i)}return r(e,i),o}}function Kt(e){return{name:e.name,header:e.label||e.name}}function qt(e,t){return e==null?``:typeof e==`number`&&t?e.toLocaleString(`en-US`,Jt(t)):Xt(String(e))}function Jt(e){if(e.includes(`%`))return{style:`percent`,minimumFractionDigits:0};let t=(e.match(/0/g)||[]).length;return{minimumFractionDigits:Math.max(0,t-1),maximumFractionDigits:Math.max(0,t-1)}}function Yt(e){let t=``,n=e;for(;n>=0;)t=String.fromCharCode(n%26+65)+t,n=Math.floor(n/26)-1;return t}function Xt(e){if(e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`'${e}`}return e}function Zt(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)}var Qt=t({JoinedBlocksEditor:()=>yt,JoinedReportRenderer:()=>qe,LegacyReportRenderer:()=>fe,MatrixRenderer:()=>Ue,ReportBuilder:()=>ft,ReportConfigPanel:()=>Ht,ReportRenderer:()=>Ye,ReportViewer:()=>ut,ScheduleConfig:()=>dt,SpecReportGrid:()=>Re,aggregateRows:()=>Y,bucketDate:()=>pe,buildAggregateQuery:()=>Ce,buildDrillAction:()=>Ae,collectFields:()=>Se,columnKey:()=>q,createDrillHandler:()=>Me,createScheduleTrigger:()=>Gt,exportAsCSV:()=>Xe,exportAsExcel:()=>et,exportAsHTML:()=>Qe,exportAsJSON:()=>Ze,exportAsPDF:()=>$e,exportExcelWithFormulas:()=>Wt,exportReport:()=>tt,exportWithLiveData:()=>Ut,formatValue:()=>ot,groupAndAggregate:()=>me,groupingValue:()=>J,isDrillAction:()=>je,mergeFilters:()=>X,pivotRows:()=>he,registerDrillHandler:()=>Ne,useReportData:()=>Te,validateJoinedBlocks:()=>bt});s.register(`report`,Ye,{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`}]}),s.register(`spec-report`,Ye,{namespace:`report`,label:`Spec Report`,category:`Report`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`},{name:`type`,type:`string`,label:`Report Type`}]}),s.register(`report-viewer`,ut,{namespace:`report`,label:`Report Viewer`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Report Definition`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`}]}),s.register(`report-builder`,ft,{namespace:`report`,label:`Report Builder`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Initial Report`}]});export{Qt as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{g as n,r}from"./vendor-react-CIpZOxG3.js";import{_ as i,m as a,r as o}from"./vendor-objectstack-CwZ3saTl.js";import{H as s,M as c,V as l,at as u,ot as d,r as f,ut as p}from"./framework-ClI3DbWX.js";import{$o as m,N as h,Qo as g,Zo as _}from"./ui-components-ZN8XdmwJ.js";import{n as v}from"./vendor-ui-utils-D3GsyZyi.js";import{a as y}from"./plugin-grid-DtceFt_J.js";var b=e(n(),1),x=r(),S=10080*60*1e3;function C(e){let t=e.flatMap(e=>(e.items||[]).flatMap(e=>[e.startDate,e.endDate])),n=Math.min(...t.map(e=>new Date(e).getTime())),r=Math.max(...t.map(e=>new Date(e).getTime()));return{minDate:new Date(n).toISOString().split(`T`)[0],maxDate:new Date(r).toISOString().split(`T`)[0]}}function w(e,t,n,r){let i=new Date(e).getTime(),a=new Date(t).getTime(),o=new Date(n).getTime(),s=new Date(r).getTime()-o,c=i-o,l=a-i;return{start:c/s*100,width:l/s*100}}function T(e,t){let n=new Date(e);return t===`short`?n.toLocaleDateString():t===`long`?n.toLocaleDateString(`en-US`,{year:`numeric`,month:`long`,day:`numeric`}):n.toISOString().split(`T`)[0]}function E({label:e,color:t}){let n=t?{backgroundColor:`${t}22`,color:t,borderColor:`${t}55`}:void 0;return(0,x.jsx)(`span`,{className:_(`inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium`,!t&&`bg-muted text-muted-foreground border-transparent`),style:n,children:e})}function D(e){let t=[];for(let n of e){let e=n.group==null?``:String(n.group),r=t[t.length-1];r&&r.key===e?r.items.push(n):t.push({key:e,items:[n]})}return t}var O=({schema:e,className:t,...n})=>{let{variant:r=`vertical`,items:i=[],dateFormat:a=`short`,onItemClick:o}=e;if(r===`vertical`){let e=D(i),r=e.some(e=>e.key!==``),s=(e,t)=>{let n=e.color?{backgroundColor:`${e.color}33`,borderColor:e.color}:void 0,r=e.time?T(e.time,a):e.startDate?T(e.startDate,a):``,i=e.endDate&&e.endDate!==e.startDate?T(e.endDate,a):``,s=Array.isArray(e.meta)?e.meta:[];return(0,x.jsxs)(I,{density:`compact`,className:_(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,x.jsx)(R,{variant:e.color?`default`:e.variant||`default`,style:n,children:e.icon&&(0,x.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,x.jsxs)(z,{children:[(r||i)&&(0,x.jsxs)(V,{dateTime:e.time||e.startDate,className:`!mb-1 text-xs`,children:[r,i&&(0,x.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[` → `,i]})]}),e.title&&(0,x.jsx)(B,{className:`text-sm sm:text-base mb-1`,children:e.title}),s.length>0&&(0,x.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1 mb-1`,children:s.map(e=>(0,x.jsx)(E,{label:e.label,color:e.color},e.key))}),e.description&&(0,x.jsx)(H,{className:`text-sm text-muted-foreground line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&g(e.content)]})]},t)};return r?(0,x.jsx)(`div`,{className:_(`px-4 sm:px-6 py-2`,t),...n,children:e.map((e,t)=>(0,x.jsxs)(`section`,{className:`mb-4`,children:[(0,x.jsxs)(`header`,{className:`sticky top-0 z-10 -mx-4 sm:-mx-6 px-4 sm:px-6 py-1.5 backdrop-blur bg-background/90 text-xs font-semibold uppercase tracking-wide text-muted-foreground border-b`,children:[(0,x.jsx)(`span`,{children:e.key}),(0,x.jsx)(`span`,{className:`ml-2 text-muted-foreground/60 font-normal normal-case`,children:e.items.length})]}),(0,x.jsx)(P,{className:`mt-3`,children:e.items.map((e,n)=>s(e,`${t}-${n}`))})]},`${e.key}-${t}`))}):(0,x.jsx)(P,{className:t,...n,children:i.map((e,t)=>s(e,t))})}if(r===`horizontal`)return(0,x.jsx)(U,{className:_(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:i.map((e,t)=>(0,x.jsxs)(W,{className:_(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,x.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,x.jsx)(R,{variant:e.variant||`default`,children:e.icon&&(0,x.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,x.jsxs)(`div`,{className:`mt-4 text-center`,children:[e.time&&(0,x.jsx)(V,{dateTime:e.time,children:T(e.time,a)}),e.title&&(0,x.jsx)(B,{children:e.title}),e.description&&(0,x.jsx)(H,{className:`text-center line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&g(e.content)]})]}),t<i.length-1&&(0,x.jsx)(`div`,{className:`absolute left-full w-16 border-t-2 border-gray-200 top-3`})]},t))});if(r===`gantt`){let r=C(i),s=e.minDate||r.minDate,c=e.maxDate||r.maxDate,l=e.timeScale||`month`,u=(()=>{let e=[],t=new Date(s),n=new Date(c);if(l===`month`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`})),r.setMonth(r.getMonth()+1)}else if(l===`week`){let r=new Date(t);for(;r<=n;)e.push(`Week ${Math.ceil((r.getTime()-t.getTime())/S)+1}`),r.setDate(r.getDate()+7)}else if(l===`day`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})),r.setDate(r.getDate()+1)}return e})();return(0,x.jsxs)(G,{className:_(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:[(0,x.jsxs)(K,{children:[(0,x.jsx)(q,{className:`flex items-center px-2 sm:px-4 py-2 sm:py-3`,children:(0,x.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:e.rowLabel||`Items`})}),(0,x.jsx)(J,{children:(0,x.jsx)(`div`,{className:`flex h-full`,children:u.map((e,t)=>(0,x.jsx)(`div`,{className:`flex-1 px-1 sm:px-2 py-2 sm:py-3 border-r text-xs font-medium text-center`,children:e},t))})})]}),(0,x.jsx)(`div`,{children:(0,x.jsxs)(`div`,{className:`flex`,children:[(0,x.jsx)(q,{children:i.map((e,t)=>(0,x.jsx)(Y,{children:(0,x.jsx)(X,{title:e.label,className:`truncate`,children:e.label})},t))}),(0,x.jsx)(J,{className:`relative`,children:i.map((e,t)=>(0,x.jsx)(Y,{className:`relative`,children:(e.items||[]).map((n,r)=>{let i=w(n.startDate,n.endDate,s,c);return(0,x.jsx)(Z,{start:i.start,width:i.width,variant:n.variant||`default`,onClick:()=>o?.(n,e,t,r),title:`${n.title||``}\n${T(n.startDate,a)} - ${T(n.endDate,a)}`,children:(0,x.jsx)(Q,{children:n.title})},r)})},t))})]})})]})}return null};p.register(`timeline`,O,{namespace:`plugin-timeline`,label:`Timeline`,category:`data-display`,inputs:[{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],label:`Timeline Variant`,defaultValue:`vertical`},{name:`items`,type:`array`,label:`Timeline Items`,description:`For vertical/horizontal: Array of { time, title, description, variant, icon, content }. For gantt: Array of { label, items: [{ title, startDate, endDate, variant }] }`},{name:`dateFormat`,type:`enum`,enum:[`short`,`long`,`iso`],label:`Date Format`,defaultValue:`short`},{name:`timeScale`,type:`enum`,enum:[`day`,`week`,`month`],label:`Time Scale (Gantt only)`,defaultValue:`month`},{name:`rowLabel`,type:`string`,label:`Row Label (Gantt only)`,defaultValue:`Items`},{name:`minDate`,type:`string`,label:`Min Date (Gantt only)`,description:`Override auto-calculated min date (YYYY-MM-DD)`},{name:`maxDate`,type:`string`,label:`Max Date (Gantt only)`,description:`Override auto-calculated max date (YYYY-MM-DD)`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{variant:`vertical`,dateFormat:`short`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`,icon:`🚀`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`,icon:`🎨`},{time:`2024-03-15`,title:`Beta Release`,description:`Released beta version to testers`,variant:`warning`,icon:`⚡`},{time:`2024-04-01`,title:`Launch`,description:`Official product launch`,variant:`success`,icon:`🎉`}]},examples:{vertical:{variant:`vertical`,dateFormat:`long`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`}]},horizontal:{variant:`horizontal`,dateFormat:`short`,items:[{time:`2024-01-01`,title:`Q1`,description:`First quarter`,variant:`default`},{time:`2024-04-01`,title:`Q2`,description:`Second quarter`,variant:`info`},{time:`2024-07-01`,title:`Q3`,description:`Third quarter`,variant:`warning`},{time:`2024-10-01`,title:`Q4`,description:`Fourth quarter`,variant:`success`}]},gantt:{variant:`gantt`,dateFormat:`short`,timeScale:`month`,rowLabel:`Projects`,items:[{label:`Backend Development`,items:[{title:`API Design`,startDate:`2024-01-01`,endDate:`2024-01-31`,variant:`success`},{title:`Implementation`,startDate:`2024-02-01`,endDate:`2024-03-31`,variant:`info`}]},{label:`Frontend Development`,items:[{title:`UI Design`,startDate:`2024-01-15`,endDate:`2024-02-15`,variant:`warning`},{title:`Component Dev`,startDate:`2024-02-15`,endDate:`2024-04-15`,variant:`default`}]},{label:`Testing`,items:[{title:`QA Phase`,startDate:`2024-03-01`,endDate:`2024-04-30`,variant:`danger`}]}]}}});var k={"timeline.bucket.overdue":`Overdue`,"timeline.bucket.today":`Today`,"timeline.bucket.tomorrow":`Tomorrow`,"timeline.bucket.thisWeek":`This week`,"timeline.bucket.nextWeek":`Next week`,"timeline.bucket.later":`Later`,"timeline.bucket.noDate":`No date`,"timeline.bucket.unassigned":`Unassigned`,"timeline.relative.today":`Today`,"timeline.relative.tomorrow":`Tomorrow`,"timeline.relative.yesterday":`Yesterday`,"timeline.relative.inDays":`In {{n}} days`,"timeline.relative.daysAgo":`{{n}} days ago`},A=`timeline.bucket.today`;function j(e,t){let n=k[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}function ee(){try{let e=f();return e.t(A)===A?{t:j}:{t:e.t}}catch{return{t:j}}}function te(){try{return m()}catch{return{fieldOptionLabel:(e,t,n,r)=>r,translateOptions:(e,t,n)=>n,fieldLabel:(e,t,n)=>n}}}var ne=a({mapping:a({title:i().optional(),date:i().optional(),description:i().optional(),variant:i().optional()}).optional(),objectName:i().optional(),titleField:i().optional(),dateField:i().optional(),startDateField:i().optional(),endDateField:i().optional(),descriptionField:i().optional(),groupByField:i().optional(),colorField:i().optional(),scale:o([`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional()}),M=({schema:e,dataSource:t,className:n,onRowClick:r,onItemClick:i,...a})=>{let[o,s]=(0,b.useState)([]),[f,p]=(0,b.useState)(()=>{let t=Array.isArray(e.items)&&e.items.length>0,n=Array.isArray(a.data)&&a.data.length>0;return!t&&!n&&!!e.objectName}),[m,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(0),[S,C]=(0,b.useState)(null),w=e.timeline;(0,b.useEffect)(()=>{let t=ne.safeParse(e);t.success||console.warn(`[ObjectTimeline] Invalid timeline configuration:`,t.error.format())},[e]);let T=l(e.bind);(0,b.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||typeof t.getObjectSchema!=`function`||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&C(r)}catch(e){console.warn(`Failed to fetch object def for ObjectTimeline`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,b.useEffect)(()=>{e.objectName&&!T&&!e.items&&!a.data?(async()=>{if(!t||typeof t.find!=`function`||!e.objectName){p(!1);return}p(!0);try{let n=u(S?.fields);s(d(await t.find(e.objectName,{options:{$top:100},...n.length>0?{$expand:n}:{}})))}catch(e){console.error(e),g(e)}finally{p(!1)}})():p(!1)},[e.objectName,t,T,e.items,a.data,_,S]);let E=a.data||T||o,{t:D}=ee(),{fieldOptionLabel:k}=te(),A=w?.titleField??e.mapping?.title??e.titleField??`name`,j=w?.startDateField??e.mapping?.date??e.startDateField??e.dateField??`date`,M=w?.endDateField??e.endDateField??j,N=e.mapping?.description??e.descriptionField??`description`,P=e.mapping?.variant??`variant`,F=w?.groupByField??e.groupByField,I=w?.colorField??e.colorField,L=(0,b.useMemo)(()=>{if(e.items)return e.items;if(!E||!Array.isArray(E))return[];let t=S?.fields??{},n=e.objectName||``,r=e=>{if(!e||!t[e]?.options)return{};let n={};for(let r of t[e].options)r&&r.value!=null&&(n[String(r.value)]=r);return n},i=r(I),a=Array.isArray(w?.metaFields)?w.metaFields.filter(e=>typeof e==`string`&&e):[`status`,`priority`].filter(e=>t[e]),o={};for(let e of a)o[e]=r(e);let s=e=>{if(e==null||e===``)return;let t=i[String(e)];if(t?.color)return String(t.color);let n=String(e);if(/^#([0-9a-f]{3}){1,2}$/i.test(n)||n.startsWith(`rgb`)||n.startsWith(`hsl`))return n},c=(e,t,r)=>{if(t==null||t===``)return null;let i=r[String(t)];return{label:i?.label?k(n,e,String(t),i.label):String(t),color:i?.color}},l=E.map(e=>{let t=e[j],r=e[M],i=I?e[I]:void 0,l=F?e[F]:void 0,u=[];if(n)for(let t of a){let n=c(t,e[t],o[t]||{});n&&u.push({key:t,label:n.label,color:n.color})}return{title:e[A],time:t,startDate:t,endDate:r,description:e[N],variant:e[P]||`default`,color:s(i),group:l,meta:u,_data:e}});l.sort((e,t)=>(e.startDate?new Date(e.startDate).getTime():1/0)-(t.startDate?new Date(t.startDate).getTime():1/0));let u=new Date,d=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),f=d(u),p=864e5,m=f-(u.getDay()+6)%7*p+7*p,h=m+7*p,g=e=>{if(!e)return D(`timeline.bucket.noDate`);let t=d(new Date(e));return Number.isNaN(t)?D(`timeline.bucket.noDate`):t<f?D(`timeline.bucket.overdue`):t===f?D(`timeline.bucket.today`):t===f+p?D(`timeline.bucket.tomorrow`):D(t<m?`timeline.bucket.thisWeek`:t<h?`timeline.bucket.nextWeek`:`timeline.bucket.later`)};if(F&&!l.every(e=>e.group==null||e.group===``)){let e=r(F);return l.map(t=>{let n=c(F,t.group,e);return{...t,group:n?n.label:t.group!=null&&t.group!==``?String(t.group):D(`timeline.bucket.unassigned`)}})}return l.map(e=>({...e,group:g(e.startDate)}))},[e.items,E,S,e.objectName,A,j,M,N,P,I,F,D,k]),{ref:R,isRefreshing:z,pullDistance:B}=y({onRefresh:(0,b.useCallback)(async()=>{v(e=>e+1)},[]),enabled:!!e.objectName&&!!t}),V=c({navigation:e.navigation,objectName:e.objectName,onRowClick:r??i}),H=w?.scale??e.scale,U={...e,items:L||[],className:n||e.className,...H?{timeScale:H}:{},onItemClick:e=>{let t=e._data||e;V.handleClick(t),i?.(t)}};return m?(0,x.jsxs)(`div`,{className:`p-4 text-destructive`,"data-testid":`timeline-error`,role:`alert`,children:[`Error loading timeline: `,m.message]}):f&&(!L||L.length===0)?(0,x.jsxs)(`div`,{className:`flex flex-col h-full min-h-[200px] p-4 gap-3`,"data-testid":`timeline-loading`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,x.jsx)(`span`,{className:`sr-only`,children:`Loading timeline…`}),[0,1,2,3].map(e=>(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,style:{opacity:Math.max(.3,1-e*.18)},children:[(0,x.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-muted/70 animate-pulse mt-1.5 shrink-0`}),(0,x.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,x.jsx)(`div`,{className:`h-4 w-1/3 rounded bg-muted/70 animate-pulse`}),(0,x.jsx)(`div`,{className:`h-3 w-2/3 rounded bg-muted/50 animate-pulse`})]})]},e))]}):(0,x.jsxs)(`div`,{ref:R,className:`relative overflow-auto h-full min-w-0`,children:[B>0&&(0,x.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:B},children:z?`Refreshing…`:`Pull to refresh`}),(0,x.jsx)(O,{schema:U}),V.isOverlay&&(0,x.jsx)(h,{...V,title:`Timeline Item`,children:e=>(0,x.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,x.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},N=t({ObjectTimeline:()=>M,ObjectTimelineRenderer:()=>$,Timeline:()=>P,TimelineContent:()=>z,TimelineDescription:()=>H,TimelineGantt:()=>G,TimelineGanttBar:()=>Z,TimelineGanttBarContent:()=>Q,TimelineGanttGrid:()=>J,TimelineGanttHeader:()=>K,TimelineGanttLabel:()=>X,TimelineGanttRow:()=>Y,TimelineGanttRowLabels:()=>q,TimelineHorizontal:()=>U,TimelineHorizontalItem:()=>W,TimelineItem:()=>I,TimelineMarker:()=>R,TimelineRenderer:()=>O,TimelineTime:()=>V,TimelineTitle:()=>B,timelineItemVariants:()=>F,timelineMarkerVariants:()=>L}),P=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`ol`,{ref:n,className:_(`relative ml-3 border-l border-gray-200`,e),...t}));P.displayName=`Timeline`;var F=v(`ml-6`,{variants:{density:{default:`mb-10`,compact:`mb-3`,comfortable:`mb-6`}},defaultVariants:{density:`default`}}),I=b.forwardRef(({className:e,density:t,...n},r)=>(0,x.jsx)(`li`,{ref:r,className:_(F({density:t}),e),...n}));I.displayName=`TimelineItem`;var L=v(`absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center`,{variants:{variant:{default:`bg-blue-200 border-blue-400`,success:`bg-emerald-200 border-emerald-500`,warning:`bg-amber-200 border-amber-500`,danger:`bg-red-200 border-red-500`,info:`bg-purple-200 border-purple-500`,todo:`bg-slate-200 border-slate-400`,"in-progress":`bg-blue-200 border-blue-500`,done:`bg-emerald-200 border-emerald-500`}},defaultVariants:{variant:`default`}}),R=b.forwardRef(({className:e,variant:t=`default`,...n},r)=>(0,x.jsx)(`div`,{ref:r,className:_(L({variant:t}),e),...n}));R.displayName=`TimelineMarker`;var z=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:e,...t}));z.displayName=`TimelineContent`;var B=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`h3`,{ref:n,className:_(`font-semibold text-lg mb-1`,e),...t}));B.displayName=`TimelineTitle`;var V=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`time`,{ref:n,className:_(`text-sm font-normal text-gray-500 mb-2 block`,e),...t}));V.displayName=`TimelineTime`;var H=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`p`,{ref:n,className:_(`text-base text-gray-700`,e),...t}));H.displayName=`TimelineDescription`;var U=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:_(`relative flex overflow-x-auto py-8`,e),...t}));U.displayName=`TimelineHorizontal`;var W=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:_(`shrink-0 w-64 relative`,e),...t}));W.displayName=`TimelineHorizontalItem`;var G=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:_(`relative w-full border rounded-lg overflow-hidden`,e),...t}));G.displayName=`TimelineGantt`;var K=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:_(`flex border-b bg-gray-50`,e),...t}));K.displayName=`TimelineGanttHeader`;var q=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:_(`w-48 border-r bg-white`,e),...t}));q.displayName=`TimelineGanttRowLabels`;var J=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:_(`flex-1 overflow-x-auto`,e),...t}));J.displayName=`TimelineGanttGrid`;var Y=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:_(`flex items-center border-b min-h-12`,e),...t}));Y.displayName=`TimelineGanttRow`;var X=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:_(`px-4 py-2 font-medium text-sm truncate`,e),...t}));X.displayName=`TimelineGanttLabel`;var Z=b.forwardRef(({className:e,start:t=0,width:n=100,variant:r=`default`,...i},a)=>(0,x.jsx)(`div`,{ref:a,className:_(`absolute h-8 rounded-md transition-colors cursor-pointer`,{default:`bg-blue-500 hover:bg-blue-600`,success:`bg-green-500 hover:bg-green-600`,warning:`bg-yellow-500 hover:bg-yellow-600`,danger:`bg-red-500 hover:bg-red-600`,info:`bg-purple-500 hover:bg-purple-600`}[r],e),style:{left:`${t}%`,width:`${n}%`},...i}));Z.displayName=`TimelineGanttBar`;var Q=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:_(`px-2 py-1 text-white text-xs font-medium truncate`,e),...t}));Q.displayName=`TimelineGanttBarContent`;var $=({schema:e,...t})=>{let{dataSource:n}=s()||{};return(0,x.jsx)(M,{schema:e,dataSource:n,...t})};p.register(`object-timeline`,$,{namespace:`plugin-timeline`,label:`Object Timeline`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]}),p.register(`timeline`,$,{namespace:`view`,label:`Timeline View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]});export{N as t};
|