react-semaphor 0.0.312 → 0.0.313
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{index-C3nDeUKb.js → index-6-OHYvoS.js} +2 -2
- package/dist/chunks/{index-Q404IERU.js → index-BTonSpSL.js} +1 -1
- package/dist/chunks/{index-5TRXjSsj.js → index-CQJxYR8z.js} +1548 -1552
- package/dist/chunks/{index-DHFxECHD.js → index-CtrJ6W5f.js} +2 -2
- package/dist/chunks/{lucide-react-BWhJMZ64.js → lucide-react-BmrZWURY.js} +3 -3
- package/dist/chunks/{lucide-react-BlblZidB.js → lucide-react-C5W0mSbU.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/package.json +1 -1
|
@@ -235,7 +235,7 @@ Valid keys: `+JSON.stringify(Object.keys(k),null," "));var ie=ge(J,ce,ee,q,oe+"
|
|
|
235
235
|
* This source code is licensed under the ISC license.
|
|
236
236
|
* See the LICENSE file in the root directory of this source tree.
|
|
237
237
|
*/const Cd=Nn("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),lee=({data:e,filename:t="output.csv"})=>{const n=()=>{if(e.length===0)return;const r=[],i=Object.keys(e[0]);r.push(i.join(","));for(const c of e){const u=i.map(d=>`"${(""+c[d]).replace(/"/g,'""')}"`);r.push(u.join(","))}const o=r.join(`
|
|
238
|
-
`),s=new Blob([o],{type:"text/csv"}),a=window.URL.createObjectURL(s),l=document.createElement("a");l.setAttribute("hidden",""),l.setAttribute("href",a),l.setAttribute("download",t),document.body.appendChild(l),l.click(),document.body.removeChild(l)};return v.jsx(U5,{onClick:n,className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})};function e4({frame:e}){var _;const t=ye(C=>C.isDashboardEditing),n=ye(C=>C.filterValues),r=ye(C=>C.isVisualEditing),i=ye(C=>C.selectedSheetId);ye(C=>C.currentBreakpoint);const{removeFrame:o}=ye(C=>C.actions),s=ye(C=>C.actions.setIsVisualEditing),a=Ur(C=>C.actions.setFilterValues),l=Ur(C=>C.actions.setApplyFilters),{setCard:c,setFrame:u,setQueryResultColumns:d}=Ur(C=>C.actions),p=Ur(C=>C.actions.setSelectedConnectionId),h=Ur(C=>C.actions.setSelectedDatamodelId),m=Ur(C=>C.actions.setSelectedDatabaseName),b=Ur(C=>C.actions.setSelectedSchemaName),x=Ur(C=>C.actions.setSelectedTableName),y=e.cards.find(C=>C.id===e.activeCardId);function S(){s(!r),c(y);const{dimensionKeys:C}=or((y==null?void 0:y.data)||[]);d(C),u(e),y!=null&&y.connectionId&&p(y==null?void 0:y.connectionId),y!=null&&y.datamodelId&&y.datamodelId!=="none"&&(h(y==null?void 0:y.datamodelId),m("")),y!=null&&y.lastSelectedDatabase&&y.lastSelectedDatabase!=="none"&&(m(y==null?void 0:y.lastSelectedDatabase),h("")),y!=null&&y.lastSelectedSchema&&b(y==null?void 0:y.lastSelectedSchema),y!=null&&y.lastSelectedTable&&x(y==null?void 0:y.lastSelectedTable),n&&(a(n),l(!0))}return v.jsx("section",{className:"absolute right-2 top-2 z-10",children:v.jsxs("div",{className:"flex items-center gap-2",children:[t&&(r?v.jsx(NZ,{onClick:()=>{s(!r)},className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"}):v.jsx(FZ,{role:"edit-visual",onClick:S,className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})),t&&v.jsx(F5,{onClick:()=>o(i,e.id),className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"}),((_=y.preferences)==null?void 0:_.allowDownload)===!0&&v.jsx(lee,{data:(y==null?void 0:y.data)||[],filename:y.title})]})})}function cee(e,t){ye(s=>s.selectedSheetId);const n=ye(s=>s.selectedFrameId),r=ye(s=>s.isDashboardEditing),i=ye(s=>s.isVisualEditing);ye(s=>s.actions),P.useEffect(()=>{n===e.id&&r&&!i&&o()},[n,e.id,r,i]);function o(){const s=t==null?void 0:t.current;s==null||s.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}}const uee=P.createContext(null),Ax={didCatch:!1,error:null};class qy extends P.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Ax}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:o,reason:"imperative-api"}),this.setState(Ax)}}componentDidCatch(t,n){var r,i;(r=(i=this.props).onError)===null||r===void 0||r.call(i,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:i}=this.props;if(r&&n.error!==null&&dee(t.resetKeys,i)){var o,s;(o=(s=this.props).onReset)===null||o===void 0||o.call(s,{next:i,prev:t.resetKeys,reason:"keys"}),this.setState(Ax)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:i}=this.props,{didCatch:o,error:s}=this.state;let a=t;if(o){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=P.createElement(r,l);else if(i!==void 0)a=i;else throw s}return P.createElement(uee.Provider,{value:{didCatch:o,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function dee(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function IC({error:e}){return v.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{height:"100%"},children:v.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md bg-muted p-10",children:[v.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),v.jsx("p",{className:"text-sm",children:"Something went wrong:"}),v.jsx("pre",{className:"text-xs",children:e.message})]})})}function fee({error:e,frame:t}){return v.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[v.jsx(e4,{frame:t}),v.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),v.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[v.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),v.jsx("p",{className:"text-sm",children:"Something went wrong:"}),v.jsx("pre",{className:"text-xs",children:e.message})]})]})}function hee({error:e}){return v.jsxs("div",{className:"flex h-full flex-col items-center justify-center",role:"alert",children:[v.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),v.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[v.jsx("p",{className:"text-lg font-semibold",children:"Oops! Something went wrong!"}),v.jsx("p",{className:"text-sm",children:"Something went wrong:"}),v.jsx("pre",{className:"text-xs",children:e.message})]})]})}var ed=1e3,td=ed*60,nd=td*60,pc=nd*24,pee=pc*7,gee=pc*365.25,mee=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return bee(e);if(n==="number"&&isFinite(e))return t.long?vee(e):yee(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function bee(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*gee;case"weeks":case"week":case"w":return n*pee;case"days":case"day":case"d":return n*pc;case"hours":case"hour":case"hrs":case"hr":case"h":return n*nd;case"minutes":case"minute":case"mins":case"min":case"m":return n*td;case"seconds":case"second":case"secs":case"sec":case"s":return n*ed;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function yee(e){var t=Math.abs(e);return t>=pc?Math.round(e/pc)+"d":t>=nd?Math.round(e/nd)+"h":t>=td?Math.round(e/td)+"m":t>=ed?Math.round(e/ed)+"s":e+"ms"}function vee(e){var t=Math.abs(e);return t>=pc?qg(e,t,pc,"day"):t>=nd?qg(e,t,nd,"hour"):t>=td?qg(e,t,td,"minute"):t>=ed?qg(e,t,ed,"second"):e+" ms"}function qg(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+" "+r+(i?"s":"")}const xee=Pc(mee);function wee(e){const t=ye(u=>u.selectedSheetId),n=ye(u=>u.selectedLensId),r=ye(u=>u.dashboard.baseQueries),i=ye(u=>u.dashboard.filters),o=ye(u=>u.filterValues),s=i==null?void 0:i.filter(u=>u.sheetId===t||!u.sheetId),a=o==null?void 0:o.filter(u=>(s==null?void 0:s.some(d=>d.id===u.filterId))||u.filterId.endsWith(t)),l=GY(e.sql,r);return{queryKey:["query",e.id,l,n||"",JSON.stringify(a)],sql:l,sheetFilterValues:a}}function Yy(e,t){const{authToken:n}=Hi(),r=ye(d=>d.isVisualEditing),i=ye(d=>d.authToken),o=xee((e==null?void 0:e.refreshInterval)||"0"),{queryKey:s,sql:a,sheetFilterValues:l}=wee(e);return{...pp({queryKey:s,queryFn:()=>yy("https://semaphor.cloud/api/v1/query",(n==null?void 0:n.accessToken)||(i==null?void 0:i.accessToken)||"",{connection_id:e.connectionId,sql:a,python:e.python===aN?"":e.python,active_filters:l,cache_config:U_()}),refetchInterval:o,placeholderData:NK,enabled:!!e.connectionId&&!!e.sql&&!0&&!r}),queryKey:s}}function Qs({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:i="",locale:o="en-US"}){let s=1,a=r,l=o;const c=t;n&&!r&&(e>=1e9?(s=1e9,a="B"):e>=1e7&&o==="en-IN"?(s=1e7,a="Cr"):e>=1e5&&o==="en-IN"?(s=1e5,a="L"):e>=1e6?(s=1e6,a="M"):e>=1e3&&(s=1e3,a="K"));const u=e/s,d={maximumFractionDigits:c,minimumFractionDigits:c};if(i){d.style="currency",d.currency=i;try{new Intl.NumberFormat(o,d).format(0)}catch{}}try{new Intl.NumberFormat(o,d).format(0)}catch{l="en-US"}let h=new Intl.NumberFormat(l,d).format(u);return n&&(h+=a),h}function kC(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function t4(e){try{const n=new Function("getDatalabelColor",e)(x1);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function n4(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return See(t)}function See(e){const[t,n,r]=e.split(" "),i=parseFloat(t),o=parseFloat(n),s=parseFloat(r),a=o/100,l=s/100,c=(1-Math.abs(2*l-1))*a,u=c*(1-Math.abs(i/60%2-1)),d=l-c/2;let p=0,h=0,m=0;0<=i&&i<60?(p=c,h=u,m=0):60<=i&&i<120?(p=u,h=c,m=0):120<=i&&i<180?(p=0,h=c,m=u):180<=i&&i<240?(p=0,h=u,m=c):240<=i&&i<300?(p=u,h=0,m=c):300<=i&&i<360&&(p=c,h=0,m=u),p=Math.round((p+d)*255),h=Math.round((h+d)*255),m=Math.round((m+d)*255);const b=x=>{const y=x.toString(16);return y.length==1?"0"+y:y};return`#${b(p)}${b(h)}${b(m)}`}function vl({data:e,cfg:t,customCfg:n,preferences:r}){ye.getState().themeStyle;const{dimensionKeys:i,metricKeys:o}=or(e),s=ZZ(o,e,r),a=kf(s,n),l=i[0],c=K1(e,l);NC(r,t),r4(r);const{options:u,plugins:d}=o4({cfg:t,preferences:r,customCfg:n});return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:c,datasets:a},options:u,plugins:d}}function NC(e,t){var i,o,s;const n=((i=t==null?void 0:t.options)==null?void 0:i.indexAxis)==="y"?"x":"y";return(o=e==null?void 0:e.chartOptions)!=null&&o.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function r4(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function i4(e,t){var o,s,a,l,c,u,d,p,h,m,b,x;const n=NC(t,e),r=r4(t);return{...e==null?void 0:e.options,scales:{...(o=e==null?void 0:e.options)==null?void 0:o.scales,[n]:{...(a=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:a[n],ticks:{...(u=(c=(l=e==null?void 0:e.options)==null?void 0:l.scales)==null?void 0:c[n])==null?void 0:u.ticks,callback:y=>{var S,_,C,R;return Qs({number:Number(y),decimalPlaces:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.decimalPlaces)||0,useSuffix:!!((_=t==null?void 0:t.numberAxisFormat)!=null&&_.suffix),customSuffix:"",locale:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.locale)||"",currency:((R=t==null?void 0:t.numberAxisFormat)==null?void 0:R.currency)||""})}}},[r]:{...(h=(p=(d=e==null?void 0:e.options)==null?void 0:d.scales)==null?void 0:p[r])==null?void 0:h.ticks,callback:null}},plugins:{...(m=e==null?void 0:e.options)==null?void 0:m.plugins,datalabels:{...(x=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:x.datalabels,formatter:function(y){var S,_,C,R;return Qs({number:Number(y),decimalPlaces:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.decimalPlaces)||0,useSuffix:!!((_=t==null?void 0:t.numberAxisFormat)!=null&&_.suffix),customSuffix:"",locale:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.locale)||"",currency:((R=t==null?void 0:t.numberAxisFormat)==null?void 0:R.currency)||""})}}}}}function o4({cfg:e,preferences:t,customCfg:n}){var p,h,m,b,x,y,S,_,C,R,M,D,A,I,F,j,$,K,H,L,W,B,U,Y,k,Q,G,O,ee;const r=ye.getState().themeStyle,i=i4(e,t),o=no((e==null?void 0:e.options)||{},t==null?void 0:t.chartOptions),s=no(i,o),a=no(s,(n==null?void 0:n.options)||{}),l={...a,scales:{...a==null?void 0:a.scales,x:{...(p=a==null?void 0:a.scales)==null?void 0:p.x,grid:{...(m=(h=a==null?void 0:a.scales)==null?void 0:h.x)==null?void 0:m.grid,color:(_=(S=(y=(x=(b=r==null?void 0:r.chart)==null?void 0:b.options)==null?void 0:x.scales)==null?void 0:y.x)==null?void 0:S.grid)==null?void 0:_.color}},y:{...(C=a==null?void 0:a.scales)==null?void 0:C.y,grid:{...(M=(R=a==null?void 0:a.scales)==null?void 0:R.y)==null?void 0:M.grid,color:(j=(F=(I=(A=(D=r==null?void 0:r.chart)==null?void 0:D.options)==null?void 0:A.scales)==null?void 0:I.y)==null?void 0:F.grid)==null?void 0:j.color}}},plugins:{...a==null?void 0:a.plugins,tooltip:{...($=a==null?void 0:a.plugins)==null?void 0:$.tooltip,backgroundColor:(W=(L=(H=(K=r==null?void 0:r.chart)==null?void 0:K.options)==null?void 0:H.plugins)==null?void 0:L.tooltip)==null?void 0:W.backgroundColor,bodyColor:(k=(Y=(U=(B=r==null?void 0:r.chart)==null?void 0:B.options)==null?void 0:U.plugins)==null?void 0:Y.tooltip)==null?void 0:k.bodyColor,titleColor:(ee=(O=(G=(Q=r==null?void 0:r.chart)==null?void 0:Q.options)==null?void 0:G.plugins)==null?void 0:O.tooltip)==null?void 0:ee.titleColor}}},{plugins:c,options:u}=t4((t==null?void 0:t.customVisualCode)||"");return{options:no(l,u),plugins:c}}/*!
|
|
238
|
+
`),s=new Blob([o],{type:"text/csv"}),a=window.URL.createObjectURL(s),l=document.createElement("a");l.setAttribute("hidden",""),l.setAttribute("href",a),l.setAttribute("download",t),document.body.appendChild(l),l.click(),document.body.removeChild(l)};return v.jsx(U5,{onClick:n,className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})};function e4({frame:e}){var _;const t=ye(C=>C.isDashboardEditing),n=ye(C=>C.filterValues),r=ye(C=>C.isVisualEditing),i=ye(C=>C.selectedSheetId);ye(C=>C.currentBreakpoint);const{removeFrame:o}=ye(C=>C.actions),s=ye(C=>C.actions.setIsVisualEditing),a=Ur(C=>C.actions.setFilterValues),l=Ur(C=>C.actions.setApplyFilters),{setCard:c,setFrame:u,setQueryResultColumns:d}=Ur(C=>C.actions),p=Ur(C=>C.actions.setSelectedConnectionId),h=Ur(C=>C.actions.setSelectedDatamodelId),m=Ur(C=>C.actions.setSelectedDatabaseName),b=Ur(C=>C.actions.setSelectedSchemaName),x=Ur(C=>C.actions.setSelectedTableName),y=e.cards.find(C=>C.id===e.activeCardId);function S(){s(!r),c(y);const{dimensionKeys:C}=or((y==null?void 0:y.data)||[]);d(C),u(e),y!=null&&y.connectionId&&p(y==null?void 0:y.connectionId),y!=null&&y.datamodelId&&y.datamodelId!=="none"&&(h(y==null?void 0:y.datamodelId),m("")),y!=null&&y.lastSelectedDatabase&&y.lastSelectedDatabase!=="none"&&(m(y==null?void 0:y.lastSelectedDatabase),h("")),y!=null&&y.lastSelectedSchema&&b(y==null?void 0:y.lastSelectedSchema),y!=null&&y.lastSelectedTable&&x(y==null?void 0:y.lastSelectedTable),n&&(a(n),l(!0))}return v.jsx("section",{onMouseDown:C=>{C.stopPropagation()},className:"absolute right-2 top-2",children:v.jsxs("div",{className:"flex items-center gap-2",children:[t&&(r?v.jsx("button",{onClick:()=>{s(!r)},children:v.jsx(NZ,{className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}):v.jsx("button",{role:"edit-visual",onClick:S,children:v.jsx(FZ,{className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})})),t&&v.jsx("button",{onClick:()=>o(i,e.id),children:v.jsx(F5,{className:"h-[14px] w-[14px] text-foreground/30 hover:cursor-pointer hover:text-foreground/50"})}),((_=y.preferences)==null?void 0:_.allowDownload)===!0&&v.jsx(lee,{data:(y==null?void 0:y.data)||[],filename:y.title})]})})}function cee(e,t){ye(s=>s.selectedSheetId);const n=ye(s=>s.selectedFrameId),r=ye(s=>s.isDashboardEditing),i=ye(s=>s.isVisualEditing);ye(s=>s.actions),P.useEffect(()=>{n===e.id&&r&&!i&&o()},[n,e.id,r,i]);function o(){const s=t==null?void 0:t.current;s==null||s.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}}const uee=P.createContext(null),Ax={didCatch:!1,error:null};class qy extends P.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Ax}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:o,reason:"imperative-api"}),this.setState(Ax)}}componentDidCatch(t,n){var r,i;(r=(i=this.props).onError)===null||r===void 0||r.call(i,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:i}=this.props;if(r&&n.error!==null&&dee(t.resetKeys,i)){var o,s;(o=(s=this.props).onReset)===null||o===void 0||o.call(s,{next:i,prev:t.resetKeys,reason:"keys"}),this.setState(Ax)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:i}=this.props,{didCatch:o,error:s}=this.state;let a=t;if(o){const l={error:s,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(l);else if(r)a=P.createElement(r,l);else if(i!==void 0)a=i;else throw s}return P.createElement(uee.Provider,{value:{didCatch:o,error:s,resetErrorBoundary:this.resetErrorBoundary}},a)}}function dee(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function IC({error:e}){return v.jsx("div",{className:"flex flex-col items-center justify-center",role:"alert",style:{height:"100%"},children:v.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md bg-muted p-10",children:[v.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),v.jsx("p",{className:"text-sm",children:"Something went wrong:"}),v.jsx("pre",{className:"text-xs",children:e.message})]})})}function fee({error:e,frame:t}){return v.jsxs("div",{className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[v.jsx(e4,{frame:t}),v.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),v.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[v.jsx("p",{className:"text-lg font-semibold",children:"Oops! Looks like we tripped on a loose wire!"}),v.jsx("p",{className:"text-sm",children:"Something went wrong:"}),v.jsx("pre",{className:"text-xs",children:e.message})]})]})}function hee({error:e}){return v.jsxs("div",{className:"flex h-full flex-col items-center justify-center",role:"alert",children:[v.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),v.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[v.jsx("p",{className:"text-lg font-semibold",children:"Oops! Something went wrong!"}),v.jsx("p",{className:"text-sm",children:"Something went wrong:"}),v.jsx("pre",{className:"text-xs",children:e.message})]})]})}var ed=1e3,td=ed*60,nd=td*60,pc=nd*24,pee=pc*7,gee=pc*365.25,mee=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return bee(e);if(n==="number"&&isFinite(e))return t.long?vee(e):yee(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function bee(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*gee;case"weeks":case"week":case"w":return n*pee;case"days":case"day":case"d":return n*pc;case"hours":case"hour":case"hrs":case"hr":case"h":return n*nd;case"minutes":case"minute":case"mins":case"min":case"m":return n*td;case"seconds":case"second":case"secs":case"sec":case"s":return n*ed;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function yee(e){var t=Math.abs(e);return t>=pc?Math.round(e/pc)+"d":t>=nd?Math.round(e/nd)+"h":t>=td?Math.round(e/td)+"m":t>=ed?Math.round(e/ed)+"s":e+"ms"}function vee(e){var t=Math.abs(e);return t>=pc?qg(e,t,pc,"day"):t>=nd?qg(e,t,nd,"hour"):t>=td?qg(e,t,td,"minute"):t>=ed?qg(e,t,ed,"second"):e+" ms"}function qg(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+" "+r+(i?"s":"")}const xee=Pc(mee);function wee(e){const t=ye(u=>u.selectedSheetId),n=ye(u=>u.selectedLensId),r=ye(u=>u.dashboard.baseQueries),i=ye(u=>u.dashboard.filters),o=ye(u=>u.filterValues),s=i==null?void 0:i.filter(u=>u.sheetId===t||!u.sheetId),a=o==null?void 0:o.filter(u=>(s==null?void 0:s.some(d=>d.id===u.filterId))||u.filterId.endsWith(t)),l=GY(e.sql,r);return{queryKey:["query",e.id,l,n||"",JSON.stringify(a)],sql:l,sheetFilterValues:a}}function Yy(e,t){const{authToken:n}=Hi(),r=ye(d=>d.isVisualEditing),i=ye(d=>d.authToken),o=xee((e==null?void 0:e.refreshInterval)||"0"),{queryKey:s,sql:a,sheetFilterValues:l}=wee(e);return{...pp({queryKey:s,queryFn:()=>yy("https://semaphor.cloud/api/v1/query",(n==null?void 0:n.accessToken)||(i==null?void 0:i.accessToken)||"",{connection_id:e.connectionId,sql:a,python:e.python===aN?"":e.python,active_filters:l,cache_config:U_()}),refetchInterval:o,placeholderData:NK,enabled:!!e.connectionId&&!!e.sql&&!0&&!r}),queryKey:s}}function Qs({number:e,decimalPlaces:t=0,useSuffix:n=!1,customSuffix:r="",currency:i="",locale:o="en-US"}){let s=1,a=r,l=o;const c=t;n&&!r&&(e>=1e9?(s=1e9,a="B"):e>=1e7&&o==="en-IN"?(s=1e7,a="Cr"):e>=1e5&&o==="en-IN"?(s=1e5,a="L"):e>=1e6?(s=1e6,a="M"):e>=1e3&&(s=1e3,a="K"));const u=e/s,d={maximumFractionDigits:c,minimumFractionDigits:c};if(i){d.style="currency",d.currency=i;try{new Intl.NumberFormat(o,d).format(0)}catch{}}try{new Intl.NumberFormat(o,d).format(0)}catch{l="en-US"}let h=new Intl.NumberFormat(l,d).format(u);return n&&(h+=a),h}function kC(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function t4(e){try{const n=new Function("getDatalabelColor",e)(x1);return{options:n==null?void 0:n.options,plugins:(n==null?void 0:n.plugins)||[]}}catch(t){return console.error("Error processing custom visual code",t),{options:{},plugins:[]}}}function n4(e){const t=getComputedStyle(document.documentElement).getPropertyValue(e);return See(t)}function See(e){const[t,n,r]=e.split(" "),i=parseFloat(t),o=parseFloat(n),s=parseFloat(r),a=o/100,l=s/100,c=(1-Math.abs(2*l-1))*a,u=c*(1-Math.abs(i/60%2-1)),d=l-c/2;let p=0,h=0,m=0;0<=i&&i<60?(p=c,h=u,m=0):60<=i&&i<120?(p=u,h=c,m=0):120<=i&&i<180?(p=0,h=c,m=u):180<=i&&i<240?(p=0,h=u,m=c):240<=i&&i<300?(p=u,h=0,m=c):300<=i&&i<360&&(p=c,h=0,m=u),p=Math.round((p+d)*255),h=Math.round((h+d)*255),m=Math.round((m+d)*255);const b=x=>{const y=x.toString(16);return y.length==1?"0"+y:y};return`#${b(p)}${b(h)}${b(m)}`}function vl({data:e,cfg:t,customCfg:n,preferences:r}){ye.getState().themeStyle;const{dimensionKeys:i,metricKeys:o}=or(e),s=ZZ(o,e,r),a=kf(s,n),l=i[0],c=K1(e,l);NC(r,t),r4(r);const{options:u,plugins:d}=o4({cfg:t,preferences:r,customCfg:n});return{type:(n==null?void 0:n.type)||(t==null?void 0:t.type)||"bar",data:{labels:c,datasets:a},options:u,plugins:d}}function NC(e,t){var i,o,s;const n=((i=t==null?void 0:t.options)==null?void 0:i.indexAxis)==="y"?"x":"y";return(o=e==null?void 0:e.chartOptions)!=null&&o.indexAxis?((s=e==null?void 0:e.chartOptions)==null?void 0:s.indexAxis)==="x"?"y":"x":n}function r4(e){var n,r;return(n=e==null?void 0:e.chartOptions)!=null&&n.indexAxis?((r=e==null?void 0:e.chartOptions)==null?void 0:r.indexAxis)==="x"?"x":"y":"x"}function i4(e,t){var o,s,a,l,c,u,d,p,h,m,b,x;const n=NC(t,e),r=r4(t);return{...e==null?void 0:e.options,scales:{...(o=e==null?void 0:e.options)==null?void 0:o.scales,[n]:{...(a=(s=e==null?void 0:e.options)==null?void 0:s.scales)==null?void 0:a[n],ticks:{...(u=(c=(l=e==null?void 0:e.options)==null?void 0:l.scales)==null?void 0:c[n])==null?void 0:u.ticks,callback:y=>{var S,_,C,R;return Qs({number:Number(y),decimalPlaces:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.decimalPlaces)||0,useSuffix:!!((_=t==null?void 0:t.numberAxisFormat)!=null&&_.suffix),customSuffix:"",locale:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.locale)||"",currency:((R=t==null?void 0:t.numberAxisFormat)==null?void 0:R.currency)||""})}}},[r]:{...(h=(p=(d=e==null?void 0:e.options)==null?void 0:d.scales)==null?void 0:p[r])==null?void 0:h.ticks,callback:null}},plugins:{...(m=e==null?void 0:e.options)==null?void 0:m.plugins,datalabels:{...(x=(b=e==null?void 0:e.options)==null?void 0:b.plugins)==null?void 0:x.datalabels,formatter:function(y){var S,_,C,R;return Qs({number:Number(y),decimalPlaces:((S=t==null?void 0:t.numberAxisFormat)==null?void 0:S.decimalPlaces)||0,useSuffix:!!((_=t==null?void 0:t.numberAxisFormat)!=null&&_.suffix),customSuffix:"",locale:((C=t==null?void 0:t.numberAxisFormat)==null?void 0:C.locale)||"",currency:((R=t==null?void 0:t.numberAxisFormat)==null?void 0:R.currency)||""})}}}}}function o4({cfg:e,preferences:t,customCfg:n}){var p,h,m,b,x,y,S,_,C,R,M,D,A,I,F,j,$,K,H,L,W,B,U,Y,k,Q,G,O,ee;const r=ye.getState().themeStyle,i=i4(e,t),o=no((e==null?void 0:e.options)||{},t==null?void 0:t.chartOptions),s=no(i,o),a=no(s,(n==null?void 0:n.options)||{}),l={...a,scales:{...a==null?void 0:a.scales,x:{...(p=a==null?void 0:a.scales)==null?void 0:p.x,grid:{...(m=(h=a==null?void 0:a.scales)==null?void 0:h.x)==null?void 0:m.grid,color:(_=(S=(y=(x=(b=r==null?void 0:r.chart)==null?void 0:b.options)==null?void 0:x.scales)==null?void 0:y.x)==null?void 0:S.grid)==null?void 0:_.color}},y:{...(C=a==null?void 0:a.scales)==null?void 0:C.y,grid:{...(M=(R=a==null?void 0:a.scales)==null?void 0:R.y)==null?void 0:M.grid,color:(j=(F=(I=(A=(D=r==null?void 0:r.chart)==null?void 0:D.options)==null?void 0:A.scales)==null?void 0:I.y)==null?void 0:F.grid)==null?void 0:j.color}}},plugins:{...a==null?void 0:a.plugins,tooltip:{...($=a==null?void 0:a.plugins)==null?void 0:$.tooltip,backgroundColor:(W=(L=(H=(K=r==null?void 0:r.chart)==null?void 0:K.options)==null?void 0:H.plugins)==null?void 0:L.tooltip)==null?void 0:W.backgroundColor,bodyColor:(k=(Y=(U=(B=r==null?void 0:r.chart)==null?void 0:B.options)==null?void 0:U.plugins)==null?void 0:Y.tooltip)==null?void 0:k.bodyColor,titleColor:(ee=(O=(G=(Q=r==null?void 0:r.chart)==null?void 0:Q.options)==null?void 0:G.plugins)==null?void 0:O.tooltip)==null?void 0:ee.titleColor}}},{plugins:c,options:u}=t4((t==null?void 0:t.customVisualCode)||"");return{options:no(l,u),plugins:c}}/*!
|
|
239
239
|
* @kurkle/color v0.3.4
|
|
240
240
|
* https://github.com/kurkle/color#readme
|
|
241
241
|
* (c) 2024 Jukka Kurkela
|