⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.72
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
build
/
View File Name :
pyroscopePlugin.eb14b78419d619d90dca.js
"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6312],{68929:(q,v,s)=>{s.r(v),s.d(v,{plugin:()=>ct});var C=s(40187),l=s(96540),I=s(32264),E=s(91409),y=s(94333),D=s(29734);const _=e=>{const{options:t,onOptionsChange:a}=e;return l.createElement(l.Fragment,null,l.createElement(E.t,{defaultUrl:"http://localhost:4040",dataSourceConfig:t,showAccessOptions:!1,onChange:a,secureSocksDSProxyEnabled:I.$.secureSocksDSProxyEnabled}),l.createElement("h3",{className:"page-heading"},"Querying"),l.createElement("div",{className:"gf-form-group"},l.createElement("div",{className:"gf-form-inline"},l.createElement("div",{className:"gf-form"},l.createElement(y.LegacyForms.FormField,{label:"Minimal step",labelWidth:13,inputEl:l.createElement(y.LegacyForms.Input,{className:"width-6",value:t.jsonData.minStep,spellCheck:!1,placeholder:"15s",onChange:n=>{a({...t,jsonData:{...t.jsonData,minStep:n.currentTarget.value}})},validationEvents:{[D.Pw.onBlur]:[(0,D.RP)(/^$|^\d+(ms|[Mwdhmsy])$/,"Value is not valid, you can use number with time unit specifier: y, M, w, d, h, m, s")]}}),tooltip:"Minimal step used for metric query. Should be the same or higher as the scrape interval setting in the Pyroscope database."})))))};var ee=s(32017),te=s.n(ee),V=s(2543),B=s(39558),N=s(28848),ae=s.n(N),S=s(62467),Q=s(41987),le=s(26657),ne=s(72574),A=s(65474),P=s(81160),re=s(29505),w=s(39268),R=s(14186),O=s(88323),oe=s(3988);function $(e){const t=se(e.profileTypes);return l.createElement(oe.v,{placeholder:e.placeholder,separator:"-",displayAllSelectedLevels:!0,initialValue:e.initialProfileTypeId,allowCustomValue:!0,onSelect:e.onChange,options:t,changeOnSelect:!1,width:e.width??26})}function se(e){return(0,l.useMemo)(()=>{if(!e)return[];let t=new Map;for(let a of e){let n=[];a.id.indexOf(":")>-1&&(n=a.id.split(":"));const[r,i]=n;t.has(r)||t.set(r,{label:r,value:r,items:[]}),t.get(r)?.items.push({label:i,value:a.id})}return Array.from(t.values())},[e])}function z(e,t){const[a,n]=(0,l.useState)(),r={to:Math.ceil((t?.to.valueOf()||0)/6e4)*6e4,from:Math.floor((t?.from.valueOf()||0)/6e4)*6e4};return(0,l.useEffect)(()=>{(async()=>{const i=await e.getProfileTypes(r.from.valueOf(),r.to.valueOf());n(i)})()},[e,r.from,r.to]),a}function ie(e){return l.createElement(l.Fragment,null,l.createElement(w.C,null,l.createElement(R.I,{label:"Query type",labelWidth:20,tooltip:l.createElement("div",null,"The Pyroscope data source plugin provides the following query types for template variables")},l.createElement(O.l6,{placeholder:"Select query type","aria-label":"Query type",width:25,options:[{label:"Profile type",value:"profileType"},{label:"Label",value:"label"},{label:"Label value",value:"labelValue"}],onChange:t=>{t.value==="profileType"&&e.onChange({...e.query,type:t.value}),t.value==="label"&&e.onChange({...e.query,type:t.value,profileTypeId:""}),t.value==="labelValue"&&e.onChange({...e.query,type:t.value,profileTypeId:"",labelName:""})},value:e.query.type}))),(e.query.type==="labelValue"||e.query.type==="label")&&l.createElement(ue,{datasource:e.datasource,initialValue:e.query.profileTypeId,onChange:t=>{(e.query.type==="label"||e.query.type==="labelValue")&&e.onChange({...e.query,profileTypeId:t})},range:e.range}),e.query.type==="labelValue"&&l.createElement(ce,{value:e.query.labelName,datasource:e.datasource,profileTypeId:e.query.profileTypeId,onChange:t=>{e.query.type==="labelValue"&&e.onChange({...e.query,labelName:t})},from:e.range?.from.valueOf()||Date.now().valueOf()-1e3*60*60*24,to:e.range?.to.valueOf()||Date.now().valueOf()}))}function ce(e){const[t,a]=(0,l.useState)();(0,l.useEffect)(()=>{(async()=>a(await e.datasource.getLabelNames((e.profileTypeId||"")+"{}",e.from,e.to)))()},[e.datasource,e.profileTypeId,e.to,e.from]);const n=t?t.map(r=>({label:r,value:r})):[];return t&&e.value&&!t.find(r=>r===e.value)&&n.push({value:e.value,label:e.value}),l.createElement(w.C,null,l.createElement(R.I,{label:"Label",labelWidth:20,tooltip:l.createElement("div",null,"Select label for which to retrieve available values")},l.createElement(O.l6,{allowCustomValue:!0,placeholder:"Select label","aria-label":"Select label",width:25,options:n,onChange:r=>e.onChange(r.value),value:e.value})))}function ue(e){const t=z(e.datasource,e.range);return l.createElement(w.C,null,l.createElement(R.I,{label:"Profile type","aria-label":"Profile type",labelWidth:20,tooltip:l.createElement("div",null,"Select profile type for which to retrieve available labels")},t?l.createElement($,{onChange:e.onChange,profileTypes:t,initialProfileTypeId:e.initialValue}):l.createElement(B._,{text:"Loading"})))}class fe extends re.f5{constructor(t){super(),this.dataAPI=t,this.editor=ie}query(t){return t.targets[0].type==="profileType"?(0,A.H)(this.dataAPI.getProfileTypes(t.range.from.valueOf(),t.range.to.valueOf())).pipe((0,P.T)(a=>({data:a.map(n=>({text:n.label,value:n.id}))}))):t.targets[0].type==="label"?t.targets[0].profileTypeId?(0,A.H)(this.dataAPI.getLabelNames(t.targets[0].profileTypeId+"{}",t.range.from.valueOf(),t.range.to.valueOf())).pipe((0,P.T)(a=>({data:a.map(n=>({text:n}))}))):(0,S.of)({data:[]}):t.targets[0].type==="labelValue"?!t.targets[0].labelName||!t.targets[0].profileTypeId?(0,S.of)({data:[]}):(0,A.H)(this.dataAPI.getLabelValues(t.targets[0].profileTypeId+"{}",t.targets[0].labelName,t.range.from.valueOf(),t.range.to.valueOf())).pipe((0,P.T)(a=>({data:a.map(n=>({text:n}))}))):(0,S.of)({data:[]})}}const de="both",pe={groupBy:[],labelSelector:"{}",spanSelector:[]};var x=s(73372);function ge(e){const t=[];for(const a of e)if(a instanceof N.Token&&a.type==="context-labels"){let n="",r="",i="";const u=Array.isArray(a.content)?a.content:[a.content];for(let c of u)if(typeof c=="string"){let o;o=c,(o==="="||o==="!="||o==="=~"||o==="!~")&&(i=o)}else if(c instanceof N.Token)switch(c.type){case"label-key":n=W(c);break;case"label-value":r=W(c),r=r.substring(1,r.length-1);const o=U[i];o&&t.push({name:n,operator:o,value:r});break}}return t}function me(e){const t=e.labelMatchers.map(a=>{const n=ye[a.operator];return n?`${a.name}${n}"${a.value}"`:""}).filter(a=>a!=="").join(", ");return t?`{${t}}`:""}function W(e){return typeof e.content=="string"?e.content:""}const U={"=":x.D_.Equal,"!=":x.D_.NotEqual,"=~":x.D_.EqualRegEx,"!~":x.D_.NotEqualRegEx},ye=(0,V.invert)(U);class he extends le.iy{constructor(t,a=(0,ne.w)()){super(t),this.templateSrv=a,this.variables=new fe(this)}query(t){const a=t.targets.filter(n=>n.profileTypeId).map(n=>n.labelSelector===""?{...n,labelSelector:"{}"}:K(n,t.app));return a.length?super.query({...t,targets:a}):(0,S.of)({data:[]})}async getProfileTypes(t,a){return await this.getResource("profileTypes",{start:t,end:a})}async getAllProfileTypes(){return await this.getResource("profileTypes")}async getLabelNames(t,a,n){return await this.getResource("labelNames",{query:this.templateSrv.replace(t),start:a,end:n})}async getLabelValues(t,a,n,r){return await this.getResource("labelValues",{label:this.templateSrv.replace(a),query:this.templateSrv.replace(t),start:n,end:r})}applyTemplateVariables(t,a){return{...t,labelSelector:this.templateSrv.replace(t.labelSelector??"",a),profileTypeId:this.templateSrv.replace(t.profileTypeId??"",a)}}async importFromAbstractQueries(t){return t.map(a=>this.importFromAbstractQuery(a))}importFromAbstractQuery(t){return{refId:t.refId,labelSelector:me(t),queryType:"both",profileTypeId:"",groupBy:[]}}async exportToAbstractQueries(t){return t.map(a=>this.exportToAbstractQuery(a))}exportToAbstractQuery(t){const a=t.labelSelector;if(!a||a.length===0)return{refId:t.refId,labelMatchers:[]};const n=ae().tokenize(a,be);return{refId:t.refId,labelMatchers:ge(n)}}getDefaultQuery(t){return k}}const k={...pe,queryType:de};function K(e,t){let a={...k,...e};return t!==Q.Jk.Explore&&a.queryType==="both"&&(a.queryType="profile"),a}const be={"context-labels":{pattern:/\{[^}]*(?=}?)/,greedy:!0,inside:{comment:{pattern:/#.*/},"label-key":{pattern:/[a-zA-Z_]\w*(?=\s*(=|!=|=~|!~))/,alias:"attr-name",greedy:!0},"label-value":{pattern:/"(?:\\.|[^\\"])*"/,greedy:!0,alias:"attr-value"},punctuation:/[{]/}},punctuation:/[{}(),.]/};var d=s(32196),m=s(40845);function F(e){const t=(0,m.of)(ve,e);return l.createElement("div",{className:t.root},e.children)}const ve=(e,t)=>({root:(0,d.css)({display:"flex",flexDirection:t.direction??"row",flexWrap:t.wrap??!0?"wrap":void 0,alignItems:t.alignItems,gap:e.spacing(t.gap??2),flexGrow:t.flexGrow})}),G=({children:e,stackProps:t})=>{const a=(0,m.of)(Ee);return l.createElement("div",{className:a.root},l.createElement(F,{gap:2,...t},e))},Ee=e=>({root:(0,d.css)({padding:e.spacing(1),backgroundColor:e.colors.background.secondary,borderRadius:e.shape.radius.default})}),Se=({children:e})=>l.createElement(F,{gap:.5,direction:"column"},e);var xe=s(39554),H=s(16817),Te=s(32372);const Le={id:"pyroscopeql",extensions:[".pyroscopeql"],aliases:["pyroscope","pyroscopeql"],mimetypes:[],def:{language:{ignoreCase:!1,defaultToken:"",tokenPostfix:".pyroscopeql",keywords:[],operators:[],symbols:/[=>](?!@symbols)/,"@brackets"],[/@symbols/,{cases:{"@operators":"delimiter","@default":""}}],[/\d+/,"number"],[/\d*\d+[eE]([\-+]?\d+)?(@floatsuffix)/,"number.float"],[/\d*\.\d+([eE][\-+]?\d+)?(@floatsuffix)/,"number.float"],[/0[xX][0-9a-fA-F']*[0-9a-fA-F](@integersuffix)/,"number.hex"],[/0[0-7']*[0-7](@integersuffix)/,"number.octal"],[/0[bB][0-1']*[0-1](@integersuffix)/,"number.binary"],[/\d[\d']*\d(@integersuffix)/,"number"],[/\d(@integersuffix)/,"number"]],string_double:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,"string","@pop"]],string_single:[[/[^\\']+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/'/,"string","@pop"]],clauses:[[/[^(,)]/,"tag"],[/\)/,"identifier","@pop"]],whitespace:[[/[ \t\r\n]+/,"white"]]}},languageConfiguration:{wordPattern:/(-?\d*\.\d\w*)|([^`~!#%^&*()=+\[{\]}\\|;:'",<>\/?\s]+)/g,brackets:[["{","}"]],autoClosingPairs:[{open:"{",close:"}"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{}}}};class Ce{constructor(){this.triggerCharacters=["{",",","[","(","=","~"," ",'"'],this.labels=[],this.getLabelValues=()=>Promise.resolve([])}init(t,a){this.labels=t,this.getLabelValues=a}provideCompletionItems(t,a){if(!(this.monaco&&this.editor))throw new Error("provideCompletionItems called before CompletionProvider was initialized");if(this.editor.getModel()?.id!==t.id)return{suggestions:[]};const{range:n,offset:r}=Re(this.monaco,t,a),i=we(t.getValue(),r);return this.getCompletions(i).then(u=>{const c=u.length.toString().length;return{suggestions:u.map((f,p)=>({kind:Ie(f.type,this.monaco),label:f.label,insertText:f.insertText,sortText:p.toString().padStart(c,"0"),range:n}))}})}async getCompletions(t){switch(t.type){case"UNKNOWN":return[];case"EMPTY":return this.labels.map(n=>({label:n,insertText:`{${n}="`,type:"LABEL_NAME"}));case"IN_LABEL_NAME":return this.labels.map(n=>({label:n,insertText:n,type:"LABEL_NAME"}));case"IN_LABEL_VALUE":let a=await this.getLabelValues(t.labelName);return a?a.map(n=>({label:n,insertText:t.betweenQuotes?n:`"${n}"`,type:"LABEL_VALUE"})):[];default:throw new Error(`Unexpected situation ${t}`)}}}function Ie(e,t){switch(e){case"LABEL_NAME":return t.languages.CompletionItemKind.Enum;case"LABEL_VALUE":return t.languages.CompletionItemKind.EnumMember;default:throw new Error(`Unexpected CompletionType: ${e}`)}}const j=/[a-zA-Z_][a-zA-Z0-9_]*/,Z=/[^"]*/,Ne=new RegExp(`(${j.source})="(${Z.source})"`,"g"),Ae=new RegExp(`(${j.source})=("?)${Z.source}$`),Pe=new RegExp(/[{,]\s*[a-zA-Z0-9_]*$/);function we(e,t){if(e==="")return{type:"EMPTY"};const a=e.matchAll(Ne),n=Array.from(a).reduce((u,c)=>{const[o,f,p]=c[1];return u.push({name:f,value:p}),u},[]),r=e.substring(0,t).match(Ae);return r?{type:"IN_LABEL_VALUE",labelName:r[1],betweenQuotes:!!r[2],otherLabels:n}:e.substring(0,t).match(Pe)?{type:"IN_LABEL_NAME",otherLabels:n}:{type:"UNKNOWN"}}function Re(e,t,a){const n=t.getWordAtPosition(a),r=n!=null?e.Range.lift({startLineNumber:a.lineNumber,endLineNumber:a.lineNumber,startColumn:n.startColumn,endColumn:n.endColumn}):e.Range.fromPositions(a),i={column:a.column,lineNumber:a.lineNumber};return{offset:t.getOffsetAt(i),range:r}}function Oe(e){const t=Me(e.getLabelValues,e.labels),a=(0,m.of)(Ve),n=(0,xe.A)(e.onRunQuery),r=(0,l.useRef)(null);return l.createElement("div",{className:a.wrapper,ref:r},l.createElement(Te.B,{value:e.value,language:h,onChange:e.onChange,containerStyles:a.queryField,monacoOptions:{folding:!1,fontSize:14,lineNumbers:"off",overviewRulerLanes:0,renderLineHighlight:"none",scrollbar:{vertical:"hidden",verticalScrollbarSize:8,horizontal:"hidden",horizontalScrollbarSize:0},scrollBeyondLastLine:!1,wordWrap:"on",padding:{top:4,bottom:5}},onBeforeEditorMount:De,onEditorDidMount:(i,u)=>{t(i,u);const c=()=>{const o=r.current;if(o!==null){const f=i.getContentHeight();o.style.height=`${f+Fe}px`,o.style.width="100%";const p=o.clientWidth;i.layout({width:p,height:f})}};i.onDidContentSizeChange(c),c(),i.addCommand(u.KeyMod.Shift|u.KeyCode.Enter,()=>{n.current(i.getValue())})}}))}const Fe=2;function Me(e,t){const a=(0,l.useRef)();a.current===void 0&&(a.current=new Ce),(0,H.A)(async()=>{a.current&&a.current.init(t||[],e)},[t,e]);const n=(0,l.useRef)(null);return(0,l.useEffect)(()=>()=>{n.current?.()},[]),(r,i)=>{if(a.current){a.current.editor=r,a.current.monaco=i;const{dispose:u}=i.languages.registerCompletionItemProvider(h,a.current);n.current=u}}}let X=!1;const h="pyroscopeql";function De(e){if(X===!1){X=!0;const{aliases:t,extensions:a,mimetypes:n,def:r}=Le;e.languages.register({id:h,aliases:t,extensions:a,mimetypes:n}),e.languages.setMonarchTokensProvider(h,r.language),e.languages.setLanguageConfiguration(h,r.languageConfiguration)}}const Ve=()=>({queryField:(0,d.css)` label: LabelsEditorQueryField; flex: 1; // Not exactly sure but without this the editor does not shrink after resizing (so you can make it bigger but not // smaller). At the same time this does not actually make the editor 100px because it has flex 1 so I assume // this should sort of act as a flex-basis (but flex-basis does not work for this). So yeah CSS magic. width: 100px; `,wrapper:(0,d.css)` label: LabelsEditorWrapper; display: flex; flex: 1; border: 1px solid rgba(36, 41, 46, 0.3); border-radius: 2px; `});var Be=s(17172),Qe=s(4402),$e=s(55852);const ze="plugins/grafana-pyroscope-datasource/query-links",b={};function dt(){Object.keys(b).forEach(e=>delete b[e])}function We(e){const{datasource:{uid:t},query:a,range:n}=e,{value:r}=(0,H.A)(async()=>{if(b[t])return b[t];const o=await(0,Be.AI)().get(`/api/datasources/uid/${t}`);return b[t]=o,o},[t]),i={datasourceUid:t,query:a,range:n,datasourceSettings:r},{extensions:u}=(0,Qe.Kf)({extensionPointId:ze,context:i}),c=(0,m.of)(Ue);return u.length===0?null:l.createElement(l.Fragment,null,u.map(o=>l.createElement($e.z9,{className:c.linkButton,key:`${o.id}`,variant:"secondary",icon:o.icon||"external-link-alt",tooltip:o.description,target:"_blank",href:o.path,onClick:o.onClick},o.title)))}function Ue(e){return{linkButton:(0,d.css)({marginLeft:e.spacing(1)})}}var ke=s(94354),J=s(10354),Ke=s(67892),Ge=s(56034),He=s(14578),je=s(88575);const T=e=>{const{label:t,optional:a,tooltip:n,children:r,width:i,...u}=e,c=(0,m.of)(Ze,i),o=u?.htmlFor||Ke?.getChildId(r),f=l.createElement(l.Fragment,null,l.createElement("label",{className:c.label,htmlFor:o},t,a&&l.createElement("span",{className:c.optional}," - optional"),n&&l.createElement(Ge.m,{placement:"top",content:n,theme:"info"},l.createElement(He.I,{name:"info-circle",size:"sm",className:c.icon}))),l.createElement("span",{className:c.space}));return l.createElement("div",{className:c.root},l.createElement(je.D,{className:c.field,label:f,...u},r))},Ze=(e,t)=>({space:(0,d.css)({paddingRight:e.spacing(0),paddingBottom:e.spacing(.5)}),root:(0,d.css)({minWidth:e.spacing(t??0)}),label:(0,d.css)({fontSize:12,fontWeight:e.typography.fontWeightMedium}),optional:(0,d.css)({fontStyle:"italic",color:e.colors.text.secondary}),field:(0,d.css)({marginBottom:0}),icon:(0,d.css)({color:e.colors.text.secondary,marginLeft:e.spacing(1),":hover":{color:e.colors.text.primary}})});var Xe=s(42941),Je=s(82762),Ye=s(67061);function qe({title:e,children:t,collapsedInfo:a}){const[n,r]=(0,Xe.A)(!1),i=(0,m.of)(_e);return l.createElement("div",{className:i.wrapper},l.createElement(Je.S,{className:i.collapse,collapsible:!0,isOpen:n,onToggle:r,label:l.createElement(Ye.B,{gap:0},l.createElement("h6",{className:i.title},e),!n&&l.createElement("div",{className:i.description},a.map((u,c)=>l.createElement("span",{key:c},u))))},l.createElement("div",{className:i.body},t)))}const _e=e=>({collapse:(0,d.css)({backgroundColor:"unset",border:"unset",marginBottom:0,["> button"]:{padding:e.spacing(0,1)}}),wrapper:(0,d.css)({width:"100%",display:"flex",justifyContent:"space-between",alignItems:"baseline"}),title:(0,d.css)({flexGrow:1,overflow:"hidden",fontSize:e.typography.bodySmall.fontSize,fontWeight:e.typography.fontWeightMedium,margin:0}),description:(0,d.css)({color:e.colors.text.secondary,fontSize:e.typography.bodySmall.fontSize,fontWeight:e.typography.bodySmall.fontWeight,paddingLeft:e.spacing(2),gap:e.spacing(2),display:"flex"}),body:(0,d.css)({display:"flex",gap:e.spacing(2),flexWrap:"wrap"})}),Y=[{value:"metrics",label:"Metric",description:"Return aggregated metrics"},{value:"profile",label:"Profile",description:"Return profile"},{value:"both",label:"Both",description:"Return both metric and profile data"}];function et(e){return e===Q.Jk.Explore?Y:Y.filter(t=>t.value!=="both")}function tt({query:e,onQueryChange:t,app:a,labels:n}){const r=(0,m.of)(at),i=et(a),u=n?n.map(o=>({label:o,value:o})):[];let c=[`Type: ${e.queryType}`];return e.groupBy?.length&&c.push(`Group by: ${e.groupBy.join(", ")}`),e.spanSelector?.length&&c.push(`Span ID: ${e.spanSelector.join(", ")}`),e.maxNodes&&c.push(`Max nodes: ${e.maxNodes}`),l.createElement(F,{gap:0,direction:"column"},l.createElement(qe,{title:"Options",collapsedInfo:c},l.createElement("div",{className:r.body},l.createElement(T,{label:"Query Type"},l.createElement(ke.z,{options:i,value:e.queryType,onChange:o=>t({...e,queryType:o})})),l.createElement(T,{label:"Group by",tooltip:l.createElement(l.Fragment,null,"Used to group the metric result by a specific label or set of labels. Does not apply to profile query.")},l.createElement(O.KF,{placeholder:"Label",value:e.groupBy,allowCustomValue:!0,options:u,onChange:o=>{const f=o.map(p=>p.value);t({...e,groupBy:f})}})),l.createElement(T,{label:"Span ID",tooltip:l.createElement(l.Fragment,null,"Sets the span ID from which to search for profiles.")},l.createElement(J.p,{value:e.spanSelector||[""],type:"string",placeholder:"64f170a95f537095",onChange:o=>{t({...e,spanSelector:o.currentTarget.value!==""?[o.currentTarget.value]:[]})}})),l.createElement(T,{label:"Max Nodes",tooltip:l.createElement(l.Fragment,null,"Sets the maximum number of nodes to return in the flamegraph.")},l.createElement(J.p,{value:e.maxNodes||"",type:"number",placeholder:"16384",onChange:o=>{let f=parseInt(o.currentTarget.value,10);f=isNaN(f)?0:f,t({...e,maxNodes:f})}})))))}const at=e=>({switchLabel:(0,d.css)({color:e.colors.text.secondary,cursor:"pointer",fontSize:e.typography.bodySmall.fontSize,"&:hover":{color:e.colors.text.primary}}),body:(0,d.css)({display:"flex",paddingTop:e.spacing(2),gap:e.spacing(2),flexWrap:"wrap"})}),lt=/(\w+)\s*=\s*("[^,"]+")/g;function nt(e){const{onChange:t,onRunQuery:a,datasource:n,query:r,range:i,app:u}=e;function c(M){t({...r,labelSelector:M}),a()}const o=it(r,t),f=z(n,i),{labels:p,getLabelValues:L}=st(i,n,r);rt(r,f,t,u);let g=l.createElement(B._,{text:"Loading"});return f&&r.profileTypeId!==void 0&&(g=l.createElement($,{placeholder:f.length===0?"No profile types found":"Select profile type",profileTypes:f,initialProfileTypeId:r.profileTypeId,onChange:M=>{t({...r,profileTypeId:M})}})),l.createElement(Se,null,l.createElement(G,{stackProps:{wrap:!1,gap:1}},g,l.createElement(Oe,{value:r.labelSelector,onChange:o,onRunQuery:c,labels:p,getLabelValues:L}),l.createElement(We,{...e})),l.createElement(G,null,l.createElement(tt,{query:r,onQueryChange:e.onChange,app:e.app,labels:p})))}function rt(e,t,a,n){(0,l.useEffect)(()=>{if(!t)return;const r=K(e,n);e.profileTypeId||(r.profileTypeId=ot(t)),te()(e,r)||a(r)},[n,e,t,a])}function ot(e){const t=e.filter(a=>a.id.indexOf("cpu")>=0);if(t.length){const a=t.find(n=>n.id.indexOf("samples")===-1);return a?a.id:t[0].id}return e[0]?.id||""}function st(e,t,a){const n={to:Math.ceil((e?.to.valueOf()||0)/1e4)*1e4,from:Math.floor((e?.from.valueOf()||0)/1e4)*1e4},r=(o,f,p)=>{let L=[`__profile_type__="${f}"`],g;for(;(g=lt.exec(o))!==null;)if(g[1]&&g[2]){if(g[1]===p)continue;L.push(`${g[1]}=${g[2]}`)}return`{${L.join(",")}}`},[i,u]=(0,l.useState)(()=>[""]);(0,l.useEffect)(()=>{(async()=>{const f=await t.getLabelNames(r(a.labelSelector,a.profileTypeId,""),n.from,n.to);u(f)})()},[a,n.from,n.to,t,u]);const c=(0,l.useCallback)(o=>{const f=r(a.labelSelector,a.profileTypeId,o);return t.getLabelValues(f,o,n.from,n.to)},[t,a.labelSelector,a.profileTypeId,n.to,n.from]);return{labels:i,getLabelValues:c}}function it(e,t){const a=(0,l.useRef)(e);a.current=e;const n=(0,V.debounce)(i=>{t&&t({...a.current,labelSelector:i})},200);return(0,l.useCallback)(i=>{n(i)},[n])}const ct=new C.tD(he).setConfigEditor(_).setQueryEditor(nt)},39554:(q,v,s)=>{s.d(v,{A:()=>I});var C=s(96540),l=function(E){var y=(0,C.useRef)(E);return y.current=E,y};const I=l}}]); //# sourceMappingURL=pyroscopePlugin.eb14b78419d619d90dca.js.map