(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["VirtualMachine"] = factory();
	else
		root["VirtualMachine"] = factory();
})(global, () => {
return /******/ (() => { // webpackBootstrap
/******/ 	var __webpack_modules__ = ({

/***/ "./src/dispatch/shared-dispatch.js"
/*!*****************************************!*\
  !*** ./src/dispatch/shared-dispatch.js ***!
  \*****************************************/
(module, __unused_webpack_exports, __webpack_require__) {

const log = __webpack_require__(/*! ../util/log */ "./src/util/log.js");

/**
 * @typedef {object} DispatchCallMessage - a message to the dispatch system representing a service method call
 * @property {*} responseId - send a response message with this response ID. See {@link DispatchResponseMessage}
 * @property {string} service - the name of the service to be called
 * @property {string} method - the name of the method to be called
 * @property {Array|undefined} args - the arguments to be passed to the method
 */

/**
 * @typedef {object} DispatchResponseMessage - a message to the dispatch system representing the results of a call
 * @property {*} responseId - a copy of the response ID from the call which generated this response
 * @property {*|undefined} error - if this is truthy, then it contains results from a failed call (such as an exception)
 * @property {*|undefined} result - if error is not truthy, then this contains the return value of the call (if any)
 */

/**
 * @typedef {DispatchCallMessage|DispatchResponseMessage} DispatchMessage
 * Any message to the dispatch system.
 */

/**
 * The SharedDispatch class is responsible for dispatch features shared by
 * {@link CentralDispatch} and {@link WorkerDispatch}.
 */
class SharedDispatch {
  constructor() {
    /**
     * List of callback registrations for promises waiting for a response from a call to a service on another
     * worker. A callback registration is an array of [resolve,reject] Promise functions.
     * Calls to local services don't enter this list.
     * @type {Array.<Function[]>}
     */
    this.callbacks = [];

    /**
     * The next response ID to be used.
     * @type {int}
     */
    this.nextResponseId = 0;
  }

  /**
   * Call a particular method on a particular service, regardless of whether that service is provided locally or on
   * a worker. If the service is provided by a worker, the `args` will be copied using the Structured Clone
   * algorithm, except for any items which are also in the `transfer` list. Ownership of those items will be
   * transferred to the worker, and they should not be used after this call.
   * @example
   *      dispatcher.call('vm', 'setData', 'cat', 42);
   *      // this finds the worker for the 'vm' service, then on that worker calls:
   *      vm.setData('cat', 42);
   * @param {string} service - the name of the service.
   * @param {string} method - the name of the method.
   * @param {*} [args] - the arguments to be copied to the method, if any.
   * @returns {Promise} - a promise for the return value of the service method.
   */
  call(service, method) {
    for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      args[_key - 2] = arguments[_key];
    }
    return this.transferCall(service, method, null, ...args);
  }

  /**
   * Call a particular method on a particular service, regardless of whether that service is provided locally or on
   * a worker. If the service is provided by a worker, the `args` will be copied using the Structured Clone
   * algorithm, except for any items which are also in the `transfer` list. Ownership of those items will be
   * transferred to the worker, and they should not be used after this call.
   * @example
   *      dispatcher.transferCall('vm', 'setData', [myArrayBuffer], 'cat', myArrayBuffer);
   *      // this finds the worker for the 'vm' service, transfers `myArrayBuffer` to it, then on that worker calls:
   *      vm.setData('cat', myArrayBuffer);
   * @param {string} service - the name of the service.
   * @param {string} method - the name of the method.
   * @param {Array} [transfer] - objects to be transferred instead of copied. Must be present in `args` to be useful.
   * @param {*} [args] - the arguments to be copied to the method, if any.
   * @returns {Promise} - a promise for the return value of the service method.
   */
  transferCall(service, method, transfer) {
    try {
      const {
        provider,
        isRemote
      } = this._getServiceProvider(service);
      if (provider) {
        for (var _len2 = arguments.length, args = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
          args[_key2 - 3] = arguments[_key2];
        }
        if (isRemote) {
          return this._remoteTransferCall(provider, service, method, transfer, ...args);
        }

        // TODO: verify correct `this` after switching from apply to spread
        // eslint-disable-next-line prefer-spread
        const result = provider[method].apply(provider, args);
        return Promise.resolve(result);
      }
      return Promise.reject(new Error("Service not found: ".concat(service)));
    } catch (e) {
      return Promise.reject(e);
    }
  }

  /**
   * Check if a particular service lives on another worker.
   * @param {string} service - the service to check.
   * @returns {boolean} - true if the service is remote (calls must cross a Worker boundary), false otherwise.
   * @private
   */
  _isRemoteService(service) {
    return this._getServiceProvider(service).isRemote;
  }

  /**
   * Like {@link call}, but force the call to be posted through a particular communication channel.
   * @param {object} provider - send the call through this object's `postMessage` function.
   * @param {string} service - the name of the service.
   * @param {string} method - the name of the method.
   * @param {*} [args] - the arguments to be copied to the method, if any.
   * @returns {Promise} - a promise for the return value of the service method.
   */
  _remoteCall(provider, service, method) {
    for (var _len3 = arguments.length, args = new Array(_len3 > 3 ? _len3 - 3 : 0), _key3 = 3; _key3 < _len3; _key3++) {
      args[_key3 - 3] = arguments[_key3];
    }
    return this._remoteTransferCall(provider, service, method, null, ...args);
  }

  /**
   * Like {@link transferCall}, but force the call to be posted through a particular communication channel.
   * @param {object} provider - send the call through this object's `postMessage` function.
   * @param {string} service - the name of the service.
   * @param {string} method - the name of the method.
   * @param {Array} [transfer] - objects to be transferred instead of copied. Must be present in `args` to be useful.
   * @param {*} [args] - the arguments to be copied to the method, if any.
   * @returns {Promise} - a promise for the return value of the service method.
   */
  _remoteTransferCall(provider, service, method, transfer) {
    for (var _len4 = arguments.length, args = new Array(_len4 > 4 ? _len4 - 4 : 0), _key4 = 4; _key4 < _len4; _key4++) {
      args[_key4 - 4] = arguments[_key4];
    }
    return new Promise((resolve, reject) => {
      const responseId = this._storeCallbacks(resolve, reject);

      /** @TODO: remove this hack! this is just here so we don't try to send `util` to a worker */
      if (args.length > 0 && typeof args[args.length - 1].yield === 'function') {
        args.pop();
      }
      if (transfer) {
        provider.postMessage({
          service,
          method,
          responseId,
          args
        }, transfer);
      } else {
        provider.postMessage({
          service,
          method,
          responseId,
          args
        });
      }
    });
  }

  /**
   * Store callback functions pending a response message.
   * @param {Function} resolve - function to call if the service method returns.
   * @param {Function} reject - function to call if the service method throws.
   * @returns {*} - a unique response ID for this set of callbacks. See {@link _deliverResponse}.
   * @protected
   */
  _storeCallbacks(resolve, reject) {
    const responseId = this.nextResponseId++;
    this.callbacks[responseId] = [resolve, reject];
    return responseId;
  }

  /**
   * Deliver call response from a worker. This should only be called as the result of a message from a worker.
   * @param {int} responseId - the response ID of the callback set to call.
   * @param {DispatchResponseMessage} message - the message containing the response value(s).
   * @protected
   */
  _deliverResponse(responseId, message) {
    try {
      const [resolve, reject] = this.callbacks[responseId];
      delete this.callbacks[responseId];
      if (message.error) {
        reject(message.error);
      } else {
        resolve(message.result);
      }
    } catch (e) {
      log.error("Dispatch callback failed: ".concat(JSON.stringify(e)));
    }
  }

  /**
   * Handle a message event received from a connected worker.
   * @param {Worker} worker - the worker which sent the message, or the global object if running in a worker.
   * @param {MessageEvent} event - the message event to be handled.
   * @protected
   */
  _onMessage(worker, event) {
    /** @type {DispatchMessage} */
    const message = event.data;
    message.args = message.args || [];
    let promise;
    if (message.service) {
      if (message.service === 'dispatch') {
        promise = this._onDispatchMessage(worker, message);
      } else {
        promise = this.call(message.service, message.method, ...message.args);
      }
    } else if (typeof message.responseId === 'undefined') {
      log.error("Dispatch caught malformed message from a worker: ".concat(JSON.stringify(event)));
    } else {
      this._deliverResponse(message.responseId, message);
    }
    if (promise) {
      if (typeof message.responseId === 'undefined') {
        log.error("Dispatch message missing required response ID: ".concat(JSON.stringify(event)));
      } else {
        promise.then(result => worker.postMessage({
          responseId: message.responseId,
          result
        }), error => worker.postMessage({
          responseId: message.responseId,
          error
        }));
      }
    }
  }

  /**
   * Fetch the service provider object for a particular service name.
   * @abstract
   * @param {string} service - the name of the service to look up
   * @returns {{provider:(object|Worker), isRemote:boolean}} - the means to contact the service, if found
   * @protected
   */
  _getServiceProvider(service) {
    throw new Error("Could not get provider for ".concat(service, ": _getServiceProvider not implemented"));
  }

  /**
   * Handle a call message sent to the dispatch service itself
   * @abstract
   * @param {Worker} worker - the worker which sent the message.
   * @param {DispatchCallMessage} message - the message to be handled.
   * @returns {Promise|undefined} - a promise for the results of this operation, if appropriate
   * @private
   */
  _onDispatchMessage(worker, message) {
    throw new Error("Unimplemented dispatch message handler cannot handle ".concat(message.method, " method"));
  }
}
module.exports = SharedDispatch;

/***/ },

/***/ "./src/dispatch/worker-dispatch.js"
/*!*****************************************!*\
  !*** ./src/dispatch/worker-dispatch.js ***!
  \*****************************************/
(module, __unused_webpack_exports, __webpack_require__) {

const SharedDispatch = __webpack_require__(/*! ./shared-dispatch */ "./src/dispatch/shared-dispatch.js");
const log = __webpack_require__(/*! ../util/log */ "./src/util/log.js");

/**
 * This class provides a Worker with the means to participate in the message dispatch system managed by CentralDispatch.
 * From any context in the messaging system, the dispatcher's "call" method can call any method on any "service"
 * provided in any participating context. The dispatch system will forward function arguments and return values across
 * worker boundaries as needed.
 * @see {CentralDispatch}
 */
class WorkerDispatch extends SharedDispatch {
  constructor() {
    super();

    /**
     * This promise will be resolved when we have successfully connected to central dispatch.
     * @type {Promise}
     * @see {waitForConnection}
     * @private
     */
    this._connectionPromise = new Promise(resolve => {
      this._onConnect = resolve;
    });

    /**
     * Map of service name to local service provider.
     * If a service is not listed here, it is assumed to be provided by another context (another Worker or the main
     * thread).
     * @see {setService}
     * @type {object}
     */
    this.services = {};
    this._onMessage = this._onMessage.bind(this, self);
    if (typeof self !== 'undefined') {
      self.onmessage = this._onMessage;
    }
  }

  /**
   * @returns {Promise} a promise which will resolve upon connection to central dispatch. If you need to make a call
   * immediately on "startup" you can attach a 'then' to this promise.
   * @example
   *      dispatch.waitForConnection.then(() => {
   *          dispatch.call('myService', 'hello');
   *      })
   */
  get waitForConnection() {
    return this._connectionPromise;
  }

  /**
   * Set a local object as the global provider of the specified service.
   * WARNING: Any method on the provider can be called from any worker within the dispatch system.
   * @param {string} service - a globally unique string identifying this service. Examples: 'vm', 'gui', 'extension9'.
   * @param {object} provider - a local object which provides this service.
   * @returns {Promise} - a promise which will resolve once the service is registered.
   */
  setService(service, provider) {
    if (Object.prototype.hasOwnProperty.call(this.services, service)) {
      log.warn("Worker dispatch replacing existing service provider for ".concat(service));
    }
    this.services[service] = provider;
    return this.waitForConnection.then(() => this._remoteCall(self, 'dispatch', 'setService', service));
  }

  /**
   * Fetch the service provider object for a particular service name.
   * @override
   * @param {string} service - the name of the service to look up
   * @returns {{provider:(object|Worker), isRemote:boolean}} - the means to contact the service, if found
   * @protected
   */
  _getServiceProvider(service) {
    // if we don't have a local service by this name, contact central dispatch by calling `postMessage` on self
    const provider = this.services[service];
    return {
      provider: provider || self,
      isRemote: !provider
    };
  }

  /**
   * Handle a call message sent to the dispatch service itself
   * @override
   * @param {Worker} worker - the worker which sent the message.
   * @param {DispatchCallMessage} message - the message to be handled.
   * @returns {Promise|undefined} - a promise for the results of this operation, if appropriate
   * @protected
   */
  _onDispatchMessage(worker, message) {
    let promise;
    switch (message.method) {
      case 'handshake':
        promise = this._onConnect();
        break;
      case 'terminate':
        // Don't close until next tick, after sending confirmation back
        setTimeout(() => self.close(), 0);
        promise = Promise.resolve();
        break;
      default:
        log.error("Worker dispatch received message for unknown method: ".concat(message.method));
    }
    return promise;
  }
}
module.exports = new WorkerDispatch();

/***/ },

/***/ "./src/extension-support/argument-type.js"
/*!************************************************!*\
  !*** ./src/extension-support/argument-type.js ***!
  \************************************************/
(module) {

/**
 * Block argument types
 * @enum {string}
 */
const ArgumentType = {
  /**
   * Numeric value with angle picker
   */
  ANGLE: 'angle',
  /**
   * Boolean value with hexagonal placeholder
   */
  BOOLEAN: 'Boolean',
  /**
   * Numeric value with color picker
   */
  COLOR: 'color',
  /**
   * Numeric value with text field
   */
  NUMBER: 'number',
  /**
   * String value with text field
   */
  STRING: 'string',
  /**
   * String value with matrix field
   */
  MATRIX: 'matrix',
  /**
   * MIDI note number with note picker (piano) field
   */
  NOTE: 'note',
  /**
   * Inline image on block (as part of the label)
   */
  IMAGE: 'image'
};
module.exports = ArgumentType;

/***/ },

/***/ "./src/extension-support/block-type.js"
/*!*********************************************!*\
  !*** ./src/extension-support/block-type.js ***!
  \*********************************************/
(module) {

/**
 * Types of block
 * @enum {string}
 */
const BlockType = {
  /**
   * Boolean reporter with hexagonal shape
   */
  BOOLEAN: 'Boolean',
  /**
   * A button (not an actual block) for some special action, like making a variable
   */
  BUTTON: 'button',
  /**
   * Command block
   */
  COMMAND: 'command',
  /**
   * Specialized command block which may or may not run a child branch
   * The thread continues with the next block whether or not a child branch ran.
   */
  CONDITIONAL: 'conditional',
  /**
   * Specialized hat block with no implementation function
   * This stack only runs if the corresponding event is emitted by other code.
   */
  EVENT: 'event',
  /**
   * Hat block which conditionally starts a block stack
   */
  HAT: 'hat',
  /**
   * Specialized command block which may or may not run a child branch
   * If a child branch runs, the thread evaluates the loop block again.
   */
  LOOP: 'loop',
  /**
   * General reporter with numeric or string value
   */
  REPORTER: 'reporter'
};
module.exports = BlockType;

/***/ },

/***/ "./src/extension-support/target-type.js"
/*!**********************************************!*\
  !*** ./src/extension-support/target-type.js ***!
  \**********************************************/
(module) {

/**
 * Default types of Target supported by the VM
 * @enum {string}
 */
const TargetType = {
  /**
   * Rendered target which can move, change costumes, etc.
   */
  SPRITE: 'sprite',
  /**
   * Rendered target which cannot move but can change backdrops
   */
  STAGE: 'stage'
};
module.exports = TargetType;

/***/ },

/***/ "./src/util/log.js"
/*!*************************!*\
  !*** ./src/util/log.js ***!
  \*************************/
(module, __unused_webpack_exports, __webpack_require__) {

const {
  Logger
} = __webpack_require__(/*! tslog */ "../../node_modules/tslog/cjs/index.js");
module.exports = new Logger({
  name: 'scratch-vm'
});

/***/ },

/***/ "buffer"
/*!*************************!*\
  !*** external "buffer" ***!
  \*************************/
(module) {

"use strict";
module.exports = require("buffer");

/***/ },

/***/ "../../node_modules/tslog/cjs/BaseLogger.js"
/*!**************************************************!*\
  !*** ../../node_modules/tslog/cjs/BaseLogger.js ***!
  \**************************************************/
(__unused_webpack_module, exports, __webpack_require__) {

"use strict";
/* provided dependency */ var Buffer = __webpack_require__(/*! buffer */ "buffer")["Buffer"];

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.BaseLogger = exports.loggerEnvironment = void 0;
exports.createLoggerEnvironment = createLoggerEnvironment;
const urlToObj_js_1 = __webpack_require__(/*! ./urlToObj.js */ "../../node_modules/tslog/cjs/urlToObj.js");
const metaFormatting_js_1 = __webpack_require__(/*! ./internal/metaFormatting.js */ "../../node_modules/tslog/cjs/internal/metaFormatting.js");
const errorUtils_js_1 = __webpack_require__(/*! ./internal/errorUtils.js */ "../../node_modules/tslog/cjs/internal/errorUtils.js");
const formatTemplate_js_1 = __webpack_require__(/*! ./formatTemplate.js */ "../../node_modules/tslog/cjs/formatTemplate.js");
const util_inspect_polyfill_js_1 = __webpack_require__(/*! ./internal/util.inspect.polyfill.js */ "../../node_modules/tslog/cjs/internal/util.inspect.polyfill.js");
const stackTrace_js_1 = __webpack_require__(/*! ./internal/stackTrace.js */ "../../node_modules/tslog/cjs/internal/stackTrace.js");
const environment_js_1 = __webpack_require__(/*! ./internal/environment.js */ "../../node_modules/tslog/cjs/internal/environment.js");
const jsonStringifyRecursive_js_1 = __webpack_require__(/*! ./internal/jsonStringifyRecursive.js */ "../../node_modules/tslog/cjs/internal/jsonStringifyRecursive.js");
function createLoggerEnvironment() {
    const runtimeInfo = detectRuntimeInfo();
    const meta = createRuntimeMeta(runtimeInfo);
    const usesBrowserStack = runtimeInfo.name === "browser" || runtimeInfo.name === "worker";
    const callerIgnorePatterns = usesBrowserStack
        ? [...(0, stackTrace_js_1.getDefaultIgnorePatterns)(), /node_modules[\\/].*tslog/i]
        : [...(0, stackTrace_js_1.getDefaultIgnorePatterns)(), /node:(?:internal|vm)/i, /\binternal[\\/]/i];
    let cachedCwd;
    const environment = {
        getMeta(logLevelId, logLevelName, stackDepthLevel, hideLogPositionForPerformance, name, parentNames) {
            return Object.assign({}, meta, {
                name,
                parentNames,
                date: new Date(),
                logLevelId,
                logLevelName,
                path: !hideLogPositionForPerformance ? environment.getCallerStackFrame(stackDepthLevel) : undefined,
            });
        },
        getCallerStackFrame(stackDepthLevel, error = new Error()) {
            const frames = (0, stackTrace_js_1.buildStackTrace)(error, (line) => parseStackLine(line));
            if (frames.length === 0) {
                return {};
            }
            const autoIndex = (0, stackTrace_js_1.findFirstExternalFrameIndex)(frames, callerIgnorePatterns);
            const useManualIndex = Number.isFinite(stackDepthLevel) && stackDepthLevel >= 0;
            const resolvedIndex = useManualIndex ? (0, stackTrace_js_1.clampIndex)(stackDepthLevel, frames.length) : (0, stackTrace_js_1.clampIndex)(autoIndex, frames.length);
            return frames[resolvedIndex] ?? {};
        },
        getErrorTrace(error) {
            return (0, stackTrace_js_1.buildStackTrace)(error, (line) => parseStackLine(line));
        },
        isError(value) {
            return isNativeError(value);
        },
        isBuffer(value) {
            return typeof Buffer !== "undefined" && typeof Buffer.isBuffer === "function" ? Buffer.isBuffer(value) : false;
        },
        prettyFormatLogObj(maskedArgs, settings) {
            return maskedArgs.reduce((result, arg) => {
                if (environment.isError(arg)) {
                    result.errors.push(environment.prettyFormatErrorObj(arg, settings));
                }
                else {
                    result.args.push(arg);
                }
                return result;
            }, { args: [], errors: [] });
        },
        prettyFormatErrorObj(error, settings) {
            const stackLines = formatStackFrames(environment.getErrorTrace(error), settings);
            const causeSections = (0, errorUtils_js_1.collectErrorCauses)(error).map((cause, index) => {
                const header = `Caused by (${index + 1}): ${cause.name ?? "Error"}${cause.message ? `: ${cause.message}` : ""}`;
                const frames = formatStackFrames((0, stackTrace_js_1.buildStackTrace)(cause, (line) => parseStackLine(line)), settings);
                return [header, ...frames].join("\n");
            });
            const placeholderValuesError = {
                errorName: ` ${error.name} `,
                errorMessage: formatErrorMessage(error),
                errorStack: [...stackLines, ...causeSections].join("\n"),
            };
            return (0, formatTemplate_js_1.formatTemplate)(settings, settings.prettyErrorTemplate, placeholderValuesError);
        },
        transportFormatted(logMetaMarkup, logArgs, logErrors, logMeta, settings) {
            const prettyLogs = settings.stylePrettyLogs !== false;
            const logErrorsStr = (logErrors.length > 0 && logArgs.length > 0 ? "\n" : "") + logErrors.join("\n");
            const sanitizedMetaMarkup = stripAnsi(logMetaMarkup);
            const metaMarkupForText = prettyLogs ? logMetaMarkup : sanitizedMetaMarkup;
            if (shouldUseCss(prettyLogs)) {
                settings.prettyInspectOptions.colors = false;
                const formattedArgs = formatWithOptionsSafe(settings.prettyInspectOptions, logArgs);
                const cssMeta = logMeta != null ? buildCssMetaOutput(settings, logMeta) : { text: sanitizedMetaMarkup, styles: [] };
                const hasCssMeta = cssMeta.text.length > 0 && cssMeta.styles.length > 0;
                const metaOutput = hasCssMeta ? cssMeta.text : sanitizedMetaMarkup;
                const output = metaOutput + formattedArgs + logErrorsStr;
                if (hasCssMeta) {
                    console.log(output, ...cssMeta.styles);
                }
                else {
                    console.log(output);
                }
                return;
            }
            settings.prettyInspectOptions.colors = prettyLogs;
            const formattedArgs = formatWithOptionsSafe(settings.prettyInspectOptions, logArgs);
            console.log(metaMarkupForText + formattedArgs + logErrorsStr);
        },
        transportJSON(json) {
            console.log((0, jsonStringifyRecursive_js_1.jsonStringifyRecursive)(json));
        },
    };
    if (getNodeEnv() === "test") {
        environment.__resetWorkingDirectoryCacheForTests = () => {
            cachedCwd = undefined;
        };
    }
    return environment;
    function parseStackLine(line) {
        return usesBrowserStack ? parseBrowserStackLine(line) : parseServerStackLine(line);
    }
    function parseServerStackLine(rawLine) {
        if (typeof rawLine !== "string" || rawLine.length === 0) {
            return undefined;
        }
        const trimmedLine = rawLine.trim();
        if (!trimmedLine.includes(" at ") && !trimmedLine.startsWith("at ")) {
            return undefined;
        }
        const line = trimmedLine.replace(/^at\s+/, "");
        let method;
        let location = line;
        const methodMatch = line.match(/^(.*?)\s+\((.*)\)$/);
        if (methodMatch) {
            method = methodMatch[1];
            location = methodMatch[2];
        }
        const sanitizedLocation = location.replace(/^\(/, "").replace(/\)$/, "");
        const withoutQuery = sanitizedLocation.replace(/\?.*$/, "");
        let fileLine;
        let fileColumn;
        let filePathCandidate = withoutQuery;
        const segments = withoutQuery.split(":");
        if (segments.length >= 3 && /^\d+$/.test(segments[segments.length - 1] ?? "")) {
            fileColumn = segments.pop();
            fileLine = segments.pop();
            filePathCandidate = segments.join(":");
        }
        else if (segments.length >= 2 && /^\d+$/.test(segments[segments.length - 1] ?? "")) {
            fileLine = segments.pop();
            filePathCandidate = segments.join(":");
        }
        let normalizedPath = filePathCandidate.replace(/^file:\/\//, "");
        const cwd = getWorkingDirectory();
        if (cwd != null && normalizedPath.startsWith(cwd)) {
            normalizedPath = normalizedPath.slice(cwd.length);
            normalizedPath = normalizedPath.replace(/^[\\/]/, "");
        }
        if (normalizedPath.length === 0) {
            normalizedPath = filePathCandidate;
        }
        const normalizedPathWithoutLine = normalizeFilePath(normalizedPath);
        const effectivePath = normalizedPathWithoutLine.length > 0 ? normalizedPathWithoutLine : normalizedPath;
        const pathSegments = effectivePath.split(/\\|\//);
        const fileName = pathSegments[pathSegments.length - 1];
        const fileNameWithLine = fileName && fileLine ? `${fileName}:${fileLine}` : undefined;
        const filePathWithLine = effectivePath && fileLine ? `${effectivePath}:${fileLine}` : undefined;
        return {
            fullFilePath: sanitizedLocation,
            fileName,
            fileNameWithLine,
            fileColumn,
            fileLine,
            filePath: effectivePath,
            filePathWithLine,
            method,
        };
    }
    function parseBrowserStackLine(line) {
        const href = globalThis.location?.origin;
        if (line == null) {
            return undefined;
        }
        const match = line.match(BROWSER_PATH_REGEX);
        if (!match) {
            return undefined;
        }
        const filePath = match[1]?.replace(/\?.*$/, "");
        if (filePath == null) {
            return undefined;
        }
        const pathParts = filePath.split("/");
        const fileLine = match[2];
        const fileColumn = match[3];
        const fileName = pathParts[pathParts.length - 1];
        return {
            fullFilePath: href ? `${href}${filePath}` : filePath,
            fileName,
            fileNameWithLine: fileName && fileLine ? `${fileName}:${fileLine}` : undefined,
            fileColumn,
            fileLine,
            filePath,
            filePathWithLine: fileLine ? `${filePath}:${fileLine}` : undefined,
            method: undefined,
        };
    }
    function formatStackFrames(frames, settings) {
        return frames.map((stackFrame) => (0, formatTemplate_js_1.formatTemplate)(settings, settings.prettyErrorStackTemplate, { ...stackFrame }, true));
    }
    function formatErrorMessage(error) {
        return Object.getOwnPropertyNames(error)
            .filter((key) => key !== "stack" && key !== "cause")
            .reduce((result, key) => {
            const value = error[key];
            if (typeof value === "function") {
                return result;
            }
            result.push(String(value));
            return result;
        }, [])
            .join(", ");
    }
    function shouldUseCss(prettyLogs) {
        return prettyLogs && (runtimeInfo.name === "browser" || runtimeInfo.name === "worker") && (0, environment_js_1.consoleSupportsCssStyling)();
    }
    function stripAnsi(value) {
        return value.replace(ANSI_REGEX, "");
    }
    function buildCssMetaOutput(settings, metaValue) {
        if (metaValue == null) {
            return { text: "", styles: [] };
        }
        const { template, placeholders } = (0, metaFormatting_js_1.buildPrettyMeta)(settings, metaValue);
        const parts = [];
        const styles = [];
        let lastIndex = 0;
        const placeholderRegex = /{{(.+?)}}/g;
        let match;
        while ((match = placeholderRegex.exec(template)) != null) {
            if (match.index > lastIndex) {
                parts.push(template.slice(lastIndex, match.index));
            }
            const key = match[1];
            const rawValue = placeholders[key] != null ? String(placeholders[key]) : "";
            const tokens = collectStyleTokens(settings.prettyLogStyles?.[key], rawValue);
            const css = tokensToCss(tokens);
            if (css.length > 0) {
                parts.push(`%c${rawValue}%c`);
                styles.push(css, "");
            }
            else {
                parts.push(rawValue);
            }
            lastIndex = placeholderRegex.lastIndex;
        }
        if (lastIndex < template.length) {
            parts.push(template.slice(lastIndex));
        }
        return {
            text: parts.join(""),
            styles,
        };
    }
    function collectStyleTokens(style, value) {
        if (style == null) {
            return [];
        }
        if (typeof style === "string") {
            return [style];
        }
        if (Array.isArray(style)) {
            return style.flatMap((token) => collectStyleTokens(token, value));
        }
        if (typeof style === "object") {
            const normalizedValue = value.trim();
            const nextStyle = style[normalizedValue] ?? style["*"];
            if (nextStyle == null) {
                return [];
            }
            return collectStyleTokens(nextStyle, value);
        }
        return [];
    }
    function tokensToCss(tokens) {
        const seen = new Set();
        const cssParts = [];
        for (const token of tokens) {
            const css = styleTokenToCss(token);
            if (css != null && css.length > 0 && !seen.has(css)) {
                seen.add(css);
                cssParts.push(css);
            }
        }
        return cssParts.join("; ");
    }
    function styleTokenToCss(token) {
        const color = COLOR_TOKENS[token];
        if (color != null) {
            return `color: ${color}`;
        }
        const background = BACKGROUND_TOKENS[token];
        if (background != null) {
            return `background-color: ${background}`;
        }
        switch (token) {
            case "bold":
                return "font-weight: bold";
            case "dim":
                return "opacity: 0.75";
            case "italic":
                return "font-style: italic";
            case "underline":
                return "text-decoration: underline";
            case "overline":
                return "text-decoration: overline";
            case "inverse":
                return "filter: invert(1)";
            case "hidden":
                return "visibility: hidden";
            case "strikethrough":
                return "text-decoration: line-through";
            default:
                return undefined;
        }
    }
    function getWorkingDirectory() {
        if (cachedCwd === undefined) {
            cachedCwd = (0, environment_js_1.safeGetCwd)() ?? null;
        }
        return cachedCwd ?? undefined;
    }
    function shouldCaptureHostname() {
        return runtimeInfo.name === "node" || runtimeInfo.name === "deno" || runtimeInfo.name === "bun";
    }
    function shouldCaptureRuntimeVersion() {
        return runtimeInfo.name === "node" || runtimeInfo.name === "deno" || runtimeInfo.name === "bun";
    }
    function createRuntimeMeta(info) {
        if (info.name === "browser" || info.name === "worker") {
            return {
                runtime: info.name,
                browser: info.userAgent,
            };
        }
        const metaStatic = {
            runtime: info.name,
        };
        if (shouldCaptureRuntimeVersion()) {
            metaStatic.runtimeVersion = info.version ?? "unknown";
        }
        if (shouldCaptureHostname()) {
            metaStatic.hostname = info.hostname ?? "unknown";
        }
        return metaStatic;
    }
    function formatWithOptionsSafe(options, args) {
        try {
            return (0, util_inspect_polyfill_js_1.formatWithOptions)(options, ...args);
        }
        catch {
            return args.map(stringifyFallback).join(" ");
        }
    }
    function stringifyFallback(value) {
        if (typeof value === "string") {
            return value;
        }
        try {
            return JSON.stringify(value);
        }
        catch {
            return String(value);
        }
    }
    function normalizeFilePath(value) {
        if (typeof value !== "string" || value.length === 0) {
            return value;
        }
        const replaced = value.replace(/\\+/g, "\\").replace(/\\/g, "/");
        const hasRootDoubleSlash = replaced.startsWith("//");
        const hasLeadingSlash = replaced.startsWith("/") && !hasRootDoubleSlash;
        const driveMatch = replaced.match(/^[A-Za-z]:/);
        const drivePrefix = driveMatch ? driveMatch[0] : "";
        const withoutDrive = drivePrefix ? replaced.slice(drivePrefix.length) : replaced;
        const segments = withoutDrive.split("/");
        const normalizedSegments = [];
        for (const segment of segments) {
            if (segment === "" || segment === ".") {
                continue;
            }
            if (segment === "..") {
                if (normalizedSegments.length > 0) {
                    normalizedSegments.pop();
                }
                continue;
            }
            normalizedSegments.push(segment);
        }
        let normalized = normalizedSegments.join("/");
        if (hasRootDoubleSlash) {
            normalized = `//${normalized}`;
        }
        else if (hasLeadingSlash) {
            normalized = `/${normalized}`;
        }
        else if (drivePrefix !== "") {
            normalized = `${drivePrefix}${normalized.length > 0 ? `/${normalized}` : ""}`;
        }
        if (normalized.length === 0) {
            return value;
        }
        return normalized;
    }
    function detectRuntimeInfo() {
        if ((0, environment_js_1.isBrowserEnvironment)()) {
            const navigatorObj = globalThis.navigator;
            return {
                name: "browser",
                userAgent: navigatorObj?.userAgent,
            };
        }
        const globalScope = globalThis;
        if (typeof globalScope.importScripts === "function") {
            return {
                name: "worker",
                userAgent: globalScope.navigator?.userAgent,
            };
        }
        const globalAny = globalThis;
        if (globalAny.Bun != null) {
            const bunVersion = globalAny.Bun.version;
            return {
                name: "bun",
                version: bunVersion != null ? `bun/${bunVersion}` : undefined,
                hostname: getEnvironmentHostname(globalAny.process, globalAny.Deno, globalAny.Bun, globalAny.location),
            };
        }
        if (globalAny.Deno != null) {
            const denoHostname = resolveDenoHostname(globalAny.Deno);
            const denoVersion = globalAny.Deno?.version?.deno;
            return {
                name: "deno",
                version: denoVersion != null ? `deno/${denoVersion}` : undefined,
                hostname: denoHostname ?? getEnvironmentHostname(globalAny.process, globalAny.Deno, globalAny.Bun, globalAny.location),
            };
        }
        if (globalAny.process?.versions?.node != null || globalAny.process?.version != null) {
            return {
                name: "node",
                version: globalAny.process?.versions?.node ?? globalAny.process?.version,
                hostname: getEnvironmentHostname(globalAny.process, globalAny.Deno, globalAny.Bun, globalAny.location),
            };
        }
        if (globalAny.process != null) {
            return {
                name: "node",
                version: "unknown",
                hostname: getEnvironmentHostname(globalAny.process, globalAny.Deno, globalAny.Bun, globalAny.location),
            };
        }
        return {
            name: "unknown",
        };
    }
    function getEnvironmentHostname(nodeProcess, deno, bun, location) {
        const processHostname = nodeProcess?.env?.HOSTNAME ?? nodeProcess?.env?.HOST ?? nodeProcess?.env?.COMPUTERNAME;
        if (processHostname != null && processHostname.length > 0) {
            return processHostname;
        }
        const bunHostname = bun?.env?.HOSTNAME ?? bun?.env?.HOST ?? bun?.env?.COMPUTERNAME;
        if (bunHostname != null && bunHostname.length > 0) {
            return bunHostname;
        }
        try {
            const denoEnvGet = deno?.env?.get;
            if (typeof denoEnvGet === "function") {
                const value = denoEnvGet("HOSTNAME");
                if (value != null && value.length > 0) {
                    return value;
                }
            }
        }
        catch {
        }
        if (location?.hostname != null && location.hostname.length > 0) {
            return location.hostname;
        }
        return undefined;
    }
    function resolveDenoHostname(deno) {
        try {
            if (typeof deno?.hostname === "function") {
                const value = deno.hostname();
                if (value != null && value.length > 0) {
                    return value;
                }
            }
        }
        catch {
        }
        const locationHostname = globalThis.location?.hostname;
        if (locationHostname != null && locationHostname.length > 0) {
            return locationHostname;
        }
        return undefined;
    }
    function getNodeEnv() {
        const globalProcess = globalThis?.process;
        return globalProcess?.env?.NODE_ENV;
    }
    function isNativeError(value) {
        if (value instanceof Error) {
            return true;
        }
        if (value != null && typeof value === "object") {
            const objectTag = Object.prototype.toString.call(value);
            if (/\[object .*Error\]/.test(objectTag)) {
                return true;
            }
            const name = value.name;
            if (typeof name === "string" && name.endsWith("Error")) {
                return true;
            }
        }
        return false;
    }
}
const ANSI_REGEX = /\u001b\[[0-9;]*m/g;
const COLOR_TOKENS = {
    black: "#000000",
    red: "#ef5350",
    green: "#66bb6a",
    yellow: "#fdd835",
    blue: "#42a5f5",
    magenta: "#ab47bc",
    cyan: "#26c6da",
    white: "#fafafa",
    blackBright: "#424242",
    redBright: "#ff7043",
    greenBright: "#81c784",
    yellowBright: "#ffe082",
    blueBright: "#64b5f6",
    magentaBright: "#ce93d8",
    cyanBright: "#4dd0e1",
    whiteBright: "#ffffff",
};
const BACKGROUND_TOKENS = {
    bgBlack: "#000000",
    bgRed: "#ef5350",
    bgGreen: "#66bb6a",
    bgYellow: "#fdd835",
    bgBlue: "#42a5f5",
    bgMagenta: "#ab47bc",
    bgCyan: "#26c6da",
    bgWhite: "#fafafa",
    bgBlackBright: "#424242",
    bgRedBright: "#ff7043",
    bgGreenBright: "#81c784",
    bgYellowBright: "#ffe082",
    bgBlueBright: "#64b5f6",
    bgMagentaBright: "#ce93d8",
    bgCyanBright: "#4dd0e1",
    bgWhiteBright: "#ffffff",
};
const BROWSER_PATH_REGEX = /(?:(?:file|https?|global code|[^@]+)@)?(?:file:)?((?:\/[^:/]+){2,})(?::(\d+))?(?::(\d+))?/;
const runtime = createLoggerEnvironment();
exports.loggerEnvironment = runtime;
__exportStar(__webpack_require__(/*! ./interfaces.js */ "../../node_modules/tslog/cjs/interfaces.js"), exports);
class BaseLogger {
    constructor(settings, logObj, stackDepthLevel = Number.NaN) {
        this.logObj = logObj;
        this.stackDepthLevel = stackDepthLevel;
        this.runtime = runtime;
        this.maxErrorCauseDepth = 5;
        this.settings = {
            type: settings?.type ?? "pretty",
            name: settings?.name,
            parentNames: settings?.parentNames,
            minLevel: settings?.minLevel ?? 0,
            argumentsArrayName: settings?.argumentsArrayName,
            hideLogPositionForProduction: settings?.hideLogPositionForProduction ?? false,
            prettyLogTemplate: settings?.prettyLogTemplate ??
                "{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}\t{{logLevelName}}\t{{filePathWithLine}}{{nameWithDelimiterPrefix}}\t",
            prettyErrorTemplate: settings?.prettyErrorTemplate ?? "\n{{errorName}} {{errorMessage}}\nerror stack:\n{{errorStack}}",
            prettyErrorStackTemplate: settings?.prettyErrorStackTemplate ?? "  • {{fileName}}\t{{method}}\n\t{{filePathWithLine}}",
            prettyErrorParentNamesSeparator: settings?.prettyErrorParentNamesSeparator ?? ":",
            prettyErrorLoggerNameDelimiter: settings?.prettyErrorLoggerNameDelimiter ?? "\t",
            stylePrettyLogs: settings?.stylePrettyLogs ?? true,
            prettyLogTimeZone: settings?.prettyLogTimeZone ?? "UTC",
            prettyLogStyles: settings?.prettyLogStyles ?? {
                logLevelName: {
                    "*": ["bold", "black", "bgWhiteBright", "dim"],
                    SILLY: ["bold", "white"],
                    TRACE: ["bold", "whiteBright"],
                    DEBUG: ["bold", "green"],
                    INFO: ["bold", "blue"],
                    WARN: ["bold", "yellow"],
                    ERROR: ["bold", "red"],
                    FATAL: ["bold", "redBright"],
                },
                dateIsoStr: "white",
                filePathWithLine: "white",
                name: ["white", "bold"],
                nameWithDelimiterPrefix: ["white", "bold"],
                nameWithDelimiterSuffix: ["white", "bold"],
                errorName: ["bold", "bgRedBright", "whiteBright"],
                fileName: ["yellow"],
                fileNameWithLine: "white",
            },
            prettyInspectOptions: settings?.prettyInspectOptions ?? {
                colors: true,
                compact: false,
                depth: Infinity,
            },
            metaProperty: settings?.metaProperty ?? "_meta",
            maskPlaceholder: settings?.maskPlaceholder ?? "[***]",
            maskValuesOfKeys: settings?.maskValuesOfKeys ?? ["password"],
            maskValuesOfKeysCaseInsensitive: settings?.maskValuesOfKeysCaseInsensitive ?? false,
            maskValuesRegEx: settings?.maskValuesRegEx,
            prefix: [...(settings?.prefix ?? [])],
            attachedTransports: [...(settings?.attachedTransports ?? [])],
            overwrite: {
                mask: settings?.overwrite?.mask,
                toLogObj: settings?.overwrite?.toLogObj,
                addMeta: settings?.overwrite?.addMeta,
                addPlaceholders: settings?.overwrite?.addPlaceholders,
                formatMeta: settings?.overwrite?.formatMeta,
                formatLogObj: settings?.overwrite?.formatLogObj,
                transportFormatted: settings?.overwrite?.transportFormatted,
                transportJSON: settings?.overwrite?.transportJSON,
            },
        };
        this.captureStackForMeta = this._shouldCaptureStack();
    }
    log(logLevelId, logLevelName, ...args) {
        if (logLevelId < this.settings.minLevel) {
            return;
        }
        const resolvedArgs = this._resolveLogArguments(args);
        const logArgs = [...this.settings.prefix, ...resolvedArgs];
        const maskedArgs = this.settings.overwrite?.mask != null
            ? this.settings.overwrite?.mask(logArgs)
            : this.settings.maskValuesOfKeys != null && this.settings.maskValuesOfKeys.length > 0
                ? this._mask(logArgs)
                : logArgs;
        const thisLogObj = this.logObj != null ? this._recursiveCloneAndExecuteFunctions(this.logObj) : undefined;
        const logObj = this.settings.overwrite?.toLogObj != null ? this.settings.overwrite?.toLogObj(maskedArgs, thisLogObj) : this._toLogObj(maskedArgs, thisLogObj);
        const logObjWithMeta = this.settings.overwrite?.addMeta != null
            ? this.settings.overwrite?.addMeta(logObj, logLevelId, logLevelName)
            : this._addMetaToLogObj(logObj, logLevelId, logLevelName);
        const logMeta = logObjWithMeta?.[this.settings.metaProperty];
        let logMetaMarkup;
        let logArgsAndErrorsMarkup = undefined;
        if (this.settings.overwrite?.formatMeta != null) {
            logMetaMarkup = this.settings.overwrite?.formatMeta(logObjWithMeta?.[this.settings.metaProperty]);
        }
        if (this.settings.overwrite?.formatLogObj != null) {
            logArgsAndErrorsMarkup = this.settings.overwrite?.formatLogObj(maskedArgs, this.settings);
        }
        if (this.settings.type === "pretty") {
            logMetaMarkup = logMetaMarkup ?? this._prettyFormatLogObjMeta(logObjWithMeta?.[this.settings.metaProperty]);
            logArgsAndErrorsMarkup = logArgsAndErrorsMarkup ?? runtime.prettyFormatLogObj(maskedArgs, this.settings);
        }
        if (logMetaMarkup != null && logArgsAndErrorsMarkup != null) {
            if (this.settings.overwrite?.transportFormatted != null) {
                const transport = this.settings.overwrite.transportFormatted;
                const declaredParams = transport.length;
                if (declaredParams < 4) {
                    transport(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors);
                }
                else if (declaredParams === 4) {
                    transport(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, logMeta);
                }
                else {
                    transport(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, logMeta, this.settings);
                }
            }
            else {
                runtime.transportFormatted(logMetaMarkup, logArgsAndErrorsMarkup.args, logArgsAndErrorsMarkup.errors, logMeta, this.settings);
            }
        }
        else {
            if (this.settings.overwrite?.transportJSON != null) {
                this.settings.overwrite.transportJSON(logObjWithMeta);
            }
            else if (this.settings.type !== "hidden") {
                runtime.transportJSON(logObjWithMeta);
            }
        }
        if (this.settings.attachedTransports != null && this.settings.attachedTransports.length > 0) {
            this.settings.attachedTransports.forEach((transportLogger) => {
                transportLogger(logObjWithMeta);
            });
        }
        return logObjWithMeta;
    }
    attachTransport(transportLogger) {
        this.settings.attachedTransports.push(transportLogger);
    }
    getSubLogger(settings, logObj) {
        const subLoggerSettings = {
            ...this.settings,
            ...settings,
            parentNames: this.settings?.parentNames != null && this.settings?.name != null
                ? [...this.settings.parentNames, this.settings.name]
                : this.settings?.name != null
                    ? [this.settings.name]
                    : undefined,
            prefix: [...this.settings.prefix, ...(settings?.prefix ?? [])],
        };
        const subLogger = new this.constructor(subLoggerSettings, logObj ?? this.logObj, this.stackDepthLevel);
        return subLogger;
    }
    _mask(args) {
        const maskKeys = this._getMaskKeys();
        return args?.map((arg) => {
            return this._recursiveCloneAndMaskValuesOfKeys(arg, maskKeys);
        });
    }
    _getMaskKeys() {
        const maskKeys = this.settings.maskValuesOfKeys ?? [];
        const signature = maskKeys.map(String).join("|");
        if (this.settings.maskValuesOfKeysCaseInsensitive === true) {
            if (this.maskKeysCache?.source === maskKeys && this.maskKeysCache.caseInsensitive === true && this.maskKeysCache.signature === signature) {
                return this.maskKeysCache.normalized;
            }
            const normalized = maskKeys.map((key) => (typeof key === "string" ? key.toLowerCase() : String(key).toLowerCase()));
            this.maskKeysCache = {
                source: maskKeys,
                caseInsensitive: true,
                normalized,
                signature,
            };
            return normalized;
        }
        this.maskKeysCache = {
            source: maskKeys,
            caseInsensitive: false,
            normalized: maskKeys,
            signature,
        };
        return maskKeys;
    }
    _resolveLogArguments(args) {
        if (args.length === 1 && typeof args[0] === "function") {
            const candidate = args[0];
            if (candidate.length === 0) {
                const result = candidate();
                return Array.isArray(result) ? result : [result];
            }
        }
        return args;
    }
    _recursiveCloneAndMaskValuesOfKeys(source, keys, seen = []) {
        if (seen.includes(source)) {
            return { ...source };
        }
        if (typeof source === "object" && source !== null) {
            seen.push(source);
        }
        if (runtime.isError(source) || runtime.isBuffer(source)) {
            return source;
        }
        else if (source instanceof Map) {
            return new Map(source);
        }
        else if (source instanceof Set) {
            return new Set(source);
        }
        else if (Array.isArray(source)) {
            return source.map((item) => this._recursiveCloneAndMaskValuesOfKeys(item, keys, seen));
        }
        else if (source instanceof Date) {
            return new Date(source.getTime());
        }
        else if (source instanceof URL) {
            return (0, urlToObj_js_1.urlToObject)(source);
        }
        else if (source !== null && typeof source === "object") {
            const baseObject = runtime.isError(source) ? this._cloneError(source) : Object.create(Object.getPrototypeOf(source));
            return Object.getOwnPropertyNames(source).reduce((o, prop) => {
                const lookupKey = this.settings?.maskValuesOfKeysCaseInsensitive !== true
                    ? prop
                    : typeof prop === "string"
                        ? prop.toLowerCase()
                        : String(prop).toLowerCase();
                o[prop] = keys.includes(lookupKey)
                    ? this.settings.maskPlaceholder
                    : (() => {
                        try {
                            return this._recursiveCloneAndMaskValuesOfKeys(source[prop], keys, seen);
                        }
                        catch {
                            return null;
                        }
                    })();
                return o;
            }, baseObject);
        }
        else {
            if (typeof source === "string") {
                let modifiedSource = source;
                for (const regEx of this.settings?.maskValuesRegEx || []) {
                    modifiedSource = modifiedSource.replace(regEx, this.settings?.maskPlaceholder || "");
                }
                return modifiedSource;
            }
            return source;
        }
    }
    _recursiveCloneAndExecuteFunctions(source, seen = []) {
        if (this.isObjectOrArray(source) && seen.includes(source)) {
            return this.shallowCopy(source);
        }
        if (this.isObjectOrArray(source)) {
            seen.push(source);
        }
        if (Array.isArray(source)) {
            return source.map((item) => this._recursiveCloneAndExecuteFunctions(item, seen));
        }
        else if (source instanceof Date) {
            return new Date(source.getTime());
        }
        else if (this.isObject(source)) {
            return Object.getOwnPropertyNames(source).reduce((o, prop) => {
                const descriptor = Object.getOwnPropertyDescriptor(source, prop);
                if (descriptor) {
                    Object.defineProperty(o, prop, descriptor);
                    const value = source[prop];
                    o[prop] = typeof value === "function" ? value() : this._recursiveCloneAndExecuteFunctions(value, seen);
                }
                return o;
            }, Object.create(Object.getPrototypeOf(source)));
        }
        else {
            return source;
        }
    }
    isObjectOrArray(value) {
        return typeof value === "object" && value !== null;
    }
    isObject(value) {
        return typeof value === "object" && !Array.isArray(value) && value !== null;
    }
    shallowCopy(source) {
        if (Array.isArray(source)) {
            return [...source];
        }
        else {
            return { ...source };
        }
    }
    _toLogObj(args, clonedLogObj = {}) {
        args = args?.map((arg) => (runtime.isError(arg) ? this._toErrorObject(arg) : arg));
        if (this.settings.argumentsArrayName == null) {
            if (args.length === 1 && !Array.isArray(args[0]) && runtime.isBuffer(args[0]) !== true && !(args[0] instanceof Date)) {
                clonedLogObj = typeof args[0] === "object" && args[0] != null ? { ...args[0], ...clonedLogObj } : { 0: args[0], ...clonedLogObj };
            }
            else {
                clonedLogObj = { ...clonedLogObj, ...args };
            }
        }
        else {
            clonedLogObj = {
                ...clonedLogObj,
                [this.settings.argumentsArrayName]: args,
            };
        }
        return clonedLogObj;
    }
    _cloneError(error) {
        const cloned = new error.constructor();
        Object.getOwnPropertyNames(error).forEach((key) => {
            cloned[key] = error[key];
        });
        return cloned;
    }
    _toErrorObject(error, depth = 0, seen = new Set()) {
        if (!seen.has(error)) {
            seen.add(error);
        }
        const errorObject = {
            nativeError: error,
            name: error.name ?? "Error",
            message: error.message,
            stack: runtime.getErrorTrace(error),
        };
        if (depth >= this.maxErrorCauseDepth) {
            return errorObject;
        }
        const causeValue = error.cause;
        if (causeValue != null) {
            const normalizedCause = (0, errorUtils_js_1.toError)(causeValue);
            if (!seen.has(normalizedCause)) {
                errorObject.cause = this._toErrorObject(normalizedCause, depth + 1, seen);
            }
        }
        return errorObject;
    }
    _addMetaToLogObj(logObj, logLevelId, logLevelName) {
        return {
            ...logObj,
            [this.settings.metaProperty]: runtime.getMeta(logLevelId, logLevelName, this.stackDepthLevel, !this.captureStackForMeta, this.settings.name, this.settings.parentNames),
        };
    }
    _shouldCaptureStack() {
        if (this.settings.hideLogPositionForProduction) {
            return false;
        }
        if (this.settings.type === "json") {
            return true;
        }
        const template = this.settings.prettyLogTemplate ?? "";
        const stackPlaceholders = /{{\s*(file(Name|Path|Line|PathWithLine|NameWithLine)|fullFilePath)\s*}}/;
        if (stackPlaceholders.test(template)) {
            return true;
        }
        return false;
    }
    _prettyFormatLogObjMeta(logObjMeta) {
        return (0, metaFormatting_js_1.buildPrettyMeta)(this.settings, logObjMeta).text;
    }
}
exports.BaseLogger = BaseLogger;


/***/ },

/***/ "../../node_modules/tslog/cjs/formatNumberAddZeros.js"
/*!************************************************************!*\
  !*** ../../node_modules/tslog/cjs/formatNumberAddZeros.js ***!
  \************************************************************/
(__unused_webpack_module, exports) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.formatNumberAddZeros = formatNumberAddZeros;
function formatNumberAddZeros(value, digits = 2, addNumber = 0) {
    if (value != null && isNaN(value)) {
        return "";
    }
    value = value != null ? value + addNumber : value;
    return digits === 2
        ? value == null
            ? "--"
            : value < 10
                ? "0" + value
                : value.toString()
        : value == null
            ? "---"
            : value < 10
                ? "00" + value
                : value < 100
                    ? "0" + value
                    : value.toString();
}


/***/ },

/***/ "../../node_modules/tslog/cjs/formatTemplate.js"
/*!******************************************************!*\
  !*** ../../node_modules/tslog/cjs/formatTemplate.js ***!
  \******************************************************/
(__unused_webpack_module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.formatTemplate = formatTemplate;
const prettyLogStyles_js_1 = __webpack_require__(/*! ./prettyLogStyles.js */ "../../node_modules/tslog/cjs/prettyLogStyles.js");
function formatTemplate(settings, template, values, hideUnsetPlaceholder = false) {
    const templateString = String(template);
    const ansiColorWrap = (placeholderValue, code) => `\u001b[${code[0]}m${placeholderValue}\u001b[${code[1]}m`;
    const styleWrap = (value, style) => {
        if (style != null && typeof style === "string") {
            return ansiColorWrap(value, prettyLogStyles_js_1.prettyLogStyles[style]);
        }
        else if (style != null && Array.isArray(style)) {
            return style.reduce((prevValue, thisStyle) => styleWrap(prevValue, thisStyle), value);
        }
        else {
            if (style != null && style[value.trim()] != null) {
                return styleWrap(value, style[value.trim()]);
            }
            else if (style != null && style["*"] != null) {
                return styleWrap(value, style["*"]);
            }
            else {
                return value;
            }
        }
    };
    const defaultStyle = null;
    return templateString.replace(/{{(.+?)}}/g, (_, placeholder) => {
        const value = values[placeholder] != null ? String(values[placeholder]) : hideUnsetPlaceholder ? "" : _;
        return settings.stylePrettyLogs
            ? styleWrap(value, settings?.prettyLogStyles?.[placeholder] ?? defaultStyle) + ansiColorWrap("", prettyLogStyles_js_1.prettyLogStyles.reset)
            : value;
    });
}


/***/ },

/***/ "../../node_modules/tslog/cjs/index.js"
/*!*********************************************!*\
  !*** ../../node_modules/tslog/cjs/index.js ***!
  \*********************************************/
(__unused_webpack_module, exports, __webpack_require__) {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Logger = void 0;
const BaseLogger_js_1 = __webpack_require__(/*! ./BaseLogger.js */ "../../node_modules/tslog/cjs/BaseLogger.js");
__exportStar(__webpack_require__(/*! ./interfaces.js */ "../../node_modules/tslog/cjs/interfaces.js"), exports);
__exportStar(__webpack_require__(/*! ./BaseLogger.js */ "../../node_modules/tslog/cjs/BaseLogger.js"), exports);
class Logger extends BaseLogger_js_1.BaseLogger {
    constructor(settings, logObj) {
        const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
        const normalizedSettings = { ...(settings ?? {}) };
        if (isBrowser) {
            normalizedSettings.stylePrettyLogs = settings?.stylePrettyLogs ?? true;
        }
        super(normalizedSettings, logObj, Number.NaN);
    }
    log(logLevelId, logLevelName, ...args) {
        return super.log(logLevelId, logLevelName, ...args);
    }
    silly(...args) {
        return super.log(0, "SILLY", ...args);
    }
    trace(...args) {
        return super.log(1, "TRACE", ...args);
    }
    debug(...args) {
        return super.log(2, "DEBUG", ...args);
    }
    info(...args) {
        return super.log(3, "INFO", ...args);
    }
    warn(...args) {
        return super.log(4, "WARN", ...args);
    }
    error(...args) {
        return super.log(5, "ERROR", ...args);
    }
    fatal(...args) {
        return super.log(6, "FATAL", ...args);
    }
    getSubLogger(settings, logObj) {
        return super.getSubLogger(settings, logObj);
    }
}
exports.Logger = Logger;


/***/ },

/***/ "../../node_modules/tslog/cjs/interfaces.js"
/*!**************************************************!*\
  !*** ../../node_modules/tslog/cjs/interfaces.js ***!
  \**************************************************/
(__unused_webpack_module, exports) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));


/***/ },

/***/ "../../node_modules/tslog/cjs/internal/environment.js"
/*!************************************************************!*\
  !*** ../../node_modules/tslog/cjs/internal/environment.js ***!
  \************************************************************/
(__unused_webpack_module, exports) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.safeGetCwd = safeGetCwd;
exports.isBrowserEnvironment = isBrowserEnvironment;
exports.consoleSupportsCssStyling = consoleSupportsCssStyling;
function safeGetCwd() {
    try {
        const nodeProcess = globalThis?.process;
        if (typeof nodeProcess?.cwd === "function") {
            return nodeProcess.cwd();
        }
    }
    catch {
    }
    try {
        const deno = globalThis?.["Deno"];
        if (typeof deno?.cwd === "function") {
            return deno.cwd();
        }
    }
    catch {
    }
    return undefined;
}
function isBrowserEnvironment() {
    return typeof window !== "undefined" && typeof document !== "undefined";
}
function consoleSupportsCssStyling() {
    if (!isBrowserEnvironment()) {
        return false;
    }
    const navigatorObj = globalThis?.navigator;
    const userAgent = navigatorObj?.userAgent ?? "";
    if (/firefox/i.test(userAgent)) {
        return true;
    }
    const windowObj = globalThis;
    if (windowObj?.CSS?.supports?.("color", "#000")) {
        return true;
    }
    return /safari/i.test(userAgent) && !/chrome/i.test(userAgent);
}


/***/ },

/***/ "../../node_modules/tslog/cjs/internal/errorUtils.js"
/*!***********************************************************!*\
  !*** ../../node_modules/tslog/cjs/internal/errorUtils.js ***!
  \***********************************************************/
(__unused_webpack_module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.collectErrorCauses = collectErrorCauses;
exports.toError = toError;
exports.toErrorObject = toErrorObject;
const stackTrace_js_1 = __webpack_require__(/*! ./stackTrace.js */ "../../node_modules/tslog/cjs/internal/stackTrace.js");
const DEFAULT_CAUSE_DEPTH = 5;
function collectErrorCauses(error, options = {}) {
    const maxDepth = options.maxDepth ?? DEFAULT_CAUSE_DEPTH;
    const causes = [];
    const visited = new Set();
    let current = error;
    let depth = 0;
    while (current != null && depth < maxDepth) {
        const cause = current?.cause;
        if (cause == null || visited.has(cause)) {
            break;
        }
        visited.add(cause);
        causes.push(toError(cause));
        current = cause;
        depth += 1;
    }
    return causes;
}
function toError(value) {
    if (value instanceof Error) {
        return value;
    }
    const error = new Error(typeof value === "string" ? value : JSON.stringify(value));
    if (typeof value === "object" && value != null) {
        Object.assign(error, value);
    }
    return error;
}
function toErrorObject(error, parseLine) {
    return {
        nativeError: error,
        name: error.name ?? "Error",
        message: error.message ?? "",
        stack: (0, stackTrace_js_1.buildStackTrace)(error, parseLine),
    };
}


/***/ },

/***/ "../../node_modules/tslog/cjs/internal/jsonStringifyRecursive.js"
/*!***********************************************************************!*\
  !*** ../../node_modules/tslog/cjs/internal/jsonStringifyRecursive.js ***!
  \***********************************************************************/
(__unused_webpack_module, exports) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.jsonStringifyRecursive = jsonStringifyRecursive;
function jsonStringifyRecursive(obj) {
    const cache = new Set();
    return JSON.stringify(obj, (key, value) => {
        if (typeof value === "object" && value !== null) {
            if (cache.has(value)) {
                return "[Circular]";
            }
            cache.add(value);
        }
        if (typeof value === "bigint") {
            return `${value}`;
        }
        if (typeof value === "undefined") {
            return "[undefined]";
        }
        return value;
    });
}


/***/ },

/***/ "../../node_modules/tslog/cjs/internal/metaFormatting.js"
/*!***************************************************************!*\
  !*** ../../node_modules/tslog/cjs/internal/metaFormatting.js ***!
  \***************************************************************/
(__unused_webpack_module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.buildPrettyMeta = buildPrettyMeta;
const formatTemplate_js_1 = __webpack_require__(/*! ../formatTemplate.js */ "../../node_modules/tslog/cjs/formatTemplate.js");
const formatNumberAddZeros_js_1 = __webpack_require__(/*! ../formatNumberAddZeros.js */ "../../node_modules/tslog/cjs/formatNumberAddZeros.js");
function buildPrettyMeta(settings, meta) {
    if (meta == null) {
        return {
            text: "",
            template: settings.prettyLogTemplate,
            placeholders: {},
        };
    }
    let template = settings.prettyLogTemplate;
    const placeholderValues = {};
    if (template.includes("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}")) {
        template = template.replace("{{yyyy}}.{{mm}}.{{dd}} {{hh}}:{{MM}}:{{ss}}:{{ms}}", "{{dateIsoStr}}");
    }
    else {
        if (settings.prettyLogTimeZone === "UTC") {
            placeholderValues["yyyy"] = meta.date?.getUTCFullYear() ?? "----";
            placeholderValues["mm"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getUTCMonth(), 2, 1);
            placeholderValues["dd"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getUTCDate(), 2);
            placeholderValues["hh"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getUTCHours(), 2);
            placeholderValues["MM"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getUTCMinutes(), 2);
            placeholderValues["ss"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getUTCSeconds(), 2);
            placeholderValues["ms"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getUTCMilliseconds(), 3);
        }
        else {
            placeholderValues["yyyy"] = meta.date?.getFullYear() ?? "----";
            placeholderValues["mm"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getMonth(), 2, 1);
            placeholderValues["dd"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getDate(), 2);
            placeholderValues["hh"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getHours(), 2);
            placeholderValues["MM"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getMinutes(), 2);
            placeholderValues["ss"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getSeconds(), 2);
            placeholderValues["ms"] = (0, formatNumberAddZeros_js_1.formatNumberAddZeros)(meta.date?.getMilliseconds(), 3);
        }
    }
    const dateInSettingsTimeZone = settings.prettyLogTimeZone === "UTC" ? meta.date : meta.date != null ? new Date(meta.date.getTime() - meta.date.getTimezoneOffset() * 60000) : undefined;
    placeholderValues["rawIsoStr"] = dateInSettingsTimeZone?.toISOString() ?? "";
    placeholderValues["dateIsoStr"] = dateInSettingsTimeZone?.toISOString().replace("T", " ").replace("Z", "") ?? "";
    placeholderValues["logLevelName"] = meta.logLevelName;
    placeholderValues["fileNameWithLine"] = meta.path?.fileNameWithLine ?? "";
    placeholderValues["filePathWithLine"] = meta.path?.filePathWithLine ?? "";
    placeholderValues["fullFilePath"] = meta.path?.fullFilePath ?? "";
    let parentNamesString = settings.parentNames?.join(settings.prettyErrorParentNamesSeparator);
    parentNamesString = parentNamesString != null && meta.name != null ? parentNamesString + settings.prettyErrorParentNamesSeparator : undefined;
    const combinedName = meta.name != null || parentNamesString != null ? `${parentNamesString ?? ""}${meta.name ?? ""}` : "";
    placeholderValues["name"] = combinedName;
    placeholderValues["nameWithDelimiterPrefix"] = combinedName.length > 0 ? settings.prettyErrorLoggerNameDelimiter + combinedName : "";
    placeholderValues["nameWithDelimiterSuffix"] = combinedName.length > 0 ? combinedName + settings.prettyErrorLoggerNameDelimiter : "";
    if (settings.overwrite?.addPlaceholders != null) {
        settings.overwrite.addPlaceholders(meta, placeholderValues);
    }
    return {
        text: (0, formatTemplate_js_1.formatTemplate)(settings, template, placeholderValues),
        template,
        placeholders: placeholderValues,
    };
}


/***/ },

/***/ "../../node_modules/tslog/cjs/internal/stackTrace.js"
/*!***********************************************************!*\
  !*** ../../node_modules/tslog/cjs/internal/stackTrace.js ***!
  \***********************************************************/
(__unused_webpack_module, exports) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.splitStackLines = splitStackLines;
exports.sanitizeStackLines = sanitizeStackLines;
exports.toStackFrames = toStackFrames;
exports.findFirstExternalFrameIndex = findFirstExternalFrameIndex;
exports.getFrameAt = getFrameAt;
exports.getCleanStackLines = getCleanStackLines;
exports.buildStackTrace = buildStackTrace;
exports.isIgnorableFrame = isIgnorableFrame;
exports.clampIndex = clampIndex;
exports.pickCallerStackFrame = pickCallerStackFrame;
exports.getDefaultIgnorePatterns = getDefaultIgnorePatterns;
const DEFAULT_IGNORE_PATTERNS = [
    /(?:^|[\\/])node_modules[\\/].*tslog/i,
    /(?:^|[\\/])deps[\\/].*tslog/i,
    /tslog[\\/]+src[\\/]+internal[\\/]/i,
    /tslog[\\/]+src[\\/]BaseLogger/i,
    /tslog[\\/]+src[\\/]index/i,
];
function splitStackLines(error) {
    const stack = typeof error?.stack === "string" ? error.stack : undefined;
    if (stack == null || stack.length === 0) {
        return [];
    }
    return stack.split("\n").map((line) => line.trimEnd());
}
function sanitizeStackLines(lines) {
    return lines.filter((line) => line.length > 0 && !/^\s*Error\b/.test(line));
}
function toStackFrames(lines, parseLine) {
    const frames = [];
    for (const line of lines) {
        const frame = parseLine(line);
        if (frame != null) {
            frames.push(frame);
        }
    }
    return frames;
}
function findFirstExternalFrameIndex(frames, ignorePatterns = DEFAULT_IGNORE_PATTERNS) {
    for (let index = 0; index < frames.length; index += 1) {
        const frame = frames[index];
        const filePathCandidate = frame.filePath ?? "";
        const fullPathCandidate = frame.fullFilePath ?? "";
        if (!ignorePatterns.some((pattern) => pattern.test(filePathCandidate) || pattern.test(fullPathCandidate))) {
            return index;
        }
    }
    return 0;
}
function getFrameAt(frames, index) {
    if (index < 0 || index >= frames.length) {
        return undefined;
    }
    return frames[index];
}
function getCleanStackLines(error) {
    return sanitizeStackLines(splitStackLines(error));
}
function buildStackTrace(error, parseLine) {
    return toStackFrames(getCleanStackLines(error), parseLine);
}
function isIgnorableFrame(frame, ignorePatterns) {
    const filePathCandidate = frame.filePath ?? "";
    const fullPathCandidate = frame.fullFilePath ?? "";
    return ignorePatterns.some((pattern) => pattern.test(filePathCandidate) || pattern.test(fullPathCandidate));
}
function clampIndex(index, maxExclusive) {
    if (index < 0) {
        return 0;
    }
    if (index >= maxExclusive) {
        return Math.max(0, maxExclusive - 1);
    }
    return index;
}
function pickCallerStackFrame(error, parseLine, options = {}) {
    const lines = getCleanStackLines(error);
    const frames = toStackFrames(lines, parseLine);
    if (frames.length === 0) {
        return undefined;
    }
    const ignorePatterns = options.ignorePatterns ?? DEFAULT_IGNORE_PATTERNS;
    const autoIndex = findFirstExternalFrameIndex(frames, ignorePatterns);
    const resolvedIndex = options.stackDepthLevel != null ? options.stackDepthLevel : autoIndex;
    return getFrameAt(frames, clampIndex(resolvedIndex, frames.length));
}
function getDefaultIgnorePatterns() {
    return [...DEFAULT_IGNORE_PATTERNS];
}


/***/ },

/***/ "../../node_modules/tslog/cjs/internal/util.inspect.polyfill.js"
/*!**********************************************************************!*\
  !*** ../../node_modules/tslog/cjs/internal/util.inspect.polyfill.js ***!
  \**********************************************************************/
(__unused_webpack_module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.inspect = inspect;
exports.formatValue = formatValue;
exports.formatWithOptions = formatWithOptions;
const prettyLogStyles_js_1 = __webpack_require__(/*! ../prettyLogStyles.js */ "../../node_modules/tslog/cjs/prettyLogStyles.js");
const jsonStringifyRecursive_js_1 = __webpack_require__(/*! ./jsonStringifyRecursive.js */ "../../node_modules/tslog/cjs/internal/jsonStringifyRecursive.js");
function inspect(obj, opts) {
    const ctx = {
        seen: [],
        stylize: stylizeNoColor,
    };
    if (opts != null) {
        _extend(ctx, opts);
    }
    if (isUndefined(ctx.showHidden))
        ctx.showHidden = false;
    if (isUndefined(ctx.depth))
        ctx.depth = 2;
    if (isUndefined(ctx.colors))
        ctx.colors = true;
    if (isUndefined(ctx.customInspect))
        ctx.customInspect = true;
    if (ctx.colors)
        ctx.stylize = stylizeWithColor;
    return formatValue(ctx, obj, ctx.depth);
}
inspect.colors = prettyLogStyles_js_1.prettyLogStyles;
inspect.styles = {
    special: "cyan",
    number: "yellow",
    boolean: "yellow",
    undefined: "grey",
    null: "bold",
    string: "green",
    date: "magenta",
    regexp: "red",
};
function isBoolean(arg) {
    return typeof arg === "boolean";
}
function isUndefined(arg) {
    return arg === undefined;
}
function stylizeNoColor(str) {
    return str;
}
function stylizeWithColor(str, styleType) {
    const style = inspect.styles[styleType];
    if (style != null && inspect?.colors?.[style]?.[0] != null && inspect?.colors?.[style]?.[1] != null) {
        return "\u001b[" + inspect.colors[style][0] + "m" + str + "\u001b[" + inspect.colors[style][1] + "m";
    }
    else {
        return str;
    }
}
function isFunction(arg) {
    return typeof arg === "function";
}
function isString(arg) {
    return typeof arg === "string";
}
function isNumber(arg) {
    return typeof arg === "number";
}
function isNull(arg) {
    return arg === null;
}
function hasOwn(obj, prop) {
    return Object.prototype.hasOwnProperty.call(obj, prop);
}
function isRegExp(re) {
    return isObject(re) && objectToString(re) === "[object RegExp]";
}
function isObject(arg) {
    return typeof arg === "object" && arg !== null;
}
function isError(e) {
    return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
}
function isDate(d) {
    return isObject(d) && objectToString(d) === "[object Date]";
}
function objectToString(o) {
    return Object.prototype.toString.call(o);
}
function arrayToHash(array) {
    const hash = {};
    array.forEach((val) => {
        hash[val] = true;
    });
    return hash;
}
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
    const output = [];
    for (let i = 0, l = value.length; i < l; ++i) {
        if (hasOwn(value, String(i))) {
            output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
        }
        else {
            output.push("");
        }
    }
    keys.forEach((key) => {
        if (!key.match(/^\d+$/)) {
            output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
        }
    });
    return output;
}
function formatError(value) {
    return "[" + Error.prototype.toString.call(value) + "]";
}
function formatValue(ctx, value, recurseTimes = 0) {
    if (ctx.customInspect &&
        value != null &&
        isFunction(value) &&
        value?.inspect !== inspect &&
        !(value?.constructor && value?.constructor.prototype === value)) {
        if (typeof value.inspect !== "function" && value.toString != null) {
            return value.toString();
        }
        let ret = value?.inspect(recurseTimes, ctx);
        if (!isString(ret)) {
            ret = formatValue(ctx, ret, recurseTimes);
        }
        return ret;
    }
    const primitive = formatPrimitive(ctx, value);
    if (primitive) {
        return primitive;
    }
    let keys = Object.keys(value);
    const visibleKeys = arrayToHash(keys);
    try {
        if (ctx.showHidden && Object.getOwnPropertyNames) {
            keys = Object.getOwnPropertyNames(value);
        }
    }
    catch {
    }
    if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0)) {
        return formatError(value);
    }
    if (keys.length === 0) {
        if (isFunction(ctx.stylize)) {
            if (isFunction(value)) {
                const name = value.name ? ": " + value.name : "";
                return ctx.stylize("[Function" + name + "]", "special");
            }
            if (isRegExp(value)) {
                return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
            }
            if (isDate(value)) {
                return ctx.stylize(Date.prototype.toISOString.call(value), "date");
            }
            if (isError(value)) {
                return formatError(value);
            }
        }
        else {
            return value;
        }
    }
    let base = "";
    let array = false;
    let braces = ["{\n", "\n}"];
    if (Array.isArray(value)) {
        array = true;
        braces = ["[\n", "\n]"];
    }
    if (isFunction(value)) {
        const n = value.name ? ": " + value.name : "";
        base = " [Function" + n + "]";
    }
    if (isRegExp(value)) {
        base = " " + RegExp.prototype.toString.call(value);
    }
    if (isDate(value)) {
        base = " " + Date.prototype.toUTCString.call(value);
    }
    if (isError(value)) {
        base = " " + formatError(value);
    }
    if (keys.length === 0 && (!array || value.length == 0)) {
        return braces[0] + base + braces[1];
    }
    if (recurseTimes < 0) {
        if (isRegExp(value)) {
            return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
        }
        else {
            return ctx.stylize("[Object]", "special");
        }
    }
    ctx.seen.push(value);
    let output;
    if (array) {
        output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
    }
    else {
        output = keys.map((key) => {
            return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
        });
    }
    ctx.seen.pop();
    return reduceToSingleString(output, base, braces);
}
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
    let name, str;
    let desc = { value: void 0 };
    try {
        desc.value = value[key];
    }
    catch {
    }
    try {
        if (Object.getOwnPropertyDescriptor) {
            desc = Object.getOwnPropertyDescriptor(value, key) || desc;
        }
    }
    catch {
    }
    if (desc.get) {
        if (desc.set) {
            str = ctx.stylize("[Getter/Setter]", "special");
        }
        else {
            str = ctx.stylize("[Getter]", "special");
        }
    }
    else {
        if (desc.set) {
            str = ctx.stylize("[Setter]", "special");
        }
    }
    if (!hasOwn(visibleKeys, key)) {
        name = "[" + key + "]";
    }
    if (!str) {
        if (ctx.seen.indexOf(desc.value) < 0) {
            if (isNull(recurseTimes)) {
                str = formatValue(ctx, desc.value, undefined);
            }
            else {
                str = formatValue(ctx, desc.value, recurseTimes - 1);
            }
            if (str.indexOf("\n") > -1) {
                if (array) {
                    str = str
                        .split("\n")
                        .map((line) => {
                        return "  " + line;
                    })
                        .join("\n")
                        .substr(2);
                }
                else {
                    str =
                        "\n" +
                            str
                                .split("\n")
                                .map((line) => {
                                return "   " + line;
                            })
                                .join("\n");
                }
            }
        }
        else {
            str = ctx.stylize("[Circular]", "special");
        }
    }
    if (isUndefined(name)) {
        if (array && key.match(/^\d+$/)) {
            return str;
        }
        name = JSON.stringify("" + key);
        if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
            name = name.substr(1, name.length - 2);
            name = ctx.stylize(name, "name");
        }
        else {
            name = name
                .replace(/'/g, "\\'")
                .replace(/\\"/g, "\\'")
                .replace(/(^"|"$)/g, "'");
            name = ctx.stylize(name, "string");
        }
    }
    return name + ": " + str;
}
function formatPrimitive(ctx, value) {
    if (isUndefined(value))
        return ctx.stylize("undefined", "undefined");
    if (isString(value)) {
        const simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, "\\'") + "'";
        return ctx.stylize(simple, "string");
    }
    if (isNumber(value))
        return ctx.stylize("" + value, "number");
    if (isBoolean(value))
        return ctx.stylize("" + value, "boolean");
    if (isNull(value))
        return ctx.stylize("null", "null");
}
function reduceToSingleString(output, base, braces) {
    return braces[0] + (base === "" ? "" : base + "\n") + "  " + output.join(",\n  ") + " " + braces[1];
}
function _extend(origin, add) {
    const typedOrigin = { ...origin };
    if (!add || !isObject(add))
        return origin;
    const clonedAdd = { ...add };
    const keys = Object.keys(add);
    let i = keys.length;
    while (i--) {
        typedOrigin[keys[i]] = clonedAdd[keys[i]];
    }
    return typedOrigin;
}
function formatWithOptions(inspectOptions, ...args) {
    const ctx = {
        seen: [],
        stylize: stylizeNoColor,
    };
    if (inspectOptions != null) {
        _extend(ctx, inspectOptions);
    }
    const first = args[0];
    let a = 0;
    let str = "";
    let join = "";
    if (typeof first === "string") {
        if (args.length === 1) {
            return first;
        }
        let tempStr;
        let lastPos = 0;
        for (let i = 0; i < first.length - 1; i++) {
            if (first.charCodeAt(i) === 37) {
                const nextChar = first.charCodeAt(++i);
                if (a + 1 !== args.length) {
                    switch (nextChar) {
                        case 115: {
                            const tempArg = args[++a];
                            if (typeof tempArg === "number") {
                                tempStr = formatPrimitive(ctx, tempArg);
                            }
                            else if (typeof tempArg === "bigint") {
                                tempStr = formatPrimitive(ctx, tempArg);
                            }
                            else if (typeof tempArg !== "object" || tempArg === null) {
                                tempStr = String(tempArg);
                            }
                            else {
                                tempStr = inspect(tempArg, {
                                    ...inspectOptions,
                                    compact: 3,
                                    colors: false,
                                    depth: 0,
                                });
                            }
                            break;
                        }
                        case 106:
                            tempStr = (0, jsonStringifyRecursive_js_1.jsonStringifyRecursive)(args[++a]);
                            break;
                        case 100: {
                            const tempNum = args[++a];
                            if (typeof tempNum === "bigint") {
                                tempStr = formatPrimitive(ctx, tempNum);
                            }
                            else if (typeof tempNum === "symbol") {
                                tempStr = "NaN";
                            }
                            else {
                                tempStr = formatPrimitive(ctx, tempNum);
                            }
                            break;
                        }
                        case 79:
                            tempStr = inspect(args[++a], inspectOptions);
                            break;
                        case 111:
                            tempStr = inspect(args[++a], {
                                ...inspectOptions,
                                showHidden: true,
                                showProxy: true,
                                depth: 4,
                            });
                            break;
                        case 105: {
                            const tempInteger = args[++a];
                            if (typeof tempInteger === "bigint") {
                                tempStr = formatPrimitive(ctx, tempInteger);
                            }
                            else if (typeof tempInteger === "symbol") {
                                tempStr = "NaN";
                            }
                            else {
                                tempStr = formatPrimitive(ctx, parseInt(tempStr));
                            }
                            break;
                        }
                        case 102: {
                            const tempFloat = args[++a];
                            if (typeof tempFloat === "symbol") {
                                tempStr = "NaN";
                            }
                            else {
                                tempStr = formatPrimitive(ctx, parseInt(tempFloat));
                            }
                            break;
                        }
                        case 99:
                            a += 1;
                            tempStr = "";
                            break;
                        case 37:
                            str += first.slice(lastPos, i);
                            lastPos = i + 1;
                            continue;
                        default:
                            continue;
                    }
                    if (lastPos !== i - 1) {
                        str += first.slice(lastPos, i - 1);
                    }
                    str += tempStr;
                    lastPos = i + 1;
                }
                else if (nextChar === 37) {
                    str += first.slice(lastPos, i);
                    lastPos = i + 1;
                }
            }
        }
        if (lastPos !== 0) {
            a++;
            join = " ";
            if (lastPos < first.length) {
                str += first.slice(lastPos);
            }
        }
    }
    while (a < args.length) {
        const value = args[a];
        str += join;
        str += typeof value !== "string" ? inspect(value, inspectOptions) : value;
        join = " ";
        a++;
    }
    return str;
}


