+ *
+ * 123
+ */
+ return !node.next && !node.hasTrailingSpaces && node.isTrailingSpaceSensitive && getLastDescendant(node).type === "text";
+}
+
+function printOpeningTagPrefix(node) {
+ return needsToBorrowParentOpeningTagEndMarker(node) ? printOpeningTagEndMarker(node.parent) : needsToBorrowPrevClosingTagEndMarker(node) ? printClosingTagEndMarker(node.prev) : "";
+}
+
+function printClosingTagPrefix(node) {
+ return needsToBorrowLastChildClosingTagEndMarker(node) ? printClosingTagEndMarker(node.lastChild) : "";
+}
+
+function printClosingTagSuffix(node) {
+ return needsToBorrowParentClosingTagStartMarker(node) ? printClosingTagStartMarker(node.parent) : needsToBorrowNextOpeningTagStartMarker(node) ? printOpeningTagStartMarker(node.next) : "";
+}
+
+function printOpeningTagStartMarker(node) {
+ switch (node.type) {
+ case "comment":
+ return "";
+
+ case "ieConditionalComment":
+ return "[endif]-->";
+
+ case "interpolation":
+ return "}}";
+
+ case "element":
+ if (node.isSelfClosing) {
+ return "/>";
+ }
+
+ // fall through
+
+ default:
+ return ">";
+ }
+}
+
+function getTextValueParts(node) {
+ var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node.value;
+ return node.isWhitespaceSensitive ? node.isIndentationSensitive ? replaceNewlines(value, literalline$2) : replaceNewlines(dedentString(value.replace(/^\s*?\n|\n\s*?$/g, "")), hardline$7) : // non-breaking whitespace: 0xA0
+ join$5(line$6, value.split(/[^\S\xA0]+/)).parts;
+}
+
+function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
+ var isKeyMatched = function isKeyMatched(patterns) {
+ return new RegExp(patterns.join("|")).test(node.fullName);
+ };
+
+ var getValue = function getValue() {
+ return node.value.replace(/"/g, '"').replace(/'/g, "'");
+ };
+
+ var shouldHug = false;
+
+ var __onHtmlBindingRoot = function __onHtmlBindingRoot(root) {
+ var rootNode = root.type === "NGRoot" ? root.node.type === "NGMicrosyntax" && root.node.body.length === 1 && root.node.body[0].type === "NGMicrosyntaxExpression" ? root.node.body[0].expression : root.node : root.type === "JsExpressionRoot" ? root.node : root;
+
+ if (rootNode && (rootNode.type === "ObjectExpression" || rootNode.type === "ArrayExpression")) {
+ shouldHug = true;
+ }
+ };
+
+ var printHug = function printHug(doc$$2) {
+ return group$8(doc$$2);
+ };
+
+ var printExpand = function printExpand(doc$$2) {
+ return group$8(concat$8([indent$5(concat$8([softline$4, doc$$2])), softline$4]));
+ };
+
+ var printMaybeHug = function printMaybeHug(doc$$2) {
+ return shouldHug ? printHug(doc$$2) : printExpand(doc$$2);
+ };
+
+ var textToDoc = function textToDoc(code, opts) {
+ return originalTextToDoc(code, Object.assign({
+ __onHtmlBindingRoot: __onHtmlBindingRoot
+ }, opts));
+ };
+
+ if (node.fullName === "srcset" && (node.parent.fullName === "img" || node.parent.fullName === "source")) {
+ return printExpand(printImgSrcset(getValue()));
+ }
+
+ if (options.parser === "vue") {
+ if (node.fullName === "v-for") {
+ return printVueFor(getValue(), textToDoc);
+ }
+
+ if (node.fullName === "slot-scope") {
+ return printVueSlotScope(getValue(), textToDoc);
+ }
+ /**
+ * @click="jsStatement"
+ * @click="jsExpression"
+ * v-on:click="jsStatement"
+ * v-on:click="jsExpression"
+ */
+
+
+ var vueEventBindingPatterns = ["^@", "^v-on:"];
+ /**
+ * :class="vueExpression"
+ * v-bind:id="vueExpression"
+ */
+
+ var vueExpressionBindingPatterns = ["^:", "^v-bind:"];
+ /**
+ * v-if="jsExpression"
+ */
+
+ var jsExpressionBindingPatterns = ["^v-"];
+
+ if (isKeyMatched(vueEventBindingPatterns)) {
+ // copied from https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/codegen/events.js#L3-L4
+ var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
+ var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
+ var value = getValue() // https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
+ .trim();
+ return printMaybeHug(simplePathRE.test(value) || fnExpRE.test(value) ? textToDoc(value, {
+ parser: "__js_expression"
+ }) : stripTrailingHardline$1(textToDoc(value, {
+ parser: "babylon"
+ })));
+ }
+
+ if (isKeyMatched(vueExpressionBindingPatterns)) {
+ return printMaybeHug(textToDoc(getValue(), {
+ parser: "__vue_expression"
+ }));
+ }
+
+ if (isKeyMatched(jsExpressionBindingPatterns)) {
+ return printMaybeHug(textToDoc(getValue(), {
+ parser: "__js_expression"
+ }));
+ }
+ }
+
+ if (options.parser === "angular") {
+ var ngTextToDoc = function ngTextToDoc(code, opts) {
+ return (// angular does not allow trailing comma
+ textToDoc(code, Object.assign({
+ trailingComma: "none"
+ }, opts))
+ );
+ };
+ /**
+ * *directive="angularDirective"
+ */
+
+
+ var ngDirectiveBindingPatterns = ["^\\*"];
+ /**
+ * (click)="angularStatement"
+ * on-click="angularStatement"
+ */
+
+ var ngStatementBindingPatterns = ["^\\(.+\\)$", "^on-"];
+ /**
+ * [target]="angularExpression"
+ * bind-target="angularExpression"
+ * [(target)]="angularExpression"
+ * bindon-target="angularExpression"
+ */
+
+ var ngExpressionBindingPatterns = ["^\\[.+\\]$", "^bind(on)?-"];
+
+ if (isKeyMatched(ngStatementBindingPatterns)) {
+ return printMaybeHug(ngTextToDoc(getValue(), {
+ parser: "__ng_action"
+ }));
+ }
+
+ if (isKeyMatched(ngExpressionBindingPatterns)) {
+ return printMaybeHug(ngTextToDoc(getValue(), {
+ parser: "__ng_binding"
+ }));
+ }
+
+ if (isKeyMatched(ngDirectiveBindingPatterns)) {
+ return printMaybeHug(ngTextToDoc(getValue(), {
+ parser: "__ng_directive"
+ }));
+ }
+ }
+
+ return null;
+}
+
+var printerHtml = {
+ preprocess: preprocess_1,
+ print: genericPrint$2,
+ insertPragma: insertPragma$5,
+ massageAstNode: clean$4,
+ embed: embed$2
+};
+
+var CATEGORY_HTML = "HTML"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
+
+var options$9 = {
+ htmlWhitespaceSensitivity: {
+ since: "1.15.0",
+ category: CATEGORY_HTML,
+ type: "choice",
+ default: "css",
+ description: "How to handle whitespaces in HTML.",
+ choices: [{
+ value: "css",
+ description: "Respect the default value of CSS display property."
+ }, {
+ value: "strict",
+ description: "Whitespaces are considered sensitive."
+ }, {
+ value: "ignore",
+ description: "Whitespaces are considered insensitive."
+ }]
+ }
+};
+
+var name$7 = "HTML";
+var type$6 = "markup";
+var tmScope$6 = "text.html.basic";
+var aceMode$6 = "html";
+var codemirrorMode$3 = "htmlmixed";
+var codemirrorMimeType$3 = "text/html";
+var color$1 = "#e34c26";
+var aliases$1 = ["xhtml"];
+var extensions$6 = [".html", ".htm", ".html.hl", ".inc", ".st", ".xht", ".xhtml"];
+var languageId$6 = 146;
+var html$1 = {
+ name: name$7,
+ type: type$6,
+ tmScope: tmScope$6,
+ aceMode: aceMode$6,
+ codemirrorMode: codemirrorMode$3,
+ codemirrorMimeType: codemirrorMimeType$3,
+ color: color$1,
+ aliases: aliases$1,
+ extensions: extensions$6,
+ languageId: languageId$6
+};
+
+var html$2 = Object.freeze({
+ name: name$7,
+ type: type$6,
+ tmScope: tmScope$6,
+ aceMode: aceMode$6,
+ codemirrorMode: codemirrorMode$3,
+ codemirrorMimeType: codemirrorMimeType$3,
+ color: color$1,
+ aliases: aliases$1,
+ extensions: extensions$6,
+ languageId: languageId$6,
+ default: html$1
+});
+
+var name$8 = "Vue";
+var type$7 = "markup";
+var color$2 = "#2c3e50";
+var extensions$7 = [".vue"];
+var tmScope$7 = "text.html.vue";
+var aceMode$7 = "html";
+var languageId$7 = 391;
+var vue = {
+ name: name$8,
+ type: type$7,
+ color: color$2,
+ extensions: extensions$7,
+ tmScope: tmScope$7,
+ aceMode: aceMode$7,
+ languageId: languageId$7
+};
+
+var vue$1 = Object.freeze({
+ name: name$8,
+ type: type$7,
+ color: color$2,
+ extensions: extensions$7,
+ tmScope: tmScope$7,
+ aceMode: aceMode$7,
+ languageId: languageId$7,
+ default: vue
+});
+
+var require$$0$20 = ( html$2 && html$1 ) || html$2;
+
+var require$$1$11 = ( vue$1 && vue ) || vue$1;
+
+var languages$3 = [createLanguage(require$$0$20, {
+ override: {
+ name: "Angular",
+ since: "1.15.0",
+ parsers: ["angular"],
+ vscodeLanguageIds: ["html"],
+ extensions: [".component.html"],
+ filenames: []
+ }
+}), createLanguage(require$$0$20, {
+ override: {
+ since: "1.15.0",
+ parsers: ["html"],
+ vscodeLanguageIds: ["html"]
+ }
+}), createLanguage(require$$1$11, {
+ override: {
+ since: "1.10.0",
+ parsers: ["vue"],
+ vscodeLanguageIds: ["vue"]
+ }
+})];
+var printers$3 = {
+ html: printerHtml
+};
+var languageHtml = {
+ languages: languages$3,
+ printers: printers$3,
+ options: options$9
+};
+
+var _require$$0$builders$6 = doc.builders;
+var indent$7 = _require$$0$builders$6.indent;
+var join$8 = _require$$0$builders$6.join;
+var hardline$9 = _require$$0$builders$6.hardline;
+var softline$6 = _require$$0$builders$6.softline;
+var literalline$4 = _require$$0$builders$6.literalline;
+var concat$13 = _require$$0$builders$6.concat;
+var group$11 = _require$$0$builders$6.group;
+var dedentToRoot$1 = _require$$0$builders$6.dedentToRoot;
+var _require$$0$utils$1 = doc.utils;
+var mapDoc$5 = _require$$0$utils$1.mapDoc;
+var stripTrailingHardline$2 = _require$$0$utils$1.stripTrailingHardline;
+
+function embed$4(path, print, textToDoc
+/*, options */
+) {
+ var node = path.getValue();
+ var parent = path.getParentNode();
+ var parentParent = path.getParentNode(1);
+
+ switch (node.type) {
+ case "TemplateLiteral":
+ {
+ var isCss = [isStyledJsx, isStyledComponents, isCssProp, isAngularComponentStyles].some(function (isIt) {
+ return isIt(path);
+ });
+
+ if (isCss) {
+ // Get full template literal with expressions replaced by placeholders
+ var rawQuasis = node.quasis.map(function (q) {
+ return q.value.raw;
+ });
+ var placeholderID = 0;
+ var text = rawQuasis.reduce(function (prevVal, currVal, idx) {
+ return idx == 0 ? currVal : prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
+ }, "");
+ var doc$$2 = textToDoc(text, {
+ parser: "css"
+ });
+ return transformCssDoc(doc$$2, path, print);
+ }
+ /*
+ * react-relay and graphql-tag
+ * graphql`...`
+ * graphql.experimental`...`
+ * gql`...`
+ *
+ * This intentionally excludes Relay Classic tags, as Prettier does not
+ * support Relay Classic formatting.
+ */
+
+
+ if (isGraphQL(path)) {
+ var expressionDocs = node.expressions ? path.map(print, "expressions") : [];
+ var numQuasis = node.quasis.length;
+
+ if (numQuasis === 1 && node.quasis[0].value.raw.trim() === "") {
+ return "``";
+ }
+
+ var parts = [];
+
+ for (var i = 0; i < numQuasis; i++) {
+ var templateElement = node.quasis[i];
+ var isFirst = i === 0;
+ var isLast = i === numQuasis - 1;
+ var _text = templateElement.value.cooked; // Bail out if any of the quasis have an invalid escape sequence
+ // (which would make the `cooked` value be `null` or `undefined`)
+
+ if (typeof _text !== "string") {
+ return null;
+ }
+
+ var lines = _text.split("\n");
+
+ var numLines = lines.length;
+ var expressionDoc = expressionDocs[i];
+ var startsWithBlankLine = numLines > 2 && lines[0].trim() === "" && lines[1].trim() === "";
+ var endsWithBlankLine = numLines > 2 && lines[numLines - 1].trim() === "" && lines[numLines - 2].trim() === "";
+ var commentsAndWhitespaceOnly = lines.every(function (line) {
+ return /^\s*(?:#[^\r\n]*)?$/.test(line);
+ }); // Bail out if an interpolation occurs within a comment.
+
+ if (!isLast && /#[^\r\n]*$/.test(lines[numLines - 1])) {
+ return null;
+ }
+
+ var _doc = null;
+
+ if (commentsAndWhitespaceOnly) {
+ _doc = printGraphqlComments(lines);
+ } else {
+ _doc = stripTrailingHardline$2(textToDoc(_text, {
+ parser: "graphql"
+ }));
+ }
+
+ if (_doc) {
+ _doc = escapeTemplateCharacters(_doc, false);
+
+ if (!isFirst && startsWithBlankLine) {
+ parts.push("");
+ }
+
+ parts.push(_doc);
+
+ if (!isLast && endsWithBlankLine) {
+ parts.push("");
+ }
+ } else if (!isFirst && !isLast && startsWithBlankLine) {
+ parts.push("");
+ }
+
+ if (expressionDoc) {
+ parts.push(concat$13(["${", expressionDoc, "}"]));
+ }
+ }
+
+ return concat$13(["`", indent$7(concat$13([hardline$9, join$8(hardline$9, parts)])), hardline$9, "`"]);
+ }
+
+ if (isHtml(path)) {
+ return printHtmlTemplateLiteral(path, print, textToDoc, "html");
+ }
+
+ if (isAngularComponentTemplate(path)) {
+ return printHtmlTemplateLiteral(path, print, textToDoc, "angular");
+ }
+
+ break;
+ }
+
+ case "TemplateElement":
+ {
+ /**
+ * md`...`
+ * markdown`...`
+ */
+ if (parentParent && parentParent.type === "TaggedTemplateExpression" && parent.quasis.length === 1 && parentParent.tag.type === "Identifier" && (parentParent.tag.name === "md" || parentParent.tag.name === "markdown")) {
+ var _text2 = parent.quasis[0].value.raw.replace(/((?:\\\\)*)\\`/g, function (_, backslashes) {
+ return "\\".repeat(backslashes.length / 2) + "`";
+ });
+
+ var indentation = getIndentation(_text2);
+ var hasIndent = indentation !== "";
+ return concat$13([hasIndent ? indent$7(concat$13([softline$6, printMarkdown(_text2.replace(new RegExp("^".concat(indentation), "gm"), ""))])) : concat$13([literalline$4, dedentToRoot$1(printMarkdown(_text2))]), softline$6]);
+ }
+
+ break;
+ }
+ }
+
+ function printMarkdown(text) {
+ var doc$$2 = textToDoc(text, {
+ parser: "markdown",
+ __inJsTemplate: true
+ });
+ return stripTrailingHardline$2(escapeTemplateCharacters(doc$$2, true));
+ }
+}
+
+function getIndentation(str) {
+ var firstMatchedIndent = str.match(/^([^\S\n]*)\S/m);
+ return firstMatchedIndent === null ? "" : firstMatchedIndent[1];
+}
+
+function escapeTemplateCharacters(doc$$2, raw) {
+ return mapDoc$5(doc$$2, function (currentDoc) {
+ if (!currentDoc.parts) {
+ return currentDoc;
+ }
+
+ var parts = [];
+ currentDoc.parts.forEach(function (part) {
+ if (typeof part === "string") {
+ parts.push(raw ? part.replace(/(\\*)`/g, "$1$1\\`") : part.replace(/([\\`]|\$\{)/g, "\\$1"));
+ } else {
+ parts.push(part);
+ }
+ });
+ return Object.assign({}, currentDoc, {
+ parts: parts
+ });
+ });
+}
+
+function transformCssDoc(quasisDoc, path, print) {
+ var parentNode = path.getValue();
+ var isEmpty = parentNode.quasis.length === 1 && !parentNode.quasis[0].value.raw.trim();
+
+ if (isEmpty) {
+ return "``";
+ }
+
+ var expressionDocs = parentNode.expressions ? path.map(print, "expressions") : [];
+ var newDoc = replacePlaceholders(quasisDoc, expressionDocs);
+ /* istanbul ignore if */
+
+ if (!newDoc) {
+ throw new Error("Couldn't insert all the expressions");
+ }
+
+ return concat$13(["`", indent$7(concat$13([hardline$9, stripTrailingHardline$2(newDoc)])), softline$6, "`"]);
+} // Search all the placeholders in the quasisDoc tree
+// and replace them with the expression docs one by one
+// returns a new doc with all the placeholders replaced,
+// or null if it couldn't replace any expression
+
+
+function replacePlaceholders(quasisDoc, expressionDocs) {
+ if (!expressionDocs || !expressionDocs.length) {
+ return quasisDoc;
+ }
+
+ var expressions = expressionDocs.slice();
+ var replaceCounter = 0;
+ var newDoc = mapDoc$5(quasisDoc, function (doc$$2) {
+ if (!doc$$2 || !doc$$2.parts || !doc$$2.parts.length) {
+ return doc$$2;
+ }
+
+ var parts = doc$$2.parts;
+ var atIndex = parts.indexOf("@");
+ var placeholderIndex = atIndex + 1;
+
+ if (atIndex > -1 && typeof parts[placeholderIndex] === "string" && parts[placeholderIndex].startsWith("prettier-placeholder")) {
+ // If placeholder is split, join it
+ var at = parts[atIndex];
+ var placeholder = parts[placeholderIndex];
+ var rest = parts.slice(placeholderIndex + 1);
+ parts = parts.slice(0, atIndex).concat([at + placeholder]).concat(rest);
+ }
+
+ var atPlaceholderIndex = parts.findIndex(function (part) {
+ return typeof part === "string" && part.startsWith("@prettier-placeholder");
+ });
+
+ if (atPlaceholderIndex > -1) {
+ var _placeholder = parts[atPlaceholderIndex];
+
+ var _rest = parts.slice(atPlaceholderIndex + 1);
+
+ var placeholderMatch = _placeholder.match(/@prettier-placeholder-(.+)-id([\s\S]*)/);
+
+ var placeholderID = placeholderMatch[1]; // When the expression has a suffix appended, like:
+ // animation: linear ${time}s ease-out;
+
+ var suffix = placeholderMatch[2];
+ var expression = expressions[placeholderID];
+ replaceCounter++;
+ parts = parts.slice(0, atPlaceholderIndex).concat(["${", expression, "}" + suffix]).concat(_rest);
+ }
+
+ return Object.assign({}, doc$$2, {
+ parts: parts
+ });
+ });
+ return expressions.length === replaceCounter ? newDoc : null;
+}
+
+function printGraphqlComments(lines) {
+ var parts = [];
+ var seenComment = false;
+ lines.map(function (textLine) {
+ return textLine.trim();
+ }).forEach(function (textLine, i, array) {
+ // Lines are either whitespace only, or a comment (with poential whitespace
+ // around it). Drop whitespace-only lines.
+ if (textLine === "") {
+ return;
+ }
+
+ if (array[i - 1] === "" && seenComment) {
+ // If a non-first comment is preceded by a blank (whitespace only) line,
+ // add in a blank line.
+ parts.push(concat$13([hardline$9, textLine]));
+ } else {
+ parts.push(textLine);
+ }
+
+ seenComment = true;
+ }); // If `lines` was whitespace only, return `null`.
+
+ return parts.length === 0 ? null : join$8(hardline$9, parts);
+}
+/**
+ * Template literal in this context:
+ *
+ */
+
+
+function isStyledJsx(path) {
+ var node = path.getValue();
+ var parent = path.getParentNode();
+ var parentParent = path.getParentNode(1);
+ return parentParent && node.quasis && parent.type === "JSXExpressionContainer" && parentParent.type === "JSXElement" && parentParent.openingElement.name.name === "style" && parentParent.openingElement.attributes.some(function (attribute) {
+ return attribute.name.name === "jsx";
+ });
+}
+/**
+ * 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 isPathMatch(path, [function (node) {
+ return node.type === "TemplateLiteral";
+ }, function (node, name) {
+ return node.type === "ArrayExpression" && name === "elements";
+ }, function (node, name) {
+ return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "styles" && name === "value";
+ }].concat(getAngularComponentObjectExpressionPredicates()));
+}
+
+function isAngularComponentTemplate(path) {
+ return isPathMatch(path, [function (node) {
+ return node.type === "TemplateLiteral";
+ }, function (node, name) {
+ return node.type === "Property" && node.key.type === "Identifier" && node.key.name === "template" && name === "value";
+ }].concat(getAngularComponentObjectExpressionPredicates()));
+}
+
+function getAngularComponentObjectExpressionPredicates() {
+ return [function (node, name) {
+ return node.type === "ObjectExpression" && name === "properties";
+ }, function (node, name) {
+ return node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "Component" && name === "arguments";
+ }, function (node, name) {
+ return node.type === "Decorator" && name === "expression";
+ }];
+}
+/**
+ * styled-components template literals
+ */
+
+
+function isStyledComponents(path) {
+ var parent = path.getParentNode();
+
+ if (!parent || parent.type !== "TaggedTemplateExpression") {
+ return false;
+ }
+
+ var tag = parent.tag;
+
+ 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.attr({})``
+ isStyledIdentifier(tag.callee.object.object) || // Component.extend.attr({)``
+ isStyledExtend(tag.callee.object)) || // styled(Component).attr({})``
+ 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) {
+ var parent = path.getParentNode();
+ var 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) {
+ var node = path.getValue();
+ var 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 node.leadingComments && node.leadingComments.some(function (comment) {
+ return comment.type === "CommentBlock" && comment.value === " ".concat(languageName, " ");
+ });
+}
+
+function isPathMatch(path, predicateStack) {
+ var stack = path.stack.slice();
+ var name = null;
+ var node = stack.pop();
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = predicateStack[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var predicate = _step.value;
+
+ if (node === undefined) {
+ return false;
+ } // skip index/array
+
+
+ if (typeof name === "number") {
+ name = stack.pop();
+ node = stack.pop();
+ }
+
+ if (!predicate(node, name)) {
+ return false;
+ }
+
+ name = stack.pop();
+ node = stack.pop();
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+
+ return true;
+}
+/**
+ * - html`...`
+ * - HTML comment block
+ */
+
+
+function isHtml(path) {
+ var node = path.getValue();
+ return hasLanguageComment(node, "HTML") || isPathMatch(path, [function (node) {
+ return node.type === "TemplateLiteral";
+ }, function (node, name) {
+ return node.type === "TaggedTemplateExpression" && node.tag.type === "Identifier" && node.tag.name === "html" && name === "quasi";
+ }]);
+}
+
+function printHtmlTemplateLiteral(path, print, textToDoc, parser) {
+ var node = path.getValue();
+ var placeholderPattern = "prettierhtmlplaceholder(\\d+)redlohecalplmthreitterp";
+ var placeholders = node.expressions.map(function (_, i) {
+ return "prettierhtmlplaceholder".concat(i, "redlohecalplmthreitterp");
+ });
+ var text = node.quasis.map(function (quasi, index, quasis) {
+ return index === quasis.length - 1 ? quasi.value.raw : quasi.value.raw + placeholders[index];
+ }).join("");
+ var expressionDocs = path.map(print, "expressions");
+
+ if (expressionDocs.length === 0 && text.trim().length === 0) {
+ return "``";
+ }
+
+ var contentDoc = mapDoc$5(stripTrailingHardline$2(textToDoc(text, {
+ parser: parser
+ })), function (doc$$2) {
+ var placeholderRegex = new RegExp(placeholderPattern, "g");
+ var hasPlaceholder = typeof doc$$2 === "string" && placeholderRegex.test(doc$$2);
+
+ if (!hasPlaceholder) {
+ return doc$$2;
+ }
+
+ var parts = [];
+ var components = doc$$2.split(placeholderRegex);
+
+ for (var i = 0; i < components.length; i++) {
+ var component = components[i];
+
+ if (i % 2 === 0) {
+ if (component) {
+ parts.push(component);
+ }
+
+ continue;
+ }
+
+ var placeholderIndex = +component;
+ parts.push(concat$13(["${", group$11(concat$13([indent$7(concat$13([softline$6, expressionDocs[placeholderIndex]])), softline$6])), "}"]));
+ }
+
+ return concat$13(parts);
+ });
+ return group$11(concat$13(["`", indent$7(concat$13([hardline$9, group$11(contentDoc)])), softline$6, "`"]));
+}
+
+var embed_1$2 = embed$4;
+
+function clean$7(ast, newObj, parent) {
+ ["range", "raw", "comments", "leadingComments", "trailingComments", "extra", "start", "end", "flags"].forEach(function (name) {
+ delete newObj[name];
+ });
+
+ 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;
+ } // (TypeScript) bypass TSParenthesizedType
+
+
+ if (ast.type === "TSParenthesizedType" && ast.typeAnnotation.type === "TSTypeAnnotation") {
+ return newObj.typeAnnotation.typeAnnotation;
+ } // 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(function (attr) {
+ return attr.name.name === "jsx";
+ })) {
+ var templateLiterals = newObj.children.filter(function (child) {
+ return child.type === "JSXExpressionContainer" && child.expression.type === "TemplateLiteral";
+ }).map(function (container) {
+ return container.expression;
+ });
+ var quasis = templateLiterals.reduce(function (quasis, templateLiteral) {
+ return quasis.concat(templateLiteral.quasis);
+ }, []);
+ quasis.forEach(function (q) {
+ return 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(function (q) {
+ return delete q.value;
+ });
+ } // Angular Components: Inline HTML template and Inline CSS styles
+
+
+ var expression = ast.expression || ast.callee;
+
+ if (ast.type === "Decorator" && expression.type === "CallExpression" && expression.callee.name === "Component" && expression.arguments.length === 1) {
+ var astProps = ast.expression.arguments[0].properties;
+ newObj.expression.arguments[0].properties.forEach(function (prop, index) {
+ var 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(function (q) {
+ return 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(function (quasi) {
+ return 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
+ var hasLanguageComment = ast.leadingComments && ast.leadingComments.some(function (comment) {
+ return comment.type === "CommentBlock" && ["GraphQL", "HTML"].some(function (languageName) {
+ return comment.value === " ".concat(languageName, " ");
+ });
+ });
+
+ if (hasLanguageComment || parent.type === "CallExpression" && parent.callee.name === "graphql") {
+ newObj.quasis.forEach(function (quasi) {
+ return delete quasi.value;
+ });
+ }
+ }
+}
+
+var clean_1$2 = clean$7;
+
+var addLeadingComment$2 = utilShared.addLeadingComment;
+var addTrailingComment$2 = utilShared.addTrailingComment;
+var addDanglingComment$2 = utilShared.addDanglingComment;
+
+function handleOwnLineComment(comment, text, options, ast, isLastComment) {
+ var precedingNode = comment.precedingNode,
+ enclosingNode = comment.enclosingNode,
+ followingNode = comment.followingNode;
+
+ if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleMemberExpressionComments(enclosingNode, followingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleImportSpecifierComments(enclosingNode, comment) || handleForComments(enclosingNode, precedingNode, comment) || handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) || handleAssignmentPatternComments(enclosingNode, comment) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options)) {
+ return true;
+ }
+
+ return false;
+}
+
+function handleEndOfLineComment(comment, text, options, ast, isLastComment) {
+ var precedingNode = comment.precedingNode,
+ enclosingNode = comment.enclosingNode,
+ followingNode = comment.followingNode;
+
+ if (handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) || handleImportSpecifierComments(enclosingNode, comment) || handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) || handleClassComments(enclosingNode, precedingNode, followingNode, comment) || handleLabeledStatementComments(enclosingNode, comment) || handleCallExpressionComments(precedingNode, enclosingNode, comment) || handlePropertyComments(enclosingNode, comment) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleTypeAliasComments(enclosingNode, followingNode, comment) || handleVariableDeclaratorComments(enclosingNode, followingNode, comment)) {
+ return true;
+ }
+
+ return false;
+}
+
+function handleRemainingComment(comment, text, options, ast, isLastComment) {
+ var precedingNode = comment.precedingNode,
+ enclosingNode = comment.enclosingNode,
+ followingNode = comment.followingNode;
+
+ if (handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) || handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) || handleCommentInEmptyParens(text, enclosingNode, comment, options) || handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) || handleOnlyComments(enclosingNode, ast, comment, isLastComment) || handleCommentAfterArrowParams(text, enclosingNode, comment, options) || handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) || handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) || handleBreakAndContinueStatementComments(enclosingNode, comment)) {
+ return true;
+ }
+
+ return false;
+}
+
+function addBlockStatementFirstComment(node, comment) {
+ var body = node.body.filter(function (n) {
+ return n.type !== "EmptyStatement";
+ });
+
+ if (body.length === 0) {
+ addDanglingComment$2(node, comment);
+ } else {
+ addLeadingComment$2(body[0], comment);
+ }
+}
+
+function addBlockOrNotComment(node, comment) {
+ if (node.type === "BlockStatement") {
+ addBlockStatementFirstComment(node, comment);
+ } else {
+ addLeadingComment$2(node, comment);
+ }
+} // There are often comments before the else clause of if statements like
+//
+// if (1) { ... }
+// // comment
+// else { ... }
+//
+// They are being attached as leading comments of the BlockExpression which
+// is not well printed. What we want is to instead move the comment inside
+// of the block and make it leadingComment of the first element of the block
+// or dangling comment of the block if there is nothing inside
+//
+// if (1) { ... }
+// else {
+// // comment
+// ...
+// }
+
+
+function handleIfStatementComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
+ if (!enclosingNode || enclosingNode.type !== "IfStatement" || !followingNode) {
+ return false;
+ } // We unfortunately have no way using the AST or location of nodes to know
+ // if the comment is positioned before the condition parenthesis:
+ // if (a /* comment */) {}
+ // The only workaround I found is to look at the next character to see if
+ // it is a ).
+
+
+ var nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
+
+ if (nextCharacter === ")") {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ } // Comments before `else`:
+ // - treat as trailing comments of the consequent, if it's a BlockStatement
+ // - treat as a dangling comment otherwise
+
+
+ if (precedingNode === enclosingNode.consequent && followingNode === enclosingNode.alternate) {
+ if (precedingNode.type === "BlockStatement") {
+ addTrailingComment$2(precedingNode, comment);
+ } else {
+ addDanglingComment$2(enclosingNode, comment);
+ }
+
+ return true;
+ }
+
+ if (followingNode.type === "BlockStatement") {
+ addBlockStatementFirstComment(followingNode, comment);
+ return true;
+ }
+
+ if (followingNode.type === "IfStatement") {
+ addBlockOrNotComment(followingNode.consequent, comment);
+ return true;
+ } // For comments positioned after the condition parenthesis in an if statement
+ // before the consequent without brackets on, such as
+ // if (a) /* comment */ true,
+ // we look at the next character to see if the following node
+ // is the consequent for the if statement
+
+
+ if (enclosingNode.consequent === followingNode) {
+ addLeadingComment$2(followingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleWhileComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
+ if (!enclosingNode || enclosingNode.type !== "WhileStatement" || !followingNode) {
+ return false;
+ } // We unfortunately have no way using the AST or location of nodes to know
+ // if the comment is positioned before the condition parenthesis:
+ // while (a /* comment */) {}
+ // The only workaround I found is to look at the next character to see if
+ // it is a ).
+
+
+ var nextCharacter = util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd);
+
+ if (nextCharacter === ")") {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ }
+
+ if (followingNode.type === "BlockStatement") {
+ addBlockStatementFirstComment(followingNode, comment);
+ return true;
+ }
+
+ return false;
+} // Same as IfStatement but for TryStatement
+
+
+function handleTryStatementComments(enclosingNode, precedingNode, followingNode, comment) {
+ if (!enclosingNode || enclosingNode.type !== "TryStatement" && enclosingNode.type !== "CatchClause" || !followingNode) {
+ return false;
+ }
+
+ if (enclosingNode.type === "CatchClause" && precedingNode) {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ }
+
+ if (followingNode.type === "BlockStatement") {
+ addBlockStatementFirstComment(followingNode, comment);
+ return true;
+ }
+
+ if (followingNode.type === "TryStatement") {
+ addBlockOrNotComment(followingNode.finalizer, comment);
+ return true;
+ }
+
+ if (followingNode.type === "CatchClause") {
+ addBlockOrNotComment(followingNode.body, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleMemberExpressionComments(enclosingNode, followingNode, comment) {
+ if (enclosingNode && enclosingNode.type === "MemberExpression" && followingNode && followingNode.type === "Identifier") {
+ addLeadingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleConditionalExpressionComments(enclosingNode, precedingNode, followingNode, comment, text, options) {
+ var isSameLineAsPrecedingNode = precedingNode && !util.hasNewlineInRange(text, options.locEnd(precedingNode), options.locStart(comment));
+
+ if ((!precedingNode || !isSameLineAsPrecedingNode) && enclosingNode && enclosingNode.type === "ConditionalExpression" && followingNode) {
+ addLeadingComment$2(followingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleObjectPropertyAssignment(enclosingNode, precedingNode, comment) {
+ if (enclosingNode && (enclosingNode.type === "ObjectProperty" || enclosingNode.type === "Property") && enclosingNode.shorthand && enclosingNode.key === precedingNode && enclosingNode.value.type === "AssignmentPattern") {
+ addTrailingComment$2(enclosingNode.value.left, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleClassComments(enclosingNode, precedingNode, followingNode, comment) {
+ if (enclosingNode && (enclosingNode.type === "ClassDeclaration" || enclosingNode.type === "ClassExpression") && enclosingNode.decorators && enclosingNode.decorators.length > 0 && !(followingNode && followingNode.type === "Decorator")) {
+ if (!enclosingNode.decorators || enclosingNode.decorators.length === 0) {
+ addLeadingComment$2(enclosingNode, comment);
+ } else {
+ addTrailingComment$2(enclosingNode.decorators[enclosingNode.decorators.length - 1], comment);
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+function handleMethodNameComments(text, enclosingNode, precedingNode, comment, options) {
+ // This is only needed for estree parsers (flow, typescript) to attach
+ // after a method name:
+ // obj = { fn /*comment*/() {} };
+ if (enclosingNode && precedingNode && (enclosingNode.type === "Property" || enclosingNode.type === "MethodDefinition") && precedingNode.type === "Identifier" && enclosingNode.key === precedingNode && // special Property case: { key: /*comment*/(value) };
+ // comment should be attached to value instead of key
+ util.getNextNonSpaceNonCommentCharacter(text, precedingNode, options.locEnd) !== ":") {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ } // Print comments between decorators and class methods as a trailing comment
+ // on the decorator node instead of the method node
+
+
+ if (precedingNode && enclosingNode && precedingNode.type === "Decorator" && (enclosingNode.type === "ClassMethod" || enclosingNode.type === "ClassProperty" || enclosingNode.type === "TSAbstractClassProperty" || enclosingNode.type === "TSAbstractMethodDefinition" || enclosingNode.type === "MethodDefinition")) {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleFunctionNameComments(text, enclosingNode, precedingNode, comment, options) {
+ if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== "(") {
+ return false;
+ }
+
+ if (precedingNode && enclosingNode && (enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ClassMethod" || enclosingNode.type === "MethodDefinition" || enclosingNode.type === "ObjectMethod")) {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleCommentAfterArrowParams(text, enclosingNode, comment, options) {
+ if (!(enclosingNode && enclosingNode.type === "ArrowFunctionExpression")) {
+ return false;
+ }
+
+ var index = utilShared.getNextNonSpaceNonCommentCharacterIndex(text, comment, options);
+
+ if (text.substr(index, 2) === "=>") {
+ addDanglingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleCommentInEmptyParens(text, enclosingNode, comment, options) {
+ if (util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) !== ")") {
+ return false;
+ } // Only add dangling comments to fix the case when no params are present,
+ // i.e. a function without any argument.
+
+
+ if (enclosingNode && ((enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "ArrowFunctionExpression" && (enclosingNode.body.type !== "CallExpression" || enclosingNode.body.arguments.length === 0) || enclosingNode.type === "ClassMethod" || enclosingNode.type === "ObjectMethod") && enclosingNode.params.length === 0 || (enclosingNode.type === "CallExpression" || enclosingNode.type === "NewExpression") && enclosingNode.arguments.length === 0)) {
+ addDanglingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ if (enclosingNode && enclosingNode.type === "MethodDefinition" && enclosingNode.value.params.length === 0) {
+ addDanglingComment$2(enclosingNode.value, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleLastFunctionArgComments(text, precedingNode, enclosingNode, followingNode, comment, options) {
+ // Type definitions functions
+ if (precedingNode && precedingNode.type === "FunctionTypeParam" && enclosingNode && enclosingNode.type === "FunctionTypeAnnotation" && followingNode && followingNode.type !== "FunctionTypeParam") {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ } // Real functions
+
+
+ if (precedingNode && (precedingNode.type === "Identifier" || precedingNode.type === "AssignmentPattern") && enclosingNode && (enclosingNode.type === "ArrowFunctionExpression" || enclosingNode.type === "FunctionExpression" || enclosingNode.type === "FunctionDeclaration" || enclosingNode.type === "ObjectMethod" || enclosingNode.type === "ClassMethod") && util.getNextNonSpaceNonCommentCharacter(text, comment, options.locEnd) === ")") {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ }
+
+ if (enclosingNode && enclosingNode.type === "FunctionDeclaration" && followingNode && followingNode.type === "BlockStatement") {
+ var functionParamRightParenIndex = function () {
+ if (enclosingNode.params.length !== 0) {
+ return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(util.getLast(enclosingNode.params)));
+ }
+
+ var functionParamLeftParenIndex = util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, options.locEnd(enclosingNode.id));
+ return util.getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, functionParamLeftParenIndex + 1);
+ }();
+
+ if (options.locStart(comment) > functionParamRightParenIndex) {
+ addBlockStatementFirstComment(followingNode, comment);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+function handleImportSpecifierComments(enclosingNode, comment) {
+ if (enclosingNode && enclosingNode.type === "ImportSpecifier") {
+ addLeadingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleLabeledStatementComments(enclosingNode, comment) {
+ if (enclosingNode && enclosingNode.type === "LabeledStatement") {
+ addLeadingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleBreakAndContinueStatementComments(enclosingNode, comment) {
+ if (enclosingNode && (enclosingNode.type === "ContinueStatement" || enclosingNode.type === "BreakStatement") && !enclosingNode.label) {
+ addTrailingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleCallExpressionComments(precedingNode, enclosingNode, comment) {
+ if (enclosingNode && enclosingNode.type === "CallExpression" && precedingNode && enclosingNode.callee === precedingNode && enclosingNode.arguments.length > 0) {
+ addLeadingComment$2(enclosingNode.arguments[0], comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleUnionTypeComments(precedingNode, enclosingNode, followingNode, comment) {
+ if (enclosingNode && (enclosingNode.type === "UnionTypeAnnotation" || enclosingNode.type === "TSUnionType")) {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handlePropertyComments(enclosingNode, comment) {
+ if (enclosingNode && (enclosingNode.type === "Property" || enclosingNode.type === "ObjectProperty")) {
+ addLeadingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleOnlyComments(enclosingNode, ast, comment, isLastComment) {
+ // With Flow the enclosingNode is undefined so use the AST instead.
+ if (ast && ast.body && ast.body.length === 0) {
+ if (isLastComment) {
+ addDanglingComment$2(ast, comment);
+ } else {
+ addLeadingComment$2(ast, comment);
+ }
+
+ return true;
+ } else if (enclosingNode && enclosingNode.type === "Program" && enclosingNode.body.length === 0 && enclosingNode.directives && enclosingNode.directives.length === 0) {
+ if (isLastComment) {
+ addDanglingComment$2(enclosingNode, comment);
+ } else {
+ addLeadingComment$2(enclosingNode, comment);
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+function handleForComments(enclosingNode, precedingNode, comment) {
+ if (enclosingNode && (enclosingNode.type === "ForInStatement" || enclosingNode.type === "ForOfStatement")) {
+ addLeadingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleImportDeclarationComments(text, enclosingNode, precedingNode, comment, options) {
+ if (precedingNode && precedingNode.type === "ImportSpecifier" && enclosingNode && enclosingNode.type === "ImportDeclaration" && util.hasNewline(text, options.locEnd(comment))) {
+ addTrailingComment$2(precedingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleAssignmentPatternComments(enclosingNode, comment) {
+ if (enclosingNode && enclosingNode.type === "AssignmentPattern") {
+ addLeadingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleTypeAliasComments(enclosingNode, followingNode, comment) {
+ if (enclosingNode && enclosingNode.type === "TypeAlias") {
+ addLeadingComment$2(enclosingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleVariableDeclaratorComments(enclosingNode, followingNode, comment) {
+ if (enclosingNode && (enclosingNode.type === "VariableDeclarator" || enclosingNode.type === "AssignmentExpression") && followingNode && (followingNode.type === "ObjectExpression" || followingNode.type === "ArrayExpression" || followingNode.type === "TemplateLiteral" || followingNode.type === "TaggedTemplateExpression")) {
+ addLeadingComment$2(followingNode, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function handleTSMappedTypeComments(text, enclosingNode, precedingNode, followingNode, comment) {
+ if (!enclosingNode || enclosingNode.type !== "TSMappedType") {
+ return false;
+ }
+
+ if (followingNode && followingNode.type === "TSTypeParameter" && followingNode.name) {
+ addLeadingComment$2(followingNode.name, comment);
+ return true;
+ }
+
+ if (precedingNode && precedingNode.type === "TSTypeParameter" && precedingNode.constraint) {
+ addTrailingComment$2(precedingNode.constraint, comment);
+ return true;
+ }
+
+ return false;
+}
+
+function isBlockComment(comment) {
+ return comment.type === "Block" || comment.type === "CommentBlock";
+}
+
+var comments$3 = {
+ handleOwnLineComment: handleOwnLineComment,
+ handleEndOfLineComment: handleEndOfLineComment,
+ handleRemainingComment: handleRemainingComment,
+ isBlockComment: isBlockComment
+};
+
+// 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.
+
+var NON_LINE_TERMINATING_WHITE_SPACE = "(?:(?=.)\\s)";
+var FLOW_SHORTHAND_ANNOTATION = new RegExp("^".concat(NON_LINE_TERMINATING_WHITE_SPACE, "*:"));
+var FLOW_ANNOTATION = new RegExp("^".concat(NON_LINE_TERMINATING_WHITE_SPACE, "*::"));
+
+function hasFlowShorthandAnnotationComment$2(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$1(comments) {
+ return comments && comments[0].value.match(FLOW_ANNOTATION);
+}
+
+function hasNode$1(node, fn) {
+ if (!node || _typeof(node) !== "object") {
+ return false;
+ }
+
+ if (Array.isArray(node)) {
+ return node.some(function (value) {
+ return hasNode$1(value, fn);
+ });
+ }
+
+ var result = fn(node);
+ return typeof result === "boolean" ? result : Object.keys(node).some(function (key) {
+ return hasNode$1(node[key], fn);
+ });
+}
+
+var utils$6 = {
+ hasNode: hasNode$1,
+ hasFlowShorthandAnnotationComment: hasFlowShorthandAnnotationComment$2,
+ hasFlowAnnotationComment: hasFlowAnnotationComment$1
+};
+
+var hasFlowShorthandAnnotationComment$1 = utils$6.hasFlowShorthandAnnotationComment;
+
+function hasClosureCompilerTypeCastComment(text, path, locStart, locEnd) {
+ // https://github.com/google/closure-compiler/wiki/Annotating-Types#type-casts
+ // Syntax example: var x = /** @type {string} */ (fruit);
+ var n = path.getValue();
+ return util.getNextNonSpaceNonCommentCharacter(text, n, locEnd) === ")" && (hasTypeCastComment(n) || hasAncestorTypeCastComment(0)); // for sub-item: /** @type {array} */ (numberOrString).map(x => x);
+
+ function hasAncestorTypeCastComment(index) {
+ var ancestor = path.getParentNode(index);
+ return ancestor && util.getNextNonSpaceNonCommentCharacter(text, ancestor, locEnd) !== ")" && /^[\s(]*$/.test(text.slice(locStart(ancestor), locStart(n))) ? hasTypeCastComment(ancestor) || hasAncestorTypeCastComment(index + 1) : false;
+ }
+
+ function hasTypeCastComment(node) {
+ return node.comments && node.comments.some(function (comment) {
+ return comment.leading && comments$3.isBlockComment(comment) && comment.value.match(/^\*\s*@type\s*{[^}]+}\s*$/) && util.getNextNonSpaceNonCommentCharacter(text, comment, locEnd) === "(";
+ });
+ }
+}
+
+function needsParens(path, options) {
+ var parent = path.getParentNode();
+
+ if (!parent) {
+ return false;
+ }
+
+ var name = path.getName();
+ var 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;
+ } // Only statements don't need parentheses.
+
+
+ if (isStatement(node)) {
+ return false;
+ } // Closure compiler requires that type casted expressions to be surrounded by
+ // parentheses.
+
+
+ if (hasClosureCompilerTypeCastComment(options.originalText, path, options.locStart, options.locEnd)) {
+ return true;
+ }
+
+ 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") {
+ 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 === "ArrowFunctionExpression" && parent.body === node && node.type !== "SequenceExpression" && // these have parens added anyway
+ util.startsWithNoLookaheadToken(node,
+ /* forbidFunctionClassAndDoExpr */
+ false) || parent.type === "ExpressionStatement" && util.startsWithNoLookaheadToken(node,
+ /* forbidFunctionClassAndDoExpr */
+ true)) {
+ return true;
+ }
+
+ switch (node.type) {
+ case "CallExpression":
+ {
+ var firstParentNotMemberExpression = parent;
+ var i = 0;
+
+ while (firstParentNotMemberExpression && firstParentNotMemberExpression.type === "MemberExpression") {
+ firstParentNotMemberExpression = path.getParentNode(++i);
+ }
+
+ if (firstParentNotMemberExpression.type === "NewExpression" && firstParentNotMemberExpression.callee === path.getParentNode(i - 1)) {
+ return true;
+ }
+
+ if (parent.type === "BindExpression" && parent.callee === node) {
+ return true;
+ }
+
+ return false;
+ }
+
+ 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":
+ return name === "object" && parent.object === node;
+
+ case "TaggedTemplateExpression":
+ return true;
+
+ case "NewExpression":
+ case "CallExpression":
+ return name === "callee" && parent.callee === node;
+
+ case "BinaryExpression":
+ return parent.operator === "**" && name === "left";
+
+ case "TSNonNullExpression":
+ return true;
+
+ default:
+ return false;
+ }
+
+ case "BinaryExpression":
+ {
+ if (parent.type === "UpdateExpression") {
+ return true;
+ }
+
+ var isLeftOfAForStatement = function isLeftOfAForStatement(node) {
+ var i = 0;
+
+ while (node) {
+ var _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 "TSTypeAssertionExpression":
+ case "TSAsExpression":
+ case "LogicalExpression":
+ switch (parent.type) {
+ case "ConditionalExpression":
+ return node.type === "TSAsExpression";
+
+ case "CallExpression":
+ case "NewExpression":
+ return name === "callee" && parent.callee === node;
+
+ case "ClassExpression":
+ case "ClassDeclaration":
+ case "TSAbstractClassDeclaration":
+ return name === "superClass" && parent.superClass === node;
+
+ case "TSTypeAssertionExpression":
+ case "TaggedTemplateExpression":
+ case "UnaryExpression":
+ case "SpreadElement":
+ case "SpreadProperty":
+ case "BindExpression":
+ case "AwaitExpression":
+ case "TSAsExpression":
+ case "TSNonNullExpression":
+ case "UpdateExpression":
+ return true;
+
+ case "MemberExpression":
+ return name === "object" && parent.object === node;
+
+ case "AssignmentExpression":
+ return parent.left === node && (node.type === "TSTypeAssertionExpression" || node.type === "TSAsExpression");
+
+ case "Decorator":
+ return parent.expression === node && (node.type === "TSTypeAssertionExpression" || node.type === "TSAsExpression");
+
+ case "BinaryExpression":
+ case "LogicalExpression":
+ {
+ if (!node.operator && node.type !== "TSTypeAssertionExpression") {
+ return true;
+ }
+
+ var po = parent.operator;
+ var pp = util.getPrecedence(po);
+ var no = node.operator;
+ var np = util.getPrecedence(no);
+
+ if (pp > np) {
+ return true;
+ }
+
+ if ((po === "||" || po === "??") && no === "&&") {
+ return true;
+ }
+
+ if (pp === np && name === "right") {
+ assert$3.strictEqual(parent.right, node);
+ return true;
+ }
+
+ if (pp === np && !util.shouldFlatten(po, no)) {
+ return true;
+ }
+
+ if (pp < np && no === "%") {
+ return po === "+" || po === "-";
+ } // Add parenthesis when working with bitwise operators
+ // It's not stricly needed but helps with code understanding
+
+
+ if (util.isBitwiseOperator(po)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ default:
+ return false;
+ }
+
+ case "TSParenthesizedType":
+ {
+ var grandParent = path.getParentNode(1);
+
+ if ((parent.type === "TSTypeParameter" || parent.type === "TypeParameter" || parent.type === "VariableDeclarator" || parent.type === "TSTypeAnnotation" || parent.type === "GenericTypeAnnotation" || parent.type === "TSTypeReference") && node.typeAnnotation.type === "TSTypeAnnotation" && node.typeAnnotation.typeAnnotation.type !== "TSFunctionType" && grandParent.type !== "TSTypeOperator" && grandParent.type !== "TSOptionalType") {
+ return false;
+ } // Delegate to inner TSParenthesizedType
+
+
+ if (node.typeAnnotation.type === "TSParenthesizedType") {
+ return false;
+ }
+
+ return true;
+ }
+
+ 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":
+ return parent.object === node;
+
+ case "NewExpression":
+ case "CallExpression":
+ return parent.callee === node;
+
+ case "ConditionalExpression":
+ return parent.test === node;
+
+ default:
+ return false;
+ }
+
+ 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":
+ {
+ var 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.substr(options.locStart(node) - 1, 1) === "(")) {
+ // To avoid becoming a directive
+ var _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":
+ {
+ var _grandParent2 = 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" && _grandParent2 && _grandParent2.type === "ForStatement" && (_grandParent2.init === parent || _grandParent2.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 "TSTypeAssertionExpression":
+ case "TypeCastExpression":
+ case "TSAsExpression":
+ case "TSNonNullExpression":
+ case "OptionalMemberExpression":
+ return true;
+
+ case "NewExpression":
+ case "CallExpression":
+ return name === "callee" && parent.callee === node;
+
+ case "ConditionalExpression":
+ return name === "test" && parent.test === node;
+
+ case "MemberExpression":
+ return name === "object" && parent.object === node;
+
+ default:
+ return false;
+ }
+
+ case "FunctionExpression":
+ switch (parent.type) {
+ case "CallExpression":
+ return name === "callee";
+ // Not strictly necessary, but it's clearer to the reader if IIFEs are wrapped in parentheses.
+
+ case "TaggedTemplateExpression":
+ return true;
+ // This is basically a kind of IIFE.
+
+ case "ExportDefaultDeclaration":
+ return true;
+
+ default:
+ return false;
+ }
+
+ case "ArrowFunctionExpression":
+ switch (parent.type) {
+ case "CallExpression":
+ return name === "callee";
+
+ case "NewExpression":
+ return name === "callee";
+
+ case "MemberExpression":
+ return name === "object";
+
+ case "TSAsExpression":
+ case "BindExpression":
+ case "TaggedTemplateExpression":
+ case "UnaryExpression":
+ case "LogicalExpression":
+ case "BinaryExpression":
+ case "AwaitExpression":
+ case "TSTypeAssertionExpression":
+ return true;
+
+ case "ConditionalExpression":
+ return name === "test";
+
+ default:
+ return false;
+ }
+
+ case "ClassExpression":
+ return parent.type === "ExportDefaultDeclaration";
+
+ case "OptionalMemberExpression":
+ return parent.type === "MemberExpression";
+
+ case "MemberExpression":
+ if (parent.type === "BindExpression" && name === "callee" && parent.callee === node) {
+ var object = node.object;
+
+ while (object) {
+ if (object.type === "CallExpression") {
+ return true;
+ }
+
+ if (object.type !== "MemberExpression" && object.type !== "BindExpression") {
+ break;
+ }
+
+ object = object.object;
+ }
+ }
+
+ return false;
+
+ case "BindExpression":
+ if (parent.type === "BindExpression" && name === "callee" && parent.callee === node || parent.type === "MemberExpression") {
+ return true;
+ }
+
+ return false;
+
+ case "NGPipeExpression":
+ if (parent.type === "NGRoot" || 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;
+ }
+
+ 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 === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration" || node.type === "ExpressionStatement" || node.type === "ForAwaitStatement" || 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 === "TSAbstractClassDeclaration" || 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";
+}
+
+var needsParens_1 = needsParens;
+
+var _require$$0$builders$7 = doc.builders;
+var concat$14 = _require$$0$builders$7.concat;
+var join$9 = _require$$0$builders$7.join;
+var line$9 = _require$$0$builders$7.line;
+
+function printHtmlBinding$1(path, options, print) {
+ var node = path.getValue();
+
+ if (options.__onHtmlBindingRoot && path.getName() === null) {
+ options.__onHtmlBindingRoot(node);
+ }
+
+ if (node.type !== "File") {
+ return;
+ }
+
+ if (options.__isVueForBindingLeft) {
+ return path.call(function (functionDeclarationPath) {
+ var _functionDeclarationP = functionDeclarationPath.getValue(),
+ params = _functionDeclarationP.params;
+
+ return concat$14([params.length > 1 ? "(" : "", join$9(concat$14([",", line$9]), functionDeclarationPath.map(print, "params")), params.length > 1 ? ")" : ""]);
+ }, "program", "body", 0);
+ }
+
+ if (options.__isVueSlotScope) {
+ return path.call(function (functionDeclarationPath) {
+ return join$9(concat$14([",", line$9]), functionDeclarationPath.map(print, "params"));
+ }, "program", "body", 0);
+ }
+}
+
+var htmlBinding = {
+ printHtmlBinding: printHtmlBinding$1
+};
+
+function preprocess$2(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: []
+ });
+
+ default:
+ return ast;
+ }
+}
+
+var preprocess_1$2 = preprocess$2;
+
+var getParentExportDeclaration$1 = util.getParentExportDeclaration;
+var isExportDeclaration$1 = util.isExportDeclaration;
+var shouldFlatten$1 = util.shouldFlatten;
+var getNextNonSpaceNonCommentCharacter$1 = util.getNextNonSpaceNonCommentCharacter;
+var hasNewline$3 = util.hasNewline;
+var hasNewlineInRange$1 = util.hasNewlineInRange;
+var getLast$4 = util.getLast;
+var getStringWidth$2 = util.getStringWidth;
+var printString$2 = util.printString;
+var printNumber$2 = util.printNumber;
+var hasIgnoreComment$3 = util.hasIgnoreComment;
+var skipWhitespace$1 = util.skipWhitespace;
+var hasNodeIgnoreComment$1 = util.hasNodeIgnoreComment;
+var getPenultimate$1 = util.getPenultimate;
+var startsWithNoLookaheadToken$1 = util.startsWithNoLookaheadToken;
+var getIndentSize$1 = util.getIndentSize;
+var matchAncestorTypes$1 = util.matchAncestorTypes;
+var getPreferredQuote$1 = util.getPreferredQuote;
+var isNextLineEmpty$4 = utilShared.isNextLineEmpty;
+var isNextLineEmptyAfterIndex$1 = utilShared.isNextLineEmptyAfterIndex;
+var getNextNonSpaceNonCommentCharacterIndex$2 = utilShared.getNextNonSpaceNonCommentCharacterIndex;
+var isIdentifierName = utils$2.keyword.isIdentifierNameES5;
+var insertPragma$7 = pragma$2.insertPragma;
+var printHtmlBinding = htmlBinding.printHtmlBinding;
+var hasNode = utils$6.hasNode;
+var hasFlowAnnotationComment = utils$6.hasFlowAnnotationComment;
+var hasFlowShorthandAnnotationComment = utils$6.hasFlowShorthandAnnotationComment;
+var _require$$6$builders = doc.builders;
+var concat$12 = _require$$6$builders.concat;
+var join$7 = _require$$6$builders.join;
+var line$8 = _require$$6$builders.line;
+var hardline$8 = _require$$6$builders.hardline;
+var softline$5 = _require$$6$builders.softline;
+var literalline$3 = _require$$6$builders.literalline;
+var group$10 = _require$$6$builders.group;
+var indent$6 = _require$$6$builders.indent;
+var align$1 = _require$$6$builders.align;
+var conditionalGroup$1 = _require$$6$builders.conditionalGroup;
+var fill$4 = _require$$6$builders.fill;
+var ifBreak$6 = _require$$6$builders.ifBreak;
+var breakParent$3 = _require$$6$builders.breakParent;
+var lineSuffixBoundary$1 = _require$$6$builders.lineSuffixBoundary;
+var addAlignmentToDoc$2 = _require$$6$builders.addAlignmentToDoc;
+var dedent$3 = _require$$6$builders.dedent;
+var _require$$6$utils = doc.utils;
+var willBreak$1 = _require$$6$utils.willBreak;
+var isLineNext$1 = _require$$6$utils.isLineNext;
+var isEmpty$1 = _require$$6$utils.isEmpty;
+var removeLines$2 = _require$$6$utils.removeLines;
+var printDocToString$1 = doc.printer.printDocToString;
+var uid = 0;
+
+function shouldPrintComma$1(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$3(path, options, printPath, args) {
+ var node = path.getValue();
+ var needsParens = false;
+ var linesWithoutParens = printPathNoParens(path, options, printPath, args);
+
+ if (!node || isEmpty$1(linesWithoutParens)) {
+ return linesWithoutParens;
+ }
+
+ var parentExportDecl = getParentExportDeclaration$1(path);
+ var decorators = [];
+
+ if (node.type === "ClassMethod" || node.type === "ClassProperty" || node.type === "TSAbstractClassProperty" || node.type === "ClassPrivateProperty") {// their decorators are handled themselves
+ } 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]))) {
+ var shouldBreak = node.type === "ClassExpression" || node.type === "ClassDeclaration" || hasNewlineBetweenOrAfterDecorators(node, options);
+ var separator = shouldBreak ? hardline$8 : line$8;
+ path.each(function (decoratorPath) {
+ var decorator = decoratorPath.getValue();
+
+ if (decorator.expression) {
+ decorator = decorator.expression;
+ } else {
+ decorator = decorator.callee;
+ }
+
+ decorators.push(printPath(decoratorPath), separator);
+ }, "decorators");
+
+ if (parentExportDecl) {
+ decorators.unshift(hardline$8);
+ }
+ } 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(function (decoratorPath) {
+ var decorator = decoratorPath.getValue();
+ var prefix = decorator.type === "Decorator" ? "" : "@";
+ decorators.push(prefix, printPath(decoratorPath), hardline$8);
+ }, "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);
+ }
+
+ var parts = [];
+
+ if (needsParens) {
+ parts.unshift("(");
+ }
+
+ parts.push(linesWithoutParens);
+
+ if (needsParens) {
+ var _node = path.getValue();
+
+ if (hasFlowShorthandAnnotationComment(_node)) {
+ parts.push(" /*");
+ parts.push(_node.trailingComments[0].value.trimLeft());
+ parts.push("*/");
+ _node.trailingComments[0].printed = true;
+ }
+
+ parts.push(")");
+ }
+
+ if (decorators.length > 0) {
+ return group$10(concat$12(decorators.concat(parts)));
+ }
+
+ return concat$12(parts);
+}
+
+function hasNewlineBetweenOrAfterDecorators(node, options) {
+ return hasNewlineInRange$1(options.originalText, options.locStart(node.decorators[0]), options.locEnd(getLast$4(node.decorators))) || hasNewline$3(options.originalText, options.locEnd(getLast$4(node.decorators)));
+}
+
+function printDecorators(path, options, print) {
+ var node = path.getValue();
+ return group$10(concat$12([join$7(line$8, path.map(print, "decorators")), hasNewlineBetweenOrAfterDecorators(node, options) ? hardline$8 : line$8]));
+}
+
+function hasPrettierIgnore$2(path) {
+ return hasIgnoreComment$3(path) || hasJsxIgnoreComment(path);
+}
+
+function hasJsxIgnoreComment(path) {
+ var node = path.getValue();
+ var parent = path.getParentNode();
+
+ if (!parent || !node || !isJSXNode(node) || !isJSXNode(parent)) {
+ return false;
+ } // Lookup the previous sibling, ignoring any empty JSXText elements
+
+
+ var index = parent.children.indexOf(node);
+ var prevSibling = null;
+
+ for (var i = index; i > 0; i--) {
+ var 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(function (comment) {
+ return comment.value.trim() === "prettier-ignore";
+ });
+}
+/**
+ * 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} testNodePropertyName - The property at which the test node can be found on the main node, eg "test".
+ * @property {boolean} breakNested - Whether to break all nested ternaries when one breaks.
+ * @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) {
+ var node = path.getValue();
+ var testNode = node[operatorOptions.testNodePropertyName];
+ var consequentNode = node[operatorOptions.consequentNodePropertyName];
+ var alternateNode = node[operatorOptions.alternateNodePropertyName];
+ var parts = []; // We print a ConditionalExpression in either "JSX mode" or "normal mode".
+ // See tests/jsx/conditional-expression.js for more info.
+
+ var jsxMode = false;
+ var parent = path.getParentNode();
+ var forceNoIndent = parent.type === operatorOptions.conditionalNodeType; // Find the outermost non-ConditionalExpression parent, and the outermost
+ // ConditionalExpression parent. We'll use these to determine if we should
+ // print in JSX mode.
+
+ var currentParent;
+ var previousParent;
+ var i = 0;
+
+ do {
+ previousParent = currentParent || node;
+ currentParent = path.getParentNode(i);
+ i++;
+ } while (currentParent && currentParent.type === operatorOptions.conditionalNodeType);
+
+ var firstNonConditionalParent = currentParent || parent;
+ var lastConditionalParent = previousParent;
+
+ if (operatorOptions.shouldCheckJsx && (isJSXNode(testNode) || isJSXNode(consequentNode) || isJSXNode(alternateNode) || conditionalExpressionChainContainsJSX(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.
+
+ var wrap = function wrap(doc$$2) {
+ return concat$12([ifBreak$6("(", ""), indent$6(concat$12([softline$5, doc$$2])), softline$5, ifBreak$6(")", "")]);
+ }; // The only things we don't wrap are:
+ // * Nested conditional expressions in alternates
+ // * null
+
+
+ var isNull = function isNull(node) {
+ return node.type === "NullLiteral" || node.type === "Literal" && node.value === null;
+ };
+
+ parts.push(" ? ", isNull(consequentNode) ? path.call(print, operatorOptions.consequentNodePropertyName) : wrap(path.call(print, operatorOptions.consequentNodePropertyName)), " : ", alternateNode.type === operatorOptions.conditionalNodeType || isNull(alternateNode) ? path.call(print, operatorOptions.alternateNodePropertyName) : wrap(path.call(print, operatorOptions.alternateNodePropertyName)));
+ } else {
+ // normal mode
+ var part = concat$12([line$8, "? ", consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$6("", "(") : "", align$1(2, path.call(print, operatorOptions.consequentNodePropertyName)), consequentNode.type === operatorOptions.conditionalNodeType ? ifBreak$6("", ")") : "", line$8, ": ", 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 ? part : options.useTabs ? dedent$3(indent$6(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.
+
+
+ var maybeGroup = function maybeGroup(doc$$2) {
+ return operatorOptions.breakNested ? parent === firstNonConditionalParent ? group$10(doc$$2) : doc$$2 : group$10(doc$$2);
+ }; // Break the closing paren to keep the chain right after it:
+ // (a
+ // ? b
+ // : c
+ // ).call()
+
+
+ var breakClosingParen = !jsxMode && (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed;
+ return maybeGroup(concat$12([].concat(function (testDoc) {
+ return (
+ /**
+ * a
+ * ? b
+ * : multiline
+ * test
+ * node
+ * ^^ align(2)
+ * ? d
+ * : e
+ */
+ parent.type === operatorOptions.conditionalNodeType && parent[operatorOptions.alternateNodePropertyName] === node ? align$1(2, testDoc) : testDoc
+ );
+ }(concat$12(operatorOptions.beforeParts())), forceNoIndent ? concat$12(parts) : indent$6(concat$12(parts)), operatorOptions.afterParts(breakClosingParen))));
+}
+
+function getTypeScriptMappedTypeModifier(tokenNode, keyword) {
+ if (tokenNode.type === "TSPlusToken") {
+ return "+" + keyword;
+ } else if (tokenNode.type === "TSMinusToken") {
+ return "-" + keyword;
+ }
+
+ return keyword;
+}
+
+function printPathNoParens(path, options, print, args) {
+ var n = path.getValue();
+ var semi = options.semi ? ";" : "";
+
+ if (!n) {
+ return "";
+ }
+
+ if (typeof n === "string") {
+ return n;
+ }
+
+ var htmlBinding$$1 = printHtmlBinding(path, options, print);
+
+ if (htmlBinding$$1) {
+ return htmlBinding$$1;
+ }
+
+ var parts = [];
+
+ switch (n.type) {
+ case "JsExpressionRoot":
+ return path.call(print, "node");
+
+ case "JsonRoot":
+ return concat$12([path.call(print, "node"), hardline$8]);
+
+ 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(function (programPath) {
+ return programPath.call(print, "interpreter");
+ }, "program"));
+ }
+
+ parts.push(path.call(print, "program"));
+ return concat$12(parts);
+
+ case "Program":
+ // Babel 6
+ if (n.directives) {
+ path.each(function (childPath) {
+ parts.push(print(childPath), semi, hardline$8);
+
+ if (isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) {
+ parts.push(hardline$8);
+ }
+ }, "directives");
+ }
+
+ parts.push(path.call(function (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.length || n.comments) {
+ parts.push(hardline$8);
+ }
+
+ return concat$12(parts);
+ // Babel extension.
+
+ case "EmptyStatement":
+ return "";
+
+ case "ExpressionStatement":
+ // Detect Flow-parsed directives
+ if (n.directive) {
+ return concat$12([nodeStr(n.expression, options, true), semi]);
+ } // Do not append semicolon after the only JSX element in a program
+
+
+ return concat$12([path.call(print, "expression"), isTheOnlyJSXElementInMarkdown(options, path) ? "" : semi]);
+ // Babel extension.
+
+ case "ParenthesizedExpression":
+ return concat$12(["(", path.call(print, "expression"), ")"]);
+
+ case "AssignmentExpression":
+ return printAssignment(n.left, path.call(print, "left"), concat$12([" ", n.operator]), n.right, path.call(print, "right"), options);
+
+ case "BinaryExpression":
+ case "LogicalExpression":
+ case "NGPipeExpression":
+ {
+ var parent = path.getParentNode();
+ var parentParent = path.getParentNode(1);
+ var isInsideParenthesis = n !== parent.body && (parent.type === "IfStatement" || parent.type === "WhileStatement" || parent.type === "DoWhileStatement");
+
+ var _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$12(_parts);
+ } // Break between the parens in unaries or in a member expression, i.e.
+ //
+ // (
+ // a &&
+ // b &&
+ // c
+ // ).call()
+
+
+ if (parent.type === "UnaryExpression" || (parent.type === "MemberExpression" || parent.type === "OptionalMemberExpression") && !parent.computed) {
+ return group$10(concat$12([indent$6(concat$12([softline$5, concat$12(_parts)])), softline$5]));
+ } // 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.
+
+
+ var shouldNotIndent = parent.type === "ReturnStatement" || parent.type === "JSXExpressionContainer" && parentParent.type === "JSXAttribute" || 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 !== "CallExpression";
+ var shouldIndentIfInlining = parent.type === "AssignmentExpression" || parent.type === "VariableDeclarator" || parent.type === "ClassProperty" || parent.type === "TSAbstractClassProperty" || parent.type === "ClassPrivateProperty" || parent.type === "ObjectProperty" || parent.type === "Property";
+ var samePrecedenceSubExpression = isBinaryish(n.left) && shouldFlatten$1(n.operator, n.left.operator);
+
+ if (shouldNotIndent || shouldInlineLogicalExpression(n) && !samePrecedenceSubExpression || !shouldInlineLogicalExpression(n) && shouldIndentIfInlining) {
+ return group$10(concat$12(_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 && (
+ //
+ //
+ //
+ // )
+
+
+ var hasJSX = isJSXNode(n.right);
+ var rest = concat$12(hasJSX ? _parts.slice(1, -1) : _parts.slice(1));
+ var groupId = Symbol("logicalChain-" + ++uid);
+ var chain = group$10(concat$12([// 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$6(rest)]), {
+ id: groupId
+ });
+
+ if (!hasJSX) {
+ return chain;
+ }
+
+ var jsxPart = getLast$4(_parts);
+ return group$10(concat$12([chain, ifBreak$6(indent$6(jsxPart), jsxPart, {
+ groupId: groupId
+ })]));
+ }
+
+ case "AssignmentPattern":
+ return concat$12([path.call(print, "left"), " = ", path.call(print, "right")]);
+
+ case "TSTypeAssertionExpression":
+ {
+ var shouldBreakAfterCast = !(n.expression.type === "ArrayExpression" || n.expression.type === "ObjectExpression");
+ var castGroup = group$10(concat$12(["<", indent$6(concat$12([softline$5, path.call(print, "typeAnnotation")])), softline$5, ">"]));
+ var exprContents = concat$12([ifBreak$6("("), indent$6(concat$12([softline$5, path.call(print, "expression")])), softline$5, ifBreak$6(")")]);
+
+ if (shouldBreakAfterCast) {
+ return conditionalGroup$1([concat$12([castGroup, path.call(print, "expression")]), concat$12([castGroup, group$10(exprContents, {
+ shouldBreak: true
+ })]), concat$12([castGroup, path.call(print, "expression")])]);
+ }
+
+ return group$10(concat$12([castGroup, path.call(print, "expression")]));
+ }
+
+ case "OptionalMemberExpression":
+ case "MemberExpression":
+ {
+ var _parent = path.getParentNode();
+
+ var firstNonMemberParent;
+ var i = 0;
+
+ do {
+ firstNonMemberParent = path.getParentNode(i);
+ i++;
+ } while (firstNonMemberParent && (firstNonMemberParent.type === "MemberExpression" || firstNonMemberParent.type === "OptionalMemberExpression" || firstNonMemberParent.type === "TSNonNullExpression"));
+
+ var 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$12([path.call(print, "object"), shouldInline ? printMemberLookup(path, options, print) : group$10(indent$6(concat$12([softline$5, printMemberLookup(path, options, print)])))]);
+ }
+
+ case "MetaProperty":
+ return concat$12([path.call(print, "meta"), ".", path.call(print, "property")]);
+
+ case "BindExpression":
+ if (n.object) {
+ parts.push(path.call(print, "object"));
+ }
+
+ parts.push(group$10(indent$6(concat$12([softline$5, printBindExpressionCallee(path, options, print)]))));
+ return concat$12(parts);
+
+ case "Identifier":
+ {
+ return concat$12([n.name, printOptionalToken(path), printTypeAnnotation(path, options, print)]);
+ }
+
+ case "SpreadElement":
+ case "SpreadElementPattern":
+ case "RestProperty":
+ case "SpreadProperty":
+ case "SpreadPropertyPattern":
+ case "RestElement":
+ case "ObjectTypeSpreadProperty":
+ return concat$12(["...", path.call(print, "argument"), printTypeAnnotation(path, options, print)]);
+
+ case "FunctionDeclaration":
+ case "FunctionExpression":
+ if (isNodeStartingWithDeclare(n, options)) {
+ parts.push("declare ");
+ }
+
+ parts.push(printFunctionDeclaration(path, print, options));
+
+ if (!n.body) {
+ parts.push(semi);
+ }
+
+ return concat$12(parts);
+
+ case "ArrowFunctionExpression":
+ {
+ if (n.async) {
+ parts.push("async ");
+ }
+
+ if (shouldPrintParamsWithoutParens(path, options)) {
+ parts.push(path.call(print, "params", 0));
+ } else {
+ parts.push(group$10(concat$12([printFunctionParams(path, print, options,
+ /* expandLast */
+ args && (args.expandLastArg || args.expandFirstArg),
+ /* printTypeParams */
+ true), printReturnType(path, print, options)])));
+ }
+
+ var dangling = comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true, function (comment) {
+ var nextCharacter = getNextNonSpaceNonCommentCharacterIndex$2(options.originalText, comment, options);
+ return options.originalText.substr(nextCharacter, 2) === "=>";
+ });
+
+ if (dangling) {
+ parts.push(" ", dangling);
+ }
+
+ parts.push(" =>");
+ var body = path.call(function (bodyPath) {
+ return print(bodyPath, args);
+ }, "body"); // We want to always keep these types of nodes on the same line
+ // as the arrow.
+
+ if (!hasLeadingOwnLineComment(options.originalText, n.body, options) && (n.body.type === "ArrayExpression" || n.body.type === "ObjectExpression" || n.body.type === "BlockStatement" || isJSXNode(n.body) || isTemplateOnItsOwnLine(n.body, options.originalText, options) || n.body.type === "ArrowFunctionExpression" || n.body.type === "DoExpression")) {
+ return group$10(concat$12([concat$12(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$10(concat$12([concat$12(parts), group$10(concat$12([" (", indent$6(concat$12([softline$5, body])), softline$5, ")"]))]));
+ } // 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 {.
+
+
+ var shouldAddSoftLine = (args && args.expandLastArg || path.getParentNode().type === "JSXExpressionContainer") && !(n.comments && n.comments.length);
+ var printTrailingComma = args && args.expandLastArg && shouldPrintComma$1(options, "all"); // In order to avoid confusion between
+ // a => a ? a : a
+ // a <= a ? a : a
+
+ var shouldAddParens = n.body.type === "ConditionalExpression" && !startsWithNoLookaheadToken$1(n.body,
+ /* forbidFunctionAndClass */
+ false);
+ return group$10(concat$12([concat$12(parts), group$10(concat$12([indent$6(concat$12([line$8, shouldAddParens ? ifBreak$6("", "(") : "", body, shouldAddParens ? ifBreak$6("", ")") : ""])), shouldAddSoftLine ? concat$12([ifBreak$6(printTrailingComma ? "," : ""), softline$5]) : ""]))]));
+ }
+
+ case "MethodDefinition":
+ case "TSAbstractMethodDefinition":
+ if (n.accessibility) {
+ parts.push(n.accessibility + " ");
+ }
+
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ if (n.type === "TSAbstractMethodDefinition") {
+ parts.push("abstract ");
+ }
+
+ parts.push(printMethod(path, options, print));
+ return concat$12(parts);
+
+ case "YieldExpression":
+ parts.push("yield");
+
+ if (n.delegate) {
+ parts.push("*");
+ }
+
+ if (n.argument) {
+ parts.push(" ", path.call(print, "argument"));
+ }
+
+ return concat$12(parts);
+
+ case "AwaitExpression":
+ return concat$12(["await ", path.call(print, "argument")]);
+
+ 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$12(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$12(parts);
+
+ case "ImportNamespaceSpecifier":
+ parts.push("* as ");
+
+ if (n.local) {
+ parts.push(path.call(print, "local"));
+ } else if (n.id) {
+ parts.push(path.call(print, "id"));
+ }
+
+ return concat$12(parts);
+
+ case "ImportDefaultSpecifier":
+ if (n.local) {
+ return path.call(print, "local");
+ }
+
+ return path.call(print, "id");
+
+ case "TSExportAssignment":
+ return concat$12(["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("* from ", path.call(print, "source"), semi);
+ return concat$12(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 + " ");
+ }
+
+ var standalones = [];
+ var grouped = [];
+
+ if (n.specifiers && n.specifiers.length > 0) {
+ path.each(function (specifierPath) {
+ var 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$7(", ", standalones));
+ }
+
+ if (standalones.length > 0 && grouped.length > 0) {
+ parts.push(", ");
+ }
+
+ if (grouped.length === 1 && standalones.length === 0 && n.specifiers && !n.specifiers.some(function (node) {
+ return node.comments;
+ })) {
+ parts.push(concat$12(["{", options.bracketSpacing ? " " : "", concat$12(grouped), options.bracketSpacing ? " " : "", "}"]));
+ } else if (grouped.length >= 1) {
+ parts.push(group$10(concat$12(["{", indent$6(concat$12([options.bracketSpacing ? line$8 : softline$5, join$7(concat$12([",", line$8]), grouped)])), ifBreak$6(shouldPrintComma$1(options) ? "," : ""), options.bracketSpacing ? line$8 : softline$5, "}"])));
+ }
+
+ 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$12(parts);
+ }
+
+ case "Import":
+ return "import";
+
+ case "BlockStatement":
+ {
+ var naked = path.call(function (bodyPath) {
+ return printStatementSequence(bodyPath, options, print);
+ }, "body");
+ var hasContent = n.body.find(function (node) {
+ return node.type !== "EmptyStatement";
+ });
+ var hasDirectives = n.directives && n.directives.length > 0;
+
+ var _parent2 = path.getParentNode();
+
+ var _parentParent = path.getParentNode(1);
+
+ if (!hasContent && !hasDirectives && !hasDanglingComments(n) && (_parent2.type === "ArrowFunctionExpression" || _parent2.type === "FunctionExpression" || _parent2.type === "FunctionDeclaration" || _parent2.type === "ObjectMethod" || _parent2.type === "ClassMethod" || _parent2.type === "ForStatement" || _parent2.type === "WhileStatement" || _parent2.type === "DoWhileStatement" || _parent2.type === "DoExpression" || _parent2.type === "CatchClause" && !_parentParent.finalizer)) {
+ return "{}";
+ }
+
+ parts.push("{"); // Babel 6
+
+ if (hasDirectives) {
+ path.each(function (childPath) {
+ parts.push(indent$6(concat$12([hardline$8, print(childPath), semi])));
+
+ if (isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) {
+ parts.push(hardline$8);
+ }
+ }, "directives");
+ }
+
+ if (hasContent) {
+ parts.push(indent$6(concat$12([hardline$8, naked])));
+ }
+
+ parts.push(comments.printDanglingComments(path, options));
+ parts.push(hardline$8, "}");
+ return concat$12(parts);
+ }
+
+ case "ReturnStatement":
+ parts.push("return");
+
+ if (n.argument) {
+ if (returnArgumentHasLeadingComment(options, n.argument)) {
+ parts.push(concat$12([" (", indent$6(concat$12([hardline$8, path.call(print, "argument")])), hardline$8, ")"]));
+ } else if (n.argument.type === "LogicalExpression" || n.argument.type === "BinaryExpression" || n.argument.type === "SequenceExpression") {
+ parts.push(group$10(concat$12([ifBreak$6(" (", " "), indent$6(concat$12([softline$5, path.call(print, "argument")])), softline$5, ifBreak$6(")")])));
+ } else {
+ parts.push(" ", path.call(print, "argument"));
+ }
+ }
+
+ if (hasDanglingComments(n)) {
+ parts.push(" ", comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true));
+ }
+
+ parts.push(semi);
+ return concat$12(parts);
+
+ case "NewExpression":
+ case "OptionalCallExpression":
+ case "CallExpression":
+ {
+ var isNew = n.type === "NewExpression";
+ var 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") || n.callee.type === "Import" || // Template literals as single arguments
+ n.arguments.length === 1 && isTemplateOnItsOwnLine(n.arguments[0], options.originalText, options) || // Keep test declarations on a single line
+ // e.g. `it('long name', () => {`
+ !isNew && isTestCall(n, path.getParentNode())) {
+ return concat$12([isNew ? "new " : "", path.call(print, "callee"), optional, printFunctionTypeParameters(path, options, print), concat$12(["(", join$7(", ", 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.
+
+
+ var isIdentifierWithFlowAnnotation = n.callee.type === "Identifier" && hasFlowAnnotationComment(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(n.callee)) {
+ return printMemberChain(path, options, print);
+ }
+
+ return concat$12([isNew ? "new " : "", path.call(print, "callee"), optional, isIdentifierWithFlowAnnotation ? "/*:: ".concat(n.callee.trailingComments[0].value.substring(2).trim(), " */") : "", printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]);
+ }
+
+ case "TSInterfaceDeclaration":
+ if (isNodeStartingWithDeclare(n, options)) {
+ 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.heritage.length) {
+ parts.push(group$10(indent$6(concat$12([softline$5, "extends ", (n.heritage.length === 1 ? identity$1 : indent$6)(join$7(concat$12([",", line$8]), path.map(print, "heritage"))), " "]))));
+ }
+
+ parts.push(path.call(print, "body"));
+ return concat$12(parts);
+
+ case "ObjectTypeInternalSlot":
+ return concat$12([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":
+ {
+ var propertiesField;
+
+ if (n.type === "TSTypeLiteral") {
+ propertiesField = "members";
+ } else if (n.type === "TSInterfaceBody") {
+ propertiesField = "body";
+ } else {
+ propertiesField = "properties";
+ }
+
+ var isTypeAnnotation = n.type === "ObjectTypeAnnotation";
+ var fields = [];
+
+ if (isTypeAnnotation) {
+ fields.push("indexers", "callProperties", "internalSlots");
+ }
+
+ fields.push(propertiesField);
+ var firstProperty = fields.map(function (field) {
+ return n[field][0];
+ }).sort(function (a, b) {
+ return options.locStart(a) - options.locStart(b);
+ })[0];
+
+ var _parent3 = path.getParentNode(0);
+
+ var isFlowInterfaceLikeBody = isTypeAnnotation && _parent3 && (_parent3.type === "InterfaceDeclaration" || _parent3.type === "DeclareInterface" || _parent3.type === "DeclareClass") && path.getName() === "body";
+ var shouldBreak = n.type === "TSInterfaceBody" || isFlowInterfaceLikeBody || n.type === "ObjectPattern" && _parent3.type !== "FunctionDeclaration" && _parent3.type !== "FunctionExpression" && _parent3.type !== "ArrowFunctionExpression" && _parent3.type !== "AssignmentPattern" && _parent3.type !== "CatchClause" && n.properties.some(function (property) {
+ return property.value && (property.value.type === "ObjectPattern" || property.value.type === "ArrayPattern");
+ }) || n.type !== "ObjectPattern" && firstProperty && hasNewlineInRange$1(options.originalText, options.locStart(n), options.locStart(firstProperty));
+ var separator = isFlowInterfaceLikeBody ? ";" : n.type === "TSInterfaceBody" || n.type === "TSTypeLiteral" ? ifBreak$6(semi, ";") : ",";
+ var leftBrace = n.exact ? "{|" : "{";
+ var 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.
+
+ var propsAndLoc = [];
+ fields.forEach(function (field) {
+ path.each(function (childPath) {
+ var node = childPath.getValue();
+ propsAndLoc.push({
+ node: node,
+ printed: print(childPath),
+ loc: options.locStart(node)
+ });
+ }, field);
+ });
+ var separatorParts = [];
+ var props = propsAndLoc.sort(function (a, b) {
+ return a.loc - b.loc;
+ }).map(function (prop) {
+ var result = concat$12(separatorParts.concat(group$10(prop.printed)));
+ separatorParts = [separator, line$8];
+
+ if ((prop.node.type === "TSPropertySignature" || prop.node.type === "TSMethodSignature") && hasNodeIgnoreComment$1(prop.node)) {
+ separatorParts.shift();
+ }
+
+ if (isNextLineEmpty$4(options.originalText, prop.node, options)) {
+ separatorParts.push(hardline$8);
+ }
+
+ return result;
+ });
+
+ if (n.inexact) {
+ props.push(concat$12(separatorParts.concat(group$10("..."))));
+ }
+
+ var lastElem = getLast$4(n[propertiesField]);
+ var canHaveTrailingSeparator = !(lastElem && (lastElem.type === "RestProperty" || lastElem.type === "RestElement" || hasNodeIgnoreComment$1(lastElem) || n.inexact));
+ var content;
+
+ if (props.length === 0 && !n.typeAnnotation) {
+ if (!hasDanglingComments(n)) {
+ return concat$12([leftBrace, rightBrace]);
+ }
+
+ content = group$10(concat$12([leftBrace, comments.printDanglingComments(path, options), softline$5, rightBrace, printOptionalToken(path)]));
+ } else {
+ content = concat$12([leftBrace, indent$6(concat$12([options.bracketSpacing ? line$8 : softline$5, concat$12(props)])), ifBreak$6(canHaveTrailingSeparator && (separator !== "," || shouldPrintComma$1(options)) ? separator : ""), concat$12([options.bracketSpacing ? line$8 : softline$5, 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
+
+
+ var parentParentParent = path.getParentNode(2);
+
+ if (n.type === "ObjectPattern" && _parent3 && shouldHugArguments(_parent3) && _parent3.params[0] === n || shouldHugType(n) && parentParentParent && shouldHugArguments(parentParentParent) && parentParentParent.params[0].typeAnnotation && parentParentParent.params[0].typeAnnotation.typeAnnotation === n) {
+ return content;
+ }
+
+ return group$10(content, {
+ shouldBreak: 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 {
+ var printedLeft;
+
+ if (n.computed) {
+ printedLeft = concat$12(["[", path.call(print, "key"), "]"]);
+ } else {
+ printedLeft = printPropertyKey(path, options, print);
+ }
+
+ parts.push(printAssignment(n.key, printedLeft, ":", n.value, path.call(print, "value"), options));
+ }
+
+ return concat$12(parts);
+ // Babel 6
+
+ case "ClassMethod":
+ if (n.decorators && n.decorators.length !== 0) {
+ parts.push(printDecorators(path, options, print));
+ }
+
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ parts = parts.concat(printObjectMethod(path, options, print));
+ return concat$12(parts);
+ // Babel 6
+
+ case "ObjectMethod":
+ return printObjectMethod(path, options, print);
+
+ case "Decorator":
+ return concat$12(["@", path.call(print, "expression"), path.call(print, "callee")]);
+
+ case "ArrayExpression":
+ case "ArrayPattern":
+ if (n.elements.length === 0) {
+ if (!hasDanglingComments(n)) {
+ parts.push("[]");
+ } else {
+ parts.push(group$10(concat$12(["[", comments.printDanglingComments(path, options), softline$5, "]"])));
+ }
+ } else {
+ var _lastElem = getLast$4(n.elements);
+
+ var 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
+
+ var needsForcedTrailingComma = canHaveTrailingComma && _lastElem === null;
+ parts.push(group$10(concat$12(["[", indent$6(concat$12([softline$5, printArrayItems(path, options, "elements", print)])), needsForcedTrailingComma ? "," : "", ifBreak$6(canHaveTrailingComma && !needsForcedTrailingComma && shouldPrintComma$1(options) ? "," : ""), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), softline$5, "]"])));
+ }
+
+ parts.push(printOptionalToken(path), printTypeAnnotation(path, options, print));
+ return concat$12(parts);
+
+ case "SequenceExpression":
+ {
+ var _parent4 = path.getParentNode(0);
+
+ if (_parent4.type === "ExpressionStatement" || _parent4.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.
+ var _parts2 = [];
+ path.each(function (p) {
+ if (p.getName() === 0) {
+ _parts2.push(print(p));
+ } else {
+ _parts2.push(",", indent$6(concat$12([line$8, print(p)])));
+ }
+ }, "expressions");
+ return group$10(concat$12(_parts2));
+ }
+
+ return group$10(concat$12([join$7(concat$12([",", line$8]), 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$2(n.extra.raw);
+
+ case "BigIntLiteral":
+ return concat$12([printNumber$2(n.extra.rawValue), "n"]);
+
+ 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$2(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
+
+
+ var grandParent = path.getParentNode(1);
+ var 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(" ");
+ }
+
+ parts.push(path.call(print, "argument"));
+ return concat$12(parts);
+
+ case "UpdateExpression":
+ parts.push(path.call(print, "argument"), n.operator);
+
+ if (n.prefix) {
+ parts.reverse();
+ }
+
+ return concat$12(parts);
+
+ case "ConditionalExpression":
+ return printTernaryOperator(path, options, print, {
+ beforeParts: function beforeParts() {
+ return [path.call(print, "test")];
+ },
+ afterParts: function afterParts(breakClosingParen) {
+ return [breakClosingParen ? softline$5 : ""];
+ },
+ shouldCheckJsx: true,
+ conditionalNodeType: "ConditionalExpression",
+ consequentNodePropertyName: "consequent",
+ alternateNodePropertyName: "alternate",
+ testNodePropertyName: "test",
+ breakNested: true
+ });
+
+ case "VariableDeclaration":
+ {
+ var printed = path.map(function (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.
+
+ var parentNode = path.getParentNode();
+ var isParentForLoop = parentNode.type === "ForStatement" || parentNode.type === "ForInStatement" || parentNode.type === "ForOfStatement" || parentNode.type === "ForAwaitStatement";
+ var hasValue = n.declarations.some(function (decl) {
+ return decl.init;
+ });
+ var 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$6(printed[0]);
+ }
+
+ parts = [isNodeStartingWithDeclare(n, options) ? "declare " : "", n.kind, firstVariable ? concat$12([" ", firstVariable]) : "", indent$6(concat$12(printed.slice(1).map(function (p) {
+ return concat$12([",", hasValue && !isParentForLoop ? hardline$8 : line$8, p]);
+ })))];
+
+ if (!(isParentForLoop && parentNode.body !== n)) {
+ parts.push(semi);
+ }
+
+ return group$10(concat$12(parts));
+ }
+
+ case "VariableDeclarator":
+ return printAssignment(n.id, concat$12([path.call(print, "id"), path.call(print, "typeParameters")]), " =", n.init, n.init && path.call(print, "init"), options);
+
+ case "WithStatement":
+ return group$10(concat$12(["with (", path.call(print, "object"), ")", adjustClause(n.body, path.call(print, "body"))]));
+
+ case "IfStatement":
+ {
+ var con = adjustClause(n.consequent, path.call(print, "consequent"));
+ var opening = group$10(concat$12(["if (", group$10(concat$12([indent$6(concat$12([softline$5, path.call(print, "test")])), softline$5])), ")", con]));
+ parts.push(opening);
+
+ if (n.alternate) {
+ var commentOnOwnLine = hasTrailingComment(n.consequent) && n.consequent.comments.some(function (comment) {
+ return comment.trailing && !comments$3.isBlockComment(comment);
+ }) || needsHardlineAfterDanglingComment(n);
+ var elseOnSameLine = n.consequent.type === "BlockStatement" && !commentOnOwnLine;
+ parts.push(elseOnSameLine ? " " : hardline$8);
+
+ if (hasDanglingComments(n)) {
+ parts.push(comments.printDanglingComments(path, options, true), commentOnOwnLine ? hardline$8 : " ");
+ }
+
+ parts.push("else", group$10(adjustClause(n.alternate, path.call(print, "alternate"), n.alternate.type === "IfStatement")));
+ }
+
+ return concat$12(parts);
+ }
+
+ case "ForStatement":
+ {
+ var _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.
+
+
+ var _dangling = comments.printDanglingComments(path, options,
+ /* sameLine */
+ true);
+
+ var printedComments = _dangling ? concat$12([_dangling, softline$5]) : "";
+
+ if (!n.init && !n.test && !n.update) {
+ return concat$12([printedComments, group$10(concat$12(["for (;;)", _body]))]);
+ }
+
+ return concat$12([printedComments, group$10(concat$12(["for (", group$10(concat$12([indent$6(concat$12([softline$5, path.call(print, "init"), ";", line$8, path.call(print, "test"), ";", line$8, path.call(print, "update")])), softline$5])), ")", _body]))]);
+ }
+
+ case "WhileStatement":
+ return group$10(concat$12(["while (", group$10(concat$12([indent$6(concat$12([softline$5, path.call(print, "test")])), softline$5])), ")", adjustClause(n.body, path.call(print, "body"))]));
+
+ case "ForInStatement":
+ // Note: esprima can't actually parse "for each (".
+ return group$10(concat$12([n.each ? "for each (" : "for (", path.call(print, "left"), " in ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
+
+ case "ForOfStatement":
+ case "ForAwaitStatement":
+ {
+ // Babylon 7 removed ForAwaitStatement in favor of ForOfStatement
+ // with `"await": true`:
+ // https://github.com/estree/estree/pull/138
+ var isAwait = n.type === "ForAwaitStatement" || n.await;
+ return group$10(concat$12(["for", isAwait ? " await" : "", " (", path.call(print, "left"), " of ", path.call(print, "right"), ")", adjustClause(n.body, path.call(print, "body"))]));
+ }
+
+ case "DoWhileStatement":
+ {
+ var clause = adjustClause(n.body, path.call(print, "body"));
+ var doBody = group$10(concat$12(["do", clause]));
+ parts = [doBody];
+
+ if (n.body.type === "BlockStatement") {
+ parts.push(" ");
+ } else {
+ parts.push(hardline$8);
+ }
+
+ parts.push("while (");
+ parts.push(group$10(concat$12([indent$6(concat$12([softline$5, path.call(print, "test")])), softline$5])), ")", semi);
+ return concat$12(parts);
+ }
+
+ case "DoExpression":
+ return concat$12(["do ", path.call(print, "body")]);
+
+ case "BreakStatement":
+ parts.push("break");
+
+ if (n.label) {
+ parts.push(" ", path.call(print, "label"));
+ }
+
+ parts.push(semi);
+ return concat$12(parts);
+
+ case "ContinueStatement":
+ parts.push("continue");
+
+ if (n.label) {
+ parts.push(" ", path.call(print, "label"));
+ }
+
+ parts.push(semi);
+ return concat$12(parts);
+
+ case "LabeledStatement":
+ if (n.body.type === "EmptyStatement") {
+ return concat$12([path.call(print, "label"), ":;"]);
+ }
+
+ return concat$12([path.call(print, "label"), ": ", path.call(print, "body")]);
+
+ case "TryStatement":
+ return concat$12(["try ", path.call(print, "block"), n.handler ? concat$12([" ", path.call(print, "handler")]) : "", n.finalizer ? concat$12([" finally ", path.call(print, "finalizer")]) : ""]);
+
+ case "CatchClause":
+ if (n.param) {
+ var hasComments = n.param.comments && n.param.comments.some(function (comment) {
+ return !comments$3.isBlockComment(comment) || comment.leading && hasNewline$3(options.originalText, options.locEnd(comment)) || comment.trailing && hasNewline$3(options.originalText, options.locStart(comment), {
+ backwards: true
+ });
+ });
+ var param = path.call(print, "param");
+ return concat$12(["catch ", hasComments ? concat$12(["(", indent$6(concat$12([softline$5, param])), softline$5, ") "]) : concat$12(["(", param, ") "]), path.call(print, "body")]);
+ }
+
+ return concat$12(["catch ", path.call(print, "body")]);
+
+ case "ThrowStatement":
+ return concat$12(["throw ", path.call(print, "argument"), semi]);
+ // Note: ignoring n.lexical because it has no printing consequences.
+
+ case "SwitchStatement":
+ return concat$12([group$10(concat$12(["switch (", indent$6(concat$12([softline$5, path.call(print, "discriminant")])), softline$5, ")"])), " {", n.cases.length > 0 ? indent$6(concat$12([hardline$8, join$7(hardline$8, path.map(function (casePath) {
+ var caseNode = casePath.getValue();
+ return concat$12([casePath.call(print), n.cases.indexOf(caseNode) !== n.cases.length - 1 && isNextLineEmpty$4(options.originalText, caseNode, options) ? hardline$8 : ""]);
+ }, "cases"))])) : "", hardline$8, "}"]);
+
+ case "SwitchCase":
+ {
+ if (n.test) {
+ parts.push("case ", path.call(print, "test"), ":");
+ } else {
+ parts.push("default:");
+ }
+
+ var consequent = n.consequent.filter(function (node) {
+ return node.type !== "EmptyStatement";
+ });
+
+ if (consequent.length > 0) {
+ var cons = path.call(function (consequentPath) {
+ return printStatementSequence(consequentPath, options, print);
+ }, "consequent");
+ parts.push(consequent.length === 1 && consequent[0].type === "BlockStatement" ? concat$12([" ", cons]) : indent$6(concat$12([hardline$8, cons])));
+ }
+
+ return concat$12(parts);
+ }
+ // JSX extensions below.
+
+ case "DebuggerStatement":
+ return concat$12(["debugger", semi]);
+
+ case "JSXAttribute":
+ parts.push(path.call(print, "name"));
+
+ if (n.value) {
+ var res;
+
+ if (isStringLiteral(n.value)) {
+ var raw = rawText(n.value); // Unescape all quotes so we get an accurate preferred quote
+
+ var final = raw.replace(/'/g, "'").replace(/"/g, '"');
+ var quote = getPreferredQuote$1(final, options.jsxSingleQuote ? "'" : '"');
+
+ var _escape = quote === "'" ? "'" : """;
+
+ final = final.slice(1, -1).replace(new RegExp(quote, "g"), _escape);
+ res = concat$12([quote, final, quote]);
+ } else {
+ res = path.call(print, "value");
+ }
+
+ parts.push("=", res);
+ }
+
+ return concat$12(parts);
+
+ case "JSXIdentifier":
+ return "" + n.name;
+
+ case "JSXNamespacedName":
+ return join$7(":", [path.call(print, "namespace"), path.call(print, "name")]);
+
+ case "JSXMemberExpression":
+ return join$7(".", [path.call(print, "object"), path.call(print, "property")]);
+
+ case "TSQualifiedName":
+ return join$7(".", [path.call(print, "left"), path.call(print, "right")]);
+
+ case "JSXSpreadAttribute":
+ case "JSXSpreadChild":
+ {
+ return concat$12(["{", path.call(function (p) {
+ var printed = concat$12(["...", print(p)]);
+ var n = p.getValue();
+
+ if (!n.comments || !n.comments.length) {
+ return printed;
+ }
+
+ return concat$12([indent$6(concat$12([softline$5, comments.printComments(p, function () {
+ return printed;
+ }, options)])), softline$5]);
+ }, n.type === "JSXSpreadAttribute" ? "argument" : "expression"), "}"]);
+ }
+
+ case "JSXExpressionContainer":
+ {
+ var _parent5 = path.getParentNode(0);
+
+ var preventInline = _parent5.type === "JSXAttribute" && n.expression.comments && n.expression.comments.length > 0;
+
+ var _shouldInline = !preventInline && (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 === "JSXEmptyExpression" || n.expression.type === "TemplateLiteral" || n.expression.type === "TaggedTemplateExpression" || n.expression.type === "DoExpression" || isJSXNode(_parent5) && (n.expression.type === "ConditionalExpression" || isBinaryish(n.expression)));
+
+ if (_shouldInline) {
+ return group$10(concat$12(["{", path.call(print, "expression"), lineSuffixBoundary$1, "}"]));
+ }
+
+ return group$10(concat$12(["{", indent$6(concat$12([softline$5, path.call(print, "expression")])), softline$5, lineSuffixBoundary$1, "}"]));
+ }
+
+ case "JSXFragment":
+ case "TSJsxFragment":
+ case "JSXElement":
+ {
+ var elem = comments.printComments(path, function () {
+ return printJSXElement(path, options, print);
+ }, options);
+ return maybeWrapJSXElementInParens(path, elem);
+ }
+
+ case "JSXOpeningElement":
+ {
+ var _n = path.getValue();
+
+ var nameHasComments = _n.name && _n.name.comments && _n.name.comments.length > 0; // Don't break self-closing elements with no attributes and no comments
+
+ if (_n.selfClosing && !_n.attributes.length && !nameHasComments) {
+ return concat$12(["<", 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(_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$10(concat$12(["<", path.call(print, "name"), path.call(print, "typeParameters"), " ", concat$12(path.map(print, "attributes")), _n.selfClosing ? " />" : ">"]));
+ }
+
+ var lastAttrHasTrailingComments = _n.attributes.length && hasTrailingComment(getLast$4(_n.attributes));
+ var 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
+
+ var _shouldBreak = _n.attributes && _n.attributes.some(function (attr) {
+ return attr.value && isStringLiteral(attr.value) && attr.value.value.includes("\n");
+ });
+
+ return group$10(concat$12(["<", path.call(print, "name"), path.call(print, "typeParameters"), concat$12([indent$6(concat$12(path.map(function (attr) {
+ return concat$12([line$8, print(attr)]);
+ }, "attributes"))), _n.selfClosing ? line$8 : bracketSameLine ? ">" : softline$5]), _n.selfClosing ? "/>" : bracketSameLine ? "" : ">"]), {
+ shouldBreak: _shouldBreak
+ });
+ }
+
+ case "JSXClosingElement":
+ return concat$12(["", path.call(print, "name"), ">"]);
+
+ case "JSXOpeningFragment":
+ case "JSXClosingFragment":
+ case "TSJsxOpeningFragment":
+ case "TSJsxClosingFragment":
+ {
+ var hasComment = n.comments && n.comments.length;
+ var hasOwnLineComment = hasComment && !n.comments.every(comments$3.isBlockComment);
+ var isOpeningFragment = n.type === "JSXOpeningFragment" || n.type === "TSJsxOpeningFragment";
+ return concat$12([isOpeningFragment ? "<" : "", indent$6(concat$12([hasOwnLineComment ? hardline$8 : hasComment && !isOpeningFragment ? " " : "", comments.printDanglingComments(path, options, true)])), hasOwnLineComment ? hardline$8 : "", ">"]);
+ }
+
+ case "JSXText":
+ /* istanbul ignore next */
+ throw new Error("JSXTest should be handled by JSXElement");
+
+ case "JSXEmptyExpression":
+ {
+ var requiresHardline = n.comments && !n.comments.every(comments$3.isBlockComment);
+ return concat$12([comments.printDanglingComments(path, options,
+ /* sameIndent */
+ !requiresHardline), requiresHardline ? hardline$8 : ""]);
+ }
+
+ case "ClassBody":
+ if (!n.comments && n.body.length === 0) {
+ return "{}";
+ }
+
+ return concat$12(["{", n.body.length > 0 ? indent$6(concat$12([hardline$8, path.call(function (bodyPath) {
+ return printStatementSequence(bodyPath, options, print);
+ }, "body")])) : comments.printDanglingComments(path, options), hardline$8, "}"]);
+
+ 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.static) {
+ parts.push("static ");
+ }
+
+ if (n.type === "TSAbstractClassProperty") {
+ parts.push("abstract ");
+ }
+
+ if (n.readonly) {
+ parts.push("readonly ");
+ }
+
+ var variance = getFlowVariance(n);
+
+ if (variance) {
+ parts.push(variance);
+ }
+
+ if (n.computed) {
+ parts.push("[", path.call(print, "key"), "]");
+ } else {
+ parts.push(printPropertyKey(path, options, print));
+ }
+
+ parts.push(printOptionalToken(path));
+ parts.push(printTypeAnnotation(path, options, print));
+
+ if (n.value) {
+ parts.push(" =", printAssignmentRight(n.key, n.value, path.call(print, "value"), options));
+ }
+
+ parts.push(semi);
+ return group$10(concat$12(parts));
+ }
+
+ case "ClassDeclaration":
+ case "ClassExpression":
+ case "TSAbstractClassDeclaration":
+ if (isNodeStartingWithDeclare(n, options)) {
+ parts.push("declare ");
+ }
+
+ parts.push(concat$12(printClass(path, options, print)));
+ return concat$12(parts);
+
+ case "TSInterfaceHeritage":
+ parts.push(path.call(print, "id"));
+
+ if (n.typeParameters) {
+ parts.push(path.call(print, "typeParameters"));
+ }
+
+ return concat$12(parts);
+
+ case "TemplateElement":
+ return join$7(literalline$3, n.value.raw.split(/\r?\n/g));
+
+ case "TemplateLiteral":
+ {
+ var expressions = path.map(print, "expressions");
+
+ var _parentNode = path.getParentNode();
+ /**
+ * 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
+ */
+
+
+ var jestEachTriggerRegex = /^[xf]?(describe|it|test)$/;
+
+ if (_parentNode.type === "TaggedTemplateExpression" && _parentNode.quasi === n && _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))) {
+ /**
+ * a | b | expected
+ * ${1} | ${1} | ${2}
+ * ${1} | ${2} | ${3}
+ * ${2} | ${1} | ${3}
+ */
+ var headerNames = n.quasis[0].value.raw.trim().split(/\s*\|\s*/);
+
+ if (headerNames.length > 1 || headerNames.some(function (headerName) {
+ return headerName.length !== 0;
+ })) {
+ var stringifiedExpressions = expressions.map(function (doc$$2) {
+ return "${" + printDocToString$1(doc$$2, Object.assign({}, options, {
+ printWidth: Infinity
+ })).formatted + "}";
+ });
+ var tableBody = [{
+ hasLineBreak: false,
+ cells: []
+ }];
+
+ for (var _i = 1; _i < n.quasis.length; _i++) {
+ var row = tableBody[tableBody.length - 1];
+ var correspondingExpression = stringifiedExpressions[_i - 1];
+ row.cells.push(correspondingExpression);
+
+ if (correspondingExpression.indexOf("\n") !== -1) {
+ row.hasLineBreak = true;
+ }
+
+ if (n.quasis[_i].value.raw.indexOf("\n") !== -1) {
+ tableBody.push({
+ hasLineBreak: false,
+ cells: []
+ });
+ }
+ }
+
+ var maxColumnCount = tableBody.reduce(function (maxColumnCount, row) {
+ return Math.max(maxColumnCount, row.cells.length);
+ }, headerNames.length);
+ var maxColumnWidths = Array.from(new Array(maxColumnCount), function () {
+ return 0;
+ });
+ var table = [{
+ cells: headerNames
+ }].concat(tableBody.filter(function (row) {
+ return row.cells.length !== 0;
+ }));
+ table.filter(function (row) {
+ return !row.hasLineBreak;
+ }).forEach(function (row) {
+ row.cells.forEach(function (cell, index) {
+ maxColumnWidths[index] = Math.max(maxColumnWidths[index], getStringWidth$2(cell));
+ });
+ });
+ parts.push("`", indent$6(concat$12([hardline$8, join$7(hardline$8, table.map(function (row) {
+ return join$7(" | ", row.cells.map(function (cell, index) {
+ return row.hasLineBreak ? cell : cell + " ".repeat(maxColumnWidths[index] - getStringWidth$2(cell));
+ }));
+ }))])), hardline$8, "`");
+ return concat$12(parts);
+ }
+ }
+
+ parts.push("`");
+ path.each(function (childPath) {
+ var 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 `.
+ var tabWidth = options.tabWidth;
+ var indentSize = getIndentSize$1(childPath.getValue().value.raw, tabWidth);
+ var _printed = expressions[i];
+
+ 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") {
+ _printed = concat$12([indent$6(concat$12([softline$5, _printed])), softline$5]);
+ }
+
+ var aligned = addAlignmentToDoc$2(_printed, indentSize, tabWidth);
+ parts.push(group$10(concat$12(["${", aligned, lineSuffixBoundary$1, "}"])));
+ }
+ }, "quasis");
+ parts.push("`");
+ return concat$12(parts);
+ }
+ // These types are unprintable because they serve as abstract
+ // supertypes for other (printable) types.
+
+ case "TaggedTemplateExpression":
+ return concat$12([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":
+ {
+ var typesField = n.type === "TSTupleType" ? "elementTypes" : "types";
+ return group$10(concat$12(["[", indent$6(concat$12([softline$5, printArrayItems(path, options, typesField, print)])), // TypeScript doesn't support trailing commas in tuple types
+ n.type === "TSTupleType" ? "" : ifBreak$6(shouldPrintComma$1(options) ? "," : ""), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), softline$5, "]"]));
+ }
+
+ case "ExistsTypeAnnotation":
+ return "*";
+
+ case "EmptyTypeAnnotation":
+ return "empty";
+
+ case "AnyTypeAnnotation":
+ return "any";
+
+ case "MixedTypeAnnotation":
+ return "mixed";
+
+ case "ArrayTypeAnnotation":
+ return concat$12([path.call(print, "elementType"), "[]"]);
+
+ case "BooleanTypeAnnotation":
+ return "boolean";
+
+ case "BooleanLiteralTypeAnnotation":
+ return "" + n.value;
+
+ case "DeclareClass":
+ return printFlowDeclaration(path, printClass(path, options, print));
+
+ case "DeclareFunction":
+ // For TypeScript the DeclareFunction node shares the AST
+ // structure with FunctionDeclaration
+ if (n.params) {
+ return concat$12(["declare ", printFunctionDeclaration(path, print, options), semi]);
+ }
+
+ 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$12(["declare export * from ", path.call(print, "source")]);
+
+ case "DeclareExportDeclaration":
+ return concat$12(["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$12(parts);
+ }
+
+ case "FunctionTypeAnnotation":
+ case "TSFunctionType":
+ {
+ // FunctionTypeAnnotation is ambiguous:
+ // declare function foo(a: B): void; OR
+ // var A: (a: B) => void;
+ var _parent6 = path.getParentNode(0);
+
+ var _parentParent2 = path.getParentNode(1);
+
+ var _parentParentParent = path.getParentNode(2);
+
+ var isArrowFunctionTypeAnnotation = n.type === "TSFunctionType" || !((_parent6.type === "ObjectTypeProperty" || _parent6.type === "ObjectTypeInternalSlot") && !getFlowVariance(_parent6) && !_parent6.optional && options.locStart(_parent6) === options.locStart(n) || _parent6.type === "ObjectTypeCallProperty" || _parentParentParent && _parentParentParent.type === "DeclareFunction");
+ var needsColon = isArrowFunctionTypeAnnotation && (_parent6.type === "TypeAnnotation" || _parent6.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 :(
+
+ var needsParens = needsColon && isArrowFunctionTypeAnnotation && (_parent6.type === "TypeAnnotation" || _parent6.type === "TSTypeAnnotation") && _parentParent2.type === "ArrowFunctionExpression";
+
+ if (isObjectTypePropertyAFunction(_parent6, 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$10(concat$12(parts));
+ }
+
+ case "TSRestType":
+ return concat$12(["...", path.call(print, "typeAnnotation")]);
+
+ case "TSOptionalType":
+ return concat$12([path.call(print, "typeAnnotation"), "?"]);
+
+ case "FunctionTypeParam":
+ return concat$12([path.call(print, "name"), printOptionalToken(path), n.name ? ": " : "", path.call(print, "typeAnnotation")]);
+
+ case "GenericTypeAnnotation":
+ return concat$12([path.call(print, "id"), path.call(print, "typeParameters")]);
+
+ case "DeclareInterface":
+ case "InterfaceDeclaration":
+ case "InterfaceTypeAnnotation":
+ {
+ if (n.type === "DeclareInterface" || isNodeStartingWithDeclare(n, options)) {
+ 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$10(indent$6(concat$12([line$8, "extends ", (n.extends.length === 1 ? identity$1 : indent$6)(join$7(concat$12([",", line$8]), path.map(print, "extends")))]))));
+ }
+
+ parts.push(" ", path.call(print, "body"));
+ return group$10(concat$12(parts));
+ }
+
+ case "ClassImplements":
+ case "InterfaceExtends":
+ return concat$12([path.call(print, "id"), path.call(print, "typeParameters")]);
+
+ case "TSIntersectionType":
+ case "IntersectionTypeAnnotation":
+ {
+ var types = path.map(print, "types");
+ var result = [];
+ var wasIndented = false;
+
+ for (var _i2 = 0; _i2 < types.length; ++_i2) {
+ if (_i2 === 0) {
+ result.push(types[_i2]);
+ } else if (isObjectType(n.types[_i2 - 1]) && isObjectType(n.types[_i2])) {
+ // If both are objects, don't indent
+ result.push(concat$12([" & ", wasIndented ? indent$6(types[_i2]) : types[_i2]]));
+ } else if (!isObjectType(n.types[_i2 - 1]) && !isObjectType(n.types[_i2])) {
+ // If no object is involved, go to the next line if it breaks
+ result.push(indent$6(concat$12([" &", line$8, types[_i2]])));
+ } else {
+ // If you go from object to non-object or vis-versa, then inline it
+ if (_i2 > 1) {
+ wasIndented = true;
+ }
+
+ result.push(" & ", _i2 > 1 ? indent$6(types[_i2]) : types[_i2]);
+ }
+ }
+
+ return group$10(concat$12(result));
+ }
+
+ case "TSUnionType":
+ case "UnionTypeAnnotation":
+ {
+ // single-line variation
+ // A | B | C
+ // multi-line variation
+ // | A
+ // | B
+ // | C
+ var _parent7 = path.getParentNode();
+
+ var _parentParent3 = path.getParentNode(1); // If there's a leading comment, the parent is doing the indentation
+
+
+ var shouldIndent = _parent7.type !== "TypeParameterInstantiation" && _parent7.type !== "TSTypeParameterInstantiation" && _parent7.type !== "GenericTypeAnnotation" && _parent7.type !== "TSTypeReference" && !(_parent7.type === "FunctionTypeParam" && !_parent7.name) && _parentParent3.type !== "TSTypeAssertionExpression" && !((_parent7.type === "TypeAlias" || _parent7.type === "VariableDeclarator") && hasLeadingOwnLineComment(options.originalText, n, options)); // {
+ // a: string
+ // } | null | void
+ // should be inlined and not be printed in the multi-line variant
+
+ var shouldHug = shouldHugType(n); // We want to align the children but without its comment, so it looks like
+ // | child1
+ // // comment
+ // | child2
+
+ var _printed2 = path.map(function (typePath) {
+ var printedType = typePath.call(print);
+
+ if (!shouldHug) {
+ printedType = align$1(2, printedType);
+ }
+
+ return comments.printComments(typePath, function () {
+ return printedType;
+ }, options);
+ }, "types");
+
+ if (shouldHug) {
+ return join$7(" | ", _printed2);
+ }
+
+ var code = concat$12([ifBreak$6(concat$12([shouldIndent ? line$8 : "", "| "])), join$7(concat$12([line$8, "| "]), _printed2)]);
+ var hasParens;
+
+ if (n.type === "TSUnionType") {
+ var greatGrandParent = path.getParentNode(2);
+ var greatGreatGrandParent = path.getParentNode(3);
+ hasParens = greatGrandParent && greatGrandParent.type === "TSParenthesizedType" && greatGreatGrandParent && (greatGreatGrandParent.type === "TSUnionType" || greatGreatGrandParent.type === "TSIntersectionType");
+ } else {
+ hasParens = needsParens_1(path, options);
+ }
+
+ if (hasParens) {
+ return group$10(concat$12([indent$6(code), softline$5]));
+ }
+
+ return group$10(shouldIndent ? indent$6(code) : code);
+ }
+
+ case "NullableTypeAnnotation":
+ return concat$12(["?", path.call(print, "typeAnnotation")]);
+
+ case "TSNullKeyword":
+ case "NullLiteralTypeAnnotation":
+ return "null";
+
+ case "ThisTypeAnnotation":
+ return "this";
+
+ case "NumberTypeAnnotation":
+ return "number";
+
+ case "ObjectTypeCallProperty":
+ if (n.static) {
+ parts.push("static ");
+ }
+
+ parts.push(path.call(print, "value"));
+ return concat$12(parts);
+
+ case "ObjectTypeIndexer":
+ {
+ var _variance = getFlowVariance(n);
+
+ return concat$12([_variance || "", "[", path.call(print, "id"), n.id ? ": " : "", path.call(print, "key"), "]: ", path.call(print, "value")]);
+ }
+
+ case "ObjectTypeProperty":
+ {
+ var _variance2 = getFlowVariance(n);
+
+ var modifier = "";
+
+ if (n.proto) {
+ modifier = "proto ";
+ } else if (n.static) {
+ modifier = "static ";
+ }
+
+ return concat$12([modifier, isGetterOrSetter(n) ? n.kind + " " : "", _variance2 || "", printPropertyKey(path, options, print), printOptionalToken(path), isFunctionNotation(n, options) ? "" : ": ", path.call(print, "value")]);
+ }
+
+ case "QualifiedTypeIdentifier":
+ return concat$12([path.call(print, "qualification"), ".", path.call(print, "id")]);
+
+ case "StringLiteralTypeAnnotation":
+ return nodeStr(n, options);
+
+ case "NumberLiteralTypeAnnotation":
+ assert$3.strictEqual(_typeof(n.value), "number");
+
+ if (n.extra != null) {
+ return printNumber$2(n.extra.raw);
+ }
+
+ return printNumber$2(n.raw);
+
+ case "StringTypeAnnotation":
+ return "string";
+
+ case "DeclareTypeAlias":
+ case "TypeAlias":
+ {
+ if (n.type === "DeclareTypeAlias" || isNodeStartingWithDeclare(n, options)) {
+ parts.push("declare ");
+ }
+
+ var _printed3 = printAssignmentRight(n.id, n.right, path.call(print, "right"), options);
+
+ parts.push("type ", path.call(print, "id"), path.call(print, "typeParameters"), " =", _printed3, semi);
+ return group$10(concat$12(parts));
+ }
+
+ case "TypeCastExpression":
+ {
+ var value = path.getValue(); // Flow supports a comment syntax for specifying type annotations: https://flow.org/en/docs/types/comments/.
+ // Unfortunately, its parser doesn't differentiate between comment annotations and regular
+ // annotations when producing an AST. So to preserve parentheses around type casts that use
+ // the comment syntax, we need to hackily read the source itself to see if the code contains
+ // a type annotation comment.
+ //
+ // Note that we're able to use the normal whitespace regex here because the Flow parser has
+ // already deemed this AST node to be a type cast. Only the Babylon parser needs the
+ // non-line-break whitespace regex, which is why hasFlowShorthandAnnotationComment() is
+ // implemented differently.
+
+ var commentSyntax = value && value.typeAnnotation && value.typeAnnotation.range && options.originalText.substring(value.typeAnnotation.range[0]).match(/^\/\*\s*:/);
+ return concat$12(["(", path.call(print, "expression"), commentSyntax ? " /*" : "", ": ", path.call(print, "typeAnnotation"), commentSyntax ? " */" : "", ")"]);
+ }
+
+ case "TypeParameterDeclaration":
+ case "TypeParameterInstantiation":
+ {
+ var _value = path.getValue();
+
+ var commentStart = _value.range ? options.originalText.substring(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.
+
+ var _commentSyntax = commentStart >= 0 && options.originalText.substring(commentStart).match(/^\/\*\s*::/);
+
+ if (_commentSyntax) {
+ return concat$12(["/*:: ", 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":
+ {
+ var _parent8 = path.getParentNode();
+
+ if (_parent8.type === "TSMappedType") {
+ parts.push("[", path.call(print, "name"));
+
+ if (n.constraint) {
+ parts.push(" in ", path.call(print, "constraint"));
+ }
+
+ parts.push("]");
+ return concat$12(parts);
+ }
+
+ var _variance3 = getFlowVariance(n);
+
+ if (_variance3) {
+ parts.push(_variance3);
+ }
+
+ 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"));
+ }
+
+ return concat$12(parts);
+ }
+
+ case "TypeofTypeAnnotation":
+ return concat$12(["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$12(["%checks(", path.call(print, "value"), ")"]);
+
+ case "TSAbstractKeyword":
+ return "abstract";
+
+ case "TSAnyKeyword":
+ return "any";
+
+ case "TSAsyncKeyword":
+ return "async";
+
+ case "TSBooleanKeyword":
+ return "boolean";
+
+ 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$12([path.call(print, "expression"), " as ", path.call(print, "typeAnnotation")]);
+
+ case "TSArrayType":
+ return concat$12([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 ");
+ }
+
+ if (n.computed) {
+ parts.push("[");
+ }
+
+ parts.push(printPropertyKey(path, options, print));
+
+ if (n.computed) {
+ parts.push("]");
+ }
+
+ parts.push(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$12(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$12(parts);
+
+ case "TSTypeReference":
+ return concat$12([path.call(print, "typeName"), printTypeParameters(path, options, print, "typeParameters")]);
+
+ case "TSTypeQuery":
+ return concat$12(["typeof ", path.call(print, "exprName")]);
+
+ case "TSParenthesizedType":
+ {
+ return path.call(print, "typeAnnotation");
+ }
+
+ case "TSIndexSignature":
+ {
+ var _parent9 = path.getParentNode();
+
+ return concat$12([n.export ? "export " : "", n.accessibility ? concat$12([n.accessibility, " "]) : "", n.static ? "static " : "", n.readonly ? "readonly " : "", "[", path.call(print, "index"), "]: ", path.call(print, "typeAnnotation"), _parent9.type === "ClassBody" ? semi : ""]);
+ }
+
+ case "TSTypePredicate":
+ return concat$12([path.call(print, "parameterName"), " is ", path.call(print, "typeAnnotation")]);
+
+ case "TSNonNullExpression":
+ return concat$12([path.call(print, "expression"), "!"]);
+
+ case "TSThisType":
+ return "this";
+
+ case "TSImportType":
+ return concat$12([!n.isTypeOf ? "" : "typeof ", "import(", path.call(print, "parameter"), ")", !n.qualifier ? "" : concat$12([".", path.call(print, "qualifier")]), printTypeParameters(path, options, print, "typeParameters")]);
+
+ case "TSLiteralType":
+ return path.call(print, "literal");
+
+ case "TSIndexedAccessType":
+ return concat$12([path.call(print, "objectType"), "[", path.call(print, "indexType"), "]"]);
+
+ case "TSConstructSignature":
+ case "TSConstructorType":
+ case "TSCallSignature":
+ {
+ if (n.type !== "TSCallSignature") {
+ parts.push("new ");
+ }
+
+ parts.push(group$10(printFunctionParams(path, print, options,
+ /* expandArg */
+ false,
+ /* printTypeParams */
+ true)));
+
+ if (n.typeAnnotation) {
+ var isType = n.type === "TSConstructorType";
+ parts.push(isType ? " => " : ": ", path.call(print, "typeAnnotation"));
+ }
+
+ return concat$12(parts);
+ }
+
+ case "TSTypeOperator":
+ return concat$12([n.operator, " ", path.call(print, "typeAnnotation")]);
+
+ case "TSMappedType":
+ return group$10(concat$12(["{", indent$6(concat$12([options.bracketSpacing ? line$8 : softline$5, n.readonlyToken ? concat$12([getTypeScriptMappedTypeModifier(n.readonlyToken, "readonly"), " "]) : "", printTypeScriptModifiers(path, options, print), path.call(print, "typeParameter"), n.questionToken ? getTypeScriptMappedTypeModifier(n.questionToken, "?") : "", ": ", path.call(print, "typeAnnotation")])), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), options.bracketSpacing ? line$8 : softline$5, "}"]));
+
+ case "TSMethodSignature":
+ parts.push(n.accessibility ? concat$12([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.typeAnnotation) {
+ parts.push(": ", path.call(print, "typeAnnotation"));
+ }
+
+ return group$10(concat$12(parts));
+
+ case "TSNamespaceExportDeclaration":
+ parts.push("export as namespace ", path.call(print, "name"));
+
+ if (options.semi) {
+ parts.push(";");
+ }
+
+ return group$10(concat$12(parts));
+
+ case "TSEnumDeclaration":
+ if (isNodeStartingWithDeclare(n, options)) {
+ 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$10(concat$12(["{", comments.printDanglingComments(path, options), softline$5, "}"])));
+ } else {
+ parts.push(group$10(concat$12(["{", indent$6(concat$12([hardline$8, printArrayItems(path, options, "members", print), shouldPrintComma$1(options, "es5") ? "," : ""])), comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), hardline$8, "}"])));
+ }
+
+ return concat$12(parts);
+
+ case "TSEnumMember":
+ parts.push(path.call(print, "id"));
+
+ if (n.initializer) {
+ parts.push(" = ", path.call(print, "initializer"));
+ }
+
+ return concat$12(parts);
+
+ case "TSImportEqualsDeclaration":
+ parts.push(printTypeScriptModifiers(path, options, print), "import ", path.call(print, "name"), " = ", path.call(print, "moduleReference"));
+
+ if (options.semi) {
+ parts.push(";");
+ }
+
+ return group$10(concat$12(parts));
+
+ case "TSExternalModuleReference":
+ return concat$12(["require(", path.call(print, "expression"), ")"]);
+
+ case "TSModuleDeclaration":
+ {
+ var _parent10 = path.getParentNode();
+
+ var isExternalModule = isLiteral(n.id);
+ var parentIsDeclaration = _parent10.type === "TSModuleDeclaration";
+ var bodyIsDeclaration = n.body && n.body.type === "TSModuleDeclaration";
+
+ if (parentIsDeclaration) {
+ parts.push(".");
+ } else {
+ if (n.declare === true) {
+ parts.push("declare ");
+ }
+
+ parts.push(printTypeScriptModifiers(path, options, print));
+ var textBetweenNodeAndItsId = options.originalText.slice(options.locStart(n), options.locStart(n.id)); // Global declaration looks like this:
+ // (declare)? global { ... }
+
+ var isGlobalDeclaration = n.id.type === "Identifier" && n.id.name === "global" && !/namespace|module/.test(textBetweenNodeAndItsId);
+
+ if (!isGlobalDeclaration) {
+ parts.push(isExternalModule || /\smodule\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(" {", indent$6(concat$12([line$8, path.call(function (bodyPath) {
+ return comments.printDanglingComments(bodyPath, options, true);
+ }, "body"), group$10(path.call(print, "body"))])), line$8, "}");
+ } else {
+ parts.push(semi);
+ }
+
+ return concat$12(parts);
+ }
+
+ case "TSModuleBlock":
+ return path.call(function (bodyPath) {
+ return printStatementSequence(bodyPath, options, print);
+ }, "body");
+
+ case "PrivateName":
+ return concat$12(["#", path.call(print, "id")]);
+
+ case "TSConditionalType":
+ return printTernaryOperator(path, options, print, {
+ beforeParts: function beforeParts() {
+ return [path.call(print, "checkType"), " ", "extends", " ", path.call(print, "extendsType")];
+ },
+ afterParts: function afterParts() {
+ return [];
+ },
+ shouldCheckJsx: false,
+ conditionalNodeType: "TSConditionalType",
+ consequentNodePropertyName: "trueType",
+ alternateNodePropertyName: "falseType",
+ testNodePropertyName: "checkType",
+ breakNested: true
+ });
+
+ case "TSInferType":
+ return concat$12(["infer", " ", path.call(print, "typeParameter")]);
+
+ case "InterpreterDirective":
+ parts.push("#!", n.value, hardline$8);
+
+ if (isNextLineEmpty$4(options.originalText, n, options)) {
+ parts.push(hardline$8);
+ }
+
+ return concat$12(parts);
+
+ case "NGRoot":
+ return concat$12([].concat(path.call(print, "node"), !n.node.comments || n.node.comments.length === 0 ? [] : concat$12([" //", n.node.comments[0].value.trimRight()])));
+
+ case "NGChainedExpression":
+ return group$10(join$7(concat$12([";", line$8]), path.map(function (childPath) {
+ return hasNgSideEffect(childPath) ? print(childPath) : concat$12(["(", print(childPath), ")"]);
+ }, "expressions")));
+
+ case "NGEmptyExpression":
+ return "";
+
+ case "NGQuotedExpression":
+ return concat$12([n.prefix, ":", n.value]);
+
+ case "NGMicrosyntax":
+ return concat$12(path.map(function (childPath, index) {
+ return concat$12([index === 0 ? "" : isNgForOf(childPath) ? " " : concat$12([";", line$8]), 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$12([path.call(print, "expression"), n.alias === null ? "" : concat$12([" as ", path.call(print, "alias")])]);
+
+ case "NGMicrosyntaxKeyedExpression":
+ return concat$12([path.call(print, "key"), isNgForOf(path) ? " " : ": ", path.call(print, "expression")]);
+
+ case "NGMicrosyntaxLet":
+ return concat$12(["let ", path.call(print, "key"), n.value === null ? "" : concat$12([" = ", path.call(print, "value")])]);
+
+ case "NGMicrosyntaxAs":
+ return concat$12([path.call(print, "key"), " as ", path.call(print, "alias")]);
+
+ default:
+ /* istanbul ignore next */
+ throw new Error("unknown type: " + JSON.stringify(n.type));
+ }
+}
+/** prefer `let hero of heros` over `let hero; of: heros` */
+
+
+function isNgForOf(path) {
+ var node = path.getValue();
+ var index = path.getName();
+ var parentNode = path.getParentNode();
+ return node.type === "NGMicrosyntaxKeyedExpression" && node.key.name === "of" && index === 1 && parentNode.body[0].type === "NGMicrosyntaxLet" && parentNode.body[0].value === null;
+}
+/** identify if an angular expression seems to have side effects */
+
+
+function hasNgSideEffect(path) {
+ return hasNode(path.getValue(), function (node) {
+ switch (node.type) {
+ case undefined:
+ return false;
+
+ case "CallExpression":
+ case "OptionalCallExpression":
+ case "AssignmentExpression":
+ return true;
+ }
+ });
+}
+
+function printStatementSequence(path, options, print) {
+ var printed = [];
+ var bodyNode = path.getNode();
+ var isClass = bodyNode.type === "ClassBody";
+ path.map(function (stmtPath, i) {
+ var 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;
+ }
+
+ var stmtPrinted = print(stmtPath);
+ var text = options.originalText;
+ var 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(options, stmtPath) && stmtNeedsASIProtection(stmtPath, options)) {
+ if (stmt.comments && stmt.comments.some(function (comment) {
+ return comment.leading;
+ })) {
+ parts.push(print(stmtPath, {
+ needsSemi: true
+ }));
+ } else {
+ parts.push(";", stmtPrinted);
+ }
+ } else {
+ parts.push(stmtPrinted);
+ }
+
+ if (!options.semi && isClass) {
+ if (classPropMayCauseASIProblems(stmtPath)) {
+ parts.push(";");
+ } else if (stmt.type === "ClassProperty") {
+ var nextChild = bodyNode.body[i + 1];
+
+ if (classChildNeedsASIProtection(nextChild)) {
+ parts.push(";");
+ }
+ }
+ }
+
+ if (isNextLineEmpty$4(text, stmt, options) && !isLastStatement(stmtPath)) {
+ parts.push(hardline$8);
+ }
+
+ printed.push(concat$12(parts));
+ });
+ return join$7(hardline$8, printed);
+}
+
+function printPropertyKey(path, options, print) {
+ var node = path.getNode();
+ var key = node.key;
+
+ if (key.type === "Identifier" && !node.computed && options.parser === "json") {
+ // a -> "a"
+ return path.call(function (keyPath) {
+ return comments.printComments(keyPath, function () {
+ return JSON.stringify(key.name);
+ }, options);
+ }, "key");
+ }
+
+ if (isStringLiteral(key) && isIdentifierName(key.value) && !node.computed && options.parser !== "json" && !(options.parser === "typescript" && node.type === "ClassProperty")) {
+ // 'a' -> a
+ return path.call(function (keyPath) {
+ return comments.printComments(keyPath, function () {
+ return key.value;
+ }, options);
+ }, "key");
+ }
+
+ return path.call(print, "key");
+}
+
+function printMethod(path, options, print) {
+ var node = path.getNode();
+ var semi = options.semi ? ";" : "";
+ var kind = node.kind;
+ var parts = [];
+
+ if (node.type === "ObjectMethod" || node.type === "ClassMethod") {
+ node.value = node;
+ }
+
+ if (node.value.async) {
+ parts.push("async ");
+ }
+
+ if (!kind || kind === "init" || kind === "method" || kind === "constructor") {
+ if (node.value.generator) {
+ parts.push("*");
+ }
+ } else {
+ assert$3.ok(kind === "get" || kind === "set");
+ parts.push(kind, " ");
+ }
+
+ var key = printPropertyKey(path, options, print);
+
+ if (node.computed) {
+ key = concat$12(["[", key, "]"]);
+ }
+
+ parts.push(key, concat$12(path.call(function (valuePath) {
+ return [printFunctionTypeParameters(valuePath, options, print), group$10(concat$12([printFunctionParams(valuePath, print, options), printReturnType(valuePath, print, options)]))];
+ }, "value")));
+
+ if (!node.value.body || node.value.body.length === 0) {
+ parts.push(semi);
+ } else {
+ parts.push(" ", path.call(print, "value", "body"));
+ }
+
+ return concat$12(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 === "TSTypeAssertionExpression" || arg.type === "TSAsExpression" || arg.type === "FunctionExpression" || arg.type === "ArrowFunctionExpression" && !arg.returnType && (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(arg.body));
+}
+
+function shouldGroupLastArg(args) {
+ var lastArg = getLast$4(args);
+ var penultimateArg = getPenultimate$1(args);
+ return !hasLeadingComment(lastArg) && !hasTrailingComment(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;
+ }
+
+ var firstArg = args[0];
+ var secondArg = args[1];
+ 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 isSimpleFlowType(node) {
+ var flowTypeAnnotations = ["AnyTypeAnnotation", "NullLiteralTypeAnnotation", "GenericTypeAnnotation", "ThisTypeAnnotation", "NumberTypeAnnotation", "VoidTypeAnnotation", "EmptyTypeAnnotation", "MixedTypeAnnotation", "BooleanTypeAnnotation", "BooleanLiteralTypeAnnotation", "StringTypeAnnotation"];
+ return node && flowTypeAnnotations.indexOf(node.type) !== -1 && !(node.type === "GenericTypeAnnotation" && node.typeParameters);
+}
+
+var functionCompositionFunctionNames = new Set(["pipe", // RxJS, Ramda
+"pipeP", // Ramda
+"pipeK", // Ramda
+"compose", // Ramda, Redux
+"composeFlipped", // Not from any library, but common in Haskell, so supported
+"composeP", // Ramda
+"composeK", // Ramda
+"flow", // Lodash
+"flowRight", // Lodash
+"connect", // Redux
+"createSelector" // Reselect
+]);
+
+function isFunctionCompositionFunction(node) {
+ switch (node.type) {
+ case "OptionalMemberExpression":
+ case "MemberExpression":
+ {
+ return isFunctionCompositionFunction(node.property);
+ }
+
+ case "Identifier":
+ {
+ return functionCompositionFunctionNames.has(node.name);
+ }
+
+ case "StringLiteral":
+ case "Literal":
+ {
+ return functionCompositionFunctionNames.has(node.value);
+ }
+ }
+}
+
+function printArgumentsList(path, options, print) {
+ var node = path.getValue();
+ var args = node.arguments;
+
+ if (args.length === 0) {
+ return concat$12(["(", comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true), ")"]);
+ }
+
+ var anyArgEmptyLine = false;
+ var hasEmptyLineFollowingFirstArg = false;
+ var lastArgIndex = args.length - 1;
+ var printedArguments = path.map(function (argPath, index) {
+ var arg = argPath.getNode();
+ var parts = [print(argPath)];
+
+ if (index === lastArgIndex) {// do nothing
+ } else if (isNextLineEmpty$4(options.originalText, arg, options)) {
+ if (index === 0) {
+ hasEmptyLineFollowingFirstArg = true;
+ }
+
+ anyArgEmptyLine = true;
+ parts.push(",", hardline$8, hardline$8);
+ } else {
+ parts.push(",", line$8);
+ }
+
+ return concat$12(parts);
+ }, "arguments");
+ var maybeTrailingComma = shouldPrintComma$1(options, "all") ? "," : "";
+
+ function allArgsBrokenOut() {
+ return group$10(concat$12(["(", indent$6(concat$12([line$8, concat$12(printedArguments)])), maybeTrailingComma, line$8, ")"]), {
+ shouldBreak: true
+ });
+ } // We want to get
+ // pipe(
+ // x => x + 1,
+ // x => x - 1
+ // )
+ // here, but not
+ // process.stdout.pipe(socket)
+
+
+ if (isFunctionCompositionFunction(node.callee) && args.length > 1) {
+ return allArgsBrokenOut();
+ }
+
+ var shouldGroupFirst = shouldGroupFirstArg(args);
+ var shouldGroupLast = shouldGroupLastArg(args);
+
+ if (shouldGroupFirst || shouldGroupLast) {
+ var shouldBreak = (shouldGroupFirst ? printedArguments.slice(1).some(willBreak$1) : printedArguments.slice(0, -1).some(willBreak$1)) || anyArgEmptyLine; // We want to print the last argument with a special flag
+
+ var printedExpanded;
+ var i = 0;
+ path.each(function (argPath) {
+ if (shouldGroupFirst && i === 0) {
+ printedExpanded = [concat$12([argPath.call(function (p) {
+ return print(p, {
+ expandFirstArg: true
+ });
+ }), printedArguments.length > 1 ? "," : "", hasEmptyLineFollowingFirstArg ? hardline$8 : line$8, hasEmptyLineFollowingFirstArg ? hardline$8 : ""])].concat(printedArguments.slice(1));
+ }
+
+ if (shouldGroupLast && i === args.length - 1) {
+ printedExpanded = printedArguments.slice(0, -1).concat(argPath.call(function (p) {
+ return print(p, {
+ expandLastArg: true
+ });
+ }));
+ }
+
+ i++;
+ }, "arguments");
+ var somePrintedArgumentsWillBreak = printedArguments.some(willBreak$1);
+ return concat$12([somePrintedArgumentsWillBreak ? breakParent$3 : "", conditionalGroup$1([concat$12([ifBreak$6(indent$6(concat$12(["(", softline$5, concat$12(printedExpanded)])), concat$12(["(", concat$12(printedExpanded)])), somePrintedArgumentsWillBreak ? concat$12([ifBreak$6(maybeTrailingComma), softline$5]) : "", ")"]), shouldGroupFirst ? concat$12(["(", group$10(printedExpanded[0], {
+ shouldBreak: true
+ }), concat$12(printedExpanded.slice(1)), ")"]) : concat$12(["(", concat$12(printedArguments.slice(0, -1)), group$10(getLast$4(printedExpanded), {
+ shouldBreak: true
+ }), ")"]), allArgsBrokenOut()], {
+ shouldBreak: shouldBreak
+ })]);
+ }
+
+ return group$10(concat$12(["(", indent$6(concat$12([softline$5, concat$12(printedArguments)])), ifBreak$6(shouldPrintComma$1(options, "all") ? "," : ""), softline$5, ")"]), {
+ shouldBreak: printedArguments.some(willBreak$1) || anyArgEmptyLine
+ });
+}
+
+function printTypeAnnotation(path, options, print) {
+ var node = path.getValue();
+
+ if (!node.typeAnnotation) {
+ return "";
+ }
+
+ var parentNode = path.getParentNode();
+ var isDefinite = node.definite || parentNode && parentNode.type === "VariableDeclarator" && parentNode.definite;
+ var isFunctionDeclarationIdentifier = parentNode.type === "DeclareFunction" && parentNode.id === node;
+
+ if (isFlowAnnotationComment(options.originalText, node.typeAnnotation, options)) {
+ return concat$12([" /*: ", path.call(print, "typeAnnotation"), " */"]);
+ }
+
+ return concat$12([isFunctionDeclarationIdentifier ? "" : isDefinite ? "!: " : ": ", path.call(print, "typeAnnotation")]);
+}
+
+function printFunctionTypeParameters(path, options, print) {
+ var 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) {
+ var fun = path.getValue();
+ var paramsField = fun.parameters ? "parameters" : "params";
+ var typeParams = printTypeParams ? printFunctionTypeParameters(path, options, print) : "";
+ var printed = [];
+
+ if (fun[paramsField]) {
+ printed = path.map(print, paramsField);
+ }
+
+ if (fun.rest) {
+ printed.push(concat$12(["...", path.call(print, "rest")]));
+ }
+
+ if (printed.length === 0) {
+ return concat$12([typeParams, "(", comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true, function (comment) {
+ return getNextNonSpaceNonCommentCharacter$1(options.originalText, comment, options.locEnd) === ")";
+ }), ")"]);
+ }
+
+ var lastParam = getLast$4(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 dont 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 (expandArg && !(fun[paramsField] && fun[paramsField].some(function (n) {
+ return n.comments;
+ }))) {
+ return group$10(concat$12([removeLines$2(typeParams), "(", join$7(", ", printed.map(removeLines$2)), ")"]));
+ } // Single object destructuring should hug
+ //
+ // function({
+ // a,
+ // b,
+ // c
+ // }) {}
+
+
+ if (shouldHugArguments(fun)) {
+ return concat$12([typeParams, "(", join$7(", ", printed), ")"]);
+ }
+
+ var parent = path.getParentNode(); // don't break in specs, eg; `it("should maintain parens around done even when long", (done) => {})`
+
+ if (isTestCall(parent)) {
+ return concat$12([typeParams, "(", join$7(", ", printed), ")"]);
+ }
+
+ var isFlowShorthandWithOneArg = (isObjectTypePropertyAFunction(parent, options) || isTypeAnnotationAFunction(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(fun[paramsField][0].typeAnnotation) && !fun.rest;
+
+ if (isFlowShorthandWithOneArg) {
+ if (options.arrowParens === "always") {
+ return concat$12(["(", concat$12(printed), ")"]);
+ }
+
+ return concat$12(printed);
+ }
+
+ var canHaveTrailingComma = !(lastParam && lastParam.type === "RestElement") && !fun.rest;
+ return concat$12([typeParams, "(", indent$6(concat$12([softline$5, join$7(concat$12([",", line$8]), printed)])), ifBreak$6(canHaveTrailingComma && shouldPrintComma$1(options, "all") ? "," : ""), softline$5, ")"]);
+}
+
+function shouldPrintParamsWithoutParens(path, options) {
+ if (options.arrowParens === "always") {
+ return false;
+ }
+
+ if (options.arrowParens === "avoid") {
+ var 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(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) {
+ var n = path.getValue();
+ var parts = [];
+
+ if (n.async) {
+ parts.push("async ");
+ }
+
+ parts.push("function");
+
+ if (n.generator) {
+ parts.push("*");
+ }
+
+ if (n.id) {
+ parts.push(" ", path.call(print, "id"));
+ }
+
+ parts.push(printFunctionTypeParameters(path, options, print), group$10(concat$12([printFunctionParams(path, print, options), printReturnType(path, print, options)])), n.body ? " " : "", path.call(print, "body"));
+ return concat$12(parts);
+}
+
+function printObjectMethod(path, options, print) {
+ var objMethod = path.getValue();
+ var parts = [];
+
+ if (objMethod.async) {
+ parts.push("async ");
+ }
+
+ if (objMethod.generator) {
+ parts.push("*");
+ }
+
+ if (objMethod.method || objMethod.kind === "get" || objMethod.kind === "set") {
+ return printMethod(path, options, print);
+ }
+
+ var key = printPropertyKey(path, options, print);
+
+ if (objMethod.computed) {
+ parts.push("[", key, "]");
+ } else {
+ parts.push(key);
+ }
+
+ parts.push(printFunctionTypeParameters(path, options, print), group$10(concat$12([printFunctionParams(path, print, options), printReturnType(path, print, options)])), " ", path.call(print, "body"));
+ return concat$12(parts);
+}
+
+function printReturnType(path, print, options) {
+ var n = path.getValue();
+ var returnType = path.call(print, "returnType");
+
+ if (n.returnType && isFlowAnnotationComment(options.originalText, n.returnType, options)) {
+ return concat$12([" /*: ", returnType, " */"]);
+ }
+
+ var 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$12(parts);
+}
+
+function printExportDeclaration(path, options, print) {
+ var decl = path.getValue();
+ var semi = options.semi ? ";" : "";
+ var parts = ["export "];
+ var isDefault = decl["default"] || decl.type === "ExportDefaultDeclaration";
+
+ if (isDefault) {
+ parts.push("default ");
+ }
+
+ parts.push(comments.printDanglingComments(path, options,
+ /* sameIndent */
+ true));
+
+ if (needsHardlineAfterDanglingComment(decl)) {
+ parts.push(hardline$8);
+ }
+
+ if (decl.declaration) {
+ parts.push(path.call(print, "declaration"));
+
+ if (isDefault && decl.declaration.type !== "ClassDeclaration" && decl.declaration.type !== "FunctionDeclaration" && decl.declaration.type !== "TSAbstractClassDeclaration" && decl.declaration.type !== "TSInterfaceDeclaration" && decl.declaration.type !== "DeclareClass" && decl.declaration.type !== "DeclareFunction") {
+ parts.push(semi);
+ }
+ } else {
+ if (decl.specifiers && decl.specifiers.length > 0) {
+ var specifiers = [];
+ var defaultSpecifiers = [];
+ var namespaceSpecifiers = [];
+ path.each(function (specifierPath) {
+ var 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$12(["* as ", print(specifierPath)]));
+ }
+ }, "specifiers");
+ var isNamespaceFollowed = namespaceSpecifiers.length !== 0 && specifiers.length !== 0;
+ var isDefaultFollowed = defaultSpecifiers.length !== 0 && (namespaceSpecifiers.length !== 0 || specifiers.length !== 0);
+ parts.push(decl.exportKind === "type" ? "type " : "", concat$12(defaultSpecifiers), concat$12([isDefaultFollowed ? ", " : ""]), concat$12(namespaceSpecifiers), concat$12([isNamespaceFollowed ? ", " : ""]), specifiers.length !== 0 ? group$10(concat$12(["{", indent$6(concat$12([options.bracketSpacing ? line$8 : softline$5, join$7(concat$12([",", line$8]), specifiers)])), ifBreak$6(shouldPrintComma$1(options) ? "," : ""), options.bracketSpacing ? line$8 : softline$5, "}"])) : "");
+ } else {
+ parts.push("{}");
+ }
+
+ if (decl.source) {
+ parts.push(" from ", path.call(print, "source"));
+ }
+
+ parts.push(semi);
+ }
+
+ return concat$12(parts);
+}
+
+function printFlowDeclaration(path, parts) {
+ var parentExportDecl = getParentExportDeclaration$1(path);
+
+ if (parentExportDecl) {
+ assert$3.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$12(parts);
+}
+
+function getFlowVariance(path) {
+ if (!path.variance) {
+ return null;
+ } // Babylon 7.0 currently uses variance node type, and flow should
+ // follow suit soon:
+ // https://github.com/babel/babel/issues/4722
+
+
+ var variance = path.variance.kind || path.variance;
+
+ switch (variance) {
+ case "plus":
+ return "+";
+
+ case "minus":
+ return "-";
+
+ default:
+ /* istanbul ignore next */
+ return variance;
+ }
+}
+
+function printTypeScriptModifiers(path, options, print) {
+ var n = path.getValue();
+
+ if (!n.modifiers || !n.modifiers.length) {
+ return "";
+ }
+
+ return concat$12([join$7(" ", path.map(print, "modifiers")), " "]);
+}
+
+function printTypeParameters(path, options, print, paramsKey) {
+ var n = path.getValue();
+
+ if (!n[paramsKey]) {
+ return "";
+ } // for TypeParameterDeclaration typeParameters is a single node
+
+
+ if (!Array.isArray(n[paramsKey])) {
+ return path.call(print, paramsKey);
+ }
+
+ var grandparent = path.getNode(2);
+ var isParameterInTestCall = grandparent != null && isTestCall(grandparent);
+ var 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");
+
+ if (shouldInline) {
+ return concat$12(["<", join$7(", ", path.map(print, paramsKey)), ">"]);
+ }
+
+ return group$10(concat$12(["<", indent$6(concat$12([softline$5, join$7(concat$12([",", line$8]), path.map(print, paramsKey))])), ifBreak$6(options.parser !== "typescript" && shouldPrintComma$1(options, "all") ? "," : ""), softline$5, ">"]));
+}
+
+function printClass(path, options, print) {
+ var n = path.getValue();
+ var parts = [];
+
+ if (n.type === "TSAbstractClassDeclaration") {
+ parts.push("abstract ");
+ }
+
+ parts.push("class");
+
+ if (n.id) {
+ parts.push(" ", path.call(print, "id"));
+ }
+
+ parts.push(path.call(print, "typeParameters"));
+ var partsGroup = [];
+
+ if (n.superClass) {
+ var printed = concat$12(["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$12([" ", path.call(function (superClass) {
+ return comments.printComments(superClass, function () {
+ return printed;
+ }, options);
+ }, "superClass")]));
+ } else {
+ partsGroup.push(group$10(concat$12([line$8, path.call(function (superClass) {
+ return comments.printComments(superClass, function () {
+ return printed;
+ }, options);
+ }, "superClass")])));
+ }
+ } else if (n.extends && n.extends.length > 0) {
+ parts.push(" extends ", join$7(", ", path.map(print, "extends")));
+ }
+
+ if (n["mixins"] && n["mixins"].length > 0) {
+ partsGroup.push(line$8, "mixins ", group$10(indent$6(join$7(concat$12([",", line$8]), path.map(print, "mixins")))));
+ }
+
+ if (n["implements"] && n["implements"].length > 0) {
+ partsGroup.push(line$8, "implements", group$10(indent$6(concat$12([line$8, join$7(concat$12([",", line$8]), path.map(print, "implements"))]))));
+ }
+
+ if (partsGroup.length > 0) {
+ parts.push(group$10(indent$6(concat$12(partsGroup))));
+ }
+
+ if (n.body && n.body.comments && hasLeadingOwnLineComment(options.originalText, n.body, options)) {
+ parts.push(hardline$8);
+ } else {
+ parts.push(" ");
+ }
+
+ parts.push(path.call(print, "body"));
+ return parts;
+}
+
+function printOptionalToken(path) {
+ var node = path.getValue();
+
+ if (!node.optional) {
+ return "";
+ }
+
+ if (node.type === "OptionalCallExpression" || node.type === "OptionalMemberExpression" && node.computed) {
+ return "?.";
+ }
+
+ return "?";
+}
+
+function printMemberLookup(path, options, print) {
+ var property = path.call(print, "property");
+ var n = path.getValue();
+ var optional = printOptionalToken(path);
+
+ if (!n.computed) {
+ return concat$12([optional, ".", property]);
+ }
+
+ if (!n.property || isNumericLiteral(n.property)) {
+ return concat$12([optional, "[", property, "]"]);
+ }
+
+ return group$10(concat$12([optional, "[", indent$6(concat$12([softline$5, property])), softline$5, "]"]));
+}
+
+function printBindExpressionCallee(path, options, print) {
+ return concat$12(["::", 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]
+ var 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) {
+ var originalText = options.originalText;
+ var nextCharIndex = getNextNonSpaceNonCommentCharacterIndex$2(originalText, node, options);
+ var 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$1(originalText, nextCharIndex + 1, options);
+ }
+
+ return isNextLineEmpty$4(originalText, node, options);
+ }
+
+ function rec(path) {
+ var node = path.getValue();
+
+ if ((node.type === "CallExpression" || node.type === "OptionalCallExpression") && (isMemberish(node.callee) || node.callee.type === "CallExpression" || node.callee.type === "OptionalCallExpression")) {
+ printedNodes.unshift({
+ node: node,
+ printed: concat$12([comments.printComments(path, function () {
+ return concat$12([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)]);
+ }, options), shouldInsertEmptyLineAfter(node) ? hardline$8 : ""])
+ });
+ path.call(function (callee) {
+ return rec(callee);
+ }, "callee");
+ } else if (isMemberish(node)) {
+ printedNodes.unshift({
+ node: node,
+ needsParens: needsParens_1(path, options),
+ printed: comments.printComments(path, function () {
+ return node.type === "OptionalMemberExpression" || node.type === "MemberExpression" ? printMemberLookup(path, options, print) : printBindExpressionCallee(path, options, print);
+ }, options)
+ });
+ path.call(function (object) {
+ return rec(object);
+ }, "object");
+ } else if (node.type === "TSNonNullExpression") {
+ printedNodes.unshift({
+ node: node,
+ printed: comments.printComments(path, function () {
+ return "!";
+ }, options)
+ });
+ path.call(function (expression) {
+ return rec(expression);
+ }, "expression");
+ } else {
+ printedNodes.unshift({
+ node: 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.
+
+
+ var node = path.getValue();
+ printedNodes.unshift({
+ node: node,
+ printed: concat$12([printOptionalToken(path), printFunctionTypeParameters(path, options, print), printArgumentsList(path, options, print)])
+ });
+ path.call(function (callee) {
+ return 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 acessors as possible
+ // < fn()[0][1][2] >.something()
+ // - then, as many MemberExpression as possible but the last one
+ // < this.items >.something()
+
+ var groups = [];
+ var currentGroup = [printedNodes[0]];
+ var 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(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(printedNodes[i].node) && isMemberish(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
+
+ var hasSeenCallExpression = false;
+
+ for (; i < printedNodes.length; ++i) {
+ if (hasSeenCallExpression && isMemberish(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(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(function (comment) {
+ return 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) {
+ var parent = path.getParentNode();
+ var isExpression = parent && parent.type === "ExpressionStatement";
+ var hasComputed = groups[1].length && groups[1][0].node.computed;
+
+ if (groups[0].length === 1) {
+ var firstNode = groups[0][0].node;
+ return firstNode.type === "ThisExpression" || firstNode.type === "Identifier" && (isFactory(firstNode.name) || isExpression && isShort(firstNode.name) || hasComputed);
+ }
+
+ var lastNode = getLast$4(groups[0]).node;
+ return (lastNode.type === "MemberExpression" || lastNode.type === "OptionalMemberExpression") && lastNode.property.type === "Identifier" && (isFactory(lastNode.property.name) || hasComputed);
+ }
+
+ var shouldMerge = groups.length >= 2 && !groups[1][0].node.comments && shouldNotWrap(groups);
+
+ function printGroup(printedGroup) {
+ var result = [];
+
+ for (var _i3 = 0; _i3 < printedGroup.length; _i3++) {
+ // Checks if the next node (i.e. the parent node) needs parens
+ // and print accordingly
+ if (printedGroup[_i3 + 1] && printedGroup[_i3 + 1].needsParens) {
+ result.push("(", printedGroup[_i3].printed, printedGroup[_i3 + 1].printed, ")");
+ _i3++;
+ } else {
+ result.push(printedGroup[_i3].printed);
+ }
+ }
+
+ return concat$12(result);
+ }
+
+ function printIndentedGroup(groups) {
+ if (groups.length === 0) {
+ return "";
+ }
+
+ return indent$6(group$10(concat$12([hardline$8, join$7(hardline$8, groups.map(printGroup))])));
+ }
+
+ var printedGroups = groups.map(printGroup);
+ var oneLine = concat$12(printedGroups);
+ var cutoff = shouldMerge ? 3 : 2;
+ var flatGroups = groups.slice(0, cutoff).reduce(function (res, group) {
+ return res.concat(group);
+ }, []);
+ var hasComment = flatGroups.slice(1, -1).some(function (node) {
+ return hasLeadingComment(node.node);
+ }) || flatGroups.slice(0, -1).some(function (node) {
+ return hasTrailingComment(node.node);
+ }) || groups[cutoff] && hasLeadingComment(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) {
+ return group$10(oneLine);
+ } // Find out the last node in the first group and check if it has an
+ // empty line after
+
+
+ var lastNodeBeforeIndent = getLast$4(shouldMerge ? groups.slice(1, 2)[0] : groups[0]).node;
+ var shouldHaveEmptyLineBeforeIndent = lastNodeBeforeIndent.type !== "CallExpression" && lastNodeBeforeIndent.type !== "OptionalCallExpression" && shouldInsertEmptyLineAfter(lastNodeBeforeIndent);
+ var expanded = concat$12([printGroup(groups[0]), shouldMerge ? concat$12(groups.slice(1, 2).map(printGroup)) : "", shouldHaveEmptyLineBeforeIndent ? hardline$8 : "", printIndentedGroup(groups.slice(shouldMerge ? 2 : 1))]);
+ var callExpressions = printedNodes.map(function (_ref) {
+ var node = _ref.node;
+ return node;
+ }).filter(isCallOrOptionalCallExpression); // We don't want to print in one line if there's:
+ // * A comment.
+ // * 3 or more chained calls.
+ // * 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 >= 3 || printedGroups.slice(0, -1).some(willBreak$1) ||
+ /**
+ * scopes.filter(scope => scope.value !== '').map((scope, i) => {
+ * // multi line content
+ * })
+ */
+ function (lastGroupDoc, lastGroupNode) {
+ return isCallOrOptionalCallExpression(lastGroupNode) && willBreak$1(lastGroupDoc);
+ }(getLast$4(printedGroups), getLast$4(getLast$4(groups)).node) && callExpressions.slice(0, -1).some(function (n) {
+ return n.arguments.some(isFunctionOrArrowExpression);
+ })) {
+ return group$10(expanded);
+ }
+
+ return concat$12([// 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$3 : "", conditionalGroup$1([oneLine, expanded])]);
+}
+
+function isCallOrOptionalCallExpression(node) {
+ return node.type === "CallExpression" || node.type === "OptionalCallExpression";
+}
+
+function isJSXNode(node) {
+ return node.type === "JSXElement" || node.type === "JSXFragment" || node.type === "TSJsxFragment";
+}
+
+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.
+
+
+ var child = node.children[0];
+ return isLiteral(child) && !isMeaningfulJSXText(child);
+} // Only space, newline, carriage return, and tab are treated as whitespace
+// inside JSX.
+
+
+var jsxWhitespaceChars = " \n\r\t";
+var containsNonJsxWhitespaceRegex = new RegExp("[^" + jsxWhitespaceChars + "]");
+var matchJsxWhitespaceRegex = 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 conditionalExpressionChainContainsJSX(node) {
+ return Boolean(getConditionalChainContents(node).find(isJSXNode));
+} // 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.
+ var 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;
+} // Detect an expression node representing `{" "}`
+
+
+function isJSXWhitespaceExpression(node) {
+ return node.type === "JSXExpressionContainer" && isLiteral(node.expression) && node.expression.value === " " && !node.expression.comments;
+}
+
+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$5 : hardline$8;
+ }
+
+ return softline$5;
+}
+
+function separatorWithWhitespace(isFacebookTranslationTag, child, childNode, nextNode) {
+ if (isFacebookTranslationTag) {
+ return hardline$8;
+ }
+
+ if (child.length === 1) {
+ return childNode.type === "JSXElement" && !childNode.closingElement || nextNode && nextNode.type === "JSXElement" && !nextNode.closingElement ? hardline$8 : softline$5;
+ }
+
+ return hardline$8;
+} // 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) {
+ var n = path.getValue();
+ var children = []; // using `map` instead of `each` because it provides `i`
+
+ path.map(function (childPath, i) {
+ var child = childPath.getValue();
+
+ if (isLiteral(child)) {
+ var text = rawText(child); // Contains a non-whitespace character
+
+ if (isMeaningfulJSXText(child)) {
+ var words = text.split(matchJsxWhitespaceRegex); // Starts with whitespace
+
+ if (words[0] === "") {
+ children.push("");
+ words.shift();
+
+ if (/\n/.test(words[0])) {
+ var next = n.children[i + 1];
+ children.push(separatorWithWhitespace(isFacebookTranslationTag, words[1], child, next));
+ } else {
+ children.push(jsxWhitespace);
+ }
+
+ words.shift();
+ }
+
+ var endWhitespace; // Ends with whitespace
+
+ if (getLast$4(words) === "") {
+ words.pop();
+ endWhitespace = words.pop();
+ } // This was whitespace only without a new line.
+
+
+ if (words.length === 0) {
+ return;
+ }
+
+ words.forEach(function (word, i) {
+ if (i % 2 === 1) {
+ children.push(line$8);
+ } else {
+ children.push(word);
+ }
+ });
+
+ if (endWhitespace !== undefined) {
+ if (/\n/.test(endWhitespace)) {
+ var _next = n.children[i + 1];
+ children.push(separatorWithWhitespace(isFacebookTranslationTag, getLast$4(children), child, _next));
+ } else {
+ children.push(jsxWhitespace);
+ }
+ } else {
+ var _next2 = n.children[i + 1];
+ children.push(separatorNoWhitespace(isFacebookTranslationTag, getLast$4(children), child, _next2));
+ }
+ } 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$8);
+ }
+ } else {
+ children.push("");
+ children.push(jsxWhitespace);
+ }
+ } else {
+ var printedChild = print(childPath);
+ children.push(printedChild);
+ var _next3 = n.children[i + 1];
+
+ var directlyFollowedByMeaningfulText = _next3 && isMeaningfulJSXText(_next3);
+
+ if (directlyFollowedByMeaningfulText) {
+ var firstWord = rawText(_next3).trim().split(matchJsxWhitespaceRegex)[0];
+ children.push(separatorNoWhitespace(isFacebookTranslationTag, firstWord, child, _next3));
+ } else {
+ children.push(hardline$8);
+ }
+ }
+ }, "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) {
+ var n = path.getValue(); // Turn into
+
+ if (n.type === "JSXElement" && isEmptyJSXElement(n)) {
+ n.openingElement.selfClosing = true;
+ return path.call(print, "openingElement");
+ }
+
+ var openingLines = n.type === "JSXElement" ? path.call(print, "openingElement") : path.call(print, "openingFragment");
+ var 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$12([openingLines, concat$12(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(function (child) {
+ if (isJSXWhitespaceExpression(child)) {
+ return {
+ type: "JSXText",
+ value: " ",
+ raw: " "
+ };
+ }
+
+ return child;
+ });
+ var containsTag = n.children.filter(isJSXNode).length > 0;
+ var containsMultipleExpressions = n.children.filter(function (child) {
+ return child.type === "JSXExpressionContainer";
+ }).length > 1;
+ var containsMultipleAttributes = n.type === "JSXElement" && n.openingElement.attributes.length > 1; // Record any breaks. Should never go from true to false, only false to true.
+
+ var forcedBreak = willBreak$1(openingLines) || containsTag || containsMultipleAttributes || containsMultipleExpressions;
+ var rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}';
+ var jsxWhitespace = ifBreak$6(concat$12([rawJsxWhitespace, softline$5]), " ");
+ var isFacebookTranslationTag = n.openingElement && n.openingElement.name && n.openingElement.name.name === "fbt";
+ var children = printJSXChildren(path, options, print, jsxWhitespace, isFacebookTranslationTag);
+ var containsText = n.children.filter(function (child) {
+ return isMeaningfulJSXText(child);
+ }).length > 0; // 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 (var i = children.length - 2; i >= 0; i--) {
+ var isPairOfEmptyStrings = children[i] === "" && children[i + 1] === "";
+ var isPairOfHardlines = children[i] === hardline$8 && children[i + 1] === "" && children[i + 2] === hardline$8;
+ var isLineFollowedByJSXWhitespace = (children[i] === softline$5 || children[i] === hardline$8) && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
+ var isJSXWhitespaceFollowedByLine = children[i] === jsxWhitespace && children[i + 1] === "" && (children[i + 2] === softline$5 || children[i + 2] === hardline$8);
+ var isDoubleJSXWhitespace = children[i] === jsxWhitespace && children[i + 1] === "" && children[i + 2] === jsxWhitespace;
+ var isPairOfHardOrSoftLines = children[i] === softline$5 && children[i + 1] === "" && children[i + 2] === hardline$8 || children[i] === hardline$8 && children[i + 1] === "" && children[i + 2] === softline$5;
+
+ 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$4(children)) || isEmpty$1(getLast$4(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.
+
+
+ var multilineChildren = [];
+ children.forEach(function (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$12([rawJsxWhitespace, hardline$8]));
+ return;
+ } else if (i === children.length - 1) {
+ // Trailing whitespace
+ multilineChildren.push(rawJsxWhitespace);
+ return;
+ } else if (children[i - 1] === "" && children[i - 2] === hardline$8) {
+ // 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.
+
+ var content = containsText ? fill$4(multilineChildren) : group$10(concat$12(multilineChildren), {
+ shouldBreak: true
+ });
+ var multiLineElem = group$10(concat$12([openingLines, indent$6(concat$12([hardline$8, content])), hardline$8, closingLines]));
+
+ if (forcedBreak) {
+ return multiLineElem;
+ }
+
+ return conditionalGroup$1([group$10(concat$12([openingLines, concat$12(children), closingLines])), multiLineElem]);
+}
+
+function maybeWrapJSXElementInParens(path, elem) {
+ var parent = path.getParentNode();
+
+ if (!parent) {
+ return elem;
+ }
+
+ var NO_WRAP_PARENTS = {
+ ArrayExpression: true,
+ JSXAttribute: true,
+ JSXElement: true,
+ JSXExpressionContainer: true,
+ JSXFragment: true,
+ TSJsxFragment: true,
+ ExpressionStatement: true,
+ CallExpression: true,
+ OptionalCallExpression: true,
+ ConditionalExpression: true,
+ JsExpressionRoot: true
+ };
+
+ if (NO_WRAP_PARENTS[parent.type]) {
+ return elem;
+ }
+
+ var shouldBreak = matchAncestorTypes$1(path, ["ArrowFunctionExpression", "CallExpression", "JSXExpressionContainer"]);
+ return group$10(concat$12([ifBreak$6("("), indent$6(concat$12([softline$5, elem])), softline$5, ifBreak$6(")")]), {
+ shouldBreak: shouldBreak
+ });
+}
+
+function isBinaryish(node) {
+ return node.type === "BinaryExpression" || node.type === "LogicalExpression" || node.type === "NGPipeExpression";
+}
+
+function isMemberish(node) {
+ return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "BindExpression" && node.object;
+}
+
+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(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) {
+ var parts = [];
+ var node = path.getValue(); // We treat BinaryExpression and LogicalExpression nodes the same.
+
+ if (isBinaryish(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(function (left) {
+ return printBinaryishExpressions(left, print, options,
+ /* isNested */
+ true, isInsideParenthesis);
+ }, "left"));
+ } else {
+ parts.push(path.call(print, "left"));
+ }
+
+ var shouldInline = shouldInlineLogicalExpression(node);
+ var lineBeforeOperator = (node.operator === "|>" || node.type === "NGPipeExpression" || node.operator === "|" && options.parser === "__vue_expression") && !hasLeadingOwnLineComment(options.originalText, node.right, options);
+ var operator = node.type === "NGPipeExpression" ? "|" : node.operator;
+ var rightSuffix = node.type === "NGPipeExpression" && node.arguments.length !== 0 ? group$10(indent$6(concat$12([softline$5, ": ", join$7(concat$12([softline$5, ":", ifBreak$6(" ")]), path.map(print, "arguments").map(function (arg) {
+ return align$1(2, group$10(arg));
+ }))]))) : "";
+ var right = shouldInline ? concat$12([operator, " ", path.call(print, "right"), rightSuffix]) : concat$12([lineBeforeOperator ? softline$5 : "", operator, lineBeforeOperator ? " " : line$8, 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.
+
+ var parent = path.getParentNode();
+ var shouldGroup = !(isInsideParenthesis && node.type === "LogicalExpression") && parent.type !== node.type && node.left.type !== node.type && node.right.type !== node.type;
+ parts.push(" ", shouldGroup ? group$10(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, function () {
+ return concat$12(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(options.originalText, rightNode, options)) {
+ return indent$6(concat$12([hardline$8, printedRight]));
+ }
+
+ var canBreak = isBinaryish(rightNode) && !shouldInlineLogicalExpression(rightNode) || rightNode.type === "ConditionalExpression" && isBinaryish(rightNode.test) && !shouldInlineLogicalExpression(rightNode.test) || rightNode.type === "StringLiteralTypeAnnotation" || rightNode.type === "ClassExpression" && rightNode.decorators && rightNode.decorators.length || (leftNode.type === "Identifier" || isStringLiteral(leftNode) || leftNode.type === "MemberExpression") && (isStringLiteral(rightNode) || isMemberExpressionChain(rightNode)) && // do not put values on a separate line from the key in json
+ options.parser !== "json" && options.parser !== "json5";
+
+ if (canBreak) {
+ return group$10(indent$6(concat$12([line$8, printedRight])));
+ }
+
+ return concat$12([" ", printedRight]);
+}
+
+function printAssignment(leftNode, printedLeft, operator, rightNode, printedRight, options) {
+ if (!rightNode) {
+ return printedLeft;
+ }
+
+ var printed = printAssignmentRight(leftNode, rightNode, printedRight, options);
+ return group$10(concat$12([printedLeft, operator, printed]));
+}
+
+function adjustClause(node, clause, forceSpace) {
+ if (node.type === "EmptyStatement") {
+ return ";";
+ }
+
+ if (node.type === "BlockStatement" || forceSpace) {
+ return concat$12([" ", clause]);
+ }
+
+ return indent$6(concat$12([line$8, clause]));
+}
+
+function nodeStr(node, options, isFlowOrTypeScriptDirectiveLiteral) {
+ var raw = rawText(node);
+ var isDirectiveLiteral = isFlowOrTypeScriptDirectiveLiteral || node.type === "DirectiveLiteral";
+ return printString$2(raw, options, isDirectiveLiteral);
+}
+
+function printRegex(node) {
+ var flags = node.flags.split("").sort().join("");
+ return "/".concat(node.pattern, "/").concat(flags);
+}
+
+function isLastStatement(path) {
+ var parent = path.getParentNode();
+
+ if (!parent) {
+ return true;
+ }
+
+ var node = path.getValue();
+ var body = (parent.body || parent.consequent).filter(function (stmt) {
+ return stmt.type !== "EmptyStatement";
+ });
+ return body && body[body.length - 1] === node;
+}
+
+function hasLeadingComment(node) {
+ return node.comments && node.comments.some(function (comment) {
+ return comment.leading;
+ });
+}
+
+function hasTrailingComment(node) {
+ return node.comments && node.comments.some(function (comment) {
+ return comment.trailing;
+ });
+}
+
+function hasLeadingOwnLineComment(text, node, options) {
+ if (isJSXNode(node)) {
+ return hasNodeIgnoreComment$1(node);
+ }
+
+ var res = node.comments && node.comments.some(function (comment) {
+ return comment.leading && hasNewline$3(text, options.locEnd(comment));
+ });
+ return res;
+}
+
+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 === "TSNonNullExpression";
+}
+
+function isFlowAnnotationComment(text, typeAnnotation, options) {
+ var start = options.locStart(typeAnnotation);
+ var end = skipWhitespace$1(text, options.locEnd(typeAnnotation));
+ return text.substr(start, 2) === "/*" && text.substr(end, 2) === "*/";
+}
+
+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);
+}
+
+function exprNeedsASIProtection(path, options) {
+ var node = path.getValue();
+ var 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(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(node)) {
+ return false;
+ }
+
+ return path.call.apply(path, [function (childPath) {
+ return exprNeedsASIProtection(childPath, options);
+ }].concat(getLeftSidePathName(path, node)));
+}
+
+function stmtNeedsASIProtection(path, options) {
+ var node = path.getNode();
+
+ if (node.type !== "ExpressionStatement") {
+ return false;
+ }
+
+ return path.call(function (childPath) {
+ return exprNeedsASIProtection(childPath, options);
+ }, "expression");
+}
+
+function classPropMayCauseASIProblems(path) {
+ var node = path.getNode();
+
+ if (node.type !== "ClassProperty") {
+ return false;
+ }
+
+ var 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) {
+ var 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":
+ {
+ // Babylon
+ var isAsync = node.value ? node.value.async : node.async;
+ var 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;
+ }
+
+ default:
+ /* istanbul ignore next */
+ return false;
+ }
+} // 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)) {
+ var leftMost = argument;
+ var newLeftMost;
+
+ while (newLeftMost = getLeftSide(leftMost)) {
+ leftMost = newLeftMost;
+
+ if (hasLeadingOwnLineComment(options.originalText, leftMost, options)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+function isMemberExpressionChain(node) {
+ if (node.type !== "MemberExpression" && node.type !== "OptionalMemberExpression") {
+ return false;
+ }
+
+ if (node.object.type === "Identifier") {
+ return true;
+ }
+
+ return isMemberExpressionChain(node.object);
+} // 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);
+} // 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);
+}
+
+function isGetterOrSetter(node) {
+ return node.kind === "get" || node.kind === "set";
+}
+
+function sameLocStart(nodeA, nodeB, options) {
+ return options.locStart(nodeA) === options.locStart(nodeB);
+} // 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);
+}
+
+function isNodeStartingWithDeclare(node, options) {
+ if (!(options.parser === "flow" || options.parser === "typescript")) {
+ return false;
+ }
+
+ return options.originalText.slice(0, options.locStart(node)).match(/declare[ \t]*$/) || options.originalText.slice(node.range[0], node.range[1]).startsWith("declare ");
+}
+
+function shouldHugType(node) {
+ if (isSimpleFlowType(node) || isObjectType(node)) {
+ return true;
+ }
+
+ if (node.type === "UnionTypeAnnotation" || node.type === "TSUnionType") {
+ var voidCount = node.types.filter(function (n) {
+ return n.type === "VoidTypeAnnotation" || n.type === "TSVoidKeyword" || n.type === "NullLiteralTypeAnnotation" || n.type === "TSNullKeyword";
+ }).length;
+ var objectCount = node.types.filter(function (n) {
+ return n.type === "ObjectTypeAnnotation" || n.type === "TSTypeLiteral" || // This is a bit aggressive but captures Array<{x}>
+ n.type === "GenericTypeAnnotation" || n.type === "TSTypeReference";
+ }).length;
+
+ if (node.types.length - 1 === voidCount && objectCount > 0) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+function shouldHugArguments(fun) {
+ return fun && fun.params && fun.params.length === 1 && !fun.params[0].comments && (fun.params[0].type === "ObjectPattern" || fun.params[0].type === "ArrayPattern" || fun.params[0].type === "Identifier" && fun.params[0].typeAnnotation && (fun.params[0].typeAnnotation.type === "TypeAnnotation" || fun.params[0].typeAnnotation.type === "TSTypeAnnotation") && isObjectType(fun.params[0].typeAnnotation.typeAnnotation) || fun.params[0].type === "FunctionTypeParam" && isObjectType(fun.params[0].typeAnnotation) || fun.params[0].type === "AssignmentPattern" && (fun.params[0].left.type === "ObjectPattern" || fun.params[0].left.type === "ArrayPattern") && (fun.params[0].right.type === "Identifier" || fun.params[0].right.type === "ObjectExpression" && fun.params[0].right.properties.length === 0 || fun.params[0].right.type === "ArrayExpression" && fun.params[0].right.elements.length === 0)) && !fun.rest;
+}
+
+function templateLiteralHasNewLines(template) {
+ return template.quasis.some(function (quasi) {
+ return 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 printArrayItems(path, options, printPath, print) {
+ var printedElements = [];
+ var separatorParts = [];
+ path.each(function (childPath) {
+ printedElements.push(concat$12(separatorParts));
+ printedElements.push(group$10(print(childPath)));
+ separatorParts = [",", line$8];
+
+ if (childPath.getValue() && isNextLineEmpty$4(options.originalText, childPath.getValue(), options)) {
+ separatorParts.push(softline$5);
+ }
+ }, printPath);
+ return concat$12(printedElements);
+}
+
+function hasDanglingComments(node) {
+ return node.comments && node.comments.some(function (comment) {
+ return !comment.leading && !comment.trailing;
+ });
+}
+
+function needsHardlineAfterDanglingComment(node) {
+ if (!node.comments) {
+ return false;
+ }
+
+ var lastDanglingComment = getLast$4(node.comments.filter(function (comment) {
+ return !comment.leading && !comment.trailing;
+ }));
+ return lastDanglingComment && !comments$3.isBlockComment(lastDanglingComment);
+}
+
+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";
+}
+
+var unitTestRe = /^(skip|[fx]?(it|describe|test))$/; // 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 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 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 isFunctionOrArrowExpression(node) {
+ return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression";
+}
+
+function isFunctionOrArrowExpressionWithBody(node) {
+ return node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression" && node.body.type === "BlockStatement";
+}
+
+function isUnitTestSetUp(n) {
+ var unitTestSetUpRe = /^(before|after)(Each|All)$/;
+ return n.callee.type === "Identifier" && unitTestSetUpRe.test(n.callee.name) && n.arguments.length === 1;
+}
+
+function isTheOnlyJSXElementInMarkdown(options, path) {
+ if (options.parentParser !== "markdown" && options.parentParser !== "mdx") {
+ return false;
+ }
+
+ var node = path.getNode();
+
+ if (!node.expression || !isJSXNode(node.expression)) {
+ return false;
+ }
+
+ var parent = path.getParentNode();
+ return parent.type === "Program" && parent.body.length == 1;
+}
+
+function willPrintOwnComments(path) {
+ var node = path.getValue();
+ var parent = path.getParentNode();
+ return (node && (isJSXNode(node) || hasFlowShorthandAnnotationComment(node) || parent && parent.type === "CallExpression" && (hasFlowAnnotationComment(node.leadingComments) || hasFlowAnnotationComment(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$3(path);
+}
+
+function canAttachComment$1(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" && !(node.callee && node.callee.type === "Import");
+}
+
+function printComment$2(commentPath, options) {
+ var comment = commentPath.getValue();
+
+ switch (comment.type) {
+ case "CommentBlock":
+ case "Block":
+ {
+ if (isIndentableBlockComment(comment)) {
+ var 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$3(options.originalText, options.locStart(comment), {
+ backwards: true
+ })) {
+ return concat$12([hardline$8, printed]);
+ }
+
+ return printed;
+ }
+
+ var isInsideFlowComment = options.originalText.substr(options.locEnd(comment) - 3, 3) === "*-/";
+ 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.trimRight();
+ }
+
+ return "//" + comment.value.trimRight();
+
+ 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.
+ var lines = "*".concat(comment.value, "*").split("\n");
+ return lines.length > 1 && lines.every(function (line) {
+ return line.trim()[0] === "*";
+ });
+}
+
+function printIndentableBlockComment(comment) {
+ var lines = comment.value.split("\n");
+ return concat$12(["/*", join$7(hardline$8, lines.map(function (line, index) {
+ return index === 0 ? line.trimRight() : " " + (index < lines.length - 1 ? line.trim() : line.trimLeft());
+ })), "*/"]);
+}
+
+function rawText(node) {
+ return node.extra ? node.extra.raw : node.raw;
+}
+
+function identity$1(x) {
+ return x;
+}
+
+var printerEstree = {
+ preprocess: preprocess_1$2,
+ print: genericPrint$3,
+ embed: embed_1$2,
+ insertPragma: insertPragma$7,
+ massageAstNode: clean_1$2,
+ hasPrettierIgnore: hasPrettierIgnore$2,
+ willPrintOwnComments: willPrintOwnComments,
+ canAttachComment: canAttachComment$1,
+ printComment: printComment$2,
+ isBlockComment: comments$3.isBlockComment,
+ handleComments: {
+ ownLine: comments$3.handleOwnLineComment,
+ endOfLine: comments$3.handleEndOfLineComment,
+ remaining: comments$3.handleRemainingComment
+ }
+};
+
+var _require$$0$builders$8 = doc.builders;
+var concat$15 = _require$$0$builders$8.concat;
+var hardline$10 = _require$$0$builders$8.hardline;
+var indent$8 = _require$$0$builders$8.indent;
+var join$10 = _require$$0$builders$8.join;
+
+function genericPrint$4(path, options, print) {
+ var node = path.getValue();
+
+ switch (node.type) {
+ case "JsonRoot":
+ return concat$15([path.call(print, "node"), hardline$10]);
+
+ case "ArrayExpression":
+ return node.elements.length === 0 ? "[]" : concat$15(["[", indent$8(concat$15([hardline$10, join$10(concat$15([",", hardline$10]), path.map(print, "elements"))])), hardline$10, "]"]);
+
+ case "ObjectExpression":
+ return node.properties.length === 0 ? "{}" : concat$15(["{", indent$8(concat$15([hardline$10, join$10(concat$15([",", hardline$10]), path.map(print, "properties"))])), hardline$10, "}"]);
+
+ case "ObjectProperty":
+ return concat$15([path.call(print, "key"), ": ", path.call(print, "value")]);
+
+ case "UnaryExpression":
+ return concat$15([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$9(node, newNode
+/*, parent*/
+) {
+ delete newNode.start;
+ delete newNode.end;
+ delete newNode.extra;
+ delete newNode.loc;
+ delete newNode.comments;
+
+ if (node.type === "Identifier") {
+ return {
+ type: "StringLiteral",
+ value: node.name
+ };
+ }
+
+ if (node.type === "UnaryExpression" && node.operator === "+") {
+ return newNode.argument;
+ }
+}
+
+var printerEstreeJson = {
+ preprocess: preprocess_1$2,
+ print: genericPrint$4,
+ massageAstNode: clean$9
+};
+
+var CATEGORY_JAVASCRIPT = "JavaScript"; // format based on https://github.com/prettier/prettier/blob/master/src/main/core-options.js
+
+var options$12 = {
+ arrowParens: {
+ since: "1.9.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "choice",
+ default: "avoid",
+ description: "Include parentheses around a sole arrow function parameter.",
+ choices: [{
+ value: "avoid",
+ description: "Omit parens when possible. Example: `x => x`"
+ }, {
+ value: "always",
+ description: "Always include parens. 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."
+ },
+ trailingComma: {
+ since: "0.0.0",
+ category: CATEGORY_JAVASCRIPT,
+ type: "choice",
+ default: [{
+ since: "0.0.0",
+ value: false
+ }, {
+ since: "0.19.0",
+ value: "none"
+ }],
+ description: "Print trailing commas wherever possible when multi-line.",
+ choices: [{
+ value: "none",
+ description: "No trailing commas."
+ }, {
+ value: "es5",
+ description: "Trailing commas where valid in ES5 (objects, arrays, etc.)"
+ }, {
+ value: "all",
+ description: "Trailing commas wherever possible (including function arguments)."
+ }, {
+ value: true,
+ deprecated: "0.19.0",
+ redirect: "es5"
+ }, {
+ value: false,
+ deprecated: "0.19.0",
+ redirect: "none"
+ }]
+ }
+};
+
+var name$9 = "JavaScript";
+var type$8 = "programming";
+var tmScope$8 = "source.js";
+var aceMode$8 = "javascript";
+var codemirrorMode$4 = "javascript";
+var codemirrorMimeType$4 = "text/javascript";
+var color$3 = "#f1e05a";
+var aliases$2 = ["js", "node"];
+var extensions$8 = [".js", "._js", ".bones", ".es", ".es6", ".frag", ".gs", ".jake", ".jsb", ".jscad", ".jsfl", ".jsm", ".jss", ".mjs", ".njs", ".pac", ".sjs", ".ssjs", ".xsjs", ".xsjslib"];
+var filenames = ["Jakefile"];
+var interpreters = ["node"];
+var languageId$8 = 183;
+var javascript = {
+ name: name$9,
+ type: type$8,
+ tmScope: tmScope$8,
+ aceMode: aceMode$8,
+ codemirrorMode: codemirrorMode$4,
+ codemirrorMimeType: codemirrorMimeType$4,
+ color: color$3,
+ aliases: aliases$2,
+ extensions: extensions$8,
+ filenames: filenames,
+ interpreters: interpreters,
+ languageId: languageId$8
+};
+
+var javascript$1 = Object.freeze({
+ name: name$9,
+ type: type$8,
+ tmScope: tmScope$8,
+ aceMode: aceMode$8,
+ codemirrorMode: codemirrorMode$4,
+ codemirrorMimeType: codemirrorMimeType$4,
+ color: color$3,
+ aliases: aliases$2,
+ extensions: extensions$8,
+ filenames: filenames,
+ interpreters: interpreters,
+ languageId: languageId$8,
+ default: javascript
+});
+
+var name$10 = "JSX";
+var type$9 = "programming";
+var group$12 = "JavaScript";
+var extensions$9 = [".jsx"];
+var tmScope$9 = "source.js.jsx";
+var aceMode$9 = "javascript";
+var codemirrorMode$5 = "jsx";
+var codemirrorMimeType$5 = "text/jsx";
+var languageId$9 = 178;
+var jsx = {
+ name: name$10,
+ type: type$9,
+ group: group$12,
+ extensions: extensions$9,
+ tmScope: tmScope$9,
+ aceMode: aceMode$9,
+ codemirrorMode: codemirrorMode$5,
+ codemirrorMimeType: codemirrorMimeType$5,
+ languageId: languageId$9
+};
+
+var jsx$1 = Object.freeze({
+ name: name$10,
+ type: type$9,
+ group: group$12,
+ extensions: extensions$9,
+ tmScope: tmScope$9,
+ aceMode: aceMode$9,
+ codemirrorMode: codemirrorMode$5,
+ codemirrorMimeType: codemirrorMimeType$5,
+ languageId: languageId$9,
+ default: jsx
+});
+
+var name$11 = "TypeScript";
+var type$10 = "programming";
+var color$4 = "#2b7489";
+var aliases$3 = ["ts"];
+var extensions$10 = [".ts", ".tsx"];
+var tmScope$10 = "source.ts";
+var aceMode$10 = "typescript";
+var codemirrorMode$6 = "javascript";
+var codemirrorMimeType$6 = "application/typescript";
+var languageId$10 = 378;
+var typescript = {
+ name: name$11,
+ type: type$10,
+ color: color$4,
+ aliases: aliases$3,
+ extensions: extensions$10,
+ tmScope: tmScope$10,
+ aceMode: aceMode$10,
+ codemirrorMode: codemirrorMode$6,
+ codemirrorMimeType: codemirrorMimeType$6,
+ languageId: languageId$10
+};
+
+var typescript$1 = Object.freeze({
+ name: name$11,
+ type: type$10,
+ color: color$4,
+ aliases: aliases$3,
+ extensions: extensions$10,
+ tmScope: tmScope$10,
+ aceMode: aceMode$10,
+ codemirrorMode: codemirrorMode$6,
+ codemirrorMimeType: codemirrorMimeType$6,
+ languageId: languageId$10,
+ default: typescript
+});
+
+var name$12 = "JSON";
+var type$11 = "data";
+var tmScope$11 = "source.json";
+var group$13 = "JavaScript";
+var aceMode$11 = "json";
+var codemirrorMode$7 = "javascript";
+var codemirrorMimeType$7 = "application/json";
+var searchable = false;
+var extensions$11 = [".json", ".avsc", ".geojson", ".gltf", ".JSON-tmLanguage", ".jsonl", ".tfstate", ".tfstate.backup", ".topojson", ".webapp", ".webmanifest"];
+var filenames$1 = [".arcconfig", ".htmlhintrc", ".tern-config", ".tern-project", "composer.lock", "mcmod.info"];
+var languageId$11 = 174;
+var json$5 = {
+ name: name$12,
+ type: type$11,
+ tmScope: tmScope$11,
+ group: group$13,
+ aceMode: aceMode$11,
+ codemirrorMode: codemirrorMode$7,
+ codemirrorMimeType: codemirrorMimeType$7,
+ searchable: searchable,
+ extensions: extensions$11,
+ filenames: filenames$1,
+ languageId: languageId$11
+};
+
+var json$6 = Object.freeze({
+ name: name$12,
+ type: type$11,
+ tmScope: tmScope$11,
+ group: group$13,
+ aceMode: aceMode$11,
+ codemirrorMode: codemirrorMode$7,
+ codemirrorMimeType: codemirrorMimeType$7,
+ searchable: searchable,
+ extensions: extensions$11,
+ filenames: filenames$1,
+ languageId: languageId$11,
+ default: json$5
+});
+
+var name$13 = "JSON with Comments";
+var type$12 = "data";
+var group$14 = "JSON";
+var tmScope$12 = "source.js";
+var aceMode$12 = "javascript";
+var codemirrorMode$8 = "javascript";
+var codemirrorMimeType$8 = "text/javascript";
+var aliases$4 = ["jsonc"];
+var extensions$12 = [".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", "tsconfig.json"];
+var languageId$12 = 423;
+var jsonWithComments = {
+ name: name$13,
+ type: type$12,
+ group: group$14,
+ tmScope: tmScope$12,
+ aceMode: aceMode$12,
+ codemirrorMode: codemirrorMode$8,
+ codemirrorMimeType: codemirrorMimeType$8,
+ aliases: aliases$4,
+ extensions: extensions$12,
+ filenames: filenames$2,
+ languageId: languageId$12
+};
+
+var jsonWithComments$1 = Object.freeze({
+ name: name$13,
+ type: type$12,
+ group: group$14,
+ tmScope: tmScope$12,
+ aceMode: aceMode$12,
+ codemirrorMode: codemirrorMode$8,
+ codemirrorMimeType: codemirrorMimeType$8,
+ aliases: aliases$4,
+ extensions: extensions$12,
+ filenames: filenames$2,
+ languageId: languageId$12,
+ default: jsonWithComments
+});
+
+var name$14 = "JSON5";
+var type$13 = "data";
+var extensions$13 = [".json5"];
+var tmScope$13 = "source.js";
+var aceMode$13 = "javascript";
+var codemirrorMode$9 = "javascript";
+var codemirrorMimeType$9 = "application/json";
+var languageId$13 = 175;
+var json5 = {
+ name: name$14,
+ type: type$13,
+ extensions: extensions$13,
+ tmScope: tmScope$13,
+ aceMode: aceMode$13,
+ codemirrorMode: codemirrorMode$9,
+ codemirrorMimeType: codemirrorMimeType$9,
+ languageId: languageId$13
+};
+
+var json5$1 = Object.freeze({
+ name: name$14,
+ type: type$13,
+ extensions: extensions$13,
+ tmScope: tmScope$13,
+ aceMode: aceMode$13,
+ codemirrorMode: codemirrorMode$9,
+ codemirrorMimeType: codemirrorMimeType$9,
+ languageId: languageId$13,
+ default: json5
+});
+
+var require$$0$22 = ( javascript$1 && javascript ) || javascript$1;
+
+var require$$1$12 = ( jsx$1 && jsx ) || jsx$1;
+
+var require$$2$11 = ( typescript$1 && typescript ) || typescript$1;
+
+var require$$3$7 = ( json$6 && json$5 ) || json$6;
+
+var require$$4$4 = ( jsonWithComments$1 && jsonWithComments ) || jsonWithComments$1;
+
+var require$$5$1 = ( json5$1 && json5 ) || json5$1;
+
+var languages$4 = [createLanguage(require$$0$22, {
+ override: {
+ since: "0.0.0",
+ parsers: ["babylon", "flow"],
+ vscodeLanguageIds: ["javascript"]
+ },
+ extend: {
+ interpreters: ["nodejs"]
+ }
+}), createLanguage(require$$0$22, {
+ override: {
+ name: "Flow",
+ since: "0.0.0",
+ parsers: ["babylon", "flow"],
+ vscodeLanguageIds: ["javascript"],
+ aliases: [],
+ filenames: [],
+ extensions: [".js.flow"]
+ }
+}), createLanguage(require$$1$12, {
+ override: {
+ since: "0.0.0",
+ parsers: ["babylon", "flow"],
+ vscodeLanguageIds: ["javascriptreact"]
+ }
+}), createLanguage(require$$2$11, {
+ override: {
+ since: "1.4.0",
+ parsers: ["typescript"],
+ vscodeLanguageIds: ["typescript", "typescriptreact"]
+ }
+}), createLanguage(require$$3$7, {
+ override: {
+ 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$$3$7, {
+ override: {
+ since: "1.5.0",
+ parsers: ["json"],
+ vscodeLanguageIds: ["json"]
+ },
+ extend: {
+ filenames: [".prettierrc"]
+ }
+}), createLanguage(require$$4$4, {
+ override: {
+ since: "1.5.0",
+ parsers: ["json"],
+ vscodeLanguageIds: ["jsonc"]
+ },
+ extend: {
+ filenames: [".eslintrc"]
+ }
+}), createLanguage(require$$5$1, {
+ override: {
+ since: "1.13.0",
+ parsers: ["json5"],
+ vscodeLanguageIds: ["json5"]
+ }
+})];
+var printers$4 = {
+ estree: printerEstree,
+ "estree-json": printerEstreeJson
+};
+var languageJs = {
+ languages: languages$4,
+ options: options$12,
+ printers: printers$4
+};
+
+const json$9 = {"cjkPattern":"[\\u1100-\\u11ff\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u3000-\\u303f\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312e\\u3131-\\u318e\\u3190-\\u3191\\u3196-\\u31ba\\u31c0-\\u31e3\\u31f0-\\u321e\\u322a-\\u3247\\u3260-\\u327e\\u328a-\\u32b0\\u32c0-\\u32cb\\u32d0-\\u32fe\\u3300-\\u3370\\u337b-\\u337f\\u33e0-\\u33fe\\u3400-\\u4db5\\u4e00-\\u9fea\\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]|\\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\\u0af0\\u0df4\\u0e4f\\u0e5a-\\u0e5b\\u0f04-\\u0f12\\u0f14\\u0f3a-\\u0f3d\\u0f85\\u0fd0-\\u0fd4\\u0fd9-\\u0fda\\u104a-\\u104f\\u10fb\\u1360-\\u1368\\u1400\\u166d-\\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-\\u2e49\\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]|\\ud804[\\udc47-\\udc4d\\udcbb-\\udcbc\\udcbe-\\udcc1\\udd40-\\udd43\\udd74-\\udd75\\uddc5-\\uddc9\\uddcd\\udddb\\udddd-\\udddf\\ude38-\\ude3d\\udea9]|\\ud805[\\udc4b-\\udc4f\\udc5b\\udc5d\\udcc6\\uddc1-\\uddd7\\ude41-\\ude43\\ude60-\\ude6c\\udf3c-\\udf3e]|\\ud806[\\ude3f-\\ude46\\ude9a-\\ude9c\\ude9e-\\udea2]|\\ud807[\\udc41-\\udc45\\udc70-\\udc71]|\\ud809[\\udc70-\\udc74]|\\ud81a[\\ude6e-\\ude6f\\udef5\\udf37-\\udf3b\\udf44]|\\ud82f[\\udc9f]|\\ud836[\\ude87-\\ude8b]|\\ud83a[\\udd5e-\\udd5f]"};
+
+var cjkPattern = json$9.cjkPattern;
+var kPattern = json$9.kPattern;
+var punctuationPattern$1 = json$9.punctuationPattern;
+var getLast$5 = util.getLast;
+var kRegex = new RegExp(kPattern);
+var punctuationRegex = new RegExp(punctuationPattern$1);
+/**
+ * split text into whitespaces and words
+ * @param {string} text
+ * @return {Array<{ type: "whitespace", value: " " | "\n" | "" } | { type: "word", value: string }>}
+ */
+
+function splitText$1(text, options) {
+ var KIND_NON_CJK = "non-cjk";
+ var KIND_CJ_LETTER = "cj-letter";
+ var KIND_K_LETTER = "k-letter";
+ var KIND_CJK_PUNCTUATION = "cjk-punctuation";
+ var nodes = [];
+ (options.proseWrap === "preserve" ? text : text.replace(new RegExp("(".concat(cjkPattern, ")\n(").concat(cjkPattern, ")"), "g"), "$1$2")).split(/([ \t\n]+)/).forEach(function (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("(".concat(cjkPattern, ")"))).forEach(function (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$5(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) {
+ var lastNode = getLast$5(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(function (value) {
+ return /\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$1(orderListItem, originalText) {
+ var _originalText$slice$m = originalText.slice(orderListItem.position.start.offset, orderListItem.position.end.offset).match(/^\s*(\d+)(\.|\))(\s*)/),
+ _originalText$slice$m2 = _slicedToArray(_originalText$slice$m, 4),
+ numberText = _originalText$slice$m2[1],
+ marker = _originalText$slice$m2[2],
+ leadingSpaces = _originalText$slice$m2[3];
+
+ return {
+ numberText: numberText,
+ marker: marker,
+ leadingSpaces: leadingSpaces
+ };
+} // workaround for https://github.com/remarkjs/remark/issues/351
+// leading and trailing newlines are stripped by remark
+
+
+function getFencedCodeBlockValue$2(node, originalText) {
+ var text = originalText.slice(node.position.start.offset, node.position.end.offset);
+ var leadingSpaceCount = text.match(/^\s*/)[0].length;
+ var replaceRegex = new RegExp("^\\s{0,".concat(leadingSpaceCount, "}"));
+ var lineContents = text.replace(/\r\n?/g, "\n").split("\n");
+ var markerStyle = text[leadingSpaceCount]; // ` or ~
+
+ var marker = text.slice(leadingSpaceCount).match(new RegExp("^[".concat(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
+
+ var hasEndMarker = new RegExp("^\\s{0,3}".concat(marker)).test(lineContents[lineContents.length - 1].slice(getIndent(lineContents.length - 1)));
+ return lineContents.slice(1, hasEndMarker ? -1 : undefined).map(function (x, i) {
+ return 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 || [];
+ var newNode = Object.assign({}, handler(node, index, parentStack));
+
+ if (newNode.children) {
+ newNode.children = newNode.children.map(function (child, index) {
+ return preorder(child, index, [newNode].concat(parentStack));
+ });
+ }
+
+ return newNode;
+ }(ast, null, null);
+}
+
+var utils$8 = {
+ mapAst: mapAst,
+ splitText: splitText$1,
+ punctuationPattern: punctuationPattern$1,
+ getFencedCodeBlockValue: getFencedCodeBlockValue$2,
+ getOrderedListItemInfo: getOrderedListItemInfo$1
+};
+
+var _require$$0$builders$10 = doc.builders;
+var hardline$12 = _require$$0$builders$10.hardline;
+var literalline$6 = _require$$0$builders$10.literalline;
+var concat$17 = _require$$0$builders$10.concat;
+var markAsRoot$4 = _require$$0$builders$10.markAsRoot;
+var mapDoc$7 = doc.utils.mapDoc;
+var getFencedCodeBlockValue$1 = utils$8.getFencedCodeBlockValue;
+
+function embed$6(path, print, textToDoc, options) {
+ var 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)
+ var langMatch = node.lang.match(/^[A-Za-z0-9_-]+/);
+ var lang = langMatch ? langMatch[0] : "";
+ var parser = getParserName(lang);
+
+ if (parser) {
+ var styleUnit = options.__inJsTemplate ? "~" : "`";
+ var style = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1));
+ var doc$$2 = textToDoc(getFencedCodeBlockValue$1(node, options.originalText), {
+ parser: parser
+ });
+ return markAsRoot$4(concat$17([style, node.lang, hardline$12, replaceNewlinesWithLiterallines(doc$$2), style]));
+ }
+ }
+
+ if (node.type === "yaml") {
+ return markAsRoot$4(concat$17(["---", hardline$12, node.value.trim() ? replaceNewlinesWithLiterallines(textToDoc(node.value, {
+ parser: "yaml"
+ })) : "", "---"]));
+ } // MDX
+
+
+ switch (node.type) {
+ case "importExport":
+ return textToDoc(node.value, {
+ parser: "babylon"
+ });
+
+ case "jsx":
+ return textToDoc(node.value, {
+ parser: "__js_expression"
+ });
+ }
+
+ return null;
+
+ function getParserName(lang) {
+ var supportInfo = support.getSupportInfo(null, {
+ plugins: options.plugins
+ });
+ var language = supportInfo.languages.find(function (language) {
+ return language.name.toLowerCase() === lang || language.aliases && language.aliases.indexOf(lang) !== -1 || language.extensions && language.extensions.find(function (ext) {
+ return ext.substring(1) === lang;
+ });
+ });
+
+ if (language) {
+ return language.parsers[0];
+ }
+
+ return null;
+ }
+
+ function replaceNewlinesWithLiterallines(doc$$2) {
+ return mapDoc$7(doc$$2, function (currentDoc) {
+ return typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$17(currentDoc.split(/(\n)/g).map(function (v, i) {
+ return i % 2 === 0 ? v : literalline$6;
+ })) : currentDoc;
+ });
+ }
+}
+
+var embed_1$4 = embed$6;
+
+var pragma$8 = createCommonjsModule(function (module) {
+ "use strict";
+
+ var pragmas = ["format", "prettier"];
+
+ function startWithPragma(text) {
+ var pragma = "@(".concat(pragmas.join("|"), ")");
+ var regex = new RegExp([""), "")].join("|"), "m");
+ var matched = text.match(regex);
+ return matched && matched.index === 0;
+ }
+
+ module.exports = {
+ startWithPragma: startWithPragma,
+ hasPragma: function hasPragma(text) {
+ return startWithPragma(frontMatter(text).content.trimLeft());
+ },
+ insertPragma: function insertPragma(text) {
+ var extracted = frontMatter(text);
+ var pragma = "");
+ return extracted.frontMatter ? "".concat(extracted.frontMatter.raw, "\n\n").concat(pragma, "\n\n").concat(extracted.content) : "".concat(pragma, "\n\n").concat(extracted.content);
+ }
+ };
+});
+
+var getOrderedListItemInfo$2 = utils$8.getOrderedListItemInfo;
+var mapAst$1 = utils$8.mapAst;
+var splitText$2 = utils$8.splitText; // 0x0 ~ 0x10ffff
+
+var isSingleCharRegex = /^([\u0000-\uffff]|[\ud800-\udbff][\udc00-\udfff])$/;
+
+function preprocess$4(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, function (node) {
+ if (node.type !== "import" && node.type !== "export") {
+ return node;
+ }
+
+ return Object.assign({}, node, {
+ type: "importExport"
+ });
+ });
+}
+
+function transformInlineCode(ast) {
+ return mapAst$1(ast, function (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, function (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, function (prevNode, node) {
+ return prevNode.type === "importExport" && node.type === "importExport";
+ }, function (prevNode, node) {
+ return {
+ 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, function (node) {
+ if (!node.children) {
+ return node;
+ }
+
+ var children = node.children.reduce(function (current, child) {
+ var 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: children
+ });
+ });
+}
+
+function mergeContinuousTexts(ast) {
+ return mergeChildren(ast, function (prevNode, node) {
+ return prevNode.type === "text" && node.type === "text";
+ }, function (prevNode, node) {
+ return {
+ type: "text",
+ value: prevNode.value + node.value,
+ position: {
+ start: prevNode.position.start,
+ end: node.position.end
+ }
+ };
+ });
+}
+
+function splitTextIntoSentences(ast, options) {
+ return mapAst$1(ast, function (node, index, _ref) {
+ var _ref2 = _slicedToArray(_ref, 1),
+ parentNode = _ref2[0];
+
+ if (node.type !== "text") {
+ return node;
+ }
+
+ var value = node.value;
+
+ if (parentNode.type === "paragraph") {
+ if (index === 0) {
+ value = value.trimLeft();
+ }
+
+ if (index === parentNode.children.length - 1) {
+ value = value.trimRight();
+ }
+ }
+
+ return {
+ type: "sentence",
+ position: node.position,
+ children: splitText$2(value, options)
+ };
+ });
+}
+
+function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
+ return mapAst$1(ast, function (node, index, parentStack) {
+ if (node.type === "code") {
+ // the first char may point to `\n`, e.g. `\n\t\tbar`, just ignore it
+ var isIndented = /^\n?( {4,}|\t)/.test(options.originalText.slice(node.position.start.offset, node.position.end.offset));
+ node.isIndented = isIndented;
+
+ if (isIndented) {
+ for (var i = 0; i < parentStack.length; i++) {
+ var 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, function (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 (var i = 0; i < parentStack.length; i++) {
+ var 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;
+ }
+
+ var _list$children = _slicedToArray(list.children, 2),
+ firstItem = _list$children[0],
+ secondItem = _list$children[1];
+
+ var firstInfo = getOrderedListItemInfo$2(firstItem, options.originalText);
+
+ if (firstInfo.leadingSpaces.length > 1) {
+ /**
+ * 1. 123
+ *
+ * 1. 123
+ * 1. 123
+ */
+ return true;
+ }
+
+ var 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;
+ }
+
+ var 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
+ */
+
+
+ var secondInfo = getOrderedListItemInfo$2(secondItem, options.originalText);
+ return secondInfo.leadingSpaces.length > 1;
+ }
+}
+
+var preprocess_1$4 = preprocess$4;
+
+var _require$$0$builders$9 = doc.builders;
+var concat$16 = _require$$0$builders$9.concat;
+var join$11 = _require$$0$builders$9.join;
+var line$10 = _require$$0$builders$9.line;
+var literalline$5 = _require$$0$builders$9.literalline;
+var markAsRoot$3 = _require$$0$builders$9.markAsRoot;
+var hardline$11 = _require$$0$builders$9.hardline;
+var softline$7 = _require$$0$builders$9.softline;
+var fill$5 = _require$$0$builders$9.fill;
+var align$2 = _require$$0$builders$9.align;
+var indent$9 = _require$$0$builders$9.indent;
+var group$15 = _require$$0$builders$9.group;
+var mapDoc$6 = doc.utils.mapDoc;
+var printDocToString$2 = doc.printer.printDocToString;
+var getFencedCodeBlockValue = utils$8.getFencedCodeBlockValue;
+var getOrderedListItemInfo = utils$8.getOrderedListItemInfo;
+var splitText = utils$8.splitText;
+var punctuationPattern = utils$8.punctuationPattern;
+var TRAILING_HARDLINE_NODES = ["importExport"];
+var SINGLE_LINE_NODE_TYPES = ["heading", "tableCell", "link"];
+var SIBLING_NODE_TYPES = ["listItem", "definition", "footnoteDefinition"];
+var INLINE_NODE_TYPES = ["liquidNode", "inlineCode", "emphasis", "strong", "delete", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"];
+var INLINE_NODE_WRAPPER_TYPES = INLINE_NODE_TYPES.concat(["tableCell", "paragraph", "heading"]);
+
+function genericPrint$5(path, options, print) {
+ var node = path.getValue();
+
+ if (shouldRemainTheSameContent(path)) {
+ return concat$16(splitText(options.originalText.slice(node.position.start.offset, node.position.end.offset), options).map(function (node) {
+ return 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$16([normalizeDoc(printRoot(path, options, print)), TRAILING_HARDLINE_NODES.indexOf(getLastDescendantNode(node).type) === -1 ? hardline$11 : ""]);
+
+ 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(["(^|".concat(punctuationPattern, ")(_+)"), "(_+)(".concat(punctuationPattern, "|$)")].join("|"), "g"), function (_, text1, underscore1, underscore2, text2) {
+ return (underscore1 ? "".concat(text1).concat(underscore1) : "".concat(underscore2).concat(text2)).replace(/_/g, "\\_");
+ });
+ // escape all `_` except concating with non-punctuation, e.g. `1_2_3` is not considered emphasis
+
+ case "whitespace":
+ {
+ var parentNode = path.getParentNode();
+ var index = parentNode.children.indexOf(node);
+ var nextNode = parentNode.children[index + 1];
+ var 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: proseWrap
+ });
+ }
+
+ case "emphasis":
+ {
+ var _parentNode = path.getParentNode();
+
+ var _index = _parentNode.children.indexOf(node);
+
+ var prevNode = _parentNode.children[_index - 1];
+ var _nextNode = _parentNode.children[_index + 1];
+ var hasPrevOrNextWord = // `1*2*3` is considered emphais but `1_2_3` is not
+ prevNode && prevNode.type === "sentence" && prevNode.children.length > 0 && util.getLast(prevNode.children).type === "word" && !util.getLast(prevNode.children).hasTrailingPunctuation || _nextNode && _nextNode.type === "sentence" && _nextNode.children.length > 0 && _nextNode.children[0].type === "word" && !_nextNode.children[0].hasLeadingPunctuation;
+ var style = hasPrevOrNextWord || getAncestorNode$2(path, "emphasis") ? "*" : "_";
+ return concat$16([style, printChildren$1(path, options, print), style]);
+ }
+
+ case "strong":
+ return concat$16(["**", printChildren$1(path, options, print), "**"]);
+
+ case "delete":
+ return concat$16(["~~", printChildren$1(path, options, print), "~~"]);
+
+ case "inlineCode":
+ {
+ var backtickCount = util.getMaxContinuousCount(node.value, "`");
+
+ var _style = backtickCount === 1 ? "``" : "`";
+
+ var gap = backtickCount ? " " : "";
+ return concat$16([_style, gap, node.value, gap, _style]);
+ }
+
+ case "link":
+ switch (options.originalText[node.position.start.offset]) {
+ case "<":
+ {
+ var mailto = "mailto:";
+ var 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$16(["<", url, ">"]);
+ }
+
+ case "[":
+ return concat$16(["[", 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$16([""), printTitle(node.title, options), ")"]);
+
+ case "blockquote":
+ return concat$16(["> ", align$2("> ", printChildren$1(path, options, print))]);
+
+ case "heading":
+ return concat$16(["#".repeat(node.depth) + " ", printChildren$1(path, options, print)]);
+
+ case "code":
+ {
+ if (node.isIndented) {
+ // indented code block
+ var alignment = " ".repeat(4);
+ return align$2(alignment, concat$16([alignment, replaceNewlinesWith(node.value, hardline$11)]));
+ } // fenced code block
+
+
+ var styleUnit = options.__inJsTemplate ? "~" : "`";
+
+ var _style2 = styleUnit.repeat(Math.max(3, util.getMaxContinuousCount(node.value, styleUnit) + 1));
+
+ return concat$16([_style2, node.lang || "", hardline$11, replaceNewlinesWith(getFencedCodeBlockValue(node, options.originalText), hardline$11), hardline$11, _style2]);
+ }
+
+ case "yaml":
+ case "toml":
+ return options.originalText.slice(node.position.start.offset, node.position.end.offset);
+
+ case "html":
+ {
+ var _parentNode2 = path.getParentNode();
+
+ var value = _parentNode2.type === "root" && util.getLast(_parentNode2.children) === node ? node.value.trimRight() : node.value;
+ var isHtmlComment = /^$/.test(value);
+ return replaceNewlinesWith(value, isHtmlComment ? hardline$11 : markAsRoot$3(literalline$5));
+ }
+
+ case "list":
+ {
+ var nthSiblingIndex = getNthListSiblingIndex(node, path.getParentNode());
+ var isGitDiffFriendlyOrderedList = node.ordered && node.children.length > 1 && +getOrderedListItemInfo(node.children[1], options.originalText).numberText === 1;
+ return printChildren$1(path, options, print, {
+ processor: function processor(childPath, index) {
+ var prefix = getPrefix();
+ return concat$16([prefix, align$2(" ".repeat(prefix.length), printListItem(childPath, options, print, prefix))]);
+
+ function getPrefix() {
+ var 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":
+ {
+ var counter = getAncestorCounter$1(path, "list");
+
+ if (counter === -1) {
+ return "---";
+ }
+
+ var _nthSiblingIndex = getNthListSiblingIndex(path.getParentNode(counter), path.getParentNode(counter + 1));
+
+ return _nthSiblingIndex % 2 === 0 ? "***" : "---";
+ }
+
+ case "linkReference":
+ return concat$16(["[", printChildren$1(path, options, print), "]", node.referenceType === "full" ? concat$16(["[", node.identifier, "]"]) : node.referenceType === "collapsed" ? "[]" : ""]);
+
+ case "imageReference":
+ switch (node.referenceType) {
+ case "full":
+ return concat$16(["![", node.alt || "", "][", node.identifier, "]"]);
+
+ default:
+ return concat$16(["![", node.alt, "]", node.referenceType === "collapsed" ? "[]" : ""]);
+ }
+
+ case "definition":
+ {
+ var lineOrSpace = options.proseWrap === "always" ? line$10 : " ";
+ return group$15(concat$16([concat$16(["[", node.identifier, "]:"]), indent$9(concat$16([lineOrSpace, printUrl(node.url), node.title === null ? "" : concat$16([lineOrSpace, printTitle(node.title, options, false)])]))]));
+ }
+
+ case "footnote":
+ return concat$16(["[^", printChildren$1(path, options, print), "]"]);
+
+ case "footnoteReference":
+ return concat$16(["[^", node.identifier, "]"]);
+
+ case "footnoteDefinition":
+ {
+ var _nextNode2 = path.getParentNode().children[path.getName() + 1];
+ var 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$16(["[^", node.identifier, "]: ", shouldInlineFootnote ? printChildren$1(path, options, print) : group$15(concat$16([align$2(" ".repeat(options.tabWidth), printChildren$1(path, options, print, {
+ processor: function processor(childPath, index) {
+ return index === 0 ? group$15(concat$16([softline$7, softline$7, childPath.call(print)])) : childPath.call(print);
+ }
+ })), _nextNode2 && _nextNode2.type === "footnoteDefinition" ? softline$7 : ""]))]);
+ }
+
+ 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$16([" ", markAsRoot$3(literalline$5)]) : concat$16(["\\", hardline$11]);
+
+ case "liquidNode":
+ return replaceNewlinesWith(node.value, hardline$11);
+ // MDX
+
+ case "importExport":
+ case "jsx":
+ return node.value;
+ // fallback to the original text if multiparser failed
+
+ case "math":
+ return concat$16(["$$", hardline$11, node.value ? concat$16([replaceNewlinesWith(node.value, hardline$11), hardline$11]) : "", "$$"]);
+
+ case "inlineMath":
+ {
+ // $$math$$ can be block math in some variants
+ // see https://github.com/Rokt33r/remark-math#double-dollars-in-inline
+ var _style3 = options.originalText[node.position.start.offset + 1] === "$" ? "$$" : "$";
+
+ return concat$16([_style3, node.value, _style3]);
+ }
+
+ case "tableRow": // handled in "table"
+
+ case "listItem": // handled in "list"
+
+ default:
+ throw new Error("Unknown markdown type ".concat(JSON.stringify(node.type)));
+ }
+}
+
+function printListItem(path, options, print, listPrefix) {
+ var node = path.getValue();
+ var prefix = node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
+ return concat$16([prefix, printChildren$1(path, options, print, {
+ processor: function processor(childPath, index) {
+ if (index === 0 && childPath.getValue().type !== "list") {
+ return align$2(" ".repeat(prefix.length), childPath.call(print));
+ }
+
+ var alignment = " ".repeat(clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
+ );
+ return concat$16([alignment, align$2(alignment, childPath.call(print))]);
+ }
+ })]);
+}
+
+function alignListPrefix(prefix, options) {
+ var additionalSpaces = getAdditionalSpaces();
+ return prefix + " ".repeat(additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
+ );
+
+ function getAdditionalSpaces() {
+ var restSpaces = prefix.length % options.tabWidth;
+ return restSpaces === 0 ? 0 : options.tabWidth - restSpaces;
+ }
+}
+
+function getNthListSiblingIndex(node, parentNode) {
+ return getNthSiblingIndex(node, parentNode, function (siblingNode) {
+ return siblingNode.ordered === node.ordered;
+ });
+}
+
+function replaceNewlinesWith(str, doc$$2) {
+ return join$11(doc$$2, str.replace(/\r\n?/g, "\n").split("\n"));
+}
+
+function getNthSiblingIndex(node, parentNode, condition) {
+ condition = condition || function () {
+ return true;
+ };
+
+ var index = -1;
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = parentNode.children[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var childNode = _step.value;
+
+ if (childNode.type === node.type && condition(childNode)) {
+ index++;
+ } else {
+ index = -1;
+ }
+
+ if (childNode === node) {
+ return index;
+ }
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+}
+
+function getAncestorCounter$1(path, typeOrTypes) {
+ var types = [].concat(typeOrTypes);
+ var counter = -1;
+ var ancestorNode;
+
+ while (ancestorNode = path.getParentNode(++counter)) {
+ if (types.indexOf(ancestorNode.type) !== -1) {
+ return counter;
+ }
+ }
+
+ return -1;
+}
+
+function getAncestorNode$2(path, typeOrTypes) {
+ var 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$11;
+ }
+
+ var isBreakable = options.proseWrap === "always" && !getAncestorNode$2(path, SINGLE_LINE_NODE_TYPES);
+ return value !== "" ? isBreakable ? line$10 : " " : isBreakable ? softline$7 : "";
+}
+
+function printTable(path, options, print) {
+ var node = path.getValue();
+ var contents = []; // { [rowIndex: number]: { [columnIndex: number]: string } }
+
+ path.map(function (rowPath) {
+ var rowContents = [];
+ rowPath.map(function (cellPath) {
+ rowContents.push(printDocToString$2(cellPath.call(print), options).formatted);
+ }, "children");
+ contents.push(rowContents);
+ }, "children");
+ var columnMaxWidths = contents.reduce(function (currentWidths, rowContents) {
+ return currentWidths.map(function (width, columnIndex) {
+ return Math.max(width, util.getStringWidth(rowContents[columnIndex]));
+ });
+ }, contents[0].map(function () {
+ return 3;
+ }) // minimum width = 3 (---, :--, :-:, --:)
+ );
+ return join$11(hardline$11, [printRow(contents[0]), printSeparator(), join$11(hardline$11, contents.slice(1).map(printRow))]);
+
+ function printSeparator() {
+ return concat$16(["| ", join$11(" | ", columnMaxWidths.map(function (width, index) {
+ switch (node.align[index]) {
+ case "left":
+ return ":" + "-".repeat(width - 1);
+
+ case "right":
+ return "-".repeat(width - 1) + ":";
+
+ case "center":
+ return ":" + "-".repeat(width - 2) + ":";
+
+ default:
+ return "-".repeat(width);
+ }
+ })), " |"]);
+ }
+
+ function printRow(rowContents) {
+ return concat$16(["| ", join$11(" | ", rowContents.map(function (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) {
+ return concat$16([text, " ".repeat(width - util.getStringWidth(text))]);
+ }
+
+ function alignRight(text, width) {
+ return concat$16([" ".repeat(width - util.getStringWidth(text)), text]);
+ }
+
+ function alignCenter(text, width) {
+ var spaces = width - util.getStringWidth(text);
+ var left = Math.floor(spaces / 2);
+ var right = spaces - left;
+ return concat$16([" ".repeat(left), text, " ".repeat(right)]);
+ }
+}
+
+function printRoot(path, options, print) {
+ /** @typedef {{ index: number, offset: number }} IgnorePosition */
+
+ /** @type {Array<{start: IgnorePosition, end: IgnorePosition}>} */
+ var ignoreRanges = [];
+ /** @type {IgnorePosition | null} */
+
+ var ignoreStart = null;
+ var children = path.getValue().children;
+ children.forEach(function (childNode, index) {
+ switch (isPrettierIgnore$1(childNode)) {
+ case "start":
+ if (ignoreStart === null) {
+ ignoreStart = {
+ index: index,
+ offset: childNode.position.end.offset
+ };
+ }
+
+ break;
+
+ case "end":
+ if (ignoreStart !== null) {
+ ignoreRanges.push({
+ start: ignoreStart,
+ end: {
+ index: index,
+ offset: childNode.position.start.offset
+ }
+ });
+ ignoreStart = null;
+ }
+
+ break;
+
+ default:
+ // do nothing
+ break;
+ }
+ });
+ return printChildren$1(path, options, print, {
+ processor: function processor(childPath, index) {
+ if (ignoreRanges.length !== 0) {
+ var ignoreRange = ignoreRanges[0];
+
+ if (index === ignoreRange.start.index) {
+ return concat$16([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 || {};
+ var postprocessor = events.postprocessor || concat$16;
+
+ var processor = events.processor || function (childPath) {
+ return childPath.call(print);
+ };
+
+ var node = path.getValue();
+ var parts = [];
+ var lastChildNode;
+ path.map(function (childPath, index) {
+ var childNode = childPath.getValue();
+ var result = processor(childPath, index);
+
+ if (result !== false) {
+ var data = {
+ parts: parts,
+ prevNode: lastChildNode,
+ parentNode: node,
+ options: options
+ };
+
+ if (!shouldNotPrePrintHardline(childNode, data)) {
+ parts.push(hardline$11);
+
+ if (lastChildNode && TRAILING_HARDLINE_NODES.indexOf(lastChildNode.type) !== -1) {
+ if (shouldPrePrintTripleHardline(childNode, data)) {
+ parts.push(hardline$11);
+ }
+ } else {
+ if (shouldPrePrintDoubleHardline(childNode, data) || shouldPrePrintTripleHardline(childNode, data)) {
+ parts.push(hardline$11);
+ }
+
+ if (shouldPrePrintTripleHardline(childNode, data)) {
+ parts.push(hardline$11);
+ }
+ }
+ }
+
+ parts.push(result);
+ lastChildNode = childNode;
+ }
+ }, "children");
+ return postprocessor(parts);
+}
+
+function getLastDescendantNode(node) {
+ var 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$1(node) {
+ if (node.type !== "html") {
+ return false;
+ }
+
+ var match = node.value.match(/^$/);
+ return match === null ? false : match[1] ? match[1] : "next";
+}
+
+function shouldNotPrePrintHardline(node, data) {
+ var isFirstNode = data.parts.length === 0;
+ var isInlineNode = INLINE_NODE_TYPES.indexOf(node.type) !== -1;
+ var isInlineHTML = node.type === "html" && INLINE_NODE_WRAPPER_TYPES.indexOf(data.parentNode.type) !== -1;
+ return isFirstNode || isInlineNode || isInlineHTML;
+}
+
+function shouldPrePrintDoubleHardline(node, data) {
+ var isSequence = (data.prevNode && data.prevNode.type) === node.type;
+ var isSiblingNode = isSequence && SIBLING_NODE_TYPES.indexOf(node.type) !== -1;
+ var isInTightListItem = data.parentNode.type === "listItem" && !data.parentNode.loose;
+ var isPrevNodeLooseListItem = data.prevNode && data.prevNode.type === "listItem" && data.prevNode.loose;
+ var isPrevNodePrettierIgnore = isPrettierIgnore$1(data.prevNode) === "next";
+ var isBlockHtmlWithoutBlankLineBetweenPrevHtml = node.type === "html" && data.prevNode && data.prevNode.type === "html" && data.prevNode.position.end.line + 1 === node.position.start.line;
+ return isPrevNodeLooseListItem || !(isSiblingNode || isInTightListItem || isPrevNodePrettierIgnore || isBlockHtmlWithoutBlankLineBetweenPrevHtml);
+}
+
+function shouldPrePrintTripleHardline(node, data) {
+ var isPrevNodeList = data.prevNode && data.prevNode.type === "list";
+ var isIndentedCode = node.type === "code" && node.isIndented;
+ return isPrevNodeList && isIndentedCode;
+}
+
+function shouldRemainTheSameContent(path) {
+ var ancestorNode = getAncestorNode$2(path, ["linkReference", "imageReference"]);
+ return ancestorNode && (ancestorNode.type !== "linkReference" || ancestorNode.referenceType !== "full");
+}
+
+function normalizeDoc(doc$$2) {
+ return mapDoc$6(doc$$2, function (currentDoc) {
+ if (!currentDoc.parts) {
+ return currentDoc;
+ }
+
+ if (currentDoc.type === "concat" && currentDoc.parts.length === 1) {
+ return currentDoc.parts[0];
+ }
+
+ var parts = [];
+ currentDoc.parts.forEach(function (part) {
+ if (part.type === "concat") {
+ parts.push.apply(parts, part.parts);
+ } else if (part !== "") {
+ parts.push(part);
+ }
+ });
+ return Object.assign({}, currentDoc, {
+ parts: normalizeParts$2(parts)
+ });
+ });
+}
+
+function printUrl(url, dangerousCharOrChars) {
+ var dangerousChars = [" "].concat(dangerousCharOrChars || []);
+ return new RegExp(dangerousChars.map(function (x) {
+ return "\\".concat(x);
+ }).join("|")).test(url) ? "<".concat(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 "(".concat(title, ")"); // avoid escaped quotes
+ } // faster than using RegExps: https://jsperf.com/performance-of-match-vs-split
+
+
+ var singleCount = title.split("'").length - 1;
+ var doubleCount = title.split('"').length - 1;
+ var quote = singleCount > doubleCount ? '"' : doubleCount > singleCount ? "'" : options.singleQuote ? "'" : '"';
+ title = title.replace(new RegExp("(".concat(quote, ")"), "g"), "\\$1");
+ return "".concat(quote).concat(title).concat(quote);
+}
+
+function normalizeParts$2(parts) {
+ return parts.reduce(function (current, part) {
+ var lastPart = util.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$10(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$8.startWithPragma(ast.value)) {
+ return null;
+ }
+}
+
+function hasPrettierIgnore$3(path) {
+ var index = +path.getName();
+
+ if (index === 0) {
+ return false;
+ }
+
+ var prevNode = path.getParentNode().children[index - 1];
+ return isPrettierIgnore$1(prevNode) === "next";
+}
+
+var printerMarkdown = {
+ preprocess: preprocess_1$4,
+ print: genericPrint$5,
+ embed: embed_1$4,
+ massageAstNode: clean$10,
+ hasPrettierIgnore: hasPrettierIgnore$3,
+ insertPragma: pragma$8.insertPragma
+};
+
+var options$15 = {
+ proseWrap: commonOptions.proseWrap,
+ singleQuote: commonOptions.singleQuote
+};
+
+var name$15 = "Markdown";
+var type$14 = "prose";
+var aliases$5 = ["pandoc"];
+var aceMode$14 = "markdown";
+var codemirrorMode$10 = "gfm";
+var codemirrorMimeType$10 = "text/x-gfm";
+var wrap = true;
+var extensions$14 = [".md", ".markdown", ".mdown", ".mdwn", ".mkd", ".mkdn", ".mkdown", ".ronn", ".workbook"];
+var tmScope$14 = "source.gfm";
+var languageId$14 = 222;
+var markdown = {
+ name: name$15,
+ type: type$14,
+ aliases: aliases$5,
+ aceMode: aceMode$14,
+ codemirrorMode: codemirrorMode$10,
+ codemirrorMimeType: codemirrorMimeType$10,
+ wrap: wrap,
+ extensions: extensions$14,
+ tmScope: tmScope$14,
+ languageId: languageId$14
+};
+
+var markdown$1 = Object.freeze({
+ name: name$15,
+ type: type$14,
+ aliases: aliases$5,
+ aceMode: aceMode$14,
+ codemirrorMode: codemirrorMode$10,
+ codemirrorMimeType: codemirrorMimeType$10,
+ wrap: wrap,
+ extensions: extensions$14,
+ tmScope: tmScope$14,
+ languageId: languageId$14,
+ default: markdown
+});
+
+var require$$0$25 = ( markdown$1 && markdown ) || markdown$1;
+
+var languages$5 = [createLanguage(require$$0$25, {
+ override: {
+ since: "1.8.0",
+ parsers: ["remark"],
+ vscodeLanguageIds: ["markdown"]
+ },
+ extend: {
+ filenames: ["README"]
+ }
+}), createLanguage({
+ name: "MDX",
+ extensions: [".mdx"]
+}, // TODO: use linguist data
+{
+ override: {
+ since: "1.15.0",
+ parsers: ["mdx"],
+ vscodeLanguageIds: ["mdx"]
+ }
+})];
+var printers$5 = {
+ mdast: printerMarkdown
+};
+var languageMarkdown = {
+ languages: languages$5,
+ options: options$15,
+ printers: printers$5
+};
+
+function isPragma$1(text) {
+ return /^\s*@(prettier|format)\s*$/.test(text);
+}
+
+function hasPragma$4(text) {
+ return /^\s*#[^\n\S]*@(prettier|format)\s*?(\n|$)/.test(text);
+}
+
+function insertPragma$9(text) {
+ return "# @format\n\n".concat(text);
+}
+
+var pragma$11 = {
+ isPragma: isPragma$1,
+ hasPragma: hasPragma$4,
+ insertPragma: insertPragma$9
+};
+
+function getLast$7(array) {
+ return array[array.length - 1];
+}
+
+function getAncestorCount$1(path, filter) {
+ var counter = 0;
+ var pathStackLength = path.stack.length - 1;
+
+ for (var i = 0; i < pathStackLength; i++) {
+ var value = path.stack[i];
+
+ if (isNode$1(value) && filter(value)) {
+ counter++;
+ }
+ }
+
+ return counter;
+}
+/**
+ * @param {any} value
+ * @param {string[]=} types
+ */
+
+
+function isNode$1(value, types) {
+ return value && typeof value.type === "string" && (!types || types.indexOf(value.type) !== -1);
+}
+
+function mapNode$1(node, callback, parent) {
+ return callback("children" in node ? Object.assign({}, node, {
+ children: node.children.map(function (childNode) {
+ return mapNode$1(childNode, callback, node);
+ })
+ }) : node, parent);
+}
+
+function defineShortcut$1(x, key, getter) {
+ Object.defineProperty(x, key, {
+ get: getter,
+ enumerable: false
+ });
+}
+
+function isNextLineEmpty$6(node, text) {
+ var newlineCount = 0;
+ var textLength = text.length;
+
+ for (var i = node.position.end.offset - 1; i < textLength; i++) {
+ var char = text[i];
+
+ if (char === "\n") {
+ newlineCount++;
+ }
+
+ if (newlineCount === 1 && /\S/.test(char)) {
+ return false;
+ }
+
+ if (newlineCount === 2) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+function isLastDescendantNode$1(path) {
+ var node = path.getValue();
+
+ switch (node.type) {
+ case "tag":
+ case "anchor":
+ case "comment":
+ return false;
+ }
+
+ var pathStackLength = path.stack.length;
+
+ for (var i = 1; i < pathStackLength; i++) {
+ var item = path.stack[i];
+ var parentItem = path.stack[i - 1];
+
+ if (Array.isArray(parentItem) && typeof item === "number" && item !== parentItem.length - 1) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+function getLastDescendantNode$2(node) {
+ return "children" in node && node.children.length !== 0 ? getLastDescendantNode$2(getLast$7(node.children)) : node;
+}
+
+function isPrettierIgnore$2(comment) {
+ return comment.value.trim() === "prettier-ignore";
+}
+
+function hasPrettierIgnore$5(path) {
+ var node = path.getValue();
+
+ if (node.type === "documentBody") {
+ var document = path.getParentNode();
+ return hasEndComments$1(document.head) && isPrettierIgnore$2(getLast$7(document.head.endComments));
+ }
+
+ return hasLeadingComments$1(node) && isPrettierIgnore$2(getLast$7(node.leadingComments));
+}
+
+function isEmptyNode$1(node) {
+ return (!node.children || node.children.length === 0) && !hasComments(node);
+}
+
+function hasComments(node) {
+ return hasLeadingComments$1(node) || hasMiddleComments$1(node) || hasIndicatorComment$1(node) || hasTrailingComment$2(node) || hasEndComments$1(node);
+}
+
+function hasLeadingComments$1(node) {
+ return node && node.leadingComments && node.leadingComments.length !== 0;
+}
+
+function hasMiddleComments$1(node) {
+ return node && node.middleComments && node.middleComments.length !== 0;
+}
+
+function hasIndicatorComment$1(node) {
+ return node && node.indicatorComment;
+}
+
+function hasTrailingComment$2(node) {
+ return node && node.trailingComment;
+}
+
+function hasEndComments$1(node) {
+ return node && node.endComments && node.endComments.length !== 0;
+}
+/**
+ * " a b c d e f " -> [" a b", "c d", "e f "]
+ */
+
+
+function splitWithSingleSpace(text) {
+ var parts = [];
+ var lastPart = undefined;
+ var _iteratorNormalCompletion = true;
+ var _didIteratorError = false;
+ var _iteratorError = undefined;
+
+ try {
+ for (var _iterator = text.split(/( +)/g)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
+ var part = _step.value;
+
+ if (part !== " ") {
+ if (lastPart === " ") {
+ parts.push(part);
+ } else {
+ parts.push((parts.pop() || "") + part);
+ }
+ } else if (lastPart === undefined) {
+ parts.unshift("");
+ }
+
+ lastPart = part;
+ }
+ } catch (err) {
+ _didIteratorError = true;
+ _iteratorError = err;
+ } finally {
+ try {
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
+ _iterator.return();
+ }
+ } finally {
+ if (_didIteratorError) {
+ throw _iteratorError;
+ }
+ }
+ }
+
+ if (lastPart === " ") {
+ parts.push((parts.pop() || "") + " ");
+ }
+
+ if (parts[0] === "") {
+ parts.shift();
+ parts.unshift(" " + (parts.shift() || ""));
+ }
+
+ return parts;
+}
+
+function getFlowScalarLineContents$1(nodeType, content, options) {
+ var rawLineContents = content.split("\n").map(function (lineContent, index, lineContents) {
+ return index === 0 && index === lineContents.length - 1 ? lineContent : index !== 0 && index !== lineContents.length - 1 ? lineContent.trim() : index === 0 ? lineContent.trimRight() : lineContent.trimLeft();
+ });
+
+ if (options.proseWrap === "preserve") {
+ return rawLineContents.map(function (lineContent) {
+ return lineContent.length === 0 ? [] : [lineContent];
+ });
+ }
+
+ return rawLineContents.map(function (lineContent) {
+ return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
+ }).reduce(function (reduced, lineContentWords, index) {
+ return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !( // trailing backslash in quoteDouble should be preserved
+ nodeType === "quoteDouble" && getLast$7(getLast$7(reduced)).endsWith("\\")) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
+ }, []).map(function (lineContentWords) {
+ return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
+ });
+}
+
+function getBlockValueLineContents$1(node, _ref) {
+ var parentIndent = _ref.parentIndent,
+ isLastDescendant = _ref.isLastDescendant,
+ options = _ref.options;
+ var content = node.position.start.line === node.position.end.line ? "" : options.originalText.slice(node.position.start.offset, node.position.end.offset) // exclude open line `>` or `|`
+ .match(/^[^\n]*?\n([\s\S]*)$/)[1];
+ var leadingSpaceCount = node.indent === null ? function (match) {
+ return match ? match[1].length : Infinity;
+ }(content.match(/^( *)\S/m)) : node.indent - 1 + parentIndent;
+ var rawLineContents = content.split("\n").map(function (lineContent) {
+ return lineContent.slice(leadingSpaceCount);
+ });
+
+ if (options.proseWrap === "preserve" || node.type === "blockLiteral") {
+ return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
+ return lineContent.length === 0 ? [] : [lineContent];
+ }));
+ }
+
+ return removeUnnecessaryTrailingNewlines(rawLineContents.map(function (lineContent) {
+ return lineContent.length === 0 ? [] : splitWithSingleSpace(lineContent);
+ }).reduce(function (reduced, lineContentWords, index) {
+ return index !== 0 && rawLineContents[index - 1].length !== 0 && lineContentWords.length !== 0 && !/^\s/.test(lineContentWords[0]) && !/^\s|\s$/.test(getLast$7(reduced)) ? reduced.concat([reduced.pop().concat(lineContentWords)]) : reduced.concat([lineContentWords]);
+ }, []).map(function (lineContentWords) {
+ return lineContentWords.reduce(function (reduced, word) {
+ return (// disallow trailing spaces
+ reduced.length !== 0 && /\s$/.test(getLast$7(reduced)) ? reduced.concat(reduced.pop() + " " + word) : reduced.concat(word)
+ );
+ }, []);
+ }).map(function (lineContentWords) {
+ return options.proseWrap === "never" ? [lineContentWords.join(" ")] : lineContentWords;
+ }));
+
+ function removeUnnecessaryTrailingNewlines(lineContents) {
+ if (node.chomping === "keep") {
+ return getLast$7(lineContents).length === 0 ? lineContents.slice(0, -1) : lineContents;
+ }
+
+ var trailingNewlineCount = 0;
+
+ for (var i = lineContents.length - 1; i >= 0; i--) {
+ if (lineContents[i].length === 0) {
+ trailingNewlineCount++;
+ } else {
+ break;
+ }
+ }
+
+ return trailingNewlineCount === 0 ? lineContents : trailingNewlineCount >= 2 && !isLastDescendant ? // next empty line
+ lineContents.slice(0, -(trailingNewlineCount - 1)) : lineContents.slice(0, -trailingNewlineCount);
+ }
+}
+
+var utils$10 = {
+ getLast: getLast$7,
+ getAncestorCount: getAncestorCount$1,
+ isNode: isNode$1,
+ isEmptyNode: isEmptyNode$1,
+ mapNode: mapNode$1,
+ defineShortcut: defineShortcut$1,
+ isNextLineEmpty: isNextLineEmpty$6,
+ isLastDescendantNode: isLastDescendantNode$1,
+ getBlockValueLineContents: getBlockValueLineContents$1,
+ getFlowScalarLineContents: getFlowScalarLineContents$1,
+ getLastDescendantNode: getLastDescendantNode$2,
+ hasPrettierIgnore: hasPrettierIgnore$5,
+ hasLeadingComments: hasLeadingComments$1,
+ hasMiddleComments: hasMiddleComments$1,
+ hasIndicatorComment: hasIndicatorComment$1,
+ hasTrailingComment: hasTrailingComment$2,
+ hasEndComments: hasEndComments$1
+};
+
+var insertPragma$8 = pragma$11.insertPragma;
+var isPragma = pragma$11.isPragma;
+var getAncestorCount = utils$10.getAncestorCount;
+var getBlockValueLineContents = utils$10.getBlockValueLineContents;
+var getFlowScalarLineContents = utils$10.getFlowScalarLineContents;
+var getLast$6 = utils$10.getLast;
+var getLastDescendantNode$1 = utils$10.getLastDescendantNode;
+var hasLeadingComments = utils$10.hasLeadingComments;
+var hasMiddleComments = utils$10.hasMiddleComments;
+var hasIndicatorComment = utils$10.hasIndicatorComment;
+var hasTrailingComment$1 = utils$10.hasTrailingComment;
+var hasEndComments = utils$10.hasEndComments;
+var hasPrettierIgnore$4 = utils$10.hasPrettierIgnore;
+var isLastDescendantNode = utils$10.isLastDescendantNode;
+var isNextLineEmpty$5 = utils$10.isNextLineEmpty;
+var isNode = utils$10.isNode;
+var isEmptyNode = utils$10.isEmptyNode;
+var defineShortcut = utils$10.defineShortcut;
+var mapNode = utils$10.mapNode;
+var docBuilders$3 = doc.builders;
+var conditionalGroup$2 = docBuilders$3.conditionalGroup;
+var breakParent$4 = docBuilders$3.breakParent;
+var concat$18 = docBuilders$3.concat;
+var dedent$4 = docBuilders$3.dedent;
+var dedentToRoot$2 = docBuilders$3.dedentToRoot;
+var fill$6 = docBuilders$3.fill;
+var group$16 = docBuilders$3.group;
+var hardline$13 = docBuilders$3.hardline;
+var ifBreak$7 = docBuilders$3.ifBreak;
+var join$12 = docBuilders$3.join;
+var line$11 = docBuilders$3.line;
+var lineSuffix$2 = docBuilders$3.lineSuffix;
+var literalline$7 = docBuilders$3.literalline;
+var markAsRoot$5 = docBuilders$3.markAsRoot;
+var softline$8 = docBuilders$3.softline;
+
+function preprocess$6(ast) {
+ return mapNode(ast, defineShortcuts);
+}
+
+function defineShortcuts(node) {
+ switch (node.type) {
+ case "document":
+ defineShortcut(node, "head", function () {
+ return node.children[0];
+ });
+ defineShortcut(node, "body", function () {
+ return node.children[1];
+ });
+ break;
+
+ case "documentBody":
+ case "sequenceItem":
+ case "flowSequenceItem":
+ case "mappingKey":
+ case "mappingValue":
+ defineShortcut(node, "content", function () {
+ return node.children[0];
+ });
+ break;
+
+ case "mappingItem":
+ case "flowMappingItem":
+ defineShortcut(node, "key", function () {
+ return node.children[0];
+ });
+ defineShortcut(node, "value", function () {
+ return node.children[1];
+ });
+ break;
+ }
+
+ return node;
+}
+
+function genericPrint$6(path, options, print) {
+ var node = path.getValue();
+ var parentNode = path.getParentNode();
+ var tag = !node.tag ? "" : path.call(print, "tag");
+ var anchor = !node.anchor ? "" : path.call(print, "anchor");
+ var nextEmptyLine = isNode(node, ["mapping", "sequence", "comment", "directive", "mappingItem", "sequenceItem"]) && !isLastDescendantNode(path) ? printNextEmptyLine(path, options.originalText) : "";
+ return concat$18([node.type !== "mappingValue" && hasLeadingComments(node) ? concat$18([join$12(hardline$13, path.map(print, "leadingComments")), hardline$13]) : "", tag, tag && anchor ? " " : "", anchor, tag || anchor ? isNode(node, ["sequence", "mapping"]) && !hasMiddleComments(node) ? hardline$13 : " " : "", hasMiddleComments(node) ? concat$18([node.middleComments.length === 1 ? "" : hardline$13, join$12(hardline$13, path.map(print, "middleComments")), hardline$13]) : "", hasPrettierIgnore$4(path) ? options.originalText.slice(node.position.start.offset, node.position.end.offset) : group$16(_print(node, parentNode, path, options, print)), hasTrailingComment$1(node) && !isNode(node, ["document", "documentHead"]) ? lineSuffix$2(concat$18([node.type === "mappingValue" && !node.content ? "" : " ", parentNode.type === "mappingKey" && path.getParentNode(2).type === "mapping" && isInlineNode(node) ? "" : breakParent$4, path.call(print, "trailingComment")])) : "", nextEmptyLine, hasEndComments(node) && !isNode(node, ["documentHead", "documentBody"]) ? align$3(node.type === "sequenceItem" ? 2 : 0, concat$18([hardline$13, join$12(hardline$13, path.map(print, "endComments"))])) : ""]);
+}
+
+function _print(node, parentNode, path, options, print) {
+ switch (node.type) {
+ case "root":
+ return concat$18([join$12(hardline$13, path.map(function (childPath, index) {
+ var document = node.children[index];
+ var nextDocument = node.children[index + 1];
+ return concat$18([print(childPath), shouldPrintDocumentEndMarker(document, nextDocument) ? concat$18([hardline$13, "...", hasTrailingComment$1(document) ? concat$18([" ", path.call(print, "trailingComment")]) : ""]) : !nextDocument || hasTrailingComment$1(nextDocument.head) ? "" : concat$18([hardline$13, "---"])]);
+ }, "children")), node.children.length === 0 || function (lastDescendantNode) {
+ return isNode(lastDescendantNode, ["blockLiteral", "blockFolded"]) && lastDescendantNode.chomping === "keep";
+ }(getLastDescendantNode$1(node)) ? "" : hardline$13]);
+
+ case "document":
+ {
+ var nextDocument = parentNode.children[path.getName() + 1];
+ return join$12(hardline$13, [shouldPrintDocumentHeadEndMarker(node, nextDocument) === "head" ? join$12(hardline$13, [node.head.children.length === 0 && node.head.endComments.length === 0 ? "" : path.call(print, "head"), concat$18(["---", hasTrailingComment$1(node.head) ? concat$18([" ", path.call(print, "head", "trailingComment")]) : ""])].filter(Boolean)) : "", shouldPrintDocumentBody(node) ? path.call(print, "body") : ""].filter(Boolean));
+ }
+
+ case "documentHead":
+ return join$12(hardline$13, [].concat(path.map(print, "children"), path.map(print, "endComments")));
+
+ case "documentBody":
+ {
+ var children = join$12(hardline$13, path.map(print, "children")).parts;
+ var endComments = join$12(hardline$13, path.map(print, "endComments")).parts;
+ var separator = children.length === 0 || endComments.length === 0 ? "" : function (lastDescendantNode) {
+ return isNode(lastDescendantNode, ["blockFolded", "blockLiteral"]) ? lastDescendantNode.chomping === "keep" ? // there's already a newline printed at the end of blockValue (chomping=keep, lastDescendant=true)
+ "" : // an extra newline for better readability
+ concat$18([hardline$13, hardline$13]) : hardline$13;
+ }(getLastDescendantNode$1(node));
+ return concat$18([].concat(children, separator, endComments));
+ }
+
+ case "directive":
+ return concat$18(["%", join$12(" ", [node.name].concat(node.parameters))]);
+
+ case "comment":
+ return concat$18(["#", node.value]);
+
+ case "alias":
+ return concat$18(["*", node.value]);
+
+ case "tag":
+ return options.originalText.slice(node.position.start.offset, node.position.end.offset);
+
+ case "anchor":
+ return concat$18(["&", node.value]);
+
+ case "plain":
+ return printFlowScalarContent(node.type, options.originalText.slice(node.position.start.offset, node.position.end.offset), options);
+
+ case "quoteDouble":
+ case "quoteSingle":
+ {
+ var singleQuote = "'";
+ var doubleQuote = '"';
+ var raw = options.originalText.slice(node.position.start.offset + 1, node.position.end.offset - 1);
+
+ if (node.type === "quoteSingle" && raw.includes("\\") || node.type === "quoteDouble" && /\\[^"]/.test(raw)) {
+ // only quoteDouble can use escape chars
+ // and quoteSingle do not need to escape backslashes
+ var originalQuote = node.type === "quoteDouble" ? doubleQuote : singleQuote;
+ return concat$18([originalQuote, printFlowScalarContent(node.type, raw, options), originalQuote]);
+ } else if (raw.includes(doubleQuote)) {
+ return concat$18([singleQuote, printFlowScalarContent(node.type, node.type === "quoteDouble" ? raw // double quote needs to be escaped by backslash in quoteDouble
+ .replace(/\\"/g, doubleQuote).replace(/'/g, singleQuote.repeat(2)) : raw, options), singleQuote]);
+ }
+
+ if (raw.includes(singleQuote)) {
+ return concat$18([doubleQuote, printFlowScalarContent(node.type, node.type === "quoteSingle" ? // single quote needs to be escaped by 2 single quotes in quoteSingle
+ raw.replace(/''/g, singleQuote) : raw, options), doubleQuote]);
+ }
+
+ var quote = options.singleQuote ? singleQuote : doubleQuote;
+ return concat$18([quote, printFlowScalarContent(node.type, raw, options), quote]);
+ }
+
+ case "blockFolded":
+ case "blockLiteral":
+ {
+ var parentIndent = getAncestorCount(path, function (ancestorNode) {
+ return isNode(ancestorNode, ["sequence", "mapping"]);
+ });
+ var isLastDescendant = isLastDescendantNode(path);
+ return concat$18([node.type === "blockFolded" ? ">" : "|", node.indent === null ? "" : node.indent.toString(), node.chomping === "clip" ? "" : node.chomping === "keep" ? "+" : "-", hasIndicatorComment(node) ? concat$18([" ", path.call(print, "indicatorComment")]) : "", (node.indent === null ? dedent$4 : dedentToRoot$2)(align$3(node.indent === null ? options.tabWidth : node.indent - 1 + parentIndent, concat$18(getBlockValueLineContents(node, {
+ parentIndent: parentIndent,
+ isLastDescendant: isLastDescendant,
+ options: options
+ }).reduce(function (reduced, lineWords, index, lineContents) {
+ return reduced.concat(index === 0 ? hardline$13 : "", fill$6(join$12(line$11, lineWords).parts), index !== lineContents.length - 1 ? lineWords.length === 0 ? hardline$13 : markAsRoot$5(literalline$7) : node.chomping === "keep" && isLastDescendant ? lineWords.length === 0 ? dedentToRoot$2(hardline$13) : dedentToRoot$2(literalline$7) : "");
+ }, []))))]);
+ }
+
+ case "sequence":
+ return join$12(hardline$13, path.map(print, "children"));
+
+ case "sequenceItem":
+ return concat$18(["- ", align$3(2, !node.content ? "" : path.call(print, "content"))]);
+
+ case "mappingKey":
+ return !node.content ? "" : path.call(print, "content");
+
+ case "mappingValue":
+ return !node.content ? "" : path.call(print, "content");
+
+ case "mapping":
+ return join$12(hardline$13, path.map(print, "children"));
+
+ case "mappingItem":
+ case "flowMappingItem":
+ {
+ var isEmptyMappingKey = isEmptyNode(node.key);
+ var isEmptyMappingValue = isEmptyNode(node.value);
+
+ if (isEmptyMappingKey && isEmptyMappingValue) {
+ return concat$18([": "]);
+ }
+
+ var key = path.call(print, "key");
+ var value = path.call(print, "value");
+
+ if (isEmptyMappingValue) {
+ return node.type === "flowMappingItem" && parentNode.type === "flowMapping" ? key : node.type === "mappingItem" && isAbsolutelyPrintedAsSingleLineNode(node.key.content, options) && !hasTrailingComment$1(node.key.content) && (!parentNode.tag || parentNode.tag.value !== "tag:yaml.org,2002:set") ? concat$18([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ":"]) : concat$18(["? ", align$3(2, key)]);
+ }
+
+ if (isEmptyMappingKey) {
+ return concat$18([": ", align$3(2, value)]);
+ }
+
+ var groupId = Symbol("mappingKey");
+ var forceExplicitKey = hasLeadingComments(node.value) || !isInlineNode(node.key.content);
+ return forceExplicitKey ? concat$18(["? ", align$3(2, key), hardline$13, join$12("", path.map(print, "value", "leadingComments").map(function (comment) {
+ return concat$18([comment, hardline$13]);
+ })), ": ", align$3(2, value)]) : // force singleline
+ isSingleLineNode(node.key.content) && !hasLeadingComments(node.key.content) && !hasMiddleComments(node.key.content) && !hasTrailingComment$1(node.key.content) && !hasEndComments(node.key) && !hasLeadingComments(node.value.content) && !hasMiddleComments(node.value.content) && !hasEndComments(node.value) && isAbsolutelyPrintedAsSingleLineNode(node.value.content, options) ? concat$18([key, needsSpaceInFrontOfMappingValue(node) ? " " : "", ": ", value]) : conditionalGroup$2([concat$18([group$16(concat$18([ifBreak$7("? "), group$16(align$3(2, key), {
+ id: groupId
+ })])), ifBreak$7(concat$18([hardline$13, ": ", align$3(2, value)]), indent(concat$18([needsSpaceInFrontOfMappingValue(node) ? " " : "", ":", hasLeadingComments(node.value.content) || hasEndComments(node.value) && node.value.content && !isNode(node.value.content, ["mapping", "sequence"]) || parentNode.type === "mapping" && hasTrailingComment$1(node.key.content) && isInlineNode(node.value.content) || isNode(node.value.content, ["mapping", "sequence"]) && node.value.content.tag === null && node.value.content.anchor === null ? hardline$13 : !node.value.content ? "" : line$11, value])), {
+ groupId: groupId
+ })])]);
+ }
+
+ case "flowMapping":
+ case "flowSequence":
+ {
+ var openMarker = node.type === "flowMapping" ? "{" : "[";
+ var closeMarker = node.type === "flowMapping" ? "}" : "]";
+ var bracketSpacing = node.type === "flowMapping" && node.children.length !== 0 && options.bracketSpacing ? line$11 : softline$8;
+
+ var isLastItemEmptyMappingItem = node.children.length !== 0 && function (lastItem) {
+ return lastItem.type === "flowMappingItem" && isEmptyNode(lastItem.key) && isEmptyNode(lastItem.value);
+ }(getLast$6(node.children));
+
+ return concat$18([openMarker, indent(concat$18([bracketSpacing, concat$18(path.map(function (childPath, index) {
+ return concat$18([print(childPath), index === node.children.length - 1 ? "" : concat$18([",", line$11, node.children[index].position.start.line !== node.children[index + 1].position.start.line ? printNextEmptyLine(childPath, options.originalText) : ""])]);
+ }, "children")), ifBreak$7(",", "")])), isLastItemEmptyMappingItem ? "" : bracketSpacing, closeMarker]);
+ }
+
+ case "flowSequenceItem":
+ return path.call(print, "content");
+ // istanbul ignore next
+
+ default:
+ throw new Error("Unexpected node type ".concat(node.type));
+ }
+
+ function indent(doc$$2) {
+ return docBuilders$3.align(" ".repeat(options.tabWidth), doc$$2);
+ }
+}
+
+function align$3(n, doc$$2) {
+ return typeof n === "number" && n > 0 ? docBuilders$3.align(" ".repeat(n), doc$$2) : docBuilders$3.align(n, doc$$2);
+}
+
+function isInlineNode(node) {
+ if (!node) {
+ return true;
+ }
+
+ switch (node.type) {
+ case "plain":
+ case "quoteDouble":
+ case "quoteSingle":
+ case "alias":
+ case "flowMapping":
+ case "flowSequence":
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+function isSingleLineNode(node) {
+ if (!node) {
+ return true;
+ }
+
+ switch (node.type) {
+ case "plain":
+ case "quoteDouble":
+ case "quoteSingle":
+ return node.position.start.line === node.position.end.line;
+
+ case "alias":
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+function shouldPrintDocumentBody(document) {
+ return document.body.children.length !== 0 || hasEndComments(document.body);
+}
+
+function shouldPrintDocumentEndMarker(document, nextDocument) {
+ return (
+ /**
+ *... # trailingComment
+ */
+ hasTrailingComment$1(document) || nextDocument && (
+ /**
+ * ...
+ * %DIRECTIVE
+ * ---
+ */
+ nextDocument.head.children.length !== 0 ||
+ /**
+ * ...
+ * # endComment
+ * ---
+ */
+ hasEndComments(nextDocument.head))
+ );
+}
+
+function shouldPrintDocumentHeadEndMarker(document, nextDocument) {
+ if (
+ /**
+ * %DIRECTIVE
+ * ---
+ */
+ document.head.children.length !== 0 ||
+ /**
+ * # end comment
+ * ---
+ */
+ hasEndComments(document.head) ||
+ /**
+ * --- # trailing comment
+ */
+ hasTrailingComment$1(document.head)) {
+ return "head";
+ }
+
+ if (shouldPrintDocumentEndMarker(document, nextDocument)) {
+ return false;
+ }
+
+ return nextDocument ? "root" : false;
+}
+
+function isAbsolutelyPrintedAsSingleLineNode(node, options) {
+ if (!node) {
+ return true;
+ }
+
+ switch (node.type) {
+ case "plain":
+ case "quoteSingle":
+ case "quoteDouble":
+ break;
+
+ case "alias":
+ return true;
+
+ default:
+ return false;
+ }
+
+ if (options.proseWrap === "preserve") {
+ return node.position.start.line === node.position.end.line;
+ }
+
+ if ( // backslash-newline
+ /\\$/m.test(options.originalText.slice(node.position.start.offset, node.position.end.offset))) {
+ return false;
+ }
+
+ switch (options.proseWrap) {
+ case "never":
+ return node.value.indexOf("\n") === -1;
+
+ case "always":
+ return !/[\n ]/.test(node.value);
+ // istanbul ignore next
+
+ default:
+ return false;
+ }
+}
+
+function needsSpaceInFrontOfMappingValue(node) {
+ return node.key.content && node.key.content.type === "alias";
+}
+
+function printNextEmptyLine(path, originalText) {
+ var node = path.getValue();
+ var root = path.stack[0];
+ root.isNextEmptyLinePrintedChecklist = root.isNextEmptyLinePrintedChecklist || [];
+
+ if (!root.isNextEmptyLinePrintedChecklist[node.position.end.line]) {
+ if (isNextLineEmpty$5(node, originalText)) {
+ root.isNextEmptyLinePrintedChecklist[node.position.end.line] = true;
+ return softline$8;
+ }
+ }
+
+ return "";
+}
+
+function printFlowScalarContent(nodeType, content, options) {
+ var lineContents = getFlowScalarLineContents(nodeType, content, options);
+ return join$12(hardline$13, lineContents.map(function (lineContentWords) {
+ return fill$6(join$12(line$11, lineContentWords).parts);
+ }));
+}
+
+function clean$11(node, newNode
+/*, parent */
+) {
+ if (isNode(newNode)) {
+ delete newNode.position;
+
+ switch (newNode.type) {
+ case "comment":
+ // insert pragma
+ if (isPragma(newNode.value)) {
+ return null;
+ }
+
+ break;
+
+ case "quoteDouble":
+ case "quoteSingle":
+ newNode.type = "quote";
+ break;
+ }
+ }
+}
+
+var printerYaml = {
+ preprocess: preprocess$6,
+ print: genericPrint$6,
+ massageAstNode: clean$11,
+ insertPragma: insertPragma$8
+};
+
+var options$18 = {
+ bracketSpacing: commonOptions.bracketSpacing,
+ singleQuote: commonOptions.singleQuote,
+ proseWrap: commonOptions.proseWrap
+};
+
+var name$16 = "YAML";
+var type$15 = "data";
+var tmScope$15 = "source.yaml";
+var aliases$6 = ["yml"];
+var extensions$15 = [".yml", ".mir", ".reek", ".rviz", ".sublime-syntax", ".syntax", ".yaml", ".yaml-tmlanguage", ".yml.mysql"];
+var filenames$3 = [".clang-format", ".clang-tidy", ".gemrc", "glide.lock"];
+var aceMode$15 = "yaml";
+var codemirrorMode$11 = "yaml";
+var codemirrorMimeType$11 = "text/x-yaml";
+var languageId$15 = 407;
+var yaml = {
+ name: name$16,
+ type: type$15,
+ tmScope: tmScope$15,
+ aliases: aliases$6,
+ extensions: extensions$15,
+ filenames: filenames$3,
+ aceMode: aceMode$15,
+ codemirrorMode: codemirrorMode$11,
+ codemirrorMimeType: codemirrorMimeType$11,
+ languageId: languageId$15
+};
+
+var yaml$1 = Object.freeze({
+ name: name$16,
+ type: type$15,
+ tmScope: tmScope$15,
+ aliases: aliases$6,
+ extensions: extensions$15,
+ filenames: filenames$3,
+ aceMode: aceMode$15,
+ codemirrorMode: codemirrorMode$11,
+ codemirrorMimeType: codemirrorMimeType$11,
+ languageId: languageId$15,
+ default: yaml
+});
+
+var require$$0$27 = ( yaml$1 && yaml ) || yaml$1;
+
+var languages$6 = [createLanguage(require$$0$27, {
+ override: {
+ since: "1.14.0",
+ parsers: ["yaml"],
+ vscodeLanguageIds: ["yaml"]
+ }
+})];
+var languageYaml = {
+ languages: languages$6,
+ printers: {
+ yaml: printerYaml
+ },
+ options: options$18
+};
+
+var version = require$$0.version;
+var getSupportInfo = support.getSupportInfo;
+var internalPlugins = [languageCss, languageGraphql, languageHandlebars, languageHtml, languageJs, languageMarkdown, languageYaml];
+
+var isArray = Array.isArray || function (arr) {
+ return Object.prototype.toString.call(arr) === "[object Array]";
+}; // Luckily `opts` is always the 2nd argument
+
+
+function withPlugins(fn) {
+ return function () {
+ var args = Array.from(arguments);
+ var plugins = args[1] && args[1].plugins || [];
+
+ if (!isArray(plugins)) {
+ plugins = Object.values(plugins);
+ }
+
+ args[1] = Object.assign({}, args[1], {
+ plugins: internalPlugins.concat(plugins)
+ });
+ return fn.apply(null, args);
+ };
+}
+
+var formatWithCursor = withPlugins(core.formatWithCursor);
+var standalone$2 = {
+ formatWithCursor: formatWithCursor,
+ format: function format(text, opts) {
+ return formatWithCursor(text, opts).formatted;
+ },
+ check: function check(text, opts) {
+ var formatted = formatWithCursor(text, opts).formatted;
+ return formatted === text;
+ },
+ doc: doc,
+ getSupportInfo: withPlugins(getSupportInfo),
+ version: version,
+ util: utilShared,
+ __debug: {
+ parse: withPlugins(core.parse),
+ formatAST: withPlugins(core.formatAST),
+ formatDoc: withPlugins(core.formatDoc),
+ printToDoc: withPlugins(core.printToDoc),
+ printDocToString: withPlugins(core.printDocToString)
+ }
+};
+
+var standalone = standalone$2;
+
+return standalone;
+
+})));
diff --git a/app/script.js b/app/script.js
index b92aeca..816b0bb 100644
--- a/app/script.js
+++ b/app/script.js
@@ -77,4 +77,4 @@ if (
});
}
-webpackJsonp([0],{"+ZAi":function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&("object"==typeof t||"function"==typeof t)?t:e}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0,t.default=void 0;var r=o("KM04"),l=o("inAt"),d=n(l),c=o("CIHI"),p=n(c),h=(0,r.h)("h1",null,"Atomic CSS Settings"),u=(0,r.h)("h3",null,"Configure Atomizer settings."," ",(0,r.h)("a",{href:"https://github.com/acss-io/atomizer#api",target:"_blank",rel:"noopener noreferrer"},"Read more")," ","about available settings."),m=function(e){function t(){return s(this,t),a(this,e.apply(this,arguments))}return i(t,e),t.prototype.componentDidUpdate=function(){var e=this;this.props.show&&setTimeout(function(){e.props.settings&&e.cm.setValue(e.props.settings.acssConfig),e.cm.refresh(),e.cm.focus()},500)},t.prototype.render=function(){var e=this;return(0,r.h)(d.default,{show:this.props.show,closeHandler:this.props.closeHandler},h,u,(0,r.h)("div",{style:"height: calc(100vh - 350px);"},(0,r.h)(p.default,{options:{mode:"application/ld+json",theme:this.props.editorTheme},onCreation:function(t){return e.cm=t},onBlur:function(t){return e.props.onChange(t.getValue())}})),(0,r.h)("div",{class:"flex flex-h-end"},(0,r.h)("button",{class:"btn btn--primary",onClick:this.props.closeHandler},"Apply and Close")))},t}(r.Component);t.default=m},0:function(){},"03MQ":function(e,t,o){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.CreateNewModal=function(e){var t=e.show,o=e.closeHandler,n=e.onBlankTemplateSelect,a=e.onTemplateSelect;return(0,s.h)(i.default,{show:t,closeHandler:o,smll:!0},(0,s.h)("div",{class:"tac"},(0,s.h)("button",{className:"btn",onClick:n},"Start a blank creation")),c,"Or choose from a template:",(0,s.h)("div",{class:"saved-items-pane__container"},d.default.map(function(e){return(0,s.h)(r.ItemTile,{inline:!0,item:e,focusable:!0,onClick:a.bind(null,e)})})))};var s=o("KM04"),a=o("inAt"),i=n(a),r=o("iGzD"),l=o("g3Nw"),d=n(l),c=(0,s.h)("hr",null)},"0job":function(e,t,o){"use strict";t.__esModule=!0,t.Icons=function(){return(0,n.h)("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",style:{display:"none"}},s,a,i,r,l,d,c,p,h,u,m,f,(0,n.h)("symbol",{id:"gift-icon",viewBox:"0 0 24 24"},g,b,y,v,C,k,S,(0,n.h)("symbol",{id:"loader-icon",viewBox:"0 0 44 44"},w)))};var n=o("KM04"),s=(0,n.h)("symbol",{id:"logo",viewBox:"-145 -2 372 175"},(0,n.h)("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",transform:"translate(-145.000000, -1.000000)"},(0,n.h)("polygon",{id:"Path-1",fill:"#FF4600",points:"31 0 232 0 132 173.310547"}),(0,n.h)("polygon",{id:"Path-1",fill:"#FF6C00",points:"0 0 201 0 101 173.310547"}),(0,n.h)("polygon",{id:"Path-1",fill:"#FF6C00",transform:"translate(271.500000, 86.500000) scale(1, -1) translate(-271.500000, -86.500000) ",points:"171 0 372 0 272 173.310547"}),(0,n.h)("polygon",{id:"Path-1",fill:"#FF4600",transform:"translate(241.500000, 86.500000) scale(1, -1) translate(-241.500000, -86.500000) ",points:"141 0 342 0 242 173.310547"}))),a=(0,n.h)("symbol",{id:"bug-icon",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M14,12H10V10H14M14,16H10V14H14M20,8H17.19C16.74,7.22 16.12,6.55 15.37,6.04L17,4.41L15.59,3L13.42,5.17C12.96,5.06 12.5,5 12,5C11.5,5 11.04,5.06 10.59,5.17L8.41,3L7,4.41L8.62,6.04C7.88,6.55 7.26,7.22 6.81,8H4V10H6.09C6.04,10.33 6,10.66 6,11V12H4V14H6V15C6,15.34 6.04,15.67 6.09,16H4V18H6.81C7.85,19.79 9.78,21 12,21C14.22,21 16.15,19.79 17.19,18H20V16H17.91C17.96,15.67 18,15.34 18,15V14H20V12H18V11C18,10.66 17.96,10.33 17.91,10H20V8Z"})),i=(0,n.h)("symbol",{id:"google-icon",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M21.35,11.1H12.18V13.83H18.69C18.36,17.64 15.19,19.27 12.19,19.27C8.36,19.27 5,16.25 5,12C5,7.9 8.2,4.73 12.2,4.73C15.29,4.73 17.1,6.7 17.1,6.7L19,4.72C19,4.72 16.56,2 12.1,2C6.42,2 2.03,6.8 2.03,12C2.03,17.05 6.16,22 12.25,22C17.6,22 21.5,18.33 21.5,12.91C21.5,11.76 21.35,11.1 21.35,11.1V11.1Z"})),r=(0,n.h)("symbol",{id:"fb-icon",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M17,2V2H17V6H15C14.31,6 14,6.81 14,7.5V10H14L17,10V14H14V22H10V14H7V10H10V6A4,4 0 0,1 14,2H17Z"})),l=(0,n.h)("symbol",{id:"github-icon",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z"})),d=(0,n.h)("symbol",{id:"settings-icon",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z"})),c=(0,n.h)("symbol",{id:"twitter-icon",viewBox:"0 0 16 16"},(0,n.h)("path",{d:"M15.969,3.058c-0.586,0.26-1.217,0.436-1.878,0.515c0.675-0.405,1.194-1.045,1.438-1.809 c-0.632,0.375-1.332,0.647-2.076,0.793c-0.596-0.636-1.446-1.033-2.387-1.033c-1.806,0-3.27,1.464-3.27,3.27 c0,0.256,0.029,0.506,0.085,0.745C5.163,5.404,2.753,4.102,1.14,2.124C0.859,2.607,0.698,3.168,0.698,3.767 c0,1.134,0.577,2.135,1.455,2.722C1.616,6.472,1.112,6.325,0.671,6.08c0,0.014,0,0.027,0,0.041c0,1.584,1.127,2.906,2.623,3.206 C3.02,9.402,2.731,9.442,2.433,9.442c-0.211,0-0.416-0.021-0.615-0.059c0.416,1.299,1.624,2.245,3.055,2.271 c-1.119,0.877-2.529,1.4-4.061,1.4c-0.264,0-0.524-0.015-0.78-0.046c1.447,0.928,3.166,1.469,5.013,1.469 c6.015,0,9.304-4.983,9.304-9.304c0-0.142-0.003-0.283-0.009-0.423C14.976,4.29,15.531,3.714,15.969,3.058z"})),p=(0,n.h)("symbol",{id:"heart-icon",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M12,21.35L10.55,20.03C5.4,15.36 2,12.27 2,8.5C2,5.41 4.42,3 7.5,3C9.24,3 10.91,3.81 12,5.08C13.09,3.81 14.76,3 16.5,3C19.58,3 22,5.41 22,8.5C22,12.27 18.6,15.36 13.45,20.03L12,21.35Z"})),h=(0,n.h)("symbol",{id:"play-icon",viewBox:"0 0 24 24"},(0,n.h)("svg",null,(0,n.h)("path",{d:"M8,5.14V19.14L19,12.14L8,5.14Z"}))),u=(0,n.h)("symbol",{id:"cancel-icon",viewBox:"0 0 24 24"},(0,n.h)("svg",null,(0,n.h)("path",{d:"M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12C4,13.85 4.63,15.55 5.68,16.91L16.91,5.68C15.55,4.63 13.85,4 12,4M12,20A8,8 0 0,0 20,12C20,10.15 19.37,8.45 18.32,7.09L7.09,18.32C8.45,19.37 10.15,20 12,20Z"}))),m=(0,n.h)("symbol",{id:"chevron-icon",viewBox:"0 0 24 24"},(0,n.h)("svg",null,(0,n.h)("path",{d:"M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z"}))),f=(0,n.h)("symbol",{id:"chat-icon",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4A2,2 0 0,0 20,2M8,14H6V12H8V14M8,11H6V9H8V11M8,8H6V6H8V8M15,14H10V12H15V14M18,11H10V9H18V11M18,8H10V6H18V8Z"})),g=(0,n.h)("path",{d:"M22,12V20A2,2 0 0,1 20,22H4A2,2 0 0,1 2,20V12A1,1 0 0,1 1,11V8A2,2 0 0,1 3,6H6.17C6.06,5.69 6,5.35 6,5A3,3 0 0,1 9,2C10,2 10.88,2.5 11.43,3.24V3.23L12,4L12.57,3.23V3.24C13.12,2.5 14,2 15,2A3,3 0 0,1 18,5C18,5.35 17.94,5.69 17.83,6H21A2,2 0 0,1 23,8V11A1,1 0 0,1 22,12M4,20H11V12H4V20M20,20V12H13V20H20M9,4A1,1 0 0,0 8,5A1,1 0 0,0 9,6A1,1 0 0,0 10,5A1,1 0 0,0 9,4M15,4A1,1 0 0,0 14,5A1,1 0 0,0 15,6A1,1 0 0,0 16,5A1,1 0 0,0 15,4M3,8V10H11V8H3M13,8V10H21V8H13Z"}),b=(0,n.h)("symbol",{id:"gift-icon",viewBox:"0 0 24 24"}),y=(0,n.h)("symbol",{id:"cross-icon",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"})),v=(0,n.h)("symbol",{id:"keyboard-icon",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M19,10H17V8H19M19,13H17V11H19M16,10H14V8H16M16,13H14V11H16M16,17H8V15H16M7,10H5V8H7M7,13H5V11H7M8,11H10V13H8M8,8H10V10H8M11,11H13V13H11M11,8H13V10H11M20,5H4C2.89,5 2,5.89 2,7V17A2,2 0 0,0 4,19H20A2,2 0 0,0 22,17V7C22,5.89 21.1,5 20,5Z"})),C=(0,n.h)("symbol",{id:"mode-icon",viewBox:"0 0 100 100"},(0,n.h)("g",null,(0,n.h)("rect",{x:0,y:0,width:28,height:47}),(0,n.h)("rect",{x:36,y:0,width:28,height:47}),(0,n.h)("rect",{x:72,y:0,width:28,height:47}),(0,n.h)("rect",{x:0,y:53,width:100,height:47}))),k=(0,n.h)("symbol",{id:"vertical-mode-icon",viewBox:"0 0 100 100"},(0,n.h)("g",null,(0,n.h)("rect",{x:0,y:0,width:20,height:100}),(0,n.h)("rect",{x:23,y:0,width:20,height:100}),(0,n.h)("rect",{x:46,y:0,width:20,height:100}),(0,n.h)("rect",{x:69,y:0,width:32,height:100}))),S=(0,n.h)("symbol",{id:"search",viewBox:"0 0 24 24"},(0,n.h)("path",{d:"M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z"})),w=(0,n.h)("g",{fill:"none",fillRule:"evenodd",strokeWidth:10},(0,n.h)("circle",{cx:22,cy:22,r:1},(0,n.h)("animate",{attributeName:"r",begin:"0s",dur:"1.8s",values:"1; 20",calcMode:"spline",keyTimes:"0; 1",keySplines:"0.165, 0.84, 0.44, 1",repeatCount:"indefinite"}),(0,n.h)("animate",{attributeName:"stroke-opacity",begin:"0s",dur:"1.8s",values:"1; 0",calcMode:"spline",keyTimes:"0; 1",keySplines:"0.3, 0.61, 0.355, 1",repeatCount:"indefinite"})),(0,n.h)("circle",{cx:22,cy:22,r:1},(0,n.h)("animate",{attributeName:"r",begin:"-0.9s",dur:"1.8s",values:"1; 20",calcMode:"spline",keyTimes:"0; 1",keySplines:"0.165, 0.84, 0.44, 1",repeatCount:"indefinite"}),(0,n.h)("animate",{attributeName:"stroke-opacity",begin:"-0.9s",dur:"1.8s",values:"1; 0",calcMode:"spline",keyTimes:"0; 1",keySplines:"0.3, 0.61, 0.355, 1",repeatCount:"indefinite"})))},"0lUe":function(e,t,o){"use strict";function n(e,t){var o={};for(var n in e)0<=t.indexOf(n)||Object.prototype.hasOwnProperty.call(e,n)&&(o[n]=e[n]);return o}function s(e){var t,o=e.type,n=e.children;return"bug"===o?t=c:"a11y"===o?t=p:"ui"===o&&(t=h),(0,l.h)("li",null,t,": ",n)}function a(e){var t=e.name,o=e.url;return(0,l.h)("a",{href:o,target:"_blank",rel:"noopener noreferrer"}," ",t)}function i(e){var t=e.version,o=e.isLatest,s=n(e,["version","isLatest"]);return(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},t),(0,l.h)("ul",null,s.children),o?(0,l.h)("div",{class:"mt-2"},u,m,(0,l.h)("p",null,"Web Maker now has more than 50K weekly active users! Thank you for being a part of this community of awesome developers. If you find Web Maker helpful,"," ",f,"\xA0",g,"\xA0",(0,l.h)(d.Button,{"aria-label":"Support the developer",onClick:s.onSupportBtnClick,"data-event-action":"supportDeveloperChangelogBtnClick","data-event-category":"ui",class:"btn btn-icon"},"Support the developer"))):null)}t.__esModule=!0;var r=Object.assign||function(e){for(var t,o=1;o",(0,l.h)("a",{href:"https://webmakerapp.com/app/",target:"_blank",rel:"noopener noreferrer"},"https://webmakerapp.com/app/"),"."),(0,l.h)("li",null,"Now use Web Maker web app on any modern browser (tested with Chrome and Firefox)."),(0,l.h)("li",null,(0,l.h)("strong",null,"User Accounts")," - The much requested user accounts are here. Now maintain your account and store all your creations in the cloud and access them anywhere anytime."),(0,l.h)("li",null,(0,l.h)("strong",null,"New layout mode")," - One more layout mode, that lets you align all the panes vertically."),(0,l.h)("li",null,(0,l.h)("strong",null,"No more restriction on scripts (Web app only)")," - If you are using the web app, there is no more a restriction to load scripts from only specific domains. Load any script!"),(0,l.h)("li",null,(0,l.h)("strong",null,"Inline scripts (Web app only)")," - The restriction of writing JavaScript only in JS pane is also removed."))),X=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.9.7"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("a",{href:"https://tailwindcss.com/",target:"_blank",rel:"noopener noreferrer"},"Tailwind CSS")," ","added to popular CSS libraries list. Thanks"," ",(0,l.h)(a,{url:"https://github.com/diomed",name:"diomed"}),"."),(0,l.h)("li",null,"Popular libraries list updated. Thanks"," ",(0,l.h)(a,{url:"https://github.com/diomed",name:"diomed"}),"."),(0,l.h)("li",null,(0,l.h)("strong",null,"Dev"),": Bug fixes and code refactoring to make things simple."," ",(0,l.h)(a,{url:"https://github.com/iamandrewluca",name:"iamandrewluca"})," ","."))),ee=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.9.6"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix"),": Fix close buttons not working in notifications and keyboard shortcuts modal."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix"),": Fix keyboard shortcut to see keyboard shortcuts :) Thanks",(0,l.h)("a",{href:"https://github.com/ClassicOldSong",target:"_blank",rel:"noopener noreferrer"},"ClassicOldSong"),"."))),te=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.9.5"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("a",{href:"https://medium.com/web-maker/release-2-9-5-add-library-search-pane-collapsing-ux-improvements-more-1085216c1301",target:"_blank",rel:"noopener noreferrer"},"Read blog post about this release.")),(0,l.h)("li",null,(0,l.h)("strong",null,"Keyboard shortcuts panel"),": Add a list of all keyboard shotcuts. Access with",(0,l.h)("code",null," Ctrl/\u2318 + Shift + ?")," or click keyboard button in footer."),(0,l.h)("li",null,(0,l.h)("strong",null,"Add external library"),": Better UX for searching third party libraries."),(0,l.h)("li",null,(0,l.h)("strong",null,"Improvement"),": Code panes now go fullscreen when double-clicked on their headers - which is much more intuitive behavior based on feedback from lot of developers."),(0,l.h)("li",null,(0,l.h)("strong",null,"Improvement"),": Add",(0,l.h)("code",null,"allowfullscreen")," attribute on iframes. Thanks",(0,l.h)("a",{href:"https://github.com/ClassicOldSong",target:"_blank",rel:"noopener noreferrer"},"ClassicOldSong"),"."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Stop screenlog.js from showing up in the exported HTML."),(0,l.h)("li",null,"Popular external libraries list updated. Thanks",(0,l.h)("a",{href:"https://github.com/jlapitan",target:"_blank",rel:"noopener noreferrer"},"jlapitan"),"."))),oe=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.9.4"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Improvement"),": Atomic CSS (Atomizer) has been updated to latest version. Now you can do things like psuedo elements. Learn More."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Logging circular objects is now possible. It won't show in the Web Maker console, but will show fine in browser's console."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Console's z-index issue has been fixed."))),ne=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.9.3"),(0,l.h)("ul",null,(0,l.h)("li",null,"Choose the save location while exporting your saved creations. Now easily sync them to your Dropbox or any cloud storage."),(0,l.h)("li",null,"All modals inside the app now have a close button."),(0,l.h)("li",null,"Checkbox that showed on clicking a boolean value is now removed. Thanks",(0,l.h)("a",{href:"https://github.com/gauravmuk",target:"_blank",rel:"noopener noreferrer"},"Gaurav Nanda"),"."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Screenshots on retina device are now correct. Thanks",(0,l.h)("a",{href:"https://github.com/AshBardhan",target:"_blank",rel:"noopener noreferrer"},"Ashish Bardhan"),"."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Double console log in detached mode fixed."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Console.clear now works in detached mode too."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - DOCTYPE added in preview."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Typo correction in README. Thanks",(0,l.h)("a",{href:"https://github.com/AdilMah",target:"_blank",rel:"noopener noreferrer"},"Adil Mahmood"),"."),(0,l.h)("li",null,"gstatic.com is available to load external JavaScripts from."),(0,l.h)("li",null,"Popular libraries list updated. Thanks",(0,l.h)("a",{href:"https://github.com/diomed",target:"_blank",rel:"noopener noreferrer"},"diomed"),"."),(0,l.h)("li",null,"Added",(0,l.h)("a",{href:"https://github.com/chinchang/web-maker/blob/master/CONTRIBUTING.md",target:"_blank",rel:"noopener noreferrer"},"contribution guidelines")," ","in the Github repository."))),se=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.9.2"),(0,l.h)("ul",null,(0,l.h)("li",null,"Minor bug fixes."))),ae=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.9.1"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("a",{href:"https://medium.com/web-maker/v2-9-lots-of-goodies-bd1e939571f6",target:"_blank",rel:"noopener noreferrer"},"Read blog post about last release.")),(0,l.h)("li",null,"Use Ctrl/Cmd+D to select next occurence of matching selection."),(0,l.h)("li",null,"Improve onboard experience."))),ie=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.9.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("a",{href:"https://medium.com/web-maker/v2-9-lots-of-goodies-bd1e939571f6",target:"_blank",rel:"noopener noreferrer"},"Read blog post about this release.")),(0,l.h)("li",null,(0,l.h)("strong",null,"Detached Preview")," - Yes, you read that correct! You can now detach your preview and send it to your secondary monitor."),(0,l.h)("li",null,(0,l.h)("strong",null,"Find & Replace")," - Long awaited, now its there. Ctrl/Cmd+f to find and add Alt to replace."),(0,l.h)("li",null,(0,l.h)("strong",null,"Atomic CSS (Atomizer) configurations")," - Add custom config for Atomic CSS.",(0,l.h)("a",{href:"https://github.com/acss-io/atomizer#api",target:"_blank",rel:"noopener noreferrer"},"Read more"),"."),(0,l.h)("li",null,(0,l.h)("strong",null,"Light mode")," - This new setting makes Web Maker drop some heavy effects like blur etc to gain more performance. Thanks",(0,l.h)("a",{href:"https://github.com/iamandrewluca",target:"_blank",rel:"noopener noreferrer"},"Andrew"),"."),(0,l.h)("li",null,(0,l.h)("strong",null,"Preserve logs setting")," - Choose whether or not to preserve logs across preview refreshes. Thanks",(0,l.h)("a",{href:"https://github.com/BasitAli",target:"_blank",rel:"noopener noreferrer"},"Basit"),"."),(0,l.h)("li",null,(0,l.h)("strong",null,"Line wrap setting")," - As the name says."),(0,l.h)("li",null,"Semantic UI added to popular libraries."),(0,l.h)("li",null,"Bootstrap, Vue, UI-Kit and more updated to latest versions in popular libraries."),(0,l.h)("li",null,"UX improvements in settings UI"),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Trigger preview refresh anytime with Ctrl/\u2318 + Shift + 5. Even with auto-preview on."))),re=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.8.1"),(0,l.h)("ul",null,(0,l.h)("li",null,"Vue.js & UIKit version updated to latest version in 'Add Library' list."),(0,l.h)("li",null,"UTF-8 charset added to preview HTML to support universal characters."))),le=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.8.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("a",{href:"https://medium.com/web-maker/release-v2-8-is-out-f44e6ea5d9c4",target:"_blank",rel:"noopener noreferrer"},"Read blog post about this release.")),(0,l.h)("li",null,(0,l.h)("strong",null,"Auto Save")," - Your creations now auto-save after your first manual save. This is configurable from settings."),(0,l.h)("li",null,(0,l.h)("strong",null,"Base2Tone-Meadow Editor Theme")," - First user contributed theme. Thanks to Diomed."),(0,l.h)("li",null,(0,l.h)("strong",null,"Use System Fonts")," - You can now use any of your existing system fonts in the editor!"),(0,l.h)("li",null,(0,l.h)("strong",null,"Matching Tag Highlight")," - Cursor over any HTML tag would highlight the matching pair tag."),(0,l.h)("li",null,"Auto-completion suggestion can now be switched off from settings."),(0,l.h)("li",null,(0,l.h)("strong",null,"Improvement")," - Stop white flicker in editor when the app opens."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Add Babel Polyfill to enable use of next-gen built-ins like Promise or WeakMap."),(0,l.h)("li",null,"Vue.js version updated to 2.4.0 in popular library list."),(0,l.h)("li",null,"Downloads permission is optional. Asked only when you take screenshot."))),de=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.7.2"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"External Libraries")," - Add Foundation.js and update UIKit 3 to latest beta."),(0,l.h)("li",null,(0,l.h)("strong",null,"rawgit.com")," &",(0,l.h)("strong",null,"wzrd.in")," domains are now allowed for loading external libraries from."),(0,l.h)("li",null,"Minor booting speed improvements"))),ce=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.7.1"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Framer.js support")," - You can now load the latest framer.js library from",(0,l.h)("a",{href:"https://builds.framerjs.com/",target:"_blank",rel:"noopener noreferrer"},"framer builds page")," ","and start coding framer prototypes."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix"),": Edit on CodePen is back in action."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix"),": Autocompletion menu doesn't show on cut and paste now."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix"),": Updated & fixed urls of some common external libraries to latest versions. UIKit3 & Bootstrap 4\u03B1 are now in the list."),(0,l.h)("li",null,"Preprocessor selector are now more accessible."))),pe=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.7.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Fork any creation!"),": Now you can fork any existing creation of yours to start a new work based on it. One big use case of this feature is \"Templates\"!",(0,l.h)("a",{target:"_blank",rel:"noopener noreferrer",href:"https://kushagragour.in/blog/2017/05/web-maker-fork-templates/?utm_source=webmakerapp&utm_medium=referral"},"Read more about it"),"."),(0,l.h)("li",null,(0,l.h)("strong",null,"Fonts \uD83D\uDE0D "),": Super-awesome 4 fonts (mostly with ligature support) now available to choose from. Fira Code is the default font now."),(0,l.h)("li",null,"Updated most used external libraries to latest versions."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix"),": Add missing Bootstrap JS file to most used external libraries list."),(0,l.h)("li",null,"Several other minor bugfixes and improvements to make Web Maker awesome!"),(0,l.h)("li",null,"Great news to share with you - Web Maker has been featured on the Chrome Webstore homepage! Thanks for all the love :)"))),he=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.6.1"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix"),": Emojis vanishing while exporting to Codepen has been fixed."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix"),":",(0,l.h)("code",null,"console.clear()")," now doesn't error and clears the inbuilt console."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix"),": External libraries added to the creation are exported as well to Codepen."))),ue=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.6.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"The \"Console\""),": The most awaited feature is here! There is now an inbuilt console to see your logs, errors and for quickly evaluating JavaScript code inside your preview. Enjoy! I also a",(0,l.h)("a",{href:"https://kushagragour.in/blog/2017/05/web-maker-console-is-here/?utm_source=webmakerapp&utm_medium=referral",target:"_blank",rel:"noopener noreferrer"},"blog post about it"),"."),(0,l.h)("li",null,"Number slider which popped on clicking any number in the code has been removed due to poor user experience."),(0,l.h)("li",null,"Minor usability improvements."))),me=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.5.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Atomic CSS"),": Use can now use Atomic CSS(ACSS) in your work!",(0,l.h)("a",{href:"https://acss.io/",target:"_blank",rel:"noopener noreferrer"},"Read more about it here"),"."),(0,l.h)("li",null,(0,l.h)("strong",null,"Search your saved creations"),": Easily search through all your saved creations by title."),(0,l.h)("li",null,(0,l.h)("strong",null,"Configurable Auto-preview")," - You can turn off the auto preview in settings if you don't want the preview to update as you type."),(0,l.h)("li",null,(0,l.h)("strong",null,"Configurable refresh on resize")," - You can configure whether you want the preview to refresh when you resize the preview panel."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Fix indentation",(0,l.h)("a",{href:"https://github.com/chinchang/web-maker/issues/104",target:"_blank",rel:"noopener noreferrer"},"issue")," ","with custom indentation size."))),fe=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.4.2"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Improved infinite loop protection"),": Infinite loop protection is now faster and more reliable. And works without the need of Escodegen. Thanks to Ariya Hidayat!"),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Default parameters not working in JavaScript is fixed."))),ge=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.4.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Import/Export"),": Your creations are most important. Now export all your creations into a single file as a backup that can be imported anytime & anywhere."),(0,l.h)("li",null,(0,l.h)("strong",null,"Editor themes"),": You have been heard. Now you can choose from a huge list of wonderful editor themes!"),(0,l.h)("li",null,(0,l.h)("strong",null,"Identation settings"),": Not a spaces fan? Switch to tabs and set your indentation size."),(0,l.h)("li",null,(0,l.h)("strong",null,"Vim key bindings"),": Rejoice Vim lovers!"),(0,l.h)("li",null,(0,l.h)("strong",null,"Code blast"),": Why don't you try coding with this switched on from the settings? Go on..."),(0,l.h)("li",null,(0,l.h)("strong",null,"Important"),": Due to security policy changes from Chrome 57 onwards, Web Maker now allows loading external JavaScript libraries only from certain whitelisted domains (localhost, https://ajax.googleapis.com, https://code.jquery.com, https://cdnjs.cloudflare.com, https://unpkg.com, https://maxcdn.com, https://cdn77.com, https://maxcdn.bootstrapcdn.com, https://cdn.jsdelivr.net/)"),(0,l.h)("li",null,"Save button now highlights when you have unsaved changes."),(0,l.h)("li",null,"Jade is now called Pug. Just a name change."))),be=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.3.2"),(0,l.h)("ul",null,(0,l.h)("li",null,"Update Babel to support latest and coolest ES6 features."),(0,l.h)("li",null,"Improve onboarding experience at first install."))),ye=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.3.1"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Splitting of code and preview panes is remembered by the editor."),(0,l.h)("li",null,"Title of the creation is used for the file name when saving as HTML."))),ve=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.3.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Add Library Autocompletion")," - Just start typing the name of library and you'll be shown matching libraries from cdnjs."),(0,l.h)("li",null,(0,l.h)("strong",null,"Preview Screenshot Capture")," - Want to grab a nice screenshot of your creation. You have it! Click and capture."),(0,l.h)("li",null,(0,l.h)("strong",null,"Auto Indent Code")," - Select your code and hit Shift-Tab to auto-indent it!"),(0,l.h)("li",null,(0,l.h)("strong",null,"Keyboard Navigation in Saved List")," - Now select your creation using arrow keys and hit ENTER to open it."),(0,l.h)("li",null,"Highlight active line in code panes."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Fix in generated title of new creation."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - HTML autocompletion is manual triggered now with Ctrl+Space."))),Ce=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.2.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Code Autocompletion")," - See code suggestions while you type!"),(0,l.h)("li",null,(0,l.h)("strong",null,"Full Screen Preview")," - Checkout your creation in a full-screen layout."),(0,l.h)("li",null,(0,l.h)("strong",null,"SASS")," - SASS support added for CSS."),(0,l.h)("li",null,(0,l.h)("strong",null,"Faster CSS update")," - Preview updates instantly without refresh when just CSS is changed."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Indentation fixed while going on new line."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Works even in Chrome Canary now. Though libraries can be added only through CDNs."))),ke=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.1.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"TypeScript")," - Now you can code in TypeScript too!"),(0,l.h)("li",null,(0,l.h)("strong",null,"Stylus Preprocessor")," - Stylus supported adding for CSS."),(0,l.h)("li",null,(0,l.h)("strong",null,"Code Folding")," - Collapse large code blocks for easy editing."),(0,l.h)("li",null,(0,l.h)("strong",null,"Bugfix")," - Support JSX in JavaScript."),(0,l.h)("li",null,"Better onboarding for first time users."))),Se=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"2.0.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Save and Load")," - Long pending and super-useful, now you can save your creations and resume them anytime later."),(0,l.h)("li",null,(0,l.h)("strong",null,"Insert JS & CSS")," - Load popular JavaScript & CSS libraries in your work without writing any code."),(0,l.h)("li",null,(0,l.h)("strong",null,"Collapsed Panes")," - Collapse/uncollapse code panes with a single click. Your pane configuration is even saved with every creation!"),(0,l.h)("li",null,(0,l.h)("strong",null,"Quick color & number change")," - Click on any color or number and experiment with quick values using a slider."),(0,l.h)("li",null,(0,l.h)("strong",null,"Linting")," - See your code errors right where you are coding."),(0,l.h)("li",null,"No more browser hang due to infinite loops!"))),we=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"1.7.0"),(0,l.h)("ul",null,(0,l.h)("li",null,(0,l.h)("strong",null,"Preprocessors!")," - Enjoy a whole list of preprocessors for HTML(Jade & markdown), CSS(SCSS & LESS) and JavaScript(CoffeeScript & Babel)."),(0,l.h)("li",null,"More awesome font for code."))),Me=(0,l.h)("div",{class:"notification"},(0,l.h)("span",{class:"notification__version"},"1.6.0"),(0,l.h)("ul",null,(0,l.h)("li",null,"You can now configure Web-Maker to not replace new tab page from the settings. It is always accessible from the icon in the top-right."),(0,l.h)("li",null,"Download current code as HTML file with Ctrl/\u2318 + S keyboard shortcut."),(0,l.h)("li",null,"New notifications panel added so you are always aware of the new changes in Web-Maker.")))},1:function(){},"18yn":function(e,t,o){"use strict";t.__esModule=!0,t.Profile=function(e){var t=e.user,o=e.logoutBtnHandler;return(0,n.h)("div",{class:"tac"},(0,n.h)("img",{height:"80",class:"profile-modal__avatar-img",src:t?t.photoURL||s:"",id:"profileAvatarImg",alt:"Profile image"}),(0,n.h)("h3",{id:"profileUserName",class:"mb-2"},t&&t.displayName?t.displayName:"Anonymous Creator"),(0,n.h)("p",null,(0,n.h)("button",{class:"btn","aria-label":"Logout from your account",onClick:o},"Logout")))};var n=o("KM04"),s="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='#ccc' d='M12,19.2C9.5,19.2 7.29,17.92 6,16C6.03,14 10,12.9 12,12.9C14,12.9 17.97,14 18,16C16.71,17.92 14.5,19.2 12,19.2M12,5A3,3 0 0,1 15,8A3,3 0 0,1 12,11A3,3 0 0,1 9,8A3,3 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z' /%3E%3C/svg%3E"},"1IZv":function(e,t,o){"use strict";t.__esModule=!0,t.KeyboardShortcutsModal=function(e){var t=e.show,o=e.closeHandler;return(0,n.h)(a.default,{show:t,closeHandler:o},i,r)};var n=o("KM04"),s=o("inAt"),a=function(e){return e&&e.__esModule?e:{default:e}}(s),i=(0,n.h)("h1",null,"Keyboard Shortcuts"),r=(0,n.h)("div",{class:"flex"},(0,n.h)("div",null,(0,n.h)("h2",null,"Global"),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + Shift + ?"),(0,n.h)("span",{class:"kbd-shortcut__details"},"See keyboard shortcuts")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + Shift + 5"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Refresh preview")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + S"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Save current creations")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + O"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Open list of saved creations")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl + L"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Clear console (works when console input is focused)")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Esc"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Close saved creations panel & modals"))),(0,n.h)("div",{class:"ml-2"},(0,n.h)("h2",null,"Editor"),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + F"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Find")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + G"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Select next match")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + Shift + G"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Select previous match")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + Opt/Alt + F"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Find & replace")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Shift + Tab"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Realign code")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + ]"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Indent code right")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + ["),(0,n.h)("span",{class:"kbd-shortcut__details"},"Indent code left")),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Tab"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Emmet code completion"," ",(0,n.h)("a",{href:"https://emmet.io/",target:"_blank",rel:"noopener noreferrer"},"Read more"))),(0,n.h)("p",null,(0,n.h)("span",{class:"kbd-shortcut__keys"},"Ctrl/\u2318 + /"),(0,n.h)("span",{class:"kbd-shortcut__details"},"Single line comment"))))},"3Z4F":function(e,t){"use strict";t.__esModule=!0;var o=Object.assign||function(e){for(var t,o=1;o":"")},""),i=n.externalLibs.css.split("\n").reduce(function(e,t){return e+(t?"\n":"")},""));var r="\n\n\n\n"+i+"\n\n\n\n"+e+"\n"+a+"\n";if(s||(r+=""),n.jsMode===d.JsModes.ES6&&(r+=""),"string"==typeof o)r+="\n\n",r}t.__esModule=!0,t.BASE_PATH=void 0,t.semverCompare=function(e,t){for(var o=e.split("."),n=t.split("."),s=0;3>s;s++){var a=+o[s],i=+n[s];if(a>i)return 1;if(i>a)return-1;if(!isNaN(a)&&isNaN(i))return 1;if(isNaN(a)&&!isNaN(i))return-1}return 0},t.generateRandomId=function(e){for(var t="",o=e||10;o--;)t+=u[~~(Math.random()*u.length)];return t},t.onButtonClick=function(e,t){e.addEventListener("click",function(o){return t(o),!1})},t.log=n,t.addInfiniteLoopProtection=function(e,t){var o=t.timeout,n=1,s=[],a="_wmloopvar";return p.parse(e,{tolerant:!0,range:!0,jsx:!0},function(e){switch(e.type){case"DoWhileStatement":case"ForStatement":case"ForInStatement":case"ForOfStatement":case"WhileStatement":var t=1+e.body.range[0],i=e.body.range[1],r=("\nif (Date.now() - %d > "+o+") { window.top.previewException(new Error(\"Infinite loop\")); break;}\n").replace("%d",a+n),l="";"BlockStatement"!==e.body.type&&(r="{"+r,l="}",--t),s.push({pos:t,str:r}),s.push({pos:i,str:l}),s.push({pos:e.range[0],str:"var %d = Date.now();\n".replace("%d",a+n)}),++n;break;default:}}),s.sort(function(e,t){return t.pos-e.pos}).forEach(function(t){e=e.slice(0,t.pos)+t.str+e.slice(t.pos)}),e},t.getHumanDate=function(e){var t=new Date(e),o=t.getDate()+" "+["January","February","March","April","May","June","July","August","September","October","November","December"][t.getMonth()]+" "+t.getFullYear();return o},t.once=function(e,t,o){e.addEventListener(t,function(n){return n.target.removeEventListener(t,arguments.callee),o(n)})},t.downloadFile=s,t.writeFile=a,t.loadJS=function(e){var t=(0,c.deferred)(),o=window.document.getElementsByTagName("script")[0],n=window.document.createElement("script");return n.src=e,n.async=!0,o.parentNode.insertBefore(n,o),n.onload=function(){t.resolve()},t.promise},t.getCompleteHtml=i,t.saveAsHtml=function(e){var t=(0,l.computeHtml)(e.html,e.htmlMode),o=(0,l.computeCss)(e.css,e.cssMode),n=(0,l.computeJs)(e.js,e.jsMode,!1);Promise.all([t,o,n]).then(function(t){var o=t[0].code,n=t[1].code,a=t[2].code,l=i(o,n,a,e,!0),c=new Date,d=["web-maker",c.getFullYear(),c.getMonth()+1,c.getDate(),c.getHours(),c.getMinutes(),c.getSeconds()].join("-");e.title&&(d=e.title),d+=".html";var p=new Blob([l],{type:"text/html;charset=UTF-8"});s(d,p),(0,r.trackEvent)("fn","saveFileComplete")})},t.handleDownloadsPermission=function(){var e=(0,c.deferred)();return window.IS_EXTENSION?(chrome.permissions.contains({permissions:["downloads"]},function(t){t?e.resolve():chrome.permissions.request({permissions:["downloads"]},function(t){t?((0,r.trackEvent)("fn","downloadsPermGiven"),e.resolve()):e.reject()})}),e.promise):(e.resolve(),e.promise)},t.getFilenameFromUrl=function(e){return e?e.match(/\/([^/]*)$/)[1]:""},t.prettify=function(e){var t=1n?e.classList.add("is-minimized"):e.classList.remove("is-minimized"),-1===e.style[o].indexOf("100% - "+2*k+"px")?e.classList.remove("is-maximized"):e.classList.add("is-maximized")})},50)},t.prototype.toggleCodeWrapCollapse=function(e){if(e.classList.contains("is-minimized")||e.classList.contains("is-maximized"))e.classList.remove("is-minimized"),e.classList.remove("is-maximized"),this.codeSplitInstance.setSizes([33.3,33.3,33.3]);else{var t=parseInt(e.dataset.codeWrapId,10),o=[k+"px",k+"px",k+"px"];o[t]="calc(100% - "+2*k+"px)",this.codeSplitInstance.setSizes(o),e.classList.add("is-maximized")}this.updateSplits()},t.prototype.collapseBtnHandler=function(t){var e=t.currentTarget.parentElement.parentElement.parentElement;this.toggleCodeWrapCollapse(e),(0,m.trackEvent)("ui","paneCollapseBtnClick",e.dataset.type)},t.prototype.codeWrapHeaderDblClickHandler=function(t){if(t.target.classList.contains("js-code-wrap__header")){var e=t.target.parentElement;this.toggleCodeWrapCollapse(e),(0,m.trackEvent)("ui","paneHeaderDblClick",e.dataset.type)}},t.prototype.resetSplitting=function(){this.setState({codeSplitSizes:this.getCodeSplitSizes(),mainSplitSizes:this.getMainSplitSizesToApply()})},t.prototype.updateSplits=function(){this.props.onSplitUpdate(),this.state.codeSplitSizes=this.props.currentItem.sizes,this.state.mainSplitSizes=this.props.currentItem.mainSizes},t.prototype.getMainSplitSizesToApply=function(){var e,t=this.props,o=t.currentItem,n=t.currentLayoutMode;return e=o&&o.mainSizes?3===n?[o.mainSizes[1],o.mainSizes[0]]:o.mainSizes:5===n?[75,25]:[50,50],e},t.prototype.getCodeSplitSizes=function(){return this.props.currentItem&&this.props.currentItem.sizes?this.props.currentItem.sizes:[33.33,33.33,33.33]},t.prototype.mainSplitDragEndHandler=function(){var e=this;this.props.prefs.refreshOnResize&&setTimeout(function(){e.setPreviewContent(!0)},1),this.updateSplits()},t.prototype.codeSplitDragStart=function(){document.body.classList.add("is-dragging")},t.prototype.codeSplitDragEnd=function(){this.updateCodeWrapCollapseStates(),document.body.classList.remove("is-dragging"),this.updateSplits()},t.prototype.handleModeRequirements=function(e){function t(){p.modes[e].hasLoaded=!0,n.resolve()}var o="lib/transpilers",n=(0,y.deferred)();return p.modes[e].hasLoaded?(n.resolve(),n.promise):(e===p.HtmlModes.JADE?(0,h.loadJS)(o+"/jade.js").then(t):e===p.HtmlModes.MARKDOWN?(0,h.loadJS)(o+"/marked.js").then(t):e===p.CssModes.LESS?(0,h.loadJS)(o+"/less.min.js").then(t):e===p.CssModes.SCSS||e===p.CssModes.SASS?(0,h.loadJS)(o+"/sass.js").then(function(){window.sass=new Sass(o+"/sass.worker.js"),t()}):e===p.CssModes.STYLUS?(0,h.loadJS)(o+"/stylus.min.js").then(t):e===p.CssModes.ACSS?(0,h.loadJS)(o+"/atomizer.browser.js").then(t):e===p.JsModes.COFFEESCRIPT?(0,h.loadJS)(o+"/coffee-script.js").then(t):e===p.JsModes.ES6?(0,h.loadJS)(o+"/babel.min.js").then(t):e===p.JsModes.TS?(0,h.loadJS)(o+"/typescript.js").then(t):n.resolve(),n.promise)},t.prototype.updateHtmlMode=function(e){return this.props.onCodeModeChange("html",e),this.props.currentItem.htmlMode=e,this.cm.html.setOption("mode",p.modes[e].cmMode),g.default.autoLoadMode(this.cm.html,p.modes[e].cmPath||p.modes[e].cmMode),this.handleModeRequirements(e)},t.prototype.updateCssMode=function(e){return this.props.onCodeModeChange("css",e),this.props.currentItem.cssMode=e,this.cm.css.setOption("mode",p.modes[e].cmMode),this.cm.css.setOption("readOnly",p.modes[e].cmDisable),window.cssSettingsBtn.classList[p.modes[e].hasSettings?"remove":"add"]("hide"),g.default.autoLoadMode(this.cm.css,p.modes[e].cmPath||p.modes[e].cmMode),this.handleModeRequirements(e)},t.prototype.updateJsMode=function(e){return this.props.onCodeModeChange("js",e),this.props.currentItem.jsMode=e,this.cm.js.setOption("mode",p.modes[e].cmMode),g.default.autoLoadMode(this.cm.js,p.modes[e].cmPath||p.modes[e].cmMode),this.handleModeRequirements(e)},t.prototype.codeModeChangeHandler=function(t){var e=this,o=t.target.value,n=t.target.dataset.type,s=this.props.currentItem["html"===n?"htmlMode":"css"===n?"cssMode":"jsMode"];s!==o&&("html"===n?this.updateHtmlMode(o).then(function(){return e.setPreviewContent(!0)}):"js"===n?this.updateJsMode(o).then(function(){return e.setPreviewContent(!0)}):"css"===n&&this.updateCssMode(o).then(function(){return e.setPreviewContent(!0)}),(0,m.trackEvent)("ui","updateCodeMode",o))},t.prototype.detachPreview=function(){var e=this;if(this.detachedWindow)return void this.detachedWindow.focus();var t=this.frame.getBoundingClientRect(),o=t.width,n=t.height;document.body.classList.add("is-detached-mode"),this.detachedWindow=window.open("./preview.html","Web Maker","width="+o+",height="+n+",resizable,scrollbars=yes,status=1"),setTimeout(function(){e.setPreviewContent(!0)},1500);var s=window.setInterval(function(){e.detachedWindow&&e.detachedWindow.closed&&(clearInterval(s),document.body.classList.remove("is-detached-mode"),e.detachedWindow=null,e.setPreviewContent(!0))},500)},t.prototype.updateLogCount=function(){window.logCountEl&&(logCountEl.textContent=this.logCount)},t.prototype.onMessageFromConsole=function(){var e=this;[].concat(Array.prototype.slice.call(arguments)).forEach(function(t){t&&t.indexOf&&-1!==t.indexOf("filesystem:chrome-extension")&&(t=t.replace(/filesystem:chrome-extension.*\.js:(\d+):*(\d*)/g,"script $1:$2"));try{e.consoleCm.replaceRange(t+" "+((t+"").match(/\[object \w+]/)?JSON.stringify(t):"")+"\n",{line:Infinity})}catch(t){e.consoleCm.replaceRange("\uD83C\uDF00\n",{line:Infinity})}e.consoleCm.scrollTo(0,Infinity),e.logCount++}),this.updateLogCount()},t.prototype.previewException=function(e){console.error("Possible infinite loop detected.",e.stack),this.onMessageFromConsole("Possible infinite loop detected.",e.stack)},t.prototype.toggleConsole=function(){this.setState({isConsoleOpen:!this.state.isConsoleOpen}),(0,m.trackEvent)("ui","consoleToggle")},t.prototype.consoleHeaderDblClickHandler=function(t){t.target.classList.contains("js-console__header")&&((0,m.trackEvent)("ui","consoleToggleDblClick"),this.toggleConsole())},t.prototype.clearConsole=function(){this.consoleCm.setValue(""),this.logCount=0,this.updateLogCount()},t.prototype.clearConsoleBtnClickHandler=function(){this.clearConsole(),(0,m.trackEvent)("ui","consoleClearBtnClick")},t.prototype.evalConsoleExpr=function(t){(76===t.which||12===t.which)&&t.ctrlKey?(this.clearConsole(),(0,m.trackEvent)("ui","consoleClearKeyboardShortcut")):13===t.which&&(this.onMessageFromConsole("> "+t.target.value),this.frame.contentWindow._wmEvaluate(t.target.value),t.target.value="",(0,m.trackEvent)("fn","evalConsoleExpr"))},t.prototype.cssSettingsBtnClickHandler=function(){this.setState({isCssSettingsModalOpen:!0}),(0,m.trackEvent)("ui","cssSettingsBtnClick")},t.prototype.cssSettingsChangeHandler=function(e){this.props.onCodeSettingsChange("css",e),this.setPreviewContent(!0)},t.prototype.getDemoFrame=function(e){e(this.frame)},t.prototype.editorFocusHandler=function(e){this.props.onEditorFocus(e)},t.prototype.render=function(){var e=this;return(0,r.h)(u.SplitPane,{class:"content-wrap flex flex-grow",sizes:this.state.mainSplitSizes,minSize:150,style:"",direction:2===this.props.currentLayoutMode?"vertical":"horizontal",onDragEnd:this.mainSplitDragEndHandler.bind(this)},(0,r.h)(u.SplitPane,{class:"code-side",id:"js-code-side",sizes:this.state.codeSplitSizes,minSize:k,direction:2===this.props.currentLayoutMode||5===this.props.currentLayoutMode?"horizontal":"vertical",onDragStart:this.codeSplitDragStart.bind(this),onDragEnd:this.codeSplitDragEnd.bind(this),onSplit:function(t){return e.codeSplitInstance=t}},(0,r.h)("div",{"data-code-wrap-id":"0",id:"htmlCodeEl","data-type":"html",class:"code-wrap",onTransitionEnd:this.updateCodeWrapCollapseStates.bind(this)},(0,r.h)("div",{class:"js-code-wrap__header code-wrap__header",title:"Double click to toggle code pane",onDblClick:this.codeWrapHeaderDblClickHandler.bind(this)},(0,r.h)("label",{class:"btn-group",dropdow:!0,title:"Click to change"},(0,r.h)("span",{class:"code-wrap__header-label"},p.modes[this.props.currentItem.htmlMode||"html"].label),S,(0,r.h)("select",{"data-type":"html",class:"js-mode-select hidden-select",onChange:this.codeModeChangeHandler.bind(this),value:this.props.currentItem.htmlMode},w,M,_)),(0,r.h)("div",{class:"code-wrap__header-right-options"},(0,r.h)("a",{class:"js-code-collapse-btn code-wrap__header-btn code-wrap__collapse-btn",title:"Toggle code pane",onClick:this.collapseBtnHandler.bind(this)}))),(0,r.h)(d.default,{options:{mode:"htmlmixed",profile:"xhtml",gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],noAutocomplete:!0,matchTags:{bothTags:!0},emmet:!0},prefs:this.props.prefs,onChange:this.onHtmlCodeChange.bind(this),onCreation:function(t){return e.cm.html=t},onFocus:this.editorFocusHandler.bind(this)})),(0,r.h)("div",{"data-code-wrap-id":"1",id:"cssCodeEl","data-type":"css",class:"code-wrap",onTransitionEnd:this.updateCodeWrapCollapseStates.bind(this)},(0,r.h)("div",{class:"js-code-wrap__header code-wrap__header",title:"Double click to toggle code pane",onDblClick:this.codeWrapHeaderDblClickHandler.bind(this)},(0,r.h)("label",{class:"btn-group",title:"Click to change"},(0,r.h)("span",{class:"code-wrap__header-label"},p.modes[this.props.currentItem.cssMode||"css"].label),x,(0,r.h)("select",{"data-type":"css",class:"js-mode-select hidden-select",onChange:this.codeModeChangeHandler.bind(this),value:this.props.currentItem.cssMode},H,I,L,j,E,B)),(0,r.h)("div",{class:"code-wrap__header-right-options"},(0,r.h)("a",{href:"#",id:"cssSettingsBtn",title:"Atomic CSS configuration",onClick:this.cssSettingsBtnClickHandler.bind(this),class:"code-wrap__header-btn hide"},A),(0,r.h)("a",{class:"js-code-collapse-btn code-wrap__header-btn code-wrap__collapse-btn",title:"Toggle code pane",onClick:this.collapseBtnHandler.bind(this)}))),(0,r.h)(d.default,{options:{mode:"css",gutters:["error-gutter","CodeMirror-linenumbers","CodeMirror-foldgutter"],emmet:!0,prettier:!0,prettierParser:"css"},prefs:this.props.prefs,onChange:this.onCssCodeChange.bind(this),onCreation:function(t){return e.cm.css=t},onFocus:this.editorFocusHandler.bind(this)})),(0,r.h)("div",{"data-code-wrap-id":"2",id:"jsCodeEl","data-type":"js",class:"code-wrap",onTransitionEnd:this.updateCodeWrapCollapseStates.bind(this)},(0,r.h)("div",{class:"js-code-wrap__header code-wrap__header",title:"Double click to toggle code pane",onDblClick:this.codeWrapHeaderDblClickHandler.bind(this)},(0,r.h)("label",{class:"btn-group",title:"Click to change"},(0,r.h)("span",{class:"code-wrap__header-label"},p.modes[this.props.currentItem.jsMode||"js"].label),O,(0,r.h)("select",{"data-type":"js",class:"js-mode-select hidden-select",onChange:this.codeModeChangeHandler.bind(this),value:this.props.currentItem.jsMode},T,P,D,V)),(0,r.h)("div",{class:"code-wrap__header-right-options"},(0,r.h)("a",{class:"js-code-collapse-btn code-wrap__header-btn code-wrap__collapse-btn",title:"Toggle code pane",onClick:this.collapseBtnHandler.bind(this)}))),(0,r.h)(d.default,{options:{mode:"javascript",gutters:["error-gutter","CodeMirror-linenumbers","CodeMirror-foldgutter"],prettier:!0,prettierParser:"js"},prefs:this.props.prefs,autoComplete:this.props.prefs.autoComplete,onChange:this.onJsCodeChange.bind(this),onCreation:function(t){return e.cm.js=t},onFocus:this.editorFocusHandler.bind(this)}))),(0,r.h)("div",{class:"demo-side",id:"js-demo-side",style:""},(0,r.h)("iframe",{ref:function(t){return e.frame=t},src:"about://blank",frameborder:"0",id:"demo-frame",allowfullscreen:!0}),(0,r.h)(b.Console,{isConsoleOpen:this.state.isConsoleOpen,onConsoleHeaderDblClick:this.consoleHeaderDblClickHandler.bind(this),onClearConsoleBtnClick:this.clearConsoleBtnClickHandler.bind(this),toggleConsole:this.toggleConsole.bind(this),onEvalInputKeyup:this.evalConsoleExpr.bind(this),onReady:function(t){return e.consoleCm=t}}),(0,r.h)(C.default,{show:this.state.isCssSettingsModalOpen,closeHandler:function(){return e.setState({isCssSettingsModalOpen:!1})},onChange:this.cssSettingsChangeHandler.bind(this),settings:this.props.currentItem.cssSettings,editorTheme:this.props.prefs.editorTheme})))},t}(r.Component);t.default=F},"9VU0":function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&("object"==typeof t||"function"==typeof t)?t:e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0,t.LibraryAutoSuggest=void 0;var i=function(){function e(e,t){for(var o,n=0;n"+t[o].name+"";e.isShowingSuggestions=!0,e.textareaBounds||(e.textareaBounds=e.t.getBoundingClientRect(),e.list.style.top=e.textareaBounds.bottom+"px",e.list.style.left=e.textareaBounds.left+"px",e.list.style.width=e.textareaBounds.width+"px"),e.list.classList.add("is-open")})},500)}},t.prototype.onKeyDown=function(e){var t;this.isShowingSuggestions&&(27===e.keyCode&&(this.closeSuggestions(),e.stopPropagation()),40===e.keyCode&&this.isShowingSuggestions?(t=this.list.querySelector(".selected"),t?(t.classList.remove("selected"),t.nextElementSibling.classList.add("selected")):this.list.querySelector("li:first-child").classList.add("selected"),this.list.querySelector(".selected").scrollIntoView(!1),e.preventDefault()):38===e.keyCode&&this.isShowingSuggestions?(t=this.list.querySelector(".selected"),t?(t.classList.remove("selected"),t.previousElementSibling.classList.add("selected")):this.list.querySelector("li:first-child").classList.add("selected"),this.list.querySelector(".selected").scrollIntoView(!1),e.preventDefault()):13===e.keyCode&&this.isShowingSuggestions&&(t=this.list.querySelector(".selected"),this.selectSuggestion(t.dataset.url),this.closeSuggestions()))},t.prototype.listMouseDownHandler=function(e){var t=e.target;t.parentElement.dataset.url&&this.selectSuggestion(t.parentElement.dataset.url)},t.prototype.selectSuggestion=function(e){this.t.focus(),(0,l.trackEvent)("ui","autoSuggestionLibSelected",e),this.selectedCallback?this.selectedCallback.call(null,e):this.replaceCurrentLine(e),this.closeSuggestions()},t.prototype.render=function(){var e=this;return(0,r.h)("div",{class:"btn-group "+(this.props.fullWidth?"flex-grow":""),ref:function(t){return e.wrap=t}},this.props.children,(0,r.h)("ul",{ref:function(t){return e.list=t},class:"dropdown__menu autocomplete-dropdown",onMouseDown:this.listMouseDownHandler.bind(this)}),(0,r.h)("div",{ref:function(t){return e.loader=t},class:"loader autocomplete__loader",style:"display:none"}))},i(t,[{key:"currentLineNumber",get:function(){return this.t.value.substr(0,this.t.selectionStart).split("\n").length}},{key:"currentLine",get:function(){var e=this.currentLineNumber;return this.t.value.split("\n")[e-1]}}]),t}(r.Component)},BcU7:function(e,t,o){"use strict";function n(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,o){function n(s,a){try{var i=t[s](a),r=i.value}catch(e){return void o(e)}return i.done?void e(r):Promise.resolve(r).then(function(e){n("next",e)},function(e){n("throw",e)})}return n("next")})}}var s=Object.assign||function(e){for(var t,o=1;o+l&&(a=Math.floor((r-l)/1e3/3600/24)),i.setState({daysLeft:a}),i}return a(t,e),t.prototype.render=function(){var e=this.props.codeSize?(this.props.codeSize/1024).toFixed(2):0;return(0,i.h)("div",{role:"button",class:"flex flex-v-center",tabIndex:"0",onClick:this.props.onClick,onBlur:this.props.onBlur},l," ",(0,i.h)("div",{class:"footer__js13k-days-left"},this.state.daysLeft," days to go"),(0,i.h)("div",{class:"footer__js13k-code-size",style:{color:10Hello, World!
\"}"})),ie=function(e){function t(){a(this,t);var o=i(this,e.call(this));return o.AUTO_SAVE_INTERVAL=15000,o.modalDefaultStates={isModalOpen:!1,isAddLibraryModalOpen:!1,isSettingsModalOpen:!1,isHelpModalOpen:!1,isNotificationsModalOpen:!1,isLoginModalOpen:!1,isProfileModalOpen:!1,isSupportDeveloperModalOpen:!1,isKeyboardShortcutsModalOpen:!1,isAskToImportModalOpen:!1,isOnboardModalOpen:!1,isJs13KModalOpen:!1,isCreateNewModalOpen:!1},o.state=l({isSavedItemPaneOpen:!1},o.modalDefaultStates,{prefs:{},currentItem:{title:"",externalLibs:{js:"",css:""}}}),o.defaultSettings={preserveLastCode:!0,replaceNewTab:!1,htmlMode:"html",jsMode:"js",cssMode:"css",isCodeBlastOn:!1,indentWith:"spaces",indentSize:2,editorTheme:"monokai",keymap:"sublime",fontSize:16,refreshOnResize:!1,autoPreview:!0,editorFont:"FiraCode",editorCustomFont:"",autoSave:!0,autoComplete:!0,preserveConsoleLogs:!0,lightVersion:!1,lineWrap:!0,infiniteLoopTimeout:1e3,layoutMode:2,isJs13kModeOn:!1},o.prefs={},O.default.auth().onAuthStateChanged(function(e){o.setState({isLoginModalOpen:!1}),e?((0,M.log)("You are -> ",e),B.alertsService.add("You are now logged in!"),o.setState({user:e}),window.user=e,!window.localStorage[Q.ASKED_TO_IMPORT_CREATIONS]&&o.fetchItems(!1,!0).then(function(e){e.length&&(o.oldSavedItems=e,o.oldSavedCreationsCount=e.length,o.setState({isAskToImportModalOpen:!0}),(0,j.trackEvent)("ui","askToImportModalSeen"))}),window.db.getUser(e.uid).then(function(t){if(t){var n=l({},o.state.prefs);l(n,e.settings),o.setState({prefs:n}),o.updateSetting()}})):(o.setState({user:void 0}),delete window.user),o.updateProfileUi()}),o}return r(t,e),t.prototype.componentWillMount=function(){var e,t=this;window.onunload=function(){t.saveCode("code"),t.detachedWindow&&t.detachedWindow.close()},db.local.get({layoutMode:1,code:""},function(o){t.toggleLayout(o.layoutMode),t.state.prefs.layoutMode=o.layoutMode,o.code&&(e=o.code)}),db.getSettings(this.defaultSettings).then(function(o){o.preserveLastCode&&e?(t.setState({unsavedEditCount:0}),e.id&&window.IS_EXTENSION?db.local.get(e.id,function(o){o[e.id]&&((0,M.log)("Load item ",e.id),t.setCurrentItem(o[e.id]).then(function(){return t.refreshEditor()}))}):((0,M.log)("Load last unsaved item",e),t.setCurrentItem(e).then(function(){return t.refreshEditor()}))):t.createNewItem(),l(t.state.prefs,o),t.setState({prefs:t.state.prefs}),t.updateSetting()}),db.getUserLastSeenVersion().then(function(e){e||(t.setState({isOnboardModalOpen:!0}),-1===document.cookie.indexOf("onboarded")&&((0,j.trackEvent)("ui","onboardModalSeen",ee),document.cookie="onboarded=1"),window.db.setUserLastSeenVersion(ee)),e&&-1===(0,M.semverCompare)(e,ee)&&!window.localStorage.pledgeModalSeen&&(t.openSupportDeveloperModal(),window.localStorage.pledgeModalSeen=!0),e&&-1!==(0,M.semverCompare)(e,ee)||(t.setState({hasUnseenChangelog:!0}),t.hasSeenNotifications=!1)})},t.prototype.updateProfileUi=function(){this.state.user?document.body.classList.add("is-logged-in"):document.body.classList.remove("is-logged-in")},t.prototype.refreshEditor=function(){this.toggleLayout(this.state.currentItem.layoutMode||this.state.prefs.layoutMode),this.updateExternalLibCount(),this.contentWrap.refreshEditor()},t.prototype.forkItem=function(e){var t=this;if(this.state.unsavedEditCount){var o=confirm("You have unsaved changes in your current work. Do you want to discard unsaved changes and continue?");if(!o)return}var n=JSON.parse(JSON.stringify(e));delete n.id,n.title="(Forked) "+e.title,n.updatedOn=Date.now(),this.setCurrentItem(n).then(function(){return t.refreshEditor()}),B.alertsService.add("\""+e.title+"\" was forked"),(0,j.trackEvent)("fn","itemForked")},t.prototype.createNewItem=function(){var e=this,t=new Date;this.setCurrentItem({title:"Untitled "+t.getDate()+"-"+(t.getMonth()+1)+"-"+t.getHours()+":"+t.getMinutes(),html:"",css:"",js:"",externalLibs:{js:"",css:""},layoutMode:this.state.currentLayoutMode}).then(function(){return e.refreshEditor()}),B.alertsService.add("New item created")},t.prototype.openItem=function(e){var t=this;this.setCurrentItem(e).then(function(){return t.refreshEditor()}),B.alertsService.add("Saved item loaded")},t.prototype.removeItem=function(e){var t=this,o=confirm("Are you sure you want to delete \""+e.title+"\"?");o&&(_.itemService.unsetItemForUser(e.id),_.itemService.removeItem(e.id).then(function(){B.alertsService.add("Item removed.",e),t.state.currentItem.id===e.id&&t.createNewItem()}),delete this.state.savedItems[e.id],this.setState({savedItems:l({},this.state.savedItems)}),(0,j.trackEvent)("fn","itemRemoved"))},t.prototype.setCurrentItem=function(e){var t=(0,E.deferred)();return e.htmlMode=e.htmlMode||this.state.prefs.htmlMode||L.HtmlModes.HTML,e.cssMode=e.cssMode||this.state.prefs.cssMode||L.CssModes.CSS,e.jsMode=e.jsMode||this.state.prefs.jsMode||L.JsModes.JS,this.setState({currentItem:e},t.resolve),this.isAutoSavingEnabled=!1,this.setState({unsavedEditCount:0}),t.promise},t.prototype.saveBtnClickHandler=function(){(0,j.trackEvent)("ui","saveBtnClick",this.state.currentItem.id?"saved":"new"),this.saveItem()},t.prototype.populateItemsInSavedPane=function(){this.setState({savedItems:l({},this.state.savedItems)}),this.toggleSavedItemsPane()},t.prototype.toggleSavedItemsPane=function(){this.setState({isSavedItemPaneOpen:!this.state.isSavedItemPaneOpen}),this.state.isSavedItemPaneOpen?window.searchInput.focus():window.searchInput.value="",document.body.classList[this.state.isSavedItemPaneOpen?"add":"remove"]("overlay-visible")},t.prototype.fetchItems=function(){var e=s(function*(e,t){var o=this,n=(0,E.deferred)();this.state.savedItems={};var s=[];return window.user&&!t?(s=yield _.itemService.getAllItems(),(0,M.log)("got items"),e&&s.forEach(function(e){o.state.savedItems[e.id]=e}),n.resolve(s),n.promise):(db.local.get("items",function(t){var a=Object.getOwnPropertyNames(t.items||{});a.length||n.resolve([]),(0,j.trackEvent)("fn","fetchItems",a.length);for(var r=function(t){db.local.get(a[t],function(i){e&&(o.state.savedItems[a[t]]=i[a[t]]),s.push(i[a[t]]),a.length===s.length&&n.resolve(s)})},l=0;lwindow.innerWidth?2:e,this.state.currentLayoutMode===e?(this.contentWrap.resetSplitting(),void this.setState({currentLayoutMode:e})):void([1,2,3,4,5].forEach(function(e){window["layoutBtn"+e].classList.remove("selected"),document.body.classList.remove("layout-"+e)}),$("#layoutBtn"+e).classList.add("selected"),document.body.classList.add("layout-"+e),this.setState({currentLayoutMode:e},function(){t.contentWrap.resetSplitting(),t.contentWrap.setPreviewContent(!0)}))},t.prototype.layoutBtnClickHandler=function(e){this.saveSetting("layoutMode",e),(0,j.trackEvent)("ui","toggleLayoutClick",e),this.toggleLayout(e)},t.prototype.getCodePaneSizes=function(){var e,t=this.state.currentLayoutMode,o=2===t||5===t?"width":"height";try{e=[htmlCodeEl.style[o],cssCodeEl.style[o],jsCodeEl.style[o]]}catch(t){e=[33.33,33.33,33.33]}finally{return e}},t.prototype.getMainPaneSizes=function(){var e,t=this.state.currentLayoutMode,o=2===t?"height":"width";try{e=[+$("#js-code-side").style[o].match(/([\d.]+)%/)[1],+$("#js-demo-side").style[o].match(/([\d.]+)%/)[1]]}catch(t){e=[50,50]}finally{return e}},t.prototype.saveSetting=function(e,t){var o,n=(0,E.deferred)(),s=(o={},o[e]=t,o);return db.local.set(s,n.resolve),n.promise},t.prototype.saveCode=function(e){return this.state.currentItem.updatedOn=Date.now(),this.state.currentItem.layoutMode=this.state.currentLayoutMode,this.state.currentItem.sizes=this.getCodePaneSizes(),this.state.currentItem.mainSizes=this.getMainPaneSizes(),(0,M.log)("saving key",e||this.state.currentItem.id,this.state.currentItem),_.itemService.setItem(e||this.state.currentItem.id,this.state.currentItem).then(function(){window.user&&!navigator.onLine?B.alertsService.add("Item saved locally. Will save to account when you are online."):B.alertsService.add("Item saved."),this.setState({unsavedEditCount:0})}.bind(this))},t.prototype.saveItem=function(){var e=this;if(!window.user&&!window.localStorage[Q.LOGIN_AND_SAVE_MESSAGE_SEEN]){var t=confirm("Saving without signing in will save your work only on this machine and this browser. If you want it to be secure & available anywhere, please login in your account and then save.\n\nDo you still want to continue saving locally?");if(window.localStorage[Q.LOGIN_AND_SAVE_MESSAGE_SEEN]=!0,!t)return(0,j.trackEvent)("ui",Q.LOGIN_AND_SAVE_MESSAGE_SEEN,"login"),this.closeAllOverlays(),void this.setState({isLoginModalOpen:!0});(0,j.trackEvent)("ui",Q.LOGIN_AND_SAVE_MESSAGE_SEEN,"local")}var o=!this.state.currentItem.id;this.state.currentItem.id=this.state.currentItem.id||"item-"+(0,M.generateRandomId)(),this.setState({isSaving:!0}),this.saveCode().then(function(){e.setState({isSaving:!1}),!e.isAutoSavingEnabled&&e.state.prefs.autoSave&&(e.isAutoSavingEnabled=!0,B.alertsService.add("Auto-save enabled."))}),o&&_.itemService.setItemForUser(this.state.currentItem.id)},t.prototype.onCodeModeChange=function(e,t){var o=l({},this.state.currentItem);o[e+"Mode"]=t,this.setState({currentItem:o})},t.prototype.onCodeChange=function(e,t,o){var n=this;this.state.currentItem[e]=t,o&&(this.setState({unsavedEditCount:this.state.unsavedEditCount+1}),0==this.state.unsavedEditCount%X&&this.state.unsavedEditCount>=X&&(window.saveBtn.classList.add("animated"),window.saveBtn.classList.add("wobble"),window.saveBtn.addEventListener("animationend",function(){window.saveBtn.classList.remove("animated"),window.saveBtn.classList.remove("wobble")}))),this.state.prefs.isJs13kModeOn&&(this.codeSizeCalculationTimeout&&clearTimeout(this.codeSizeCalculationTimeout),this.codeSizeCalculationTimeout=setTimeout(function(){n.calculateCodeSize(),n.codeSizeCalculationTimeout=null},1e3))},t.prototype.onCodeSettingsChange=function(e,t){this.state.currentItem[e+"Settings"]={acssConfig:t}},t.prototype.titleInputBlurHandler=function(t){this.state.currentItem.title=t.target.value,this.state.currentItem.id&&(this.saveItem(),(0,j.trackEvent)("ui","titleChanged"))},t.prototype.updateSetting=function(t){var e=this;if(t){var o=t.target.dataset.setting,n={},s=t.target;(0,M.log)(o,"checkbox"===s.type?s.checked:s.value);var a=l({},this.state.prefs);a[o]="checkbox"===s.type?s.checked:s.value,n[o]=a[o],this.setState({prefs:a}),db.sync.set(n,function(){B.alertsService.add("Setting saved")}),window.user&&window.db.getDb().then(function(t){var n;t.collection("users").doc(window.user.uid).update((n={},n["settings."+o]=e.state.prefs[o],n)).then(function(e){(0,M.log)("Setting \""+o+"\" for user",e)}).catch(function(e){return(0,M.log)(e)})}),(0,j.trackEvent)("ui","updatePref-"+o,a[o])}var i=this.state.prefs;runBtn.classList[i.autoPreview?"add":"remove"]("hide"),this.contentWrap.applyCodemirrorSettings(this.state.prefs),i.autoSave?!this.autoSaveInterval&&(this.autoSaveInterval=setInterval(function(){e.autoSaveLoop()},this.AUTO_SAVE_INTERVAL)):(clearInterval(this.autoSaveInterval),this.autoSaveInterval=null),document.body.classList[i.lightVersion?"add":"remove"]("light-version")},t.prototype.autoSaveLoop=function(){this.isAutoSavingEnabled&&this.state.unsavedEditCount&&this.saveItem()},t.prototype.loginBtnClickHandler=function(){this.setState({isLoginModalOpen:!0})},t.prototype.profileBtnClickHandler=function(){this.setState({isProfileModalOpen:!0})},t.prototype.logout=function(){if(this.state.unsavedEditCount){var e=confirm("You have unsaved changes. Do you still want to logout?");if(!e)return}(0,j.trackEvent)("fn","loggedOut"),P.auth.logout(),this.setState({isProfileModalOpen:!1}),B.alertsService.add("Log out successfull")},t.prototype.itemClickHandler=function(e){var t=this;setTimeout(function(){t.openItem(e)},350),this.toggleSavedItemsPane()},t.prototype.itemRemoveBtnClickHandler=function(e){this.removeItem(e)},t.prototype.itemForkBtnClickHandler=function(e){var t=this;this.toggleSavedItemsPane(),setTimeout(function(){t.forkItem(e)},350)},t.prototype.newBtnClickHandler=function(){if((0,j.trackEvent)("ui","newBtnClick"),this.state.unsavedEditCount){var e=confirm("You have unsaved changes. Do you still want to create something new?");e&&this.setState({isCreateNewModalOpen:!0})}else this.setState({isCreateNewModalOpen:!0})},t.prototype.openBtnClickHandler=function(){(0,j.trackEvent)("ui","openBtnClick"),this.openSavedItemsPane()},t.prototype.detachedPreviewBtnHandler=function(){(0,j.trackEvent)("ui","detachPreviewBtnClick"),this.contentWrap.detachPreview()},t.prototype.notificationsBtnClickHandler=function(){return this.setState({isNotificationsModalOpen:!0}),this.state.isNotificationsModalOpen&&!this.hasSeenNotifications&&(this.hasSeenNotifications=!0,this.setState({hasUnseenChangelog:!1}),window.db.setUserLastSeenVersion(ee)),(0,j.trackEvent)("ui","notificationButtonClick",ee),!1},t.prototype.codepenBtnClickHandler=function(t){if(this.state.currentItem.cssMode===L.CssModes.ACSS)return alert("Oops! CodePen doesn't supports Atomic CSS currently. \nHere is something you can still do -> https://medium.com/web-maker/sharing-your-atomic-css-work-on-codepen-a402001b26ab"),void t.preventDefault();var e={title:"A Web Maker experiment",html:this.state.currentItem.html,css:this.state.currentItem.css,js:this.state.currentItem.js,html_pre_processor:L.modes[this.state.currentItem.htmlMode].codepenVal,css_pre_processor:L.modes[this.state.currentItem.cssMode].codepenVal,js_pre_processor:L.modes[this.state.currentItem.jsMode].codepenVal,css_external:this.state.currentItem.externalLibs.css.split("\n").join(";"),js_external:this.state.currentItem.externalLibs.js.split("\n").join(";")};this.state.currentItem.title.match(/Untitled\s\d\d*-\d/)||(e.title=this.state.currentItem.title),e=JSON.stringify(e),window.codepenForm.querySelector("input").value=e,window.codepenForm.submit(),(0,j.trackEvent)("ui","openInCodepen"),t.preventDefault()},t.prototype.saveHtmlBtnClickHandler=function(t){(0,M.saveAsHtml)(this.state.currentItem),(0,j.trackEvent)("ui","saveHtmlClick"),t.preventDefault()},t.prototype.runBtnClickHandler=function(){this.contentWrap.setPreviewContent(!0,!0),(0,j.trackEvent)("ui","runBtnClick")},t.prototype.exportItems=function(){var e=this;(0,M.handleDownloadsPermission)().then(function(){e.fetchItems().then(function(e){var t=new Date,o=["web-maker-export",t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()].join("-");o+=".json";var n=new Blob([JSON.stringify(e,!1,2)],{type:"application/json;charset=UTF-8"});(0,M.downloadFile)(o,n),(0,j.trackEvent)("fn","exportItems")})})},t.prototype.exportBtnClickHandler=function(t){this.exportItems(),t.preventDefault(),(0,j.trackEvent)("ui","exportBtnClicked")},t.prototype.screenshotBtnClickHandler=function(t){this.contentWrap.getDemoFrame(function(e){(0,F.takeScreenshot)(e.getBoundingClientRect())}),t.preventDefault()},t.prototype.openSupportDeveloperModal=function(){this.closeAllOverlays(),this.setState({isSupportDeveloperModalOpen:!0})},t.prototype.supportDeveloperBtnClickHandler=function(t){this.openSupportDeveloperModal(t)},t.prototype.dontAskToImportAnymore=function(t){this.setState({isAskToImportModalOpen:!1}),window.localStorage[Q.ASKED_TO_IMPORT_CREATIONS]=!0,t&&(0,j.trackEvent)("ui","dontAskToImportBtnClick")},t.prototype.importCreationsAndSettingsIntoApp=function(){var e=this;this.mergeImportedItems(this.oldSavedItems).then(function(){(0,j.trackEvent)("fn","oldItemsImported"),e.dontAskToImportAnymore()})},t.prototype.editorFocusHandler=function(e){this.editorWithFocus=e},t.prototype.modalOverlayClickHandler=function(){this.closeAllOverlays()},t.prototype.splitUpdateHandler=function(){this.state.currentItem.sizes=this.getCodePaneSizes(),this.state.currentItem.mainSizes=this.getMainPaneSizes()},t.prototype.calculateTextSize=function(e){if(!e)return 0;var t=/(\r?\n|\r)/g,o=/(\r?\n|\r|\s+)/g;return{count:function(e,n){n=n||{},n.lineBreaks=n.lineBreaks||1,n.ignoreWhitespace=n.ignoreWhitespace||!1;var s=e.length,a=s-e.replace(/[\u0100-\uFFFF]/g,"").length,i=s-e.replace(t,"").length;return n.ignoreWhitespace?(e=e.replace(o,""),e.length+a):s+a+Math.max(0,n.lineBreaks*(i-1))},format:function(e,t){for(var o=0;1024"+e+"")+" "+o+"B"}}.count(e)},t.prototype.getExternalLibCode=function(){var e=this.state.currentItem,t=e.externalLibs&&e.externalLibs.js||"";return t+="\n"+e.externalLibs&&e.externalLibs.css||"",t=t.split("\n").filter(function(e){return e}),t.map(function(e){return fetch(e).then(function(e){return e.text()}).then(function(t){return{code:t,fileName:(0,M.getFilenameFromUrl)(e)}})})},t.prototype.calculateCodeSize=function(){var e=this,t=this.state.currentItem,o=(0,w.computeHtml)(t.html,t.htmlMode),n=(0,w.computeCss)(t.css,t.cssMode),s=(0,w.computeJs)(t.js,t.jsMode,!1);Promise.all([o,n,s].concat(this.getExternalLibCode())).then(function(o){var n=o[0].code||"",s=o[1].code||"",a=o[2].code||"",r=(0,M.getCompleteHtml)(n,s,a,t,!0);r=r.replace(/":"")},""),i=n.externalLibs.css.split("\n").reduce(function(e,t){return e+(t?"\n":"")},""));var r="\n\n\n\n"+i+"\n\n\n\n"+e+"\n"+a+"\n";if(s||(r+=""),n.jsMode===d.JsModes.ES6&&(r+=""),"string"==typeof o)r+="\n\n",r}t.__esModule=!0,t.BASE_PATH=void 0,t.semverCompare=function(e,t){for(var o=e.split("."),n=t.split("."),s=0;3>s;s++){var a=+o[s],i=+n[s];if(a>i)return 1;if(i>a)return-1;if(!isNaN(a)&&isNaN(i))return 1;if(isNaN(a)&&!isNaN(i))return-1}return 0},t.generateRandomId=function(e){for(var t="",o=e||10;o--;)t+=u[~~(Math.random()*u.length)];return t},t.onButtonClick=function(e,t){e.addEventListener("click",function(o){return t(o),!1})},t.log=n,t.addInfiniteLoopProtection=function(e,t){var o=t.timeout,n=1,s=[],a="_wmloopvar";return c.parse(e,{tolerant:!0,range:!0,jsx:!0},function(e){switch(e.type){case"DoWhileStatement":case"ForStatement":case"ForInStatement":case"ForOfStatement":case"WhileStatement":var t=1+e.body.range[0],i=e.body.range[1],r=("\nif (Date.now() - %d > "+o+") { window.top.previewException(new Error(\"Infinite loop\")); break;}\n").replace("%d",a+n),l="";"BlockStatement"!==e.body.type&&(r="{"+r,l="}",--t),s.push({pos:t,str:r}),s.push({pos:i,str:l}),s.push({pos:e.range[0],str:"var %d = Date.now();\n".replace("%d",a+n)}),++n;break;default:}}),s.sort(function(e,t){return t.pos-e.pos}).forEach(function(t){e=e.slice(0,t.pos)+t.str+e.slice(t.pos)}),e},t.getHumanDate=function(e){var t=new Date(e),o=t.getDate()+" "+["January","February","March","April","May","June","July","August","September","October","November","December"][t.getMonth()]+" "+t.getFullYear();return o},t.once=function(e,t,o){e.addEventListener(t,function(n){return n.target.removeEventListener(t,arguments.callee),o(n)})},t.downloadFile=s,t.writeFile=a,t.loadJS=function(e){var t=(0,p.deferred)(),o=window.document.getElementsByTagName("script")[0],n=window.document.createElement("script");return n.src=e,n.async=!0,o.parentNode.insertBefore(n,o),n.onload=function(){t.resolve()},t.promise},t.getCompleteHtml=i,t.saveAsHtml=function(e){var t=(0,l.computeHtml)(e.html,e.htmlMode),o=(0,l.computeCss)(e.css,e.cssMode),n=(0,l.computeJs)(e.js,e.jsMode,!1);Promise.all([t,o,n]).then(function(t){var o=t[0].code,n=t[1].code,a=t[2].code,l=i(o,n,a,e,!0),p=new Date,d=["web-maker",p.getFullYear(),p.getMonth()+1,p.getDate(),p.getHours(),p.getMinutes(),p.getSeconds()].join("-");e.title&&(d=e.title),d+=".html";var c=new Blob([l],{type:"text/html;charset=UTF-8"});s(d,c),(0,r.trackEvent)("fn","saveFileComplete")})},t.handleDownloadsPermission=function(){var e=(0,p.deferred)();return window.IS_EXTENSION?(chrome.permissions.contains({permissions:["downloads"]},function(t){t?e.resolve():chrome.permissions.request({permissions:["downloads"]},function(t){t?((0,r.trackEvent)("fn","downloadsPermGiven"),e.resolve()):e.reject()})}),e.promise):(e.resolve(),e.promise)},t.getFilenameFromUrl=function(e){return e?e.match(/\/([^/]*)$/)[1]:""},t.prettify=function(e){var t=1n?e.classList.add("is-minimized"):e.classList.remove("is-minimized"),-1===e.style[o].indexOf("100% - "+2*k+"px")?e.classList.remove("is-maximized"):e.classList.add("is-maximized")})},50)},t.prototype.toggleCodeWrapCollapse=function(e){if(e.classList.contains("is-minimized")||e.classList.contains("is-maximized"))e.classList.remove("is-minimized"),e.classList.remove("is-maximized"),this.codeSplitInstance.setSizes([33.3,33.3,33.3]);else{var t=parseInt(e.dataset.codeWrapId,10),o=[k+"px",k+"px",k+"px"];o[t]="calc(100% - "+2*k+"px)",this.codeSplitInstance.setSizes(o),e.classList.add("is-maximized")}this.updateSplits()},t.prototype.collapseBtnHandler=function(t){var e=t.currentTarget.parentElement.parentElement.parentElement;this.toggleCodeWrapCollapse(e),(0,m.trackEvent)("ui","paneCollapseBtnClick",e.dataset.type)},t.prototype.codeWrapHeaderDblClickHandler=function(t){if(t.target.classList.contains("js-code-wrap__header")){var e=t.target.parentElement;this.toggleCodeWrapCollapse(e),(0,m.trackEvent)("ui","paneHeaderDblClick",e.dataset.type)}},t.prototype.resetSplitting=function(){this.setState({codeSplitSizes:this.getCodeSplitSizes(),mainSplitSizes:this.getMainSplitSizesToApply()})},t.prototype.updateSplits=function(){this.props.onSplitUpdate(),this.state.codeSplitSizes=this.props.currentItem.sizes,this.state.mainSplitSizes=this.props.currentItem.mainSizes},t.prototype.getMainSplitSizesToApply=function(){var e,t=this.props,o=t.currentItem,n=t.currentLayoutMode;return e=o&&o.mainSizes?3===n?[o.mainSizes[1],o.mainSizes[0]]:o.mainSizes:5===n?[75,25]:[50,50],e},t.prototype.getCodeSplitSizes=function(){return this.props.currentItem&&this.props.currentItem.sizes?this.props.currentItem.sizes:[33.33,33.33,33.33]},t.prototype.mainSplitDragEndHandler=function(){var e=this;this.props.prefs.refreshOnResize&&setTimeout(function(){e.setPreviewContent(!0)},1),this.updateSplits()},t.prototype.codeSplitDragStart=function(){document.body.classList.add("is-dragging")},t.prototype.codeSplitDragEnd=function(){this.updateCodeWrapCollapseStates(),document.body.classList.remove("is-dragging"),this.updateSplits()},t.prototype.handleModeRequirements=function(e){function t(){c.modes[e].hasLoaded=!0,n.resolve()}var o="lib/transpilers",n=(0,y.deferred)();return c.modes[e].hasLoaded?(n.resolve(),n.promise):(e===c.HtmlModes.JADE?(0,h.loadJS)(o+"/jade.js").then(t):e===c.HtmlModes.MARKDOWN?(0,h.loadJS)(o+"/marked.js").then(t):e===c.CssModes.LESS?(0,h.loadJS)(o+"/less.min.js").then(t):e===c.CssModes.SCSS||e===c.CssModes.SASS?(0,h.loadJS)(o+"/sass.js").then(function(){window.sass=new Sass(o+"/sass.worker.js"),t()}):e===c.CssModes.STYLUS?(0,h.loadJS)(o+"/stylus.min.js").then(t):e===c.CssModes.ACSS?(0,h.loadJS)(o+"/atomizer.browser.js").then(t):e===c.JsModes.COFFEESCRIPT?(0,h.loadJS)(o+"/coffee-script.js").then(t):e===c.JsModes.ES6?(0,h.loadJS)(o+"/babel.min.js").then(t):e===c.JsModes.TS?(0,h.loadJS)(o+"/typescript.js").then(t):n.resolve(),n.promise)},t.prototype.updateHtmlMode=function(e){return this.props.onCodeModeChange("html",e),this.props.currentItem.htmlMode=e,this.cm.html.setOption("mode",c.modes[e].cmMode),g.default.autoLoadMode(this.cm.html,c.modes[e].cmPath||c.modes[e].cmMode),this.handleModeRequirements(e)},t.prototype.updateCssMode=function(e){return this.props.onCodeModeChange("css",e),this.props.currentItem.cssMode=e,this.cm.css.setOption("mode",c.modes[e].cmMode),this.cm.css.setOption("readOnly",c.modes[e].cmDisable),window.cssSettingsBtn.classList[c.modes[e].hasSettings?"remove":"add"]("hide"),g.default.autoLoadMode(this.cm.css,c.modes[e].cmPath||c.modes[e].cmMode),this.handleModeRequirements(e)},t.prototype.updateJsMode=function(e){return this.props.onCodeModeChange("js",e),this.props.currentItem.jsMode=e,this.cm.js.setOption("mode",c.modes[e].cmMode),g.default.autoLoadMode(this.cm.js,c.modes[e].cmPath||c.modes[e].cmMode),this.handleModeRequirements(e)},t.prototype.codeModeChangeHandler=function(t){var e=this,o=t.target.value,n=t.target.dataset.type,s=this.props.currentItem["html"===n?"htmlMode":"css"===n?"cssMode":"jsMode"];s!==o&&("html"===n?this.updateHtmlMode(o).then(function(){return e.setPreviewContent(!0)}):"js"===n?this.updateJsMode(o).then(function(){return e.setPreviewContent(!0)}):"css"===n&&this.updateCssMode(o).then(function(){return e.setPreviewContent(!0)}),(0,m.trackEvent)("ui","updateCodeMode",o))},t.prototype.detachPreview=function(){var e=this;if(this.detachedWindow)return void this.detachedWindow.focus();var t=this.frame.getBoundingClientRect(),o=t.width,n=t.height;document.body.classList.add("is-detached-mode"),this.detachedWindow=window.open("./preview.html","Web Maker","width="+o+",height="+n+",resizable,scrollbars=yes,status=1"),setTimeout(function(){e.setPreviewContent(!0)},1500);var s=window.setInterval(function(){e.detachedWindow&&e.detachedWindow.closed&&(clearInterval(s),document.body.classList.remove("is-detached-mode"),e.detachedWindow=null,e.setPreviewContent(!0))},500)},t.prototype.updateLogCount=function(){window.logCountEl&&(logCountEl.textContent=this.logCount)},t.prototype.onMessageFromConsole=function(){var e=this;[].concat(Array.prototype.slice.call(arguments)).forEach(function(t){t&&t.indexOf&&-1!==t.indexOf("filesystem:chrome-extension")&&(t=t.replace(/filesystem:chrome-extension.*\.js:(\d+):*(\d*)/g,"script $1:$2"));try{e.consoleCm.replaceRange(t+" "+((t+"").match(/\[object \w+]/)?JSON.stringify(t):"")+"\n",{line:Infinity})}catch(t){e.consoleCm.replaceRange("\uD83C\uDF00\n",{line:Infinity})}e.consoleCm.scrollTo(0,Infinity),e.logCount++}),this.updateLogCount()},t.prototype.previewException=function(e){console.error("Possible infinite loop detected.",e.stack),this.onMessageFromConsole("Possible infinite loop detected.",e.stack)},t.prototype.toggleConsole=function(){this.setState({isConsoleOpen:!this.state.isConsoleOpen}),(0,m.trackEvent)("ui","consoleToggle")},t.prototype.consoleHeaderDblClickHandler=function(t){t.target.classList.contains("js-console__header")&&((0,m.trackEvent)("ui","consoleToggleDblClick"),this.toggleConsole())},t.prototype.clearConsole=function(){this.consoleCm.setValue(""),this.logCount=0,this.updateLogCount()},t.prototype.clearConsoleBtnClickHandler=function(){this.clearConsole(),(0,m.trackEvent)("ui","consoleClearBtnClick")},t.prototype.evalConsoleExpr=function(t){(76===t.which||12===t.which)&&t.ctrlKey?(this.clearConsole(),(0,m.trackEvent)("ui","consoleClearKeyboardShortcut")):13===t.which&&(this.onMessageFromConsole("> "+t.target.value),this.frame.contentWindow._wmEvaluate(t.target.value),t.target.value="",(0,m.trackEvent)("fn","evalConsoleExpr"))},t.prototype.cssSettingsBtnClickHandler=function(){this.setState({isCssSettingsModalOpen:!0}),(0,m.trackEvent)("ui","cssSettingsBtnClick")},t.prototype.cssSettingsChangeHandler=function(e){this.props.onCodeSettingsChange("css",e),this.setPreviewContent(!0)},t.prototype.getDemoFrame=function(e){e(this.frame)},t.prototype.editorFocusHandler=function(e){this.props.onEditorFocus(e)},t.prototype.render=function(){var e=this;return(0,r.h)(u.SplitPane,{class:"content-wrap flex flex-grow",sizes:this.state.mainSplitSizes,minSize:150,style:"",direction:2===this.props.currentLayoutMode?"vertical":"horizontal",onDragEnd:this.mainSplitDragEndHandler.bind(this)},(0,r.h)(u.SplitPane,{class:"code-side",id:"js-code-side",sizes:this.state.codeSplitSizes,minSize:k,direction:2===this.props.currentLayoutMode||5===this.props.currentLayoutMode?"horizontal":"vertical",onDragStart:this.codeSplitDragStart.bind(this),onDragEnd:this.codeSplitDragEnd.bind(this),onSplit:function(t){return e.codeSplitInstance=t}},(0,r.h)("div",{"data-code-wrap-id":"0",id:"htmlCodeEl","data-type":"html",class:"code-wrap",onTransitionEnd:this.updateCodeWrapCollapseStates.bind(this)},(0,r.h)("div",{class:"js-code-wrap__header code-wrap__header",title:"Double click to toggle code pane",onDblClick:this.codeWrapHeaderDblClickHandler.bind(this)},(0,r.h)("label",{class:"btn-group",dropdow:!0,title:"Click to change"},(0,r.h)("span",{class:"code-wrap__header-label"},c.modes[this.props.currentItem.htmlMode||"html"].label),S,(0,r.h)("select",{"data-type":"html",class:"js-mode-select hidden-select",onChange:this.codeModeChangeHandler.bind(this),value:this.props.currentItem.htmlMode},w,M,_)),(0,r.h)("div",{class:"code-wrap__header-right-options"},(0,r.h)("a",{class:"js-code-collapse-btn code-wrap__header-btn code-wrap__collapse-btn",title:"Toggle code pane",onClick:this.collapseBtnHandler.bind(this)}))),(0,r.h)(d.default,{options:{mode:"htmlmixed",profile:"xhtml",gutters:["CodeMirror-linenumbers","CodeMirror-foldgutter"],noAutocomplete:!0,matchTags:{bothTags:!0},prettier:!0,prettierParser:"html",emmet:!0},prefs:this.props.prefs,onChange:this.onHtmlCodeChange.bind(this),onCreation:function(t){return e.cm.html=t},onFocus:this.editorFocusHandler.bind(this)})),(0,r.h)("div",{"data-code-wrap-id":"1",id:"cssCodeEl","data-type":"css",class:"code-wrap",onTransitionEnd:this.updateCodeWrapCollapseStates.bind(this)},(0,r.h)("div",{class:"js-code-wrap__header code-wrap__header",title:"Double click to toggle code pane",onDblClick:this.codeWrapHeaderDblClickHandler.bind(this)},(0,r.h)("label",{class:"btn-group",title:"Click to change"},(0,r.h)("span",{class:"code-wrap__header-label"},c.modes[this.props.currentItem.cssMode||"css"].label),x,(0,r.h)("select",{"data-type":"css",class:"js-mode-select hidden-select",onChange:this.codeModeChangeHandler.bind(this),value:this.props.currentItem.cssMode},H,I,L,j,E,A)),(0,r.h)("div",{class:"code-wrap__header-right-options"},(0,r.h)("a",{href:"#",id:"cssSettingsBtn",title:"Atomic CSS configuration",onClick:this.cssSettingsBtnClickHandler.bind(this),class:"code-wrap__header-btn hide"},B),(0,r.h)("a",{class:"js-code-collapse-btn code-wrap__header-btn code-wrap__collapse-btn",title:"Toggle code pane",onClick:this.collapseBtnHandler.bind(this)}))),(0,r.h)(d.default,{options:{mode:"css",gutters:["error-gutter","CodeMirror-linenumbers","CodeMirror-foldgutter"],emmet:!0,prettier:!0,prettierParser:"css"},prefs:this.props.prefs,onChange:this.onCssCodeChange.bind(this),onCreation:function(t){return e.cm.css=t},onFocus:this.editorFocusHandler.bind(this)})),(0,r.h)("div",{"data-code-wrap-id":"2",id:"jsCodeEl","data-type":"js",class:"code-wrap",onTransitionEnd:this.updateCodeWrapCollapseStates.bind(this)},(0,r.h)("div",{class:"js-code-wrap__header code-wrap__header",title:"Double click to toggle code pane",onDblClick:this.codeWrapHeaderDblClickHandler.bind(this)},(0,r.h)("label",{class:"btn-group",title:"Click to change"},(0,r.h)("span",{class:"code-wrap__header-label"},c.modes[this.props.currentItem.jsMode||"js"].label),O,(0,r.h)("select",{"data-type":"js",class:"js-mode-select hidden-select",onChange:this.codeModeChangeHandler.bind(this),value:this.props.currentItem.jsMode},T,P,D,V)),(0,r.h)("div",{class:"code-wrap__header-right-options"},(0,r.h)("a",{class:"js-code-collapse-btn code-wrap__header-btn code-wrap__collapse-btn",title:"Toggle code pane",onClick:this.collapseBtnHandler.bind(this)}))),(0,r.h)(d.default,{options:{mode:"javascript",gutters:["error-gutter","CodeMirror-linenumbers","CodeMirror-foldgutter"],prettier:!0,prettierParser:"js"},prefs:this.props.prefs,autoComplete:this.props.prefs.autoComplete,onChange:this.onJsCodeChange.bind(this),onCreation:function(t){return e.cm.js=t},onFocus:this.editorFocusHandler.bind(this)}))),(0,r.h)("div",{class:"demo-side",id:"js-demo-side",style:""},(0,r.h)("iframe",{ref:function(t){return e.frame=t},src:"about://blank",frameborder:"0",id:"demo-frame",allowfullscreen:!0}),(0,r.h)(b.Console,{isConsoleOpen:this.state.isConsoleOpen,onConsoleHeaderDblClick:this.consoleHeaderDblClickHandler.bind(this),onClearConsoleBtnClick:this.clearConsoleBtnClickHandler.bind(this),toggleConsole:this.toggleConsole.bind(this),onEvalInputKeyup:this.evalConsoleExpr.bind(this),onReady:function(t){return e.consoleCm=t}}),(0,r.h)(C.default,{show:this.state.isCssSettingsModalOpen,closeHandler:function(){return e.setState({isCssSettingsModalOpen:!1})},onChange:this.cssSettingsChangeHandler.bind(this),settings:this.props.currentItem.cssSettings,editorTheme:this.props.prefs.editorTheme})))},t}(r.Component);t.default=F},"9VU0":function(e,t,o){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t&&("object"==typeof t||"function"==typeof t)?t:e}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0,t.LibraryAutoSuggest=void 0;var i=function(){function e(e,t){for(var o,n=0;n"+t[o].name+"";e.isShowingSuggestions=!0,e.textareaBounds||(e.textareaBounds=e.t.getBoundingClientRect(),e.list.style.top=e.textareaBounds.bottom+"px",e.list.style.left=e.textareaBounds.left+"px",e.list.style.width=e.textareaBounds.width+"px"),e.list.classList.add("is-open")})},500)}},t.prototype.onKeyDown=function(e){var t;this.isShowingSuggestions&&(27===e.keyCode&&(this.closeSuggestions(),e.stopPropagation()),40===e.keyCode&&this.isShowingSuggestions?(t=this.list.querySelector(".selected"),t?(t.classList.remove("selected"),t.nextElementSibling.classList.add("selected")):this.list.querySelector("li:first-child").classList.add("selected"),this.list.querySelector(".selected").scrollIntoView(!1),e.preventDefault()):38===e.keyCode&&this.isShowingSuggestions?(t=this.list.querySelector(".selected"),t?(t.classList.remove("selected"),t.previousElementSibling.classList.add("selected")):this.list.querySelector("li:first-child").classList.add("selected"),this.list.querySelector(".selected").scrollIntoView(!1),e.preventDefault()):13===e.keyCode&&this.isShowingSuggestions&&(t=this.list.querySelector(".selected"),this.selectSuggestion(t.dataset.url),this.closeSuggestions()))},t.prototype.listMouseDownHandler=function(e){var t=e.target;t.parentElement.dataset.url&&this.selectSuggestion(t.parentElement.dataset.url)},t.prototype.selectSuggestion=function(e){this.t.focus(),(0,l.trackEvent)("ui","autoSuggestionLibSelected",e),this.selectedCallback?this.selectedCallback.call(null,e):this.replaceCurrentLine(e),this.closeSuggestions()},t.prototype.render=function(){var e=this;return(0,r.h)("div",{class:"btn-group "+(this.props.fullWidth?"flex-grow":""),ref:function(t){return e.wrap=t}},this.props.children,(0,r.h)("ul",{ref:function(t){return e.list=t},class:"dropdown__menu autocomplete-dropdown",onMouseDown:this.listMouseDownHandler.bind(this)}),(0,r.h)("div",{ref:function(t){return e.loader=t},class:"loader autocomplete__loader",style:"display:none"}))},i(t,[{key:"currentLineNumber",get:function(){return this.t.value.substr(0,this.t.selectionStart).split("\n").length}},{key:"currentLine",get:function(){var e=this.currentLineNumber;return this.t.value.split("\n")[e-1]}}]),t}(r.Component)},BcU7:function(e,t,o){"use strict";function n(e){return function(){var t=e.apply(this,arguments);return new Promise(function(e,o){function n(s,a){try{var i=t[s](a),r=i.value}catch(e){return void o(e)}return i.done?void e(r):Promise.resolve(r).then(function(e){n("next",e)},function(e){n("throw",e)})}return n("next")})}}var s=Object.assign||function(e){for(var t,o=1;o+l&&(a=Math.floor((r-l)/1e3/3600/24)),i.setState({daysLeft:a}),i}return a(t,e),t.prototype.render=function(){var e=this.props.codeSize?(this.props.codeSize/1024).toFixed(2):0;return(0,i.h)("div",{role:"button",class:"flex flex-v-center",tabIndex:"0",onClick:this.props.onClick,onBlur:this.props.onBlur},l," ",(0,i.h)("div",{class:"footer__js13k-days-left"},this.state.daysLeft," days to go"),(0,i.h)("div",{class:"footer__js13k-code-size",style:{color:10Hello, World!
\"}"})),ie=function(e){function t(){a(this,t);var o=i(this,e.call(this));return o.AUTO_SAVE_INTERVAL=15000,o.modalDefaultStates={isModalOpen:!1,isAddLibraryModalOpen:!1,isSettingsModalOpen:!1,isHelpModalOpen:!1,isNotificationsModalOpen:!1,isLoginModalOpen:!1,isProfileModalOpen:!1,isSupportDeveloperModalOpen:!1,isKeyboardShortcutsModalOpen:!1,isAskToImportModalOpen:!1,isOnboardModalOpen:!1,isJs13KModalOpen:!1,isCreateNewModalOpen:!1},o.state=l({isSavedItemPaneOpen:!1},o.modalDefaultStates,{prefs:{},currentItem:{title:"",externalLibs:{js:"",css:""}}}),o.defaultSettings={preserveLastCode:!0,replaceNewTab:!1,htmlMode:"html",jsMode:"js",cssMode:"css",isCodeBlastOn:!1,indentWith:"spaces",indentSize:2,editorTheme:"monokai",keymap:"sublime",fontSize:16,refreshOnResize:!1,autoPreview:!0,editorFont:"FiraCode",editorCustomFont:"",autoSave:!0,autoComplete:!0,preserveConsoleLogs:!0,lightVersion:!1,lineWrap:!0,infiniteLoopTimeout:1e3,layoutMode:2,isJs13kModeOn:!1,autoCloseTags:!0},o.prefs={},O.default.auth().onAuthStateChanged(function(e){o.setState({isLoginModalOpen:!1}),e?((0,M.log)("You are -> ",e),A.alertsService.add("You are now logged in!"),o.setState({user:e}),window.user=e,!window.localStorage[Q.ASKED_TO_IMPORT_CREATIONS]&&o.fetchItems(!1,!0).then(function(e){e.length&&(o.oldSavedItems=e,o.oldSavedCreationsCount=e.length,o.setState({isAskToImportModalOpen:!0}),(0,j.trackEvent)("ui","askToImportModalSeen"))}),window.db.getUser(e.uid).then(function(t){if(t){var n=l({},o.state.prefs);l(n,e.settings),o.setState({prefs:n}),o.updateSetting()}})):(o.setState({user:void 0}),delete window.user),o.updateProfileUi()}),o}return r(t,e),t.prototype.componentWillMount=function(){var e,t=this;window.onunload=function(){t.saveCode("code"),t.detachedWindow&&t.detachedWindow.close()},db.local.get({layoutMode:1,code:""},function(o){t.toggleLayout(o.layoutMode),t.state.prefs.layoutMode=o.layoutMode,o.code&&(e=o.code)}),db.getSettings(this.defaultSettings).then(function(o){o.preserveLastCode&&e?(t.setState({unsavedEditCount:0}),e.id&&window.IS_EXTENSION?db.local.get(e.id,function(o){o[e.id]&&((0,M.log)("Load item ",e.id),t.setCurrentItem(o[e.id]).then(function(){return t.refreshEditor()}))}):((0,M.log)("Load last unsaved item",e),t.setCurrentItem(e).then(function(){return t.refreshEditor()}))):t.createNewItem(),l(t.state.prefs,o),t.setState({prefs:t.state.prefs}),t.updateSetting()}),db.getUserLastSeenVersion().then(function(e){e||(t.setState({isOnboardModalOpen:!0}),-1===document.cookie.indexOf("onboarded")&&((0,j.trackEvent)("ui","onboardModalSeen",ee),document.cookie="onboarded=1"),window.db.setUserLastSeenVersion(ee)),e&&-1===(0,M.semverCompare)(e,ee)&&!window.localStorage.pledgeModalSeen&&(t.openSupportDeveloperModal(),window.localStorage.pledgeModalSeen=!0),e&&-1!==(0,M.semverCompare)(e,ee)||(t.setState({hasUnseenChangelog:!0}),t.hasSeenNotifications=!1)})},t.prototype.updateProfileUi=function(){this.state.user?document.body.classList.add("is-logged-in"):document.body.classList.remove("is-logged-in")},t.prototype.refreshEditor=function(){this.toggleLayout(this.state.currentItem.layoutMode||this.state.prefs.layoutMode),this.updateExternalLibCount(),this.contentWrap.refreshEditor()},t.prototype.forkItem=function(e){var t=this;if(this.state.unsavedEditCount){var o=confirm("You have unsaved changes in your current work. Do you want to discard unsaved changes and continue?");if(!o)return}var n=JSON.parse(JSON.stringify(e));delete n.id,n.title="(Forked) "+e.title,n.updatedOn=Date.now(),this.setCurrentItem(n).then(function(){return t.refreshEditor()}),A.alertsService.add("\""+e.title+"\" was forked"),(0,j.trackEvent)("fn","itemForked")},t.prototype.createNewItem=function(){var e=this,t=new Date;this.setCurrentItem({title:"Untitled "+t.getDate()+"-"+(t.getMonth()+1)+"-"+t.getHours()+":"+t.getMinutes(),html:"",css:"",js:"",externalLibs:{js:"",css:""},layoutMode:this.state.currentLayoutMode}).then(function(){return e.refreshEditor()}),A.alertsService.add("New item created")},t.prototype.openItem=function(e){var t=this;this.setCurrentItem(e).then(function(){return t.refreshEditor()}),A.alertsService.add("Saved item loaded")},t.prototype.removeItem=function(e){var t=this,o=confirm("Are you sure you want to delete \""+e.title+"\"?");o&&(_.itemService.unsetItemForUser(e.id),_.itemService.removeItem(e.id).then(function(){A.alertsService.add("Item removed.",e),t.state.currentItem.id===e.id&&t.createNewItem()}),delete this.state.savedItems[e.id],this.setState({savedItems:l({},this.state.savedItems)}),(0,j.trackEvent)("fn","itemRemoved"))},t.prototype.setCurrentItem=function(e){var t=(0,E.deferred)();return e.htmlMode=e.htmlMode||this.state.prefs.htmlMode||L.HtmlModes.HTML,e.cssMode=e.cssMode||this.state.prefs.cssMode||L.CssModes.CSS,e.jsMode=e.jsMode||this.state.prefs.jsMode||L.JsModes.JS,this.setState({currentItem:e},t.resolve),this.isAutoSavingEnabled=!1,this.setState({unsavedEditCount:0}),t.promise},t.prototype.saveBtnClickHandler=function(){(0,j.trackEvent)("ui","saveBtnClick",this.state.currentItem.id?"saved":"new"),this.saveItem()},t.prototype.populateItemsInSavedPane=function(){this.setState({savedItems:l({},this.state.savedItems)}),this.toggleSavedItemsPane()},t.prototype.toggleSavedItemsPane=function(){this.setState({isSavedItemPaneOpen:!this.state.isSavedItemPaneOpen}),this.state.isSavedItemPaneOpen?window.searchInput.focus():window.searchInput.value="",document.body.classList[this.state.isSavedItemPaneOpen?"add":"remove"]("overlay-visible")},t.prototype.fetchItems=function(){var e=s(function*(e,t){var o=this,n=(0,E.deferred)();this.state.savedItems={};var s=[];return window.user&&!t?(s=yield _.itemService.getAllItems(),(0,M.log)("got items"),e&&s.forEach(function(e){o.state.savedItems[e.id]=e}),n.resolve(s),n.promise):(db.local.get("items",function(t){var a=Object.getOwnPropertyNames(t.items||{});a.length||n.resolve([]),(0,j.trackEvent)("fn","fetchItems",a.length);for(var r=function(t){db.local.get(a[t],function(i){e&&(o.state.savedItems[a[t]]=i[a[t]]),s.push(i[a[t]]),a.length===s.length&&n.resolve(s)})},l=0;lwindow.innerWidth?2:e,this.state.currentLayoutMode===e?(this.contentWrap.resetSplitting(),void this.setState({currentLayoutMode:e})):void([1,2,3,4,5].forEach(function(e){window["layoutBtn"+e].classList.remove("selected"),document.body.classList.remove("layout-"+e)}),$("#layoutBtn"+e).classList.add("selected"),document.body.classList.add("layout-"+e),this.setState({currentLayoutMode:e},function(){t.contentWrap.resetSplitting(),t.contentWrap.setPreviewContent(!0)}))},t.prototype.layoutBtnClickHandler=function(e){this.saveSetting("layoutMode",e),(0,j.trackEvent)("ui","toggleLayoutClick",e),this.toggleLayout(e)},t.prototype.getCodePaneSizes=function(){var e,t=this.state.currentLayoutMode,o=2===t||5===t?"width":"height";try{e=[htmlCodeEl.style[o],cssCodeEl.style[o],jsCodeEl.style[o]]}catch(t){e=[33.33,33.33,33.33]}finally{return e}},t.prototype.getMainPaneSizes=function(){var e,t=this.state.currentLayoutMode,o=2===t?"height":"width";try{e=[+$("#js-code-side").style[o].match(/([\d.]+)%/)[1],+$("#js-demo-side").style[o].match(/([\d.]+)%/)[1]]}catch(t){e=[50,50]}finally{return e}},t.prototype.saveSetting=function(e,t){var o,n=(0,E.deferred)(),s=(o={},o[e]=t,o);return db.local.set(s,n.resolve),n.promise},t.prototype.saveCode=function(e){return this.state.currentItem.updatedOn=Date.now(),this.state.currentItem.layoutMode=this.state.currentLayoutMode,this.state.currentItem.sizes=this.getCodePaneSizes(),this.state.currentItem.mainSizes=this.getMainPaneSizes(),(0,M.log)("saving key",e||this.state.currentItem.id,this.state.currentItem),_.itemService.setItem(e||this.state.currentItem.id,this.state.currentItem).then(function(){window.user&&!navigator.onLine?A.alertsService.add("Item saved locally. Will save to account when you are online."):A.alertsService.add("Item saved."),this.setState({unsavedEditCount:0})}.bind(this))},t.prototype.saveItem=function(){var e=this;if(!window.user&&!window.localStorage[Q.LOGIN_AND_SAVE_MESSAGE_SEEN]){var t=confirm("Saving without signing in will save your work only on this machine and this browser. If you want it to be secure & available anywhere, please login in your account and then save.\n\nDo you still want to continue saving locally?");if(window.localStorage[Q.LOGIN_AND_SAVE_MESSAGE_SEEN]=!0,!t)return(0,j.trackEvent)("ui",Q.LOGIN_AND_SAVE_MESSAGE_SEEN,"login"),this.closeAllOverlays(),void this.setState({isLoginModalOpen:!0});(0,j.trackEvent)("ui",Q.LOGIN_AND_SAVE_MESSAGE_SEEN,"local")}var o=!this.state.currentItem.id;this.state.currentItem.id=this.state.currentItem.id||"item-"+(0,M.generateRandomId)(),this.setState({isSaving:!0}),this.saveCode().then(function(){e.setState({isSaving:!1}),!e.isAutoSavingEnabled&&e.state.prefs.autoSave&&(e.isAutoSavingEnabled=!0,A.alertsService.add("Auto-save enabled."))}),o&&_.itemService.setItemForUser(this.state.currentItem.id)},t.prototype.onCodeModeChange=function(e,t){var o=l({},this.state.currentItem);o[e+"Mode"]=t,this.setState({currentItem:o})},t.prototype.onCodeChange=function(e,t,o){var n=this;this.state.currentItem[e]=t,o&&(this.setState({unsavedEditCount:this.state.unsavedEditCount+1}),0==this.state.unsavedEditCount%X&&this.state.unsavedEditCount>=X&&(window.saveBtn.classList.add("animated"),window.saveBtn.classList.add("wobble"),window.saveBtn.addEventListener("animationend",function(){window.saveBtn.classList.remove("animated"),window.saveBtn.classList.remove("wobble")}))),this.state.prefs.isJs13kModeOn&&(this.codeSizeCalculationTimeout&&clearTimeout(this.codeSizeCalculationTimeout),this.codeSizeCalculationTimeout=setTimeout(function(){n.calculateCodeSize(),n.codeSizeCalculationTimeout=null},1e3))},t.prototype.onCodeSettingsChange=function(e,t){this.state.currentItem[e+"Settings"]={acssConfig:t}},t.prototype.titleInputBlurHandler=function(t){this.state.currentItem.title=t.target.value,this.state.currentItem.id&&(this.saveItem(),(0,j.trackEvent)("ui","titleChanged"))},t.prototype.updateSetting=function(t){var e=this;if(t){var o=t.target.dataset.setting,n={},s=t.target;(0,M.log)(o,"checkbox"===s.type?s.checked:s.value);var a=l({},this.state.prefs);a[o]="checkbox"===s.type?s.checked:s.value,n[o]=a[o],this.setState({prefs:a}),db.sync.set(n,function(){A.alertsService.add("Setting saved")}),window.user&&window.db.getDb().then(function(t){var n;t.collection("users").doc(window.user.uid).update((n={},n["settings."+o]=e.state.prefs[o],n)).then(function(e){(0,M.log)("Setting \""+o+"\" for user",e)}).catch(function(e){return(0,M.log)(e)})}),(0,j.trackEvent)("ui","updatePref-"+o,a[o])}var i=this.state.prefs;runBtn.classList[i.autoPreview?"add":"remove"]("hide"),this.contentWrap.applyCodemirrorSettings(this.state.prefs),i.autoSave?!this.autoSaveInterval&&(this.autoSaveInterval=setInterval(function(){e.autoSaveLoop()},this.AUTO_SAVE_INTERVAL)):(clearInterval(this.autoSaveInterval),this.autoSaveInterval=null),document.body.classList[i.lightVersion?"add":"remove"]("light-version")},t.prototype.autoSaveLoop=function(){this.isAutoSavingEnabled&&this.state.unsavedEditCount&&this.saveItem()},t.prototype.loginBtnClickHandler=function(){this.setState({isLoginModalOpen:!0})},t.prototype.profileBtnClickHandler=function(){this.setState({isProfileModalOpen:!0})},t.prototype.logout=function(){if(this.state.unsavedEditCount){var e=confirm("You have unsaved changes. Do you still want to logout?");if(!e)return}(0,j.trackEvent)("fn","loggedOut"),P.auth.logout(),this.setState({isProfileModalOpen:!1}),A.alertsService.add("Log out successfull")},t.prototype.itemClickHandler=function(e){var t=this;setTimeout(function(){t.openItem(e)},350),this.toggleSavedItemsPane()},t.prototype.itemRemoveBtnClickHandler=function(e){this.removeItem(e)},t.prototype.itemForkBtnClickHandler=function(e){var t=this;this.toggleSavedItemsPane(),setTimeout(function(){t.forkItem(e)},350)},t.prototype.newBtnClickHandler=function(){if((0,j.trackEvent)("ui","newBtnClick"),this.state.unsavedEditCount){var e=confirm("You have unsaved changes. Do you still want to create something new?");e&&this.setState({isCreateNewModalOpen:!0})}else this.setState({isCreateNewModalOpen:!0})},t.prototype.openBtnClickHandler=function(){(0,j.trackEvent)("ui","openBtnClick"),this.openSavedItemsPane()},t.prototype.detachedPreviewBtnHandler=function(){(0,j.trackEvent)("ui","detachPreviewBtnClick"),this.contentWrap.detachPreview()},t.prototype.notificationsBtnClickHandler=function(){return this.setState({isNotificationsModalOpen:!0}),this.state.isNotificationsModalOpen&&!this.hasSeenNotifications&&(this.hasSeenNotifications=!0,this.setState({hasUnseenChangelog:!1}),window.db.setUserLastSeenVersion(ee)),(0,j.trackEvent)("ui","notificationButtonClick",ee),!1},t.prototype.codepenBtnClickHandler=function(t){if(this.state.currentItem.cssMode===L.CssModes.ACSS)return alert("Oops! CodePen doesn't supports Atomic CSS currently. \nHere is something you can still do -> https://medium.com/web-maker/sharing-your-atomic-css-work-on-codepen-a402001b26ab"),void t.preventDefault();var e={title:"A Web Maker experiment",html:this.state.currentItem.html,css:this.state.currentItem.css,js:this.state.currentItem.js,html_pre_processor:L.modes[this.state.currentItem.htmlMode].codepenVal,css_pre_processor:L.modes[this.state.currentItem.cssMode].codepenVal,js_pre_processor:L.modes[this.state.currentItem.jsMode].codepenVal,css_external:this.state.currentItem.externalLibs.css.split("\n").join(";"),js_external:this.state.currentItem.externalLibs.js.split("\n").join(";")};this.state.currentItem.title.match(/Untitled\s\d\d*-\d/)||(e.title=this.state.currentItem.title),e=JSON.stringify(e),window.codepenForm.querySelector("input").value=e,window.codepenForm.submit(),(0,j.trackEvent)("ui","openInCodepen"),t.preventDefault()},t.prototype.saveHtmlBtnClickHandler=function(t){(0,M.saveAsHtml)(this.state.currentItem),(0,j.trackEvent)("ui","saveHtmlClick"),t.preventDefault()},t.prototype.runBtnClickHandler=function(){this.contentWrap.setPreviewContent(!0,!0),(0,j.trackEvent)("ui","runBtnClick")},t.prototype.exportItems=function(){var e=this;(0,M.handleDownloadsPermission)().then(function(){e.fetchItems().then(function(e){var t=new Date,o=["web-maker-export",t.getFullYear(),t.getMonth()+1,t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds()].join("-");o+=".json";var n=new Blob([JSON.stringify(e,!1,2)],{type:"application/json;charset=UTF-8"});(0,M.downloadFile)(o,n),(0,j.trackEvent)("fn","exportItems")})})},t.prototype.exportBtnClickHandler=function(t){this.exportItems(),t.preventDefault(),(0,j.trackEvent)("ui","exportBtnClicked")},t.prototype.screenshotBtnClickHandler=function(t){this.contentWrap.getDemoFrame(function(e){(0,F.takeScreenshot)(e.getBoundingClientRect())}),t.preventDefault()},t.prototype.openSupportDeveloperModal=function(){this.closeAllOverlays(),this.setState({isSupportDeveloperModalOpen:!0})},t.prototype.supportDeveloperBtnClickHandler=function(t){this.openSupportDeveloperModal(t)},t.prototype.dontAskToImportAnymore=function(t){this.setState({isAskToImportModalOpen:!1}),window.localStorage[Q.ASKED_TO_IMPORT_CREATIONS]=!0,t&&(0,j.trackEvent)("ui","dontAskToImportBtnClick")},t.prototype.importCreationsAndSettingsIntoApp=function(){var e=this;this.mergeImportedItems(this.oldSavedItems).then(function(){(0,j.trackEvent)("fn","oldItemsImported"),e.dontAskToImportAnymore()})},t.prototype.editorFocusHandler=function(e){this.editorWithFocus=e},t.prototype.modalOverlayClickHandler=function(){this.closeAllOverlays()},t.prototype.splitUpdateHandler=function(){this.state.currentItem.sizes=this.getCodePaneSizes(),this.state.currentItem.mainSizes=this.getMainPaneSizes()},t.prototype.calculateTextSize=function(e){if(!e)return 0;var t=/(\r?\n|\r)/g,o=/(\r?\n|\r|\s+)/g;return{count:function(e,n){n=n||{},n.lineBreaks=n.lineBreaks||1,n.ignoreWhitespace=n.ignoreWhitespace||!1;var s=e.length,a=s-e.replace(/[\u0100-\uFFFF]/g,"").length,i=s-e.replace(t,"").length;return n.ignoreWhitespace?(e=e.replace(o,""),e.length+a):s+a+Math.max(0,n.lineBreaks*(i-1))},format:function(e,t){for(var o=0;1024"+e+"")+" "+o+"B"}}.count(e)},t.prototype.getExternalLibCode=function(){var e=this.state.currentItem,t=e.externalLibs&&e.externalLibs.js||"";return t+="\n"+e.externalLibs&&e.externalLibs.css||"",t=t.split("\n").filter(function(e){return e}),t.map(function(e){return fetch(e).then(function(e){return e.text()}).then(function(t){return{code:t,fileName:(0,M.getFilenameFromUrl)(e)}})})},t.prototype.calculateCodeSize=function(){var e=this,t=this.state.currentItem,o=(0,w.computeHtml)(t.html,t.htmlMode),n=(0,w.computeCss)(t.css,t.cssMode),s=(0,w.computeJs)(t.js,t.jsMode,!1);Promise.all([o,n,s].concat(this.getExternalLibCode())).then(function(o){var n=o[0].code||"",s=o[1].code||"",a=o[2].code||"",r=(0,M.getCompleteHtml)(n,s,a,t,!0);r=r.replace(/