"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.collectClassesAndIdsFromDocument = exports.extractStylesheets = void 0; const utils_1 = require("@astrojs/compiler/utils"); const language_core_1 = require("@volar/language-core"); function extractStylesheets(snapshot, htmlDocument, ast) { const embeddedCSSCodes = findEmbeddedStyles(snapshot, htmlDocument.roots); const inlineStyles = findInlineStyles(ast); if (inlineStyles.length > 0) { const codes = []; for (const inlineStyle of inlineStyles) { codes.push('x { '); codes.push([ inlineStyle.value, undefined, inlineStyle.position.start.offset + 'style="'.length, { completion: true, verification: false, semantic: true, navigation: true, structure: true, format: false, }, ]); codes.push(' }\n'); } const mappings = (0, language_core_1.buildMappings)(codes); const text = (0, language_core_1.toString)(codes); embeddedCSSCodes.push({ id: 'inline.css', languageId: 'css', snapshot: { getText: (start, end) => text.substring(start, end), getLength: () => text.length, getChangeRange: () => undefined, }, embeddedCodes: [], mappings, }); } return embeddedCSSCodes; } exports.extractStylesheets = extractStylesheets; /** * Find all embedded styles in a document. * Embedded styles are styles that are defined in `