/***/ },

/***/ "../../node_modules/tslog/cjs/prettyLogStyles.js"
/*!*******************************************************!*\
  !*** ../../node_modules/tslog/cjs/prettyLogStyles.js ***!
  \*******************************************************/
(__unused_webpack_module, exports) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.prettyLogStyles = void 0;
exports.prettyLogStyles = {
    reset: [0, 0],
    bold: [1, 22],
    dim: [2, 22],
    italic: [3, 23],
    underline: [4, 24],
    overline: [53, 55],
    inverse: [7, 27],
    hidden: [8, 28],
    strikethrough: [9, 29],
    black: [30, 39],
    red: [31, 39],
    green: [32, 39],
    yellow: [33, 39],
    blue: [34, 39],
    magenta: [35, 39],
    cyan: [36, 39],
    white: [37, 39],
    blackBright: [90, 39],
    redBright: [91, 39],
    greenBright: [92, 39],
    yellowBright: [93, 39],
    blueBright: [94, 39],
    magentaBright: [95, 39],
    cyanBright: [96, 39],
    whiteBright: [97, 39],
    bgBlack: [40, 49],
    bgRed: [41, 49],
    bgGreen: [42, 49],
    bgYellow: [43, 49],
    bgBlue: [44, 49],
    bgMagenta: [45, 49],
    bgCyan: [46, 49],
    bgWhite: [47, 49],
    bgBlackBright: [100, 49],
    bgRedBright: [101, 49],
    bgGreenBright: [102, 49],
    bgYellowBright: [103, 49],
    bgBlueBright: [104, 49],
    bgMagentaBright: [105, 49],
    bgCyanBright: [106, 49],
    bgWhiteBright: [107, 49],
};


