(function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("node:fs/promises"),require("node:path"),require("node:child_process"),require("node:process")):typeof define=="function"&&define.amd?define(["exports","node:fs/promises","node:path","node:child_process","node:process"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.BuildTls={},o.promises,o.node_path,o.node_child_process,o.process))})(this,function(o,a,$,b,y){"use strict";var g=(e=>(e.L="小写",e.U="大写",e.N="正常",e))(g||{});function B(e,i,r){r==null&&(r="正常");var s=r==="小写",t=e.replace(/[A-Z]+/g,function(f){var l=s?f.toLowerCase():f;return i+l}),n="(^\\s*)"+i+"+",u=new RegExp(n);return t=t.replace(u,"$1"),r=="大写"&&(t=P(t)),t}function P(e){return e.replace(/(^\W*)(\w)/,function(i,r,s){return r+s.toUpperCase()})}const d="build-tls";function S(e){return/\.d\.ts$/.test(e)||$.extname(e).length===0}function x(e,i,r){const s=(r==null?void 0:r.exclude)||[];return console.log(`${d}: 开始拷贝 .d.ts 文件`),a.cp(e,i,{recursive:!0,force:!0,filter:function(t){return s.some(function(u){return t.endsWith(u)})?!1:S.call(this,t)},...r}).then(function(t){return console.log(`${d}: .d.ts 文件拷贝完成`),t},function(t){throw console.error(`${d}: .d.ts 文件拷贝出错`,t),t})}function j(e,i,r){const s={...r};let{copyDTS:t,onExit:n}=s;t=s.outFile?!1:t??!0,n=n??!0;const{emptyOutDir:u,dtsBundle:f}=s;if(f){const c=typeof f=="object"?{...f}:{};c.entry=c.entry??$.join(e,"index.ts"),s.dtsBundle=c}async function l(){u&&await O(i);const c=[];if(t){const h=typeof t=="object"?t:{};c.push(x(e,i,h))}return c.push(_(i,s)),Promise.all(c)}return n?v().then(l):l()}function _(e,i){const{outFile:r,comArg:s,dtsBundle:t}=i??{};let n="npx tsc --emitDeclarationOnly";if(r){let u=r;if(typeof r!="string"&&(u=$.extname(e).length===0?$.join(e,"index.d.ts"):e),t){const{entry:f,noBanner:l,...c}=t||{};n=`npx dts-bundle-generator --out-file ${u}`,f&&(n+=` ${f}`),(l??!0)&&(n+=" --no-banner");for(const[w,p]of Object.entries(c)){if(!p)continue;let m=B(w,"-",g.L);m=` --${m}`;const E=typeof p;if(Array.isArray(p)){const F=p.map(A=>`${m} ${A}`);n+=F.join("")}else E==="string"?n+=`${m} ${p}`:n+=m}}else n+=` --outFile ${u}`}else n+=` --declarationDir ${e}`;return s&&(n+=` ${s}`),new Promise((u,f)=>{console.log(`${d}: 执行命令:${n}`),b.exec(n,function(l,c,h){console.log(`${d}: 命令已结束:${n}`),l?(console.error(`${d}: 错误: ${h}`),console.error(c),f(l)):(console.log(`${d}: 完成: `,c),u(c))})})}function v(){return new Promise(function(e){const i=()=>{y.off("beforeExit",i),e()};y.on("beforeExit",i)})}function O(e){return a.rm(e,{force:!0,recursive:!0})}o.copy_d_ts=x,o.generate_d_ts=j,o.onBeforeExit=v,o.removePath=O,o.tsc_d_ts=_,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});