react-semaphor 0.1.479 → 0.1.481

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 (24) hide show
  1. package/dist/chunks/{dashboard-briefing-launcher-DWwSdfV7.cjs → dashboard-briefing-launcher-CNfjHXUY.cjs} +1 -1
  2. package/dist/chunks/{dashboard-briefing-launcher-Dk4yNOLY.js → dashboard-briefing-launcher-DqXcsWHp.js} +2 -2
  3. package/dist/chunks/{dashboard-controls-B0Pm_y8L.cjs → dashboard-controls-CSEDFI2k.cjs} +2 -2
  4. package/dist/chunks/{dashboard-controls-CIC5_549.js → dashboard-controls-DVssK0HR.js} +5 -5
  5. package/dist/chunks/{dashboard-json-YDTb3r4e.js → dashboard-json-BGNpj0SL.js} +1 -1
  6. package/dist/chunks/{dashboard-json-Bk6nEHap.cjs → dashboard-json-uLgspKtl.cjs} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-q5Yj9dMP.js → edit-dashboard-visual-CYQV8Q5y.js} +2 -2
  8. package/dist/chunks/{edit-dashboard-visual-B3oH-O0L.cjs → edit-dashboard-visual-DXTMYEBO.cjs} +1 -1
  9. package/dist/chunks/{editor-action-buttons-BqelO0n9.js → editor-action-buttons-CXJ-LUjw.js} +1 -1
  10. package/dist/chunks/{editor-action-buttons-vZ63-lN-.cjs → editor-action-buttons-RgHDm7DR.cjs} +1 -1
  11. package/dist/chunks/{index-DhDfPZUu.cjs → index-C9IHd6wo.cjs} +1 -1
  12. package/dist/chunks/{index-CUCiMVzS.js → index-zgwR8S22.js} +5 -5
  13. package/dist/chunks/{report-preferences-dialog-DKq0k5BH.js → report-preferences-dialog-B4yeayvj.js} +1 -1
  14. package/dist/chunks/{report-preferences-dialog--aV7ITSE.cjs → report-preferences-dialog-BSzTduxH.cjs} +1 -1
  15. package/dist/dashboard/index.cjs +1 -1
  16. package/dist/dashboard/index.js +1 -1
  17. package/dist/data-app-builder/index.cjs +1 -1
  18. package/dist/data-app-builder/index.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/style.css +1 -1
  22. package/dist/surfboard/index.cjs +1 -1
  23. package/dist/surfboard/index.js +2 -2
  24. package/package.json +1 -1
