"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasFolding = exports.insideHeading = exports.headingType = void 0;
exports.isHeading = isHeading;
exports.isFoldingHeading = isFoldingHeading;
exports.isFoldedHeading = isFoldedHeading;
exports.isUnfoldedHeading = isUnfoldedHeading;
exports.parseLevel = parseLevel;
const const_1 = require("./const.js");
var HeadingSpecs_1 = require("../../markdown/Heading/HeadingSpecs/index.js");
Object.defineProperty(exports, "headingType", { enumerable: true, get: function () { return HeadingSpecs_1.headingType; } });
const insideHeading = ({ $anchor, $head }) => $anchor.sameParent($head) && isHeading($head.parent);
exports.insideHeading = insideHeading;
const hasFolding = (sel) => (0, exports.insideHeading)(sel) && sel.$head.parent.attrs[const_1.YfmHeadingAttr.Folding] !== null;
exports.hasFolding = hasFolding;
function isHeading(node) {
    return node.type.name === const_1.headingNodeName;
}
function isFoldingHeading(node) {
    return isHeading(node) && typeof node.attrs[const_1.YfmHeadingAttr.Folding] === 'boolean';
}
function isFoldedHeading(node) {
    return isHeading(node) && node.attrs[const_1.YfmHeadingAttr.Folding] === true;
}
function isUnfoldedHeading(node) {
    return isHeading(node) && node.attrs[const_1.YfmHeadingAttr.Folding] === false;
}
function parseLevel(node) {
    return Number.parseInt(node.attrs[const_1.YfmHeadingAttr.Level], 10);
}
//# sourceMappingURL=utils.js.map
