sv
Version:
A CLI for creating and updating SvelteKit projects
1,300 lines (1,292 loc) • 229 kB
JavaScript
import { Element, T, Tag, __commonJS, __export, __toESM as __toESM$1, __toESM$1 as __toESM, be, detect, esm_exports, getUserAgent, parseCss$1, parseHtml, parseHtml$1, parseJson$1, parseScript, parseScript$1, parseSvelte, require_picocolors as require_picocolors$1, require_picocolors$1 as require_picocolors, resolveCommand, serializeScript, stripAst, up, walk, walk_exports } from "./package-manager-DO5R9a6p.js";
import fs, { existsSync, lstatSync, readdirSync } from "node:fs";
import path, { dirname, join } from "node:path";
import process$1, { stdin, stdout } from "node:process";
import * as _ from "node:readline";
import Eu from "node:readline";
import { ReadStream, WriteStream } from "node:tty";
import { stripVTControlCharacters } from "node:util";
//#region packages/cli/utils/env.ts
const TESTING = process$1.env.NODE_ENV?.toLowerCase() === "test";
//#endregion
//#region packages/core/dist/dedent-DwrHTfuc.js
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(Object(source), !0).forEach(function(key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
else obj[key] = value;
return obj;
}
function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");
return typeof key === "symbol" ? key : String(key);
}
function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];
if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return (hint === "string" ? String : Number)(input);
}
const dedent = createDedent({});
var dedent_default = dedent;
function createDedent(options$6) {
dedent$1.withOptions = (newOptions) => createDedent(_objectSpread(_objectSpread({}, options$6), newOptions));
return dedent$1;
function dedent$1(strings, ...values) {
const raw = typeof strings === "string" ? [strings] : strings.raw;
const { escapeSpecialCharacters = Array.isArray(strings), trimWhitespace = true } = options$6;
let result = "";
for (let i = 0; i < raw.length; i++) {
let next = raw[i];
if (escapeSpecialCharacters) next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{");
result += next;
if (i < values.length) result += values[i];
}
const lines = result.split("\n");
let mindent = null;
for (const l of lines) {
const m$1 = l.match(/^(\s+)\S+/);
if (m$1) {
const indent = m$1[1].length;
if (!mindent) mindent = indent;
else mindent = Math.min(mindent, indent);
}
}
if (mindent !== null) {
const m$1 = mindent;
result = lines.map((l) => l[0] === " " || l[0] === " " ? l.slice(m$1) : l).join("\n");
}
if (trimWhitespace) result = result.trim();
if (escapeSpecialCharacters) result = result.replace(/\\n/g, "\n");
return result;
}
}
//#endregion
//#region packages/core/dist/common-D3LG2iy6.js
function decircular(object) {
const seenObjects = new WeakMap();
function internalDecircular(value, path$1 = []) {
if (!(value !== null && typeof value === "object")) return value;
const existingPath = seenObjects.get(value);
if (existingPath) return `[Circular *${existingPath.join(".")}]`;
seenObjects.set(value, path$1);
const newValue = Array.isArray(value) ? [] : {};
for (const [key2, value2] of Object.entries(value)) newValue[key2] = internalDecircular(value2, [...path$1, key2]);
seenObjects.delete(value);
return newValue;
}
return internalDecircular(object);
}
var common_exports = {};
__export(common_exports, {
addJsDocComment: () => addJsDocComment,
addJsDocTypeComment: () => addJsDocTypeComment,
appendFromString: () => appendFromString,
appendStatement: () => appendStatement,
areNodesEqual: () => areNodesEqual,
contains: () => contains,
createBlockStatement: () => createBlockStatement,
createExpressionStatement: () => createExpressionStatement,
createLiteral: () => createLiteral,
createSatisfies: () => createSatisfies,
createSpread: () => createSpread,
hasTypeProperty: () => hasTypeProperty,
parseExpression: () => parseExpression,
parseFromString: () => parseFromString,
parseStatement: () => parseStatement,
typeAnnotate: () => typeAnnotate
});
function addJsDocTypeComment(node, options$6) {
const comment = {
type: "Block",
value: `* @type {${options$6.type}} `
};
addComment(node, comment);
}
function addJsDocComment(node, options$6) {
const commentLines = [];
for (const [key, value] of Object.entries(options$6.params)) commentLines.push(`@param {${key}} ${value}`);
const comment = {
type: "Block",
value: `*\n * ${commentLines.join("\n * ")}\n `
};
addComment(node, comment);
}
function addComment(node, comment) {
node.leadingComments ??= [];
const found = node.leadingComments.find((item) => item.type === "Block" && item.value === comment.value);
if (!found) node.leadingComments.push(comment);
}
function typeAnnotate(node, options$6) {
const expression = {
type: "TSAsExpression",
expression: node,
typeAnnotation: {
type: "TSTypeReference",
typeName: {
type: "Identifier",
name: options$6.type
}
}
};
return expression;
}
function createSatisfies(node, options$6) {
const expression = {
type: "TSSatisfiesExpression",
expression: node,
typeAnnotation: {
type: "TSTypeReference",
typeName: {
type: "Identifier",
name: options$6.type
}
}
};
return expression;
}
function createSpread(argument) {
return {
type: "SpreadElement",
argument
};
}
function createLiteral(value) {
const literal = {
type: "Literal",
value: value ?? null
};
return literal;
}
function areNodesEqual(node, otherNode) {
const nodeClone = stripAst(decircular(node), ["loc", "raw"]);
const otherNodeClone = stripAst(decircular(otherNode), ["loc", "raw"]);
return serializeScript(nodeClone) === serializeScript(otherNodeClone);
}
function createBlockStatement() {
const statement = {
type: "BlockStatement",
body: []
};
return statement;
}
function createExpressionStatement(options$6) {
const statement = {
type: "ExpressionStatement",
expression: options$6.expression
};
return statement;
}
function appendFromString(node, options$6) {
const program = parseScript(dedent_default(options$6.code));
for (const childNode of program.body) node.body.push(childNode);
}
function parseExpression(code) {
const program = parseScript(dedent_default(code));
stripAst(program, ["raw"]);
const statement = program.body[0];
if (statement.type !== "ExpressionStatement") throw new Error("Code provided was not an expression");
return statement.expression;
}
function parseStatement(code) {
return parseFromString(code);
}
function parseFromString(code) {
const program = parseScript(dedent_default(code));
const statement = program.body[0];
return statement;
}
function appendStatement(node, options$6) {
if (!contains(node, options$6.statement)) node.body.push(options$6.statement);
}
function contains(node, targetNode) {
let found = false;
walk(node, null, { _(currentNode, { next, stop }) {
if (currentNode.type === targetNode.type) {
found = areNodesEqual(currentNode, targetNode);
if (found) stop();
}
next();
} });
return found;
}
function hasTypeProperty(node, options$6) {
return node.type === "TSPropertySignature" && node.key.type === "Identifier" && node.key.name === options$6.name;
}
//#endregion
//#region packages/core/dist/js.js
var array_exports = {};
__export(array_exports, {
append: () => append,
create: () => create$1,
prepend: () => prepend
});
function create$1() {
const arrayExpression = {
type: "ArrayExpression",
elements: []
};
return arrayExpression;
}
function append(node, element) {
insertElement(node, element, { insertEnd: true });
}
function prepend(node, element) {
insertElement(node, element, { insertEnd: false });
}
function insertElement(node, element, options$6) {
if (typeof element === "string") {
const existingLiterals = node.elements.filter((item) => item !== null && item.type === "Literal");
let literal = existingLiterals.find((item) => item.value === element);
if (!literal) {
literal = {
type: "Literal",
value: element
};
if (options$6.insertEnd) node.elements.push(literal);
else node.elements.unshift(literal);
}
} else {
const elements = node.elements;
const anyNodeEquals = elements.some((item) => item && areNodesEqual(element, item));
if (!anyNodeEquals) if (options$6.insertEnd) node.elements.push(element);
else node.elements.unshift(element);
}
}
var object_exports = {};
__export(object_exports, {
addProperties: () => addProperties,
create: () => create,
overrideProperties: () => overrideProperties,
overrideProperty: () => overrideProperty,
property: () => property,
removeProperty: () => removeProperty
});
function property(node, options$6) {
const properties = node.properties.filter((x$2) => x$2.type === "Property");
let prop = properties.find((x$2) => x$2.key.name === options$6.name);
let propertyValue;
if (prop) propertyValue = prop.value;
else {
let isShorthand = false;
if (options$6.fallback.type === "Identifier") {
const identifier = options$6.fallback;
isShorthand = identifier.name === options$6.name;
}
propertyValue = options$6.fallback;
prop = {
type: "Property",
shorthand: isShorthand,
key: {
type: "Identifier",
name: options$6.name
},
value: propertyValue,
kind: "init",
computed: false,
method: false
};
node.properties.push(prop);
}
return propertyValue;
}
function overrideProperty(node, options$6) {
const properties = node.properties.filter((x$2) => x$2.type === "Property");
const prop = properties.find((x$2) => x$2.key.name === options$6.name);
if (!prop) return property(node, {
name: options$6.name,
fallback: options$6.value
});
prop.value = options$6.value;
return options$6.value;
}
function overrideProperties(node, options$6) {
for (const [prop, value] of Object.entries(options$6.properties)) {
if (value === undefined) continue;
overrideProperty(node, {
name: prop,
value
});
}
}
function addProperties(node, options$6) {
for (const [prop, value] of Object.entries(options$6.properties)) {
if (value === undefined) continue;
property(node, {
name: prop,
fallback: value
});
}
}
function removeProperty(node, options$6) {
const properties = node.properties.filter((x$2) => x$2.type === "Property");
const propIdx = properties.findIndex((x$2) => x$2.key.name === options$6.name);
if (propIdx !== -1) node.properties.splice(propIdx, 1);
}
function create(properties) {
const objExpression = {
type: "ObjectExpression",
properties: []
};
const getExpression = (value) => {
let expression;
if (Array.isArray(value)) {
expression = create$1();
for (const v$2 of value) append(expression, getExpression(v$2));
} else if (typeof value === "object" && value !== null) expression = value.type !== undefined ? value : create(value);
else expression = createLiteral(value);
return expression;
};
for (const [prop, value] of Object.entries(properties)) {
if (value === undefined) continue;
property(objExpression, {
name: prop,
fallback: getExpression(value)
});
}
return objExpression;
}
var function_exports = {};
__export(function_exports, {
createArrow: () => createArrow,
createCall: () => createCall,
getArgument: () => getArgument
});
function createCall(options$6) {
const callExpression = {
type: "CallExpression",
callee: {
type: "Identifier",
name: options$6.name
},
arguments: [],
optional: false
};
for (const arg of options$6.args) {
let argNode;
if (options$6.useIdentifiers) argNode = {
type: "Identifier",
name: arg
};
else argNode = {
type: "Literal",
value: arg
};
callExpression.arguments.push(argNode);
}
return callExpression;
}
function createArrow(options$6) {
const arrowFunction = {
type: "ArrowFunctionExpression",
async: options$6.async,
body: options$6.body,
params: [],
expression: options$6.body.type !== "BlockStatement"
};
return arrowFunction;
}
function getArgument(node, options$6) {
if (options$6.index < node.arguments.length) return node.arguments[options$6.index];
node.arguments.push(options$6.fallback);
return options$6.fallback;
}
var imports_exports = {};
__export(imports_exports, {
addDefault: () => addDefault,
addEmpty: () => addEmpty,
addNamed: () => addNamed,
addNamespace: () => addNamespace
});
function addEmpty(node, options$6) {
const expectedImportDeclaration = {
type: "ImportDeclaration",
source: {
type: "Literal",
value: options$6.from
},
specifiers: [],
attributes: [],
importKind: "value"
};
addImportIfNecessary(node, expectedImportDeclaration);
}
function addNamespace(node, options$6) {
const expectedImportDeclaration = {
type: "ImportDeclaration",
importKind: "value",
source: {
type: "Literal",
value: options$6.from
},
specifiers: [{
type: "ImportNamespaceSpecifier",
local: {
type: "Identifier",
name: options$6.as
}
}],
attributes: []
};
addImportIfNecessary(node, expectedImportDeclaration);
}
function addDefault(node, options$6) {
const expectedImportDeclaration = {
type: "ImportDeclaration",
source: {
type: "Literal",
value: options$6.from
},
specifiers: [{
type: "ImportDefaultSpecifier",
local: {
type: "Identifier",
name: options$6.as
}
}],
attributes: [],
importKind: "value"
};
addImportIfNecessary(node, expectedImportDeclaration);
}
function addNamed(node, options$6) {
const o_imports = Array.isArray(options$6.imports) ? Object.fromEntries(options$6.imports.map((n$1) => [n$1, n$1])) : options$6.imports;
const specifiers = Object.entries(o_imports).map(([key, value]) => {
const specifier = {
type: "ImportSpecifier",
imported: {
type: "Identifier",
name: key
},
local: {
type: "Identifier",
name: value
}
};
return specifier;
});
let importDecl;
walk(node, null, { ImportDeclaration(declaration$1) {
if (declaration$1.source.value === options$6.from && declaration$1.specifiers) importDecl = declaration$1;
} });
if (importDecl) {
specifiers.forEach((specifierToAdd) => {
const sourceExists = importDecl?.specifiers?.every((existingSpecifier) => existingSpecifier.type === "ImportSpecifier" && existingSpecifier.local?.name !== specifierToAdd.local?.name && existingSpecifier.imported.type === "Identifier" && specifierToAdd.imported.type === "Identifier" && existingSpecifier.imported.name !== specifierToAdd.imported.name);
if (sourceExists) importDecl?.specifiers?.push(specifierToAdd);
});
return;
}
const expectedImportDeclaration = {
type: "ImportDeclaration",
source: {
type: "Literal",
value: options$6.from
},
specifiers,
attributes: [],
importKind: options$6.isType ? "type" : "value"
};
node.body.unshift(expectedImportDeclaration);
}
function addImportIfNecessary(node, expectedImportDeclaration) {
const importDeclarations = node.body.filter((item) => item.type === "ImportDeclaration");
const importDeclaration = importDeclarations.find((item) => areNodesEqual(item, expectedImportDeclaration));
if (!importDeclaration) node.body.unshift(expectedImportDeclaration);
}
var variables_exports = {};
__export(variables_exports, {
createIdentifier: () => createIdentifier,
declaration: () => declaration,
typeAnnotateDeclarator: () => typeAnnotateDeclarator
});
function declaration(node, options$6) {
const declarations = node.type === "Program" ? node.body.filter((x$2) => x$2.type === "VariableDeclaration") : [node];
let declaration$1 = declarations.find((x$2) => {
const declarator = x$2.declarations[0];
const identifier = declarator.id;
return identifier.name === options$6.name;
});
if (declaration$1) return declaration$1;
declaration$1 = {
type: "VariableDeclaration",
kind: options$6.kind,
declarations: [{
type: "VariableDeclarator",
id: {
type: "Identifier",
name: options$6.name
},
init: options$6.value
}]
};
return declaration$1;
}
function createIdentifier(name) {
const identifier = {
type: "Identifier",
name
};
return identifier;
}
function typeAnnotateDeclarator(node, options$6) {
if (node.id.type === "Identifier") node.id.typeAnnotation = {
type: "TSTypeAnnotation",
typeAnnotation: {
type: "TSTypeReference",
typeName: {
type: "Identifier",
name: options$6.typeName
}
}
};
return node;
}
var exports_exports = {};
__export(exports_exports, {
createDefault: () => createDefault,
createNamed: () => createNamed
});
function createDefault(node, options$6) {
const existingNode = node.body.find((item) => item.type === "ExportDefaultDeclaration");
if (!existingNode) {
const exportNode = {
type: "ExportDefaultDeclaration",
declaration: options$6.fallback
};
node.body.push(exportNode);
return {
astNode: exportNode,
value: options$6.fallback
};
}
const exportDefaultDeclaration = existingNode;
if (exportDefaultDeclaration.declaration.type === "Identifier") {
const identifier = exportDefaultDeclaration.declaration;
let variableDeclaration;
let variableDeclarator;
for (const declaration$2 of node.body) {
if (declaration$2.type !== "VariableDeclaration") continue;
const declarator = declaration$2.declarations.find((declarator$1) => declarator$1.type === "VariableDeclarator" && declarator$1.id.type === "Identifier" && declarator$1.id.name === identifier.name);
variableDeclarator = declarator;
variableDeclaration = declaration$2;
}
if (!variableDeclaration || !variableDeclarator) throw new Error(`Unable to find exported variable '${identifier.name}'`);
const value = variableDeclarator.init;
return {
astNode: exportDefaultDeclaration,
value
};
}
const declaration$1 = exportDefaultDeclaration.declaration;
return {
astNode: exportDefaultDeclaration,
value: declaration$1
};
}
function createNamed(node, options$6) {
const namedExports = node.body.filter((item) => item.type === "ExportNamedDeclaration");
let namedExport = namedExports.find((exportNode) => {
const variableDeclaration = exportNode.declaration;
const variableDeclarator = variableDeclaration.declarations[0];
const identifier = variableDeclarator.id;
return identifier.name === options$6.name;
});
if (namedExport) return namedExport;
namedExport = {
type: "ExportNamedDeclaration",
declaration: options$6.fallback,
specifiers: [],
attributes: []
};
node.body.push(namedExport);
return namedExport;
}
var kit_exports = {};
__export(kit_exports, {
addGlobalAppInterface: () => addGlobalAppInterface,
addHooksHandle: () => addHooksHandle
});
function addGlobalAppInterface(node, options$6) {
let globalDecl = node.body.filter((n$1) => n$1.type === "TSModuleDeclaration").find((m$1) => m$1.global && m$1.declare);
if (!globalDecl) {
globalDecl = parseFromString("declare global {}");
node.body.push(globalDecl);
}
if (globalDecl.body?.type !== "TSModuleBlock") throw new Error("Unexpected body type of `declare global` in `src/app.d.ts`");
let app;
let interfaceNode;
walk(globalDecl, null, {
TSModuleDeclaration(node$1, { next }) {
if (node$1.id.type === "Identifier" && node$1.id.name === "App") app = node$1;
next();
},
TSInterfaceDeclaration(node$1) {
if (node$1.id.type === "Identifier" && node$1.id.name === options$6.name) interfaceNode = node$1;
}
});
if (!app) {
app = parseFromString("namespace App {}");
globalDecl.body.body.push(app);
}
if (app.body?.type !== "TSModuleBlock") throw new Error("Unexpected body type of `namespace App` in `src/app.d.ts`");
if (!interfaceNode) {
interfaceNode = parseFromString(`interface ${options$6.name} {}`);
app.body.body.push(interfaceNode);
}
return interfaceNode;
}
function addHooksHandle(node, options$6) {
if (options$6.typescript) addNamed(node, {
from: "@sveltejs/kit",
imports: { Handle: "Handle" },
isType: true
});
let isSpecifier = false;
let handleName = "handle";
let exportDecl;
let originalHandleDecl;
walk(node, null, { ExportNamedDeclaration(declaration$1) {
let maybeHandleDecl;
const handleSpecifier = declaration$1.specifiers?.find((specifier) => specifier.exported.type === "Identifier" && specifier.exported.name === "handle");
if (handleSpecifier && handleSpecifier.local.type === "Identifier" && handleSpecifier.exported.type === "Identifier") {
isSpecifier = true;
handleName = handleSpecifier.local?.name ?? handleSpecifier.exported.name;
const handleFunc = node.body.find((item) => isFunctionDeclaration(item, handleName));
const handleVar = node.body.find((item) => isVariableDeclaration(item, handleName));
maybeHandleDecl = handleFunc ?? handleVar;
}
maybeHandleDecl ??= declaration$1.declaration ?? undefined;
if (maybeHandleDecl && isVariableDeclaration(maybeHandleDecl, handleName)) {
exportDecl = declaration$1;
originalHandleDecl = maybeHandleDecl;
}
if (maybeHandleDecl && isFunctionDeclaration(maybeHandleDecl, handleName)) {
exportDecl = declaration$1;
originalHandleDecl = maybeHandleDecl;
}
} });
const newHandle = parseExpression(options$6.handleContent);
if (contains(node, newHandle)) return;
if (!originalHandleDecl || !exportDecl) {
const newHandleDecl$1 = declaration(node, {
kind: "const",
name: options$6.newHandleName,
value: newHandle
});
if (options$6.typescript) {
const declarator = newHandleDecl$1.declarations[0];
typeAnnotateDeclarator(declarator, { typeName: "Handle" });
}
node.body.push(newHandleDecl$1);
const handleDecl = declaration(node, {
kind: "const",
name: handleName,
value: createIdentifier(options$6.newHandleName)
});
if (options$6.typescript) {
const declarator = handleDecl.declarations[0];
typeAnnotateDeclarator(declarator, { typeName: "Handle" });
}
createNamed(node, {
name: handleName,
fallback: handleDecl
});
return;
}
const newHandleDecl = declaration(node, {
kind: "const",
name: options$6.newHandleName,
value: newHandle
});
if (options$6.typescript) {
const declarator = newHandleDecl.declarations[0];
typeAnnotateDeclarator(declarator, { typeName: "Handle" });
}
let sequence;
if (originalHandleDecl.type === "VariableDeclaration") {
const handle = originalHandleDecl.declarations.find((declarator) => declarator.type === "VariableDeclarator" && usingSequence(declarator, handleName));
sequence = handle?.init;
}
if (sequence) {
const hasNewArg = sequence.arguments.some((arg) => arg.type === "Identifier" && arg.name === options$6.newHandleName);
if (!hasNewArg) sequence.arguments.push(createIdentifier(options$6.newHandleName));
node.body = node.body.filter((item) => item !== originalHandleDecl && item !== exportDecl && item !== newHandleDecl);
if (isSpecifier) node.body.push(newHandleDecl, originalHandleDecl, exportDecl);
else node.body.push(newHandleDecl, exportDecl);
}
const NEW_HANDLE_NAME = "originalHandle";
const sequenceCall = createCall({
name: "sequence",
args: [NEW_HANDLE_NAME, options$6.newHandleName],
useIdentifiers: true
});
const finalHandleDecl = declaration(node, {
kind: "const",
name: handleName,
value: sequenceCall
});
addNamed(node, {
from: "@sveltejs/kit/hooks",
imports: { sequence: "sequence" }
});
let renameRequired = false;
if (originalHandleDecl && isVariableDeclaration(originalHandleDecl, handleName)) {
const handle = getVariableDeclarator(originalHandleDecl, handleName);
if (handle && handle.id.type === "Identifier" && handle.init?.type !== "Identifier") {
renameRequired = true;
handle.id.name = NEW_HANDLE_NAME;
}
}
if (originalHandleDecl && isFunctionDeclaration(originalHandleDecl, handleName)) {
renameRequired = true;
originalHandleDecl.id.name = NEW_HANDLE_NAME;
}
node.body = node.body.filter((item) => item !== originalHandleDecl && item !== exportDecl && item !== newHandleDecl);
if (isSpecifier) node.body.push(originalHandleDecl, newHandleDecl, finalHandleDecl, exportDecl);
if (exportDecl.declaration && renameRequired) {
node.body.push(exportDecl.declaration, newHandleDecl);
createNamed(node, {
name: handleName,
fallback: finalHandleDecl
});
} else if (exportDecl.declaration && isVariableDeclaration(originalHandleDecl, handleName)) {
const variableDeclarator = getVariableDeclarator(originalHandleDecl, handleName);
const sequenceCall$1 = createCall({
name: "sequence",
args: [(variableDeclarator?.init).name, options$6.newHandleName],
useIdentifiers: true
});
const finalHandleDecl$1 = declaration(node, {
kind: "const",
name: handleName,
value: sequenceCall$1
});
if (options$6.typescript) {
const declarator = finalHandleDecl$1.declarations[0];
typeAnnotateDeclarator(declarator, { typeName: "Handle" });
}
node.body.push(newHandleDecl);
createNamed(node, {
name: handleName,
fallback: finalHandleDecl$1
});
}
}
function usingSequence(node, handleName) {
return node.id.type === "Identifier" && node.id.name === handleName && node.init?.type === "CallExpression" && node.init.callee.type === "Identifier" && node.init.callee.name === "sequence";
}
function isVariableDeclaration(node, variableName) {
return node.type === "VariableDeclaration" && getVariableDeclarator(node, variableName) !== undefined;
}
function getVariableDeclarator(node, variableName) {
return node.declarations.find((d$1) => d$1.type === "VariableDeclarator" && d$1.id.type === "Identifier" && d$1.id.name === variableName);
}
function isFunctionDeclaration(node, funcName) {
return node.type === "FunctionDeclaration" && node.id?.name === funcName;
}
var vite_exports = {};
__export(vite_exports, { addPlugin: () => addPlugin });
function exportDefaultConfig(ast, options$6 = {}) {
const { fallback, ignoreWrapper } = options$6;
let fallbackExpression;
if (fallback) fallbackExpression = typeof fallback === "string" ? parseExpression(fallback) : fallback;
else fallbackExpression = create({});
const { value } = createDefault(ast, { fallback: fallbackExpression });
const rootObject = value.type === "TSSatisfiesExpression" ? value.expression : value;
let configObject;
if (!ignoreWrapper || !("arguments" in rootObject) || !Array.isArray(rootObject.arguments)) {
configObject = rootObject;
return configObject;
}
if (rootObject.type !== "CallExpression" || rootObject.callee.type !== "Identifier" || rootObject.callee.name !== ignoreWrapper) {
configObject = rootObject;
return configObject;
}
const firstArg = getArgument(rootObject, {
index: 0,
fallback: create({})
});
if (firstArg.type === "ArrowFunctionExpression") {
const arrowFunction = firstArg;
if (arrowFunction.body.type === "BlockStatement") {
const returnStatement = arrowFunction.body.body.find((stmt) => stmt.type === "ReturnStatement");
if (returnStatement && returnStatement.argument?.type === "ObjectExpression") configObject = returnStatement.argument;
else {
configObject = create({});
const newReturnStatement = {
type: "ReturnStatement",
argument: configObject
};
arrowFunction.body.body.push(newReturnStatement);
}
} else if (arrowFunction.body.type === "ObjectExpression") configObject = arrowFunction.body;
else {
configObject = create({});
arrowFunction.body = configObject;
arrowFunction.expression = true;
}
} else if (firstArg.type === "ObjectExpression") configObject = firstArg;
else configObject = create({});
return configObject;
}
function addInArrayOfObject(ast, options$6) {
const { code, arrayProperty, mode = "append" } = options$6;
const targetArray = property(ast, {
name: arrayProperty,
fallback: create$1()
});
const expression = parseExpression(code);
if (mode === "prepend") prepend(targetArray, expression);
else append(targetArray, expression);
}
const addPlugin = (ast, options$6) => {
addNamed(ast, {
from: "vite",
imports: { defineConfig: "defineConfig" }
});
const configObject = exportDefaultConfig(ast, {
fallback: "defineConfig()",
ignoreWrapper: "defineConfig"
});
addInArrayOfObject(configObject, {
arrayProperty: "plugins",
...options$6
});
};
//#endregion
//#region packages/cli/commands/add/utils.ts
var import_picocolors$5 = __toESM(require_picocolors(), 1);
function getPackageJson(cwd) {
const packageText = readFile(cwd, commonFilePaths.packageJson);
if (!packageText) {
const pkgPath = path.join(cwd, commonFilePaths.packageJson);
throw new Error(`Invalid workspace: missing '${pkgPath}'`);
}
const { data, generateCode } = parseJson$1(packageText);
return {
source: packageText,
data,
generateCode
};
}
async function formatFiles(options$6) {
const args = [
"prettier",
"--write",
"--ignore-unknown",
...options$6.paths
];
const cmd = resolveCommand(options$6.packageManager, "execute-local", args);
await be(cmd.command, cmd.args, {
nodeOptions: {
cwd: options$6.cwd,
stdio: "pipe"
},
throwOnError: true
});
}
function readFile(cwd, filePath) {
const fullFilePath = path.resolve(cwd, filePath);
if (!fileExists(cwd, filePath)) return "";
const text = fs.readFileSync(fullFilePath, "utf8");
return text;
}
function installPackages(dependencies, workspace) {
const { data, generateCode } = getPackageJson(workspace.cwd);
for (const dependency of dependencies) if (dependency.dev) {
data.devDependencies ??= {};
data.devDependencies[dependency.pkg] = dependency.version;
} else {
data.dependencies ??= {};
data.dependencies[dependency.pkg] = dependency.version;
}
if (data.dependencies) data.dependencies = alphabetizeProperties(data.dependencies);
if (data.devDependencies) data.devDependencies = alphabetizeProperties(data.devDependencies);
writeFile(workspace, commonFilePaths.packageJson, generateCode());
return commonFilePaths.packageJson;
}
function alphabetizeProperties(obj) {
const orderedObj = {};
const sortedEntries = Object.entries(obj).sort(([a], [b$1]) => a.localeCompare(b$1));
for (const [key, value] of sortedEntries) orderedObj[key] = value;
return orderedObj;
}
function writeFile(workspace, filePath, content) {
const fullFilePath = path.resolve(workspace.cwd, filePath);
const fullDirectoryPath = path.dirname(fullFilePath);
if (content && !content.endsWith("\n")) content += "\n";
if (!fs.existsSync(fullDirectoryPath)) fs.mkdirSync(fullDirectoryPath, { recursive: true });
fs.writeFileSync(fullFilePath, content, "utf8");
}
function fileExists(cwd, filePath) {
const fullFilePath = path.resolve(cwd, filePath);
return fs.existsSync(fullFilePath);
}
const commonFilePaths = {
packageJson: "package.json",
svelteConfig: "svelte.config.js",
tsconfig: "tsconfig.json",
viteConfigTS: "vite.config.ts"
};
function getHighlighter() {
return {
command: (str) => import_picocolors$5.default.bold(import_picocolors$5.default.cyanBright(str)),
env: (str) => import_picocolors$5.default.yellow(str),
path: (str) => import_picocolors$5.default.green(str),
route: (str) => import_picocolors$5.default.bold(str),
website: (str) => import_picocolors$5.default.whiteBright(str)
};
}
//#endregion
//#region packages/cli/commands/add/workspace.ts
async function createWorkspace({ cwd, options: options$6 = {}, packageManager }) {
const resolvedCwd = path.resolve(cwd);
const viteConfigPath = path.join(resolvedCwd, commonFilePaths.viteConfigTS);
let usesTypescript = fs.existsSync(viteConfigPath);
if (TESTING) usesTypescript ||= fs.existsSync(path.join(resolvedCwd, commonFilePaths.tsconfig));
else usesTypescript ||= up(commonFilePaths.tsconfig, { cwd }) !== undefined;
let dependencies = {};
let directory = resolvedCwd;
const root = findRoot(resolvedCwd);
while (directory && directory !== root) {
if (fs.existsSync(path.join(directory, commonFilePaths.packageJson))) {
const { data: packageJson } = getPackageJson(directory);
dependencies = {
...packageJson.devDependencies,
...packageJson.dependencies,
...dependencies
};
}
directory = path.dirname(directory);
}
for (const [key, value] of Object.entries(dependencies)) dependencies[key] = value.replaceAll(/[^\d|.]/g, "");
return {
cwd: resolvedCwd,
options: options$6,
packageManager: packageManager ?? (await detect({ cwd }))?.name ?? getUserAgent() ?? "npm",
typescript: usesTypescript,
kit: dependencies["@sveltejs/kit"] ? parseKitOptions(resolvedCwd) : undefined,
dependencyVersion: (pkg) => dependencies[pkg]
};
}
function findRoot(cwd) {
const { root } = path.parse(cwd);
let directory = cwd;
while (directory && directory !== root) {
if (fs.existsSync(path.join(directory, commonFilePaths.packageJson))) {
if (fs.existsSync(path.join(directory, "pnpm-workspace.yaml"))) return directory;
const { data } = getPackageJson(directory);
if (data.workspaces) return directory;
}
directory = path.dirname(directory);
}
return root;
}
function parseKitOptions(cwd) {
const configSource = readFile(cwd, commonFilePaths.svelteConfig);
const { ast } = parseScript$1(configSource);
const defaultExport = ast.body.find((s) => s.type === "ExportDefaultDeclaration");
if (!defaultExport) throw Error("Missing default export in `svelte.config.js`");
let objectExpression;
if (defaultExport.declaration.type === "Identifier") {
const identifier = defaultExport.declaration;
for (const declaration$1 of ast.body) {
if (declaration$1.type !== "VariableDeclaration") continue;
const declarator = declaration$1.declarations.find((d$1) => d$1.type === "VariableDeclarator" && d$1.id.type === "Identifier" && d$1.id.name === identifier.name);
if (declarator?.init?.type !== "ObjectExpression") continue;
objectExpression = declarator.init;
}
if (!objectExpression) throw Error("Unable to find svelte config object expression from `svelte.config.js`");
} else if (defaultExport.declaration.type === "ObjectExpression") objectExpression = defaultExport.declaration;
if (!objectExpression) throw new Error("Unexpected svelte config shape from `svelte.config.js`");
const kit = object_exports.property(objectExpression, {
name: "kit",
fallback: object_exports.create({})
});
const files = object_exports.property(kit, {
name: "files",
fallback: object_exports.create({})
});
const routes = object_exports.property(files, {
name: "routes",
fallback: common_exports.createLiteral("")
});
const lib = object_exports.property(files, {
name: "lib",
fallback: common_exports.createLiteral("")
});
const routesDirectory = routes.value || "src/routes";
const libDirectory = lib.value || "src/lib";
return {
routesDirectory,
libDirectory
};
}
//#endregion
//#region packages/cli/lib/install.ts
var import_picocolors$4 = __toESM(require_picocolors(), 1);
async function installAddon({ addons, cwd, options: options$6, packageManager = "npm" }) {
const workspace = await createWorkspace({
cwd,
packageManager
});
const addonSetupResults = setupAddons(Object.values(addons), workspace);
return await applyAddons({
addons,
workspace,
options: options$6,
addonSetupResults
});
}
async function applyAddons({ addons, workspace, addonSetupResults, options: options$6 }) {
const filesToFormat = new Set();
const allPnpmBuildDependencies = [];
const mapped = Object.entries(addons).map(([, addon]) => addon);
const ordered = orderAddons(mapped, addonSetupResults);
for (const addon of ordered) {
workspace = await createWorkspace({
...workspace,
options: options$6[addon.id]
});
const { files, pnpmBuildDependencies } = await runAddon({
workspace,
addon,
multiple: ordered.length > 1
});
files.forEach((f$1) => filesToFormat.add(f$1));
pnpmBuildDependencies.forEach((s) => allPnpmBuildDependencies.push(s));
}
return {
filesToFormat: Array.from(filesToFormat),
pnpmBuildDependencies: allPnpmBuildDependencies
};
}
function setupAddons(addons, workspace) {
const addonSetupResults = {};
for (const addon of addons) {
const setupResult = {
unsupported: [],
dependsOn: [],
runsAfter: []
};
addon.setup?.({
...workspace,
dependsOn: (name) => {
setupResult.dependsOn.push(name);
setupResult.runsAfter.push(name);
},
unsupported: (reason) => setupResult.unsupported.push(reason),
runsAfter: (name) => setupResult.runsAfter.push(name)
});
addonSetupResults[addon.id] = setupResult;
}
return addonSetupResults;
}
async function runAddon({ addon, multiple, workspace }) {
const files = new Set();
for (const [id, question] of Object.entries(addon.options)) if (question.condition?.(workspace.options) !== false) workspace.options[id] ??= question.default;
const dependencies = [];
const pnpmBuildDependencies = [];
const sv = {
file: (path$1, content) => {
try {
const exists = fileExists(workspace.cwd, path$1);
let fileContent = exists ? readFile(workspace.cwd, path$1) : "";
fileContent = content(fileContent);
if (!fileContent) return fileContent;
writeFile(workspace, path$1, fileContent);
files.add(path$1);
} catch (e) {
if (e instanceof Error) throw new Error(`Unable to process '${path$1}'. Reason: ${e.message}`);
throw e;
}
},
execute: async (commandArgs, stdio) => {
const { command, args } = resolveCommand(workspace.packageManager, "execute", commandArgs);
const addonPrefix = multiple ? `${addon.id}: ` : "";
const executedCommand = `${command} ${args.join(" ")}`;
if (!TESTING) T.step(`${addonPrefix}Running external command ${import_picocolors$4.default.gray(`(${executedCommand})`)}`);
if (workspace.packageManager === "npm") args.unshift("--yes");
try {
await be(command, args, {
nodeOptions: {
cwd: workspace.cwd,
stdio: TESTING ? "pipe" : stdio
},
throwOnError: true
});
} catch (error) {
const typedError = error;
throw new Error(`Failed to execute scripts '${executedCommand}': ${typedError.message}`, { cause: typedError.output });
}
},
dependency: (pkg, version) => {
dependencies.push({
pkg,
version,
dev: false
});
},
devDependency: (pkg, version) => {
dependencies.push({
pkg,
version,
dev: true
});
},
pnpmBuildDependendency: (pkg) => {
pnpmBuildDependencies.push(pkg);
}
};
await addon.run({
...workspace,
sv
});
const pkgPath = installPackages(dependencies, workspace);
files.add(pkgPath);
return {
files: Array.from(files),
pnpmBuildDependencies
};
}
function orderAddons(addons, setupResults) {
return addons.sort((a, b$1) => {
return setupResults[a.id]?.runsAfter?.length - setupResults[b$1.id]?.runsAfter?.length;
});
}
//#endregion
//#region packages/core/dist/index.js
function defineAddon(config) {
return config;
}
function defineAddonOptions(options$6) {
return options$6;
}
var require_src = __commonJS({ "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module) {
const ESC = "\x1B";
const CSI = `${ESC}[`;
const beep = "\x07";
const cursor = {
to(x$2, y) {
if (!y) return `${CSI}${x$2 + 1}G`;
return `${CSI}${y + 1};${x$2 + 1}H`;
},
move(x$2, y) {
let ret = "";
if (x$2 < 0) ret += `${CSI}${-x$2}D`;
else if (x$2 > 0) ret += `${CSI}${x$2}C`;
if (y < 0) ret += `${CSI}${-y}A`;
else if (y > 0) ret += `${CSI}${y}B`;
return ret;
},
up: (count = 1) => `${CSI}${count}A`,
down: (count = 1) => `${CSI}${count}B`,
forward: (count = 1) => `${CSI}${count}C`,
backward: (count = 1) => `${CSI}${count}D`,
nextLine: (count = 1) => `${CSI}E`.repeat(count),
prevLine: (count = 1) => `${CSI}F`.repeat(count),
left: `${CSI}G`,
hide: `${CSI}?25l`,
show: `${CSI}?25h`,
save: `${ESC}7`,
restore: `${ESC}8`
};
const scroll = {
up: (count = 1) => `${CSI}S`.repeat(count),
down: (count = 1) => `${CSI}T`.repeat(count)
};
const erase = {
screen: `${CSI}2J`,
up: (count = 1) => `${CSI}1J`.repeat(count),
down: (count = 1) => `${CSI}J`.repeat(count),
line: `${CSI}2K`,
lineEnd: `${CSI}K`,
lineStart: `${CSI}1K`,
lines(count) {
let clear = "";
for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
if (count) clear += cursor.left;
return clear;
}
};
module.exports = {
cursor,
scroll,
erase,
beep
};
} });
var import_src$1 = __toESM$1(require_src(), 1);
var import_picocolors$3 = __toESM$1(require_picocolors$1(), 1);
function hu({ onlyFirst: e$1 = !1 } = {}) {
const t = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
return new RegExp(t, e$1 ? void 0 : "g");
}
const cu = hu();
function Y(e$1) {
if (typeof e$1 != "string") throw new TypeError(`Expected a \`string\`, got \`${typeof e$1}\``);
return e$1.replace(cu, "");
}
function Z(e$1) {
return e$1 && e$1.__esModule && Object.prototype.hasOwnProperty.call(e$1, "default") ? e$1.default : e$1;
}
var q$1 = { exports: {} };
(function(e$1) {
var D$1 = {};
e$1.exports = D$1, D$1.eastAsianWidth = function(s) {
var i = s.charCodeAt(0), F$1 = s.length == 2 ? s.charCodeAt(1) : 0, u = i;
return 55296 <= i && i <= 56319 && 56320 <= F$1 && F$1 <= 57343 && (i &= 1023, F$1 &= 1023, u = i << 10 | F$1, u += 65536), u == 12288 || 65281 <= u && u <= 65376 || 65504 <= u && u <= 65510 ? "F" : u == 8361 || 65377 <= u && u <= 65470 || 65474 <= u && u <= 65479 || 65482 <= u && u <= 65487 || 65490 <= u && u <= 65495 || 65498 <= u && u <= 65500 || 65512 <= u && u <= 65518 ? "H" : 4352 <= u && u <= 4447 || 4515 <= u && u <= 4519 || 4602 <= u && u <= 4607 || 9001 <= u && u <= 9002 || 11904 <= u && u <= 11929 || 11931 <= u && u <= 12019 || 12032 <= u && u <= 12245 || 12272 <= u && u <= 12283 || 12289 <= u && u <= 12350 || 12353 <= u && u <= 12438 || 12441 <= u && u <= 12543 || 12549 <= u && u <= 12589 || 12593 <= u && u <= 12686 || 12688 <= u && u <= 12730 || 12736 <= u && u <= 12771 || 12784 <= u && u <= 12830 || 12832 <= u && u <= 12871 || 12880 <= u && u <= 13054 || 13056 <= u && u <= 19903 || 19968 <= u && u <= 42124 || 42128 <= u && u <= 42182 || 43360 <= u && u <= 43388 || 44032 <= u && u <= 55203 || 55216 <= u && u <= 55238 || 55243 <= u && u <= 55291 || 63744 <= u && u <= 64255 || 65040 <= u && u <= 65049 || 65072 <= u && u <= 65106 || 65108 <= u && u <= 65126 || 65128 <= u && u <= 65131 || 110592 <= u && u <= 110593 || 127488 <= u && u <= 127490 || 127504 <= u && u <= 127546 || 127552 <= u && u <= 127560 || 127568 <= u && u <= 127569 || 131072 <= u && u <= 194367 || 177984 <= u && u <= 196605 || 196608 <= u && u <= 262141 ? "W" : 32 <= u && u <= 126 || 162 <= u && u <= 163 || 165 <= u && u <= 166 || u == 172 || u == 175 || 10214 <= u && u <= 10221 || 10629 <= u && u <= 10630 ? "Na" : u == 161 || u == 164 || 167 <= u && u <= 168 || u == 170 || 173 <= u && u <= 174 || 176 <= u && u <= 180 || 182 <= u && u <= 186 || 188 <= u && u <= 191 || u == 198 || u == 208 || 215 <= u && u <= 216 || 222 <= u && u <= 225 || u == 230 || 232 <= u && u <= 234 || 236 <= u && u <= 237 || u == 240 || 242 <= u && u <= 243 || 247 <= u && u <= 250 || u == 252 || u == 254 || u == 257 || u == 273 || u == 275 || u == 283 || 294 <= u && u <= 295 || u == 299 || 305 <= u && u <= 307 || u == 312 || 319 <= u && u <= 322 || u == 324 || 328 <= u && u <= 331 || u == 333 || 338 <= u && u <= 339 || 358 <= u && u <= 359 || u == 363 || u == 462 || u == 464 || u == 466 || u == 468 || u == 470 || u == 472 || u == 474 || u == 476 || u == 593 || u == 609 || u == 708 || u == 711 || 713 <= u && u <= 715 || u == 717 || u == 720 || 728 <= u && u <= 731 || u == 733 || u == 735 || 768 <= u && u <= 879 || 913 <= u && u <= 929 || 931 <= u && u <= 937 || 945 <= u && u <= 961 || 963 <= u && u <= 969 || u == 1025 || 1040 <= u && u <= 1103 || u == 1105 || u == 8208 || 8211 <= u && u <= 8214 || 8216 <= u && u <= 8217 || 8220 <= u && u <= 8221 || 8224 <= u && u <= 8226 || 8228 <= u && u <= 8231 || u == 8240 || 8242 <= u && u <= 8243 || u == 8245 || u == 8251 || u == 8254 || u == 8308 || u == 8319 || 8321 <= u && u <= 8324 || u == 8364 || u == 8451 || u == 8453 || u == 8457 || u == 8467 || u == 8470 || 8481 <= u && u <= 8482 || u == 8486 || u == 8491 || 8531 <= u && u <= 8532 || 8539 <= u && u <= 8542 || 8544 <= u && u <= 8555 || 8560 <= u && u <= 8569 || u == 8585 || 8592 <= u && u <= 8601 || 8632 <= u && u <= 8633 || u == 8658 || u == 8660 || u == 8679 || u == 8704 || 8706 <= u && u <= 8707 || 8711 <= u && u <= 8712 || u == 8715 || u == 8719 || u == 8721 || u == 8725 || u == 8730 || 8733 <= u && u <= 8736 || u == 8739 || u == 8741 || 8743 <= u && u <= 8748 || u == 8750 || 8756 <= u && u <= 8759 || 8764 <= u && u <= 8765 || u == 8776 || u == 8780 || u == 8786 || 8800 <= u && u <= 8801 || 8804 <= u && u <= 8807 || 8810 <= u && u <= 8811 || 8814 <= u && u <= 8815 || 8834 <= u && u <= 8835 || 8838 <= u && u <= 8839 || u == 8853 || u == 8857 || u == 8869 || u == 8895 || u == 8978 || 9312 <= u && u <= 9449 || 9451 <= u && u <= 9547 || 9552 <= u && u <= 9587 || 9600 <= u && u <= 9615 || 9618 <= u && u <= 9621 || 9632 <= u && u <= 9633 || 9635 <= u && u <= 9641 || 9650 <= u && u <= 9651 || 9654 <= u && u <= 9655 || 9660 <= u && u <= 9661 || 9664 <= u && u <= 9665 || 9670 <= u && u <= 9672 || u == 9675 || 9678 <= u && u <= 9681 || 9698 <= u && u <= 9701 || u == 9711 || 9733 <= u && u <= 9734 || u == 9737 || 9742 <= u && u <= 9743 || 9748 <= u && u <= 9749 || u == 9756 || u == 9758 || u == 9792 || u == 9794 || 9824 <= u && u <= 9825 || 9827 <= u && u <= 9829 || 9831 <= u && u <= 9834 || 9836 <= u && u <= 9837 || u == 9839 || 9886 <= u && u <= 9887 || 9918 <= u && u <= 9919 || 9924 <= u && u <= 9933 || 9935 <= u && u <= 9953 || u == 9955 || 9960 <= u && u <= 9983 || u == 10045 || u == 10071 || 10102 <= u && u <= 10111 || 11093 <= u && u <= 11097 || 12872 <= u && u <= 12879 || 57344 <= u && u <= 63743 || 65024 <= u && u <= 65039 || u == 65533 || 127232 <= u && u <= 127242 || 127248 <= u && u <= 127277 || 127280 <= u && u <= 127337 || 127344 <= u && u <= 127386 || 917760 <= u && u <= 917999 || 983040 <= u && u <= 1048573 || 1048576 <= u && u <= 1114109 ? "A" : "N";
}, D$1.characterLength = function(s) {
var i = this.eastAsianWidth(s);
return i == "F" || i == "W" || i == "A" ? 2 : 1;
};
function t(s) {
return s.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g) || [];
}
D$1.length = function(s) {
for (var i = t(s), F$1 = 0, u = 0; u < i.length; u++) F$1 = F$1 + this.characterLength(i[u]);
return F$1;
}, D$1.slice = function(s, i, F$1) {
textLen = D$1.length(s), i = i || 0, F$1 = F$1 || 1, i < 0 && (i = textLen + i), F$1 < 0 && (F$1 = textLen + F$1);
for (var u = "", r = 0, a = t(s), n$1 = 0; n$1 < a.length; n$1++) {
var l = a[n$1], o$1 = D$1.length(l);
if (r >= i - (o$1 == 2 ? 1 : 0)) if (r + o$1 <= F$1) u += l;
else break;
r += o$1;
}
return u;
};
})(q$1);
var xu = q$1.exports;
const Bu = Z(xu);
var pu = function() {
return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\