@briklab/lib 1.0.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -142,10 +142,10 @@ declare class UtilitiesClass {
142
142
  addTag(name: string, config?: Partial<(typeof this.tags)["error"]>): this;
143
143
  /** Set style for a tag */
144
144
  setTagStyle(tagName: string, style: InlineStyle): this;
145
- log(tagName: string, message: string): void;
146
- error(msg: string): this;
147
- warning(msg: string): this;
148
- info(msg: string): this;
145
+ log(tagName: string, ...messages: any[]): void;
146
+ error(...msg: any[]): this;
147
+ warning(...msg: any[]): this;
148
+ info(...msg: any[]): this;
149
149
  }
150
150
  export declare const Utilities: UtilitiesClass;
151
151
  export {};
@@ -1,449 +1,52 @@
1
- /**
2
- * @packageDocumentation
3
- *
4
- * # CLI John
5
- *
6
- * **CLI John** is a **Node.js CLI framework** designed to create **fully functional CLIs** quickly.
7
- * It hooks into a given NodeJS process, automatically listens for commands, parses arguments,
8
- * and allows beautiful console messages. Its design is **modular**, using Commands and Options as sub-classes.
9
- *
10
- * ## Features
11
- * - Auto-listening to commands
12
- * - Command parsing
13
- * - Beautiful console messages
14
- * - One CLI per file
15
- * - Add your file to `bin` in package.json → CLI works seamlessly
16
- * - Event-driven command handling
17
- *
18
- * ## Usage
19
- * ```ts
20
- * import { CLI as CLI } from "@briklab/lib/cli-john"
21
- * import * as process from "node:process"
22
- *
23
- * const cli = new CLI(process);
24
- *
25
- * const cmd = cli.command("myCommand");
26
- * const opt = cmd.option("force");
27
- *
28
- * cmd.on("run", ({commandArgs}) => {
29
- * CJ.notice("Hey, this is my CLI!");
30
- * CJ.message("Do you like it?");
31
- * CJ.error("Invalid args:", ...commandArgs.map(a => a.name));
32
- * });
33
- *
34
- * cli.run();
35
- * ```
36
- *
37
- * ## Limitations
38
- * - Only **one CLI per file** is allowed (CLI enforces this)
39
- * - CLI file must be manually added to `bin` in package.json
40
- *
41
- * ## Hierarchy
42
- * ```
43
- * CLI
44
- * ├─ Command
45
- * │ └─ Option
46
- * └─ CLIErrors
47
- * ```
48
- *
49
- * ## Error Handling
50
- * - All errors are instances of `CLIErrors`
51
- * - Dynamic names allow easy identification of which part of the CLI threw the error
52
- *
53
- * @module cli-john
54
- */
55
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
56
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
57
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
58
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
59
- };
60
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
61
- if (kind === "m") throw new TypeError("Private method is not writable");
62
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
63
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
64
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
65
- };
66
- var _CLI_instances, _CLI_commands, _CLI_onCmdFunctions, _CLI_figureOutCommand, _CLI_process, _CLI_ErrorClass, _CLI_createErr, _CLI_createWarn;
67
- // -------------------------------------------------------------------------------------------------------
68
- //#region Defination of custom JSTC handler
69
- import JSTC from "../jstc/index.js";
70
- import InlineStyle, { StyleSheet } from "../stylesheet/index.js";
71
- JSTC.addCustomHandler("NodeJS Process", (p) => {
72
- return (p &&
73
- typeof p === "object" &&
74
- typeof p.pid === "number" &&
75
- typeof p.cwd === "function" &&
76
- typeof p.exit === "function");
77
- });
78
- //#endregion
79
- // -------------------------------------------------------------------------------------------------------
80
- //#region The Main Class
81
- /**
82
- * # CLI
83
- * @classdesc The main class for **CLI**.
84
- * @example
85
- * import * as process from "node:process"
86
- * import {CLI} from "@briklab/lib/cli-john"
87
- * const cli = new CLI(process)
88
- * cli.run()
89
- */
90
- export class CLI {
91
- /**
92
- * ## CLI: Constructor
93
- * @param {NodeJS.Process} process - **The main process**
94
- * @constructor
95
- * @constructs CLI
96
- * @example
97
- * import * as process from "node:process"
98
- * import {CLI} from "@briklab/lib/cli-john"
99
- * const cli = new CLI(process)
100
- * cli.run()
101
- */
102
- constructor(process) {
103
- _CLI_instances.add(this);
104
- _CLI_commands.set(this, []);
105
- _CLI_onCmdFunctions.set(this, []);
106
- _CLI_process.set(this, void 0);
107
- _CLI_ErrorClass.set(this, class extends CLIErrors {
108
- constructor(message) {
109
- super(message);
110
- this.setName = "CLI";
111
- }
112
- });
113
- if (!JSTC.for([process]).check(["NodeJS Process"])) {
114
- throw __classPrivateFieldGet(this, _CLI_instances, "m", _CLI_createErr).call(this, "Invalid First Argument!", "You must pass a valid NodeJS process (imported from node:process) while constructing a CLI Class!");
115
- }
116
- __classPrivateFieldSet(this, _CLI_process, process, "f");
117
- }
118
- /**
119
- * ### CLI.command
120
- * create a new command in a CLI.
121
- *
122
- * @param {string} name
123
- */
124
- command(name) {
125
- if (!JSTC.for([name]).check(["string"])) {
126
- __classPrivateFieldGet(this, _CLI_instances, "m", _CLI_createWarn).call(this, "Invalid First Argument!", "CLI.option expects a string as the first argument.", "Using String(given argument) as fallback.");
127
- name = String(name);
128
- }
129
- let c = new CLI.Command(name);
130
- let f = __classPrivateFieldGet(this, _CLI_commands, "f").findIndex((a) => a.name === name);
131
- if (f !== -1)
132
- __classPrivateFieldGet(this, _CLI_commands, "f")[f] = c;
133
- else
134
- __classPrivateFieldGet(this, _CLI_commands, "f").push(c);
135
- return c;
136
- }
137
- on(event, func) {
138
- if (!JSTC.for([event, func]).check(["string", "function"]))
139
- throw __classPrivateFieldGet(this, _CLI_instances, "m", _CLI_createErr).call(this, "Arguments in CLI.on are invalid!", "The first argument must be a string, and the second argument must be a function.");
140
- switch (event.toLowerCase()) {
141
- case "command":
142
- __classPrivateFieldGet(this, _CLI_onCmdFunctions, "f").push(func);
143
- break;
144
- default:
145
- __classPrivateFieldGet(this, _CLI_instances, "m", _CLI_createWarn).call(this, "Invalid event in CLI.on", "Please enter a valid event from CLI.ValidEvents (array)");
146
- }
147
- }
148
- run() {
149
- let { options, commandArgs, command, failed } = __classPrivateFieldGet(this, _CLI_instances, "m", _CLI_figureOutCommand).call(this);
150
- if (failed)
151
- return;
152
- for (let i = 0; i < __classPrivateFieldGet(this, _CLI_onCmdFunctions, "f").length; i++) {
153
- __classPrivateFieldGet(this, _CLI_onCmdFunctions, "f")[i]({ options, commandArgs, command });
154
- }
155
- }
156
- }
157
- _CLI_commands = new WeakMap(), _CLI_onCmdFunctions = new WeakMap(), _CLI_process = new WeakMap(), _CLI_ErrorClass = new WeakMap(), _CLI_instances = new WeakSet(), _CLI_figureOutCommand = function _CLI_figureOutCommand() {
158
- // for eg. we have nodepath filepath cli build
159
- let [, , ...commands] = __classPrivateFieldGet(this, _CLI_process, "f").argv; // now its cli build. clear
160
- if (commands.length === 0)
161
- return { options: [], command: "", commandArgs: [], failed: true };
162
- let command = __classPrivateFieldGet(this, _CLI_commands, "f").find((a) => a.name === commands[0]); // find the command
163
- if (!command)
164
- return { options: [], command: "", commandArgs: [], failed: true }; // command not found?
165
- let commandArgs = [];
166
- const args = commands.slice(1);
167
- for (let i = 0; i < args.length; i++) {
168
- let arg = args[i];
169
- if (arg.startsWith("--"))
170
- break;
171
- commandArgs.push(arg);
172
- }
173
- let leftover = args.slice(commandArgs.length); // args = [1,2,3]; command args = [1,2] command args length is 2, therefore .slice(2) results in [3]
174
- let options = [];
175
- for (let i = 0; i < leftover.length; i++) {
176
- const opt = leftover[i];
177
- if (!opt.startsWith("--"))
178
- continue;
179
- const values = [];
180
- for (let j = i + 1; j < leftover.length; j++) {
181
- if (leftover[j].startsWith("--"))
182
- break;
183
- values.push(leftover[j]);
184
- }
185
- options.push({ option: opt, arguments: values });
186
- }
187
- return {
188
- options,
189
- commandArgs,
190
- command,
191
- failed: false,
192
- };
193
- }, _CLI_createErr = function _CLI_createErr(message, hint) {
194
- return new (__classPrivateFieldGet(this, _CLI_ErrorClass, "f"))(`${message}
195
- Hint: ${hint}`);
196
- }, _CLI_createWarn = function _CLI_createWarn(message, hint, otherMessage) {
197
- return console.warn(`[Class CLI] ${message}
198
- Hint: ${hint}
199
- ${otherMessage}`);
200
- };
201
- //#endregion
202
- // -------------------------------------------------------------------------------------------------------
203
- //#region Error Class
204
- class CLIErrors extends Error {
205
- constructor(message) {
206
- super(message);
207
- this.name = `[] @briklab/lib/cli-john`;
208
- Error.captureStackTrace(this, CLIErrors);
209
- }
210
- set setName(name) {
211
- this.name = `[${name}] @briklab/lib/cli-john`;
212
- }
213
- }
214
- (function (CLI) {
215
- var _Command_instances, _Command_name, _Command_createWarn, _Command_options;
216
- CLI.ValidEvents = ["command"];
217
- /**
218
- * ## CLI.Command
219
- * A command in a CLI Command
220
- */
221
- class Command {
222
- /**
223
- * ### Command Constructor
224
- * @param name The name of the command
225
- * @constructor
226
- */
227
- constructor(name) {
228
- _Command_instances.add(this);
229
- _Command_name.set(this, void 0);
230
- _Command_options.set(this, []);
231
- __classPrivateFieldSet(this, _Command_name, name, "f");
232
- return this;
233
- }
234
- /**
235
- * The name of the Command
236
- * @returns {string}
237
- */
238
- get name() {
239
- return __classPrivateFieldGet(this, _Command_name, "f");
240
- }
241
- /**
242
- * the metadata of the Command
243
- * @returns {object}
244
- */
245
- get metadata() {
246
- let metadata = {
247
- options: __classPrivateFieldGet(this, _Command_options, "f").map((a) => a.metadata),
248
- name: this.name,
249
- };
250
- return metadata;
251
- }
252
- option(name) {
253
- if (!JSTC.for([name]).check(["string"])) {
254
- __classPrivateFieldGet(this, _Command_instances, "m", _Command_createWarn).call(this, "First argument is invalid!", "The first argument must be a string", "Using String(argument) as fallback");
255
- name = String(name);
256
- }
257
- let o = new CLI.Command.Option(name);
258
- let f = __classPrivateFieldGet(this, _Command_options, "f").findIndex((a) => a.name === name);
259
- if (f !== -1)
260
- __classPrivateFieldGet(this, _Command_options, "f")[f] = o;
261
- else
262
- __classPrivateFieldGet(this, _Command_options, "f").push(o);
263
- return o;
264
- }
265
- }
266
- _Command_name = new WeakMap(), _Command_options = new WeakMap(), _Command_instances = new WeakSet(), _Command_createWarn = function _Command_createWarn(message, hint, otherMessage) {
267
- return console.warn(`[Class CLI.Command] ${message}
268
- Hint: ${hint}
269
- ${otherMessage}`);
270
- };
271
- CLI.Command = Command;
272
- })(CLI || (CLI = {}));
273
- //#endregion
274
- // -------------------------------------------------------------------------------------------------------
275
- //#region CLI.Command.Option
276
- (function (CLI) {
277
- var Command;
278
- (function (Command) {
279
- var _Option_name;
280
- /**
281
- * ## CLI.Command.Option
282
- * A option for a CLI.Command
283
- */
284
- class Option {
285
- get metadata() {
286
- let metadata = {
287
- name: `${__classPrivateFieldGet(this, _Option_name, "f")}`, // <-- Templates TO NOT reference the actual variable
288
- };
289
- return metadata;
290
- }
291
- constructor(name) {
292
- _Option_name.set(this, void 0);
293
- __classPrivateFieldSet(this, _Option_name, name, "f");
294
- return this;
295
- }
296
- get name() {
297
- return __classPrivateFieldGet(this, _Option_name, "f");
298
- }
299
- }
300
- _Option_name = new WeakMap();
301
- Command.Option = Option;
302
- })(Command = CLI.Command || (CLI.Command = {}));
303
- })(CLI || (CLI = {}));
304
- //#endregion
305
- // -------------------------------------------------------------------------------------------------------
306
- //#region CLI Utilities
307
- JSTC.addCustomHandler("Utilities Tag Config", (p) => {
308
- return (p &&
309
- typeof p === "object" &&
310
- typeof p.tag === "string" &&
311
- typeof p.showErrorInTag === "boolean" &&
312
- typeof p.paddingLeft === "number" &&
313
- typeof p.paddingRight === "number" &&
314
- (typeof p.styleName === "string" || p.styleName === undefined));
315
- });
316
- class UtilitiesClass {
317
- constructor() {
318
- this.styleSheet = new StyleSheet();
319
- this.tags = {};
320
- this.addTag("error", {
321
- tag: "ERROR",
322
- showErrorInTag: false,
323
- paddingLeft: 1,
324
- paddingRight: 1,
325
- });
326
- this.addTag("warning", {
327
- tag: "WARNING",
328
- showErrorInTag: true,
329
- paddingLeft: 1,
330
- paddingRight: 1,
331
- });
332
- this.addTag("info", {
333
- tag: "INFO",
334
- showErrorInTag: true,
335
- paddingLeft: 1,
336
- paddingRight: 1,
337
- });
338
- this.setTagStyle("error", new InlineStyle({ color: "red", fontWeight: "bold" }));
339
- this.setTagStyle("warning", new InlineStyle({ color: "orange", fontWeight: "bold" }));
340
- this.setTagStyle("info", new InlineStyle({ color: "blue" }));
341
- }
342
- /** Add a new tag */
343
- addTag(name, config = {}) {
344
- if (!JSTC.for([name, config]).check(["string", "object"])) {
345
- console.warn(`[UtilitiesClass.addTag] @briklab/lib/cli-john: Invalid Arguments!
346
- Hint: The first argument must be a string, and the second argument must be a object.
347
- Using String(argument1) and {} as fallback.`);
348
- name = String(name);
349
- config = {};
350
- }
351
- const fullConfig = {
352
- tag: name.toUpperCase(),
353
- showErrorInTag: false,
354
- paddingLeft: 0,
355
- paddingRight: 0,
356
- styleName: "",
357
- ...config,
358
- };
359
- if (!JSTC.for([fullConfig]).check(["Utilities Tag Config"])) {
360
- console.warn(`[UtilitiesClass.addTag] @briklab/lib/cli-john: Invalid tag config passed for "${name}"
361
- Hint: The config must be in format {tag?: string, showErrorInTag?:boolean, paddingLeft?:number, paddingRight?:number, styleName?:string}`);
362
- console.warn(fullConfig);
363
- return this;
364
- }
365
- this.tags[name] = fullConfig;
366
- return this;
367
- }
368
- /** Set style for a tag */
369
- setTagStyle(tagName, style) {
370
- if (typeof tagName !== "string" || !(style instanceof InlineStyle)) {
371
- console.warn(`[UtilitiesClass.setTagStyle] @briklab/lib/cli-john: Invalid arguments!
372
- Hint: The first argument must be a string and the second argument must be a instance of InlineStyle
373
- Using String(firstArgument) and new InlineStyle({}) as fallback`);
374
- tagName = String(tagName);
375
- style = new InlineStyle({});
376
- }
377
- if (!this.tags[tagName]) {
378
- console.warn(`[UtilitiesClass.setTagStyle] @briklab/lib/cli-john: Tag "${tagName}" does not exist!
379
- Hint: Use a valid tag that you have defined or use "error"|"warn"|"info"`);
380
- return this;
381
- }
382
- const styleName = `${tagName} Tag Color`;
383
- this.styleSheet.set(styleName, style);
384
- this.tags[tagName].styleName = styleName;
385
- return this;
386
- }
387
- log(tagName, message) {
388
- if (!JSTC.for([tagName, message]).check(["string", "string"])) {
389
- console.warn(`[UtilitiesClass.log] @briklab/lib/cli-john: Invalid Arguments!
390
- Hint: The first argument must be a string and the second argument must be a string
391
- Using String(argument1) and String(argument2) as fallback`);
392
- tagName = String(tagName);
393
- message = String(message);
394
- }
395
- const tag = this.tags[tagName];
396
- if (!tag) {
397
- console.warn(`[UtilitiesClass.log] @briklab/lib/cli-john: Tag "${tagName}" does not exist!
398
- Hint: Use a valid tag that you have defined or use "error"|"warn"|"info"`);
399
- console.log(message);
400
- return;
401
- }
402
- const style = this.styleSheet.get(tag.styleName)?.text ?? "";
403
- const leftPad = " ".repeat(tag.paddingLeft);
404
- const rightPad = " ".repeat(tag.paddingRight);
405
- if (tag.showErrorInTag) {
406
- console.log(`[%c${leftPad}${tag.tag}${rightPad}%c]: ${message}`, style);
407
- }
408
- else {
409
- console.log(`%c[${leftPad}${tag.tag}${rightPad}]%c: ${message}`, style);
410
- }
411
- }
412
- error(msg) {
413
- if (typeof msg !== "string") {
414
- console.warn(`[UtilitiesClass.error] Invalid First Argument!
415
- Hint: The first argument must be a string.
416
- Using String(firstArgument) as fallback`);
417
- msg = String(msg);
418
- }
419
- this.log("error", msg);
420
- return this;
421
- }
422
- warning(msg) {
423
- if (typeof msg !== "string") {
424
- console.warn(`[UtilitiesClass.warning] Invalid First Argument!
425
- Hint: The first argument must be a string.
426
- Using String(firstArgument) as fallback`);
427
- msg = String(msg);
428
- }
429
- this.log("warning", msg);
430
- return this;
431
- }
432
- info(msg) {
433
- if (typeof msg !== "string") {
434
- console.warn(`[UtilitiesClass.info] Invalid First Argument!
435
- Hint: The first argument must be a string.
436
- Using String(firstArgument) as fallback`);
437
- msg = String(msg);
438
- }
439
- this.log("info", msg);
440
- return this;
441
- }
442
- }
443
- export const Utilities = new UtilitiesClass();
444
- //#endregion
445
- // -------------------------------------------------------------------------------------------------------
446
- //#region TODO
447
- // TODO: Wire Options to Commands
448
- // TODO: Create metadata getter-s in both commands and options
449
- //#endregion
1
+ var Lt=Object.create;var rt=Object.defineProperty;var qt=Object.getOwnPropertyDescriptor;var Pt=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,Ft=Object.prototype.hasOwnProperty;var h=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Ht=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Pt(e))!Ft.call(i,n)&&n!==t&&rt(i,n,{get:()=>e[n],enumerable:!(r=qt(e,n))||r.enumerable});return i};var Ut=(i,e,t)=>(t=i!=null?Lt(At(i)):{},Ht(e||!i||!i.__esModule?rt(t,"default",{value:i,enumerable:!0}):t,i));var Le=h(st=>{var it={};it.StyleSheet=function(){this.parentStyleSheet=null};st.StyleSheet=it.StyleSheet});var m=h(nt=>{var d={};d.CSSRule=function(){this.parentRule=null,this.parentStyleSheet=null};d.CSSRule.UNKNOWN_RULE=0;d.CSSRule.STYLE_RULE=1;d.CSSRule.CHARSET_RULE=2;d.CSSRule.IMPORT_RULE=3;d.CSSRule.MEDIA_RULE=4;d.CSSRule.FONT_FACE_RULE=5;d.CSSRule.PAGE_RULE=6;d.CSSRule.KEYFRAMES_RULE=7;d.CSSRule.KEYFRAME_RULE=8;d.CSSRule.MARGIN_RULE=9;d.CSSRule.NAMESPACE_RULE=10;d.CSSRule.COUNTER_STYLE_RULE=11;d.CSSRule.SUPPORTS_RULE=12;d.CSSRule.DOCUMENT_RULE=13;d.CSSRule.FONT_FEATURE_VALUES_RULE=14;d.CSSRule.VIEWPORT_RULE=15;d.CSSRule.REGION_STYLE_RULE=16;d.CSSRule.prototype={constructor:d.CSSRule};nt.CSSRule=d.CSSRule});var ne=h(ot=>{var b={CSSStyleDeclaration:j().CSSStyleDeclaration,CSSRule:m().CSSRule};b.CSSStyleRule=function(){b.CSSRule.call(this),this.selectorText="",this.style=new b.CSSStyleDeclaration,this.style.parentRule=this};b.CSSStyleRule.prototype=new b.CSSRule;b.CSSStyleRule.prototype.constructor=b.CSSStyleRule;b.CSSStyleRule.prototype.type=1;Object.defineProperty(b.CSSStyleRule.prototype,"cssText",{get:function(){var i;return this.selectorText?i=this.selectorText+" {"+this.style.cssText+"}":i="",i},set:function(i){var e=b.CSSStyleRule.parse(i);this.style=e.style,this.selectorText=e.selectorText}});b.CSSStyleRule.parse=function(i){for(var e=0,t="selector",r,n=e,s="",o={selector:!0,value:!0},l=new b.CSSStyleRule,u,S="",a;a=i.charAt(e);e++)switch(a){case" ":case" ":case"\r":case`
2
+ `:case"\f":if(o[t])switch(i.charAt(e-1)){case" ":case" ":case"\r":case`
3
+ `:case"\f":break;default:s+=" ";break}break;case'"':if(n=e+1,r=i.indexOf('"',n)+1,!r)throw'" is missing';s+=i.slice(e,r),e=r-1;break;case"'":if(n=e+1,r=i.indexOf("'",n)+1,!r)throw"' is missing";s+=i.slice(e,r),e=r-1;break;case"/":if(i.charAt(e+1)==="*"){if(e+=2,r=i.indexOf("*/",e),r===-1)throw new SyntaxError("Missing */");e=r+1}else s+=a;break;case"{":t==="selector"&&(l.selectorText=s.trim(),s="",t="name");break;case":":t==="name"?(u=s.trim(),s="",t="value"):s+=a;break;case"!":t==="value"&&i.indexOf("!important",e)===e?(S="important",e+=9):s+=a;break;case";":t==="value"?(l.style.setProperty(u,s.trim(),S),S="",s="",t="name"):s+=a;break;case"}":if(t==="value")l.style.setProperty(u,s.trim(),S),S="",s="";else{if(t==="name")break;s+=a}t="selector";break;default:s+=a;break}return l};ot.CSSStyleRule=b.CSSStyleRule});var oe=h(lt=>{var w={StyleSheet:Le().StyleSheet,CSSStyleRule:ne().CSSStyleRule};w.CSSStyleSheet=function(){w.StyleSheet.call(this),this.cssRules=[]};w.CSSStyleSheet.prototype=new w.StyleSheet;w.CSSStyleSheet.prototype.constructor=w.CSSStyleSheet;w.CSSStyleSheet.prototype.insertRule=function(i,e){if(e<0||e>this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");var t=w.parse(i).cssRules[0];return t.parentStyleSheet=this,this.cssRules.splice(e,0,t),e};w.CSSStyleSheet.prototype.deleteRule=function(i){if(i<0||i>=this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");this.cssRules.splice(i,1)};w.CSSStyleSheet.prototype.toString=function(){for(var i="",e=this.cssRules,t=0;t<e.length;t++)i+=e[t].cssText+`
4
+ `;return i};lt.CSSStyleSheet=w.CSSStyleSheet;w.parse=he().parse});var pe=h(at=>{var fe={};fe.MediaList=function(){this.length=0};fe.MediaList.prototype={constructor:fe.MediaList,get mediaText(){return Array.prototype.join.call(this,", ")},set mediaText(i){for(var e=i.split(","),t=this.length=e.length,r=0;r<t;r++)this[r]=e[r].trim()},appendMedium:function(i){Array.prototype.indexOf.call(this,i)===-1&&(this[this.length]=i,this.length++)},deleteMedium:function(i){var e=Array.prototype.indexOf.call(this,i);e!==-1&&Array.prototype.splice.call(this,e,1)}};at.MediaList=fe.MediaList});var qe=h(ut=>{var T={CSSRule:m().CSSRule,CSSStyleSheet:oe().CSSStyleSheet,MediaList:pe().MediaList};T.CSSImportRule=function(){T.CSSRule.call(this),this.href="",this.media=new T.MediaList,this.styleSheet=new T.CSSStyleSheet};T.CSSImportRule.prototype=new T.CSSRule;T.CSSImportRule.prototype.constructor=T.CSSImportRule;T.CSSImportRule.prototype.type=3;Object.defineProperty(T.CSSImportRule.prototype,"cssText",{get:function(){var i=this.media.mediaText;return"@import url("+this.href+")"+(i?" "+i:"")+";"},set:function(i){for(var e=0,t="",r="",n,s;s=i.charAt(e);e++)switch(s){case" ":case" ":case"\r":case`
5
+ `:case"\f":t==="after-import"?t="url":r+=s;break;case"@":!t&&i.indexOf("@import",e)===e&&(t="after-import",e+=6,r="");break;case"u":if(t==="url"&&i.indexOf("url(",e)===e){if(n=i.indexOf(")",e+1),n===-1)throw e+': ")" not found';e+=4;var o=i.slice(e,n);o[0]===o[o.length-1]&&(o[0]==='"'||o[0]==="'")&&(o=o.slice(1,-1)),this.href=o,e=n,t="media"}break;case'"':if(t==="url"){if(n=i.indexOf('"',e+1),!n)throw e+`: '"' not found`;this.href=i.slice(e+1,n),e=n,t="media"}break;case"'":if(t==="url"){if(n=i.indexOf("'",e+1),!n)throw e+`: "'" not found`;this.href=i.slice(e+1,n),e=n,t="media"}break;case";":t==="media"&&r&&(this.media.mediaText=r.trim());break;default:t==="media"&&(r+=s);break}}});ut.CSSImportRule=T.CSSImportRule});var V=h(St=>{var I={CSSRule:m().CSSRule};I.CSSGroupingRule=function(){I.CSSRule.call(this),this.cssRules=[]};I.CSSGroupingRule.prototype=new I.CSSRule;I.CSSGroupingRule.prototype.constructor=I.CSSGroupingRule;I.CSSGroupingRule.prototype.insertRule=function(e,t){if(t<0||t>this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");var r=I.parse(e).cssRules[0];return r.parentRule=this,this.cssRules.splice(t,0,r),t};I.CSSGroupingRule.prototype.deleteRule=function(e){if(e<0||e>=this.cssRules.length)throw new RangeError("INDEX_SIZE_ERR");this.cssRules.splice(e,1)[0].parentRule=null};St.CSSGroupingRule=I.CSSGroupingRule});var W=h(ct=>{var L={CSSRule:m().CSSRule,CSSGroupingRule:V().CSSGroupingRule};L.CSSConditionRule=function(){L.CSSGroupingRule.call(this),this.cssRules=[]};L.CSSConditionRule.prototype=new L.CSSGroupingRule;L.CSSConditionRule.prototype.constructor=L.CSSConditionRule;L.CSSConditionRule.prototype.conditionText="";L.CSSConditionRule.prototype.cssText="";ct.CSSConditionRule=L.CSSConditionRule});var de=h(ht=>{var E={CSSRule:m().CSSRule,CSSGroupingRule:V().CSSGroupingRule,CSSConditionRule:W().CSSConditionRule,MediaList:pe().MediaList};E.CSSMediaRule=function(){E.CSSConditionRule.call(this),this.media=new E.MediaList};E.CSSMediaRule.prototype=new E.CSSConditionRule;E.CSSMediaRule.prototype.constructor=E.CSSMediaRule;E.CSSMediaRule.prototype.type=4;Object.defineProperties(E.CSSMediaRule.prototype,{conditionText:{get:function(){return this.media.mediaText},set:function(i){this.media.mediaText=i},configurable:!0,enumerable:!0},cssText:{get:function(){for(var i=[],e=0,t=this.cssRules.length;e<t;e++)i.push(this.cssRules[e].cssText);return"@media "+this.media.mediaText+" {"+i.join("")+"}"},configurable:!0,enumerable:!0}});ht.CSSMediaRule=E.CSSMediaRule});var Ce=h(ft=>{var q={CSSRule:m().CSSRule,CSSGroupingRule:V().CSSGroupingRule,CSSConditionRule:W().CSSConditionRule};q.CSSSupportsRule=function(){q.CSSConditionRule.call(this)};q.CSSSupportsRule.prototype=new q.CSSConditionRule;q.CSSSupportsRule.prototype.constructor=q.CSSSupportsRule;q.CSSSupportsRule.prototype.type=12;Object.defineProperty(q.CSSSupportsRule.prototype,"cssText",{get:function(){for(var i=[],e=0,t=this.cssRules.length;e<t;e++)i.push(this.cssRules[e].cssText);return"@supports "+this.conditionText+" {"+i.join("")+"}"}});ft.CSSSupportsRule=q.CSSSupportsRule});var Pe=h(pt=>{var M={CSSStyleDeclaration:j().CSSStyleDeclaration,CSSRule:m().CSSRule};M.CSSFontFaceRule=function(){M.CSSRule.call(this),this.style=new M.CSSStyleDeclaration,this.style.parentRule=this};M.CSSFontFaceRule.prototype=new M.CSSRule;M.CSSFontFaceRule.prototype.constructor=M.CSSFontFaceRule;M.CSSFontFaceRule.prototype.type=5;Object.defineProperty(M.CSSFontFaceRule.prototype,"cssText",{get:function(){return"@font-face {"+this.style.cssText+"}"}});pt.CSSFontFaceRule=M.CSSFontFaceRule});var Ae=h(dt=>{var P={CSSRule:m().CSSRule};P.CSSHostRule=function(){P.CSSRule.call(this),this.cssRules=[]};P.CSSHostRule.prototype=new P.CSSRule;P.CSSHostRule.prototype.constructor=P.CSSHostRule;P.CSSHostRule.prototype.type=1001;Object.defineProperty(P.CSSHostRule.prototype,"cssText",{get:function(){for(var i=[],e=0,t=this.cssRules.length;e<t;e++)i.push(this.cssRules[e].cssText);return"@host {"+i.join("")+"}"}});dt.CSSHostRule=P.CSSHostRule});var ge=h(Ct=>{var $={CSSRule:m().CSSRule,CSSStyleDeclaration:j().CSSStyleDeclaration};$.CSSKeyframeRule=function(){$.CSSRule.call(this),this.keyText="",this.style=new $.CSSStyleDeclaration,this.style.parentRule=this};$.CSSKeyframeRule.prototype=new $.CSSRule;$.CSSKeyframeRule.prototype.constructor=$.CSSKeyframeRule;$.CSSKeyframeRule.prototype.type=8;Object.defineProperty($.CSSKeyframeRule.prototype,"cssText",{get:function(){return this.keyText+" {"+this.style.cssText+"} "}});Ct.CSSKeyframeRule=$.CSSKeyframeRule});var ye=h(gt=>{var A={CSSRule:m().CSSRule};A.CSSKeyframesRule=function(){A.CSSRule.call(this),this.name="",this.cssRules=[]};A.CSSKeyframesRule.prototype=new A.CSSRule;A.CSSKeyframesRule.prototype.constructor=A.CSSKeyframesRule;A.CSSKeyframesRule.prototype.type=7;Object.defineProperty(A.CSSKeyframesRule.prototype,"cssText",{get:function(){for(var i=[],e=0,t=this.cssRules.length;e<t;e++)i.push(" "+this.cssRules[e].cssText);return"@"+(this._vendorPrefix||"")+"keyframes "+this.name+` {
6
+ `+i.join(`
7
+ `)+`
8
+ }`}});gt.CSSKeyframesRule=A.CSSKeyframesRule});var Fe=h(yt=>{var Re={};Re.CSSValue=function(){};Re.CSSValue.prototype={constructor:Re.CSSValue,set cssText(i){var e=this._getConstructorName();throw new Error('DOMException: property "cssText" of "'+e+'" is readonly and can not be replaced with "'+i+'"!')},get cssText(){var i=this._getConstructorName();throw new Error('getter "cssText" of "'+i+'" is not implemented!')},_getConstructorName:function(){var i=this.constructor.toString(),e=i.match(/function\s([^\(]+)/),t=e[1];return t}};yt.CSSValue=Re.CSSValue});var He=h(Rt=>{var k={CSSValue:Fe().CSSValue};k.CSSValueExpression=function(e,t){this._token=e,this._idx=t};k.CSSValueExpression.prototype=new k.CSSValue;k.CSSValueExpression.prototype.constructor=k.CSSValueExpression;k.CSSValueExpression.prototype.parse=function(){for(var i=this._token,e=this._idx,t="",r="",n="",s,o=[];;++e){if(t=i.charAt(e),t===""){n="css expression error: unfinished expression!";break}switch(t){case"(":o.push(t),r+=t;break;case")":o.pop(t),r+=t;break;case"/":(s=this._parseJSComment(i,e))?s.error?n="css expression error: unfinished comment in expression!":e=s.idx:(s=this._parseJSRexExp(i,e))?(e=s.idx,r+=s.text):r+=t;break;case"'":case'"':s=this._parseJSString(i,e,t),s?(e=s.idx,r+=s.text):r+=t;break;default:r+=t;break}if(n||o.length===0)break}var l;return n?l={error:n}:l={idx:e,expression:r},l};k.CSSValueExpression.prototype._parseJSComment=function(i,e){var t=i.charAt(e+1),r;if(t==="/"||t==="*"){var n=e,s,o;if(t==="/"?o=`
9
+ `:t==="*"&&(o="*/"),s=i.indexOf(o,n+1+1),s!==-1)return s=s+o.length-1,r=i.substring(e,s+1),{idx:s,text:r};var l="css expression error: unfinished comment in expression!";return{error:l}}else return!1};k.CSSValueExpression.prototype._parseJSString=function(i,e,t){var r=this._findMatchedIdx(i,e,t),n;return r===-1?!1:(n=i.substring(e,r+t.length),{idx:r,text:n})};k.CSSValueExpression.prototype._parseJSRexExp=function(i,e){var t=i.substring(0,e).replace(/\s+$/,""),r=[/^$/,/\($/,/\[$/,/\!$/,/\+$/,/\-$/,/\*$/,/\/\s+/,/\%$/,/\=$/,/\>$/,/<$/,/\&$/,/\|$/,/\^$/,/\~$/,/\?$/,/\,$/,/delete$/,/in$/,/instanceof$/,/new$/,/typeof$/,/void$/],n=r.some(function(o){return o.test(t)});if(n){var s="/";return this._parseJSString(i,e,s)}else return!1};k.CSSValueExpression.prototype._findMatchedIdx=function(i,e,t){for(var r=e,n,s=-1;;)if(n=i.indexOf(t,r+1),n===-1){n=s;break}else{var o=i.substring(e+1,n),l=o.match(/\\+$/);if(!l||l[0]%2===0)break;r=n}var u=i.indexOf(`
10
+ `,e+1);return u<n&&(n=s),n};Rt.CSSValueExpression=k.CSSValueExpression});var Ue=h(mt=>{var me={};me.MatcherList=function(){this.length=0};me.MatcherList.prototype={constructor:me.MatcherList,get matcherText(){return Array.prototype.join.call(this,", ")},set matcherText(i){for(var e=i.split(","),t=this.length=e.length,r=0;r<t;r++)this[r]=e[r].trim()},appendMatcher:function(i){Array.prototype.indexOf.call(this,i)===-1&&(this[this.length]=i,this.length++)},deleteMatcher:function(i){var e=Array.prototype.indexOf.call(this,i);e!==-1&&Array.prototype.splice.call(this,e,1)}};mt.MatcherList=me.MatcherList});var De=h(bt=>{var O={CSSRule:m().CSSRule,MatcherList:Ue().MatcherList};O.CSSDocumentRule=function(){O.CSSRule.call(this),this.matcher=new O.MatcherList,this.cssRules=[]};O.CSSDocumentRule.prototype=new O.CSSRule;O.CSSDocumentRule.prototype.constructor=O.CSSDocumentRule;O.CSSDocumentRule.prototype.type=10;Object.defineProperty(O.CSSDocumentRule.prototype,"cssText",{get:function(){for(var i=[],e=0,t=this.cssRules.length;e<t;e++)i.push(this.cssRules[e].cssText);return"@-moz-document "+this.matcher.matcherText+" {"+i.join("")+"}"}});bt.CSSDocumentRule=O.CSSDocumentRule});var he=h(vt=>{var c={};c.parse=function(e){for(var t=0,r="before-selector",n,s="",o=0,l={selector:!0,value:!0,"value-parenthesis":!0,atRule:!0,"importRule-begin":!0,importRule:!0,atBlock:!0,conditionBlock:!0,"documentRule-begin":!0},u=new c.CSSStyleSheet,S=u,a,_=[],F=!1,Xe,Me,z="",y,Q,ee,te,re,D,K,ae,ze=/@(-(?:\w+-)+)?keyframes/g,ie=function(Ot){var Qe=e.substring(0,t).split(`
11
+ `),et=Qe.length,tt=Qe.pop().length+1,ce=new Error(Ot+" (line "+et+", char "+tt+")");throw ce.line=et,ce.char=tt,ce.styleSheet=u,ce},R;R=e.charAt(t);t++)switch(R){case" ":case" ":case"\r":case`
12
+ `:case"\f":l[r]&&(s+=R);break;case'"':n=t+1;do n=e.indexOf('"',n)+1,n||ie('Unmatched "');while(e[n-2]==="\\");switch(s+=e.slice(t,n),t=n-1,r){case"before-value":r="value";break;case"importRule-begin":r="importRule";break}break;case"'":n=t+1;do n=e.indexOf("'",n)+1,n||ie("Unmatched '");while(e[n-2]==="\\");switch(s+=e.slice(t,n),t=n-1,r){case"before-value":r="value";break;case"importRule-begin":r="importRule";break}break;case"/":e.charAt(t+1)==="*"?(t+=2,n=e.indexOf("*/",t),n===-1?ie("Missing */"):t=n+1):s+=R,r==="importRule-begin"&&(s+=" ",r="importRule");break;case"@":if(e.indexOf("@-moz-document",t)===t){r="documentRule-begin",K=new c.CSSDocumentRule,K.__starts=t,t+=13,s="";break}else if(e.indexOf("@media",t)===t){r="atBlock",Q=new c.CSSMediaRule,Q.__starts=t,t+=5,s="";break}else if(e.indexOf("@supports",t)===t){r="conditionBlock",ee=new c.CSSSupportsRule,ee.__starts=t,t+=8,s="";break}else if(e.indexOf("@host",t)===t){r="hostRule-begin",t+=4,ae=new c.CSSHostRule,ae.__starts=t,s="";break}else if(e.indexOf("@import",t)===t){r="importRule-begin",t+=6,s+="@import";break}else if(e.indexOf("@font-face",t)===t){r="fontFaceRule-begin",t+=9,re=new c.CSSFontFaceRule,re.__starts=t,s="";break}else{ze.lastIndex=t;var ue=ze.exec(e);if(ue&&ue.index===t){r="keyframesRule-begin",D=new c.CSSKeyframesRule,D.__starts=t,D._vendorPrefix=ue[1],t+=ue[0].length-1,s="";break}else r==="selector"&&(r="atRule")}s+=R;break;case"{":r==="selector"||r==="atRule"?(y.selectorText=s.trim(),y.style.__starts=t,s="",r="before-name"):r==="atBlock"?(Q.media.mediaText=s.trim(),a&&_.push(a),S=a=Q,Q.parentStyleSheet=u,s="",r="before-selector"):r==="conditionBlock"?(ee.conditionText=s.trim(),a&&_.push(a),S=a=ee,ee.parentStyleSheet=u,s="",r="before-selector"):r==="hostRule-begin"?(a&&_.push(a),S=a=ae,ae.parentStyleSheet=u,s="",r="before-selector"):r==="fontFaceRule-begin"?(a&&(re.parentRule=a),re.parentStyleSheet=u,y=re,s="",r="before-name"):r==="keyframesRule-begin"?(D.name=s.trim(),a&&(_.push(a),D.parentRule=a),D.parentStyleSheet=u,S=a=D,s="",r="keyframeRule-begin"):r==="keyframeRule-begin"?(y=new c.CSSKeyframeRule,y.keyText=s.trim(),y.__starts=t,s="",r="before-name"):r==="documentRule-begin"&&(K.matcher.matcherText=s.trim(),a&&(_.push(a),K.parentRule=a),S=a=K,K.parentStyleSheet=u,s="",r="before-selector");break;case":":r==="name"?(Me=s.trim(),s="",r="before-value"):s+=R;break;case"(":if(r==="value")if(s.trim()==="expression"){var Se=new c.CSSValueExpression(e,t).parse();Se.error?ie(Se.error):(s+=Se.expression,t=Se.idx)}else r="value-parenthesis",o=1,s+=R;else r==="value-parenthesis"&&o++,s+=R;break;case")":r==="value-parenthesis"&&(o--,o===0&&(r="value")),s+=R;break;case"!":r==="value"&&e.indexOf("!important",t)===t?(z="important",t+=9):s+=R;break;case";":switch(r){case"value":y.style.setProperty(Me,s.trim(),z),z="",s="",r="before-name";break;case"atRule":s="",r="before-selector";break;case"importRule":te=new c.CSSImportRule,te.parentStyleSheet=te.styleSheet.parentStyleSheet=u,te.cssText=s+R,u.cssRules.push(te),s="",r="before-selector";break;default:s+=R;break}break;case"}":switch(r){case"value":y.style.setProperty(Me,s.trim(),z),z="";case"before-name":case"name":y.__ends=t+1,a&&(y.parentRule=a),y.parentStyleSheet=u,S.cssRules.push(y),s="",S.constructor===c.CSSKeyframesRule?r="keyframeRule-begin":r="before-selector";break;case"keyframeRule-begin":case"before-selector":case"selector":for(a||ie("Unexpected }"),F=_.length>0;_.length>0;){if(a=_.pop(),a.constructor.name==="CSSMediaRule"||a.constructor.name==="CSSSupportsRule"){Xe=S,S=a,S.cssRules.push(Xe);break}_.length===0&&(F=!1)}F||(S.__ends=t+1,u.cssRules.push(S),S=u,a=null),s="",r="before-selector";break}break;default:switch(r){case"before-selector":r="selector",y=new c.CSSStyleRule,y.__starts=t;break;case"before-name":r="name";break;case"before-value":r="value";break;case"importRule-begin":r="importRule";break}s+=R;break}return u};vt.parse=c.parse;c.CSSStyleSheet=oe().CSSStyleSheet;c.CSSStyleRule=ne().CSSStyleRule;c.CSSImportRule=qe().CSSImportRule;c.CSSGroupingRule=V().CSSGroupingRule;c.CSSMediaRule=de().CSSMediaRule;c.CSSConditionRule=W().CSSConditionRule;c.CSSSupportsRule=Ce().CSSSupportsRule;c.CSSFontFaceRule=Pe().CSSFontFaceRule;c.CSSHostRule=Ae().CSSHostRule;c.CSSStyleDeclaration=j().CSSStyleDeclaration;c.CSSKeyframeRule=ge().CSSKeyframeRule;c.CSSKeyframesRule=ye().CSSKeyframesRule;c.CSSValueExpression=He().CSSValueExpression;c.CSSDocumentRule=De().CSSDocumentRule});var j=h(wt=>{var B={};B.CSSStyleDeclaration=function(){this.length=0,this.parentRule=null,this._importants={}};B.CSSStyleDeclaration.prototype={constructor:B.CSSStyleDeclaration,getPropertyValue:function(i){return this[i]||""},setProperty:function(i,e,t){if(this[i]){var r=Array.prototype.indexOf.call(this,i);r<0&&(this[this.length]=i,this.length++)}else this[this.length]=i,this.length++;this[i]=e+"",this._importants[i]=t},removeProperty:function(i){if(!(i in this))return"";var e=Array.prototype.indexOf.call(this,i);if(e<0)return"";var t=this[i];return this[i]="",Array.prototype.splice.call(this,e,1),t},getPropertyCSSValue:function(){},getPropertyPriority:function(i){return this._importants[i]||""},getPropertyShorthand:function(){},isPropertyImplicit:function(){},get cssText(){for(var i=[],e=0,t=this.length;e<t;++e){var r=this[e],n=this.getPropertyValue(r),s=this.getPropertyPriority(r);s&&(s=" !"+s),i[e]=r+": "+n+s+";"}return i.join(" ")},set cssText(i){var e,t;for(e=this.length;e--;)t=this[e],this[t]="";Array.prototype.splice.call(this,0,this.length),this._importants={};var r=B.parse("#bogus{"+i+"}").cssRules[0].style,n=r.length;for(e=0;e<n;++e)t=r[e],this.setProperty(r[e],r.getPropertyValue(t),r.getPropertyPriority(t))}};wt.CSSStyleDeclaration=B.CSSStyleDeclaration;B.parse=he().parse});var _t=h(xt=>{var be={CSSStyleSheet:oe().CSSStyleSheet,CSSRule:m().CSSRule,CSSStyleRule:ne().CSSStyleRule,CSSGroupingRule:V().CSSGroupingRule,CSSConditionRule:W().CSSConditionRule,CSSMediaRule:de().CSSMediaRule,CSSSupportsRule:Ce().CSSSupportsRule,CSSStyleDeclaration:j().CSSStyleDeclaration,CSSKeyframeRule:ge().CSSKeyframeRule,CSSKeyframesRule:ye().CSSKeyframesRule};be.clone=function i(e){var t=new be.CSSStyleSheet,r=e.cssRules;if(!r)return t;for(var n=0,s=r.length;n<s;n++){var o=r[n],l=t.cssRules[n]=new o.constructor,u=o.style;if(u){for(var S=l.style=new be.CSSStyleDeclaration,a=0,_=u.length;a<_;a++){var F=S[a]=u[a];S[F]=u[F],S._importants[F]=u.getPropertyPriority(F)}S.length=u.length}o.hasOwnProperty("keyText")&&(l.keyText=o.keyText),o.hasOwnProperty("selectorText")&&(l.selectorText=o.selectorText),o.hasOwnProperty("mediaText")&&(l.mediaText=o.mediaText),o.hasOwnProperty("conditionText")&&(l.conditionText=o.conditionText),o.hasOwnProperty("cssRules")&&(l.cssRules=i(o).cssRules)}return t};xt.clone=be.clone});var Tt=h(f=>{"use strict";f.CSSStyleDeclaration=j().CSSStyleDeclaration;f.CSSRule=m().CSSRule;f.CSSGroupingRule=V().CSSGroupingRule;f.CSSConditionRule=W().CSSConditionRule;f.CSSStyleRule=ne().CSSStyleRule;f.MediaList=pe().MediaList;f.CSSMediaRule=de().CSSMediaRule;f.CSSSupportsRule=Ce().CSSSupportsRule;f.CSSImportRule=qe().CSSImportRule;f.CSSFontFaceRule=Pe().CSSFontFaceRule;f.CSSHostRule=Ae().CSSHostRule;f.StyleSheet=Le().StyleSheet;f.CSSStyleSheet=oe().CSSStyleSheet;f.CSSKeyframesRule=ye().CSSKeyframesRule;f.CSSKeyframeRule=ge().CSSKeyframeRule;f.MatcherList=Ue().MatcherList;f.CSSDocumentRule=De().CSSDocumentRule;f.CSSValue=Fe().CSSValue;f.CSSValueExpression=He().CSSValueExpression;f.parse=he().parse;f.clone=_t().clone});var $e=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},se,Oe=class{constructor(){se.set(this,{Array:e=>Array.isArray(e),"string[]":e=>Array.isArray(e)&&e.every(t=>typeof t=="string")})}for(e){return Array.isArray(e)||(console.warn(`[JSTC.for] @briklab/lib/jstc: Invalid first argument!
13
+ Hint: The first argument must be a array.
14
+ Using [givenValue] as fallback`),e=[e]),{check:t=>{if(Array.isArray(t)||(console.warn(`[JSTC.for().check] @briklab/lib/jstc: Invalid first argument!
15
+ Hint: The first argument must be a valid array!
16
+ Using [givenValue] as fallback`),t=[t]),e.length<t.length)return!1;for(let r=0;r<t.length;r++){let n=e[r],s=t[r],o=Array.isArray(s)?s:[s],l=!1;for(let u of o){let S=typeof u=="string"?u.split("|"):[u];for(let a of S)if(typeof a=="function"){if(n instanceof a){l=!0;break}}else if(typeof a=="string"&&$e(this,se,"f")[a]){if($e(this,se,"f")[a](n)){l=!0;break}}else if(typeof n===a){l=!0;break}if(l)break}if(!l)return!1}return!0}}}addCustomHandler(e,t){typeof e=="string"&&typeof t=="function"||(console.warn(`[JSTC.addCustomHandler] @briklab/lib/jstc: Invalid Arguments!
17
+ Hint: The first argument must be a string, and the second argument must be a function
18
+ Using String(argument1) and ()=>false as fallbacks`),e=String(e),t=()=>!1),$e(this,se,"f")[e]=t}};se=new WeakMap;var Dt=new Oe,C=Dt;var Ge=Ut(Tt(),1);var v=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},g,je,ve,we,It,Ve,Ne,kt={red:"#ff0000",blue:"#0000ff",green:"#00ff00",yellow:"#ffff00",orange:"#ffa500",black:"#000000",white:"#ffffff",gray:"#808080"},J=class i{constructor(e){if(g.add(this),this.r=0,this.g=0,this.b=0,this.a=1,typeof e=="string")v(this,g,"m",It).call(this,e);else if("r"in e&&"g"in e&&"b"in e)this.r=v(this,g,"m",ve).call(this,e.r),this.g=v(this,g,"m",ve).call(this,e.g),this.b=v(this,g,"m",ve).call(this,e.b),this.a=e.a??1;else if("h"in e&&"s"in e&&"l"in e){let{r:t,g:r,b:n}=v(this,g,"m",Ve).call(this,e.h,e.s,e.l);this.r=t,this.g=r,this.b=n,this.a=e.a??1}else console.warn(`[Color.constructor] Invalid first argument!
19
+ Hint: The first argument must be a valid color array
20
+ Using black as fallback.`)}hex(){return`#${v(this,g,"m",we).call(this,this.r)}${v(this,g,"m",we).call(this,this.g)}${v(this,g,"m",we).call(this,this.b)}`}rgb(){return`rgb(${this.r}, ${this.g}, ${this.b})`}rgba(){return`rgba(${this.r}, ${this.g}, ${this.b}, ${this.a})`}hsl(){let{h:e,s:t,l:r}=v(this,g,"m",Ne).call(this,this.r,this.g,this.b);return`hsl(${e}, ${t}%, ${r}%)`}hsla(){let{h:e,s:t,l:r}=v(this,g,"m",Ne).call(this,this.r,this.g,this.b);return`hsla(${e}, ${t}%, ${r}%, ${this.a})`}css(){return this.a===1?this.hex():this.rgba()}ansiTruecolor(){return`\x1B[38;2;${this.r};${this.g};${this.b}m`}ansiTruecolorBg(){return`\x1B[48;2;${this.r};${this.g};${this.b}m`}ansi256(){return`\x1B[38;5;${v(this,g,"m",je).call(this,this.r,this.g,this.b)}m`}ansi256Bg(){return`\x1B[48;5;${v(this,g,"m",je).call(this,this.r,this.g,this.b)}m`}wrapAnsi(e,t={}){let r=!!t.use256,n=t.background?r?this.ansi256Bg():this.ansiTruecolorBg():r?this.ansi256():this.ansiTruecolor();return`${`${t.bold?i.BOLD:""}${t.underline?i.UNDERLINE:""}`}${n}${e}${i.RESET}`}};g=new WeakSet,je=function(e,t,r){if(e===t&&t===r)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;let n=u=>Math.round(u/255*5),s=n(e),o=n(t),l=n(r);return 16+36*s+6*o+l},ve=function(e){return Math.max(0,Math.min(255,e))},we=function(e){return e.toString(16).padStart(2,"0")},It=function(e){if(e=e.trim().toLowerCase(),kt[e]&&(e=kt[e]),e.startsWith("#")){let t=e.slice(1);t.length===3?(this.r=parseInt(t[0]+t[0],16),this.g=parseInt(t[1]+t[1],16),this.b=parseInt(t[2]+t[2],16)):t.length===6?(this.r=parseInt(t.slice(0,2),16),this.g=parseInt(t.slice(2,4),16),this.b=parseInt(t.slice(4,6),16)):console.warn(`[Color class] @briklab/lib/color: Invalid hex!
21
+ Hint: You must pass a valid hex color string!
22
+ Using black as fallback.`)}else if(e.startsWith("rgb")){let t=e.match(/[\d.]+/g)?.map(Number);t&&t.length>=3&&([this.r,this.g,this.b]=t,this.a=t[3]??1)}else if(e.startsWith("hsl")){let t=e.match(/[\d.]+/g)?.map(Number);if(t&&t.length>=3){let{r,g:n,b:s}=v(this,g,"m",Ve).call(this,t[0],t[1],t[2]);this.r=r,this.g=n,this.b=s,this.a=t[3]??1}}else console.warn(`[Color class] @briklab/lib/color: Unknown color string "${e}"!
23
+ Hint: The argument must be a valid color string!
24
+ Using black as fallback.`)},Ve=function(e,t,r){t/=100,r/=100;let n=l=>(l+e/30)%12,s=t*Math.min(r,1-r),o=l=>r-s*Math.max(-1,Math.min(n(l)-3,Math.min(9-n(l),1)));return{r:Math.round(o(0)*255),g:Math.round(o(8)*255),b:Math.round(o(4)*255)}},Ne=function(e,t,r){e/=255,t/=255,r/=255;let n=Math.max(e,t,r),s=Math.min(e,t,r),o=0,l=0,u=(n+s)/2;if(n!==s){let S=n-s;switch(l=u>.5?S/(2-n-s):S/(n+s),n){case e:o=(t-r)/S+(t<r?6:0);break;case t:o=(r-e)/S+2;break;case r:o=(e-t)/S+4;break}o*=60}return{h:Math.round(o),s:Math.round(l*100),l:Math.round(u*100)}};J.RESET="\x1B[0m";J.BOLD="\x1B[1m";J.UNDERLINE="\x1B[4m";var N=J;var xe=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},x=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Te,_e,Et,Mt,H,U,ke=class{constructor(e){Te.add(this),_e.set(this,void 0),H.set(this,void 0),C.for([e]).check(["object|undefined"])||(console.warn(`[InlineStyle class] @briklab/lib/stylesheet: Invalid first argument!
25
+ Hint: The first argument must be a valid style object or not be given!
26
+ Using {"imeMode":givenValue} as fallback`),e={imeMode:`${e}`}),xe(this,H,e,"f"),xe(this,_e,new Ge.CSSStyleDeclaration,"f")}generate(){let e=x(this,_e,"f"),t=x(this,H,"f"),r=Object.keys(t),n=Object.values(t);for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(l==null){console.warn(`[InlineStyle.generate] @briklab/lib/stylesheet: Skipping property "${o}" with ${String(l)} value. Hint: avoid null/undefined style values.`);continue}typeof l!="string"&&(console.warn(`[InlineStyle.generate] @briklab/lib/stylesheet: Non-string style value for "${o}" (type=${typeof l}). Coercing to string.`),l=String(l)),e.setProperty(o,l)}return e.cssText}get text(){return this.generate()}get ansi(){let e=x(this,H,"f")||{},t=[];(e["font-weight"]==="bold"||e.fontWeight==="bold")&&t.push(N.BOLD),(e["text-decoration"]||e.textDecoration||"").includes("underline")&&t.push(N.UNDERLINE);let r=e.color||e.color;if(r)try{let s=new N(String(r));t.push(s.ansiTruecolor())}catch{console.warn(`[InlineStyle.ansi] @briklab/lib/stylesheet: Invalid color value "${String(r)}" \u2014 ignoring. Hint: use a valid hex, rgb(), hsl() or named color.`)}let n=e["background-color"]||e.backgroundColor;if(n)try{let s=new N(String(n));t.push(s.ansiTruecolorBg())}catch{console.warn(`[InlineStyle.ansi] @briklab/lib/stylesheet: Invalid background-color value "${String(n)}" \u2014 ignoring. Hint: use a valid hex, rgb(), hsl() or named color.`)}return t.join("")}addStyleWithObject(e){return C.for([e]).check(["object"])?(xe(this,H,{...x(this,H,"f"),...e},"f"),this.generate(),this):(console.warn(`[InlineStyle.addStyleWithObject] @briklab/lib/stylesheet: Invalid first argument!
27
+ Hint: expected a plain object with CSS properties. Received: ${String(e)}
28
+ Returned with no operations.`),this)}addStyleWithInlineCSS(e){if(!C.for([e]).check(["string"]))return console.warn(`[InlineStyle.addStyleWithInlineCSS] @briklab/lib/stylesheet: Invalid first argument!
29
+ Hint: The first argument must be a valid inline css string!
30
+ Returned with no operations.`),this;let t=new Ge.CSSStyleDeclaration;t.cssText=x(this,Te,"m",Mt).call(this,e);let r={};for(let n=0;n<t.length;n++){let s=t[n],o=t.getPropertyValue(s);r[s]=o}return this.addStyleWithObject(r),this}removeStyle(e){if(!C.for([e]).check(["string[]|string"]))return console.warn(`[InlineStyle.removeStyle] @briklab/lib/stylesheet: Invalid first argument!
31
+ Hint: expected a string or array of strings. Returned with no operations. Received: ${String(e)}`),this;typeof e=="string"&&(e=[e]);for(let t=0;t<e.length;t++){let r=e[t];if(typeof r!="string"){console.warn(`[InlineStyle.removeStyle] @briklab/lib/stylesheet: Ignoring non-string style name at index ${t}: ${String(r)}`);continue}delete x(this,H,"f")[r]}return this}applyTo(e){return C.for([e]).check(["object"])?!e||typeof e.style!="object"?(console.warn("[InlineStyle.applyTo] @briklab/lib/stylesheet: Given object does not look like an HTMLElement (missing .style). No operation was performed."),this):(e.style.cssText=this.generate(),this):(console.warn(`[InlineStyle.applyTo] @briklab/lib/stylesheet: Invalid first argument!
32
+ Hint: expected an HTMLElement. No operation was performed.`),this)}};_e=new WeakMap,H=new WeakMap,Te=new WeakSet,Et=function(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)},Mt=function(e){let t=String(e).split(";"),r="";for(let n=0;n<t.length;n++){let s=t[n].trim();if(!s)continue;let o=s.split(":");if(o.length<2){console.warn(`[InlineStyle.#convertKeysToValidCSS] @briklab/lib/stylesheet: Skipping malformed rule: "${s}". Hint: expected "property: value" pairs separated by ";"`);continue}let l=o[0].trim(),u=o.slice(1).join(":").trim();if(!l||!u){console.warn(`[InlineStyle.#convertKeysToValidCSS] @briklab/lib/stylesheet: Skipping empty property or value in rule: "${s}".`);continue}r+=`${x(this,Te,"m",Et).call(this,l)}:${u};`}return r};var Y=ke,Ie=class{constructor(){U.set(this,void 0),xe(this,U,{},"f")}set(e,t){return C.for([e,t]).check(["string","object"])?t instanceof ke?(x(this,U,"f")[e]=t,this):(console.warn(`[StyleSheet.set] @briklab/lib/stylesheet: Provided style is not an InlineStyle instance!
33
+ Hint: create the style with new InlineStyle({...}). Received: ${String(t)}. Returned with no operations.`),this):(console.warn(`[StyleSheet.set] @briklab/lib/stylesheet: Invalid arguments!
34
+ Hint: call .set("ruleName", new InlineStyle({...})). Received name=${String(e)}, style=${String(t)}. Returned with no operations.`),this)}get(e){if(!C.for([e]).check(["string"])){console.warn(`[StyleSheet.get] @briklab/lib/stylesheet: Invalid argument!
35
+ Hint: name must be a string. Received: ${String(e)}. Returned undefined.`);return}return x(this,U,"f")[e]}remove(e){return C.for([e]).check(["string"])?(delete x(this,U,"f")[e],this):(console.warn(`[StyleSheet.remove] @briklab/lib/stylesheet: Invalid argument!
36
+ Hint: name must be a string. Received: ${String(e)}. No-op.`),this)}generate(){let e="";for(let t in x(this,U,"f")){let r=x(this,U,"f")[t];r&&(e+=`${t} { ${r.text} }
37
+ `)}return e.trim()}toString(){return this.generate()}};U=new WeakMap;var p=function(i,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?i!==e||!r:!e.has(i))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(i):r?r.value:e.get(i)},Ze=function(i,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?i!==e||!n:!e.has(i))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(i,t):n?n.value=t:e.set(i,t),t},G,Z,le,$t,Ee,Ke,We,Be;C.addCustomHandler("NodeJS Process",i=>i&&typeof i=="object"&&typeof i.pid=="number"&&typeof i.cwd=="function"&&typeof i.exit=="function");var X=class i{constructor(e){if(G.add(this),Z.set(this,[]),le.set(this,[]),Ee.set(this,void 0),Ke.set(this,class extends Je{constructor(t){super(t),this.setName="CLI"}}),!C.for([e]).check(["NodeJS Process"]))throw p(this,G,"m",We).call(this,"Invalid First Argument!","You must pass a valid NodeJS process (imported from node:process) while constructing a CLI Class!");Ze(this,Ee,e,"f")}command(e){C.for([e]).check(["string"])||(p(this,G,"m",Be).call(this,"Invalid First Argument!","CLI.option expects a string as the first argument.","Using String(given argument) as fallback."),e=String(e));let t=new i.Command(e),r=p(this,Z,"f").findIndex(n=>n.name===e);return r!==-1?p(this,Z,"f")[r]=t:p(this,Z,"f").push(t),t}on(e,t){if(!C.for([e,t]).check(["string","function"]))throw p(this,G,"m",We).call(this,"Arguments in CLI.on are invalid!","The first argument must be a string, and the second argument must be a function.");e.toLowerCase()==="command"?p(this,le,"f").push(t):p(this,G,"m",Be).call(this,"Invalid event in CLI.on","Please enter a valid event from CLI.ValidEvents (array)")}run(){let{options:e,commandArgs:t,command:r,failed:n}=p(this,G,"m",$t).call(this);if(!n)for(let s=0;s<p(this,le,"f").length;s++)p(this,le,"f")[s]({options:e,commandArgs:t,command:r})}};Z=new WeakMap,le=new WeakMap,Ee=new WeakMap,Ke=new WeakMap,G=new WeakSet,$t=function(){let[,,...e]=p(this,Ee,"f").argv;if(e.length===0)return{options:[],command:"",commandArgs:[],failed:!0};let t=p(this,Z,"f").find(l=>l.name===e[0]);if(!t)return{options:[],command:"",commandArgs:[],failed:!0};let r=[],n=e.slice(1);for(let l=0;l<n.length;l++){let u=n[l];if(u.startsWith("--"))break;r.push(u)}let s=n.slice(r.length),o=[];for(let l=0;l<s.length;l++){let u=s[l];if(!u.startsWith("--"))continue;let S=[];for(let a=l+1;a<s.length&&!s[a].startsWith("--");a++)S.push(s[a]);o.push({option:u,arguments:S})}return{options:o,commandArgs:r,command:t,failed:!1}},We=function(e,t){return new(p(this,Ke,"f"))(`${e}
38
+ Hint: ${t}`)},Be=function(e,t,r){return console.warn(`[Class CLI] ${e}
39
+ Hint: ${t}
40
+ ${r}`)};var Je=class i extends Error{constructor(e){super(e),this.name="[] @briklab/lib/cli-john",Error.captureStackTrace(this,i)}set setName(e){this.name=`[${e}] @briklab/lib/cli-john`}};(function(i){var e,t,r,n;i.ValidEvents=["command"];class s{constructor(l){return e.add(this),t.set(this,void 0),n.set(this,[]),Ze(this,t,l,"f"),this}get name(){return p(this,t,"f")}get metadata(){return{options:p(this,n,"f").map(u=>u.metadata),name:this.name}}option(l){C.for([l]).check(["string"])||(p(this,e,"m",r).call(this,"First argument is invalid!","The first argument must be a string","Using String(argument) as fallback"),l=String(l));let u=new i.Command.Option(l),S=p(this,n,"f").findIndex(a=>a.name===l);return S!==-1?p(this,n,"f")[S]=u:p(this,n,"f").push(u),u}}t=new WeakMap,n=new WeakMap,e=new WeakSet,r=function(l,u,S){return console.warn(`[Class CLI.Command] ${l}
41
+ Hint: ${u}
42
+ ${S}`)},i.Command=s})(X||(X={}));(function(i){var e;(function(t){var r;class n{get metadata(){return{name:`${p(this,r,"f")}`}}constructor(o){return r.set(this,void 0),Ze(this,r,o,"f"),this}get name(){return p(this,r,"f")}}r=new WeakMap,t.Option=n})(e=i.Command||(i.Command={}))})(X||(X={}));C.addCustomHandler("Utilities Tag Config",i=>i&&typeof i=="object"&&typeof i.tag=="string"&&typeof i.showErrorInTag=="boolean"&&typeof i.paddingLeft=="number"&&typeof i.paddingRight=="number"&&(typeof i.styleName=="string"||i.styleName===void 0));var Ye=class{constructor(){this.styleSheet=new Ie,this.tags={},this.addTag("error",{tag:"ERROR",showErrorInTag:!1,paddingLeft:0,paddingRight:0}),this.addTag("warning",{tag:"WARNING",showErrorInTag:!0,paddingLeft:0,paddingRight:0}),this.addTag("info",{tag:"INFO",showErrorInTag:!0,paddingLeft:0,paddingRight:0}),this.setTagStyle("error",new Y({color:"red",fontWeight:"bold"})),this.setTagStyle("warning",new Y({color:"orange",fontWeight:"bold"})),this.setTagStyle("info",new Y({color:"blue"}))}addTag(e,t={}){C.for([e,t]).check(["string","object"])||(console.warn(`[UtilitiesClass.addTag] @briklab/lib/cli-john: Invalid Arguments!
43
+ Hint: The first argument must be a string, and the second argument must be a object.
44
+ Using String(argument1) and {} as fallback.`),e=String(e),t={});let r={tag:e.toUpperCase(),showErrorInTag:!1,paddingLeft:0,paddingRight:0,styleName:"",...t};return C.for([r]).check(["Utilities Tag Config"])?(this.tags[e]=r,this):(console.warn(`[UtilitiesClass.addTag] @briklab/lib/cli-john: Invalid tag config passed for "${e}"
45
+ Hint: The config must be in format {tag?: string, showErrorInTag?:boolean, paddingLeft?:number, paddingRight?:number, styleName?:string}`),console.warn(r),this)}setTagStyle(e,t){if((typeof e!="string"||!(t instanceof Y))&&(console.warn(`[UtilitiesClass.setTagStyle] @briklab/lib/cli-john: Invalid arguments!
46
+ Hint: The first argument must be a string and the second argument must be a instance of InlineStyle
47
+ Using String(firstArgument) and new InlineStyle({}) as fallback`),e=String(e),t=new Y({})),!this.tags[e])return console.warn(`[UtilitiesClass.setTagStyle] @briklab/lib/cli-john: Tag "${e}" does not exist!
48
+ Hint: Use a valid tag that you have defined or use "error"|"warn"|"info"`),this;let r=`${e} Tag Color`;return this.styleSheet.set(r,t),this.tags[e].styleName=r,this}log(e,...t){C.for([e]).check(["string"])||(console.warn(`[UtilitiesClass.log] @briklab/lib/cli-john: Invalid Arguments!
49
+ Hint: The first argument must be a string
50
+ Using String(argument1) as fallback`),e=String(e)),(!t||t.length===0)&&(t=[""]);let r=this.tags[e];if(!r){console.warn(`[UtilitiesClass.log] @briklab/lib/cli-john: Tag "${e}" does not exist!
51
+ Hint: Use a valid tag that you have defined or use "error"|"warn"|"info"`),console.log(...t);return}let n=this.styleSheet.get(r.styleName),s=n?.text??"",o=" ".repeat(r.paddingLeft),l=" ".repeat(r.paddingRight);if(typeof process<"u"&&typeof process.stdout<"u"&&!!process.stdout.isTTY){let S=n?.ansi??"",a=N.RESET;r.showErrorInTag?console.log("["+S+o+r.tag+l+a+"]:",...t):console.log(S+"["+o+r.tag+l+"]"+a+":",...t)}else r.showErrorInTag?console.log(`[%c${o}${r.tag}${l}%c]:`,s,...t):console.log(`%c[${o}${r.tag}${l}]%c:`,s,...t)}error(...e){return(!e||e.length===0)&&(e=[""]),this.log("error",...e),this}warning(...e){return(!e||e.length===0)&&(e=[""]),this.log("warning",...e),this}info(...e){return(!e||e.length===0)&&(e=[""]),this.log("info",...e),this}},yr=new Ye;export{X as CLI,yr as Utilities};
52
+ //# sourceMappingURL=index.js.map