react-semaphor 0.1.358 → 0.1.359

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 (27) hide show
  1. package/dist/chunks/{calendar-preferences-dialog-BzAHg2dH.js → calendar-preferences-dialog-BHq3bPkF.js} +1 -1
  2. package/dist/chunks/{calendar-preferences-dialog-DGA5mlpS.js → calendar-preferences-dialog-BeZvsJV0.js} +1 -1
  3. package/dist/chunks/{dashboard-briefing-launcher-Cx8GVVDP.js → dashboard-briefing-launcher-Dr6trdJw.js} +1 -1
  4. package/dist/chunks/{dashboard-briefing-launcher-BV4oNYVr.js → dashboard-briefing-launcher-gm3YPxOh.js} +3 -3
  5. package/dist/chunks/{dashboard-controls-2Yydgr4q.js → dashboard-controls-4a3fKtuD.js} +1 -1
  6. package/dist/chunks/{dashboard-controls-Aqn8jM53.js → dashboard-controls-BZljC-GB.js} +3 -3
  7. package/dist/chunks/{dashboard-json-DCDAthMc.js → dashboard-json-4uDp0D6Y.js} +1 -1
  8. package/dist/chunks/{dashboard-json-D0Pc1dwB.js → dashboard-json-wTRw_VIn.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-BdVNDANy.js → edit-dashboard-visual-BztJSdkR.js} +3 -3
  10. package/dist/chunks/{edit-dashboard-visual-C-yLMahk.js → edit-dashboard-visual-CqnMxF8h.js} +1 -1
  11. package/dist/chunks/{index-Cs6rC7Qx.js → index-DZ3lq1Pk.js} +8 -4
  12. package/dist/chunks/{index-BMQsLAi3.js → index-YZnHD2NF.js} +2 -2
  13. package/dist/chunks/{resource-management-panel-D6zRXAE_.js → resource-management-panel-BajPY5IU.js} +1 -1
  14. package/dist/chunks/{resource-management-panel-CuFOHM8_.js → resource-management-panel-CEVKKwSW.js} +2 -2
  15. package/dist/chunks/{use-create-flow-overlay-state-dPApJpMV.js → use-create-flow-overlay-state-CT1BlsPJ.js} +2 -2
  16. package/dist/chunks/{use-create-flow-overlay-state-CcAzq169.js → use-create-flow-overlay-state-D010FtSh.js} +1 -1
  17. package/dist/chunks/{use-visual-utils-Dg4iuSLu.js → use-visual-utils-CIHFvxpt.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-BUSgtvLJ.js → use-visual-utils-H2FXMsGo.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/data-app-builder/index.cjs +1 -1
  22. package/dist/data-app-builder/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +5 -5
  25. package/dist/surfboard/index.cjs +1 -1
  26. package/dist/surfboard/index.js +2 -2
  27. package/package.json +1 -1
@@ -1375,7 +1375,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
1375
1375
  - less than the value passed to \`max\` (or ${X3} if no \`max\` prop is set)
1376
1376
  - \`null\` or \`undefined\` if the progress is indeterminate.
1377
1377
 
1378
- Defaulting to \`null\`.`}var _de=Sde,Ift=Nde;const Q3=Q.forwardRef(({className:e,value:t,...n},r)=>l.jsx(_de,{ref:r,className:m.cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:l.jsx(Ift,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Q3.displayName=_de.displayName;function Dft({files:e,onRemove:t,showRemove:n=!0,className:r=""}){if(e.length===0)return null;const s=o=>hb.includes(o)?Ame:o.includes("pdf")||o.includes("text")?wi:o.includes("javascript")||o.includes("typescript")||o.includes("python")||o.includes("sql")?SC:Fme;return l.jsx("div",{className:`flex flex-wrap gap-1.5 ${r}`,children:e.map(o=>{const i=s(o.type);return l.jsxs("div",{className:"group inline-flex h-7 items-center gap-1.5 rounded-control border border-border/60 bg-background px-1.5 text-[11px]",children:[l.jsx("span",{className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] bg-muted",children:l.jsx(i,{className:"h-2.5 w-2.5 text-muted-foreground"})}),l.jsx("span",{className:"max-w-[140px] truncate text-foreground/85",children:o.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:V0(o.size)}),o.uploadProgress!==void 0&&o.uploadProgress<100&&l.jsx(Q3,{value:o.uploadProgress,className:"h-0.5 w-12 shrink-0"}),n&&t&&l.jsx("button",{type:"button",onClick:()=>t(o.id),className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":`Remove ${o.name}`,children:l.jsx(m.X,{className:"h-3 w-3"})})]},o.id)})})}function Mft({file:e,className:t=""}){return hb.includes(e.type)&&e.preview?l.jsxs("div",{className:`inline-block ${t}`,children:[l.jsx("img",{src:e.preview,alt:e.name,className:"max-h-64 max-w-full rounded-card border border-border"}),l.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.name," • ",V0(e.size)]})]}):l.jsxs("div",{className:`inline-flex items-center gap-1.5 rounded-control border border-border/60 bg-muted/30 px-2 py-1 ${t}`,children:[l.jsx(wi,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-[12px] text-foreground/85",children:e.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:V0(e.size)})]})}function Aft({children:e,onFilesDropped:t,disabled:n=!1,currentFileCount:r=0,className:s}){const[o,i]=v.useState(!1),a=v.useCallback(f=>{f.preventDefault(),f.stopPropagation(),n||i(!0)},[n]),c=v.useCallback(f=>{f.preventDefault(),f.stopPropagation();const h=f.currentTarget.getBoundingClientRect(),p=f.clientX,g=f.clientY;(p<h.left||p>=h.right||g<h.top||g>=h.bottom)&&i(!1)},[]),u=v.useCallback(f=>{f.preventDefault(),f.stopPropagation()},[]),d=v.useCallback(async f=>{if(f.preventDefault(),f.stopPropagation(),i(!1),n)return;const h=Array.from(f.dataTransfer.files);if(h.length===0)return;const p=lc-r;if(h.length>p){at.error(`You can only attach ${lc} files per message. You have ${p} slot(s) remaining.`);return}const{valid:g,errors:b}=vde(h);if(b.forEach(({file:x,error:y})=>{at.error(`${x.name}: ${y}`)}),g.length>0)try{const x=await Promise.all(g.map(y=>K3(y)));t(x),at.success(`${x.length} file(s) attached successfully`)}catch(x){console.error("Failed to process files:",x),at.error("Failed to process one or more files")}},[n,r,t]);return l.jsxs("div",{className:m.cn("relative",s),onDragEnter:a,onDragLeave:c,onDragOver:u,onDrop:d,children:[e,o&&!n&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-control border-2 border-dashed border-primary bg-primary/5 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx(m.Upload,{className:"h-8 w-8 text-primary"}),l.jsx("p",{className:"text-sm font-medium text-primary",children:"Drop files here to upload"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[lc-r," slot(s) available"]})]})})]})}function Rft(e,t,n){switch(e){case"none":return!1;case"include":return n.includes(t);case"exclude":return!n.includes(t);case"all":default:return!0}}function Fft({mode:e,currentDomainId:t,scopedDomainIds:n,hasSelectedEntities:r}){return e==="all"?!1:e==="none"?!!t||r:t?!Rft(e,t,n):r}function jde(e){const{tokenProps:t}=Ct(),n=m.useDashboardStore(c=>c.authToken)||e;m.useEditorStore(c=>c.selectedConnectionId),m.useEditorStore(c=>{var u,d;return(d=(u=c==null?void 0:c.card)==null?void 0:u.dataSource)==null?void 0:d.connectionId});const{refetch:r,isPending:s,data:o,isLoading:i,isError:a}=$n({queryKey:["semantic-domains"],queryFn:()=>m.getRequest(`${t.apiServiceUrl}/v1/domains`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)});return{isPending:s,error:a,semanticDomainsData:o,semanticDomains:(o==null?void 0:o.domains)||[],isSemanticDomainsLoading:i,isSemanticDomainsError:a,refetchSemanticDomains:r}}function Pft({domainAccess:e,search:t,scopeDomainId:n,selectedEntities:r,onSelectionChange:s}){const{semanticDomains:o,isSemanticDomainsLoading:i}=jde(),a=v.useMemo(()=>Lft(o,e),[o,e]),c=v.useMemo(()=>n?a.filter(d=>d.id===n):a,[a,n]);if(i&&c.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading semantic domains…"});if(c.length===0)return null;const u=!!n;return l.jsxs("div",{children:[l.jsx(Ede,{label:"Semantic Domains"}),c.map(d=>l.jsx(Oft,{domain:d,search:t,forceExpanded:u,selectedEntities:r,onSelectionChange:s},d.id))]})}function Oft({domain:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:s}){const[o,i]=v.useState(!1),a=o||t.length>0||!!n,{datasets:c,isPending:u}=ENe(a?e.id:void 0),d=v.useMemo(()=>{if(!t)return c;const w=t.trim().toLowerCase();return c.filter(C=>`${C.label??""} ${C.name??""} ${C.description??""}`.toLowerCase().includes(w))},[c,t]),f=t.length>0&&d.length>0,h=o||f||!!n,p=c.length,g=v.useMemo(()=>d.filter(w=>r.some(C=>ir(C,mS(w)))).length,[d,r]),b=v.useMemo(()=>d.map(mS),[d]),x=b.length>0&&b.every(w=>r.some(C=>ir(C,w))),y=()=>{if(b.length===0)return;if(x){s(r.filter(C=>!b.some(N=>ir(C,N))));return}const w=[...r];for(const C of b)w.some(N=>ir(N,C))||w.push(C);s(w)},S=w=>{const C=mS(w),N=r.some(k=>ir(k,C));s(N?r.filter(k=>!ir(k,C)):[...r,C])};return t.length>0&&!f&&!u?null:l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center rounded-[4px] px-3 py-1.5 transition-colors hover:bg-muted/50",children:[l.jsxs("button",{type:"button",onClick:()=>i(w=>!w),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[l.jsx(mr,{className:m.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",h&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:e.label||e.name}),p>0&&l.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:["· ",p," dataset",p===1?"":"s"," · curated"]})]}),h&&!u&&b.length>0&&l.jsx("button",{type:"button",onClick:y,className:"ml-2 shrink-0 rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-background hover:text-foreground",children:x?"Clear":"Select all"}),l.jsx("span",{className:"ml-auto font-mono text-[10px] tabular-nums text-muted-foreground",children:g>0?g:""})]}),h&&l.jsx("ul",{className:"space-y-px pb-1",children:u&&c.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"Loading datasets…"}):d.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"No datasets in this domain."}):d.map(w=>{const C=mS(w),N=r.some(k=>ir(k,C));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded-[4px] px-9 py-1.5 transition-colors hover:bg-muted/40",children:[l.jsx(zn,{checked:N,onCheckedChange:()=>S(w),className:"mt-[3px] h-3.5 w-3.5 shrink-0"}),l.jsx(ti,{className:"mt-[3px] h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground",children:w.label||w.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:w.type==="virtual"?"virtual":"dataset"})]}),w.description&&l.jsx("p",{className:"mt-0.5 text-[11px] leading-[1.4] text-muted-foreground",children:w.description})]})]})},w.id)})})]})}function Ede({label:e}){return l.jsx("div",{className:"px-3 pb-1.5 pt-2.5",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})})}function Lft(e,t){if(!t||t.mode==="all")return e;const n=new Set(t.domainIds??[]);return t.mode==="include"?e.filter(r=>n.has(r.id)):t.mode==="exclude"?e.filter(r=>!n.has(r.id)):[]}function mS(e){return{id:e.id,datasetType:e.type,name:e.name||e.table,label:e.label,domainId:e.domainId,description:e.description,database:e.database,schema:e.schema,table:e.table,type:"dataset",connectionId:e.connectionId,connectionType:e.connectionType,dialect:e.dialect,datamodelId:e.datamodelId,sql:e.sql}}function $ft({search:e,scopeConnectionId:t,selectedEntities:n,onSelectionChange:r}){const{connections:s,isConnectionsLoading:o}=Qc(),i=v.useMemo(()=>t?s.filter(c=>c.id===t):s,[s,t]);if(o&&i.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading connections…"});if(i.length===0)return null;const a=!!t;return l.jsxs("div",{children:[l.jsx(Ede,{label:"Direct Sources"}),i.map(c=>l.jsx(zft,{connection:c,search:e,forceExpanded:a,selectedEntities:n,onSelectionChange:r},c.id))]})}function zft({connection:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:s}){var g;const[o,i]=v.useState(!1),a=o||t.length>0||!!n,c=((g=e.capabilities)==null?void 0:g.path)??[],u=c.includes("database"),d=c.includes("schema"),f=e.type==="upload",h=e.type==="url",p=v.useMemo(()=>r.filter(b=>b.connectionId===e.id).length,[r,e.id]);return l.jsxs("div",{className:"border-b border-border/60 last:border-b-0",children:[l.jsxs("button",{type:"button",onClick:()=>i(b=>!b),className:"flex w-full items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-muted/40",children:[l.jsx(mr,{className:m.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",a&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground/90",children:e.name}),l.jsxs("span",{className:"truncate text-[11px] text-muted-foreground",children:["· ",e.type]}),l.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground",children:p>0?p:""})]}),a&&l.jsxs(l.Fragment,{children:[f?l.jsx(Bft,{connection:e,selectedEntities:r,onSelectionChange:s}):h?l.jsx(Vft,{connection:e,selectedEntities:r,onSelectionChange:s}):u?l.jsx(Hft,{connection:e,requiresSchema:d,search:t,selectedEntities:r,onSelectionChange:s}):d?l.jsx(Tde,{connection:e,databaseName:"",search:t,selectedEntities:r,onSelectionChange:s}):l.jsx(J3,{connection:e,databaseName:"",schemaName:"",search:t,selectedEntities:r,onSelectionChange:s}),!f&&!h&&l.jsx(Uft,{connection:e,search:t,selectedEntities:r,onSelectionChange:s})]})]})}function Bft({connection:e,selectedEntities:t,onSelectionChange:n}){const r=`upload-source-${e.id}`,s=t.filter(a=>a.connectionId===e.id&&(a.type==="upload"||a.type==="file")),o=a=>{if(!(a!=null&&a.length))return;const c=Array.from(a).map(u=>({id:`file-${Date.now()}-${Math.random()}`,name:u.name,type:"upload",connectionId:e.id,connectionType:e.type,label:u.name,description:`Uploaded ${new Date().toLocaleString()}`,originalName:u.name,file:u}));n([...t,...c])},i=a=>{n(t.filter(c=>!("id"in c&&c.id===a&&c.connectionId===e.id&&(c.type==="upload"||c.type==="file"))))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"rounded-[6px] border border-dashed border-border bg-muted/20 p-4 text-center",children:[l.jsx(m.Upload,{className:"mx-auto mb-2 h-5 w-5 text-muted-foreground"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Add CSV, JSON, or Excel files."}),l.jsx("input",{id:r,type:"file",multiple:!0,className:"hidden",onChange:a=>o(a.target.files),accept:".csv,.json,.xlsx,.xls"}),l.jsx(m.Button,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-7 text-[12px]",onClick:()=>{var a;return(a=document.getElementById(r))==null?void 0:a.click()},children:"Select files"})]}),s.length>0&&l.jsx("ul",{className:"space-y-1",children:s.map(a=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(wi,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:a.originalName||a.name}),l.jsx("button",{type:"button","aria-label":`Remove ${a.originalName||a.name}`,onClick:()=>i(a.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-3 w-3"})})]},a.id))})]})}function Vft({connection:e,selectedEntities:t,onSelectionChange:n}){const[r,s]=v.useState(""),[o,i]=v.useState(""),[a,c]=v.useState("api"),u=t.filter(h=>h.connectionId===e.id&&h.type==="url"),d=()=>{const h=r.trim(),p=o.trim();if(!h||!p)return;const g={id:`url-${Date.now()}-${Math.random()}`,name:h,type:"url",connectionId:e.id,connectionType:e.type,label:h,description:`URL source of type ${a}`,originalName:h,url:p,sourceType:a};n([...t,g]),s(""),i(""),c("api")},f=h=>{n(t.filter(p=>!("id"in p&&p.id===h&&p.connectionId===e.id&&p.type==="url")))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"space-y-2 rounded-[6px] border border-border bg-muted/20 p-3",children:[l.jsx(m.Input,{value:r,onChange:h=>s(h.target.value),placeholder:"Source name",className:"h-7 text-[12px]"}),l.jsx(m.Input,{value:o,onChange:h=>i(h.target.value),placeholder:"https://api.example.com/data",className:"h-7 text-[12px]"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:a,onChange:h=>c(h.target.value),className:"h-7 flex-1 rounded-control border border-input bg-background px-2 text-[12px]",children:[l.jsx("option",{value:"api",children:"API endpoint"}),l.jsx("option",{value:"csv",children:"CSV file"}),l.jsx("option",{value:"json",children:"JSON file"})]}),l.jsxs(m.Button,{type:"button",size:"sm",className:"h-7 text-[12px]",disabled:!r.trim()||!o.trim(),onClick:d,children:[l.jsx(pr,{className:"mr-1 h-3 w-3"}),"Add"]})]})]}),u.length>0&&l.jsx("ul",{className:"space-y-1",children:u.map(h=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(mg,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-[12px]",children:h.name}),l.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:h.url})]}),l.jsx("button",{type:"button","aria-label":`Remove ${h.name}`,onClick:()=>f(h.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-3 w-3"})})]},h.id))})]})}function Hft({connection:e,requiresSchema:t,search:n,selectedEntities:r,onSelectionChange:s}){var a;const o=fE("/v1/databases",{connection_id:e.id},["databases",e.id]);if(o.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading databases…"});const i=((a=o.data)==null?void 0:a.databases)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No databases."}):l.jsx("div",{children:i.map(c=>l.jsx(Ide,{label:c.database_name,indentLevel:1,search:n,renderChildren:u=>u&&(t?l.jsx(Tde,{connection:e,databaseName:c.database_name,search:n,selectedEntities:r,onSelectionChange:s}):l.jsx(J3,{connection:e,databaseName:c.database_name,schemaName:"",search:n,selectedEntities:r,onSelectionChange:s}))},c.database_name))})}function Tde({connection:e,databaseName:t,search:n,selectedEntities:r,onSelectionChange:s}){var a;const o=fE("/v1/schemas",{connection_id:e.id,database_name:t||"NA"},["schemas",e.id,t],!!e.id);if(o.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading schemas…"});const i=((a=o.data)==null?void 0:a.schemas)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No schemas."}):l.jsx("div",{children:i.map(c=>l.jsx(Ide,{label:c.schema_name,indentLevel:t?2:1,search:n,renderChildren:u=>u&&l.jsx(J3,{connection:e,databaseName:t,schemaName:c.schema_name,search:n,selectedEntities:r,onSelectionChange:s})},c.schema_name))})}function J3({connection:e,databaseName:t,schemaName:n,search:r,selectedEntities:s,onSelectionChange:o}){const i=fE("/v1/tables",{connection_id:e.id,database_name:t||void 0,schema_name:n||void 0},["tables",e.id,t,n]),a=v.useMemo(()=>{var b;const p=((b=i.data)==null?void 0:b.tables)??[];if(!r)return p;const g=r.trim().toLowerCase();return p.filter(x=>x.table_name.toLowerCase().includes(g))},[i.data,r]),c=(p,g)=>({connectionId:e.id,connectionType:e.type,type:"table",dialect:e.dialect,database:t||void 0,schema:n||void 0,name:p,dbObjectType:g==null?void 0:g.toLowerCase()});if(i.isLoading)return l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"Loading tables…"});if(a.length===0)return r?null:l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"No tables."});const u=a.map(p=>c(p.table_name,p.table_type)),d=u.length>0&&u.every(p=>s.some(g=>ir(g,p))),f=(p,g)=>{const b=c(p,g),x=s.some(y=>ir(y,b));o(x?s.filter(y=>!ir(y,b)):[...s,b])},h=()=>{if(u.length===0)return;if(d){o(s.filter(g=>!u.some(b=>ir(g,b))));return}const p=[...s];for(const g of u)p.some(b=>ir(b,g))||p.push(g);o(p)};return l.jsxs("ul",{children:[l.jsxs("li",{className:"flex items-center justify-between gap-2 py-1 pl-12 pr-4",children:[l.jsxs("span",{className:"text-[10.5px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:[a.length," table",a.length===1?"":"s"]}),l.jsx("button",{type:"button",onClick:h,className:"rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground",children:d?"Clear":"Select all"})]}),a.map(p=>{const g=c(p.table_name,p.table_type),b=s.some(x=>ir(x,g));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(zn,{checked:b,onCheckedChange:()=>f(p.table_name,p.table_type),className:"h-3.5 w-3.5 shrink-0"}),l.jsx(m.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:p.table_name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:p.table_type??"table"})]})]})},p.table_name)})]})}function Uft({connection:e,search:t,selectedEntities:n,onSelectionChange:r}){const s=fE("/v1/datamodels",{connection_id:e.id},["datamodels",e.id]),o=v.useMemo(()=>{var u;const a=((u=s.data)==null?void 0:u.datamodels)??[];if(!t)return a;const c=t.trim().toLowerCase();return a.filter(d=>`${d.label??""} ${d.name??""} ${d.description??""}`.toLowerCase().includes(c))},[s.data,t]);if(s.isLoading||o.length===0)return null;const i=a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>ir(d,c));r(u?n.filter(d=>!ir(d,c)):[...n,c])};return l.jsxs("div",{children:[l.jsx("div",{className:"px-8 pb-1 pt-2",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data models"})}),l.jsx("ul",{children:o.map(a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>ir(d,c));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(zn,{checked:u,onCheckedChange:()=>i(a),className:"mt-[2px] h-3.5 w-3.5 shrink-0"}),l.jsx(_me,{className:"mt-[2px] h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:a.label||a.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:"model"})]}),a.description&&l.jsx("p",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",children:a.description})]})]})},a.id)})})]})}function Ide({label:e,indentLevel:t,search:n,renderChildren:r}){const[s,o]=v.useState(!1),i=s||n.length>0,a=t===1?"pl-8":"pl-10";return l.jsxs("div",{children:[l.jsxs("button",{type:"button",onClick:()=>o(c=>!c),className:m.cn("flex h-6 w-full items-center gap-1.5 pr-4 text-left transition-colors hover:bg-muted/40",a),children:[l.jsx(mr,{className:m.cn("h-2.5 w-2.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e})]}),r(i)]})}function fE(e,t,n,r=!0){const{tokenProps:s}=Ct(),o=m.useDashboardStore(a=>a.authToken),i=v.useMemo(()=>Object.fromEntries(Object.entries(t).filter(([,a])=>a!==void 0)),[t]);return $n({queryKey:n,queryFn:()=>m.getRequest(`${s.apiServiceUrl}${e}`,(o==null?void 0:o.accessToken)||"",i),enabled:r&&!!(o!=null&&o.accessToken)&&Object.values(i).every(a=>a.length>0)})}function dU(e){return e.type==="dataset"&&e.label||e.name}function qft({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:l.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((n,r)=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-control border border-input bg-muted/50 py-0.5 pl-1.5 pr-0.5 text-[11px] text-foreground/80",children:[l.jsx("span",{className:"max-w-[180px] truncate",children:dU(n)}),l.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),t(n)},"aria-label":`Remove ${dU(n)}`,className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-2.5 w-2.5"})})]},`${n.type}-${n.name}-${r}`))})}function fU(e){const t=new Set;for(const n of e||[])"domainId"in n&&typeof n.domainId=="string"&&t.add(n.domainId);if(t.size===1)return[...t][0]}function r2(e){if(e!=null&&e.length)return e.every(t=>t.type==="dataset")?"semanticDomain":e.every(t=>t.type==="url")?"url":e.every(t=>t.type==="upload"||t.type==="file")?"upload":"database"}function e$({open:e,onOpenChange:t,dataSource:n,dialogMode:r,incomingSelectedEntities:s,onSaveSelectedEntities:o,saveAsDashboardDefault:i=!1}){var se,xe;const{tokenProps:a}=Ct(),c=a.config,u=a.semanticDomainAccess||Ohe.DEFAULT_SEMANTIC_DOMAIN_ACCESS,[d,f]=v.useState([]),[h,p]=v.useState(void 0),[g,b]=v.useState(""),[x,y]=v.useState("all"),[S,w]=v.useState(void 0),C=v.useRef(!1),{updateDataSource:N}=m.useEditorActions(),k=m.useDashboardStore(ie=>ie.isVisualEditing),_=m.useDashboardStore(ie=>ie.dashboard.aiContext),{setAiContext:j}=m.useDashboardActions(),T=u.mode,E=(c==null?void 0:c.showDirectSource)!==!1,I=T==="include"||T==="exclude"||!E,D=T!=="all",A=E&&!I,R=I?"semanticDomain":n.mode,F=r==="dataSource"&&!E,H=T==="include"&&(((se=u.domainIds)==null?void 0:se.length)||0)===1?(xe=u.domainIds)==null?void 0:xe[0]:void 0,B=v.useCallback(ie=>{C.current=!0,N({...n,connectionId:(n==null?void 0:n.connectionId)||"",connectionType:(n==null?void 0:n.connectionType)||"",mode:ie,selectedEntities:(n==null?void 0:n.selectedEntities)||[],...ie!=="semanticDomain"&&{semanticDomainId:void 0}})},[n,N]),U=v.useCallback(ie=>{N({...n,...ie})},[n,N]),W=v.useCallback(ie=>{if(r==="aiContext"){"semanticDomainId"in ie&&p(ie.semanticDomainId);return}U(ie)},[r,U]),O=r==="aiContext"?h:n.semanticDomainId;r==="aiContext"&&{...n},v.useEffect(()=>{if(r==="aiContext"&&!e)return;if(I&&n.mode!=="semanticDomain"&&r==="dataSource"){B("semanticDomain");return}if(!D||R!=="semanticDomain")return;const ie=O,Ae=u.domainIds??[],oe=r==="aiContext"?d:n.selectedEntities,ge=((oe==null?void 0:oe.length)??0)>0,fe=((d==null?void 0:d.length)??0)>0;Fft({mode:T,currentDomainId:ie,scopedDomainIds:Ae,hasSelectedEntities:ge})&&(r==="dataSource"?U({semanticDomainId:void 0,selectedEntities:[]}):p(void 0),fe&&f([]))},[I,D,R,n.mode,O,n.selectedEntities,r,h,d,e,u.domainIds,T,E,U,B]),v.useEffect(()=>{H&&!O&&W({semanticDomainId:H})},[H,O,W]),v.useEffect(()=>{if(!e){C.current=!1,b(""),w(void 0),y(I?"semantic":"all");return}if(C.current)return;f([...s||[]]);const ie=r==="aiContext"?fU(s):void 0;p(n.semanticDomainId||ie),w(r2(s))},[e,r,s,n.semanticDomainId,I]);const Z=ie=>{C.current=!0,f(d.filter(Ae=>!ir(Ae,ie)))},Y=v.useCallback((ie,Ae)=>{C.current=!0,f(ie),w(Ae??r2(ie))},[]),M=()=>{var Ae,oe;if(r==="aiContext"){if(k&&N(n),i){const ge={..._,selectedEntities:d,mode:d.length>0?"fixed":"auto"};j(ge)}o==null||o(d),t(!1);return}const ie=r2(d)??S??R;if(ie==="semanticDomain"){const ge=fU(d)||h||n.semanticDomainId,fe=((Ae=d==null?void 0:d[0])==null?void 0:Ae.connectionId)||n.connectionId,me=((oe=d==null?void 0:d[0])==null?void 0:oe.connectionType)||n.connectionType;N({...n,mode:"semanticDomain",semanticDomainId:ge,connectionId:fe,connectionType:me,selectedEntities:d})}else if(ie==="upload"||ie==="url"){const ge=d==null?void 0:d[0];N({...n,mode:ie,semanticDomainId:void 0,connectionId:(ge==null?void 0:ge.connectionId)||n.connectionId,connectionType:(ge==null?void 0:ge.connectionType)||n.connectionType,selectedEntities:d})}else{const ge=d==null?void 0:d[0];N({...n,mode:"database",semanticDomainId:void 0,connectionId:(ge==null?void 0:ge.connectionId)||n.connectionId,connectionType:(ge==null?void 0:ge.connectionType)||n.connectionType,selectedEntities:d})}t(!1)},{semanticDomains:K}=jde(),{connections:L}=Qc(),$=ie=>{y(ie),ie==="semantic"||ie.startsWith("domain:")?n.mode!=="semanticDomain"&&B("semanticDomain"):(ie==="direct"||ie.startsWith("conn:"))&&n.mode==="semanticDomain"&&B("database")},z=x.startsWith("domain:"),V=x.startsWith("conn:"),P=z?x.slice(7):void 0,q=V?x.slice(5):void 0,G=!A||x==="all"||x==="semantic"||z,X=E&&!I&&(x==="all"||x==="direct"||V),J=((s==null?void 0:s.length)??0)>0,de=d.length===0&&!J,he=d.length===0&&J?"Clear":"Add",be=r==="aiContext"?"Data context":F?"Select dataset":"Add data",Se=r==="aiContext"?"Set the overall data scope for the dashboard":F?"Choose a curated dataset to analyze":"Search your semantic domains and connections";return l.jsx(Po,{open:e,onOpenChange:t,children:l.jsxs(mo,{showCloseButton:!1,className:"flex h-[560px] w-[620px] max-w-[620px] flex-col gap-0 overflow-hidden rounded-[6px] border border-border bg-popover p-0",children:[l.jsx(m.VisuallyHidden,{children:l.jsx(go,{children:be})}),l.jsxs("div",{className:"flex items-start justify-between border-b border-border px-4 py-2.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-[14px] font-semibold text-foreground",children:be}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:Se})]}),l.jsx("button",{type:"button",onClick:()=>t(!1),"aria-label":"Close",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-3.5 w-3.5"})})]}),l.jsxs("div",{className:"border-b border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[l.jsx(Ws,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:g,onChange:ie=>b(ie.target.value),placeholder:"Search datasets, tables, views, models",className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground/60 focus:outline-none"}),g&&l.jsx("button",{type:"button",onClick:()=>b(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-3 w-3"})})]}),A&&l.jsx("div",{className:"-mx-4 mt-2 overflow-x-auto px-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:l.jsxs("div",{className:"flex w-max items-center gap-1",children:[l.jsx(cx,{label:"All",active:x==="all",onClick:()=>$("all")}),(K.length>0||L.length>0)&&l.jsxs(l.Fragment,{children:[l.jsx(cx,{label:"Semantic",active:x==="semantic",onClick:()=>$("semantic")}),l.jsx(cx,{label:"Direct",active:x==="direct",onClick:()=>$("direct")}),l.jsx("span",{className:"shrink-0 px-0.5 text-muted-foreground/50",children:"·"})]}),K.map(ie=>l.jsx(cx,{label:ie.label||ie.name,active:x===`domain:${ie.id}`,onClick:()=>$(`domain:${ie.id}`)},`domain:${ie.id}`)),L.map(ie=>l.jsx(cx,{label:ie.name,active:x===`conn:${ie.id}`,onClick:()=>$(`conn:${ie.id}`)},`conn:${ie.id}`))]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[G&&l.jsx(Pft,{domainAccess:u,search:g,scopeDomainId:P,selectedEntities:d,onSelectionChange:ie=>Y(ie,"semanticDomain")}),X&&l.jsx($ft,{search:g,scopeConnectionId:q,selectedEntities:d,onSelectionChange:ie=>Y(ie)})]}),l.jsxs("div",{className:"flex flex-col gap-0.5 border-t border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:"Selected"}),l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["· ",d.length]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{type:"button",onClick:()=>t(!1),className:"inline-flex h-7 items-center rounded-control px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Cancel"}),l.jsxs("button",{type:"button",onClick:M,disabled:de,className:m.cn("inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition-colors hover:bg-primary/90",de&&"cursor-not-allowed opacity-50 hover:bg-primary"),children:[l.jsx("span",{children:he}),d.length>0&&l.jsxs("span",{className:"font-mono tabular-nums text-primary-foreground/70",children:["· ",d.length]})]})]})]}),d.length>0&&l.jsx(qft,{selectedEntities:d,onDeselectEntity:Z})]})]})})}function cx({label:e,active:t,onClick:n}){return l.jsx("button",{type:"button",onClick:n,"aria-pressed":t,className:m.cn("inline-flex h-6 shrink-0 items-center whitespace-nowrap rounded-control px-2 text-[11px] font-medium transition-colors",t?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:e})}const ug={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]};function bk(e,t={}){const{size:n="h-4 w-4"}=t,r=n;switch(e){case"table":return l.jsx(TF,{className:r});case"view":return l.jsx(rv,{className:r});case"materialized view":return l.jsx(Mme,{className:r});case"model":return l.jsx(sv,{className:r});case"file":return l.jsx(wi,{className:r});case"dataset":return l.jsx(ti,{className:r});case"upload":return l.jsx(m.Upload,{className:r});case"url":return l.jsx(SF,{className:r});default:return l.jsx(mg,{className:r})}}const Gx=e=>e.name||e.name,Wft=e=>{const t=Gx(e),n="description"in e?e.description:"",r=e.database||"",s=e.schema||"",o=[e.type,r,s].filter(Boolean);return l.jsxs("div",{className:"max-w-[260px] space-y-1",children:[l.jsx("div",{className:"break-all font-mono text-[11px] font-medium leading-[1.35]",children:t}),n&&l.jsx("div",{className:"text-[11px] leading-[1.45] text-background/70",children:n}),o.length>0&&l.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.06em] text-background/60",children:o.join(" · ")})]})};function Yft({entities:e,availableEntities:t,onRemoveEntity:n,onRemoveEntities:r,className:s}){const[o,i]=v.useState(!1),a=e.length>0,c=e.length>=3?e.slice(0,2):e,u=e.length>=3?e.slice(2):[],d=u.length>0;return l.jsx(m.TooltipProvider,{children:l.jsx("div",{className:s,children:a&&l.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.map((f,h)=>{const p="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group relative inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 font-mono text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",children:[l.jsx("span",{className:"grid h-3 w-3 place-items-center text-muted-foreground transition-colors group-hover:text-background/60",children:bk(f.type,{size:"h-3 w-3"})}),l.jsx("span",{className:"max-w-24 truncate",children:Gx(f)}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>n(f),"aria-label":`Remove ${Gx(f)}`,children:l.jsx(m.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(m.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,children:Wft(f)})]},p)}),d&&l.jsxs(m.Tooltip,{open:o,onOpenChange:i,children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",onClick:()=>i(!0),children:[l.jsx(ja,{className:"h-3 w-3"}),l.jsxs("span",{children:[u.length," more"]}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>r(u),"aria-label":"Remove all extra entities",children:l.jsx(m.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(m.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,className:"max-h-60 w-[260px] overflow-y-auto p-1.5",children:l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("div",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-background/60",children:"More entities"}),l.jsx("div",{className:"space-y-0.5",children:u.map(f=>{const h="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[3px] px-1 py-1 hover:bg-background/10",children:[l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-background/60",children:bk(f.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate font-mono text-[11px]",children:Gx(f)}),l.jsx("div",{className:"truncate text-[10px] text-background/60",children:[f.type,f.database].filter(Boolean).join(" · ")})]}),l.jsx("button",{type:"button",onClick:()=>{n(f),u.length===1&&i(!1)},className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-background/60 opacity-0 transition-opacity hover:bg-background/10 hover:text-background group-hover:opacity-100","aria-label":`Remove ${Gx(f)}`,children:l.jsx(m.X,{className:"h-2.5 w-2.5"})})]},h)})})]})})]})]})})})}const gS=e=>e.label||(e==null?void 0:e.name),hU=e=>"description"in e?e.description:`${e.type} from ${e.database||"database"}`;function Gft({isOpen:e,onSelect:t,onDeselect:n,onClose:r,availableEntities:s,selectedEntities:o,onTabComplete:i,onSelectAll:a,onRemoveAll:c,onAddContext:u}){const{tokenProps:d}=Ct(),f=(d==null?void 0:d.type)==="dashboard",[h,p]=v.useState(""),[g,b]=v.useState(""),x=s.filter(k=>{if(!h)return!0;const _=gS(k).toLowerCase(),j=(hU(k)||"").toLowerCase(),T=h.toLowerCase();return _.includes(T)||j.includes(T)});v.useEffect(()=>{e||(p(""),b(""))},[e]),v.useEffect(()=>{x.length>0&&!g&&b(gS(x[0]))},[x,g]);const y=()=>{if(!g)return;const k=x.find(_=>gS(_)===g);k&&(o.some(j=>"id"in k&&"id"in j?k.id===j.id:k.name===j.name&&k.connectionId===j.connectionId)||t(k),i(k),r())},S=k=>{(k.key==="Tab"||k.key==="Enter")&&(k.preventDefault(),y())};if(!e)return null;const w=k=>o.some(_=>"id"in k&&"id"in _?k.id===_.id:k.name===_.name&&k.connectionId===_.connectionId),C=o.length===s.length,N=o.length>0;return l.jsx(l.Fragment,{children:l.jsxs(qj,{shouldFilter:!1,value:g,onValueChange:b,onKeyDown:S,children:[s.length>0&&l.jsxs("div",{"cmdk-input-wrapper":"",className:"flex h-8 items-center gap-1.5 border-b border-border/60 px-2",children:[l.jsx(Ws,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx(Lo.Input,{placeholder:"Search entities",value:h,onValueChange:p,autoFocus:!0,className:"flex h-full min-w-0 flex-1 bg-transparent text-[12px] outline-none placeholder:text-muted-foreground/70 disabled:cursor-not-allowed disabled:opacity-50"}),!f&&l.jsxs("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),u==null||u()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[3px] border border-border/60 px-1.5 text-[10px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",children:[l.jsx(pr,{className:"h-2.5 w-2.5"}),"Add"]})]}),s.length>0&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-2 py-1 text-[10px] text-muted-foreground",children:[l.jsxs("span",{children:[o.length," selected"]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),a==null||a()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},disabled:C,className:"hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:"Select all"}),N&&l.jsx("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),c==null||c()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"hover:text-foreground",children:"Clear"})]})]}),l.jsxs(Wj,{className:"max-h-60 min-h-[120px]",children:[l.jsx(Yj,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-4",children:[l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No entities found"}),!f&&l.jsxs("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),u==null||u()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 px-2 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(pr,{className:"h-3 w-3"}),"Add datasets"]})]})}),l.jsx(Gj,{className:"p-0.5",children:x.map((k,_)=>{const j=w(k),T="id"in k?k.id:`${k.connectionId}-${k.name}`,E=gS(k);return l.jsxs(Kj,{value:E,onSelect:()=>{j?n==null||n(k):t(k)},onMouseDown:I=>{I.preventDefault(),I.stopPropagation()},className:m.cn("flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1.5 data-[selected=true]:bg-muted/60"),children:[l.jsx("span",{className:"grid h-3.5 w-3.5 shrink-0 place-items-center rounded-[3px] border border-border/60 bg-background",children:j&&l.jsx(m.Check,{className:"h-2.5 w-2.5 text-foreground"})}),l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-muted-foreground",children:bk(k.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[12px] font-medium leading-tight text-foreground",children:E}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] leading-tight text-muted-foreground",children:hU(k)})]})]},T)})})]})]})})}function GR({mode:e="full",compact:t=!1,inlineLayout:n=!1,inlineTriggerFirst:r=!1,syncOnOpen:s=!1,open:o,onOpenChange:i,onEntityMention:a,onEntityRemoved:c,onEntitiesRemoved:u,onSelectionChange:d,className:f,triggerClassName:h,triggerVariant:p="secondary",triggerLabel:g="Add entity",triggerIconOnly:b=!0,assistantType:x}){const[y,S]=v.useState(!1),[w,C]=v.useState(!1),N=o??y,k=o!==void 0,_=v.useRef(!1),T=m.useEditorStore(P=>P.card.dataSource)??ug,{selectedEntities:E,availableEntities:I,syncWithGlobalContext:D,setSelectedEntities:A,applyDashboardDefaultEntities:R,isEntitySelected:F}=Pj(x),H=e==="full"||e==="display",B=e==="full"||e==="trigger",U=v.useMemo(()=>b&&E.length>0?`Add entity (${E.length})`:g,[E.length,b,g]);v.useEffect(()=>{N&&!_.current&&s&&D(),_.current=N},[N,s,D]);const W=v.useCallback(P=>{k||S(P),i==null||i(P)},[k,i]),O=v.useCallback(P=>{const q=E.filter(G=>!ir(G,P));A(q),c==null||c(P),d==null||d(q)},[c,d,E,A]),Z=v.useCallback(P=>{if(P.length===0)return;const q=E.filter(G=>!P.some(X=>ir(G,X)));A(q),u==null||u(P),d==null||d(q)},[u,d,E,A]),Y=v.useCallback(P=>{const q=F(P)?E.filter(G=>!ir(G,P)):[...E,P];A(q),d==null||d(q)},[F,d,E,A]),M=v.useCallback(()=>{A(I),d==null||d(I)},[I,d,A]),K=v.useCallback(()=>{A([]),d==null||d([])},[d,A]),L=v.useCallback(P=>{x==="dashboard"?R():A(P),d==null||d(P)},[R,x,d,A]),$=v.useCallback(P=>{const q=E.some(G=>ir(G,P))?E:[...E,P];A(q),a==null||a(P),d==null||d(q),W(!1)},[a,d,E,W,A]),z=H?l.jsx(Yft,{className:m.cn(n?"contents":"space-y-2"),entities:E,availableEntities:I,onRemoveEntity:O,onRemoveEntities:Z}):null,V=B?l.jsxs(l.Fragment,{children:[l.jsxs(m.Popover,{open:N,onOpenChange:W,children:[l.jsx(m.PopoverTrigger,{asChild:!0,children:l.jsxs(m.Button,{variant:p,size:"xs",className:m.cn(t&&"h-6 gap-1.5 px-2 text-[11px] font-medium",h),title:g,children:[l.jsx(pW,{className:"h-3 w-3 text-muted-foreground"}),!b&&l.jsx("span",{children:U})]})}),l.jsx(m.PopoverContent,{className:m.cn("w-80 p-0",t&&"w-72"),align:"start",side:"top",sideOffset:8,onOpenAutoFocus:P=>P.preventDefault(),children:l.jsx(Gft,{isOpen:!0,onSelect:Y,onDeselect:Y,onClose:()=>W(!1),availableEntities:I,selectedEntities:E,onTabComplete:$,onSelectAll:M,onRemoveAll:K,onAddContext:()=>{W(!1),C(!0)}})})]}),l.jsx(e$,{incomingSelectedEntities:E,open:w,onOpenChange:C,dataSource:T,dialogMode:"aiContext",onSaveSelectedEntities:L,saveAsDashboardDefault:x==="dashboard"})]}):null;return l.jsx("div",{className:m.cn(n?"flex flex-wrap items-center gap-1":"",!n&&H?"space-y-2":"",f),children:n&&r?l.jsxs(l.Fragment,{children:[V,z]}):l.jsxs(l.Fragment,{children:[z,V]})})}const t$=v.forwardRef(({input:e,setInput:t,handleInputChange:n,handleSubmit:r,isLoading:s,stop:o,onFocus:i,status:a,assistantType:c},u)=>{const[d,f]=v.useState(!1),h=v.useRef(null),{queueMessage:p}=m.useQueueActions(),{addFileAttachment:g,removeFileAttachment:b,clearFileAttachments:x}=m.useFileActions(),y=m.useFileAttachments(c);v.useEffect(()=>{u&&"current"in u&&(u.current=h.current)},[u]);const S=v.useCallback(()=>{const D=h.current;if(D){if(!e||e.length===0){D.style.height="10px";return}D.style.height="auto";const A=Math.min(Math.max(D.scrollHeight,10),200);D.style.height=`${A}px`}},[e]);v.useEffect(()=>{S()},[S]),v.useEffect(()=>{const D=setTimeout(()=>{S()},0);return()=>clearTimeout(D)},[S]);const w=()=>{const D=e.trim();!D&&y.length===0||(a!=="ready"?(p(c,D,y),t(""),x(c)):r({preventDefault:()=>{}}))},C=D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),w()),D.key==="@"&&f(!0)},N=v.useCallback(D=>{const A=yft(D.nativeEvent);A.length>0&&(D.preventDefault(),A.forEach(async R=>{const F=await K3(R);g(c,F)}))},[g,c]),k=v.useCallback(D=>{D.forEach(A=>{g(c,A)})},[g,c]),_=v.useCallback(D=>{D.forEach(A=>{g(c,A)})},[g,c]),j=v.useCallback(D=>{b(c,D)},[b,c]),T=v.useCallback(D=>{const A=`@${D}`;e.includes(A)&&t(e.replace(A,"").replace(/\s{2,}/g," ").trim())},[e,t]),E=!e.trim()&&y.length===0,I=a!=="ready"&&!s;return l.jsxs(Aft,{onFilesDropped:k,currentFileCount:y.length,disabled:s,className:"space-y-2",children:[l.jsx(GR,{mode:"display",assistantType:c,onEntityRemoved:D=>{const A="label"in D?D.label:D.name;T(A)},onEntitiesRemoved:D=>{let A=e;D.forEach(R=>{const F="label"in R?R.label:R.name;A=A.replace(`@${F}`,"")}),A!==e&&t(A.replace(/\s{2,}/g," ").trim())}}),y.length>0&&l.jsx(Dft,{files:y,onRemove:j,showRemove:!s}),l.jsxs("div",{className:"rounded-control border border-border bg-background transition-colors focus-within:border-foreground/40",children:[l.jsx("textarea",{ref:h,value:e,onChange:n,onKeyDown:C,onPaste:N,onFocus:()=>{S(),i==null||i()},placeholder:I?"Will be queued":"Ask about this dashboard",className:"block max-h-[200px] min-h-[40px] w-full resize-none overflow-y-auto border-0 bg-transparent px-2.5 pb-1 pt-2 text-[13px] leading-[1.55] text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-0",style:{height:"40px"}}),l.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/60 px-1.5 py-1.5",children:[l.jsx(GR,{mode:"trigger",assistantType:c,syncOnOpen:c==="dashboard",open:d,onOpenChange:f,onEntityMention:D=>{var R;const A="label"in D?D.label:D.name;t(`${e}@${A} `),(R=h.current)==null||R.focus()},triggerVariant:"ghost",triggerIconOnly:!0,triggerClassName:"h-6 w-6 rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",triggerLabel:"Add entity"}),l.jsx(vft,{onFilesSelected:_,disabled:s,currentFileCount:y.length}),l.jsx("div",{className:"ml-auto"}),s?l.jsx("button",{type:"button",onClick:o,title:"Stop",className:"grid h-7 w-7 place-items-center rounded-control border border-border text-foreground transition-colors hover:bg-muted",children:l.jsx(jF,{className:"h-3 w-3 fill-current"})}):l.jsx("button",{type:"button",disabled:E,onClick:w,title:I?"Message will be queued":"Send",className:I?"grid h-7 w-7 place-items-center rounded-control border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40":"grid h-7 w-7 place-items-center rounded-control bg-foreground text-background transition-colors hover:bg-foreground/85 disabled:cursor-not-allowed disabled:opacity-40",children:l.jsx(kF,{className:"h-3 w-3"})})]})]})]})});t$.displayName="ChatInputWithContext";function Dde({assistantType:e,className:t}){const n=m.useMessageQueue(e),{removeFromQueue:r}=m.useQueueActions();return n.length===0?null:l.jsxs("div",{className:m.cn("rounded-control border border-dashed border-border bg-muted/30 p-2",t),children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-1 pb-1.5",children:[l.jsx(wF,{className:"h-3 w-3 text-muted-foreground"}),l.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Queued · ",n.length]})]}),l.jsx("div",{className:"space-y-1",children:n.map(s=>l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[4px] bg-background px-2 py-1 text-[12px] text-foreground/85 animate-in fade-in-0 slide-in-from-bottom-1",children:[l.jsx("span",{className:"flex-1 break-words",children:s.text}),l.jsx("button",{type:"button",onClick:()=>r(e,s.id),title:"Remove from queue",className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground group-hover:opacity-100",children:l.jsx(m.X,{className:"h-3 w-3"})})]},s.id))})]})}function Mde({assistantType:e,status:t,isLoading:n,sendMessage:r}){const s=m.useMessageQueue(e),{dequeueMessage:o}=m.useQueueActions();v.useEffect(()=>{if(t!=="ready"||n||!(s&&s.length>0))return;const a=o(e);a&&r({role:"user",parts:[{type:"text",text:a.text}]})},[t,n,s,o,r,e])}const pU={"tool-getTableColumns":{"input-streaming":"Fetching table columns...","input-available":"Reading column definitions..."},"tool-getChartDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartDataFromCardConfig":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getForecastDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartSQLSyntax":{"input-streaming":"Generating SQL syntax...","input-available":"SQL syntax generated"},"tool-validateCardConfigFormat":{"input-streaming":"Validating card config format...","input-available":"Card config format validated"},"tool-generateQueryConfig":{"input-streaming":"Generating query config...","input-available":"Sending query config..."},"tool-generateDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Generating dynamic visual..."},"tool-generateDynamicVisualFromData":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-inspectDashboard":{"input-streaming":"Inspecting dashboard...","input-available":"Reading dashboard context..."},"tool-runDashboardAnalysis":{"input-streaming":"Planning governed analysis...","input-available":"Fetching governed results..."},"tool-runAdvancedAnalysis":{"input-streaming":"Planning advanced analysis...","input-available":"Fetching governed results..."},"tool-renderDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-askForMoreInfo":{"input-streaming":"Asking for more information...","input-available":"More information requested"},"tool-createChartFromSql":{"input-streaming":"Creating chart...","input-available":"Chart created"},"tool-getUserSql":{"input-streaming":"Getting SQL...","input-available":"SQL retrieved"},"tool-inspectTableData":{"input-streaming":"Inspecting table data...","input-available":"Analyzing data..."},"tool-getDomainRelationships":{"input-streaming":"Getting domain relationships...","input-available":"Analyzing data..."}};function Kft(e,t){var r;if((r=pU[e])!=null&&r[t])return pU[e][t];const n=e.replace("tool-","").replace(/([A-Z])/g," $1").toLowerCase().trim();return t==="input-streaming"?`Processing ${n}...`:`Preparing ${n} response...`}function Ade(e){var n;if(!e||e.length===0)return{hasActiveTools:!1};const t=e[e.length-1];if(!(t!=null&&t.parts))return{hasActiveTools:!1};for(const r of t.parts){if(r.type==="reasoning"&&"state"in r&&r.state==="streaming")return{hasActiveTools:!0,activeToolText:"Reasoning...",toolType:"reasoning"};if(((n=r.type)!=null&&n.startsWith("tool-")||r.type==="dynamic-tool")&&"state"in r&&["input-streaming","input-available"].includes(r.state)){const s=r,o=s.state;return{hasActiveTools:!0,activeToolText:Kft(s.type,o),toolType:s.type}}}return{hasActiveTools:!1}}function Zft({children:e}){return l.jsx("pre",{className:"border-1 whitespace-pre-wrap rounded-md border border-muted p-3 text-xs",children:e})}function Xft(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Qft=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Jft=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eht={};function mU(e,t){return(eht.jsx?Jft:Qft).test(e)}const tht=/[ \t\n\f\r]/g;function nht(e){return typeof e=="object"?e.type==="text"?gU(e.value):!1:gU(e)}function gU(e){return e.replace(tht,"")===""}class xw{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}xw.prototype.normal={};xw.prototype.property={};xw.prototype.space=void 0;function Rde(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new xw(n,r,t)}function KR(e){return e.toLowerCase()}class ai{constructor(t,n){this.attribute=n,this.property=t}}ai.prototype.attribute="";ai.prototype.booleanish=!1;ai.prototype.boolean=!1;ai.prototype.commaOrSpaceSeparated=!1;ai.prototype.commaSeparated=!1;ai.prototype.defined=!1;ai.prototype.mustUseProperty=!1;ai.prototype.number=!1;ai.prototype.overloadedBoolean=!1;ai.prototype.property="";ai.prototype.spaceSeparated=!1;ai.prototype.space=void 0;let rht=0;const gn=np(),ss=np(),ZR=np(),gt=np(),Nr=np(),mm=np(),di=np();function np(){return 2**++rht}const XR=Object.freeze(Object.defineProperty({__proto__:null,boolean:gn,booleanish:ss,commaOrSpaceSeparated:di,commaSeparated:mm,number:gt,overloadedBoolean:ZR,spaceSeparated:Nr},Symbol.toStringTag,{value:"Module"})),s2=Object.keys(XR);class n$ extends ai{constructor(t,n,r,s){let o=-1;if(super(t,n),bU(this,"space",s),typeof r=="number")for(;++o<s2.length;){const i=s2[o];bU(this,s2[o],(r&XR[i])===XR[i])}}}n$.prototype.defined=!0;function bU(e,t,n){n&&(e[t]=n)}function pb(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new n$(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[KR(r)]=r,n[KR(o.attribute)]=r}return new xw(t,n,e.space)}const Fde=pb({properties:{ariaActiveDescendant:null,ariaAtomic:ss,ariaAutoComplete:null,ariaBusy:ss,ariaChecked:ss,ariaColCount:gt,ariaColIndex:gt,ariaColSpan:gt,ariaControls:Nr,ariaCurrent:null,ariaDescribedBy:Nr,ariaDetails:null,ariaDisabled:ss,ariaDropEffect:Nr,ariaErrorMessage:null,ariaExpanded:ss,ariaFlowTo:Nr,ariaGrabbed:ss,ariaHasPopup:null,ariaHidden:ss,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Nr,ariaLevel:gt,ariaLive:null,ariaModal:ss,ariaMultiLine:ss,ariaMultiSelectable:ss,ariaOrientation:null,ariaOwns:Nr,ariaPlaceholder:null,ariaPosInSet:gt,ariaPressed:ss,ariaReadOnly:ss,ariaRelevant:null,ariaRequired:ss,ariaRoleDescription:Nr,ariaRowCount:gt,ariaRowIndex:gt,ariaRowSpan:gt,ariaSelected:ss,ariaSetSize:gt,ariaSort:null,ariaValueMax:gt,ariaValueMin:gt,ariaValueNow:gt,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Pde(e,t){return t in e?e[t]:t}function Ode(e,t){return Pde(e,t.toLowerCase())}const sht=pb({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:mm,acceptCharset:Nr,accessKey:Nr,action:null,allow:null,allowFullScreen:gn,allowPaymentRequest:gn,allowUserMedia:gn,alt:null,as:null,async:gn,autoCapitalize:null,autoComplete:Nr,autoFocus:gn,autoPlay:gn,blocking:Nr,capture:null,charSet:null,checked:gn,cite:null,className:Nr,cols:gt,colSpan:null,content:null,contentEditable:ss,controls:gn,controlsList:Nr,coords:gt|mm,crossOrigin:null,data:null,dateTime:null,decoding:null,default:gn,defer:gn,dir:null,dirName:null,disabled:gn,download:ZR,draggable:ss,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:gn,formTarget:null,headers:Nr,height:gt,hidden:ZR,high:gt,href:null,hrefLang:null,htmlFor:Nr,httpEquiv:Nr,id:null,imageSizes:null,imageSrcSet:null,inert:gn,inputMode:null,integrity:null,is:null,isMap:gn,itemId:null,itemProp:Nr,itemRef:Nr,itemScope:gn,itemType:Nr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:gn,low:gt,manifest:null,max:null,maxLength:gt,media:null,method:null,min:null,minLength:gt,multiple:gn,muted:gn,name:null,nonce:null,noModule:gn,noValidate:gn,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:gn,optimum:gt,pattern:null,ping:Nr,placeholder:null,playsInline:gn,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:gn,referrerPolicy:null,rel:Nr,required:gn,reversed:gn,rows:gt,rowSpan:gt,sandbox:Nr,scope:null,scoped:gn,seamless:gn,selected:gn,shadowRootClonable:gn,shadowRootDelegatesFocus:gn,shadowRootMode:null,shape:null,size:gt,sizes:null,slot:null,span:gt,spellCheck:ss,src:null,srcDoc:null,srcLang:null,srcSet:null,start:gt,step:null,style:null,tabIndex:gt,target:null,title:null,translate:null,type:null,typeMustMatch:gn,useMap:null,value:ss,width:gt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Nr,axis:null,background:null,bgColor:null,border:gt,borderColor:null,bottomMargin:gt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:gn,declare:gn,event:null,face:null,frame:null,frameBorder:null,hSpace:gt,leftMargin:gt,link:null,longDesc:null,lowSrc:null,marginHeight:gt,marginWidth:gt,noResize:gn,noHref:gn,noShade:gn,noWrap:gn,object:null,profile:null,prompt:null,rev:null,rightMargin:gt,rules:null,scheme:null,scrolling:ss,standby:null,summary:null,text:null,topMargin:gt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:gt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:gn,disableRemotePlayback:gn,prefix:null,property:null,results:gt,security:null,unselectable:null},space:"html",transform:Ode}),oht=pb({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:di,accentHeight:gt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:gt,amplitude:gt,arabicForm:null,ascent:gt,attributeName:null,attributeType:null,azimuth:gt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:gt,by:null,calcMode:null,capHeight:gt,className:Nr,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:gt,diffuseConstant:gt,direction:null,display:null,dur:null,divisor:gt,dominantBaseline:null,download:gn,dx:null,dy:null,edgeMode:null,editable:null,elevation:gt,enableBackground:null,end:null,event:null,exponent:gt,externalResourcesRequired:null,fill:null,fillOpacity:gt,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:mm,g2:mm,glyphName:mm,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:gt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:gt,horizOriginX:gt,horizOriginY:gt,id:null,ideographic:gt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:gt,k:gt,k1:gt,k2:gt,k3:gt,k4:gt,kernelMatrix:di,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:gt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:gt,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:gt,overlineThickness:gt,paintOrder:null,panose1:null,path:null,pathLength:gt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Nr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:gt,pointsAtY:gt,pointsAtZ:gt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:di,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:di,rev:di,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:di,requiredFeatures:di,requiredFonts:di,requiredFormats:di,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:gt,specularExponent:gt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:gt,strikethroughThickness:gt,string:null,stroke:null,strokeDashArray:di,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:gt,strokeOpacity:gt,strokeWidth:null,style:null,surfaceScale:gt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:di,tabIndex:gt,tableValues:null,target:null,targetX:gt,targetY:gt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:di,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:gt,underlineThickness:gt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:gt,values:null,vAlphabetic:gt,vMathematical:gt,vectorEffect:null,vHanging:gt,vIdeographic:gt,version:null,vertAdvY:gt,vertOriginX:gt,vertOriginY:gt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:gt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Pde}),Lde=pb({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),$de=pb({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ode}),zde=pb({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),iht={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},aht=/[A-Z]/g,xU=/-[a-z]/g,lht=/^data[-\w.:]+$/i;function cht(e,t){const n=KR(t);let r=t,s=ai;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&lht.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(xU,dht);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!xU.test(o)){let i=o.replace(aht,uht);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}s=n$}return new s(r,t)}function uht(e){return"-"+e.toLowerCase()}function dht(e){return e.charAt(1).toUpperCase()}const fht=Rde([Fde,sht,Lde,$de,zde],"html"),r$=Rde([Fde,oht,Lde,$de,zde],"svg");function hht(e){return e.join(" ").trim()}var s$={},yU=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,pht=/\n/g,mht=/^\s*/,ght=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,bht=/^:\s*/,xht=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,yht=/^[;\s]*/,vht=/^\s+|\s+$/g,wht=`
1378
+ Defaulting to \`null\`.`}var _de=Sde,Ift=Nde;const Q3=Q.forwardRef(({className:e,value:t,...n},r)=>l.jsx(_de,{ref:r,className:m.cn("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...n,children:l.jsx(Ift,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Q3.displayName=_de.displayName;function Dft({files:e,onRemove:t,showRemove:n=!0,className:r=""}){if(e.length===0)return null;const s=o=>hb.includes(o)?Ame:o.includes("pdf")||o.includes("text")?wi:o.includes("javascript")||o.includes("typescript")||o.includes("python")||o.includes("sql")?SC:Fme;return l.jsx("div",{className:`flex flex-wrap gap-1.5 ${r}`,children:e.map(o=>{const i=s(o.type);return l.jsxs("div",{className:"group inline-flex h-7 items-center gap-1.5 rounded-control border border-border/60 bg-background px-1.5 text-[11px]",children:[l.jsx("span",{className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] bg-muted",children:l.jsx(i,{className:"h-2.5 w-2.5 text-muted-foreground"})}),l.jsx("span",{className:"max-w-[140px] truncate text-foreground/85",children:o.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:V0(o.size)}),o.uploadProgress!==void 0&&o.uploadProgress<100&&l.jsx(Q3,{value:o.uploadProgress,className:"h-0.5 w-12 shrink-0"}),n&&t&&l.jsx("button",{type:"button",onClick:()=>t(o.id),className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":`Remove ${o.name}`,children:l.jsx(m.X,{className:"h-3 w-3"})})]},o.id)})})}function Mft({file:e,className:t=""}){return hb.includes(e.type)&&e.preview?l.jsxs("div",{className:`inline-block ${t}`,children:[l.jsx("img",{src:e.preview,alt:e.name,className:"max-h-64 max-w-full rounded-card border border-border"}),l.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.name," • ",V0(e.size)]})]}):l.jsxs("div",{className:`inline-flex items-center gap-1.5 rounded-control border border-border/60 bg-muted/30 px-2 py-1 ${t}`,children:[l.jsx(wi,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-[12px] text-foreground/85",children:e.name}),l.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:V0(e.size)})]})}function Aft({children:e,onFilesDropped:t,disabled:n=!1,currentFileCount:r=0,className:s}){const[o,i]=v.useState(!1),a=v.useCallback(f=>{f.preventDefault(),f.stopPropagation(),n||i(!0)},[n]),c=v.useCallback(f=>{f.preventDefault(),f.stopPropagation();const h=f.currentTarget.getBoundingClientRect(),p=f.clientX,g=f.clientY;(p<h.left||p>=h.right||g<h.top||g>=h.bottom)&&i(!1)},[]),u=v.useCallback(f=>{f.preventDefault(),f.stopPropagation()},[]),d=v.useCallback(async f=>{if(f.preventDefault(),f.stopPropagation(),i(!1),n)return;const h=Array.from(f.dataTransfer.files);if(h.length===0)return;const p=lc-r;if(h.length>p){at.error(`You can only attach ${lc} files per message. You have ${p} slot(s) remaining.`);return}const{valid:g,errors:b}=vde(h);if(b.forEach(({file:x,error:y})=>{at.error(`${x.name}: ${y}`)}),g.length>0)try{const x=await Promise.all(g.map(y=>K3(y)));t(x),at.success(`${x.length} file(s) attached successfully`)}catch(x){console.error("Failed to process files:",x),at.error("Failed to process one or more files")}},[n,r,t]);return l.jsxs("div",{className:m.cn("relative",s),onDragEnter:a,onDragLeave:c,onDragOver:u,onDrop:d,children:[e,o&&!n&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-50 flex items-center justify-center rounded-control border-2 border-dashed border-primary bg-primary/5 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2",children:[l.jsx(m.Upload,{className:"h-8 w-8 text-primary"}),l.jsx("p",{className:"text-sm font-medium text-primary",children:"Drop files here to upload"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[lc-r," slot(s) available"]})]})})]})}function Rft(e,t,n){switch(e){case"none":return!1;case"include":return n.includes(t);case"exclude":return!n.includes(t);case"all":default:return!0}}function Fft({mode:e,currentDomainId:t,scopedDomainIds:n,hasSelectedEntities:r}){return e==="all"?!1:e==="none"?!!t||r:t?!Rft(e,t,n):r}function jde(e){const{tokenProps:t}=Ct(),n=m.useDashboardStore(c=>c.authToken)||e;m.useEditorStore(c=>c.selectedConnectionId),m.useEditorStore(c=>{var u,d;return(d=(u=c==null?void 0:c.card)==null?void 0:u.dataSource)==null?void 0:d.connectionId});const{refetch:r,isPending:s,data:o,isLoading:i,isError:a}=$n({queryKey:["semantic-domains"],queryFn:()=>m.getRequest(`${t.apiServiceUrl}/v1/domains`,(n==null?void 0:n.accessToken)||""),enabled:!!(n!=null&&n.accessToken)});return{isPending:s,error:a,semanticDomainsData:o,semanticDomains:(o==null?void 0:o.domains)||[],isSemanticDomainsLoading:i,isSemanticDomainsError:a,refetchSemanticDomains:r}}function Pft({domainAccess:e,search:t,scopeDomainId:n,selectedEntities:r,onSelectionChange:s}){const{semanticDomains:o,isSemanticDomainsLoading:i}=jde(),a=v.useMemo(()=>Lft(o,e),[o,e]),c=v.useMemo(()=>n?a.filter(d=>d.id===n):a,[a,n]);if(i&&c.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading semantic domains…"});if(c.length===0)return null;const u=!!n;return l.jsxs("div",{children:[l.jsx(Ede,{label:"Semantic Domains"}),c.map(d=>l.jsx(Oft,{domain:d,search:t,forceExpanded:u,selectedEntities:r,onSelectionChange:s},d.id))]})}function Oft({domain:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:s}){const[o,i]=v.useState(!1),a=o||t.length>0||!!n,{datasets:c,isPending:u}=ENe(a?e.id:void 0),d=v.useMemo(()=>{if(!t)return c;const w=t.trim().toLowerCase();return c.filter(C=>`${C.label??""} ${C.name??""} ${C.description??""}`.toLowerCase().includes(w))},[c,t]),f=t.length>0&&d.length>0,h=o||f||!!n,p=c.length,g=v.useMemo(()=>d.filter(w=>r.some(C=>ir(C,mS(w)))).length,[d,r]),b=v.useMemo(()=>d.map(mS),[d]),x=b.length>0&&b.every(w=>r.some(C=>ir(C,w))),y=()=>{if(b.length===0)return;if(x){s(r.filter(C=>!b.some(N=>ir(C,N))));return}const w=[...r];for(const C of b)w.some(N=>ir(N,C))||w.push(C);s(w)},S=w=>{const C=mS(w),N=r.some(k=>ir(k,C));s(N?r.filter(k=>!ir(k,C)):[...r,C])};return t.length>0&&!f&&!u?null:l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center rounded-[4px] px-3 py-1.5 transition-colors hover:bg-muted/50",children:[l.jsxs("button",{type:"button",onClick:()=>i(w=>!w),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[l.jsx(mr,{className:m.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",h&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:e.label||e.name}),p>0&&l.jsxs("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:["· ",p," dataset",p===1?"":"s"," · curated"]})]}),h&&!u&&b.length>0&&l.jsx("button",{type:"button",onClick:y,className:"ml-2 shrink-0 rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-background hover:text-foreground",children:x?"Clear":"Select all"}),l.jsx("span",{className:"ml-auto font-mono text-[10px] tabular-nums text-muted-foreground",children:g>0?g:""})]}),h&&l.jsx("ul",{className:"space-y-px pb-1",children:u&&c.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"Loading datasets…"}):d.length===0?l.jsx("li",{className:"px-9 py-1.5 text-[11px] text-muted-foreground",children:"No datasets in this domain."}):d.map(w=>{const C=mS(w),N=r.some(k=>ir(k,C));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded-[4px] px-9 py-1.5 transition-colors hover:bg-muted/40",children:[l.jsx(zn,{checked:N,onCheckedChange:()=>S(w),className:"mt-[3px] h-3.5 w-3.5 shrink-0"}),l.jsx(ti,{className:"mt-[3px] h-3 w-3 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground",children:w.label||w.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:w.type==="virtual"?"virtual":"dataset"})]}),w.description&&l.jsx("p",{className:"mt-0.5 text-[11px] leading-[1.4] text-muted-foreground",children:w.description})]})]})},w.id)})})]})}function Ede({label:e}){return l.jsx("div",{className:"px-3 pb-1.5 pt-2.5",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})})}function Lft(e,t){if(!t||t.mode==="all")return e;const n=new Set(t.domainIds??[]);return t.mode==="include"?e.filter(r=>n.has(r.id)):t.mode==="exclude"?e.filter(r=>!n.has(r.id)):[]}function mS(e){return{id:e.id,datasetType:e.type,name:e.name||e.table,label:e.label,domainId:e.domainId,description:e.description,database:e.database,schema:e.schema,table:e.table,type:"dataset",connectionId:e.connectionId,connectionType:e.connectionType,dialect:e.dialect,datamodelId:e.datamodelId,sql:e.sql}}function $ft({search:e,scopeConnectionId:t,selectedEntities:n,onSelectionChange:r}){const{connections:s,isConnectionsLoading:o}=Qc(),i=v.useMemo(()=>t?s.filter(c=>c.id===t):s,[s,t]);if(o&&i.length===0)return l.jsx("div",{className:"px-3 py-4 text-[11px] text-muted-foreground",children:"Loading connections…"});if(i.length===0)return null;const a=!!t;return l.jsxs("div",{children:[l.jsx(Ede,{label:"Direct Sources"}),i.map(c=>l.jsx(zft,{connection:c,search:e,forceExpanded:a,selectedEntities:n,onSelectionChange:r},c.id))]})}function zft({connection:e,search:t,forceExpanded:n,selectedEntities:r,onSelectionChange:s}){var g;const[o,i]=v.useState(!1),a=o||t.length>0||!!n,c=((g=e.capabilities)==null?void 0:g.path)??[],u=c.includes("database"),d=c.includes("schema"),f=e.type==="upload",h=e.type==="url",p=v.useMemo(()=>r.filter(b=>b.connectionId===e.id).length,[r,e.id]);return l.jsxs("div",{className:"border-b border-border/60 last:border-b-0",children:[l.jsxs("button",{type:"button",onClick:()=>i(b=>!b),className:"flex w-full items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-muted/40",children:[l.jsx(mr,{className:m.cn("h-3 w-3 shrink-0 text-muted-foreground transition-transform",a&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground/90",children:e.name}),l.jsxs("span",{className:"truncate text-[11px] text-muted-foreground",children:["· ",e.type]}),l.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground",children:p>0?p:""})]}),a&&l.jsxs(l.Fragment,{children:[f?l.jsx(Bft,{connection:e,selectedEntities:r,onSelectionChange:s}):h?l.jsx(Vft,{connection:e,selectedEntities:r,onSelectionChange:s}):u?l.jsx(Hft,{connection:e,requiresSchema:d,search:t,selectedEntities:r,onSelectionChange:s}):d?l.jsx(Tde,{connection:e,databaseName:"",search:t,selectedEntities:r,onSelectionChange:s}):l.jsx(J3,{connection:e,databaseName:"",schemaName:"",search:t,selectedEntities:r,onSelectionChange:s}),!f&&!h&&l.jsx(Uft,{connection:e,search:t,selectedEntities:r,onSelectionChange:s})]})]})}function Bft({connection:e,selectedEntities:t,onSelectionChange:n}){const r=`upload-source-${e.id}`,s=t.filter(a=>a.connectionId===e.id&&(a.type==="upload"||a.type==="file")),o=a=>{if(!(a!=null&&a.length))return;const c=Array.from(a).map(u=>({id:`file-${Date.now()}-${Math.random()}`,name:u.name,type:"upload",connectionId:e.id,connectionType:e.type,label:u.name,description:`Uploaded ${new Date().toLocaleString()}`,originalName:u.name,file:u}));n([...t,...c])},i=a=>{n(t.filter(c=>!("id"in c&&c.id===a&&c.connectionId===e.id&&(c.type==="upload"||c.type==="file"))))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"rounded-[6px] border border-dashed border-border bg-muted/20 p-4 text-center",children:[l.jsx(m.Upload,{className:"mx-auto mb-2 h-5 w-5 text-muted-foreground"}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Add CSV, JSON, or Excel files."}),l.jsx("input",{id:r,type:"file",multiple:!0,className:"hidden",onChange:a=>o(a.target.files),accept:".csv,.json,.xlsx,.xls"}),l.jsx(m.Button,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-7 text-[12px]",onClick:()=>{var a;return(a=document.getElementById(r))==null?void 0:a.click()},children:"Select files"})]}),s.length>0&&l.jsx("ul",{className:"space-y-1",children:s.map(a=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(wi,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px]",children:a.originalName||a.name}),l.jsx("button",{type:"button","aria-label":`Remove ${a.originalName||a.name}`,onClick:()=>i(a.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-3 w-3"})})]},a.id))})]})}function Vft({connection:e,selectedEntities:t,onSelectionChange:n}){const[r,s]=v.useState(""),[o,i]=v.useState(""),[a,c]=v.useState("api"),u=t.filter(h=>h.connectionId===e.id&&h.type==="url"),d=()=>{const h=r.trim(),p=o.trim();if(!h||!p)return;const g={id:`url-${Date.now()}-${Math.random()}`,name:h,type:"url",connectionId:e.id,connectionType:e.type,label:h,description:`URL source of type ${a}`,originalName:h,url:p,sourceType:a};n([...t,g]),s(""),i(""),c("api")},f=h=>{n(t.filter(p=>!("id"in p&&p.id===h&&p.connectionId===e.id&&p.type==="url")))};return l.jsxs("div",{className:"space-y-2 px-8 py-2",children:[l.jsxs("div",{className:"space-y-2 rounded-[6px] border border-border bg-muted/20 p-3",children:[l.jsx(m.Input,{value:r,onChange:h=>s(h.target.value),placeholder:"Source name",className:"h-7 text-[12px]"}),l.jsx(m.Input,{value:o,onChange:h=>i(h.target.value),placeholder:"https://api.example.com/data",className:"h-7 text-[12px]"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("select",{value:a,onChange:h=>c(h.target.value),className:"h-7 flex-1 rounded-control border border-input bg-background px-2 text-[12px]",children:[l.jsx("option",{value:"api",children:"API endpoint"}),l.jsx("option",{value:"csv",children:"CSV file"}),l.jsx("option",{value:"json",children:"JSON file"})]}),l.jsxs(m.Button,{type:"button",size:"sm",className:"h-7 text-[12px]",disabled:!r.trim()||!o.trim(),onClick:d,children:[l.jsx(pr,{className:"mr-1 h-3 w-3"}),"Add"]})]})]}),u.length>0&&l.jsx("ul",{className:"space-y-1",children:u.map(h=>l.jsxs("li",{className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 py-1.5",children:[l.jsx(mg,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-[12px]",children:h.name}),l.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:h.url})]}),l.jsx("button",{type:"button","aria-label":`Remove ${h.name}`,onClick:()=>f(h.id),className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-3 w-3"})})]},h.id))})]})}function Hft({connection:e,requiresSchema:t,search:n,selectedEntities:r,onSelectionChange:s}){var a;const o=fE("/v1/databases",{connection_id:e.id},["databases",e.id]);if(o.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading databases…"});const i=((a=o.data)==null?void 0:a.databases)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No databases."}):l.jsx("div",{children:i.map(c=>l.jsx(Ide,{label:c.database_name,indentLevel:1,search:n,renderChildren:u=>u&&(t?l.jsx(Tde,{connection:e,databaseName:c.database_name,search:n,selectedEntities:r,onSelectionChange:s}):l.jsx(J3,{connection:e,databaseName:c.database_name,schemaName:"",search:n,selectedEntities:r,onSelectionChange:s}))},c.database_name))})}function Tde({connection:e,databaseName:t,search:n,selectedEntities:r,onSelectionChange:s}){var a;const o=fE("/v1/schemas",{connection_id:e.id,database_name:t||"NA"},["schemas",e.id,t],!!e.id);if(o.isLoading)return l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"Loading schemas…"});const i=((a=o.data)==null?void 0:a.schemas)??[];return i.length===0?l.jsx("div",{className:"px-8 py-1.5 text-[11px] text-muted-foreground",children:"No schemas."}):l.jsx("div",{children:i.map(c=>l.jsx(Ide,{label:c.schema_name,indentLevel:t?2:1,search:n,renderChildren:u=>u&&l.jsx(J3,{connection:e,databaseName:t,schemaName:c.schema_name,search:n,selectedEntities:r,onSelectionChange:s})},c.schema_name))})}function J3({connection:e,databaseName:t,schemaName:n,search:r,selectedEntities:s,onSelectionChange:o}){const i=fE("/v1/tables",{connection_id:e.id,database_name:t||void 0,schema_name:n||void 0},["tables",e.id,t,n]),a=v.useMemo(()=>{var b;const p=((b=i.data)==null?void 0:b.tables)??[];if(!r)return p;const g=r.trim().toLowerCase();return p.filter(x=>x.table_name.toLowerCase().includes(g))},[i.data,r]),c=(p,g)=>({connectionId:e.id,connectionType:e.type,type:"table",dialect:e.dialect,database:t||void 0,schema:n||void 0,name:p,dbObjectType:g==null?void 0:g.toLowerCase()});if(i.isLoading)return l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"Loading tables…"});if(a.length===0)return r?null:l.jsx("div",{className:"px-10 py-1.5 text-[11px] text-muted-foreground",children:"No tables."});const u=a.map(p=>c(p.table_name,p.table_type)),d=u.length>0&&u.every(p=>s.some(g=>ir(g,p))),f=(p,g)=>{const b=c(p,g),x=s.some(y=>ir(y,b));o(x?s.filter(y=>!ir(y,b)):[...s,b])},h=()=>{if(u.length===0)return;if(d){o(s.filter(g=>!u.some(b=>ir(g,b))));return}const p=[...s];for(const g of u)p.some(b=>ir(b,g))||p.push(g);o(p)};return l.jsxs("ul",{children:[l.jsxs("li",{className:"flex items-center justify-between gap-2 py-1 pl-12 pr-4",children:[l.jsxs("span",{className:"text-[10.5px] font-medium uppercase tracking-[0.06em] text-muted-foreground",children:[a.length," table",a.length===1?"":"s"]}),l.jsx("button",{type:"button",onClick:h,className:"rounded-[3px] px-1.5 py-0.5 text-[10.5px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground",children:d?"Clear":"Select all"})]}),a.map(p=>{const g=c(p.table_name,p.table_type),b=s.some(x=>ir(x,g));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(zn,{checked:b,onCheckedChange:()=>f(p.table_name,p.table_type),className:"h-3.5 w-3.5 shrink-0"}),l.jsx(m.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:p.table_name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:p.table_type??"table"})]})]})},p.table_name)})]})}function Uft({connection:e,search:t,selectedEntities:n,onSelectionChange:r}){const s=fE("/v1/datamodels",{connection_id:e.id},["datamodels",e.id]),o=v.useMemo(()=>{var u;const a=((u=s.data)==null?void 0:u.datamodels)??[];if(!t)return a;const c=t.trim().toLowerCase();return a.filter(d=>`${d.label??""} ${d.name??""} ${d.description??""}`.toLowerCase().includes(c))},[s.data,t]);if(s.isLoading||o.length===0)return null;const i=a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>ir(d,c));r(u?n.filter(d=>!ir(d,c)):[...n,c])};return l.jsxs("div",{children:[l.jsx("div",{className:"px-8 pb-1 pt-2",children:l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data models"})}),l.jsx("ul",{children:o.map(a=>{const c={id:a.id,name:a.name,label:a.label||"",description:a.description||"",connectionId:e.id,connectionType:e.type,type:"model",dialect:a.dialect??e.dialect,database:a.database||"",schema:a.schema||""},u=n.some(d=>ir(d,c));return l.jsx("li",{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-2.5 py-1.5 pl-12 pr-4 transition-colors hover:bg-muted/40",children:[l.jsx(zn,{checked:u,onCheckedChange:()=>i(a),className:"mt-[2px] h-3.5 w-3.5 shrink-0"}),l.jsx(_me,{className:"mt-[2px] h-3.5 w-3.5 shrink-0 text-muted-foreground",strokeWidth:1.75}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-baseline gap-1.5",children:[l.jsx("span",{className:"truncate text-[13px] text-foreground/90",children:a.label||a.name}),l.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-[0.06em] text-muted-foreground/70",children:"model"})]}),a.description&&l.jsx("p",{className:"mt-0.5 line-clamp-2 text-[11px] leading-[1.4] text-muted-foreground",children:a.description})]})]})},a.id)})})]})}function Ide({label:e,indentLevel:t,search:n,renderChildren:r}){const[s,o]=v.useState(!1),i=s||n.length>0,a=t===1?"pl-8":"pl-10";return l.jsxs("div",{children:[l.jsxs("button",{type:"button",onClick:()=>o(c=>!c),className:m.cn("flex h-6 w-full items-center gap-1.5 pr-4 text-left transition-colors hover:bg-muted/40",a),children:[l.jsx(mr,{className:m.cn("h-2.5 w-2.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),strokeWidth:1.75}),l.jsx("span",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e})]}),r(i)]})}function fE(e,t,n,r=!0){const{tokenProps:s}=Ct(),o=m.useDashboardStore(a=>a.authToken),i=v.useMemo(()=>Object.fromEntries(Object.entries(t).filter(([,a])=>a!==void 0)),[t]);return $n({queryKey:n,queryFn:()=>m.getRequest(`${s.apiServiceUrl}${e}`,(o==null?void 0:o.accessToken)||"",i),enabled:r&&!!(o!=null&&o.accessToken)&&Object.values(i).every(a=>a.length>0)})}function dU(e){return e.type==="dataset"&&e.label||e.name}function qft({selectedEntities:e,onDeselectEntity:t}){return e.length===0?null:l.jsx("div",{className:"flex flex-wrap gap-1",children:e.map((n,r)=>l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-control border border-input bg-muted/50 py-0.5 pl-1.5 pr-0.5 text-[11px] text-foreground/80",children:[l.jsx("span",{className:"max-w-[180px] truncate",children:dU(n)}),l.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),t(n)},"aria-label":`Remove ${dU(n)}`,className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-2.5 w-2.5"})})]},`${n.type}-${n.name}-${r}`))})}function fU(e){const t=new Set;for(const n of e||[])"domainId"in n&&typeof n.domainId=="string"&&t.add(n.domainId);if(t.size===1)return[...t][0]}function r2(e){if(e!=null&&e.length)return e.every(t=>t.type==="dataset")?"semanticDomain":e.every(t=>t.type==="url")?"url":e.every(t=>t.type==="upload"||t.type==="file")?"upload":"database"}function e$({open:e,onOpenChange:t,dataSource:n,dialogMode:r,incomingSelectedEntities:s,onSaveSelectedEntities:o,saveAsDashboardDefault:i=!1}){var se,xe;const{tokenProps:a}=Ct(),c=a.config,u=a.semanticDomainAccess||Ohe.DEFAULT_SEMANTIC_DOMAIN_ACCESS,[d,f]=v.useState([]),[h,p]=v.useState(void 0),[g,b]=v.useState(""),[x,y]=v.useState("all"),[S,w]=v.useState(void 0),C=v.useRef(!1),{updateDataSource:N}=m.useEditorActions(),k=m.useDashboardStore(ie=>ie.isVisualEditing),_=m.useDashboardStore(ie=>ie.dashboard.aiContext),{setAiContext:j}=m.useDashboardActions(),T=u.mode,E=(c==null?void 0:c.showDirectSource)!==!1,I=T==="include"||T==="exclude"||!E,D=T!=="all",A=E&&!I,R=I?"semanticDomain":n.mode,F=r==="dataSource"&&!E,H=T==="include"&&(((se=u.domainIds)==null?void 0:se.length)||0)===1?(xe=u.domainIds)==null?void 0:xe[0]:void 0,B=v.useCallback(ie=>{C.current=!0,N({...n,connectionId:(n==null?void 0:n.connectionId)||"",connectionType:(n==null?void 0:n.connectionType)||"",mode:ie,selectedEntities:(n==null?void 0:n.selectedEntities)||[],...ie!=="semanticDomain"&&{semanticDomainId:void 0}})},[n,N]),U=v.useCallback(ie=>{N({...n,...ie})},[n,N]),W=v.useCallback(ie=>{if(r==="aiContext"){"semanticDomainId"in ie&&p(ie.semanticDomainId);return}U(ie)},[r,U]),O=r==="aiContext"?h:n.semanticDomainId;r==="aiContext"&&{...n},v.useEffect(()=>{if(r==="aiContext"&&!e)return;if(I&&n.mode!=="semanticDomain"&&r==="dataSource"){B("semanticDomain");return}if(!D||R!=="semanticDomain")return;const ie=O,Ae=u.domainIds??[],oe=r==="aiContext"?d:n.selectedEntities,ge=((oe==null?void 0:oe.length)??0)>0,fe=((d==null?void 0:d.length)??0)>0;Fft({mode:T,currentDomainId:ie,scopedDomainIds:Ae,hasSelectedEntities:ge})&&(r==="dataSource"?U({semanticDomainId:void 0,selectedEntities:[]}):p(void 0),fe&&f([]))},[I,D,R,n.mode,O,n.selectedEntities,r,h,d,e,u.domainIds,T,E,U,B]),v.useEffect(()=>{H&&!O&&W({semanticDomainId:H})},[H,O,W]),v.useEffect(()=>{if(!e){C.current=!1,b(""),w(void 0),y(I?"semantic":"all");return}if(C.current)return;f([...s||[]]);const ie=r==="aiContext"?fU(s):void 0;p(n.semanticDomainId||ie),w(r2(s))},[e,r,s,n.semanticDomainId,I]);const Z=ie=>{C.current=!0,f(d.filter(Ae=>!ir(Ae,ie)))},Y=v.useCallback((ie,Ae)=>{C.current=!0,f(ie),w(Ae??r2(ie))},[]),M=()=>{var Ae,oe;if(r==="aiContext"){if(k&&N(n),i){const ge={..._,selectedEntities:d,mode:d.length>0?"fixed":"auto"};j(ge)}o==null||o(d),t(!1);return}const ie=r2(d)??S??R;if(ie==="semanticDomain"){const ge=fU(d)||h||n.semanticDomainId,fe=((Ae=d==null?void 0:d[0])==null?void 0:Ae.connectionId)||n.connectionId,me=((oe=d==null?void 0:d[0])==null?void 0:oe.connectionType)||n.connectionType;N({...n,mode:"semanticDomain",semanticDomainId:ge,connectionId:fe,connectionType:me,selectedEntities:d})}else if(ie==="upload"||ie==="url"){const ge=d==null?void 0:d[0];N({...n,mode:ie,semanticDomainId:void 0,connectionId:(ge==null?void 0:ge.connectionId)||n.connectionId,connectionType:(ge==null?void 0:ge.connectionType)||n.connectionType,selectedEntities:d})}else{const ge=d==null?void 0:d[0];N({...n,mode:"database",semanticDomainId:void 0,connectionId:(ge==null?void 0:ge.connectionId)||n.connectionId,connectionType:(ge==null?void 0:ge.connectionType)||n.connectionType,selectedEntities:d})}t(!1)},{semanticDomains:K}=jde(),{connections:L}=Qc(),$=ie=>{y(ie),ie==="semantic"||ie.startsWith("domain:")?n.mode!=="semanticDomain"&&B("semanticDomain"):(ie==="direct"||ie.startsWith("conn:"))&&n.mode==="semanticDomain"&&B("database")},z=x.startsWith("domain:"),V=x.startsWith("conn:"),P=z?x.slice(7):void 0,q=V?x.slice(5):void 0,G=!A||x==="all"||x==="semantic"||z,X=E&&!I&&(x==="all"||x==="direct"||V),J=((s==null?void 0:s.length)??0)>0,de=d.length===0&&!J,he=d.length===0&&J?"Clear":"Add",be=r==="aiContext"?"Data context":F?"Select dataset":"Add data",Se=r==="aiContext"?"Set the overall data scope for the dashboard":F?"Choose a curated dataset to analyze":"Search your semantic domains and connections";return l.jsx(Po,{open:e,onOpenChange:t,children:l.jsxs(mo,{showCloseButton:!1,className:"flex h-[560px] w-[620px] max-w-[620px] flex-col gap-0 overflow-hidden rounded-[6px] border border-border bg-popover p-0",children:[l.jsx(m.VisuallyHidden,{children:l.jsx(go,{children:be})}),l.jsxs("div",{className:"flex items-start justify-between border-b border-border px-4 py-2.5",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-[14px] font-semibold text-foreground",children:be}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:Se})]}),l.jsx("button",{type:"button",onClick:()=>t(!1),"aria-label":"Close",className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-[4px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-3.5 w-3.5"})})]}),l.jsxs("div",{className:"border-b border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[l.jsx(Ws,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:g,onChange:ie=>b(ie.target.value),placeholder:"Search datasets, tables, views, models",className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground/60 focus:outline-none"}),g&&l.jsx("button",{type:"button",onClick:()=>b(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(m.X,{className:"h-3 w-3"})})]}),A&&l.jsx("div",{className:"-mx-4 mt-2 overflow-x-auto px-4 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:l.jsxs("div",{className:"flex w-max items-center gap-1",children:[l.jsx(cx,{label:"All",active:x==="all",onClick:()=>$("all")}),(K.length>0||L.length>0)&&l.jsxs(l.Fragment,{children:[l.jsx(cx,{label:"Semantic",active:x==="semantic",onClick:()=>$("semantic")}),l.jsx(cx,{label:"Direct",active:x==="direct",onClick:()=>$("direct")}),l.jsx("span",{className:"shrink-0 px-0.5 text-muted-foreground/50",children:"·"})]}),K.map(ie=>l.jsx(cx,{label:ie.label||ie.name,active:x===`domain:${ie.id}`,onClick:()=>$(`domain:${ie.id}`)},`domain:${ie.id}`)),L.map(ie=>l.jsx(cx,{label:ie.name,active:x===`conn:${ie.id}`,onClick:()=>$(`conn:${ie.id}`)},`conn:${ie.id}`))]})})]}),l.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[G&&l.jsx(Pft,{domainAccess:u,search:g,scopeDomainId:P,selectedEntities:d,onSelectionChange:ie=>Y(ie,"semanticDomain")}),X&&l.jsx($ft,{search:g,scopeConnectionId:q,selectedEntities:d,onSelectionChange:ie=>Y(ie)})]}),l.jsxs("div",{className:"flex flex-col gap-0.5 border-t border-border px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:"Selected"}),l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["· ",d.length]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("button",{type:"button",onClick:()=>t(!1),className:"inline-flex h-7 items-center rounded-control px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Cancel"}),l.jsxs("button",{type:"button",onClick:M,disabled:de,className:m.cn("inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-2.5 text-[12px] font-medium text-primary-foreground transition-colors hover:bg-primary/90",de&&"cursor-not-allowed opacity-50 hover:bg-primary"),children:[l.jsx("span",{children:he}),d.length>0&&l.jsxs("span",{className:"font-mono tabular-nums text-primary-foreground/70",children:["· ",d.length]})]})]})]}),d.length>0&&l.jsx(qft,{selectedEntities:d,onDeselectEntity:Z})]})]})})}function cx({label:e,active:t,onClick:n}){return l.jsx("button",{type:"button",onClick:n,"aria-pressed":t,className:m.cn("inline-flex h-6 shrink-0 items-center whitespace-nowrap rounded-control px-2 text-[11px] font-medium transition-colors",t?"bg-primary text-primary-foreground hover:bg-primary/90":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:e})}const ug={connectionId:"",connectionType:"none",mode:"semanticDomain",selectedEntities:[]};function bk(e,t={}){const{size:n="h-4 w-4"}=t,r=n;switch(e){case"table":return l.jsx(TF,{className:r});case"view":return l.jsx(rv,{className:r});case"materialized view":return l.jsx(Mme,{className:r});case"model":return l.jsx(sv,{className:r});case"file":return l.jsx(wi,{className:r});case"dataset":return l.jsx(ti,{className:r});case"upload":return l.jsx(m.Upload,{className:r});case"url":return l.jsx(SF,{className:r});default:return l.jsx(mg,{className:r})}}const Gx=e=>e.name||e.name,Wft=e=>{const t=Gx(e),n="description"in e?e.description:"",r=e.database||"",s=e.schema||"",o=[e.type,r,s].filter(Boolean);return l.jsxs("div",{className:"max-w-[260px] space-y-1",children:[l.jsx("div",{className:"break-all font-mono text-[11px] font-medium leading-[1.35]",children:t}),n&&l.jsx("div",{className:"text-[11px] leading-[1.45] text-background/70",children:n}),o.length>0&&l.jsx("div",{className:"font-mono text-[10px] uppercase tracking-[0.06em] text-background/60",children:o.join(" · ")})]})};function Yft({entities:e,availableEntities:t,onRemoveEntity:n,onRemoveEntities:r,className:s}){const[o,i]=v.useState(!1),a=e.length>0,c=e.length>=3?e.slice(0,2):e,u=e.length>=3?e.slice(2):[],d=u.length>0;return l.jsx(m.TooltipProvider,{children:l.jsx("div",{className:s,children:a&&l.jsxs("div",{className:"flex flex-wrap gap-1",children:[c.map((f,h)=>{const p="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs(m.Tooltip,{children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group relative inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 font-mono text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",children:[l.jsx("span",{className:"grid h-3 w-3 place-items-center text-muted-foreground transition-colors group-hover:text-background/60",children:bk(f.type,{size:"h-3 w-3"})}),l.jsx("span",{className:"max-w-24 truncate",children:Gx(f)}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>n(f),"aria-label":`Remove ${Gx(f)}`,children:l.jsx(m.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(m.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,children:Wft(f)})]},p)}),d&&l.jsxs(m.Tooltip,{open:o,onOpenChange:i,children:[l.jsx(m.TooltipTrigger,{asChild:!0,children:l.jsxs("span",{className:"group inline-flex h-5 cursor-pointer items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-foreground/85 transition-colors hover:border-foreground hover:bg-foreground hover:text-background",onClick:()=>i(!0),children:[l.jsx(ja,{className:"h-3 w-3"}),l.jsxs("span",{children:[u.length," more"]}),l.jsx("button",{type:"button",className:"grid h-3 w-3 place-items-center rounded-[2px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground group-hover:text-background/70 group-hover:hover:bg-background/15 group-hover:hover:text-background",onClick:()=>r(u),"aria-label":"Remove all extra entities",children:l.jsx(m.X,{className:"h-2.5 w-2.5"})})]})}),l.jsx(m.TooltipContent,{side:"top",collisionPadding:8,sideOffset:6,className:"max-h-60 w-[260px] overflow-y-auto p-1.5",children:l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("div",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-background/60",children:"More entities"}),l.jsx("div",{className:"space-y-0.5",children:u.map(f=>{const h="id"in f?f.id:`${f.connectionId}-${f.name}`;return l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[3px] px-1 py-1 hover:bg-background/10",children:[l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-background/60",children:bk(f.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate font-mono text-[11px]",children:Gx(f)}),l.jsx("div",{className:"truncate text-[10px] text-background/60",children:[f.type,f.database].filter(Boolean).join(" · ")})]}),l.jsx("button",{type:"button",onClick:()=>{n(f),u.length===1&&i(!1)},className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-background/60 opacity-0 transition-opacity hover:bg-background/10 hover:text-background group-hover:opacity-100","aria-label":`Remove ${Gx(f)}`,children:l.jsx(m.X,{className:"h-2.5 w-2.5"})})]},h)})})]})})]})]})})})}const gS=e=>e.label||(e==null?void 0:e.name),hU=e=>"description"in e?e.description:`${e.type} from ${e.database||"database"}`;function Gft({isOpen:e,onSelect:t,onDeselect:n,onClose:r,availableEntities:s,selectedEntities:o,onTabComplete:i,onSelectAll:a,onRemoveAll:c,onAddContext:u}){const{tokenProps:d}=Ct(),f=(d==null?void 0:d.type)==="dashboard",[h,p]=v.useState(""),[g,b]=v.useState(""),x=s.filter(k=>{if(!h)return!0;const _=gS(k).toLowerCase(),j=(hU(k)||"").toLowerCase(),T=h.toLowerCase();return _.includes(T)||j.includes(T)});v.useEffect(()=>{e||(p(""),b(""))},[e]),v.useEffect(()=>{x.length>0&&!g&&b(gS(x[0]))},[x,g]);const y=()=>{if(!g)return;const k=x.find(_=>gS(_)===g);k&&(o.some(j=>"id"in k&&"id"in j?k.id===j.id:k.name===j.name&&k.connectionId===j.connectionId)||t(k),i(k),r())},S=k=>{(k.key==="Tab"||k.key==="Enter")&&(k.preventDefault(),y())};if(!e)return null;const w=k=>o.some(_=>"id"in k&&"id"in _?k.id===_.id:k.name===_.name&&k.connectionId===_.connectionId),C=o.length===s.length,N=o.length>0;return l.jsx(l.Fragment,{children:l.jsxs(qj,{shouldFilter:!1,value:g,onValueChange:b,onKeyDown:S,children:[s.length>0&&l.jsxs("div",{"cmdk-input-wrapper":"",className:"flex h-8 items-center gap-1.5 border-b border-border/60 px-2",children:[l.jsx(Ws,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx(Lo.Input,{placeholder:"Search entities",value:h,onValueChange:p,autoFocus:!0,className:"flex h-full min-w-0 flex-1 bg-transparent text-[12px] outline-none placeholder:text-muted-foreground/70 disabled:cursor-not-allowed disabled:opacity-50"}),!f&&l.jsxs("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),u==null||u()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[3px] border border-border/60 px-1.5 text-[10px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",children:[l.jsx(pr,{className:"h-2.5 w-2.5"}),"Add"]})]}),s.length>0&&l.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-2 py-1 text-[10px] text-muted-foreground",children:[l.jsxs("span",{children:[o.length," selected"]}),l.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[l.jsx("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),a==null||a()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},disabled:C,className:"hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:"Select all"}),N&&l.jsx("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),c==null||c()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"hover:text-foreground",children:"Clear"})]})]}),l.jsxs(Wj,{className:"max-h-60 min-h-[120px]",children:[l.jsx(Yj,{children:l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-4",children:[l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No entities found"}),!f&&l.jsxs("button",{type:"button",onClick:k=>{k.preventDefault(),k.stopPropagation(),u==null||u()},onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 px-2 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(pr,{className:"h-3 w-3"}),"Add datasets"]})]})}),l.jsx(Gj,{className:"p-0.5",children:x.map((k,_)=>{const j=w(k),T="id"in k?k.id:`${k.connectionId}-${k.name}`,E=gS(k);return l.jsxs(Kj,{value:E,onSelect:()=>{j?n==null||n(k):t(k)},onMouseDown:I=>{I.preventDefault(),I.stopPropagation()},className:m.cn("flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1.5 data-[selected=true]:bg-muted/60"),children:[l.jsx("span",{className:"grid h-3.5 w-3.5 shrink-0 place-items-center rounded-[3px] border border-border/60 bg-background",children:j&&l.jsx(m.Check,{className:"h-2.5 w-2.5 text-foreground"})}),l.jsx("span",{className:"grid h-3 w-3 shrink-0 place-items-center text-muted-foreground",children:bk(k.type,{size:"h-3 w-3"})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"truncate text-[12px] font-medium leading-tight text-foreground",children:E}),l.jsx("div",{className:"mt-0.5 truncate text-[10px] leading-tight text-muted-foreground",children:hU(k)})]})]},T)})})]})]})})}function GR({mode:e="full",compact:t=!1,inlineLayout:n=!1,inlineTriggerFirst:r=!1,syncOnOpen:s=!1,open:o,onOpenChange:i,onEntityMention:a,onEntityRemoved:c,onEntitiesRemoved:u,onSelectionChange:d,className:f,triggerClassName:h,triggerVariant:p="secondary",triggerLabel:g="Add entity",triggerIconOnly:b=!0,assistantType:x}){const[y,S]=v.useState(!1),[w,C]=v.useState(!1),N=o??y,k=o!==void 0,_=v.useRef(!1),T=m.useEditorStore(P=>P.card.dataSource)??ug,{selectedEntities:E,availableEntities:I,syncWithGlobalContext:D,setSelectedEntities:A,applyDashboardDefaultEntities:R,isEntitySelected:F}=Pj(x),H=e==="full"||e==="display",B=e==="full"||e==="trigger",U=v.useMemo(()=>b&&E.length>0?`Add entity (${E.length})`:g,[E.length,b,g]);v.useEffect(()=>{N&&!_.current&&s&&D(),_.current=N},[N,s,D]);const W=v.useCallback(P=>{k||S(P),i==null||i(P)},[k,i]),O=v.useCallback(P=>{const q=E.filter(G=>!ir(G,P));A(q),c==null||c(P),d==null||d(q)},[c,d,E,A]),Z=v.useCallback(P=>{if(P.length===0)return;const q=E.filter(G=>!P.some(X=>ir(G,X)));A(q),u==null||u(P),d==null||d(q)},[u,d,E,A]),Y=v.useCallback(P=>{const q=F(P)?E.filter(G=>!ir(G,P)):[...E,P];A(q),d==null||d(q)},[F,d,E,A]),M=v.useCallback(()=>{A(I),d==null||d(I)},[I,d,A]),K=v.useCallback(()=>{A([]),d==null||d([])},[d,A]),L=v.useCallback(P=>{x==="dashboard"?R():A(P),d==null||d(P)},[R,x,d,A]),$=v.useCallback(P=>{const q=E.some(G=>ir(G,P))?E:[...E,P];A(q),a==null||a(P),d==null||d(q),W(!1)},[a,d,E,W,A]),z=H?l.jsx(Yft,{className:m.cn(n?"contents":"space-y-2"),entities:E,availableEntities:I,onRemoveEntity:O,onRemoveEntities:Z}):null,V=B?l.jsxs(l.Fragment,{children:[l.jsxs(m.Popover,{open:N,onOpenChange:W,children:[l.jsx(m.PopoverTrigger,{asChild:!0,children:l.jsxs(m.Button,{variant:p,size:"xs",className:m.cn(t&&"h-6 gap-1.5 px-2 text-[11px] font-medium",h),title:g,children:[l.jsx(pW,{className:"h-3 w-3 text-muted-foreground"}),!b&&l.jsx("span",{children:U})]})}),l.jsx(m.PopoverContent,{className:m.cn("w-80 p-0",t&&"w-72"),align:"start",side:"top",sideOffset:8,onOpenAutoFocus:P=>P.preventDefault(),children:l.jsx(Gft,{isOpen:!0,onSelect:Y,onDeselect:Y,onClose:()=>W(!1),availableEntities:I,selectedEntities:E,onTabComplete:$,onSelectAll:M,onRemoveAll:K,onAddContext:()=>{W(!1),C(!0)}})})]}),l.jsx(e$,{incomingSelectedEntities:E,open:w,onOpenChange:C,dataSource:T,dialogMode:"aiContext",onSaveSelectedEntities:L,saveAsDashboardDefault:x==="dashboard"})]}):null;return l.jsx("div",{className:m.cn(n?"flex flex-wrap items-center gap-1":"",!n&&H?"space-y-2":"",f),children:n&&r?l.jsxs(l.Fragment,{children:[V,z]}):l.jsxs(l.Fragment,{children:[z,V]})})}const t$=v.forwardRef(({input:e,setInput:t,handleInputChange:n,handleSubmit:r,isLoading:s,stop:o,onFocus:i,status:a,assistantType:c},u)=>{const[d,f]=v.useState(!1),h=v.useRef(null),{queueMessage:p}=m.useQueueActions(),{addFileAttachment:g,removeFileAttachment:b,clearFileAttachments:x}=m.useFileActions(),y=m.useFileAttachments(c);v.useEffect(()=>{u&&"current"in u&&(u.current=h.current)},[u]);const S=v.useCallback(()=>{const D=h.current;if(D){if(!e||e.length===0){D.style.height="10px";return}D.style.height="auto";const A=Math.min(Math.max(D.scrollHeight,10),200);D.style.height=`${A}px`}},[e]);v.useEffect(()=>{S()},[S]),v.useEffect(()=>{const D=setTimeout(()=>{S()},0);return()=>clearTimeout(D)},[S]);const w=()=>{const D=e.trim();!D&&y.length===0||(a!=="ready"?(p(c,D,y),t(""),x(c)):r({preventDefault:()=>{}}))},C=D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),w()),D.key==="@"&&f(!0)},N=v.useCallback(D=>{const A=yft(D.nativeEvent);A.length>0&&(D.preventDefault(),A.forEach(async R=>{const F=await K3(R);g(c,F)}))},[g,c]),k=v.useCallback(D=>{D.forEach(A=>{g(c,A)})},[g,c]),_=v.useCallback(D=>{D.forEach(A=>{g(c,A)})},[g,c]),j=v.useCallback(D=>{b(c,D)},[b,c]),T=v.useCallback(D=>{const A=`@${D}`;e.includes(A)&&t(e.replace(A,"").replace(/\s{2,}/g," ").trim())},[e,t]),E=!e.trim()&&y.length===0,I=a!=="ready"&&!s;return l.jsxs(Aft,{onFilesDropped:k,currentFileCount:y.length,disabled:s,className:"space-y-2",children:[l.jsx(GR,{mode:"display",assistantType:c,onEntityRemoved:D=>{const A="label"in D?D.label:D.name;T(A)},onEntitiesRemoved:D=>{let A=e;D.forEach(R=>{const F="label"in R?R.label:R.name;A=A.replace(`@${F}`,"")}),A!==e&&t(A.replace(/\s{2,}/g," ").trim())}}),y.length>0&&l.jsx(Dft,{files:y,onRemove:j,showRemove:!s}),l.jsxs("div",{className:"rounded-control border border-border bg-background transition-colors focus-within:border-foreground/40",children:[l.jsx("textarea",{ref:h,value:e,onChange:n,onKeyDown:C,onPaste:N,onFocus:()=>{S(),i==null||i()},placeholder:I?"Will be queued":"Ask about this dashboard",className:"block max-h-[200px] min-h-[40px] w-full resize-none overflow-y-auto border-0 bg-transparent px-2.5 pb-1 pt-2 text-[13px] leading-[1.55] text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-0",style:{height:"40px"}}),l.jsxs("div",{className:"flex items-center gap-0.5 border-t border-border/60 px-1.5 py-1.5",children:[l.jsx(GR,{mode:"trigger",assistantType:c,syncOnOpen:c==="dashboard",open:d,onOpenChange:f,onEntityMention:D=>{var R;const A="label"in D?D.label:D.name;t(`${e}@${A} `),(R=h.current)==null||R.focus()},triggerVariant:"ghost",triggerIconOnly:!0,triggerClassName:"h-6 w-6 rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",triggerLabel:"Add entity"}),l.jsx(vft,{onFilesSelected:_,disabled:s,currentFileCount:y.length}),l.jsx("div",{className:"ml-auto"}),s?l.jsx("button",{type:"button",onClick:o,title:"Stop",className:"grid h-7 w-7 place-items-center rounded-control border border-border text-foreground transition-colors hover:bg-muted",children:l.jsx(jF,{className:"h-3 w-3 fill-current"})}):l.jsx("button",{type:"button",disabled:E,onClick:w,title:I?"Message will be queued":"Send",className:I?"grid h-7 w-7 place-items-center rounded-control border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40":"grid h-7 w-7 place-items-center rounded-control bg-foreground text-background transition-colors hover:bg-foreground/85 disabled:cursor-not-allowed disabled:opacity-40",children:l.jsx(kF,{className:"h-3 w-3"})})]})]})]})});t$.displayName="ChatInputWithContext";function Dde({assistantType:e,className:t}){const n=m.useMessageQueue(e),{removeFromQueue:r}=m.useQueueActions();return n.length===0?null:l.jsxs("div",{className:m.cn("rounded-control border border-dashed border-border bg-muted/30 p-2",t),children:[l.jsxs("div",{className:"flex items-center gap-1.5 px-1 pb-1.5",children:[l.jsx(wF,{className:"h-3 w-3 text-muted-foreground"}),l.jsxs("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Queued · ",n.length]})]}),l.jsx("div",{className:"space-y-1",children:n.map(s=>l.jsxs("div",{className:"group flex items-center gap-1.5 rounded-[4px] bg-background px-2 py-1 text-[12px] text-foreground/85 animate-in fade-in-0 slide-in-from-bottom-1",children:[l.jsx("span",{className:"flex-1 break-words",children:s.text}),l.jsx("button",{type:"button",onClick:()=>r(e,s.id),title:"Remove from queue",className:"grid h-4 w-4 shrink-0 place-items-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-muted hover:text-foreground group-hover:opacity-100",children:l.jsx(m.X,{className:"h-3 w-3"})})]},s.id))})]})}function Mde({assistantType:e,status:t,isLoading:n,sendMessage:r}){const s=m.useMessageQueue(e),{dequeueMessage:o}=m.useQueueActions();v.useEffect(()=>{if(t!=="ready"||n||!(s&&s.length>0))return;const a=o(e);a&&r({role:"user",parts:[{type:"text",text:a.text}]})},[t,n,s,o,r,e])}const pU={"tool-getTableColumns":{"input-streaming":"Fetching table columns...","input-available":"Reading column definitions..."},"tool-getChartDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartDataFromCardConfig":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getForecastDataFromSqlAndPython":{"input-streaming":"Planning...","input-available":"Fetching data..."},"tool-getChartSQLSyntax":{"input-streaming":"Generating SQL syntax...","input-available":"SQL syntax generated"},"tool-validateCardConfigFormat":{"input-streaming":"Validating card config format...","input-available":"Card config format validated"},"tool-generateQueryConfig":{"input-streaming":"Generating query config...","input-available":"Sending query config..."},"tool-generateDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Generating dynamic visual..."},"tool-generateDynamicVisualFromData":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-inspectDashboard":{"input-streaming":"Inspecting dashboard...","input-available":"Reading dashboard context..."},"tool-inspectDataContext":{"input-streaming":"Inspecting data context...","input-available":"Reading grounded fields..."},"tool-runDashboardAnalysis":{"input-streaming":"Planning governed analysis...","input-available":"Fetching governed results..."},"tool-runAdvancedAnalysis":{"input-streaming":"Planning advanced analysis...","input-available":"Fetching governed results..."},"tool-renderDynamicVisual":{"input-streaming":"Planning dynamic visual...","input-available":"Building visual..."},"tool-askForMoreInfo":{"input-streaming":"Asking for more information...","input-available":"More information requested"},"tool-createChartFromSql":{"input-streaming":"Creating chart...","input-available":"Chart created"},"tool-getUserSql":{"input-streaming":"Getting SQL...","input-available":"SQL retrieved"},"tool-inspectTableData":{"input-streaming":"Inspecting table data...","input-available":"Analyzing data..."},"tool-getDomainRelationships":{"input-streaming":"Getting domain relationships...","input-available":"Analyzing data..."}};function Kft(e,t){var r;if((r=pU[e])!=null&&r[t])return pU[e][t];const n=e.replace("tool-","").replace(/([A-Z])/g," $1").toLowerCase().trim();return t==="input-streaming"?`Processing ${n}...`:`Preparing ${n} response...`}function Ade(e){var n;if(!e||e.length===0)return{hasActiveTools:!1};const t=e[e.length-1];if(!(t!=null&&t.parts))return{hasActiveTools:!1};for(const r of t.parts){if(r.type==="reasoning"&&"state"in r&&r.state==="streaming")return{hasActiveTools:!0,activeToolText:"Reasoning...",toolType:"reasoning"};if(((n=r.type)!=null&&n.startsWith("tool-")||r.type==="dynamic-tool")&&"state"in r&&["input-streaming","input-available"].includes(r.state)){const s=r,o=s.state;return{hasActiveTools:!0,activeToolText:Kft(s.type,o),toolType:s.type}}}return{hasActiveTools:!1}}function Zft({children:e}){return l.jsx("pre",{className:"border-1 whitespace-pre-wrap rounded-md border border-muted p-3 text-xs",children:e})}function Xft(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Qft=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Jft=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eht={};function mU(e,t){return(eht.jsx?Jft:Qft).test(e)}const tht=/[ \t\n\f\r]/g;function nht(e){return typeof e=="object"?e.type==="text"?gU(e.value):!1:gU(e)}function gU(e){return e.replace(tht,"")===""}class xw{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}xw.prototype.normal={};xw.prototype.property={};xw.prototype.space=void 0;function Rde(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new xw(n,r,t)}function KR(e){return e.toLowerCase()}class ai{constructor(t,n){this.attribute=n,this.property=t}}ai.prototype.attribute="";ai.prototype.booleanish=!1;ai.prototype.boolean=!1;ai.prototype.commaOrSpaceSeparated=!1;ai.prototype.commaSeparated=!1;ai.prototype.defined=!1;ai.prototype.mustUseProperty=!1;ai.prototype.number=!1;ai.prototype.overloadedBoolean=!1;ai.prototype.property="";ai.prototype.spaceSeparated=!1;ai.prototype.space=void 0;let rht=0;const gn=np(),ss=np(),ZR=np(),gt=np(),Nr=np(),mm=np(),di=np();function np(){return 2**++rht}const XR=Object.freeze(Object.defineProperty({__proto__:null,boolean:gn,booleanish:ss,commaOrSpaceSeparated:di,commaSeparated:mm,number:gt,overloadedBoolean:ZR,spaceSeparated:Nr},Symbol.toStringTag,{value:"Module"})),s2=Object.keys(XR);class n$ extends ai{constructor(t,n,r,s){let o=-1;if(super(t,n),bU(this,"space",s),typeof r=="number")for(;++o<s2.length;){const i=s2[o];bU(this,s2[o],(r&XR[i])===XR[i])}}}n$.prototype.defined=!0;function bU(e,t,n){n&&(e[t]=n)}function pb(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new n$(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[KR(r)]=r,n[KR(o.attribute)]=r}return new xw(t,n,e.space)}const Fde=pb({properties:{ariaActiveDescendant:null,ariaAtomic:ss,ariaAutoComplete:null,ariaBusy:ss,ariaChecked:ss,ariaColCount:gt,ariaColIndex:gt,ariaColSpan:gt,ariaControls:Nr,ariaCurrent:null,ariaDescribedBy:Nr,ariaDetails:null,ariaDisabled:ss,ariaDropEffect:Nr,ariaErrorMessage:null,ariaExpanded:ss,ariaFlowTo:Nr,ariaGrabbed:ss,ariaHasPopup:null,ariaHidden:ss,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Nr,ariaLevel:gt,ariaLive:null,ariaModal:ss,ariaMultiLine:ss,ariaMultiSelectable:ss,ariaOrientation:null,ariaOwns:Nr,ariaPlaceholder:null,ariaPosInSet:gt,ariaPressed:ss,ariaReadOnly:ss,ariaRelevant:null,ariaRequired:ss,ariaRoleDescription:Nr,ariaRowCount:gt,ariaRowIndex:gt,ariaRowSpan:gt,ariaSelected:ss,ariaSetSize:gt,ariaSort:null,ariaValueMax:gt,ariaValueMin:gt,ariaValueNow:gt,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Pde(e,t){return t in e?e[t]:t}function Ode(e,t){return Pde(e,t.toLowerCase())}const sht=pb({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:mm,acceptCharset:Nr,accessKey:Nr,action:null,allow:null,allowFullScreen:gn,allowPaymentRequest:gn,allowUserMedia:gn,alt:null,as:null,async:gn,autoCapitalize:null,autoComplete:Nr,autoFocus:gn,autoPlay:gn,blocking:Nr,capture:null,charSet:null,checked:gn,cite:null,className:Nr,cols:gt,colSpan:null,content:null,contentEditable:ss,controls:gn,controlsList:Nr,coords:gt|mm,crossOrigin:null,data:null,dateTime:null,decoding:null,default:gn,defer:gn,dir:null,dirName:null,disabled:gn,download:ZR,draggable:ss,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:gn,formTarget:null,headers:Nr,height:gt,hidden:ZR,high:gt,href:null,hrefLang:null,htmlFor:Nr,httpEquiv:Nr,id:null,imageSizes:null,imageSrcSet:null,inert:gn,inputMode:null,integrity:null,is:null,isMap:gn,itemId:null,itemProp:Nr,itemRef:Nr,itemScope:gn,itemType:Nr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:gn,low:gt,manifest:null,max:null,maxLength:gt,media:null,method:null,min:null,minLength:gt,multiple:gn,muted:gn,name:null,nonce:null,noModule:gn,noValidate:gn,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:gn,optimum:gt,pattern:null,ping:Nr,placeholder:null,playsInline:gn,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:gn,referrerPolicy:null,rel:Nr,required:gn,reversed:gn,rows:gt,rowSpan:gt,sandbox:Nr,scope:null,scoped:gn,seamless:gn,selected:gn,shadowRootClonable:gn,shadowRootDelegatesFocus:gn,shadowRootMode:null,shape:null,size:gt,sizes:null,slot:null,span:gt,spellCheck:ss,src:null,srcDoc:null,srcLang:null,srcSet:null,start:gt,step:null,style:null,tabIndex:gt,target:null,title:null,translate:null,type:null,typeMustMatch:gn,useMap:null,value:ss,width:gt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Nr,axis:null,background:null,bgColor:null,border:gt,borderColor:null,bottomMargin:gt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:gn,declare:gn,event:null,face:null,frame:null,frameBorder:null,hSpace:gt,leftMargin:gt,link:null,longDesc:null,lowSrc:null,marginHeight:gt,marginWidth:gt,noResize:gn,noHref:gn,noShade:gn,noWrap:gn,object:null,profile:null,prompt:null,rev:null,rightMargin:gt,rules:null,scheme:null,scrolling:ss,standby:null,summary:null,text:null,topMargin:gt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:gt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:gn,disableRemotePlayback:gn,prefix:null,property:null,results:gt,security:null,unselectable:null},space:"html",transform:Ode}),oht=pb({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:di,accentHeight:gt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:gt,amplitude:gt,arabicForm:null,ascent:gt,attributeName:null,attributeType:null,azimuth:gt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:gt,by:null,calcMode:null,capHeight:gt,className:Nr,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:gt,diffuseConstant:gt,direction:null,display:null,dur:null,divisor:gt,dominantBaseline:null,download:gn,dx:null,dy:null,edgeMode:null,editable:null,elevation:gt,enableBackground:null,end:null,event:null,exponent:gt,externalResourcesRequired:null,fill:null,fillOpacity:gt,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:mm,g2:mm,glyphName:mm,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:gt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:gt,horizOriginX:gt,horizOriginY:gt,id:null,ideographic:gt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:gt,k:gt,k1:gt,k2:gt,k3:gt,k4:gt,kernelMatrix:di,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:gt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:gt,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:gt,overlineThickness:gt,paintOrder:null,panose1:null,path:null,pathLength:gt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Nr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:gt,pointsAtY:gt,pointsAtZ:gt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:di,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:di,rev:di,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:di,requiredFeatures:di,requiredFonts:di,requiredFormats:di,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:gt,specularExponent:gt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:gt,strikethroughThickness:gt,string:null,stroke:null,strokeDashArray:di,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:gt,strokeOpacity:gt,strokeWidth:null,style:null,surfaceScale:gt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:di,tabIndex:gt,tableValues:null,target:null,targetX:gt,targetY:gt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:di,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:gt,underlineThickness:gt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:gt,values:null,vAlphabetic:gt,vMathematical:gt,vectorEffect:null,vHanging:gt,vIdeographic:gt,version:null,vertAdvY:gt,vertOriginX:gt,vertOriginY:gt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:gt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Pde}),Lde=pb({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),$de=pb({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ode}),zde=pb({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),iht={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},aht=/[A-Z]/g,xU=/-[a-z]/g,lht=/^data[-\w.:]+$/i;function cht(e,t){const n=KR(t);let r=t,s=ai;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&lht.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(xU,dht);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!xU.test(o)){let i=o.replace(aht,uht);i.charAt(0)!=="-"&&(i="-"+i),t="data"+i}}s=n$}return new s(r,t)}function uht(e){return"-"+e.toLowerCase()}function dht(e){return e.charAt(1).toUpperCase()}const fht=Rde([Fde,sht,Lde,$de,zde],"html"),r$=Rde([Fde,oht,Lde,$de,zde],"svg");function hht(e){return e.join(" ").trim()}var s$={},yU=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,pht=/\n/g,mht=/^\s*/,ght=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,bht=/^:\s*/,xht=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,yht=/^[;\s]*/,vht=/^\s+|\s+$/g,wht=`
1379
1379
  `,vU="/",wU="*",xf="",Sht="comment",Cht="declaration";function Nht(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(g){var b=g.match(pht);b&&(n+=b.length);var x=g.lastIndexOf(wht);r=~x?g.length-x:r+g.length}function o(){var g={line:n,column:r};return function(b){return b.position=new i(g),u(),b}}function i(g){this.start=g,this.end={line:n,column:r},this.source=t.source}i.prototype.content=e;function a(g){var b=new Error(t.source+":"+n+":"+r+": "+g);if(b.reason=g,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function c(g){var b=g.exec(e);if(b){var x=b[0];return s(x),e=e.slice(x.length),b}}function u(){c(mht)}function d(g){var b;for(g=g||[];b=f();)b!==!1&&g.push(b);return g}function f(){var g=o();if(!(vU!=e.charAt(0)||wU!=e.charAt(1))){for(var b=2;xf!=e.charAt(b)&&(wU!=e.charAt(b)||vU!=e.charAt(b+1));)++b;if(b+=2,xf===e.charAt(b-1))return a("End of comment missing");var x=e.slice(2,b-2);return r+=2,s(x),e=e.slice(b),r+=2,g({type:Sht,comment:x})}}function h(){var g=o(),b=c(ght);if(b){if(f(),!c(bht))return a("property missing ':'");var x=c(xht),y=g({type:Cht,property:SU(b[0].replace(yU,xf)),value:x?SU(x[0].replace(yU,xf)):xf});return c(yht),y}}function p(){var g=[];d(g);for(var b;b=h();)b!==!1&&(g.push(b),d(g));return g}return u(),p()}function SU(e){return e?e.replace(vht,xf):xf}var kht=Nht,_ht=m.commonjsGlobal&&m.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(s$,"__esModule",{value:!0});s$.default=Eht;const jht=_ht(kht);function Eht(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,jht.default)(e),s=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:i,value:a}=o;s?t(i,a,o):a&&(n=n||{},n[i]=a)}),n}var hE={};Object.defineProperty(hE,"__esModule",{value:!0});hE.camelCase=void 0;var Tht=/^--[a-zA-Z0-9_-]+$/,Iht=/-([a-z])/g,Dht=/^[^-]+$/,Mht=/^-(webkit|moz|ms|o|khtml)-/,Aht=/^-(ms)-/,Rht=function(e){return!e||Dht.test(e)||Tht.test(e)},Fht=function(e,t){return t.toUpperCase()},CU=function(e,t){return"".concat(t,"-")},Pht=function(e,t){return t===void 0&&(t={}),Rht(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(Aht,CU):e=e.replace(Mht,CU),e.replace(Iht,Fht))};hE.camelCase=Pht;var Oht=m.commonjsGlobal&&m.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},Lht=Oht(s$),$ht=hE;function QR(e,t){var n={};return!e||typeof e!="string"||(0,Lht.default)(e,function(r,s){r&&s&&(n[(0,$ht.camelCase)(r,t)]=s)}),n}QR.default=QR;var zht=QR;const Bht=m.getDefaultExportFromCjs(zht),Bde=Vde("end"),o$=Vde("start");function Vde(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Vht(e){const t=o$(e),n=Bde(e);if(t&&n)return{start:t,end:n}}function jy(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?NU(e.position):"start"in e||"end"in e?NU(e):"line"in e||"column"in e?JR(e):""}function JR(e){return kU(e&&e.line)+":"+kU(e&&e.column)}function NU(e){return JR(e&&e.start)+"-"+JR(e&&e.end)}function kU(e){return e&&typeof e=="number"?e:1}class bo extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",o={},i=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?s=t:!o.cause&&t&&(i=!0,s=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?o.ruleId=r:(o.source=r.slice(0,c),o.ruleId=r.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const a=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=a?a.line:void 0,this.name=jy(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=i&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}bo.prototype.file="";bo.prototype.name="";bo.prototype.reason="";bo.prototype.message="";bo.prototype.stack="";bo.prototype.column=void 0;bo.prototype.line=void 0;bo.prototype.ancestors=void 0;bo.prototype.cause=void 0;bo.prototype.fatal=void 0;bo.prototype.place=void 0;bo.prototype.ruleId=void 0;bo.prototype.source=void 0;const i$={}.hasOwnProperty,Hht=new Map,Uht=/[A-Z]/g,qht=new Set(["table","tbody","thead","tfoot","tr"]),Wht=new Set(["td","th"]),Hde="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Yht(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=tpt(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=ept(n,t.jsx,t.jsxs)}const s={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?r$:fht,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=Ude(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function Ude(e,t,n){if(t.type==="element")return Ght(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Kht(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Xht(e,t,n);if(t.type==="mdxjsEsm")return Zht(e,t);if(t.type==="root")return Qht(e,t,n);if(t.type==="text")return Jht(e,t)}function Ght(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=r$,e.schema=s),e.ancestors.push(t);const o=Wde(e,t.tagName,!1),i=npt(e,t);let a=l$(e,t);return qht.has(t.tagName)&&(a=a.filter(function(c){return typeof c=="string"?!nht(c):!0})),qde(e,i,o,t),a$(i,a),e.ancestors.pop(),e.schema=r,e.create(t,o,i,n)}function Kht(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}H0(e,t.position)}function Zht(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);H0(e,t.position)}function Xht(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=r$,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:Wde(e,t.name,!0),i=rpt(e,t),a=l$(e,t);return qde(e,i,o,t),a$(i,a),e.ancestors.pop(),e.schema=r,e.create(t,o,i,n)}function Qht(e,t,n){const r={};return a$(r,l$(e,t)),e.create(t,e.Fragment,r,n)}function Jht(e,t){return t.value}function qde(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function a$(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function ept(e,t,n){return r;function r(s,o,i,a){const u=Array.isArray(i.children)?n:t;return a?u(o,i,a):u(o,i)}}function tpt(e,t){return n;function n(r,s,o,i){const a=Array.isArray(o.children),c=o$(r);return t(s,o,i,a,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function npt(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&i$.call(t.properties,s)){const o=spt(e,s,t.properties[s]);if(o){const[i,a]=o;e.tableCellAlignToStyle&&i==="align"&&typeof a=="string"&&Wht.has(t.tagName)?r=a:n[i]=a}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function rpt(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const i=o.expression;i.type;const a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else H0(e,t.position);else{const s=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,o=e.evaluater.evaluateExpression(a.expression)}else H0(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function l$(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:Hht;for(;++r<t.children.length;){const o=t.children[r];let i;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const u=s.get(c)||0;i=c+"-"+u,s.set(c,u+1)}}const a=Ude(e,o,i);a!==void 0&&n.push(a)}return n}function spt(e,t,n){const r=cht(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Xft(n):hht(n)),r.property==="style"){let s=typeof n=="object"?n:opt(e,String(n));return e.stylePropertyNameCase==="css"&&(s=ipt(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?iht[r.property]||r.property:r.attribute,n]}}function opt(e,t){try{return Bht(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new bo("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=e.filePath||void 0,s.url=Hde+"#cannot-parse-style-attribute",s}}function Wde(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let o=-1,i;for(;++o<s.length;){const a=mU(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};i=i?{type:"MemberExpression",object:i,property:a,computed:!!(o&&a.type==="Literal"),optional:!1}:a}r=i}else r=mU(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return i$.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);H0(e)}function H0(e,t){const n=new bo("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Hde+"#cannot-handle-mdx-estrees-without-createevaluater",n}function ipt(e){const t={};let n;for(n in e)i$.call(e,n)&&(t[apt(n)]=e[n]);return t}function apt(e){let t=e.replace(Uht,lpt);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function lpt(e){return"-"+e.toLowerCase()}const o2={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},cpt={};function c$(e,t){const n=cpt,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Yde(e,r,s)}function Yde(e,t,n){if(upt(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return _U(e.children,t,n)}return Array.isArray(e)?_U(e,t,n):""}function _U(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=Yde(e[s],t,n);return r.join("")}function upt(e){return!!(e&&typeof e=="object")}const jU=document.createElement("i");function u$(e){const t="&"+e+";";jU.innerHTML=t;const n=jU.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function vi(e,t,n,r){const s=e.length;let o=0,i;if(t<0?t=-t>s?0:s+t:t=t>s?s:t,n=n>0?n:0,r.length<1e4)i=Array.from(r),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<r.length;)i=r.slice(o,o+1e4),i.unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}function Hi(e,t){return e.length>0?(vi(e,e.length,0,t),e):t}const EU={}.hasOwnProperty;function Gde(e){const t={};let n=-1;for(;++n<e.length;)dpt(t,e[n]);return t}function dpt(e,t){let n;for(n in t){const s=(EU.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let i;if(o)for(i in o){EU.call(s,i)||(s[i]=[]);const a=o[i];fpt(s[i],Array.isArray(a)?a:a?[a]:[])}}}function fpt(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);vi(e,0,0,r)}function Kde(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function _a(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Io=Od(/[A-Za-z]/),lo=Od(/[\dA-Za-z]/),hpt=Od(/[#-'*+\--9=?A-Z^-~]/);function xk(e){return e!==null&&(e<32||e===127)}const eF=Od(/\d/),ppt=Od(/[\dA-Fa-f]/),mpt=Od(/[!-/:-@[-`{-~]/);function Gt(e){return e!==null&&e<-2}function vr(e){return e!==null&&(e<0||e===32)}function En(e){return e===-2||e===-1||e===32}const pE=Od(new RegExp("\\p{P}|\\p{S}","u")),Ah=Od(/\s/);function Od(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function mb(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const o=e.charCodeAt(n);let i="";if(o===37&&lo(e.charCodeAt(n+1))&&lo(e.charCodeAt(n+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(i=String.fromCharCode(o));else if(o>55295&&o<57344){const a=e.charCodeAt(n+1);o<56320&&a>56319&&a<57344?(i=String.fromCharCode(o,a),s=1):i="�"}else i=String.fromCharCode(o);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+s+1,i=""),s&&(n+=s,s=0)}return t.join("")+e.slice(r)}function Ln(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return i;function i(c){return En(c)?(e.enter(n),a(c)):t(c)}function a(c){return En(c)&&o++<s?(e.consume(c),a):(e.exit(n),t(c))}}const gpt={tokenize:bpt};function bpt(e){const t=e.attempt(this.parser.constructs.contentInitial,r,s);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ln(e,t,"linePrefix")}function s(a){return e.enter("paragraph"),o(a)}function o(a){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,i(a)}function i(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return Gt(a)?(e.consume(a),e.exit("chunkText"),o):(e.consume(a),i)}}const xpt={tokenize:ypt},TU={tokenize:vpt};function ypt(e){const t=this,n=[];let r=0,s,o,i;return a;function a(w){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,c,u)(w)}return u(w)}function c(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&S();const C=t.events.length;let N=C,k;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){k=t.events[N][1].end;break}y(r);let _=C;for(;_<t.events.length;)t.events[_][1].end={...k},_++;return vi(t.events,N+1,0,t.events.slice(C)),t.events.length=_,u(w)}return a(w)}function u(w){if(r===n.length){if(!s)return h(w);if(s.currentConstruct&&s.currentConstruct.concrete)return g(w);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(TU,d,f)(w)}function d(w){return s&&S(),y(r),h(w)}function f(w){return t.parser.lazy[t.now().line]=r!==n.length,i=t.now().offset,g(w)}function h(w){return t.containerState={},e.attempt(TU,p,g)(w)}function p(w){return r++,n.push([t.currentConstruct,t.containerState]),h(w)}function g(w){if(w===null){s&&S(),y(0),e.consume(w);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),b(w)}function b(w){if(w===null){x(e.exit("chunkFlow"),!0),y(0),e.consume(w);return}return Gt(w)?(e.consume(w),x(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(w),b)}function x(w,C){const N=t.sliceStream(w);if(C&&N.push(null),w.previous=o,o&&(o.next=w),o=w,s.defineSkip(w.start),s.write(N),t.parser.lazy[w.start.line]){let k=s.events.length;for(;k--;)if(s.events[k][1].start.offset<i&&(!s.events[k][1].end||s.events[k][1].end.offset>i))return;const _=t.events.length;let j=_,T,E;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){if(T){E=t.events[j][1].end;break}T=!0}for(y(r),k=_;k<t.events.length;)t.events[k][1].end={...E},k++;vi(t.events,j+1,0,t.events.slice(_)),t.events.length=k}}function y(w){let C=n.length;for(;C-- >w;){const N=n[C];t.containerState=N[1],N[0].exit.call(t,e)}n.length=w}function S(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function vpt(e,t,n){return Ln(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function dg(e){if(e===null||vr(e)||Ah(e))return 1;if(pE(e))return 2}function mE(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const tF={name:"attention",resolveAll:wpt,tokenize:Spt};function wpt(e,t){let n=-1,r,s,o,i,a,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};IU(f,-c),IU(h,c),i={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},a={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},o={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:c>1?"strong":"emphasis",start:{...i.start},end:{...a.end}},e[r][1].end={...i.start},e[n][1].start={...a.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Hi(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Hi(u,[["enter",s,t],["enter",i,t],["exit",i,t],["enter",o,t]]),u=Hi(u,mE(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Hi(u,[["exit",o,t],["enter",a,t],["exit",a,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Hi(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,vi(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function Spt(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=dg(r);let o;return i;function i(c){return o=c,e.enter("attentionSequence"),a(c)}function a(c){if(c===o)return e.consume(c),a;const u=e.exit("attentionSequence"),d=dg(c),f=!d||d===2&&s||n.includes(c),h=!s||s===2&&d||n.includes(r);return u._open=!!(o===42?f:f&&(s||!h)),u._close=!!(o===42?h:h&&(d||!f)),t(c)}}function IU(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Cpt={name:"autolink",tokenize:Npt};function Npt(e,t,n){let r=0;return s;function s(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(p){return Io(p)?(e.consume(p),i):p===64?n(p):u(p)}function i(p){return p===43||p===45||p===46||lo(p)?(r=1,a(p)):u(p)}function a(p){return p===58?(e.consume(p),r=0,c):(p===43||p===45||p===46||lo(p))&&r++<32?(e.consume(p),a):(r=0,u(p))}function c(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||xk(p)?n(p):(e.consume(p),c)}function u(p){return p===64?(e.consume(p),d):hpt(p)?(e.consume(p),u):n(p)}function d(p){return lo(p)?f(p):n(p)}function f(p){return p===46?(e.consume(p),r=0,d):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||lo(p))&&r++<63){const g=p===45?h:f;return e.consume(p),g}return n(p)}}const yw={partial:!0,tokenize:kpt};function kpt(e,t,n){return r;function r(o){return En(o)?Ln(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||Gt(o)?t(o):n(o)}}const Zde={continuation:{tokenize:jpt},exit:Ept,name:"blockQuote",tokenize:_pt};function _pt(e,t,n){const r=this;return s;function s(i){if(i===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(i),e.exit("blockQuoteMarker"),o}return n(i)}function o(i){return En(i)?(e.enter("blockQuotePrefixWhitespace"),e.consume(i),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(i))}}function jpt(e,t,n){const r=this;return s;function s(i){return En(i)?Ln(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i):o(i)}function o(i){return e.attempt(Zde,t,n)(i)}}function Ept(e){e.exit("blockQuote")}const Xde={name:"characterEscape",tokenize:Tpt};function Tpt(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return mpt(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const Qde={name:"characterReference",tokenize:Ipt};function Ipt(e,t,n){const r=this;let s=0,o,i;return a;function a(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,i=lo,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,i=ppt,d):(e.enter("characterReferenceValue"),o=7,i=eF,d(f))}function d(f){if(f===59&&s){const h=e.exit("characterReferenceValue");return i===lo&&!u$(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return i(f)&&s++<o?(e.consume(f),d):n(f)}}const DU={partial:!0,tokenize:Mpt},MU={concrete:!0,name:"codeFenced",tokenize:Dpt};function Dpt(e,t,n){const r=this,s={partial:!0,tokenize:N};let o=0,i=0,a;return c;function c(k){return u(k)}function u(k){const _=r.events[r.events.length-1];return o=_&&_[1].type==="linePrefix"?_[2].sliceSerialize(_[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(k)}function d(k){return k===a?(i++,e.consume(k),d):i<3?n(k):(e.exit("codeFencedFenceSequence"),En(k)?Ln(e,f,"whitespace")(k):f(k))}function f(k){return k===null||Gt(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(DU,b,C)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(k))}function h(k){return k===null||Gt(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(k)):En(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ln(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),h)}function p(k){return k===null||Gt(k)?f(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(k))}function g(k){return k===null||Gt(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(k)):k===96&&k===a?n(k):(e.consume(k),g)}function b(k){return e.attempt(s,C,x)(k)}function x(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),y}function y(k){return o>0&&En(k)?Ln(e,S,"linePrefix",o+1)(k):S(k)}function S(k){return k===null||Gt(k)?e.check(DU,b,C)(k):(e.enter("codeFlowValue"),w(k))}function w(k){return k===null||Gt(k)?(e.exit("codeFlowValue"),S(k)):(e.consume(k),w)}function C(k){return e.exit("codeFenced"),t(k)}function N(k,_,j){let T=0;return E;function E(F){return k.enter("lineEnding"),k.consume(F),k.exit("lineEnding"),I}function I(F){return k.enter("codeFencedFence"),En(F)?Ln(k,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):D(F)}function D(F){return F===a?(k.enter("codeFencedFenceSequence"),A(F)):j(F)}function A(F){return F===a?(T++,k.consume(F),A):T>=i?(k.exit("codeFencedFenceSequence"),En(F)?Ln(k,R,"whitespace")(F):R(F)):j(F)}function R(F){return F===null||Gt(F)?(k.exit("codeFencedFence"),_(F)):j(F)}}}function Mpt(e,t,n){const r=this;return s;function s(i){return i===null?n(i):(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o)}function o(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}const i2={name:"codeIndented",tokenize:Rpt},Apt={partial:!0,tokenize:Fpt};function Rpt(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),Ln(e,o,"linePrefix",5)(u)}function o(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?i(u):n(u)}function i(u){return u===null?c(u):Gt(u)?e.attempt(Apt,i,c)(u):(e.enter("codeFlowValue"),a(u))}function a(u){return u===null||Gt(u)?(e.exit("codeFlowValue"),i(u)):(e.consume(u),a)}function c(u){return e.exit("codeIndented"),t(u)}}function Fpt(e,t,n){const r=this;return s;function s(i){return r.parser.lazy[r.now().line]?n(i):Gt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),s):Ln(e,o,"linePrefix",5)(i)}function o(i){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):Gt(i)?s(i):n(i)}}const Ppt={name:"codeText",previous:Lpt,resolve:Opt,tokenize:$pt};function Opt(e){let t=e.length-4,n=3,r,s;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)s===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(s=r):(r===t||e[r][1].type==="lineEnding")&&(e[s][1].type="codeTextData",r!==s+2&&(e[s][1].end=e[r-1][1].end,e.splice(s+2,r-s-2),t-=r-s-2,r=s+2),s=void 0);return e}function Lpt(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function $pt(e,t,n){let r=0,s,o;return i;function i(f){return e.enter("codeText"),e.enter("codeTextSequence"),a(f)}function a(f){return f===96?(e.consume(f),r++,a):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(o=e.enter("codeTextSequence"),s=0,d(f)):Gt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||Gt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),s++,d):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",u(f))}}class zpt{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&ux(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ux(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ux(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);ux(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ux(this.left,n.reverse())}}}function ux(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Jde(e){const t={};let n=-1,r,s,o,i,a,c,u;const d=new zpt(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,Bpt(d,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,s=void 0;o--;)if(i=d.get(o),i[1].type==="lineEnding"||i[1].type==="lineEndingBlank")i[0]==="enter"&&(s&&(d.get(s)[1].type="lineEndingBlank"),i[1].type="lineEnding",s=o);else if(!(i[1].type==="linePrefix"||i[1].type==="listItemIndent"))break;s&&(r[1].end={...d.get(s)[1].start},a=d.slice(s,n),a.unshift(r),d.splice(s,n-s+1,a))}}return vi(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function Bpt(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const o=[];let i=n._tokenizer;i||(i=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(i._contentTypeTextTrailing=!0));const a=i.events,c=[],u={};let d,f,h=-1,p=n,g=0,b=0;const x=[b];for(;p;){for(;e.get(++s)[1]!==p;);o.push(s),p._tokenizer||(d=r.sliceStream(p),p.next||d.push(null),f&&i.defineSkip(p.start),p._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),p._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),f=p,p=p.next}for(p=n;++h<a.length;)a[h][0]==="exit"&&a[h-1][0]==="enter"&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[h][1].end.line&&(b=h+1,x.push(b),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(i.events=[],p?(p._tokenizer=void 0,p.previous=void 0):x.pop(),h=x.length;h--;){const y=a.slice(x[h],x[h+1]),S=o.pop();c.push([S,S+y.length-1]),e.splice(S,2,y)}for(c.reverse(),h=-1;++h<c.length;)u[g+c[h][0]]=g+c[h][1],g+=c[h][1]-c[h][0]-1;return u}const Vpt={resolve:Upt,tokenize:qpt},Hpt={partial:!0,tokenize:Wpt};function Upt(e){return Jde(e),e}function qpt(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),s(a)}function s(a){return a===null?o(a):Gt(a)?e.check(Hpt,i,o)(a):(e.consume(a),s)}function o(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function i(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,s}}function Wpt(e,t,n){const r=this;return s;function s(i){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),Ln(e,o,"linePrefix")}function o(i){if(i===null||Gt(i))return n(i);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function efe(e,t,n,r,s,o,i,a,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(y){return y===60?(e.enter(r),e.enter(s),e.enter(o),e.consume(y),e.exit(o),h):y===null||y===32||y===41||xk(y)?n(y):(e.enter(r),e.enter(i),e.enter(a),e.enter("chunkString",{contentType:"string"}),b(y))}function h(y){return y===62?(e.enter(o),e.consume(y),e.exit(o),e.exit(s),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(y))}function p(y){return y===62?(e.exit("chunkString"),e.exit(a),h(y)):y===null||y===60||Gt(y)?n(y):(e.consume(y),y===92?g:p)}function g(y){return y===60||y===62||y===92?(e.consume(y),p):p(y)}function b(y){return!d&&(y===null||y===41||vr(y))?(e.exit("chunkString"),e.exit(a),e.exit(i),e.exit(r),t(y)):d<u&&y===40?(e.consume(y),d++,b):y===41?(e.consume(y),d--,b):y===null||y===32||y===40||xk(y)?n(y):(e.consume(y),y===92?x:b)}function x(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function tfe(e,t,n,r,s,o){const i=this;let a=0,c;return u;function u(p){return e.enter(r),e.enter(s),e.consume(p),e.exit(s),e.enter(o),d}function d(p){return a>999||p===null||p===91||p===93&&!c||p===94&&!a&&"_hiddenFootnoteSupport"in i.parser.constructs?n(p):p===93?(e.exit(o),e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):Gt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||Gt(p)||a++>999?(e.exit("chunkString"),d(p)):(e.consume(p),c||(c=!En(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,f):f(p)}}function nfe(e,t,n,r,s,o){let i;return a;function a(h){return h===34||h===39||h===40?(e.enter(r),e.enter(s),e.consume(h),e.exit(s),i=h===40?41:h,c):n(h)}function c(h){return h===i?(e.enter(s),e.consume(h),e.exit(s),e.exit(r),t):(e.enter(o),u(h))}function u(h){return h===i?(e.exit(o),c(i)):h===null?n(h):Gt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Ln(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===i||h===null||Gt(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===i||h===92?(e.consume(h),d):d(h)}}function Ey(e,t){let n;return r;function r(s){return Gt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):En(s)?Ln(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const Ypt={name:"definition",tokenize:Kpt},Gpt={partial:!0,tokenize:Zpt};function Kpt(e,t,n){const r=this;let s;return o;function o(p){return e.enter("definition"),i(p)}function i(p){return tfe.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return s=_a(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return vr(p)?Ey(e,u)(p):u(p)}function u(p){return efe(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(Gpt,f,f)(p)}function f(p){return En(p)?Ln(e,h,"whitespace")(p):h(p)}function h(p){return p===null||Gt(p)?(e.exit("definition"),r.parser.defined.push(s),t(p)):n(p)}}function Zpt(e,t,n){return r;function r(a){return vr(a)?Ey(e,s)(a):n(a)}function s(a){return nfe(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function o(a){return En(a)?Ln(e,i,"whitespace")(a):i(a)}function i(a){return a===null||Gt(a)?t(a):n(a)}}const Xpt={name:"hardBreakEscape",tokenize:Qpt};function Qpt(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return Gt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const Jpt={name:"headingAtx",resolve:emt,tokenize:tmt};function emt(e,t){let n=e.length-2,r=3,s,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(s={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},vi(e,r,n-r+1,[["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t]])),e}function tmt(e,t,n){let r=0;return s;function s(d){return e.enter("atxHeading"),o(d)}function o(d){return e.enter("atxHeadingSequence"),i(d)}function i(d){return d===35&&r++<6?(e.consume(d),i):d===null||vr(d)?(e.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||Gt(d)?(e.exit("atxHeading"),t(d)):En(d)?Ln(e,a,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),a(d))}function u(d){return d===null||d===35||vr(d)?(e.exit("atxHeadingText"),a(d)):(e.consume(d),u)}}const nmt=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],AU=["pre","script","style","textarea"],rmt={concrete:!0,name:"htmlFlow",resolveTo:imt,tokenize:amt},smt={partial:!0,tokenize:cmt},omt={partial:!0,tokenize:lmt};function imt(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function amt(e,t,n){const r=this;let s,o,i,a,c;return u;function u(M){return d(M)}function d(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),f}function f(M){return M===33?(e.consume(M),h):M===47?(e.consume(M),o=!0,b):M===63?(e.consume(M),s=3,r.interrupt?t:O):Io(M)?(e.consume(M),i=String.fromCharCode(M),x):n(M)}function h(M){return M===45?(e.consume(M),s=2,p):M===91?(e.consume(M),s=5,a=0,g):Io(M)?(e.consume(M),s=4,r.interrupt?t:O):n(M)}function p(M){return M===45?(e.consume(M),r.interrupt?t:O):n(M)}function g(M){const K="CDATA[";return M===K.charCodeAt(a++)?(e.consume(M),a===K.length?r.interrupt?t:D:g):n(M)}function b(M){return Io(M)?(e.consume(M),i=String.fromCharCode(M),x):n(M)}function x(M){if(M===null||M===47||M===62||vr(M)){const K=M===47,L=i.toLowerCase();return!K&&!o&&AU.includes(L)?(s=1,r.interrupt?t(M):D(M)):nmt.includes(i.toLowerCase())?(s=6,K?(e.consume(M),y):r.interrupt?t(M):D(M)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(M):o?S(M):w(M))}return M===45||lo(M)?(e.consume(M),i+=String.fromCharCode(M),x):n(M)}function y(M){return M===62?(e.consume(M),r.interrupt?t:D):n(M)}function S(M){return En(M)?(e.consume(M),S):E(M)}function w(M){return M===47?(e.consume(M),E):M===58||M===95||Io(M)?(e.consume(M),C):En(M)?(e.consume(M),w):E(M)}function C(M){return M===45||M===46||M===58||M===95||lo(M)?(e.consume(M),C):N(M)}function N(M){return M===61?(e.consume(M),k):En(M)?(e.consume(M),N):w(M)}function k(M){return M===null||M===60||M===61||M===62||M===96?n(M):M===34||M===39?(e.consume(M),c=M,_):En(M)?(e.consume(M),k):j(M)}function _(M){return M===c?(e.consume(M),c=null,T):M===null||Gt(M)?n(M):(e.consume(M),_)}function j(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||vr(M)?N(M):(e.consume(M),j)}function T(M){return M===47||M===62||En(M)?w(M):n(M)}function E(M){return M===62?(e.consume(M),I):n(M)}function I(M){return M===null||Gt(M)?D(M):En(M)?(e.consume(M),I):n(M)}function D(M){return M===45&&s===2?(e.consume(M),H):M===60&&s===1?(e.consume(M),B):M===62&&s===4?(e.consume(M),Z):M===63&&s===3?(e.consume(M),O):M===93&&s===5?(e.consume(M),W):Gt(M)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(smt,Y,A)(M)):M===null||Gt(M)?(e.exit("htmlFlowData"),A(M)):(e.consume(M),D)}function A(M){return e.check(omt,R,Y)(M)}function R(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),F}function F(M){return M===null||Gt(M)?A(M):(e.enter("htmlFlowData"),D(M))}function H(M){return M===45?(e.consume(M),O):D(M)}function B(M){return M===47?(e.consume(M),i="",U):D(M)}function U(M){if(M===62){const K=i.toLowerCase();return AU.includes(K)?(e.consume(M),Z):D(M)}return Io(M)&&i.length<8?(e.consume(M),i+=String.fromCharCode(M),U):D(M)}function W(M){return M===93?(e.consume(M),O):D(M)}function O(M){return M===62?(e.consume(M),Z):M===45&&s===2?(e.consume(M),O):D(M)}function Z(M){return M===null||Gt(M)?(e.exit("htmlFlowData"),Y(M)):(e.consume(M),Z)}function Y(M){return e.exit("htmlFlow"),t(M)}}function lmt(e,t,n){const r=this;return s;function s(i){return Gt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),o):n(i)}function o(i){return r.parser.lazy[r.now().line]?n(i):t(i)}}function cmt(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(yw,t,n)}}const umt={name:"htmlText",tokenize:dmt};function dmt(e,t,n){const r=this;let s,o,i;return a;function a(O){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(O),c}function c(O){return O===33?(e.consume(O),u):O===47?(e.consume(O),N):O===63?(e.consume(O),w):Io(O)?(e.consume(O),j):n(O)}function u(O){return O===45?(e.consume(O),d):O===91?(e.consume(O),o=0,g):Io(O)?(e.consume(O),S):n(O)}function d(O){return O===45?(e.consume(O),p):n(O)}function f(O){return O===null?n(O):O===45?(e.consume(O),h):Gt(O)?(i=f,B(O)):(e.consume(O),f)}function h(O){return O===45?(e.consume(O),p):f(O)}function p(O){return O===62?H(O):O===45?h(O):f(O)}function g(O){const Z="CDATA[";return O===Z.charCodeAt(o++)?(e.consume(O),o===Z.length?b:g):n(O)}function b(O){return O===null?n(O):O===93?(e.consume(O),x):Gt(O)?(i=b,B(O)):(e.consume(O),b)}function x(O){return O===93?(e.consume(O),y):b(O)}function y(O){return O===62?H(O):O===93?(e.consume(O),y):b(O)}function S(O){return O===null||O===62?H(O):Gt(O)?(i=S,B(O)):(e.consume(O),S)}function w(O){return O===null?n(O):O===63?(e.consume(O),C):Gt(O)?(i=w,B(O)):(e.consume(O),w)}function C(O){return O===62?H(O):w(O)}function N(O){return Io(O)?(e.consume(O),k):n(O)}function k(O){return O===45||lo(O)?(e.consume(O),k):_(O)}function _(O){return Gt(O)?(i=_,B(O)):En(O)?(e.consume(O),_):H(O)}function j(O){return O===45||lo(O)?(e.consume(O),j):O===47||O===62||vr(O)?T(O):n(O)}function T(O){return O===47?(e.consume(O),H):O===58||O===95||Io(O)?(e.consume(O),E):Gt(O)?(i=T,B(O)):En(O)?(e.consume(O),T):H(O)}function E(O){return O===45||O===46||O===58||O===95||lo(O)?(e.consume(O),E):I(O)}function I(O){return O===61?(e.consume(O),D):Gt(O)?(i=I,B(O)):En(O)?(e.consume(O),I):T(O)}function D(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),s=O,A):Gt(O)?(i=D,B(O)):En(O)?(e.consume(O),D):(e.consume(O),R)}function A(O){return O===s?(e.consume(O),s=void 0,F):O===null?n(O):Gt(O)?(i=A,B(O)):(e.consume(O),A)}function R(O){return O===null||O===34||O===39||O===60||O===61||O===96?n(O):O===47||O===62||vr(O)?T(O):(e.consume(O),R)}function F(O){return O===47||O===62||vr(O)?T(O):n(O)}function H(O){return O===62?(e.consume(O),e.exit("htmlTextData"),e.exit("htmlText"),t):n(O)}function B(O){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),U}function U(O){return En(O)?Ln(e,W,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):W(O)}function W(O){return e.enter("htmlTextData"),i(O)}}const d$={name:"labelEnd",resolveAll:mmt,resolveTo:gmt,tokenize:bmt},fmt={tokenize:xmt},hmt={tokenize:ymt},pmt={tokenize:vmt};function mmt(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const s=r.type==="labelImage"?4:2;r.type="data",t+=s}}return e.length!==n.length&&vi(e,0,e.length,n),e}function gmt(e,t){let n=e.length,r=0,s,o,i,a;for(;n--;)if(s=e[n][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[n][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(i){if(e[n][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(i=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[o][1].start},end:{...e[i][1].end}},d={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[i-2][1].start}};return a=[["enter",c,t],["enter",u,t]],a=Hi(a,e.slice(o+1,o+r+3)),a=Hi(a,[["enter",d,t]]),a=Hi(a,mE(t.parser.constructs.insideSpan.null,e.slice(o+r+4,i-3),t)),a=Hi(a,[["exit",d,t],e[i-2],e[i-1],["exit",u,t]]),a=Hi(a,e.slice(i+1)),a=Hi(a,[["exit",c,t]]),vi(e,o,e.length,a),e}function bmt(e,t,n){const r=this;let s=r.events.length,o,i;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){o=r.events[s][1];break}return a;function a(h){return o?o._inactive?f(h):(i=r.parser.defined.includes(_a(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),c):n(h)}function c(h){return h===40?e.attempt(fmt,d,i?d:f)(h):h===91?e.attempt(hmt,d,i?u:f)(h):i?d(h):f(h)}function u(h){return e.attempt(pmt,d,f)(h)}function d(h){return t(h)}function f(h){return o._balanced=!0,n(h)}}function xmt(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),s}function s(f){return vr(f)?Ey(e,o)(f):o(f)}function o(f){return f===41?d(f):efe(e,i,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function i(f){return vr(f)?Ey(e,c)(f):d(f)}function a(f){return n(f)}function c(f){return f===34||f===39||f===40?nfe(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return vr(f)?Ey(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function ymt(e,t,n){const r=this;return s;function s(a){return tfe.call(r,e,o,i,"reference","referenceMarker","referenceString")(a)}function o(a){return r.parser.defined.includes(_a(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function i(a){return n(a)}}function vmt(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const wmt={name:"labelStartImage",resolveAll:d$.resolveAll,tokenize:Smt};function Smt(e,t,n){const r=this;return s;function s(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),o}function o(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),i):n(a)}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const Cmt={name:"labelStartLink",resolveAll:d$.resolveAll,tokenize:Nmt};function Nmt(e,t,n){const r=this;return s;function s(i){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(i),e.exit("labelMarker"),e.exit("labelLink"),o}function o(i){return i===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(i):t(i)}}const a2={name:"lineEnding",tokenize:kmt};function kmt(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ln(e,t,"linePrefix")}}const dC={name:"thematicBreak",tokenize:_mt};function _mt(e,t,n){let r=0,s;return o;function o(u){return e.enter("thematicBreak"),i(u)}function i(u){return s=u,a(u)}function a(u){return u===s?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||Gt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),En(u)?Ln(e,a,"whitespace")(u):a(u))}}const Ho={continuation:{tokenize:Imt},exit:Mmt,name:"list",tokenize:Tmt},jmt={partial:!0,tokenize:Amt},Emt={partial:!0,tokenize:Dmt};function Tmt(e,t,n){const r=this,s=r.events[r.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,i=0;return a;function a(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:eF(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(dC,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return eF(p)&&++i<10?(e.consume(p),c):(!r.interrupt||i<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(yw,r.interrupt?n:d,e.attempt(jmt,h,f))}function d(p){return r.containerState.initialBlankLine=!0,o++,h(p)}function f(p){return En(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function Imt(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(yw,s,o);function s(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ln(e,t,"listItemIndent",r.containerState.size+1)(a)}function o(a){return r.containerState.furtherBlankLines||!En(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,i(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Emt,t,i)(a))}function i(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ln(e,e.attempt(Ho,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Dmt(e,t,n){const r=this;return Ln(e,s,"listItemIndent",r.containerState.size+1);function s(o){const i=r.events[r.events.length-1];return i&&i[1].type==="listItemIndent"&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(o):n(o)}}function Mmt(e){e.exit(this.containerState.type)}function Amt(e,t,n){const r=this;return Ln(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const i=r.events[r.events.length-1];return!En(o)&&i&&i[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const RU={name:"setextUnderline",resolveTo:Rmt,tokenize:Fmt};function Rmt(e,t){let n=e.length,r,s,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(s=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const i={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",i,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=i,e.push(["exit",i,t]),e}function Fmt(e,t,n){const r=this;let s;return o;function o(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),s=u,i(u)):n(u)}function i(u){return e.enter("setextHeadingLineSequence"),a(u)}function a(u){return u===s?(e.consume(u),a):(e.exit("setextHeadingLineSequence"),En(u)?Ln(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||Gt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const Pmt={tokenize:Omt};function Omt(e){const t=this,n=e.attempt(yw,r,e.attempt(this.parser.constructs.flowInitial,s,Ln(e,e.attempt(this.parser.constructs.flow,s,e.attempt(Vpt,s)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Lmt={resolveAll:sfe()},$mt=rfe("string"),zmt=rfe("text");function rfe(e){return{resolveAll:sfe(e==="text"?Bmt:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],o=n.attempt(s,i,a);return i;function i(d){return u(d)?o(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),o(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=s[d];let h=-1;if(f)for(;++h<f.length;){const p=f[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function sfe(e){return t;function t(n,r){let s=-1,o;for(;++s<=n.length;)o===void 0?n[s]&&n[s][1].type==="data"&&(o=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==o+2&&(n[o][1].end=n[s-1][1].end,n.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(n,r):n}}function Bmt(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],s=t.sliceStream(r);let o=s.length,i=-1,a=0,c;for(;o--;){const u=s[o];if(typeof u=="string"){for(i=u.length;u.charCodeAt(i-1)===32;)a++,i--;if(i)break;i=-1}else if(u===-2)c=!0,a++;else if(u!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const u={type:n===e.length||c||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?i:r.start._bufferIndex+i,_index:r.start._index+o,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const Vmt={42:Ho,43:Ho,45:Ho,48:Ho,49:Ho,50:Ho,51:Ho,52:Ho,53:Ho,54:Ho,55:Ho,56:Ho,57:Ho,62:Zde},Hmt={91:Ypt},Umt={[-2]:i2,[-1]:i2,32:i2},qmt={35:Jpt,42:dC,45:[RU,dC],60:rmt,61:RU,95:dC,96:MU,126:MU},Wmt={38:Qde,92:Xde},Ymt={[-5]:a2,[-4]:a2,[-3]:a2,33:wmt,38:Qde,42:tF,60:[Cpt,umt],91:Cmt,92:[Xpt,Xde],93:d$,95:tF,96:Ppt},Gmt={null:[tF,Lmt]},Kmt={null:[42,95]},Zmt={null:[]},Xmt=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Kmt,contentInitial:Hmt,disable:Zmt,document:Vmt,flow:qmt,flowInitial:Umt,insideSpan:Gmt,string:Wmt,text:Ymt},Symbol.toStringTag,{value:"Module"}));function Qmt(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},o=[];let i=[],a=[];const c={attempt:_(N),check:_(k),consume:S,enter:w,exit:C,interrupt:_(k,{interrupt:!0})},u={code:null,containerState:{},defineSkip:b,events:[],now:g,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function f(I){return i=Hi(i,I),x(),i[i.length-1]!==null?[]:(j(t,0),u.events=mE(o,u.events,u),u.events)}function h(I,D){return egt(p(I),D)}function p(I){return Jmt(i,I)}function g(){const{_bufferIndex:I,_index:D,line:A,column:R,offset:F}=r;return{_bufferIndex:I,_index:D,line:A,column:R,offset:F}}function b(I){s[I.line]=I.column,E()}function x(){let I;for(;r._index<i.length;){const D=i[r._index];if(typeof D=="string")for(I=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===I&&r._bufferIndex<D.length;)y(D.charCodeAt(r._bufferIndex));else y(D)}}function y(I){d=d(I)}function S(I){Gt(I)?(r.line++,r.column=1,r.offset+=I===-3?2:1,E()):I!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=I}function w(I,D){const A=D||{};return A.type=I,A.start=g(),u.events.push(["enter",A,u]),a.push(A),A}function C(I){const D=a.pop();return D.end=g(),u.events.push(["exit",D,u]),D}function N(I,D){j(I,D.from)}function k(I,D){D.restore()}function _(I,D){return A;function A(R,F,H){let B,U,W,O;return Array.isArray(R)?Y(R):"tokenize"in R?Y([R]):Z(R);function Z($){return z;function z(V){const P=V!==null&&$[V],q=V!==null&&$.null,G=[...Array.isArray(P)?P:P?[P]:[],...Array.isArray(q)?q:q?[q]:[]];return Y(G)(V)}}function Y($){return B=$,U=0,$.length===0?H:M($[U])}function M($){return z;function z(V){return O=T(),W=$,$.partial||(u.currentConstruct=$),$.name&&u.parser.constructs.disable.null.includes($.name)?L():$.tokenize.call(D?Object.assign(Object.create(u),D):u,c,K,L)(V)}}function K($){return I(W,O),F}function L($){return O.restore(),++U<B.length?M(B[U]):H}}}function j(I,D){I.resolveAll&&!o.includes(I)&&o.push(I),I.resolve&&vi(u.events,D,u.events.length-D,I.resolve(u.events.slice(D),u)),I.resolveTo&&(u.events=I.resolveTo(u.events,u))}function T(){const I=g(),D=u.previous,A=u.currentConstruct,R=u.events.length,F=Array.from(a);return{from:R,restore:H};function H(){r=I,u.previous=D,u.currentConstruct=A,u.events.length=R,a=F,E()}}function E(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function Jmt(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,o=t.end._bufferIndex;let i;if(n===s)i=[e[n].slice(r,o)];else{if(i=e.slice(n,s),r>-1){const a=i[0];typeof a=="string"?i[0]=a.slice(r):i.shift()}o>0&&i.push(e[s].slice(0,o))}return i}function egt(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const o=e[n];let i;if(typeof o=="string")i=o;else switch(o){case-5:{i="\r";break}case-4:{i=`
1380
1380
  `;break}case-3:{i=`\r
1381
1381
  `;break}case-2:{i=t?" ":" ";break}case-1:{if(!t&&s)continue;i=" ";break}default:i=String.fromCharCode(o)}s=o===-2,r.push(i)}return r.join("")}function tgt(e){const r={constructs:Gde([Xmt,...(e||{}).extensions||[]]),content:s(gpt),defined:[],document:s(xpt),flow:s(Pmt),lazy:{},string:s($mt),text:s(zmt)};return r;function s(o){return i;function i(a){return Qmt(r,o,a)}}}function ngt(e){for(;!Jde(e););return e}const FU=/[\0\t\n\r]/g;function rgt(){let e=1,t="",n=!0,r;return s;function s(o,i,a){const c=[];let u,d,f,h,p;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(i||void 0).decode(o)),f=0,t="",n&&(o.charCodeAt(0)===65279&&f++,n=void 0);f<o.length;){if(FU.lastIndex=f,u=FU.exec(o),h=u&&u.index!==void 0?u.index:o.length,p=o.charCodeAt(h),!u){t=o.slice(f);break}if(p===10&&f===h&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<h&&(c.push(o.slice(f,h)),e+=h-f),p){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return a&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const sgt=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ogt(e){return e.replace(sgt,igt)}function igt(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return Kde(n.slice(o?2:1),o?16:10)}return u$(n)||e}const ofe={}.hasOwnProperty;function agt(e,t,n){return typeof t!="string"&&(n=t,t=void 0),lgt(n)(ngt(tgt(n).document().write(rgt()(e,t,!0))))}function lgt(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(xe),autolinkProtocol:T,autolinkEmail:T,atxHeading:o(he),blockQuote:o(q),characterEscape:T,characterReference:T,codeFenced:o(G),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:o(G,i),codeText:o(X,i),codeTextData:T,data:T,codeFlowValue:T,definition:o(J),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:o(de),hardBreakEscape:o(be),hardBreakTrailing:o(be),htmlFlow:o(Se,i),htmlFlowData:T,htmlText:o(Se,i),htmlTextData:T,image:o(se),label:i,link:o(xe),listItem:o(Ae),listItemValue:h,listOrdered:o(ie,f),listUnordered:o(ie),paragraph:o(oe),reference:M,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:o(he),strong:o(ge),thematicBreak:o(me)},exit:{atxHeading:c(),atxHeadingSequence:N,autolink:c(),autolinkEmail:P,autolinkProtocol:V,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:L,characterReferenceMarkerNumeric:L,characterReferenceValue:$,characterReference:z,codeFenced:c(x),codeFencedFence:b,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:E,codeIndented:c(y),codeText:c(F),codeTextData:E,data:E,definition:c(),definitionDestinationString:C,definitionLabelString:S,definitionTitleString:w,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(A),htmlFlowData:E,htmlText:c(R),htmlTextData:E,image:c(B),label:W,labelText:U,lineEnding:I,link:c(H),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:K,resourceDestinationString:O,resourceTitleString:Z,resource:Y,setextHeading:c(j),setextHeadingLineSequence:_,setextHeadingText:k,strong:c(),thematicBreak:c()}};ife(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ee){let te={type:"root",children:[]};const ue={stack:[te],tokenStack:[],config:t,enter:a,exit:u,buffer:i,resume:d,data:n},ne=[];let Ce=-1;for(;++Ce<ee.length;)if(ee[Ce][1].type==="listOrdered"||ee[Ce][1].type==="listUnordered")if(ee[Ce][0]==="enter")ne.push(Ce);else{const ve=ne.pop();Ce=s(ee,ve,Ce)}for(Ce=-1;++Ce<ee.length;){const ve=t[ee[Ce][0]];ofe.call(ve,ee[Ce][1].type)&&ve[ee[Ce][1].type].call(Object.assign({sliceSerialize:ee[Ce][2].sliceSerialize},ue),ee[Ce][1])}if(ue.tokenStack.length>0){const ve=ue.tokenStack[ue.tokenStack.length-1];(ve[1]||PU).call(ue,void 0,ve[0])}for(te.position={start:mu(ee.length>0?ee[0][1].start:{line:1,column:1,offset:0}),end:mu(ee.length>0?ee[ee.length-2][1].end:{line:1,column:1,offset:0})},Ce=-1;++Ce<t.transforms.length;)te=t.transforms[Ce](te)||te;return te}function s(ee,te,ue){let ne=te-1,Ce=-1,ve=!1,re,Ee,Fe,$e;for(;++ne<=ue;){const Xe=ee[ne];switch(Xe[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Xe[0]==="enter"?Ce++:Ce--,$e=void 0;break}case"lineEndingBlank":{Xe[0]==="enter"&&(re&&!$e&&!Ce&&!Fe&&(Fe=ne),$e=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:$e=void 0}if(!Ce&&Xe[0]==="enter"&&Xe[1].type==="listItemPrefix"||Ce===-1&&Xe[0]==="exit"&&(Xe[1].type==="listUnordered"||Xe[1].type==="listOrdered")){if(re){let qe=ne;for(Ee=void 0;qe--;){const We=ee[qe];if(We[1].type==="lineEnding"||We[1].type==="lineEndingBlank"){if(We[0]==="exit")continue;Ee&&(ee[Ee][1].type="lineEndingBlank",ve=!0),We[1].type="lineEnding",Ee=qe}else if(!(We[1].type==="linePrefix"||We[1].type==="blockQuotePrefix"||We[1].type==="blockQuotePrefixWhitespace"||We[1].type==="blockQuoteMarker"||We[1].type==="listItemIndent"))break}Fe&&(!Ee||Fe<Ee)&&(re._spread=!0),re.end=Object.assign({},Ee?ee[Ee][1].start:Xe[1].end),ee.splice(Ee||ne,0,["exit",re,Xe[2]]),ne++,ue++}if(Xe[1].type==="listItemPrefix"){const qe={type:"listItem",_spread:!1,start:Object.assign({},Xe[1].start),end:void 0};re=qe,ee.splice(ne,0,["enter",qe,Xe[2]]),ne++,ue++,Fe=void 0,$e=!0}}}return ee[te][1]._spread=ve,ue}function o(ee,te){return ue;function ue(ne){a.call(this,ee(ne),ne),te&&te.call(this,ne)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(ee,te,ue){this.stack[this.stack.length-1].children.push(ee),this.stack.push(ee),this.tokenStack.push([te,ue||void 0]),ee.position={start:mu(te.start),end:void 0}}function c(ee){return te;function te(ue){ee&&ee.call(this,ue),u.call(this,ue)}}function u(ee,te){const ue=this.stack.pop(),ne=this.tokenStack.pop();if(ne)ne[0].type!==ee.type&&(te?te.call(this,ee,ne[0]):(ne[1]||PU).call(this,ee,ne[0]));else throw new Error("Cannot close `"+ee.type+"` ("+jy({start:ee.start,end:ee.end})+"): it’s not open");ue.position.end=mu(ee.end)}function d(){return c$(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(ee){if(this.data.expectingFirstListItemValue){const te=this.stack[this.stack.length-2];te.start=Number.parseInt(this.sliceSerialize(ee),10),this.data.expectingFirstListItemValue=void 0}}function p(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.lang=ee}function g(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.meta=ee}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function x(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee.replace(/(\r?\n|\r)$/g,"")}function S(ee){const te=this.resume(),ue=this.stack[this.stack.length-1];ue.label=te,ue.identifier=_a(this.sliceSerialize(ee)).toLowerCase()}function w(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.title=ee}function C(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.url=ee}function N(ee){const te=this.stack[this.stack.length-1];if(!te.depth){const ue=this.sliceSerialize(ee).length;te.depth=ue}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function _(ee){const te=this.stack[this.stack.length-1];te.depth=this.sliceSerialize(ee).codePointAt(0)===61?1:2}function j(){this.data.setextHeadingSlurpLineEnding=void 0}function T(ee){const ue=this.stack[this.stack.length-1].children;let ne=ue[ue.length-1];(!ne||ne.type!=="text")&&(ne=fe(),ne.position={start:mu(ee.start),end:void 0},ue.push(ne)),this.stack.push(ne)}function E(ee){const te=this.stack.pop();te.value+=this.sliceSerialize(ee),te.position.end=mu(ee.end)}function I(ee){const te=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ue=te.children[te.children.length-1];ue.position.end=mu(ee.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(te.type)&&(T.call(this,ee),E.call(this,ee))}function D(){this.data.atHardBreak=!0}function A(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee}function R(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee}function F(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.value=ee}function H(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const te=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=te,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function B(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const te=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=te,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function U(ee){const te=this.sliceSerialize(ee),ue=this.stack[this.stack.length-2];ue.label=ogt(te),ue.identifier=_a(te).toLowerCase()}function W(){const ee=this.stack[this.stack.length-1],te=this.resume(),ue=this.stack[this.stack.length-1];if(this.data.inReference=!0,ue.type==="link"){const ne=ee.children;ue.children=ne}else ue.alt=te}function O(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.url=ee}function Z(){const ee=this.resume(),te=this.stack[this.stack.length-1];te.title=ee}function Y(){this.data.inReference=void 0}function M(){this.data.referenceType="collapsed"}function K(ee){const te=this.resume(),ue=this.stack[this.stack.length-1];ue.label=te,ue.identifier=_a(this.sliceSerialize(ee)).toLowerCase(),this.data.referenceType="full"}function L(ee){this.data.characterReferenceType=ee.type}function $(ee){const te=this.sliceSerialize(ee),ue=this.data.characterReferenceType;let ne;ue?(ne=Kde(te,ue==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ne=u$(te);const Ce=this.stack[this.stack.length-1];Ce.value+=ne}function z(ee){const te=this.stack.pop();te.position.end=mu(ee.end)}function V(ee){E.call(this,ee);const te=this.stack[this.stack.length-1];te.url=this.sliceSerialize(ee)}function P(ee){E.call(this,ee);const te=this.stack[this.stack.length-1];te.url="mailto:"+this.sliceSerialize(ee)}function q(){return{type:"blockquote",children:[]}}function G(){return{type:"code",lang:null,meta:null,value:""}}function X(){return{type:"inlineCode",value:""}}function J(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function de(){return{type:"emphasis",children:[]}}function he(){return{type:"heading",depth:0,children:[]}}function be(){return{type:"break"}}function Se(){return{type:"html",value:""}}function se(){return{type:"image",title:null,url:"",alt:null}}function xe(){return{type:"link",title:null,url:"",children:[]}}function ie(ee){return{type:"list",ordered:ee.type==="listOrdered",start:null,spread:ee._spread,children:[]}}function Ae(ee){return{type:"listItem",spread:ee._spread,checked:null,children:[]}}function oe(){return{type:"paragraph",children:[]}}function ge(){return{type:"strong",children:[]}}function fe(){return{type:"text",value:""}}function me(){return{type:"thematicBreak"}}}function mu(e){return{line:e.line,column:e.column,offset:e.offset}}function ife(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?ife(e,r):cgt(e,r)}}function cgt(e,t){let n;for(n in t)if(ofe.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function PU(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+jy({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+jy({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+jy({start:t.start,end:t.end})+") is still open")}function ugt(e){const t=this;t.parser=n;function n(r){return agt(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function dgt(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function fgt(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -1407,4 +1407,4 @@ Defaulting to \`null\`.`}var _de=Sde,Ift=Nde;const Q3=Q.forwardRef(({className:e
1407
1407
  More info: ${s.docs}`:"",a=typeof s.message=="string"&&s.message.trim()?s.message.trim():typeof s.error=="string"&&s.error.trim()?s.error.trim():null;if(a){const c=o?` (code: ${o})`:"",u=o==="insufficient_quota"||a.toLowerCase().includes("quota")?`
1408
1408
 
1409
1409
  Semaphor supports bring-your-own OpenAI API keys. Add yours in Settings or drop a note to support@semaphor.cloud and we’ll help you get set up.`:"";return`${a}${c}${i}${u}`}return null};if(typeof e=="string"){const r=e.trim();if(!r)return"Something went wrong.";try{const s=JSON.parse(r),o=t(s);if(o)return o}catch{}return r}const n=t(e);if(n)return n;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function S$({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(Ki,{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:_0t(e)})]})}function j0t({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(S$,{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 E0t({text:e,files:t}){return l.jsxs(nhe,{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(Mft,{file:n},n.id))})]})}function T0t({text:e}){const t=e.split("|"),n=t[0],r=t[1]||"{}",s=JSON.parse(r);return l.jsxs("div",{className:"space-y-1 text-xs",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-bold",children:"System Message:"})," ",n]}),l.jsxs("div",{className:"space-y-1",children:[l.jsx("span",{className:"font-mono text-xs",children:"Scope:"}),l.jsx(Zft,{children:JSON.stringify(s,null,2)})]})]})}function rhe(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")?w$(r,t):!1}})}function xq(){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 I0t({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(xq,{}),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(xq,{}),l.jsx("span",{children:e==="submitted"?"Thinking":"Generating"})]}):e==="error"?l.jsx(S$,{errorMessage:t}):null}function D0t(e){var t;return e?(t=[...e].reverse().find(n=>{var r;return n.role==="assistant"&&((r=n.parts)==null?void 0:r.some(s=>s.type==="text"&&typeof s.text=="string"&&s.text.trim().length>0))}))==null?void 0:t.id:void 0}function M0t({message:e,messageIndex:t,messages:n,showTools:r=!1,onAddToDashboard:s,showSystemMessage:o=!1,handleRun:i,onQuickReply:a,disableQuickReplies:c=!1}){var y,S,w,C;const u=D0t(n),d=e.id===u;if(e.role==="user"){const N=((y=e.parts)==null?void 0:y.filter(T=>T.type==="text"))||[],k=((S=e.parts)==null?void 0:S.filter(T=>T.type==="file"))||[],_=N.map(T=>T.text).join(`
1410
- `).trim(),j=k.map((T,E)=>{var A,R;let I="",D;if((A=T.url)!=null&&A.startsWith("data:")){const F=T.url.match(/data:[^;]+;base64,(.+)/);F&&(I=F[1],(R=T.mediaType)!=null&&R.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${E}`,name:T.filename||`File ${E+1}`,size:0,type:T.mediaType||"application/octet-stream",data:I,preview:D}});return l.jsx(E0t,{text:_||void 0,files:j.length>0?j:void 0})}const f=((w=e.parts)==null?void 0:w.filter(N=>N.type==="reasoning"))||[],h=f.length>0,p=f.some(N=>N.state==="streaming"),g=f.filter(N=>N.text&&N.text.trim().length>0),b=h&&(g.length>0||p)?l.jsxs(Hc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Uc,{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(mr,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:p?"animate-pulse":"",children:p?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(qc,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,k)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:k+1}),l.jsx(uq,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${k}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,k)=>{var j;const _=`${e.id||t}-${k}`;switch(N.type){case"text":{const T=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:E,quickReplies:I}=N0t(T),D=E.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(uq,{text:E,handleRun:i,onAddToDashboard:s,messageId:e.id,messages:n}),I.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[I.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(({label:A,value:R},F)=>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:A})})}),l.jsx(m.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:R})})]},`${_}-qr-${F}`))})]})]},_)}return e.role==="system"&&o?l.jsx(T0t,{text:T},_):null}case"error":{const T=N,E=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(S$,{errorMessage:E})},_)}case"reasoning":return null;default:return((j=N.type)!=null&&j.startsWith("tool-")||N.type==="dynamic-tool")&&w$(N,r)?l.jsx(Aa,{FallbackComponent:({error:T,resetErrorBoundary:E})=>l.jsx(j0t,{error:T,resetErrorBoundary:E}),children:l.jsx(y0t,{part:N,idx:_,messageId:e.id,showTools:r,onAddToDashboard:s,messages:n})},_):null}});return e.role==="assistant"?rhe(e,r)?l.jsxs(nhe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const A0t=8,R0t=24,F0t=20;function P0t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function she({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:s,onQuickReply:o,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:p,scrollToEndSignal:g=0}){const b=v.useRef(null),x=v.useRef(null),y=v.useRef(e.length),S=v.useRef(!1),w=v.useRef(null),C=v.useRef(!1),N=v.useRef(g),[k,_]=v.useState(!0),[j,T]=v.useState(0),[E,I]=v.useState(R0t);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],A=rhe(D,t),R=P0t(a,c,u,A),F=J_({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const O=e[W];return(O==null?void 0:O.role)==="user"?88:180},getItemKey:W=>{const O=e[W];return(O==null?void 0:O.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:A0t,overscan:6,gap:20,paddingEnd:R?E+F0t:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const O=W.isAtEnd();_(Z=>Z===O?Z:O),O&&T(0)}}),H=v.useCallback((W="smooth")=>{w.current!==null&&cancelAnimationFrame(w.current),w.current=requestAnimationFrame(()=>{w.current=null,F.scrollToEnd({behavior:W})}),T(0),_(!0)},[F]);v.useLayoutEffect(()=>{S.current||(S.current=!0,H("auto"))},[H]),v.useLayoutEffect(()=>{C.current&&(C.current=!1,H("auto"))},[e.length,g,H]),v.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!F.isAtEnd()&&T(O=>O+e.length-W),e.length===0&&(T(0),_(!0),S.current=!1,C.current=!1)},[e.length,F]);const B=F.getVirtualItems(),U=F.getTotalSize();return v.useEffect(()=>()=>{w.current!==null&&cancelAnimationFrame(w.current)},[]),v.useLayoutEffect(()=>{const W=x.current;if(!W||!R)return;const O=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&I(M=>M===Y?M:Y)};if(O(),typeof ResizeObserver>"u")return;const Z=new ResizeObserver(O);return Z.observe(W),()=>Z.disconnect()},[R,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(Vl,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:m.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:U},children:[B.map(W=>{const O=e[W.index];return O?l.jsx("div",{ref:F.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(M0t,{message:O,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:s,onQuickReply:o,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(U-E,0)}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(I0t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!k&&l.jsxs("button",{type:"button",onClick:()=>H("smooth"),"aria-label":"Scroll to latest",className:m.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",p),children:[l.jsx(Ls,{className:"h-3 w-3"}),"Latest",j>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:j>9?"9+":j})]})]})}function O0t(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 L0t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function $0t({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:s}){const[o,i]=v.useState(!1),[a,c]=v.useState(m.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[p,g]=v.useState(!1),[b,x]=v.useState(!1),[y,S]=v.useState(0),w=n??b,{isLocalDev:C,isConsoleMode:N}=bg(),k=C||N||a,_=v.useRef(null);m.useDashboardStore(ne=>ne.dashboard.aiScopeTables),m.useDashboardStore(ne=>ne.isDashboardEditing);const j=m.useDashboardStore(ne=>ne.selectedSheetId),{setDataSource:T}=m.useEditorActions(),{setSelectedFrameId:E,setIsDashboardEditing:I}=m.useDashboardActions(),D=qL(),{clearAssistantMessageContexts:A}=m.useAIActions(),{clearQueue:R}=m.useQueueActions(),{clearFileAttachments:F,getFileAttachments:H}=m.useFileActions(),B=m.useFileAttachments("dashboard"),U=m.useEditorStore(ne=>ne.card.dataSource),{assistantProfile:W}=mde(),O=m.useDashboardStore(ne=>ne.handleOpenAssistantProfile),{selectedEntities:Z,applyDashboardDefaultEntities:Y}=Pj("dashboard"),{sendMessage:M,isLoading:K,messages:L,setMessages:$,status:z,stop:V,errorMessage:P,clearError:q}=dft({dynamicVisualMode:f}),G=v.useCallback(()=>{S(ne=>ne+1)},[]),X=v.useCallback(ne=>{r==null||r(ne),n===void 0&&x(ne)},[n,r]),J=v.useCallback(()=>{X(!w)},[w,X]);v.useEffect(()=>{if(!w)return;function ne(Ce){Ce.key==="Escape"&&X(!1)}return window.addEventListener("keydown",ne),()=>{window.removeEventListener("keydown",ne)}},[w,X]);const[de,he]=v.useState(""),be=ne=>{he(ne.target.value)};async function Se({sql:ne,cardTitle:Ce,connectionId:ve,cardType:re,python:Ee,cardConfig:Fe,dataSource:$e,customVisualPreferences:Xe,visualizationMode:qe,dynamicCardPreferences:We}){if(!j)return;const Qe=qe==="dynamic",_e=m.hasValidCardConfig(Fe),tt=ve||($e==null?void 0:$e.connectionId)||"",ze=$e?{...$e,connectionId:tt||$e.connectionId,connectionType:$e.connectionType||"",mode:$e.mode||"database",selectedEntities:$e.selectedEntities||[]}:tt?{connectionId:tt,connectionType:"",mode:"database",selectedEntities:[]}:ug,ot=!(_e&&(!Qe||(We==null?void 0:We.provenance)==="card-config"||(We==null?void 0:We.provenance)==="query_spec")),Pe=ot?O0t(ne):"",Ie=ot?Ee:"",Ke={id:m.v4(),title:Ce||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:re==="horizontalBar"?"y":"x"},...Qe&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:re,sql:Pe,python:Ie,dataSource:ze,config:Fe,connectionId:tt,visualizationMode:qe,dynamicCardPreferences:We,customCardPreferences:Xe?{url:Xe.url,componentName:Xe.componentName,pluginChartType:Xe.pluginChartType,settings:Xe.settings,type:"component"}:void 0},wt={id:m.v4(),cards:[Ke],activeCardId:Ke.id};try{await D(j,wt,"end"),I(!0),E(wt.id)}catch(St){console.error("Failed to add assistant visual to dashboard:",St),at.error(St instanceof Error?St.message:"Failed to prepare semantic metadata for the new visual")}}const se=ne=>{ne.preventDefault();const Ce=de.trim();if(!Ce&&B.length===0)return;const ve=[];Ce&&ve.push({type:"text",text:Ce}),B.forEach(re=>{re.data&&ve.push({type:"file",mediaType:re.type,filename:re.name,url:`data:${re.type};base64,${re.data}`})}),M({role:"user",parts:ve}),he(""),F("dashboard"),G()};v.useEffect(()=>{var ne;e&&((ne=_.current)==null||ne.focus())},[e]),Mde({assistantType:"dashboard",status:z,isLoading:K,sendMessage:M});const{hasActiveTools:xe,activeToolText:ie}=Ade(L);function Ae(ne){const Ce={role:"user",parts:[{type:"text",text:ne.title+" "+ne.subtitle}]};M(Ce),G()}function oe(ne){M({role:"user",parts:[{type:"text",text:ne}]}),G()}function ge(ne){M({role:"user",parts:[{type:"text",text:ne}]}),G()}const fe=v.useCallback(async()=>{const ne=JSON.stringify(L??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ne),at.success("Conversation copied")}catch(Ce){console.error("Failed to copy conversation",Ce),at.error("Unable to copy conversation")}},[L]),me=(de==null?void 0:de.length)===0&&(L==null?void 0:L.filter(ne=>ne.role==="user").length)===0;function ee(){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 te(){return l.jsxs(Mo,{children:[l.jsx(Ao,{asChild:!0,children:l.jsx(jc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Oh,{className:"size-3.5"})})}),l.jsxs(fo,{align:"end",children:[l.jsx(Ec,{children:"Options"}),l.jsx(Ea,{}),l.jsx(xu,{checked:o,onCheckedChange:i,children:"Token Usage"}),l.jsx(xu,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(xu,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(Ea,{}),l.jsx(Ec,{children:"Dynamic Visuals"}),l.jsx(xu,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(xu,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(xu,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ue=l.jsxs("div",{"data-role":"dashboard-assistant",className:m.cn("relative flex h-full grow flex-col break-words bg-background",w&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[ee(),O&&l.jsxs("button",{type:"button",onClick:O,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(W==null?void 0:W.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[N&&te(),k&&l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:fe,children:"Copy Conversation"}),l.jsx(jc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:w?"Exit fullscreen":"Expand",onClick:J,children:w?l.jsx(CF,{className:"h-3.5 w-3.5"}):l.jsx(Ak,{className:"h-3.5 w-3.5"})}),l.jsx(jc,{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 ne=L.filter(Ce=>Ce.role==="assistant").map(Ce=>Ce.id).filter(Ce=>!!Ce);$([]),R("dashboard"),q(),A(ne)},children:l.jsx(Fk,{className:"h-3.5 w-3.5"})}),l.jsx(jc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(m.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(she,{messages:L,showTools:a,showSystemMessage:u,onAddToDashboard:Se,onQuickReply:ge,disableQuickReplies:K,status:z,errorMessage:P,activeToolText:K&&xe?ie:void 0,className:m.cn(w?"px-6 py-5":"px-3 py-3"),rowContentClassName:m.cn(w&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!W&&me&&l.jsx(Gce,{onClick:Ae,placeholders:L0t}),me&&W&&l.jsx(gde,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:oe}),l.jsx(Dde,{assistantType:"dashboard"}),l.jsx(t$,{ref:_,setInput:he,stop:V,input:de,handleInputChange:be,handleSubmit:ne=>{se(ne)},isLoading:K,status:z,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(e$,{incomingSelectedEntities:Z,open:p,onOpenChange:g,dataSource:U||ug,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ne=>Y()})]});return w&&s?_r.createPortal(l.jsx(rb,{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:ue})}),s):ue}function z0t(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=m.useDashboardActions(),s=Hie(),o=m.useDashboardStore(d=>d.dashboard.sheets),a=m.useDashboardStore(d=>d.selectedSheetId)??(o==null?void 0:o[0].id),c=m.useDashboardStore(d=>d.isDashboardEditing),u=m.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(p){if(B0t(p.target))return;const g=p.ctrlKey||p.metaKey;g&&p.key==="c"?(await f(),at.success("Card copied to clipboard"),p.preventDefault()):g&&p.key==="v"&&(await h(),p.preventDefault())}async function f(){try{const p=n();p&&await navigator.clipboard.writeText(JSON.stringify(p))}catch(p){console.error("Failed to copy text:",p)}}async function h(){if(!a)return null;try{const p=await navigator.clipboard.readText(),g=V0t(p);if(g!=null&&g.id){const b=zie(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await s(a,b),r(b.id),at.success("Card pasted from clipboard")}return p}catch(p){return console.error("Failed to paste text:",p),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[s,n,r,a,c,u,t])}function B0t(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 V0t(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 H0t(e,t){switch(e.interactionMode){case"drillToDetail":U0t(e,t);break;case"drillThrough":q0t(e,t);break;case"drillToURL":W0t(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 U0t(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:s,filterGroups:o}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=o.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=o.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}s==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function q0t(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:s,sourceCardId:o}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=s.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function W0t(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 Y0t({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:s,contextMode:o,cardTitle:i,cardDescription:a}){return l.jsx(Po,{open:e,onOpenChange:t,children:l.jsxs(mo,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(ra,{children:[l.jsx(go,{children:i||"Insight Detail"}),l.jsx(oi,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(Wie,{filters:r,filterDefinitions:s,contextMode:o}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(aae,{insightId:n,filters:r,contextMode:o}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function G0t(){const e=m.useInteractionStore(C=>C.interactionStates),t=m.useInteractionStore(C=>C.setInteractionState),n=m.useInteractionStore(C=>C.clearLastInteractionEvent),r=m.useInteractionStore(C=>C.replaceCardWithInsight),s=m.useInteractionStore(C=>C.setPendingDrillThrough),o=m.useInteractionStore(C=>C.pendingDrillThrough),i=m.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=m.useDashboardActions(),{selectDashboard:u}=Fh(),d=m.useDashboardStore(C=>C.dashboard),f=m.useDashboardStore(C=>C.filterValues),{data:h,isLoading:p}=XY((o==null?void 0:o.targetDashboardId)||"",{enabled:!!(o!=null&&o.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=lae(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),S=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:k})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:k})},replaceCardContent:({cardId:C,insightId:N,filters:k,contextMode:_})=>{r(C,N,k,_)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:s,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:k,sourceDashboardTitle:_,targetDashboardId:j})=>{const T={filters:C},E={sourceCardId:m.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},I={...m.createInitialInteractionState(),appliedClickFilters:[E],contextMode:N,sourceDashboardId:k,sourceDashboardTitle:_,targetDashboardId:j};t(m.DRILL_CONTEXT_CARD_ID,I)}}),[a,r,f,c,d,s,t]);v.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const k=N.lastInteractionEvent,_=`${C}-${k.interactionMode}-${k.sourceCardId}-${Date.now()}`;if(y.current.has(_))return;y.current.add(_);try{H0t(k,S)}catch(j){console.error("Error executing interaction event:",j)}finally{n(C),setTimeout(()=>{y.current.delete(_)},5e3)}}})},[e,n,S]),v.useEffect(()=>{if(!(!o||!h||p))try{u(h),c(o.targetDashboardId,o.sourceDashboardId,o.sourceDashboardTitle,o.filters,o.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[o,h,p,u,c,i]);const w=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(Y0t,{open:g.open,onOpenChange:w,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),o&&p&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function K0t(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,s=Z0t(t.value);return r==="="?`${n} = ${s}`:`${n} ${r} ${s}`}).join(", ")}function Z0t(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function X0t(e){return e?`Back to ${e}`:"Back"}function Q0t(){var y,S,w,C,N;const e=m.useInteractionStore(k=>k.interactionStates[m.DRILL_CONTEXT_CARD_ID]),t=m.useDashboardStore(k=>k.actions.goBackFromDrill),n=m.useDashboardStore(k=>k.actions.clearDrillContext),{selectDashboard:r}=Fh(),[s,o]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const k=j=>{o({x:j.clientX-c.current.x,y:j.clientY-c.current.y})},_=()=>{a(!1)};return document.addEventListener("mousemove",k),document.addEventListener("mouseup",_),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",_)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((C=(w=(S=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:S.filterGroups)==null?void 0:w[0])==null?void 0:C.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((N=e.appliedClickFilters)!=null&&N.length))return null;const p=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(k){console.error("[DrillBack] Error during back navigation:",k)}},g=()=>{n()},b=k=>{k.target.closest("button")||(a(!0),c.current={x:k.clientX-s.x,y:k.clientY-s.y})};K0t(f);const x=X0t(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${s.x}px, ${s.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((k,_)=>{const j=k.field.label||k.field.name,T=String(k.value);return l.jsxs(ps,{variant:"secondary",className:"pointer-events-none text-xs",children:[j," = ",T]},_)})})]}),l.jsx(m.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(m.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(m.Button,{variant:"secondary",size:"sm",onClick:p,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(nv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function J0t(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function evt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:p,transition:g,isDragging:b}=ub({id:`filter:${e.id}`,disabled:n||!t}),x={transform:ji.Translate.toString(p),transition:g,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:h,style:x,...d,children:l.jsx(kL,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const yq="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",tvt=[];function ohe({open:e,onOpenChange:t}){var L,$,z;const[n,r]=v.useState(!1),[s,o]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=m.useDashboardStore(V=>{var P;return(P=V.dashboard)==null?void 0:P.sheets}),u=m.useDashboardStore(V=>V.dashboard),d=m.useDashboardStore(V=>V.dashboardInputValues),f=m.useDashboardStore(V=>V.filterValues),h=m.useDashboardStore(V=>V.controlValues),p=m.useDashboardStore(V=>V.inlineFilterValuesMap),g=m.useDashboardStore(V=>V.cardControlValuesMap),b=m.useDashboardStore(V=>V.selectedSheetId),x=m.useDashboardStore(V=>V.selectedSheetId?V.documentInputRuntimeBySheetId[V.selectedSheetId]:void 0),y=m.useDashboardStore(V=>V.isDownloadingPdf),{authToken:S,tokenProps:w}=Ct(),C=c==null?void 0:c.find(V=>V.id===b),N=v.useMemo(()=>m.getDashboardExportSheets(c),[c]),k=m.isDocumentSheet(C),_=k&&C?C.document:void 0,j=v.useMemo(()=>k&&C?hw(u,C.id):[],[C,k,u]),T=j.length>0,E=v.useMemo(()=>k&&C?Uce(u,C.id):!1,[C,k,u]),I=v.useMemo(()=>T?j.map(pw):(_==null?void 0:_.inputs)||tvt,[_,j,T]),D=(($=(L=w==null?void 0:w.params)==null?void 0:L.calendarContext)==null?void 0:$.tz)||((z=w==null?void 0:w.params)==null?void 0:z.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),A=v.useMemo(()=>Ule(I),[I]),R=v.useMemo(()=>Vle(I,D),[I,D]),F=v.useMemo(()=>Hle(I),[I]),H=x?x.filterValuesByInputId:R,B=x?x.controlValuesByInputId:F,U=v.useMemo(()=>k?E&&C&&_?nX({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:_.sections.map(V=>V.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},timezone:D}):Yle(I,H,B,A,A):[],[_,I,C,k,u,g,h,f,p,d,B,H,A,D,E]),W=!!C,O=N.length>0,Z=((c==null?void 0:c.length)||0)>1||k,Y=i.sheetSelection==="current"&&(!W||k&&U.length>0)||i.sheetSelection==="all"&&!O;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!O&&a(V=>({...V,sheetSelection:"current"}))},[O,e,i.sheetSelection]);const M=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function K(){if(y){at.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){at.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){at.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!O){at.error("No dashboard sheets are available to export");return}o(!0);const V=i.sheetSelection==="current"&&k,P=V?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",q=at.loading(P);try{if(V){if(!_||!C)throw new Error("Selected document sheet is missing document data");if(U.length>0){at.dismiss(q),at.error(`Set ${U.join(", ")} before exporting`);return}const X=new Date().toISOString(),J=E?sX({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:_.sections.map(de=>de.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},generatedAt:X,timezone:D}).snapshot:void 0;await qP(w.apiServiceUrl,S,{sheetId:C.id,title:C.title||"Document",pageSize:_.page.size,orientation:_.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:J,...J?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:H,controlValuesByInputId:B,generatedAt:X}}})}else{const X=Mee();await dX(w.apiServiceUrl,S,i.protectPdf?i.password:void 0,i.sheetSelection,X)}at.dismiss(q);const G=V?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";at.success(G,{duration:2e3}),M()}catch(G){at.dismiss(q),at.error("Failed to download PDF",{description:C_(G,"Please try again or contact support."),descriptionClassName:S_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",G)}finally{o(!1)}}return l.jsx(Po,{open:e,onOpenChange:V=>{if(!V){M();return}t(!0)},children:l.jsxs(mo,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(ra,{children:[l.jsx(go,{className:"text-[15px]",children:k?"Export document":"Export dashboard"}),l.jsx(oi,{className:"text-[13px] leading-5",children:k?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[Z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(m.Label,{className:yq,children:"Export scope"}),l.jsxs(Ia,{value:i.sheetSelection,onValueChange:V=>a({...i,sheetSelection:V}),className:"gap-1.5",children:[l.jsxs(m.Label,{htmlFor:"scope-current",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!W&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(js,{value:"current",id:"scope-current",disabled:!W}),k?"This document":"This sheet"," (",(C==null?void 0:C.title)||"Current",")"]}),l.jsxs(m.Label,{htmlFor:"scope-all",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!O&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(js,{value:"all",id:"scope-all",disabled:!O}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),k&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:U.length>0?`Set ${U.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(m.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(m.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(zn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:V=>{a({...i,protectPdf:V,password:V?i.password:""}),V||r(!1)}}),l.jsx(Mk,{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:yq,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(m.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:V=>a({...i,password:V.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:V=>{V.key==="Enter"&&i.password&&K()}}),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(Dk,{className:"h-3.5 w-3.5"}):l.jsx(rv,{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(Kc,{children:[l.jsx(m.Button,{variant:"outline",size:"xs",onClick:M,disabled:s,children:"Cancel"}),l.jsx(m.Button,{size:"xs",onClick:K,disabled:s||y||Y,children:s?l.jsxs(l.Fragment,{children:[l.jsx(m.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(Yc,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function ihe({iconClassName:e,open:t,onOpenChange:n}){const[r,s]=v.useState(!1),o=t!==void 0,i=o?t:r,a=u=>{o||s(u),n==null||n(u)},c=m.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[o?null:l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(Yc,{className:m.cn("size-4",e)})}),l.jsx(ohe,{open:i,onOpenChange:a})]})}function vq(e,t,n){const r=new Set(t),s=[...n];return e.map(o=>r.has(o.id)?s.shift()??o.id:o.id)}function nvt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:s,listeners:o,setNodeRef:i,transform:a,transition:c,isDragging:u}=ub({id:`control:${e.id}`,disabled:!n}),d={transform:ji.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...s,children:l.jsx(ace,{control:e,value:t,isEditing:n,dragListeners:n?o:void 0,onChange:r})})}function wq(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function Sq(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function rvt(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 Sq(t,n);const s=e.filter(a=>r.has(a)),o=new Set(s),i=Sq(t,n).filter(a=>!o.has(a));return[...s,...i]}function svt(e,t){return m.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function ovt(e){return Lm(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Lm(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function Cq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function ivt(e){const t={sheetId:e.selectedSheetId},n=m.getDashboardInputRuntimeSlot(e.dashboardInputValues,e.dashboardInput,t);if(n)return n;const r=m.getDashboardInputRuntimeSlot(e.defaultInputValues,e.dashboardInput,t);return r||m.getBackingDefaultSlot(e.dashboardInput)}function avt(e){return ahe(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 ahe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=svt(e.dashboard,t);return SZ(m_({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!ovt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function lvt(e,t){return"toolbar"}function cvt(){const e=Xc("interactive"),t=m.useDashboardStore($=>$.selectedSheetId),n=m.useDashboardStore($=>$.dashboard.filters),r=m.useDashboardStore($=>$.dashboard.filterLayout),s=m.useDashboardStore($=>$.isDashboardEditing),o=m.useDashboardStore($=>$.controlValues),i=m.useDashboardStore($=>$.filterValues);m.useDashboardStore($=>$.filteringCards);const a=m.useDashboardStore($=>$.inlineFilterValuesMap),c=m.useDashboardStore($=>$.dashboardInputValues),u=m.useInteractionStore($=>$.clearAllClickFilters),d=m.useInteractionStore($=>Object.entries($.interactionStates).reduce((z,[V,P])=>{var q;return V===m.DRILL_CONTEXT_CARD_ID?z:z+(((q=P.appliedClickFilters)==null?void 0:q.length)??0)},0)),f=m.useDashboardStore($=>$.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:p,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:S,setFilteringCards:w,upsertDashboardInput:C}=m.useDashboardActions(),N=zj(ag(lb,{activationConstraint:{distance:5}})),k=m.useDashboardStore($=>$.dashboard),_=avt({dashboard:k,selectedSheetId:t}).filter($=>lvt($.filter)==="toolbar"),j=ahe({dashboard:k,selectedSheetId:t}),T=_.map($=>$.filter),E=new Map(_.map($=>[`filter:${$.filter.id}`,$])),I=XKe(k),D=I.filter($=>!$.hidden&&_0($)==="toolbar"),A=I.filter($=>!$.hidden&&_0($)==="advanced"),R=rvt(r==null?void 0:r.toolbarItemOrder,T,D),F=new Map(T.map($=>[`filter:${$.id}`,$])),H=new Map(D.map($=>[`control:${$.id}`,$]));function B($){const{active:z,over:V}=$;if(!V||z.id===V.id)return;const P=String(z.id),q=String(V.id),G=R.findIndex(xe=>xe===P),X=R.findIndex(xe=>xe===q);if(G===-1||X===-1)return;const J=cb(R,G,X);y({toolbarItemOrder:J});const de=new Set((n||[]).map(xe=>xe.id)),he=R.filter(xe=>xe.startsWith("filter:")).map(xe=>xe.replace("filter:","")).filter(xe=>de.has(xe)),be=J.filter(xe=>xe.startsWith("filter:")).map(xe=>xe.replace("filter:","")).filter(xe=>de.has(xe)),Se=R.filter(xe=>xe.startsWith("control:")).map(xe=>xe.replace("control:","")),se=J.filter(xe=>xe.startsWith("control:")).map(xe=>xe.replace("control:",""));h(vq(n||[],he,be)),g(vq(k.controls||[],Se,se))}const U=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,O=(i==null?void 0:i.filter($=>wq($)).length)??0,Z=j.filter(Cq),Y=Z.filter($=>{const z=ivt({dashboardInput:$,dashboardInputValues:c,defaultInputValues:k.defaultInputValues,selectedSheetId:t});return(z==null?void 0:z.status)==="set"&&z.value.kind==="filter"&&wq(z.value.filterValue)}).length,M=a?Object.values(a).reduce(($,z)=>$+((z==null?void 0:z.length)??0),0):0,K=O+Y+M+d,L=()=>{S([]),Z.forEach($=>{p($,{sheetId:t})}),w([]),u(),a&&Object.entries(a).forEach(([$,z])=>{z==null||z.forEach(V=>{f($,V.filterId)})})};return!T.length&&!D.length&&!A.length&&!W&&K===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(aw,{sensors:N,collisionDetection:sw,onDragEnd:B,children:l.jsxs("div",{className:m.cn("flex items-center",U?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(lw,{items:R,strategy:e3,children:l.jsx(AR,{className:"gap-3 pr-0",wrap:U,children:R.map($=>{const z=F.get($);if(z){const P=E.get($),q=P&&Cq(P);return l.jsx(evt,{filter:z,isEditing:s,storageOptions:q?{storageTarget:"dashboardInput",dashboardInput:P,sheetId:t??void 0}:void 0,inputVariableName:q?P.variableName:void 0,onUpdateFilter:q?(G,X)=>{C({...P,variableName:(X==null?void 0:X.variableName)||P.variableName,filter:G})}:void 0,onRemoveFilter:q?()=>{S((i||[]).filter(G=>G.filterId!==z.id)),b(P.id)}:void 0},$)}const V=H.get($);return V?l.jsx(nvt,{control:V,value:o==null?void 0:o[V.id],isEditing:s,onChange:P=>x(V.id,P)},$):null})})}),A.length>0&&l.jsx(nae,{title:"",controls:A,values:o,onChange:($,z)=>x($.id,z),immediatePlacement:"toolbar",advancedLabel:"More controls"}),K>0&&l.jsxs("button",{type:"button",onClick:L,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(m.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:K})]}),W&&l.jsx("div",{className:m.cn(K>0?"ml-1.5":"ml-auto"),children:l.jsx(ihe,{})})]})})})}function lhe(){var te,ue;const{showAssistant:e,tokenProps:t,renderMode:n}=Ct(),r=J0t((te=t.config)==null?void 0:te.showDashboardAssistant,e),{preferences:s,isConsoleMode:o}=bg(),i=(ue=s==null?void 0:s.cardDisplay)==null?void 0:ue.mode,a=Uh(i),c=zZ({displayMode:i,renderMode:n}),u=v.useRef(null),d=v.useRef(null),[f,h]=v.useState(!1),{handleDragStart:p,isDraggingRef:g,getStyle:b,getPositionClasses:x}=Qot({initialPosition:"bottom-right"}),y=Uf(ne=>ne.setFullscreen),S=Uf(ne=>ne.setPanelOpen),w=Uf(ne=>ne.setContainer),C=TK("dashboard"),N=IK(),k=DK("dashboard"),_=C.isOpen,j=N==="dashboard",T=m.useDashboardStore(ne=>ne.isVisualEditing),E=m.useDashboardStore(ne=>ne.themeStyle),I=Pl(),D=m.useDashboardStore(ne=>{var Ce;return(Ce=ne.dashboard)==null?void 0:Ce.sheets}),A=m.useDashboardStore(ne=>ne.showFilters),R=m.useDashboardStore(ne=>ne.isDashboardEditing),F=m.useDashboardStore(ne=>ne.selectedSheetId),H=D==null?void 0:D.find(ne=>ne.id===F),B=m.useDashboardStore(ne=>{var Ce,ve,re;return(re=(ve=(Ce=ne.dashboard)==null?void 0:Ce.sheets)==null?void 0:ve.find(Ee=>Ee.id===ne.selectedSheetId))==null?void 0:re.kind}),U=m.useDashboardStore(ne=>{var Ce,ve;return((ve=(Ce=ne.dashboard)==null?void 0:Ce.summary)==null?void 0:ve.position)||"top"}),W=B==="document",O=m.useDashboardStore(ne=>{var Ce;return(Ce=ne.dashboard)==null?void 0:Ce.id}),Z=m.useDashboardStore(ne=>ne.isDashboardPanelOpen),Y=m.useDashboardStore(ne=>ne.actions.setIsDashboardPanelOpen),{getDefaultSheetId:M,setDefaultSheetId:K,clearDefaultSheetId:L}=cW(O),[$,z]=v.useState(null);Vk(Zr.DASHBOARD);const{setSelectedSheetId:V,setSheetTitle:P,addSheet:q,setSheets:G}=m.useDashboardActions();z0t(d);const{setActiveAssistantType:X}=m.useAIActions();v.useEffect(()=>{if(O){const ne=M();z(ne)}},[O,M]),v.useEffect(()=>{_?X("dashboard"):N==="dashboard"&&y(null)},[_,X,N,y]),v.useEffect(()=>{var ne;_||(ne=u.current)==null||ne.resize(0)},[_]);function J(ne){var Ce,ve;ne?((Ce=u.current)==null||Ce.resize(40),S("dashboard",!0),y("dashboard"),X("dashboard")):(S("dashboard",!1),y(null),(ve=u.current)==null||ve.resize(0),X(null))}function de(ne="dashboard"){const Ce={id:m.v4(),title:ne==="document"?"New Document":"New Sheet",...ne==="document"?{kind:ne,document:m.createDefaultDocumentDefinition()}:{}};q(Ce),V(Ce.id)}function he(ne,Ce){if(!O)return;$===ne?(L(),z(null),at.success("Default sheet cleared")):(K(ne),z(ne),at.success(`"${Ce}" set as default sheet`))}function be(ne){var Ce;ne<1?(S("dashboard",!1),y(null),X(null),(Ce=u.current)==null||Ce.resize(0)):(_||S("dashboard",!0),X("dashboard"))}function Se(){return(E==null?void 0:E.canvasTheme)==="muted"||!(E!=null&&E.canvasTheme)?"hsl(var(--semaphor-muted))":(E==null?void 0:E.canvasTheme)==="clear"?"":E==null?void 0:E.canvasTheme}const se=(ne,Ce)=>{ne.dataTransfer.setData("tabIndex",Ce.toString())},xe=ne=>{ne.preventDefault()},ie=(ne,Ce)=>{const ve=ne.dataTransfer.getData("tabIndex");if(ve===Ce.toString())return;const re=Array.from(D||[]),[Ee]=re.splice(parseInt(ve),1);re.splice(Ce,0,Ee),G(re)},Ae=t.orgUserId||t.tenantId&&t.endUserId&&t.endUserEmail,oe=r===!0&&!a&&!_&&!T&&!A;function ge(){if(D&&D.length>1||R)return l.jsxs("div",{className:"relative flex w-full items-stretch border-b border-border",children:[o&&Ae&&!Z&&l.jsx("button",{type:"button","aria-label":"Toggle dashboards panel",onClick:()=>{Y(!Z)},className:"group/panel mx-2 inline-flex h-9 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground",children:l.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-[4px] group-hover/panel:bg-muted",children:l.jsx(NF,{className:"h-3.5 w-3.5",strokeWidth:1.75})})}),l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(m.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[D==null?void 0:D.map((ne,Ce)=>{const ve=F===ne.id,re=$===ne.id;return l.jsxs(m.TabsTrigger,{draggable:!0,onDragStart:Ee=>se(Ee,Ce),onDragOver:xe,onDrop:Ee=>ie(Ee,Ce),onClick:()=>V(ne.id),className:m.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:ne.id,children:[ne.kind==="document"&&l.jsx(wi,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(VN,{enabled:R&&ve,text:ne.title,onSave:Ee=>P(ne.id,Ee),children:ne.title},ne.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":re?"Clear default sheet":"Set as default sheet",title:re?"Clear default sheet":"Set as default sheet",onClick:Ee=>{Ee.stopPropagation(),he(ne.id,ne.title||"Sheet")},onKeyDown:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),Ee.stopPropagation(),he(ne.id,ne.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",ve||re?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(EF,{className:m.cn("h-3 w-3 transition-colors",re?"fill-current text-amber-500":"text-muted-foreground")})}),R&&ve&&D.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:Ee=>{Ee.stopPropagation(),h(!0)},onKeyDown:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),Ee.stopPropagation(),h(!0))},children:l.jsx(m.X,{className:"h-3 w-3"})})]},ne.id)}),R&&l.jsxs(Mo,{children:[l.jsx(Ao,{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(pr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(fo,{align:"start",className:"w-48",children:[l.jsxs(Tn,{onSelect:()=>de("dashboard"),children:[l.jsx(Am,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(Tn,{onSelect:()=>de("document"),children:[l.jsx(wi,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})]})}function fe(){return l.jsx("div",{ref:d,style:{},className:"h-full min-h-0 grow",children:D==null?void 0:D.map(ne=>l.jsx(m.TabsContent,{style:{backgroundColor:Se(),...I.dashboardCanvasStyle},className:m.cn("mt-0 h-full min-h-0",{}),value:ne.id,children:l.jsx(EH,{sheet:ne})},ne.id))})}function me(){return l.jsxs(m.Tabs,{"data-role":"dashboard-tabs-container",className:m.cn("relative flex h-full flex-col",E==null?void 0:E.dashboardTabsContainer),onValueChange:ne=>{V(ne)},value:F||void 0,children:[ge(),U==="top"&&!W&&l.jsx(hR,{}),F&&!W&&l.jsx(cvt,{}),W?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:fe()}):l.jsx(Vl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:fe()}),U==="bottom"&&!W&&l.jsx(hR,{}),l.jsx(Jot,{open:f,setOpen:h})]})}const ee=v.useCallback(ne=>{w("dashboard",ne)},[w]);return D?c&&F&&!W?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',F,'" was not found or is not a document sheet in the loaded dashboard.']}):c&&W&&H?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(EH,{sheet:H})}):l.jsxs(l.Fragment,{children:[l.jsx(G0t,{}),l.jsx(Q0t,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(JF,{className:m.cn("flex-1 basis-0 overflow-y-auto transition-opacity",j&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(Oy,{children:me()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(Xot,{open:_,onTabClick:J,withHandle:!0,disabled:!_}),l.jsx(Oy,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:be,defaultSize:_?40:0,ref:u,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx($0t,{open:_,setOpen:J,isFullscreen:j,onFullscreenChange:ne=>y(ne?"dashboard":null),fullscreenContainer:k})})})]})]}),l.jsx("div",{ref:ee,className:m.cn("absolute inset-0",!j&&"pointer-events-none")}),oe&&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||J(!0)},onMouseDown:p,onTouchStart:p,title:"Open Assistant (drag to move)",children:l.jsx(Vme,{className:"h-5 w-5"})})})]})]}):null}const che=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:s,children:o,className:i,style:a,...c},u)=>{const d=v.useId(),f=v.useMemo(()=>uvt(d),[d]),{theme:h}=dF(),p=dvt(h),g=v.useMemo(()=>s??Wc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,s,n]),b=v.useMemo(()=>m.compileAppearance({spec:g,systemMode:p}),[g,p]),x=v.useMemo(()=>m.createAppearanceContextValue(f,b),[b,f]);return l.jsx(m.AppearanceContext.Provider,{value:x,children:l.jsx(rb,{...c,ref:u,className:i,style:a,children:o})})});che.displayName="AppearanceProvider";function uvt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function dvt(e){const t=gC(e),[n,r]=v.useState(()=>fvt());return v.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const s=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!s)return;const o=()=>{r(s.matches?"dark":"light")};return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):((a=s.addListener)==null||a.call(s,o),()=>{var c;return(c=s.removeListener)==null?void 0:c.call(s,o)})},[t]),t==="system"?n:t}function fvt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const uhe=v.createContext({openBrandStudioPreview:()=>{}}),hvt=uhe.Provider;function pvt(){return v.useContext(uhe)}function mvt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const s=gC(t),[o,i]=v.useState(()=>gvt(n)||s),a=v.useCallback(u=>{const d=gC(u);bvt(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:o,setTheme:a}),[o,a]);return l.jsx(Bq.Provider,{...r,value:c,children:e})}function gvt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=gC(t,"system");return n===t?n:null}catch{return null}}function bvt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const xvt=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function C$({appearance:e,children:t}){var I,D;const{authToken:n,id:r,tokenProps:s}=Ct(),o=ev(),i=(I=o.data)==null?void 0:I.organizationAppearance,a=(D=s.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,p]=v.useState(null),[g,b]=v.useState(null),[x,y]=v.useState(null),S=`${s.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,w=$n({queryKey:WY({resourceType:Zr.DASHBOARD,apiServiceUrl:s.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>m.getRequest(`${s.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:A=>(A==null?void 0:A.organizationAppearance)??null,enabled:!o.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:S,appearance:i})},[i,S]),v.useEffect(()=>{w.data!==void 0&&y({scopeKey:S,appearance:w.data})},[w.data,S]);const C=(x==null?void 0:x.scopeKey)===S?x.appearance:null,N=i!==void 0?i:w.data!==void 0?w.data:C,k=v.useMemo(()=>Wc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),_=v.useCallback(()=>{f(g??h??k),u(!0)},[g,h,k]),j=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),p(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:_}),[_]),E=g??h??e;return l.jsx(mvt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(hvt,{value:T,children:l.jsx(che,{organizationAppearance:N,tokenAppearance:a,reactAppearance:E,style:{height:"100%",width:"100%"},children:l.jsxs(m.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(xvt,{appearance:d,onDraftChange:b,onSave:A=>{p(A),b(A),f(A)},onCancel:j})})})]})})})})}function dhe({children:e,preferences:t}){const{currentUser:n}=na(),r=v.useMemo(()=>{var s,o;return{preferences:t||{},isLocalDev:((s=t==null?void 0:t.uiMode)==null?void 0:s.developer)||!1,isConsoleMode:((o=t==null?void 0:t.uiMode)==null?void 0:o.console)||!1}},[t]);return l.jsx(HY.Provider,{value:r,children:l.jsx(Rj,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function yvt(e=2e3,t=500){const n=Qpe(),[r,s]=v.useState(!1),[o,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>s(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),o}function N$({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const s=yvt(e,t);return v.useEffect(()=>(s&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[s,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:s?"ready":""})}function fhe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(Aa,{FallbackComponent:Mj,children:l.jsxs(bF,{dashboardProps:e,children:[l.jsx(N$,{componentType:"dashboard",componentId:e.id}),l.jsx(C$,{appearance:e.appearance,children:l.jsx(dhe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(nP,{...e,type:"dashboard",children:l.jsx(lhe,{})})})})})]})})}function vvt(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[s,o]=v.useState(),i=v.useCallback(()=>{var p,g,b;const a=((p=t.current)==null?void 0:p.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);o(x=>x===h?x:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:s,updateAvailableWidth:i}}function wvt({filter:e}){var g;const t=m.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=bg(),r=Uh((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),s=m.useDashboardStore(b=>b.filterValues),o=s==null?void 0:s.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=m.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:p}=vvt([t,o,r]);return v.useEffect(()=>{p()},[e.title,p]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(m.Label,{className:"my-1 block w-full text-sm",children:l.jsx(ei,{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(NL,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(m.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Svt(){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(wvt,{filter:r}),l.jsx(kj,{filter:r})]},r.id))}):null}function Cvt(){var i;const e=m.useDashboardStore(a=>a.dashboard),t=m.useDashboardStore(a=>a.selectedSheetId),n=m.useDashboardStore(a=>a.isVisualEditing),r=m.useDashboardStore(a=>a.isDashboardEditing),s=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),o=m.isDocumentSheet(s);return l.jsx("div",{role:"dashboard-plus-main",className:m.cn("",{"max-h-0 overflow-hidden":n,"flex min-h-0 grow basis-0 overflow-hidden":!n}),children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[r&&!o&&l.jsx(Svt,{}),l.jsx(lhe,{})]})})}const Nvt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-2Yydgr4q.js"))),kvt=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-C-yLMahk.js"))),_vt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-D0Pc1dwB.js"))),jvt=v.lazy(()=>Promise.resolve().then(()=>require("./resource-management-panel-D6zRXAE_.js")).then(e=>({default:e.ResourceManagementPanel})));function Evt({showControls:e=!1,showFooter:t=!0,...n}){const r=m.useDashboardStore(u=>u.isDashboardPanelOpen),s=m.useDashboardStore(u=>u.isVisualEditing),o=m.useDashboardStore(u=>u.showDashboardJSON),i=m.useDashboardStore(u=>u.actions.setIsDashboardPanelOpen),{appearance:a,preferences:c}=n;return l.jsx(Aa,{FallbackComponent:Mj,children:l.jsxs(bF,{dashboardProps:n,children:[l.jsx(N$,{componentType:"surfboard",componentId:n.id}),l.jsxs(C$,{appearance:a,children:[l.jsx(Kbe,{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(dhe,{preferences:c,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(_vt,{})}),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(Nvt,{})}),l.jsxs("div",{className:"flex grow overflow-hidden",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(jvt,{isOpen:r,onClose:()=>i(!1),variant:"inline"})}),l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(nP,{...n,type:"dashboard",children:[s&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(kvt,{})}),l.jsx(Cvt,{})]})})]})]})]})]})]})})}var Tvt=Object.defineProperty,Ivt=(e,t,n)=>t in e?Tvt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wS=(e,t,n)=>Ivt(e,typeof t!="symbol"?t+"":t,n);const Dvt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},Mvt={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}},Avt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function Rvt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function hhe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const Fvt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const s=hhe(t);if(typeof n<"u"&&s in n.container)return n.container[s]})();return typeof r=="function"?r.bind(n):void 0}},Pvt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},Ovt={stringify:e=>e,parse:e=>e},v2={string:Ovt,number:Pvt,boolean:Dvt,function:Mvt,method:Fvt,json:Avt},hx=Symbol.for("r2wc.render"),SS=Symbol.for("r2wc.connected"),Jd=Symbol.for("r2wc.context"),ci=Symbol.for("r2wc.props");function Lvt(e,t,n){var r,s,o;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const p of i){c[p]=Array.isArray(t.props)?"string":t.props[p];const g=Rvt(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(),wS(this,o,!0),wS(this,s),wS(this,r,{}),wS(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[ci].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],S=y?v2[y]:null;if(y==="method"){const w=hhe(b);Object.defineProperty(this[ci].container,w,{enumerable:!0,configurable:!0,get(){return this[ci][w]},set(C){this[ci][w]=C,this[hx]()}}),this[ci][g]=S.parse(x,b,this)}S!=null&&S.parse&&x&&(this[ci][g]=S.parse(x,b,this))}for(const g of a)this[ci][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[SS]=!0,this[hx]()}disconnectedCallback(){this[SS]=!1,this[Jd]&&n.unmount(this[Jd]),delete this[Jd]}attributeChangedCallback(g,b,x){const y=f[g],S=c[y],w=S?v2[S]:null;y in c&&w!=null&&w.parse&&x&&(this[ci][y]=w.parse(x,g,this),this[hx]())}[(o=SS,s=Jd,r=ci,hx)](){this[SS]&&(this[Jd]?n.update(this[Jd],this[ci]):this[Jd]=n.mount(this.container,e,this[ci]))}}for(const p of i){const g=d[p],b=c[p];Object.defineProperty(h.prototype,p,{enumerable:!0,configurable:!0,get(){return this[ci][p]},set(x){this[ci][p]=x;const y=b?v2[b]:null;if(y!=null&&y.stringify){const S=y.stringify(x,g,this);this.getAttribute(g)!==S&&this.setAttribute(g,S)}else this[hx]()}})}return h}function $vt(e,t,n){const r=Lq.createRoot(e),s=v.createElement(t,n);return r.render(s),{root:r,ReactComponent:t}}function zvt({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function Bvt({root:e}){e.unmount()}function Vvt(e,t={}){return Lvt(e,t,{mount:$vt,update:zvt,unmount:Bvt})}const Hvt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},Uvt=Vvt(fhe,{props:Hvt}),qvt=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(N3,{context:t})," "]})}),phe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),Wvt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),Yvt=Array.from(phe).join(", "),Gvt=3,Kvt="Self-heal",Zvt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function Xvt({card:e}){var W,O,Z,Y,M;const[t,n]=v.useState({}),{authToken:r}=Ct(),s=m.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:o}=m.useAppearance(),i=v.useMemo(()=>Kv(o),[o]),a=m.useEditorStore(K=>K.frame),c=m.useEditorStore(K=>K.inlineFilterValuesMap[e.id]),u=m.useEditorStore(K=>K.actions.setCardInlineFilterValue),d=m.useEditorStore(K=>K.actions.removeCardInlineFilterValue),f=e,{getCard:h,manifest:p}=Xh(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(O=p==null?void 0:p.visuals)==null?void 0:O.find(K=>{var L;return K.name===((L=f.customCardPreferences)==null?void 0:L.componentName)}),b=Zv(f,g)??"single",x=v.useMemo(()=>TL({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=v.useMemo(()=>{const K=x.findIndex(L=>(L==null?void 0:L.id)===e.id);return K<0?-1:S0(e,K)},[x,e]),S=v.useMemo(()=>b!=="multiple"||y<0?e.type:hm(e,y,g==null?void 0:g.slots)??e.type,[b,y,e,g==null?void 0:g.slots]),w=v.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:S!==e.type?{...e,type:S}:e,[e,S,b]),{data:C}=v_(w),N=m.useInteractionStore(K=>K.interactionStates),k=m.useDashboardStore(K=>{var L;return(L=K.dashboard)==null?void 0:L.id}),_=m.useDashboardStore(K=>K.dashboard.filters),j=m.useDashboardStore(K=>K.filterValues),T=m.useDashboardStore(K=>K.selectedSheetId),E=v.useMemo(()=>_L({card:e,sheetId:T||"",inlineFilterValues:c,setInlineFilterValue:K=>u(e.id,K),removeInlineFilterValue:K=>d(e.id,K)}),[e,T,c,u,d]),{cardFilters:I,cardFilterValues:D}=v.useMemo(()=>hv({card:e,interactionStates:N,currentDashboardId:k,filters:_,filterValues:j,selectedSheetId:T}),[e,N,k,_,j,T]),A=v.useCallback((K,L)=>{const $=DL(L);n(z=>({...z,[K]:$}))},[]),R=(Z=f.customCardPreferences)==null?void 0:Z.componentName,F=R?h(R):null,H=zN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),B=v.useMemo(()=>EL(x),[x]),U=v.useMemo(()=>B.map((K,L)=>hm(K,L,g==null?void 0:g.slots)),[B,g==null?void 0:g.slots]);return R?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:[F&&b==="single"&&l.jsx(F,{editing:!0,params:s,theme:i,settings:H,cardMetadata:yie({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:A,data:(C==null?void 0:C.records)||[],filters:I,filterValues:[...D||[],...c||[]],inlineFilters:E}),F&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((K,L)=>{if(!K)return null;const $=S0(K,L),z=hm(K,$,g==null?void 0:g.slots);return l.jsx(Q5,{onDataChange:A,card:K,effectiveCardType:z},`${K.id}-${$}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(F,{editing:!0,onDataChange:A,...ML({configCard:f,slotOrderedCards:B,slotTypes:U,multiInputData:t,params:s,theme:i,chartSettings:H,filters:I,filterValues:[...D||[],...c||[]],inlineFilters:E})})})]})]},(M=f.customCardPreferences)==null?void 0:M.componentName)}):null}const Qvt=v.memo(Xvt,(e,t)=>{var n,r,s,o,i,a,c,u;return e.card.id===t.card.id&&e.card.inlineFilters===t.card.inlineFilters&&((n=e.card.customCardPreferences)==null?void 0:n.settings)===((r=t.card.customCardPreferences)==null?void 0:r.settings)&&((s=e.card.customCardPreferences)==null?void 0:s.slotSettings)===((o=t.card.customCardPreferences)==null?void 0:o.slotSettings)&&((i=e.card.customCardPreferences)==null?void 0:i.url)===((a=t.card.customCardPreferences)==null?void 0:a.url)&&((c=e.card.customCardPreferences)==null?void 0:c.componentName)===((u=t.card.customCardPreferences)==null?void 0:u.componentName)}),Jvt=m.create()(m.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(s=>s.type===n&&s.id===r),toggleStar:n=>{e(r=>{const s=r.starredCharts.findIndex(o=>o.type===n.type&&o.id===n.id);return s>=0?{starredCharts:r.starredCharts.filter((o,i)=>i!==s)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(s=>s.type===n&&s.id===r)}),{name:"semaphor-starred-charts"}));var mhe=["PageUp","PageDown"],ghe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],bhe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},bb="Slider",[aF,ewt,twt]=m.createCollection(bb),[xhe]=m.createContextScope(bb,[twt]),[nwt,wE]=xhe(bb),yhe=Q.forwardRef((e,t)=>{const{name:n,min:r=0,max:s=100,step:o=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:p=!1,form:g,...b}=e,x=Q.useRef(new Set),y=Q.useRef(0),w=i==="horizontal"?rwt:swt,[C=[],N]=m.useControllableState({prop:d,defaultProp:u,onChange:I=>{var A;(A=[...x.current][y.current])==null||A.focus(),f(I)}}),k=Q.useRef(C);function _(I){const D=cwt(C,I);E(I,D)}function j(I){E(I,y.current)}function T(){const I=k.current[y.current];C[y.current]!==I&&h(C)}function E(I,D,{commit:A}={commit:!1}){const R=hwt(o),F=pwt(Math.round((I-r)/o)*o+r,R),H=m.clamp(F,[r,s]);N((B=[])=>{const U=awt(B,H,D);if(fwt(U,c*o)){y.current=U.indexOf(H);const W=String(U)!==String(B);return W&&A&&h(U),W?U:B}else return B})}return l.jsx(nwt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:s,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(aF.Provider,{scope:e.__scopeSlider,children:l.jsx(aF.Slot,{scope:e.__scopeSlider,children:l.jsx(w,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:m.composeEventHandlers(b.onPointerDown,()=>{a||(k.current=C)}),min:r,max:s,inverted:p,onSlideStart:a?void 0:_,onSlideMove:a?void 0:j,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&E(r,0,{commit:!0}),onEndKeyDown:()=>!a&&E(s,C.length-1,{commit:!0}),onStepKeyDown:({event:I,direction:D})=>{if(!a){const F=mhe.includes(I.key)||I.shiftKey&&ghe.includes(I.key)?10:1,H=y.current,B=C[H],U=o*F*D;E(B+U,H,{commit:!0})}}})})})})});yhe.displayName=bb;var[vhe,whe]=xhe(bb,{startEdge:"left",endEdge:"right",size:"width",direction:1}),rwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:s,inverted:o,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=Q.useState(null),p=m.useComposedRefs(t,w=>h(w)),g=Q.useRef(void 0),b=m.useDirection(s),x=b==="ltr",y=x&&!o||!x&&o;function S(w){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],_=k$(N,y?[n,r]:[r,n]);return g.current=C,_(w-C.left)}return l.jsx(vhe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(She,{dir:b,"data-orientation":"horizontal",...d,ref:p,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const C=S(w.clientX);i==null||i(C)},onSlideMove:w=>{const C=S(w.clientX);a==null||a(C)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const N=bhe[y?"from-left":"from-right"].includes(w.key);u==null||u({event:w,direction:N?-1:1})}})})}),swt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:s,onSlideStart:o,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=m.useComposedRefs(t,d),h=Q.useRef(void 0),p=!s;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],w=k$(y,p?[r,n]:[n,r]);return h.current=x,w(b-x.top)}return l.jsx(vhe,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:l.jsx(She,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);o==null||o(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=bhe[p?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),She=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=wE(bb,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()):mhe.concat(ghe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:m.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:m.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&s(f)}),onPointerUp:m.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),o(f))})})}),Che="SliderTrack",Nhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=wE(Che,n);return l.jsx(m.Primitive.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...r,ref:t})});Nhe.displayName=Che;var lF="SliderRange",khe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=wE(lF,n),o=whe(lF,n),i=Q.useRef(null),a=m.useComposedRefs(t,i),c=s.values.length,u=s.values.map(h=>Ehe(h,s.min,s.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(m.Primitive.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...r,ref:a,style:{...e.style,[o.startEdge]:d+"%",[o.endEdge]:f+"%"}})});khe.displayName=lF;var cF="SliderThumb",_he=Q.forwardRef((e,t)=>{const n=ewt(e.__scopeSlider),[r,s]=Q.useState(null),o=m.useComposedRefs(t,a=>s(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(owt,{...e,ref:o,index:i})}),owt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:s,...o}=e,i=wE(cF,n),a=whe(cF,n),[c,u]=Q.useState(null),d=m.useComposedRefs(t,S=>u(S)),f=c?i.form||!!c.closest("form"):!0,h=m.useSize(c),p=i.values[r],g=p===void 0?0:Ehe(p,i.min,i.max),b=lwt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?uwt(x,g,a.direction):0;return Q.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(aF.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(m.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":p,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...o,ref:d,style:p===void 0?{display:"none"}:e.style,onFocus:m.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(jhe,{name:s??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},r)]})});_he.displayName=cF;var iwt="RadioBubbleInput",jhe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const s=Q.useRef(null),o=m.useComposedRefs(s,r),i=m.usePrevious(t);return Q.useEffect(()=>{const a=s.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(m.Primitive.input,{style:{display:"none"},...n,ref:o,defaultValue:t})});jhe.displayName=iwt;function awt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((s,o)=>s-o)}function Ehe(e,t,n){const o=100/(n-t)*(e-t);return m.clamp(o,[0,100])}function lwt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function cwt(e,t){if(e.length===1)return 0;const n=e.map(s=>Math.abs(s-t)),r=Math.min(...n);return n.indexOf(r)}function uwt(e,t,n){const r=e/2,o=k$([0,50],[0,r]);return(r-o(t)*n)*n}function dwt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function fwt(e,t){if(t>0){const n=dwt(e);return Math.min(...n)>=t}return!0}function k$(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 hwt(e){return(String(e).split(".")[1]||"").length}function pwt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var The=yhe,mwt=Nhe,gwt=khe,bwt=_he;const Ihe=Q.forwardRef(({className:e,...t},n)=>l.jsxs(The,{ref:n,className:m.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(mwt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(gwt,{className:"absolute h-full bg-primary"})}),l.jsx(bwt,{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"})]}));Ihe.displayName=The.displayName;const Dhe=["SUN","MON","TUE","WED","THU","FRI","SAT"],xwt=Dhe.reduce((e,t,n)=>({...e,[t]:n}),{}),rc={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function ywt(e){if(!e||!e.trim())return{...rc};const t=e.trim(),r=(t.startsWith("cron(")&&t.endsWith(")")?t.slice(5,-1):t).trim().split(/\s+/);if(r.length<5||r.length>6)return{...rc,isCustom:!0};const[s,o,i,a,c]=r,u=Number(s),d=Number(o);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...rc,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...rc,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(p=>p.toUpperCase()).map(p=>xwt[p]).filter(p=>typeof p=="number");if(h.length>0)return{...rc,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...rc,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...rc,repeats:"monthly",hour:d,minute:u}:{...rc,hour:d,minute:u,isCustom:!0}}function vwt(e){const t=e.minute,n=e.hour;switch(e.repeats){case"daily":return`cron(${t} ${n} * * ? *)`;case"weekly":{const r=e.weekdays.length>0?e.weekdays.slice().sort((s,o)=>s-o).map(s=>Dhe[s]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function Mhe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,s=t.toString().padStart(2,"0");return`${r}:${s} ${n}`}function wwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Swt(e){if(e.length===7)return"every day";const t=e.slice().sort((s,o)=>s-o);if(t.length===5&&t.every(s=>s>=1&&s<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(s=>r[s]).join(", ")}function Cwt(e,t,n,r){const s=Mhe(e.hour,e.minute),o=wwt(t);let i;if(e.isCustom)i=`Custom schedule · ${s} ${o}`;else switch(e.repeats){case"daily":i=`Daily at ${s} ${o}`;break;case"weekly":i=`Weekly · ${Swt(e.weekdays)} at ${s} ${o}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${s} ${o}`;break;case"monthly":i=`Monthly on the 1st at ${s} ${o}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const Nwt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=g3;exports.AccordionContent=R0;exports.AccordionItem=M0;exports.AccordionTrigger=A0;exports.AddDataPicker=e$;exports.AggregateTable=ej;exports.Alert=KP;exports.AlertDescription=ZP;exports.AlertDialog=$c;exports.AlertDialogAction=jl;exports.AlertDialogCancel=El;exports.AlertDialogContent=Sl;exports.AlertDialogDescription=_l;exports.AlertDialogFooter=Nl;exports.AlertDialogHeader=Cl;exports.AlertDialogTitle=kl;exports.AlertDialogTrigger=X2;exports.AlertTitle=FX;exports.ArrowDown=Ls;exports.ArrowDownIcon=ZWe;exports.ArrowLeft=nv;exports.ArrowRight=Tk;exports.ArrowUp=eo;exports.ArrowUpIcon=QWe;exports.AssistantContextEntityControls=GR;exports.AssistantVirtualizedMessages=she;exports.AtSign=pW;exports.AxisConfigurator=_g;exports.Badge=ps;exports.Bell=kS;exports.BookType=gW;exports.BulletChartIcon=Zfe;exports.COMMON_TIMEZONES=Nwt;exports.CSS=ji;exports.CalculatedFieldEditor=Mle;exports.Calculator=xW;exports.Calendar=bi;exports.Calendar$1=JS;exports.CalendarRange=yW;exports.Card=Im;exports.CardContent=Ek;exports.CardHeader=jk;exports.CardSummary=vR;exports.CardTitle=pg;exports.ChartArea=U2;exports.ChartColumnIncreasing=vW;exports.ChartColumnStacked=wW;exports.ChartJsVisual=Bv;exports.ChartLine=SW;exports.ChartNoAxesGantt=NW;exports.ChartPie=kW;exports.ChartScatter=_W;exports.ChatInputWithContext=t$;exports.Checkbox=zn;exports.ChevronLeft=Ph;exports.ChevronRight=mr;exports.Circle=Ik;exports.CircleAlert=ah;exports.CircleCheck=TW;exports.CircleHelp=IW;exports.Clock=wF;exports.CodeHighlighter=Uu;exports.CodeXml=Vf;exports.Collapsible=Hc;exports.CollapsibleContent=qc;exports.CollapsibleTrigger=Uc;exports.ColorField=Vi;exports.Command=qj;exports.CommandEmpty=Yj;exports.CommandGroup=Gj;exports.CommandInput=s3;exports.CommandItem=Kj;exports.CommandList=Wj;exports.CommandSeparator=Qae;exports.ComparisonMetadataBadge=ote;exports.Container=nP;exports.ControlDefaultValueEditor=ece;exports.ControlDefinitionOptionsEditor=Jle;exports.ControlIdInput=Kle;exports.ControlVisibilitySettings=mnt;exports.Copy=vl;exports.CopyButton=Ju;exports.CopyPlus=W2;exports.Cross2Icon=nYe;exports.CustomFilterPopover=NL;exports.CustomScrollArea=Vl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=lee;exports.DEFAULT_SCHEDULE_VM=rc;exports.Dashboard=fhe;exports.DashboardActionsMenu=UY;exports.DashboardCard=sae;exports.DashboardCreateDialogBase=wG;exports.DashboardExportDialog=ohe;exports.DashboardPlus=Evt;exports.DashboardWC=Uvt;exports.DataAppBuilder=EK;exports.DataTableConditionalFormattingSettings=Vce;exports.DataTablePagination=G_;exports.Database=ti;exports.DateRangePicker=sL;exports.DefaultChatTransport=W3;exports.Dialog=Po;exports.DialogContent=mo;exports.DialogDescription=oi;exports.DialogFooter=Kc;exports.DialogHeader=ra;exports.DialogTitle=go;exports.DialogTrigger=xG;exports.DisplayPreferencesProvider=Rj;exports.DndContext=aw;exports.Donut=DW;exports.Download=Yc;exports.DownloadPdf=ihe;exports.DragOverlay=Lae;exports.DropdownMenu=Mo;exports.DropdownMenuCheckboxItem=xu;exports.DropdownMenuContent=fo;exports.DropdownMenuItem=Tn;exports.DropdownMenuLabel=Ec;exports.DropdownMenuRadioGroup=Sbe;exports.DropdownMenuRadioItem=VY;exports.DropdownMenuSeparator=Ea;exports.DropdownMenuSub=zF;exports.DropdownMenuSubContent=$k;exports.DropdownMenuSubTrigger=Lk;exports.DropdownMenuTrigger=Ao;exports.EMPTY_DATA_SOURCE=ug;exports.Editable=VN;exports.EditableText=ei;exports.EditorCustomVisual=Qvt;exports.Ellipsis=ja;exports.EllipsisVertical=Oh;exports.ErrorBoundary=Aa;exports.ExportError=Ag;exports.ExternalLink=Mm;exports.Eye=rv;exports.EyeOff=Dk;exports.Fallback=Mj;exports.FallbackVisual=N0;exports.FeedbackCategory=Cd;exports.FeedbackDialog=q0;exports.FieldsList=N3;exports.FieldsSection=qvt;exports.FileSpreadsheet=MW;exports.FileText=wi;exports.Filter=lh;exports.FilterComponent=kj;exports.FilterInfo=gR;exports.FilterableFieldsPanel=Rle;exports.Globe=mg;exports.Grid3x3=AW;exports.GripVertical=Gc;exports.HEATMAP_PRESET_PALETTES=nA;exports.Hash=RW;exports.House=FW;exports.HoverCard=Fg;exports.HoverCardContent=ud;exports.HoverCardTrigger=Pg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=phe;exports.INLINE_ALLOWED_TOOL_LIST=Yvt;exports.INLINE_BLOCKED_MUTATING_TOOLS=Wvt;exports.IconButton=jc;exports.IconForFieldType=iC;exports.InfoHover=WL;exports.InlineFilterBar=Gie;exports.KPICard=bd;exports.KeyboardSensor=ow;exports.Layers=sv;exports.LayoutDashboard=Am;exports.Link=SF;exports.LoadingDots=fd;exports.Lock=Mk;exports.MAX_SELF_HEAL_ATTEMPTS=Gvt;exports.Map=LW;exports.Markdown=gfe;exports.Maximize2=Ak;exports.MdStackedLineChart=Gfe;exports.Minimize2=CF;exports.MultiInputEmptyRenderer=Q5;exports.PYTHON_DEFAULT_CODE=uF;exports.PanelLeft=NF;exports.PanelResizeHandle=e_;exports.Paperclip=$W;exports.PenLine=Y2;exports.Pencil=G2;exports.PendingMessagesDisplay=Dde;exports.PersistedDynamicVisual=Aj;exports.PiChartPolar=Ufe;exports.PivotTableTanstack=nb;exports.Placeholders=Gce;exports.Play=zW;exports.Plus=pr;exports.PointerSensor=lb;exports.Progress=Q3;exports.RECOVERABLE_SQL_ERROR_CODES=Zvt;exports.Radar=BW;exports.RadioGroup=Ia;exports.RadioGroupItem=js;exports.RefreshCw=Lc;exports.ResizableHandle=NK;exports.ResizablePanel=Oy;exports.ResizablePanelGroup=JF;exports.ResourceEditDialog=QG;exports.ResourceType=Zr;exports.SELF_HEAL_TIMELINE_STEP=Kvt;exports.Search=Ws;exports.SeedQuestions=gde;exports.SemaphorContext=hg;exports.SemaphorContextProvider=bF;exports.SemaphorQueryClient=lW;exports.SemaphorReadyIndicator=N$;exports.SemaphorStyleWrapper=rb;exports.Send=kF;exports.Settings=_F;exports.Settings2=gg;exports.Share2=VW;exports.ShareDialog=XG;exports.Sheet=Yee;exports.SheetContent=ZO;exports.SheetDescription=QO;exports.SheetHeader=Kee;exports.SheetTitle=XO;exports.SheetTrigger=t5e;exports.Slider=Ihe;exports.SortableContext=lw;exports.Sparkles=CC;exports.Square=jF;exports.SquarePen=Fk;exports.Star=EF;exports.StructuralParticipantSelector=Zle;exports.SummaryCard=hR;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Xu;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=qi;exports.TableBody=yh;exports.TableCell=or;exports.TableColumnVisibilitySettings=Ice;exports.TableHead=Ko;exports.TableHeader=Rg;exports.TablePresentationSettings=Mce;exports.TableRow=Gr;exports.TableSkeleton=YL;exports.TableVisual=dd;exports.TbChartBubble=qfe;exports.TbChartFunnel=Wfe;exports.TbChartTreemap=Yfe;exports.TextCard=rg;exports.Textarea=zh;exports.TiSortNumerically=Kfe;exports.Toggle=Ij;exports.Tornado=HW;exports.Trash2=wl;exports.TreePalm=IF;exports.TrendingUp=UW;exports.TriangleAlert=Ki;exports.TypeGlyph=ew;exports.UXProvider=C$;exports.User=qW;exports.Users=DF;exports.applyFilterOverridesToDashboardInputSlots=tX;exports.areContextEntitiesEqual=ir;exports.areEntitiesJoined=hee;exports.arrayMove=cb;exports.buildCardControlUsageById=bnt;exports.buildCustomCardTheme=Kv;exports.buildDashboardCardExecutionSnapshot=eX;exports.buildDashboardControlUsageById=gnt;exports.buildDashboardExecutionSnapshot=HP;exports.buildDashboardInputExecutionSnapshot=qu;exports.buildDashboardSheetsInputExecutionSnapshot=rX;exports.buildDashboardStructuralParticipantIdsByControlId=rce;exports.buildFilterFieldMeta=u3;exports.buildFilterSemanticContext=d3;exports.buildInlineFilterNodes=_L;exports.buildMultiInputCustomVisualProps=ML;exports.buildScheduleExpr=vwt;exports.buildSchedulePreview=Cwt;exports.buildSlotOrderedCards=EL;exports.calculateContextAwareFilters=hv;exports.calculateFieldState=BO;exports.canUserAccessVisuals=YKe;exports.canUserCreateDashboards=WKe;exports.canUserEdit=HKe;exports.canUserManageDashboards=qKe;exports.canUserManageGroups=GKe;exports.canUserUseFilters=UKe;exports.cancelExport=HPe;exports.chartSupportsDataLabels=oJ;exports.chartSupportsLegend=rJ;exports.chartTypes=vE;exports.cleanupKpiMetricComparisonMode=ile;exports.cloneDeep=Zo;exports.cloneLinkedFrameWithSourceMapping=pKe;exports.closestCenter=sw;exports.commitSharedCalculatedFields=cf;exports.createAssistantConversationId=Up;exports.createAssistantRequestId=pde;exports.createCardsFromSlots=TYe;exports.createChartConfig=Mg;exports.createDashboardControlInputFromControl=fot;exports.createDefaultGlobalDateFilter=SNe;exports.createExport=Aee;exports.createUniqueDashboardInputVariableNameFromName=ed;exports.dedup=qdt;exports.doesStoredFilterMatchField=lg;exports.downloadDocumentPdf=qP;exports.downloadPdf=dX;exports.extractSqlParamReferences=aoe;exports.extractTableMetadata=c3;exports.fieldAlreadyExists=mee;exports.findCustomVisualConfigCard=IL;exports.findDashboardFrameById=hNe;exports.flexRender=Qo;exports.formatDisplayFormula=uet;exports.formatFileSize=WPe;exports.formatFilterLine=OX;exports.formatTimeLabel=Mhe;exports.getAutoDetectedChartIcon=t0t;exports.getChartGridStyle=W_e;exports.getChartIconByType=n0t;exports.getColorForValue=yM;exports.getConfigSlotExpectedType=EYe;exports.getCoreRowModel=q_;exports.getCustomVisualInputCards=TL;exports.getDateFormatOptionsForGranularity=I0;exports.getDefaultAxisConfig=wM;exports.getDefaultChartColors=qh;exports.getDefaultDataLabelsConfig=kv;exports.getDefaultExportFormat=eQ;exports.getDefaultFilterSql=cL;exports.getDefaultLegendConfig=NO;exports.getDefaultRunningTotalPartitionByFieldIds=Cy;exports.getDocumentSectionEditorCard=Gtt;exports.getDocumentSheetDashboardInputs=hw;exports.getDownloadUrl=VPe;exports.getEffectiveCardTypeForSlot=hm;exports.getEntityIcon=bk;exports.getErrorMessage=nde;exports.getExportStatus=BPe;exports.getExports=zPe;exports.getExpressionFieldKind=yd;exports.getFieldExpressionAnnotation=f3;exports.getFilterCount=YN;exports.getGlobalDateFilter=vg;exports.getGlobalDateFilterCoverage=CNe;exports.getGranularityOptionsForFieldType=I3;exports.getKeys=yr;exports.getMetricDisplayLabel=lPe;exports.getNewField=vee;exports.getObjectDiff=Vq;exports.getPaginationRowModel=W_;exports.getRoleBasedDisplayOverrides=Yie;exports.getRunningTotalOrderByCandidates=MJe;exports.getSelectedDateFilterColumn=coe;exports.getSheetScopedFilterValues=By;exports.getSlotDefinitionForIndex=jL;exports.getSlotExpectedChartType=Ej;exports.getSlotIndexForCard=S0;exports.getSortedRowModel=Wee;exports.getSupportedExportFormats=JX;exports.getTableConditionalFormattingColumnOptions=Pce;exports.getTableOutputColumnOptions=Oce;exports.getTablePageSizeOptions=Iee;exports.handleAggregationChange=bR;exports.handleAggregationLabelChange=qie;exports.hasFlatTableTotalsBehavior=bke;exports.horizontalListSortingStrategy=e3;exports.isCalculatedFilterField=D0;exports.isCardSummaryVisibleOnCard=AL;exports.isCustomVisualConfigCard=dR;exports.isDefaultColor=_ke;exports.isEligibleFlatTableTotalsCard=wg;exports.isExportComplete=qPe;exports.isExportInProgress=UPe;exports.isInAiScopeArray=Udt;exports.isManagedCalculatedExpressionField=ka;exports.isMetricTransformEnabled=IJe;exports.isPromiseLike=YR;exports.isSubtotalEnabledAggregateTable=l3;exports.isSupportedDocumentTableCardType=Ktt;exports.lastAssistantMessageIsCompleteWithToolCalls=Que;exports.merge=yl;exports.mergeAxisConfig=SM;exports.normalizeConditionalFormatting=PP;exports.normalizeContextFormatMode=HX;exports.normalizeDashboardInputVariableName=tv;exports.normalizeMultiInputPayload=DL;exports.parseScheduleExpr=ywt;exports.pivotData=xv;exports.prepareFeedbackData=yE;exports.purify=qA;exports.reindexSlotCards=jYe;exports.remarkGfm=zfe;exports.removeFromScopeArray=Wdt;exports.resolveDashboardInputContext=Bl;exports.resolveDomainCalculatedFieldForEdit=itt;exports.resolveMultiInputType=Zv;exports.resolveMultiInputTypeFromVisual=IYe;exports.resolveTablePageSize=V_;exports.resolveTablePresentationStyle=a5;exports.sanitizeAIScope=tde;exports.saveCalculatedFieldToCardScope=TR;exports.saveCalculatedFieldToSharedScope=Ale;exports.saveCalculatedFieldToSheetScope=IR;exports.seedSemanticMetricFormatDefaults=lle;exports.setTableColumnVisibility=Pee;exports.setupEditorWithCard=w_;exports.showAllTableColumns=ZPe;exports.showJoinRequiredNotification=pee;exports.sortByColumnsToSortState=mte;exports.sortStateToSortByColumns=gte;exports.sortableKeyboardCoordinates=n3;exports.supportsMetricTransformForMetric=ale;exports.supportsTableConditionalFormatting=Ace;exports.toEntityArray=Na;exports.ue=at;exports.useActiveExports=Awe;exports.useActiveToolStatus=Ade;exports.useAddFrameWithFreshSemanticExecutionPayload=qL;exports.useAddNewFrame=pae;exports.useAssistantContainer=DK;exports.useAssistantContextEntities=Pj;exports.useAssistantLayoutStore=Uf;exports.useAssistantPanel=TK;exports.useAssistantProfile=mde;exports.useAutoSubmitQueue=Mde;exports.useBrandStudioPreview=pvt;exports.useCard=vPe;exports.useCardFilterValues=See;exports.useCardSummary=RL;exports.useChat=ede;exports.useColumns=o3;exports.useCreateVisualWithFrame=pxe;exports.useCurrentUserInfo=na;exports.useCustomVisual=Xh;exports.useCustomVisualsQuery=CL;exports.useDashboardAppearance=Pl;exports.useDashboardById=XY;exports.useDashboardCreation=eG;exports.useDashboardManagement=JY;exports.useDashboardPreferences=bg;exports.useDashboardQuery=ev;exports.useDashboardStructuralParticipants=sce;exports.useDashboardSummary=Eie;exports.useDataColumns=ule;exports.useDateFilterHook=aHe;exports.useDebounce=by;exports.useDefaultDashboardMutation=qY;exports.useDisplayPreferences=zl;exports.useDroppable=Oae;exports.useEditorAside=Zj;exports.useEditorCardQuery=v_;exports.useEnsureReactGlobals=Pse;exports.useExportActions=MK;exports.useExportStore=t_;exports.useFieldManagement=cle;exports.useFilterableFields=rle;exports.useFullscreenAssistant=IK;exports.useGroupMembers=pye;exports.useGroups=HG;exports.useHasDashboardId=AK;exports.useInProgressExportsCount=Rwe;exports.useIsDashboardSelected=nme;exports.useIsVisualSelected=rme;exports.useJoinabilityMap=a3;exports.useManagementActions=Fh;exports.useManagementStore=os;exports.useMutation=co;exports.usePivotTableConfig=Yh;exports.usePluginQuery=pie;exports.useQuery=$n;exports.useQueryClient=ts;exports.useReactTable=Y_;exports.useResolveExistingFrameSemanticExecutionPayload=xKe;exports.useResourceManagement=Vk;exports.useResourceUpdateState=QY;exports.useScopedFields=nle;exports.useSelectedVisual=tme;exports.useSemaphorContext=Ct;exports.useSensor=ag;exports.useSensors=zj;exports.useSortable=ub;exports.useStarredChartsStore=Jvt;exports.useSurfaceAppearance=Xc;exports.useTableQueryState=ite;exports.useTextFilterHook=xHe;exports.useTheme=dF;exports.useTopoJson=jv;exports.useUnifiedUsers=WF;exports.useUpdateResource=YY;exports.useUpdateVisualMutation=mxe;exports.useUserPreferences=SG;exports.useVisualById=Bk;exports.useVisualManagement=hxe;exports.validateFieldForChartType=ole;exports.verticalListSortingStrategy=t3;
1410
+ `).trim(),j=k.map((T,E)=>{var A,R;let I="",D;if((A=T.url)!=null&&A.startsWith("data:")){const F=T.url.match(/data:[^;]+;base64,(.+)/);F&&(I=F[1],(R=T.mediaType)!=null&&R.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${E}`,name:T.filename||`File ${E+1}`,size:0,type:T.mediaType||"application/octet-stream",data:I,preview:D}});return l.jsx(E0t,{text:_||void 0,files:j.length>0?j:void 0})}const f=((w=e.parts)==null?void 0:w.filter(N=>N.type==="reasoning"))||[],h=f.length>0,p=f.some(N=>N.state==="streaming"),g=f.filter(N=>N.text&&N.text.trim().length>0),b=h&&(g.length>0||p)?l.jsxs(Hc,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Uc,{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(mr,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:p?"animate-pulse":"",children:p?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(qc,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((N,k)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:k+1}),l.jsx(uq,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:N.text})]},`${e.id||t}-reasoning-${k}`))})})]},`${e.id||t}-reasoning`):null,x=(C=e.parts)==null?void 0:C.map((N,k)=>{var j;const _=`${e.id||t}-${k}`;switch(N.type){case"text":{const T=typeof N.text=="string"?N.text:JSON.stringify(N.text??"",null,2);if(e.role==="assistant"){const{cleanedText:E,quickReplies:I}=N0t(T),D=E.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(uq,{text:E,handleRun:i,onAddToDashboard:s,messageId:e.id,messages:n}),I.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[I.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(({label:A,value:R},F)=>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:A})})}),l.jsx(m.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:R})})]},`${_}-qr-${F}`))})]})]},_)}return e.role==="system"&&o?l.jsx(T0t,{text:T},_):null}case"error":{const T=N,E=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(S$,{errorMessage:E})},_)}case"reasoning":return null;default:return((j=N.type)!=null&&j.startsWith("tool-")||N.type==="dynamic-tool")&&w$(N,r)?l.jsx(Aa,{FallbackComponent:({error:T,resetErrorBoundary:E})=>l.jsx(j0t,{error:T,resetErrorBoundary:E}),children:l.jsx(y0t,{part:N,idx:_,messageId:e.id,showTools:r,onAddToDashboard:s,messages:n})},_):null}});return e.role==="assistant"?rhe(e,r)?l.jsxs(nhe,{who:"Assistant",className:"space-y-2",children:[b,x]}):null:l.jsxs("div",{className:"space-y-2",children:[b,x]})}const A0t=8,R0t=24,F0t=20;function P0t(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function she({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:s,onQuickReply:o,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:p,scrollToEndSignal:g=0}){const b=v.useRef(null),x=v.useRef(null),y=v.useRef(e.length),S=v.useRef(!1),w=v.useRef(null),C=v.useRef(!1),N=v.useRef(g),[k,_]=v.useState(!0),[j,T]=v.useState(0),[E,I]=v.useState(R0t);N.current!==g&&(N.current=g,C.current=!0);const D=e[e.length-1],A=rhe(D,t),R=P0t(a,c,u,A),F=J_({count:e.length,getScrollElement:()=>b.current,estimateSize:W=>{const O=e[W];return(O==null?void 0:O.role)==="user"?88:180},getItemKey:W=>{const O=e[W];return(O==null?void 0:O.id)||`message-${W}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:A0t,overscan:6,gap:20,paddingEnd:R?E+F0t:0,useAnimationFrameWithResizeObserver:!0,onChange:W=>{const O=W.isAtEnd();_(Z=>Z===O?Z:O),O&&T(0)}}),H=v.useCallback((W="smooth")=>{w.current!==null&&cancelAnimationFrame(w.current),w.current=requestAnimationFrame(()=>{w.current=null,F.scrollToEnd({behavior:W})}),T(0),_(!0)},[F]);v.useLayoutEffect(()=>{S.current||(S.current=!0,H("auto"))},[H]),v.useLayoutEffect(()=>{C.current&&(C.current=!1,H("auto"))},[e.length,g,H]),v.useEffect(()=>{const W=y.current;y.current=e.length,e.length>W&&!F.isAtEnd()&&T(O=>O+e.length-W),e.length===0&&(T(0),_(!0),S.current=!1,C.current=!1)},[e.length,F]);const B=F.getVirtualItems(),U=F.getTotalSize();return v.useEffect(()=>()=>{w.current!==null&&cancelAnimationFrame(w.current)},[]),v.useLayoutEffect(()=>{const W=x.current;if(!W||!R)return;const O=()=>{const Y=Math.ceil(W.getBoundingClientRect().height);Y>0&&I(M=>M===Y?M:Y)};if(O(),typeof ResizeObserver>"u")return;const Z=new ResizeObserver(O);return Z.observe(W),()=>Z.disconnect()},[R,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(Vl,{"data-role":"assistant-virtualized-scroll-area",ref:b,className:m.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:U},children:[B.map(W=>{const O=e[W.index];return O?l.jsx("div",{ref:F.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(M0t,{message:O,messageIndex:W.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:s,onQuickReply:o,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(U-E,0)}px)`},children:l.jsx("div",{className:m.cn("min-w-0",f),children:l.jsx(I0t,{status:a,errorMessage:c,activeToolText:u})})})]})}),!k&&l.jsxs("button",{type:"button",onClick:()=>H("smooth"),"aria-label":"Scroll to latest",className:m.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",p),children:[l.jsx(Ls,{className:"h-3 w-3"}),"Latest",j>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:j>9?"9+":j})]})]})}function O0t(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 L0t=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function $0t({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:s}){const[o,i]=v.useState(!1),[a,c]=v.useState(m.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[p,g]=v.useState(!1),[b,x]=v.useState(!1),[y,S]=v.useState(0),w=n??b,{isLocalDev:C,isConsoleMode:N}=bg(),k=C||N||a,_=v.useRef(null);m.useDashboardStore(ne=>ne.dashboard.aiScopeTables),m.useDashboardStore(ne=>ne.isDashboardEditing);const j=m.useDashboardStore(ne=>ne.selectedSheetId),{setDataSource:T}=m.useEditorActions(),{setSelectedFrameId:E,setIsDashboardEditing:I}=m.useDashboardActions(),D=qL(),{clearAssistantMessageContexts:A}=m.useAIActions(),{clearQueue:R}=m.useQueueActions(),{clearFileAttachments:F,getFileAttachments:H}=m.useFileActions(),B=m.useFileAttachments("dashboard"),U=m.useEditorStore(ne=>ne.card.dataSource),{assistantProfile:W}=mde(),O=m.useDashboardStore(ne=>ne.handleOpenAssistantProfile),{selectedEntities:Z,applyDashboardDefaultEntities:Y}=Pj("dashboard"),{sendMessage:M,isLoading:K,messages:L,setMessages:$,status:z,stop:V,errorMessage:P,clearError:q}=dft({dynamicVisualMode:f}),G=v.useCallback(()=>{S(ne=>ne+1)},[]),X=v.useCallback(ne=>{r==null||r(ne),n===void 0&&x(ne)},[n,r]),J=v.useCallback(()=>{X(!w)},[w,X]);v.useEffect(()=>{if(!w)return;function ne(Ce){Ce.key==="Escape"&&X(!1)}return window.addEventListener("keydown",ne),()=>{window.removeEventListener("keydown",ne)}},[w,X]);const[de,he]=v.useState(""),be=ne=>{he(ne.target.value)};async function Se({sql:ne,cardTitle:Ce,connectionId:ve,cardType:re,python:Ee,cardConfig:Fe,dataSource:$e,customVisualPreferences:Xe,visualizationMode:qe,dynamicCardPreferences:We}){if(!j)return;const Qe=qe==="dynamic",_e=m.hasValidCardConfig(Fe),tt=ve||($e==null?void 0:$e.connectionId)||"",ze=$e?{...$e,connectionId:tt||$e.connectionId,connectionType:$e.connectionType||"",mode:$e.mode||"database",selectedEntities:$e.selectedEntities||[]}:tt?{connectionId:tt,connectionType:"",mode:"database",selectedEntities:[]}:ug,ot=!(_e&&(!Qe||(We==null?void 0:We.provenance)==="card-config"||(We==null?void 0:We.provenance)==="query_spec")),Pe=ot?O0t(ne):"",Ie=ot?Ee:"",Ke={id:m.v4(),title:Ce||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:re==="horizontalBar"?"y":"x"},...Qe&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:re,sql:Pe,python:Ie,dataSource:ze,config:Fe,connectionId:tt,visualizationMode:qe,dynamicCardPreferences:We,customCardPreferences:Xe?{url:Xe.url,componentName:Xe.componentName,pluginChartType:Xe.pluginChartType,settings:Xe.settings,type:"component"}:void 0},wt={id:m.v4(),cards:[Ke],activeCardId:Ke.id};try{await D(j,wt,"end"),I(!0),E(wt.id)}catch(St){console.error("Failed to add assistant visual to dashboard:",St),at.error(St instanceof Error?St.message:"Failed to prepare semantic metadata for the new visual")}}const se=ne=>{ne.preventDefault();const Ce=de.trim();if(!Ce&&B.length===0)return;const ve=[];Ce&&ve.push({type:"text",text:Ce}),B.forEach(re=>{re.data&&ve.push({type:"file",mediaType:re.type,filename:re.name,url:`data:${re.type};base64,${re.data}`})}),M({role:"user",parts:ve}),he(""),F("dashboard"),G()};v.useEffect(()=>{var ne;e&&((ne=_.current)==null||ne.focus())},[e]),Mde({assistantType:"dashboard",status:z,isLoading:K,sendMessage:M});const{hasActiveTools:xe,activeToolText:ie}=Ade(L);function Ae(ne){const Ce={role:"user",parts:[{type:"text",text:ne.title+" "+ne.subtitle}]};M(Ce),G()}function oe(ne){M({role:"user",parts:[{type:"text",text:ne}]}),G()}function ge(ne){M({role:"user",parts:[{type:"text",text:ne}]}),G()}const fe=v.useCallback(async()=>{const ne=JSON.stringify(L??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(ne),at.success("Conversation copied")}catch(Ce){console.error("Failed to copy conversation",Ce),at.error("Unable to copy conversation")}},[L]),me=(de==null?void 0:de.length)===0&&(L==null?void 0:L.filter(ne=>ne.role==="user").length)===0;function ee(){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 te(){return l.jsxs(Mo,{children:[l.jsx(Ao,{asChild:!0,children:l.jsx(jc,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx(Oh,{className:"size-3.5"})})}),l.jsxs(fo,{align:"end",children:[l.jsx(Ec,{children:"Options"}),l.jsx(Ea,{}),l.jsx(xu,{checked:o,onCheckedChange:i,children:"Token Usage"}),l.jsx(xu,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(xu,{checked:u,onCheckedChange:d,children:"System Message"}),(C||N)&&l.jsxs(l.Fragment,{children:[l.jsx(Ea,{}),l.jsx(Ec,{children:"Dynamic Visuals"}),l.jsx(xu,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(xu,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(xu,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ue=l.jsxs("div",{"data-role":"dashboard-assistant",className:m.cn("relative flex h-full grow flex-col break-words bg-background",w&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[ee(),O&&l.jsxs("button",{type:"button",onClick:O,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(W==null?void 0:W.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[N&&te(),k&&l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:fe,children:"Copy Conversation"}),l.jsx(jc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:w?"Exit fullscreen":"Expand",onClick:J,children:w?l.jsx(CF,{className:"h-3.5 w-3.5"}):l.jsx(Ak,{className:"h-3.5 w-3.5"})}),l.jsx(jc,{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 ne=L.filter(Ce=>Ce.role==="assistant").map(Ce=>Ce.id).filter(Ce=>!!Ce);$([]),R("dashboard"),q(),A(ne)},children:l.jsx(Fk,{className:"h-3.5 w-3.5"})}),l.jsx(jc,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(m.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(she,{messages:L,showTools:a,showSystemMessage:u,onAddToDashboard:Se,onQuickReply:ge,disableQuickReplies:K,status:z,errorMessage:P,activeToolText:K&&xe?ie:void 0,className:m.cn(w?"px-6 py-5":"px-3 py-3"),rowContentClassName:m.cn(w&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!W&&me&&l.jsx(Gce,{onClick:Ae,placeholders:L0t}),me&&W&&l.jsx(gde,{seedQuestions:W.seedQuestions||[],handleSeedQuestionClick:oe}),l.jsx(Dde,{assistantType:"dashboard"}),l.jsx(t$,{ref:_,setInput:he,stop:V,input:de,handleInputChange:be,handleSubmit:ne=>{se(ne)},isLoading:K,status:z,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(e$,{incomingSelectedEntities:Z,open:p,onOpenChange:g,dataSource:U||ug,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:ne=>Y()})]});return w&&s?_r.createPortal(l.jsx(rb,{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:ue})}),s):ue}function z0t(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=m.useDashboardActions(),s=Hie(),o=m.useDashboardStore(d=>d.dashboard.sheets),a=m.useDashboardStore(d=>d.selectedSheetId)??(o==null?void 0:o[0].id),c=m.useDashboardStore(d=>d.isDashboardEditing),u=m.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(p){if(B0t(p.target))return;const g=p.ctrlKey||p.metaKey;g&&p.key==="c"?(await f(),at.success("Card copied to clipboard"),p.preventDefault()):g&&p.key==="v"&&(await h(),p.preventDefault())}async function f(){try{const p=n();p&&await navigator.clipboard.writeText(JSON.stringify(p))}catch(p){console.error("Failed to copy text:",p)}}async function h(){if(!a)return null;try{const p=await navigator.clipboard.readText(),g=V0t(p);if(g!=null&&g.id){const b=zie(g),x=b.cards.findIndex(y=>y.id===b.activeCardId);x!==-1&&(b.cards[x].title=`${b.cards[x].title} (Copy)`),await s(a,b),r(b.id),at.success("Card pasted from clipboard")}return p}catch(p){return console.error("Failed to paste text:",p),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[s,n,r,a,c,u,t])}function B0t(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 V0t(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 H0t(e,t){switch(e.interactionMode){case"drillToDetail":U0t(e,t);break;case"drillThrough":q0t(e,t);break;case"drillToURL":W0t(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 U0t(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:s,filterGroups:o}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=o.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=o.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}s==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function q0t(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:s,sourceCardId:o}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=s.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function W0t(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 Y0t({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:s,contextMode:o,cardTitle:i,cardDescription:a}){return l.jsx(Po,{open:e,onOpenChange:t,children:l.jsxs(mo,{className:"max-h-[90vh] max-w-[90vw] p-6",children:[l.jsxs(ra,{children:[l.jsx(go,{children:i||"Insight Detail"}),l.jsx(oi,{children:a||"View detailed insight data with applied filters"})]}),l.jsx(Wie,{filters:r,filterDefinitions:s,contextMode:o}),l.jsx("div",{className:"h-[400px] flex-1 overflow-auto",children:n?l.jsx(aae,{insightId:n,filters:r,contextMode:o}):l.jsx("div",{className:"flex items-center justify-center p-12 text-muted-foreground",children:"No insight selected"})})]})})}function G0t(){const e=m.useInteractionStore(C=>C.interactionStates),t=m.useInteractionStore(C=>C.setInteractionState),n=m.useInteractionStore(C=>C.clearLastInteractionEvent),r=m.useInteractionStore(C=>C.replaceCardWithInsight),s=m.useInteractionStore(C=>C.setPendingDrillThrough),o=m.useInteractionStore(C=>C.pendingDrillThrough),i=m.useInteractionStore(C=>C.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=m.useDashboardActions(),{selectDashboard:u}=Fh(),d=m.useDashboardStore(C=>C.dashboard),f=m.useDashboardStore(C=>C.filterValues),{data:h,isLoading:p}=XY((o==null?void 0:o.targetDashboardId)||"",{enabled:!!(o!=null&&o.targetDashboardId)}),[g,b]=v.useState({open:!1,insightId:""}),x=lae(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),S=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:C,filters:N,contextMode:k})=>{b({open:!0,insightId:C,filters:N,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:k})},replaceCardContent:({cardId:C,insightId:N,filters:k,contextMode:_})=>{r(C,N,k,_)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:s,setGlobalDrillContext:({filters:C,contextMode:N,sourceDashboardId:k,sourceDashboardTitle:_,targetDashboardId:j})=>{const T={filters:C},E={sourceCardId:m.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},I={...m.createInitialInteractionState(),appliedClickFilters:[E],contextMode:N,sourceDashboardId:k,sourceDashboardTitle:_,targetDashboardId:j};t(m.DRILL_CONTEXT_CARD_ID,I)}}),[a,r,f,c,d,s,t]);v.useEffect(()=>{Object.entries(e).forEach(([C,N])=>{if(N!=null&&N.lastInteractionEvent){const k=N.lastInteractionEvent,_=`${C}-${k.interactionMode}-${k.sourceCardId}-${Date.now()}`;if(y.current.has(_))return;y.current.add(_);try{H0t(k,S)}catch(j){console.error("Error executing interaction event:",j)}finally{n(C),setTimeout(()=>{y.current.delete(_)},5e3)}}})},[e,n,S]),v.useEffect(()=>{if(!(!o||!h||p))try{u(h),c(o.targetDashboardId,o.sourceDashboardId,o.sourceDashboardTitle,o.filters,o.contextMode),i()}catch(C){console.error("[DrillThrough] Error during automatic navigation:",C),i()}},[o,h,p,u,c,i]);const w=()=>{b({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(Y0t,{open:g.open,onOpenChange:w,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:x.title,cardDescription:x.description}),o&&p&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(m.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function K0t(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,s=Z0t(t.value);return r==="="?`${n} = ${s}`:`${n} ${r} ${s}`}).join(", ")}function Z0t(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function X0t(e){return e?`Back to ${e}`:"Back"}function Q0t(){var y,S,w,C,N;const e=m.useInteractionStore(k=>k.interactionStates[m.DRILL_CONTEXT_CARD_ID]),t=m.useDashboardStore(k=>k.actions.goBackFromDrill),n=m.useDashboardStore(k=>k.actions.clearDrillContext),{selectDashboard:r}=Fh(),[s,o]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const k=j=>{o({x:j.clientX-c.current.x,y:j.clientY-c.current.y})},_=()=>{a(!1)};return document.addEventListener("mousemove",k),document.addEventListener("mouseup",_),()=>{document.removeEventListener("mousemove",k),document.removeEventListener("mouseup",_)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((C=(w=(S=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:S.filterGroups)==null?void 0:w[0])==null?void 0:C.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((N=e.appliedClickFilters)!=null&&N.length))return null;const p=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(k){console.error("[DrillBack] Error during back navigation:",k)}},g=()=>{n()},b=k=>{k.target.closest("button")||(a(!0),c.current={x:k.clientX-s.x,y:k.clientY-s.y})};K0t(f);const x=X0t(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${s.x}px, ${s.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:b,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((k,_)=>{const j=k.field.label||k.field.name,T=String(k.value);return l.jsxs(ps,{variant:"secondary",className:"pointer-events-none text-xs",children:[j," = ",T]},_)})})]}),l.jsx(m.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(m.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(m.Button,{variant:"secondary",size:"sm",onClick:p,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(nv,{className:"mr-2 h-4 w-4"}),x]})})]})})}function J0t(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function evt({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u}){const{attributes:d,listeners:f,setNodeRef:h,transform:p,transition:g,isDragging:b}=ub({id:`filter:${e.id}`,disabled:n||!t}),x={transform:ji.Translate.toString(p),transition:g,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:h,style:x,...d,children:l.jsx(kL,{filter:e,isEditing:t,dragListeners:t?f:void 0,storageOptions:r,settingsVariant:s,filterQueryContext:o,inputVariableName:i,reservedInputVariableNames:a,onUpdateFilter:c,onRemoveFilter:u})})}const yq="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",tvt=[];function ohe({open:e,onOpenChange:t}){var L,$,z;const[n,r]=v.useState(!1),[s,o]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=m.useDashboardStore(V=>{var P;return(P=V.dashboard)==null?void 0:P.sheets}),u=m.useDashboardStore(V=>V.dashboard),d=m.useDashboardStore(V=>V.dashboardInputValues),f=m.useDashboardStore(V=>V.filterValues),h=m.useDashboardStore(V=>V.controlValues),p=m.useDashboardStore(V=>V.inlineFilterValuesMap),g=m.useDashboardStore(V=>V.cardControlValuesMap),b=m.useDashboardStore(V=>V.selectedSheetId),x=m.useDashboardStore(V=>V.selectedSheetId?V.documentInputRuntimeBySheetId[V.selectedSheetId]:void 0),y=m.useDashboardStore(V=>V.isDownloadingPdf),{authToken:S,tokenProps:w}=Ct(),C=c==null?void 0:c.find(V=>V.id===b),N=v.useMemo(()=>m.getDashboardExportSheets(c),[c]),k=m.isDocumentSheet(C),_=k&&C?C.document:void 0,j=v.useMemo(()=>k&&C?hw(u,C.id):[],[C,k,u]),T=j.length>0,E=v.useMemo(()=>k&&C?Uce(u,C.id):!1,[C,k,u]),I=v.useMemo(()=>T?j.map(pw):(_==null?void 0:_.inputs)||tvt,[_,j,T]),D=(($=(L=w==null?void 0:w.params)==null?void 0:L.calendarContext)==null?void 0:$.tz)||((z=w==null?void 0:w.params)==null?void 0:z.timezone)||(typeof Intl<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0),A=v.useMemo(()=>Ule(I),[I]),R=v.useMemo(()=>Vle(I,D),[I,D]),F=v.useMemo(()=>Hle(I),[I]),H=x?x.filterValuesByInputId:R,B=x?x.controlValuesByInputId:F,U=v.useMemo(()=>k?E&&C&&_?nX({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:_.sections.map(V=>V.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},timezone:D}):Yle(I,H,B,A,A):[],[_,I,C,k,u,g,h,f,p,d,B,H,A,D,E]),W=!!C,O=N.length>0,Z=((c==null?void 0:c.length)||0)>1||k,Y=i.sheetSelection==="current"&&(!W||k&&U.length>0)||i.sheetSelection==="all"&&!O;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!O&&a(V=>({...V,sheetSelection:"current"}))},[O,e,i.sheetSelection]);const M=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function K(){if(y){at.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){at.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!W){at.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!O){at.error("No dashboard sheets are available to export");return}o(!0);const V=i.sheetSelection==="current"&&k,P=V?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",q=at.loading(P);try{if(V){if(!_||!C)throw new Error("Selected document sheet is missing document data");if(U.length>0){at.dismiss(q),at.error(`Set ${U.join(", ")} before exporting`);return}const X=new Date().toISOString(),J=E?sX({dashboard:u,sheetId:C.id,sheetKind:"document",sectionIds:_.sections.map(de=>de.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:p,cardControlValuesMap:g},generatedAt:X,timezone:D}).snapshot:void 0;await qP(w.apiServiceUrl,S,{sheetId:C.id,title:C.title||"Document",pageSize:_.page.size,orientation:_.page.orientation,timezone:D,password:i.protectPdf?i.password:void 0,inputSnapshot:J,...J?{}:{inputValues:{sheetId:C.id,filterValuesByInputId:H,controlValuesByInputId:B,generatedAt:X}}})}else{const X=Mee();await dX(w.apiServiceUrl,S,i.protectPdf?i.password:void 0,i.sheetSelection,X)}at.dismiss(q);const G=V?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";at.success(G,{duration:2e3}),M()}catch(G){at.dismiss(q),at.error("Failed to download PDF",{description:C_(G,"Please try again or contact support."),descriptionClassName:S_,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",G)}finally{o(!1)}}return l.jsx(Po,{open:e,onOpenChange:V=>{if(!V){M();return}t(!0)},children:l.jsxs(mo,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(ra,{children:[l.jsx(go,{className:"text-[15px]",children:k?"Export document":"Export dashboard"}),l.jsx(oi,{className:"text-[13px] leading-5",children:k?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[Z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(m.Label,{className:yq,children:"Export scope"}),l.jsxs(Ia,{value:i.sheetSelection,onValueChange:V=>a({...i,sheetSelection:V}),className:"gap-1.5",children:[l.jsxs(m.Label,{htmlFor:"scope-current",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!W&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(js,{value:"current",id:"scope-current",disabled:!W}),k?"This document":"This sheet"," (",(C==null?void 0:C.title)||"Current",")"]}),l.jsxs(m.Label,{htmlFor:"scope-all",className:m.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!O&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(js,{value:"all",id:"scope-all",disabled:!O}),"Dashboard sheets (",N.length," ",N.length===1?"sheet":"sheets",")"]})]}),k&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:U.length>0?`Set ${U.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(m.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(m.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(zn,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:V=>{a({...i,protectPdf:V,password:V?i.password:""}),V||r(!1)}}),l.jsx(Mk,{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:yq,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(m.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:V=>a({...i,password:V.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:V=>{V.key==="Enter"&&i.password&&K()}}),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(Dk,{className:"h-3.5 w-3.5"}):l.jsx(rv,{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(Kc,{children:[l.jsx(m.Button,{variant:"outline",size:"xs",onClick:M,disabled:s,children:"Cancel"}),l.jsx(m.Button,{size:"xs",onClick:K,disabled:s||y||Y,children:s?l.jsxs(l.Fragment,{children:[l.jsx(m.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(Yc,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function ihe({iconClassName:e,open:t,onOpenChange:n}){const[r,s]=v.useState(!1),o=t!==void 0,i=o?t:r,a=u=>{o||s(u),n==null||n(u)},c=m.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[o?null:l.jsx(m.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(Yc,{className:m.cn("size-4",e)})}),l.jsx(ohe,{open:i,onOpenChange:a})]})}function vq(e,t,n){const r=new Set(t),s=[...n];return e.map(o=>r.has(o.id)?s.shift()??o.id:o.id)}function nvt({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:s,listeners:o,setNodeRef:i,transform:a,transition:c,isDragging:u}=ub({id:`control:${e.id}`,disabled:!n}),d={transform:ji.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...s,children:l.jsx(ace,{control:e,value:t,isEditing:n,dragListeners:n?o:void 0,onChange:r})})}function wq(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function Sq(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function rvt(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 Sq(t,n);const s=e.filter(a=>r.has(a)),o=new Set(s),i=Sq(t,n).filter(a=>!o.has(a));return[...s,...i]}function svt(e,t){return m.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function ovt(e){return Lm(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>Lm(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function Cq(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function ivt(e){const t={sheetId:e.selectedSheetId},n=m.getDashboardInputRuntimeSlot(e.dashboardInputValues,e.dashboardInput,t);if(n)return n;const r=m.getDashboardInputRuntimeSlot(e.defaultInputValues,e.dashboardInput,t);return r||m.getBackingDefaultSlot(e.dashboardInput)}function avt(e){return ahe(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 ahe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=svt(e.dashboard,t);return SZ(m_({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!ovt({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function lvt(e,t){return"toolbar"}function cvt(){const e=Xc("interactive"),t=m.useDashboardStore($=>$.selectedSheetId),n=m.useDashboardStore($=>$.dashboard.filters),r=m.useDashboardStore($=>$.dashboard.filterLayout),s=m.useDashboardStore($=>$.isDashboardEditing),o=m.useDashboardStore($=>$.controlValues),i=m.useDashboardStore($=>$.filterValues);m.useDashboardStore($=>$.filteringCards);const a=m.useDashboardStore($=>$.inlineFilterValuesMap),c=m.useDashboardStore($=>$.dashboardInputValues),u=m.useInteractionStore($=>$.clearAllClickFilters),d=m.useInteractionStore($=>Object.entries($.interactionStates).reduce((z,[V,P])=>{var q;return V===m.DRILL_CONTEXT_CARD_ID?z:z+(((q=P.appliedClickFilters)==null?void 0:q.length)??0)},0)),f=m.useDashboardStore($=>$.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:p,reorderDashboardControls:g,removeDashboardInput:b,setControlValue:x,setFilterLayout:y,setFilterValues:S,setFilteringCards:w,upsertDashboardInput:C}=m.useDashboardActions(),N=zj(ag(lb,{activationConstraint:{distance:5}})),k=m.useDashboardStore($=>$.dashboard),_=avt({dashboard:k,selectedSheetId:t}).filter($=>lvt($.filter)==="toolbar"),j=ahe({dashboard:k,selectedSheetId:t}),T=_.map($=>$.filter),E=new Map(_.map($=>[`filter:${$.filter.id}`,$])),I=XKe(k),D=I.filter($=>!$.hidden&&_0($)==="toolbar"),A=I.filter($=>!$.hidden&&_0($)==="advanced"),R=rvt(r==null?void 0:r.toolbarItemOrder,T,D),F=new Map(T.map($=>[`filter:${$.id}`,$])),H=new Map(D.map($=>[`control:${$.id}`,$]));function B($){const{active:z,over:V}=$;if(!V||z.id===V.id)return;const P=String(z.id),q=String(V.id),G=R.findIndex(xe=>xe===P),X=R.findIndex(xe=>xe===q);if(G===-1||X===-1)return;const J=cb(R,G,X);y({toolbarItemOrder:J});const de=new Set((n||[]).map(xe=>xe.id)),he=R.filter(xe=>xe.startsWith("filter:")).map(xe=>xe.replace("filter:","")).filter(xe=>de.has(xe)),be=J.filter(xe=>xe.startsWith("filter:")).map(xe=>xe.replace("filter:","")).filter(xe=>de.has(xe)),Se=R.filter(xe=>xe.startsWith("control:")).map(xe=>xe.replace("control:","")),se=J.filter(xe=>xe.startsWith("control:")).map(xe=>xe.replace("control:",""));h(vq(n||[],he,be)),g(vq(k.controls||[],Se,se))}const U=(r==null?void 0:r.toolbarWrap)??!1,W=(r==null?void 0:r.showDownloadButton)??!1,O=(i==null?void 0:i.filter($=>wq($)).length)??0,Z=j.filter(Cq),Y=Z.filter($=>{const z=ivt({dashboardInput:$,dashboardInputValues:c,defaultInputValues:k.defaultInputValues,selectedSheetId:t});return(z==null?void 0:z.status)==="set"&&z.value.kind==="filter"&&wq(z.value.filterValue)}).length,M=a?Object.values(a).reduce(($,z)=>$+((z==null?void 0:z.length)??0),0):0,K=O+Y+M+d,L=()=>{S([]),Z.forEach($=>{p($,{sheetId:t})}),w([]),u(),a&&Object.entries(a).forEach(([$,z])=>{z==null||z.forEach(V=>{f($,V.filterId)})})};return!T.length&&!D.length&&!A.length&&!W&&K===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(aw,{sensors:N,collisionDetection:sw,onDragEnd:B,children:l.jsxs("div",{className:m.cn("flex items-center",U?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(lw,{items:R,strategy:e3,children:l.jsx(AR,{className:"gap-3 pr-0",wrap:U,children:R.map($=>{const z=F.get($);if(z){const P=E.get($),q=P&&Cq(P);return l.jsx(evt,{filter:z,isEditing:s,storageOptions:q?{storageTarget:"dashboardInput",dashboardInput:P,sheetId:t??void 0}:void 0,inputVariableName:q?P.variableName:void 0,onUpdateFilter:q?(G,X)=>{C({...P,variableName:(X==null?void 0:X.variableName)||P.variableName,filter:G})}:void 0,onRemoveFilter:q?()=>{S((i||[]).filter(G=>G.filterId!==z.id)),b(P.id)}:void 0},$)}const V=H.get($);return V?l.jsx(nvt,{control:V,value:o==null?void 0:o[V.id],isEditing:s,onChange:P=>x(V.id,P)},$):null})})}),A.length>0&&l.jsx(nae,{title:"",controls:A,values:o,onChange:($,z)=>x($.id,z),immediatePlacement:"toolbar",advancedLabel:"More controls"}),K>0&&l.jsxs("button",{type:"button",onClick:L,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(m.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:K})]}),W&&l.jsx("div",{className:m.cn(K>0?"ml-1.5":"ml-auto"),children:l.jsx(ihe,{})})]})})})}function lhe(){var te,ue;const{showAssistant:e,tokenProps:t,renderMode:n}=Ct(),r=J0t((te=t.config)==null?void 0:te.showDashboardAssistant,e),{preferences:s,isConsoleMode:o}=bg(),i=(ue=s==null?void 0:s.cardDisplay)==null?void 0:ue.mode,a=Uh(i),c=zZ({displayMode:i,renderMode:n}),u=v.useRef(null),d=v.useRef(null),[f,h]=v.useState(!1),{handleDragStart:p,isDraggingRef:g,getStyle:b,getPositionClasses:x}=Qot({initialPosition:"bottom-right"}),y=Uf(ne=>ne.setFullscreen),S=Uf(ne=>ne.setPanelOpen),w=Uf(ne=>ne.setContainer),C=TK("dashboard"),N=IK(),k=DK("dashboard"),_=C.isOpen,j=N==="dashboard",T=m.useDashboardStore(ne=>ne.isVisualEditing),E=m.useDashboardStore(ne=>ne.themeStyle),I=Pl(),D=m.useDashboardStore(ne=>{var Ce;return(Ce=ne.dashboard)==null?void 0:Ce.sheets}),A=m.useDashboardStore(ne=>ne.showFilters),R=m.useDashboardStore(ne=>ne.isDashboardEditing),F=m.useDashboardStore(ne=>ne.selectedSheetId),H=D==null?void 0:D.find(ne=>ne.id===F),B=m.useDashboardStore(ne=>{var Ce,ve,re;return(re=(ve=(Ce=ne.dashboard)==null?void 0:Ce.sheets)==null?void 0:ve.find(Ee=>Ee.id===ne.selectedSheetId))==null?void 0:re.kind}),U=m.useDashboardStore(ne=>{var Ce,ve;return((ve=(Ce=ne.dashboard)==null?void 0:Ce.summary)==null?void 0:ve.position)||"top"}),W=B==="document",O=m.useDashboardStore(ne=>{var Ce;return(Ce=ne.dashboard)==null?void 0:Ce.id}),Z=m.useDashboardStore(ne=>ne.isDashboardPanelOpen),Y=m.useDashboardStore(ne=>ne.actions.setIsDashboardPanelOpen),{getDefaultSheetId:M,setDefaultSheetId:K,clearDefaultSheetId:L}=cW(O),[$,z]=v.useState(null);Vk(Zr.DASHBOARD);const{setSelectedSheetId:V,setSheetTitle:P,addSheet:q,setSheets:G}=m.useDashboardActions();z0t(d);const{setActiveAssistantType:X}=m.useAIActions();v.useEffect(()=>{if(O){const ne=M();z(ne)}},[O,M]),v.useEffect(()=>{_?X("dashboard"):N==="dashboard"&&y(null)},[_,X,N,y]),v.useEffect(()=>{var ne;_||(ne=u.current)==null||ne.resize(0)},[_]);function J(ne){var Ce,ve;ne?((Ce=u.current)==null||Ce.resize(40),S("dashboard",!0),y("dashboard"),X("dashboard")):(S("dashboard",!1),y(null),(ve=u.current)==null||ve.resize(0),X(null))}function de(ne="dashboard"){const Ce={id:m.v4(),title:ne==="document"?"New Document":"New Sheet",...ne==="document"?{kind:ne,document:m.createDefaultDocumentDefinition()}:{}};q(Ce),V(Ce.id)}function he(ne,Ce){if(!O)return;$===ne?(L(),z(null),at.success("Default sheet cleared")):(K(ne),z(ne),at.success(`"${Ce}" set as default sheet`))}function be(ne){var Ce;ne<1?(S("dashboard",!1),y(null),X(null),(Ce=u.current)==null||Ce.resize(0)):(_||S("dashboard",!0),X("dashboard"))}function Se(){return(E==null?void 0:E.canvasTheme)==="muted"||!(E!=null&&E.canvasTheme)?"hsl(var(--semaphor-muted))":(E==null?void 0:E.canvasTheme)==="clear"?"":E==null?void 0:E.canvasTheme}const se=(ne,Ce)=>{ne.dataTransfer.setData("tabIndex",Ce.toString())},xe=ne=>{ne.preventDefault()},ie=(ne,Ce)=>{const ve=ne.dataTransfer.getData("tabIndex");if(ve===Ce.toString())return;const re=Array.from(D||[]),[Ee]=re.splice(parseInt(ve),1);re.splice(Ce,0,Ee),G(re)},Ae=t.orgUserId||t.tenantId&&t.endUserId&&t.endUserEmail,oe=r===!0&&!a&&!_&&!T&&!A;function ge(){if(D&&D.length>1||R)return l.jsxs("div",{className:"relative flex w-full items-stretch border-b border-border",children:[o&&Ae&&!Z&&l.jsx("button",{type:"button","aria-label":"Toggle dashboards panel",onClick:()=>{Y(!Z)},className:"group/panel mx-2 inline-flex h-9 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground",children:l.jsx("span",{className:"inline-flex h-7 w-7 items-center justify-center rounded-[4px] group-hover/panel:bg-muted",children:l.jsx(NF,{className:"h-3.5 w-3.5",strokeWidth:1.75})})}),l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(m.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[D==null?void 0:D.map((ne,Ce)=>{const ve=F===ne.id,re=$===ne.id;return l.jsxs(m.TabsTrigger,{draggable:!0,onDragStart:Ee=>se(Ee,Ce),onDragOver:xe,onDrop:Ee=>ie(Ee,Ce),onClick:()=>V(ne.id),className:m.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:ne.id,children:[ne.kind==="document"&&l.jsx(wi,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(VN,{enabled:R&&ve,text:ne.title,onSave:Ee=>P(ne.id,Ee),children:ne.title},ne.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":re?"Clear default sheet":"Set as default sheet",title:re?"Clear default sheet":"Set as default sheet",onClick:Ee=>{Ee.stopPropagation(),he(ne.id,ne.title||"Sheet")},onKeyDown:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),Ee.stopPropagation(),he(ne.id,ne.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",ve||re?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(EF,{className:m.cn("h-3 w-3 transition-colors",re?"fill-current text-amber-500":"text-muted-foreground")})}),R&&ve&&D.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:Ee=>{Ee.stopPropagation(),h(!0)},onKeyDown:Ee=>{(Ee.key==="Enter"||Ee.key===" ")&&(Ee.preventDefault(),Ee.stopPropagation(),h(!0))},children:l.jsx(m.X,{className:"h-3 w-3"})})]},ne.id)}),R&&l.jsxs(Mo,{children:[l.jsx(Ao,{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(pr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(fo,{align:"start",className:"w-48",children:[l.jsxs(Tn,{onSelect:()=>de("dashboard"),children:[l.jsx(Am,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(Tn,{onSelect:()=>de("document"),children:[l.jsx(wi,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})]})}function fe(){return l.jsx("div",{ref:d,style:{},className:"h-full min-h-0 grow",children:D==null?void 0:D.map(ne=>l.jsx(m.TabsContent,{style:{backgroundColor:Se(),...I.dashboardCanvasStyle},className:m.cn("mt-0 h-full min-h-0",{}),value:ne.id,children:l.jsx(EH,{sheet:ne})},ne.id))})}function me(){return l.jsxs(m.Tabs,{"data-role":"dashboard-tabs-container",className:m.cn("relative flex h-full flex-col",E==null?void 0:E.dashboardTabsContainer),onValueChange:ne=>{V(ne)},value:F||void 0,children:[ge(),U==="top"&&!W&&l.jsx(hR,{}),F&&!W&&l.jsx(cvt,{}),W?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:fe()}):l.jsx(Vl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:fe()}),U==="bottom"&&!W&&l.jsx(hR,{}),l.jsx(Jot,{open:f,setOpen:h})]})}const ee=v.useCallback(ne=>{w("dashboard",ne)},[w]);return D?c&&F&&!W?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',F,'" was not found or is not a document sheet in the loaded dashboard.']}):c&&W&&H?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(EH,{sheet:H})}):l.jsxs(l.Fragment,{children:[l.jsx(G0t,{}),l.jsx(Q0t,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(JF,{className:m.cn("flex-1 basis-0 overflow-y-auto transition-opacity",j&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(Oy,{children:me()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(Xot,{open:_,onTabClick:J,withHandle:!0,disabled:!_}),l.jsx(Oy,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:be,defaultSize:_?40:0,ref:u,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx($0t,{open:_,setOpen:J,isFullscreen:j,onFullscreenChange:ne=>y(ne?"dashboard":null),fullscreenContainer:k})})})]})]}),l.jsx("div",{ref:ee,className:m.cn("absolute inset-0",!j&&"pointer-events-none")}),oe&&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||J(!0)},onMouseDown:p,onTouchStart:p,title:"Open Assistant (drag to move)",children:l.jsx(Vme,{className:"h-5 w-5"})})})]})]}):null}const che=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:s,children:o,className:i,style:a,...c},u)=>{const d=v.useId(),f=v.useMemo(()=>uvt(d),[d]),{theme:h}=dF(),p=dvt(h),g=v.useMemo(()=>s??Wc.resolveAppearance({organizationAppearance:t,tokenAppearance:n,reactAppearance:r??e}),[e,t,r,s,n]),b=v.useMemo(()=>m.compileAppearance({spec:g,systemMode:p}),[g,p]),x=v.useMemo(()=>m.createAppearanceContextValue(f,b),[b,f]);return l.jsx(m.AppearanceContext.Provider,{value:x,children:l.jsx(rb,{...c,ref:u,className:i,style:a,children:o})})});che.displayName="AppearanceProvider";function uvt(e){return`semaphor-appearance-${e.replace(/[^a-zA-Z0-9_-]/g,"")}`}function dvt(e){const t=gC(e),[n,r]=v.useState(()=>fvt());return v.useEffect(()=>{var i,a;if(t!=="system"||typeof window>"u")return;const s=(i=window.matchMedia)==null?void 0:i.call(window,"(prefers-color-scheme: dark)");if(!s)return;const o=()=>{r(s.matches?"dark":"light")};return o(),typeof s.addEventListener=="function"?(s.addEventListener("change",o),()=>s.removeEventListener("change",o)):((a=s.addListener)==null||a.call(s,o),()=>{var c;return(c=s.removeListener)==null?void 0:c.call(s,o)})},[t]),t==="system"?n:t}function fvt(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}const uhe=v.createContext({openBrandStudioPreview:()=>{}}),hvt=uhe.Provider;function pvt(){return v.useContext(uhe)}function mvt({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const s=gC(t),[o,i]=v.useState(()=>gvt(n)||s),a=v.useCallback(u=>{const d=gC(u);bvt(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:o,setTheme:a}),[o,a]);return l.jsx(Bq.Provider,{...r,value:c,children:e})}function gvt(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=gC(t,"system");return n===t?n:null}catch{return null}}function bvt(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const xvt=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function C$({appearance:e,children:t}){var I,D;const{authToken:n,id:r,tokenProps:s}=Ct(),o=ev(),i=(I=o.data)==null?void 0:I.organizationAppearance,a=(D=s.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,p]=v.useState(null),[g,b]=v.useState(null),[x,y]=v.useState(null),S=`${s.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,w=$n({queryKey:WY({resourceType:Zr.DASHBOARD,apiServiceUrl:s.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>m.getRequest(`${s.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:A=>(A==null?void 0:A.organizationAppearance)??null,enabled:!o.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:S,appearance:i})},[i,S]),v.useEffect(()=>{w.data!==void 0&&y({scopeKey:S,appearance:w.data})},[w.data,S]);const C=(x==null?void 0:x.scopeKey)===S?x.appearance:null,N=i!==void 0?i:w.data!==void 0?w.data:C,k=v.useMemo(()=>Wc.resolveAppearance({organizationAppearance:N,tokenAppearance:a,reactAppearance:e}),[e,N,a]),_=v.useCallback(()=>{f(g??h??k),u(!0)},[g,h,k]),j=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),p(null),b(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:_}),[_]),E=g??h??e;return l.jsx(mvt,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(hvt,{value:T,children:l.jsx(che,{organizationAppearance:N,tokenAppearance:a,reactAppearance:E,style:{height:"100%",width:"100%"},children:l.jsxs(m.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(xvt,{appearance:d,onDraftChange:b,onSave:A=>{p(A),b(A),f(A)},onCancel:j})})})]})})})})}function dhe({children:e,preferences:t}){const{currentUser:n}=na(),r=v.useMemo(()=>{var s,o;return{preferences:t||{},isLocalDev:((s=t==null?void 0:t.uiMode)==null?void 0:s.developer)||!1,isConsoleMode:((o=t==null?void 0:t.uiMode)==null?void 0:o.console)||!1}},[t]);return l.jsx(HY.Provider,{value:r,children:l.jsx(Rj,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function yvt(e=2e3,t=500){const n=Qpe(),[r,s]=v.useState(!1),[o,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>s(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),o}function N$({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const s=yvt(e,t);return v.useEffect(()=>(s&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[s,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:s?"ready":""})}function fhe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(Aa,{FallbackComponent:Mj,children:l.jsxs(bF,{dashboardProps:e,children:[l.jsx(N$,{componentType:"dashboard",componentId:e.id}),l.jsx(C$,{appearance:e.appearance,children:l.jsx(dhe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(nP,{...e,type:"dashboard",children:l.jsx(lhe,{})})})})})]})})}function vvt(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[s,o]=v.useState(),i=v.useCallback(()=>{var p,g,b;const a=((p=t.current)==null?void 0:p.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((b=n.current)==null?void 0:b.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);o(x=>x===h?x:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:s,updateAvailableWidth:i}}function wvt({filter:e}){var g;const t=m.useDashboardStore(b=>b.isDashboardEditing),{preferences:n}=bg(),r=Uh((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),s=m.useDashboardStore(b=>b.filterValues),o=s==null?void 0:s.some(b=>b.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=m.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:p}=vvt([t,o,r]);return v.useEffect(()=>{p()},[e.title,p]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(m.Label,{className:"my-1 block w-full text-sm",children:l.jsx(ei,{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(NL,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(m.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function Svt(){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(wvt,{filter:r}),l.jsx(kj,{filter:r})]},r.id))}):null}function Cvt(){var i;const e=m.useDashboardStore(a=>a.dashboard),t=m.useDashboardStore(a=>a.selectedSheetId),n=m.useDashboardStore(a=>a.isVisualEditing),r=m.useDashboardStore(a=>a.isDashboardEditing),s=(i=e.sheets)==null?void 0:i.find(a=>a.id===t),o=m.isDocumentSheet(s);return l.jsx("div",{role:"dashboard-plus-main",className:m.cn("",{"max-h-0 overflow-hidden":n,"flex min-h-0 grow basis-0 overflow-hidden":!n}),children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[r&&!o&&l.jsx(Svt,{}),l.jsx(lhe,{})]})})}const Nvt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-4a3fKtuD.js"))),kvt=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-CqnMxF8h.js"))),_vt=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-wTRw_VIn.js"))),jvt=v.lazy(()=>Promise.resolve().then(()=>require("./resource-management-panel-BajPY5IU.js")).then(e=>({default:e.ResourceManagementPanel})));function Evt({showControls:e=!1,showFooter:t=!0,...n}){const r=m.useDashboardStore(u=>u.isDashboardPanelOpen),s=m.useDashboardStore(u=>u.isVisualEditing),o=m.useDashboardStore(u=>u.showDashboardJSON),i=m.useDashboardStore(u=>u.actions.setIsDashboardPanelOpen),{appearance:a,preferences:c}=n;return l.jsx(Aa,{FallbackComponent:Mj,children:l.jsxs(bF,{dashboardProps:n,children:[l.jsx(N$,{componentType:"surfboard",componentId:n.id}),l.jsxs(C$,{appearance:a,children:[l.jsx(Kbe,{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(dhe,{preferences:c,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(_vt,{})}),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(Nvt,{})}),l.jsxs("div",{className:"flex grow overflow-hidden",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(jvt,{isOpen:r,onClose:()=>i(!1),variant:"inline"})}),l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(nP,{...n,type:"dashboard",children:[s&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(kvt,{})}),l.jsx(Cvt,{})]})})]})]})]})]})]})})}var Tvt=Object.defineProperty,Ivt=(e,t,n)=>t in e?Tvt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wS=(e,t,n)=>Ivt(e,typeof t!="symbol"?t+"":t,n);const Dvt={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},Mvt={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}},Avt={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function Rvt(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function hhe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const Fvt={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const s=hhe(t);if(typeof n<"u"&&s in n.container)return n.container[s]})();return typeof r=="function"?r.bind(n):void 0}},Pvt={stringify:e=>`${e}`,parse:e=>parseFloat(e)},Ovt={stringify:e=>e,parse:e=>e},v2={string:Ovt,number:Pvt,boolean:Dvt,function:Mvt,method:Fvt,json:Avt},hx=Symbol.for("r2wc.render"),SS=Symbol.for("r2wc.connected"),Jd=Symbol.for("r2wc.context"),ci=Symbol.for("r2wc.props");function Lvt(e,t,n){var r,s,o;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const p of i){c[p]=Array.isArray(t.props)?"string":t.props[p];const g=Rvt(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(),wS(this,o,!0),wS(this,s),wS(this,r,{}),wS(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[ci].container=this.container;for(const g of i){const b=d[g],x=this.getAttribute(b),y=c[g],S=y?v2[y]:null;if(y==="method"){const w=hhe(b);Object.defineProperty(this[ci].container,w,{enumerable:!0,configurable:!0,get(){return this[ci][w]},set(C){this[ci][w]=C,this[hx]()}}),this[ci][g]=S.parse(x,b,this)}S!=null&&S.parse&&x&&(this[ci][g]=S.parse(x,b,this))}for(const g of a)this[ci][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[SS]=!0,this[hx]()}disconnectedCallback(){this[SS]=!1,this[Jd]&&n.unmount(this[Jd]),delete this[Jd]}attributeChangedCallback(g,b,x){const y=f[g],S=c[y],w=S?v2[S]:null;y in c&&w!=null&&w.parse&&x&&(this[ci][y]=w.parse(x,g,this),this[hx]())}[(o=SS,s=Jd,r=ci,hx)](){this[SS]&&(this[Jd]?n.update(this[Jd],this[ci]):this[Jd]=n.mount(this.container,e,this[ci]))}}for(const p of i){const g=d[p],b=c[p];Object.defineProperty(h.prototype,p,{enumerable:!0,configurable:!0,get(){return this[ci][p]},set(x){this[ci][p]=x;const y=b?v2[b]:null;if(y!=null&&y.stringify){const S=y.stringify(x,g,this);this.getAttribute(g)!==S&&this.setAttribute(g,S)}else this[hx]()}})}return h}function $vt(e,t,n){const r=Lq.createRoot(e),s=v.createElement(t,n);return r.render(s),{root:r,ReactComponent:t}}function zvt({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function Bvt({root:e}){e.unmount()}function Vvt(e,t={}){return Lvt(e,t,{mount:$vt,update:zvt,unmount:Bvt})}const Hvt={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},Uvt=Vvt(fhe,{props:Hvt}),qvt=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(N3,{context:t})," "]})}),phe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),Wvt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),Yvt=Array.from(phe).join(", "),Gvt=3,Kvt="Self-heal",Zvt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function Xvt({card:e}){var W,O,Z,Y,M;const[t,n]=v.useState({}),{authToken:r}=Ct(),s=m.getTokenParams(r==null?void 0:r.accessToken),{compiledAppearance:o}=m.useAppearance(),i=v.useMemo(()=>Kv(o),[o]),a=m.useEditorStore(K=>K.frame),c=m.useEditorStore(K=>K.inlineFilterValuesMap[e.id]),u=m.useEditorStore(K=>K.actions.setCardInlineFilterValue),d=m.useEditorStore(K=>K.actions.removeCardInlineFilterValue),f=e,{getCard:h,manifest:p}=Xh(((W=f.customCardPreferences)==null?void 0:W.url)||""),g=(O=p==null?void 0:p.visuals)==null?void 0:O.find(K=>{var L;return K.name===((L=f.customCardPreferences)==null?void 0:L.componentName)}),b=Zv(f,g)??"single",x=v.useMemo(()=>TL({frame:a,configCard:f,isMultiInputVisual:b==="multiple"}),[a,f,b]),y=v.useMemo(()=>{const K=x.findIndex(L=>(L==null?void 0:L.id)===e.id);return K<0?-1:S0(e,K)},[x,e]),S=v.useMemo(()=>b!=="multiple"||y<0?e.type:hm(e,y,g==null?void 0:g.slots)??e.type,[b,y,e,g==null?void 0:g.slots]),w=v.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:S!==e.type?{...e,type:S}:e,[e,S,b]),{data:C}=v_(w),N=m.useInteractionStore(K=>K.interactionStates),k=m.useDashboardStore(K=>{var L;return(L=K.dashboard)==null?void 0:L.id}),_=m.useDashboardStore(K=>K.dashboard.filters),j=m.useDashboardStore(K=>K.filterValues),T=m.useDashboardStore(K=>K.selectedSheetId),E=v.useMemo(()=>_L({card:e,sheetId:T||"",inlineFilterValues:c,setInlineFilterValue:K=>u(e.id,K),removeInlineFilterValue:K=>d(e.id,K)}),[e,T,c,u,d]),{cardFilters:I,cardFilterValues:D}=v.useMemo(()=>hv({card:e,interactionStates:N,currentDashboardId:k,filters:_,filterValues:j,selectedSheetId:T}),[e,N,k,_,j,T]),A=v.useCallback((K,L)=>{const $=DL(L);n(z=>({...z,[K]:$}))},[]),R=(Z=f.customCardPreferences)==null?void 0:Z.componentName,F=R?h(R):null,H=zN((Y=f.customCardPreferences)==null?void 0:Y.settings,f),B=v.useMemo(()=>EL(x),[x]),U=v.useMemo(()=>B.map((K,L)=>hm(K,L,g==null?void 0:g.slots)),[B,g==null?void 0:g.slots]);return R?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:[F&&b==="single"&&l.jsx(F,{editing:!0,params:s,theme:i,settings:H,cardMetadata:yie({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:A,data:(C==null?void 0:C.records)||[],filters:I,filterValues:[...D||[],...c||[]],inlineFilters:E}),F&&b==="multiple"&&l.jsxs(l.Fragment,{children:[x.map((K,L)=>{if(!K)return null;const $=S0(K,L),z=hm(K,$,g==null?void 0:g.slots);return l.jsx(Q5,{onDataChange:A,card:K,effectiveCardType:z},`${K.id}-${$}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(F,{editing:!0,onDataChange:A,...ML({configCard:f,slotOrderedCards:B,slotTypes:U,multiInputData:t,params:s,theme:i,chartSettings:H,filters:I,filterValues:[...D||[],...c||[]],inlineFilters:E})})})]})]},(M=f.customCardPreferences)==null?void 0:M.componentName)}):null}const Qvt=v.memo(Xvt,(e,t)=>{var n,r,s,o,i,a,c,u;return e.card.id===t.card.id&&e.card.inlineFilters===t.card.inlineFilters&&((n=e.card.customCardPreferences)==null?void 0:n.settings)===((r=t.card.customCardPreferences)==null?void 0:r.settings)&&((s=e.card.customCardPreferences)==null?void 0:s.slotSettings)===((o=t.card.customCardPreferences)==null?void 0:o.slotSettings)&&((i=e.card.customCardPreferences)==null?void 0:i.url)===((a=t.card.customCardPreferences)==null?void 0:a.url)&&((c=e.card.customCardPreferences)==null?void 0:c.componentName)===((u=t.card.customCardPreferences)==null?void 0:u.componentName)}),Jvt=m.create()(m.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(s=>s.type===n&&s.id===r),toggleStar:n=>{e(r=>{const s=r.starredCharts.findIndex(o=>o.type===n.type&&o.id===n.id);return s>=0?{starredCharts:r.starredCharts.filter((o,i)=>i!==s)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(s=>s.type===n&&s.id===r)}),{name:"semaphor-starred-charts"}));var mhe=["PageUp","PageDown"],ghe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],bhe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},bb="Slider",[aF,ewt,twt]=m.createCollection(bb),[xhe]=m.createContextScope(bb,[twt]),[nwt,wE]=xhe(bb),yhe=Q.forwardRef((e,t)=>{const{name:n,min:r=0,max:s=100,step:o=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:p=!1,form:g,...b}=e,x=Q.useRef(new Set),y=Q.useRef(0),w=i==="horizontal"?rwt:swt,[C=[],N]=m.useControllableState({prop:d,defaultProp:u,onChange:I=>{var A;(A=[...x.current][y.current])==null||A.focus(),f(I)}}),k=Q.useRef(C);function _(I){const D=cwt(C,I);E(I,D)}function j(I){E(I,y.current)}function T(){const I=k.current[y.current];C[y.current]!==I&&h(C)}function E(I,D,{commit:A}={commit:!1}){const R=hwt(o),F=pwt(Math.round((I-r)/o)*o+r,R),H=m.clamp(F,[r,s]);N((B=[])=>{const U=awt(B,H,D);if(fwt(U,c*o)){y.current=U.indexOf(H);const W=String(U)!==String(B);return W&&A&&h(U),W?U:B}else return B})}return l.jsx(nwt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:s,valueIndexToChangeRef:y,thumbs:x.current,values:C,orientation:i,form:g,children:l.jsx(aF.Provider,{scope:e.__scopeSlider,children:l.jsx(aF.Slot,{scope:e.__scopeSlider,children:l.jsx(w,{"aria-disabled":a,"data-disabled":a?"":void 0,...b,ref:t,onPointerDown:m.composeEventHandlers(b.onPointerDown,()=>{a||(k.current=C)}),min:r,max:s,inverted:p,onSlideStart:a?void 0:_,onSlideMove:a?void 0:j,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&E(r,0,{commit:!0}),onEndKeyDown:()=>!a&&E(s,C.length-1,{commit:!0}),onStepKeyDown:({event:I,direction:D})=>{if(!a){const F=mhe.includes(I.key)||I.shiftKey&&ghe.includes(I.key)?10:1,H=y.current,B=C[H],U=o*F*D;E(B+U,H,{commit:!0})}}})})})})});yhe.displayName=bb;var[vhe,whe]=xhe(bb,{startEdge:"left",endEdge:"right",size:"width",direction:1}),rwt=Q.forwardRef((e,t)=>{const{min:n,max:r,dir:s,inverted:o,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=Q.useState(null),p=m.useComposedRefs(t,w=>h(w)),g=Q.useRef(void 0),b=m.useDirection(s),x=b==="ltr",y=x&&!o||!x&&o;function S(w){const C=g.current||f.getBoundingClientRect(),N=[0,C.width],_=k$(N,y?[n,r]:[r,n]);return g.current=C,_(w-C.left)}return l.jsx(vhe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(She,{dir:b,"data-orientation":"horizontal",...d,ref:p,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const C=S(w.clientX);i==null||i(C)},onSlideMove:w=>{const C=S(w.clientX);a==null||a(C)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const N=bhe[y?"from-left":"from-right"].includes(w.key);u==null||u({event:w,direction:N?-1:1})}})})}),swt=Q.forwardRef((e,t)=>{const{min:n,max:r,inverted:s,onSlideStart:o,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=Q.useRef(null),f=m.useComposedRefs(t,d),h=Q.useRef(void 0),p=!s;function g(b){const x=h.current||d.current.getBoundingClientRect(),y=[0,x.height],w=k$(y,p?[r,n]:[n,r]);return h.current=x,w(b-x.top)}return l.jsx(vhe,{scope:e.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:l.jsx(She,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=g(b.clientY);o==null||o(x)},onSlideMove:b=>{const x=g(b.clientY);i==null||i(x)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:b=>{const y=bhe[p?"from-bottom":"from-top"].includes(b.key);c==null||c({event:b,direction:y?-1:1})}})})}),She=Q.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=wE(bb,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()):mhe.concat(ghe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:m.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:m.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&s(f)}),onPointerUp:m.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),o(f))})})}),Che="SliderTrack",Nhe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=wE(Che,n);return l.jsx(m.Primitive.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...r,ref:t})});Nhe.displayName=Che;var lF="SliderRange",khe=Q.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,s=wE(lF,n),o=whe(lF,n),i=Q.useRef(null),a=m.useComposedRefs(t,i),c=s.values.length,u=s.values.map(h=>Ehe(h,s.min,s.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(m.Primitive.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...r,ref:a,style:{...e.style,[o.startEdge]:d+"%",[o.endEdge]:f+"%"}})});khe.displayName=lF;var cF="SliderThumb",_he=Q.forwardRef((e,t)=>{const n=ewt(e.__scopeSlider),[r,s]=Q.useState(null),o=m.useComposedRefs(t,a=>s(a)),i=Q.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(owt,{...e,ref:o,index:i})}),owt=Q.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:s,...o}=e,i=wE(cF,n),a=whe(cF,n),[c,u]=Q.useState(null),d=m.useComposedRefs(t,S=>u(S)),f=c?i.form||!!c.closest("form"):!0,h=m.useSize(c),p=i.values[r],g=p===void 0?0:Ehe(p,i.min,i.max),b=lwt(r,i.values.length),x=h==null?void 0:h[a.size],y=x?uwt(x,g,a.direction):0;return Q.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(aF.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(m.Primitive.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":i.min,"aria-valuenow":p,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...o,ref:d,style:p===void 0?{display:"none"}:e.style,onFocus:m.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(jhe,{name:s??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},r)]})});_he.displayName=cF;var iwt="RadioBubbleInput",jhe=Q.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const s=Q.useRef(null),o=m.useComposedRefs(s,r),i=m.usePrevious(t);return Q.useEffect(()=>{const a=s.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(m.Primitive.input,{style:{display:"none"},...n,ref:o,defaultValue:t})});jhe.displayName=iwt;function awt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((s,o)=>s-o)}function Ehe(e,t,n){const o=100/(n-t)*(e-t);return m.clamp(o,[0,100])}function lwt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function cwt(e,t){if(e.length===1)return 0;const n=e.map(s=>Math.abs(s-t)),r=Math.min(...n);return n.indexOf(r)}function uwt(e,t,n){const r=e/2,o=k$([0,50],[0,r]);return(r-o(t)*n)*n}function dwt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function fwt(e,t){if(t>0){const n=dwt(e);return Math.min(...n)>=t}return!0}function k$(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 hwt(e){return(String(e).split(".")[1]||"").length}function pwt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var The=yhe,mwt=Nhe,gwt=khe,bwt=_he;const Ihe=Q.forwardRef(({className:e,...t},n)=>l.jsxs(The,{ref:n,className:m.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(mwt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(gwt,{className:"absolute h-full bg-primary"})}),l.jsx(bwt,{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"})]}));Ihe.displayName=The.displayName;const Dhe=["SUN","MON","TUE","WED","THU","FRI","SAT"],xwt=Dhe.reduce((e,t,n)=>({...e,[t]:n}),{}),rc={repeats:"weekly",hour:9,minute:0,weekdays:[1,2,3,4,5],isCustom:!1};function ywt(e){if(!e||!e.trim())return{...rc};const t=e.trim(),r=(t.startsWith("cron(")&&t.endsWith(")")?t.slice(5,-1):t).trim().split(/\s+/);if(r.length<5||r.length>6)return{...rc,isCustom:!0};const[s,o,i,a,c]=r,u=Number(s),d=Number(o);if(!Number.isInteger(u)||u<0||u>59||!Number.isInteger(d)||d<0||d>23)return{...rc,isCustom:!0};if(i==="*"&&(c==="?"||c==="*"))return{...rc,repeats:"daily",hour:d,minute:u};if(i==="?"&&c!=="?"&&c!=="*"){const h=c.split(",").map(p=>p.toUpperCase()).map(p=>xwt[p]).filter(p=>typeof p=="number");if(h.length>0)return{...rc,repeats:"weekly",hour:d,minute:u,weekdays:h}}return i==="1,15"&&(c==="?"||c==="*")?{...rc,repeats:"biweekly",hour:d,minute:u}:i==="1"&&(c==="?"||c==="*")?{...rc,repeats:"monthly",hour:d,minute:u}:{...rc,hour:d,minute:u,isCustom:!0}}function vwt(e){const t=e.minute,n=e.hour;switch(e.repeats){case"daily":return`cron(${t} ${n} * * ? *)`;case"weekly":{const r=e.weekdays.length>0?e.weekdays.slice().sort((s,o)=>s-o).map(s=>Dhe[s]).join(","):"MON";return`cron(${t} ${n} ? * ${r} *)`}case"biweekly":return`cron(${t} ${n} 1,15 * ? *)`;case"monthly":return`cron(${t} ${n} 1 * ? *)`}}function Mhe(e,t){const n=e<12?"AM":"PM",r=e%12===0?12:e%12,s=t.toString().padStart(2,"0");return`${r}:${s} ${n}`}function wwt(e){return!e||e==="UTC"?"UTC":(e.split("/").pop()??e).replace(/_/g," ")}function Swt(e){if(e.length===7)return"every day";const t=e.slice().sort((s,o)=>s-o);if(t.length===5&&t.every(s=>s>=1&&s<=5))return"weekdays";const r=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return t.map(s=>r[s]).join(", ")}function Cwt(e,t,n,r){const s=Mhe(e.hour,e.minute),o=wwt(t);let i;if(e.isCustom)i=`Custom schedule · ${s} ${o}`;else switch(e.repeats){case"daily":i=`Daily at ${s} ${o}`;break;case"weekly":i=`Weekly · ${Swt(e.weekdays)} at ${s} ${o}`;break;case"biweekly":i=`Every two weeks (1st and 15th) at ${s} ${o}`;break;case"monthly":i=`Monthly on the 1st at ${s} ${o}`;break}const a=[];return n&&n!=="Today"&&a.push(`from ${n}`),r&&a.push(`until ${r}`),a.length>0?`${i}, ${a.join(" ")}`:i}const Nwt=["UTC","America/New_York","America/Chicago","America/Denver","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Singapore","Asia/Tokyo","Australia/Sydney"];exports.Accordion=g3;exports.AccordionContent=R0;exports.AccordionItem=M0;exports.AccordionTrigger=A0;exports.AddDataPicker=e$;exports.AggregateTable=ej;exports.Alert=KP;exports.AlertDescription=ZP;exports.AlertDialog=$c;exports.AlertDialogAction=jl;exports.AlertDialogCancel=El;exports.AlertDialogContent=Sl;exports.AlertDialogDescription=_l;exports.AlertDialogFooter=Nl;exports.AlertDialogHeader=Cl;exports.AlertDialogTitle=kl;exports.AlertDialogTrigger=X2;exports.AlertTitle=FX;exports.ArrowDown=Ls;exports.ArrowDownIcon=ZWe;exports.ArrowLeft=nv;exports.ArrowRight=Tk;exports.ArrowUp=eo;exports.ArrowUpIcon=QWe;exports.AssistantContextEntityControls=GR;exports.AssistantVirtualizedMessages=she;exports.AtSign=pW;exports.AxisConfigurator=_g;exports.Badge=ps;exports.Bell=kS;exports.BookType=gW;exports.BulletChartIcon=Zfe;exports.COMMON_TIMEZONES=Nwt;exports.CSS=ji;exports.CalculatedFieldEditor=Mle;exports.Calculator=xW;exports.Calendar=bi;exports.Calendar$1=JS;exports.CalendarRange=yW;exports.Card=Im;exports.CardContent=Ek;exports.CardHeader=jk;exports.CardSummary=vR;exports.CardTitle=pg;exports.ChartArea=U2;exports.ChartColumnIncreasing=vW;exports.ChartColumnStacked=wW;exports.ChartJsVisual=Bv;exports.ChartLine=SW;exports.ChartNoAxesGantt=NW;exports.ChartPie=kW;exports.ChartScatter=_W;exports.ChatInputWithContext=t$;exports.Checkbox=zn;exports.ChevronLeft=Ph;exports.ChevronRight=mr;exports.Circle=Ik;exports.CircleAlert=ah;exports.CircleCheck=TW;exports.CircleHelp=IW;exports.Clock=wF;exports.CodeHighlighter=Uu;exports.CodeXml=Vf;exports.Collapsible=Hc;exports.CollapsibleContent=qc;exports.CollapsibleTrigger=Uc;exports.ColorField=Vi;exports.Command=qj;exports.CommandEmpty=Yj;exports.CommandGroup=Gj;exports.CommandInput=s3;exports.CommandItem=Kj;exports.CommandList=Wj;exports.CommandSeparator=Qae;exports.ComparisonMetadataBadge=ote;exports.Container=nP;exports.ControlDefaultValueEditor=ece;exports.ControlDefinitionOptionsEditor=Jle;exports.ControlIdInput=Kle;exports.ControlVisibilitySettings=mnt;exports.Copy=vl;exports.CopyButton=Ju;exports.CopyPlus=W2;exports.Cross2Icon=nYe;exports.CustomFilterPopover=NL;exports.CustomScrollArea=Vl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=lee;exports.DEFAULT_SCHEDULE_VM=rc;exports.Dashboard=fhe;exports.DashboardActionsMenu=UY;exports.DashboardCard=sae;exports.DashboardCreateDialogBase=wG;exports.DashboardExportDialog=ohe;exports.DashboardPlus=Evt;exports.DashboardWC=Uvt;exports.DataAppBuilder=EK;exports.DataTableConditionalFormattingSettings=Vce;exports.DataTablePagination=G_;exports.Database=ti;exports.DateRangePicker=sL;exports.DefaultChatTransport=W3;exports.Dialog=Po;exports.DialogContent=mo;exports.DialogDescription=oi;exports.DialogFooter=Kc;exports.DialogHeader=ra;exports.DialogTitle=go;exports.DialogTrigger=xG;exports.DisplayPreferencesProvider=Rj;exports.DndContext=aw;exports.Donut=DW;exports.Download=Yc;exports.DownloadPdf=ihe;exports.DragOverlay=Lae;exports.DropdownMenu=Mo;exports.DropdownMenuCheckboxItem=xu;exports.DropdownMenuContent=fo;exports.DropdownMenuItem=Tn;exports.DropdownMenuLabel=Ec;exports.DropdownMenuRadioGroup=Sbe;exports.DropdownMenuRadioItem=VY;exports.DropdownMenuSeparator=Ea;exports.DropdownMenuSub=zF;exports.DropdownMenuSubContent=$k;exports.DropdownMenuSubTrigger=Lk;exports.DropdownMenuTrigger=Ao;exports.EMPTY_DATA_SOURCE=ug;exports.Editable=VN;exports.EditableText=ei;exports.EditorCustomVisual=Qvt;exports.Ellipsis=ja;exports.EllipsisVertical=Oh;exports.ErrorBoundary=Aa;exports.ExportError=Ag;exports.ExternalLink=Mm;exports.Eye=rv;exports.EyeOff=Dk;exports.Fallback=Mj;exports.FallbackVisual=N0;exports.FeedbackCategory=Cd;exports.FeedbackDialog=q0;exports.FieldsList=N3;exports.FieldsSection=qvt;exports.FileSpreadsheet=MW;exports.FileText=wi;exports.Filter=lh;exports.FilterComponent=kj;exports.FilterInfo=gR;exports.FilterableFieldsPanel=Rle;exports.Globe=mg;exports.Grid3x3=AW;exports.GripVertical=Gc;exports.HEATMAP_PRESET_PALETTES=nA;exports.Hash=RW;exports.House=FW;exports.HoverCard=Fg;exports.HoverCardContent=ud;exports.HoverCardTrigger=Pg;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=phe;exports.INLINE_ALLOWED_TOOL_LIST=Yvt;exports.INLINE_BLOCKED_MUTATING_TOOLS=Wvt;exports.IconButton=jc;exports.IconForFieldType=iC;exports.InfoHover=WL;exports.InlineFilterBar=Gie;exports.KPICard=bd;exports.KeyboardSensor=ow;exports.Layers=sv;exports.LayoutDashboard=Am;exports.Link=SF;exports.LoadingDots=fd;exports.Lock=Mk;exports.MAX_SELF_HEAL_ATTEMPTS=Gvt;exports.Map=LW;exports.Markdown=gfe;exports.Maximize2=Ak;exports.MdStackedLineChart=Gfe;exports.Minimize2=CF;exports.MultiInputEmptyRenderer=Q5;exports.PYTHON_DEFAULT_CODE=uF;exports.PanelLeft=NF;exports.PanelResizeHandle=e_;exports.Paperclip=$W;exports.PenLine=Y2;exports.Pencil=G2;exports.PendingMessagesDisplay=Dde;exports.PersistedDynamicVisual=Aj;exports.PiChartPolar=Ufe;exports.PivotTableTanstack=nb;exports.Placeholders=Gce;exports.Play=zW;exports.Plus=pr;exports.PointerSensor=lb;exports.Progress=Q3;exports.RECOVERABLE_SQL_ERROR_CODES=Zvt;exports.Radar=BW;exports.RadioGroup=Ia;exports.RadioGroupItem=js;exports.RefreshCw=Lc;exports.ResizableHandle=NK;exports.ResizablePanel=Oy;exports.ResizablePanelGroup=JF;exports.ResourceEditDialog=QG;exports.ResourceType=Zr;exports.SELF_HEAL_TIMELINE_STEP=Kvt;exports.Search=Ws;exports.SeedQuestions=gde;exports.SemaphorContext=hg;exports.SemaphorContextProvider=bF;exports.SemaphorQueryClient=lW;exports.SemaphorReadyIndicator=N$;exports.SemaphorStyleWrapper=rb;exports.Send=kF;exports.Settings=_F;exports.Settings2=gg;exports.Share2=VW;exports.ShareDialog=XG;exports.Sheet=Yee;exports.SheetContent=ZO;exports.SheetDescription=QO;exports.SheetHeader=Kee;exports.SheetTitle=XO;exports.SheetTrigger=t5e;exports.Slider=Ihe;exports.SortableContext=lw;exports.Sparkles=CC;exports.Square=jF;exports.SquarePen=Fk;exports.Star=EF;exports.StructuralParticipantSelector=Zle;exports.SummaryCard=hR;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Xu;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=qi;exports.TableBody=yh;exports.TableCell=or;exports.TableColumnVisibilitySettings=Ice;exports.TableHead=Ko;exports.TableHeader=Rg;exports.TablePresentationSettings=Mce;exports.TableRow=Gr;exports.TableSkeleton=YL;exports.TableVisual=dd;exports.TbChartBubble=qfe;exports.TbChartFunnel=Wfe;exports.TbChartTreemap=Yfe;exports.TextCard=rg;exports.Textarea=zh;exports.TiSortNumerically=Kfe;exports.Toggle=Ij;exports.Tornado=HW;exports.Trash2=wl;exports.TreePalm=IF;exports.TrendingUp=UW;exports.TriangleAlert=Ki;exports.TypeGlyph=ew;exports.UXProvider=C$;exports.User=qW;exports.Users=DF;exports.applyFilterOverridesToDashboardInputSlots=tX;exports.areContextEntitiesEqual=ir;exports.areEntitiesJoined=hee;exports.arrayMove=cb;exports.buildCardControlUsageById=bnt;exports.buildCustomCardTheme=Kv;exports.buildDashboardCardExecutionSnapshot=eX;exports.buildDashboardControlUsageById=gnt;exports.buildDashboardExecutionSnapshot=HP;exports.buildDashboardInputExecutionSnapshot=qu;exports.buildDashboardSheetsInputExecutionSnapshot=rX;exports.buildDashboardStructuralParticipantIdsByControlId=rce;exports.buildFilterFieldMeta=u3;exports.buildFilterSemanticContext=d3;exports.buildInlineFilterNodes=_L;exports.buildMultiInputCustomVisualProps=ML;exports.buildScheduleExpr=vwt;exports.buildSchedulePreview=Cwt;exports.buildSlotOrderedCards=EL;exports.calculateContextAwareFilters=hv;exports.calculateFieldState=BO;exports.canUserAccessVisuals=YKe;exports.canUserCreateDashboards=WKe;exports.canUserEdit=HKe;exports.canUserManageDashboards=qKe;exports.canUserManageGroups=GKe;exports.canUserUseFilters=UKe;exports.cancelExport=HPe;exports.chartSupportsDataLabels=oJ;exports.chartSupportsLegend=rJ;exports.chartTypes=vE;exports.cleanupKpiMetricComparisonMode=ile;exports.cloneDeep=Zo;exports.cloneLinkedFrameWithSourceMapping=pKe;exports.closestCenter=sw;exports.commitSharedCalculatedFields=cf;exports.createAssistantConversationId=Up;exports.createAssistantRequestId=pde;exports.createCardsFromSlots=TYe;exports.createChartConfig=Mg;exports.createDashboardControlInputFromControl=fot;exports.createDefaultGlobalDateFilter=SNe;exports.createExport=Aee;exports.createUniqueDashboardInputVariableNameFromName=ed;exports.dedup=qdt;exports.doesStoredFilterMatchField=lg;exports.downloadDocumentPdf=qP;exports.downloadPdf=dX;exports.extractSqlParamReferences=aoe;exports.extractTableMetadata=c3;exports.fieldAlreadyExists=mee;exports.findCustomVisualConfigCard=IL;exports.findDashboardFrameById=hNe;exports.flexRender=Qo;exports.formatDisplayFormula=uet;exports.formatFileSize=WPe;exports.formatFilterLine=OX;exports.formatTimeLabel=Mhe;exports.getAutoDetectedChartIcon=t0t;exports.getChartGridStyle=W_e;exports.getChartIconByType=n0t;exports.getColorForValue=yM;exports.getConfigSlotExpectedType=EYe;exports.getCoreRowModel=q_;exports.getCustomVisualInputCards=TL;exports.getDateFormatOptionsForGranularity=I0;exports.getDefaultAxisConfig=wM;exports.getDefaultChartColors=qh;exports.getDefaultDataLabelsConfig=kv;exports.getDefaultExportFormat=eQ;exports.getDefaultFilterSql=cL;exports.getDefaultLegendConfig=NO;exports.getDefaultRunningTotalPartitionByFieldIds=Cy;exports.getDocumentSectionEditorCard=Gtt;exports.getDocumentSheetDashboardInputs=hw;exports.getDownloadUrl=VPe;exports.getEffectiveCardTypeForSlot=hm;exports.getEntityIcon=bk;exports.getErrorMessage=nde;exports.getExportStatus=BPe;exports.getExports=zPe;exports.getExpressionFieldKind=yd;exports.getFieldExpressionAnnotation=f3;exports.getFilterCount=YN;exports.getGlobalDateFilter=vg;exports.getGlobalDateFilterCoverage=CNe;exports.getGranularityOptionsForFieldType=I3;exports.getKeys=yr;exports.getMetricDisplayLabel=lPe;exports.getNewField=vee;exports.getObjectDiff=Vq;exports.getPaginationRowModel=W_;exports.getRoleBasedDisplayOverrides=Yie;exports.getRunningTotalOrderByCandidates=MJe;exports.getSelectedDateFilterColumn=coe;exports.getSheetScopedFilterValues=By;exports.getSlotDefinitionForIndex=jL;exports.getSlotExpectedChartType=Ej;exports.getSlotIndexForCard=S0;exports.getSortedRowModel=Wee;exports.getSupportedExportFormats=JX;exports.getTableConditionalFormattingColumnOptions=Pce;exports.getTableOutputColumnOptions=Oce;exports.getTablePageSizeOptions=Iee;exports.handleAggregationChange=bR;exports.handleAggregationLabelChange=qie;exports.hasFlatTableTotalsBehavior=bke;exports.horizontalListSortingStrategy=e3;exports.isCalculatedFilterField=D0;exports.isCardSummaryVisibleOnCard=AL;exports.isCustomVisualConfigCard=dR;exports.isDefaultColor=_ke;exports.isEligibleFlatTableTotalsCard=wg;exports.isExportComplete=qPe;exports.isExportInProgress=UPe;exports.isInAiScopeArray=Udt;exports.isManagedCalculatedExpressionField=ka;exports.isMetricTransformEnabled=IJe;exports.isPromiseLike=YR;exports.isSubtotalEnabledAggregateTable=l3;exports.isSupportedDocumentTableCardType=Ktt;exports.lastAssistantMessageIsCompleteWithToolCalls=Que;exports.merge=yl;exports.mergeAxisConfig=SM;exports.normalizeConditionalFormatting=PP;exports.normalizeContextFormatMode=HX;exports.normalizeDashboardInputVariableName=tv;exports.normalizeMultiInputPayload=DL;exports.parseScheduleExpr=ywt;exports.pivotData=xv;exports.prepareFeedbackData=yE;exports.purify=qA;exports.reindexSlotCards=jYe;exports.remarkGfm=zfe;exports.removeFromScopeArray=Wdt;exports.resolveDashboardInputContext=Bl;exports.resolveDomainCalculatedFieldForEdit=itt;exports.resolveMultiInputType=Zv;exports.resolveMultiInputTypeFromVisual=IYe;exports.resolveTablePageSize=V_;exports.resolveTablePresentationStyle=a5;exports.sanitizeAIScope=tde;exports.saveCalculatedFieldToCardScope=TR;exports.saveCalculatedFieldToSharedScope=Ale;exports.saveCalculatedFieldToSheetScope=IR;exports.seedSemanticMetricFormatDefaults=lle;exports.setTableColumnVisibility=Pee;exports.setupEditorWithCard=w_;exports.showAllTableColumns=ZPe;exports.showJoinRequiredNotification=pee;exports.sortByColumnsToSortState=mte;exports.sortStateToSortByColumns=gte;exports.sortableKeyboardCoordinates=n3;exports.supportsMetricTransformForMetric=ale;exports.supportsTableConditionalFormatting=Ace;exports.toEntityArray=Na;exports.ue=at;exports.useActiveExports=Awe;exports.useActiveToolStatus=Ade;exports.useAddFrameWithFreshSemanticExecutionPayload=qL;exports.useAddNewFrame=pae;exports.useAssistantContainer=DK;exports.useAssistantContextEntities=Pj;exports.useAssistantLayoutStore=Uf;exports.useAssistantPanel=TK;exports.useAssistantProfile=mde;exports.useAutoSubmitQueue=Mde;exports.useBrandStudioPreview=pvt;exports.useCard=vPe;exports.useCardFilterValues=See;exports.useCardSummary=RL;exports.useChat=ede;exports.useColumns=o3;exports.useCreateVisualWithFrame=pxe;exports.useCurrentUserInfo=na;exports.useCustomVisual=Xh;exports.useCustomVisualsQuery=CL;exports.useDashboardAppearance=Pl;exports.useDashboardById=XY;exports.useDashboardCreation=eG;exports.useDashboardManagement=JY;exports.useDashboardPreferences=bg;exports.useDashboardQuery=ev;exports.useDashboardStructuralParticipants=sce;exports.useDashboardSummary=Eie;exports.useDataColumns=ule;exports.useDateFilterHook=aHe;exports.useDebounce=by;exports.useDefaultDashboardMutation=qY;exports.useDisplayPreferences=zl;exports.useDroppable=Oae;exports.useEditorAside=Zj;exports.useEditorCardQuery=v_;exports.useEnsureReactGlobals=Pse;exports.useExportActions=MK;exports.useExportStore=t_;exports.useFieldManagement=cle;exports.useFilterableFields=rle;exports.useFullscreenAssistant=IK;exports.useGroupMembers=pye;exports.useGroups=HG;exports.useHasDashboardId=AK;exports.useInProgressExportsCount=Rwe;exports.useIsDashboardSelected=nme;exports.useIsVisualSelected=rme;exports.useJoinabilityMap=a3;exports.useManagementActions=Fh;exports.useManagementStore=os;exports.useMutation=co;exports.usePivotTableConfig=Yh;exports.usePluginQuery=pie;exports.useQuery=$n;exports.useQueryClient=ts;exports.useReactTable=Y_;exports.useResolveExistingFrameSemanticExecutionPayload=xKe;exports.useResourceManagement=Vk;exports.useResourceUpdateState=QY;exports.useScopedFields=nle;exports.useSelectedVisual=tme;exports.useSemaphorContext=Ct;exports.useSensor=ag;exports.useSensors=zj;exports.useSortable=ub;exports.useStarredChartsStore=Jvt;exports.useSurfaceAppearance=Xc;exports.useTableQueryState=ite;exports.useTextFilterHook=xHe;exports.useTheme=dF;exports.useTopoJson=jv;exports.useUnifiedUsers=WF;exports.useUpdateResource=YY;exports.useUpdateVisualMutation=mxe;exports.useUserPreferences=SG;exports.useVisualById=Bk;exports.useVisualManagement=hxe;exports.validateFieldForChartType=ole;exports.verticalListSortingStrategy=t3;