/*! For license information please see 8420.8128b05ac04b15cbf98d.js.LICENSE.txt */
(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8420],{"./public/app/core/components/NodeGraphSettings.tsx":(e,t,n)=>{"use strict";n.d(t,{n:()=>l});n("./node_modules/react/index.js");var a,s=n("./node_modules/@emotion/css/dist/emotion-css.esm.js"),r=n("./packages/grafana-data/src/index.ts"),i=n("./packages/grafana-ui/src/index.ts"),o=n("./node_modules/react/jsx-runtime.js");function l({options:e,onOptionsChange:t}){var n;const s=(0,i.useStyles)(u);return(0,o.jsxs)("div",{className:s.container,children:[a||(a=(0,o.jsx)("h3",{className:"page-heading",children:"Node Graph"})),(0,o.jsx)(i.InlineFieldRow,{className:s.row,children:(0,o.jsx)(i.InlineField,{tooltip:"Enables the Node Graph visualization in the trace viewer.",label:"Enable Node Graph",labelWidth:26,children:(0,o.jsx)(i.InlineSwitch,{value:null===(n=e.jsonData.nodeGraph)||void 0===n?void 0:n.enabled,onChange:n=>(0,r.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"nodeGraph",Object.assign({},e.jsonData.nodeGraph,{enabled:n.currentTarget.checked}))})})})]})}const u=e=>({container:s.css`
    label: container;
    width: 100%;
  `,row:s.css`
    label: row;
    align-items: baseline;
  `})},"./public/app/core/components/TraceToLogsSettings.tsx":(e,t,n)=>{"use strict";n.d(t,{Z:()=>u});var a,s=n("./node_modules/@emotion/css/dist/emotion-css.esm.js"),r=n("./packages/grafana-data/src/index.ts"),i=n("./packages/grafana-runtime/src/index.ts"),o=n("./packages/grafana-ui/src/index.ts"),l=(n("./node_modules/react/index.js"),n("./node_modules/react/jsx-runtime.js"));function u({options:e,onOptionsChange:t}){var n,u,c,h,p,g,f;const m=(0,o.useStyles)(d);return(0,l.jsxs)("div",{className:(0,s.css)({width:"100%"}),children:[a||(a=(0,l.jsx)("h3",{className:"page-heading",children:"Trace to logs"})),(0,l.jsx)("div",{className:m.infoText,children:"Trace to logs let's you navigate from a trace span to the selected data source's log."}),(0,l.jsx)(o.InlineFieldRow,{children:(0,l.jsx)(o.InlineField,{tooltip:"The data source the trace is going to navigate to",label:"Data source",labelWidth:26,children:(0,l.jsx)(i.DataSourcePicker,{pluginId:"loki",current:null===(n=e.jsonData.tracesToLogs)||void 0===n?void 0:n.datasourceUid,noDefault:!0,width:40,onChange:n=>{var a;return(0,r.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToLogs",{datasourceUid:n.uid,tags:null===(a=e.jsonData.tracesToLogs)||void 0===a?void 0:a.tags})}})})}),(0,l.jsx)(o.InlineFieldRow,{children:(0,l.jsx)(o.InlineField,{tooltip:"Tags that will be used in the Loki query. Default tags: 'cluster', 'hostname', 'namespace', 'pod'",label:"Tags",labelWidth:26,children:(0,l.jsx)(o.TagsInput,{tags:null===(u=e.jsonData.tracesToLogs)||void 0===u?void 0:u.tags,width:40,onChange:n=>{var a;return(0,r.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToLogs",{datasourceUid:null===(a=e.jsonData.tracesToLogs)||void 0===a?void 0:a.datasourceUid,tags:n})}})})}),(0,l.jsx)(o.InlineFieldRow,{children:(0,l.jsx)(o.InlineField,{label:"Span start time shift",labelWidth:26,grow:!0,tooltip:"Shifts the start time of the span. Default 0 (Time units can be used here, for example: 5s, 1m, 3h)",children:(0,l.jsx)(o.Input,{type:"text",placeholder:"1h",width:40,onChange:n=>(0,r.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToLogs",Object.assign({},e.jsonData.tracesToLogs,{spanStartTimeShift:n.currentTarget.value})),value:(null===(c=e.jsonData.tracesToLogs)||void 0===c?void 0:c.spanStartTimeShift)||""})})}),(0,l.jsx)(o.InlineFieldRow,{children:(0,l.jsx)(o.InlineField,{label:"Span end time shift",labelWidth:26,grow:!0,tooltip:"Shifts the end time of the span. Default 0 Time units can be used here, for example: 5s, 1m, 3h",children:(0,l.jsx)(o.Input,{type:"text",placeholder:"1h",width:40,onChange:n=>(0,r.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToLogs",Object.assign({},e.jsonData.tracesToLogs,{spanEndTimeShift:n.currentTarget.value})),value:(null===(h=e.jsonData.tracesToLogs)||void 0===h?void 0:h.spanEndTimeShift)||""})})}),(0,l.jsx)(o.InlineFieldRow,{children:(0,l.jsx)(o.InlineField,{label:"Filter by Trace ID",labelWidth:26,grow:!0,tooltip:"Filters logs by Trace ID. Appends '|=<trace id>' to the query.",children:(0,l.jsx)(o.InlineSwitch,{value:null===(p=e.jsonData.tracesToLogs)||void 0===p?void 0:p.filterByTraceID,onChange:n=>(0,r.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToLogs",Object.assign({},e.jsonData.tracesToLogs,{filterByTraceID:n.currentTarget.checked}))})})}),(0,l.jsx)(o.InlineFieldRow,{children:(0,l.jsx)(o.InlineField,{label:"Filter by Span ID",labelWidth:26,grow:!0,tooltip:"Filters logs by Span ID. Appends '|=<span id>' to the query.",children:(0,l.jsx)(o.InlineSwitch,{value:null===(g=e.jsonData.tracesToLogs)||void 0===g?void 0:g.filterBySpanID,onChange:n=>(0,r.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToLogs",Object.assign({},e.jsonData.tracesToLogs,{filterBySpanID:n.currentTarget.checked}))})})}),(0,l.jsx)(o.InlineFieldRow,{children:(0,l.jsx)(o.InlineField,{label:"Loki Search",labelWidth:26,grow:!0,tooltip:"Use this logs data source to search for traces.",children:(0,l.jsx)(o.InlineSwitch,{defaultChecked:!0,value:null===(f=e.jsonData.tracesToLogs)||void 0===f?void 0:f.lokiSearch,onChange:n=>(0,r.updateDatasourcePluginJsonDataOption)({onOptionsChange:t,options:e},"tracesToLogs",Object.assign({},e.jsonData.tracesToLogs,{lokiSearch:n.currentTarget.checked}))})})})]})}const d=e=>({infoText:s.css`
    padding-bottom: ${e.spacing.md};
    color: ${e.colors.textSemiWeak};
  `})},"./public/app/core/utils/tracing.ts":(e,t,n)=>{"use strict";n.d(t,{et:()=>s,nO:()=>r,fy:()=>i,np:()=>l});var a=n("./packages/grafana-data/src/index.ts");function s(e){e.sort(((e,t)=>e[0]-t[0]));return e.reduce(((e,t)=>{if(!e.length)return[t];const n=e.slice(-1)[0],[a,s]=n,[r,i]=t;return i<s?e:r>s?[...e,t]:[...e.slice(0,-1),[a,i]]}),[]).reduce(((e,t)=>e+(t[1]-t[0])),0)}function r(e){const t={};let n;for(let a=0;n=e(a),n;a++){t[n.id]?t[n.id].span=n.span:t[n.id]={span:n.span,children:[]};for(const e of n.parentIds)e&&(t[e]?t[e].children.push(n.id):t[e]={span:void 0,children:[n.id]})}return t}function i(e,t,n){return{main:`${o(e)}ms (${o(e/t*100)}%)`,secondary:`${o(n)}ms (${o(n/e*100)}%)`}}function o(e){return parseFloat(e.toFixed(2))}function l(){return[new a.MutableDataFrame({fields:[{name:a.NodeGraphDataFrameFieldNames.id,type:a.FieldType.string},{name:a.NodeGraphDataFrameFieldNames.title,type:a.FieldType.string},{name:a.NodeGraphDataFrameFieldNames.subTitle,type:a.FieldType.string},{name:a.NodeGraphDataFrameFieldNames.mainStat,type:a.FieldType.string,config:{displayName:"Total time (% of trace)"}},{name:a.NodeGraphDataFrameFieldNames.secondaryStat,type:a.FieldType.string,config:{displayName:"Self time (% of total)"}},{name:a.NodeGraphDataFrameFieldNames.color,type:a.FieldType.number,config:{color:{mode:"continuous-GrYlRd"},displayName:"Self time / Trace duration"}}],meta:{preferredVisualisationType:"nodeGraph"}}),new a.MutableDataFrame({fields:[{name:a.NodeGraphDataFrameFieldNames.id,type:a.FieldType.string},{name:a.NodeGraphDataFrameFieldNames.target,type:a.FieldType.string},{name:a.NodeGraphDataFrameFieldNames.source,type:a.FieldType.string}],meta:{preferredVisualisationType:"nodeGraph"}})]}},"./public/app/plugins/datasource/jaeger/module.ts":(e,t,n)=>{"use strict";n.r(t),n.d(t,{plugin:()=>R});var a=n("./packages/grafana-data/src/index.ts"),s=n("./node_modules/lodash/lodash.js"),r=n("./node_modules/rxjs/dist/esm5/internal/lastValueFrom.js"),i=n("./node_modules/rxjs/dist/esm5/internal/observable/of.js"),o=n("./node_modules/rxjs/dist/esm5/internal/operators/map.js"),l=n("./node_modules/rxjs/dist/esm5/internal/operators/catchError.js"),u=n("./packages/grafana-runtime/src/index.ts"),d=n("./public/app/core/utils/fetch.ts"),c=n("./public/app/features/dashboard/services/TimeSrv.ts"),h=n("./public/app/plugins/datasource/jaeger/responseTransform.ts"),p=n("./public/app/core/utils/tracing.ts");function g(e){const{nodes:t,edges:n}=function(e){const t=[],n=[],s=function(e){let t=0,n=1/0;for(const a of e)a.startTime<n&&(n=a.startTime),a.startTime+a.duration>t&&(t=a.startTime+a.duration);return t-n}(e.spans),r=(0,p.nO)((t=>{var n;if(t>=e.spans.length)return;const a=e.spans[t];return{span:a,id:a.spanID,parentIds:(null===(n=a.references)||void 0===n?void 0:n.filter((e=>"CHILD_OF"===e.refType)).map((e=>e.spanID)))||[]}}));for(const u of e.spans){var i,o,l;const d=e.processes[u.processID],c=r[u.spanID].children.map((e=>{const t=r[e].span;return[t.startTime,t.startTime+t.duration]})),h=(0,p.et)(c),g=u.duration-h,f=(0,p.fy)(u.duration/1e3,s/1e3,g/1e3);t.push({[a.NodeGraphDataFrameFieldNames.id]:u.spanID,[a.NodeGraphDataFrameFieldNames.title]:null!==(i=null==d?void 0:d.serviceName)&&void 0!==i?i:"",[a.NodeGraphDataFrameFieldNames.subTitle]:u.operationName,[a.NodeGraphDataFrameFieldNames.mainStat]:f.main,[a.NodeGraphDataFrameFieldNames.secondaryStat]:f.secondary,[a.NodeGraphDataFrameFieldNames.color]:g/s});const m=null===(o=u.references)||void 0===o||null===(l=o.find((e=>"CHILD_OF"===e.refType)))||void 0===l?void 0:l.spanID;m&&r[m].span&&n.push({[a.NodeGraphDataFrameFieldNames.id]:m+"--"+u.spanID,[a.NodeGraphDataFrameFieldNames.target]:u.spanID,[a.NodeGraphDataFrameFieldNames.source]:m})}return{nodes:t,edges:n}}(e),[s,r]=(0,p.np)();for(const e of t)s.add(e);for(const e of n)r.add(e);return[s,r]}var f=n("./node_modules/logfmt/logfmt.js"),m=n.n(f);function v(e){if(!e)return"";const t=m().parse(e);return Object.keys(t).forEach((e=>{const n=t[e];"string"!=typeof n&&(t[e]=String(n))})),JSON.stringify(t)}function b(e){if(!e)return"";try{return m().stringify(JSON.parse(e))}catch{return e}}var y=n("./node_modules/@emotion/css/dist/emotion-css.esm.js"),j=n("./packages/grafana-ui/src/index.ts"),x=n("./node_modules/react/index.js"),T=n("./node_modules/react-transition-group/esm/CSSTransition.js"),D=n("./node_modules/react/jsx-runtime.js");const w="e.g. 1.2s, 100ms, 500us";function F({query:e,onChange:t}){const[n,a]=(0,x.useState)(!1),s=(0,j.useStyles)(N);return(0,D.jsxs)("div",{children:[(0,D.jsx)(j.InlineFieldRow,{children:(0,D.jsx)("div",{className:s.advancedOptionsContainer,onClick:()=>a(!n),children:(0,D.jsxs)(j.InlineLabel,{as:"div",children:["Advanced options"," ",(0,D.jsx)(j.Icon,{className:n?s.angleUp:s.angleDown,name:"angle-down"})]})})}),(0,D.jsx)(T.Z,{in:n,mountOnEnter:!0,unmountOnExit:!0,timeout:300,classNames:s,children:(0,D.jsxs)("div",{children:[(0,D.jsx)(j.InlineFieldRow,{children:(0,D.jsx)(j.InlineField,{label:"Min Duration",labelWidth:21,grow:!0,children:(0,D.jsx)(j.Input,{value:e.minDuration||"",placeholder:w,onChange:n=>t(Object.assign({},e,{minDuration:n.currentTarget.value}))})})}),(0,D.jsx)(j.InlineFieldRow,{children:(0,D.jsx)(j.InlineField,{label:"Max Duration",labelWidth:21,grow:!0,children:(0,D.jsx)(j.Input,{value:e.maxDuration||"",placeholder:w,onChange:n=>t(Object.assign({},e,{maxDuration:n.currentTarget.value}))})})}),(0,D.jsx)(j.InlineFieldRow,{children:(0,D.jsx)(j.InlineField,{label:"Limit",labelWidth:21,grow:!0,tooltip:"Maximum numbers of returned results",children:(0,D.jsx)(j.Input,{value:e.limit||"",type:"number",onChange:n=>t(Object.assign({},e,{limit:n.currentTarget.value?parseInt(n.currentTarget.value,10):void 0}))})})})]})})]})}function N(e){return{advancedOptionsContainer:y.css`
      margin: 0 ${e.spacing.xs} ${e.spacing.xs} 0;
      width: 100%;
      cursor: pointer;
    `,enter:y.css`
      label: enter;
      height: 0;
      opacity: 0;
    `,enterActive:y.css`
      label: enterActive;
      height: 108px;
      opacity: 1;
      transition: height 300ms ease, opacity 300ms ease;
    `,exit:y.css`
      label: exit;
      height: 108px;
      opacity: 1;
    `,exitActive:y.css`
      label: exitActive;
      height: 0;
      opacity: 0;
      transition: height 300ms ease, opacity 300ms ease;
    `,angleUp:y.css`
      transform: rotate(-180deg);
      transition: transform 300ms;
    `,angleDown:y.css`
      transform: rotate(0deg);
      transition: transform 300ms;
    `}}const S={label:"All",value:void 0};function I({datasource:e,query:t,onChange:n}){const[a,s]=(0,x.useState)(),[r,i]=(0,x.useState)();return(0,x.useEffect)((()=>{(async()=>{const t=await _({dataSource:e,url:"/api/services",notFoundLabel:"No service found"});s(t)})()}),[e]),(0,x.useEffect)((()=>{t.service&&(async()=>{const n=await _({dataSource:e,url:`/api/services/${encodeURIComponent(t.service)}/operations`,notFoundLabel:"No operation found"});i([S,...n])})()}),[e,t.service]),(0,D.jsxs)("div",{className:(0,y.css)({maxWidth:"500px"}),children:[(0,D.jsx)(j.InlineFieldRow,{children:(0,D.jsx)(j.InlineField,{label:"Service",labelWidth:14,grow:!0,children:(0,D.jsx)(j.Select,{menuShouldPortal:!0,options:a,value:(null==a?void 0:a.find((e=>e.value===t.service)))||null,onChange:e=>{n(Object.assign({},t,{service:e.value,operation:t.service!==e.value?void 0:t.operation}))},menuPlacement:"bottom",isClearable:!0})})}),(0,D.jsx)(j.InlineFieldRow,{children:(0,D.jsx)(j.InlineField,{label:"Operation",labelWidth:14,grow:!0,disabled:!t.service,children:(0,D.jsx)(j.Select,{menuShouldPortal:!0,options:r,value:(null==r?void 0:r.find((e=>e.value===t.operation)))||null,onChange:e=>n(Object.assign({},t,{operation:e.value})),menuPlacement:"bottom",isClearable:!0})})}),(0,D.jsx)(j.InlineFieldRow,{children:(0,D.jsx)(j.InlineField,{label:"Tags",labelWidth:14,grow:!0,children:(0,D.jsx)(j.Input,{value:b(t.tags),placeholder:"http.status_code=200 error=true",onChange:e=>n(Object.assign({},t,{tags:e.currentTarget.value}))})})}),(0,D.jsx)(F,{query:t,onChange:n})]})}const _=async({dataSource:e,url:t,notFoundLabel:n})=>{const a=await e.metadataRequest(t);if(!a)return[{label:n,value:n}];return a.sort().map((e=>({label:e,value:e})))};function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class C extends a.DataSourceApi{constructor(e,t=(0,c.$t)()){super(e),O(this,"uploadedJson",null),O(this,"nodeGraph",void 0),this.instanceSettings=e,this.timeSrv=t,this.nodeGraph=e.jsonData.nodeGraph}async metadataRequest(e,t){return(await(0,r.n)(this._request(e,t,{hideFromInspector:!0}))).data.data}query(e){const t=e.targets[0];if(!t)return(0,i.of)({data:[q]});if("search"!==t.queryType&&t.query)return this._request(`/api/traces/${encodeURIComponent(t.query)}`).pipe((0,o.U)((e=>{var t,n,a;const s=null==e||null===(t=e.data)||void 0===t||null===(n=t.data)||void 0===n?void 0:n[0];if(!s)return{data:[q]};let r=[(0,h.xM)(s)];return null!==(a=this.nodeGraph)&&void 0!==a&&a.enabled&&r.push(...g(s)),{data:r}})));if("upload"===t.queryType){if(!this.uploadedJson)return(0,i.of)({data:[]});try{var n;const e=JSON.parse(this.uploadedJson).data[0];let t=[(0,h.xM)(e)];return null!==(n=this.nodeGraph)&&void 0!==n&&n.enabled&&t.push(...g(e)),(0,i.of)({data:t})}catch(e){return(0,i.of)({error:{message:"JSON is not valid Jaeger format"},data:[]})}}let a=(0,s.pick)(t,["operation","service","tags","minDuration","maxDuration","limit"]);return a=(0,s.pickBy)(a,s.identity),a.tags&&(a=Object.assign({},a,{tags:v(a.tags)})),"All"===a.operation&&(a=(0,s.omit)(a,"operation")),this._request("/api/traces",Object.assign({},a,this.getTimeRange(),{lookback:"custom"})).pipe((0,o.U)((e=>({data:[(0,h.Wp)(e.data.data,this.instanceSettings)]}))))}async testDatasource(){return(0,r.n)(this._request("/api/services").pipe((0,o.U)((e=>{var t;return((null==e||null===(t=e.data)||void 0===t?void 0:t.data)||[]).length>0?{status:"success",message:"Data source connected and services found."}:{status:"error",message:"Data source connected, but no services received. Verify that Jaeger is configured properly."}})),(0,l.K)((e=>{let t="Jaeger: ";return e.statusText?t+=e.statusText:t+="Cannot connect to Jaeger",e.status&&(t+=`. ${e.status}`),e.data&&e.data.message?t+=`. ${e.data.message}`:e.data&&(t+=`. ${JSON.stringify(e.data)}`),(0,i.of)({status:"error",message:t})}))))}getTimeRange(){const e=this.timeSrv.timeRange();return{start:k(e.from,!1),end:k(e.to,!0)}}getQueryDisplayText(e){return e.query||""}_request(e,t,n){const a=t?(0,d.tW)(t):"",s=`${this.instanceSettings.url}${e}${a.length?`?${a}`:""}`,r=Object.assign({},n,{url:s});return(0,u.getBackendSrv)().fetch(r)}}function k(e,t){return"string"==typeof e&&(e=a.dateMath.parse(e,t)),1e3*e.valueOf()}const q=new a.MutableDataFrame({fields:[{name:"trace",type:a.FieldType.trace,values:[]}],meta:{preferredVisualisationType:"trace",custom:{traceFormat:"jaeger"}}});var L=n("./public/app/core/components/NodeGraphSettings.tsx"),G=n("./public/app/core/components/TraceToLogsSettings.tsx");const R=new a.DataSourcePlugin(C).setConfigEditor((({options:e,onOptionsChange:t})=>(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(j.DataSourceHttpSettings,{defaultUrl:"http://localhost:16686",dataSourceConfig:e,showAccessOptions:!1,onChange:t}),(0,D.jsx)("div",{className:"gf-form-group",children:(0,D.jsx)(G.Z,{options:e,onOptionsChange:t})}),(0,D.jsx)("div",{className:"gf-form-group",children:(0,D.jsx)(L.n,{options:e,onOptionsChange:t})})]}))).setQueryEditor((function({datasource:e,query:t,onChange:n,onRunQuery:a}){var s;const r=(0,j.useTheme2)(),i=e=>{const a=Object.assign({},t,{query:e});n(a)};return(0,D.jsx)(D.Fragment,{children:(0,D.jsxs)("div",{className:(0,y.css)({width:"100%"}),children:[(0,D.jsx)(j.InlineFieldRow,{children:(0,D.jsx)(j.InlineField,{label:"Query type",children:(0,D.jsx)(j.RadioButtonGroup,{options:[{value:"search",label:"Search"},{value:void 0,label:"TraceID"},{value:"upload",label:"JSON file"}],value:t.queryType,onChange:e=>n(Object.assign({},t,{queryType:e})),size:"md"})})}),(()=>{switch(t.queryType){case"search":return s||(s=(0,D.jsx)(I,{datasource:e,query:t,onChange:n}));case"upload":return(0,D.jsx)("div",{className:(0,y.css)({padding:r.spacing(2)}),children:(0,D.jsx)(j.FileDropzone,{options:{multiple:!1},onLoad:t=>{e.uploadedJson=t,a()}})});default:return(0,D.jsx)(j.InlineFieldRow,{children:(0,D.jsx)(j.InlineField,{label:"Trace ID",labelWidth:14,grow:!0,children:(0,D.jsx)(j.QueryField,{query:t.query,onChange:i,onRunQuery:a,onBlur:()=>{},placeholder:"Enter a Trace ID (run with Shift+Enter)",portalOrigin:"jaeger"})})})}})()]})})}))},"./node_modules/logfmt/lib/body_parser.js":(e,t)=>{e.exports=function(e){return null==e&&(e={}),function(t,n,a){return t._body?a():t.header("content-type")===e.contentType?(t._body=!0,t.body=t.body||{},s="",t.setEncoding("utf8"),t.on("data",(function(e){return s+=e})),void t.on("end",(function(){try{var n=[];s.trim().split("\n").forEach((function(t){n.push(e.parser(t))})),t.body=n}catch(e){return e.body=s,e.status=400,a(e)}return a()}))):a();var s}}},"./node_modules/logfmt/lib/body_parser_stream.js":(e,t,n)=>{n("./node_modules/split/index.js"),n("./node_modules/through/index.js"),n("?45f7").Readable;var a=n("?45f7").PassThrough,s=n("./node_modules/logfmt/logfmt.js");e.exports=function(e){null==e&&(e={});var t=e.contentType||"application/logplex-1";return function(e,n,r){return e._body?r():e.header("content-type")===t?(e._body=!0,e.body=new a({objectMode:!0}),e.pipe(s.streamParser()).pipe(e.body),r()):r()}}},"./node_modules/logfmt/lib/logfmt_parser.js":(e,t)=>{t.debug=!1,t.parse=function(e){var n="",a="",s=!1,r=!1,i=!1,o=!1,l={},u=t.debug;"\n"==e[e.length-1]&&(e=e.slice(0,e.length-1));for(var d=0;d<=e.length;d++){if(" "==e[d]&&!i||d==e.length){if(s&&n.length>0?l[n]=!0:r&&("true"==a?a=!0:"false"==a?a=!1:""!==a||o||(a=null),l[n]=a,a=""),d==e.length)break;s=!1,r=!1,i=!1,o=!1}"="!=e[d]||i?"\\"==e[d]?(a+=e[++d],u&&console.log("escape: "+e[d])):'"'==e[d]?(o=!0,i=!i,u&&console.log("in quote: "+i)):" "==e[d]||r||s?s?(u&&console.log("add to key: "+e[d]),n+=e[d]):r&&(u&&console.log("add to value: "+e[d]),a+=e[d]):(u&&console.log("start key with: "+e[d]),s=!0,n=e[d]):(u&&console.log("split"),s=!1,r=!0)}return l}},"./node_modules/logfmt/lib/logger.js":(e,t,n)=>{t.log=function(e,t){this.stream=this.stream||process.stdout,null==t&&(t=this.stream);var n=Object.assign({},this.defaultData,e);if(this.timers)for(var a in this.timers){var s=(new Date).getTime();n[a]=(s-this.timers[a]).toString()+"ms"}t.write(this.stringify(n)+"\n")},t.time=function(e){var t=n("./node_modules/logfmt/logfmt.js"),a=(new Date).getTime(),s=(e=e||"elapsed",new t);return s.stream=this.stream,s.defaultData=this.defaultData,s.timers=Object.assign({},this.timers),s.timers[e]=a,s},t.namespace=function(e){var t=new(n("./node_modules/logfmt/logfmt.js")),a=Object.assign({},this.defaultData,e);return t.stream=this.stream,t.defaultData=a,t.timers=this.timers,t},t.error=function(e,t){this.maxErrorLines=this.maxErrorLines||10,void 0===t&&(t=Math.random().toString().slice(2,12));var n=this.namespace({error:!0,id:t,now:(new Date).toISOString()});if(n.log({message:e.message}),e.stack){var a=e.stack.split("\n");for(var s in a){if(s>=this.maxErrorLines)break;n.log({line:s,trace:a[s]})}}}},"./node_modules/logfmt/lib/request_logger.js":(e,t)=>{var n=function(e,t){if("function"==typeof e.path)var n=e.path();else n=e.originalUrl||e.path||e.url;var a=e.header&&e.header("x-forwarded-for"),s=e.header&&e.header("x-request-id"),r={ip:e.ip||a||e.connection.remoteAddress,time:(new Date).toISOString(),method:e.method,path:n,status:t.statusCode};return s&&(r.request_id=s),t.get&&(r.content_length=t.get("content-length"),r.content_type=t.get("content-type")),r};t.init=function(e,t,a){return this.logger=e,a||t?a||("function"==typeof t?(a=t,t={}):a=n):(a=n,t={}),(t=t||{}).immediate?function(e,t,n){return function(t,a,s){var r=n(t,a);e.log(r),s()}}(e,0,a):function(e,t,n){return function(a,s,r){var i=t.elapsed||"elapsed",o=e.time(i),l=s.end;s.end=function(e,t){var r=n(a,s);s.end=l,s.end(e,t),o.log(r)},r()}}(e,t,a)},t.commonFormatter=n},"./node_modules/logfmt/lib/streaming.js":(e,t,n)=>{var a=n("./node_modules/split/index.js"),s=n("./node_modules/through/index.js"),r=n("?45f7").PassThrough;t.streamParser=function(e){var t=new r,n=this,i=s((function(e){""!==e&&this.queue(n.parse(e))}));return t.on("pipe",(function(e){e.unpipe&&e.unpipe(this),this.transformStream=e.pipe(a()).pipe(i)})),t.pipe=function(e,t){return this.transformStream.pipe(e,t)},t},t.streamStringify=function(e){var t=this;if((e=e||{}).hasOwnProperty("delimiter"))var n=e.delimiter;else n="\n";return s((function(e){this.queue(t.stringify(e)+n)}),(function(){this.queue(null)}))}},"./node_modules/logfmt/lib/stringify.js":(e,t)=>{t.stringify=function(e){var t="";for(var n in e){var a=e[n],s=!1;null==a?(s=!0,a=""):a=a.toString();var r=a.indexOf(" ")>-1||a.indexOf("=")>-1;(a.indexOf('"')>-1||a.indexOf("\\")>-1)&&(a=a.replace(/["\\]/g,"\\$&")),r&&(a='"'+a+'"'),""!==a||s||(a='""'),t+=n+"="+a+" "}return t.substring(0,t.length-1)}},"./node_modules/logfmt/logfmt.js":(e,t,n)=>{function a(){}e.exports=a;var s=n("./node_modules/logfmt/lib/streaming.js"),r=n("./node_modules/logfmt/lib/body_parser.js"),i=n("./node_modules/logfmt/lib/body_parser_stream.js"),o=n("./node_modules/logfmt/lib/logfmt_parser.js"),l=n("./node_modules/logfmt/lib/logger.js"),u=n("./node_modules/logfmt/lib/request_logger.js"),d=n("./node_modules/logfmt/lib/stringify.js");Object.assign(a.prototype,l),Object.assign(a.prototype,s),a.prototype.stringify=d.stringify,a.prototype.parse=o.parse,a.prototype.bodyParser=function(e){e||(e={});var t=e.contentType||"application/logplex-1";return r({contentType:t,parser:this.parse})},a.prototype.bodyParserStream=function(e){e||(e={});var t=e.contentType||"application/logplex-1";return i({contentType:t})},a.prototype.requestLogger=function(e,t){return u.init(this,e,t)},a.prototype.requestLogger.commonFormatter=u.commonFormatter,Object.assign(a,a.prototype)},"./node_modules/safe-buffer/index.js":(e,t,n)=>{var a=n("./node_modules/buffer/index.js"),s=a.Buffer;function r(e,t){for(var n in e)t[n]=e[n]}function i(e,t,n){return s(e,t,n)}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?e.exports=a:(r(a,t),t.Buffer=i),i.prototype=Object.create(s.prototype),r(s,i),i.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return s(e,t,n)},i.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var a=s(e);return void 0!==t?"string"==typeof n?a.fill(t,n):a.fill(t):a.fill(0),a},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return s(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return a.SlowBuffer(e)}},"./node_modules/split/index.js":(e,t,n)=>{var a=n("./node_modules/through/index.js"),s=n("./node_modules/string_decoder/lib/string_decoder.js").s;e.exports=function(e,t){var n=new s,r="";"function"==typeof e&&(t=e,e=null);e||(e=/\r?\n/);function i(e,n){if(t){try{n=t(n)}catch(t){return e.emit("error",t)}void 0!==n&&e.queue(n)}else e.queue(n)}function o(t,n){var a=(r+n).split(e);r=a.pop();for(var s=0;s<a.length;s++){i(t,a[s])}}return a((function(e){o(this,n.write(e))}),(function(){n.end&&o(this,n.end()),null!=r&&i(this,r),this.queue(null)}))}},"./node_modules/string_decoder/lib/string_decoder.js":(e,t,n)=>{"use strict";var a=n("./node_modules/safe-buffer/index.js").Buffer,s=a.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(a.isEncoding===s||!s(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=l,this.end=u,t=4;break;case"utf8":this.fillLast=o,t=4;break;case"base64":this.text=d,this.end=c,t=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=a.allocUnsafe(t)}function i(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function o(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function l(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var a=n.charCodeAt(n.length-1);if(a>=55296&&a<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function d(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function c(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}t.s=r,r.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},r.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},r.prototype.text=function(e,t){var n=function(e,t,n){var a=t.length-1;if(a<n)return 0;var s=i(t[a]);if(s>=0)return s>0&&(e.lastNeed=s-1),s;if(--a<n||-2===s)return 0;if((s=i(t[a]))>=0)return s>0&&(e.lastNeed=s-2),s;if(--a<n||-2===s)return 0;if((s=i(t[a]))>=0)return s>0&&(2===s?s=0:e.lastNeed=s-3),s;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var a=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,a),e.toString("utf8",t,a)},r.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},"./node_modules/through/index.js":(e,t,n)=>{var a=n("?0354");function s(e,t,n){e=e||function(e){this.queue(e)},t=t||function(){this.queue(null)};var s=!1,r=!1,i=[],o=!1,l=new a;function u(){for(;i.length&&!l.paused;){var e=i.shift();if(null===e)return l.emit("end");l.emit("data",e)}}function d(){l.writable=!1,t.call(l),!l.readable&&l.autoDestroy&&l.destroy()}return l.readable=l.writable=!0,l.paused=!1,l.autoDestroy=!(n&&!1===n.autoDestroy),l.write=function(t){return e.call(this,t),!l.paused},l.queue=l.push=function(e){return o||(null===e&&(o=!0),i.push(e),u()),l},l.on("end",(function(){l.readable=!1,!l.writable&&l.autoDestroy&&process.nextTick((function(){l.destroy()}))})),l.end=function(e){if(!s)return s=!0,arguments.length&&l.write(e),d(),l},l.destroy=function(){if(!r)return r=!0,s=!0,i.length=0,l.writable=l.readable=!1,l.emit("close"),l},l.pause=function(){if(!l.paused)return l.paused=!0,l},l.resume=function(){return l.paused&&(l.paused=!1,l.emit("resume")),u(),l.paused||l.emit("drain"),l},l}e.exports=s,s.through=s}}]);
//# sourceMappingURL=8420.8128b05ac04b15cbf98d.js.map