@wistia/kaleidoscope 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/{color-BY2NrNVz.js → color-BgYVUbOQ.js} +3 -3
- package/dist/{color-BY2NrNVz.js.map → color-BgYVUbOQ.js.map} +1 -1
- package/dist/{engine-DeOUPRa0.js → engine-DHDkDPaV.js} +385 -80
- package/dist/engine-DHDkDPaV.js.map +1 -0
- package/dist/entries/color.js +3 -3
- package/dist/entries/engine.js +2 -2
- package/dist/entries/styleRegistry.js +2 -2
- package/dist/entries/validate.js +2 -2
- package/dist/entries/vocabulary.js +3 -3
- package/dist/{getColorLightnessClassification--FSkjXEx.js → getColorLightnessClassification-C6BXD8Da.js} +2 -2
- package/dist/{getColorLightnessClassification--FSkjXEx.js.map → getColorLightnessClassification-C6BXD8Da.js.map} +1 -1
- package/dist/{guards-t_cf_IOV.js → guards-BJfumKYK.js} +2 -2
- package/dist/{guards-t_cf_IOV.js.map → guards-BJfumKYK.js.map} +1 -1
- package/dist/index.js +8 -8
- package/dist/{styleRegistry-CT4jvu4h.js → styleRegistry-Dcho9r3B.js} +31 -31
- package/dist/styleRegistry-Dcho9r3B.js.map +1 -0
- package/dist/{styleVocabulary-DcxbkEvK.js → styleVocabulary-DMhXOr4F.js} +2 -2
- package/dist/{styleVocabulary-DcxbkEvK.js.map → styleVocabulary-DMhXOr4F.js.map} +1 -1
- package/dist/{typography-BA9Pz8Im.js → typography-BLPIIq_8.js} +2 -2
- package/dist/{typography-BA9Pz8Im.js.map → typography-BLPIIq_8.js.map} +1 -1
- package/dist/{validate-D-OR7_3g.js → validate-BkOpEpch.js} +5 -5
- package/dist/{validate-D-OR7_3g.js.map → validate-BkOpEpch.js.map} +1 -1
- package/package.json +2 -2
- package/styles/glass-dark.json +13 -13
- package/styles/glass-light.json +16 -16
- package/dist/engine-DeOUPRa0.js.map +0 -1
- package/dist/styleRegistry-CT4jvu4h.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-D-OR7_3g.js","names":[],"sources":["../src/private/styleDocumentPatterns.ts","../src/validateStyleDocument/issues.ts","../src/validateStyleDocument/anchorValues.ts","../src/validateStyleDocument/anchors.ts","../src/validateStyleDocument/backgroundColor.ts","../src/validateStyleDocument/border.ts","../src/validateStyleDocument/elevation.ts","../src/validateStyleDocument/gradientShape.ts","../src/validateStyleDocument/motion.ts","../src/validateStyleDocument/radius.ts","../src/validateStyleDocument/textColor.ts","../src/validateStyleDocument/texture.ts","../src/validateStyleDocument/surfaces.ts","../src/validateStyleDocument/typography.ts","../src/validateStyleDocument/validateStyleDocument.ts"],"sourcesContent":["// oxlint-disable typescript/no-inferrable-types -- `isolatedDeclarations` (tsconfig.build.json)\n// requires an explicit annotation on every exported const, including ones oxlint considers\n// trivially inferable.\n\nimport { GENERIC_FONT_FAMILIES } from '../styleVocabulary';\n\nexport const ID_PATTERN: RegExp = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n\n/** No dots: brand tokens are not namespaced. */\nexport const TOKEN_PATTERN: RegExp = /^\\$[A-Za-z][A-Za-z0-9]*$/;\n\nconst HEX_COLOR = String.raw`#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})`;\n\n/** One channel or alpha inside an `rgb()`: a number, or a percentage of the channel's range. */\nconst RGB_VALUE = String.raw`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)%?`;\n\n/**\n * Legacy `rgb(41, 73, 229)` and modern `rgb(41 73 229 / 50%)`, each with an optional alpha.\n *\n * Kept in step with `parseColor`, which reads a document's literals at render time: a literal this\n * accepts must be one the parser can read, or validation approves a color that silently falls back.\n * The parser is the more forgiving of the two — it also takes a hex without its `#`, `RGB()` in any\n * case, and separators mixed within one function — so only that direction is guaranteed.\n */\nconst RGB_COLOR = String.raw`rgba?\\(\\s*(?:${RGB_VALUE}\\s*,\\s*${RGB_VALUE}\\s*,\\s*${RGB_VALUE}(?:\\s*,\\s*${RGB_VALUE})?|${RGB_VALUE}\\s+${RGB_VALUE}\\s+${RGB_VALUE}(?:\\s*/\\s*${RGB_VALUE})?)\\s*\\)`;\n\nexport const LITERAL_COLOR_PATTERN: RegExp = new RegExp(\n String.raw`^(?:${HEX_COLOR}|${RGB_COLOR})$`,\n);\n\nconst NOT_IN_QUOTED_FAMILY = String.raw`$;{}()<>\\\\`;\n\n/** A comma delineates font families, but inside quotes it should be considered part of the name. */\nconst NOT_IN_FAMILY = `,${NOT_IN_QUOTED_FAMILY}`;\n\n/**\n * One family in a list, where each item is delineated by a comma.\n * No `$`, parentheses, braces, angle brackets, backslashes or semicolons allowed in the family\n * names. Any quotes must have a matching end quote.\n */\nconst FONT_FAMILY = [\n String.raw`\"[^\"${NOT_IN_QUOTED_FAMILY}]+\"`, // \"Segoe UI\", and may hold the other quote: \"Foo's Text\"\n String.raw`'[^'${NOT_IN_QUOTED_FAMILY}]+'`, // 'Fraunces', or with a comma: 'ACME, Inc'\n // Ends on a non-space so trailing spaces only match the separator\n String.raw`[^\\s\"'${NOT_IN_FAMILY}](?:[^\"'${NOT_IN_FAMILY}]*[^\\s\"'${NOT_IN_FAMILY}])?`, // Georgia, -apple-system, メイリオ\n].join('|');\n\n/**\n * A CSS font-family list that ends in a generic family, so a face that fails to load falls back\n * to something of the right kind rather than the browser default.\n *\n * Every family is matched in turn rather than the list being taken as one run of allowed\n * characters: a browser drops a whole `font-family` declaration over one empty family, so\n * `Georgia,, serif` renders nothing the document asked for and must not validate.\n */\nexport const FONT_STACK_PATTERN: RegExp = new RegExp(\n String.raw`^(?:(?:${FONT_FAMILY})\\s*,\\s*)*(?:${GENERIC_FONT_FAMILIES.join('|')})\\s*$`,\n);\n","import type { ColorAnchorName, Treatment } from '../styleVocabulary';\n\n/** One thing wrong with a document, addressed well enough to fix without hunting. */\nexport type StyleDocumentIssue = {\n readonly message: string;\n readonly path: string;\n};\n\n/**\n * Everything a check found, split by what it costs.\n *\n * An **error** is blocking and fails style validation\n * A **warning** is not blocking and only produces a warning message\n */\nexport type StyleDocumentReport = {\n readonly errors: readonly StyleDocumentIssue[];\n readonly warnings: readonly StyleDocumentIssue[];\n};\n\n/**\n * What a walk over the surfaces gathers for the checks that span subtrees: which color anchors a\n * surface named, and which treatments the document uses. Written here, read once anchor\n * completeness arrives.\n */\nexport type Collected = {\n readonly referenced: Set<ColorAnchorName>;\n readonly treatments: Set<Treatment>;\n};\n\nexport const list = (values: readonly string[]): string => values.join(', ');\n\nexport const checkNoUnknownKeys = (\n value: Readonly<Record<string, unknown>>,\n known: readonly string[],\n path: string,\n label: string,\n): readonly StyleDocumentIssue[] =>\n Object.keys(value)\n .filter((key) => !known.includes(key))\n .map((key) => ({\n message: `unknown ${label} — the set is fixed: ${list(known)}`,\n path: path === '' ? key : `${path}.${key}`,\n }));\n","import type { SingleColorAnchorName } from '../styleVocabulary';\nimport { at, isOneOf, isRecord, isString } from '../private/guards';\nimport { LITERAL_COLOR_PATTERN, TOKEN_PATTERN } from '../private/styleDocumentPatterns';\nimport {\n ANCHOR_REF_PREFIX,\n COLOR_RELATIONSHIPS,\n COLOR_TONES,\n MAX_COLOR_SCALE_OFFSET,\n SINGLE_COLOR_ANCHOR_NAMES,\n} from '../styleVocabulary';\nimport { list } from './issues';\n\nexport const COLOR_FORM_MESSAGE =\n 'must be a hex or rgb() literal, a token reference like \"$primaryColor\", or { from, relation, tone }';\n\nexport const isTokenRef = (value: unknown): boolean => isString(value) && TOKEN_PATTERN.test(value);\n\nconst RELATED_COLOR_KEYS: ReadonlySet<string> = new Set(['from', 'relation', 'tone']);\n\n/**\n * A `{ from, relation, tone }` color. `relation` and `tone` are optional, but an unknown one is rejected.\n */\nconst isRelatedColor = (value: unknown): boolean => {\n if (!isRecord(value)) {\n return false;\n }\n const relation = at(value, 'relation');\n const tone = at(value, 'tone');\n const unknownKeys = Object.keys(value).filter((key) => !RELATED_COLOR_KEYS.has(key));\n\n return (\n unknownKeys.length === 0 &&\n isTokenRef(at(value, 'from')) &&\n (relation === undefined || isOneOf(COLOR_RELATIONSHIPS, relation)) &&\n (tone === undefined || isOneOf(COLOR_TONES, tone))\n );\n};\n\n/** One color, in any of the three forms a document may write. */\nexport const isColorForm = (value: unknown): boolean =>\n (isString(value) && LITERAL_COLOR_PATTERN.test(value)) ||\n isTokenRef(value) ||\n isRelatedColor(value);\n\nconst COLOR_REF_PREFIX = `${ANCHOR_REF_PREFIX}colors.`;\n\n/**\n * The color anchor a reference names, when that anchor holds a single color.\n *\n * `anchors.colors.gradientStops` is a reference to a real anchor but resolves to a list, so it\n * cannot be used anywhere that a single color is expected.\n */\nexport const singleColorAnchorFromRef = (value: unknown): SingleColorAnchorName | undefined => {\n if (!isString(value) || !value.startsWith(COLOR_REF_PREFIX)) {\n return undefined;\n }\n const name = value.slice(COLOR_REF_PREFIX.length);\n return isOneOf(SINGLE_COLOR_ANCHOR_NAMES, name) ? name : undefined;\n};\n\nexport const singleColorRefList = (): string =>\n list(SINGLE_COLOR_ANCHOR_NAMES.map((name) => `${COLOR_REF_PREFIX}${name}`));\n\nexport const isScaleOffset = (value: unknown): boolean =>\n typeof value === 'number' &&\n Number.isInteger(value) &&\n value >= 0 &&\n value <= MAX_COLOR_SCALE_OFFSET;\n\n/** A non-negative number of CSS pixels — the same convention as `border.width`. */\nconst isPixelValue = (value: unknown): boolean =>\n typeof value === 'number' && Number.isFinite(value) && value >= 0;\n\n/** A length: a brand token or a number of CSS pixels. */\nexport const isDimension = (value: unknown): boolean => isPixelValue(value) || isTokenRef(value);\n","import type { AnchorGroup } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue, StyleDocumentReport } from './issues';\nimport { at, isOneOf, isRecord, isString } from '../private/guards';\nimport { FONT_STACK_PATTERN } from '../private/styleDocumentPatterns';\nimport {\n ANCHOR_GROUPS,\n ANCHORS_REQUIRED_BY_TREATMENT,\n COLOR_ANCHOR_NAMES,\n MAX_GRADIENT_STOPS,\n MIN_GRADIENT_STOPS,\n OPTIONAL_COLOR_ANCHORS,\n REQUIRED_COLOR_ANCHORS,\n REQUIRED_DIMENSION_ANCHORS,\n REQUIRED_FONT_ANCHORS,\n} from '../styleVocabulary';\nimport { COLOR_FORM_MESSAGE, isColorForm, isDimension, isTokenRef } from './anchorValues';\nimport { checkNoUnknownKeys } from './issues';\n\nconst isFontStack = (value: unknown): boolean => isString(value) && FONT_STACK_PATTERN.test(value);\n\n/**\n * `gradientStops` is always a list because a gradient interpolates between colors.\n * The other color anchors are always a single color.\n */\nconst checkColorAnchor = (\n value: unknown,\n path: string,\n { asStops = false }: { readonly asStops?: boolean } = {},\n): readonly StyleDocumentIssue[] => {\n if (!asStops) {\n return isColorForm(value) ? [] : [{ message: COLOR_FORM_MESSAGE, path }];\n }\n\n if (!Array.isArray(value)) {\n return [\n { message: `must be a list of ${MIN_GRADIENT_STOPS}-${MAX_GRADIENT_STOPS} colors`, path },\n ];\n }\n\n const countMessage = `a gradient needs ${MIN_GRADIENT_STOPS}-${MAX_GRADIENT_STOPS} stops, not ${value.length}`;\n\n // A list over the limit has to be rewritten anyway, and its length may be far beyond its contents.\n if (value.length > MAX_GRADIENT_STOPS) {\n return [{ message: countMessage, path }];\n }\n\n const countIssues: readonly StyleDocumentIssue[] =\n value.length < MIN_GRADIENT_STOPS ? [{ message: countMessage, path }] : [];\n\n return [\n ...countIssues,\n ...Array.from(value, (stop: unknown, index: number): readonly StyleDocumentIssue[] =>\n isColorForm(stop) ? [] : [{ message: COLOR_FORM_MESSAGE, path: `${path}.${index}` }],\n ).flat(),\n ];\n};\n\nconst ALWAYS_DECLARED_MESSAGE =\n 'mirrors a Brand Kit input, so every Style declares it, whether or not it is used';\n\nconst UNUSED_ANCHOR_MESSAGE =\n 'nothing references it and no treatment needs it, so the engine ignores it';\n\n/** A group's members once it is known to be present and shaped right, alongside what was wrong. */\ntype AnchorGroupResult = {\n readonly members: Readonly<Record<string, unknown>> | undefined;\n readonly issues: readonly StyleDocumentIssue[];\n};\n\nconst checkAnchorGroup = (\n anchors: Readonly<Record<string, unknown>>,\n group: AnchorGroup,\n members: readonly string[],\n label: string,\n): AnchorGroupResult => {\n const path = `anchors.${group}`;\n const value = at(anchors, group);\n\n if (value === undefined) {\n return {\n members: undefined,\n issues: [{ message: 'every Style declares every anchor group', path }],\n };\n }\n if (!isRecord(value)) {\n return { members: undefined, issues: [{ message: 'must be an object', path }] };\n }\n\n return { members: value, issues: checkNoUnknownKeys(value, members, path, label) };\n};\n\nconst checkDimensionAnchors = (\n dimensions: Readonly<Record<string, unknown>>,\n): readonly StyleDocumentIssue[] =>\n REQUIRED_DIMENSION_ANCHORS.flatMap((name): readonly StyleDocumentIssue[] => {\n const path = `anchors.dimensions.${name}`;\n const declared = at(dimensions, name);\n\n if (declared === undefined) {\n return [{ message: ALWAYS_DECLARED_MESSAGE, path }];\n }\n if (!isDimension(declared)) {\n return [\n { message: `${name} must be a token reference or a number of pixels, e.g. 20`, path },\n ];\n }\n\n return [];\n });\n\nconst checkFontAnchors = (\n fonts: Readonly<Record<string, unknown>>,\n): readonly StyleDocumentIssue[] =>\n REQUIRED_FONT_ANCHORS.flatMap((name): readonly StyleDocumentIssue[] => {\n const path = `anchors.fonts.${name}`;\n const declared = at(fonts, name);\n\n if (declared === undefined) {\n return [{ message: ALWAYS_DECLARED_MESSAGE, path }];\n }\n if (!isTokenRef(declared) && !isFontStack(declared)) {\n return [\n {\n message: `${name} must be a token reference, e.g. \"$${name}FontFamily\", or a font stack ending in a generic family, e.g. \"'Fraunces', Georgia, serif\"`,\n path,\n },\n ];\n }\n\n return [];\n });\n\nconst checkColorAnchors = (\n colors: Readonly<Record<string, unknown>>,\n collected: Collected,\n): StyleDocumentReport => {\n const declaredIssues = COLOR_ANCHOR_NAMES.flatMap((name): readonly StyleDocumentIssue[] => {\n const declared = at(colors, name);\n\n return declared === undefined\n ? []\n : checkColorAnchor(declared, `anchors.colors.${name}`, {\n asStops: name === 'gradientStops',\n });\n });\n\n // The brand's own colors are always declared, referenced or not.\n const missingRequired = REQUIRED_COLOR_ANCHORS.filter(\n (name) => at(colors, name) === undefined,\n ).map((name) => ({ message: ALWAYS_DECLARED_MESSAGE, path: `anchors.colors.${name}` }));\n\n // Treatment colors are declared only where they are needed — and must be, when they are.\n const needed = new Set(collected.referenced);\n for (const treatment of collected.treatments) {\n for (const anchor of ANCHORS_REQUIRED_BY_TREATMENT[treatment]) {\n needed.add(anchor);\n }\n }\n\n const missingNeeded = [...needed]\n .filter(\n (anchor) => !isOneOf(REQUIRED_COLOR_ANCHORS, anchor) && at(colors, anchor) === undefined,\n )\n .map((anchor) => ({\n message: 'referenced by a surface or required by a treatment, but not declared',\n path: `anchors.colors.${anchor}`,\n }));\n\n // And nowhere else: an unreachable treatment color is dead weight, usually a copied document.\n // It changes nothing about how the document renders, so it is a warning rather than an error.\n const warnings = OPTIONAL_COLOR_ANCHORS.filter(\n (anchor) => at(colors, anchor) !== undefined && !needed.has(anchor),\n ).map((anchor) => ({ message: UNUSED_ANCHOR_MESSAGE, path: `anchors.colors.${anchor}` }));\n\n return { errors: [...declaredIssues, ...missingRequired, ...missingNeeded], warnings };\n};\n\nexport const checkAnchors = (value: unknown, collected: Collected): StyleDocumentReport => {\n if (!isRecord(value)) {\n return { errors: [{ message: 'must be an object', path: 'anchors' }], warnings: [] };\n }\n\n const dimensions = checkAnchorGroup(\n value,\n 'dimensions',\n REQUIRED_DIMENSION_ANCHORS,\n 'dimension anchor',\n );\n const colors = checkAnchorGroup(value, 'colors', COLOR_ANCHOR_NAMES, 'color anchor');\n const fonts = checkAnchorGroup(value, 'fonts', REQUIRED_FONT_ANCHORS, 'font anchor');\n\n const colorReport: StyleDocumentReport =\n colors.members === undefined\n ? { errors: [], warnings: [] }\n : checkColorAnchors(colors.members, collected);\n\n return {\n errors: [\n ...checkNoUnknownKeys(value, ANCHOR_GROUPS, 'anchors', 'anchor group'),\n ...dimensions.issues,\n ...(dimensions.members === undefined ? [] : checkDimensionAnchors(dimensions.members)),\n ...colors.issues,\n ...colorReport.errors,\n ...fonts.issues,\n ...(fonts.members === undefined ? [] : checkFontAnchors(fonts.members)),\n ],\n warnings: colorReport.warnings,\n };\n};\n","import type { SurfaceName } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport {\n INVERT_RULES,\n MAX_COLOR_SCALE_OFFSET,\n OFFSET_ORIGINS,\n STACKABLE_ON,\n} from '../styleVocabulary';\nimport { isScaleOffset, singleColorAnchorFromRef, singleColorRefList } from './anchorValues';\nimport { checkNoUnknownKeys, list } from './issues';\n\n/**\n * A surface's fill: an anchor, or `parent` on a surface that sits on something.\n * Since a `flat` surface with an offset of `parent: 0` is essentially transparent,\n * we reject that syntax in favor of `treatment: \"none\"` — unless it inverts\n * `when-indistinct`, which always fires at that offset and paints the text color instead.\n */\nexport const checkBackgroundColor = (\n value: unknown,\n path: string,\n surface: SurfaceName,\n treatment: unknown,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(\n value,\n ['source', 'offset', 'from', 'invert'],\n path,\n 'backgroundColor key',\n ),\n ];\n\n const from = at(value, 'from');\n if (!isOneOf(OFFSET_ORIGINS, from)) {\n issues.push({ message: `from must be one of: ${list(OFFSET_ORIGINS)}`, path: `${path}.from` });\n } else if (from === 'parent' && STACKABLE_ON[surface].length === 0) {\n issues.push({\n message: `\"parent\" needs a surface to count from, and ${surface} sits on nothing — use \"source\"`,\n path: `${path}.from`,\n });\n }\n\n const invert = at(value, 'invert');\n if (!isOneOf(INVERT_RULES, invert)) {\n issues.push({\n message: `invert must be one of: ${list(INVERT_RULES)}`,\n path: `${path}.invert`,\n });\n } else if (invert === 'when-indistinct' && STACKABLE_ON[surface].length === 0) {\n issues.push({\n message: `\"when-indistinct\" compares a fill with what it sits on, and ${surface} sits on nothing — use \"never\"`,\n path: `${path}.invert`,\n });\n } else if (invert === 'when-indistinct' && treatment !== 'flat') {\n issues.push({\n message: 'only a flat fill can trade places with its text — use \"never\", or treatment \"flat\"',\n path: `${path}.invert`,\n });\n }\n\n const source = at(value, 'source');\n const offset = at(value, 'offset');\n const offsetIsValid = isScaleOffset(offset);\n\n if (source === 'parent') {\n if (STACKABLE_ON[surface].length === 0) {\n issues.push({\n message: `\"parent\" needs a surface to sit on, and ${surface} sits on nothing — use an anchor`,\n path: `${path}.source`,\n });\n } else if (treatment === 'flat' && invert === 'never' && offsetIsValid && offset === 0) {\n issues.push({\n message: `a flat surface at parent · 0 paints exactly its parent's fill and cannot be seen — step at least 1, invert \"when-indistinct\" to trade places with its text, or use treatment \"none\" to paint nothing`,\n path: `${path}.offset`,\n });\n }\n } else {\n const anchor = singleColorAnchorFromRef(source);\n if (anchor === undefined) {\n issues.push({\n message: `source must be \"parent\" or one of: ${singleColorRefList()}`,\n path: `${path}.source`,\n });\n } else {\n collected.referenced.add(anchor);\n }\n }\n\n if (!offsetIsValid) {\n issues.push({\n message: `offset must be an integer 0-${MAX_COLOR_SCALE_OFFSET}`,\n path: `${path}.offset`,\n });\n }\n\n return issues;\n};\n","import type { SurfaceName } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport { BORDER_STYLES, MAX_COLOR_SCALE_OFFSET, STACKABLE_ON } from '../styleVocabulary';\nimport { isScaleOffset, singleColorAnchorFromRef, singleColorRefList } from './anchorValues';\nimport { checkNoUnknownKeys, list } from './issues';\n\nexport const checkBorder = (\n value: Readonly<Record<string, unknown>>,\n surfacePath: string,\n surface: SurfaceName,\n treatment: unknown,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n const path = `${surfacePath}.border`;\n const declared = Object.hasOwn(value, 'border');\n\n if (STACKABLE_ON[surface].length === 0) {\n return declared\n ? [\n {\n message: `${surface} sits on nothing and has no edge of its own, so it carries no border`,\n path,\n },\n ]\n : [];\n }\n\n if (!declared) {\n return [\n {\n message: 'every surface with an edge of its own declares a border, even one of width 0',\n path,\n },\n ];\n }\n\n const border = at(value, 'border');\n\n if (!isRecord(border)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(border, ['width', 'source', 'offset', 'style'], path, 'border key'),\n ];\n\n const style = at(border, 'style');\n if (!isOneOf(BORDER_STYLES, style)) {\n issues.push({ message: `style must be one of: ${list(BORDER_STYLES)}`, path: `${path}.style` });\n } else if (style === 'scalloped' && treatment === 'none') {\n issues.push({\n message:\n 'scallops are drawn in the surface\\'s own fill, and treatment \"none\" paints none — give the surface a fill, or use \"lace\"',\n path: `${path}.style`,\n });\n }\n\n const width = at(border, 'width');\n if (typeof width !== 'number' || !Number.isFinite(width) || width < 0) {\n issues.push({\n message: 'width must be a non-negative number of pixels, e.g. 1 or 0.5 (0 for none)',\n path: `${path}.width`,\n });\n }\n\n const borderSource = at(border, 'source');\n const borderAnchor = singleColorAnchorFromRef(borderSource);\n if (borderAnchor !== undefined) {\n collected.referenced.add(borderAnchor);\n } else if (borderSource !== 'surface') {\n issues.push({\n message: `source must be \"surface\" or one of: ${singleColorRefList()}`,\n path: `${path}.source`,\n });\n }\n\n if (!isScaleOffset(at(border, 'offset'))) {\n issues.push({\n message: `offset must be an integer 0-${MAX_COLOR_SCALE_OFFSET}`,\n path: `${path}.offset`,\n });\n }\n\n return issues;\n};\n","import type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport {\n ELEVATION_COLOR_SOURCE_KEYWORDS,\n ELEVATION_DEPTHS,\n ELEVATION_HARDNESSES,\n} from '../styleVocabulary';\nimport { isColorForm, singleColorAnchorFromRef, singleColorRefList } from './anchorValues';\nimport { checkNoUnknownKeys, list } from './issues';\n\nexport const checkElevation = (\n value: unknown,\n path: string,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['depth', 'hardness', 'source'], path, 'elevation key'),\n ];\n\n if (!isOneOf(ELEVATION_DEPTHS, at(value, 'depth'))) {\n issues.push({\n message: `depth must be one of: ${list(ELEVATION_DEPTHS)}`,\n path: `${path}.depth`,\n });\n }\n\n if (!isOneOf(ELEVATION_HARDNESSES, at(value, 'hardness'))) {\n issues.push({\n message: `hardness must be one of: ${list(ELEVATION_HARDNESSES)}`,\n path: `${path}.hardness`,\n });\n }\n\n const elevationSource = at(value, 'source');\n const elevationAnchor = singleColorAnchorFromRef(elevationSource);\n if (elevationAnchor !== undefined) {\n collected.referenced.add(elevationAnchor);\n } else if (\n !isOneOf(ELEVATION_COLOR_SOURCE_KEYWORDS, elevationSource) &&\n !isColorForm(elevationSource)\n ) {\n issues.push({\n message: `source must be one of: ${list(ELEVATION_COLOR_SOURCE_KEYWORDS)}, ${singleColorRefList()}, or a color — a hex or rgb() literal, a token reference like \"$primaryColor\", or { from, relation, tone }`,\n path: `${path}.source`,\n });\n }\n\n return issues;\n};\n","import type { GradientShapeOption } from '../styleVocabulary';\nimport type { StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport {\n GRADIENT_DIRECTIONS,\n GRADIENT_EXTENTS,\n GRADIENT_POSITIONS,\n GRADIENT_SHAPE_OPTIONS,\n} from '../styleVocabulary';\nimport { checkNoUnknownKeys, list } from './issues';\n\n/** Every key a gradientShape may carry, and which kinds each option belongs to. */\nconst GRADIENT_SHAPE_KEYS = ['kind', 'direction', 'position', 'extent'] as const;\nconst KIND_SPECIFIC_KEYS: readonly (readonly [\n key: string,\n kinds: readonly GradientShapeOption[],\n allowed: readonly string[],\n])[] = [\n ['direction', ['linear'], GRADIENT_DIRECTIONS],\n ['position', ['radial'], GRADIENT_POSITIONS],\n ['extent', ['radial'], GRADIENT_EXTENTS],\n];\n\n/**\n * `gradientShape` is the one setting a surface carries conditionally: required when the treatment\n * is `gradient`, absent otherwise. Naming a shape on a surface that paints no gradient is an error\n * rather than a line that silently does nothing — the same reason unknown keys are caught.\n */\nexport const checkGradientShape = (\n value: Record<string, unknown>,\n path: string,\n treatment: unknown,\n): readonly StyleDocumentIssue[] => {\n const declared = Object.hasOwn(value, 'gradientShape');\n\n if (treatment !== 'gradient') {\n return declared\n ? [\n {\n message: 'only a surface with treatment \"gradient\" carries a gradientShape',\n path: `${path}.gradientShape`,\n },\n ]\n : [];\n }\n\n if (!declared) {\n return [\n {\n message: `a gradient surface must name its shape: ${list(GRADIENT_SHAPE_OPTIONS)}`,\n path: `${path}.gradientShape`,\n },\n ];\n }\n\n const shape = at(value, 'gradientShape');\n const shapePath = `${path}.gradientShape`;\n\n if (!isRecord(shape)) {\n return [{ message: 'must be an object', path: shapePath }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(shape, GRADIENT_SHAPE_KEYS, shapePath, 'setting'),\n ];\n\n const kind = at(shape, 'kind');\n\n if (!isOneOf(GRADIENT_SHAPE_OPTIONS, kind)) {\n issues.push({\n message: `kind must be one of: ${list(GRADIENT_SHAPE_OPTIONS)}`,\n path: `${shapePath}.kind`,\n });\n\n return issues;\n }\n\n /**\n * Each arrangement carries exactly what it needs to be drawn and nothing else, so a direction on\n * a radial gradient is an error rather than a line the engine quietly ignores.\n */\n for (const [key, kinds, allowed] of KIND_SPECIFIC_KEYS) {\n const wanted = kinds.includes(kind);\n const present = Object.hasOwn(shape, key);\n\n if (wanted && !present) {\n issues.push({\n message: `a ${kind} gradient must name its ${key}: ${list(allowed)}`,\n path: `${shapePath}.${key}`,\n });\n } else if (!wanted && present) {\n issues.push({\n message: `only a ${list(kinds)} gradient carries a ${key}`,\n path: `${shapePath}.${key}`,\n });\n } else if (wanted && !isOneOf(allowed, at(shape, key))) {\n issues.push({\n message: `${key} must be one of: ${list(allowed)}`,\n path: `${shapePath}.${key}`,\n });\n }\n }\n\n return issues;\n};\n","import type { StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport { AMBIENT_MOTIONS, MOTION_SPEEDS, TRANSITIONS } from '../styleVocabulary';\nimport { checkNoUnknownKeys, list } from './issues';\n\nexport const checkMotion = (value: unknown, path: string): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['ambient', 'speed', 'transition'], path, 'motion key'),\n ];\n\n if (!isOneOf(AMBIENT_MOTIONS, at(value, 'ambient'))) {\n issues.push({\n message: `ambient must be one of: ${list(AMBIENT_MOTIONS)}`,\n path: `${path}.ambient`,\n });\n }\n if (!isOneOf(MOTION_SPEEDS, at(value, 'speed'))) {\n issues.push({\n message: `speed must be one of: ${list(MOTION_SPEEDS)}`,\n path: `${path}.speed`,\n });\n }\n if (!isOneOf(TRANSITIONS, at(value, 'transition'))) {\n issues.push({\n message: `transition must be one of: ${list(TRANSITIONS)}`,\n path: `${path}.transition`,\n });\n }\n\n return issues;\n};\n","import type { StyleDocumentIssue } from './issues';\nimport { at, isRecord } from '../private/guards';\nimport { ANCHOR_REF_PREFIX } from '../styleVocabulary';\nimport { isDimension } from './anchorValues';\nimport { checkNoUnknownKeys } from './issues';\n\nconst BORDER_RADIUS_REF = `${ANCHOR_REF_PREFIX}dimensions.borderRadius`;\n\n/** Only the border-radius anchor: any other length, such as a spacing value, is not a radius. */\nconst isRadiusSource = (value: unknown): boolean =>\n value === BORDER_RADIUS_REF || isDimension(value);\n\nexport const checkRadius = (value: unknown, path: string): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['source'], path, 'radius key'),\n ];\n\n if (!isRadiusSource(at(value, 'source'))) {\n issues.push({\n message: `source must be \"${BORDER_RADIUS_REF}\", a token reference, or a number of pixels`,\n path: `${path}.source`,\n });\n }\n\n return issues;\n};\n","import type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isRecord } from '../private/guards';\nimport { MAX_COLOR_SCALE_OFFSET } from '../styleVocabulary';\nimport {\n isColorForm,\n isScaleOffset,\n singleColorAnchorFromRef,\n singleColorRefList,\n} from './anchorValues';\nimport { checkNoUnknownKeys } from './issues';\n\nexport const checkTextColor = (\n value: unknown,\n path: string,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n const anchor = singleColorAnchorFromRef(value);\n if (anchor !== undefined) {\n collected.referenced.add(anchor);\n return [];\n }\n if (value === 'derive' || isColorForm(value)) {\n return [];\n }\n if (!isRecord(value) || Object.hasOwn(value, 'from')) {\n return [\n {\n message: `textColor must be \"derive\", { source, offset }, one of: ${singleColorRefList()}, or a color — a hex or rgb() literal, a token reference like \"$primaryColor\", or { from, relation, tone }`,\n path,\n },\n ];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['source', 'offset'], path, 'textColor key'),\n ];\n\n const source = singleColorAnchorFromRef(at(value, 'source'));\n if (source === undefined) {\n issues.push({\n message: `source must be one of: ${singleColorRefList()}`,\n path: `${path}.source`,\n });\n } else {\n collected.referenced.add(source);\n }\n\n if (!isScaleOffset(at(value, 'offset'))) {\n issues.push({\n message: `offset must be an integer 0-${MAX_COLOR_SCALE_OFFSET}`,\n path: `${path}.offset`,\n });\n }\n\n return issues;\n};\n","import type { StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport { TEXTURE_INTENSITIES, TEXTURE_KINDS } from '../styleVocabulary';\nimport { checkNoUnknownKeys, list } from './issues';\n\n/**\n * A named texture at a named intensity. A surface that paints nothing has no fill to lay a\n * texture over, so `treatment: \"none\"` requires `kind: \"none\"`.\n */\nexport const checkTexture = (\n value: unknown,\n path: string,\n treatment: unknown,\n): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['kind', 'intensity'], path, 'texture key'),\n ];\n\n const kind = at(value, 'kind');\n if (!isOneOf(TEXTURE_KINDS, kind)) {\n issues.push({ message: `kind must be one of: ${list(TEXTURE_KINDS)}`, path: `${path}.kind` });\n } else if (treatment === 'none' && kind !== 'none') {\n issues.push({\n message:\n 'a surface with treatment \"none\" paints no fill to texture — use kind \"none\", or give the surface a fill',\n path: `${path}.kind`,\n });\n }\n\n if (!isOneOf(TEXTURE_INTENSITIES, at(value, 'intensity'))) {\n issues.push({\n message: `intensity must be one of: ${list(TEXTURE_INTENSITIES)}`,\n path: `${path}.intensity`,\n });\n }\n\n return issues;\n};\n","import type { SurfaceName } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport { ALL_SETTING_NAMES, SURFACE_NAMES, TREATMENTS } from '../styleVocabulary';\nimport { checkBackgroundColor } from './backgroundColor';\nimport { checkBorder } from './border';\nimport { checkElevation } from './elevation';\nimport { checkGradientShape } from './gradientShape';\nimport { checkNoUnknownKeys, list } from './issues';\nimport { checkMotion } from './motion';\nimport { checkRadius } from './radius';\nimport { checkTextColor } from './textColor';\nimport { checkTexture } from './texture';\n\nconst checkSurface = (\n value: unknown,\n name: SurfaceName,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n const path = `surfaces.${name}`;\n\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const treatment = at(value, 'treatment');\n const namedTreatment = isOneOf(TREATMENTS, treatment);\n\n if (namedTreatment) {\n collected.treatments.add(treatment);\n }\n\n return [\n ...checkNoUnknownKeys(value, ALL_SETTING_NAMES, path, 'setting'),\n ...(namedTreatment\n ? []\n : [\n {\n message: `treatment must be one of: ${list(TREATMENTS)}`,\n path: `${path}.treatment`,\n },\n ]),\n ...checkGradientShape(value, path, treatment),\n ...checkBackgroundColor(\n at(value, 'backgroundColor'),\n `${path}.backgroundColor`,\n name,\n treatment,\n collected,\n ),\n ...checkTextColor(at(value, 'textColor'), `${path}.textColor`, collected),\n ...checkBorder(value, path, name, treatment, collected),\n ...checkElevation(at(value, 'elevation'), `${path}.elevation`, collected),\n ...checkRadius(at(value, 'radius'), `${path}.radius`),\n ...checkTexture(at(value, 'texture'), `${path}.texture`, treatment),\n ...checkMotion(at(value, 'motion'), `${path}.motion`),\n ];\n};\n\nexport const checkSurfaces = (\n value: unknown,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path: 'surfaces' }];\n }\n\n const unknown = Object.keys(value)\n .filter((key) => !isOneOf(SURFACE_NAMES, key))\n .map((key) => ({\n message: `unknown surface — the set is fixed: ${list(SURFACE_NAMES)}`,\n path: `surfaces.${key}`,\n }));\n\n return [\n ...unknown,\n ...SURFACE_NAMES.flatMap((name) => {\n const surface = at(value, name);\n\n return surface === undefined\n ? [{ message: 'every Style must define every surface', path: `surfaces.${name}` }]\n : checkSurface(surface, name, collected);\n }),\n ];\n};\n","import type { StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord, isString } from '../private/guards';\nimport {\n ANCHOR_REF_PREFIX,\n REQUIRED_FONT_ANCHORS,\n TYPE_CASES,\n TYPE_ROLES,\n} from '../styleVocabulary';\nimport { checkNoUnknownKeys, list } from './issues';\n\nconst FONT_REF_PREFIX = `${ANCHOR_REF_PREFIX}fonts.`;\n\nconst fontRefList = (): string =>\n list(REQUIRED_FONT_ANCHORS.map((name) => `${FONT_REF_PREFIX}${name}`));\n\nconst isFontAnchorRef = (value: unknown): boolean =>\n isString(value) &&\n value.startsWith(FONT_REF_PREFIX) &&\n isOneOf(REQUIRED_FONT_ANCHORS, value.slice(FONT_REF_PREFIX.length));\n\nconst checkTypeRole = (value: unknown, path: string): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['font', 'fontSize', 'case', 'fontWeight'], path, 'type key'),\n ];\n\n if (!isFontAnchorRef(at(value, 'font'))) {\n issues.push({ message: `font must be one of: ${fontRefList()}`, path: `${path}.font` });\n }\n const fontSize = at(value, 'fontSize');\n if (typeof fontSize !== 'number' || !Number.isFinite(fontSize) || fontSize <= 0) {\n issues.push({\n message: 'fontSize must be a positive number of pixels, e.g. 16',\n path: `${path}.fontSize`,\n });\n }\n if (!isOneOf(TYPE_CASES, at(value, 'case'))) {\n issues.push({ message: `case must be one of: ${list(TYPE_CASES)}`, path: `${path}.case` });\n }\n const fontWeight = at(value, 'fontWeight');\n if (\n typeof fontWeight !== 'number' ||\n !Number.isFinite(fontWeight) ||\n fontWeight < 1 ||\n fontWeight > 1000\n ) {\n issues.push({\n message: 'fontWeight must be a CSS weight from 1 to 1000, e.g. 400 or 700',\n path: `${path}.fontWeight`,\n });\n }\n\n return issues;\n};\n\nexport const checkTypography = (value: unknown): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path: 'typography' }];\n }\n\n return [\n ...checkNoUnknownKeys(value, TYPE_ROLES, 'typography', 'type role'),\n ...TYPE_ROLES.flatMap((role) => checkTypeRole(at(value, role), `typography.${role}`)),\n ];\n};\n","import type { StyleDocument } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue, StyleDocumentReport } from './issues';\nimport { at, isRecord, isString } from '../private/guards';\nimport { ID_PATTERN } from '../private/styleDocumentPatterns';\nimport { DOCUMENT_KEYS } from '../styleVocabulary';\nimport { checkAnchors } from './anchors';\nimport { checkNoUnknownKeys } from './issues';\nimport { checkSurfaces } from './surfaces';\nimport { checkTypography } from './typography';\n\n/**\n * Structural validation for a Style document, based on the schema.\n *\n * @param input a parsed Style document, of unknown shape\n * @returns every problem found, split into errors, which make the document invalid, and\n * warnings, which do not\n *\n * @example\n * ```ts\n * const { errors, warnings } = checkStyleDocument(doc);\n * for (const { path, message } of warnings) {\n * console.warn(`${path}: ${message}`);\n * }\n * if (errors.length > 0) {\n * throw new Error(errors.map(({ path, message }) => `${path}: ${message}`).join('\\n'));\n * }\n * ```\n */\nexport const checkStyleDocument = (input: unknown): StyleDocumentReport => {\n if (!isRecord(input)) {\n return { errors: [{ message: 'a Style document must be an object', path: '' }], warnings: [] };\n }\n\n const issues: StyleDocumentIssue[] = [...checkNoUnknownKeys(input, DOCUMENT_KEYS, '', 'key')];\n const collected: Collected = { referenced: new Set(), treatments: new Set() };\n\n const id = at(input, 'id');\n if (!isString(id) || !ID_PATTERN.test(id)) {\n issues.push({ message: 'id must be lowercase kebab-case, e.g. \"glass-dark\"', path: 'id' });\n }\n\n const name = at(input, 'name');\n if (!isString(name) || name.length === 0) {\n issues.push({ message: 'name is required', path: 'name' });\n }\n\n if (at(input, 'schemaVersion') !== 1) {\n issues.push({ message: 'schemaVersion must be 1', path: 'schemaVersion' });\n }\n\n const surfaceIssues = [\n ...checkTypography(at(input, 'typography')),\n ...checkSurfaces(at(input, 'surfaces'), collected),\n ];\n\n // checkSurfaces fills `collected`, which anchor completeness reads, so anchors run last.\n const anchors = checkAnchors(at(input, 'anchors'), collected);\n\n issues.push(...surfaceIssues, ...anchors.errors);\n\n return { errors: issues, warnings: anchors.warnings };\n};\n\n/**\n * What makes a document invalid, and nothing else.\n *\n * Empty means the document is safe to render, so a caller can drop a document on a non-empty\n * result without reading it — the reason warnings are a separate channel rather than entries\n * here with a severity on them. Nothing inert should ever cost a customer their Style.\n *\n * @example\n * ```ts\n * const issues = validateStyleDocument(doc);\n * if (issues.length > 0) {\n * throw new Error(issues.map(({ path, message }) => `${path}: ${message}`).join('\\n'));\n * }\n * ```\n */\nexport const validateStyleDocument = (input: unknown): readonly StyleDocumentIssue[] =>\n checkStyleDocument(input).errors;\n\n/** Whether a value is a valid Style document. */\nexport const isStyleDocument = (input: unknown): input is StyleDocument =>\n validateStyleDocument(input).length === 0;\n"],"mappings":";;;;;;;;;;;;;AAMA,M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yleDocument/issues.ts","../src/validateStyleDocument/anchorValues.ts","../src/validateStyleDocument/anchors.ts","../src/validateStyleDocument/backgroundColor.ts","../src/validateStyleDocument/border.ts","../src/validateStyleDocument/elevation.ts","../src/validateStyleDocument/gradientShape.ts","../src/validateStyleDocument/motion.ts","../src/validateStyleDocument/radius.ts","../src/validateStyleDocument/textColor.ts","../src/validateStyleDocument/texture.ts","../src/validateStyleDocument/surfaces.ts","../src/validateStyleDocument/typography.ts","../src/validateStyleDocument/validateStyleDocument.ts"],"sourcesContent":["// oxlint-disable typescript/no-inferrable-types -- `isolatedDeclarations` (tsconfig.build.json)\n// requires an explicit annotation on every exported const, including ones oxlint considers\n// trivially inferable.\n\nimport { GENERIC_FONT_FAMILIES } from '../styleVocabulary';\n\nexport const ID_PATTERN: RegExp = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\n\n/** No dots: brand tokens are not namespaced. */\nexport const TOKEN_PATTERN: RegExp = /^\\$[A-Za-z][A-Za-z0-9]*$/;\n\nconst HEX_COLOR = String.raw`#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})`;\n\n/** One channel or alpha inside an `rgb()`: a number, or a percentage of the channel's range. */\nconst RGB_VALUE = String.raw`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)%?`;\n\n/**\n * Legacy `rgb(41, 73, 229)` and modern `rgb(41 73 229 / 50%)`, each with an optional alpha.\n *\n * Kept in step with `parseColor`, which reads a document's literals at render time: a literal this\n * accepts must be one the parser can read, or validation approves a color that silently falls back.\n * The parser is the more forgiving of the two — it also takes a hex without its `#`, `RGB()` in any\n * case, and separators mixed within one function — so only that direction is guaranteed.\n */\nconst RGB_COLOR = String.raw`rgba?\\(\\s*(?:${RGB_VALUE}\\s*,\\s*${RGB_VALUE}\\s*,\\s*${RGB_VALUE}(?:\\s*,\\s*${RGB_VALUE})?|${RGB_VALUE}\\s+${RGB_VALUE}\\s+${RGB_VALUE}(?:\\s*/\\s*${RGB_VALUE})?)\\s*\\)`;\n\nexport const LITERAL_COLOR_PATTERN: RegExp = new RegExp(\n String.raw`^(?:${HEX_COLOR}|${RGB_COLOR})$`,\n);\n\nconst NOT_IN_QUOTED_FAMILY = String.raw`$;{}()<>\\\\`;\n\n/** A comma delineates font families, but inside quotes it should be considered part of the name. */\nconst NOT_IN_FAMILY = `,${NOT_IN_QUOTED_FAMILY}`;\n\n/**\n * One family in a list, where each item is delineated by a comma.\n * No `$`, parentheses, braces, angle brackets, backslashes or semicolons allowed in the family\n * names. Any quotes must have a matching end quote.\n */\nconst FONT_FAMILY = [\n String.raw`\"[^\"${NOT_IN_QUOTED_FAMILY}]+\"`, // \"Segoe UI\", and may hold the other quote: \"Foo's Text\"\n String.raw`'[^'${NOT_IN_QUOTED_FAMILY}]+'`, // 'Fraunces', or with a comma: 'ACME, Inc'\n // Ends on a non-space so trailing spaces only match the separator\n String.raw`[^\\s\"'${NOT_IN_FAMILY}](?:[^\"'${NOT_IN_FAMILY}]*[^\\s\"'${NOT_IN_FAMILY}])?`, // Georgia, -apple-system, メイリオ\n].join('|');\n\n/**\n * A CSS font-family list that ends in a generic family, so a face that fails to load falls back\n * to something of the right kind rather than the browser default.\n *\n * Every family is matched in turn rather than the list being taken as one run of allowed\n * characters: a browser drops a whole `font-family` declaration over one empty family, so\n * `Georgia,, serif` renders nothing the document asked for and must not validate.\n */\nexport const FONT_STACK_PATTERN: RegExp = new RegExp(\n String.raw`^(?:(?:${FONT_FAMILY})\\s*,\\s*)*(?:${GENERIC_FONT_FAMILIES.join('|')})\\s*$`,\n);\n","import type { ColorAnchorName, Treatment } from '../styleVocabulary';\n\n/** One thing wrong with a document, addressed well enough to fix without hunting. */\nexport type StyleDocumentIssue = {\n readonly message: string;\n readonly path: string;\n};\n\n/**\n * Everything a check found, split by what it costs.\n *\n * An **error** is blocking and fails style validation\n * A **warning** is not blocking and only produces a warning message\n */\nexport type StyleDocumentReport = {\n readonly errors: readonly StyleDocumentIssue[];\n readonly warnings: readonly StyleDocumentIssue[];\n};\n\n/**\n * What a walk over the surfaces gathers for the checks that span subtrees: which color anchors a\n * surface named, and which treatments the document uses. Written here, read once anchor\n * completeness arrives.\n */\nexport type Collected = {\n readonly referenced: Set<ColorAnchorName>;\n readonly treatments: Set<Treatment>;\n};\n\nexport const list = (values: readonly string[]): string => values.join(', ');\n\nexport const checkNoUnknownKeys = (\n value: Readonly<Record<string, unknown>>,\n known: readonly string[],\n path: string,\n label: string,\n): readonly StyleDocumentIssue[] =>\n Object.keys(value)\n .filter((key) => !known.includes(key))\n .map((key) => ({\n message: `unknown ${label} — the set is fixed: ${list(known)}`,\n path: path === '' ? key : `${path}.${key}`,\n }));\n","import type { SingleColorAnchorName } from '../styleVocabulary';\nimport { at, isOneOf, isRecord, isString } from '../private/guards';\nimport { LITERAL_COLOR_PATTERN, TOKEN_PATTERN } from '../private/styleDocumentPatterns';\nimport {\n ANCHOR_REF_PREFIX,\n COLOR_RELATIONSHIPS,\n COLOR_TONES,\n MAX_COLOR_SCALE_OFFSET,\n SINGLE_COLOR_ANCHOR_NAMES,\n} from '../styleVocabulary';\nimport { list } from './issues';\n\nexport const COLOR_FORM_MESSAGE =\n 'must be a hex or rgb() literal, a token reference like \"$primaryColor\", or { from, relation, tone }';\n\nexport const isTokenRef = (value: unknown): boolean => isString(value) && TOKEN_PATTERN.test(value);\n\nconst RELATED_COLOR_KEYS: ReadonlySet<string> = new Set(['from', 'relation', 'tone']);\n\n/**\n * A `{ from, relation, tone }` color. `relation` and `tone` are optional, but an unknown one is rejected.\n */\nconst isRelatedColor = (value: unknown): boolean => {\n if (!isRecord(value)) {\n return false;\n }\n const relation = at(value, 'relation');\n const tone = at(value, 'tone');\n const unknownKeys = Object.keys(value).filter((key) => !RELATED_COLOR_KEYS.has(key));\n\n return (\n unknownKeys.length === 0 &&\n isTokenRef(at(value, 'from')) &&\n (relation === undefined || isOneOf(COLOR_RELATIONSHIPS, relation)) &&\n (tone === undefined || isOneOf(COLOR_TONES, tone))\n );\n};\n\n/** One color, in any of the three forms a document may write. */\nexport const isColorForm = (value: unknown): boolean =>\n (isString(value) && LITERAL_COLOR_PATTERN.test(value)) ||\n isTokenRef(value) ||\n isRelatedColor(value);\n\nconst COLOR_REF_PREFIX = `${ANCHOR_REF_PREFIX}colors.`;\n\n/**\n * The color anchor a reference names, when that anchor holds a single color.\n *\n * `anchors.colors.gradientStops` is a reference to a real anchor but resolves to a list, so it\n * cannot be used anywhere that a single color is expected.\n */\nexport const singleColorAnchorFromRef = (value: unknown): SingleColorAnchorName | undefined => {\n if (!isString(value) || !value.startsWith(COLOR_REF_PREFIX)) {\n return undefined;\n }\n const name = value.slice(COLOR_REF_PREFIX.length);\n return isOneOf(SINGLE_COLOR_ANCHOR_NAMES, name) ? name : undefined;\n};\n\nexport const singleColorRefList = (): string =>\n list(SINGLE_COLOR_ANCHOR_NAMES.map((name) => `${COLOR_REF_PREFIX}${name}`));\n\nexport const isScaleOffset = (value: unknown): boolean =>\n typeof value === 'number' &&\n Number.isInteger(value) &&\n value >= 0 &&\n value <= MAX_COLOR_SCALE_OFFSET;\n\n/** A non-negative number of CSS pixels — the same convention as `border.width`. */\nconst isPixelValue = (value: unknown): boolean =>\n typeof value === 'number' && Number.isFinite(value) && value >= 0;\n\n/** A length: a brand token or a number of CSS pixels. */\nexport const isDimension = (value: unknown): boolean => isPixelValue(value) || isTokenRef(value);\n","import type { AnchorGroup } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue, StyleDocumentReport } from './issues';\nimport { at, isOneOf, isRecord, isString } from '../private/guards';\nimport { FONT_STACK_PATTERN } from '../private/styleDocumentPatterns';\nimport {\n ANCHOR_GROUPS,\n ANCHORS_REQUIRED_BY_TREATMENT,\n COLOR_ANCHOR_NAMES,\n MAX_GRADIENT_STOPS,\n MIN_GRADIENT_STOPS,\n OPTIONAL_COLOR_ANCHORS,\n REQUIRED_COLOR_ANCHORS,\n REQUIRED_DIMENSION_ANCHORS,\n REQUIRED_FONT_ANCHORS,\n} from '../styleVocabulary';\nimport { COLOR_FORM_MESSAGE, isColorForm, isDimension, isTokenRef } from './anchorValues';\nimport { checkNoUnknownKeys } from './issues';\n\nconst isFontStack = (value: unknown): boolean => isString(value) && FONT_STACK_PATTERN.test(value);\n\n/**\n * `gradientStops` is always a list because a gradient interpolates between colors.\n * The other color anchors are always a single color.\n */\nconst checkColorAnchor = (\n value: unknown,\n path: string,\n { asStops = false }: { readonly asStops?: boolean } = {},\n): readonly StyleDocumentIssue[] => {\n if (!asStops) {\n return isColorForm(value) ? [] : [{ message: COLOR_FORM_MESSAGE, path }];\n }\n\n if (!Array.isArray(value)) {\n return [\n { message: `must be a list of ${MIN_GRADIENT_STOPS}-${MAX_GRADIENT_STOPS} colors`, path },\n ];\n }\n\n const countMessage = `a gradient needs ${MIN_GRADIENT_STOPS}-${MAX_GRADIENT_STOPS} stops, not ${value.length}`;\n\n // A list over the limit has to be rewritten anyway, and its length may be far beyond its contents.\n if (value.length > MAX_GRADIENT_STOPS) {\n return [{ message: countMessage, path }];\n }\n\n const countIssues: readonly StyleDocumentIssue[] =\n value.length < MIN_GRADIENT_STOPS ? [{ message: countMessage, path }] : [];\n\n return [\n ...countIssues,\n ...Array.from(value, (stop: unknown, index: number): readonly StyleDocumentIssue[] =>\n isColorForm(stop) ? [] : [{ message: COLOR_FORM_MESSAGE, path: `${path}.${index}` }],\n ).flat(),\n ];\n};\n\nconst ALWAYS_DECLARED_MESSAGE =\n 'mirrors a Brand Kit input, so every Style declares it, whether or not it is used';\n\nconst UNUSED_ANCHOR_MESSAGE =\n 'nothing references it and no treatment needs it, so the engine ignores it';\n\n/** A group's members once it is known to be present and shaped right, alongside what was wrong. */\ntype AnchorGroupResult = {\n readonly members: Readonly<Record<string, unknown>> | undefined;\n readonly issues: readonly StyleDocumentIssue[];\n};\n\nconst checkAnchorGroup = (\n anchors: Readonly<Record<string, unknown>>,\n group: AnchorGroup,\n members: readonly string[],\n label: string,\n): AnchorGroupResult => {\n const path = `anchors.${group}`;\n const value = at(anchors, group);\n\n if (value === undefined) {\n return {\n members: undefined,\n issues: [{ message: 'every Style declares every anchor group', path }],\n };\n }\n if (!isRecord(value)) {\n return { members: undefined, issues: [{ message: 'must be an object', path }] };\n }\n\n return { members: value, issues: checkNoUnknownKeys(value, members, path, label) };\n};\n\nconst checkDimensionAnchors = (\n dimensions: Readonly<Record<string, unknown>>,\n): readonly StyleDocumentIssue[] =>\n REQUIRED_DIMENSION_ANCHORS.flatMap((name): readonly StyleDocumentIssue[] => {\n const path = `anchors.dimensions.${name}`;\n const declared = at(dimensions, name);\n\n if (declared === undefined) {\n return [{ message: ALWAYS_DECLARED_MESSAGE, path }];\n }\n if (!isDimension(declared)) {\n return [\n { message: `${name} must be a token reference or a number of pixels, e.g. 20`, path },\n ];\n }\n\n return [];\n });\n\nconst checkFontAnchors = (\n fonts: Readonly<Record<string, unknown>>,\n): readonly StyleDocumentIssue[] =>\n REQUIRED_FONT_ANCHORS.flatMap((name): readonly StyleDocumentIssue[] => {\n const path = `anchors.fonts.${name}`;\n const declared = at(fonts, name);\n\n if (declared === undefined) {\n return [{ message: ALWAYS_DECLARED_MESSAGE, path }];\n }\n if (!isTokenRef(declared) && !isFontStack(declared)) {\n return [\n {\n message: `${name} must be a token reference, e.g. \"$${name}FontFamily\", or a font stack ending in a generic family, e.g. \"'Fraunces', Georgia, serif\"`,\n path,\n },\n ];\n }\n\n return [];\n });\n\nconst checkColorAnchors = (\n colors: Readonly<Record<string, unknown>>,\n collected: Collected,\n): StyleDocumentReport => {\n const declaredIssues = COLOR_ANCHOR_NAMES.flatMap((name): readonly StyleDocumentIssue[] => {\n const declared = at(colors, name);\n\n return declared === undefined\n ? []\n : checkColorAnchor(declared, `anchors.colors.${name}`, {\n asStops: name === 'gradientStops',\n });\n });\n\n // The brand's own colors are always declared, referenced or not.\n const missingRequired = REQUIRED_COLOR_ANCHORS.filter(\n (name) => at(colors, name) === undefined,\n ).map((name) => ({ message: ALWAYS_DECLARED_MESSAGE, path: `anchors.colors.${name}` }));\n\n // Treatment colors are declared only where they are needed — and must be, when they are.\n const needed = new Set(collected.referenced);\n for (const treatment of collected.treatments) {\n for (const anchor of ANCHORS_REQUIRED_BY_TREATMENT[treatment]) {\n needed.add(anchor);\n }\n }\n\n const missingNeeded = [...needed]\n .filter(\n (anchor) => !isOneOf(REQUIRED_COLOR_ANCHORS, anchor) && at(colors, anchor) === undefined,\n )\n .map((anchor) => ({\n message: 'referenced by a surface or required by a treatment, but not declared',\n path: `anchors.colors.${anchor}`,\n }));\n\n // And nowhere else: an unreachable treatment color is dead weight, usually a copied document.\n // It changes nothing about how the document renders, so it is a warning rather than an error.\n const warnings = OPTIONAL_COLOR_ANCHORS.filter(\n (anchor) => at(colors, anchor) !== undefined && !needed.has(anchor),\n ).map((anchor) => ({ message: UNUSED_ANCHOR_MESSAGE, path: `anchors.colors.${anchor}` }));\n\n return { errors: [...declaredIssues, ...missingRequired, ...missingNeeded], warnings };\n};\n\nexport const checkAnchors = (value: unknown, collected: Collected): StyleDocumentReport => {\n if (!isRecord(value)) {\n return { errors: [{ message: 'must be an object', path: 'anchors' }], warnings: [] };\n }\n\n const dimensions = checkAnchorGroup(\n value,\n 'dimensions',\n REQUIRED_DIMENSION_ANCHORS,\n 'dimension anchor',\n );\n const colors = checkAnchorGroup(value, 'colors', COLOR_ANCHOR_NAMES, 'color anchor');\n const fonts = checkAnchorGroup(value, 'fonts', REQUIRED_FONT_ANCHORS, 'font anchor');\n\n const colorReport: StyleDocumentReport =\n colors.members === undefined\n ? { errors: [], warnings: [] }\n : checkColorAnchors(colors.members, collected);\n\n return {\n errors: [\n ...checkNoUnknownKeys(value, ANCHOR_GROUPS, 'anchors', 'anchor group'),\n ...dimensions.issues,\n ...(dimensions.members === undefined ? [] : checkDimensionAnchors(dimensions.members)),\n ...colors.issues,\n ...colorReport.errors,\n ...fonts.issues,\n ...(fonts.members === undefined ? [] : checkFontAnchors(fonts.members)),\n ],\n warnings: colorReport.warnings,\n };\n};\n","import type { SurfaceName } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport {\n INVERT_RULES,\n MAX_COLOR_SCALE_OFFSET,\n OFFSET_ORIGINS,\n STACKABLE_ON,\n} from '../styleVocabulary';\nimport { isScaleOffset, singleColorAnchorFromRef, singleColorRefList } from './anchorValues';\nimport { checkNoUnknownKeys, list } from './issues';\n\n/**\n * A surface's fill: an anchor, or `parent` on a surface that sits on something.\n * Since a `flat` surface with an offset of `parent: 0` is essentially transparent,\n * we reject that syntax in favor of `treatment: \"none\"` — unless it inverts\n * `when-indistinct`, which always fires at that offset and paints the text color instead.\n */\nexport const checkBackgroundColor = (\n value: unknown,\n path: string,\n surface: SurfaceName,\n treatment: unknown,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(\n value,\n ['source', 'offset', 'from', 'invert'],\n path,\n 'backgroundColor key',\n ),\n ];\n\n const from = at(value, 'from');\n if (!isOneOf(OFFSET_ORIGINS, from)) {\n issues.push({ message: `from must be one of: ${list(OFFSET_ORIGINS)}`, path: `${path}.from` });\n } else if (from === 'parent' && STACKABLE_ON[surface].length === 0) {\n issues.push({\n message: `\"parent\" needs a surface to count from, and ${surface} sits on nothing — use \"source\"`,\n path: `${path}.from`,\n });\n }\n\n const invert = at(value, 'invert');\n if (!isOneOf(INVERT_RULES, invert)) {\n issues.push({\n message: `invert must be one of: ${list(INVERT_RULES)}`,\n path: `${path}.invert`,\n });\n } else if (invert === 'when-indistinct' && STACKABLE_ON[surface].length === 0) {\n issues.push({\n message: `\"when-indistinct\" compares a fill with what it sits on, and ${surface} sits on nothing — use \"never\"`,\n path: `${path}.invert`,\n });\n } else if (invert === 'when-indistinct' && treatment !== 'flat') {\n issues.push({\n message: 'only a flat fill can trade places with its text — use \"never\", or treatment \"flat\"',\n path: `${path}.invert`,\n });\n }\n\n const source = at(value, 'source');\n const offset = at(value, 'offset');\n const offsetIsValid = isScaleOffset(offset);\n\n if (source === 'parent') {\n if (STACKABLE_ON[surface].length === 0) {\n issues.push({\n message: `\"parent\" needs a surface to sit on, and ${surface} sits on nothing — use an anchor`,\n path: `${path}.source`,\n });\n } else if (treatment === 'flat' && invert === 'never' && offsetIsValid && offset === 0) {\n issues.push({\n message: `a flat surface at parent · 0 paints exactly its parent's fill and cannot be seen — step at least 1, invert \"when-indistinct\" to trade places with its text, or use treatment \"none\" to paint nothing`,\n path: `${path}.offset`,\n });\n }\n } else {\n const anchor = singleColorAnchorFromRef(source);\n if (anchor === undefined) {\n issues.push({\n message: `source must be \"parent\" or one of: ${singleColorRefList()}`,\n path: `${path}.source`,\n });\n } else {\n collected.referenced.add(anchor);\n }\n }\n\n if (!offsetIsValid) {\n issues.push({\n message: `offset must be an integer 0-${MAX_COLOR_SCALE_OFFSET}`,\n path: `${path}.offset`,\n });\n }\n\n return issues;\n};\n","import type { SurfaceName } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport { BORDER_STYLES, MAX_COLOR_SCALE_OFFSET, STACKABLE_ON } from '../styleVocabulary';\nimport { isScaleOffset, singleColorAnchorFromRef, singleColorRefList } from './anchorValues';\nimport { checkNoUnknownKeys, list } from './issues';\n\nexport const checkBorder = (\n value: Readonly<Record<string, unknown>>,\n surfacePath: string,\n surface: SurfaceName,\n treatment: unknown,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n const path = `${surfacePath}.border`;\n const declared = Object.hasOwn(value, 'border');\n\n if (STACKABLE_ON[surface].length === 0) {\n return declared\n ? [\n {\n message: `${surface} sits on nothing and has no edge of its own, so it carries no border`,\n path,\n },\n ]\n : [];\n }\n\n if (!declared) {\n return [\n {\n message: 'every surface with an edge of its own declares a border, even one of width 0',\n path,\n },\n ];\n }\n\n const border = at(value, 'border');\n\n if (!isRecord(border)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(border, ['width', 'source', 'offset', 'style'], path, 'border key'),\n ];\n\n const style = at(border, 'style');\n if (!isOneOf(BORDER_STYLES, style)) {\n issues.push({ message: `style must be one of: ${list(BORDER_STYLES)}`, path: `${path}.style` });\n } else if (style === 'scalloped' && treatment === 'none') {\n issues.push({\n message:\n 'scallops are drawn in the surface\\'s own fill, and treatment \"none\" paints none — give the surface a fill, or use \"lace\"',\n path: `${path}.style`,\n });\n }\n\n const width = at(border, 'width');\n if (typeof width !== 'number' || !Number.isFinite(width) || width < 0) {\n issues.push({\n message: 'width must be a non-negative number of pixels, e.g. 1 or 0.5 (0 for none)',\n path: `${path}.width`,\n });\n }\n\n const borderSource = at(border, 'source');\n const borderAnchor = singleColorAnchorFromRef(borderSource);\n if (borderAnchor !== undefined) {\n collected.referenced.add(borderAnchor);\n } else if (borderSource !== 'surface') {\n issues.push({\n message: `source must be \"surface\" or one of: ${singleColorRefList()}`,\n path: `${path}.source`,\n });\n }\n\n if (!isScaleOffset(at(border, 'offset'))) {\n issues.push({\n message: `offset must be an integer 0-${MAX_COLOR_SCALE_OFFSET}`,\n path: `${path}.offset`,\n });\n }\n\n return issues;\n};\n","import type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport {\n ELEVATION_COLOR_SOURCE_KEYWORDS,\n ELEVATION_DEPTHS,\n ELEVATION_HARDNESSES,\n} from '../styleVocabulary';\nimport { isColorForm, singleColorAnchorFromRef, singleColorRefList } from './anchorValues';\nimport { checkNoUnknownKeys, list } from './issues';\n\nexport const checkElevation = (\n value: unknown,\n path: string,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['depth', 'hardness', 'source'], path, 'elevation key'),\n ];\n\n if (!isOneOf(ELEVATION_DEPTHS, at(value, 'depth'))) {\n issues.push({\n message: `depth must be one of: ${list(ELEVATION_DEPTHS)}`,\n path: `${path}.depth`,\n });\n }\n\n if (!isOneOf(ELEVATION_HARDNESSES, at(value, 'hardness'))) {\n issues.push({\n message: `hardness must be one of: ${list(ELEVATION_HARDNESSES)}`,\n path: `${path}.hardness`,\n });\n }\n\n const elevationSource = at(value, 'source');\n const elevationAnchor = singleColorAnchorFromRef(elevationSource);\n if (elevationAnchor !== undefined) {\n collected.referenced.add(elevationAnchor);\n } else if (\n !isOneOf(ELEVATION_COLOR_SOURCE_KEYWORDS, elevationSource) &&\n !isColorForm(elevationSource)\n ) {\n issues.push({\n message: `source must be one of: ${list(ELEVATION_COLOR_SOURCE_KEYWORDS)}, ${singleColorRefList()}, or a color — a hex or rgb() literal, a token reference like \"$primaryColor\", or { from, relation, tone }`,\n path: `${path}.source`,\n });\n }\n\n return issues;\n};\n","import type { GradientShapeOption } from '../styleVocabulary';\nimport type { StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport {\n GRADIENT_DIRECTIONS,\n GRADIENT_EXTENTS,\n GRADIENT_POSITIONS,\n GRADIENT_SHAPE_OPTIONS,\n} from '../styleVocabulary';\nimport { checkNoUnknownKeys, list } from './issues';\n\n/** Every key a gradientShape may carry, and which kinds each option belongs to. */\nconst GRADIENT_SHAPE_KEYS = ['kind', 'direction', 'position', 'extent'] as const;\nconst KIND_SPECIFIC_KEYS: readonly (readonly [\n key: string,\n kinds: readonly GradientShapeOption[],\n allowed: readonly string[],\n])[] = [\n ['direction', ['linear'], GRADIENT_DIRECTIONS],\n ['position', ['radial'], GRADIENT_POSITIONS],\n ['extent', ['radial'], GRADIENT_EXTENTS],\n];\n\n/**\n * `gradientShape` is the one setting a surface carries conditionally: required when the treatment\n * is `gradient`, absent otherwise. Naming a shape on a surface that paints no gradient is an error\n * rather than a line that silently does nothing — the same reason unknown keys are caught.\n */\nexport const checkGradientShape = (\n value: Record<string, unknown>,\n path: string,\n treatment: unknown,\n): readonly StyleDocumentIssue[] => {\n const declared = Object.hasOwn(value, 'gradientShape');\n\n if (treatment !== 'gradient') {\n return declared\n ? [\n {\n message: 'only a surface with treatment \"gradient\" carries a gradientShape',\n path: `${path}.gradientShape`,\n },\n ]\n : [];\n }\n\n if (!declared) {\n return [\n {\n message: `a gradient surface must name its shape: ${list(GRADIENT_SHAPE_OPTIONS)}`,\n path: `${path}.gradientShape`,\n },\n ];\n }\n\n const shape = at(value, 'gradientShape');\n const shapePath = `${path}.gradientShape`;\n\n if (!isRecord(shape)) {\n return [{ message: 'must be an object', path: shapePath }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(shape, GRADIENT_SHAPE_KEYS, shapePath, 'setting'),\n ];\n\n const kind = at(shape, 'kind');\n\n if (!isOneOf(GRADIENT_SHAPE_OPTIONS, kind)) {\n issues.push({\n message: `kind must be one of: ${list(GRADIENT_SHAPE_OPTIONS)}`,\n path: `${shapePath}.kind`,\n });\n\n return issues;\n }\n\n /**\n * Each arrangement carries exactly what it needs to be drawn and nothing else, so a direction on\n * a radial gradient is an error rather than a line the engine quietly ignores.\n */\n for (const [key, kinds, allowed] of KIND_SPECIFIC_KEYS) {\n const wanted = kinds.includes(kind);\n const present = Object.hasOwn(shape, key);\n\n if (wanted && !present) {\n issues.push({\n message: `a ${kind} gradient must name its ${key}: ${list(allowed)}`,\n path: `${shapePath}.${key}`,\n });\n } else if (!wanted && present) {\n issues.push({\n message: `only a ${list(kinds)} gradient carries a ${key}`,\n path: `${shapePath}.${key}`,\n });\n } else if (wanted && !isOneOf(allowed, at(shape, key))) {\n issues.push({\n message: `${key} must be one of: ${list(allowed)}`,\n path: `${shapePath}.${key}`,\n });\n }\n }\n\n return issues;\n};\n","import type { StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport { AMBIENT_MOTIONS, MOTION_SPEEDS, TRANSITIONS } from '../styleVocabulary';\nimport { checkNoUnknownKeys, list } from './issues';\n\nexport const checkMotion = (value: unknown, path: string): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['ambient', 'speed', 'transition'], path, 'motion key'),\n ];\n\n if (!isOneOf(AMBIENT_MOTIONS, at(value, 'ambient'))) {\n issues.push({\n message: `ambient must be one of: ${list(AMBIENT_MOTIONS)}`,\n path: `${path}.ambient`,\n });\n }\n if (!isOneOf(MOTION_SPEEDS, at(value, 'speed'))) {\n issues.push({\n message: `speed must be one of: ${list(MOTION_SPEEDS)}`,\n path: `${path}.speed`,\n });\n }\n if (!isOneOf(TRANSITIONS, at(value, 'transition'))) {\n issues.push({\n message: `transition must be one of: ${list(TRANSITIONS)}`,\n path: `${path}.transition`,\n });\n }\n\n return issues;\n};\n","import type { StyleDocumentIssue } from './issues';\nimport { at, isRecord } from '../private/guards';\nimport { ANCHOR_REF_PREFIX } from '../styleVocabulary';\nimport { isDimension } from './anchorValues';\nimport { checkNoUnknownKeys } from './issues';\n\nconst BORDER_RADIUS_REF = `${ANCHOR_REF_PREFIX}dimensions.borderRadius`;\n\n/** Only the border-radius anchor: any other length, such as a spacing value, is not a radius. */\nconst isRadiusSource = (value: unknown): boolean =>\n value === BORDER_RADIUS_REF || isDimension(value);\n\nexport const checkRadius = (value: unknown, path: string): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['source'], path, 'radius key'),\n ];\n\n if (!isRadiusSource(at(value, 'source'))) {\n issues.push({\n message: `source must be \"${BORDER_RADIUS_REF}\", a token reference, or a number of pixels`,\n path: `${path}.source`,\n });\n }\n\n return issues;\n};\n","import type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isRecord } from '../private/guards';\nimport { MAX_COLOR_SCALE_OFFSET } from '../styleVocabulary';\nimport {\n isColorForm,\n isScaleOffset,\n singleColorAnchorFromRef,\n singleColorRefList,\n} from './anchorValues';\nimport { checkNoUnknownKeys } from './issues';\n\nexport const checkTextColor = (\n value: unknown,\n path: string,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n const anchor = singleColorAnchorFromRef(value);\n if (anchor !== undefined) {\n collected.referenced.add(anchor);\n return [];\n }\n if (value === 'derive' || isColorForm(value)) {\n return [];\n }\n if (!isRecord(value) || Object.hasOwn(value, 'from')) {\n return [\n {\n message: `textColor must be \"derive\", { source, offset }, one of: ${singleColorRefList()}, or a color — a hex or rgb() literal, a token reference like \"$primaryColor\", or { from, relation, tone }`,\n path,\n },\n ];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['source', 'offset'], path, 'textColor key'),\n ];\n\n const source = singleColorAnchorFromRef(at(value, 'source'));\n if (source === undefined) {\n issues.push({\n message: `source must be one of: ${singleColorRefList()}`,\n path: `${path}.source`,\n });\n } else {\n collected.referenced.add(source);\n }\n\n if (!isScaleOffset(at(value, 'offset'))) {\n issues.push({\n message: `offset must be an integer 0-${MAX_COLOR_SCALE_OFFSET}`,\n path: `${path}.offset`,\n });\n }\n\n return issues;\n};\n","import type { StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport { TEXTURE_INTENSITIES, TEXTURE_KINDS } from '../styleVocabulary';\nimport { checkNoUnknownKeys, list } from './issues';\n\n/**\n * A named texture at a named intensity. A surface that paints nothing has no fill to lay a\n * texture over, so `treatment: \"none\"` requires `kind: \"none\"`.\n */\nexport const checkTexture = (\n value: unknown,\n path: string,\n treatment: unknown,\n): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['kind', 'intensity'], path, 'texture key'),\n ];\n\n const kind = at(value, 'kind');\n if (!isOneOf(TEXTURE_KINDS, kind)) {\n issues.push({ message: `kind must be one of: ${list(TEXTURE_KINDS)}`, path: `${path}.kind` });\n } else if (treatment === 'none' && kind !== 'none') {\n issues.push({\n message:\n 'a surface with treatment \"none\" paints no fill to texture — use kind \"none\", or give the surface a fill',\n path: `${path}.kind`,\n });\n }\n\n if (!isOneOf(TEXTURE_INTENSITIES, at(value, 'intensity'))) {\n issues.push({\n message: `intensity must be one of: ${list(TEXTURE_INTENSITIES)}`,\n path: `${path}.intensity`,\n });\n }\n\n return issues;\n};\n","import type { SurfaceName } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord } from '../private/guards';\nimport { ALL_SETTING_NAMES, SURFACE_NAMES, TREATMENTS } from '../styleVocabulary';\nimport { checkBackgroundColor } from './backgroundColor';\nimport { checkBorder } from './border';\nimport { checkElevation } from './elevation';\nimport { checkGradientShape } from './gradientShape';\nimport { checkNoUnknownKeys, list } from './issues';\nimport { checkMotion } from './motion';\nimport { checkRadius } from './radius';\nimport { checkTextColor } from './textColor';\nimport { checkTexture } from './texture';\n\nconst checkSurface = (\n value: unknown,\n name: SurfaceName,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n const path = `surfaces.${name}`;\n\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const treatment = at(value, 'treatment');\n const namedTreatment = isOneOf(TREATMENTS, treatment);\n\n if (namedTreatment) {\n collected.treatments.add(treatment);\n }\n\n return [\n ...checkNoUnknownKeys(value, ALL_SETTING_NAMES, path, 'setting'),\n ...(namedTreatment\n ? []\n : [\n {\n message: `treatment must be one of: ${list(TREATMENTS)}`,\n path: `${path}.treatment`,\n },\n ]),\n ...checkGradientShape(value, path, treatment),\n ...checkBackgroundColor(\n at(value, 'backgroundColor'),\n `${path}.backgroundColor`,\n name,\n treatment,\n collected,\n ),\n ...checkTextColor(at(value, 'textColor'), `${path}.textColor`, collected),\n ...checkBorder(value, path, name, treatment, collected),\n ...checkElevation(at(value, 'elevation'), `${path}.elevation`, collected),\n ...checkRadius(at(value, 'radius'), `${path}.radius`),\n ...checkTexture(at(value, 'texture'), `${path}.texture`, treatment),\n ...checkMotion(at(value, 'motion'), `${path}.motion`),\n ];\n};\n\nexport const checkSurfaces = (\n value: unknown,\n collected: Collected,\n): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path: 'surfaces' }];\n }\n\n const unknown = Object.keys(value)\n .filter((key) => !isOneOf(SURFACE_NAMES, key))\n .map((key) => ({\n message: `unknown surface — the set is fixed: ${list(SURFACE_NAMES)}`,\n path: `surfaces.${key}`,\n }));\n\n return [\n ...unknown,\n ...SURFACE_NAMES.flatMap((name) => {\n const surface = at(value, name);\n\n return surface === undefined\n ? [{ message: 'every Style must define every surface', path: `surfaces.${name}` }]\n : checkSurface(surface, name, collected);\n }),\n ];\n};\n","import type { StyleDocumentIssue } from './issues';\nimport { at, isOneOf, isRecord, isString } from '../private/guards';\nimport {\n ANCHOR_REF_PREFIX,\n REQUIRED_FONT_ANCHORS,\n TYPE_CASES,\n TYPE_ROLES,\n} from '../styleVocabulary';\nimport { checkNoUnknownKeys, list } from './issues';\n\nconst FONT_REF_PREFIX = `${ANCHOR_REF_PREFIX}fonts.`;\n\nconst fontRefList = (): string =>\n list(REQUIRED_FONT_ANCHORS.map((name) => `${FONT_REF_PREFIX}${name}`));\n\nconst isFontAnchorRef = (value: unknown): boolean =>\n isString(value) &&\n value.startsWith(FONT_REF_PREFIX) &&\n isOneOf(REQUIRED_FONT_ANCHORS, value.slice(FONT_REF_PREFIX.length));\n\nconst checkTypeRole = (value: unknown, path: string): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path }];\n }\n\n const issues: StyleDocumentIssue[] = [\n ...checkNoUnknownKeys(value, ['font', 'fontSize', 'case', 'fontWeight'], path, 'type key'),\n ];\n\n if (!isFontAnchorRef(at(value, 'font'))) {\n issues.push({ message: `font must be one of: ${fontRefList()}`, path: `${path}.font` });\n }\n const fontSize = at(value, 'fontSize');\n if (typeof fontSize !== 'number' || !Number.isFinite(fontSize) || fontSize <= 0) {\n issues.push({\n message: 'fontSize must be a positive number of pixels, e.g. 16',\n path: `${path}.fontSize`,\n });\n }\n if (!isOneOf(TYPE_CASES, at(value, 'case'))) {\n issues.push({ message: `case must be one of: ${list(TYPE_CASES)}`, path: `${path}.case` });\n }\n const fontWeight = at(value, 'fontWeight');\n if (\n typeof fontWeight !== 'number' ||\n !Number.isFinite(fontWeight) ||\n fontWeight < 1 ||\n fontWeight > 1000\n ) {\n issues.push({\n message: 'fontWeight must be a CSS weight from 1 to 1000, e.g. 400 or 700',\n path: `${path}.fontWeight`,\n });\n }\n\n return issues;\n};\n\nexport const checkTypography = (value: unknown): readonly StyleDocumentIssue[] => {\n if (!isRecord(value)) {\n return [{ message: 'must be an object', path: 'typography' }];\n }\n\n return [\n ...checkNoUnknownKeys(value, TYPE_ROLES, 'typography', 'type role'),\n ...TYPE_ROLES.flatMap((role) => checkTypeRole(at(value, role), `typography.${role}`)),\n ];\n};\n","import type { StyleDocument } from '../styleVocabulary';\nimport type { Collected, StyleDocumentIssue, StyleDocumentReport } from './issues';\nimport { at, isRecord, isString } from '../private/guards';\nimport { ID_PATTERN } from '../private/styleDocumentPatterns';\nimport { DOCUMENT_KEYS } from '../styleVocabulary';\nimport { checkAnchors } from './anchors';\nimport { checkNoUnknownKeys } from './issues';\nimport { checkSurfaces } from './surfaces';\nimport { checkTypography } from './typography';\n\n/**\n * Structural validation for a Style document, based on the schema.\n *\n * @param input a parsed Style document, of unknown shape\n * @returns every problem found, split into errors, which make the document invalid, and\n * warnings, which do not\n *\n * @example\n * ```ts\n * const { errors, warnings } = checkStyleDocument(doc);\n * for (const { path, message } of warnings) {\n * console.warn(`${path}: ${message}`);\n * }\n * if (errors.length > 0) {\n * throw new Error(errors.map(({ path, message }) => `${path}: ${message}`).join('\\n'));\n * }\n * ```\n */\nexport const checkStyleDocument = (input: unknown): StyleDocumentReport => {\n if (!isRecord(input)) {\n return { errors: [{ message: 'a Style document must be an object', path: '' }], warnings: [] };\n }\n\n const issues: StyleDocumentIssue[] = [...checkNoUnknownKeys(input, DOCUMENT_KEYS, '', 'key')];\n const collected: Collected = { referenced: new Set(), treatments: new Set() };\n\n const id = at(input, 'id');\n if (!isString(id) || !ID_PATTERN.test(id)) {\n issues.push({ message: 'id must be lowercase kebab-case, e.g. \"glass-dark\"', path: 'id' });\n }\n\n const name = at(input, 'name');\n if (!isString(name) || name.length === 0) {\n issues.push({ message: 'name is required', path: 'name' });\n }\n\n if (at(input, 'schemaVersion') !== 1) {\n issues.push({ message: 'schemaVersion must be 1', path: 'schemaVersion' });\n }\n\n const surfaceIssues = [\n ...checkTypography(at(input, 'typography')),\n ...checkSurfaces(at(input, 'surfaces'), collected),\n ];\n\n // checkSurfaces fills `collected`, which anchor completeness reads, so anchors run last.\n const anchors = checkAnchors(at(input, 'anchors'), collected);\n\n issues.push(...surfaceIssues, ...anchors.errors);\n\n return { errors: issues, warnings: anchors.warnings };\n};\n\n/**\n * What makes a document invalid, and nothing else.\n *\n * Empty means the document is safe to render, so a caller can drop a document on a non-empty\n * result without reading it — the reason warnings are a separate channel rather than entries\n * here with a severity on them. Nothing inert should ever cost a customer their Style.\n *\n * @example\n * ```ts\n * const issues = validateStyleDocument(doc);\n * if (issues.length > 0) {\n * throw new Error(issues.map(({ path, message }) => `${path}: ${message}`).join('\\n'));\n * }\n * ```\n */\nexport const validateStyleDocument = (input: unknown): readonly StyleDocumentIssue[] =>\n checkStyleDocument(input).errors;\n\n/** Whether a value is a valid Style document. */\nexport const isStyleDocument = (input: unknown): input is StyleDocument =>\n validateStyleDocument(input).length === 0;\n"],"mappings":";;;;;;;;;;;;;AAMA,MAAa,aAAqB;;AAGlC,MAAa,gBAAwB;AAErC,MAAM,YAAY,OAAO,GAAG;;AAG5B,MAAM,YAAY,OAAO,GAAG;;;;;;;;;AAU5B,MAAM,YAAY,OA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C;GAAE,SAAS;GAAsC,MAAM;EAAG,CAAC;EAAG,UAAU,CAAC;CAAE;CAG/F,MAAM,SAA+B,CAAC,GAAG,mBAAmB,OAAO,eAAe,IAAI,KAAK,CAAC;CAC5F,MAAM,YAAuB;EAAE,4BAAY,IAAI,IAAI;EAAG,4BAAY,IAAI,IAAI;CAAE;CAE5E,MAAM,KAAK,GAAG,OAAO,IAAI;CACzB,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,KAAK,EAAE,GACtC,OAAO,KAAK;EAAE,SAAS;EAAsD,MAAM;CAAK,CAAC;CAG3F,MAAM,OAAO,GAAG,OAAO,MAAM;CAC7B,IAAI,CAAC,SAAS,IAAI,KAAK,KAAK,WAAW,GACrC,OAAO,KAAK;EAAE,SAAS;EAAoB,MAAM;CAAO,CAAC;CAG3D,IAAI,GAAG,OAAO,eAAe,MAAM,GACjC,OAAO,KAAK;EAAE,SAAS;EAA2B,MAAM;CAAgB,CAAC;CAG3E,MAAM,gBAAgB,CACpB,GAAG,gBAAgB,GAAG,OAAO,YAAY,CAAC,GAC1C,GAAG,cAAc,GAAG,OAAO,UAAU,GAAG,SAAS,CACnD;CAGA,MAAM,UAAU,aAAa,GAAG,OAAO,SAAS,GAAG,SAAS;CAE5D,OAAO,KAAK,GAAG,eAAe,GAAG,QAAQ,MAAM;CAE/C,OAAO;EAAE,QAAQ;EAAQ,UAAU,QAAQ;CAAS;AACtD;;;;;;;;;;;;;;;;AAiBA,MAAa,yBAAyB,UACpC,mBAAmB,KAAK,CAAC,CAAC;;AAG5B,MAAa,mBAAmB,UAC9B,sBAAsB,KAAK,CAAC,CAAC,WAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wistia/kaleidoscope",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Shared logic and token engine for Wistia's audience-facing design system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@types/react-dom": "^19.3.0",
|
|
67
67
|
"@typescript/native": "npm:typescript@7.1.0-beta",
|
|
68
68
|
"@vitest/coverage-v8": "^5.0.5",
|
|
69
|
-
"@wistia/ui": "3.
|
|
69
|
+
"@wistia/ui": "3.8.0",
|
|
70
70
|
"ajv": "^8.20.0",
|
|
71
71
|
"check-export-map": "^1.3.1",
|
|
72
72
|
"react": "^19.3.1",
|
package/styles/glass-dark.json
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"from": "source",
|
|
47
47
|
"invert": "never"
|
|
48
48
|
},
|
|
49
|
-
"textColor": "
|
|
49
|
+
"textColor": "#ffffff",
|
|
50
50
|
"elevation": {
|
|
51
51
|
"depth": "none",
|
|
52
52
|
"hardness": "soft",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
"from": "source",
|
|
74
74
|
"invert": "never"
|
|
75
75
|
},
|
|
76
|
-
"textColor": "
|
|
76
|
+
"textColor": "#ffffff",
|
|
77
77
|
"border": {
|
|
78
|
-
"width": 0
|
|
79
|
-
"source": "
|
|
80
|
-
"offset":
|
|
78
|
+
"width": 0,
|
|
79
|
+
"source": "surface",
|
|
80
|
+
"offset": 0,
|
|
81
81
|
"style": "solid"
|
|
82
82
|
},
|
|
83
83
|
"elevation": {
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
"from": "source",
|
|
107
107
|
"invert": "never"
|
|
108
108
|
},
|
|
109
|
-
"textColor": "
|
|
109
|
+
"textColor": "#ffffff",
|
|
110
110
|
"border": {
|
|
111
|
-
"width": 0
|
|
112
|
-
"source": "
|
|
113
|
-
"offset":
|
|
111
|
+
"width": 0,
|
|
112
|
+
"source": "surface",
|
|
113
|
+
"offset": 0,
|
|
114
114
|
"style": "solid"
|
|
115
115
|
},
|
|
116
116
|
"elevation": {
|
|
@@ -172,11 +172,11 @@
|
|
|
172
172
|
"from": "source",
|
|
173
173
|
"invert": "never"
|
|
174
174
|
},
|
|
175
|
-
"textColor": "
|
|
175
|
+
"textColor": "#ffffff",
|
|
176
176
|
"border": {
|
|
177
|
-
"width": 0
|
|
178
|
-
"source": "
|
|
179
|
-
"offset":
|
|
177
|
+
"width": 0,
|
|
178
|
+
"source": "surface",
|
|
179
|
+
"offset": 0,
|
|
180
180
|
"style": "solid"
|
|
181
181
|
},
|
|
182
182
|
"elevation": {
|
package/styles/glass-light.json
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"from": "source",
|
|
47
47
|
"invert": "never"
|
|
48
48
|
},
|
|
49
|
-
"textColor": "
|
|
49
|
+
"textColor": "#000000",
|
|
50
50
|
"elevation": {
|
|
51
51
|
"depth": "none",
|
|
52
52
|
"hardness": "soft",
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
"from": "source",
|
|
74
74
|
"invert": "never"
|
|
75
75
|
},
|
|
76
|
-
"textColor": "
|
|
76
|
+
"textColor": "#000000",
|
|
77
77
|
"border": {
|
|
78
|
-
"width": 0
|
|
79
|
-
"source": "
|
|
80
|
-
"offset":
|
|
78
|
+
"width": 0,
|
|
79
|
+
"source": "surface",
|
|
80
|
+
"offset": 0,
|
|
81
81
|
"style": "solid"
|
|
82
82
|
},
|
|
83
83
|
"elevation": {
|
|
84
|
-
"depth": "
|
|
84
|
+
"depth": "none",
|
|
85
85
|
"hardness": "soft",
|
|
86
86
|
"source": "shade"
|
|
87
87
|
},
|
|
@@ -106,15 +106,15 @@
|
|
|
106
106
|
"from": "source",
|
|
107
107
|
"invert": "never"
|
|
108
108
|
},
|
|
109
|
-
"textColor": "
|
|
109
|
+
"textColor": "#000000",
|
|
110
110
|
"border": {
|
|
111
|
-
"width": 0
|
|
112
|
-
"source": "
|
|
113
|
-
"offset":
|
|
111
|
+
"width": 0,
|
|
112
|
+
"source": "surface",
|
|
113
|
+
"offset": 0,
|
|
114
114
|
"style": "solid"
|
|
115
115
|
},
|
|
116
116
|
"elevation": {
|
|
117
|
-
"depth": "
|
|
117
|
+
"depth": "none",
|
|
118
118
|
"hardness": "soft",
|
|
119
119
|
"source": "shade"
|
|
120
120
|
},
|
|
@@ -167,16 +167,16 @@
|
|
|
167
167
|
"buttonSecondary": {
|
|
168
168
|
"treatment": "glassy",
|
|
169
169
|
"backgroundColor": {
|
|
170
|
-
"source": "
|
|
170
|
+
"source": "anchors.colors.ground",
|
|
171
171
|
"offset": 0,
|
|
172
172
|
"from": "source",
|
|
173
173
|
"invert": "never"
|
|
174
174
|
},
|
|
175
|
-
"textColor": "
|
|
175
|
+
"textColor": "#000000",
|
|
176
176
|
"border": {
|
|
177
|
-
"width": 0
|
|
178
|
-
"source": "
|
|
179
|
-
"offset":
|
|
177
|
+
"width": 0,
|
|
178
|
+
"source": "surface",
|
|
179
|
+
"offset": 0,
|
|
180
180
|
"style": "solid"
|
|
181
181
|
},
|
|
182
182
|
"elevation": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"engine-DeOUPRa0.js","names":[],"sources":["../src/brandTokens.ts","../src/private/engine/constants/color.ts","../src/private/engine/scale.ts","../src/private/engine/anchors.ts","../src/private/engine/rules/border.ts","../src/private/engine/constants/elevation.ts","../src/private/engine/rules/elevation.ts","../src/private/engine/kebab.ts","../src/private/engine/surfaces.ts","../src/private/engine/slots.ts","../src/private/engine/treatments/flat.ts","../src/private/engine/treatments/index.ts","../src/private/engine/rules/fill.ts","../src/private/engine/constants/motion.ts","../src/private/engine/rules/motion.ts","../src/private/engine/rules/panelInput.ts","../src/private/engine/constants/radius.ts","../src/private/engine/rules/radius.ts","../src/private/engine/rules/text.ts","../src/private/engine/constants/typography.ts","../src/private/engine/rules/typography.ts","../src/private/engine/contract.ts","../src/kaleidoscopeContract.ts","../src/private/engine/rules/invert.ts","../src/private/engine/evaluateSurfaces.ts","../src/private/engine/rules/texture.ts","../src/private/engine/support.ts","../src/getKaleidoscopeStyles.ts","../src/serializeKaleidoscopeStyles.ts"],"sourcesContent":["/** The Brand Kit tokens a Style document can reference, each as `$<name>`. */\nexport const BRAND_TOKEN_NAMES = [\n 'primaryColor',\n 'pageBackgroundColor',\n 'borderRadius',\n 'headingFontFamily',\n 'bodyFontFamily',\n 'buttonFontFamily',\n] as const;\nexport type BrandTokenName = (typeof BRAND_TOKEN_NAMES)[number];\n\n/**\n * The Brand Kit values `getKaleidoscopeStyles()` resolves a Style against. Colors are CSS colors,\n * `borderRadius` is in pixels, and the font families are CSS `font-family` values.\n *\n * Every token is optional: a token the Style references but the Brand Kit leaves out takes its\n * {@link DEFAULT_BRAND_TOKENS | default}.\n */\nexport type BrandTokens = {\n readonly bodyFontFamily?: string;\n readonly borderRadius?: number;\n readonly buttonFontFamily?: string;\n readonly headingFontFamily?: string;\n readonly pageBackgroundColor?: string;\n readonly primaryColor?: string;\n};\n\n/** What a missing Brand Kit token falls back to: Wistia's own brand. */\nexport const DEFAULT_BRAND_TOKENS: Required<BrandTokens> = {\n primaryColor: '#2949e5',\n pageBackgroundColor: '#ffffff',\n borderRadius: 20,\n headingFontFamily: 'GT Walsheim',\n bodyFontFamily: 'Inter',\n buttonFontFamily: 'Inter',\n};\n","import type { ColorRelationship } from '../../../styleVocabulary';\nimport { colorContrastRatiosByShape } from '../../../colorContrastRatiosByShape';\n\n/** Degrees a `relation` turns a hue, measured around the Lab a/b plane. Placeholder. */\nexport const RELATION_HUE_DEGREES = {\n same: 0,\n analogous: 30,\n triad: 120,\n complementary: 180,\n} satisfies Record<ColorRelationship, number>;\n\n/** Contrast below which a flat fill is pushed one more step from its parent. Placeholder. */\nexport const SEPARATION_MIN_CONTRAST = 1.1;\n\n/** WCAG non-text contrast: below this a fill does not read as a shape against its parent. */\nexport const INVERT_BELOW_CONTRAST = colorContrastRatiosByShape.nonText;\n\n/** How far low-emphasis text fades from the surface's text color. Placeholder. */\nexport const LOW_EMPHASIS_TEXT_ALPHA = 0.7;\n\n/** How far a hover fill must sit from the resting fill and the parent to be seen. */\nexport const HOVER_MIN_CONTRAST = 1.1;\n","import type { BrandedColorScale } from '../buildBrandedColorScale';\nimport { Color } from '../../Color';\nimport { getColorLightnessClassification } from '../../getColorLightnessClassification';\nimport { buildBrandedColorScale } from '../buildBrandedColorScale';\nimport { clamp } from '../clamp';\n\nexport type Scale = BrandedColorScale;\n\nconst MAX_CACHED_SCALES = 600;\nconst scaleCache = new Map<string, Scale>();\n\n/** The branded scale through `color`, cached because every surface of every Style asks for it. */\nexport const scaleOf = (color: Color): Scale => {\n const hex = color.toHex();\n let scale = scaleCache.get(hex);\n\n if (scale === undefined) {\n if (scaleCache.size >= MAX_CACHED_SCALES) {\n scaleCache.clear();\n }\n\n scale = buildBrandedColorScale(new Color(hex));\n scaleCache.set(hex, scale);\n }\n\n return scale;\n};\n\nconst lastStep = (scale: Scale): number => scale.steps - 1;\n\nexport const stepAt = (scale: Scale, index: number): Color =>\n scale.atStep(clamp(index, 0, lastStep(scale)));\n\nconst nearestStep = (scale: Scale, color: Color): number =>\n clamp(Math.round(scale.stepOf(color)), 0, lastStep(scale));\n\n/**\n * `offset` steps along `scale` from `color`, away from its lightness: a dark color steps lighter,\n * and a light or midtone one steps darker. The color decides, not its place on the scale, so a\n * page steps the same way whatever the brand.\n */\nexport const stepAlong = (scale: Scale, color: Color, offset: number): Color => {\n const position = nearestStep(scale, color);\n const lightness = getColorLightnessClassification(color);\n const direction = lightness === 'dark' || lightness === 'veryDark' ? -1 : 1;\n\n return stepAt(scale, position + direction * offset);\n};\n\nexport const stepFrom = (color: Color, offset: number): Color =>\n stepAlong(scaleOf(color), color, offset);\n\n/**\n * `offset` steps from `color` along its scale, away from `text`, so their contrast grows; a negative\n * offset steps towards it. A color with no room left on that side steps the other way, so it still\n * visibly changes.\n */\nexport const stepAwayFrom = (color: Color, text: Color, offset: number): Color => {\n const scale = scaleOf(color);\n const position = nearestStep(scale, color);\n const away = position + (text.luminance() > color.luminance() ? offset : -offset);\n\n return stepAt(scale, away >= 0 && away <= lastStep(scale) ? away : position * 2 - away);\n};\n","import type { BrandTokens } from '../../brandTokens';\nimport type {\n BrandKitTokenRef,\n Dimension,\n FontAnchorRef,\n SingleColor,\n SingleColorAnchorName,\n SingleColorAnchorRef,\n StyleDocument,\n} from '../../styleVocabulary';\nimport type { Scale } from './scale';\nimport { BRAND_TOKEN_NAMES, DEFAULT_BRAND_TOKENS } from '../../brandTokens';\nimport { Color } from '../../Color';\nimport { getBrandDarkBackgroundColor } from '../../getBrandDarkBackgroundColor';\nimport { getBrandLightBackgroundColor } from '../../getBrandLightBackgroundColor';\nimport { isOneOf } from '../guards';\nimport { RELATION_HUE_DEGREES } from './constants/color';\nimport { scaleOf } from './scale';\n\n/** A Style document's anchors, resolved once against the Brand Kit. */\nexport type ResolvedAnchors = {\n readonly borderRadius: number;\n readonly colors: Readonly<Record<SingleColorAnchorName, Color | null>>;\n readonly dimension: (value: Dimension) => number;\n readonly fonts: Readonly<Record<FontAnchorRef, string>>;\n /** For an anchor toned from a token, the token's own scale, so stepping keeps its hue. */\n readonly scales: Readonly<Record<SingleColorAnchorName, Scale | null>>;\n readonly tokens: BrandTokens;\n};\n\nconst isTokenRef = (value: string): value is BrandKitTokenRef => value.startsWith('$');\n\n/** A token the Brand Kit leaves out takes its default; a token no Brand Kit has is an error. */\nconst tokenValue = (tokens: BrandTokens, ref: BrandKitTokenRef): number | string => {\n const name = ref.slice(1);\n\n if (!isOneOf(BRAND_TOKEN_NAMES, name)) {\n throw new Error(`${ref} is not a Brand Kit token`);\n }\n\n return tokens[name] ?? DEFAULT_BRAND_TOKENS[name];\n};\n\nconst tokenColor = (tokens: BrandTokens, ref: BrandKitTokenRef): Color =>\n new Color(String(tokenValue(tokens, ref)));\n\n/** Turns a hue around the Lab a/b plane. */\nconst rotateHue = (color: Color, degrees: number): Color => {\n if (degrees === 0) {\n return color;\n }\n\n const lab = color.toLab();\n const radians = (degrees * Math.PI) / 180;\n const cos = Math.cos(radians);\n const sin = Math.sin(radians);\n\n return Color.fromLab(\n {\n lightness: lab.lightness,\n // oxlint-disable-next-line id-length -- the Lab axes are named a and b\n a: lab.a * cos - lab.b * sin,\n // oxlint-disable-next-line id-length -- the Lab axes are named a and b\n b: lab.a * sin + lab.b * cos,\n },\n color.a,\n );\n};\n\nexport const resolveSingleColor = (value: SingleColor, tokens: BrandTokens): Color => {\n if (typeof value === 'string') {\n return isTokenRef(value) ? tokenColor(tokens, value) : new Color(value);\n }\n\n const related = rotateHue(\n tokenColor(tokens, value.from),\n RELATION_HUE_DEGREES[value.relation ?? 'same'],\n );\n\n if (value.tone === 'dark') {\n return getBrandDarkBackgroundColor(related);\n }\n\n if (value.tone === 'light') {\n return getBrandLightBackgroundColor(related);\n }\n\n return related;\n};\n\n/**\n * A toned anchor is a point on its token's scale, so stepping from it should walk that scale.\n * Rebuilding a scale from a pale tone would keep almost none of the brand's hue.\n */\nconst scaleBeforeTone = (value: SingleColor | undefined, tokens: BrandTokens): Scale | null => {\n if (value === undefined || typeof value === 'string' || value.tone === undefined) {\n return null;\n }\n\n return scaleOf(\n rotateHue(tokenColor(tokens, value.from), RELATION_HUE_DEGREES[value.relation ?? 'same']),\n );\n};\n\nconst fontFrom = (value: string, tokens: BrandTokens): string =>\n isTokenRef(value) ? String(tokenValue(tokens, value)) : value;\n\nexport const resolveAnchors = (style: StyleDocument, tokens: BrandTokens): ResolvedAnchors => {\n const { colors, dimensions, fonts } = style.anchors;\n const dimension = (value: Dimension): number =>\n typeof value === 'number' ? value : Number(tokenValue(tokens, value));\n\n return {\n tokens,\n dimension,\n borderRadius: dimension(dimensions.borderRadius),\n colors: {\n pageBackground: resolveSingleColor(colors.pageBackground, tokens),\n primary: resolveSingleColor(colors.primary, tokens),\n ground: colors.ground === undefined ? null : resolveSingleColor(colors.ground, tokens),\n },\n scales: {\n pageBackground: scaleBeforeTone(colors.pageBackground, tokens),\n primary: scaleBeforeTone(colors.primary, tokens),\n ground: scaleBeforeTone(colors.ground, tokens),\n },\n fonts: {\n 'anchors.fonts.heading': fontFrom(fonts.heading, tokens),\n 'anchors.fonts.body': fontFrom(fonts.body, tokens),\n 'anchors.fonts.button': fontFrom(fonts.button, tokens),\n },\n };\n};\n\nconst ANCHOR_BY_REF: Readonly<Record<SingleColorAnchorRef, SingleColorAnchorName>> = {\n 'anchors.colors.pageBackground': 'pageBackground',\n 'anchors.colors.primary': 'primary',\n 'anchors.colors.ground': 'ground',\n};\n\nexport const anchorName = (ref: SingleColorAnchorRef): SingleColorAnchorName => ANCHOR_BY_REF[ref];\n\nexport const anchorColor = (ref: SingleColorAnchorRef, anchors: ResolvedAnchors): Color => {\n const color = anchors.colors[ANCHOR_BY_REF[ref]];\n\n if (color === null) {\n throw new Error(`${ref} is referenced but not declared`);\n }\n\n return color;\n};\n\n/** The scale stepping from an anchor walks: its token's if it's toned, or else its own. */\nexport const anchorScale = (ref: SingleColorAnchorRef, anchors: ResolvedAnchors): Scale =>\n anchors.scales[anchorName(ref)] ?? scaleOf(anchorColor(ref, anchors));\n","import type { Color } from '../../../Color';\nimport type { Border } from '../../../styleVocabulary';\nimport type { ResolvedAnchors } from '../anchors';\nimport type { Slots, SurfaceSlotFragment } from '../slots';\nimport type { FindGaps } from './types';\nimport { ORNAMENTAL_BORDER_STYLES, SURFACE_NAMES } from '../../../styleVocabulary';\nimport { anchorColor } from '../anchors';\nimport { stepFrom } from '../scale';\n\n/** The page sits on nothing and has no edge, so it carries no border. */\nexport const BORDER_SLOTS: SurfaceSlotFragment = {\n surfaces: SURFACE_NAMES.filter((name) => name !== 'page'),\n initialValues: {\n 'border-width': '0',\n 'border-style': 'none',\n 'border-color': 'transparent',\n },\n};\n\n/** A `width` of 0 keeps the initial values, so the surface has no edge whatever its source. */\nexport const borderSlots = (\n border: Border | undefined,\n solid: Color,\n anchors: ResolvedAnchors,\n): Slots => {\n if (border === undefined || border.width === 0) {\n return {};\n }\n\n const { offset, source, style, width } = border;\n const from = source === 'surface' ? solid : anchorColor(source, anchors);\n\n return {\n 'border-width': `${width}px`,\n 'border-style': style,\n 'border-color': stepFrom(from, offset).toHex(),\n };\n};\n\n/** An ornament is a drawn tile rather than a CSS border, and draws whatever the width. */\nexport const borderGaps: FindGaps = ({ border }) =>\n ORNAMENTAL_BORDER_STYLES.some((ornament) => ornament === border?.style)\n ? [`border.style: ${border?.style}`]\n : [];\n","import type { ElevationDepth, ElevationHardness } from '../../../styleVocabulary';\n\nexport type Shadow = {\n readonly alpha: number;\n readonly blur: number;\n readonly x: number;\n readonly y: number;\n};\n\n/**\n * The shadow each hardness casts at each depth. A pairing missing here is one the engine does not\n * resolve yet. `soft · low` is from the Phase 1 carousel sandbox.\n */\nexport const SHADOWS: Readonly<\n Partial<Record<ElevationHardness, Partial<Record<Exclude<ElevationDepth, 'none'>, Shadow>>>>\n> = {\n soft: { low: { x: 0, y: 8, blur: 32, alpha: 0.2 } },\n};\n","import type { Elevation } from '../../../styleVocabulary';\nimport type { Slots, SurfaceSlotFragment } from '../slots';\nimport type { FindGaps } from './types';\nimport { SURFACE_NAMES } from '../../../styleVocabulary';\nimport { SHADOWS } from '../constants/elevation';\n\nexport const ELEVATION_SLOTS: SurfaceSlotFragment = {\n surfaces: SURFACE_NAMES,\n initialValues: { 'box-shadow': 'none' },\n};\n\nexport const elevationSlots = ({ depth, hardness }: Elevation): Slots => {\n const shadow = depth === 'none' ? undefined : SHADOWS[hardness]?.[depth];\n\n if (shadow === undefined) {\n return {};\n }\n\n const { alpha, blur, x, y } = shadow;\n\n return { 'box-shadow': `${x}px ${y}px ${blur}px rgba(0, 0, 0, ${alpha})` };\n};\n\nexport const elevationGaps: FindGaps = ({ elevation: { depth, hardness, source } }) => {\n if (depth === 'none') {\n return [];\n }\n\n return [\n ...(SHADOWS[hardness]?.[depth] === undefined ? [`elevation: ${hardness} ${depth}`] : []),\n ...(source === 'shade' ? [] : [`elevation.source: ${JSON.stringify(source)}`]),\n ];\n};\n","/** `buttonPrimary` → `button-primary`, as surface names appear in variable names. */\nexport const kebab = (name: string): string =>\n name.replaceAll(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n","import type { SurfaceName } from '../../styleVocabulary';\nimport { STACKABLE_ON, SURFACE_NAMES } from '../../styleVocabulary';\nimport { kebab } from './kebab';\n\nexport type SurfaceSpec = {\n /** Page, panel and card hold copy, so they carry heading and low-emphasis text; a button doesn't. */\n readonly holdsContent: boolean;\n /** Hover, focus and active states: only for surfaces a viewer acts on. */\n readonly interactive: boolean;\n /** Forms live only in panels, so only a panel carries input slots. */\n readonly mayContainForm: boolean;\n};\n\n/** What the engine knows about each surface beyond what a Style document says. */\nexport const SURFACES: Readonly<Record<SurfaceName, SurfaceSpec>> = {\n page: { holdsContent: true, interactive: false, mayContainForm: false },\n panel: { holdsContent: true, interactive: false, mayContainForm: true },\n card: { holdsContent: true, interactive: true, mayContainForm: false },\n buttonPrimary: { holdsContent: false, interactive: true, mayContainForm: false },\n buttonSecondary: { holdsContent: false, interactive: true, mayContainForm: false },\n};\n\n/**\n * One evaluation of a surface: the surface on its only parent, or once per parent for a surface\n * that can sit on several, named `<surface>-on-<parent>`.\n */\nexport type SurfaceGroup = {\n readonly parent: SurfaceName | null;\n readonly prefix: string;\n readonly surface: SurfaceName;\n};\n\n/** Every surface group, parents before the surfaces that sit on them. */\nexport const SURFACE_GROUPS: readonly SurfaceGroup[] = SURFACE_NAMES.flatMap((surface) => {\n const parents = STACKABLE_ON[surface];\n\n if (parents.length <= 1) {\n return [{ surface, parent: parents[0] ?? null, prefix: kebab(surface) }];\n }\n\n return parents.map((parent) => ({\n surface,\n parent,\n prefix: `${kebab(surface)}-on-${kebab(parent)}`,\n }));\n});\n","import type { SurfaceName, TypeRoleName } from '../../styleVocabulary';\nimport type { SurfaceSpec } from './surfaces';\nimport { SURFACE_NAMES } from '../../styleVocabulary';\nimport { SURFACES } from './surfaces';\n\nexport const VARIABLE_PREFIX = '--wistia-kaleidoscope-';\nexport type VariableName = `${typeof VARIABLE_PREFIX}${string}`;\n\n/** Slot name → CSS value, for one surface group or one type role. */\nexport type Slots = Readonly<Record<string, string>>;\n\n/**\n * One rule's share of the contract: the slots it emits on each surface it applies to, with the\n * value each takes when a Style doesn't use the rule — the CSS initial value of the property the\n * slot feeds, or the value that draws nothing where the property has no fixed one.\n */\nexport type SurfaceSlotFragment = {\n readonly initialValues: Slots;\n readonly surfaces: readonly SurfaceName[];\n};\n\nexport const surfacesWhere = (flag: keyof SurfaceSpec): readonly SurfaceName[] =>\n SURFACE_NAMES.filter((name) => SURFACES[name][flag]);\n\nexport const surfaceVariable = (prefix: string, slot: string): VariableName =>\n `${VARIABLE_PREFIX}${prefix}-${slot}`;\n\nexport const typeVariable = (role: TypeRoleName, slot: string): VariableName =>\n `${VARIABLE_PREFIX}type-${role}-${slot}`;\n","import type { Scale } from '../scale';\nimport type { ResolvedFill, TreatmentFn, TreatmentResult } from './types';\nimport { Color } from '../../../Color';\nimport { anchorColor, anchorScale } from '../anchors';\nimport { HOVER_MIN_CONTRAST, SEPARATION_MIN_CONTRAST } from '../constants/color';\nimport { scaleOf, stepAlong, stepAwayFrom } from '../scale';\n\n/**\n * A step away from the text, unless that lands too close to the resting fill or the parent to be\n * seen. Then a step towards it, which relies on the hover text staying readable.\n */\nconst hoverFill = (solid: Color, text: Color, parent: ResolvedFill | null): Color => {\n // Measured as the hex it renders as, because a step can sit right on the threshold.\n const away = new Color(stepAwayFrom(solid, text, 1).toHex());\n const isVisible =\n away.contrast(solid) >= HOVER_MIN_CONTRAST &&\n (parent === null || away.contrast(parent.solid) >= HOVER_MIN_CONTRAST);\n\n return isVisible ? away : stepAwayFrom(solid, text, -1);\n};\n\n/** The slots that paint `solid` as a flat fill on `parent`. */\nexport const flatFill = (\n solid: Color,\n scale: Scale | null,\n parent: ResolvedFill | null,\n): TreatmentResult => ({\n solid,\n scale,\n fill: { 'background-color': solid.toHex() },\n hover: (text) => {\n const solidHover = hoverFill(solid, text, parent);\n\n return { solid: solidHover, slots: { 'background-color-hover': solidHover.toHex() } };\n },\n});\n\n/** A single opaque color, stepped along its source's scale. */\nexport const flat: TreatmentFn = ({ anchors, parent, settings }) => {\n const { from, offset, source } = settings.backgroundColor;\n const sourceColor =\n source === 'parent'\n ? (parent?.solid ?? anchorColor('anchors.colors.pageBackground', anchors))\n : anchorColor(source, anchors);\n const scale =\n source === 'parent' ? (parent?.scale ?? scaleOf(sourceColor)) : anchorScale(source, anchors);\n const start = from === 'parent' && parent !== null ? parent.solid : sourceColor;\n let solid = stepAlong(scale, start, offset);\n\n if (parent !== null && solid.contrast(parent.solid) < SEPARATION_MIN_CONTRAST) {\n solid = stepAlong(scale, start, offset + 1);\n }\n\n return flatFill(solid, scale, parent);\n};\n","import type { Treatment } from '../../../styleVocabulary';\nimport type { TreatmentFn } from './types';\nimport { flat } from './flat';\n\n/** The treatments the engine can paint. A Style using any other is not supported yet. */\nexport const TREATMENT_FUNCTIONS: Readonly<Partial<Record<Treatment, TreatmentFn>>> = {\n flat,\n};\n","import type { SurfaceSlotFragment } from '../slots';\nimport type { FindGaps } from './types';\nimport { SURFACE_NAMES } from '../../../styleVocabulary';\nimport { surfacesWhere } from '../slots';\nimport { TREATMENT_FUNCTIONS } from '../treatments';\n\n/**\n * A surface's fill. `background-image` holds layers drawn over `background-color` — glass sheens,\n * gradients — and `backdrop-filter` blurs what is behind a translucent fill.\n */\nexport const FILL_SLOTS: SurfaceSlotFragment = {\n surfaces: SURFACE_NAMES,\n initialValues: {\n 'background-color': 'transparent',\n 'background-image': 'none',\n 'backdrop-filter': 'none',\n },\n};\n\nexport const HOVER_FILL_SLOTS: SurfaceSlotFragment = {\n surfaces: surfacesWhere('interactive'),\n initialValues: {\n 'background-color-hover': 'transparent',\n 'background-image-hover': 'none',\n },\n};\n\nexport const fillGaps: FindGaps = ({ treatment }) =>\n Object.hasOwn(TREATMENT_FUNCTIONS, treatment) ? [] : [`treatment: ${treatment}`];\n","import type { Transition } from '../../../styleVocabulary';\n\n/** How long a surface takes to move between states. Placeholder. */\nexport const TRANSITION_DURATIONS = {\n none: null,\n quick: '120ms',\n smooth: '240ms',\n} satisfies Record<Transition, string | null>;\n\n/** The properties a state change animates. */\nexport const TRANSITIONED_PROPERTIES = ['background-color', 'box-shadow', 'border-color', 'color'];\n\nexport const TRANSITION_EASING = 'ease';\n","import type { Motion } from '../../../styleVocabulary';\nimport type { Slots, SurfaceSlotFragment } from '../slots';\nimport type { FindGaps } from './types';\nimport { SURFACE_NAMES } from '../../../styleVocabulary';\nimport {\n TRANSITION_DURATIONS,\n TRANSITION_EASING,\n TRANSITIONED_PROPERTIES,\n} from '../constants/motion';\n\nexport const MOTION_SLOTS: SurfaceSlotFragment = {\n surfaces: SURFACE_NAMES,\n initialValues: { transition: 'none', animation: 'none' },\n};\n\nexport const motionSlots = ({ transition }: Motion): Slots => {\n const duration = TRANSITION_DURATIONS[transition];\n\n if (duration === null) {\n return {};\n }\n\n return {\n transition: TRANSITIONED_PROPERTIES.map(\n (property) => `${property} ${duration} ${TRANSITION_EASING}`,\n ).join(', '),\n };\n};\n\n/** No ambient motion yet. */\nexport const motionGaps: FindGaps = ({ motion: { ambient } }) =>\n ambient === 'none' ? [] : [`motion.ambient: ${ambient}`];\n","import type { Color } from '../../../Color';\nimport type { ResolvedAnchors } from '../anchors';\nimport type { Slots, SurfaceSlotFragment } from '../slots';\nimport { anchorColor } from '../anchors';\nimport { stepFrom } from '../scale';\nimport { surfacesWhere } from '../slots';\n\n/** The form fields inside a panel. */\nexport const PANEL_INPUT_SLOTS: SurfaceSlotFragment = {\n surfaces: surfacesWhere('mayContainForm'),\n initialValues: {\n 'input-background-color': 'transparent',\n 'input-background-color-focus': 'transparent',\n 'input-border-color-focus': 'transparent',\n },\n};\n\n/** Inputs step off the panel's fill, and take the primary color when focused. */\nexport const panelInputSlots = (solid: Color, anchors: ResolvedAnchors): Slots => ({\n 'input-background-color': stepFrom(solid, 1).toHex(),\n 'input-background-color-focus': stepFrom(solid, 2).toHex(),\n 'input-border-color-focus': anchorColor('anchors.colors.primary', anchors).toHex(),\n});\n","import type { SurfaceName } from '../../../styleVocabulary';\n\n/** How the radius anchor scales on each surface. Placeholder. */\nexport const RADIUS_FACTORS = {\n page: 0,\n panel: 1,\n card: 0.7,\n buttonPrimary: 0.5,\n buttonSecondary: 0.5,\n} satisfies Record<SurfaceName, number>;\n","import type { Radius, SurfaceName } from '../../../styleVocabulary';\nimport type { ResolvedAnchors } from '../anchors';\nimport type { Slots, SurfaceSlotFragment } from '../slots';\nimport { SURFACE_NAMES } from '../../../styleVocabulary';\nimport { RADIUS_FACTORS } from '../constants/radius';\n\nexport const RADIUS_SLOTS: SurfaceSlotFragment = {\n surfaces: SURFACE_NAMES,\n initialValues: { 'border-radius': '0' },\n};\n\nexport const radiusSlots = (\n surface: SurfaceName,\n { source }: Radius,\n anchors: ResolvedAnchors,\n): Slots => ({\n 'border-radius':\n source === 'anchors.dimensions.borderRadius'\n ? `${Math.round(anchors.borderRadius * RADIUS_FACTORS[surface])}px`\n : `${anchors.dimension(source)}px`,\n});\n","import type { Color } from '../../../Color';\nimport type { SurfaceName, TextColor, TextColorPreference } from '../../../styleVocabulary';\nimport type { ResolvedAnchors } from '../anchors';\nimport type { Slots, SurfaceSlotFragment } from '../slots';\nimport type { FindGaps } from './types';\nimport { adjustColorForProperContrast } from '../../../adjustColorForProperContrast';\nimport { getBestColorForText } from '../../../getBestColorForText';\nimport { SURFACE_NAMES } from '../../../styleVocabulary';\nimport { anchorColor, anchorScale } from '../anchors';\nimport { LOW_EMPHASIS_TEXT_ALPHA } from '../constants/color';\nimport { stepAlong } from '../scale';\nimport { surfacesWhere } from '../slots';\nimport { SURFACES } from '../surfaces';\n\nexport const TEXT_SLOTS: SurfaceSlotFragment = {\n surfaces: SURFACE_NAMES,\n initialValues: { 'text-color': 'canvastext' },\n};\n\nexport const CONTENT_TEXT_SLOTS: SurfaceSlotFragment = {\n surfaces: surfacesWhere('holdsContent'),\n initialValues: {\n 'heading-text-color': 'canvastext',\n 'low-emphasis-text-color': 'canvastext',\n },\n};\n\nexport const HOVER_TEXT_SLOTS: SurfaceSlotFragment = {\n surfaces: surfacesWhere('interactive'),\n initialValues: { 'text-color-hover': 'canvastext' },\n};\n\nexport const CONTENT_HOVER_TEXT_SLOTS: SurfaceSlotFragment = {\n surfaces: surfacesWhere('interactive').filter((surface) => SURFACES[surface].holdsContent),\n initialValues: {\n 'heading-text-color-hover': 'canvastext',\n 'low-emphasis-text-color-hover': 'canvastext',\n },\n};\n\nconst isPreference = (textColor: TextColor): textColor is TextColorPreference =>\n typeof textColor === 'object' && 'source' in textColor;\n\n/**\n * `derive` allows text color to be calculated by the engine so we can pick a color with appropriate contrast.\n * A preferred color starts from a reference point (a color anchor) and adjusts it until it meets required contrast rules.\n */\nexport const resolveTextColor = (\n textColor: TextColor,\n solid: Color,\n anchors: ResolvedAnchors,\n): Color => {\n if (!isPreference(textColor)) {\n return getBestColorForText({ backgroundColor: solid });\n }\n\n const { offset, source } = textColor;\n const preferred = stepAlong(anchorScale(source, anchors), anchorColor(source, anchors), offset);\n\n return adjustColorForProperContrast({ foregroundColor: preferred, backgroundColor: solid });\n};\n\nexport const textSlots = (surface: SurfaceName, text: Color): Slots => ({\n 'text-color': text.toHex(),\n ...(SURFACES[surface].holdsContent\n ? {\n 'heading-text-color': text.toHex(),\n 'low-emphasis-text-color': text.withAlpha(LOW_EMPHASIS_TEXT_ALPHA).toRgba(),\n }\n : {}),\n});\n\n/** The same text slots with a `-hover` suffix, moved only as far as the hovered fill needs. */\nexport const hoverTextSlots = (surface: SurfaceName, text: Color, solidHover: Color): Slots => {\n const readable = adjustColorForProperContrast({\n foregroundColor: text,\n backgroundColor: solidHover,\n });\n\n return Object.fromEntries(\n Object.entries(textSlots(surface, readable)).map(([slot, value]) => [`${slot}-hover`, value]),\n );\n};\n\nexport const textGaps: FindGaps = ({ textColor }) =>\n textColor === 'derive' || isPreference(textColor)\n ? []\n : [`textColor: ${JSON.stringify(textColor)}`];\n","/** Letter spacing for `case: upper`, which reads cramped at the spacing set for mixed case. */\nexport const UPPERCASE_LETTER_SPACING = '0.05em';\n","import type { StyleDocument } from '../../../styleVocabulary';\nimport type { ResolvedAnchors } from '../anchors';\nimport type { VariableName } from '../slots';\nimport { TYPE_ROLES } from '../../../styleVocabulary';\nimport { UPPERCASE_LETTER_SPACING } from '../constants/typography';\nimport { typeVariable } from '../slots';\n\n/**\n * `font-family` has no fixed initial value — it is up to the browser — so its unused value is the\n * generic family instead.\n */\nconst TYPE_INITIAL_VALUES = {\n 'font-family': 'sans-serif',\n 'font-size': 'medium',\n 'font-weight': 'normal',\n 'text-transform': 'none',\n 'letter-spacing': 'normal',\n} as const;\n\nexport const TYPOGRAPHY_CONTRACT: Readonly<Record<VariableName, string>> = Object.fromEntries(\n TYPE_ROLES.flatMap((role) =>\n Object.entries(TYPE_INITIAL_VALUES).map(([slot, value]) => [typeVariable(role, slot), value]),\n ),\n);\n\nexport const typographyVariables = (\n { typography }: StyleDocument,\n anchors: ResolvedAnchors,\n): Readonly<Record<VariableName, string>> =>\n Object.fromEntries(\n TYPE_ROLES.flatMap((role) => {\n const type = typography[role];\n const upper = type.case === 'upper';\n\n return [\n [typeVariable(role, 'font-family'), anchors.fonts[type.font]],\n [typeVariable(role, 'font-size'), `${type.fontSize}px`],\n [typeVariable(role, 'font-weight'), String(type.fontWeight)],\n [typeVariable(role, 'text-transform'), upper ? 'uppercase' : 'none'],\n [typeVariable(role, 'letter-spacing'), upper ? UPPERCASE_LETTER_SPACING : 'normal'],\n ];\n }),\n );\n","import type { SurfaceSlotFragment, VariableName } from './slots';\nimport { BORDER_SLOTS } from './rules/border';\nimport { ELEVATION_SLOTS } from './rules/elevation';\nimport { FILL_SLOTS, HOVER_FILL_SLOTS } from './rules/fill';\nimport { MOTION_SLOTS } from './rules/motion';\nimport { PANEL_INPUT_SLOTS } from './rules/panelInput';\nimport { RADIUS_SLOTS } from './rules/radius';\nimport {\n CONTENT_HOVER_TEXT_SLOTS,\n CONTENT_TEXT_SLOTS,\n HOVER_TEXT_SLOTS,\n TEXT_SLOTS,\n} from './rules/text';\nimport { TYPOGRAPHY_CONTRACT } from './rules/typography';\nimport { surfaceVariable } from './slots';\nimport { SURFACE_GROUPS } from './surfaces';\n\n/** Every rule's surface slots. A rule that adds slots adds its fragment here. */\nconst SURFACE_SLOT_FRAGMENTS: readonly SurfaceSlotFragment[] = [\n FILL_SLOTS,\n HOVER_FILL_SLOTS,\n TEXT_SLOTS,\n CONTENT_TEXT_SLOTS,\n HOVER_TEXT_SLOTS,\n CONTENT_HOVER_TEXT_SLOTS,\n PANEL_INPUT_SLOTS,\n BORDER_SLOTS,\n ELEVATION_SLOTS,\n RADIUS_SLOTS,\n MOTION_SLOTS,\n];\n\nconst surfaceContract = (): Readonly<Record<VariableName, string>> =>\n Object.fromEntries(\n SURFACE_GROUPS.flatMap(({ prefix, surface }) =>\n SURFACE_SLOT_FRAGMENTS.filter(({ surfaces }) => surfaces.includes(surface)).flatMap(\n ({ initialValues }) =>\n Object.entries(initialValues).map(([slot, value]) => [\n surfaceVariable(prefix, slot),\n value,\n ]),\n ),\n ),\n );\n\nexport const CONTRACT: Readonly<Record<VariableName, string>> = {\n ...surfaceContract(),\n ...TYPOGRAPHY_CONTRACT,\n};\n","import type { VariableName } from './private/engine/slots';\nimport { CONTRACT } from './private/engine/contract';\n\nexport { VARIABLE_PREFIX as KALEIDOSCOPE_VARIABLE_PREFIX } from './private/engine/slots';\n\n/** A `--wistia-kaleidoscope-*` custom property name. */\nexport type KaleidoscopeVariableName = VariableName;\n\n/**\n * The record `getKaleidoscopeStyles()` returns: every variable and its value. The type\n * only checks the `--wistia-kaleidoscope-` prefix, so a misspelled name still compiles. The names\n * themselves are defined by {@link KALEIDOSCOPE_CONTRACT} and pinned by its contract test.\n */\nexport type KaleidoscopeVariables = Readonly<Record<KaleidoscopeVariableName, string>>;\n\n/**\n * Every variable the engine emits, with the value it takes when a Style doesn't use the rule\n * behind it: the CSS initial value of the property it feeds, or the value that draws nothing.\n * Every Style emits exactly these names, so embeds and hosted pages can rely on each one.\n *\n * Surface variables are `--wistia-kaleidoscope-<surface>-<slot>`. A surface that can sit on several\n * parents is emitted once per parent, as `<surface>-on-<parent>`: `button-primary-on-panel`. Slots\n * are named after the CSS property they feed — `background-color`, `border-radius`, `box-shadow` —\n * with a `-hover` or `-focus` suffix for a state. There are two exceptions: `text-color`,\n * `heading-text-color` and `low-emphasis-text-color` all feed `color`, and a panel's input slots\n * carry an `input-` prefix, as in `input-background-color`.\n *\n * Typography variables are `--wistia-kaleidoscope-type-<role>-<property>`, for the `heading`,\n * `body` and `button` roles.\n */\nexport const KALEIDOSCOPE_CONTRACT: KaleidoscopeVariables = CONTRACT;\n","import type { Color } from '../../../Color';\nimport type { ResolvedFill, TreatmentResult } from '../treatments/types';\nimport type { AnySurfaceSettings } from './types';\nimport { INVERT_BELOW_CONTRAST } from '../constants/color';\nimport { flatFill } from '../treatments/flat';\n\nexport type PaintedPair = {\n readonly text: Color;\n readonly treated: TreatmentResult;\n};\n\n/**\n * `invert: when-indistinct`: if a surface's background fill color is too close to its parent background fill,\n * invert: when-indistinct allows the fill and text color to be inverted. This provides better contrast between the surface\n * and its parent while also preserving legible contrast between the surface and its text color.\n */\nexport const invertWhenIndistinct = (\n { backgroundColor: { invert }, treatment }: AnySurfaceSettings,\n treated: TreatmentResult,\n text: Color,\n parent: ResolvedFill | null,\n): PaintedPair => {\n if (invert !== 'when-indistinct' || treatment !== 'flat' || parent === null) {\n return { text, treated };\n }\n\n const fillContrast = treated.solid.contrast(parent.solid);\n\n return fillContrast < INVERT_BELOW_CONTRAST && text.contrast(parent.solid) > fillContrast\n ? { text: treated.solid, treated: flatFill(text, null, parent) }\n : { text, treated };\n};\n","import type { StyleDocument, SurfaceName } from '../../styleVocabulary';\nimport type { ResolvedAnchors } from './anchors';\nimport type { Slots, VariableName } from './slots';\nimport type { ResolvedFill } from './treatments/types';\nimport { borderSlots } from './rules/border';\nimport { elevationSlots } from './rules/elevation';\nimport { invertWhenIndistinct } from './rules/invert';\nimport { motionSlots } from './rules/motion';\nimport { panelInputSlots } from './rules/panelInput';\nimport { radiusSlots } from './rules/radius';\nimport { hoverTextSlots, resolveTextColor, textSlots } from './rules/text';\nimport { surfaceVariable } from './slots';\nimport { SURFACE_GROUPS, SURFACES } from './surfaces';\nimport { TREATMENT_FUNCTIONS } from './treatments';\n\ntype EvaluatedSurface = ResolvedFill & { readonly slots: Slots };\n\n/**\n * One surface on one parent. A slot a Style doesn't use is left out, so it keeps the contract's\n * initial value.\n */\nconst evaluateSurface = (\n style: StyleDocument,\n surface: SurfaceName,\n anchors: ResolvedAnchors,\n parent: ResolvedFill | null,\n): EvaluatedSurface => {\n const settings = style.surfaces[surface];\n const treatment = TREATMENT_FUNCTIONS[settings.treatment];\n\n if (treatment === undefined) {\n throw new Error(`The engine cannot paint a ${settings.treatment} ${surface} yet`);\n }\n\n const painted = treatment({ anchors, parent, settings, surface });\n const { text, treated } = invertWhenIndistinct(\n settings,\n painted,\n resolveTextColor(settings.textColor, painted.solid, anchors),\n parent,\n );\n const spec = SURFACES[surface];\n const hover = treated.hover(text);\n\n return {\n solid: treated.solid,\n scale: treated.scale,\n slots: {\n ...treated.fill,\n ...(spec.interactive\n ? { ...hover.slots, ...hoverTextSlots(surface, text, hover.solid) }\n : {}),\n ...textSlots(surface, text),\n ...(spec.mayContainForm ? panelInputSlots(treated.solid, anchors) : {}),\n ...borderSlots(settings.border, treated.solid, anchors),\n ...elevationSlots(settings.elevation),\n ...radiusSlots(surface, settings.radius, anchors),\n ...motionSlots(settings.motion),\n },\n };\n};\n\n/**\n * Evaluates every surface group parents first, so each surface knows the fill it sits on, and\n * names each slot after its group.\n */\nexport const evaluateSurfaces = (\n style: StyleDocument,\n anchors: ResolvedAnchors,\n): Readonly<Record<VariableName, string>> => {\n const containers = new Map<SurfaceName, ResolvedFill>();\n const variables: Record<VariableName, string> = {};\n\n for (const { parent, prefix, surface } of SURFACE_GROUPS) {\n const evaluated = evaluateSurface(\n style,\n surface,\n anchors,\n parent === null ? null : (containers.get(parent) ?? null),\n );\n\n // A surface on several parents is never a container itself, so the last one evaluated is fine.\n containers.set(surface, evaluated);\n\n for (const [slot, value] of Object.entries(evaluated.slots)) {\n variables[surfaceVariable(prefix, slot)] = value;\n }\n }\n\n return variables;\n};\n","import type { FindGaps } from './types';\n\n/** No textures yet, so no texture slots: the Style that first uses one adds them. */\nexport const textureGaps: FindGaps = ({ texture: { kind } }) =>\n kind === 'none' ? [] : [`texture.kind: ${kind}`];\n","import type { StyleDocument } from '../../styleVocabulary';\nimport type { FindGaps } from './rules/types';\nimport { SURFACE_NAMES } from '../../styleVocabulary';\nimport { borderGaps } from './rules/border';\nimport { elevationGaps } from './rules/elevation';\nimport { fillGaps } from './rules/fill';\nimport { motionGaps } from './rules/motion';\nimport { textGaps } from './rules/text';\nimport { textureGaps } from './rules/texture';\n\nconst GAP_FINDERS: readonly FindGaps[] = [\n fillGaps,\n textGaps,\n borderGaps,\n elevationGaps,\n motionGaps,\n textureGaps,\n];\n\n/** The rules in `style` the engine cannot resolve yet, as `<surface>.<setting>: <value>`. */\nexport const findUnsupportedRules = (style: StyleDocument): readonly string[] =>\n SURFACE_NAMES.flatMap((surface) =>\n GAP_FINDERS.flatMap((findGaps) => findGaps(style.surfaces[surface])).map(\n (gap) => `${surface}.${gap}`,\n ),\n );\n\n/**\n * Whether the engine resolves every rule `style` uses. The contract test and the Storybook's\n * engine-backed Styles both come from this, so a Style switches over as soon as the engine covers\n * it.\n */\nexport const isSupportedStyle = (style: StyleDocument): boolean =>\n findUnsupportedRules(style).length === 0;\n","import type { BrandTokens } from './brandTokens';\nimport type { KaleidoscopeVariables } from './kaleidoscopeContract';\nimport type { StyleDocument } from './styleVocabulary';\nimport { KALEIDOSCOPE_CONTRACT } from './kaleidoscopeContract';\nimport { resolveAnchors } from './private/engine/anchors';\nimport { evaluateSurfaces } from './private/engine/evaluateSurfaces';\nimport { typographyVariables } from './private/engine/rules/typography';\nimport { findUnsupportedRules } from './private/engine/support';\n\nconst resolveAgainstDefaultValues = (resolved: KaleidoscopeVariables): KaleidoscopeVariables => ({\n ...KALEIDOSCOPE_CONTRACT,\n ...resolved,\n});\n\n/**\n * Resolves a Style against a Brand Kit into the `--wistia-kaleidoscope-*` variables that style an\n * embed or hosted page. The record always holds every name in {@link KALEIDOSCOPE_CONTRACT}.\n *\n * A Brand Kit token the Style references but `brandTokens` leaves out takes its default from\n * `DEFAULT_BRAND_TOKENS`.\n *\n * @throws when the Style uses a rule the engine cannot resolve yet, or references a token that is\n * not a Brand Kit token.\n *\n * @example\n * ```ts\n * const variables = getKaleidoscopeStyles(OPAQUE_MINIMAL, { primaryColor: '#5b4cf0' });\n * variables['--wistia-kaleidoscope-button-primary-on-page-background-color']; // '#5b4cf0'\n * ```\n */\nexport const getKaleidoscopeStyles = (\n style: StyleDocument,\n brandTokens: BrandTokens = {},\n): KaleidoscopeVariables => {\n const unsupported = findUnsupportedRules(style);\n\n if (unsupported.length > 0) {\n throw new Error(`The engine cannot resolve \"${style.id}\" yet: ${unsupported.join(', ')}`);\n }\n\n const anchors = resolveAnchors(style, brandTokens);\n\n return resolveAgainstDefaultValues({\n ...evaluateSurfaces(style, anchors),\n ...typographyVariables(style, anchors),\n });\n};\n","import type { KaleidoscopeVariables } from './kaleidoscopeContract';\nimport { KALEIDOSCOPE_VARIABLE_PREFIX } from './kaleidoscopeContract';\n\nconst NAME_SUFFIX = /^[a-z0-9-]+$/;\n/** Ends the declaration or rule, or the `<style>` element, or escapes what follows, or `!important`. */\nconst UNSAFE_IN_VALUE = /[{};<\\\\!\\p{Cc}]|\\/\\*|\\*\\//u;\nconst UNSAFE_IN_SELECTOR = /[{};<\\\\@\\p{Cc}]|\\/\\*|\\*\\//u;\nconst QUOTED = /\"[^\"]*\"|'[^']*'/g;\nconst CLOSER_OF: Readonly<Record<string, string>> = { '(': ')', '[': ']' };\nconst CLOSERS = new Set(Object.values(CLOSER_OF));\n\n/** An unclosed quote or bracket swallows the declarations and rules after it. */\nconst isBalanced = (text: string): boolean => {\n const unquoted = text.replaceAll(QUOTED, '');\n const expected: string[] = [];\n\n if (/[\"']/.test(unquoted)) {\n return false;\n }\n\n for (const char of unquoted) {\n const closer = CLOSER_OF[char];\n\n if (closer !== undefined) {\n expected.push(closer);\n } else if (CLOSERS.has(char) && expected.pop() !== char) {\n return false;\n }\n }\n\n return expected.length === 0;\n};\n\nconst assertSafe = (label: string, text: string, unsafe: RegExp): void => {\n if (text.trim() === '' || unsafe.test(text) || !isBalanced(text)) {\n throw new Error(`Cannot serialize ${label} safely: ${JSON.stringify(text)}`);\n }\n};\n\nconst assertName = (name: string): void => {\n if (\n !name.startsWith(KALEIDOSCOPE_VARIABLE_PREFIX) ||\n !NAME_SUFFIX.test(name.slice(KALEIDOSCOPE_VARIABLE_PREFIX.length))\n ) {\n throw new Error(`Cannot serialize variable name safely: ${JSON.stringify(name)}`);\n }\n};\n\n/**\n * Writes the record from `getKaleidoscopeStyles()` as a CSS rule, for a server-rendered `<style>`\n * or for injecting at runtime.\n *\n * Text that could leave its declaration, its rule or the `<style>` element is refused rather than\n * escaped. The engine's own values never need it, so such text is a font family from a Brand Kit\n * that should not reach the page, and an escaped version would no longer name a real font.\n *\n * @throws when `selector`, a variable name or a value is unsafe. Callers rendering customer Brand\n * Kits should catch this and fall back.\n *\n * @example\n * ```ts\n * serializeKaleidoscopeStyles(getKaleidoscopeStyles(OPAQUE_MINIMAL), '.my-scope');\n * // '.my-scope {\\n --wistia-kaleidoscope-page-background-color: #ffffff;\\n …\\n}'\n * ```\n */\nexport const serializeKaleidoscopeStyles = (\n variables: KaleidoscopeVariables,\n selector: string,\n): string => {\n assertSafe('selector', selector, UNSAFE_IN_SELECTOR);\n\n const declarations = Object.entries(variables).map(([name, value]) => {\n assertName(name);\n assertSafe(`the value of ${name}`, value, UNSAFE_IN_VALUE);\n\n return ` ${name}: ${value};`;\n });\n\n return `${selector} {\\n${declarations.join('\\n')}\\n}`;\n};\n"],"mappings":";;;;;;;;;;;;;;AACA,MAAa,oBA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