dt-app
Version:
The Dynatrace App Toolkit is a tool you can use from your command line to create, develop, and deploy apps on your Dynatrace environment.
67 lines (51 loc) • 138 kB
JavaScript
"use strict";var _l=Object.create;var Fn=Object.defineProperty;var Bl=Object.getOwnPropertyDescriptor;var Ml=Object.getOwnPropertyNames;var Ul=Object.getPrototypeOf,$l=Object.prototype.hasOwnProperty;var b=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(o){throw n=[o],o}};var Xo=(e,t)=>{for(var n in t)Fn(e,n,{get:t[n],enumerable:!0})},li=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ml(t))!$l.call(e,r)&&r!==n&&Fn(e,r,{get:()=>t[r],enumerable:!(o=Bl(t,r))||o.enumerable});return e};var O=(e,t,n)=>(n=e!=null?_l(Ul(e)):{},li(t||!e||!e.__esModule?Fn(n,"default",{value:e,enumerable:!0}):n,e)),Nl=e=>li(Fn({},"__esModule",{value:!0}),e);function z(e){if(e.sourcemaps===void 0)return e.dev?jl:pi;switch(e.sourcemaps){case!0:return{sourcemap:!0,includeVendorSourceMaps:!1};case!1:return{sourcemap:!1,includeVendorSourceMaps:!1};case"all":return{sourcemap:!0,includeVendorSourceMaps:!0};default:return pi}}var pi,jl,Ne=b(()=>{"use strict";pi={sourcemap:!1,includeVendorSourceMaps:!1},jl={sourcemap:!0,includeVendorSourceMaps:!0}});function mt(e,t){let n=ce.posix.normalize(ce.posix.join(t.split(ce.win32.sep).join(ce.posix.sep),"/")),o=new RegExp(`^.*?${n}`,"g"),r=ce.posix.parse(e.split(ce.win32.sep).join(ce.posix.sep).replace(o,""));return new URL("http://localhost"+ce.posix.normalize(ce.posix.join("/",r.dir,r.name.replace(/\.function$/,"")))).pathname}var ce,In=b(()=>{"use strict";ce=require("path")});var ui,Ll,Wl,me,gt=b(()=>{"use strict";ui=require("fs"),Ll="//# sourceMappingURL=data:application/json;base64,ewogICJtYXBwaW5ncyI6ICJBQUFBQSIsCiAgInNvdXJjZXMiOiBbIiJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiIl0sCiAgIm5hbWVzIjogWyIiXSwKICAidmVyc2lvbiI6IDMsCiAgImZpbGUiOiAiIgp9",Wl=[".js",".mjs",".cjs"],me=()=>({name:"excludeVendorFromSourceMap",setup(e){e.onLoad({filter:/node_modules/},t=>{if(Wl.some(n=>t.path.endsWith(n)))return{contents:`${(0,ui.readFileSync)(t.path,"utf8")}
${Ll}`,loader:"default"}})}})});function j(e,t){return require.resolve(e,{paths:[t]})}var De=b(()=>{"use strict"});var _n=b(()=>{"use strict"});function Qo(e){let t=[e,Vl];return new Error(t.filter(Boolean).join(`
`),{cause:259})}function er(e){return e?e.replace(/\(|\)/g,"").split(" ").filter(Boolean).map((t,n)=>n===0&&t.toLocaleLowerCase()==="error:"?"":t).map(t=>t.includes("http")||t.includes("://")?"":t).map(t=>t.includes(Zo.sep)?`${t.replace(/["']/g,"").split(Zo.sep).pop()}`:t).join(" ").substring(0,200).trim():""}function B(e){return e instanceof Error?e:new Error(String(e))}function Bn(e,t){throw new Error(`ERROR [${(0,fi.green)(t)}]: ${e.message}`)}var Zo,fi,C,Vl,P=b(()=>{"use strict";Zo=require("path");_n();fi=require("chalk"),C=(p=>(p[p.POSIX_SIGNAL_BASE=128]="POSIX_SIGNAL_BASE",p[p.UNCAUGHT=256]="UNCAUGHT",p[p.INTERNAL=257]="INTERNAL",p[p.USER=258]="USER",p[p.AUTH=259]="AUTH",p[p.TIMEOUT=260]="TIMEOUT",p[p.COMPILATION=261]="COMPILATION",p[p.NETWORKING=263]="NETWORKING",p[p.VALIDATION=264]="VALIDATION",p[p.BUILD=265]="BUILD",p[p.APP_GATEWAY_COMMUNICATION=266]="APP_GATEWAY_COMMUNICATION",p))(C||{}),Vl=`Authentication failed!
Please make sure that:
* The provided client ID and the secret are correct.
* The provided client ID has needed scopes.
Deploy scopes:
* app-engine:apps:run
* app-engine:apps:install
* app-engine:apps:delete
Uninstall scopes:
* app-engine:apps:delete
Telemetry scopes:
* app-engine:apps:run
Development server needs all the scopes specified in the app.config.
For more details on how you can configure authentication, see https://dt-url.net/qw024j8
`});function je(e){return tr||(tr=require(j("typescript",e))),tr}var tr,Mn=b(()=>{"use strict";De()});function Ae(e,t){return{category:t,text:e.text,filePath:e.location?.file?(0,mi.resolve)(e.location.file):void 0,line:e.location?.line??1,column:(e.location?.column??0)+1}}function nr(e,t){let n=je(t),o=`TS${e.code}`,r=n.flattenDiagnosticMessageText(e.messageText,`
`),i=e.category===n.DiagnosticCategory.Error?"Error":"Warning";if(e.file){let{line:s,character:a}=n.getLineAndCharacterOfPosition(e.file,e.start);return{code:o,category:i,text:r,filePath:e.file.fileName,column:a+1,line:s+1}}return{code:o,category:i,text:r,filePath:void 0,line:1,column:1}}var mi,le=b(()=>{"use strict";mi=require("path");Mn()});function L(){if(__filename.endsWith("bin.js"))return(0,Un.resolve)(__dirname);if(__filename.endsWith("index.js"))return(0,Un.resolve)(__dirname,"src");if(__filename.endsWith(".ts"))return(0,Un.resolve)(__dirname,"..");throw new Error("Could not retrieve lib source folder!",{cause:257})}var Un,Le=b(()=>{"use strict";Un=require("path");P()});function x(e,t){let o=(Array.isArray(e)?e:e.split(/[\/\\]/g)).map(r=>r?r.replace(/\\/g,"/"):"").join("/").replace(/\/\.\//g,"/").replace(/(?<!:)\/{2,}/g,"/").replace(/^.\//,"");return t?.keepFullPath?o:o.replace(/^([a-zA-Z]):/,"")}var W=b(()=>{"use strict"});function yi(e){if(e){console.log(`════════
`);return}console.log(ee.default.hex(Fe.blue).bold("══")+ee.default.hex(Fe.limeGreen).bold("══")+ee.default.hex(Fe.green).bold("══")+ee.default.hex(Fe.purple).bold("══")+`
`)}function ge(e,t="white",n){if(n){process.stdout.write(e);return}process.stdout.write(te(e,t))}function bi(e,t="white",n){if(n){console.log(e);return}console.log(te(e,t))}function te(e,t="white"){return{white:ee.default.white,blue:ee.default.hex(Fe.blue),green:ee.default.hex(Fe.green),purple:ee.default.hex(Fe.purple),limeGreen:ee.default.hex(Fe.limeGreen),gray:ee.default.dim}[t](e)}function or(e){let n=process.stdout.columns<=100?process.stdout.columns:100;if(e){console.log("─".repeat(n)+`
`);return}console.log(ee.default.hex(Fe.blue)("─".repeat(n))+`
`)}function he(){console.log(`
`)}function Gt(e,t=""){let n=(o,r="")=>{let c="";return o.items?.forEach((l,d)=>{let p=d===o.items.length-1,m=p?"└─ ":"├─ ",f=p?" ":"│ ";c+=`${r}${m}${l.name}
`,l.items?.length&&(c+=n(l,r+f))}),c};console.log(n(e,t))}function Jt(e,t,n,o=!0){let r={};e.forEach(s=>{let c=s.split("/")[0];r[c]||(r[c]=[]),r[c].push(s)});let i={items:[]};return Object.keys(r).forEach(s=>{let a={name:s,items:[]};r[s].forEach(c=>{let l=c.split("/");if(l.shift(),l.length!==0)if(l.length===1){let d=l[0];a.items.push(d.endsWith("widget.tsx")?gi(d,t,n,o):hi(d,t,n))}else{let d=a;for(let m=0;m<l.length-1;m++){let f=l[m],g=d.items.find(h=>h.name===f&&Array.isArray(h.items));g||(g={name:f,items:[]},d.items.push(g)),d=g}let p=l[l.length-1];d.items.push(p.endsWith("widget.tsx")?gi(p,t,n,o):hi(p,t,n))}}),i.items.push(a)}),i}function gi(e,t,n,o){let r=[{name:`Local: ${t[e+"_local"]}`}];return o&&r.push({name:`Environment: ${t[e+"_environment"]}`}),{name:n[e],items:r}}function hi(e,t,n){return{name:`${n[e]}: ${t[e]}`}}var ee,Fe,$n=b(()=>{"use strict";ee=O(require("chalk")),Fe={green:"#73be28",purple:"#6f2da8",blue:"#1496ff",limeGreen:"#b4dc00"}});function pe(e){if(!(0,xi.existsSync)((0,G.join)(e.cwd,e.sourceRoot,"api")))return[];let t=e.includeJs?"{ts,js}":"ts";return(0,We.sync)(x([e.sourceRoot,"api",`**/*.function.${t}`]),{cwd:e.cwd,ignore:["**/*.test.ts","**/*.spec.ts"]})}function Ti(e){let t=pe({cwd:e.cwd,sourceRoot:e.sourceRoot});if(!t.length)return;ge("Available app functions served from '/api':","green"),he();let n={};t.forEach(i=>{n[i.split("/")[i.split("/").length-1]]=te(e.url+x(["/api",mt(i,"api").replace(".resumable","")]),"gray")});let o=jn(t,e.cwd),r=Jt(t,n,o);Gt(r)}async function wi(e){let t=await(0,We.default)(`${e.actionsDir}/*.widget.tsx`,{cwd:e.cwd,ignore:["**/*.{test,spec}.ts","node_modules"]}),n=await(0,We.default)(`${e.actionsDir}/*.action.ts`,{cwd:e.cwd,ignore:["**/*.{test,spec}.ts","node_modules"]});if(n.length===0&&t.length===0)return;ge("Available workflow actions:","green"),he();let o=jn([...n,...t],e.cwd),r=Hl(e,n,t),i=Jt([...n,...t],r,o);Gt(i)}function Hl(e,t,n){let o={};return t.forEach(r=>{let i=(0,G.basename)(r),s=(0,G.basename)(r,".action.ts");o[i]=te(`${e.url}/api/${s.replace(".resumable","")}`,"gray")}),n.forEach(r=>{let i=(0,G.basename)(r),s=(0,G.basename)(r,".widget.tsx"),a=`${e.url}/widgets/actions/${s}`;o[`${i}_local`]=te(a,"gray"),o[`${i}_environment`]=te(zl(e.environmentUrl,a,e.locationAppIds),"gray")}),o}function zl(e,t,n){return`${e}/ui/apps/dynatrace.automations/dev-helper?src=${t}&locationAppIds=${n}`}async function ht(e,t){return(await(0,We.default)(t,{cwd:e,ignore:["**/*.{test,spec}.ts","node_modules"]})).map(o=>(0,G.join)(e,o))}async function Ei(e){let t=await(0,We.default)(`${e.widgetSettingsDir}/*.widget.tsx`,{cwd:e.cwd,ignore:["**/*.{test,spec}.ts","node_modules"]});if(t.length===0)return;ge("Available settings widgets:","green"),he();let n={};t.forEach(i=>{let s=(0,G.basename)(i),a=(0,G.basename)(s,".widget.tsx"),c=`${e.url}/widgets/settings/${a}`;n[`${s}_local`]=te(c,"gray")});let o=jn(t,e.cwd),r=Jt(t,n,o,!1);Gt(r)}async function Pi(e){let t=await(0,We.default)(`${e.documentsDir}/*.*`,{cwd:e.cwd,onlyFiles:!0});if(!t.length)return;ge("Available documents:","green"),he();let n={};t.forEach(i=>{let s=(0,G.basename)(i),a=`${e.appId}.${(0,G.basename)(i).split(".")[0]}`;n[s]=te(a,"gray")});let o=jn(t,e.cwd),r=Jt(t,n,o);Gt(r)}function jn(e,t){let n={};return e.forEach(o=>{let r=(0,G.basename)(o);n[r]=Gl((0,G.join)(t,o),r)}),n}function Gl(e,t){return process.platform==="win32"&&(e="/"+e.replace(/\\/g,"/").replace(/^\/+/,"")),`\x1B]8;;file://${e.replace(/\\/g,"/")}\x1B\\${t}\x1B]8;;\x1B\\`}var xi,We,G,Nn,Si,ke=b(()=>{"use strict";xi=require("fs"),We=O(require("fast-glob")),G=require("path");W();In();$n();Nn="documents",Si="document-types"});function Wn(e){return e.map(Jl).filter(t=>!t.filePath?.includes("node_modules/"))}async function Ci(e,t){let o=pe({cwd:e.root,sourceRoot:e.build.sourceRoot}).length>0,r=(0,Ln.existsSync)((0,rr.join)(e.root,t));if(o&&!r)throw new Error(`Failed to build functions
A tsconfig.json must exist, if function source files are present in the api directory.
Please create a tsconfig.json file in the api directory, or delete the directory.
${(0,Ln.readFileSync)((0,rr.join)(L(),"function/template/tsconfig.json"),"utf-8")}:
`,{cause:265});if(!o&&r)throw new Error(`Failed to build functions
A tsconfig.json exists, but no functions were found in the api directory.
Please create a function in the api directory, or delete the directory.
You can create functions with the generate command:
$ npm run generate:function
`,{cause:265})}function ye(){return{sourcemap:!0,color:!0,loader:{".node":"empty"},bundle:!0,logLevel:"silent",charset:"utf8",write:!1}}var rr,Ln,He,Jl,yt=b(()=>{"use strict";rr=require("path"),Ln=require("fs");le();P();Le();ke();He=e=>Ae(e,"Error"),Jl=e=>Ae(e,"Warning")});async function Ri(e,t,n){let o=require(j("esbuild",t.cwd));if(!o.context)throw new Error(`esbuild context function not found. This is likely happening because you may have dependencies in your project that are installing an older version of esbuild. Please fix your dependencies and try again. ${o.version?`Your current esbuild version being used is ${o.version}.`:""}`,{cause:258});let{context:r}=o,i=t.sourcemapOptions?.sourcemap??!1;i&&!t.sourcemapOptions?.includeVendorSourceMaps&&(t.plugins=[...t.plugins??[],me()]);let s=await r({...ye(),entryPoints:t.entryPoints.map(c=>(0,bt.isAbsolute)(c)?c:(0,bt.join)(t.cwd,c)),outbase:t.outbase,target:t.target,minify:t.minify??!1,sourcemap:i,platform:t.platform||"browser",plugins:t.plugins||[],external:t.external||[],sourceRoot:t.sourceRoot,tsconfig:(0,bt.isAbsolute)(t.tsconfig)?t.tsconfig:(0,bt.join)(t.cwd,t.tsconfig),outdir:e,format:t.format,globalName:t.globalName,metafile:t.metafile,write:!1,define:t.define});n?.addEventListener("abort",()=>s.cancel());let a=s.rebuild();try{return await a}finally{s.dispose()}}var bt,Oi=b(()=>{"use strict";bt=require("path");gt();De();P();yt()});async function Vn(e,t){let n=Date.now();try{let o=(0,qt.join)(e.cwd,"dist"),r=await Ri(o,e,t),i=Date.now(),s=r.warnings.map(l=>Ae(l,"Warning")).filter(l=>!l.filePath?.includes("node_modules/")),a=e.outDir??"dist";return{fileMap:r.outputFiles.reduce((l,d)=>{let p=`${qt.sep}${(0,qt.join)(a,d.path.replace(o,""))}`;return{...l,[p]:{content:Buffer.from(d.contents)}}},{}),diagnostics:s,duration:i-n}}catch(o){let r=Date.now();if(ql(o)){let s=[...o.errors.map(a=>Ae(a,"Error")),...o.warnings.map(a=>Ae(a,"Warning")).filter(a=>!a.filePath?.includes("node_modules/"))];return{fileMap:{},diagnostics:s,duration:r-n}}throw o instanceof Error?o:new Error(String(o),{cause:261})}}function ql(e){return typeof e=="object"&&typeof e?.errors<"u"}var qt,ir=b(()=>{"use strict";qt=require("path");Oi();le();P()});var vt,Hn=b(()=>{"use strict";vt=()=>({name:"skip-css",setup(e){e.onResolve({filter:/\.css$/},({path:t})=>({path:t,external:!0,namespace:"skip-css"}))}})});var be=b(()=>{"use strict"});function sr(e){let{ScriptTarget:t}=je(e);return{ui:{target:t.ES2022,...zn},functions:{target:t.ESNext,...zn},actions:{target:t.ESNext,...zn},widgets:{target:t.ESNext,...zn}}}var zn,Di=b(()=>{"use strict";Mn();be();zn={noEmit:!0,skipLibCheck:!0}});function ne(e){let{createCompilerHost:t,createProgram:n}=je(e.srcRoot),{tsConfigContents:o,tsConfigFileDiagnostics:r}=Kl(e.srcRoot,e.tsConfigFullPath);if(o.projectReferences&&o.projectReferences.length>0&&o.fileNames.length===0)return Yl(e);let s={...o.options,...sr(e.srcRoot)[e.buildType],incremental:!1},a=t(o.options),c=[],l=(0,ar.not)(e.entrypoints,o.raw.exclude).map(f=>(0,Ge.isAbsolute)(f)?f:(0,Ge.join)(e.srcRoot,f));if(o.options.composite)c=[...new Set([...l,...o.fileNames])];else{let f=o.fileNames.filter(h=>h.endsWith(".d.ts")),g=(0,ar.not)(f,o.raw.exclude).map(h=>(0,Ge.isAbsolute)(h)?h:(0,Ge.join)(e.srcRoot,h));c=[...new Set([...l,...g])]}let d=n({rootNames:c,options:s,host:a,configFileParsingDiagnostics:r,projectReferences:o.projectReferences}),p=d.emit();return[...d.getSyntacticDiagnostics(),...d.getSemanticDiagnostics(),...d.getConfigFileParsingDiagnostics(),...d.getGlobalDiagnostics(),...d.getDeclarationDiagnostics(),...p.diagnostics].map(f=>nr(f,e.appRoot))}function Kl(e,t){let{sys:n,readConfigFile:o,parseJsonConfigFileContent:r}=je(e),i=o(t,c=>(0,Ai.readFileSync)(c).toString()),s=[];i.error&&(0,Gn.has)(i.error.file,"parseDiagnostics")&&(s=(0,Gn.get)(i.error?.file,"parseDiagnostics"));let a=r(i.config,n,(0,Ge.dirname)(t));return s.push(...a.errors),{tsConfigContents:a,tsConfigFileDiagnostics:s}}function Yl(e){let{sys:t,createSolutionBuilderHost:n,createSolutionBuilder:o}=je(e.srcRoot),r=[],{noEmit:i,...s}=sr(e.appRoot)[e.buildType],a=n(t,void 0,d=>{d.code!==6357&&r.push(d)},d=>{d.code!==6357&&r.push(d)}),c=a.writeFile;return a.writeFile=(d,p,m)=>{(d.endsWith(".d.ts")||d.endsWith(".d.ts.map")||d.endsWith(".tsbuildinfo"))&&c?.(d,p,m)},o(a,[e.tsConfigFullPath],{dry:!1,force:!1,verbose:!1,...s}).build(),r.map(d=>nr(d,e.appRoot))}var Gn,ar,Ai,Ge,Jn,et=b(()=>{"use strict";Gn=require("lodash"),ar=require("micromatch"),Ai=require("fs"),Ge=require("path");le();Mn();Di();be();Jn=e=>({actions:`${e}/*.action.ts`,widgets:`${e}/*.widget.tsx`})});async function Ii(e){return Kn=new lr,Kn.setup(e)}var K,ki,qn,Xl,Fi,Zl,Ql,cr,lr,Kn,_i=b(()=>{"use strict";K=require("fs"),ki=require("fs/promises"),qn=require("path"),Xl=new RegExp(/[0-9]{4}-[0-9]{2}-[0-9]{2}_log.txt/),Fi=e=>(e>9?"":"0")+e,Zl=e=>`${e.getFullYear()}-${Fi(e.getMonth()+1)}-${Fi(e.getDate())}_log.txt`,Ql=e=>{try{let t=e.split("-");return new Date(Number(t[0]),Number(t[1]),Number(t[2].split("_")[0]))}catch{return}},cr=class{async setup(t){return Promise.resolve()}write(t){}getLogFile(){return""}},lr=class{logFolder;logFile;stream;async setup(t){this.logFolder=(0,qn.join)(t,".dt-app/logs"),(0,K.existsSync)(this.logFolder)||(0,K.mkdirSync)(this.logFolder,{recursive:!0}),await this.rotate()}async rotate(){if(this.logFile=(0,qn.join)(this.logFolder,Zl(new Date)),!(0,K.existsSync)(this.logFile)){let t=(0,K.readdirSync)(this.logFolder).map(n=>n.trim()).filter(n=>Xl.test(n));if(t.length>=10){let n=t.map(o=>({path:o,date:Ql(o)})).filter(o=>o.date).sort((o,r)=>o.date.getTime()-r.date.getTime())[0].path;(0,ki.unlink)((0,qn.join)(this.logFolder,n))}(0,K.closeSync)((0,K.openSync)(this.logFile,"w"))}await new Promise(t=>{this.stream=(0,K.createWriteStream)(this.logFile,{encoding:"utf-8",flags:"a"}),this.stream.on("open",()=>t())})}write(t){this.stream&&this.stream.write(t)}getLogFile(){return this.logFile}};Kn=new cr});function ep(e){return new Promise((t,n)=>{pr.push(async()=>{try{let o=await e();t(o)}catch(o){n(o)}}),tp()})}async function tp(){if(!xt){for(xt=!0;pr.length>0;)await pr.shift()();xt=!1}}async function Yn(e){return ep(e)}var pr,xt,Xn=b(()=>{"use strict";pr=[],xt=!1});function op(){Xt.text=np()}function rp(){Yt&&ve!=="running"&&!xt&&(I.length>=2?(Je===void 0&&(Je=setInterval(op,Kt.interval)),Xt.start(),ve="running"):I.length===1&&(I[0].startOraSpinner(),ve="running"))}function Bi(){ve==="running"&&(ve="paused",I.length>=2?Xt.stop():I.length===1&&I[0].stopOraSpinner())}function Mi(){ve==="paused"&&!xt&&(ve="running",I.length>=2?Xt.start():I.length===1&&I[0].startOraSpinner())}function ur(){ve="idle",I.length>=2?Xt.stop():I.length===1&&I[0].stopOraSpinner(),I.forEach(e=>e.abort()),Je!==void 0&&(clearInterval(Je),Je=void 0)}var dr,Yt,Kt,I,ve,Xt,np,Je,Zn,xe,Ui=b(()=>{"use strict";dr=O(require("ora"));Xn();Yt=process.env.DT_APP_DEACTIVATE_SPINNER!=="true",Kt={interval:80},I=[],ve="idle",Xt=(0,dr.default)({spinner:{frames:[""],interval:Kt.interval},isSilent:!Yt}),np=()=>`
${I.map(e=>e.getFrame()).join(`
`)}`;Zn=class{spinner;constructor(t){this.spinner=(0,dr.default)({...t,isSilent:!Yt})}get text(){return this.spinner.text}set text(t){this.spinner.text=t}cleanup(){let t=I.indexOf(this);t>-1&&(this.spinner.isSpinning&&this.spinner.stop(),I.splice(t,1)),I.length===0&&ur()}startOraSpinner(){this.spinner.isSpinning||this.spinner.start()}stopOraSpinner(){this.spinner.isSpinning&&this.spinner.stop()}getFrame(){return this.spinner.frame()}start(t){t&&(this.text=t);let n=I.length===1;return I.includes(this)||I.push(this),n&&I.length===2&&ve==="running"&&(I[0].stopOraSpinner(),Je!==void 0&&(clearInterval(Je),Je=void 0),ve="idle"),rp(),this}_stop(t,n="abort"){switch(this.text=t??this.text,Bi(),n){case"success":this.spinner.succeed(this.text);break;case"info":this.spinner.info(this.text);break;case"fail":this.spinner.fail(this.text);break;case"warn":this.spinner.warn(this.text);break;case"abort":this.spinner.stop();break;default:this.spinner.stopAndPersist(n)}return this.cleanup(),Mi(),this}stop(t,n={}){return this._stop(t,n)}abort(){return this._stop(void 0,"abort")}info(t){return this._stop(t,"info")}succeed(t){return this._stop(t,"success")}fail(t){return this._stop(t,"fail")}warn(t){return this._stop(t,"warn")}},xe={create:(e={})=>new Zn({...e,interval:Kt.interval}),start:(e,t={})=>new Zn({...t,interval:Kt.interval}).start(e),pause:Bi,resume:Mi,reset:ur,successAll:e=>I.forEach(t=>t.succeed(e)),failAll:e=>I.forEach(t=>t.fail(e)),disable:()=>{Yt=!1,ur()},enable:()=>{Yt=!0},getInterval:()=>Kt.interval,_getMockedSpinner:function(e){let t={abort:(...n)=>t,fail:(...n)=>t,info:(...n)=>t,start:(...n)=>t,stop:(...n)=>t,succeed:(...n)=>t,text:e??"",warn:(...n)=>t};return t}}});function ip(e){let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return e.replace(new RegExp(t,"g"),"")}function sp(){let e=new Date,t=e.getTimezoneOffset()*6e4;return e.setTime(e.getTime()-t),e}var J,St,$i,Ni,fr,u,T=b(()=>{"use strict";J=require("chalk"),St=require("lodash");_i();$i=require("os");Ui();Xn();Ni=`Using 0.0.0.0 as host will expose the dev server to your internal network!
Use 0.0.0.0 as host only when you want to access the dev server from another machine.
Remove "host: '0.0.0.0'" if this behavior is not explicitly wanted.`,fr=class{boxSize=80;warningBoxSize=90;disabled=!1;spinner={create:()=>xe.create(),disable:xe.disable,start:t=>xe.start(t),pause:xe.pause,resume:xe.resume,abort:xe.reset};disable(){this.disabled=!0,xe.disable()}log(t){this._log(`${this._padString(t,1)}`,"INFO")}debug(t,n){global.VERBOSE_MODE&&n.startsWith(global.VERBOSE_MODE.replace("%",""))&&(this.spinner.pause(),console.log(`${(0,J.yellow)("DEBUG")}${this._padString(`[${n}] ${t}`,1)}`),this.debounceTimeout=setTimeout(()=>{this.spinner.resume()},xe.getInterval())),this._printToFile(`[${n}] ${t}`,"DEBUG")}info(t,n){this._log(n===void 0||n?this._padString(t,0):t,"INFO")}success(t){this._log((0,J.green)(this._padString(t,0)),"INFO")}error(t){this._log((0,J.red)(this._padString(t,0)),"ERROR")}warn(t){let n=`
${(0,J.yellow)("Warning "+(0,St.repeat)("─",this.warningBoxSize-8))}
${(0,J.yellow)(this._padString(t))}
${(0,J.yellow)((0,St.repeat)("─",this.warningBoxSize))}
`;this._log(n,"WARNING")}logBox(t){if(this.disabled)return;let n=`
${(0,J.magenta)((0,St.repeat)("─",this.boxSize))}
${(0,J.magenta)(this._padString(t))}
${(0,J.magenta)((0,St.repeat)("─",this.boxSize))}
`;this._log(n,"INFO")}clean(){this.spinner.abort()}async initLogFile(t){this.disabled||await Ii(t)}debounceTimeout;_log(t,n){this.disabled||(this.debounceTimeout&&clearTimeout(this.debounceTimeout),this.spinner.pause(),n==="ERROR"?console.log(t):Yn(()=>Promise.resolve(console.log(t))),this.debounceTimeout=setTimeout(()=>{this.spinner.resume()},xe.getInterval()),this._printToFile(t,n))}_printToFile(t,n){Kn.write(`${sp().toISOString()} ${n} ${ip(t)}
`)}_padString(t,n=2){return`${t}`.split(/[\n\r]/).map(o=>`${(0,St.repeat)(" ",n)}${o}`).join($i.EOL)}};u=new fr});function mr(e,t){let o={cwd:t||process.cwd(),maxBuffer:10485760};return new Promise((r,i)=>{(0,ji.exec)(e,o,(s,a,c)=>{s!==null?i(s):typeof c!="string"?i(c):r(a)})})}var ji,ap,gr=b(()=>{"use strict";ji=require("child_process"),ap=require("commander")});function Li(e){if(!Qn)return;let t=process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN;return`${Qn}-${e}.${t}`}var Qn,Wi=b(()=>{"use strict";Qn=process.env.CODESPACE_NAME&&process.env.CODESPACE_NAME.trim()!==""?process.env.CODESPACE_NAME:void 0});function Vi(e){if(!Zt)return;let t=new URL(Zt).hostname;return`${e}-${t}`}var Zt,Hi=b(()=>{"use strict";Zt=process.env.GITPOD_WORKSPACE_URL&&process.env.GITPOD_WORKSPACE_URL.trim()!==""?process.env.GITPOD_WORKSPACE_URL:void 0});function Ie(e){if(Y)return hr?hr.replace(/^https?:\/\//,""):Zt?Vi(e):Li(e)}function eo(e){let t=Ie(e);return t?`wss://${t.replace(/^https?:\/\//,"")}`:""}var hr,Y,tt=b(()=>{"use strict";Wi();Hi();hr=process.env.DT_APP_DEV_ENVIRONMENT_URL&&process.env.DT_APP_DEV_ENVIRONMENT_URL.trim()!==""?process.env.DT_APP_DEV_ENVIRONMENT_URL:void 0,Y=Zt||Qn||hr});async function D(e,t){return(0,to.fetch)(e,t)}var to,X=b(()=>{"use strict";to=require("undici")});function pp(e){let t=["Error while connecting to the app registry",e];return new Error(t.filter(Boolean).join(`
`),{cause:266})}async function yr(e,t){try{let n=new URL(e),o={headers:{authorization:`Bearer ${t}`,"content-type":"application/octet-stream"}};n.pathname="/platform/metadata/v1/user";let r=await D(n.toString(),o);return!r.ok||r.headers.get("content-type")?.includes("text/html")?void 0:await r.json()}catch(n){throw pp(B(n).message)}}async function zi(e,t){let n=await D(`${e}/platform/app-engine/registry/v1/app.default.csp.json`,{headers:{authorization:`Bearer ${t}`}});return n.status>=200&&n.status<=299?(await n.json()).policyDirectives:(u.warn(`The default csp policy from the platform couldn't be applied. App-registry failed with: ${n.status} ${n.statusText}`),{})}var no=b(()=>{"use strict";X();T();P()});function nt(e){let t=new URL(e),[n,...o]=t.hostname.split(".");if(!o||o.length<1)throw new Error(`Invalid environment URL: "${e}"`,{cause:258});return{tenant:n,hostname:o.join(".")}}async function up(e,t,n,o){let r=await zi(e,n),i=oo.flatMap(f=>Y?[`https://${Ie(f)}`]:[`http://localhost:${f}`,`https://localhost:${f}`]),s=oo.flatMap(f=>Y?[eo(f)]:[`ws://localhost:${f}`,`wss://localhost:${f}`]),a={"script-src":["'unsafe-eval'",...i,...t.map(f=>`'sha256-${f}'`)],"connect-src":[...i,...s],"frame-ancestors":i},{tenant:c,hostname:l}=nt(e),d=f=>f.replaceAll("{tenantId}",c).replaceAll("{hostname}",l),p={},m=[...Object.keys(r),...Object.keys(a)];for(let f of m){let g=new Set;for(let h of r[f]??[])g.add(d(h));for(let h of a[f]??[])g.add(d(h));p[f]=Array.from(g)}return p["frame-src"]=["*"],p["frame-ancestors"]=["*"],o&&Object.entries(o).forEach(([f,g])=>{p[f]?p[f].push(...g.map(h=>h.value)):p[f]=g.map(h=>h.value)}),dp(p)}function dp(e){return Object.entries(e).map(([t,n])=>`${t} ${n.join(" ")}`).join("; ")}async function Ji(e,t,n,o){let r=`${e}-${t.join(",")}-${o}`,i=Gi.get(r);if(i)return i;let s=await up(e,t,n,o);return Gi.set(r,s),s}var oo,Gi,Tt=b(()=>{"use strict";tt();no();P();oo=[3e3,3001,3002,3003,3004,3005];Gi=new Map});function ue(e){if(!(0,wt.existsSync)(e)&&!(0,wt.lstatSync)(e,{throwIfNoEntry:!1})?.isFile())throw new Error(`[read-json.ts] File does not exist: ${e}`,{cause:257});let t=(0,wt.readFileSync)(e,"utf-8");return JSON.parse(t)}var wt,qe=b(()=>{"use strict";wt=require("fs");P()});function fp(e){let t=new Ki.default({allErrors:!0,formats:{"relative-path":{type:"string",validate:r=>!(0,Yi.isAbsolute)(r)},"valid-glob":{type:"string",validate:r=>{if(!r||r.length===0)return!1;try{return(0,Zi.parse)(r),!0}catch{return!1}}},url:{type:"string",validate:r=>{try{let i=new URL(r);return i.protocol==="http:"||i.protocol==="https:"}catch{return!1}}},regex:!0},strict:!1});(0,qi.default)(t);let n=(0,Xi.readFileSync)(e,"utf-8"),o=JSON.parse(n);return{appConfigSchema:o,validateAppConfigSchema:t.compile(o)}}async function Qi(e,t,n="default"){if(n==="none"||process.env.DT_APP_SKIP_CONFIG_VALIDATION==="true")return t;let{validateAppConfigSchema:o}=fp(e);if(o(t))return t;for(let r of o.errors)u.info(mp({error:r}));throw new Error("App config validation failed",{cause:264})}function mp({title:e="App config",error:t}){let n=ro.red`error:`,o=t.instancePath??"";t.schemaPath&&t.schemaPath.indexOf("additionalProperties")>=0&&o.indexOf("app")<0&&(o=o?.substr(0,t.instancePath.lastIndexOf("/")));let r=o?o.split("/").reduce((s,a)=>s?isNaN(+a)?`${s}.${a}`:`${s}[${a}]`:a):"CliOptions",i=t.message?t.message.replace(/"/gi,"'"):"";return`> ${(0,ro.bold)(e)}: ${n} '${r}' ${i}.`}function es(e){if(e.distDir)throw new Error('The "distDir" option is no longer supported. Please remove "distDir" from the app.config.');if(e?.server?.open)throw new Error('The "server.open" option is no longer supported. Please remove "server.open" from the app.config.')}var qi,Ki,ro,Yi,Xi,Zi,ts=b(()=>{"use strict";qi=O(require("ajv-errors")),Ki=O(require("ajv/dist/2019")),ro=require("chalk"),Yi=require("path"),Xi=require("fs"),Zi=require("micromatch");T();P()});function ns(e){return e.plugins.map(t=>gp(t,e.root)).filter(t=>!!t)}function gp(e,t){try{return require(j(e,t)).default}catch(n){u.warn(`Could not require plugin ${e}. It will be ignored.`),u.debug(B(n).toString(),oe)}}var oe,Qt=b(()=>{"use strict";T();De();P();oe="PLUGIN"});async function hp(e,t){for(let n of yp(e)){u.debug(`Running '${e}' hook of plugin '${n.name}'...`,oe);try{await n.callBack(...t)}catch(o){u.error(`An error occurred during the '${e}' hook of plugin '${n.name}':
${B(o).toString()}`);continue}u.debug(`Finished '${e}' hook of plugin '${n.name}'.`,oe)}}function yp(e){return br[e]}function os(e){let t={"before-build":[],"before-serve":[]},n={beforeBuild(o){t["before-build"].push({name:e.name,callBack:o})},beforeServe(o){t["before-serve"].push({name:e.name,callBack:o})}};try{e.setup(n)}catch(o){u.error(`An error occurred during the setup of plugin '${e.name}':
${B(o).toString()}`);return}Object.keys(t).forEach(o=>{bp(o)&&br[o].push(...t[o])})}function bp(e){return["before-build","before-serve"].includes(e)}function vp(e){for(let t of e)os(t)}var br,io,vr=b(()=>{"use strict";T();Qt();P();br={"before-build":[],"before-serve":[]};io={registeredHooks:br,register:os,registerAll:vp,invoke:hp}});function Et(e){return(0,so.basename)(e,(0,so.extname)(e))}function Pt(e){(0,en.existsSync)(e)||(0,en.mkdirSync)(e)}var so,en,ot=b(()=>{"use strict";so=require("path"),en=require("fs")});function rs(e,t){try{let n=xp(e,t??""),o=(0,Ct.join)(n,"lib","src","app.config.schema.json");if((0,xr.existsSync)(o))return o}catch{}return(0,Ct.join)(L(),"app.config.schema.json")}function xp(e,t){return(0,Ct.resolve)(require.resolve("dt-app",{paths:[(0,Ct.join)(e,t)]}),"../..")}var Ct,xr,is=b(()=>{"use strict";Ct=require("path"),xr=require("fs");ot();Le()});function _e(){return ss.default.resolve(L(),"utils","snippets")}var ss,ao=b(()=>{"use strict";Le();ss=O(require("path"))});function ls(e){let t={};e.https&&(t={https:{cert:(0,Sr.readFileSync)(e.https.cert),key:(0,Sr.readFileSync)(e.https.key)}});let n=(0,as.default)({...t,bodyLimit:50*1048576,forceCloseConnections:!0});return n.removeAllContentTypeParsers(),n.addContentTypeParser("*",{parseAs:"buffer"},(o,r,i)=>{i(null,r)}),n}function ps(){return new cs.WebSocketServer({noServer:!0})}function us(e){let t=e.https?"wss":"ws",n=e.host==="127.0.0.1"?"localhost":e.host;return`${t}://${n}:${e.port}`}var as,Sr,cs,co,tn=b(()=>{"use strict";as=O(require("fastify")),Sr=require("fs"),cs=require("ws"),co="/__dt_app_live_reload__"});var rt,nn=b(()=>{"use strict";rt="x-dt-app-dev-server-session-token"});function ds(){let e=(0,rn.resolve)(_e(),"defaultIndex.snippet.html");return on.default.readFileSync(e).toString("utf-8")}function Rt(e,t){let{transformSync:n}=require(j("esbuild",t)),o=(0,rn.resolve)(_e(),"sdkWebShim.snippet.ts"),r=on.default.readFileSync(o,"utf-8"),i={loader:"ts",define:{"process.env.INJECT":JSON.stringify(e)}};return n(r,i).code}function fs(e){let t=(0,rn.resolve)(_e(),"selfmon_config.snippet.js");return on.default.readFileSync(t,"utf-8").replace("{{PLATFORM_PREFIX}}",e)}async function po(e){return lo||(lo=await(await D(e)).text(),lo)}function Ot(e){let t=eo(e.server.port),n=us(e.server);return`window.socketUrl = '${t||n}${co}';`}function Dt(e){let t=(0,rn.resolve)(_e(),"devServerSessionToken.snippet.ts"),n=on.default.readFileSync(t,"utf-8"),{transformSync:o}=require("esbuild");return o(n,{loader:"ts",define:{"process.env.SESSION_TOKEN":JSON.stringify(e),"process.env.SESSION_HEADER":JSON.stringify(rt)}}).code}var on,rn,lo,At=b(()=>{"use strict";on=O(require("fs"));X();rn=require("path");De();ao();tn();tt();nn()});function gs(e){let t;Tr?t=Tr:(t=Sp.exec(e),Tr=t);try{return t[0]}catch{throw new Error(`The self monitoring agent could not be retrieved, please check if ${ms.default.cyan`options.app.selfMonitoringAgent`} is configured to the correct url.`,{cause:263})}}async function hs(e){try{if(!e.includes("http"))return 3;let t=await D(e),n=t.status,r=t.headers.get("content-type")?.includes("javascript"),s=(await t.text()).includes("cuc=");return n===404||!r||!s?2:(await po(e),0)}catch{return 1}}var ms,Sp,Tr,wr=b(()=>{"use strict";X();At();ms=O(require("chalk"));P();Sp=/(?<=(?:\||")cuc=).*?(?=\||")/g});function bs(e,t){return e.map(n=>Tp(n,t))}async function Tp(e,t){let n=e;if((0,uo.existsSync)((0,fo.join)(t.root,t.actionsDir,`${e.name}.action.ts`))||(0,uo.existsSync)((0,fo.join)(t.root,t.actionsDir,`${e.name}.resumable.action.ts`))||(0,uo.existsSync)((0,fo.join)(t.root,t.actionsDir,`${e.name}.stateful-action.ts`)))return n;if(!(await(0,ys.default)("api/**/"+e.name+"*.ts",{cwd:t.root})).length)throw new Error(e.name+" has no UI and no function implementation!",{cause:257});return n}var uo,fo,ys,vs=b(()=>{"use strict";uo=require("fs"),fo=require("path"),ys=O(require("fast-glob"));P()});function Ep(e){return(0,Z.join)(e,"/.dt-app/.tokens.json")}function an(e,t,n){if((0,sn.existsSync)((0,Z.join)(e,t,"ui","main.tsx")))return{entryPoint:(0,Z.join)(e,t,"ui","main.tsx"),assetsInput:n.assets[0].input,tsConfigFullPath:(0,Z.join)(e,t,"ui","tsconfig.json")};u.debug(`No ${(0,Z.join)(e,t,"ui","main.tsx")} found. Defaulting to legacy structure.`,"UI");let r=(0,Z.join)(e,t,"tsconfig.json"),i=(0,Z.join)(e,t,"main.tsx");if(!(0,sn.existsSync)(r)){if(!(0,sn.existsSync)(i))return u.debug(`No UI entry point found at ${i}. Returning null — UI build will be skipped.`,"UI"),null;Bn(new Error("tsconfig.json not found. Please make sure it is located next to the main.tsx file."),"DEC:E3")}let s={entryPoint:i,assetsInput:n.assets[0].input,tsConfigFullPath:r};return u.debug(`Paths that are used: ${JSON.stringify(s)}`,"LEGACY"),s}function it(e,t,n){return{appFunctionsBuildPlatform:"browser",root:n??process.cwd(),distDir:"dist",dryRun:!1,noLiveReload:!1,noSecurityHardening:!1,injectSdk:!0,build:{index:(0,Z.join)("src/index.html"),sourceRoot:t??"./",sourceMaps:void 0,ui:{assets:[{glob:"**/*",ignore:[],input:t?(0,Z.join)(t,"ui/assets"):(0,Z.join)("ui/assets"),output:"assets"}]},api:{plugins:[]},mode:e?"development":"production",namedChunks:!1,baseHref:"/ui/",dynatraceDependencies:{addOrOverride:{},ignore:[]},typeCheck:!0},server:{open:!0,port:3e3,host:"127.0.0.1",showWarnings:!1,enableCSP:!0},plugins:[]}}function mo(e){return e.endsWith("/")?e:`${e}/`}function Pp(e){try{return new URL(e).origin}catch{return e}}function Ss(e,t){return(0,kt.mergeWith)((0,kt.cloneDeep)(e),t,(n,o,r)=>{if(o===void 0)return n;if(Array.isArray(o))return o.length>0&&Cp(o[0])&&r in xs?o.map(i=>(0,kt.merge)({},xs[r],i)):[...o]})}function Cp(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ts(e,t){let n=t.root?t.root:process.cwd(),o=e.build?.sourceRoot,r=[];e.build?.settingsPath&&r.push('The configuration "build.settingsPath" has been removed in dt-app v1.0. The settings have to be inside <source_root>/settings/schemas directory. The current default location is ./settings/schemas/'),e.build?.ui?.additionalEntryPoints&&r.push('The configuration "build.ui.additionalEntryPoints" has been removed in dt-app v1.0. The additionalEntryPoints for the ui have to be inside <source_root>/ui directory. The current default location is ./ui/'),e.build?.ui?.entryPoint&&r.push('The configuration "build.ui.entryPoint" has been removed in dt-app v1.0. The main entry point for the ui has to be inside <source_root>/ui directory. The current default location is ./ui/main.tsx.'),e.build?.ui?.tsconfig&&r.push('The configuration "build.ui.tsconfig" has been removed in dt-app v1.0. The tsconfig for the ui has to be inside <source_root>/ui directory. The current default location is ./ui/tsconfig.json.'),!o&&(0,sn.existsSync)((0,Z.join)(n,"src","main.tsx"))&&r.push(`In dt-app v1.0, UI sources are expected to be located in the project's sourceRoot directory. To specify a different source root, please use the "build.sourceRoot" configuration.`),e.build?.functions&&r.push('The configuration "build.functions" has been removed in dt-app v1.0. To configure your App Functions please use "build.api" instead.'),e.build?.functions?.input&&r.push('The configuration "build.functions.input" has been removed in dt-app v1.0. To specify the location of your App Functions, please use "build.sourceRoot" instead.'),e.build?.functions?.glob&&r.push('All the app functions in v1.0 will have to have a postfix ".function.ts". will be removed in dt-app v1.0. To specify the glob for your app functions, please use "build.sourceRoot" instead. All the app functions in v1.0 will have to have a postfix ".function.ts".'),e.build?.functions?.tsconfig&&r.push('The configuration "build.functions.tsconfig" has been removed in dt-app v1.0. The App Functions tsconfig has to be inside the <source_root>/api directory'),e.build?.functions?.plugins&&r.push('The "build.functions.plugins" are deprecated and will be removed in the next major release of App Toolkit'),e.build?.actions?.plugins&&r.push('The "build.actions.plugins" are deprecated and will be removed in the next major release of App Toolkit'),e.build?.widgets?.plugins&&r.push('The "build.widgets.plugins" are deprecated and will be removed in the next major release of App Toolkit'),e.root&&r.push('The configuration "root" has been removed in dt-app v1.0. To specify the root of your project, please use the flag `--cwd` instead.'),e.oauthClientId&&r.push('The configuration "oauthClientId" has been removed in dt-app v1.0.'),e.distDir&&r.push('The configuration "distDir" has been removed in dt-app v1.0. Default value "./dist" will be used.'),e.oauth2File&&r.push('The configuration "oauth2File" has been removed in dt-app v1.0. Default value "./dt-app/.tokens.json" will be used.'),e.dev?.fileWatcher?.ignore&&r.push('The configuration "dev.fileWatcher.ignore" has been removed in dt-app v1.0. Development server will ignore redundant files by default.'),e.dev?.fileWatcher?.include&&r.push('The configuration "dev.fileWatcher.include" has been removed in dt-app v1.0. Development server will include all required files by default.'),e.server?.open&&r.push('The configuration "server.open" has been removed in dt-app v1.0. To specify if the project should be opened, please use the flag `--open` instead.'),process.env.DT_APP_SIGNING_PK&&r.push('The env variable "DT_APP_SIGNING_PK" has been removed in dt-app v1.0.'),process.env.DT_APP_SIGNING_CERT&&r.push('The env variable "DT_APP_SIGNING_CERT" has been removed in dt-app v1.0.'),process.env.DEBUG&&r.push('The env variable "DEBUG" has been removed in dt-app v1.0. Please user --verbose flag instead.'),process.env.DT_APP_SERVERLESS_MAX_CONNECTIONS&&r.push('The env variable "DT_APP_SERVERLESS_MAX_CONNECTIONS" has been removed in dt-app v1.0. Default value of 128 will be used instead.'),t?.injectSdk!==void 0&&r.push('The flag "--no-sdk-injection" has been removed in dt-app v1.0. Please use app.config instead'),t.global&&r.push('The flag "--global" has been removed in dt-app v1.0.'),e.build?.ui?.sourceMaps&&r.push('The configuration "build.ui.sourceMaps" has been removed in dt-app v1.0. Please use centralize "build.sourceMaps" configuration instead.'),e.build?.functions?.sourceMaps&&r.push('The configuration "build.functions.sourceMaps" has been removed in dt-app v1.0. Please use centralize "build.sourceMaps" configuration instead.'),t.build?.mode==="development"&&r.push('The flags "--prod" and "--no-prod" are deprecated and will be removed in dt-app v1.0. Please use "build.mode" configuration instead.'),r.length&&u.warn(r.join(`
`))}function ws(e){let t=an(e.root,e.build.sourceRoot,e.build.ui);t!==null&&(e.build.ui.assets[0].input=t.assetsInput)}async function Es(e){if(!e.app?.actions)return;let t=e.build.sourceRoot?(0,Z.join)(e.build.sourceRoot,"actions"):"actions";e.app.actions=await Promise.all(bs(e.app.actions,{root:e.root,actionsDir:t}))}async function Ps(e){if(!e.app?.selfMonitoringAgent)return;let t=e.app.selfMonitoringAgent,n=await hs(t);n===3&&(u.warn(`Failed to configure self monitoring agent. Self monitoring agent url missing ${(0,Ft.green)("https://")}. Please prepend to the url in the ${(0,Ft.blue)("app.config.ts")}.`),e.app.selfMonitoringAgent=void 0),n===1&&(u.warn(`Failed to configure self monitoring agent. Could not reach ${t}. Please make sure its accessible from the environment you're running.`),e.app.selfMonitoringAgent=void 0),n===2&&(u.warn(`Failed to configure self monitoring agent. Could not find a self monitoring script at the configured url ${t}. Please make sure you've configured the right url and that it is reachable.`),e.app.selfMonitoringAgent=void 0),e.build.mode==="production"&&n!==0&&(u.error(`Exiting production build. If you wish to build anyways, please set the ${(0,Ft.blue)("build.mode")} to ${(0,Ft.green)("'development'")} in your app config.`),process.exit(1))}function go(e,t,n=process.env,o=!1){!e.environmentUrl&&n.DT_APP_ENVIRONMENT_URL?.trim()&&(e.environmentUrl=n.DT_APP_ENVIRONMENT_URL);let r=Ss(t,e),i=Ss(it(o,r.build?.sourceRoot,r?.root),r);return i.oauth2File=Ep(i.root),i.environmentUrl&&(i.environmentUrl=Pp(i.environmentUrl)),i}var Z,sn,kt,Ft,xs,Se=b(()=>{"use strict";Z=require("path"),sn=require("fs"),kt=require("lodash"),Ft=require("chalk");cn();wr();vs();T();P();xs={assets:{ignore:[]},actions:{build:{entryPoint:"src/main.tsx",tsconfig:"tsconfig.json"}}}});function Op(){let e=null;return{async init(t,n,o=process.env,r="default",i=!1,s){if(e)throw new Error("Config module has already been initialized. Cannot initialize twice.");Ts(n,t),es(n);let a=t.root??process.cwd(),c=t.environmentUrl??o.DT_APP_ENVIRONMENT_URL?.trim()??n.environmentUrl;await Qi(rs(a),{...n,environmentUrl:c},r);let l=go(t,n,o,i);ws(l),await Es(l),await Ps(l),io.registerAll(ns({root:l.root,plugins:l.plugins})),s&&(l=await s(l)),e=Cs(l)},getConfig(){if(!e)throw new Error("Config module has not been initialized. Call init() first.");return e},isInitialized(){return e!==null},invalidate(){e=null}}}function Cs(e){return Object.getOwnPropertyNames(e).forEach(t=>{let n=e[t];n&&typeof n=="object"&&!Object.isFrozen(n)&&Cs(n)}),Object.freeze(e)}var S,_=b(()=>{"use strict";ts();vr();Qt();is();Se();S=Op()});function Ds(e){return e instanceof Error?{error:{name:e.name,message:e.message,stack:e.stack,cause:e.cause}}:e}function Er(e){return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,As(n)]))}function As(e){return e==null?e:Array.isArray(e)?e.map(t=>As(t)):typeof e=="object"?Er(e):typeof e=="string"?er(e):e}function Fs(e){return e.includes("dev")?"dev":e.includes("hardening")?"hardening":"prod"}var Rs,Os,Wm,It=b(()=>{"use strict";Rs=require("path"),Os=require("os");P();T();qe();no();Wm=(0,Rs.join)((0,Os.homedir)(),".dt-app",".session")});function Ke(e,t){if(!Fp||!ks||!Is)return;let n=Er(Ds(e.payload||{})),o=t?.environmentUrl||ho?.environmentUrl||"",r=t?.app?.id||ho.appId||"",i=t?.app?.version||ho.appVersion||"",s=process.version.charAt(0)==="v"?process.version.substring(1):process.version,a=o?{tenantId:nt(o).tenant,sessionType:Fs(o)}:{tenantId:"",sessionType:""},c={..._s&&{userId:_s},userType:ho.userType||""},l={sessionId:Is.toString(),"event.category":e["event.category"],"event.provider":"dt-app",operatingSystemVersion:(0,ln.version)(),nodejsVersion:s,appId:r,appVersion:i,cliVersion:global.DT_APP_VERSION,...a,...c,...n},d=`dt-app.${e["event.category"]}.${e.name}`;ks.sendBizEvent(d,l)}var Pr,Dp,ln,Bs,Ap,og,ks,Is,_s,Fp,ho,pn=b(()=>{"use strict";Pr=require("@dynatrace/openkit-js"),Dp=require("lodash"),ln=require("os"),Bs=require("path");T();gr();Tt();P();qe();_();Ap=require("jsonwebtoken");It();og=(0,Bs.join)((0,ln.homedir)(),".dt-app",".uuid"),Fp=!1});async function $s(){let e=["actions","functions","ui","widgets"];await Promise.all(e.map(t=>{let n=_t[t];return n?(_t[t]=void 0,n.terminate()):Promise.resolve()})),u.debug("All TypeScript workers terminated","TYPESCRIPT")}function Te(e,t){if(_t[e.buildType])return;let n=o=>{switch(o.type){case"initialized":u.debug(`
${o.payload} typescript worker thread has been initialized!`,"TYPESCRIPT");break;case"type-error":u.info(o.payload),t?.onTypeError?.(o.payload);break;case"type-check-complete":t?.onTypeCheckComplete?.(o.payload.errorCount);break;case"send-biz-event":Ke({"event.category":"error",name:"ts-worker-error",payload:o.payload});break;case"entrypoints-changed":u.debug(`New amount of entrypoints for ${o.payload.buildType}: ${o.payload.entrypoints.length}`,`ENTRYPOINTS_WATCHER-${o.payload.event}`)}};_t[e.buildType]=new Us.Worker((0,Ms.join)(L(),"ts-worker.js"),{workerData:e}),_t[e.buildType].once("error",o=>{u.error(`TypeScript worker thread error: ${o}`),process.exit(1)}),_t[e.buildType].on("message",o=>{n(o)})}var Ms,Us,_t,st=b(()=>{"use strict";Ms=require("path"),Us=require("worker_threads");be();Le();T();pn();It();_t={actions:void 0,functions:void 0,ui:void 0,widgets:void 0}});async function js(e,t,n){let o=(0,U.join)(e.build.sourceRoot,"api","tsconfig.json"),r=n||pe({cwd:e.root,sourceRoot:e.build.sourceRoot}).map(m=>x([e.root,m]));if(r.length===0)return{fileMap:{},diagnostics:[],duration:0};let i=(0,U.join)(e.distDir,"/api"),s=z({sourcemaps:e.build.sourceMaps,dev:t});t&&s.sourcemap&&(s.sourcemap="inline");let a=[];e.build.typeCheck&&(t?Te({buildType:"functions",appRoot:e.root,tsconfigFullPath:(0,U.join)(e.root,o),entrypoints:r,glob:x([e.build.sourceRoot,"api"])}):a=ne({appRoot:e.root,srcRoot:(0,U.join)(e.root,e.build.sourceRoot,"api"),entrypoints:r,tsConfigFullPath:(0,U.join)(e.root,o),buildType:"functions"}));let c=await Vn({cwd:e.root,entryPoints:r,outbase:(0,U.join)(e.root,e.build.sourceRoot,"api"),tsconfig:o,plugins:[vt(),...e.build.api?.plugins?.filter(m=>"setup"in m)||[]],platform:e.appFunctionsBuildPlatform==="node"?"node":"browser",external:e.appFunctionsBuildPlatform==="node"?[]:un,target:"esnext",format:"esm",outDir:i,metafile:!0,sourcemapOptions:s,sourceRoot:Rr((0,U.join)(e.build.sourceRoot,"api"))?(0,U.resolve)(e.root,(0,U.dirname)((0,U.join)(e.build.sourceRoot,"api")).split(U.sep)[0]):void 0,minify:!t,production:!t,define:{"process.env.NODE_ENV":e.build.mode==="production"?'"production"':'"development"'}}),l=c.fileMap,d=[...c.diagnostics,...a],p=c.duration;return t?{fileMap:Object.entries(c.fileMap).map(f=>{try{let g="sourceMappingURL=data:application/json;base64,",h=f[1].content.toString("utf-8"),E=h.lastIndexOf(g);E>=0&&(f[1].sourceMap=Buffer.from(h.substring(E+g.length),"base64"))}catch{}return f}).reduce((f,[g,h])=>{if(!g.endsWith(".js.map")){let E=mt(g,i);f[E]={...h,filename:(0,U.parse)(g).base,isOfType:"function"}}return f},{}),diagnostics:d,duration:p}:{fileMap:l,diagnostics:d,duration:p}}function Rr(e){return(0,U.join)(e).split(U.sep).filter(n=>n).length>1}var U,Ns,un,cn=b(()=>{"use strict";U=require("path");Ne();In();ir();ke();Hn();et();be();W();st();Ns=O(require("@dynatrace/js-runtime/capabilities/capabilities.json")),un=Ns.default.supportedModules});function Wa(e){return e.filter(t=>t.category==="Error"||!t.filePath||!t.filePath.includes("node_modules"))}var Va=b(()=>{"use strict";le()});function Ce(e,t){return t?Wa(e):e.filter(n=>n.category==="Error")}var jt=b(()=>{"use strict";le();Va()});function Re(e){return e.startsWith("../")?e:e.startsWith("./")?e.slice(1):e.startsWith("/")?e:"/"+e}var qa=b(()=>{"use strict"});function dt(e){let t={},n={fileExists:o,throwIfFileDoesNotExist:r,getFile:i,getFilePathsByRegex:s,getFileMap:a,getFileName:c,setFile:l,setFiles:d,mapEsbuildOutputFiles:p,mapViteOutputFiles:m,deleteFile:f,writeFileToDisc:g,writeFileMapToDisc:h,addAssetFiles:E,resetFileMap:w};return e&&d(e),n;function o(y){let v=Re(y);return!!t[v]}function r(y){let v=Re(y);if(!o(y))throw Ke({"event.category":"crash",name:"fileManager.setFile",payload:{error:`Failed to set file ${y} with fileManager.`}}),new Error(`File ${v} does not exist in fileMap!`)}function i(y){return y=Re(x(y)),r(y),t[y]}function s(y){return Object.keys(t).filter(v=>v.match(y))}function a(){return t}function c(y){return y=Re(x(y)),r(y),(0,de.basename)(y)}function l(y,v){y=Re(x(y)),t[y]={content:v}}function d(y){for(let v in y)l(v,y[v].content)}function p(y,v,k="dist"){let H=x([v,"dist"]);return(y||[]).forEach($=>{let ae=x($.path),$e=x([k,ae.replace(H,"")]),zt=Re($e);t[zt]={content:Buffer.from($.contents)}}),n}function m(y,v){if("close"in y)return n;let k=Array.isArray(y)?y:[y];for(let H of k)for(let $ of H.output){let ae=x([v,$.fileName]),$e=$.type==="chunk"?Buffer.from($.code):Buffer.from($.source instanceof Uint8Array?$.source:String($.source)),zt=Re(ae);t[zt]={content:$e}}return n}function f(y){y=Re(x(y)),delete t[y]}async function g(y){y=Re(x(y)),r(y),await(0,xn.writeFile)((0,de.join)(y),t[y].content)}async function h(y){await Promise.all(Object.entries(t).map(async([v,{content:k,mode:H}])=>{let $=(Buffer.byteLength(k,"utf8")/Math.pow(2,10)).toFixed(2),ae=(0,de.join)(y,v);return u.debug(`${H!==void 0?Ka[H]:Ka.created} ${ae} ${`(${$} KB)`}`,"FILES"),await(0,xn.mkdir)((0,de.dirname)(ae),{recursive:!0}),(0,xn.writeFile)(ae,k)}))}async function E(y){for(let v of y.assetConfigs){let k=(0,de.isAbsolute)(v.input)?v.input:(0,de.join)(y.root,v.input),H=await(0,Ya.default)(v.glob,{cwd:k,dot:!0,ignore:v.ignore});for(let $ of H){let ae=x([y.distDir,v.output,$]);l(ae,(0,Xa.readFileSync)((0,de.join)(k,$)))}}}function w(){t={}}}var Nr,de,xn,Ya,Xa,Ka,A,Oe=b(()=>{"use strict";Nr=O(require("chalk")),de=require("path"),xn=require("fs/promises");W();T();qa();pn();It();Ya=O(require("fast-glob")),Xa=require("fs"),Ka={created:Nr.default.green`CREATED:`,updated:"UPDATED:",deleted:Nr.default.red`DELETED:`,copied:"COPIED:"};A=dt()});function _o(e){return typeof e=="object"&&e!==null&&"setup"in e&&typeof e.setup=="function"}function Bo(e){let t=(e||[]).flat(),n=t.filter(_o),o=t.filter(r=>!_o(r));if(o.length>0){let r=o.map(i=>i.name).join(", ");u.warn(`The following Vite plugin(s) will be excluded from the esbuild build: ${r}. Esbuild builds do not support Vite plugins — please use equivalent esbuild plugin(s) instead.`)}return n}function vc(e){let t=(e||[]).flat(),n=t.filter(r=>!_o(r)),o=t.filter(_o);if(o.length>0){let r=o.map(i=>i.name).join(", ");u.warn(`The following esbuild plugin(s) will be excluded from the Vite build: ${r}. Vite builds do not support esbuild plugins — please use equivalent Vite plugin(s) instead.`)}return n}function Mo(e){return e.flat().some(t=>typeof t=="object"&&t!==null&&typeof t.name=="string"&&t.name.includes("vanilla-extract"))}var Pn=b(()=>{"use strict";T()});function Me(e){let t=f(e)??ds(),n=new xc.JSDOM(t),{document:o}=n.window,r={setAppName:s,setBaseURL:a,setRootID:c,injectScript:l,injectScriptWithContent:d,injectStylesheet:p,addInjectionMarker:i,build:m};return r;function i(){let g=o.createElement("injection-marker");return o.head.append(g),r}function s(g){return o.title=`Dynatrace - ${g}`,r}function a(g){let h=o.getElementsByTagName("base")[0];return h||(h=o.createElement("base"),o.head.append(h)),h.href=g,r}function c(g){let h=o.querySelectorAll('body > [id*="root"]')[0];return h||(h=o.createElement("div"),o.body.append(h)),h.id=g,r}function l(g,h){let E={location:"head",defer:!1},{location:w,defer:y}={...E,...h},v=o.createElement("script");return v.src=g,v.defer=y,h?.type&&(v.type=h.type),w==="head"&&o.head.append(v),w==="body"&&o.body.append(v),r}function d(g,h="head"){let E=o.createElement("script");return E.type="text/javascript",E.textContent=g,h==="head"&&o.head.append(E),h==="body"&&o.body.appendChild(E),r}function p(g){let h=o.c