UNPKG

storybook-addon-sdc

Version:

Drupal Single Directory Components as stories

1,417 lines (1,412 loc) 397 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw Error('Dynamic require of "' + x + '" is not supported'); }); var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require2() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); // node_modules/tsup/assets/esm_shims.js import path from "path"; import { fileURLToPath } from "url"; var init_esm_shims = __esm({ "node_modules/tsup/assets/esm_shims.js"() { "use strict"; } }); // node_modules/@christianwiedemann/drupal-twig-extensions/state.cjs var require_state = __commonJS({ "node_modules/@christianwiedemann/drupal-twig-extensions/state.cjs"(exports, module) { "use strict"; init_esm_shims(); var state3 = {}; module.exports.state = state3; } }); // node_modules/locutus/php/datetime/date.js var require_date = __commonJS({ "node_modules/locutus/php/datetime/date.js"(exports, module) { "use strict"; init_esm_shims(); module.exports = function date3(format, timestamp) { let jsdate; let f; const txtWords = [ "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; const formatChr = /\\?(.?)/gi; const formatChrCb = function(t, s) { return f[t] ? f[t]() : s; }; const _pad = function(n, c) { n = String(n); while (n.length < c) { n = "0" + n; } return n; }; f = { // Day d: function() { return _pad(f.j(), 2); }, D: function() { return f.l().slice(0, 3); }, j: function() { return jsdate.getDate(); }, l: function() { return txtWords[f.w()] + "day"; }, N: function() { return f.w() || 7; }, S: function() { const j = f.j(); let i = j % 10; if (i <= 3 && parseInt(j % 100 / 10, 10) === 1) { i = 0; } return ["st", "nd", "rd"][i - 1] || "th"; }, w: function() { return jsdate.getDay(); }, z: function() { const a = new Date(f.Y(), f.n() - 1, f.j()); const b = new Date(f.Y(), 0, 1); return Math.round((a - b) / 864e5); }, // Week W: function() { const a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3); const b = new Date(a.getFullYear(), 0, 4); return _pad(1 + Math.round((a - b) / 864e5 / 7), 2); }, // Month F: function() { return txtWords[6 + f.n()]; }, m: function() { return _pad(f.n(), 2); }, M: function() { return f.F().slice(0, 3); }, n: function() { return jsdate.getMonth() + 1; }, t: function() { return new Date(f.Y(), f.n(), 0).getDate(); }, // Year L: function() { const j = f.Y(); return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0; }, o: function() { const n = f.n(); const W = f.W(); const Y = f.Y(); return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0); }, Y: function() { return jsdate.getFullYear(); }, y: function() { return f.Y().toString().slice(-2); }, // Time a: function() { return jsdate.getHours() > 11 ? "pm" : "am"; }, A: function() { return f.a().toUpperCase(); }, B: function() { const H = jsdate.getUTCHours() * 3600; const i = jsdate.getUTCMinutes() * 60; const s = jsdate.getUTCSeconds(); return _pad(Math.floor((H + i + s + 3600) / 86.4) % 1e3, 3); }, g: function() { return f.G() % 12 || 12; }, G: function() { return jsdate.getHours(); }, h: function() { return _pad(f.g(), 2); }, H: function() { return _pad(f.G(), 2); }, i: function() { return _pad(jsdate.getMinutes(), 2); }, s: function() { return _pad(jsdate.getSeconds(), 2); }, u: function() { return _pad(jsdate.getMilliseconds() * 1e3, 6); }, // Timezone e: function() { const msg = "Not supported (see source code of date() for timezone on how to add support)"; throw new Error(msg); }, I: function() { const a = new Date(f.Y(), 0); const c = Date.UTC(f.Y(), 0); const b = new Date(f.Y(), 6); const d = Date.UTC(f.Y(), 6); return a - c !== b - d ? 1 : 0; }, O: function() { const tzo = jsdate.getTimezoneOffset(); const a = Math.abs(tzo); return (tzo > 0 ? "-" : "+") + _pad(Math.floor(a / 60) * 100 + a % 60, 4); }, P: function() { const O = f.O(); return O.substr(0, 3) + ":" + O.substr(3, 2); }, T: function() { return "UTC"; }, Z: function() { return -jsdate.getTimezoneOffset() * 60; }, // Full Date/Time c: function() { return "Y-m-d\\TH:i:sP".replace(formatChr, formatChrCb); }, r: function() { return "D, d M Y H:i:s O".replace(formatChr, formatChrCb); }, U: function() { return jsdate / 1e3 | 0; } }; const _date = function(format2, timestamp2) { jsdate = timestamp2 === void 0 ? /* @__PURE__ */ new Date() : timestamp2 instanceof Date ? new Date(timestamp2) : new Date(timestamp2 * 1e3); return format2.replace(formatChr, formatChrCb); }; return _date(format, timestamp); }; } }); // node_modules/lodash.clonedeep/index.js var require_lodash = __commonJS({ "node_modules/lodash.clonedeep/index.js"(exports, module) { "use strict"; init_esm_shims(); var LARGE_ARRAY_SIZE = 200; var HASH_UNDEFINED = "__lodash_hash_undefined__"; var MAX_SAFE_INTEGER = 9007199254740991; var argsTag = "[object Arguments]"; var arrayTag = "[object Array]"; var boolTag = "[object Boolean]"; var dateTag = "[object Date]"; var errorTag = "[object Error]"; var funcTag = "[object Function]"; var genTag = "[object GeneratorFunction]"; var mapTag = "[object Map]"; var numberTag = "[object Number]"; var objectTag = "[object Object]"; var promiseTag = "[object Promise]"; var regexpTag = "[object RegExp]"; var setTag = "[object Set]"; var stringTag = "[object String]"; var symbolTag = "[object Symbol]"; var weakMapTag = "[object WeakMap]"; var arrayBufferTag = "[object ArrayBuffer]"; var dataViewTag = "[object DataView]"; var float32Tag = "[object Float32Array]"; var float64Tag = "[object Float64Array]"; var int8Tag = "[object Int8Array]"; var int16Tag = "[object Int16Array]"; var int32Tag = "[object Int32Array]"; var uint8Tag = "[object Uint8Array]"; var uint8ClampedTag = "[object Uint8ClampedArray]"; var uint16Tag = "[object Uint16Array]"; var uint32Tag = "[object Uint32Array]"; var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; var reFlags = /\w*$/; var reIsHostCtor = /^\[object .+?Constructor\]$/; var reIsUint = /^(?:0|[1-9]\d*)$/; var cloneableTags = {}; cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false; var freeGlobal = typeof global == "object" && global && global.Object === Object && global; var freeSelf = typeof self == "object" && self && self.Object === Object && self; var root = freeGlobal || freeSelf || Function("return this")(); var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports; var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module; var moduleExports = freeModule && freeModule.exports === freeExports; function addMapEntry(map, pair) { map.set(pair[0], pair[1]); return map; } function addSetEntry(set, value) { set.add(value); return set; } function arrayEach(array, iteratee) { var index = -1, length = array ? array.length : 0; while (++index < length) { if (iteratee(array[index], index, array) === false) { break; } } return array; } function arrayPush(array, values) { var index = -1, length = values.length, offset = array.length; while (++index < length) { array[offset + index] = values[index]; } return array; } function arrayReduce(array, iteratee, accumulator, initAccum) { var index = -1, length = array ? array.length : 0; if (initAccum && length) { accumulator = array[++index]; } while (++index < length) { accumulator = iteratee(accumulator, array[index], index, array); } return accumulator; } function baseTimes(n, iteratee) { var index = -1, result = Array(n); while (++index < n) { result[index] = iteratee(index); } return result; } function getValue(object, key) { return object == null ? void 0 : object[key]; } function isHostObject(value) { var result = false; if (value != null && typeof value.toString != "function") { try { result = !!(value + ""); } catch (e) { } } return result; } function mapToArray(map) { var index = -1, result = Array(map.size); map.forEach(function(value, key) { result[++index] = [key, value]; }); return result; } function overArg(func, transform) { return function(arg) { return func(transform(arg)); }; } function setToArray(set) { var index = -1, result = Array(set.size); set.forEach(function(value) { result[++index] = value; }); return result; } var arrayProto = Array.prototype; var funcProto = Function.prototype; var objectProto = Object.prototype; var coreJsData = root["__core-js_shared__"]; var maskSrcKey = (function() { var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ""); return uid ? "Symbol(src)_1." + uid : ""; })(); var funcToString = funcProto.toString; var hasOwnProperty = objectProto.hasOwnProperty; var objectToString = objectProto.toString; var reIsNative = RegExp( "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" ); var Buffer2 = moduleExports ? root.Buffer : void 0; var Symbol2 = root.Symbol; var Uint8Array2 = root.Uint8Array; var getPrototype = overArg(Object.getPrototypeOf, Object); var objectCreate = Object.create; var propertyIsEnumerable = objectProto.propertyIsEnumerable; var splice = arrayProto.splice; var nativeGetSymbols = Object.getOwnPropertySymbols; var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0; var nativeKeys = overArg(Object.keys, Object); var DataView = getNative(root, "DataView"); var Map2 = getNative(root, "Map"); var Promise2 = getNative(root, "Promise"); var Set2 = getNative(root, "Set"); var WeakMap2 = getNative(root, "WeakMap"); var nativeCreate = getNative(Object, "create"); var dataViewCtorString = toSource(DataView); var mapCtorString = toSource(Map2); var promiseCtorString = toSource(Promise2); var setCtorString = toSource(Set2); var weakMapCtorString = toSource(WeakMap2); var symbolProto = Symbol2 ? Symbol2.prototype : void 0; var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0; function Hash(entries2) { var index = -1, length = entries2 ? entries2.length : 0; this.clear(); while (++index < length) { var entry = entries2[index]; this.set(entry[0], entry[1]); } } function hashClear() { this.__data__ = nativeCreate ? nativeCreate(null) : {}; } function hashDelete(key) { return this.has(key) && delete this.__data__[key]; } function hashGet(key) { var data = this.__data__; if (nativeCreate) { var result = data[key]; return result === HASH_UNDEFINED ? void 0 : result; } return hasOwnProperty.call(data, key) ? data[key] : void 0; } function hashHas(key) { var data = this.__data__; return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key); } function hashSet(key, value) { var data = this.__data__; data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value; return this; } Hash.prototype.clear = hashClear; Hash.prototype["delete"] = hashDelete; Hash.prototype.get = hashGet; Hash.prototype.has = hashHas; Hash.prototype.set = hashSet; function ListCache(entries2) { var index = -1, length = entries2 ? entries2.length : 0; this.clear(); while (++index < length) { var entry = entries2[index]; this.set(entry[0], entry[1]); } } function listCacheClear() { this.__data__ = []; } function listCacheDelete(key) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { return false; } var lastIndex = data.length - 1; if (index == lastIndex) { data.pop(); } else { splice.call(data, index, 1); } return true; } function listCacheGet(key) { var data = this.__data__, index = assocIndexOf(data, key); return index < 0 ? void 0 : data[index][1]; } function listCacheHas(key) { return assocIndexOf(this.__data__, key) > -1; } function listCacheSet(key, value) { var data = this.__data__, index = assocIndexOf(data, key); if (index < 0) { data.push([key, value]); } else { data[index][1] = value; } return this; } ListCache.prototype.clear = listCacheClear; ListCache.prototype["delete"] = listCacheDelete; ListCache.prototype.get = listCacheGet; ListCache.prototype.has = listCacheHas; ListCache.prototype.set = listCacheSet; function MapCache(entries2) { var index = -1, length = entries2 ? entries2.length : 0; this.clear(); while (++index < length) { var entry = entries2[index]; this.set(entry[0], entry[1]); } } function mapCacheClear() { this.__data__ = { "hash": new Hash(), "map": new (Map2 || ListCache)(), "string": new Hash() }; } function mapCacheDelete(key) { return getMapData(this, key)["delete"](key); } function mapCacheGet(key) { return getMapData(this, key).get(key); } function mapCacheHas(key) { return getMapData(this, key).has(key); } function mapCacheSet(key, value) { getMapData(this, key).set(key, value); return this; } MapCache.prototype.clear = mapCacheClear; MapCache.prototype["delete"] = mapCacheDelete; MapCache.prototype.get = mapCacheGet; MapCache.prototype.has = mapCacheHas; MapCache.prototype.set = mapCacheSet; function Stack(entries2) { this.__data__ = new ListCache(entries2); } function stackClear() { this.__data__ = new ListCache(); } function stackDelete(key) { return this.__data__["delete"](key); } function stackGet(key) { return this.__data__.get(key); } function stackHas(key) { return this.__data__.has(key); } function stackSet(key, value) { var cache = this.__data__; if (cache instanceof ListCache) { var pairs = cache.__data__; if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) { pairs.push([key, value]); return this; } cache = this.__data__ = new MapCache(pairs); } cache.set(key, value); return this; } Stack.prototype.clear = stackClear; Stack.prototype["delete"] = stackDelete; Stack.prototype.get = stackGet; Stack.prototype.has = stackHas; Stack.prototype.set = stackSet; function arrayLikeKeys(value, inherited) { var result = isArray(value) || isArguments(value) ? baseTimes(value.length, String) : []; var length = result.length, skipIndexes = !!length; for (var key in value) { if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == "length" || isIndex(key, length)))) { result.push(key); } } return result; } function assignValue(object, key, value) { var objValue = object[key]; if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) { object[key] = value; } } function assocIndexOf(array, key) { var length = array.length; while (length--) { if (eq(array[length][0], key)) { return length; } } return -1; } function baseAssign(object, source) { return object && copyObject(source, keys(source), object); } function baseClone(value, isDeep, isFull, customizer, key, object, stack) { var result; if (customizer) { result = object ? customizer(value, key, object, stack) : customizer(value); } if (result !== void 0) { return result; } if (!isObject2(value)) { return value; } var isArr = isArray(value); if (isArr) { result = initCloneArray(value); if (!isDeep) { return copyArray(value, result); } } else { var tag = getTag(value), isFunc = tag == funcTag || tag == genTag; if (isBuffer(value)) { return cloneBuffer(value, isDeep); } if (tag == objectTag || tag == argsTag || isFunc && !object) { if (isHostObject(value)) { return object ? value : {}; } result = initCloneObject(isFunc ? {} : value); if (!isDeep) { return copySymbols(value, baseAssign(result, value)); } } else { if (!cloneableTags[tag]) { return object ? value : {}; } result = initCloneByTag(value, tag, baseClone, isDeep); } } stack || (stack = new Stack()); var stacked = stack.get(value); if (stacked) { return stacked; } stack.set(value, result); if (!isArr) { var props = isFull ? getAllKeys(value) : keys(value); } arrayEach(props || value, function(subValue, key2) { if (props) { key2 = subValue; subValue = value[key2]; } assignValue(result, key2, baseClone(subValue, isDeep, isFull, customizer, key2, value, stack)); }); return result; } function baseCreate(proto) { return isObject2(proto) ? objectCreate(proto) : {}; } function baseGetAllKeys(object, keysFunc, symbolsFunc) { var result = keysFunc(object); return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); } function baseGetTag(value) { return objectToString.call(value); } function baseIsNative(value) { if (!isObject2(value) || isMasked(value)) { return false; } var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource(value)); } function baseKeys(object) { if (!isPrototype(object)) { return nativeKeys(object); } var result = []; for (var key in Object(object)) { if (hasOwnProperty.call(object, key) && key != "constructor") { result.push(key); } } return result; } function cloneBuffer(buffer, isDeep) { if (isDeep) { return buffer.slice(); } var result = new buffer.constructor(buffer.length); buffer.copy(result); return result; } function cloneArrayBuffer(arrayBuffer) { var result = new arrayBuffer.constructor(arrayBuffer.byteLength); new Uint8Array2(result).set(new Uint8Array2(arrayBuffer)); return result; } function cloneDataView(dataView, isDeep) { var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); } function cloneMap(map, isDeep, cloneFunc) { var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map); return arrayReduce(array, addMapEntry, new map.constructor()); } function cloneRegExp(regexp) { var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); result.lastIndex = regexp.lastIndex; return result; } function cloneSet(set, isDeep, cloneFunc) { var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set); return arrayReduce(array, addSetEntry, new set.constructor()); } function cloneSymbol(symbol) { return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; } function cloneTypedArray(typedArray, isDeep) { var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); } function copyArray(source, array) { var index = -1, length = source.length; array || (array = Array(length)); while (++index < length) { array[index] = source[index]; } return array; } function copyObject(source, props, object, customizer) { object || (object = {}); var index = -1, length = props.length; while (++index < length) { var key = props[index]; var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0; assignValue(object, key, newValue === void 0 ? source[key] : newValue); } return object; } function copySymbols(source, object) { return copyObject(source, getSymbols(source), object); } function getAllKeys(object) { return baseGetAllKeys(object, keys, getSymbols); } function getMapData(map, key) { var data = map.__data__; return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; } function getNative(object, key) { var value = getValue(object, key); return baseIsNative(value) ? value : void 0; } var getSymbols = nativeGetSymbols ? overArg(nativeGetSymbols, Object) : stubArray; var getTag = baseGetTag; if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) { getTag = function(value) { var result = objectToString.call(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : void 0; if (ctorString) { switch (ctorString) { case dataViewCtorString: return dataViewTag; case mapCtorString: return mapTag; case promiseCtorString: return promiseTag; case setCtorString: return setTag; case weakMapCtorString: return weakMapTag; } } return result; }; } function initCloneArray(array) { var length = array.length, result = array.constructor(length); if (length && typeof array[0] == "string" && hasOwnProperty.call(array, "index")) { result.index = array.index; result.input = array.input; } return result; } function initCloneObject(object) { return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {}; } function initCloneByTag(object, tag, cloneFunc, isDeep) { var Ctor = object.constructor; switch (tag) { case arrayBufferTag: return cloneArrayBuffer(object); case boolTag: case dateTag: return new Ctor(+object); case dataViewTag: return cloneDataView(object, isDeep); case float32Tag: case float64Tag: case int8Tag: case int16Tag: case int32Tag: case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: return cloneTypedArray(object, isDeep); case mapTag: return cloneMap(object, isDeep, cloneFunc); case numberTag: case stringTag: return new Ctor(object); case regexpTag: return cloneRegExp(object); case setTag: return cloneSet(object, isDeep, cloneFunc); case symbolTag: return cloneSymbol(object); } } function isIndex(value, length) { length = length == null ? MAX_SAFE_INTEGER : length; return !!length && (typeof value == "number" || reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length); } function isKeyable(value) { var type = typeof value; return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null; } function isMasked(func) { return !!maskSrcKey && maskSrcKey in func; } function isPrototype(value) { var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto; return value === proto; } function toSource(func) { if (func != null) { try { return funcToString.call(func); } catch (e) { } try { return func + ""; } catch (e) { } } return ""; } function cloneDeep3(value) { return baseClone(value, true, true); } function eq(value, other) { return value === other || value !== value && other !== other; } function isArguments(value) { return isArrayLikeObject(value) && hasOwnProperty.call(value, "callee") && (!propertyIsEnumerable.call(value, "callee") || objectToString.call(value) == argsTag); } var isArray = Array.isArray; function isArrayLike(value) { return value != null && isLength(value.length) && !isFunction(value); } function isArrayLikeObject(value) { return isObjectLike(value) && isArrayLike(value); } var isBuffer = nativeIsBuffer || stubFalse; function isFunction(value) { var tag = isObject2(value) ? objectToString.call(value) : ""; return tag == funcTag || tag == genTag; } function isLength(value) { return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } function isObject2(value) { var type = typeof value; return !!value && (type == "object" || type == "function"); } function isObjectLike(value) { return !!value && typeof value == "object"; } function keys(object) { return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } function stubArray() { return []; } function stubFalse() { return false; } module.exports = cloneDeep3; } }); // node_modules/twig/src/twig.core.js var require_twig_core = __commonJS({ "node_modules/twig/src/twig.core.js"(exports, module) { "use strict"; init_esm_shims(); module.exports = function(Twig2) { "use strict"; Twig2.trace = false; Twig2.debug = false; Twig2.cache = true; Twig2.noop = function() { }; Twig2.merge = function(target, source, onlyChanged) { Object.keys(source).forEach((key) => { if (onlyChanged && !(key in target)) { return; } target[key] = source[key]; }); return target; }; Twig2.Error = function(message, file) { this.message = message; this.name = "TwigException"; this.type = "TwigException"; this.file = file; }; Twig2.Error.prototype.toString = function() { const output = this.name + ": " + this.message; return output; }; Twig2.log = { trace(...args) { if (Twig2.trace && console) { console.log(Array.prototype.slice.call(args)); } }, debug(...args) { if (Twig2.debug && console) { console.log(Array.prototype.slice.call(args)); } } }; if (typeof console === "undefined") { Twig2.log.error = function() { }; } else if (typeof console.error !== "undefined") { Twig2.log.error = function(...args) { console.error(...args); }; } else if (typeof console.log !== "undefined") { Twig2.log.error = function(...args) { console.log(...args); }; } Twig2.token = {}; Twig2.token.type = { output: "output", logic: "logic", comment: "comment", raw: "raw", outputWhitespacePre: "output_whitespace_pre", outputWhitespacePost: "output_whitespace_post", outputWhitespaceBoth: "output_whitespace_both", logicWhitespacePre: "logic_whitespace_pre", logicWhitespacePost: "logic_whitespace_post", logicWhitespaceBoth: "logic_whitespace_both" }; Twig2.token.definitions = [ { type: Twig2.token.type.raw, open: "{% raw %}", close: "{% endraw %}" }, { type: Twig2.token.type.raw, open: "{% verbatim %}", close: "{% endverbatim %}" }, // *Whitespace type tokens* // // These typically take the form `{{- expression -}}` or `{{- expression }}` or `{{ expression -}}`. { type: Twig2.token.type.outputWhitespacePre, open: "{{-", close: "}}" }, { type: Twig2.token.type.outputWhitespacePost, open: "{{", close: "-}}" }, { type: Twig2.token.type.outputWhitespaceBoth, open: "{{-", close: "-}}" }, { type: Twig2.token.type.logicWhitespacePre, open: "{%-", close: "%}" }, { type: Twig2.token.type.logicWhitespacePost, open: "{%", close: "-%}" }, { type: Twig2.token.type.logicWhitespaceBoth, open: "{%-", close: "-%}" }, // *Output type tokens* // // These typically take the form `{{ expression }}`. { type: Twig2.token.type.output, open: "{{", close: "}}" }, // *Logic type tokens* // // These typically take a form like `{% if expression %}` or `{% endif %}` { type: Twig2.token.type.logic, open: "{%", close: "%}" }, // *Comment type tokens* // // These take the form `{# anything #}` { type: Twig2.token.type.comment, open: "{#", close: "#}" } ]; Twig2.token.strings = ['"', "'"]; Twig2.token.findStart = function(template) { const output = { position: null, def: null }; let closePosition = null; const len = Twig2.token.definitions.length; let i; let tokenTemplate; let firstKeyPosition; let closeKeyPosition; for (i = 0; i < len; i++) { tokenTemplate = Twig2.token.definitions[i]; firstKeyPosition = template.indexOf(tokenTemplate.open); closeKeyPosition = template.indexOf(tokenTemplate.close); Twig2.log.trace("Twig.token.findStart: ", "Searching for ", tokenTemplate.open, " found at ", firstKeyPosition); if (firstKeyPosition >= 0) { if (tokenTemplate.open.length !== tokenTemplate.close.length) { if (closeKeyPosition < 0) { continue; } } } if (firstKeyPosition >= 0 && (output.position === null || firstKeyPosition < output.position)) { output.position = firstKeyPosition; output.def = tokenTemplate; closePosition = closeKeyPosition; } else if (firstKeyPosition >= 0 && output.position !== null && firstKeyPosition === output.position) { if (tokenTemplate.open.length > output.def.open.length) { output.position = firstKeyPosition; output.def = tokenTemplate; closePosition = closeKeyPosition; } else if (tokenTemplate.open.length === output.def.open.length) { if (tokenTemplate.close.length > output.def.close.length) { if (closeKeyPosition >= 0 && closeKeyPosition < closePosition) { output.position = firstKeyPosition; output.def = tokenTemplate; closePosition = closeKeyPosition; } } else if (closeKeyPosition >= 0 && closeKeyPosition < closePosition) { output.position = firstKeyPosition; output.def = tokenTemplate; closePosition = closeKeyPosition; } } } } return output; }; Twig2.token.findEnd = function(template, tokenDef, start) { let end = null; let found = false; let offset = 0; let strPos = null; let strFound = null; let pos = null; let endOffset = null; let thisStrPos = null; let endStrPos = null; let i; let l; while (!found) { strPos = null; strFound = null; pos = template.indexOf(tokenDef.close, offset); if (pos >= 0) { end = pos; found = true; } else { throw new Twig2.Error("Unable to find closing bracket '" + tokenDef.close + "' opened near template position " + start); } if (tokenDef.type === Twig2.token.type.comment) { break; } if (tokenDef.type === Twig2.token.type.raw) { break; } l = Twig2.token.strings.length; for (i = 0; i < l; i += 1) { thisStrPos = template.indexOf(Twig2.token.strings[i], offset); if (thisStrPos > 0 && thisStrPos < pos && (strPos === null || thisStrPos < strPos)) { strPos = thisStrPos; strFound = Twig2.token.strings[i]; } } if (strPos !== null) { endOffset = strPos + 1; end = null; found = false; for (; ; ) { endStrPos = template.indexOf(strFound, endOffset); if (endStrPos < 0) { throw Twig2.Error("Unclosed string in template"); } if (template.slice(endStrPos - 1, endStrPos) === "\\") { endOffset = endStrPos + 1; } else { offset = endStrPos + 1; break; } } } } return end; }; Twig2.tokenize = function(template) { const tokens = []; let currentPosition = 0; let foundToken = null; let end = null; while (template.length > 0) { foundToken = Twig2.token.findStart(template); Twig2.log.trace("Twig.tokenize: ", "Found token: ", foundToken); if (foundToken.position === null) { tokens.push({ type: Twig2.token.type.raw, value: template, position: { start: currentPosition, end: currentPosition + foundToken.position } }); template = ""; } else { if (foundToken.position > 0) { tokens.push({ type: Twig2.token.type.raw, value: template.slice(0, Math.max(0, foundToken.position)), position: { start: currentPosition, end: currentPosition + Math.max(0, foundToken.position) } }); } template = template.slice(foundToken.position + foundToken.def.open.length); currentPosition += foundToken.position + foundToken.def.open.length; end = Twig2.token.findEnd(template, foundToken.def, currentPosition); Twig2.log.trace("Twig.tokenize: ", "Token ends at ", end); tokens.push({ type: foundToken.def.type, value: template.slice(0, Math.max(0, end)).trim(), position: { start: currentPosition - foundToken.def.open.length, end: currentPosition + end + foundToken.def.close.length } }); if (template.slice(end + foundToken.def.close.length, end + foundToken.def.close.length + 1) === "\n") { switch (foundToken.def.type) { case "logic_whitespace_pre": case "logic_whitespace_post": case "logic_whitespace_both": case "logic": end += 1; break; default: break; } } template = template.slice(end + foundToken.def.close.length); currentPosition += end + foundToken.def.close.length; } } return tokens; }; Twig2.compile = function(tokens) { const self2 = this; try { const output = []; const stack = []; let intermediateOutput = []; let token = null; let logicToken = null; let unclosedToken = null; let prevToken = null; let prevOutput = null; let prevIntermediateOutput = null; let prevTemplate = null; let nextToken = null; let tokOutput = null; let type = null; let open = null; let next = null; const compileOutput = function(token2) { Twig2.expression.compile.call(self2, token2); if (stack.length > 0) { intermediateOutput.push(token2); } else { output.push(token2); } }; const compileLogic = function(token2) { logicToken = Twig2.logic.compile.call(self2, token2); logicToken.position = token2.position; type = logicToken.type; open = Twig2.logic.handler[type].open; next = Twig2.logic.handler[type].next; Twig2.log.trace( "Twig.compile: ", "Compiled logic token to ", logicToken, " next is: ", next, " open is : ", open ); if (open !== void 0 && !open) { prevToken = stack.pop(); prevTemplate = Twig2.logic.handler[prevToken.type]; if (!prevTemplate.next.includes(type)) { throw new Error(type + " not expected after a " + prevToken.type); } prevToken.output = prevToken.output || []; prevToken.output = prevToken.output.concat(intermediateOutput); intermediateOutput = []; tokOutput = { type: Twig2.token.type.logic, token: prevToken, position: { open: prevToken.position, close: token2.position } }; if (stack.length > 0) { intermediateOutput.push(tokOutput); } else { output.push(tokOutput); } } if (next !== void 0 && next.length > 0) { Twig2.log.trace("Twig.compile: ", "Pushing ", logicToken, " to logic stack."); if (stack.length > 0) { prevToken = stack.pop(); prevToken.output = prevToken.output || []; prevToken.output = prevToken.output.concat(intermediateOutput); stack.push(prevToken); intermediateOutput = []; } stack.push(logicToken); } else if (open !== void 0 && open) { tokOutput = { type: Twig2.token.type.logic, token: logicToken, position: logicToken.position }; if (stack.length > 0) { intermediateOutput.push(tokOutput); } else { output.push(tokOutput); } } }; while (tokens.length > 0) { token = tokens.shift(); prevOutput = output[output.length - 1]; prevIntermediateOutput = intermediateOutput[intermediateOutput.length - 1]; nextToken = tokens[0]; Twig2.log.trace("Compiling token ", token); switch (token.type) { case Twig2.token.type.raw: if (stack.length > 0) { intermediateOutput.push(token); } else { output.push(token); } break; case Twig2.token.type.logic: compileLogic.call(self2, token); break; // Do nothing, comments should be ignored case Twig2.token.type.comment: break; case Twig2.token.type.output: compileOutput.call(self2, token); break; // Kill whitespace ahead and behind this token case Twig2.token.type.logicWhitespacePre: case Twig2.token.type.logicWhitespacePost: case Twig2.token.type.logicWhitespaceBoth: case Twig2.token.type.outputWhitespacePre: case Twig2.token.type.outputWhitespacePost: case Twig2.token.type.outputWhitespaceBoth: if (token.type !== Twig2.token.type.outputWhitespacePost && token.type !== Twig2.token.type.logicWhitespacePost) { if (prevOutput) { if (prevOutput.type === Twig2.token.type.raw) { output.pop(); prevOutput.value = prevOutput.value.trimEnd(); output.push(prevOutput); } } if (prevIntermediateOutput) { if (prevIntermediateOutput.type === Twig2.token.type.raw) { intermediateOutput.pop(); prevIntermediateOutput.value = prevIntermediateOutput.value.trimEnd(); intermediateOutput.push(prevIntermediateOutput); } } } switch (token.type) { case Twig2.token.type.outputWhitespacePre: case Twig2.token.type.outputWhitespacePost: case Twig2.token.type.outputWhitespaceBoth: compileOutput.call(self2, token); break; case Twig2.token.type.logicWhitespacePre: case Twig2.token.type.logicWhitespacePost: case Twig2.token.type.logicWhitespaceBoth: compileLogic.call(self2, token); break; default: break; } if (token.type !== Twig2.token.type.outputWhitespacePre && token.type !== Twig2.token.type.logicWhitespacePre) { if (nextToken) { if (nextToken.type === Twig2.token.type.raw) { tokens.shift(); nextToken.value = nextToken.value.trimStart(); tokens.unshift(nextToken); } } } break; default: break; } Twig2.log.trace( "Twig.compile: ", " Output: ", output, " Logic Stack: ", stack, " Pending Output: ", intermediateOutput ); } if (stack.length > 0) { unclosedToken = stack.pop(); throw new Error("Unable to find an end tag for " + unclosedToken.type + ", expecting one of " + unclosedToken.next); } return output; } catch (error) { if (self2.options.rethrow) { if (error.type === "TwigException" && !error.file) { error.file = self2.id; } throw error; } else { Twig2.log.error("Error compiling twig template " + self2.id + ": "); if (error.stack) { Twig2.log.error(error.stack); } else { Twig2.log.error(error.toString()); } } } }; function handleException(state3, ex) { if (state3.template.options.rethrow) { if (typeof ex === "string") { ex = new Twig2.Error(ex); } if (ex.type === "TwigException" && !ex.file) { ex.file = state3.template.id; } throw ex; } else { Twig2.log.error("Error parsing twig template " + state3.template.id + ": "); if (ex.stack) { Twig2.log.error(ex.stack); } else { Twig2.log.error(ex.toString()); } if (Twig2.debug) { return ex.toString(); } } } Twig2.prepare = function(data) { Twig2.log.debug("Twig.prepare: ", "Tokenizing ", data); const rawTokens = Twig2.tokenize.call(this, data); Twig2.log.debug("Twig.prepare: ", "Compiling ", rawTokens); const tokens = Twig2.compile.call(this, rawTokens); Twig2.log.debug("Twig.prepare: ", "Compiled ", tokens); return tokens; }; Twig2.output = function(output) { const { autoescape } = this.options; if (!autoescape) { return output.join(""); } const strategy = typeof autoescape === "string" ? autoescape : "html"; const escapedOutput = output.map((str) => { if (str && (str.twigMarkup !== true && str.twigMarkup !== strategy) && !(strategy === "html" && str.twigMarkup === "html_attr")) { str = Twig2.filters.escape(str, [strategy]); } return str; }); if (escapedOutput.length === 0) { return ""; } const joinedOutput = escapedOutput.join(""); if (joinedOutput.length === 0) { return ""; } return new Twig2.Markup(joinedOutput, true); }; Twig2.Templates = { /** * Registered template loaders - use Twig.Templates.reg