+ !nameHasComments || n.attributes.length) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
+ // string literal with newlines
+
+ const shouldBreak = n.attributes && n.attributes.some(attr => attr.value && isStringLiteral$1(attr.value) && attr.value.value.includes("\n"));
+ return group$2(concat$6(["<", path.call(print, "name"), path.call(print, "typeParameters"), concat$6([indent$3(concat$6(path.map(attr => concat$6([line$4, print(attr)]), "attributes"))), n.selfClosing ? line$4 : bracketSameLine ? ">" : softline$2]), n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), {
+ shouldBreak
+ });
+ }
+
+ case "JSXClosingElement":
+ return concat$6(["", path.call(print, "name"), ">"]);
+
+ case "JSXOpeningFragment":
+ case "JSXClosingFragment":
+ {
+ const hasComment = n.comments && n.comments.length;
+ const hasOwnLineComment = hasComment && !n.comments.every(comments$1.isBlockComment);
+ const isOpeningFragment = n.type === "JSXOpeningFragment";
+ return concat$6([isOpeningFragment ? "<" : "", indent$3(concat$6([hasOwnLineComment ? hardline$4 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path, options, true)])), hasOwnLineComment ? hardline$4 : "", ">"]);
+ }
+
+ case "JSXText":
+ /* istanbul ignore next */
+ throw new Error("JSXTest should be handled by JSXElement");
+
+ case "JSXEmptyExpression":
+ {
+ const requiresHardline = n.comments && !n.comments.every(comments$1.isBlockComment);
+ return concat$6([comments.printDanglingComments(path, options,
+ /* sameIndent */
+ !requiresHardline), requiresHardline ? hardline$4 : ""]);
+ }
+
+ case "ClassBody":
+ if (!n.comments && n.body.length === 0) {
+ return "{}";
+ }
+
+ return concat$6(["{", n.body.length > 0 ? indent$3(concat$6([hardline$4, path.call(bodyPath => {
+ return printStatementSequence(bodyPath, options, print);
+ }, "body")])) : comments.printDanglingComments(path, options), hardline$4, "}"]);
+
+ case "ClassProperty":
+ case "TSAbstractClassProperty":
+ case "ClassPrivateProperty":
+ {
+ if (n.decorators && n.decorators.length !== 0) {
+ parts.push(printDecorators(path, options, print));
+ }
+
+ if (n.accessibility) {
+ parts.push(n.accessibility + " ");
+ }
+
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ if (n.type === "TSAbstractClassProperty" || n.abstract) {
+ parts.push("abstract ");
+ }
+
+ if (n.readonly) {
+ parts.push("readonly ");
+ }
+
+ const variance = getFlowVariance$1(n);
+
+ if (variance) {
+ parts.push(variance);
+ }
+
+ parts.push(printPropertyKey(path, options, print), printOptionalToken(path), printTypeAnnotation(path, options, print));
+
+ if (n.value) {
+ parts.push(" =", printAssignmentRight(n.key, n.value, path.call(print, "value"), options));
+ }
+
+ parts.push(semi);
+ return group$2(concat$6(parts));
+ }
+
+ case "ClassDeclaration":
+ case "ClassExpression":
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ parts.push(concat$6(printClass(path, options, print)));
+ return concat$6(parts);
+
+ case "TSInterfaceHeritage":
+ case "TSExpressionWithTypeArguments":
+ // Babel AST
+ parts.push(path.call(print, "expression"));
+
+ if (n.typeParameters) {
+ parts.push(path.call(print, "typeParameters"));
+ }
+
+ return concat$6(parts);
+
+ case "TemplateElement":
+ return join$4(literalline$2, n.value.raw.split(/\r?\n/g));
+
+ case "TemplateLiteral":
+ {
+ let expressions = path.map(print, "expressions");
+ const parentNode = path.getParentNode();
+
+ if (isJestEachTemplateLiteral$1(n, parentNode)) {
+ const printed = printJestEachTemplateLiteral(n, expressions, options);
+
+ if (printed) {
+ return printed;
+ }
+ }
+
+ const isSimple = isSimpleTemplateLiteral$1(n);
+
+ if (isSimple) {
+ expressions = expressions.map(doc => printDocToString$2(doc, Object.assign({}, options, {
+ printWidth: Infinity
+ })).formatted);
+ }
+
+ parts.push(lineSuffixBoundary$1, "`");
+ path.each(childPath => {
+ const i = childPath.getName();
+ parts.push(print(childPath));
+
+ if (i < expressions.length) {
+ // For a template literal of the following form:
+ // `someQuery {
+ // ${call({
+ // a,
+ // b,
+ // })}
+ // }`
+ // the expression is on its own line (there is a \n in the previous
+ // quasi literal), therefore we want to indent the JavaScript
+ // expression inside at the beginning of ${ instead of the beginning
+ // of the `.
+ const {
+ tabWidth
+ } = options;
+ const quasi = childPath.getValue();
+ const indentSize = getIndentSize$2(quasi.value.raw, tabWidth);
+ let printed = expressions[i];
+
+ if (!isSimple) {
+ // Breaks at the template element boundaries (${ and }) are preferred to breaking
+ // in the middle of a MemberExpression
+ if (n.expressions[i].comments && n.expressions[i].comments.length || n.expressions[i].type === "MemberExpression" || n.expressions[i].type === "OptionalMemberExpression" || n.expressions[i].type === "ConditionalExpression" || n.expressions[i].type === "SequenceExpression" || n.expressions[i].type === "TSAsExpression" || isBinaryish$1(n.expressions[i])) {
+ printed = concat$6([indent$3(concat$6([softline$2, printed])), softline$2]);
+ }
+ }
+
+ const aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, printed) : addAlignmentToDoc$2(printed, indentSize, tabWidth);
+ parts.push(group$2(concat$6(["${", aligned, lineSuffixBoundary$1, "}"])));
+ }
+ }, "quasis");
+ parts.push("`");
+ return concat$6(parts);
+ }
+ // These types are unprintable because they serve as abstract
+ // supertypes for other (printable) types.
+
+ case "TaggedTemplateExpression":
+ return concat$6([path.call(print, "tag"), path.call(print, "typeParameters"), path.call(print, "quasi")]);
+
+ case "Node":
+ case "Printable":
+ case "SourceLocation":
+ case "Position":
+ case "Statement":
+ case "Function":
+ case "Pattern":
+ case "Expression":
+ case "Declaration":
+ case "Specifier":
+ case "NamedSpecifier":
+ case "Comment":
+ case "MemberTypeAnnotation": // Flow
+
+ case "Type":
+ /* istanbul ignore next */
+ throw new Error("unprintable type: " + JSON.stringify(n.type));
+ // Type Annotations for Facebook Flow, typically stripped out or
+ // transformed away before printing.
+
+ case "TypeAnnotation":
+ case "TSTypeAnnotation":
+ if (n.typeAnnotation) {
+ return path.call(print, "typeAnnotation");
+ }
+ /* istanbul ignore next */
+
+
+ return "";
+
+ case "TSTupleType":
+ case "TupleTypeAnnotation":
+ {
+ const typesField = n.type === "TSTupleType" ? "elementTypes" : "types";
+ const hasRest = n[typesField].length > 0 && getLast$2(n[typesField]).type === "TSRestType";
+ return group$2(concat$6(["[", indent$3(concat$6([softline$2, printArrayItems(path, options, typesField, print)])), ifBreak$1(shouldPrintComma(options, "all") && !hasRest ? "," : ""), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), softline$2, "]"]));
+ }
+
+ case "ExistsTypeAnnotation":
+ return "*";
+
+ case "EmptyTypeAnnotation":
+ return "empty";
+
+ case "AnyTypeAnnotation":
+ return "any";
+
+ case "MixedTypeAnnotation":
+ return "mixed";
+
+ case "ArrayTypeAnnotation":
+ return concat$6([path.call(print, "elementType"), "[]"]);
+
+ case "BooleanTypeAnnotation":
+ return "boolean";
+
+ case "BooleanLiteralTypeAnnotation":
+ return "" + n.value;
+
+ case "DeclareClass":
+ return printFlowDeclaration(path, printClass(path, options, print));
+
+ case "TSDeclareFunction":
+ // For TypeScript the TSDeclareFunction node shares the AST
+ // structure with FunctionDeclaration
+ return concat$6([n.declare ? "declare " : "", printFunctionDeclaration(path, print, options), semi]);
+
+ case "DeclareFunction":
+ return printFlowDeclaration(path, ["function ", path.call(print, "id"), n.predicate ? " " : "", path.call(print, "predicate"), semi]);
+
+ case "DeclareModule":
+ return printFlowDeclaration(path, ["module ", path.call(print, "id"), " ", path.call(print, "body")]);
+
+ case "DeclareModuleExports":
+ return printFlowDeclaration(path, ["module.exports", ": ", path.call(print, "typeAnnotation"), semi]);
+
+ case "DeclareVariable":
+ return printFlowDeclaration(path, ["var ", path.call(print, "id"), semi]);
+
+ case "DeclareExportAllDeclaration":
+ return concat$6(["declare export * from ", path.call(print, "source")]);
+
+ case "DeclareExportDeclaration":
+ return concat$6(["declare ", printExportDeclaration(path, options, print)]);
+
+ case "DeclareOpaqueType":
+ case "OpaqueType":
+ {
+ parts.push("opaque type ", path.call(print, "id"), path.call(print, "typeParameters"));
+
+ if (n.supertype) {
+ parts.push(": ", path.call(print, "supertype"));
+ }
+
+ if (n.impltype) {
+ parts.push(" = ", path.call(print, "impltype"));
+ }
+
+ parts.push(semi);
+
+ if (n.type === "DeclareOpaqueType") {
+ return printFlowDeclaration(path, parts);
+ }
+
+ return concat$6(parts);
+ }
+
+ case "EnumDeclaration":
+ return concat$6(["enum ", path.call(print, "id"), " ", path.call(print, "body")]);
+
+ case "EnumBooleanBody":
+ case "EnumNumberBody":
+ case "EnumStringBody":
+ case "EnumSymbolBody":
+ {
+ if (n.type === "EnumSymbolBody" || n.explicitType) {
+ let type = null;
+
+ switch (n.type) {
+ case "EnumBooleanBody":
+ type = "boolean";
+ break;
+
+ case "EnumNumberBody":
+ type = "number";
+ break;
+
+ case "EnumStringBody":
+ type = "string";
+ break;
+
+ case "EnumSymbolBody":
+ type = "symbol";
+ break;
+ }
+
+ parts.push("of ", type, " ");
+ }
+
+ if (n.members.length === 0) {
+ parts.push(group$2(concat$6(["{", comments.printDanglingComments(path, options), softline$2, "}"])));
+ } else {
+ parts.push(group$2(concat$6(["{", indent$3(concat$6([hardline$4, printArrayItems(path, options, "members", print), shouldPrintComma(options) ? "," : ""])), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), hardline$4, "}"])));
+ }
+
+ return concat$6(parts);
+ }
+
+ case "EnumBooleanMember":
+ case "EnumNumberMember":
+ case "EnumStringMember":
+ return concat$6([path.call(print, "id"), " = ", typeof n.init === "object" ? path.call(print, "init") : String(n.init)]);
+
+ case "EnumDefaultedMember":
+ return path.call(print, "id");
+
+ case "FunctionTypeAnnotation":
+ case "TSFunctionType":
+ {
+ // FunctionTypeAnnotation is ambiguous:
+ // declare function foo(a: B): void; OR
+ // var A: (a: B) => void;
+ const parent = path.getParentNode(0);
+ const parentParent = path.getParentNode(1);
+ const parentParentParent = path.getParentNode(2);
+ let isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeInternalSlot") && !getFlowVariance$1(parent) && !parent.optional && options.locStart(parent) === options.locStart(n) || parent.type === "ObjectTypeCallProperty" || parentParentParent && parentParentParent.type === "DeclareFunction");
+ let needsColon = isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation"); // Sadly we can't put it inside of FastPath::needsColon because we are
+ // printing ":" as part of the expression and it would put parenthesis
+ // around :(
+
+ const needsParens = needsColon && isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation") && parentParent.type === "ArrowFunctionExpression";
+
+ if (isObjectTypePropertyAFunction$1(parent, options)) {
+ isArrowFunctionTypeAnnotation = true;
+ needsColon = true;
+ }
+
+ if (needsParens) {
+ parts.push("(");
+ }
+
+ parts.push(printFunctionParams(path, print, options,
+ /* expandArg */
+ false,
+ /* printTypeParams */
+ true)); // The returnType is not wrapped in a TypeAnnotation, so the colon
+ // needs to be added separately.
+
+ if (n.returnType || n.predicate || n.typeAnnotation) {
+ parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path.call(print, "returnType"), path.call(print, "predicate"), path.call(print, "typeAnnotation"));
+ }
+
+ if (needsParens) {
+ parts.push(")");
+ }
+
+ return group$2(concat$6(parts));
+ }
+
+ case "TSRestType":
+ return concat$6(["...", path.call(print, "typeAnnotation")]);
+
+ case "TSOptionalType":
+ return concat$6([path.call(print, "typeAnnotation"), "?"]);
+
+ case "FunctionTypeParam":
+ return concat$6([path.call(print, "name"), printOptionalToken(path), n.name ? ": " : "", path.call(print, "typeAnnotation")]);
+
+ case "GenericTypeAnnotation":
+ return concat$6([path.call(print, "id"), path.call(print, "typeParameters")]);
+
+ case "DeclareInterface":
+ case "InterfaceDeclaration":
+ case "InterfaceTypeAnnotation":
+ {
+ if (n.type === "DeclareInterface" || n.declare) {
+ parts.push("declare ");
+ }
+
+ parts.push("interface");
+
+ if (n.type === "DeclareInterface" || n.type === "InterfaceDeclaration") {
+ parts.push(" ", path.call(print, "id"), path.call(print, "typeParameters"));
+ }
+
+ if (n.extends.length > 0) {
+ parts.push(group$2(indent$3(concat$6([line$4, "extends ", (n.extends.length === 1 ? identity$2 : indent$3)(join$4(concat$6([",", line$4]), path.map(print, "extends")))]))));
+ }
+
+ parts.push(" ", path.call(print, "body"));
+ return group$2(concat$6(parts));
+ }
+
+ case "ClassImplements":
+ case "InterfaceExtends":
+ return concat$6([path.call(print, "id"), path.call(print, "typeParameters")]);
+
+ case "TSClassImplements":
+ return concat$6([path.call(print, "expression"), path.call(print, "typeParameters")]);
+
+ case "TSIntersectionType":
+ case "IntersectionTypeAnnotation":
+ {
+ const types = path.map(print, "types");
+ const result = [];
+ let wasIndented = false;
+
+ for (let i = 0; i < types.length; ++i) {
+ if (i === 0) {
+ result.push(types[i]);
+ } else if (isObjectType$1(n.types[i - 1]) && isObjectType$1(n.types[i])) {
+ // If both are objects, don't indent
+ result.push(concat$6([" & ", wasIndented ? indent$3(types[i]) : types[i]]));
+ } else if (!isObjectType$1(n.types[i - 1]) && !isObjectType$1(n.types[i])) {
+ // If no object is involved, go to the next line if it breaks
+ result.push(indent$3(concat$6([" &", line$4, types[i]])));
+ } else {
+ // If you go from object to non-object or vis-versa, then inline it
+ if (i > 1) {
+ wasIndented = true;
+ }
+
+ result.push(" & ", i > 1 ? indent$3(types[i]) : types[i]);
+ }
+ }
+
+ return group$2(concat$6(result));
+ }
+
+ case "TSUnionType":
+ case "UnionTypeAnnotation":
+ {
+ // single-line variation
+ // A | B | C
+ // multi-line variation
+ // | A
+ // | B
+ // | C
+ const parent = path.getParentNode(); // If there's a leading comment, the parent is doing the indentation
+
+ const shouldIndent = parent.type !== "TypeParameterInstantiation" && parent.type !== "TSTypeParameterInstantiation" && parent.type !== "GenericTypeAnnotation" && parent.type !== "TSTypeReference" && parent.type !== "TSTypeAssertion" && parent.type !== "TupleTypeAnnotation" && parent.type !== "TSTupleType" && !(parent.type === "FunctionTypeParam" && !parent.name) && !((parent.type === "TypeAlias" || parent.type === "VariableDeclarator" || parent.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment$1(options.originalText, n, options)); // {
+ // a: string
+ // } | null | void
+ // should be inlined and not be printed in the multi-line variant
+
+ const shouldHug = shouldHugType(n); // We want to align the children but without its comment, so it looks like
+ // | child1
+ // // comment
+ // | child2
+
+ const printed = path.map(typePath => {
+ let printedType = typePath.call(print);
+
+ if (!shouldHug) {
+ printedType = align$1(2, printedType);
+ }
+
+ return comments.printComments(typePath, () => printedType, options);
+ }, "types");
+
+ if (shouldHug) {
+ return join$4(" | ", printed);
+ }
+
+ const shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment$1(options.originalText, n, options);
+ const code = concat$6([ifBreak$1(concat$6([shouldAddStartLine ? line$4 : "", "| "])), join$4(concat$6([line$4, "| "]), printed)]);
+
+ if (needsParens_1(path, options)) {
+ return group$2(concat$6([indent$3(code), softline$2]));
+ }
+
+ if (parent.type === "TupleTypeAnnotation" && parent.types.length > 1 || parent.type === "TSTupleType" && parent.elementTypes.length > 1) {
+ return group$2(concat$6([indent$3(concat$6([ifBreak$1(concat$6(["(", softline$2])), code])), softline$2, ifBreak$1(")")]));
+ }
+
+ return group$2(shouldIndent ? indent$3(code) : code);
+ }
+
+ case "NullableTypeAnnotation":
+ return concat$6(["?", path.call(print, "typeAnnotation")]);
+
+ case "TSNullKeyword":
+ case "NullLiteralTypeAnnotation":
+ return "null";
+
+ case "ThisTypeAnnotation":
+ return "this";
+
+ case "NumberTypeAnnotation":
+ return "number";
+
+ case "SymbolTypeAnnotation":
+ return "symbol";
+
+ case "ObjectTypeCallProperty":
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ parts.push(path.call(print, "value"));
+ return concat$6(parts);
+
+ case "ObjectTypeIndexer":
+ {
+ const variance = getFlowVariance$1(n);
+ return concat$6([variance || "", "[", path.call(print, "id"), n.id ? ": " : "", path.call(print, "key"), "]: ", path.call(print, "value")]);
+ }
+
+ case "ObjectTypeProperty":
+ {
+ const variance = getFlowVariance$1(n);
+ let modifier = "";
+
+ if (n.proto) {
+ modifier = "proto ";
+ } else if (n.static) {
+ modifier = "static ";
+ }
+
+ return concat$6([modifier, isGetterOrSetter$1(n) ? n.kind + " " : "", variance || "", printPropertyKey(path, options, print), printOptionalToken(path), isFunctionNotation$1(n, options) ? "" : ": ", path.call(print, "value")]);
+ }
+
+ case "QualifiedTypeIdentifier":
+ return concat$6([path.call(print, "qualification"), ".", path.call(print, "id")]);
+
+ case "StringLiteralTypeAnnotation":
+ return nodeStr(n, options);
+
+ case "NumberLiteralTypeAnnotation":
+ assert.strictEqual(typeof n.value, "number");
+
+ if (n.extra != null) {
+ return printNumber$1(n.extra.raw);
+ }
+
+ return printNumber$1(n.raw);
+
+ case "StringTypeAnnotation":
+ return "string";
+
+ case "DeclareTypeAlias":
+ case "TypeAlias":
+ {
+ if (n.type === "DeclareTypeAlias" || n.declare) {
+ parts.push("declare ");
+ }
+
+ const printed = printAssignmentRight(n.id, n.right, path.call(print, "right"), options);
+ parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", printed, semi);
+ return group$2(concat$6(parts));
+ }
+
+ case "TypeCastExpression":
+ {
+ return concat$6(["(", path.call(print, "expression"), printTypeAnnotation(path, options, print), ")"]);
+ }
+
+ case "TypeParameterDeclaration":
+ case "TypeParameterInstantiation":
+ {
+ const value = path.getValue();
+ const commentStart = value.range ? options.originalText.slice(0, value.range[0]).lastIndexOf("/*") : -1; // As noted in the TypeCastExpression comments above, we're able to use a normal whitespace regex here
+ // because we know for sure that this is a type definition.
+
+ const commentSyntax = commentStart >= 0 && options.originalText.slice(commentStart).match(/^\/\*\s*::/);
+
+ if (commentSyntax) {
+ return concat$6(["/*:: ", printTypeParameters(path, options, print, "params"), " */"]);
+ }
+
+ return printTypeParameters(path, options, print, "params");
+ }
+
+ case "TSTypeParameterDeclaration":
+ case "TSTypeParameterInstantiation":
+ return printTypeParameters(path, options, print, "params");
+
+ case "TSTypeParameter":
+ case "TypeParameter":
+ {
+ const parent = path.getParentNode();
+
+ if (parent.type === "TSMappedType") {
+ parts.push("[", path.call(print, "name"));
+
+ if (n.constraint) {
+ parts.push(" in ", path.call(print, "constraint"));
+ }
+
+ parts.push("]");
+ return concat$6(parts);
+ }
+
+ const variance = getFlowVariance$1(n);
+
+ if (variance) {
+ parts.push(variance);
+ }
+
+ parts.push(path.call(print, "name"));
+
+ if (n.bound) {
+ parts.push(": ");
+ parts.push(path.call(print, "bound"));
+ }
+
+ if (n.constraint) {
+ parts.push(" extends ", path.call(print, "constraint"));
+ }
+
+ if (n.default) {
+ parts.push(" = ", path.call(print, "default"));
+ } // Keep comma if the file extension is .tsx and
+ // has one type parameter that isn't extend with any types.
+ // Because, otherwise formatted result will be invalid as tsx.
+
+
+ const grandParent = path.getNode(2);
+
+ if (parent.params && parent.params.length === 1 && isTSXFile$1(options) && !n.constraint && grandParent.type === "ArrowFunctionExpression") {
+ parts.push(",");
+ }
+
+ return concat$6(parts);
+ }
+
+ case "TypeofTypeAnnotation":
+ return concat$6(["typeof ", path.call(print, "argument")]);
+
+ case "VoidTypeAnnotation":
+ return "void";
+
+ case "InferredPredicate":
+ return "%checks";
+ // Unhandled types below. If encountered, nodes of these types should
+ // be either left alone or desugared into AST types that are fully
+ // supported by the pretty-printer.
+
+ case "DeclaredPredicate":
+ return concat$6(["%checks(", path.call(print, "value"), ")"]);
+
+ case "TSAbstractKeyword":
+ return "abstract";
+
+ case "TSAnyKeyword":
+ return "any";
+
+ case "TSAsyncKeyword":
+ return "async";
+
+ case "TSBooleanKeyword":
+ return "boolean";
+
+ case "TSBigIntKeyword":
+ return "bigint";
+
+ case "TSConstKeyword":
+ return "const";
+
+ case "TSDeclareKeyword":
+ return "declare";
+
+ case "TSExportKeyword":
+ return "export";
+
+ case "TSNeverKeyword":
+ return "never";
+
+ case "TSNumberKeyword":
+ return "number";
+
+ case "TSObjectKeyword":
+ return "object";
+
+ case "TSProtectedKeyword":
+ return "protected";
+
+ case "TSPrivateKeyword":
+ return "private";
+
+ case "TSPublicKeyword":
+ return "public";
+
+ case "TSReadonlyKeyword":
+ return "readonly";
+
+ case "TSSymbolKeyword":
+ return "symbol";
+
+ case "TSStaticKeyword":
+ return "static";
+
+ case "TSStringKeyword":
+ return "string";
+
+ case "TSUndefinedKeyword":
+ return "undefined";
+
+ case "TSUnknownKeyword":
+ return "unknown";
+
+ case "TSVoidKeyword":
+ return "void";
+
+ case "TSAsExpression":
+ return concat$6([path.call(print, "expression"), " as ", path.call(print, "typeAnnotation")]);
+
+ case "TSArrayType":
+ return concat$6([path.call(print, "elementType"), "[]"]);
+
+ case "TSPropertySignature":
+ {
+ if (n.export) {
+ parts.push("export ");
+ }
+
+ if (n.accessibility) {
+ parts.push(n.accessibility + " ");
+ }
+
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ if (n.readonly) {
+ parts.push("readonly ");
+ }
+
+ parts.push(printPropertyKey(path, options, print), printOptionalToken(path));
+
+ if (n.typeAnnotation) {
+ parts.push(": ");
+ parts.push(path.call(print, "typeAnnotation"));
+ } // This isn't valid semantically, but it's in the AST so we can print it.
+
+
+ if (n.initializer) {
+ parts.push(" = ", path.call(print, "initializer"));
+ }
+
+ return concat$6(parts);
+ }
+
+ case "TSParameterProperty":
+ if (n.accessibility) {
+ parts.push(n.accessibility + " ");
+ }
+
+ if (n.export) {
+ parts.push("export ");
+ }
+
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ if (n.readonly) {
+ parts.push("readonly ");
+ }
+
+ parts.push(path.call(print, "parameter"));
+ return concat$6(parts);
+
+ case "TSTypeReference":
+ return concat$6([path.call(print, "typeName"), printTypeParameters(path, options, print, "typeParameters")]);
+
+ case "TSTypeQuery":
+ return concat$6(["typeof ", path.call(print, "exprName")]);
+
+ case "TSIndexSignature":
+ {
+ const parent = path.getParentNode(); // The typescript parser accepts multiple parameters here. If you're
+ // using them, it makes sense to have a trailing comma. But if you
+ // aren't, this is more like a computed property name than an array.
+ // So we leave off the trailing comma when there's just one parameter.
+
+ const trailingComma = n.parameters.length > 1 ? ifBreak$1(shouldPrintComma(options) ? "," : "") : "";
+ const parametersGroup = group$2(concat$6([indent$3(concat$6([softline$2, join$4(concat$6([", ", softline$2]), path.map(print, "parameters"))])), trailingComma, softline$2]));
+ return concat$6([n.export ? "export " : "", n.accessibility ? concat$6([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", n.parameters ? parametersGroup : "", n.typeAnnotation ? "]: " : "]", n.typeAnnotation ? path.call(print, "typeAnnotation") : "", parent.type === "ClassBody" ? semi : ""]);
+ }
+
+ case "TSTypePredicate":
+ return concat$6([n.asserts ? "asserts " : "", path.call(print, "parameterName"), n.typeAnnotation ? concat$6([" is ", path.call(print, "typeAnnotation")]) : ""]);
+
+ case "TSNonNullExpression":
+ return concat$6([path.call(print, "expression"), "!"]);
+
+ case "TSThisType":
+ return "this";
+
+ case "TSImportType":
+ return concat$6([!n.isTypeOf ? "" : "typeof ", "import(", path.call(print, n.parameter ? "parameter" : "argument"), ")", !n.qualifier ? "" : concat$6([".", path.call(print, "qualifier")]), printTypeParameters(path, options, print, "typeParameters")]);
+
+ case "TSLiteralType":
+ return path.call(print, "literal");
+
+ case "TSIndexedAccessType":
+ return concat$6([path.call(print, "objectType"), "[", path.call(print, "indexType"), "]"]);
+
+ case "TSConstructSignatureDeclaration":
+ case "TSCallSignatureDeclaration":
+ case "TSConstructorType":
+ {
+ if (n.type !== "TSCallSignatureDeclaration") {
+ parts.push("new ");
+ }
+
+ parts.push(group$2(printFunctionParams(path, print, options,
+ /* expandArg */
+ false,
+ /* printTypeParams */
+ true)));
+
+ if (n.returnType || n.typeAnnotation) {
+ const isType = n.type === "TSConstructorType";
+ parts.push(isType ? " => " : ": ", path.call(print, "returnType"), path.call(print, "typeAnnotation"));
+ }
+
+ return concat$6(parts);
+ }
+
+ case "TSTypeOperator":
+ return concat$6([n.operator, " ", path.call(print, "typeAnnotation")]);
+
+ case "TSMappedType":
+ {
+ const shouldBreak = hasNewlineInRange$3(options.originalText, options.locStart(n), options.locEnd(n));
+ return group$2(concat$6(["{", indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, n.readonly ? concat$6([getTypeScriptMappedTypeModifier$1(n.readonly, "readonly"), " "]) : "", printTypeScriptModifiers(path, options, print), path.call(print, "typeParameter"), n.optional ? getTypeScriptMappedTypeModifier$1(n.optional, "?") : "", n.typeAnnotation ? ": " : "", path.call(print, "typeAnnotation"), ifBreak$1(semi, "")])), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), options.bracketSpacing ? line$4 : softline$2, "}"]), {
+ shouldBreak
+ });
+ }
+
+ case "TSMethodSignature":
+ parts.push(n.accessibility ? concat$6([n.accessibility, " "]) : "", n.export ? "export " : "", n.static ? "static " : "", n.readonly ? "readonly " : "", n.computed ? "[" : "", path.call(print, "key"), n.computed ? "]" : "", printOptionalToken(path), printFunctionParams(path, print, options,
+ /* expandArg */
+ false,
+ /* printTypeParams */
+ true));
+
+ if (n.returnType || n.typeAnnotation) {
+ parts.push(": ", path.call(print, "returnType"), path.call(print, "typeAnnotation"));
+ }
+
+ return group$2(concat$6(parts));
+
+ case "TSNamespaceExportDeclaration":
+ parts.push("export as namespace ", path.call(print, "id"));
+
+ if (options.semi) {
+ parts.push(";");
+ }
+
+ return group$2(concat$6(parts));
+
+ case "TSEnumDeclaration":
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ if (n.modifiers) {
+ parts.push(printTypeScriptModifiers(path, options, print));
+ }
+
+ if (n.const) {
+ parts.push("const ");
+ }
+
+ parts.push("enum ", path.call(print, "id"), " ");
+
+ if (n.members.length === 0) {
+ parts.push(group$2(concat$6(["{", comments.printDanglingComments(path, options), softline$2, "}"])));
+ } else {
+ parts.push(group$2(concat$6(["{", indent$3(concat$6([hardline$4, printArrayItems(path, options, "members", print), shouldPrintComma(options, "es5") ? "," : ""])), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), hardline$4, "}"])));
+ }
+
+ return concat$6(parts);
+
+ case "TSEnumMember":
+ parts.push(path.call(print, "id"));
+
+ if (n.initializer) {
+ parts.push(" = ", path.call(print, "initializer"));
+ }
+
+ return concat$6(parts);
+
+ case "TSImportEqualsDeclaration":
+ if (n.isExport) {
+ parts.push("export ");
+ }
+
+ parts.push("import ", path.call(print, "id"), " = ", path.call(print, "moduleReference"));
+
+ if (options.semi) {
+ parts.push(";");
+ }
+
+ return group$2(concat$6(parts));
+
+ case "TSExternalModuleReference":
+ return concat$6(["require(", path.call(print, "expression"), ")"]);
+
+ case "TSModuleDeclaration":
+ {
+ const parent = path.getParentNode();
+ const isExternalModule = isLiteral$1(n.id);
+ const parentIsDeclaration = parent.type === "TSModuleDeclaration";
+ const bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
+
+ if (parentIsDeclaration) {
+ parts.push(".");
+ } else {
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ parts.push(printTypeScriptModifiers(path, options, print));
+ const textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id)); // Global declaration looks like this:
+ // (declare)? global { ... }
+
+ const isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
+
+ if (!isGlobalDeclaration) {
+ parts.push(isExternalModule || /(^|\s)module(\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
+ }
+ }
+
+ parts.push(path.call(print, "id"));
+
+ if (bodyIsDeclaration) {
+ parts.push(path.call(print, "body"));
+ } else if (n.body) {
+ parts.push(" ", group$2(path.call(print, "body")));
+ } else {
+ parts.push(semi);
+ }
+
+ return concat$6(parts);
+ }
+
+ case "PrivateName":
+ return concat$6(["#", path.call(print, "id")]);
+ // TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields.
+
+ case "TSPrivateIdentifier":
+ return n.escapedText;
+
+ case "TSConditionalType":
+ return printTernaryOperator(path, options, print, {
+ beforeParts: () => [path.call(print, "checkType"), " ", "extends", " ", path.call(print, "extendsType")],
+ afterParts: () => [],
+ shouldCheckJsx: false,
+ conditionalNodeType: "TSConditionalType",
+ consequentNodePropertyName: "trueType",
+ alternateNodePropertyName: "falseType",
+ testNodePropertyNames: ["checkType", "extendsType"]
+ });
+
+ case "TSInferType":
+ return concat$6(["infer", " ", path.call(print, "typeParameter")]);
+
+ case "InterpreterDirective":
+ parts.push("#!", n.value, hardline$4);
+
+ if (isNextLineEmpty$2(options.originalText, n, options.locEnd)) {
+ parts.push(hardline$4);
+ }
+
+ return concat$6(parts);
+
+ case "NGRoot":
+ return concat$6([].concat(path.call(print, "node"), !n.node.comments || n.node.comments.length === 0 ? [] : concat$6([" //", n.node.comments[0].value.trimEnd()])));
+
+ case "NGChainedExpression":
+ return group$2(join$4(concat$6([";", line$4]), path.map(childPath => hasNgSideEffect$1(childPath) ? print(childPath) : concat$6(["(", print(childPath), ")"]), "expressions")));
+
+ case "NGEmptyExpression":
+ return "";
+
+ case "NGQuotedExpression":
+ return concat$6([n.prefix, ": ", n.value.trim()]);
+
+ case "NGMicrosyntax":
+ return concat$6(path.map((childPath, index) => concat$6([index === 0 ? "" : isNgForOf$1(childPath.getValue(), index, n) ? " " : concat$6([";", line$4]), print(childPath)]), "body"));
+
+ case "NGMicrosyntaxKey":
+ return /^[a-z_$][a-z0-9_$]*(-[a-z_$][a-z0-9_$])*$/i.test(n.name) ? n.name : JSON.stringify(n.name);
+
+ case "NGMicrosyntaxExpression":
+ return concat$6([path.call(print, "expression"), n.alias === null ? "" : concat$6([" as ", path.call(print, "alias")])]);
+
+ case "NGMicrosyntaxKeyedExpression":
+ {
+ const index = path.getName();
+ const parentNode = path.getParentNode();
+ const shouldNotPrintColon = isNgForOf$1(n, index, parentNode) || (index === 1 && (n.key.name === "then" || n.key.name === "else") || index === 2 && n.key.name === "else" && parentNode.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && parentNode.body[index - 1].key.name === "then") && parentNode.body[0].type === "NGMicrosyntaxExpression";
+ return concat$6([path.call(print, "key"), shouldNotPrintColon ? " " : ": ", path.call(print, "expression")]);
+ }
+
+ case "NGMicrosyntaxLet":
+ return concat$6(["let ", path.call(print, "key"), n.value === null ? "" : concat$6([" = ", path.call(print, "value")])]);
+
+ case "NGMicrosyntaxAs":
+ return concat$6([path.call(print, "key"), " as ", path.call(print, "alias")]);
+
+ case "ArgumentPlaceholder":
+ return "?";
+ // These are not valid TypeScript. Printing them just for the sake of error recovery.
+
+ case "TSJSDocAllType":
+ return "*";
+
+ case "TSJSDocUnknownType":
+ return "?";
+
+ case "TSJSDocNullableType":
+ return concat$6(["?", path.call(print, "typeAnnotation")]);
+
+ case "TSJSDocNonNullableType":
+ return concat$6(["!", path.call(print, "typeAnnotation")]);
+
+ case "TSJSDocFunctionType":
+ return concat$6(["function(", // The parameters could be here, but typescript-estree doesn't convert them anyway (throws an error).
+ "): ", path.call(print, "typeAnnotation")]);
+
+ default:
+ /* istanbul ignore next */
+ throw new Error("unknown type: " + JSON.stringify(n.type));
+ }
+}
+
+function printStatementSequence(path, options, print) {
+ const printed = [];
+ const bodyNode = path.getNode();
+ const isClass = bodyNode.type === "ClassBody";
+ path.map((stmtPath, i) => {
+ const stmt = stmtPath.getValue(); // Just in case the AST has been modified to contain falsy
+ // "statements," it's safer simply to skip them.
+
+ /* istanbul ignore if */
+
+ if (!stmt) {
+ return;
+ } // Skip printing EmptyStatement nodes to avoid leaving stray
+ // semicolons lying around.
+
+
+ if (stmt.type === "EmptyStatement") {
+ return;
+ }
+
+ const stmtPrinted = print(stmtPath);
+ const text = options.originalText;
+ const parts = []; // in no-semi mode, prepend statement with semicolon if it might break ASI
+ // don't prepend the only JSX element in a program with semicolon
+
+ if (!options.semi && !isClass && !isTheOnlyJSXElementInMarkdown$1(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) {
+ if (stmt.comments && stmt.comments.some(comment => comment.leading)) {
+ parts.push(print(stmtPath, {
+ needsSemi: true
+ }));
+ } else {
+ parts.push(";", stmtPrinted);
+ }
+ } else {
+ parts.push(stmtPrinted);
+ }
+
+ if (!options.semi && isClass) {
+ if (classPropMayCauseASIProblems$1(stmtPath)) {
+ parts.push(";");
+ } else if (stmt.type === "ClassProperty") {
+ const nextChild = bodyNode.body[i + 1];
+
+ if (classChildNeedsASIProtection$1(nextChild)) {
+ parts.push(";");
+ }
+ }
+ }
+
+ if (isNextLineEmpty$2(text, stmt, options.locEnd) && !isLastStatement$1(stmtPath)) {
+ parts.push(hardline$4);
+ }
+
+ printed.push(concat$6(parts));
+ });
+ return join$4(hardline$4, printed);
+}
+
+function printPropertyKey(path, options, print) {
+ const node = path.getNode();
+
+ if (node.computed) {
+ return concat$6(["[", path.call(print, "key"), "]"]);
+ }
+
+ const parent = path.getParentNode();
+ const {
+ key
+ } = node;
+
+ if (node.type === "ClassPrivateProperty" && // flow has `Identifier` key, and babel has `PrivateName` key
+ key.type === "Identifier") {
+ return concat$6(["#", path.call(print, "key")]);
+ }
+
+ if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
+ const objectHasStringProp = (parent.properties || parent.body || parent.members).some(prop => !prop.computed && prop.key && isStringLiteral$1(prop.key) && !isStringPropSafeToCoerceToIdentifier$1(prop, options));
+ needsQuoteProps.set(parent, objectHasStringProp);
+ }
+
+ if (key.type === "Identifier" && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
+ // a -> "a"
+ const prop = printString$1(JSON.stringify(key.name), options);
+ return path.call(keyPath => comments.printComments(keyPath, () => prop, options), "key");
+ }
+
+ if (isStringPropSafeToCoerceToIdentifier$1(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
+ // 'a' -> a
+ return path.call(keyPath => comments.printComments(keyPath, () => key.value, options), "key");
+ }
+
+ return path.call(print, "key");
+}
+
+function printMethod(path, options, print) {
+ const node = path.getNode();
+ const {
+ kind
+ } = node;
+ const value = node.value || node;
+ const parts = [];
+
+ if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
+ if (value.async) {
+ parts.push("async ");
+ }
+
+ if (value.generator) {
+ parts.push("*");
+ }
+ } else {
+ assert.ok(kind === "get" || kind === "set");
+ parts.push(kind, " ");
+ }
+
+ parts.push(printPropertyKey(path, options, print), node.optional || node.key.optional ? "?" : "", node === value ? printMethodInternal(path, options, print) : path.call(path => printMethodInternal(path, options, print), "value"));
+ return concat$6(parts);
+}
+
+function printMethodInternal(path, options, print) {
+ const parts = [printFunctionTypeParameters(path, options, print), group$2(concat$6([printFunctionParams(path, print, options), printReturnType(path, print, options)]))];
+
+ if (path.getNode().body) {
+ parts.push(" ", path.call(print, "body"));
+ } else {
+ parts.push(options.semi ? ";" : "");
+ }
+
+ return concat$6(parts);
+}
+
+function couldGroupArg(arg) {
+ return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || arg.type === "TSAsExpression" && couldGroupArg(arg.expression) || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && ( // we want to avoid breaking inside composite return types but not simple keywords
+ // https://github.com/prettier/prettier/issues/4070
+ // export class Thing implements OtherThing {
+ // do: (type: Type) => Provider
= memoize(
+ // (type: ObjectType): Provider => {}
+ // );
+ // }
+ // https://github.com/prettier/prettier/issues/6099
+ // app.get("/", (req, res): void => {
+ // res.send("Hello World!");
+ // });
+ !arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference") && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || arg.body.type === "ConditionalExpression" || isJSXNode$1(arg.body));
+}
+
+function shouldGroupLastArg(args) {
+ const lastArg = getLast$2(args);
+ const penultimateArg = getPenultimate$1(args);
+ return !hasLeadingComment$3(lastArg) && !hasTrailingComment$1(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
+ // disable last element expansion.
+ !penultimateArg || penultimateArg.type !== lastArg.type);
+}
+
+function shouldGroupFirstArg(args) {
+ if (args.length !== 2) {
+ return false;
+ }
+
+ const [firstArg, secondArg] = args;
+ return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg);
+}
+
+function printJestEachTemplateLiteral(node, expressions, options) {
+ /**
+ * a | b | expected
+ * ${1} | ${1} | ${2}
+ * ${1} | ${2} | ${3}
+ * ${2} | ${1} | ${3}
+ */
+ const headerNames = node.quasis[0].value.raw.trim().split(/\s*\|\s*/);
+
+ if (headerNames.length > 1 || headerNames.some(headerName => headerName.length !== 0)) {
+ const parts = [];
+ const stringifiedExpressions = expressions.map(doc => "${" + printDocToString$2(doc, Object.assign({}, options, {
+ printWidth: Infinity,
+ endOfLine: "lf"
+ })).formatted + "}");
+ const tableBody = [{
+ hasLineBreak: false,
+ cells: []
+ }];
+
+ for (let i = 1; i < node.quasis.length; i++) {
+ const row = tableBody[tableBody.length - 1];
+ const correspondingExpression = stringifiedExpressions[i - 1];
+ row.cells.push(correspondingExpression);
+
+ if (correspondingExpression.includes("\n")) {
+ row.hasLineBreak = true;
+ }
+
+ if (node.quasis[i].value.raw.includes("\n")) {
+ tableBody.push({
+ hasLineBreak: false,
+ cells: []
+ });
+ }
+ }
+
+ const maxColumnCount = Math.max(headerNames.length, ...tableBody.map(row => row.cells.length));
+ const maxColumnWidths = Array.from({
+ length: maxColumnCount
+ }).fill(0);
+ const table = [{
+ cells: headerNames
+ }, ...tableBody.filter(row => row.cells.length !== 0)];
+
+ for (const {
+ cells
+ } of table.filter(row => !row.hasLineBreak)) {
+ cells.forEach((cell, index) => {
+ maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$3(cell));
+ });
+ }
+
+ parts.push(lineSuffixBoundary$1, "`", indent$3(concat$6([hardline$4, join$4(hardline$4, table.map(row => join$4(" | ", row.cells.map((cell, index) => row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$3(cell))))))])), hardline$4, "`");
+ return concat$6(parts);
+ }
+}
+
+function printArgumentsList(path, options, print) {
+ const node = path.getValue();
+ const args = node.arguments;
+
+ if (args.length === 0) {
+ return concat$6(["(", comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), ")"]);
+ } // useEffect(() => { ... }, [foo, bar, baz])
+
+
+ if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(arg => arg.comments)) {
+ return concat$6(["(", path.call(print, "arguments", 0), ", ", path.call(print, "arguments", 1), ")"]);
+ } // func(
+ // ({
+ // a,
+ // b
+ // }) => {}
+ // );
+
+
+ function shouldBreakForArrowFunctionInArguments(arg, argPath) {
+ if (!arg || arg.type !== "ArrowFunctionExpression" || !arg.body || arg.body.type !== "BlockStatement" || !arg.params || arg.params.length < 1) {
+ return false;
+ }
+
+ let shouldBreak = false;
+ argPath.each(paramPath => {
+ const printed = concat$6([print(paramPath)]);
+ shouldBreak = shouldBreak || willBreak$1(printed);
+ }, "params");
+ return shouldBreak;
+ }
+
+ let anyArgEmptyLine = false;
+ let shouldBreakForArrowFunction = false;
+ let hasEmptyLineFollowingFirstArg = false;
+ const lastArgIndex = args.length - 1;
+ const printedArguments = path.map((argPath, index) => {
+ const arg = argPath.getNode();
+ const parts = [print(argPath)];
+
+ if (index === lastArgIndex) ; else if (isNextLineEmpty$2(options.originalText, arg, options.locEnd)) {
+ if (index === 0) {
+ hasEmptyLineFollowingFirstArg = true;
+ }
+
+ anyArgEmptyLine = true;
+ parts.push(",", hardline$4, hardline$4);
+ } else {
+ parts.push(",", line$4);
+ }
+
+ shouldBreakForArrowFunction = shouldBreakForArrowFunctionInArguments(arg, argPath);
+ return concat$6(parts);
+ }, "arguments");
+ const maybeTrailingComma = // Dynamic imports cannot have trailing commas
+ !(node.callee && node.callee.type === "Import") && shouldPrintComma(options, "all") ? "," : "";
+
+ function allArgsBrokenOut() {
+ return group$2(concat$6(["(", indent$3(concat$6([line$4, concat$6(printedArguments)])), maybeTrailingComma, line$4, ")"]), {
+ shouldBreak: true
+ });
+ }
+
+ if (path.getParentNode().type !== "Decorator" && isFunctionCompositionArgs$1(args)) {
+ return allArgsBrokenOut();
+ }
+
+ const shouldGroupFirst = shouldGroupFirstArg(args);
+ const shouldGroupLast = shouldGroupLastArg(args);
+
+ if (shouldGroupFirst || shouldGroupLast) {
+ const shouldBreak = (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$1) : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine || shouldBreakForArrowFunction; // We want to print the last argument with a special flag
+
+ let printedExpanded;
+ let i = 0;
+ path.each(argPath => {
+ if (shouldGroupFirst && i === 0) {
+ printedExpanded = [concat$6([argPath.call(p => print(p, {
+ expandFirstArg: true
+ })), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$4 : line$4, hasEmptyLineFollowingFirstArg ? hardline$4 : ""])].concat(printedArguments.slice(1));
+ }
+
+ if (shouldGroupLast && i === args.length - 1) {
+ printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(p => print(p, {
+ expandLastArg: true
+ })));
+ }
+
+ i++;
+ }, "arguments");
+ const somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
+ const simpleConcat = concat$6(["(", concat$6(printedExpanded), ")"]);
+ return concat$6([somePrintedArgumentsWillBreak ? breakParent$2 : "", conditionalGroup$1([!somePrintedArgumentsWillBreak && !node.typeArguments && !node.typeParameters ? simpleConcat : ifBreak$1(allArgsBrokenOut(), simpleConcat), shouldGroupFirst ? concat$6(["(", group$2(printedExpanded[0], {
+ shouldBreak: true
+ }), concat$6(printedExpanded.slice(1)), ")"]) : concat$6(["(", concat$6(printedArguments.slice(0, -1)), group$2(getLast$2(printedExpanded), {
+ shouldBreak: true
+ }), ")"]), allArgsBrokenOut()], {
+ shouldBreak
+ })]);
+ }
+
+ const contents = concat$6(["(", indent$3(concat$6([softline$2, concat$6(printedArguments)])), ifBreak$1(maybeTrailingComma), softline$2, ")"]);
+
+ if (isLongCurriedCallExpression$1(path)) {
+ // By not wrapping the arguments in a group, the printer prioritizes
+ // breaking up these arguments rather than the args of the parent call.
+ return contents;
+ }
+
+ return group$2(contents, {
+ shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
+ });
+}
+
+function printTypeAnnotation(path, options, print) {
+ const node = path.getValue();
+
+ if (!node.typeAnnotation) {
+ return "";
+ }
+
+ const parentNode = path.getParentNode();
+ const isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
+ const isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
+
+ if (isFlowAnnotationComment$1(options.originalText, node.typeAnnotation, options)) {
+ return concat$6([" /*: ", path.call(print, "typeAnnotation"), " */"]);
+ }
+
+ return concat$6([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path.call(print, "typeAnnotation")]);
+}
+
+function printFunctionTypeParameters(path, options, print) {
+ const fun = path.getValue();
+
+ if (fun.typeArguments) {
+ return path.call(print, "typeArguments");
+ }
+
+ if (fun.typeParameters) {
+ return path.call(print, "typeParameters");
+ }
+
+ return "";
+}
+
+function printFunctionParams(path, print, options, expandArg, printTypeParams) {
+ const fun = path.getValue();
+ const parent = path.getParentNode();
+ const paramsField = fun.parameters ? "parameters" : "params";
+ const isParametersInTestCall = isTestCall$1(parent);
+ const shouldHugParameters = shouldHugArguments(fun);
+ const shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(n => n.comments));
+ const typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : "";
+ let printed = [];
+
+ if (fun[paramsField]) {
+ const lastArgIndex = fun[paramsField].length - 1;
+ printed = path.map((childPath, index) => {
+ const parts = [];
+ const param = childPath.getValue();
+ parts.push(print(childPath));
+
+ if (index === lastArgIndex) {
+ if (fun.rest) {
+ parts.push(",", line$4);
+ }
+ } else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
+ parts.push(", ");
+ } else if (isNextLineEmpty$2(options.originalText, param, options.locEnd)) {
+ parts.push(",", hardline$4, hardline$4);
+ } else {
+ parts.push(",", line$4);
+ }
+
+ return concat$6(parts);
+ }, paramsField);
+ }
+
+ if (fun.rest) {
+ printed.push(concat$6(["...", path.call(print, "rest")]));
+ }
+
+ if (printed.length === 0) {
+ return concat$6([typeParams, "(", comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true, comment => getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")"), ")"]);
+ }
+
+ const lastParam = getLast$2(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
+ // params of the first/last argument, we don't want the arguments to break and instead
+ // want the whole expression to be on a new line.
+ //
+ // Good: Bad:
+ // verylongcall( verylongcall((
+ // (a, b) => { a,
+ // } b,
+ // }) ) => {
+ // })
+
+ if (shouldExpandParameters) {
+ return group$2(concat$6([removeLines$1(typeParams), "(", concat$6(printed.map(removeLines$1)), ")"]));
+ } // Single object destructuring should hug
+ //
+ // function({
+ // a,
+ // b,
+ // c
+ // }) {}
+
+
+ const hasNotParameterDecorator = fun[paramsField].every(param => !param.decorators);
+
+ if (shouldHugParameters && hasNotParameterDecorator) {
+ return concat$6([typeParams, "(", concat$6(printed), ")"]);
+ } // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
+
+
+ if (isParametersInTestCall) {
+ return concat$6([typeParams, "(", concat$6(printed), ")"]);
+ }
+
+ const isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction$1(parent, options) || isTypeAnnotationAFunction$1(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType$1(fun[paramsField][0].typeAnnotation) && !fun.rest;
+
+ if (isFlowShorthandWithOneArg) {
+ if (options.arrowParens === "always") {
+ return concat$6(["(", concat$6(printed), ")"]);
+ }
+
+ return concat$6(printed);
+ }
+
+ const canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
+ return concat$6([typeParams, "(", indent$3(concat$6([softline$2, concat$6(printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$2, ")"]);
+}
+
+function shouldPrintParamsWithoutParens(path, options) {
+ if (options.arrowParens === "always") {
+ return false;
+ }
+
+ if (options.arrowParens === "avoid") {
+ const node = path.getValue();
+ return canPrintParamsWithoutParens(node);
+ } // Fallback default; should be unreachable
+
+
+ return false;
+}
+
+function canPrintParamsWithoutParens(node) {
+ return node.params.length === 1 && !node.rest && !node.typeParameters && !hasDanglingComments$1(node) && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.params[0].comments && !node.params[0].optional && !node.predicate && !node.returnType;
+}
+
+function printFunctionDeclaration(path, print, options) {
+ const n = path.getValue();
+ const parts = [];
+
+ if (n.async) {
+ parts.push("async ");
+ }
+
+ if (n.generator) {
+ parts.push("function* ");
+ } else {
+ parts.push("function ");
+ }
+
+ if (n.id) {
+ parts.push(path.call(print, "id"));
+ }
+
+ parts.push(printFunctionTypeParameters(path, options, print), group$2(concat$6([printFunctionParams(path, print, options), printReturnType(path, print, options)])), n.body ? " " : "", path.call(print, "body"));
+ return concat$6(parts);
+}
+
+function printReturnType(path, print, options) {
+ const n = path.getValue();
+ const returnType = path.call(print, "returnType");
+
+ if (n.returnType && isFlowAnnotationComment$1(options.originalText, n.returnType, options)) {
+ return concat$6([" /*: ", returnType, " */"]);
+ }
+
+ const parts = [returnType]; // prepend colon to TypeScript type annotation
+
+ if (n.returnType && n.returnType.typeAnnotation) {
+ parts.unshift(": ");
+ }
+
+ if (n.predicate) {
+ // The return type will already add the colon, but otherwise we
+ // need to do it ourselves
+ parts.push(n.returnType ? " " : ": ", path.call(print, "predicate"));
+ }
+
+ return concat$6(parts);
+}
+
+function printExportDeclaration(path, options, print) {
+ const decl = path.getValue();
+ const semi = options.semi ? ";" : "";
+ const parts = ["export "];
+ const isDefault = decl.default || decl.type === "ExportDefaultDeclaration";
+
+ if (isDefault) {
+ parts.push("default ");
+ }
+
+ parts.push(comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true));
+
+ if (needsHardlineAfterDanglingComment$1(decl)) {
+ parts.push(hardline$4);
+ }
+
+ if (decl.declaration) {
+ parts.push(path.call(print, "declaration"));
+
+ if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
+ parts.push(semi);
+ }
+ } else {
+ if (decl.specifiers && decl.specifiers.length > 0) {
+ const specifiers = [];
+ const defaultSpecifiers = [];
+ const namespaceSpecifiers = [];
+ path.each(specifierPath => {
+ const specifierType = path.getValue().type;
+
+ if (specifierType === "ExportSpecifier") {
+ specifiers.push(print(specifierPath));
+ } else if (specifierType === "ExportDefaultSpecifier") {
+ defaultSpecifiers.push(print(specifierPath));
+ } else if (specifierType === "ExportNamespaceSpecifier") {
+ namespaceSpecifiers.push(concat$6(["* as ", print(specifierPath)]));
+ }
+ }, "specifiers");
+ const isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0;
+ const isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0);
+ const canBreak = specifiers.length > 1 || defaultSpecifiers.length > 0 || decl.specifiers && decl.specifiers.some(node => node.comments);
+ let printed = "";
+
+ if (specifiers.length !== 0) {
+ if (canBreak) {
+ printed = group$2(concat$6(["{", indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, join$4(concat$6([",", line$4]), specifiers)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$4 : softline$2, "}"]));
+ } else {
+ printed = concat$6(["{", options.bracketSpacing ? " " : "", concat$6(specifiers), options.bracketSpacing ? " " : "", "}"]);
+ }
+ }
+
+ parts.push(decl.exportKind === "type" ? "type " : "", concat$6(defaultSpecifiers), concat$6([isDefaultFollowed ? ", " : ""]), concat$6(namespaceSpecifiers), concat$6([isNamespaceFollowed ? ", " : ""]), printed);
+ } else {
+ parts.push("{}");
+ }
+
+ if (decl.source) {
+ parts.push(" from ", path.call(print, "source"));
+ }
+
+ parts.push(semi);
+ }
+
+ return concat$6(parts);
+}
+
+function printFlowDeclaration(path, parts) {
+ const parentExportDecl = getParentExportDeclaration$1(path);
+
+ if (parentExportDecl) {
+ assert.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
+ } else {
+ // If the parent node has type DeclareExportDeclaration, then it
+ // will be responsible for printing the "declare" token. Otherwise
+ // it needs to be printed with this non-exported declaration node.
+ parts.unshift("declare ");
+ }
+
+ return concat$6(parts);
+}
+
+function printTypeScriptModifiers(path, options, print) {
+ const n = path.getValue();
+
+ if (!n.modifiers || !n.modifiers.length) {
+ return "";
+ }
+
+ return concat$6([join$4(" ", path.map(print, "modifiers")), " "]);
+}
+
+function printTypeParameters(path, options, print, paramsKey) {
+ const n = path.getValue();
+
+ if (!n[paramsKey]) {
+ return "";
+ } // for TypeParameterDeclaration typeParameters is a single node
+
+
+ if (!Array.isArray(n[paramsKey])) {
+ return path.call(print, paramsKey);
+ }
+
+ const grandparent = path.getNode(2);
+ const greatGrandParent = path.getNode(3);
+ const greatGreatGrandParent = path.getNode(4);
+ const isParameterInTestCall = grandparent != null && isTestCall$1(grandparent);
+ const shouldInline = isParameterInTestCall || n[paramsKey].length === 0 || n[paramsKey].length === 1 && (shouldHugType(n[paramsKey][0]) || n[paramsKey][0].type === "GenericTypeAnnotation" && shouldHugType(n[paramsKey][0].id) || n[paramsKey][0].type === "TSTypeReference" && shouldHugType(n[paramsKey][0].typeName) || n[paramsKey][0].type === "NullableTypeAnnotation" || // See https://github.com/prettier/prettier/pull/6467 for the context.
+ greatGreatGrandParent && greatGreatGrandParent.type === "VariableDeclarator" && grandparent.type === "TSTypeAnnotation" && greatGrandParent.type !== "ArrowFunctionExpression" && n[paramsKey][0].type !== "TSUnionType" && n[paramsKey][0].type !== "UnionTypeAnnotation" && n[paramsKey][0].type !== "TSIntersectionType" && n[paramsKey][0].type !== "IntersectionTypeAnnotation" && n[paramsKey][0].type !== "TSConditionalType" && n[paramsKey][0].type !== "TSMappedType" && n[paramsKey][0].type !== "TSTypeOperator" && n[paramsKey][0].type !== "TSIndexedAccessType" && n[paramsKey][0].type !== "TSArrayType");
+
+ function printDanglingCommentsForInline(n) {
+ if (!hasDanglingComments$1(n)) {
+ return "";
+ }
+
+ const hasOnlyBlockComments = n.comments.every(comments$1.isBlockComment);
+ const printed = comments.printDanglingComments(path, options,
+ /* sameIndent */
+ hasOnlyBlockComments);
+
+ if (hasOnlyBlockComments) {
+ return printed;
+ }
+
+ return concat$6([printed, hardline$4]);
+ }
+
+ if (shouldInline) {
+ return concat$6(["<", join$4(", ", path.map(print, paramsKey)), printDanglingCommentsForInline(n), ">"]);
+ }
+
+ return group$2(concat$6(["<", indent$3(concat$6([softline$2, join$4(concat$6([",", line$4]), path.map(print, paramsKey))])), ifBreak$1(options.parser !== "typescript" && options.parser !== "babel-ts" && shouldPrintComma(options, "all") ? "," : ""), softline$2, ">"]));
+}
+
+function printClass(path, options, print) {
+ const n = path.getValue();
+ const parts = [];
+
+ if (n.abstract) {
+ parts.push("abstract ");
+ }
+
+ parts.push("class");
+
+ if (n.id) {
+ parts.push(" ", path.call(print, "id"));
+ }
+
+ parts.push(path.call(print, "typeParameters"));
+ const partsGroup = [];
+
+ if (n.superClass) {
+ const printed = concat$6(["extends ", path.call(print, "superClass"), path.call(print, "superTypeParameters")]); // Keep old behaviour of extends in same line
+ // If there is only on extends and there are not comments
+
+ if ((!n.implements || n.implements.length === 0) && (!n.superClass.comments || n.superClass.comments.length === 0)) {
+ parts.push(concat$6([" ", path.call(superClass => comments.printComments(superClass, () => printed, options), "superClass")]));
+ } else {
+ partsGroup.push(group$2(concat$6([line$4, path.call(superClass => comments.printComments(superClass, () => printed, options), "superClass")])));
+ }
+ } else if (n.extends && n.extends.length > 0) {
+ parts.push(" extends ", join$4(", ", path.map(print, "extends")));
+ }
+
+ if (n.mixins && n.mixins.length > 0) {
+ partsGroup.push(line$4, "mixins ", group$2(indent$3(join$4(concat$6([",", line$4]), path.map(print, "mixins")))));
+ }
+
+ if (n.implements && n.implements.length > 0) {
+ partsGroup.push(line$4, "implements", group$2(indent$3(concat$6([line$4, join$4(concat$6([",", line$4]), path.map(print, "implements"))]))));
+ }
+
+ if (partsGroup.length > 0) {
+ parts.push(group$2(indent$3(concat$6(partsGroup))));
+ }
+
+ if (n.body && n.body.comments && hasLeadingOwnLineComment$1(options.originalText, n.body, options)) {
+ parts.push(hardline$4);
+ } else {
+ parts.push(" ");
+ }
+
+ parts.push(path.call(print, "body"));
+ return parts;
+}
+
+function printOptionalToken(path) {
+ const node = path.getValue();
+
+ if (!node.optional || // It's an optional computed method parsed by typescript-estree.
+ // "?" is printed in `printMethod`.
+ node.type === "Identifier" && node === path.getParentNode().key) {
+ return "";
+ }
+
+ if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
+ return "?.";
+ }
+
+ return "?";
+}
+
+function printMemberLookup(path, options, print) {
+ const property = path.call(print, "property");
+ const n = path.getValue();
+ const optional = printOptionalToken(path);
+
+ if (!n.computed) {
+ return concat$6([optional, ".", property]);
+ }
+
+ if (!n.property || isNumericLiteral$1(n.property)) {
+ return concat$6([optional, "[", property, "]"]);
+ }
+
+ return group$2(concat$6([optional, "[", indent$3(concat$6([softline$2, property])), softline$2, "]"]));
+}
+
+function printBindExpressionCallee(path, options, print) {
+ return concat$6(["::", path.call(print, "callee")]);
+} // We detect calls on member expressions specially to format a
+// common pattern better. The pattern we are looking for is this:
+//
+// arr
+// .map(x => x + 1)
+// .filter(x => x > 10)
+// .some(x => x % 2)
+//
+// The way it is structured in the AST is via a nested sequence of
+// MemberExpression and CallExpression. We need to traverse the AST
+// and make groups out of it to print it in the desired way.
+
+
+function printMemberChain(path, options, print) {
+ // The first phase is to linearize the AST by traversing it down.
+ //
+ // a().b()
+ // has the following AST structure:
+ // CallExpression(MemberExpression(CallExpression(Identifier)))
+ // and we transform it into
+ // [Identifier, CallExpression, MemberExpression, CallExpression]
+ const printedNodes = []; // Here we try to retain one typed empty line after each call expression or
+ // the first group whether it is in parentheses or not
+
+ function shouldInsertEmptyLineAfter(node) {
+ const {
+ originalText
+ } = options;
+ const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$3(originalText, node, options.locEnd);
+ const nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
+ // line after that parenthesis
+
+ if (nextChar === ")") {
+ return isNextLineEmptyAfterIndex$2(originalText, nextCharIndex + 1, options.locEnd);
+ }
+
+ return isNextLineEmpty$2(originalText, node, options.locEnd);
+ }
+
+ function rec(path) {
+ const node = path.getValue();
+
+ if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish$1(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) {
+ printedNodes.unshift({
+ node,
+ printed: concat$6([comments.printComments(path, () => concat$6([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]), options), shouldInsertEmptyLineAfter(node) ? hardline$4 : ""])
+ });
+ path.call(callee => rec(callee), "callee");
+ } else if (isMemberish$1(node)) {
+ printedNodes.unshift({
+ node,
+ needsParens: needsParens_1(path, options),
+ printed: comments.printComments(path, () => node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path, options, print) : printBindExpressionCallee(path, options, print), options)
+ });
+ path.call(object => rec(object), "object");
+ } else if (node.type === "TSNonNullExpression") {
+ printedNodes.unshift({
+ node,
+ printed: comments.printComments(path, () => "!", options)
+ });
+ path.call(expression => rec(expression), "expression");
+ } else {
+ printedNodes.unshift({
+ node,
+ printed: path.call(print)
+ });
+ }
+ } // Note: the comments of the root node have already been printed, so we
+ // need to extract this first call without printing them as they would
+ // if handled inside of the recursive call.
+
+
+ const node = path.getValue();
+ printedNodes.unshift({
+ node,
+ printed: concat$6([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)])
+ });
+ path.call(callee => rec(callee), "callee"); // Once we have a linear list of printed nodes, we want to create groups out
+ // of it.
+ //
+ // a().b.c().d().e
+ // will be grouped as
+ // [
+ // [Identifier, CallExpression],
+ // [MemberExpression, MemberExpression, CallExpression],
+ // [MemberExpression, CallExpression],
+ // [MemberExpression],
+ // ]
+ // so that we can print it as
+ // a()
+ // .b.c()
+ // .d()
+ // .e
+ // The first group is the first node followed by
+ // - as many CallExpression as possible
+ // < fn()()() >.something()
+ // - as many array accessors as possible
+ // < fn()[0][1][2] >.something()
+ // - then, as many MemberExpression as possible but the last one
+ // < this.items >.something()
+
+ const groups = [];
+ let currentGroup = [printedNodes[0]];
+ let i = 1;
+
+ for (; i < printedNodes.length; ++i) {
+ if (printedNodes[i].node.type === "TSNonNullExpression" || printedNodes[i].node.type === "OptionalCallExpression" || printedNodes[i].node.type === "CallExpression" || (printedNodes[i].node.type === "MemberExpression" || printedNodes[i].node.type === "OptionalMemberExpression") && printedNodes[i].node.computed && isNumericLiteral$1(printedNodes[i].node.property)) {
+ currentGroup.push(printedNodes[i]);
+ } else {
+ break;
+ }
+ }
+
+ if (printedNodes[0].node.type !== "CallExpression" && printedNodes[0].node.type !== "OptionalCallExpression") {
+ for (; i + 1 < printedNodes.length; ++i) {
+ if (isMemberish$1(printedNodes[i].node) && isMemberish$1(printedNodes[i + 1].node)) {
+ currentGroup.push(printedNodes[i]);
+ } else {
+ break;
+ }
+ }
+ }
+
+ groups.push(currentGroup);
+ currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
+ // a sequence of CallExpression. To compute it, we keep adding things to the
+ // group until we has seen a CallExpression in the past and reach a
+ // MemberExpression
+
+ let hasSeenCallExpression = false;
+
+ for (; i < printedNodes.length; ++i) {
+ if (hasSeenCallExpression && isMemberish$1(printedNodes[i].node)) {
+ // [0] should be appended at the end of the group instead of the
+ // beginning of the next one
+ if (printedNodes[i].node.computed && isNumericLiteral$1(printedNodes[i].node.property)) {
+ currentGroup.push(printedNodes[i]);
+ continue;
+ }
+
+ groups.push(currentGroup);
+ currentGroup = [];
+ hasSeenCallExpression = false;
+ }
+
+ if (printedNodes[i].node.type === "CallExpression" || printedNodes[i].node.type === "OptionalCallExpression") {
+ hasSeenCallExpression = true;
+ }
+
+ currentGroup.push(printedNodes[i]);
+
+ if (printedNodes[i].node.comments && printedNodes[i].node.comments.some(comment => comment.trailing)) {
+ groups.push(currentGroup);
+ currentGroup = [];
+ hasSeenCallExpression = false;
+ }
+ }
+
+ if (currentGroup.length > 0) {
+ groups.push(currentGroup);
+ } // There are cases like Object.keys(), Observable.of(), _.values() where
+ // they are the subject of all the chained calls and therefore should
+ // be kept on the same line:
+ //
+ // Object.keys(items)
+ // .filter(x => x)
+ // .map(x => x)
+ //
+ // In order to detect those cases, we use an heuristic: if the first
+ // node is an identifier with the name starting with a capital
+ // letter or just a sequence of _$. The rationale is that they are
+ // likely to be factories.
+
+
+ function isFactory(name) {
+ return /^[A-Z]|^[_$]+$/.test(name);
+ } // In case the Identifier is shorter than tab width, we can keep the
+ // first call in a single line, if it's an ExpressionStatement.
+ //
+ // d3.scaleLinear()
+ // .domain([0, 100])
+ // .range([0, width]);
+ //
+
+
+ function isShort(name) {
+ return name.length <= options.tabWidth;
+ }
+
+ function shouldNotWrap(groups) {
+ const parent = path.getParentNode();
+ const isExpression = parent && parent.type === "ExpressionStatement";
+ const hasComputed = groups[1].length && groups[1][0].node.computed;
+
+ if (groups[0].length === 1) {
+ const firstNode = groups[0][0].node;
+ return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
+ }
+
+ const lastNode = getLast$2(groups[0]).node;
+ return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
+ }
+
+ const shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
+
+ function printGroup(printedGroup) {
+ const printed = printedGroup.map(tuple => tuple.printed); // Checks if the last node (i.e. the parent node) needs parens and print
+ // accordingly
+
+ if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
+ return concat$6(["(", ...printed, ")"]);
+ }
+
+ return concat$6(printed);
+ }
+
+ function printIndentedGroup(groups) {
+ if (groups.length === 0) {
+ return "";
+ }
+
+ return indent$3(group$2(concat$6([hardline$4, join$4(hardline$4, groups.map(printGroup))])));
+ }
+
+ const printedGroups = groups.map(printGroup);
+ const oneLine = concat$6(printedGroups);
+ const cutoff = shouldMerge ? 3 : 2;
+ const flatGroups = groups.reduce((res, group) => res.concat(group), []);
+ const hasComment = flatGroups.slice(1, -1).some(node => hasLeadingComment$3(node.node)) || flatGroups.slice(0, -1).some(node => hasTrailingComment$1(node.node)) || groups[cutoff] && hasLeadingComment$3(groups[cutoff][0].node); // If we only have a single `.`, we shouldn't do anything fancy and just
+ // render everything concatenated together.
+
+ if (groups.length <= cutoff && !hasComment) {
+ if (isLongCurriedCallExpression$1(path)) {
+ return oneLine;
+ }
+
+ return group$2(oneLine);
+ } // Find out the last node in the first group and check if it has an
+ // empty line after
+
+
+ const lastNodeBeforeIndent = getLast$2(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
+ const shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
+ const expanded = concat$6([printGroup(groups[0]), shouldMerge ? concat$6(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$4 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
+ const callExpressions = printedNodes.map(({
+ node
+ }) => node).filter(isCallOrOptionalCallExpression$1); // We don't want to print in one line if the chain has:
+ // * A comment.
+ // * Non-trivial arguments.
+ // * Any group but the last one has a hard line.
+ // If the last group is a function it's okay to inline if it fits.
+
+ if (hasComment || callExpressions.length > 2 && callExpressions.some(expr => !expr.arguments.every(arg => isSimpleCallArgument$1(arg, 0))) || printedGroups.slice(0, -1).some(willBreak$1) ||
+ /**
+ * scopes.filter(scope => scope.value !== '').map((scope, i) => {
+ * // multi line content
+ * })
+ */
+ ((lastGroupDoc, lastGroupNode) => isCallOrOptionalCallExpression$1(lastGroupNode) && willBreak$1(lastGroupDoc))(getLast$2(printedGroups), getLast$2(getLast$2(groups)).node) && callExpressions.slice(0, -1).some(n => n.arguments.some(isFunctionOrArrowExpression$1))) {
+ return group$2(expanded);
+ }
+
+ return concat$6([// We only need to check `oneLine` because if `expanded` is chosen
+ // that means that the parent group has already been broken
+ // naturally
+ willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$2 : "", conditionalGroup$1([oneLine, expanded])]);
+}
+
+function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
+ if (isFacebookTranslationTag) {
+ return "";
+ }
+
+ if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
+ return child.length === 1 ? softline$2 : hardline$4;
+ }
+
+ return softline$2;
+}
+
+function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
+ if (isFacebookTranslationTag) {
+ return hardline$4;
+ }
+
+ if (child.length === 1) {
+ return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$4 : softline$2;
+ }
+
+ return hardline$4;
+} // JSX Children are strange, mostly for two reasons:
+// 1. JSX reads newlines into string values, instead of skipping them like JS
+// 2. up to one whitespace between elements within a line is significant,
+// but not between lines.
+//
+// Leading, trailing, and lone whitespace all need to
+// turn themselves into the rather ugly `{' '}` when breaking.
+//
+// We print JSX using the `fill` doc primitive.
+// This requires that we give it an array of alternating
+// content and whitespace elements.
+// To ensure this we add dummy `""` content elements as needed.
+
+
+function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag) {
+ const n = path.getValue();
+ const children = []; // using `map` instead of `each` because it provides `i`
+
+ path.map((childPath, i) => {
+ const child = childPath.getValue();
+
+ if (isLiteral$1(child)) {
+ const text = rawText$1(child); // Contains a non-whitespace character
+
+ if (isMeaningfulJSXText$1(child)) {
+ const words = text.split(matchJsxWhitespaceRegex$1); // Starts with whitespace
+
+ if (words[0] === "") {
+ children.push("");
+ words.shift();
+
+ if (/\n/.test(words[0])) {
+ const next = n.children[i + 1];
+ children.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
+ } else {
+ children.push(jsxWhitespace);
+ }
+
+ words.shift();
+ }
+
+ let endWhitespace; // Ends with whitespace
+
+ if (getLast$2(words) === "") {
+ words.pop();
+ endWhitespace = words.pop();
+ } // This was whitespace only without a new line.
+
+
+ if (words.length === 0) {
+ return;
+ }
+
+ words.forEach((word, i) => {
+ if (i % 2 === 1) {
+ children.push(line$4);
+ } else {
+ children.push(word);
+ }
+ });
+
+ if (endWhitespace !== undefined) {
+ if (/\n/.test(endWhitespace)) {
+ const next = n.children[i + 1];
+ children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$2(children), child, next));
+ } else {
+ children.push(jsxWhitespace);
+ }
+ } else {
+ const next = n.children[i + 1];
+ children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$2(children), child, next));
+ }
+ } else if (/\n/.test(text)) {
+ // Keep (up to one) blank line between tags/expressions/text.
+ // Note: We don't keep blank lines between text elements.
+ if (text.match(/\n/g).length > 1) {
+ children.push("");
+ children.push(hardline$4);
+ }
+ } else {
+ children.push("");
+ children.push(jsxWhitespace);
+ }
+ } else {
+ const printedChild = print(childPath);
+ children.push(printedChild);
+ const next = n.children[i + 1];
+ const directlyFollowedByMeaningfulText = next && isMeaningfulJSXText$1(next);
+
+ if (directlyFollowedByMeaningfulText) {
+ const firstWord = rawText$1(next).trim().split(matchJsxWhitespaceRegex$1)[0];
+ children.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, next));
+ } else {
+ children.push(hardline$4);
+ }
+ }
+ }, "children");
+ return children;
+} // JSX expands children from the inside-out, instead of the outside-in.
+// This is both to break children before attributes,
+// and to ensure that when children break, their parents do as well.
+//
+// Any element that is written without any newlines and fits on a single line
+// is left that way.
+// Not only that, any user-written-line containing multiple JSX siblings
+// should also be kept on one line if possible,
+// so each user-written-line is wrapped in its own group.
+//
+// Elements that contain newlines or don't fit on a single line (recursively)
+// are fully-split, using hardline and shouldBreak: true.
+//
+// To support that case properly, all leading and trailing spaces
+// are stripped from the list of children, and replaced with a single hardline.
+
+
+function printJSXElement(path, options, print) {
+ const n = path.getValue();
+
+ if (n.type === "JSXElement" && isEmptyJSXElement$1(n)) {
+ return concat$6([path.call(print, "openingElement"), path.call(print, "closingElement")]);
+ }
+
+ const openingLines = n.type === "JSXElement" ? path.call(print, "openingElement") : path.call(print, "openingFragment");
+ const closingLines = n.type === "JSXElement" ? path.call(print, "closingElement") : path.call(print, "closingFragment");
+
+ if (n.children.length === 1 && n.children[0].type === "JSXExpressionContainer" && (n.children[0].expression.type === "TemplateLiteral" || n.children[0].expression.type === "TaggedTemplateExpression")) {
+ return concat$6([openingLines, concat$6(path.map(print, "children")), closingLines]);
+ } // Convert `{" "}` to text nodes containing a space.
+ // This makes it easy to turn them into `jsxWhitespace` which
+ // can then print as either a space or `{" "}` when breaking.
+
+
+ n.children = n.children.map(child => {
+ if (isJSXWhitespaceExpression$1(child)) {
+ return {
+ type: "JSXText",
+ value: " ",
+ raw: " "
+ };
+ }
+
+ return child;
+ });
+ const containsTag = n.children.filter(isJSXNode$1).length > 0;
+ const containsMultipleExpressions = n.children.filter(child => child.type === "JSXExpressionContainer").length > 1;
+ const containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
+
+ let forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
+ const isMdxBlock = path.getParentNode().rootMarker === "mdx";
+ const rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
+ const jsxWhitespace = isMdxBlock ? concat$6([" "]) : ifBreak$1(concat$6([rawJsxWhitespace, softline$2]), " ");
+ const isFacebookTranslationTag = n.openingElement && n.openingElement.name && n.openingElement.name.name === "fbt";
+ const children = printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag);
+ const containsText = n.children.some(child => isMeaningfulJSXText$1(child)); // We can end up we multiple whitespace elements with empty string
+ // content between them.
+ // We need to remove empty whitespace and softlines before JSX whitespace
+ // to get the correct output.
+
+ for (let i = children.length - 2; i >= 0; i--) {
+ const isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
+ const isPairOfHardlines = children[i] === hardline$4 && children[i + 1] === "" && children[i + 2] === hardline$4;
+ const isLineFollowedByJSXWhitespace = (children[i] === softline$2 || children[i] === hardline$4) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
+ const isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$2 || children[i + 2] === hardline$4);
+ const isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
+ const isPairOfHardOrSoftLines = children[i] === softline$2 && children[i + 1] === "" && children[i + 2] === hardline$4 || children[i] === hardline$4 && children[i + 1] === "" && children[i + 2] === softline$2;
+
+ if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJSXWhitespace || isDoubleJSXWhitespace || isPairOfHardOrSoftLines) {
+ children.splice(i, 2);
+ } else if (isJSXWhitespaceFollowedByLine) {
+ children.splice(i + 1, 2);
+ }
+ } // Trim trailing lines (or empty strings)
+
+
+ while (children.length && (isLineNext$1(getLast$2(children)) || isEmpty$1(getLast$2(children)))) {
+ children.pop();
+ } // Trim leading lines (or empty strings)
+
+
+ while (children.length && (isLineNext$1(children[0]) || isEmpty$1(children[0])) && (isLineNext$1(children[1]) || isEmpty$1(children[1]))) {
+ children.shift();
+ children.shift();
+ } // Tweak how we format children if outputting this element over multiple lines.
+ // Also detect whether we will force this element to output over multiple lines.
+
+
+ const multilineChildren = [];
+ children.forEach((child, i) => {
+ // There are a number of situations where we need to ensure we display
+ // whitespace as `{" "}` when outputting this element over multiple lines.
+ if (child === jsxWhitespace) {
+ if (i === 1 && children[i - 1] === "") {
+ if (children.length === 2) {
+ // Solitary whitespace
+ multilineChildren.push(rawJsxWhitespace);
+ return;
+ } // Leading whitespace
+
+
+ multilineChildren.push(concat$6([rawJsxWhitespace, hardline$4]));
+ return;
+ } else if (i === children.length - 1) {
+ // Trailing whitespace
+ multilineChildren.push(rawJsxWhitespace);
+ return;
+ } else if (children[i - 1] === "" && children[i - 2] === hardline$4) {
+ // Whitespace after line break
+ multilineChildren.push(rawJsxWhitespace);
+ return;
+ }
+ }
+
+ multilineChildren.push(child);
+
+ if (willBreak$1(child)) {
+ forcedBreak = true;
+ }
+ }); // If there is text we use `fill` to fit as much onto each line as possible.
+ // When there is no text (just tags and expressions) we use `group`
+ // to output each on a separate line.
+
+ const content = containsText ? fill$3(multilineChildren) : group$2(concat$6(multilineChildren), {
+ shouldBreak: true
+ });
+
+ if (isMdxBlock) {
+ return content;
+ }
+
+ const multiLineElem = group$2(concat$6([openingLines, indent$3(concat$6([hardline$4, content])), hardline$4, closingLines]));
+
+ if (forcedBreak) {
+ return multiLineElem;
+ }
+
+ return conditionalGroup$1([group$2(concat$6([openingLines, concat$6(children), closingLines])), multiLineElem]);
+}
+
+function maybeWrapJSXElementInParens(path, elem, options) {
+ const parent = path.getParentNode();
+
+ if (!parent) {
+ return elem;
+ }
+
+ const NO_WRAP_PARENTS = {
+ ArrayExpression: true,
+ JSXAttribute: true,
+ JSXElement: true,
+ JSXExpressionContainer: true,
+ JSXFragment: true,
+ ExpressionStatement: true,
+ CallExpression: true,
+ OptionalCallExpression: true,
+ ConditionalExpression: true,
+ JsExpressionRoot: true
+ };
+
+ if (NO_WRAP_PARENTS[parent.type]) {
+ return elem;
+ }
+
+ const shouldBreak = path.match(undefined, node => node.type === "ArrowFunctionExpression", isCallOrOptionalCallExpression$1, node => node.type === "JSXExpressionContainer");
+ const needsParens = needsParens_1(path, options);
+ return group$2(concat$6([needsParens ? "" : ifBreak$1("("), indent$3(concat$6([softline$2, elem])), softline$2, needsParens ? "" : ifBreak$1(")")]), {
+ shouldBreak
+ });
+}
+
+function shouldInlineLogicalExpression(node) {
+ if (node.type !== "LogicalExpression") {
+ return false;
+ }
+
+ if (node.right.type === "ObjectExpression" && node.right.properties.length !== 0) {
+ return true;
+ }
+
+ if (node.right.type === "ArrayExpression" && node.right.elements.length !== 0) {
+ return true;
+ }
+
+ if (isJSXNode$1(node.right)) {
+ return true;
+ }
+
+ return false;
+} // For binary expressions to be consistent, we need to group
+// subsequent operators with the same precedence level under a single
+// group. Otherwise they will be nested such that some of them break
+// onto new lines but not all. Operators with the same precedence
+// level should either all break or not. Because we group them by
+// precedence level and the AST is structured based on precedence
+// level, things are naturally broken up correctly, i.e. `&&` is
+// broken before `+`.
+
+
+function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) {
+ let parts = [];
+ const node = path.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same.
+
+ if (isBinaryish$1(node)) {
+ // Put all operators with the same precedence level in the same
+ // group. The reason we only need to do this with the `left`
+ // expression is because given an expression like `1 + 2 - 3`, it
+ // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
+ // is where the rest of the expression will exist. Binary
+ // expressions on the right side mean they have a difference
+ // precedence level and should be treated as a separate group, so
+ // print them normally. (This doesn't hold for the `**` operator,
+ // which is unique in that it is right-associative.)
+ if (shouldFlatten$1(node.operator, node.left.operator)) {
+ // Flatten them out by recursively calling this function.
+ parts = parts.concat(path.call(left => printBinaryishExpressions(left, print, options,
+ /* isNested */
+ true, isInsideParenthesis), "left"));
+ } else {
+ parts.push(path.call(print, "left"));
+ }
+
+ const shouldInline = shouldInlineLogicalExpression(node);
+ const lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment$1(options.originalText, node.right, options);
+ const operator = node.type === "NGPipeExpression" ? "|" : node.operator;
+ const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length !== 0 ? group$2(indent$3(concat$6([softline$2, ": ", join$4(concat$6([softline$2, ":", ifBreak$1(" ")]), path.map(print, "arguments").map(arg => align$1(2, group$2(arg))))]))) : "";
+ const right = shouldInline ? concat$6([operator, " ", path.call(print, "right"), rightSuffix]) : concat$6([lineBeforeOperator ? softline$2 : "", operator, lineBeforeOperator ? " " : line$4, path.call(print, "right"), rightSuffix]); // If there's only a single binary expression, we want to create a group
+ // in order to avoid having a small right part like -1 be on its own line.
+
+ const parent = path.getParentNode();
+ const shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
+ parts.push(" ", shouldGroup ? group$2(right) : right); // The root comments are already printed, but we need to manually print
+ // the other ones since we don't call the normal print on BinaryExpression,
+ // only for the left and right parts
+
+ if (isNested && node.comments) {
+ parts = comments.printComments(path, () => concat$6(parts), options);
+ }
+ } else {
+ // Our stopping case. Simply print the node normally.
+ parts.push(path.call(print));
+ }
+
+ return parts;
+}
+
+function printAssignmentRight(leftNode, rightNode, printedRight, options) {
+ if (hasLeadingOwnLineComment$1(options.originalText, rightNode, options)) {
+ return indent$3(concat$6([line$4, printedRight]));
+ }
+
+ const canBreak = isBinaryish$1(rightNode) && !shouldInlineLogicalExpression(rightNode) || rightNode.type === "ConditionalExpression" && isBinaryish$1(rightNode.test) && !shouldInlineLogicalExpression(rightNode.test) || rightNode.type === "StringLiteralTypeAnnotation" || rightNode.type === "ClassExpression" && rightNode.decorators && rightNode.decorators.length || (leftNode.type === "Identifier" || isStringLiteral$1(leftNode) || leftNode.type === "MemberExpression") && (isStringLiteral$1(rightNode) || isMemberExpressionChain$1(rightNode)) && // do not put values on a separate line from the key in json
+ options.parser !== "json" && options.parser !== "json5" || rightNode.type === "SequenceExpression";
+
+ if (canBreak) {
+ return group$2(indent$3(concat$6([line$4, printedRight])));
+ }
+
+ return concat$6([" ", printedRight]);
+}
+
+function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) {
+ if (!rightNode) {
+ return printedLeft;
+ }
+
+ const printed = printAssignmentRight(leftNode, rightNode, printedRight, options);
+ return group$2(concat$6([printedLeft, operator, printed]));
+}
+
+function adjustClause(node, clause, forceSpace) {
+ if (node.type === "EmptyStatement") {
+ return ";";
+ }
+
+ if (node.type === "BlockStatement" || forceSpace) {
+ return concat$6([" ", clause]);
+ }
+
+ return indent$3(concat$6([line$4, clause]));
+}
+
+function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
+ const raw = rawText$1(node);
+ const isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
+ return printString$1(raw, options, isDirectiveLiteral);
+}
+
+function printRegex(node) {
+ const flags = node.flags.split("").sort().join("");
+ return `/${node.pattern}/${flags}`;
+}
+
+function exprNeedsASIProtection(path, options) {
+ const node = path.getValue();
+ const maybeASIProblem = needsParens_1(path, options) || node.type === "ParenthesizedExpression" || node.type === "TypeCastExpression" || node.type === "ArrowFunctionExpression" && !shouldPrintParamsWithoutParens(path, options) || node.type === "ArrayExpression" || node.type === "ArrayPattern" || node.type === "UnaryExpression" && node.prefix && (node.operator === "+" || node.operator === "-") || node.type === "TemplateLiteral" || node.type === "TemplateElement" || isJSXNode$1(node) || node.type === "BindExpression" && !node.object || node.type === "RegExpLiteral" || node.type === "Literal" && node.pattern || node.type === "Literal" && node.regex;
+
+ if (maybeASIProblem) {
+ return true;
+ }
+
+ if (!hasNakedLeftSide$2(node)) {
+ return false;
+ }
+
+ return path.call(childPath => exprNeedsASIProtection(childPath, options), ...getLeftSidePathName$2(path, node));
+}
+
+function stmtNeedsASIProtection(path, options) {
+ const node = path.getNode();
+
+ if (node.type !== "ExpressionStatement") {
+ return false;
+ }
+
+ return path.call(childPath => exprNeedsASIProtection(childPath, options), "expression");
+}
+
+function shouldHugType(node) {
+ if (isSimpleFlowType$1(node) || isObjectType$1(node)) {
+ return true;
+ }
+
+ if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
+ const voidCount = node.types.filter(n => n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword").length;
+ const hasObject = node.types.some(n => n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
+ n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference");
+
+ if (node.types.length - 1 === voidCount && hasObject) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+function shouldHugArguments(fun) {
+ if (!fun || fun.rest) {
+ return false;
+ }
+
+ const params = fun.params || fun.parameters;
+
+ if (!params || params.length !== 1) {
+ return false;
+ }
+
+ const param = params[0];
+ return !param.comments && (param.type === "ObjectPattern" || param.type === "ArrayPattern" || param.type === "Identifier" && param.typeAnnotation && (param.typeAnnotation.type === "TypeAnnotation" || param.typeAnnotation.type === "TSTypeAnnotation") && isObjectType$1(param.typeAnnotation.typeAnnotation) || param.type === "FunctionTypeParam" && isObjectType$1(param.typeAnnotation) || param.type === "AssignmentPattern" && (param.left.type === "ObjectPattern" || param.left.type === "ArrayPattern") && (param.right.type === "Identifier" || param.right.type === "ObjectExpression" && param.right.properties.length === 0 || param.right.type === "ArrayExpression" && param.right.elements.length === 0));
+}
+
+function printArrayItems(path, options, printPath, print) {
+ const printedElements = [];
+ let separatorParts = [];
+ path.each(childPath => {
+ printedElements.push(concat$6(separatorParts));
+ printedElements.push(group$2(print(childPath)));
+ separatorParts = [",", line$4];
+
+ if (childPath.getValue() && isNextLineEmpty$2(options.originalText, childPath.getValue(), options.locEnd)) {
+ separatorParts.push(softline$2);
+ }
+ }, printPath);
+ return concat$6(printedElements);
+}
+
+function printReturnAndThrowArgument(path, options, print) {
+ const node = path.getValue();
+ const semi = options.semi ? ";" : "";
+ const parts = [];
+
+ if (node.argument) {
+ if (returnArgumentHasLeadingComment$1(options, node.argument)) {
+ parts.push(concat$6([" (", indent$3(concat$6([hardline$4, path.call(print, "argument")])), hardline$4, ")"]));
+ } else if (isBinaryish$1(node.argument) || node.argument.type === "SequenceExpression") {
+ parts.push(group$2(concat$6([ifBreak$1(" (", " "), indent$3(concat$6([softline$2, path.call(print, "argument")])), softline$2, ifBreak$1(")")])));
+ } else {
+ parts.push(" ", path.call(print, "argument"));
+ }
+ }
+
+ const lastComment = Array.isArray(node.comments) && node.comments[node.comments.length - 1];
+ const isLastCommentLine = lastComment && (lastComment.type === "CommentLine" || lastComment.type === "Line");
+
+ if (isLastCommentLine) {
+ parts.push(semi);
+ }
+
+ if (hasDanglingComments$1(node)) {
+ parts.push(" ", comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true));
+ }
+
+ if (!isLastCommentLine) {
+ parts.push(semi);
+ }
+
+ return concat$6(parts);
+}
+
+function willPrintOwnComments(path
+/*, options */
+) {
+ const node = path.getValue();
+ const parent = path.getParentNode();
+ return (node && (isJSXNode$1(node) || hasFlowShorthandAnnotationComment$2(node) || parent && (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && (hasFlowAnnotationComment$1(node.leadingComments) || hasFlowAnnotationComment$1(node.trailingComments))) || parent && (parent.type === "JSXSpreadAttribute" || parent.type === "JSXSpreadChild" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node)) && (!hasIgnoreComment$2(path) || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType");
+}
+
+function canAttachComment(node) {
+ return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
+}
+
+function printComment$1(commentPath, options) {
+ const comment = commentPath.getValue();
+
+ switch (comment.type) {
+ case "CommentBlock":
+ case "Block":
+ {
+ if (isIndentableBlockComment(comment)) {
+ const printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment
+ // printed as a `lineSuffix` which causes the comments to be
+ // interleaved. See https://github.com/prettier/prettier/issues/4412
+
+ if (comment.trailing && !hasNewline$4(options.originalText, options.locStart(comment), {
+ backwards: true
+ })) {
+ return concat$6([hardline$4, printed]);
+ }
+
+ return printed;
+ }
+
+ const commentEnd = options.locEnd(comment);
+ const isInsideFlowComment = options.originalText.slice(commentEnd - 3, commentEnd) === "*-/";
+ return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
+ }
+
+ case "CommentLine":
+ case "Line":
+ // Print shebangs with the proper comment characters
+ if (options.originalText.slice(options.locStart(comment)).startsWith("#!")) {
+ return "#!" + comment.value.trimEnd();
+ }
+
+ return "//" + comment.value.trimEnd();
+
+ default:
+ throw new Error("Not a comment: " + JSON.stringify(comment));
+ }
+}
+
+function isIndentableBlockComment(comment) {
+ // If the comment has multiple lines and every line starts with a star
+ // we can fix the indentation of each line. The stars in the `/*` and
+ // `*/` delimiters are not included in the comment value, so add them
+ // back first.
+ const lines = `*${comment.value}*`.split("\n");
+ return lines.length > 1 && lines.every(line => line.trim()[0] === "*");
+}
+
+function printIndentableBlockComment(comment) {
+ const lines = comment.value.split("\n");
+ return concat$6(["/*", join$4(hardline$4, lines.map((line, index) => index === 0 ? line.trimEnd() : " " + (index < lines.length - 1 ? line.trim() : line.trimStart()))), "*/"]);
+}
+
+var printerEstree = {
+ preprocess: preprocess_1,
+ print: genericPrint,
+ embed: embed_1,
+ insertPragma: insertPragma$1,
+ massageAstNode: clean_1,
+ hasPrettierIgnore: hasPrettierIgnore$1,
+ willPrintOwnComments,
+ canAttachComment,
+ printComment: printComment$1,
+ isBlockComment: comments$1.isBlockComment,
+ handleComments: {
+ ownLine: comments$1.handleOwnLineComment,
+ endOfLine: comments$1.handleEndOfLineComment,
+ remaining: comments$1.handleRemainingComment
+ },
+ getGapRegex: comments$1.getGapRegex,
+ getCommentChildNodes: comments$1.getCommentChildNodes
+};
+
+const {
+ concat: concat$7,
+ hardline: hardline$5,
+ indent: indent$4,
+ join: join$5
+} = document.builders;
+
+function genericPrint$1(path, options, print) {
+ const node = path.getValue();
+
+ switch (node.type) {
+ case "JsonRoot":
+ return concat$7([path.call(print, "node"), hardline$5]);
+
+ case "ArrayExpression":
+ return node.elements.length === 0 ? "[]" : concat$7(["[", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path.map(print, "elements"))])), hardline$5, "]"]);
+
+ case "ObjectExpression":
+ return node.properties.length === 0 ? "{}" : concat$7(["{", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path.map(print, "properties"))])), hardline$5, "}"]);
+
+ case "ObjectProperty":
+ return concat$7([path.call(print, "key"), ": ", path.call(print, "value")]);
+
+ case "UnaryExpression":
+ return concat$7([node.operator === "+" ? "" : node.operator, path.call(print, "argument")]);
+
+ case "NullLiteral":
+ return "null";
+
+ case "BooleanLiteral":
+ return node.value ? "true" : "false";
+
+ case "StringLiteral":
+ case "NumericLiteral":
+ return JSON.stringify(node.value);
+
+ case "Identifier":
+ return JSON.stringify(node.name);
+
+ default:
+ /* istanbul ignore next */
+ throw new Error("unknown type: " + JSON.stringify(node.type));
+ }
+}
+
+function clean$1(node, newNode
+/*, parent*/
+) {
+ delete newNode.start;
+ delete newNode.end;
+ delete newNode.extra;
+ delete newNode.loc;
+ delete newNode.comments;
+ delete newNode.errors;
+
+ if (node.type === "Identifier") {
+ return {
+ type: "StringLiteral",
+ value: node.name
+ };
+ }
+
+ if (node.type === "UnaryExpression" && node.operator === "+") {
+ return newNode.argument;
+ }
+}
+
+var printerEstreeJson = {
+ preprocess: preprocess_1,
+ print: genericPrint$1,
+ massageAstNode: clean$1
+};
+
+const CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
+
+var commonOptions = {
+ bracketSpacing: {
+ since: "0.0.0",
+ category: CATEGORY_COMMON,
+ type: "boolean",
+ default: true,
+ description: "Print spaces between brackets.",
+ oppositeDescription: "Do not print spaces between brackets."
+ },
+ singleQuote: {
+ since: "0.0.0",
+ category: CATEGORY_COMMON,
+ type: "boolean",
+ default: false,
+ description: "Use single quotes instead of double quotes."
+ },
+ proseWrap: {
+ since: "1.8.2",
+ category: CATEGORY_COMMON,
+ type: "choice",
+ default: [{
+ since: "1.8.2",
+ value: true
+ }, {
+ since: "1.9.0",
+ value: "preserve"
+ }],
+ description: "How to wrap prose.",
+ choices: [{
+ since: "1.9.0",
+ value: "always",
+ description: "Wrap prose if it exceeds the print width."
+ }, {
+ since: "1.9.0",
+ value: "never",
+ description: "Do not wrap prose."
+ }, {
+ since: "1.9.0",
+ value: "preserve",
+ description: "Wrap prose as-is."
+ }]
+ }
+};
+
+const CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
+
+var options$2 = {
+ arrowParens: {
+ since: "1.9.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "choice",
+ default: [{
+ since: "1.9.0",
+ value: "avoid"
+ }, {
+ since: "2.0.0",
+ value: "always"
+ }],
+ description: "Include parentheses around a sole arrow function parameter.",
+ choices: [{
+ value: "always",
+ description: "Always include parens. Example: `(x) => x`"
+ }, {
+ value: "avoid",
+ description: "Omit parens when possible. Example: `x => x`"
+ }]
+ },
+ bracketSpacing: commonOptions.bracketSpacing,
+ jsxBracketSameLine: {
+ since: "0.17.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "boolean",
+ default: false,
+ description: "Put > on the last line instead of at a new line."
+ },
+ semi: {
+ since: "1.0.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "boolean",
+ default: true,
+ description: "Print semicolons.",
+ oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
+ },
+ singleQuote: commonOptions.singleQuote,
+ jsxSingleQuote: {
+ since: "1.15.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "boolean",
+ default: false,
+ description: "Use single quotes in JSX."
+ },
+ quoteProps: {
+ since: "1.17.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "choice",
+ default: "as-needed",
+ description: "Change when properties in objects are quoted.",
+ choices: [{
+ value: "as-needed",
+ description: "Only add quotes around object properties where required."
+ }, {
+ value: "consistent",
+ description: "If at least one property in an object requires quotes, quote all properties."
+ }, {
+ value: "preserve",
+ description: "Respect the input use of quotes in object properties."
+ }]
+ },
+ trailingComma: {
+ since: "0.0.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "choice",
+ default: [{
+ since: "0.0.0",
+ value: false
+ }, {
+ since: "0.19.0",
+ value: "none"
+ }, {
+ since: "2.0.0",
+ value: "es5"
+ }],
+ description: "Print trailing commas wherever possible when multi-line.",
+ choices: [{
+ value: "es5",
+ description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
+ }, {
+ value: "none",
+ description: "No trailing commas."
+ }, {
+ value: "all",
+ description: "Trailing commas wherever possible (including function arguments)."
+ }]
+ }
+};
+
+var createLanguage = function (linguistData, override) {
+ const {
+ languageId
+ } = linguistData,
+ rest = _objectWithoutPropertiesLoose(linguistData, ["languageId"]);
+
+ return Object.assign({
+ linguistLanguageId: languageId
+ }, rest, {}, override(linguistData));
+};
+
+var name$2 = "JavaScript";
+var type = "programming";
+var tmScope = "source.js";
+var aceMode = "javascript";
+var codemirrorMode = "javascript";
+var codemirrorMimeType = "text/javascript";
+var color = "#f1e05a";
+var aliases = [
+ "js",
+ "node"
+];
+var extensions = [
+ ".js",
+ "._js",
+ ".bones",
+ ".cjs",
+ ".es",
+ ".es6",
+ ".frag",
+ ".gs",
+ ".jake",
+ ".jsb",
+ ".jscad",
+ ".jsfl",
+ ".jsm",
+ ".jss",
+ ".mjs",
+ ".njs",
+ ".pac",
+ ".sjs",
+ ".ssjs",
+ ".xsjs",
+ ".xsjslib"
+];
+var filenames = [
+ "Jakefile"
+];
+var interpreters = [
+ "chakra",
+ "d8",
+ "gjs",
+ "js",
+ "node",
+ "qjs",
+ "rhino",
+ "v8",
+ "v8-shell"
+];
+var languageId = 183;
+var JavaScript = {
+ name: name$2,
+ type: type,
+ tmScope: tmScope,
+ aceMode: aceMode,
+ codemirrorMode: codemirrorMode,
+ codemirrorMimeType: codemirrorMimeType,
+ color: color,
+ aliases: aliases,
+ extensions: extensions,
+ filenames: filenames,
+ interpreters: interpreters,
+ languageId: languageId
+};
+
+var JavaScript$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$2,
+ type: type,
+ tmScope: tmScope,
+ aceMode: aceMode,
+ codemirrorMode: codemirrorMode,
+ codemirrorMimeType: codemirrorMimeType,
+ color: color,
+ aliases: aliases,
+ extensions: extensions,
+ filenames: filenames,
+ interpreters: interpreters,
+ languageId: languageId,
+ 'default': JavaScript
+});
+
+var name$3 = "JSX";
+var type$1 = "programming";
+var group$3 = "JavaScript";
+var extensions$1 = [
+ ".jsx"
+];
+var tmScope$1 = "source.js.jsx";
+var aceMode$1 = "javascript";
+var codemirrorMode$1 = "jsx";
+var codemirrorMimeType$1 = "text/jsx";
+var languageId$1 = 178;
+var JSX = {
+ name: name$3,
+ type: type$1,
+ group: group$3,
+ extensions: extensions$1,
+ tmScope: tmScope$1,
+ aceMode: aceMode$1,
+ codemirrorMode: codemirrorMode$1,
+ codemirrorMimeType: codemirrorMimeType$1,
+ languageId: languageId$1
+};
+
+var JSX$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$3,
+ type: type$1,
+ group: group$3,
+ extensions: extensions$1,
+ tmScope: tmScope$1,
+ aceMode: aceMode$1,
+ codemirrorMode: codemirrorMode$1,
+ codemirrorMimeType: codemirrorMimeType$1,
+ languageId: languageId$1,
+ 'default': JSX
+});
+
+var name$4 = "TypeScript";
+var type$2 = "programming";
+var color$1 = "#2b7489";
+var aliases$1 = [
+ "ts"
+];
+var interpreters$1 = [
+ "deno",
+ "ts-node"
+];
+var extensions$2 = [
+ ".ts"
+];
+var tmScope$2 = "source.ts";
+var aceMode$2 = "typescript";
+var codemirrorMode$2 = "javascript";
+var codemirrorMimeType$2 = "application/typescript";
+var languageId$2 = 378;
+var TypeScript = {
+ name: name$4,
+ type: type$2,
+ color: color$1,
+ aliases: aliases$1,
+ interpreters: interpreters$1,
+ extensions: extensions$2,
+ tmScope: tmScope$2,
+ aceMode: aceMode$2,
+ codemirrorMode: codemirrorMode$2,
+ codemirrorMimeType: codemirrorMimeType$2,
+ languageId: languageId$2
+};
+
+var TypeScript$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$4,
+ type: type$2,
+ color: color$1,
+ aliases: aliases$1,
+ interpreters: interpreters$1,
+ extensions: extensions$2,
+ tmScope: tmScope$2,
+ aceMode: aceMode$2,
+ codemirrorMode: codemirrorMode$2,
+ codemirrorMimeType: codemirrorMimeType$2,
+ languageId: languageId$2,
+ 'default': TypeScript
+});
+
+var name$5 = "TSX";
+var type$3 = "programming";
+var group$4 = "TypeScript";
+var extensions$3 = [
+ ".tsx"
+];
+var tmScope$3 = "source.tsx";
+var aceMode$3 = "javascript";
+var codemirrorMode$3 = "jsx";
+var codemirrorMimeType$3 = "text/jsx";
+var languageId$3 = 94901924;
+var TSX = {
+ name: name$5,
+ type: type$3,
+ group: group$4,
+ extensions: extensions$3,
+ tmScope: tmScope$3,
+ aceMode: aceMode$3,
+ codemirrorMode: codemirrorMode$3,
+ codemirrorMimeType: codemirrorMimeType$3,
+ languageId: languageId$3
+};
+
+var TSX$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$5,
+ type: type$3,
+ group: group$4,
+ extensions: extensions$3,
+ tmScope: tmScope$3,
+ aceMode: aceMode$3,
+ codemirrorMode: codemirrorMode$3,
+ codemirrorMimeType: codemirrorMimeType$3,
+ languageId: languageId$3,
+ 'default': TSX
+});
+
+var name$6 = "JSON";
+var type$4 = "data";
+var tmScope$4 = "source.json";
+var aceMode$4 = "json";
+var codemirrorMode$4 = "javascript";
+var codemirrorMimeType$4 = "application/json";
+var searchable = false;
+var extensions$4 = [
+ ".json",
+ ".avsc",
+ ".geojson",
+ ".gltf",
+ ".har",
+ ".ice",
+ ".JSON-tmLanguage",
+ ".jsonl",
+ ".mcmeta",
+ ".tfstate",
+ ".tfstate.backup",
+ ".topojson",
+ ".webapp",
+ ".webmanifest",
+ ".yy",
+ ".yyp"
+];
+var filenames$1 = [
+ ".arcconfig",
+ ".htmlhintrc",
+ ".tern-config",
+ ".tern-project",
+ ".watchmanconfig",
+ "composer.lock",
+ "mcmod.info"
+];
+var languageId$4 = 174;
+var _JSON = {
+ name: name$6,
+ type: type$4,
+ tmScope: tmScope$4,
+ aceMode: aceMode$4,
+ codemirrorMode: codemirrorMode$4,
+ codemirrorMimeType: codemirrorMimeType$4,
+ searchable: searchable,
+ extensions: extensions$4,
+ filenames: filenames$1,
+ languageId: languageId$4
+};
+
+var _JSON$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$6,
+ type: type$4,
+ tmScope: tmScope$4,
+ aceMode: aceMode$4,
+ codemirrorMode: codemirrorMode$4,
+ codemirrorMimeType: codemirrorMimeType$4,
+ searchable: searchable,
+ extensions: extensions$4,
+ filenames: filenames$1,
+ languageId: languageId$4,
+ 'default': _JSON
+});
+
+var name$7 = "JSON with Comments";
+var type$5 = "data";
+var group$5 = "JSON";
+var tmScope$5 = "source.js";
+var aceMode$5 = "javascript";
+var codemirrorMode$5 = "javascript";
+var codemirrorMimeType$5 = "text/javascript";
+var aliases$2 = [
+ "jsonc"
+];
+var extensions$5 = [
+ ".jsonc",
+ ".sublime-build",
+ ".sublime-commands",
+ ".sublime-completions",
+ ".sublime-keymap",
+ ".sublime-macro",
+ ".sublime-menu",
+ ".sublime-mousemap",
+ ".sublime-project",
+ ".sublime-settings",
+ ".sublime-theme",
+ ".sublime-workspace",
+ ".sublime_metrics",
+ ".sublime_session"
+];
+var filenames$2 = [
+ ".babelrc",
+ ".eslintrc.json",
+ ".jscsrc",
+ ".jshintrc",
+ ".jslintrc",
+ "jsconfig.json",
+ "language-configuration.json",
+ "tsconfig.json"
+];
+var languageId$5 = 423;
+var JSON_with_Comments = {
+ name: name$7,
+ type: type$5,
+ group: group$5,
+ tmScope: tmScope$5,
+ aceMode: aceMode$5,
+ codemirrorMode: codemirrorMode$5,
+ codemirrorMimeType: codemirrorMimeType$5,
+ aliases: aliases$2,
+ extensions: extensions$5,
+ filenames: filenames$2,
+ languageId: languageId$5
+};
+
+var JSON_with_Comments$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$7,
+ type: type$5,
+ group: group$5,
+ tmScope: tmScope$5,
+ aceMode: aceMode$5,
+ codemirrorMode: codemirrorMode$5,
+ codemirrorMimeType: codemirrorMimeType$5,
+ aliases: aliases$2,
+ extensions: extensions$5,
+ filenames: filenames$2,
+ languageId: languageId$5,
+ 'default': JSON_with_Comments
+});
+
+var name$8 = "JSON5";
+var type$6 = "data";
+var extensions$6 = [
+ ".json5"
+];
+var tmScope$6 = "source.js";
+var aceMode$6 = "javascript";
+var codemirrorMode$6 = "javascript";
+var codemirrorMimeType$6 = "application/json";
+var languageId$6 = 175;
+var JSON5 = {
+ name: name$8,
+ type: type$6,
+ extensions: extensions$6,
+ tmScope: tmScope$6,
+ aceMode: aceMode$6,
+ codemirrorMode: codemirrorMode$6,
+ codemirrorMimeType: codemirrorMimeType$6,
+ languageId: languageId$6
+};
+
+var JSON5$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$8,
+ type: type$6,
+ extensions: extensions$6,
+ tmScope: tmScope$6,
+ aceMode: aceMode$6,
+ codemirrorMode: codemirrorMode$6,
+ codemirrorMimeType: codemirrorMimeType$6,
+ languageId: languageId$6,
+ 'default': JSON5
+});
+
+var require$$0$1 = getCjsExportFromNamespace(JavaScript$1);
+
+var require$$1$1 = getCjsExportFromNamespace(JSX$1);
+
+var require$$2 = getCjsExportFromNamespace(TypeScript$1);
+
+var require$$3 = getCjsExportFromNamespace(TSX$1);
+
+var require$$4$1 = getCjsExportFromNamespace(_JSON$1);
+
+var require$$5 = getCjsExportFromNamespace(JSON_with_Comments$1);
+
+var require$$6 = getCjsExportFromNamespace(JSON5$1);
+
+const languages = [createLanguage(require$$0$1, data => ({
+ since: "0.0.0",
+ parsers: ["babel", "flow"],
+ vscodeLanguageIds: ["javascript", "mongo"],
+ interpreters: data.interpreters.concat(["nodejs"])
+})), createLanguage(require$$0$1, () => ({
+ name: "Flow",
+ since: "0.0.0",
+ parsers: ["babel", "flow"],
+ vscodeLanguageIds: ["javascript"],
+ aliases: [],
+ filenames: [],
+ extensions: [".js.flow"]
+})), createLanguage(require$$1$1, () => ({
+ since: "0.0.0",
+ parsers: ["babel", "flow"],
+ vscodeLanguageIds: ["javascriptreact"]
+})), createLanguage(require$$2, () => ({
+ since: "1.4.0",
+ parsers: ["typescript", "babel-ts"],
+ vscodeLanguageIds: ["typescript"]
+})), createLanguage(require$$3, () => ({
+ since: "1.4.0",
+ parsers: ["typescript", "babel-ts"],
+ vscodeLanguageIds: ["typescriptreact"]
+})), createLanguage(require$$4$1, () => ({
+ name: "JSON.stringify",
+ since: "1.13.0",
+ parsers: ["json-stringify"],
+ vscodeLanguageIds: ["json"],
+ extensions: [],
+ // .json file defaults to json instead of json-stringify
+ filenames: ["package.json", "package-lock.json", "composer.json"]
+})), createLanguage(require$$4$1, data => ({
+ since: "1.5.0",
+ parsers: ["json"],
+ vscodeLanguageIds: ["json"],
+ filenames: data.filenames.concat([".prettierrc"])
+})), createLanguage(require$$5, data => ({
+ since: "1.5.0",
+ parsers: ["json"],
+ vscodeLanguageIds: ["jsonc"],
+ filenames: data.filenames.concat([".eslintrc"])
+})), createLanguage(require$$6, () => ({
+ since: "1.13.0",
+ parsers: ["json5"],
+ vscodeLanguageIds: ["json5"]
+}))];
+const printers = {
+ estree: printerEstree,
+ "estree-json": printerEstreeJson
+};
+var languageJs = {
+ languages,
+ options: options$2,
+ printers
+};
+
+function clean$2(ast, newObj, parent) {
+ ["raw", // front-matter
+ "raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(name => {
+ delete newObj[name];
+ });
+
+ if (ast.type === "yaml") {
+ delete newObj.value;
+ } // --insert-pragma
+
+
+ if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length !== 0 && ( // first non-front-matter comment
+ parent.nodes[0] === ast || (parent.nodes[0].type === "yaml" || parent.nodes[0].type === "toml") && parent.nodes[1] === ast)) {
+ /**
+ * something
+ *
+ * @format
+ */
+ delete newObj.text; // standalone pragma
+
+ if (/^\*\s*@(format|prettier)\s*$/.test(ast.text)) {
+ return null;
+ }
+ }
+
+ if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
+ delete newObj.value;
+ }
+
+ if (ast.type === "css-rule") {
+ delete newObj.params;
+ }
+
+ if (ast.type === "selector-combinator") {
+ newObj.value = newObj.value.replace(/\s+/g, " ");
+ }
+
+ if (ast.type === "media-feature") {
+ newObj.value = newObj.value.replace(/ /g, "");
+ }
+
+ if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].includes(newObj.value.replace().toLowerCase())) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") {
+ newObj.value = newObj.value.toLowerCase();
+ }
+
+ if (ast.type === "css-decl") {
+ newObj.prop = newObj.prop.toLowerCase();
+ }
+
+ if (ast.type === "css-atrule" || ast.type === "css-import") {
+ newObj.name = newObj.name.toLowerCase();
+ }
+
+ if (ast.type === "value-number") {
+ newObj.unit = newObj.unit.toLowerCase();
+ }
+
+ if ((ast.type === "media-feature" || ast.type === "media-keyword" || ast.type === "media-type" || ast.type === "media-unknown" || ast.type === "media-url" || ast.type === "media-value" || ast.type === "selector-attribute" || ast.type === "selector-string" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "value-string") && newObj.value) {
+ newObj.value = cleanCSSStrings(newObj.value);
+ }
+
+ if (ast.type === "selector-attribute") {
+ newObj.attribute = newObj.attribute.trim();
+
+ if (newObj.namespace) {
+ if (typeof newObj.namespace === "string") {
+ newObj.namespace = newObj.namespace.trim();
+
+ if (newObj.namespace.length === 0) {
+ newObj.namespace = true;
+ }
+ }
+ }
+
+ if (newObj.value) {
+ newObj.value = newObj.value.trim().replace(/^['"]|['"]$/g, "");
+ delete newObj.quoted;
+ }
+ }
+
+ if ((ast.type === "media-value" || ast.type === "media-type" || ast.type === "value-number" || ast.type === "selector-root-invalid" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "selector-tag") && newObj.value) {
+ newObj.value = newObj.value.replace(/([\d.eE+-]+)([a-zA-Z]*)/g, (match, numStr, unit) => {
+ const num = Number(numStr);
+ return isNaN(num) ? match : num + unit.toLowerCase();
+ });
+ }
+
+ if (ast.type === "selector-tag") {
+ const lowercasedValue = ast.value.toLowerCase();
+
+ if (["from", "to"].includes(lowercasedValue)) {
+ newObj.value = lowercasedValue;
+ }
+ } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
+
+
+ if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
+ delete newObj.value;
+ } // Workaround for SCSS nested properties
+
+
+ if (ast.type === "selector-unknown") {
+ delete newObj.value;
+ }
+}
+
+function cleanCSSStrings(value) {
+ return value.replace(/'/g, '"').replace(/\\([^a-fA-F\d])/g, "$1");
+}
+
+var clean_1$1 = clean$2;
+
+const {
+ builders: {
+ hardline: hardline$6,
+ literalline: literalline$3,
+ concat: concat$8,
+ markAsRoot: markAsRoot$1
+ },
+ utils: {
+ mapDoc: mapDoc$2
+ }
+} = document;
+
+function embed$1(path, print, textToDoc
+/*, options */
+) {
+ const node = path.getValue();
+
+ if (node.type === "yaml") {
+ return markAsRoot$1(concat$8(["---", hardline$6, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
+ parser: "yaml"
+ })) : "", "---", hardline$6]));
+ }
+
+ return null;
+
+ function replaceNewlinesWithLiterallines(doc) {
+ return mapDoc$2(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$8(currentDoc.split(/(\n)/g).map((v, i) => i % 2 === 0 ? v : literalline$3)) : currentDoc);
+ }
+}
+
+var embed_1$1 = embed$1;
+
+const DELIMITER_MAP = {
+ "---": "yaml",
+ "+++": "toml"
+};
+
+function parse$4(text) {
+ const delimiterRegex = Object.keys(DELIMITER_MAP).map(escapeStringRegexp$2).join("|");
+ const match = text.match( // trailing spaces after delimiters are allowed
+ new RegExp(`^(${delimiterRegex})[^\\n\\S]*\\n(?:([\\s\\S]*?)\\n)?\\1[^\\n\\S]*(\\n|$)`));
+
+ if (match === null) {
+ return {
+ frontMatter: null,
+ content: text
+ };
+ }
+
+ const [raw, delimiter, value] = match;
+ return {
+ frontMatter: {
+ type: DELIMITER_MAP[delimiter],
+ value,
+ raw: raw.replace(/\n$/, "")
+ },
+ content: raw.replace(/[^\n]/g, " ") + text.slice(raw.length)
+ };
+}
+
+var frontMatter = parse$4;
+
+function hasPragma$1(text) {
+ return pragma.hasPragma(frontMatter(text).content);
+}
+
+function insertPragma$2(text) {
+ const {
+ frontMatter: frontMatter$1,
+ content
+ } = frontMatter(text);
+ return (frontMatter$1 ? frontMatter$1.raw + "\n\n" : "") + pragma.insertPragma(content);
+}
+
+var pragma$1 = {
+ hasPragma: hasPragma$1,
+ insertPragma: insertPragma$2
+};
+
+var lineColumnToIndex = function (lineColumn, text) {
+ let index = 0;
+
+ for (let i = 0; i < lineColumn.line - 1; ++i) {
+ index = text.indexOf("\n", index) + 1;
+
+ if (index === -1) {
+ return -1;
+ }
+ }
+
+ return index + lineColumn.column;
+};
+
+const {
+ getLast: getLast$3,
+ skipEverythingButNewLine: skipEverythingButNewLine$2
+} = util$1;
+
+function calculateLocStart(node, text) {
+ if (node.source) {
+ return lineColumnToIndex(node.source.start, text) - 1;
+ }
+
+ return null;
+}
+
+function calculateLocEnd(node, text) {
+ if (node.type === "css-comment" && node.inline) {
+ return skipEverythingButNewLine$2(text, node.source.startOffset);
+ }
+
+ const endNode = node.nodes && getLast$3(node.nodes);
+
+ if (endNode && node.source && !node.source.end) {
+ node = endNode;
+ }
+
+ if (node.source && node.source.end) {
+ return lineColumnToIndex(node.source.end, text);
+ }
+
+ return null;
+}
+
+function calculateLoc(node, text) {
+ if (node && typeof node === "object") {
+ if (node.source) {
+ node.source.startOffset = calculateLocStart(node, text);
+ node.source.endOffset = calculateLocEnd(node, text);
+ }
+
+ for (const key in node) {
+ calculateLoc(node[key], text);
+ }
+ }
+}
+/**
+ * Workaround for a bug: quotes in inline comments corrupt loc data of subsequent nodes.
+ * This function replaces the quotes with U+FFFE and U+FFFF. Later, when the comments are printed,
+ * their content is extracted from the original text or restored by replacing the placeholder
+ * characters back with quotes.
+ * - https://github.com/prettier/prettier/issues/7780
+ * - https://github.com/shellscape/postcss-less/issues/145
+ * - About noncharacters (U+FFFE and U+FFFF): http://www.unicode.org/faq/private_use.html#nonchar1
+ * @param text {string}
+ */
+
+
+function replaceQuotesInInlineComments(text) {
+ /** @typedef { 'initial' | 'single-quotes' | 'double-quotes' | 'url' | 'comment-block' | 'comment-inline' } State */
+
+ /** @type {State} */
+ let state = "initial";
+ /** @type {State} */
+
+ let stateToReturnFromQuotes = "initial";
+ let inlineCommentStartIndex;
+ let inlineCommentContainsQuotes = false;
+ const inlineCommentsToReplace = [];
+
+ for (let i = 0; i < text.length; i++) {
+ const c = text[i];
+
+ switch (state) {
+ case "initial":
+ if (c === "'") {
+ state = "single-quotes";
+ continue;
+ }
+
+ if (c === '"') {
+ state = "double-quotes";
+ continue;
+ }
+
+ if ((c === "u" || c === "U") && text.slice(i, i + 4).toLowerCase() === "url(") {
+ state = "url";
+ i += 3;
+ continue;
+ }
+
+ if (c === "*" && text[i - 1] === "/") {
+ state = "comment-block";
+ continue;
+ }
+
+ if (c === "/" && text[i - 1] === "/") {
+ state = "comment-inline";
+ inlineCommentStartIndex = i - 1;
+ continue;
+ }
+
+ continue;
+
+ case "single-quotes":
+ if (c === "'" && text[i - 1] !== "\\") {
+ state = stateToReturnFromQuotes;
+ stateToReturnFromQuotes = "initial";
+ }
+
+ if (c === "\n" || c === "\r") {
+ return text; // invalid input
+ }
+
+ continue;
+
+ case "double-quotes":
+ if (c === '"' && text[i - 1] !== "\\") {
+ state = stateToReturnFromQuotes;
+ stateToReturnFromQuotes = "initial";
+ }
+
+ if (c === "\n" || c === "\r") {
+ return text; // invalid input
+ }
+
+ continue;
+
+ case "url":
+ if (c === ")") {
+ state = "initial";
+ }
+
+ if (c === "\n" || c === "\r") {
+ return text; // invalid input
+ }
+
+ if (c === "'") {
+ state = "single-quotes";
+ stateToReturnFromQuotes = "url";
+ continue;
+ }
+
+ if (c === '"') {
+ state = "double-quotes";
+ stateToReturnFromQuotes = "url";
+ continue;
+ }
+
+ continue;
+
+ case "comment-block":
+ if (c === "/" && text[i - 1] === "*") {
+ state = "initial";
+ }
+
+ continue;
+
+ case "comment-inline":
+ if (c === '"' || c === "'") {
+ inlineCommentContainsQuotes = true;
+ }
+
+ if (c === "\n" || c === "\r") {
+ if (inlineCommentContainsQuotes) {
+ inlineCommentsToReplace.push([inlineCommentStartIndex, i]);
+ }
+
+ state = "initial";
+ inlineCommentContainsQuotes = false;
+ }
+
+ continue;
+ }
+ }
+
+ for (const [start, end] of inlineCommentsToReplace) {
+ text = text.slice(0, start) + text.slice(start, end).replace(/'/g, "\ufffe").replace(/"/g, "\uffff") + text.slice(end);
+ }
+
+ return text;
+}
+
+function restoreQuotesInInlineComments(text) {
+ return text.replace(/\ufffe/g, "'").replace(/\uffff/g, '"');
+}
+
+var loc$1 = {
+ calculateLoc,
+ replaceQuotesInInlineComments,
+ restoreQuotesInInlineComments
+};
+
+const colorAdjusterFunctions = ["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"];
+
+function getAncestorCounter(path, typeOrTypes) {
+ const types = [].concat(typeOrTypes);
+ let counter = -1;
+ let ancestorNode;
+
+ while (ancestorNode = path.getParentNode(++counter)) {
+ if (types.includes(ancestorNode.type)) {
+ return counter;
+ }
+ }
+
+ return -1;
+}
+
+function getAncestorNode(path, typeOrTypes) {
+ const counter = getAncestorCounter(path, typeOrTypes);
+ return counter === -1 ? null : path.getParentNode(counter);
+}
+
+function getPropOfDeclNode(path) {
+ const declAncestorNode = getAncestorNode(path, "css-decl");
+ return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
+}
+
+function isSCSS(parser, text) {
+ const hasExplicitParserChoice = parser === "less" || parser === "scss";
+ const IS_POSSIBLY_SCSS = /(\w\s*:\s*[^}:]+|#){|@import[^\n]+(?:url|,)/;
+ return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
+}
+
+function isWideKeywords(value) {
+ return ["initial", "inherit", "unset", "revert"].includes(value.toLowerCase());
+}
+
+function isKeyframeAtRuleKeywords(path, value) {
+ const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
+ return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].includes(value.toLowerCase());
+}
+
+function maybeToLowerCase(value) {
+ return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
+}
+
+function insideValueFunctionNode(path, functionName) {
+ const funcAncestorNode = getAncestorNode(path, "value-func");
+ return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
+}
+
+function insideICSSRuleNode(path) {
+ const ruleAncestorNode = getAncestorNode(path, "css-rule");
+ return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
+}
+
+function insideAtRuleNode(path, atRuleNameOrAtRuleNames) {
+ const atRuleNames = [].concat(atRuleNameOrAtRuleNames);
+ const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
+ return atRuleAncestorNode && atRuleNames.includes(atRuleAncestorNode.name.toLowerCase());
+}
+
+function insideURLFunctionInImportAtRuleNode(path) {
+ const node = path.getValue();
+ const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
+ return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
+}
+
+function isURLFunctionNode(node) {
+ return node.type === "value-func" && node.value.toLowerCase() === "url";
+}
+
+function isLastNode(path, node) {
+ const parentNode = path.getParentNode();
+
+ if (!parentNode) {
+ return false;
+ }
+
+ const {
+ nodes
+ } = parentNode;
+ return nodes && nodes.indexOf(node) === nodes.length - 1;
+}
+
+function isDetachedRulesetDeclarationNode(node) {
+ // If a Less file ends up being parsed with the SCSS parser, Less
+ // variable declarations will be parsed as atrules with names ending
+ // with a colon, so keep the original case then.
+ if (!node.selector) {
+ return false;
+ }
+
+ return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
+}
+
+function isForKeywordNode(node) {
+ return node.type === "value-word" && ["from", "through", "end"].includes(node.value);
+}
+
+function isIfElseKeywordNode(node) {
+ return node.type === "value-word" && ["and", "or", "not"].includes(node.value);
+}
+
+function isEachKeywordNode(node) {
+ return node.type === "value-word" && node.value === "in";
+}
+
+function isMultiplicationNode(node) {
+ return node.type === "value-operator" && node.value === "*";
+}
+
+function isDivisionNode(node) {
+ return node.type === "value-operator" && node.value === "/";
+}
+
+function isAdditionNode(node) {
+ return node.type === "value-operator" && node.value === "+";
+}
+
+function isSubtractionNode(node) {
+ return node.type === "value-operator" && node.value === "-";
+}
+
+function isModuloNode(node) {
+ return node.type === "value-operator" && node.value === "%";
+}
+
+function isMathOperatorNode(node) {
+ return isMultiplicationNode(node) || isDivisionNode(node) || isAdditionNode(node) || isSubtractionNode(node) || isModuloNode(node);
+}
+
+function isEqualityOperatorNode(node) {
+ return node.type === "value-word" && ["==", "!="].includes(node.value);
+}
+
+function isRelationalOperatorNode(node) {
+ return node.type === "value-word" && ["<", ">", "<=", ">="].includes(node.value);
+}
+
+function isSCSSControlDirectiveNode(node) {
+ return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].includes(node.name);
+}
+
+function isSCSSNestedPropertyNode(node) {
+ if (!node.selector) {
+ return false;
+ }
+
+ return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
+}
+
+function isDetachedRulesetCallNode(node) {
+ return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
+}
+
+function isTemplatePlaceholderNode(node) {
+ return node.name.startsWith("prettier-placeholder");
+}
+
+function isTemplatePropNode(node) {
+ return node.prop.startsWith("@prettier-placeholder");
+}
+
+function isPostcssSimpleVarNode(currentNode, nextNode) {
+ return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
+}
+
+function hasComposesNode(node) {
+ return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
+}
+
+function hasParensAroundNode(node) {
+ return node.value && node.value.group && node.value.group.group && node.value.group.group.type === "value-paren_group" && node.value.group.group.open !== null && node.value.group.group.close !== null;
+}
+
+function hasEmptyRawBefore(node) {
+ return node.raws && node.raws.before === "";
+}
+
+function isKeyValuePairNode(node) {
+ return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
+}
+
+function isKeyValuePairInParenGroupNode(node) {
+ return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode(node.groups[0]);
+}
+
+function isSCSSMapItemNode(path) {
+ const node = path.getValue(); // Ignore empty item (i.e. `$key: ()`)
+
+ if (node.groups.length === 0) {
+ return false;
+ }
+
+ const parentParentNode = path.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
+
+ if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
+ return false;
+ }
+
+ const declNode = getAncestorNode(path, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
+
+ if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
+ return true;
+ } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
+
+
+ if (isKeyValuePairInParenGroupNode(parentParentNode)) {
+ return true;
+ } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
+
+
+ if (parentParentNode.type === "value-func") {
+ return true;
+ }
+
+ return false;
+}
+
+function isInlineValueCommentNode(node) {
+ return node.type === "value-comment" && node.inline;
+}
+
+function isHashNode(node) {
+ return node.type === "value-word" && node.value === "#";
+}
+
+function isLeftCurlyBraceNode(node) {
+ return node.type === "value-word" && node.value === "{";
+}
+
+function isRightCurlyBraceNode(node) {
+ return node.type === "value-word" && node.value === "}";
+}
+
+function isWordNode(node) {
+ return ["value-word", "value-atword"].includes(node.type);
+}
+
+function isColonNode(node) {
+ return node.type === "value-colon";
+}
+
+function isMediaAndSupportsKeywords(node) {
+ return node.value && ["not", "and", "or"].includes(node.value.toLowerCase());
+}
+
+function isColorAdjusterFuncNode(node) {
+ if (node.type !== "value-func") {
+ return false;
+ }
+
+ return colorAdjusterFunctions.includes(node.value.toLowerCase());
+} // TODO: only check `less` when we don't use `less` to parse `css`
+
+
+function isLessParser(options) {
+ return options.parser === "css" || options.parser === "less";
+}
+
+function lastLineHasInlineComment(text) {
+ return /\/\//.test(text.split(/[\r\n]/).pop());
+}
+
+var utils$7 = {
+ getAncestorCounter,
+ getAncestorNode,
+ getPropOfDeclNode,
+ maybeToLowerCase,
+ insideValueFunctionNode,
+ insideICSSRuleNode,
+ insideAtRuleNode,
+ insideURLFunctionInImportAtRuleNode,
+ isKeyframeAtRuleKeywords,
+ isWideKeywords,
+ isSCSS,
+ isLastNode,
+ isLessParser,
+ isSCSSControlDirectiveNode,
+ isDetachedRulesetDeclarationNode,
+ isRelationalOperatorNode,
+ isEqualityOperatorNode,
+ isMultiplicationNode,
+ isDivisionNode,
+ isAdditionNode,
+ isSubtractionNode,
+ isModuloNode,
+ isMathOperatorNode,
+ isEachKeywordNode,
+ isForKeywordNode,
+ isURLFunctionNode,
+ isIfElseKeywordNode,
+ hasComposesNode,
+ hasParensAroundNode,
+ hasEmptyRawBefore,
+ isSCSSNestedPropertyNode,
+ isDetachedRulesetCallNode,
+ isTemplatePlaceholderNode,
+ isTemplatePropNode,
+ isPostcssSimpleVarNode,
+ isKeyValuePairNode,
+ isKeyValuePairInParenGroupNode,
+ isSCSSMapItemNode,
+ isInlineValueCommentNode,
+ isHashNode,
+ isLeftCurlyBraceNode,
+ isRightCurlyBraceNode,
+ isWordNode,
+ isColonNode,
+ isMediaAndSupportsKeywords,
+ isColorAdjusterFuncNode,
+ lastLineHasInlineComment
+};
+
+const {
+ insertPragma: insertPragma$3
+} = pragma$1;
+const {
+ printNumber: printNumber$2,
+ printString: printString$2,
+ hasIgnoreComment: hasIgnoreComment$3,
+ hasNewline: hasNewline$5
+} = util$1;
+const {
+ isNextLineEmpty: isNextLineEmpty$3
+} = utilShared;
+const {
+ restoreQuotesInInlineComments: restoreQuotesInInlineComments$1
+} = loc$1;
+const {
+ builders: {
+ concat: concat$9,
+ join: join$6,
+ line: line$5,
+ hardline: hardline$7,
+ softline: softline$3,
+ group: group$6,
+ fill: fill$4,
+ indent: indent$5,
+ dedent: dedent$2,
+ ifBreak: ifBreak$2
+ },
+ utils: {
+ removeLines: removeLines$2
+ }
+} = document;
+const {
+ getAncestorNode: getAncestorNode$1,
+ getPropOfDeclNode: getPropOfDeclNode$1,
+ maybeToLowerCase: maybeToLowerCase$1,
+ insideValueFunctionNode: insideValueFunctionNode$1,
+ insideICSSRuleNode: insideICSSRuleNode$1,
+ insideAtRuleNode: insideAtRuleNode$1,
+ insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
+ isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
+ isWideKeywords: isWideKeywords$1,
+ isSCSS: isSCSS$1,
+ isLastNode: isLastNode$1,
+ isLessParser: isLessParser$1,
+ isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
+ isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
+ isRelationalOperatorNode: isRelationalOperatorNode$1,
+ isEqualityOperatorNode: isEqualityOperatorNode$1,
+ isMultiplicationNode: isMultiplicationNode$1,
+ isDivisionNode: isDivisionNode$1,
+ isAdditionNode: isAdditionNode$1,
+ isSubtractionNode: isSubtractionNode$1,
+ isMathOperatorNode: isMathOperatorNode$1,
+ isEachKeywordNode: isEachKeywordNode$1,
+ isForKeywordNode: isForKeywordNode$1,
+ isURLFunctionNode: isURLFunctionNode$1,
+ isIfElseKeywordNode: isIfElseKeywordNode$1,
+ hasComposesNode: hasComposesNode$1,
+ hasParensAroundNode: hasParensAroundNode$1,
+ hasEmptyRawBefore: hasEmptyRawBefore$1,
+ isKeyValuePairNode: isKeyValuePairNode$1,
+ isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
+ isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
+ isTemplatePropNode: isTemplatePropNode$1,
+ isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
+ isSCSSMapItemNode: isSCSSMapItemNode$1,
+ isInlineValueCommentNode: isInlineValueCommentNode$1,
+ isHashNode: isHashNode$1,
+ isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
+ isRightCurlyBraceNode: isRightCurlyBraceNode$1,
+ isWordNode: isWordNode$1,
+ isColonNode: isColonNode$1,
+ isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
+ isColorAdjusterFuncNode: isColorAdjusterFuncNode$1,
+ lastLineHasInlineComment: lastLineHasInlineComment$1
+} = utils$7;
+
+function shouldPrintComma$1(options) {
+ switch (options.trailingComma) {
+ case "all":
+ case "es5":
+ return true;
+
+ case "none":
+ default:
+ return false;
+ }
+}
+
+function genericPrint$2(path, options, print) {
+ const node = path.getValue();
+ /* istanbul ignore if */
+
+ if (!node) {
+ return "";
+ }
+
+ if (typeof node === "string") {
+ return node;
+ }
+
+ switch (node.type) {
+ case "yaml":
+ case "toml":
+ return concat$9([node.raw, hardline$7]);
+
+ case "css-root":
+ {
+ const nodes = printNodeSequence(path, options, print);
+
+ if (nodes.parts.length) {
+ return concat$9([nodes, options.__isHTMLStyleAttribute ? "" : hardline$7]);
+ }
+
+ return nodes;
+ }
+
+ case "css-comment":
+ {
+ const isInlineComment = node.inline || node.raws.inline;
+ const text = options.originalText.slice(options.locStart(node), options.locEnd(node));
+ return isInlineComment ? text.trimEnd() : text;
+ }
+
+ case "css-rule":
+ {
+ return concat$9([path.call(print, "selector"), node.important ? " !important" : "", node.nodes ? concat$9([node.selector && node.selector.type === "selector-unknown" && lastLineHasInlineComment$1(node.selector.value) ? line$5 : " ", "{", node.nodes.length > 0 ? indent$5(concat$9([hardline$7, printNodeSequence(path, options, print)])) : "", hardline$7, "}", isDetachedRulesetDeclarationNode$1(node) ? ";" : ""]) : ";"]);
+ }
+
+ case "css-decl":
+ {
+ const parentNode = path.getParentNode();
+ return concat$9([node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode$1(path) ? node.prop : maybeToLowerCase$1(node.prop), node.raws.between.trim() === ":" ? ":" : node.raws.between.trim(), node.extend ? "" : " ", hasComposesNode$1(node) ? removeLines$2(path.call(print, "value")) : path.call(print, "value"), node.raws.important ? node.raws.important.replace(/\s*!\s*important/i, " !important") : node.important ? " !important" : "", node.raws.scssDefault ? node.raws.scssDefault.replace(/\s*!default/i, " !default") : node.scssDefault ? " !default" : "", node.raws.scssGlobal ? node.raws.scssGlobal.replace(/\s*!global/i, " !global") : node.scssGlobal ? " !global" : "", node.nodes ? concat$9([" {", indent$5(concat$9([softline$3, printNodeSequence(path, options, print)])), softline$3, "}"]) : isTemplatePropNode$1(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
+ }
+
+ case "css-atrule":
+ {
+ const parentNode = path.getParentNode();
+ const isTemplatePlaceholderNodeWithoutSemiColon = isTemplatePlaceholderNode$1(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";";
+
+ if (isLessParser$1(options)) {
+ if (node.mixin) {
+ return concat$9([path.call(print, "selector"), node.important ? " !important" : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
+ }
+
+ if (node.function) {
+ return concat$9([node.name, concat$9([path.call(print, "params")]), isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
+ }
+
+ if (node.variable) {
+ return concat$9(["@", node.name, ": ", node.value ? concat$9([path.call(print, "value")]) : "", node.raws.between.trim() ? node.raws.between.trim() + " " : "", node.nodes ? concat$9(["{", indent$5(concat$9([node.nodes.length > 0 ? softline$3 : "", printNodeSequence(path, options, print)])), softline$3, "}"]) : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
+ }
+ }
+
+ return concat$9(["@", // If a Less file ends up being parsed with the SCSS parser, Less
+ // variable declarations will be parsed as at-rules with names ending
+ // with a colon, so keep the original case then.
+ isDetachedRulesetCallNode$1(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase$1(node.name), node.params ? concat$9([isDetachedRulesetCallNode$1(node) ? "" : isTemplatePlaceholderNode$1(node) ? node.raws.afterName === "" ? "" : node.name.endsWith(":") ? " " : /^\s*\n\s*\n/.test(node.raws.afterName) ? concat$9([hardline$7, hardline$7]) : /^\s*\n/.test(node.raws.afterName) ? hardline$7 : " " : " ", path.call(print, "params")]) : "", node.selector ? indent$5(concat$9([" ", path.call(print, "selector")])) : "", node.value ? group$6(concat$9([" ", path.call(print, "value"), isSCSSControlDirectiveNode$1(node) ? hasParensAroundNode$1(node) ? " " : line$5 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$9([isSCSSControlDirectiveNode$1(node) ? "" : " ", "{", indent$5(concat$9([node.nodes.length > 0 ? softline$3 : "", printNodeSequence(path, options, print)])), softline$3, "}"]) : isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
+ }
+ // postcss-media-query-parser
+
+ case "media-query-list":
+ {
+ const parts = [];
+ path.each(childPath => {
+ const node = childPath.getValue();
+
+ if (node.type === "media-query" && node.value === "") {
+ return;
+ }
+
+ parts.push(childPath.call(print));
+ }, "nodes");
+ return group$6(indent$5(join$6(line$5, parts)));
+ }
+
+ case "media-query":
+ {
+ return concat$9([join$6(" ", path.map(print, "nodes")), isLastNode$1(path, node) ? "" : ","]);
+ }
+
+ case "media-type":
+ {
+ return adjustNumbers(adjustStrings(node.value, options));
+ }
+
+ case "media-feature-expression":
+ {
+ if (!node.nodes) {
+ return node.value;
+ }
+
+ return concat$9(["(", concat$9(path.map(print, "nodes")), ")"]);
+ }
+
+ case "media-feature":
+ {
+ return maybeToLowerCase$1(adjustStrings(node.value.replace(/ +/g, " "), options));
+ }
+
+ case "media-colon":
+ {
+ return concat$9([node.value, " "]);
+ }
+
+ case "media-value":
+ {
+ return adjustNumbers(adjustStrings(node.value, options));
+ }
+
+ case "media-keyword":
+ {
+ return adjustStrings(node.value, options);
+ }
+
+ case "media-url":
+ {
+ return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/gi, ")"), options);
+ }
+
+ case "media-unknown":
+ {
+ return node.value;
+ }
+ // postcss-selector-parser
+
+ case "selector-root":
+ {
+ return group$6(concat$9([insideAtRuleNode$1(path, "custom-selector") ? concat$9([getAncestorNode$1(path, "css-atrule").customSelector, line$5]) : "", join$6(concat$9([",", insideAtRuleNode$1(path, ["extend", "custom-selector", "nest"]) ? line$5 : hardline$7]), path.map(print, "nodes"))]));
+ }
+
+ case "selector-selector":
+ {
+ return group$6(indent$5(concat$9(path.map(print, "nodes"))));
+ }
+
+ case "selector-comment":
+ {
+ return node.value;
+ }
+
+ case "selector-string":
+ {
+ return adjustStrings(node.value, options);
+ }
+
+ case "selector-tag":
+ {
+ const parentNode = path.getParentNode();
+ const index = parentNode && parentNode.nodes.indexOf(node);
+ const prevNode = index && parentNode.nodes[index - 1];
+ return concat$9([node.namespace ? concat$9([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isKeyframeAtRuleKeywords$1(path, node.value) ? node.value.toLowerCase() : node.value)]);
+ }
+
+ case "selector-id":
+ {
+ return concat$9(["#", node.value]);
+ }
+
+ case "selector-class":
+ {
+ return concat$9([".", adjustNumbers(adjustStrings(node.value, options))]);
+ }
+
+ case "selector-attribute":
+ {
+ return concat$9(["[", node.namespace ? concat$9([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.attribute.trim(), node.operator ? node.operator : "", node.value ? quoteAttributeValue(adjustStrings(node.value.trim(), options), options) : "", node.insensitive ? " i" : "", "]"]);
+ }
+
+ case "selector-combinator":
+ {
+ if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
+ const parentNode = path.getParentNode();
+ const leading = parentNode.type === "selector-selector" && parentNode.nodes[0] === node ? "" : line$5;
+ return concat$9([leading, node.value, isLastNode$1(path, node) ? "" : " "]);
+ }
+
+ const leading = node.value.trim().startsWith("(") ? line$5 : "";
+ const value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$5;
+ return concat$9([leading, value]);
+ }
+
+ case "selector-universal":
+ {
+ return concat$9([node.namespace ? concat$9([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.value]);
+ }
+
+ case "selector-pseudo":
+ {
+ return concat$9([maybeToLowerCase$1(node.value), node.nodes && node.nodes.length > 0 ? concat$9(["(", join$6(", ", path.map(print, "nodes")), ")"]) : ""]);
+ }
+
+ case "selector-nesting":
+ {
+ return node.value;
+ }
+
+ case "selector-unknown":
+ {
+ const ruleAncestorNode = getAncestorNode$1(path, "css-rule"); // Nested SCSS property
+
+ if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
+ return adjustNumbers(adjustStrings(maybeToLowerCase$1(node.value), options));
+ } // originalText has to be used for Less, see replaceQuotesInInlineComments in loc.js
+
+
+ const parentNode = path.getParentNode();
+
+ if (parentNode.raws && parentNode.raws.selector) {
+ const start = options.locStart(parentNode);
+ const end = start + parentNode.raws.selector.length;
+ return options.originalText.slice(start, end).trim();
+ }
+
+ return node.value;
+ }
+ // postcss-values-parser
+
+ case "value-value":
+ case "value-root":
+ {
+ return path.call(print, "group");
+ }
+
+ case "value-comment":
+ {
+ return concat$9([node.inline ? "//" : "/*", // see replaceQuotesInInlineComments in loc.js
+ // value-* nodes don't have correct location data, so we have to rely on placeholder characters.
+ restoreQuotesInInlineComments$1(node.value), node.inline ? "" : "*/"]);
+ }
+
+ case "value-comma_group":
+ {
+ const parentNode = path.getParentNode();
+ const parentParentNode = path.getParentNode(1);
+ const declAncestorProp = getPropOfDeclNode$1(path);
+ const isGridValue = declAncestorProp && parentNode.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
+ const atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
+ const isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode$1(atRuleAncestorNode);
+ const printed = path.map(print, "groups");
+ const parts = [];
+ const insideURLFunction = insideValueFunctionNode$1(path, "url");
+ let insideSCSSInterpolationInString = false;
+ let didBreak = false;
+
+ for (let i = 0; i < node.groups.length; ++i) {
+ parts.push(printed[i]);
+ const iPrevNode = node.groups[i - 1];
+ const iNode = node.groups[i];
+ const iNextNode = node.groups[i + 1];
+ const iNextNextNode = node.groups[i + 2];
+
+ if (insideURLFunction) {
+ if (iNextNode && isAdditionNode$1(iNextNode) || isAdditionNode$1(iNode)) {
+ parts.push(" ");
+ }
+
+ continue;
+ } // Ignore after latest node (i.e. before semicolon)
+
+
+ if (!iNextNode) {
+ continue;
+ } // styled.div` background: var(--${one}); `
+
+
+ if (!iPrevNode && iNode.value === "--" && iNextNode.type === "value-atword") {
+ continue;
+ } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
+
+
+ const isStartSCSSInterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
+ const isEndingSCSSInterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
+
+ if (isStartSCSSInterpolationInString || isEndingSCSSInterpolationInString) {
+ insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
+ continue;
+ }
+
+ if (insideSCSSInterpolationInString) {
+ continue;
+ } // Ignore colon (i.e. `:`)
+
+
+ if (isColonNode$1(iNode) || isColonNode$1(iNextNode)) {
+ continue;
+ } // Ignore `@` in Less (i.e. `@@var;`)
+
+
+ if (iNode.type === "value-atword" && iNode.value === "") {
+ continue;
+ } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
+
+
+ if (iNode.value === "~") {
+ continue;
+ } // Ignore escape `\`
+
+
+ if (iNode.value && iNode.value.includes("\\") && iNextNode && iNextNode.type !== "value-comment") {
+ continue;
+ } // Ignore escaped `/`
+
+
+ if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
+ continue;
+ } // Ignore `\` (i.e. `$variable: \@small;`)
+
+
+ if (iNode.value === "\\") {
+ continue;
+ } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
+
+
+ if (isPostcssSimpleVarNode$1(iNode, iNextNode)) {
+ continue;
+ } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
+
+
+ if (isHashNode$1(iNode) || isLeftCurlyBraceNode$1(iNode) || isRightCurlyBraceNode$1(iNextNode) || isLeftCurlyBraceNode$1(iNextNode) && hasEmptyRawBefore$1(iNextNode) || isRightCurlyBraceNode$1(iNode) && hasEmptyRawBefore$1(iNextNode)) {
+ continue;
+ } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
+
+
+ if (iNode.value === "--" && isHashNode$1(iNextNode)) {
+ continue;
+ } // Formatting math operations
+
+
+ const isMathOperator = isMathOperatorNode$1(iNode);
+ const isNextMathOperator = isMathOperatorNode$1(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
+ // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
+ // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
+
+ if ((isMathOperator && isHashNode$1(iNextNode) || isNextMathOperator && isRightCurlyBraceNode$1(iNode)) && hasEmptyRawBefore$1(iNextNode)) {
+ continue;
+ } // Print spaces before and after addition and subtraction math operators as is in `calc` function
+ // due to the fact that it is not valid syntax
+ // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
+
+
+ if (insideValueFunctionNode$1(path, "calc") && (isAdditionNode$1(iNode) || isAdditionNode$1(iNextNode) || isSubtractionNode$1(iNode) || isSubtractionNode$1(iNextNode)) && hasEmptyRawBefore$1(iNextNode)) {
+ continue;
+ } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
+ // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
+
+
+ const isColorAdjusterNode = (isAdditionNode$1(iNode) || isSubtractionNode$1(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode$1(parentParentNode) && !hasEmptyRawBefore$1(iNextNode);
+ const requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode$1(iNextNextNode) || iNode.type === "value-func" || isWordNode$1(iNode);
+ const requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode$1(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode$1(iPrevNode); // Formatting `/`, `+`, `-` sign
+
+ if (!(isMultiplicationNode$1(iNextNode) || isMultiplicationNode$1(iNode)) && !insideValueFunctionNode$1(path, "calc") && !isColorAdjusterNode && (isDivisionNode$1(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode$1(iNode) && !requireSpaceAfterOperator || isAdditionNode$1(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode$1(iNode) && !requireSpaceAfterOperator || isSubtractionNode$1(iNextNode) || isSubtractionNode$1(iNode)) && (hasEmptyRawBefore$1(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode$1(iPrevNode)))) {
+ continue;
+ } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
+
+
+ if (isInlineValueCommentNode$1(iNode)) {
+ parts.push(hardline$7);
+ continue;
+ } // Handle keywords in SCSS control directive
+
+
+ if (isControlDirective && (isEqualityOperatorNode$1(iNextNode) || isRelationalOperatorNode$1(iNextNode) || isIfElseKeywordNode$1(iNextNode) || isEachKeywordNode$1(iNode) || isForKeywordNode$1(iNode))) {
+ parts.push(" ");
+ continue;
+ } // At-rule `namespace` should be in one line
+
+
+ if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
+ parts.push(" ");
+ continue;
+ } // Formatting `grid` property
+
+
+ if (isGridValue) {
+ if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
+ parts.push(hardline$7);
+ didBreak = true;
+ } else {
+ parts.push(" ");
+ }
+
+ continue;
+ } // Add `space` before next math operation
+ // Note: `grip` property have `/` delimiter and it is not math operation, so
+ // `grid` property handles above
+
+
+ if (isNextMathOperator) {
+ parts.push(" ");
+ continue;
+ } // Be default all values go through `line`
+
+
+ parts.push(line$5);
+ }
+
+ if (didBreak) {
+ parts.unshift(hardline$7);
+ }
+
+ if (isControlDirective) {
+ return group$6(indent$5(concat$9(parts)));
+ } // Indent is not needed for import url when url is very long
+ // and node has two groups
+ // when type is value-comma_group
+ // example @import url("verylongurl") projection,tv
+
+
+ if (insideURLFunctionInImportAtRuleNode$1(path)) {
+ return group$6(fill$4(parts));
+ }
+
+ return group$6(indent$5(fill$4(parts)));
+ }
+
+ case "value-paren_group":
+ {
+ const parentNode = path.getParentNode();
+
+ if (parentNode && isURLFunctionNode$1(parentNode) && (node.groups.length === 1 || node.groups.length > 0 && node.groups[0].type === "value-comma_group" && node.groups[0].groups.length > 0 && node.groups[0].groups[0].type === "value-word" && node.groups[0].groups[0].value.startsWith("data:"))) {
+ return concat$9([node.open ? path.call(print, "open") : "", join$6(",", path.map(print, "groups")), node.close ? path.call(print, "close") : ""]);
+ }
+
+ if (!node.open) {
+ const printed = path.map(print, "groups");
+ const res = [];
+
+ for (let i = 0; i < printed.length; i++) {
+ if (i !== 0) {
+ res.push(concat$9([",", line$5]));
+ }
+
+ res.push(printed[i]);
+ }
+
+ return group$6(indent$5(fill$4(res)));
+ }
+
+ const isSCSSMapItem = isSCSSMapItemNode$1(path);
+ const lastItem = node.groups[node.groups.length - 1];
+ const isLastItemComment = lastItem && lastItem.type === "value-comment";
+ return group$6(concat$9([node.open ? path.call(print, "open") : "", indent$5(concat$9([softline$3, join$6(concat$9([",", line$5]), path.map(childPath => {
+ const node = childPath.getValue();
+ const printed = print(childPath); // Key/Value pair in open paren already indented
+
+ if (isKeyValuePairNode$1(node) && node.type === "value-comma_group" && node.groups && node.groups[2] && node.groups[2].type === "value-paren_group") {
+ printed.contents.contents.parts[1] = group$6(printed.contents.contents.parts[1]);
+ return group$6(dedent$2(printed));
+ }
+
+ return printed;
+ }, "groups"))])), ifBreak$2(!isLastItemComment && isSCSS$1(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma$1(options) ? "," : ""), softline$3, node.close ? path.call(print, "close") : ""]), {
+ shouldBreak: isSCSSMapItem
+ });
+ }
+
+ case "value-func":
+ {
+ return concat$9([node.value, insideAtRuleNode$1(path, "supports") && isMediaAndSupportsKeywords$1(node) ? " " : "", path.call(print, "group")]);
+ }
+
+ case "value-paren":
+ {
+ return node.value;
+ }
+
+ case "value-number":
+ {
+ return concat$9([printCssNumber(node.value), maybeToLowerCase$1(node.unit)]);
+ }
+
+ case "value-operator":
+ {
+ return node.value;
+ }
+
+ case "value-word":
+ {
+ if (node.isColor && node.isHex || isWideKeywords$1(node.value)) {
+ return node.value.toLowerCase();
+ }
+
+ return node.value;
+ }
+
+ case "value-colon":
+ {
+ return concat$9([node.value, // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
+ insideValueFunctionNode$1(path, "url") ? "" : line$5]);
+ }
+
+ case "value-comma":
+ {
+ return concat$9([node.value, " "]);
+ }
+
+ case "value-string":
+ {
+ return printString$2(node.raws.quote + node.value + node.raws.quote, options);
+ }
+
+ case "value-atword":
+ {
+ return concat$9(["@", node.value]);
+ }
+
+ case "value-unicode-range":
+ {
+ return node.value;
+ }
+
+ case "value-unknown":
+ {
+ return node.value;
+ }
+
+ default:
+ /* istanbul ignore next */
+ throw new Error(`Unknown postcss type ${JSON.stringify(node.type)}`);
+ }
+}
+
+function printNodeSequence(path, options, print) {
+ const node = path.getValue();
+ const parts = [];
+ let i = 0;
+ path.map(pathChild => {
+ const prevNode = node.nodes[i - 1];
+
+ if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
+ const childNode = pathChild.getValue();
+ parts.push(options.originalText.slice(options.locStart(childNode), options.locEnd(childNode)));
+ } else {
+ parts.push(pathChild.call(print));
+ }
+
+ if (i !== node.nodes.length - 1) {
+ if (node.nodes[i + 1].type === "css-comment" && !hasNewline$5(options.originalText, options.locStart(node.nodes[i + 1]), {
+ backwards: true
+ }) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml" || node.nodes[i + 1].type === "css-atrule" && node.nodes[i + 1].name === "else" && node.nodes[i].type !== "css-comment") {
+ parts.push(" ");
+ } else {
+ parts.push(options.__isHTMLStyleAttribute ? line$5 : hardline$7);
+
+ if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), options.locEnd) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml") {
+ parts.push(hardline$7);
+ }
+ }
+ }
+
+ i++;
+ }, "nodes");
+ return concat$9(parts);
+}
+
+const STRING_REGEX$3 = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g;
+const NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g;
+const STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
+const WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
+const ADJUST_NUMBERS_REGEX = new RegExp(STRING_REGEX$3.source + "|" + `(${WORD_PART_REGEX.source})?` + `(${NUMBER_REGEX.source})` + `(${STANDARD_UNIT_REGEX.source})?`, "g");
+
+function adjustStrings(value, options) {
+ return value.replace(STRING_REGEX$3, match => printString$2(match, options));
+}
+
+function quoteAttributeValue(value, options) {
+ const quote = options.singleQuote ? "'" : '"';
+ return value.includes('"') || value.includes("'") ? value : quote + value + quote;
+}
+
+function adjustNumbers(value) {
+ return value.replace(ADJUST_NUMBERS_REGEX, (match, quote, wordPart, number, unit) => !wordPart && number ? printCssNumber(number) + maybeToLowerCase$1(unit || "") : match);
+}
+
+function printCssNumber(rawNumber) {
+ return printNumber$2(rawNumber) // Remove trailing `.0`.
+ .replace(/\.0(?=$|e)/, "");
+}
+
+var printerPostcss = {
+ print: genericPrint$2,
+ embed: embed_1$1,
+ insertPragma: insertPragma$3,
+ hasPrettierIgnore: hasIgnoreComment$3,
+ massageAstNode: clean_1$1
+};
+
+var options$3 = {
+ singleQuote: commonOptions.singleQuote
+};
+
+var name$9 = "CSS";
+var type$7 = "markup";
+var tmScope$7 = "source.css";
+var aceMode$7 = "css";
+var codemirrorMode$7 = "css";
+var codemirrorMimeType$7 = "text/css";
+var color$2 = "#563d7c";
+var extensions$7 = [
+ ".css"
+];
+var languageId$7 = 50;
+var CSS = {
+ name: name$9,
+ type: type$7,
+ tmScope: tmScope$7,
+ aceMode: aceMode$7,
+ codemirrorMode: codemirrorMode$7,
+ codemirrorMimeType: codemirrorMimeType$7,
+ color: color$2,
+ extensions: extensions$7,
+ languageId: languageId$7
+};
+
+var CSS$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$9,
+ type: type$7,
+ tmScope: tmScope$7,
+ aceMode: aceMode$7,
+ codemirrorMode: codemirrorMode$7,
+ codemirrorMimeType: codemirrorMimeType$7,
+ color: color$2,
+ extensions: extensions$7,
+ languageId: languageId$7,
+ 'default': CSS
+});
+
+var name$a = "PostCSS";
+var type$8 = "markup";
+var tmScope$8 = "source.postcss";
+var group$7 = "CSS";
+var extensions$8 = [
+ ".pcss",
+ ".postcss"
+];
+var aceMode$8 = "text";
+var languageId$8 = 262764437;
+var PostCSS = {
+ name: name$a,
+ type: type$8,
+ tmScope: tmScope$8,
+ group: group$7,
+ extensions: extensions$8,
+ aceMode: aceMode$8,
+ languageId: languageId$8
+};
+
+var PostCSS$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$a,
+ type: type$8,
+ tmScope: tmScope$8,
+ group: group$7,
+ extensions: extensions$8,
+ aceMode: aceMode$8,
+ languageId: languageId$8,
+ 'default': PostCSS
+});
+
+var name$b = "Less";
+var type$9 = "markup";
+var group$8 = "CSS";
+var extensions$9 = [
+ ".less"
+];
+var tmScope$9 = "source.css.less";
+var aceMode$9 = "less";
+var codemirrorMode$8 = "css";
+var codemirrorMimeType$8 = "text/css";
+var languageId$9 = 198;
+var Less = {
+ name: name$b,
+ type: type$9,
+ group: group$8,
+ extensions: extensions$9,
+ tmScope: tmScope$9,
+ aceMode: aceMode$9,
+ codemirrorMode: codemirrorMode$8,
+ codemirrorMimeType: codemirrorMimeType$8,
+ languageId: languageId$9
+};
+
+var Less$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$b,
+ type: type$9,
+ group: group$8,
+ extensions: extensions$9,
+ tmScope: tmScope$9,
+ aceMode: aceMode$9,
+ codemirrorMode: codemirrorMode$8,
+ codemirrorMimeType: codemirrorMimeType$8,
+ languageId: languageId$9,
+ 'default': Less
+});
+
+var name$c = "SCSS";
+var type$a = "markup";
+var tmScope$a = "source.css.scss";
+var group$9 = "CSS";
+var aceMode$a = "scss";
+var codemirrorMode$9 = "css";
+var codemirrorMimeType$9 = "text/x-scss";
+var extensions$a = [
+ ".scss"
+];
+var languageId$a = 329;
+var SCSS = {
+ name: name$c,
+ type: type$a,
+ tmScope: tmScope$a,
+ group: group$9,
+ aceMode: aceMode$a,
+ codemirrorMode: codemirrorMode$9,
+ codemirrorMimeType: codemirrorMimeType$9,
+ extensions: extensions$a,
+ languageId: languageId$a
+};
+
+var SCSS$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$c,
+ type: type$a,
+ tmScope: tmScope$a,
+ group: group$9,
+ aceMode: aceMode$a,
+ codemirrorMode: codemirrorMode$9,
+ codemirrorMimeType: codemirrorMimeType$9,
+ extensions: extensions$a,
+ languageId: languageId$a,
+ 'default': SCSS
+});
+
+var require$$0$2 = getCjsExportFromNamespace(CSS$1);
+
+var require$$1$2 = getCjsExportFromNamespace(PostCSS$1);
+
+var require$$2$1 = getCjsExportFromNamespace(Less$1);
+
+var require$$3$1 = getCjsExportFromNamespace(SCSS$1);
+
+const languages$1 = [createLanguage(require$$0$2, () => ({
+ since: "1.4.0",
+ parsers: ["css"],
+ vscodeLanguageIds: ["css"]
+})), createLanguage(require$$1$2, () => ({
+ since: "1.4.0",
+ parsers: ["css"],
+ vscodeLanguageIds: ["postcss"]
+})), createLanguage(require$$2$1, () => ({
+ since: "1.4.0",
+ parsers: ["less"],
+ vscodeLanguageIds: ["less"]
+})), createLanguage(require$$3$1, () => ({
+ since: "1.4.0",
+ parsers: ["scss"],
+ vscodeLanguageIds: ["scss"]
+}))];
+const printers$1 = {
+ postcss: printerPostcss
+};
+var languageCss = {
+ languages: languages$1,
+ options: options$3,
+ printers: printers$1
+};
+
+var clean$3 = function (ast, newNode) {
+ delete newNode.loc;
+ delete newNode.selfClosing; // (Glimmer/HTML) ignore TextNode whitespace
+
+ if (ast.type === "TextNode") {
+ const trimmed = ast.chars.trim();
+
+ if (!trimmed) {
+ return null;
+ }
+
+ newNode.chars = trimmed;
+ }
+};
+
+function isUppercase(string) {
+ return string.toUpperCase() === string;
+}
+
+function isGlimmerComponent(node) {
+ return isNodeOfSomeType(node, ["ElementNode"]) && typeof node.tag === "string" && (isUppercase(node.tag[0]) || node.tag.includes("."));
+}
+
+function isWhitespaceNode(node) {
+ return isNodeOfSomeType(node, ["TextNode"]) && !/\S/.test(node.chars);
+}
+
+function isNodeOfSomeType(node, types) {
+ return node && types.some(type => node.type === type);
+}
+
+function isParentOfSomeType(path, types) {
+ const parentNode = path.getParentNode(0);
+ return isNodeOfSomeType(parentNode, types);
+}
+
+function isPreviousNodeOfSomeType(path, types) {
+ const previousNode = getPreviousNode(path);
+ return isNodeOfSomeType(previousNode, types);
+}
+
+function isNextNodeOfSomeType(path, types) {
+ const nextNode = getNextNode(path);
+ return isNodeOfSomeType(nextNode, types);
+}
+
+function getSiblingNode(path, offset) {
+ const node = path.getValue();
+ const parentNode = path.getParentNode(0) || {};
+ const children = parentNode.children || parentNode.body || [];
+ const index = children.indexOf(node);
+ return index !== -1 && children[index + offset];
+}
+
+function getPreviousNode(path, lookBack = 1) {
+ return getSiblingNode(path, -lookBack);
+}
+
+function getNextNode(path) {
+ return getSiblingNode(path, 1);
+}
+
+function isPrettierIgnoreNode(node) {
+ return isNodeOfSomeType(node, ["MustacheCommentStatement"]) && typeof node.value === "string" && node.value.trim() === "prettier-ignore";
+}
+
+function hasPrettierIgnore$2(path) {
+ const node = path.getValue();
+ const previousPreviousNode = getPreviousNode(path, 2);
+ return isPrettierIgnoreNode(node) || isPrettierIgnoreNode(previousPreviousNode);
+}
+
+var utils$8 = {
+ getNextNode,
+ getPreviousNode,
+ hasPrettierIgnore: hasPrettierIgnore$2,
+ isGlimmerComponent,
+ isNextNodeOfSomeType,
+ isNodeOfSomeType,
+ isParentOfSomeType,
+ isPreviousNodeOfSomeType,
+ isWhitespaceNode
+};
+
+const {
+ concat: concat$a,
+ join: join$7,
+ softline: softline$4,
+ hardline: hardline$8,
+ line: line$6,
+ group: group$a,
+ indent: indent$6,
+ ifBreak: ifBreak$3
+} = document.builders;
+const {
+ getNextNode: getNextNode$1,
+ getPreviousNode: getPreviousNode$1,
+ hasPrettierIgnore: hasPrettierIgnore$3,
+ isGlimmerComponent: isGlimmerComponent$1,
+ isNextNodeOfSomeType: isNextNodeOfSomeType$1,
+ isParentOfSomeType: isParentOfSomeType$1,
+ isPreviousNodeOfSomeType: isPreviousNodeOfSomeType$1,
+ isWhitespaceNode: isWhitespaceNode$1
+} = utils$8; // http://w3c.github.io/html/single-page.html#void-elements
+
+const voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]; // Formatter based on @glimmerjs/syntax's built-in test formatter:
+// https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
+
+function print(path, options, print) {
+ const n = path.getValue();
+ /* istanbul ignore if*/
+
+ if (!n) {
+ return "";
+ }
+
+ if (hasPrettierIgnore$3(path)) {
+ const startOffset = locationToOffset(options.originalText, n.loc.start.line - 1, n.loc.start.column);
+ const endOffset = locationToOffset(options.originalText, n.loc.end.line - 1, n.loc.end.column);
+ const ignoredText = options.originalText.slice(startOffset, endOffset);
+ return ignoredText;
+ }
+
+ switch (n.type) {
+ case "Block":
+ case "Program":
+ case "Template":
+ {
+ return group$a(concat$a(path.map(print, "body")));
+ }
+
+ case "ElementNode":
+ {
+ const hasChildren = n.children.length > 0;
+ const hasNonWhitespaceChildren = n.children.some(n => !isWhitespaceNode$1(n));
+ const isVoid = isGlimmerComponent$1(n) && (!hasChildren || !hasNonWhitespaceChildren) || voidTags.includes(n.tag);
+ const closeTagForNoBreak = isVoid ? concat$a([" />", softline$4]) : ">";
+ const closeTagForBreak = isVoid ? "/>" : ">";
+
+ const printParams = (path, print) => indent$6(concat$a([n.attributes.length ? line$6 : "", join$7(line$6, path.map(print, "attributes")), n.modifiers.length ? line$6 : "", join$7(line$6, path.map(print, "modifiers")), n.comments.length ? line$6 : "", join$7(line$6, path.map(print, "comments"))]));
+
+ const nextNode = getNextNode$1(path);
+ return concat$a([group$a(concat$a(["<", n.tag, printParams(path, print), n.blockParams.length ? ` as |${n.blockParams.join(" ")}|` : "", ifBreak$3(softline$4, ""), ifBreak$3(closeTagForBreak, closeTagForNoBreak)])), !isVoid ? group$a(concat$a([hasNonWhitespaceChildren ? indent$6(printChildren(path, options, print)) : "", ifBreak$3(hasChildren ? hardline$8 : "", ""), concat$a(["", n.tag, ">"])])) : "", nextNode && nextNode.type === "ElementNode" ? hardline$8 : ""]);
+ }
+
+ case "BlockStatement":
+ {
+ const pp = path.getParentNode(1);
+ const isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if";
+ const hasElseIf = n.inverse && n.inverse.body.length === 1 && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if";
+ const indentElse = hasElseIf ? a => a : indent$6;
+ const inverseElseStatement = (n.inverseStrip.open ? "{{~" : "{{") + "else" + (n.inverseStrip.close ? "~}}" : "}}");
+
+ if (n.inverse) {
+ return concat$a([isElseIf ? concat$a([n.openStrip.open ? "{{~else " : "{{else ", printPathParams(path, print), n.openStrip.close ? "~}}" : "}}"]) : printOpenBlock(path, print, n.openStrip), indent$6(concat$a([hardline$8, path.call(print, "program")])), n.inverse && !hasElseIf ? concat$a([hardline$8, inverseElseStatement]) : "", n.inverse ? indentElse(concat$a([hardline$8, path.call(print, "inverse")])) : "", isElseIf ? "" : concat$a([hardline$8, printCloseBlock(path, print, n.closeStrip)])]);
+ } else if (isElseIf) {
+ return concat$a([concat$a([n.openStrip.open ? "{{~else" : "{{else ", printPathParams(path, print), n.openStrip.close ? "~}}" : "}}"]), indent$6(concat$a([hardline$8, path.call(print, "program")]))]);
+ }
+
+ const hasNonWhitespaceChildren = n.program.body.some(n => !isWhitespaceNode$1(n));
+ return concat$a([printOpenBlock(path, print, n.openStrip), group$a(concat$a([indent$6(concat$a([softline$4, path.call(print, "program")])), hasNonWhitespaceChildren ? hardline$8 : softline$4, printCloseBlock(path, print, n.closeStrip)]))]);
+ }
+
+ case "ElementModifierStatement":
+ {
+ return group$a(concat$a(["{{", printPathParams(path, print), softline$4, "}}"]));
+ }
+
+ case "MustacheStatement":
+ {
+ const isEscaped = n.escaped === false;
+ const {
+ open: openStrip,
+ close: closeStrip
+ } = n.strip;
+ const opening = (isEscaped ? "{{{" : "{{") + (openStrip ? "~" : "");
+ const closing = (closeStrip ? "~" : "") + (isEscaped ? "}}}" : "}}");
+ const leading = isParentOfSomeType$1(path, ["AttrNode", "ConcatStatement", "ElementNode"]) ? [opening, indent$6(softline$4)] : [opening];
+ return group$a(concat$a([...leading, printPathParams(path, print), softline$4, closing]));
+ }
+
+ case "SubExpression":
+ {
+ const params = printParams(path, print);
+ const printedParams = params.length > 0 ? indent$6(concat$a([line$6, group$a(join$7(line$6, params))])) : "";
+ return group$a(concat$a(["(", printPath(path, print), printedParams, softline$4, ")"]));
+ }
+
+ case "AttrNode":
+ {
+ const isText = n.value.type === "TextNode";
+ const isEmptyText = isText && n.value.chars === ""; // If the text is empty and the value's loc start and end columns are the
+ // same, there is no value for this AttrNode and it should be printed
+ // without the `=""`. Example: `` -> ``
+
+ const isEmptyValue = isEmptyText && n.value.loc.start.column === n.value.loc.end.column;
+
+ if (isEmptyValue) {
+ return concat$a([n.name]);
+ }
+
+ const value = path.call(print, "value");
+ const quotedValue = isText ? printStringLiteral(value.parts.join(), options) : value;
+ return concat$a([n.name, "=", quotedValue]);
+ }
+
+ case "ConcatStatement":
+ {
+ return concat$a(['"', concat$a(path.map(partPath => print(partPath), "parts").filter(a => a !== "")), '"']);
+ }
+
+ case "Hash":
+ {
+ return concat$a([join$7(line$6, path.map(print, "pairs"))]);
+ }
+
+ case "HashPair":
+ {
+ return concat$a([n.key, "=", path.call(print, "value")]);
+ }
+
+ case "TextNode":
+ {
+ const maxLineBreaksToPreserve = 2;
+ const isFirstElement = !getPreviousNode$1(path);
+ const isLastElement = !getNextNode$1(path);
+ const isWhitespaceOnly = !/\S/.test(n.chars);
+ const lineBreaksCount = countNewLines(n.chars);
+ const hasBlockParent = path.getParentNode(0).type === "Block";
+ const hasElementParent = path.getParentNode(0).type === "ElementNode";
+ const hasTemplateParent = path.getParentNode(0).type === "Template";
+ let leadingLineBreaksCount = countLeadingNewLines(n.chars);
+ let trailingLineBreaksCount = countTrailingNewLines(n.chars);
+
+ if ((isFirstElement || isLastElement) && isWhitespaceOnly && (hasBlockParent || hasElementParent || hasTemplateParent)) {
+ return "";
+ }
+
+ if (isWhitespaceOnly && lineBreaksCount) {
+ leadingLineBreaksCount = Math.min(lineBreaksCount, maxLineBreaksToPreserve);
+ trailingLineBreaksCount = 0;
+ } else {
+ if (isNextNodeOfSomeType$1(path, ["BlockStatement", "ElementNode"])) {
+ trailingLineBreaksCount = Math.max(trailingLineBreaksCount, 1);
+ }
+
+ if (isPreviousNodeOfSomeType$1(path, ["ElementNode"]) || isPreviousNodeOfSomeType$1(path, ["BlockStatement"])) {
+ leadingLineBreaksCount = Math.max(leadingLineBreaksCount, 1);
+ }
+ }
+
+ let leadingSpace = "";
+ let trailingSpace = ""; // preserve a space inside of an attribute node where whitespace present,
+ // when next to mustache statement.
+
+ const inAttrNode = path.stack.includes("attributes");
+
+ if (inAttrNode) {
+ const parentNode = path.getParentNode(0);
+ const isConcat = parentNode.type === "ConcatStatement";
+
+ if (isConcat) {
+ const {
+ parts
+ } = parentNode;
+ const partIndex = parts.indexOf(n);
+
+ if (partIndex > 0) {
+ const partType = parts[partIndex - 1].type;
+ const isMustache = partType === "MustacheStatement";
+
+ if (isMustache) {
+ leadingSpace = " ";
+ }
+ }
+
+ if (partIndex < parts.length - 1) {
+ const partType = parts[partIndex + 1].type;
+ const isMustache = partType === "MustacheStatement";
+
+ if (isMustache) {
+ trailingSpace = " ";
+ }
+ }
+ }
+ } else {
+ if (trailingLineBreaksCount === 0 && isNextNodeOfSomeType$1(path, ["MustacheStatement"])) {
+ trailingSpace = " ";
+ }
+
+ if (leadingLineBreaksCount === 0 && isPreviousNodeOfSomeType$1(path, ["MustacheStatement"])) {
+ leadingSpace = " ";
+ }
+
+ if (isFirstElement) {
+ leadingLineBreaksCount = 0;
+ leadingSpace = "";
+ }
+
+ if (isLastElement) {
+ trailingLineBreaksCount = 0;
+ trailingSpace = "";
+ }
+ }
+
+ return concat$a([...generateHardlines(leadingLineBreaksCount, maxLineBreaksToPreserve), n.chars.replace(/^[\s ]+/g, leadingSpace).replace(/[\s ]+$/, trailingSpace), ...generateHardlines(trailingLineBreaksCount, maxLineBreaksToPreserve)].filter(Boolean));
+ }
+
+ case "MustacheCommentStatement":
+ {
+ const dashes = n.value.includes("}}") ? "--" : "";
+ return concat$a(["{{!", dashes, n.value, dashes, "}}"]);
+ }
+
+ case "PathExpression":
+ {
+ return n.original;
+ }
+
+ case "BooleanLiteral":
+ {
+ return String(n.value);
+ }
+
+ case "CommentStatement":
+ {
+ return concat$a([""]);
+ }
+
+ case "StringLiteral":
+ {
+ return printStringLiteral(n.value, options);
+ }
+
+ case "NumberLiteral":
+ {
+ return String(n.value);
+ }
+
+ case "UndefinedLiteral":
+ {
+ return "undefined";
+ }
+
+ case "NullLiteral":
+ {
+ return "null";
+ }
+
+ /* istanbul ignore next */
+
+ default:
+ throw new Error("unknown glimmer type: " + JSON.stringify(n.type));
+ }
+}
+
+function printChildren(path, options, print) {
+ return concat$a(path.map((childPath, childIndex) => {
+ const childNode = path.getValue();
+ const isFirstNode = childIndex === 0;
+ const isLastNode = childIndex === path.getParentNode(0).children.length - 1;
+ const isLastNodeInMultiNodeList = isLastNode && !isFirstNode;
+ const isWhitespace = isWhitespaceNode$1(childNode);
+
+ if (isWhitespace && isLastNodeInMultiNodeList) {
+ return print(childPath, options, print);
+ } else if (isFirstNode) {
+ return concat$a([softline$4, print(childPath, options, print)]);
+ }
+
+ return print(childPath, options, print);
+ }, "children"));
+}
+/**
+ * Prints a string literal with the correct surrounding quotes based on
+ * `options.singleQuote` and the number of escaped quotes contained in
+ * the string literal. This function is the glimmer equivalent of `printString`
+ * in `common/util`, but has differences because of the way escaped characters
+ * are treated in hbs string literals.
+ * @param {string} stringLiteral - the string literal value
+ * @param {object} options - the prettier options object
+ */
+
+
+function printStringLiteral(stringLiteral, options) {
+ const double = {
+ quote: '"',
+ regex: /"/g
+ };
+ const single = {
+ quote: "'",
+ regex: /'/g
+ };
+ const preferred = options.singleQuote ? single : double;
+ const alternate = preferred === single ? double : single;
+ let shouldUseAlternateQuote = false; // If `stringLiteral` contains at least one of the quote preferred for
+ // enclosing the string, we might want to enclose with the alternate quote
+ // instead, to minimize the number of escaped quotes.
+
+ if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) {
+ const numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length;
+ const numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length;
+ shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes;
+ }
+
+ const enclosingQuote = shouldUseAlternateQuote ? alternate : preferred;
+ const escapedStringLiteral = stringLiteral.replace(enclosingQuote.regex, `\\${enclosingQuote.quote}`);
+ return concat$a([enclosingQuote.quote, escapedStringLiteral, enclosingQuote.quote]);
+}
+
+function printPath(path, print) {
+ return path.call(print, "path");
+}
+
+function printParams(path, print) {
+ const node = path.getValue();
+ let parts = [];
+
+ if (node.params.length > 0) {
+ parts = parts.concat(path.map(print, "params"));
+ }
+
+ if (node.hash && node.hash.pairs.length > 0) {
+ parts.push(path.call(print, "hash"));
+ }
+
+ return parts;
+}
+
+function printPathParams(path, print) {
+ const printedPath = printPath(path, print);
+ const printedParams = printParams(path, print);
+ const parts = [printedPath, ...printedParams];
+ return indent$6(group$a(join$7(line$6, parts)));
+}
+
+function printBlockParams(path) {
+ const block = path.getValue();
+
+ if (!block.program || !block.program.blockParams.length) {
+ return "";
+ }
+
+ return concat$a([" as |", block.program.blockParams.join(" "), "|"]);
+}
+
+function printOpenBlock(path, print, {
+ open: isOpenStrip = false,
+ close: isCloseStrip = false
+} = {}) {
+ return group$a(concat$a([isOpenStrip ? "{{~#" : "{{#", printPathParams(path, print), printBlockParams(path), softline$4, isCloseStrip ? "~}}" : "}}"]));
+}
+
+function printCloseBlock(path, print, {
+ open: isOpenStrip = false,
+ close: isCloseStrip = false
+} = {}) {
+ return concat$a([isOpenStrip ? "{{~/" : "{{/", path.call(print, "path"), isCloseStrip ? "~}}" : "}}"]);
+}
+
+function countNewLines(string) {
+ /* istanbul ignore next */
+ string = typeof string === "string" ? string : "";
+ return string.split("\n").length - 1;
+}
+
+function countLeadingNewLines(string) {
+ /* istanbul ignore next */
+ string = typeof string === "string" ? string : "";
+ const newLines = (string.match(/^([^\S\r\n]*[\r\n])+/g) || [])[0] || "";
+ return countNewLines(newLines);
+}
+
+function countTrailingNewLines(string) {
+ /* istanbul ignore next */
+ string = typeof string === "string" ? string : "";
+ const newLines = (string.match(/([\r\n][^\S\r\n]*)+$/g) || [])[0] || "";
+ return countNewLines(newLines);
+}
+
+function generateHardlines(number = 0, max = 0) {
+ return new Array(Math.min(number, max)).fill(hardline$8);
+}
+/* istanbul ignore next
+ https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/location.ts#L5-L29
+*/
+
+
+function locationToOffset(source, line, column) {
+ let seenLines = 0;
+ let seenChars = 0; // eslint-disable-next-line no-constant-condition
+
+ while (true) {
+ if (seenChars === source.length) {
+ return null;
+ }
+
+ let nextLine = source.indexOf("\n", seenChars);
+
+ if (nextLine === -1) {
+ nextLine = source.length;
+ }
+
+ if (seenLines === line) {
+ if (seenChars + column > nextLine) {
+ return null;
+ }
+
+ return seenChars + column;
+ } else if (nextLine === -1) {
+ return null;
+ }
+
+ seenLines += 1;
+ seenChars = nextLine + 1;
+ }
+}
+
+var printerGlimmer = {
+ print,
+ massageAstNode: clean$3
+};
+
+var name$d = "Handlebars";
+var type$b = "markup";
+var group$b = "HTML";
+var aliases$3 = [
+ "hbs",
+ "htmlbars"
+];
+var extensions$b = [
+ ".handlebars",
+ ".hbs"
+];
+var tmScope$b = "text.html.handlebars";
+var aceMode$b = "handlebars";
+var languageId$b = 155;
+var Handlebars = {
+ name: name$d,
+ type: type$b,
+ group: group$b,
+ aliases: aliases$3,
+ extensions: extensions$b,
+ tmScope: tmScope$b,
+ aceMode: aceMode$b,
+ languageId: languageId$b
+};
+
+var Handlebars$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$d,
+ type: type$b,
+ group: group$b,
+ aliases: aliases$3,
+ extensions: extensions$b,
+ tmScope: tmScope$b,
+ aceMode: aceMode$b,
+ languageId: languageId$b,
+ 'default': Handlebars
+});
+
+var require$$0$3 = getCjsExportFromNamespace(Handlebars$1);
+
+const languages$2 = [createLanguage(require$$0$3, () => ({
+ since: null,
+ // unreleased
+ parsers: ["glimmer"],
+ vscodeLanguageIds: ["handlebars"]
+}))];
+const printers$2 = {
+ glimmer: printerGlimmer
+};
+var languageHandlebars = {
+ languages: languages$2,
+ printers: printers$2
+};
+
+function hasPragma$2(text) {
+ return /^\s*#[^\n\S]*@(format|prettier)\s*(\n|$)/.test(text);
+}
+
+function insertPragma$4(text) {
+ return "# @format\n\n" + text;
+}
+
+var pragma$2 = {
+ hasPragma: hasPragma$2,
+ insertPragma: insertPragma$4
+};
+
+const {
+ concat: concat$b,
+ join: join$8,
+ hardline: hardline$9,
+ line: line$7,
+ softline: softline$5,
+ group: group$c,
+ indent: indent$7,
+ ifBreak: ifBreak$4
+} = document.builders;
+const {
+ hasIgnoreComment: hasIgnoreComment$4
+} = util$1;
+const {
+ isNextLineEmpty: isNextLineEmpty$4
+} = utilShared;
+const {
+ insertPragma: insertPragma$5
+} = pragma$2;
+
+function genericPrint$3(path, options, print) {
+ const n = path.getValue();
+
+ if (!n) {
+ return "";
+ }
+
+ if (typeof n === "string") {
+ return n;
+ }
+
+ switch (n.kind) {
+ case "Document":
+ {
+ const parts = [];
+ path.map((pathChild, index) => {
+ parts.push(concat$b([pathChild.call(print)]));
+
+ if (index !== n.definitions.length - 1) {
+ parts.push(hardline$9);
+
+ if (isNextLineEmpty$4(options.originalText, pathChild.getValue(), options.locEnd)) {
+ parts.push(hardline$9);
+ }
+ }
+ }, "definitions");
+ return concat$b([concat$b(parts), hardline$9]);
+ }
+
+ case "OperationDefinition":
+ {
+ const hasOperation = options.originalText[options.locStart(n)] !== "{";
+ const hasName = !!n.name;
+ return concat$b([hasOperation ? n.operation : "", hasOperation && hasName ? concat$b([" ", path.call(print, "name")]) : "", n.variableDefinitions && n.variableDefinitions.length ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? !hasOperation && !hasName ? "" : " " : "", path.call(print, "selectionSet")]);
+ }
+
+ case "FragmentDefinition":
+ {
+ return concat$b(["fragment ", path.call(print, "name"), n.variableDefinitions && n.variableDefinitions.length ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", " on ", path.call(print, "typeCondition"), printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
+ }
+
+ case "SelectionSet":
+ {
+ return concat$b(["{", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(selectionsPath => printSequence(selectionsPath, options, print), "selections"))])), hardline$9, "}"]);
+ }
+
+ case "Field":
+ {
+ return group$c(concat$b([n.alias ? concat$b([path.call(print, "alias"), ": "]) : "", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? " " : "", path.call(print, "selectionSet")]));
+ }
+
+ case "Name":
+ {
+ return n.value;
+ }
+
+ case "StringValue":
+ {
+ if (n.block) {
+ return concat$b(['"""', hardline$9, join$8(hardline$9, n.value.replace(/"""/g, "\\$&").split("\n")), hardline$9, '"""']);
+ }
+
+ return concat$b(['"', n.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"']);
+ }
+
+ case "IntValue":
+ case "FloatValue":
+ case "EnumValue":
+ {
+ return n.value;
+ }
+
+ case "BooleanValue":
+ {
+ return n.value ? "true" : "false";
+ }
+
+ case "NullValue":
+ {
+ return "null";
+ }
+
+ case "Variable":
+ {
+ return concat$b(["$", path.call(print, "name")]);
+ }
+
+ case "ListValue":
+ {
+ return group$c(concat$b(["[", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "values"))])), softline$5, "]"]));
+ }
+
+ case "ObjectValue":
+ {
+ return group$c(concat$b(["{", options.bracketSpacing && n.fields.length > 0 ? " " : "", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "fields"))])), softline$5, ifBreak$4("", options.bracketSpacing && n.fields.length > 0 ? " " : ""), "}"]));
+ }
+
+ case "ObjectField":
+ case "Argument":
+ {
+ return concat$b([path.call(print, "name"), ": ", path.call(print, "value")]);
+ }
+
+ case "Directive":
+ {
+ return concat$b(["@", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : ""]);
+ }
+
+ case "NamedType":
+ {
+ return path.call(print, "name");
+ }
+
+ case "VariableDefinition":
+ {
+ return concat$b([path.call(print, "variable"), ": ", path.call(print, "type"), n.defaultValue ? concat$b([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
+ }
+
+ case "TypeExtensionDefinition":
+ {
+ return concat$b(["extend ", path.call(print, "definition")]);
+ }
+
+ case "ObjectTypeExtension":
+ case "ObjectTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ObjectTypeExtension" ? "extend " : "", "type ", path.call(print, "name"), n.interfaces.length > 0 ? concat$b([" implements ", concat$b(printInterfaces(path, options, print))]) : "", printDirectives(path, print, n), n.fields.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))])), hardline$9, "}"]) : ""]);
+ }
+
+ case "FieldDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : "", ": ", path.call(print, "type"), printDirectives(path, print, n)]);
+ }
+
+ case "DirectiveDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", "directive ", "@", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : "", n.repeatable ? " repeatable" : "", concat$b([" on ", join$8(" | ", path.map(print, "locations"))])]);
+ }
+
+ case "EnumTypeExtension":
+ case "EnumTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "EnumTypeExtension" ? "extend " : "", "enum ", path.call(print, "name"), printDirectives(path, print, n), n.values.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(valuesPath => printSequence(valuesPath, options, print), "values"))])), hardline$9, "}"]) : ""]);
+ }
+
+ case "EnumValueDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", path.call(print, "name"), printDirectives(path, print, n)]);
+ }
+
+ case "InputValueDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? n.description.block ? hardline$9 : line$7 : "", path.call(print, "name"), ": ", path.call(print, "type"), n.defaultValue ? concat$b([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
+ }
+
+ case "InputObjectTypeExtension":
+ case "InputObjectTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))])), hardline$9, "}"]) : ""]);
+ }
+
+ case "SchemaDefinition":
+ {
+ return concat$b(["schema", printDirectives(path, print, n), " {", n.operationTypes.length > 0 ? indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(opsPath => printSequence(opsPath, options, print), "operationTypes"))])) : "", hardline$9, "}"]);
+ }
+
+ case "OperationTypeDefinition":
+ {
+ return concat$b([path.call(print, "operation"), ": ", path.call(print, "type")]);
+ }
+
+ case "InterfaceTypeExtension":
+ case "InterfaceTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))])), hardline$9, "}"]) : ""]);
+ }
+
+ case "FragmentSpread":
+ {
+ return concat$b(["...", path.call(print, "name"), printDirectives(path, print, n)]);
+ }
+
+ case "InlineFragment":
+ {
+ return concat$b(["...", n.typeCondition ? concat$b([" on ", path.call(print, "typeCondition")]) : "", printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
+ }
+
+ case "UnionTypeExtension":
+ case "UnionTypeDefinition":
+ {
+ return group$c(concat$b([path.call(print, "description"), n.description ? hardline$9 : "", group$c(concat$b([n.kind === "UnionTypeExtension" ? "extend " : "", "union ", path.call(print, "name"), printDirectives(path, print, n), n.types.length > 0 ? concat$b([" =", ifBreak$4("", " "), indent$7(concat$b([ifBreak$4(concat$b([line$7, " "])), join$8(concat$b([line$7, "| "]), path.map(print, "types"))]))]) : ""]))]));
+ }
+
+ case "ScalarTypeExtension":
+ case "ScalarTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", path.call(print, "name"), printDirectives(path, print, n)]);
+ }
+
+ case "NonNullType":
+ {
+ return concat$b([path.call(print, "type"), "!"]);
+ }
+
+ case "ListType":
+ {
+ return concat$b(["[", path.call(print, "type"), "]"]);
+ }
+
+ default:
+ /* istanbul ignore next */
+ throw new Error("unknown graphql type: " + JSON.stringify(n.kind));
+ }
+}
+
+function printDirectives(path, print, n) {
+ if (n.directives.length === 0) {
+ return "";
+ }
+
+ return concat$b([" ", group$c(indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", " "), softline$5]), path.map(print, "directives"))])))]);
+}
+
+function printSequence(sequencePath, options, print) {
+ const count = sequencePath.getValue().length;
+ return sequencePath.map((path, i) => {
+ const printed = print(path);
+
+ if (isNextLineEmpty$4(options.originalText, path.getValue(), options.locEnd) && i < count - 1) {
+ return concat$b([printed, hardline$9]);
+ }
+
+ return printed;
+ });
+}
+
+function canAttachComment$1(node) {
+ return node.kind && node.kind !== "Comment";
+}
+
+function printComment$2(commentPath) {
+ const comment = commentPath.getValue();
+
+ if (comment.kind === "Comment") {
+ return "#" + comment.value.trimEnd();
+ }
+
+ throw new Error("Not a comment: " + JSON.stringify(comment));
+}
+
+function determineInterfaceSeparatorBetween(first, second, options) {
+ const textBetween = options.originalText.slice(first.loc.end, second.loc.start).replace(/#.*/g, "").trim();
+ return textBetween === "," ? ", " : " & ";
+}
+
+function printInterfaces(path, options, print) {
+ const node = path.getNode();
+ const parts = [];
+ const {
+ interfaces
+ } = node;
+ const printed = path.map(node => print(node), "interfaces");
+
+ for (let index = 0; index < interfaces.length; index++) {
+ const interfaceNode = interfaces[index];
+
+ if (index > 0) {
+ parts.push(determineInterfaceSeparatorBetween(interfaces[index - 1], interfaceNode, options));
+ }
+
+ parts.push(printed[index]);
+ }
+
+ return parts;
+}
+
+function clean$4(node, newNode
+/*, parent*/
+) {
+ delete newNode.loc;
+ delete newNode.comments;
+}
+
+var printerGraphql = {
+ print: genericPrint$3,
+ massageAstNode: clean$4,
+ hasPrettierIgnore: hasIgnoreComment$4,
+ insertPragma: insertPragma$5,
+ printComment: printComment$2,
+ canAttachComment: canAttachComment$1
+};
+
+var options$4 = {
+ bracketSpacing: commonOptions.bracketSpacing
+};
+
+var name$e = "GraphQL";
+var type$c = "data";
+var extensions$c = [
+ ".graphql",
+ ".gql",
+ ".graphqls"
+];
+var tmScope$c = "source.graphql";
+var aceMode$c = "text";
+var languageId$c = 139;
+var GraphQL = {
+ name: name$e,
+ type: type$c,
+ extensions: extensions$c,
+ tmScope: tmScope$c,
+ aceMode: aceMode$c,
+ languageId: languageId$c
+};
+
+var GraphQL$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$e,
+ type: type$c,
+ extensions: extensions$c,
+ tmScope: tmScope$c,
+ aceMode: aceMode$c,
+ languageId: languageId$c,
+ 'default': GraphQL
+});
+
+var require$$0$4 = getCjsExportFromNamespace(GraphQL$1);
+
+const languages$3 = [createLanguage(require$$0$4, () => ({
+ since: "1.5.0",
+ parsers: ["graphql"],
+ vscodeLanguageIds: ["graphql"]
+}))];
+const printers$3 = {
+ graphql: printerGraphql
+};
+var languageGraphql = {
+ languages: languages$3,
+ options: options$4,
+ printers: printers$3
+};
+
+var json = {
+ "cjkPattern": "[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fef\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e\\udd50-\\udd52\\udd64-\\udd67]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d]",
+ "kPattern": "[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]",
+ "punctuationPattern": "[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0a76\\u0af0\\u0c77\\u0c84\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e4f\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud803[\\udf55-\\udf59]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc8\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\udc3b\\udde2\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71\\udef7-\\udef8\\udfff]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud81b[\\ude97-\\ude9a\\udfe2]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"
+};
+
+const {
+ cjkPattern,
+ kPattern,
+ punctuationPattern
+} = json;
+const {
+ getLast: getLast$4
+} = util$1;
+const INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
+const INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]);
+const kRegex = new RegExp(kPattern);
+const punctuationRegex = new RegExp(punctuationPattern);
+/**
+ * split text into whitespaces and words
+ * @param {string} text
+ * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
+ */
+
+function splitText(text, options) {
+ const KIND_NON_CJK = "non-cjk";
+ const KIND_CJ_LETTER = "cj-letter";
+ const KIND_K_LETTER = "k-letter";
+ const KIND_CJK_PUNCTUATION = "cjk-punctuation";
+ const nodes = [];
+ (options.proseWrap === "preserve" ? text : text.replace(new RegExp(`(${cjkPattern})\n(${cjkPattern})`, "g"), "$1$2")).split(/([ \t\n]+)/).forEach((token, index, tokens) => {
+ // whitespace
+ if (index % 2 === 1) {
+ nodes.push({
+ type: "whitespace",
+ value: /\n/.test(token) ? "\n" : " "
+ });
+ return;
+ } // word separated by whitespace
+
+
+ if ((index === 0 || index === tokens.length - 1) && token === "") {
+ return;
+ }
+
+ token.split(new RegExp(`(${cjkPattern})`)).forEach((innerToken, innerIndex, innerTokens) => {
+ if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
+ return;
+ } // non-CJK word
+
+
+ if (innerIndex % 2 === 0) {
+ if (innerToken !== "") {
+ appendNode({
+ type: "word",
+ value: innerToken,
+ kind: KIND_NON_CJK,
+ hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
+ hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
+ });
+ }
+
+ return;
+ } // CJK character
+
+
+ appendNode(punctuationRegex.test(innerToken) ? {
+ type: "word",
+ value: innerToken,
+ kind: KIND_CJK_PUNCTUATION,
+ hasLeadingPunctuation: true,
+ hasTrailingPunctuation: true
+ } : {
+ type: "word",
+ value: innerToken,
+ kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
+ hasLeadingPunctuation: false,
+ hasTrailingPunctuation: false
+ });
+ });
+ });
+ return nodes;
+
+ function appendNode(node) {
+ const lastNode = getLast$4(nodes);
+
+ if (lastNode && lastNode.type === "word") {
+ if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
+ nodes.push({
+ type: "whitespace",
+ value: " "
+ });
+ } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
+ ![lastNode.value, node.value].some(value => /\u3000/.test(value))) {
+ nodes.push({
+ type: "whitespace",
+ value: ""
+ });
+ }
+ }
+
+ nodes.push(node);
+
+ function isBetween(kind1, kind2) {
+ return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
+ }
+ }
+}
+
+function getOrderedListItemInfo(orderListItem, originalText) {
+ const [, numberText, marker, leadingSpaces] = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/);
+ return {
+ numberText,
+ marker,
+ leadingSpaces
+ };
+}
+
+function hasGitDiffFriendlyOrderedList(node, options) {
+ if (!node.ordered) {
+ return false;
+ }
+
+ if (node.children.length < 2) {
+ return false;
+ }
+
+ const firstNumber = Number(getOrderedListItemInfo(node.children[0], options.originalText).numberText);
+ const secondNumber = Number(getOrderedListItemInfo(node.children[1], options.originalText).numberText);
+
+ if (firstNumber === 0 && node.children.length > 2) {
+ const thirdNumber = Number(getOrderedListItemInfo(node.children[2], options.originalText).numberText);
+ return secondNumber === 1 && thirdNumber === 1;
+ }
+
+ return secondNumber === 1;
+} // workaround for https://github.com/remarkjs/remark/issues/351
+// leading and trailing newlines are stripped by remark
+
+
+function getFencedCodeBlockValue(node, originalText) {
+ const text = originalText.slice(node.position.start.offset, node.position.end.offset);
+ const leadingSpaceCount = text.match(/^\s*/)[0].length;
+ const replaceRegex = new RegExp(`^\\s{0,${leadingSpaceCount}}`);
+ const lineContents = text.split("\n");
+ const markerStyle = text[leadingSpaceCount]; // ` or ~
+
+ const marker = text.slice(leadingSpaceCount).match(new RegExp(`^[${markerStyle}]+`))[0]; // https://spec.commonmark.org/0.28/#example-104: Closing fences may be indented by 0-3 spaces
+ // https://spec.commonmark.org/0.28/#example-93: The closing code fence must be at least as long as the opening fence
+
+ const hasEndMarker = new RegExp(`^\\s{0,3}${marker}`).test(lineContents[lineContents.length - 1].slice(getIndent(lineContents.length - 1)));
+ return lineContents.slice(1, hasEndMarker ? -1 : undefined).map((x, i) => x.slice(getIndent(i + 1)).replace(replaceRegex, "")).join("\n");
+
+ function getIndent(lineIndex) {
+ return node.position.indent[lineIndex - 1] - 1;
+ }
+}
+
+function mapAst(ast, handler) {
+ return function preorder(node, index, parentStack) {
+ parentStack = parentStack || [];
+ const newNode = Object.assign({}, handler(node, index, parentStack));
+
+ if (newNode.children) {
+ newNode.children = newNode.children.map((child, index) => {
+ return preorder(child, index, [newNode].concat(parentStack));
+ });
+ }
+
+ return newNode;
+ }(ast, null, null);
+}
+
+var utils$9 = {
+ mapAst,
+ splitText,
+ punctuationPattern,
+ getFencedCodeBlockValue,
+ getOrderedListItemInfo,
+ hasGitDiffFriendlyOrderedList,
+ INLINE_NODE_TYPES,
+ INLINE_NODE_WRAPPER_TYPES
+};
+
+const {
+ builders: {
+ hardline: hardline$a,
+ literalline: literalline$4,
+ concat: concat$c,
+ markAsRoot: markAsRoot$2
+ },
+ utils: {
+ mapDoc: mapDoc$3
+ }
+} = document;
+const {
+ getFencedCodeBlockValue: getFencedCodeBlockValue$1
+} = utils$9;
+
+function embed$2(path, print, textToDoc, options) {
+ const node = path.getValue();
+
+ if (node.type === "code" && node.lang !== null) {
+ // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
+ const langMatch = node.lang.match(/^[A-Za-z0-9_-]+/);
+ const lang = langMatch ? langMatch[0] : "";
+ const parser = getParserName(lang);
+
+ if (parser) {
+ const styleUnit = options.__inJsTemplate ? "~" : "`";
+ const style = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
+ const doc = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), {
+ parser
+ });
+ return markAsRoot$2(concat$c([style, node.lang, hardline$a, replaceNewlinesWithLiterallines(doc), style]));
+ }
+ }
+
+ if (node.type === "yaml") {
+ return markAsRoot$2(concat$c(["---", hardline$a, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
+ parser: "yaml"
+ })) : "", "---"]));
+ } // MDX
+
+
+ switch (node.type) {
+ case "importExport":
+ return textToDoc(node.value, {
+ parser: "babel"
+ });
+
+ case "jsx":
+ return textToDoc(`<$>${node.value}$>`, {
+ parser: "__js_expression",
+ rootMarker: "mdx"
+ });
+ }
+
+ return null;
+
+ function getParserName(lang) {
+ const supportInfo = support.getSupportInfo({
+ plugins: options.plugins
+ });
+ const language = supportInfo.languages.find(language => language.name.toLowerCase() === lang || language.aliases && language.aliases.includes(lang) || language.extensions && language.extensions.find(ext => ext === `.${lang}`));
+
+ if (language) {
+ return language.parsers[0];
+ }
+
+ return null;
+ }
+
+ function replaceNewlinesWithLiterallines(doc) {
+ return mapDoc$3(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$c(currentDoc.split(/(\n)/g).map((v, i) => i % 2 === 0 ? v : literalline$4)) : currentDoc);
+ }
+}
+
+var embed_1$2 = embed$2;
+
+const pragmas = ["format", "prettier"];
+
+function startWithPragma(text) {
+ const pragma = `@(${pragmas.join("|")})`;
+ const regex = new RegExp([``, ``].join("|"), "m");
+ const matched = text.match(regex);
+ return matched && matched.index === 0;
+}
+
+var pragma$3 = {
+ startWithPragma,
+ hasPragma: text => startWithPragma(frontMatter(text).content.trimStart()),
+ insertPragma: text => {
+ const extracted = frontMatter(text);
+ const pragma = ``;
+ return extracted.frontMatter ? `${extracted.frontMatter.raw}\n\n${pragma}\n\n${extracted.content}` : `${pragma}\n\n${extracted.content}`;
+ }
+};
+
+const {
+ getOrderedListItemInfo: getOrderedListItemInfo$1,
+ mapAst: mapAst$1,
+ splitText: splitText$1
+} = utils$9; // 0x0 ~ 0x10ffff
+// eslint-disable-next-line no-control-regex
+
+const isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/;
+
+function preprocess$1(ast, options) {
+ ast = restoreUnescapedCharacter(ast, options);
+ ast = mergeContinuousTexts(ast);
+ ast = transformInlineCode(ast);
+ ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
+ ast = markAlignedList(ast, options);
+ ast = splitTextIntoSentences(ast, options);
+ ast = transformImportExport(ast);
+ ast = mergeContinuousImportExport(ast);
+ return ast;
+}
+
+function transformImportExport(ast) {
+ return mapAst$1(ast, node => {
+ if (node.type !== "import" && node.type !== "export") {
+ return node;
+ }
+
+ return Object.assign({}, node, {
+ type: "importExport"
+ });
+ });
+}
+
+function transformInlineCode(ast) {
+ return mapAst$1(ast, node => {
+ if (node.type !== "inlineCode") {
+ return node;
+ }
+
+ return Object.assign({}, node, {
+ value: node.value.replace(/\s+/g, " ")
+ });
+ });
+}
+
+function restoreUnescapedCharacter(ast, options) {
+ return mapAst$1(ast, node => {
+ return node.type !== "text" ? node : Object.assign({}, node, {
+ value: node.value !== "*" && node.value !== "_" && node.value !== "$" && // handle these cases in printer
+ isSingleCharRegex.test(node.value) && node.position.end.offset - node.position.start.offset !== node.value.length ? options.originalText.slice(node.position.start.offset, node.position.end.offset) : node.value
+ });
+ });
+}
+
+function mergeContinuousImportExport(ast) {
+ return mergeChildren(ast, (prevNode, node) => prevNode.type === "importExport" && node.type === "importExport", (prevNode, node) => ({
+ type: "importExport",
+ value: prevNode.value + "\n\n" + node.value,
+ position: {
+ start: prevNode.position.start,
+ end: node.position.end
+ }
+ }));
+}
+
+function mergeChildren(ast, shouldMerge, mergeNode) {
+ return mapAst$1(ast, node => {
+ if (!node.children) {
+ return node;
+ }
+
+ const children = node.children.reduce((current, child) => {
+ const lastChild = current[current.length - 1];
+
+ if (lastChild && shouldMerge(lastChild, child)) {
+ current.splice(-1, 1, mergeNode(lastChild, child));
+ } else {
+ current.push(child);
+ }
+
+ return current;
+ }, []);
+ return Object.assign({}, node, {
+ children
+ });
+ });
+}
+
+function mergeContinuousTexts(ast) {
+ return mergeChildren(ast, (prevNode, node) => prevNode.type === "text" && node.type === "text", (prevNode, node) => ({
+ type: "text",
+ value: prevNode.value + node.value,
+ position: {
+ start: prevNode.position.start,
+ end: node.position.end
+ }
+ }));
+}
+
+function splitTextIntoSentences(ast, options) {
+ return mapAst$1(ast, (node, index, [parentNode]) => {
+ if (node.type !== "text") {
+ return node;
+ }
+
+ let {
+ value
+ } = node;
+
+ if (parentNode.type === "paragraph") {
+ if (index === 0) {
+ value = value.trimStart();
+ }
+
+ if (index === parentNode.children.length - 1) {
+ value = value.trimEnd();
+ }
+ }
+
+ return {
+ type: "sentence",
+ position: node.position,
+ children: splitText$1(value, options)
+ };
+ });
+}
+
+function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
+ return mapAst$1(ast, (node, index, parentStack) => {
+ if (node.type === "code") {
+ // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
+ const isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
+ node.isIndented = isIndented;
+
+ if (isIndented) {
+ for (let i = 0; i < parentStack.length; i++) {
+ const parent = parentStack[i]; // no need to check checked items
+
+ if (parent.hasIndentedCodeblock) {
+ break;
+ }
+
+ if (parent.type === "list") {
+ parent.hasIndentedCodeblock = true;
+ }
+ }
+ }
+ }
+
+ return node;
+ });
+}
+
+function markAlignedList(ast, options) {
+ return mapAst$1(ast, (node, index, parentStack) => {
+ if (node.type === "list" && node.children.length !== 0) {
+ // if one of its parents is not aligned, it's not possible to be aligned in sub-lists
+ for (let i = 0; i < parentStack.length; i++) {
+ const parent = parentStack[i];
+
+ if (parent.type === "list" && !parent.isAligned) {
+ node.isAligned = false;
+ return node;
+ }
+ }
+
+ node.isAligned = isAligned(node);
+ }
+
+ return node;
+ });
+
+ function getListItemStart(listItem) {
+ return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
+ }
+
+ function isAligned(list) {
+ if (!list.ordered) {
+ /**
+ * - 123
+ * - 123
+ */
+ return true;
+ }
+
+ const [firstItem, secondItem] = list.children;
+ const firstInfo = getOrderedListItemInfo$1(firstItem, options.originalText);
+
+ if (firstInfo.leadingSpaces.length > 1) {
+ /**
+ * 1. 123
+ *
+ * 1. 123
+ * 1. 123
+ */
+ return true;
+ }
+
+ const firstStart = getListItemStart(firstItem);
+
+ if (firstStart === -1) {
+ /**
+ * 1.
+ *
+ * 1.
+ * 1.
+ */
+ return false;
+ }
+
+ if (list.children.length === 1) {
+ /**
+ * aligned:
+ *
+ * 11. 123
+ *
+ * not aligned:
+ *
+ * 1. 123
+ */
+ return firstStart % options.tabWidth === 0;
+ }
+
+ const secondStart = getListItemStart(secondItem);
+
+ if (firstStart !== secondStart) {
+ /**
+ * 11. 123
+ * 1. 123
+ *
+ * 1. 123
+ * 11. 123
+ */
+ return false;
+ }
+
+ if (firstStart % options.tabWidth === 0) {
+ /**
+ * 11. 123
+ * 12. 123
+ */
+ return true;
+ }
+ /**
+ * aligned:
+ *
+ * 11. 123
+ * 1. 123
+ *
+ * not aligned:
+ *
+ * 1. 123
+ * 2. 123
+ */
+
+
+ const secondInfo = getOrderedListItemInfo$1(secondItem, options.originalText);
+ return secondInfo.leadingSpaces.length > 1;
+ }
+}
+
+var preprocess_1$1 = preprocess$1;
+
+const {
+ builders: {
+ breakParent: breakParent$3,
+ concat: concat$d,
+ join: join$9,
+ line: line$8,
+ literalline: literalline$5,
+ markAsRoot: markAsRoot$3,
+ hardline: hardline$b,
+ softline: softline$6,
+ ifBreak: ifBreak$5,
+ fill: fill$5,
+ align: align$2,
+ indent: indent$8,
+ group: group$d
+ },
+ utils: {
+ mapDoc: mapDoc$4
+ },
+ printer: {
+ printDocToString: printDocToString$3
+ }
+} = document;
+const {
+ getFencedCodeBlockValue: getFencedCodeBlockValue$2,
+ hasGitDiffFriendlyOrderedList: hasGitDiffFriendlyOrderedList$1,
+ splitText: splitText$2,
+ punctuationPattern: punctuationPattern$1,
+ INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
+ INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
+} = utils$9;
+const {
+ replaceEndOfLineWith: replaceEndOfLineWith$1
+} = util$1;
+const TRAILING_HARDLINE_NODES = ["importExport"];
+const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
+const SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
+
+function genericPrint$4(path, options, print) {
+ const node = path.getValue();
+
+ if (shouldRemainTheSameContent(path)) {
+ return concat$d(splitText$2(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(node => node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options)));
+ }
+
+ switch (node.type) {
+ case "root":
+ if (node.children.length === 0) {
+ return "";
+ }
+
+ return concat$d([normalizeDoc(printRoot(path, options, print)), !TRAILING_HARDLINE_NODES.includes(getLastDescendantNode(node).type) ? hardline$b : ""]);
+
+ case "paragraph":
+ return printChildren$1(path, options, print, {
+ postprocessor: fill$5
+ });
+
+ case "sentence":
+ return printChildren$1(path, options, print);
+
+ case "word":
+ return node.value.replace(/[*$]/g, "\\$&") // escape all `*` and `$` (math)
+ .replace(new RegExp([`(^|${punctuationPattern$1})(_+)`, `(_+)(${punctuationPattern$1}|$)`].join("|"), "g"), (_, text1, underscore1, underscore2, text2) => (underscore1 ? `${text1}${underscore1}` : `${underscore2}${text2}`).replace(/_/g, "\\_"));
+ // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
+
+ case "whitespace":
+ {
+ const parentNode = path.getParentNode();
+ const index = parentNode.children.indexOf(node);
+ const nextNode = parentNode.children[index + 1];
+ const proseWrap = // leading char that may cause different syntax
+ nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) ? "never" : options.proseWrap;
+ return printLine(path, node.value, {
+ proseWrap
+ });
+ }
+
+ case "emphasis":
+ {
+ const parentNode = path.getParentNode();
+ const index = parentNode.children.indexOf(node);
+ const prevNode = parentNode.children[index - 1];
+ const nextNode = parentNode.children[index + 1];
+ const hasPrevOrNextWord = // `1*2*3` is considered emphasis but `1_2_3` is not
+ prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && util$1.getLast(prevNode.children).type === "word" && !util$1.getLast(prevNode.children).hasTrailingPunctuation || nextNode && nextNode.type === "sentence" && nextNode.children.length > 0 && nextNode.children[0].type === "word" && !nextNode.children[0].hasLeadingPunctuation;
+ const style = hasPrevOrNextWord || getAncestorNode$2(path, "emphasis") ? "*" : "_";
+ return concat$d([style, printChildren$1(path, options, print), style]);
+ }
+
+ case "strong":
+ return concat$d(["**", printChildren$1(path, options, print), "**"]);
+
+ case "delete":
+ return concat$d(["~~", printChildren$1(path, options, print), "~~"]);
+
+ case "inlineCode":
+ {
+ const backtickCount = util$1.getMinNotPresentContinuousCount(node.value, "`");
+ const style = "`".repeat(backtickCount || 1);
+ const gap = backtickCount ? " " : "";
+ return concat$d([style, gap, node.value, gap, style]);
+ }
+
+ case "link":
+ switch (options.originalText[node.position.start.offset]) {
+ case "<":
+ {
+ const mailto = "mailto:";
+ const url = // is parsed as { url: "mailto:hello@example.com" }
+ node.url.startsWith(mailto) && options.originalText.slice(node.position.start.offset + 1, node.position.start.offset + 1 + mailto.length) !== mailto ? node.url.slice(mailto.length) : node.url;
+ return concat$d(["<", url, ">"]);
+ }
+
+ case "[":
+ return concat$d(["[", printChildren$1(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
+
+ default:
+ return options.originalText.slice(node.position.start.offset, node.position.end.offset);
+ }
+
+ case "image":
+ return concat$d(["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
+
+ case "blockquote":
+ return concat$d(["> ", align$2("> ", printChildren$1(path, options, print))]);
+
+ case "heading":
+ return concat$d(["#".repeat(node.depth) + " ", printChildren$1(path, options, print)]);
+
+ case "code":
+ {
+ if (node.isIndented) {
+ // indented code block
+ const alignment = " ".repeat(4);
+ return align$2(alignment, concat$d([alignment, concat$d(replaceEndOfLineWith$1(node.value, hardline$b))]));
+ } // fenced code block
+
+
+ const styleUnit = options.__inJsTemplate ? "~" : "`";
+ const style = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
+ return concat$d([style, node.lang || "", hardline$b, concat$d(replaceEndOfLineWith$1(getFencedCodeBlockValue$2(node, options.originalText), hardline$b)), hardline$b, style]);
+ }
+
+ case "yaml":
+ case "toml":
+ return options.originalText.slice(node.position.start.offset, node.position.end.offset);
+
+ case "html":
+ {
+ const parentNode = path.getParentNode();
+ const value = parentNode.type === "root" && util$1.getLast(parentNode.children) === node ? node.value.trimEnd() : node.value;
+ const isHtmlComment = /^$/.test(value);
+ return concat$d(replaceEndOfLineWith$1(value, isHtmlComment ? hardline$b : markAsRoot$3(literalline$5)));
+ }
+
+ case "list":
+ {
+ const nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
+ const isGitDiffFriendlyOrderedList = hasGitDiffFriendlyOrderedList$1(node, options);
+ return printChildren$1(path, options, print, {
+ processor: (childPath, index) => {
+ const prefix = getPrefix();
+ const childNode = childPath.getValue();
+
+ if (childNode.children.length === 2 && childNode.children[1].type === "html" && childNode.children[0].position.start.column !== childNode.children[1].position.start.column) {
+ return concat$d([prefix, printListItem(childPath, options, print, prefix)]);
+ }
+
+ return concat$d([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]);
+
+ function getPrefix() {
+ const rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
+ return node.isAligned ||
+ /* workaround for https://github.com/remarkjs/remark/issues/315 */
+ node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
+ }
+ }
+ });
+ }
+
+ case "thematicBreak":
+ {
+ const counter = getAncestorCounter$1(path, "list");
+
+ if (counter === -1) {
+ return "---";
+ }
+
+ const nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
+ return nthSiblingIndex % 2 === 0 ? "***" : "---";
+ }
+
+ case "linkReference":
+ return concat$d(["[", printChildren$1(path, options, print), "]", node.referenceType === "full" ? concat$d(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]);
+
+ case "imageReference":
+ switch (node.referenceType) {
+ case "full":
+ return concat$d(["![", node.alt || "", "][", node.identifier, "]"]);
+
+ default:
+ return concat$d(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]);
+ }
+
+ case "definition":
+ {
+ const lineOrSpace = options.proseWrap === "always" ? line$8 : " ";
+ return group$d(concat$d([concat$d(["[", node.identifier, "]:"]), indent$8(concat$d([lineOrSpace, printUrl(node.url), node.title === null ? "" : concat$d([lineOrSpace, printTitle(node.title, options, false)])]))]));
+ }
+
+ case "footnote":
+ return concat$d(["[^", printChildren$1(path, options, print), "]"]);
+
+ case "footnoteReference":
+ return concat$d(["[^", node.identifier, "]"]);
+
+ case "footnoteDefinition":
+ {
+ const nextNode = path.getParentNode().children[path.getName() + 1];
+ const shouldInlineFootnote = node.children.length === 1 && node.children[0].type === "paragraph" && (options.proseWrap === "never" || options.proseWrap === "preserve" && node.children[0].position.start.line === node.children[0].position.end.line);
+ return concat$d(["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren$1(path, options, print) : group$d(concat$d([align$2(" ".repeat(options.tabWidth), printChildren$1(path, options, print, {
+ processor: (childPath, index) => {
+ return index === 0 ? group$d(concat$d([softline$6, childPath.call(print)])) : childPath.call(print);
+ }
+ })), nextNode && nextNode.type === "footnoteDefinition" ? softline$6 : ""]))]);
+ }
+
+ case "table":
+ return printTable(path, options, print);
+
+ case "tableCell":
+ return printChildren$1(path, options, print);
+
+ case "break":
+ return /\s/.test(options.originalText[node.position.start.offset]) ? concat$d([" ", markAsRoot$3(literalline$5)]) : concat$d(["\\", hardline$b]);
+
+ case "liquidNode":
+ return concat$d(replaceEndOfLineWith$1(node.value, hardline$b));
+ // MDX
+
+ case "importExport":
+ case "jsx":
+ return node.value;
+ // fallback to the original text if multiparser failed
+
+ case "math":
+ return concat$d(["$$", hardline$b, node.value ? concat$d([concat$d(replaceEndOfLineWith$1(node.value, hardline$b)), hardline$b]) : "", "$$"]);
+
+ case "inlineMath":
+ {
+ // remark-math trims content but we don't want to remove whitespaces
+ // since it's very possible that it's recognized as math accidentally
+ return options.originalText.slice(options.locStart(node), options.locEnd(node));
+ }
+
+ case "tableRow": // handled in "table"
+
+ case "listItem": // handled in "list"
+
+ default:
+ throw new Error(`Unknown markdown type ${JSON.stringify(node.type)}`);
+ }
+}
+
+function printListItem(path, options, print, listPrefix) {
+ const node = path.getValue();
+ const prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
+ return concat$d([prefix, printChildren$1(path, options, print, {
+ processor: (childPath, index) => {
+ if (index === 0 && childPath.getValue().type !== "list") {
+ return align$2(" ".repeat(prefix.length), childPath.call(print));
+ }
+
+ const alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
+ );
+ return concat$d([alignment, align$2(alignment, childPath.call(print))]);
+ }
+ })]);
+}
+
+function alignListPrefix(prefix, options) {
+ const additionalSpaces = getAdditionalSpaces();
+ return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
+ );
+
+ function getAdditionalSpaces() {
+ const restSpaces = prefix.length % options.tabWidth;
+ return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
+ }
+}
+
+function getNthListSiblingIndex(node, parentNode) {
+ return getNthSiblingIndex(node, parentNode, siblingNode => siblingNode.ordered === node.ordered);
+}
+
+function getNthSiblingIndex(node, parentNode, condition) {
+ condition = condition || (() => true);
+
+ let index = -1;
+
+ for (const childNode of parentNode.children) {
+ if (childNode.type === node.type && condition(childNode)) {
+ index++;
+ } else {
+ index = -1;
+ }
+
+ if (childNode === node) {
+ return index;
+ }
+ }
+}
+
+function getAncestorCounter$1(path, typeOrTypes) {
+ const types = [].concat(typeOrTypes);
+ let counter = -1;
+ let ancestorNode;
+
+ while (ancestorNode = path.getParentNode(++counter)) {
+ if (types.includes(ancestorNode.type)) {
+ return counter;
+ }
+ }
+
+ return -1;
+}
+
+function getAncestorNode$2(path, typeOrTypes) {
+ const counter = getAncestorCounter$1(path, typeOrTypes);
+ return counter === -1 ? null : path.getParentNode(counter);
+}
+
+function printLine(path, value, options) {
+ if (options.proseWrap === "preserve" && value === "\n") {
+ return hardline$b;
+ }
+
+ const isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path, SINGLE_LINE_NODE_TYPES);
+ return value !== "" ? isBreakable ? line$8 : " " : isBreakable ? softline$6 : "";
+}
+
+function printTable(path, options, print) {
+ const hardlineWithoutBreakParent = hardline$b.parts[0];
+ const node = path.getValue();
+ const contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
+
+ path.map(rowPath => {
+ const rowContents = [];
+ rowPath.map(cellPath => {
+ rowContents.push(printDocToString$3(cellPath.call(print), options).formatted);
+ }, "children");
+ contents.push(rowContents);
+ }, "children"); // Get the width of each column
+
+ const columnMaxWidths = contents.reduce((currentWidths, rowContents) => currentWidths.map((width, columnIndex) => Math.max(width, util$1.getStringWidth(rowContents[columnIndex]))), contents[0].map(() => 3) // minimum width = 3 (---, :--, :-:, --:)
+ );
+ const alignedTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$9(hardlineWithoutBreakParent, contents.slice(1).map(rowContents => printRow(rowContents)))]);
+
+ if (options.proseWrap !== "never") {
+ return concat$d([breakParent$3, alignedTable]);
+ } // Only if the --prose-wrap never is set and it exceeds the print width.
+
+
+ const compactTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0],
+ /* isCompact */
+ true), printSeparator(
+ /* isCompact */
+ true), join$9(hardlineWithoutBreakParent, contents.slice(1).map(rowContents => printRow(rowContents,
+ /* isCompact */
+ true)))]);
+ return concat$d([breakParent$3, group$d(ifBreak$5(compactTable, alignedTable))]);
+
+ function printSeparator(isCompact) {
+ return concat$d(["| ", join$9(" | ", columnMaxWidths.map((width, index) => {
+ const spaces = isCompact ? 3 : width;
+
+ switch (node.align[index]) {
+ case "left":
+ return ":" + "-".repeat(spaces - 1);
+
+ case "right":
+ return "-".repeat(spaces - 1) + ":";
+
+ case "center":
+ return ":" + "-".repeat(spaces - 2) + ":";
+
+ default:
+ return "-".repeat(spaces);
+ }
+ })), " |"]);
+ }
+
+ function printRow(rowContents, isCompact) {
+ return concat$d(["| ", join$9(" | ", isCompact ? rowContents : rowContents.map((rowContent, columnIndex) => {
+ switch (node.align[columnIndex]) {
+ case "right":
+ return alignRight(rowContent, columnMaxWidths[columnIndex]);
+
+ case "center":
+ return alignCenter(rowContent, columnMaxWidths[columnIndex]);
+
+ default:
+ return alignLeft(rowContent, columnMaxWidths[columnIndex]);
+ }
+ })), " |"]);
+ }
+
+ function alignLeft(text, width) {
+ const spaces = width - util$1.getStringWidth(text);
+ return concat$d([text, " ".repeat(spaces)]);
+ }
+
+ function alignRight(text, width) {
+ const spaces = width - util$1.getStringWidth(text);
+ return concat$d([" ".repeat(spaces), text]);
+ }
+
+ function alignCenter(text, width) {
+ const spaces = width - util$1.getStringWidth(text);
+ const left = Math.floor(spaces / 2);
+ const right = spaces - left;
+ return concat$d([" ".repeat(left), text, " ".repeat(right)]);
+ }
+}
+
+function printRoot(path, options, print) {
+ /** @typedef {{ index: number, offset: number }} IgnorePosition */
+
+ /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
+ const ignoreRanges = [];
+ /** @type {IgnorePosition | null} */
+
+ let ignoreStart = null;
+ const {
+ children
+ } = path.getValue();
+ children.forEach((childNode, index) => {
+ switch (isPrettierIgnore(childNode)) {
+ case "start":
+ if (ignoreStart === null) {
+ ignoreStart = {
+ index,
+ offset: childNode.position.end.offset
+ };
+ }
+
+ break;
+
+ case "end":
+ if (ignoreStart !== null) {
+ ignoreRanges.push({
+ start: ignoreStart,
+ end: {
+ index,
+ offset: childNode.position.start.offset
+ }
+ });
+ ignoreStart = null;
+ }
+
+ break;
+ }
+ });
+ return printChildren$1(path, options, print, {
+ processor: (childPath, index) => {
+ if (ignoreRanges.length !== 0) {
+ const ignoreRange = ignoreRanges[0];
+
+ if (index === ignoreRange.start.index) {
+ return concat$d([children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value]);
+ }
+
+ if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
+ return false;
+ }
+
+ if (index === ignoreRange.end.index) {
+ ignoreRanges.shift();
+ return false;
+ }
+ }
+
+ return childPath.call(print);
+ }
+ });
+}
+
+function printChildren$1(path, options, print, events) {
+ events = events || {};
+ const postprocessor = events.postprocessor || concat$d;
+
+ const processor = events.processor || (childPath => childPath.call(print));
+
+ const node = path.getValue();
+ const parts = [];
+ let lastChildNode;
+ path.map((childPath, index) => {
+ const childNode = childPath.getValue();
+ const result = processor(childPath, index);
+
+ if (result !== false) {
+ const data = {
+ parts,
+ prevNode: lastChildNode,
+ parentNode: node,
+ options
+ };
+
+ if (!shouldNotPrePrintHardline(childNode, data)) {
+ parts.push(hardline$b);
+
+ if (lastChildNode && TRAILING_HARDLINE_NODES.includes(lastChildNode.type)) {
+ if (shouldPrePrintTripleHardline(childNode, data)) {
+ parts.push(hardline$b);
+ }
+ } else {
+ if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
+ parts.push(hardline$b);
+ }
+
+ if (shouldPrePrintTripleHardline(childNode, data)) {
+ parts.push(hardline$b);
+ }
+ }
+ }
+
+ parts.push(result);
+ lastChildNode = childNode;
+ }
+ }, "children");
+ return postprocessor(parts);
+}
+
+function getLastDescendantNode(node) {
+ let current = node;
+
+ while (current.children && current.children.length !== 0) {
+ current = current.children[current.children.length - 1];
+ }
+
+ return current;
+}
+/** @return {false | 'next' | 'start' | 'end'} */
+
+
+function isPrettierIgnore(node) {
+ if (node.type !== "html") {
+ return false;
+ }
+
+ const match = node.value.match(/^$/);
+ return match === null ? false : match[1] ? match[1] : "next";
+}
+
+function shouldNotPrePrintHardline(node, data) {
+ const isFirstNode = data.parts.length === 0;
+ const isInlineNode = INLINE_NODE_TYPES$1.includes(node.type);
+ const isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES$1.includes(data.parentNode.type);
+ return isFirstNode || isInlineNode || isInlineHTML;
+}
+
+function shouldPrePrintDoubleHardline(node, data) {
+ const isSequence = (data.prevNode && data.prevNode.type) === node.type;
+ const isSiblingNode = isSequence && SIBLING_NODE_TYPES.includes(node.type);
+ const isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
+ const isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
+ const isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
+ const isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
+ const isHtmlDirectAfterListItem = node.type === "html" && data.parentNode.type === "listItem" && data.prevNode && data.prevNode.type === "paragraph" && data.prevNode.position.end.line + 1 === node.position.start.line;
+ return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml || isHtmlDirectAfterListItem);
+}
+
+function shouldPrePrintTripleHardline(node, data) {
+ const isPrevNodeList = data.prevNode && data.prevNode.type === "list";
+ const isIndentedCode = node.type === "code" && node.isIndented;
+ return isPrevNodeList && isIndentedCode;
+}
+
+function shouldRemainTheSameContent(path) {
+ const ancestorNode = getAncestorNode$2(path, ["linkReference", "imageReference"]);
+ return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
+}
+
+function normalizeDoc(doc) {
+ return mapDoc$4(doc, currentDoc => {
+ if (!currentDoc.parts) {
+ return currentDoc;
+ }
+
+ if (currentDoc.type === "concat" && currentDoc.parts.length === 1) {
+ return currentDoc.parts[0];
+ }
+
+ const parts = currentDoc.parts.reduce((parts, part) => {
+ if (part.type === "concat") {
+ parts.push(...part.parts);
+ } else if (part !== "") {
+ parts.push(part);
+ }
+
+ return parts;
+ }, []);
+ return Object.assign({}, currentDoc, {
+ parts: normalizeParts(parts)
+ });
+ });
+}
+
+function printUrl(url, dangerousCharOrChars) {
+ const dangerousChars = [" "].concat(dangerousCharOrChars || []);
+ return new RegExp(dangerousChars.map(x => `\\${x}`).join("|")).test(url) ? `<${url}>` : url;
+}
+
+function printTitle(title, options, printSpace) {
+ if (printSpace == null) {
+ printSpace = true;
+ }
+
+ if (!title) {
+ return "";
+ }
+
+ if (printSpace) {
+ return " " + printTitle(title, options, false);
+ }
+
+ if (title.includes('"') && title.includes("'") && !title.includes(")")) {
+ return `(${title})`; // avoid escaped quotes
+ } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
+
+
+ const singleCount = title.split("'").length - 1;
+ const doubleCount = title.split('"').length - 1;
+ const quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
+ title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
+ return `${quote}${title}${quote}`;
+}
+
+function normalizeParts(parts) {
+ return parts.reduce((current, part) => {
+ const lastPart = util$1.getLast(current);
+
+ if (typeof lastPart === "string" && typeof part === "string") {
+ current.splice(-1, 1, lastPart + part);
+ } else {
+ current.push(part);
+ }
+
+ return current;
+ }, []);
+}
+
+function clamp(value, min, max) {
+ return value < min ? min : value > max ? max : value;
+}
+
+function clean$5(ast, newObj, parent) {
+ delete newObj.position;
+ delete newObj.raw; // front-matter
+ // for codeblock
+
+ if (ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
+ delete newObj.value;
+ }
+
+ if (ast.type === "list") {
+ delete newObj.isAligned;
+ } // texts can be splitted or merged
+
+
+ if (ast.type === "text") {
+ return null;
+ }
+
+ if (ast.type === "inlineCode") {
+ newObj.value = ast.value.replace(/[ \t\n]+/g, " ");
+ } // for insert pragma
+
+
+ if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || (parent.children[0].type === "yaml" || parent.children[0].type === "toml") && parent.children[1] === ast) && ast.type === "html" && pragma$3.startWithPragma(ast.value)) {
+ return null;
+ }
+}
+
+function hasPrettierIgnore$4(path) {
+ const index = +path.getName();
+
+ if (index === 0) {
+ return false;
+ }
+
+ const prevNode = path.getParentNode().children[index - 1];
+ return isPrettierIgnore(prevNode) === "next";
+}
+
+var printerMarkdown = {
+ preprocess: preprocess_1$1,
+ print: genericPrint$4,
+ embed: embed_1$2,
+ massageAstNode: clean$5,
+ hasPrettierIgnore: hasPrettierIgnore$4,
+ insertPragma: pragma$3.insertPragma
+};
+
+var options$5 = {
+ proseWrap: commonOptions.proseWrap,
+ singleQuote: commonOptions.singleQuote
+};
+
+var name$f = "Markdown";
+var type$d = "prose";
+var aliases$4 = [
+ "pandoc"
+];
+var aceMode$d = "markdown";
+var codemirrorMode$a = "gfm";
+var codemirrorMimeType$a = "text/x-gfm";
+var wrap = true;
+var extensions$d = [
+ ".md",
+ ".markdown",
+ ".mdown",
+ ".mdwn",
+ ".mdx",
+ ".mkd",
+ ".mkdn",
+ ".mkdown",
+ ".ronn",
+ ".workbook"
+];
+var filenames$3 = [
+ "contents.lr"
+];
+var tmScope$d = "source.gfm";
+var languageId$d = 222;
+var Markdown = {
+ name: name$f,
+ type: type$d,
+ aliases: aliases$4,
+ aceMode: aceMode$d,
+ codemirrorMode: codemirrorMode$a,
+ codemirrorMimeType: codemirrorMimeType$a,
+ wrap: wrap,
+ extensions: extensions$d,
+ filenames: filenames$3,
+ tmScope: tmScope$d,
+ languageId: languageId$d
+};
+
+var Markdown$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$f,
+ type: type$d,
+ aliases: aliases$4,
+ aceMode: aceMode$d,
+ codemirrorMode: codemirrorMode$a,
+ codemirrorMimeType: codemirrorMimeType$a,
+ wrap: wrap,
+ extensions: extensions$d,
+ filenames: filenames$3,
+ tmScope: tmScope$d,
+ languageId: languageId$d,
+ 'default': Markdown
+});
+
+var require$$0$5 = getCjsExportFromNamespace(Markdown$1);
+
+const languages$4 = [createLanguage(require$$0$5, data => ({
+ since: "1.8.0",
+ parsers: ["markdown"],
+ vscodeLanguageIds: ["markdown"],
+ filenames: data.filenames.concat(["README"]),
+ extensions: data.extensions.filter(extension => extension !== ".mdx")
+})), createLanguage(require$$0$5, () => ({
+ name: "MDX",
+ since: "1.15.0",
+ parsers: ["mdx"],
+ vscodeLanguageIds: ["mdx"],
+ filenames: [],
+ extensions: [".mdx"]
+}))];
+const printers$4 = {
+ mdast: printerMarkdown
+};
+var languageMarkdown = {
+ languages: languages$4,
+ options: options$5,
+ printers: printers$4
+};
+
+var clean$6 = function (ast, newNode) {
+ delete newNode.sourceSpan;
+ delete newNode.startSourceSpan;
+ delete newNode.endSourceSpan;
+ delete newNode.nameSpan;
+ delete newNode.valueSpan;
+
+ if (ast.type === "text" || ast.type === "comment") {
+ return null;
+ } // may be formatted by multiparser
+
+
+ if (ast.type === "yaml" || ast.type === "toml") {
+ return null;
+ }
+
+ if (ast.type === "attribute") {
+ delete newNode.value;
+ }
+
+ if (ast.type === "docType") {
+ delete newNode.value;
+ }
+};
+
+var json$1 = {
+ "CSS_DISPLAY_TAGS": {
+ "area": "none",
+ "base": "none",
+ "basefont": "none",
+ "datalist": "none",
+ "head": "none",
+ "link": "none",
+ "meta": "none",
+ "noembed": "none",
+ "noframes": "none",
+ "param": "none",
+ "rp": "none",
+ "script": "block",
+ "source": "block",
+ "style": "none",
+ "template": "inline",
+ "track": "block",
+ "title": "none",
+ "html": "block",
+ "body": "block",
+ "address": "block",
+ "blockquote": "block",
+ "center": "block",
+ "div": "block",
+ "figure": "block",
+ "figcaption": "block",
+ "footer": "block",
+ "form": "block",
+ "header": "block",
+ "hr": "block",
+ "legend": "block",
+ "listing": "block",
+ "main": "block",
+ "p": "block",
+ "plaintext": "block",
+ "pre": "block",
+ "xmp": "block",
+ "slot": "contents",
+ "ruby": "ruby",
+ "rt": "ruby-text",
+ "article": "block",
+ "aside": "block",
+ "h1": "block",
+ "h2": "block",
+ "h3": "block",
+ "h4": "block",
+ "h5": "block",
+ "h6": "block",
+ "hgroup": "block",
+ "nav": "block",
+ "section": "block",
+ "dir": "block",
+ "dd": "block",
+ "dl": "block",
+ "dt": "block",
+ "ol": "block",
+ "ul": "block",
+ "li": "list-item",
+ "table": "table",
+ "caption": "table-caption",
+ "colgroup": "table-column-group",
+ "col": "table-column",
+ "thead": "table-header-group",
+ "tbody": "table-row-group",
+ "tfoot": "table-footer-group",
+ "tr": "table-row",
+ "td": "table-cell",
+ "th": "table-cell",
+ "fieldset": "block",
+ "button": "inline-block",
+ "video": "inline-block",
+ "audio": "inline-block"
+ },
+ "CSS_DISPLAY_DEFAULT": "inline",
+ "CSS_WHITE_SPACE_TAGS": {
+ "listing": "pre",
+ "plaintext": "pre",
+ "pre": "pre",
+ "xmp": "pre",
+ "nobr": "nowrap",
+ "table": "initial",
+ "textarea": "pre-wrap"
+ },
+ "CSS_WHITE_SPACE_DEFAULT": "normal"
+};
+
+var index = [
+ "a",
+ "abbr",
+ "acronym",
+ "address",
+ "applet",
+ "area",
+ "article",
+ "aside",
+ "audio",
+ "b",
+ "base",
+ "basefont",
+ "bdi",
+ "bdo",
+ "bgsound",
+ "big",
+ "blink",
+ "blockquote",
+ "body",
+ "br",
+ "button",
+ "canvas",
+ "caption",
+ "center",
+ "cite",
+ "code",
+ "col",
+ "colgroup",
+ "command",
+ "content",
+ "data",
+ "datalist",
+ "dd",
+ "del",
+ "details",
+ "dfn",
+ "dialog",
+ "dir",
+ "div",
+ "dl",
+ "dt",
+ "element",
+ "em",
+ "embed",
+ "fieldset",
+ "figcaption",
+ "figure",
+ "font",
+ "footer",
+ "form",
+ "frame",
+ "frameset",
+ "h1",
+ "h2",
+ "h3",
+ "h4",
+ "h5",
+ "h6",
+ "head",
+ "header",
+ "hgroup",
+ "hr",
+ "html",
+ "i",
+ "iframe",
+ "image",
+ "img",
+ "input",
+ "ins",
+ "isindex",
+ "kbd",
+ "keygen",
+ "label",
+ "legend",
+ "li",
+ "link",
+ "listing",
+ "main",
+ "map",
+ "mark",
+ "marquee",
+ "math",
+ "menu",
+ "menuitem",
+ "meta",
+ "meter",
+ "multicol",
+ "nav",
+ "nextid",
+ "nobr",
+ "noembed",
+ "noframes",
+ "noscript",
+ "object",
+ "ol",
+ "optgroup",
+ "option",
+ "output",
+ "p",
+ "param",
+ "picture",
+ "plaintext",
+ "pre",
+ "progress",
+ "q",
+ "rb",
+ "rbc",
+ "rp",
+ "rt",
+ "rtc",
+ "ruby",
+ "s",
+ "samp",
+ "script",
+ "section",
+ "select",
+ "shadow",
+ "slot",
+ "small",
+ "source",
+ "spacer",
+ "span",
+ "strike",
+ "strong",
+ "style",
+ "sub",
+ "summary",
+ "sup",
+ "svg",
+ "table",
+ "tbody",
+ "td",
+ "template",
+ "textarea",
+ "tfoot",
+ "th",
+ "thead",
+ "time",
+ "title",
+ "tr",
+ "track",
+ "tt",
+ "u",
+ "ul",
+ "var",
+ "video",
+ "wbr",
+ "xmp"
+];
+
+var htmlTagNames = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ 'default': index
+});
+
+var a = [
+ "accesskey",
+ "charset",
+ "coords",
+ "download",
+ "href",
+ "hreflang",
+ "name",
+ "ping",
+ "referrerpolicy",
+ "rel",
+ "rev",
+ "shape",
+ "tabindex",
+ "target",
+ "type"
+];
+var abbr = [
+ "title"
+];
+var applet = [
+ "align",
+ "alt",
+ "archive",
+ "code",
+ "codebase",
+ "height",
+ "hspace",
+ "name",
+ "object",
+ "vspace",
+ "width"
+];
+var area = [
+ "accesskey",
+ "alt",
+ "coords",
+ "download",
+ "href",
+ "hreflang",
+ "nohref",
+ "ping",
+ "referrerpolicy",
+ "rel",
+ "shape",
+ "tabindex",
+ "target",
+ "type"
+];
+var audio = [
+ "autoplay",
+ "controls",
+ "crossorigin",
+ "loop",
+ "muted",
+ "preload",
+ "src"
+];
+var base = [
+ "href",
+ "target"
+];
+var basefont = [
+ "color",
+ "face",
+ "size"
+];
+var bdo = [
+ "dir"
+];
+var blockquote = [
+ "cite"
+];
+var body = [
+ "alink",
+ "background",
+ "bgcolor",
+ "link",
+ "text",
+ "vlink"
+];
+var br = [
+ "clear"
+];
+var button = [
+ "accesskey",
+ "autofocus",
+ "disabled",
+ "form",
+ "formaction",
+ "formenctype",
+ "formmethod",
+ "formnovalidate",
+ "formtarget",
+ "name",
+ "tabindex",
+ "type",
+ "value"
+];
+var canvas = [
+ "height",
+ "width"
+];
+var caption = [
+ "align"
+];
+var col = [
+ "align",
+ "char",
+ "charoff",
+ "span",
+ "valign",
+ "width"
+];
+var colgroup = [
+ "align",
+ "char",
+ "charoff",
+ "span",
+ "valign",
+ "width"
+];
+var data = [
+ "value"
+];
+var del$1 = [
+ "cite",
+ "datetime"
+];
+var details = [
+ "open"
+];
+var dfn = [
+ "title"
+];
+var dialog = [
+ "open"
+];
+var dir = [
+ "compact"
+];
+var div = [
+ "align"
+];
+var dl = [
+ "compact"
+];
+var embed$3 = [
+ "height",
+ "src",
+ "type",
+ "width"
+];
+var fieldset = [
+ "disabled",
+ "form",
+ "name"
+];
+var font = [
+ "color",
+ "face",
+ "size"
+];
+var form = [
+ "accept",
+ "accept-charset",
+ "action",
+ "autocomplete",
+ "enctype",
+ "method",
+ "name",
+ "novalidate",
+ "target"
+];
+var frame = [
+ "frameborder",
+ "longdesc",
+ "marginheight",
+ "marginwidth",
+ "name",
+ "noresize",
+ "scrolling",
+ "src"
+];
+var frameset = [
+ "cols",
+ "rows"
+];
+var h1 = [
+ "align"
+];
+var h2 = [
+ "align"
+];
+var h3 = [
+ "align"
+];
+var h4 = [
+ "align"
+];
+var h5 = [
+ "align"
+];
+var h6 = [
+ "align"
+];
+var head = [
+ "profile"
+];
+var hr = [
+ "align",
+ "noshade",
+ "size",
+ "width"
+];
+var html = [
+ "manifest",
+ "version"
+];
+var iframe = [
+ "align",
+ "allow",
+ "allowfullscreen",
+ "allowpaymentrequest",
+ "allowusermedia",
+ "frameborder",
+ "height",
+ "longdesc",
+ "marginheight",
+ "marginwidth",
+ "name",
+ "referrerpolicy",
+ "sandbox",
+ "scrolling",
+ "src",
+ "srcdoc",
+ "width"
+];
+var img = [
+ "align",
+ "alt",
+ "border",
+ "crossorigin",
+ "decoding",
+ "height",
+ "hspace",
+ "ismap",
+ "longdesc",
+ "name",
+ "referrerpolicy",
+ "sizes",
+ "src",
+ "srcset",
+ "usemap",
+ "vspace",
+ "width"
+];
+var input = [
+ "accept",
+ "accesskey",
+ "align",
+ "alt",
+ "autocomplete",
+ "autofocus",
+ "checked",
+ "dirname",
+ "disabled",
+ "form",
+ "formaction",
+ "formenctype",
+ "formmethod",
+ "formnovalidate",
+ "formtarget",
+ "height",
+ "ismap",
+ "list",
+ "max",
+ "maxlength",
+ "min",
+ "minlength",
+ "multiple",
+ "name",
+ "pattern",
+ "placeholder",
+ "readonly",
+ "required",
+ "size",
+ "src",
+ "step",
+ "tabindex",
+ "title",
+ "type",
+ "usemap",
+ "value",
+ "width"
+];
+var ins = [
+ "cite",
+ "datetime"
+];
+var isindex = [
+ "prompt"
+];
+var label = [
+ "accesskey",
+ "for",
+ "form"
+];
+var legend = [
+ "accesskey",
+ "align"
+];
+var li = [
+ "type",
+ "value"
+];
+var link$3 = [
+ "as",
+ "charset",
+ "color",
+ "crossorigin",
+ "href",
+ "hreflang",
+ "imagesizes",
+ "imagesrcset",
+ "integrity",
+ "media",
+ "nonce",
+ "referrerpolicy",
+ "rel",
+ "rev",
+ "sizes",
+ "target",
+ "title",
+ "type"
+];
+var map$1 = [
+ "name"
+];
+var menu = [
+ "compact"
+];
+var meta = [
+ "charset",
+ "content",
+ "http-equiv",
+ "name",
+ "scheme"
+];
+var meter = [
+ "high",
+ "low",
+ "max",
+ "min",
+ "optimum",
+ "value"
+];
+var object = [
+ "align",
+ "archive",
+ "border",
+ "classid",
+ "codebase",
+ "codetype",
+ "data",
+ "declare",
+ "form",
+ "height",
+ "hspace",
+ "name",
+ "standby",
+ "tabindex",
+ "type",
+ "typemustmatch",
+ "usemap",
+ "vspace",
+ "width"
+];
+var ol = [
+ "compact",
+ "reversed",
+ "start",
+ "type"
+];
+var optgroup = [
+ "disabled",
+ "label"
+];
+var option = [
+ "disabled",
+ "label",
+ "selected",
+ "value"
+];
+var output = [
+ "for",
+ "form",
+ "name"
+];
+var p = [
+ "align"
+];
+var param = [
+ "name",
+ "type",
+ "value",
+ "valuetype"
+];
+var pre = [
+ "width"
+];
+var progress = [
+ "max",
+ "value"
+];
+var q = [
+ "cite"
+];
+var script = [
+ "async",
+ "charset",
+ "crossorigin",
+ "defer",
+ "integrity",
+ "language",
+ "nomodule",
+ "nonce",
+ "referrerpolicy",
+ "src",
+ "type"
+];
+var select = [
+ "autocomplete",
+ "autofocus",
+ "disabled",
+ "form",
+ "multiple",
+ "name",
+ "required",
+ "size",
+ "tabindex"
+];
+var slot = [
+ "name"
+];
+var source$1 = [
+ "media",
+ "sizes",
+ "src",
+ "srcset",
+ "type"
+];
+var style = [
+ "media",
+ "nonce",
+ "title",
+ "type"
+];
+var table = [
+ "align",
+ "bgcolor",
+ "border",
+ "cellpadding",
+ "cellspacing",
+ "frame",
+ "rules",
+ "summary",
+ "width"
+];
+var tbody = [
+ "align",
+ "char",
+ "charoff",
+ "valign"
+];
+var td = [
+ "abbr",
+ "align",
+ "axis",
+ "bgcolor",
+ "char",
+ "charoff",
+ "colspan",
+ "headers",
+ "height",
+ "nowrap",
+ "rowspan",
+ "scope",
+ "valign",
+ "width"
+];
+var textarea = [
+ "accesskey",
+ "autocomplete",
+ "autofocus",
+ "cols",
+ "dirname",
+ "disabled",
+ "form",
+ "maxlength",
+ "minlength",
+ "name",
+ "placeholder",
+ "readonly",
+ "required",
+ "rows",
+ "tabindex",
+ "wrap"
+];
+var tfoot = [
+ "align",
+ "char",
+ "charoff",
+ "valign"
+];
+var th = [
+ "abbr",
+ "align",
+ "axis",
+ "bgcolor",
+ "char",
+ "charoff",
+ "colspan",
+ "headers",
+ "height",
+ "nowrap",
+ "rowspan",
+ "scope",
+ "valign",
+ "width"
+];
+var thead = [
+ "align",
+ "char",
+ "charoff",
+ "valign"
+];
+var time = [
+ "datetime"
+];
+var tr = [
+ "align",
+ "bgcolor",
+ "char",
+ "charoff",
+ "valign"
+];
+var track = [
+ "default",
+ "kind",
+ "label",
+ "src",
+ "srclang"
+];
+var ul = [
+ "compact",
+ "type"
+];
+var video = [
+ "autoplay",
+ "controls",
+ "crossorigin",
+ "height",
+ "loop",
+ "muted",
+ "playsinline",
+ "poster",
+ "preload",
+ "src",
+ "width"
+];
+var index$1 = {
+ "*": [
+ "accesskey",
+ "autocapitalize",
+ "autofocus",
+ "class",
+ "contenteditable",
+ "dir",
+ "draggable",
+ "enterkeyhint",
+ "hidden",
+ "id",
+ "inputmode",
+ "is",
+ "itemid",
+ "itemprop",
+ "itemref",
+ "itemscope",
+ "itemtype",
+ "lang",
+ "nonce",
+ "slot",
+ "spellcheck",
+ "style",
+ "tabindex",
+ "title",
+ "translate"
+],
+ a: a,
+ abbr: abbr,
+ applet: applet,
+ area: area,
+ audio: audio,
+ base: base,
+ basefont: basefont,
+ bdo: bdo,
+ blockquote: blockquote,
+ body: body,
+ br: br,
+ button: button,
+ canvas: canvas,
+ caption: caption,
+ col: col,
+ colgroup: colgroup,
+ data: data,
+ del: del$1,
+ details: details,
+ dfn: dfn,
+ dialog: dialog,
+ dir: dir,
+ div: div,
+ dl: dl,
+ embed: embed$3,
+ fieldset: fieldset,
+ font: font,
+ form: form,
+ frame: frame,
+ frameset: frameset,
+ h1: h1,
+ h2: h2,
+ h3: h3,
+ h4: h4,
+ h5: h5,
+ h6: h6,
+ head: head,
+ hr: hr,
+ html: html,
+ iframe: iframe,
+ img: img,
+ input: input,
+ ins: ins,
+ isindex: isindex,
+ label: label,
+ legend: legend,
+ li: li,
+ link: link$3,
+ map: map$1,
+ menu: menu,
+ meta: meta,
+ meter: meter,
+ object: object,
+ ol: ol,
+ optgroup: optgroup,
+ option: option,
+ output: output,
+ p: p,
+ param: param,
+ pre: pre,
+ progress: progress,
+ q: q,
+ script: script,
+ select: select,
+ slot: slot,
+ source: source$1,
+ style: style,
+ table: table,
+ tbody: tbody,
+ td: td,
+ textarea: textarea,
+ tfoot: tfoot,
+ th: th,
+ thead: thead,
+ time: time,
+ tr: tr,
+ track: track,
+ ul: ul,
+ video: video
+};
+
+var htmlElementAttributes = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ a: a,
+ abbr: abbr,
+ applet: applet,
+ area: area,
+ audio: audio,
+ base: base,
+ basefont: basefont,
+ bdo: bdo,
+ blockquote: blockquote,
+ body: body,
+ br: br,
+ button: button,
+ canvas: canvas,
+ caption: caption,
+ col: col,
+ colgroup: colgroup,
+ data: data,
+ del: del$1,
+ details: details,
+ dfn: dfn,
+ dialog: dialog,
+ dir: dir,
+ div: div,
+ dl: dl,
+ embed: embed$3,
+ fieldset: fieldset,
+ font: font,
+ form: form,
+ frame: frame,
+ frameset: frameset,
+ h1: h1,
+ h2: h2,
+ h3: h3,
+ h4: h4,
+ h5: h5,
+ h6: h6,
+ head: head,
+ hr: hr,
+ html: html,
+ iframe: iframe,
+ img: img,
+ input: input,
+ ins: ins,
+ isindex: isindex,
+ label: label,
+ legend: legend,
+ li: li,
+ link: link$3,
+ map: map$1,
+ menu: menu,
+ meta: meta,
+ meter: meter,
+ object: object,
+ ol: ol,
+ optgroup: optgroup,
+ option: option,
+ output: output,
+ p: p,
+ param: param,
+ pre: pre,
+ progress: progress,
+ q: q,
+ script: script,
+ select: select,
+ slot: slot,
+ source: source$1,
+ style: style,
+ table: table,
+ tbody: tbody,
+ td: td,
+ textarea: textarea,
+ tfoot: tfoot,
+ th: th,
+ thead: thead,
+ time: time,
+ tr: tr,
+ track: track,
+ ul: ul,
+ video: video,
+ 'default': index$1
+});
+
+var htmlTagNames$1 = getCjsExportFromNamespace(htmlTagNames);
+
+var htmlElementAttributes$1 = getCjsExportFromNamespace(htmlElementAttributes);
+
+const {
+ CSS_DISPLAY_TAGS,
+ CSS_DISPLAY_DEFAULT,
+ CSS_WHITE_SPACE_TAGS,
+ CSS_WHITE_SPACE_DEFAULT
+} = json$1;
+const HTML_TAGS = arrayToMap(htmlTagNames$1);
+const HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes$1, arrayToMap);
+
+function arrayToMap(array) {
+ const map = Object.create(null);
+
+ for (const value of array) {
+ map[value] = true;
+ }
+
+ return map;
+}
+
+function mapObject(object, fn) {
+ const newObject = Object.create(null);
+
+ for (const key of Object.keys(object)) {
+ newObject[key] = fn(object[key], key);
+ }
+
+ return newObject;
+}
+
+function shouldPreserveContent(node, options) {
+ if (!node.endSourceSpan) {
+ return false;
+ }
+
+ if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") {
+ return true;
+ } // unterminated node in ie conditional comment
+ // e.g.
+
+
+ if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
+ return true;
+ } // incomplete html in ie conditional comment
+ // e.g.
+
+
+ if (node.type === "ieConditionalComment" && !node.complete) {
+ return true;
+ } // top-level elements (excluding ,
+ * css``
+ * css.global``
+ * css.resolve``
+ */
+
+
+function isStyledJsx(path) {
+ const node = path.getValue();
+ const parent = path.getParentNode();
+ const parentParent = path.getParentNode(1);
+ return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(attribute => attribute.name.name === "jsx") || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "Identifier" && parent.tag.name === "css" || parent && parent.type === "TaggedTemplateExpression" && parent.tag.type === "MemberExpression" && parent.tag.object.name === "css" && (parent.tag.property.name === "global" || parent.tag.property.name === "resolve");
+}
+/**
+ * Angular Components can have:
+ * - Inline HTML template
+ * - Inline CSS styles
+ *
+ * ...which are both within template literals somewhere
+ * inside of the Component decorator factory.
+ *
+ * E.g.
+ * @Component({
+ * template: `...
`,
+ * styles: [`h1 { color: blue; }`]
+ * })
+ */
+
+
+function isAngularComponentStyles(path) {
+ return path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "ArrayExpression" && name === "elements", (node, name) => (node.type === "Property" || node.type === "ObjectProperty") && node.key.type === "Identifier" && node.key.name === "styles" && name === "value", ...angularComponentObjectExpressionPredicates);
+}
+
+function isAngularComponentTemplate(path) {
+ return path.match(node => node.type === "TemplateLiteral", (node, name) => (node.type === "Property" || node.type === "ObjectProperty") && node.key.type === "Identifier" && node.key.name === "template" && name === "value", ...angularComponentObjectExpressionPredicates);
+}
+
+const angularComponentObjectExpressionPredicates = [(node, name) => node.type === "ObjectExpression" && name === "properties", (node, name) => node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments", (node, name) => node.type === "Decorator" && name === "expression"];
+/**
+ * styled-components template literals
+ */
+
+function isStyledComponents(path) {
+ const parent = path.getParentNode();
+
+ if (!parent || parent.type !== "TaggedTemplateExpression") {
+ return false;
+ }
+
+ const {
+ tag
+ } = parent;
+
+ switch (tag.type) {
+ case "MemberExpression":
+ return (// styled.foo``
+ isStyledIdentifier(tag.object) || // Component.extend``
+ isStyledExtend(tag)
+ );
+
+ case "CallExpression":
+ return (// styled(Component)``
+ isStyledIdentifier(tag.callee) || tag.callee.type === "MemberExpression" && (tag.callee.object.type === "MemberExpression" && ( // styled.foo.attrs({})``
+ isStyledIdentifier(tag.callee.object.object) || // Component.extend.attrs({})``
+ isStyledExtend(tag.callee.object)) || // styled(Component).attrs({})``
+ tag.callee.object.type === "CallExpression" && isStyledIdentifier(tag.callee.object.callee))
+ );
+
+ case "Identifier":
+ // css``
+ return tag.name === "css";
+
+ default:
+ return false;
+ }
+}
+/**
+ * JSX element with CSS prop
+ */
+
+
+function isCssProp(path) {
+ const parent = path.getParentNode();
+ const parentParent = path.getParentNode(1);
+ return parentParent && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" && parentParent.name.type === "JSXIdentifier" && parentParent.name.name === "css";
+}
+
+function isStyledIdentifier(node) {
+ return node.type === "Identifier" && node.name === "styled";
+}
+
+function isStyledExtend(node) {
+ return /^[A-Z]/.test(node.object.name) && node.property.name === "extend";
+}
+/*
+ * react-relay and graphql-tag
+ * graphql`...`
+ * graphql.experimental`...`
+ * gql`...`
+ * GraphQL comment block
+ *
+ * This intentionally excludes Relay Classic tags, as Prettier does not
+ * support Relay Classic formatting.
+ */
+
+
+function isGraphQL(path) {
+ const node = path.getValue();
+ const parent = path.getParentNode();
+ return hasLanguageComment(node, "GraphQL") || parent && (parent.type === "TaggedTemplateExpression" && (parent.tag.type === "MemberExpression" && parent.tag.object.name === "graphql" && parent.tag.property.name === "experimental" || parent.tag.type === "Identifier" && (parent.tag.name === "gql" || parent.tag.name === "graphql")) || parent.type === "CallExpression" && parent.callee.type === "Identifier" && parent.callee.name === "graphql");
+}
+
+function hasLanguageComment(node, languageName) {
+ // This checks for a leading comment that is exactly `/* GraphQL */`
+ // In order to be in line with other implementations of this comment tag
+ // we will not trim the comment value and we will expect exactly one space on
+ // either side of the GraphQL string
+ // Also see ./clean.js
+ return hasLeadingComment$1(node, comment => isBlockComment$1(comment) && comment.value === ` ${languageName} `);
+}
+/**
+ * - html`...`
+ * - HTML comment block
+ */
+
+
+function isHtml(path) {
+ return hasLanguageComment(path.getValue(), "HTML") || path.match(node => node.type === "TemplateLiteral", (node, name) => node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi");
+} // The counter is needed to distinguish nested embeds.
+
+
+let htmlTemplateLiteralCounter = 0;
+
+function printHtmlTemplateLiteral(path, print, textToDoc, parser, options) {
+ const node = path.getValue();
+ const counter = htmlTemplateLiteralCounter;
+ htmlTemplateLiteralCounter = htmlTemplateLiteralCounter + 1 >>> 0;
+
+ const composePlaceholder = index => `PRETTIER_HTML_PLACEHOLDER_${index}_${counter}_IN_JS`;
+
+ const text = node.quasis.map((quasi, index, quasis) => index === quasis.length - 1 ? quasi.value.cooked : quasi.value.cooked + composePlaceholder(index)).join("");
+ const expressionDocs = path.map(print, "expressions");
+
+ if (expressionDocs.length === 0 && text.trim().length === 0) {
+ return "``";
+ }
+
+ const placeholderRegex = new RegExp(composePlaceholder("(\\d+)"), "g");
+ let topLevelCount = 0;
+ const contentDoc = mapDoc$1(stripTrailingHardline$1(textToDoc(text, {
+ parser,
+
+ __onHtmlRoot(root) {
+ topLevelCount = root.children.length;
+ }
+
+ })), doc => {
+ if (typeof doc !== "string") {
+ return doc;
+ }
+
+ const parts = [];
+ const components = doc.split(placeholderRegex);
+
+ for (let i = 0; i < components.length; i++) {
+ let component = components[i];
+
+ if (i % 2 === 0) {
+ if (component) {
+ component = uncook(component);
+
+ if (options.embeddedInHtml) {
+ component = component.replace(/<\/(script)\b/gi, "<\\/$1");
+ }
+
+ parts.push(component);
+ }
+
+ continue;
+ }
+
+ const placeholderIndex = +component;
+ parts.push(concat$4(["${", group$1(expressionDocs[placeholderIndex]), "}"]));
+ }
+
+ return concat$4(parts);
+ });
+ const leadingWhitespace = /^\s/.test(text) ? " " : "";
+ const trailingWhitespace = /\s$/.test(text) ? " " : "";
+ const linebreak = options.htmlWhitespaceSensitivity === "ignore" ? hardline$3 : leadingWhitespace && trailingWhitespace ? line$2 : null;
+
+ if (linebreak) {
+ return group$1(concat$4(["`", indent$2(concat$4([linebreak, group$1(contentDoc)])), linebreak, "`"]));
+ }
+
+ return group$1(concat$4(["`", leadingWhitespace, topLevelCount > 1 ? indent$2(group$1(contentDoc)) : group$1(contentDoc), trailingWhitespace, "`"]));
+}
+
+var embed_1 = embed;
+
+function clean(ast, newObj, parent) {
+ ["range", "raw", "comments", "leadingComments", "trailingComments", "innerComments", "extra", "start", "end", "flags", "errors"].forEach(name => {
+ delete newObj[name];
+ });
+
+ if (ast.loc && ast.loc.source === null) {
+ delete newObj.loc.source;
+ }
+
+ if (ast.type === "BigIntLiteral") {
+ newObj.value = newObj.value.toLowerCase();
+ } // We remove extra `;` and add them when needed
+
+
+ if (ast.type === "EmptyStatement") {
+ return null;
+ } // We move text around, including whitespaces and add {" "}
+
+
+ if (ast.type === "JSXText") {
+ return null;
+ }
+
+ if (ast.type === "JSXExpressionContainer" && ast.expression.type === "Literal" && ast.expression.value === " ") {
+ return null;
+ } // (TypeScript) Ignore `static` in `constructor(static p) {}`
+ // and `export` in `constructor(export p) {}`
+
+
+ if (ast.type === "TSParameterProperty" && ast.accessibility === null && !ast.readonly) {
+ return {
+ type: "Identifier",
+ name: ast.parameter.name,
+ typeAnnotation: newObj.parameter.typeAnnotation,
+ decorators: newObj.decorators
+ };
+ } // (TypeScript) ignore empty `specifiers` array
+
+
+ if (ast.type === "TSNamespaceExportDeclaration" && ast.specifiers && ast.specifiers.length === 0) {
+ delete newObj.specifiers;
+ } // We convert to
+
+
+ if (ast.type === "JSXOpeningElement") {
+ delete newObj.selfClosing;
+ }
+
+ if (ast.type === "JSXElement") {
+ delete newObj.closingElement;
+ } // We change {'key': value} into {key: value}
+
+
+ if ((ast.type === "Property" || ast.type === "ObjectProperty" || ast.type === "MethodDefinition" || ast.type === "ClassProperty" || ast.type === "TSPropertySignature" || ast.type === "ObjectTypeProperty") && typeof ast.key === "object" && ast.key && (ast.key.type === "Literal" || ast.key.type === "StringLiteral" || ast.key.type === "Identifier")) {
+ delete newObj.key;
+ }
+
+ if (ast.type === "OptionalMemberExpression" && ast.optional === false) {
+ newObj.type = "MemberExpression";
+ delete newObj.optional;
+ } // Remove raw and cooked values from TemplateElement when it's CSS
+ // styled-jsx
+
+
+ if (ast.type === "JSXElement" && ast.openingElement.name.name === "style" && ast.openingElement.attributes.some(attr => attr.name.name === "jsx")) {
+ const templateLiterals = newObj.children.filter(child => child.type === "JSXExpressionContainer" && child.expression.type === "TemplateLiteral").map(container => container.expression);
+ const quasis = templateLiterals.reduce((quasis, templateLiteral) => quasis.concat(templateLiteral.quasis), []);
+ quasis.forEach(q => delete q.value);
+ } // CSS template literals in css prop
+
+
+ if (ast.type === "JSXAttribute" && ast.name.name === "css" && ast.value.type === "JSXExpressionContainer" && ast.value.expression.type === "TemplateLiteral") {
+ newObj.value.expression.quasis.forEach(q => delete q.value);
+ } // Angular Components: Inline HTML template and Inline CSS styles
+
+
+ const expression = ast.expression || ast.callee;
+
+ if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
+ const astProps = ast.expression.arguments[0].properties;
+ newObj.expression.arguments[0].properties.forEach((prop, index) => {
+ let templateLiteral = null;
+
+ switch (astProps[index].key.name) {
+ case "styles":
+ if (prop.value.type === "ArrayExpression") {
+ templateLiteral = prop.value.elements[0];
+ }
+
+ break;
+
+ case "template":
+ if (prop.value.type === "TemplateLiteral") {
+ templateLiteral = prop.value;
+ }
+
+ break;
+ }
+
+ if (templateLiteral) {
+ templateLiteral.quasis.forEach(q => delete q.value);
+ }
+ });
+ } // styled-components, graphql, markdown
+
+
+ if (ast.type === "TaggedTemplateExpression" && (ast.tag.type === "MemberExpression" || ast.tag.type === "Identifier" && (ast.tag.name === "gql" || ast.tag.name === "graphql" || ast.tag.name === "css" || ast.tag.name === "md" || ast.tag.name === "markdown" || ast.tag.name === "html") || ast.tag.type === "CallExpression")) {
+ newObj.quasi.quasis.forEach(quasi => delete quasi.value);
+ }
+
+ if (ast.type === "TemplateLiteral") {
+ // This checks for a leading comment that is exactly `/* GraphQL */`
+ // In order to be in line with other implementations of this comment tag
+ // we will not trim the comment value and we will expect exactly one space on
+ // either side of the GraphQL string
+ // Also see ./embed.js
+ const hasLanguageComment = ast.leadingComments && ast.leadingComments.some(comment => comment.type === "CommentBlock" && ["GraphQL", "HTML"].some(languageName => comment.value === ` ${languageName} `));
+
+ if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql") {
+ newObj.quasis.forEach(quasi => delete quasi.value);
+ }
+ }
+}
+
+var clean_1 = clean;
+
+const detectNewline = string => {
+ if (typeof string !== 'string') {
+ throw new TypeError('Expected a string');
+ }
+
+ const newlines = string.match(/(?:\r?\n)/g) || [];
+
+ if (newlines.length === 0) {
+ return;
+ }
+
+ const crlf = newlines.filter(newline => newline === '\r\n').length;
+ const lf = newlines.length - crlf;
+ return crlf > lf ? '\r\n' : '\n';
+};
+
+var detectNewline_1 = detectNewline;
+
+var graceful = string => typeof string === 'string' && detectNewline(string) || '\n';
+detectNewline_1.graceful = graceful;
+
+var build = createCommonjsModule(function (module, exports) {
+
+ Object.defineProperty(exports, '__esModule', {
+ value: true
+ });
+ exports.extract = extract;
+ exports.strip = strip;
+ exports.parse = parse;
+ exports.parseWithComments = parseWithComments;
+ exports.print = print;
+
+ function _os() {
+ const data = os;
+
+ _os = function () {
+ return data;
+ };
+
+ return data;
+ }
+
+ function _detectNewline() {
+ const data = _interopRequireDefault(detectNewline_1);
+
+ _detectNewline = function () {
+ return data;
+ };
+
+ return data;
+ }
+
+ function _interopRequireDefault(obj) {
+ return obj && obj.__esModule ? obj : {
+ default: obj
+ };
+ }
+ /**
+ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+
+ const commentEndRe = /\*\/$/;
+ const commentStartRe = /^\/\*\*/;
+ const docblockRe = /^\s*(\/\*\*?(.|\r?\n)*?\*\/)/;
+ const lineCommentRe = /(^|\s+)\/\/([^\r\n]*)/g;
+ const ltrimNewlineRe = /^(\r?\n)+/;
+ const multilineRe = /(?:^|\r?\n) *(@[^\r\n]*?) *\r?\n *(?![^@\r\n]*\/\/[^]*)([^@\r\n\s][^@\r\n]+?) *\r?\n/g;
+ const propertyRe = /(?:^|\r?\n) *@(\S+) *([^\r\n]*)/g;
+ const stringStartRe = /(\r?\n|^) *\* ?/g;
+
+ function extract(contents) {
+ const match = contents.match(docblockRe);
+ return match ? match[0].trimLeft() : '';
+ }
+
+ function strip(contents) {
+ const match = contents.match(docblockRe);
+ return match && match[0] ? contents.substring(match[0].length) : contents;
+ }
+
+ function parse(docblock) {
+ return parseWithComments(docblock).pragmas;
+ }
+
+ function parseWithComments(docblock) {
+ const line = (0, _detectNewline().default)(docblock) || _os().EOL;
+
+ docblock = docblock.replace(commentStartRe, '').replace(commentEndRe, '').replace(stringStartRe, '$1'); // Normalize multi-line directives
+
+ let prev = '';
+
+ while (prev !== docblock) {
+ prev = docblock;
+ docblock = docblock.replace(multilineRe, `${line}$1 $2${line}`);
+ }
+
+ docblock = docblock.replace(ltrimNewlineRe, '').trimRight();
+ const result = Object.create(null);
+ const comments = docblock.replace(propertyRe, '').replace(ltrimNewlineRe, '').trimRight();
+ let match;
+
+ while (match = propertyRe.exec(docblock)) {
+ // strip linecomments from pragmas
+ const nextPragma = match[2].replace(lineCommentRe, '');
+
+ if (typeof result[match[1]] === 'string' || Array.isArray(result[match[1]])) {
+ result[match[1]] = [].concat(result[match[1]], nextPragma);
+ } else {
+ result[match[1]] = nextPragma;
+ }
+ }
+
+ return {
+ comments,
+ pragmas: result
+ };
+ }
+
+ function print({
+ comments = '',
+ pragmas = {}
+ }) {
+ const line = (0, _detectNewline().default)(comments) || _os().EOL;
+
+ const head = '/**';
+ const start = ' *';
+ const tail = ' */';
+ const keys = Object.keys(pragmas);
+ const printedObject = keys.map(key => printKeyValues(key, pragmas[key])).reduce((arr, next) => arr.concat(next), []).map(keyValue => start + ' ' + keyValue + line).join('');
+
+ if (!comments) {
+ if (keys.length === 0) {
+ return '';
+ }
+
+ if (keys.length === 1 && !Array.isArray(pragmas[keys[0]])) {
+ const value = pragmas[keys[0]];
+ return `${head} ${printKeyValues(keys[0], value)[0]}${tail}`;
+ }
+ }
+
+ const printedComments = comments.split(line).map(textLine => `${start} ${textLine}`).join(line) + line;
+ return head + line + (comments ? printedComments : '') + (comments && keys.length ? start + line : '') + printedObject + tail;
+ }
+
+ function printKeyValues(key, valueOrArray) {
+ return [].concat(valueOrArray).map(value => `@${key} ${value}`.trim());
+ }
+});
+unwrapExports(build);
+var build_1 = build.extract;
+var build_2 = build.strip;
+var build_3 = build.parse;
+var build_4 = build.parseWithComments;
+var build_5 = build.print;
+
+function hasPragma(text) {
+ const pragmas = Object.keys(build.parse(build.extract(text)));
+ return pragmas.includes("prettier") || pragmas.includes("format");
+}
+
+function insertPragma(text) {
+ const parsedDocblock = build.parseWithComments(build.extract(text));
+ const pragmas = Object.assign({
+ format: ""
+ }, parsedDocblock.pragmas);
+ const newDocblock = build.print({
+ pragmas,
+ comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
+
+ }).replace(/(\r\n|\r)/g, "\n"); // normalise newlines (mitigate use of os.EOL by jest-docblock)
+
+ const strippedText = build.strip(text);
+ const separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
+ return newDocblock + separatingNewlines + strippedText;
+}
+
+var pragma = {
+ hasPragma,
+ insertPragma
+};
+
+const {
+ getLast: getLast$1,
+ hasNewline: hasNewline$3,
+ hasNewlineInRange: hasNewlineInRange$2,
+ hasIgnoreComment: hasIgnoreComment$1,
+ hasNodeIgnoreComment: hasNodeIgnoreComment$1,
+ skipWhitespace: skipWhitespace$2
+} = util$1;
+const isIdentifierName = utils$1.keyword.isIdentifierNameES5; // We match any whitespace except line terminators because
+// Flow annotation comments cannot be split across lines. For example:
+//
+// (this /*
+// : any */).foo = 5;
+//
+// is not picked up by Flow (see https://github.com/facebook/flow/issues/7050), so
+// removing the newline would create a type annotation that the user did not intend
+// to create.
+
+const NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
+const FLOW_SHORTHAND_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*:`);
+const FLOW_ANNOTATION = new RegExp(`^${NON_LINE_TERMINATING_WHITE_SPACE}*::`);
+
+function hasFlowShorthandAnnotationComment(node) {
+ // https://flow.org/en/docs/types/comments/
+ // Syntax example: const r = new (window.Request /*: Class */)("");
+ return node.extra && node.extra.parenthesized && node.trailingComments && node.trailingComments[0].value.match(FLOW_SHORTHAND_ANNOTATION);
+}
+
+function hasFlowAnnotationComment(comments) {
+ return comments && comments[0].value.match(FLOW_ANNOTATION);
+}
+
+function hasNode(node, fn) {
+ if (!node || typeof node !== "object") {
+ return false;
+ }
+
+ if (Array.isArray(node)) {
+ return node.some(value => hasNode(value, fn));
+ }
+
+ const result = fn(node);
+ return typeof result === "boolean" ? result : Object.keys(node).some(key => hasNode(node[key], fn));
+}
+
+function hasNakedLeftSide(node) {
+ return node.type === "AssignmentExpression" || node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression" || node.type === "ConditionalExpression" || node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "BindExpression" || node.type === "UpdateExpression" && !node.prefix || node.type === "TSAsExpression" || node.type === "TSNonNullExpression";
+}
+
+function getLeftSide(node) {
+ if (node.expressions) {
+ return node.expressions[0];
+ }
+
+ return node.left || node.test || node.callee || node.object || node.tag || node.argument || node.expression;
+}
+
+function getLeftSidePathName(path, node) {
+ if (node.expressions) {
+ return ["expressions", 0];
+ }
+
+ if (node.left) {
+ return ["left"];
+ }
+
+ if (node.test) {
+ return ["test"];
+ }
+
+ if (node.object) {
+ return ["object"];
+ }
+
+ if (node.callee) {
+ return ["callee"];
+ }
+
+ if (node.tag) {
+ return ["tag"];
+ }
+
+ if (node.argument) {
+ return ["argument"];
+ }
+
+ if (node.expression) {
+ return ["expression"];
+ }
+
+ throw new Error("Unexpected node has no left side", node);
+}
+
+const exportDeclarationTypes = new Set(["ExportDefaultDeclaration", "ExportDefaultSpecifier", "DeclareExportDeclaration", "ExportNamedDeclaration", "ExportAllDeclaration"]);
+
+function isExportDeclaration(node) {
+ return node && exportDeclarationTypes.has(node.type);
+}
+
+function getParentExportDeclaration(path) {
+ const parentNode = path.getParentNode();
+
+ if (path.getName() === "declaration" && isExportDeclaration(parentNode)) {
+ return parentNode;
+ }
+
+ return null;
+}
+
+function isLiteral(node) {
+ return node.type === "BooleanLiteral" || node.type === "DirectiveLiteral" || node.type === "Literal" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "RegExpLiteral" || node.type === "StringLiteral" || node.type === "TemplateLiteral" || node.type === "TSTypeLiteral" || node.type === "JSXText";
+}
+
+function isNumericLiteral(node) {
+ return node.type === "NumericLiteral" || node.type === "Literal" && typeof node.value === "number";
+}
+
+function isStringLiteral(node) {
+ return node.type === "StringLiteral" || node.type === "Literal" && typeof node.value === "string";
+}
+
+function isObjectType(n) {
+ return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral";
+}
+
+function isFunctionOrArrowExpression(node) {
+ return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
+}
+
+function isFunctionOrArrowExpressionWithBody(node) {
+ return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
+}
+
+function isTemplateLiteral(node) {
+ return node.type === "TemplateLiteral";
+} // `inject` is used in AngularJS 1.x, `async` in Angular 2+
+// example: https://docs.angularjs.org/guide/unit-testing#using-beforeall-
+
+
+function isAngularTestWrapper(node) {
+ return (node.type === "CallExpression" || node.type === "OptionalCallExpression") && node.callee.type === "Identifier" && (node.callee.name === "async" || node.callee.name === "inject" || node.callee.name === "fakeAsync");
+}
+
+function isJSXNode(node) {
+ return node.type === "JSXElement" || node.type === "JSXFragment";
+}
+
+function isTheOnlyJSXElementInMarkdown(options, path) {
+ if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
+ return false;
+ }
+
+ const node = path.getNode();
+
+ if (!node.expression || !isJSXNode(node.expression)) {
+ return false;
+ }
+
+ const parent = path.getParentNode();
+ return parent.type === "Program" && parent.body.length === 1;
+} // Detect an expression node representing `{" "}`
+
+
+function isJSXWhitespaceExpression(node) {
+ return node.type === "JSXExpressionContainer" && isLiteral(node.expression) && node.expression.value === " " && !node.expression.comments;
+}
+
+function isMemberExpressionChain(node) {
+ if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") {
+ return false;
+ }
+
+ if (node.object.type === "Identifier") {
+ return true;
+ }
+
+ return isMemberExpressionChain(node.object);
+}
+
+function isGetterOrSetter(node) {
+ return node.kind === "get" || node.kind === "set";
+}
+
+function sameLocStart(nodeA, nodeB, options) {
+ return options.locStart(nodeA) === options.locStart(nodeB);
+} // TODO: This is a bad hack and we need a better way to distinguish between
+// arrow functions and otherwise
+
+
+function isFunctionNotation(node, options) {
+ return isGetterOrSetter(node) || sameLocStart(node, node.value, options);
+} // Hack to differentiate between the following two which have the same ast
+// type T = { method: () => void };
+// type T = { method(): void };
+
+
+function isObjectTypePropertyAFunction(node, options) {
+ return (node.type === "ObjectTypeProperty" || node.type === "ObjectTypeInternalSlot") && node.value.type === "FunctionTypeAnnotation" && !node.static && !isFunctionNotation(node, options);
+} // Hack to differentiate between the following two which have the same ast
+// declare function f(a): void;
+// var f: (a) => void;
+
+
+function isTypeAnnotationAFunction(node, options) {
+ return (node.type === "TypeAnnotation" || node.type === "TSTypeAnnotation") && node.typeAnnotation.type === "FunctionTypeAnnotation" && !node.static && !sameLocStart(node, node.typeAnnotation, options);
+}
+
+const binaryishNodeTypes = new Set(["BinaryExpression", "LogicalExpression", "NGPipeExpression"]);
+
+function isBinaryish(node) {
+ return binaryishNodeTypes.has(node.type);
+}
+
+function isMemberish(node) {
+ return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "BindExpression" && node.object;
+}
+
+function isSimpleFlowType(node) {
+ const flowTypeAnnotations = ["AnyTypeAnnotation", "NullLiteralTypeAnnotation", "GenericTypeAnnotation", "ThisTypeAnnotation", "NumberTypeAnnotation", "VoidTypeAnnotation", "EmptyTypeAnnotation", "MixedTypeAnnotation", "BooleanTypeAnnotation", "BooleanLiteralTypeAnnotation", "StringTypeAnnotation"];
+ return node && flowTypeAnnotations.includes(node.type) && !(node.type === "GenericTypeAnnotation" && node.typeParameters);
+}
+
+const unitTestRe = /^(skip|[fx]?(it|describe|test))$/;
+
+function isSkipOrOnlyBlock(node) {
+ return (node.callee.type === "MemberExpression" || node.callee.type === "OptionalMemberExpression") && node.callee.object.type === "Identifier" && node.callee.property.type === "Identifier" && unitTestRe.test(node.callee.object.name) && (node.callee.property.name === "only" || node.callee.property.name === "skip");
+}
+
+function isUnitTestSetUp(n) {
+ const unitTestSetUpRe = /^(before|after)(Each|All)$/;
+ return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1;
+} // eg; `describe("some string", (done) => {})`
+
+
+function isTestCall(n, parent) {
+ if (n.type !== "CallExpression") {
+ return false;
+ }
+
+ if (n.arguments.length === 1) {
+ if (isAngularTestWrapper(n) && parent && isTestCall(parent)) {
+ return isFunctionOrArrowExpression(n.arguments[0]);
+ }
+
+ if (isUnitTestSetUp(n)) {
+ return isAngularTestWrapper(n.arguments[0]);
+ }
+ } else if (n.arguments.length === 2 || n.arguments.length === 3) {
+ if ((n.callee.type === "Identifier" && unitTestRe.test(n.callee.name) || isSkipOrOnlyBlock(n)) && (isTemplateLiteral(n.arguments[0]) || isStringLiteral(n.arguments[0]))) {
+ // it("name", () => { ... }, 2500)
+ if (n.arguments[2] && !isNumericLiteral(n.arguments[2])) {
+ return false;
+ }
+
+ return (n.arguments.length === 2 ? isFunctionOrArrowExpression(n.arguments[1]) : isFunctionOrArrowExpressionWithBody(n.arguments[1]) && n.arguments[1].params.length <= 1) || isAngularTestWrapper(n.arguments[1]);
+ }
+ }
+
+ return false;
+}
+
+function hasLeadingComment$2(node) {
+ return node.comments && node.comments.some(comment => comment.leading);
+}
+
+function hasTrailingComment(node) {
+ return node.comments && node.comments.some(comment => comment.trailing);
+}
+
+function isCallOrOptionalCallExpression(node) {
+ return node.type === "CallExpression" || node.type === "OptionalCallExpression";
+}
+
+function hasDanglingComments(node) {
+ return node.comments && node.comments.some(comment => !comment.leading && !comment.trailing);
+}
+/** identify if an angular expression seems to have side effects */
+
+
+function hasNgSideEffect(path) {
+ return hasNode(path.getValue(), node => {
+ switch (node.type) {
+ case undefined:
+ return false;
+
+ case "CallExpression":
+ case "OptionalCallExpression":
+ case "AssignmentExpression":
+ return true;
+ }
+ });
+}
+
+function isNgForOf(node, index, parentNode) {
+ return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
+}
+/** @param node {import("estree").TemplateLiteral} */
+
+
+function isSimpleTemplateLiteral(node) {
+ if (node.expressions.length === 0) {
+ return false;
+ }
+
+ return node.expressions.every(expr => {
+ // Disallow comments since printDocToString can't print them here
+ if (expr.comments) {
+ return false;
+ } // Allow `x` and `this`
+
+
+ if (expr.type === "Identifier" || expr.type === "ThisExpression") {
+ return true;
+ } // Allow `a.b.c`, `a.b[c]`, and `this.x.y`
+
+
+ if (expr.type === "MemberExpression" || expr.type === "OptionalMemberExpression") {
+ let head = expr;
+
+ while (head.type === "MemberExpression" || head.type === "OptionalMemberExpression") {
+ if (head.property.type !== "Identifier" && head.property.type !== "Literal" && head.property.type !== "StringLiteral" && head.property.type !== "NumericLiteral") {
+ return false;
+ }
+
+ head = head.object;
+
+ if (head.comments) {
+ return false;
+ }
+ }
+
+ if (head.type === "Identifier" || head.type === "ThisExpression") {
+ return true;
+ }
+
+ return false;
+ }
+
+ return false;
+ });
+}
+
+function getFlowVariance(path) {
+ if (!path.variance) {
+ return null;
+ } // Babel 7.0 currently uses variance node type, and flow should
+ // follow suit soon:
+ // https://github.com/babel/babel/issues/4722
+
+
+ const variance = path.variance.kind || path.variance;
+
+ switch (variance) {
+ case "plus":
+ return "+";
+
+ case "minus":
+ return "-";
+
+ default:
+ /* istanbul ignore next */
+ return variance;
+ }
+}
+
+function classPropMayCauseASIProblems(path) {
+ const node = path.getNode();
+
+ if (node.type !== "ClassProperty") {
+ return false;
+ }
+
+ const name = node.key && node.key.name; // this isn't actually possible yet with most parsers available today
+ // so isn't properly tested yet.
+
+ if ((name === "static" || name === "get" || name === "set") && !node.value && !node.typeAnnotation) {
+ return true;
+ }
+}
+
+function classChildNeedsASIProtection(node) {
+ if (!node) {
+ return;
+ }
+
+ if (node.static || node.accessibility // TypeScript
+ ) {
+ return false;
+ }
+
+ if (!node.computed) {
+ const name = node.key && node.key.name;
+
+ if (name === "in" || name === "instanceof") {
+ return true;
+ }
+ }
+
+ switch (node.type) {
+ case "ClassProperty":
+ case "TSAbstractClassProperty":
+ return node.computed;
+
+ case "MethodDefinition": // Flow
+
+ case "TSAbstractMethodDefinition": // TypeScript
+
+ case "ClassMethod":
+ case "ClassPrivateMethod":
+ {
+ // Babel
+ const isAsync = node.value ? node.value.async : node.async;
+ const isGenerator = node.value ? node.value.generator : node.generator;
+
+ if (isAsync || node.kind === "get" || node.kind === "set") {
+ return false;
+ }
+
+ if (node.computed || isGenerator) {
+ return true;
+ }
+
+ return false;
+ }
+
+ case "TSIndexSignature":
+ return true;
+
+ default:
+ /* istanbul ignore next */
+ return false;
+ }
+}
+
+function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
+ if (tokenNode === "+") {
+ return "+" + keyword;
+ } else if (tokenNode === "-") {
+ return "-" + keyword;
+ }
+
+ return keyword;
+}
+
+function hasNewlineBetweenOrAfterDecorators(node, options) {
+ return hasNewlineInRange$2(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$1(node.decorators))) || hasNewline$3(options.originalText, options.locEnd(getLast$1(node.decorators)));
+} // Only space, newline, carriage return, and tab are treated as whitespace
+// inside JSX.
+
+
+const jsxWhitespaceChars = " \n\r\t";
+const matchJsxWhitespaceRegex = new RegExp("([" + jsxWhitespaceChars + "]+)");
+const containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]"); // Meaningful if it contains non-whitespace characters,
+// or it contains whitespace without a new line.
+
+function isMeaningfulJSXText(node) {
+ return isLiteral(node) && (containsNonJsxWhitespaceRegex.test(rawText(node)) || !/\n/.test(rawText(node)));
+}
+
+function hasJsxIgnoreComment(path) {
+ const node = path.getValue();
+ const parent = path.getParentNode();
+
+ if (!parent || !node || !isJSXNode(node) || !isJSXNode(parent)) {
+ return false;
+ } // Lookup the previous sibling, ignoring any empty JSXText elements
+
+
+ const index = parent.children.indexOf(node);
+ let prevSibling = null;
+
+ for (let i = index; i > 0; i--) {
+ const candidate = parent.children[i - 1];
+
+ if (candidate.type === "JSXText" && !isMeaningfulJSXText(candidate)) {
+ continue;
+ }
+
+ prevSibling = candidate;
+ break;
+ }
+
+ return prevSibling && prevSibling.type === "JSXExpressionContainer" && prevSibling.expression.type === "JSXEmptyExpression" && prevSibling.expression.comments && prevSibling.expression.comments.find(comment => comment.value.trim() === "prettier-ignore");
+}
+
+function isEmptyJSXElement(node) {
+ if (node.children.length === 0) {
+ return true;
+ }
+
+ if (node.children.length > 1) {
+ return false;
+ } // if there is one text child and does not contain any meaningful text
+ // we can treat the element as empty.
+
+
+ const child = node.children[0];
+ return isLiteral(child) && !isMeaningfulJSXText(child);
+}
+
+function hasPrettierIgnore(path) {
+ return hasIgnoreComment$1(path) || hasJsxIgnoreComment(path);
+}
+
+function isLastStatement(path) {
+ const parent = path.getParentNode();
+
+ if (!parent) {
+ return true;
+ }
+
+ const node = path.getValue();
+ const body = (parent.body || parent.consequent).filter(stmt => stmt.type !== "EmptyStatement");
+ return body && body[body.length - 1] === node;
+}
+
+function isFlowAnnotationComment(text, typeAnnotation, options) {
+ const start = options.locStart(typeAnnotation);
+ const end = skipWhitespace$2(text, options.locEnd(typeAnnotation));
+ return text.slice(start, start + 2) === "/*" && text.slice(end, end + 2) === "*/";
+}
+
+function hasLeadingOwnLineComment(text, node, options) {
+ if (isJSXNode(node)) {
+ return hasNodeIgnoreComment$1(node);
+ }
+
+ const res = node.comments && node.comments.some(comment => comment.leading && hasNewline$3(text, options.locEnd(comment)));
+ return res;
+} // This recurses the return argument, looking for the first token
+// (the leftmost leaf node) and, if it (or its parents) has any
+// leadingComments, returns true (so it can be wrapped in parens).
+
+
+function returnArgumentHasLeadingComment(options, argument) {
+ if (hasLeadingOwnLineComment(options.originalText, argument, options)) {
+ return true;
+ }
+
+ if (hasNakedLeftSide(argument)) {
+ let leftMost = argument;
+ let newLeftMost;
+
+ while (newLeftMost = getLeftSide(leftMost)) {
+ leftMost = newLeftMost;
+
+ if (hasLeadingOwnLineComment(options.originalText, leftMost, options)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+function isStringPropSafeToCoerceToIdentifier(node, options) {
+ return isStringLiteral(node.key) && isIdentifierName(node.key.value) && options.parser !== "json" && // With `--strictPropertyInitialization`, TS treats properties with quoted names differently than unquoted ones.
+ // See https://github.com/microsoft/TypeScript/pull/20075
+ !((options.parser === "typescript" || options.parser === "babel-ts") && node.type === "ClassProperty");
+}
+
+function isJestEachTemplateLiteral(node, parentNode) {
+ /**
+ * describe.each`table`(name, fn)
+ * describe.only.each`table`(name, fn)
+ * describe.skip.each`table`(name, fn)
+ * test.each`table`(name, fn)
+ * test.only.each`table`(name, fn)
+ * test.skip.each`table`(name, fn)
+ *
+ * Ref: https://github.com/facebook/jest/pull/6102
+ */
+ const jestEachTriggerRegex = /^[xf]?(describe|it|test)$/;
+ return parentNode.type === "TaggedTemplateExpression" && parentNode.quasi === node && parentNode.tag.type === "MemberExpression" && parentNode.tag.property.type === "Identifier" && parentNode.tag.property.name === "each" && (parentNode.tag.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.name) || parentNode.tag.object.type === "MemberExpression" && parentNode.tag.object.property.type === "Identifier" && (parentNode.tag.object.property.name === "only" || parentNode.tag.object.property.name === "skip") && parentNode.tag.object.object.type === "Identifier" && jestEachTriggerRegex.test(parentNode.tag.object.object.name));
+}
+
+function templateLiteralHasNewLines(template) {
+ return template.quasis.some(quasi => quasi.value.raw.includes("\n"));
+}
+
+function isTemplateOnItsOwnLine(n, text, options) {
+ return (n.type === "TemplateLiteral" && templateLiteralHasNewLines(n) || n.type === "TaggedTemplateExpression" && templateLiteralHasNewLines(n.quasi)) && !hasNewline$3(text, options.locStart(n), {
+ backwards: true
+ });
+}
+
+function needsHardlineAfterDanglingComment(node) {
+ if (!node.comments) {
+ return false;
+ }
+
+ const lastDanglingComment = getLast$1(node.comments.filter(comment => !comment.leading && !comment.trailing));
+ return lastDanglingComment && !comments$1.isBlockComment(lastDanglingComment);
+} // If we have nested conditional expressions, we want to print them in JSX mode
+// if there's at least one JSXElement somewhere in the tree.
+//
+// A conditional expression chain like this should be printed in normal mode,
+// because there aren't JSXElements anywhere in it:
+//
+// isA ? "A" : isB ? "B" : isC ? "C" : "Unknown";
+//
+// But a conditional expression chain like this should be printed in JSX mode,
+// because there is a JSXElement in the last ConditionalExpression:
+//
+// isA ? "A" : isB ? "B" : isC ? "C" : Unknown;
+//
+// This type of ConditionalExpression chain is structured like this in the AST:
+//
+// ConditionalExpression {
+// test: ...,
+// consequent: ...,
+// alternate: ConditionalExpression {
+// test: ...,
+// consequent: ...,
+// alternate: ConditionalExpression {
+// test: ...,
+// consequent: ...,
+// alternate: ...,
+// }
+// }
+// }
+//
+// We want to traverse over that shape and convert it into a flat structure so
+// that we can find if there's a JSXElement somewhere inside.
+
+
+function getConditionalChainContents(node) {
+ // Given this code:
+ //
+ // // Using a ConditionalExpression as the consequent is uncommon, but should
+ // // be handled.
+ // A ? B : C ? D : E ? F ? G : H : I
+ //
+ // which has this AST:
+ //
+ // ConditionalExpression {
+ // test: Identifier(A),
+ // consequent: Identifier(B),
+ // alternate: ConditionalExpression {
+ // test: Identifier(C),
+ // consequent: Identifier(D),
+ // alternate: ConditionalExpression {
+ // test: Identifier(E),
+ // consequent: ConditionalExpression {
+ // test: Identifier(F),
+ // consequent: Identifier(G),
+ // alternate: Identifier(H),
+ // },
+ // alternate: Identifier(I),
+ // }
+ // }
+ // }
+ //
+ // we should return this Array:
+ //
+ // [
+ // Identifier(A),
+ // Identifier(B),
+ // Identifier(C),
+ // Identifier(D),
+ // Identifier(E),
+ // Identifier(F),
+ // Identifier(G),
+ // Identifier(H),
+ // Identifier(I)
+ // ];
+ //
+ // This loses the information about whether each node was the test,
+ // consequent, or alternate, but we don't care about that here- we are only
+ // flattening this structure to find if there's any JSXElements inside.
+ const nonConditionalExpressions = [];
+
+ function recurse(node) {
+ if (node.type === "ConditionalExpression") {
+ recurse(node.test);
+ recurse(node.consequent);
+ recurse(node.alternate);
+ } else {
+ nonConditionalExpressions.push(node);
+ }
+ }
+
+ recurse(node);
+ return nonConditionalExpressions;
+}
+
+function conditionalExpressionChainContainsJSX(node) {
+ return Boolean(getConditionalChainContents(node).find(isJSXNode));
+} // Logic to check for args with multiple anonymous functions. For instance,
+// the following call should be split on multiple lines for readability:
+// source.pipe(map((x) => x + x), filter((x) => x % 2 === 0))
+
+
+function isFunctionCompositionArgs(args) {
+ if (args.length <= 1) {
+ return false;
+ }
+
+ let count = 0;
+
+ for (const arg of args) {
+ if (isFunctionOrArrowExpression(arg)) {
+ count += 1;
+
+ if (count > 1) {
+ return true;
+ }
+ } else if (isCallOrOptionalCallExpression(arg)) {
+ for (const childArg of arg.arguments) {
+ if (isFunctionOrArrowExpression(childArg)) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+} // Logic to determine if a call is a “long curried function call”.
+// See https://github.com/prettier/prettier/issues/1420.
+//
+// `connect(a, b, c)(d)`
+// In the above call expression, the second call is the parent node and the
+// first call is the current node.
+
+
+function isLongCurriedCallExpression(path) {
+ const node = path.getValue();
+ const parent = path.getParentNode();
+ return isCallOrOptionalCallExpression(node) && isCallOrOptionalCallExpression(parent) && parent.callee === node && node.arguments.length > parent.arguments.length && parent.arguments.length > 0;
+}
+/**
+ * @param {import('estree').Node} node
+ * @param {number} depth
+ * @returns {boolean}
+ */
+
+
+function isSimpleCallArgument(node, depth) {
+ if (depth >= 2) {
+ return false;
+ }
+
+ const isChildSimple = child => isSimpleCallArgument(child, depth + 1);
+
+ const regexpPattern = node.type === "Literal" && node.regex && node.regex.pattern || node.type === "RegExpLiteral" && node.pattern;
+
+ if (regexpPattern && regexpPattern.length > 5) {
+ return false;
+ }
+
+ if (node.type === "Literal" || node.type === "BooleanLiteral" || node.type === "NullLiteral" || node.type === "NumericLiteral" || node.type === "StringLiteral" || node.type === "Identifier" || node.type === "ThisExpression" || node.type === "Super" || node.type === "BigIntLiteral" || node.type === "PrivateName" || node.type === "ArgumentPlaceholder" || node.type === "RegExpLiteral" || node.type === "Import") {
+ return true;
+ }
+
+ if (node.type === "TemplateLiteral") {
+ return node.expressions.every(isChildSimple);
+ }
+
+ if (node.type === "ObjectExpression") {
+ return node.properties.every(p => !p.computed && (p.shorthand || p.value && isChildSimple(p.value)));
+ }
+
+ if (node.type === "ArrayExpression") {
+ return node.elements.every(x => x == null || isChildSimple(x));
+ }
+
+ if (node.type === "CallExpression" || node.type === "OptionalCallExpression" || node.type === "NewExpression") {
+ return isSimpleCallArgument(node.callee, depth) && node.arguments.every(isChildSimple);
+ }
+
+ if (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") {
+ return isSimpleCallArgument(node.object, depth) && isSimpleCallArgument(node.property, depth);
+ }
+
+ if (node.type === "UnaryExpression" && (node.operator === "!" || node.operator === "-")) {
+ return isSimpleCallArgument(node.argument, depth);
+ }
+
+ if (node.type === "TSNonNullExpression") {
+ return isSimpleCallArgument(node.expression, depth);
+ }
+
+ return false;
+}
+
+function rawText(node) {
+ return node.extra ? node.extra.raw : node.raw;
+}
+
+function identity$1(x) {
+ return x;
+}
+
+function isTSXFile(options) {
+ return options.filepath && /\.tsx$/i.test(options.filepath);
+}
+
+var utils$6 = {
+ classChildNeedsASIProtection,
+ classPropMayCauseASIProblems,
+ conditionalExpressionChainContainsJSX,
+ getFlowVariance,
+ getLeftSidePathName,
+ getParentExportDeclaration,
+ getTypeScriptMappedTypeModifier,
+ hasDanglingComments,
+ hasFlowAnnotationComment,
+ hasFlowShorthandAnnotationComment,
+ hasLeadingComment: hasLeadingComment$2,
+ hasLeadingOwnLineComment,
+ hasNakedLeftSide,
+ hasNewlineBetweenOrAfterDecorators,
+ hasNgSideEffect,
+ hasNode,
+ hasPrettierIgnore,
+ hasTrailingComment,
+ identity: identity$1,
+ isBinaryish,
+ isCallOrOptionalCallExpression,
+ isEmptyJSXElement,
+ isExportDeclaration,
+ isFlowAnnotationComment,
+ isFunctionCompositionArgs,
+ isFunctionNotation,
+ isFunctionOrArrowExpression,
+ isGetterOrSetter,
+ isJestEachTemplateLiteral,
+ isJSXNode,
+ isJSXWhitespaceExpression,
+ isLastStatement,
+ isLiteral,
+ isLongCurriedCallExpression,
+ isSimpleCallArgument,
+ isMeaningfulJSXText,
+ isMemberExpressionChain,
+ isMemberish,
+ isNgForOf,
+ isNumericLiteral,
+ isObjectType,
+ isObjectTypePropertyAFunction,
+ isSimpleFlowType,
+ isSimpleTemplateLiteral,
+ isStringLiteral,
+ isStringPropSafeToCoerceToIdentifier,
+ isTemplateOnItsOwnLine,
+ isTestCall,
+ isTheOnlyJSXElementInMarkdown,
+ isTSXFile,
+ isTypeAnnotationAFunction,
+ matchJsxWhitespaceRegex,
+ needsHardlineAfterDanglingComment,
+ rawText,
+ returnArgumentHasLeadingComment
+};
+
+const {
+ getLeftSidePathName: getLeftSidePathName$1,
+ hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$1,
+ hasNakedLeftSide: hasNakedLeftSide$1,
+ hasNode: hasNode$1
+} = utils$6;
+
+function needsParens(path, options) {
+ const parent = path.getParentNode();
+
+ if (!parent) {
+ return false;
+ }
+
+ const name = path.getName();
+ const node = path.getNode(); // If the value of this path is some child of a Node and not a Node
+ // itself, then it doesn't need parentheses. Only Node objects (in
+ // fact, only Expression nodes) need parentheses.
+
+ if (path.getValue() !== node) {
+ return false;
+ } // to avoid unexpected `}}` in HTML interpolations
+
+
+ if (options.__isInHtmlInterpolation && !options.bracketSpacing && endsWithRightBracket(node) && isFollowedByRightBracket(path)) {
+ return true;
+ } // Only statements don't need parentheses.
+
+
+ if (isStatement(node)) {
+ return false;
+ }
+
+ if ( // Preserve parens if we have a Flow annotation comment, unless we're using the Flow
+ // parser. The Flow parser turns Flow comments into type annotation nodes in its
+ // AST, which we handle separately.
+ options.parser !== "flow" && hasFlowShorthandAnnotationComment$1(path.getValue())) {
+ return true;
+ } // Identifiers never need parentheses.
+
+
+ if (node.type === "Identifier") {
+ // ...unless those identifiers are embed placeholders. They might be substituted by complex
+ // expressions, so the parens around them should not be dropped. Example (JS-in-HTML-in-JS):
+ // let tpl = html``;
+ // If the inner JS formatter removes the parens, the expression might change its meaning:
+ // f((a + b) / 2) vs f(a + b / 2)
+ if (node.extra && node.extra.parenthesized && /^PRETTIER_HTML_PLACEHOLDER_\d+_\d+_IN_JS$/.test(node.name)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ if (parent.type === "ParenthesizedExpression") {
+ return false;
+ } // Add parens around the extends clause of a class. It is needed for almost
+ // all expressions.
+
+
+ if ((parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node && (node.type === "ArrowFunctionExpression" || node.type === "AssignmentExpression" || node.type === "AwaitExpression" || node.type === "BinaryExpression" || node.type === "ConditionalExpression" || node.type === "LogicalExpression" || node.type === "NewExpression" || node.type === "ObjectExpression" || node.type === "ParenthesizedExpression" || node.type === "SequenceExpression" || node.type === "TaggedTemplateExpression" || node.type === "UnaryExpression" || node.type === "UpdateExpression" || node.type === "YieldExpression")) {
+ return true;
+ }
+
+ if (parent.type === "ExportDefaultDeclaration") {
+ return (// `export default function` or `export default class` can't be followed by
+ // anything after. So an expression like `export default (function(){}).toString()`
+ // needs to be followed by a parentheses
+ shouldWrapFunctionForExportDefault(path, options) || // `export default (foo, bar)` also needs parentheses
+ node.type === "SequenceExpression"
+ );
+ }
+
+ if (parent.type === "Decorator" && parent.expression === node) {
+ let hasCallExpression = false;
+ let hasMemberExpression = false;
+ let current = node;
+
+ while (current) {
+ switch (current.type) {
+ case "MemberExpression":
+ hasMemberExpression = true;
+ current = current.object;
+ break;
+
+ case "CallExpression":
+ if (
+ /** @(x().y) */
+ hasMemberExpression ||
+ /** @(x().y()) */
+ hasCallExpression) {
+ return true;
+ }
+
+ hasCallExpression = true;
+ current = current.callee;
+ break;
+
+ case "Identifier":
+ return false;
+
+ default:
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+ if (parent.type === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
+ util$1.startsWithNoLookaheadToken(node,
+ /* forbidFunctionClassAndDoExpr */
+ false) || parent.type === "ExpressionStatement" && util$1.startsWithNoLookaheadToken(node,
+ /* forbidFunctionClassAndDoExpr */
+ true)) {
+ return true;
+ }
+
+ switch (node.type) {
+ case "SpreadElement":
+ case "SpreadProperty":
+ return parent.type === "MemberExpression" && name === "object" && parent.object === node;
+
+ case "UpdateExpression":
+ if (parent.type === "UnaryExpression") {
+ return node.prefix && (node.operator === "++" && parent.operator === "+" || node.operator === "--" && parent.operator === "-");
+ }
+
+ // else fallthrough
+
+ case "UnaryExpression":
+ switch (parent.type) {
+ case "UnaryExpression":
+ return node.operator === parent.operator && (node.operator === "+" || node.operator === "-");
+
+ case "BindExpression":
+ return true;
+
+ case "MemberExpression":
+ case "OptionalMemberExpression":
+ return name === "object";
+
+ case "TaggedTemplateExpression":
+ return true;
+
+ case "NewExpression":
+ case "CallExpression":
+ case "OptionalCallExpression":
+ return name === "callee";
+
+ case "BinaryExpression":
+ return parent.operator === "**" && name === "left";
+
+ case "TSNonNullExpression":
+ return true;
+
+ default:
+ return false;
+ }
+
+ case "BinaryExpression":
+ {
+ if (parent.type === "UpdateExpression") {
+ return true;
+ }
+
+ const isLeftOfAForStatement = node => {
+ let i = 0;
+
+ while (node) {
+ const parent = path.getParentNode(i++);
+
+ if (!parent) {
+ return false;
+ }
+
+ if (parent.type === "ForStatement" && parent.init === node) {
+ return true;
+ }
+
+ node = parent;
+ }
+
+ return false;
+ };
+
+ if (node.operator === "in" && isLeftOfAForStatement(node)) {
+ return true;
+ }
+ }
+ // fallthrough
+
+ case "TSTypeAssertion":
+ case "TSAsExpression":
+ case "LogicalExpression":
+ switch (parent.type) {
+ case "ConditionalExpression":
+ return node.type === "TSAsExpression";
+
+ case "CallExpression":
+ case "NewExpression":
+ case "OptionalCallExpression":
+ return name === "callee";
+
+ case "ClassExpression":
+ case "ClassDeclaration":
+ return name === "superClass" && parent.superClass === node;
+
+ case "TSTypeAssertion":
+ case "TaggedTemplateExpression":
+ case "UnaryExpression":
+ case "JSXSpreadAttribute":
+ case "SpreadElement":
+ case "SpreadProperty":
+ case "BindExpression":
+ case "AwaitExpression":
+ case "TSAsExpression":
+ case "TSNonNullExpression":
+ case "UpdateExpression":
+ return true;
+
+ case "MemberExpression":
+ case "OptionalMemberExpression":
+ return name === "object";
+
+ case "AssignmentExpression":
+ return parent.left === node && (node.type === "TSTypeAssertion" || node.type === "TSAsExpression");
+
+ case "LogicalExpression":
+ if (node.type === "LogicalExpression") {
+ return parent.operator !== node.operator;
+ }
+
+ // else fallthrough
+
+ case "BinaryExpression":
+ {
+ if (!node.operator && node.type !== "TSTypeAssertion") {
+ return true;
+ }
+
+ const po = parent.operator;
+ const pp = util$1.getPrecedence(po);
+ const no = node.operator;
+ const np = util$1.getPrecedence(no);
+
+ if (pp > np) {
+ return true;
+ }
+
+ if (pp === np && name === "right") {
+ assert.strictEqual(parent.right, node);
+ return true;
+ }
+
+ if (pp === np && !util$1.shouldFlatten(po, no)) {
+ return true;
+ }
+
+ if (pp < np && no === "%") {
+ return po === "+" || po === "-";
+ } // Add parenthesis when working with bitwise operators
+ // It's not strictly needed but helps with code understanding
+
+
+ if (util$1.isBitwiseOperator(po)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ default:
+ return false;
+ }
+
+ case "SequenceExpression":
+ switch (parent.type) {
+ case "ReturnStatement":
+ return false;
+
+ case "ForStatement":
+ // Although parentheses wouldn't hurt around sequence
+ // expressions in the head of for loops, traditional style
+ // dictates that e.g. i++, j++ should not be wrapped with
+ // parentheses.
+ return false;
+
+ case "ExpressionStatement":
+ return name !== "expression";
+
+ case "ArrowFunctionExpression":
+ // We do need parentheses, but SequenceExpressions are handled
+ // specially when printing bodies of arrow functions.
+ return name !== "body";
+
+ default:
+ // Otherwise err on the side of overparenthesization, adding
+ // explicit exceptions above if this proves overzealous.
+ return true;
+ }
+
+ case "YieldExpression":
+ if (parent.type === "UnaryExpression" || parent.type === "AwaitExpression" || parent.type === "TSAsExpression" || parent.type === "TSNonNullExpression") {
+ return true;
+ }
+
+ // else fallthrough
+
+ case "AwaitExpression":
+ switch (parent.type) {
+ case "TaggedTemplateExpression":
+ case "UnaryExpression":
+ case "BinaryExpression":
+ case "LogicalExpression":
+ case "SpreadElement":
+ case "SpreadProperty":
+ case "TSAsExpression":
+ case "TSNonNullExpression":
+ case "BindExpression":
+ return true;
+
+ case "MemberExpression":
+ case "OptionalMemberExpression":
+ return name === "object";
+
+ case "NewExpression":
+ case "CallExpression":
+ case "OptionalCallExpression":
+ return name === "callee";
+
+ case "ConditionalExpression":
+ return parent.test === node;
+
+ default:
+ return false;
+ }
+
+ case "TSJSDocFunctionType":
+ case "TSConditionalType":
+ if (parent.type === "TSConditionalType" && node === parent.extendsType) {
+ return true;
+ }
+
+ // fallthrough
+
+ case "TSFunctionType":
+ case "TSConstructorType":
+ if (parent.type === "TSConditionalType" && node === parent.checkType) {
+ return true;
+ }
+
+ // fallthrough
+
+ case "TSUnionType":
+ case "TSIntersectionType":
+ if (parent.type === "TSUnionType" || parent.type === "TSIntersectionType") {
+ return true;
+ }
+
+ // fallthrough
+
+ case "TSTypeOperator":
+ case "TSInferType":
+ return parent.type === "TSArrayType" || parent.type === "TSOptionalType" || parent.type === "TSRestType" || parent.type === "TSIndexedAccessType" && node === parent.objectType || parent.type === "TSTypeOperator" || parent.type === "TSTypeAnnotation" && /^TSJSDoc/.test(path.getParentNode(1).type);
+
+ case "ArrayTypeAnnotation":
+ return parent.type === "NullableTypeAnnotation";
+
+ case "IntersectionTypeAnnotation":
+ case "UnionTypeAnnotation":
+ return parent.type === "ArrayTypeAnnotation" || parent.type === "NullableTypeAnnotation" || parent.type === "IntersectionTypeAnnotation" || parent.type === "UnionTypeAnnotation";
+
+ case "NullableTypeAnnotation":
+ return parent.type === "ArrayTypeAnnotation";
+
+ case "FunctionTypeAnnotation":
+ {
+ const ancestor = parent.type === "NullableTypeAnnotation" ? path.getParentNode(1) : parent;
+ return ancestor.type === "UnionTypeAnnotation" || ancestor.type === "IntersectionTypeAnnotation" || ancestor.type === "ArrayTypeAnnotation" || // We should check ancestor's parent to know whether the parentheses
+ // are really needed, but since ??T doesn't make sense this check
+ // will almost never be true.
+ ancestor.type === "NullableTypeAnnotation";
+ }
+
+ case "StringLiteral":
+ case "NumericLiteral":
+ case "Literal":
+ if (typeof node.value === "string" && parent.type === "ExpressionStatement" && ( // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
+ // See corresponding workaround in printer.js case: "Literal"
+ options.parser !== "typescript" && !parent.directive || options.parser === "typescript" && options.originalText.charAt(options.locStart(node) - 1) === "(")) {
+ // To avoid becoming a directive
+ const grandParent = path.getParentNode(1);
+ return grandParent.type === "Program" || grandParent.type === "BlockStatement";
+ }
+
+ return parent.type === "MemberExpression" && typeof node.value === "number" && name === "object" && parent.object === node;
+
+ case "AssignmentExpression":
+ {
+ const grandParent = path.getParentNode(1);
+
+ if (parent.type === "ArrowFunctionExpression" && parent.body === node) {
+ return true;
+ } else if (parent.type === "ClassProperty" && parent.key === node && parent.computed) {
+ return false;
+ } else if (parent.type === "TSPropertySignature" && parent.name === node) {
+ return false;
+ } else if (parent.type === "ForStatement" && (parent.init === node || parent.update === node)) {
+ return false;
+ } else if (parent.type === "ExpressionStatement") {
+ return node.left.type === "ObjectPattern";
+ } else if (parent.type === "TSPropertySignature" && parent.key === node) {
+ return false;
+ } else if (parent.type === "AssignmentExpression") {
+ return false;
+ } else if (parent.type === "SequenceExpression" && grandParent && grandParent.type === "ForStatement" && (grandParent.init === parent || grandParent.update === parent)) {
+ return false;
+ } else if (parent.type === "Property" && parent.value === node) {
+ return false;
+ } else if (parent.type === "NGChainedExpression") {
+ return false;
+ }
+
+ return true;
+ }
+
+ case "ConditionalExpression":
+ switch (parent.type) {
+ case "TaggedTemplateExpression":
+ case "UnaryExpression":
+ case "SpreadElement":
+ case "SpreadProperty":
+ case "BinaryExpression":
+ case "LogicalExpression":
+ case "NGPipeExpression":
+ case "ExportDefaultDeclaration":
+ case "AwaitExpression":
+ case "JSXSpreadAttribute":
+ case "TSTypeAssertion":
+ case "TypeCastExpression":
+ case "TSAsExpression":
+ case "TSNonNullExpression":
+ return true;
+
+ case "NewExpression":
+ case "CallExpression":
+ case "OptionalCallExpression":
+ return name === "callee";
+
+ case "ConditionalExpression":
+ return name === "test" && parent.test === node;
+
+ case "MemberExpression":
+ case "OptionalMemberExpression":
+ return name === "object";
+
+ default:
+ return false;
+ }
+
+ case "FunctionExpression":
+ switch (parent.type) {
+ case "NewExpression":
+ case "CallExpression":
+ case "OptionalCallExpression":
+ // Not always necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
+ // Is necessary if it is `expression` of `ExpressionStatement`.
+ return name === "callee";
+
+ case "TaggedTemplateExpression":
+ return true;
+ // This is basically a kind of IIFE.
+
+ default:
+ return false;
+ }
+
+ case "ArrowFunctionExpression":
+ switch (parent.type) {
+ case "NewExpression":
+ case "CallExpression":
+ case "OptionalCallExpression":
+ return name === "callee";
+
+ case "MemberExpression":
+ case "OptionalMemberExpression":
+ return name === "object";
+
+ case "TSAsExpression":
+ case "BindExpression":
+ case "TaggedTemplateExpression":
+ case "UnaryExpression":
+ case "LogicalExpression":
+ case "BinaryExpression":
+ case "AwaitExpression":
+ case "TSTypeAssertion":
+ return true;
+
+ case "ConditionalExpression":
+ return name === "test";
+
+ default:
+ return false;
+ }
+
+ case "ClassExpression":
+ switch (parent.type) {
+ case "NewExpression":
+ return name === "callee" && parent.callee === node;
+
+ default:
+ return false;
+ }
+
+ case "OptionalMemberExpression":
+ case "OptionalCallExpression":
+ if (parent.type === "MemberExpression" && name === "object" || (parent.type === "CallExpression" || parent.type === "NewExpression") && name === "callee") {
+ return true;
+ }
+
+ // fallthrough
+
+ case "CallExpression":
+ case "MemberExpression":
+ case "TaggedTemplateExpression":
+ case "TSNonNullExpression":
+ if ((parent.type === "BindExpression" || parent.type === "NewExpression") && name === "callee") {
+ let object = node;
+
+ while (object) {
+ switch (object.type) {
+ case "CallExpression":
+ case "OptionalCallExpression":
+ return true;
+
+ case "MemberExpression":
+ case "OptionalMemberExpression":
+ case "BindExpression":
+ object = object.object;
+ break;
+ // tagged templates are basically member expressions from a grammar perspective
+ // see https://tc39.github.io/ecma262/#prod-MemberExpression
+
+ case "TaggedTemplateExpression":
+ object = object.tag;
+ break;
+
+ case "TSNonNullExpression":
+ object = object.expression;
+ break;
+
+ default:
+ return false;
+ }
+ }
+ }
+
+ return false;
+
+ case "BindExpression":
+ return (parent.type === "BindExpression" || parent.type === "NewExpression") && name === "callee" || (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && name === "object";
+
+ case "NGPipeExpression":
+ if (parent.type === "NGRoot" || parent.type === "NGMicrosyntaxExpression" || parent.type === "ObjectProperty" || parent.type === "ArrayExpression" || (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.arguments[name] === node || parent.type === "NGPipeExpression" && name === "right" || parent.type === "MemberExpression" && name === "property" || parent.type === "AssignmentExpression") {
+ return false;
+ }
+
+ return true;
+
+ case "JSXFragment":
+ case "JSXElement":
+ return name === "callee" || parent.type !== "ArrayExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "AssignmentExpression" && parent.type !== "AssignmentPattern" && parent.type !== "BinaryExpression" && parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "ConditionalExpression" && parent.type !== "ExpressionStatement" && parent.type !== "JsExpressionRoot" && parent.type !== "JSXAttribute" && parent.type !== "JSXElement" && parent.type !== "JSXExpressionContainer" && parent.type !== "JSXFragment" && parent.type !== "LogicalExpression" && parent.type !== "ObjectProperty" && parent.type !== "OptionalCallExpression" && parent.type !== "Property" && parent.type !== "ReturnStatement" && parent.type !== "ThrowStatement" && parent.type !== "TypeCastExpression" && parent.type !== "VariableDeclarator" && parent.type !== "YieldExpression";
+
+ case "TypeAnnotation":
+ return name === "returnType" && parent.type === "ArrowFunctionExpression" && includesFunctionTypeInObjectType(node);
+ }
+
+ return false;
+}
+
+function isStatement(node) {
+ return node.type === "BlockStatement" || node.type === "BreakStatement" || node.type === "ClassBody" || node.type === "ClassDeclaration" || node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "ClassPrivateProperty" || node.type === "ContinueStatement" || node.type === "DebuggerStatement" || node.type === "DeclareClass" || node.type === "DeclareExportAllDeclaration" || node.type === "DeclareExportDeclaration" || node.type === "DeclareFunction" || node.type === "DeclareInterface" || node.type === "DeclareModule" || node.type === "DeclareModuleExports" || node.type === "DeclareVariable" || node.type === "DoWhileStatement" || node.type === "EnumDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForInStatement" || node.type === "ForOfStatement" || node.type === "ForStatement" || node.type === "FunctionDeclaration" || node.type === "IfStatement" || node.type === "ImportDeclaration" || node.type === "InterfaceDeclaration" || node.type === "LabeledStatement" || node.type === "MethodDefinition" || node.type === "ReturnStatement" || node.type === "SwitchStatement" || node.type === "ThrowStatement" || node.type === "TryStatement" || node.type === "TSDeclareFunction" || node.type === "TSEnumDeclaration" || node.type === "TSImportEqualsDeclaration" || node.type === "TSInterfaceDeclaration" || node.type === "TSModuleDeclaration" || node.type === "TSNamespaceExportDeclaration" || node.type === "TypeAlias" || node.type === "VariableDeclaration" || node.type === "WhileStatement" || node.type === "WithStatement";
+}
+
+function includesFunctionTypeInObjectType(node) {
+ return hasNode$1(node, n1 => n1.type === "ObjectTypeAnnotation" && hasNode$1(n1, n2 => n2.type === "FunctionTypeAnnotation" || undefined) || undefined);
+}
+
+function endsWithRightBracket(node) {
+ switch (node.type) {
+ case "ObjectExpression":
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+function isFollowedByRightBracket(path) {
+ const node = path.getValue();
+ const parent = path.getParentNode();
+ const name = path.getName();
+
+ switch (parent.type) {
+ case "NGPipeExpression":
+ if (typeof name === "number" && parent.arguments[name] === node && parent.arguments.length - 1 === name) {
+ return path.callParent(isFollowedByRightBracket);
+ }
+
+ break;
+
+ case "ObjectProperty":
+ if (name === "value") {
+ const parentParent = path.getParentNode(1);
+ return parentParent.properties[parentParent.properties.length - 1] === parent;
+ }
+
+ break;
+
+ case "BinaryExpression":
+ case "LogicalExpression":
+ if (name === "right") {
+ return path.callParent(isFollowedByRightBracket);
+ }
+
+ break;
+
+ case "ConditionalExpression":
+ if (name === "alternate") {
+ return path.callParent(isFollowedByRightBracket);
+ }
+
+ break;
+
+ case "UnaryExpression":
+ if (parent.prefix) {
+ return path.callParent(isFollowedByRightBracket);
+ }
+
+ break;
+ }
+
+ return false;
+}
+
+function shouldWrapFunctionForExportDefault(path, options) {
+ const node = path.getValue();
+ const parent = path.getParentNode();
+
+ if (node.type === "FunctionExpression" || node.type === "ClassExpression") {
+ return parent.type === "ExportDefaultDeclaration" || // in some cases the function is already wrapped
+ // (e.g. `export default (function() {})();`)
+ // in this case we don't need to add extra parens
+ !needsParens(path, options);
+ }
+
+ if (!hasNakedLeftSide$1(node) || parent.type !== "ExportDefaultDeclaration" && needsParens(path, options)) {
+ return false;
+ }
+
+ return path.call(childPath => shouldWrapFunctionForExportDefault(childPath, options), ...getLeftSidePathName$1(path, node));
+}
+
+var needsParens_1 = needsParens;
+
+const {
+ builders: {
+ concat: concat$5,
+ join: join$3,
+ line: line$3
+ }
+} = document;
+
+function printHtmlBinding(path, options, print) {
+ const node = path.getValue();
+
+ if (options.__onHtmlBindingRoot && path.getName() === null) {
+ options.__onHtmlBindingRoot(node, options);
+ }
+
+ if (node.type !== "File") {
+ return;
+ }
+
+ if (options.__isVueForBindingLeft) {
+ return path.call(functionDeclarationPath => {
+ const {
+ params
+ } = functionDeclarationPath.getValue();
+ return concat$5([params.length > 1 ? "(" : "", join$3(concat$5([",", line$3]), functionDeclarationPath.map(print, "params")), params.length > 1 ? ")" : ""]);
+ }, "program", "body", 0);
+ }
+
+ if (options.__isVueSlotScope) {
+ return path.call(functionDeclarationPath => join$3(concat$5([",", line$3]), functionDeclarationPath.map(print, "params")), "program", "body", 0);
+ }
+} // based on https://github.com/prettier/prettier/blob/master/src/language-html/syntax-vue.js isVueEventBindingExpression()
+
+
+function isVueEventBindingExpression(node) {
+ switch (node.type) {
+ case "MemberExpression":
+ switch (node.property.type) {
+ case "Identifier":
+ case "NumericLiteral":
+ case "StringLiteral":
+ return isVueEventBindingExpression(node.object);
+ }
+
+ return false;
+
+ case "Identifier":
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+var htmlBinding = {
+ isVueEventBindingExpression,
+ printHtmlBinding
+};
+
+function preprocess(ast, options) {
+ switch (options.parser) {
+ case "json":
+ case "json5":
+ case "json-stringify":
+ case "__js_expression":
+ case "__vue_expression":
+ return Object.assign({}, ast, {
+ type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
+ node: ast,
+ comments: [],
+ rootMarker: options.rootMarker
+ });
+
+ default:
+ return ast;
+ }
+}
+
+var preprocess_1 = preprocess;
+
+const {
+ shouldFlatten: shouldFlatten$1,
+ getNextNonSpaceNonCommentCharacter: getNextNonSpaceNonCommentCharacter$1,
+ hasNewline: hasNewline$4,
+ hasNewlineInRange: hasNewlineInRange$3,
+ getLast: getLast$2,
+ getStringWidth: getStringWidth$3,
+ printString: printString$1,
+ printNumber: printNumber$1,
+ hasIgnoreComment: hasIgnoreComment$2,
+ hasNodeIgnoreComment: hasNodeIgnoreComment$2,
+ getPenultimate: getPenultimate$1,
+ startsWithNoLookaheadToken: startsWithNoLookaheadToken$1,
+ getIndentSize: getIndentSize$2,
+ getPreferredQuote: getPreferredQuote$1
+} = util$1;
+const {
+ isNextLineEmpty: isNextLineEmpty$2,
+ isNextLineEmptyAfterIndex: isNextLineEmptyAfterIndex$2,
+ getNextNonSpaceNonCommentCharacterIndex: getNextNonSpaceNonCommentCharacterIndex$3
+} = utilShared;
+const {
+ insertPragma: insertPragma$1
+} = pragma;
+const {
+ printHtmlBinding: printHtmlBinding$1,
+ isVueEventBindingExpression: isVueEventBindingExpression$1
+} = htmlBinding;
+const {
+ classChildNeedsASIProtection: classChildNeedsASIProtection$1,
+ classPropMayCauseASIProblems: classPropMayCauseASIProblems$1,
+ conditionalExpressionChainContainsJSX: conditionalExpressionChainContainsJSX$1,
+ getFlowVariance: getFlowVariance$1,
+ getLeftSidePathName: getLeftSidePathName$2,
+ getParentExportDeclaration: getParentExportDeclaration$1,
+ getTypeScriptMappedTypeModifier: getTypeScriptMappedTypeModifier$1,
+ hasDanglingComments: hasDanglingComments$1,
+ hasFlowAnnotationComment: hasFlowAnnotationComment$1,
+ hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
+ hasLeadingComment: hasLeadingComment$3,
+ hasLeadingOwnLineComment: hasLeadingOwnLineComment$1,
+ hasNakedLeftSide: hasNakedLeftSide$2,
+ hasNewlineBetweenOrAfterDecorators: hasNewlineBetweenOrAfterDecorators$1,
+ hasNgSideEffect: hasNgSideEffect$1,
+ hasPrettierIgnore: hasPrettierIgnore$1,
+ hasTrailingComment: hasTrailingComment$1,
+ identity: identity$2,
+ isBinaryish: isBinaryish$1,
+ isCallOrOptionalCallExpression: isCallOrOptionalCallExpression$1,
+ isEmptyJSXElement: isEmptyJSXElement$1,
+ isExportDeclaration: isExportDeclaration$1,
+ isFlowAnnotationComment: isFlowAnnotationComment$1,
+ isFunctionCompositionArgs: isFunctionCompositionArgs$1,
+ isFunctionNotation: isFunctionNotation$1,
+ isFunctionOrArrowExpression: isFunctionOrArrowExpression$1,
+ isGetterOrSetter: isGetterOrSetter$1,
+ isJestEachTemplateLiteral: isJestEachTemplateLiteral$1,
+ isJSXNode: isJSXNode$1,
+ isJSXWhitespaceExpression: isJSXWhitespaceExpression$1,
+ isLastStatement: isLastStatement$1,
+ isLiteral: isLiteral$1,
+ isLongCurriedCallExpression: isLongCurriedCallExpression$1,
+ isMeaningfulJSXText: isMeaningfulJSXText$1,
+ isMemberExpressionChain: isMemberExpressionChain$1,
+ isMemberish: isMemberish$1,
+ isNgForOf: isNgForOf$1,
+ isNumericLiteral: isNumericLiteral$1,
+ isObjectType: isObjectType$1,
+ isObjectTypePropertyAFunction: isObjectTypePropertyAFunction$1,
+ isSimpleCallArgument: isSimpleCallArgument$1,
+ isSimpleFlowType: isSimpleFlowType$1,
+ isSimpleTemplateLiteral: isSimpleTemplateLiteral$1,
+ isStringLiteral: isStringLiteral$1,
+ isStringPropSafeToCoerceToIdentifier: isStringPropSafeToCoerceToIdentifier$1,
+ isTemplateOnItsOwnLine: isTemplateOnItsOwnLine$1,
+ isTestCall: isTestCall$1,
+ isTheOnlyJSXElementInMarkdown: isTheOnlyJSXElementInMarkdown$1,
+ isTSXFile: isTSXFile$1,
+ isTypeAnnotationAFunction: isTypeAnnotationAFunction$1,
+ matchJsxWhitespaceRegex: matchJsxWhitespaceRegex$1,
+ needsHardlineAfterDanglingComment: needsHardlineAfterDanglingComment$1,
+ rawText: rawText$1,
+ returnArgumentHasLeadingComment: returnArgumentHasLeadingComment$1
+} = utils$6;
+const needsQuoteProps = new WeakMap();
+const {
+ builders: {
+ concat: concat$6,
+ join: join$4,
+ line: line$4,
+ hardline: hardline$4,
+ softline: softline$2,
+ literalline: literalline$2,
+ group: group$2,
+ indent: indent$3,
+ align: align$1,
+ conditionalGroup: conditionalGroup$1,
+ fill: fill$3,
+ ifBreak: ifBreak$1,
+ breakParent: breakParent$2,
+ lineSuffixBoundary: lineSuffixBoundary$1,
+ addAlignmentToDoc: addAlignmentToDoc$2,
+ dedent: dedent$1
+ },
+ utils: {
+ willBreak: willBreak$1,
+ isLineNext: isLineNext$1,
+ isEmpty: isEmpty$1,
+ removeLines: removeLines$1
+ },
+ printer: {
+ printDocToString: printDocToString$2
+ }
+} = document;
+let uid = 0;
+
+function shouldPrintComma(options, level) {
+ level = level || "es5";
+
+ switch (options.trailingComma) {
+ case "all":
+ if (level === "all") {
+ return true;
+ }
+
+ // fallthrough
+
+ case "es5":
+ if (level === "es5") {
+ return true;
+ }
+
+ // fallthrough
+
+ case "none":
+ default:
+ return false;
+ }
+}
+
+function genericPrint(path, options, printPath, args) {
+ const node = path.getValue();
+ let needsParens = false;
+ const linesWithoutParens = printPathNoParens(path, options, printPath, args);
+
+ if (!node || isEmpty$1(linesWithoutParens)) {
+ return linesWithoutParens;
+ }
+
+ const parentExportDecl = getParentExportDeclaration$1(path);
+ const decorators = [];
+
+ if (node.type === "ClassMethod" || node.type === "ClassPrivateMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty" || node.type === "MethodDefinition" || node.type === "TSAbstractMethodDefinition" || node.type === "TSDeclareMethod") ; else if (node.decorators && node.decorators.length > 0 && // If the parent node is an export declaration and the decorator
+ // was written before the export, the export will be responsible
+ // for printing the decorators.
+ !(parentExportDecl && options.locStart(parentExportDecl, {
+ ignoreDecorators: true
+ }) > options.locStart(node.decorators[0]))) {
+ const shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators$1(node, options);
+ const separator = shouldBreak ? hardline$4 : line$4;
+ path.each(decoratorPath => {
+ let decorator = decoratorPath.getValue();
+
+ if (decorator.expression) {
+ decorator = decorator.expression;
+ } else {
+ decorator = decorator.callee;
+ }
+
+ decorators.push(printPath(decoratorPath), separator);
+ }, "decorators");
+
+ if (parentExportDecl) {
+ decorators.unshift(hardline$4);
+ }
+ } else if (isExportDeclaration$1(node) && node.declaration && node.declaration.decorators && node.declaration.decorators.length > 0 && // Only print decorators here if they were written before the export,
+ // otherwise they are printed by the node.declaration
+ options.locStart(node, {
+ ignoreDecorators: true
+ }) > options.locStart(node.declaration.decorators[0])) {
+ // Export declarations are responsible for printing any decorators
+ // that logically apply to node.declaration.
+ path.each(decoratorPath => {
+ const decorator = decoratorPath.getValue();
+ const prefix = decorator.type === "Decorator" ? "" : "@";
+ decorators.push(prefix, printPath(decoratorPath), hardline$4);
+ }, "declaration", "decorators");
+ } else {
+ // Nodes with decorators can't have parentheses, so we can avoid
+ // computing pathNeedsParens() except in this case.
+ needsParens = needsParens_1(path, options);
+ }
+
+ const parts = [];
+
+ if (needsParens) {
+ parts.unshift("(");
+ }
+
+ parts.push(linesWithoutParens);
+
+ if (needsParens) {
+ const node = path.getValue();
+
+ if (hasFlowShorthandAnnotationComment$2(node)) {
+ parts.push(" /*");
+ parts.push(node.trailingComments[0].value.trimStart());
+ parts.push("*/");
+ node.trailingComments[0].printed = true;
+ }
+
+ parts.push(")");
+ }
+
+ if (decorators.length > 0) {
+ return group$2(concat$6(decorators.concat(parts)));
+ }
+
+ return concat$6(parts);
+}
+
+function printDecorators(path, options, print) {
+ const node = path.getValue();
+ return group$2(concat$6([join$4(line$4, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators$1(node, options) ? hardline$4 : line$4]));
+}
+/**
+ * The following is the shared logic for
+ * ternary operators, namely ConditionalExpression
+ * and TSConditionalType
+ * @typedef {Object} OperatorOptions
+ * @property {() => Array} beforeParts - Parts to print before the `?`.
+ * @property {(breakClosingParen: boolean) => Array} afterParts - Parts to print after the conditional expression.
+ * @property {boolean} shouldCheckJsx - Whether to check for and print in JSX mode.
+ * @property {string} conditionalNodeType - The type of the conditional expression node, ie "ConditionalExpression" or "TSConditionalType".
+ * @property {string} consequentNodePropertyName - The property at which the consequent node can be found on the main node, eg "consequent".
+ * @property {string} alternateNodePropertyName - The property at which the alternate node can be found on the main node, eg "alternate".
+ * @property {string[]} testNodePropertyNames - The properties at which the test nodes can be found on the main node, eg "test".
+ * @param {FastPath} path - The path to the ConditionalExpression/TSConditionalType node.
+ * @param {Options} options - Prettier options
+ * @param {Function} print - Print function to call recursively
+ * @param {OperatorOptions} operatorOptions
+ * @returns Doc
+ */
+
+
+function printTernaryOperator(path, options, print, operatorOptions) {
+ const node = path.getValue();
+ const consequentNode = node[operatorOptions.consequentNodePropertyName];
+ const alternateNode = node[operatorOptions.alternateNodePropertyName];
+ const parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode".
+ // See tests/jsx/conditional-expression.js for more info.
+
+ let jsxMode = false;
+ const parent = path.getParentNode();
+ const isParentTest = parent.type === operatorOptions.conditionalNodeType && operatorOptions.testNodePropertyNames.some(prop => parent[prop] === node);
+ let forceNoIndent = parent.type === operatorOptions.conditionalNodeType && !isParentTest; // Find the outermost non-ConditionalExpression parent, and the outermost
+ // ConditionalExpression parent. We'll use these to determine if we should
+ // print in JSX mode.
+
+ let currentParent;
+ let previousParent;
+ let i = 0;
+
+ do {
+ previousParent = currentParent || node;
+ currentParent = path.getParentNode(i);
+ i++;
+ } while (currentParent && currentParent.type === operatorOptions.conditionalNodeType && operatorOptions.testNodePropertyNames.every(prop => currentParent[prop] !== previousParent));
+
+ const firstNonConditionalParent = currentParent || parent;
+ const lastConditionalParent = previousParent;
+
+ if (operatorOptions.shouldCheckJsx && (isJSXNode$1(node[operatorOptions.testNodePropertyNames[0]]) || isJSXNode$1(consequentNode) || isJSXNode$1(alternateNode) || conditionalExpressionChainContainsJSX$1(lastConditionalParent))) {
+ jsxMode = true;
+ forceNoIndent = true; // Even though they don't need parens, we wrap (almost) everything in
+ // parens when using ?: within JSX, because the parens are analogous to
+ // curly braces in an if statement.
+
+ const wrap = doc => concat$6([ifBreak$1("(", ""), indent$3(concat$6([softline$2, doc])), softline$2, ifBreak$1(")", "")]); // The only things we don't wrap are:
+ // * Nested conditional expressions in alternates
+ // * null
+ // * undefined
+
+
+ const isNil = node => node.type === "NullLiteral" || node.type === "Literal" && node.value === null || node.type === "Identifier" && node.name === "undefined";
+
+ parts.push(" ? ", isNil(consequentNode) ? path.call(print, operatorOptions.consequentNodePropertyName) : wrap(path.call(print, operatorOptions.consequentNodePropertyName)), " : ", alternateNode.type === operatorOptions.conditionalNodeType || isNil(alternateNode) ? path.call(print, operatorOptions.alternateNodePropertyName) : wrap(path.call(print, operatorOptions.alternateNodePropertyName)));
+ } else {
+ // normal mode
+ const part = concat$6([line$4, "? ", consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$1("", "(") : "", align$1(2, path.call(print, operatorOptions.consequentNodePropertyName)), consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$1("", ")") : "", line$4, ": ", alternateNode.type === operatorOptions.conditionalNodeType ? path.call(print, operatorOptions.alternateNodePropertyName) : align$1(2, path.call(print, operatorOptions.alternateNodePropertyName))]);
+ parts.push(parent.type !== operatorOptions.conditionalNodeType || parent[operatorOptions.alternateNodePropertyName] === node || isParentTest ? part : options.useTabs ? dedent$1(indent$3(part)) : align$1(Math.max(0, options.tabWidth - 2), part));
+ } // We want a whole chain of ConditionalExpressions to all
+ // break if any of them break. That means we should only group around the
+ // outer-most ConditionalExpression.
+
+
+ const maybeGroup = doc => parent === firstNonConditionalParent ? group$2(doc) : doc; // Break the closing paren to keep the chain right after it:
+ // (a
+ // ? b
+ // : c
+ // ).call()
+
+
+ const breakClosingParen = !jsxMode && (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression" || parent.type === "NGPipeExpression" && parent.left === node) && !parent.computed;
+ const result = maybeGroup(concat$6([].concat((testDoc =>
+ /**
+ * a
+ * ? b
+ * : multiline
+ * test
+ * node
+ * ^^ align(2)
+ * ? d
+ * : e
+ */
+ parent.type === operatorOptions.conditionalNodeType && parent[operatorOptions.alternateNodePropertyName] === node ? align$1(2, testDoc) : testDoc)(concat$6(operatorOptions.beforeParts())), forceNoIndent ? concat$6(parts) : indent$3(concat$6(parts)), operatorOptions.afterParts(breakClosingParen))));
+ return isParentTest ? group$2(concat$6([indent$3(concat$6([softline$2, result])), softline$2])) : result;
+}
+
+function printPathNoParens(path, options, print, args) {
+ const n = path.getValue();
+ const semi = options.semi ? ";" : "";
+
+ if (!n) {
+ return "";
+ }
+
+ if (typeof n === "string") {
+ return n;
+ }
+
+ const htmlBinding = printHtmlBinding$1(path, options, print);
+
+ if (htmlBinding) {
+ return htmlBinding;
+ }
+
+ let parts = [];
+
+ switch (n.type) {
+ case "JsExpressionRoot":
+ return path.call(print, "node");
+
+ case "JsonRoot":
+ return concat$6([path.call(print, "node"), hardline$4]);
+
+ case "File":
+ // Print @babel/parser's InterpreterDirective here so that
+ // leading comments on the `Program` node get printed after the hashbang.
+ if (n.program && n.program.interpreter) {
+ parts.push(path.call(programPath => programPath.call(print, "interpreter"), "program"));
+ }
+
+ parts.push(path.call(print, "program"));
+ return concat$6(parts);
+
+ case "Program":
+ // Babel 6
+ if (n.directives) {
+ path.each(childPath => {
+ parts.push(print(childPath), semi, hardline$4);
+
+ if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options.locEnd)) {
+ parts.push(hardline$4);
+ }
+ }, "directives");
+ }
+
+ parts.push(path.call(bodyPath => {
+ return printStatementSequence(bodyPath, options, print);
+ }, "body"));
+ parts.push(comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true)); // Only force a trailing newline if there were any contents.
+
+ if (!n.body.every(({
+ type
+ }) => type === "EmptyStatement") || n.comments) {
+ parts.push(hardline$4);
+ }
+
+ return concat$6(parts);
+ // Babel extension.
+
+ case "EmptyStatement":
+ return "";
+
+ case "ExpressionStatement":
+ // Detect Flow-parsed directives
+ if (n.directive) {
+ return concat$6([nodeStr(n.expression, options, true), semi]);
+ }
+
+ if (options.parser === "__vue_event_binding") {
+ const parent = path.getParentNode();
+
+ if (parent.type === "Program" && parent.body.length === 1 && parent.body[0] === n) {
+ return concat$6([path.call(print, "expression"), isVueEventBindingExpression$1(n.expression) ? ";" : ""]);
+ }
+ } // Do not append semicolon after the only JSX element in a program
+
+
+ return concat$6([path.call(print, "expression"), isTheOnlyJSXElementInMarkdown$1(options, path) ? "" : semi]);
+ // Babel non-standard node. Used for Closure-style type casts. See postprocess.js.
+
+ case "ParenthesizedExpression":
+ {
+ const shouldHug = !n.expression.comments;
+
+ if (shouldHug) {
+ return concat$6(["(", path.call(print, "expression"), ")"]);
+ }
+
+ return group$2(concat$6(["(", indent$3(concat$6([softline$2, path.call(print, "expression")])), softline$2, ")"]));
+ }
+
+ case "AssignmentExpression":
+ return printAssignment(n.left, path.call(print, "left"), concat$6([" ", n.operator]), n.right, path.call(print, "right"), options);
+
+ case "BinaryExpression":
+ case "LogicalExpression":
+ case "NGPipeExpression":
+ {
+ const parent = path.getParentNode();
+ const parentParent = path.getParentNode(1);
+ const isInsideParenthesis = n !== parent.body && (parent.type === "IfStatement" || parent.type === "WhileStatement" || parent.type === "SwitchStatement" || parent.type === "DoWhileStatement");
+ const parts = printBinaryishExpressions(path, print, options,
+ /* isNested */
+ false, isInsideParenthesis); // if (
+ // this.hasPlugin("dynamicImports") && this.lookahead().type === tt.parenLeft
+ // ) {
+ //
+ // looks super weird, we want to break the children if the parent breaks
+ //
+ // if (
+ // this.hasPlugin("dynamicImports") &&
+ // this.lookahead().type === tt.parenLeft
+ // ) {
+
+ if (isInsideParenthesis) {
+ return concat$6(parts);
+ } // Break between the parens in
+ // unaries or in a member or specific call expression, i.e.
+ //
+ // (
+ // a &&
+ // b &&
+ // c
+ // ).call()
+
+
+ if ((parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.callee === n || parent.type === "UnaryExpression" || (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed) {
+ return group$2(concat$6([indent$3(concat$6([softline$2, concat$6(parts)])), softline$2]));
+ } // Avoid indenting sub-expressions in some cases where the first sub-expression is already
+ // indented accordingly. We should indent sub-expressions where the first case isn't indented.
+
+
+ const shouldNotIndent = parent.type === "ReturnStatement" || parent.type === "ThrowStatement" || parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || n.operator !== "|" && parent.type === "JsExpressionRoot" || n.type !== "NGPipeExpression" && (parent.type === "NGRoot" && options.parser === "__ng_binding" || parent.type === "NGMicrosyntaxExpression" && parentParent.type === "NGMicrosyntax" && parentParent.body.length === 1) || n === parent.body && parent.type === "ArrowFunctionExpression" || n !== parent.body && parent.type === "ForStatement" || parent.type === "ConditionalExpression" && parentParent.type !== "ReturnStatement" && parentParent.type !== "ThrowStatement" && parentParent.type !== "CallExpression" && parentParent.type !== "OptionalCallExpression" || parent.type === "TemplateLiteral";
+ const shouldIndentIfInlining = parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator" || parent.type === "ClassProperty" || parent.type === "TSAbstractClassProperty" || parent.type === "ClassPrivateProperty" || parent.type === "ObjectProperty" || parent.type === "Property";
+ const samePrecedenceSubExpression = isBinaryish$1(n.left) && shouldFlatten$1(n.operator, n.left.operator);
+
+ if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) {
+ return group$2(concat$6(parts));
+ }
+
+ if (parts.length === 0) {
+ return "";
+ } // If the right part is a JSX node, we include it in a separate group to
+ // prevent it breaking the whole chain, so we can print the expression like:
+ //
+ // foo && bar && (
+ //
+ //
+ //
+ // )
+
+
+ const hasJSX = isJSXNode$1(n.right);
+ const rest = concat$6(hasJSX ? parts.slice(1, -1) : parts.slice(1));
+ const groupId = Symbol("logicalChain-" + ++uid);
+ const chain = group$2(concat$6([// Don't include the initial expression in the indentation
+ // level. The first item is guaranteed to be the first
+ // left-most expression.
+ parts.length > 0 ? parts[0] : "", indent$3(rest)]), {
+ id: groupId
+ });
+
+ if (!hasJSX) {
+ return chain;
+ }
+
+ const jsxPart = getLast$2(parts);
+ return group$2(concat$6([chain, ifBreak$1(indent$3(jsxPart), jsxPart, {
+ groupId
+ })]));
+ }
+
+ case "AssignmentPattern":
+ return concat$6([path.call(print, "left"), " = ", path.call(print, "right")]);
+
+ case "TSTypeAssertion":
+ {
+ const shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
+ const castGroup = group$2(concat$6(["<", indent$3(concat$6([softline$2, path.call(print, "typeAnnotation")])), softline$2, ">"]));
+ const exprContents = concat$6([ifBreak$1("("), indent$3(concat$6([softline$2, path.call(print, "expression")])), softline$2, ifBreak$1(")")]);
+
+ if (shouldBreakAfterCast) {
+ return conditionalGroup$1([concat$6([castGroup, path.call(print, "expression")]), concat$6([castGroup, group$2(exprContents, {
+ shouldBreak: true
+ })]), concat$6([castGroup, path.call(print, "expression")])]);
+ }
+
+ return group$2(concat$6([castGroup, path.call(print, "expression")]));
+ }
+
+ case "OptionalMemberExpression":
+ case "MemberExpression":
+ {
+ const parent = path.getParentNode();
+ let firstNonMemberParent;
+ let i = 0;
+
+ do {
+ firstNonMemberParent = path.getParentNode(i);
+ i++;
+ } while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression"));
+
+ const shouldInline = firstNonMemberParent && (firstNonMemberParent.type === "NewExpression" || firstNonMemberParent.type === "BindExpression" || firstNonMemberParent.type === "VariableDeclarator" && firstNonMemberParent.id.type !== "Identifier" || firstNonMemberParent.type === "AssignmentExpression" && firstNonMemberParent.left.type !== "Identifier") || n.computed || n.object.type === "Identifier" && n.property.type === "Identifier" && parent.type !== "MemberExpression" && parent.type !== "OptionalMemberExpression";
+ return concat$6([path.call(print, "object"), shouldInline ? printMemberLookup(path, options, print) : group$2(indent$3(concat$6([softline$2, printMemberLookup(path, options, print)])))]);
+ }
+
+ case "MetaProperty":
+ return concat$6([path.call(print, "meta"), ".", path.call(print, "property")]);
+
+ case "BindExpression":
+ if (n.object) {
+ parts.push(path.call(print, "object"));
+ }
+
+ parts.push(group$2(indent$3(concat$6([softline$2, printBindExpressionCallee(path, options, print)]))));
+ return concat$6(parts);
+
+ case "Identifier":
+ {
+ return concat$6([n.name, printOptionalToken(path), printTypeAnnotation(path, options, print)]);
+ }
+
+ case "V8IntrinsicIdentifier":
+ return concat$6(["%", n.name]);
+
+ case "SpreadElement":
+ case "SpreadElementPattern":
+ case "SpreadProperty":
+ case "SpreadPropertyPattern":
+ case "RestElement":
+ case "ObjectTypeSpreadProperty":
+ return concat$6(["...", path.call(print, "argument"), printTypeAnnotation(path, options, print)]);
+
+ case "FunctionDeclaration":
+ case "FunctionExpression":
+ parts.push(printFunctionDeclaration(path, print, options));
+
+ if (!n.body) {
+ parts.push(semi);
+ }
+
+ return concat$6(parts);
+
+ case "ArrowFunctionExpression":
+ {
+ if (n.async) {
+ parts.push("async ");
+ }
+
+ if (shouldPrintParamsWithoutParens(path, options)) {
+ parts.push(path.call(print, "params", 0));
+ } else {
+ parts.push(group$2(concat$6([printFunctionParams(path, print, options,
+ /* expandLast */
+ args && (args.expandLastArg || args.expandFirstArg),
+ /* printTypeParams */
+ true), printReturnType(path, print, options)])));
+ }
+
+ const dangling = comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true, comment => {
+ const nextCharacter = getNextNonSpaceNonCommentCharacterIndex$3(options.originalText, comment, options.locEnd);
+ return options.originalText.slice(nextCharacter, nextCharacter + 2) === "=>";
+ });
+
+ if (dangling) {
+ parts.push(" ", dangling);
+ }
+
+ parts.push(" =>");
+ const body = path.call(bodyPath => print(bodyPath, args), "body"); // We want to always keep these types of nodes on the same line
+ // as the arrow.
+
+ if (!hasLeadingOwnLineComment$1(options.originalText, n.body, options) && (n.body.type === "ArrayExpression" || n.body.type === "ObjectExpression" || n.body.type === "BlockStatement" || isJSXNode$1(n.body) || isTemplateOnItsOwnLine$1(n.body, options.originalText, options) || n.body.type === "ArrowFunctionExpression" || n.body.type === "DoExpression")) {
+ return group$2(concat$6([concat$6(parts), " ", body]));
+ } // We handle sequence expressions as the body of arrows specially,
+ // so that the required parentheses end up on their own lines.
+
+
+ if (n.body.type === "SequenceExpression") {
+ return group$2(concat$6([concat$6(parts), group$2(concat$6([" (", indent$3(concat$6([softline$2, body])), softline$2, ")"]))]));
+ } // if the arrow function is expanded as last argument, we are adding a
+ // level of indentation and need to add a softline to align the closing )
+ // with the opening (, or if it's inside a JSXExpression (e.g. an attribute)
+ // we should align the expression's closing } with the line with the opening {.
+
+
+ const shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !(n.comments && n.comments.length);
+ const printTrailingComma = args && args.expandLastArg && shouldPrintComma(options, "all"); // In order to avoid confusion between
+ // a => a ? a : a
+ // a <= a ? a : a
+
+ const shouldAddParens = n.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken$1(n.body,
+ /* forbidFunctionAndClass */
+ false);
+ return group$2(concat$6([concat$6(parts), group$2(concat$6([indent$3(concat$6([line$4, shouldAddParens ? ifBreak$1("", "(") : "", body, shouldAddParens ? ifBreak$1("", ")") : ""])), shouldAddSoftLine ? concat$6([ifBreak$1(printTrailingComma ? "," : ""), softline$2]) : ""]))]));
+ }
+
+ case "YieldExpression":
+ parts.push("yield");
+
+ if (n.delegate) {
+ parts.push("*");
+ }
+
+ if (n.argument) {
+ parts.push(" ", path.call(print, "argument"));
+ }
+
+ return concat$6(parts);
+
+ case "AwaitExpression":
+ {
+ parts.push("await ", path.call(print, "argument"));
+ const parent = path.getParentNode();
+
+ if ((parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && parent.callee === n || (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && parent.object === n) {
+ return group$2(concat$6([indent$3(concat$6([softline$2, concat$6(parts)])), softline$2]));
+ }
+
+ return concat$6(parts);
+ }
+
+ case "ImportSpecifier":
+ if (n.importKind) {
+ parts.push(path.call(print, "importKind"), " ");
+ }
+
+ parts.push(path.call(print, "imported"));
+
+ if (n.local && n.local.name !== n.imported.name) {
+ parts.push(" as ", path.call(print, "local"));
+ }
+
+ return concat$6(parts);
+
+ case "ExportSpecifier":
+ parts.push(path.call(print, "local"));
+
+ if (n.exported && n.exported.name !== n.local.name) {
+ parts.push(" as ", path.call(print, "exported"));
+ }
+
+ return concat$6(parts);
+
+ case "ImportNamespaceSpecifier":
+ parts.push("* as ");
+ parts.push(path.call(print, "local"));
+ return concat$6(parts);
+
+ case "ImportDefaultSpecifier":
+ return path.call(print, "local");
+
+ case "TSExportAssignment":
+ return concat$6(["export = ", path.call(print, "expression"), semi]);
+
+ case "ExportDefaultDeclaration":
+ case "ExportNamedDeclaration":
+ return printExportDeclaration(path, options, print);
+
+ case "ExportAllDeclaration":
+ parts.push("export ");
+
+ if (n.exportKind === "type") {
+ parts.push("type ");
+ }
+
+ parts.push("* ");
+
+ if (n.exported) {
+ parts.push("as ", path.call(print, "exported"), " ");
+ }
+
+ parts.push("from ", path.call(print, "source"), semi);
+ return concat$6(parts);
+
+ case "ExportNamespaceSpecifier":
+ case "ExportDefaultSpecifier":
+ return path.call(print, "exported");
+
+ case "ImportDeclaration":
+ {
+ parts.push("import ");
+
+ if (n.importKind && n.importKind !== "value") {
+ parts.push(n.importKind + " ");
+ }
+
+ const standalones = [];
+ const grouped = [];
+
+ if (n.specifiers && n.specifiers.length > 0) {
+ path.each(specifierPath => {
+ const value = specifierPath.getValue();
+
+ if (value.type === "ImportDefaultSpecifier" || value.type === "ImportNamespaceSpecifier") {
+ standalones.push(print(specifierPath));
+ } else {
+ grouped.push(print(specifierPath));
+ }
+ }, "specifiers");
+
+ if (standalones.length > 0) {
+ parts.push(join$4(", ", standalones));
+ }
+
+ if (standalones.length > 0 && grouped.length > 0) {
+ parts.push(", ");
+ }
+
+ if (grouped.length === 1 && standalones.length === 0 && n.specifiers && !n.specifiers.some(node => node.comments)) {
+ parts.push(concat$6(["{", options.bracketSpacing ? " " : "", concat$6(grouped), options.bracketSpacing ? " " : "", "}"]));
+ } else if (grouped.length >= 1) {
+ parts.push(group$2(concat$6(["{", indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, join$4(concat$6([",", line$4]), grouped)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$4 : softline$2, "}"])));
+ }
+
+ parts.push(" from ");
+ } else if (n.importKind && n.importKind === "type" || // import {} from 'x'
+ /{\s*}/.test(options.originalText.slice(options.locStart(n), options.locStart(n.source)))) {
+ parts.push("{} from ");
+ }
+
+ parts.push(path.call(print, "source"), semi);
+ return concat$6(parts);
+ }
+
+ case "Import":
+ return "import";
+
+ case "TSModuleBlock":
+ case "BlockStatement":
+ {
+ const naked = path.call(bodyPath => {
+ return printStatementSequence(bodyPath, options, print);
+ }, "body");
+ const hasContent = n.body.find(node => node.type !== "EmptyStatement");
+ const hasDirectives = n.directives && n.directives.length > 0;
+ const parent = path.getParentNode();
+ const parentParent = path.getParentNode(1);
+
+ if (!hasContent && !hasDirectives && !hasDanglingComments$1(n) && (parent.type === "ArrowFunctionExpression" || parent.type === "FunctionExpression" || parent.type === "FunctionDeclaration" || parent.type === "ObjectMethod" || parent.type === "ClassMethod" || parent.type === "ClassPrivateMethod" || parent.type === "ForStatement" || parent.type === "WhileStatement" || parent.type === "DoWhileStatement" || parent.type === "DoExpression" || parent.type === "CatchClause" && !parentParent.finalizer || parent.type === "TSModuleDeclaration")) {
+ return "{}";
+ }
+
+ parts.push("{"); // Babel 6
+
+ if (hasDirectives) {
+ path.each(childPath => {
+ parts.push(indent$3(concat$6([hardline$4, print(childPath), semi])));
+
+ if (isNextLineEmpty$2(options.originalText, childPath.getValue(), options.locEnd)) {
+ parts.push(hardline$4);
+ }
+ }, "directives");
+ }
+
+ if (hasContent) {
+ parts.push(indent$3(concat$6([hardline$4, naked])));
+ }
+
+ parts.push(comments.printDanglingComments(path, options));
+ parts.push(hardline$4, "}");
+ return concat$6(parts);
+ }
+
+ case "ReturnStatement":
+ return concat$6(["return", printReturnAndThrowArgument(path, options, print)]);
+
+ case "NewExpression":
+ case "OptionalCallExpression":
+ case "CallExpression":
+ {
+ const isNew = n.type === "NewExpression";
+ const optional = printOptionalToken(path);
+
+ if ( // We want to keep CommonJS- and AMD-style require calls, and AMD-style
+ // define calls, as a unit.
+ // e.g. `define(["some/lib", (lib) => {`
+ !isNew && n.callee.type === "Identifier" && (n.callee.name === "require" || n.callee.name === "define") || // Template literals as single arguments
+ n.arguments.length === 1 && isTemplateOnItsOwnLine$1(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
+ // e.g. `it('long name', () => {`
+ !isNew && isTestCall$1(n, path.getParentNode())) {
+ return concat$6([isNew ? "new " : "", path.call(print, "callee"), optional, printFunctionTypeParameters(path, options, print), concat$6(["(", join$4(", ", path.map(print, "arguments")), ")"])]);
+ } // Inline Flow annotation comments following Identifiers in Call nodes need to
+ // stay with the Identifier. For example:
+ //
+ // foo /*:: */(bar);
+ //
+ // Here, we ensure that such comments stay between the Identifier and the Callee.
+
+
+ const isIdentifierWithFlowAnnotation = n.callee.type === "Identifier" && hasFlowAnnotationComment$1(n.callee.trailingComments);
+
+ if (isIdentifierWithFlowAnnotation) {
+ n.callee.trailingComments[0].printed = true;
+ } // We detect calls on member lookups and possibly print them in a
+ // special chain format. See `printMemberChain` for more info.
+
+
+ if (!isNew && isMemberish$1(n.callee) && !path.call(path => needsParens_1(path, options), "callee")) {
+ return printMemberChain(path, options, print);
+ }
+
+ const contents = concat$6([isNew ? "new " : "", path.call(print, "callee"), optional, isIdentifierWithFlowAnnotation ? `/*:: ${n.callee.trailingComments[0].value.slice(2).trim()} */` : "", printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]); // We group here when the callee is itself a call expression.
+ // See `isLongCurriedCallExpression` for more info.
+
+ if (isCallOrOptionalCallExpression$1(n.callee)) {
+ return group$2(contents);
+ }
+
+ return contents;
+ }
+
+ case "TSInterfaceDeclaration":
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ parts.push(n.abstract ? "abstract " : "", printTypeScriptModifiers(path, options, print), "interface ", path.call(print, "id"), n.typeParameters ? path.call(print, "typeParameters") : "", " ");
+
+ if (n.extends && n.extends.length) {
+ parts.push(group$2(indent$3(concat$6([softline$2, "extends ", (n.extends.length === 1 ? identity$2 : indent$3)(join$4(concat$6([",", line$4]), path.map(print, "extends"))), " "]))));
+ }
+
+ parts.push(path.call(print, "body"));
+ return concat$6(parts);
+
+ case "ObjectTypeInternalSlot":
+ return concat$6([n.static ? "static " : "", "[[", path.call(print, "id"), "]]", printOptionalToken(path), n.method ? "" : ": ", path.call(print, "value")]);
+
+ case "ObjectExpression":
+ case "ObjectPattern":
+ case "ObjectTypeAnnotation":
+ case "TSInterfaceBody":
+ case "TSTypeLiteral":
+ {
+ let propertiesField;
+
+ if (n.type === "TSTypeLiteral") {
+ propertiesField = "members";
+ } else if (n.type === "TSInterfaceBody") {
+ propertiesField = "body";
+ } else {
+ propertiesField = "properties";
+ }
+
+ const isTypeAnnotation = n.type === "ObjectTypeAnnotation";
+ const fields = [];
+
+ if (isTypeAnnotation) {
+ fields.push("indexers", "callProperties", "internalSlots");
+ }
+
+ fields.push(propertiesField);
+ const firstProperty = fields.map(field => n[field][0]).sort((a, b) => options.locStart(a) - options.locStart(b))[0];
+ const parent = path.getParentNode(0);
+ const isFlowInterfaceLikeBody = isTypeAnnotation && parent && (parent.type === "InterfaceDeclaration" || parent.type === "DeclareInterface" || parent.type === "DeclareClass") && path.getName() === "body";
+ const shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" && parent.type !== "FunctionDeclaration" && parent.type !== "FunctionExpression" && parent.type !== "ArrowFunctionExpression" && parent.type !== "ObjectMethod" && parent.type !== "ClassMethod" && parent.type !== "ClassPrivateMethod" && parent.type !== "AssignmentPattern" && parent.type !== "CatchClause" && n.properties.some(property => property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern")) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$3(options.originalText, options.locStart(n), options.locStart(firstProperty));
+ const separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$1(semi, ";") : ",";
+ const leftBrace = n.exact ? "{|" : "{";
+ const rightBrace = n.exact ? "|}" : "}"; // Unfortunately, things are grouped together in the ast can be
+ // interleaved in the source code. So we need to reorder them before
+ // printing them.
+
+ const propsAndLoc = [];
+ fields.forEach(field => {
+ path.each(childPath => {
+ const node = childPath.getValue();
+ propsAndLoc.push({
+ node,
+ printed: print(childPath),
+ loc: options.locStart(node)
+ });
+ }, field);
+ });
+ let separatorParts = [];
+ const props = propsAndLoc.sort((a, b) => a.loc - b.loc).map(prop => {
+ const result = concat$6(separatorParts.concat(group$2(prop.printed)));
+ separatorParts = [separator, line$4];
+
+ if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature" || prop.node.type === "TSConstructSignatureDeclaration") && hasNodeIgnoreComment$2(prop.node)) {
+ separatorParts.shift();
+ }
+
+ if (isNextLineEmpty$2(options.originalText, prop.node, options.locEnd)) {
+ separatorParts.push(hardline$4);
+ }
+
+ return result;
+ });
+
+ if (n.inexact) {
+ let printed;
+
+ if (hasDanglingComments$1(n)) {
+ const hasLineComments = !n.comments.every(comments$1.isBlockComment);
+ const printedDanglingComments = comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true);
+ printed = concat$6([printedDanglingComments, hasLineComments || hasNewline$4(options.originalText, options.locEnd(n.comments[n.comments.length - 1])) ? hardline$4 : line$4, "..."]);
+ } else {
+ printed = "...";
+ }
+
+ props.push(concat$6(separatorParts.concat(printed)));
+ }
+
+ const lastElem = getLast$2(n[propertiesField]);
+ const canHaveTrailingSeparator = !(n.inexact || lastElem && (lastElem.type === "RestElement" || hasNodeIgnoreComment$2(lastElem)));
+ let content;
+
+ if (props.length === 0) {
+ if (!hasDanglingComments$1(n)) {
+ return concat$6([leftBrace, rightBrace, printTypeAnnotation(path, options, print)]);
+ }
+
+ content = group$2(concat$6([leftBrace, comments.printDanglingComments(path, options), softline$2, rightBrace, printOptionalToken(path), printTypeAnnotation(path, options, print)]));
+ } else {
+ content = concat$6([leftBrace, indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, concat$6(props)])), ifBreak$1(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma(options)) ? separator : ""), concat$6([options.bracketSpacing ? line$4 : softline$2, rightBrace]), printOptionalToken(path), printTypeAnnotation(path, options, print)]);
+ } // If we inline the object as first argument of the parent, we don't want
+ // to create another group so that the object breaks before the return
+ // type
+
+
+ if (path.match(node => node.type === "ObjectPattern" && !node.decorators, (node, name, number) => shouldHugArguments(node) && (name === "params" || name === "parameters") && number === 0) || path.match(shouldHugType, (node, name) => name === "typeAnnotation", (node, name) => name === "typeAnnotation", (node, name, number) => shouldHugArguments(node) && (name === "params" || name === "parameters") && number === 0)) {
+ return content;
+ }
+
+ return group$2(content, {
+ shouldBreak
+ });
+ }
+ // Babel 6
+
+ case "ObjectProperty": // Non-standard AST node type.
+
+ case "Property":
+ if (n.method || n.kind === "get" || n.kind === "set") {
+ return printMethod(path, options, print);
+ }
+
+ if (n.shorthand) {
+ parts.push(path.call(print, "value"));
+ } else {
+ parts.push(printAssignment(n.key, printPropertyKey(path, options, print), ":", n.value, path.call(print, "value"), options));
+ }
+
+ return concat$6(parts);
+ // Babel 6
+
+ case "ClassMethod":
+ case "ClassPrivateMethod":
+ case "MethodDefinition":
+ case "TSAbstractMethodDefinition":
+ case "TSDeclareMethod":
+ if (n.decorators && n.decorators.length !== 0) {
+ parts.push(printDecorators(path, options, print));
+ }
+
+ if (n.accessibility) {
+ parts.push(n.accessibility + " ");
+ }
+
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ if (n.type === "TSAbstractMethodDefinition" || n.abstract) {
+ parts.push("abstract ");
+ }
+
+ parts.push(printMethod(path, options, print));
+ return concat$6(parts);
+
+ case "ObjectMethod":
+ return printMethod(path, options, print);
+
+ case "Decorator":
+ return concat$6(["@", path.call(print, "expression"), path.call(print, "callee")]);
+
+ case "ArrayExpression":
+ case "ArrayPattern":
+ if (n.elements.length === 0) {
+ if (!hasDanglingComments$1(n)) {
+ parts.push("[]");
+ } else {
+ parts.push(group$2(concat$6(["[", comments.printDanglingComments(path, options), softline$2, "]"])));
+ }
+ } else {
+ const lastElem = getLast$2(n.elements);
+ const canHaveTrailingComma = !(lastElem && lastElem.type === "RestElement"); // JavaScript allows you to have empty elements in an array which
+ // changes its length based on the number of commas. The algorithm
+ // is that if the last argument is null, we need to force insert
+ // a comma to ensure JavaScript recognizes it.
+ // [,].length === 1
+ // [1,].length === 1
+ // [1,,].length === 2
+ //
+ // Note that getLast returns null if the array is empty, but
+ // we already check for an empty array just above so we are safe
+
+ const needsForcedTrailingComma = canHaveTrailingComma && lastElem === null;
+ const shouldBreak = n.elements.length > 1 && n.elements.every((element, i, elements) => {
+ const elementType = element && element.type;
+
+ if (elementType !== "ArrayExpression" && elementType !== "ObjectExpression") {
+ return false;
+ }
+
+ const nextElement = elements[i + 1];
+
+ if (nextElement && elementType !== nextElement.type) {
+ return false;
+ }
+
+ const itemsKey = elementType === "ArrayExpression" ? "elements" : "properties";
+ return element[itemsKey] && element[itemsKey].length > 1;
+ });
+ parts.push(group$2(concat$6(["[", indent$3(concat$6([softline$2, printArrayItems(path, options, "elements", print)])), needsForcedTrailingComma ? "," : "", ifBreak$1(canHaveTrailingComma && !needsForcedTrailingComma && shouldPrintComma(options) ? "," : ""), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), softline$2, "]"]), {
+ shouldBreak
+ }));
+ }
+
+ parts.push(printOptionalToken(path), printTypeAnnotation(path, options, print));
+ return concat$6(parts);
+
+ case "SequenceExpression":
+ {
+ const parent = path.getParentNode(0);
+
+ if (parent.type === "ExpressionStatement" || parent.type === "ForStatement") {
+ // For ExpressionStatements and for-loop heads, which are among
+ // the few places a SequenceExpression appears unparenthesized, we want
+ // to indent expressions after the first.
+ const parts = [];
+ path.each(p => {
+ if (p.getName() === 0) {
+ parts.push(print(p));
+ } else {
+ parts.push(",", indent$3(concat$6([line$4, print(p)])));
+ }
+ }, "expressions");
+ return group$2(concat$6(parts));
+ }
+
+ return group$2(concat$6([join$4(concat$6([",", line$4]), path.map(print, "expressions"))]));
+ }
+
+ case "ThisExpression":
+ return "this";
+
+ case "Super":
+ return "super";
+
+ case "NullLiteral":
+ // Babel 6 Literal split
+ return "null";
+
+ case "RegExpLiteral":
+ // Babel 6 Literal split
+ return printRegex(n);
+
+ case "NumericLiteral":
+ // Babel 6 Literal split
+ return printNumber$1(n.extra.raw);
+
+ case "BigIntLiteral":
+ // babel: n.extra.raw, typescript: n.raw, flow: n.bigint
+ return (n.bigint || (n.extra ? n.extra.raw : n.raw)).toLowerCase();
+
+ case "BooleanLiteral": // Babel 6 Literal split
+
+ case "StringLiteral": // Babel 6 Literal split
+
+ case "Literal":
+ {
+ if (n.regex) {
+ return printRegex(n.regex);
+ }
+
+ if (typeof n.value === "number") {
+ return printNumber$1(n.raw);
+ }
+
+ if (typeof n.value !== "string") {
+ return "" + n.value;
+ } // TypeScript workaround for https://github.com/JamesHenry/typescript-estree/issues/2
+ // See corresponding workaround in needs-parens.js
+
+
+ const grandParent = path.getParentNode(1);
+ const isTypeScriptDirective = options.parser === "typescript" && typeof n.value === "string" && grandParent && (grandParent.type === "Program" || grandParent.type === "BlockStatement");
+ return nodeStr(n, options, isTypeScriptDirective);
+ }
+
+ case "Directive":
+ return path.call(print, "value");
+ // Babel 6
+
+ case "DirectiveLiteral":
+ return nodeStr(n, options);
+
+ case "UnaryExpression":
+ parts.push(n.operator);
+
+ if (/[a-z]$/.test(n.operator)) {
+ parts.push(" ");
+ }
+
+ if (n.argument.comments && n.argument.comments.length > 0) {
+ parts.push(group$2(concat$6(["(", indent$3(concat$6([softline$2, path.call(print, "argument")])), softline$2, ")"])));
+ } else {
+ parts.push(path.call(print, "argument"));
+ }
+
+ return concat$6(parts);
+
+ case "UpdateExpression":
+ parts.push(path.call(print, "argument"), n.operator);
+
+ if (n.prefix) {
+ parts.reverse();
+ }
+
+ return concat$6(parts);
+
+ case "ConditionalExpression":
+ return printTernaryOperator(path, options, print, {
+ beforeParts: () => [path.call(print, "test")],
+ afterParts: breakClosingParen => [breakClosingParen ? softline$2 : ""],
+ shouldCheckJsx: true,
+ conditionalNodeType: "ConditionalExpression",
+ consequentNodePropertyName: "consequent",
+ alternateNodePropertyName: "alternate",
+ testNodePropertyNames: ["test"]
+ });
+
+ case "VariableDeclaration":
+ {
+ const printed = path.map(childPath => {
+ return print(childPath);
+ }, "declarations"); // We generally want to terminate all variable declarations with a
+ // semicolon, except when they in the () part of for loops.
+
+ const parentNode = path.getParentNode();
+ const isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement";
+ const hasValue = n.declarations.some(decl => decl.init);
+ let firstVariable;
+
+ if (printed.length === 1 && !n.declarations[0].comments) {
+ firstVariable = printed[0];
+ } else if (printed.length > 0) {
+ // Indent first var to comply with eslint one-var rule
+ firstVariable = indent$3(printed[0]);
+ }
+
+ parts = [n.declare ? "declare " : "", n.kind, firstVariable ? concat$6([" ", firstVariable]) : "", indent$3(concat$6(printed.slice(1).map(p => concat$6([",", hasValue && !isParentForLoop ? hardline$4 : line$4, p]))))];
+
+ if (!(isParentForLoop && parentNode.body !== n)) {
+ parts.push(semi);
+ }
+
+ return group$2(concat$6(parts));
+ }
+
+ case "TSTypeAliasDeclaration":
+ {
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ const printed = printAssignmentRight(n.id, n.typeAnnotation, n.typeAnnotation && path.call(print, "typeAnnotation"), options);
+ parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", printed, semi);
+ return group$2(concat$6(parts));
+ }
+
+ case "VariableDeclarator":
+ return printAssignment(n.id, path.call(print, "id"), " =", n.init, n.init && path.call(print, "init"), options);
+
+ case "WithStatement":
+ return group$2(concat$6(["with (", path.call(print, "object"), ")", adjustClause(n.body, path.call(print, "body"))]));
+
+ case "IfStatement":
+ {
+ const con = adjustClause(n.consequent, path.call(print, "consequent"));
+ const opening = group$2(concat$6(["if (", group$2(concat$6([indent$3(concat$6([softline$2, path.call(print, "test")])), softline$2])), ")", con]));
+ parts.push(opening);
+
+ if (n.alternate) {
+ const commentOnOwnLine = hasTrailingComment$1(n.consequent) && n.consequent.comments.some(comment => comment.trailing && !comments$1.isBlockComment(comment)) || needsHardlineAfterDanglingComment$1(n);
+ const elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine;
+ parts.push(elseOnSameLine ? " " : hardline$4);
+
+ if (hasDanglingComments$1(n)) {
+ parts.push(comments.printDanglingComments(path, options, true), commentOnOwnLine ? hardline$4 : " ");
+ }
+
+ parts.push("else", group$2(adjustClause(n.alternate, path.call(print, "alternate"), n.alternate.type === "IfStatement")));
+ }
+
+ return concat$6(parts);
+ }
+
+ case "ForStatement":
+ {
+ const body = adjustClause(n.body, path.call(print, "body")); // We want to keep dangling comments above the loop to stay consistent.
+ // Any comment positioned between the for statement and the parentheses
+ // is going to be printed before the statement.
+
+ const dangling = comments.printDanglingComments(path, options,
+ /* sameLine */
+ true);
+ const printedComments = dangling ? concat$6([dangling, softline$2]) : "";
+
+ if (!n.init && !n.test && !n.update) {
+ return concat$6([printedComments, group$2(concat$6(["for (;;)", body]))]);
+ }
+
+ return concat$6([printedComments, group$2(concat$6(["for (", group$2(concat$6([indent$3(concat$6([softline$2, path.call(print, "init"), ";", line$4, path.call(print, "test"), ";", line$4, path.call(print, "update")])), softline$2])), ")", body]))]);
+ }
+
+ case "WhileStatement":
+ return group$2(concat$6(["while (", group$2(concat$6([indent$3(concat$6([softline$2, path.call(print, "test")])), softline$2])), ")", adjustClause(n.body, path.call(print, "body"))]));
+
+ case "ForInStatement":
+ // Note: esprima can't actually parse "for each (".
+ return group$2(concat$6([n.each ? "for each (" : "for (", path.call(print, "left"), " in ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
+
+ case "ForOfStatement":
+ return group$2(concat$6(["for", n.await ? " await" : "", " (", path.call(print, "left"), " of ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
+
+ case "DoWhileStatement":
+ {
+ const clause = adjustClause(n.body, path.call(print, "body"));
+ const doBody = group$2(concat$6(["do", clause]));
+ parts = [doBody];
+
+ if (n.body.type === "BlockStatement") {
+ parts.push(" ");
+ } else {
+ parts.push(hardline$4);
+ }
+
+ parts.push("while (");
+ parts.push(group$2(concat$6([indent$3(concat$6([softline$2, path.call(print, "test")])), softline$2])), ")", semi);
+ return concat$6(parts);
+ }
+
+ case "DoExpression":
+ return concat$6(["do ", path.call(print, "body")]);
+
+ case "BreakStatement":
+ parts.push("break");
+
+ if (n.label) {
+ parts.push(" ", path.call(print, "label"));
+ }
+
+ parts.push(semi);
+ return concat$6(parts);
+
+ case "ContinueStatement":
+ parts.push("continue");
+
+ if (n.label) {
+ parts.push(" ", path.call(print, "label"));
+ }
+
+ parts.push(semi);
+ return concat$6(parts);
+
+ case "LabeledStatement":
+ if (n.body.type === "EmptyStatement") {
+ return concat$6([path.call(print, "label"), ":;"]);
+ }
+
+ return concat$6([path.call(print, "label"), ": ", path.call(print, "body")]);
+
+ case "TryStatement":
+ return concat$6(["try ", path.call(print, "block"), n.handler ? concat$6([" ", path.call(print, "handler")]) : "", n.finalizer ? concat$6([" finally ", path.call(print, "finalizer")]) : ""]);
+
+ case "CatchClause":
+ if (n.param) {
+ const hasComments = n.param.comments && n.param.comments.some(comment => !comments$1.isBlockComment(comment) || comment.leading && hasNewline$4(options.originalText, options.locEnd(comment)) || comment.trailing && hasNewline$4(options.originalText, options.locStart(comment), {
+ backwards: true
+ }));
+ const param = path.call(print, "param");
+ return concat$6(["catch ", hasComments ? concat$6(["(", indent$3(concat$6([softline$2, param])), softline$2, ") "]) : concat$6(["(", param, ") "]), path.call(print, "body")]);
+ }
+
+ return concat$6(["catch ", path.call(print, "body")]);
+
+ case "ThrowStatement":
+ return concat$6(["throw", printReturnAndThrowArgument(path, options, print)]);
+ // Note: ignoring n.lexical because it has no printing consequences.
+
+ case "SwitchStatement":
+ return concat$6([group$2(concat$6(["switch (", indent$3(concat$6([softline$2, path.call(print, "discriminant")])), softline$2, ")"])), " {", n.cases.length > 0 ? indent$3(concat$6([hardline$4, join$4(hardline$4, path.map(casePath => {
+ const caseNode = casePath.getValue();
+ return concat$6([casePath.call(print), n.cases.indexOf(caseNode) !== n.cases.length - 1 && isNextLineEmpty$2(options.originalText, caseNode, options.locEnd) ? hardline$4 : ""]);
+ }, "cases"))])) : "", hardline$4, "}"]);
+
+ case "SwitchCase":
+ {
+ if (n.test) {
+ parts.push("case ", path.call(print, "test"), ":");
+ } else {
+ parts.push("default:");
+ }
+
+ const consequent = n.consequent.filter(node => node.type !== "EmptyStatement");
+
+ if (consequent.length > 0) {
+ const cons = path.call(consequentPath => {
+ return printStatementSequence(consequentPath, options, print);
+ }, "consequent");
+ parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? concat$6([" ", cons]) : indent$3(concat$6([hardline$4, cons])));
+ }
+
+ return concat$6(parts);
+ }
+ // JSX extensions below.
+
+ case "DebuggerStatement":
+ return concat$6(["debugger", semi]);
+
+ case "JSXAttribute":
+ parts.push(path.call(print, "name"));
+
+ if (n.value) {
+ let res;
+
+ if (isStringLiteral$1(n.value)) {
+ const raw = rawText$1(n.value); // Unescape all quotes so we get an accurate preferred quote
+
+ let final = raw.replace(/'/g, "'").replace(/"/g, '"');
+ const quote = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"');
+ const escape = quote === "'" ? "'" : """;
+ final = final.slice(1, -1).replace(new RegExp(quote, "g"), escape);
+ res = concat$6([quote, final, quote]);
+ } else {
+ res = path.call(print, "value");
+ }
+
+ parts.push("=", res);
+ }
+
+ return concat$6(parts);
+
+ case "JSXIdentifier":
+ return "" + n.name;
+
+ case "JSXNamespacedName":
+ return join$4(":", [path.call(print, "namespace"), path.call(print, "name")]);
+
+ case "JSXMemberExpression":
+ return join$4(".", [path.call(print, "object"), path.call(print, "property")]);
+
+ case "TSQualifiedName":
+ return join$4(".", [path.call(print, "left"), path.call(print, "right")]);
+
+ case "JSXSpreadAttribute":
+ case "JSXSpreadChild":
+ {
+ return concat$6(["{", path.call(p => {
+ const printed = concat$6(["...", print(p)]);
+ const n = p.getValue();
+
+ if (!n.comments || !n.comments.length) {
+ return printed;
+ }
+
+ return concat$6([indent$3(concat$6([softline$2, comments.printComments(p, () => printed, options)])), softline$2]);
+ }, n.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"]);
+ }
+
+ case "JSXExpressionContainer":
+ {
+ const parent = path.getParentNode(0);
+ const hasComments = n.expression.comments && n.expression.comments.length > 0;
+ const shouldInline = n.expression.type === "JSXEmptyExpression" || !hasComments && (n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression" || n.expression.type === "ArrowFunctionExpression" || n.expression.type === "CallExpression" || n.expression.type === "OptionalCallExpression" || n.expression.type === "FunctionExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode$1(parent) && (n.expression.type === "ConditionalExpression" || isBinaryish$1(n.expression)));
+
+ if (shouldInline) {
+ return group$2(concat$6(["{", path.call(print, "expression"), lineSuffixBoundary$1, "}"]));
+ }
+
+ return group$2(concat$6(["{", indent$3(concat$6([softline$2, path.call(print, "expression")])), softline$2, lineSuffixBoundary$1, "}"]));
+ }
+
+ case "JSXFragment":
+ case "JSXElement":
+ {
+ const elem = comments.printComments(path, () => printJSXElement(path, options, print), options);
+ return maybeWrapJSXElementInParens(path, elem, options);
+ }
+
+ case "JSXOpeningElement":
+ {
+ const n = path.getValue();
+ const nameHasComments = n.name && n.name.comments && n.name.comments.length > 0 || n.typeParameters && n.typeParameters.comments && n.typeParameters.comments.length > 0; // Don't break self-closing elements with no attributes and no comments
+
+ if (n.selfClosing && !n.attributes.length && !nameHasComments) {
+ return concat$6(["<", path.call(print, "name"), path.call(print, "typeParameters"), " />"]);
+ } // don't break up opening elements with a single long text attribute
+
+
+ if (n.attributes && n.attributes.length === 1 && n.attributes[0].value && isStringLiteral$1(n.attributes[0].value) && !n.attributes[0].value.value.includes("\n") && // We should break for the following cases:
+ //
+ //
+ !nameHasComments && (!n.attributes[0].comments || !n.attributes[0].comments.length)) {
+ return group$2(concat$6(["<", path.call(print, "name"), path.call(print, "typeParameters"), " ", concat$6(path.map(print, "attributes")), n.selfClosing ? " />" : ">"]));
+ }
+
+ const lastAttrHasTrailingComments = n.attributes.length && hasTrailingComment$1(getLast$2(n.attributes));
+ const bracketSameLine = // Simple tags (no attributes and no comment in tag name) should be
+ // kept unbroken regardless of `jsxBracketSameLine`
+ !n.attributes.length && !nameHasComments || options.jsxBracketSameLine && ( // We should print the bracket in a new line for the following cases:
+ //
+ //
+ !nameHasComments || n.attributes.length) && !lastAttrHasTrailingComments; // We should print the opening element expanded if any prop value is a
+ // string literal with newlines
+
+ const shouldBreak = n.attributes && n.attributes.some(attr => attr.value && isStringLiteral$1(attr.value) && attr.value.value.includes("\n"));
+ return group$2(concat$6(["<", path.call(print, "name"), path.call(print, "typeParameters"), concat$6([indent$3(concat$6(path.map(attr => concat$6([line$4, print(attr)]), "attributes"))), n.selfClosing ? line$4 : bracketSameLine ? ">" : softline$2]), n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), {
+ shouldBreak
+ });
+ }
+
+ case "JSXClosingElement":
+ return concat$6(["", path.call(print, "name"), ">"]);
+
+ case "JSXOpeningFragment":
+ case "JSXClosingFragment":
+ {
+ const hasComment = n.comments && n.comments.length;
+ const hasOwnLineComment = hasComment && !n.comments.every(comments$1.isBlockComment);
+ const isOpeningFragment = n.type === "JSXOpeningFragment";
+ return concat$6([isOpeningFragment ? "<" : "", indent$3(concat$6([hasOwnLineComment ? hardline$4 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path, options, true)])), hasOwnLineComment ? hardline$4 : "", ">"]);
+ }
+
+ case "JSXText":
+ /* istanbul ignore next */
+ throw new Error("JSXTest should be handled by JSXElement");
+
+ case "JSXEmptyExpression":
+ {
+ const requiresHardline = n.comments && !n.comments.every(comments$1.isBlockComment);
+ return concat$6([comments.printDanglingComments(path, options,
+ /* sameIndent */
+ !requiresHardline), requiresHardline ? hardline$4 : ""]);
+ }
+
+ case "ClassBody":
+ if (!n.comments && n.body.length === 0) {
+ return "{}";
+ }
+
+ return concat$6(["{", n.body.length > 0 ? indent$3(concat$6([hardline$4, path.call(bodyPath => {
+ return printStatementSequence(bodyPath, options, print);
+ }, "body")])) : comments.printDanglingComments(path, options), hardline$4, "}"]);
+
+ case "ClassProperty":
+ case "TSAbstractClassProperty":
+ case "ClassPrivateProperty":
+ {
+ if (n.decorators && n.decorators.length !== 0) {
+ parts.push(printDecorators(path, options, print));
+ }
+
+ if (n.accessibility) {
+ parts.push(n.accessibility + " ");
+ }
+
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ if (n.type === "TSAbstractClassProperty" || n.abstract) {
+ parts.push("abstract ");
+ }
+
+ if (n.readonly) {
+ parts.push("readonly ");
+ }
+
+ const variance = getFlowVariance$1(n);
+
+ if (variance) {
+ parts.push(variance);
+ }
+
+ parts.push(printPropertyKey(path, options, print), printOptionalToken(path), printTypeAnnotation(path, options, print));
+
+ if (n.value) {
+ parts.push(" =", printAssignmentRight(n.key, n.value, path.call(print, "value"), options));
+ }
+
+ parts.push(semi);
+ return group$2(concat$6(parts));
+ }
+
+ case "ClassDeclaration":
+ case "ClassExpression":
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ parts.push(concat$6(printClass(path, options, print)));
+ return concat$6(parts);
+
+ case "TSInterfaceHeritage":
+ case "TSExpressionWithTypeArguments":
+ // Babel AST
+ parts.push(path.call(print, "expression"));
+
+ if (n.typeParameters) {
+ parts.push(path.call(print, "typeParameters"));
+ }
+
+ return concat$6(parts);
+
+ case "TemplateElement":
+ return join$4(literalline$2, n.value.raw.split(/\r?\n/g));
+
+ case "TemplateLiteral":
+ {
+ let expressions = path.map(print, "expressions");
+ const parentNode = path.getParentNode();
+
+ if (isJestEachTemplateLiteral$1(n, parentNode)) {
+ const printed = printJestEachTemplateLiteral(n, expressions, options);
+
+ if (printed) {
+ return printed;
+ }
+ }
+
+ const isSimple = isSimpleTemplateLiteral$1(n);
+
+ if (isSimple) {
+ expressions = expressions.map(doc => printDocToString$2(doc, Object.assign({}, options, {
+ printWidth: Infinity
+ })).formatted);
+ }
+
+ parts.push(lineSuffixBoundary$1, "`");
+ path.each(childPath => {
+ const i = childPath.getName();
+ parts.push(print(childPath));
+
+ if (i < expressions.length) {
+ // For a template literal of the following form:
+ // `someQuery {
+ // ${call({
+ // a,
+ // b,
+ // })}
+ // }`
+ // the expression is on its own line (there is a \n in the previous
+ // quasi literal), therefore we want to indent the JavaScript
+ // expression inside at the beginning of ${ instead of the beginning
+ // of the `.
+ const {
+ tabWidth
+ } = options;
+ const quasi = childPath.getValue();
+ const indentSize = getIndentSize$2(quasi.value.raw, tabWidth);
+ let printed = expressions[i];
+
+ if (!isSimple) {
+ // Breaks at the template element boundaries (${ and }) are preferred to breaking
+ // in the middle of a MemberExpression
+ if (n.expressions[i].comments && n.expressions[i].comments.length || n.expressions[i].type === "MemberExpression" || n.expressions[i].type === "OptionalMemberExpression" || n.expressions[i].type === "ConditionalExpression" || n.expressions[i].type === "SequenceExpression" || n.expressions[i].type === "TSAsExpression" || isBinaryish$1(n.expressions[i])) {
+ printed = concat$6([indent$3(concat$6([softline$2, printed])), softline$2]);
+ }
+ }
+
+ const aligned = indentSize === 0 && quasi.value.raw.endsWith("\n") ? align$1(-Infinity, printed) : addAlignmentToDoc$2(printed, indentSize, tabWidth);
+ parts.push(group$2(concat$6(["${", aligned, lineSuffixBoundary$1, "}"])));
+ }
+ }, "quasis");
+ parts.push("`");
+ return concat$6(parts);
+ }
+ // These types are unprintable because they serve as abstract
+ // supertypes for other (printable) types.
+
+ case "TaggedTemplateExpression":
+ return concat$6([path.call(print, "tag"), path.call(print, "typeParameters"), path.call(print, "quasi")]);
+
+ case "Node":
+ case "Printable":
+ case "SourceLocation":
+ case "Position":
+ case "Statement":
+ case "Function":
+ case "Pattern":
+ case "Expression":
+ case "Declaration":
+ case "Specifier":
+ case "NamedSpecifier":
+ case "Comment":
+ case "MemberTypeAnnotation": // Flow
+
+ case "Type":
+ /* istanbul ignore next */
+ throw new Error("unprintable type: " + JSON.stringify(n.type));
+ // Type Annotations for Facebook Flow, typically stripped out or
+ // transformed away before printing.
+
+ case "TypeAnnotation":
+ case "TSTypeAnnotation":
+ if (n.typeAnnotation) {
+ return path.call(print, "typeAnnotation");
+ }
+ /* istanbul ignore next */
+
+
+ return "";
+
+ case "TSTupleType":
+ case "TupleTypeAnnotation":
+ {
+ const typesField = n.type === "TSTupleType" ? "elementTypes" : "types";
+ const hasRest = n[typesField].length > 0 && getLast$2(n[typesField]).type === "TSRestType";
+ return group$2(concat$6(["[", indent$3(concat$6([softline$2, printArrayItems(path, options, typesField, print)])), ifBreak$1(shouldPrintComma(options, "all") && !hasRest ? "," : ""), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), softline$2, "]"]));
+ }
+
+ case "ExistsTypeAnnotation":
+ return "*";
+
+ case "EmptyTypeAnnotation":
+ return "empty";
+
+ case "AnyTypeAnnotation":
+ return "any";
+
+ case "MixedTypeAnnotation":
+ return "mixed";
+
+ case "ArrayTypeAnnotation":
+ return concat$6([path.call(print, "elementType"), "[]"]);
+
+ case "BooleanTypeAnnotation":
+ return "boolean";
+
+ case "BooleanLiteralTypeAnnotation":
+ return "" + n.value;
+
+ case "DeclareClass":
+ return printFlowDeclaration(path, printClass(path, options, print));
+
+ case "TSDeclareFunction":
+ // For TypeScript the TSDeclareFunction node shares the AST
+ // structure with FunctionDeclaration
+ return concat$6([n.declare ? "declare " : "", printFunctionDeclaration(path, print, options), semi]);
+
+ case "DeclareFunction":
+ return printFlowDeclaration(path, ["function ", path.call(print, "id"), n.predicate ? " " : "", path.call(print, "predicate"), semi]);
+
+ case "DeclareModule":
+ return printFlowDeclaration(path, ["module ", path.call(print, "id"), " ", path.call(print, "body")]);
+
+ case "DeclareModuleExports":
+ return printFlowDeclaration(path, ["module.exports", ": ", path.call(print, "typeAnnotation"), semi]);
+
+ case "DeclareVariable":
+ return printFlowDeclaration(path, ["var ", path.call(print, "id"), semi]);
+
+ case "DeclareExportAllDeclaration":
+ return concat$6(["declare export * from ", path.call(print, "source")]);
+
+ case "DeclareExportDeclaration":
+ return concat$6(["declare ", printExportDeclaration(path, options, print)]);
+
+ case "DeclareOpaqueType":
+ case "OpaqueType":
+ {
+ parts.push("opaque type ", path.call(print, "id"), path.call(print, "typeParameters"));
+
+ if (n.supertype) {
+ parts.push(": ", path.call(print, "supertype"));
+ }
+
+ if (n.impltype) {
+ parts.push(" = ", path.call(print, "impltype"));
+ }
+
+ parts.push(semi);
+
+ if (n.type === "DeclareOpaqueType") {
+ return printFlowDeclaration(path, parts);
+ }
+
+ return concat$6(parts);
+ }
+
+ case "EnumDeclaration":
+ return concat$6(["enum ", path.call(print, "id"), " ", path.call(print, "body")]);
+
+ case "EnumBooleanBody":
+ case "EnumNumberBody":
+ case "EnumStringBody":
+ case "EnumSymbolBody":
+ {
+ if (n.type === "EnumSymbolBody" || n.explicitType) {
+ let type = null;
+
+ switch (n.type) {
+ case "EnumBooleanBody":
+ type = "boolean";
+ break;
+
+ case "EnumNumberBody":
+ type = "number";
+ break;
+
+ case "EnumStringBody":
+ type = "string";
+ break;
+
+ case "EnumSymbolBody":
+ type = "symbol";
+ break;
+ }
+
+ parts.push("of ", type, " ");
+ }
+
+ if (n.members.length === 0) {
+ parts.push(group$2(concat$6(["{", comments.printDanglingComments(path, options), softline$2, "}"])));
+ } else {
+ parts.push(group$2(concat$6(["{", indent$3(concat$6([hardline$4, printArrayItems(path, options, "members", print), shouldPrintComma(options) ? "," : ""])), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), hardline$4, "}"])));
+ }
+
+ return concat$6(parts);
+ }
+
+ case "EnumBooleanMember":
+ case "EnumNumberMember":
+ case "EnumStringMember":
+ return concat$6([path.call(print, "id"), " = ", typeof n.init === "object" ? path.call(print, "init") : String(n.init)]);
+
+ case "EnumDefaultedMember":
+ return path.call(print, "id");
+
+ case "FunctionTypeAnnotation":
+ case "TSFunctionType":
+ {
+ // FunctionTypeAnnotation is ambiguous:
+ // declare function foo(a: B): void; OR
+ // var A: (a: B) => void;
+ const parent = path.getParentNode(0);
+ const parentParent = path.getParentNode(1);
+ const parentParentParent = path.getParentNode(2);
+ let isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((parent.type === "ObjectTypeProperty" || parent.type === "ObjectTypeInternalSlot") && !getFlowVariance$1(parent) && !parent.optional && options.locStart(parent) === options.locStart(n) || parent.type === "ObjectTypeCallProperty" || parentParentParent && parentParentParent.type === "DeclareFunction");
+ let needsColon = isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation"); // Sadly we can't put it inside of FastPath::needsColon because we are
+ // printing ":" as part of the expression and it would put parenthesis
+ // around :(
+
+ const needsParens = needsColon && isArrowFunctionTypeAnnotation && (parent.type === "TypeAnnotation" || parent.type === "TSTypeAnnotation") && parentParent.type === "ArrowFunctionExpression";
+
+ if (isObjectTypePropertyAFunction$1(parent, options)) {
+ isArrowFunctionTypeAnnotation = true;
+ needsColon = true;
+ }
+
+ if (needsParens) {
+ parts.push("(");
+ }
+
+ parts.push(printFunctionParams(path, print, options,
+ /* expandArg */
+ false,
+ /* printTypeParams */
+ true)); // The returnType is not wrapped in a TypeAnnotation, so the colon
+ // needs to be added separately.
+
+ if (n.returnType || n.predicate || n.typeAnnotation) {
+ parts.push(isArrowFunctionTypeAnnotation ? " => " : ": ", path.call(print, "returnType"), path.call(print, "predicate"), path.call(print, "typeAnnotation"));
+ }
+
+ if (needsParens) {
+ parts.push(")");
+ }
+
+ return group$2(concat$6(parts));
+ }
+
+ case "TSRestType":
+ return concat$6(["...", path.call(print, "typeAnnotation")]);
+
+ case "TSOptionalType":
+ return concat$6([path.call(print, "typeAnnotation"), "?"]);
+
+ case "FunctionTypeParam":
+ return concat$6([path.call(print, "name"), printOptionalToken(path), n.name ? ": " : "", path.call(print, "typeAnnotation")]);
+
+ case "GenericTypeAnnotation":
+ return concat$6([path.call(print, "id"), path.call(print, "typeParameters")]);
+
+ case "DeclareInterface":
+ case "InterfaceDeclaration":
+ case "InterfaceTypeAnnotation":
+ {
+ if (n.type === "DeclareInterface" || n.declare) {
+ parts.push("declare ");
+ }
+
+ parts.push("interface");
+
+ if (n.type === "DeclareInterface" || n.type === "InterfaceDeclaration") {
+ parts.push(" ", path.call(print, "id"), path.call(print, "typeParameters"));
+ }
+
+ if (n.extends.length > 0) {
+ parts.push(group$2(indent$3(concat$6([line$4, "extends ", (n.extends.length === 1 ? identity$2 : indent$3)(join$4(concat$6([",", line$4]), path.map(print, "extends")))]))));
+ }
+
+ parts.push(" ", path.call(print, "body"));
+ return group$2(concat$6(parts));
+ }
+
+ case "ClassImplements":
+ case "InterfaceExtends":
+ return concat$6([path.call(print, "id"), path.call(print, "typeParameters")]);
+
+ case "TSClassImplements":
+ return concat$6([path.call(print, "expression"), path.call(print, "typeParameters")]);
+
+ case "TSIntersectionType":
+ case "IntersectionTypeAnnotation":
+ {
+ const types = path.map(print, "types");
+ const result = [];
+ let wasIndented = false;
+
+ for (let i = 0; i < types.length; ++i) {
+ if (i === 0) {
+ result.push(types[i]);
+ } else if (isObjectType$1(n.types[i - 1]) && isObjectType$1(n.types[i])) {
+ // If both are objects, don't indent
+ result.push(concat$6([" & ", wasIndented ? indent$3(types[i]) : types[i]]));
+ } else if (!isObjectType$1(n.types[i - 1]) && !isObjectType$1(n.types[i])) {
+ // If no object is involved, go to the next line if it breaks
+ result.push(indent$3(concat$6([" &", line$4, types[i]])));
+ } else {
+ // If you go from object to non-object or vis-versa, then inline it
+ if (i > 1) {
+ wasIndented = true;
+ }
+
+ result.push(" & ", i > 1 ? indent$3(types[i]) : types[i]);
+ }
+ }
+
+ return group$2(concat$6(result));
+ }
+
+ case "TSUnionType":
+ case "UnionTypeAnnotation":
+ {
+ // single-line variation
+ // A | B | C
+ // multi-line variation
+ // | A
+ // | B
+ // | C
+ const parent = path.getParentNode(); // If there's a leading comment, the parent is doing the indentation
+
+ const shouldIndent = parent.type !== "TypeParameterInstantiation" && parent.type !== "TSTypeParameterInstantiation" && parent.type !== "GenericTypeAnnotation" && parent.type !== "TSTypeReference" && parent.type !== "TSTypeAssertion" && parent.type !== "TupleTypeAnnotation" && parent.type !== "TSTupleType" && !(parent.type === "FunctionTypeParam" && !parent.name) && !((parent.type === "TypeAlias" || parent.type === "VariableDeclarator" || parent.type === "TSTypeAliasDeclaration") && hasLeadingOwnLineComment$1(options.originalText, n, options)); // {
+ // a: string
+ // } | null | void
+ // should be inlined and not be printed in the multi-line variant
+
+ const shouldHug = shouldHugType(n); // We want to align the children but without its comment, so it looks like
+ // | child1
+ // // comment
+ // | child2
+
+ const printed = path.map(typePath => {
+ let printedType = typePath.call(print);
+
+ if (!shouldHug) {
+ printedType = align$1(2, printedType);
+ }
+
+ return comments.printComments(typePath, () => printedType, options);
+ }, "types");
+
+ if (shouldHug) {
+ return join$4(" | ", printed);
+ }
+
+ const shouldAddStartLine = shouldIndent && !hasLeadingOwnLineComment$1(options.originalText, n, options);
+ const code = concat$6([ifBreak$1(concat$6([shouldAddStartLine ? line$4 : "", "| "])), join$4(concat$6([line$4, "| "]), printed)]);
+
+ if (needsParens_1(path, options)) {
+ return group$2(concat$6([indent$3(code), softline$2]));
+ }
+
+ if (parent.type === "TupleTypeAnnotation" && parent.types.length > 1 || parent.type === "TSTupleType" && parent.elementTypes.length > 1) {
+ return group$2(concat$6([indent$3(concat$6([ifBreak$1(concat$6(["(", softline$2])), code])), softline$2, ifBreak$1(")")]));
+ }
+
+ return group$2(shouldIndent ? indent$3(code) : code);
+ }
+
+ case "NullableTypeAnnotation":
+ return concat$6(["?", path.call(print, "typeAnnotation")]);
+
+ case "TSNullKeyword":
+ case "NullLiteralTypeAnnotation":
+ return "null";
+
+ case "ThisTypeAnnotation":
+ return "this";
+
+ case "NumberTypeAnnotation":
+ return "number";
+
+ case "SymbolTypeAnnotation":
+ return "symbol";
+
+ case "ObjectTypeCallProperty":
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ parts.push(path.call(print, "value"));
+ return concat$6(parts);
+
+ case "ObjectTypeIndexer":
+ {
+ const variance = getFlowVariance$1(n);
+ return concat$6([variance || "", "[", path.call(print, "id"), n.id ? ": " : "", path.call(print, "key"), "]: ", path.call(print, "value")]);
+ }
+
+ case "ObjectTypeProperty":
+ {
+ const variance = getFlowVariance$1(n);
+ let modifier = "";
+
+ if (n.proto) {
+ modifier = "proto ";
+ } else if (n.static) {
+ modifier = "static ";
+ }
+
+ return concat$6([modifier, isGetterOrSetter$1(n) ? n.kind + " " : "", variance || "", printPropertyKey(path, options, print), printOptionalToken(path), isFunctionNotation$1(n, options) ? "" : ": ", path.call(print, "value")]);
+ }
+
+ case "QualifiedTypeIdentifier":
+ return concat$6([path.call(print, "qualification"), ".", path.call(print, "id")]);
+
+ case "StringLiteralTypeAnnotation":
+ return nodeStr(n, options);
+
+ case "NumberLiteralTypeAnnotation":
+ assert.strictEqual(typeof n.value, "number");
+
+ if (n.extra != null) {
+ return printNumber$1(n.extra.raw);
+ }
+
+ return printNumber$1(n.raw);
+
+ case "StringTypeAnnotation":
+ return "string";
+
+ case "DeclareTypeAlias":
+ case "TypeAlias":
+ {
+ if (n.type === "DeclareTypeAlias" || n.declare) {
+ parts.push("declare ");
+ }
+
+ const printed = printAssignmentRight(n.id, n.right, path.call(print, "right"), options);
+ parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", printed, semi);
+ return group$2(concat$6(parts));
+ }
+
+ case "TypeCastExpression":
+ {
+ return concat$6(["(", path.call(print, "expression"), printTypeAnnotation(path, options, print), ")"]);
+ }
+
+ case "TypeParameterDeclaration":
+ case "TypeParameterInstantiation":
+ {
+ const value = path.getValue();
+ const commentStart = value.range ? options.originalText.slice(0, value.range[0]).lastIndexOf("/*") : -1; // As noted in the TypeCastExpression comments above, we're able to use a normal whitespace regex here
+ // because we know for sure that this is a type definition.
+
+ const commentSyntax = commentStart >= 0 && options.originalText.slice(commentStart).match(/^\/\*\s*::/);
+
+ if (commentSyntax) {
+ return concat$6(["/*:: ", printTypeParameters(path, options, print, "params"), " */"]);
+ }
+
+ return printTypeParameters(path, options, print, "params");
+ }
+
+ case "TSTypeParameterDeclaration":
+ case "TSTypeParameterInstantiation":
+ return printTypeParameters(path, options, print, "params");
+
+ case "TSTypeParameter":
+ case "TypeParameter":
+ {
+ const parent = path.getParentNode();
+
+ if (parent.type === "TSMappedType") {
+ parts.push("[", path.call(print, "name"));
+
+ if (n.constraint) {
+ parts.push(" in ", path.call(print, "constraint"));
+ }
+
+ parts.push("]");
+ return concat$6(parts);
+ }
+
+ const variance = getFlowVariance$1(n);
+
+ if (variance) {
+ parts.push(variance);
+ }
+
+ parts.push(path.call(print, "name"));
+
+ if (n.bound) {
+ parts.push(": ");
+ parts.push(path.call(print, "bound"));
+ }
+
+ if (n.constraint) {
+ parts.push(" extends ", path.call(print, "constraint"));
+ }
+
+ if (n.default) {
+ parts.push(" = ", path.call(print, "default"));
+ } // Keep comma if the file extension is .tsx and
+ // has one type parameter that isn't extend with any types.
+ // Because, otherwise formatted result will be invalid as tsx.
+
+
+ const grandParent = path.getNode(2);
+
+ if (parent.params && parent.params.length === 1 && isTSXFile$1(options) && !n.constraint && grandParent.type === "ArrowFunctionExpression") {
+ parts.push(",");
+ }
+
+ return concat$6(parts);
+ }
+
+ case "TypeofTypeAnnotation":
+ return concat$6(["typeof ", path.call(print, "argument")]);
+
+ case "VoidTypeAnnotation":
+ return "void";
+
+ case "InferredPredicate":
+ return "%checks";
+ // Unhandled types below. If encountered, nodes of these types should
+ // be either left alone or desugared into AST types that are fully
+ // supported by the pretty-printer.
+
+ case "DeclaredPredicate":
+ return concat$6(["%checks(", path.call(print, "value"), ")"]);
+
+ case "TSAbstractKeyword":
+ return "abstract";
+
+ case "TSAnyKeyword":
+ return "any";
+
+ case "TSAsyncKeyword":
+ return "async";
+
+ case "TSBooleanKeyword":
+ return "boolean";
+
+ case "TSBigIntKeyword":
+ return "bigint";
+
+ case "TSConstKeyword":
+ return "const";
+
+ case "TSDeclareKeyword":
+ return "declare";
+
+ case "TSExportKeyword":
+ return "export";
+
+ case "TSNeverKeyword":
+ return "never";
+
+ case "TSNumberKeyword":
+ return "number";
+
+ case "TSObjectKeyword":
+ return "object";
+
+ case "TSProtectedKeyword":
+ return "protected";
+
+ case "TSPrivateKeyword":
+ return "private";
+
+ case "TSPublicKeyword":
+ return "public";
+
+ case "TSReadonlyKeyword":
+ return "readonly";
+
+ case "TSSymbolKeyword":
+ return "symbol";
+
+ case "TSStaticKeyword":
+ return "static";
+
+ case "TSStringKeyword":
+ return "string";
+
+ case "TSUndefinedKeyword":
+ return "undefined";
+
+ case "TSUnknownKeyword":
+ return "unknown";
+
+ case "TSVoidKeyword":
+ return "void";
+
+ case "TSAsExpression":
+ return concat$6([path.call(print, "expression"), " as ", path.call(print, "typeAnnotation")]);
+
+ case "TSArrayType":
+ return concat$6([path.call(print, "elementType"), "[]"]);
+
+ case "TSPropertySignature":
+ {
+ if (n.export) {
+ parts.push("export ");
+ }
+
+ if (n.accessibility) {
+ parts.push(n.accessibility + " ");
+ }
+
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ if (n.readonly) {
+ parts.push("readonly ");
+ }
+
+ parts.push(printPropertyKey(path, options, print), printOptionalToken(path));
+
+ if (n.typeAnnotation) {
+ parts.push(": ");
+ parts.push(path.call(print, "typeAnnotation"));
+ } // This isn't valid semantically, but it's in the AST so we can print it.
+
+
+ if (n.initializer) {
+ parts.push(" = ", path.call(print, "initializer"));
+ }
+
+ return concat$6(parts);
+ }
+
+ case "TSParameterProperty":
+ if (n.accessibility) {
+ parts.push(n.accessibility + " ");
+ }
+
+ if (n.export) {
+ parts.push("export ");
+ }
+
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ if (n.readonly) {
+ parts.push("readonly ");
+ }
+
+ parts.push(path.call(print, "parameter"));
+ return concat$6(parts);
+
+ case "TSTypeReference":
+ return concat$6([path.call(print, "typeName"), printTypeParameters(path, options, print, "typeParameters")]);
+
+ case "TSTypeQuery":
+ return concat$6(["typeof ", path.call(print, "exprName")]);
+
+ case "TSIndexSignature":
+ {
+ const parent = path.getParentNode(); // The typescript parser accepts multiple parameters here. If you're
+ // using them, it makes sense to have a trailing comma. But if you
+ // aren't, this is more like a computed property name than an array.
+ // So we leave off the trailing comma when there's just one parameter.
+
+ const trailingComma = n.parameters.length > 1 ? ifBreak$1(shouldPrintComma(options) ? "," : "") : "";
+ const parametersGroup = group$2(concat$6([indent$3(concat$6([softline$2, join$4(concat$6([", ", softline$2]), path.map(print, "parameters"))])), trailingComma, softline$2]));
+ return concat$6([n.export ? "export " : "", n.accessibility ? concat$6([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", n.parameters ? parametersGroup : "", n.typeAnnotation ? "]: " : "]", n.typeAnnotation ? path.call(print, "typeAnnotation") : "", parent.type === "ClassBody" ? semi : ""]);
+ }
+
+ case "TSTypePredicate":
+ return concat$6([n.asserts ? "asserts " : "", path.call(print, "parameterName"), n.typeAnnotation ? concat$6([" is ", path.call(print, "typeAnnotation")]) : ""]);
+
+ case "TSNonNullExpression":
+ return concat$6([path.call(print, "expression"), "!"]);
+
+ case "TSThisType":
+ return "this";
+
+ case "TSImportType":
+ return concat$6([!n.isTypeOf ? "" : "typeof ", "import(", path.call(print, n.parameter ? "parameter" : "argument"), ")", !n.qualifier ? "" : concat$6([".", path.call(print, "qualifier")]), printTypeParameters(path, options, print, "typeParameters")]);
+
+ case "TSLiteralType":
+ return path.call(print, "literal");
+
+ case "TSIndexedAccessType":
+ return concat$6([path.call(print, "objectType"), "[", path.call(print, "indexType"), "]"]);
+
+ case "TSConstructSignatureDeclaration":
+ case "TSCallSignatureDeclaration":
+ case "TSConstructorType":
+ {
+ if (n.type !== "TSCallSignatureDeclaration") {
+ parts.push("new ");
+ }
+
+ parts.push(group$2(printFunctionParams(path, print, options,
+ /* expandArg */
+ false,
+ /* printTypeParams */
+ true)));
+
+ if (n.returnType || n.typeAnnotation) {
+ const isType = n.type === "TSConstructorType";
+ parts.push(isType ? " => " : ": ", path.call(print, "returnType"), path.call(print, "typeAnnotation"));
+ }
+
+ return concat$6(parts);
+ }
+
+ case "TSTypeOperator":
+ return concat$6([n.operator, " ", path.call(print, "typeAnnotation")]);
+
+ case "TSMappedType":
+ {
+ const shouldBreak = hasNewlineInRange$3(options.originalText, options.locStart(n), options.locEnd(n));
+ return group$2(concat$6(["{", indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, n.readonly ? concat$6([getTypeScriptMappedTypeModifier$1(n.readonly, "readonly"), " "]) : "", printTypeScriptModifiers(path, options, print), path.call(print, "typeParameter"), n.optional ? getTypeScriptMappedTypeModifier$1(n.optional, "?") : "", n.typeAnnotation ? ": " : "", path.call(print, "typeAnnotation"), ifBreak$1(semi, "")])), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), options.bracketSpacing ? line$4 : softline$2, "}"]), {
+ shouldBreak
+ });
+ }
+
+ case "TSMethodSignature":
+ parts.push(n.accessibility ? concat$6([n.accessibility, " "]) : "", n.export ? "export " : "", n.static ? "static " : "", n.readonly ? "readonly " : "", n.computed ? "[" : "", path.call(print, "key"), n.computed ? "]" : "", printOptionalToken(path), printFunctionParams(path, print, options,
+ /* expandArg */
+ false,
+ /* printTypeParams */
+ true));
+
+ if (n.returnType || n.typeAnnotation) {
+ parts.push(": ", path.call(print, "returnType"), path.call(print, "typeAnnotation"));
+ }
+
+ return group$2(concat$6(parts));
+
+ case "TSNamespaceExportDeclaration":
+ parts.push("export as namespace ", path.call(print, "id"));
+
+ if (options.semi) {
+ parts.push(";");
+ }
+
+ return group$2(concat$6(parts));
+
+ case "TSEnumDeclaration":
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ if (n.modifiers) {
+ parts.push(printTypeScriptModifiers(path, options, print));
+ }
+
+ if (n.const) {
+ parts.push("const ");
+ }
+
+ parts.push("enum ", path.call(print, "id"), " ");
+
+ if (n.members.length === 0) {
+ parts.push(group$2(concat$6(["{", comments.printDanglingComments(path, options), softline$2, "}"])));
+ } else {
+ parts.push(group$2(concat$6(["{", indent$3(concat$6([hardline$4, printArrayItems(path, options, "members", print), shouldPrintComma(options, "es5") ? "," : ""])), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), hardline$4, "}"])));
+ }
+
+ return concat$6(parts);
+
+ case "TSEnumMember":
+ parts.push(path.call(print, "id"));
+
+ if (n.initializer) {
+ parts.push(" = ", path.call(print, "initializer"));
+ }
+
+ return concat$6(parts);
+
+ case "TSImportEqualsDeclaration":
+ if (n.isExport) {
+ parts.push("export ");
+ }
+
+ parts.push("import ", path.call(print, "id"), " = ", path.call(print, "moduleReference"));
+
+ if (options.semi) {
+ parts.push(";");
+ }
+
+ return group$2(concat$6(parts));
+
+ case "TSExternalModuleReference":
+ return concat$6(["require(", path.call(print, "expression"), ")"]);
+
+ case "TSModuleDeclaration":
+ {
+ const parent = path.getParentNode();
+ const isExternalModule = isLiteral$1(n.id);
+ const parentIsDeclaration = parent.type === "TSModuleDeclaration";
+ const bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
+
+ if (parentIsDeclaration) {
+ parts.push(".");
+ } else {
+ if (n.declare) {
+ parts.push("declare ");
+ }
+
+ parts.push(printTypeScriptModifiers(path, options, print));
+ const textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id)); // Global declaration looks like this:
+ // (declare)? global { ... }
+
+ const isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
+
+ if (!isGlobalDeclaration) {
+ parts.push(isExternalModule || /(^|\s)module(\s|$)/.test(textBetweenNodeAndItsId) ? "module " : "namespace ");
+ }
+ }
+
+ parts.push(path.call(print, "id"));
+
+ if (bodyIsDeclaration) {
+ parts.push(path.call(print, "body"));
+ } else if (n.body) {
+ parts.push(" ", group$2(path.call(print, "body")));
+ } else {
+ parts.push(semi);
+ }
+
+ return concat$6(parts);
+ }
+
+ case "PrivateName":
+ return concat$6(["#", path.call(print, "id")]);
+ // TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields.
+
+ case "TSPrivateIdentifier":
+ return n.escapedText;
+
+ case "TSConditionalType":
+ return printTernaryOperator(path, options, print, {
+ beforeParts: () => [path.call(print, "checkType"), " ", "extends", " ", path.call(print, "extendsType")],
+ afterParts: () => [],
+ shouldCheckJsx: false,
+ conditionalNodeType: "TSConditionalType",
+ consequentNodePropertyName: "trueType",
+ alternateNodePropertyName: "falseType",
+ testNodePropertyNames: ["checkType", "extendsType"]
+ });
+
+ case "TSInferType":
+ return concat$6(["infer", " ", path.call(print, "typeParameter")]);
+
+ case "InterpreterDirective":
+ parts.push("#!", n.value, hardline$4);
+
+ if (isNextLineEmpty$2(options.originalText, n, options.locEnd)) {
+ parts.push(hardline$4);
+ }
+
+ return concat$6(parts);
+
+ case "NGRoot":
+ return concat$6([].concat(path.call(print, "node"), !n.node.comments || n.node.comments.length === 0 ? [] : concat$6([" //", n.node.comments[0].value.trimEnd()])));
+
+ case "NGChainedExpression":
+ return group$2(join$4(concat$6([";", line$4]), path.map(childPath => hasNgSideEffect$1(childPath) ? print(childPath) : concat$6(["(", print(childPath), ")"]), "expressions")));
+
+ case "NGEmptyExpression":
+ return "";
+
+ case "NGQuotedExpression":
+ return concat$6([n.prefix, ": ", n.value.trim()]);
+
+ case "NGMicrosyntax":
+ return concat$6(path.map((childPath, index) => concat$6([index === 0 ? "" : isNgForOf$1(childPath.getValue(), index, n) ? " " : concat$6([";", line$4]), print(childPath)]), "body"));
+
+ case "NGMicrosyntaxKey":
+ return /^[a-z_$][a-z0-9_$]*(-[a-z_$][a-z0-9_$])*$/i.test(n.name) ? n.name : JSON.stringify(n.name);
+
+ case "NGMicrosyntaxExpression":
+ return concat$6([path.call(print, "expression"), n.alias === null ? "" : concat$6([" as ", path.call(print, "alias")])]);
+
+ case "NGMicrosyntaxKeyedExpression":
+ {
+ const index = path.getName();
+ const parentNode = path.getParentNode();
+ const shouldNotPrintColon = isNgForOf$1(n, index, parentNode) || (index === 1 && (n.key.name === "then" || n.key.name === "else") || index === 2 && n.key.name === "else" && parentNode.body[index - 1].type === "NGMicrosyntaxKeyedExpression" && parentNode.body[index - 1].key.name === "then") && parentNode.body[0].type === "NGMicrosyntaxExpression";
+ return concat$6([path.call(print, "key"), shouldNotPrintColon ? " " : ": ", path.call(print, "expression")]);
+ }
+
+ case "NGMicrosyntaxLet":
+ return concat$6(["let ", path.call(print, "key"), n.value === null ? "" : concat$6([" = ", path.call(print, "value")])]);
+
+ case "NGMicrosyntaxAs":
+ return concat$6([path.call(print, "key"), " as ", path.call(print, "alias")]);
+
+ case "ArgumentPlaceholder":
+ return "?";
+ // These are not valid TypeScript. Printing them just for the sake of error recovery.
+
+ case "TSJSDocAllType":
+ return "*";
+
+ case "TSJSDocUnknownType":
+ return "?";
+
+ case "TSJSDocNullableType":
+ return concat$6(["?", path.call(print, "typeAnnotation")]);
+
+ case "TSJSDocNonNullableType":
+ return concat$6(["!", path.call(print, "typeAnnotation")]);
+
+ case "TSJSDocFunctionType":
+ return concat$6(["function(", // The parameters could be here, but typescript-estree doesn't convert them anyway (throws an error).
+ "): ", path.call(print, "typeAnnotation")]);
+
+ default:
+ /* istanbul ignore next */
+ throw new Error("unknown type: " + JSON.stringify(n.type));
+ }
+}
+
+function printStatementSequence(path, options, print) {
+ const printed = [];
+ const bodyNode = path.getNode();
+ const isClass = bodyNode.type === "ClassBody";
+ path.map((stmtPath, i) => {
+ const stmt = stmtPath.getValue(); // Just in case the AST has been modified to contain falsy
+ // "statements," it's safer simply to skip them.
+
+ /* istanbul ignore if */
+
+ if (!stmt) {
+ return;
+ } // Skip printing EmptyStatement nodes to avoid leaving stray
+ // semicolons lying around.
+
+
+ if (stmt.type === "EmptyStatement") {
+ return;
+ }
+
+ const stmtPrinted = print(stmtPath);
+ const text = options.originalText;
+ const parts = []; // in no-semi mode, prepend statement with semicolon if it might break ASI
+ // don't prepend the only JSX element in a program with semicolon
+
+ if (!options.semi && !isClass && !isTheOnlyJSXElementInMarkdown$1(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) {
+ if (stmt.comments && stmt.comments.some(comment => comment.leading)) {
+ parts.push(print(stmtPath, {
+ needsSemi: true
+ }));
+ } else {
+ parts.push(";", stmtPrinted);
+ }
+ } else {
+ parts.push(stmtPrinted);
+ }
+
+ if (!options.semi && isClass) {
+ if (classPropMayCauseASIProblems$1(stmtPath)) {
+ parts.push(";");
+ } else if (stmt.type === "ClassProperty") {
+ const nextChild = bodyNode.body[i + 1];
+
+ if (classChildNeedsASIProtection$1(nextChild)) {
+ parts.push(";");
+ }
+ }
+ }
+
+ if (isNextLineEmpty$2(text, stmt, options.locEnd) && !isLastStatement$1(stmtPath)) {
+ parts.push(hardline$4);
+ }
+
+ printed.push(concat$6(parts));
+ });
+ return join$4(hardline$4, printed);
+}
+
+function printPropertyKey(path, options, print) {
+ const node = path.getNode();
+
+ if (node.computed) {
+ return concat$6(["[", path.call(print, "key"), "]"]);
+ }
+
+ const parent = path.getParentNode();
+ const {
+ key
+ } = node;
+
+ if (node.type === "ClassPrivateProperty" && // flow has `Identifier` key, and babel has `PrivateName` key
+ key.type === "Identifier") {
+ return concat$6(["#", path.call(print, "key")]);
+ }
+
+ if (options.quoteProps === "consistent" && !needsQuoteProps.has(parent)) {
+ const objectHasStringProp = (parent.properties || parent.body || parent.members).some(prop => !prop.computed && prop.key && isStringLiteral$1(prop.key) && !isStringPropSafeToCoerceToIdentifier$1(prop, options));
+ needsQuoteProps.set(parent, objectHasStringProp);
+ }
+
+ if (key.type === "Identifier" && (options.parser === "json" || options.quoteProps === "consistent" && needsQuoteProps.get(parent))) {
+ // a -> "a"
+ const prop = printString$1(JSON.stringify(key.name), options);
+ return path.call(keyPath => comments.printComments(keyPath, () => prop, options), "key");
+ }
+
+ if (isStringPropSafeToCoerceToIdentifier$1(node, options) && (options.quoteProps === "as-needed" || options.quoteProps === "consistent" && !needsQuoteProps.get(parent))) {
+ // 'a' -> a
+ return path.call(keyPath => comments.printComments(keyPath, () => key.value, options), "key");
+ }
+
+ return path.call(print, "key");
+}
+
+function printMethod(path, options, print) {
+ const node = path.getNode();
+ const {
+ kind
+ } = node;
+ const value = node.value || node;
+ const parts = [];
+
+ if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
+ if (value.async) {
+ parts.push("async ");
+ }
+
+ if (value.generator) {
+ parts.push("*");
+ }
+ } else {
+ assert.ok(kind === "get" || kind === "set");
+ parts.push(kind, " ");
+ }
+
+ parts.push(printPropertyKey(path, options, print), node.optional || node.key.optional ? "?" : "", node === value ? printMethodInternal(path, options, print) : path.call(path => printMethodInternal(path, options, print), "value"));
+ return concat$6(parts);
+}
+
+function printMethodInternal(path, options, print) {
+ const parts = [printFunctionTypeParameters(path, options, print), group$2(concat$6([printFunctionParams(path, print, options), printReturnType(path, print, options)]))];
+
+ if (path.getNode().body) {
+ parts.push(" ", path.call(print, "body"));
+ } else {
+ parts.push(options.semi ? ";" : "");
+ }
+
+ return concat$6(parts);
+}
+
+function couldGroupArg(arg) {
+ return arg.type === "ObjectExpression" && (arg.properties.length > 0 || arg.comments) || arg.type === "ArrayExpression" && (arg.elements.length > 0 || arg.comments) || arg.type === "TSTypeAssertion" && couldGroupArg(arg.expression) || arg.type === "TSAsExpression" && couldGroupArg(arg.expression) || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && ( // we want to avoid breaking inside composite return types but not simple keywords
+ // https://github.com/prettier/prettier/issues/4070
+ // export class Thing implements OtherThing {
+ // do: (type: Type) => Provider
= memoize(
+ // (type: ObjectType): Provider => {}
+ // );
+ // }
+ // https://github.com/prettier/prettier/issues/6099
+ // app.get("/", (req, res): void => {
+ // res.send("Hello World!");
+ // });
+ !arg.returnType || !arg.returnType.typeAnnotation || arg.returnType.typeAnnotation.type !== "TSTypeReference") && (arg.body.type === "BlockStatement" || arg.body.type === "ArrowFunctionExpression" || arg.body.type === "ObjectExpression" || arg.body.type === "ArrayExpression" || arg.body.type === "CallExpression" || arg.body.type === "OptionalCallExpression" || arg.body.type === "ConditionalExpression" || isJSXNode$1(arg.body));
+}
+
+function shouldGroupLastArg(args) {
+ const lastArg = getLast$2(args);
+ const penultimateArg = getPenultimate$1(args);
+ return !hasLeadingComment$3(lastArg) && !hasTrailingComment$1(lastArg) && couldGroupArg(lastArg) && ( // If the last two arguments are of the same type,
+ // disable last element expansion.
+ !penultimateArg || penultimateArg.type !== lastArg.type);
+}
+
+function shouldGroupFirstArg(args) {
+ if (args.length !== 2) {
+ return false;
+ }
+
+ const [firstArg, secondArg] = args;
+ return (!firstArg.comments || !firstArg.comments.length) && (firstArg.type === "FunctionExpression" || firstArg.type === "ArrowFunctionExpression" && firstArg.body.type === "BlockStatement") && secondArg.type !== "FunctionExpression" && secondArg.type !== "ArrowFunctionExpression" && secondArg.type !== "ConditionalExpression" && !couldGroupArg(secondArg);
+}
+
+function printJestEachTemplateLiteral(node, expressions, options) {
+ /**
+ * a | b | expected
+ * ${1} | ${1} | ${2}
+ * ${1} | ${2} | ${3}
+ * ${2} | ${1} | ${3}
+ */
+ const headerNames = node.quasis[0].value.raw.trim().split(/\s*\|\s*/);
+
+ if (headerNames.length > 1 || headerNames.some(headerName => headerName.length !== 0)) {
+ const parts = [];
+ const stringifiedExpressions = expressions.map(doc => "${" + printDocToString$2(doc, Object.assign({}, options, {
+ printWidth: Infinity,
+ endOfLine: "lf"
+ })).formatted + "}");
+ const tableBody = [{
+ hasLineBreak: false,
+ cells: []
+ }];
+
+ for (let i = 1; i < node.quasis.length; i++) {
+ const row = tableBody[tableBody.length - 1];
+ const correspondingExpression = stringifiedExpressions[i - 1];
+ row.cells.push(correspondingExpression);
+
+ if (correspondingExpression.includes("\n")) {
+ row.hasLineBreak = true;
+ }
+
+ if (node.quasis[i].value.raw.includes("\n")) {
+ tableBody.push({
+ hasLineBreak: false,
+ cells: []
+ });
+ }
+ }
+
+ const maxColumnCount = Math.max(headerNames.length, ...tableBody.map(row => row.cells.length));
+ const maxColumnWidths = Array.from({
+ length: maxColumnCount
+ }).fill(0);
+ const table = [{
+ cells: headerNames
+ }, ...tableBody.filter(row => row.cells.length !== 0)];
+
+ for (const {
+ cells
+ } of table.filter(row => !row.hasLineBreak)) {
+ cells.forEach((cell, index) => {
+ maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$3(cell));
+ });
+ }
+
+ parts.push(lineSuffixBoundary$1, "`", indent$3(concat$6([hardline$4, join$4(hardline$4, table.map(row => join$4(" | ", row.cells.map((cell, index) => row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$3(cell))))))])), hardline$4, "`");
+ return concat$6(parts);
+ }
+}
+
+function printArgumentsList(path, options, print) {
+ const node = path.getValue();
+ const args = node.arguments;
+
+ if (args.length === 0) {
+ return concat$6(["(", comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), ")"]);
+ } // useEffect(() => { ... }, [foo, bar, baz])
+
+
+ if (args.length === 2 && args[0].type === "ArrowFunctionExpression" && args[0].params.length === 0 && args[0].body.type === "BlockStatement" && args[1].type === "ArrayExpression" && !args.find(arg => arg.comments)) {
+ return concat$6(["(", path.call(print, "arguments", 0), ", ", path.call(print, "arguments", 1), ")"]);
+ } // func(
+ // ({
+ // a,
+ // b
+ // }) => {}
+ // );
+
+
+ function shouldBreakForArrowFunctionInArguments(arg, argPath) {
+ if (!arg || arg.type !== "ArrowFunctionExpression" || !arg.body || arg.body.type !== "BlockStatement" || !arg.params || arg.params.length < 1) {
+ return false;
+ }
+
+ let shouldBreak = false;
+ argPath.each(paramPath => {
+ const printed = concat$6([print(paramPath)]);
+ shouldBreak = shouldBreak || willBreak$1(printed);
+ }, "params");
+ return shouldBreak;
+ }
+
+ let anyArgEmptyLine = false;
+ let shouldBreakForArrowFunction = false;
+ let hasEmptyLineFollowingFirstArg = false;
+ const lastArgIndex = args.length - 1;
+ const printedArguments = path.map((argPath, index) => {
+ const arg = argPath.getNode();
+ const parts = [print(argPath)];
+
+ if (index === lastArgIndex) ; else if (isNextLineEmpty$2(options.originalText, arg, options.locEnd)) {
+ if (index === 0) {
+ hasEmptyLineFollowingFirstArg = true;
+ }
+
+ anyArgEmptyLine = true;
+ parts.push(",", hardline$4, hardline$4);
+ } else {
+ parts.push(",", line$4);
+ }
+
+ shouldBreakForArrowFunction = shouldBreakForArrowFunctionInArguments(arg, argPath);
+ return concat$6(parts);
+ }, "arguments");
+ const maybeTrailingComma = // Dynamic imports cannot have trailing commas
+ !(node.callee && node.callee.type === "Import") && shouldPrintComma(options, "all") ? "," : "";
+
+ function allArgsBrokenOut() {
+ return group$2(concat$6(["(", indent$3(concat$6([line$4, concat$6(printedArguments)])), maybeTrailingComma, line$4, ")"]), {
+ shouldBreak: true
+ });
+ }
+
+ if (path.getParentNode().type !== "Decorator" && isFunctionCompositionArgs$1(args)) {
+ return allArgsBrokenOut();
+ }
+
+ const shouldGroupFirst = shouldGroupFirstArg(args);
+ const shouldGroupLast = shouldGroupLastArg(args);
+
+ if (shouldGroupFirst || shouldGroupLast) {
+ const shouldBreak = (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$1) : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine || shouldBreakForArrowFunction; // We want to print the last argument with a special flag
+
+ let printedExpanded;
+ let i = 0;
+ path.each(argPath => {
+ if (shouldGroupFirst && i === 0) {
+ printedExpanded = [concat$6([argPath.call(p => print(p, {
+ expandFirstArg: true
+ })), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$4 : line$4, hasEmptyLineFollowingFirstArg ? hardline$4 : ""])].concat(printedArguments.slice(1));
+ }
+
+ if (shouldGroupLast && i === args.length - 1) {
+ printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(p => print(p, {
+ expandLastArg: true
+ })));
+ }
+
+ i++;
+ }, "arguments");
+ const somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
+ const simpleConcat = concat$6(["(", concat$6(printedExpanded), ")"]);
+ return concat$6([somePrintedArgumentsWillBreak ? breakParent$2 : "", conditionalGroup$1([!somePrintedArgumentsWillBreak && !node.typeArguments && !node.typeParameters ? simpleConcat : ifBreak$1(allArgsBrokenOut(), simpleConcat), shouldGroupFirst ? concat$6(["(", group$2(printedExpanded[0], {
+ shouldBreak: true
+ }), concat$6(printedExpanded.slice(1)), ")"]) : concat$6(["(", concat$6(printedArguments.slice(0, -1)), group$2(getLast$2(printedExpanded), {
+ shouldBreak: true
+ }), ")"]), allArgsBrokenOut()], {
+ shouldBreak
+ })]);
+ }
+
+ const contents = concat$6(["(", indent$3(concat$6([softline$2, concat$6(printedArguments)])), ifBreak$1(maybeTrailingComma), softline$2, ")"]);
+
+ if (isLongCurriedCallExpression$1(path)) {
+ // By not wrapping the arguments in a group, the printer prioritizes
+ // breaking up these arguments rather than the args of the parent call.
+ return contents;
+ }
+
+ return group$2(contents, {
+ shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
+ });
+}
+
+function printTypeAnnotation(path, options, print) {
+ const node = path.getValue();
+
+ if (!node.typeAnnotation) {
+ return "";
+ }
+
+ const parentNode = path.getParentNode();
+ const isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
+ const isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
+
+ if (isFlowAnnotationComment$1(options.originalText, node.typeAnnotation, options)) {
+ return concat$6([" /*: ", path.call(print, "typeAnnotation"), " */"]);
+ }
+
+ return concat$6([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path.call(print, "typeAnnotation")]);
+}
+
+function printFunctionTypeParameters(path, options, print) {
+ const fun = path.getValue();
+
+ if (fun.typeArguments) {
+ return path.call(print, "typeArguments");
+ }
+
+ if (fun.typeParameters) {
+ return path.call(print, "typeParameters");
+ }
+
+ return "";
+}
+
+function printFunctionParams(path, print, options, expandArg, printTypeParams) {
+ const fun = path.getValue();
+ const parent = path.getParentNode();
+ const paramsField = fun.parameters ? "parameters" : "params";
+ const isParametersInTestCall = isTestCall$1(parent);
+ const shouldHugParameters = shouldHugArguments(fun);
+ const shouldExpandParameters = expandArg && !(fun[paramsField] && fun[paramsField].some(n => n.comments));
+ const typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : "";
+ let printed = [];
+
+ if (fun[paramsField]) {
+ const lastArgIndex = fun[paramsField].length - 1;
+ printed = path.map((childPath, index) => {
+ const parts = [];
+ const param = childPath.getValue();
+ parts.push(print(childPath));
+
+ if (index === lastArgIndex) {
+ if (fun.rest) {
+ parts.push(",", line$4);
+ }
+ } else if (isParametersInTestCall || shouldHugParameters || shouldExpandParameters) {
+ parts.push(", ");
+ } else if (isNextLineEmpty$2(options.originalText, param, options.locEnd)) {
+ parts.push(",", hardline$4, hardline$4);
+ } else {
+ parts.push(",", line$4);
+ }
+
+ return concat$6(parts);
+ }, paramsField);
+ }
+
+ if (fun.rest) {
+ printed.push(concat$6(["...", path.call(print, "rest")]));
+ }
+
+ if (printed.length === 0) {
+ return concat$6([typeParams, "(", comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true, comment => getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")"), ")"]);
+ }
+
+ const lastParam = getLast$2(fun[paramsField]); // If the parent is a call with the first/last argument expansion and this is the
+ // params of the first/last argument, we don't want the arguments to break and instead
+ // want the whole expression to be on a new line.
+ //
+ // Good: Bad:
+ // verylongcall( verylongcall((
+ // (a, b) => { a,
+ // } b,
+ // }) ) => {
+ // })
+
+ if (shouldExpandParameters) {
+ return group$2(concat$6([removeLines$1(typeParams), "(", concat$6(printed.map(removeLines$1)), ")"]));
+ } // Single object destructuring should hug
+ //
+ // function({
+ // a,
+ // b,
+ // c
+ // }) {}
+
+
+ const hasNotParameterDecorator = fun[paramsField].every(param => !param.decorators);
+
+ if (shouldHugParameters && hasNotParameterDecorator) {
+ return concat$6([typeParams, "(", concat$6(printed), ")"]);
+ } // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
+
+
+ if (isParametersInTestCall) {
+ return concat$6([typeParams, "(", concat$6(printed), ")"]);
+ }
+
+ const isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction$1(parent, options) || isTypeAnnotationAFunction$1(parent, options) || parent.type === "TypeAlias" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || parent.type === "IntersectionTypeAnnotation" || parent.type === "FunctionTypeAnnotation" && parent.returnType === fun) && fun[paramsField].length === 1 && fun[paramsField][0].name === null && fun[paramsField][0].typeAnnotation && fun.typeParameters === null && isSimpleFlowType$1(fun[paramsField][0].typeAnnotation) && !fun.rest;
+
+ if (isFlowShorthandWithOneArg) {
+ if (options.arrowParens === "always") {
+ return concat$6(["(", concat$6(printed), ")"]);
+ }
+
+ return concat$6(printed);
+ }
+
+ const canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
+ return concat$6([typeParams, "(", indent$3(concat$6([softline$2, concat$6(printed)])), ifBreak$1(canHaveTrailingComma && shouldPrintComma(options, "all") ? "," : ""), softline$2, ")"]);
+}
+
+function shouldPrintParamsWithoutParens(path, options) {
+ if (options.arrowParens === "always") {
+ return false;
+ }
+
+ if (options.arrowParens === "avoid") {
+ const node = path.getValue();
+ return canPrintParamsWithoutParens(node);
+ } // Fallback default; should be unreachable
+
+
+ return false;
+}
+
+function canPrintParamsWithoutParens(node) {
+ return node.params.length === 1 && !node.rest && !node.typeParameters && !hasDanglingComments$1(node) && node.params[0].type === "Identifier" && !node.params[0].typeAnnotation && !node.params[0].comments && !node.params[0].optional && !node.predicate && !node.returnType;
+}
+
+function printFunctionDeclaration(path, print, options) {
+ const n = path.getValue();
+ const parts = [];
+
+ if (n.async) {
+ parts.push("async ");
+ }
+
+ if (n.generator) {
+ parts.push("function* ");
+ } else {
+ parts.push("function ");
+ }
+
+ if (n.id) {
+ parts.push(path.call(print, "id"));
+ }
+
+ parts.push(printFunctionTypeParameters(path, options, print), group$2(concat$6([printFunctionParams(path, print, options), printReturnType(path, print, options)])), n.body ? " " : "", path.call(print, "body"));
+ return concat$6(parts);
+}
+
+function printReturnType(path, print, options) {
+ const n = path.getValue();
+ const returnType = path.call(print, "returnType");
+
+ if (n.returnType && isFlowAnnotationComment$1(options.originalText, n.returnType, options)) {
+ return concat$6([" /*: ", returnType, " */"]);
+ }
+
+ const parts = [returnType]; // prepend colon to TypeScript type annotation
+
+ if (n.returnType && n.returnType.typeAnnotation) {
+ parts.unshift(": ");
+ }
+
+ if (n.predicate) {
+ // The return type will already add the colon, but otherwise we
+ // need to do it ourselves
+ parts.push(n.returnType ? " " : ": ", path.call(print, "predicate"));
+ }
+
+ return concat$6(parts);
+}
+
+function printExportDeclaration(path, options, print) {
+ const decl = path.getValue();
+ const semi = options.semi ? ";" : "";
+ const parts = ["export "];
+ const isDefault = decl.default || decl.type === "ExportDefaultDeclaration";
+
+ if (isDefault) {
+ parts.push("default ");
+ }
+
+ parts.push(comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true));
+
+ if (needsHardlineAfterDanglingComment$1(decl)) {
+ parts.push(hardline$4);
+ }
+
+ if (decl.declaration) {
+ parts.push(path.call(print, "declaration"));
+
+ if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction" && decl.declaration.type !== "TSDeclareFunction") {
+ parts.push(semi);
+ }
+ } else {
+ if (decl.specifiers && decl.specifiers.length > 0) {
+ const specifiers = [];
+ const defaultSpecifiers = [];
+ const namespaceSpecifiers = [];
+ path.each(specifierPath => {
+ const specifierType = path.getValue().type;
+
+ if (specifierType === "ExportSpecifier") {
+ specifiers.push(print(specifierPath));
+ } else if (specifierType === "ExportDefaultSpecifier") {
+ defaultSpecifiers.push(print(specifierPath));
+ } else if (specifierType === "ExportNamespaceSpecifier") {
+ namespaceSpecifiers.push(concat$6(["* as ", print(specifierPath)]));
+ }
+ }, "specifiers");
+ const isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0;
+ const isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0);
+ const canBreak = specifiers.length > 1 || defaultSpecifiers.length > 0 || decl.specifiers && decl.specifiers.some(node => node.comments);
+ let printed = "";
+
+ if (specifiers.length !== 0) {
+ if (canBreak) {
+ printed = group$2(concat$6(["{", indent$3(concat$6([options.bracketSpacing ? line$4 : softline$2, join$4(concat$6([",", line$4]), specifiers)])), ifBreak$1(shouldPrintComma(options) ? "," : ""), options.bracketSpacing ? line$4 : softline$2, "}"]));
+ } else {
+ printed = concat$6(["{", options.bracketSpacing ? " " : "", concat$6(specifiers), options.bracketSpacing ? " " : "", "}"]);
+ }
+ }
+
+ parts.push(decl.exportKind === "type" ? "type " : "", concat$6(defaultSpecifiers), concat$6([isDefaultFollowed ? ", " : ""]), concat$6(namespaceSpecifiers), concat$6([isNamespaceFollowed ? ", " : ""]), printed);
+ } else {
+ parts.push("{}");
+ }
+
+ if (decl.source) {
+ parts.push(" from ", path.call(print, "source"));
+ }
+
+ parts.push(semi);
+ }
+
+ return concat$6(parts);
+}
+
+function printFlowDeclaration(path, parts) {
+ const parentExportDecl = getParentExportDeclaration$1(path);
+
+ if (parentExportDecl) {
+ assert.strictEqual(parentExportDecl.type, "DeclareExportDeclaration");
+ } else {
+ // If the parent node has type DeclareExportDeclaration, then it
+ // will be responsible for printing the "declare" token. Otherwise
+ // it needs to be printed with this non-exported declaration node.
+ parts.unshift("declare ");
+ }
+
+ return concat$6(parts);
+}
+
+function printTypeScriptModifiers(path, options, print) {
+ const n = path.getValue();
+
+ if (!n.modifiers || !n.modifiers.length) {
+ return "";
+ }
+
+ return concat$6([join$4(" ", path.map(print, "modifiers")), " "]);
+}
+
+function printTypeParameters(path, options, print, paramsKey) {
+ const n = path.getValue();
+
+ if (!n[paramsKey]) {
+ return "";
+ } // for TypeParameterDeclaration typeParameters is a single node
+
+
+ if (!Array.isArray(n[paramsKey])) {
+ return path.call(print, paramsKey);
+ }
+
+ const grandparent = path.getNode(2);
+ const greatGrandParent = path.getNode(3);
+ const greatGreatGrandParent = path.getNode(4);
+ const isParameterInTestCall = grandparent != null && isTestCall$1(grandparent);
+ const shouldInline = isParameterInTestCall || n[paramsKey].length === 0 || n[paramsKey].length === 1 && (shouldHugType(n[paramsKey][0]) || n[paramsKey][0].type === "GenericTypeAnnotation" && shouldHugType(n[paramsKey][0].id) || n[paramsKey][0].type === "TSTypeReference" && shouldHugType(n[paramsKey][0].typeName) || n[paramsKey][0].type === "NullableTypeAnnotation" || // See https://github.com/prettier/prettier/pull/6467 for the context.
+ greatGreatGrandParent && greatGreatGrandParent.type === "VariableDeclarator" && grandparent.type === "TSTypeAnnotation" && greatGrandParent.type !== "ArrowFunctionExpression" && n[paramsKey][0].type !== "TSUnionType" && n[paramsKey][0].type !== "UnionTypeAnnotation" && n[paramsKey][0].type !== "TSIntersectionType" && n[paramsKey][0].type !== "IntersectionTypeAnnotation" && n[paramsKey][0].type !== "TSConditionalType" && n[paramsKey][0].type !== "TSMappedType" && n[paramsKey][0].type !== "TSTypeOperator" && n[paramsKey][0].type !== "TSIndexedAccessType" && n[paramsKey][0].type !== "TSArrayType");
+
+ function printDanglingCommentsForInline(n) {
+ if (!hasDanglingComments$1(n)) {
+ return "";
+ }
+
+ const hasOnlyBlockComments = n.comments.every(comments$1.isBlockComment);
+ const printed = comments.printDanglingComments(path, options,
+ /* sameIndent */
+ hasOnlyBlockComments);
+
+ if (hasOnlyBlockComments) {
+ return printed;
+ }
+
+ return concat$6([printed, hardline$4]);
+ }
+
+ if (shouldInline) {
+ return concat$6(["<", join$4(", ", path.map(print, paramsKey)), printDanglingCommentsForInline(n), ">"]);
+ }
+
+ return group$2(concat$6(["<", indent$3(concat$6([softline$2, join$4(concat$6([",", line$4]), path.map(print, paramsKey))])), ifBreak$1(options.parser !== "typescript" && options.parser !== "babel-ts" && shouldPrintComma(options, "all") ? "," : ""), softline$2, ">"]));
+}
+
+function printClass(path, options, print) {
+ const n = path.getValue();
+ const parts = [];
+
+ if (n.abstract) {
+ parts.push("abstract ");
+ }
+
+ parts.push("class");
+
+ if (n.id) {
+ parts.push(" ", path.call(print, "id"));
+ }
+
+ parts.push(path.call(print, "typeParameters"));
+ const partsGroup = [];
+
+ if (n.superClass) {
+ const printed = concat$6(["extends ", path.call(print, "superClass"), path.call(print, "superTypeParameters")]); // Keep old behaviour of extends in same line
+ // If there is only on extends and there are not comments
+
+ if ((!n.implements || n.implements.length === 0) && (!n.superClass.comments || n.superClass.comments.length === 0)) {
+ parts.push(concat$6([" ", path.call(superClass => comments.printComments(superClass, () => printed, options), "superClass")]));
+ } else {
+ partsGroup.push(group$2(concat$6([line$4, path.call(superClass => comments.printComments(superClass, () => printed, options), "superClass")])));
+ }
+ } else if (n.extends && n.extends.length > 0) {
+ parts.push(" extends ", join$4(", ", path.map(print, "extends")));
+ }
+
+ if (n.mixins && n.mixins.length > 0) {
+ partsGroup.push(line$4, "mixins ", group$2(indent$3(join$4(concat$6([",", line$4]), path.map(print, "mixins")))));
+ }
+
+ if (n.implements && n.implements.length > 0) {
+ partsGroup.push(line$4, "implements", group$2(indent$3(concat$6([line$4, join$4(concat$6([",", line$4]), path.map(print, "implements"))]))));
+ }
+
+ if (partsGroup.length > 0) {
+ parts.push(group$2(indent$3(concat$6(partsGroup))));
+ }
+
+ if (n.body && n.body.comments && hasLeadingOwnLineComment$1(options.originalText, n.body, options)) {
+ parts.push(hardline$4);
+ } else {
+ parts.push(" ");
+ }
+
+ parts.push(path.call(print, "body"));
+ return parts;
+}
+
+function printOptionalToken(path) {
+ const node = path.getValue();
+
+ if (!node.optional || // It's an optional computed method parsed by typescript-estree.
+ // "?" is printed in `printMethod`.
+ node.type === "Identifier" && node === path.getParentNode().key) {
+ return "";
+ }
+
+ if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
+ return "?.";
+ }
+
+ return "?";
+}
+
+function printMemberLookup(path, options, print) {
+ const property = path.call(print, "property");
+ const n = path.getValue();
+ const optional = printOptionalToken(path);
+
+ if (!n.computed) {
+ return concat$6([optional, ".", property]);
+ }
+
+ if (!n.property || isNumericLiteral$1(n.property)) {
+ return concat$6([optional, "[", property, "]"]);
+ }
+
+ return group$2(concat$6([optional, "[", indent$3(concat$6([softline$2, property])), softline$2, "]"]));
+}
+
+function printBindExpressionCallee(path, options, print) {
+ return concat$6(["::", path.call(print, "callee")]);
+} // We detect calls on member expressions specially to format a
+// common pattern better. The pattern we are looking for is this:
+//
+// arr
+// .map(x => x + 1)
+// .filter(x => x > 10)
+// .some(x => x % 2)
+//
+// The way it is structured in the AST is via a nested sequence of
+// MemberExpression and CallExpression. We need to traverse the AST
+// and make groups out of it to print it in the desired way.
+
+
+function printMemberChain(path, options, print) {
+ // The first phase is to linearize the AST by traversing it down.
+ //
+ // a().b()
+ // has the following AST structure:
+ // CallExpression(MemberExpression(CallExpression(Identifier)))
+ // and we transform it into
+ // [Identifier, CallExpression, MemberExpression, CallExpression]
+ const printedNodes = []; // Here we try to retain one typed empty line after each call expression or
+ // the first group whether it is in parentheses or not
+
+ function shouldInsertEmptyLineAfter(node) {
+ const {
+ originalText
+ } = options;
+ const nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$3(originalText, node, options.locEnd);
+ const nextChar = originalText.charAt(nextCharIndex); // if it is cut off by a parenthesis, we only account for one typed empty
+ // line after that parenthesis
+
+ if (nextChar === ")") {
+ return isNextLineEmptyAfterIndex$2(originalText, nextCharIndex + 1, options.locEnd);
+ }
+
+ return isNextLineEmpty$2(originalText, node, options.locEnd);
+ }
+
+ function rec(path) {
+ const node = path.getValue();
+
+ if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish$1(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) {
+ printedNodes.unshift({
+ node,
+ printed: concat$6([comments.printComments(path, () => concat$6([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]), options), shouldInsertEmptyLineAfter(node) ? hardline$4 : ""])
+ });
+ path.call(callee => rec(callee), "callee");
+ } else if (isMemberish$1(node)) {
+ printedNodes.unshift({
+ node,
+ needsParens: needsParens_1(path, options),
+ printed: comments.printComments(path, () => node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path, options, print) : printBindExpressionCallee(path, options, print), options)
+ });
+ path.call(object => rec(object), "object");
+ } else if (node.type === "TSNonNullExpression") {
+ printedNodes.unshift({
+ node,
+ printed: comments.printComments(path, () => "!", options)
+ });
+ path.call(expression => rec(expression), "expression");
+ } else {
+ printedNodes.unshift({
+ node,
+ printed: path.call(print)
+ });
+ }
+ } // Note: the comments of the root node have already been printed, so we
+ // need to extract this first call without printing them as they would
+ // if handled inside of the recursive call.
+
+
+ const node = path.getValue();
+ printedNodes.unshift({
+ node,
+ printed: concat$6([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)])
+ });
+ path.call(callee => rec(callee), "callee"); // Once we have a linear list of printed nodes, we want to create groups out
+ // of it.
+ //
+ // a().b.c().d().e
+ // will be grouped as
+ // [
+ // [Identifier, CallExpression],
+ // [MemberExpression, MemberExpression, CallExpression],
+ // [MemberExpression, CallExpression],
+ // [MemberExpression],
+ // ]
+ // so that we can print it as
+ // a()
+ // .b.c()
+ // .d()
+ // .e
+ // The first group is the first node followed by
+ // - as many CallExpression as possible
+ // < fn()()() >.something()
+ // - as many array accessors as possible
+ // < fn()[0][1][2] >.something()
+ // - then, as many MemberExpression as possible but the last one
+ // < this.items >.something()
+
+ const groups = [];
+ let currentGroup = [printedNodes[0]];
+ let i = 1;
+
+ for (; i < printedNodes.length; ++i) {
+ if (printedNodes[i].node.type === "TSNonNullExpression" || printedNodes[i].node.type === "OptionalCallExpression" || printedNodes[i].node.type === "CallExpression" || (printedNodes[i].node.type === "MemberExpression" || printedNodes[i].node.type === "OptionalMemberExpression") && printedNodes[i].node.computed && isNumericLiteral$1(printedNodes[i].node.property)) {
+ currentGroup.push(printedNodes[i]);
+ } else {
+ break;
+ }
+ }
+
+ if (printedNodes[0].node.type !== "CallExpression" && printedNodes[0].node.type !== "OptionalCallExpression") {
+ for (; i + 1 < printedNodes.length; ++i) {
+ if (isMemberish$1(printedNodes[i].node) && isMemberish$1(printedNodes[i + 1].node)) {
+ currentGroup.push(printedNodes[i]);
+ } else {
+ break;
+ }
+ }
+ }
+
+ groups.push(currentGroup);
+ currentGroup = []; // Then, each following group is a sequence of MemberExpression followed by
+ // a sequence of CallExpression. To compute it, we keep adding things to the
+ // group until we has seen a CallExpression in the past and reach a
+ // MemberExpression
+
+ let hasSeenCallExpression = false;
+
+ for (; i < printedNodes.length; ++i) {
+ if (hasSeenCallExpression && isMemberish$1(printedNodes[i].node)) {
+ // [0] should be appended at the end of the group instead of the
+ // beginning of the next one
+ if (printedNodes[i].node.computed && isNumericLiteral$1(printedNodes[i].node.property)) {
+ currentGroup.push(printedNodes[i]);
+ continue;
+ }
+
+ groups.push(currentGroup);
+ currentGroup = [];
+ hasSeenCallExpression = false;
+ }
+
+ if (printedNodes[i].node.type === "CallExpression" || printedNodes[i].node.type === "OptionalCallExpression") {
+ hasSeenCallExpression = true;
+ }
+
+ currentGroup.push(printedNodes[i]);
+
+ if (printedNodes[i].node.comments && printedNodes[i].node.comments.some(comment => comment.trailing)) {
+ groups.push(currentGroup);
+ currentGroup = [];
+ hasSeenCallExpression = false;
+ }
+ }
+
+ if (currentGroup.length > 0) {
+ groups.push(currentGroup);
+ } // There are cases like Object.keys(), Observable.of(), _.values() where
+ // they are the subject of all the chained calls and therefore should
+ // be kept on the same line:
+ //
+ // Object.keys(items)
+ // .filter(x => x)
+ // .map(x => x)
+ //
+ // In order to detect those cases, we use an heuristic: if the first
+ // node is an identifier with the name starting with a capital
+ // letter or just a sequence of _$. The rationale is that they are
+ // likely to be factories.
+
+
+ function isFactory(name) {
+ return /^[A-Z]|^[_$]+$/.test(name);
+ } // In case the Identifier is shorter than tab width, we can keep the
+ // first call in a single line, if it's an ExpressionStatement.
+ //
+ // d3.scaleLinear()
+ // .domain([0, 100])
+ // .range([0, width]);
+ //
+
+
+ function isShort(name) {
+ return name.length <= options.tabWidth;
+ }
+
+ function shouldNotWrap(groups) {
+ const parent = path.getParentNode();
+ const isExpression = parent && parent.type === "ExpressionStatement";
+ const hasComputed = groups[1].length && groups[1][0].node.computed;
+
+ if (groups[0].length === 1) {
+ const firstNode = groups[0][0].node;
+ return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
+ }
+
+ const lastNode = getLast$2(groups[0]).node;
+ return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
+ }
+
+ const shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
+
+ function printGroup(printedGroup) {
+ const printed = printedGroup.map(tuple => tuple.printed); // Checks if the last node (i.e. the parent node) needs parens and print
+ // accordingly
+
+ if (printedGroup.length > 0 && printedGroup[printedGroup.length - 1].needsParens) {
+ return concat$6(["(", ...printed, ")"]);
+ }
+
+ return concat$6(printed);
+ }
+
+ function printIndentedGroup(groups) {
+ if (groups.length === 0) {
+ return "";
+ }
+
+ return indent$3(group$2(concat$6([hardline$4, join$4(hardline$4, groups.map(printGroup))])));
+ }
+
+ const printedGroups = groups.map(printGroup);
+ const oneLine = concat$6(printedGroups);
+ const cutoff = shouldMerge ? 3 : 2;
+ const flatGroups = groups.reduce((res, group) => res.concat(group), []);
+ const hasComment = flatGroups.slice(1, -1).some(node => hasLeadingComment$3(node.node)) || flatGroups.slice(0, -1).some(node => hasTrailingComment$1(node.node)) || groups[cutoff] && hasLeadingComment$3(groups[cutoff][0].node); // If we only have a single `.`, we shouldn't do anything fancy and just
+ // render everything concatenated together.
+
+ if (groups.length <= cutoff && !hasComment) {
+ if (isLongCurriedCallExpression$1(path)) {
+ return oneLine;
+ }
+
+ return group$2(oneLine);
+ } // Find out the last node in the first group and check if it has an
+ // empty line after
+
+
+ const lastNodeBeforeIndent = getLast$2(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
+ const shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
+ const expanded = concat$6([printGroup(groups[0]), shouldMerge ? concat$6(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$4 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
+ const callExpressions = printedNodes.map(({
+ node
+ }) => node).filter(isCallOrOptionalCallExpression$1); // We don't want to print in one line if the chain has:
+ // * A comment.
+ // * Non-trivial arguments.
+ // * Any group but the last one has a hard line.
+ // If the last group is a function it's okay to inline if it fits.
+
+ if (hasComment || callExpressions.length > 2 && callExpressions.some(expr => !expr.arguments.every(arg => isSimpleCallArgument$1(arg, 0))) || printedGroups.slice(0, -1).some(willBreak$1) ||
+ /**
+ * scopes.filter(scope => scope.value !== '').map((scope, i) => {
+ * // multi line content
+ * })
+ */
+ ((lastGroupDoc, lastGroupNode) => isCallOrOptionalCallExpression$1(lastGroupNode) && willBreak$1(lastGroupDoc))(getLast$2(printedGroups), getLast$2(getLast$2(groups)).node) && callExpressions.slice(0, -1).some(n => n.arguments.some(isFunctionOrArrowExpression$1))) {
+ return group$2(expanded);
+ }
+
+ return concat$6([// We only need to check `oneLine` because if `expanded` is chosen
+ // that means that the parent group has already been broken
+ // naturally
+ willBreak$1(oneLine) || shouldHaveEmptyLineBeforeIndent ? breakParent$2 : "", conditionalGroup$1([oneLine, expanded])]);
+}
+
+function separatorNoWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
+ if (isFacebookTranslationTag) {
+ return "";
+ }
+
+ if (childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement) {
+ return child.length === 1 ? softline$2 : hardline$4;
+ }
+
+ return softline$2;
+}
+
+function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
+ if (isFacebookTranslationTag) {
+ return hardline$4;
+ }
+
+ if (child.length === 1) {
+ return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$4 : softline$2;
+ }
+
+ return hardline$4;
+} // JSX Children are strange, mostly for two reasons:
+// 1. JSX reads newlines into string values, instead of skipping them like JS
+// 2. up to one whitespace between elements within a line is significant,
+// but not between lines.
+//
+// Leading, trailing, and lone whitespace all need to
+// turn themselves into the rather ugly `{' '}` when breaking.
+//
+// We print JSX using the `fill` doc primitive.
+// This requires that we give it an array of alternating
+// content and whitespace elements.
+// To ensure this we add dummy `""` content elements as needed.
+
+
+function printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag) {
+ const n = path.getValue();
+ const children = []; // using `map` instead of `each` because it provides `i`
+
+ path.map((childPath, i) => {
+ const child = childPath.getValue();
+
+ if (isLiteral$1(child)) {
+ const text = rawText$1(child); // Contains a non-whitespace character
+
+ if (isMeaningfulJSXText$1(child)) {
+ const words = text.split(matchJsxWhitespaceRegex$1); // Starts with whitespace
+
+ if (words[0] === "") {
+ children.push("");
+ words.shift();
+
+ if (/\n/.test(words[0])) {
+ const next = n.children[i + 1];
+ children.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
+ } else {
+ children.push(jsxWhitespace);
+ }
+
+ words.shift();
+ }
+
+ let endWhitespace; // Ends with whitespace
+
+ if (getLast$2(words) === "") {
+ words.pop();
+ endWhitespace = words.pop();
+ } // This was whitespace only without a new line.
+
+
+ if (words.length === 0) {
+ return;
+ }
+
+ words.forEach((word, i) => {
+ if (i % 2 === 1) {
+ children.push(line$4);
+ } else {
+ children.push(word);
+ }
+ });
+
+ if (endWhitespace !== undefined) {
+ if (/\n/.test(endWhitespace)) {
+ const next = n.children[i + 1];
+ children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$2(children), child, next));
+ } else {
+ children.push(jsxWhitespace);
+ }
+ } else {
+ const next = n.children[i + 1];
+ children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$2(children), child, next));
+ }
+ } else if (/\n/.test(text)) {
+ // Keep (up to one) blank line between tags/expressions/text.
+ // Note: We don't keep blank lines between text elements.
+ if (text.match(/\n/g).length > 1) {
+ children.push("");
+ children.push(hardline$4);
+ }
+ } else {
+ children.push("");
+ children.push(jsxWhitespace);
+ }
+ } else {
+ const printedChild = print(childPath);
+ children.push(printedChild);
+ const next = n.children[i + 1];
+ const directlyFollowedByMeaningfulText = next && isMeaningfulJSXText$1(next);
+
+ if (directlyFollowedByMeaningfulText) {
+ const firstWord = rawText$1(next).trim().split(matchJsxWhitespaceRegex$1)[0];
+ children.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, next));
+ } else {
+ children.push(hardline$4);
+ }
+ }
+ }, "children");
+ return children;
+} // JSX expands children from the inside-out, instead of the outside-in.
+// This is both to break children before attributes,
+// and to ensure that when children break, their parents do as well.
+//
+// Any element that is written without any newlines and fits on a single line
+// is left that way.
+// Not only that, any user-written-line containing multiple JSX siblings
+// should also be kept on one line if possible,
+// so each user-written-line is wrapped in its own group.
+//
+// Elements that contain newlines or don't fit on a single line (recursively)
+// are fully-split, using hardline and shouldBreak: true.
+//
+// To support that case properly, all leading and trailing spaces
+// are stripped from the list of children, and replaced with a single hardline.
+
+
+function printJSXElement(path, options, print) {
+ const n = path.getValue();
+
+ if (n.type === "JSXElement" && isEmptyJSXElement$1(n)) {
+ return concat$6([path.call(print, "openingElement"), path.call(print, "closingElement")]);
+ }
+
+ const openingLines = n.type === "JSXElement" ? path.call(print, "openingElement") : path.call(print, "openingFragment");
+ const closingLines = n.type === "JSXElement" ? path.call(print, "closingElement") : path.call(print, "closingFragment");
+
+ if (n.children.length === 1 && n.children[0].type === "JSXExpressionContainer" && (n.children[0].expression.type === "TemplateLiteral" || n.children[0].expression.type === "TaggedTemplateExpression")) {
+ return concat$6([openingLines, concat$6(path.map(print, "children")), closingLines]);
+ } // Convert `{" "}` to text nodes containing a space.
+ // This makes it easy to turn them into `jsxWhitespace` which
+ // can then print as either a space or `{" "}` when breaking.
+
+
+ n.children = n.children.map(child => {
+ if (isJSXWhitespaceExpression$1(child)) {
+ return {
+ type: "JSXText",
+ value: " ",
+ raw: " "
+ };
+ }
+
+ return child;
+ });
+ const containsTag = n.children.filter(isJSXNode$1).length > 0;
+ const containsMultipleExpressions = n.children.filter(child => child.type === "JSXExpressionContainer").length > 1;
+ const containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
+
+ let forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
+ const isMdxBlock = path.getParentNode().rootMarker === "mdx";
+ const rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
+ const jsxWhitespace = isMdxBlock ? concat$6([" "]) : ifBreak$1(concat$6([rawJsxWhitespace, softline$2]), " ");
+ const isFacebookTranslationTag = n.openingElement && n.openingElement.name && n.openingElement.name.name === "fbt";
+ const children = printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag);
+ const containsText = n.children.some(child => isMeaningfulJSXText$1(child)); // We can end up we multiple whitespace elements with empty string
+ // content between them.
+ // We need to remove empty whitespace and softlines before JSX whitespace
+ // to get the correct output.
+
+ for (let i = children.length - 2; i >= 0; i--) {
+ const isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
+ const isPairOfHardlines = children[i] === hardline$4 && children[i + 1] === "" && children[i + 2] === hardline$4;
+ const isLineFollowedByJSXWhitespace = (children[i] === softline$2 || children[i] === hardline$4) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
+ const isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$2 || children[i + 2] === hardline$4);
+ const isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
+ const isPairOfHardOrSoftLines = children[i] === softline$2 && children[i + 1] === "" && children[i + 2] === hardline$4 || children[i] === hardline$4 && children[i + 1] === "" && children[i + 2] === softline$2;
+
+ if (isPairOfHardlines && containsText || isPairOfEmptyStrings || isLineFollowedByJSXWhitespace || isDoubleJSXWhitespace || isPairOfHardOrSoftLines) {
+ children.splice(i, 2);
+ } else if (isJSXWhitespaceFollowedByLine) {
+ children.splice(i + 1, 2);
+ }
+ } // Trim trailing lines (or empty strings)
+
+
+ while (children.length && (isLineNext$1(getLast$2(children)) || isEmpty$1(getLast$2(children)))) {
+ children.pop();
+ } // Trim leading lines (or empty strings)
+
+
+ while (children.length && (isLineNext$1(children[0]) || isEmpty$1(children[0])) && (isLineNext$1(children[1]) || isEmpty$1(children[1]))) {
+ children.shift();
+ children.shift();
+ } // Tweak how we format children if outputting this element over multiple lines.
+ // Also detect whether we will force this element to output over multiple lines.
+
+
+ const multilineChildren = [];
+ children.forEach((child, i) => {
+ // There are a number of situations where we need to ensure we display
+ // whitespace as `{" "}` when outputting this element over multiple lines.
+ if (child === jsxWhitespace) {
+ if (i === 1 && children[i - 1] === "") {
+ if (children.length === 2) {
+ // Solitary whitespace
+ multilineChildren.push(rawJsxWhitespace);
+ return;
+ } // Leading whitespace
+
+
+ multilineChildren.push(concat$6([rawJsxWhitespace, hardline$4]));
+ return;
+ } else if (i === children.length - 1) {
+ // Trailing whitespace
+ multilineChildren.push(rawJsxWhitespace);
+ return;
+ } else if (children[i - 1] === "" && children[i - 2] === hardline$4) {
+ // Whitespace after line break
+ multilineChildren.push(rawJsxWhitespace);
+ return;
+ }
+ }
+
+ multilineChildren.push(child);
+
+ if (willBreak$1(child)) {
+ forcedBreak = true;
+ }
+ }); // If there is text we use `fill` to fit as much onto each line as possible.
+ // When there is no text (just tags and expressions) we use `group`
+ // to output each on a separate line.
+
+ const content = containsText ? fill$3(multilineChildren) : group$2(concat$6(multilineChildren), {
+ shouldBreak: true
+ });
+
+ if (isMdxBlock) {
+ return content;
+ }
+
+ const multiLineElem = group$2(concat$6([openingLines, indent$3(concat$6([hardline$4, content])), hardline$4, closingLines]));
+
+ if (forcedBreak) {
+ return multiLineElem;
+ }
+
+ return conditionalGroup$1([group$2(concat$6([openingLines, concat$6(children), closingLines])), multiLineElem]);
+}
+
+function maybeWrapJSXElementInParens(path, elem, options) {
+ const parent = path.getParentNode();
+
+ if (!parent) {
+ return elem;
+ }
+
+ const NO_WRAP_PARENTS = {
+ ArrayExpression: true,
+ JSXAttribute: true,
+ JSXElement: true,
+ JSXExpressionContainer: true,
+ JSXFragment: true,
+ ExpressionStatement: true,
+ CallExpression: true,
+ OptionalCallExpression: true,
+ ConditionalExpression: true,
+ JsExpressionRoot: true
+ };
+
+ if (NO_WRAP_PARENTS[parent.type]) {
+ return elem;
+ }
+
+ const shouldBreak = path.match(undefined, node => node.type === "ArrowFunctionExpression", isCallOrOptionalCallExpression$1, node => node.type === "JSXExpressionContainer");
+ const needsParens = needsParens_1(path, options);
+ return group$2(concat$6([needsParens ? "" : ifBreak$1("("), indent$3(concat$6([softline$2, elem])), softline$2, needsParens ? "" : ifBreak$1(")")]), {
+ shouldBreak
+ });
+}
+
+function shouldInlineLogicalExpression(node) {
+ if (node.type !== "LogicalExpression") {
+ return false;
+ }
+
+ if (node.right.type === "ObjectExpression" && node.right.properties.length !== 0) {
+ return true;
+ }
+
+ if (node.right.type === "ArrayExpression" && node.right.elements.length !== 0) {
+ return true;
+ }
+
+ if (isJSXNode$1(node.right)) {
+ return true;
+ }
+
+ return false;
+} // For binary expressions to be consistent, we need to group
+// subsequent operators with the same precedence level under a single
+// group. Otherwise they will be nested such that some of them break
+// onto new lines but not all. Operators with the same precedence
+// level should either all break or not. Because we group them by
+// precedence level and the AST is structured based on precedence
+// level, things are naturally broken up correctly, i.e. `&&` is
+// broken before `+`.
+
+
+function printBinaryishExpressions(path, print, options, isNested, isInsideParenthesis) {
+ let parts = [];
+ const node = path.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same.
+
+ if (isBinaryish$1(node)) {
+ // Put all operators with the same precedence level in the same
+ // group. The reason we only need to do this with the `left`
+ // expression is because given an expression like `1 + 2 - 3`, it
+ // is always parsed like `((1 + 2) - 3)`, meaning the `left` side
+ // is where the rest of the expression will exist. Binary
+ // expressions on the right side mean they have a difference
+ // precedence level and should be treated as a separate group, so
+ // print them normally. (This doesn't hold for the `**` operator,
+ // which is unique in that it is right-associative.)
+ if (shouldFlatten$1(node.operator, node.left.operator)) {
+ // Flatten them out by recursively calling this function.
+ parts = parts.concat(path.call(left => printBinaryishExpressions(left, print, options,
+ /* isNested */
+ true, isInsideParenthesis), "left"));
+ } else {
+ parts.push(path.call(print, "left"));
+ }
+
+ const shouldInline = shouldInlineLogicalExpression(node);
+ const lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment$1(options.originalText, node.right, options);
+ const operator = node.type === "NGPipeExpression" ? "|" : node.operator;
+ const rightSuffix = node.type === "NGPipeExpression" && node.arguments.length !== 0 ? group$2(indent$3(concat$6([softline$2, ": ", join$4(concat$6([softline$2, ":", ifBreak$1(" ")]), path.map(print, "arguments").map(arg => align$1(2, group$2(arg))))]))) : "";
+ const right = shouldInline ? concat$6([operator, " ", path.call(print, "right"), rightSuffix]) : concat$6([lineBeforeOperator ? softline$2 : "", operator, lineBeforeOperator ? " " : line$4, path.call(print, "right"), rightSuffix]); // If there's only a single binary expression, we want to create a group
+ // in order to avoid having a small right part like -1 be on its own line.
+
+ const parent = path.getParentNode();
+ const shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
+ parts.push(" ", shouldGroup ? group$2(right) : right); // The root comments are already printed, but we need to manually print
+ // the other ones since we don't call the normal print on BinaryExpression,
+ // only for the left and right parts
+
+ if (isNested && node.comments) {
+ parts = comments.printComments(path, () => concat$6(parts), options);
+ }
+ } else {
+ // Our stopping case. Simply print the node normally.
+ parts.push(path.call(print));
+ }
+
+ return parts;
+}
+
+function printAssignmentRight(leftNode, rightNode, printedRight, options) {
+ if (hasLeadingOwnLineComment$1(options.originalText, rightNode, options)) {
+ return indent$3(concat$6([line$4, printedRight]));
+ }
+
+ const canBreak = isBinaryish$1(rightNode) && !shouldInlineLogicalExpression(rightNode) || rightNode.type === "ConditionalExpression" && isBinaryish$1(rightNode.test) && !shouldInlineLogicalExpression(rightNode.test) || rightNode.type === "StringLiteralTypeAnnotation" || rightNode.type === "ClassExpression" && rightNode.decorators && rightNode.decorators.length || (leftNode.type === "Identifier" || isStringLiteral$1(leftNode) || leftNode.type === "MemberExpression") && (isStringLiteral$1(rightNode) || isMemberExpressionChain$1(rightNode)) && // do not put values on a separate line from the key in json
+ options.parser !== "json" && options.parser !== "json5" || rightNode.type === "SequenceExpression";
+
+ if (canBreak) {
+ return group$2(indent$3(concat$6([line$4, printedRight])));
+ }
+
+ return concat$6([" ", printedRight]);
+}
+
+function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) {
+ if (!rightNode) {
+ return printedLeft;
+ }
+
+ const printed = printAssignmentRight(leftNode, rightNode, printedRight, options);
+ return group$2(concat$6([printedLeft, operator, printed]));
+}
+
+function adjustClause(node, clause, forceSpace) {
+ if (node.type === "EmptyStatement") {
+ return ";";
+ }
+
+ if (node.type === "BlockStatement" || forceSpace) {
+ return concat$6([" ", clause]);
+ }
+
+ return indent$3(concat$6([line$4, clause]));
+}
+
+function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
+ const raw = rawText$1(node);
+ const isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
+ return printString$1(raw, options, isDirectiveLiteral);
+}
+
+function printRegex(node) {
+ const flags = node.flags.split("").sort().join("");
+ return `/${node.pattern}/${flags}`;
+}
+
+function exprNeedsASIProtection(path, options) {
+ const node = path.getValue();
+ const maybeASIProblem = needsParens_1(path, options) || node.type === "ParenthesizedExpression" || node.type === "TypeCastExpression" || node.type === "ArrowFunctionExpression" && !shouldPrintParamsWithoutParens(path, options) || node.type === "ArrayExpression" || node.type === "ArrayPattern" || node.type === "UnaryExpression" && node.prefix && (node.operator === "+" || node.operator === "-") || node.type === "TemplateLiteral" || node.type === "TemplateElement" || isJSXNode$1(node) || node.type === "BindExpression" && !node.object || node.type === "RegExpLiteral" || node.type === "Literal" && node.pattern || node.type === "Literal" && node.regex;
+
+ if (maybeASIProblem) {
+ return true;
+ }
+
+ if (!hasNakedLeftSide$2(node)) {
+ return false;
+ }
+
+ return path.call(childPath => exprNeedsASIProtection(childPath, options), ...getLeftSidePathName$2(path, node));
+}
+
+function stmtNeedsASIProtection(path, options) {
+ const node = path.getNode();
+
+ if (node.type !== "ExpressionStatement") {
+ return false;
+ }
+
+ return path.call(childPath => exprNeedsASIProtection(childPath, options), "expression");
+}
+
+function shouldHugType(node) {
+ if (isSimpleFlowType$1(node) || isObjectType$1(node)) {
+ return true;
+ }
+
+ if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
+ const voidCount = node.types.filter(n => n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword").length;
+ const hasObject = node.types.some(n => n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
+ n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference");
+
+ if (node.types.length - 1 === voidCount && hasObject) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+function shouldHugArguments(fun) {
+ if (!fun || fun.rest) {
+ return false;
+ }
+
+ const params = fun.params || fun.parameters;
+
+ if (!params || params.length !== 1) {
+ return false;
+ }
+
+ const param = params[0];
+ return !param.comments && (param.type === "ObjectPattern" || param.type === "ArrayPattern" || param.type === "Identifier" && param.typeAnnotation && (param.typeAnnotation.type === "TypeAnnotation" || param.typeAnnotation.type === "TSTypeAnnotation") && isObjectType$1(param.typeAnnotation.typeAnnotation) || param.type === "FunctionTypeParam" && isObjectType$1(param.typeAnnotation) || param.type === "AssignmentPattern" && (param.left.type === "ObjectPattern" || param.left.type === "ArrayPattern") && (param.right.type === "Identifier" || param.right.type === "ObjectExpression" && param.right.properties.length === 0 || param.right.type === "ArrayExpression" && param.right.elements.length === 0));
+}
+
+function printArrayItems(path, options, printPath, print) {
+ const printedElements = [];
+ let separatorParts = [];
+ path.each(childPath => {
+ printedElements.push(concat$6(separatorParts));
+ printedElements.push(group$2(print(childPath)));
+ separatorParts = [",", line$4];
+
+ if (childPath.getValue() && isNextLineEmpty$2(options.originalText, childPath.getValue(), options.locEnd)) {
+ separatorParts.push(softline$2);
+ }
+ }, printPath);
+ return concat$6(printedElements);
+}
+
+function printReturnAndThrowArgument(path, options, print) {
+ const node = path.getValue();
+ const semi = options.semi ? ";" : "";
+ const parts = [];
+
+ if (node.argument) {
+ if (returnArgumentHasLeadingComment$1(options, node.argument)) {
+ parts.push(concat$6([" (", indent$3(concat$6([hardline$4, path.call(print, "argument")])), hardline$4, ")"]));
+ } else if (isBinaryish$1(node.argument) || node.argument.type === "SequenceExpression") {
+ parts.push(group$2(concat$6([ifBreak$1(" (", " "), indent$3(concat$6([softline$2, path.call(print, "argument")])), softline$2, ifBreak$1(")")])));
+ } else {
+ parts.push(" ", path.call(print, "argument"));
+ }
+ }
+
+ const lastComment = Array.isArray(node.comments) && node.comments[node.comments.length - 1];
+ const isLastCommentLine = lastComment && (lastComment.type === "CommentLine" || lastComment.type === "Line");
+
+ if (isLastCommentLine) {
+ parts.push(semi);
+ }
+
+ if (hasDanglingComments$1(node)) {
+ parts.push(" ", comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true));
+ }
+
+ if (!isLastCommentLine) {
+ parts.push(semi);
+ }
+
+ return concat$6(parts);
+}
+
+function willPrintOwnComments(path
+/*, options */
+) {
+ const node = path.getValue();
+ const parent = path.getParentNode();
+ return (node && (isJSXNode$1(node) || hasFlowShorthandAnnotationComment$2(node) || parent && (parent.type === "CallExpression" || parent.type === "OptionalCallExpression") && (hasFlowAnnotationComment$1(node.leadingComments) || hasFlowAnnotationComment$1(node.trailingComments))) || parent && (parent.type === "JSXSpreadAttribute" || parent.type === "JSXSpreadChild" || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType" || (parent.type === "ClassDeclaration" || parent.type === "ClassExpression") && parent.superClass === node)) && (!hasIgnoreComment$2(path) || parent.type === "UnionTypeAnnotation" || parent.type === "TSUnionType");
+}
+
+function canAttachComment(node) {
+ return node.type && node.type !== "CommentBlock" && node.type !== "CommentLine" && node.type !== "Line" && node.type !== "Block" && node.type !== "EmptyStatement" && node.type !== "TemplateElement" && node.type !== "Import";
+}
+
+function printComment$1(commentPath, options) {
+ const comment = commentPath.getValue();
+
+ switch (comment.type) {
+ case "CommentBlock":
+ case "Block":
+ {
+ if (isIndentableBlockComment(comment)) {
+ const printed = printIndentableBlockComment(comment); // We need to prevent an edge case of a previous trailing comment
+ // printed as a `lineSuffix` which causes the comments to be
+ // interleaved. See https://github.com/prettier/prettier/issues/4412
+
+ if (comment.trailing && !hasNewline$4(options.originalText, options.locStart(comment), {
+ backwards: true
+ })) {
+ return concat$6([hardline$4, printed]);
+ }
+
+ return printed;
+ }
+
+ const commentEnd = options.locEnd(comment);
+ const isInsideFlowComment = options.originalText.slice(commentEnd - 3, commentEnd) === "*-/";
+ return "/*" + comment.value + (isInsideFlowComment ? "*-/" : "*/");
+ }
+
+ case "CommentLine":
+ case "Line":
+ // Print shebangs with the proper comment characters
+ if (options.originalText.slice(options.locStart(comment)).startsWith("#!")) {
+ return "#!" + comment.value.trimEnd();
+ }
+
+ return "//" + comment.value.trimEnd();
+
+ default:
+ throw new Error("Not a comment: " + JSON.stringify(comment));
+ }
+}
+
+function isIndentableBlockComment(comment) {
+ // If the comment has multiple lines and every line starts with a star
+ // we can fix the indentation of each line. The stars in the `/*` and
+ // `*/` delimiters are not included in the comment value, so add them
+ // back first.
+ const lines = `*${comment.value}*`.split("\n");
+ return lines.length > 1 && lines.every(line => line.trim()[0] === "*");
+}
+
+function printIndentableBlockComment(comment) {
+ const lines = comment.value.split("\n");
+ return concat$6(["/*", join$4(hardline$4, lines.map((line, index) => index === 0 ? line.trimEnd() : " " + (index < lines.length - 1 ? line.trim() : line.trimStart()))), "*/"]);
+}
+
+var printerEstree = {
+ preprocess: preprocess_1,
+ print: genericPrint,
+ embed: embed_1,
+ insertPragma: insertPragma$1,
+ massageAstNode: clean_1,
+ hasPrettierIgnore: hasPrettierIgnore$1,
+ willPrintOwnComments,
+ canAttachComment,
+ printComment: printComment$1,
+ isBlockComment: comments$1.isBlockComment,
+ handleComments: {
+ ownLine: comments$1.handleOwnLineComment,
+ endOfLine: comments$1.handleEndOfLineComment,
+ remaining: comments$1.handleRemainingComment
+ },
+ getGapRegex: comments$1.getGapRegex,
+ getCommentChildNodes: comments$1.getCommentChildNodes
+};
+
+const {
+ concat: concat$7,
+ hardline: hardline$5,
+ indent: indent$4,
+ join: join$5
+} = document.builders;
+
+function genericPrint$1(path, options, print) {
+ const node = path.getValue();
+
+ switch (node.type) {
+ case "JsonRoot":
+ return concat$7([path.call(print, "node"), hardline$5]);
+
+ case "ArrayExpression":
+ return node.elements.length === 0 ? "[]" : concat$7(["[", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path.map(print, "elements"))])), hardline$5, "]"]);
+
+ case "ObjectExpression":
+ return node.properties.length === 0 ? "{}" : concat$7(["{", indent$4(concat$7([hardline$5, join$5(concat$7([",", hardline$5]), path.map(print, "properties"))])), hardline$5, "}"]);
+
+ case "ObjectProperty":
+ return concat$7([path.call(print, "key"), ": ", path.call(print, "value")]);
+
+ case "UnaryExpression":
+ return concat$7([node.operator === "+" ? "" : node.operator, path.call(print, "argument")]);
+
+ case "NullLiteral":
+ return "null";
+
+ case "BooleanLiteral":
+ return node.value ? "true" : "false";
+
+ case "StringLiteral":
+ case "NumericLiteral":
+ return JSON.stringify(node.value);
+
+ case "Identifier":
+ return JSON.stringify(node.name);
+
+ default:
+ /* istanbul ignore next */
+ throw new Error("unknown type: " + JSON.stringify(node.type));
+ }
+}
+
+function clean$1(node, newNode
+/*, parent*/
+) {
+ delete newNode.start;
+ delete newNode.end;
+ delete newNode.extra;
+ delete newNode.loc;
+ delete newNode.comments;
+ delete newNode.errors;
+
+ if (node.type === "Identifier") {
+ return {
+ type: "StringLiteral",
+ value: node.name
+ };
+ }
+
+ if (node.type === "UnaryExpression" && node.operator === "+") {
+ return newNode.argument;
+ }
+}
+
+var printerEstreeJson = {
+ preprocess: preprocess_1,
+ print: genericPrint$1,
+ massageAstNode: clean$1
+};
+
+const CATEGORY_COMMON = "Common"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
+
+var commonOptions = {
+ bracketSpacing: {
+ since: "0.0.0",
+ category: CATEGORY_COMMON,
+ type: "boolean",
+ default: true,
+ description: "Print spaces between brackets.",
+ oppositeDescription: "Do not print spaces between brackets."
+ },
+ singleQuote: {
+ since: "0.0.0",
+ category: CATEGORY_COMMON,
+ type: "boolean",
+ default: false,
+ description: "Use single quotes instead of double quotes."
+ },
+ proseWrap: {
+ since: "1.8.2",
+ category: CATEGORY_COMMON,
+ type: "choice",
+ default: [{
+ since: "1.8.2",
+ value: true
+ }, {
+ since: "1.9.0",
+ value: "preserve"
+ }],
+ description: "How to wrap prose.",
+ choices: [{
+ since: "1.9.0",
+ value: "always",
+ description: "Wrap prose if it exceeds the print width."
+ }, {
+ since: "1.9.0",
+ value: "never",
+ description: "Do not wrap prose."
+ }, {
+ since: "1.9.0",
+ value: "preserve",
+ description: "Wrap prose as-is."
+ }]
+ }
+};
+
+const CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
+
+var options$2 = {
+ arrowParens: {
+ since: "1.9.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "choice",
+ default: [{
+ since: "1.9.0",
+ value: "avoid"
+ }, {
+ since: "2.0.0",
+ value: "always"
+ }],
+ description: "Include parentheses around a sole arrow function parameter.",
+ choices: [{
+ value: "always",
+ description: "Always include parens. Example: `(x) => x`"
+ }, {
+ value: "avoid",
+ description: "Omit parens when possible. Example: `x => x`"
+ }]
+ },
+ bracketSpacing: commonOptions.bracketSpacing,
+ jsxBracketSameLine: {
+ since: "0.17.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "boolean",
+ default: false,
+ description: "Put > on the last line instead of at a new line."
+ },
+ semi: {
+ since: "1.0.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "boolean",
+ default: true,
+ description: "Print semicolons.",
+ oppositeDescription: "Do not print semicolons, except at the beginning of lines which may need them."
+ },
+ singleQuote: commonOptions.singleQuote,
+ jsxSingleQuote: {
+ since: "1.15.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "boolean",
+ default: false,
+ description: "Use single quotes in JSX."
+ },
+ quoteProps: {
+ since: "1.17.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "choice",
+ default: "as-needed",
+ description: "Change when properties in objects are quoted.",
+ choices: [{
+ value: "as-needed",
+ description: "Only add quotes around object properties where required."
+ }, {
+ value: "consistent",
+ description: "If at least one property in an object requires quotes, quote all properties."
+ }, {
+ value: "preserve",
+ description: "Respect the input use of quotes in object properties."
+ }]
+ },
+ trailingComma: {
+ since: "0.0.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "choice",
+ default: [{
+ since: "0.0.0",
+ value: false
+ }, {
+ since: "0.19.0",
+ value: "none"
+ }, {
+ since: "2.0.0",
+ value: "es5"
+ }],
+ description: "Print trailing commas wherever possible when multi-line.",
+ choices: [{
+ value: "es5",
+ description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
+ }, {
+ value: "none",
+ description: "No trailing commas."
+ }, {
+ value: "all",
+ description: "Trailing commas wherever possible (including function arguments)."
+ }]
+ }
+};
+
+var createLanguage = function (linguistData, override) {
+ const {
+ languageId
+ } = linguistData,
+ rest = _objectWithoutPropertiesLoose(linguistData, ["languageId"]);
+
+ return Object.assign({
+ linguistLanguageId: languageId
+ }, rest, {}, override(linguistData));
+};
+
+var name$2 = "JavaScript";
+var type = "programming";
+var tmScope = "source.js";
+var aceMode = "javascript";
+var codemirrorMode = "javascript";
+var codemirrorMimeType = "text/javascript";
+var color = "#f1e05a";
+var aliases = [
+ "js",
+ "node"
+];
+var extensions = [
+ ".js",
+ "._js",
+ ".bones",
+ ".cjs",
+ ".es",
+ ".es6",
+ ".frag",
+ ".gs",
+ ".jake",
+ ".jsb",
+ ".jscad",
+ ".jsfl",
+ ".jsm",
+ ".jss",
+ ".mjs",
+ ".njs",
+ ".pac",
+ ".sjs",
+ ".ssjs",
+ ".xsjs",
+ ".xsjslib"
+];
+var filenames = [
+ "Jakefile"
+];
+var interpreters = [
+ "chakra",
+ "d8",
+ "gjs",
+ "js",
+ "node",
+ "qjs",
+ "rhino",
+ "v8",
+ "v8-shell"
+];
+var languageId = 183;
+var JavaScript = {
+ name: name$2,
+ type: type,
+ tmScope: tmScope,
+ aceMode: aceMode,
+ codemirrorMode: codemirrorMode,
+ codemirrorMimeType: codemirrorMimeType,
+ color: color,
+ aliases: aliases,
+ extensions: extensions,
+ filenames: filenames,
+ interpreters: interpreters,
+ languageId: languageId
+};
+
+var JavaScript$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$2,
+ type: type,
+ tmScope: tmScope,
+ aceMode: aceMode,
+ codemirrorMode: codemirrorMode,
+ codemirrorMimeType: codemirrorMimeType,
+ color: color,
+ aliases: aliases,
+ extensions: extensions,
+ filenames: filenames,
+ interpreters: interpreters,
+ languageId: languageId,
+ 'default': JavaScript
+});
+
+var name$3 = "JSX";
+var type$1 = "programming";
+var group$3 = "JavaScript";
+var extensions$1 = [
+ ".jsx"
+];
+var tmScope$1 = "source.js.jsx";
+var aceMode$1 = "javascript";
+var codemirrorMode$1 = "jsx";
+var codemirrorMimeType$1 = "text/jsx";
+var languageId$1 = 178;
+var JSX = {
+ name: name$3,
+ type: type$1,
+ group: group$3,
+ extensions: extensions$1,
+ tmScope: tmScope$1,
+ aceMode: aceMode$1,
+ codemirrorMode: codemirrorMode$1,
+ codemirrorMimeType: codemirrorMimeType$1,
+ languageId: languageId$1
+};
+
+var JSX$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$3,
+ type: type$1,
+ group: group$3,
+ extensions: extensions$1,
+ tmScope: tmScope$1,
+ aceMode: aceMode$1,
+ codemirrorMode: codemirrorMode$1,
+ codemirrorMimeType: codemirrorMimeType$1,
+ languageId: languageId$1,
+ 'default': JSX
+});
+
+var name$4 = "TypeScript";
+var type$2 = "programming";
+var color$1 = "#2b7489";
+var aliases$1 = [
+ "ts"
+];
+var interpreters$1 = [
+ "deno",
+ "ts-node"
+];
+var extensions$2 = [
+ ".ts"
+];
+var tmScope$2 = "source.ts";
+var aceMode$2 = "typescript";
+var codemirrorMode$2 = "javascript";
+var codemirrorMimeType$2 = "application/typescript";
+var languageId$2 = 378;
+var TypeScript = {
+ name: name$4,
+ type: type$2,
+ color: color$1,
+ aliases: aliases$1,
+ interpreters: interpreters$1,
+ extensions: extensions$2,
+ tmScope: tmScope$2,
+ aceMode: aceMode$2,
+ codemirrorMode: codemirrorMode$2,
+ codemirrorMimeType: codemirrorMimeType$2,
+ languageId: languageId$2
+};
+
+var TypeScript$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$4,
+ type: type$2,
+ color: color$1,
+ aliases: aliases$1,
+ interpreters: interpreters$1,
+ extensions: extensions$2,
+ tmScope: tmScope$2,
+ aceMode: aceMode$2,
+ codemirrorMode: codemirrorMode$2,
+ codemirrorMimeType: codemirrorMimeType$2,
+ languageId: languageId$2,
+ 'default': TypeScript
+});
+
+var name$5 = "TSX";
+var type$3 = "programming";
+var group$4 = "TypeScript";
+var extensions$3 = [
+ ".tsx"
+];
+var tmScope$3 = "source.tsx";
+var aceMode$3 = "javascript";
+var codemirrorMode$3 = "jsx";
+var codemirrorMimeType$3 = "text/jsx";
+var languageId$3 = 94901924;
+var TSX = {
+ name: name$5,
+ type: type$3,
+ group: group$4,
+ extensions: extensions$3,
+ tmScope: tmScope$3,
+ aceMode: aceMode$3,
+ codemirrorMode: codemirrorMode$3,
+ codemirrorMimeType: codemirrorMimeType$3,
+ languageId: languageId$3
+};
+
+var TSX$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$5,
+ type: type$3,
+ group: group$4,
+ extensions: extensions$3,
+ tmScope: tmScope$3,
+ aceMode: aceMode$3,
+ codemirrorMode: codemirrorMode$3,
+ codemirrorMimeType: codemirrorMimeType$3,
+ languageId: languageId$3,
+ 'default': TSX
+});
+
+var name$6 = "JSON";
+var type$4 = "data";
+var tmScope$4 = "source.json";
+var aceMode$4 = "json";
+var codemirrorMode$4 = "javascript";
+var codemirrorMimeType$4 = "application/json";
+var searchable = false;
+var extensions$4 = [
+ ".json",
+ ".avsc",
+ ".geojson",
+ ".gltf",
+ ".har",
+ ".ice",
+ ".JSON-tmLanguage",
+ ".jsonl",
+ ".mcmeta",
+ ".tfstate",
+ ".tfstate.backup",
+ ".topojson",
+ ".webapp",
+ ".webmanifest",
+ ".yy",
+ ".yyp"
+];
+var filenames$1 = [
+ ".arcconfig",
+ ".htmlhintrc",
+ ".tern-config",
+ ".tern-project",
+ ".watchmanconfig",
+ "composer.lock",
+ "mcmod.info"
+];
+var languageId$4 = 174;
+var _JSON = {
+ name: name$6,
+ type: type$4,
+ tmScope: tmScope$4,
+ aceMode: aceMode$4,
+ codemirrorMode: codemirrorMode$4,
+ codemirrorMimeType: codemirrorMimeType$4,
+ searchable: searchable,
+ extensions: extensions$4,
+ filenames: filenames$1,
+ languageId: languageId$4
+};
+
+var _JSON$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$6,
+ type: type$4,
+ tmScope: tmScope$4,
+ aceMode: aceMode$4,
+ codemirrorMode: codemirrorMode$4,
+ codemirrorMimeType: codemirrorMimeType$4,
+ searchable: searchable,
+ extensions: extensions$4,
+ filenames: filenames$1,
+ languageId: languageId$4,
+ 'default': _JSON
+});
+
+var name$7 = "JSON with Comments";
+var type$5 = "data";
+var group$5 = "JSON";
+var tmScope$5 = "source.js";
+var aceMode$5 = "javascript";
+var codemirrorMode$5 = "javascript";
+var codemirrorMimeType$5 = "text/javascript";
+var aliases$2 = [
+ "jsonc"
+];
+var extensions$5 = [
+ ".jsonc",
+ ".sublime-build",
+ ".sublime-commands",
+ ".sublime-completions",
+ ".sublime-keymap",
+ ".sublime-macro",
+ ".sublime-menu",
+ ".sublime-mousemap",
+ ".sublime-project",
+ ".sublime-settings",
+ ".sublime-theme",
+ ".sublime-workspace",
+ ".sublime_metrics",
+ ".sublime_session"
+];
+var filenames$2 = [
+ ".babelrc",
+ ".eslintrc.json",
+ ".jscsrc",
+ ".jshintrc",
+ ".jslintrc",
+ "jsconfig.json",
+ "language-configuration.json",
+ "tsconfig.json"
+];
+var languageId$5 = 423;
+var JSON_with_Comments = {
+ name: name$7,
+ type: type$5,
+ group: group$5,
+ tmScope: tmScope$5,
+ aceMode: aceMode$5,
+ codemirrorMode: codemirrorMode$5,
+ codemirrorMimeType: codemirrorMimeType$5,
+ aliases: aliases$2,
+ extensions: extensions$5,
+ filenames: filenames$2,
+ languageId: languageId$5
+};
+
+var JSON_with_Comments$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$7,
+ type: type$5,
+ group: group$5,
+ tmScope: tmScope$5,
+ aceMode: aceMode$5,
+ codemirrorMode: codemirrorMode$5,
+ codemirrorMimeType: codemirrorMimeType$5,
+ aliases: aliases$2,
+ extensions: extensions$5,
+ filenames: filenames$2,
+ languageId: languageId$5,
+ 'default': JSON_with_Comments
+});
+
+var name$8 = "JSON5";
+var type$6 = "data";
+var extensions$6 = [
+ ".json5"
+];
+var tmScope$6 = "source.js";
+var aceMode$6 = "javascript";
+var codemirrorMode$6 = "javascript";
+var codemirrorMimeType$6 = "application/json";
+var languageId$6 = 175;
+var JSON5 = {
+ name: name$8,
+ type: type$6,
+ extensions: extensions$6,
+ tmScope: tmScope$6,
+ aceMode: aceMode$6,
+ codemirrorMode: codemirrorMode$6,
+ codemirrorMimeType: codemirrorMimeType$6,
+ languageId: languageId$6
+};
+
+var JSON5$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$8,
+ type: type$6,
+ extensions: extensions$6,
+ tmScope: tmScope$6,
+ aceMode: aceMode$6,
+ codemirrorMode: codemirrorMode$6,
+ codemirrorMimeType: codemirrorMimeType$6,
+ languageId: languageId$6,
+ 'default': JSON5
+});
+
+var require$$0$1 = getCjsExportFromNamespace(JavaScript$1);
+
+var require$$1 = getCjsExportFromNamespace(JSX$1);
+
+var require$$2 = getCjsExportFromNamespace(TypeScript$1);
+
+var require$$3 = getCjsExportFromNamespace(TSX$1);
+
+var require$$4$1 = getCjsExportFromNamespace(_JSON$1);
+
+var require$$5 = getCjsExportFromNamespace(JSON_with_Comments$1);
+
+var require$$6 = getCjsExportFromNamespace(JSON5$1);
+
+const languages = [createLanguage(require$$0$1, data => ({
+ since: "0.0.0",
+ parsers: ["babel", "flow"],
+ vscodeLanguageIds: ["javascript", "mongo"],
+ interpreters: data.interpreters.concat(["nodejs"])
+})), createLanguage(require$$0$1, () => ({
+ name: "Flow",
+ since: "0.0.0",
+ parsers: ["babel", "flow"],
+ vscodeLanguageIds: ["javascript"],
+ aliases: [],
+ filenames: [],
+ extensions: [".js.flow"]
+})), createLanguage(require$$1, () => ({
+ since: "0.0.0",
+ parsers: ["babel", "flow"],
+ vscodeLanguageIds: ["javascriptreact"]
+})), createLanguage(require$$2, () => ({
+ since: "1.4.0",
+ parsers: ["typescript", "babel-ts"],
+ vscodeLanguageIds: ["typescript"]
+})), createLanguage(require$$3, () => ({
+ since: "1.4.0",
+ parsers: ["typescript", "babel-ts"],
+ vscodeLanguageIds: ["typescriptreact"]
+})), createLanguage(require$$4$1, () => ({
+ name: "JSON.stringify",
+ since: "1.13.0",
+ parsers: ["json-stringify"],
+ vscodeLanguageIds: ["json"],
+ extensions: [],
+ // .json file defaults to json instead of json-stringify
+ filenames: ["package.json", "package-lock.json", "composer.json"]
+})), createLanguage(require$$4$1, data => ({
+ since: "1.5.0",
+ parsers: ["json"],
+ vscodeLanguageIds: ["json"],
+ filenames: data.filenames.concat([".prettierrc"])
+})), createLanguage(require$$5, data => ({
+ since: "1.5.0",
+ parsers: ["json"],
+ vscodeLanguageIds: ["jsonc"],
+ filenames: data.filenames.concat([".eslintrc"])
+})), createLanguage(require$$6, () => ({
+ since: "1.13.0",
+ parsers: ["json5"],
+ vscodeLanguageIds: ["json5"]
+}))];
+const printers = {
+ estree: printerEstree,
+ "estree-json": printerEstreeJson
+};
+var languageJs = {
+ languages,
+ options: options$2,
+ printers
+};
+
+function clean$2(ast, newObj, parent) {
+ ["raw", // front-matter
+ "raws", "sourceIndex", "source", "before", "after", "trailingComma"].forEach(name => {
+ delete newObj[name];
+ });
+
+ if (ast.type === "yaml") {
+ delete newObj.value;
+ } // --insert-pragma
+
+
+ if (ast.type === "css-comment" && parent.type === "css-root" && parent.nodes.length !== 0 && ( // first non-front-matter comment
+ parent.nodes[0] === ast || (parent.nodes[0].type === "yaml" || parent.nodes[0].type === "toml") && parent.nodes[1] === ast)) {
+ /**
+ * something
+ *
+ * @format
+ */
+ delete newObj.text; // standalone pragma
+
+ if (/^\*\s*@(format|prettier)\s*$/.test(ast.text)) {
+ return null;
+ }
+ }
+
+ if (ast.type === "media-query" || ast.type === "media-query-list" || ast.type === "media-feature-expression") {
+ delete newObj.value;
+ }
+
+ if (ast.type === "css-rule") {
+ delete newObj.params;
+ }
+
+ if (ast.type === "selector-combinator") {
+ newObj.value = newObj.value.replace(/\s+/g, " ");
+ }
+
+ if (ast.type === "media-feature") {
+ newObj.value = newObj.value.replace(/ /g, "");
+ }
+
+ if (ast.type === "value-word" && (ast.isColor && ast.isHex || ["initial", "inherit", "unset", "revert"].includes(newObj.value.replace().toLowerCase())) || ast.type === "media-feature" || ast.type === "selector-root-invalid" || ast.type === "selector-pseudo") {
+ newObj.value = newObj.value.toLowerCase();
+ }
+
+ if (ast.type === "css-decl") {
+ newObj.prop = newObj.prop.toLowerCase();
+ }
+
+ if (ast.type === "css-atrule" || ast.type === "css-import") {
+ newObj.name = newObj.name.toLowerCase();
+ }
+
+ if (ast.type === "value-number") {
+ newObj.unit = newObj.unit.toLowerCase();
+ }
+
+ if ((ast.type === "media-feature" || ast.type === "media-keyword" || ast.type === "media-type" || ast.type === "media-unknown" || ast.type === "media-url" || ast.type === "media-value" || ast.type === "selector-attribute" || ast.type === "selector-string" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "value-string") && newObj.value) {
+ newObj.value = cleanCSSStrings(newObj.value);
+ }
+
+ if (ast.type === "selector-attribute") {
+ newObj.attribute = newObj.attribute.trim();
+
+ if (newObj.namespace) {
+ if (typeof newObj.namespace === "string") {
+ newObj.namespace = newObj.namespace.trim();
+
+ if (newObj.namespace.length === 0) {
+ newObj.namespace = true;
+ }
+ }
+ }
+
+ if (newObj.value) {
+ newObj.value = newObj.value.trim().replace(/^['"]|['"]$/g, "");
+ delete newObj.quoted;
+ }
+ }
+
+ if ((ast.type === "media-value" || ast.type === "media-type" || ast.type === "value-number" || ast.type === "selector-root-invalid" || ast.type === "selector-class" || ast.type === "selector-combinator" || ast.type === "selector-tag") && newObj.value) {
+ newObj.value = newObj.value.replace(/([\d.eE+-]+)([a-zA-Z]*)/g, (match, numStr, unit) => {
+ const num = Number(numStr);
+ return isNaN(num) ? match : num + unit.toLowerCase();
+ });
+ }
+
+ if (ast.type === "selector-tag") {
+ const lowercasedValue = ast.value.toLowerCase();
+
+ if (["from", "to"].includes(lowercasedValue)) {
+ newObj.value = lowercasedValue;
+ }
+ } // Workaround when `postcss-values-parser` parse `not`, `and` or `or` keywords as `value-func`
+
+
+ if (ast.type === "css-atrule" && ast.name.toLowerCase() === "supports") {
+ delete newObj.value;
+ } // Workaround for SCSS nested properties
+
+
+ if (ast.type === "selector-unknown") {
+ delete newObj.value;
+ }
+}
+
+function cleanCSSStrings(value) {
+ return value.replace(/'/g, '"').replace(/\\([^a-fA-F\d])/g, "$1");
+}
+
+var clean_1$1 = clean$2;
+
+const {
+ builders: {
+ hardline: hardline$6,
+ literalline: literalline$3,
+ concat: concat$8,
+ markAsRoot: markAsRoot$1
+ },
+ utils: {
+ mapDoc: mapDoc$2
+ }
+} = document;
+
+function embed$1(path, print, textToDoc
+/*, options */
+) {
+ const node = path.getValue();
+
+ if (node.type === "yaml") {
+ return markAsRoot$1(concat$8(["---", hardline$6, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
+ parser: "yaml"
+ })) : "", "---", hardline$6]));
+ }
+
+ return null;
+
+ function replaceNewlinesWithLiterallines(doc) {
+ return mapDoc$2(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$8(currentDoc.split(/(\n)/g).map((v, i) => i % 2 === 0 ? v : literalline$3)) : currentDoc);
+ }
+}
+
+var embed_1$1 = embed$1;
+
+const DELIMITER_MAP = {
+ "---": "yaml",
+ "+++": "toml"
+};
+
+function parse$4(text) {
+ const delimiterRegex = Object.keys(DELIMITER_MAP).map(escapeStringRegexp$2).join("|");
+ const match = text.match( // trailing spaces after delimiters are allowed
+ new RegExp(`^(${delimiterRegex})[^\\n\\S]*\\n(?:([\\s\\S]*?)\\n)?\\1[^\\n\\S]*(\\n|$)`));
+
+ if (match === null) {
+ return {
+ frontMatter: null,
+ content: text
+ };
+ }
+
+ const [raw, delimiter, value] = match;
+ return {
+ frontMatter: {
+ type: DELIMITER_MAP[delimiter],
+ value,
+ raw: raw.replace(/\n$/, "")
+ },
+ content: raw.replace(/[^\n]/g, " ") + text.slice(raw.length)
+ };
+}
+
+var frontMatter = parse$4;
+
+function hasPragma$1(text) {
+ return pragma.hasPragma(frontMatter(text).content);
+}
+
+function insertPragma$2(text) {
+ const {
+ frontMatter: frontMatter$1,
+ content
+ } = frontMatter(text);
+ return (frontMatter$1 ? frontMatter$1.raw + "\n\n" : "") + pragma.insertPragma(content);
+}
+
+var pragma$1 = {
+ hasPragma: hasPragma$1,
+ insertPragma: insertPragma$2
+};
+
+var lineColumnToIndex = function (lineColumn, text) {
+ let index = 0;
+
+ for (let i = 0; i < lineColumn.line - 1; ++i) {
+ index = text.indexOf("\n", index) + 1;
+
+ if (index === -1) {
+ return -1;
+ }
+ }
+
+ return index + lineColumn.column;
+};
+
+const {
+ getLast: getLast$3,
+ skipEverythingButNewLine: skipEverythingButNewLine$2
+} = util$1;
+
+function calculateLocStart(node, text) {
+ if (node.source) {
+ return lineColumnToIndex(node.source.start, text) - 1;
+ }
+
+ return null;
+}
+
+function calculateLocEnd(node, text) {
+ if (node.type === "css-comment" && node.inline) {
+ return skipEverythingButNewLine$2(text, node.source.startOffset);
+ }
+
+ const endNode = node.nodes && getLast$3(node.nodes);
+
+ if (endNode && node.source && !node.source.end) {
+ node = endNode;
+ }
+
+ if (node.source && node.source.end) {
+ return lineColumnToIndex(node.source.end, text);
+ }
+
+ return null;
+}
+
+function calculateLoc(node, text) {
+ if (node && typeof node === "object") {
+ if (node.source) {
+ node.source.startOffset = calculateLocStart(node, text);
+ node.source.endOffset = calculateLocEnd(node, text);
+ }
+
+ for (const key in node) {
+ calculateLoc(node[key], text);
+ }
+ }
+}
+/**
+ * Workaround for a bug: quotes in inline comments corrupt loc data of subsequent nodes.
+ * This function replaces the quotes with U+FFFE and U+FFFF. Later, when the comments are printed,
+ * their content is extracted from the original text or restored by replacing the placeholder
+ * characters back with quotes.
+ * - https://github.com/prettier/prettier/issues/7780
+ * - https://github.com/shellscape/postcss-less/issues/145
+ * - About noncharacters (U+FFFE and U+FFFF): http://www.unicode.org/faq/private_use.html#nonchar1
+ * @param text {string}
+ */
+
+
+function replaceQuotesInInlineComments(text) {
+ /** @typedef { 'initial' | 'single-quotes' | 'double-quotes' | 'url' | 'comment-block' | 'comment-inline' } State */
+
+ /** @type {State} */
+ let state = "initial";
+ /** @type {State} */
+
+ let stateToReturnFromQuotes = "initial";
+ let inlineCommentStartIndex;
+ let inlineCommentContainsQuotes = false;
+ const inlineCommentsToReplace = [];
+
+ for (let i = 0; i < text.length; i++) {
+ const c = text[i];
+
+ switch (state) {
+ case "initial":
+ if (c === "'") {
+ state = "single-quotes";
+ continue;
+ }
+
+ if (c === '"') {
+ state = "double-quotes";
+ continue;
+ }
+
+ if ((c === "u" || c === "U") && text.slice(i, i + 4).toLowerCase() === "url(") {
+ state = "url";
+ i += 3;
+ continue;
+ }
+
+ if (c === "*" && text[i - 1] === "/") {
+ state = "comment-block";
+ continue;
+ }
+
+ if (c === "/" && text[i - 1] === "/") {
+ state = "comment-inline";
+ inlineCommentStartIndex = i - 1;
+ continue;
+ }
+
+ continue;
+
+ case "single-quotes":
+ if (c === "'" && text[i - 1] !== "\\") {
+ state = stateToReturnFromQuotes;
+ stateToReturnFromQuotes = "initial";
+ }
+
+ if (c === "\n" || c === "\r") {
+ return text; // invalid input
+ }
+
+ continue;
+
+ case "double-quotes":
+ if (c === '"' && text[i - 1] !== "\\") {
+ state = stateToReturnFromQuotes;
+ stateToReturnFromQuotes = "initial";
+ }
+
+ if (c === "\n" || c === "\r") {
+ return text; // invalid input
+ }
+
+ continue;
+
+ case "url":
+ if (c === ")") {
+ state = "initial";
+ }
+
+ if (c === "\n" || c === "\r") {
+ return text; // invalid input
+ }
+
+ if (c === "'") {
+ state = "single-quotes";
+ stateToReturnFromQuotes = "url";
+ continue;
+ }
+
+ if (c === '"') {
+ state = "double-quotes";
+ stateToReturnFromQuotes = "url";
+ continue;
+ }
+
+ continue;
+
+ case "comment-block":
+ if (c === "/" && text[i - 1] === "*") {
+ state = "initial";
+ }
+
+ continue;
+
+ case "comment-inline":
+ if (c === '"' || c === "'") {
+ inlineCommentContainsQuotes = true;
+ }
+
+ if (c === "\n" || c === "\r") {
+ if (inlineCommentContainsQuotes) {
+ inlineCommentsToReplace.push([inlineCommentStartIndex, i]);
+ }
+
+ state = "initial";
+ inlineCommentContainsQuotes = false;
+ }
+
+ continue;
+ }
+ }
+
+ for (const [start, end] of inlineCommentsToReplace) {
+ text = text.slice(0, start) + text.slice(start, end).replace(/'/g, "\ufffe").replace(/"/g, "\uffff") + text.slice(end);
+ }
+
+ return text;
+}
+
+function restoreQuotesInInlineComments(text) {
+ return text.replace(/\ufffe/g, "'").replace(/\uffff/g, '"');
+}
+
+var loc$1 = {
+ calculateLoc,
+ replaceQuotesInInlineComments,
+ restoreQuotesInInlineComments
+};
+
+const colorAdjusterFunctions = ["red", "green", "blue", "alpha", "a", "rgb", "hue", "h", "saturation", "s", "lightness", "l", "whiteness", "w", "blackness", "b", "tint", "shade", "blend", "blenda", "contrast", "hsl", "hsla", "hwb", "hwba"];
+
+function getAncestorCounter(path, typeOrTypes) {
+ const types = [].concat(typeOrTypes);
+ let counter = -1;
+ let ancestorNode;
+
+ while (ancestorNode = path.getParentNode(++counter)) {
+ if (types.includes(ancestorNode.type)) {
+ return counter;
+ }
+ }
+
+ return -1;
+}
+
+function getAncestorNode(path, typeOrTypes) {
+ const counter = getAncestorCounter(path, typeOrTypes);
+ return counter === -1 ? null : path.getParentNode(counter);
+}
+
+function getPropOfDeclNode(path) {
+ const declAncestorNode = getAncestorNode(path, "css-decl");
+ return declAncestorNode && declAncestorNode.prop && declAncestorNode.prop.toLowerCase();
+}
+
+function isSCSS(parser, text) {
+ const hasExplicitParserChoice = parser === "less" || parser === "scss";
+ const IS_POSSIBLY_SCSS = /(\w\s*:\s*[^}:]+|#){|@import[^\n]+(?:url|,)/;
+ return hasExplicitParserChoice ? parser === "scss" : IS_POSSIBLY_SCSS.test(text);
+}
+
+function isWideKeywords(value) {
+ return ["initial", "inherit", "unset", "revert"].includes(value.toLowerCase());
+}
+
+function isKeyframeAtRuleKeywords(path, value) {
+ const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
+ return atRuleAncestorNode && atRuleAncestorNode.name && atRuleAncestorNode.name.toLowerCase().endsWith("keyframes") && ["from", "to"].includes(value.toLowerCase());
+}
+
+function maybeToLowerCase(value) {
+ return value.includes("$") || value.includes("@") || value.includes("#") || value.startsWith("%") || value.startsWith("--") || value.startsWith(":--") || value.includes("(") && value.includes(")") ? value : value.toLowerCase();
+}
+
+function insideValueFunctionNode(path, functionName) {
+ const funcAncestorNode = getAncestorNode(path, "value-func");
+ return funcAncestorNode && funcAncestorNode.value && funcAncestorNode.value.toLowerCase() === functionName;
+}
+
+function insideICSSRuleNode(path) {
+ const ruleAncestorNode = getAncestorNode(path, "css-rule");
+ return ruleAncestorNode && ruleAncestorNode.raws && ruleAncestorNode.raws.selector && (ruleAncestorNode.raws.selector.startsWith(":import") || ruleAncestorNode.raws.selector.startsWith(":export"));
+}
+
+function insideAtRuleNode(path, atRuleNameOrAtRuleNames) {
+ const atRuleNames = [].concat(atRuleNameOrAtRuleNames);
+ const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
+ return atRuleAncestorNode && atRuleNames.includes(atRuleAncestorNode.name.toLowerCase());
+}
+
+function insideURLFunctionInImportAtRuleNode(path) {
+ const node = path.getValue();
+ const atRuleAncestorNode = getAncestorNode(path, "css-atrule");
+ return atRuleAncestorNode && atRuleAncestorNode.name === "import" && node.groups[0].value === "url" && node.groups.length === 2;
+}
+
+function isURLFunctionNode(node) {
+ return node.type === "value-func" && node.value.toLowerCase() === "url";
+}
+
+function isLastNode(path, node) {
+ const parentNode = path.getParentNode();
+
+ if (!parentNode) {
+ return false;
+ }
+
+ const {
+ nodes
+ } = parentNode;
+ return nodes && nodes.indexOf(node) === nodes.length - 1;
+}
+
+function isDetachedRulesetDeclarationNode(node) {
+ // If a Less file ends up being parsed with the SCSS parser, Less
+ // variable declarations will be parsed as atrules with names ending
+ // with a colon, so keep the original case then.
+ if (!node.selector) {
+ return false;
+ }
+
+ return typeof node.selector === "string" && /^@.+:.*$/.test(node.selector) || node.selector.value && /^@.+:.*$/.test(node.selector.value);
+}
+
+function isForKeywordNode(node) {
+ return node.type === "value-word" && ["from", "through", "end"].includes(node.value);
+}
+
+function isIfElseKeywordNode(node) {
+ return node.type === "value-word" && ["and", "or", "not"].includes(node.value);
+}
+
+function isEachKeywordNode(node) {
+ return node.type === "value-word" && node.value === "in";
+}
+
+function isMultiplicationNode(node) {
+ return node.type === "value-operator" && node.value === "*";
+}
+
+function isDivisionNode(node) {
+ return node.type === "value-operator" && node.value === "/";
+}
+
+function isAdditionNode(node) {
+ return node.type === "value-operator" && node.value === "+";
+}
+
+function isSubtractionNode(node) {
+ return node.type === "value-operator" && node.value === "-";
+}
+
+function isModuloNode(node) {
+ return node.type === "value-operator" && node.value === "%";
+}
+
+function isMathOperatorNode(node) {
+ return isMultiplicationNode(node) || isDivisionNode(node) || isAdditionNode(node) || isSubtractionNode(node) || isModuloNode(node);
+}
+
+function isEqualityOperatorNode(node) {
+ return node.type === "value-word" && ["==", "!="].includes(node.value);
+}
+
+function isRelationalOperatorNode(node) {
+ return node.type === "value-word" && ["<", ">", "<=", ">="].includes(node.value);
+}
+
+function isSCSSControlDirectiveNode(node) {
+ return node.type === "css-atrule" && ["if", "else", "for", "each", "while"].includes(node.name);
+}
+
+function isSCSSNestedPropertyNode(node) {
+ if (!node.selector) {
+ return false;
+ }
+
+ return node.selector.replace(/\/\*.*?\*\//, "").replace(/\/\/.*?\n/, "").trim().endsWith(":");
+}
+
+function isDetachedRulesetCallNode(node) {
+ return node.raws && node.raws.params && /^\(\s*\)$/.test(node.raws.params);
+}
+
+function isTemplatePlaceholderNode(node) {
+ return node.name.startsWith("prettier-placeholder");
+}
+
+function isTemplatePropNode(node) {
+ return node.prop.startsWith("@prettier-placeholder");
+}
+
+function isPostcssSimpleVarNode(currentNode, nextNode) {
+ return currentNode.value === "$$" && currentNode.type === "value-func" && nextNode && nextNode.type === "value-word" && !nextNode.raws.before;
+}
+
+function hasComposesNode(node) {
+ return node.value && node.value.type === "value-root" && node.value.group && node.value.group.type === "value-value" && node.prop.toLowerCase() === "composes";
+}
+
+function hasParensAroundNode(node) {
+ return node.value && node.value.group && node.value.group.group && node.value.group.group.type === "value-paren_group" && node.value.group.group.open !== null && node.value.group.group.close !== null;
+}
+
+function hasEmptyRawBefore(node) {
+ return node.raws && node.raws.before === "";
+}
+
+function isKeyValuePairNode(node) {
+ return node.type === "value-comma_group" && node.groups && node.groups[1] && node.groups[1].type === "value-colon";
+}
+
+function isKeyValuePairInParenGroupNode(node) {
+ return node.type === "value-paren_group" && node.groups && node.groups[0] && isKeyValuePairNode(node.groups[0]);
+}
+
+function isSCSSMapItemNode(path) {
+ const node = path.getValue(); // Ignore empty item (i.e. `$key: ()`)
+
+ if (node.groups.length === 0) {
+ return false;
+ }
+
+ const parentParentNode = path.getParentNode(1); // Check open parens contain key/value pair (i.e. `(key: value)` and `(key: (value, other-value)`)
+
+ if (!isKeyValuePairInParenGroupNode(node) && !(parentParentNode && isKeyValuePairInParenGroupNode(parentParentNode))) {
+ return false;
+ }
+
+ const declNode = getAncestorNode(path, "css-decl"); // SCSS map declaration (i.e. `$map: (key: value, other-key: other-value)`)
+
+ if (declNode && declNode.prop && declNode.prop.startsWith("$")) {
+ return true;
+ } // List as value of key inside SCSS map (i.e. `$map: (key: (value other-value other-other-value))`)
+
+
+ if (isKeyValuePairInParenGroupNode(parentParentNode)) {
+ return true;
+ } // SCSS Map is argument of function (i.e. `func((key: value, other-key: other-value))`)
+
+
+ if (parentParentNode.type === "value-func") {
+ return true;
+ }
+
+ return false;
+}
+
+function isInlineValueCommentNode(node) {
+ return node.type === "value-comment" && node.inline;
+}
+
+function isHashNode(node) {
+ return node.type === "value-word" && node.value === "#";
+}
+
+function isLeftCurlyBraceNode(node) {
+ return node.type === "value-word" && node.value === "{";
+}
+
+function isRightCurlyBraceNode(node) {
+ return node.type === "value-word" && node.value === "}";
+}
+
+function isWordNode(node) {
+ return ["value-word", "value-atword"].includes(node.type);
+}
+
+function isColonNode(node) {
+ return node.type === "value-colon";
+}
+
+function isMediaAndSupportsKeywords(node) {
+ return node.value && ["not", "and", "or"].includes(node.value.toLowerCase());
+}
+
+function isColorAdjusterFuncNode(node) {
+ if (node.type !== "value-func") {
+ return false;
+ }
+
+ return colorAdjusterFunctions.includes(node.value.toLowerCase());
+} // TODO: only check `less` when we don't use `less` to parse `css`
+
+
+function isLessParser(options) {
+ return options.parser === "css" || options.parser === "less";
+}
+
+function lastLineHasInlineComment(text) {
+ return /\/\//.test(text.split(/[\r\n]/).pop());
+}
+
+var utils$7 = {
+ getAncestorCounter,
+ getAncestorNode,
+ getPropOfDeclNode,
+ maybeToLowerCase,
+ insideValueFunctionNode,
+ insideICSSRuleNode,
+ insideAtRuleNode,
+ insideURLFunctionInImportAtRuleNode,
+ isKeyframeAtRuleKeywords,
+ isWideKeywords,
+ isSCSS,
+ isLastNode,
+ isLessParser,
+ isSCSSControlDirectiveNode,
+ isDetachedRulesetDeclarationNode,
+ isRelationalOperatorNode,
+ isEqualityOperatorNode,
+ isMultiplicationNode,
+ isDivisionNode,
+ isAdditionNode,
+ isSubtractionNode,
+ isModuloNode,
+ isMathOperatorNode,
+ isEachKeywordNode,
+ isForKeywordNode,
+ isURLFunctionNode,
+ isIfElseKeywordNode,
+ hasComposesNode,
+ hasParensAroundNode,
+ hasEmptyRawBefore,
+ isSCSSNestedPropertyNode,
+ isDetachedRulesetCallNode,
+ isTemplatePlaceholderNode,
+ isTemplatePropNode,
+ isPostcssSimpleVarNode,
+ isKeyValuePairNode,
+ isKeyValuePairInParenGroupNode,
+ isSCSSMapItemNode,
+ isInlineValueCommentNode,
+ isHashNode,
+ isLeftCurlyBraceNode,
+ isRightCurlyBraceNode,
+ isWordNode,
+ isColonNode,
+ isMediaAndSupportsKeywords,
+ isColorAdjusterFuncNode,
+ lastLineHasInlineComment
+};
+
+const {
+ insertPragma: insertPragma$3
+} = pragma$1;
+const {
+ printNumber: printNumber$2,
+ printString: printString$2,
+ hasIgnoreComment: hasIgnoreComment$3,
+ hasNewline: hasNewline$5
+} = util$1;
+const {
+ isNextLineEmpty: isNextLineEmpty$3
+} = utilShared;
+const {
+ restoreQuotesInInlineComments: restoreQuotesInInlineComments$1
+} = loc$1;
+const {
+ builders: {
+ concat: concat$9,
+ join: join$6,
+ line: line$5,
+ hardline: hardline$7,
+ softline: softline$3,
+ group: group$6,
+ fill: fill$4,
+ indent: indent$5,
+ dedent: dedent$2,
+ ifBreak: ifBreak$2
+ },
+ utils: {
+ removeLines: removeLines$2
+ }
+} = document;
+const {
+ getAncestorNode: getAncestorNode$1,
+ getPropOfDeclNode: getPropOfDeclNode$1,
+ maybeToLowerCase: maybeToLowerCase$1,
+ insideValueFunctionNode: insideValueFunctionNode$1,
+ insideICSSRuleNode: insideICSSRuleNode$1,
+ insideAtRuleNode: insideAtRuleNode$1,
+ insideURLFunctionInImportAtRuleNode: insideURLFunctionInImportAtRuleNode$1,
+ isKeyframeAtRuleKeywords: isKeyframeAtRuleKeywords$1,
+ isWideKeywords: isWideKeywords$1,
+ isSCSS: isSCSS$1,
+ isLastNode: isLastNode$1,
+ isLessParser: isLessParser$1,
+ isSCSSControlDirectiveNode: isSCSSControlDirectiveNode$1,
+ isDetachedRulesetDeclarationNode: isDetachedRulesetDeclarationNode$1,
+ isRelationalOperatorNode: isRelationalOperatorNode$1,
+ isEqualityOperatorNode: isEqualityOperatorNode$1,
+ isMultiplicationNode: isMultiplicationNode$1,
+ isDivisionNode: isDivisionNode$1,
+ isAdditionNode: isAdditionNode$1,
+ isSubtractionNode: isSubtractionNode$1,
+ isMathOperatorNode: isMathOperatorNode$1,
+ isEachKeywordNode: isEachKeywordNode$1,
+ isForKeywordNode: isForKeywordNode$1,
+ isURLFunctionNode: isURLFunctionNode$1,
+ isIfElseKeywordNode: isIfElseKeywordNode$1,
+ hasComposesNode: hasComposesNode$1,
+ hasParensAroundNode: hasParensAroundNode$1,
+ hasEmptyRawBefore: hasEmptyRawBefore$1,
+ isKeyValuePairNode: isKeyValuePairNode$1,
+ isDetachedRulesetCallNode: isDetachedRulesetCallNode$1,
+ isTemplatePlaceholderNode: isTemplatePlaceholderNode$1,
+ isTemplatePropNode: isTemplatePropNode$1,
+ isPostcssSimpleVarNode: isPostcssSimpleVarNode$1,
+ isSCSSMapItemNode: isSCSSMapItemNode$1,
+ isInlineValueCommentNode: isInlineValueCommentNode$1,
+ isHashNode: isHashNode$1,
+ isLeftCurlyBraceNode: isLeftCurlyBraceNode$1,
+ isRightCurlyBraceNode: isRightCurlyBraceNode$1,
+ isWordNode: isWordNode$1,
+ isColonNode: isColonNode$1,
+ isMediaAndSupportsKeywords: isMediaAndSupportsKeywords$1,
+ isColorAdjusterFuncNode: isColorAdjusterFuncNode$1,
+ lastLineHasInlineComment: lastLineHasInlineComment$1
+} = utils$7;
+
+function shouldPrintComma$1(options) {
+ switch (options.trailingComma) {
+ case "all":
+ case "es5":
+ return true;
+
+ case "none":
+ default:
+ return false;
+ }
+}
+
+function genericPrint$2(path, options, print) {
+ const node = path.getValue();
+ /* istanbul ignore if */
+
+ if (!node) {
+ return "";
+ }
+
+ if (typeof node === "string") {
+ return node;
+ }
+
+ switch (node.type) {
+ case "yaml":
+ case "toml":
+ return concat$9([node.raw, hardline$7]);
+
+ case "css-root":
+ {
+ const nodes = printNodeSequence(path, options, print);
+
+ if (nodes.parts.length) {
+ return concat$9([nodes, options.__isHTMLStyleAttribute ? "" : hardline$7]);
+ }
+
+ return nodes;
+ }
+
+ case "css-comment":
+ {
+ const isInlineComment = node.inline || node.raws.inline;
+ const text = options.originalText.slice(options.locStart(node), options.locEnd(node));
+ return isInlineComment ? text.trimEnd() : text;
+ }
+
+ case "css-rule":
+ {
+ return concat$9([path.call(print, "selector"), node.important ? " !important" : "", node.nodes ? concat$9([node.selector && node.selector.type === "selector-unknown" && lastLineHasInlineComment$1(node.selector.value) ? line$5 : " ", "{", node.nodes.length > 0 ? indent$5(concat$9([hardline$7, printNodeSequence(path, options, print)])) : "", hardline$7, "}", isDetachedRulesetDeclarationNode$1(node) ? ";" : ""]) : ";"]);
+ }
+
+ case "css-decl":
+ {
+ const parentNode = path.getParentNode();
+ return concat$9([node.raws.before.replace(/[\s;]/g, ""), insideICSSRuleNode$1(path) ? node.prop : maybeToLowerCase$1(node.prop), node.raws.between.trim() === ":" ? ":" : node.raws.between.trim(), node.extend ? "" : " ", hasComposesNode$1(node) ? removeLines$2(path.call(print, "value")) : path.call(print, "value"), node.raws.important ? node.raws.important.replace(/\s*!\s*important/i, " !important") : node.important ? " !important" : "", node.raws.scssDefault ? node.raws.scssDefault.replace(/\s*!default/i, " !default") : node.scssDefault ? " !default" : "", node.raws.scssGlobal ? node.raws.scssGlobal.replace(/\s*!global/i, " !global") : node.scssGlobal ? " !global" : "", node.nodes ? concat$9([" {", indent$5(concat$9([softline$3, printNodeSequence(path, options, print)])), softline$3, "}"]) : isTemplatePropNode$1(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";" ? "" : ";"]);
+ }
+
+ case "css-atrule":
+ {
+ const parentNode = path.getParentNode();
+ const isTemplatePlaceholderNodeWithoutSemiColon = isTemplatePlaceholderNode$1(node) && !parentNode.raws.semicolon && options.originalText[options.locEnd(node) - 1] !== ";";
+
+ if (isLessParser$1(options)) {
+ if (node.mixin) {
+ return concat$9([path.call(print, "selector"), node.important ? " !important" : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
+ }
+
+ if (node.function) {
+ return concat$9([node.name, concat$9([path.call(print, "params")]), isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
+ }
+
+ if (node.variable) {
+ return concat$9(["@", node.name, ": ", node.value ? concat$9([path.call(print, "value")]) : "", node.raws.between.trim() ? node.raws.between.trim() + " " : "", node.nodes ? concat$9(["{", indent$5(concat$9([node.nodes.length > 0 ? softline$3 : "", printNodeSequence(path, options, print)])), softline$3, "}"]) : "", isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
+ }
+ }
+
+ return concat$9(["@", // If a Less file ends up being parsed with the SCSS parser, Less
+ // variable declarations will be parsed as at-rules with names ending
+ // with a colon, so keep the original case then.
+ isDetachedRulesetCallNode$1(node) || node.name.endsWith(":") ? node.name : maybeToLowerCase$1(node.name), node.params ? concat$9([isDetachedRulesetCallNode$1(node) ? "" : isTemplatePlaceholderNode$1(node) ? node.raws.afterName === "" ? "" : node.name.endsWith(":") ? " " : /^\s*\n\s*\n/.test(node.raws.afterName) ? concat$9([hardline$7, hardline$7]) : /^\s*\n/.test(node.raws.afterName) ? hardline$7 : " " : " ", path.call(print, "params")]) : "", node.selector ? indent$5(concat$9([" ", path.call(print, "selector")])) : "", node.value ? group$6(concat$9([" ", path.call(print, "value"), isSCSSControlDirectiveNode$1(node) ? hasParensAroundNode$1(node) ? " " : line$5 : ""])) : node.name === "else" ? " " : "", node.nodes ? concat$9([isSCSSControlDirectiveNode$1(node) ? "" : " ", "{", indent$5(concat$9([node.nodes.length > 0 ? softline$3 : "", printNodeSequence(path, options, print)])), softline$3, "}"]) : isTemplatePlaceholderNodeWithoutSemiColon ? "" : ";"]);
+ }
+ // postcss-media-query-parser
+
+ case "media-query-list":
+ {
+ const parts = [];
+ path.each(childPath => {
+ const node = childPath.getValue();
+
+ if (node.type === "media-query" && node.value === "") {
+ return;
+ }
+
+ parts.push(childPath.call(print));
+ }, "nodes");
+ return group$6(indent$5(join$6(line$5, parts)));
+ }
+
+ case "media-query":
+ {
+ return concat$9([join$6(" ", path.map(print, "nodes")), isLastNode$1(path, node) ? "" : ","]);
+ }
+
+ case "media-type":
+ {
+ return adjustNumbers(adjustStrings(node.value, options));
+ }
+
+ case "media-feature-expression":
+ {
+ if (!node.nodes) {
+ return node.value;
+ }
+
+ return concat$9(["(", concat$9(path.map(print, "nodes")), ")"]);
+ }
+
+ case "media-feature":
+ {
+ return maybeToLowerCase$1(adjustStrings(node.value.replace(/ +/g, " "), options));
+ }
+
+ case "media-colon":
+ {
+ return concat$9([node.value, " "]);
+ }
+
+ case "media-value":
+ {
+ return adjustNumbers(adjustStrings(node.value, options));
+ }
+
+ case "media-keyword":
+ {
+ return adjustStrings(node.value, options);
+ }
+
+ case "media-url":
+ {
+ return adjustStrings(node.value.replace(/^url\(\s+/gi, "url(").replace(/\s+\)$/gi, ")"), options);
+ }
+
+ case "media-unknown":
+ {
+ return node.value;
+ }
+ // postcss-selector-parser
+
+ case "selector-root":
+ {
+ return group$6(concat$9([insideAtRuleNode$1(path, "custom-selector") ? concat$9([getAncestorNode$1(path, "css-atrule").customSelector, line$5]) : "", join$6(concat$9([",", insideAtRuleNode$1(path, ["extend", "custom-selector", "nest"]) ? line$5 : hardline$7]), path.map(print, "nodes"))]));
+ }
+
+ case "selector-selector":
+ {
+ return group$6(indent$5(concat$9(path.map(print, "nodes"))));
+ }
+
+ case "selector-comment":
+ {
+ return node.value;
+ }
+
+ case "selector-string":
+ {
+ return adjustStrings(node.value, options);
+ }
+
+ case "selector-tag":
+ {
+ const parentNode = path.getParentNode();
+ const index = parentNode && parentNode.nodes.indexOf(node);
+ const prevNode = index && parentNode.nodes[index - 1];
+ return concat$9([node.namespace ? concat$9([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", prevNode.type === "selector-nesting" ? node.value : adjustNumbers(isKeyframeAtRuleKeywords$1(path, node.value) ? node.value.toLowerCase() : node.value)]);
+ }
+
+ case "selector-id":
+ {
+ return concat$9(["#", node.value]);
+ }
+
+ case "selector-class":
+ {
+ return concat$9([".", adjustNumbers(adjustStrings(node.value, options))]);
+ }
+
+ case "selector-attribute":
+ {
+ return concat$9(["[", node.namespace ? concat$9([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.attribute.trim(), node.operator ? node.operator : "", node.value ? quoteAttributeValue(adjustStrings(node.value.trim(), options), options) : "", node.insensitive ? " i" : "", "]"]);
+ }
+
+ case "selector-combinator":
+ {
+ if (node.value === "+" || node.value === ">" || node.value === "~" || node.value === ">>>") {
+ const parentNode = path.getParentNode();
+ const leading = parentNode.type === "selector-selector" && parentNode.nodes[0] === node ? "" : line$5;
+ return concat$9([leading, node.value, isLastNode$1(path, node) ? "" : " "]);
+ }
+
+ const leading = node.value.trim().startsWith("(") ? line$5 : "";
+ const value = adjustNumbers(adjustStrings(node.value.trim(), options)) || line$5;
+ return concat$9([leading, value]);
+ }
+
+ case "selector-universal":
+ {
+ return concat$9([node.namespace ? concat$9([node.namespace === true ? "" : node.namespace.trim(), "|"]) : "", node.value]);
+ }
+
+ case "selector-pseudo":
+ {
+ return concat$9([maybeToLowerCase$1(node.value), node.nodes && node.nodes.length > 0 ? concat$9(["(", join$6(", ", path.map(print, "nodes")), ")"]) : ""]);
+ }
+
+ case "selector-nesting":
+ {
+ return node.value;
+ }
+
+ case "selector-unknown":
+ {
+ const ruleAncestorNode = getAncestorNode$1(path, "css-rule"); // Nested SCSS property
+
+ if (ruleAncestorNode && ruleAncestorNode.isSCSSNesterProperty) {
+ return adjustNumbers(adjustStrings(maybeToLowerCase$1(node.value), options));
+ } // originalText has to be used for Less, see replaceQuotesInInlineComments in loc.js
+
+
+ const parentNode = path.getParentNode();
+
+ if (parentNode.raws && parentNode.raws.selector) {
+ const start = options.locStart(parentNode);
+ const end = start + parentNode.raws.selector.length;
+ return options.originalText.slice(start, end).trim();
+ }
+
+ return node.value;
+ }
+ // postcss-values-parser
+
+ case "value-value":
+ case "value-root":
+ {
+ return path.call(print, "group");
+ }
+
+ case "value-comment":
+ {
+ return concat$9([node.inline ? "//" : "/*", // see replaceQuotesInInlineComments in loc.js
+ // value-* nodes don't have correct location data, so we have to rely on placeholder characters.
+ restoreQuotesInInlineComments$1(node.value), node.inline ? "" : "*/"]);
+ }
+
+ case "value-comma_group":
+ {
+ const parentNode = path.getParentNode();
+ const parentParentNode = path.getParentNode(1);
+ const declAncestorProp = getPropOfDeclNode$1(path);
+ const isGridValue = declAncestorProp && parentNode.type === "value-value" && (declAncestorProp === "grid" || declAncestorProp.startsWith("grid-template"));
+ const atRuleAncestorNode = getAncestorNode$1(path, "css-atrule");
+ const isControlDirective = atRuleAncestorNode && isSCSSControlDirectiveNode$1(atRuleAncestorNode);
+ const printed = path.map(print, "groups");
+ const parts = [];
+ const insideURLFunction = insideValueFunctionNode$1(path, "url");
+ let insideSCSSInterpolationInString = false;
+ let didBreak = false;
+
+ for (let i = 0; i < node.groups.length; ++i) {
+ parts.push(printed[i]);
+ const iPrevNode = node.groups[i - 1];
+ const iNode = node.groups[i];
+ const iNextNode = node.groups[i + 1];
+ const iNextNextNode = node.groups[i + 2];
+
+ if (insideURLFunction) {
+ if (iNextNode && isAdditionNode$1(iNextNode) || isAdditionNode$1(iNode)) {
+ parts.push(" ");
+ }
+
+ continue;
+ } // Ignore after latest node (i.e. before semicolon)
+
+
+ if (!iNextNode) {
+ continue;
+ } // styled.div` background: var(--${one}); `
+
+
+ if (!iPrevNode && iNode.value === "--" && iNextNode.type === "value-atword") {
+ continue;
+ } // Ignore spaces before/after string interpolation (i.e. `"#{my-fn("_")}"`)
+
+
+ const isStartSCSSInterpolationInString = iNode.type === "value-string" && iNode.value.startsWith("#{");
+ const isEndingSCSSInterpolationInString = insideSCSSInterpolationInString && iNextNode.type === "value-string" && iNextNode.value.endsWith("}");
+
+ if (isStartSCSSInterpolationInString || isEndingSCSSInterpolationInString) {
+ insideSCSSInterpolationInString = !insideSCSSInterpolationInString;
+ continue;
+ }
+
+ if (insideSCSSInterpolationInString) {
+ continue;
+ } // Ignore colon (i.e. `:`)
+
+
+ if (isColonNode$1(iNode) || isColonNode$1(iNextNode)) {
+ continue;
+ } // Ignore `@` in Less (i.e. `@@var;`)
+
+
+ if (iNode.type === "value-atword" && iNode.value === "") {
+ continue;
+ } // Ignore `~` in Less (i.e. `content: ~"^//* some horrible but needed css hack";`)
+
+
+ if (iNode.value === "~") {
+ continue;
+ } // Ignore escape `\`
+
+
+ if (iNode.value && iNode.value.includes("\\") && iNextNode && iNextNode.type !== "value-comment") {
+ continue;
+ } // Ignore escaped `/`
+
+
+ if (iPrevNode && iPrevNode.value && iPrevNode.value.indexOf("\\") === iPrevNode.value.length - 1 && iNode.type === "value-operator" && iNode.value === "/") {
+ continue;
+ } // Ignore `\` (i.e. `$variable: \@small;`)
+
+
+ if (iNode.value === "\\") {
+ continue;
+ } // Ignore `$$` (i.e. `background-color: $$(style)Color;`)
+
+
+ if (isPostcssSimpleVarNode$1(iNode, iNextNode)) {
+ continue;
+ } // Ignore spaces after `#` and after `{` and before `}` in SCSS interpolation (i.e. `#{variable}`)
+
+
+ if (isHashNode$1(iNode) || isLeftCurlyBraceNode$1(iNode) || isRightCurlyBraceNode$1(iNextNode) || isLeftCurlyBraceNode$1(iNextNode) && hasEmptyRawBefore$1(iNextNode) || isRightCurlyBraceNode$1(iNode) && hasEmptyRawBefore$1(iNextNode)) {
+ continue;
+ } // Ignore css variables and interpolation in SCSS (i.e. `--#{$var}`)
+
+
+ if (iNode.value === "--" && isHashNode$1(iNextNode)) {
+ continue;
+ } // Formatting math operations
+
+
+ const isMathOperator = isMathOperatorNode$1(iNode);
+ const isNextMathOperator = isMathOperatorNode$1(iNextNode); // Print spaces before and after math operators beside SCSS interpolation as is
+ // (i.e. `#{$var}+5`, `#{$var} +5`, `#{$var}+ 5`, `#{$var} + 5`)
+ // (i.e. `5+#{$var}`, `5 +#{$var}`, `5+ #{$var}`, `5 + #{$var}`)
+
+ if ((isMathOperator && isHashNode$1(iNextNode) || isNextMathOperator && isRightCurlyBraceNode$1(iNode)) && hasEmptyRawBefore$1(iNextNode)) {
+ continue;
+ } // Print spaces before and after addition and subtraction math operators as is in `calc` function
+ // due to the fact that it is not valid syntax
+ // (i.e. `calc(1px+1px)`, `calc(1px+ 1px)`, `calc(1px +1px)`, `calc(1px + 1px)`)
+
+
+ if (insideValueFunctionNode$1(path, "calc") && (isAdditionNode$1(iNode) || isAdditionNode$1(iNextNode) || isSubtractionNode$1(iNode) || isSubtractionNode$1(iNextNode)) && hasEmptyRawBefore$1(iNextNode)) {
+ continue;
+ } // Print spaces after `+` and `-` in color adjuster functions as is (e.g. `color(red l(+ 20%))`)
+ // Adjusters with signed numbers (e.g. `color(red l(+20%))`) output as-is.
+
+
+ const isColorAdjusterNode = (isAdditionNode$1(iNode) || isSubtractionNode$1(iNode)) && i === 0 && (iNextNode.type === "value-number" || iNextNode.isHex) && parentParentNode && isColorAdjusterFuncNode$1(parentParentNode) && !hasEmptyRawBefore$1(iNextNode);
+ const requireSpaceBeforeOperator = iNextNextNode && iNextNextNode.type === "value-func" || iNextNextNode && isWordNode$1(iNextNextNode) || iNode.type === "value-func" || isWordNode$1(iNode);
+ const requireSpaceAfterOperator = iNextNode.type === "value-func" || isWordNode$1(iNextNode) || iPrevNode && iPrevNode.type === "value-func" || iPrevNode && isWordNode$1(iPrevNode); // Formatting `/`, `+`, `-` sign
+
+ if (!(isMultiplicationNode$1(iNextNode) || isMultiplicationNode$1(iNode)) && !insideValueFunctionNode$1(path, "calc") && !isColorAdjusterNode && (isDivisionNode$1(iNextNode) && !requireSpaceBeforeOperator || isDivisionNode$1(iNode) && !requireSpaceAfterOperator || isAdditionNode$1(iNextNode) && !requireSpaceBeforeOperator || isAdditionNode$1(iNode) && !requireSpaceAfterOperator || isSubtractionNode$1(iNextNode) || isSubtractionNode$1(iNode)) && (hasEmptyRawBefore$1(iNextNode) || isMathOperator && (!iPrevNode || iPrevNode && isMathOperatorNode$1(iPrevNode)))) {
+ continue;
+ } // Add `hardline` after inline comment (i.e. `// comment\n foo: bar;`)
+
+
+ if (isInlineValueCommentNode$1(iNode)) {
+ parts.push(hardline$7);
+ continue;
+ } // Handle keywords in SCSS control directive
+
+
+ if (isControlDirective && (isEqualityOperatorNode$1(iNextNode) || isRelationalOperatorNode$1(iNextNode) || isIfElseKeywordNode$1(iNextNode) || isEachKeywordNode$1(iNode) || isForKeywordNode$1(iNode))) {
+ parts.push(" ");
+ continue;
+ } // At-rule `namespace` should be in one line
+
+
+ if (atRuleAncestorNode && atRuleAncestorNode.name.toLowerCase() === "namespace") {
+ parts.push(" ");
+ continue;
+ } // Formatting `grid` property
+
+
+ if (isGridValue) {
+ if (iNode.source && iNextNode.source && iNode.source.start.line !== iNextNode.source.start.line) {
+ parts.push(hardline$7);
+ didBreak = true;
+ } else {
+ parts.push(" ");
+ }
+
+ continue;
+ } // Add `space` before next math operation
+ // Note: `grip` property have `/` delimiter and it is not math operation, so
+ // `grid` property handles above
+
+
+ if (isNextMathOperator) {
+ parts.push(" ");
+ continue;
+ } // Be default all values go through `line`
+
+
+ parts.push(line$5);
+ }
+
+ if (didBreak) {
+ parts.unshift(hardline$7);
+ }
+
+ if (isControlDirective) {
+ return group$6(indent$5(concat$9(parts)));
+ } // Indent is not needed for import url when url is very long
+ // and node has two groups
+ // when type is value-comma_group
+ // example @import url("verylongurl") projection,tv
+
+
+ if (insideURLFunctionInImportAtRuleNode$1(path)) {
+ return group$6(fill$4(parts));
+ }
+
+ return group$6(indent$5(fill$4(parts)));
+ }
+
+ case "value-paren_group":
+ {
+ const parentNode = path.getParentNode();
+
+ if (parentNode && isURLFunctionNode$1(parentNode) && (node.groups.length === 1 || node.groups.length > 0 && node.groups[0].type === "value-comma_group" && node.groups[0].groups.length > 0 && node.groups[0].groups[0].type === "value-word" && node.groups[0].groups[0].value.startsWith("data:"))) {
+ return concat$9([node.open ? path.call(print, "open") : "", join$6(",", path.map(print, "groups")), node.close ? path.call(print, "close") : ""]);
+ }
+
+ if (!node.open) {
+ const printed = path.map(print, "groups");
+ const res = [];
+
+ for (let i = 0; i < printed.length; i++) {
+ if (i !== 0) {
+ res.push(concat$9([",", line$5]));
+ }
+
+ res.push(printed[i]);
+ }
+
+ return group$6(indent$5(fill$4(res)));
+ }
+
+ const isSCSSMapItem = isSCSSMapItemNode$1(path);
+ const lastItem = node.groups[node.groups.length - 1];
+ const isLastItemComment = lastItem && lastItem.type === "value-comment";
+ return group$6(concat$9([node.open ? path.call(print, "open") : "", indent$5(concat$9([softline$3, join$6(concat$9([",", line$5]), path.map(childPath => {
+ const node = childPath.getValue();
+ const printed = print(childPath); // Key/Value pair in open paren already indented
+
+ if (isKeyValuePairNode$1(node) && node.type === "value-comma_group" && node.groups && node.groups[2] && node.groups[2].type === "value-paren_group") {
+ printed.contents.contents.parts[1] = group$6(printed.contents.contents.parts[1]);
+ return group$6(dedent$2(printed));
+ }
+
+ return printed;
+ }, "groups"))])), ifBreak$2(!isLastItemComment && isSCSS$1(options.parser, options.originalText) && isSCSSMapItem && shouldPrintComma$1(options) ? "," : ""), softline$3, node.close ? path.call(print, "close") : ""]), {
+ shouldBreak: isSCSSMapItem
+ });
+ }
+
+ case "value-func":
+ {
+ return concat$9([node.value, insideAtRuleNode$1(path, "supports") && isMediaAndSupportsKeywords$1(node) ? " " : "", path.call(print, "group")]);
+ }
+
+ case "value-paren":
+ {
+ return node.value;
+ }
+
+ case "value-number":
+ {
+ return concat$9([printCssNumber(node.value), maybeToLowerCase$1(node.unit)]);
+ }
+
+ case "value-operator":
+ {
+ return node.value;
+ }
+
+ case "value-word":
+ {
+ if (node.isColor && node.isHex || isWideKeywords$1(node.value)) {
+ return node.value.toLowerCase();
+ }
+
+ return node.value;
+ }
+
+ case "value-colon":
+ {
+ return concat$9([node.value, // Don't add spaces on `:` in `url` function (i.e. `url(fbglyph: cross-outline, fig-white)`)
+ insideValueFunctionNode$1(path, "url") ? "" : line$5]);
+ }
+
+ case "value-comma":
+ {
+ return concat$9([node.value, " "]);
+ }
+
+ case "value-string":
+ {
+ return printString$2(node.raws.quote + node.value + node.raws.quote, options);
+ }
+
+ case "value-atword":
+ {
+ return concat$9(["@", node.value]);
+ }
+
+ case "value-unicode-range":
+ {
+ return node.value;
+ }
+
+ case "value-unknown":
+ {
+ return node.value;
+ }
+
+ default:
+ /* istanbul ignore next */
+ throw new Error(`Unknown postcss type ${JSON.stringify(node.type)}`);
+ }
+}
+
+function printNodeSequence(path, options, print) {
+ const node = path.getValue();
+ const parts = [];
+ let i = 0;
+ path.map(pathChild => {
+ const prevNode = node.nodes[i - 1];
+
+ if (prevNode && prevNode.type === "css-comment" && prevNode.text.trim() === "prettier-ignore") {
+ const childNode = pathChild.getValue();
+ parts.push(options.originalText.slice(options.locStart(childNode), options.locEnd(childNode)));
+ } else {
+ parts.push(pathChild.call(print));
+ }
+
+ if (i !== node.nodes.length - 1) {
+ if (node.nodes[i + 1].type === "css-comment" && !hasNewline$5(options.originalText, options.locStart(node.nodes[i + 1]), {
+ backwards: true
+ }) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml" || node.nodes[i + 1].type === "css-atrule" && node.nodes[i + 1].name === "else" && node.nodes[i].type !== "css-comment") {
+ parts.push(" ");
+ } else {
+ parts.push(options.__isHTMLStyleAttribute ? line$5 : hardline$7);
+
+ if (isNextLineEmpty$3(options.originalText, pathChild.getValue(), options.locEnd) && node.nodes[i].type !== "yaml" && node.nodes[i].type !== "toml") {
+ parts.push(hardline$7);
+ }
+ }
+ }
+
+ i++;
+ }, "nodes");
+ return concat$9(parts);
+}
+
+const STRING_REGEX$3 = /(['"])(?:(?!\1)[^\\]|\\[\s\S])*\1/g;
+const NUMBER_REGEX = /(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g;
+const STANDARD_UNIT_REGEX = /[a-zA-Z]+/g;
+const WORD_PART_REGEX = /[$@]?[a-zA-Z_\u0080-\uFFFF][\w\-\u0080-\uFFFF]*/g;
+const ADJUST_NUMBERS_REGEX = new RegExp(STRING_REGEX$3.source + "|" + `(${WORD_PART_REGEX.source})?` + `(${NUMBER_REGEX.source})` + `(${STANDARD_UNIT_REGEX.source})?`, "g");
+
+function adjustStrings(value, options) {
+ return value.replace(STRING_REGEX$3, match => printString$2(match, options));
+}
+
+function quoteAttributeValue(value, options) {
+ const quote = options.singleQuote ? "'" : '"';
+ return value.includes('"') || value.includes("'") ? value : quote + value + quote;
+}
+
+function adjustNumbers(value) {
+ return value.replace(ADJUST_NUMBERS_REGEX, (match, quote, wordPart, number, unit) => !wordPart && number ? printCssNumber(number) + maybeToLowerCase$1(unit || "") : match);
+}
+
+function printCssNumber(rawNumber) {
+ return printNumber$2(rawNumber) // Remove trailing `.0`.
+ .replace(/\.0(?=$|e)/, "");
+}
+
+var printerPostcss = {
+ print: genericPrint$2,
+ embed: embed_1$1,
+ insertPragma: insertPragma$3,
+ hasPrettierIgnore: hasIgnoreComment$3,
+ massageAstNode: clean_1$1
+};
+
+var options$3 = {
+ singleQuote: commonOptions.singleQuote
+};
+
+var name$9 = "CSS";
+var type$7 = "markup";
+var tmScope$7 = "source.css";
+var aceMode$7 = "css";
+var codemirrorMode$7 = "css";
+var codemirrorMimeType$7 = "text/css";
+var color$2 = "#563d7c";
+var extensions$7 = [
+ ".css"
+];
+var languageId$7 = 50;
+var CSS = {
+ name: name$9,
+ type: type$7,
+ tmScope: tmScope$7,
+ aceMode: aceMode$7,
+ codemirrorMode: codemirrorMode$7,
+ codemirrorMimeType: codemirrorMimeType$7,
+ color: color$2,
+ extensions: extensions$7,
+ languageId: languageId$7
+};
+
+var CSS$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$9,
+ type: type$7,
+ tmScope: tmScope$7,
+ aceMode: aceMode$7,
+ codemirrorMode: codemirrorMode$7,
+ codemirrorMimeType: codemirrorMimeType$7,
+ color: color$2,
+ extensions: extensions$7,
+ languageId: languageId$7,
+ 'default': CSS
+});
+
+var name$a = "PostCSS";
+var type$8 = "markup";
+var tmScope$8 = "source.postcss";
+var group$7 = "CSS";
+var extensions$8 = [
+ ".pcss",
+ ".postcss"
+];
+var aceMode$8 = "text";
+var languageId$8 = 262764437;
+var PostCSS = {
+ name: name$a,
+ type: type$8,
+ tmScope: tmScope$8,
+ group: group$7,
+ extensions: extensions$8,
+ aceMode: aceMode$8,
+ languageId: languageId$8
+};
+
+var PostCSS$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$a,
+ type: type$8,
+ tmScope: tmScope$8,
+ group: group$7,
+ extensions: extensions$8,
+ aceMode: aceMode$8,
+ languageId: languageId$8,
+ 'default': PostCSS
+});
+
+var name$b = "Less";
+var type$9 = "markup";
+var group$8 = "CSS";
+var extensions$9 = [
+ ".less"
+];
+var tmScope$9 = "source.css.less";
+var aceMode$9 = "less";
+var codemirrorMode$8 = "css";
+var codemirrorMimeType$8 = "text/css";
+var languageId$9 = 198;
+var Less = {
+ name: name$b,
+ type: type$9,
+ group: group$8,
+ extensions: extensions$9,
+ tmScope: tmScope$9,
+ aceMode: aceMode$9,
+ codemirrorMode: codemirrorMode$8,
+ codemirrorMimeType: codemirrorMimeType$8,
+ languageId: languageId$9
+};
+
+var Less$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$b,
+ type: type$9,
+ group: group$8,
+ extensions: extensions$9,
+ tmScope: tmScope$9,
+ aceMode: aceMode$9,
+ codemirrorMode: codemirrorMode$8,
+ codemirrorMimeType: codemirrorMimeType$8,
+ languageId: languageId$9,
+ 'default': Less
+});
+
+var name$c = "SCSS";
+var type$a = "markup";
+var tmScope$a = "source.css.scss";
+var group$9 = "CSS";
+var aceMode$a = "scss";
+var codemirrorMode$9 = "css";
+var codemirrorMimeType$9 = "text/x-scss";
+var extensions$a = [
+ ".scss"
+];
+var languageId$a = 329;
+var SCSS = {
+ name: name$c,
+ type: type$a,
+ tmScope: tmScope$a,
+ group: group$9,
+ aceMode: aceMode$a,
+ codemirrorMode: codemirrorMode$9,
+ codemirrorMimeType: codemirrorMimeType$9,
+ extensions: extensions$a,
+ languageId: languageId$a
+};
+
+var SCSS$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$c,
+ type: type$a,
+ tmScope: tmScope$a,
+ group: group$9,
+ aceMode: aceMode$a,
+ codemirrorMode: codemirrorMode$9,
+ codemirrorMimeType: codemirrorMimeType$9,
+ extensions: extensions$a,
+ languageId: languageId$a,
+ 'default': SCSS
+});
+
+var require$$0$2 = getCjsExportFromNamespace(CSS$1);
+
+var require$$1$1 = getCjsExportFromNamespace(PostCSS$1);
+
+var require$$2$1 = getCjsExportFromNamespace(Less$1);
+
+var require$$3$1 = getCjsExportFromNamespace(SCSS$1);
+
+const languages$1 = [createLanguage(require$$0$2, () => ({
+ since: "1.4.0",
+ parsers: ["css"],
+ vscodeLanguageIds: ["css"]
+})), createLanguage(require$$1$1, () => ({
+ since: "1.4.0",
+ parsers: ["css"],
+ vscodeLanguageIds: ["postcss"]
+})), createLanguage(require$$2$1, () => ({
+ since: "1.4.0",
+ parsers: ["less"],
+ vscodeLanguageIds: ["less"]
+})), createLanguage(require$$3$1, () => ({
+ since: "1.4.0",
+ parsers: ["scss"],
+ vscodeLanguageIds: ["scss"]
+}))];
+const printers$1 = {
+ postcss: printerPostcss
+};
+var languageCss = {
+ languages: languages$1,
+ options: options$3,
+ printers: printers$1
+};
+
+var clean$3 = function (ast, newNode) {
+ delete newNode.loc;
+ delete newNode.selfClosing; // (Glimmer/HTML) ignore TextNode whitespace
+
+ if (ast.type === "TextNode") {
+ const trimmed = ast.chars.trim();
+
+ if (!trimmed) {
+ return null;
+ }
+
+ newNode.chars = trimmed;
+ }
+};
+
+function isUppercase(string) {
+ return string.toUpperCase() === string;
+}
+
+function isGlimmerComponent(node) {
+ return isNodeOfSomeType(node, ["ElementNode"]) && typeof node.tag === "string" && (isUppercase(node.tag[0]) || node.tag.includes("."));
+}
+
+function isWhitespaceNode(node) {
+ return isNodeOfSomeType(node, ["TextNode"]) && !/\S/.test(node.chars);
+}
+
+function isNodeOfSomeType(node, types) {
+ return node && types.some(type => node.type === type);
+}
+
+function isParentOfSomeType(path, types) {
+ const parentNode = path.getParentNode(0);
+ return isNodeOfSomeType(parentNode, types);
+}
+
+function isPreviousNodeOfSomeType(path, types) {
+ const previousNode = getPreviousNode(path);
+ return isNodeOfSomeType(previousNode, types);
+}
+
+function isNextNodeOfSomeType(path, types) {
+ const nextNode = getNextNode(path);
+ return isNodeOfSomeType(nextNode, types);
+}
+
+function getSiblingNode(path, offset) {
+ const node = path.getValue();
+ const parentNode = path.getParentNode(0) || {};
+ const children = parentNode.children || parentNode.body || [];
+ const index = children.indexOf(node);
+ return index !== -1 && children[index + offset];
+}
+
+function getPreviousNode(path, lookBack = 1) {
+ return getSiblingNode(path, -lookBack);
+}
+
+function getNextNode(path) {
+ return getSiblingNode(path, 1);
+}
+
+function isPrettierIgnoreNode(node) {
+ return isNodeOfSomeType(node, ["MustacheCommentStatement"]) && typeof node.value === "string" && node.value.trim() === "prettier-ignore";
+}
+
+function hasPrettierIgnore$2(path) {
+ const node = path.getValue();
+ const previousPreviousNode = getPreviousNode(path, 2);
+ return isPrettierIgnoreNode(node) || isPrettierIgnoreNode(previousPreviousNode);
+}
+
+var utils$8 = {
+ getNextNode,
+ getPreviousNode,
+ hasPrettierIgnore: hasPrettierIgnore$2,
+ isGlimmerComponent,
+ isNextNodeOfSomeType,
+ isNodeOfSomeType,
+ isParentOfSomeType,
+ isPreviousNodeOfSomeType,
+ isWhitespaceNode
+};
+
+const {
+ concat: concat$a,
+ join: join$7,
+ softline: softline$4,
+ hardline: hardline$8,
+ line: line$6,
+ group: group$a,
+ indent: indent$6,
+ ifBreak: ifBreak$3
+} = document.builders;
+const {
+ getNextNode: getNextNode$1,
+ getPreviousNode: getPreviousNode$1,
+ hasPrettierIgnore: hasPrettierIgnore$3,
+ isGlimmerComponent: isGlimmerComponent$1,
+ isNextNodeOfSomeType: isNextNodeOfSomeType$1,
+ isParentOfSomeType: isParentOfSomeType$1,
+ isPreviousNodeOfSomeType: isPreviousNodeOfSomeType$1,
+ isWhitespaceNode: isWhitespaceNode$1
+} = utils$8; // http://w3c.github.io/html/single-page.html#void-elements
+
+const voidTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]; // Formatter based on @glimmerjs/syntax's built-in test formatter:
+// https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/syntax/lib/generation/print.ts
+
+function print(path, options, print) {
+ const n = path.getValue();
+ /* istanbul ignore if*/
+
+ if (!n) {
+ return "";
+ }
+
+ if (hasPrettierIgnore$3(path)) {
+ const startOffset = locationToOffset(options.originalText, n.loc.start.line - 1, n.loc.start.column);
+ const endOffset = locationToOffset(options.originalText, n.loc.end.line - 1, n.loc.end.column);
+ const ignoredText = options.originalText.slice(startOffset, endOffset);
+ return ignoredText;
+ }
+
+ switch (n.type) {
+ case "Block":
+ case "Program":
+ case "Template":
+ {
+ return group$a(concat$a(path.map(print, "body")));
+ }
+
+ case "ElementNode":
+ {
+ const hasChildren = n.children.length > 0;
+ const hasNonWhitespaceChildren = n.children.some(n => !isWhitespaceNode$1(n));
+ const isVoid = isGlimmerComponent$1(n) && (!hasChildren || !hasNonWhitespaceChildren) || voidTags.includes(n.tag);
+ const closeTagForNoBreak = isVoid ? concat$a([" />", softline$4]) : ">";
+ const closeTagForBreak = isVoid ? "/>" : ">";
+
+ const printParams = (path, print) => indent$6(concat$a([n.attributes.length ? line$6 : "", join$7(line$6, path.map(print, "attributes")), n.modifiers.length ? line$6 : "", join$7(line$6, path.map(print, "modifiers")), n.comments.length ? line$6 : "", join$7(line$6, path.map(print, "comments"))]));
+
+ const nextNode = getNextNode$1(path);
+ return concat$a([group$a(concat$a(["<", n.tag, printParams(path, print), n.blockParams.length ? ` as |${n.blockParams.join(" ")}|` : "", ifBreak$3(softline$4, ""), ifBreak$3(closeTagForBreak, closeTagForNoBreak)])), !isVoid ? group$a(concat$a([hasNonWhitespaceChildren ? indent$6(printChildren(path, options, print)) : "", ifBreak$3(hasChildren ? hardline$8 : "", ""), concat$a(["", n.tag, ">"])])) : "", nextNode && nextNode.type === "ElementNode" ? hardline$8 : ""]);
+ }
+
+ case "BlockStatement":
+ {
+ const pp = path.getParentNode(1);
+ const isElseIf = pp && pp.inverse && pp.inverse.body.length === 1 && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if";
+ const hasElseIf = n.inverse && n.inverse.body.length === 1 && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if";
+ const indentElse = hasElseIf ? a => a : indent$6;
+ const inverseElseStatement = (n.inverseStrip.open ? "{{~" : "{{") + "else" + (n.inverseStrip.close ? "~}}" : "}}");
+
+ if (n.inverse) {
+ return concat$a([isElseIf ? concat$a([n.openStrip.open ? "{{~else " : "{{else ", printPathParams(path, print), n.openStrip.close ? "~}}" : "}}"]) : printOpenBlock(path, print, n.openStrip), indent$6(concat$a([hardline$8, path.call(print, "program")])), n.inverse && !hasElseIf ? concat$a([hardline$8, inverseElseStatement]) : "", n.inverse ? indentElse(concat$a([hardline$8, path.call(print, "inverse")])) : "", isElseIf ? "" : concat$a([hardline$8, printCloseBlock(path, print, n.closeStrip)])]);
+ } else if (isElseIf) {
+ return concat$a([concat$a([n.openStrip.open ? "{{~else" : "{{else ", printPathParams(path, print), n.openStrip.close ? "~}}" : "}}"]), indent$6(concat$a([hardline$8, path.call(print, "program")]))]);
+ }
+
+ const hasNonWhitespaceChildren = n.program.body.some(n => !isWhitespaceNode$1(n));
+ return concat$a([printOpenBlock(path, print, n.openStrip), group$a(concat$a([indent$6(concat$a([softline$4, path.call(print, "program")])), hasNonWhitespaceChildren ? hardline$8 : softline$4, printCloseBlock(path, print, n.closeStrip)]))]);
+ }
+
+ case "ElementModifierStatement":
+ {
+ return group$a(concat$a(["{{", printPathParams(path, print), softline$4, "}}"]));
+ }
+
+ case "MustacheStatement":
+ {
+ const isEscaped = n.escaped === false;
+ const {
+ open: openStrip,
+ close: closeStrip
+ } = n.strip;
+ const opening = (isEscaped ? "{{{" : "{{") + (openStrip ? "~" : "");
+ const closing = (closeStrip ? "~" : "") + (isEscaped ? "}}}" : "}}");
+ const leading = isParentOfSomeType$1(path, ["AttrNode", "ConcatStatement", "ElementNode"]) ? [opening, indent$6(softline$4)] : [opening];
+ return group$a(concat$a([...leading, printPathParams(path, print), softline$4, closing]));
+ }
+
+ case "SubExpression":
+ {
+ const params = printParams(path, print);
+ const printedParams = params.length > 0 ? indent$6(concat$a([line$6, group$a(join$7(line$6, params))])) : "";
+ return group$a(concat$a(["(", printPath(path, print), printedParams, softline$4, ")"]));
+ }
+
+ case "AttrNode":
+ {
+ const isText = n.value.type === "TextNode";
+ const isEmptyText = isText && n.value.chars === ""; // If the text is empty and the value's loc start and end columns are the
+ // same, there is no value for this AttrNode and it should be printed
+ // without the `=""`. Example: `` -> ``
+
+ const isEmptyValue = isEmptyText && n.value.loc.start.column === n.value.loc.end.column;
+
+ if (isEmptyValue) {
+ return concat$a([n.name]);
+ }
+
+ const value = path.call(print, "value");
+ const quotedValue = isText ? printStringLiteral(value.parts.join(), options) : value;
+ return concat$a([n.name, "=", quotedValue]);
+ }
+
+ case "ConcatStatement":
+ {
+ return concat$a(['"', concat$a(path.map(partPath => print(partPath), "parts").filter(a => a !== "")), '"']);
+ }
+
+ case "Hash":
+ {
+ return concat$a([join$7(line$6, path.map(print, "pairs"))]);
+ }
+
+ case "HashPair":
+ {
+ return concat$a([n.key, "=", path.call(print, "value")]);
+ }
+
+ case "TextNode":
+ {
+ const maxLineBreaksToPreserve = 2;
+ const isFirstElement = !getPreviousNode$1(path);
+ const isLastElement = !getNextNode$1(path);
+ const isWhitespaceOnly = !/\S/.test(n.chars);
+ const lineBreaksCount = countNewLines(n.chars);
+ const hasBlockParent = path.getParentNode(0).type === "Block";
+ const hasElementParent = path.getParentNode(0).type === "ElementNode";
+ const hasTemplateParent = path.getParentNode(0).type === "Template";
+ let leadingLineBreaksCount = countLeadingNewLines(n.chars);
+ let trailingLineBreaksCount = countTrailingNewLines(n.chars);
+
+ if ((isFirstElement || isLastElement) && isWhitespaceOnly && (hasBlockParent || hasElementParent || hasTemplateParent)) {
+ return "";
+ }
+
+ if (isWhitespaceOnly && lineBreaksCount) {
+ leadingLineBreaksCount = Math.min(lineBreaksCount, maxLineBreaksToPreserve);
+ trailingLineBreaksCount = 0;
+ } else {
+ if (isNextNodeOfSomeType$1(path, ["BlockStatement", "ElementNode"])) {
+ trailingLineBreaksCount = Math.max(trailingLineBreaksCount, 1);
+ }
+
+ if (isPreviousNodeOfSomeType$1(path, ["ElementNode"]) || isPreviousNodeOfSomeType$1(path, ["BlockStatement"])) {
+ leadingLineBreaksCount = Math.max(leadingLineBreaksCount, 1);
+ }
+ }
+
+ let leadingSpace = "";
+ let trailingSpace = ""; // preserve a space inside of an attribute node where whitespace present,
+ // when next to mustache statement.
+
+ const inAttrNode = path.stack.includes("attributes");
+
+ if (inAttrNode) {
+ const parentNode = path.getParentNode(0);
+ const isConcat = parentNode.type === "ConcatStatement";
+
+ if (isConcat) {
+ const {
+ parts
+ } = parentNode;
+ const partIndex = parts.indexOf(n);
+
+ if (partIndex > 0) {
+ const partType = parts[partIndex - 1].type;
+ const isMustache = partType === "MustacheStatement";
+
+ if (isMustache) {
+ leadingSpace = " ";
+ }
+ }
+
+ if (partIndex < parts.length - 1) {
+ const partType = parts[partIndex + 1].type;
+ const isMustache = partType === "MustacheStatement";
+
+ if (isMustache) {
+ trailingSpace = " ";
+ }
+ }
+ }
+ } else {
+ if (trailingLineBreaksCount === 0 && isNextNodeOfSomeType$1(path, ["MustacheStatement"])) {
+ trailingSpace = " ";
+ }
+
+ if (leadingLineBreaksCount === 0 && isPreviousNodeOfSomeType$1(path, ["MustacheStatement"])) {
+ leadingSpace = " ";
+ }
+
+ if (isFirstElement) {
+ leadingLineBreaksCount = 0;
+ leadingSpace = "";
+ }
+
+ if (isLastElement) {
+ trailingLineBreaksCount = 0;
+ trailingSpace = "";
+ }
+ }
+
+ return concat$a([...generateHardlines(leadingLineBreaksCount, maxLineBreaksToPreserve), n.chars.replace(/^[\s ]+/g, leadingSpace).replace(/[\s ]+$/, trailingSpace), ...generateHardlines(trailingLineBreaksCount, maxLineBreaksToPreserve)].filter(Boolean));
+ }
+
+ case "MustacheCommentStatement":
+ {
+ const dashes = n.value.includes("}}") ? "--" : "";
+ return concat$a(["{{!", dashes, n.value, dashes, "}}"]);
+ }
+
+ case "PathExpression":
+ {
+ return n.original;
+ }
+
+ case "BooleanLiteral":
+ {
+ return String(n.value);
+ }
+
+ case "CommentStatement":
+ {
+ return concat$a([""]);
+ }
+
+ case "StringLiteral":
+ {
+ return printStringLiteral(n.value, options);
+ }
+
+ case "NumberLiteral":
+ {
+ return String(n.value);
+ }
+
+ case "UndefinedLiteral":
+ {
+ return "undefined";
+ }
+
+ case "NullLiteral":
+ {
+ return "null";
+ }
+
+ /* istanbul ignore next */
+
+ default:
+ throw new Error("unknown glimmer type: " + JSON.stringify(n.type));
+ }
+}
+
+function printChildren(path, options, print) {
+ return concat$a(path.map((childPath, childIndex) => {
+ const childNode = path.getValue();
+ const isFirstNode = childIndex === 0;
+ const isLastNode = childIndex === path.getParentNode(0).children.length - 1;
+ const isLastNodeInMultiNodeList = isLastNode && !isFirstNode;
+ const isWhitespace = isWhitespaceNode$1(childNode);
+
+ if (isWhitespace && isLastNodeInMultiNodeList) {
+ return print(childPath, options, print);
+ } else if (isFirstNode) {
+ return concat$a([softline$4, print(childPath, options, print)]);
+ }
+
+ return print(childPath, options, print);
+ }, "children"));
+}
+/**
+ * Prints a string literal with the correct surrounding quotes based on
+ * `options.singleQuote` and the number of escaped quotes contained in
+ * the string literal. This function is the glimmer equivalent of `printString`
+ * in `common/util`, but has differences because of the way escaped characters
+ * are treated in hbs string literals.
+ * @param {string} stringLiteral - the string literal value
+ * @param {object} options - the prettier options object
+ */
+
+
+function printStringLiteral(stringLiteral, options) {
+ const double = {
+ quote: '"',
+ regex: /"/g
+ };
+ const single = {
+ quote: "'",
+ regex: /'/g
+ };
+ const preferred = options.singleQuote ? single : double;
+ const alternate = preferred === single ? double : single;
+ let shouldUseAlternateQuote = false; // If `stringLiteral` contains at least one of the quote preferred for
+ // enclosing the string, we might want to enclose with the alternate quote
+ // instead, to minimize the number of escaped quotes.
+
+ if (stringLiteral.includes(preferred.quote) || stringLiteral.includes(alternate.quote)) {
+ const numPreferredQuotes = (stringLiteral.match(preferred.regex) || []).length;
+ const numAlternateQuotes = (stringLiteral.match(alternate.regex) || []).length;
+ shouldUseAlternateQuote = numPreferredQuotes > numAlternateQuotes;
+ }
+
+ const enclosingQuote = shouldUseAlternateQuote ? alternate : preferred;
+ const escapedStringLiteral = stringLiteral.replace(enclosingQuote.regex, `\\${enclosingQuote.quote}`);
+ return concat$a([enclosingQuote.quote, escapedStringLiteral, enclosingQuote.quote]);
+}
+
+function printPath(path, print) {
+ return path.call(print, "path");
+}
+
+function printParams(path, print) {
+ const node = path.getValue();
+ let parts = [];
+
+ if (node.params.length > 0) {
+ parts = parts.concat(path.map(print, "params"));
+ }
+
+ if (node.hash && node.hash.pairs.length > 0) {
+ parts.push(path.call(print, "hash"));
+ }
+
+ return parts;
+}
+
+function printPathParams(path, print) {
+ const printedPath = printPath(path, print);
+ const printedParams = printParams(path, print);
+ const parts = [printedPath, ...printedParams];
+ return indent$6(group$a(join$7(line$6, parts)));
+}
+
+function printBlockParams(path) {
+ const block = path.getValue();
+
+ if (!block.program || !block.program.blockParams.length) {
+ return "";
+ }
+
+ return concat$a([" as |", block.program.blockParams.join(" "), "|"]);
+}
+
+function printOpenBlock(path, print, {
+ open: isOpenStrip = false,
+ close: isCloseStrip = false
+} = {}) {
+ return group$a(concat$a([isOpenStrip ? "{{~#" : "{{#", printPathParams(path, print), printBlockParams(path), softline$4, isCloseStrip ? "~}}" : "}}"]));
+}
+
+function printCloseBlock(path, print, {
+ open: isOpenStrip = false,
+ close: isCloseStrip = false
+} = {}) {
+ return concat$a([isOpenStrip ? "{{~/" : "{{/", path.call(print, "path"), isCloseStrip ? "~}}" : "}}"]);
+}
+
+function countNewLines(string) {
+ /* istanbul ignore next */
+ string = typeof string === "string" ? string : "";
+ return string.split("\n").length - 1;
+}
+
+function countLeadingNewLines(string) {
+ /* istanbul ignore next */
+ string = typeof string === "string" ? string : "";
+ const newLines = (string.match(/^([^\S\r\n]*[\r\n])+/g) || [])[0] || "";
+ return countNewLines(newLines);
+}
+
+function countTrailingNewLines(string) {
+ /* istanbul ignore next */
+ string = typeof string === "string" ? string : "";
+ const newLines = (string.match(/([\r\n][^\S\r\n]*)+$/g) || [])[0] || "";
+ return countNewLines(newLines);
+}
+
+function generateHardlines(number = 0, max = 0) {
+ return new Array(Math.min(number, max)).fill(hardline$8);
+}
+/* istanbul ignore next
+ https://github.com/glimmerjs/glimmer-vm/blob/master/packages/%40glimmer/compiler/lib/location.ts#L5-L29
+*/
+
+
+function locationToOffset(source, line, column) {
+ let seenLines = 0;
+ let seenChars = 0; // eslint-disable-next-line no-constant-condition
+
+ while (true) {
+ if (seenChars === source.length) {
+ return null;
+ }
+
+ let nextLine = source.indexOf("\n", seenChars);
+
+ if (nextLine === -1) {
+ nextLine = source.length;
+ }
+
+ if (seenLines === line) {
+ if (seenChars + column > nextLine) {
+ return null;
+ }
+
+ return seenChars + column;
+ } else if (nextLine === -1) {
+ return null;
+ }
+
+ seenLines += 1;
+ seenChars = nextLine + 1;
+ }
+}
+
+var printerGlimmer = {
+ print,
+ massageAstNode: clean$3
+};
+
+var name$d = "Handlebars";
+var type$b = "markup";
+var group$b = "HTML";
+var aliases$3 = [
+ "hbs",
+ "htmlbars"
+];
+var extensions$b = [
+ ".handlebars",
+ ".hbs"
+];
+var tmScope$b = "text.html.handlebars";
+var aceMode$b = "handlebars";
+var languageId$b = 155;
+var Handlebars = {
+ name: name$d,
+ type: type$b,
+ group: group$b,
+ aliases: aliases$3,
+ extensions: extensions$b,
+ tmScope: tmScope$b,
+ aceMode: aceMode$b,
+ languageId: languageId$b
+};
+
+var Handlebars$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$d,
+ type: type$b,
+ group: group$b,
+ aliases: aliases$3,
+ extensions: extensions$b,
+ tmScope: tmScope$b,
+ aceMode: aceMode$b,
+ languageId: languageId$b,
+ 'default': Handlebars
+});
+
+var require$$0$3 = getCjsExportFromNamespace(Handlebars$1);
+
+const languages$2 = [createLanguage(require$$0$3, () => ({
+ since: null,
+ // unreleased
+ parsers: ["glimmer"],
+ vscodeLanguageIds: ["handlebars"]
+}))];
+const printers$2 = {
+ glimmer: printerGlimmer
+};
+var languageHandlebars = {
+ languages: languages$2,
+ printers: printers$2
+};
+
+function hasPragma$2(text) {
+ return /^\s*#[^\n\S]*@(format|prettier)\s*(\n|$)/.test(text);
+}
+
+function insertPragma$4(text) {
+ return "# @format\n\n" + text;
+}
+
+var pragma$2 = {
+ hasPragma: hasPragma$2,
+ insertPragma: insertPragma$4
+};
+
+const {
+ concat: concat$b,
+ join: join$8,
+ hardline: hardline$9,
+ line: line$7,
+ softline: softline$5,
+ group: group$c,
+ indent: indent$7,
+ ifBreak: ifBreak$4
+} = document.builders;
+const {
+ hasIgnoreComment: hasIgnoreComment$4
+} = util$1;
+const {
+ isNextLineEmpty: isNextLineEmpty$4
+} = utilShared;
+const {
+ insertPragma: insertPragma$5
+} = pragma$2;
+
+function genericPrint$3(path, options, print) {
+ const n = path.getValue();
+
+ if (!n) {
+ return "";
+ }
+
+ if (typeof n === "string") {
+ return n;
+ }
+
+ switch (n.kind) {
+ case "Document":
+ {
+ const parts = [];
+ path.map((pathChild, index) => {
+ parts.push(concat$b([pathChild.call(print)]));
+
+ if (index !== n.definitions.length - 1) {
+ parts.push(hardline$9);
+
+ if (isNextLineEmpty$4(options.originalText, pathChild.getValue(), options.locEnd)) {
+ parts.push(hardline$9);
+ }
+ }
+ }, "definitions");
+ return concat$b([concat$b(parts), hardline$9]);
+ }
+
+ case "OperationDefinition":
+ {
+ const hasOperation = options.originalText[options.locStart(n)] !== "{";
+ const hasName = !!n.name;
+ return concat$b([hasOperation ? n.operation : "", hasOperation && hasName ? concat$b([" ", path.call(print, "name")]) : "", n.variableDefinitions && n.variableDefinitions.length ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? !hasOperation && !hasName ? "" : " " : "", path.call(print, "selectionSet")]);
+ }
+
+ case "FragmentDefinition":
+ {
+ return concat$b(["fragment ", path.call(print, "name"), n.variableDefinitions && n.variableDefinitions.length ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "variableDefinitions"))])), softline$5, ")"])) : "", " on ", path.call(print, "typeCondition"), printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
+ }
+
+ case "SelectionSet":
+ {
+ return concat$b(["{", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(selectionsPath => printSequence(selectionsPath, options, print), "selections"))])), hardline$9, "}"]);
+ }
+
+ case "Field":
+ {
+ return group$c(concat$b([n.alias ? concat$b([path.call(print, "alias"), ": "]) : "", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : "", printDirectives(path, print, n), n.selectionSet ? " " : "", path.call(print, "selectionSet")]));
+ }
+
+ case "Name":
+ {
+ return n.value;
+ }
+
+ case "StringValue":
+ {
+ if (n.block) {
+ return concat$b(['"""', hardline$9, join$8(hardline$9, n.value.replace(/"""/g, "\\$&").split("\n")), hardline$9, '"""']);
+ }
+
+ return concat$b(['"', n.value.replace(/["\\]/g, "\\$&").replace(/\n/g, "\\n"), '"']);
+ }
+
+ case "IntValue":
+ case "FloatValue":
+ case "EnumValue":
+ {
+ return n.value;
+ }
+
+ case "BooleanValue":
+ {
+ return n.value ? "true" : "false";
+ }
+
+ case "NullValue":
+ {
+ return "null";
+ }
+
+ case "Variable":
+ {
+ return concat$b(["$", path.call(print, "name")]);
+ }
+
+ case "ListValue":
+ {
+ return group$c(concat$b(["[", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "values"))])), softline$5, "]"]));
+ }
+
+ case "ObjectValue":
+ {
+ return group$c(concat$b(["{", options.bracketSpacing && n.fields.length > 0 ? " " : "", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.map(print, "fields"))])), softline$5, ifBreak$4("", options.bracketSpacing && n.fields.length > 0 ? " " : ""), "}"]));
+ }
+
+ case "ObjectField":
+ case "Argument":
+ {
+ return concat$b([path.call(print, "name"), ": ", path.call(print, "value")]);
+ }
+
+ case "Directive":
+ {
+ return concat$b(["@", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : ""]);
+ }
+
+ case "NamedType":
+ {
+ return path.call(print, "name");
+ }
+
+ case "VariableDefinition":
+ {
+ return concat$b([path.call(print, "variable"), ": ", path.call(print, "type"), n.defaultValue ? concat$b([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
+ }
+
+ case "TypeExtensionDefinition":
+ {
+ return concat$b(["extend ", path.call(print, "definition")]);
+ }
+
+ case "ObjectTypeExtension":
+ case "ObjectTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ObjectTypeExtension" ? "extend " : "", "type ", path.call(print, "name"), n.interfaces.length > 0 ? concat$b([" implements ", concat$b(printInterfaces(path, options, print))]) : "", printDirectives(path, print, n), n.fields.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))])), hardline$9, "}"]) : ""]);
+ }
+
+ case "FieldDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : "", ": ", path.call(print, "type"), printDirectives(path, print, n)]);
+ }
+
+ case "DirectiveDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", "directive ", "@", path.call(print, "name"), n.arguments.length > 0 ? group$c(concat$b(["(", indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", ", "), softline$5]), path.call(argsPath => printSequence(argsPath, options, print), "arguments"))])), softline$5, ")"])) : "", n.repeatable ? " repeatable" : "", concat$b([" on ", join$8(" | ", path.map(print, "locations"))])]);
+ }
+
+ case "EnumTypeExtension":
+ case "EnumTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "EnumTypeExtension" ? "extend " : "", "enum ", path.call(print, "name"), printDirectives(path, print, n), n.values.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(valuesPath => printSequence(valuesPath, options, print), "values"))])), hardline$9, "}"]) : ""]);
+ }
+
+ case "EnumValueDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", path.call(print, "name"), printDirectives(path, print, n)]);
+ }
+
+ case "InputValueDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? n.description.block ? hardline$9 : line$7 : "", path.call(print, "name"), ": ", path.call(print, "type"), n.defaultValue ? concat$b([" = ", path.call(print, "defaultValue")]) : "", printDirectives(path, print, n)]);
+ }
+
+ case "InputObjectTypeExtension":
+ case "InputObjectTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InputObjectTypeExtension" ? "extend " : "", "input ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))])), hardline$9, "}"]) : ""]);
+ }
+
+ case "SchemaDefinition":
+ {
+ return concat$b(["schema", printDirectives(path, print, n), " {", n.operationTypes.length > 0 ? indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(opsPath => printSequence(opsPath, options, print), "operationTypes"))])) : "", hardline$9, "}"]);
+ }
+
+ case "OperationTypeDefinition":
+ {
+ return concat$b([path.call(print, "operation"), ": ", path.call(print, "type")]);
+ }
+
+ case "InterfaceTypeExtension":
+ case "InterfaceTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "InterfaceTypeExtension" ? "extend " : "", "interface ", path.call(print, "name"), printDirectives(path, print, n), n.fields.length > 0 ? concat$b([" {", indent$7(concat$b([hardline$9, join$8(hardline$9, path.call(fieldsPath => printSequence(fieldsPath, options, print), "fields"))])), hardline$9, "}"]) : ""]);
+ }
+
+ case "FragmentSpread":
+ {
+ return concat$b(["...", path.call(print, "name"), printDirectives(path, print, n)]);
+ }
+
+ case "InlineFragment":
+ {
+ return concat$b(["...", n.typeCondition ? concat$b([" on ", path.call(print, "typeCondition")]) : "", printDirectives(path, print, n), " ", path.call(print, "selectionSet")]);
+ }
+
+ case "UnionTypeExtension":
+ case "UnionTypeDefinition":
+ {
+ return group$c(concat$b([path.call(print, "description"), n.description ? hardline$9 : "", group$c(concat$b([n.kind === "UnionTypeExtension" ? "extend " : "", "union ", path.call(print, "name"), printDirectives(path, print, n), n.types.length > 0 ? concat$b([" =", ifBreak$4("", " "), indent$7(concat$b([ifBreak$4(concat$b([line$7, " "])), join$8(concat$b([line$7, "| "]), path.map(print, "types"))]))]) : ""]))]));
+ }
+
+ case "ScalarTypeExtension":
+ case "ScalarTypeDefinition":
+ {
+ return concat$b([path.call(print, "description"), n.description ? hardline$9 : "", n.kind === "ScalarTypeExtension" ? "extend " : "", "scalar ", path.call(print, "name"), printDirectives(path, print, n)]);
+ }
+
+ case "NonNullType":
+ {
+ return concat$b([path.call(print, "type"), "!"]);
+ }
+
+ case "ListType":
+ {
+ return concat$b(["[", path.call(print, "type"), "]"]);
+ }
+
+ default:
+ /* istanbul ignore next */
+ throw new Error("unknown graphql type: " + JSON.stringify(n.kind));
+ }
+}
+
+function printDirectives(path, print, n) {
+ if (n.directives.length === 0) {
+ return "";
+ }
+
+ return concat$b([" ", group$c(indent$7(concat$b([softline$5, join$8(concat$b([ifBreak$4("", " "), softline$5]), path.map(print, "directives"))])))]);
+}
+
+function printSequence(sequencePath, options, print) {
+ const count = sequencePath.getValue().length;
+ return sequencePath.map((path, i) => {
+ const printed = print(path);
+
+ if (isNextLineEmpty$4(options.originalText, path.getValue(), options.locEnd) && i < count - 1) {
+ return concat$b([printed, hardline$9]);
+ }
+
+ return printed;
+ });
+}
+
+function canAttachComment$1(node) {
+ return node.kind && node.kind !== "Comment";
+}
+
+function printComment$2(commentPath) {
+ const comment = commentPath.getValue();
+
+ if (comment.kind === "Comment") {
+ return "#" + comment.value.trimEnd();
+ }
+
+ throw new Error("Not a comment: " + JSON.stringify(comment));
+}
+
+function determineInterfaceSeparatorBetween(first, second, options) {
+ const textBetween = options.originalText.slice(first.loc.end, second.loc.start).replace(/#.*/g, "").trim();
+ return textBetween === "," ? ", " : " & ";
+}
+
+function printInterfaces(path, options, print) {
+ const node = path.getNode();
+ const parts = [];
+ const {
+ interfaces
+ } = node;
+ const printed = path.map(node => print(node), "interfaces");
+
+ for (let index = 0; index < interfaces.length; index++) {
+ const interfaceNode = interfaces[index];
+
+ if (index > 0) {
+ parts.push(determineInterfaceSeparatorBetween(interfaces[index - 1], interfaceNode, options));
+ }
+
+ parts.push(printed[index]);
+ }
+
+ return parts;
+}
+
+function clean$4(node, newNode
+/*, parent*/
+) {
+ delete newNode.loc;
+ delete newNode.comments;
+}
+
+var printerGraphql = {
+ print: genericPrint$3,
+ massageAstNode: clean$4,
+ hasPrettierIgnore: hasIgnoreComment$4,
+ insertPragma: insertPragma$5,
+ printComment: printComment$2,
+ canAttachComment: canAttachComment$1
+};
+
+var options$4 = {
+ bracketSpacing: commonOptions.bracketSpacing
+};
+
+var name$e = "GraphQL";
+var type$c = "data";
+var extensions$c = [
+ ".graphql",
+ ".gql",
+ ".graphqls"
+];
+var tmScope$c = "source.graphql";
+var aceMode$c = "text";
+var languageId$c = 139;
+var GraphQL = {
+ name: name$e,
+ type: type$c,
+ extensions: extensions$c,
+ tmScope: tmScope$c,
+ aceMode: aceMode$c,
+ languageId: languageId$c
+};
+
+var GraphQL$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$e,
+ type: type$c,
+ extensions: extensions$c,
+ tmScope: tmScope$c,
+ aceMode: aceMode$c,
+ languageId: languageId$c,
+ 'default': GraphQL
+});
+
+var require$$0$4 = getCjsExportFromNamespace(GraphQL$1);
+
+const languages$3 = [createLanguage(require$$0$4, () => ({
+ since: "1.5.0",
+ parsers: ["graphql"],
+ vscodeLanguageIds: ["graphql"]
+}))];
+const printers$3 = {
+ graphql: printerGraphql
+};
+var languageGraphql = {
+ languages: languages$3,
+ options: options$4,
+ printers: printers$3
+};
+
+var json = {
+ "cjkPattern": "[\\u02ea-\\u02eb\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u3099-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fef\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufe10-\\ufe1f\\ufe30-\\ufe6f\\uff00-\\uffef]|[\\ud840-\\ud868\\ud86a-\\ud86c\\ud86f-\\ud872\\ud874-\\ud879][\\udc00-\\udfff]|\\ud82c[\\udc00-\\udd1e\\udd50-\\udd52\\udd64-\\udd67]|\\ud83c[\\ude00\\ude50-\\ude51]|\\ud869[\\udc00-\\uded6\\udf00-\\udfff]|\\ud86d[\\udc00-\\udf34\\udf40-\\udfff]|\\ud86e[\\udc00-\\udc1d\\udc20-\\udfff]|\\ud873[\\udc00-\\udea1\\udeb0-\\udfff]|\\ud87a[\\udc00-\\udfe0]|\\ud87e[\\udc00-\\ude1d]",
+ "kPattern": "[\\u1100-\\u11ff\\u3001-\\u3003\\u3008-\\u3011\\u3013-\\u301f\\u302e-\\u3030\\u3037\\u30fb\\u3131-\\u318e\\u3200-\\u321e\\u3260-\\u327e\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\ufe45-\\ufe46\\uff61-\\uff65\\uffa0-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc]",
+ "punctuationPattern": "[\\u0021-\\u002f\\u003a-\\u0040\\u005b-\\u0060\\u007b-\\u007e\\u00a1\\u00a7\\u00ab\\u00b6-\\u00b7\\u00bb\\u00bf\\u037e\\u0387\\u055a-\\u055f\\u0589-\\u058a\\u05be\\u05c0\\u05c3\\u05c6\\u05f3-\\u05f4\\u0609-\\u060a\\u060c-\\u060d\\u061b\\u061e-\\u061f\\u066a-\\u066d\\u06d4\\u0700-\\u070d\\u07f7-\\u07f9\\u0830-\\u083e\\u085e\\u0964-\\u0965\\u0970\\u09fd\\u0a76\\u0af0\\u0c77\\u0c84\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166e\\u169b-\\u169c\\u16eb-\\u16ed\\u1735-\\u1736\\u17d4-\\u17d6\\u17d8-\\u17da\\u1800-\\u180a\\u1944-\\u1945\\u1a1e-\\u1a1f\\u1aa0-\\u1aa6\\u1aa8-\\u1aad\\u1b5a-\\u1b60\\u1bfc-\\u1bff\\u1c3b-\\u1c3f\\u1c7e-\\u1c7f\\u1cc0-\\u1cc7\\u1cd3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205e\\u207d-\\u207e\\u208d-\\u208e\\u2308-\\u230b\\u2329-\\u232a\\u2768-\\u2775\\u27c5-\\u27c6\\u27e6-\\u27ef\\u2983-\\u2998\\u29d8-\\u29db\\u29fc-\\u29fd\\u2cf9-\\u2cfc\\u2cfe-\\u2cff\\u2d70\\u2e00-\\u2e2e\\u2e30-\\u2e4f\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301f\\u3030\\u303d\\u30a0\\u30fb\\ua4fe-\\ua4ff\\ua60d-\\ua60f\\ua673\\ua67e\\ua6f2-\\ua6f7\\ua874-\\ua877\\ua8ce-\\ua8cf\\ua8f8-\\ua8fa\\ua8fc\\ua92e-\\ua92f\\ua95f\\ua9c1-\\ua9cd\\ua9de-\\ua9df\\uaa5c-\\uaa5f\\uaade-\\uaadf\\uaaf0-\\uaaf1\\uabeb\\ufd3e-\\ufd3f\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe61\\ufe63\\ufe68\\ufe6a-\\ufe6b\\uff01-\\uff03\\uff05-\\uff0a\\uff0c-\\uff0f\\uff1a-\\uff1b\\uff1f-\\uff20\\uff3b-\\uff3d\\uff3f\\uff5b\\uff5d\\uff5f-\\uff65]|\\ud800[\\udd00-\\udd02\\udf9f\\udfd0]|\\ud801[\\udd6f]|\\ud802[\\udc57\\udd1f\\udd3f\\ude50-\\ude58\\ude7f\\udef0-\\udef6\\udf39-\\udf3f\\udf99-\\udf9c]|\\ud803[\\udf55-\\udf59]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc8\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\udc3b\\udde2\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71\\udef7-\\udef8\\udfff]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud81b[\\ude97-\\ude9a\\udfe2]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"
+};
+
+const {
+ cjkPattern,
+ kPattern,
+ punctuationPattern
+} = json;
+const {
+ getLast: getLast$4
+} = util$1;
+const INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
+const INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]);
+const kRegex = new RegExp(kPattern);
+const punctuationRegex = new RegExp(punctuationPattern);
+/**
+ * split text into whitespaces and words
+ * @param {string} text
+ * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
+ */
+
+function splitText(text, options) {
+ const KIND_NON_CJK = "non-cjk";
+ const KIND_CJ_LETTER = "cj-letter";
+ const KIND_K_LETTER = "k-letter";
+ const KIND_CJK_PUNCTUATION = "cjk-punctuation";
+ const nodes = [];
+ (options.proseWrap === "preserve" ? text : text.replace(new RegExp(`(${cjkPattern})\n(${cjkPattern})`, "g"), "$1$2")).split(/([ \t\n]+)/).forEach((token, index, tokens) => {
+ // whitespace
+ if (index % 2 === 1) {
+ nodes.push({
+ type: "whitespace",
+ value: /\n/.test(token) ? "\n" : " "
+ });
+ return;
+ } // word separated by whitespace
+
+
+ if ((index === 0 || index === tokens.length - 1) && token === "") {
+ return;
+ }
+
+ token.split(new RegExp(`(${cjkPattern})`)).forEach((innerToken, innerIndex, innerTokens) => {
+ if ((innerIndex === 0 || innerIndex === innerTokens.length - 1) && innerToken === "") {
+ return;
+ } // non-CJK word
+
+
+ if (innerIndex % 2 === 0) {
+ if (innerToken !== "") {
+ appendNode({
+ type: "word",
+ value: innerToken,
+ kind: KIND_NON_CJK,
+ hasLeadingPunctuation: punctuationRegex.test(innerToken[0]),
+ hasTrailingPunctuation: punctuationRegex.test(getLast$4(innerToken))
+ });
+ }
+
+ return;
+ } // CJK character
+
+
+ appendNode(punctuationRegex.test(innerToken) ? {
+ type: "word",
+ value: innerToken,
+ kind: KIND_CJK_PUNCTUATION,
+ hasLeadingPunctuation: true,
+ hasTrailingPunctuation: true
+ } : {
+ type: "word",
+ value: innerToken,
+ kind: kRegex.test(innerToken) ? KIND_K_LETTER : KIND_CJ_LETTER,
+ hasLeadingPunctuation: false,
+ hasTrailingPunctuation: false
+ });
+ });
+ });
+ return nodes;
+
+ function appendNode(node) {
+ const lastNode = getLast$4(nodes);
+
+ if (lastNode && lastNode.type === "word") {
+ if (lastNode.kind === KIND_NON_CJK && node.kind === KIND_CJ_LETTER && !lastNode.hasTrailingPunctuation || lastNode.kind === KIND_CJ_LETTER && node.kind === KIND_NON_CJK && !node.hasLeadingPunctuation) {
+ nodes.push({
+ type: "whitespace",
+ value: " "
+ });
+ } else if (!isBetween(KIND_NON_CJK, KIND_CJK_PUNCTUATION) && // disallow leading/trailing full-width whitespace
+ ![lastNode.value, node.value].some(value => /\u3000/.test(value))) {
+ nodes.push({
+ type: "whitespace",
+ value: ""
+ });
+ }
+ }
+
+ nodes.push(node);
+
+ function isBetween(kind1, kind2) {
+ return lastNode.kind === kind1 && node.kind === kind2 || lastNode.kind === kind2 && node.kind === kind1;
+ }
+ }
+}
+
+function getOrderedListItemInfo(orderListItem, originalText) {
+ const [, numberText, marker, leadingSpaces] = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/);
+ return {
+ numberText,
+ marker,
+ leadingSpaces
+ };
+}
+
+function hasGitDiffFriendlyOrderedList(node, options) {
+ if (!node.ordered) {
+ return false;
+ }
+
+ if (node.children.length < 2) {
+ return false;
+ }
+
+ const firstNumber = Number(getOrderedListItemInfo(node.children[0], options.originalText).numberText);
+ const secondNumber = Number(getOrderedListItemInfo(node.children[1], options.originalText).numberText);
+
+ if (firstNumber === 0 && node.children.length > 2) {
+ const thirdNumber = Number(getOrderedListItemInfo(node.children[2], options.originalText).numberText);
+ return secondNumber === 1 && thirdNumber === 1;
+ }
+
+ return secondNumber === 1;
+} // workaround for https://github.com/remarkjs/remark/issues/351
+// leading and trailing newlines are stripped by remark
+
+
+function getFencedCodeBlockValue(node, originalText) {
+ const text = originalText.slice(node.position.start.offset, node.position.end.offset);
+ const leadingSpaceCount = text.match(/^\s*/)[0].length;
+ const replaceRegex = new RegExp(`^\\s{0,${leadingSpaceCount}}`);
+ const lineContents = text.split("\n");
+ const markerStyle = text[leadingSpaceCount]; // ` or ~
+
+ const marker = text.slice(leadingSpaceCount).match(new RegExp(`^[${markerStyle}]+`))[0]; // https://spec.commonmark.org/0.28/#example-104: Closing fences may be indented by 0-3 spaces
+ // https://spec.commonmark.org/0.28/#example-93: The closing code fence must be at least as long as the opening fence
+
+ const hasEndMarker = new RegExp(`^\\s{0,3}${marker}`).test(lineContents[lineContents.length - 1].slice(getIndent(lineContents.length - 1)));
+ return lineContents.slice(1, hasEndMarker ? -1 : undefined).map((x, i) => x.slice(getIndent(i + 1)).replace(replaceRegex, "")).join("\n");
+
+ function getIndent(lineIndex) {
+ return node.position.indent[lineIndex - 1] - 1;
+ }
+}
+
+function mapAst(ast, handler) {
+ return function preorder(node, index, parentStack) {
+ parentStack = parentStack || [];
+ const newNode = Object.assign({}, handler(node, index, parentStack));
+
+ if (newNode.children) {
+ newNode.children = newNode.children.map((child, index) => {
+ return preorder(child, index, [newNode].concat(parentStack));
+ });
+ }
+
+ return newNode;
+ }(ast, null, null);
+}
+
+var utils$9 = {
+ mapAst,
+ splitText,
+ punctuationPattern,
+ getFencedCodeBlockValue,
+ getOrderedListItemInfo,
+ hasGitDiffFriendlyOrderedList,
+ INLINE_NODE_TYPES,
+ INLINE_NODE_WRAPPER_TYPES
+};
+
+const {
+ builders: {
+ hardline: hardline$a,
+ literalline: literalline$4,
+ concat: concat$c,
+ markAsRoot: markAsRoot$2
+ },
+ utils: {
+ mapDoc: mapDoc$3
+ }
+} = document;
+const {
+ getFencedCodeBlockValue: getFencedCodeBlockValue$1
+} = utils$9;
+
+function embed$2(path, print, textToDoc, options) {
+ const node = path.getValue();
+
+ if (node.type === "code" && node.lang !== null) {
+ // only look for the first string so as to support [markdown-preview-enhanced](https://shd101wyy.github.io/markdown-preview-enhanced/#/code-chunk)
+ const langMatch = node.lang.match(/^[A-Za-z0-9_-]+/);
+ const lang = langMatch ? langMatch[0] : "";
+ const parser = getParserName(lang);
+
+ if (parser) {
+ const styleUnit = options.__inJsTemplate ? "~" : "`";
+ const style = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
+ const doc = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), {
+ parser
+ });
+ return markAsRoot$2(concat$c([style, node.lang, hardline$a, replaceNewlinesWithLiterallines(doc), style]));
+ }
+ }
+
+ if (node.type === "yaml") {
+ return markAsRoot$2(concat$c(["---", hardline$a, node.value && node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
+ parser: "yaml"
+ })) : "", "---"]));
+ } // MDX
+
+
+ switch (node.type) {
+ case "importExport":
+ return textToDoc(node.value, {
+ parser: "babel"
+ });
+
+ case "jsx":
+ return textToDoc(`<$>${node.value}$>`, {
+ parser: "__js_expression",
+ rootMarker: "mdx"
+ });
+ }
+
+ return null;
+
+ function getParserName(lang) {
+ const supportInfo = support.getSupportInfo({
+ plugins: options.plugins
+ });
+ const language = supportInfo.languages.find(language => language.name.toLowerCase() === lang || language.aliases && language.aliases.includes(lang) || language.extensions && language.extensions.find(ext => ext === `.${lang}`));
+
+ if (language) {
+ return language.parsers[0];
+ }
+
+ return null;
+ }
+
+ function replaceNewlinesWithLiterallines(doc) {
+ return mapDoc$3(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$c(currentDoc.split(/(\n)/g).map((v, i) => i % 2 === 0 ? v : literalline$4)) : currentDoc);
+ }
+}
+
+var embed_1$2 = embed$2;
+
+const pragmas = ["format", "prettier"];
+
+function startWithPragma(text) {
+ const pragma = `@(${pragmas.join("|")})`;
+ const regex = new RegExp([``, ``].join("|"), "m");
+ const matched = text.match(regex);
+ return matched && matched.index === 0;
+}
+
+var pragma$3 = {
+ startWithPragma,
+ hasPragma: text => startWithPragma(frontMatter(text).content.trimStart()),
+ insertPragma: text => {
+ const extracted = frontMatter(text);
+ const pragma = ``;
+ return extracted.frontMatter ? `${extracted.frontMatter.raw}\n\n${pragma}\n\n${extracted.content}` : `${pragma}\n\n${extracted.content}`;
+ }
+};
+
+const {
+ getOrderedListItemInfo: getOrderedListItemInfo$1,
+ mapAst: mapAst$1,
+ splitText: splitText$1
+} = utils$9; // 0x0 ~ 0x10ffff
+// eslint-disable-next-line no-control-regex
+
+const isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/;
+
+function preprocess$1(ast, options) {
+ ast = restoreUnescapedCharacter(ast, options);
+ ast = mergeContinuousTexts(ast);
+ ast = transformInlineCode(ast);
+ ast = transformIndentedCodeblockAndMarkItsParentList(ast, options);
+ ast = markAlignedList(ast, options);
+ ast = splitTextIntoSentences(ast, options);
+ ast = transformImportExport(ast);
+ ast = mergeContinuousImportExport(ast);
+ return ast;
+}
+
+function transformImportExport(ast) {
+ return mapAst$1(ast, node => {
+ if (node.type !== "import" && node.type !== "export") {
+ return node;
+ }
+
+ return Object.assign({}, node, {
+ type: "importExport"
+ });
+ });
+}
+
+function transformInlineCode(ast) {
+ return mapAst$1(ast, node => {
+ if (node.type !== "inlineCode") {
+ return node;
+ }
+
+ return Object.assign({}, node, {
+ value: node.value.replace(/\s+/g, " ")
+ });
+ });
+}
+
+function restoreUnescapedCharacter(ast, options) {
+ return mapAst$1(ast, node => {
+ return node.type !== "text" ? node : Object.assign({}, node, {
+ value: node.value !== "*" && node.value !== "_" && node.value !== "$" && // handle these cases in printer
+ isSingleCharRegex.test(node.value) && node.position.end.offset - node.position.start.offset !== node.value.length ? options.originalText.slice(node.position.start.offset, node.position.end.offset) : node.value
+ });
+ });
+}
+
+function mergeContinuousImportExport(ast) {
+ return mergeChildren(ast, (prevNode, node) => prevNode.type === "importExport" && node.type === "importExport", (prevNode, node) => ({
+ type: "importExport",
+ value: prevNode.value + "\n\n" + node.value,
+ position: {
+ start: prevNode.position.start,
+ end: node.position.end
+ }
+ }));
+}
+
+function mergeChildren(ast, shouldMerge, mergeNode) {
+ return mapAst$1(ast, node => {
+ if (!node.children) {
+ return node;
+ }
+
+ const children = node.children.reduce((current, child) => {
+ const lastChild = current[current.length - 1];
+
+ if (lastChild && shouldMerge(lastChild, child)) {
+ current.splice(-1, 1, mergeNode(lastChild, child));
+ } else {
+ current.push(child);
+ }
+
+ return current;
+ }, []);
+ return Object.assign({}, node, {
+ children
+ });
+ });
+}
+
+function mergeContinuousTexts(ast) {
+ return mergeChildren(ast, (prevNode, node) => prevNode.type === "text" && node.type === "text", (prevNode, node) => ({
+ type: "text",
+ value: prevNode.value + node.value,
+ position: {
+ start: prevNode.position.start,
+ end: node.position.end
+ }
+ }));
+}
+
+function splitTextIntoSentences(ast, options) {
+ return mapAst$1(ast, (node, index, [parentNode]) => {
+ if (node.type !== "text") {
+ return node;
+ }
+
+ let {
+ value
+ } = node;
+
+ if (parentNode.type === "paragraph") {
+ if (index === 0) {
+ value = value.trimStart();
+ }
+
+ if (index === parentNode.children.length - 1) {
+ value = value.trimEnd();
+ }
+ }
+
+ return {
+ type: "sentence",
+ position: node.position,
+ children: splitText$1(value, options)
+ };
+ });
+}
+
+function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
+ return mapAst$1(ast, (node, index, parentStack) => {
+ if (node.type === "code") {
+ // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
+ const isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
+ node.isIndented = isIndented;
+
+ if (isIndented) {
+ for (let i = 0; i < parentStack.length; i++) {
+ const parent = parentStack[i]; // no need to check checked items
+
+ if (parent.hasIndentedCodeblock) {
+ break;
+ }
+
+ if (parent.type === "list") {
+ parent.hasIndentedCodeblock = true;
+ }
+ }
+ }
+ }
+
+ return node;
+ });
+}
+
+function markAlignedList(ast, options) {
+ return mapAst$1(ast, (node, index, parentStack) => {
+ if (node.type === "list" && node.children.length !== 0) {
+ // if one of its parents is not aligned, it's not possible to be aligned in sub-lists
+ for (let i = 0; i < parentStack.length; i++) {
+ const parent = parentStack[i];
+
+ if (parent.type === "list" && !parent.isAligned) {
+ node.isAligned = false;
+ return node;
+ }
+ }
+
+ node.isAligned = isAligned(node);
+ }
+
+ return node;
+ });
+
+ function getListItemStart(listItem) {
+ return listItem.children.length === 0 ? -1 : listItem.children[0].position.start.column - 1;
+ }
+
+ function isAligned(list) {
+ if (!list.ordered) {
+ /**
+ * - 123
+ * - 123
+ */
+ return true;
+ }
+
+ const [firstItem, secondItem] = list.children;
+ const firstInfo = getOrderedListItemInfo$1(firstItem, options.originalText);
+
+ if (firstInfo.leadingSpaces.length > 1) {
+ /**
+ * 1. 123
+ *
+ * 1. 123
+ * 1. 123
+ */
+ return true;
+ }
+
+ const firstStart = getListItemStart(firstItem);
+
+ if (firstStart === -1) {
+ /**
+ * 1.
+ *
+ * 1.
+ * 1.
+ */
+ return false;
+ }
+
+ if (list.children.length === 1) {
+ /**
+ * aligned:
+ *
+ * 11. 123
+ *
+ * not aligned:
+ *
+ * 1. 123
+ */
+ return firstStart % options.tabWidth === 0;
+ }
+
+ const secondStart = getListItemStart(secondItem);
+
+ if (firstStart !== secondStart) {
+ /**
+ * 11. 123
+ * 1. 123
+ *
+ * 1. 123
+ * 11. 123
+ */
+ return false;
+ }
+
+ if (firstStart % options.tabWidth === 0) {
+ /**
+ * 11. 123
+ * 12. 123
+ */
+ return true;
+ }
+ /**
+ * aligned:
+ *
+ * 11. 123
+ * 1. 123
+ *
+ * not aligned:
+ *
+ * 1. 123
+ * 2. 123
+ */
+
+
+ const secondInfo = getOrderedListItemInfo$1(secondItem, options.originalText);
+ return secondInfo.leadingSpaces.length > 1;
+ }
+}
+
+var preprocess_1$1 = preprocess$1;
+
+const {
+ builders: {
+ breakParent: breakParent$3,
+ concat: concat$d,
+ join: join$9,
+ line: line$8,
+ literalline: literalline$5,
+ markAsRoot: markAsRoot$3,
+ hardline: hardline$b,
+ softline: softline$6,
+ ifBreak: ifBreak$5,
+ fill: fill$5,
+ align: align$2,
+ indent: indent$8,
+ group: group$d
+ },
+ utils: {
+ mapDoc: mapDoc$4
+ },
+ printer: {
+ printDocToString: printDocToString$3
+ }
+} = document;
+const {
+ getFencedCodeBlockValue: getFencedCodeBlockValue$2,
+ hasGitDiffFriendlyOrderedList: hasGitDiffFriendlyOrderedList$1,
+ splitText: splitText$2,
+ punctuationPattern: punctuationPattern$1,
+ INLINE_NODE_TYPES: INLINE_NODE_TYPES$1,
+ INLINE_NODE_WRAPPER_TYPES: INLINE_NODE_WRAPPER_TYPES$1
+} = utils$9;
+const {
+ replaceEndOfLineWith: replaceEndOfLineWith$1
+} = util$1;
+const TRAILING_HARDLINE_NODES = ["importExport"];
+const SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
+const SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
+
+function genericPrint$4(path, options, print) {
+ const node = path.getValue();
+
+ if (shouldRemainTheSameContent(path)) {
+ return concat$d(splitText$2(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(node => node.type === "word" ? node.value : node.value === "" ? "" : printLine(path, node.value, options)));
+ }
+
+ switch (node.type) {
+ case "root":
+ if (node.children.length === 0) {
+ return "";
+ }
+
+ return concat$d([normalizeDoc(printRoot(path, options, print)), !TRAILING_HARDLINE_NODES.includes(getLastDescendantNode(node).type) ? hardline$b : ""]);
+
+ case "paragraph":
+ return printChildren$1(path, options, print, {
+ postprocessor: fill$5
+ });
+
+ case "sentence":
+ return printChildren$1(path, options, print);
+
+ case "word":
+ return node.value.replace(/[*$]/g, "\\$&") // escape all `*` and `$` (math)
+ .replace(new RegExp([`(^|${punctuationPattern$1})(_+)`, `(_+)(${punctuationPattern$1}|$)`].join("|"), "g"), (_, text1, underscore1, underscore2, text2) => (underscore1 ? `${text1}${underscore1}` : `${underscore2}${text2}`).replace(/_/g, "\\_"));
+ // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
+
+ case "whitespace":
+ {
+ const parentNode = path.getParentNode();
+ const index = parentNode.children.indexOf(node);
+ const nextNode = parentNode.children[index + 1];
+ const proseWrap = // leading char that may cause different syntax
+ nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value) ? "never" : options.proseWrap;
+ return printLine(path, node.value, {
+ proseWrap
+ });
+ }
+
+ case "emphasis":
+ {
+ const parentNode = path.getParentNode();
+ const index = parentNode.children.indexOf(node);
+ const prevNode = parentNode.children[index - 1];
+ const nextNode = parentNode.children[index + 1];
+ const hasPrevOrNextWord = // `1*2*3` is considered emphasis but `1_2_3` is not
+ prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && util$1.getLast(prevNode.children).type === "word" && !util$1.getLast(prevNode.children).hasTrailingPunctuation || nextNode && nextNode.type === "sentence" && nextNode.children.length > 0 && nextNode.children[0].type === "word" && !nextNode.children[0].hasLeadingPunctuation;
+ const style = hasPrevOrNextWord || getAncestorNode$2(path, "emphasis") ? "*" : "_";
+ return concat$d([style, printChildren$1(path, options, print), style]);
+ }
+
+ case "strong":
+ return concat$d(["**", printChildren$1(path, options, print), "**"]);
+
+ case "delete":
+ return concat$d(["~~", printChildren$1(path, options, print), "~~"]);
+
+ case "inlineCode":
+ {
+ const backtickCount = util$1.getMinNotPresentContinuousCount(node.value, "`");
+ const style = "`".repeat(backtickCount || 1);
+ const gap = backtickCount ? " " : "";
+ return concat$d([style, gap, node.value, gap, style]);
+ }
+
+ case "link":
+ switch (options.originalText[node.position.start.offset]) {
+ case "<":
+ {
+ const mailto = "mailto:";
+ const url = // is parsed as { url: "mailto:hello@example.com" }
+ node.url.startsWith(mailto) && options.originalText.slice(node.position.start.offset + 1, node.position.start.offset + 1 + mailto.length) !== mailto ? node.url.slice(mailto.length) : node.url;
+ return concat$d(["<", url, ">"]);
+ }
+
+ case "[":
+ return concat$d(["[", printChildren$1(path, options, print), "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
+
+ default:
+ return options.originalText.slice(node.position.start.offset, node.position.end.offset);
+ }
+
+ case "image":
+ return concat$d(["![", node.alt || "", "](", printUrl(node.url, ")"), printTitle(node.title, options), ")"]);
+
+ case "blockquote":
+ return concat$d(["> ", align$2("> ", printChildren$1(path, options, print))]);
+
+ case "heading":
+ return concat$d(["#".repeat(node.depth) + " ", printChildren$1(path, options, print)]);
+
+ case "code":
+ {
+ if (node.isIndented) {
+ // indented code block
+ const alignment = " ".repeat(4);
+ return align$2(alignment, concat$d([alignment, concat$d(replaceEndOfLineWith$1(node.value, hardline$b))]));
+ } // fenced code block
+
+
+ const styleUnit = options.__inJsTemplate ? "~" : "`";
+ const style = styleUnit.repeat(Math.max(3, util$1.getMaxContinuousCount(node.value, styleUnit) + 1));
+ return concat$d([style, node.lang || "", hardline$b, concat$d(replaceEndOfLineWith$1(getFencedCodeBlockValue$2(node, options.originalText), hardline$b)), hardline$b, style]);
+ }
+
+ case "yaml":
+ case "toml":
+ return options.originalText.slice(node.position.start.offset, node.position.end.offset);
+
+ case "html":
+ {
+ const parentNode = path.getParentNode();
+ const value = parentNode.type === "root" && util$1.getLast(parentNode.children) === node ? node.value.trimEnd() : node.value;
+ const isHtmlComment = /^$/.test(value);
+ return concat$d(replaceEndOfLineWith$1(value, isHtmlComment ? hardline$b : markAsRoot$3(literalline$5)));
+ }
+
+ case "list":
+ {
+ const nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
+ const isGitDiffFriendlyOrderedList = hasGitDiffFriendlyOrderedList$1(node, options);
+ return printChildren$1(path, options, print, {
+ processor: (childPath, index) => {
+ const prefix = getPrefix();
+ const childNode = childPath.getValue();
+
+ if (childNode.children.length === 2 && childNode.children[1].type === "html" && childNode.children[0].position.start.column !== childNode.children[1].position.start.column) {
+ return concat$d([prefix, printListItem(childPath, options, print, prefix)]);
+ }
+
+ return concat$d([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]);
+
+ function getPrefix() {
+ const rawPrefix = node.ordered ? (index === 0 ? node.start : isGitDiffFriendlyOrderedList ? 1 : node.start + index) + (nthSiblingIndex % 2 === 0 ? ". " : ") ") : nthSiblingIndex % 2 === 0 ? "- " : "* ";
+ return node.isAligned ||
+ /* workaround for https://github.com/remarkjs/remark/issues/315 */
+ node.hasIndentedCodeblock ? alignListPrefix(rawPrefix, options) : rawPrefix;
+ }
+ }
+ });
+ }
+
+ case "thematicBreak":
+ {
+ const counter = getAncestorCounter$1(path, "list");
+
+ if (counter === -1) {
+ return "---";
+ }
+
+ const nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
+ return nthSiblingIndex % 2 === 0 ? "***" : "---";
+ }
+
+ case "linkReference":
+ return concat$d(["[", printChildren$1(path, options, print), "]", node.referenceType === "full" ? concat$d(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]);
+
+ case "imageReference":
+ switch (node.referenceType) {
+ case "full":
+ return concat$d(["![", node.alt || "", "][", node.identifier, "]"]);
+
+ default:
+ return concat$d(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]);
+ }
+
+ case "definition":
+ {
+ const lineOrSpace = options.proseWrap === "always" ? line$8 : " ";
+ return group$d(concat$d([concat$d(["[", node.identifier, "]:"]), indent$8(concat$d([lineOrSpace, printUrl(node.url), node.title === null ? "" : concat$d([lineOrSpace, printTitle(node.title, options, false)])]))]));
+ }
+
+ case "footnote":
+ return concat$d(["[^", printChildren$1(path, options, print), "]"]);
+
+ case "footnoteReference":
+ return concat$d(["[^", node.identifier, "]"]);
+
+ case "footnoteDefinition":
+ {
+ const nextNode = path.getParentNode().children[path.getName() + 1];
+ const shouldInlineFootnote = node.children.length === 1 && node.children[0].type === "paragraph" && (options.proseWrap === "never" || options.proseWrap === "preserve" && node.children[0].position.start.line === node.children[0].position.end.line);
+ return concat$d(["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren$1(path, options, print) : group$d(concat$d([align$2(" ".repeat(options.tabWidth), printChildren$1(path, options, print, {
+ processor: (childPath, index) => {
+ return index === 0 ? group$d(concat$d([softline$6, childPath.call(print)])) : childPath.call(print);
+ }
+ })), nextNode && nextNode.type === "footnoteDefinition" ? softline$6 : ""]))]);
+ }
+
+ case "table":
+ return printTable(path, options, print);
+
+ case "tableCell":
+ return printChildren$1(path, options, print);
+
+ case "break":
+ return /\s/.test(options.originalText[node.position.start.offset]) ? concat$d([" ", markAsRoot$3(literalline$5)]) : concat$d(["\\", hardline$b]);
+
+ case "liquidNode":
+ return concat$d(replaceEndOfLineWith$1(node.value, hardline$b));
+ // MDX
+
+ case "importExport":
+ case "jsx":
+ return node.value;
+ // fallback to the original text if multiparser failed
+
+ case "math":
+ return concat$d(["$$", hardline$b, node.value ? concat$d([concat$d(replaceEndOfLineWith$1(node.value, hardline$b)), hardline$b]) : "", "$$"]);
+
+ case "inlineMath":
+ {
+ // remark-math trims content but we don't want to remove whitespaces
+ // since it's very possible that it's recognized as math accidentally
+ return options.originalText.slice(options.locStart(node), options.locEnd(node));
+ }
+
+ case "tableRow": // handled in "table"
+
+ case "listItem": // handled in "list"
+
+ default:
+ throw new Error(`Unknown markdown type ${JSON.stringify(node.type)}`);
+ }
+}
+
+function printListItem(path, options, print, listPrefix) {
+ const node = path.getValue();
+ const prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
+ return concat$d([prefix, printChildren$1(path, options, print, {
+ processor: (childPath, index) => {
+ if (index === 0 && childPath.getValue().type !== "list") {
+ return align$2(" ".repeat(prefix.length), childPath.call(print));
+ }
+
+ const alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
+ );
+ return concat$d([alignment, align$2(alignment, childPath.call(print))]);
+ }
+ })]);
+}
+
+function alignListPrefix(prefix, options) {
+ const additionalSpaces = getAdditionalSpaces();
+ return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
+ );
+
+ function getAdditionalSpaces() {
+ const restSpaces = prefix.length % options.tabWidth;
+ return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
+ }
+}
+
+function getNthListSiblingIndex(node, parentNode) {
+ return getNthSiblingIndex(node, parentNode, siblingNode => siblingNode.ordered === node.ordered);
+}
+
+function getNthSiblingIndex(node, parentNode, condition) {
+ condition = condition || (() => true);
+
+ let index = -1;
+
+ for (const childNode of parentNode.children) {
+ if (childNode.type === node.type && condition(childNode)) {
+ index++;
+ } else {
+ index = -1;
+ }
+
+ if (childNode === node) {
+ return index;
+ }
+ }
+}
+
+function getAncestorCounter$1(path, typeOrTypes) {
+ const types = [].concat(typeOrTypes);
+ let counter = -1;
+ let ancestorNode;
+
+ while (ancestorNode = path.getParentNode(++counter)) {
+ if (types.includes(ancestorNode.type)) {
+ return counter;
+ }
+ }
+
+ return -1;
+}
+
+function getAncestorNode$2(path, typeOrTypes) {
+ const counter = getAncestorCounter$1(path, typeOrTypes);
+ return counter === -1 ? null : path.getParentNode(counter);
+}
+
+function printLine(path, value, options) {
+ if (options.proseWrap === "preserve" && value === "\n") {
+ return hardline$b;
+ }
+
+ const isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path, SINGLE_LINE_NODE_TYPES);
+ return value !== "" ? isBreakable ? line$8 : " " : isBreakable ? softline$6 : "";
+}
+
+function printTable(path, options, print) {
+ const hardlineWithoutBreakParent = hardline$b.parts[0];
+ const node = path.getValue();
+ const contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
+
+ path.map(rowPath => {
+ const rowContents = [];
+ rowPath.map(cellPath => {
+ rowContents.push(printDocToString$3(cellPath.call(print), options).formatted);
+ }, "children");
+ contents.push(rowContents);
+ }, "children"); // Get the width of each column
+
+ const columnMaxWidths = contents.reduce((currentWidths, rowContents) => currentWidths.map((width, columnIndex) => Math.max(width, util$1.getStringWidth(rowContents[columnIndex]))), contents[0].map(() => 3) // minimum width = 3 (---, :--, :-:, --:)
+ );
+ const alignedTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0]), printSeparator(), join$9(hardlineWithoutBreakParent, contents.slice(1).map(rowContents => printRow(rowContents)))]);
+
+ if (options.proseWrap !== "never") {
+ return concat$d([breakParent$3, alignedTable]);
+ } // Only if the --prose-wrap never is set and it exceeds the print width.
+
+
+ const compactTable = join$9(hardlineWithoutBreakParent, [printRow(contents[0],
+ /* isCompact */
+ true), printSeparator(
+ /* isCompact */
+ true), join$9(hardlineWithoutBreakParent, contents.slice(1).map(rowContents => printRow(rowContents,
+ /* isCompact */
+ true)))]);
+ return concat$d([breakParent$3, group$d(ifBreak$5(compactTable, alignedTable))]);
+
+ function printSeparator(isCompact) {
+ return concat$d(["| ", join$9(" | ", columnMaxWidths.map((width, index) => {
+ const spaces = isCompact ? 3 : width;
+
+ switch (node.align[index]) {
+ case "left":
+ return ":" + "-".repeat(spaces - 1);
+
+ case "right":
+ return "-".repeat(spaces - 1) + ":";
+
+ case "center":
+ return ":" + "-".repeat(spaces - 2) + ":";
+
+ default:
+ return "-".repeat(spaces);
+ }
+ })), " |"]);
+ }
+
+ function printRow(rowContents, isCompact) {
+ return concat$d(["| ", join$9(" | ", isCompact ? rowContents : rowContents.map((rowContent, columnIndex) => {
+ switch (node.align[columnIndex]) {
+ case "right":
+ return alignRight(rowContent, columnMaxWidths[columnIndex]);
+
+ case "center":
+ return alignCenter(rowContent, columnMaxWidths[columnIndex]);
+
+ default:
+ return alignLeft(rowContent, columnMaxWidths[columnIndex]);
+ }
+ })), " |"]);
+ }
+
+ function alignLeft(text, width) {
+ const spaces = width - util$1.getStringWidth(text);
+ return concat$d([text, " ".repeat(spaces)]);
+ }
+
+ function alignRight(text, width) {
+ const spaces = width - util$1.getStringWidth(text);
+ return concat$d([" ".repeat(spaces), text]);
+ }
+
+ function alignCenter(text, width) {
+ const spaces = width - util$1.getStringWidth(text);
+ const left = Math.floor(spaces / 2);
+ const right = spaces - left;
+ return concat$d([" ".repeat(left), text, " ".repeat(right)]);
+ }
+}
+
+function printRoot(path, options, print) {
+ /** @typedef {{ index: number, offset: number }} IgnorePosition */
+
+ /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
+ const ignoreRanges = [];
+ /** @type {IgnorePosition | null} */
+
+ let ignoreStart = null;
+ const {
+ children
+ } = path.getValue();
+ children.forEach((childNode, index) => {
+ switch (isPrettierIgnore(childNode)) {
+ case "start":
+ if (ignoreStart === null) {
+ ignoreStart = {
+ index,
+ offset: childNode.position.end.offset
+ };
+ }
+
+ break;
+
+ case "end":
+ if (ignoreStart !== null) {
+ ignoreRanges.push({
+ start: ignoreStart,
+ end: {
+ index,
+ offset: childNode.position.start.offset
+ }
+ });
+ ignoreStart = null;
+ }
+
+ break;
+ }
+ });
+ return printChildren$1(path, options, print, {
+ processor: (childPath, index) => {
+ if (ignoreRanges.length !== 0) {
+ const ignoreRange = ignoreRanges[0];
+
+ if (index === ignoreRange.start.index) {
+ return concat$d([children[ignoreRange.start.index].value, options.originalText.slice(ignoreRange.start.offset, ignoreRange.end.offset), children[ignoreRange.end.index].value]);
+ }
+
+ if (ignoreRange.start.index < index && index < ignoreRange.end.index) {
+ return false;
+ }
+
+ if (index === ignoreRange.end.index) {
+ ignoreRanges.shift();
+ return false;
+ }
+ }
+
+ return childPath.call(print);
+ }
+ });
+}
+
+function printChildren$1(path, options, print, events) {
+ events = events || {};
+ const postprocessor = events.postprocessor || concat$d;
+
+ const processor = events.processor || (childPath => childPath.call(print));
+
+ const node = path.getValue();
+ const parts = [];
+ let lastChildNode;
+ path.map((childPath, index) => {
+ const childNode = childPath.getValue();
+ const result = processor(childPath, index);
+
+ if (result !== false) {
+ const data = {
+ parts,
+ prevNode: lastChildNode,
+ parentNode: node,
+ options
+ };
+
+ if (!shouldNotPrePrintHardline(childNode, data)) {
+ parts.push(hardline$b);
+
+ if (lastChildNode && TRAILING_HARDLINE_NODES.includes(lastChildNode.type)) {
+ if (shouldPrePrintTripleHardline(childNode, data)) {
+ parts.push(hardline$b);
+ }
+ } else {
+ if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
+ parts.push(hardline$b);
+ }
+
+ if (shouldPrePrintTripleHardline(childNode, data)) {
+ parts.push(hardline$b);
+ }
+ }
+ }
+
+ parts.push(result);
+ lastChildNode = childNode;
+ }
+ }, "children");
+ return postprocessor(parts);
+}
+
+function getLastDescendantNode(node) {
+ let current = node;
+
+ while (current.children && current.children.length !== 0) {
+ current = current.children[current.children.length - 1];
+ }
+
+ return current;
+}
+/** @return {false | 'next' | 'start' | 'end'} */
+
+
+function isPrettierIgnore(node) {
+ if (node.type !== "html") {
+ return false;
+ }
+
+ const match = node.value.match(/^$/);
+ return match === null ? false : match[1] ? match[1] : "next";
+}
+
+function shouldNotPrePrintHardline(node, data) {
+ const isFirstNode = data.parts.length === 0;
+ const isInlineNode = INLINE_NODE_TYPES$1.includes(node.type);
+ const isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES$1.includes(data.parentNode.type);
+ return isFirstNode || isInlineNode || isInlineHTML;
+}
+
+function shouldPrePrintDoubleHardline(node, data) {
+ const isSequence = (data.prevNode && data.prevNode.type) === node.type;
+ const isSiblingNode = isSequence && SIBLING_NODE_TYPES.includes(node.type);
+ const isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
+ const isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
+ const isPrevNodePrettierIgnore = isPrettierIgnore(data.prevNode) === "next";
+ const isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
+ const isHtmlDirectAfterListItem = node.type === "html" && data.parentNode.type === "listItem" && data.prevNode && data.prevNode.type === "paragraph" && data.prevNode.position.end.line + 1 === node.position.start.line;
+ return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml || isHtmlDirectAfterListItem);
+}
+
+function shouldPrePrintTripleHardline(node, data) {
+ const isPrevNodeList = data.prevNode && data.prevNode.type === "list";
+ const isIndentedCode = node.type === "code" && node.isIndented;
+ return isPrevNodeList && isIndentedCode;
+}
+
+function shouldRemainTheSameContent(path) {
+ const ancestorNode = getAncestorNode$2(path, ["linkReference", "imageReference"]);
+ return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
+}
+
+function normalizeDoc(doc) {
+ return mapDoc$4(doc, currentDoc => {
+ if (!currentDoc.parts) {
+ return currentDoc;
+ }
+
+ if (currentDoc.type === "concat" && currentDoc.parts.length === 1) {
+ return currentDoc.parts[0];
+ }
+
+ const parts = currentDoc.parts.reduce((parts, part) => {
+ if (part.type === "concat") {
+ parts.push(...part.parts);
+ } else if (part !== "") {
+ parts.push(part);
+ }
+
+ return parts;
+ }, []);
+ return Object.assign({}, currentDoc, {
+ parts: normalizeParts(parts)
+ });
+ });
+}
+
+function printUrl(url, dangerousCharOrChars) {
+ const dangerousChars = [" "].concat(dangerousCharOrChars || []);
+ return new RegExp(dangerousChars.map(x => `\\${x}`).join("|")).test(url) ? `<${url}>` : url;
+}
+
+function printTitle(title, options, printSpace) {
+ if (printSpace == null) {
+ printSpace = true;
+ }
+
+ if (!title) {
+ return "";
+ }
+
+ if (printSpace) {
+ return " " + printTitle(title, options, false);
+ }
+
+ if (title.includes('"') && title.includes("'") && !title.includes(")")) {
+ return `(${title})`; // avoid escaped quotes
+ } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
+
+
+ const singleCount = title.split("'").length - 1;
+ const doubleCount = title.split('"').length - 1;
+ const quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
+ title = title.replace(new RegExp(`(${quote})`, "g"), "\\$1");
+ return `${quote}${title}${quote}`;
+}
+
+function normalizeParts(parts) {
+ return parts.reduce((current, part) => {
+ const lastPart = util$1.getLast(current);
+
+ if (typeof lastPart === "string" && typeof part === "string") {
+ current.splice(-1, 1, lastPart + part);
+ } else {
+ current.push(part);
+ }
+
+ return current;
+ }, []);
+}
+
+function clamp(value, min, max) {
+ return value < min ? min : value > max ? max : value;
+}
+
+function clean$5(ast, newObj, parent) {
+ delete newObj.position;
+ delete newObj.raw; // front-matter
+ // for codeblock
+
+ if (ast.type === "code" || ast.type === "yaml" || ast.type === "import" || ast.type === "export" || ast.type === "jsx") {
+ delete newObj.value;
+ }
+
+ if (ast.type === "list") {
+ delete newObj.isAligned;
+ } // texts can be splitted or merged
+
+
+ if (ast.type === "text") {
+ return null;
+ }
+
+ if (ast.type === "inlineCode") {
+ newObj.value = ast.value.replace(/[ \t\n]+/g, " ");
+ } // for insert pragma
+
+
+ if (parent && parent.type === "root" && parent.children.length > 0 && (parent.children[0] === ast || (parent.children[0].type === "yaml" || parent.children[0].type === "toml") && parent.children[1] === ast) && ast.type === "html" && pragma$3.startWithPragma(ast.value)) {
+ return null;
+ }
+}
+
+function hasPrettierIgnore$4(path) {
+ const index = +path.getName();
+
+ if (index === 0) {
+ return false;
+ }
+
+ const prevNode = path.getParentNode().children[index - 1];
+ return isPrettierIgnore(prevNode) === "next";
+}
+
+var printerMarkdown = {
+ preprocess: preprocess_1$1,
+ print: genericPrint$4,
+ embed: embed_1$2,
+ massageAstNode: clean$5,
+ hasPrettierIgnore: hasPrettierIgnore$4,
+ insertPragma: pragma$3.insertPragma
+};
+
+var options$5 = {
+ proseWrap: commonOptions.proseWrap,
+ singleQuote: commonOptions.singleQuote
+};
+
+var name$f = "Markdown";
+var type$d = "prose";
+var aliases$4 = [
+ "pandoc"
+];
+var aceMode$d = "markdown";
+var codemirrorMode$a = "gfm";
+var codemirrorMimeType$a = "text/x-gfm";
+var wrap = true;
+var extensions$d = [
+ ".md",
+ ".markdown",
+ ".mdown",
+ ".mdwn",
+ ".mdx",
+ ".mkd",
+ ".mkdn",
+ ".mkdown",
+ ".ronn",
+ ".workbook"
+];
+var filenames$3 = [
+ "contents.lr"
+];
+var tmScope$d = "source.gfm";
+var languageId$d = 222;
+var Markdown = {
+ name: name$f,
+ type: type$d,
+ aliases: aliases$4,
+ aceMode: aceMode$d,
+ codemirrorMode: codemirrorMode$a,
+ codemirrorMimeType: codemirrorMimeType$a,
+ wrap: wrap,
+ extensions: extensions$d,
+ filenames: filenames$3,
+ tmScope: tmScope$d,
+ languageId: languageId$d
+};
+
+var Markdown$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ name: name$f,
+ type: type$d,
+ aliases: aliases$4,
+ aceMode: aceMode$d,
+ codemirrorMode: codemirrorMode$a,
+ codemirrorMimeType: codemirrorMimeType$a,
+ wrap: wrap,
+ extensions: extensions$d,
+ filenames: filenames$3,
+ tmScope: tmScope$d,
+ languageId: languageId$d,
+ 'default': Markdown
+});
+
+var require$$0$5 = getCjsExportFromNamespace(Markdown$1);
+
+const languages$4 = [createLanguage(require$$0$5, data => ({
+ since: "1.8.0",
+ parsers: ["markdown"],
+ vscodeLanguageIds: ["markdown"],
+ filenames: data.filenames.concat(["README"]),
+ extensions: data.extensions.filter(extension => extension !== ".mdx")
+})), createLanguage(require$$0$5, () => ({
+ name: "MDX",
+ since: "1.15.0",
+ parsers: ["mdx"],
+ vscodeLanguageIds: ["mdx"],
+ filenames: [],
+ extensions: [".mdx"]
+}))];
+const printers$4 = {
+ mdast: printerMarkdown
+};
+var languageMarkdown = {
+ languages: languages$4,
+ options: options$5,
+ printers: printers$4
+};
+
+var clean$6 = function (ast, newNode) {
+ delete newNode.sourceSpan;
+ delete newNode.startSourceSpan;
+ delete newNode.endSourceSpan;
+ delete newNode.nameSpan;
+ delete newNode.valueSpan;
+
+ if (ast.type === "text" || ast.type === "comment") {
+ return null;
+ } // may be formatted by multiparser
+
+
+ if (ast.type === "yaml" || ast.type === "toml") {
+ return null;
+ }
+
+ if (ast.type === "attribute") {
+ delete newNode.value;
+ }
+
+ if (ast.type === "docType") {
+ delete newNode.value;
+ }
+};
+
+var json$1 = {
+ "CSS_DISPLAY_TAGS": {
+ "area": "none",
+ "base": "none",
+ "basefont": "none",
+ "datalist": "none",
+ "head": "none",
+ "link": "none",
+ "meta": "none",
+ "noembed": "none",
+ "noframes": "none",
+ "param": "none",
+ "rp": "none",
+ "script": "block",
+ "source": "block",
+ "style": "none",
+ "template": "inline",
+ "track": "block",
+ "title": "none",
+ "html": "block",
+ "body": "block",
+ "address": "block",
+ "blockquote": "block",
+ "center": "block",
+ "div": "block",
+ "figure": "block",
+ "figcaption": "block",
+ "footer": "block",
+ "form": "block",
+ "header": "block",
+ "hr": "block",
+ "legend": "block",
+ "listing": "block",
+ "main": "block",
+ "p": "block",
+ "plaintext": "block",
+ "pre": "block",
+ "xmp": "block",
+ "slot": "contents",
+ "ruby": "ruby",
+ "rt": "ruby-text",
+ "article": "block",
+ "aside": "block",
+ "h1": "block",
+ "h2": "block",
+ "h3": "block",
+ "h4": "block",
+ "h5": "block",
+ "h6": "block",
+ "hgroup": "block",
+ "nav": "block",
+ "section": "block",
+ "dir": "block",
+ "dd": "block",
+ "dl": "block",
+ "dt": "block",
+ "ol": "block",
+ "ul": "block",
+ "li": "list-item",
+ "table": "table",
+ "caption": "table-caption",
+ "colgroup": "table-column-group",
+ "col": "table-column",
+ "thead": "table-header-group",
+ "tbody": "table-row-group",
+ "tfoot": "table-footer-group",
+ "tr": "table-row",
+ "td": "table-cell",
+ "th": "table-cell",
+ "fieldset": "block",
+ "button": "inline-block",
+ "video": "inline-block",
+ "audio": "inline-block"
+ },
+ "CSS_DISPLAY_DEFAULT": "inline",
+ "CSS_WHITE_SPACE_TAGS": {
+ "listing": "pre",
+ "plaintext": "pre",
+ "pre": "pre",
+ "xmp": "pre",
+ "nobr": "nowrap",
+ "table": "initial",
+ "textarea": "pre-wrap"
+ },
+ "CSS_WHITE_SPACE_DEFAULT": "normal"
+};
+
+var index = [
+ "a",
+ "abbr",
+ "acronym",
+ "address",
+ "applet",
+ "area",
+ "article",
+ "aside",
+ "audio",
+ "b",
+ "base",
+ "basefont",
+ "bdi",
+ "bdo",
+ "bgsound",
+ "big",
+ "blink",
+ "blockquote",
+ "body",
+ "br",
+ "button",
+ "canvas",
+ "caption",
+ "center",
+ "cite",
+ "code",
+ "col",
+ "colgroup",
+ "command",
+ "content",
+ "data",
+ "datalist",
+ "dd",
+ "del",
+ "details",
+ "dfn",
+ "dialog",
+ "dir",
+ "div",
+ "dl",
+ "dt",
+ "element",
+ "em",
+ "embed",
+ "fieldset",
+ "figcaption",
+ "figure",
+ "font",
+ "footer",
+ "form",
+ "frame",
+ "frameset",
+ "h1",
+ "h2",
+ "h3",
+ "h4",
+ "h5",
+ "h6",
+ "head",
+ "header",
+ "hgroup",
+ "hr",
+ "html",
+ "i",
+ "iframe",
+ "image",
+ "img",
+ "input",
+ "ins",
+ "isindex",
+ "kbd",
+ "keygen",
+ "label",
+ "legend",
+ "li",
+ "link",
+ "listing",
+ "main",
+ "map",
+ "mark",
+ "marquee",
+ "math",
+ "menu",
+ "menuitem",
+ "meta",
+ "meter",
+ "multicol",
+ "nav",
+ "nextid",
+ "nobr",
+ "noembed",
+ "noframes",
+ "noscript",
+ "object",
+ "ol",
+ "optgroup",
+ "option",
+ "output",
+ "p",
+ "param",
+ "picture",
+ "plaintext",
+ "pre",
+ "progress",
+ "q",
+ "rb",
+ "rbc",
+ "rp",
+ "rt",
+ "rtc",
+ "ruby",
+ "s",
+ "samp",
+ "script",
+ "section",
+ "select",
+ "shadow",
+ "slot",
+ "small",
+ "source",
+ "spacer",
+ "span",
+ "strike",
+ "strong",
+ "style",
+ "sub",
+ "summary",
+ "sup",
+ "svg",
+ "table",
+ "tbody",
+ "td",
+ "template",
+ "textarea",
+ "tfoot",
+ "th",
+ "thead",
+ "time",
+ "title",
+ "tr",
+ "track",
+ "tt",
+ "u",
+ "ul",
+ "var",
+ "video",
+ "wbr",
+ "xmp"
+];
+
+var htmlTagNames = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ 'default': index
+});
+
+var a = [
+ "accesskey",
+ "charset",
+ "coords",
+ "download",
+ "href",
+ "hreflang",
+ "name",
+ "ping",
+ "referrerpolicy",
+ "rel",
+ "rev",
+ "shape",
+ "tabindex",
+ "target",
+ "type"
+];
+var abbr = [
+ "title"
+];
+var applet = [
+ "align",
+ "alt",
+ "archive",
+ "code",
+ "codebase",
+ "height",
+ "hspace",
+ "name",
+ "object",
+ "vspace",
+ "width"
+];
+var area = [
+ "accesskey",
+ "alt",
+ "coords",
+ "download",
+ "href",
+ "hreflang",
+ "nohref",
+ "ping",
+ "referrerpolicy",
+ "rel",
+ "shape",
+ "tabindex",
+ "target",
+ "type"
+];
+var audio = [
+ "autoplay",
+ "controls",
+ "crossorigin",
+ "loop",
+ "muted",
+ "preload",
+ "src"
+];
+var base = [
+ "href",
+ "target"
+];
+var basefont = [
+ "color",
+ "face",
+ "size"
+];
+var bdo = [
+ "dir"
+];
+var blockquote = [
+ "cite"
+];
+var body = [
+ "alink",
+ "background",
+ "bgcolor",
+ "link",
+ "text",
+ "vlink"
+];
+var br = [
+ "clear"
+];
+var button = [
+ "accesskey",
+ "autofocus",
+ "disabled",
+ "form",
+ "formaction",
+ "formenctype",
+ "formmethod",
+ "formnovalidate",
+ "formtarget",
+ "name",
+ "tabindex",
+ "type",
+ "value"
+];
+var canvas = [
+ "height",
+ "width"
+];
+var caption = [
+ "align"
+];
+var col = [
+ "align",
+ "char",
+ "charoff",
+ "span",
+ "valign",
+ "width"
+];
+var colgroup = [
+ "align",
+ "char",
+ "charoff",
+ "span",
+ "valign",
+ "width"
+];
+var data = [
+ "value"
+];
+var del$1 = [
+ "cite",
+ "datetime"
+];
+var details = [
+ "open"
+];
+var dfn = [
+ "title"
+];
+var dialog = [
+ "open"
+];
+var dir = [
+ "compact"
+];
+var div = [
+ "align"
+];
+var dl = [
+ "compact"
+];
+var embed$3 = [
+ "height",
+ "src",
+ "type",
+ "width"
+];
+var fieldset = [
+ "disabled",
+ "form",
+ "name"
+];
+var font = [
+ "color",
+ "face",
+ "size"
+];
+var form = [
+ "accept",
+ "accept-charset",
+ "action",
+ "autocomplete",
+ "enctype",
+ "method",
+ "name",
+ "novalidate",
+ "target"
+];
+var frame = [
+ "frameborder",
+ "longdesc",
+ "marginheight",
+ "marginwidth",
+ "name",
+ "noresize",
+ "scrolling",
+ "src"
+];
+var frameset = [
+ "cols",
+ "rows"
+];
+var h1 = [
+ "align"
+];
+var h2 = [
+ "align"
+];
+var h3 = [
+ "align"
+];
+var h4 = [
+ "align"
+];
+var h5 = [
+ "align"
+];
+var h6 = [
+ "align"
+];
+var head = [
+ "profile"
+];
+var hr = [
+ "align",
+ "noshade",
+ "size",
+ "width"
+];
+var html = [
+ "manifest",
+ "version"
+];
+var iframe = [
+ "align",
+ "allow",
+ "allowfullscreen",
+ "allowpaymentrequest",
+ "allowusermedia",
+ "frameborder",
+ "height",
+ "longdesc",
+ "marginheight",
+ "marginwidth",
+ "name",
+ "referrerpolicy",
+ "sandbox",
+ "scrolling",
+ "src",
+ "srcdoc",
+ "width"
+];
+var img = [
+ "align",
+ "alt",
+ "border",
+ "crossorigin",
+ "decoding",
+ "height",
+ "hspace",
+ "ismap",
+ "longdesc",
+ "name",
+ "referrerpolicy",
+ "sizes",
+ "src",
+ "srcset",
+ "usemap",
+ "vspace",
+ "width"
+];
+var input = [
+ "accept",
+ "accesskey",
+ "align",
+ "alt",
+ "autocomplete",
+ "autofocus",
+ "checked",
+ "dirname",
+ "disabled",
+ "form",
+ "formaction",
+ "formenctype",
+ "formmethod",
+ "formnovalidate",
+ "formtarget",
+ "height",
+ "ismap",
+ "list",
+ "max",
+ "maxlength",
+ "min",
+ "minlength",
+ "multiple",
+ "name",
+ "pattern",
+ "placeholder",
+ "readonly",
+ "required",
+ "size",
+ "src",
+ "step",
+ "tabindex",
+ "title",
+ "type",
+ "usemap",
+ "value",
+ "width"
+];
+var ins = [
+ "cite",
+ "datetime"
+];
+var isindex = [
+ "prompt"
+];
+var label = [
+ "accesskey",
+ "for",
+ "form"
+];
+var legend = [
+ "accesskey",
+ "align"
+];
+var li = [
+ "type",
+ "value"
+];
+var link$3 = [
+ "as",
+ "charset",
+ "color",
+ "crossorigin",
+ "href",
+ "hreflang",
+ "imagesizes",
+ "imagesrcset",
+ "integrity",
+ "media",
+ "nonce",
+ "referrerpolicy",
+ "rel",
+ "rev",
+ "sizes",
+ "target",
+ "title",
+ "type"
+];
+var map$1 = [
+ "name"
+];
+var menu = [
+ "compact"
+];
+var meta = [
+ "charset",
+ "content",
+ "http-equiv",
+ "name",
+ "scheme"
+];
+var meter = [
+ "high",
+ "low",
+ "max",
+ "min",
+ "optimum",
+ "value"
+];
+var object = [
+ "align",
+ "archive",
+ "border",
+ "classid",
+ "codebase",
+ "codetype",
+ "data",
+ "declare",
+ "form",
+ "height",
+ "hspace",
+ "name",
+ "standby",
+ "tabindex",
+ "type",
+ "typemustmatch",
+ "usemap",
+ "vspace",
+ "width"
+];
+var ol = [
+ "compact",
+ "reversed",
+ "start",
+ "type"
+];
+var optgroup = [
+ "disabled",
+ "label"
+];
+var option = [
+ "disabled",
+ "label",
+ "selected",
+ "value"
+];
+var output = [
+ "for",
+ "form",
+ "name"
+];
+var p = [
+ "align"
+];
+var param = [
+ "name",
+ "type",
+ "value",
+ "valuetype"
+];
+var pre = [
+ "width"
+];
+var progress = [
+ "max",
+ "value"
+];
+var q = [
+ "cite"
+];
+var script = [
+ "async",
+ "charset",
+ "crossorigin",
+ "defer",
+ "integrity",
+ "language",
+ "nomodule",
+ "nonce",
+ "referrerpolicy",
+ "src",
+ "type"
+];
+var select = [
+ "autocomplete",
+ "autofocus",
+ "disabled",
+ "form",
+ "multiple",
+ "name",
+ "required",
+ "size",
+ "tabindex"
+];
+var slot = [
+ "name"
+];
+var source$1 = [
+ "media",
+ "sizes",
+ "src",
+ "srcset",
+ "type"
+];
+var style = [
+ "media",
+ "nonce",
+ "title",
+ "type"
+];
+var table = [
+ "align",
+ "bgcolor",
+ "border",
+ "cellpadding",
+ "cellspacing",
+ "frame",
+ "rules",
+ "summary",
+ "width"
+];
+var tbody = [
+ "align",
+ "char",
+ "charoff",
+ "valign"
+];
+var td = [
+ "abbr",
+ "align",
+ "axis",
+ "bgcolor",
+ "char",
+ "charoff",
+ "colspan",
+ "headers",
+ "height",
+ "nowrap",
+ "rowspan",
+ "scope",
+ "valign",
+ "width"
+];
+var textarea = [
+ "accesskey",
+ "autocomplete",
+ "autofocus",
+ "cols",
+ "dirname",
+ "disabled",
+ "form",
+ "maxlength",
+ "minlength",
+ "name",
+ "placeholder",
+ "readonly",
+ "required",
+ "rows",
+ "tabindex",
+ "wrap"
+];
+var tfoot = [
+ "align",
+ "char",
+ "charoff",
+ "valign"
+];
+var th = [
+ "abbr",
+ "align",
+ "axis",
+ "bgcolor",
+ "char",
+ "charoff",
+ "colspan",
+ "headers",
+ "height",
+ "nowrap",
+ "rowspan",
+ "scope",
+ "valign",
+ "width"
+];
+var thead = [
+ "align",
+ "char",
+ "charoff",
+ "valign"
+];
+var time = [
+ "datetime"
+];
+var tr = [
+ "align",
+ "bgcolor",
+ "char",
+ "charoff",
+ "valign"
+];
+var track = [
+ "default",
+ "kind",
+ "label",
+ "src",
+ "srclang"
+];
+var ul = [
+ "compact",
+ "type"
+];
+var video = [
+ "autoplay",
+ "controls",
+ "crossorigin",
+ "height",
+ "loop",
+ "muted",
+ "playsinline",
+ "poster",
+ "preload",
+ "src",
+ "width"
+];
+var index$1 = {
+ "*": [
+ "accesskey",
+ "autocapitalize",
+ "autofocus",
+ "class",
+ "contenteditable",
+ "dir",
+ "draggable",
+ "enterkeyhint",
+ "hidden",
+ "id",
+ "inputmode",
+ "is",
+ "itemid",
+ "itemprop",
+ "itemref",
+ "itemscope",
+ "itemtype",
+ "lang",
+ "nonce",
+ "slot",
+ "spellcheck",
+ "style",
+ "tabindex",
+ "title",
+ "translate"
+],
+ a: a,
+ abbr: abbr,
+ applet: applet,
+ area: area,
+ audio: audio,
+ base: base,
+ basefont: basefont,
+ bdo: bdo,
+ blockquote: blockquote,
+ body: body,
+ br: br,
+ button: button,
+ canvas: canvas,
+ caption: caption,
+ col: col,
+ colgroup: colgroup,
+ data: data,
+ del: del$1,
+ details: details,
+ dfn: dfn,
+ dialog: dialog,
+ dir: dir,
+ div: div,
+ dl: dl,
+ embed: embed$3,
+ fieldset: fieldset,
+ font: font,
+ form: form,
+ frame: frame,
+ frameset: frameset,
+ h1: h1,
+ h2: h2,
+ h3: h3,
+ h4: h4,
+ h5: h5,
+ h6: h6,
+ head: head,
+ hr: hr,
+ html: html,
+ iframe: iframe,
+ img: img,
+ input: input,
+ ins: ins,
+ isindex: isindex,
+ label: label,
+ legend: legend,
+ li: li,
+ link: link$3,
+ map: map$1,
+ menu: menu,
+ meta: meta,
+ meter: meter,
+ object: object,
+ ol: ol,
+ optgroup: optgroup,
+ option: option,
+ output: output,
+ p: p,
+ param: param,
+ pre: pre,
+ progress: progress,
+ q: q,
+ script: script,
+ select: select,
+ slot: slot,
+ source: source$1,
+ style: style,
+ table: table,
+ tbody: tbody,
+ td: td,
+ textarea: textarea,
+ tfoot: tfoot,
+ th: th,
+ thead: thead,
+ time: time,
+ tr: tr,
+ track: track,
+ ul: ul,
+ video: video
+};
+
+var htmlElementAttributes = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ a: a,
+ abbr: abbr,
+ applet: applet,
+ area: area,
+ audio: audio,
+ base: base,
+ basefont: basefont,
+ bdo: bdo,
+ blockquote: blockquote,
+ body: body,
+ br: br,
+ button: button,
+ canvas: canvas,
+ caption: caption,
+ col: col,
+ colgroup: colgroup,
+ data: data,
+ del: del$1,
+ details: details,
+ dfn: dfn,
+ dialog: dialog,
+ dir: dir,
+ div: div,
+ dl: dl,
+ embed: embed$3,
+ fieldset: fieldset,
+ font: font,
+ form: form,
+ frame: frame,
+ frameset: frameset,
+ h1: h1,
+ h2: h2,
+ h3: h3,
+ h4: h4,
+ h5: h5,
+ h6: h6,
+ head: head,
+ hr: hr,
+ html: html,
+ iframe: iframe,
+ img: img,
+ input: input,
+ ins: ins,
+ isindex: isindex,
+ label: label,
+ legend: legend,
+ li: li,
+ link: link$3,
+ map: map$1,
+ menu: menu,
+ meta: meta,
+ meter: meter,
+ object: object,
+ ol: ol,
+ optgroup: optgroup,
+ option: option,
+ output: output,
+ p: p,
+ param: param,
+ pre: pre,
+ progress: progress,
+ q: q,
+ script: script,
+ select: select,
+ slot: slot,
+ source: source$1,
+ style: style,
+ table: table,
+ tbody: tbody,
+ td: td,
+ textarea: textarea,
+ tfoot: tfoot,
+ th: th,
+ thead: thead,
+ time: time,
+ tr: tr,
+ track: track,
+ ul: ul,
+ video: video,
+ 'default': index$1
+});
+
+var htmlTagNames$1 = getCjsExportFromNamespace(htmlTagNames);
+
+var htmlElementAttributes$1 = getCjsExportFromNamespace(htmlElementAttributes);
+
+const {
+ CSS_DISPLAY_TAGS,
+ CSS_DISPLAY_DEFAULT,
+ CSS_WHITE_SPACE_TAGS,
+ CSS_WHITE_SPACE_DEFAULT
+} = json$1;
+const HTML_TAGS = arrayToMap(htmlTagNames$1);
+const HTML_ELEMENT_ATTRIBUTES = mapObject(htmlElementAttributes$1, arrayToMap);
+
+function arrayToMap(array) {
+ const map = Object.create(null);
+
+ for (const value of array) {
+ map[value] = true;
+ }
+
+ return map;
+}
+
+function mapObject(object, fn) {
+ const newObject = Object.create(null);
+
+ for (const key of Object.keys(object)) {
+ newObject[key] = fn(object[key], key);
+ }
+
+ return newObject;
+}
+
+function shouldPreserveContent(node, options) {
+ if (!node.endSourceSpan) {
+ return false;
+ }
+
+ if (node.type === "element" && node.fullName === "template" && node.attrMap.lang && node.attrMap.lang !== "html") {
+ return true;
+ } // unterminated node in ie conditional comment
+ // e.g.
+
+
+ if (node.type === "ieConditionalComment" && node.lastChild && !node.lastChild.isSelfClosing && !node.lastChild.endSourceSpan) {
+ return true;
+ } // incomplete html in ie conditional comment
+ // e.g.
+
+
+ if (node.type === "ieConditionalComment" && !node.complete) {
+ return true;
+ } // top-level elements (excluding , "!==this.input.substring(this.index,this.index+8)||"script"===t&&"<\/script>"!==this.input.substring(this.index,this.index+9)},t}();function V(t,e){return{path:t.PathExpression(e.path),params:e.params?e.params.map(e=>t.acceptNode(e)):[],hash:e.hash?t.Hash(e.hash):y.hash()}}function M(t,e){let{path:r,params:i,hash:a,loc:n}=e;if(P(r)){let i="{{".concat(N(r),"}}"),a="<".concat(t.name," ... ").concat(i," ...");throw new S("In ".concat(a,", ").concat(i,' is not a valid modifier: "').concat(r.original,'" on line ').concat(n&&n.start.line,"."),e.loc)}let s=y.elementModifier(r,i,a,n);t.modifiers.push(s)}function H(t,e){t.isDynamic=!0,t.parts.push(e)}const U={Program:r("body"),Template:r("body"),Block:r("body"),MustacheStatement:r("path","params","hash"),BlockStatement:r("path","params","hash","program","inverse"),ElementModifierStatement:r("path","params","hash"),PartialStatement:r("name","params","hash"),CommentStatement:r(),MustacheCommentStatement:r(),ElementNode:r("attributes","modifiers","children","comments"),AttrNode:r("value"),TextNode:r(),ConcatStatement:r("parts"),SubExpression:r("path","params","hash"),PathExpression:r(),StringLiteral:r(),BooleanLiteral:r(),NumberLiteral:r(),NullLiteral:r(),UndefinedLiteral:r(),Hash:r("pairs"),HashPair:r("value")},j=function(){function t(t,e,r,i){let a=Error.call(this,t);this.key=i,this.message=t,this.node=e,this.parent=r,this.stack=a.stack}return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}();function $(t,e,r){return new j("Cannot remove a node unless it is part of an array",t,e,r)}function z(t,e,r){return new j("Cannot replace a node with multiple nodes unless it is part of an array",t,e,r)}function F(t,e){return new j("Replacing and removing in key handlers is not yet supported.",t,null,e)}class G{constructor(t,e=null,r=null){this.node=t,this.parent=e,this.parentKey=r}get parentNode(){return this.parent?this.parent.node:null}parents(){return{[Symbol.iterator]:()=>new K(this)}}}class K{constructor(t){this.path=t}next(){return this.path.parent?(this.path=this.path.parent,{done:!1,value:this.path}):{done:!0,value:null}}}function J(t){return"function"==typeof t?t:t.enter}function W(t){return"function"==typeof t?void 0:t.exit}function Q(t,e){let r,i,a,{node:n,parent:s,parentKey:o}=e,l=function(t,e){if(("Template"===e||"Block"===e)&&t.Program)return t.Program;let r=t[e];return void 0!==r?r:t.All}(t,n.type);if(void 0!==l&&(r=J(l),i=W(l)),void 0!==r&&(a=r(n,e)),null!=a){if(JSON.stringify(n)!==JSON.stringify(a)){if(Array.isArray(a))return X(t,a,s,o),a;return Q(t,new G(a,s,o))||a}a=void 0}if(void 0===a){let r=U[n.type];for(let i=0;i]/,nt=new RegExp(at.source,"g");function st(t){switch(t.charCodeAt(0)){case 160:return" ";case 34:return""";case 38:return"&";default:return t}}function ot(t){switch(t.charCodeAt(0)){case 160:return" ";case 38:return"&";case 60:return"<";case 62:return">";default:return t}}const lt=/\S/;class ct{constructor(t){this.buffer="",this.options=t}handledByOverride(t,e=!1){if(void 0!==this.options.override){let r=this.options.override(t,this.options);if("string"==typeof r)return e&<.test(r[0])&&(r=" ".concat(r)),this.buffer+=r,!0}return!1}Node(t){switch(t.type){case"MustacheStatement":case"BlockStatement":case"PartialStatement":case"MustacheCommentStatement":case"CommentStatement":case"TextNode":case"ElementNode":case"AttrNode":case"Block":case"Template":return this.TopLevelStatement(t);case"StringLiteral":case"BooleanLiteral":case"NumberLiteral":case"UndefinedLiteral":case"NullLiteral":case"PathExpression":case"SubExpression":return this.Expression(t);case"Program":return this.Block(t);case"ConcatStatement":return this.ConcatStatement(t);case"Hash":return this.Hash(t);case"HashPair":return this.HashPair(t);case"ElementModifierStatement":return this.ElementModifierStatement(t)}return ut(t,"Node")}Expression(t){switch(t.type){case"StringLiteral":case"BooleanLiteral":case"NumberLiteral":case"UndefinedLiteral":case"NullLiteral":return this.Literal(t);case"PathExpression":return this.PathExpression(t);case"SubExpression":return this.SubExpression(t)}return ut(t,"Expression")}Literal(t){switch(t.type){case"StringLiteral":return this.StringLiteral(t);case"BooleanLiteral":return this.BooleanLiteral(t);case"NumberLiteral":return this.NumberLiteral(t);case"UndefinedLiteral":return this.UndefinedLiteral(t);case"NullLiteral":return this.NullLiteral(t)}return ut(t,"Literal")}TopLevelStatement(t){switch(t.type){case"MustacheStatement":return this.MustacheStatement(t);case"BlockStatement":return this.BlockStatement(t);case"PartialStatement":return this.PartialStatement(t);case"MustacheCommentStatement":return this.MustacheCommentStatement(t);case"CommentStatement":return this.CommentStatement(t);case"TextNode":return this.TextNode(t);case"ElementNode":return this.ElementNode(t);case"Block":case"Template":return this.Block(t);case"AttrNode":return this.AttrNode(t)}ut(t,"TopLevelStatement")}Block(t){if(t.chained){t.body[0].chained=!0}this.handledByOverride(t)||this.TopLevelStatements(t.body)}TopLevelStatements(t){t.forEach(t=>this.TopLevelStatement(t))}ElementNode(t){this.handledByOverride(t)||(this.OpenElementNode(t),this.TopLevelStatements(t.children),this.CloseElementNode(t))}OpenElementNode(t){this.buffer+="<".concat(t.tag),t.attributes.length&&t.attributes.forEach(t=>{this.buffer+=" ",this.AttrNode(t)}),t.modifiers.length&&t.modifiers.forEach(t=>{this.buffer+=" ",this.ElementModifierStatement(t)}),t.comments.length&&t.comments.forEach(t=>{this.buffer+=" ",this.MustacheCommentStatement(t)}),t.blockParams.length&&this.BlockParams(t.blockParams),t.selfClosing&&(this.buffer+=" /"),this.buffer+=">"}CloseElementNode(t){t.selfClosing||Qt[t.tag.toLowerCase()]||(this.buffer+="".concat(t.tag,">"))}AttrNode(t){if(this.handledByOverride(t))return;let{name:e,value:r}=t;this.buffer+=e,("TextNode"!==r.type||r.chars.length>0)&&(this.buffer+="=",this.AttrNodeValue(r))}AttrNodeValue(t){"TextNode"===t.type?(this.buffer+='"',this.TextNode(t,!0),this.buffer+='"'):this.Node(t)}TextNode(t,e){var r;this.handledByOverride(t)||("raw"===this.options.entityEncoding?this.buffer+=t.chars:this.buffer+=e?(r=t.chars,rt.test(r)?r.replace(it,st):r):function(t){return at.test(t)?t.replace(nt,ot):t}(t.chars))}MustacheStatement(t){this.handledByOverride(t)||(this.buffer+=t.escaped?"{{":"{{{",t.strip.open&&(this.buffer+="~"),this.Expression(t.path),this.Params(t.params),this.Hash(t.hash),t.strip.close&&(this.buffer+="~"),this.buffer+=t.escaped?"}}":"}}}")}BlockStatement(t){this.handledByOverride(t)||(t.chained?(this.buffer+=t.inverseStrip.open?"{{~":"{{",this.buffer+="else "):this.buffer+=t.openStrip.open?"{{~#":"{{#",this.Expression(t.path),this.Params(t.params),this.Hash(t.hash),t.program.blockParams.length&&this.BlockParams(t.program.blockParams),t.chained?this.buffer+=t.inverseStrip.close?"~}}":"}}":this.buffer+=t.openStrip.close?"~}}":"}}",this.Block(t.program),t.inverse&&(t.inverse.chained||(this.buffer+=t.inverseStrip.open?"{{~":"{{",this.buffer+="else",this.buffer+=t.inverseStrip.close?"~}}":"}}"),this.Block(t.inverse)),t.chained||(this.buffer+=t.closeStrip.open?"{{~/":"{{/",this.Expression(t.path),this.buffer+=t.closeStrip.close?"~}}":"}}"))}BlockParams(t){this.buffer+=" as |".concat(t.join(" "),"|")}PartialStatement(t){this.handledByOverride(t)||(this.buffer+="{{>",this.Expression(t.name),this.Params(t.params),this.Hash(t.hash),this.buffer+="}}")}ConcatStatement(t){this.handledByOverride(t)||(this.buffer+='"',t.parts.forEach(t=>{"TextNode"===t.type?this.TextNode(t,!0):this.Node(t)}),this.buffer+='"')}MustacheCommentStatement(t){this.handledByOverride(t)||(this.buffer+="{{!--".concat(t.value,"--}}"))}ElementModifierStatement(t){this.handledByOverride(t)||(this.buffer+="{{",this.Expression(t.path),this.Params(t.params),this.Hash(t.hash),this.buffer+="}}")}CommentStatement(t){this.handledByOverride(t)||(this.buffer+="\x3c!--".concat(t.value,"--\x3e"))}PathExpression(t){this.handledByOverride(t)||(this.buffer+=t.original)}SubExpression(t){this.handledByOverride(t)||(this.buffer+="(",this.Expression(t.path),this.Params(t.params),this.Hash(t.hash),this.buffer+=")")}Params(t){t.length&&t.forEach(t=>{this.buffer+=" ",this.Expression(t)})}Hash(t){this.handledByOverride(t,!0)||t.pairs.forEach(t=>{this.buffer+=" ",this.HashPair(t)})}HashPair(t){this.handledByOverride(t)||(this.buffer+=t.key,this.buffer+="=",this.Node(t.value))}StringLiteral(t){this.handledByOverride(t)||(this.buffer+=JSON.stringify(t.value))}BooleanLiteral(t){this.handledByOverride(t)||(this.buffer+=t.value)}NumberLiteral(t){this.handledByOverride(t)||(this.buffer+=t.value)}UndefinedLiteral(t){this.handledByOverride(t)||(this.buffer+="undefined")}NullLiteral(t){this.handledByOverride(t)||(this.buffer+="null")}print(t){let{options:e}=this;if(e.override){let r=e.override(t,e);if(void 0!==r)return r}return this.buffer="",this.Node(t),this.buffer}}function ut(t,e){let{loc:r,type:i}=t;throw new Error("Non-exhaustive node narrowing ".concat(i," @ location: ").concat(JSON.stringify(r)," for parent ").concat(e))}function ht(t,e={entityEncoding:"transformed"}){if(!t)return"";return new ct(e).print(t)}class pt{constructor(t){this.order=t,this.stack=[]}visit(t,e){t&&(this.stack.push(t),"post"===this.order?(this.children(t,e),e(t,this)):(e(t,this),this.children(t,e)),this.stack.pop())}children(t,e){let r;r="Block"===t.type||"Template"===t.type&&dt.Program?"Program":t.type;let i=dt[r];i&&i(this,t,e)}}let dt={Program(t,e,r){for(let i=0;i":">",'"':""","'":"'","`":"`","=":"="},i=/[&<>"'`=]/g,a=/[&<>"'`=]/;function n(t){return r[t]}function s(t){for(var e=1;e0?(r.ids&&(r.ids=[r.name]),t.helpers.each(e,r)):i(this);if(r.data&&r.ids){var n=bt.createFrame(r.data);n.contextPath=bt.appendContextPath(r.data.contextPath,r.name),r={data:n}}return a(e,r)}))},t.exports=e.default}));mt(yt);var kt=gt((function(t,e){e.__esModule=!0;var r,i=(r=vt)&&r.__esModule?r:{default:r};e.default=function(t){t.registerHelper("each",(function(t,e){if(!e)throw new i.default("Must pass iterator to #each");var r,a=e.fn,n=e.inverse,s=0,o="",l=void 0,c=void 0;function u(e,r,i){l&&(l.key=e,l.index=r,l.first=0===r,l.last=!!i,c&&(l.contextPath=c+e)),o+=a(t[e],{data:l,blockParams:bt.blockParams([t[e],e],[c+e,null])})}if(e.data&&e.ids&&(c=bt.appendContextPath(e.data.contextPath,e.ids[0])+"."),bt.isFunction(t)&&(t=t.call(this)),e.data&&(l=bt.createFrame(e.data)),t&&"object"==typeof t)if(bt.isArray(t))for(var h=t.length;s=0?e:parseInt(t,10)}return t},log:function(t){if(t=r.lookupLevel(t),"undefined"!=typeof console&&r.lookupLevel(r.level)<=t){var e=r.methodMap[t];console[e]||(e="log");for(var i=arguments.length,a=Array(i>1?i-1:0),n=1;n= 2.0.0-beta.1",7:">= 4.0.0 <4.3.0",8:">= 4.3.0"};function n(t,e,r){this.helpers=t||{},this.partials=e||{},this.decorators=r||{},Nt.registerDefaultHelpers(this),At.registerDefaultDecorators(this)}n.prototype={constructor:n,logger:a.default,log:a.default.log,registerHelper:function(t,e){if("[object Object]"===bt.toString.call(t)){if(e)throw new i.default("Arg not supported with multiple helpers");bt.extend(this.helpers,t)}else this.helpers[t]=e},unregisterHelper:function(t){delete this.helpers[t]},registerPartial:function(t,e){if("[object Object]"===bt.toString.call(t))bt.extend(this.partials,t);else{if(void 0===e)throw new i.default('Attempting to register a partial called "'+t+'" as undefined');this.partials[t]=e}},unregisterPartial:function(t){delete this.partials[t]},registerDecorator:function(t,e){if("[object Object]"===bt.toString.call(t)){if(e)throw new i.default("Arg not supported with multiple decorators");bt.extend(this.decorators,t)}else this.decorators[t]=e},unregisterDecorator:function(t){delete this.decorators[t]},resetLoggedPropertyAccesses:function(){Ct.resetLoggedProperties()}};var s=a.default.log;e.log=s,e.createFrame=bt.createFrame,e.logger=a.default}));mt(Dt);Dt.HandlebarsEnvironment,Dt.VERSION,Dt.COMPILER_REVISION,Dt.LAST_COMPATIBLE_COMPILER_REVISION,Dt.REVISION_CHANGES,Dt.log,Dt.createFrame,Dt.logger;var qt=gt((function(t,e){function r(t){this.string=t}e.__esModule=!0,r.prototype.toString=r.prototype.toHTML=function(){return""+this.string},e.default=r,t.exports=e.default}));mt(qt);var Ot=gt((function(t,e){e.__esModule=!0,e.wrapHelper=function(t,e){if("function"!=typeof t)return t;return function(){var r=arguments[arguments.length-1];return arguments[arguments.length-1]=e(r),t.apply(this,arguments)}}}));mt(Ot);Ot.wrapHelper;var Bt=gt((function(t,e){e.__esModule=!0,e.checkRevision=function(t){var e=t&&t[0]||1,r=Dt.COMPILER_REVISION;if(e>=Dt.LAST_COMPATIBLE_COMPILER_REVISION&&e<=Dt.COMPILER_REVISION)return;if(e2&&y.push("'"+this.terminals_[g]+"'");w=this.lexer.showPosition?"Parse error on line "+(o+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+y.join(", ")+", got '"+(this.terminals_[p]||p)+"'":"Parse error on line "+(o+1)+": Unexpected "+(1==p?"end of input":"'"+(this.terminals_[p]||p)+"'"),this.parseError(w,{text:this.lexer.match,token:this.terminals_[p]||p,line:this.lexer.yylineno,loc:u,expected:y})}}if(f[0]instanceof Array&&f.length>1)throw new Error("Parse Error: multiple actions possible at state: "+d+", token: "+p);switch(f[0]){case 1:r.push(p),i.push(this.lexer.yytext),a.push(this.lexer.yylloc),r.push(f[1]),p=null,l=this.lexer.yyleng,s=this.lexer.yytext,o=this.lexer.yylineno,u=this.lexer.yylloc,c>0&&c--;break;case 2:if(b=this.productions_[f[1]][1],S.$=i[i.length-b],S._$={first_line:a[a.length-(b||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(b||1)].first_column,last_column:a[a.length-1].last_column},h&&(S._$.range=[a[a.length-(b||1)].range[0],a[a.length-1].range[1]]),void 0!==(m=this.performAction.call(S,s,l,o,this.yy,f[1],i,a)))return m;b&&(r=r.slice(0,-1*b*2),i=i.slice(0,-1*b),a=a.slice(0,-1*b)),r.push(this.productions_[f[1]][0]),i.push(S.$),a.push(S._$),v=n[r[r.length-2]][r[r.length-1]],r.push(v);break;case 3:return!0}}return!0}},e=function(){var t={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t){return this._input=t,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,r=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e-1),this.offset-=e;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),r.length-1&&(this.yylineno-=r.length-1);var a=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:r?(r.length===i.length?this.yylloc.first_column:0)+i[i.length-r.length].length-r[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[a[0],a[0]+this.yyleng-e]),this},more:function(){return this._more=!0,this},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},next:function(){if(this.done)return this.EOF;var t,e,r,i,a;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var n=this._currentRules(),s=0;se[0].length)||(e=r,i=s,this.options.flex));s++);return e?((a=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=a.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:a?a[a.length-1].length-a[a.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],t=this.performAction.call(this,this.yy,this,n[i],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),t||void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return void 0!==t?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(t){this.begin(t)},options:{},performAction:function(t,e,r,i){function a(t,r){return e.yytext=e.yytext.substring(t,e.yyleng-r+t)}switch(r){case 0:if("\\\\"===e.yytext.slice(-2)?(a(0,1),this.begin("mu")):"\\"===e.yytext.slice(-1)?(a(0,1),this.begin("emu")):this.begin("mu"),e.yytext)return 15;break;case 1:return 15;case 2:return this.popState(),15;case 3:return this.begin("raw"),15;case 4:return this.popState(),"raw"===this.conditionStack[this.conditionStack.length-1]?15:(a(5,9),"END_RAW_BLOCK");case 5:return 15;case 6:return this.popState(),14;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:case 16:return this.popState(),44;case 17:return 34;case 18:return 39;case 19:return 51;case 20:return 48;case 21:this.unput(e.yytext),this.popState(),this.begin("com");break;case 22:return this.popState(),14;case 23:return 48;case 24:return 73;case 25:case 26:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;case 30:return this.popState(),33;case 31:return e.yytext=a(1,2).replace(/\\"/g,'"'),80;case 32:return e.yytext=a(1,2).replace(/\\'/g,"'"),80;case 33:return 85;case 34:case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 41:return 72;case 42:return e.yytext=e.yytext.replace(/\\([\\\]])/g,"$1"),72;case 43:return"INVALID";case 44:return 5}},rules:[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^\/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]+?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],conditions:{mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}}};return t}();function r(){this.yy={}}return t.lexer=e,r.prototype=t,t.Parser=r,new r}();e.default=r,t.exports=e.default}));mt(Mt);var Ht=gt((function(t,e){e.__esModule=!0;var r,i=(r=vt)&&r.__esModule?r:{default:r};function a(){this.parents=[]}function n(t){this.acceptRequired(t,"path"),this.acceptArray(t.params),this.acceptKey(t,"hash")}function s(t){n.call(this,t),this.acceptKey(t,"program"),this.acceptKey(t,"inverse")}function o(t){this.acceptRequired(t,"name"),this.acceptArray(t.params),this.acceptKey(t,"hash")}a.prototype={constructor:a,mutating:!1,acceptKey:function(t,e){var r=this.accept(t[e]);if(this.mutating){if(r&&!a.prototype[r.type])throw new i.default('Unexpected node type "'+r.type+'" found when accepting '+e+" on "+t.type);t[e]=r}},acceptRequired:function(t,e){if(this.acceptKey(t,e),!t[e])throw new i.default(t.type+" requires "+e)},acceptArray:function(t){for(var e=0,r=t.length;e0)throw new i.default("Invalid path: "+a,{loc:r});".."===c&&s++}}return{type:"PathExpression",data:t,depth:s,parts:n,original:a,loc:r}},e.prepareMustache=function(t,e,r,i,a,n){var s=i.charAt(3)||i.charAt(2),o="{"!==s&&"&"!==s;return{type:/\*/.test(i)?"Decorator":"MustacheStatement",path:t,params:e,hash:r,escaped:o,strip:a,loc:this.locInfo(n)}},e.prepareRawBlock=function(t,e,r,i){a(t,r),i=this.locInfo(i);var n={type:"Program",body:e,strip:{},loc:i};return{type:"BlockStatement",path:t.path,params:t.params,hash:t.hash,program:n,openStrip:{},inverseStrip:{},closeStrip:{},loc:i}},e.prepareBlock=function(t,e,r,n,s,o){n&&n.path&&a(t,n);var l=/\*/.test(t.open);e.blockParams=t.blockParams;var c=void 0,u=void 0;if(r){if(l)throw new i.default("Unexpected inverse block on decorator",r);r.chain&&(r.program.body[0].closeStrip=n.strip),u=r.strip,c=r.program}s&&(s=c,c=e,e=s);return{type:l?"DecoratorBlock":"BlockStatement",path:t.path,params:t.params,hash:t.hash,program:e,inverse:c,openStrip:t.strip,inverseStrip:u,closeStrip:n&&n.strip,loc:this.locInfo(o)}},e.prepareProgram=function(t,e){if(!e&&t.length){var r=t[0].loc,i=t[t.length-1].loc;r&&i&&(e={source:r.source,start:{line:r.start.line,column:r.start.column},end:{line:i.end.line,column:i.end.column}})}return{type:"Program",body:t,strip:{},loc:e}},e.preparePartialBlock=function(t,e,r,i){return a(t,r),{type:"PartialBlockStatement",name:t.path,params:t.params,hash:t.hash,program:e,openStrip:t.strip,closeStrip:r&&r.strip,loc:this.locInfo(i)}};var r,i=(r=vt)&&r.__esModule?r:{default:r};function a(t,e){if(e=e.path?e.path.original:e,t.path.original!==e){var r={loc:t.path.loc};throw new i.default(t.path.original+" doesn't match "+e,r)}}}));mt(jt);jt.SourceLocation,jt.id,jt.stripFlags,jt.stripComment,jt.preparePath,jt.prepareMustache,jt.prepareRawBlock,jt.prepareBlock,jt.prepareProgram,jt.preparePartialBlock;var $t=gt((function(t,e){function r(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0,e.parseWithoutProcessing=o,e.parse=function(t,e){var r=o(t,e);return new a.default(e).accept(r)};var i=r(Mt),a=r(Ut),n=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}(jt);e.parser=i.default;var s={};function o(t,e){return"Program"===t.type?t:(i.default.yy=s,s.locInfo=function(t){return new s.SourceLocation(e&&e.srcName,t)},i.default.parse(t))}bt.extend(s,n)}));mt($t);$t.parseWithoutProcessing,$t.parse,$t.parser;var zt=gt((function(t,e){function r(t){return t&&t.__esModule?t:{default:t}}e.__esModule=!0,e.Compiler=s,e.precompile=function(t,e,r){if(null==t||"string"!=typeof t&&"Program"!==t.type)throw new i.default("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+t);"data"in(e=e||{})||(e.data=!0);e.compat&&(e.useDepths=!0);var a=r.parse(t,e),n=(new r.Compiler).compile(a,e);return(new r.JavaScriptCompiler).compile(n,e)},e.compile=function(t,e,r){void 0===e&&(e={});if(null==t||"string"!=typeof t&&"Program"!==t.type)throw new i.default("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+t);"data"in(e=bt.extend({},e))||(e.data=!0);e.compat&&(e.useDepths=!0);var a=void 0;function n(){var i=r.parse(t,e),a=(new r.Compiler).compile(i,e),n=(new r.JavaScriptCompiler).compile(a,e,void 0,!0);return r.template(n)}function s(t,e){return a||(a=n()),a.call(this,t,e)}return s._setup=function(t){return a||(a=n()),a._setup(t)},s._child=function(t,e,r,i){return a||(a=n()),a._child(t,e,r,i)},s};var i=r(vt),a=r(Vt),n=[].slice;function s(){}function o(t,e){if(t===e)return!0;if(bt.isArray(t)&&bt.isArray(e)&&t.length===e.length){for(var r=0;r1)throw new i.default("Unsupported number of partial arguments: "+r.length,t);r.length||(this.options.explicitPartialContext?this.opcode("pushLiteral","undefined"):r.push({type:"PathExpression",parts:[],depth:0}));var a=t.name.original,n="SubExpression"===t.name.type;n&&this.accept(t.name),this.setupFullMustacheParams(t,e,void 0,!0);var s=t.indent||"";this.options.preventIndent&&s&&(this.opcode("appendContent",s),s=""),this.opcode("invokePartial",n,a,s),this.opcode("append")},PartialBlockStatement:function(t){this.PartialStatement(t)},MustacheStatement:function(t){this.SubExpression(t),t.escaped&&!this.options.noEscape?this.opcode("appendEscaped"):this.opcode("append")},Decorator:function(t){this.DecoratorBlock(t)},ContentStatement:function(t){t.value&&this.opcode("appendContent",t.value)},CommentStatement:function(){},SubExpression:function(t){l(t);var e=this.classifySexpr(t);"simple"===e?this.simpleSexpr(t):"helper"===e?this.helperSexpr(t):this.ambiguousSexpr(t)},ambiguousSexpr:function(t,e,r){var i=t.path,a=i.parts[0],n=null!=e||null!=r;this.opcode("getContext",i.depth),this.opcode("pushProgram",e),this.opcode("pushProgram",r),i.strict=!0,this.accept(i),this.opcode("invokeAmbiguous",a,n)},simpleSexpr:function(t){var e=t.path;e.strict=!0,this.accept(e),this.opcode("resolvePossibleLambda")},helperSexpr:function(t,e,r){var n=this.setupFullMustacheParams(t,e,r),s=t.path,o=s.parts[0];if(this.options.knownHelpers[o])this.opcode("invokeKnownHelper",n.length,o);else{if(this.options.knownHelpersOnly)throw new i.default("You specified knownHelpersOnly, but used the unknown helper "+o,t);s.strict=!0,s.falsy=!0,this.accept(s),this.opcode("invokeHelper",n.length,s.original,a.default.helpers.simpleId(s))}},PathExpression:function(t){this.addDepth(t.depth),this.opcode("getContext",t.depth);var e=t.parts[0],r=a.default.helpers.scopedId(t),i=!t.depth&&!r&&this.blockParamIndex(e);i?this.opcode("lookupBlockParam",i,t.parts):e?t.data?(this.options.data=!0,this.opcode("lookupData",t.depth,t.parts,t.strict)):this.opcode("lookupOnContext",t.parts,t.falsy,t.strict,r):this.opcode("pushContext")},StringLiteral:function(t){this.opcode("pushString",t.value)},NumberLiteral:function(t){this.opcode("pushLiteral",t.value)},BooleanLiteral:function(t){this.opcode("pushLiteral",t.value)},UndefinedLiteral:function(){this.opcode("pushLiteral","undefined")},NullLiteral:function(){this.opcode("pushLiteral","null")},Hash:function(t){var e=t.pairs,r=0,i=e.length;for(this.opcode("pushHash");r=0)return[e,a]}}}}));mt(zt);zt.Compiler,zt.precompile,zt.compile;var Ft=gt((function(t,e){e.__esModule=!0;var r=void 0;try{var i=require("source-map");r=i.SourceNode}catch(t){}function a(t,e,r){if(bt.isArray(t)){for(var i=[],a=0,n=t.length;a0&&(r+=", "+i.join(", "));var a=0;Object.keys(this.aliases).forEach((function(t){var i=e.aliases[t];i.children&&i.referenceCount>1&&(r+=", alias"+ ++a+"="+t,i.children[0]="alias"+a)})),this.lookupPropertyFunctionIsUsed&&(r+=", "+this.lookupPropertyFunctionVarDeclaration());var n=["container","depth0","helpers","partials","data"];(this.useBlockParams||this.useDepths)&&n.push("blockParams"),this.useDepths&&n.push("depths");var s=this.mergeSource(r);return t?(n.push(s),Function.apply(this,n)):this.source.wrap(["function(",n.join(","),") {\n ",s,"}"])},mergeSource:function(t){var e=this.environment.isSimple,r=!this.forceBuffer,i=void 0,a=void 0,n=void 0,s=void 0;return this.source.each((function(t){t.appendToBuffer?(n?t.prepend(" + "):n=t,s=t):(n&&(a?n.prepend("buffer += "):i=!0,s.add(";"),n=s=void 0),a=!0,e||(r=!1))})),r?n?(n.prepend("return "),s.add(";")):a||this.source.push('return "";'):(t+=", buffer = "+(i?"":this.initializeBuffer()),n?(n.prepend("return buffer + "),s.add(";")):this.source.push("return buffer;")),t&&this.source.prepend("var "+t.substring(2)+(i?"":";\n")),this.source.merge()},lookupPropertyFunctionVarDeclaration:function(){return"\n lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n }\n ".trim()},blockValue:function(t){var e=this.aliasable("container.hooks.blockHelperMissing"),r=[this.contextName(0)];this.setupHelperArgs(t,0,r);var i=this.popStack();r.splice(1,0,i),this.push(this.source.functionCall(e,"call",r))},ambiguousBlockValue:function(){var t=this.aliasable("container.hooks.blockHelperMissing"),e=[this.contextName(0)];this.setupHelperArgs("",0,e,!0),this.flushInline();var r=this.topStack();e.splice(1,0,r),this.pushSource(["if (!",this.lastHelper,") { ",r," = ",this.source.functionCall(t,"call",e),"}"])},appendContent:function(t){this.pendingContent?t=this.pendingContent+t:this.pendingLocation=this.source.currentLocation,this.pendingContent=t},append:function(){if(this.isInline())this.replaceStack((function(t){return[" != null ? ",t,' : ""']})),this.pushSource(this.appendToBuffer(this.popStack()));else{var t=this.popStack();this.pushSource(["if (",t," != null) { ",this.appendToBuffer(t,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(t){this.lastContext=t},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(t,e,r,i){var a=0;i||!this.options.compat||this.lastContext?this.pushContext():this.push(this.depthedLookup(t[a++])),this.resolvePath("context",t,a,e,r)},lookupBlockParam:function(t,e){this.useBlockParams=!0,this.push(["blockParams[",t[0],"][",t[1],"]"]),this.resolvePath("context",e,1)},lookupData:function(t,e,r){t?this.pushStackLiteral("container.data(data, "+t+")"):this.pushStackLiteral("data"),this.resolvePath("data",e,0,!0,r)},resolvePath:function(t,e,r,i,a){var n=this;if(this.options.strict||this.options.assumeObjects)this.push(function(t,e,r,i){var a=e.popStack(),n=0,s=r.length;t&&s--;for(;nthis.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var t=this.inlineStack;this.inlineStack=[];for(var e=0,r=t.length;e{Qt[t]=!0});class Yt extends class extends class{constructor(t,e=new C(L)){this.elementStack=[],this.currentAttribute=null,this.currentNode=null,this.source=t.split(/(?:\r\n?|\n)/g),this.tokenizer=new R(this,e)}get currentAttr(){return this.currentAttribute}get currentTag(){return this.currentNode}get currentStartTag(){return this.currentNode}get currentEndTag(){return this.currentNode}get currentComment(){return this.currentNode}get currentData(){return this.currentNode}acceptTemplate(t){return this[t.type](t)}acceptNode(t){return this[t.type](t)}currentElement(){return this.elementStack[this.elementStack.length-1]}sourceForNode(t,e){let r,i,a,n=t.loc.start.line-1,s=n-1,o=t.loc.start.column,l=[];for(e?(i=e.loc.end.line-1,a=e.loc.end.column):(i=t.loc.end.line-1,a=t.loc.end.column);s{if("guid"===t.key)throw new S("Cannot pass `guid` from user space",r);"insertBefore"===t.key&&(i=!0)});let a=y.literal("StringLiteral",t),n=y.pair("guid",a);if(e.pairs.unshift(n),!i){let t=y.literal("UndefinedLiteral",void 0),r=y.pair("insertBefore",t);e.pairs.push(r)}return e}(this.cursor(),i,t.loc));let s=y.block(e,r,i,a,n,t.loc,t.openStrip,t.inverseStrip,t.closeStrip);E(this.currentElement(),s)}MustacheStatement(t){let e,{tokenizer:r}=this;if("comment"===r.state)return void this.appendToCommentData(this.sourceForNode(t));let{escaped:i,loc:a,strip:n}=t;if(P(t.path))e={type:"MustacheStatement",path:this.acceptNode(t.path),params:[],hash:y.hash(),escaped:i,loc:a,strip:n};else{let{path:r,params:s,hash:o}=V(this,t);e=y.mustache(r,s,o,!i,a,n)}switch(r.state){case"tagOpen":case"tagName":throw new S("Cannot use mustaches in an elements tagname: `".concat(this.sourceForNode(t,t.path),"` at L").concat(a.start.line,":C").concat(a.start.column),e.loc);case"beforeAttributeName":M(this.currentStartTag,e);break;case"attributeName":case"afterAttributeName":this.beginAttributeValue(!1),this.finishAttributeValue(),M(this.currentStartTag,e),r.transitionTo("beforeAttributeName");break;case"afterAttributeValueQuoted":M(this.currentStartTag,e),r.transitionTo("beforeAttributeName");break;case"beforeAttributeValue":this.beginAttributeValue(!1),H(this.currentAttribute,e),r.transitionTo("attributeValueUnquoted");break;case"attributeValueDoubleQuoted":case"attributeValueSingleQuoted":case"attributeValueUnquoted":H(this.currentAttribute,e);break;default:E(this.currentElement(),e)}return e}ContentStatement(t){!function(t,e){let r=e.loc.start.line,i=e.loc.start.column,a=function(t,e){if(""===e)return{lines:t.split("\n").length-1,columns:0};let r=t.split(e)[0].split(/\n/),i=r.length-1;return{lines:i,columns:r[i].length}}(e.original,e.value);r+=a.lines,a.lines?i=a.columns:i+=a.columns;t.line=r,t.column=i}(this.tokenizer,t),this.tokenizer.tokenizePart(t.value),this.tokenizer.flushData()}CommentStatement(t){let{tokenizer:e}=this;if("comment"===e.state)return this.appendToCommentData(this.sourceForNode(t)),null;let{value:r,loc:i}=t,a=y.mustacheComment(r,i);switch(e.state){case"beforeAttributeName":this.currentStartTag.comments.push(a);break;case"beforeData":case"data":E(this.currentElement(),a);break;default:throw new S("Using a Handlebars comment when in the `".concat(e.state,'` state is not supported: "').concat(a.value,'" on line ').concat(i.start.line,":").concat(i.start.column),t.loc)}return a}PartialStatement(t){let{loc:e}=t;throw new S('Handlebars partials are not supported: "'.concat(this.sourceForNode(t,t.name),'" at L').concat(e.start.line,":C").concat(e.start.column),t.loc)}PartialBlockStatement(t){let{loc:e}=t;throw new S('Handlebars partial blocks are not supported: "'.concat(this.sourceForNode(t,t.name),'" at L').concat(e.start.line,":C").concat(e.start.column),t.loc)}Decorator(t){let{loc:e}=t;throw new S('Handlebars decorators are not supported: "'.concat(this.sourceForNode(t,t.path),'" at L').concat(e.start.line,":C").concat(e.start.column),t.loc)}DecoratorBlock(t){let{loc:e}=t;throw new S('Handlebars decorator blocks are not supported: "'.concat(this.sourceForNode(t,t.path),'" at L').concat(e.start.line,":C").concat(e.start.column),t.loc)}SubExpression(t){let{path:e,params:r,hash:i}=V(this,t);return y.sexpr(e,r,i,t.loc)}PathExpression(t){let e,{original:r,loc:i}=t;if(-1!==r.indexOf("/")){if("./"===r.slice(0,2))throw new S('Using "./" is not supported in Glimmer and unnecessary: "'.concat(t.original,'" on line ').concat(i.start.line,"."),t.loc);if("../"===r.slice(0,3))throw new S('Changing context using "../" is not supported in Glimmer: "'.concat(t.original,'" on line ').concat(i.start.line,"."),t.loc);if(-1!==r.indexOf("."))throw new S("Mixing '.' and '/' in paths is not supported in Glimmer; use only '.' to separate property paths: \"".concat(t.original,'" on line ').concat(i.start.line,"."),t.loc);e=[t.parts.join("/")]}else{if("."===r){let e="L".concat(i.start.line,":C").concat(i.start.column);throw new S("'.' is not a supported path in Glimmer; check for a path with a trailing '.' at ".concat(e,"."),t.loc)}e=t.parts}let a=!1;return r.match(/^this(\..+)?$/)&&(a=!0),{type:"PathExpression",original:t.original,this:a,parts:e,data:t.data,loc:t.loc}}Hash(t){let e=[];for(let r=0;r' character, or '/>' (on line ".concat(i,")"),y.loc(i,0))}return t.length>0?t[0]:y.text("")}(e,r,i,this.tokenizer.line);s.loc=y.loc(a,n,this.tokenizer.line,this.tokenizer.column);let o=y.loc(this.currentAttr.start.line,this.currentAttr.start.column,this.tokenizer.line,this.tokenizer.column),l=y.attr(t,s,o);this.currentStartTag.attributes.push(l)}reportSyntaxError(t){throw new S("Syntax error at line ".concat(this.tokenizer.line," col ").concat(this.tokenizer.column,": ").concat(t),y.loc(this.tokenizer.line,this.tokenizer.column))}}function Zt(t){return"`"+t.name+"` (on line "+t.loc.end.line+")"}const Xt={parse:te,builders:y,print:ht,traverse:et,Walker:pt};function te(t,e={}){let r,i=e.mode||"precompile";r="object"==typeof t?t:"codemod"===i?Wt(t,e.parseOptions):Jt(t,e.parseOptions);let n=void 0;"codemod"===i&&(n=new C({}));let s=new Yt(t,n).acceptTemplate(r);if(e&&e.plugins&&e.plugins.ast)for(let t=0,r=e.plugins.ast.length;t