react-semaphor 0.1.419 → 0.1.420
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.
|
@@ -114,4 +114,4 @@
|
|
|
114
114
|
.${T}-tab:hover {
|
|
115
115
|
color: var(--sd-fg);
|
|
116
116
|
}
|
|
117
|
-
`;function pr(){if(typeof document>"u"||document.getElementById(er))return;const e=document.createElement("style");e.id=er,e.textContent=it,document.head.appendChild(e)}const ue='ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',$="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",Se={color:"var(--sd-fg-muted)",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em"},a={launcher:{position:"fixed",bottom:20,zIndex:2147483e3,display:"inline-flex",alignItems:"center",gap:7,height:36,minWidth:36,padding:"0 10px",borderWidth:1,borderStyle:"solid",borderRadius:6,boxShadow:"var(--sd-shadow)",font:`600 12px/1.2 ${ue}`,cursor:"pointer"},launcherText:{fontVariantNumeric:"tabular-nums"},launcherIssueCount:{display:"grid",minWidth:18,height:18,padding:"0 6px",placeItems:"center",borderRadius:999,border:"1px solid currentColor",background:"var(--sd-bg)",color:"currentColor",fontSize:10,lineHeight:"18px",whiteSpace:"nowrap"},logoMark:{display:"grid",width:18,height:18,placeItems:"center",flex:"0 0 auto",borderRadius:4,background:"var(--sd-fg)",color:"var(--sd-bg)"},panel:{position:"fixed",top:16,right:16,bottom:16,zIndex:2147483001,width:"min(720px, calc(100vw - 32px))",display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid var(--sd-border)",borderRadius:6,background:"var(--sd-bg)",color:"var(--sd-fg)",boxShadow:"var(--sd-shadow)",font:`13px/1.4 ${ue}`},panelFullscreen:{top:0,right:0,bottom:0,left:0,width:"100vw",height:"100vh",borderRadius:0},panelHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",borderBottom:"1px solid var(--sd-border)"},panelTitleBlock:{minWidth:0},panelTitle:{fontSize:13,fontWeight:600},panelSubtitle:{marginTop:2,color:"var(--sd-fg-muted)",fontSize:11},panelActions:{display:"flex",alignItems:"center",gap:6},iconButton:{display:"grid",width:28,height:28,placeItems:"center",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:5,background:"var(--sd-bg)",color:"var(--sd-fg-muted)",cursor:"pointer"},searchBox:{display:"flex",alignItems:"center",gap:8,margin:10,height:28,padding:"0 8px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:5,color:"var(--sd-fg-muted)"},searchInput:{minWidth:0,flex:1,border:0,outline:0,background:"transparent",color:"var(--sd-fg)",font:`12px/1.4 ${ue}`},issueSummary:{margin:"0 10px 10px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-warning-border)",borderRadius:6,background:"var(--sd-warning-bg)",color:"var(--sd-warning-fg)",overflow:"hidden"},issueSummaryToggle:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,width:"100%",padding:"7px 9px 5px",border:0,background:"transparent",color:"inherit",cursor:"pointer",...Se},issueSummaryHeaderLabel:{display:"inline-flex",alignItems:"center",gap:4,minWidth:0},issueSummaryCount:{fontVariantNumeric:"tabular-nums"},issueSummaryCollapsed:{padding:"0 9px 8px 26px",color:"var(--sd-fg-muted)",fontSize:11},issueSummaryList:{display:"grid",gap:1,padding:"0 6px 6px"},issueSummaryItem:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",alignItems:"start",gap:8,width:"100%",padding:"7px 8px",border:0,borderRadius:5,background:"transparent",color:"inherit",textAlign:"left",cursor:"pointer"},issueSummaryBadge:{display:"inline-flex",alignItems:"center",height:17,padding:"0 5px",borderWidth:1,borderStyle:"solid",borderRadius:3,fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em"},issueSummaryBadgeError:{borderColor:"var(--sd-error-border)",background:"var(--sd-error-bg)",color:"var(--sd-error-fg)"},issueSummaryBadgeWarning:{borderColor:"var(--sd-warning-border)",background:"var(--sd-bg)",color:"var(--sd-warning-fg)"},issueSummaryText:{display:"grid",gap:2,minWidth:0},issueSummaryTitle:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,fontWeight:650},issueSummaryMessage:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-warning-fg)",fontSize:11},issueSummaryMore:{padding:"3px 8px 5px",color:"var(--sd-fg-muted)",fontSize:11},panelBody:{display:"grid",gridTemplateColumns:"minmax(210px, 280px) minmax(0, 1fr)",minHeight:0,flex:1,borderTop:"1px solid var(--sd-border-soft)"},queryList:{minHeight:0,overflowY:"auto",padding:8,borderRight:"1px solid var(--sd-border)",background:"var(--sd-bg-muted)"},queryGroup:{display:"grid",gap:3,marginBottom:8},queryGroupHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 6px 3px",...Se},queryGroupCount:{color:"var(--sd-fg-subtle)",fontVariantNumeric:"tabular-nums"},queryGroupEmpty:{padding:"7px 8px",color:"var(--sd-fg-subtle)",fontSize:11},queryListItem:{display:"grid",gap:3,width:"100%",padding:"7px 8px",borderWidth:1,borderStyle:"solid",borderColor:"transparent",borderRadius:5,background:"transparent",color:"var(--sd-fg)",textAlign:"left",cursor:"pointer"},queryListItemSelected:{borderColor:"var(--sd-border-strong)",background:"var(--sd-bg-raised)"},queryListItemHeader:{display:"flex",alignItems:"center",gap:7,minWidth:0},statusDot:{width:7,height:7,flex:"0 0 auto",borderRadius:999},queryListTitle:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,fontWeight:650,color:"var(--sd-fg)"},queryListKindChip:{flex:"0 0 auto",display:"inline-flex",alignItems:"center",height:15,padding:"0 5px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)",fontFamily:$,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},queryListIssueBadge:{flex:"0 0 auto",display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:16,height:16,padding:"0 4px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-warning-border)",borderRadius:999,background:"var(--sd-warning-bg)",color:"var(--sd-warning-fg)",fontSize:10,fontWeight:700,fontVariantNumeric:"tabular-nums"},queryListSource:{minWidth:0,paddingLeft:14,color:"var(--sd-fg-muted)",fontSize:11,lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},queryListSubtitleSep:{color:"var(--sd-fg-subtle)"},detailsPane:{minHeight:0,overflowY:"auto",padding:16},detailsHeader:{display:"grid",gap:6,marginBottom:14},detailsHeaderTopRow:{display:"flex",alignItems:"center",gap:8,minWidth:0},detailsHeaderStatusDot:{width:8,height:8,flex:"0 0 auto",borderRadius:999},detailsTitle:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:14,fontWeight:700,color:"var(--sd-fg)"},detailsKindChip:{flex:"0 0 auto",padding:"2px 6px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)",fontFamily:$,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},metaStrip:{display:"flex",flexWrap:"wrap",alignItems:"center",columnGap:6,rowGap:2,paddingLeft:16,color:"var(--sd-fg-muted)",fontSize:11},metaStripItem:{color:"var(--sd-fg-muted)",fontVariantNumeric:"tabular-nums"},metaStripDot:{color:"var(--sd-fg-subtle)"},sourcePillRow:{display:"flex",flexWrap:"wrap",gap:6},sourcePill:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 7px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:5,background:"var(--sd-bg)",color:"var(--sd-fg)"},sourcePillLabel:{fontFamily:$,fontSize:11,color:"var(--sd-fg)"},sourcePillRole:{display:"inline-flex",alignItems:"center",height:14,padding:"0 4px",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg-subtle)",fontFamily:$,fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em"},fieldChipList:{display:"grid",gap:0,paddingTop:2},fieldChip:{display:"flex",alignItems:"center",gap:8,minWidth:0,padding:"5px 6px",margin:"0 -6px",borderRadius:4},fieldGlyph:{display:"inline-flex",flex:"0 0 auto",alignItems:"center",justifyContent:"center",width:18,height:18,borderWidth:1,borderStyle:"solid",borderRadius:4,fontFamily:$,fontSize:11,fontWeight:700,lineHeight:1},fieldAggBadge:{display:"inline-flex",alignItems:"center",height:16,padding:"0 5px",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg)",fontFamily:$,fontSize:10,fontWeight:600,letterSpacing:"0.04em"},fieldChipName:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,fontWeight:500},fieldChipMeta:{flex:"0 0 auto",fontFamily:$,fontSize:10,color:"var(--sd-fg-subtle)"},fieldChipMetaDot:{color:"var(--sd-fg-subtle)",fontSize:10},sqlKeyword:{color:"var(--sd-sql-keyword)",fontWeight:600},sqlBindParam:{color:"var(--sd-sql-bind)"},traceTabs:{marginTop:16},traceTabBar:{display:"flex",gap:2,borderBottom:"1px solid var(--sd-border)",overflowX:"auto",scrollbarWidth:"none"},traceTab:{flex:"0 0 auto",appearance:"none",border:"none",background:"transparent",cursor:"pointer",padding:"6px 9px",marginBottom:-1,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",borderBottom:"2px solid transparent",whiteSpace:"nowrap"},traceTabActive:{color:"var(--sd-fg)",borderBottom:"2px solid var(--sd-fg)"},traceTabPanel:{paddingTop:12},alertCard:{marginTop:12,padding:"8px 10px",borderWidth:1,borderStyle:"solid",borderRadius:5,fontSize:12,lineHeight:1.45},alertCardError:{borderColor:"var(--sd-error-border)",background:"var(--sd-error-bg)",color:"var(--sd-error-fg)"},alertCardWarning:{borderColor:"var(--sd-warning-border)",background:"var(--sd-warning-bg)",color:"var(--sd-warning-fg)"},alertCardTitle:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",fontSize:10,marginBottom:4},alertCardList:{margin:0,paddingLeft:16,display:"grid",gap:3},recipe:{display:"grid",gap:16},traceLineage:{display:"grid",gap:12},recipeGroup:{display:"grid",gap:4},recipeGroupHeader:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:2},recipeGroupTitle:{color:"var(--sd-fg-muted)",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em"},recipeGroupCount:{color:"var(--sd-fg-subtle)",fontSize:10,fontVariantNumeric:"tabular-nums"},recipeFieldList:{display:"grid"},recipeEmptyText:{padding:"5px 0",color:"var(--sd-fg-subtle)",fontSize:11},recipeFieldRow:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, auto)",alignItems:"center",gap:10,minHeight:26,padding:"4px 0",borderBottom:"1px solid var(--sd-border-soft)"},recipeFieldName:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,fontWeight:500},recipeFieldMeta:{minWidth:0,display:"inline-flex",alignItems:"baseline",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg-subtle)",fontSize:11,textAlign:"right"},inputsAppliedBlock:{marginTop:16,padding:"10px 12px",border:"1px solid var(--sd-border)",borderLeft:"2px solid var(--sd-fg-muted)",borderRadius:5,background:"var(--sd-bg-muted)"},inputsAppliedHeader:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,marginBottom:6},inputsAppliedTitle:{color:"var(--sd-fg)",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em"},inputsAppliedCount:{color:"var(--sd-fg-subtle)",fontSize:10,fontVariantNumeric:"tabular-nums"},inputRecipeList:{display:"grid"},inputRecipeRow:{display:"grid",gap:2,minWidth:0,padding:"6px 0",borderBottom:"1px solid var(--sd-border-soft)"},inputRecipeHeader:{display:"flex",alignItems:"center",gap:8,minWidth:0},inputRecipeLabel:{flex:"1 1 auto",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,fontWeight:600},inputRecipeId:{flex:"0 0 auto",maxWidth:"32%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg-subtle)",fontFamily:$,fontSize:10,fontWeight:600},inputOperatorBadge:{display:"inline-flex",flex:"0 0 auto",alignItems:"center",height:16,padding:"0 5px",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)",fontFamily:$,fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em"},inputValuePreview:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,textAlign:"right"},inputRecipeBinding:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg-muted)",fontSize:11},eventList:{display:"grid"},eventRow:{display:"grid",gridTemplateColumns:"96px minmax(0, 1fr)",gap:10,padding:"6px 0",borderBottom:"1px solid var(--sd-border-soft)"},eventType:{color:"var(--sd-fg)",fontWeight:600,fontSize:12},eventMeta:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg-muted)",fontSize:11},mutedText:{color:"var(--sd-fg-muted)",fontSize:12},compiledQuery:{display:"grid",gap:10},resultPreview:{display:"grid",gap:8},resultPreviewHeader:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10},resultPreviewTitle:{color:"var(--sd-fg)",fontSize:12,fontWeight:650},resultPreviewSummary:{flex:"0 0 auto",color:"var(--sd-fg-subtle)",fontSize:11,fontVariantNumeric:"tabular-nums"},resultPreviewScroller:{maxHeight:260,overflow:"auto",border:"1px solid var(--sd-border)",borderRadius:5,background:"var(--sd-bg-muted)"},resultPreviewTable:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:11},resultPreviewTh:{position:"sticky",top:0,zIndex:1,padding:"6px 8px",borderBottom:"1px solid var(--sd-border)",background:"var(--sd-bg-raised)",color:"var(--sd-fg-muted)",fontSize:10,fontWeight:700,letterSpacing:"0.06em",textAlign:"left",textTransform:"uppercase"},resultPreviewTd:{minWidth:0,padding:"6px 8px",borderBottom:"1px solid var(--sd-border-soft)",color:"var(--sd-fg)",fontFamily:$,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"top"},resultPreviewEmptyCell:{padding:"9px 10px",color:"var(--sd-fg-subtle)",fontSize:12,textAlign:"center"},resultPreviewFootnote:{color:"var(--sd-fg-subtle)",fontSize:11},codeBlockGroup:{display:"grid",gap:5},codeBlockLabel:{...Se},codeBlock:{maxHeight:260,margin:0,overflow:"auto",padding:"8px 10px",border:"1px solid var(--sd-border)",borderRadius:5,background:"var(--sd-bg-muted)",color:"var(--sd-fg)",fontFamily:$,fontSize:11,lineHeight:1.5,whiteSpace:"pre-wrap"},emptyState:{padding:10,color:"var(--sd-fg-muted)",textAlign:"center",fontSize:12},inspectButton:{display:"inline-flex",alignItems:"center",gap:5,height:24,maxWidth:"100%",padding:"0 7px",borderWidth:1,borderStyle:"solid",borderRadius:5,background:"var(--sd-bg)",font:`600 11px/1 ${ue}`,cursor:"pointer"},inspectButtonText:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},we=10,Ie=100,ot=25,at=500,gr={enabled:!1,queries:[],issues:[],getQuery:()=>{},getQueries:()=>[]},We=c.createContext(null),_e=c.createContext(null),Ne=c.createContext(void 0),P=[];function lt({debug:e,children:r}){const t=c.useMemo(()=>cn(e),[e]),[n,s]=c.useReducer(nn,t,wr),o=c.useRef(n),u=c.useId(),[p,d]=c.useState({open:!1});o.current=n,c.useEffect(()=>{s({type:"config",config:t})},[t]),c.useEffect(()=>{if(!n.enabled||!n.exposeWindowBridge||typeof window>"u")return;const h=un(()=>o.current);return dt({ownerId:u,bridge:h}),()=>{ut(u)}},[u,n.enabled,n.exposeWindowBridge]);const f=c.useMemo(()=>({state:n,dispatch:s}),[n]),y=c.useCallback(h=>{d({open:!0,focus:h})},[]),m=c.useCallback(()=>{d(h=>({...h,open:!1}))},[]),v=c.useCallback(h=>{d({open:!0,focus:h})},[]),g=c.useMemo(()=>({open:p.open,focus:p.focus,openDevtools:y,closeDevtools:m,focusTrace:v}),[m,v,y,p.focus,p.open]);return i.jsx(We.Provider,{value:f,children:i.jsx(_e.Provider,{value:g,children:r})})}function dt(e){const r=P.findIndex(t=>t.ownerId===e.ownerId);r>=0&&P.splice(r,1),P.push(e),mr()}function ut(e){const r=P.findIndex(t=>t.ownerId===e);r>=0&&P.splice(r,1),mr()}function mr(){if(typeof window>"u")return;const e=P[P.length-1];e?window.__SEMAPHOR_DEVTOOLS__=e.bridge:delete window.__SEMAPHOR_DEVTOOLS__}function ct({id:e,title:r,children:t}){const n=c.useMemo(()=>({id:e,title:r}),[e,r]);return i.jsx(Ne.Provider,{value:n,children:t})}function yr({buttonPosition:e="bottom-right",initialIsOpen:r=!1,panelPosition:t="right",className:n,style:s}={}){const o=Pe(),u=c.useContext(_e),[p,d]=c.useState(""),[f,y]=c.useState(!1),m=c.useRef(null),v=c.useRef(null),g=u==null?void 0:u.openDevtools,h=u==null?void 0:u.closeDevtools,j=(u==null?void 0:u.open)===!0;c.useEffect(()=>{pr()},[]),c.useEffect(()=>{r&&o.enabled&&(g==null||g())},[r,o.enabled,g]),c.useEffect(()=>{if(!j||!h)return;const x=S=>{var I,L;const E=S.target;E instanceof Node&&((I=m.current)!=null&&I.contains(E)||(L=v.current)!=null&&L.contains(E)||h())};return document.addEventListener("pointerdown",x,!0),document.addEventListener("mousedown",x,!0),document.addEventListener("click",x,!0),()=>{document.removeEventListener("pointerdown",x,!0),document.removeEventListener("mousedown",x,!0),document.removeEventListener("click",x,!0)}},[h,j]);const l=c.useMemo(()=>Qr(o.queries),[o.queries]),b=c.useMemo(()=>Me(o.queries),[o.queries]),D=Dt(l),C=c.useMemo(()=>$t(o.queries,p),[o.queries,p]),B=c.useMemo(()=>Ot(C),[C]),R=c.useMemo(()=>hr(C,u==null?void 0:u.focus)||C[0],[C,u==null?void 0:u.focus]);return!o.enabled||!u?null:i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:m,type:"button","aria-label":"Open Semaphor Inspector",title:D,className:n?`${T} ${n}`:T,style:{...a.launcher,...Zr(e),...et(l.severity),...s},onClick:()=>{var S;const x=(S=b[0])==null?void 0:S.trace;u.openDevtools(x?{traceId:x.traceId,queryId:x.queryId,viewId:x.viewId}:void 0)},children:[i.jsx(gt,{}),i.jsx("span",{style:a.launcherText,children:l.total}),l.issueCount>0?i.jsxs("span",{style:a.launcherIssueCount,children:[l.issueCount," issue",l.issueCount===1?"":"s"]}):null]}),u.open?i.jsxs("div",{ref:v,role:"dialog","aria-label":"Semaphor Inspector","aria-modal":"false",className:T,style:{...a.panel,...rt(t),...f?a.panelFullscreen:null},children:[i.jsxs("div",{style:a.panelHeader,children:[i.jsxs("div",{style:a.panelTitleBlock,children:[i.jsx("div",{style:a.panelTitle,children:"Semaphor Inspector"}),i.jsxs("div",{style:a.panelSubtitle,children:[l.total," queries · ",l.loading," loading ·"," ",l.failed," failed · ",l.errorCount," errors ·"," ",l.warningCount," warnings"]})]}),i.jsxs("div",{style:a.panelActions,children:[i.jsx("button",{type:"button","aria-label":f?"Exit fullscreen Semaphor Inspector":"Enter fullscreen Semaphor Inspector",title:f?"Exit fullscreen Semaphor Inspector":"Enter fullscreen Semaphor Inspector",style:a.iconButton,onClick:()=>y(x=>!x),children:f?i.jsx(se.Minimize2,{size:15}):i.jsx(se.Maximize2,{size:15})}),i.jsx("button",{type:"button","aria-label":"Close Semaphor Inspector",style:a.iconButton,onClick:u.closeDevtools,children:i.jsx(Ke.X,{size:15})})]})]}),i.jsxs("label",{style:a.searchBox,children:[i.jsx(se.Search,{size:14}),i.jsx("input",{"aria-label":"Search Semaphor traces",value:p,onChange:x=>d(x.currentTarget.value),placeholder:"Search traces",style:a.searchInput})]}),b.length?i.jsx(bt,{issues:b,onSelect:x=>u.focusTrace({traceId:x.traceId,queryId:x.queryId,viewId:x.viewId})}):null,i.jsxs("div",{style:{...a.panelBody,...tt(t)},children:[i.jsx("div",{style:{...a.queryList,...nt()},"aria-label":"Registered queries",children:C.length?B.map(x=>i.jsxs("div",{style:a.queryGroup,children:[i.jsxs("div",{style:a.queryGroupHeader,children:[i.jsx("span",{children:x.title}),i.jsx("span",{style:a.queryGroupCount,children:x.traces.length})]}),x.traces.length?x.traces.map(S=>{var Y;const E=Kt(S,R),I=ye(S),L=xr(S),ae=Sr(S),G=Wt(S,I,ae),J=G.join(" · "),k=br(L),W=Vr(b,S);return i.jsxs("button",{type:"button",title:`${I} · ${L} · ${J}`,style:{...a.queryListItem,...E?a.queryListItemSelected:null},onClick:()=>u.focusTrace({traceId:S.traceId,queryId:S.queryId,viewId:S.viewId}),children:[i.jsxs("span",{style:a.queryListItemHeader,children:[i.jsx(vt,{status:(Y=S.latestAttempt)==null?void 0:Y.status}),i.jsx("span",{style:a.queryListTitle,title:I,children:I}),i.jsx("span",{style:{...a.queryListKindChip,...vr(k)},children:L}),W>0?i.jsx("span",{style:a.queryListIssueBadge,children:W}):null]}),i.jsx("span",{className:`${T}-source`,style:a.queryListSource,title:J,children:G.map((X,Z)=>i.jsxs(c.Fragment,{children:[Z>0?i.jsx("span",{style:a.queryListSubtitleSep,children:" · "}):null,i.jsx("span",{children:X})]},`${X}:${Z}`))})]},Le(S))}):i.jsx("div",{style:a.queryGroupEmpty,children:"No input traces"})]},x.title)):i.jsx("div",{style:a.emptyState,children:"No matching traces"})}),i.jsx(mt,{trace:R})]})]}):null]})}function ft({queryId:e,viewId:r,label:t,className:n,style:s}={}){var m,v;const o=Pe(),u=c.useContext(_e),p=c.useContext(Ne);c.useEffect(()=>{pr()},[]);const d=r||(p==null?void 0:p.id),f=c.useMemo(()=>Bt(o.queries,{queryId:e,viewId:d}),[o.queries,e,d]);if(!o.enabled||!u||!f)return null;const y=t||`Inspect ${_t(f,!!e)}`;return i.jsxs("button",{type:"button","aria-label":y,title:y,className:n?`${T} ${n}`:T,style:{...a.inspectButton,...st((m=f.latestAttempt)==null?void 0:m.status),...s},onClick:()=>u.openDevtools({traceId:f.traceId,queryId:f.queryId,viewId:f.viewId}),children:[i.jsx(se.Eye,{size:13}),i.jsx("span",{style:a.inspectButtonText,children:((v=f.latestAttempt)==null?void 0:v.status)||"idle"})]})}function Pe(){const e=c.useContext(We);return!e||!e.state.enabled?gr:ne(e.state)}function pt({spec:e,queryKind:r,queryKey:t,intent:n,activeInputs:s,debug:o}){const u=c.useContext(We),p=c.useContext(Ne),d=!!(u!=null&&u.state.enabled),f=u==null?void 0:u.dispatch,y=pn(e),m=zr(e),v=c.useMemo(()=>JSON.stringify(e),[e]),g=c.useMemo(()=>JSON.stringify(s||[]),[s]),h=c.useMemo(()=>JSON.stringify(n||null),[n]),j=c.useRef(e),l=c.useRef(v),b=c.useRef(n),D=c.useRef(h),C=c.useRef(s),B=c.useRef(g),R=fn(o),x=JSON.stringify(R||[]),S=c.useRef(R),E=c.useRef(x);l.current!==v&&(l.current=v,j.current=e),D.current!==h&&(D.current=h,b.current=n),B.current!==g&&(B.current=g,C.current=s),E.current!==x&&(E.current=x,S.current=R);const I=j.current,L=b.current,ae=C.current,G=S.current,J=c.useId(),k=c.useMemo(()=>y||`query_${jr(t)}`,[t,y]),W=(o==null?void 0:o.viewId)||(p==null?void 0:p.id),Y=(o==null?void 0:o.viewTitle)||(o==null?void 0:o.title)||(p==null?void 0:p.title),X=o==null?void 0:o.visualType,Z=o==null?void 0:o.sectionTitle,_=c.useMemo(()=>[W||"unscoped-view",k,J].join("::"),[k,J,W]),Qe=c.useMemo(()=>({traceKey:_,spec:I,queryId:k,queryLabel:m,queryKind:r,builder:gn(r),viewId:W,viewTitle:Y,visualType:X,sectionTitle:Z,sourceHints:G,intent:L,activeInputs:ae,clientWarnings:y?[]:["Query spec is missing an explicit id; using an opaque internal id."]}),[k,r,y,m,I,ae,L,G,Z,_,W,Y,X]);c.useEffect(()=>{if(!(!d||!f))return f({type:"register",descriptor:Qe}),()=>{f({type:"unregister",traceKey:_})}},[Qe,f,d,_]);const K=c.useCallback((A,z)=>{!d||!f||f({type:"event",traceKey:_,event:A,latestAttempt:z})},[f,d,_]),Ue=c.useCallback(()=>{K({type:"query_started",queryId:k,at:fe()},{status:"loading"})},[K,k]),Ge=c.useCallback((A,z)=>{const ee=ar(A),re=wn(A),Dr=In(A);K({type:"query_succeeded",queryId:k,requestId:ee,at:fe(),rowCount:re,durationMs:z},{requestId:ee,status:"success",durationMs:z,rowCount:re,columnCount:Dr,metricCoverage:qn(A),executionResult:or(A)})},[K,k]),le=c.useCallback((A,z)=>{const ee=ar(A),re=A instanceof Error?A.message:String(A);K({type:"query_failed",queryId:k,requestId:ee,at:fe(),errorMessage:re},{requestId:ee,status:"error",durationMs:z,errorMessage:re,executionResult:or(A)})},[K,k]),Je=c.useCallback(A=>{K({type:"query_ignored_stale",queryId:k,at:fe(),reason:A})},[K,k]),Ye=c.useCallback(A=>{le(A,0)},[le]),ve=d?u==null?void 0:u.state.entries[_]:void 0;return c.useMemo(()=>({enabled:d,queryId:k,trace:ve?pe(ve):void 0,start:Ue,success:Ge,failure:le,ignored:Je,validationFailure:Ye}),[d,le,Je,k,Ue,Ge,ve,Ye])}function gt(){return i.jsx("span",{style:a.logoMark,"aria-hidden":!0,children:i.jsxs("svg",{viewBox:"0 0 100 100",fill:"none",width:"16",height:"16",focusable:"false",children:[i.jsx("rect",{x:"20",y:"15",width:"60",height:"12",rx:"6",fill:"currentColor"}),i.jsx("rect",{x:"20",y:"35",width:"40",height:"12",rx:"6",fill:"currentColor"}),i.jsx("rect",{x:"40",y:"55",width:"40",height:"12",rx:"6",fill:"currentColor"}),i.jsx("rect",{x:"20",y:"75",width:"60",height:"12",rx:"6",fill:"currentColor"})]})})}function mt({trace:e}){var R,x,S,E,I;if(!e)return i.jsx("div",{style:a.detailsPane,children:i.jsx("div",{style:a.emptyState,children:"No traces registered yet"})});const r=e.latestAttempt,t=r==null?void 0:r.executionResult,n=je((R=t==null?void 0:t.validation)==null?void 0:R.warnings),s=je((x=t==null?void 0:t.validation)==null?void 0:x.errors),o=Zt((S=t==null?void 0:t.coverage)==null?void 0:S.missingObligations),u=je((E=t==null?void 0:t.coverage)==null?void 0:E.warnings),p=t==null?void 0:t.compiledQuery,d=tn(t),f=((I=e.server)==null?void 0:I.compiledSql)||d.compiledSql,y=Mr(t),m=[...r!=null&&r.errorMessage?[r.errorMessage]:[],...s],v=[...e.clientWarnings,...n,...o,...u],g=e.inputsApplied.length>0,h=!!(p||f),j=zt(e),l=Qt(r==null?void 0:r.rowCount),b=Ut(r==null?void 0:r.durationMs),D=e.sourceRefs.length,C=xr(e),B=br(C);return i.jsxs("div",{style:a.detailsPane,children:[i.jsxs("div",{style:a.detailsHeader,children:[i.jsxs("div",{style:a.detailsHeaderTopRow,children:[i.jsx("span",{"aria-hidden":!0,style:{...a.detailsHeaderStatusDot,...fr(r==null?void 0:r.status)}}),i.jsx("span",{style:a.detailsTitle,children:ye(e)}),i.jsx("span",{style:{...a.detailsKindChip,...vr(B)},children:C})]}),i.jsxs("div",{style:a.metaStrip,children:[i.jsx("span",{style:a.metaStripItem,children:j}),i.jsx("span",{style:a.metaStripDot,children:"·"}),i.jsxs("span",{style:a.metaStripItem,children:[l," rows"]}),i.jsx("span",{style:a.metaStripDot,children:"·"}),i.jsx("span",{style:a.metaStripItem,children:b}),D>0?i.jsxs(i.Fragment,{children:[i.jsx("span",{style:a.metaStripDot,children:"·"}),i.jsx("span",{style:a.metaStripItem,children:D===1?"1 source":`${D} sources`})]}):null]})]}),m.length?i.jsx(rr,{tone:"error",title:"Error",items:m}):null,v.length?i.jsx(rr,{tone:"warning",title:"Warnings",items:v}):null,i.jsx(xt,{trace:e}),g?i.jsx(kt,{inputs:e.inputsApplied}):null,i.jsx(yt,{trace:e,resultPreview:y,compiledQuery:p,compiledSql:f,hasCompiled:h})]})}function yt({trace:e,resultPreview:r,compiledQuery:t,compiledSql:n,hasCompiled:s}){var h,j;const o=[];r&&o.push({id:"returned",label:"Returned",render:()=>i.jsx(Tt,{preview:r})}),s&&o.push({id:"compiled",label:"Compiled",render:()=>i.jsx(Et,{compiledQuery:t,compiledSql:n})}),(e.sourceRefs.length||e.fieldRefs.length)&&o.push({id:"lineage",label:"Sources",render:()=>i.jsx(It,{trace:e})}),(h=e.sourceHints)!=null&&h.length&&o.push({id:"hints",label:"Hints",render:()=>i.jsx(qt,{hints:e.sourceHints??[]})}),o.push({id:"lifecycle",label:"Lifecycle",render:()=>i.jsx(ht,{trace:e})}),o.push({id:"raw",label:"Raw",render:()=>i.jsx("pre",{style:a.codeBlock,children:Gt(e)})});const u=(j=o[0])==null?void 0:j.id,p=e.traceId||`${e.viewId??""}:${e.queryId}`,[d,f]=c.useState(u),y=c.useRef(p),m=c.useRef(!1),v=o.map(l=>l.id).join("|");c.useEffect(()=>{if(y.current!==p){y.current=p,m.current=!1,f(u);return}if(!(d?v.split("|").includes(d):!1)){m.current=!1,f(u);return}!m.current&&d!==u&&f(u)},[d,u,v,p]);const g=o.find(l=>l.id===d)??o[0];return i.jsxs("div",{style:a.traceTabs,children:[i.jsx("div",{style:a.traceTabBar,role:"tablist","aria-label":"Trace details",children:o.map(l=>{const b=l.id===g.id;return i.jsx("button",{type:"button",role:"tab","aria-selected":b,className:`${T}-tab`,style:{...a.traceTab,...b?a.traceTabActive:null},onClick:()=>{m.current=!0,f(l.id)},children:l.label},l.id)})}),i.jsx("div",{style:a.traceTabPanel,role:"tabpanel",children:g.render()})]})}function ht({trace:e}){return e.recentEvents.length?i.jsx("div",{style:a.eventList,children:e.recentEvents.slice(-5).map((r,t)=>i.jsxs("div",{style:a.eventRow,children:[i.jsx("span",{style:a.eventType,children:Jt(r)}),i.jsx("span",{style:a.eventMeta,children:Yt(r)})]},`${r.type}:${r.at}:${t}`))}):i.jsx("div",{style:a.mutedText,children:"No attempts recorded"})}function rr({tone:e,title:r,items:t}){const n=e==="error"?a.alertCardError:a.alertCardWarning;return i.jsxs("div",{style:{...a.alertCard,...n},children:[i.jsx("div",{style:a.alertCardTitle,children:r}),t.length>1?i.jsx("ul",{style:a.alertCardList,children:t.map((s,o)=>i.jsx("li",{children:s},`${e}-${o}`))}):i.jsx("div",{children:t[0]})]})}function bt({issues:e,onSelect:r}){const[t,n]=c.useState(!1),s=e.slice(0,6),o=e.length-s.length,u=e.filter(f=>f.tone==="error").length,p=e.length-u,d=[u?`${u} error${u===1?"":"s"}`:"",p?`${p} warning${p===1?"":"s"}`:""].filter(Boolean);return i.jsxs("section",{style:a.issueSummary,"aria-label":"Semaphor trace issues",children:[i.jsxs("button",{type:"button","aria-expanded":t,style:a.issueSummaryToggle,onClick:()=>n(f=>!f),children:[i.jsxs("span",{style:a.issueSummaryHeaderLabel,children:[t?i.jsx(Ke.ChevronDown,{size:13}):i.jsx(se.ChevronRight,{size:13}),i.jsx("span",{children:"Issues"})]}),i.jsx("span",{style:a.issueSummaryCount,children:e.length})]}),t?i.jsxs("div",{style:a.issueSummaryList,children:[s.map((f,y)=>i.jsxs("button",{type:"button",title:`${f.title}: ${f.message}`,style:a.issueSummaryItem,onClick:()=>r(f.trace),children:[i.jsx("span",{style:{...a.issueSummaryBadge,...f.tone==="error"?a.issueSummaryBadgeError:a.issueSummaryBadgeWarning},children:f.tone==="error"?"Error":"Warning"}),i.jsxs("span",{style:a.issueSummaryText,children:[i.jsx("span",{style:a.issueSummaryTitle,children:f.title}),i.jsx("span",{style:a.issueSummaryMessage,children:f.message})]})]},`${f.trace.traceId}:${f.title}:${y}`)),o>0?i.jsxs("div",{style:a.issueSummaryMore,children:[o," more issue",o===1?"":"s"," in traces"]}):null]}):i.jsxs("div",{style:a.issueSummaryCollapsed,children:[d.join(" · ")," across traces"]})]})}function vt({status:e}){return i.jsx("span",{"aria-hidden":!0,style:{...a.statusDot,...fr(e)}})}function xt({trace:e}){var s;const r=(s=e.projectionFieldRefs)!=null&&s.length?e.projectionFieldRefs:e.fieldRefs,t=e.inputFieldRefs||[],n=Pt(r);return i.jsxs("div",{style:a.recipe,children:[i.jsx(St,{sources:e.sourceRefs}),i.jsx(N,{title:"Measures",fields:n.measures}),i.jsx(N,{title:"Time fields",fields:n.timeFields}),i.jsx(N,{title:"Dimensions",fields:n.dimensions,emptyText:"No dimensions selected"}),i.jsx(N,{title:"Identifiers",fields:n.identifiers}),i.jsx(N,{title:"Other fields",fields:n.other}),i.jsx(N,{title:"Input bindings",fields:t})]})}function St({sources:e}){return e.length?i.jsxs("div",{style:a.recipeGroup,children:[i.jsxs("div",{style:a.recipeGroupHeader,children:[i.jsx("span",{style:a.recipeGroupTitle,children:"From"}),i.jsx("span",{style:a.recipeGroupCount,children:e.length})]}),i.jsx("div",{style:a.sourcePillRow,children:e.map((r,t)=>i.jsx(wt,{source:r},`${M(r)}:${t}`))})]}):null}function wt({source:e}){const r=M(e);return i.jsxs("span",{style:a.sourcePill,title:r,children:[i.jsx("span",{style:a.sourcePillLabel,children:r}),i.jsx("span",{style:a.sourcePillRole,children:e.kind})]})}function It({trace:e}){return i.jsxs("div",{style:a.traceLineage,children:[i.jsx(jt,{sources:e.sourceRefs}),i.jsx(N,{title:"All field refs",fields:e.fieldRefs,emptyText:"No field refs captured"})]})}function qt({hints:e}){return i.jsx("div",{style:a.recipeFieldList,children:e.map((r,t)=>{const n=Vt(r),s=r.component||r.exportName||n||"Source hint",o=[r.exportName&&r.exportName!==s?r.exportName:void 0,n,r.note].filter(Boolean).join(" · ");return i.jsxs("div",{style:a.recipeFieldRow,title:o||s,children:[i.jsx("span",{style:a.recipeFieldName,children:s}),o?i.jsx("span",{style:a.recipeFieldMeta,children:o}):null]},`${s}:${n}:${t}`)})})}function jt({sources:e}){return i.jsxs("div",{style:a.recipeGroup,children:[i.jsxs("div",{style:a.recipeGroupHeader,children:[i.jsx("span",{style:a.recipeGroupTitle,children:"Sources"}),i.jsx("span",{style:a.recipeGroupCount,children:e.length})]}),e.length?i.jsx("div",{style:a.recipeFieldList,children:e.map((r,t)=>i.jsxs("div",{style:a.recipeFieldRow,title:M(r),children:[i.jsx("span",{style:a.recipeFieldName,children:M(r)}),i.jsx("span",{style:a.recipeFieldMeta,children:r.kind})]},`${M(r)}:${t}`))}):i.jsx("div",{style:a.recipeEmptyText,children:"No sources captured"})]})}function N({title:e,fields:r,emptyText:t}){return!r.length&&!t?null:i.jsxs("div",{style:a.recipeGroup,children:[i.jsxs("div",{style:a.recipeGroupHeader,children:[i.jsx("span",{style:a.recipeGroupTitle,children:e}),i.jsx("span",{style:a.recipeGroupCount,children:r.length})]}),r.length?i.jsx("div",{style:a.fieldChipList,children:r.map((n,s)=>i.jsx(Ct,{field:n,groupTitle:e},`${ze(n)}:${s}`))}):i.jsx("div",{style:a.recipeEmptyText,children:t})]})}function Ct({field:e,groupTitle:r}){const t=Ft(e),n=e.label||e.name,s=e.dataType&&e.dataType!=="unknown"?e.dataType:void 0,o=e.source?M(e.source):void 0,u=[t,s,o].filter(Boolean).join(" · "),p=At(e,r);return i.jsxs("div",{className:`${T}-field-row`,style:a.fieldChip,title:u,children:[i.jsx("span",{style:{...a.fieldGlyph,...p.style},children:p.text}),e.aggregate?i.jsx("span",{style:a.fieldAggBadge,children:e.aggregate}):null,i.jsx("span",{style:a.fieldChipName,children:n}),s?i.jsx("span",{style:a.fieldChipMeta,children:s}):null,s&&o?i.jsx("span",{style:a.fieldChipMetaDot,children:"·"}):null,o?i.jsx("span",{style:a.fieldChipMeta,children:o}):null]})}function At(e,r){const t=e.dataType,n=e.role;return!!e.aggregate||n==="measure"||r==="Measures"?{text:"Σ",style:{borderColor:"var(--sd-tone-metric-border)",background:"var(--sd-tone-metric-bg)",color:"var(--sd-tone-metric-fg)"}}:t==="date"||t==="datetime"||n==="date"||r==="Time fields"?{text:"◷",style:{borderColor:"var(--sd-tone-date-border)",background:"var(--sd-tone-date-bg)",color:"var(--sd-tone-date-fg)"}}:t==="number"?{text:"#",style:{borderColor:"var(--sd-tone-records-border)",background:"var(--sd-tone-records-bg)",color:"var(--sd-tone-records-fg)"}}:t==="boolean"?{text:"◐",style:{borderColor:"var(--sd-border)",background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)"}}:{text:"A",style:{borderColor:"var(--sd-tone-string-border)",background:"var(--sd-tone-string-bg)",color:"var(--sd-tone-string-fg)"}}}function kt({inputs:e}){return i.jsxs("div",{style:a.inputsAppliedBlock,children:[i.jsxs("div",{style:a.inputsAppliedHeader,children:[i.jsx("span",{style:a.inputsAppliedTitle,children:"Active Inputs"}),i.jsx("span",{style:a.inputsAppliedCount,children:e.length})]}),i.jsx("div",{style:a.inputRecipeList,children:e.map(r=>{const t=Ht(r);return i.jsxs("div",{style:a.inputRecipeRow,title:t.title,children:[i.jsxs("div",{style:a.inputRecipeHeader,children:[i.jsx("span",{style:a.inputRecipeLabel,title:t.title,children:t.label}),t.showId?i.jsx("span",{style:a.inputRecipeId,title:r.inputId,children:r.inputId}):null,t.operator?i.jsx("span",{style:a.inputOperatorBadge,children:t.operator}):null,i.jsx("span",{style:a.inputValuePreview,title:t.value,children:t.value})]}),t.binding?i.jsx("div",{style:a.inputRecipeBinding,title:t.binding,children:t.binding}):null]},r.inputId)})})]})}function Tt({preview:e}){return i.jsxs("div",{style:a.resultPreview,children:[i.jsxs("div",{style:a.resultPreviewHeader,children:[i.jsx("span",{style:a.resultPreviewTitle,children:e.title}),i.jsx("span",{style:a.resultPreviewSummary,children:e.summary})]}),i.jsx("div",{style:a.resultPreviewScroller,children:i.jsxs("table",{style:a.resultPreviewTable,children:[i.jsx("thead",{children:i.jsx("tr",{children:e.columns.map(r=>i.jsx("th",{style:a.resultPreviewTh,children:r.label},r.key))})}),i.jsx("tbody",{children:e.rows.length?e.rows.map((r,t)=>i.jsx("tr",{children:e.columns.map(n=>i.jsx("td",{style:a.resultPreviewTd,children:Nr(r[n.key])},n.key))},t)):i.jsx("tr",{children:i.jsx("td",{colSpan:e.columns.length,style:a.resultPreviewEmptyCell,children:"No rows returned"})})})]})}),e.truncatedRows||e.truncatedColumns?i.jsxs("div",{style:a.resultPreviewFootnote,children:["Showing first ",ie," rows and first"," ",Re," columns."]}):null]})}function Et({compiledQuery:e,compiledSql:r}){return(e==null?void 0:e.kind)==="sql"?i.jsxs("div",{style:a.compiledQuery,children:[i.jsx(tr,{label:"SQL",value:e.sql}),e.pythonCode?i.jsx(qe,{label:"Python",value:e.pythonCode}):null,e.parameters?i.jsx(qe,{label:"Parameters",value:De(e.parameters)}):null]}):r?i.jsx(tr,{label:"SQL",value:r}):i.jsx(qe,{label:"Compiled Query",value:De(e)})}function qe({label:e,value:r}){return i.jsxs("div",{style:a.codeBlockGroup,children:[i.jsx("div",{style:a.codeBlockLabel,children:e}),i.jsx("pre",{style:a.codeBlock,children:r})]})}function tr({label:e,value:r}){return i.jsxs("div",{style:a.codeBlockGroup,children:[i.jsx("div",{style:a.codeBlockLabel,children:e}),i.jsx("pre",{style:a.codeBlock,children:Lt(r)})]})}const Rt=new Set(["SELECT","FROM","JOIN","LEFT","RIGHT","INNER","OUTER","CROSS","ON","USING","WHERE","AND","OR","GROUP","BY","HAVING","ORDER","ASC","DESC","LIMIT","OFFSET","AS","BETWEEN","IN","NOT","NULL","IS","CASE","WHEN","THEN","ELSE","END","DISTINCT","UNION","ALL","WITH"]);function Lt(e){return e.split(/(\s+|,|\(|\))/).map((t,n)=>{if(!t)return null;const s=t.toUpperCase();return Rt.has(s)?i.jsx("span",{style:a.sqlKeyword,children:t},n):t.startsWith("$")||t.startsWith(":")||t.startsWith("?")?i.jsx("span",{style:a.sqlBindParam,children:t},n):i.jsx("span",{children:t},n)})}function Dt(e){return[`${e.total} ${e.total===1?"trace":"traces"}`,`${e.loading} loading`,`${e.failed} failed`,`${e.errorCount} error${e.errorCount===1?"":"s"}`,`${e.warningCount} warning${e.warningCount===1?"":"s"}`].join(" · ")}function $t(e,r){const t=r.trim().toLowerCase();return t?e.filter(n=>[n.queryId,n.queryLabel,n.viewId,n.viewTitle,n.visualType,n.sectionTitle,n.builder,n.queryKind,Sr(n)].filter(Boolean).join(" ").toLowerCase().includes(t)):e}function Ot(e){const r=e.filter(s=>s.queryKind==="inputOptions"),t=new Set(r.map(Le));return[{title:"Views",traces:e.filter(s=>!t.has(Le(s)))},{title:"Inputs",traces:r}]}function hr(e,r){if(!(!(r!=null&&r.traceId)&&!(r!=null&&r.queryId)&&!(r!=null&&r.viewId)))return r.traceId?e.find(t=>t.traceId===r.traceId):e.find(t=>!(r.queryId&&t.queryId!==r.queryId||r.viewId&&t.viewId!==r.viewId))}function Bt(e,r){if(r.queryId)return hr(e,r);if(!r.viewId)return;const t=e.filter(n=>n.viewId===r.viewId);return t.length===1?t[0]:void 0}function Kt(e,r){return!!(e&&r&&e.traceId===r.traceId)}function Le(e){return e.traceId}function Mt(e){switch(e){case"metric":return"metric";case"records":return"records";case"matrix":return"matrix";case"analysis":return"analysis";case"inputOptions":return"inputs";case"sql":return"sql";default:return he(e)}}function br(e){const r=e.trim().toLowerCase();return r==="metric"||r==="kpi"?"metric":r==="records"||r==="table"?"records":r==="matrix"||r==="pivot"?"matrix":r==="analysis"?"analysis":r==="inputs"||r==="input options"?"inputs":r==="sql"?"sql":"default"}function vr(e){switch(e){case"metric":return{borderColor:"var(--sd-tone-metric-border)",background:"var(--sd-tone-metric-bg)",color:"var(--sd-tone-metric-fg)"};case"records":return{borderColor:"var(--sd-tone-records-border)",background:"var(--sd-tone-records-bg)",color:"var(--sd-tone-records-fg)"};case"analysis":case"matrix":return{borderColor:"var(--sd-tone-analysis-border)",background:"var(--sd-tone-analysis-bg)",color:"var(--sd-tone-analysis-fg)"};case"inputs":case"sql":case"default":default:return{borderColor:"var(--sd-border)",background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)"}}}function Wt(e,r,t){const n=[];return e.queryLabel&&e.queryLabel!==r&&n.push(e.queryLabel),e.queryId&&e.queryId!==r&&e.queryId!==e.queryLabel?n.push(e.queryId):e.viewId&&e.viewId!==r&&e.viewId!==e.queryLabel&&n.push(e.viewId),n.push(t),n}function xr(e){return Nt(e.visualType)||Mt(e.queryKind)}function _t(e,r){return r?e.queryLabel||e.queryId:ye(e)}function Nt(e){if(e)return e.replace(/[_-]+/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function Sr(e){const r=e.sourceRefs.map(M);return r.length?r.length===1?r[0]:`${r[0]} + ${r.length-1} more`:"No source"}function Pt(e){return e.reduce((r,t)=>(t.role==="measure"?r.measures.push(t):t.role==="date"?r.timeFields.push(t):t.role==="dimension"?r.dimensions.push(t):t.role==="id"?r.identifiers.push(t):r.other.push(t),r),{measures:[],timeFields:[],dimensions:[],identifiers:[],other:[]})}function zt(e){var r,t;if(e.queryKind==="records"&&((r=e.projectionFieldRefs)!=null&&r.length)&&e.projectionFieldRefs.every(n=>n.role==="measure")&&((t=e.latestAttempt)==null?void 0:t.rowCount)===1)return"KPI query";switch(e.queryKind){case"metric":return"KPI query";case"records":return"Records query";case"matrix":return"Matrix query";case"analysis":return"Analysis query";case"inputOptions":return"Input options query";case"sql":return"SQL query";default:return he(e.queryKind)}}function Ft(e){return[e.aggregate,e.label||e.name].filter(Boolean).join(" ")}function Ht(e){var p,d,f;const r=e.valuePreview||"redacted",t=e.inputLabel||e.inputId,n=((p=e.fieldRef)==null?void 0:p.label)||((d=e.fieldRef)==null?void 0:d.name),s=(f=e.fieldRef)!=null&&f.source?M(e.fieldRef.source):void 0,o=[n?`on ${n}`:void 0,s].filter(Boolean).join(" · "),u=[t,e.inputId,e.operator,r,o].filter(Boolean).join(" - ");return{label:t,showId:t!==e.inputId,operator:e.operator,value:r,binding:o,title:u}}function M(e){return e.kind==="semantic"?e.datasetName||e.datasetId||e.domainId:e.kind==="physical"?[e.schemaName,e.tableName].filter(Boolean).join(".")||e.tableName:e.connectionId?`SQL ${e.connectionId}`:"SQL source"}function Vt(e){if(e.file)return e.line&&e.column?`${e.file}:${e.line}:${e.column}`:e.line?`${e.file}:${e.line}`:e.file}function Qt(e){return typeof e=="number"?e.toLocaleString():"-"}function Ut(e){return typeof e=="number"?`${Math.round(e)}ms`:"-"}function Gt(e){return De(e)}function De(e){return JSON.stringify(e,null,2)??"undefined"}function Jt(e){switch(e.type){case"query_started":return"Started";case"query_succeeded":return"Succeeded";case"query_failed":return"Failed";case"query_ignored_stale":return"Ignored stale";case"input_changed":return"Input changed";default:return Xt(e)}}function Yt(e){return[e.at,"durationMs"in e&&typeof e.durationMs=="number"?`${Math.round(e.durationMs)}ms`:void 0,"rowCount"in e&&typeof e.rowCount=="number"?`${e.rowCount} rows`:void 0,"reason"in e?e.reason:void 0,"errorMessage"in e?e.errorMessage:void 0].filter(Boolean).join(" - ")}function Xt(e){throw new Error(`Unsupported Semaphor trace event: ${JSON.stringify(e)}`)}function Zt(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function je(e){return Array.isArray(e)?e.map(r=>en(r)).filter(r=>!!r):[]}function en(e){var r;return(r=rn(e))==null?void 0:r.message}function rn(e){if(typeof e=="string")return{message:e};if(!e||typeof e!="object"||Array.isArray(e))return;const r=e,t=typeof r.message=="string"?r.message:"",n=typeof r.code=="string"?r.code:"",s=typeof r.path=="string"?r.path:"";return t&&n?{message:s?`${t} (${n}, ${s})`:`${t} (${n})`,code:n,...s?{path:s}:{}}:t?{message:t}:n?{message:n,code:n}:void 0}function tn(e){const r=e==null?void 0:e.metadata,t=r&&typeof r=="object"&&!Array.isArray(r)&&"dataAppDebug"in r&&r.dataAppDebug&&typeof r.dataAppDebug=="object"&&!Array.isArray(r.dataAppDebug)?r.dataAppDebug:void 0;return{compiledSql:typeof(t==null?void 0:t.compiledSql)=="string"?t.compiledSql:void 0,queryHash:typeof(t==null?void 0:t.queryHash)=="string"?t.queryHash:void 0}}function wr(e){return{...e,order:[],entries:{},sequence:0}}function nn(e,r){if(r.type==="config")return r.config.enabled?{...e,...r.config}:wr(r.config);if(!e.enabled)return e;switch(r.type){case"register":return ln(sn(e,r.descriptor));case"unregister":return on(e,r.traceKey);case"event":return an(e,r);default:return e}}function sn(e,r){const t=e.entries[r.traceKey],n=t?e.sequence:e.sequence+1,s=Fe(),o={...t||dn(r),...Ir(r),traceKey:r.traceKey,latestAttempt:(t==null?void 0:t.latestAttempt)||{status:"idle"},recentEvents:(t==null?void 0:t.recentEvents)||[],mounted:!0,registeredAt:(t==null?void 0:t.registeredAt)||n,lastEventAt:(t==null?void 0:t.lastEventAt)||s};return{...e,sequence:n,order:t?e.order:[...e.order,r.traceKey],entries:{...e.entries,[r.traceKey]:o}}}function on(e,r){const t=e.entries[r];return t?{...e,entries:{...e.entries,[r]:{...t,mounted:!1}}}:e}function an(e,r){const t=e.entries[r.traceKey];if(!t)return e;const n=Fe(),s=[...t.recentEvents,r.event].slice(-e.maxEventsPerQuery);return{...e,entries:{...e.entries,[r.traceKey]:{...t,latestAttempt:r.latestAttempt?{...t.latestAttempt,...r.latestAttempt}:t.latestAttempt,recentEvents:s,lastEventAt:n}}}}function ln(e){if(e.order.length<=e.maxQueries)return e;const r=e.order.map(s=>e.entries[s]).filter(s=>!!s).sort((s,o)=>s.mounted!==o.mounted?s.mounted?1:-1:s.lastEventAt-o.lastEventAt),t=e.order.length-e.maxQueries,n=new Set(r.slice(0,t).map(s=>s.traceKey));return n.size?{...e,order:e.order.filter(s=>!n.has(s)),entries:Object.fromEntries(Object.entries(e.entries).filter(([s])=>!n.has(s)))}:e}function dn(e){const r=Fe();return{...Ir(e),traceKey:e.traceKey,latestAttempt:{status:"idle"},recentEvents:[],mounted:!0,registeredAt:0,lastEventAt:r}}function Ir(e){var n;const r=bn(e.spec),t=vn(e.spec,e.activeInputs);return{traceId:jr(e.traceKey),viewId:e.viewId,viewTitle:e.viewTitle,visualType:e.visualType,sectionTitle:e.sectionTitle,queryId:e.queryId,queryLabel:e.queryLabel,queryKind:e.queryKind,builder:e.builder,sourceRefs:hn(e.intent),sourceHints:(n=e.sourceHints)!=null&&n.length?e.sourceHints:void 0,projectionFieldRefs:r,inputFieldRefs:t,fieldRefs:xn(e.intent),inputsApplied:(e.activeInputs||[]).map(s=>({inputId:s.inputId,inputLabel:s.label,fieldRef:s.field,operator:s.operator,valuePreview:mn(s)})),recentEvents:[],clientWarnings:e.clientWarnings}}function pe(e){const{traceKey:r,mounted:t,registeredAt:n,lastEventAt:s,...o}=e;return o}function ne(e){if(!e.enabled)return gr;const r=e.order.map(n=>e.entries[n]).filter(n=>!!n).map(pe),t=Me(r).map(Hr);return{enabled:!0,queries:r,issues:t,getQuery:n=>{const s=Object.values(e.entries).find(o=>o.queryId===n);return s?pe(s):void 0},getQueries:n=>Object.values(e.entries).filter(s=>s.queryId===n).map(pe)}}function un(e){return{snapshot:()=>Jr(ne(e())),getQuery:r=>Ze(ne(e()).getQuery(r)),getQueries:r=>ne(e()).getQueries(r).map(t=>Ze(t)).filter(t=>!!t),getIssues:()=>ne(e()).issues}}function cn(e){return e===void 0||e===!1?{enabled:!1,exposeWindowBridge:!1,maxEventsPerQuery:we,maxQueries:Ie}:e===!0?{enabled:!0,exposeWindowBridge:!1,maxEventsPerQuery:we,maxQueries:Ie}:{enabled:e.enabled!==!1,exposeWindowBridge:e.exposeWindowBridge===!0,maxEventsPerQuery:sr(e.maxEventsPerQuery,we,ot),maxQueries:sr(e.maxQueries,Ie,at)}}function fn(e){const t=[e==null?void 0:e.sourceHint,...(e==null?void 0:e.sourceHints)||[]].filter(n=>!!n).map(n=>({file:ce(n.file),line:nr(n.line),column:nr(n.column),exportName:ce(n.exportName),component:ce(n.component),note:ce(n.note)})).filter(n=>!!(n.file||n.line||n.column||n.exportName||n.component||n.note));return t.length?t:void 0}function ce(e){if(typeof e!="string")return;const r=e.trim();return r||void 0}function nr(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0}function sr(e,r,t){return e===void 0||!Number.isFinite(e)||!Number.isInteger(e)||e<=0?r:Math.min(e,t)}function pn(e){return typeof e.id=="string"&&e.id.trim()?e.id:void 0}function gn(e){switch(e){case"metric":return"semaphor.metric";case"records":return"semaphor.records";case"matrix":return"semaphor.matrix";case"analysis":return"semaphor.analysis";case"inputOptions":return"semaphor.inputOptions";case"sql":return"semaphor.sql";default:return he(e)}}function he(e){throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`)}function mn(e){if(yn(e))return;const r=e.value;if(r!==void 0){if(Array.isArray(r)){const t=r.filter(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean").map(n=>String(n));if(t.length===r.length&&t.length>0){const n=t.slice(0,3).join(", "),s=t.length>3?`, +${t.length-3} more`:"";return ir(`${n}${s}`)}return`${r.length} selected`}return typeof r=="number"||typeof r=="boolean"?String(r):typeof r=="string"?ir(r):r&&typeof r=="object"?`object(${Object.keys(r).slice(0,5).join(",")})`:String(r)}}function ir(e){return e.length>80?`${e.slice(0,77)}...`:e}function yn(e){var t;const r=[e.inputId,e.label,(t=e.field)==null?void 0:t.name].filter(Boolean).join(" ").toLowerCase();return["token","secret","password","email","phone","ssn"].some(n=>r.includes(n))}function hn(e){const r=[];return me(e,t=>{Sn(t)&&r.push(t)}),Be.mergeSemaphorSourcesByIdentity(r)}function bn(e){switch(e.queryKind){case"metric":case"analysis":return V([...e.measures||[],e.primaryMeasure,e.dateField,...e.dimensions||[]]);case"records":return V(e.fields||[]);case"inputOptions":return V([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]);case"sql":return V(e.fields||[]);case"matrix":return V([...(e.rows||[]).map(Ce),...(e.columns||[]).map(Ce),...(e.values||[]).map(Ce)]);default:return he(e)}}function vn(e,r){const t=[...(e.inputs||[]).map(qr),...(r||[]).map(n=>n.field)];return V(t)}function V(e){const r=new Map;return e.forEach(t=>{t&&oe(t)&&r.set(ze(t),t)}),[...r.values()]}function qr(e){if(!e||typeof e!="object")return;const r=e.toAnalyticsInput;if(typeof r=="function"){const n=r.call(e);return qr(n)}const t=e.field;return oe(t)?t:void 0}function Ce(e){if(oe(e))return e;if(!e||typeof e!="object")return;const r=e.field;return oe(r)?r:void 0}function xn(e){const r=new Map;return me(e,t=>{oe(t)&&r.set(ze(t),t)}),[...r.values()]}function me(e,r){if(!(!e||typeof e!="object")){if(r(e),Array.isArray(e)){e.forEach(t=>me(t,r));return}Object.values(e).forEach(t=>me(t,r))}}function Sn(e){if(!e||typeof e!="object")return!1;const r=e;return r.kind==="semantic"?typeof r.domainId=="string"&&typeof r.datasetName=="string":r.kind==="physical"?typeof r.connectionId=="string"&&typeof r.tableName=="string":r.kind==="sql"?typeof r.connectionId=="string":!1}function oe(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.name=="string"&&(r.source!==void 0||r.role!==void 0||r.dataType!==void 0||r.aggregate!==void 0)}function ze(e){return[e.name,e.role,e.aggregate,e.source?Be.semaphorSourceIdentityKey(e.source):""].join(":")}function wn(e){const r=e;return typeof(r==null?void 0:r.rowCount)=="number"?r.rowCount:Array.isArray(r==null?void 0:r.records)?r.records.length:void 0}function In(e){const r=e;return Array.isArray(r==null?void 0:r.columns)?r.columns.length:void 0}function or(e){const r=e;return r==null?void 0:r.executionResult}function qn(e){const r=e,t=[...r!=null&&r.measures?Object.keys(r.measures):[],...r!=null&&r.measureBindings?Object.keys(r.measureBindings):[]].filter(Boolean).sort(),n=Array.isArray(r==null?void 0:r.missingMeasures)?r.missingMeasures.filter(s=>typeof s=="string"&&!!s):[];if(!(t.length===0&&n.length===0))return{...t.length>0?{populatedMetricKeys:t}:{},...n.length>0?{missingMeasures:n}:{}}}function ar(e){const r=e;return typeof(r==null?void 0:r.requestId)=="string"?r.requestId:void 0}function jr(e){let r=2166136261;for(let t=0;t<e.length;t+=1)r^=e.charCodeAt(t),r=Math.imul(r,16777619);return(r>>>0).toString(36)}function fe(){return new Date().toISOString()}function Fe(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const jn=["primary","comparisons","contributors","segments","periodChanges","records","changes","drivers","absoluteDeltaDrivers","largestNegativeChanges","largestPositiveChanges","largestNegativeDrivers","largestPositiveDrivers"],Cn=["primary","records","periodChanges","changes","comparisons","contributors","segments","drivers","absoluteDeltaDrivers","largestNegativeChanges","largestPositiveChanges","largestNegativeDrivers","largestPositiveDrivers"];function Cr(e){if(!e)return{};const r=Ln(e.executionResult),t=An(e,r),n=En(t),s=Ar(Ve(e.analysisWarnings),On(t));return{...e,...Object.keys(t).length?{resultSets:t}:{},...s.length?{analysisWarnings:s}:{},...n?{columns:n.columns,records:n.records,rowCount:n.rowCount}:{}}}function An(e,r){const t=kn(e.resultSets);for(const s of jn){if(t[s])continue;const o=Dn(e[s]);if(!o.length)continue;const u=r.length?r:$n(o);t[s]={id:s,role:s,...He({records:o,columns:u,resultSetKey:s}),columns:u,rowCount:o.length}}const n=Rn(e.executionResult);return n&&n.records.length>0&&!t.records&&(t.records=n),t}function kn(e){return Object.fromEntries(Object.entries(e||{}).map(([r,t])=>[r,Tn(t,r)]))}function Tn(e,r=e.id||e.role||"resultSet"){var n;const t=He({records:e.records||[],columns:e.columns||[],resultSetKey:r});return{...e,...t,...e.warnings||t.warnings?{warnings:Ar(Ve(e.warnings),t.warnings)}:{},rowCount:e.rowCount??((n=e.records)==null?void 0:n.length)??0}}function En(e){var r;for(const t of Cn)if((r=e[t])!=null&&r.records.length)return e[t];return Object.values(e).find(t=>t.records.length)||Object.values(e)[0]}function Rn(e){const r=e==null?void 0:e.result;if(!(!r||r.kind!=="records"&&r.kind!=="sql"))return{id:"records",role:"records",...He({records:r.records,columns:r.columns,resultSetKey:"records"}),columns:r.columns,rowCount:r.rowCount??r.records.length}}function Ln(e){const r=e==null?void 0:e.result;return!r||r.kind!=="records"&&r.kind!=="sql"?[]:r.columns}function Dn(e){return Array.isArray(e)?e.filter(r=>!!(r&&typeof r=="object"&&!Array.isArray(r))):[]}function He({records:e,columns:r,resultSetKey:t}){if(!r.length)return{records:e};const n=[];return{records:e.map((o,u)=>{const p={};return r.forEach(d=>{if(Object.prototype.hasOwnProperty.call(o,d.key)){p[d.key]=o[d.key];return}n.push({code:"missing_analysis_result_key",severity:"warning",resultSetKey:t,rowIndex:u,columnKey:d.key,...d.name?{columnName:d.name}:{},...d.label?{columnLabel:d.label}:{},availableKeys:Object.keys(o),message:`Analysis result set "${t}" row ${u} is missing column key "${d.key}". Rows must expose values by column.key; labels and column names are display metadata only.`})}),p}),...n.length?{warnings:n}:{}}}function $n(e){return Array.from(new Set(e.flatMap(t=>Object.keys(t)))).map(t=>({key:t,name:t,label:t}))}function On(e){return Object.values(e).flatMap(r=>Ve(r.warnings))}function Ve(e){return Array.isArray(e)?e.filter(Bn):[]}function Bn(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ar(...e){const r=new Set,t=[];for(const n of e.flatMap(s=>s||[])){const s=Kn(n);r.has(s)||(r.add(s),t.push(n))}return t}function Kn(e){return e.code==="missing_analysis_result_key"?[e.code,e.resultSetKey,e.rowIndex,e.columnKey].join(":"):$e(e)}function $e(e){if(!e||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t=>$e(t)).join(",")}]`;const r=e;return`{${Object.keys(r).sort().map(t=>`${JSON.stringify(t)}:${$e(r[t])}`).join(",")}}`}const Ae={value:null,primaryValue:null},ke={},Mn={records:[]},Te={options:[]},Wn={records:[]},Ee={};function _n(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs),t=w.toSemaphorAnalysisQueryOptions(e);try{const n=w.toSemaphorAnalysisIntent(e),s=U(n,"analysis");return s?{error:s,activeInputs:r,analysisOptions:t,queryKey:q(void 0,r,s,t),idleData:ke}:{intent:n,error:null,activeInputs:r,analysisOptions:t,queryKey:q(n,r,void 0,t),idleData:ke}}catch(n){const s=Q(n,"analysis");return{error:s,activeInputs:r,analysisOptions:t,queryKey:q(void 0,r,s,t),idleData:ke}}}function Nn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs);try{const t=w.toSemaphorMetricIntent(e),n=U(t);return n?{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Ae}:{intent:t,error:null,activeInputs:r,queryKey:q(t,r),idleData:Ae}}catch(t){const n=Q(t,"metric");return{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Ae}}}function Pn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs),t=Mn;try{const n=w.toSemaphorRecordsIntent(e),s=U(n);return s?{error:s,activeInputs:r,queryKey:q(void 0,r,s),idleData:t}:{intent:n,error:null,activeInputs:r,queryKey:q(n,r),idleData:t}}catch(n){const s=Q(n,"records");return{error:s,activeInputs:r,queryKey:q(void 0,r,s),idleData:t}}}function zn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs);try{const t=w.toSemaphorInputOptionsIntent(e),n=U(t);return n?{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Te}:{intent:t,error:null,activeInputs:r,queryKey:q(t,r),idleData:Te}}catch(t){const n=Q(t,"inputOptions");return{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Te}}}function Fn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs),t=Wn;try{const n=w.toSemaphorSqlIntent(e),s=U(n);return s?{error:s,activeInputs:r,queryKey:q(void 0,r,s),idleData:t}:{intent:n,error:null,activeInputs:r,queryKey:q(n,r),idleData:t}}catch(n){const s=Q(n,"sql");return{error:s,activeInputs:r,queryKey:q(void 0,r,s),idleData:t}}}function Hn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs);try{const t=w.toSemaphorMatrixIntent(e),n=U(t);return n?{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Ee}:{intent:t,error:null,activeInputs:r,queryKey:q(t,r),idleData:Ee}}catch(t){const n=Q(t,"matrix");return{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Ee}}}function Oe(e){var o;if(Vn(e))return e;const r=e instanceof Error?e:void 0,t=e,n=t==null?void 0:t.executionResult,s=be((r==null?void 0:r.message)??String(e),{requestId:typeof(t==null?void 0:t.requestId)=="string"?t.requestId:void 0,details:t==null?void 0:t.details,executionResult:n,validation:(t==null?void 0:t.validation)??(n==null?void 0:n.validation),validationIssues:(t==null?void 0:t.validationIssues)??((o=n==null?void 0:n.validation)==null?void 0:o.errors)});return s.name=(r==null?void 0:r.name)||s.name,s.stack=r==null?void 0:r.stack,s}function Q(e,r){const t=Oe(e);if(t.executionResult||t.validation)return t;const n={ok:!1,errors:[{code:"invalid_query_spec",message:t.message,path:"spec"}],warnings:[],repairHints:[{code:"invalid_query_spec",message:t.message,recommendedNextStep:"Update the Data App query spec to satisfy the SDK builder contract."}]},s=kr(void 0,r,n),o=be(t.message,{executionResult:s,validation:n,validationIssues:n.errors});return o.stack=t.stack,o}function be(e,r={}){var s,o,u;const t=new Error(e);t.name="SemaphorDataAppQueryError",t.kind="data_app_query_error",r.requestId&&(t.requestId=r.requestId),r.details!==void 0&&(t.details=r.details),r.executionResult!==void 0&&(t.executionResult=r.executionResult),r.validation!==void 0&&(t.validation=r.validation);const n=r.validationIssues??((s=r.validation)==null?void 0:s.errors)??((u=(o=r.executionResult)==null?void 0:o.validation)==null?void 0:u.errors);return n!==void 0&&(t.validationIssues=n),t}function Vn(e){return e instanceof Error&&e.kind==="data_app_query_error"}function U(e,r=e.kind){const t=$r.validateSemaphorAnalyticsIntent(e);if(t.ok)return null;const n=t.errors.map(o=>o.path?`${o.code} at ${o.path}: ${o.message}`:`${o.code}: ${o.message}`).join("; "),s=kr(e,r,t);return be(`Invalid Semaphor analytics intent. ${n}`,{executionResult:s,validation:t,validationIssues:t.errors})}function kr(e,r,t){return{...e!=null&&e.id?{intentId:e.id}:{},...e?{intent:e}:{},status:"failed",resultShape:r,validation:t,coverage:{answeredObligations:[],missingObligations:["query_spec_validation"],warnings:t.warnings},missingFields:t.errors.filter(n=>n.code==="missing_field").flatMap(n=>{var o;const s=n.path||((o=n.repairHint)==null?void 0:o.invalidField);return s?[s]:[]}),warnings:t.warnings.map(n=>n.message),diagnosticFeedback:{version:1,status:"blocked",summary:"Data App query spec validation failed.",answered:[],blocked:t.errors.map(n=>{var o,u;const s={reasonCode:"query_validation_failed",message:n.message};return n.code==="missing_field"&&(s.missingFields=[n.path||((o=n.repairHint)==null?void 0:o.invalidField)||n.message]),(u=n.repairHint)!=null&&u.recommendedNextStep&&(s.recommendedNextStep=n.repairHint.recommendedNextStep),s})},metadata:{validationKind:"data_app_sdk_query_spec"}}}function q(e,r,t,n){return JSON.stringify({intent:e,activeInputs:r,analysisOptions:n,error:t==null?void 0:t.message})}function Tr(){return{executeAnalysis:(e,r,t)=>F(e,r,t??{}).then(Cr),executeMetric:(e,r)=>F(e,r),executeRecords:(e,r)=>F(e,r),executeInputOptions:(e,r)=>F(e,r),executeSql:(e,r)=>F(e,r),executeMatrix:(e,r)=>F(e,r)}}async function F(e,r,t){if(!r.token)throw new Error("SemaphorDataAppProvider needs a token to execute queries.");const n=es(r),s=Gn(e,n);let o;try{o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.token}`},body:JSON.stringify({intent:e,activeInputs:r.activeInputs,...t?{analysisOptions:t}:{},resultShape:e.kind,...Un(r)?{debug:{responseDetail:"debug"}}:{}})})}catch(p){throw new Error(`${s}: ${p instanceof Error?p.message:String(p)}`)}const u=await Xn(o);if(!o.ok||u.error)throw Qn(`${s}: ${u.error||`Semaphor Data App execution failed with status ${o.status}.`}`,u);return u}function Qn(e,r){var t;return be(e,{requestId:r.requestId,details:r.details,executionResult:r.executionResult,validation:(t=r.executionResult)==null?void 0:t.validation})}function Un(e){const r=e.debug;return r?r===!0?!0:r.enabled!==!1&&r.requestServerDebug!==!1:!1}function Gn(e,r){return[`Semaphor ${e.kind} query`,e.id?`id=${e.id}`:void 0,e.label?`label=${e.label}`:void 0,Jn(e),`endpoint=${Yn(r)}`].filter(t=>!!t).join(" ")}function Jn(e){const r="source"in e?e.source:void 0;if(!(!r||typeof r!="object")){if(r.kind==="semantic")return`source=${[r.domainId,r.datasetId||r.datasetName].filter(Boolean).join("/")}`;if(r.kind==="physical")return`source=${[r.connectionId,r.databaseName,r.schemaName,r.tableName].filter(Boolean).join("/")}`;if(r.kind==="sql")return r.connectionId?`source=${r.connectionId}`:void 0}}function Yn(e){if(!e)return"/api/v1/data-app/execute";try{return new URL(e,"http://localhost").pathname}catch{return e}}async function Xn(e){const r=await e.text().catch(()=>"");if(!r.trim())return e.ok?{error:"Semaphor Data App execution returned an empty response."}:{};try{return JSON.parse(r)}catch{return e.ok?{error:"Semaphor Data App execution returned invalid JSON.",details:r}:{error:Zn(e,r),details:r}}}function Zn(e,r){const t=e.statusText?` ${e.statusText}`:"",n=r.replace(/\s+/g," ").trim();return n?`Semaphor Data App execution failed with status ${e.status}${t}: ${n.slice(0,240)}`:`Semaphor Data App execution failed with status ${e.status}${t}.`}function es(e){const r=rs(e).replace(/\/+$/,"");return r?r.endsWith("/api")?`${r}/v1/data-app/execute`:`${r}/api/v1/data-app/execute`:"/api/v1/data-app/execute"}function rs(e){if(e.apiBaseUrl)return e.apiBaseUrl;if(!e.token)return"";try{return Ke.jwtDecode(e.token).apiServiceUrl||""}catch{return""}}const Er=c.createContext({});function ts(){if(!(typeof window>"u"))return window.__SEMAPHOR_DATA_APP_RUNTIME__}function ns(){return c.useContext(Er)}function ss(e){const[r,t]=c.useState(e.defaultValue),n=Object.prototype.hasOwnProperty.call(e,"value"),s=n?e.value:r,o=c.useMemo(()=>w.normalizeSemaphorInputOptions(e.options),[e.options]),u=c.useCallback(d=>{var y;const f=d;(y=e.onValueChange)==null||y.call(e,f),n||t(f)},[n,e]),p=c.useCallback(()=>u(void 0),[u]);return c.useMemo(()=>{const d=w.toSemaphorInputSpec(e);return{id:e.id,kind:e.kind,label:e.label,field:d.field,operator:d.operator,relationshipHint:d.relationshipHint,controlRole:e.kind==="control"?e.role:void 0,value:s,options:o,isActive:w.hasSemaphorInputValue(s),setValue:u,clear:p,toAnalyticsInput:()=>({inputId:d.inputId,field:d.field,kind:e.kind,label:e.label,value:s,isActive:w.hasSemaphorInputValue(s),operator:d.operator,relationshipHint:d.relationshipHint,controlRole:e.kind==="control"?e.role:void 0})}},[p,o,u,e,s])}function is(e){const[r,t]=c.useState(()=>ps(e));return c.useEffect(()=>{t(n=>{let s=n;for(const o of e)!Object.prototype.hasOwnProperty.call(s,o.id)&&o.defaultValue!==void 0&&(s={...s,[o.id]:o.defaultValue});return s})},[e]),c.useMemo(()=>e.map(n=>{const s=Object.prototype.hasOwnProperty.call(n,"value"),o=s?n.value:r[n.id],u=w.normalizeSemaphorInputOptions(n.options),p=y=>{var m;(m=n.onValueChange)==null||m.call(n,y),s||t(v=>({...v,[n.id]:y}))},d=()=>p(void 0),f=w.toSemaphorInputSpec(n);return{id:n.id,kind:n.kind,label:n.label,field:f.field,operator:f.operator,relationshipHint:f.relationshipHint,controlRole:n.kind==="control"?n.role:void 0,value:o,options:u,isActive:w.hasSemaphorInputValue(o),setValue:p,clear:d,toAnalyticsInput:()=>({inputId:f.inputId,field:f.field,kind:n.kind,label:n.label,value:o,isActive:w.hasSemaphorInputValue(o),operator:f.operator,relationshipHint:f.relationshipHint,controlRole:n.kind==="control"?n.role:void 0})}}),[e,r])}function os(e,r){const t=(r==null?void 0:r.status)==="success"?r.options:void 0,n=c.useMemo(()=>as(t),[t]);c.useEffect(()=>{Rr(e.value,t)||e.clear()},[e,n,r==null?void 0:r.status,t])}function Rr(e,r){if(!w.hasSemaphorInputValue(e)||r===void 0)return!0;const t=new Set(r.map(s=>lr(s.value)));return(Array.isArray(e)?e:[e]).every(s=>t.has(lr(s)))}function as(e){return JSON.stringify((e||[]).map(r=>r.value))}function lr(e){return`${typeof e}:${String(e)}`}function ls(e,r={}){const t=c.useMemo(()=>r.inputs?{...e,inputs:r.inputs}:e,[r.inputs,e]),n=c.useMemo(()=>{switch(t.queryKind){case"metric":return{queryKind:t.queryKind,request:Nn(t)};case"analysis":return{queryKind:t.queryKind,request:_n(t)};case"records":return{queryKind:t.queryKind,request:Pn(t)};case"inputOptions":return{queryKind:t.queryKind,request:zn(t)};case"sql":return{queryKind:t.queryKind,request:Fn(t)};case"matrix":return{queryKind:t.queryKind,request:Hn(t)};default:return ge(t)}},[t]),s=pt({spec:t,queryKind:n.queryKind,queryKey:n.request.queryKey,intent:n.request.intent,activeInputs:n.request.activeInputs,debug:r.debug}),o=c.useRef(null),u=c.useMemo(()=>({start:s.start,success:s.success,failure:s.failure,ignored:s.ignored}),[s.failure,s.ignored,s.start,s.success]),p=c.useCallback(l=>{var D,C,B,R,x,S,E,I,L;const b=n.request;if(b.intent)switch(n.queryKind){case"metric":return(D=l.executor)==null?void 0:D.executeMetric(b.intent,l);case"analysis":return(B=(C=l.executor)==null?void 0:C.executeAnalysis)==null?void 0:B.call(C,b.intent,l,b.analysisOptions);case"records":return(R=l.executor)==null?void 0:R.executeRecords(b.intent,l);case"inputOptions":return(x=l.executor)==null?void 0:x.executeInputOptions(b.intent,l);case"sql":return(E=(S=l.executor)==null?void 0:S.executeSql)==null?void 0:E.call(S,b.intent,l);case"matrix":return(L=(I=l.executor)==null?void 0:I.executeMatrix)==null?void 0:L.call(I,b.intent,l);default:return ge(n)}},[n]),d=fs(n.request.queryKey,p,n.request.idleData,n.request.activeInputs,u),f=s.queryId,y=s.validationFailure;c.useEffect(()=>{const l=n.request.error;if(!l){o.current=null;return}const b=`${f}:${l.message}`;o.current!==b&&(o.current=b,y(l))},[n.request.error,n.request.queryKey,f,y]);const m=n.request.error?n.request.idleData:d.data,v=n.request.error?"error":d.status,g=!n.request.error&&d.status==="loading",h=n.request.error||d.error,j=s.trace;switch(n.queryKind){case"metric":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,value:(l==null?void 0:l.value)??null,primaryValue:(l==null?void 0:l.primaryValue)??null,measures:l==null?void 0:l.measures,measureBindings:l==null?void 0:l.measureBindings,missingMeasures:l==null?void 0:l.missingMeasures,comparisonValue:l==null?void 0:l.comparisonValue,comparisonKind:l==null?void 0:l.comparisonKind,delta:l==null?void 0:l.delta,deltaPercent:l==null?void 0:l.deltaPercent,records:l==null?void 0:l.records,...b}}case"analysis":{const l=Cr(m),b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,...l||{},...b}}case"records":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,records:(l==null?void 0:l.records)||[],columns:l==null?void 0:l.columns,rowCount:l==null?void 0:l.rowCount,pagination:l==null?void 0:l.pagination,totals:l==null?void 0:l.totals,...b}}case"inputOptions":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,options:(l==null?void 0:l.options)||[],...b}}case"sql":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,records:(l==null?void 0:l.records)||[],columns:l==null?void 0:l.columns,rowCount:l==null?void 0:l.rowCount,pagination:l==null?void 0:l.pagination,output:l==null?void 0:l.output,rowLimitExceeded:l==null?void 0:l.rowLimitExceeded,...b}}case"matrix":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,matrixResult:l==null?void 0:l.matrixResult,grid:l==null?void 0:l.grid,expansion:l==null?void 0:l.expansion,...b}}default:return ge(n)}}function H(e){var o,u,p;const r=ds(e.payload)??((o=e.error)==null?void 0:o.executionResult),t=((u=e.error)==null?void 0:u.validation)??(r==null?void 0:r.validation),n=r==null?void 0:r.coverage,s=r==null?void 0:r.diagnosticFeedback;return{status:e.status,executionStatus:r==null?void 0:r.status,executionResult:r,validation:t,coverage:n,diagnosticFeedback:s,isLoading:e.isLoading,isEmpty:cs(e.queryKind,e.payload,e.status),isPartial:us(e.payload,r),isFiltered:!!((p=e.activeInputs)!=null&&p.some(d=>d.kind==="filter"&&d.isActive)),isStale:e.isStale,isValidated:!!t,error:e.error,trace:e.trace}}function ds(e){const r=e;return r==null?void 0:r.executionResult}function us(e,r){var n,s;const t=!!(e!=null&&e.rowLimitExceeded);return!!((r==null?void 0:r.status)==="partial"||((n=r==null?void 0:r.diagnosticFeedback)==null?void 0:n.status)==="partial"||(r==null?void 0:r.status)!=="failed"&&((s=r==null?void 0:r.coverage)!=null&&s.missingObligations.length)||t)}function cs(e,r,t){var n,s,o,u,p;if(t!=="success")return!1;switch(e){case"metric":{const d=r;return(d==null?void 0:d.value)==null&&!O(d==null?void 0:d.records)}case"analysis":{const d=r;return d?!d.answerSummary&&!O(d.records)&&!O(d.changes)&&!O(d.drivers)&&!O(d.largestNegativeChanges)&&!O(d.largestPositiveChanges)&&!O(d.largestNegativeDrivers)&&!O(d.largestPositiveDrivers)&&!Object.values(d.resultSets||{}).some(f=>O(f.records)):!0}case"records":{const d=r;return!O(d==null?void 0:d.records)}case"sql":{const d=r;return!O(d==null?void 0:d.records)&&(d==null?void 0:d.output)===void 0}case"inputOptions":{const d=r;return!((n=d==null?void 0:d.options)!=null&&n.length)}case"matrix":{const d=r;return!((o=(s=d==null?void 0:d.matrixResult)==null?void 0:s.cells)!=null&&o.length)&&!((p=(u=d==null?void 0:d.grid)==null?void 0:u.cells)!=null&&p.length)}default:return ge(e)}}function O(e){return Array.isArray(e)&&e.length>0}function fs(e,r,t,n,s){const o=ns(),u=c.useRef(r),p=c.useRef(n),[d,f]=c.useState({status:"idle",data:t,error:null,isStale:!1});return u.current=r,p.current=n,c.useEffect(()=>{let y;try{y=u.current({...o,activeInputs:p.current})}catch(g){s==null||s.failure(g,0),f({status:"error",data:t,error:Oe(g),isStale:!1});return}if(!y){f({status:"idle",data:t,error:null,isStale:!1});return}let m=!1;const v=Lr();return s==null||s.start(),f(g=>({status:"loading",data:g.data,error:null,isStale:g.isStale||g.status==="success"})),y.then(g=>{m?s==null||s.ignored("superseded"):(s==null||s.success(g,dr(v)),f({status:"success",data:g,error:null,isStale:!1}))}).catch(g=>{m?s==null||s.ignored("superseded"):(s==null||s.failure(g,dr(v)),f({status:"error",data:t,error:Oe(g),isStale:!1}))}),()=>{m=!0}},[t,e,o,s]),d}function Lr(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function dr(e){return Math.max(0,Math.round(Lr()-e))}function ps(e){return Object.fromEntries(e.filter(r=>r.defaultValue!==void 0).map(r=>[r.id,r.defaultValue]))}function ge(e){throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`)}function gs(e){return!e||typeof e=="boolean"||e.enabled===!1?null:e.autoRenderDevtools===!0?{}:e.autoRenderDevtools?e.autoRenderDevtools:null}function ms({token:e,apiBaseUrl:r,executor:t,debug:n,children:s}){var g;const o=ts(),u=((g=o==null?void 0:o.authToken)==null?void 0:g.accessToken)||e,p=(o==null?void 0:o.dataApiBaseUrl)||(o==null?void 0:o.apiBaseUrl)||r,d=(o==null?void 0:o.debug)??n,f=gs(d),y=c.useMemo(()=>Tr(),[]),m=t||y,v=c.useMemo(()=>({token:u,apiBaseUrl:p,executor:m,debug:d}),[p,d,m,u]);return i.jsx(lt,{debug:d,children:i.jsxs(Er.Provider,{value:v,children:[s,f?i.jsx(yr,{...f}):null]})})}exports.semaphorMetricMeasureBindingKey=Be.semaphorMetricMeasureBindingKey;exports.SemaphorDataAppProvider=ms;exports.SemaphorDevtools=yr;exports.SemaphorDevtoolsInspectButton=ft;exports.SemaphorViewBoundary=ct;exports.createSemaphorQueryExecutor=Tr;exports.defineSemaphorDataApp=Or;exports.defineSemaphorInput=Br;exports.isSemaphorInputValueValidForOptions=Rr;exports.semaphor=Kr;exports.useClearInvalidSemaphorInputValue=os;exports.useSemaphorDevtools=Pe;exports.useSemaphorInput=ss;exports.useSemaphorInputs=is;exports.useSemaphorQuery=ls;
|
|
117
|
+
`;function pr(){if(typeof document>"u"||document.getElementById(er))return;const e=document.createElement("style");e.id=er,e.textContent=it,document.head.appendChild(e)}const ue='ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',$="ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",Se={color:"var(--sd-fg-muted)",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em"},a={launcher:{position:"fixed",bottom:20,zIndex:2147483e3,display:"inline-flex",alignItems:"center",gap:7,height:36,minWidth:36,padding:"0 10px",borderWidth:1,borderStyle:"solid",borderRadius:6,boxShadow:"var(--sd-shadow)",font:`600 12px/1.2 ${ue}`,cursor:"pointer"},launcherText:{fontVariantNumeric:"tabular-nums"},launcherIssueCount:{display:"grid",minWidth:18,height:18,padding:"0 6px",placeItems:"center",borderRadius:999,border:"1px solid currentColor",background:"var(--sd-bg)",color:"currentColor",fontSize:10,lineHeight:"18px",whiteSpace:"nowrap"},logoMark:{display:"grid",width:18,height:18,placeItems:"center",flex:"0 0 auto",borderRadius:4,background:"var(--sd-fg)",color:"var(--sd-bg)"},panel:{position:"fixed",top:16,right:16,bottom:16,zIndex:2147483001,width:"min(720px, calc(100vw - 32px))",display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid var(--sd-border)",borderRadius:6,background:"var(--sd-bg)",color:"var(--sd-fg)",boxShadow:"var(--sd-shadow)",font:`13px/1.4 ${ue}`},panelFullscreen:{top:0,right:0,bottom:0,left:0,width:"100vw",height:"100vh",borderRadius:0},panelHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,padding:"10px 12px",borderBottom:"1px solid var(--sd-border)"},panelTitleBlock:{minWidth:0},panelTitle:{fontSize:13,fontWeight:600},panelSubtitle:{marginTop:2,color:"var(--sd-fg-muted)",fontSize:11},panelActions:{display:"flex",alignItems:"center",gap:6},iconButton:{display:"grid",width:28,height:28,placeItems:"center",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:5,background:"var(--sd-bg)",color:"var(--sd-fg-muted)",cursor:"pointer"},searchBox:{display:"flex",alignItems:"center",gap:8,margin:10,height:28,padding:"0 8px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:5,color:"var(--sd-fg-muted)"},searchInput:{minWidth:0,flex:1,border:0,outline:0,background:"transparent",color:"var(--sd-fg)",font:`12px/1.4 ${ue}`},issueSummary:{margin:"0 10px 10px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-warning-border)",borderRadius:6,background:"var(--sd-warning-bg)",color:"var(--sd-warning-fg)",overflow:"hidden"},issueSummaryToggle:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,width:"100%",padding:"7px 9px 5px",border:0,background:"transparent",color:"inherit",cursor:"pointer",...Se},issueSummaryHeaderLabel:{display:"inline-flex",alignItems:"center",gap:4,minWidth:0},issueSummaryCount:{fontVariantNumeric:"tabular-nums"},issueSummaryCollapsed:{padding:"0 9px 8px 26px",color:"var(--sd-fg-muted)",fontSize:11},issueSummaryList:{display:"grid",gap:1,padding:"0 6px 6px"},issueSummaryItem:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr)",alignItems:"start",gap:8,width:"100%",padding:"7px 8px",border:0,borderRadius:5,background:"transparent",color:"inherit",textAlign:"left",cursor:"pointer"},issueSummaryBadge:{display:"inline-flex",alignItems:"center",height:17,padding:"0 5px",borderWidth:1,borderStyle:"solid",borderRadius:3,fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em"},issueSummaryBadgeError:{borderColor:"var(--sd-error-border)",background:"var(--sd-error-bg)",color:"var(--sd-error-fg)"},issueSummaryBadgeWarning:{borderColor:"var(--sd-warning-border)",background:"var(--sd-bg)",color:"var(--sd-warning-fg)"},issueSummaryText:{display:"grid",gap:2,minWidth:0},issueSummaryTitle:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,fontWeight:650},issueSummaryMessage:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-warning-fg)",fontSize:11},issueSummaryMore:{padding:"3px 8px 5px",color:"var(--sd-fg-muted)",fontSize:11},panelBody:{display:"grid",gridTemplateColumns:"minmax(210px, 280px) minmax(0, 1fr)",minHeight:0,flex:1,borderTop:"1px solid var(--sd-border-soft)"},queryList:{minHeight:0,overflowY:"auto",padding:8,borderRight:"1px solid var(--sd-border)",background:"var(--sd-bg-muted)"},queryGroup:{display:"grid",gap:3,marginBottom:8},queryGroupHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 6px 3px",...Se},queryGroupCount:{color:"var(--sd-fg-subtle)",fontVariantNumeric:"tabular-nums"},queryGroupEmpty:{padding:"7px 8px",color:"var(--sd-fg-subtle)",fontSize:11},queryListItem:{display:"grid",gap:3,width:"100%",padding:"7px 8px",borderWidth:1,borderStyle:"solid",borderColor:"transparent",borderRadius:5,background:"transparent",color:"var(--sd-fg)",textAlign:"left",cursor:"pointer"},queryListItemSelected:{borderColor:"var(--sd-border-strong)",background:"var(--sd-bg-raised)"},queryListItemHeader:{display:"flex",alignItems:"center",gap:7,minWidth:0},statusDot:{width:7,height:7,flex:"0 0 auto",borderRadius:999},queryListTitle:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,fontWeight:650,color:"var(--sd-fg)"},queryListKindChip:{flex:"0 0 auto",display:"inline-flex",alignItems:"center",height:15,padding:"0 5px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)",fontFamily:$,fontSize:9,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},queryListIssueBadge:{flex:"0 0 auto",display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:16,height:16,padding:"0 4px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-warning-border)",borderRadius:999,background:"var(--sd-warning-bg)",color:"var(--sd-warning-fg)",fontSize:10,fontWeight:700,fontVariantNumeric:"tabular-nums"},queryListSource:{minWidth:0,paddingLeft:14,color:"var(--sd-fg-muted)",fontSize:11,lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},queryListSubtitleSep:{color:"var(--sd-fg-subtle)"},detailsPane:{minHeight:0,overflowY:"auto",padding:16},detailsHeader:{display:"grid",gap:6,marginBottom:14},detailsHeaderTopRow:{display:"flex",alignItems:"center",gap:8,minWidth:0},detailsHeaderStatusDot:{width:8,height:8,flex:"0 0 auto",borderRadius:999},detailsTitle:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:14,fontWeight:700,color:"var(--sd-fg)"},detailsKindChip:{flex:"0 0 auto",padding:"2px 6px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)",fontFamily:$,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},metaStrip:{display:"flex",flexWrap:"wrap",alignItems:"center",columnGap:6,rowGap:2,paddingLeft:16,color:"var(--sd-fg-muted)",fontSize:11},metaStripItem:{color:"var(--sd-fg-muted)",fontVariantNumeric:"tabular-nums"},metaStripDot:{color:"var(--sd-fg-subtle)"},sourcePillRow:{display:"flex",flexWrap:"wrap",gap:6},sourcePill:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 7px",borderWidth:1,borderStyle:"solid",borderColor:"var(--sd-border)",borderRadius:5,background:"var(--sd-bg)",color:"var(--sd-fg)"},sourcePillLabel:{fontFamily:$,fontSize:11,color:"var(--sd-fg)"},sourcePillRole:{display:"inline-flex",alignItems:"center",height:14,padding:"0 4px",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg-subtle)",fontFamily:$,fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em"},fieldChipList:{display:"grid",gap:0,paddingTop:2},fieldChip:{display:"flex",alignItems:"center",gap:8,minWidth:0,padding:"5px 6px",margin:"0 -6px",borderRadius:4},fieldGlyph:{display:"inline-flex",flex:"0 0 auto",alignItems:"center",justifyContent:"center",width:18,height:18,borderWidth:1,borderStyle:"solid",borderRadius:4,fontFamily:$,fontSize:11,fontWeight:700,lineHeight:1},fieldAggBadge:{display:"inline-flex",alignItems:"center",height:16,padding:"0 5px",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg)",fontFamily:$,fontSize:10,fontWeight:600,letterSpacing:"0.04em"},fieldChipName:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,fontWeight:500},fieldChipMeta:{flex:"0 0 auto",fontFamily:$,fontSize:10,color:"var(--sd-fg-subtle)"},fieldChipMetaDot:{color:"var(--sd-fg-subtle)",fontSize:10},sqlKeyword:{color:"var(--sd-sql-keyword)",fontWeight:600},sqlBindParam:{color:"var(--sd-sql-bind)"},traceTabs:{marginTop:16},traceTabBar:{display:"flex",gap:2,borderBottom:"1px solid var(--sd-border)",overflowX:"auto",scrollbarWidth:"none"},traceTab:{flex:"0 0 auto",appearance:"none",border:"none",background:"transparent",cursor:"pointer",padding:"6px 9px",marginBottom:-1,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",borderBottom:"2px solid transparent",whiteSpace:"nowrap"},traceTabActive:{color:"var(--sd-fg)",borderBottom:"2px solid var(--sd-fg)"},traceTabPanel:{paddingTop:12},alertCard:{marginTop:12,padding:"8px 10px",borderWidth:1,borderStyle:"solid",borderRadius:5,fontSize:12,lineHeight:1.45},alertCardError:{borderColor:"var(--sd-error-border)",background:"var(--sd-error-bg)",color:"var(--sd-error-fg)"},alertCardWarning:{borderColor:"var(--sd-warning-border)",background:"var(--sd-warning-bg)",color:"var(--sd-warning-fg)"},alertCardTitle:{fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",fontSize:10,marginBottom:4},alertCardList:{margin:0,paddingLeft:16,display:"grid",gap:3},recipe:{display:"grid",gap:16},traceLineage:{display:"grid",gap:12},recipeGroup:{display:"grid",gap:4},recipeGroupHeader:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:2},recipeGroupTitle:{color:"var(--sd-fg-muted)",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em"},recipeGroupCount:{color:"var(--sd-fg-subtle)",fontSize:10,fontVariantNumeric:"tabular-nums"},recipeFieldList:{display:"grid"},recipeEmptyText:{padding:"5px 0",color:"var(--sd-fg-subtle)",fontSize:11},recipeFieldRow:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, auto)",alignItems:"center",gap:10,minHeight:26,padding:"4px 0",borderBottom:"1px solid var(--sd-border-soft)"},recipeFieldName:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,fontWeight:500},recipeFieldMeta:{minWidth:0,display:"inline-flex",alignItems:"baseline",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg-subtle)",fontSize:11,textAlign:"right"},inputsAppliedBlock:{marginTop:16,padding:"10px 12px",border:"1px solid var(--sd-border)",borderLeft:"2px solid var(--sd-fg-muted)",borderRadius:5,background:"var(--sd-bg-muted)"},inputsAppliedHeader:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,marginBottom:6},inputsAppliedTitle:{color:"var(--sd-fg)",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em"},inputsAppliedCount:{color:"var(--sd-fg-subtle)",fontSize:10,fontVariantNumeric:"tabular-nums"},inputRecipeList:{display:"grid"},inputRecipeRow:{display:"grid",gap:2,minWidth:0,padding:"6px 0",borderBottom:"1px solid var(--sd-border-soft)"},inputRecipeHeader:{display:"flex",alignItems:"center",gap:8,minWidth:0},inputRecipeLabel:{flex:"1 1 auto",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,fontWeight:600},inputRecipeId:{flex:"0 0 auto",maxWidth:"32%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg-subtle)",fontFamily:$,fontSize:10,fontWeight:600},inputOperatorBadge:{display:"inline-flex",flex:"0 0 auto",alignItems:"center",height:16,padding:"0 5px",borderRadius:3,background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)",fontFamily:$,fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em"},inputValuePreview:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg)",fontSize:12,textAlign:"right"},inputRecipeBinding:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg-muted)",fontSize:11},eventList:{display:"grid"},eventRow:{display:"grid",gridTemplateColumns:"96px minmax(0, 1fr)",gap:10,padding:"6px 0",borderBottom:"1px solid var(--sd-border-soft)"},eventType:{color:"var(--sd-fg)",fontWeight:600,fontSize:12},eventMeta:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--sd-fg-muted)",fontSize:11},mutedText:{color:"var(--sd-fg-muted)",fontSize:12},compiledQuery:{display:"grid",gap:10},resultPreview:{display:"grid",gap:8},resultPreviewHeader:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10},resultPreviewTitle:{color:"var(--sd-fg)",fontSize:12,fontWeight:650},resultPreviewSummary:{flex:"0 0 auto",color:"var(--sd-fg-subtle)",fontSize:11,fontVariantNumeric:"tabular-nums"},resultPreviewScroller:{maxHeight:260,overflow:"auto",border:"1px solid var(--sd-border)",borderRadius:5,background:"var(--sd-bg-muted)"},resultPreviewTable:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed",fontSize:11},resultPreviewTh:{position:"sticky",top:0,zIndex:1,padding:"6px 8px",borderBottom:"1px solid var(--sd-border)",background:"var(--sd-bg-raised)",color:"var(--sd-fg-muted)",fontSize:10,fontWeight:700,letterSpacing:"0.06em",textAlign:"left",textTransform:"uppercase"},resultPreviewTd:{minWidth:0,padding:"6px 8px",borderBottom:"1px solid var(--sd-border-soft)",color:"var(--sd-fg)",fontFamily:$,fontSize:11,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"top"},resultPreviewEmptyCell:{padding:"9px 10px",color:"var(--sd-fg-subtle)",fontSize:12,textAlign:"center"},resultPreviewFootnote:{color:"var(--sd-fg-subtle)",fontSize:11},codeBlockGroup:{display:"grid",gap:5},codeBlockLabel:{...Se},codeBlock:{maxHeight:260,margin:0,overflow:"auto",padding:"8px 10px",border:"1px solid var(--sd-border)",borderRadius:5,background:"var(--sd-bg-muted)",color:"var(--sd-fg)",fontFamily:$,fontSize:11,lineHeight:1.5,whiteSpace:"pre-wrap"},emptyState:{padding:10,color:"var(--sd-fg-muted)",textAlign:"center",fontSize:12},inspectButton:{display:"inline-flex",alignItems:"center",gap:5,height:24,maxWidth:"100%",padding:"0 7px",borderWidth:1,borderStyle:"solid",borderRadius:5,background:"var(--sd-bg)",font:`600 11px/1 ${ue}`,cursor:"pointer"},inspectButtonText:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},we=10,Ie=100,ot=25,at=500,gr={enabled:!1,queries:[],issues:[],getQuery:()=>{},getQueries:()=>[]},We=c.createContext(null),_e=c.createContext(null),Ne=c.createContext(void 0),P=[];function lt({debug:e,children:r}){const t=c.useMemo(()=>cn(e),[e]),[n,s]=c.useReducer(nn,t,wr),o=c.useRef(n),u=c.useId(),[p,d]=c.useState({open:!1});o.current=n,c.useEffect(()=>{s({type:"config",config:t})},[t]),c.useEffect(()=>{if(!n.enabled||!n.exposeWindowBridge||typeof window>"u")return;const h=un(()=>o.current);return dt({ownerId:u,bridge:h}),()=>{ut(u)}},[u,n.enabled,n.exposeWindowBridge]);const f=c.useMemo(()=>({state:n,dispatch:s}),[n]),y=c.useCallback(h=>{d({open:!0,focus:h})},[]),m=c.useCallback(()=>{d(h=>({...h,open:!1}))},[]),v=c.useCallback(h=>{d({open:!0,focus:h})},[]),g=c.useMemo(()=>({open:p.open,focus:p.focus,openDevtools:y,closeDevtools:m,focusTrace:v}),[m,v,y,p.focus,p.open]);return i.jsx(We.Provider,{value:f,children:i.jsx(_e.Provider,{value:g,children:r})})}function dt(e){const r=P.findIndex(t=>t.ownerId===e.ownerId);r>=0&&P.splice(r,1),P.push(e),mr()}function ut(e){const r=P.findIndex(t=>t.ownerId===e);r>=0&&P.splice(r,1),mr()}function mr(){if(typeof window>"u")return;const e=P[P.length-1];e?window.__SEMAPHOR_DEVTOOLS__=e.bridge:delete window.__SEMAPHOR_DEVTOOLS__}function ct({id:e,title:r,children:t}){const n=c.useMemo(()=>({id:e,title:r}),[e,r]);return i.jsx(Ne.Provider,{value:n,children:t})}function yr({buttonPosition:e="bottom-right",initialIsOpen:r=!1,panelPosition:t="right",className:n,style:s}={}){const o=Pe(),u=c.useContext(_e),[p,d]=c.useState(""),[f,y]=c.useState(!1),m=c.useRef(null),v=c.useRef(null),g=u==null?void 0:u.openDevtools,h=u==null?void 0:u.closeDevtools,j=(u==null?void 0:u.open)===!0;c.useEffect(()=>{pr()},[]),c.useEffect(()=>{r&&o.enabled&&(g==null||g())},[r,o.enabled,g]),c.useEffect(()=>{if(!j||!h)return;const x=S=>{var I,L;const E=S.target;E instanceof Node&&((I=m.current)!=null&&I.contains(E)||(L=v.current)!=null&&L.contains(E)||h())};return document.addEventListener("pointerdown",x,!0),document.addEventListener("mousedown",x,!0),document.addEventListener("click",x,!0),()=>{document.removeEventListener("pointerdown",x,!0),document.removeEventListener("mousedown",x,!0),document.removeEventListener("click",x,!0)}},[h,j]);const l=c.useMemo(()=>Qr(o.queries),[o.queries]),b=c.useMemo(()=>Me(o.queries),[o.queries]),D=Dt(l),C=c.useMemo(()=>$t(o.queries,p),[o.queries,p]),B=c.useMemo(()=>Ot(C),[C]),R=c.useMemo(()=>hr(C,u==null?void 0:u.focus)||C[0],[C,u==null?void 0:u.focus]);return!o.enabled||!u?null:i.jsxs(i.Fragment,{children:[i.jsxs("button",{ref:m,type:"button","aria-label":"Open Semaphor Inspector",title:D,className:n?`${T} ${n}`:T,style:{...a.launcher,...Zr(e),...et(l.severity),...s},onClick:()=>{var S;const x=(S=b[0])==null?void 0:S.trace;u.openDevtools(x?{traceId:x.traceId,queryId:x.queryId,viewId:x.viewId}:void 0)},children:[i.jsx(gt,{}),i.jsx("span",{style:a.launcherText,children:l.total}),l.issueCount>0?i.jsxs("span",{style:a.launcherIssueCount,children:[l.issueCount," issue",l.issueCount===1?"":"s"]}):null]}),u.open?i.jsxs("div",{ref:v,role:"dialog","aria-label":"Semaphor Inspector","aria-modal":"false",className:T,style:{...a.panel,...rt(t),...f?a.panelFullscreen:null},children:[i.jsxs("div",{style:a.panelHeader,children:[i.jsxs("div",{style:a.panelTitleBlock,children:[i.jsx("div",{style:a.panelTitle,children:"Semaphor Inspector"}),i.jsxs("div",{style:a.panelSubtitle,children:[l.total," queries · ",l.loading," loading ·"," ",l.failed," failed · ",l.errorCount," errors ·"," ",l.warningCount," warnings"]})]}),i.jsxs("div",{style:a.panelActions,children:[i.jsx("button",{type:"button","aria-label":f?"Exit fullscreen Semaphor Inspector":"Enter fullscreen Semaphor Inspector",title:f?"Exit fullscreen Semaphor Inspector":"Enter fullscreen Semaphor Inspector",style:a.iconButton,onClick:()=>y(x=>!x),children:f?i.jsx(se.Minimize2,{size:15}):i.jsx(se.Maximize2,{size:15})}),i.jsx("button",{type:"button","aria-label":"Close Semaphor Inspector",style:a.iconButton,onClick:u.closeDevtools,children:i.jsx(Ke.X,{size:15})})]})]}),i.jsxs("label",{style:a.searchBox,children:[i.jsx(se.Search,{size:14}),i.jsx("input",{"aria-label":"Search Semaphor traces",value:p,onChange:x=>d(x.currentTarget.value),placeholder:"Search traces",style:a.searchInput})]}),b.length?i.jsx(bt,{issues:b,onSelect:x=>u.focusTrace({traceId:x.traceId,queryId:x.queryId,viewId:x.viewId})}):null,i.jsxs("div",{style:{...a.panelBody,...tt(t)},children:[i.jsx("div",{style:{...a.queryList,...nt()},"aria-label":"Registered queries",children:C.length?B.map(x=>i.jsxs("div",{style:a.queryGroup,children:[i.jsxs("div",{style:a.queryGroupHeader,children:[i.jsx("span",{children:x.title}),i.jsx("span",{style:a.queryGroupCount,children:x.traces.length})]}),x.traces.length?x.traces.map(S=>{var Y;const E=Kt(S,R),I=ye(S),L=xr(S),ae=Sr(S),G=Wt(S,I,ae),J=G.join(" · "),k=br(L),W=Vr(b,S);return i.jsxs("button",{type:"button",title:`${I} · ${L} · ${J}`,style:{...a.queryListItem,...E?a.queryListItemSelected:null},onClick:()=>u.focusTrace({traceId:S.traceId,queryId:S.queryId,viewId:S.viewId}),children:[i.jsxs("span",{style:a.queryListItemHeader,children:[i.jsx(vt,{status:(Y=S.latestAttempt)==null?void 0:Y.status}),i.jsx("span",{style:a.queryListTitle,title:I,children:I}),i.jsx("span",{style:{...a.queryListKindChip,...vr(k)},children:L}),W>0?i.jsx("span",{style:a.queryListIssueBadge,children:W}):null]}),i.jsx("span",{className:`${T}-source`,style:a.queryListSource,title:J,children:G.map((X,Z)=>i.jsxs(c.Fragment,{children:[Z>0?i.jsx("span",{style:a.queryListSubtitleSep,children:" · "}):null,i.jsx("span",{children:X})]},`${X}:${Z}`))})]},Le(S))}):i.jsx("div",{style:a.queryGroupEmpty,children:"No input traces"})]},x.title)):i.jsx("div",{style:a.emptyState,children:"No matching traces"})}),i.jsx(mt,{trace:R})]})]}):null]})}function ft({queryId:e,viewId:r,label:t,className:n,style:s}={}){var m,v;const o=Pe(),u=c.useContext(_e),p=c.useContext(Ne);c.useEffect(()=>{pr()},[]);const d=r||(p==null?void 0:p.id),f=c.useMemo(()=>Bt(o.queries,{queryId:e,viewId:d}),[o.queries,e,d]);if(!o.enabled||!u||!f)return null;const y=t||`Inspect ${_t(f,!!e)}`;return i.jsxs("button",{type:"button","aria-label":y,title:y,className:n?`${T} ${n}`:T,style:{...a.inspectButton,...st((m=f.latestAttempt)==null?void 0:m.status),...s},onClick:()=>u.openDevtools({traceId:f.traceId,queryId:f.queryId,viewId:f.viewId}),children:[i.jsx(se.Eye,{size:13}),i.jsx("span",{style:a.inspectButtonText,children:((v=f.latestAttempt)==null?void 0:v.status)||"idle"})]})}function Pe(){const e=c.useContext(We);return!e||!e.state.enabled?gr:ne(e.state)}function pt({spec:e,queryKind:r,queryKey:t,intent:n,activeInputs:s,debug:o}){const u=c.useContext(We),p=c.useContext(Ne),d=!!(u!=null&&u.state.enabled),f=u==null?void 0:u.dispatch,y=pn(e),m=zr(e),v=c.useMemo(()=>JSON.stringify(e),[e]),g=c.useMemo(()=>JSON.stringify(s||[]),[s]),h=c.useMemo(()=>JSON.stringify(n||null),[n]),j=c.useRef(e),l=c.useRef(v),b=c.useRef(n),D=c.useRef(h),C=c.useRef(s),B=c.useRef(g),R=fn(o),x=JSON.stringify(R||[]),S=c.useRef(R),E=c.useRef(x);l.current!==v&&(l.current=v,j.current=e),D.current!==h&&(D.current=h,b.current=n),B.current!==g&&(B.current=g,C.current=s),E.current!==x&&(E.current=x,S.current=R);const I=j.current,L=b.current,ae=C.current,G=S.current,J=c.useId(),k=c.useMemo(()=>y||`query_${jr(t)}`,[t,y]),W=(o==null?void 0:o.viewId)||(p==null?void 0:p.id),Y=(o==null?void 0:o.viewTitle)||(o==null?void 0:o.title)||(p==null?void 0:p.title),X=o==null?void 0:o.visualType,Z=o==null?void 0:o.sectionTitle,_=c.useMemo(()=>[W||"unscoped-view",k,J].join("::"),[k,J,W]),Qe=c.useMemo(()=>({traceKey:_,spec:I,queryId:k,queryLabel:m,queryKind:r,builder:gn(r),viewId:W,viewTitle:Y,visualType:X,sectionTitle:Z,sourceHints:G,intent:L,activeInputs:ae,clientWarnings:y?[]:["Query spec is missing an explicit id; using an opaque internal id."]}),[k,r,y,m,I,ae,L,G,Z,_,W,Y,X]);c.useEffect(()=>{if(!(!d||!f))return f({type:"register",descriptor:Qe}),()=>{f({type:"unregister",traceKey:_})}},[Qe,f,d,_]);const K=c.useCallback((A,z)=>{!d||!f||f({type:"event",traceKey:_,event:A,latestAttempt:z})},[f,d,_]),Ue=c.useCallback(()=>{K({type:"query_started",queryId:k,at:fe()},{status:"loading"})},[K,k]),Ge=c.useCallback((A,z)=>{const ee=ar(A),re=wn(A),Dr=In(A);K({type:"query_succeeded",queryId:k,requestId:ee,at:fe(),rowCount:re,durationMs:z},{requestId:ee,status:"success",durationMs:z,rowCount:re,columnCount:Dr,metricCoverage:qn(A),executionResult:or(A)})},[K,k]),le=c.useCallback((A,z)=>{const ee=ar(A),re=A instanceof Error?A.message:String(A);K({type:"query_failed",queryId:k,requestId:ee,at:fe(),errorMessage:re},{requestId:ee,status:"error",durationMs:z,errorMessage:re,executionResult:or(A)})},[K,k]),Je=c.useCallback(A=>{K({type:"query_ignored_stale",queryId:k,at:fe(),reason:A})},[K,k]),Ye=c.useCallback(A=>{le(A,0)},[le]),ve=d?u==null?void 0:u.state.entries[_]:void 0;return c.useMemo(()=>({enabled:d,queryId:k,trace:ve?pe(ve):void 0,start:Ue,success:Ge,failure:le,ignored:Je,validationFailure:Ye}),[d,le,Je,k,Ue,Ge,ve,Ye])}function gt(){return i.jsx("span",{style:a.logoMark,"aria-hidden":!0,children:i.jsxs("svg",{viewBox:"0 0 100 100",fill:"none",width:"16",height:"16",focusable:"false",children:[i.jsx("rect",{x:"20",y:"15",width:"60",height:"12",rx:"6",fill:"currentColor"}),i.jsx("rect",{x:"20",y:"35",width:"40",height:"12",rx:"6",fill:"currentColor"}),i.jsx("rect",{x:"40",y:"55",width:"40",height:"12",rx:"6",fill:"currentColor"}),i.jsx("rect",{x:"20",y:"75",width:"60",height:"12",rx:"6",fill:"currentColor"})]})})}function mt({trace:e}){var R,x,S,E,I;if(!e)return i.jsx("div",{style:a.detailsPane,children:i.jsx("div",{style:a.emptyState,children:"No traces registered yet"})});const r=e.latestAttempt,t=r==null?void 0:r.executionResult,n=je((R=t==null?void 0:t.validation)==null?void 0:R.warnings),s=je((x=t==null?void 0:t.validation)==null?void 0:x.errors),o=Zt((S=t==null?void 0:t.coverage)==null?void 0:S.missingObligations),u=je((E=t==null?void 0:t.coverage)==null?void 0:E.warnings),p=t==null?void 0:t.compiledQuery,d=tn(t),f=((I=e.server)==null?void 0:I.compiledSql)||d.compiledSql,y=Mr(t),m=[...r!=null&&r.errorMessage?[r.errorMessage]:[],...s],v=[...e.clientWarnings,...n,...o,...u],g=e.inputsApplied.length>0,h=!!(p||f),j=zt(e),l=Qt(r==null?void 0:r.rowCount),b=Ut(r==null?void 0:r.durationMs),D=e.sourceRefs.length,C=xr(e),B=br(C);return i.jsxs("div",{style:a.detailsPane,children:[i.jsxs("div",{style:a.detailsHeader,children:[i.jsxs("div",{style:a.detailsHeaderTopRow,children:[i.jsx("span",{"aria-hidden":!0,style:{...a.detailsHeaderStatusDot,...fr(r==null?void 0:r.status)}}),i.jsx("span",{style:a.detailsTitle,children:ye(e)}),i.jsx("span",{style:{...a.detailsKindChip,...vr(B)},children:C})]}),i.jsxs("div",{style:a.metaStrip,children:[i.jsx("span",{style:a.metaStripItem,children:j}),i.jsx("span",{style:a.metaStripDot,children:"·"}),i.jsxs("span",{style:a.metaStripItem,children:[l," rows"]}),i.jsx("span",{style:a.metaStripDot,children:"·"}),i.jsx("span",{style:a.metaStripItem,children:b}),D>0?i.jsxs(i.Fragment,{children:[i.jsx("span",{style:a.metaStripDot,children:"·"}),i.jsx("span",{style:a.metaStripItem,children:D===1?"1 source":`${D} sources`})]}):null]})]}),m.length?i.jsx(rr,{tone:"error",title:"Error",items:m}):null,v.length?i.jsx(rr,{tone:"warning",title:"Warnings",items:v}):null,i.jsx(xt,{trace:e}),g?i.jsx(kt,{inputs:e.inputsApplied}):null,i.jsx(yt,{trace:e,resultPreview:y,compiledQuery:p,compiledSql:f,hasCompiled:h})]})}function yt({trace:e,resultPreview:r,compiledQuery:t,compiledSql:n,hasCompiled:s}){var h,j;const o=[];r&&o.push({id:"returned",label:"Returned",render:()=>i.jsx(Tt,{preview:r})}),s&&o.push({id:"compiled",label:"Compiled",render:()=>i.jsx(Et,{compiledQuery:t,compiledSql:n})}),(e.sourceRefs.length||e.fieldRefs.length)&&o.push({id:"lineage",label:"Sources",render:()=>i.jsx(It,{trace:e})}),(h=e.sourceHints)!=null&&h.length&&o.push({id:"hints",label:"Hints",render:()=>i.jsx(qt,{hints:e.sourceHints??[]})}),o.push({id:"lifecycle",label:"Lifecycle",render:()=>i.jsx(ht,{trace:e})}),o.push({id:"raw",label:"Raw",render:()=>i.jsx("pre",{style:a.codeBlock,children:Gt(e)})});const u=(j=o[0])==null?void 0:j.id,p=e.traceId||`${e.viewId??""}:${e.queryId}`,[d,f]=c.useState(u),y=c.useRef(p),m=c.useRef(!1),v=o.map(l=>l.id).join("|");c.useEffect(()=>{if(y.current!==p){y.current=p,m.current=!1,f(u);return}if(!(d?v.split("|").includes(d):!1)){m.current=!1,f(u);return}!m.current&&d!==u&&f(u)},[d,u,v,p]);const g=o.find(l=>l.id===d)??o[0];return i.jsxs("div",{style:a.traceTabs,children:[i.jsx("div",{style:a.traceTabBar,role:"tablist","aria-label":"Trace details",children:o.map(l=>{const b=l.id===g.id;return i.jsx("button",{type:"button",role:"tab","aria-selected":b,className:`${T}-tab`,style:{...a.traceTab,...b?a.traceTabActive:null},onClick:()=>{m.current=!0,f(l.id)},children:l.label},l.id)})}),i.jsx("div",{style:a.traceTabPanel,role:"tabpanel",children:g.render()})]})}function ht({trace:e}){return e.recentEvents.length?i.jsx("div",{style:a.eventList,children:e.recentEvents.slice(-5).map((r,t)=>i.jsxs("div",{style:a.eventRow,children:[i.jsx("span",{style:a.eventType,children:Jt(r)}),i.jsx("span",{style:a.eventMeta,children:Yt(r)})]},`${r.type}:${r.at}:${t}`))}):i.jsx("div",{style:a.mutedText,children:"No attempts recorded"})}function rr({tone:e,title:r,items:t}){const n=e==="error"?a.alertCardError:a.alertCardWarning;return i.jsxs("div",{style:{...a.alertCard,...n},children:[i.jsx("div",{style:a.alertCardTitle,children:r}),t.length>1?i.jsx("ul",{style:a.alertCardList,children:t.map((s,o)=>i.jsx("li",{children:s},`${e}-${o}`))}):i.jsx("div",{children:t[0]})]})}function bt({issues:e,onSelect:r}){const[t,n]=c.useState(!1),s=e.slice(0,6),o=e.length-s.length,u=e.filter(f=>f.tone==="error").length,p=e.length-u,d=[u?`${u} error${u===1?"":"s"}`:"",p?`${p} warning${p===1?"":"s"}`:""].filter(Boolean);return i.jsxs("section",{style:a.issueSummary,"aria-label":"Semaphor trace issues",children:[i.jsxs("button",{type:"button","aria-expanded":t,style:a.issueSummaryToggle,onClick:()=>n(f=>!f),children:[i.jsxs("span",{style:a.issueSummaryHeaderLabel,children:[t?i.jsx(Ke.ChevronDown,{size:13}):i.jsx(se.ChevronRight,{size:13}),i.jsx("span",{children:"Issues"})]}),i.jsx("span",{style:a.issueSummaryCount,children:e.length})]}),t?i.jsxs("div",{style:a.issueSummaryList,children:[s.map((f,y)=>i.jsxs("button",{type:"button",title:`${f.title}: ${f.message}`,style:a.issueSummaryItem,onClick:()=>r(f.trace),children:[i.jsx("span",{style:{...a.issueSummaryBadge,...f.tone==="error"?a.issueSummaryBadgeError:a.issueSummaryBadgeWarning},children:f.tone==="error"?"Error":"Warning"}),i.jsxs("span",{style:a.issueSummaryText,children:[i.jsx("span",{style:a.issueSummaryTitle,children:f.title}),i.jsx("span",{style:a.issueSummaryMessage,children:f.message})]})]},`${f.trace.traceId}:${f.title}:${y}`)),o>0?i.jsxs("div",{style:a.issueSummaryMore,children:[o," more issue",o===1?"":"s"," in traces"]}):null]}):i.jsxs("div",{style:a.issueSummaryCollapsed,children:[d.join(" · ")," across traces"]})]})}function vt({status:e}){return i.jsx("span",{"aria-hidden":!0,style:{...a.statusDot,...fr(e)}})}function xt({trace:e}){var s;const r=(s=e.projectionFieldRefs)!=null&&s.length?e.projectionFieldRefs:e.fieldRefs,t=e.inputFieldRefs||[],n=Pt(r);return i.jsxs("div",{style:a.recipe,children:[i.jsx(St,{sources:e.sourceRefs}),i.jsx(N,{title:"Measures",fields:n.measures}),i.jsx(N,{title:"Time fields",fields:n.timeFields}),i.jsx(N,{title:"Dimensions",fields:n.dimensions,emptyText:"No dimensions selected"}),i.jsx(N,{title:"Identifiers",fields:n.identifiers}),i.jsx(N,{title:"Other fields",fields:n.other}),i.jsx(N,{title:"Input bindings (Filters)",fields:t})]})}function St({sources:e}){return e.length?i.jsxs("div",{style:a.recipeGroup,children:[i.jsxs("div",{style:a.recipeGroupHeader,children:[i.jsx("span",{style:a.recipeGroupTitle,children:"From"}),i.jsx("span",{style:a.recipeGroupCount,children:e.length})]}),i.jsx("div",{style:a.sourcePillRow,children:e.map((r,t)=>i.jsx(wt,{source:r},`${M(r)}:${t}`))})]}):null}function wt({source:e}){const r=M(e);return i.jsxs("span",{style:a.sourcePill,title:r,children:[i.jsx("span",{style:a.sourcePillLabel,children:r}),i.jsx("span",{style:a.sourcePillRole,children:e.kind})]})}function It({trace:e}){return i.jsxs("div",{style:a.traceLineage,children:[i.jsx(jt,{sources:e.sourceRefs}),i.jsx(N,{title:"All field refs",fields:e.fieldRefs,emptyText:"No field refs captured"})]})}function qt({hints:e}){return i.jsx("div",{style:a.recipeFieldList,children:e.map((r,t)=>{const n=Vt(r),s=r.component||r.exportName||n||"Source hint",o=[r.exportName&&r.exportName!==s?r.exportName:void 0,n,r.note].filter(Boolean).join(" · ");return i.jsxs("div",{style:a.recipeFieldRow,title:o||s,children:[i.jsx("span",{style:a.recipeFieldName,children:s}),o?i.jsx("span",{style:a.recipeFieldMeta,children:o}):null]},`${s}:${n}:${t}`)})})}function jt({sources:e}){return i.jsxs("div",{style:a.recipeGroup,children:[i.jsxs("div",{style:a.recipeGroupHeader,children:[i.jsx("span",{style:a.recipeGroupTitle,children:"Sources"}),i.jsx("span",{style:a.recipeGroupCount,children:e.length})]}),e.length?i.jsx("div",{style:a.recipeFieldList,children:e.map((r,t)=>i.jsxs("div",{style:a.recipeFieldRow,title:M(r),children:[i.jsx("span",{style:a.recipeFieldName,children:M(r)}),i.jsx("span",{style:a.recipeFieldMeta,children:r.kind})]},`${M(r)}:${t}`))}):i.jsx("div",{style:a.recipeEmptyText,children:"No sources captured"})]})}function N({title:e,fields:r,emptyText:t}){return!r.length&&!t?null:i.jsxs("div",{style:a.recipeGroup,children:[i.jsxs("div",{style:a.recipeGroupHeader,children:[i.jsx("span",{style:a.recipeGroupTitle,children:e}),i.jsx("span",{style:a.recipeGroupCount,children:r.length})]}),r.length?i.jsx("div",{style:a.fieldChipList,children:r.map((n,s)=>i.jsx(Ct,{field:n,groupTitle:e},`${ze(n)}:${s}`))}):i.jsx("div",{style:a.recipeEmptyText,children:t})]})}function Ct({field:e,groupTitle:r}){const t=Ft(e),n=e.label||e.name,s=e.dataType&&e.dataType!=="unknown"?e.dataType:void 0,o=e.source?M(e.source):void 0,u=[t,s,o].filter(Boolean).join(" · "),p=At(e,r);return i.jsxs("div",{className:`${T}-field-row`,style:a.fieldChip,title:u,children:[i.jsx("span",{style:{...a.fieldGlyph,...p.style},children:p.text}),e.aggregate?i.jsx("span",{style:a.fieldAggBadge,children:e.aggregate}):null,i.jsx("span",{style:a.fieldChipName,children:n}),s?i.jsx("span",{style:a.fieldChipMeta,children:s}):null,s&&o?i.jsx("span",{style:a.fieldChipMetaDot,children:"·"}):null,o?i.jsx("span",{style:a.fieldChipMeta,children:o}):null]})}function At(e,r){const t=e.dataType,n=e.role;return!!e.aggregate||n==="measure"||r==="Measures"?{text:"Σ",style:{borderColor:"var(--sd-tone-metric-border)",background:"var(--sd-tone-metric-bg)",color:"var(--sd-tone-metric-fg)"}}:t==="date"||t==="datetime"||n==="date"||r==="Time fields"?{text:"◷",style:{borderColor:"var(--sd-tone-date-border)",background:"var(--sd-tone-date-bg)",color:"var(--sd-tone-date-fg)"}}:t==="number"?{text:"#",style:{borderColor:"var(--sd-tone-records-border)",background:"var(--sd-tone-records-bg)",color:"var(--sd-tone-records-fg)"}}:t==="boolean"?{text:"◐",style:{borderColor:"var(--sd-border)",background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)"}}:{text:"A",style:{borderColor:"var(--sd-tone-string-border)",background:"var(--sd-tone-string-bg)",color:"var(--sd-tone-string-fg)"}}}function kt({inputs:e}){return i.jsxs("div",{style:a.inputsAppliedBlock,children:[i.jsxs("div",{style:a.inputsAppliedHeader,children:[i.jsx("span",{style:a.inputsAppliedTitle,children:"Active Inputs (Active Filters)"}),i.jsx("span",{style:a.inputsAppliedCount,children:e.length})]}),i.jsx("div",{style:a.inputRecipeList,children:e.map(r=>{const t=Ht(r);return i.jsxs("div",{style:a.inputRecipeRow,title:t.title,children:[i.jsxs("div",{style:a.inputRecipeHeader,children:[i.jsx("span",{style:a.inputRecipeLabel,title:t.title,children:t.label}),t.showId?i.jsx("span",{style:a.inputRecipeId,title:r.inputId,children:r.inputId}):null,t.operator?i.jsx("span",{style:a.inputOperatorBadge,children:t.operator}):null,i.jsx("span",{style:a.inputValuePreview,title:t.value,children:t.value})]}),t.binding?i.jsx("div",{style:a.inputRecipeBinding,title:t.binding,children:t.binding}):null]},r.inputId)})})]})}function Tt({preview:e}){return i.jsxs("div",{style:a.resultPreview,children:[i.jsxs("div",{style:a.resultPreviewHeader,children:[i.jsx("span",{style:a.resultPreviewTitle,children:e.title}),i.jsx("span",{style:a.resultPreviewSummary,children:e.summary})]}),i.jsx("div",{style:a.resultPreviewScroller,children:i.jsxs("table",{style:a.resultPreviewTable,children:[i.jsx("thead",{children:i.jsx("tr",{children:e.columns.map(r=>i.jsx("th",{style:a.resultPreviewTh,children:r.label},r.key))})}),i.jsx("tbody",{children:e.rows.length?e.rows.map((r,t)=>i.jsx("tr",{children:e.columns.map(n=>i.jsx("td",{style:a.resultPreviewTd,children:Nr(r[n.key])},n.key))},t)):i.jsx("tr",{children:i.jsx("td",{colSpan:e.columns.length,style:a.resultPreviewEmptyCell,children:"No rows returned"})})})]})}),e.truncatedRows||e.truncatedColumns?i.jsxs("div",{style:a.resultPreviewFootnote,children:["Showing first ",ie," rows and first"," ",Re," columns."]}):null]})}function Et({compiledQuery:e,compiledSql:r}){return(e==null?void 0:e.kind)==="sql"?i.jsxs("div",{style:a.compiledQuery,children:[i.jsx(tr,{label:"SQL",value:e.sql}),e.pythonCode?i.jsx(qe,{label:"Python",value:e.pythonCode}):null,e.parameters?i.jsx(qe,{label:"Parameters",value:De(e.parameters)}):null]}):r?i.jsx(tr,{label:"SQL",value:r}):i.jsx(qe,{label:"Compiled Query",value:De(e)})}function qe({label:e,value:r}){return i.jsxs("div",{style:a.codeBlockGroup,children:[i.jsx("div",{style:a.codeBlockLabel,children:e}),i.jsx("pre",{style:a.codeBlock,children:r})]})}function tr({label:e,value:r}){return i.jsxs("div",{style:a.codeBlockGroup,children:[i.jsx("div",{style:a.codeBlockLabel,children:e}),i.jsx("pre",{style:a.codeBlock,children:Lt(r)})]})}const Rt=new Set(["SELECT","FROM","JOIN","LEFT","RIGHT","INNER","OUTER","CROSS","ON","USING","WHERE","AND","OR","GROUP","BY","HAVING","ORDER","ASC","DESC","LIMIT","OFFSET","AS","BETWEEN","IN","NOT","NULL","IS","CASE","WHEN","THEN","ELSE","END","DISTINCT","UNION","ALL","WITH"]);function Lt(e){return e.split(/(\s+|,|\(|\))/).map((t,n)=>{if(!t)return null;const s=t.toUpperCase();return Rt.has(s)?i.jsx("span",{style:a.sqlKeyword,children:t},n):t.startsWith("$")||t.startsWith(":")||t.startsWith("?")?i.jsx("span",{style:a.sqlBindParam,children:t},n):i.jsx("span",{children:t},n)})}function Dt(e){return[`${e.total} ${e.total===1?"trace":"traces"}`,`${e.loading} loading`,`${e.failed} failed`,`${e.errorCount} error${e.errorCount===1?"":"s"}`,`${e.warningCount} warning${e.warningCount===1?"":"s"}`].join(" · ")}function $t(e,r){const t=r.trim().toLowerCase();return t?e.filter(n=>[n.queryId,n.queryLabel,n.viewId,n.viewTitle,n.visualType,n.sectionTitle,n.builder,n.queryKind,Sr(n)].filter(Boolean).join(" ").toLowerCase().includes(t)):e}function Ot(e){const r=e.filter(s=>s.queryKind==="inputOptions"),t=new Set(r.map(Le));return[{title:"Views",traces:e.filter(s=>!t.has(Le(s)))},{title:"Inputs",traces:r}]}function hr(e,r){if(!(!(r!=null&&r.traceId)&&!(r!=null&&r.queryId)&&!(r!=null&&r.viewId)))return r.traceId?e.find(t=>t.traceId===r.traceId):e.find(t=>!(r.queryId&&t.queryId!==r.queryId||r.viewId&&t.viewId!==r.viewId))}function Bt(e,r){if(r.queryId)return hr(e,r);if(!r.viewId)return;const t=e.filter(n=>n.viewId===r.viewId);return t.length===1?t[0]:void 0}function Kt(e,r){return!!(e&&r&&e.traceId===r.traceId)}function Le(e){return e.traceId}function Mt(e){switch(e){case"metric":return"metric";case"records":return"records";case"matrix":return"matrix";case"analysis":return"analysis";case"inputOptions":return"inputs";case"sql":return"sql";default:return he(e)}}function br(e){const r=e.trim().toLowerCase();return r==="metric"||r==="kpi"?"metric":r==="records"||r==="table"?"records":r==="matrix"||r==="pivot"?"matrix":r==="analysis"?"analysis":r==="inputs"||r==="input options"?"inputs":r==="sql"?"sql":"default"}function vr(e){switch(e){case"metric":return{borderColor:"var(--sd-tone-metric-border)",background:"var(--sd-tone-metric-bg)",color:"var(--sd-tone-metric-fg)"};case"records":return{borderColor:"var(--sd-tone-records-border)",background:"var(--sd-tone-records-bg)",color:"var(--sd-tone-records-fg)"};case"analysis":case"matrix":return{borderColor:"var(--sd-tone-analysis-border)",background:"var(--sd-tone-analysis-bg)",color:"var(--sd-tone-analysis-fg)"};case"inputs":case"sql":case"default":default:return{borderColor:"var(--sd-border)",background:"var(--sd-bg-accent)",color:"var(--sd-fg-muted)"}}}function Wt(e,r,t){const n=[];return e.queryLabel&&e.queryLabel!==r&&n.push(e.queryLabel),e.queryId&&e.queryId!==r&&e.queryId!==e.queryLabel?n.push(e.queryId):e.viewId&&e.viewId!==r&&e.viewId!==e.queryLabel&&n.push(e.viewId),n.push(t),n}function xr(e){return Nt(e.visualType)||Mt(e.queryKind)}function _t(e,r){return r?e.queryLabel||e.queryId:ye(e)}function Nt(e){if(e)return e.replace(/[_-]+/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function Sr(e){const r=e.sourceRefs.map(M);return r.length?r.length===1?r[0]:`${r[0]} + ${r.length-1} more`:"No source"}function Pt(e){return e.reduce((r,t)=>(t.role==="measure"?r.measures.push(t):t.role==="date"?r.timeFields.push(t):t.role==="dimension"?r.dimensions.push(t):t.role==="id"?r.identifiers.push(t):r.other.push(t),r),{measures:[],timeFields:[],dimensions:[],identifiers:[],other:[]})}function zt(e){var r,t;if(e.queryKind==="records"&&((r=e.projectionFieldRefs)!=null&&r.length)&&e.projectionFieldRefs.every(n=>n.role==="measure")&&((t=e.latestAttempt)==null?void 0:t.rowCount)===1)return"KPI query";switch(e.queryKind){case"metric":return"KPI query";case"records":return"Records query";case"matrix":return"Matrix query";case"analysis":return"Analysis query";case"inputOptions":return"Input options query";case"sql":return"SQL query";default:return he(e.queryKind)}}function Ft(e){return[e.aggregate,e.label||e.name].filter(Boolean).join(" ")}function Ht(e){var p,d,f;const r=e.valuePreview||"redacted",t=e.inputLabel||e.inputId,n=((p=e.fieldRef)==null?void 0:p.label)||((d=e.fieldRef)==null?void 0:d.name),s=(f=e.fieldRef)!=null&&f.source?M(e.fieldRef.source):void 0,o=[n?`on ${n}`:void 0,s].filter(Boolean).join(" · "),u=[t,e.inputId,e.operator,r,o].filter(Boolean).join(" - ");return{label:t,showId:t!==e.inputId,operator:e.operator,value:r,binding:o,title:u}}function M(e){return e.kind==="semantic"?e.datasetName||e.datasetId||e.domainId:e.kind==="physical"?[e.schemaName,e.tableName].filter(Boolean).join(".")||e.tableName:e.connectionId?`SQL ${e.connectionId}`:"SQL source"}function Vt(e){if(e.file)return e.line&&e.column?`${e.file}:${e.line}:${e.column}`:e.line?`${e.file}:${e.line}`:e.file}function Qt(e){return typeof e=="number"?e.toLocaleString():"-"}function Ut(e){return typeof e=="number"?`${Math.round(e)}ms`:"-"}function Gt(e){return De(e)}function De(e){return JSON.stringify(e,null,2)??"undefined"}function Jt(e){switch(e.type){case"query_started":return"Started";case"query_succeeded":return"Succeeded";case"query_failed":return"Failed";case"query_ignored_stale":return"Ignored stale";case"input_changed":return"Input changed";default:return Xt(e)}}function Yt(e){return[e.at,"durationMs"in e&&typeof e.durationMs=="number"?`${Math.round(e.durationMs)}ms`:void 0,"rowCount"in e&&typeof e.rowCount=="number"?`${e.rowCount} rows`:void 0,"reason"in e?e.reason:void 0,"errorMessage"in e?e.errorMessage:void 0].filter(Boolean).join(" - ")}function Xt(e){throw new Error(`Unsupported Semaphor trace event: ${JSON.stringify(e)}`)}function Zt(e){return Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function je(e){return Array.isArray(e)?e.map(r=>en(r)).filter(r=>!!r):[]}function en(e){var r;return(r=rn(e))==null?void 0:r.message}function rn(e){if(typeof e=="string")return{message:e};if(!e||typeof e!="object"||Array.isArray(e))return;const r=e,t=typeof r.message=="string"?r.message:"",n=typeof r.code=="string"?r.code:"",s=typeof r.path=="string"?r.path:"";return t&&n?{message:s?`${t} (${n}, ${s})`:`${t} (${n})`,code:n,...s?{path:s}:{}}:t?{message:t}:n?{message:n,code:n}:void 0}function tn(e){const r=e==null?void 0:e.metadata,t=r&&typeof r=="object"&&!Array.isArray(r)&&"dataAppDebug"in r&&r.dataAppDebug&&typeof r.dataAppDebug=="object"&&!Array.isArray(r.dataAppDebug)?r.dataAppDebug:void 0;return{compiledSql:typeof(t==null?void 0:t.compiledSql)=="string"?t.compiledSql:void 0,queryHash:typeof(t==null?void 0:t.queryHash)=="string"?t.queryHash:void 0}}function wr(e){return{...e,order:[],entries:{},sequence:0}}function nn(e,r){if(r.type==="config")return r.config.enabled?{...e,...r.config}:wr(r.config);if(!e.enabled)return e;switch(r.type){case"register":return ln(sn(e,r.descriptor));case"unregister":return on(e,r.traceKey);case"event":return an(e,r);default:return e}}function sn(e,r){const t=e.entries[r.traceKey],n=t?e.sequence:e.sequence+1,s=Fe(),o={...t||dn(r),...Ir(r),traceKey:r.traceKey,latestAttempt:(t==null?void 0:t.latestAttempt)||{status:"idle"},recentEvents:(t==null?void 0:t.recentEvents)||[],mounted:!0,registeredAt:(t==null?void 0:t.registeredAt)||n,lastEventAt:(t==null?void 0:t.lastEventAt)||s};return{...e,sequence:n,order:t?e.order:[...e.order,r.traceKey],entries:{...e.entries,[r.traceKey]:o}}}function on(e,r){const t=e.entries[r];return t?{...e,entries:{...e.entries,[r]:{...t,mounted:!1}}}:e}function an(e,r){const t=e.entries[r.traceKey];if(!t)return e;const n=Fe(),s=[...t.recentEvents,r.event].slice(-e.maxEventsPerQuery);return{...e,entries:{...e.entries,[r.traceKey]:{...t,latestAttempt:r.latestAttempt?{...t.latestAttempt,...r.latestAttempt}:t.latestAttempt,recentEvents:s,lastEventAt:n}}}}function ln(e){if(e.order.length<=e.maxQueries)return e;const r=e.order.map(s=>e.entries[s]).filter(s=>!!s).sort((s,o)=>s.mounted!==o.mounted?s.mounted?1:-1:s.lastEventAt-o.lastEventAt),t=e.order.length-e.maxQueries,n=new Set(r.slice(0,t).map(s=>s.traceKey));return n.size?{...e,order:e.order.filter(s=>!n.has(s)),entries:Object.fromEntries(Object.entries(e.entries).filter(([s])=>!n.has(s)))}:e}function dn(e){const r=Fe();return{...Ir(e),traceKey:e.traceKey,latestAttempt:{status:"idle"},recentEvents:[],mounted:!0,registeredAt:0,lastEventAt:r}}function Ir(e){var n;const r=bn(e.spec),t=vn(e.spec,e.activeInputs);return{traceId:jr(e.traceKey),viewId:e.viewId,viewTitle:e.viewTitle,visualType:e.visualType,sectionTitle:e.sectionTitle,queryId:e.queryId,queryLabel:e.queryLabel,queryKind:e.queryKind,builder:e.builder,sourceRefs:hn(e.intent),sourceHints:(n=e.sourceHints)!=null&&n.length?e.sourceHints:void 0,projectionFieldRefs:r,inputFieldRefs:t,fieldRefs:xn(e.intent),inputsApplied:(e.activeInputs||[]).map(s=>({inputId:s.inputId,inputLabel:s.label,fieldRef:s.field,operator:s.operator,valuePreview:mn(s)})),recentEvents:[],clientWarnings:e.clientWarnings}}function pe(e){const{traceKey:r,mounted:t,registeredAt:n,lastEventAt:s,...o}=e;return o}function ne(e){if(!e.enabled)return gr;const r=e.order.map(n=>e.entries[n]).filter(n=>!!n).map(pe),t=Me(r).map(Hr);return{enabled:!0,queries:r,issues:t,getQuery:n=>{const s=Object.values(e.entries).find(o=>o.queryId===n);return s?pe(s):void 0},getQueries:n=>Object.values(e.entries).filter(s=>s.queryId===n).map(pe)}}function un(e){return{snapshot:()=>Jr(ne(e())),getQuery:r=>Ze(ne(e()).getQuery(r)),getQueries:r=>ne(e()).getQueries(r).map(t=>Ze(t)).filter(t=>!!t),getIssues:()=>ne(e()).issues}}function cn(e){return e===void 0||e===!1?{enabled:!1,exposeWindowBridge:!1,maxEventsPerQuery:we,maxQueries:Ie}:e===!0?{enabled:!0,exposeWindowBridge:!1,maxEventsPerQuery:we,maxQueries:Ie}:{enabled:e.enabled!==!1,exposeWindowBridge:e.exposeWindowBridge===!0,maxEventsPerQuery:sr(e.maxEventsPerQuery,we,ot),maxQueries:sr(e.maxQueries,Ie,at)}}function fn(e){const t=[e==null?void 0:e.sourceHint,...(e==null?void 0:e.sourceHints)||[]].filter(n=>!!n).map(n=>({file:ce(n.file),line:nr(n.line),column:nr(n.column),exportName:ce(n.exportName),component:ce(n.component),note:ce(n.note)})).filter(n=>!!(n.file||n.line||n.column||n.exportName||n.component||n.note));return t.length?t:void 0}function ce(e){if(typeof e!="string")return;const r=e.trim();return r||void 0}function nr(e){return typeof e=="number"&&Number.isInteger(e)&&e>0?e:void 0}function sr(e,r,t){return e===void 0||!Number.isFinite(e)||!Number.isInteger(e)||e<=0?r:Math.min(e,t)}function pn(e){return typeof e.id=="string"&&e.id.trim()?e.id:void 0}function gn(e){switch(e){case"metric":return"semaphor.metric";case"records":return"semaphor.records";case"matrix":return"semaphor.matrix";case"analysis":return"semaphor.analysis";case"inputOptions":return"semaphor.inputOptions";case"sql":return"semaphor.sql";default:return he(e)}}function he(e){throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`)}function mn(e){if(yn(e))return;const r=e.value;if(r!==void 0){if(Array.isArray(r)){const t=r.filter(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean").map(n=>String(n));if(t.length===r.length&&t.length>0){const n=t.slice(0,3).join(", "),s=t.length>3?`, +${t.length-3} more`:"";return ir(`${n}${s}`)}return`${r.length} selected`}return typeof r=="number"||typeof r=="boolean"?String(r):typeof r=="string"?ir(r):r&&typeof r=="object"?`object(${Object.keys(r).slice(0,5).join(",")})`:String(r)}}function ir(e){return e.length>80?`${e.slice(0,77)}...`:e}function yn(e){var t;const r=[e.inputId,e.label,(t=e.field)==null?void 0:t.name].filter(Boolean).join(" ").toLowerCase();return["token","secret","password","email","phone","ssn"].some(n=>r.includes(n))}function hn(e){const r=[];return me(e,t=>{Sn(t)&&r.push(t)}),Be.mergeSemaphorSourcesByIdentity(r)}function bn(e){switch(e.queryKind){case"metric":case"analysis":return V([...e.measures||[],e.primaryMeasure,e.dateField,...e.dimensions||[]]);case"records":return V(e.fields||[]);case"inputOptions":return V([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]);case"sql":return V(e.fields||[]);case"matrix":return V([...(e.rows||[]).map(Ce),...(e.columns||[]).map(Ce),...(e.values||[]).map(Ce)]);default:return he(e)}}function vn(e,r){const t=[...(e.inputs||[]).map(qr),...(r||[]).map(n=>n.field)];return V(t)}function V(e){const r=new Map;return e.forEach(t=>{t&&oe(t)&&r.set(ze(t),t)}),[...r.values()]}function qr(e){if(!e||typeof e!="object")return;const r=e.toAnalyticsInput;if(typeof r=="function"){const n=r.call(e);return qr(n)}const t=e.field;return oe(t)?t:void 0}function Ce(e){if(oe(e))return e;if(!e||typeof e!="object")return;const r=e.field;return oe(r)?r:void 0}function xn(e){const r=new Map;return me(e,t=>{oe(t)&&r.set(ze(t),t)}),[...r.values()]}function me(e,r){if(!(!e||typeof e!="object")){if(r(e),Array.isArray(e)){e.forEach(t=>me(t,r));return}Object.values(e).forEach(t=>me(t,r))}}function Sn(e){if(!e||typeof e!="object")return!1;const r=e;return r.kind==="semantic"?typeof r.domainId=="string"&&typeof r.datasetName=="string":r.kind==="physical"?typeof r.connectionId=="string"&&typeof r.tableName=="string":r.kind==="sql"?typeof r.connectionId=="string":!1}function oe(e){if(!e||typeof e!="object")return!1;const r=e;return typeof r.name=="string"&&(r.source!==void 0||r.role!==void 0||r.dataType!==void 0||r.aggregate!==void 0)}function ze(e){return[e.name,e.role,e.aggregate,e.source?Be.semaphorSourceIdentityKey(e.source):""].join(":")}function wn(e){const r=e;return typeof(r==null?void 0:r.rowCount)=="number"?r.rowCount:Array.isArray(r==null?void 0:r.records)?r.records.length:void 0}function In(e){const r=e;return Array.isArray(r==null?void 0:r.columns)?r.columns.length:void 0}function or(e){const r=e;return r==null?void 0:r.executionResult}function qn(e){const r=e,t=[...r!=null&&r.measures?Object.keys(r.measures):[],...r!=null&&r.measureBindings?Object.keys(r.measureBindings):[]].filter(Boolean).sort(),n=Array.isArray(r==null?void 0:r.missingMeasures)?r.missingMeasures.filter(s=>typeof s=="string"&&!!s):[];if(!(t.length===0&&n.length===0))return{...t.length>0?{populatedMetricKeys:t}:{},...n.length>0?{missingMeasures:n}:{}}}function ar(e){const r=e;return typeof(r==null?void 0:r.requestId)=="string"?r.requestId:void 0}function jr(e){let r=2166136261;for(let t=0;t<e.length;t+=1)r^=e.charCodeAt(t),r=Math.imul(r,16777619);return(r>>>0).toString(36)}function fe(){return new Date().toISOString()}function Fe(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const jn=["primary","comparisons","contributors","segments","periodChanges","records","changes","drivers","absoluteDeltaDrivers","largestNegativeChanges","largestPositiveChanges","largestNegativeDrivers","largestPositiveDrivers"],Cn=["primary","records","periodChanges","changes","comparisons","contributors","segments","drivers","absoluteDeltaDrivers","largestNegativeChanges","largestPositiveChanges","largestNegativeDrivers","largestPositiveDrivers"];function Cr(e){if(!e)return{};const r=Ln(e.executionResult),t=An(e,r),n=En(t),s=Ar(Ve(e.analysisWarnings),On(t));return{...e,...Object.keys(t).length?{resultSets:t}:{},...s.length?{analysisWarnings:s}:{},...n?{columns:n.columns,records:n.records,rowCount:n.rowCount}:{}}}function An(e,r){const t=kn(e.resultSets);for(const s of jn){if(t[s])continue;const o=Dn(e[s]);if(!o.length)continue;const u=r.length?r:$n(o);t[s]={id:s,role:s,...He({records:o,columns:u,resultSetKey:s}),columns:u,rowCount:o.length}}const n=Rn(e.executionResult);return n&&n.records.length>0&&!t.records&&(t.records=n),t}function kn(e){return Object.fromEntries(Object.entries(e||{}).map(([r,t])=>[r,Tn(t,r)]))}function Tn(e,r=e.id||e.role||"resultSet"){var n;const t=He({records:e.records||[],columns:e.columns||[],resultSetKey:r});return{...e,...t,...e.warnings||t.warnings?{warnings:Ar(Ve(e.warnings),t.warnings)}:{},rowCount:e.rowCount??((n=e.records)==null?void 0:n.length)??0}}function En(e){var r;for(const t of Cn)if((r=e[t])!=null&&r.records.length)return e[t];return Object.values(e).find(t=>t.records.length)||Object.values(e)[0]}function Rn(e){const r=e==null?void 0:e.result;if(!(!r||r.kind!=="records"&&r.kind!=="sql"))return{id:"records",role:"records",...He({records:r.records,columns:r.columns,resultSetKey:"records"}),columns:r.columns,rowCount:r.rowCount??r.records.length}}function Ln(e){const r=e==null?void 0:e.result;return!r||r.kind!=="records"&&r.kind!=="sql"?[]:r.columns}function Dn(e){return Array.isArray(e)?e.filter(r=>!!(r&&typeof r=="object"&&!Array.isArray(r))):[]}function He({records:e,columns:r,resultSetKey:t}){if(!r.length)return{records:e};const n=[];return{records:e.map((o,u)=>{const p={};return r.forEach(d=>{if(Object.prototype.hasOwnProperty.call(o,d.key)){p[d.key]=o[d.key];return}n.push({code:"missing_analysis_result_key",severity:"warning",resultSetKey:t,rowIndex:u,columnKey:d.key,...d.name?{columnName:d.name}:{},...d.label?{columnLabel:d.label}:{},availableKeys:Object.keys(o),message:`Analysis result set "${t}" row ${u} is missing column key "${d.key}". Rows must expose values by column.key; labels and column names are display metadata only.`})}),p}),...n.length?{warnings:n}:{}}}function $n(e){return Array.from(new Set(e.flatMap(t=>Object.keys(t)))).map(t=>({key:t,name:t,label:t}))}function On(e){return Object.values(e).flatMap(r=>Ve(r.warnings))}function Ve(e){return Array.isArray(e)?e.filter(Bn):[]}function Bn(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ar(...e){const r=new Set,t=[];for(const n of e.flatMap(s=>s||[])){const s=Kn(n);r.has(s)||(r.add(s),t.push(n))}return t}function Kn(e){return e.code==="missing_analysis_result_key"?[e.code,e.resultSetKey,e.rowIndex,e.columnKey].join(":"):$e(e)}function $e(e){if(!e||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t=>$e(t)).join(",")}]`;const r=e;return`{${Object.keys(r).sort().map(t=>`${JSON.stringify(t)}:${$e(r[t])}`).join(",")}}`}const Ae={value:null,primaryValue:null},ke={},Mn={records:[]},Te={options:[]},Wn={records:[]},Ee={};function _n(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs),t=w.toSemaphorAnalysisQueryOptions(e);try{const n=w.toSemaphorAnalysisIntent(e),s=U(n,"analysis");return s?{error:s,activeInputs:r,analysisOptions:t,queryKey:q(void 0,r,s,t),idleData:ke}:{intent:n,error:null,activeInputs:r,analysisOptions:t,queryKey:q(n,r,void 0,t),idleData:ke}}catch(n){const s=Q(n,"analysis");return{error:s,activeInputs:r,analysisOptions:t,queryKey:q(void 0,r,s,t),idleData:ke}}}function Nn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs);try{const t=w.toSemaphorMetricIntent(e),n=U(t);return n?{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Ae}:{intent:t,error:null,activeInputs:r,queryKey:q(t,r),idleData:Ae}}catch(t){const n=Q(t,"metric");return{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Ae}}}function Pn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs),t=Mn;try{const n=w.toSemaphorRecordsIntent(e),s=U(n);return s?{error:s,activeInputs:r,queryKey:q(void 0,r,s),idleData:t}:{intent:n,error:null,activeInputs:r,queryKey:q(n,r),idleData:t}}catch(n){const s=Q(n,"records");return{error:s,activeInputs:r,queryKey:q(void 0,r,s),idleData:t}}}function zn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs);try{const t=w.toSemaphorInputOptionsIntent(e),n=U(t);return n?{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Te}:{intent:t,error:null,activeInputs:r,queryKey:q(t,r),idleData:Te}}catch(t){const n=Q(t,"inputOptions");return{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Te}}}function Fn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs),t=Wn;try{const n=w.toSemaphorSqlIntent(e),s=U(n);return s?{error:s,activeInputs:r,queryKey:q(void 0,r,s),idleData:t}:{intent:n,error:null,activeInputs:r,queryKey:q(n,r),idleData:t}}catch(n){const s=Q(n,"sql");return{error:s,activeInputs:r,queryKey:q(void 0,r,s),idleData:t}}}function Hn(e){const r=w.toSemaphorActiveInputSnapshots(e.inputs);try{const t=w.toSemaphorMatrixIntent(e),n=U(t);return n?{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Ee}:{intent:t,error:null,activeInputs:r,queryKey:q(t,r),idleData:Ee}}catch(t){const n=Q(t,"matrix");return{error:n,activeInputs:r,queryKey:q(void 0,r,n),idleData:Ee}}}function Oe(e){var o;if(Vn(e))return e;const r=e instanceof Error?e:void 0,t=e,n=t==null?void 0:t.executionResult,s=be((r==null?void 0:r.message)??String(e),{requestId:typeof(t==null?void 0:t.requestId)=="string"?t.requestId:void 0,details:t==null?void 0:t.details,executionResult:n,validation:(t==null?void 0:t.validation)??(n==null?void 0:n.validation),validationIssues:(t==null?void 0:t.validationIssues)??((o=n==null?void 0:n.validation)==null?void 0:o.errors)});return s.name=(r==null?void 0:r.name)||s.name,s.stack=r==null?void 0:r.stack,s}function Q(e,r){const t=Oe(e);if(t.executionResult||t.validation)return t;const n={ok:!1,errors:[{code:"invalid_query_spec",message:t.message,path:"spec"}],warnings:[],repairHints:[{code:"invalid_query_spec",message:t.message,recommendedNextStep:"Update the Data App query spec to satisfy the SDK builder contract."}]},s=kr(void 0,r,n),o=be(t.message,{executionResult:s,validation:n,validationIssues:n.errors});return o.stack=t.stack,o}function be(e,r={}){var s,o,u;const t=new Error(e);t.name="SemaphorDataAppQueryError",t.kind="data_app_query_error",r.requestId&&(t.requestId=r.requestId),r.details!==void 0&&(t.details=r.details),r.executionResult!==void 0&&(t.executionResult=r.executionResult),r.validation!==void 0&&(t.validation=r.validation);const n=r.validationIssues??((s=r.validation)==null?void 0:s.errors)??((u=(o=r.executionResult)==null?void 0:o.validation)==null?void 0:u.errors);return n!==void 0&&(t.validationIssues=n),t}function Vn(e){return e instanceof Error&&e.kind==="data_app_query_error"}function U(e,r=e.kind){const t=$r.validateSemaphorAnalyticsIntent(e);if(t.ok)return null;const n=t.errors.map(o=>o.path?`${o.code} at ${o.path}: ${o.message}`:`${o.code}: ${o.message}`).join("; "),s=kr(e,r,t);return be(`Invalid Semaphor analytics intent. ${n}`,{executionResult:s,validation:t,validationIssues:t.errors})}function kr(e,r,t){return{...e!=null&&e.id?{intentId:e.id}:{},...e?{intent:e}:{},status:"failed",resultShape:r,validation:t,coverage:{answeredObligations:[],missingObligations:["query_spec_validation"],warnings:t.warnings},missingFields:t.errors.filter(n=>n.code==="missing_field").flatMap(n=>{var o;const s=n.path||((o=n.repairHint)==null?void 0:o.invalidField);return s?[s]:[]}),warnings:t.warnings.map(n=>n.message),diagnosticFeedback:{version:1,status:"blocked",summary:"Data App query spec validation failed.",answered:[],blocked:t.errors.map(n=>{var o,u;const s={reasonCode:"query_validation_failed",message:n.message};return n.code==="missing_field"&&(s.missingFields=[n.path||((o=n.repairHint)==null?void 0:o.invalidField)||n.message]),(u=n.repairHint)!=null&&u.recommendedNextStep&&(s.recommendedNextStep=n.repairHint.recommendedNextStep),s})},metadata:{validationKind:"data_app_sdk_query_spec"}}}function q(e,r,t,n){return JSON.stringify({intent:e,activeInputs:r,analysisOptions:n,error:t==null?void 0:t.message})}function Tr(){return{executeAnalysis:(e,r,t)=>F(e,r,t??{}).then(Cr),executeMetric:(e,r)=>F(e,r),executeRecords:(e,r)=>F(e,r),executeInputOptions:(e,r)=>F(e,r),executeSql:(e,r)=>F(e,r),executeMatrix:(e,r)=>F(e,r)}}async function F(e,r,t){if(!r.token)throw new Error("SemaphorDataAppProvider needs a token to execute queries.");const n=es(r),s=Gn(e,n);let o;try{o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r.token}`},body:JSON.stringify({intent:e,activeInputs:r.activeInputs,...t?{analysisOptions:t}:{},resultShape:e.kind,...Un(r)?{debug:{responseDetail:"debug"}}:{}})})}catch(p){throw new Error(`${s}: ${p instanceof Error?p.message:String(p)}`)}const u=await Xn(o);if(!o.ok||u.error)throw Qn(`${s}: ${u.error||`Semaphor Data App execution failed with status ${o.status}.`}`,u);return u}function Qn(e,r){var t;return be(e,{requestId:r.requestId,details:r.details,executionResult:r.executionResult,validation:(t=r.executionResult)==null?void 0:t.validation})}function Un(e){const r=e.debug;return r?r===!0?!0:r.enabled!==!1&&r.requestServerDebug!==!1:!1}function Gn(e,r){return[`Semaphor ${e.kind} query`,e.id?`id=${e.id}`:void 0,e.label?`label=${e.label}`:void 0,Jn(e),`endpoint=${Yn(r)}`].filter(t=>!!t).join(" ")}function Jn(e){const r="source"in e?e.source:void 0;if(!(!r||typeof r!="object")){if(r.kind==="semantic")return`source=${[r.domainId,r.datasetId||r.datasetName].filter(Boolean).join("/")}`;if(r.kind==="physical")return`source=${[r.connectionId,r.databaseName,r.schemaName,r.tableName].filter(Boolean).join("/")}`;if(r.kind==="sql")return r.connectionId?`source=${r.connectionId}`:void 0}}function Yn(e){if(!e)return"/api/v1/data-app/execute";try{return new URL(e,"http://localhost").pathname}catch{return e}}async function Xn(e){const r=await e.text().catch(()=>"");if(!r.trim())return e.ok?{error:"Semaphor Data App execution returned an empty response."}:{};try{return JSON.parse(r)}catch{return e.ok?{error:"Semaphor Data App execution returned invalid JSON.",details:r}:{error:Zn(e,r),details:r}}}function Zn(e,r){const t=e.statusText?` ${e.statusText}`:"",n=r.replace(/\s+/g," ").trim();return n?`Semaphor Data App execution failed with status ${e.status}${t}: ${n.slice(0,240)}`:`Semaphor Data App execution failed with status ${e.status}${t}.`}function es(e){const r=rs(e).replace(/\/+$/,"");return r?r.endsWith("/api")?`${r}/v1/data-app/execute`:`${r}/api/v1/data-app/execute`:"/api/v1/data-app/execute"}function rs(e){if(e.apiBaseUrl)return e.apiBaseUrl;if(!e.token)return"";try{return Ke.jwtDecode(e.token).apiServiceUrl||""}catch{return""}}const Er=c.createContext({});function ts(){if(!(typeof window>"u"))return window.__SEMAPHOR_DATA_APP_RUNTIME__}function ns(){return c.useContext(Er)}function ss(e){const[r,t]=c.useState(e.defaultValue),n=Object.prototype.hasOwnProperty.call(e,"value"),s=n?e.value:r,o=c.useMemo(()=>w.normalizeSemaphorInputOptions(e.options),[e.options]),u=c.useCallback(d=>{var y;const f=d;(y=e.onValueChange)==null||y.call(e,f),n||t(f)},[n,e]),p=c.useCallback(()=>u(void 0),[u]);return c.useMemo(()=>{const d=w.toSemaphorInputSpec(e);return{id:e.id,kind:e.kind,label:e.label,field:d.field,operator:d.operator,relationshipHint:d.relationshipHint,controlRole:e.kind==="control"?e.role:void 0,value:s,options:o,isActive:w.hasSemaphorInputValue(s),setValue:u,clear:p,toAnalyticsInput:()=>({inputId:d.inputId,field:d.field,kind:e.kind,label:e.label,value:s,isActive:w.hasSemaphorInputValue(s),operator:d.operator,relationshipHint:d.relationshipHint,controlRole:e.kind==="control"?e.role:void 0})}},[p,o,u,e,s])}function is(e){const[r,t]=c.useState(()=>ps(e));return c.useEffect(()=>{t(n=>{let s=n;for(const o of e)!Object.prototype.hasOwnProperty.call(s,o.id)&&o.defaultValue!==void 0&&(s={...s,[o.id]:o.defaultValue});return s})},[e]),c.useMemo(()=>e.map(n=>{const s=Object.prototype.hasOwnProperty.call(n,"value"),o=s?n.value:r[n.id],u=w.normalizeSemaphorInputOptions(n.options),p=y=>{var m;(m=n.onValueChange)==null||m.call(n,y),s||t(v=>({...v,[n.id]:y}))},d=()=>p(void 0),f=w.toSemaphorInputSpec(n);return{id:n.id,kind:n.kind,label:n.label,field:f.field,operator:f.operator,relationshipHint:f.relationshipHint,controlRole:n.kind==="control"?n.role:void 0,value:o,options:u,isActive:w.hasSemaphorInputValue(o),setValue:p,clear:d,toAnalyticsInput:()=>({inputId:f.inputId,field:f.field,kind:n.kind,label:n.label,value:o,isActive:w.hasSemaphorInputValue(o),operator:f.operator,relationshipHint:f.relationshipHint,controlRole:n.kind==="control"?n.role:void 0})}}),[e,r])}function os(e,r){const t=(r==null?void 0:r.status)==="success"?r.options:void 0,n=c.useMemo(()=>as(t),[t]);c.useEffect(()=>{Rr(e.value,t)||e.clear()},[e,n,r==null?void 0:r.status,t])}function Rr(e,r){if(!w.hasSemaphorInputValue(e)||r===void 0)return!0;const t=new Set(r.map(s=>lr(s.value)));return(Array.isArray(e)?e:[e]).every(s=>t.has(lr(s)))}function as(e){return JSON.stringify((e||[]).map(r=>r.value))}function lr(e){return`${typeof e}:${String(e)}`}function ls(e,r={}){const t=c.useMemo(()=>r.inputs?{...e,inputs:r.inputs}:e,[r.inputs,e]),n=c.useMemo(()=>{switch(t.queryKind){case"metric":return{queryKind:t.queryKind,request:Nn(t)};case"analysis":return{queryKind:t.queryKind,request:_n(t)};case"records":return{queryKind:t.queryKind,request:Pn(t)};case"inputOptions":return{queryKind:t.queryKind,request:zn(t)};case"sql":return{queryKind:t.queryKind,request:Fn(t)};case"matrix":return{queryKind:t.queryKind,request:Hn(t)};default:return ge(t)}},[t]),s=pt({spec:t,queryKind:n.queryKind,queryKey:n.request.queryKey,intent:n.request.intent,activeInputs:n.request.activeInputs,debug:r.debug}),o=c.useRef(null),u=c.useMemo(()=>({start:s.start,success:s.success,failure:s.failure,ignored:s.ignored}),[s.failure,s.ignored,s.start,s.success]),p=c.useCallback(l=>{var D,C,B,R,x,S,E,I,L;const b=n.request;if(b.intent)switch(n.queryKind){case"metric":return(D=l.executor)==null?void 0:D.executeMetric(b.intent,l);case"analysis":return(B=(C=l.executor)==null?void 0:C.executeAnalysis)==null?void 0:B.call(C,b.intent,l,b.analysisOptions);case"records":return(R=l.executor)==null?void 0:R.executeRecords(b.intent,l);case"inputOptions":return(x=l.executor)==null?void 0:x.executeInputOptions(b.intent,l);case"sql":return(E=(S=l.executor)==null?void 0:S.executeSql)==null?void 0:E.call(S,b.intent,l);case"matrix":return(L=(I=l.executor)==null?void 0:I.executeMatrix)==null?void 0:L.call(I,b.intent,l);default:return ge(n)}},[n]),d=fs(n.request.queryKey,p,n.request.idleData,n.request.activeInputs,u),f=s.queryId,y=s.validationFailure;c.useEffect(()=>{const l=n.request.error;if(!l){o.current=null;return}const b=`${f}:${l.message}`;o.current!==b&&(o.current=b,y(l))},[n.request.error,n.request.queryKey,f,y]);const m=n.request.error?n.request.idleData:d.data,v=n.request.error?"error":d.status,g=!n.request.error&&d.status==="loading",h=n.request.error||d.error,j=s.trace;switch(n.queryKind){case"metric":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,value:(l==null?void 0:l.value)??null,primaryValue:(l==null?void 0:l.primaryValue)??null,measures:l==null?void 0:l.measures,measureBindings:l==null?void 0:l.measureBindings,missingMeasures:l==null?void 0:l.missingMeasures,comparisonValue:l==null?void 0:l.comparisonValue,comparisonKind:l==null?void 0:l.comparisonKind,delta:l==null?void 0:l.delta,deltaPercent:l==null?void 0:l.deltaPercent,records:l==null?void 0:l.records,...b}}case"analysis":{const l=Cr(m),b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,...l||{},...b}}case"records":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,records:(l==null?void 0:l.records)||[],columns:l==null?void 0:l.columns,rowCount:l==null?void 0:l.rowCount,pagination:l==null?void 0:l.pagination,totals:l==null?void 0:l.totals,...b}}case"inputOptions":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,options:(l==null?void 0:l.options)||[],...b}}case"sql":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,records:(l==null?void 0:l.records)||[],columns:l==null?void 0:l.columns,rowCount:l==null?void 0:l.rowCount,pagination:l==null?void 0:l.pagination,output:l==null?void 0:l.output,rowLimitExceeded:l==null?void 0:l.rowLimitExceeded,...b}}case"matrix":{const l=m,b=H({queryKind:n.queryKind,status:v,isLoading:g,error:h,trace:j,payload:l,activeInputs:n.request.activeInputs,isStale:d.isStale});return{id:t.id,intent:n.request.intent,matrixResult:l==null?void 0:l.matrixResult,grid:l==null?void 0:l.grid,expansion:l==null?void 0:l.expansion,...b}}default:return ge(n)}}function H(e){var o,u,p;const r=ds(e.payload)??((o=e.error)==null?void 0:o.executionResult),t=((u=e.error)==null?void 0:u.validation)??(r==null?void 0:r.validation),n=r==null?void 0:r.coverage,s=r==null?void 0:r.diagnosticFeedback;return{status:e.status,executionStatus:r==null?void 0:r.status,executionResult:r,validation:t,coverage:n,diagnosticFeedback:s,isLoading:e.isLoading,isEmpty:cs(e.queryKind,e.payload,e.status),isPartial:us(e.payload,r),isFiltered:!!((p=e.activeInputs)!=null&&p.some(d=>d.kind==="filter"&&d.isActive)),isStale:e.isStale,isValidated:!!t,error:e.error,trace:e.trace}}function ds(e){const r=e;return r==null?void 0:r.executionResult}function us(e,r){var n,s;const t=!!(e!=null&&e.rowLimitExceeded);return!!((r==null?void 0:r.status)==="partial"||((n=r==null?void 0:r.diagnosticFeedback)==null?void 0:n.status)==="partial"||(r==null?void 0:r.status)!=="failed"&&((s=r==null?void 0:r.coverage)!=null&&s.missingObligations.length)||t)}function cs(e,r,t){var n,s,o,u,p;if(t!=="success")return!1;switch(e){case"metric":{const d=r;return(d==null?void 0:d.value)==null&&!O(d==null?void 0:d.records)}case"analysis":{const d=r;return d?!d.answerSummary&&!O(d.records)&&!O(d.changes)&&!O(d.drivers)&&!O(d.largestNegativeChanges)&&!O(d.largestPositiveChanges)&&!O(d.largestNegativeDrivers)&&!O(d.largestPositiveDrivers)&&!Object.values(d.resultSets||{}).some(f=>O(f.records)):!0}case"records":{const d=r;return!O(d==null?void 0:d.records)}case"sql":{const d=r;return!O(d==null?void 0:d.records)&&(d==null?void 0:d.output)===void 0}case"inputOptions":{const d=r;return!((n=d==null?void 0:d.options)!=null&&n.length)}case"matrix":{const d=r;return!((o=(s=d==null?void 0:d.matrixResult)==null?void 0:s.cells)!=null&&o.length)&&!((p=(u=d==null?void 0:d.grid)==null?void 0:u.cells)!=null&&p.length)}default:return ge(e)}}function O(e){return Array.isArray(e)&&e.length>0}function fs(e,r,t,n,s){const o=ns(),u=c.useRef(r),p=c.useRef(n),[d,f]=c.useState({status:"idle",data:t,error:null,isStale:!1});return u.current=r,p.current=n,c.useEffect(()=>{let y;try{y=u.current({...o,activeInputs:p.current})}catch(g){s==null||s.failure(g,0),f({status:"error",data:t,error:Oe(g),isStale:!1});return}if(!y){f({status:"idle",data:t,error:null,isStale:!1});return}let m=!1;const v=Lr();return s==null||s.start(),f(g=>({status:"loading",data:g.data,error:null,isStale:g.isStale||g.status==="success"})),y.then(g=>{m?s==null||s.ignored("superseded"):(s==null||s.success(g,dr(v)),f({status:"success",data:g,error:null,isStale:!1}))}).catch(g=>{m?s==null||s.ignored("superseded"):(s==null||s.failure(g,dr(v)),f({status:"error",data:t,error:Oe(g),isStale:!1}))}),()=>{m=!0}},[t,e,o,s]),d}function Lr(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}function dr(e){return Math.max(0,Math.round(Lr()-e))}function ps(e){return Object.fromEntries(e.filter(r=>r.defaultValue!==void 0).map(r=>[r.id,r.defaultValue]))}function ge(e){throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`)}function gs(e){return!e||typeof e=="boolean"||e.enabled===!1?null:e.autoRenderDevtools===!0?{}:e.autoRenderDevtools?e.autoRenderDevtools:null}function ms({token:e,apiBaseUrl:r,executor:t,debug:n,children:s}){var g;const o=ts(),u=((g=o==null?void 0:o.authToken)==null?void 0:g.accessToken)||e,p=(o==null?void 0:o.dataApiBaseUrl)||(o==null?void 0:o.apiBaseUrl)||r,d=(o==null?void 0:o.debug)??n,f=gs(d),y=c.useMemo(()=>Tr(),[]),m=t||y,v=c.useMemo(()=>({token:u,apiBaseUrl:p,executor:m,debug:d}),[p,d,m,u]);return i.jsx(lt,{debug:d,children:i.jsxs(Er.Provider,{value:v,children:[s,f?i.jsx(yr,{...f}):null]})})}exports.semaphorMetricMeasureBindingKey=Be.semaphorMetricMeasureBindingKey;exports.SemaphorDataAppProvider=ms;exports.SemaphorDevtools=yr;exports.SemaphorDevtoolsInspectButton=ft;exports.SemaphorViewBoundary=ct;exports.createSemaphorQueryExecutor=Tr;exports.defineSemaphorDataApp=Or;exports.defineSemaphorInput=Br;exports.isSemaphorInputValueValidForOptions=Rr;exports.semaphor=Kr;exports.useClearInvalidSemaphorInputValue=os;exports.useSemaphorDevtools=Pe;exports.useSemaphorInput=ss;exports.useSemaphorInputs=is;exports.useSemaphorQuery=ls;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { toSemaphorInputSnapshots as Pr, toSemaphorInputBinding as
|
|
1
|
+
import { toSemaphorInputSnapshots as Pr, toSemaphorInputBinding as Fr, toSemaphorActiveInputSnapshots as X, toSemaphorMatrixIntent as zr, toSemaphorSqlIntent as Mr, toSemaphorInputOptionsIntent as jr, toSemaphorRecordsIntent as Hr, toSemaphorAnalysisQueryOptions as Vr, toSemaphorAnalysisIntent as Qr, toSemaphorMetricIntent as Ur, hasSemaphorInputValue as ue, normalizeSemaphorInputOptions as gr, toSemaphorInputSpec as mr } from "../data-app-sdk-adapters/index.js";
|
|
2
2
|
import { jsxs as p, Fragment as yr, jsx as a } from "react/jsx-runtime";
|
|
3
|
-
import { createContext as Ie, useContext as Q, useState as
|
|
3
|
+
import { createContext as Ie, useContext as Q, useState as z, useRef as E, useEffect as B, useMemo as I, Fragment as Gr, useId as hr, useCallback as O, useReducer as Jr } from "react";
|
|
4
4
|
import { H as Yr, K as Xr } from "../chunks/analyze-result-contract-DdhEt99q.js";
|
|
5
5
|
import { L as ro } from "../chunks/analyze-result-contract-DdhEt99q.js";
|
|
6
6
|
import { M as Zr, a as et, S as rt, E as tt, C as nt } from "../chunks/search-BHsQIWBV.js";
|
|
@@ -57,7 +57,7 @@ const Hi = {
|
|
|
57
57
|
bindInput(e, r) {
|
|
58
58
|
return {
|
|
59
59
|
toAnalyticsInput() {
|
|
60
|
-
const [t] = Pr([e]), n =
|
|
60
|
+
const [t] = Pr([e]), n = Fr({
|
|
61
61
|
...r,
|
|
62
62
|
inputId: r.inputId || t.inputId
|
|
63
63
|
});
|
|
@@ -1558,7 +1558,7 @@ function $t({
|
|
|
1558
1558
|
Cn,
|
|
1559
1559
|
t,
|
|
1560
1560
|
Rr
|
|
1561
|
-
), o = E(n), u = hr(), [f, d] =
|
|
1561
|
+
), o = E(n), u = hr(), [f, d] = z({ open: !1 });
|
|
1562
1562
|
o.current = n, B(() => {
|
|
1563
1563
|
i({ type: "config", config: t });
|
|
1564
1564
|
}, [t]), B(() => {
|
|
@@ -1629,7 +1629,7 @@ function Bt({
|
|
|
1629
1629
|
className: n,
|
|
1630
1630
|
style: i
|
|
1631
1631
|
} = {}) {
|
|
1632
|
-
const o = qr(), u = Q(He), [f, d] =
|
|
1632
|
+
const o = qr(), u = Q(He), [f, d] = z(""), [c, y] = z(!1), m = E(null), v = E(null), g = u == null ? void 0 : u.openDevtools, h = u == null ? void 0 : u.closeDevtools, A = (u == null ? void 0 : u.open) === !0;
|
|
1633
1633
|
B(() => {
|
|
1634
1634
|
wr();
|
|
1635
1635
|
}, []), B(() => {
|
|
@@ -1769,7 +1769,7 @@ function Bt({
|
|
|
1769
1769
|
)
|
|
1770
1770
|
] }),
|
|
1771
1771
|
b.length ? /* @__PURE__ */ a(
|
|
1772
|
-
|
|
1772
|
+
Ft,
|
|
1773
1773
|
{
|
|
1774
1774
|
issues: b,
|
|
1775
1775
|
onSelect: (S) => u.focusTrace({
|
|
@@ -1819,7 +1819,7 @@ function Bt({
|
|
|
1819
1819
|
}),
|
|
1820
1820
|
children: [
|
|
1821
1821
|
/* @__PURE__ */ p("span", { style: s.queryListItemHeader, children: [
|
|
1822
|
-
/* @__PURE__ */ a(
|
|
1822
|
+
/* @__PURE__ */ a(zt, { status: (ne = w.latestAttempt) == null ? void 0 : ne.status }),
|
|
1823
1823
|
/* @__PURE__ */ a("span", { style: s.queryListTitle, title: x, children: x }),
|
|
1824
1824
|
/* @__PURE__ */ a(
|
|
1825
1825
|
"span",
|
|
@@ -2219,7 +2219,7 @@ function Nt({
|
|
|
2219
2219
|
label: "Raw",
|
|
2220
2220
|
render: () => /* @__PURE__ */ a("pre", { style: s.codeBlock, children: vn(e) })
|
|
2221
2221
|
});
|
|
2222
|
-
const u = (A = o[0]) == null ? void 0 : A.id, f = e.traceId || `${e.viewId ?? ""}:${e.queryId}`, [d, c] =
|
|
2222
|
+
const u = (A = o[0]) == null ? void 0 : A.id, f = e.traceId || `${e.viewId ?? ""}:${e.queryId}`, [d, c] = z(u), y = E(f), m = E(!1), v = o.map((l) => l.id).join("|");
|
|
2223
2223
|
B(() => {
|
|
2224
2224
|
if (y.current !== f) {
|
|
2225
2225
|
y.current = f, m.current = !1, c(u);
|
|
@@ -2276,11 +2276,11 @@ function or({
|
|
|
2276
2276
|
t.length > 1 ? /* @__PURE__ */ a("ul", { style: s.alertCardList, children: t.map((i, o) => /* @__PURE__ */ a("li", { children: i }, `${e}-${o}`)) }) : /* @__PURE__ */ a("div", { children: t[0] })
|
|
2277
2277
|
] });
|
|
2278
2278
|
}
|
|
2279
|
-
function
|
|
2279
|
+
function Ft({
|
|
2280
2280
|
issues: e,
|
|
2281
2281
|
onSelect: r
|
|
2282
2282
|
}) {
|
|
2283
|
-
const [t, n] =
|
|
2283
|
+
const [t, n] = z(!1), i = e.slice(0, 6), o = e.length - i.length, u = e.filter((c) => c.tone === "error").length, f = e.length - u, d = [
|
|
2284
2284
|
u ? `${u} error${u === 1 ? "" : "s"}` : "",
|
|
2285
2285
|
f ? `${f} warning${f === 1 ? "" : "s"}` : ""
|
|
2286
2286
|
].filter(Boolean);
|
|
@@ -2340,7 +2340,7 @@ function zt({
|
|
|
2340
2340
|
] })
|
|
2341
2341
|
] });
|
|
2342
2342
|
}
|
|
2343
|
-
function
|
|
2343
|
+
function zt({
|
|
2344
2344
|
status: e
|
|
2345
2345
|
}) {
|
|
2346
2346
|
return /* @__PURE__ */ a(
|
|
@@ -2373,7 +2373,13 @@ function Mt({
|
|
|
2373
2373
|
),
|
|
2374
2374
|
/* @__PURE__ */ a(H, { title: "Identifiers", fields: n.identifiers }),
|
|
2375
2375
|
/* @__PURE__ */ a(H, { title: "Other fields", fields: n.other }),
|
|
2376
|
-
/* @__PURE__ */ a(
|
|
2376
|
+
/* @__PURE__ */ a(
|
|
2377
|
+
H,
|
|
2378
|
+
{
|
|
2379
|
+
title: "Input bindings (Filters)",
|
|
2380
|
+
fields: t
|
|
2381
|
+
}
|
|
2382
|
+
)
|
|
2377
2383
|
] });
|
|
2378
2384
|
}
|
|
2379
2385
|
function jt({
|
|
@@ -2389,12 +2395,12 @@ function jt({
|
|
|
2389
2395
|
{
|
|
2390
2396
|
source: r
|
|
2391
2397
|
},
|
|
2392
|
-
`${
|
|
2398
|
+
`${F(r)}:${t}`
|
|
2393
2399
|
)) })
|
|
2394
2400
|
] }) : null;
|
|
2395
2401
|
}
|
|
2396
2402
|
function Ht({ source: e }) {
|
|
2397
|
-
const r =
|
|
2403
|
+
const r = F(e);
|
|
2398
2404
|
return /* @__PURE__ */ p("span", { style: s.sourcePill, title: r, children: [
|
|
2399
2405
|
/* @__PURE__ */ a("span", { style: s.sourcePillLabel, children: r }),
|
|
2400
2406
|
/* @__PURE__ */ a("span", { style: s.sourcePillRole, children: e.kind })
|
|
@@ -2450,13 +2456,13 @@ function Ut({
|
|
|
2450
2456
|
"div",
|
|
2451
2457
|
{
|
|
2452
2458
|
style: s.recipeFieldRow,
|
|
2453
|
-
title:
|
|
2459
|
+
title: F(r),
|
|
2454
2460
|
children: [
|
|
2455
|
-
/* @__PURE__ */ a("span", { style: s.recipeFieldName, children:
|
|
2461
|
+
/* @__PURE__ */ a("span", { style: s.recipeFieldName, children: F(r) }),
|
|
2456
2462
|
/* @__PURE__ */ a("span", { style: s.recipeFieldMeta, children: r.kind })
|
|
2457
2463
|
]
|
|
2458
2464
|
},
|
|
2459
|
-
`${
|
|
2465
|
+
`${F(r)}:${t}`
|
|
2460
2466
|
)) }) : /* @__PURE__ */ a("div", { style: s.recipeEmptyText, children: "No sources captured" })
|
|
2461
2467
|
] });
|
|
2462
2468
|
}
|
|
@@ -2484,7 +2490,7 @@ function Gt({
|
|
|
2484
2490
|
field: e,
|
|
2485
2491
|
groupTitle: r
|
|
2486
2492
|
}) {
|
|
2487
|
-
const t = gn(e), n = e.label || e.name, i = e.dataType && e.dataType !== "unknown" ? e.dataType : void 0, o = e.source ?
|
|
2493
|
+
const t = gn(e), n = e.label || e.name, i = e.dataType && e.dataType !== "unknown" ? e.dataType : void 0, o = e.source ? F(e.source) : void 0, u = [t, i, o].filter(Boolean).join(" · "), f = Jt(e, r);
|
|
2488
2494
|
return /* @__PURE__ */ p(
|
|
2489
2495
|
"div",
|
|
2490
2496
|
{
|
|
@@ -2546,7 +2552,7 @@ function Yt({
|
|
|
2546
2552
|
}) {
|
|
2547
2553
|
return /* @__PURE__ */ p("div", { style: s.inputsAppliedBlock, children: [
|
|
2548
2554
|
/* @__PURE__ */ p("div", { style: s.inputsAppliedHeader, children: [
|
|
2549
|
-
/* @__PURE__ */ a("span", { style: s.inputsAppliedTitle, children: "Active Inputs" }),
|
|
2555
|
+
/* @__PURE__ */ a("span", { style: s.inputsAppliedTitle, children: "Active Inputs (Active Filters)" }),
|
|
2550
2556
|
/* @__PURE__ */ a("span", { style: s.inputsAppliedCount, children: e.length })
|
|
2551
2557
|
] }),
|
|
2552
2558
|
/* @__PURE__ */ a("div", { style: s.inputRecipeList, children: e.map((r) => {
|
|
@@ -2798,7 +2804,7 @@ function cn(e) {
|
|
|
2798
2804
|
return e.replace(/[_-]+/g, " ").replace(/\b\w/g, (r) => r.toUpperCase());
|
|
2799
2805
|
}
|
|
2800
2806
|
function Er(e) {
|
|
2801
|
-
const r = e.sourceRefs.map(
|
|
2807
|
+
const r = e.sourceRefs.map(F);
|
|
2802
2808
|
return r.length ? r.length === 1 ? r[0] : `${r[0]} + ${r.length - 1} more` : "No source";
|
|
2803
2809
|
}
|
|
2804
2810
|
function fn(e) {
|
|
@@ -2839,7 +2845,7 @@ function gn(e) {
|
|
|
2839
2845
|
}
|
|
2840
2846
|
function mn(e) {
|
|
2841
2847
|
var f, d, c;
|
|
2842
|
-
const r = e.valuePreview || "redacted", t = e.inputLabel || e.inputId, n = ((f = e.fieldRef) == null ? void 0 : f.label) || ((d = e.fieldRef) == null ? void 0 : d.name), i = (c = e.fieldRef) != null && c.source ?
|
|
2848
|
+
const r = e.valuePreview || "redacted", t = e.inputLabel || e.inputId, n = ((f = e.fieldRef) == null ? void 0 : f.label) || ((d = e.fieldRef) == null ? void 0 : d.name), i = (c = e.fieldRef) != null && c.source ? F(e.fieldRef.source) : void 0, o = [n ? `on ${n}` : void 0, i].filter(Boolean).join(" · "), u = [
|
|
2843
2849
|
t,
|
|
2844
2850
|
e.inputId,
|
|
2845
2851
|
e.operator,
|
|
@@ -2855,7 +2861,7 @@ function mn(e) {
|
|
|
2855
2861
|
title: u
|
|
2856
2862
|
};
|
|
2857
2863
|
}
|
|
2858
|
-
function
|
|
2864
|
+
function F(e) {
|
|
2859
2865
|
return e.kind === "semantic" ? e.datasetName || e.datasetId || e.domainId : e.kind === "physical" ? [
|
|
2860
2866
|
e.schemaName,
|
|
2861
2867
|
e.tableName
|
|
@@ -3047,7 +3053,7 @@ function $n(e) {
|
|
|
3047
3053
|
}
|
|
3048
3054
|
function Lr(e) {
|
|
3049
3055
|
var n;
|
|
3050
|
-
const r =
|
|
3056
|
+
const r = Fn(e.spec), t = zn(
|
|
3051
3057
|
e.spec,
|
|
3052
3058
|
e.activeInputs
|
|
3053
3059
|
);
|
|
@@ -3228,7 +3234,7 @@ function Pn(e) {
|
|
|
3228
3234
|
jn(t) && r.push(t);
|
|
3229
3235
|
}), Xr(r);
|
|
3230
3236
|
}
|
|
3231
|
-
function
|
|
3237
|
+
function Fn(e) {
|
|
3232
3238
|
switch (e.queryKind) {
|
|
3233
3239
|
case "metric":
|
|
3234
3240
|
case "analysis":
|
|
@@ -3259,7 +3265,7 @@ function zn(e) {
|
|
|
3259
3265
|
return qe(e);
|
|
3260
3266
|
}
|
|
3261
3267
|
}
|
|
3262
|
-
function
|
|
3268
|
+
function zn(e, r) {
|
|
3263
3269
|
const t = [
|
|
3264
3270
|
...(e.inputs || []).map($r),
|
|
3265
3271
|
...(r || []).map((n) => n.field)
|
|
@@ -3564,15 +3570,15 @@ function si(e) {
|
|
|
3564
3570
|
e.resultSetKey,
|
|
3565
3571
|
e.rowIndex,
|
|
3566
3572
|
e.columnKey
|
|
3567
|
-
].join(":") :
|
|
3573
|
+
].join(":") : Fe(e);
|
|
3568
3574
|
}
|
|
3569
|
-
function
|
|
3575
|
+
function Fe(e) {
|
|
3570
3576
|
if (!e || typeof e != "object")
|
|
3571
3577
|
return JSON.stringify(e);
|
|
3572
3578
|
if (Array.isArray(e))
|
|
3573
|
-
return `[${e.map((t) =>
|
|
3579
|
+
return `[${e.map((t) => Fe(t)).join(",")}]`;
|
|
3574
3580
|
const r = e;
|
|
3575
|
-
return `{${Object.keys(r).sort().map((t) => `${JSON.stringify(t)}:${
|
|
3581
|
+
return `{${Object.keys(r).sort().map((t) => `${JSON.stringify(t)}:${Fe(r[t])}`).join(",")}}`;
|
|
3576
3582
|
}
|
|
3577
3583
|
const Oe = {
|
|
3578
3584
|
value: null,
|
|
@@ -3724,7 +3730,7 @@ function pi(e) {
|
|
|
3724
3730
|
function gi(e) {
|
|
3725
3731
|
const r = X(e.inputs);
|
|
3726
3732
|
try {
|
|
3727
|
-
const t =
|
|
3733
|
+
const t = zr(e), n = ee(t);
|
|
3728
3734
|
return n ? {
|
|
3729
3735
|
error: n,
|
|
3730
3736
|
activeInputs: r,
|
|
@@ -3747,7 +3753,7 @@ function gi(e) {
|
|
|
3747
3753
|
};
|
|
3748
3754
|
}
|
|
3749
3755
|
}
|
|
3750
|
-
function
|
|
3756
|
+
function ze(e) {
|
|
3751
3757
|
var o;
|
|
3752
3758
|
if (mi(e))
|
|
3753
3759
|
return e;
|
|
@@ -3764,7 +3770,7 @@ function Fe(e) {
|
|
|
3764
3770
|
return i.name = (r == null ? void 0 : r.name) || i.name, i.stack = r == null ? void 0 : r.stack, i;
|
|
3765
3771
|
}
|
|
3766
3772
|
function Z(e, r) {
|
|
3767
|
-
const t =
|
|
3773
|
+
const t = ze(e);
|
|
3768
3774
|
if (t.executionResult || t.validation)
|
|
3769
3775
|
return t;
|
|
3770
3776
|
const n = {
|
|
@@ -4017,7 +4023,7 @@ function Ci() {
|
|
|
4017
4023
|
return Q(Wr);
|
|
4018
4024
|
}
|
|
4019
4025
|
function Ui(e) {
|
|
4020
|
-
const [r, t] =
|
|
4026
|
+
const [r, t] = z(e.defaultValue), n = Object.prototype.hasOwnProperty.call(e, "value"), i = n ? e.value : r, o = I(
|
|
4021
4027
|
() => gr(e.options),
|
|
4022
4028
|
[e.options]
|
|
4023
4029
|
), u = O(
|
|
@@ -4058,7 +4064,7 @@ function Ui(e) {
|
|
|
4058
4064
|
}, [f, o, u, e, i]);
|
|
4059
4065
|
}
|
|
4060
4066
|
function Gi(e) {
|
|
4061
|
-
const [r, t] =
|
|
4067
|
+
const [r, t] = z(() => Oi(e));
|
|
4062
4068
|
return B(() => {
|
|
4063
4069
|
t((n) => {
|
|
4064
4070
|
let i = n;
|
|
@@ -4461,7 +4467,7 @@ function _(e) {
|
|
|
4461
4467
|
return Array.isArray(e) && e.length > 0;
|
|
4462
4468
|
}
|
|
4463
4469
|
function Di(e, r, t, n, i) {
|
|
4464
|
-
const o = Ci(), u = E(r), f = E(n), [d, c] =
|
|
4470
|
+
const o = Ci(), u = E(r), f = E(n), [d, c] = z({
|
|
4465
4471
|
status: "idle",
|
|
4466
4472
|
data: t,
|
|
4467
4473
|
error: null,
|
|
@@ -4478,7 +4484,7 @@ function Di(e, r, t, n, i) {
|
|
|
4478
4484
|
i == null || i.failure(g, 0), c({
|
|
4479
4485
|
status: "error",
|
|
4480
4486
|
data: t,
|
|
4481
|
-
error:
|
|
4487
|
+
error: ze(g),
|
|
4482
4488
|
isStale: !1
|
|
4483
4489
|
});
|
|
4484
4490
|
return;
|
|
@@ -4500,7 +4506,7 @@ function Di(e, r, t, n, i) {
|
|
|
4500
4506
|
m ? i == null || i.ignored("superseded") : (i == null || i.failure(g, pr(v)), c({
|
|
4501
4507
|
status: "error",
|
|
4502
4508
|
data: t,
|
|
4503
|
-
error:
|
|
4509
|
+
error: ze(g),
|
|
4504
4510
|
isStale: !1
|
|
4505
4511
|
}));
|
|
4506
4512
|
}), () => {
|