var e=require("dts-bundle-generator"),t=require("node:buffer"),r=require("node:events"),o=require("node:fs"),s=require("node:path"),i=require("node:worker_threads");function n(e,t,r,o){Object.defineProperty(e,t,{get:r,set:o,enumerable:!0,configurable:!0})}function a(e){return e&&e.__esModule?e.default:e}var l=globalThis,u={},p={},c=l.parcelRequire3913;null==c&&((c=function(e){if(e in u)return u[e].exports;if(e in p){var t=p[e];delete p[e];var r={id:e,exports:{}};return u[e]=r,t.call(r.exports,r,r.exports),r.exports}var o=Error("Cannot find module '"+e+"'");throw o.code="MODULE_NOT_FOUND",o}).register=function(e,t){p[e]=t},l.parcelRequire3913=c),(0,c.register)("eXtsc",function(t,r){n(t.exports,"compile",()=>a);let o=/^export\s+{\s*};?\s*$/gmi,s=/^export\s+\*.*?\bfrom\s+"[\.~\/].*$/gmi,i=/^\s*?[\r\n]+/gmi;function a(t,{compilationOptions:r,removeEmptyExports:n,removeEmptyLines:a,removeRelativeReExport:l}){return new Promise((u,p)=>{try{let p=(0,e.generateDtsBundle)(t,r).flatMap(e=>e.split("\n").map(e=>e.trimEnd())),c=p.filter(e=>!(a&&i.test(e))&&!(n&&o.test(e))&&!(l&&s.test(e))).join("\n");u(Buffer.from(c))}catch(e){p(e)}})}}),Object.defineProperty(module.exports,"__esModule",{value:!0,configurable:!0}),n(module.exports,"PLUGIN_NAME",()=>h),n(module.exports,"BundleDeclarationsWebpackPlugin",()=>y),n(module.exports,"default",()=>y),n(module.exports,"compile",()=>c("eXtsc").compile);var d=c("eXtsc"),m={};n(m,"DefaultOptions",()=>f),n(m,"DefaultEntryOptions",()=>g);const f={outFile:"index.d.ts",removeEmptyLines:!0,removeEmptyExports:!0},g={output:{sortNodes:!0,noBanner:!0}},h="BundleDeclarationsWebpackPlugin";class y extends a(r){constructor(e){super({captureRejections:!0}),this._options=e?{...f,...e}:f}apply(e){let{webpack:{sources:r,Compilation:n},options:{watch:a}}=e,{RawSource:l}=r,{entry:u,outFile:p,blockingWatch:c}=this._options,m=this.getEntriesFromConfig(u);if(a&&!c){let r;e.hooks.thisCompilation.tap(h,(a,l)=>{a.hooks.processAssets.tapPromise({name:h,stage:n.PROCESS_ASSETS_STAGE_ADDITIONAL},async n=>{m??=this.getDefaultEntries(a.entrypoints),r=new(0,i.Worker)(new URL("worker.67bc3e4d.cjs","file:"+__filename),{workerData:{entries:m,options:this._options},stderr:!0,stdout:!0}).on("message",r=>{this.emit("compiled",r);let i=(0,s.resolve)(e.outputPath,p),n=(0,s.dirname)(i);(0,o.existsSync)(n)||(0,o.mkdirSync)(n,{recursive:!0}),e.outputFileSystem.writeFile(i,(0,t.Buffer).from(r),e=>{e?this.emit("error",e):this.emit("updated")})}).on("error",e=>this.emit("error",e)).on("exit",e=>{0!==e&&this.emit("error",Error(`Background generator exited with code ${e}`))})})}),e.hooks.watchClose.tap(h,()=>r?.terminate())}else e.hooks.thisCompilation.tap(h,(e,t)=>{e.hooks.processAssets.tapPromise({name:h,stage:n.PROCESS_ASSETS_STAGE_ADDITIONAL},async t=>{let r=e.getLogger(h);try{m??=this.getDefaultEntries(e.entrypoints),r.log("Creating .d.ts bundle",m),e.emitAsset(p,new l(await (0,d.compile)(m,this._options))),r.log(".d.ts bundle created",p)}catch(e){r.warn("Failed to create .d.ts",e)}})})}getDefaultEntries(e){let t=new Set;for(let[r,o]of e)for(let e of o.origins)e.request?.endsWith(".ts")&&t.add({...g,filePath:e.request});return Array.from(t)}getEntriesFromConfig(e){return e?"string"==typeof e?[{...g,filePath:e}]:Array.isArray(e)?e.map(e=>"string"==typeof e?{...g,filePath:e}:{...g,...e}):[{...g,...e}]:void 0}}!function(e,t){Object.keys(t).forEach(function(r){"default"===r||"__esModule"===r||Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(module.exports,m);