@briklab/lib 1.0.2 → 1.0.10

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.
@@ -52,6 +52,7 @@
52
52
  *
53
53
  * @module cli-john
54
54
  */
55
+ import InlineStyle, { StyleSheet } from "../stylesheet/index.js";
55
56
  /**
56
57
  * # CLI
57
58
  * @classdesc The main class for **CLI**.
@@ -87,7 +88,7 @@ export declare class CLI {
87
88
  }
88
89
  export declare namespace CLI {
89
90
  const ValidEvents: readonly ["command"];
90
- type ValidEvent = typeof ValidEvents[number];
91
+ type ValidEvent = (typeof ValidEvents)[number];
91
92
  /**
92
93
  * ## CLI.Command
93
94
  * A command in a CLI Command
@@ -127,9 +128,24 @@ export declare namespace CLI.Command {
127
128
  get name(): string;
128
129
  }
129
130
  }
130
- /**
131
- * Will be implemented in v1.2.0
132
- * @experimental v1.2.0
133
- */
134
- export declare namespace Utilities {
131
+ declare class UtilitiesClass {
132
+ styleSheet: StyleSheet;
133
+ tags: Record<string, {
134
+ tag: string;
135
+ showErrorInTag: boolean;
136
+ paddingLeft: number;
137
+ paddingRight: number;
138
+ styleName: string;
139
+ }>;
140
+ constructor();
141
+ /** Add a new tag */
142
+ addTag(name: string, config?: Partial<(typeof this.tags)["error"]>): this;
143
+ /** Set style for a tag */
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;
135
149
  }
150
+ export declare const Utilities: UtilitiesClass;
151
+ export {};
@@ -1,308 +1,58 @@
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
- import JSTC from "../jstc/index.js";
68
- JSTC.addCustomHandler("NodeJS Process", (p) => {
69
- return (p &&
70
- typeof p === "object" &&
71
- typeof p.pid === "number" &&
72
- typeof p.cwd === "function" &&
73
- typeof p.exit === "function");
74
- });
75
- //#endregion
76
- // -------------------------------------------------------------------------------------------------------
77
- //#region The Main Class
78
- /**
79
- * # CLI
80
- * @classdesc The main class for **CLI**.
81
- * @example
82
- * import * as process from "node:process"
83
- * import {CLI} from "@briklab/lib/cli-john"
84
- * const cli = new CLI(process)
85
- * cli.run()
86
- */
87
- export class CLI {
88
- /**
89
- * ## CLI: Constructor
90
- * @param {NodeJS.Process} process - **The main process**
91
- * @constructor
92
- * @constructs CLI
93
- * @example
94
- * import * as process from "node:process"
95
- * import {CLI} from "@briklab/lib/cli-john"
96
- * const cli = new CLI(process)
97
- * cli.run()
98
- */
99
- constructor(process) {
100
- _CLI_instances.add(this);
101
- _CLI_commands.set(this, []);
102
- _CLI_onCmdFunctions.set(this, []);
103
- _CLI_process.set(this, void 0);
104
- _CLI_ErrorClass.set(this, class extends CLIErrors {
105
- constructor(message) {
106
- super(message);
107
- this.setName = "CLI";
108
- }
109
- });
110
- if (!JSTC.for([process]).check(["NodeJS Process"])) {
111
- 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!");
112
- }
113
- __classPrivateFieldSet(this, _CLI_process, process, "f");
114
- }
115
- /**
116
- * ### CLI.command
117
- * create a new command in a CLI.
118
- *
119
- * @param {string} name
120
- */
121
- command(name) {
122
- if (!JSTC.for([name]).check(["string"])) {
123
- __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.");
124
- name = String(name);
125
- }
126
- let c = new CLI.Command(name);
127
- let f = __classPrivateFieldGet(this, _CLI_commands, "f").findIndex((a) => a.name === name);
128
- if (f !== -1)
129
- __classPrivateFieldGet(this, _CLI_commands, "f")[f] = c;
130
- else
131
- __classPrivateFieldGet(this, _CLI_commands, "f").push(c);
132
- return c;
133
- }
134
- on(event, func) {
135
- if (!JSTC.for([event, func]).check(["string", "function"]))
136
- 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.");
137
- switch (event.toLowerCase()) {
138
- case "command":
139
- __classPrivateFieldGet(this, _CLI_onCmdFunctions, "f").push(func);
140
- break;
141
- default:
142
- __classPrivateFieldGet(this, _CLI_instances, "m", _CLI_createWarn).call(this, "Invalid event in CLI.on", "Please enter a valid event from CLI.ValidEvents (array)");
143
- }
144
- }
145
- run() {
146
- let { options, commandArgs, command, failed } = __classPrivateFieldGet(this, _CLI_instances, "m", _CLI_figureOutCommand).call(this);
147
- if (failed)
148
- return;
149
- for (let i = 0; i < __classPrivateFieldGet(this, _CLI_onCmdFunctions, "f").length; i++) {
150
- __classPrivateFieldGet(this, _CLI_onCmdFunctions, "f")[i]({ options, commandArgs, command });
151
- }
152
- }
153
- }
154
- _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() {
155
- // for eg. we have nodepath filepath cli build
156
- let [, , ...commands] = __classPrivateFieldGet(this, _CLI_process, "f").argv; // now its cli build. clear
157
- if (commands.length === 0)
158
- return { options: [], command: "", commandArgs: [], failed: true };
159
- let command = __classPrivateFieldGet(this, _CLI_commands, "f").find((a) => a.name === commands[0]); // find the command
160
- if (!command)
161
- return { options: [], command: "", commandArgs: [], failed: true }; // command not found?
162
- let commandArgs = [];
163
- const args = commands.slice(1);
164
- for (let i = 0; i < args.length; i++) {
165
- let arg = args[i];
166
- if (arg.startsWith("--"))
167
- break;
168
- commandArgs.push(arg);
169
- }
170
- 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]
171
- let options = [];
172
- for (let i = 0; i < leftover.length; i++) {
173
- const opt = leftover[i];
174
- if (!opt.startsWith("--"))
175
- continue;
176
- const values = [];
177
- for (let j = i + 1; j < leftover.length; j++) {
178
- if (leftover[j].startsWith("--"))
179
- break;
180
- values.push(leftover[j]);
181
- }
182
- options.push({ option: opt, arguments: values });
183
- }
184
- return {
185
- options,
186
- commandArgs,
187
- command,
188
- failed: false,
189
- };
190
- }, _CLI_createErr = function _CLI_createErr(message, hint) {
191
- return new (__classPrivateFieldGet(this, _CLI_ErrorClass, "f"))(`${message}
192
- Hint: ${hint}`);
193
- }, _CLI_createWarn = function _CLI_createWarn(message, hint, otherMessage) {
194
- return console.warn(`[Class CLI] ${message}
195
- Hint: ${hint}
196
- ${otherMessage}`);
197
- };
198
- //#endregion
199
- // -------------------------------------------------------------------------------------------------------
200
- //#region Error Class
201
- class CLIErrors extends Error {
202
- constructor(message) {
203
- super(message);
204
- this.name = `[] @briklab/lib/cli-john`;
205
- Error.captureStackTrace(this, CLIErrors);
206
- }
207
- set setName(name) {
208
- this.name = `[${name}] @briklab/lib/cli-john`;
209
- }
210
- }
211
- (function (CLI) {
212
- var _Command_instances, _Command_name, _Command_createWarn, _Command_options;
213
- CLI.ValidEvents = [
214
- "command"
215
- ];
216
- /**
217
- * ## CLI.Command
218
- * A command in a CLI Command
219
- */
220
- class Command {
221
- /**
222
- * ### Command Constructor
223
- * @param name The name of the command
224
- * @constructor
225
- */
226
- constructor(name) {
227
- _Command_instances.add(this);
228
- _Command_name.set(this, void 0);
229
- _Command_options.set(this, []);
230
- __classPrivateFieldSet(this, _Command_name, name, "f");
231
- return this;
232
- }
233
- /**
234
- * The name of the Command
235
- * @returns {string}
236
- */
237
- get name() {
238
- return __classPrivateFieldGet(this, _Command_name, "f");
239
- }
240
- /**
241
- * the metadata of the Command
242
- * @returns {object}
243
- */
244
- get metadata() {
245
- let metadata = {
246
- options: __classPrivateFieldGet(this, _Command_options, "f").map((a) => a.metadata),
247
- name: this.name,
248
- };
249
- return metadata;
250
- }
251
- option(name) {
252
- if (!JSTC.for([name]).check(["string"])) {
253
- __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");
254
- name = String(name);
255
- }
256
- let o = new CLI.Command.Option(name);
257
- let f = __classPrivateFieldGet(this, _Command_options, "f").findIndex((a) => a.name === name);
258
- if (f !== -1)
259
- __classPrivateFieldGet(this, _Command_options, "f")[f] = o;
260
- else
261
- __classPrivateFieldGet(this, _Command_options, "f").push(o);
262
- return o;
263
- }
264
- }
265
- _Command_name = new WeakMap(), _Command_options = new WeakMap(), _Command_instances = new WeakSet(), _Command_createWarn = function _Command_createWarn(message, hint, otherMessage) {
266
- return console.warn(`[Class CLI.Command] ${message}
267
- Hint: ${hint}
268
- ${otherMessage}`);
269
- };
270
- CLI.Command = Command;
271
- })(CLI || (CLI = {}));
272
- //#endregion
273
- // -------------------------------------------------------------------------------------------------------
274
- //#region CLI.Command.Option
275
- (function (CLI) {
276
- var Command;
277
- (function (Command) {
278
- var _Option_name;
279
- /**
280
- * ## CLI.Command.Option
281
- * A option for a CLI.Command
282
- */
283
- class Option {
284
- get metadata() {
285
- let metadata = {
286
- name: `${__classPrivateFieldGet(this, _Option_name, "f")}`, // <-- Templates TO NOT reference the actual variable
287
- };
288
- return metadata;
289
- }
290
- constructor(name) {
291
- _Option_name.set(this, void 0);
292
- __classPrivateFieldSet(this, _Option_name, name, "f");
293
- return this;
294
- }
295
- get name() {
296
- return __classPrivateFieldGet(this, _Option_name, "f");
297
- }
298
- }
299
- _Option_name = new WeakMap();
300
- Command.Option = Option;
301
- })(Command = CLI.Command || (CLI.Command = {}));
302
- })(CLI || (CLI = {}));
303
- //#endregion
304
- // -------------------------------------------------------------------------------------------------------
305
- //#region TODO
306
- // TODO: Wire Options to Commands
307
- // TODO: Create metadata getter-s in both commands and options
308
- //#endregion
1
+ var Ot=Object.create;var tt=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var qt=Object.getOwnPropertyNames;var Pt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var h=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var Ut=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of qt(e))!At.call(i,n)&&n!==t&&tt(i,n,{get:()=>e[n],enumerable:!(r=Lt(e,n))||r.enumerable});return i};var Ft=(i,e,t)=>(t=i!=null?Ot(Pt(i)):{},Ut(e||!i||!i.__esModule?tt(t,"default",{value:i,enumerable:!0}):t,i));var Oe=h(it=>{var rt={};rt.StyleSheet=function(){this.parentStyleSheet=null};it.StyleSheet=rt.StyleSheet});var R=h(st=>{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};st.CSSRule=d.CSSRule});var ne=h(nt=>{var b={CSSStyleDeclaration:j().CSSStyleDeclaration,CSSRule:R().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},a=new b.CSSStyleRule,l,S="",u;u=i.charAt(e);e++)switch(u){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+=u;break;case"{":t==="selector"&&(a.selectorText=s.trim(),s="",t="name");break;case":":t==="name"?(l=s.trim(),s="",t="value"):s+=u;break;case"!":t==="value"&&i.indexOf("!important",e)===e?(S="important",e+=9):s+=u;break;case";":t==="value"?(a.style.setProperty(l,s.trim(),S),S="",s="",t="name"):s+=u;break;case"}":if(t==="value")a.style.setProperty(l,s.trim(),S),S="",s="";else{if(t==="name")break;s+=u}t="selector";break;default:s+=u;break}return a};nt.CSSStyleRule=b.CSSStyleRule});var oe=h(ot=>{var w={StyleSheet:Oe().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};ot.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 Le=h(lt=>{var T={CSSRule:R().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}}});lt.CSSImportRule=T.CSSImportRule});var V=h(ut=>{var I={CSSRule:R().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};ut.CSSGroupingRule=I.CSSGroupingRule});var G=h(St=>{var L={CSSRule:R().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="";St.CSSConditionRule=L.CSSConditionRule});var de=h(ct=>{var E={CSSRule:R().CSSRule,CSSGroupingRule:V().CSSGroupingRule,CSSConditionRule:G().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}});ct.CSSMediaRule=E.CSSMediaRule});var ge=h(ht=>{var q={CSSRule:R().CSSRule,CSSGroupingRule:V().CSSGroupingRule,CSSConditionRule:G().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("")+"}"}});ht.CSSSupportsRule=q.CSSSupportsRule});var qe=h(ft=>{var M={CSSStyleDeclaration:j().CSSStyleDeclaration,CSSRule:R().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+"}"}});ft.CSSFontFaceRule=M.CSSFontFaceRule});var Pe=h(pt=>{var P={CSSRule:R().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("")+"}"}});pt.CSSHostRule=P.CSSHostRule});var Ce=h(dt=>{var $={CSSRule:R().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+"} "}});dt.CSSKeyframeRule=$.CSSKeyframeRule});var ye=h(gt=>{var A={CSSRule:R().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 Ae=h(Ct=>{var me={};me.CSSValue=function(){};me.CSSValue.prototype={constructor:me.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}};Ct.CSSValue=me.CSSValue});var Ue=h(yt=>{var k={CSSValue:Ae().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 a;return n?a={error:n}:a={idx:e,expression:r},a};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 a="css expression error: unfinished comment in expression!";return{error:a}}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),a=o.match(/\\+$/);if(!a||a[0]%2===0)break;r=n}var l=i.indexOf(`
10
+ `,e+1);return l<n&&(n=s),n};yt.CSSValueExpression=k.CSSValueExpression});var Fe=h(mt=>{var Re={};Re.MatcherList=function(){this.length=0};Re.MatcherList.prototype={constructor:Re.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=Re.MatcherList});var He=h(Rt=>{var O={CSSRule:R().CSSRule,MatcherList:Fe().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("")+"}"}});Rt.CSSDocumentRule=O.CSSDocumentRule});var he=h(bt=>{var c={};c.parse=function(e){for(var t=0,r="before-selector",n,s="",o=0,a={selector:!0,value:!0,"value-parenthesis":!0,atRule:!0,"importRule-begin":!0,importRule:!0,atBlock:!0,conditionBlock:!0,"documentRule-begin":!0},l=new c.CSSStyleSheet,S=l,u,_=[],U=!1,Ze,Me,z="",y,Q,ee,te,re,D,W,le,Xe=/@(-(?:\w+-)+)?keyframes/g,ie=function($t){var ze=e.substring(0,t).split(`
11
+ `),Qe=ze.length,et=ze.pop().length+1,ce=new Error($t+" (line "+Qe+", char "+et+")");throw ce.line=Qe,ce.char=et,ce.styleSheet=l,ce},m;m=e.charAt(t);t++)switch(m){case" ":case" ":case"\r":case`
12
+ `:case"\f":a[r]&&(s+=m);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+=m,r==="importRule-begin"&&(s+=" ",r="importRule");break;case"@":if(e.indexOf("@-moz-document",t)===t){r="documentRule-begin",W=new c.CSSDocumentRule,W.__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,le=new c.CSSHostRule,le.__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{Xe.lastIndex=t;var ue=Xe.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+=m;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(),u&&_.push(u),S=u=Q,Q.parentStyleSheet=l,s="",r="before-selector"):r==="conditionBlock"?(ee.conditionText=s.trim(),u&&_.push(u),S=u=ee,ee.parentStyleSheet=l,s="",r="before-selector"):r==="hostRule-begin"?(u&&_.push(u),S=u=le,le.parentStyleSheet=l,s="",r="before-selector"):r==="fontFaceRule-begin"?(u&&(re.parentRule=u),re.parentStyleSheet=l,y=re,s="",r="before-name"):r==="keyframesRule-begin"?(D.name=s.trim(),u&&(_.push(u),D.parentRule=u),D.parentStyleSheet=l,S=u=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"&&(W.matcher.matcherText=s.trim(),u&&(_.push(u),W.parentRule=u),S=u=W,W.parentStyleSheet=l,s="",r="before-selector");break;case":":r==="name"?(Me=s.trim(),s="",r="before-value"):s+=m;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+=m;else r==="value-parenthesis"&&o++,s+=m;break;case")":r==="value-parenthesis"&&(o--,o===0&&(r="value")),s+=m;break;case"!":r==="value"&&e.indexOf("!important",t)===t?(z="important",t+=9):s+=m;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=l,te.cssText=s+m,l.cssRules.push(te),s="",r="before-selector";break;default:s+=m;break}break;case"}":switch(r){case"value":y.style.setProperty(Me,s.trim(),z),z="";case"before-name":case"name":y.__ends=t+1,u&&(y.parentRule=u),y.parentStyleSheet=l,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(u||ie("Unexpected }"),U=_.length>0;_.length>0;){if(u=_.pop(),u.constructor.name==="CSSMediaRule"||u.constructor.name==="CSSSupportsRule"){Ze=S,S=u,S.cssRules.push(Ze);break}_.length===0&&(U=!1)}U||(S.__ends=t+1,l.cssRules.push(S),S=l,u=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+=m;break}return l};bt.parse=c.parse;c.CSSStyleSheet=oe().CSSStyleSheet;c.CSSStyleRule=ne().CSSStyleRule;c.CSSImportRule=Le().CSSImportRule;c.CSSGroupingRule=V().CSSGroupingRule;c.CSSMediaRule=de().CSSMediaRule;c.CSSConditionRule=G().CSSConditionRule;c.CSSSupportsRule=ge().CSSSupportsRule;c.CSSFontFaceRule=qe().CSSFontFaceRule;c.CSSHostRule=Pe().CSSHostRule;c.CSSStyleDeclaration=j().CSSStyleDeclaration;c.CSSKeyframeRule=Ce().CSSKeyframeRule;c.CSSKeyframesRule=ye().CSSKeyframesRule;c.CSSValueExpression=Ue().CSSValueExpression;c.CSSDocumentRule=He().CSSDocumentRule});var j=h(vt=>{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))}};vt.CSSStyleDeclaration=B.CSSStyleDeclaration;B.parse=he().parse});var xt=h(wt=>{var be={CSSStyleSheet:oe().CSSStyleSheet,CSSRule:R().CSSRule,CSSStyleRule:ne().CSSStyleRule,CSSGroupingRule:V().CSSGroupingRule,CSSConditionRule:G().CSSConditionRule,CSSMediaRule:de().CSSMediaRule,CSSSupportsRule:ge().CSSSupportsRule,CSSStyleDeclaration:j().CSSStyleDeclaration,CSSKeyframeRule:Ce().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],a=t.cssRules[n]=new o.constructor,l=o.style;if(l){for(var S=a.style=new be.CSSStyleDeclaration,u=0,_=l.length;u<_;u++){var U=S[u]=l[u];S[U]=l[U],S._importants[U]=l.getPropertyPriority(U)}S.length=l.length}o.hasOwnProperty("keyText")&&(a.keyText=o.keyText),o.hasOwnProperty("selectorText")&&(a.selectorText=o.selectorText),o.hasOwnProperty("mediaText")&&(a.mediaText=o.mediaText),o.hasOwnProperty("conditionText")&&(a.conditionText=o.conditionText),o.hasOwnProperty("cssRules")&&(a.cssRules=i(o).cssRules)}return t};wt.clone=be.clone});var _t=h(f=>{"use strict";f.CSSStyleDeclaration=j().CSSStyleDeclaration;f.CSSRule=R().CSSRule;f.CSSGroupingRule=V().CSSGroupingRule;f.CSSConditionRule=G().CSSConditionRule;f.CSSStyleRule=ne().CSSStyleRule;f.MediaList=pe().MediaList;f.CSSMediaRule=de().CSSMediaRule;f.CSSSupportsRule=ge().CSSSupportsRule;f.CSSImportRule=Le().CSSImportRule;f.CSSFontFaceRule=qe().CSSFontFaceRule;f.CSSHostRule=Pe().CSSHostRule;f.StyleSheet=Oe().StyleSheet;f.CSSStyleSheet=oe().CSSStyleSheet;f.CSSKeyframesRule=ye().CSSKeyframesRule;f.CSSKeyframeRule=Ce().CSSKeyframeRule;f.MatcherList=Fe().MatcherList;f.CSSDocumentRule=He().CSSDocumentRule;f.CSSValue=Ae().CSSValue;f.CSSValueExpression=Ue().CSSValueExpression;f.parse=he().parse;f.clone=xt().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,Ht=class{constructor(){se.set(this,{Array:i=>Array.isArray(i),"string[]":i=>Array.isArray(i)&&i.every(e=>typeof e=="string")})}for(i){return Array.isArray(i)||(console.warn(`[JSTC.for] @briklab/lib/jstc: Invalid first argument!
13
+ Hint: The first argument must be a array.
14
+ Using [givenValue] as fallback`),i=[i]),{check:e=>{if(Array.isArray(e)||(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`),e=[e]),i.length<e.length)return!1;for(let t=0;t<e.length;t++){let r=i[t],n=e[t],s=Array.isArray(n)?n:[n],o=!1;for(let a of s){let l=typeof a=="string"?a.split("|"):[a];for(let S of l)if(typeof S=="function"){if(r instanceof S){o=!0;break}}else if(typeof S=="string"&&$e(this,se,"f")[S]){if($e(this,se,"f")[S](r)){o=!0;break}}else if(typeof r===S){o=!0;break}if(o)break}if(!o)return!1}return!0}}}addCustomHandler(i,e){typeof i=="string"&&typeof e=="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`),i=String(i),e=()=>!1),$e(this,se,"f")[i]=e}};se=new WeakMap;var Dt=new Ht,g=Dt;var Ne=Ft(_t(),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)},C,De,ve,we,kt,je,Ve,Tt={red:"#ff0000",blue:"#0000ff",green:"#00ff00",yellow:"#ffff00",orange:"#ffa500",black:"#000000",white:"#ffffff",gray:"#808080"},J=class i{constructor(e){if(C.add(this),this.r=0,this.g=0,this.b=0,this.a=1,typeof e=="string")v(this,C,"m",kt).call(this,e);else if("r"in e&&"g"in e&&"b"in e)this.r=v(this,C,"m",ve).call(this,e.r),this.g=v(this,C,"m",ve).call(this,e.g),this.b=v(this,C,"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,C,"m",je).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,C,"m",we).call(this,this.r)}${v(this,C,"m",we).call(this,this.g)}${v(this,C,"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,C,"m",Ve).call(this,this.r,this.g,this.b);return`hsl(${e}, ${t}%, ${r}%)`}hsla(){let{h:e,s:t,l:r}=v(this,C,"m",Ve).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,C,"m",De).call(this,this.r,this.g,this.b)}m`}ansi256Bg(){return`\x1B[48;5;${v(this,C,"m",De).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}`}};C=new WeakSet,De=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=l=>Math.round(l/255*5),s=n(e),o=n(t),a=n(r);return 16+36*s+6*o+a},ve=function(e){return Math.max(0,Math.min(255,e))},we=function(e){return e.toString(16).padStart(2,"0")},kt=function(e){if(e=e.trim().toLowerCase(),Tt[e]&&(e=Tt[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,C,"m",je).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.`)},je=function(e,t,r){t/=100,r/=100;let n=a=>(a+e/30)%12,s=t*Math.min(r,1-r),o=a=>r-s*Math.max(-1,Math.min(n(a)-3,Math.min(9-n(a),1)));return{r:Math.round(o(0)*255),g:Math.round(o(8)*255),b:Math.round(o(4)*255)}},Ve=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,a=0,l=(n+s)/2;if(n!==s){let S=n-s;switch(a=l>.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(a*100),l:Math.round(l*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,It,Et,F,H,ke=class{constructor(e){Te.add(this),_e.set(this,void 0),F.set(this,void 0),g.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,F,e,"f"),xe(this,_e,new Ne.CSSStyleDeclaration,"f")}generate(){let e=x(this,_e,"f"),t=x(this,F,"f"),r=Object.keys(t),n=Object.values(t);for(let s=0;s<r.length;s++){let o=r[s],a=n[s];if(a==null){console.warn(`[InlineStyle.generate] @briklab/lib/stylesheet: Skipping property "${o}" with ${String(a)} value. Hint: avoid null/undefined style values.`);continue}typeof a!="string"&&(console.warn(`[InlineStyle.generate] @briklab/lib/stylesheet: Non-string style value for "${o}" (type=${typeof a}). Coercing to string.`),a=String(a)),e.setProperty(o,a)}return e.cssText}get text(){return this.generate()}get ansi(){let e=x(this,F,"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 g.for([e]).check(["object"])?(xe(this,F,{...x(this,F,"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(!g.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 Ne.CSSStyleDeclaration;t.cssText=x(this,Te,"m",Et).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(!g.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,F,"f")[r]}return this}applyTo(e){return g.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,F=new WeakMap,Te=new WeakSet,It=function(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)},Et=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 a=o[0].trim(),l=o.slice(1).join(":").trim();if(!a||!l){console.warn(`[InlineStyle.#convertKeysToValidCSS] @briklab/lib/stylesheet: Skipping empty property or value in rule: "${s}".`);continue}r+=`${x(this,Te,"m",It).call(this,a)}:${l};`}return r};var Y=ke,Ie=class{constructor(){H.set(this,void 0),xe(this,H,{},"f")}set(e,t){return g.for([e,t]).check(["string","object"])?t instanceof ke?(x(this,H,"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(!g.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,H,"f")[e]}remove(e){return g.for([e]).check(["string"])?(delete x(this,H,"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,H,"f")){let r=x(this,H,"f")[t];r&&(e+=`${t} { ${r.text} }
37
+ `)}return e.trim()}toString(){return this.generate()}};H=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)},Ye=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},K,Z,ae,Mt,Ee,Ke,We,Ge;g.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(K.add(this),Z.set(this,[]),ae.set(this,[]),Ee.set(this,void 0),Ke.set(this,class extends Be{constructor(t){super(t),this.setName="CLI"}}),!g.for([e]).check(["NodeJS Process"]))throw p(this,K,"m",We).call(this,"Invalid First Argument!","You must pass a valid NodeJS process (imported from node:process) while constructing a CLI Class!");Ye(this,Ee,e,"f")}command(e){g.for([e]).check(["string"])||(p(this,K,"m",Ge).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(!g.for([e,t]).check(["string","function"]))throw p(this,K,"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,ae,"f").push(t):p(this,K,"m",Ge).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,K,"m",Mt).call(this);if(!n)for(let s=0;s<p(this,ae,"f").length;s++)p(this,ae,"f")[s]({options:e,commandArgs:t,command:r})}};Z=new WeakMap,ae=new WeakMap,Ee=new WeakMap,Ke=new WeakMap,K=new WeakSet,Mt=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(a=>a.name===e[0]);if(!t)return{options:[],command:"",commandArgs:[],failed:!0};let r=[],n=e.slice(1);for(let a=0;a<n.length;a++){let l=n[a];if(l.startsWith("--"))break;r.push(l)}let s=n.slice(r.length),o=[];for(let a=0;a<s.length;a++){let l=s[a];if(!l.startsWith("--"))continue;let S=[];for(let u=a+1;u<s.length&&!s[u].startsWith("--");u++)S.push(s[u]);o.push({option:l,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}`)},Ge=function(e,t,r){return console.warn(`[Class CLI] ${e}
39
+ Hint: ${t}
40
+ ${r}`)};var Be=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(a){return e.add(this),t.set(this,void 0),n.set(this,[]),Ye(this,t,a,"f"),this}get name(){return p(this,t,"f")}get metadata(){return{options:p(this,n,"f").map(l=>l.metadata),name:this.name}}option(a){g.for([a]).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"),a=String(a));let l=new i.Command.Option(a),S=p(this,n,"f").findIndex(u=>u.name===a);return S!==-1?p(this,n,"f")[S]=l:p(this,n,"f").push(l),l}}t=new WeakMap,n=new WeakMap,e=new WeakSet,r=function(a,l,S){return console.warn(`[Class CLI.Command] ${a}
41
+ Hint: ${l}
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),Ye(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={}));g.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 Je=class{constructor(){this.styleSheet=new Ie,this.tags={},this.addTag("error",{tag:"ERROR",showErrorInTag:!1,paddingLeft:1,paddingRight:1}),this.addTag("warning",{tag:"WARNING",showErrorInTag:!0,paddingLeft:1,paddingRight:1}),this.addTag("info",{tag:"INFO",showErrorInTag:!0,paddingLeft:1,paddingRight:1}),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={}){g.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 g.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){g.for([e,t]).check(["string","string"])||(console.warn(`[UtilitiesClass.log] @briklab/lib/cli-john: Invalid Arguments!
49
+ Hint: The first argument must be a string and the second argument must be a string
50
+ Using String(argument1) and String(argument2) as fallback`),e=String(e),t=String(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),a=" ".repeat(r.paddingRight);if(typeof process<"u"&&typeof process.stdout<"u"&&!!process.stdout.isTTY){let S=n?.ansi??"",u=N.RESET;r.showErrorInTag?console.log("["+S+`${o}${r.tag}${a}`+u+"]: "+t):console.log(S+`[${o}${r.tag}${a}]`+u+`: ${t}`)}else r.showErrorInTag?console.log(`[%c${o}${r.tag}${a}%c]: ${t}`,s):console.log(`%c[${o}${r.tag}${a}]%c: ${t}`,s)}error(e){return typeof e!="string"&&(console.warn(`[UtilitiesClass.error] Invalid First Argument!
52
+ Hint: The first argument must be a string.
53
+ Using String(firstArgument) as fallback`),e=String(e)),this.log("error",e),this}warning(e){return typeof e!="string"&&(console.warn(`[UtilitiesClass.warning] Invalid First Argument!
54
+ Hint: The first argument must be a string.
55
+ Using String(firstArgument) as fallback`),e=String(e)),this.log("warning",e),this}info(e){return typeof e!="string"&&(console.warn(`[UtilitiesClass.info] Invalid First Argument!
56
+ Hint: The first argument must be a string.
57
+ Using String(firstArgument) as fallback`),e=String(e)),this.log("info",e),this}},mr=new Je;export{X as CLI,mr as Utilities};
58
+ //# sourceMappingURL=index.js.map