@@ -1401,4 +1401,4 @@ Defaulting to \`null\`.`}var cxe=sxe,ekt=axe;const K4=oe.forwardRef(({className:
1401
1401
  More info: ${o.docs}`:"",a=typeof o.message=="string"&&o.message.trim()?o.message.trim():typeof o.error=="string"&&o.error.trim()?o.error.trim():null;if(a){const c=s?` (code: ${s})`:"",u=s==="insufficient_quota"||a.toLowerCase().includes("quota")?`
1402
1402
 
1403
1403
  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 o=JSON.parse(r),s=t(o);if(s)return s}catch{}return r}const n=t(e);if(n)return n;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function eB({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(Po,{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:y_t(e)})]})}function v_t({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(eB,{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 w_t({text:e,files:t}){return l.jsxs(Mxe,{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(nkt,{file:n},n.id))})]})}function C_t({text:e}){const t=e.split("|"),n=t[0],r=t[1]||"{}",o=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(Nkt,{children:JSON.stringify(o,null,2)})]})]})}function Rxe(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")?J4(r,t):!1}})}function UG(){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 S_t({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(UG,{}),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(UG,{}),l.jsx("span",{children:e==="submitted"?"Thinking":"Generating"})]}):e==="error"?l.jsx(eB,{errorMessage:t}):null}function N_t(e){var t;return e?(t=[...e].reverse().find(n=>{var r;return n.role==="assistant"&&((r=n.parts)==null?void 0:r.some(o=>o.type==="text"&&typeof o.text=="string"&&o.text.trim().length>0))}))==null?void 0:t.id:void 0}function j_t({message:e,messageIndex:t,messages:n,showTools:r=!1,onAddToDashboard:o,showSystemMessage:s=!1,handleRun:i,onQuickReply:a,disableQuickReplies:c=!1}){var y,w,C,N;const u=N_t(n),d=e.id===u;if(e.role==="user"){const S=((y=e.parts)==null?void 0:y.filter(T=>T.type==="text"))||[],j=((w=e.parts)==null?void 0:w.filter(T=>T.type==="file"))||[],I=S.map(T=>T.text).join(`
1404
- `).trim(),k=j.map((T,_)=>{var M,R;let E="",D;if((M=T.url)!=null&&M.startsWith("data:")){const A=T.url.match(/data:[^;]+;base64,(.+)/);A&&(E=A[1],(R=T.mediaType)!=null&&R.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${_}`,name:T.filename||`File ${_+1}`,size:0,type:T.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(w_t,{text:I||void 0,files:k.length>0?k:void 0})}const f=((C=e.parts)==null?void 0:C.filter(S=>S.type==="reasoning"))||[],h=f.length>0,p=f.some(S=>S.state==="streaming"),g=f.filter(S=>S.text&&S.text.trim().length>0),b=h&&(g.length>0||p)?l.jsxs(Nu,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(ju,{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(Pt.ChevronRight,{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(ku,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((S,j)=>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:j+1}),l.jsx(OG,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:S.text})]},`${e.id||t}-reasoning-${j}`))})})]},`${e.id||t}-reasoning`):null,x=(N=e.parts)==null?void 0:N.map((S,j)=>{var k;const I=`${e.id||t}-${j}`;switch(S.type){case"text":{const T=typeof S.text=="string"?S.text:JSON.stringify(S.text??"",null,2);if(e.role==="assistant"){const{cleanedText:_,quickReplies:E}=b_t(T),D=_.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(OG,{text:_,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.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:E.map(({label:M,value:R},A)=>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(R),children:l.jsx("span",{className:"truncate",children:M})})}),l.jsx(m.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:R})})]},`${I}-qr-${A}`))})]})]},I)}return e.role==="system"&&s?l.jsx(C_t,{text:T},I):null}case"error":{const T=S,_=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(eB,{errorMessage:_})},I)}case"reasoning":return null;default:return((k=S.type)!=null&&k.startsWith("tool-")||S.type==="dynamic-tool")&&J4(S,r)?l.jsx(ki,{FallbackComponent:({error:T,resetErrorBoundary:_})=>l.jsx(v_t,{error:T,resetErrorBoundary:_}),children:l.jsx(f_t,{part:S,idx:I,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},I):null}});return e.role==="assistant"?Rxe(e,r)?l.jsxs(Mxe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const k_t=8,__t=24,I_t=20;function T_t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function Axe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,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),w=v.useRef(!1),C=v.useRef(null),N=v.useRef(!1),S=v.useRef(g),[j,I]=v.useState(!0),[k,T]=v.useState(0),[_,E]=v.useState(__t);S.current!==g&&(S.current=g,N.current=!0);const D=e[e.length-1],M=Rxe(D,t),R=T_t(a,c,u,M),A=Iw({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const F=e[W];return(F==null?void 0:F.role)==="user"?88:180},getItemKey:W=>{const F=e[W];return(F==null?void 0:F.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:k_t,overscan:6,gap:20,paddingEnd:R?_+I_t:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const F=W.isAtEnd();I(q=>q===F?q:F),F&&T(0)}}),$=v.useCallback((W="smooth")=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{C.current=null,A.scrollToEnd({behavior:W})}),T(0),I(!0)},[A]);v.useLayoutEffect(()=>{w.current||(w.current=!0,$("auto"))},[$]),v.useLayoutEffect(()=>{N.current&&(N.current=!1,$("auto"))},[e.length,g,$]),v.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!A.isAtEnd()&&T(F=>F+e.length-W),e.length===0&&(T(0),I(!0),w.current=!1,N.current=!1)},[e.length,A]);const O=A.getVirtualItems(),B=A.getTotalSize();return v.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]),v.useLayoutEffect(()=>{const W=x.current;if(!W||!R)return;const F=()=>{const z=Math.ceil(W.getBoundingClientRect().height);z>0&&E(P=>P===z?P:z)};if(F(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(F);return q.observe(W),()=>q.disconnect()},[R,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(yl,{"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:B},children:[O.map(W=>{const F=e[W.index];return F?l.jsx("div",{ref:A.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(j_t,{message:F,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},W.key):null}),R&&l.jsx("div",{ref:x,className:m.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(B-_,0)}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(S_t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!j&&l.jsxs("button",{type:"button",onClick:()=>$("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(rs,{className:"h-3 w-3"}),"Latest",k>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:k>9?"9+":k})]})]})}function E_t(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 D_t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function M_t({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(ut.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[p,g]=v.useState(!1),[b,x]=v.useState(!1),[y,w]=v.useState(0),C=n??b,{isLocalDev:N,isConsoleMode:S}=$m(),j=N||S||a,I=v.useRef(null);m.useDashboardStore(ue=>ue.dashboard.aiScopeTables),m.useDashboardStore(ue=>ue.isDashboardEditing);const k=m.useDashboardStore(ue=>ue.selectedSheetId),{setDataSource:T}=m.useEditorActions(),{setSelectedFrameId:_,setIsDashboardEditing:E}=m.useDashboardActions(),D=lz(),{clearAssistantMessageContexts:M}=m.useAIActions(),{clearQueue:R}=m.useQueueActions(),{clearFileAttachments:A,getFileAttachments:$}=m.useFileActions(),O=m.useFileAttachments("dashboard"),B=m.useEditorStore(ue=>ue.card.dataSource),{assistantProfile:W}=Qbe(),F=m.useDashboardStore(ue=>ue.handleOpenAssistantProfile),{selectedEntities:q,applyDashboardDefaultEntities:z}=fT("dashboard"),{sendMessage:P,isLoading:U,messages:G,setMessages:Q,status:H,stop:L,errorMessage:K,clearError:Y}=Fjt({dynamicVisualMode:f}),V=v.useCallback(()=>{w(ue=>ue+1)},[]),Z=v.useCallback(ue=>{r==null||r(ue),n===void 0&&x(ue)},[n,r]),X=v.useCallback(()=>{Z(!C)},[C,Z]);v.useEffect(()=>{if(!C)return;function ue(ge){ge.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",ue),()=>{window.removeEventListener("keydown",ue)}},[C,Z]);const[te,re]=v.useState(""),ie=ue=>{re(ue.target.value)};async function se({sql:ue,cardTitle:ge,connectionId:_e,cardType:Te,python:Ce,cardConfig:Re,dataSource:Ve,customVisualPreferences:Ee,visualizationMode:We,dynamicCardPreferences:Ie}){if(!k)return;const we=We==="dynamic",de=ut.hasValidCardConfig(Re),Se=_e||(Ve==null?void 0:Ve.connectionId)||"",Le=Ve?{...Ve,connectionId:Se||Ve.connectionId,connectionType:Ve.connectionType||"",mode:Ve.mode||"database",selectedEntities:Ve.selectedEntities||[]}:Se?{connectionId:Se,connectionType:"",mode:"database",selectedEntities:[]}:mb,st=!(de&&(!we||(Ie==null?void 0:Ie.provenance)==="card-config"||(Ie==null?void 0:Ie.provenance)==="query_spec")),$e=st?E_t(ue):"",Ke=st?Ce:"",at={id:ut.v4(),title:ge||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Te==="horizontalBar"?"y":"x"},...we&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Te,sql:$e,python:Ke,dataSource:Le,config:Re,connectionId:Se,visualizationMode:We,dynamicCardPreferences:Ie,customCardPreferences:Ee?{url:Ee.url,componentName:Ee.componentName,pluginChartType:Ee.pluginChartType,settings:Ee.settings,type:"component"}:void 0},ct={id:ut.v4(),cards:[at],activeCardId:at.id};try{await D(k,ct,"end"),E(!0),_(ct.id)}catch(rt){console.error("Failed to add assistant visual to dashboard:",rt),et.error(rt instanceof Error?rt.message:"Failed to prepare semantic metadata for the new visual")}}const le=ue=>{ue.preventDefault();const ge=te.trim();if(!ge&&O.length===0)return;const _e=[];ge&&_e.push({type:"text",text:ge}),O.forEach(Te=>{Te.data&&_e.push({type:"file",mediaType:Te.type,filename:Te.name,url:`data:${Te.type};base64,${Te.data}`})}),P({role:"user",parts:_e}),re(""),A("dashboard"),V()};v.useEffect(()=>{var ue;e&&((ue=I.current)==null||ue.focus())},[e]),pxe({assistantType:"dashboard",status:H,isLoading:U,sendMessage:P});const{hasActiveTools:ae,activeToolText:be}=gxe(G);function fe(ue){const ge={role:"user",parts:[{type:"text",text:ue.title+" "+ue.subtitle}]};P(ge),V()}function xe(ue){P({role:"user",parts:[{type:"text",text:ue}]}),V()}function pe(ue){P({role:"user",parts:[{type:"text",text:ue}]}),V()}const ye=v.useCallback(async()=>{const ue=JSON.stringify(G??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ue),et.success("Conversation copied")}catch(ge){console.error("Failed to copy conversation",ge),et.error("Unable to copy conversation")}},[G]),ce=(te==null?void 0:te.length)===0&&(G==null?void 0:G.filter(ue=>ue.role==="user").length)===0;function J(){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 ne(){return l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx(su,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Fm,{className:"size-3.5"})})}),l.jsxs(mo,{align:"end",children:[l.jsx(Ca,{children:"Options"}),l.jsx(Ia,{}),l.jsx(sd,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(sd,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(sd,{checked:u,onCheckedChange:d,children:"System Message"}),(N||S)&&l.jsxs(l.Fragment,{children:[l.jsx(Ia,{}),l.jsx(Ca,{children:"Dynamic Visuals"}),l.jsx(sd,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(sd,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(sd,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ee=l.jsxs("div",{"data-role":"dashboard-assistant",className:m.cn("relative flex h-full grow flex-col break-words bg-background",C&&"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:[J(),F&&l.jsxs("button",{type:"button",onClick:F,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:[S&&ne(),j&&l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:ye,children:"Copy Conversation"}),l.jsx(su,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:C?"Exit fullscreen":"Expand",onClick:X,children:C?l.jsx(Pt.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(su,{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 ue=G.filter(ge=>ge.role==="assistant").map(ge=>ge.id).filter(ge=>!!ge);Q([]),R("dashboard"),Y(),M(ue)},children:l.jsx(LO,{className:"h-3.5 w-3.5"})}),l.jsx(su,{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(Me.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(Axe,{messages:G,showTools:a,showSystemMessage:u,onAddToDashboard:se,onQuickReply:pe,disableQuickReplies:U,status:H,errorMessage:K,activeToolText:U&&ae?be:void 0,className:m.cn(C?"px-6 py-5":"px-3 py-3"),rowContentClassName:m.cn(C&&"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&&ce&&l.jsx(Tge,{onClick:fe,placeholders:D_t}),ce&&W&&l.jsx(Jbe,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:xe}),l.jsx(mxe,{assistantType:"dashboard"}),l.jsx(Q4,{ref:I,setInput:re,stop:L,input:te,handleInputChange:ie,handleSubmit:ue=>{le(ue)},isLoading:U,status:H,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(X4,{incomingSelectedEntities:q,open:p,onOpenChange:g,dataSource:B||mb,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ue=>z()})]});return C&&o?vr.createPortal(l.jsx(tx,{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:ee})}),o):ee}function R_t(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=m.useDashboardActions(),o=tde(),s=m.useDashboardStore(d=>d.dashboard.sheets),a=m.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[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(A_t(p.target))return;const g=p.ctrlKey||p.metaKey;g&&p.key==="c"?(await f(),et.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=F_t(p);if(g!=null&&g.id){const b=Que(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await o(a,b),r(b.id),et.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)},[o,n,r,a,c,u,t])}function A_t(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 F_t(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 P_t(e,t){switch(e.interactionMode){case"drillToDetail":O_t(e,t);break;case"drillThrough":L_t(e,t);break;case"drillToURL":$_t(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 O_t(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function L_t(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.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 $_t(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 z_t({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(No,{open:e,onOpenChange:t,children:l.jsxs(po,{className:"flex max-h-[90vh] max-w-[90vw] flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Es,{className:"space-y-1 border-b border-border px-5 pb-3.5 pt-4 text-left",children:[l.jsx(go,{className:"text-[15px] font-semibold tracking-tight",children:i||"Insight detail"}),l.jsx(Oo,{className:"text-[12px] leading-[1.5] text-muted-foreground",children:a||"View detailed insight data with applied filters"})]}),l.jsx(ade,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] min-h-0 flex-1 overflow-auto px-5 py-4",children:n?l.jsx(bhe,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-[13px] text-muted-foreground",children:"No insight selected"})})]})})}function B_t(){const e=m.useInteractionStore(N=>N.interactionStates),t=m.useInteractionStore(N=>N.setInteractionState),n=m.useInteractionStore(N=>N.clearLastInteractionEvent),r=m.useInteractionStore(N=>N.replaceCardWithInsight),o=m.useInteractionStore(N=>N.setPendingDrillThrough),s=m.useInteractionStore(N=>N.pendingDrillThrough),i=m.useInteractionStore(N=>N.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=m.useDashboardActions(),{selectDashboard:u}=Rm(),d=m.useDashboardStore(N=>N.dashboard),f=m.useDashboardStore(N=>N.filterValues),{data:h,isLoading:p}=XX((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=xhe(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),w=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:N,filters:S,contextMode:j})=>{b({open:!0,insightId:N,filters:S,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:j})},replaceCardContent:({cardId:N,insightId:S,filters:j,contextMode:I})=>{r(N,S,j,I)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:N,contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k})=>{const T={filters:N},_={sourceCardId:m.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},E={...m.createInitialInteractionState(),appliedClickFilters:[_],contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k};t(m.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);v.useEffect(()=>{Object.entries(e).forEach(([N,S])=>{if(S!=null&&S.lastInteractionEvent){const j=S.lastInteractionEvent,I=`${N}-${j.interactionMode}-${j.sourceCardId}-${Date.now()}`;if(y.current.has(I))return;y.current.add(I);try{P_t(j,w)}catch(k){console.error("Error executing interaction event:",k)}finally{n(N),setTimeout(()=>{y.current.delete(I)},5e3)}}})},[e,n,w]),v.useEffect(()=>{if(!(!s||!h||p))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(N){console.error("[DrillThrough] Error during automatic navigation:",N),i()}},[s,h,p,u,c,i]);const C=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(z_t,{open:g.open,onOpenChange:C,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),s&&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 V_t(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=H_t(uz(t));return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function H_t(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function q_t(e){return e?`Back to ${e}`:"Back"}function U_t(){var y,w,C,N,S;const e=m.useInteractionStore(j=>j.interactionStates[m.DRILL_CONTEXT_CARD_ID]),t=m.useDashboardStore(j=>j.actions.goBackFromDrill),n=m.useDashboardStore(j=>j.actions.clearDrillContext),{selectDashboard:r}=Rm(),[o,s]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const j=k=>{s({x:k.clientX-c.current.x,y:k.clientY-c.current.y})},I=()=>{a(!1)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",I),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((N=(C=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:C[0])==null?void 0:N.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||!((S=e.appliedClickFilters)!=null&&S.length))return null;const p=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(j){console.error("[DrillBack] Error during back navigation:",j)}},g=()=>{n()},b=j=>{j.target.closest("button")||(a(!0),c.current={x:j.clientX-o.x,y:j.clientY-o.y})};V_t(f);const x=q_t(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.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((j,I)=>{const k=j.field.label||j.field.name,T=String(j.value);return l.jsxs(xi,{variant:"secondary",className:"pointer-events-none text-xs",children:[k," = ",T]},I)})})]}),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(Me.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(Xv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function W_t(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function K_t({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d}){const{attributes:f,listeners:h,setNodeRef:p,transform:g,transition:b,isDragging:x}=cx({id:`filter:${e.id}`,disabled:n||!t}),y={transform:Xi.Translate.toString(g),transition:b,opacity:x?.5:1,zIndex:x?10:void 0};return l.jsx("div",{ref:p,style:y,...f,children:l.jsx(H$,{filter:e,isEditing:t,dragListeners:t?h:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d})})}const WG="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",G_t=[];function Fxe({open:e,onOpenChange:t}){const[n,r]=v.useState(!1),[o,s]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=m.useDashboardStore(H=>{var L;return(L=H.dashboard)==null?void 0:L.sheets}),u=m.useDashboardStore(H=>H.dashboard),d=m.useDashboardStore(H=>H.dashboardInputValues),f=m.useDashboardStore(H=>H.filterValues),h=m.useDashboardStore(H=>H.controlValues),p=m.useDashboardStore(H=>H.inlineFilterValuesMap),g=m.useDashboardStore(H=>H.cardControlValuesMap),b=m.useDashboardStore(H=>H.selectedSheetId),x=m.useDashboardStore(H=>H.selectedSheetId?H.documentInputRuntimeBySheetId[H.selectedSheetId]:void 0),y=m.useDashboardStore(H=>H.isDownloadingPdf),w=m.useDashboardStore(H=>H.reportContext),{authToken:C,tokenProps:N}=Et(),S=c==null?void 0:c.find(H=>H.id===b),j=v.useMemo(()=>m.getDashboardExportSheets(c),[c]),I=m.isDocumentSheet(S),k=I&&S?S.document:void 0,T=v.useMemo(()=>I&&S?dx(u,S.id):[],[S,I,u]),_=T.length>0,E=v.useMemo(()=>I&&S?rge(u,S.id):!1,[S,I,u]),D=v.useMemo(()=>_?T.map(bC):(k==null?void 0:k.inputs)||G_t,[k,T,_]),M=w==null?void 0:w.calendar.tz,R=v.useMemo(()=>epe(D),[D]),A=v.useMemo(()=>Qme(D,M),[D,M]),$=v.useMemo(()=>Jme(D),[D]),O=x?x.filterValuesByInputId:A,B=v.useMemo(()=>npe(O,D),[D,O]),W=x?x.controlValuesByInputId:$,F=v.useMemo(()=>I?E&&S&&k?tZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(H=>H.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},timezone:M}):ope(D,B,W,R,R):[],[k,D,S,I,u,g,h,f,p,d,W,B,R,M,E]),q=!!S,z=j.length>0,P=((c==null?void 0:c.length)||0)>1||I,U=i.sheetSelection==="current"&&(!q||I&&F.length>0)||i.sheetSelection==="all"&&!z;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!z&&a(H=>({...H,sheetSelection:"current"}))},[z,e,i.sheetSelection]);const G=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function Q(){if(y){et.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){et.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!q){et.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!z){et.error("No dashboard sheets are available to export");return}s(!0);const H=i.sheetSelection==="current"&&I,L=H?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",K=et.loading(L);try{if(H){if(!k||!S)throw new Error("Selected document sheet is missing document data");if(F.length>0){et.dismiss(K),et.error(`Set ${F.join(", ")} before exporting`);return}const V=new Date().toISOString(),Z=E?nZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(X=>X.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},generatedAt:V,timezone:M}).snapshot:void 0;await rL(N.apiServiceUrl,C,{sheetId:S.id,title:S.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:M,password:i.protectPdf?i.password:void 0,inputSnapshot:Z,...Z?{}:{inputValues:{sheetId:S.id,filterValuesByInputId:B,controlValuesByInputId:W,generatedAt:V}}})}else{const V=goe();await ste(N.apiServiceUrl,C,i.protectPdf?i.password:void 0,i.sheetSelection,V)}et.dismiss(K);const Y=H?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!";et.success(Y,{duration:2e3}),G()}catch(Y){et.dismiss(K),et.error("Failed to download PDF",{description:L_(Y,"Please try again or contact support."),descriptionClassName:O_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",Y)}finally{s(!1)}}return l.jsx(No,{open:e,onOpenChange:H=>{if(!H){G();return}t(!0)},children:l.jsxs(po,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Es,{children:[l.jsx(go,{className:"text-[15px]",children:I?"Export document":"Export dashboard"}),l.jsx(Oo,{className:"text-[13px] leading-5",children:I?"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:[P&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(m.Label,{className:WG,children:"Export scope"}),l.jsxs(yu,{value:i.sheetSelection,onValueChange:H=>a({...i,sheetSelection:H}),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",!q&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Xs,{value:"current",id:"scope-current",disabled:!q}),I?"This document":"This sheet"," (",(S==null?void 0:S.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",!z&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Xs,{value:"all",id:"scope-all",disabled:!z}),"Dashboard sheets (",j.length," ",j.length===1?"sheet":"sheets",")"]})]}),I&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:F.length>0?`Set ${F.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(In,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:H=>{a({...i,protectPdf:H,password:H?i.password:""}),H||r(!1)}}),l.jsx(Jv,{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:WG,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:H=>a({...i,password:H.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:H=>{H.key==="Enter"&&i.password&&Q()}}),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(Uk,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Eye,{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(il,{children:[l.jsx(m.Button,{variant:"outline",size:"xs",onClick:G,disabled:o,children:"Cancel"}),l.jsx(m.Button,{size:"xs",onClick:Q,disabled:o||y||U,children:o?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(_u,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function Pxe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=v.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=m.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(_u,{className:m.cn("size-4",e)})}),l.jsx(Fxe,{open:i,onOpenChange:a})]})}function KG(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function Y_t({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=cx({id:`control:${e.id}`,disabled:!n}),d={transform:Xi.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(wpe,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function GG(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function YG(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Z_t(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 YG(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=YG(t,n).filter(a=>!s.has(a));return[...o,...i]}function X_t(e,t){return m.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function Q_t(e){return m.doesDashboardInputApplyToTarget(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>m.doesDashboardInputApplyToTarget(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function U2(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function J_t(e){return Oxe(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 Oxe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=X_t(e.dashboard,t);return m.removeShadowedCompatibilityInputs(m.buildNormalizedDashboardInputs({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!Q_t({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function eIt(e,t){return"toolbar"}function tIt(){const e=ml("interactive"),t=m.useDashboardStore(V=>V.selectedSheetId),n=m.useDashboardStore(V=>V.dashboard.filters),r=m.useDashboardStore(V=>V.dashboard.filterLayout),o=m.useDashboardStore(V=>V.isDashboardEditing),s=m.useDashboardStore(V=>V.controlValues),i=m.useDashboardStore(V=>V.filterValues);m.useDashboardStore(V=>V.filteringCards);const a=m.useDashboardStore(V=>V.inlineFilterValuesMap),c=m.useDashboardStore(V=>V.dashboardInputValues),u=m.useInteractionStore(V=>V.clearAllClickFilters),d=m.useInteractionStore(V=>Object.entries(V.interactionStates).reduce((Z,[X,te])=>{var re;return X===m.DRILL_CONTEXT_CARD_ID?Z:Z+(((re=te.appliedClickFilters)==null?void 0:re.length)??0)},0)),f=m.useDashboardStore(V=>V.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:p,reorderDashboardControls:g,removeDashboardInput:b,removeFilter:x,setControlValue:y,setFilterLayout:w,setFilterValues:C,setFilteringCards:N,updateFilterDashboardInputDefinition:S}=m.useDashboardActions(),j=gT(db(ax,{activationConstraint:{distance:5}})),I=m.useDashboardStore(V=>V.dashboard),k=J_t({dashboard:I,selectedSheetId:t}).filter(V=>eIt(V.filter)==="toolbar"),T=Oxe({dashboard:I,selectedSheetId:t}),_=k.map(V=>V.filter),E=new Map(k.map(V=>[`filter:${V.filter.id}`,V])),D=ent(I),M=D.filter(V=>!V.hidden&&mv(V)==="toolbar"),R=D.filter(V=>!V.hidden&&mv(V)==="advanced"),A=Z_t(r==null?void 0:r.toolbarItemOrder,_,M),$=new Map(_.map(V=>[`filter:${V.id}`,V])),O=new Map(M.map(V=>[`control:${V.id}`,V]));function B(V){const{active:Z,over:X}=V;if(!X||Z.id===X.id)return;const te=String(Z.id),re=String(X.id),ie=A.findIndex(ye=>ye===te),se=A.findIndex(ye=>ye===re);if(ie===-1||se===-1)return;const le=lx(A,ie,se);w({toolbarItemOrder:le});const ae=new Set((n||[]).map(ye=>ye.id)),be=A.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>ae.has(ye)),fe=le.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>ae.has(ye)),xe=A.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:","")),pe=le.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:",""));h(KG(n||[],be,fe)),g(KG(I.controls||[],xe,pe))}const W=(r==null?void 0:r.toolbarWrap)??!1,F=(r==null?void 0:r.showDownloadButton)??!1,q=T.filter(U2),z=T.filter(V=>{if(U2(V))return!1;const Z=m.getDashboardInputRuntimeSlot(c,V,{sheetId:t});return(Z==null?void 0:Z.status)==="set"||(Z==null?void 0:Z.status)==="cleared"}),P=new Set([...q,...z].map(V=>V.filter.id)),U=(i==null?void 0:i.filter(V=>!P.has(V.filterId)&&GG(V)).length)??0,G=[...q,...z],Q=G.filter(V=>{const Z=m.hydrateAuthoredDashboardInputSlot({dashboard:I,input:V,runtimeValues:c,target:{sheetId:t}});return(Z==null?void 0:Z.status)==="set"&&Z.value.kind==="filter"&&GG(Z.value.filterValue)}).length,H=a?Object.values(a).reduce((V,Z)=>V+((Z==null?void 0:Z.length)??0),0):0,L=U+Q+H+d,K=G.some(V=>V.forceSelection),Y=()=>{C([]),G.forEach(V=>{p(V,{sheetId:t})}),N([]),u(),a&&Object.entries(a).forEach(([V,Z])=>{Z==null||Z.forEach(X=>{f(V,X.filterId)})})};return!_.length&&!M.length&&!R.length&&!F&&L===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(dC,{sensors:j,collisionDetection:lC,onDragEnd:B,children:l.jsxs("div",{className:m.cn("flex items-center",W?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(fC,{items:A,strategy:Kz,children:l.jsx(qP,{className:"gap-3 pr-0",wrap:W,children:A.map(V=>{const Z=$.get(V);if(Z){const te=E.get(V),re=te&&U2(te),ie=re&&te.definitionOrigin==="dashboardFilter";return l.jsx(K_t,{filter:Z,isEditing:o,storageOptions:re?{storageTarget:"dashboardInput",dashboardInput:te,sheetId:t??void 0}:void 0,inputVariableName:re?te.variableName:void 0,isDashboardFilterReference:ie,onUpdateFilter:re?(se,le)=>{S(te.id,se,le)}:void 0,onRemoveFilter:re?()=>{if(te.definitionOrigin==="dashboardFilter"){x(Z.id);return}C((i||[]).filter(se=>se.filterId!==Z.id)),b(te.id)}:void 0},V)}const X=O.get(V);return X?l.jsx(Y_t,{control:X,value:s==null?void 0:s[X.id],isEditing:o,onChange:te=>y(X.id,te)},V):null})})}),R.length>0&&l.jsx(pde,{title:"",controls:R,values:s,onChange:(V,Z)=>y(V.id,Z),immediatePlacement:"toolbar",advancedLabel:"More controls"}),L>0&&l.jsxs("button",{type:"button",onClick:Y,"aria-label":K?"Reset filters":"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(Me.X,{className:"h-3 w-3"}),K?"Reset filters":"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:L})]}),F&&l.jsx("div",{className:m.cn(L>0?"ml-1.5":"ml-auto"),children:l.jsx(Pxe,{})})]})})})}function Lxe(){var J,ne;const{showAssistant:e,tokenProps:t,renderMode:n}=Et(),r=W_t((J=t.config)==null?void 0:J.showDashboardAssistant,e),{preferences:o}=$m(),s=(ne=o==null?void 0:o.cardDisplay)==null?void 0:ne.mode,i=gf(s),a=dee({displayMode:s,renderMode:n}),c=v.useRef(null),u=v.useRef(null),d=v.useRef(null),[f,h]=v.useState(!1),{handleDragStart:p,isDraggingRef:g,getStyle:b,getPositionClasses:x}=Svt({initialPosition:"bottom-right"}),y=Ah(ee=>ee.setFullscreen),w=Ah(ee=>ee.setPanelOpen),C=Ah(ee=>ee.setContainer),N=eJ("dashboard"),S=tJ(),j=nJ("dashboard"),I=N.isOpen,k=S==="dashboard",T=m.useDashboardStore(ee=>ee.isVisualEditing),_=m.useDashboardStore(ee=>ee.themeStyle),E=Ou(),D=m.useDashboardStore(ee=>{var ue;return(ue=ee.dashboard)==null?void 0:ue.sheets}),M=m.useDashboardStore(ee=>ee.showFilters),R=m.useDashboardStore(ee=>ee.isDashboardEditing),A=m.useDashboardStore(ee=>ee.selectedSheetId),$=D==null?void 0:D.find(ee=>ee.id===A),O=m.useDashboardStore(ee=>{var ue,ge,_e;return(_e=(ge=(ue=ee.dashboard)==null?void 0:ue.sheets)==null?void 0:ge.find(Te=>Te.id===ee.selectedSheetId))==null?void 0:_e.kind}),B=m.useDashboardStore(ee=>{var ue,ge;return((ge=(ue=ee.dashboard)==null?void 0:ue.summary)==null?void 0:ge.position)||"top"}),W=O==="document",F=m.useDashboardStore(ee=>{var ue;return(ue=ee.dashboard)==null?void 0:ue.id}),{getDefaultSheetId:q,setDefaultSheetId:z,clearDefaultSheetId:P}=$Y(F),[U,G]=v.useState(null),{setSelectedSheetId:Q,setSheetTitle:H,addSheet:L,setSheets:K,duplicateSheet:Y}=m.useDashboardActions();R_t(u);const{setActiveAssistantType:V}=m.useAIActions();v.useEffect(()=>{if(F){const ee=q();G(ee)}},[F,q]),v.useEffect(()=>{I?V("dashboard"):S==="dashboard"&&y(null)},[I,V,S,y]),v.useEffect(()=>{var ee;I||(ee=c.current)==null||ee.resize(0)},[I]);function Z(ee){var ue,ge;ee?((ue=c.current)==null||ue.resize(40),w("dashboard",!0),y("dashboard"),V("dashboard")):(w("dashboard",!1),y(null),(ge=c.current)==null||ge.resize(0),V(null))}function X(ee="dashboard"){const ue={id:ut.v4(),title:ee==="document"?"New Document":"New Sheet",...ee==="document"?{kind:ee,document:m.createDefaultDocumentDefinition()}:{}};L(ue),Q(ue.id)}function te(ee){const ue=Y(ee);ue&&(et.success("Sheet duplicated"),requestAnimationFrame(()=>{var _e;const ge=(_e=d.current)==null?void 0:_e.querySelector(`[data-sheet-id="${ue}"]`);ge==null||ge.focus(),ge==null||ge.scrollIntoView({block:"nearest",inline:"nearest"})}))}function re(ee,ue){if(!F)return;U===ee?(P(),G(null),et.success("Default sheet cleared")):(z(ee),G(ee),et.success(`"${ue}" set as default sheet`))}function ie(ee){var ue;ee<1?(w("dashboard",!1),y(null),V(null),(ue=c.current)==null||ue.resize(0)):(I||w("dashboard",!0),V("dashboard"))}function se(){return(_==null?void 0:_.canvasTheme)==="muted"||!(_!=null&&_.canvasTheme)?"hsl(var(--semaphor-muted))":(_==null?void 0:_.canvasTheme)==="clear"?"":_==null?void 0:_.canvasTheme}const le=(ee,ue)=>{ee.dataTransfer.setData("tabIndex",ue.toString())},ae=ee=>{ee.preventDefault()},be=(ee,ue)=>{const ge=ee.dataTransfer.getData("tabIndex");if(ge===ue.toString())return;const _e=Array.from(D||[]),[Te]=_e.splice(parseInt(ge),1);_e.splice(ue,0,Te),K(_e)},fe=r===!0&&!i&&!I&&!T&&!M;function xe(){if(D&&D.length>1||R)return l.jsx("div",{className:"relative flex w-full items-stretch border-b border-border",children: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,{ref:d,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((ee,ue)=>{const ge=A===ee.id,_e=U===ee.id;return l.jsxs("div",{className:"relative flex shrink-0 items-center",children:[l.jsxs(m.TabsTrigger,{"data-sheet-id":ee.id,draggable:!0,onDragStart:Te=>le(Te,ue),onDragOver:ae,onDrop:Te=>be(Te,ue),onClick:()=>Q(ee.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",R&&ge&&"pr-9","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:ee.id,children:[ee.kind==="document"&&l.jsx(ti,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(Kj,{enabled:R&&ge,text:ee.title,onSave:Te=>H(ee.id,Te),children:ee.title},ee.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":_e?"Clear default sheet":"Set as default sheet",title:_e?"Clear default sheet":"Set as default sheet",onClick:Te=>{Te.stopPropagation(),re(ee.id,ee.title||"Sheet")},onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),Te.stopPropagation(),re(ee.id,ee.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",ge||_e?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(VZ,{className:m.cn("h-3 w-3 transition-colors",_e?"fill-current text-amber-500":"text-muted-foreground")})})]}),R&&ge&&l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx("button",{type:"button","aria-label":`Sheet actions for ${ee.title||"Sheet"}`,className:"absolute right-2 inline-flex h-4 w-4 items-center justify-center rounded-[4px] text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground",children:l.jsx(ei,{className:"h-3 w-3"})})}),l.jsxs(mo,{align:"start",className:"w-44",children:[l.jsxs(mn,{onSelect:()=>te(ee.id),children:[l.jsx(zd,{className:"h-4 w-4"}),"Duplicate sheet"]}),l.jsxs(mn,{disabled:D.length<=1,onSelect:()=>h(!0),children:[l.jsx(_a,{className:"h-4 w-4"}),"Delete sheet"]})]})]})]},ee.id)}),R&&l.jsxs(Co,{children:[l.jsx(So,{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(Mr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(mo,{align:"start",className:"w-48",children:[l.jsxs(mn,{onSelect:()=>X("dashboard"),children:[l.jsx(em,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(mn,{onSelect:()=>X("document"),children:[l.jsx(ti,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function pe(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:D==null?void 0:D.map(ee=>l.jsx(m.TabsContent,{style:{backgroundColor:se(),...E.dashboardCanvasStyle},className:m.cn("mt-0 h-full min-h-0",{}),value:ee.id,children:l.jsx(HK,{sheet:ee})},ee.id))})}function ye(){return l.jsxs(m.Tabs,{"data-role":"dashboard-tabs-container",className:m.cn("relative flex h-full flex-col",_==null?void 0:_.dashboardTabsContainer),onValueChange:ee=>{Q(ee)},value:A||void 0,children:[xe(),B==="top"&&!W&&l.jsx(sP,{}),A&&!W&&l.jsx(tIt,{}),W?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:pe()}):l.jsx(yl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:pe()}),B==="bottom"&&!W&&l.jsx(sP,{}),l.jsx(Nvt,{open:f,setOpen:h})]})}const ce=v.useCallback(ee=>{C("dashboard",ee)},[C]);return D?a&&A&&!W?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',A,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&W&&$?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(HK,{sheet:$})}):l.jsxs(l.Fragment,{children:[l.jsx(B_t,{}),l.jsx(U_t,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Ige,{className:m.cn("flex-1 basis-0 overflow-y-auto transition-opacity",k&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(GP,{children:ye()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(Cvt,{open:I,onTabClick:Z,withHandle:!0,disabled:!I}),l.jsx(GP,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:ie,defaultSize:I?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(M_t,{open:I,setOpen:Z,isFullscreen:k,onFullscreenChange:ee=>y(ee?"dashboard":null),fullscreenContainer:j})})})]})]}),l.jsx("div",{ref:ce,className:m.cn("absolute inset-0",!k&&"pointer-events-none")}),fe&&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||Z(!0)},onMouseDown:p,onTouchStart:p,title:"Open Assistant (drag to move)",children:l.jsx(Fve,{className:"h-5 w-5"})})})]})]}):null}const $xe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:i,className:a,style:c,...u},d)=>l.jsx(ig.InternalAppearanceRuntimeProvider,{appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:l.jsx(tx,{...u,ref:d,className:a,style:c,children:i})}));$xe.displayName="AppearanceProvider";const zxe=v.createContext({openBrandStudioPreview:()=>{}}),nIt=zxe.Provider;function rIt(){return v.useContext(zxe)}function oIt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=ig.normalizeTheme(t),[s,i]=v.useState(()=>sIt(n)||o),a=v.useCallback(u=>{const d=ig.normalizeTheme(u);iIt(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(ig.ThemeProviderContext.Provider,{...r,value:c,children:e})}function sIt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=ig.normalizeTheme(t,"system");return n===t?n:null}catch{return null}}function iIt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const aIt=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function tB({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=Et(),s=Kv(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.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),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,C=Kn({queryKey:WX({resourceType:ho.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>m.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:M=>(M==null?void 0:M.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),v.useEffect(()=>{C.data!==void 0&&y({scopeKey:w,appearance:C.data})},[C.data,w]);const N=(x==null?void 0:x.scopeKey)===w?x.appearance:null,S=i!==void 0?i:C.data!==void 0?C.data:N,j=v.useMemo(()=>Em.resolveAppearance({organizationAppearance:S,tokenAppearance:a,reactAppearance:e}),[e,S,a]),I=v.useCallback(()=>{f(g??h??j),u(!0)},[g,h,j]),k=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),p(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:I}),[I]),_=g??h??e;return l.jsx(oIt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(nIt,{value:T,children:l.jsx($xe,{organizationAppearance:S,tokenAppearance:a,reactAppearance:_,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(aIt,{appearance:d,onDraftChange:b,onSave:M=>{p(M),b(M),f(M)},onCancel:k})})})]})})})})}function Bxe({children:e,preferences:t}){const{currentUser:n}=si(),r=v.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(HX.Provider,{value:r,children:l.jsx(tT,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function lIt(e=2e3,t=500){const n=M0e(),[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>o(!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]),s}function nB({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=lIt(e,t);return v.useEffect(()=>(o&&(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()}}),[o,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:o?"ready":""})}function Vxe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ki,{FallbackComponent:JI,children:l.jsx(wO,{dashboardProps:e,children:l.jsxs(dT,{children:[l.jsx(nB,{componentType:"dashboard",componentId:e.id}),l.jsx(tB,{appearance:e.appearance,children:l.jsx(Bxe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(i5,{...e,type:"dashboard",children:l.jsx(Lxe,{})})})})})]})})})}function cIt(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[o,s]=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);s(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:o,updateAvailableWidth:i}}function uIt({filter:e}){var g;const t=m.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=$m(),r=gf((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=m.useDashboardStore(b=>b.filterValues),s=o==null?void 0:o.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=m.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:p}=cIt([t,s,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(Ci,{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(V$,{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(Me.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function dIt(){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(uIt,{filter:r}),l.jsx(GI,{filter:r})]},r.id))}):null}function fIt(){var s;const e=m.useDashboardStore(i=>i.dashboard),t=m.useDashboardStore(i=>i.selectedSheetId),n=m.useDashboardStore(i=>i.isDashboardEditing),r=(s=e.sheets)==null?void 0:s.find(i=>i.id===t),o=m.isDocumentSheet(r);return l.jsx("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[n&&!o&&l.jsx(dIt,{}),l.jsx(Lxe,{})]})})}const hIt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-B0Pm_y8L.cjs"))),mIt=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-B3oH-O0L.cjs"))),pIt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-Bk6nEHap.cjs")));function gIt({showControls:e=!1,showFooter:t=!0,...n}){const r=m.useDashboardStore(a=>a.isVisualEditing),o=m.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(ki,{FallbackComponent:JI,children:l.jsx(wO,{dashboardProps:n,children:l.jsxs(dT,{children:[l.jsx(nB,{componentType:"surfboard",componentId:n.id}),l.jsxs(tB,{appearance:s,children:[l.jsx(BCe,{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(Bxe,{preferences:i,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(pIt,{})}),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(hIt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(i5,{...n,type:"dashboard",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(mIt,{})}),l.jsx(v.Activity,{mode:r?"hidden":"visible",children:l.jsx(fIt,{})})]})})})]})]})]})]})})})}const lO=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],Hxe=new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),bIt=Bi.getSupportedCurrencyCodes(),xIt=bIt.filter(e=>!Hxe.has(e)),qxe=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],ZG="2026-07-31",W2="2026-07-31T14:30:45";function cO(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level"}}function K2(e){var t;return((t=qxe.find(n=>n.value===e))==null?void 0:t.label)??e}function yIt(e){const t=lO.find(n=>n.value===e);return t?`${t.label} — ${t.value}`:e}function G2(e){return{short:e("short"),medium:e("medium"),long:e("long")}}function Y2({id:e,label:t,value:n,inherited:r,inheritedSource:o,examples:s,disabled:i,onValueChange:a}){const c=n===void 0?`Inherited · ${K2(r)}`:K2(n);return l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),l.jsxs(m.Select,{value:n??"inherit",disabled:i,onValueChange:a,children:[l.jsx(m.SelectTrigger,{id:e,size:"xs",children:l.jsx(m.SelectValue,{children:c})}),l.jsxs(m.SelectContent,{children:[l.jsx(m.SelectItem,{value:"inherit",className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsxs("span",{children:["Inherited from ",cO(o)," ·"," ",K2(r)]}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[r]})]})}),qxe.map(u=>l.jsx(m.SelectItem,{value:u.value,className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsx("span",{children:u.label}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[u.value]})]})},u.value))]})]})]})}function vIt({value:e,inherited:t,inheritedSources:n,onChange:r,disabled:o}){var j,I,k,T;const s=v.useId(),i=v.useId(),a=v.useId(),c=v.useId(),u=v.useId(),f=(e.locale===void 0?void 0:Bi.canonicalizeSupportedLocale(e.locale))??t.locale,h=e.defaultCurrency??t.defaultCurrency,p={locale:f,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((j=e.dateTime)==null?void 0:j.dateStyle)??t.dateTime.dateStyle,timeStyle:((I=e.dateTime)==null?void 0:I.timeStyle)??t.dateTime.timeStyle},defaultCurrency:h},g=new Intl.NumberFormat(f,{style:"currency",currency:h}).format(1e3),b=$t.resolveRawTemporalFormat({preferences:p,calendar:{tz:"UTC"}}),x=$t.formatRawTemporalValue({value:ZG,metadata:{kind:"raw_temporal",valueKind:"date"},format:b}).text,y=$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:b}).text,w=G2(_=>$t.formatRawTemporalValue({value:ZG,metadata:{kind:"raw_temporal",valueKind:"date"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateStyle:_},calendar:{tz:"UTC"}})}).text),C=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateTime:{...p.dateTime,dateStyle:_}},calendar:{tz:"UTC"}})}).text),N=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateTime:{...p.dateTime,timeStyle:_}},calendar:{tz:"UTC"}})}).text),S=(_,E)=>{const D={...e.dateTime,[_]:E==="inherit"?void 0:E};r({...e,dateTime:D.dateStyle===void 0&&D.timeStyle===void 0?void 0:D})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:s,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),l.jsxs(m.Select,{value:e.locale??"inherit",disabled:o,onValueChange:_=>r({...e,locale:_==="inherit"?void 0:_}),children:[l.jsx(m.SelectTrigger,{id:s,size:"xs",children:l.jsx(m.SelectValue,{children:e.locale===void 0?`Inherited · ${t.locale}`:yIt(e.locale)})}),l.jsxs(m.SelectContent,{children:[l.jsxs(m.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.locale)," ·"," ",t.locale]}),e.locale&&!lO.some(_=>_.value===e.locale)&&l.jsx(m.SelectItem,{value:e.locale,children:e.locale}),lO.map(_=>l.jsxs(m.SelectItem,{value:_.value,children:[_.label," — ",_.value]},_.value))]})]})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),l.jsx(Y2,{id:a,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:n.dateStyle,examples:w,disabled:o,onValueChange:_=>r({...e,dateStyle:_==="inherit"?void 0:_})})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),l.jsx(Y2,{id:c,label:"Date",value:(k=e.dateTime)==null?void 0:k.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:n.dateTime.dateStyle,examples:C,disabled:o,onValueChange:_=>S("dateStyle",_)}),l.jsx(Y2,{id:u,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:n.dateTime.timeStyle,examples:N,disabled:o,onValueChange:_=>S("timeStyle",_)})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),l.jsxs(m.Select,{value:e.defaultCurrency??"inherit",disabled:o,onValueChange:_=>r({...e,defaultCurrency:_==="inherit"?void 0:_}),children:[l.jsx(m.SelectTrigger,{id:i,size:"xs",children:l.jsx(m.SelectValue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),l.jsxs(m.SelectContent,{children:[l.jsxs(m.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...Hxe].map(_=>l.jsx(m.SelectItem,{value:_,children:_},_)),xIt.map(_=>l.jsx(m.SelectItem,{value:_,children:_},_))]})]})]}),l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),l.jsxs("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:x})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date & time"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:y})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Currency"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:g})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]})}const uO=new Set;function Uxe(e){return uO.add(e),()=>{uO.delete(e)}}function rB(){uO.forEach(e=>{e()})}var wIt=Object.defineProperty,CIt=(e,t,n)=>t in e?wIt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y1=(e,t,n)=>CIt(e,typeof t!="symbol"?t+"":t,n);const SIt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},NIt={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}},jIt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function kIt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function Wxe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const _It={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=Wxe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},IIt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},TIt={stringify:e=>e,parse:e=>e},Z2={string:TIt,number:IIt,boolean:SIt,function:NIt,method:_It,json:jIt},sy=Symbol.for("r2wc.render"),v1=Symbol.for("r2wc.connected"),Kf=Symbol.for("r2wc.context"),Di=Symbol.for("r2wc.props");function EIt(e,t,n){var r,o,s;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=kIt(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(),y1(this,s,!0),y1(this,o),y1(this,r,{}),y1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Di].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?Z2[y]:null;if(y==="method"){const C=Wxe(b);Object.defineProperty(this[Di].container,C,{enumerable:!0,configurable:!0,get(){return this[Di][C]},set(N){this[Di][C]=N,this[sy]()}}),this[Di][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Di][g]=w.parse(x,b,this))}for(const g of a)this[Di][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[v1]=!0,this[sy]()}disconnectedCallback(){this[v1]=!1,this[Kf]&&n.unmount(this[Kf]),delete this[Kf]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],C=w?Z2[w]:null;y in c&&C!=null&&C.parse&&x&&(this[Di][y]=C.parse(x,g,this),this[sy]())}[(s=v1,o=Kf,r=Di,sy)](){this[v1]&&(this[Kf]?n.update(this[Kf],this[Di]):this[Kf]=n.mount(this.container,e,this[Di]))}}for(const p of i){const g=d[p],b=c[p];Object.defineProperty(h.prototype,p,{enumerable:!0,configurable:!0,get(){return this[Di][p]},set(x){this[Di][p]=x;const y=b?Z2[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[sy]()}})}return h}function DIt(e,t,n){const r=xye.createRoot(e),o=v.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function MIt({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function RIt({root:e}){e.unmount()}function AIt(e,t={}){return EIt(e,t,{mount:DIt,update:MIt,unmount:RIt})}const FIt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",interactionExecutionSnapshot:"json",presentationExecutionSnapshot:"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"},PIt=AIt(Vxe,{props:FIt}),OIt=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(g4,{context:t})," "]})});var Kxe="Toggle",Gxe=oe.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[i,a]=m.useControllableState({prop:n,onChange:o,defaultProp:r??!1,caller:Kxe});return l.jsx(m.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:m.composeEventHandlers(e.onClick,()=>{e.disabled||a(!i)})})});Gxe.displayName=Kxe;var Yxe=Gxe;const LIt=m.cva("inline-flex items-center justify-center rounded-control text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Zxe=oe.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(Yxe,{ref:o,className:m.cn(LIt({variant:t,size:n,className:e})),...r}));Zxe.displayName=Yxe.displayName;function oB(){var c,u;const e=m.useEditorStore(d=>d.card),t=m.useEditorStore(d=>d.frame),n=v.useMemo(()=>tt.findCustomVisualConfigCard(t,e),[t,e]),{manifest:r}=kf(((c=n==null?void 0:n.customCardPreferences)==null?void 0:c.url)||""),o=v.useMemo(()=>{var d;return(d=r==null?void 0:r.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=n==null?void 0:n.customCardPreferences)==null?void 0:h.componentName)})},[r,(u=n==null?void 0:n.customCardPreferences)==null?void 0:u.componentName]),s=tt.resolveMultiInputType(n,o),i=v.useMemo(()=>tt.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:s==="multiple"}),[t,n,s]),a=v.useMemo(()=>{const d=i.findIndex(f=>(f==null?void 0:f.id)===e.id);return d<0?-1:tt.getSlotIndexForCard(e,d)},[i,e]);return v.useMemo(()=>!n||s!=="multiple"||a<0?e.type:tt.getEffectiveCardTypeForSlot(e,a,o==null?void 0:o.slots)??e.type,[n,s,a,e,o==null?void 0:o.slots])}function Xxe({storeValue:e,defaultValue:t="",onStoreUpdate:n,delay:r=300}){const[o,s]=v.useState(e??t),i=v.useRef(null),a=v.useRef(o),c=v.useRef(e),u=v.useRef(!1),d=v.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null),u.current&&a.current!==(c.current??t)&&(n(a.current),c.current=a.current)},[t,n]);v.useEffect(()=>{if(e!==c.current){i.current&&(clearTimeout(i.current),i.current=null);const h=e??t;s(h),a.current=h,c.current=e,u.current=!1}},[e,t]),v.useEffect(()=>{if(u.current)return i.current=setTimeout(()=>{d()},r),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[r,d,o]),v.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const f=v.useCallback(h=>{const p=h??t;u.current=!0,a.current=p,s(p)},[t]);return{value:o,onChange:f,flush:d}}const $It=300;function zIt({onExpand:e},t){const n=m.useEditorStore(C=>C.card.sql),r=m.useEditorStore(C=>C.sqlGen),o=m.useEditorStore(C=>C.card),s=oB(),{setCardSql:i,setSqlGen:a,setRunSql:c}=m.useEditorActions(),u=v.useMemo(()=>s!==o.type?{...o,type:s}:o,[o,s]),{queryKey:d}=Cb(u),f=Br(),h=v.useRef(d);h.current=d;const p=v.useRef(r);p.current=r;const g=v.useCallback(C=>{i(C)},[i]),{value:b,onChange:x,flush:y}=Xxe({storeValue:n,defaultValue:"",onStoreUpdate:g,delay:$It});v.useEffect(()=>Uxe(y),[y]);function w(C){x(C),m.isObjectEmpty(p.current)||a({})}return l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx(m.CodeEditor,{ref:t,value:b??"",onValueChange:w,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,wrapLines:!0,placeholder:"Write your SQL here",onKeyDown:C=>{C.key==="Enter"&&C.shiftKey&&(C.preventDefault(),rB(),setTimeout(()=>{f.removeQueries({queryKey:h.current,exact:!0}),c(!0)},0))}}),e?l.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-2.5 top-2 z-20 h-7 w-7 bg-background/80 p-0 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:text-foreground",onClick:e,"aria-label":"Expand SQL editor",title:"Expand SQL editor",children:l.jsx(Pt.Maximize2,{className:"h-3.5 w-3.5",strokeWidth:1.75})}):null]})}const BIt=v.forwardRef(zIt),VIt=300;function HIt(e,t){const n=m.useEditorStore(g=>g.card.python),r=m.useEditorStore(g=>g.card),o=oB(),{setCardPython:s,setRunSql:i}=m.useEditorActions(),a=v.useMemo(()=>o!==r.type?{...r,type:o}:r,[r,o]),{queryKey:c}=Cb(a),u=Br(),d=v.useRef(c);d.current=c;const{value:f,onChange:h,flush:p}=Xxe({storeValue:n,defaultValue:tt.PYTHON_DEFAULT_CODE,onStoreUpdate:s,delay:VIt});return v.useEffect(()=>Uxe(p),[p]),l.jsx(m.CodeEditor,{ref:t,value:f??"",onValueChange:h,language:"python",embedded:!0,hideLineNumbers:!0,wrapLines:!0,className:"[&_.code-editor-pre]:!pt-2 [&_.code-editor-textarea]:!pt-2",onKeyDown:g=>{g.key==="Enter"&&g.shiftKey&&(g.preventDefault(),rB(),setTimeout(()=>{u.removeQueries({queryKey:d.current,exact:!0}),i(!0)},0))}})}const qIt=v.forwardRef(HIt),Qxe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),UIt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),WIt=Array.from(Qxe).join(", "),KIt=3,GIt="Self-heal",YIt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function ZIt({card:e}){var z,P,U,G,Q;const t=xl(),[n,r]=v.useState({}),{authToken:o}=Et(),s=m.getTokenParams(o==null?void 0:o.accessToken),{compiledAppearance:i}=oi.useAppearance(),a=v.useMemo(()=>Ww(i),[i]),c=m.useEditorStore(H=>H.frame),u=m.useEditorStore(H=>H.inlineFilterValuesMap[e.id]),d=m.useEditorStore(H=>H.actions.setCardInlineFilterValue),f=m.useEditorStore(H=>H.actions.removeCardInlineFilterValue),h=e,{getCard:p,manifest:g}=kf(((z=h.customCardPreferences)==null?void 0:z.url)||""),b=(P=g==null?void 0:g.visuals)==null?void 0:P.find(H=>{var L;return H.name===((L=h.customCardPreferences)==null?void 0:L.componentName)}),x=tt.resolveMultiInputType(h,b)??"single",y=v.useMemo(()=>tt.getCustomVisualInputCards({frame:c,configCard:h,isMultiInputVisual:x==="multiple"}),[c,h,x]),w=v.useMemo(()=>{const H=y.findIndex(L=>(L==null?void 0:L.id)===e.id);return H<0?-1:tt.getSlotIndexForCard(e,H)},[y,e]),C=v.useMemo(()=>x!=="multiple"||w<0?e.type:tt.getEffectiveCardTypeForSlot(e,w,b==null?void 0:b.slots)??e.type,[x,w,e,b==null?void 0:b.slots]),N=v.useMemo(()=>x==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:C!==e.type?{...e,type:C}:e,[e,C,x]),{data:S,effectiveCardConfig:j}=Cb(N),I=m.useInteractionStore(H=>H.interactionStates),k=m.useDashboardStore(H=>{var L;return(L=H.dashboard)==null?void 0:L.id}),T=m.useDashboardStore(H=>H.dashboard.filters),_=m.useDashboardStore(H=>H.filterValues),E=m.useDashboardStore(H=>H.selectedSheetId),D=v.useMemo(()=>q$({card:e,sheetId:E||"",inlineFilterValues:u,setInlineFilterValue:H=>d(e.id,H),removeInlineFilterValue:H=>f(e.id,H)}),[e,E,u,d,f]),{cardFilters:M,cardFilterValues:R}=v.useMemo(()=>v_({card:e,interactionStates:I,currentDashboardId:k,filters:T,filterValues:_,selectedSheetId:E}),[e,I,k,T,_,E]),A=v.useCallback((H,L)=>{const K=tt.normalizeMultiInputPayload(L);r(Y=>({...Y,[H]:K}))},[]),$=(U=h.customCardPreferences)==null?void 0:U.componentName,O=$?p($):null,B=Uj((G=h.customCardPreferences)==null?void 0:G.settings,h),W=v.useMemo(()=>tt.buildSlotOrderedCards(y),[y]),F=v.useMemo(()=>W.map((H,L)=>tt.getEffectiveCardTypeForSlot(H,L,b==null?void 0:b.slots)),[W,b==null?void 0:b.slots]),q=v.useMemo(()=>K$(x==="multiple"?W$({slotOrderedCards:W,multiInputData:n,valueFormatPreferences:t}):[{card:e,cardConfig:j,columns:S==null?void 0:S.columns,columnKeyMap:S==null?void 0:S.columnKeyMap,valueFormatPreferences:t}]),[e,S==null?void 0:S.columnKeyMap,S==null?void 0:S.columns,j,n,W,x,t]);return $?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:[O&&x==="single"&&l.jsx(O,{editing:!0,params:s,theme:a,settings:B,cardMetadata:Due({card:e,dataMetadata:S==null?void 0:S.metadata}),onDataChange:A,data:(S==null?void 0:S.records)||[],columns:(S==null?void 0:S.columns)||[],formatTemporalBucketValue:q,filters:M,filterValues:[...R||[],...u||[]],inlineFilters:D}),O&&x==="multiple"&&l.jsxs(l.Fragment,{children:[y.map((H,L)=>{if(!H)return null;const K=tt.getSlotIndexForCard(H,L),Y=tt.getEffectiveCardTypeForSlot(H,K,b==null?void 0:b.slots);return l.jsx(p$,{onDataChange:A,card:H,effectiveCardType:Y},`${H.id}-${K}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(O,{editing:!0,onDataChange:A,...U$({configCard:h,slotOrderedCards:W,slotTypes:F,multiInputData:n,params:s,theme:a,chartSettings:B,filters:M,filterValues:[...R||[],...u||[]],inlineFilters:D,formatTemporalBucketValue:q})})})]})]},(Q=h.customCardPreferences)==null?void 0:Q.componentName)}):null}const XIt=v.memo(ZIt),QIt=m.create()(m.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var Jxe=["PageUp","PageDown"],eye=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],tye={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},px="Slider",[dO,JIt,eTt]=m.createCollection(px),[nye]=m.createContextScope(px,[eTt]),[tTt,ZT]=nye(px),rye=oe.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=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=oe.useRef(new Set),y=oe.useRef(0),C=i==="horizontal"?nTt:rTt,[N=[],S]=m.useControllableState({prop:d,defaultProp:u,onChange:E=>{var M;(M=[...x.current][y.current])==null||M.focus(),f(E)}}),j=oe.useRef(N);function I(E){const D=lTt(N,E);_(E,D)}function k(E){_(E,y.current)}function T(){const E=j.current[y.current];N[y.current]!==E&&h(N)}function _(E,D,{commit:M}={commit:!1}){const R=fTt(s),A=hTt(Math.round((E-r)/s)*s+r,R),$=m.clamp(A,[r,o]);S((O=[])=>{const B=iTt(O,$,D);if(dTt(B,c*s)){y.current=B.indexOf($);const W=String(B)!==String(O);return W&&M&&h(B),W?B:O}else return O})}return l.jsx(tTt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:N,orientation:i,form:g,children:l.jsx(dO.Provider,{scope:e.__scopeSlider,children:l.jsx(dO.Slot,{scope:e.__scopeSlider,children:l.jsx(C,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:m.composeEventHandlers(b.onPointerDown,()=>{a||(j.current=N)}),min:r,max:o,inverted:p,onSlideStart:a?void 0:I,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&_(r,0,{commit:!0}),onEndKeyDown:()=>!a&&_(o,N.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const A=Jxe.includes(E.key)||E.shiftKey&&eye.includes(E.key)?10:1,$=y.current,O=N[$],B=s*A*D;_(O+B,$,{commit:!0})}}})})})})});rye.displayName=px;var[oye,sye]=nye(px,{startEdge:"left",endEdge:"right",size:"width",direction:1}),nTt=oe.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=oe.useState(null),p=m.useComposedRefs(t,C=>h(C)),g=oe.useRef(void 0),b=m.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function w(C){const N=g.current||f.getBoundingClientRect(),S=[0,N.width],I=sB(S,y?[n,r]:[r,n]);return g.current=N,I(C-N.left)}return l.jsx(oye,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(iye,{dir:b,"data-orientation":"horizontal",...d,ref:p,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const N=w(C.clientX);i==null||i(N)},onSlideMove:C=>{const N=w(C.clientX);a==null||a(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:C=>{const S=tye[y?"from-left":"from-right"].includes(C.key);u==null||u({event:C,direction:S?-1:1})}})})}),rTt=oe.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=oe.useRef(null),f=m.useComposedRefs(t,d),h=oe.useRef(void 0),p=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],C=sB(y,p?[r,n]:[n,r]);return h.current=x,C(b-x.top)}return l.jsx(oye,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:l.jsx(iye,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);s==null||s(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=tye[p?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),iye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=ZT(px,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()):Jxe.concat(eye).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)&&o(f)}),onPointerUp:m.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),aye="SliderTrack",lye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=ZT(aye,n);return l.jsx(m.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});lye.displayName=aye;var fO="SliderRange",cye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=ZT(fO,n),s=sye(fO,n),i=oe.useRef(null),a=m.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>fye(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(m.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});cye.displayName=fO;var hO="SliderThumb",uye=oe.forwardRef((e,t)=>{const n=JIt(e.__scopeSlider),[r,o]=oe.useState(null),s=m.useComposedRefs(t,a=>o(a)),i=oe.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(oTt,{...e,ref:s,index:i})}),oTt=oe.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=ZT(hO,n),a=sye(hO,n),[c,u]=oe.useState(null),d=m.useComposedRefs(t,w=>u(w)),f=c?i.form||!!c.closest("form"):!0,h=m.useSize(c),p=i.values[r],g=p===void 0?0:fye(p,i.min,i.max),b=aTt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?cTt(x,g,a.direction):0;return oe.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(dO.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,...s,ref:d,style:p===void 0?{display:"none"}:e.style,onFocus:m.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(dye,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},r)]})});uye.displayName=hO;var sTt="RadioBubbleInput",dye=oe.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=oe.useRef(null),s=m.useComposedRefs(o,r),i=m.usePrevious(t);return oe.useEffect(()=>{const a=o.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:s,defaultValue:t})});dye.displayName=sTt;function iTt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function fye(e,t,n){const s=100/(n-t)*(e-t);return m.clamp(s,[0,100])}function aTt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function lTt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function cTt(e,t,n){const r=e/2,s=sB([0,50],[0,r]);return(r-s(t)*n)*n}function uTt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function dTt(e,t){if(t>0){const n=uTt(e);return Math.min(...n)>=t}return!0}function sB(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 fTt(e){return(String(e).split(".")[1]||"").length}function hTt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var hye=rye,mTt=lye,pTt=cye,gTt=uye;const mye=oe.forwardRef(({className:e,...t},n)=>l.jsxs(hye,{ref:n,className:m.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(mTt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(pTt,{className:"absolute h-full bg-primary"})}),l.jsx(gTt,{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"})]}));mye.displayName=hye.displayName;exports.Accordion=a4;exports.AccordionContent=kv;exports.AccordionItem=Nv;exports.AccordionTrigger=jv;exports.AddDataPicker=X4;exports.AggregateTable=NI;exports.Alert=lL;exports.AlertDescription=cL;exports.AlertDialog=mf;exports.AlertDialogAction=Fu;exports.AlertDialogCancel=Pu;exports.AlertDialogContent=Eu;exports.AlertDialogDescription=Au;exports.AlertDialogFooter=Mu;exports.AlertDialogHeader=Du;exports.AlertDialogTitle=Ru;exports.AlertDialogTrigger=a1e;exports.AlertTitle=Ite;exports.ArrowDown=rs;exports.ArrowDownIcon=HQe;exports.ArrowLeft=Xv;exports.ArrowRight=Qv;exports.ArrowUp=vs;exports.ArrowUpIcon=UQe;exports.AssistantContextEntityControls=iO;exports.AssistantVirtualizedMessages=Axe;exports.AxisConfigurator=Km;exports.BackgroundRunPill=wut;exports.Badge=xi;exports.Bell=N1;exports.BookType=uZ;exports.BriefingAuthor=dhe;exports.BriefingAuthorDialog=fhe;exports.BriefingUiCapabilitiesBoundary=Hut;exports.BriefingUiCapabilitiesProvider=dT;exports.BriefingsApiError=eC;exports.BulletChartIcon=kxe;exports.CSS=Xi;exports.CalculatedFieldEditor=Vme;exports.Calculator=fZ;exports.Calendar=Ka;exports.CalendarClock=EO;exports.Card=SN;exports.CardContent=TO;exports.CardHeader=IO;exports.CardSummary=fP;exports.CardTitle=gb;exports.ChartArea=SR;exports.ChartColumnIncreasing=mZ;exports.ChartColumnStacked=pZ;exports.ChartJsVisual=Bw;exports.ChartLine=gZ;exports.ChartNoAxesGantt=xZ;exports.ChartPie=yZ;exports.ChartScatter=vZ;exports.ChatInputWithContext=Q4;exports.Checkbox=In;exports.ChevronLeft=Am;exports.ChevronsUpDown=SZ;exports.Circle=DO;exports.CircleAlert=ja;exports.CircleCheck=NZ;exports.CircleHelp=jZ;exports.Clock=kZ;exports.CodeHighlighter=$d;exports.CodeXml=j1;exports.Collapsible=Nu;exports.CollapsibleContent=ku;exports.CollapsibleTrigger=ju;exports.ColorField=ha;exports.Command=wT;exports.CommandEmpty=ST;exports.CommandGroup=NT;exports.CommandInput=Xz;exports.CommandItem=jT;exports.CommandList=CT;exports.CommandSeparator=ame;exports.ComparisonMetadataBadge=Xoe;exports.Container=i5;exports.ControlDefaultValueEditor=fpe;exports.ControlDefinitionOptionsEditor=dpe;exports.ControlIdInput=ape;exports.ControlVisibilitySettings=abt;exports.Copy=zd;exports.CopyButton=Ld;exports.CopyPlus=NR;exports.Cross2Icon=YQe;exports.CustomFilterPopover=V$;exports.CustomScrollArea=yl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=Kre;exports.Dashboard=Vxe;exports.DashboardCard=ghe;exports.DashboardCreateDialogBase=yQ;exports.DashboardExportDialog=Fxe;exports.DashboardPlus=gIt;exports.DashboardWC=PIt;exports.DataTableConditionalFormattingSettings=tge;exports.DataTablePagination=pI;exports.Database=Go;exports.DateRangePicker=L$;exports.DefaultChatTransport=B4;exports.Dialog=No;exports.DialogContent=po;exports.DialogDescription=Oo;exports.DialogFooter=il;exports.DialogHeader=Es;exports.DialogTitle=go;exports.DialogTrigger=gQ;exports.DisplayFormatPreferencesFields=vIt;exports.DisplayPreferencesProvider=tT;exports.DndContext=dC;exports.Donut=_Z;exports.Download=_u;exports.DownloadPdf=Pxe;exports.DragOverlay=Khe;exports.DropdownMenu=Co;exports.DropdownMenuCheckboxItem=sd;exports.DropdownMenuContent=mo;exports.DropdownMenuItem=mn;exports.DropdownMenuLabel=Ca;exports.DropdownMenuRadioGroup=mCe;exports.DropdownMenuRadioItem=VX;exports.DropdownMenuSeparator=Ia;exports.DropdownMenuSub=XO;exports.DropdownMenuSubContent=Zk;exports.DropdownMenuSubTrigger=Yk;exports.DropdownMenuTrigger=So;exports.EMPTY_DATA_SOURCE=mb;exports.Editable=Kj;exports.EditableText=Ci;exports.EditorCustomVisual=XIt;exports.Ellipsis=ei;exports.EllipsisVertical=Fm;exports.ErrorBoundary=ki;exports.ExportError=Rb;exports.ExternalLink=Bd;exports.EyeOff=Uk;exports.Fallback=JI;exports.FallbackVisual=Xw;exports.FeedbackCategory=df;exports.FeedbackDialog=Pv;exports.FieldsList=g4;exports.FieldsSection=OIt;exports.FileCode=IZ;exports.FileText=ti;exports.Filter=Vd;exports.FilterComponent=GI;exports.FilterInfo=lP;exports.FilterableFieldsPanel=qme;exports.Grid3x3=jR;exports.GripVertical=Iu;exports.HEATMAP_PRESET_PALETTES=$A;exports.Hash=bb;exports.House=TZ;exports.HoverCard=Qm;exports.HoverCardContent=wu;exports.HoverCardTrigger=Qd;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=Qxe;exports.INLINE_ALLOWED_TOOL_LIST=WIt;exports.INLINE_BLOCKED_MUTATING_TOOLS=UIt;exports.IconButton=su;exports.IconForFieldType=cN;exports.Inbox=RO;exports.InfoHover=cz;exports.InlineFilterBar=lde;exports.KPICard=of;exports.KeyboardSensor=cC;exports.Layers=Om;exports.Link=AO;exports.LoadingDots=uc;exports.MAX_SELF_HEAL_ATTEMPTS=KIt;exports.Map=RZ;exports.Markdown=Rz;exports.MatrixTableVisual=SI;exports.MdStackedLineChart=Nxe;exports.MultiInputEmptyRenderer=p$;exports.PanelResizeHandle=VT;exports.Pause=AZ;exports.PenLine=IR;exports.Pencil=TR;exports.PendingMessagesDisplay=mxe;exports.PersistedDynamicVisual=eT;exports.PiChartPolar=vxe;exports.Pin=PZ;exports.PinOff=FZ;exports.PivotTableTanstack=ex;exports.Placeholders=Tge;exports.Play=OZ;exports.Plus=Mr;exports.PointerSensor=ax;exports.Progress=K4;exports.PythonEditor=qIt;exports.RECOVERABLE_SQL_ERROR_CODES=YIt;exports.Radar=LZ;exports.RadioGroup=yu;exports.RadioGroupItem=Xs;exports.RefreshCw=ka;exports.ResizableHandle=wvt;exports.ResizablePanel=GP;exports.ResizablePanelGroup=Ige;exports.ResourceEditDialog=ZQ;exports.ResourceType=ho;exports.Rows3=$Z;exports.RunCompletionBanner=Cut;exports.SELF_HEAL_TIMELINE_STEP=GIt;exports.SeedQuestions=Jbe;exports.SemaphorContext=Wv;exports.SemaphorContextProvider=wO;exports.SemaphorQueryClient=LY;exports.SemaphorReadyIndicator=nB;exports.SemaphorStyleWrapper=tx;exports.Send=PO;exports.SendHorizontal=zZ;exports.Settings=OO;exports.Settings2=ff;exports.Share2=BZ;exports.ShareDialog=YQ;exports.Sheet=p3;exports.SheetContent=gI;exports.SheetDescription=xI;exports.SheetHeader=Boe;exports.SheetTitle=bI;exports.SheetTrigger=g4e;exports.Slider=mye;exports.SortableContext=fC;exports.Sparkles=k0;exports.SqlEditor=BIt;exports.Square=$O;exports.SquarePen=LO;exports.Star=VZ;exports.StructuralParticipantSelector=lpe;exports.SummaryCard=sP;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Pd;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=ga;exports.TableBody=Xd;exports.TableCell=Wn;exports.TableColumnVisibilitySettings=Hpe;exports.TableHead=vo;exports.TableHeader=Xm;exports.TablePresentationSettings=Upe;exports.TableRow=Pr;exports.TableSkeleton=dz;exports.TableVisual=Jd;exports.Tag=HZ;exports.TbChartBubble=wxe;exports.TbChartFunnel=Cxe;exports.TbChartTreemap=Sxe;exports.TextCard=sb;exports.Textarea=Bm;exports.TiSortNumerically=jxe;exports.Toggle=Zxe;exports.Tornado=qZ;exports.Trash2=_a;exports.TriangleAlert=Po;exports.TypeGlyph=oC;exports.UXProvider=tB;exports.Undo2=UZ;exports.User=BO;exports.Users=Wk;exports.UsersRound=VO;exports.VisualErrorState=Wue;exports.Zap=ER;exports.applyBriefingFormPatch=pv;exports.areContextEntitiesEqual=ur;exports.areEntitiesJoined=Xre;exports.arrayMove=lx;exports.briefingFormDraftToCreateRequest=pP;exports.briefingFormDraftToUpdateRequest=Ude;exports.briefingToFormDraft=og;exports.briefingTone=Er;exports.buildCardControlUsageById=cbt;exports.buildCustomCardTheme=Ww;exports.buildDashboardControlUsageById=lbt;exports.buildDashboardSheetsInputExecutionSnapshot=_O;exports.buildDashboardStructuralParticipantIdsByControlId=ppe;exports.buildFilterFieldMeta=pO;exports.buildFilterSemanticContext=gO;exports.buildInlineFilterNodes=q$;exports.buildMultiInputCustomVisualProps=U$;exports.buildMultiInputTemporalPresentationInputs=W$;exports.calculateCardFilterValues=y_;exports.calculateContextAwareFilters=v_;exports.calculateFieldState=e3;exports.canEditLocalCalculatedFields=f4;exports.canUserAccessVisuals=hNe;exports.canUserCreateDashboards=QQ;exports.canUserEdit=uNe;exports.canUserManageDashboards=fNe;exports.canUserManageGroups=mNe;exports.canUserUseFilters=dNe;exports.cancelBriefingPreviewRun=Rde;exports.cancelBriefingRun=Fde;exports.cancelExport=F$e;exports.chartSupportsDataLabels=qne;exports.chartSupportsLegend=Vne;exports.chartTypes=YT;exports.cleanupKpiMetricComparisonMode=gme;exports.cloneLinkedFrameWithSourceMapping=ytt;exports.closestCenter=lC;exports.commitSharedCalculatedFields=th;exports.createAssistantConversationId=Wp;exports.createAssistantRequestId=Xbe;exports.createBriefing=jde;exports.createBriefingFormDraft=mP;exports.createChartConfig=Db;exports.createCustomVisualTemporalBucketFormatter=K$;exports.createDashboardControlInputFromControl=l0t;exports.createExport=boe;exports.currencyPresentationTargetKey=va;exports.dedup=gjt;exports.dedupeContextEntities=Bz;exports.deleteBriefing=Ide;exports.deleteBriefingRun=Pde;exports.diagnoseCurrencyPresentationBindings=Q0e;exports.doesStoredFilterMatchField=Ag;exports.downloadDocumentPdf=rL;exports.downloadPdf=ste;exports.extractTableMetadata=n4;exports.fieldAlreadyExists=Jre;exports.flexRender=vi;exports.flushPendingEditorDrafts=rB;exports.formatDisplayFormula=opt;exports.formatFileSize=L$e;exports.getAutoDetectedChartIcon=Gkt;exports.getBriefing=Nde;exports.getBriefingArtifact=Nnt;exports.getBriefingEvidence=jnt;exports.getBriefingPreviewRun=Mde;exports.getBriefingRun=Ade;exports.getCardCurrencyPresentationFields=jO;exports.getCardCurrencyPresentationTargets=kO;exports.getChartGridStyle=SDe;exports.getChartIconByType=Ykt;exports.getColorForValue=JR;exports.getCoreRowModel=fI;exports.getDefaultAxisConfig=oA;exports.getDefaultChartColors=Wm;exports.getDefaultDataLabelsConfig=Cw;exports.getDefaultLegendConfig=PL;exports.getDefaultRunningTotalPartitionByFieldIds=b0;exports.getDisplayedKpiResultColumnKeys=jw;exports.getDocumentSectionEditorCard=Bgt;exports.getDocumentSheetDashboardInputs=dx;exports.getDownloadUrl=A$e;exports.getEntityIcon=Ok;exports.getErrorMessage=Obe;exports.getExportStatus=R$e;exports.getExports=M$e;exports.getExpressionFieldKind=af;exports.getFieldExpressionAnnotation=r4;exports.getFilterCount=ek;exports.getFilterSourceDatabase=pY;exports.getGranularityOptionsForFieldType=ipe;exports.getKeys=Cr;exports.getMatrixVisualLoadingState=cI;exports.getMetricDisplayLabel=$3e;exports.getNewField=ooe;exports.getPaginationRowModel=hI;exports.getRoleBasedDisplayOverrides=XQ;exports.getRunningTotalOrderByCandidates=_mt;exports.getSelectedDateFilterColumn=uue;exports.getSemanticDomainLabel=hxe;exports.getSortedRowModel=Loe;exports.getTableConditionalFormattingColumnOptions=Ype;exports.getTableOutputColumnOptions=Zpe;exports.handleAggregationChange=cP;exports.handleAggregationLabelChange=ide;exports.hasFlatTableTotalsBehavior=Um;exports.hasMatrixResultData=_w;exports.horizontalListSortingStrategy=Kz;exports.inferSemanticDomainIdFromSelectedEntities=Pk;exports.isActiveBriefingRunStatus=sk;exports.isCardSummaryVisibleOnCard=G$;exports.isCurrencyPresentationControl=Z0e;exports.isDefaultColor=LTe;exports.isDevPaginationSwitchableCard=poe;exports.isEligibleFlatTableTotalsCard=hw;exports.isExportComplete=O$e;exports.isExportInProgress=P$e;exports.isInAiScopeArray=pjt;exports.isManagedCalculatedExpressionField=ol;exports.isMetricTransformEnabled=jmt;exports.isPresentationCurrencyBinding=Yv;exports.isPromiseLike=sO;exports.isSqlBackedKpi=soe;exports.isStructuralControlBinding=Y0e;exports.isSubtotalEnabledAggregateTable=t4;exports.isSupportedDocumentTableCardType=Vgt;exports.isTableType=cDe;exports.isTerminalBriefingRunStatus=ok;exports.lastAssistantMessageIsCompleteWithToolCalls=Rbe;exports.listBriefingRuns=Snt;exports.listBriefingTenantSummaries=Cnt;exports.listBriefings=wnt;exports.merge=sc;exports.mergeAxisConfig=sA;exports.normalizeConditionalFormatting=z5;exports.normalizeContextFormatMode=Eee;exports.pauseBriefing=kde;exports.pivotData=gw;exports.polishBriefingText=Ode;exports.prepareFeedbackData=GT;exports.previewBriefingPlan=Ede;exports.remarkGfm=Oz;exports.removeFromScopeArray=bjt;exports.resolveCurrencyPresentationTargetFormat=Aee;exports.resolveDashboardBriefingsVisibility=hhe;exports.resolveDashboardControlsVisibility=xNe;exports.resolveDashboardTitleEditability=bNe;exports.resolveDomainCalculatedFieldForEdit=Jpt;exports.resolveMatrixCardMeasureInstances=qk;exports.resolvePendingPivotTableResultState=h$e;exports.resolveTablePresentationStyle=S3;exports.resumeBriefing=_de;exports.runBriefingNow=Tde;exports.runBriefingPreview=Dde;exports.sanitizeAIScope=Pbe;exports.saveCalculatedFieldToCardScope=zP;exports.saveCalculatedFieldToSharedScope=Hme;exports.saveCalculatedFieldToSheetScope=BP;exports.seedSemanticMetricFormatDefaults=xme;exports.setTableColumnVisibility=yoe;exports.setupEditorWithCard=F_;exports.showAllTableColumns=z$e;exports.showJoinRequiredNotification=Qre;exports.sortByColumnsToSortState=ase;exports.sortStateToSortByColumns=lse;exports.sortableKeyboardCoordinates=Yz;exports.supportsLiveNumericPresentation=Gv;exports.supportsMetricTransformForMetric=bme;exports.supportsTableConditionalFormatting=Wpe;exports.toEntityArray=rl;exports.ue=et;exports.updateBriefing=rT;exports.useActiveExports=NNe;exports.useActiveToolStatus=gxe;exports.useAddFrameWithFreshSemanticExecutionPayload=lz;exports.useAddNewFrame=She;exports.useAssistantContainer=nJ;exports.useAssistantContextEntities=fT;exports.useAssistantLayoutStore=Ah;exports.useAssistantPanel=eJ;exports.useAssistantProfile=Qbe;exports.useAutoSubmitQueue=pxe;exports.useBrandStudioPreview=rIt;exports.useBriefingRunPolling=bP;exports.useBriefingUiCapabilities=mhe;exports.useCalendarContext=Z3e;exports.useCard=r$e;exports.useCardNumericPresentation=Fa;exports.useCardSummary=Y$;exports.useChartNumericPresentation=Mb;exports.useChat=Fbe;exports.useColumns=Qz;exports.useCreateVisualWithFrame=uSe;exports.useCurrentUserInfo=si;exports.useCustomVisual=kf;exports.useCustomVisualsQuery=B$;exports.useDashboardAppearance=Ou;exports.useDashboardById=XX;exports.useDashboardInteractionMode=nde;exports.useDashboardPreferences=$m;exports.useDashboardQuery=Kv;exports.useDashboardStructuralParticipants=gpe;exports.useDashboardSummary=Lue;exports.useDataColumns=vme;exports.useDateFilterHook=vYe;exports.useDefaultDashboardMutation=qX;exports.useDisplayPreferences=pl;exports.useDroppable=Whe;exports.useEditorAside=kT;exports.useEditorCardQuery=Cb;exports.useEffectiveEditorCardType=oB;exports.useEnsureReactGlobals=Mle;exports.useExportActions=rJ;exports.useExportStore=s_;exports.useFieldManagement=yme;exports.useFilterableFields=hme;exports.useFullscreenAssistant=tJ;exports.useGroupMembers=f1e;exports.useGroups=o5;exports.useHasDashboardId=oJ;exports.useInProgressExportsCount=jNe;exports.useJoinabilityMap=e4;exports.useManagementActions=Rm;exports.useManagementStore=Ts;exports.useMutation=Is;exports.usePivotTableConfig=Ym;exports.usePluginQuery=Cue;exports.useQuery=Kn;exports.useQueryClient=Br;exports.useReactTable=mI;exports.useResolveExistingFrameSemanticExecutionPayload=Stt;exports.useResolvedDefaultCurrency=r3;exports.useResolvedTemporalStylePreferences=xl;exports.useResolvedValueFormatLocale=n3;exports.useResourceManagement=JO;exports.useResourceUpdateState=QX;exports.useScopedFields=fme;exports.useSelectedVisual=P0e;exports.useSemanticDomains=G4;exports.useSemaphorContext=Et;exports.useSensor=db;exports.useSensors=gT;exports.useSortable=cx;exports.useStarredChartsStore=QIt;exports.useSurfaceAppearance=ml;exports.useTableQueryState=Qoe;exports.useTextFilterHook=ZUe;exports.useTheme=gY;exports.useTimezone=bl;exports.useTopoJson=Nw;exports.useUnifiedUsers=r_;exports.useUpdateResource=KX;exports.useUpdateVisualMutation=dSe;exports.useUserPreferences=vQ;exports.useVisualById=Qk;exports.useVisualManagement=cSe;exports.validateBriefingFormDraft=gP;exports.validateFieldForChartType=pme;exports.verticalListSortingStrategy=Gz;
1404
+ `).trim(),k=j.map((T,_)=>{var M,R;let E="",D;if((M=T.url)!=null&&M.startsWith("data:")){const A=T.url.match(/data:[^;]+;base64,(.+)/);A&&(E=A[1],(R=T.mediaType)!=null&&R.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${_}`,name:T.filename||`File ${_+1}`,size:0,type:T.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(w_t,{text:I||void 0,files:k.length>0?k:void 0})}const f=((C=e.parts)==null?void 0:C.filter(S=>S.type==="reasoning"))||[],h=f.length>0,p=f.some(S=>S.state==="streaming"),g=f.filter(S=>S.text&&S.text.trim().length>0),b=h&&(g.length>0||p)?l.jsxs(Nu,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(ju,{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(Pt.ChevronRight,{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(ku,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((S,j)=>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:j+1}),l.jsx(OG,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:S.text})]},`${e.id||t}-reasoning-${j}`))})})]},`${e.id||t}-reasoning`):null,x=(N=e.parts)==null?void 0:N.map((S,j)=>{var k;const I=`${e.id||t}-${j}`;switch(S.type){case"text":{const T=typeof S.text=="string"?S.text:JSON.stringify(S.text??"",null,2);if(e.role==="assistant"){const{cleanedText:_,quickReplies:E}=b_t(T),D=_.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(OG,{text:_,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.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:E.map(({label:M,value:R},A)=>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(R),children:l.jsx("span",{className:"truncate",children:M})})}),l.jsx(m.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:R})})]},`${I}-qr-${A}`))})]})]},I)}return e.role==="system"&&s?l.jsx(C_t,{text:T},I):null}case"error":{const T=S,_=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(eB,{errorMessage:_})},I)}case"reasoning":return null;default:return((k=S.type)!=null&&k.startsWith("tool-")||S.type==="dynamic-tool")&&J4(S,r)?l.jsx(ki,{FallbackComponent:({error:T,resetErrorBoundary:_})=>l.jsx(v_t,{error:T,resetErrorBoundary:_}),children:l.jsx(f_t,{part:S,idx:I,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},I):null}});return e.role==="assistant"?Rxe(e,r)?l.jsxs(Mxe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const k_t=8,__t=24,I_t=20;function T_t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function Axe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,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),w=v.useRef(!1),C=v.useRef(null),N=v.useRef(!1),S=v.useRef(g),[j,I]=v.useState(!0),[k,T]=v.useState(0),[_,E]=v.useState(__t);S.current!==g&&(S.current=g,N.current=!0);const D=e[e.length-1],M=Rxe(D,t),R=T_t(a,c,u,M),A=Iw({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const F=e[W];return(F==null?void 0:F.role)==="user"?88:180},getItemKey:W=>{const F=e[W];return(F==null?void 0:F.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:k_t,overscan:6,gap:20,paddingEnd:R?_+I_t:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const F=W.isAtEnd();I(q=>q===F?q:F),F&&T(0)}}),$=v.useCallback((W="smooth")=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{C.current=null,A.scrollToEnd({behavior:W})}),T(0),I(!0)},[A]);v.useLayoutEffect(()=>{w.current||(w.current=!0,$("auto"))},[$]),v.useLayoutEffect(()=>{N.current&&(N.current=!1,$("auto"))},[e.length,g,$]),v.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!A.isAtEnd()&&T(F=>F+e.length-W),e.length===0&&(T(0),I(!0),w.current=!1,N.current=!1)},[e.length,A]);const O=A.getVirtualItems(),B=A.getTotalSize();return v.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]),v.useLayoutEffect(()=>{const W=x.current;if(!W||!R)return;const F=()=>{const z=Math.ceil(W.getBoundingClientRect().height);z>0&&E(P=>P===z?P:z)};if(F(),typeof ResizeObserver>"u")return;const q=new ResizeObserver(F);return q.observe(W),()=>q.disconnect()},[R,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(yl,{"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:B},children:[O.map(W=>{const F=e[W.index];return F?l.jsx("div",{ref:A.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(j_t,{message:F,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},W.key):null}),R&&l.jsx("div",{ref:x,className:m.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(B-_,0)}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(S_t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!j&&l.jsxs("button",{type:"button",onClick:()=>$("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(rs,{className:"h-3 w-3"}),"Latest",k>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:k>9?"9+":k})]})]})}function E_t(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 D_t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function M_t({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(ut.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[p,g]=v.useState(!1),[b,x]=v.useState(!1),[y,w]=v.useState(0),C=n??b,{isLocalDev:N,isConsoleMode:S}=$m(),j=N||S||a,I=v.useRef(null);m.useDashboardStore(ue=>ue.dashboard.aiScopeTables),m.useDashboardStore(ue=>ue.isDashboardEditing);const k=m.useDashboardStore(ue=>ue.selectedSheetId),{setDataSource:T}=m.useEditorActions(),{setSelectedFrameId:_,setIsDashboardEditing:E}=m.useDashboardActions(),D=lz(),{clearAssistantMessageContexts:M}=m.useAIActions(),{clearQueue:R}=m.useQueueActions(),{clearFileAttachments:A,getFileAttachments:$}=m.useFileActions(),O=m.useFileAttachments("dashboard"),B=m.useEditorStore(ue=>ue.card.dataSource),{assistantProfile:W}=Qbe(),F=m.useDashboardStore(ue=>ue.handleOpenAssistantProfile),{selectedEntities:q,applyDashboardDefaultEntities:z}=fT("dashboard"),{sendMessage:P,isLoading:U,messages:G,setMessages:Q,status:H,stop:L,errorMessage:K,clearError:Y}=Fjt({dynamicVisualMode:f}),V=v.useCallback(()=>{w(ue=>ue+1)},[]),Z=v.useCallback(ue=>{r==null||r(ue),n===void 0&&x(ue)},[n,r]),X=v.useCallback(()=>{Z(!C)},[C,Z]);v.useEffect(()=>{if(!C)return;function ue(ge){ge.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",ue),()=>{window.removeEventListener("keydown",ue)}},[C,Z]);const[te,re]=v.useState(""),ie=ue=>{re(ue.target.value)};async function se({sql:ue,cardTitle:ge,connectionId:_e,cardType:Te,python:Ce,cardConfig:Re,dataSource:Ve,customVisualPreferences:Ee,visualizationMode:We,dynamicCardPreferences:Ie}){if(!k)return;const we=We==="dynamic",de=ut.hasValidCardConfig(Re),Se=_e||(Ve==null?void 0:Ve.connectionId)||"",Le=Ve?{...Ve,connectionId:Se||Ve.connectionId,connectionType:Ve.connectionType||"",mode:Ve.mode||"database",selectedEntities:Ve.selectedEntities||[]}:Se?{connectionId:Se,connectionType:"",mode:"database",selectedEntities:[]}:mb,st=!(de&&(!we||(Ie==null?void 0:Ie.provenance)==="card-config"||(Ie==null?void 0:Ie.provenance)==="query_spec")),$e=st?E_t(ue):"",Ke=st?Ce:"",at={id:ut.v4(),title:ge||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:Te==="horizontalBar"?"y":"x"},...we&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:Te,sql:$e,python:Ke,dataSource:Le,config:Re,connectionId:Se,visualizationMode:We,dynamicCardPreferences:Ie,customCardPreferences:Ee?{url:Ee.url,componentName:Ee.componentName,pluginChartType:Ee.pluginChartType,settings:Ee.settings,type:"component"}:void 0},ct={id:ut.v4(),cards:[at],activeCardId:at.id};try{await D(k,ct,"end"),E(!0),_(ct.id)}catch(rt){console.error("Failed to add assistant visual to dashboard:",rt),et.error(rt instanceof Error?rt.message:"Failed to prepare semantic metadata for the new visual")}}const le=ue=>{ue.preventDefault();const ge=te.trim();if(!ge&&O.length===0)return;const _e=[];ge&&_e.push({type:"text",text:ge}),O.forEach(Te=>{Te.data&&_e.push({type:"file",mediaType:Te.type,filename:Te.name,url:`data:${Te.type};base64,${Te.data}`})}),P({role:"user",parts:_e}),re(""),A("dashboard"),V()};v.useEffect(()=>{var ue;e&&((ue=I.current)==null||ue.focus())},[e]),pxe({assistantType:"dashboard",status:H,isLoading:U,sendMessage:P});const{hasActiveTools:ae,activeToolText:be}=gxe(G);function fe(ue){const ge={role:"user",parts:[{type:"text",text:ue.title+" "+ue.subtitle}]};P(ge),V()}function xe(ue){P({role:"user",parts:[{type:"text",text:ue}]}),V()}function pe(ue){P({role:"user",parts:[{type:"text",text:ue}]}),V()}const ye=v.useCallback(async()=>{const ue=JSON.stringify(G??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ue),et.success("Conversation copied")}catch(ge){console.error("Failed to copy conversation",ge),et.error("Unable to copy conversation")}},[G]),ce=(te==null?void 0:te.length)===0&&(G==null?void 0:G.filter(ue=>ue.role==="user").length)===0;function J(){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 ne(){return l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx(su,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Fm,{className:"size-3.5"})})}),l.jsxs(mo,{align:"end",children:[l.jsx(Ca,{children:"Options"}),l.jsx(Ia,{}),l.jsx(sd,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(sd,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(sd,{checked:u,onCheckedChange:d,children:"System Message"}),(N||S)&&l.jsxs(l.Fragment,{children:[l.jsx(Ia,{}),l.jsx(Ca,{children:"Dynamic Visuals"}),l.jsx(sd,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(sd,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(sd,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ee=l.jsxs("div",{"data-role":"dashboard-assistant",className:m.cn("relative flex h-full grow flex-col break-words bg-background",C&&"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:[J(),F&&l.jsxs("button",{type:"button",onClick:F,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:[S&&ne(),j&&l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:ye,children:"Copy Conversation"}),l.jsx(su,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:C?"Exit fullscreen":"Expand",onClick:X,children:C?l.jsx(Pt.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(su,{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 ue=G.filter(ge=>ge.role==="assistant").map(ge=>ge.id).filter(ge=>!!ge);Q([]),R("dashboard"),Y(),M(ue)},children:l.jsx(LO,{className:"h-3.5 w-3.5"})}),l.jsx(su,{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(Me.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(Axe,{messages:G,showTools:a,showSystemMessage:u,onAddToDashboard:se,onQuickReply:pe,disableQuickReplies:U,status:H,errorMessage:K,activeToolText:U&&ae?be:void 0,className:m.cn(C?"px-6 py-5":"px-3 py-3"),rowContentClassName:m.cn(C&&"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&&ce&&l.jsx(Tge,{onClick:fe,placeholders:D_t}),ce&&W&&l.jsx(Jbe,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:xe}),l.jsx(mxe,{assistantType:"dashboard"}),l.jsx(Q4,{ref:I,setInput:re,stop:L,input:te,handleInputChange:ie,handleSubmit:ue=>{le(ue)},isLoading:U,status:H,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(X4,{incomingSelectedEntities:q,open:p,onOpenChange:g,dataSource:B||mb,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ue=>z()})]});return C&&o?vr.createPortal(l.jsx(tx,{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:ee})}),o):ee}function R_t(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=m.useDashboardActions(),o=tde(),s=m.useDashboardStore(d=>d.dashboard.sheets),a=m.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[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(A_t(p.target))return;const g=p.ctrlKey||p.metaKey;g&&p.key==="c"?(await f(),et.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=F_t(p);if(g!=null&&g.id){const b=Que(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await o(a,b),r(b.id),et.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)},[o,n,r,a,c,u,t])}function A_t(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 F_t(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 P_t(e,t){switch(e.interactionMode){case"drillToDetail":O_t(e,t);break;case"drillThrough":L_t(e,t);break;case"drillToURL":$_t(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 O_t(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function L_t(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.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 $_t(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 z_t({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(No,{open:e,onOpenChange:t,children:l.jsxs(po,{className:"flex max-h-[90vh] max-w-[90vw] flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Es,{className:"space-y-1 border-b border-border px-5 pb-3.5 pt-4 text-left",children:[l.jsx(go,{className:"text-[15px] font-semibold tracking-tight",children:i||"Insight detail"}),l.jsx(Oo,{className:"text-[12px] leading-[1.5] text-muted-foreground",children:a||"View detailed insight data with applied filters"})]}),l.jsx(ade,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] min-h-0 flex-1 overflow-auto px-5 py-4",children:n?l.jsx(bhe,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-[13px] text-muted-foreground",children:"No insight selected"})})]})})}function B_t(){const e=m.useInteractionStore(N=>N.interactionStates),t=m.useInteractionStore(N=>N.setInteractionState),n=m.useInteractionStore(N=>N.clearLastInteractionEvent),r=m.useInteractionStore(N=>N.replaceCardWithInsight),o=m.useInteractionStore(N=>N.setPendingDrillThrough),s=m.useInteractionStore(N=>N.pendingDrillThrough),i=m.useInteractionStore(N=>N.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=m.useDashboardActions(),{selectDashboard:u}=Rm(),d=m.useDashboardStore(N=>N.dashboard),f=m.useDashboardStore(N=>N.filterValues),{data:h,isLoading:p}=XX((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=xhe(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),w=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:N,filters:S,contextMode:j})=>{b({open:!0,insightId:N,filters:S,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:j})},replaceCardContent:({cardId:N,insightId:S,filters:j,contextMode:I})=>{r(N,S,j,I)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:N,contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k})=>{const T={filters:N},_={sourceCardId:m.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},E={...m.createInitialInteractionState(),appliedClickFilters:[_],contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k};t(m.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);v.useEffect(()=>{Object.entries(e).forEach(([N,S])=>{if(S!=null&&S.lastInteractionEvent){const j=S.lastInteractionEvent,I=`${N}-${j.interactionMode}-${j.sourceCardId}-${Date.now()}`;if(y.current.has(I))return;y.current.add(I);try{P_t(j,w)}catch(k){console.error("Error executing interaction event:",k)}finally{n(N),setTimeout(()=>{y.current.delete(I)},5e3)}}})},[e,n,w]),v.useEffect(()=>{if(!(!s||!h||p))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(N){console.error("[DrillThrough] Error during automatic navigation:",N),i()}},[s,h,p,u,c,i]);const C=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(z_t,{open:g.open,onOpenChange:C,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),s&&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 V_t(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=H_t(uz(t));return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function H_t(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function q_t(e){return e?`Back to ${e}`:"Back"}function U_t(){var y,w,C,N,S;const e=m.useInteractionStore(j=>j.interactionStates[m.DRILL_CONTEXT_CARD_ID]),t=m.useDashboardStore(j=>j.actions.goBackFromDrill),n=m.useDashboardStore(j=>j.actions.clearDrillContext),{selectDashboard:r}=Rm(),[o,s]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const j=k=>{s({x:k.clientX-c.current.x,y:k.clientY-c.current.y})},I=()=>{a(!1)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",I),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((N=(C=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:C[0])==null?void 0:N.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||!((S=e.appliedClickFilters)!=null&&S.length))return null;const p=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(j){console.error("[DrillBack] Error during back navigation:",j)}},g=()=>{n()},b=j=>{j.target.closest("button")||(a(!0),c.current={x:j.clientX-o.x,y:j.clientY-o.y})};V_t(f);const x=q_t(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.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((j,I)=>{const k=j.field.label||j.field.name,T=String(j.value);return l.jsxs(xi,{variant:"secondary",className:"pointer-events-none text-xs",children:[k," = ",T]},I)})})]}),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(Me.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(Xv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function W_t(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function K_t({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d}){const{attributes:f,listeners:h,setNodeRef:p,transform:g,transition:b,isDragging:x}=cx({id:`filter:${e.id}`,disabled:n||!t}),y={transform:Xi.Translate.toString(g),transition:b,opacity:x?.5:1,zIndex:x?10:void 0};return l.jsx("div",{ref:p,style:y,...f,children:l.jsx(H$,{filter:e,isEditing:t,dragListeners:t?h:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d})})}const WG="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",G_t=[];function Fxe({open:e,onOpenChange:t}){const[n,r]=v.useState(!1),[o,s]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=m.useDashboardStore(H=>{var L;return(L=H.dashboard)==null?void 0:L.sheets}),u=m.useDashboardStore(H=>H.dashboard),d=m.useDashboardStore(H=>H.dashboardInputValues),f=m.useDashboardStore(H=>H.filterValues),h=m.useDashboardStore(H=>H.controlValues),p=m.useDashboardStore(H=>H.inlineFilterValuesMap),g=m.useDashboardStore(H=>H.cardControlValuesMap),b=m.useDashboardStore(H=>H.selectedSheetId),x=m.useDashboardStore(H=>H.selectedSheetId?H.documentInputRuntimeBySheetId[H.selectedSheetId]:void 0),y=m.useDashboardStore(H=>H.isDownloadingPdf),w=m.useDashboardStore(H=>H.reportContext),{authToken:C,tokenProps:N}=Et(),S=c==null?void 0:c.find(H=>H.id===b),j=v.useMemo(()=>m.getDashboardExportSheets(c),[c]),I=m.isDocumentSheet(S),k=I&&S?S.document:void 0,T=v.useMemo(()=>I&&S?dx(u,S.id):[],[S,I,u]),_=T.length>0,E=v.useMemo(()=>I&&S?rge(u,S.id):!1,[S,I,u]),D=v.useMemo(()=>_?T.map(bC):(k==null?void 0:k.inputs)||G_t,[k,T,_]),M=w==null?void 0:w.calendar.tz,R=v.useMemo(()=>epe(D),[D]),A=v.useMemo(()=>Qme(D,M),[D,M]),$=v.useMemo(()=>Jme(D),[D]),O=x?x.filterValuesByInputId:A,B=v.useMemo(()=>npe(O,D),[D,O]),W=x?x.controlValuesByInputId:$,F=v.useMemo(()=>I?E&&S&&k?tZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(H=>H.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},timezone:M}):ope(D,B,W,R,R):[],[k,D,S,I,u,g,h,f,p,d,W,B,R,M,E]),q=!!S,z=j.length>0,P=((c==null?void 0:c.length)||0)>1||I,U=i.sheetSelection==="current"&&(!q||I&&F.length>0)||i.sheetSelection==="all"&&!z;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!z&&a(H=>({...H,sheetSelection:"current"}))},[z,e,i.sheetSelection]);const G=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function Q(){if(y){et.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){et.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!q){et.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!z){et.error("No dashboard sheets are available to export");return}s(!0);const H=i.sheetSelection==="current"&&I,L=H?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",K=et.loading(L);try{if(H){if(!k||!S)throw new Error("Selected document sheet is missing document data");if(F.length>0){et.dismiss(K),et.error(`Set ${F.join(", ")} before exporting`);return}const V=new Date().toISOString(),Z=E?nZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(X=>X.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},generatedAt:V,timezone:M}).snapshot:void 0;await rL(N.apiServiceUrl,C,{sheetId:S.id,title:S.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:M,password:i.protectPdf?i.password:void 0,inputSnapshot:Z,...Z?{}:{inputValues:{sheetId:S.id,filterValuesByInputId:B,controlValuesByInputId:W,generatedAt:V}}})}else{const V=goe();await ste(N.apiServiceUrl,C,i.protectPdf?i.password:void 0,i.sheetSelection,V)}et.dismiss(K);const Y=H?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!";et.success(Y,{duration:2e3}),G()}catch(Y){et.dismiss(K),et.error("Failed to download PDF",{description:L_(Y,"Please try again or contact support."),descriptionClassName:O_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",Y)}finally{s(!1)}}return l.jsx(No,{open:e,onOpenChange:H=>{if(!H){G();return}t(!0)},children:l.jsxs(po,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Es,{children:[l.jsx(go,{className:"text-[15px]",children:I?"Export document":"Export dashboard"}),l.jsx(Oo,{className:"text-[13px] leading-5",children:I?"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:[P&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(m.Label,{className:WG,children:"Export scope"}),l.jsxs(yu,{value:i.sheetSelection,onValueChange:H=>a({...i,sheetSelection:H}),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",!q&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Xs,{value:"current",id:"scope-current",disabled:!q}),I?"This document":"This sheet"," (",(S==null?void 0:S.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",!z&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Xs,{value:"all",id:"scope-all",disabled:!z}),"Dashboard sheets (",j.length," ",j.length===1?"sheet":"sheets",")"]})]}),I&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:F.length>0?`Set ${F.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(In,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:H=>{a({...i,protectPdf:H,password:H?i.password:""}),H||r(!1)}}),l.jsx(Jv,{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:WG,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:H=>a({...i,password:H.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:H=>{H.key==="Enter"&&i.password&&Q()}}),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(Uk,{className:"h-3.5 w-3.5"}):l.jsx(Pt.Eye,{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(il,{children:[l.jsx(m.Button,{variant:"outline",size:"xs",onClick:G,disabled:o,children:"Cancel"}),l.jsx(m.Button,{size:"xs",onClick:Q,disabled:o||y||U,children:o?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(_u,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function Pxe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=v.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=m.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(_u,{className:m.cn("size-4",e)})}),l.jsx(Fxe,{open:i,onOpenChange:a})]})}function KG(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function Y_t({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=cx({id:`control:${e.id}`,disabled:!n}),d={transform:Xi.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(wpe,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function GG(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function YG(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function Z_t(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 YG(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=YG(t,n).filter(a=>!s.has(a));return[...o,...i]}function X_t(e,t){return m.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function Q_t(e){return m.doesDashboardInputApplyToTarget(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>m.doesDashboardInputApplyToTarget(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function U2(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function J_t(e){return Oxe(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 Oxe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=X_t(e.dashboard,t);return m.removeShadowedCompatibilityInputs(m.buildNormalizedDashboardInputs({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!Q_t({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function eIt(e,t){return"toolbar"}function tIt(){const e=ml("interactive"),t=m.useDashboardStore(V=>V.selectedSheetId),n=m.useDashboardStore(V=>V.dashboard.filters),r=m.useDashboardStore(V=>V.dashboard.filterLayout),o=m.useDashboardStore(V=>V.isDashboardEditing),s=m.useDashboardStore(V=>V.controlValues),i=m.useDashboardStore(V=>V.filterValues);m.useDashboardStore(V=>V.filteringCards);const a=m.useDashboardStore(V=>V.inlineFilterValuesMap),c=m.useDashboardStore(V=>V.dashboardInputValues),u=m.useInteractionStore(V=>V.clearAllClickFilters),d=m.useInteractionStore(V=>Object.entries(V.interactionStates).reduce((Z,[X,te])=>{var re;return X===m.DRILL_CONTEXT_CARD_ID?Z:Z+(((re=te.appliedClickFilters)==null?void 0:re.length)??0)},0)),f=m.useDashboardStore(V=>V.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:p,reorderDashboardControls:g,removeDashboardInput:b,removeFilter:x,setControlValue:y,setFilterLayout:w,setFilterValues:C,setFilteringCards:N,updateFilterDashboardInputDefinition:S}=m.useDashboardActions(),j=gT(db(ax,{activationConstraint:{distance:5}})),I=m.useDashboardStore(V=>V.dashboard),k=J_t({dashboard:I,selectedSheetId:t}).filter(V=>eIt(V.filter)==="toolbar"),T=Oxe({dashboard:I,selectedSheetId:t}),_=k.map(V=>V.filter),E=new Map(k.map(V=>[`filter:${V.filter.id}`,V])),D=ent(I),M=D.filter(V=>!V.hidden&&mv(V)==="toolbar"),R=D.filter(V=>!V.hidden&&mv(V)==="advanced"),A=Z_t(r==null?void 0:r.toolbarItemOrder,_,M),$=new Map(_.map(V=>[`filter:${V.id}`,V])),O=new Map(M.map(V=>[`control:${V.id}`,V]));function B(V){const{active:Z,over:X}=V;if(!X||Z.id===X.id)return;const te=String(Z.id),re=String(X.id),ie=A.findIndex(ye=>ye===te),se=A.findIndex(ye=>ye===re);if(ie===-1||se===-1)return;const le=lx(A,ie,se);w({toolbarItemOrder:le});const ae=new Set((n||[]).map(ye=>ye.id)),be=A.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>ae.has(ye)),fe=le.filter(ye=>ye.startsWith("filter:")).map(ye=>ye.replace("filter:","")).filter(ye=>ae.has(ye)),xe=A.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:","")),pe=le.filter(ye=>ye.startsWith("control:")).map(ye=>ye.replace("control:",""));h(KG(n||[],be,fe)),g(KG(I.controls||[],xe,pe))}const W=(r==null?void 0:r.toolbarWrap)??!1,F=(r==null?void 0:r.showDownloadButton)??!1,q=T.filter(U2),z=T.filter(V=>{if(U2(V))return!1;const Z=m.getDashboardInputRuntimeSlot(c,V,{sheetId:t});return(Z==null?void 0:Z.status)==="set"||(Z==null?void 0:Z.status)==="cleared"}),P=new Set([...q,...z].map(V=>V.filter.id)),U=(i==null?void 0:i.filter(V=>!P.has(V.filterId)&&GG(V)).length)??0,G=[...q,...z],Q=G.filter(V=>{const Z=m.hydrateAuthoredDashboardInputSlot({dashboard:I,input:V,runtimeValues:c,target:{sheetId:t}});return(Z==null?void 0:Z.status)==="set"&&Z.value.kind==="filter"&&GG(Z.value.filterValue)}).length,H=a?Object.values(a).reduce((V,Z)=>V+((Z==null?void 0:Z.length)??0),0):0,L=U+Q+H+d,K=G.some(V=>V.forceSelection),Y=()=>{C([]),G.forEach(V=>{p(V,{sheetId:t})}),N([]),u(),a&&Object.entries(a).forEach(([V,Z])=>{Z==null||Z.forEach(X=>{f(V,X.filterId)})})};return!_.length&&!M.length&&!R.length&&!F&&L===0?null:l.jsx("div",{className:"z-20 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(dC,{sensors:j,collisionDetection:lC,onDragEnd:B,children:l.jsxs("div",{className:m.cn("flex items-center",W?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(fC,{items:A,strategy:Kz,children:l.jsx(qP,{className:"gap-3 pr-0",wrap:W,children:A.map(V=>{const Z=$.get(V);if(Z){const te=E.get(V),re=te&&U2(te),ie=re&&te.definitionOrigin==="dashboardFilter";return l.jsx(K_t,{filter:Z,isEditing:o,storageOptions:re?{storageTarget:"dashboardInput",dashboardInput:te,sheetId:t??void 0}:void 0,inputVariableName:re?te.variableName:void 0,isDashboardFilterReference:ie,onUpdateFilter:re?(se,le)=>{S(te.id,se,le)}:void 0,onRemoveFilter:re?()=>{if(te.definitionOrigin==="dashboardFilter"){x(Z.id);return}C((i||[]).filter(se=>se.filterId!==Z.id)),b(te.id)}:void 0},V)}const X=O.get(V);return X?l.jsx(Y_t,{control:X,value:s==null?void 0:s[X.id],isEditing:o,onChange:te=>y(X.id,te)},V):null})})}),R.length>0&&l.jsx(pde,{title:"",controls:R,values:s,onChange:(V,Z)=>y(V.id,Z),immediatePlacement:"toolbar",advancedLabel:"More controls"}),L>0&&l.jsxs("button",{type:"button",onClick:Y,"aria-label":K?"Reset filters":"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(Me.X,{className:"h-3 w-3"}),K?"Reset filters":"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:L})]}),F&&l.jsx("div",{className:m.cn(L>0?"ml-1.5":"ml-auto"),children:l.jsx(Pxe,{})})]})})})}function Lxe(){var J,ne;const{showAssistant:e,tokenProps:t,renderMode:n}=Et(),r=W_t((J=t.config)==null?void 0:J.showDashboardAssistant,e),{preferences:o}=$m(),s=(ne=o==null?void 0:o.cardDisplay)==null?void 0:ne.mode,i=gf(s),a=dee({displayMode:s,renderMode:n}),c=v.useRef(null),u=v.useRef(null),d=v.useRef(null),[f,h]=v.useState(!1),{handleDragStart:p,isDraggingRef:g,getStyle:b,getPositionClasses:x}=Svt({initialPosition:"bottom-right"}),y=Ah(ee=>ee.setFullscreen),w=Ah(ee=>ee.setPanelOpen),C=Ah(ee=>ee.setContainer),N=eJ("dashboard"),S=tJ(),j=nJ("dashboard"),I=N.isOpen,k=S==="dashboard",T=m.useDashboardStore(ee=>ee.isVisualEditing),_=m.useDashboardStore(ee=>ee.themeStyle),E=Ou(),D=m.useDashboardStore(ee=>{var ue;return(ue=ee.dashboard)==null?void 0:ue.sheets}),M=m.useDashboardStore(ee=>ee.showFilters),R=m.useDashboardStore(ee=>ee.isDashboardEditing),A=m.useDashboardStore(ee=>ee.selectedSheetId),$=D==null?void 0:D.find(ee=>ee.id===A),O=m.useDashboardStore(ee=>{var ue,ge,_e;return(_e=(ge=(ue=ee.dashboard)==null?void 0:ue.sheets)==null?void 0:ge.find(Te=>Te.id===ee.selectedSheetId))==null?void 0:_e.kind}),B=m.useDashboardStore(ee=>{var ue,ge;return((ge=(ue=ee.dashboard)==null?void 0:ue.summary)==null?void 0:ge.position)||"top"}),W=O==="document",F=m.useDashboardStore(ee=>{var ue;return(ue=ee.dashboard)==null?void 0:ue.id}),{getDefaultSheetId:q,setDefaultSheetId:z,clearDefaultSheetId:P}=$Y(F),[U,G]=v.useState(null),{setSelectedSheetId:Q,setSheetTitle:H,addSheet:L,setSheets:K,duplicateSheet:Y}=m.useDashboardActions();R_t(u);const{setActiveAssistantType:V}=m.useAIActions();v.useEffect(()=>{if(F){const ee=q();G(ee)}},[F,q]),v.useEffect(()=>{I?V("dashboard"):S==="dashboard"&&y(null)},[I,V,S,y]),v.useEffect(()=>{var ee;I||(ee=c.current)==null||ee.resize(0)},[I]);function Z(ee){var ue,ge;ee?((ue=c.current)==null||ue.resize(40),w("dashboard",!0),y("dashboard"),V("dashboard")):(w("dashboard",!1),y(null),(ge=c.current)==null||ge.resize(0),V(null))}function X(ee="dashboard"){const ue={id:ut.v4(),title:ee==="document"?"New Document":"New Sheet",...ee==="document"?{kind:ee,document:m.createDefaultDocumentDefinition()}:{}};L(ue),Q(ue.id)}function te(ee){const ue=Y(ee);ue&&(et.success("Sheet duplicated"),requestAnimationFrame(()=>{var _e;const ge=(_e=d.current)==null?void 0:_e.querySelector(`[data-sheet-id="${ue}"]`);ge==null||ge.focus(),ge==null||ge.scrollIntoView({block:"nearest",inline:"nearest"})}))}function re(ee,ue){if(!F)return;U===ee?(P(),G(null),et.success("Default sheet cleared")):(z(ee),G(ee),et.success(`"${ue}" set as default sheet`))}function ie(ee){var ue;ee<1?(w("dashboard",!1),y(null),V(null),(ue=c.current)==null||ue.resize(0)):(I||w("dashboard",!0),V("dashboard"))}function se(){return(_==null?void 0:_.canvasTheme)==="muted"||!(_!=null&&_.canvasTheme)?"hsl(var(--semaphor-muted))":(_==null?void 0:_.canvasTheme)==="clear"?"":_==null?void 0:_.canvasTheme}const le=(ee,ue)=>{ee.dataTransfer.setData("tabIndex",ue.toString())},ae=ee=>{ee.preventDefault()},be=(ee,ue)=>{const ge=ee.dataTransfer.getData("tabIndex");if(ge===ue.toString())return;const _e=Array.from(D||[]),[Te]=_e.splice(parseInt(ge),1);_e.splice(ue,0,Te),K(_e)},fe=r===!0&&!i&&!I&&!T&&!M;function xe(){if(D&&D.length>1||R)return l.jsx("div",{className:"relative flex w-full items-stretch",children: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,{ref:d,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((ee,ue)=>{const ge=A===ee.id,_e=U===ee.id;return l.jsxs("div",{className:"relative flex shrink-0 items-center",children:[l.jsxs(m.TabsTrigger,{"data-sheet-id":ee.id,draggable:!0,onDragStart:Te=>le(Te,ue),onDragOver:ae,onDrop:Te=>be(Te,ue),onClick:()=>Q(ee.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",R&&ge&&"pr-9","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:ee.id,children:[ee.kind==="document"&&l.jsx(ti,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(Kj,{enabled:R&&ge,text:ee.title,onSave:Te=>H(ee.id,Te),children:ee.title},ee.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":_e?"Clear default sheet":"Set as default sheet",title:_e?"Clear default sheet":"Set as default sheet",onClick:Te=>{Te.stopPropagation(),re(ee.id,ee.title||"Sheet")},onKeyDown:Te=>{(Te.key==="Enter"||Te.key===" ")&&(Te.preventDefault(),Te.stopPropagation(),re(ee.id,ee.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",ge||_e?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(VZ,{className:m.cn("h-3 w-3 transition-colors",_e?"fill-current text-amber-500":"text-muted-foreground")})})]}),R&&ge&&l.jsxs(Co,{children:[l.jsx(So,{asChild:!0,children:l.jsx("button",{type:"button","aria-label":`Sheet actions for ${ee.title||"Sheet"}`,className:"absolute right-2 inline-flex h-4 w-4 items-center justify-center rounded-[4px] text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground",children:l.jsx(ei,{className:"h-3 w-3"})})}),l.jsxs(mo,{align:"start",className:"w-44",children:[l.jsxs(mn,{onSelect:()=>te(ee.id),children:[l.jsx(zd,{className:"h-4 w-4"}),"Duplicate sheet"]}),l.jsxs(mn,{disabled:D.length<=1,onSelect:()=>h(!0),children:[l.jsx(_a,{className:"h-4 w-4"}),"Delete sheet"]})]})]})]},ee.id)}),R&&l.jsxs(Co,{children:[l.jsx(So,{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(Mr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(mo,{align:"start",className:"w-48",children:[l.jsxs(mn,{onSelect:()=>X("dashboard"),children:[l.jsx(em,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(mn,{onSelect:()=>X("document"),children:[l.jsx(ti,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function pe(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:D==null?void 0:D.map(ee=>l.jsx(m.TabsContent,{style:{backgroundColor:se(),...E.dashboardCanvasStyle},className:m.cn("mt-0 h-full min-h-0",{}),value:ee.id,children:l.jsx(HK,{sheet:ee})},ee.id))})}function ye(){return l.jsxs(m.Tabs,{"data-role":"dashboard-tabs-container",className:m.cn("relative flex h-full flex-col",_==null?void 0:_.dashboardTabsContainer),onValueChange:ee=>{Q(ee)},value:A||void 0,children:[xe(),B==="top"&&!W&&l.jsx(sP,{}),A&&!W&&l.jsx(tIt,{}),W?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:pe()}):l.jsx(yl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:pe()}),B==="bottom"&&!W&&l.jsx(sP,{}),l.jsx(Nvt,{open:f,setOpen:h})]})}const ce=v.useCallback(ee=>{C("dashboard",ee)},[C]);return D?a&&A&&!W?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',A,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&W&&$?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(HK,{sheet:$})}):l.jsxs(l.Fragment,{children:[l.jsx(B_t,{}),l.jsx(U_t,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Ige,{className:m.cn("flex-1 basis-0 overflow-y-auto transition-opacity",k&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(GP,{children:ye()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(Cvt,{open:I,onTabClick:Z,withHandle:!0,disabled:!I}),l.jsx(GP,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:ie,defaultSize:I?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(M_t,{open:I,setOpen:Z,isFullscreen:k,onFullscreenChange:ee=>y(ee?"dashboard":null),fullscreenContainer:j})})})]})]}),l.jsx("div",{ref:ce,className:m.cn("absolute inset-0",!k&&"pointer-events-none")}),fe&&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||Z(!0)},onMouseDown:p,onTouchStart:p,title:"Open Assistant (drag to move)",children:l.jsx(Fve,{className:"h-5 w-5"})})})]})]}):null}const $xe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:i,className:a,style:c,...u},d)=>l.jsx(ig.InternalAppearanceRuntimeProvider,{appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:l.jsx(tx,{...u,ref:d,className:a,style:c,children:i})}));$xe.displayName="AppearanceProvider";const zxe=v.createContext({openBrandStudioPreview:()=>{}}),nIt=zxe.Provider;function rIt(){return v.useContext(zxe)}function oIt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=ig.normalizeTheme(t),[s,i]=v.useState(()=>sIt(n)||o),a=v.useCallback(u=>{const d=ig.normalizeTheme(u);iIt(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(ig.ThemeProviderContext.Provider,{...r,value:c,children:e})}function sIt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=ig.normalizeTheme(t,"system");return n===t?n:null}catch{return null}}function iIt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const aIt=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function tB({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=Et(),s=Kv(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.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),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,C=Kn({queryKey:WX({resourceType:ho.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>m.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:M=>(M==null?void 0:M.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),v.useEffect(()=>{C.data!==void 0&&y({scopeKey:w,appearance:C.data})},[C.data,w]);const N=(x==null?void 0:x.scopeKey)===w?x.appearance:null,S=i!==void 0?i:C.data!==void 0?C.data:N,j=v.useMemo(()=>Em.resolveAppearance({organizationAppearance:S,tokenAppearance:a,reactAppearance:e}),[e,S,a]),I=v.useCallback(()=>{f(g??h??j),u(!0)},[g,h,j]),k=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),p(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:I}),[I]),_=g??h??e;return l.jsx(oIt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(nIt,{value:T,children:l.jsx($xe,{organizationAppearance:S,tokenAppearance:a,reactAppearance:_,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(aIt,{appearance:d,onDraftChange:b,onSave:M=>{p(M),b(M),f(M)},onCancel:k})})})]})})})})}function Bxe({children:e,preferences:t}){const{currentUser:n}=si(),r=v.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(HX.Provider,{value:r,children:l.jsx(tT,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function lIt(e=2e3,t=500){const n=M0e(),[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>o(!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]),s}function nB({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=lIt(e,t);return v.useEffect(()=>(o&&(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()}}),[o,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:o?"ready":""})}function Vxe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(ki,{FallbackComponent:JI,children:l.jsx(wO,{dashboardProps:e,children:l.jsxs(dT,{children:[l.jsx(nB,{componentType:"dashboard",componentId:e.id}),l.jsx(tB,{appearance:e.appearance,children:l.jsx(Bxe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(i5,{...e,type:"dashboard",children:l.jsx(Lxe,{})})})})})]})})})}function cIt(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[o,s]=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);s(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:o,updateAvailableWidth:i}}function uIt({filter:e}){var g;const t=m.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=$m(),r=gf((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=m.useDashboardStore(b=>b.filterValues),s=o==null?void 0:o.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=m.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:p}=cIt([t,s,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(Ci,{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(V$,{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(Me.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function dIt(){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(uIt,{filter:r}),l.jsx(GI,{filter:r})]},r.id))}):null}function fIt(){var s;const e=m.useDashboardStore(i=>i.dashboard),t=m.useDashboardStore(i=>i.selectedSheetId),n=m.useDashboardStore(i=>i.isDashboardEditing),r=(s=e.sheets)==null?void 0:s.find(i=>i.id===t),o=m.isDocumentSheet(r);return l.jsx("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[n&&!o&&l.jsx(dIt,{}),l.jsx(Lxe,{})]})})}const hIt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-CSEDFI2k.cjs"))),mIt=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-DXTMYEBO.cjs"))),pIt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-uLgspKtl.cjs")));function gIt({showControls:e=!1,showFooter:t=!0,...n}){const r=m.useDashboardStore(a=>a.isVisualEditing),o=m.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(ki,{FallbackComponent:JI,children:l.jsx(wO,{dashboardProps:n,children:l.jsxs(dT,{children:[l.jsx(nB,{componentType:"surfboard",componentId:n.id}),l.jsxs(tB,{appearance:s,children:[l.jsx(BCe,{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(Bxe,{preferences:i,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(pIt,{})}),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(hIt,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(i5,{...n,type:"dashboard",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(mIt,{})}),l.jsx(v.Activity,{mode:r?"hidden":"visible",children:l.jsx(fIt,{})})]})})})]})]})]})]})})})}const lO=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],Hxe=new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),bIt=Bi.getSupportedCurrencyCodes(),xIt=bIt.filter(e=>!Hxe.has(e)),qxe=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],ZG="2026-07-31",W2="2026-07-31T14:30:45";function cO(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level"}}function K2(e){var t;return((t=qxe.find(n=>n.value===e))==null?void 0:t.label)??e}function yIt(e){const t=lO.find(n=>n.value===e);return t?`${t.label} — ${t.value}`:e}function G2(e){return{short:e("short"),medium:e("medium"),long:e("long")}}function Y2({id:e,label:t,value:n,inherited:r,inheritedSource:o,examples:s,disabled:i,onValueChange:a}){const c=n===void 0?`Inherited · ${K2(r)}`:K2(n);return l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),l.jsxs(m.Select,{value:n??"inherit",disabled:i,onValueChange:a,children:[l.jsx(m.SelectTrigger,{id:e,size:"xs",children:l.jsx(m.SelectValue,{children:c})}),l.jsxs(m.SelectContent,{children:[l.jsx(m.SelectItem,{value:"inherit",className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsxs("span",{children:["Inherited from ",cO(o)," ·"," ",K2(r)]}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[r]})]})}),qxe.map(u=>l.jsx(m.SelectItem,{value:u.value,className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsx("span",{children:u.label}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[u.value]})]})},u.value))]})]})]})}function vIt({value:e,inherited:t,inheritedSources:n,onChange:r,disabled:o}){var j,I,k,T;const s=v.useId(),i=v.useId(),a=v.useId(),c=v.useId(),u=v.useId(),f=(e.locale===void 0?void 0:Bi.canonicalizeSupportedLocale(e.locale))??t.locale,h=e.defaultCurrency??t.defaultCurrency,p={locale:f,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((j=e.dateTime)==null?void 0:j.dateStyle)??t.dateTime.dateStyle,timeStyle:((I=e.dateTime)==null?void 0:I.timeStyle)??t.dateTime.timeStyle},defaultCurrency:h},g=new Intl.NumberFormat(f,{style:"currency",currency:h}).format(1e3),b=$t.resolveRawTemporalFormat({preferences:p,calendar:{tz:"UTC"}}),x=$t.formatRawTemporalValue({value:ZG,metadata:{kind:"raw_temporal",valueKind:"date"},format:b}).text,y=$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:b}).text,w=G2(_=>$t.formatRawTemporalValue({value:ZG,metadata:{kind:"raw_temporal",valueKind:"date"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateStyle:_},calendar:{tz:"UTC"}})}).text),C=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateTime:{...p.dateTime,dateStyle:_}},calendar:{tz:"UTC"}})}).text),N=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...p,dateTime:{...p.dateTime,timeStyle:_}},calendar:{tz:"UTC"}})}).text),S=(_,E)=>{const D={...e.dateTime,[_]:E==="inherit"?void 0:E};r({...e,dateTime:D.dateStyle===void 0&&D.timeStyle===void 0?void 0:D})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:s,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),l.jsxs(m.Select,{value:e.locale??"inherit",disabled:o,onValueChange:_=>r({...e,locale:_==="inherit"?void 0:_}),children:[l.jsx(m.SelectTrigger,{id:s,size:"xs",children:l.jsx(m.SelectValue,{children:e.locale===void 0?`Inherited · ${t.locale}`:yIt(e.locale)})}),l.jsxs(m.SelectContent,{children:[l.jsxs(m.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.locale)," ·"," ",t.locale]}),e.locale&&!lO.some(_=>_.value===e.locale)&&l.jsx(m.SelectItem,{value:e.locale,children:e.locale}),lO.map(_=>l.jsxs(m.SelectItem,{value:_.value,children:[_.label," — ",_.value]},_.value))]})]})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),l.jsx(Y2,{id:a,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:n.dateStyle,examples:w,disabled:o,onValueChange:_=>r({...e,dateStyle:_==="inherit"?void 0:_})})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),l.jsx(Y2,{id:c,label:"Date",value:(k=e.dateTime)==null?void 0:k.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:n.dateTime.dateStyle,examples:C,disabled:o,onValueChange:_=>S("dateStyle",_)}),l.jsx(Y2,{id:u,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:n.dateTime.timeStyle,examples:N,disabled:o,onValueChange:_=>S("timeStyle",_)})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(m.Label,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),l.jsxs(m.Select,{value:e.defaultCurrency??"inherit",disabled:o,onValueChange:_=>r({...e,defaultCurrency:_==="inherit"?void 0:_}),children:[l.jsx(m.SelectTrigger,{id:i,size:"xs",children:l.jsx(m.SelectValue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),l.jsxs(m.SelectContent,{children:[l.jsxs(m.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...Hxe].map(_=>l.jsx(m.SelectItem,{value:_,children:_},_)),xIt.map(_=>l.jsx(m.SelectItem,{value:_,children:_},_))]})]})]}),l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),l.jsxs("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:x})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date & time"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:y})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Currency"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:g})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]})}const uO=new Set;function Uxe(e){return uO.add(e),()=>{uO.delete(e)}}function rB(){uO.forEach(e=>{e()})}var wIt=Object.defineProperty,CIt=(e,t,n)=>t in e?wIt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y1=(e,t,n)=>CIt(e,typeof t!="symbol"?t+"":t,n);const SIt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},NIt={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}},jIt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function kIt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function Wxe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const _It={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=Wxe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},IIt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},TIt={stringify:e=>e,parse:e=>e},Z2={string:TIt,number:IIt,boolean:SIt,function:NIt,method:_It,json:jIt},sy=Symbol.for("r2wc.render"),v1=Symbol.for("r2wc.connected"),Kf=Symbol.for("r2wc.context"),Di=Symbol.for("r2wc.props");function EIt(e,t,n){var r,o,s;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=kIt(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(),y1(this,s,!0),y1(this,o),y1(this,r,{}),y1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Di].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],w=y?Z2[y]:null;if(y==="method"){const C=Wxe(b);Object.defineProperty(this[Di].container,C,{enumerable:!0,configurable:!0,get(){return this[Di][C]},set(N){this[Di][C]=N,this[sy]()}}),this[Di][g]=w.parse(x,b,this)}w!=null&&w.parse&&x&&(this[Di][g]=w.parse(x,b,this))}for(const g of a)this[Di][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[v1]=!0,this[sy]()}disconnectedCallback(){this[v1]=!1,this[Kf]&&n.unmount(this[Kf]),delete this[Kf]}attributeChangedCallback(g,b,x){const y=f[g],w=c[y],C=w?Z2[w]:null;y in c&&C!=null&&C.parse&&x&&(this[Di][y]=C.parse(x,g,this),this[sy]())}[(s=v1,o=Kf,r=Di,sy)](){this[v1]&&(this[Kf]?n.update(this[Kf],this[Di]):this[Kf]=n.mount(this.container,e,this[Di]))}}for(const p of i){const g=d[p],b=c[p];Object.defineProperty(h.prototype,p,{enumerable:!0,configurable:!0,get(){return this[Di][p]},set(x){this[Di][p]=x;const y=b?Z2[b]:null;if(y!=null&&y.stringify){const w=y.stringify(x,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[sy]()}})}return h}function DIt(e,t,n){const r=xye.createRoot(e),o=v.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function MIt({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function RIt({root:e}){e.unmount()}function AIt(e,t={}){return EIt(e,t,{mount:DIt,update:MIt,unmount:RIt})}const FIt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",interactionExecutionSnapshot:"json",presentationExecutionSnapshot:"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"},PIt=AIt(Vxe,{props:FIt}),OIt=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(g4,{context:t})," "]})});var Kxe="Toggle",Gxe=oe.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[i,a]=m.useControllableState({prop:n,onChange:o,defaultProp:r??!1,caller:Kxe});return l.jsx(m.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:m.composeEventHandlers(e.onClick,()=>{e.disabled||a(!i)})})});Gxe.displayName=Kxe;var Yxe=Gxe;const LIt=m.cva("inline-flex items-center justify-center rounded-control text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Zxe=oe.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(Yxe,{ref:o,className:m.cn(LIt({variant:t,size:n,className:e})),...r}));Zxe.displayName=Yxe.displayName;function oB(){var c,u;const e=m.useEditorStore(d=>d.card),t=m.useEditorStore(d=>d.frame),n=v.useMemo(()=>tt.findCustomVisualConfigCard(t,e),[t,e]),{manifest:r}=kf(((c=n==null?void 0:n.customCardPreferences)==null?void 0:c.url)||""),o=v.useMemo(()=>{var d;return(d=r==null?void 0:r.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=n==null?void 0:n.customCardPreferences)==null?void 0:h.componentName)})},[r,(u=n==null?void 0:n.customCardPreferences)==null?void 0:u.componentName]),s=tt.resolveMultiInputType(n,o),i=v.useMemo(()=>tt.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:s==="multiple"}),[t,n,s]),a=v.useMemo(()=>{const d=i.findIndex(f=>(f==null?void 0:f.id)===e.id);return d<0?-1:tt.getSlotIndexForCard(e,d)},[i,e]);return v.useMemo(()=>!n||s!=="multiple"||a<0?e.type:tt.getEffectiveCardTypeForSlot(e,a,o==null?void 0:o.slots)??e.type,[n,s,a,e,o==null?void 0:o.slots])}function Xxe({storeValue:e,defaultValue:t="",onStoreUpdate:n,delay:r=300}){const[o,s]=v.useState(e??t),i=v.useRef(null),a=v.useRef(o),c=v.useRef(e),u=v.useRef(!1),d=v.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null),u.current&&a.current!==(c.current??t)&&(n(a.current),c.current=a.current)},[t,n]);v.useEffect(()=>{if(e!==c.current){i.current&&(clearTimeout(i.current),i.current=null);const h=e??t;s(h),a.current=h,c.current=e,u.current=!1}},[e,t]),v.useEffect(()=>{if(u.current)return i.current=setTimeout(()=>{d()},r),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[r,d,o]),v.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const f=v.useCallback(h=>{const p=h??t;u.current=!0,a.current=p,s(p)},[t]);return{value:o,onChange:f,flush:d}}const $It=300;function zIt({onExpand:e},t){const n=m.useEditorStore(C=>C.card.sql),r=m.useEditorStore(C=>C.sqlGen),o=m.useEditorStore(C=>C.card),s=oB(),{setCardSql:i,setSqlGen:a,setRunSql:c}=m.useEditorActions(),u=v.useMemo(()=>s!==o.type?{...o,type:s}:o,[o,s]),{queryKey:d}=Cb(u),f=Br(),h=v.useRef(d);h.current=d;const p=v.useRef(r);p.current=r;const g=v.useCallback(C=>{i(C)},[i]),{value:b,onChange:x,flush:y}=Xxe({storeValue:n,defaultValue:"",onStoreUpdate:g,delay:$It});v.useEffect(()=>Uxe(y),[y]);function w(C){x(C),m.isObjectEmpty(p.current)||a({})}return l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx(m.CodeEditor,{ref:t,value:b??"",onValueChange:w,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,wrapLines:!0,placeholder:"Write your SQL here",onKeyDown:C=>{C.key==="Enter"&&C.shiftKey&&(C.preventDefault(),rB(),setTimeout(()=>{f.removeQueries({queryKey:h.current,exact:!0}),c(!0)},0))}}),e?l.jsx(m.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-2.5 top-2 z-20 h-7 w-7 bg-background/80 p-0 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:text-foreground",onClick:e,"aria-label":"Expand SQL editor",title:"Expand SQL editor",children:l.jsx(Pt.Maximize2,{className:"h-3.5 w-3.5",strokeWidth:1.75})}):null]})}const BIt=v.forwardRef(zIt),VIt=300;function HIt(e,t){const n=m.useEditorStore(g=>g.card.python),r=m.useEditorStore(g=>g.card),o=oB(),{setCardPython:s,setRunSql:i}=m.useEditorActions(),a=v.useMemo(()=>o!==r.type?{...r,type:o}:r,[r,o]),{queryKey:c}=Cb(a),u=Br(),d=v.useRef(c);d.current=c;const{value:f,onChange:h,flush:p}=Xxe({storeValue:n,defaultValue:tt.PYTHON_DEFAULT_CODE,onStoreUpdate:s,delay:VIt});return v.useEffect(()=>Uxe(p),[p]),l.jsx(m.CodeEditor,{ref:t,value:f??"",onValueChange:h,language:"python",embedded:!0,hideLineNumbers:!0,wrapLines:!0,className:"[&_.code-editor-pre]:!pt-2 [&_.code-editor-textarea]:!pt-2",onKeyDown:g=>{g.key==="Enter"&&g.shiftKey&&(g.preventDefault(),rB(),setTimeout(()=>{u.removeQueries({queryKey:d.current,exact:!0}),i(!0)},0))}})}const qIt=v.forwardRef(HIt),Qxe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),UIt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),WIt=Array.from(Qxe).join(", "),KIt=3,GIt="Self-heal",YIt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function ZIt({card:e}){var z,P,U,G,Q;const t=xl(),[n,r]=v.useState({}),{authToken:o}=Et(),s=m.getTokenParams(o==null?void 0:o.accessToken),{compiledAppearance:i}=oi.useAppearance(),a=v.useMemo(()=>Ww(i),[i]),c=m.useEditorStore(H=>H.frame),u=m.useEditorStore(H=>H.inlineFilterValuesMap[e.id]),d=m.useEditorStore(H=>H.actions.setCardInlineFilterValue),f=m.useEditorStore(H=>H.actions.removeCardInlineFilterValue),h=e,{getCard:p,manifest:g}=kf(((z=h.customCardPreferences)==null?void 0:z.url)||""),b=(P=g==null?void 0:g.visuals)==null?void 0:P.find(H=>{var L;return H.name===((L=h.customCardPreferences)==null?void 0:L.componentName)}),x=tt.resolveMultiInputType(h,b)??"single",y=v.useMemo(()=>tt.getCustomVisualInputCards({frame:c,configCard:h,isMultiInputVisual:x==="multiple"}),[c,h,x]),w=v.useMemo(()=>{const H=y.findIndex(L=>(L==null?void 0:L.id)===e.id);return H<0?-1:tt.getSlotIndexForCard(e,H)},[y,e]),C=v.useMemo(()=>x!=="multiple"||w<0?e.type:tt.getEffectiveCardTypeForSlot(e,w,b==null?void 0:b.slots)??e.type,[x,w,e,b==null?void 0:b.slots]),N=v.useMemo(()=>x==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:C!==e.type?{...e,type:C}:e,[e,C,x]),{data:S,effectiveCardConfig:j}=Cb(N),I=m.useInteractionStore(H=>H.interactionStates),k=m.useDashboardStore(H=>{var L;return(L=H.dashboard)==null?void 0:L.id}),T=m.useDashboardStore(H=>H.dashboard.filters),_=m.useDashboardStore(H=>H.filterValues),E=m.useDashboardStore(H=>H.selectedSheetId),D=v.useMemo(()=>q$({card:e,sheetId:E||"",inlineFilterValues:u,setInlineFilterValue:H=>d(e.id,H),removeInlineFilterValue:H=>f(e.id,H)}),[e,E,u,d,f]),{cardFilters:M,cardFilterValues:R}=v.useMemo(()=>v_({card:e,interactionStates:I,currentDashboardId:k,filters:T,filterValues:_,selectedSheetId:E}),[e,I,k,T,_,E]),A=v.useCallback((H,L)=>{const K=tt.normalizeMultiInputPayload(L);r(Y=>({...Y,[H]:K}))},[]),$=(U=h.customCardPreferences)==null?void 0:U.componentName,O=$?p($):null,B=Uj((G=h.customCardPreferences)==null?void 0:G.settings,h),W=v.useMemo(()=>tt.buildSlotOrderedCards(y),[y]),F=v.useMemo(()=>W.map((H,L)=>tt.getEffectiveCardTypeForSlot(H,L,b==null?void 0:b.slots)),[W,b==null?void 0:b.slots]),q=v.useMemo(()=>K$(x==="multiple"?W$({slotOrderedCards:W,multiInputData:n,valueFormatPreferences:t}):[{card:e,cardConfig:j,columns:S==null?void 0:S.columns,columnKeyMap:S==null?void 0:S.columnKeyMap,valueFormatPreferences:t}]),[e,S==null?void 0:S.columnKeyMap,S==null?void 0:S.columns,j,n,W,x,t]);return $?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:[O&&x==="single"&&l.jsx(O,{editing:!0,params:s,theme:a,settings:B,cardMetadata:Due({card:e,dataMetadata:S==null?void 0:S.metadata}),onDataChange:A,data:(S==null?void 0:S.records)||[],columns:(S==null?void 0:S.columns)||[],formatTemporalBucketValue:q,filters:M,filterValues:[...R||[],...u||[]],inlineFilters:D}),O&&x==="multiple"&&l.jsxs(l.Fragment,{children:[y.map((H,L)=>{if(!H)return null;const K=tt.getSlotIndexForCard(H,L),Y=tt.getEffectiveCardTypeForSlot(H,K,b==null?void 0:b.slots);return l.jsx(p$,{onDataChange:A,card:H,effectiveCardType:Y},`${H.id}-${K}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(O,{editing:!0,onDataChange:A,...U$({configCard:h,slotOrderedCards:W,slotTypes:F,multiInputData:n,params:s,theme:a,chartSettings:B,filters:M,filterValues:[...R||[],...u||[]],inlineFilters:D,formatTemporalBucketValue:q})})})]})]},(Q=h.customCardPreferences)==null?void 0:Q.componentName)}):null}const XIt=v.memo(ZIt),QIt=m.create()(m.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var Jxe=["PageUp","PageDown"],eye=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],tye={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},px="Slider",[dO,JIt,eTt]=m.createCollection(px),[nye]=m.createContextScope(px,[eTt]),[tTt,ZT]=nye(px),rye=oe.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=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=oe.useRef(new Set),y=oe.useRef(0),C=i==="horizontal"?nTt:rTt,[N=[],S]=m.useControllableState({prop:d,defaultProp:u,onChange:E=>{var M;(M=[...x.current][y.current])==null||M.focus(),f(E)}}),j=oe.useRef(N);function I(E){const D=lTt(N,E);_(E,D)}function k(E){_(E,y.current)}function T(){const E=j.current[y.current];N[y.current]!==E&&h(N)}function _(E,D,{commit:M}={commit:!1}){const R=fTt(s),A=hTt(Math.round((E-r)/s)*s+r,R),$=m.clamp(A,[r,o]);S((O=[])=>{const B=iTt(O,$,D);if(dTt(B,c*s)){y.current=B.indexOf($);const W=String(B)!==String(O);return W&&M&&h(B),W?B:O}else return O})}return l.jsx(tTt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:x.current,values:N,orientation:i,form:g,children:l.jsx(dO.Provider,{scope:e.__scopeSlider,children:l.jsx(dO.Slot,{scope:e.__scopeSlider,children:l.jsx(C,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:m.composeEventHandlers(b.onPointerDown,()=>{a||(j.current=N)}),min:r,max:o,inverted:p,onSlideStart:a?void 0:I,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&_(r,0,{commit:!0}),onEndKeyDown:()=>!a&&_(o,N.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const A=Jxe.includes(E.key)||E.shiftKey&&eye.includes(E.key)?10:1,$=y.current,O=N[$],B=s*A*D;_(O+B,$,{commit:!0})}}})})})})});rye.displayName=px;var[oye,sye]=nye(px,{startEdge:"left",endEdge:"right",size:"width",direction:1}),nTt=oe.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=oe.useState(null),p=m.useComposedRefs(t,C=>h(C)),g=oe.useRef(void 0),b=m.useDirection(o),x=b==="ltr",y=x&&!s||!x&&s;function w(C){const N=g.current||f.getBoundingClientRect(),S=[0,N.width],I=sB(S,y?[n,r]:[r,n]);return g.current=N,I(C-N.left)}return l.jsx(oye,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(iye,{dir:b,"data-orientation":"horizontal",...d,ref:p,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const N=w(C.clientX);i==null||i(N)},onSlideMove:C=>{const N=w(C.clientX);a==null||a(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:C=>{const S=tye[y?"from-left":"from-right"].includes(C.key);u==null||u({event:C,direction:S?-1:1})}})})}),rTt=oe.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=oe.useRef(null),f=m.useComposedRefs(t,d),h=oe.useRef(void 0),p=!o;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],C=sB(y,p?[r,n]:[n,r]);return h.current=x,C(b-x.top)}return l.jsx(oye,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:l.jsx(iye,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);s==null||s(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=tye[p?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),iye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=ZT(px,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()):Jxe.concat(eye).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)&&o(f)}),onPointerUp:m.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),aye="SliderTrack",lye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=ZT(aye,n);return l.jsx(m.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});lye.displayName=aye;var fO="SliderRange",cye=oe.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=ZT(fO,n),s=sye(fO,n),i=oe.useRef(null),a=m.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>fye(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(m.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});cye.displayName=fO;var hO="SliderThumb",uye=oe.forwardRef((e,t)=>{const n=JIt(e.__scopeSlider),[r,o]=oe.useState(null),s=m.useComposedRefs(t,a=>o(a)),i=oe.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(oTt,{...e,ref:s,index:i})}),oTt=oe.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=ZT(hO,n),a=sye(hO,n),[c,u]=oe.useState(null),d=m.useComposedRefs(t,w=>u(w)),f=c?i.form||!!c.closest("form"):!0,h=m.useSize(c),p=i.values[r],g=p===void 0?0:fye(p,i.min,i.max),b=aTt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?cTt(x,g,a.direction):0;return oe.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(dO.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,...s,ref:d,style:p===void 0?{display:"none"}:e.style,onFocus:m.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(dye,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},r)]})});uye.displayName=hO;var sTt="RadioBubbleInput",dye=oe.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=oe.useRef(null),s=m.useComposedRefs(o,r),i=m.usePrevious(t);return oe.useEffect(()=>{const a=o.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:s,defaultValue:t})});dye.displayName=sTt;function iTt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function fye(e,t,n){const s=100/(n-t)*(e-t);return m.clamp(s,[0,100])}function aTt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function lTt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function cTt(e,t,n){const r=e/2,s=sB([0,50],[0,r]);return(r-s(t)*n)*n}function uTt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function dTt(e,t){if(t>0){const n=uTt(e);return Math.min(...n)>=t}return!0}function sB(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 fTt(e){return(String(e).split(".")[1]||"").length}function hTt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var hye=rye,mTt=lye,pTt=cye,gTt=uye;const mye=oe.forwardRef(({className:e,...t},n)=>l.jsxs(hye,{ref:n,className:m.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(mTt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(pTt,{className:"absolute h-full bg-primary"})}),l.jsx(gTt,{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"})]}));mye.displayName=hye.displayName;exports.Accordion=a4;exports.AccordionContent=kv;exports.AccordionItem=Nv;exports.AccordionTrigger=jv;exports.AddDataPicker=X4;exports.AggregateTable=NI;exports.Alert=lL;exports.AlertDescription=cL;exports.AlertDialog=mf;exports.AlertDialogAction=Fu;exports.AlertDialogCancel=Pu;exports.AlertDialogContent=Eu;exports.AlertDialogDescription=Au;exports.AlertDialogFooter=Mu;exports.AlertDialogHeader=Du;exports.AlertDialogTitle=Ru;exports.AlertDialogTrigger=a1e;exports.AlertTitle=Ite;exports.ArrowDown=rs;exports.ArrowDownIcon=HQe;exports.ArrowLeft=Xv;exports.ArrowRight=Qv;exports.ArrowUp=vs;exports.ArrowUpIcon=UQe;exports.AssistantContextEntityControls=iO;exports.AssistantVirtualizedMessages=Axe;exports.AxisConfigurator=Km;exports.BackgroundRunPill=wut;exports.Badge=xi;exports.Bell=N1;exports.BookType=uZ;exports.BriefingAuthor=dhe;exports.BriefingAuthorDialog=fhe;exports.BriefingUiCapabilitiesBoundary=Hut;exports.BriefingUiCapabilitiesProvider=dT;exports.BriefingsApiError=eC;exports.BulletChartIcon=kxe;exports.CSS=Xi;exports.CalculatedFieldEditor=Vme;exports.Calculator=fZ;exports.Calendar=Ka;exports.CalendarClock=EO;exports.Card=SN;exports.CardContent=TO;exports.CardHeader=IO;exports.CardSummary=fP;exports.CardTitle=gb;exports.ChartArea=SR;exports.ChartColumnIncreasing=mZ;exports.ChartColumnStacked=pZ;exports.ChartJsVisual=Bw;exports.ChartLine=gZ;exports.ChartNoAxesGantt=xZ;exports.ChartPie=yZ;exports.ChartScatter=vZ;exports.ChatInputWithContext=Q4;exports.Checkbox=In;exports.ChevronLeft=Am;exports.ChevronsUpDown=SZ;exports.Circle=DO;exports.CircleAlert=ja;exports.CircleCheck=NZ;exports.CircleHelp=jZ;exports.Clock=kZ;exports.CodeHighlighter=$d;exports.CodeXml=j1;exports.Collapsible=Nu;exports.CollapsibleContent=ku;exports.CollapsibleTrigger=ju;exports.ColorField=ha;exports.Command=wT;exports.CommandEmpty=ST;exports.CommandGroup=NT;exports.CommandInput=Xz;exports.CommandItem=jT;exports.CommandList=CT;exports.CommandSeparator=ame;exports.ComparisonMetadataBadge=Xoe;exports.Container=i5;exports.ControlDefaultValueEditor=fpe;exports.ControlDefinitionOptionsEditor=dpe;exports.ControlIdInput=ape;exports.ControlVisibilitySettings=abt;exports.Copy=zd;exports.CopyButton=Ld;exports.CopyPlus=NR;exports.Cross2Icon=YQe;exports.CustomFilterPopover=V$;exports.CustomScrollArea=yl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=Kre;exports.Dashboard=Vxe;exports.DashboardCard=ghe;exports.DashboardCreateDialogBase=yQ;exports.DashboardExportDialog=Fxe;exports.DashboardPlus=gIt;exports.DashboardWC=PIt;exports.DataTableConditionalFormattingSettings=tge;exports.DataTablePagination=pI;exports.Database=Go;exports.DateRangePicker=L$;exports.DefaultChatTransport=B4;exports.Dialog=No;exports.DialogContent=po;exports.DialogDescription=Oo;exports.DialogFooter=il;exports.DialogHeader=Es;exports.DialogTitle=go;exports.DialogTrigger=gQ;exports.DisplayFormatPreferencesFields=vIt;exports.DisplayPreferencesProvider=tT;exports.DndContext=dC;exports.Donut=_Z;exports.Download=_u;exports.DownloadPdf=Pxe;exports.DragOverlay=Khe;exports.DropdownMenu=Co;exports.DropdownMenuCheckboxItem=sd;exports.DropdownMenuContent=mo;exports.DropdownMenuItem=mn;exports.DropdownMenuLabel=Ca;exports.DropdownMenuRadioGroup=mCe;exports.DropdownMenuRadioItem=VX;exports.DropdownMenuSeparator=Ia;exports.DropdownMenuSub=XO;exports.DropdownMenuSubContent=Zk;exports.DropdownMenuSubTrigger=Yk;exports.DropdownMenuTrigger=So;exports.EMPTY_DATA_SOURCE=mb;exports.Editable=Kj;exports.EditableText=Ci;exports.EditorCustomVisual=XIt;exports.Ellipsis=ei;exports.EllipsisVertical=Fm;exports.ErrorBoundary=ki;exports.ExportError=Rb;exports.ExternalLink=Bd;exports.EyeOff=Uk;exports.Fallback=JI;exports.FallbackVisual=Xw;exports.FeedbackCategory=df;exports.FeedbackDialog=Pv;exports.FieldsList=g4;exports.FieldsSection=OIt;exports.FileCode=IZ;exports.FileText=ti;exports.Filter=Vd;exports.FilterComponent=GI;exports.FilterInfo=lP;exports.FilterableFieldsPanel=qme;exports.Grid3x3=jR;exports.GripVertical=Iu;exports.HEATMAP_PRESET_PALETTES=$A;exports.Hash=bb;exports.House=TZ;exports.HoverCard=Qm;exports.HoverCardContent=wu;exports.HoverCardTrigger=Qd;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=Qxe;exports.INLINE_ALLOWED_TOOL_LIST=WIt;exports.INLINE_BLOCKED_MUTATING_TOOLS=UIt;exports.IconButton=su;exports.IconForFieldType=cN;exports.Inbox=RO;exports.InfoHover=cz;exports.InlineFilterBar=lde;exports.KPICard=of;exports.KeyboardSensor=cC;exports.Layers=Om;exports.Link=AO;exports.LoadingDots=uc;exports.MAX_SELF_HEAL_ATTEMPTS=KIt;exports.Map=RZ;exports.Markdown=Rz;exports.MatrixTableVisual=SI;exports.MdStackedLineChart=Nxe;exports.MultiInputEmptyRenderer=p$;exports.PanelResizeHandle=VT;exports.Pause=AZ;exports.PenLine=IR;exports.Pencil=TR;exports.PendingMessagesDisplay=mxe;exports.PersistedDynamicVisual=eT;exports.PiChartPolar=vxe;exports.Pin=PZ;exports.PinOff=FZ;exports.PivotTableTanstack=ex;exports.Placeholders=Tge;exports.Play=OZ;exports.Plus=Mr;exports.PointerSensor=ax;exports.Progress=K4;exports.PythonEditor=qIt;exports.RECOVERABLE_SQL_ERROR_CODES=YIt;exports.Radar=LZ;exports.RadioGroup=yu;exports.RadioGroupItem=Xs;exports.RefreshCw=ka;exports.ResizableHandle=wvt;exports.ResizablePanel=GP;exports.ResizablePanelGroup=Ige;exports.ResourceEditDialog=ZQ;exports.ResourceType=ho;exports.Rows3=$Z;exports.RunCompletionBanner=Cut;exports.SELF_HEAL_TIMELINE_STEP=GIt;exports.SeedQuestions=Jbe;exports.SemaphorContext=Wv;exports.SemaphorContextProvider=wO;exports.SemaphorQueryClient=LY;exports.SemaphorReadyIndicator=nB;exports.SemaphorStyleWrapper=tx;exports.Send=PO;exports.SendHorizontal=zZ;exports.Settings=OO;exports.Settings2=ff;exports.Share2=BZ;exports.ShareDialog=YQ;exports.Sheet=p3;exports.SheetContent=gI;exports.SheetDescription=xI;exports.SheetHeader=Boe;exports.SheetTitle=bI;exports.SheetTrigger=g4e;exports.Slider=mye;exports.SortableContext=fC;exports.Sparkles=k0;exports.SqlEditor=BIt;exports.Square=$O;exports.SquarePen=LO;exports.Star=VZ;exports.StructuralParticipantSelector=lpe;exports.SummaryCard=sP;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Pd;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=ga;exports.TableBody=Xd;exports.TableCell=Wn;exports.TableColumnVisibilitySettings=Hpe;exports.TableHead=vo;exports.TableHeader=Xm;exports.TablePresentationSettings=Upe;exports.TableRow=Pr;exports.TableSkeleton=dz;exports.TableVisual=Jd;exports.Tag=HZ;exports.TbChartBubble=wxe;exports.TbChartFunnel=Cxe;exports.TbChartTreemap=Sxe;exports.TextCard=sb;exports.Textarea=Bm;exports.TiSortNumerically=jxe;exports.Toggle=Zxe;exports.Tornado=qZ;exports.Trash2=_a;exports.TriangleAlert=Po;exports.TypeGlyph=oC;exports.UXProvider=tB;exports.Undo2=UZ;exports.User=BO;exports.Users=Wk;exports.UsersRound=VO;exports.VisualErrorState=Wue;exports.Zap=ER;exports.applyBriefingFormPatch=pv;exports.areContextEntitiesEqual=ur;exports.areEntitiesJoined=Xre;exports.arrayMove=lx;exports.briefingFormDraftToCreateRequest=pP;exports.briefingFormDraftToUpdateRequest=Ude;exports.briefingToFormDraft=og;exports.briefingTone=Er;exports.buildCardControlUsageById=cbt;exports.buildCustomCardTheme=Ww;exports.buildDashboardControlUsageById=lbt;exports.buildDashboardSheetsInputExecutionSnapshot=_O;exports.buildDashboardStructuralParticipantIdsByControlId=ppe;exports.buildFilterFieldMeta=pO;exports.buildFilterSemanticContext=gO;exports.buildInlineFilterNodes=q$;exports.buildMultiInputCustomVisualProps=U$;exports.buildMultiInputTemporalPresentationInputs=W$;exports.calculateCardFilterValues=y_;exports.calculateContextAwareFilters=v_;exports.calculateFieldState=e3;exports.canEditLocalCalculatedFields=f4;exports.canUserAccessVisuals=hNe;exports.canUserCreateDashboards=QQ;exports.canUserEdit=uNe;exports.canUserManageDashboards=fNe;exports.canUserManageGroups=mNe;exports.canUserUseFilters=dNe;exports.cancelBriefingPreviewRun=Rde;exports.cancelBriefingRun=Fde;exports.cancelExport=F$e;exports.chartSupportsDataLabels=qne;exports.chartSupportsLegend=Vne;exports.chartTypes=YT;exports.cleanupKpiMetricComparisonMode=gme;exports.cloneLinkedFrameWithSourceMapping=ytt;exports.closestCenter=lC;exports.commitSharedCalculatedFields=th;exports.createAssistantConversationId=Wp;exports.createAssistantRequestId=Xbe;exports.createBriefing=jde;exports.createBriefingFormDraft=mP;exports.createChartConfig=Db;exports.createCustomVisualTemporalBucketFormatter=K$;exports.createDashboardControlInputFromControl=l0t;exports.createExport=boe;exports.currencyPresentationTargetKey=va;exports.dedup=gjt;exports.dedupeContextEntities=Bz;exports.deleteBriefing=Ide;exports.deleteBriefingRun=Pde;exports.diagnoseCurrencyPresentationBindings=Q0e;exports.doesStoredFilterMatchField=Ag;exports.downloadDocumentPdf=rL;exports.downloadPdf=ste;exports.extractTableMetadata=n4;exports.fieldAlreadyExists=Jre;exports.flexRender=vi;exports.flushPendingEditorDrafts=rB;exports.formatDisplayFormula=opt;exports.formatFileSize=L$e;exports.getAutoDetectedChartIcon=Gkt;exports.getBriefing=Nde;exports.getBriefingArtifact=Nnt;exports.getBriefingEvidence=jnt;exports.getBriefingPreviewRun=Mde;exports.getBriefingRun=Ade;exports.getCardCurrencyPresentationFields=jO;exports.getCardCurrencyPresentationTargets=kO;exports.getChartGridStyle=SDe;exports.getChartIconByType=Ykt;exports.getColorForValue=JR;exports.getCoreRowModel=fI;exports.getDefaultAxisConfig=oA;exports.getDefaultChartColors=Wm;exports.getDefaultDataLabelsConfig=Cw;exports.getDefaultLegendConfig=PL;exports.getDefaultRunningTotalPartitionByFieldIds=b0;exports.getDisplayedKpiResultColumnKeys=jw;exports.getDocumentSectionEditorCard=Bgt;exports.getDocumentSheetDashboardInputs=dx;exports.getDownloadUrl=A$e;exports.getEntityIcon=Ok;exports.getErrorMessage=Obe;exports.getExportStatus=R$e;exports.getExports=M$e;exports.getExpressionFieldKind=af;exports.getFieldExpressionAnnotation=r4;exports.getFilterCount=ek;exports.getFilterSourceDatabase=pY;exports.getGranularityOptionsForFieldType=ipe;exports.getKeys=Cr;exports.getMatrixVisualLoadingState=cI;exports.getMetricDisplayLabel=$3e;exports.getNewField=ooe;exports.getPaginationRowModel=hI;exports.getRoleBasedDisplayOverrides=XQ;exports.getRunningTotalOrderByCandidates=_mt;exports.getSelectedDateFilterColumn=uue;exports.getSemanticDomainLabel=hxe;exports.getSortedRowModel=Loe;exports.getTableConditionalFormattingColumnOptions=Ype;exports.getTableOutputColumnOptions=Zpe;exports.handleAggregationChange=cP;exports.handleAggregationLabelChange=ide;exports.hasFlatTableTotalsBehavior=Um;exports.hasMatrixResultData=_w;exports.horizontalListSortingStrategy=Kz;exports.inferSemanticDomainIdFromSelectedEntities=Pk;exports.isActiveBriefingRunStatus=sk;exports.isCardSummaryVisibleOnCard=G$;exports.isCurrencyPresentationControl=Z0e;exports.isDefaultColor=LTe;exports.isDevPaginationSwitchableCard=poe;exports.isEligibleFlatTableTotalsCard=hw;exports.isExportComplete=O$e;exports.isExportInProgress=P$e;exports.isInAiScopeArray=pjt;exports.isManagedCalculatedExpressionField=ol;exports.isMetricTransformEnabled=jmt;exports.isPresentationCurrencyBinding=Yv;exports.isPromiseLike=sO;exports.isSqlBackedKpi=soe;exports.isStructuralControlBinding=Y0e;exports.isSubtotalEnabledAggregateTable=t4;exports.isSupportedDocumentTableCardType=Vgt;exports.isTableType=cDe;exports.isTerminalBriefingRunStatus=ok;exports.lastAssistantMessageIsCompleteWithToolCalls=Rbe;exports.listBriefingRuns=Snt;exports.listBriefingTenantSummaries=Cnt;exports.listBriefings=wnt;exports.merge=sc;exports.mergeAxisConfig=sA;exports.normalizeConditionalFormatting=z5;exports.normalizeContextFormatMode=Eee;exports.pauseBriefing=kde;exports.pivotData=gw;exports.polishBriefingText=Ode;exports.prepareFeedbackData=GT;exports.previewBriefingPlan=Ede;exports.remarkGfm=Oz;exports.removeFromScopeArray=bjt;exports.resolveCurrencyPresentationTargetFormat=Aee;exports.resolveDashboardBriefingsVisibility=hhe;exports.resolveDashboardControlsVisibility=xNe;exports.resolveDashboardTitleEditability=bNe;exports.resolveDomainCalculatedFieldForEdit=Jpt;exports.resolveMatrixCardMeasureInstances=qk;exports.resolvePendingPivotTableResultState=h$e;exports.resolveTablePresentationStyle=S3;exports.resumeBriefing=_de;exports.runBriefingNow=Tde;exports.runBriefingPreview=Dde;exports.sanitizeAIScope=Pbe;exports.saveCalculatedFieldToCardScope=zP;exports.saveCalculatedFieldToSharedScope=Hme;exports.saveCalculatedFieldToSheetScope=BP;exports.seedSemanticMetricFormatDefaults=xme;exports.setTableColumnVisibility=yoe;exports.setupEditorWithCard=F_;exports.showAllTableColumns=z$e;exports.showJoinRequiredNotification=Qre;exports.sortByColumnsToSortState=ase;exports.sortStateToSortByColumns=lse;exports.sortableKeyboardCoordinates=Yz;exports.supportsLiveNumericPresentation=Gv;exports.supportsMetricTransformForMetric=bme;exports.supportsTableConditionalFormatting=Wpe;exports.toEntityArray=rl;exports.ue=et;exports.updateBriefing=rT;exports.useActiveExports=NNe;exports.useActiveToolStatus=gxe;exports.useAddFrameWithFreshSemanticExecutionPayload=lz;exports.useAddNewFrame=She;exports.useAssistantContainer=nJ;exports.useAssistantContextEntities=fT;exports.useAssistantLayoutStore=Ah;exports.useAssistantPanel=eJ;exports.useAssistantProfile=Qbe;exports.useAutoSubmitQueue=pxe;exports.useBrandStudioPreview=rIt;exports.useBriefingRunPolling=bP;exports.useBriefingUiCapabilities=mhe;exports.useCalendarContext=Z3e;exports.useCard=r$e;exports.useCardNumericPresentation=Fa;exports.useCardSummary=Y$;exports.useChartNumericPresentation=Mb;exports.useChat=Fbe;exports.useColumns=Qz;exports.useCreateVisualWithFrame=uSe;exports.useCurrentUserInfo=si;exports.useCustomVisual=kf;exports.useCustomVisualsQuery=B$;exports.useDashboardAppearance=Ou;exports.useDashboardById=XX;exports.useDashboardInteractionMode=nde;exports.useDashboardPreferences=$m;exports.useDashboardQuery=Kv;exports.useDashboardStructuralParticipants=gpe;exports.useDashboardSummary=Lue;exports.useDataColumns=vme;exports.useDateFilterHook=vYe;exports.useDefaultDashboardMutation=qX;exports.useDisplayPreferences=pl;exports.useDroppable=Whe;exports.useEditorAside=kT;exports.useEditorCardQuery=Cb;exports.useEffectiveEditorCardType=oB;exports.useEnsureReactGlobals=Mle;exports.useExportActions=rJ;exports.useExportStore=s_;exports.useFieldManagement=yme;exports.useFilterableFields=hme;exports.useFullscreenAssistant=tJ;exports.useGroupMembers=f1e;exports.useGroups=o5;exports.useHasDashboardId=oJ;exports.useInProgressExportsCount=jNe;exports.useJoinabilityMap=e4;exports.useManagementActions=Rm;exports.useManagementStore=Ts;exports.useMutation=Is;exports.usePivotTableConfig=Ym;exports.usePluginQuery=Cue;exports.useQuery=Kn;exports.useQueryClient=Br;exports.useReactTable=mI;exports.useResolveExistingFrameSemanticExecutionPayload=Stt;exports.useResolvedDefaultCurrency=r3;exports.useResolvedTemporalStylePreferences=xl;exports.useResolvedValueFormatLocale=n3;exports.useResourceManagement=JO;exports.useResourceUpdateState=QX;exports.useScopedFields=fme;exports.useSelectedVisual=P0e;exports.useSemanticDomains=G4;exports.useSemaphorContext=Et;exports.useSensor=db;exports.useSensors=gT;exports.useSortable=cx;exports.useStarredChartsStore=QIt;exports.useSurfaceAppearance=ml;exports.useTableQueryState=Qoe;exports.useTextFilterHook=ZUe;exports.useTheme=gY;exports.useTimezone=bl;exports.useTopoJson=Nw;exports.useUnifiedUsers=r_;exports.useUpdateResource=KX;exports.useUpdateVisualMutation=dSe;exports.useUserPreferences=vQ;exports.useVisualById=Qk;exports.useVisualManagement=cSe;exports.validateBriefingFormDraft=gP;exports.validateFieldForChartType=pme;exports.verticalListSortingStrategy=Gz;