create-bundler-option-DLv8UpsD.mjs 155 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263
  1. import { n as __toESM, t as require_binding } from "./binding-B4m_2rFW.mjs";
  2. import { a as logInputHookInOutputPlugin, n as error, s as logMissingCodeSplittingGroupDebugName } from "./logs-D6uA606S.mjs";
  3. import { n as BuiltinPlugin } from "./normalize-string-or-regex-xyy0kCQR.mjs";
  4. import { C as LOG_LEVEL_WARN, T as VERSION, _ as getParallelPluginInfo, a as measureIfFunction, b as LOG_LEVEL_DEBUG, c as PluginContextData, d as transformRenderedChunk, g as MinimalPluginContextImpl, i as measureHookCost, l as transformModuleInfo, o as pluginTimingsRecorderFor, p as transformAssetSource, r as OUTPUT_OPTIONS_OWNER, t as bindingifyInputOptions, v as normalizeHook, w as logLevelPriority, y as normalizeLog } from "./bindingify-input-options-DCTviPFW.mjs";
  5. import { a as unimplemented, t as arraify } from "./misc-DOSKtd97.mjs";
  6. import { Worker } from "node:worker_threads";
  7. import path, { sep } from "node:path";
  8. import { formatWithOptions, styleText } from "node:util";
  9. import g$1 from "node:process";
  10. import * as tty from "node:tty";
  11. import os from "node:os";
  12. //#region src/log/logger.ts
  13. function getLogger(plugins, onLog, logLevel, watchMode) {
  14. const minimalPriority = logLevelPriority[logLevel];
  15. const logger = (level, log, skipped = /* @__PURE__ */ new Set()) => {
  16. if (logLevelPriority[level] < minimalPriority) return;
  17. for (const plugin of getSortedPlugins("onLog", plugins)) {
  18. if (skipped.has(plugin)) continue;
  19. const { onLog: pluginOnLog } = plugin;
  20. if (pluginOnLog) {
  21. const getLogHandler = (level) => {
  22. if (logLevelPriority[level] < minimalPriority) return () => {};
  23. return (log) => logger(level, normalizeLog(log), new Set(skipped).add(plugin));
  24. };
  25. if (("handler" in pluginOnLog ? pluginOnLog.handler : pluginOnLog).call({
  26. debug: getLogHandler("debug"),
  27. error: (log) => error(normalizeLog(log)),
  28. info: getLogHandler("info"),
  29. meta: {
  30. rollupVersion: "4.23.0",
  31. rolldownVersion: VERSION,
  32. watchMode
  33. },
  34. warn: getLogHandler("warn"),
  35. pluginName: plugin.name || "unknown"
  36. }, level, log) === false) return;
  37. }
  38. }
  39. onLog(level, log);
  40. };
  41. return logger;
  42. }
  43. const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
  44. const { onwarn, onLog } = config;
  45. const defaultOnLog = getDefaultOnLog(printLog, onwarn);
  46. if (onLog) {
  47. const minimalPriority = logLevelPriority[logLevel];
  48. return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
  49. if (level === "error") return error(normalizeLog(handledLog));
  50. if (logLevelPriority[level] >= minimalPriority) defaultOnLog(level, normalizeLog(handledLog));
  51. });
  52. }
  53. return defaultOnLog;
  54. };
  55. const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
  56. if (level === "warn") onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
  57. else printLog(level, log);
  58. } : printLog;
  59. const addLogToString = (log) => {
  60. Object.defineProperty(log, "toString", {
  61. value: () => getExtendedLogMessage(log),
  62. writable: true
  63. });
  64. return log;
  65. };
  66. const defaultPrintLog = (level, log) => {
  67. const message = getExtendedLogMessage(log);
  68. switch (level) {
  69. case LOG_LEVEL_WARN: return console.warn(message);
  70. case LOG_LEVEL_DEBUG: return console.debug(message);
  71. default: return console.info(message);
  72. }
  73. };
  74. const getExtendedLogMessage = (log) => {
  75. let prefix = "";
  76. if (log.plugin) prefix += `(${log.plugin} plugin) `;
  77. if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
  78. return prefix + log.message;
  79. };
  80. function relativeId(id) {
  81. if (!path.isAbsolute(id)) return id;
  82. return path.relative(path.resolve(), id);
  83. }
  84. //#endregion
  85. //#region src/constants/plugin.ts
  86. const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
  87. "options",
  88. "buildStart",
  89. "resolveId",
  90. "load",
  91. "transform",
  92. "moduleParsed",
  93. "buildEnd",
  94. "onLog",
  95. "resolveDynamicImport",
  96. "closeBundle",
  97. "closeWatcher",
  98. "watchChange"
  99. ];
  100. const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
  101. "augmentChunkHash",
  102. "outputOptions",
  103. "renderChunk",
  104. "renderStart",
  105. "renderError",
  106. "writeBundle",
  107. "generateBundle",
  108. "resolveFileUrl"
  109. ];
  110. const ENUMERATED_PLUGIN_HOOK_NAMES = [
  111. ...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
  112. ...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
  113. "footer",
  114. "banner",
  115. "intro",
  116. "outro"
  117. ];
  118. ENUMERATED_PLUGIN_HOOK_NAMES[0], ENUMERATED_PLUGIN_HOOK_NAMES[0], ENUMERATED_PLUGIN_HOOK_NAMES[1], ENUMERATED_PLUGIN_HOOK_NAMES[1], ENUMERATED_PLUGIN_HOOK_NAMES[2], ENUMERATED_PLUGIN_HOOK_NAMES[2], ENUMERATED_PLUGIN_HOOK_NAMES[3], ENUMERATED_PLUGIN_HOOK_NAMES[3], ENUMERATED_PLUGIN_HOOK_NAMES[4], ENUMERATED_PLUGIN_HOOK_NAMES[4], ENUMERATED_PLUGIN_HOOK_NAMES[5], ENUMERATED_PLUGIN_HOOK_NAMES[5], ENUMERATED_PLUGIN_HOOK_NAMES[6], ENUMERATED_PLUGIN_HOOK_NAMES[6], ENUMERATED_PLUGIN_HOOK_NAMES[7], ENUMERATED_PLUGIN_HOOK_NAMES[7], ENUMERATED_PLUGIN_HOOK_NAMES[8], ENUMERATED_PLUGIN_HOOK_NAMES[8], ENUMERATED_PLUGIN_HOOK_NAMES[9], ENUMERATED_PLUGIN_HOOK_NAMES[9], ENUMERATED_PLUGIN_HOOK_NAMES[10], ENUMERATED_PLUGIN_HOOK_NAMES[10], ENUMERATED_PLUGIN_HOOK_NAMES[11], ENUMERATED_PLUGIN_HOOK_NAMES[11], ENUMERATED_PLUGIN_HOOK_NAMES[12], ENUMERATED_PLUGIN_HOOK_NAMES[12], ENUMERATED_PLUGIN_HOOK_NAMES[13], ENUMERATED_PLUGIN_HOOK_NAMES[13], ENUMERATED_PLUGIN_HOOK_NAMES[14], ENUMERATED_PLUGIN_HOOK_NAMES[14], ENUMERATED_PLUGIN_HOOK_NAMES[15], ENUMERATED_PLUGIN_HOOK_NAMES[15], ENUMERATED_PLUGIN_HOOK_NAMES[16], ENUMERATED_PLUGIN_HOOK_NAMES[16], ENUMERATED_PLUGIN_HOOK_NAMES[17], ENUMERATED_PLUGIN_HOOK_NAMES[17], ENUMERATED_PLUGIN_HOOK_NAMES[18], ENUMERATED_PLUGIN_HOOK_NAMES[18], ENUMERATED_PLUGIN_HOOK_NAMES[19], ENUMERATED_PLUGIN_HOOK_NAMES[19], ENUMERATED_PLUGIN_HOOK_NAMES[20], ENUMERATED_PLUGIN_HOOK_NAMES[20], ENUMERATED_PLUGIN_HOOK_NAMES[21], ENUMERATED_PLUGIN_HOOK_NAMES[21], ENUMERATED_PLUGIN_HOOK_NAMES[22], ENUMERATED_PLUGIN_HOOK_NAMES[22], ENUMERATED_PLUGIN_HOOK_NAMES[23], ENUMERATED_PLUGIN_HOOK_NAMES[23];
  119. //#endregion
  120. //#region src/plugin/internal-hooks.ts
  121. /**
  122. * Names of the hidden hooks, alongside {@linkcode InternalFunctionPluginHooks}.
  123. * Kept separate from `ENUMERATED_INPUT_PLUGIN_HOOK_NAMES` so the names stay out
  124. * of the published `.d.ts` (that list's type is reachable from public types).
  125. */
  126. const INTERNAL_PLUGIN_HOOK_NAMES = ["hotUpdate"];
  127. //#endregion
  128. //#region src/utils/async-flatten.ts
  129. async function asyncFlatten(array) {
  130. do
  131. array = (await Promise.all(array)).flat(Infinity);
  132. while (array.some((v) => v?.then));
  133. return array;
  134. }
  135. //#endregion
  136. //#region src/utils/normalize-plugin-option.ts
  137. const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
  138. function checkOutputPluginOption(plugins, onLog) {
  139. for (const plugin of plugins) for (const hook of [...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES, ...INTERNAL_PLUGIN_HOOK_NAMES]) if (hook in plugin) {
  140. delete plugin[hook];
  141. onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
  142. }
  143. return plugins;
  144. }
  145. function normalizePlugins(plugins, anonymousPrefix) {
  146. for (const [index, plugin] of plugins.entries()) {
  147. if (getParallelPluginInfo(plugin)) continue;
  148. if (plugin instanceof BuiltinPlugin) continue;
  149. const objectPlugin = plugin;
  150. if (!objectPlugin.name) objectPlugin.name = `${anonymousPrefix}${index + 1}`;
  151. }
  152. return plugins;
  153. }
  154. const ANONYMOUS_PLUGIN_PREFIX = "at position ";
  155. const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
  156. //#endregion
  157. //#region src/plugin/plugin-driver.ts
  158. var PluginDriver = class {
  159. static async callOptionsHook(inputOptions, watchMode = false) {
  160. const logLevel = inputOptions.logLevel || "info";
  161. const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
  162. const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
  163. for (const plugin of plugins) {
  164. const name = plugin.name || "unknown";
  165. const options = plugin.options;
  166. if (options) {
  167. const { handler } = normalizeHook(options);
  168. const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
  169. if (result) inputOptions = result;
  170. }
  171. }
  172. return inputOptions;
  173. }
  174. static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
  175. const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
  176. for (const plugin of sortedPlugins) {
  177. const name = plugin.name || "unknown";
  178. const options = plugin.outputOptions;
  179. if (options) {
  180. const { handler } = normalizeHook(options);
  181. const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
  182. if (result) outputOptions = result;
  183. }
  184. }
  185. return outputOptions;
  186. }
  187. };
  188. function getObjectPlugins(plugins) {
  189. return plugins.filter((plugin) => {
  190. if (!plugin) return;
  191. if (getParallelPluginInfo(plugin)) return;
  192. if (plugin instanceof BuiltinPlugin) return;
  193. return plugin;
  194. });
  195. }
  196. function getSortedPlugins(hookName, plugins) {
  197. const pre = [];
  198. const normal = [];
  199. const post = [];
  200. for (const plugin of plugins) {
  201. const hook = plugin[hookName];
  202. if (hook) {
  203. if (typeof hook === "object") {
  204. if (hook.order === "pre") {
  205. pre.push(plugin);
  206. continue;
  207. }
  208. if (hook.order === "post") {
  209. post.push(plugin);
  210. continue;
  211. }
  212. }
  213. normal.push(plugin);
  214. }
  215. }
  216. return [
  217. ...pre,
  218. ...normal,
  219. ...post
  220. ];
  221. }
  222. const DEFAULT_CONFIG = {
  223. lang: void 0,
  224. message: void 0,
  225. abortEarly: void 0,
  226. abortPipeEarly: void 0
  227. };
  228. /**
  229. * Returns the global configuration.
  230. *
  231. * @param config The config to merge.
  232. *
  233. * @returns The configuration.
  234. */
  235. /* @__NO_SIDE_EFFECTS__ */
  236. function getGlobalConfig(config$1) {
  237. if (!config$1 && true) return DEFAULT_CONFIG;
  238. return {
  239. lang: config$1?.lang ?? void 0,
  240. message: config$1?.message,
  241. abortEarly: config$1?.abortEarly ?? void 0,
  242. abortPipeEarly: config$1?.abortPipeEarly ?? void 0
  243. };
  244. }
  245. /**
  246. * Stringifies an unknown input to a literal or type string.
  247. *
  248. * @param input The unknown input.
  249. *
  250. * @returns A literal or type string.
  251. *
  252. * @internal
  253. */
  254. /* @__NO_SIDE_EFFECTS__ */
  255. function _stringify(input) {
  256. const type = typeof input;
  257. if (type === "string") return `"${input}"`;
  258. if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
  259. if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
  260. return type;
  261. }
  262. /**
  263. * Adds an issue to the dataset.
  264. *
  265. * @param context The issue context.
  266. * @param label The issue label.
  267. * @param dataset The input dataset.
  268. * @param config The configuration.
  269. * @param other The optional props.
  270. *
  271. * @internal
  272. */
  273. function _addIssue(context, label, dataset, config$1, other) {
  274. const input = other && "input" in other ? other.input : dataset.value;
  275. const expected = other?.expected ?? context.expects ?? null;
  276. const received = other?.received ?? /* @__PURE__ */ _stringify(input);
  277. const issue = {
  278. kind: context.kind,
  279. type: context.type,
  280. input,
  281. expected,
  282. received,
  283. message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
  284. requirement: context.requirement,
  285. path: other?.path,
  286. issues: other?.issues,
  287. lang: config$1.lang,
  288. abortEarly: config$1.abortEarly,
  289. abortPipeEarly: config$1.abortPipeEarly
  290. };
  291. const isSchema = context.kind === "schema";
  292. const message$1 = other?.message ?? context.message ?? (context.reference, issue.lang, void 0) ?? (isSchema ? (issue.lang, void 0) : null) ?? config$1.message ?? (issue.lang, void 0);
  293. if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
  294. if (isSchema) dataset.typed = false;
  295. if (dataset.issues) dataset.issues.push(issue);
  296. else dataset.issues = [issue];
  297. }
  298. /**
  299. * Compares two values using the SameValueZero algorithm, which treats `NaN`
  300. * as equal to itself unlike `===`.
  301. *
  302. * @param value1 The first value.
  303. * @param value2 The second value.
  304. *
  305. * @returns Whether the values are equal.
  306. *
  307. * @internal
  308. */
  309. /* @__NO_SIDE_EFFECTS__ */
  310. function _isSameValueZero(value1, value2) {
  311. return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
  312. }
  313. /**
  314. * Disallows inherited object properties and prevents object prototype
  315. * pollution by disallowing certain keys.
  316. *
  317. * @param object The object to check.
  318. * @param key The key to check.
  319. *
  320. * @returns Whether the key is allowed.
  321. *
  322. * @internal
  323. */
  324. /* @__NO_SIDE_EFFECTS__ */
  325. function _isValidObjectKey(object$1, key) {
  326. return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
  327. }
  328. /**
  329. * Joins multiple `expects` values with the given separator.
  330. *
  331. * @param values The `expects` values.
  332. * @param separator The separator.
  333. *
  334. * @returns The joined `expects` property.
  335. *
  336. * @internal
  337. */
  338. /* @__NO_SIDE_EFFECTS__ */
  339. function _joinExpects(values$1, separator) {
  340. const list = [...new Set(values$1)];
  341. if (list.length > 1) return `(${list.join(` ${separator} `)})`;
  342. return list[0] ?? "never";
  343. }
  344. /**
  345. * Eagerly creates and attaches the Standard Schema properties of a schema.
  346. *
  347. * Hint: The contextual `this` type includes the standard properties that are
  348. * attached before the schema is returned.
  349. *
  350. * @param schema The schema to attach standard properties to.
  351. *
  352. * @returns The schema with standard properties attached.
  353. *
  354. * @internal
  355. */
  356. function _standardSchema(schema) {
  357. schema["~standard"] = {
  358. version: 1,
  359. vendor: "valibot",
  360. validate: (value$1) => schema["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig())
  361. };
  362. return schema;
  363. }
  364. /**
  365. * A Valibot error with useful information.
  366. */
  367. var ValiError = class extends Error {
  368. /**
  369. * Creates a Valibot error with useful information.
  370. *
  371. * @param issues The error issues.
  372. */
  373. constructor(issues) {
  374. super(issues[0].message);
  375. this.name = "ValiError";
  376. this.issues = issues;
  377. }
  378. };
  379. /* @__NO_SIDE_EFFECTS__ */
  380. function args(schema) {
  381. return {
  382. kind: "transformation",
  383. type: "args",
  384. reference: args,
  385. async: false,
  386. schema,
  387. "~run"(dataset, config$1) {
  388. const func = dataset.value;
  389. dataset.value = (...args_) => {
  390. const argsDataset = this.schema["~run"]({ value: args_ }, config$1);
  391. if (argsDataset.issues) throw new ValiError(argsDataset.issues);
  392. return func(...argsDataset.value);
  393. };
  394. return dataset;
  395. }
  396. };
  397. }
  398. /**
  399. * Creates an await transformation action.
  400. *
  401. * @returns An await action.
  402. */
  403. /* @__NO_SIDE_EFFECTS__ */
  404. function awaitAsync() {
  405. return {
  406. kind: "transformation",
  407. type: "await",
  408. reference: awaitAsync,
  409. async: true,
  410. async "~run"(dataset) {
  411. dataset.value = await dataset.value;
  412. return dataset;
  413. }
  414. };
  415. }
  416. /**
  417. * Creates a description metadata action.
  418. *
  419. * @param description_ The description text.
  420. *
  421. * @returns A description action.
  422. */
  423. /* @__NO_SIDE_EFFECTS__ */
  424. function description(description_) {
  425. return {
  426. kind: "metadata",
  427. type: "description",
  428. reference: description,
  429. description: description_
  430. };
  431. }
  432. /* @__NO_SIDE_EFFECTS__ */
  433. function returns(schema) {
  434. return {
  435. kind: "transformation",
  436. type: "returns",
  437. reference: returns,
  438. async: false,
  439. schema,
  440. "~run"(dataset, config$1) {
  441. const func = dataset.value;
  442. dataset.value = (...args_) => {
  443. const returnsDataset = this.schema["~run"]({ value: func(...args_) }, config$1);
  444. if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
  445. return returnsDataset.value;
  446. };
  447. return dataset;
  448. }
  449. };
  450. }
  451. /* @__NO_SIDE_EFFECTS__ */
  452. function returnsAsync(schema) {
  453. return {
  454. kind: "transformation",
  455. type: "returns",
  456. reference: returnsAsync,
  457. async: false,
  458. schema,
  459. "~run"(dataset, config$1) {
  460. const func = dataset.value;
  461. dataset.value = async (...args_) => {
  462. const returnsDataset = await this.schema["~run"]({ value: await func(...args_) }, config$1);
  463. if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
  464. return returnsDataset.value;
  465. };
  466. return dataset;
  467. }
  468. };
  469. }
  470. const ABORT_EARLY_CONFIG = { abortEarly: true };
  471. /**
  472. * Returns the fallback value of the schema.
  473. *
  474. * @param schema The schema to get it from.
  475. * @param dataset The output dataset if available.
  476. * @param config The config if available.
  477. *
  478. * @returns The fallback value.
  479. */
  480. /* @__NO_SIDE_EFFECTS__ */
  481. function getFallback(schema, dataset, config$1) {
  482. return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
  483. }
  484. /**
  485. * Returns the default value of the schema.
  486. *
  487. * @param schema The schema to get it from.
  488. * @param dataset The input dataset if available.
  489. * @param config The config if available.
  490. *
  491. * @returns The default value.
  492. */
  493. /* @__NO_SIDE_EFFECTS__ */
  494. function getDefault(schema, dataset, config$1) {
  495. return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
  496. }
  497. /**
  498. * Checks if the input matches the schema. By using a type predicate, this
  499. * function can be used as a type guard.
  500. *
  501. * @param schema The schema to be used.
  502. * @param input The input to be tested.
  503. *
  504. * @returns Whether the input matches the schema.
  505. */
  506. /* @__NO_SIDE_EFFECTS__ */
  507. function is(schema, input) {
  508. return !schema["~run"]({ value: input }, ABORT_EARLY_CONFIG).issues;
  509. }
  510. /**
  511. * Creates an any schema.
  512. *
  513. * Hint: This schema function exists only for completeness and is not
  514. * recommended in practice. Instead, `unknown` should be used to accept
  515. * unknown data.
  516. *
  517. * @returns An any schema.
  518. */
  519. /* @__NO_SIDE_EFFECTS__ */
  520. function any() {
  521. return _standardSchema({
  522. kind: "schema",
  523. type: "any",
  524. reference: any,
  525. expects: "any",
  526. async: false,
  527. "~run"(dataset) {
  528. dataset.typed = true;
  529. return dataset;
  530. }
  531. });
  532. }
  533. /* @__NO_SIDE_EFFECTS__ */
  534. function array(item, message$1) {
  535. return _standardSchema({
  536. kind: "schema",
  537. type: "array",
  538. reference: array,
  539. expects: "Array",
  540. async: false,
  541. item,
  542. message: message$1,
  543. "~run"(dataset, config$1) {
  544. const input = dataset.value;
  545. if (Array.isArray(input)) {
  546. dataset.typed = true;
  547. dataset.value = [];
  548. for (let key = 0; key < input.length; key++) {
  549. const value$1 = input[key];
  550. const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
  551. if (itemDataset.issues) {
  552. const pathItem = {
  553. type: "array",
  554. origin: "value",
  555. input,
  556. key,
  557. value: value$1
  558. };
  559. for (const issue of itemDataset.issues) {
  560. if (issue.path) issue.path.unshift(pathItem);
  561. else issue.path = [pathItem];
  562. dataset.issues?.push(issue);
  563. }
  564. if (!dataset.issues) dataset.issues = itemDataset.issues;
  565. if (config$1.abortEarly) {
  566. dataset.typed = false;
  567. break;
  568. }
  569. }
  570. if (!itemDataset.typed) dataset.typed = false;
  571. dataset.value.push(itemDataset.value);
  572. }
  573. } else _addIssue(this, "type", dataset, config$1);
  574. return dataset;
  575. }
  576. });
  577. }
  578. /* @__NO_SIDE_EFFECTS__ */
  579. function boolean(message$1) {
  580. return _standardSchema({
  581. kind: "schema",
  582. type: "boolean",
  583. reference: boolean,
  584. expects: "boolean",
  585. async: false,
  586. message: message$1,
  587. "~run"(dataset, config$1) {
  588. if (typeof dataset.value === "boolean") dataset.typed = true;
  589. else _addIssue(this, "type", dataset, config$1);
  590. return dataset;
  591. }
  592. });
  593. }
  594. /* @__NO_SIDE_EFFECTS__ */
  595. function custom(check$1, message$1) {
  596. return _standardSchema({
  597. kind: "schema",
  598. type: "custom",
  599. reference: custom,
  600. expects: "unknown",
  601. async: false,
  602. check: check$1,
  603. message: message$1,
  604. "~run"(dataset, config$1) {
  605. if (this.check(dataset.value)) dataset.typed = true;
  606. else _addIssue(this, "type", dataset, config$1);
  607. return dataset;
  608. }
  609. });
  610. }
  611. /* @__NO_SIDE_EFFECTS__ */
  612. function function_(message$1) {
  613. return _standardSchema({
  614. kind: "schema",
  615. type: "function",
  616. reference: function_,
  617. expects: "Function",
  618. async: false,
  619. message: message$1,
  620. "~run"(dataset, config$1) {
  621. if (typeof dataset.value === "function") dataset.typed = true;
  622. else _addIssue(this, "type", dataset, config$1);
  623. return dataset;
  624. }
  625. });
  626. }
  627. /* @__NO_SIDE_EFFECTS__ */
  628. function instance(class_, message$1) {
  629. return _standardSchema({
  630. kind: "schema",
  631. type: "instance",
  632. reference: instance,
  633. expects: class_.name,
  634. async: false,
  635. class: class_,
  636. message: message$1,
  637. "~run"(dataset, config$1) {
  638. if (dataset.value instanceof this.class) dataset.typed = true;
  639. else _addIssue(this, "type", dataset, config$1);
  640. return dataset;
  641. }
  642. });
  643. }
  644. /* @__NO_SIDE_EFFECTS__ */
  645. function literal(literal_, message$1) {
  646. return _standardSchema({
  647. kind: "schema",
  648. type: "literal",
  649. reference: literal,
  650. expects: /* @__PURE__ */ _stringify(literal_),
  651. async: false,
  652. literal: literal_,
  653. message: message$1,
  654. "~run"(dataset, config$1) {
  655. if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
  656. else _addIssue(this, "type", dataset, config$1);
  657. return dataset;
  658. }
  659. });
  660. }
  661. /* @__NO_SIDE_EFFECTS__ */
  662. function never(message$1) {
  663. return _standardSchema({
  664. kind: "schema",
  665. type: "never",
  666. reference: never,
  667. expects: "never",
  668. async: false,
  669. message: message$1,
  670. "~run"(dataset, config$1) {
  671. _addIssue(this, "type", dataset, config$1);
  672. return dataset;
  673. }
  674. });
  675. }
  676. /* @__NO_SIDE_EFFECTS__ */
  677. function nullish(wrapped, default_) {
  678. return _standardSchema({
  679. kind: "schema",
  680. type: "nullish",
  681. reference: nullish,
  682. expects: `(${wrapped.expects} | null | undefined)`,
  683. async: false,
  684. wrapped,
  685. default: default_,
  686. "~run"(dataset, config$1) {
  687. if (dataset.value === null || dataset.value === void 0) {
  688. if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
  689. if (dataset.value === null || dataset.value === void 0) {
  690. dataset.typed = true;
  691. return dataset;
  692. }
  693. }
  694. return this.wrapped["~run"](dataset, config$1);
  695. }
  696. });
  697. }
  698. /* @__NO_SIDE_EFFECTS__ */
  699. function number(message$1) {
  700. return _standardSchema({
  701. kind: "schema",
  702. type: "number",
  703. reference: number,
  704. expects: "number",
  705. async: false,
  706. message: message$1,
  707. "~run"(dataset, config$1) {
  708. if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
  709. else _addIssue(this, "type", dataset, config$1);
  710. return dataset;
  711. }
  712. });
  713. }
  714. /* @__NO_SIDE_EFFECTS__ */
  715. function object(entries$1, message$1) {
  716. return _standardSchema({
  717. kind: "schema",
  718. type: "object",
  719. reference: object,
  720. expects: "Object",
  721. async: false,
  722. entries: entries$1,
  723. message: message$1,
  724. "~run"(dataset, config$1) {
  725. const input = dataset.value;
  726. if (input && typeof input === "object") {
  727. dataset.typed = true;
  728. dataset.value = {};
  729. for (const key in this.entries) {
  730. const valueSchema = this.entries[key];
  731. if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
  732. const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
  733. const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
  734. if (valueDataset.issues) {
  735. const pathItem = {
  736. type: "object",
  737. origin: "value",
  738. input,
  739. key,
  740. value: value$1
  741. };
  742. for (const issue of valueDataset.issues) {
  743. if (issue.path) issue.path.unshift(pathItem);
  744. else issue.path = [pathItem];
  745. dataset.issues?.push(issue);
  746. }
  747. if (!dataset.issues) dataset.issues = valueDataset.issues;
  748. if (config$1.abortEarly) {
  749. dataset.typed = false;
  750. break;
  751. }
  752. }
  753. if (!valueDataset.typed) dataset.typed = false;
  754. dataset.value[key] = valueDataset.value;
  755. } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
  756. else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
  757. _addIssue(this, "key", dataset, config$1, {
  758. input: void 0,
  759. expected: `"${key}"`,
  760. path: [{
  761. type: "object",
  762. origin: "key",
  763. input,
  764. key,
  765. value: input[key]
  766. }]
  767. });
  768. if (config$1.abortEarly) break;
  769. }
  770. }
  771. } else _addIssue(this, "type", dataset, config$1);
  772. return dataset;
  773. }
  774. });
  775. }
  776. /* @__NO_SIDE_EFFECTS__ */
  777. function optional(wrapped, default_) {
  778. return _standardSchema({
  779. kind: "schema",
  780. type: "optional",
  781. reference: optional,
  782. expects: `(${wrapped.expects} | undefined)`,
  783. async: false,
  784. wrapped,
  785. default: default_,
  786. "~run"(dataset, config$1) {
  787. if (dataset.value === void 0) {
  788. if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
  789. if (dataset.value === void 0) {
  790. dataset.typed = true;
  791. return dataset;
  792. }
  793. }
  794. return this.wrapped["~run"](dataset, config$1);
  795. }
  796. });
  797. }
  798. /* @__NO_SIDE_EFFECTS__ */
  799. function picklist(options, message$1) {
  800. return _standardSchema({
  801. kind: "schema",
  802. type: "picklist",
  803. reference: picklist,
  804. expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
  805. async: false,
  806. options,
  807. message: message$1,
  808. "~run"(dataset, config$1) {
  809. if (this.options.includes(dataset.value)) dataset.typed = true;
  810. else _addIssue(this, "type", dataset, config$1);
  811. return dataset;
  812. }
  813. });
  814. }
  815. /* @__NO_SIDE_EFFECTS__ */
  816. function promise(message$1) {
  817. return _standardSchema({
  818. kind: "schema",
  819. type: "promise",
  820. reference: promise,
  821. expects: "Promise",
  822. async: false,
  823. message: message$1,
  824. "~run"(dataset, config$1) {
  825. if (dataset.value instanceof Promise) dataset.typed = true;
  826. else _addIssue(this, "type", dataset, config$1);
  827. return dataset;
  828. }
  829. });
  830. }
  831. /* @__NO_SIDE_EFFECTS__ */
  832. function record(key, value$1, message$1) {
  833. return _standardSchema({
  834. kind: "schema",
  835. type: "record",
  836. reference: record,
  837. expects: "Object",
  838. async: false,
  839. key,
  840. value: value$1,
  841. message: message$1,
  842. "~run"(dataset, config$1) {
  843. const input = dataset.value;
  844. if (input && typeof input === "object") {
  845. dataset.typed = true;
  846. dataset.value = {};
  847. for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
  848. const entryValue = input[entryKey];
  849. const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
  850. if (keyDataset.issues) {
  851. const pathItem = {
  852. type: "object",
  853. origin: "key",
  854. input,
  855. key: entryKey,
  856. value: entryValue
  857. };
  858. for (const issue of keyDataset.issues) {
  859. issue.path = [pathItem];
  860. dataset.issues?.push(issue);
  861. }
  862. if (!dataset.issues) dataset.issues = keyDataset.issues;
  863. if (config$1.abortEarly) {
  864. dataset.typed = false;
  865. break;
  866. }
  867. }
  868. const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
  869. if (valueDataset.issues) {
  870. const pathItem = {
  871. type: "object",
  872. origin: "value",
  873. input,
  874. key: entryKey,
  875. value: entryValue
  876. };
  877. for (const issue of valueDataset.issues) {
  878. if (issue.path) issue.path.unshift(pathItem);
  879. else issue.path = [pathItem];
  880. dataset.issues?.push(issue);
  881. }
  882. if (!dataset.issues) dataset.issues = valueDataset.issues;
  883. if (config$1.abortEarly) {
  884. dataset.typed = false;
  885. break;
  886. }
  887. }
  888. if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
  889. if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
  890. }
  891. } else _addIssue(this, "type", dataset, config$1);
  892. return dataset;
  893. }
  894. });
  895. }
  896. /* @__NO_SIDE_EFFECTS__ */
  897. function strictObject(entries$1, message$1) {
  898. return _standardSchema({
  899. kind: "schema",
  900. type: "strict_object",
  901. reference: strictObject,
  902. expects: "Object",
  903. async: false,
  904. entries: entries$1,
  905. message: message$1,
  906. "~run"(dataset, config$1) {
  907. const input = dataset.value;
  908. if (input && typeof input === "object") {
  909. dataset.typed = true;
  910. dataset.value = {};
  911. for (const key in this.entries) {
  912. const valueSchema = this.entries[key];
  913. if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
  914. const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
  915. const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
  916. if (valueDataset.issues) {
  917. const pathItem = {
  918. type: "object",
  919. origin: "value",
  920. input,
  921. key,
  922. value: value$1
  923. };
  924. for (const issue of valueDataset.issues) {
  925. if (issue.path) issue.path.unshift(pathItem);
  926. else issue.path = [pathItem];
  927. dataset.issues?.push(issue);
  928. }
  929. if (!dataset.issues) dataset.issues = valueDataset.issues;
  930. if (config$1.abortEarly) {
  931. dataset.typed = false;
  932. break;
  933. }
  934. }
  935. if (!valueDataset.typed) dataset.typed = false;
  936. dataset.value[key] = valueDataset.value;
  937. } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
  938. else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
  939. _addIssue(this, "key", dataset, config$1, {
  940. input: void 0,
  941. expected: `"${key}"`,
  942. path: [{
  943. type: "object",
  944. origin: "key",
  945. input,
  946. key,
  947. value: input[key]
  948. }]
  949. });
  950. if (config$1.abortEarly) break;
  951. }
  952. }
  953. if (!dataset.issues || !config$1.abortEarly) {
  954. for (const key in input) if (!Object.prototype.hasOwnProperty.call(this.entries, key)) {
  955. _addIssue(this, "key", dataset, config$1, {
  956. input: key,
  957. expected: "never",
  958. path: [{
  959. type: "object",
  960. origin: "key",
  961. input,
  962. key,
  963. value: input[key]
  964. }]
  965. });
  966. break;
  967. }
  968. }
  969. } else _addIssue(this, "type", dataset, config$1);
  970. return dataset;
  971. }
  972. });
  973. }
  974. /* @__NO_SIDE_EFFECTS__ */
  975. function string(message$1) {
  976. return _standardSchema({
  977. kind: "schema",
  978. type: "string",
  979. reference: string,
  980. expects: "string",
  981. async: false,
  982. message: message$1,
  983. "~run"(dataset, config$1) {
  984. if (typeof dataset.value === "string") dataset.typed = true;
  985. else _addIssue(this, "type", dataset, config$1);
  986. return dataset;
  987. }
  988. });
  989. }
  990. /* @__NO_SIDE_EFFECTS__ */
  991. function tuple(items, message$1) {
  992. return _standardSchema({
  993. kind: "schema",
  994. type: "tuple",
  995. reference: tuple,
  996. expects: "Array",
  997. async: false,
  998. items,
  999. message: message$1,
  1000. "~run"(dataset, config$1) {
  1001. const input = dataset.value;
  1002. if (Array.isArray(input)) {
  1003. dataset.typed = true;
  1004. dataset.value = [];
  1005. for (let key = 0; key < this.items.length; key++) {
  1006. const value$1 = input[key];
  1007. const itemDataset = this.items[key]["~run"]({ value: value$1 }, config$1);
  1008. if (itemDataset.issues) {
  1009. const pathItem = {
  1010. type: "array",
  1011. origin: "value",
  1012. input,
  1013. key,
  1014. value: value$1
  1015. };
  1016. for (const issue of itemDataset.issues) {
  1017. if (issue.path) issue.path.unshift(pathItem);
  1018. else issue.path = [pathItem];
  1019. dataset.issues?.push(issue);
  1020. }
  1021. if (!dataset.issues) dataset.issues = itemDataset.issues;
  1022. if (config$1.abortEarly) {
  1023. dataset.typed = false;
  1024. break;
  1025. }
  1026. }
  1027. if (!itemDataset.typed) dataset.typed = false;
  1028. dataset.value.push(itemDataset.value);
  1029. }
  1030. } else _addIssue(this, "type", dataset, config$1);
  1031. return dataset;
  1032. }
  1033. });
  1034. }
  1035. /* @__NO_SIDE_EFFECTS__ */
  1036. function undefined_(message$1) {
  1037. return _standardSchema({
  1038. kind: "schema",
  1039. type: "undefined",
  1040. reference: undefined_,
  1041. expects: "undefined",
  1042. async: false,
  1043. message: message$1,
  1044. "~run"(dataset, config$1) {
  1045. if (dataset.value === void 0) dataset.typed = true;
  1046. else _addIssue(this, "type", dataset, config$1);
  1047. return dataset;
  1048. }
  1049. });
  1050. }
  1051. /**
  1052. * Returns the sub issues of the provided datasets for the union issue.
  1053. *
  1054. * @param datasets The datasets.
  1055. *
  1056. * @returns The sub issues.
  1057. *
  1058. * @internal
  1059. */
  1060. /* @__NO_SIDE_EFFECTS__ */
  1061. function _subIssues(datasets) {
  1062. let issues;
  1063. if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
  1064. else issues = dataset.issues;
  1065. return issues;
  1066. }
  1067. /* @__NO_SIDE_EFFECTS__ */
  1068. function union(options, message$1) {
  1069. return _standardSchema({
  1070. kind: "schema",
  1071. type: "union",
  1072. reference: union,
  1073. expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
  1074. async: false,
  1075. options,
  1076. message: message$1,
  1077. "~run"(dataset, config$1) {
  1078. let validDataset;
  1079. let typedDatasets;
  1080. let untypedDatasets;
  1081. for (const schema of this.options) {
  1082. const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
  1083. if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
  1084. else typedDatasets = [optionDataset];
  1085. else {
  1086. validDataset = optionDataset;
  1087. break;
  1088. }
  1089. else if (untypedDatasets) untypedDatasets.push(optionDataset);
  1090. else untypedDatasets = [optionDataset];
  1091. }
  1092. if (validDataset) return validDataset;
  1093. if (typedDatasets) {
  1094. if (typedDatasets.length === 1) return typedDatasets[0];
  1095. _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
  1096. dataset.typed = true;
  1097. } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
  1098. else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
  1099. return dataset;
  1100. }
  1101. });
  1102. }
  1103. /* @__NO_SIDE_EFFECTS__ */
  1104. function unionAsync(options, message$1) {
  1105. return _standardSchema({
  1106. kind: "schema",
  1107. type: "union",
  1108. reference: unionAsync,
  1109. expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
  1110. async: true,
  1111. options,
  1112. message: message$1,
  1113. async "~run"(dataset, config$1) {
  1114. let validDataset;
  1115. let typedDatasets;
  1116. let untypedDatasets;
  1117. for (const schema of this.options) {
  1118. const optionDataset = await schema["~run"]({ value: dataset.value }, config$1);
  1119. if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
  1120. else typedDatasets = [optionDataset];
  1121. else {
  1122. validDataset = optionDataset;
  1123. break;
  1124. }
  1125. else if (untypedDatasets) untypedDatasets.push(optionDataset);
  1126. else untypedDatasets = [optionDataset];
  1127. }
  1128. if (validDataset) return validDataset;
  1129. if (typedDatasets) {
  1130. if (typedDatasets.length === 1) return typedDatasets[0];
  1131. _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
  1132. dataset.typed = true;
  1133. } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
  1134. else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
  1135. return dataset;
  1136. }
  1137. });
  1138. }
  1139. /* @__NO_SIDE_EFFECTS__ */
  1140. function void_(message$1) {
  1141. return _standardSchema({
  1142. kind: "schema",
  1143. type: "void",
  1144. reference: void_,
  1145. expects: "void",
  1146. async: false,
  1147. message: message$1,
  1148. "~run"(dataset, config$1) {
  1149. if (dataset.value === void 0) dataset.typed = true;
  1150. else _addIssue(this, "type", dataset, config$1);
  1151. return dataset;
  1152. }
  1153. });
  1154. }
  1155. /* @__NO_SIDE_EFFECTS__ */
  1156. function keyof(schema, message$1) {
  1157. return /* @__PURE__ */ picklist(Object.keys(schema.entries), message$1);
  1158. }
  1159. /**
  1160. * Creates a modified copy of an object schema that does not contain the
  1161. * selected entries.
  1162. *
  1163. * @param schema The schema to omit from.
  1164. * @param keys The selected entries.
  1165. *
  1166. * @returns An object schema.
  1167. */
  1168. /* @__NO_SIDE_EFFECTS__ */
  1169. function omit(schema, keys) {
  1170. const entries$1 = { ...schema.entries };
  1171. for (const key of keys) delete entries$1[key];
  1172. return _standardSchema({
  1173. ...schema,
  1174. entries: entries$1
  1175. });
  1176. }
  1177. /* @__NO_SIDE_EFFECTS__ */
  1178. function partial(schema, keys) {
  1179. const entries$1 = {};
  1180. for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
  1181. return _standardSchema({
  1182. ...schema,
  1183. entries: entries$1
  1184. });
  1185. }
  1186. /* @__NO_SIDE_EFFECTS__ */
  1187. function pipe(...pipe$1) {
  1188. return _standardSchema({
  1189. ...pipe$1[0],
  1190. pipe: pipe$1,
  1191. "~run"(dataset, config$1) {
  1192. for (const item of pipe$1) if (item.kind !== "metadata") {
  1193. if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
  1194. dataset.typed = false;
  1195. break;
  1196. }
  1197. if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
  1198. }
  1199. return dataset;
  1200. }
  1201. });
  1202. }
  1203. /* @__NO_SIDE_EFFECTS__ */
  1204. function pipeAsync(...pipe$1) {
  1205. return _standardSchema({
  1206. ...pipe$1[0],
  1207. pipe: pipe$1,
  1208. async: true,
  1209. async "~run"(dataset, config$1) {
  1210. for (const item of pipe$1) if (item.kind !== "metadata") {
  1211. if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
  1212. dataset.typed = false;
  1213. break;
  1214. }
  1215. if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = await item["~run"](dataset, config$1);
  1216. }
  1217. return dataset;
  1218. }
  1219. });
  1220. }
  1221. /**
  1222. * Parses an unknown input based on a schema.
  1223. *
  1224. * @param schema The schema to be used.
  1225. * @param input The input to be parsed.
  1226. * @param config The parse configuration.
  1227. *
  1228. * @returns The parse result.
  1229. */
  1230. /* @__NO_SIDE_EFFECTS__ */
  1231. function safeParse(schema, input, config$1) {
  1232. const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
  1233. return {
  1234. typed: dataset.typed,
  1235. success: !dataset.issues,
  1236. output: dataset.value,
  1237. issues: dataset.issues
  1238. };
  1239. }
  1240. //#endregion
  1241. //#region src/utils/flatten-valibot-schema.ts
  1242. function unwrapSchema(schema) {
  1243. if (!schema) return schema;
  1244. if (schema.type === "optional" && schema.wrapped) return unwrapSchema(schema.wrapped);
  1245. if (schema.type === "nullable" && schema.wrapped) return unwrapSchema(schema.wrapped);
  1246. if (schema.type === "nullish" && schema.wrapped) return unwrapSchema(schema.wrapped);
  1247. return schema;
  1248. }
  1249. function getValibotSchemaType(schema) {
  1250. if (!schema) return "any";
  1251. if (schema.type) switch (schema.type) {
  1252. case "string": return "string";
  1253. case "number": return "number";
  1254. case "boolean": return "boolean";
  1255. case "array": return "array";
  1256. case "object":
  1257. case "strict_object":
  1258. case "loose_object": return "object";
  1259. case "union": return "union";
  1260. case "literal": return typeof schema.literal;
  1261. case "record": return "object";
  1262. case "optional": return getValibotSchemaType(schema.wrapped);
  1263. case "nullable": return getValibotSchemaType(schema.wrapped);
  1264. case "nullish": return getValibotSchemaType(schema.wrapped);
  1265. case "never": return "never";
  1266. case "any": return "any";
  1267. case "custom": return "any";
  1268. case "function": return "never";
  1269. case "instance": return "object";
  1270. default: return "any";
  1271. }
  1272. return "any";
  1273. }
  1274. function getValibotDescription(schema) {
  1275. if (!schema) return void 0;
  1276. if (schema.pipe && Array.isArray(schema.pipe)) {
  1277. for (const action of schema.pipe) if (action.type === "description" && action.description) return action.description;
  1278. }
  1279. if (schema.type === "optional" && schema.wrapped) return getValibotDescription(schema.wrapped);
  1280. }
  1281. function flattenValibotSchema(schema, result = {}, prefix = "") {
  1282. if (!schema || typeof schema !== "object") return result;
  1283. if (schema.type === "strict_object" || schema.type === "object" || schema.type === "loose_object") {
  1284. if (schema.entries && typeof schema.entries === "object") for (const [key, value] of Object.entries(schema.entries)) {
  1285. const fullKey = prefix ? `${prefix}.${key}` : key;
  1286. const valueSchema = value;
  1287. const type = getValibotSchemaType(valueSchema);
  1288. const description = getValibotDescription(valueSchema);
  1289. if (type === "object") {
  1290. const unwrappedSchema = unwrapSchema(valueSchema);
  1291. if (unwrappedSchema && unwrappedSchema.entries) flattenValibotSchema(unwrappedSchema, result, fullKey);
  1292. else result[fullKey] = {
  1293. type,
  1294. description
  1295. };
  1296. } else result[fullKey] = {
  1297. type,
  1298. description
  1299. };
  1300. }
  1301. }
  1302. return result;
  1303. }
  1304. //#endregion
  1305. //#region src/utils/style-text.ts
  1306. /**
  1307. * Cross-platform styleText utility that works in both Node.js and browser environments
  1308. * In Node.js, it uses the native `styleText` from `node:util`
  1309. * In browser, it provides empty styling functions for compatibility
  1310. */
  1311. function styleText$1(...args) {
  1312. return styleText(...args);
  1313. }
  1314. //#endregion
  1315. //#region src/utils/validator.ts
  1316. const StringOrRegExpSchema = /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ instance(RegExp)]);
  1317. function vFunction() {
  1318. return /* @__PURE__ */ function_();
  1319. }
  1320. const LogLevelSchema = /* @__PURE__ */ union([
  1321. /* @__PURE__ */ literal("debug"),
  1322. /* @__PURE__ */ literal("info"),
  1323. /* @__PURE__ */ literal("warn")
  1324. ]);
  1325. const LogLevelOptionSchema = /* @__PURE__ */ union([LogLevelSchema, /* @__PURE__ */ literal("silent")]);
  1326. const LogLevelWithErrorSchema = /* @__PURE__ */ union([LogLevelSchema, /* @__PURE__ */ literal("error")]);
  1327. const RollupLogSchema = /* @__PURE__ */ any();
  1328. const RollupLogWithStringSchema = /* @__PURE__ */ union([RollupLogSchema, /* @__PURE__ */ string()]);
  1329. const InputOptionSchema = /* @__PURE__ */ union([
  1330. /* @__PURE__ */ string(),
  1331. /* @__PURE__ */ array(/* @__PURE__ */ string()),
  1332. /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string())
  1333. ]);
  1334. const ExternalOptionFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([
  1335. /* @__PURE__ */ string(),
  1336. /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1337. /* @__PURE__ */ boolean()
  1338. ])), /* @__PURE__ */ returns(/* @__PURE__ */ nullish(/* @__PURE__ */ boolean())));
  1339. const ExternalOptionSchema = /* @__PURE__ */ union([
  1340. StringOrRegExpSchema,
  1341. /* @__PURE__ */ array(StringOrRegExpSchema),
  1342. ExternalOptionFunctionSchema
  1343. ]);
  1344. const ModuleTypesSchema = /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([
  1345. /* @__PURE__ */ literal("asset"),
  1346. /* @__PURE__ */ literal("base64"),
  1347. /* @__PURE__ */ literal("binary"),
  1348. /* @__PURE__ */ literal("copy"),
  1349. /* @__PURE__ */ literal("css"),
  1350. /* @__PURE__ */ literal("dataurl"),
  1351. /* @__PURE__ */ literal("empty"),
  1352. /* @__PURE__ */ literal("js"),
  1353. /* @__PURE__ */ literal("json"),
  1354. /* @__PURE__ */ literal("jsx"),
  1355. /* @__PURE__ */ literal("text"),
  1356. /* @__PURE__ */ literal("ts"),
  1357. /* @__PURE__ */ literal("tsx")
  1358. ]));
  1359. const TransformOptionsSchema = /* @__PURE__ */ object({
  1360. assumptions: /* @__PURE__ */ optional(/* @__PURE__ */ object({
  1361. ignoreFunctionLength: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1362. noDocumentAll: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1363. objectRestNoSymbols: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1364. pureGetters: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1365. setPublicClassFields: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1366. })),
  1367. typescript: /* @__PURE__ */ optional(/* @__PURE__ */ object({
  1368. jsxPragma: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1369. jsxPragmaFrag: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1370. onlyRemoveTypeImports: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1371. allowNamespaces: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1372. allowDeclareFields: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1373. removeClassFieldsWithoutInitializer: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1374. optimizeConstEnums: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1375. optimizeEnums: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1376. declaration: /* @__PURE__ */ optional(/* @__PURE__ */ object({
  1377. stripInternal: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1378. sourcemap: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1379. })),
  1380. rewriteImportExtensions: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1381. /* @__PURE__ */ literal("rewrite"),
  1382. /* @__PURE__ */ literal("remove"),
  1383. /* @__PURE__ */ boolean()
  1384. ]))
  1385. })),
  1386. helpers: /* @__PURE__ */ optional(/* @__PURE__ */ object({ mode: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("Runtime"), /* @__PURE__ */ literal("External")])) })),
  1387. decorator: /* @__PURE__ */ optional(/* @__PURE__ */ object({
  1388. legacy: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1389. emitDecoratorMetadata: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1390. strictNullChecks: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1391. })),
  1392. jsx: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1393. /* @__PURE__ */ literal(false),
  1394. /* @__PURE__ */ literal("preserve"),
  1395. /* @__PURE__ */ literal("react"),
  1396. /* @__PURE__ */ literal("react-jsx"),
  1397. /* @__PURE__ */ strictObject({
  1398. runtime: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("classic"), /* @__PURE__ */ literal("automatic")])), /* @__PURE__ */ description("Which runtime to use")),
  1399. development: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Development specific information")),
  1400. throwIfNamespace: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Toggles whether to throw an error when a tag name uses an XML namespace")),
  1401. pure: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Mark JSX elements and top-level React method calls as pure for tree shaking.")),
  1402. importSource: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Import the factory of element and fragment if mode is classic")),
  1403. pragma: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Jsx element transformation")),
  1404. pragmaFrag: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Jsx fragment transformation")),
  1405. refresh: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ any()])), /* @__PURE__ */ description("Enable react fast refresh"))
  1406. })
  1407. ])),
  1408. target: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string())])), /* @__PURE__ */ description("The JavaScript target environment")),
  1409. define: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string())), /* @__PURE__ */ description("Define global variables (syntax: key:value,key2:value2)")),
  1410. inject: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ tuple([/* @__PURE__ */ string(), /* @__PURE__ */ string()])]))), /* @__PURE__ */ description("Inject import statements on demand")),
  1411. dropLabels: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())), /* @__PURE__ */ description("Remove labeled statements with these label names")),
  1412. plugins: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ object({
  1413. styledComponents: /* @__PURE__ */ optional(/* @__PURE__ */ any()),
  1414. taggedTemplateEscape: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1415. })), /* @__PURE__ */ description("Third-party plugins to use"))
  1416. });
  1417. const WatcherFileWatcherOptionsSchema = /* @__PURE__ */ strictObject({
  1418. usePolling: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Use polling-based file watching instead of native OS events")),
  1419. pollInterval: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Poll interval in milliseconds (only used when usePolling is true)")),
  1420. compareContentsForPolling: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Compare file contents for poll-based watchers (only used when usePolling is true)")),
  1421. useDebounce: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Use debounced event delivery at the filesystem level")),
  1422. debounceDelay: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Debounce delay in milliseconds (only used when useDebounce is true)")),
  1423. debounceTickRate: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Tick rate in milliseconds for debouncer (only used when useDebounce is true)"))
  1424. });
  1425. const WatcherOptionsSchema = /* @__PURE__ */ strictObject({
  1426. chokidar: /* @__PURE__ */ optional(/* @__PURE__ */ never(`The "watch.chokidar" option is deprecated, please use "watch.watcher" instead of it`)),
  1427. exclude: /* @__PURE__ */ optional(/* @__PURE__ */ union([StringOrRegExpSchema, /* @__PURE__ */ array(StringOrRegExpSchema)])),
  1428. include: /* @__PURE__ */ optional(/* @__PURE__ */ union([StringOrRegExpSchema, /* @__PURE__ */ array(StringOrRegExpSchema)])),
  1429. watcher: /* @__PURE__ */ optional(WatcherFileWatcherOptionsSchema),
  1430. notify: /* @__PURE__ */ optional(WatcherFileWatcherOptionsSchema),
  1431. skipWrite: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Skip the bundle.write() step")),
  1432. buildDelay: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Throttle watch rebuilds")),
  1433. clearScreen: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to clear the screen when a rebuild is triggered")),
  1434. onInvalidate: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(vFunction()), /* @__PURE__ */ description("An optional function that will be called immediately every time a module changes that is part of the build."))
  1435. });
  1436. const ChecksOptionsSchema = /* @__PURE__ */ strictObject({
  1437. circularDependency: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when detecting circular dependency")),
  1438. eval: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when detecting uses of direct `eval`s")),
  1439. missingGlobalName: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when the `output.globals` option is missing when needed")),
  1440. missingNameOptionForIifeExport: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when the `output.name` option is missing when needed")),
  1441. invalidAnnotation: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a `#__PURE__` / `@__PURE__` annotation has no effect due to its position")),
  1442. mixedExports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when the way to export values is ambiguous")),
  1443. unresolvedEntry: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when an entrypoint cannot be resolved")),
  1444. unresolvedImport: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when an import cannot be resolved")),
  1445. filenameConflict: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when files generated have the same name with different contents")),
  1446. moduleLevelDirective: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings for module-level directives other than `use strict`")),
  1447. commonJsVariableInEsm: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a CommonJS variable is used in an ES module")),
  1448. importIsUndefined: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when an imported variable is not exported")),
  1449. emptyImportMeta: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when `import.meta` is not supported with the output format and is replaced with an empty object (`{}`)")),
  1450. toleratedTransform: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when detecting tolerated transform")),
  1451. cannotCallNamespace: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a namespace is called as a function")),
  1452. configurationFieldConflict: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a config value is overridden by another config value with a higher priority")),
  1453. preferBuiltinFeature: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a plugin that is covered by a built-in feature is used")),
  1454. couldNotCleanDirectory: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when Rolldown could not clean the output directory")),
  1455. bundlerTimings: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when plugins and option callbacks take significant time during the build process")),
  1456. pluginTimings: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Deprecated alias for bundlerTimings. Rolldown uses bundlerTimings if both options have values.")),
  1457. duplicateShebang: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when both the code and postBanner contain shebang")),
  1458. unsupportedTsconfigOption: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a tsconfig option or combination of options is not supported")),
  1459. ineffectiveDynamicImport: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a module is dynamically imported but also statically imported, making the dynamic import ineffective for code splitting")),
  1460. largeBarrelModules: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit info logs when a barrel module has a very large number of re-exports (more than 5000)")),
  1461. sourcemapBroken: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a plugin transforms code without generating a sourcemap")),
  1462. namespaceConflict: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when multiple star re-exports provide the same name from different modules"))
  1463. });
  1464. const MinifyOptionsSchema = /* @__PURE__ */ strictObject({
  1465. compress: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1466. target: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string())])),
  1467. dropConsole: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1468. dropDebugger: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1469. keepNames: /* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1470. function: /* @__PURE__ */ boolean(),
  1471. class: /* @__PURE__ */ boolean()
  1472. })),
  1473. unused: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("keep_assign")])),
  1474. joinVars: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1475. sequences: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1476. dropLabels: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1477. maxIterations: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1478. treeshake: /* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1479. annotations: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1480. manualPureFunctions: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1481. propertyReadSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("always")])),
  1482. propertyWriteSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1483. unknownGlobalSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1484. invalidImportSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1485. }))
  1486. })])),
  1487. mangle: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1488. toplevel: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1489. keepNames: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1490. function: /* @__PURE__ */ boolean(),
  1491. class: /* @__PURE__ */ boolean()
  1492. })])),
  1493. reserved: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1494. debug: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1495. })])),
  1496. mangleProps: /* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1497. include: /* @__PURE__ */ instance(RegExp),
  1498. exclude: /* @__PURE__ */ optional(/* @__PURE__ */ instance(RegExp)),
  1499. reserved: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1500. quoted: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1501. debug: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1502. cache: /* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ literal(false)])))
  1503. })),
  1504. codegen: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1505. removeWhitespace: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1506. asciiOnly: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1507. legalComments: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1508. /* @__PURE__ */ literal("none"),
  1509. /* @__PURE__ */ literal("inline"),
  1510. /* @__PURE__ */ literal("eof"),
  1511. /* @__PURE__ */ literal("external"),
  1512. /* @__PURE__ */ strictObject({ linked: /* @__PURE__ */ string() })
  1513. ]))
  1514. })]))
  1515. });
  1516. const ResolveOptionsSchema = /* @__PURE__ */ strictObject({
  1517. alias: /* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([
  1518. /* @__PURE__ */ literal(false),
  1519. /* @__PURE__ */ string(),
  1520. /* @__PURE__ */ array(/* @__PURE__ */ string())
  1521. ]))),
  1522. aliasFields: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ array(/* @__PURE__ */ string()))),
  1523. conditionNames: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1524. extensionAlias: /* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string()))),
  1525. exportsFields: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ array(/* @__PURE__ */ string()))),
  1526. extensions: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1527. mainFields: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1528. mainFiles: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1529. modules: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1530. symlinks: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1531. tsconfigFilename: /* @__PURE__ */ optional(/* @__PURE__ */ string())
  1532. });
  1533. const TreeshakingOptionsSchema = /* @__PURE__ */ strictObject({
  1534. moduleSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ any()),
  1535. annotations: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1536. manualPureFunctions: /* @__PURE__ */ optional(/* @__PURE__ */ custom((input) => /* @__PURE__ */ is(/* @__PURE__ */ array(/* @__PURE__ */ string()), input), "string array")),
  1537. unknownGlobalSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1538. invalidImportSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1539. commonjs: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1540. propertyReadSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal(false), /* @__PURE__ */ literal("always")])),
  1541. propertyWriteSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal(false), /* @__PURE__ */ literal("always")]))
  1542. });
  1543. const OptimizationOptionsSchema = /* @__PURE__ */ strictObject({
  1544. inlineConst: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1545. mode: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("all"), /* @__PURE__ */ literal("smart")])),
  1546. pass: /* @__PURE__ */ optional(/* @__PURE__ */ number())
  1547. })])), /* @__PURE__ */ description("Enable crossmodule constant inlining")),
  1548. pifeForModuleWrappers: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Use PIFE pattern for module wrappers"))
  1549. });
  1550. const LogOrStringHandlerSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])));
  1551. const OnLogSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([
  1552. LogLevelSchema,
  1553. RollupLogSchema,
  1554. LogOrStringHandlerSchema
  1555. ])));
  1556. const OnwarnSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([RollupLogSchema, /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ union([RollupLogWithStringSchema, /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ returns(RollupLogWithStringSchema))])])))])));
  1557. const DevModeSchema = /* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1558. port: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1559. host: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1560. implement: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1561. skipCommonRuntimeInjection: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1562. lazy: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1563. })]);
  1564. const InputOptionsSchema = /* @__PURE__ */ strictObject({
  1565. input: /* @__PURE__ */ optional(InputOptionSchema),
  1566. plugins: /* @__PURE__ */ optional(/* @__PURE__ */ custom(() => true)),
  1567. external: /* @__PURE__ */ optional(ExternalOptionSchema),
  1568. makeAbsoluteExternalsRelative: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("ifRelativeSource")])),
  1569. resolve: /* @__PURE__ */ optional(ResolveOptionsSchema),
  1570. cwd: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Current working directory")),
  1571. platform: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1572. /* @__PURE__ */ literal("browser"),
  1573. /* @__PURE__ */ literal("neutral"),
  1574. /* @__PURE__ */ literal("node")
  1575. ])), /* @__PURE__ */ description(`Platform for which the code should be generated (node, ${styleText$1("underline", "browser")}, neutral)`)),
  1576. shimMissingExports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Create shim variables for missing exports")),
  1577. treeshake: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), TreeshakingOptionsSchema])),
  1578. optimization: /* @__PURE__ */ optional(OptimizationOptionsSchema),
  1579. logLevel: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(LogLevelOptionSchema), /* @__PURE__ */ description(`Log level (${styleText$1("dim", "silent")}, ${styleText$1(["underline", "gray"], "info")}, debug, ${styleText$1("yellow", "warn")})`)),
  1580. onLog: /* @__PURE__ */ optional(OnLogSchema),
  1581. onwarn: /* @__PURE__ */ optional(OnwarnSchema),
  1582. moduleTypes: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(ModuleTypesSchema), /* @__PURE__ */ description("Module types for customized extensions")),
  1583. experimental: /* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1584. viteMode: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1585. resolveNewUrlToAsset: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1586. devMode: /* @__PURE__ */ optional(DevModeSchema),
  1587. chunkModulesOrder: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("module-id"), /* @__PURE__ */ literal("exec-order")])),
  1588. attachDebugInfo: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1589. /* @__PURE__ */ literal("none"),
  1590. /* @__PURE__ */ literal("simple"),
  1591. /* @__PURE__ */ literal("full")
  1592. ])),
  1593. chunkImportMap: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ object({
  1594. baseUrl: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1595. fileName: /* @__PURE__ */ optional(/* @__PURE__ */ string())
  1596. })])),
  1597. onDemandWrapping: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1598. incrementalBuild: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1599. nativeMagicString: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1600. chunkOptimization: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1601. mergeCommonChunks: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1602. avoidRedundantChunkLoads: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1603. })])),
  1604. lazyBarrel: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1605. })),
  1606. transform: /* @__PURE__ */ optional(TransformOptionsSchema),
  1607. watch: /* @__PURE__ */ optional(/* @__PURE__ */ union([WatcherOptionsSchema, /* @__PURE__ */ literal(false)])),
  1608. checks: /* @__PURE__ */ optional(ChecksOptionsSchema),
  1609. devtools: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ object({ sessionId: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Used to name the build.")) })), /* @__PURE__ */ description("Enable debug mode. Emit debug information to disk. This might slow down the build process significantly.")),
  1610. preserveEntrySignatures: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1611. /* @__PURE__ */ literal("strict"),
  1612. /* @__PURE__ */ literal("allow-extension"),
  1613. /* @__PURE__ */ literal("exports-only"),
  1614. /* @__PURE__ */ literal(false)
  1615. ]))),
  1616. context: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("The value of `this` at the top level of each module.")),
  1617. tsconfig: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ string()])), /* @__PURE__ */ description("Path to the tsconfig.json file."))
  1618. });
  1619. const InputCliOverrideSchema = /* @__PURE__ */ strictObject({
  1620. input: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())), /* @__PURE__ */ description("Entry file")),
  1621. external: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())), /* @__PURE__ */ description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
  1622. treeshake: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("enable treeshaking")),
  1623. makeAbsoluteExternalsRelative: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Prevent normalization of external imports")),
  1624. preserveEntrySignatures: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ literal(false)), /* @__PURE__ */ description("Avoid facade chunks for entry points")),
  1625. context: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("The entity top-level `this` represents."))
  1626. });
  1627. const InputCliOptionsSchema = /* @__PURE__ */ omit(/* @__PURE__ */ strictObject({
  1628. ...InputOptionsSchema.entries,
  1629. ...InputCliOverrideSchema.entries
  1630. }), [
  1631. "plugins",
  1632. "onwarn",
  1633. "onLog",
  1634. "resolve",
  1635. "experimental",
  1636. "watch"
  1637. ]);
  1638. const ModuleFormatSchema = /* @__PURE__ */ union([
  1639. /* @__PURE__ */ literal("es"),
  1640. /* @__PURE__ */ literal("cjs"),
  1641. /* @__PURE__ */ literal("esm"),
  1642. /* @__PURE__ */ literal("module"),
  1643. /* @__PURE__ */ literal("commonjs"),
  1644. /* @__PURE__ */ literal("iife"),
  1645. /* @__PURE__ */ literal("umd")
  1646. ]);
  1647. const AddonFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ custom(() => true)])), /* @__PURE__ */ returnsAsync(/* @__PURE__ */ unionAsync([/* @__PURE__ */ string(), /* @__PURE__ */ pipeAsync(/* @__PURE__ */ promise(), /* @__PURE__ */ awaitAsync(), /* @__PURE__ */ string())])));
  1648. const ChunkFileNamesFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ custom(() => true)])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1649. const ChunkFileNamesSchema = /* @__PURE__ */ union([/* @__PURE__ */ string(), ChunkFileNamesFunctionSchema]);
  1650. const AssetFileNamesFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ custom(() => true)])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1651. const AssetFileNamesSchema = /* @__PURE__ */ union([/* @__PURE__ */ string(), AssetFileNamesFunctionSchema]);
  1652. const SanitizeFileNameFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string()])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1653. const SanitizeFileNameSchema = /* @__PURE__ */ union([/* @__PURE__ */ boolean(), SanitizeFileNameFunctionSchema]);
  1654. const GlobalsFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string()])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1655. const PathsFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string()])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1656. const ManualChunksFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string(), /* @__PURE__ */ object({})])), /* @__PURE__ */ returns(/* @__PURE__ */ nullish(/* @__PURE__ */ string())));
  1657. const AdvancedChunksNameFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string(), /* @__PURE__ */ object({})])), /* @__PURE__ */ returns(/* @__PURE__ */ nullish(/* @__PURE__ */ string())));
  1658. const AdvancedChunksTestFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string()])), /* @__PURE__ */ returns(/* @__PURE__ */ union([
  1659. /* @__PURE__ */ boolean(),
  1660. /* @__PURE__ */ void_(),
  1661. /* @__PURE__ */ undefined_()
  1662. ])));
  1663. const InlineCommonChunksExcludeItemSchema = /* @__PURE__ */ union([StringOrRegExpSchema, AdvancedChunksTestFunctionSchema]);
  1664. const AdvancedChunksSchema = /* @__PURE__ */ strictObject({
  1665. includeDependenciesRecursively: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1666. minSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1667. maxSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1668. minModuleSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1669. maxModuleSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1670. minShareCount: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1671. groups: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ strictObject({
  1672. debugName: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1673. name: /* @__PURE__ */ union([/* @__PURE__ */ string(), AdvancedChunksNameFunctionSchema]),
  1674. test: /* @__PURE__ */ optional(/* @__PURE__ */ union([StringOrRegExpSchema, AdvancedChunksTestFunctionSchema])),
  1675. priority: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1676. minSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1677. minShareCount: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1678. maxSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1679. minModuleSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1680. maxModuleSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1681. entriesAware: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1682. entriesAwareMergeThreshold: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1683. includeDependenciesRecursively: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1684. tags: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string()))
  1685. }))),
  1686. experimentalInlineCommonChunks: /* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1687. maxSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1688. exclude: /* @__PURE__ */ optional(/* @__PURE__ */ union([InlineCommonChunksExcludeItemSchema, /* @__PURE__ */ array(InlineCommonChunksExcludeItemSchema)]))
  1689. }))
  1690. });
  1691. const GeneratedCodeOptionsSchema = /* @__PURE__ */ strictObject({
  1692. symbols: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to use Symbol.toStringTag for namespace objects")),
  1693. preset: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("es5"), /* @__PURE__ */ literal("es2015")])),
  1694. profilerNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to add readable names to internal variables for profiling purposes"))
  1695. });
  1696. const OutputOptionsSchema = /* @__PURE__ */ strictObject({
  1697. dir: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Output directory, defaults to `dist` if `file` is not set")),
  1698. file: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Single output file")),
  1699. exports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1700. /* @__PURE__ */ literal("auto"),
  1701. /* @__PURE__ */ literal("named"),
  1702. /* @__PURE__ */ literal("default"),
  1703. /* @__PURE__ */ literal("none")
  1704. ])), /* @__PURE__ */ description(`Specify a export mode (${styleText$1("underline", "auto")}, named, default, none)`)),
  1705. hashCharacters: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1706. /* @__PURE__ */ literal("base64"),
  1707. /* @__PURE__ */ literal("base36"),
  1708. /* @__PURE__ */ literal("hex")
  1709. ])), /* @__PURE__ */ description("Use the specified character set for file hashes")),
  1710. format: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(ModuleFormatSchema), /* @__PURE__ */ description(`Output format of the generated bundle (supports ${styleText$1("underline", "esm")}, cjs, and iife)`)),
  1711. sourcemap: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1712. /* @__PURE__ */ boolean(),
  1713. /* @__PURE__ */ literal("inline"),
  1714. /* @__PURE__ */ literal("hidden")
  1715. ])), /* @__PURE__ */ description(`Generate sourcemap (\`-s inline\` for inline, or \`-s\` for \`.map\` file)`)),
  1716. sourcemapBaseUrl: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Base URL used to prefix sourcemap paths")),
  1717. sourcemapFileNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(ChunkFileNamesSchema), /* @__PURE__ */ description("Name pattern for emitted sourcemaps")),
  1718. sourcemapDebugIds: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Inject sourcemap debug IDs")),
  1719. sourcemapExcludeSources: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Exclude source content from sourcemaps")),
  1720. sourcemapIgnoreList: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1721. /* @__PURE__ */ boolean(),
  1722. /* @__PURE__ */ custom(() => true),
  1723. StringOrRegExpSchema
  1724. ])),
  1725. sourcemapPathTransform: /* @__PURE__ */ optional(/* @__PURE__ */ custom(() => true)),
  1726. banner: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1727. footer: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1728. postBanner: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1729. postFooter: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1730. intro: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1731. outro: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1732. extend: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Extend global variable defined by name in IIFE / UMD formats")),
  1733. esModule: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("if-default-prop")])),
  1734. assetFileNames: /* @__PURE__ */ optional(AssetFileNamesSchema),
  1735. entryFileNames: /* @__PURE__ */ optional(ChunkFileNamesSchema),
  1736. chunkFileNames: /* @__PURE__ */ optional(ChunkFileNamesSchema),
  1737. sanitizeFileName: /* @__PURE__ */ optional(SanitizeFileNameSchema),
  1738. minify: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1739. /* @__PURE__ */ boolean(),
  1740. /* @__PURE__ */ literal("dce-only"),
  1741. MinifyOptionsSchema
  1742. ])), /* @__PURE__ */ description("Minify the bundled file")),
  1743. name: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Name for UMD / IIFE format outputs")),
  1744. globals: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string()), GlobalsFunctionSchema])), /* @__PURE__ */ description("Global variable of UMD / IIFE dependencies (syntax: `key:value`)")),
  1745. paths: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string()), PathsFunctionSchema])), /* @__PURE__ */ description("Maps external module IDs to paths")),
  1746. generatedCode: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ partial(GeneratedCodeOptionsSchema)), /* @__PURE__ */ description("Generated code options")),
  1747. externalLiveBindings: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("external live bindings")),
  1748. inlineDynamicImports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Inline dynamic imports")),
  1749. dynamicImportInCjs: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Dynamic import in CJS output")),
  1750. manualChunks: /* @__PURE__ */ optional(ManualChunksFunctionSchema),
  1751. codeSplitting: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), AdvancedChunksSchema])),
  1752. advancedChunks: /* @__PURE__ */ optional(AdvancedChunksSchema),
  1753. legalComments: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("none"), /* @__PURE__ */ literal("inline")])), /* @__PURE__ */ description("Control legal comments in the output")),
  1754. comments: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1755. legal: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1756. annotation: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1757. jsdoc: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1758. })])), /* @__PURE__ */ description("Control comments in the output")),
  1759. plugins: /* @__PURE__ */ optional(/* @__PURE__ */ custom(() => true)),
  1760. polyfillRequire: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Disable require polyfill injection")),
  1761. hoistTransitiveImports: /* @__PURE__ */ optional(/* @__PURE__ */ literal(false)),
  1762. preserveModules: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Preserve module structure")),
  1763. preserveModulesRoot: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Put preserved modules under this path at root level")),
  1764. virtualDirname: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1765. minifyInternalExports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Minify internal exports")),
  1766. topLevelVar: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Rewrite top-level declarations to use `var`.")),
  1767. cleanDir: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Clean output directory before emitting output")),
  1768. keepNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Keep function and class names after bundling")),
  1769. strictExecutionOrder: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Preserve source module execution order across generated chunks.")),
  1770. strict: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("auto")])), /* @__PURE__ */ description("Whether to always output `\"use strict\"` directive in non-ES module outputs."))
  1771. });
  1772. const getAddonDescription = (placement, wrapper) => {
  1773. return `Code to insert the ${styleText$1("bold", placement)} of the bundled file (${styleText$1("bold", wrapper)} the wrapper function)`;
  1774. };
  1775. const OutputCliOverrideSchema = /* @__PURE__ */ strictObject({
  1776. assetFileNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Name pattern for asset files")),
  1777. entryFileNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Name pattern for emitted entry chunks")),
  1778. chunkFileNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Name pattern for emitted secondary chunks")),
  1779. sanitizeFileName: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Sanitize file name")),
  1780. banner: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description(getAddonDescription("top", "outside"))),
  1781. footer: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description(getAddonDescription("bottom", "outside"))),
  1782. postBanner: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("A string to prepend to the top of each chunk. Applied after the `renderChunk` hook and minification")),
  1783. postFooter: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("A string to append to the bottom of each chunk. Applied after the `renderChunk` hook and minification")),
  1784. intro: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description(getAddonDescription("top", "inside"))),
  1785. outro: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description(getAddonDescription("bottom", "inside"))),
  1786. esModule: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
  1787. globals: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string())), /* @__PURE__ */ description("Global variable of UMD / IIFE dependencies (syntax: `key:value`)")),
  1788. codeSplitting: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1789. minSize: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Minimum size of the chunk")),
  1790. minShareCount: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Minimum share count of the chunk"))
  1791. })])), /* @__PURE__ */ description("Code splitting options. Enabled by default; use `--no-codeSplitting` to disable, or `--codeSplitting.minSize` / `--codeSplitting.minShareCount` to configure")),
  1792. advancedChunks: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1793. minSize: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Minimum size of the chunk")),
  1794. minShareCount: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Minimum share count of the chunk"))
  1795. })), /* @__PURE__ */ description("Deprecated: use codeSplitting instead")),
  1796. minify: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Minify the bundled file"))
  1797. });
  1798. const OutputCliOptionsSchema = /* @__PURE__ */ omit(/* @__PURE__ */ strictObject({
  1799. ...OutputOptionsSchema.entries,
  1800. ...OutputCliOverrideSchema.entries
  1801. }), [
  1802. "sourcemapIgnoreList",
  1803. "sourcemapPathTransform",
  1804. "plugins",
  1805. "hoistTransitiveImports"
  1806. ]);
  1807. const CliOptionsSchema = /* @__PURE__ */ strictObject({
  1808. config: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ boolean()])), /* @__PURE__ */ description("Path to the config file (default: `rolldown.config.js`)")),
  1809. help: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Show help")),
  1810. environment: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string())])), /* @__PURE__ */ description("Pass additional settings to the config file via process.ENV.")),
  1811. version: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Show version number")),
  1812. watch: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Watch files in bundle and rebuild on changes")),
  1813. configLoader: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("bundle"), /* @__PURE__ */ literal("native")])), /* @__PURE__ */ description("How to load the config file (bundle, native)")),
  1814. ...InputCliOptionsSchema.entries,
  1815. ...OutputCliOptionsSchema.entries
  1816. });
  1817. function validateCliOptions(options) {
  1818. let parsed = /* @__PURE__ */ safeParse(CliOptionsSchema, options);
  1819. return [parsed.output, parsed.issues?.map((issue) => {
  1820. return `Invalid value for option ${issue.path?.map((pathItem) => pathItem.key).join(" ")}: ${issue.message}`;
  1821. })];
  1822. }
  1823. const inputHelperMsgRecord = {
  1824. output: { ignored: true },
  1825. "resolve.tsconfigFilename": { issueMsg: "It is deprecated. Please use the top-level `tsconfig` option instead." }
  1826. };
  1827. const outputHelperMsgRecord = {};
  1828. function validateOption(key, options) {
  1829. if (typeof options !== "object") throw new Error(`Invalid ${key} options. Expected an Object but received ${JSON.stringify(options)}.`);
  1830. if (globalThis.process?.env?.ROLLUP_TEST) return;
  1831. let parsed = /* @__PURE__ */ safeParse(key === "input" ? InputOptionsSchema : OutputOptionsSchema, options);
  1832. if (!parsed.success) {
  1833. const errors = parsed.issues.map((issue) => {
  1834. let issueMsg = issue.message;
  1835. const issuePaths = issue.path.map((path) => path.key);
  1836. if (issue.type === "union") {
  1837. const subIssue = issue.issues?.find((i) => !(i.type !== issue.received && i.input === issue.input));
  1838. if (subIssue) {
  1839. if (subIssue.path) issuePaths.push(subIssue.path.map((path) => path.key));
  1840. issueMsg = subIssue.message;
  1841. }
  1842. }
  1843. const stringPath = issuePaths.join(".");
  1844. const helper = key === "input" ? inputHelperMsgRecord[stringPath] : outputHelperMsgRecord[stringPath];
  1845. if (helper && helper.ignored) return "";
  1846. return `- For the "${stringPath}". ${helper?.issueMsg || issueMsg + "."} ${helper?.help ? `\n Help: ${helper.help}` : ""}`;
  1847. }).filter(Boolean);
  1848. if (errors.length) console.warn(`\x1b[33mWarning: Invalid ${key} options (${errors.length} issue${errors.length === 1 ? "" : "s"} found)\n${errors.join("\n")}\x1b[0m`);
  1849. }
  1850. }
  1851. function getInputCliKeys() {
  1852. return (/* @__PURE__ */ keyof(InputCliOptionsSchema)).options;
  1853. }
  1854. function getOutputCliKeys() {
  1855. return (/* @__PURE__ */ keyof(OutputCliOptionsSchema)).options;
  1856. }
  1857. function getCliSchemaInfo() {
  1858. return flattenValibotSchema(CliOptionsSchema);
  1859. }
  1860. //#endregion
  1861. //#region src/types/chunking-context.ts
  1862. var ChunkingContextImpl = class {
  1863. context;
  1864. pluginContextData;
  1865. moduleInfoCache = /* @__PURE__ */ new Map();
  1866. constructor(context, pluginContextData) {
  1867. this.context = context;
  1868. this.pluginContextData = pluginContextData;
  1869. }
  1870. clearModuleInfoCache() {
  1871. this.moduleInfoCache = void 0;
  1872. }
  1873. getModuleInfo(moduleId) {
  1874. const cached = this.moduleInfoCache?.get(moduleId);
  1875. if (cached) return cached;
  1876. const bindingInfo = this.context.getModuleInfo(moduleId);
  1877. if (bindingInfo) {
  1878. const option = this.pluginContextData.getModuleOption(moduleId);
  1879. const info = transformModuleInfo(bindingInfo, option);
  1880. Object.defineProperty(info, "moduleSideEffects", {
  1881. get: () => option.moduleSideEffects,
  1882. set: (moduleSideEffects) => {
  1883. option.moduleSideEffects = moduleSideEffects;
  1884. option.invalidate = true;
  1885. }
  1886. });
  1887. this.moduleInfoCache?.set(moduleId, info);
  1888. return info;
  1889. }
  1890. return null;
  1891. }
  1892. };
  1893. //#endregion
  1894. //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
  1895. const LogLevels = {
  1896. silent: Number.NEGATIVE_INFINITY,
  1897. fatal: 0,
  1898. error: 0,
  1899. warn: 1,
  1900. log: 2,
  1901. info: 3,
  1902. success: 3,
  1903. fail: 3,
  1904. ready: 3,
  1905. start: 3,
  1906. box: 3,
  1907. debug: 4,
  1908. trace: 5,
  1909. verbose: Number.POSITIVE_INFINITY
  1910. };
  1911. const LogTypes = {
  1912. silent: { level: -1 },
  1913. fatal: { level: LogLevels.fatal },
  1914. error: { level: LogLevels.error },
  1915. warn: { level: LogLevels.warn },
  1916. log: { level: LogLevels.log },
  1917. info: { level: LogLevels.info },
  1918. success: { level: LogLevels.success },
  1919. fail: { level: LogLevels.fail },
  1920. ready: { level: LogLevels.info },
  1921. start: { level: LogLevels.info },
  1922. box: { level: LogLevels.info },
  1923. debug: { level: LogLevels.debug },
  1924. trace: { level: LogLevels.trace },
  1925. verbose: { level: LogLevels.verbose }
  1926. };
  1927. function isPlainObject$1(value) {
  1928. if (value === null || typeof value !== "object") return false;
  1929. const prototype = Object.getPrototypeOf(value);
  1930. if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
  1931. if (Symbol.iterator in value) return false;
  1932. if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
  1933. return true;
  1934. }
  1935. function _defu(baseObject, defaults, namespace = ".", merger) {
  1936. if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
  1937. const object = Object.assign({}, defaults);
  1938. for (const key in baseObject) {
  1939. if (key === "__proto__" || key === "constructor") continue;
  1940. const value = baseObject[key];
  1941. if (value === null || value === void 0) continue;
  1942. if (merger && merger(object, key, value, namespace)) continue;
  1943. if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
  1944. else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
  1945. else object[key] = value;
  1946. }
  1947. return object;
  1948. }
  1949. function createDefu(merger) {
  1950. return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
  1951. }
  1952. const defu = createDefu();
  1953. function isPlainObject(obj) {
  1954. return Object.prototype.toString.call(obj) === "[object Object]";
  1955. }
  1956. function isLogObj(arg) {
  1957. if (!isPlainObject(arg)) return false;
  1958. if (!arg.message && !arg.args) return false;
  1959. if (arg.stack) return false;
  1960. return true;
  1961. }
  1962. let paused = false;
  1963. const queue = [];
  1964. var Consola = class Consola {
  1965. options;
  1966. _lastLog;
  1967. _mockFn;
  1968. /**
  1969. * Creates an instance of Consola with specified options or defaults.
  1970. *
  1971. * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
  1972. */
  1973. constructor(options = {}) {
  1974. const types = options.types || LogTypes;
  1975. this.options = defu({
  1976. ...options,
  1977. defaults: { ...options.defaults },
  1978. level: _normalizeLogLevel(options.level, types),
  1979. reporters: [...options.reporters || []]
  1980. }, {
  1981. types: LogTypes,
  1982. throttle: 1e3,
  1983. throttleMin: 5,
  1984. formatOptions: {
  1985. date: true,
  1986. colors: false,
  1987. compact: true
  1988. }
  1989. });
  1990. for (const type in types) {
  1991. const defaults = {
  1992. type,
  1993. ...this.options.defaults,
  1994. ...types[type]
  1995. };
  1996. this[type] = this._wrapLogFn(defaults);
  1997. this[type].raw = this._wrapLogFn(defaults, true);
  1998. }
  1999. if (this.options.mockFn) this.mockTypes();
  2000. this._lastLog = {};
  2001. }
  2002. /**
  2003. * Gets the current log level of the Consola instance.
  2004. *
  2005. * @returns {number} The current log level.
  2006. */
  2007. get level() {
  2008. return this.options.level;
  2009. }
  2010. /**
  2011. * Sets the minimum log level that will be output by the instance.
  2012. *
  2013. * @param {number} level - The new log level to set.
  2014. */
  2015. set level(level) {
  2016. this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
  2017. }
  2018. /**
  2019. * Displays a prompt to the user and returns the response.
  2020. * Throw an error if `prompt` is not supported by the current configuration.
  2021. *
  2022. * @template T
  2023. * @param {string} message - The message to display in the prompt.
  2024. * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
  2025. * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
  2026. */
  2027. prompt(message, opts) {
  2028. if (!this.options.prompt) throw new Error("prompt is not supported!");
  2029. return this.options.prompt(message, opts);
  2030. }
  2031. /**
  2032. * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
  2033. *
  2034. * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
  2035. * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
  2036. */
  2037. create(options) {
  2038. const instance = new Consola({
  2039. ...this.options,
  2040. ...options
  2041. });
  2042. if (this._mockFn) instance.mockTypes(this._mockFn);
  2043. return instance;
  2044. }
  2045. /**
  2046. * Creates a new Consola instance with the specified default log object properties.
  2047. *
  2048. * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
  2049. * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
  2050. */
  2051. withDefaults(defaults) {
  2052. return this.create({
  2053. ...this.options,
  2054. defaults: {
  2055. ...this.options.defaults,
  2056. ...defaults
  2057. }
  2058. });
  2059. }
  2060. /**
  2061. * Creates a new Consola instance with a specified tag, which will be included in every log.
  2062. *
  2063. * @param {string} tag - The tag to include in each log of the new instance.
  2064. * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
  2065. */
  2066. withTag(tag) {
  2067. return this.withDefaults({ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag });
  2068. }
  2069. /**
  2070. * Adds a custom reporter to the Consola instance.
  2071. * Reporters will be called for each log message, depending on their implementation and log level.
  2072. *
  2073. * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
  2074. * @returns {Consola} The current Consola instance.
  2075. */
  2076. addReporter(reporter) {
  2077. this.options.reporters.push(reporter);
  2078. return this;
  2079. }
  2080. /**
  2081. * Removes a custom reporter from the Consola instance.
  2082. * If no reporter is specified, all reporters will be removed.
  2083. *
  2084. * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
  2085. * @returns {Consola} The current Consola instance.
  2086. */
  2087. removeReporter(reporter) {
  2088. if (reporter) {
  2089. const i = this.options.reporters.indexOf(reporter);
  2090. if (i !== -1) return this.options.reporters.splice(i, 1);
  2091. } else this.options.reporters.splice(0);
  2092. return this;
  2093. }
  2094. /**
  2095. * Replaces all reporters of the Consola instance with the specified array of reporters.
  2096. *
  2097. * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
  2098. * @returns {Consola} The current Consola instance.
  2099. */
  2100. setReporters(reporters) {
  2101. this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
  2102. return this;
  2103. }
  2104. wrapAll() {
  2105. this.wrapConsole();
  2106. this.wrapStd();
  2107. }
  2108. restoreAll() {
  2109. this.restoreConsole();
  2110. this.restoreStd();
  2111. }
  2112. /**
  2113. * Overrides console methods with Consola logging methods for consistent logging.
  2114. */
  2115. wrapConsole() {
  2116. for (const type in this.options.types) {
  2117. if (!console["__" + type]) console["__" + type] = console[type];
  2118. console[type] = this[type].raw;
  2119. }
  2120. }
  2121. /**
  2122. * Restores the original console methods, removing Consola overrides.
  2123. */
  2124. restoreConsole() {
  2125. for (const type in this.options.types) if (console["__" + type]) {
  2126. console[type] = console["__" + type];
  2127. delete console["__" + type];
  2128. }
  2129. }
  2130. /**
  2131. * Overrides standard output and error streams to redirect them through Consola.
  2132. */
  2133. wrapStd() {
  2134. this._wrapStream(this.options.stdout, "log");
  2135. this._wrapStream(this.options.stderr, "log");
  2136. }
  2137. _wrapStream(stream, type) {
  2138. if (!stream) return;
  2139. if (!stream.__write) stream.__write = stream.write;
  2140. stream.write = (data) => {
  2141. this[type].raw(String(data).trim());
  2142. };
  2143. }
  2144. /**
  2145. * Restores the original standard output and error streams, removing the Consola redirection.
  2146. */
  2147. restoreStd() {
  2148. this._restoreStream(this.options.stdout);
  2149. this._restoreStream(this.options.stderr);
  2150. }
  2151. _restoreStream(stream) {
  2152. if (!stream) return;
  2153. if (stream.__write) {
  2154. stream.write = stream.__write;
  2155. delete stream.__write;
  2156. }
  2157. }
  2158. /**
  2159. * Pauses logging, queues incoming logs until resumed.
  2160. */
  2161. pauseLogs() {
  2162. paused = true;
  2163. }
  2164. /**
  2165. * Resumes logging, processing any queued logs.
  2166. */
  2167. resumeLogs() {
  2168. paused = false;
  2169. const _queue = queue.splice(0);
  2170. for (const item of _queue) item[0]._logFn(item[1], item[2]);
  2171. }
  2172. /**
  2173. * Replaces logging methods with mocks if a mock function is provided.
  2174. *
  2175. * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
  2176. */
  2177. mockTypes(mockFn) {
  2178. const _mockFn = mockFn || this.options.mockFn;
  2179. this._mockFn = _mockFn;
  2180. if (typeof _mockFn !== "function") return;
  2181. for (const type in this.options.types) {
  2182. this[type] = _mockFn(type, this.options.types[type]) || this[type];
  2183. this[type].raw = this[type];
  2184. }
  2185. }
  2186. _wrapLogFn(defaults, isRaw) {
  2187. return (...args) => {
  2188. if (paused) {
  2189. queue.push([
  2190. this,
  2191. defaults,
  2192. args,
  2193. isRaw
  2194. ]);
  2195. return;
  2196. }
  2197. return this._logFn(defaults, args, isRaw);
  2198. };
  2199. }
  2200. _logFn(defaults, args, isRaw) {
  2201. if ((defaults.level || 0) > this.level) return false;
  2202. const logObj = {
  2203. date: /* @__PURE__ */ new Date(),
  2204. args: [],
  2205. ...defaults,
  2206. level: _normalizeLogLevel(defaults.level, this.options.types)
  2207. };
  2208. if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
  2209. else logObj.args = [...args];
  2210. if (logObj.message) {
  2211. logObj.args.unshift(logObj.message);
  2212. delete logObj.message;
  2213. }
  2214. if (logObj.additional) {
  2215. if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
  2216. logObj.args.push("\n" + logObj.additional.join("\n"));
  2217. delete logObj.additional;
  2218. }
  2219. logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
  2220. logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
  2221. const resolveLog = (newLog = false) => {
  2222. const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
  2223. if (this._lastLog.object && repeated > 0) {
  2224. const args2 = [...this._lastLog.object.args];
  2225. if (repeated > 1) args2.push(`(repeated ${repeated} times)`);
  2226. this._log({
  2227. ...this._lastLog.object,
  2228. args: args2
  2229. });
  2230. this._lastLog.count = 1;
  2231. }
  2232. if (newLog) {
  2233. this._lastLog.object = logObj;
  2234. this._log(logObj);
  2235. }
  2236. };
  2237. clearTimeout(this._lastLog.timeout);
  2238. const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
  2239. this._lastLog.time = logObj.date;
  2240. if (diffTime < this.options.throttle) try {
  2241. const serializedLog = JSON.stringify([
  2242. logObj.type,
  2243. logObj.tag,
  2244. logObj.args
  2245. ]);
  2246. const isSameLog = this._lastLog.serialized === serializedLog;
  2247. this._lastLog.serialized = serializedLog;
  2248. if (isSameLog) {
  2249. this._lastLog.count = (this._lastLog.count || 0) + 1;
  2250. if (this._lastLog.count > this.options.throttleMin) {
  2251. this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
  2252. return;
  2253. }
  2254. }
  2255. } catch {}
  2256. resolveLog(true);
  2257. }
  2258. _log(logObj) {
  2259. for (const reporter of this.options.reporters) reporter.log(logObj, { options: this.options });
  2260. }
  2261. };
  2262. function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
  2263. if (input === void 0) return defaultLevel;
  2264. if (typeof input === "number") return input;
  2265. if (types[input] && types[input].level !== void 0) return types[input].level;
  2266. return defaultLevel;
  2267. }
  2268. Consola.prototype.add = Consola.prototype.addReporter;
  2269. Consola.prototype.remove = Consola.prototype.removeReporter;
  2270. Consola.prototype.clear = Consola.prototype.removeReporter;
  2271. Consola.prototype.withScope = Consola.prototype.withTag;
  2272. Consola.prototype.mock = Consola.prototype.mockTypes;
  2273. Consola.prototype.pause = Consola.prototype.pauseLogs;
  2274. Consola.prototype.resume = Consola.prototype.resumeLogs;
  2275. function createConsola$1(options = {}) {
  2276. return new Consola(options);
  2277. }
  2278. //#endregion
  2279. //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
  2280. function parseStack(stack, message) {
  2281. const cwd = process.cwd() + sep;
  2282. return stack.split("\n").splice(message.split("\n").length).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
  2283. }
  2284. function writeStream(data, stream) {
  2285. return (stream.__write || stream.write).call(stream, data);
  2286. }
  2287. const bracket = (x) => x ? `[${x}]` : "";
  2288. var BasicReporter = class {
  2289. formatStack(stack, message, opts) {
  2290. const indent = " ".repeat((opts?.errorLevel || 0) + 1);
  2291. return indent + parseStack(stack, message).join(`
  2292. ${indent}`);
  2293. }
  2294. formatError(err, opts) {
  2295. const message = err.message ?? formatWithOptions(opts, err);
  2296. const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
  2297. const level = opts?.errorLevel || 0;
  2298. const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
  2299. const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
  2300. ...opts,
  2301. errorLevel: level + 1
  2302. }) : "";
  2303. return causedPrefix + message + "\n" + stack + causedError;
  2304. }
  2305. formatArgs(args, opts) {
  2306. const _args = args.map((arg) => {
  2307. if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
  2308. return arg;
  2309. });
  2310. return formatWithOptions(opts, ..._args);
  2311. }
  2312. formatDate(date, opts) {
  2313. return opts.date ? date.toLocaleTimeString() : "";
  2314. }
  2315. filterAndJoin(arr) {
  2316. return arr.filter(Boolean).join(" ");
  2317. }
  2318. formatLogObj(logObj, opts) {
  2319. const message = this.formatArgs(logObj.args, opts);
  2320. if (logObj.type === "box") return "\n" + [
  2321. bracket(logObj.tag),
  2322. logObj.title && logObj.title,
  2323. ...message.split("\n")
  2324. ].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
  2325. return this.filterAndJoin([
  2326. bracket(logObj.type),
  2327. bracket(logObj.tag),
  2328. message
  2329. ]);
  2330. }
  2331. log(logObj, ctx) {
  2332. return writeStream(this.formatLogObj(logObj, {
  2333. columns: ctx.options.stdout.columns || 0,
  2334. ...ctx.options.formatOptions
  2335. }) + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
  2336. }
  2337. };
  2338. //#endregion
  2339. //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
  2340. const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
  2341. const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
  2342. const isForced = "FORCE_COLOR" in env || argv.includes("--color");
  2343. const isWindows = platform === "win32";
  2344. const isDumbTerminal = env.TERM === "dumb";
  2345. const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
  2346. const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
  2347. const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
  2348. function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
  2349. return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
  2350. }
  2351. function clearBleed(index, string, open, close, replace) {
  2352. return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
  2353. }
  2354. function filterEmpty(open, close, replace = open, at = open.length + 1) {
  2355. return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
  2356. }
  2357. function init(open, close, replace) {
  2358. return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
  2359. }
  2360. const colorDefs = {
  2361. reset: init(0, 0),
  2362. bold: init(1, 22, "\x1B[22m\x1B[1m"),
  2363. dim: init(2, 22, "\x1B[22m\x1B[2m"),
  2364. italic: init(3, 23),
  2365. underline: init(4, 24),
  2366. inverse: init(7, 27),
  2367. hidden: init(8, 28),
  2368. strikethrough: init(9, 29),
  2369. black: init(30, 39),
  2370. red: init(31, 39),
  2371. green: init(32, 39),
  2372. yellow: init(33, 39),
  2373. blue: init(34, 39),
  2374. magenta: init(35, 39),
  2375. cyan: init(36, 39),
  2376. white: init(37, 39),
  2377. gray: init(90, 39),
  2378. bgBlack: init(40, 49),
  2379. bgRed: init(41, 49),
  2380. bgGreen: init(42, 49),
  2381. bgYellow: init(43, 49),
  2382. bgBlue: init(44, 49),
  2383. bgMagenta: init(45, 49),
  2384. bgCyan: init(46, 49),
  2385. bgWhite: init(47, 49),
  2386. blackBright: init(90, 39),
  2387. redBright: init(91, 39),
  2388. greenBright: init(92, 39),
  2389. yellowBright: init(93, 39),
  2390. blueBright: init(94, 39),
  2391. magentaBright: init(95, 39),
  2392. cyanBright: init(96, 39),
  2393. whiteBright: init(97, 39),
  2394. bgBlackBright: init(100, 49),
  2395. bgRedBright: init(101, 49),
  2396. bgGreenBright: init(102, 49),
  2397. bgYellowBright: init(103, 49),
  2398. bgBlueBright: init(104, 49),
  2399. bgMagentaBright: init(105, 49),
  2400. bgCyanBright: init(106, 49),
  2401. bgWhiteBright: init(107, 49)
  2402. };
  2403. function createColors(useColor = isColorSupported) {
  2404. return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
  2405. }
  2406. const colors = createColors();
  2407. function getColor$1(color, fallback = "reset") {
  2408. return colors[color] || colors[fallback];
  2409. }
  2410. const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
  2411. function stripAnsi$1(text) {
  2412. return text.replace(new RegExp(ansiRegex$1, "g"), "");
  2413. }
  2414. const boxStylePresets = {
  2415. solid: {
  2416. tl: "┌",
  2417. tr: "┐",
  2418. bl: "└",
  2419. br: "┘",
  2420. h: "─",
  2421. v: "│"
  2422. },
  2423. double: {
  2424. tl: "╔",
  2425. tr: "╗",
  2426. bl: "╚",
  2427. br: "╝",
  2428. h: "═",
  2429. v: "║"
  2430. },
  2431. doubleSingle: {
  2432. tl: "╓",
  2433. tr: "╖",
  2434. bl: "╙",
  2435. br: "╜",
  2436. h: "─",
  2437. v: "║"
  2438. },
  2439. doubleSingleRounded: {
  2440. tl: "╭",
  2441. tr: "╮",
  2442. bl: "╰",
  2443. br: "╯",
  2444. h: "─",
  2445. v: "║"
  2446. },
  2447. singleThick: {
  2448. tl: "┏",
  2449. tr: "┓",
  2450. bl: "┗",
  2451. br: "┛",
  2452. h: "━",
  2453. v: "┃"
  2454. },
  2455. singleDouble: {
  2456. tl: "╒",
  2457. tr: "╕",
  2458. bl: "╘",
  2459. br: "╛",
  2460. h: "═",
  2461. v: "│"
  2462. },
  2463. singleDoubleRounded: {
  2464. tl: "╭",
  2465. tr: "╮",
  2466. bl: "╰",
  2467. br: "╯",
  2468. h: "═",
  2469. v: "│"
  2470. },
  2471. rounded: {
  2472. tl: "╭",
  2473. tr: "╮",
  2474. bl: "╰",
  2475. br: "╯",
  2476. h: "─",
  2477. v: "│"
  2478. }
  2479. };
  2480. const defaultStyle = {
  2481. borderColor: "white",
  2482. borderStyle: "rounded",
  2483. valign: "center",
  2484. padding: 2,
  2485. marginLeft: 1,
  2486. marginTop: 1,
  2487. marginBottom: 1
  2488. };
  2489. function box(text, _opts = {}) {
  2490. const opts = {
  2491. ..._opts,
  2492. style: {
  2493. ...defaultStyle,
  2494. ..._opts.style
  2495. }
  2496. };
  2497. const textLines = text.split("\n");
  2498. const boxLines = [];
  2499. const _color = getColor$1(opts.style.borderColor);
  2500. const borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
  2501. if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
  2502. const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
  2503. const height = textLines.length + paddingOffset;
  2504. const width = Math.max(...textLines.map((line) => stripAnsi$1(line).length), opts.title ? stripAnsi$1(opts.title).length : 0) + paddingOffset;
  2505. const widthOffset = width + paddingOffset;
  2506. const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
  2507. if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
  2508. if (opts.title) {
  2509. const title = _color ? _color(opts.title) : opts.title;
  2510. const left = borderStyle.h.repeat(Math.floor((width - stripAnsi$1(opts.title).length) / 2));
  2511. const right = borderStyle.h.repeat(width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset);
  2512. boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
  2513. } else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
  2514. const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
  2515. for (let i = 0; i < height; i++) if (i < valignOffset || i >= valignOffset + textLines.length) boxLines.push(`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`);
  2516. else {
  2517. const line = textLines[i - valignOffset];
  2518. const left = " ".repeat(paddingOffset);
  2519. const right = " ".repeat(width - stripAnsi$1(line).length);
  2520. boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
  2521. }
  2522. boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
  2523. if (opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
  2524. return boxLines.join("\n");
  2525. }
  2526. //#endregion
  2527. //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
  2528. const r = Object.create(null);
  2529. const i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis);
  2530. const o = new Proxy(r, {
  2531. get(e, s) {
  2532. return i()[s] ?? r[s];
  2533. },
  2534. has(e, s) {
  2535. return s in i() || s in r;
  2536. },
  2537. set(e, s, E) {
  2538. const B = i(true);
  2539. return B[s] = E, true;
  2540. },
  2541. deleteProperty(e, s) {
  2542. if (!s) return false;
  2543. const E = i(true);
  2544. return delete E[s], true;
  2545. },
  2546. ownKeys() {
  2547. const e = i(true);
  2548. return Object.keys(e);
  2549. }
  2550. });
  2551. const t = typeof process < "u" && process.env && process.env.NODE_ENV || "";
  2552. const f = [
  2553. ["APPVEYOR"],
  2554. [
  2555. "AWS_AMPLIFY",
  2556. "AWS_APP_ID",
  2557. { ci: true }
  2558. ],
  2559. ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
  2560. ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
  2561. ["APPCIRCLE", "AC_APPCIRCLE"],
  2562. ["BAMBOO", "bamboo_planKey"],
  2563. ["BITBUCKET", "BITBUCKET_COMMIT"],
  2564. ["BITRISE", "BITRISE_IO"],
  2565. ["BUDDY", "BUDDY_WORKSPACE_ID"],
  2566. ["BUILDKITE"],
  2567. ["CIRCLE", "CIRCLECI"],
  2568. ["CIRRUS", "CIRRUS_CI"],
  2569. [
  2570. "CLOUDFLARE_PAGES",
  2571. "CF_PAGES",
  2572. { ci: true }
  2573. ],
  2574. ["CODEBUILD", "CODEBUILD_BUILD_ARN"],
  2575. ["CODEFRESH", "CF_BUILD_ID"],
  2576. ["DRONE"],
  2577. ["DRONE", "DRONE_BUILD_EVENT"],
  2578. ["DSARI"],
  2579. ["GITHUB_ACTIONS"],
  2580. ["GITLAB", "GITLAB_CI"],
  2581. ["GITLAB", "CI_MERGE_REQUEST_ID"],
  2582. ["GOCD", "GO_PIPELINE_LABEL"],
  2583. ["LAYERCI"],
  2584. ["HUDSON", "HUDSON_URL"],
  2585. ["JENKINS", "JENKINS_URL"],
  2586. ["MAGNUM"],
  2587. ["NETLIFY"],
  2588. [
  2589. "NETLIFY",
  2590. "NETLIFY_LOCAL",
  2591. { ci: false }
  2592. ],
  2593. ["NEVERCODE"],
  2594. ["RENDER"],
  2595. ["SAIL", "SAILCI"],
  2596. ["SEMAPHORE"],
  2597. ["SCREWDRIVER"],
  2598. ["SHIPPABLE"],
  2599. ["SOLANO", "TDDIUM"],
  2600. ["STRIDER"],
  2601. ["TEAMCITY", "TEAMCITY_VERSION"],
  2602. ["TRAVIS"],
  2603. ["VERCEL", "NOW_BUILDER"],
  2604. [
  2605. "VERCEL",
  2606. "VERCEL",
  2607. { ci: false }
  2608. ],
  2609. [
  2610. "VERCEL",
  2611. "VERCEL_ENV",
  2612. { ci: false }
  2613. ],
  2614. ["APPCENTER", "APPCENTER_BUILD_ID"],
  2615. [
  2616. "CODESANDBOX",
  2617. "CODESANDBOX_SSE",
  2618. { ci: false }
  2619. ],
  2620. [
  2621. "CODESANDBOX",
  2622. "CODESANDBOX_HOST",
  2623. { ci: false }
  2624. ],
  2625. ["STACKBLITZ"],
  2626. ["STORMKIT"],
  2627. ["CLEAVR"],
  2628. ["ZEABUR"],
  2629. [
  2630. "CODESPHERE",
  2631. "CODESPHERE_APP_ID",
  2632. { ci: true }
  2633. ],
  2634. ["RAILWAY", "RAILWAY_PROJECT_ID"],
  2635. ["RAILWAY", "RAILWAY_SERVICE_ID"],
  2636. ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
  2637. [
  2638. "FIREBASE_APP_HOSTING",
  2639. "FIREBASE_APP_HOSTING",
  2640. { ci: true }
  2641. ]
  2642. ];
  2643. function b() {
  2644. if (globalThis.process?.env) for (const e of f) {
  2645. const s = e[1] || e[0];
  2646. if (globalThis.process?.env[s]) return {
  2647. name: e[0].toLowerCase(),
  2648. ...e[2]
  2649. };
  2650. }
  2651. return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
  2652. name: "stackblitz",
  2653. ci: false
  2654. } : {
  2655. name: "",
  2656. ci: false
  2657. };
  2658. }
  2659. const l = b();
  2660. l.name;
  2661. function n(e) {
  2662. return e ? e !== "false" : false;
  2663. }
  2664. const I = globalThis.process?.platform || "";
  2665. const T = n(o.CI) || l.ci !== false;
  2666. const a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY);
  2667. const g = n(o.DEBUG);
  2668. const R = t === "test" || n(o.TEST);
  2669. o.MINIMAL;
  2670. const A = /^win/i.test(I);
  2671. !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM);
  2672. const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
  2673. Number(C?.split(".")[0]);
  2674. const y = globalThis.process || Object.create(null);
  2675. const _ = { versions: {} };
  2676. new Proxy(y, { get(e, s) {
  2677. if (s === "env") return o;
  2678. if (s in e) return e[s];
  2679. if (s in _) return _[s];
  2680. } });
  2681. const c = globalThis.process?.release?.name === "node";
  2682. const O = !!globalThis.Bun || !!globalThis.process?.versions?.bun;
  2683. const D = !!globalThis.Deno;
  2684. const L = !!globalThis.fastly;
  2685. const S = !!globalThis.Netlify;
  2686. const u = !!globalThis.EdgeRuntime;
  2687. const N = globalThis.navigator?.userAgent === "Cloudflare-Workers";
  2688. const F = [
  2689. [S, "netlify"],
  2690. [u, "edge-light"],
  2691. [N, "workerd"],
  2692. [L, "fastly"],
  2693. [D, "deno"],
  2694. [O, "bun"],
  2695. [c, "node"]
  2696. ];
  2697. function G() {
  2698. const e = F.find((s) => s[0]);
  2699. if (e) return { name: e[1] };
  2700. }
  2701. G()?.name;
  2702. function ansiRegex({ onlyFirst = false } = {}) {
  2703. const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
  2704. return new RegExp(pattern, onlyFirst ? void 0 : "g");
  2705. }
  2706. const regex = ansiRegex();
  2707. function stripAnsi(string) {
  2708. if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
  2709. return string.replace(regex, "");
  2710. }
  2711. function isAmbiguous(x) {
  2712. return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
  2713. }
  2714. function isFullWidth(x) {
  2715. return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
  2716. }
  2717. function isWide(x) {
  2718. return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
  2719. }
  2720. function validate(codePoint) {
  2721. if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
  2722. }
  2723. function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
  2724. validate(codePoint);
  2725. if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
  2726. return 1;
  2727. }
  2728. const emojiRegex = () => {
  2729. return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
  2730. };
  2731. const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
  2732. const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
  2733. function stringWidth$1(string, options = {}) {
  2734. if (typeof string !== "string" || string.length === 0) return 0;
  2735. const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
  2736. if (!countAnsiEscapeCodes) string = stripAnsi(string);
  2737. if (string.length === 0) return 0;
  2738. let width = 0;
  2739. const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
  2740. for (const { segment: character } of segmenter.segment(string)) {
  2741. const codePoint = character.codePointAt(0);
  2742. if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
  2743. if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
  2744. if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
  2745. if (codePoint >= 55296 && codePoint <= 57343) continue;
  2746. if (codePoint >= 65024 && codePoint <= 65039) continue;
  2747. if (defaultIgnorableCodePointRegex.test(character)) continue;
  2748. if (emojiRegex().test(character)) {
  2749. width += 2;
  2750. continue;
  2751. }
  2752. width += eastAsianWidth(codePoint, eastAsianWidthOptions);
  2753. }
  2754. return width;
  2755. }
  2756. function isUnicodeSupported() {
  2757. const { env } = g$1;
  2758. const { TERM, TERM_PROGRAM } = env;
  2759. if (g$1.platform !== "win32") return TERM !== "linux";
  2760. return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
  2761. }
  2762. const TYPE_COLOR_MAP = {
  2763. info: "cyan",
  2764. fail: "red",
  2765. success: "green",
  2766. ready: "green",
  2767. start: "magenta"
  2768. };
  2769. const LEVEL_COLOR_MAP = {
  2770. 0: "red",
  2771. 1: "yellow"
  2772. };
  2773. const unicode = isUnicodeSupported();
  2774. const s = (c, fallback) => unicode ? c : fallback;
  2775. const TYPE_ICONS = {
  2776. error: s("✖", "×"),
  2777. fatal: s("✖", "×"),
  2778. ready: s("✔", "√"),
  2779. warn: s("⚠", "‼"),
  2780. info: s("ℹ", "i"),
  2781. success: s("✔", "√"),
  2782. debug: s("⚙", "D"),
  2783. trace: s("→", "→"),
  2784. fail: s("✖", "×"),
  2785. start: s("◐", "o"),
  2786. log: ""
  2787. };
  2788. function stringWidth(str) {
  2789. if (!(typeof Intl === "object") || !Intl.Segmenter) return stripAnsi$1(str).length;
  2790. return stringWidth$1(str);
  2791. }
  2792. var FancyReporter = class extends BasicReporter {
  2793. formatStack(stack, message, opts) {
  2794. const indent = " ".repeat((opts?.errorLevel || 0) + 1);
  2795. return `
  2796. ${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)).join(`
  2797. ${indent}`);
  2798. }
  2799. formatType(logObj, isBadge, opts) {
  2800. const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
  2801. if (isBadge) return getBgColor(typeColor)(colors.black(` ${logObj.type.toUpperCase()} `));
  2802. const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
  2803. return _type ? getColor(typeColor)(_type) : "";
  2804. }
  2805. formatLogObj(logObj, opts) {
  2806. const [message, ...additional] = this.formatArgs(logObj.args, opts).split("\n");
  2807. if (logObj.type === "box") return box(characterFormat(message + (additional.length > 0 ? "\n" + additional.join("\n") : "")), {
  2808. title: logObj.title ? characterFormat(logObj.title) : void 0,
  2809. style: logObj.style
  2810. });
  2811. const date = this.formatDate(logObj.date, opts);
  2812. const coloredDate = date && colors.gray(date);
  2813. const isBadge = logObj.badge ?? logObj.level < 2;
  2814. const type = this.formatType(logObj, isBadge, opts);
  2815. const tag = logObj.tag ? colors.gray(logObj.tag) : "";
  2816. let line;
  2817. const left = this.filterAndJoin([type, characterFormat(message)]);
  2818. const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
  2819. const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
  2820. line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
  2821. line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
  2822. if (logObj.type === "trace") {
  2823. const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
  2824. line += this.formatStack(_err.stack || "", _err.message);
  2825. }
  2826. return isBadge ? "\n" + line + "\n" : line;
  2827. }
  2828. };
  2829. function characterFormat(str) {
  2830. return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
  2831. }
  2832. function getColor(color = "white") {
  2833. return colors[color] || colors.white;
  2834. }
  2835. function getBgColor(color = "bgWhite") {
  2836. return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
  2837. }
  2838. function createConsola(options = {}) {
  2839. let level = _getDefaultLogLevel();
  2840. if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
  2841. return createConsola$1({
  2842. level,
  2843. defaults: { level },
  2844. stdout: process.stdout,
  2845. stderr: process.stderr,
  2846. prompt: (...args) => import("./prompt-CH6TK0bC.mjs").then((m) => m.prompt(...args)),
  2847. reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
  2848. ...options
  2849. });
  2850. }
  2851. function _getDefaultLogLevel() {
  2852. if (g) return LogLevels.debug;
  2853. if (R) return LogLevels.warn;
  2854. return LogLevels.info;
  2855. }
  2856. createConsola();
  2857. //#endregion
  2858. //#region src/cli/logger.ts
  2859. /**
  2860. * Console logger
  2861. */
  2862. const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
  2863. function createTestingLogger() {
  2864. const types = [
  2865. "silent",
  2866. "fatal",
  2867. "error",
  2868. "warn",
  2869. "log",
  2870. "info",
  2871. "success",
  2872. "fail",
  2873. "ready",
  2874. "start",
  2875. "box",
  2876. "debug",
  2877. "trace",
  2878. "verbose"
  2879. ];
  2880. const ret = Object.create(null);
  2881. for (const type of types) ret[type] = (...args) => console.log(...args);
  2882. return ret;
  2883. }
  2884. //#endregion
  2885. //#region src/utils/bindingify-output-options.ts
  2886. function bindingifyOutputOptions(outputOptions, pluginContextData, onLog, timings) {
  2887. const { dir, format, exports, hashCharacters, sourcemap, sourcemapBaseUrl, sourcemapDebugIds, sourcemapFileNames, sourcemapExcludeSources, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, banner, footer, postBanner, postFooter, intro, outro, esModule, globals, paths, generatedCode, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, comments, preserveModulesRoot, manualChunks, topLevelVar, cleanDir, strictExecutionOrder } = outputOptions;
  2888. if (legalComments != null) logger.warn("`legalComments` option is deprecated, please use `comments.legal` instead.");
  2889. const { inlineDynamicImports, advancedChunks } = bindingifyCodeSplitting(outputOptions.codeSplitting, outputOptions.inlineDynamicImports, outputOptions.advancedChunks, manualChunks, pluginContextData, onLog, timings);
  2890. return {
  2891. dir,
  2892. file: file == null ? void 0 : file,
  2893. format: bindingifyFormat(format),
  2894. exports,
  2895. hashCharacters,
  2896. sourcemap: bindingifySourcemap(sourcemap),
  2897. sourcemapBaseUrl,
  2898. sourcemapDebugIds,
  2899. sourcemapFileNames: measureIfFunction(timings, OUTPUT_OPTIONS_OWNER, "sourcemapFileNames", sourcemapFileNames),
  2900. sourcemapExcludeSources,
  2901. sourcemapIgnoreList: batchSourcemapIgnoreList(measureIfFunction(timings, OUTPUT_OPTIONS_OWNER, "sourcemapIgnoreList", sourcemapIgnoreList ?? /node_modules/)),
  2902. sourcemapPathTransform: batchSourcemapPathTransform(measureIfFunction(timings, OUTPUT_OPTIONS_OWNER, "sourcemapPathTransform", sourcemapPathTransform)),
  2903. banner: bindingifyAddon(banner, "banner", timings),
  2904. footer: bindingifyAddon(footer, "footer", timings),
  2905. postBanner: bindingifyAddon(postBanner, "postBanner", timings),
  2906. postFooter: bindingifyAddon(postFooter, "postFooter", timings),
  2907. intro: bindingifyAddon(intro, "intro", timings),
  2908. outro: bindingifyAddon(outro, "outro", timings),
  2909. extend: outputOptions.extend,
  2910. globals: measureIfFunction(timings, OUTPUT_OPTIONS_OWNER, "globals", globals),
  2911. paths: measureIfFunction(timings, OUTPUT_OPTIONS_OWNER, "paths", paths),
  2912. generatedCode,
  2913. esModule,
  2914. name,
  2915. assetFileNames: bindingifyAssetFilenames(assetFileNames),
  2916. entryFileNames: measureIfFunction(timings, OUTPUT_OPTIONS_OWNER, "entryFileNames", entryFileNames),
  2917. chunkFileNames: measureIfFunction(timings, OUTPUT_OPTIONS_OWNER, "chunkFileNames", chunkFileNames),
  2918. plugins: [],
  2919. minify: outputOptions.minify,
  2920. externalLiveBindings: outputOptions.externalLiveBindings,
  2921. inlineDynamicImports,
  2922. dynamicImportInCjs: outputOptions.dynamicImportInCjs,
  2923. manualCodeSplitting: advancedChunks,
  2924. polyfillRequire: outputOptions.polyfillRequire,
  2925. sanitizeFileName,
  2926. preserveModules,
  2927. virtualDirname,
  2928. legalComments,
  2929. comments: bindingifyComments(comments),
  2930. preserveModulesRoot,
  2931. topLevelVar,
  2932. minifyInternalExports: outputOptions.minifyInternalExports,
  2933. cleanDir,
  2934. strictExecutionOrder,
  2935. strict: outputOptions.strict
  2936. };
  2937. }
  2938. function bindingifyAddon(configAddon, name, timings) {
  2939. if (configAddon == null || configAddon === "") return;
  2940. if (typeof configAddon === "function") {
  2941. const measured = measureHookCost(timings, OUTPUT_OPTIONS_OWNER, name, configAddon);
  2942. return async (chunk) => measured(transformRenderedChunk(chunk));
  2943. }
  2944. return configAddon;
  2945. }
  2946. function bindingifyFormat(format) {
  2947. switch (format) {
  2948. case void 0:
  2949. case "es":
  2950. case "esm":
  2951. case "module": return "es";
  2952. case "cjs":
  2953. case "commonjs": return "cjs";
  2954. case "iife": return "iife";
  2955. case "umd": return "umd";
  2956. default: unimplemented(`output.format: ${format}`);
  2957. }
  2958. }
  2959. function bindingifySourcemap(sourcemap) {
  2960. switch (sourcemap) {
  2961. case true: return "file";
  2962. case "inline": return "inline";
  2963. case false:
  2964. case void 0: return;
  2965. case "hidden": return "hidden";
  2966. default: throw new Error(`unknown sourcemap: ${sourcemap}`);
  2967. }
  2968. }
  2969. function bindingifyAssetFilenames(assetFileNames) {
  2970. if (typeof assetFileNames === "function") return (asset) => {
  2971. return assetFileNames({
  2972. name: asset.name,
  2973. names: asset.names,
  2974. originalFileName: asset.originalFileName,
  2975. originalFileNames: asset.originalFileNames,
  2976. source: transformAssetSource(asset.source),
  2977. type: "asset"
  2978. });
  2979. };
  2980. return assetFileNames;
  2981. }
  2982. function bindingifyComments(comments) {
  2983. if (comments == null) return;
  2984. if (typeof comments === "boolean") return comments;
  2985. return comments;
  2986. }
  2987. function bindingifyCodeSplitting(codeSplitting, inlineDynamicImportsOption, advancedChunks, manualChunks, pluginContextData, onLog, timings) {
  2988. let inlineDynamicImports;
  2989. let effectiveChunksOption;
  2990. let migratedManualChunksGroup;
  2991. let chunksOptionName = "codeSplitting";
  2992. if (codeSplitting === false) {
  2993. if (inlineDynamicImportsOption != null) logger.warn("`inlineDynamicImports` option is ignored because `codeSplitting: false` is set.");
  2994. if (manualChunks != null) throw new Error("Invalid configuration: \"output.manualChunks\" cannot be used when \"output.codeSplitting\" is set to false.");
  2995. if (advancedChunks != null) logger.warn("`advancedChunks` option is ignored because `codeSplitting` is set to `false`.");
  2996. return {
  2997. inlineDynamicImports: true,
  2998. advancedChunks: void 0
  2999. };
  3000. } else if (codeSplitting === true) {
  3001. if (inlineDynamicImportsOption != null) logger.warn("`inlineDynamicImports` option is ignored because `codeSplitting: true` is set.");
  3002. } else if (codeSplitting == null) {
  3003. if (inlineDynamicImportsOption != null) {
  3004. logger.warn("`inlineDynamicImports` option is deprecated, please use `codeSplitting: false` instead.");
  3005. inlineDynamicImports = inlineDynamicImportsOption;
  3006. }
  3007. } else {
  3008. effectiveChunksOption = codeSplitting;
  3009. chunksOptionName = "codeSplitting";
  3010. if (inlineDynamicImportsOption != null) logger.warn("`inlineDynamicImports` option is ignored because the `codeSplitting` option is specified.");
  3011. }
  3012. if (inlineDynamicImports === true && manualChunks != null) throw new Error("Invalid value \"true\" for option \"output.inlineDynamicImports\" - this option is not supported for \"output.manualChunks\".");
  3013. if (effectiveChunksOption == null) {
  3014. if (advancedChunks != null) {
  3015. logger.warn("`advancedChunks` option is deprecated, please use `codeSplitting` instead.");
  3016. effectiveChunksOption = advancedChunks;
  3017. chunksOptionName = "advancedChunks";
  3018. }
  3019. } else if (advancedChunks != null) logger.warn("`advancedChunks` option is ignored because the `codeSplitting` option is specified.");
  3020. if (manualChunks != null && effectiveChunksOption != null) logger.warn("`manualChunks` option is ignored because the `codeSplitting` option is specified.");
  3021. else if (manualChunks != null) {
  3022. chunksOptionName = "manualChunks";
  3023. migratedManualChunksGroup = { name(moduleId, ctx) {
  3024. return manualChunks(moduleId, { getModuleInfo: (id) => ctx.getModuleInfo(id) });
  3025. } };
  3026. effectiveChunksOption = { groups: [migratedManualChunksGroup] };
  3027. }
  3028. if (inlineDynamicImports === true && effectiveChunksOption != null) {
  3029. logger.warn("`advancedChunks` option is ignored because `inlineDynamicImports: true` disables code splitting.");
  3030. effectiveChunksOption = void 0;
  3031. }
  3032. let advancedChunksResult;
  3033. if (effectiveChunksOption != null) {
  3034. const { groups, experimentalInlineCommonChunks, ...restOptions } = effectiveChunksOption;
  3035. let chunkingContext;
  3036. const getChunkingContext = (bindingContext) => chunkingContext ??= new ChunkingContextImpl(bindingContext, pluginContextData);
  3037. advancedChunksResult = {
  3038. ...restOptions,
  3039. experimentalInlineCommonChunks: experimentalInlineCommonChunks == null ? void 0 : {
  3040. maxSize: experimentalInlineCommonChunks.maxSize,
  3041. exclude: experimentalInlineCommonChunks.exclude == null ? void 0 : arraify(experimentalInlineCommonChunks.exclude).map((matcher) => typeof matcher === "function" ? batchTest(measureHookCost(timings, OUTPUT_OPTIONS_OWNER, "codeSplitting.experimentalInlineCommonChunks.exclude", matcher), "output.codeSplitting.experimentalInlineCommonChunks.exclude") : matcher)
  3042. },
  3043. internalInvalidateModuleInfoCache: () => {
  3044. chunkingContext?.clearModuleInfoCache();
  3045. chunkingContext = void 0;
  3046. },
  3047. groups: groups?.map((group, index) => {
  3048. const { debugName, name, test, ...restGroup } = group;
  3049. const timingKey = group === migratedManualChunksGroup ? manualChunks ?? group : group;
  3050. const timingOwner = timings === void 0 ? OUTPUT_OPTIONS_OWNER : {
  3051. ...OUTPUT_OPTIONS_OWNER,
  3052. key: timingKey
  3053. };
  3054. const groupName = `${chunksOptionName} groups[${index}]`;
  3055. let testTimingName = `${groupName}.test`;
  3056. let nameTimingName = `${groupName}.name`;
  3057. if (timings !== void 0) {
  3058. if (chunksOptionName === "manualChunks") nameTimingName = "manualChunks";
  3059. else {
  3060. const label = debugName ?? (typeof name === "string" ? name : void 0);
  3061. if (label === void 0) {
  3062. if (typeof name === "function" && !timings.warnedMissingGroupLabels.has(timingKey)) {
  3063. timings.warnedMissingGroupLabels.add(timingKey);
  3064. onLog(LOG_LEVEL_WARN, logMissingCodeSplittingGroupDebugName(`output.${chunksOptionName}.groups[${index}]`));
  3065. }
  3066. } else {
  3067. const labelSuffix = ` ${JSON.stringify(label)}`;
  3068. testTimingName = `${groupName}.test${labelSuffix}`;
  3069. nameTimingName = `${groupName}.name${labelSuffix}`;
  3070. }
  3071. }
  3072. }
  3073. return {
  3074. ...restGroup,
  3075. test: typeof test === "function" ? batchTest(measureHookCost(timings, timingOwner, testTimingName, test)) : test,
  3076. name: typeof name === "function" ? batchName(measureHookCost(timings, timingOwner, nameTimingName, name), getChunkingContext) : name
  3077. };
  3078. })
  3079. };
  3080. }
  3081. return {
  3082. inlineDynamicImports,
  3083. advancedChunks: advancedChunksResult
  3084. };
  3085. }
  3086. /**
  3087. * Wraps a per-id `test` in the batched shim that the binding expects.
  3088. *
  3089. * The loop runs in JS so that a group makes one napi crossing, not one per module.
  3090. *
  3091. * The result is a `Uint8Array`, which crosses as a buffer instead of one tagged value per id.
  3092. */
  3093. function batchTest(test, optionName = "output.codeSplitting.groups[].test") {
  3094. return (ids) => {
  3095. const results = new Uint8Array(ids.length);
  3096. for (let index = 0; index < ids.length; index++) {
  3097. const result = test(ids[index]);
  3098. if (result != null && typeof result !== "boolean") throw new TypeError(`\`${optionName}\` returned ${typeof result} for module "${ids[index]}", but expected a boolean, null or undefined.`);
  3099. results[index] = result === true ? 1 : 0;
  3100. }
  3101. return results;
  3102. };
  3103. }
  3104. /**
  3105. * This is the `name` equivalent of {@linkcode batchTest}. All groups in a chunking pass share
  3106. * a context so repeated module queries reuse their JavaScript values.
  3107. */
  3108. function batchName(name, getChunkingContext) {
  3109. return (ids, bindingContext) => {
  3110. const context = getChunkingContext(bindingContext);
  3111. const results = [];
  3112. for (let index = 0; index < ids.length; index++) {
  3113. const result = name(ids[index], context);
  3114. if (result != null && typeof result !== "string") throw new TypeError(`\`output.codeSplitting.groups[].name\` returned ${typeof result} for module "${ids[index]}", but expected a string, null or undefined.`);
  3115. results.push(result);
  3116. }
  3117. return results;
  3118. };
  3119. }
  3120. /**
  3121. * Wraps a per-source `sourcemapIgnoreList` in the batched shim that the binding expects.
  3122. *
  3123. * The loop runs in JS so that a sourcemap makes one napi crossing, not one per source. The old
  3124. * Rust loop also awaited each call before it started the next.
  3125. *
  3126. * The result is a `Uint8Array`, which crosses as a buffer instead of one tagged value per source.
  3127. *
  3128. * A boolean, string or regular expression passes through. Rust reads those without a call.
  3129. */
  3130. function batchSourcemapIgnoreList(ignoreList) {
  3131. if (typeof ignoreList !== "function") return ignoreList;
  3132. return (sources, sourcemapPath) => {
  3133. const results = new Uint8Array(sources.length);
  3134. for (let index = 0; index < sources.length; index++) {
  3135. const result = ignoreList(sources[index], sourcemapPath);
  3136. if (typeof result !== "boolean") throw new TypeError(`\`output.sourcemapIgnoreList\` returned ${typeof result} for source "${sources[index]}", but expected a boolean.`);
  3137. results[index] = result ? 1 : 0;
  3138. }
  3139. return results;
  3140. };
  3141. }
  3142. /**
  3143. * The `sourcemapPathTransform` counterpart of {@linkcode batchSourcemapIgnoreList}.
  3144. *
  3145. * A path cannot be reduced to a byte, so this batch is still an array of strings. napi reports the
  3146. * type of the array, not of the bad element, so the check runs here.
  3147. */
  3148. function batchSourcemapPathTransform(pathTransform) {
  3149. if (typeof pathTransform !== "function") return pathTransform;
  3150. return (sources, sourcemapPath) => {
  3151. const results = [];
  3152. for (let index = 0; index < sources.length; index++) {
  3153. const result = pathTransform(sources[index], sourcemapPath);
  3154. if (typeof result !== "string") throw new TypeError(`\`output.sourcemapPathTransform\` returned ${typeof result} for source "${sources[index]}", but expected a string.`);
  3155. results.push(result);
  3156. }
  3157. return results;
  3158. };
  3159. }
  3160. //#endregion
  3161. //#region src/utils/initialize-parallel-plugins.ts
  3162. var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
  3163. async function initializeParallelPlugins(plugins) {
  3164. const pluginInfos = [];
  3165. for (const [index, plugin] of plugins.entries()) {
  3166. const parallel = getParallelPluginInfo(plugin);
  3167. if (parallel) {
  3168. const { fileUrl, options } = parallel;
  3169. pluginInfos.push({
  3170. index,
  3171. fileUrl,
  3172. options
  3173. });
  3174. }
  3175. }
  3176. if (pluginInfos.length <= 0) return;
  3177. const count = availableParallelism();
  3178. const parallelJsPluginRegistry = new import_binding.ParallelJsPluginRegistry(count);
  3179. const registryId = parallelJsPluginRegistry.id;
  3180. const workers = await initializeWorkers(registryId, count, pluginInfos);
  3181. const stopWorkers = async () => {
  3182. await Promise.all(workers.map((worker) => worker.terminate()));
  3183. };
  3184. return {
  3185. registry: parallelJsPluginRegistry,
  3186. stopWorkers
  3187. };
  3188. }
  3189. function initializeWorkers(registryId, count, pluginInfos) {
  3190. return Promise.all(Array.from({ length: count }, (_, i) => initializeWorker(registryId, pluginInfos, i)));
  3191. }
  3192. async function initializeWorker(registryId, pluginInfos, threadNumber) {
  3193. const urlString = import.meta.resolve("#parallel-plugin-worker");
  3194. const workerData = {
  3195. registryId,
  3196. pluginInfos,
  3197. threadNumber
  3198. };
  3199. let worker;
  3200. try {
  3201. worker = new Worker(new URL(urlString), { workerData });
  3202. worker.unref();
  3203. await new Promise((resolve, reject) => {
  3204. worker.once("message", async (message) => {
  3205. if (message.type === "error") reject(message.error);
  3206. else resolve();
  3207. });
  3208. });
  3209. return worker;
  3210. } catch (e) {
  3211. worker?.terminate();
  3212. throw e;
  3213. }
  3214. }
  3215. const availableParallelism = () => {
  3216. let availableParallelism = 1;
  3217. try {
  3218. availableParallelism = os.availableParallelism();
  3219. } catch {
  3220. const cpus = os.cpus();
  3221. if (Array.isArray(cpus) && cpus.length > 0) availableParallelism = cpus.length;
  3222. }
  3223. return Math.min(availableParallelism, 8);
  3224. };
  3225. //#endregion
  3226. //#region src/utils/create-bundler-option.ts
  3227. async function createBundlerOptions(inputOptions, outputOptions, watchMode, measureTimings = false) {
  3228. const inputPlugins = await normalizePluginOption(inputOptions.plugins);
  3229. const outputPlugins = await normalizePluginOption(outputOptions.plugins);
  3230. const logLevel = inputOptions.logLevel || "info";
  3231. const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel, watchMode);
  3232. outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
  3233. const hookOutputPlugins = await normalizePluginOption(outputOptions.plugins);
  3234. const normalizedInputPlugins = normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX);
  3235. const normalizedOutputPlugins = normalizePlugins(hookOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX);
  3236. let plugins = [...normalizedInputPlugins, ...checkOutputPluginOption(normalizedOutputPlugins, onLog)];
  3237. const timings = measureTimings && (inputOptions.checks?.bundlerTimings ?? inputOptions.checks?.pluginTimings ?? true) ? pluginTimingsRecorderFor(inputOptions) : void 0;
  3238. if (timings) outputOptions = {
  3239. ...outputOptions,
  3240. assetFileNames: measureIfFunction(timings, OUTPUT_OPTIONS_OWNER, "assetFileNames", outputOptions.assetFileNames),
  3241. sanitizeFileName: measureIfFunction(timings, OUTPUT_OPTIONS_OWNER, "sanitizeFileName", outputOptions.sanitizeFileName)
  3242. };
  3243. const parallelPluginInitResult = await initializeParallelPlugins(plugins);
  3244. if (inputOptions.experimental?.strictExecutionOrder !== void 0) console.warn("`experimental.strictExecutionOrder` has been stabilized and moved to `output.strictExecutionOrder`. Please update your configuration.");
  3245. try {
  3246. const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedInputPlugins, normalizedOutputPlugins);
  3247. return {
  3248. bundlerOptions: {
  3249. inputOptions: bindingifyInputOptions(plugins, inputOptions, outputOptions, pluginContextData, normalizedOutputPlugins, onLog, logLevel, watchMode, timings),
  3250. outputOptions: bindingifyOutputOptions(outputOptions, pluginContextData, onLog, timings),
  3251. parallelPluginsRegistry: parallelPluginInitResult?.registry
  3252. },
  3253. inputOptions,
  3254. onLog,
  3255. stopWorkers: parallelPluginInitResult?.stopWorkers
  3256. };
  3257. } catch (e) {
  3258. await parallelPluginInitResult?.stopWorkers();
  3259. throw e;
  3260. }
  3261. }
  3262. //#endregion
  3263. export { getOutputCliKeys as a, styleText$1 as c, getInputCliKeys as i, PluginDriver as l, logger as n, validateCliOptions as o, getCliSchemaInfo as r, validateOption as s, createBundlerOptions as t };