'use strict';

var yaml$1 = require('@lezer/yaml');
var language = require('@codemirror/language');
var common = require('@lezer/common');
var highlight = require('@lezer/highlight');
var lr = require('@lezer/lr');

// This file was generated by lezer-generator. You probably shouldn't edit it.
const parser = lr.LRParser.deserialize({
  version: 14,
  states: "!vOQOPOOO]OPO'#C_OhOPO'#C^OOOO'#Cc'#CcOpOPO'#CaQOOOOOO{OPOOOOOO'#Cb'#CbO!WOPO'#C`O!`OPO,58xOOOO-E6a-E6aOOOO-E6`-E6`OOOO'#C_'#C_OOOO1G.d1G.d",
  stateData: "!h~OXPOYROWTP~OWVXXRXYRX~OYVOXSP~OXROYROWTX~OXROYROWTP~OYVOXSX~OX[O~OXY~",
  goto: "vWPPX[beioRUOQQOR]XRXQTTOUQWQRZWSSOURYS",
  nodeNames: "⚠ Document Frontmatter DashLine FrontmatterContent Body",
  maxTerm: 10,
  skippedNodes: [0],
  repeatNodeCount: 2,
  tokenData: "$z~RXOYnYZ!^Z]n]^!^^}n}!O!i!O;'Sn;'S;=`!c<%lOn~qXOYnYZ!^Z]n]^!^^;'Sn;'S;=`!c<%l~n~On~~!^~!cOY~~!fP;=`<%ln~!lZOYnYZ!^Z]n]^!^^}n}!O#_!O;'Sn;'S;=`!c<%l~n~On~~!^~#bZOYnYZ!^Z]n]^!^^}n}!O$T!O;'Sn;'S;=`!c<%l~n~On~~!^~$WXOYnYZ$sZ]n]^$s^;'Sn;'S;=`!c<%l~n~On~~$s~$zOX~Y~",
  tokenizers: [0],
  topRules: {"Document":[0,1]},
  tokenPrec: 67
});

/**
A language provider based on the [Lezer YAML
parser](https://github.com/lezer-parser/yaml), extended with
highlighting and indentation information.
*/
const yamlLanguage = language.LRLanguage.define({
    name: "yaml",
    parser: yaml$1.parser.configure({
        props: [
            language.indentNodeProp.add({
                Stream: cx => {
                    for (let before = cx.node.resolve(cx.pos, -1); before && before.to >= cx.pos; before = before.parent) {
                        if (before.name == "BlockLiteralContent" && before.from < before.to)
                            return cx.baseIndentFor(before);
                        if (before.name == "BlockLiteral")
                            return cx.baseIndentFor(before) + cx.unit;
                        if (before.name == "BlockSequence" || before.name == "BlockMapping")
                            return cx.column(before.from, 1);
                        if (before.name == "QuotedLiteral")
                            return null;
                        if (before.name == "Literal") {
                            let col = cx.column(before.from, 1);
                            if (col == cx.lineIndent(before.from, 1))
                                return col; // Start on own line
                            if (before.to > cx.pos)
                                return null;
                        }
                    }
                    return null;
                },
                FlowMapping: language.delimitedIndent({ closing: "}" }),
                FlowSequence: language.delimitedIndent({ closing: "]" }),
            }),
            language.foldNodeProp.add({
                "FlowMapping FlowSequence": language.foldInside,
                "Item Pair BlockLiteral": (node, state) => ({ from: state.doc.lineAt(node.from).to, to: node.to })
            })
        ]
    }),
    languageData: {
        commentTokens: { line: "#" },
        indentOnInput: /^\s*[\]\}]$/,
    }
});
/**
Language support for YAML.
*/
function yaml() {
    return new language.LanguageSupport(yamlLanguage);
}
const frontmatterLanguage = language.LRLanguage.define({
    name: "yaml-frontmatter",
    parser: parser.configure({
        props: [highlight.styleTags({ DashLine: highlight.tags.meta })]
    })
});
/**
Returns language support for a document parsed as `config.content`
with an optional YAML "frontmatter" delimited by lines that
contain three dashes.
*/
function yamlFrontmatter(config) {
    let { language: language$1, support } = config.content instanceof language.LanguageSupport ? config.content
        : { language: config.content, support: [] };
    return new language.LanguageSupport(frontmatterLanguage.configure({
        wrap: common.parseMixed(node => {
            return node.name == "FrontmatterContent" ? { parser: yamlLanguage.parser }
                : node.name == "Body" ? { parser: language$1.parser }
                    : null;
        })
    }), support);
}

exports.yaml = yaml;
exports.yamlFrontmatter = yamlFrontmatter;
exports.yamlLanguage = yamlLanguage;
