@stencil/core
Version:
A Compiler for Web Components and Progressive Web Apps
1,862 lines (1,850 loc) • 11 MB
JavaScript
/*!
Stencil Compiler v4.3.0 | MIT Licensed | https://stenciljs.com
*/
(function(exports) {
'use strict';
if (typeof globalThis === 'undefined') {
if (typeof self !== 'undefined') {
self.globalThis = self;
} else if (typeof window !== 'undefined') {
window.globalThis = window;
} else if (typeof global !== 'undefined') {
global.globalThis = global;
}
}
const Buffer = globalThis.Buffer || {};
const process = globalThis.process || {};
if (!process.argv) {
process.argv = [''];
}
let __cwd = '/';
if (!process.cwd) {
process.cwd = () => __cwd;
}
if (!process.chdir) {
process.chdir = (v) => __cwd = v;
}
if (!process.nextTick) {
const resolved = Promise.resolve();
process.nextTick = (cb) => resolved.then(cb);
}
if (!process.platform) {
process.platform = 'stencil';
}
if (!process.version) {
process.version = 'v16.0.0';
}
process.browser = !!globalThis.location;
const path$4 = require('path');
const fs$2 = require('fs');
const util$3 = require('util');
const require$$0 = require('events');
const assert$2 = require('assert');
const require$$0$1 = require('module');
const require$$3 = require('crypto');
const require$$0$2 = require('stream');
const os$2 = require('os');
const require$$8 = require('buffer');
const require$$9 = require('tty');
const constants$4 = require('constants');
const cp = require('child_process');
const process$3 = require('process');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
}
});
}
n['default'] = e;
return n;
}
const path__default = /*#__PURE__*/_interopDefaultLegacy(path$4);
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$2);
const fs__namespace = /*#__PURE__*/_interopNamespace(fs$2);
const util__default = /*#__PURE__*/_interopDefaultLegacy(util$3);
const require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
const assert__default = /*#__PURE__*/_interopDefaultLegacy(assert$2);
const require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
const require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
const require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
const os__default = /*#__PURE__*/_interopDefaultLegacy(os$2);
const os__namespace = /*#__PURE__*/_interopNamespace(os$2);
const require$$8__default = /*#__PURE__*/_interopDefaultLegacy(require$$8);
const require$$9__default = /*#__PURE__*/_interopDefaultLegacy(require$$9);
const constants__default = /*#__PURE__*/_interopDefaultLegacy(constants$4);
const cp__namespace = /*#__PURE__*/_interopNamespace(cp);
const process__namespace = /*#__PURE__*/_interopNamespace(process$3);
// TypeScript 5.1.6
var ts = (() => {
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true, configurable: true });
};
// src/compiler/corePublic.ts
var versionMajorMinor, version, Comparison;
var init_corePublic = __esm({
"src/compiler/corePublic.ts"() {
versionMajorMinor = "5.1";
version = "5.1.6";
Comparison = /* @__PURE__ */ ((Comparison3) => {
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
Comparison3[Comparison3["GreaterThan"] = 1] = "GreaterThan";
return Comparison3;
})(Comparison || {});
}
});
// src/compiler/core.ts
function length(array) {
return array ? array.length : 0;
}
function forEach(array, callback) {
if (array) {
for (let i = 0; i < array.length; i++) {
const result = callback(array[i], i);
if (result) {
return result;
}
}
}
return void 0;
}
function forEachRight(array, callback) {
if (array) {
for (let i = array.length - 1; i >= 0; i--) {
const result = callback(array[i], i);
if (result) {
return result;
}
}
}
return void 0;
}
function firstDefined(array, callback) {
if (array === void 0) {
return void 0;
}
for (let i = 0; i < array.length; i++) {
const result = callback(array[i], i);
if (result !== void 0) {
return result;
}
}
return void 0;
}
function firstDefinedIterator(iter, callback) {
for (const value of iter) {
const result = callback(value);
if (result !== void 0) {
return result;
}
}
return void 0;
}
function reduceLeftIterator(iterator, f, initial) {
let result = initial;
if (iterator) {
let pos = 0;
for (const value of iterator) {
result = f(result, value, pos);
pos++;
}
}
return result;
}
function zipWith(arrayA, arrayB, callback) {
const result = [];
Debug.assertEqual(arrayA.length, arrayB.length);
for (let i = 0; i < arrayA.length; i++) {
result.push(callback(arrayA[i], arrayB[i], i));
}
return result;
}
function intersperse(input, element) {
if (input.length <= 1) {
return input;
}
const result = [];
for (let i = 0, n = input.length; i < n; i++) {
if (i)
result.push(element);
result.push(input[i]);
}
return result;
}
function every(array, callback) {
if (array) {
for (let i = 0; i < array.length; i++) {
if (!callback(array[i], i)) {
return false;
}
}
}
return true;
}
function find(array, predicate, startIndex) {
if (array === void 0)
return void 0;
for (let i = startIndex ?? 0; i < array.length; i++) {
const value = array[i];
if (predicate(value, i)) {
return value;
}
}
return void 0;
}
function findLast(array, predicate, startIndex) {
if (array === void 0)
return void 0;
for (let i = startIndex ?? array.length - 1; i >= 0; i--) {
const value = array[i];
if (predicate(value, i)) {
return value;
}
}
return void 0;
}
function findIndex(array, predicate, startIndex) {
if (array === void 0)
return -1;
for (let i = startIndex ?? 0; i < array.length; i++) {
if (predicate(array[i], i)) {
return i;
}
}
return -1;
}
function findLastIndex(array, predicate, startIndex) {
if (array === void 0)
return -1;
for (let i = startIndex ?? array.length - 1; i >= 0; i--) {
if (predicate(array[i], i)) {
return i;
}
}
return -1;
}
function findMap(array, callback) {
for (let i = 0; i < array.length; i++) {
const result = callback(array[i], i);
if (result) {
return result;
}
}
return Debug.fail();
}
function contains(array, value, equalityComparer = equateValues) {
if (array) {
for (const v of array) {
if (equalityComparer(v, value)) {
return true;
}
}
}
return false;
}
function arraysEqual(a, b, equalityComparer = equateValues) {
return a.length === b.length && a.every((x, i) => equalityComparer(x, b[i]));
}
function indexOfAnyCharCode(text, charCodes, start) {
for (let i = start || 0; i < text.length; i++) {
if (contains(charCodes, text.charCodeAt(i))) {
return i;
}
}
return -1;
}
function countWhere(array, predicate) {
let count = 0;
if (array) {
for (let i = 0; i < array.length; i++) {
const v = array[i];
if (predicate(v, i)) {
count++;
}
}
}
return count;
}
function filter(array, f) {
if (array) {
const len = array.length;
let i = 0;
while (i < len && f(array[i]))
i++;
if (i < len) {
const result = array.slice(0, i);
i++;
while (i < len) {
const item = array[i];
if (f(item)) {
result.push(item);
}
i++;
}
return result;
}
}
return array;
}
function filterMutate(array, f) {
let outIndex = 0;
for (let i = 0; i < array.length; i++) {
if (f(array[i], i, array)) {
array[outIndex] = array[i];
outIndex++;
}
}
array.length = outIndex;
}
function clear(array) {
array.length = 0;
}
function map(array, f) {
let result;
if (array) {
result = [];
for (let i = 0; i < array.length; i++) {
result.push(f(array[i], i));
}
}
return result;
}
function* mapIterator(iter, mapFn) {
for (const x of iter) {
yield mapFn(x);
}
}
function sameMap(array, f) {
if (array) {
for (let i = 0; i < array.length; i++) {
const item = array[i];
const mapped = f(item, i);
if (item !== mapped) {
const result = array.slice(0, i);
result.push(mapped);
for (i++; i < array.length; i++) {
result.push(f(array[i], i));
}
return result;
}
}
}
return array;
}
function flatten(array) {
const result = [];
for (const v of array) {
if (v) {
if (isArray(v)) {
addRange(result, v);
} else {
result.push(v);
}
}
}
return result;
}
function flatMap(array, mapfn) {
let result;
if (array) {
for (let i = 0; i < array.length; i++) {
const v = mapfn(array[i], i);
if (v) {
if (isArray(v)) {
result = addRange(result, v);
} else {
result = append(result, v);
}
}
}
}
return result || emptyArray;
}
function flatMapToMutable(array, mapfn) {
const result = [];
if (array) {
for (let i = 0; i < array.length; i++) {
const v = mapfn(array[i], i);
if (v) {
if (isArray(v)) {
addRange(result, v);
} else {
result.push(v);
}
}
}
}
return result;
}
function* flatMapIterator(iter, mapfn) {
for (const x of iter) {
const iter2 = mapfn(x);
if (!iter2)
continue;
yield* iter2;
}
}
function sameFlatMap(array, mapfn) {
let result;
if (array) {
for (let i = 0; i < array.length; i++) {
const item = array[i];
const mapped = mapfn(item, i);
if (result || item !== mapped || isArray(mapped)) {
if (!result) {
result = array.slice(0, i);
}
if (isArray(mapped)) {
addRange(result, mapped);
} else {
result.push(mapped);
}
}
}
}
return result || array;
}
function mapAllOrFail(array, mapFn) {
const result = [];
for (let i = 0; i < array.length; i++) {
const mapped = mapFn(array[i], i);
if (mapped === void 0) {
return void 0;
}
result.push(mapped);
}
return result;
}
function mapDefined(array, mapFn) {
const result = [];
if (array) {
for (let i = 0; i < array.length; i++) {
const mapped = mapFn(array[i], i);
if (mapped !== void 0) {
result.push(mapped);
}
}
}
return result;
}
function* mapDefinedIterator(iter, mapFn) {
for (const x of iter) {
const value = mapFn(x);
if (value !== void 0) {
yield value;
}
}
}
function mapDefinedEntries(map2, f) {
if (!map2) {
return void 0;
}
const result = /* @__PURE__ */ new Map();
map2.forEach((value, key) => {
const entry = f(key, value);
if (entry !== void 0) {
const [newKey, newValue] = entry;
if (newKey !== void 0 && newValue !== void 0) {
result.set(newKey, newValue);
}
}
});
return result;
}
function getOrUpdate(map2, key, callback) {
if (map2.has(key)) {
return map2.get(key);
}
const value = callback();
map2.set(key, value);
return value;
}
function tryAddToSet(set, value) {
if (!set.has(value)) {
set.add(value);
return true;
}
return false;
}
function* singleIterator(value) {
yield value;
}
function spanMap(array, keyfn, mapfn) {
let result;
if (array) {
result = [];
const len = array.length;
let previousKey;
let key;
let start = 0;
let pos = 0;
while (start < len) {
while (pos < len) {
const value = array[pos];
key = keyfn(value, pos);
if (pos === 0) {
previousKey = key;
} else if (key !== previousKey) {
break;
}
pos++;
}
if (start < pos) {
const v = mapfn(array.slice(start, pos), previousKey, start, pos);
if (v) {
result.push(v);
}
start = pos;
}
previousKey = key;
pos++;
}
}
return result;
}
function mapEntries(map2, f) {
if (!map2) {
return void 0;
}
const result = /* @__PURE__ */ new Map();
map2.forEach((value, key) => {
const [newKey, newValue] = f(key, value);
result.set(newKey, newValue);
});
return result;
}
function some(array, predicate) {
if (array) {
if (predicate) {
for (const v of array) {
if (predicate(v)) {
return true;
}
}
} else {
return array.length > 0;
}
}
return false;
}
function getRangesWhere(arr, pred, cb) {
let start;
for (let i = 0; i < arr.length; i++) {
if (pred(arr[i])) {
start = start === void 0 ? i : start;
} else {
if (start !== void 0) {
cb(start, i);
start = void 0;
}
}
}
if (start !== void 0)
cb(start, arr.length);
}
function concatenate(array1, array2) {
if (!some(array2))
return array1;
if (!some(array1))
return array2;
return [...array1, ...array2];
}
function selectIndex(_, i) {
return i;
}
function indicesOf(array) {
return array.map(selectIndex);
}
function deduplicateRelational(array, equalityComparer, comparer) {
const indices = indicesOf(array);
stableSortIndices(array, indices, comparer);
let last2 = array[indices[0]];
const deduplicated = [indices[0]];
for (let i = 1; i < indices.length; i++) {
const index = indices[i];
const item = array[index];
if (!equalityComparer(last2, item)) {
deduplicated.push(index);
last2 = item;
}
}
deduplicated.sort();
return deduplicated.map((i) => array[i]);
}
function deduplicateEquality(array, equalityComparer) {
const result = [];
for (const item of array) {
pushIfUnique(result, item, equalityComparer);
}
return result;
}
function deduplicate(array, equalityComparer, comparer) {
return array.length === 0 ? [] : array.length === 1 ? array.slice() : comparer ? deduplicateRelational(array, equalityComparer, comparer) : deduplicateEquality(array, equalityComparer);
}
function deduplicateSorted(array, comparer) {
if (array.length === 0)
return emptyArray;
let last2 = array[0];
const deduplicated = [last2];
for (let i = 1; i < array.length; i++) {
const next = array[i];
switch (comparer(next, last2)) {
case true:
case 0 /* EqualTo */:
continue;
case -1 /* LessThan */:
return Debug.fail("Array is unsorted.");
}
deduplicated.push(last2 = next);
}
return deduplicated;
}
function createSortedArray() {
return [];
}
function insertSorted(array, insert, compare, allowDuplicates) {
if (array.length === 0) {
array.push(insert);
return true;
}
const insertIndex = binarySearch(array, insert, identity, compare);
if (insertIndex < 0) {
array.splice(~insertIndex, 0, insert);
return true;
}
if (allowDuplicates) {
array.splice(insertIndex, 0, insert);
return true;
}
return false;
}
function sortAndDeduplicate(array, comparer, equalityComparer) {
return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive);
}
function arrayIsSorted(array, comparer) {
if (array.length < 2)
return true;
for (let i = 1, len = array.length; i < len; i++) {
if (comparer(array[i - 1], array[i]) === 1 /* GreaterThan */) {
return false;
}
}
return true;
}
function detectSortCaseSensitivity(array, getString, compareStringsCaseSensitive2, compareStringsCaseInsensitive2) {
let kind = 3 /* Both */;
if (array.length < 2)
return kind;
let prevElement = getString(array[0]);
for (let i = 1, len = array.length; i < len && kind !== 0 /* None */; i++) {
const element = getString(array[i]);
if (kind & 1 /* CaseSensitive */ && compareStringsCaseSensitive2(prevElement, element) > 0) {
kind &= ~1 /* CaseSensitive */;
}
if (kind & 2 /* CaseInsensitive */ && compareStringsCaseInsensitive2(prevElement, element) > 0) {
kind &= ~2 /* CaseInsensitive */;
}
prevElement = element;
}
return kind;
}
function arrayIsEqualTo(array1, array2, equalityComparer = equateValues) {
if (!array1 || !array2) {
return array1 === array2;
}
if (array1.length !== array2.length) {
return false;
}
for (let i = 0; i < array1.length; i++) {
if (!equalityComparer(array1[i], array2[i], i)) {
return false;
}
}
return true;
}
function compact(array) {
let result;
if (array) {
for (let i = 0; i < array.length; i++) {
const v = array[i];
if (result || !v) {
if (!result) {
result = array.slice(0, i);
}
if (v) {
result.push(v);
}
}
}
}
return result || array;
}
function relativeComplement(arrayA, arrayB, comparer) {
if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0)
return arrayB;
const result = [];
loopB:
for (let offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
if (offsetB > 0) {
Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);
}
loopA:
for (const startA = offsetA; offsetA < arrayA.length; offsetA++) {
if (offsetA > startA) {
Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);
}
switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
case -1 /* LessThan */:
result.push(arrayB[offsetB]);
continue loopB;
case 0 /* EqualTo */:
continue loopB;
case 1 /* GreaterThan */:
continue loopA;
}
}
}
return result;
}
function append(to, value) {
if (value === void 0)
return to;
if (to === void 0)
return [value];
to.push(value);
return to;
}
function combine(xs, ys) {
if (xs === void 0)
return ys;
if (ys === void 0)
return xs;
if (isArray(xs))
return isArray(ys) ? concatenate(xs, ys) : append(xs, ys);
if (isArray(ys))
return append(ys, xs);
return [xs, ys];
}
function toOffset(array, offset) {
return offset < 0 ? array.length + offset : offset;
}
function addRange(to, from, start, end) {
if (from === void 0 || from.length === 0)
return to;
if (to === void 0)
return from.slice(start, end);
start = start === void 0 ? 0 : toOffset(from, start);
end = end === void 0 ? from.length : toOffset(from, end);
for (let i = start; i < end && i < from.length; i++) {
if (from[i] !== void 0) {
to.push(from[i]);
}
}
return to;
}
function pushIfUnique(array, toAdd, equalityComparer) {
if (contains(array, toAdd, equalityComparer)) {
return false;
} else {
array.push(toAdd);
return true;
}
}
function appendIfUnique(array, toAdd, equalityComparer) {
if (array) {
pushIfUnique(array, toAdd, equalityComparer);
return array;
} else {
return [toAdd];
}
}
function stableSortIndices(array, indices, comparer) {
indices.sort((x, y) => comparer(array[x], array[y]) || compareValues(x, y));
}
function sort(array, comparer) {
return array.length === 0 ? array : array.slice().sort(comparer);
}
function* arrayReverseIterator(array) {
for (let i = array.length - 1; i >= 0; i--) {
yield array[i];
}
}
function stableSort(array, comparer) {
const indices = indicesOf(array);
stableSortIndices(array, indices, comparer);
return indices.map((i) => array[i]);
}
function rangeEquals(array1, array2, pos, end) {
while (pos < end) {
if (array1[pos] !== array2[pos]) {
return false;
}
pos++;
}
return true;
}
function firstOrUndefined(array) {
return array === void 0 || array.length === 0 ? void 0 : array[0];
}
function firstOrUndefinedIterator(iter) {
if (iter) {
for (const value of iter) {
return value;
}
}
return void 0;
}
function first(array) {
Debug.assert(array.length !== 0);
return array[0];
}
function firstIterator(iter) {
for (const value of iter) {
return value;
}
Debug.fail("iterator is empty");
}
function lastOrUndefined(array) {
return array === void 0 || array.length === 0 ? void 0 : array[array.length - 1];
}
function last(array) {
Debug.assert(array.length !== 0);
return array[array.length - 1];
}
function singleOrUndefined(array) {
return array && array.length === 1 ? array[0] : void 0;
}
function single(array) {
return Debug.checkDefined(singleOrUndefined(array));
}
function singleOrMany(array) {
return array && array.length === 1 ? array[0] : array;
}
function replaceElement(array, index, value) {
const result = array.slice(0);
result[index] = value;
return result;
}
function binarySearch(array, value, keySelector, keyComparer, offset) {
return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset);
}
function binarySearchKey(array, key, keySelector, keyComparer, offset) {
if (!some(array)) {
return -1;
}
let low = offset || 0;
let high = array.length - 1;
while (low <= high) {
const middle = low + (high - low >> 1);
const midKey = keySelector(array[middle], middle);
switch (keyComparer(midKey, key)) {
case -1 /* LessThan */:
low = middle + 1;
break;
case 0 /* EqualTo */:
return middle;
case 1 /* GreaterThan */:
high = middle - 1;
break;
}
}
return ~low;
}
function reduceLeft(array, f, initial, start, count) {
if (array && array.length > 0) {
const size = array.length;
if (size > 0) {
let pos = start === void 0 || start < 0 ? 0 : start;
const end = count === void 0 || pos + count > size - 1 ? size - 1 : pos + count;
let result;
if (arguments.length <= 2) {
result = array[pos];
pos++;
} else {
result = initial;
}
while (pos <= end) {
result = f(result, array[pos], pos);
pos++;
}
return result;
}
}
return initial;
}
function hasProperty(map2, key) {
return hasOwnProperty.call(map2, key);
}
function getProperty(map2, key) {
return hasOwnProperty.call(map2, key) ? map2[key] : void 0;
}
function getOwnKeys(map2) {
const keys = [];
for (const key in map2) {
if (hasOwnProperty.call(map2, key)) {
keys.push(key);
}
}
return keys;
}
function getAllKeys(obj) {
const result = [];
do {
const names = Object.getOwnPropertyNames(obj);
for (const name of names) {
pushIfUnique(result, name);
}
} while (obj = Object.getPrototypeOf(obj));
return result;
}
function getOwnValues(collection) {
const values = [];
for (const key in collection) {
if (hasOwnProperty.call(collection, key)) {
values.push(collection[key]);
}
}
return values;
}
function arrayOf(count, f) {
const result = new Array(count);
for (let i = 0; i < count; i++) {
result[i] = f(i);
}
return result;
}
function arrayFrom(iterator, map2) {
const result = [];
for (const value of iterator) {
result.push(map2 ? map2(value) : value);
}
return result;
}
function assign(t, ...args) {
for (const arg of args) {
if (arg === void 0)
continue;
for (const p in arg) {
if (hasProperty(arg, p)) {
t[p] = arg[p];
}
}
}
return t;
}
function equalOwnProperties(left, right, equalityComparer = equateValues) {
if (left === right)
return true;
if (!left || !right)
return false;
for (const key in left) {
if (hasOwnProperty.call(left, key)) {
if (!hasOwnProperty.call(right, key))
return false;
if (!equalityComparer(left[key], right[key]))
return false;
}
}
for (const key in right) {
if (hasOwnProperty.call(right, key)) {
if (!hasOwnProperty.call(left, key))
return false;
}
}
return true;
}
function arrayToMap(array, makeKey, makeValue = identity) {
const result = /* @__PURE__ */ new Map();
for (const value of array) {
const key = makeKey(value);
if (key !== void 0)
result.set(key, makeValue(value));
}
return result;
}
function arrayToNumericMap(array, makeKey, makeValue = identity) {
const result = [];
for (const value of array) {
result[makeKey(value)] = makeValue(value);
}
return result;
}
function arrayToMultiMap(values, makeKey, makeValue = identity) {
const result = createMultiMap();
for (const value of values) {
result.add(makeKey(value), makeValue(value));
}
return result;
}
function group(values, getGroupId, resultSelector = identity) {
return arrayFrom(arrayToMultiMap(values, getGroupId).values(), resultSelector);
}
function groupBy(values, keySelector) {
const result = {};
if (values) {
for (const value of values) {
const key = `${keySelector(value)}`;
const array = result[key] ?? (result[key] = []);
array.push(value);
}
}
return result;
}
function clone(object) {
const result = {};
for (const id in object) {
if (hasOwnProperty.call(object, id)) {
result[id] = object[id];
}
}
return result;
}
function extend(first2, second) {
const result = {};
for (const id in second) {
if (hasOwnProperty.call(second, id)) {
result[id] = second[id];
}
}
for (const id in first2) {
if (hasOwnProperty.call(first2, id)) {
result[id] = first2[id];
}
}
return result;
}
function copyProperties(first2, second) {
for (const id in second) {
if (hasOwnProperty.call(second, id)) {
first2[id] = second[id];
}
}
}
function maybeBind(obj, fn) {
return fn ? fn.bind(obj) : void 0;
}
function createMultiMap() {
const map2 = /* @__PURE__ */ new Map();
map2.add = multiMapAdd;
map2.remove = multiMapRemove;
return map2;
}
function multiMapAdd(key, value) {
let values = this.get(key);
if (values) {
values.push(value);
} else {
this.set(key, values = [value]);
}
return values;
}
function multiMapRemove(key, value) {
const values = this.get(key);
if (values) {
unorderedRemoveItem(values, value);
if (!values.length) {
this.delete(key);
}
}
}
function createQueue(items) {
const elements = (items == null ? void 0 : items.slice()) || [];
let headIndex = 0;
function isEmpty() {
return headIndex === elements.length;
}
function enqueue(...items2) {
elements.push(...items2);
}
function dequeue() {
if (isEmpty()) {
throw new Error("Queue is empty");
}
const result = elements[headIndex];
elements[headIndex] = void 0;
headIndex++;
if (headIndex > 100 && headIndex > elements.length >> 1) {
const newLength = elements.length - headIndex;
elements.copyWithin(
/*target*/
0,
/*start*/
headIndex
);
elements.length = newLength;
headIndex = 0;
}
return result;
}
return {
enqueue,
dequeue,
isEmpty
};
}
function createSet(getHashCode, equals) {
const multiMap = /* @__PURE__ */ new Map();
let size = 0;
function* getElementIterator() {
for (const value of multiMap.values()) {
if (isArray(value)) {
yield* value;
} else {
yield value;
}
}
}
const set = {
has(element) {
const hash = getHashCode(element);
if (!multiMap.has(hash))
return false;
const candidates = multiMap.get(hash);
if (!isArray(candidates))
return equals(candidates, element);
for (const candidate of candidates) {
if (equals(candidate, element)) {
return true;
}
}
return false;
},
add(element) {
const hash = getHashCode(element);
if (multiMap.has(hash)) {
const values = multiMap.get(hash);
if (isArray(values)) {
if (!contains(values, element, equals)) {
values.push(element);
size++;
}
} else {
const value = values;
if (!equals(value, element)) {
multiMap.set(hash, [value, element]);
size++;
}
}
} else {
multiMap.set(hash, element);
size++;
}
return this;
},
delete(element) {
const hash = getHashCode(element);
if (!multiMap.has(hash))
return false;
const candidates = multiMap.get(hash);
if (isArray(candidates)) {
for (let i = 0; i < candidates.length; i++) {
if (equals(candidates[i], element)) {
if (candidates.length === 1) {
multiMap.delete(hash);
} else if (candidates.length === 2) {
multiMap.set(hash, candidates[1 - i]);
} else {
unorderedRemoveItemAt(candidates, i);
}
size--;
return true;
}
}
} else {
const candidate = candidates;
if (equals(candidate, element)) {
multiMap.delete(hash);
size--;
return true;
}
}
return false;
},
clear() {
multiMap.clear();
size = 0;
},
get size() {
return size;
},
forEach(action) {
for (const elements of arrayFrom(multiMap.values())) {
if (isArray(elements)) {
for (const element of elements) {
action(element, element, set);
}
} else {
const element = elements;
action(element, element, set);
}
}
},
keys() {
return getElementIterator();
},
values() {
return getElementIterator();
},
*entries() {
for (const value of getElementIterator()) {
yield [value, value];
}
},
[Symbol.iterator]: () => {
return getElementIterator();
},
[Symbol.toStringTag]: multiMap[Symbol.toStringTag]
};
return set;
}
function isArray(value) {
return Array.isArray(value);
}
function toArray(value) {
return isArray(value) ? value : [value];
}
function isString(text) {
return typeof text === "string";
}
function isNumber(x) {
return typeof x === "number";
}
function tryCast(value, test) {
return value !== void 0 && test(value) ? value : void 0;
}
function cast(value, test) {
if (value !== void 0 && test(value))
return value;
return Debug.fail(`Invalid cast. The supplied value ${value} did not pass the test '${Debug.getFunctionName(test)}'.`);
}
function noop(_) {
}
function returnFalse() {
return false;
}
function returnTrue() {
return true;
}
function returnUndefined() {
return void 0;
}
function identity(x) {
return x;
}
function toLowerCase(x) {
return x.toLowerCase();
}
function toFileNameLowerCase(x) {
return fileNameLowerCaseRegExp.test(x) ? x.replace(fileNameLowerCaseRegExp, toLowerCase) : x;
}
function notImplemented() {
throw new Error("Not implemented");
}
function memoize(callback) {
let value;
return () => {
if (callback) {
value = callback();
callback = void 0;
}
return value;
};
}
function memoizeOne(callback) {
const map2 = /* @__PURE__ */ new Map();
return (arg) => {
const key = `${typeof arg}:${arg}`;
let value = map2.get(key);
if (value === void 0 && !map2.has(key)) {
value = callback(arg);
map2.set(key, value);
}
return value;
};
}
function memoizeWeak(callback) {
const map2 = /* @__PURE__ */ new WeakMap();
return (arg) => {
let value = map2.get(arg);
if (value === void 0 && !map2.has(arg)) {
value = callback(arg);
map2.set(arg, value);
}
return value;
};
}
function memoizeCached(callback, cache) {
return (...args) => {
let value = cache.get(args);
if (value === void 0 && !cache.has(args)) {
value = callback(...args);
cache.set(args, value);
}
return value;
};
}
function compose(a, b, c, d, e) {
if (!!e) {
const args = [];
for (let i = 0; i < arguments.length; i++) {
args[i] = arguments[i];
}
return (t) => reduceLeft(args, (u, f) => f(u), t);
} else if (d) {
return (t) => d(c(b(a(t))));
} else if (c) {
return (t) => c(b(a(t)));
} else if (b) {
return (t) => b(a(t));
} else if (a) {
return (t) => a(t);
} else {
return (t) => t;
}
}
function equateValues(a, b) {
return a === b;
}
function equateStringsCaseInsensitive(a, b) {
return a === b || a !== void 0 && b !== void 0 && a.toUpperCase() === b.toUpperCase();
}
function equateStringsCaseSensitive(a, b) {
return equateValues(a, b);
}
function compareComparableValues(a, b) {
return a === b ? 0 /* EqualTo */ : a === void 0 ? -1 /* LessThan */ : b === void 0 ? 1 /* GreaterThan */ : a < b ? -1 /* LessThan */ : 1 /* GreaterThan */;
}
function compareValues(a, b) {
return compareComparableValues(a, b);
}
function compareTextSpans(a, b) {
return compareValues(a == null ? void 0 : a.start, b == null ? void 0 : b.start) || compareValues(a == null ? void 0 : a.length, b == null ? void 0 : b.length);
}
function min(items, compare) {
return reduceLeft(items, (x, y) => compare(x, y) === -1 /* LessThan */ ? x : y);
}
function compareStringsCaseInsensitive(a, b) {
if (a === b)
return 0 /* EqualTo */;
if (a === void 0)
return -1 /* LessThan */;
if (b === void 0)
return 1 /* GreaterThan */;
a = a.toUpperCase();
b = b.toUpperCase();
return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */;
}
function compareStringsCaseInsensitiveEslintCompatible(a, b) {
if (a === b)
return 0 /* EqualTo */;
if (a === void 0)
return -1 /* LessThan */;
if (b === void 0)
return 1 /* GreaterThan */;
a = a.toLowerCase();
b = b.toLowerCase();
return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */;
}
function compareStringsCaseSensitive(a, b) {
return compareComparableValues(a, b);
}
function getStringComparer(ignoreCase) {
return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
}
function getUILocale() {
return uiLocale;
}
function setUILocale(value) {
if (uiLocale !== value) {
uiLocale = value;
uiComparerCaseSensitive = void 0;
}
}
function compareStringsCaseSensitiveUI(a, b) {
const comparer = uiComparerCaseSensitive || (uiComparerCaseSensitive = createUIStringComparer(uiLocale));
return comparer(a, b);
}
function compareProperties(a, b, key, comparer) {
return a === b ? 0 /* EqualTo */ : a === void 0 ? -1 /* LessThan */ : b === void 0 ? 1 /* GreaterThan */ : comparer(a[key], b[key]);
}
function compareBooleans(a, b) {
return compareValues(a ? 1 : 0, b ? 1 : 0);
}
function getSpellingSuggestion(name, candidates, getName) {
const maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34));
let bestDistance = Math.floor(name.length * 0.4) + 1;
let bestCandidate;
for (const candidate of candidates) {
const candidateName = getName(candidate);
if (candidateName !== void 0 && Math.abs(candidateName.length - name.length) <= maximumLengthDifference) {
if (candidateName === name) {
continue;
}
if (candidateName.length < 3 && candidateName.toLowerCase() !== name.toLowerCase()) {
continue;
}
const distance = levenshteinWithMax(name, candidateName, bestDistance - 0.1);
if (distance === void 0) {
continue;
}
Debug.assert(distance < bestDistance);
bestDistance = distance;
bestCandidate = candidate;
}
}
return bestCandidate;
}
function levenshteinWithMax(s1, s2, max) {
let previous = new Array(s2.length + 1);
let current = new Array(s2.length + 1);
const big = max + 0.01;
for (let i = 0; i <= s2.length; i++) {
previous[i] = i;
}
for (let i = 1; i <= s1.length; i++) {
const c1 = s1.charCodeAt(i - 1);
const minJ = Math.ceil(i > max ? i - max : 1);
const maxJ = Math.floor(s2.length > max + i ? max + i : s2.length);
current[0] = i;
let colMin = i;
for (let j = 1; j < minJ; j++) {
current[j] = big;
}
for (let j = minJ; j <= maxJ; j++) {
const substitutionDistance = s1[i - 1].toLowerCase() === s2[j - 1].toLowerCase() ? previous[j - 1] + 0.1 : previous[j - 1] + 2;
const dist = c1 === s2.charCodeAt(j - 1) ? previous[j - 1] : Math.min(
/*delete*/
previous[j] + 1,
/*insert*/
current[j - 1] + 1,
/*substitute*/
substitutionDistance
);
current[j] = dist;
colMin = Math.min(colMin, dist);
}
for (let j = maxJ + 1; j <= s2.length; j++) {
current[j] = big;
}
if (colMin > max) {
return void 0;
}
const temp = previous;
previous = current;
current = temp;
}
const res = previous[s2.length];
return res > max ? void 0 : res;
}
function endsWith(str, suffix) {
const expectedPos = str.length - suffix.length;
return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
}
function removeSuffix(str, suffix) {
return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str;
}
function tryRemoveSuffix(str, suffix) {
return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : void 0;
}
function stringContains(str, substring) {
return str.indexOf(substring) !== -1;
}
function removeMinAndVersionNumbers(fileName) {
let end = fileName.length;
for (let pos = end - 1; pos > 0; pos--) {
let ch = fileName.charCodeAt(pos);
if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) {
do {
--pos;
ch = fileName.charCodeAt(pos);
} while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */);
} else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) {
--pos;
ch = fileName.charCodeAt(pos);
if (ch !== 105 /* i */ && ch !== 73 /* I */) {
break;
}
--pos;
ch = fileName.charCodeAt(pos);
if (ch !== 109 /* m */ && ch !== 77 /* M */) {
break;
}
--pos;
ch = fileName.charCodeAt(pos);
} else {
break;
}
if (ch !== 45 /* minus */ && ch !== 46 /* dot */) {
break;
}
end = pos;
}
return end === fileName.length ? fileName : fileName.slice(0, end);
}
function orderedRemoveItem(array, item) {
for (let i = 0; i < array.length; i++) {
if (array[i] === item) {
orderedRemoveItemAt(array, i);
return true;
}
}
return false;
}
function orderedRemoveItemAt(array, index) {
for (let i = index; i < array.length - 1; i++) {
array[i] = array[i + 1];
}
array.pop();
}
function unorderedRemoveItemAt(array, index) {
array[index] = array[array.length - 1];
array.pop();
}
function unorderedRemoveItem(array, item) {
return unorderedRemoveFirstItemWhere(array, (element) => element === item);
}
function unorderedRemoveFirstItemWhere(array, predicate) {
for (let i = 0; i < array.length; i++) {
if (predicate(array[i])) {
unorderedRemoveItemAt(array, i);
return true;
}
}
return false;
}
function createGetCanonicalFileName(useCaseSensitiveFileNames) {
return useCaseSensitiveFileNames ? identity : toFileNameLowerCase;
}
function patternText({ prefix, suffix }) {
return `${prefix}*${suffix}`;
}
function matchedText(pattern, candidate) {
Debug.assert(isPatternMatch(pattern, candidate));
return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
}
function findBestPatternMatch(values, getPattern, candidate) {
let matchedValue;
let longestMatchPrefixLength = -1;
for (const v of values) {
const pattern = getPattern(v);
if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
longestMatchPrefixLength = pattern.prefix.length;
matchedValue = v;
}
}
return matchedValue;
}
function startsWith(str, prefix) {
return str.lastIndexOf(prefix, 0) === 0;
}
function removePrefix(str, prefix) {
return startsWith(str, prefix) ? str.substr(prefix.length) : str;
}
function tryRemovePrefix(str, prefix, getCanonicalFileName = identity) {
return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : void 0;
}
function isPatternMatch({ prefix, suffix }, candidate) {
return candidate.length >= prefix.length + suffix.length && startsWith(candidate, prefix) && endsWith(candidate, suffix);
}
function and(f, g) {
return (arg) => f(arg) && g(arg);
}
function or(...fs) {
return (...args) => {
let lastResult;
for (const f of fs) {
lastResult = f(...args);
if (lastResult) {
return lastResult;
}
}
return lastResult;
};
}
function not(fn) {
return (...args) => !fn(...args);
}
function assertType(_) {
}
function singleElementArray(t) {
return t === void 0 ? void 0 : [t];
}
function enumerateInsertsAndDeletes(newItems, oldItems, comparer, inserted, deleted, unchanged) {
unchanged = unchanged || noop;
let newIndex = 0;
let oldIndex = 0;
const newLen = newItems.length;
const oldLen = oldItems.length;
let hasChanges = false;
while (newIndex < newLen && oldIndex < oldLen) {
const newItem = newItems[newIndex];
const oldItem = oldItems[oldIndex];
const compareResult = comparer(newItem, oldItem);
if (compareResult === -1 /* LessThan */) {
inserted(newItem);
newIndex++;
hasChanges = true;
} else if (compareResult === 1 /* GreaterThan */) {
deleted(oldItem);
oldIndex++;
hasChanges = true;
} else {
unchanged(oldItem, newItem);
newIndex++;
oldIndex++;
}
}
while (newIndex < newLen) {
inserted(newItems[newIndex++]);
hasChanges = true;
}
while (oldIndex < oldLen) {
deleted(oldItems[oldIndex++]);
hasChanges = true;
}
return hasChanges;
}
function cartesianProduct(arrays) {
const result = [];
cartesianProductWorker(
arrays,
result,
/*outer*/
void 0,
0
);
return result;
}
function cartesianProductWorker(arrays, result, outer, index) {
for (const element of arrays[index]) {
let inner;
if (outer) {
inner = outer.slice();
inner.push(element);
} else {
inner = [element];
}
if (index === arrays.length - 1) {
result.push(inner);
} else {
cartesianProductWorker(arrays, result, inner, index + 1);
}
}
}
function padLeft(s, length2, padString = " ") {
return length2 <= s.length ? s : padString.repeat(length2 - s.length) + s;
}
function padRight(s, length2, padString = " ") {
return length2 <= s.length ? s : s + padString.repeat(length2 - s.length);
}
function takeWhile(array, predicate) {
if (array) {
const len = array.length;
let index = 0;
while (index < len && predicate(array[index])) {
index++;
}
return array.slice(0, index);
}
}
function skipWhile(array, predicate) {
if (array) {
const len = array.length;
let index = 0;
while (index < len && predicate(array[index])) {
index++;
}
return array.slice(index);
}
}
function trimEndImpl(s) {
let end = s.length - 1;
while (end >= 0) {
if (!isWhiteSpaceLike(s.charCodeAt(end)))
break;
end--;
}
return s.slice(0, end + 1);
}
function isNodeLikeSystem() {
return typeof process !== "undefined" && !!process.nextTick && !process.browser && typeof module === "object";
}
var emptyArray, emptyMap, emptySet, SortKind, elementAt, hasOwnProperty, fileNameLowerCaseRegExp, AssertionLevel, createUIStringComparer, uiComparerCaseSensitive, uiLocale, trimString, trimStringEnd, trimStringStart;
var init_core = __esm({
"src/compiler/core.ts"() {
init_ts2();
emptyArray = [];
emptyMap = /* @__PURE__ */ new Map();
emptySet = /* @__PURE__ */ new Set();
SortKind = /* @__PURE__ */ ((SortKind2) => {
SortKind2[SortKind2["None"] = 0] = "None";
SortKind2[SortKind2["CaseSensitive"] = 1] = "CaseSensitive";
SortKind2[SortKind2["CaseInsensitive"] = 2] = "CaseInsensitive";
SortKind2[SortKind2["Both"] = 3] = "Both";
return SortKind2;
})(SortKind || {});
elementAt = !!Array.prototype.at ? (array, offset) => array == null ? void 0 : array.at(offset) : (array, offset) => {
if (array) {
offset = toOffset(array, offset);
if (offset < array.length) {
return array[offset];
}
}
return void 0;
};
hasOwnProperty = Object.prototype.hasOwnProperty;
fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
AssertionLevel = /* @__PURE__ */ ((AssertionLevel2) => {
AssertionLevel2[AssertionLevel2["None"] = 0] = "None";
AssertionLevel2[AssertionLevel2["Normal"] = 1] = "Normal";
AssertionLevel2[AssertionLevel2["Aggressive"] = 2] = "Aggressive";
AssertionLevel2[AssertionLevel2["VeryAggressive"] = 3] = "VeryAggressive";
return AssertionLevel2;
})(AssertionLevel || {});
createUIStringComparer = (() => {
let defaultComparer;
let enUSComparer;
const stringComparerFactory = getStringComparerFactory();
return createStringComparer;
function compareWithCallback(a, b, comparer) {
if (a === b)
return 0 /* EqualTo */;
if (a === void 0)
return -1 /* LessThan */;
if (b === void 0)
return 1 /* GreaterThan */;
const value = comparer(a, b);
return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */;
}
function createIntlCollatorStringComparer(locale) {
const comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
return (a, b) => compareWithCallback(a, b, comparer);
}
function createLocaleCompareStringComparer(locale) {
if (locale !== void 0)
return createFallbackStringComparer();
return (a, b) => compareWithCallback(a, b, compareStrings);
function compareStrings(a, b) {
return a.localeCompare(b);
}
}
function createFallbackStringComparer() {
return (a, b) => compareWithCallback(a, b, compareDictionaryOrder);
function compareDictionaryOrder(a, b) {
return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b);
}
function compareStrings(a, b) {
return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */;
}
}
function getStringComparerFactory() {
if (typeof Intl === "object" && typeof Intl.Collator === "function") {
return createIntlCollatorStringComparer;
}
if (typeof String.prototype.localeCompare === "function" && typeof String.prototype.toLocaleUpperCase === "function" && "a".localeCompare("B") < 0) {
return createLocaleCompareStringComparer;
}
return createFallbackStringComparer;
}
function createStringComparer(locale) {
if (locale === void 0) {
return defaultComparer || (defaultComparer = stringComparerFactory(locale));
} else if (locale === "en-US") {
return enUSComparer || (enUSComparer = stringComparerFactory(locale));
} else {
return stringComparerFactory(locale);
}
}
})();
trimString = !!String.prototype.trim ? (s) => s.trim() : (s) => trimStringEnd(trimStringStart(s));
trimStringEnd = !!String.prototype.trimEnd ? (s) => s.trimEnd() : trimEndImpl;
trimStringStart = !!String.prototype.trimStart ? (s) => s.trimStart() : (s) => s.replace(/^\s+/g, "");
}
});
// src/compiler/debug.ts
var LogLevel, Debug;
var init_debug = __esm({
"src/compiler/debug.ts"() {
init_ts2();
init_ts2();
LogLevel = /* @__PURE__ */ ((LogLevel2) => {
LogLevel2[LogLevel2["Off"] = 0] = "Off";
LogLevel2[LogLevel2["Error"] = 1] = "Error";
LogLevel2[LogLevel2["Warning"] = 2] = "Warning";
LogLevel2[LogLevel2["Info"] = 3] = "Info";
LogLevel2[LogLevel2["Verbose"] = 4] = "Verbose";
return LogLevel2;
})(LogLevel || {});
((Debug2) => {
let currentAssertionLevel = 0 /* None */;
Debug2.currentLogLevel = 2 /* Warning */;
Debug2.isDebugging = false;
function shouldLog(level) {
return Debug2.currentLogLevel <= level;
}
Debug2.shouldLog = shouldLog;
function logMessage(level, s) {
if (Debug2.loggingHost && shouldLog(level)) {
Debug2.loggingHost.log(level, s);
}
}
function log(s) {
logMessage(3 /* Info */, s);
}
Debug2.log = log;
((_log) => {
function error(s) {
logMessage(1 /* Error */, s);
}
_log.error = error;
function warn(s) {
logMessage(2 /* Warning */, s);
}
_log.warn = warn;
function log2(s) {
logMessage(3 /* Info */, s);
}
_log.log = log2;
function trace2(s) {
logMessage(4 /* Verbose */, s);
}
_log.trace = trace2;
})(log = Debug2.log || (Debug2.log = {}));
const assertionCache = {};
function getAssertionLevel() {
return currentAssertionLevel;
}
Debug2.getAssertionLevel = getAssertionLevel;
function setAssertionLevel(level) {
const prevAssertionLevel = currentAssertionLevel;
currentAssertionLevel = level;
if (level > prevAssertionLevel) {
for (const key of getOwnKeys(assertionCache)) {
const cachedFunc = assertionCache[key];
if (cachedFunc !== void 0 && Debug2[key] !== cachedFunc.assertion && level >= cachedFunc.level) {
Debug2[key] = cachedFunc;
assertionCache[key] = void 0;
}
}
}
}