react-semaphor 0.1.362 → 0.1.363

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/chunks/{calendar-preferences-dialog-GwtaSN53.js → calendar-preferences-dialog-CCWsI9hQ.js} +1 -1
  2. package/dist/chunks/{calendar-preferences-dialog-BEKBpwMY.js → calendar-preferences-dialog-DCh8LMFL.js} +1 -1
  3. package/dist/chunks/{dashboard-briefing-launcher-D6gGO5wz.js → dashboard-briefing-launcher-BPJcXz59.js} +3 -3
  4. package/dist/chunks/{dashboard-briefing-launcher-DYxd4856.js → dashboard-briefing-launcher-BsWvqsgi.js} +1 -1
  5. package/dist/chunks/{dashboard-controls-C_rExqPw.js → dashboard-controls-7uVDGJgT.js} +1 -1
  6. package/dist/chunks/{dashboard-controls-B4u5RsKl.js → dashboard-controls-Ty36m44I.js} +3 -3
  7. package/dist/chunks/{dashboard-json-CPGTofhm.js → dashboard-json-COqIDBU7.js} +1 -1
  8. package/dist/chunks/{dashboard-json-BWWU6a7V.js → dashboard-json-CVlvQrWF.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-D_jZ-iix.js → edit-dashboard-visual-4wuOgtnP.js} +1 -1
  10. package/dist/chunks/{edit-dashboard-visual-biMO829J.js → edit-dashboard-visual-yfR8agWj.js} +3 -3
  11. package/dist/chunks/{index-Db1XVmfU.js → index-B0Qkb2b3.js} +2 -2
  12. package/dist/chunks/{index-CJ2IEuKz.js → index-DEvjcO2T.js} +11 -5
  13. package/dist/chunks/{resource-management-panel-B9-5VHYe.js → resource-management-panel-BWHj4Red.js} +2 -2
  14. package/dist/chunks/{resource-management-panel-Bam-yvnt.js → resource-management-panel-DO4VOGlS.js} +1 -1
  15. package/dist/chunks/{use-create-flow-overlay-state-DAvEqaJV.js → use-create-flow-overlay-state-CtOJ3KgD.js} +2 -2
  16. package/dist/chunks/{use-create-flow-overlay-state-dhxgdLYo.js → use-create-flow-overlay-state-pwbt_yFw.js} +1 -1
  17. package/dist/chunks/{use-visual-utils-CAKdXsr5.js → use-visual-utils-BQBJEW6P.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-FoHNPwpu.js → use-visual-utils-CzxWsSJL.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/data-app-builder/index.cjs +1 -1
  22. package/dist/data-app-builder/index.js +1 -1
  23. package/dist/data-app-sdk/index.cjs +1 -1
  24. package/dist/data-app-sdk/index.js +35 -34
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +5 -5
  27. package/dist/surfboard/index.cjs +1 -1
  28. package/dist/surfboard/index.js +2 -2
  29. package/dist/types/data-app-sdk.d.ts +1 -1
  30. package/package.json +1 -1
@@ -752,7 +752,7 @@ prismjs/prism.js:
752
752
  <\/script>
753
753
  <script type="module" crossorigin="anonymous" src="${tT(e.runtime.entryUrl)}"><\/script>
754
754
  </body>
755
- </html>`}function Hwe({dataApp:e,onBack:t}){var d;const{authToken:n,tokenProps:r}=Ct(),[s,o]=v.useState(null),i=Bn({queryKey:["published-data-app-runtime",r.apiServiceUrl,n==null?void 0:n.accessToken,e.id],queryFn:async()=>m.getRequest(`${r.apiServiceUrl}/data-apps/${e.id}/runtime`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)&&!!e.id});v.useEffect(()=>{function f(h){const p=h.data;(p==null?void 0:p.source)!=="semaphor-data-app-runtime"||p.type!=="runtime-error"||o(p.message||"Published Data App failed to load.")}return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[]),v.useEffect(()=>{o(null)},[e.id]);const a=(d=i.data)==null?void 0:d.dataApp,c=a==null?void 0:a.runtime,u=v.useMemo(()=>!a||!c?"":Vwe({title:a.title||e.title,apiBaseUrl:r.apiServiceUrl,dataApp:a,runtime:c}),[e.title,c,a,r.apiServiceUrl]);return l.jsxs("div",{className:"flex h-full grow flex-col bg-background text-foreground",children:[l.jsxs("header",{className:"flex h-14 shrink-0 items-center justify-between border-b border-border/60 px-4",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[l.jsx(m.Button,{"aria-label":"Back to Analytics workspace",className:"h-8 w-8 px-0",onClick:t,size:"xs",variant:"ghost",children:l.jsx(hv,{className:"h-4 w-4"})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data App"}),l.jsx("h1",{className:"truncate text-[14px] font-semibold",children:(a==null?void 0:a.title)||e.title})]})]}),c?l.jsxs("div",{className:"rounded-md border border-border px-2 py-1 text-[11px] text-muted-foreground",children:["v",c.version]}):null]}),i.isLoading?l.jsx("div",{className:"flex flex-1 items-center justify-center",children:l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(m.LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Loading Data App..."]})}):i.isError?l.jsx("div",{className:"flex flex-1 items-center justify-center px-6",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(mh,{className:"h-5 w-5 text-destructive"}),l.jsx("h2",{className:"text-[13px] font-medium",children:"Couldn't load Data App"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"The published runtime could not be fetched. Please try again."})]})}):c?l.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[s?l.jsx("div",{className:"border-b border-destructive/30 bg-destructive/10 px-4 py-2 text-[12px] text-destructive",children:s}):null,l.jsx("iframe",{className:"min-h-0 flex-1 border-0",sandbox:"allow-forms allow-modals allow-popups allow-scripts",srcDoc:u,title:(a==null?void 0:a.title)||e.title})]}):l.jsx("div",{className:"flex flex-1 items-center justify-center px-6",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(mh,{className:"h-5 w-5 text-muted-foreground/60"}),l.jsx("h2",{className:"text-[13px] font-medium",children:"No published version yet"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Publish this Data App before opening it from the Analytics workspace."})]})})]})}function LK(e){var t;if(e&&e.type!=="organization"&&e.type==="tenant")return((t=e.role)==null?void 0:t.toUpperCase())==="VIEWER"?{showFilters:!1}:void 0}function Uwe(e){var t;return e?e.type==="organization"?!0:e.type==="tenant"?((t=e.role)==null?void 0:t.toUpperCase())!=="VIEWER":!1:!1}function qwe(e){var t;return e?e.type==="organization"?!0:e.type==="tenant"?((t=e.role)==null?void 0:t.toUpperCase())!=="VIEWER":!1:!1}function Wwe(e){return!!e}function $K(e){var t;return e?e.type==="organization"?!0:e.type==="tenant"?((t=e.role)==null?void 0:t.toUpperCase())!=="VIEWER":!1:!1}function Ywe(e){var t;return e?e.type==="organization"?!0:e.type==="tenant"?((t=e.role)==null?void 0:t.toUpperCase())!=="VIEWER":!1:!1}function Gwe(e){var t;return e?e.type==="organization"?!0:e.type==="tenant"?((t=e.role)==null?void 0:t.toUpperCase())==="POWER_USER":!1:!1}function Kwe({onDashboardSelect:e}){var Ae,ae,me,Ce;const{authToken:t,tokenProps:n}=Ct(),r=((ae=(Ae=n.config)==null?void 0:Ae.projectFeatures)==null?void 0:ae.features.dataAppBuilder)!==!1,[s,o]=v.useState(!1),[i,a]=v.useState(!1),[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,p]=v.useState(!1),[g,b]=v.useState(null),[x,y]=v.useState(null),[S,w]=v.useState(null),[C,N]=v.useState(null),[k,j]=v.useState(""),{data:_}=DG(),T=((me=_==null?void 0:_.preference)==null?void 0:me.defaultDashboardId)||null,E=hs(se=>se.actions.selectDashboard),{currentUser:I,userContext:D}=ua(),A=((Ce=D==null?void 0:D.permissions)==null?void 0:Ce.canCreateDashboard)??$K(I),{onCreateSuccess:P}=cG({onDashboardSelect:e}),{resources:R,isLoading:H,isError:z,createResourceAsync:U,updateResource:W,deleteResource:O,duplicateResource:Z,isCreating:Y,isUpdating:M,isDeleting:G,isDuplicating:L,refetch:$}=lG(()=>{p(!1),b(null)},se=>{o(!1),P(se,$)}),{startUpdating:B,stopUpdating:V,isUpdating:F}=aG(),q=se=>{const re=R.find(J=>J.id===se);if(re){if(re.kind==="data_app"){N(re);return}E(re),e==null||e(se)}},K=se=>{const re=x0e(se);return U({title:se.title,description:se.description,isPrivate:!1,...re?{template:re}:{}})},X=se=>{b(se),p(!0)},ee=()=>{g&&O(g.id)},de=se=>{y(se),Z(se,{onSettled:()=>y(null)})},fe=(se,re,J)=>{var we;const he=Object.fromEntries(Object.entries(re).filter(([,ne])=>ne!==void 0));if(Object.keys(he).length===0){(we=J==null?void 0:J.onSuccess)==null||we.call(J);return}const te=Object.keys(he),Se=te.length===1?te[0]:void 0;B(se,Se),W({resourceId:se,data:he},{onSuccess:()=>{var ne;V(se,Se),(ne=J==null?void 0:J.onSuccess)==null||ne.call(J)},onError:()=>{var ne;V(se,Se),(ne=J==null?void 0:J.onError)==null||ne.call(J)}})},ge=se=>{f(se),u(!0)},ve=se=>new Date(se).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),ie=R.length>5,be=ie?k.trim().toLowerCase():"",oe=v.useMemo(()=>be?R.filter(se=>{var he,te;const re=((he=se.title)==null?void 0:he.toLowerCase())??"",J=((te=se.description)==null?void 0:te.toLowerCase())??"";return re.includes(be)||J.includes(be)}):R,[be,R]);return i&&r?l.jsx(OK,{apiServiceUrl:n.apiServiceUrl,onBack:()=>a(!1),projectId:n.project_id||"embedded-project",projectName:"Analytics workspace"}):C?l.jsx(Hwe,{dataApp:C,onBack:()=>N(null)}):t?z?l.jsx("div",{className:"flex h-full grow items-center justify-center px-6",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(mh,{className:"h-6 w-6 text-destructive"}),l.jsx("h2",{className:"text-[13px] font-medium text-foreground",children:"Couldn't load dashboards"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Unable to fetch your dashboards. Please try again."}),l.jsx(m.Button,{size:"xs",variant:"outline",className:"mt-2",onClick:()=>window.location.reload(),children:"Retry"})]})}):l.jsxs(Zwe,{children:[l.jsx("div",{className:"border-b border-border/60 bg-background px-6 py-5 lg:px-8",children:l.jsx("div",{className:"mx-auto max-w-7xl",children:l.jsxs("div",{className:"flex items-start justify-between gap-6",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("h1",{className:"text-[15px] font-semibold tracking-tight text-foreground",children:"Analytics workspace"}),l.jsxs("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:["Pick an existing dashboard or app, or create a new one.",!H&&R.length>0?l.jsxs("span",{className:"ml-1.5",children:["· ",R.length," item",R.length!==1?"s":""]}):null]})]}),A&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[r?l.jsxs(m.Button,{size:"xs",variant:"outline",onClick:()=>a(!0),children:[l.jsx(yr,{className:"h-3.5 w-3.5"}),"New app"]}):null,l.jsxs(m.Button,{size:"xs",onClick:()=>o(!0),children:[l.jsx(yr,{className:"h-3.5 w-3.5"}),"New dashboard"]})]})]})})}),l.jsx(Xwe,{children:l.jsx("div",{className:"mx-auto max-w-7xl",children:H?l.jsx(Qwe,{}):R.length===0?l.jsx("div",{className:"flex items-center justify-center py-20",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(Vm,{className:"h-6 w-6 text-muted-foreground/60"}),l.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"No dashboards yet"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:A?"Create your first dashboard to get started.":"No dashboards have been shared with you yet."}),A&&l.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[r?l.jsxs(m.Button,{size:"xs",variant:"outline",onClick:()=>a(!0),children:[l.jsx(yr,{className:"h-3.5 w-3.5"}),"Create app"]}):null,l.jsxs(m.Button,{size:"xs",onClick:()=>o(!0),children:[l.jsx(yr,{className:"h-3.5 w-3.5"}),"Create dashboard"]})]})]})}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[l.jsx("h2",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Your dashboards"}),ie&&l.jsxs("div",{className:"relative w-full sm:w-72",children:[l.jsx(Xs,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),l.jsx(m.Input,{size:"xs",placeholder:"Search dashboards…",value:k,onChange:se=>j(se.target.value),className:"pl-8"})]})]}),oe.length===0?l.jsx("div",{className:"flex items-center justify-center py-20 text-center",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-1",children:[l.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"No dashboards found"}),l.jsxs("p",{className:"text-[12px] text-muted-foreground",children:["No dashboards match “",k.trim(),"”."]})]})}):l.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:oe.map(se=>l.jsx(Jwe,{dashboard:se,icon:se.kind==="data_app"?l.jsx(Fme,{className:"h-3.5 w-3.5"}):void 0,eyebrow:se.kind==="data_app"?"Data App":void 0,isDefault:se.kind!=="data_app"&&se.id===T,onView:q,isDeleting:G&&(g==null?void 0:g.id)===se.id,isDuplicating:x===se.id,onEditDetails:w,onDeleteClick:X,onDuplicateDashboard:de,onShareDashboard:ge,formatDate:ve},se.id))})]})})}),l.jsx(Zxe,{open:s,onOpenChange:o,onCreateBlank:K,onAiCreateSuccess:se=>{o(!1),P(se.dashboard,$)},isCreatingBlank:Y}),S&&l.jsx(aK,{open:!!S,resourceLabel:"Dashboard",initialTitle:S.title||"",initialDescription:S.description||"",onClose:()=>w(null),onSave:se=>{fe(S.id,se,{onSuccess:()=>{w(null)}})},isSaving:F(S.id)}),l.jsx(Wc,{open:h,onOpenChange:p,children:l.jsxs(Tl,{children:[l.jsxs(Il,{children:[l.jsx(Ml,{children:"Delete Dashboard?"}),l.jsxs(Al,{children:['Are you sure you want to delete "',g==null?void 0:g.title,'"? This action cannot be undone.']})]}),l.jsxs(Dl,{children:[l.jsx(Fl,{disabled:G,children:"Cancel"}),l.jsx(Rl,{onClick:ee,disabled:G,children:G?l.jsxs(l.Fragment,{children:[l.jsx(m.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Deleting…"]}):"Delete"})]})]})}),d&&c&&l.jsx(iK,{resource:d,resourceType:rs.DASHBOARD,onClose:()=>{u(!1),f(null)}})]}):l.jsx("div",{className:"flex h-full grow items-center justify-center px-6",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(mh,{className:"h-6 w-6 text-muted-foreground/60"}),l.jsx("h2",{className:"text-[13px] font-medium text-foreground",children:"Authentication required"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Please provide authentication to view dashboards."})]})})}function Zwe({children:e}){const t=Hl();return l.jsx("div",{"data-content-type":"dashboard-hub",className:"flex h-full grow flex-col bg-background text-foreground",style:t.dashboardContainerStyle,children:e})}function Xwe({children:e}){const t=Hl();return l.jsx("div",{className:"flex-1 overflow-y-auto bg-muted/20 px-6 py-6 lg:px-8",style:t.dashboardCanvasStyle,children:e})}function Qwe(){return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:l.jsx("h2",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Your dashboards"})}),l.jsx("div",{className:"flex min-h-[280px] items-center justify-center rounded-[6px] border border-dashed border-border/70 bg-background/40",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading dashboards..."})]})})]})}function Jwe(e){const t=Hl();return l.jsx(axe,{...e,style:{...t.cardFrameStyle,...e.style}})}const Qf=m.create()(e=>({panels:{dashboard:{isOpen:!1,container:null},editor:{isOpen:!1,container:null}},fullscreen:null,setPanelOpen:(t,n)=>e(r=>r.panels[t].isOpen===n?r:{panels:{...r.panels,[t]:{...r.panels[t],isOpen:n}},fullscreen:!n&&r.fullscreen===t?null:r.fullscreen}),setFullscreen:t=>e(n=>n.fullscreen===t?n:{fullscreen:t}),setContainer:(t,n)=>e(r=>r.panels[t].container===n?r:{panels:{...r.panels,[t]:{...r.panels[t],container:n}}})})),zK=e=>Qf(t=>t.panels[e]),BK=()=>Qf(e=>e.fullscreen),VK=e=>Qf(t=>t.panels[e].container??null);m.enableMapSet();const cj=m.create()(m.immer((e,t)=>({activeExports:new Map,actions:{addExport:n=>{e(r=>{r.activeExports.set(n.id,{...n,lastUpdatedAt:n.lastUpdatedAt??new Date})})},updateExport:(n,r)=>{e(s=>{const o=s.activeExports.get(n);if(o){const i={...o,...r};r.lastUpdatedAt||(i.lastUpdatedAt=new Date),s.activeExports.set(n,i)}})},removeExport:n=>{e(r=>{r.activeExports.delete(n)})},getInProgressExports:()=>Array.from(t().activeExports.values()).filter(r=>["pending","processing","chunking","compacting"].includes(r.status)),getAllExports:()=>Array.from(t().activeExports.values()).sort((n,r)=>r.startedAt.getTime()-n.startedAt.getTime()),clearCompleted:()=>{e(n=>{for(const[r,s]of n.activeExports)(s.status==="completed"||s.status==="failed")&&n.activeExports.delete(r)})},hasInProgressExports:()=>Array.from(t().activeExports.values()).some(r=>["pending","processing","chunking","compacting"].includes(r.status))}}))),HK=()=>cj(e=>e.actions),e1e=()=>cj(e=>e.activeExports),t1e=()=>cj(e=>Array.from(e.activeExports.values()).filter(n=>["pending","processing","chunking","compacting"].includes(n.status)).length);function UK(){const{tokenProps:e,id:t}=Ct(),n=hs(s=>s.selectedDashboard);return hs(s=>s.showHub)?!1:!!(n!=null&&n.id||t||e!=null&&e.dashboard_id)}function cP({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:s,ErrorComponent:o,onChartElementClicked:i,id:a,authToken:c,currentTheme:u,appearance:d,version:f,customCards:h,showAssistant:p,defaultFilterValues:g,defaultControlValues:b,controlContractOverrides:x,documentInputValues:y,dashboardInputExecutionSnapshot:S,renderMode:w,onFilterValuesChange:C,selectedSheetId:N,eventHandlers:k,type:j="dashboard",cardId:_,dashboardId:T,style:E,...I}){const{placeholders:D,tokenProps:A,id:P}=Ct();hs(Z=>Z.selectedDashboard);const R=m.useDashboardStore(Z=>Z.themeStyle),H=Hl(),z=m.useDashboardStore(Z=>Z.isSessionExpired),{isLoading:U,isError:W}=Ime({customStyle:t,currentTheme:u,onSave:n,onEvent:r,defaultFilterValues:g,defaultControlValues:b,controlContractOverrides:x,dashboardInputExecutionSnapshot:S,onFilterValuesChange:C,selectedSheetId:N,type:j,cardId:_}),O=UK();return c&&!O&&!U?l.jsx(Kwe,{}):U||!c?(r==null||r({type:"info",message:"Loading dashboard"}),s?l.jsx(s,{message:"loading"}):l.jsx("div",{className:"flex items-center gap-3",children:l.jsx(bo,{className:"h-1 w-full dark:h-[2px]"})})):W?(r==null||r({type:"error",message:"Error fetching dashboard"}),o?(console.log("Error fetching dashboard"),l.jsx(o,{})):l.jsx("div",{children:"Error"})):z?(r==null||r({type:"error",message:"Session Expired"}),D!=null&&D.SessionExpired?l.jsx("div",{className:"flex h-full w-full items-center justify-center",children:l.jsx("div",{children:D.SessionExpired})}):l.jsx("div",{className:"flex h-full w-full items-center justify-center",children:l.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[l.jsx(Cg,{children:"Session Expired"}),l.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue"})]})})):l.jsx("div",{className:m.cn("isolate flex grow flex-col",{"h-full":j==="visual"},R==null?void 0:R.dashboardPanel,e),style:{...H.dashboardContainerStyle,...E},"data-role":"semaphor-container",...I})}var qK={exports:{}},wv={},cM={exports:{}};(function(e,t){(function(n,r){r(t)})(m.commonjsGlobal,function(n){function r(V){return function(q,K,X,ee,de,fe,ge){return V(q,K,ge)}}function s(V){return function(q,K,X,ee){if(!q||!K||typeof q!="object"||typeof K!="object")return V(q,K,X,ee);var de=ee.get(q),fe=ee.get(K);if(de&&fe)return de===K&&fe===q;ee.set(q,K),ee.set(K,q);var ge=V(q,K,X,ee);return ee.delete(q),ee.delete(K),ge}}function o(V,F){var q={};for(var K in V)q[K]=V[K];for(var K in F)q[K]=F[K];return q}function i(V){return V.constructor===Object||V.constructor==null}function a(V){return typeof V.then=="function"}function c(V,F){return V===F||V!==V&&F!==F}var u="[object Arguments]",d="[object Boolean]",f="[object Date]",h="[object RegExp]",p="[object Map]",g="[object Number]",b="[object Object]",x="[object Set]",y="[object String]",S=Object.prototype.toString;function w(V){var F=V.areArraysEqual,q=V.areDatesEqual,K=V.areMapsEqual,X=V.areObjectsEqual,ee=V.areRegExpsEqual,de=V.areSetsEqual,fe=V.createIsNestedEqual,ge=fe(ve);function ve(ie,be,oe){if(ie===be)return!0;if(!ie||!be||typeof ie!="object"||typeof be!="object")return ie!==ie&&be!==be;if(i(ie)&&i(be))return X(ie,be,ge,oe);var Ae=Array.isArray(ie),ae=Array.isArray(be);if(Ae||ae)return Ae===ae&&F(ie,be,ge,oe);var me=S.call(ie);return me!==S.call(be)?!1:me===f?q(ie,be,ge,oe):me===h?ee(ie,be,ge,oe):me===p?K(ie,be,ge,oe):me===x?de(ie,be,ge,oe):me===b||me===u?a(ie)||a(be)?!1:X(ie,be,ge,oe):me===d||me===g||me===y?c(ie.valueOf(),be.valueOf()):!1}return ve}function C(V,F,q,K){var X=V.length;if(F.length!==X)return!1;for(;X-- >0;)if(!q(V[X],F[X],X,X,V,F,K))return!1;return!0}var N=s(C);function k(V,F){return c(V.valueOf(),F.valueOf())}function j(V,F,q,K){var X=V.size===F.size;if(!X)return!1;if(!V.size)return!0;var ee={},de=0;return V.forEach(function(fe,ge){if(X){var ve=!1,ie=0;F.forEach(function(be,oe){!ve&&!ee[ie]&&(ve=q(ge,oe,de,ie,V,F,K)&&q(fe,be,ge,oe,V,F,K))&&(ee[ie]=!0),ie++}),de++,X=ve}}),X}var _=s(j),T="_owner",E=Object.prototype.hasOwnProperty;function I(V,F,q,K){var X=Object.keys(V),ee=X.length;if(Object.keys(F).length!==ee)return!1;for(var de;ee-- >0;){if(de=X[ee],de===T){var fe=!!V.$$typeof,ge=!!F.$$typeof;if((fe||ge)&&fe!==ge)return!1}if(!E.call(F,de)||!q(V[de],F[de],de,de,V,F,K))return!1}return!0}var D=s(I);function A(V,F){return V.source===F.source&&V.flags===F.flags}function P(V,F,q,K){var X=V.size===F.size;if(!X)return!1;if(!V.size)return!0;var ee={};return V.forEach(function(de,fe){if(X){var ge=!1,ve=0;F.forEach(function(ie,be){!ge&&!ee[ve]&&(ge=q(de,ie,fe,be,V,F,K))&&(ee[ve]=!0),ve++}),X=ge}}),X}var R=s(P),H=Object.freeze({areArraysEqual:C,areDatesEqual:k,areMapsEqual:j,areObjectsEqual:I,areRegExpsEqual:A,areSetsEqual:P,createIsNestedEqual:r}),z=Object.freeze({areArraysEqual:N,areDatesEqual:k,areMapsEqual:_,areObjectsEqual:D,areRegExpsEqual:A,areSetsEqual:R,createIsNestedEqual:r}),U=w(H);function W(V,F){return U(V,F,void 0)}var O=w(o(H,{createIsNestedEqual:function(){return c}}));function Z(V,F){return O(V,F,void 0)}var Y=w(z);function M(V,F){return Y(V,F,new WeakMap)}var G=w(o(z,{createIsNestedEqual:function(){return c}}));function L(V,F){return G(V,F,new WeakMap)}function $(V){return w(o(H,V(H)))}function B(V){var F=w(o(z,V(z)));return function(q,K,X){return X===void 0&&(X=new WeakMap),F(q,K,X)}}n.circularDeepEqual=M,n.circularShallowEqual=L,n.createCustomCircularEqual=B,n.createCustomEqual=$,n.deepEqual=W,n.sameValueZeroEqual=c,n.shallowEqual=Z,Object.defineProperty(n,"__esModule",{value:!0})})})(cM,cM.exports);var uP=cM.exports;const uj=m.getAugmentedNamespace(m.clsx$1);var Cn={},n1e=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(Cn,"__esModule",{value:!0});Cn.bottom=dP;Cn.childrenEqual=i1e;Cn.cloneLayout=WK;Cn.cloneLayoutItem=Jf;Cn.collides=dj;Cn.compact=GK;Cn.compactItem=KK;Cn.compactType=y1e;Cn.correctBounds=ZK;Cn.fastPositionEqual=a1e;Cn.fastRGLPropsEqual=void 0;Cn.getAllCollisions=XK;Cn.getFirstCollision=Ef;Cn.getLayoutItem=fP;Cn.getStatics=hP;Cn.modifyLayout=YK;Cn.moveElement=Mx;Cn.moveElementAwayFromCollision=dM;Cn.noop=void 0;Cn.perc=c1e;Cn.resizeItemInDirection=m1e;Cn.setTopLeft=b1e;Cn.setTransform=g1e;Cn.sortLayoutItems=yP;Cn.sortLayoutItemsByColRow=nZ;Cn.sortLayoutItemsByRowCol=tZ;Cn.synchronizeLayoutWithChildren=x1e;Cn.validateLayout=rZ;Cn.withLayoutItem=o1e;var I4=uP,Dx=r1e(v);function r1e(e){return e&&e.__esModule?e:{default:e}}const s1e=process.env.NODE_ENV==="production";function dP(e){let t=0,n;for(let r=0,s=e.length;r<s;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function WK(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=Jf(e[n]);return t}function YK(e,t){const n=Array(e.length);for(let r=0,s=e.length;r<s;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function o1e(e,t,n){let r=fP(e,t);return r?(r=n(Jf(r)),e=YK(e,r),[e,r]):[e,null]}function Jf(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function i1e(e,t){return(0,I4.deepEqual)(Dx.default.Children.map(e,n=>n==null?void 0:n.key),Dx.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,I4.deepEqual)(Dx.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),Dx.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}Cn.fastRGLPropsEqual=n1e;function a1e(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function dj(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function GK(e,t,n,r){const s=hP(e),o=yP(e,t),i=Array(e.length);for(let a=0,c=o.length;a<c;a++){let u=Jf(o[a]);u.static||(u=KK(s,u,t,n,o,r),s.push(u)),i[e.indexOf(o[a])]=u,u.moved=!1}return i}const l1e={x:"w",y:"h"};function uM(e,t,n,r){const s=l1e[r];t[r]+=1;const o=e.map(i=>i.i).indexOf(t.i);for(let i=o+1;i<e.length;i++){const a=e[i];if(!a.static){if(a.y>t.y+t.h)break;dj(t,a)&&uM(e,a,n+t[s],r)}}t[r]=n}function KK(e,t,n,r,s,o){const i=n==="vertical",a=n==="horizontal";if(i)for(t.y=Math.min(dP(e),t.y);t.y>0&&!Ef(e,t);)t.y--;else if(a)for(;t.x>0&&!Ef(e,t);)t.x--;let c;for(;(c=Ef(e,t))&&!(n===null&&o);)if(a?uM(s,t,c.x+c.w,"x"):uM(s,t,c.y+c.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!Ef(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function ZK(e,t){const n=hP(e);for(let r=0,s=e.length;r<s;r++){const o=e[r];if(o.x+o.w>t.cols&&(o.x=t.cols-o.w),o.x<0&&(o.x=0,o.w=t.cols),!o.static)n.push(o);else for(;Ef(n,o);)o.y++}return e}function fP(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function Ef(e,t){for(let n=0,r=e.length;n<r;n++)if(dj(e[n],t))return e[n]}function XK(e,t){return e.filter(n=>dj(n,t))}function hP(e){return e.filter(t=>t.static)}function Mx(e,t,n,r,s,o,i,a,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;`${t.i}${String(n)}${String(r)}${t.x}${t.y}`;const u=t.x,d=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let f=yP(e,i);(i==="vertical"&&typeof r=="number"?d>=r:i==="horizontal"&&typeof n=="number"?u>=n:!1)&&(f=f.reverse());const p=XK(f,t),g=p.length>0;if(g&&c)return WK(e);if(g&&o)return`${t.i}`,t.x=u,t.y=d,t.moved=!1,e;for(let b=0,x=p.length;b<x;b++){const y=p[b];`${t.i}${t.x}${t.y}${y.i}${y.x}${y.y}`,!y.moved&&(y.static?e=dM(e,y,t,s,i):e=dM(e,t,y,s,i))}return e}function dM(e,t,n,r,s,o){const i=s==="horizontal",a=s==="vertical",c=t.static;if(r){r=!1;const f={x:i?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},h=Ef(e,f),p=h&&h.y+h.h>t.y,g=h&&t.x+t.w>h.x;if(h){if(p&&a)return Mx(e,n,void 0,t.y+1,r,c,s);if(p&&s==null)return t.y=n.y,n.y=n.y+n.h,e;if(g&&i)return Mx(e,t,n.x,void 0,r,c,s)}else return`${n.i}${f.x}${f.y}`,Mx(e,n,i?f.x:void 0,a?f.y:void 0,r,c,s)}const u=i?n.x+1:void 0,d=a?n.y+1:void 0;return u==null&&d==null?e:Mx(e,n,i?n.x+1:void 0,a?n.y+1:void 0,r,c,s)}function c1e(e){return e*100+"%"}const QK=(e,t,n,r)=>e+n>r?t:n,JK=(e,t,n)=>e<0?t:n,eZ=e=>Math.max(0,e),pP=e=>Math.max(0,e),mP=(e,t,n)=>{let{left:r,height:s,width:o}=t;const i=e.top-(s-e.height);return{left:r,width:o,height:JK(i,e.height,s),top:pP(i)}},gP=(e,t,n)=>{let{top:r,left:s,height:o,width:i}=t;return{top:r,height:o,width:QK(e.left,e.width,i,n),left:eZ(s)}},bP=(e,t,n)=>{let{top:r,height:s,width:o}=t;const i=e.left-(o-e.width);return{height:s,width:i<0?e.width:QK(e.left,e.width,o,n),top:pP(r),left:eZ(i)}},xP=(e,t,n)=>{let{top:r,left:s,height:o,width:i}=t;return{width:i,left:s,height:JK(r,e.height,o),top:pP(r)}},u1e=function(){return mP(arguments.length<=0?void 0:arguments[0],gP(...arguments))},d1e=function(){return mP(arguments.length<=0?void 0:arguments[0],bP(...arguments))},f1e=function(){return xP(arguments.length<=0?void 0:arguments[0],gP(...arguments))},h1e=function(){return xP(arguments.length<=0?void 0:arguments[0],bP(...arguments))},p1e={n:mP,ne:u1e,e:gP,se:f1e,s:xP,sw:h1e,w:bP,nw:d1e};function m1e(e,t,n,r){const s=p1e[e];return s?s(t,{...t,...n},r):n}function g1e(e){let{top:t,left:n,width:r,height:s}=e;const o=`translate(${n}px,${t}px)`;return{transform:o,WebkitTransform:o,MozTransform:o,msTransform:o,OTransform:o,width:`${r}px`,height:`${s}px`,position:"absolute"}}function b1e(e){let{top:t,left:n,width:r,height:s}=e;return{top:`${t}px`,left:`${n}px`,width:`${r}px`,height:`${s}px`,position:"absolute"}}function yP(e,t){return t==="horizontal"?nZ(e):t==="vertical"?tZ(e):e}function tZ(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function nZ(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function x1e(e,t,n,r,s){e=e||[];const o=[];Dx.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const c=fP(e,String(a.key)),u=a.props["data-grid"];c&&u==null?o.push(Jf(c)):u?(s1e||rZ([u],"ReactGridLayout.children"),o.push(Jf({...u,i:a.key}))):o.push(Jf({w:1,h:1,x:0,y:dP(o),i:String(a.key)}))});const i=ZK(o,{cols:n});return s?i:GK(i,r,n)}function rZ(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,s=e.length;r<s;r++){const o=e[r];for(let i=0;i<n.length;i++){const a=n[i],c=o[a];if(typeof c!="number"||Number.isNaN(c))throw new Error(`ReactGridLayout: ${t}[${r}].${a} must be a number! Received: ${c} (${typeof c})`)}if(typeof o.i<"u"&&typeof o.i!="string")throw new Error(`ReactGridLayout: ${t}[${r}].i must be a string! Received: ${o.i} (${typeof o.i})`)}}function y1e(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const v1e=()=>{};Cn.noop=v1e;var Ul={};Object.defineProperty(Ul,"__esModule",{value:!0});Ul.calcGridColWidth=fj;Ul.calcGridItemPosition=w1e;Ul.calcGridItemWHPx=fM;Ul.calcWH=C1e;Ul.calcXY=S1e;Ul.clamp=Tf;function fj(e){const{margin:t,containerPadding:n,containerWidth:r,cols:s}=e;return(r-t[0]*(s-1)-n[0]*2)/s}function fM(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function w1e(e,t,n,r,s,o){const{margin:i,containerPadding:a,rowHeight:c}=e,u=fj(e),d={};return o&&o.resizing?(d.width=Math.round(o.resizing.width),d.height=Math.round(o.resizing.height)):(d.width=fM(r,u,i[0]),d.height=fM(s,c,i[1])),o&&o.dragging?(d.top=Math.round(o.dragging.top),d.left=Math.round(o.dragging.left)):o&&o.resizing&&typeof o.resizing.top=="number"&&typeof o.resizing.left=="number"?(d.top=Math.round(o.resizing.top),d.left=Math.round(o.resizing.left)):(d.top=Math.round((c+i[1])*n+a[1]),d.left=Math.round((u+i[0])*t+a[0])),d}function S1e(e,t,n,r,s){const{margin:o,containerPadding:i,cols:a,rowHeight:c,maxRows:u}=e,d=fj(e);let f=Math.round((n-i[0])/(d+o[0])),h=Math.round((t-i[1])/(c+o[1]));return f=Tf(f,0,a-r),h=Tf(h,0,u-s),{x:f,y:h}}function C1e(e,t,n,r,s,o){const{margin:i,maxRows:a,cols:c,rowHeight:u}=e,d=fj(e);let f=Math.round((t+i[0])/(d+i[0])),h=Math.round((n+i[1])/(u+i[1])),p=Tf(f,0,c-r),g=Tf(h,0,a-s);return["sw","w","nw"].indexOf(o)!==-1&&(p=Tf(f,0,c)),["nw","n","ne"].indexOf(o)!==-1&&(g=Tf(h,0,a)),{w:p,h:g}}function Tf(e,t,n){return Math.max(Math.min(e,n),t)}var hj={},hM={exports:{}},Yw={exports:{}},er={};/** @license React v16.13.1
755
+ </html>`}function Hwe({dataApp:e,onBack:t}){var d;const{authToken:n,tokenProps:r}=Ct(),[s,o]=v.useState(null),i=Bn({queryKey:["published-data-app-runtime",r.apiServiceUrl,n==null?void 0:n.accessToken,e.id],queryFn:async()=>m.getRequest(`${r.apiServiceUrl}/data-apps/${e.id}/runtime`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)&&!!e.id});v.useEffect(()=>{function f(h){const p=h.data;(p==null?void 0:p.source)!=="semaphor-data-app-runtime"||p.type!=="runtime-error"||o(p.message||"Published Data App failed to load.")}return window.addEventListener("message",f),()=>window.removeEventListener("message",f)},[]),v.useEffect(()=>{o(null)},[e.id]);const a=(d=i.data)==null?void 0:d.dataApp,c=a==null?void 0:a.runtime,u=v.useMemo(()=>!a||!c?"":Vwe({title:a.title||e.title,apiBaseUrl:r.apiServiceUrl,dataApp:a,runtime:c}),[e.title,c,a,r.apiServiceUrl]);return l.jsxs("div",{className:"flex h-full grow flex-col bg-background text-foreground",children:[l.jsxs("header",{className:"flex h-14 shrink-0 items-center justify-between border-b border-border/60 px-4",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[l.jsx(m.Button,{"aria-label":"Back to Analytics workspace",className:"h-8 w-8 px-0",onClick:t,size:"xs",variant:"ghost",children:l.jsx(hv,{className:"h-4 w-4"})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data App"}),l.jsx("h1",{className:"truncate text-[14px] font-semibold",children:(a==null?void 0:a.title)||e.title})]})]}),c?l.jsxs("div",{className:"rounded-md border border-border px-2 py-1 text-[11px] text-muted-foreground",children:["v",c.version]}):null]}),i.isLoading?l.jsx("div",{className:"flex flex-1 items-center justify-center",children:l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(m.LoaderCircle,{className:"h-4 w-4 animate-spin"}),"Loading Data App..."]})}):i.isError?l.jsx("div",{className:"flex flex-1 items-center justify-center px-6",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(mh,{className:"h-5 w-5 text-destructive"}),l.jsx("h2",{className:"text-[13px] font-medium",children:"Couldn't load Data App"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"The published runtime could not be fetched. Please try again."})]})}):c?l.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[s?l.jsx("div",{className:"border-b border-destructive/30 bg-destructive/10 px-4 py-2 text-[12px] text-destructive",children:s}):null,l.jsx("iframe",{className:"min-h-0 flex-1 border-0",sandbox:"allow-forms allow-modals allow-popups allow-scripts",srcDoc:u,title:(a==null?void 0:a.title)||e.title})]}):l.jsx("div",{className:"flex flex-1 items-center justify-center px-6",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(mh,{className:"h-5 w-5 text-muted-foreground/60"}),l.jsx("h2",{className:"text-[13px] font-medium",children:"No published version yet"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Publish this Data App before opening it from the Analytics workspace."})]})})]})}function LK(e){var t;if(e&&e.type!=="organization"&&e.type==="tenant")return((t=e.role)==null?void 0:t.toUpperCase())==="VIEWER"?{showFilters:!1}:void 0}function Uwe(e){var t;if(!e)return!1;if(e.type==="organization")return!0;if(e.type==="tenant"){const n=(t=e.role)==null?void 0:t.toUpperCase();return n?n!=="VIEWER":!1}return!1}function qwe(e){var t;return e?e.type==="organization"?!0:e.type==="tenant"?((t=e.role)==null?void 0:t.toUpperCase())!=="VIEWER":!1:!1}function Wwe(e){return!!e}function $K(e){var t;return e?e.type==="organization"?!0:e.type==="tenant"?((t=e.role)==null?void 0:t.toUpperCase())!=="VIEWER":!1:!1}function Ywe(e){var t;return e?e.type==="organization"?!0:e.type==="tenant"?((t=e.role)==null?void 0:t.toUpperCase())!=="VIEWER":!1:!1}function Gwe(e){var t;return e?e.type==="organization"?!0:e.type==="tenant"?((t=e.role)==null?void 0:t.toUpperCase())==="POWER_USER":!1:!1}function Kwe({onDashboardSelect:e}){var Ae,ae,me,Ce;const{authToken:t,tokenProps:n}=Ct(),r=((ae=(Ae=n.config)==null?void 0:Ae.projectFeatures)==null?void 0:ae.features.dataAppBuilder)!==!1,[s,o]=v.useState(!1),[i,a]=v.useState(!1),[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,p]=v.useState(!1),[g,b]=v.useState(null),[x,y]=v.useState(null),[S,w]=v.useState(null),[C,N]=v.useState(null),[k,j]=v.useState(""),{data:_}=DG(),T=((me=_==null?void 0:_.preference)==null?void 0:me.defaultDashboardId)||null,E=hs(se=>se.actions.selectDashboard),{currentUser:I,userContext:D}=ua(),A=((Ce=D==null?void 0:D.permissions)==null?void 0:Ce.canCreateDashboard)??$K(I),{onCreateSuccess:P}=cG({onDashboardSelect:e}),{resources:R,isLoading:H,isError:z,createResourceAsync:U,updateResource:W,deleteResource:O,duplicateResource:Z,isCreating:Y,isUpdating:M,isDeleting:G,isDuplicating:L,refetch:$}=lG(()=>{p(!1),b(null)},se=>{o(!1),P(se,$)}),{startUpdating:B,stopUpdating:V,isUpdating:F}=aG(),q=se=>{const re=R.find(J=>J.id===se);if(re){if(re.kind==="data_app"){N(re);return}E(re),e==null||e(se)}},K=se=>{const re=x0e(se);return U({title:se.title,description:se.description,isPrivate:!1,...re?{template:re}:{}})},X=se=>{b(se),p(!0)},ee=()=>{g&&O(g.id)},de=se=>{y(se),Z(se,{onSettled:()=>y(null)})},fe=(se,re,J)=>{var we;const he=Object.fromEntries(Object.entries(re).filter(([,ne])=>ne!==void 0));if(Object.keys(he).length===0){(we=J==null?void 0:J.onSuccess)==null||we.call(J);return}const te=Object.keys(he),Se=te.length===1?te[0]:void 0;B(se,Se),W({resourceId:se,data:he},{onSuccess:()=>{var ne;V(se,Se),(ne=J==null?void 0:J.onSuccess)==null||ne.call(J)},onError:()=>{var ne;V(se,Se),(ne=J==null?void 0:J.onError)==null||ne.call(J)}})},ge=se=>{f(se),u(!0)},ve=se=>new Date(se).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),ie=R.length>5,be=ie?k.trim().toLowerCase():"",oe=v.useMemo(()=>be?R.filter(se=>{var he,te;const re=((he=se.title)==null?void 0:he.toLowerCase())??"",J=((te=se.description)==null?void 0:te.toLowerCase())??"";return re.includes(be)||J.includes(be)}):R,[be,R]);return i&&r?l.jsx(OK,{apiServiceUrl:n.apiServiceUrl,onBack:()=>a(!1),projectId:n.project_id||"embedded-project",projectName:"Analytics workspace"}):C?l.jsx(Hwe,{dataApp:C,onBack:()=>N(null)}):t?z?l.jsx("div",{className:"flex h-full grow items-center justify-center px-6",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(mh,{className:"h-6 w-6 text-destructive"}),l.jsx("h2",{className:"text-[13px] font-medium text-foreground",children:"Couldn't load dashboards"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Unable to fetch your dashboards. Please try again."}),l.jsx(m.Button,{size:"xs",variant:"outline",className:"mt-2",onClick:()=>window.location.reload(),children:"Retry"})]})}):l.jsxs(Zwe,{children:[l.jsx("div",{className:"border-b border-border/60 bg-background px-6 py-5 lg:px-8",children:l.jsx("div",{className:"mx-auto max-w-7xl",children:l.jsxs("div",{className:"flex items-start justify-between gap-6",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("h1",{className:"text-[15px] font-semibold tracking-tight text-foreground",children:"Analytics workspace"}),l.jsxs("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:["Pick an existing dashboard or app, or create a new one.",!H&&R.length>0?l.jsxs("span",{className:"ml-1.5",children:["· ",R.length," item",R.length!==1?"s":""]}):null]})]}),A&&l.jsxs("div",{className:"flex items-center gap-1.5",children:[r?l.jsxs(m.Button,{size:"xs",variant:"outline",onClick:()=>a(!0),children:[l.jsx(yr,{className:"h-3.5 w-3.5"}),"New app"]}):null,l.jsxs(m.Button,{size:"xs",onClick:()=>o(!0),children:[l.jsx(yr,{className:"h-3.5 w-3.5"}),"New dashboard"]})]})]})})}),l.jsx(Xwe,{children:l.jsx("div",{className:"mx-auto max-w-7xl",children:H?l.jsx(Qwe,{}):R.length===0?l.jsx("div",{className:"flex items-center justify-center py-20",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(Vm,{className:"h-6 w-6 text-muted-foreground/60"}),l.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"No dashboards yet"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:A?"Create your first dashboard to get started.":"No dashboards have been shared with you yet."}),A&&l.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[r?l.jsxs(m.Button,{size:"xs",variant:"outline",onClick:()=>a(!0),children:[l.jsx(yr,{className:"h-3.5 w-3.5"}),"Create app"]}):null,l.jsxs(m.Button,{size:"xs",onClick:()=>o(!0),children:[l.jsx(yr,{className:"h-3.5 w-3.5"}),"Create dashboard"]})]})]})}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[l.jsx("h2",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Your dashboards"}),ie&&l.jsxs("div",{className:"relative w-full sm:w-72",children:[l.jsx(Xs,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),l.jsx(m.Input,{size:"xs",placeholder:"Search dashboards…",value:k,onChange:se=>j(se.target.value),className:"pl-8"})]})]}),oe.length===0?l.jsx("div",{className:"flex items-center justify-center py-20 text-center",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-1",children:[l.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:"No dashboards found"}),l.jsxs("p",{className:"text-[12px] text-muted-foreground",children:["No dashboards match “",k.trim(),"”."]})]})}):l.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:oe.map(se=>l.jsx(Jwe,{dashboard:se,icon:se.kind==="data_app"?l.jsx(Fme,{className:"h-3.5 w-3.5"}):void 0,eyebrow:se.kind==="data_app"?"Data App":void 0,isDefault:se.kind!=="data_app"&&se.id===T,onView:q,isDeleting:G&&(g==null?void 0:g.id)===se.id,isDuplicating:x===se.id,onEditDetails:w,onDeleteClick:X,onDuplicateDashboard:de,onShareDashboard:ge,formatDate:ve},se.id))})]})})}),l.jsx(Zxe,{open:s,onOpenChange:o,onCreateBlank:K,onAiCreateSuccess:se=>{o(!1),P(se.dashboard,$)},isCreatingBlank:Y}),S&&l.jsx(aK,{open:!!S,resourceLabel:"Dashboard",initialTitle:S.title||"",initialDescription:S.description||"",onClose:()=>w(null),onSave:se=>{fe(S.id,se,{onSuccess:()=>{w(null)}})},isSaving:F(S.id)}),l.jsx(Wc,{open:h,onOpenChange:p,children:l.jsxs(Tl,{children:[l.jsxs(Il,{children:[l.jsx(Ml,{children:"Delete Dashboard?"}),l.jsxs(Al,{children:['Are you sure you want to delete "',g==null?void 0:g.title,'"? This action cannot be undone.']})]}),l.jsxs(Dl,{children:[l.jsx(Fl,{disabled:G,children:"Cancel"}),l.jsx(Rl,{onClick:ee,disabled:G,children:G?l.jsxs(l.Fragment,{children:[l.jsx(m.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Deleting…"]}):"Delete"})]})]})}),d&&c&&l.jsx(iK,{resource:d,resourceType:rs.DASHBOARD,onClose:()=>{u(!1),f(null)}})]}):l.jsx("div",{className:"flex h-full grow items-center justify-center px-6",children:l.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2 text-center",children:[l.jsx(mh,{className:"h-6 w-6 text-muted-foreground/60"}),l.jsx("h2",{className:"text-[13px] font-medium text-foreground",children:"Authentication required"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Please provide authentication to view dashboards."})]})})}function Zwe({children:e}){const t=Hl();return l.jsx("div",{"data-content-type":"dashboard-hub",className:"flex h-full grow flex-col bg-background text-foreground",style:t.dashboardContainerStyle,children:e})}function Xwe({children:e}){const t=Hl();return l.jsx("div",{className:"flex-1 overflow-y-auto bg-muted/20 px-6 py-6 lg:px-8",style:t.dashboardCanvasStyle,children:e})}function Qwe(){return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:l.jsx("h2",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Your dashboards"})}),l.jsx("div",{className:"flex min-h-[280px] items-center justify-center rounded-[6px] border border-dashed border-border/70 bg-background/40",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading dashboards..."})]})})]})}function Jwe(e){const t=Hl();return l.jsx(axe,{...e,style:{...t.cardFrameStyle,...e.style}})}const Qf=m.create()(e=>({panels:{dashboard:{isOpen:!1,container:null},editor:{isOpen:!1,container:null}},fullscreen:null,setPanelOpen:(t,n)=>e(r=>r.panels[t].isOpen===n?r:{panels:{...r.panels,[t]:{...r.panels[t],isOpen:n}},fullscreen:!n&&r.fullscreen===t?null:r.fullscreen}),setFullscreen:t=>e(n=>n.fullscreen===t?n:{fullscreen:t}),setContainer:(t,n)=>e(r=>r.panels[t].container===n?r:{panels:{...r.panels,[t]:{...r.panels[t],container:n}}})})),zK=e=>Qf(t=>t.panels[e]),BK=()=>Qf(e=>e.fullscreen),VK=e=>Qf(t=>t.panels[e].container??null);m.enableMapSet();const cj=m.create()(m.immer((e,t)=>({activeExports:new Map,actions:{addExport:n=>{e(r=>{r.activeExports.set(n.id,{...n,lastUpdatedAt:n.lastUpdatedAt??new Date})})},updateExport:(n,r)=>{e(s=>{const o=s.activeExports.get(n);if(o){const i={...o,...r};r.lastUpdatedAt||(i.lastUpdatedAt=new Date),s.activeExports.set(n,i)}})},removeExport:n=>{e(r=>{r.activeExports.delete(n)})},getInProgressExports:()=>Array.from(t().activeExports.values()).filter(r=>["pending","processing","chunking","compacting"].includes(r.status)),getAllExports:()=>Array.from(t().activeExports.values()).sort((n,r)=>r.startedAt.getTime()-n.startedAt.getTime()),clearCompleted:()=>{e(n=>{for(const[r,s]of n.activeExports)(s.status==="completed"||s.status==="failed")&&n.activeExports.delete(r)})},hasInProgressExports:()=>Array.from(t().activeExports.values()).some(r=>["pending","processing","chunking","compacting"].includes(r.status))}}))),HK=()=>cj(e=>e.actions),e1e=()=>cj(e=>e.activeExports),t1e=()=>cj(e=>Array.from(e.activeExports.values()).filter(n=>["pending","processing","chunking","compacting"].includes(n.status)).length);function UK(){const{tokenProps:e,id:t}=Ct(),n=hs(s=>s.selectedDashboard);return hs(s=>s.showHub)?!1:!!(n!=null&&n.id||t||e!=null&&e.dashboard_id)}function cP({className:e,customStyle:t,onSave:n,onEvent:r,LoadingComponent:s,ErrorComponent:o,onChartElementClicked:i,id:a,authToken:c,currentTheme:u,appearance:d,version:f,customCards:h,showAssistant:p,defaultFilterValues:g,defaultControlValues:b,controlContractOverrides:x,documentInputValues:y,dashboardInputExecutionSnapshot:S,renderMode:w,onFilterValuesChange:C,selectedSheetId:N,eventHandlers:k,type:j="dashboard",cardId:_,dashboardId:T,style:E,...I}){const{placeholders:D,tokenProps:A,id:P}=Ct();hs(Z=>Z.selectedDashboard);const R=m.useDashboardStore(Z=>Z.themeStyle),H=Hl(),z=m.useDashboardStore(Z=>Z.isSessionExpired),{isLoading:U,isError:W}=Ime({customStyle:t,currentTheme:u,onSave:n,onEvent:r,defaultFilterValues:g,defaultControlValues:b,controlContractOverrides:x,dashboardInputExecutionSnapshot:S,onFilterValuesChange:C,selectedSheetId:N,type:j,cardId:_}),O=UK();return c&&!O&&!U?l.jsx(Kwe,{}):U||!c?(r==null||r({type:"info",message:"Loading dashboard"}),s?l.jsx(s,{message:"loading"}):l.jsx("div",{className:"flex items-center gap-3",children:l.jsx(bo,{className:"h-1 w-full dark:h-[2px]"})})):W?(r==null||r({type:"error",message:"Error fetching dashboard"}),o?(console.log("Error fetching dashboard"),l.jsx(o,{})):l.jsx("div",{children:"Error"})):z?(r==null||r({type:"error",message:"Session Expired"}),D!=null&&D.SessionExpired?l.jsx("div",{className:"flex h-full w-full items-center justify-center",children:l.jsx("div",{children:D.SessionExpired})}):l.jsx("div",{className:"flex h-full w-full items-center justify-center",children:l.jsxs("div",{className:"space-y-4 rounded-md border border-muted p-10",children:[l.jsx(Cg,{children:"Session Expired"}),l.jsx("p",{className:"text-muted-foreground",children:"Please refresh your page to continue"})]})})):l.jsx("div",{className:m.cn("isolate flex grow flex-col",{"h-full":j==="visual"},R==null?void 0:R.dashboardPanel,e),style:{...H.dashboardContainerStyle,...E},"data-role":"semaphor-container",...I})}var qK={exports:{}},wv={},cM={exports:{}};(function(e,t){(function(n,r){r(t)})(m.commonjsGlobal,function(n){function r(V){return function(q,K,X,ee,de,fe,ge){return V(q,K,ge)}}function s(V){return function(q,K,X,ee){if(!q||!K||typeof q!="object"||typeof K!="object")return V(q,K,X,ee);var de=ee.get(q),fe=ee.get(K);if(de&&fe)return de===K&&fe===q;ee.set(q,K),ee.set(K,q);var ge=V(q,K,X,ee);return ee.delete(q),ee.delete(K),ge}}function o(V,F){var q={};for(var K in V)q[K]=V[K];for(var K in F)q[K]=F[K];return q}function i(V){return V.constructor===Object||V.constructor==null}function a(V){return typeof V.then=="function"}function c(V,F){return V===F||V!==V&&F!==F}var u="[object Arguments]",d="[object Boolean]",f="[object Date]",h="[object RegExp]",p="[object Map]",g="[object Number]",b="[object Object]",x="[object Set]",y="[object String]",S=Object.prototype.toString;function w(V){var F=V.areArraysEqual,q=V.areDatesEqual,K=V.areMapsEqual,X=V.areObjectsEqual,ee=V.areRegExpsEqual,de=V.areSetsEqual,fe=V.createIsNestedEqual,ge=fe(ve);function ve(ie,be,oe){if(ie===be)return!0;if(!ie||!be||typeof ie!="object"||typeof be!="object")return ie!==ie&&be!==be;if(i(ie)&&i(be))return X(ie,be,ge,oe);var Ae=Array.isArray(ie),ae=Array.isArray(be);if(Ae||ae)return Ae===ae&&F(ie,be,ge,oe);var me=S.call(ie);return me!==S.call(be)?!1:me===f?q(ie,be,ge,oe):me===h?ee(ie,be,ge,oe):me===p?K(ie,be,ge,oe):me===x?de(ie,be,ge,oe):me===b||me===u?a(ie)||a(be)?!1:X(ie,be,ge,oe):me===d||me===g||me===y?c(ie.valueOf(),be.valueOf()):!1}return ve}function C(V,F,q,K){var X=V.length;if(F.length!==X)return!1;for(;X-- >0;)if(!q(V[X],F[X],X,X,V,F,K))return!1;return!0}var N=s(C);function k(V,F){return c(V.valueOf(),F.valueOf())}function j(V,F,q,K){var X=V.size===F.size;if(!X)return!1;if(!V.size)return!0;var ee={},de=0;return V.forEach(function(fe,ge){if(X){var ve=!1,ie=0;F.forEach(function(be,oe){!ve&&!ee[ie]&&(ve=q(ge,oe,de,ie,V,F,K)&&q(fe,be,ge,oe,V,F,K))&&(ee[ie]=!0),ie++}),de++,X=ve}}),X}var _=s(j),T="_owner",E=Object.prototype.hasOwnProperty;function I(V,F,q,K){var X=Object.keys(V),ee=X.length;if(Object.keys(F).length!==ee)return!1;for(var de;ee-- >0;){if(de=X[ee],de===T){var fe=!!V.$$typeof,ge=!!F.$$typeof;if((fe||ge)&&fe!==ge)return!1}if(!E.call(F,de)||!q(V[de],F[de],de,de,V,F,K))return!1}return!0}var D=s(I);function A(V,F){return V.source===F.source&&V.flags===F.flags}function P(V,F,q,K){var X=V.size===F.size;if(!X)return!1;if(!V.size)return!0;var ee={};return V.forEach(function(de,fe){if(X){var ge=!1,ve=0;F.forEach(function(ie,be){!ge&&!ee[ve]&&(ge=q(de,ie,fe,be,V,F,K))&&(ee[ve]=!0),ve++}),X=ge}}),X}var R=s(P),H=Object.freeze({areArraysEqual:C,areDatesEqual:k,areMapsEqual:j,areObjectsEqual:I,areRegExpsEqual:A,areSetsEqual:P,createIsNestedEqual:r}),z=Object.freeze({areArraysEqual:N,areDatesEqual:k,areMapsEqual:_,areObjectsEqual:D,areRegExpsEqual:A,areSetsEqual:R,createIsNestedEqual:r}),U=w(H);function W(V,F){return U(V,F,void 0)}var O=w(o(H,{createIsNestedEqual:function(){return c}}));function Z(V,F){return O(V,F,void 0)}var Y=w(z);function M(V,F){return Y(V,F,new WeakMap)}var G=w(o(z,{createIsNestedEqual:function(){return c}}));function L(V,F){return G(V,F,new WeakMap)}function $(V){return w(o(H,V(H)))}function B(V){var F=w(o(z,V(z)));return function(q,K,X){return X===void 0&&(X=new WeakMap),F(q,K,X)}}n.circularDeepEqual=M,n.circularShallowEqual=L,n.createCustomCircularEqual=B,n.createCustomEqual=$,n.deepEqual=W,n.sameValueZeroEqual=c,n.shallowEqual=Z,Object.defineProperty(n,"__esModule",{value:!0})})})(cM,cM.exports);var uP=cM.exports;const uj=m.getAugmentedNamespace(m.clsx$1);var Cn={},n1e=function(t,n,r){return t===n?!0:t.className===n.className&&r(t.style,n.style)&&t.width===n.width&&t.autoSize===n.autoSize&&t.cols===n.cols&&t.draggableCancel===n.draggableCancel&&t.draggableHandle===n.draggableHandle&&r(t.verticalCompact,n.verticalCompact)&&r(t.compactType,n.compactType)&&r(t.layout,n.layout)&&r(t.margin,n.margin)&&r(t.containerPadding,n.containerPadding)&&t.rowHeight===n.rowHeight&&t.maxRows===n.maxRows&&t.isBounded===n.isBounded&&t.isDraggable===n.isDraggable&&t.isResizable===n.isResizable&&t.allowOverlap===n.allowOverlap&&t.preventCollision===n.preventCollision&&t.useCSSTransforms===n.useCSSTransforms&&t.transformScale===n.transformScale&&t.isDroppable===n.isDroppable&&r(t.resizeHandles,n.resizeHandles)&&r(t.resizeHandle,n.resizeHandle)&&t.onLayoutChange===n.onLayoutChange&&t.onDragStart===n.onDragStart&&t.onDrag===n.onDrag&&t.onDragStop===n.onDragStop&&t.onResizeStart===n.onResizeStart&&t.onResize===n.onResize&&t.onResizeStop===n.onResizeStop&&t.onDrop===n.onDrop&&r(t.droppingItem,n.droppingItem)&&r(t.innerRef,n.innerRef)};Object.defineProperty(Cn,"__esModule",{value:!0});Cn.bottom=dP;Cn.childrenEqual=i1e;Cn.cloneLayout=WK;Cn.cloneLayoutItem=Jf;Cn.collides=dj;Cn.compact=GK;Cn.compactItem=KK;Cn.compactType=y1e;Cn.correctBounds=ZK;Cn.fastPositionEqual=a1e;Cn.fastRGLPropsEqual=void 0;Cn.getAllCollisions=XK;Cn.getFirstCollision=Ef;Cn.getLayoutItem=fP;Cn.getStatics=hP;Cn.modifyLayout=YK;Cn.moveElement=Mx;Cn.moveElementAwayFromCollision=dM;Cn.noop=void 0;Cn.perc=c1e;Cn.resizeItemInDirection=m1e;Cn.setTopLeft=b1e;Cn.setTransform=g1e;Cn.sortLayoutItems=yP;Cn.sortLayoutItemsByColRow=nZ;Cn.sortLayoutItemsByRowCol=tZ;Cn.synchronizeLayoutWithChildren=x1e;Cn.validateLayout=rZ;Cn.withLayoutItem=o1e;var I4=uP,Dx=r1e(v);function r1e(e){return e&&e.__esModule?e:{default:e}}const s1e=process.env.NODE_ENV==="production";function dP(e){let t=0,n;for(let r=0,s=e.length;r<s;r++)n=e[r].y+e[r].h,n>t&&(t=n);return t}function WK(e){const t=Array(e.length);for(let n=0,r=e.length;n<r;n++)t[n]=Jf(e[n]);return t}function YK(e,t){const n=Array(e.length);for(let r=0,s=e.length;r<s;r++)t.i===e[r].i?n[r]=t:n[r]=e[r];return n}function o1e(e,t,n){let r=fP(e,t);return r?(r=n(Jf(r)),e=YK(e,r),[e,r]):[e,null]}function Jf(e){return{w:e.w,h:e.h,x:e.x,y:e.y,i:e.i,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}}function i1e(e,t){return(0,I4.deepEqual)(Dx.default.Children.map(e,n=>n==null?void 0:n.key),Dx.default.Children.map(t,n=>n==null?void 0:n.key))&&(0,I4.deepEqual)(Dx.default.Children.map(e,n=>n==null?void 0:n.props["data-grid"]),Dx.default.Children.map(t,n=>n==null?void 0:n.props["data-grid"]))}Cn.fastRGLPropsEqual=n1e;function a1e(e,t){return e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height}function dj(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function GK(e,t,n,r){const s=hP(e),o=yP(e,t),i=Array(e.length);for(let a=0,c=o.length;a<c;a++){let u=Jf(o[a]);u.static||(u=KK(s,u,t,n,o,r),s.push(u)),i[e.indexOf(o[a])]=u,u.moved=!1}return i}const l1e={x:"w",y:"h"};function uM(e,t,n,r){const s=l1e[r];t[r]+=1;const o=e.map(i=>i.i).indexOf(t.i);for(let i=o+1;i<e.length;i++){const a=e[i];if(!a.static){if(a.y>t.y+t.h)break;dj(t,a)&&uM(e,a,n+t[s],r)}}t[r]=n}function KK(e,t,n,r,s,o){const i=n==="vertical",a=n==="horizontal";if(i)for(t.y=Math.min(dP(e),t.y);t.y>0&&!Ef(e,t);)t.y--;else if(a)for(;t.x>0&&!Ef(e,t);)t.x--;let c;for(;(c=Ef(e,t))&&!(n===null&&o);)if(a?uM(s,t,c.x+c.w,"x"):uM(s,t,c.y+c.h,"y"),a&&t.x+t.w>r)for(t.x=r-t.w,t.y++;t.x>0&&!Ef(e,t);)t.x--;return t.y=Math.max(t.y,0),t.x=Math.max(t.x,0),t}function ZK(e,t){const n=hP(e);for(let r=0,s=e.length;r<s;r++){const o=e[r];if(o.x+o.w>t.cols&&(o.x=t.cols-o.w),o.x<0&&(o.x=0,o.w=t.cols),!o.static)n.push(o);else for(;Ef(n,o);)o.y++}return e}function fP(e,t){for(let n=0,r=e.length;n<r;n++)if(e[n].i===t)return e[n]}function Ef(e,t){for(let n=0,r=e.length;n<r;n++)if(dj(e[n],t))return e[n]}function XK(e,t){return e.filter(n=>dj(n,t))}function hP(e){return e.filter(t=>t.static)}function Mx(e,t,n,r,s,o,i,a,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return e;`${t.i}${String(n)}${String(r)}${t.x}${t.y}`;const u=t.x,d=t.y;typeof n=="number"&&(t.x=n),typeof r=="number"&&(t.y=r),t.moved=!0;let f=yP(e,i);(i==="vertical"&&typeof r=="number"?d>=r:i==="horizontal"&&typeof n=="number"?u>=n:!1)&&(f=f.reverse());const p=XK(f,t),g=p.length>0;if(g&&c)return WK(e);if(g&&o)return`${t.i}`,t.x=u,t.y=d,t.moved=!1,e;for(let b=0,x=p.length;b<x;b++){const y=p[b];`${t.i}${t.x}${t.y}${y.i}${y.x}${y.y}`,!y.moved&&(y.static?e=dM(e,y,t,s,i):e=dM(e,t,y,s,i))}return e}function dM(e,t,n,r,s,o){const i=s==="horizontal",a=s==="vertical",c=t.static;if(r){r=!1;const f={x:i?Math.max(t.x-n.w,0):n.x,y:a?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:"-1"},h=Ef(e,f),p=h&&h.y+h.h>t.y,g=h&&t.x+t.w>h.x;if(h){if(p&&a)return Mx(e,n,void 0,t.y+1,r,c,s);if(p&&s==null)return t.y=n.y,n.y=n.y+n.h,e;if(g&&i)return Mx(e,t,n.x,void 0,r,c,s)}else return`${n.i}${f.x}${f.y}`,Mx(e,n,i?f.x:void 0,a?f.y:void 0,r,c,s)}const u=i?n.x+1:void 0,d=a?n.y+1:void 0;return u==null&&d==null?e:Mx(e,n,i?n.x+1:void 0,a?n.y+1:void 0,r,c,s)}function c1e(e){return e*100+"%"}const QK=(e,t,n,r)=>e+n>r?t:n,JK=(e,t,n)=>e<0?t:n,eZ=e=>Math.max(0,e),pP=e=>Math.max(0,e),mP=(e,t,n)=>{let{left:r,height:s,width:o}=t;const i=e.top-(s-e.height);return{left:r,width:o,height:JK(i,e.height,s),top:pP(i)}},gP=(e,t,n)=>{let{top:r,left:s,height:o,width:i}=t;return{top:r,height:o,width:QK(e.left,e.width,i,n),left:eZ(s)}},bP=(e,t,n)=>{let{top:r,height:s,width:o}=t;const i=e.left-(o-e.width);return{height:s,width:i<0?e.width:QK(e.left,e.width,o,n),top:pP(r),left:eZ(i)}},xP=(e,t,n)=>{let{top:r,left:s,height:o,width:i}=t;return{width:i,left:s,height:JK(r,e.height,o),top:pP(r)}},u1e=function(){return mP(arguments.length<=0?void 0:arguments[0],gP(...arguments))},d1e=function(){return mP(arguments.length<=0?void 0:arguments[0],bP(...arguments))},f1e=function(){return xP(arguments.length<=0?void 0:arguments[0],gP(...arguments))},h1e=function(){return xP(arguments.length<=0?void 0:arguments[0],bP(...arguments))},p1e={n:mP,ne:u1e,e:gP,se:f1e,s:xP,sw:h1e,w:bP,nw:d1e};function m1e(e,t,n,r){const s=p1e[e];return s?s(t,{...t,...n},r):n}function g1e(e){let{top:t,left:n,width:r,height:s}=e;const o=`translate(${n}px,${t}px)`;return{transform:o,WebkitTransform:o,MozTransform:o,msTransform:o,OTransform:o,width:`${r}px`,height:`${s}px`,position:"absolute"}}function b1e(e){let{top:t,left:n,width:r,height:s}=e;return{top:`${t}px`,left:`${n}px`,width:`${r}px`,height:`${s}px`,position:"absolute"}}function yP(e,t){return t==="horizontal"?nZ(e):t==="vertical"?tZ(e):e}function tZ(e){return e.slice(0).sort(function(t,n){return t.y>n.y||t.y===n.y&&t.x>n.x?1:t.y===n.y&&t.x===n.x?0:-1})}function nZ(e){return e.slice(0).sort(function(t,n){return t.x>n.x||t.x===n.x&&t.y>n.y?1:-1})}function x1e(e,t,n,r,s){e=e||[];const o=[];Dx.default.Children.forEach(t,a=>{if((a==null?void 0:a.key)==null)return;const c=fP(e,String(a.key)),u=a.props["data-grid"];c&&u==null?o.push(Jf(c)):u?(s1e||rZ([u],"ReactGridLayout.children"),o.push(Jf({...u,i:a.key}))):o.push(Jf({w:1,h:1,x:0,y:dP(o),i:String(a.key)}))});const i=ZK(o,{cols:n});return s?i:GK(i,r,n)}function rZ(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const n=["x","y","w","h"];if(!Array.isArray(e))throw new Error(t+" must be an array!");for(let r=0,s=e.length;r<s;r++){const o=e[r];for(let i=0;i<n.length;i++){const a=n[i],c=o[a];if(typeof c!="number"||Number.isNaN(c))throw new Error(`ReactGridLayout: ${t}[${r}].${a} must be a number! Received: ${c} (${typeof c})`)}if(typeof o.i<"u"&&typeof o.i!="string")throw new Error(`ReactGridLayout: ${t}[${r}].i must be a string! Received: ${o.i} (${typeof o.i})`)}}function y1e(e){const{verticalCompact:t,compactType:n}=e||{};return t===!1?null:n}const v1e=()=>{};Cn.noop=v1e;var Ul={};Object.defineProperty(Ul,"__esModule",{value:!0});Ul.calcGridColWidth=fj;Ul.calcGridItemPosition=w1e;Ul.calcGridItemWHPx=fM;Ul.calcWH=C1e;Ul.calcXY=S1e;Ul.clamp=Tf;function fj(e){const{margin:t,containerPadding:n,containerWidth:r,cols:s}=e;return(r-t[0]*(s-1)-n[0]*2)/s}function fM(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function w1e(e,t,n,r,s,o){const{margin:i,containerPadding:a,rowHeight:c}=e,u=fj(e),d={};return o&&o.resizing?(d.width=Math.round(o.resizing.width),d.height=Math.round(o.resizing.height)):(d.width=fM(r,u,i[0]),d.height=fM(s,c,i[1])),o&&o.dragging?(d.top=Math.round(o.dragging.top),d.left=Math.round(o.dragging.left)):o&&o.resizing&&typeof o.resizing.top=="number"&&typeof o.resizing.left=="number"?(d.top=Math.round(o.resizing.top),d.left=Math.round(o.resizing.left)):(d.top=Math.round((c+i[1])*n+a[1]),d.left=Math.round((u+i[0])*t+a[0])),d}function S1e(e,t,n,r,s){const{margin:o,containerPadding:i,cols:a,rowHeight:c,maxRows:u}=e,d=fj(e);let f=Math.round((n-i[0])/(d+o[0])),h=Math.round((t-i[1])/(c+o[1]));return f=Tf(f,0,a-r),h=Tf(h,0,u-s),{x:f,y:h}}function C1e(e,t,n,r,s,o){const{margin:i,maxRows:a,cols:c,rowHeight:u}=e,d=fj(e);let f=Math.round((t+i[0])/(d+i[0])),h=Math.round((n+i[1])/(u+i[1])),p=Tf(f,0,c-r),g=Tf(h,0,a-s);return["sw","w","nw"].indexOf(o)!==-1&&(p=Tf(f,0,c)),["nw","n","ne"].indexOf(o)!==-1&&(g=Tf(h,0,a)),{w:p,h:g}}function Tf(e,t,n){return Math.max(Math.min(e,n),t)}var hj={},hM={exports:{}},Yw={exports:{}},er={};/** @license React v16.13.1
756
756
  * react-is.production.min.js
757
757
  *
758
758
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -1408,4 +1408,4 @@ Defaulting to \`null\`.`}var Pde=Mde,qft=Rde;const o$=Q.forwardRef(({className:e
1408
1408
  More info: ${s.docs}`:"",a=typeof s.message=="string"&&s.message.trim()?s.message.trim():typeof s.error=="string"&&s.error.trim()?s.error.trim():null;if(a){const c=o?` (code: ${o})`:"",u=o==="insufficient_quota"||a.toLowerCase().includes("quota")?`
1409
1409
 
1410
1410
  Semaphor supports bring-your-own OpenAI API keys. Add yours in Settings or drop a note to support@semaphor.cloud and we’ll help you get set up.`:"";return`${a}${c}${i}${u}`}return null};if(typeof e=="string"){const r=e.trim();if(!r)return"Something went wrong.";try{const s=JSON.parse(r),o=t(s);if(o)return o}catch{}return r}const n=t(e);if(n)return n;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function T$({errorMessage:e}){return l.jsxs("div",{className:"flex items-start gap-2 rounded-control border border-red-300 bg-red-50/60 p-2 text-[12px] text-red-700 dark:border-red-900/60 dark:bg-red-950/20 dark:text-red-300",children:[l.jsx(ra,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),l.jsx("span",{className:"whitespace-pre-wrap break-words leading-[1.55]",children:B0t(e)})]})}function V0t({error:e,resetErrorBoundary:t}){return l.jsxs("div",{className:"my-3 space-y-2 rounded-control border border-border/60 bg-muted/20 p-2.5",children:[l.jsx(T$,{errorMessage:e==null?void 0:e.message}),l.jsx("button",{type:"button",className:"text-[11px] font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground",onClick:t,children:"Try again"})]})}function H0t({text:e,files:t}){return l.jsxs(fhe,{who:"You",children:[e&&l.jsx("div",{className:"whitespace-pre-line text-[13px] leading-[1.55] text-foreground",children:e}),t&&t.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 pt-0.5",children:t.map(n=>l.jsx(Yft,{file:n},n.id))})]})}function U0t({text:e}){const t=e.split("|"),n=t[0],r=t[1]||"{}",s=JSON.parse(r);return l.jsxs("div",{className:"space-y-1 text-xs",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-bold",children:"System Message:"})," ",n]}),l.jsxs("div",{className:"space-y-1",children:[l.jsx("span",{className:"font-mono text-xs",children:"Scope:"}),l.jsx(dht,{children:JSON.stringify(s,null,2)})]})]})}function hhe(e,t){return!e||e.role!=="assistant"?!1:(e.parts??[]).some(r=>{if(!r)return!1;switch(r.type){case"text":return typeof r.text=="string"&&r.text.trim().length>0;case"reasoning":return typeof r.text=="string"&&r.text.trim().length>0||r.state==="streaming";case"error":return!0;default:return typeof r.type=="string"&&(r.type.startsWith("tool-")||r.type==="dynamic-tool")?E$(r,t):!1}})}function _q(){return l.jsx("span",{className:"relative grid h-2 w-2 shrink-0 place-items-center",children:l.jsx("span",{className:"absolute inset-0 animate-pulse rounded-full bg-muted-foreground/70"})})}function q0t({status:e,errorMessage:t,activeToolText:n}){return n?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(_q,{}),l.jsx("span",{children:n})]}):e==="submitted"||e==="streaming"?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(_q,{}),l.jsx("span",{children:e==="submitted"?"Thinking":"Generating"})]}):e==="error"?l.jsx(T$,{errorMessage:t}):null}function W0t(e){var t;return e?(t=[...e].reverse().find(n=>{var r;return n.role==="assistant"&&((r=n.parts)==null?void 0:r.some(s=>s.type==="text"&&typeof s.text=="string"&&s.text.trim().length>0))}))==null?void 0:t.id:void 0}function Y0t({message:e,messageIndex:t,messages:n,showTools:r=!1,onAddToDashboard:s,showSystemMessage:o=!1,handleRun:i,onQuickReply:a,disableQuickReplies:c=!1}){var y,S,w,C;const u=W0t(n),d=e.id===u;if(e.role==="user"){const N=((y=e.parts)==null?void 0:y.filter(T=>T.type==="text"))||[],k=((S=e.parts)==null?void 0:S.filter(T=>T.type==="file"))||[],j=N.map(T=>T.text).join(`
1411
- `).trim(),_=k.map((T,E)=>{var A,P;let I="",D;if((A=T.url)!=null&&A.startsWith("data:")){const R=T.url.match(/data:[^;]+;base64,(.+)/);R&&(I=R[1],(P=T.mediaType)!=null&&P.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${E}`,name:T.filename||`File ${E+1}`,size:0,type:T.mediaType||"application/octet-stream",data:I,preview:D}});return l.jsx(H0t,{text:j||void 0,files:_.length>0?_:void 0})}const f=((w=e.parts)==null?void 0:w.filter(N=>N.type==="reasoning"))||[],h=f.length>0,p=f.some(N=>N.state==="streaming"),g=f.filter(N=>N.text&&N.text.trim().length>0),b=h&&(g.length>0||p)?l.jsxs(Zc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Xc,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(vr,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:p?"animate-pulse":"",children:p?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(Qc,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,k)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:k+1}),l.jsx(yq,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${k}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,k)=>{var _;const j=`${e.id||t}-${k}`;switch(N.type){case"text":{const T=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:E,quickReplies:I}=$0t(T),D=E.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(yq,{text:E,handleRun:i,onAddToDashboard:s,messageId:e.id,messages:n}),I.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[I.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(({label:A,value:P},R)=>l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(P),children:l.jsx("span",{className:"truncate",children:A})})}),l.jsx(m.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${j}-qr-${R}`))})]})]},j)}return e.role==="system"&&o?l.jsx(U0t,{text:T},j):null}case"error":{const T=N,E=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(T$,{errorMessage:E})},j)}case"reasoning":return null;default:return((_=N.type)!=null&&_.startsWith("tool-")||N.type==="dynamic-tool")&&E$(N,r)?l.jsx(za,{FallbackComponent:({error:T,resetErrorBoundary:E})=>l.jsx(V0t,{error:T,resetErrorBoundary:E}),children:l.jsx(R0t,{part:N,idx:j,messageId:e.id,showTools:r,onAddToDashboard:s,messages:n})},j):null}});return e.role==="assistant"?hhe(e,r)?l.jsxs(fhe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const G0t=8,K0t=24,Z0t=20;function X0t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function phe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:s,onQuickReply:o,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:p,scrollToEndSignal:g=0}){const b=v.useRef(null),x=v.useRef(null),y=v.useRef(e.length),S=v.useRef(!1),w=v.useRef(null),C=v.useRef(!1),N=v.useRef(g),[k,j]=v.useState(!0),[_,T]=v.useState(0),[E,I]=v.useState(K0t);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],A=hhe(D,t),P=X0t(a,c,u,A),R=a_({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const O=e[W];return(O==null?void 0:O.role)==="user"?88:180},getItemKey:W=>{const O=e[W];return(O==null?void 0:O.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:G0t,overscan:6,gap:20,paddingEnd:P?E+Z0t:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const O=W.isAtEnd();j(Z=>Z===O?Z:O),O&&T(0)}}),H=v.useCallback((W="smooth")=>{w.current!==null&&cancelAnimationFrame(w.current),w.current=requestAnimationFrame(()=>{w.current=null,R.scrollToEnd({behavior:W})}),T(0),j(!0)},[R]);v.useLayoutEffect(()=>{S.current||(S.current=!0,H("auto"))},[H]),v.useLayoutEffect(()=>{C.current&&(C.current=!1,H("auto"))},[e.length,g,H]),v.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!R.isAtEnd()&&T(O=>O+e.length-W),e.length===0&&(T(0),j(!0),S.current=!1,C.current=!1)},[e.length,R]);const z=R.getVirtualItems(),U=R.getTotalSize();return v.useEffect(()=>()=>{w.current!==null&&cancelAnimationFrame(w.current)},[]),v.useLayoutEffect(()=>{const W=x.current;if(!W||!P)return;const O=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&I(M=>M===Y?M:Y)};if(O(),typeof ResizeObserver>"u")return;const Z=new ResizeObserver(O);return Z.observe(W),()=>Z.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(Kl,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:m.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:U},children:[z.map(W=>{const O=e[W.index];return O?l.jsx("div",{ref:R.measureElement,"data-index":W.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${W.start}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(Y0t,{message:O,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:s,onQuickReply:o,disableQuickReplies:i})})},W.key):null}),P&&l.jsx("div",{ref:x,className:m.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(U-E,0)}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(q0t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!k&&l.jsxs("button",{type:"button",onClick:()=>H("smooth"),"aria-label":"Scroll to latest",className:m.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",p),children:[l.jsx(Hs,{className:"h-3 w-3"}),"Latest",_>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:_>9?"9+":_})]})]})}function Q0t(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const J0t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function evt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:s}){const[o,i]=v.useState(!1),[a,c]=v.useState(m.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[p,g]=v.useState(!1),[b,x]=v.useState(!1),[y,S]=v.useState(0),w=n??b,{isLocalDev:C,isConsoleMode:N}=jg(),k=C||N||a,j=v.useRef(null);m.useDashboardStore(te=>te.dashboard.aiScopeTables),m.useDashboardStore(te=>te.isDashboardEditing);const _=m.useDashboardStore(te=>te.selectedSheetId),{setDataSource:T}=m.useEditorActions(),{setSelectedFrameId:E,setIsDashboardEditing:I}=m.useDashboardActions(),D=QL(),{clearAssistantMessageContexts:A}=m.useAIActions(),{clearQueue:P}=m.useQueueActions(),{clearFileAttachments:R,getFileAttachments:H}=m.useFileActions(),z=m.useFileAttachments("dashboard"),U=m.useEditorStore(te=>te.card.dataSource),{assistantProfile:W}=kde(),O=m.useDashboardStore(te=>te.handleOpenAssistantProfile),{selectedEntities:Z,applyDashboardDefaultEntities:Y}=U_("dashboard"),{sendMessage:M,isLoading:G,messages:L,setMessages:$,status:B,stop:V,errorMessage:F,clearError:q}=jft({dynamicVisualMode:f}),K=v.useCallback(()=>{S(te=>te+1)},[]),X=v.useCallback(te=>{r==null||r(te),n===void 0&&x(te)},[n,r]),ee=v.useCallback(()=>{X(!w)},[w,X]);v.useEffect(()=>{if(!w)return;function te(Se){Se.key==="Escape"&&X(!1)}return window.addEventListener("keydown",te),()=>{window.removeEventListener("keydown",te)}},[w,X]);const[de,fe]=v.useState(""),ge=te=>{fe(te.target.value)};async function ve({sql:te,cardTitle:Se,connectionId:we,cardType:ne,python:_e,cardConfig:Pe,dataSource:$e,customVisualPreferences:Xe,visualizationMode:Ue,dynamicCardPreferences:We}){if(!_)return;const Qe=Ue==="dynamic",je=m.hasValidCardConfig(Pe),tt=we||($e==null?void 0:$e.connectionId)||"",ze=$e?{...$e,connectionId:tt||$e.connectionId,connectionType:$e.connectionType||"",mode:$e.mode||"database",selectedEntities:$e.selectedEntities||[]}:tt?{connectionId:tt,connectionType:"",mode:"database",selectedEntities:[]}:yg,it=!(je&&(!Qe||(We==null?void 0:We.provenance)==="card-config"||(We==null?void 0:We.provenance)==="query_spec")),Fe=it?Q0t(te):"",Ie=it?_e:"",Ze={id:m.v4(),title:Se||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:ne==="horizontalBar"?"y":"x"},...Qe&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:ne,sql:Fe,python:Ie,dataSource:ze,config:Pe,connectionId:tt,visualizationMode:Ue,dynamicCardPreferences:We,customCardPreferences:Xe?{url:Xe.url,componentName:Xe.componentName,pluginChartType:Xe.pluginChartType,settings:Xe.settings,type:"component"}:void 0},yt={id:m.v4(),cards:[Ze],activeCardId:Ze.id};try{await D(_,yt,"end"),I(!0),E(yt.id)}catch(St){console.error("Failed to add assistant visual to dashboard:",St),at.error(St instanceof Error?St.message:"Failed to prepare semantic metadata for the new visual")}}const ie=te=>{te.preventDefault();const Se=de.trim();if(!Se&&z.length===0)return;const we=[];Se&&we.push({type:"text",text:Se}),z.forEach(ne=>{ne.data&&we.push({type:"file",mediaType:ne.type,filename:ne.name,url:`data:${ne.type};base64,${ne.data}`})}),M({role:"user",parts:we}),fe(""),R("dashboard"),K()};v.useEffect(()=>{var te;e&&((te=j.current)==null||te.focus())},[e]),Vde({assistantType:"dashboard",status:B,isLoading:G,sendMessage:M});const{hasActiveTools:be,activeToolText:oe}=Hde(L);function Ae(te){const Se={role:"user",parts:[{type:"text",text:te.title+" "+te.subtitle}]};M(Se),K()}function ae(te){M({role:"user",parts:[{type:"text",text:te}]}),K()}function me(te){M({role:"user",parts:[{type:"text",text:te}]}),K()}const Ce=v.useCallback(async()=>{const te=JSON.stringify(L??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(te),at.success("Conversation copied")}catch(Se){console.error("Failed to copy conversation",Se),at.error("Unable to copy conversation")}},[L]),se=(de==null?void 0:de.length)===0&&(L==null?void 0:L.filter(te=>te.role==="user").length)===0;function re(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function J(){return l.jsxs(Lo,{children:[l.jsx($o,{asChild:!0,children:l.jsx(Rc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(qh,{className:"size-3.5"})})}),l.jsxs(xo,{align:"end",children:[l.jsx(Fc,{children:"Options"}),l.jsx(Fa,{}),l.jsx(Nu,{checked:o,onCheckedChange:i,children:"Token Usage"}),l.jsx(Nu,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(Nu,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(Fa,{}),l.jsx(Fc,{children:"Dynamic Visuals"}),l.jsx(Nu,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(Nu,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(Nu,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const he=l.jsxs("div",{"data-role":"dashboard-assistant",className:m.cn("relative flex h-full grow flex-col break-words bg-background",w&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[re(),O&&l.jsxs("button",{type:"button",onClick:O,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(W==null?void 0:W.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[N&&J(),k&&l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:Ce,children:"Copy Conversation"}),l.jsx(Rc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:w?"Exit fullscreen":"Expand",onClick:ee,children:w?l.jsx(IF,{className:"h-3.5 w-3.5"}):l.jsx(Bk,{className:"h-3.5 w-3.5"})}),l.jsx(Rc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const te=L.filter(Se=>Se.role==="assistant").map(Se=>Se.id).filter(Se=>!!Se);$([]),P("dashboard"),q(),A(te)},children:l.jsx(Hk,{className:"h-3.5 w-3.5"})}),l.jsx(Rc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(m.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(phe,{messages:L,showTools:a,showSystemMessage:u,onAddToDashboard:ve,onQuickReply:me,disableQuickReplies:G,status:B,errorMessage:F,activeToolText:G&&be?oe:void 0,className:m.cn(w?"px-6 py-5":"px-3 py-3"),rowContentClassName:m.cn(w&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!W&&se&&l.jsx(sue,{onClick:Ae,placeholders:J0t}),se&&W&&l.jsx(jde,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:ae}),l.jsx(Bde,{assistantType:"dashboard"}),l.jsx(l$,{ref:j,setInput:fe,stop:V,input:de,handleInputChange:ge,handleSubmit:te=>{ie(te)},isLoading:G,status:B,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(a$,{incomingSelectedEntities:Z,open:p,onOpenChange:g,dataSource:U||yg,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:te=>Y()})]});return w&&s?Rr.createPortal(l.jsx(fb,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:he})}),s):he}function tvt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=m.useDashboardActions(),s=eae(),o=m.useDashboardStore(d=>d.dashboard.sheets),a=m.useDashboardStore(d=>d.selectedSheetId)??(o==null?void 0:o[0].id),c=m.useDashboardStore(d=>d.isDashboardEditing),u=m.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(p){if(nvt(p.target))return;const g=p.ctrlKey||p.metaKey;g&&p.key==="c"?(await f(),at.success("Card copied to clipboard"),p.preventDefault()):g&&p.key==="v"&&(await h(),p.preventDefault())}async function f(){try{const p=n();p&&await navigator.clipboard.writeText(JSON.stringify(p))}catch(p){console.error("Failed to copy text:",p)}}async function h(){if(!a)return null;try{const p=await navigator.clipboard.readText(),g=rvt(p);if(g!=null&&g.id){const b=Xie(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await s(a,b),r(b.id),at.success("Card pasted from clipboard")}return p}catch(p){return console.error("Failed to paste text:",p),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[s,n,r,a,c,u,t])}function nvt(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function rvt(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function svt(e,t){switch(e.interactionMode){case"drillToDetail":ovt(e,t);break;case"drillThrough":ivt(e,t);break;case"drillToURL":avt(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function ovt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:s,filterGroups:o}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=o.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=o.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}s==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function ivt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:s,sourceCardId:o}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=s.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function avt(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function lvt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:s,contextMode:o,cardTitle:i,cardDescription:a}){return l.jsx(Vo,{open:e,onOpenChange:t,children:l.jsxs(wo,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(da,{children:[l.jsx(So,{children:i||"Insight Detail"}),l.jsx(fi,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(rae,{filters:r,filterDefinitions:s,contextMode:o}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(bae,{insightId:n,filters:r,contextMode:o}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function cvt(){const e=m.useInteractionStore(C=>C.interactionStates),t=m.useInteractionStore(C=>C.setInteractionState),n=m.useInteractionStore(C=>C.clearLastInteractionEvent),r=m.useInteractionStore(C=>C.replaceCardWithInsight),s=m.useInteractionStore(C=>C.setPendingDrillThrough),o=m.useInteractionStore(C=>C.pendingDrillThrough),i=m.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=m.useDashboardActions(),{selectDashboard:u}=Hh(),d=m.useDashboardStore(C=>C.dashboard),f=m.useDashboardStore(C=>C.filterValues),{data:h,isLoading:p}=iG((o==null?void 0:o.targetDashboardId)||"",{enabled:!!(o!=null&&o.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=xae(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),S=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:k})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:k})},replaceCardContent:({cardId:C,insightId:N,filters:k,contextMode:j})=>{r(C,N,k,j)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:s,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:k,sourceDashboardTitle:j,targetDashboardId:_})=>{const T={filters:C},E={sourceCardId:m.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},I={...m.createInitialInteractionState(),appliedClickFilters:[E],contextMode:N,sourceDashboardId:k,sourceDashboardTitle:j,targetDashboardId:_};t(m.DRILL_CONTEXT_CARD_ID,I)}}),[a,r,f,c,d,s,t]);v.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const k=N.lastInteractionEvent,j=`${C}-${k.interactionMode}-${k.sourceCardId}-${Date.now()}`;if(y.current.has(j))return;y.current.add(j);try{svt(k,S)}catch(_){console.error("Error executing interaction event:",_)}finally{n(C),setTimeout(()=>{y.current.delete(j)},5e3)}}})},[e,n,S]),v.useEffect(()=>{if(!(!o||!h||p))try{u(h),c(o.targetDashboardId,o.sourceDashboardId,o.sourceDashboardTitle,o.filters,o.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[o,h,p,u,c,i]);const w=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(lvt,{open:g.open,onOpenChange:w,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),o&&p&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function uvt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,s=dvt(t.value);return r==="="?`${n} = ${s}`:`${n} ${r} ${s}`}).join(", ")}function dvt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function fvt(e){return e?`Back to ${e}`:"Back"}function hvt(){var y,S,w,C,N;const e=m.useInteractionStore(k=>k.interactionStates[m.DRILL_CONTEXT_CARD_ID]),t=m.useDashboardStore(k=>k.actions.goBackFromDrill),n=m.useDashboardStore(k=>k.actions.clearDrillContext),{selectDashboard:r}=Hh(),[s,o]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const k=_=>{o({x:_.clientX-c.current.x,y:_.clientY-c.current.y})},j=()=>{a(!1)};return document.addEventListener("mousemove",k),document.addEventListener("mouseup",j),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",j)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((C=(w=(S=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:S.filterGroups)==null?void 0:w[0])==null?void 0:C.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((N=e.appliedClickFilters)!=null&&N.length))return null;const p=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(k){console.error("[DrillBack] Error during back navigation:",k)}},g=()=>{n()},b=k=>{k.target.closest("button")||(a(!0),c.current={x:k.clientX-s.x,y:k.clientY-s.y})};uvt(f);const x=fvt(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${s.x}px, ${s.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((k,j)=>{const _=k.field.label||k.field.name,T=String(k.value);return l.jsxs(ws,{variant:"secondary",className:"pointer-events-none text-xs",children:[_," = ",T]},j)})})]}),l.jsx(m.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(m.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(m.Button,{variant:"secondary",size:"sm",onClick:p,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(hv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function pvt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function mvt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:p,transition:g,isDragging:b}=yb({id:`filter:${e.id}`,disabled:n||!t}),x={transform:Fi.Translate.toString(p),transition:g,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:h,style:x,...d,children:l.jsx(ML,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const Eq="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",gvt=[];function mhe({open:e,onOpenChange:t}){var L,$,B;const[n,r]=v.useState(!1),[s,o]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=m.useDashboardStore(V=>{var F;return(F=V.dashboard)==null?void 0:F.sheets}),u=m.useDashboardStore(V=>V.dashboard),d=m.useDashboardStore(V=>V.dashboardInputValues),f=m.useDashboardStore(V=>V.filterValues),h=m.useDashboardStore(V=>V.controlValues),p=m.useDashboardStore(V=>V.inlineFilterValuesMap),g=m.useDashboardStore(V=>V.cardControlValuesMap),b=m.useDashboardStore(V=>V.selectedSheetId),x=m.useDashboardStore(V=>V.selectedSheetId?V.documentInputRuntimeBySheetId[V.selectedSheetId]:void 0),y=m.useDashboardStore(V=>V.isDownloadingPdf),{authToken:S,tokenProps:w}=Ct(),C=c==null?void 0:c.find(V=>V.id===b),N=v.useMemo(()=>m.getDashboardExportSheets(c),[c]),k=m.isDocumentSheet(C),j=k&&C?C.document:void 0,_=v.useMemo(()=>k&&C?Nw(u,C.id):[],[C,k,u]),T=_.length>0,E=v.useMemo(()=>k&&C?eue(u,C.id):!1,[C,k,u]),I=v.useMemo(()=>T?_.map(kw):(j==null?void 0:j.inputs)||gvt,[j,_,T]),D=(($=(L=w==null?void 0:w.params)==null?void 0:L.calendarContext)==null?void 0:$.tz)||((B=w==null?void 0:w.params)==null?void 0:B.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),A=v.useMemo(()=>ece(I),[I]),P=v.useMemo(()=>Qle(I,D),[I,D]),R=v.useMemo(()=>Jle(I),[I]),H=x?x.filterValuesByInputId:P,z=x?x.controlValuesByInputId:R,U=v.useMemo(()=>k?E&&C&&j?hX({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:j.sections.map(V=>V.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},timezone:D}):rce(I,H,z,A,A):[],[j,I,C,k,u,g,h,f,p,d,z,H,A,D,E]),W=!!C,O=N.length>0,Z=((c==null?void 0:c.length)||0)>1||k,Y=i.sheetSelection==="current"&&(!W||k&&U.length>0)||i.sheetSelection==="all"&&!O;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!O&&a(V=>({...V,sheetSelection:"current"}))},[O,e,i.sheetSelection]);const M=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function G(){if(y){at.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){at.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){at.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!O){at.error("No dashboard sheets are available to export");return}o(!0);const V=i.sheetSelection==="current"&&k,F=V?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",q=at.loading(F);try{if(V){if(!j||!C)throw new Error("Selected document sheet is missing document data");if(U.length>0){at.dismiss(q),at.error(`Set ${U.join(", ")} before exporting`);return}const X=new Date().toISOString(),ee=E?mX({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:j.sections.map(de=>de.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},generatedAt:X,timezone:D}).snapshot:void 0;await QP(w.apiServiceUrl,S,{sheetId:C.id,title:C.title||"Document",pageSize:j.page.size,orientation:j.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:ee,...ee?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:H,controlValuesByInputId:z,generatedAt:X}}})}else{const X=Hee();await SX(w.apiServiceUrl,S,i.protectPdf?i.password:void 0,i.sheetSelection,X)}at.dismiss(q);const K=V?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";at.success(K,{duration:2e3}),M()}catch(K){at.dismiss(q),at.error("Failed to download PDF",{description:Dj(K,"Please try again or contact support."),descriptionClassName:Ij,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",K)}finally{o(!1)}}return l.jsx(Vo,{open:e,onOpenChange:V=>{if(!V){M();return}t(!0)},children:l.jsxs(wo,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(da,{children:[l.jsx(So,{className:"text-[15px]",children:k?"Export document":"Export dashboard"}),l.jsx(fi,{className:"text-[13px] leading-5",children:k?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[Z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(m.Label,{className:Eq,children:"Export scope"}),l.jsxs(Oa,{value:i.sheetSelection,onValueChange:V=>a({...i,sheetSelection:V}),className:"gap-1.5",children:[l.jsxs(m.Label,{htmlFor:"scope-current",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!W&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Rs,{value:"current",id:"scope-current",disabled:!W}),k?"This document":"This sheet"," (",(C==null?void 0:C.title)||"Current",")"]}),l.jsxs(m.Label,{htmlFor:"scope-all",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!O&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Rs,{value:"all",id:"scope-all",disabled:!O}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),k&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:U.length>0?`Set ${U.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(m.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(m.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(Vn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:V=>{a({...i,protectPdf:V,password:V?i.password:""}),V||r(!1)}}),l.jsx(zk,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(m.Label,{htmlFor:"pdf-password",className:Eq,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(m.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:V=>a({...i,password:V.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:V=>{V.key==="Enter"&&i.password&&G()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx($k,{className:"h-3.5 w-3.5"}):l.jsx(pv,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(nu,{children:[l.jsx(m.Button,{variant:"outline",size:"xs",onClick:M,disabled:s,children:"Cancel"}),l.jsx(m.Button,{size:"xs",onClick:G,disabled:s||y||Y,children:s?l.jsxs(l.Fragment,{children:[l.jsx(m.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(eu,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function ghe({iconClassName:e,open:t,onOpenChange:n}){const[r,s]=v.useState(!1),o=t!==void 0,i=o?t:r,a=u=>{o||s(u),n==null||n(u)},c=m.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[o?null:l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(eu,{className:m.cn("size-4",e)})}),l.jsx(mhe,{open:i,onOpenChange:a})]})}function Tq(e,t,n){const r=new Set(t),s=[...n];return e.map(o=>r.has(o.id)?s.shift()??o.id:o.id)}function bvt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:s,listeners:o,setNodeRef:i,transform:a,transition:c,isDragging:u}=yb({id:`control:${e.id}`,disabled:!n}),d={transform:Fi.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...s,children:l.jsx(bce,{control:e,value:t,isEditing:n,dragListeners:n?o:void 0,onChange:r})})}function Iq(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function Dq(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function xvt(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return Dq(t,n);const s=e.filter(a=>r.has(a)),o=new Set(s),i=Dq(t,n).filter(a=>!o.has(a));return[...s,...i]}function yvt(e,t){return m.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function vvt(e){return Ym(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Ym(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function Mq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function wvt(e){const t={sheetId:e.selectedSheetId},n=m.getDashboardInputRuntimeSlot(e.dashboardInputValues,e.dashboardInput,t);if(n)return n;const r=m.getDashboardInputRuntimeSlot(e.defaultInputValues,e.dashboardInput,t);return r||m.getBackingDefaultSlot(e.dashboardInput)}function Svt(e){return bhe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function bhe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=yvt(e.dashboard,t);return AZ(Cj({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!vvt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function Cvt(e,t){return"toolbar"}function Nvt(){const e=su("interactive"),t=m.useDashboardStore($=>$.selectedSheetId),n=m.useDashboardStore($=>$.dashboard.filters),r=m.useDashboardStore($=>$.dashboard.filterLayout),s=m.useDashboardStore($=>$.isDashboardEditing),o=m.useDashboardStore($=>$.controlValues),i=m.useDashboardStore($=>$.filterValues);m.useDashboardStore($=>$.filteringCards);const a=m.useDashboardStore($=>$.inlineFilterValuesMap),c=m.useDashboardStore($=>$.dashboardInputValues),u=m.useInteractionStore($=>$.clearAllClickFilters),d=m.useInteractionStore($=>Object.entries($.interactionStates).reduce((B,[V,F])=>{var q;return V===m.DRILL_CONTEXT_CARD_ID?B:B+(((q=F.appliedClickFilters)==null?void 0:q.length)??0)},0)),f=m.useDashboardStore($=>$.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:p,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:S,setFilteringCards:w,upsertDashboardInput:C}=m.useDashboardActions(),N=G_(gg(bb,{activationConstraint:{distance:5}})),k=m.useDashboardStore($=>$.dashboard),j=Svt({dashboard:k,selectedSheetId:t}).filter($=>Cvt($.filter)==="toolbar"),_=bhe({dashboard:k,selectedSheetId:t}),T=j.map($=>$.filter),E=new Map(j.map($=>[`filter:${$.filter.id}`,$])),I=fZe(k),D=I.filter($=>!$.hidden&&O0($)==="toolbar"),A=I.filter($=>!$.hidden&&O0($)==="advanced"),P=xvt(r==null?void 0:r.toolbarItemOrder,T,D),R=new Map(T.map($=>[`filter:${$.id}`,$])),H=new Map(D.map($=>[`control:${$.id}`,$]));function z($){const{active:B,over:V}=$;if(!V||B.id===V.id)return;const F=String(B.id),q=String(V.id),K=P.findIndex(be=>be===F),X=P.findIndex(be=>be===q);if(K===-1||X===-1)return;const ee=xb(P,K,X);y({toolbarItemOrder:ee});const de=new Set((n||[]).map(be=>be.id)),fe=P.filter(be=>be.startsWith("filter:")).map(be=>be.replace("filter:","")).filter(be=>de.has(be)),ge=ee.filter(be=>be.startsWith("filter:")).map(be=>be.replace("filter:","")).filter(be=>de.has(be)),ve=P.filter(be=>be.startsWith("control:")).map(be=>be.replace("control:","")),ie=ee.filter(be=>be.startsWith("control:")).map(be=>be.replace("control:",""));h(Tq(n||[],fe,ge)),g(Tq(k.controls||[],ve,ie))}const U=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,O=(i==null?void 0:i.filter($=>Iq($)).length)??0,Z=_.filter(Mq),Y=Z.filter($=>{const B=wvt({dashboardInput:$,dashboardInputValues:c,defaultInputValues:k.defaultInputValues,selectedSheetId:t});return(B==null?void 0:B.status)==="set"&&B.value.kind==="filter"&&Iq(B.value.filterValue)}).length,M=a?Object.values(a).reduce(($,B)=>$+((B==null?void 0:B.length)??0),0):0,G=O+Y+M+d,L=()=>{S([]),Z.forEach($=>{p($,{sheetId:t})}),w([]),u(),a&&Object.entries(a).forEach(([$,B])=>{B==null||B.forEach(V=>{f($,V.filterId)})})};return!T.length&&!D.length&&!A.length&&!W&&G===0?null:l.jsx("div",{className:"z-20 border-b border-border/60 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(xw,{sensors:N,collisionDetection:mw,onDragEnd:z,children:l.jsxs("div",{className:m.cn("flex items-center",U?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(yw,{items:P,strategy:a3,children:l.jsx(zR,{className:"gap-3 pr-0",wrap:U,children:P.map($=>{const B=R.get($);if(B){const F=E.get($),q=F&&Mq(F);return l.jsx(mvt,{filter:B,isEditing:s,storageOptions:q?{storageTarget:"dashboardInput",dashboardInput:F,sheetId:t??void 0}:void 0,inputVariableName:q?F.variableName:void 0,onUpdateFilter:q?(K,X)=>{C({...F,variableName:(X==null?void 0:X.variableName)||F.variableName,filter:K})}:void 0,onRemoveFilter:q?()=>{S((i||[]).filter(K=>K.filterId!==B.id)),b(F.id)}:void 0},$)}const V=H.get($);return V?l.jsx(bvt,{control:V,value:o==null?void 0:o[V.id],isEditing:s,onChange:F=>x(V.id,F)},$):null})})}),A.length>0&&l.jsx(fae,{title:"",controls:A,values:o,onChange:($,B)=>x($.id,B),immediatePlacement:"toolbar",advancedLabel:"More controls"}),G>0&&l.jsxs("button",{type:"button",onClick:L,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(m.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:G})]}),W&&l.jsx("div",{className:m.cn(G>0?"ml-1.5":"ml-auto"),children:l.jsx(ghe,{})})]})})})}function xhe(){var J,he;const{showAssistant:e,tokenProps:t,renderMode:n}=Ct(),r=pvt((J=t.config)==null?void 0:J.showDashboardAssistant,e),{preferences:s,isConsoleMode:o}=jg(),i=(he=s==null?void 0:s.cardDisplay)==null?void 0:he.mode,a=Qh(i),c=XZ({displayMode:i,renderMode:n}),u=v.useRef(null),d=v.useRef(null),[f,h]=v.useState(!1),{handleDragStart:p,isDraggingRef:g,getStyle:b,getPositionClasses:x}=hit({initialPosition:"bottom-right"}),y=Qf(te=>te.setFullscreen),S=Qf(te=>te.setPanelOpen),w=Qf(te=>te.setContainer),C=zK("dashboard"),N=BK(),k=VK("dashboard"),j=C.isOpen,_=N==="dashboard",T=m.useDashboardStore(te=>te.isVisualEditing),E=m.useDashboardStore(te=>te.themeStyle),I=Hl(),D=m.useDashboardStore(te=>{var Se;return(Se=te.dashboard)==null?void 0:Se.sheets}),A=m.useDashboardStore(te=>te.showFilters),P=m.useDashboardStore(te=>te.isDashboardEditing),R=m.useDashboardStore(te=>te.selectedSheetId),H=D==null?void 0:D.find(te=>te.id===R),z=m.useDashboardStore(te=>{var Se,we,ne;return(ne=(we=(Se=te.dashboard)==null?void 0:Se.sheets)==null?void 0:we.find(_e=>_e.id===te.selectedSheetId))==null?void 0:ne.kind}),U=m.useDashboardStore(te=>{var Se,we;return((we=(Se=te.dashboard)==null?void 0:Se.summary)==null?void 0:we.position)||"top"}),W=z==="document",O=m.useDashboardStore(te=>{var Se;return(Se=te.dashboard)==null?void 0:Se.id}),Z=m.useDashboardStore(te=>te.isDashboardPanelOpen),Y=m.useDashboardStore(te=>te.actions.setIsDashboardPanelOpen),{getDefaultSheetId:M,setDefaultSheetId:G,clearDefaultSheetId:L}=xW(O),[$,B]=v.useState(null);Zk(rs.DASHBOARD);const{setSelectedSheetId:V,setSheetTitle:F,addSheet:q,setSheets:K}=m.useDashboardActions();tvt(d);const{setActiveAssistantType:X}=m.useAIActions();v.useEffect(()=>{if(O){const te=M();B(te)}},[O,M]),v.useEffect(()=>{j?X("dashboard"):N==="dashboard"&&y(null)},[j,X,N,y]),v.useEffect(()=>{var te;j||(te=u.current)==null||te.resize(0)},[j]);function ee(te){var Se,we;te?((Se=u.current)==null||Se.resize(40),S("dashboard",!0),y("dashboard"),X("dashboard")):(S("dashboard",!1),y(null),(we=u.current)==null||we.resize(0),X(null))}function de(te="dashboard"){const Se={id:m.v4(),title:te==="document"?"New Document":"New Sheet",...te==="document"?{kind:te,document:m.createDefaultDocumentDefinition()}:{}};q(Se),V(Se.id)}function fe(te,Se){if(!O)return;$===te?(L(),B(null),at.success("Default sheet cleared")):(G(te),B(te),at.success(`"${Se}" set as default sheet`))}function ge(te){var Se;te<1?(S("dashboard",!1),y(null),X(null),(Se=u.current)==null||Se.resize(0)):(j||S("dashboard",!0),X("dashboard"))}function ve(){return(E==null?void 0:E.canvasTheme)==="muted"||!(E!=null&&E.canvasTheme)?"hsl(var(--semaphor-muted))":(E==null?void 0:E.canvasTheme)==="clear"?"":E==null?void 0:E.canvasTheme}const ie=(te,Se)=>{te.dataTransfer.setData("tabIndex",Se.toString())},be=te=>{te.preventDefault()},oe=(te,Se)=>{const we=te.dataTransfer.getData("tabIndex");if(we===Se.toString())return;const ne=Array.from(D||[]),[_e]=ne.splice(parseInt(we),1);ne.splice(Se,0,_e),K(ne)},Ae=t.orgUserId||t.tenantId&&t.endUserId&&t.endUserEmail,ae=r===!0&&!a&&!j&&!T&&!A;function me(){if(D&&D.length>1||P)return l.jsxs("div",{className:"relative flex w-full items-stretch border-b border-border",children:[o&&Ae&&!Z&&l.jsx("button",{type:"button","aria-label":"Toggle dashboards panel",onClick:()=>{Y(!Z)},className:"group/panel mx-2 inline-flex h-9 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground",children:l.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-[4px] group-hover/panel:bg-muted",children:l.jsx(DF,{className:"h-3.5 w-3.5",strokeWidth:1.75})})}),l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(m.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[D==null?void 0:D.map((te,Se)=>{const we=R===te.id,ne=$===te.id;return l.jsxs(m.TabsTrigger,{draggable:!0,onDragStart:_e=>ie(_e,Se),onDragOver:be,onDrop:_e=>oe(_e,Se),onClick:()=>V(te.id),className:m.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:te.id,children:[te.kind==="document"&&l.jsx(Ti,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(ZN,{enabled:P&&we,text:te.title,onSave:_e=>F(te.id,_e),children:te.title},te.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ne?"Clear default sheet":"Set as default sheet",title:ne?"Clear default sheet":"Set as default sheet",onClick:_e=>{_e.stopPropagation(),fe(te.id,te.title||"Sheet")},onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),_e.stopPropagation(),fe(te.id,te.title||"Sheet"))},className:m.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",we||ne?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(FF,{className:m.cn("h-3 w-3 transition-colors",ne?"fill-current text-amber-500":"text-muted-foreground")})}),P&&we&&D.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:_e=>{_e.stopPropagation(),h(!0)},onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),_e.stopPropagation(),h(!0))},children:l.jsx(m.X,{className:"h-3 w-3"})})]},te.id)}),P&&l.jsxs(Lo,{children:[l.jsx($o,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(yr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(xo,{align:"start",className:"w-48",children:[l.jsxs(In,{onSelect:()=>de("dashboard"),children:[l.jsx(Vm,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(In,{onSelect:()=>de("document"),children:[l.jsx(Ti,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})]})}function Ce(){return l.jsx("div",{ref:d,style:{},className:"h-full min-h-0 grow",children:D==null?void 0:D.map(te=>l.jsx(m.TabsContent,{style:{backgroundColor:ve(),...I.dashboardCanvasStyle},className:m.cn("mt-0 h-full min-h-0",{}),value:te.id,children:l.jsx(OH,{sheet:te})},te.id))})}function se(){return l.jsxs(m.Tabs,{"data-role":"dashboard-tabs-container",className:m.cn("relative flex h-full flex-col",E==null?void 0:E.dashboardTabsContainer),onValueChange:te=>{V(te)},value:R||void 0,children:[me(),U==="top"&&!W&&l.jsx(vR,{}),R&&!W&&l.jsx(Nvt,{}),W?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:Ce()}):l.jsx(Kl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:Ce()}),U==="bottom"&&!W&&l.jsx(vR,{}),l.jsx(pit,{open:f,setOpen:h})]})}const re=v.useCallback(te=>{w("dashboard",te)},[w]);return D?c&&R&&!W?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',R,'" was not found or is not a document sheet in the loaded dashboard.']}):c&&W&&H?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(OH,{sheet:H})}):l.jsxs(l.Fragment,{children:[l.jsx(cvt,{}),l.jsx(hvt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(iP,{className:m.cn("flex-1 basis-0 overflow-y-auto transition-opacity",_&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(Gy,{children:se()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(fit,{open:j,onTabClick:ee,withHandle:!0,disabled:!j}),l.jsx(Gy,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:ge,defaultSize:j?40:0,ref:u,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(evt,{open:j,setOpen:ee,isFullscreen:_,onFullscreenChange:te=>y(te?"dashboard":null),fullscreenContainer:k})})})]})]}),l.jsx("div",{ref:re,className:m.cn("absolute inset-0",!_&&"pointer-events-none")}),ae&&l.jsx("div",{className:m.cn("absolute z-50 transition-all duration-300 ease-in-out",x().horizontal,x().vertical),style:b(),children:l.jsx(m.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{g.current||ee(!0)},onMouseDown:p,onTouchStart:p,title:"Open Assistant (drag to move)",children:l.jsx(Qme,{className:"h-5 w-5"})})})]})]}):null}const yhe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:s,children:o,className:i,style:a,...c},u)=>{const d=v.useId(),f=v.useMemo(()=>kvt(d),[d]),{theme:h}=xF(),p=jvt(h),g=v.useMemo(()=>s??Jc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,s,n]),b=v.useMemo(()=>m.compileAppearance({spec:g,systemMode:p}),[g,p]),x=v.useMemo(()=>m.createAppearanceContextValue(f,b),[b,f]);return l.jsx(m.AppearanceContext.Provider,{value:x,children:l.jsx(fb,{...c,ref:u,className:i,style:a,children:o})})});yhe.displayName="AppearanceProvider";function kvt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function jvt(e){const t=NC(e),[n,r]=v.useState(()=>_vt());return v.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const s=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!s)return;const o=()=>{r(s.matches?"dark":"light")};return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):((a=s.addListener)==null||a.call(s,o),()=>{var c;return(c=s.removeListener)==null?void 0:c.call(s,o)})},[t]),t==="system"?n:t}function _vt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const vhe=v.createContext({openBrandStudioPreview:()=>{}}),Evt=vhe.Provider;function Tvt(){return v.useContext(vhe)}function Ivt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const s=NC(t),[o,i]=v.useState(()=>Dvt(n)||s),a=v.useCallback(u=>{const d=NC(u);Mvt(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:o,setTheme:a}),[o,a]);return l.jsx(Zq.Provider,{...r,value:c,children:e})}function Dvt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=NC(t,"system");return n===t?n:null}catch{return null}}function Mvt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const Avt=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function I$({appearance:e,children:t}){var I,D;const{authToken:n,id:r,tokenProps:s}=Ct(),o=dv(),i=(I=o.data)==null?void 0:I.organizationAppearance,a=(D=s.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,p]=v.useState(null),[g,b]=v.useState(null),[x,y]=v.useState(null),S=`${s.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,w=Bn({queryKey:tG({resourceType:rs.DASHBOARD,apiServiceUrl:s.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>m.getRequest(`${s.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:A=>(A==null?void 0:A.organizationAppearance)??null,enabled:!o.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:S,appearance:i})},[i,S]),v.useEffect(()=>{w.data!==void 0&&y({scopeKey:S,appearance:w.data})},[w.data,S]);const C=(x==null?void 0:x.scopeKey)===S?x.appearance:null,N=i!==void 0?i:w.data!==void 0?w.data:C,k=v.useMemo(()=>Jc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),j=v.useCallback(()=>{f(g??h??k),u(!0)},[g,h,k]),_=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),p(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:j}),[j]),E=g??h??e;return l.jsx(Ivt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(Evt,{value:T,children:l.jsx(yhe,{organizationAppearance:N,tokenAppearance:a,reactAppearance:E,style:{height:"100%",width:"100%"},children:l.jsxs(m.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(Avt,{appearance:d,onDraftChange:b,onSave:A=>{p(A),b(A),f(A)},onCancel:_})})})]})})})})}function whe({children:e,preferences:t}){const{currentUser:n}=ua(),r=v.useMemo(()=>{var s,o;return{preferences:t||{},isLocalDev:((s=t==null?void 0:t.uiMode)==null?void 0:s.developer)||!1,isConsoleMode:((o=t==null?void 0:t.uiMode)==null?void 0:o.console)||!1}},[t]);return l.jsx(QY.Provider,{value:r,children:l.jsx(V_,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function Rvt(e=2e3,t=500){const n=lme(),[r,s]=v.useState(!1),[o,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>s(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),o}function D$({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const s=Rvt(e,t);return v.useEffect(()=>(s&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[s,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:s?"ready":""})}function She(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(za,{FallbackComponent:z_,children:l.jsxs(NF,{dashboardProps:e,children:[l.jsx(D$,{componentType:"dashboard",componentId:e.id}),l.jsx(I$,{appearance:e.appearance,children:l.jsx(whe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(cP,{...e,type:"dashboard",children:l.jsx(xhe,{})})})})})]})})}function Fvt(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[s,o]=v.useState(),i=v.useCallback(()=>{var p,g,b;const a=((p=t.current)==null?void 0:p.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);o(x=>x===h?x:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:s,updateAvailableWidth:i}}function Pvt({filter:e}){var g;const t=m.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=jg(),r=Qh((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),s=m.useDashboardStore(b=>b.filterValues),o=s==null?void 0:s.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=m.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:p}=Fvt([t,o,r]);return v.useEffect(()=>{p()},[e.title,p]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(m.Label,{className:"my-1 block w-full text-sm",children:l.jsx(ai,{value:e.title||e.column,onSave:b=>c({...e,title:b}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(DL,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(m.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Ovt(){const e=m.useDashboardStore(r=>r.dashboard.filters),t=m.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:m.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(Pvt,{filter:r}),l.jsx(A_,{filter:r})]},r.id))}):null}function Lvt(){var i;const e=m.useDashboardStore(a=>a.dashboard),t=m.useDashboardStore(a=>a.selectedSheetId),n=m.useDashboardStore(a=>a.isVisualEditing),r=m.useDashboardStore(a=>a.isDashboardEditing),s=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),o=m.isDocumentSheet(s);return l.jsx("div",{role:"dashboard-plus-main",className:m.cn("",{"max-h-0 overflow-hidden":n,"flex min-h-0 grow basis-0 overflow-hidden":!n}),children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[r&&!o&&l.jsx(Ovt,{}),l.jsx(xhe,{})]})})}const $vt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-C_rExqPw.js"))),zvt=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-D_jZ-iix.js"))),Bvt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-BWWU6a7V.js"))),Vvt=v.lazy(()=>Promise.resolve().then(()=>require("./resource-management-panel-Bam-yvnt.js")).then(e=>({default:e.ResourceManagementPanel})));function Hvt({showControls:e=!1,showFooter:t=!0,...n}){const r=m.useDashboardStore(u=>u.isDashboardPanelOpen),s=m.useDashboardStore(u=>u.isVisualEditing),o=m.useDashboardStore(u=>u.showDashboardJSON),i=m.useDashboardStore(u=>u.actions.setIsDashboardPanelOpen),{appearance:a,preferences:c}=n;return l.jsx(za,{FallbackComponent:z_,children:l.jsxs(NF,{dashboardProps:n,children:[l.jsx(D$,{componentType:"surfboard",componentId:n.id}),l.jsxs(I$,{appearance:a,children:[l.jsx(oxe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(whe,{preferences:c,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(Bvt,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(v.Suspense,{fallback:null,children:l.jsx($vt,{})}),l.jsxs("div",{className:"flex grow overflow-hidden",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(Vvt,{isOpen:r,onClose:()=>i(!1),variant:"inline"})}),l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(cP,{...n,type:"dashboard",children:[s&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(zvt,{})}),l.jsx(Lvt,{})]})})]})]})]})]})]})})}var Uvt=Object.defineProperty,qvt=(e,t,n)=>t in e?Uvt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,IS=(e,t,n)=>qvt(e,typeof t!="symbol"?t+"":t,n);const Wvt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},Yvt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},Gvt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function Kvt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function Che(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const Zvt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const s=Che(t);if(typeof n<"u"&&s in n.container)return n.container[s]})();return typeof r=="function"?r.bind(n):void 0}},Xvt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},Qvt={stringify:e=>e,parse:e=>e},_2={string:Qvt,number:Xvt,boolean:Wvt,function:Yvt,method:Zvt,json:Gvt},kx=Symbol.for("r2wc.render"),DS=Symbol.for("r2wc.connected"),af=Symbol.for("r2wc.context"),bi=Symbol.for("r2wc.props");function Jvt(e,t,n){var r,s,o;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const p of i){c[p]=Array.isArray(t.props)?"string":t.props[p];const g=Kvt(p);d[p]=g,f[g]=p}for(const p of a)u[p]=Array.isArray(t.events)?{}:t.events[p];class h extends HTMLElement{constructor(){super(),IS(this,o,!0),IS(this,s),IS(this,r,{}),IS(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[bi].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],S=y?_2[y]:null;if(y==="method"){const w=Che(b);Object.defineProperty(this[bi].container,w,{enumerable:!0,configurable:!0,get(){return this[bi][w]},set(C){this[bi][w]=C,this[kx]()}}),this[bi][g]=S.parse(x,b,this)}S!=null&&S.parse&&x&&(this[bi][g]=S.parse(x,b,this))}for(const g of a)this[bi][g]=b=>{const x=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(x,{detail:b,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[DS]=!0,this[kx]()}disconnectedCallback(){this[DS]=!1,this[af]&&n.unmount(this[af]),delete this[af]}attributeChangedCallback(g,b,x){const y=f[g],S=c[y],w=S?_2[S]:null;y in c&&w!=null&&w.parse&&x&&(this[bi][y]=w.parse(x,g,this),this[kx]())}[(o=DS,s=af,r=bi,kx)](){this[DS]&&(this[af]?n.update(this[af],this[bi]):this[af]=n.mount(this.container,e,this[bi]))}}for(const p of i){const g=d[p],b=c[p];Object.defineProperty(h.prototype,p,{enumerable:!0,configurable:!0,get(){return this[bi][p]},set(x){this[bi][p]=x;const y=b?_2[b]:null;if(y!=null&&y.stringify){const S=y.stringify(x,g,this);this.getAttribute(g)!==S&&this.setAttribute(g,S)}else this[kx]()}})}return h}function ewt(e,t,n){const r=Yq.createRoot(e),s=v.createElement(t,n);return r.render(s),{root:r,ReactComponent:t}}function twt({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function nwt({root:e}){e.unmount()}function rwt(e,t={}){return Jvt(e,t,{mount:ewt,update:twt,unmount:nwt})}const swt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},owt=rwt(She,{props:swt}),iwt=v.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(D3,{context:t})," "]})}),Nhe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),awt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),lwt=Array.from(Nhe).join(", "),cwt=3,uwt="Self-heal",dwt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function fwt({card:e}){var W,O,Z,Y,M;const[t,n]=v.useState({}),{authToken:r}=Ct(),s=m.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:o}=m.useAppearance(),i=v.useMemo(()=>iw(o),[o]),a=m.useEditorStore(G=>G.frame),c=m.useEditorStore(G=>G.inlineFilterValuesMap[e.id]),u=m.useEditorStore(G=>G.actions.setCardInlineFilterValue),d=m.useEditorStore(G=>G.actions.removeCardInlineFilterValue),f=e,{getCard:h,manifest:p}=op(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(O=p==null?void 0:p.visuals)==null?void 0:O.find(G=>{var L;return G.name===((L=f.customCardPreferences)==null?void 0:L.componentName)}),b=aw(f,g)??"single",x=v.useMemo(()=>PL({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=v.useMemo(()=>{const G=x.findIndex(L=>(L==null?void 0:L.id)===e.id);return G<0?-1:A0(e,G)},[x,e]),S=v.useMemo(()=>b!=="multiple"||y<0?e.type:Sm(e,y,g==null?void 0:g.slots)??e.type,[b,y,e,g==null?void 0:g.slots]),w=v.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:S!==e.type?{...e,type:S}:e,[e,S,b]),{data:C}=Ej(w),N=m.useInteractionStore(G=>G.interactionStates),k=m.useDashboardStore(G=>{var L;return(L=G.dashboard)==null?void 0:L.id}),j=m.useDashboardStore(G=>G.dashboard.filters),_=m.useDashboardStore(G=>G.filterValues),T=m.useDashboardStore(G=>G.selectedSheetId),E=v.useMemo(()=>AL({card:e,sheetId:T||"",inlineFilterValues:c,setInlineFilterValue:G=>u(e.id,G),removeInlineFilterValue:G=>d(e.id,G)}),[e,T,c,u,d]),{cardFilters:I,cardFilterValues:D}=v.useMemo(()=>Nv({card:e,interactionStates:N,currentDashboardId:k,filters:j,filterValues:_,selectedSheetId:T}),[e,N,k,j,_,T]),A=v.useCallback((G,L)=>{const $=LL(L);n(B=>({...B,[G]:$}))},[]),P=(Z=f.customCardPreferences)==null?void 0:Z.componentName,R=P?h(P):null,H=GN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),z=v.useMemo(()=>FL(x),[x]),U=v.useMemo(()=>z.map((G,L)=>Sm(G,L,g==null?void 0:g.slots)),[z,g==null?void 0:g.slots]);return P?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[R&&b==="single"&&l.jsx(R,{editing:!0,params:s,theme:i,settings:H,cardMetadata:Iie({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:A,data:(C==null?void 0:C.records)||[],filters:I,filterValues:[...D||[],...c||[]],inlineFilters:E}),R&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((G,L)=>{if(!G)return null;const $=A0(G,L),B=Sm(G,$,g==null?void 0:g.slots);return l.jsx(oL,{onDataChange:A,card:G,effectiveCardType:B},`${G.id}-${$}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(R,{editing:!0,onDataChange:A,...$L({configCard:f,slotOrderedCards:z,slotTypes:U,multiInputData:t,params:s,theme:i,chartSettings:H,filters:I,filterValues:[...D||[],...c||[]],inlineFilters:E})})})]})]},(M=f.customCardPreferences)==null?void 0:M.componentName)}):null}const hwt=v.memo(fwt,(e,t)=>{var n,r,s,o,i,a,c,u;return e.card.id===t.card.id&&e.card.inlineFilters===t.card.inlineFilters&&((n=e.card.customCardPreferences)==null?void 0:n.settings)===((r=t.card.customCardPreferences)==null?void 0:r.settings)&&((s=e.card.customCardPreferences)==null?void 0:s.slotSettings)===((o=t.card.customCardPreferences)==null?void 0:o.slotSettings)&&((i=e.card.customCardPreferences)==null?void 0:i.url)===((a=t.card.customCardPreferences)==null?void 0:a.url)&&((c=e.card.customCardPreferences)==null?void 0:c.componentName)===((u=t.card.customCardPreferences)==null?void 0:u.componentName)}),pwt=m.create()(m.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(s=>s.type===n&&s.id===r),toggleStar:n=>{e(r=>{const s=r.starredCharts.findIndex(o=>o.type===n.type&&o.id===n.id);return s>=0?{starredCharts:r.starredCharts.filter((o,i)=>i!==s)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(s=>s.type===n&&s.id===r)}),{name:"semaphor-starred-charts"}));var khe=["PageUp","PageDown"],jhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],_he={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},jb="Slider",[pF,mwt,gwt]=m.createCollection(jb),[Ehe]=m.createContextScope(jb,[gwt]),[bwt,TE]=Ehe(jb),The=Q.forwardRef((e,t)=>{const{name:n,min:r=0,max:s=100,step:o=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:p=!1,form:g,...b}=e,x=Q.useRef(new Set),y=Q.useRef(0),w=i==="horizontal"?xwt:ywt,[C=[],N]=m.useControllableState({prop:d,defaultProp:u,onChange:I=>{var A;(A=[...x.current][y.current])==null||A.focus(),f(I)}}),k=Q.useRef(C);function j(I){const D=Nwt(C,I);E(I,D)}function _(I){E(I,y.current)}function T(){const I=k.current[y.current];C[y.current]!==I&&h(C)}function E(I,D,{commit:A}={commit:!1}){const P=Ewt(o),R=Twt(Math.round((I-r)/o)*o+r,P),H=m.clamp(R,[r,s]);N((z=[])=>{const U=Swt(z,H,D);if(_wt(U,c*o)){y.current=U.indexOf(H);const W=String(U)!==String(z);return W&&A&&h(U),W?U:z}else return z})}return l.jsx(bwt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:s,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(pF.Provider,{scope:e.__scopeSlider,children:l.jsx(pF.Slot,{scope:e.__scopeSlider,children:l.jsx(w,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:m.composeEventHandlers(b.onPointerDown,()=>{a||(k.current=C)}),min:r,max:s,inverted:p,onSlideStart:a?void 0:j,onSlideMove:a?void 0:_,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&E(r,0,{commit:!0}),onEndKeyDown:()=>!a&&E(s,C.length-1,{commit:!0}),onStepKeyDown:({event:I,direction:D})=>{if(!a){const R=khe.includes(I.key)||I.shiftKey&&jhe.includes(I.key)?10:1,H=y.current,z=C[H],U=o*R*D;E(z+U,H,{commit:!0})}}})})})})});The.displayName=jb;var[Ihe,Dhe]=Ehe(jb,{startEdge:"left",endEdge:"right",size:"width",direction:1}),xwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:s,inverted:o,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=Q.useState(null),p=m.useComposedRefs(t,w=>h(w)),g=Q.useRef(void 0),b=m.useDirection(s),x=b==="ltr",y=x&&!o||!x&&o;function S(w){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],j=M$(N,y?[n,r]:[r,n]);return g.current=C,j(w-C.left)}return l.jsx(Ihe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(Mhe,{dir:b,"data-orientation":"horizontal",...d,ref:p,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const C=S(w.clientX);i==null||i(C)},onSlideMove:w=>{const C=S(w.clientX);a==null||a(C)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const N=_he[y?"from-left":"from-right"].includes(w.key);u==null||u({event:w,direction:N?-1:1})}})})}),ywt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:s,onSlideStart:o,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=m.useComposedRefs(t,d),h=Q.useRef(void 0),p=!s;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],w=M$(y,p?[r,n]:[n,r]);return h.current=x,w(b-x.top)}return l.jsx(Ihe,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:l.jsx(Mhe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);o==null||o(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=_he[p?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),Mhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=TE(jb,n);return l.jsx(m.Primitive.span,{...u,ref:t,onKeyDown:m.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):khe.concat(jhe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:m.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:m.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&s(f)}),onPointerUp:m.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),o(f))})})}),Ahe="SliderTrack",Rhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=TE(Ahe,n);return l.jsx(m.Primitive.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...r,ref:t})});Rhe.displayName=Ahe;var mF="SliderRange",Fhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=TE(mF,n),o=Dhe(mF,n),i=Q.useRef(null),a=m.useComposedRefs(t,i),c=s.values.length,u=s.values.map(h=>Lhe(h,s.min,s.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(m.Primitive.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...r,ref:a,style:{...e.style,[o.startEdge]:d+"%",[o.endEdge]:f+"%"}})});Fhe.displayName=mF;var gF="SliderThumb",Phe=Q.forwardRef((e,t)=>{const n=mwt(e.__scopeSlider),[r,s]=Q.useState(null),o=m.useComposedRefs(t,a=>s(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(vwt,{...e,ref:o,index:i})}),vwt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:s,...o}=e,i=TE(gF,n),a=Dhe(gF,n),[c,u]=Q.useState(null),d=m.useComposedRefs(t,S=>u(S)),f=c?i.form||!!c.closest("form"):!0,h=m.useSize(c),p=i.values[r],g=p===void 0?0:Lhe(p,i.min,i.max),b=Cwt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?kwt(x,g,a.direction):0;return Q.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(pF.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(m.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":p,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...o,ref:d,style:p===void 0?{display:"none"}:e.style,onFocus:m.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(Ohe,{name:s??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},r)]})});Phe.displayName=gF;var wwt="RadioBubbleInput",Ohe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const s=Q.useRef(null),o=m.useComposedRefs(s,r),i=m.usePrevious(t);return Q.useEffect(()=>{const a=s.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(m.Primitive.input,{style:{display:"none"},...n,ref:o,defaultValue:t})});Ohe.displayName=wwt;function Swt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((s,o)=>s-o)}function Lhe(e,t,n){const o=100/(n-t)*(e-t);return m.clamp(o,[0,100])}function Cwt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Nwt(e,t){if(e.length===1)return 0;const n=e.map(s=>Math.abs(s-t)),r=Math.min(...n);return n.indexOf(r)}function kwt(e,t,n){const r=e/2,o=M$([0,50],[0,r]);return(r-o(t)*n)*n}function jwt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function _wt(e,t){if(t>0){const n=jwt(e);return Math.min(...n)>=t}return!0}function M$(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Ewt(e){return(String(e).split(".")[1]||"").length}function Twt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var $he=The,Iwt=Rhe,Dwt=Fhe,Mwt=Phe;const zhe=Q.forwardRef(({className:e,...t},n)=>l.jsxs($he,{ref:n,className:m.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(Iwt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(Dwt,{className:"absolute h-full bg-primary"})}),l.jsx(Mwt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));zhe.displayName=$he.displayName;const Bhe=["SUN","MON","TUE","WED","THU","FRI","SAT"],Awt=Bhe.reduce((e,t,n)=>({...e,[t]:n}),{}),uc={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function Rwt(e){if(!e||!e.trim())return{...uc};const t=e.trim(),r=(t.startsWith("cron(")&&t.endsWith(")")?t.slice(5,-1):t).trim().split(/\s+/);if(r.length<5||r.length>6)return{...uc,isCustom:!0};const[s,o,i,a,c]=r,u=Number(s),d=Number(o);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...uc,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...uc,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(p=>p.toUpperCase()).map(p=>Awt[p]).filter(p=>typeof p=="number");if(h.length>0)return{...uc,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...uc,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...uc,repeats:"monthly",hour:d,minute:u}:{...uc,hour:d,minute:u,isCustom:!0}}function Fwt(e){const t=e.minute,n=e.hour;switch(e.repeats){case"daily":return`cron(${t} ${n} * * ? *)`;case"weekly":{const r=e.weekdays.length>0?e.weekdays.slice().sort((s,o)=>s-o).map(s=>Bhe[s]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function Vhe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,s=t.toString().padStart(2,"0");return`${r}:${s} ${n}`}function Pwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Owt(e){if(e.length===7)return"every day";const t=e.slice().sort((s,o)=>s-o);if(t.length===5&&t.every(s=>s>=1&&s<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(s=>r[s]).join(", ")}function Lwt(e,t,n,r){const s=Vhe(e.hour,e.minute),o=Pwt(t);let i;if(e.isCustom)i=`Custom schedule · ${s} ${o}`;else switch(e.repeats){case"daily":i=`Daily at ${s} ${o}`;break;case"weekly":i=`Weekly · ${Owt(e.weekdays)} at ${s} ${o}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${s} ${o}`;break;case"monthly":i=`Monthly on the 1st at ${s} ${o}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const $wt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=C3;exports.AccordionContent=q0;exports.AccordionItem=H0;exports.AccordionTrigger=U0;exports.AddDataPicker=a$;exports.AggregateTable=l_;exports.Alert=nO;exports.AlertDescription=rO;exports.AlertDialog=Wc;exports.AlertDialogAction=Rl;exports.AlertDialogCancel=Fl;exports.AlertDialogContent=Tl;exports.AlertDialogDescription=Al;exports.AlertDialogFooter=Dl;exports.AlertDialogHeader=Il;exports.AlertDialogTitle=Ml;exports.AlertDialogTrigger=sM;exports.AlertTitle=WX;exports.ArrowDown=Hs;exports.ArrowDownIcon=bYe;exports.ArrowLeft=hv;exports.ArrowRight=Ok;exports.ArrowUp=io;exports.ArrowUpIcon=yYe;exports.AssistantContextEntityControls=tF;exports.AssistantVirtualizedMessages=phe;exports.AtSign=CW;exports.AxisConfigurator=Fg;exports.Badge=ws;exports.Bell=RS;exports.BookType=kW;exports.BulletChartIcon=ihe;exports.COMMON_TIMEZONES=$wt;exports.CSS=Fi;exports.CalculatedFieldEditor=Vle;exports.Calculator=_W;exports.Calendar=ki;exports.Calendar$1=aC;exports.CalendarRange=EW;exports.Card=$m;exports.CardContent=Pk;exports.CardHeader=Fk;exports.CardSummary=_R;exports.CardTitle=Cg;exports.ChartArea=X2;exports.ChartColumnIncreasing=TW;exports.ChartColumnStacked=IW;exports.ChartJsVisual=Qv;exports.ChartLine=DW;exports.ChartNoAxesGantt=AW;exports.ChartPie=RW;exports.ChartScatter=FW;exports.ChatInputWithContext=l$;exports.Checkbox=Vn;exports.ChevronLeft=Uh;exports.ChevronRight=vr;exports.Circle=Lk;exports.CircleAlert=mh;exports.CircleCheck=LW;exports.CircleHelp=$W;exports.Clock=EF;exports.CodeHighlighter=Zu;exports.CodeXml=Zf;exports.Collapsible=Zc;exports.CollapsibleContent=Qc;exports.CollapsibleTrigger=Xc;exports.ColorField=Zi;exports.Command=J_;exports.CommandEmpty=tE;exports.CommandGroup=nE;exports.CommandInput=d3;exports.CommandItem=rE;exports.CommandList=eE;exports.CommandSeparator=lle;exports.ComparisonMetadataBadge=gte;exports.Container=cP;exports.ControlDefaultValueEditor=uce;exports.ControlDefinitionOptionsEditor=cce;exports.ControlIdInput=oce;exports.ControlVisibilitySettings=Int;exports.Copy=_l;exports.CopyButton=od;exports.CopyPlus=J2;exports.Cross2Icon=CYe;exports.CustomFilterPopover=DL;exports.CustomScrollArea=Kl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=yee;exports.DEFAULT_SCHEDULE_VM=uc;exports.Dashboard=She;exports.DashboardActionsMenu=JY;exports.DashboardCard=pae;exports.DashboardCreateDialogBase=IG;exports.DashboardExportDialog=mhe;exports.DashboardPlus=Hvt;exports.DashboardWC=owt;exports.DataAppBuilder=OK;exports.DataTableConditionalFormattingSettings=Qce;exports.DataTablePagination=n_;exports.Database=li;exports.DateRangePicker=dL;exports.DefaultChatTransport=J3;exports.Dialog=Vo;exports.DialogContent=wo;exports.DialogDescription=fi;exports.DialogFooter=nu;exports.DialogHeader=da;exports.DialogTitle=So;exports.DialogTrigger=_G;exports.DisplayPreferencesProvider=V_;exports.DndContext=xw;exports.Donut=zW;exports.Download=eu;exports.DownloadPdf=ghe;exports.DragOverlay=Gae;exports.DropdownMenu=Lo;exports.DropdownMenuCheckboxItem=Nu;exports.DropdownMenuContent=xo;exports.DropdownMenuItem=In;exports.DropdownMenuLabel=Fc;exports.DropdownMenuRadioGroup=Mbe;exports.DropdownMenuRadioItem=XY;exports.DropdownMenuSeparator=Fa;exports.DropdownMenuSub=YF;exports.DropdownMenuSubContent=Yk;exports.DropdownMenuSubTrigger=Wk;exports.DropdownMenuTrigger=$o;exports.EMPTY_DATA_SOURCE=yg;exports.Editable=ZN;exports.EditableText=ai;exports.EditorCustomVisual=hwt;exports.Ellipsis=Ra;exports.EllipsisVertical=qh;exports.ErrorBoundary=za;exports.ExportError=Vg;exports.ExternalLink=Bm;exports.Eye=pv;exports.EyeOff=$k;exports.Fallback=z_;exports.FallbackVisual=F0;exports.FeedbackCategory=Td;exports.FeedbackDialog=nv;exports.FieldsList=D3;exports.FieldsSection=iwt;exports.FileSpreadsheet=BW;exports.FileText=Ti;exports.Filter=gh;exports.FilterComponent=A_;exports.FilterInfo=CR;exports.FilterableFieldsPanel=Ule;exports.Globe=Ng;exports.Grid3x3=VW;exports.GripVertical=tu;exports.HEATMAP_PRESET_PALETTES=cA;exports.Hash=HW;exports.House=UW;exports.HoverCard=Ug;exports.HoverCardContent=gd;exports.HoverCardTrigger=qg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=Nhe;exports.INLINE_ALLOWED_TOOL_LIST=lwt;exports.INLINE_BLOCKED_MUTATING_TOOLS=awt;exports.IconButton=Rc;exports.IconForFieldType=pC;exports.InfoHover=JL;exports.InlineFilterBar=sae;exports.KPICard=Cd;exports.KeyboardSensor=gw;exports.Layers=mv;exports.LayoutDashboard=Vm;exports.Link=TF;exports.LoadingDots=xd;exports.Lock=zk;exports.MAX_SELF_HEAL_ATTEMPTS=cwt;exports.Map=YW;exports.Markdown=jfe;exports.Maximize2=Bk;exports.MdStackedLineChart=she;exports.Minimize2=IF;exports.MultiInputEmptyRenderer=oL;exports.PYTHON_DEFAULT_CODE=bF;exports.PanelLeft=DF;exports.PanelResizeHandle=lj;exports.Paperclip=GW;exports.PenLine=eM;exports.Pencil=tM;exports.PendingMessagesDisplay=Bde;exports.PersistedDynamicVisual=B_;exports.PiChartPolar=ehe;exports.PivotTableTanstack=db;exports.Placeholders=sue;exports.Play=KW;exports.Plus=yr;exports.PointerSensor=bb;exports.Progress=o$;exports.RECOVERABLE_SQL_ERROR_CODES=dwt;exports.Radar=ZW;exports.RadioGroup=Oa;exports.RadioGroupItem=Rs;exports.RefreshCw=qc;exports.ResizableHandle=AK;exports.ResizablePanel=Gy;exports.ResizablePanelGroup=iP;exports.ResourceEditDialog=aK;exports.ResourceType=rs;exports.SELF_HEAL_TIMELINE_STEP=uwt;exports.Search=Xs;exports.SeedQuestions=jde;exports.SemaphorContext=Sg;exports.SemaphorContextProvider=NF;exports.SemaphorQueryClient=bW;exports.SemaphorReadyIndicator=D$;exports.SemaphorStyleWrapper=fb;exports.Send=MF;exports.Settings=AF;exports.Settings2=kg;exports.Share2=XW;exports.ShareDialog=iK;exports.Sheet=ste;exports.SheetContent=r5;exports.SheetDescription=o5;exports.SheetHeader=ite;exports.SheetTitle=s5;exports.SheetTrigger=S5e;exports.Slider=zhe;exports.SortableContext=yw;exports.Sparkles=DC;exports.Square=RF;exports.SquarePen=Hk;exports.Star=FF;exports.StructuralParticipantSelector=ice;exports.SummaryCard=vR;exports.TABLE_PRESENTATION_DEFAULT_STYLE=rd;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=Ji;exports.TableBody=_h;exports.TableCell=cr;exports.TableColumnVisibilitySettings=zce;exports.TableHead=ni;exports.TableHeader=Hg;exports.TablePresentationSettings=Vce;exports.TableRow=ts;exports.TableSkeleton=e3;exports.TableVisual=bd;exports.TbChartBubble=the;exports.TbChartFunnel=nhe;exports.TbChartTreemap=rhe;exports.TextCard=fg;exports.Textarea=Gh;exports.TiSortNumerically=ohe;exports.Toggle=L_;exports.Tornado=QW;exports.Trash2=El;exports.TreePalm=OF;exports.TrendingUp=JW;exports.TriangleAlert=ra;exports.TypeGlyph=dw;exports.UXProvider=I$;exports.User=eY;exports.Users=LF;exports.applyFilterOverridesToDashboardInputSlots=fX;exports.areContextEntitiesEqual=ur;exports.areEntitiesJoined=Nee;exports.arrayMove=xb;exports.buildCardControlUsageById=Mnt;exports.buildCustomCardTheme=iw;exports.buildDashboardCardExecutionSnapshot=dX;exports.buildDashboardControlUsageById=Dnt;exports.buildDashboardExecutionSnapshot=ZP;exports.buildDashboardInputExecutionSnapshot=Xu;exports.buildDashboardSheetsInputExecutionSnapshot=pX;exports.buildDashboardStructuralParticipantIdsByControlId=hce;exports.buildFilterFieldMeta=b3;exports.buildFilterSemanticContext=x3;exports.buildInlineFilterNodes=AL;exports.buildMultiInputCustomVisualProps=$L;exports.buildScheduleExpr=Fwt;exports.buildSchedulePreview=Lwt;exports.buildSlotOrderedCards=FL;exports.calculateContextAwareFilters=Nv;exports.calculateFieldState=GO;exports.canUserAccessVisuals=Ywe;exports.canUserCreateDashboards=$K;exports.canUserEdit=Uwe;exports.canUserManageDashboards=Wwe;exports.canUserManageGroups=Gwe;exports.canUserUseFilters=qwe;exports.cancelExport=uOe;exports.chartSupportsDataLabels=gJ;exports.chartSupportsLegend=pJ;exports.chartTypes=EE;exports.cleanupKpiMetricComparisonMode=gle;exports.cloneDeep=ri;exports.cloneLinkedFrameWithSourceMapping=FKe;exports.closestCenter=mw;exports.commitSharedCalculatedFields=gf;exports.createAssistantConversationId=Qp;exports.createAssistantRequestId=Nde;exports.createCardsFromSlots=ZYe;exports.createChartConfig=Bg;exports.createDashboardControlInputFromControl=_ot;exports.createDefaultGlobalDateFilter=HNe;exports.createExport=Uee;exports.createUniqueDashboardInputVariableNameFromName=id;exports.dedup=ift;exports.doesStoredFilterMatchField=bg;exports.downloadDocumentPdf=QP;exports.downloadPdf=SX;exports.extractSqlParamReferences=xoe;exports.extractTableMetadata=g3;exports.fieldAlreadyExists=jee;exports.findCustomVisualConfigCard=OL;exports.findDashboardFrameById=RNe;exports.flexRender=oi;exports.formatDisplayFormula=jet;exports.formatFileSize=hOe;exports.formatFilterLine=GX;exports.formatTimeLabel=Vhe;exports.getAutoDetectedChartIcon=g0t;exports.getChartGridStyle=h_e;exports.getChartIconByType=b0t;exports.getColorForValue=jM;exports.getConfigSlotExpectedType=KYe;exports.getCoreRowModel=Jj;exports.getCustomVisualInputCards=PL;exports.getDateFormatOptionsForGranularity=B0;exports.getDefaultAxisConfig=EM;exports.getDefaultChartColors=Jh;exports.getDefaultDataLabelsConfig=Pv;exports.getDefaultExportFormat=dQ;exports.getDefaultFilterSql=gL;exports.getDefaultLegendConfig=DO;exports.getDefaultRunningTotalPartitionByFieldIds=Ry;exports.getDocumentSectionEditorCard=cnt;exports.getDocumentSheetDashboardInputs=Nw;exports.getDownloadUrl=cOe;exports.getEffectiveCardTypeForSlot=Sm;exports.getEntityIcon=kk;exports.getErrorMessage=fde;exports.getExportStatus=lOe;exports.getExports=aOe;exports.getExpressionFieldKind=kd;exports.getFieldExpressionAnnotation=y3;exports.getFilterCount=tk;exports.getGlobalDateFilter=Tg;exports.getGlobalDateFilterCoverage=UNe;exports.getGranularityOptionsForFieldType=O3;exports.getKeys=Nr;exports.getMetricDisplayLabel=TPe;exports.getNewField=Dee;exports.getObjectDiff=Xq;exports.getPaginationRowModel=e_;exports.getRoleBasedDisplayOverrides=LK;exports.getRunningTotalOrderByCandidates=YJe;exports.getSelectedDateFilterColumn=voe;exports.getSheetScopedFilterValues=Qy;exports.getSlotDefinitionForIndex=RL;exports.getSlotExpectedChartType=P_;exports.getSlotIndexForCard=A0;exports.getSortedRowModel=rte;exports.getSupportedExportFormats=uQ;exports.getTableConditionalFormattingColumnOptions=Wce;exports.getTableOutputColumnOptions=Yce;exports.getTablePageSizeOptions=Bee;exports.handleAggregationChange=NR;exports.handleAggregationLabelChange=nae;exports.hasFlatTableTotalsBehavior=Lke;exports.horizontalListSortingStrategy=a3;exports.isCalculatedFilterField=V0;exports.isCardSummaryVisibleOnCard=zL;exports.isCustomVisualConfigCard=xR;exports.isDefaultColor=Yke;exports.isEligibleFlatTableTotalsCard=Ig;exports.isExportComplete=fOe;exports.isExportInProgress=dOe;exports.isInAiScopeArray=oft;exports.isManagedCalculatedExpressionField=Ma;exports.isMetricTransformEnabled=qJe;exports.isPromiseLike=eF;exports.isSubtotalEnabledAggregateTable=m3;exports.isSupportedDocumentTableCardType=unt;exports.lastAssistantMessageIsCompleteWithToolCalls=lde;exports.merge=jl;exports.mergeAxisConfig=TM;exports.normalizeConditionalFormatting=HP;exports.normalizeContextFormatMode=eQ;exports.normalizeDashboardInputVariableName=fv;exports.normalizeMultiInputPayload=LL;exports.parseScheduleExpr=Rwt;exports.pivotData=Tv;exports.prepareFeedbackData=_E;exports.purify=QA;exports.reindexSlotCards=GYe;exports.remarkGfm=Zfe;exports.removeFromScopeArray=aft;exports.resolveDashboardInputContext=Gl;exports.resolveDomainCalculatedFieldForEdit=wtt;exports.resolveMultiInputType=aw;exports.resolveMultiInputTypeFromVisual=XYe;exports.resolveTablePageSize=Zj;exports.resolveTablePresentationStyle=p5;exports.sanitizeAIScope=dde;exports.saveCalculatedFieldToCardScope=PR;exports.saveCalculatedFieldToSharedScope=Hle;exports.saveCalculatedFieldToSheetScope=OR;exports.seedSemanticMetricFormatDefaults=xle;exports.setTableColumnVisibility=Yee;exports.setupEditorWithCard=Tj;exports.showAllTableColumns=bOe;exports.showJoinRequiredNotification=kee;exports.sortByColumnsToSortState=jte;exports.sortStateToSortByColumns=_te;exports.sortableKeyboardCoordinates=c3;exports.supportsMetricTransformForMetric=ble;exports.supportsTableConditionalFormatting=Hce;exports.toEntityArray=Da;exports.ue=at;exports.useActiveExports=e1e;exports.useActiveToolStatus=Hde;exports.useAddFrameWithFreshSemanticExecutionPayload=QL;exports.useAddNewFrame=Nae;exports.useAssistantContainer=VK;exports.useAssistantContextEntities=U_;exports.useAssistantLayoutStore=Qf;exports.useAssistantPanel=zK;exports.useAssistantProfile=kde;exports.useAutoSubmitQueue=Vde;exports.useBrandStudioPreview=Tvt;exports.useCard=BPe;exports.useCardFilterValues=Aee;exports.useCardSummary=BL;exports.useChat=ude;exports.useColumns=f3;exports.useCreateVisualWithFrame=Nxe;exports.useCurrentUserInfo=ua;exports.useCustomVisual=op;exports.useCustomVisualsQuery=IL;exports.useDashboardAppearance=Hl;exports.useDashboardById=iG;exports.useDashboardCreation=cG;exports.useDashboardManagement=lG;exports.useDashboardPreferences=jg;exports.useDashboardQuery=dv;exports.useDashboardStructuralParticipants=pce;exports.useDashboardSummary=$ie;exports.useDataColumns=vle;exports.useDateFilterHook=EHe;exports.useDebounce=Ey;exports.useDefaultDashboardMutation=eG;exports.useDisplayPreferences=Yl;exports.useDroppable=Yae;exports.useEditorAside=sE;exports.useEditorCardQuery=Ej;exports.useEnsureReactGlobals=Yse;exports.useExportActions=HK;exports.useExportStore=cj;exports.useFieldManagement=yle;exports.useFilterableFields=hle;exports.useFullscreenAssistant=BK;exports.useGroupMembers=Nye;exports.useGroups=QG;exports.useHasDashboardId=UK;exports.useInProgressExportsCount=t1e;exports.useIsDashboardSelected=fme;exports.useIsVisualSelected=hme;exports.useJoinabilityMap=p3;exports.useManagementActions=Hh;exports.useManagementStore=hs;exports.useMutation=go;exports.usePivotTableConfig=tp;exports.usePluginQuery=kie;exports.useQuery=Bn;exports.useQueryClient=ls;exports.useReactTable=t_;exports.useResolveExistingFrameSemanticExecutionPayload=$Ke;exports.useResourceManagement=Zk;exports.useResourceUpdateState=aG;exports.useScopedFields=fle;exports.useSelectedVisual=dme;exports.useSemaphorContext=Ct;exports.useSensor=gg;exports.useSensors=G_;exports.useSortable=yb;exports.useStarredChartsStore=pwt;exports.useSurfaceAppearance=su;exports.useTableQueryState=bte;exports.useTextFilterHook=$He;exports.useTheme=xF;exports.useTopoJson=Lv;exports.useUnifiedUsers=JF;exports.useUpdateResource=nG;exports.useUpdateVisualMutation=kxe;exports.useUserPreferences=DG;exports.useVisualById=Kk;exports.useVisualManagement=Cxe;exports.validateFieldForChartType=mle;exports.verticalListSortingStrategy=l3;
1411
+ `).trim(),_=k.map((T,E)=>{var A,P;let I="",D;if((A=T.url)!=null&&A.startsWith("data:")){const R=T.url.match(/data:[^;]+;base64,(.+)/);R&&(I=R[1],(P=T.mediaType)!=null&&P.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${E}`,name:T.filename||`File ${E+1}`,size:0,type:T.mediaType||"application/octet-stream",data:I,preview:D}});return l.jsx(H0t,{text:j||void 0,files:_.length>0?_:void 0})}const f=((w=e.parts)==null?void 0:w.filter(N=>N.type==="reasoning"))||[],h=f.length>0,p=f.some(N=>N.state==="streaming"),g=f.filter(N=>N.text&&N.text.trim().length>0),b=h&&(g.length>0||p)?l.jsxs(Zc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Xc,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(vr,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:p?"animate-pulse":"",children:p?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(Qc,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,k)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:k+1}),l.jsx(yq,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${k}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,k)=>{var _;const j=`${e.id||t}-${k}`;switch(N.type){case"text":{const T=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:E,quickReplies:I}=$0t(T),D=E.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(yq,{text:E,handleRun:i,onAddToDashboard:s,messageId:e.id,messages:n}),I.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[I.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(({label:A,value:P},R)=>l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsx(m.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(P),children:l.jsx("span",{className:"truncate",children:A})})}),l.jsx(m.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${j}-qr-${R}`))})]})]},j)}return e.role==="system"&&o?l.jsx(U0t,{text:T},j):null}case"error":{const T=N,E=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(T$,{errorMessage:E})},j)}case"reasoning":return null;default:return((_=N.type)!=null&&_.startsWith("tool-")||N.type==="dynamic-tool")&&E$(N,r)?l.jsx(za,{FallbackComponent:({error:T,resetErrorBoundary:E})=>l.jsx(V0t,{error:T,resetErrorBoundary:E}),children:l.jsx(R0t,{part:N,idx:j,messageId:e.id,showTools:r,onAddToDashboard:s,messages:n})},j):null}});return e.role==="assistant"?hhe(e,r)?l.jsxs(fhe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const G0t=8,K0t=24,Z0t=20;function X0t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function phe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:s,onQuickReply:o,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:p,scrollToEndSignal:g=0}){const b=v.useRef(null),x=v.useRef(null),y=v.useRef(e.length),S=v.useRef(!1),w=v.useRef(null),C=v.useRef(!1),N=v.useRef(g),[k,j]=v.useState(!0),[_,T]=v.useState(0),[E,I]=v.useState(K0t);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],A=hhe(D,t),P=X0t(a,c,u,A),R=a_({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const O=e[W];return(O==null?void 0:O.role)==="user"?88:180},getItemKey:W=>{const O=e[W];return(O==null?void 0:O.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:G0t,overscan:6,gap:20,paddingEnd:P?E+Z0t:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const O=W.isAtEnd();j(Z=>Z===O?Z:O),O&&T(0)}}),H=v.useCallback((W="smooth")=>{w.current!==null&&cancelAnimationFrame(w.current),w.current=requestAnimationFrame(()=>{w.current=null,R.scrollToEnd({behavior:W})}),T(0),j(!0)},[R]);v.useLayoutEffect(()=>{S.current||(S.current=!0,H("auto"))},[H]),v.useLayoutEffect(()=>{C.current&&(C.current=!1,H("auto"))},[e.length,g,H]),v.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!R.isAtEnd()&&T(O=>O+e.length-W),e.length===0&&(T(0),j(!0),S.current=!1,C.current=!1)},[e.length,R]);const z=R.getVirtualItems(),U=R.getTotalSize();return v.useEffect(()=>()=>{w.current!==null&&cancelAnimationFrame(w.current)},[]),v.useLayoutEffect(()=>{const W=x.current;if(!W||!P)return;const O=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&I(M=>M===Y?M:Y)};if(O(),typeof ResizeObserver>"u")return;const Z=new ResizeObserver(O);return Z.observe(W),()=>Z.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(Kl,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:m.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:U},children:[z.map(W=>{const O=e[W.index];return O?l.jsx("div",{ref:R.measureElement,"data-index":W.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${W.start}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(Y0t,{message:O,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:s,onQuickReply:o,disableQuickReplies:i})})},W.key):null}),P&&l.jsx("div",{ref:x,className:m.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(U-E,0)}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(q0t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!k&&l.jsxs("button",{type:"button",onClick:()=>H("smooth"),"aria-label":"Scroll to latest",className:m.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",p),children:[l.jsx(Hs,{className:"h-3 w-3"}),"Latest",_>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:_>9?"9+":_})]})]})}function Q0t(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const J0t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function evt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:s}){const[o,i]=v.useState(!1),[a,c]=v.useState(m.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[p,g]=v.useState(!1),[b,x]=v.useState(!1),[y,S]=v.useState(0),w=n??b,{isLocalDev:C,isConsoleMode:N}=jg(),k=C||N||a,j=v.useRef(null);m.useDashboardStore(te=>te.dashboard.aiScopeTables),m.useDashboardStore(te=>te.isDashboardEditing);const _=m.useDashboardStore(te=>te.selectedSheetId),{setDataSource:T}=m.useEditorActions(),{setSelectedFrameId:E,setIsDashboardEditing:I}=m.useDashboardActions(),D=QL(),{clearAssistantMessageContexts:A}=m.useAIActions(),{clearQueue:P}=m.useQueueActions(),{clearFileAttachments:R,getFileAttachments:H}=m.useFileActions(),z=m.useFileAttachments("dashboard"),U=m.useEditorStore(te=>te.card.dataSource),{assistantProfile:W}=kde(),O=m.useDashboardStore(te=>te.handleOpenAssistantProfile),{selectedEntities:Z,applyDashboardDefaultEntities:Y}=U_("dashboard"),{sendMessage:M,isLoading:G,messages:L,setMessages:$,status:B,stop:V,errorMessage:F,clearError:q}=jft({dynamicVisualMode:f}),K=v.useCallback(()=>{S(te=>te+1)},[]),X=v.useCallback(te=>{r==null||r(te),n===void 0&&x(te)},[n,r]),ee=v.useCallback(()=>{X(!w)},[w,X]);v.useEffect(()=>{if(!w)return;function te(Se){Se.key==="Escape"&&X(!1)}return window.addEventListener("keydown",te),()=>{window.removeEventListener("keydown",te)}},[w,X]);const[de,fe]=v.useState(""),ge=te=>{fe(te.target.value)};async function ve({sql:te,cardTitle:Se,connectionId:we,cardType:ne,python:_e,cardConfig:Pe,dataSource:$e,customVisualPreferences:Xe,visualizationMode:Ue,dynamicCardPreferences:We}){if(!_)return;const Qe=Ue==="dynamic",je=m.hasValidCardConfig(Pe),tt=we||($e==null?void 0:$e.connectionId)||"",ze=$e?{...$e,connectionId:tt||$e.connectionId,connectionType:$e.connectionType||"",mode:$e.mode||"database",selectedEntities:$e.selectedEntities||[]}:tt?{connectionId:tt,connectionType:"",mode:"database",selectedEntities:[]}:yg,it=!(je&&(!Qe||(We==null?void 0:We.provenance)==="card-config"||(We==null?void 0:We.provenance)==="query_spec")),Fe=it?Q0t(te):"",Ie=it?_e:"",Ze={id:m.v4(),title:Se||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:ne==="horizontalBar"?"y":"x"},...Qe&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:ne,sql:Fe,python:Ie,dataSource:ze,config:Pe,connectionId:tt,visualizationMode:Ue,dynamicCardPreferences:We,customCardPreferences:Xe?{url:Xe.url,componentName:Xe.componentName,pluginChartType:Xe.pluginChartType,settings:Xe.settings,type:"component"}:void 0},yt={id:m.v4(),cards:[Ze],activeCardId:Ze.id};try{await D(_,yt,"end"),I(!0),E(yt.id)}catch(St){console.error("Failed to add assistant visual to dashboard:",St),at.error(St instanceof Error?St.message:"Failed to prepare semantic metadata for the new visual")}}const ie=te=>{te.preventDefault();const Se=de.trim();if(!Se&&z.length===0)return;const we=[];Se&&we.push({type:"text",text:Se}),z.forEach(ne=>{ne.data&&we.push({type:"file",mediaType:ne.type,filename:ne.name,url:`data:${ne.type};base64,${ne.data}`})}),M({role:"user",parts:we}),fe(""),R("dashboard"),K()};v.useEffect(()=>{var te;e&&((te=j.current)==null||te.focus())},[e]),Vde({assistantType:"dashboard",status:B,isLoading:G,sendMessage:M});const{hasActiveTools:be,activeToolText:oe}=Hde(L);function Ae(te){const Se={role:"user",parts:[{type:"text",text:te.title+" "+te.subtitle}]};M(Se),K()}function ae(te){M({role:"user",parts:[{type:"text",text:te}]}),K()}function me(te){M({role:"user",parts:[{type:"text",text:te}]}),K()}const Ce=v.useCallback(async()=>{const te=JSON.stringify(L??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(te),at.success("Conversation copied")}catch(Se){console.error("Failed to copy conversation",Se),at.error("Unable to copy conversation")}},[L]),se=(de==null?void 0:de.length)===0&&(L==null?void 0:L.filter(te=>te.role==="user").length)===0;function re(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function J(){return l.jsxs(Lo,{children:[l.jsx($o,{asChild:!0,children:l.jsx(Rc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(qh,{className:"size-3.5"})})}),l.jsxs(xo,{align:"end",children:[l.jsx(Fc,{children:"Options"}),l.jsx(Fa,{}),l.jsx(Nu,{checked:o,onCheckedChange:i,children:"Token Usage"}),l.jsx(Nu,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(Nu,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(Fa,{}),l.jsx(Fc,{children:"Dynamic Visuals"}),l.jsx(Nu,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(Nu,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(Nu,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const he=l.jsxs("div",{"data-role":"dashboard-assistant",className:m.cn("relative flex h-full grow flex-col break-words bg-background",w&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[re(),O&&l.jsxs("button",{type:"button",onClick:O,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(W==null?void 0:W.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[N&&J(),k&&l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:Ce,children:"Copy Conversation"}),l.jsx(Rc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:w?"Exit fullscreen":"Expand",onClick:ee,children:w?l.jsx(IF,{className:"h-3.5 w-3.5"}):l.jsx(Bk,{className:"h-3.5 w-3.5"})}),l.jsx(Rc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const te=L.filter(Se=>Se.role==="assistant").map(Se=>Se.id).filter(Se=>!!Se);$([]),P("dashboard"),q(),A(te)},children:l.jsx(Hk,{className:"h-3.5 w-3.5"})}),l.jsx(Rc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(m.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(phe,{messages:L,showTools:a,showSystemMessage:u,onAddToDashboard:ve,onQuickReply:me,disableQuickReplies:G,status:B,errorMessage:F,activeToolText:G&&be?oe:void 0,className:m.cn(w?"px-6 py-5":"px-3 py-3"),rowContentClassName:m.cn(w&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!W&&se&&l.jsx(sue,{onClick:Ae,placeholders:J0t}),se&&W&&l.jsx(jde,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:ae}),l.jsx(Bde,{assistantType:"dashboard"}),l.jsx(l$,{ref:j,setInput:fe,stop:V,input:de,handleInputChange:ge,handleSubmit:te=>{ie(te)},isLoading:G,status:B,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(a$,{incomingSelectedEntities:Z,open:p,onOpenChange:g,dataSource:U||yg,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:te=>Y()})]});return w&&s?Rr.createPortal(l.jsx(fb,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:he})}),s):he}function tvt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=m.useDashboardActions(),s=eae(),o=m.useDashboardStore(d=>d.dashboard.sheets),a=m.useDashboardStore(d=>d.selectedSheetId)??(o==null?void 0:o[0].id),c=m.useDashboardStore(d=>d.isDashboardEditing),u=m.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(p){if(nvt(p.target))return;const g=p.ctrlKey||p.metaKey;g&&p.key==="c"?(await f(),at.success("Card copied to clipboard"),p.preventDefault()):g&&p.key==="v"&&(await h(),p.preventDefault())}async function f(){try{const p=n();p&&await navigator.clipboard.writeText(JSON.stringify(p))}catch(p){console.error("Failed to copy text:",p)}}async function h(){if(!a)return null;try{const p=await navigator.clipboard.readText(),g=rvt(p);if(g!=null&&g.id){const b=Xie(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await s(a,b),r(b.id),at.success("Card pasted from clipboard")}return p}catch(p){return console.error("Failed to paste text:",p),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[s,n,r,a,c,u,t])}function nvt(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function rvt(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function svt(e,t){switch(e.interactionMode){case"drillToDetail":ovt(e,t);break;case"drillThrough":ivt(e,t);break;case"drillToURL":avt(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function ovt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:s,filterGroups:o}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=o.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=o.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}s==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function ivt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:s,sourceCardId:o}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=s.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function avt(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function lvt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:s,contextMode:o,cardTitle:i,cardDescription:a}){return l.jsx(Vo,{open:e,onOpenChange:t,children:l.jsxs(wo,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(da,{children:[l.jsx(So,{children:i||"Insight Detail"}),l.jsx(fi,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(rae,{filters:r,filterDefinitions:s,contextMode:o}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(bae,{insightId:n,filters:r,contextMode:o}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function cvt(){const e=m.useInteractionStore(C=>C.interactionStates),t=m.useInteractionStore(C=>C.setInteractionState),n=m.useInteractionStore(C=>C.clearLastInteractionEvent),r=m.useInteractionStore(C=>C.replaceCardWithInsight),s=m.useInteractionStore(C=>C.setPendingDrillThrough),o=m.useInteractionStore(C=>C.pendingDrillThrough),i=m.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=m.useDashboardActions(),{selectDashboard:u}=Hh(),d=m.useDashboardStore(C=>C.dashboard),f=m.useDashboardStore(C=>C.filterValues),{data:h,isLoading:p}=iG((o==null?void 0:o.targetDashboardId)||"",{enabled:!!(o!=null&&o.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=xae(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),S=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:k})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:k})},replaceCardContent:({cardId:C,insightId:N,filters:k,contextMode:j})=>{r(C,N,k,j)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:s,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:k,sourceDashboardTitle:j,targetDashboardId:_})=>{const T={filters:C},E={sourceCardId:m.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},I={...m.createInitialInteractionState(),appliedClickFilters:[E],contextMode:N,sourceDashboardId:k,sourceDashboardTitle:j,targetDashboardId:_};t(m.DRILL_CONTEXT_CARD_ID,I)}}),[a,r,f,c,d,s,t]);v.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const k=N.lastInteractionEvent,j=`${C}-${k.interactionMode}-${k.sourceCardId}-${Date.now()}`;if(y.current.has(j))return;y.current.add(j);try{svt(k,S)}catch(_){console.error("Error executing interaction event:",_)}finally{n(C),setTimeout(()=>{y.current.delete(j)},5e3)}}})},[e,n,S]),v.useEffect(()=>{if(!(!o||!h||p))try{u(h),c(o.targetDashboardId,o.sourceDashboardId,o.sourceDashboardTitle,o.filters,o.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[o,h,p,u,c,i]);const w=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(lvt,{open:g.open,onOpenChange:w,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),o&&p&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function uvt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,s=dvt(t.value);return r==="="?`${n} = ${s}`:`${n} ${r} ${s}`}).join(", ")}function dvt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function fvt(e){return e?`Back to ${e}`:"Back"}function hvt(){var y,S,w,C,N;const e=m.useInteractionStore(k=>k.interactionStates[m.DRILL_CONTEXT_CARD_ID]),t=m.useDashboardStore(k=>k.actions.goBackFromDrill),n=m.useDashboardStore(k=>k.actions.clearDrillContext),{selectDashboard:r}=Hh(),[s,o]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const k=_=>{o({x:_.clientX-c.current.x,y:_.clientY-c.current.y})},j=()=>{a(!1)};return document.addEventListener("mousemove",k),document.addEventListener("mouseup",j),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",j)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((C=(w=(S=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:S.filterGroups)==null?void 0:w[0])==null?void 0:C.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((N=e.appliedClickFilters)!=null&&N.length))return null;const p=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(k){console.error("[DrillBack] Error during back navigation:",k)}},g=()=>{n()},b=k=>{k.target.closest("button")||(a(!0),c.current={x:k.clientX-s.x,y:k.clientY-s.y})};uvt(f);const x=fvt(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${s.x}px, ${s.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((k,j)=>{const _=k.field.label||k.field.name,T=String(k.value);return l.jsxs(ws,{variant:"secondary",className:"pointer-events-none text-xs",children:[_," = ",T]},j)})})]}),l.jsx(m.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(m.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(m.Button,{variant:"secondary",size:"sm",onClick:p,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(hv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function pvt(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function mvt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:p,transition:g,isDragging:b}=yb({id:`filter:${e.id}`,disabled:n||!t}),x={transform:Fi.Translate.toString(p),transition:g,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:h,style:x,...d,children:l.jsx(ML,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const Eq="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",gvt=[];function mhe({open:e,onOpenChange:t}){var L,$,B;const[n,r]=v.useState(!1),[s,o]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=m.useDashboardStore(V=>{var F;return(F=V.dashboard)==null?void 0:F.sheets}),u=m.useDashboardStore(V=>V.dashboard),d=m.useDashboardStore(V=>V.dashboardInputValues),f=m.useDashboardStore(V=>V.filterValues),h=m.useDashboardStore(V=>V.controlValues),p=m.useDashboardStore(V=>V.inlineFilterValuesMap),g=m.useDashboardStore(V=>V.cardControlValuesMap),b=m.useDashboardStore(V=>V.selectedSheetId),x=m.useDashboardStore(V=>V.selectedSheetId?V.documentInputRuntimeBySheetId[V.selectedSheetId]:void 0),y=m.useDashboardStore(V=>V.isDownloadingPdf),{authToken:S,tokenProps:w}=Ct(),C=c==null?void 0:c.find(V=>V.id===b),N=v.useMemo(()=>m.getDashboardExportSheets(c),[c]),k=m.isDocumentSheet(C),j=k&&C?C.document:void 0,_=v.useMemo(()=>k&&C?Nw(u,C.id):[],[C,k,u]),T=_.length>0,E=v.useMemo(()=>k&&C?eue(u,C.id):!1,[C,k,u]),I=v.useMemo(()=>T?_.map(kw):(j==null?void 0:j.inputs)||gvt,[j,_,T]),D=(($=(L=w==null?void 0:w.params)==null?void 0:L.calendarContext)==null?void 0:$.tz)||((B=w==null?void 0:w.params)==null?void 0:B.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),A=v.useMemo(()=>ece(I),[I]),P=v.useMemo(()=>Qle(I,D),[I,D]),R=v.useMemo(()=>Jle(I),[I]),H=x?x.filterValuesByInputId:P,z=x?x.controlValuesByInputId:R,U=v.useMemo(()=>k?E&&C&&j?hX({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:j.sections.map(V=>V.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},timezone:D}):rce(I,H,z,A,A):[],[j,I,C,k,u,g,h,f,p,d,z,H,A,D,E]),W=!!C,O=N.length>0,Z=((c==null?void 0:c.length)||0)>1||k,Y=i.sheetSelection==="current"&&(!W||k&&U.length>0)||i.sheetSelection==="all"&&!O;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!O&&a(V=>({...V,sheetSelection:"current"}))},[O,e,i.sheetSelection]);const M=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function G(){if(y){at.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){at.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){at.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!O){at.error("No dashboard sheets are available to export");return}o(!0);const V=i.sheetSelection==="current"&&k,F=V?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",q=at.loading(F);try{if(V){if(!j||!C)throw new Error("Selected document sheet is missing document data");if(U.length>0){at.dismiss(q),at.error(`Set ${U.join(", ")} before exporting`);return}const X=new Date().toISOString(),ee=E?mX({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:j.sections.map(de=>de.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},generatedAt:X,timezone:D}).snapshot:void 0;await QP(w.apiServiceUrl,S,{sheetId:C.id,title:C.title||"Document",pageSize:j.page.size,orientation:j.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:ee,...ee?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:H,controlValuesByInputId:z,generatedAt:X}}})}else{const X=Hee();await SX(w.apiServiceUrl,S,i.protectPdf?i.password:void 0,i.sheetSelection,X)}at.dismiss(q);const K=V?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";at.success(K,{duration:2e3}),M()}catch(K){at.dismiss(q),at.error("Failed to download PDF",{description:Dj(K,"Please try again or contact support."),descriptionClassName:Ij,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",K)}finally{o(!1)}}return l.jsx(Vo,{open:e,onOpenChange:V=>{if(!V){M();return}t(!0)},children:l.jsxs(wo,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(da,{children:[l.jsx(So,{className:"text-[15px]",children:k?"Export document":"Export dashboard"}),l.jsx(fi,{className:"text-[13px] leading-5",children:k?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[Z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(m.Label,{className:Eq,children:"Export scope"}),l.jsxs(Oa,{value:i.sheetSelection,onValueChange:V=>a({...i,sheetSelection:V}),className:"gap-1.5",children:[l.jsxs(m.Label,{htmlFor:"scope-current",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!W&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Rs,{value:"current",id:"scope-current",disabled:!W}),k?"This document":"This sheet"," (",(C==null?void 0:C.title)||"Current",")"]}),l.jsxs(m.Label,{htmlFor:"scope-all",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!O&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Rs,{value:"all",id:"scope-all",disabled:!O}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),k&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:U.length>0?`Set ${U.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(m.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(m.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(Vn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:V=>{a({...i,protectPdf:V,password:V?i.password:""}),V||r(!1)}}),l.jsx(zk,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(m.Label,{htmlFor:"pdf-password",className:Eq,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(m.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:V=>a({...i,password:V.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:V=>{V.key==="Enter"&&i.password&&G()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx($k,{className:"h-3.5 w-3.5"}):l.jsx(pv,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(nu,{children:[l.jsx(m.Button,{variant:"outline",size:"xs",onClick:M,disabled:s,children:"Cancel"}),l.jsx(m.Button,{size:"xs",onClick:G,disabled:s||y||Y,children:s?l.jsxs(l.Fragment,{children:[l.jsx(m.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(eu,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function ghe({iconClassName:e,open:t,onOpenChange:n}){const[r,s]=v.useState(!1),o=t!==void 0,i=o?t:r,a=u=>{o||s(u),n==null||n(u)},c=m.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[o?null:l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(eu,{className:m.cn("size-4",e)})}),l.jsx(mhe,{open:i,onOpenChange:a})]})}function Tq(e,t,n){const r=new Set(t),s=[...n];return e.map(o=>r.has(o.id)?s.shift()??o.id:o.id)}function bvt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:s,listeners:o,setNodeRef:i,transform:a,transition:c,isDragging:u}=yb({id:`control:${e.id}`,disabled:!n}),d={transform:Fi.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...s,children:l.jsx(bce,{control:e,value:t,isEditing:n,dragListeners:n?o:void 0,onChange:r})})}function Iq(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function Dq(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function xvt(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return Dq(t,n);const s=e.filter(a=>r.has(a)),o=new Set(s),i=Dq(t,n).filter(a=>!o.has(a));return[...s,...i]}function yvt(e,t){return m.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function vvt(e){return Ym(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Ym(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function Mq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function wvt(e){const t={sheetId:e.selectedSheetId},n=m.getDashboardInputRuntimeSlot(e.dashboardInputValues,e.dashboardInput,t);if(n)return n;const r=m.getDashboardInputRuntimeSlot(e.defaultInputValues,e.dashboardInput,t);return r||m.getBackingDefaultSlot(e.dashboardInput)}function Svt(e){return bhe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function bhe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=yvt(e.dashboard,t);return AZ(Cj({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!vvt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function Cvt(e,t){return"toolbar"}function Nvt(){const e=su("interactive"),t=m.useDashboardStore($=>$.selectedSheetId),n=m.useDashboardStore($=>$.dashboard.filters),r=m.useDashboardStore($=>$.dashboard.filterLayout),s=m.useDashboardStore($=>$.isDashboardEditing),o=m.useDashboardStore($=>$.controlValues),i=m.useDashboardStore($=>$.filterValues);m.useDashboardStore($=>$.filteringCards);const a=m.useDashboardStore($=>$.inlineFilterValuesMap),c=m.useDashboardStore($=>$.dashboardInputValues),u=m.useInteractionStore($=>$.clearAllClickFilters),d=m.useInteractionStore($=>Object.entries($.interactionStates).reduce((B,[V,F])=>{var q;return V===m.DRILL_CONTEXT_CARD_ID?B:B+(((q=F.appliedClickFilters)==null?void 0:q.length)??0)},0)),f=m.useDashboardStore($=>$.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:p,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:S,setFilteringCards:w,upsertDashboardInput:C}=m.useDashboardActions(),N=G_(gg(bb,{activationConstraint:{distance:5}})),k=m.useDashboardStore($=>$.dashboard),j=Svt({dashboard:k,selectedSheetId:t}).filter($=>Cvt($.filter)==="toolbar"),_=bhe({dashboard:k,selectedSheetId:t}),T=j.map($=>$.filter),E=new Map(j.map($=>[`filter:${$.filter.id}`,$])),I=fZe(k),D=I.filter($=>!$.hidden&&O0($)==="toolbar"),A=I.filter($=>!$.hidden&&O0($)==="advanced"),P=xvt(r==null?void 0:r.toolbarItemOrder,T,D),R=new Map(T.map($=>[`filter:${$.id}`,$])),H=new Map(D.map($=>[`control:${$.id}`,$]));function z($){const{active:B,over:V}=$;if(!V||B.id===V.id)return;const F=String(B.id),q=String(V.id),K=P.findIndex(be=>be===F),X=P.findIndex(be=>be===q);if(K===-1||X===-1)return;const ee=xb(P,K,X);y({toolbarItemOrder:ee});const de=new Set((n||[]).map(be=>be.id)),fe=P.filter(be=>be.startsWith("filter:")).map(be=>be.replace("filter:","")).filter(be=>de.has(be)),ge=ee.filter(be=>be.startsWith("filter:")).map(be=>be.replace("filter:","")).filter(be=>de.has(be)),ve=P.filter(be=>be.startsWith("control:")).map(be=>be.replace("control:","")),ie=ee.filter(be=>be.startsWith("control:")).map(be=>be.replace("control:",""));h(Tq(n||[],fe,ge)),g(Tq(k.controls||[],ve,ie))}const U=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,O=(i==null?void 0:i.filter($=>Iq($)).length)??0,Z=_.filter(Mq),Y=Z.filter($=>{const B=wvt({dashboardInput:$,dashboardInputValues:c,defaultInputValues:k.defaultInputValues,selectedSheetId:t});return(B==null?void 0:B.status)==="set"&&B.value.kind==="filter"&&Iq(B.value.filterValue)}).length,M=a?Object.values(a).reduce(($,B)=>$+((B==null?void 0:B.length)??0),0):0,G=O+Y+M+d,L=()=>{S([]),Z.forEach($=>{p($,{sheetId:t})}),w([]),u(),a&&Object.entries(a).forEach(([$,B])=>{B==null||B.forEach(V=>{f($,V.filterId)})})};return!T.length&&!D.length&&!A.length&&!W&&G===0?null:l.jsx("div",{className:"z-20 border-b border-border/60 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(xw,{sensors:N,collisionDetection:mw,onDragEnd:z,children:l.jsxs("div",{className:m.cn("flex items-center",U?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(yw,{items:P,strategy:a3,children:l.jsx(zR,{className:"gap-3 pr-0",wrap:U,children:P.map($=>{const B=R.get($);if(B){const F=E.get($),q=F&&Mq(F);return l.jsx(mvt,{filter:B,isEditing:s,storageOptions:q?{storageTarget:"dashboardInput",dashboardInput:F,sheetId:t??void 0}:void 0,inputVariableName:q?F.variableName:void 0,onUpdateFilter:q?(K,X)=>{C({...F,variableName:(X==null?void 0:X.variableName)||F.variableName,filter:K})}:void 0,onRemoveFilter:q?()=>{S((i||[]).filter(K=>K.filterId!==B.id)),b(F.id)}:void 0},$)}const V=H.get($);return V?l.jsx(bvt,{control:V,value:o==null?void 0:o[V.id],isEditing:s,onChange:F=>x(V.id,F)},$):null})})}),A.length>0&&l.jsx(fae,{title:"",controls:A,values:o,onChange:($,B)=>x($.id,B),immediatePlacement:"toolbar",advancedLabel:"More controls"}),G>0&&l.jsxs("button",{type:"button",onClick:L,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(m.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:G})]}),W&&l.jsx("div",{className:m.cn(G>0?"ml-1.5":"ml-auto"),children:l.jsx(ghe,{})})]})})})}function xhe(){var J,he;const{showAssistant:e,tokenProps:t,renderMode:n}=Ct(),r=pvt((J=t.config)==null?void 0:J.showDashboardAssistant,e),{preferences:s,isConsoleMode:o}=jg(),i=(he=s==null?void 0:s.cardDisplay)==null?void 0:he.mode,a=Qh(i),c=XZ({displayMode:i,renderMode:n}),u=v.useRef(null),d=v.useRef(null),[f,h]=v.useState(!1),{handleDragStart:p,isDraggingRef:g,getStyle:b,getPositionClasses:x}=hit({initialPosition:"bottom-right"}),y=Qf(te=>te.setFullscreen),S=Qf(te=>te.setPanelOpen),w=Qf(te=>te.setContainer),C=zK("dashboard"),N=BK(),k=VK("dashboard"),j=C.isOpen,_=N==="dashboard",T=m.useDashboardStore(te=>te.isVisualEditing),E=m.useDashboardStore(te=>te.themeStyle),I=Hl(),D=m.useDashboardStore(te=>{var Se;return(Se=te.dashboard)==null?void 0:Se.sheets}),A=m.useDashboardStore(te=>te.showFilters),P=m.useDashboardStore(te=>te.isDashboardEditing),R=m.useDashboardStore(te=>te.selectedSheetId),H=D==null?void 0:D.find(te=>te.id===R),z=m.useDashboardStore(te=>{var Se,we,ne;return(ne=(we=(Se=te.dashboard)==null?void 0:Se.sheets)==null?void 0:we.find(_e=>_e.id===te.selectedSheetId))==null?void 0:ne.kind}),U=m.useDashboardStore(te=>{var Se,we;return((we=(Se=te.dashboard)==null?void 0:Se.summary)==null?void 0:we.position)||"top"}),W=z==="document",O=m.useDashboardStore(te=>{var Se;return(Se=te.dashboard)==null?void 0:Se.id}),Z=m.useDashboardStore(te=>te.isDashboardPanelOpen),Y=m.useDashboardStore(te=>te.actions.setIsDashboardPanelOpen),{getDefaultSheetId:M,setDefaultSheetId:G,clearDefaultSheetId:L}=xW(O),[$,B]=v.useState(null);Zk(rs.DASHBOARD);const{setSelectedSheetId:V,setSheetTitle:F,addSheet:q,setSheets:K}=m.useDashboardActions();tvt(d);const{setActiveAssistantType:X}=m.useAIActions();v.useEffect(()=>{if(O){const te=M();B(te)}},[O,M]),v.useEffect(()=>{j?X("dashboard"):N==="dashboard"&&y(null)},[j,X,N,y]),v.useEffect(()=>{var te;j||(te=u.current)==null||te.resize(0)},[j]);function ee(te){var Se,we;te?((Se=u.current)==null||Se.resize(40),S("dashboard",!0),y("dashboard"),X("dashboard")):(S("dashboard",!1),y(null),(we=u.current)==null||we.resize(0),X(null))}function de(te="dashboard"){const Se={id:m.v4(),title:te==="document"?"New Document":"New Sheet",...te==="document"?{kind:te,document:m.createDefaultDocumentDefinition()}:{}};q(Se),V(Se.id)}function fe(te,Se){if(!O)return;$===te?(L(),B(null),at.success("Default sheet cleared")):(G(te),B(te),at.success(`"${Se}" set as default sheet`))}function ge(te){var Se;te<1?(S("dashboard",!1),y(null),X(null),(Se=u.current)==null||Se.resize(0)):(j||S("dashboard",!0),X("dashboard"))}function ve(){return(E==null?void 0:E.canvasTheme)==="muted"||!(E!=null&&E.canvasTheme)?"hsl(var(--semaphor-muted))":(E==null?void 0:E.canvasTheme)==="clear"?"":E==null?void 0:E.canvasTheme}const ie=(te,Se)=>{te.dataTransfer.setData("tabIndex",Se.toString())},be=te=>{te.preventDefault()},oe=(te,Se)=>{const we=te.dataTransfer.getData("tabIndex");if(we===Se.toString())return;const ne=Array.from(D||[]),[_e]=ne.splice(parseInt(we),1);ne.splice(Se,0,_e),K(ne)},Ae=t.orgUserId||t.tenantId&&t.endUserId&&t.endUserEmail,ae=r===!0&&!a&&!j&&!T&&!A;function me(){if(D&&D.length>1||P)return l.jsxs("div",{className:"relative flex w-full items-stretch border-b border-border",children:[o&&Ae&&!Z&&l.jsx("button",{type:"button","aria-label":"Toggle dashboards panel",onClick:()=>{Y(!Z)},className:"group/panel mx-2 inline-flex h-9 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground",children:l.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-[4px] group-hover/panel:bg-muted",children:l.jsx(DF,{className:"h-3.5 w-3.5",strokeWidth:1.75})})}),l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(m.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[D==null?void 0:D.map((te,Se)=>{const we=R===te.id,ne=$===te.id;return l.jsxs(m.TabsTrigger,{draggable:!0,onDragStart:_e=>ie(_e,Se),onDragOver:be,onDrop:_e=>oe(_e,Se),onClick:()=>V(te.id),className:m.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:te.id,children:[te.kind==="document"&&l.jsx(Ti,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(ZN,{enabled:P&&we,text:te.title,onSave:_e=>F(te.id,_e),children:te.title},te.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ne?"Clear default sheet":"Set as default sheet",title:ne?"Clear default sheet":"Set as default sheet",onClick:_e=>{_e.stopPropagation(),fe(te.id,te.title||"Sheet")},onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),_e.stopPropagation(),fe(te.id,te.title||"Sheet"))},className:m.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",we||ne?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(FF,{className:m.cn("h-3 w-3 transition-colors",ne?"fill-current text-amber-500":"text-muted-foreground")})}),P&&we&&D.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:_e=>{_e.stopPropagation(),h(!0)},onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),_e.stopPropagation(),h(!0))},children:l.jsx(m.X,{className:"h-3 w-3"})})]},te.id)}),P&&l.jsxs(Lo,{children:[l.jsx($o,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(yr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(xo,{align:"start",className:"w-48",children:[l.jsxs(In,{onSelect:()=>de("dashboard"),children:[l.jsx(Vm,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(In,{onSelect:()=>de("document"),children:[l.jsx(Ti,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})]})}function Ce(){return l.jsx("div",{ref:d,style:{},className:"h-full min-h-0 grow",children:D==null?void 0:D.map(te=>l.jsx(m.TabsContent,{style:{backgroundColor:ve(),...I.dashboardCanvasStyle},className:m.cn("mt-0 h-full min-h-0",{}),value:te.id,children:l.jsx(OH,{sheet:te})},te.id))})}function se(){return l.jsxs(m.Tabs,{"data-role":"dashboard-tabs-container",className:m.cn("relative flex h-full flex-col",E==null?void 0:E.dashboardTabsContainer),onValueChange:te=>{V(te)},value:R||void 0,children:[me(),U==="top"&&!W&&l.jsx(vR,{}),R&&!W&&l.jsx(Nvt,{}),W?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:Ce()}):l.jsx(Kl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:Ce()}),U==="bottom"&&!W&&l.jsx(vR,{}),l.jsx(pit,{open:f,setOpen:h})]})}const re=v.useCallback(te=>{w("dashboard",te)},[w]);return D?c&&R&&!W?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',R,'" was not found or is not a document sheet in the loaded dashboard.']}):c&&W&&H?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(OH,{sheet:H})}):l.jsxs(l.Fragment,{children:[l.jsx(cvt,{}),l.jsx(hvt,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(iP,{className:m.cn("flex-1 basis-0 overflow-y-auto transition-opacity",_&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(Gy,{children:se()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(fit,{open:j,onTabClick:ee,withHandle:!0,disabled:!j}),l.jsx(Gy,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:ge,defaultSize:j?40:0,ref:u,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(evt,{open:j,setOpen:ee,isFullscreen:_,onFullscreenChange:te=>y(te?"dashboard":null),fullscreenContainer:k})})})]})]}),l.jsx("div",{ref:re,className:m.cn("absolute inset-0",!_&&"pointer-events-none")}),ae&&l.jsx("div",{className:m.cn("absolute z-50 transition-all duration-300 ease-in-out",x().horizontal,x().vertical),style:b(),children:l.jsx(m.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{g.current||ee(!0)},onMouseDown:p,onTouchStart:p,title:"Open Assistant (drag to move)",children:l.jsx(Qme,{className:"h-5 w-5"})})})]})]}):null}const yhe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:s,children:o,className:i,style:a,...c},u)=>{const d=v.useId(),f=v.useMemo(()=>kvt(d),[d]),{theme:h}=xF(),p=jvt(h),g=v.useMemo(()=>s??Jc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,s,n]),b=v.useMemo(()=>m.compileAppearance({spec:g,systemMode:p}),[g,p]),x=v.useMemo(()=>m.createAppearanceContextValue(f,b),[b,f]);return l.jsx(m.AppearanceContext.Provider,{value:x,children:l.jsx(fb,{...c,ref:u,className:i,style:a,children:o})})});yhe.displayName="AppearanceProvider";function kvt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function jvt(e){const t=NC(e),[n,r]=v.useState(()=>_vt());return v.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const s=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!s)return;const o=()=>{r(s.matches?"dark":"light")};return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):((a=s.addListener)==null||a.call(s,o),()=>{var c;return(c=s.removeListener)==null?void 0:c.call(s,o)})},[t]),t==="system"?n:t}function _vt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const vhe=v.createContext({openBrandStudioPreview:()=>{}}),Evt=vhe.Provider;function Tvt(){return v.useContext(vhe)}function Ivt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const s=NC(t),[o,i]=v.useState(()=>Dvt(n)||s),a=v.useCallback(u=>{const d=NC(u);Mvt(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:o,setTheme:a}),[o,a]);return l.jsx(Zq.Provider,{...r,value:c,children:e})}function Dvt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=NC(t,"system");return n===t?n:null}catch{return null}}function Mvt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const Avt=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function I$({appearance:e,children:t}){var I,D;const{authToken:n,id:r,tokenProps:s}=Ct(),o=dv(),i=(I=o.data)==null?void 0:I.organizationAppearance,a=(D=s.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,p]=v.useState(null),[g,b]=v.useState(null),[x,y]=v.useState(null),S=`${s.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,w=Bn({queryKey:tG({resourceType:rs.DASHBOARD,apiServiceUrl:s.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>m.getRequest(`${s.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:A=>(A==null?void 0:A.organizationAppearance)??null,enabled:!o.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:S,appearance:i})},[i,S]),v.useEffect(()=>{w.data!==void 0&&y({scopeKey:S,appearance:w.data})},[w.data,S]);const C=(x==null?void 0:x.scopeKey)===S?x.appearance:null,N=i!==void 0?i:w.data!==void 0?w.data:C,k=v.useMemo(()=>Jc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),j=v.useCallback(()=>{f(g??h??k),u(!0)},[g,h,k]),_=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),p(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:j}),[j]),E=g??h??e;return l.jsx(Ivt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(Evt,{value:T,children:l.jsx(yhe,{organizationAppearance:N,tokenAppearance:a,reactAppearance:E,style:{height:"100%",width:"100%"},children:l.jsxs(m.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(Avt,{appearance:d,onDraftChange:b,onSave:A=>{p(A),b(A),f(A)},onCancel:_})})})]})})})})}function whe({children:e,preferences:t}){const{currentUser:n}=ua(),r=v.useMemo(()=>{var s,o;return{preferences:t||{},isLocalDev:((s=t==null?void 0:t.uiMode)==null?void 0:s.developer)||!1,isConsoleMode:((o=t==null?void 0:t.uiMode)==null?void 0:o.console)||!1}},[t]);return l.jsx(QY.Provider,{value:r,children:l.jsx(V_,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function Rvt(e=2e3,t=500){const n=lme(),[r,s]=v.useState(!1),[o,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>s(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),o}function D$({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const s=Rvt(e,t);return v.useEffect(()=>(s&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[s,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:s?"ready":""})}function She(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(za,{FallbackComponent:z_,children:l.jsxs(NF,{dashboardProps:e,children:[l.jsx(D$,{componentType:"dashboard",componentId:e.id}),l.jsx(I$,{appearance:e.appearance,children:l.jsx(whe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(cP,{...e,type:"dashboard",children:l.jsx(xhe,{})})})})})]})})}function Fvt(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[s,o]=v.useState(),i=v.useCallback(()=>{var p,g,b;const a=((p=t.current)==null?void 0:p.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);o(x=>x===h?x:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:s,updateAvailableWidth:i}}function Pvt({filter:e}){var g;const t=m.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=jg(),r=Qh((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),s=m.useDashboardStore(b=>b.filterValues),o=s==null?void 0:s.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=m.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:p}=Fvt([t,o,r]);return v.useEffect(()=>{p()},[e.title,p]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(m.Label,{className:"my-1 block w-full text-sm",children:l.jsx(ai,{value:e.title||e.column,onSave:b=>c({...e,title:b}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(DL,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(m.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Ovt(){const e=m.useDashboardStore(r=>r.dashboard.filters),t=m.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:m.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(Pvt,{filter:r}),l.jsx(A_,{filter:r})]},r.id))}):null}function Lvt(){var i;const e=m.useDashboardStore(a=>a.dashboard),t=m.useDashboardStore(a=>a.selectedSheetId),n=m.useDashboardStore(a=>a.isVisualEditing),r=m.useDashboardStore(a=>a.isDashboardEditing),s=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),o=m.isDocumentSheet(s);return l.jsx("div",{role:"dashboard-plus-main",className:m.cn("",{"max-h-0 overflow-hidden":n,"flex min-h-0 grow basis-0 overflow-hidden":!n}),children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[r&&!o&&l.jsx(Ovt,{}),l.jsx(xhe,{})]})})}const $vt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-7uVDGJgT.js"))),zvt=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-4wuOgtnP.js"))),Bvt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-CVlvQrWF.js"))),Vvt=v.lazy(()=>Promise.resolve().then(()=>require("./resource-management-panel-DO4VOGlS.js")).then(e=>({default:e.ResourceManagementPanel})));function Hvt({showControls:e=!1,showFooter:t=!0,...n}){const r=m.useDashboardStore(u=>u.isDashboardPanelOpen),s=m.useDashboardStore(u=>u.isVisualEditing),o=m.useDashboardStore(u=>u.showDashboardJSON),i=m.useDashboardStore(u=>u.actions.setIsDashboardPanelOpen),{appearance:a,preferences:c}=n;return l.jsx(za,{FallbackComponent:z_,children:l.jsxs(NF,{dashboardProps:n,children:[l.jsx(D$,{componentType:"surfboard",componentId:n.id}),l.jsxs(I$,{appearance:a,children:[l.jsx(oxe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(whe,{preferences:c,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(Bvt,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(v.Suspense,{fallback:null,children:l.jsx($vt,{})}),l.jsxs("div",{className:"flex grow overflow-hidden",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(Vvt,{isOpen:r,onClose:()=>i(!1),variant:"inline"})}),l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(cP,{...n,type:"dashboard",children:[s&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(zvt,{})}),l.jsx(Lvt,{})]})})]})]})]})]})]})})}var Uvt=Object.defineProperty,qvt=(e,t,n)=>t in e?Uvt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,IS=(e,t,n)=>qvt(e,typeof t!="symbol"?t+"":t,n);const Wvt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},Yvt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},Gvt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function Kvt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function Che(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const Zvt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const s=Che(t);if(typeof n<"u"&&s in n.container)return n.container[s]})();return typeof r=="function"?r.bind(n):void 0}},Xvt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},Qvt={stringify:e=>e,parse:e=>e},_2={string:Qvt,number:Xvt,boolean:Wvt,function:Yvt,method:Zvt,json:Gvt},kx=Symbol.for("r2wc.render"),DS=Symbol.for("r2wc.connected"),af=Symbol.for("r2wc.context"),bi=Symbol.for("r2wc.props");function Jvt(e,t,n){var r,s,o;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const p of i){c[p]=Array.isArray(t.props)?"string":t.props[p];const g=Kvt(p);d[p]=g,f[g]=p}for(const p of a)u[p]=Array.isArray(t.events)?{}:t.events[p];class h extends HTMLElement{constructor(){super(),IS(this,o,!0),IS(this,s),IS(this,r,{}),IS(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[bi].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],S=y?_2[y]:null;if(y==="method"){const w=Che(b);Object.defineProperty(this[bi].container,w,{enumerable:!0,configurable:!0,get(){return this[bi][w]},set(C){this[bi][w]=C,this[kx]()}}),this[bi][g]=S.parse(x,b,this)}S!=null&&S.parse&&x&&(this[bi][g]=S.parse(x,b,this))}for(const g of a)this[bi][g]=b=>{const x=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(x,{detail:b,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[DS]=!0,this[kx]()}disconnectedCallback(){this[DS]=!1,this[af]&&n.unmount(this[af]),delete this[af]}attributeChangedCallback(g,b,x){const y=f[g],S=c[y],w=S?_2[S]:null;y in c&&w!=null&&w.parse&&x&&(this[bi][y]=w.parse(x,g,this),this[kx]())}[(o=DS,s=af,r=bi,kx)](){this[DS]&&(this[af]?n.update(this[af],this[bi]):this[af]=n.mount(this.container,e,this[bi]))}}for(const p of i){const g=d[p],b=c[p];Object.defineProperty(h.prototype,p,{enumerable:!0,configurable:!0,get(){return this[bi][p]},set(x){this[bi][p]=x;const y=b?_2[b]:null;if(y!=null&&y.stringify){const S=y.stringify(x,g,this);this.getAttribute(g)!==S&&this.setAttribute(g,S)}else this[kx]()}})}return h}function ewt(e,t,n){const r=Yq.createRoot(e),s=v.createElement(t,n);return r.render(s),{root:r,ReactComponent:t}}function twt({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function nwt({root:e}){e.unmount()}function rwt(e,t={}){return Jvt(e,t,{mount:ewt,update:twt,unmount:nwt})}const swt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},owt=rwt(She,{props:swt}),iwt=v.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(D3,{context:t})," "]})}),Nhe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),awt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),lwt=Array.from(Nhe).join(", "),cwt=3,uwt="Self-heal",dwt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function fwt({card:e}){var W,O,Z,Y,M;const[t,n]=v.useState({}),{authToken:r}=Ct(),s=m.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:o}=m.useAppearance(),i=v.useMemo(()=>iw(o),[o]),a=m.useEditorStore(G=>G.frame),c=m.useEditorStore(G=>G.inlineFilterValuesMap[e.id]),u=m.useEditorStore(G=>G.actions.setCardInlineFilterValue),d=m.useEditorStore(G=>G.actions.removeCardInlineFilterValue),f=e,{getCard:h,manifest:p}=op(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(O=p==null?void 0:p.visuals)==null?void 0:O.find(G=>{var L;return G.name===((L=f.customCardPreferences)==null?void 0:L.componentName)}),b=aw(f,g)??"single",x=v.useMemo(()=>PL({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=v.useMemo(()=>{const G=x.findIndex(L=>(L==null?void 0:L.id)===e.id);return G<0?-1:A0(e,G)},[x,e]),S=v.useMemo(()=>b!=="multiple"||y<0?e.type:Sm(e,y,g==null?void 0:g.slots)??e.type,[b,y,e,g==null?void 0:g.slots]),w=v.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:S!==e.type?{...e,type:S}:e,[e,S,b]),{data:C}=Ej(w),N=m.useInteractionStore(G=>G.interactionStates),k=m.useDashboardStore(G=>{var L;return(L=G.dashboard)==null?void 0:L.id}),j=m.useDashboardStore(G=>G.dashboard.filters),_=m.useDashboardStore(G=>G.filterValues),T=m.useDashboardStore(G=>G.selectedSheetId),E=v.useMemo(()=>AL({card:e,sheetId:T||"",inlineFilterValues:c,setInlineFilterValue:G=>u(e.id,G),removeInlineFilterValue:G=>d(e.id,G)}),[e,T,c,u,d]),{cardFilters:I,cardFilterValues:D}=v.useMemo(()=>Nv({card:e,interactionStates:N,currentDashboardId:k,filters:j,filterValues:_,selectedSheetId:T}),[e,N,k,j,_,T]),A=v.useCallback((G,L)=>{const $=LL(L);n(B=>({...B,[G]:$}))},[]),P=(Z=f.customCardPreferences)==null?void 0:Z.componentName,R=P?h(P):null,H=GN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),z=v.useMemo(()=>FL(x),[x]),U=v.useMemo(()=>z.map((G,L)=>Sm(G,L,g==null?void 0:g.slots)),[z,g==null?void 0:g.slots]);return P?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[R&&b==="single"&&l.jsx(R,{editing:!0,params:s,theme:i,settings:H,cardMetadata:Iie({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:A,data:(C==null?void 0:C.records)||[],filters:I,filterValues:[...D||[],...c||[]],inlineFilters:E}),R&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((G,L)=>{if(!G)return null;const $=A0(G,L),B=Sm(G,$,g==null?void 0:g.slots);return l.jsx(oL,{onDataChange:A,card:G,effectiveCardType:B},`${G.id}-${$}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(R,{editing:!0,onDataChange:A,...$L({configCard:f,slotOrderedCards:z,slotTypes:U,multiInputData:t,params:s,theme:i,chartSettings:H,filters:I,filterValues:[...D||[],...c||[]],inlineFilters:E})})})]})]},(M=f.customCardPreferences)==null?void 0:M.componentName)}):null}const hwt=v.memo(fwt,(e,t)=>{var n,r,s,o,i,a,c,u;return e.card.id===t.card.id&&e.card.inlineFilters===t.card.inlineFilters&&((n=e.card.customCardPreferences)==null?void 0:n.settings)===((r=t.card.customCardPreferences)==null?void 0:r.settings)&&((s=e.card.customCardPreferences)==null?void 0:s.slotSettings)===((o=t.card.customCardPreferences)==null?void 0:o.slotSettings)&&((i=e.card.customCardPreferences)==null?void 0:i.url)===((a=t.card.customCardPreferences)==null?void 0:a.url)&&((c=e.card.customCardPreferences)==null?void 0:c.componentName)===((u=t.card.customCardPreferences)==null?void 0:u.componentName)}),pwt=m.create()(m.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(s=>s.type===n&&s.id===r),toggleStar:n=>{e(r=>{const s=r.starredCharts.findIndex(o=>o.type===n.type&&o.id===n.id);return s>=0?{starredCharts:r.starredCharts.filter((o,i)=>i!==s)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(s=>s.type===n&&s.id===r)}),{name:"semaphor-starred-charts"}));var khe=["PageUp","PageDown"],jhe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],_he={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},jb="Slider",[pF,mwt,gwt]=m.createCollection(jb),[Ehe]=m.createContextScope(jb,[gwt]),[bwt,TE]=Ehe(jb),The=Q.forwardRef((e,t)=>{const{name:n,min:r=0,max:s=100,step:o=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:p=!1,form:g,...b}=e,x=Q.useRef(new Set),y=Q.useRef(0),w=i==="horizontal"?xwt:ywt,[C=[],N]=m.useControllableState({prop:d,defaultProp:u,onChange:I=>{var A;(A=[...x.current][y.current])==null||A.focus(),f(I)}}),k=Q.useRef(C);function j(I){const D=Nwt(C,I);E(I,D)}function _(I){E(I,y.current)}function T(){const I=k.current[y.current];C[y.current]!==I&&h(C)}function E(I,D,{commit:A}={commit:!1}){const P=Ewt(o),R=Twt(Math.round((I-r)/o)*o+r,P),H=m.clamp(R,[r,s]);N((z=[])=>{const U=Swt(z,H,D);if(_wt(U,c*o)){y.current=U.indexOf(H);const W=String(U)!==String(z);return W&&A&&h(U),W?U:z}else return z})}return l.jsx(bwt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:s,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(pF.Provider,{scope:e.__scopeSlider,children:l.jsx(pF.Slot,{scope:e.__scopeSlider,children:l.jsx(w,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:m.composeEventHandlers(b.onPointerDown,()=>{a||(k.current=C)}),min:r,max:s,inverted:p,onSlideStart:a?void 0:j,onSlideMove:a?void 0:_,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&E(r,0,{commit:!0}),onEndKeyDown:()=>!a&&E(s,C.length-1,{commit:!0}),onStepKeyDown:({event:I,direction:D})=>{if(!a){const R=khe.includes(I.key)||I.shiftKey&&jhe.includes(I.key)?10:1,H=y.current,z=C[H],U=o*R*D;E(z+U,H,{commit:!0})}}})})})})});The.displayName=jb;var[Ihe,Dhe]=Ehe(jb,{startEdge:"left",endEdge:"right",size:"width",direction:1}),xwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:s,inverted:o,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=Q.useState(null),p=m.useComposedRefs(t,w=>h(w)),g=Q.useRef(void 0),b=m.useDirection(s),x=b==="ltr",y=x&&!o||!x&&o;function S(w){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],j=M$(N,y?[n,r]:[r,n]);return g.current=C,j(w-C.left)}return l.jsx(Ihe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(Mhe,{dir:b,"data-orientation":"horizontal",...d,ref:p,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const C=S(w.clientX);i==null||i(C)},onSlideMove:w=>{const C=S(w.clientX);a==null||a(C)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const N=_he[y?"from-left":"from-right"].includes(w.key);u==null||u({event:w,direction:N?-1:1})}})})}),ywt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:s,onSlideStart:o,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=m.useComposedRefs(t,d),h=Q.useRef(void 0),p=!s;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],w=M$(y,p?[r,n]:[n,r]);return h.current=x,w(b-x.top)}return l.jsx(Ihe,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:l.jsx(Mhe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);o==null||o(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=_he[p?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),Mhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=TE(jb,n);return l.jsx(m.Primitive.span,{...u,ref:t,onKeyDown:m.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):khe.concat(jhe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:m.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:m.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&s(f)}),onPointerUp:m.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),o(f))})})}),Ahe="SliderTrack",Rhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=TE(Ahe,n);return l.jsx(m.Primitive.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...r,ref:t})});Rhe.displayName=Ahe;var mF="SliderRange",Fhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=TE(mF,n),o=Dhe(mF,n),i=Q.useRef(null),a=m.useComposedRefs(t,i),c=s.values.length,u=s.values.map(h=>Lhe(h,s.min,s.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(m.Primitive.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...r,ref:a,style:{...e.style,[o.startEdge]:d+"%",[o.endEdge]:f+"%"}})});Fhe.displayName=mF;var gF="SliderThumb",Phe=Q.forwardRef((e,t)=>{const n=mwt(e.__scopeSlider),[r,s]=Q.useState(null),o=m.useComposedRefs(t,a=>s(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(vwt,{...e,ref:o,index:i})}),vwt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:s,...o}=e,i=TE(gF,n),a=Dhe(gF,n),[c,u]=Q.useState(null),d=m.useComposedRefs(t,S=>u(S)),f=c?i.form||!!c.closest("form"):!0,h=m.useSize(c),p=i.values[r],g=p===void 0?0:Lhe(p,i.min,i.max),b=Cwt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?kwt(x,g,a.direction):0;return Q.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(pF.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(m.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":p,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...o,ref:d,style:p===void 0?{display:"none"}:e.style,onFocus:m.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(Ohe,{name:s??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},r)]})});Phe.displayName=gF;var wwt="RadioBubbleInput",Ohe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const s=Q.useRef(null),o=m.useComposedRefs(s,r),i=m.usePrevious(t);return Q.useEffect(()=>{const a=s.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(m.Primitive.input,{style:{display:"none"},...n,ref:o,defaultValue:t})});Ohe.displayName=wwt;function Swt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((s,o)=>s-o)}function Lhe(e,t,n){const o=100/(n-t)*(e-t);return m.clamp(o,[0,100])}function Cwt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Nwt(e,t){if(e.length===1)return 0;const n=e.map(s=>Math.abs(s-t)),r=Math.min(...n);return n.indexOf(r)}function kwt(e,t,n){const r=e/2,o=M$([0,50],[0,r]);return(r-o(t)*n)*n}function jwt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function _wt(e,t){if(t>0){const n=jwt(e);return Math.min(...n)>=t}return!0}function M$(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Ewt(e){return(String(e).split(".")[1]||"").length}function Twt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var $he=The,Iwt=Rhe,Dwt=Fhe,Mwt=Phe;const zhe=Q.forwardRef(({className:e,...t},n)=>l.jsxs($he,{ref:n,className:m.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(Iwt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(Dwt,{className:"absolute h-full bg-primary"})}),l.jsx(Mwt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));zhe.displayName=$he.displayName;const Bhe=["SUN","MON","TUE","WED","THU","FRI","SAT"],Awt=Bhe.reduce((e,t,n)=>({...e,[t]:n}),{}),uc={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function Rwt(e){if(!e||!e.trim())return{...uc};const t=e.trim(),r=(t.startsWith("cron(")&&t.endsWith(")")?t.slice(5,-1):t).trim().split(/\s+/);if(r.length<5||r.length>6)return{...uc,isCustom:!0};const[s,o,i,a,c]=r,u=Number(s),d=Number(o);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...uc,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...uc,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(p=>p.toUpperCase()).map(p=>Awt[p]).filter(p=>typeof p=="number");if(h.length>0)return{...uc,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...uc,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...uc,repeats:"monthly",hour:d,minute:u}:{...uc,hour:d,minute:u,isCustom:!0}}function Fwt(e){const t=e.minute,n=e.hour;switch(e.repeats){case"daily":return`cron(${t} ${n} * * ? *)`;case"weekly":{const r=e.weekdays.length>0?e.weekdays.slice().sort((s,o)=>s-o).map(s=>Bhe[s]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function Vhe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,s=t.toString().padStart(2,"0");return`${r}:${s} ${n}`}function Pwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Owt(e){if(e.length===7)return"every day";const t=e.slice().sort((s,o)=>s-o);if(t.length===5&&t.every(s=>s>=1&&s<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(s=>r[s]).join(", ")}function Lwt(e,t,n,r){const s=Vhe(e.hour,e.minute),o=Pwt(t);let i;if(e.isCustom)i=`Custom schedule · ${s} ${o}`;else switch(e.repeats){case"daily":i=`Daily at ${s} ${o}`;break;case"weekly":i=`Weekly · ${Owt(e.weekdays)} at ${s} ${o}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${s} ${o}`;break;case"monthly":i=`Monthly on the 1st at ${s} ${o}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const $wt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=C3;exports.AccordionContent=q0;exports.AccordionItem=H0;exports.AccordionTrigger=U0;exports.AddDataPicker=a$;exports.AggregateTable=l_;exports.Alert=nO;exports.AlertDescription=rO;exports.AlertDialog=Wc;exports.AlertDialogAction=Rl;exports.AlertDialogCancel=Fl;exports.AlertDialogContent=Tl;exports.AlertDialogDescription=Al;exports.AlertDialogFooter=Dl;exports.AlertDialogHeader=Il;exports.AlertDialogTitle=Ml;exports.AlertDialogTrigger=sM;exports.AlertTitle=WX;exports.ArrowDown=Hs;exports.ArrowDownIcon=bYe;exports.ArrowLeft=hv;exports.ArrowRight=Ok;exports.ArrowUp=io;exports.ArrowUpIcon=yYe;exports.AssistantContextEntityControls=tF;exports.AssistantVirtualizedMessages=phe;exports.AtSign=CW;exports.AxisConfigurator=Fg;exports.Badge=ws;exports.Bell=RS;exports.BookType=kW;exports.BulletChartIcon=ihe;exports.COMMON_TIMEZONES=$wt;exports.CSS=Fi;exports.CalculatedFieldEditor=Vle;exports.Calculator=_W;exports.Calendar=ki;exports.Calendar$1=aC;exports.CalendarRange=EW;exports.Card=$m;exports.CardContent=Pk;exports.CardHeader=Fk;exports.CardSummary=_R;exports.CardTitle=Cg;exports.ChartArea=X2;exports.ChartColumnIncreasing=TW;exports.ChartColumnStacked=IW;exports.ChartJsVisual=Qv;exports.ChartLine=DW;exports.ChartNoAxesGantt=AW;exports.ChartPie=RW;exports.ChartScatter=FW;exports.ChatInputWithContext=l$;exports.Checkbox=Vn;exports.ChevronLeft=Uh;exports.ChevronRight=vr;exports.Circle=Lk;exports.CircleAlert=mh;exports.CircleCheck=LW;exports.CircleHelp=$W;exports.Clock=EF;exports.CodeHighlighter=Zu;exports.CodeXml=Zf;exports.Collapsible=Zc;exports.CollapsibleContent=Qc;exports.CollapsibleTrigger=Xc;exports.ColorField=Zi;exports.Command=J_;exports.CommandEmpty=tE;exports.CommandGroup=nE;exports.CommandInput=d3;exports.CommandItem=rE;exports.CommandList=eE;exports.CommandSeparator=lle;exports.ComparisonMetadataBadge=gte;exports.Container=cP;exports.ControlDefaultValueEditor=uce;exports.ControlDefinitionOptionsEditor=cce;exports.ControlIdInput=oce;exports.ControlVisibilitySettings=Int;exports.Copy=_l;exports.CopyButton=od;exports.CopyPlus=J2;exports.Cross2Icon=CYe;exports.CustomFilterPopover=DL;exports.CustomScrollArea=Kl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=yee;exports.DEFAULT_SCHEDULE_VM=uc;exports.Dashboard=She;exports.DashboardActionsMenu=JY;exports.DashboardCard=pae;exports.DashboardCreateDialogBase=IG;exports.DashboardExportDialog=mhe;exports.DashboardPlus=Hvt;exports.DashboardWC=owt;exports.DataAppBuilder=OK;exports.DataTableConditionalFormattingSettings=Qce;exports.DataTablePagination=n_;exports.Database=li;exports.DateRangePicker=dL;exports.DefaultChatTransport=J3;exports.Dialog=Vo;exports.DialogContent=wo;exports.DialogDescription=fi;exports.DialogFooter=nu;exports.DialogHeader=da;exports.DialogTitle=So;exports.DialogTrigger=_G;exports.DisplayPreferencesProvider=V_;exports.DndContext=xw;exports.Donut=zW;exports.Download=eu;exports.DownloadPdf=ghe;exports.DragOverlay=Gae;exports.DropdownMenu=Lo;exports.DropdownMenuCheckboxItem=Nu;exports.DropdownMenuContent=xo;exports.DropdownMenuItem=In;exports.DropdownMenuLabel=Fc;exports.DropdownMenuRadioGroup=Mbe;exports.DropdownMenuRadioItem=XY;exports.DropdownMenuSeparator=Fa;exports.DropdownMenuSub=YF;exports.DropdownMenuSubContent=Yk;exports.DropdownMenuSubTrigger=Wk;exports.DropdownMenuTrigger=$o;exports.EMPTY_DATA_SOURCE=yg;exports.Editable=ZN;exports.EditableText=ai;exports.EditorCustomVisual=hwt;exports.Ellipsis=Ra;exports.EllipsisVertical=qh;exports.ErrorBoundary=za;exports.ExportError=Vg;exports.ExternalLink=Bm;exports.Eye=pv;exports.EyeOff=$k;exports.Fallback=z_;exports.FallbackVisual=F0;exports.FeedbackCategory=Td;exports.FeedbackDialog=nv;exports.FieldsList=D3;exports.FieldsSection=iwt;exports.FileSpreadsheet=BW;exports.FileText=Ti;exports.Filter=gh;exports.FilterComponent=A_;exports.FilterInfo=CR;exports.FilterableFieldsPanel=Ule;exports.Globe=Ng;exports.Grid3x3=VW;exports.GripVertical=tu;exports.HEATMAP_PRESET_PALETTES=cA;exports.Hash=HW;exports.House=UW;exports.HoverCard=Ug;exports.HoverCardContent=gd;exports.HoverCardTrigger=qg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=Nhe;exports.INLINE_ALLOWED_TOOL_LIST=lwt;exports.INLINE_BLOCKED_MUTATING_TOOLS=awt;exports.IconButton=Rc;exports.IconForFieldType=pC;exports.InfoHover=JL;exports.InlineFilterBar=sae;exports.KPICard=Cd;exports.KeyboardSensor=gw;exports.Layers=mv;exports.LayoutDashboard=Vm;exports.Link=TF;exports.LoadingDots=xd;exports.Lock=zk;exports.MAX_SELF_HEAL_ATTEMPTS=cwt;exports.Map=YW;exports.Markdown=jfe;exports.Maximize2=Bk;exports.MdStackedLineChart=she;exports.Minimize2=IF;exports.MultiInputEmptyRenderer=oL;exports.PYTHON_DEFAULT_CODE=bF;exports.PanelLeft=DF;exports.PanelResizeHandle=lj;exports.Paperclip=GW;exports.PenLine=eM;exports.Pencil=tM;exports.PendingMessagesDisplay=Bde;exports.PersistedDynamicVisual=B_;exports.PiChartPolar=ehe;exports.PivotTableTanstack=db;exports.Placeholders=sue;exports.Play=KW;exports.Plus=yr;exports.PointerSensor=bb;exports.Progress=o$;exports.RECOVERABLE_SQL_ERROR_CODES=dwt;exports.Radar=ZW;exports.RadioGroup=Oa;exports.RadioGroupItem=Rs;exports.RefreshCw=qc;exports.ResizableHandle=AK;exports.ResizablePanel=Gy;exports.ResizablePanelGroup=iP;exports.ResourceEditDialog=aK;exports.ResourceType=rs;exports.SELF_HEAL_TIMELINE_STEP=uwt;exports.Search=Xs;exports.SeedQuestions=jde;exports.SemaphorContext=Sg;exports.SemaphorContextProvider=NF;exports.SemaphorQueryClient=bW;exports.SemaphorReadyIndicator=D$;exports.SemaphorStyleWrapper=fb;exports.Send=MF;exports.Settings=AF;exports.Settings2=kg;exports.Share2=XW;exports.ShareDialog=iK;exports.Sheet=ste;exports.SheetContent=r5;exports.SheetDescription=o5;exports.SheetHeader=ite;exports.SheetTitle=s5;exports.SheetTrigger=S5e;exports.Slider=zhe;exports.SortableContext=yw;exports.Sparkles=DC;exports.Square=RF;exports.SquarePen=Hk;exports.Star=FF;exports.StructuralParticipantSelector=ice;exports.SummaryCard=vR;exports.TABLE_PRESENTATION_DEFAULT_STYLE=rd;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=Ji;exports.TableBody=_h;exports.TableCell=cr;exports.TableColumnVisibilitySettings=zce;exports.TableHead=ni;exports.TableHeader=Hg;exports.TablePresentationSettings=Vce;exports.TableRow=ts;exports.TableSkeleton=e3;exports.TableVisual=bd;exports.TbChartBubble=the;exports.TbChartFunnel=nhe;exports.TbChartTreemap=rhe;exports.TextCard=fg;exports.Textarea=Gh;exports.TiSortNumerically=ohe;exports.Toggle=L_;exports.Tornado=QW;exports.Trash2=El;exports.TreePalm=OF;exports.TrendingUp=JW;exports.TriangleAlert=ra;exports.TypeGlyph=dw;exports.UXProvider=I$;exports.User=eY;exports.Users=LF;exports.applyFilterOverridesToDashboardInputSlots=fX;exports.areContextEntitiesEqual=ur;exports.areEntitiesJoined=Nee;exports.arrayMove=xb;exports.buildCardControlUsageById=Mnt;exports.buildCustomCardTheme=iw;exports.buildDashboardCardExecutionSnapshot=dX;exports.buildDashboardControlUsageById=Dnt;exports.buildDashboardExecutionSnapshot=ZP;exports.buildDashboardInputExecutionSnapshot=Xu;exports.buildDashboardSheetsInputExecutionSnapshot=pX;exports.buildDashboardStructuralParticipantIdsByControlId=hce;exports.buildFilterFieldMeta=b3;exports.buildFilterSemanticContext=x3;exports.buildInlineFilterNodes=AL;exports.buildMultiInputCustomVisualProps=$L;exports.buildScheduleExpr=Fwt;exports.buildSchedulePreview=Lwt;exports.buildSlotOrderedCards=FL;exports.calculateContextAwareFilters=Nv;exports.calculateFieldState=GO;exports.canUserAccessVisuals=Ywe;exports.canUserCreateDashboards=$K;exports.canUserEdit=Uwe;exports.canUserManageDashboards=Wwe;exports.canUserManageGroups=Gwe;exports.canUserUseFilters=qwe;exports.cancelExport=uOe;exports.chartSupportsDataLabels=gJ;exports.chartSupportsLegend=pJ;exports.chartTypes=EE;exports.cleanupKpiMetricComparisonMode=gle;exports.cloneDeep=ri;exports.cloneLinkedFrameWithSourceMapping=FKe;exports.closestCenter=mw;exports.commitSharedCalculatedFields=gf;exports.createAssistantConversationId=Qp;exports.createAssistantRequestId=Nde;exports.createCardsFromSlots=ZYe;exports.createChartConfig=Bg;exports.createDashboardControlInputFromControl=_ot;exports.createDefaultGlobalDateFilter=HNe;exports.createExport=Uee;exports.createUniqueDashboardInputVariableNameFromName=id;exports.dedup=ift;exports.doesStoredFilterMatchField=bg;exports.downloadDocumentPdf=QP;exports.downloadPdf=SX;exports.extractSqlParamReferences=xoe;exports.extractTableMetadata=g3;exports.fieldAlreadyExists=jee;exports.findCustomVisualConfigCard=OL;exports.findDashboardFrameById=RNe;exports.flexRender=oi;exports.formatDisplayFormula=jet;exports.formatFileSize=hOe;exports.formatFilterLine=GX;exports.formatTimeLabel=Vhe;exports.getAutoDetectedChartIcon=g0t;exports.getChartGridStyle=h_e;exports.getChartIconByType=b0t;exports.getColorForValue=jM;exports.getConfigSlotExpectedType=KYe;exports.getCoreRowModel=Jj;exports.getCustomVisualInputCards=PL;exports.getDateFormatOptionsForGranularity=B0;exports.getDefaultAxisConfig=EM;exports.getDefaultChartColors=Jh;exports.getDefaultDataLabelsConfig=Pv;exports.getDefaultExportFormat=dQ;exports.getDefaultFilterSql=gL;exports.getDefaultLegendConfig=DO;exports.getDefaultRunningTotalPartitionByFieldIds=Ry;exports.getDocumentSectionEditorCard=cnt;exports.getDocumentSheetDashboardInputs=Nw;exports.getDownloadUrl=cOe;exports.getEffectiveCardTypeForSlot=Sm;exports.getEntityIcon=kk;exports.getErrorMessage=fde;exports.getExportStatus=lOe;exports.getExports=aOe;exports.getExpressionFieldKind=kd;exports.getFieldExpressionAnnotation=y3;exports.getFilterCount=tk;exports.getGlobalDateFilter=Tg;exports.getGlobalDateFilterCoverage=UNe;exports.getGranularityOptionsForFieldType=O3;exports.getKeys=Nr;exports.getMetricDisplayLabel=TPe;exports.getNewField=Dee;exports.getObjectDiff=Xq;exports.getPaginationRowModel=e_;exports.getRoleBasedDisplayOverrides=LK;exports.getRunningTotalOrderByCandidates=YJe;exports.getSelectedDateFilterColumn=voe;exports.getSheetScopedFilterValues=Qy;exports.getSlotDefinitionForIndex=RL;exports.getSlotExpectedChartType=P_;exports.getSlotIndexForCard=A0;exports.getSortedRowModel=rte;exports.getSupportedExportFormats=uQ;exports.getTableConditionalFormattingColumnOptions=Wce;exports.getTableOutputColumnOptions=Yce;exports.getTablePageSizeOptions=Bee;exports.handleAggregationChange=NR;exports.handleAggregationLabelChange=nae;exports.hasFlatTableTotalsBehavior=Lke;exports.horizontalListSortingStrategy=a3;exports.isCalculatedFilterField=V0;exports.isCardSummaryVisibleOnCard=zL;exports.isCustomVisualConfigCard=xR;exports.isDefaultColor=Yke;exports.isEligibleFlatTableTotalsCard=Ig;exports.isExportComplete=fOe;exports.isExportInProgress=dOe;exports.isInAiScopeArray=oft;exports.isManagedCalculatedExpressionField=Ma;exports.isMetricTransformEnabled=qJe;exports.isPromiseLike=eF;exports.isSubtotalEnabledAggregateTable=m3;exports.isSupportedDocumentTableCardType=unt;exports.lastAssistantMessageIsCompleteWithToolCalls=lde;exports.merge=jl;exports.mergeAxisConfig=TM;exports.normalizeConditionalFormatting=HP;exports.normalizeContextFormatMode=eQ;exports.normalizeDashboardInputVariableName=fv;exports.normalizeMultiInputPayload=LL;exports.parseScheduleExpr=Rwt;exports.pivotData=Tv;exports.prepareFeedbackData=_E;exports.purify=QA;exports.reindexSlotCards=GYe;exports.remarkGfm=Zfe;exports.removeFromScopeArray=aft;exports.resolveDashboardInputContext=Gl;exports.resolveDomainCalculatedFieldForEdit=wtt;exports.resolveMultiInputType=aw;exports.resolveMultiInputTypeFromVisual=XYe;exports.resolveTablePageSize=Zj;exports.resolveTablePresentationStyle=p5;exports.sanitizeAIScope=dde;exports.saveCalculatedFieldToCardScope=PR;exports.saveCalculatedFieldToSharedScope=Hle;exports.saveCalculatedFieldToSheetScope=OR;exports.seedSemanticMetricFormatDefaults=xle;exports.setTableColumnVisibility=Yee;exports.setupEditorWithCard=Tj;exports.showAllTableColumns=bOe;exports.showJoinRequiredNotification=kee;exports.sortByColumnsToSortState=jte;exports.sortStateToSortByColumns=_te;exports.sortableKeyboardCoordinates=c3;exports.supportsMetricTransformForMetric=ble;exports.supportsTableConditionalFormatting=Hce;exports.toEntityArray=Da;exports.ue=at;exports.useActiveExports=e1e;exports.useActiveToolStatus=Hde;exports.useAddFrameWithFreshSemanticExecutionPayload=QL;exports.useAddNewFrame=Nae;exports.useAssistantContainer=VK;exports.useAssistantContextEntities=U_;exports.useAssistantLayoutStore=Qf;exports.useAssistantPanel=zK;exports.useAssistantProfile=kde;exports.useAutoSubmitQueue=Vde;exports.useBrandStudioPreview=Tvt;exports.useCard=BPe;exports.useCardFilterValues=Aee;exports.useCardSummary=BL;exports.useChat=ude;exports.useColumns=f3;exports.useCreateVisualWithFrame=Nxe;exports.useCurrentUserInfo=ua;exports.useCustomVisual=op;exports.useCustomVisualsQuery=IL;exports.useDashboardAppearance=Hl;exports.useDashboardById=iG;exports.useDashboardCreation=cG;exports.useDashboardManagement=lG;exports.useDashboardPreferences=jg;exports.useDashboardQuery=dv;exports.useDashboardStructuralParticipants=pce;exports.useDashboardSummary=$ie;exports.useDataColumns=vle;exports.useDateFilterHook=EHe;exports.useDebounce=Ey;exports.useDefaultDashboardMutation=eG;exports.useDisplayPreferences=Yl;exports.useDroppable=Yae;exports.useEditorAside=sE;exports.useEditorCardQuery=Ej;exports.useEnsureReactGlobals=Yse;exports.useExportActions=HK;exports.useExportStore=cj;exports.useFieldManagement=yle;exports.useFilterableFields=hle;exports.useFullscreenAssistant=BK;exports.useGroupMembers=Nye;exports.useGroups=QG;exports.useHasDashboardId=UK;exports.useInProgressExportsCount=t1e;exports.useIsDashboardSelected=fme;exports.useIsVisualSelected=hme;exports.useJoinabilityMap=p3;exports.useManagementActions=Hh;exports.useManagementStore=hs;exports.useMutation=go;exports.usePivotTableConfig=tp;exports.usePluginQuery=kie;exports.useQuery=Bn;exports.useQueryClient=ls;exports.useReactTable=t_;exports.useResolveExistingFrameSemanticExecutionPayload=$Ke;exports.useResourceManagement=Zk;exports.useResourceUpdateState=aG;exports.useScopedFields=fle;exports.useSelectedVisual=dme;exports.useSemaphorContext=Ct;exports.useSensor=gg;exports.useSensors=G_;exports.useSortable=yb;exports.useStarredChartsStore=pwt;exports.useSurfaceAppearance=su;exports.useTableQueryState=bte;exports.useTextFilterHook=$He;exports.useTheme=xF;exports.useTopoJson=Lv;exports.useUnifiedUsers=JF;exports.useUpdateResource=nG;exports.useUpdateVisualMutation=kxe;exports.useUserPreferences=DG;exports.useVisualById=Kk;exports.useVisualManagement=Cxe;exports.validateFieldForChartType=mle;exports.verticalListSortingStrategy=l3;