@perses-dev/tempo-plugin 0.57.0 → 0.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/__mf/js/{Tempo.a15c7ca4.js → Tempo.6c9a48e0.js} +5 -5
  2. package/__mf/js/async/{1728.988e2b29.js → 1728.67c7a01e.js} +1 -1
  3. package/__mf/js/async/3.6db4a205.js +4 -0
  4. package/__mf/js/async/3208.47804c05.js +2 -0
  5. package/__mf/js/async/54.0f34f4f8.js +22 -0
  6. package/__mf/js/async/9811.b4b6d8ee.js +7 -0
  7. package/__mf/js/async/__federation_expose_TempoDatasource.a723b8ee.js +2 -0
  8. package/__mf/js/async/{__federation_expose_TempoExplorer.003c9970.js → __federation_expose_TempoExplorer.8d4424e2.js} +1 -1
  9. package/__mf/js/async/__federation_expose_TempoTraceQuery.629ec38d.js +1 -0
  10. package/__mf/js/{main.6a6654b6.js → main.019cca86.js} +3 -3
  11. package/lib/cjs/components/AttributeFilters.js +76 -51
  12. package/lib/cjs/components/complete.js +3 -3
  13. package/lib/cjs/components/filter/filter.js +2 -2
  14. package/lib/cjs/components/filter/filter_to_traceql.js +1 -1
  15. package/lib/cjs/components/filter/traceql_to_filter.js +5 -5
  16. package/lib/cjs/plugins/tempo-trace-query/TempoTraceQueryEditor.js +1 -1
  17. package/lib/cjs/plugins/tempo-trace-query/get-trace-data.js +6 -7
  18. package/lib/components/AttributeFilters.d.ts.map +1 -1
  19. package/lib/components/AttributeFilters.js +72 -47
  20. package/lib/components/AttributeFilters.js.map +1 -1
  21. package/lib/components/ClosableAlert.d.ts +2 -1
  22. package/lib/components/ClosableAlert.d.ts.map +1 -1
  23. package/lib/components/ClosableAlert.js.map +1 -1
  24. package/lib/components/complete.js +1 -1
  25. package/lib/components/complete.js.map +1 -1
  26. package/lib/components/filter/filter.d.ts.map +1 -1
  27. package/lib/components/filter/filter.js +2 -2
  28. package/lib/components/filter/filter.js.map +1 -1
  29. package/lib/components/filter/filter_to_traceql.d.ts.map +1 -1
  30. package/lib/components/filter/filter_to_traceql.js +1 -1
  31. package/lib/components/filter/filter_to_traceql.js.map +1 -1
  32. package/lib/components/filter/traceql_to_filter.js +5 -5
  33. package/lib/components/filter/traceql_to_filter.js.map +1 -1
  34. package/lib/plugins/tempo-trace-query/TempoTraceQueryEditor.d.ts +1 -1
  35. package/lib/plugins/tempo-trace-query/TempoTraceQueryEditor.d.ts.map +1 -1
  36. package/lib/plugins/tempo-trace-query/TempoTraceQueryEditor.js +1 -1
  37. package/lib/plugins/tempo-trace-query/TempoTraceQueryEditor.js.map +1 -1
  38. package/lib/plugins/tempo-trace-query/get-trace-data.d.ts.map +1 -1
  39. package/lib/plugins/tempo-trace-query/get-trace-data.js +6 -7
  40. package/lib/plugins/tempo-trace-query/get-trace-data.js.map +1 -1
  41. package/mf-manifest.json +24 -24
  42. package/mf-stats.json +26 -31
  43. package/package.json +6 -6
  44. package/__mf/js/async/1905.d3c01a20.js +0 -2
  45. package/__mf/js/async/2545.d42b194b.js +0 -2
  46. package/__mf/js/async/54.812deb71.js +0 -22
  47. package/__mf/js/async/7958.4ba5d596.js +0 -7
  48. package/__mf/js/async/__federation_expose_TempoDatasource.1f9ab43f.js +0 -2
  49. package/__mf/js/async/__federation_expose_TempoTraceQuery.eff34861.js +0 -1
  50. /package/__mf/js/async/{1905.d3c01a20.js.LICENSE.txt → 3.6db4a205.js.LICENSE.txt} +0 -0
  51. /package/__mf/js/async/{2545.d42b194b.js.LICENSE.txt → 3208.47804c05.js.LICENSE.txt} +0 -0
  52. /package/__mf/js/async/{54.812deb71.js.LICENSE.txt → 54.0f34f4f8.js.LICENSE.txt} +0 -0
  53. /package/__mf/js/async/{7958.4ba5d596.js.LICENSE.txt → 9811.b4b6d8ee.js.LICENSE.txt} +0 -0
  54. /package/__mf/js/async/{__federation_expose_TempoDatasource.1f9ab43f.js.LICENSE.txt → __federation_expose_TempoDatasource.a723b8ee.js.LICENSE.txt} +0 -0
