UNPKG

qcobjects

Version:

QCObjects is an Open-source framework that empowers full-stack developers to make micro-services and micro-frontends into an N-Tier architecture.

1,514 lines (1,484 loc) 225 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw Error('Dynamic require of "' + x + '" is not supported'); }); var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require2() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); // src/is_raw_class.ts var __is_raw_class__; var init_is_raw_class = __esm({ "src/is_raw_class.ts"() { "use strict"; __is_raw_class__ = /* @__PURE__ */ __name((o_c) => { return !!(typeof o_c === "function" && o_c.toString().startsWith("class")); }, "__is_raw_class__"); } }); // src/ObjectName.ts var ObjectName; var init_ObjectName = __esm({ "src/ObjectName.ts"() { "use strict"; ObjectName = /* @__PURE__ */ __name((o) => { let ret = ""; if (typeof o === "function" && Object.hasOwn(o, "name") && o.name !== "") { ret = o.name; } else if (typeof o !== "undefined" && typeof o.constructor === "function" && o.constructor.name !== "") { ret = o.constructor.name; } else if (typeof o !== "undefined" && typeof o.constructor === "object") { ret = o.constructor.toString().replace(/\[(.*?)\]/g, "$1").split(" ").slice(1).join(""); } return ret; }, "ObjectName"); } }); // src/getType.ts var __getType__; var init_getType = __esm({ "src/getType.ts"() { "use strict"; init_is_raw_class(); init_ObjectName(); __getType__ = /* @__PURE__ */ __name(function __getType__2(o_c) { let _ret_ = ""; switch (true) { case (typeof o_c === "object" && (!!o_c.constructor && !!o_c.constructor.name) && o_c.constructor.name !== ""): _ret_ = o_c.constructor.name; break; case (typeof o_c === "function" && !!o_c.name): _ret_ = o_c.name; break; case (__is_raw_class__(o_c) && !!o_c.name): _ret_ = o_c.name; break; case (!!o_c && !!o_c.__classType && o_c.__classType !== ""): _ret_ = o_c.__classType; break; case (!!o_c && !!o_c.__definition && !!o_c.__definition.__classType && o_c.__definition.__classType !== ""): _ret_ = o_c.__definition.__classType; break; default: _ret_ = ObjectName(o_c); break; } return _ret_; }, "__getType__"); } }); // src/make_global.ts var __make_global__; var init_make_global = __esm({ "src/make_global.ts"() { "use strict"; init_top(); __make_global__ = /* @__PURE__ */ __name((f) => { if (!!f && !!f.name) { if (typeof _top !== "undefined" && typeof f !== "undefined" && _top !== null && !Object.hasOwn(_top, f.name)) { set(f.name, f); } else if (typeof global !== "undefined") { global[f.name] = f; } else if (typeof globalThis !== "undefined") { globalThis[f.name] = f; } } }, "__make_global__"); } }); // src/PrimaryCollections.ts var _QC_CLASSES, _QC_PACKAGES, _QC_PACKAGES_IMPORTED, _QC_READY_LISTENERS, __register_class__, get_QC_CLASS, _get_packages_names, getPackagesNamesList, getPackagesList, getClassesList, getClassesNamesList, set_QC_PACKAGE; var init_PrimaryCollections = __esm({ "src/PrimaryCollections.ts"() { "use strict"; init_getType(); init_make_global(); _QC_CLASSES = {}; _QC_PACKAGES = {}; _QC_PACKAGES_IMPORTED = []; _QC_READY_LISTENERS = []; __register_class__ = /* @__PURE__ */ __name(function(_class_, __namespace) { const __classType = __getType__(_class_); let name = _class_.name || __classType; if (name.toLowerCase() === "function") { name = __classType; } if (typeof _class_.__definition === "undefined") { _class_.__definition = {}; } _class_.__definition.__classType = __classType; if (typeof __namespace !== "undefined") { _class_.__definition.__namespace = __namespace; } _QC_CLASSES[name] = _class_; __make_global__(_class_); return _QC_CLASSES[name]; }, "__register_class__"); get_QC_CLASS = /* @__PURE__ */ __name((name) => { return _QC_CLASSES[name]; }, "get_QC_CLASS"); _get_packages_names = /* @__PURE__ */ __name(function(_packages) { let _keys = []; for (const _k of Object.keys(_packages)) { if (typeof _packages[_k] !== "undefined" && typeof _packages[_k] !== "function" && Object.hasOwn(_packages[_k], "length") && _packages[_k].length > 0) { _keys.push(_k); _keys = _keys.concat(_get_packages_names(_packages[_k])); } } return _keys; }, "_get_packages_names"); getPackagesNamesList = /* @__PURE__ */ __name(() => { return _get_packages_names(_QC_PACKAGES); }, "getPackagesNamesList"); getPackagesList = /* @__PURE__ */ __name(() => { return [...getPackagesNamesList()].map((packagename) => { const _classesList = _QC_PACKAGES[packagename]; let _ret_ = void 0; if (_classesList) { _ret_ = { packageName: packagename, classesList: _classesList.filter(function() { return true; }) }; } return _ret_; }).filter(function(_p) { return typeof _p !== "undefined"; }); }, "getPackagesList"); getClassesList = /* @__PURE__ */ __name(() => { let _classesList = []; [...getPackagesList()].forEach(function(_package_element) { _classesList = _classesList.concat(_package_element.classesList.map( (_class_element) => { return { packageName: _package_element.packageName, className: `${_package_element.packageName}.${__getType__(_class_element)}`, classFactory: _class_element }; } )); return _package_element; }); return _classesList; }, "getClassesList"); getClassesNamesList = /* @__PURE__ */ __name(() => { return [...getClassesList()].map((_class_element) => { return _class_element.className; }); }, "getClassesNamesList"); set_QC_PACKAGE = /* @__PURE__ */ __name((packageName, _qc_packages) => { _QC_PACKAGES[packageName] = _qc_packages; }, "set_QC_PACKAGE"); } }); // src/Export.ts var Export; var init_Export = __esm({ "src/Export.ts"() { "use strict"; init_make_global(); Export = /* @__PURE__ */ __name(function(f) { return __make_global__(f); }, "Export"); Export.prototype.toString = function() { return "Export(function or symbol) { [QCObjects native code] }"; }; } }); // src/_import_.ts async function _import_(name) { logger.debug(`Importing ${name}...`); function isPackage(name2) { logger.debug(`Validating if ${name2} is a package name...`); return !name2.startsWith(".") && !name2.startsWith("/") && !name2.includes("/"); } __name(isPackage, "isPackage"); try { const hasExtension = /\.[^/\\]+$/.test(name); if (!hasExtension && !isPackage(name)) { logger.debug(`${name} does not have an extension and is not a package. Adding js extension.`); name += ".js"; } const m = await import(name); return m; } catch (error) { logger.warn(`Failed to load module: ${error}`); } } var init_import = __esm({ "src/_import_.ts"() { "use strict"; init_Logger(); __name(_import_, "_import_"); } }); // src/platform.ts var isDeno, isBrowser, isNodeCommonJS, deno_require, _require_, is_phonegap; var init_platform = __esm({ "src/platform.ts"() { "use strict"; init_import(); init_Logger(); isDeno = typeof window !== "undefined" && "Deno" in window; isBrowser = typeof window !== "undefined" && typeof window.self !== "undefined" && window === window.self && !isDeno; isNodeCommonJS = typeof module !== "undefined"; deno_require = /* @__PURE__ */ __name((name) => { }, "deno_require"); _require_ = /* @__PURE__ */ __name((name) => { return isDeno ? deno_require(name) : ((name2) => { let r; try { (async () => { r = await _import_(name2); })().then((m) => { r = m && m.default || m; }).catch((e) => { logger.warn(`An error ocurred: ${e}`); }); } catch (e) { logger.debug(`An error ocurred importing module. ${e}`); r = { export: {} }; } return r; })(name); }, "_require_"); is_phonegap = /* @__PURE__ */ function() { return typeof cordova !== "undefined"; }(); } }); // src/Logger.ts var Logger, logger; var init_Logger = __esm({ "src/Logger.ts"() { "use strict"; init_Export(); init_platform(); Logger = class { static { __name(this, "Logger"); } debugEnabled = true; infoEnabled = true; warnEnabled = true; debug(message) { if (this.debugEnabled) { console.log("\x1B[35m%s\x1B[0m", `[DEBUG][${performance.now().toLocaleString()}] ${message}`); } } info(message) { let color; if (this.infoEnabled) { if (isBrowser) { color = "\x1B[103m%s\x1B[0m"; } else { color = "\x1B[33m%s\x1B[0m"; } console.info(color, `[INFO][${performance.now().toLocaleString()}] ${message}`); } } warn(message) { if (this.warnEnabled) { console.warn("\x1B[31m%s\x1B[0m", `[WARN][${performance.now().toLocaleString()}] ${message}`); } } }; logger = new Logger(); Export(logger); } }); // src/Cast.ts var _Cast, _CastProps; var init_Cast = __esm({ "src/Cast.ts"() { "use strict"; init_Logger(); _Cast = /* @__PURE__ */ __name(function(obj_source, obj_dest) { for (const v in obj_source) { if (typeof obj_source[v] !== "undefined") { try { obj_dest[v] = obj_source[v]; } catch (e) { logger.debug(`An error ocurred: ${e}.`); logger.warn(`Unable to cast ${(typeof obj_source).toString()}.${typeof v.toString()} to ${(typeof obj_dest).toString()}.${typeof v.toString()}`); } } } return obj_dest; }, "_Cast"); _CastProps = /* @__PURE__ */ __name(function(obj_source, obj_dest, _ignoreError = true) { for (const v in obj_source) { if (typeof obj_source[v] !== "undefined" && typeof obj_source[v] !== "function") { try { obj_dest[v] = obj_source[v]; } catch (e) { if (!_ignoreError) { logger.debug(`An error ocurred: ${e}.`); } } } else if (typeof obj_source[v] === "function") { try { obj_dest[v] = obj_source[v].bind(obj_dest); } catch (e) { logger.warn(e); } } } return obj_dest; }, "_CastProps"); } }); // src/DOMCreateElement.ts var _DOMCreateElement, ComplexTypeCall, _DOMCreateComplexElement; var init_DOMCreateElement = __esm({ "src/DOMCreateElement.ts"() { "use strict"; init_platform(); _DOMCreateElement = /* @__PURE__ */ __name(function(elementName, props, children) { let _ret_; if (isBrowser) { _ret_ = _DOMCreateComplexElement(elementName, props, children); } else { _ret_ = {}; } return _ret_; }, "_DOMCreateElement"); ComplexTypeCall = /* @__PURE__ */ __name((_type, { props, children }) => { return _type({ props, children }); }, "ComplexTypeCall"); _DOMCreateComplexElement = /* @__PURE__ */ __name((_type, props, children) => { if (typeof _type !== "string") { return ComplexTypeCall(_type, { props, children }); } const element = document.createElement(_type); if (props) { Object.entries(props).forEach(([key, value]) => { if (typeof value === "string" || typeof value === "number") { element.setAttribute(key, value.toString()); } else if (typeof value === "function" && key.toLowerCase().startsWith("on")) { element.addEventListener(key.slice(2).toLowerCase(), value.bind(element)); } }); } if (Array.isArray(children)) { children.filter((child) => child instanceof Node).forEach((child) => { element.appendChild(child); }); } else if (children instanceof Node) { element.appendChild(children); } else if (typeof children === "string") { element.innerHTML = children; } return element; }, "_DOMCreateComplexElement"); } }); // src/IncrementInstanceID.ts var __instanceID, IncrementInstanceID; var init_IncrementInstanceID = __esm({ "src/IncrementInstanceID.ts"() { "use strict"; __instanceID = 0; IncrementInstanceID = /* @__PURE__ */ __name(() => { __instanceID = typeof __instanceID === "undefined" || __instanceID === null ? 0 : __instanceID + 1; }, "IncrementInstanceID"); } }); // src/introspection.ts var _protected_code_, _methods_; var init_introspection = __esm({ "src/introspection.ts"() { "use strict"; _protected_code_ = /* @__PURE__ */ __name((_) => { const __oldtoString = typeof _.prototype !== "undefined" ? _.prototype.toString : function() { return ""; }; if (typeof _.prototype !== "undefined") { _.prototype.toString = function() { const _protected_symbols = [ "__qcobjects__", "__qcobjects_sdk__", "__loaded__", "ComplexStorageCache", "css", "append", "attachIn", "debug", "info", "warn", "QC_Append", "set", "get", "done", "componentDone", "_new_", "__new__", "Class", "ClassFactory", "New", "Export", "Package", "Import", "subelements", "componentLoader", "buildComponents", "Controller", "View", "VO", "Service", "serviceLoader", "JSONService", "ConfigService", "SourceJS", "SourceCSS", "ArrayList", "ArrayCollection", "Effect", "Timer", "sum", "avg", "table", "max", "min", "range", "matrix", "matrix2d", "matrix3d", "unique", "uniqueId", "shortCode", "NamespaceRef" ]; let _ret_; if (_protected_symbols.includes(this.name)) { _ret_ = this.name + "{ [QCObjects native code] }"; } else { _ret_ = __oldtoString.call(this); } return _ret_; }; } }, "_protected_code_"); _protected_code_(Function); _methods_ = /* @__PURE__ */ __name(function(_) { const _m = []; for (const i in _) { if ((typeof _[i]).toLowerCase() === "function") { _m.push(_[i]); } } return _m; }, "_methods_"); } }); // src/Package.ts var Package; var init_Package = __esm({ "src/Package.ts"() { "use strict"; init_is_raw_class(); init_PrimaryCollections(); Package = /* @__PURE__ */ __name((namespace, classes = []) => { if (Object.hasOwn(_QC_PACKAGES, namespace) && typeof _QC_PACKAGES[namespace] !== "undefined" && typeof _QC_PACKAGES[namespace] !== "string" && Object.hasOwn(_QC_PACKAGES[namespace], "length") && _QC_PACKAGES[namespace].length > 0 && typeof classes !== "undefined" && Object.hasOwn(classes, "length") && classes.length > 0) { classes.forEach((_class_) => { __register_class__(_class_, namespace); }); set_QC_PACKAGE(namespace, _QC_PACKAGES[namespace].concat(classes)); } else if (typeof classes !== "undefined" && typeof classes !== "undefined" && Object.hasOwn(classes, "length") && classes.length > 0) { classes.forEach((_class_) => { __register_class__(_class_, namespace); }); set_QC_PACKAGE(namespace, classes); } else if (__is_raw_class__(classes)) { if (typeof classes.__definition === "undefined") { classes.__definition = {}; } classes.__definition.__namespace = namespace; classes.__namespace = namespace; __register_class__(classes, namespace); set_QC_PACKAGE(namespace, [classes]); } else { throw new Error(`An error ocurred. It was not possible to add classes to ${namespace}.`); } return Object.hasOwn(_QC_PACKAGES, namespace) ? _QC_PACKAGES[namespace] : []; }, "Package"); } }); // src/InheritClass.ts var InheritClass; var init_InheritClass = __esm({ "src/InheritClass.ts"() { "use strict"; init_Logger(); init_IncrementInstanceID(); init_Cast(); init_DOMCreateElement(); init_getType(); init_introspection(); init_is_a(); init_platform(); init_PrimaryCollections(); init_Package(); InheritClass = class { static { __name(this, "InheritClass"); } __definition; _body; get body() { return this._body; } set body(value) { this._body = value; } childs; __instanceID; constructor(_o_) { if (typeof _o_ !== "undefined" && typeof _o_.__definition !== "undefined") { this.__definition = { ..._o_.__definition }; } const self2 = this; if (typeof _o_ !== "undefined" && _o_ !== null) { Object.keys(_o_).filter(function(k) { return isNaN(k) && !["__instanceID", "__classType", "__definition"].includes(k); }).forEach(function(key) { if (typeof self2[key] === "function") { self2[key] = _o_[key].bind(self2); } else { self2[key] = _o_[key]; } }); } IncrementInstanceID(); if (!self2.__instanceID) { Object.defineProperty(self2, "__instanceID", { value: __instanceID, writable: false }); } if (typeof self2.__definition !== "undefined") { Object.keys(self2.__definition).filter(function(k) { return isNaN(k) && !["name", "__instanceID", "__classType", "__definition"].includes(k); }).forEach(function(key) { if (typeof self2.__definition[key] === "function") { self2[key] = self2.__definition[key].bind(self2); } else { self2[key] = self2.__definition[key]; } }); } _methods_(_QC_CLASSES[self2.__classType]).map(function(m) { self2[m.name] = m.bind(self2); return m; }); _methods_(self2.__definition).map(function(m) { self2[m.name] = m.bind(self2); return m; }); if (self2.body) { if (typeof self2.__definition === "undefined" || !Object.hasOwn(self2.__definition, "body") || typeof self2.__definition.body === "undefined") { try { if (isBrowser) { self2.body = _DOMCreateElement(self2.__definition.__classType); } else { self2.body = {}; } } catch (e) { logger.debug(`An error ocurred: ${e}.`); self2.body = {}; } } else if (Object.hasOwn(self2.__definition, "body")) { self2.body = self2.__definition.body; } } try { self2.__new__.call(self2, _o_); if (typeof self2 === "object" && Object.hasOwn(self2, "_new_") && typeof self2._new_.isCalled === "undefined") { try { self2._new_(_o_); self2._new_.isCalled = true; } catch (e) { logger.warn(`${self2.__classType}._new_() failed with error: ${e}`); } } } catch (e) { logger.warn(e); } } static get __classType() { return Object.getPrototypeOf(this.constructor).name; } get __classType() { return this.constructor.name; } static hierarchy(__class__) { const __classType = /* @__PURE__ */ __name(function(o_c) { return Object.hasOwn(o_c, "__classType") ? o_c.__classType : __getType__.call(__class__, o_c); }, "__classType"); const __hierarchy__proto__ = /* @__PURE__ */ __name((c) => { return typeof c !== "undefined" && typeof c.__proto__ !== "undefined" && c.__proto__ !== null ? (__classType(c) !== "" ? [__classType(c)] : []).concat(__hierarchy__proto__(c.__proto__)) : []; }, "__hierarchy__proto__"); if (typeof __class__ === "undefined" || __class__ === null) { __class__ = this; } let __hierarchy = []; __hierarchy.push(__classType(__class__)); __hierarchy = __hierarchy.concat(__hierarchy__proto__(__class__.__proto__)); return __hierarchy; } __namespace; __new__(_o_) { _CastProps(_o_, this); } // eslint-disable-next-line no-unused-vars _new_(_o_) { } static getParentClass() { return Object.getPrototypeOf(this.prototype.constructor); } getParentClass() { return this.constructor.getParentClass(); } static getClass() { return Object.getPrototypeOf(this.constructor); } getClass() { return this.constructor.getClass(); } css(_css) { if (typeof this.body !== "undefined" && typeof this?.body !== "string" && typeof this?.body?.style !== "undefined") { logger.debug("body style"); if (this.body) { this.body.style = _Cast(_css, this?.body?.style); } } return typeof this.body !== "string" ? this?.body?.style : {}; } hierarchy() { const __instance__ = this; return this.constructor.hierarchy(__instance__); } append(_child) { const child = _child || this.body; logger.debug("append: start"); if (is_a(child, "Component")) { logger.debug("append: child is a Component"); logger.debug(`appending the body of ${child.name}`); } if (typeof this.body !== "undefined") { logger.debug("append element"); if (arguments.length > 0) { logger.debug("append to element"); if (typeof this.body !== "string") { if (typeof this.body?.append !== "undefined") { this?.body?.append(child); } else { throw Error("body.append is undefined. That means the body is not well formed."); } } else { this.append(child); } if (typeof this.childs === "undefined") { this.childs = []; } this.childs.push(child); } else { if (isBrowser) { logger.debug("append to body"); document.body.append(child); } } } } attachIn(tag) { if (isBrowser) { const tags = document.subelements(tag); for (let i = 0, j = tags.length; i < j; i++) { tags[i].append(this); } } else { throw new Error("attachIn not yet implemented for non browser platforms"); } } }; Package("com.qcobjects", [InheritClass]); } }); // src/isQCObjects.ts var isQCObjects_Object, isQCObjects_Class; var init_isQCObjects = __esm({ "src/isQCObjects.ts"() { "use strict"; init_InheritClass(); isQCObjects_Object = /* @__PURE__ */ __name(function(_) { return !!(typeof _ === "object" && Object.hasOwn(_, "__classType") && !!_.__instanceID && Object.hasOwn(_, "__definition") && typeof _.__definition !== "undefined") || _ instanceof InheritClass; }, "isQCObjects_Object"); isQCObjects_Class = /* @__PURE__ */ __name(function(_) { return !!(typeof _ === "function" && !_.__instanceID && !!_.__definition && typeof _.__definition !== "undefined" && !!_.__definition.__classType) || _.prototype instanceof InheritClass; }, "isQCObjects_Class"); } }); // src/is_a.ts var is_a; var init_is_a = __esm({ "src/is_a.ts"() { "use strict"; init_getType(); init_isQCObjects(); init_ObjectName(); is_a = /* @__PURE__ */ __name((obj, typeName) => { return !!(typeof obj !== "undefined" && obj !== null && ((isQCObjects_Class(obj) || isQCObjects_Object(obj)) && obj.hierarchy().includes(typeName) || __getType__(obj) === typeName || ObjectName(obj) === typeName || typeof obj === typeName)); }, "is_a"); } }); // src/is_forbidden_name.ts var __is__forbidden_name__; var init_is_forbidden_name = __esm({ "src/is_forbidden_name.ts"() { "use strict"; __is__forbidden_name__ = /* @__PURE__ */ __name((name) => { return ["__proto__", "prototype", "Object", "Map", "defineProperty", "indexOf", "toString", "__instanceID", "function", "Function"].indexOf(name) !== -1; }, "__is__forbidden_name__"); } }); // src/LegacyCopy.ts var _LegacyCopy; var init_LegacyCopy = __esm({ "src/LegacyCopy.ts"() { "use strict"; init_is_raw_class(); _LegacyCopy = /* @__PURE__ */ __name(function(obj, _ignore) { let _value_; switch (true) { case typeof obj === "string": _value_ = obj; break; case typeof obj === "number": _value_ = obj; break; case typeof obj === "object": _value_ = [{ ...Object.keys(obj).filter((k) => !_ignore?.includes(k)) }].map((k) => { return { [k]: obj[k] }; }).reduce((p, c) => Object.assign(p, c)); break; case typeof obj === "function": _value_ = obj.bind({}); break; case __is_raw_class__(obj): _value_ = class extends obj { static { __name(this, "_value_"); } }; break; default: break; } return _value_; }, "_LegacyCopy"); } }); // src/Class.ts var Class; var init_Class = __esm({ "src/Class.ts"() { "use strict"; init_PrimaryCollections(); init_Cast(); init_DOMCreateElement(); init_getType(); init_IncrementInstanceID(); init_introspection(); init_is_a(); init_is_forbidden_name(); init_LegacyCopy(); init_Logger(); init_platform(); init_top(); Class = /* @__PURE__ */ __name((name, _type, _definition) => { const _types_ = {}; let type, definition; switch (true) { case (!name && !_type && !_definition): return class { }; case (!!name && !_type && !_definition): type = class { static { __name(this, "type"); } }; definition = {}; break; case (!!name && !_type && !!_definition): type = class { static { __name(this, "type"); } }; definition = _definition; break; case (!!name && !!_type && !!_definition): type = _type; definition = _definition; break; default: return class { }; } if (typeof name !== "string") { throw new Error("Class name must be a string"); } if (typeof type !== "function") { throw new Error("Class type must be a function or class"); } if (__is__forbidden_name__(name)) { throw new Error(`${name} is not an allowed word in the name of a class`); } if (typeof type.__definition === "object" && type.__definition && Object.keys(type.__definition).length !== 0) { definition.__definition = Object.assign(_LegacyCopy(type.__definition, ["name"]), type); } _types_[type.name] = type; if (typeof definition === "undefined" || definition === null) { definition = {}; } else { definition = { ...definition }; } if (typeof definition.__instanceID !== "undefined") { delete definition.__instanceID; } _QC_CLASSES[name] = class extends _types_[type.name] { __instanceID; __namespace; __definition = { ...definition }; childs; _body; get body() { return this._body; } set body(value) { this._body = value; } static get __classType() { return Object.getPrototypeOf(this.constructor).name; } get __classType() { return this.constructor.name; } static hierarchy(__class__) { const __classType = /* @__PURE__ */ __name(function(o_c) { return Object.hasOwn(o_c, "__classType") ? o_c.__classType : __getType__.call(__class__, o_c); }, "__classType"); const __hierarchy__proto__ = /* @__PURE__ */ __name((c) => { return typeof c !== "undefined" && typeof c.__proto__ !== "undefined" && c.__proto__ !== null ? (__classType(c) !== "" ? [__classType(c)] : []).concat(__hierarchy__proto__(c.__proto__)) : []; }, "__hierarchy__proto__"); if (typeof __class__ === "undefined" || __class__ === null) { __class__ = this; } let __hierarchy = []; __hierarchy.push(__classType(__class__)); __hierarchy = __hierarchy.concat(__hierarchy__proto__(__class__.__proto__)); return __hierarchy; } static getParentClass() { return Object.getPrototypeOf(this.prototype.constructor); } constructor(_o_) { super(_o_ || {}); const self2 = this; IncrementInstanceID(); if (!self2.__instanceID) { Object.defineProperty(self2, "__instanceID", { value: __instanceID, writable: false }); } if (typeof self2.__definition !== "undefined") { Object.keys(self2.__definition).filter(function(k) { return isNaN(k) && !["name", "__instanceID", "__classType", "__definition"].includes(k); }).forEach(function(key) { if (typeof self2.__definition[key] === "function") { self2[key] = self2.__definition[key].bind(self2); } else { self2[key] = self2.__definition[key]; } }); } _methods_(_QC_CLASSES[self2.__classType]).map(function(m) { self2[m.name] = m.bind(self2); return m; }); _methods_(self2.__definition).map(function(m) { self2[m.name] = m.bind(self2); return m; }); if (self2.body) { if (typeof self2.__definition === "undefined" || !Object.hasOwn(self2.__definition, "body") || typeof self2.__definition.body === "undefined") { try { if (isBrowser) { self2.body = _DOMCreateElement(self2.__definition.__classType); } else { self2.body = {}; } } catch (e) { logger.debug(`An error ocurred: ${e}.`); self2.body = {}; } } else if (Object.hasOwn(self2.__definition, "body")) { self2.body = self2.__definition.body; } } try { if (typeof self2.__new__ === "function") { self2.__new__.call(self2, _o_); } else if (typeof super.__new__ === "function") { self2.__new__ = super.__new__.bind(self2); self2.__new__.call(self2, _o_); } if (typeof self2 === "object" && Object.hasOwn(self2, "_new_") && typeof self2._new_.isCalled === "undefined") { try { self2._new_(_o_); self2._new_.isCalled = true; } catch (e) { logger.warn(`${self2.__classType}._new_() failed with error: ${e}`); } } } catch (e) { logger.warn(e); } } __new__(_o_) { _CastProps(_o_, this); } // eslint-disable-next-line no-unused-vars _new_(_o_) { } getClass() { return Object.getPrototypeOf(this.constructor); } css(_css) { if (typeof this.body !== "undefined" && typeof this?.body !== "string" && typeof this?.body?.style !== "undefined") { logger.debug("body style"); if (this.body) { this.body.style = _Cast(_css, this?.body?.style); } } return typeof this.body !== "string" ? this?.body?.style : {}; } hierarchy() { const __instance__ = this; return this.getClass()?.hierarchy(__instance__); } append(_child) { const child = _child || this.body; logger.debug("append: start"); if (is_a(child, "Component")) { logger.debug("append: child is a Component"); logger.debug(`appending the body of ${child.name}`); } if (typeof this.body !== "undefined") { logger.debug("append element"); if (arguments.length > 0) { logger.debug("append to element"); if (typeof this.body !== "string") { if (typeof this.body?.append !== "undefined") { this?.body?.append(child); } else { throw Error("body.append is undefined. That means the body is not well formed."); } } else { this.append(child); } if (typeof this.childs === "undefined") { this.childs = []; } this.childs.push(child); } else { if (isBrowser) { logger.debug("append to body"); document.body.append(child); } } } } attachIn(tag) { if (isBrowser) { const tags = document.subelements(tag); for (let i = 0, j = tags.length; i < j; i++) { tags[i].append(this); } } else { throw new Error("attachIn not yet implemented for non browser platforms"); } } }; _QC_CLASSES[name] = _CastProps(definition, _QC_CLASSES[name]); _QC_CLASSES[name].__definition = definition; _QC_CLASSES[name].__definition.__classType = name; _top[name] = _QC_CLASSES[name]; return _QC_CLASSES[name]; }, "Class"); if (typeof Class.prototype !== "undefined") { Class.prototype.toString = function() { return "Class(name, type, definition) { [QCObjects native code] }"; }; } } }); // src/ClassFactory.ts var ClassFactory; var init_ClassFactory = __esm({ "src/ClassFactory.ts"() { "use strict"; init_is_raw_class(); init_PrimaryCollections(); ClassFactory = /* @__PURE__ */ __name((className) => { let _classFactory; if (typeof className === "undefined" || className === null) { throw Error("You need to pass a parameter {className}"); } if (className !== null && className.indexOf(".") !== -1) { const packageName = className.split(".").slice(0, className.split(".").length - 1).join("."); const _className = className.split(".").slice(-1).join(""); const _package = _QC_PACKAGES[packageName] || []; const packageClasses = _package.filter((classFactory) => { return __is_raw_class__(classFactory); }).reverse(); if (packageClasses.length > 0) { _classFactory = packageClasses[0]; } else { throw Error(`Class ${_className} not found. Found classes: ${JSON.stringify(packageClasses)} in package ${packageName}`); } } else if (className !== null) { _classFactory = get_QC_CLASS(className); if (typeof _classFactory === "undefined") { throw new Error(`${className} is undefined.`); } } else { throw Error(`className is null. Unable to retrieve the class factory. Not found in: ${Object.keys(_QC_CLASSES).join("\n")}`); } return _classFactory; }, "ClassFactory"); } }); // src/Base64.ts var Base64; var init_Base64 = __esm({ "src/Base64.ts"() { "use strict"; Base64 = class _Base64 { static { __name(this, "Base64"); } static _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; static encode(e) { let t = ""; let n, r, i, s, o, u, a; let f = 0; e = _Base64._utf8_encode(e); while (f < e.length) { n = e.charCodeAt(f++); r = e.charCodeAt(f++); i = e.charCodeAt(f++); s = n >> 2; o = (n & 3) << 4 | r >> 4; u = (r & 15) << 2 | i >> 6; a = i & 63; if (isNaN(r)) { u = a = 64; } else if (isNaN(i)) { a = 64; } t = t + this._keyStr.charAt(s) + this._keyStr.charAt(o) + this._keyStr.charAt(u) + this._keyStr.charAt(a); } return t; } static decode(e) { let t = ""; let n, r, i; let s, o, u, a; let f = 0; e = e.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s = this._keyStr.indexOf(e.charAt(f++)); o = this._keyStr.indexOf(e.charAt(f++)); u = this._keyStr.indexOf(e.charAt(f++)); a = this._keyStr.indexOf(e.charAt(f++)); n = s << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u !== 64) { t = t + String.fromCharCode(r); } if (a !== 64) { t = t + String.fromCharCode(i); } } t = _Base64._utf8_decode(t); return t; } static _utf8_encode(e) { e = e.replace(/rn/g, "n"); let t = ""; for (let n = 0; n < e.length; n++) { const r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128); } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128); } } return t; } static _utf8_decode(e) { let t = ""; let n = 0; let r = 0; let c2 = 0; let c3; while (n < e.length) { r = e.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); n++; } else if (r > 191 && r < 224) { c2 = e.charCodeAt(n + 1); t += String.fromCharCode((r & 31) << 6 | c2 & 63); n += 2; } else { c2 = e.charCodeAt(n + 1); c3 = e.charCodeAt(n + 2); t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63); n += 3; } } return t; } }; } }); // src/basePath.ts import process2 from "node:process"; var _basePath_, setBasePath; var init_basePath = __esm({ "src/basePath.ts"() { "use strict"; init_platform(); _basePath_ = function() { let _basePath = ""; if (isBrowser) { const baseURI = document.baseURI.split("?")[0].split("/"); baseURI.pop(); _basePath = baseURI.join("/") + "/"; } else { if (typeof process2 !== "undefined") { _basePath = `${process2.cwd()}/`; } else { _basePath = ""; } } return _basePath; }(); setBasePath = /* @__PURE__ */ __name((value) => { _basePath_ = value; }, "setBasePath"); } }); // src/DataStringify.ts var _DataStringify; var init_DataStringify = __esm({ "src/DataStringify.ts"() { "use strict"; init_LegacyCopy(); _DataStringify = /* @__PURE__ */ __name((data) => { const getCircularReplacer = /* @__PURE__ */ __name(function() { const seen = /* @__PURE__ */ new WeakSet(); let _level = 0; return function(key, value) { if (typeof value === "object" && value !== null) { if (seen.has(value)) { _level += 1; return _level <= 3 ? _LegacyCopy(value) : null; } seen.add(value); } return value; }; }, "getCircularReplacer"); return JSON.stringify(data, getCircularReplacer()); }, "_DataStringify"); } }); // src/domain.ts var _domain_; var init_domain = __esm({ "src/domain.ts"() { "use strict"; _domain_ = typeof location !== "undefined" && location.hostname !== "" ? location.hostname : "localhost"; } }); // src/New.ts var New; var init_New = __esm({ "src/New.ts"() { "use strict"; New = /* @__PURE__ */ __name(function(__class__, args = {}) { args = arguments.length > 1 ? args : {}; return typeof __class__ === "undefined" ? new Object() : new __class__(args); }, "New"); New.prototype.toString = function() { return "New(QCObjectsClassName, args) { [QCObjects native code] }"; }; } }); // src/secretKey.ts var _secretKey; var init_secretKey = __esm({ "src/secretKey.ts"() { "use strict"; init_platform(); _secretKey = isBrowser ? location.host : "secret"; } }); // src/Crypt.ts var _Crypt, _CryptObject, _DecryptObject; var init_Crypt = __esm({ "src/Crypt.ts"() { "use strict"; init_Base64(); init_DataStringify(); init_InheritClass(); init_Package(); init_secretKey(); _Crypt = class __Crypt extends InheritClass { static { __name(this, "_Crypt"); } string = ""; key = ""; // eslint-disable-next-line no-unused-vars encrypt(_string_, key) { throw new Error("Method not implemented."); } // eslint-disable-next-line no-unused-vars decrypt(_string_, key) { throw new Error("Method not implemented."); } last_string = ""; last_key = ""; construct = false; _new_(o) { const string = o.string; let key = Object.hasOwn(o, "key") ? o.key : ""; this.__new__(o); key = key === "" ? this.__instanceID.toString() : key; this.last_key = key; this.last_string = string; this.construct = true; } _encrypt() { const string = this.string; const key = this.key; let result = ""; let char; let keychar; for (let i = 0; i < string.length; i++) { char = string.substr(i, 1); keychar = key.substr(i % key.length - 1, 1); char = String.fromCharCode(char.charCodeAt(0) + keychar.charCodeAt(0)); result += char; } this.last_string = Base64.encode(result); return this.last_string; } _decrypt() { let string = this.string; const key = this.key; let result = ""; let char; let keychar; string = Base64.decode(string); for (let i = 0; i < string.length; i++) { char = string.substr(i, 1); keychar = key.substr(i % key.length - 1, 1); char = String.fromCharCode(char.charCodeAt(0) - keychar.charCodeAt(0)); result += char; } this.last_string = result; return this.last_string; } static encrypt(string, key) { const crypt = new __Crypt({ string, key: key !== "" ? key : "12345678ABC" }); return crypt._encrypt(); } static decrypt(string, key) { const crypt = new __Crypt({ string, key: key !== "" ? key : "12345678ABC" }); return crypt._decrypt(); } }; _CryptObject = /* @__PURE__ */ __name(function(o) { return _Crypt.encrypt(_DataStringify(o), _secretKey); }, "_CryptObject"); _DecryptObject = /* @__PURE__ */ __name(function(s) { return s === "" ? {} : JSON.parse(_Crypt.decrypt(s, _secretKey)); }, "_DecryptObject"); Package("com.qcobjects", [_Crypt]); } }); // src/ConfigSettings.ts var ConfigSettings; var init_ConfigSettings = __esm({ "src/ConfigSettings.ts"() { "use strict"; init_basePath(); init_InheritClass(); init_Package(); ConfigSettings = class _ConfigSettings extends InheritClass { static { __name(this, "ConfigSettings"); } _CONFIG = { "relativeImportPath": "", "remoteImportsPath": "", "remoteSDKPath": "https://sdk.qcobjects.dev/", "asynchronousImportsLoad": false, "removePackageScriptAfterLoading": true, "componentsBasePath": "", "delayForReady": 0, "preserveComponentBodyTag": false, "useConfigService": false, "routingWay": "hash", "useSDK": true, "useLocalSDK": false, "basePath": _basePath_ }; static _instance; _CONFIG_ENC = ""; set(name, value) { this._CONFIG[name] = value; } get(name, _defaultValue) { return this._CONFIG[name] || _defaultValue; } static get instance() { if (typeof _ConfigSettings._instance === "undefined") { _ConfigSettings._instance = new _ConfigSettings(); } return _ConfigSettings._instance; } }; Package("com.qcobjects", [ConfigSettings]); } }); // src/CONFIG.ts var CONFIG; var init_CONFIG = __esm({ "src/CONFIG.ts"() { "use strict"; init_basePath(); init_Cast(); init_Crypt(); init_DataStringify(); init_Logger(); init_Processor(); init_secretKey(); init_Package(); init_InheritClass(); init_ConfigSettings(); CONFIG = class _CONFIG extends InheritClass { static { __name(this, "CONFIG"); } get _CONFIG_ENC() { return ConfigSettings.instance._CONFIG_ENC; } get _CONFIG() { return ConfigSettings.instance._CONFIG; } set(name, value) { logger.debug(`CONFIG.set ${name}: ${value}`); if (name === "basePath") { setBasePath(value); } let _conf; try { _conf = function(config) { if (config._CONFIG_ENC === null) { config._CONFIG_ENC = _Crypt.encrypt(_DataStringify({}), _secretKey); } const _protectedEnc = config._CONFIG_ENC.valueOf(); const _protectedConf = config._CONFIG?.valueOf(); return _CastProps(_protectedConf, _DecryptObject(_protectedEnc)); }(ConfigSettings.instance); } catch (e) { _conf = {}; console.error(e); logger.debug("failed to encrypt config"); } _conf[name] = value; ConfigSettings.instance._CONFIG_ENC = _CryptObject(_conf); ConfigSettings.instance.set(name, value); } get(name, _default) { let _value; try { const _conf = function(config) { if (config._CONFIG_ENC === null) { config._CONFIG_ENC = _Crypt.encrypt(_DataStringify({}), _secretKey); } const _protectedEnc = config._CONFIG_ENC.valueOf(); const _protectedConf = config._CONFIG.valueOf(); return _CastProps(_protectedConf, _DecryptObject(_protectedEnc)); }(ConfigSettings.instance); if (typeof _conf[name] !== "unde