"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParsedNgContent = void 0;
const interface_1 = require("./interface");
const SELECT_NAME_VALUE_REGEXP = /^\[slot=["']?([^"']*)["']?\]$/;
class ParsedNgContent {
    constructor(node, parent, index) {
        this.node = node;
        this.parent = parent;
        this.index = index;
        this.kind = interface_1.NgNodeKind.Content;
    }
    getNodeMeta() {
        const nameAttr = this.node.attributes.find((item) => item.name === 'select');
        let value;
        if (nameAttr) {
            const result = nameAttr.value.match(SELECT_NAME_VALUE_REGEXP);
            if (!result) {
                throw new Error(`ng-content未匹配到指定格式的select,value:${nameAttr.value},需要格式为[slot="xxxx"]`);
            }
            value = result[1];
        }
        return {
            kind: interface_1.NgNodeKind.Content,
            name: value,
            index: this.index,
        };
    }
}
exports.ParsedNgContent = ParsedNgContent;