@@ -1,2 +0,0 @@
1
- /*! For license information please see __federation_expose_TempoDatasource.1f9ab43f.js.LICENSE.txt */
2
- "use strict";(self.chunk_Tempo=self.chunk_Tempo||[]).push([["9871"],{74513:function(e,t,r){r.r(t),r.d(t,{StatusCodeError:()=>o,StatusCodeOk:()=>a,StatusCodeUnset:()=>n});let n="STATUS_CODE_UNSET",a="STATUS_CODE_OK",o="STATUS_CODE_ERROR"},37856:function(e,t,r){async function n(...e){let t=await globalThis.fetch(...e);if(!1===t.ok){let e=t.headers.get("content-type");if(e?.includes("application/json")){let e=await t.clone().json();if(e.error)throw new s(e.error,t.status);if(e.message)throw new s(e.message,t.status)}let r=await t.clone().text();if(r)throw new s(r,t.status);throw new o(t)}return t}async function a(...e){let t=await n(...e);if(!t.ok)throw new o(t);return await t.json()}r.d(t,{P7:()=>s,fk:()=>o,hd:()=>n,x6:()=>a});class o extends Error{status;constructor(e){super(`${e.status} ${e.statusText}`),this.status=e.status,Object.setPrototypeOf(this,o.prototype)}}class s extends Error{status;constructor(e,t){super(e),this.status=t,Object.setPrototypeOf(this,s.prototype)}}},2192:function(e,t,r){var n=r(70451),a=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var n,o={},u=null,l=null;for(n in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)s.call(t,n)&&!c.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===o[n]&&(o[n]=t[n]);return{$$typeof:a,type:e,key:u,ref:l,props:o,_owner:i.current}}t.Fragment=o,t.jsx=u,t.jsxs=u},62540:function(e,t,r){e.exports=r(2192)},55075:function(e,t,r){r.r(t),r.d(t,{TempoDatasource:()=>f});var n=r(37856),a=r(74513);let o=async function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];let a=await (0,n.hd)(...t);try{return await a.json()}catch(e){throw console.error("Invalid response from server",e),Error("Invalid response from server")}};function s(e,t,r){let{datasourceUrl:n,headers:a={}}=r,s=`${n}${e}`,i=(function(e){let t=new URLSearchParams;for(let r in e){let n=e[r];switch(typeof n){case"string":t.append(r,n);break;case"number":t.append(r,n.toString())}}return t})(t).toString();return""!==i&&(s+="?"+i),o(s,{method:"GET",headers:a})}function i(e,t){return s("/api/search",e,t)}function c(e,t){return s(`/api/traces/${encodeURIComponent(e.traceId)}`,{},t)}async function u(e,t){let r=await i(e,t);return r.traces&&0!==r.traces.length?r.traces.every(e=>e.serviceStats)?r:{traces:await Promise.all(r.traces.map(async e=>{if(e.serviceStats)return e;let r={};for(let s of(await c({traceId:e.traceID},t)).batches){var n,o;let e="unknown";for(let t of(null==(n=s.resource)?void 0:n.attributes)??[])if("service.name"===t.key&&"stringValue"in t.value){e=t.value.stringValue;break}let t=r[e]??{spanCount:0};for(let e of s.scopeSpans)for(let r of(t.spanCount+=e.spans.length,e.spans))(null==(o=r.status)?void 0:o.code)===a.StatusCodeError&&(t.errorCount=(t.errorCount??0)+1);r[e]=t}return{...e,serviceStats:r}}))}:{traces:[]}}var l=r(62540),p=r(36603);r(70451);let f={createClient:(e,t)=>{let{directUrl:r,proxy:n}=e,{proxyUrl:a}=t,o=r??a;if(void 0===o)throw Error("No URL specified for Tempo client. You can use directUrl in the spec to configure it.");let l=null==n?void 0:n.spec.headers;return{options:{datasourceUrl:o},query:(e,t)=>c(e,{datasourceUrl:o,headers:t??l}),search:(e,t)=>i(e,{datasourceUrl:o,headers:t??l}),searchWithFallback:(e,t)=>u(e,{datasourceUrl:o,headers:t??l}),searchTags:(e,t)=>s("/api/v2/search/tags",e,{datasourceUrl:o,headers:t??l}),searchTagValues:(e,t)=>(function(e,t){let{tag:r,...n}=e;return s(`/api/v2/search/tag/${encodeURIComponent(r)}/values`,n,t)})(e,{datasourceUrl:o,headers:t??l})}},OptionsEditorComponent:function(e){let{value:t,onChange:r,isReadonly:n}=e;return(0,l.jsx)(p.HTTPSettingsEditor,{value:t,onChange:r,isReadonly:n,initialSpecDirect:{directUrl:""},initialSpecProxy:{proxy:{kind:"HTTPProxy",spec:{allowedEndpoints:[{endpointPattern:"/api/search",method:"GET"},{endpointPattern:"/api/traces",method:"GET"},{endpointPattern:"/api/v2/search/tags",method:"GET"},{endpointPattern:"/api/v2/search/tag",method:"GET"}],url:""}}}})},createInitialOptions:()=>({directUrl:""})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.chunk_Tempo=self.chunk_Tempo||[]).push([["4397"],{91093:function(e,t,a){a.r(t),a.d(t,{TempoTraceQuery:()=>en});var r=a(36603),n=a(33862),s=a(94461);let i="TempoDatasource",l={kind:i};function o(e){let{start:t,end:a}=e;return{start:Math.ceil((0,s.getUnixTime)(t)),end:Math.ceil((0,s.getUnixTime)(a))}}let c=async(e,t)=>{if(void 0===e.query||null===e.query||""===e.query)return console.error("TempoTraceQuery is undefined, null, or an empty string."),{searchResult:[]};let a=await t.datasourceStore.listDatasourceSelectItems(i),s=(0,r.datasourceSelectValueToSelector)(e.datasource,t.variableState,a)??{kind:i},l=await t.datasourceStore.getDatasourceClient(s);if((0,n.h)(e.query))return{trace:function(e){let t={resourceSpans:e.batches};for(let e of t.resourceSpans)for(let t of e.scopeSpans)for(let e of t.spans)for(let t of(32!=e.traceId.length&&(e.traceId=u(e.traceId)),16!=e.spanId.length&&(e.spanId=u(e.spanId)),e.parentSpanId&&16!=e.parentSpanId.length&&(e.parentSpanId=u(e.parentSpanId)),e.links??[]))32!=t.traceId.length&&(t.traceId=u(t.traceId)),16!=t.spanId.length&&(t.spanId=u(t.spanId));return t}(await l.query({traceId:e.query})),metadata:{executedQueryString:e.query}};{let a={q:e.query};if(t.absoluteTimeRange){let{start:e,end:r}=o(t.absoluteTimeRange);a.start=e,a.end=r}let r=e.limit??20;a.limit=r+1;let n=(await l.searchWithFallback(a)).traces.map(e=>({startTimeUnixMs:1e-6*parseInt(e.startTimeUnixNano),durationMs:e.durationMs??0,traceId:e.traceID,rootServiceName:e.rootServiceName,rootTraceName:e.rootTraceName,serviceStats:e.serviceStats||{}})),s=n.length>r,i=[];return s&&(i.push({type:"info",message:"Not all matching traces are currently displayed. Increase the result limit to view additional traces."}),n.splice(r)),{searchResult:n,metadata:{executedQueryString:e.query,hasMoreResults:s,notices:i}}}};function u(e){try{return atob(e).split("").map(e=>e.charCodeAt(0).toString(16).padStart(2,"0")).join("")}catch{return e}}var p=a(62540),d=a(315),m=a(67987),f=a(7013),h=a(74628),g=a(54227),v=a(76795),x=a(97653),b=a(43349),y=a(38662),k=a(70451),T=a(5611),A=a(42927),j=a(93648),S=a(91807);function I(e){let t,a=[...N("resource.service.name",e.serviceName),...N("name",e.spanName),...N("resource.k8s.namespace.name",e.namespace),...(t=e.status.map(e=>`status = ${e}`)).length>1?["("+t.join(" || ")+")"]:1===t.length?t:[],...C("duration",e.spanDuration),...C("traceDuration",e.traceDuration),...e.customMatchers];return 0===a.length?"{}":`{ ${a.join(" && ")} }`}function D(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function N(e,t){let a=t.map(D);return a.length>1?[`${e} =~ "${a.join("|")}"`]:1==a.length?[`${e} = "${a[0]}"`]:[]}function C(e,t){let a=[];return t.min&&a.push(`${e} >= ${t.min}`),t.max&&a.push(`${e} <= ${t.max}`),a}var w=a(29612);function q(e){var t;let a,r,n,s,i=(t=e,a={},r="",n="",s="",w.K3.parse(t).iterate({enter(e){switch(e.type.id){case w.d4:case w.sd:return r=t.slice(e.from,e.to),!1;case w.Ib:return n=t.slice(e.from,e.to),!1;case w.jC:return s=t.slice(e.from,e.to),!1}},leave(e){if(e.type.id===w.v5&&e.node.getChild(w.Ib)){let e=a[r]??[];e.push({operator:n,value:s}),a[r]=e}}}),a);return{serviceName:V(i["resource.service.name"]),spanName:V(i.name),namespace:V(i["resource.k8s.namespace.name"]),status:function(e){let t=[];for(let{operator:a,value:r}of e??[])"="==a&&t.push(r);return t}(i.status),spanDuration:$(i.duration),traceDuration:$(i.traceDuration),customMatchers:function(e,t){let a=[];for(let[r,n]of Object.entries(e))if(!t.has(r))for(let{operator:e,value:t}of n)a.push(`${r}${e}${t}`);return a}(i,new Set(["resource.service.name","name","resource.k8s.namespace.name","status","duration","traceDuration"]))}}function V(e){let t=[];for(let{operator:a,value:r}of e??[]){let e=r.slice(1,-1).replaceAll('\\"','"').replaceAll("\\\\","\\");"="==a?t.push(e):"=~"==a&&t.push(...e.split("|"))}return t}function $(e){let t={};for(let{operator:a,value:r}of e??[])">="==a?t.min=r:"<="==a&&(t.max=r);return t}let M=["unset","ok","error"];function _(e){let{client:t,query:a,setQuery:n}=e,s=q(a),i=e=>{n(I(e))},{absoluteTimeRange:l}=(0,r.useTimeRange)(),{start:c,end:u}=o(l),{data:d}=F(t,"resource.service.name",I({...s,serviceName:[]}),c,u),{data:m}=F(t,"name",I({...s,spanName:[]}),c,u);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(R,{label:"Service Name",options:d??[],value:s.serviceName,setValue:e=>i({...s,serviceName:e})}),(0,p.jsx)(R,{label:"Span Name",options:m??[],value:s.spanName,setValue:e=>i({...s,spanName:e})}),(0,p.jsx)(R,{label:"Status",width:210,options:M??[],value:s.status,setValue:e=>i({...s,status:e})}),(0,p.jsx)(O,{label:"Trace Duration",value:s.traceDuration,setValue:e=>i({...s,traceDuration:e})}),(0,p.jsx)(E,{label:"Custom Attributes",value:s.customMatchers,setValue:e=>i({...s,customMatchers:e})})]})}function R(e){let{label:t,width:a,options:r,value:n,setValue:s}=e;return(0,p.jsx)(T.A,{multiple:!0,size:"small",limitTags:1,disableCloseOnSelect:!0,value:n,onChange:(e,t)=>s(t),options:r,renderOption:(e,t,a)=>{let{selected:r}=a,{key:n,...s}=e;return(0,p.jsxs)("li",{...s,children:[(0,p.jsx)(A.A,{style:{marginRight:8},checked:r}),t]},n)},renderInput:e=>(0,p.jsx)(j.A,{...e,label:t}),slotProps:{chip:{sx:{maxWidth:"calc(100% - 45px) !important"}}},sx:{width:a??250,"& input":{minWidth:"5px !important"}}})}function O(e){let{label:t,value:a,setValue:r}=e,{min:n,max:s}=a;return(0,p.jsxs)(d.A,{direction:"row",gap:.5,children:[(0,p.jsx)(Q,{label:`Min ${t}`,value:n??"",setValue:e=>r({min:e,max:s})}),(0,p.jsx)(Q,{label:`Max ${t}`,value:s??"",setValue:e=>r({min:n,max:e})})]})}let L=/^([0-9]+\.)?[0-9]+(ns|ms|s|m|h)$/;function Q(e){let{label:t,value:a,setValue:r}=e;return(0,p.jsx)(z,{label:t,size:"small",value:a,setValue:r,validationRegex:L,validationFailedMessage:"Invalid format. Accepted format e.g. 100ms, accepted units: ns, ms, s, m, h",sx:{width:150}})}function E(e){let{label:t,value:a,setValue:r}=e;return(0,p.jsx)(z,{label:t,size:"small",placeholder:'span.http.status_code=200 span.http.method="GET"',value:a.join(" "),setValue:e=>r(function(e){let t=!1,a=0,r=[];for(let n=0;n<e.length;n++)'"'==e[n]&&"\\"!=e[n-1]?t=!t:" "!=e[n]||t||(r.push(e.slice(a,n)),a=n+1);return r.push(e.slice(a,e.length)),r.filter(e=>e)}(e)),sx:{flexGrow:1}})}function z(e){let{validationRegex:t,validationFailedMessage:a,value:r,setValue:n,...s}=e,[i,l]=(0,k.useState)(r),o=""==i||void 0==t||t.test(i);(0,k.useEffect)(()=>{l(r)},[r,l]);let c=(0,k.useCallback)(e=>{l(e.target.value)},[]),u=(0,k.useCallback)(()=>{o&&n(i)},[o,n,i]);return(0,p.jsx)(j.A,{...s,error:!o,helperText:o?void 0:a,value:i,onChange:c,onBlur:u})}function F(e,t,a,r,n){return(0,S.useQuery)({queryKey:["useTagValues",e,t,a,r,n],enabled:!!e,queryFn:async function(){if(e)return(await e.searchTagValues({tag:t,q:a,start:r,end:n})).tagValues.map(e=>e.value??"").sort()},staleTime:6e4})}var G=a(56599),W=a(79058),P=a(63960),B=a(31650);let K=(0,B.pn)({LineComment:B._A.comment,"Parent Resource Span Identifier":B._A.labelName,IntrinsicField:B._A.labelName,String:B._A.string,"Integer Float Duration":B._A.number,Static:B._A.literal,"Aggregate AggregateExpression":B._A.function(B._A.keyword),"And Or":B._A.logicOperator,"Gt Lt Desc Anc tilde ExperimentalOp":B._A.bitwiseOperator,ComparisonOp:B._A.compareOperator,Pipe:B._A.operator,ScalarOp:B._A.arithmeticOperator,"( )":B._A.paren,"[ ]":B._A.squareBracket,"{ }":B._A.brace,"⚠":B._A.invalid});var U=a(9714);let H=['"',"`"];async function J(e,t){let{state:a,pos:r}=t,n=function(e,t,a){var r,n,s,i,l,o,c,u,p,d,m,f,h,g,v,x,b,y,k,T,A;let j=a.resolveInner(t,-1);switch(j.type.id){case w.NA:if((null===j.firstChild||(null==(r=j.firstChild)?void 0:r.type.id)===0)&&!e.sliceDoc(j.from,t).includes("}"))return{scopes:[{kind:"Scopes"},{kind:"TagName",scope:"intrinsic"}],from:t};break;case w.v5:return{scopes:[{kind:"Scopes"},{kind:"TagName",scope:"intrinsic"}],from:t};case w.d4:if((null==(n=j.firstChild)?void 0:n.type.id)===w.FW)return{scopes:[{kind:"TagName",scope:"resource"}],from:t};if((null==(s=j.firstChild)?void 0:s.type.id)===w.L9)return{scopes:[{kind:"TagName",scope:"span"}],from:t};if("."===e.sliceDoc(j.from,j.to))return{scopes:[{kind:"TagName",scope:"resource"},{kind:"TagName",scope:"span"}],from:t};break;case w.gw:if((null==(i=j.parent)?void 0:i.type.id)===w.d4){if(e.sliceDoc(j.parent.from,j.parent.to).includes(":"))return{scopes:[{kind:"TagName",scope:"intrinsic"}],from:j.parent.from};if((null==(o=j.parent)||null==(l=o.firstChild)?void 0:l.type.id)===w.FW)return{scopes:[{kind:"TagName",scope:"resource"}],from:j.from};if((null==(u=j.parent)||null==(c=u.firstChild)?void 0:c.type.id)===w.L9)return{scopes:[{kind:"TagName",scope:"span"}],from:j.from};if((null==(d=j.parent)||null==(p=d.firstChild)?void 0:p.type.id)===w.gw)return{scopes:[{kind:"TagName",scope:"resource"},{kind:"TagName",scope:"span"}],from:j.from}}break;case w.Ib:if((null==(f=j.parent)||null==(m=f.firstChild)?void 0:m.type.id)===w.v5){let a=j.parent.firstChild;return{scopes:[{kind:"TagValue",tag:e.sliceDoc(a.from,a.to)}],from:t}}break;case w.Qf:if((null==(x=j.parent)||null==(v=x.parent)||null==(g=v.parent)||null==(h=g.firstChild)?void 0:h.type.id)===w.v5&&!/^".*"$/.test(e.sliceDoc(j.from,t))){let t=j.parent.parent.parent.firstChild;return{scopes:[{kind:"TagValue",tag:e.sliceDoc(t.from,t.to)}],from:j.from+1}}break;case 0:if((null==(b=j.prevSibling)?void 0:b.type.id)===w.Ib&&(null==(k=j.parent)||null==(y=k.firstChild)?void 0:y.type.id)===w.v5){let t=j.parent.firstChild;return{scopes:[{kind:"TagValue",tag:e.sliceDoc(t.from,t.to)}],from:H.includes(e.sliceDoc(j.from,j.from+1))?j.from+1:j.from}}if((null==(T=j.parent)?void 0:T.type.id)===w.NA||(null==(A=j.parent)?void 0:A.type.id)===w.v5)return{scopes:[{kind:"Scopes"},{kind:"TagName",scope:"intrinsic"}],from:j.from}}}(a,r,(0,P.mv)(a));return n?{options:await X(e,n.scopes),from:n.from,to:n.to}:null}async function X(e,t){let a=[];for(let r of t)switch(r.kind){case"Scopes":a.push(Promise.resolve([{label:"span"},{label:"resource"}]));break;case"TagName":a.push(Y(e,r.scope));break;case"TagValue":a.push(ee(e,r.tag))}return(await Promise.all(a)).flat()}async function Y(e,t){if(!e.client)return[];let{start:a,end:r}=e.timeRange?o(e.timeRange):{},{limit:n,maxStaleValues:s}=e;return(await e.client.searchTags({scope:t,start:a,end:r,limit:n,maxStaleValues:s})).scopes.flatMap(e=>e.tags).map(e=>({label:e}))}function Z(e,t,a,r){let n='"';H.includes(e.state.sliceDoc(a-1,a))&&(n=e.state.sliceDoc(a-1,a),a--),H.includes(e.state.sliceDoc(r,r+1))&&(n=e.state.sliceDoc(r,r+1),r++),t.label.includes("`")&&(n='"');let s=`${n}${function(e,t){if("`"===t)return e;let a=e;return(a=a.replaceAll("\\","\\\\")).replaceAll('"','\\"')}(t.label,n)}${n}`;e.dispatch((0,U.zH)(e.state,s,a,r))}async function ee(e,t){if(!e.client)return[];let{start:a,end:r}=e.timeRange?o(e.timeRange):{},{limit:n,maxStaleValues:s}=e,i=await e.client.searchTagValues({tag:t,start:a,end:r,limit:n,maxStaleValues:s}),l=[];for(let{type:e,value:t}of i.tagValues)switch(e){case"string":l.push({label:t??"",displayLabel:t??"(empty string)",apply:Z});break;case"keyword":case"int":l.push({label:t??"",displayLabel:t??"(empty string)"})}return l}function et(e){let{client:t,...a}=e,s=(0,G.A)(),i="dark"===s.palette.mode,{absoluteTimeRange:l}=(0,r.useTimeRange)(),o=(0,k.useMemo)(()=>{var e;let a,r;return e={client:t,timeRange:l},r=(a=P.bj.define({parser:w.K3.configure({props:[K]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//"}}})).data.of({autocomplete:t=>J(e,t).catch(e=>console.error("error during TraceQL auto-complete",e))}),[a,r]},[t,l]),c=(0,k.useMemo)(()=>{let e="light"===s.palette.mode?"rgba(0, 0, 0, 0.23)":"rgba(255, 255, 255, 0.23)";return W.Lz.theme({"&":{backgroundColor:"transparent !important",border:`1px solid ${e}`,borderRadius:`${s.shape.borderRadius}px`},"&.cm-focused.cm-editor":{outline:"none"},".cm-content":{padding:"8px"}})},[s]);return(0,p.jsxs)(d.A,{position:"relative",sx:{flexGrow:1},children:[(0,p.jsx)(g.A,{shrink:!0,sx:{position:"absolute",top:"-6px",left:"10px",padding:"0 4px",color:s.palette.text.primary,backgroundColor:s.palette.background.default,zIndex:1},children:"TraceQL Expression"}),(0,p.jsx)(W.Ay,{...a,theme:i?"dark":"light",basicSetup:{lineNumbers:!1,highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!(0,n.h)(a.value??"")},extensions:[W.Lz.lineWrapping,o,c],placeholder:'Example: {span.http.method = "GET"}'})]})}let ea=[20,50,100,500,1e3,5e3];function er(e){let{value:t,setValue:a}=e;return(0,p.jsx)(h.A,{children:(0,p.jsxs)(m.A,{size:"small",children:[(0,p.jsx)(g.A,{id:"max-traces-label",children:"Max Traces"}),(0,p.jsx)(v.A,{labelId:"max-traces-label",id:"max-traces-select",value:t,label:"Max Traces",onChange:e=>a("number"==typeof e.target.value?e.target.value:parseInt(e.target.value)),sx:{width:110},children:ea.map(e=>(0,p.jsx)(x.A,{value:e,children:e},e))})]})})}let en={getTraceData:c,OptionsEditorComponent:function(e){let{onChange:t,value:a,value:{datasource:n,limit:s}}=e,o=n??l,c=(0,r.useDatasourceSelectValueToSelector)(o,i),u=(0,b.useId)("tempo-datasource-label"),{data:h}=(0,r.useDatasourceClient)(c),{query:g,handleQueryChange:v,handleQueryBlur:x}=function(e){let{onChange:t,value:a}=e,[r,n]=(0,k.useState)(a.query),[s,i]=(0,k.useState)(a.query);return a.query!==s&&(n(a.query),i(a.query)),{query:r,handleQueryChange:e=>{n(e)},handleQueryBlur:()=>{i(r),t((0,y.jM)(a,e=>{e.query=r}))}}}(e),[T,A]=(0,k.useState)(()=>{var e;return""==(e=g)||I(q(e))===e}),j=(0,k.useCallback)(e=>{v(e)},[v]);return(0,p.jsxs)(d.A,{spacing:2,children:[(0,p.jsx)(m.A,{margin:"dense",fullWidth:!1,children:(0,p.jsx)(r.DatasourceSelect,{datasourcePluginKind:i,value:o,onChange:e=>{if((0,r.isVariableDatasource)(e)||e.kind===i)return void t((0,y.jM)(a,t=>{t.datasource=(0,r.isVariableDatasource)(e)||void 0!==e.name?e:void 0}));throw Error("Got unexpected non-Tempo datasource selector")},labelId:u,label:"Tempo Datasource",notched:!0})}),(0,p.jsxs)(d.A,{direction:"row",spacing:2,sx:{alignItems:"flex-start"},children:[T?(0,p.jsx)(_,{client:h,query:g,setQuery:e=>{t((0,y.jM)(a,t=>{t.query=e}))}}):(0,p.jsx)(et,{client:h,value:g,onChange:j,onBlur:x}),(0,p.jsx)(f.A,{onClick:()=>A(!T),children:T?"Show query":"Hide query"}),(0,p.jsx)(er,{value:s??20,setValue:e=>t((0,y.jM)(a,t=>{t.limit=e}))})]})]})},createInitialOptions:()=>({query:"",limit:20,datasource:void 0}),dependsOn:e=>({variables:[...(0,r.isVariableDatasource)(e.datasource)?(0,r.parseVariables)(e.datasource??""):[]]})}}}]);