/***/ },

/***/ "../../node_modules/tslog/cjs/urlToObj.js"
/*!************************************************!*\
  !*** ../../node_modules/tslog/cjs/urlToObj.js ***!
  \************************************************/
(__unused_webpack_module, exports) {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.urlToObject = urlToObject;
function urlToObject(url) {
    return {
        href: url.href,
        protocol: url.protocol,
        username: url.username,
        password: url.password,
        host: url.host,
        hostname: url.hostname,
        port: url.port,
        pathname: url.pathname,
        search: url.search,
        searchParams: [...url.searchParams].map(([key, value]) => ({ key, value })),
        hash: url.hash,
        origin: url.origin,
    };
}


/***/ }

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Check if module exists (development only)
/******/ 		if (__webpack_modules__[moduleId] === undefined) {
/******/ 			var e = new Error("Cannot find module '" + moduleId + "'");
/******/ 			e.code = 'MODULE_NOT_FOUND';
/******/ 			throw e;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
(() => {
/*!***************************************************!*\
  !*** ./src/extension-support/extension-worker.js ***!
  \***************************************************/
/* eslint-env worker */

const ArgumentType = __webpack_require__(/*! ../extension-support/argument-type */ "./src/extension-support/argument-type.js");
const BlockType = __webpack_require__(/*! ../extension-support/block-type */ "./src/extension-support/block-type.js");
const dispatch = __webpack_require__(/*! ../dispatch/worker-dispatch */ "./src/dispatch/worker-dispatch.js");
const TargetType = __webpack_require__(/*! ../extension-support/target-type */ "./src/extension-support/target-type.js");
class ExtensionWorker {
  constructor() {
    this.nextExtensionId = 0;
    this.initialRegistrations = [];
    dispatch.waitForConnection.then(() => {
      dispatch.call('extensions', 'allocateWorker').then(x => {
        const [id, extension] = x;
        this.workerId = id;
        try {
          importScripts(extension);
          const initialRegistrations = this.initialRegistrations;
          this.initialRegistrations = null;
          Promise.all(initialRegistrations).then(() => dispatch.call('extensions', 'onWorkerInit', id));
        } catch (e) {
          dispatch.call('extensions', 'onWorkerInit', id, e);
        }
      });
    });
    this.extensions = [];
  }
  register(extensionObject) {
    const extensionId = this.nextExtensionId++;
    this.extensions.push(extensionObject);
    const serviceName = "extension.".concat(this.workerId, ".").concat(extensionId);
    const promise = dispatch.setService(serviceName, extensionObject).then(() => dispatch.call('extensions', 'registerExtensionService', serviceName));
    if (this.initialRegistrations) {
      this.initialRegistrations.push(promise);
    }
    return promise;
  }
}
global.Scratch = global.Scratch || {};
global.Scratch.ArgumentType = ArgumentType;
global.Scratch.BlockType = BlockType;
global.Scratch.TargetType = TargetType;

/**
 * Expose only specific parts of the worker to extensions.
 */
const extensionWorker = new ExtensionWorker();
global.Scratch.extensions = {
  register: extensionWorker.register.bind(extensionWorker)
};
})();

/******/ 	return __webpack_exports__;
/******/ })()
;
});
//# sourceMappingURL=extension-worker.js.map