UNPKG

sd-wildcards-utils

Version:

Parse Stable Diffusion wildcards source to a YAML object.

533 lines (532 loc) 24 kB
!function(e, t) { "object" == typeof exports && "undefined" != typeof module ? t(exports, require("yaml"), require("array-hyper-unique"), require("@bluelovers/extract-brackets"), require("lazy-aggregate-error"), require("picomatch")) : "function" == typeof define && define.amd ? define([ "exports", "yaml", "array-hyper-unique", "@bluelovers/extract-brackets", "lazy-aggregate-error", "picomatch" ], t) : t((e = "undefined" != typeof globalThis ? globalThis : e || self).SdWildcardsUtils = {}, e.yaml, e.arrayHyperUnique, e.extractBrackets, e.lazyAggregateError, e.picomatch); }(this, (function(e, t, r, n, i, a) { "use strict"; function getOptionsShared(e) { var t; return null !== (t = e) && void 0 !== t || (e = {}), { allowMultiRoot: e.allowMultiRoot, disableUniqueItemValues: e.disableUniqueItemValues, minifyPrompts: e.minifyPrompts, disableUnsafeQuote: e.disableUnsafeQuote }; } function defaultOptionsStringify(e) { return { blockQuote: !0, defaultKeyType: "PLAIN", defaultStringType: "PLAIN", collectionStyle: "block", uniqueKeys: !0, ...e }; } function defaultOptionsParseDocument(e) { var t; return null !== (t = e) && void 0 !== t || (e = {}), { prettyErrors: !0, ...e, toStringDefaults: defaultOptionsStringify({ ...getOptionsShared(e), ...e.toStringDefaults }) }; } function getOptionsFromDocument(e, t) { return { ...e.options, ...t }; } let o; function stripZeroStr(e) { return e.replace(/[\x00\u200b]+/g, ""); } function trimPrompts(e) { return e.replace(/\xa0/g, " ").replace(/^\s+|\s+$/g, "").replace(/^\s+|\s+$/gm, "").replace(/\n\s*\n/g, "\n").replace(/\s{2,}/gm, " ").replace(/,\s{2,}/gm, ", ").replace(/\s+,/gm, ",").replace(/,+\s*$/g, ""); } function normalizeWildcardsYamlString(e) { return stripZeroStr(e).replace(/\xa0/g, " ").replace(/[,.]+(?=,)/gm, "").replace(/[ .]+$/gm, "").replace(/(\w) +(?=,)/gm, "$1").replace(/(,) {2,}(?=\S)/gm, "$1 ").replace(/\{\s+(\d+(?:\.\d+)?(?:-(?:\d+(?:\.\d+)?)?\$\$|::))/gm, "{$1").replace(/\|\s(\d+(?:\.\d+)?::)/gm, "|$1").replace(/^[ \t]+-[ \t]*$/gm, "").replace(/^([ \t]+-)[ \t]{1,}(?:[ ,.]+|(?=[^ \t]))/gm, "$1 "); } function trimPromptsDynamic(e) { if (e.includes("=")) { var t; null !== (t = o) && void 0 !== t || (o = new n.Extractor("{", "}")); const r = o.extract(e); let i, a = 0, s = r.reduce(((t, r) => { let n = "string" == typeof r.nest[0] && r.nest[0], o = r.str, s = e.slice(a, r.index[0]); return i && (s = s.replace(/^[\s\r\n]+/g, "")), i = null == n ? void 0 : n.includes("="), i && (o = o.replace(/^\s*([\w_]+)\s*=\s*/, "$1=")), t.push(s), t.push("{" + o.trim() + "}"), a = r.index[0] + r.str.length + 2, t; }), []), l = e.slice(a); i && (l = l.replace(/[\s\r\n]+$|^[\s\r\n]+/g, "")), s.push(l), e = s.join(""); } return e; } function formatPrompts(e, t) { var r; return null !== (r = t) && void 0 !== r || (t = {}), e = normalizeWildcardsYamlString(e = trimPrompts(e = stripZeroStr(e))), t.minifyPrompts && (e = trimPromptsDynamic(e = e.replace(/(,)\s+/gm, "$1").replace(/\s+(,)/gm, "$1").replace(/(?<=,\|})\s+/gm, "").replace(/\s+(?=\{(?:\s*\d+(?:\.\d+)?::)?,)/gm, ""))), e; } function isWildcardsYAMLDocument(e) { return t.isDocument(e); } function isWildcardsYAMLMap(e) { return t.isMap(e); } const s = /*#__PURE__*/ Symbol.for("yaml.alias"), l = /*#__PURE__*/ Symbol.for("yaml.document"), c = /*#__PURE__*/ Symbol.for("yaml.map"), d = /*#__PURE__*/ Symbol.for("yaml.pair"), u = /*#__PURE__*/ Symbol.for("yaml.scalar"), m = /*#__PURE__*/ Symbol.for("yaml.seq"), p = /*#__PURE__*/ Symbol.for("yaml.node.type"), f = /(?<!#[^\n]*)__([&~!@])?([\w*](?:[*\w\/_\-]+?))(\([^\n#]+\))?__/, h = /(?<!#[^\n]*)__([&~!@])?([\w*](?:[*\w\/_\-\s]+?))(\([^\n#]+\))?__/, y = /*#__PURE__*/ new RegExp(f, f.flags + "g"), g = /*#__PURE__*/ new RegExp(h, h.flags + "g"), S = /^[\w\-_\/]+$/, _ = /^[\w\-_\/*]+$/; function matchDynamicPromptsWildcards(e, t) { return _matchDynamicPromptsWildcardsCore(e.match(null != t && t.unsafe ? h : f), e); } function _matchDynamicPromptsWildcardsCore(e, t) { if (!e) return null; let [r, n, i, a] = e; return { name: i, variables: a, keyword: n, source: r, isFullMatch: r === (null != t ? t : e.input), isStarWildcards: i.includes("*") }; } function* matchDynamicPromptsWildcardsAllGenerator(e, t) { const r = e.matchAll(null != t && t.unsafe ? g : y); for (let t of r) yield _matchDynamicPromptsWildcardsCore(t, e); } function matchDynamicPromptsWildcardsAll(e, t) { const n = [ ...matchDynamicPromptsWildcardsAllGenerator(e, t) ]; return null != t && t.unique ? r.array_unique_overwrite(n) : n; } function isBadWildcardsName(e) { return !S.test(e) || _isBadWildcardsNameCore(e); } function isBadWildcardsPath(e) { return !_.test(e) || _isBadWildcardsNameCore(e); } function _isBadWildcardsNameCore(e) { return /^[\s_\/\\-]|[\s_\/\\-]$|[\s_\/\\-]\/|\/[\s_\/\\-]|\/\/|[\s_\/\\-]{2,}/.test(e); } function assertWildcardsPath(e) { if (isBadWildcardsPath(e)) throw new SyntaxError(`Invalid Paths Syntax [UNSAFE_SYNTAX] "${e}"`); } function convertWildcardsNameToPaths(e) { return e.split("/"); } function isWildcardsPathSyntx(e) { return f.test(e); } function getNodeTypeSymbol(e) { return null == e ? void 0 : e[p]; } function _getNodeTypeCore(e) { try { return Symbol.keyFor(e); } catch (e) {} } function getNodeType(e) { return _getNodeTypeCore(getNodeTypeSymbol(e)); } function isSameNodeType(e, t) { const r = getNodeTypeSymbol(e); return r && getNodeTypeSymbol(t) === r; } let P; function _checkBrackets(e) { var t; return null !== (t = P) && void 0 !== t || (P = new n.Extractor("{", "}")), P.extractSync(e, (t => { if (t) { var r, i; let a = null === (r = t.self) || void 0 === r ? void 0 : r.result; if (!a) return { value: e, error: `Invalid Error [UNKNOWN]: ${t}` }; let o = n.infoNearExtractionError(e, t.self); return { value: e, index: null === (i = a.index) || void 0 === i ? void 0 : i[0], near: o, error: `Invalid Syntax [BRACKET] ${t.message} near "${o}"` }; } })); } function _validMap(e, r, ...n) { const i = r.items.findIndex((e => !t.isPair(e) || null == (null == e ? void 0 : e.value))); if (-1 !== i) { const t = handleVisitPathsFull(e, r, ...n); throw new SyntaxError(`Invalid SYNTAX. paths: [${t}], key: ${e}, node: ${r}, elem: ${r.items[i]}`); } } function _validSeq(e, r, ...n) { for (const i in r.items) { const a = r.items[i]; if (!t.isScalar(a)) { const t = handleVisitPathsFull(e, r, ...n); throw new SyntaxError(`Invalid SYNTAX. entry type should be 'Scalar', but got '${getNodeType(a)}'. paths: [${t}], entryIndex: ${i}, entry: ${a}, nodeKey: ${e}, node: ${r}`); } } } function _validPair(e, t, ...r) { const n = t.key; if (!isSafeKey("string" == typeof n ? n : n.value)) { const i = handleVisitPathsFull(e, t, ...r); throw new SyntaxError(`Invalid Key. paths: [${i}], key: ${e}, keyNodeValue: "${null == n ? void 0 : n.value}", keyNode: ${n}`); } } function createDefaultVisitWildcardsYAMLOptions(e) { var t; let r = { Map: _validMap, Seq: _validSeq }; if (null !== (t = e) && void 0 !== t || (e = {}), e.allowUnsafeKey || (r.Pair = _validPair), !e.disableUniqueItemValues) { const e = r.Seq; r.Seq = (t, r, ...n) => { e(t, r, ...n), uniqueSeqItems(r.items); }; } return r; } function validWildcardsYamlData(e, r) { var n; if (null !== (n = r) && void 0 !== n || (r = {}), t.isDocument(e)) { if (t.isNode(e.contents) && !t.isMap(e.contents)) throw TypeError(`The 'contents' property of the provided YAML document must be a YAMLMap. Received: ${e.contents}`); visitWildcardsYAML(e, createDefaultVisitWildcardsYAMLOptions(r)), e = e.toJSON(); } if (null == e) { if (r.allowEmptyDocument) return; throw new TypeError(`The provided JSON contents should not be empty. ${e}`); } let i = Object.keys(e); if (!i.length) throw TypeError("The provided JSON contents must contain at least one key."); if (1 !== i.length && !r.allowMultiRoot) throw TypeError("The provided JSON object cannot have more than one root key. Only one root key is allowed unless explicitly allowed by the 'allowMultiRoot' option."); } function isSafeKey(e) { return "string" == typeof e && /^[._\w-]+$/.test(e) && !/^[\._-]|[\._-]$/.test(e); } function _checkValue(e) { let t = /(?:^|[\s{},])_(?=[^_]|$)|(?<!_)_(?:[\s{},]|$)|\/_+|_+\/(?!\()|\([\w_]+\s*=(?:!|\s*[{}$])/.exec(e); if (t) { let r = _nearString(e, t.index, t[0]), n = t[0]; return { value: e, match: n, index: t.index, near: r, error: `Invalid Syntax [UNSAFE_SYNTAX] "${n}" in value near "${r}"` }; } if (/[{}]/.test(e)) return _checkBrackets(e); } function _nearString(e, t, r, n = 15) { let i = Math.max(0, t - n); return e.slice(i, t + ((null == r ? void 0 : r.length) || 0) + n); } function visitWildcardsYAML(e, r) { return t.visit(e, r); } function defaultCheckerIgnoreCase(e, t) { return "string" == typeof e && "string" == typeof t && (e = e.toLowerCase(), t = t.toLowerCase()), r.defaultChecker(e, t); } function uniqueSeqItemsChecker(e, r) { return t.isScalar(e) && t.isScalar(r) ? defaultCheckerIgnoreCase(e.value, r.value) : defaultCheckerIgnoreCase(e, r); } function uniqueSeqItems(e) { return r.array_unique_overwrite(e, { checker: uniqueSeqItemsChecker }); } function deepFindSingleRootAt(e, r) { if (t.isMap(e) && 1 === e.items.length) { var n, i; let a = e.items[0], o = a.key.value, s = null !== (n = null == r || null === (i = r.paths) || void 0 === i ? void 0 : i.slice()) && void 0 !== n ? n : []; s.push(o); let l = a.value; return t.isSeq(l) ? r : deepFindSingleRootAt(l, { paths: s, key: o, value: l, parent: e }); } if (t.isDocument(e)) { if (r) throw new TypeError("The Document Node should not as Child Node"); let t = e.contents; return deepFindSingleRootAt(t, { paths: [], key: void 0, value: t, parent: e }); } return r; } function _handleVisitPathsCore(e) { return e.filter((e => t.isPair(e))); } function convertPairsToPathsList(e) { return e.map((e => e.key.value)); } function handleVisitPaths(e) { return convertPairsToPathsList(_handleVisitPathsCore(e)); } function handleVisitPathsFull(e, t, r) { const n = handleVisitPaths(r); return "number" == typeof e && n.push(e), n; } const v = /['"]/, W = /^\s*-|[{$~!@}\n|:?#'"%]/, A = /-/; function _visitNormalizeScalar(e, t, r) { let n = t.value; if ("string" == typeof n) { if (r.checkUnsafeQuote && v.test(n)) throw new SyntaxError(`Invalid SYNTAX [UNSAFE_QUOTE]. key: ${e}, node: ${t}`); if (("QUOTE_DOUBLE" === t.type || "QUOTE_SINGLE" === t.type && !n.includes("\\")) && (t.type = "PLAIN"), n = formatPrompts(n, r.options), !n.length) throw new SyntaxError(`Invalid SYNTAX [EMPTY_VALUE]. key: ${e}, node: ${t}`); W.test(n) ? ("PLAIN" === t.type || "BLOCK_FOLDED" === t.type && /#/.test(n)) && (t.type = "BLOCK_LITERAL") : "PLAIN" === t.type && A.test(n) && (t.type = "QUOTE_DOUBLE"); let i = _checkValue(n); if (null != i && i.error) throw new SyntaxError(`${i.error}. key: ${e}, node: ${t}`); t.value = n; } } function getTopRootContents(e) { if (isWildcardsYAMLDocument(e) && (e = e.contents), isWildcardsYAMLMap(e)) return e; throw new TypeError("Input document is not a YAML Document or a YAML Map. Please provide a valid YAML structure."); } function _mergeWildcardsYAMLDocumentRootsCore(e, t) { return e.contents.items.push(...t.contents.items), e; } function _toJSON(e) { return t.isDocument(e) ? e.toJSON() : e; } function _mergeSeqCore(e, t) { return e.items.push(...t.items), e; } function pathsToWildcardsPath(e, t) { let r = e.join("/"); return t && (r = `__${r}__`), r; } function findPath(e, r, n, i = [], a = []) { var o, s, l; null !== (o = n) && void 0 !== o || (n = {}), null !== (s = i) && void 0 !== s || (i = []), null !== (l = a) && void 0 !== l || (a = []); let c = { paths: r.slice(), findOpts: n, prefix: i, globOpts: findPathOptionsToGlobOptions(n) }; return t.isDocument(e) && (c.data = e, e = e.toJSON()), _findPathCore(e, r.slice(), n, i, a, c); } function findPathOptionsToGlobOptions(e) { return { ...null == e ? void 0 : e.globOpts, ignore: null == e ? void 0 : e.ignore }; } function _findPathCore(e, t, r, n, i, o) { const s = (t = t.slice()).shift(), l = t.length > 0; for (const c in e) { if (r.onlyFirstMatchAll && i.length) break; const d = n.slice().concat(c), u = n.slice().concat(s), m = a.isMatch(pathsToWildcardsPath(d), pathsToWildcardsPath(u), o.globOpts); if (m) { const n = e[c], a = !Array.isArray(n); if (l) { if (a && "string" != typeof n) { _findPathCore(n, t, r, d, i, o); continue; } } else { if (!a) { i.push({ key: d, value: n }); continue; } if (!l && o.findOpts.allowWildcardsAtEndMatchRecord && s.includes("*") && "object" == typeof n && n) { i.push({ key: d, value: n }); continue; } } if (!s.includes("*") || a && !l) throw new TypeError(`Invalid Type. paths: [${d}], isMatch: ${m}, deep: ${l}, deep paths: [${t}], notArray: ${a}, match: [${u}], value: ${n}, _cache : ${JSON.stringify(o)}`); } } if (0 === n.length && r.throwWhenNotFound && !i.length) throw new RangeError(`Invalid Paths. paths: [${[ s, ...t ]}], _cache : ${JSON.stringify(o)}`); return i; } function normalizeDocument(e, t) { let r = getOptionsFromDocument(e, t); const n = createDefaultVisitWildcardsYAMLOptions(r); let i = !r.disableUnsafeQuote; visitWildcardsYAML(e, { ...n, Scalar: (e, t) => _visitNormalizeScalar(e, t, { checkUnsafeQuote: i, options: r }) }); } function parseWildcardsYaml(e, r) { var n; (r = defaultOptionsParseDocument(r)).allowEmptyDocument && (null !== (n = e) && void 0 !== n || (e = "")); let i = t.parseDocument(e.toString(), r); return validWildcardsYamlData(i, r), i; } e.RE_DYNAMIC_PROMPTS_WILDCARDS = f, e.RE_DYNAMIC_PROMPTS_WILDCARDS_GLOBAL = y, e.RE_DYNAMIC_PROMPTS_WILDCARDS_UNSAFE = h, e.RE_DYNAMIC_PROMPTS_WILDCARDS_UNSAFE_GLOBAL = g, e.RE_WILDCARDS_NAME = S, e.RE_WILDCARDS_NAME_STAR = _, e.SYMBOL_YAML_NODE_TYPE = p, e.SYMBOL_YAML_NODE_TYPE_ALIAS = s, e.SYMBOL_YAML_NODE_TYPE_DOC = l, e.SYMBOL_YAML_NODE_TYPE_MAP = c, e.SYMBOL_YAML_NODE_TYPE_PAIR = d, e.SYMBOL_YAML_NODE_TYPE_SCALAR = u, e.SYMBOL_YAML_NODE_TYPE_SEQ = m, e._checkBrackets = _checkBrackets, e._checkValue = _checkValue, e._findPathCore = _findPathCore, e._getNodeTypeCore = _getNodeTypeCore, e._handleVisitPathsCore = _handleVisitPathsCore, e._isBadWildcardsNameCore = _isBadWildcardsNameCore, e._matchDynamicPromptsWildcardsCore = _matchDynamicPromptsWildcardsCore, e._mergeSeqCore = _mergeSeqCore, e._mergeWildcardsYAMLDocumentRootsCore = _mergeWildcardsYAMLDocumentRootsCore, e._nearString = _nearString, e._toJSON = _toJSON, e._validKey = function _validKey(e) { if (!isSafeKey(e)) throw new SyntaxError(`Invalid Key. key: ${e}`); }, e._validMap = _validMap, e._validPair = _validPair, e._validSeq = _validSeq, e._visitNormalizeScalar = _visitNormalizeScalar, e.assertWildcardsName = function assertWildcardsName(e) { if (isBadWildcardsName(e)) throw new SyntaxError(`Invalid Wildcards Name Syntax: ${e}`); }, e.assertWildcardsPath = assertWildcardsPath, e.checkAllSelfLinkWildcardsExists = function checkAllSelfLinkWildcardsExists(e, r) { var n, i; null !== (n = r) && void 0 !== n || (r = {}); const o = r.maxErrors > 0 ? r.maxErrors : 10; t.isDocument(e) || t.isNode(e) || (e = parseWildcardsYaml(e)); const s = e.toString(), l = e.toJSON(); let c = matchDynamicPromptsWildcardsAll(s, { unsafe: !0, ...r.optsMatch, unique: !0 }), isMatchIgnore = () => !1; null !== (i = r.ignore) && void 0 !== i && i.length && (isMatchIgnore = a(r.ignore)); const d = [], u = [], m = [], p = []; for (const e of c) { if (isMatchIgnore(e.name)) { m.push(e.name); continue; } const t = convertWildcardsNameToPaths(e.name); let n = []; try { assertWildcardsPath(e.name), n = findPath(l, t, { onlyFirstMatchAll: !0, throwWhenNotFound: !0, allowWildcardsAtEndMatchRecord: r.allowWildcardsAtEndMatchRecord }), r.report && (d.push(...n.map((e => e.key.join("/")))), e.name.includes("*") && u.push(e.name)); } catch (e) { if (p.push(e), p.length >= o) { let e = new RangeError(`Max Errors. errors.length ${p.length} >= ${o}`); p.unshift(e); break; } continue; } } return { obj: e, listHasExists: d, listHasExistsWildcards: u, ignoreList: m, errors: p }; }, e.convertPairsToPathsList = convertPairsToPathsList, e.convertWildcardsNameToPaths = convertWildcardsNameToPaths, e.createDefaultVisitWildcardsYAMLOptions = createDefaultVisitWildcardsYAMLOptions, e.deepFindSingleRootAt = deepFindSingleRootAt, e.default = parseWildcardsYaml, e.defaultCheckerIgnoreCase = defaultCheckerIgnoreCase, e.defaultOptionsParseDocument = defaultOptionsParseDocument, e.defaultOptionsStringify = defaultOptionsStringify, e.defaultOptionsStringifyMinify = function defaultOptionsStringifyMinify() { return { lineWidth: 0, minifyPrompts: !0 }; }, e.findPath = findPath, e.findPathOptionsToGlobOptions = findPathOptionsToGlobOptions, e.findWildcardsYAMLPathsAll = function findWildcardsYAMLPathsAll(e) { const t = []; return visitWildcardsYAML(e, { Seq(...e) { const r = handleVisitPathsFull(...e); t.push(r); } }), t; }, e.formatPrompts = formatPrompts, e.getNodeType = getNodeType, e.getNodeTypeSymbol = getNodeTypeSymbol, e.getOptionsFromDocument = getOptionsFromDocument, e.getOptionsShared = getOptionsShared, e.getTopRootContents = getTopRootContents, e.getTopRootNodes = function getTopRootNodes(e) { return getTopRootContents(e).items; }, e.handleVisitPaths = handleVisitPaths, e.handleVisitPathsFull = handleVisitPathsFull, e.isBadWildcardsName = isBadWildcardsName, e.isBadWildcardsPath = isBadWildcardsPath, e.isDynamicPromptsWildcards = function isDynamicPromptsWildcards(e) { return matchDynamicPromptsWildcards(e).isFullMatch; }, e.isSafeKey = isSafeKey, e.isSameNodeType = isSameNodeType, e.isWildcardsName = function isWildcardsName(e) { return S.test(e) && !_isBadWildcardsNameCore(e); }, e.isWildcardsPathSyntx = isWildcardsPathSyntx, e.isWildcardsYAMLDocument = isWildcardsYAMLDocument, e.isWildcardsYAMLDocumentAndContentsIsMap = function isWildcardsYAMLDocumentAndContentsIsMap(e) { return t.isDocument(e) && t.isMap(e.contents); }, e.isWildcardsYAMLMap = isWildcardsYAMLMap, e.matchDynamicPromptsWildcards = matchDynamicPromptsWildcards, e.matchDynamicPromptsWildcardsAll = matchDynamicPromptsWildcardsAll, e.matchDynamicPromptsWildcardsAllGenerator = matchDynamicPromptsWildcardsAllGenerator, e.mergeFindSingleRoots = function mergeFindSingleRoots(e, r) { if (!t.isDocument(e) && !t.isMap(e)) throw TypeError(`The merge target should be a YAMLMap or Document. doc: ${e}`); r = [ r ].flat(); for (let n of r) { let r = deepFindSingleRootAt(n), a = null == r ? void 0 : r.paths; if (!r) throw new TypeError(`Only YAMLMap can be merged [2]. path: ${a}, node: ${n}`); { let n = e.getIn(a); if (n) { if (!t.isMap(n)) throw new TypeError(`Only YAMLMap can be merged [1]. path: ${a}, type: ${getNodeType(n)} node: ${n}`); r.value.items.forEach((e => { const r = e.key.value, o = n.get(r); if (o) if (t.isSeq(o) && t.isSeq(e.value)) _mergeSeqCore(o, e.value); else { if (!t.isMap(o) || !t.isMap(e.value)) throw isSameNodeType(o, e.value) ? new TypeError(`Current does not support deep merge at paths: ${JSON.stringify(a.concat(r))}, a: ${o}, b: ${e.value}`) : new TypeError(`Only allow merge same node type at paths: ${JSON.stringify(a.concat(r))}, a: ${getNodeType(o)}, b: ${getNodeType(e.value)}`); { const n = [], s = []; for (const r of e.value.items) try { if (t.isSeq(r.value)) { let e = o.get(r.key); if (t.isSeq(e)) { _mergeSeqCore(e, r.value); continue; } } o.add(r, !1); } catch (e) { n.push(r.key.value), s.push(e); } if (s.length) throw new i.AggregateErrorExtra(s, `Failure when merging sub YAMLMap. Paths: ${JSON.stringify(a.concat(r))}. Conflicting keys: ${JSON.stringify(n)}`); } } else n.items.push(e); })); } else e.setIn(a, r.value); } } return e; }, e.mergeSeq = function mergeSeq(e, r) { if (t.isSeq(e) && t.isSeq(r)) return _mergeSeqCore(e, r); throw new TypeError("Only allow merge YAMLSeq"); }, e.mergeWildcardsYAMLDocumentJsonBy = function mergeWildcardsYAMLDocumentJsonBy(e, t) { return t.deepmerge(e.map(_toJSON)); }, e.mergeWildcardsYAMLDocumentRoots = function mergeWildcardsYAMLDocumentRoots(e) { return e.reduce(_mergeWildcardsYAMLDocumentRootsCore); }, e.normalizeDocument = normalizeDocument, e.normalizeWildcardsYamlString = normalizeWildcardsYamlString, e.parseWildcardsYaml = parseWildcardsYaml, e.pathsToDotPath = function pathsToDotPath(e) { return e.join("."); }, e.pathsToWildcardsPath = pathsToWildcardsPath, e.stringifyWildcardsYamlData = function stringifyWildcardsYamlData(e, r) { const n = t.isDocument(e); return n && (r = getOptionsFromDocument(e, r)), r = defaultOptionsStringify(r), n ? (normalizeDocument(e, r), e.toString(r)) : t.stringify(e, r); }, e.stripBlankLines = function stripBlankLines(e, t) { return e = e.replace(/(\r?\n)[\s\r\n\t\xa0]+(\r?\n)/g, "$1$2").replace(/(\r?\n)(?:\r?\n)(?=[\s\t\xa0])/g, "$1").replace(/[ \xa0\t]+$/gm, ""), t && (e = e.replace(/\s+$/, ""), e += "\n\n"), e; }, e.stripZeroStr = stripZeroStr, e.trimPrompts = trimPrompts, e.trimPromptsDynamic = trimPromptsDynamic, e.uniqueSeqItems = uniqueSeqItems, e.uniqueSeqItemsChecker = uniqueSeqItemsChecker, e.validWildcardsYamlData = validWildcardsYamlData, e.visitWildcardsYAML = visitWildcardsYAML, e.wildcardsPathToPaths = function wildcardsPathToPaths(e) { return isWildcardsPathSyntx(e) && (e = matchDynamicPromptsWildcards(e).name), convertWildcardsNameToPaths(e); }, Object.defineProperty(e, "__esModule", { value: !0 }); })); //# sourceMappingURL=index.umd.production.min.cjs.map