@taprootio/espalier 3.1.0 → 3.3.0
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 +53 -0
- package/custom-elements.json +5656 -2169
- package/dist/box/esp-box.d.ts +10 -0
- package/dist/box/esp-box.js +4 -4
- package/dist/cli/espalier.js +2 -0
- package/dist/cli/theme-check.js +2 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +1 -1
- package/dist/page/esp-page.d.ts +23 -7
- package/dist/page/esp-page.js +37 -10
- package/dist/root/esp-root.d.ts +40 -1
- package/dist/root/esp-root.js +3 -3
- package/dist/root/helpers/compute-theme-properties.js +1 -1
- package/dist/root/helpers/data-companion-properties.js +1 -0
- package/dist/row/esp-row.d.ts +64 -0
- package/dist/row/esp-row.js +67 -0
- package/dist/section/esp-section.d.ts +55 -0
- package/dist/section/esp-section.js +22 -0
- package/dist/shared/esp-element-base.js +2 -2
- package/dist/shared/scale-engine.js +1 -1
- package/dist/shared/theme-fit-report.d.ts +94 -4
- package/dist/shared/theme-fit-report.js +1 -1
- package/dist/shared/theme-swatches.d.ts +79 -0
- package/dist/shared/theme-swatches.js +1 -0
- package/dist/shared/theme.d.ts +38 -1
- package/dist/shared/theme.js +1 -1
- package/dist/shared/unsafe-keys.js +1 -0
- package/dist/stack/esp-stack.d.ts +62 -0
- package/dist/stack/esp-stack.js +56 -0
- package/espalier.token-manifest.json +164 -1
- package/package.json +32 -1
package/dist/shared/theme.d.ts
CHANGED
|
@@ -228,9 +228,16 @@ export type ThemeRoles = {
|
|
|
228
228
|
* A context may also carry a partial lightness ramp. Color sources alone
|
|
229
229
|
* cannot make a dark zone inside a light scheme because semantic derivation
|
|
230
230
|
* deliberately takes lightness from the ramp rather than from an anchor.
|
|
231
|
+
*
|
|
232
|
+
* A context may also carry token-level `semanticMappings` (ESP0175).
|
|
233
|
+
* Root-level explicit mappings survive into every context by design —
|
|
234
|
+
* they are deliberate token pins — so a zone that needs a different
|
|
235
|
+
* value for one of them declares its own mapping here, which layers over
|
|
236
|
+
* the inherited pin exactly as a root-level mapping layers over roles.
|
|
231
237
|
*/
|
|
232
238
|
export type ThemeContext = ThemeRoles & {
|
|
233
239
|
lightness?: Partial<LightnessMap>;
|
|
240
|
+
semanticMappings?: Partial<SemanticMappings>;
|
|
234
241
|
};
|
|
235
242
|
/** Named role-rebinding zones available to `context` attributes. */
|
|
236
243
|
export type ThemeContexts = Record<string, ThemeContext>;
|
|
@@ -274,6 +281,8 @@ interface CompileRoleOptions {
|
|
|
274
281
|
explicitMappings?: Partial<SemanticMappings>;
|
|
275
282
|
/** Exact maximum paired-ink contrast of an action surface candidate. */
|
|
276
283
|
actionSurfaceContrast?: (source: MappingSource, stop: LightnessKey) => number;
|
|
284
|
+
/** ΔE-OK between an action surface candidate and the theme's background. */
|
|
285
|
+
actionSurfaceSeparation?: (source: MappingSource, stop: LightnessKey) => number;
|
|
277
286
|
}
|
|
278
287
|
/**
|
|
279
288
|
* Compile roles into semantic mappings.
|
|
@@ -628,12 +637,25 @@ export declare function parseTheme(base64: string): PartialTheme | null;
|
|
|
628
637
|
/**
|
|
629
638
|
* Encode a {@link PartialTheme} as a Base64 JSON string.
|
|
630
639
|
*
|
|
631
|
-
* The inverse of {@link parseTheme}.
|
|
640
|
+
* The inverse of {@link parseTheme}. Unicode-safe: theme strings (font
|
|
641
|
+
* names, anchor slugs' display metadata) may carry any code point.
|
|
632
642
|
*
|
|
633
643
|
* @param partial The partial theme to encode.
|
|
634
644
|
* @returns A Base64-encoded JSON string.
|
|
635
645
|
*/
|
|
636
646
|
export declare function encodeTheme(partial: PartialTheme): string;
|
|
647
|
+
/**
|
|
648
|
+
* Recover explicit mapping provenance from a resolved theme.
|
|
649
|
+
*
|
|
650
|
+
* Themes produced in this process carry exact provenance in the WeakMap.
|
|
651
|
+
* The comparison fallback preserves the historical behavior for a fully
|
|
652
|
+
* resolved theme reconstructed outside `mergeTheme`, where provenance is
|
|
653
|
+
* necessarily unavailable because it is not part of the serialized model.
|
|
654
|
+
*
|
|
655
|
+
* Exported for the fit report (ESP0175), which marks explicit tokens so
|
|
656
|
+
* a zone's surprising value traces to the mapping that pinned it.
|
|
657
|
+
*/
|
|
658
|
+
export declare function explicitMappingTokens(theme: EspalierTheme): Set<SemanticColorName>;
|
|
637
659
|
/**
|
|
638
660
|
* Deep-merge a {@link PartialTheme} over a set of defaults.
|
|
639
661
|
*
|
|
@@ -647,6 +669,21 @@ export declare function encodeTheme(partial: PartialTheme): string;
|
|
|
647
669
|
* @returns A new fully-resolved {@link EspalierTheme}.
|
|
648
670
|
*/
|
|
649
671
|
export declare function mergeTheme(defaults: EspalierTheme, overrides: PartialTheme): EspalierTheme;
|
|
672
|
+
/**
|
|
673
|
+
* Compile a named context over a resolved theme — the exact theme a
|
|
674
|
+
* `context="<name>"` zone renders (ESP0175).
|
|
675
|
+
*
|
|
676
|
+
* This is the same compilation `esp-element-base` performs for a zone
|
|
677
|
+
* host, exported so a check script or the fit report can inspect a
|
|
678
|
+
* context surface without a DOM: role rebindings and the partial
|
|
679
|
+
* lightness ramp merge over the root theme, and any context-level
|
|
680
|
+
* `semanticMappings` layer on top as explicit token pins. Returns `null`
|
|
681
|
+
* when the theme does not define the context.
|
|
682
|
+
*
|
|
683
|
+
* @param theme A resolved theme (as `mergeTheme` returns).
|
|
684
|
+
* @param name The context name a zone would set in its attribute.
|
|
685
|
+
*/
|
|
686
|
+
export declare function resolveContextTheme(theme: EspalierTheme, name: string): EspalierTheme | null;
|
|
650
687
|
/**
|
|
651
688
|
* Validate a single encoded theme partial.
|
|
652
689
|
*
|
package/dist/shared/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ACCEPTED_COLOR_FORMS as ee,apcaContrast as et,clampChannel as le,deriveSemantic as we,gamutMapToSRGB as fe,linearRgbToOklab as tt,oklchToSRGB as nt,parseCssColor as N,parseOklch as ot,serializeOklch as ae,srgbToLinearRGB as st}from"./color-engine.js";import{computeVariants as Te,parseAnchorSource as rt,resolveAnchorColor as at,resolveMappingSource as Ee}from"./variant-engine.js";import{auditColorDistances as _e,auditDataPalette as it,DATA_SERIES_KEYS as ie,DEFAULT_DATA_PALETTE as pe,DEFAULT_DATA_RAMP_STEPS as ct,MAX_DATA_RAMP_STEPS as me,MIN_DATA_RAMP_LIGHTNESS_STEP as Ie,MIN_DATA_RAMP_STEPS as he}from"./data-colors.js";const z=/^[a-z][a-z0-9-]*$/;function de(e){return rt(e)}function Le(e,n){return at(e,n)}function ut(e,n){const t=de(e);if(t){const s=Le(n,t);return s&&N(s)?s:null}return N(e)?e:null}const Z=["canvas","ink","accent","action","structure"],He={canvas:{color:[["background","surface"],["layer1","raised1"],["layer2","raised2"],["layer3","raised3"],["layer4","raised4"]]},ink:{color:[["text","text"],["inputSelection","text"]],heading:[["headings","muted"],["headingsHover","ink"]]},accent:{color:[["linkHoverBg","raised2"],["inputSelectionBg","raised2"],["inputCaret","ink"]],text:[["link","accent"]],hover:[["linkHover","text"]]},action:{color:[["actionBackground","muted"]],ink:[["actionText","surface"]]},structure:{color:[["border","border"],["shadow","shadow"]]}},lt=new Set(["action.color"]),ft={canvas:"background",ink:"text",accent:"link",action:"actionBackground",structure:"border"},pt={"action.ink":{role:"canvas",slot:"color"}},mt=.45;function Pe(e,n){const t=Ne.actionText,s=[...U].sort((p,S)=>e[p]-e[S]||U.indexOf(p)-U.indexOf(S)),a=n?s.filter(p=>n(p)>=t.targetLc):s,u=a.length>0?a:s;let f,h=1/0;for(const p of u){const S=Math.abs(e[p]-mt);S<h&&(h=S,f=p)}return f??"muted"}function ht(e,n){const t=n[e]>.5;let s=U[0];for(const a of U)(t?n[a]<n[s]:n[a]>n[s])&&(s=a);return s}const dt={"accent.hover":"text"};function gt(e,n){const t=new Map;try{const s=se(n,e),a=(u,f,h,p)=>{const S=de(f),$=S?Le(p,S):null,x=$===null?null:N($),C=t.get(u)??[];C.some(o=>o.source===f&&o.chroma===x?.c)||(C.push({source:f,where:h,chroma:x?.c}),t.set(u,C))};for(const[u,f]of Object.entries(s.semanticMappings))f.source.startsWith("anchor:")&&a(u,f.source,"the root table",s.anchors);for(const[u,f]of Object.entries(s.contexts)){const h={};for(const S of Z){const $=f[S];$!==void 0&&(h[S]=$)}const p=se(s,{lightness:f.lightness,roles:h});for(const[S,$]of Object.entries(p.semanticMappings))$.source.startsWith("anchor:")&&a(S,$.source,`contexts.${u}`,p.anchors)}}catch{return new Map}return t}function te(e,n){if(e===void 0)return;if(typeof e=="string")return n==="color"?e:void 0;const t=e[n];return typeof t=="string"?t:void 0}function De(e,n,t,s={}){const a={},u={};for(const[f,h]of Object.entries(s.explicitMappings??{}))h!==void 0&&(u[f]=h.lightness);for(const f of Z){const h=e[f];if(h!==void 0)for(const[p,S]of Object.entries(He[f])){const $=pt[`${f}.${p}`];let x=te(h,p),C=!1;if(x===void 0){$&&(x=te(e[$.role],$.slot),x??=t[ft[$.role]]?.source,C=x!==void 0);const o=dt[`${f}.${p}`];o!==void 0&&(x??=te(h,o)),x??=te(h,"color")}if(x!==void 0)for(const[o,r]of S){let i=r;if(lt.has(`${f}.${p}`))i=Pe(n,s.actionSurfaceContrast?c=>s.actionSurfaceContrast(x,c):void 0);else if(C&&$){const c=Ne[o],m=(c&&u[c.bg])??Pe(n,s.actionSurfaceContrast?y=>s.actionSurfaceContrast(te(h,"color"),y):void 0);i=ht(m,n)}a[o]={source:x,lightness:i}}}}return a}const Ne={text:{bg:"background",targetLc:75},dangerText:{bg:"background",targetLc:75},headings:{bg:"background",targetLc:60},headingsHover:{bg:"background",targetLc:60},link:{bg:"background",targetLc:75},linkHover:{bg:"background",targetLc:75},actionText:{bg:"actionBackground",targetLc:75},inputCaret:{bg:"layer2",targetLc:60},inputSelection:{bg:"inputSelectionBg",targetLc:60}},ge=["background","layer1","layer2","layer3","layer4","actionBackground","actionText","border","shadow","text","dangerText","headings","headingsHover","link","linkHover","linkHoverBg","inputCaret","inputSelection","inputSelectionBg"],ye=["primary","analogous-left","analogous-right","complementary","split-complementary-left","split-complementary-right","triadic-left","triadic-right","danger","success","warning","info"],Q=["danger","success","warning","info"],yt=["analogous-left","analogous-right","complementary","split-complementary-left","split-complementary-right","triadic-left","triadic-right","danger","success","warning","info"],U=["surface","raised1","raised2","raised3","raised4","accent","muted","text","border","ink","shadow"],bt={surface:.99,raised1:.97,raised2:.9,raised3:.8,raised4:.72,accent:.5,muted:.45,text:.35,border:.3,ink:.25,shadow:.2},$t={surface:.15,raised1:.2,raised2:.3,raised3:.4,raised4:.36,accent:.6,muted:.75,text:.85,border:.7,ink:.95,shadow:.6},be={background:{source:"primary",lightness:"surface"},layer1:{source:"primary",lightness:"raised1"},layer2:{source:"primary",lightness:"raised2"},layer3:{source:"primary",lightness:"raised3"},layer4:{source:"primary",lightness:"raised4"},actionBackground:{source:"primary",lightness:"raised3"},actionText:{source:"primary",lightness:"ink"},border:{source:"primary",lightness:"border"},shadow:{source:"primary",lightness:"shadow"},text:{source:"primary",lightness:"text"},dangerText:{source:"danger",lightness:"text"},headings:{source:"primary",lightness:"muted"},headingsHover:{source:"primary",lightness:"text"},link:{source:"complementary",lightness:"accent"},linkHover:{source:"complementary",lightness:"text"},linkHoverBg:{source:"triadic-left",lightness:"raised2"},inputCaret:{source:"triadic-right",lightness:"ink"},inputSelection:{source:"complementary",lightness:"text"},inputSelectionBg:{source:"triadic-left",lightness:"raised2"}},G=.4;function $e(){const e={};for(const n of ge)e[n]={min:0,max:G};return e}const Fe={seedColor:"oklch(0.7 0.125 216)",fontBody:"",fontHeadings:"",fontBrand:"",fontMonospace:"",fontWeightBody:"normal",fontWeightHeadings:"bold",fontWeightBrand:"bold",fontWeightMonospace:"normal",stylesheets:[],rootFontSize:16,typeRatio:1.25,spaceRatio:1.618,borderRadius:.2,viewportMin:320,viewportMax:1200,angles:{analogous:30,complementary:180,splitComplementary:30,triadic:120},semanticHues:{danger:27,success:150,warning:90,info:244},variantChroma:{},intents:{},chroma:$e(),semanticMappings:{...be},anchors:{},roles:{},contexts:{},dataPalette:{...pe},dataRamps:{}},Se={...Fe,chroma:$e(),semanticMappings:{...be},anchors:{},roles:{},contexts:{},dataPalette:{...pe},dataRamps:{},lightness:{...bt}},We={...Fe,chroma:$e(),semanticMappings:{...be},anchors:{},roles:{},contexts:{},dataPalette:{...pe},dataRamps:{},lightness:{...$t}},ce=new WeakMap;ce.set(Se,new Set),ce.set(We,new Set);const je=new Set(["__proto__","constructor","prototype"]);function A(e){return!je.has(e)}function St(e,n){return je.has(e)?void 0:n}function Dt(e){return`--esp-color-${e.replace(/([A-Z])/g,"-$1").replace(/(\d)/g,"-$1").toLowerCase()}`}function xt(e){try{const n=atob(e),t=JSON.parse(n,St);return typeof t!="object"||t===null||Array.isArray(t)?null:t}catch{return null}}function xe(e){return btoa(JSON.stringify(e))}function kt(e){const n={};for(const t of Q){const s=e[t];typeof s=="string"&&(n[t]=s.startsWith("anchor:")?s:ne(s))}return n}function ne(e){if(ot(e))return e;const n=N(e);return n?ae(n):e}function Ke(e,n){const t={};for(const[s,a]of Object.entries(e))A(s)&&(t[s]=a);if(!n)return t;for(const[s,a]of Object.entries(n)){if(a===void 0||!A(s))continue;const u=t[s];if(u!==void 0&&typeof a=="object"&&a!==null){const f={};if(typeof u=="string")f.color=u;else for(const[h,p]of Object.entries(u))A(h)&&(f[h]=p);for(const[h,p]of Object.entries(a))p!==void 0&&A(h)&&(f[h]=p);t[s]=f;continue}t[s]=a}return t}function ze(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const n=e,t={};for(const s of Z){const a=n[s];a!==void 0&&(t[s]=a)}if(typeof n.lightness=="object"&&n.lightness!==null&&!Array.isArray(n.lightness)){const s={};for(const a of U){const u=n.lightness[a];u!==void 0&&(s[a]=u)}t.lightness=s}return t}function At(e,n){const t={};for(const[s,a]of Object.entries(e)){if(!A(s)||!z.test(s))continue;const u=ze(a);u&&(t[s]=u)}if(!n)return t;for(const[s,a]of Object.entries(n)){if(!A(s)||!z.test(s)||a===void 0)continue;const u=ze(a);if(!u)continue;const f=t[s];t[s]={...f??{},...u,...f?.lightness||u.lightness?{lightness:{...f?.lightness,...u.lightness}}:{}}}return t}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Y(e){const n={};for(const[t,s]of Object.entries(e))s!==void 0&&A(t)&&(n[t]=s);return n}function Ue(e){if(!J(e))return e;const n=Y(e);return J(e.lightness)&&(n.lightness=Y(e.lightness)),n}function vt(e,n){const t={};for(const[s,a]of Object.entries(e))A(s)&&(t[s]=Ue(a));if(!n)return t;for(const[s,a]of Object.entries(n)){if(!A(s)||a===void 0)continue;const u=t[s];if(!J(u)||!J(a)){t[s]=Ue(a);continue}const f={...Y(u),...Y(a)};J(u.lightness)&&J(a.lightness)?f.lightness={...Y(u.lightness),...Y(a.lightness)}:J(a.lightness)&&(f.lightness=Y(a.lightness)),t[s]=f}return t}function Rt(e){const n={};for(const[t,s]of Object.entries(e)){if(!A(t))continue;if(typeof s=="string"){n[t]=ne(s);continue}const a={};for(const[u,f]of Object.entries(s))A(u)&&(a[u]=typeof f=="string"?ne(f):f);n[t]=a}return n}function oe(e){return typeof e!="string"?"":e.startsWith("anchor:")?e:ne(e)}function Ot(e){const n={};for(const t of ie)n[t]=oe(e[t]);return n}function Ge(e,n){const t={};for(const[s,a]of Object.entries(e))A(s)&&z.test(s)&&a&&typeof a=="object"&&!Array.isArray(a)&&(t[s]={...a});if(!n)return t;for(const[s,a]of Object.entries(n)){if(!A(s)||!z.test(s)||!a||typeof a!="object"||Array.isArray(a))continue;const u=t[s],f=u!==void 0&&a.type!==void 0&&a.type!==u.type;t[s]={...f?{}:u??{},...a}}return t}function Ct(e){const n={};for(const[t,s]of Object.entries(e))if(A(t)){if(s.type==="sequential"&&typeof s.source=="string"){n[t]={...s,source:oe(s.source)};continue}if(s.type==="diverging"&&typeof s.start=="string"&&typeof s.end=="string"){n[t]={...s,start:oe(s.start),end:oe(s.end),...typeof s.neutral=="string"?{neutral:oe(s.neutral)}:{}};continue}n[t]={...s}}return n}function Ve(e){const n=N(e.seedColor);if(!n)return;const t=Te(n,e);return(s,a)=>{const u=Ee(s,t,e.anchors)??t.primary,f=e.chroma.actionBackground,h=we(u,e.lightness[a],f.min,f.max),p={l:h.l>.5?0:1,c:0,h:0};return Math.abs(et(p,h))}}function Mt(e){const n=ce.get(e);if(n)return new Set(n);const t=new Set,s=De(e.roles,e.lightness,e.semanticMappings,{actionSurfaceContrast:Ve(e)});for(const[a,u]of Object.entries(s)){const f=e.semanticMappings[a];(f.source!==u.source||f.lightness!==u.lightness)&&t.add(a)}return t}function se(e,n){const t={...e.roles,...n.roles},s=At(e.contexts,n.contexts),a={...e.lightness,...n.lightness},u=Rt(Ke(e.anchors,n.anchors)),f=typeof n.seedColor=="string"?ne(n.seedColor):e.seedColor,h=n.semanticMappings,p={...e.angles,...n.angles},S={...e.semanticHues,...n.semanticHues},$={...e.variantChroma,...n.variantChroma},x=kt({...e.intents,...n.intents}),C=re(e.chroma,n.chroma),o=Ot(re(e.dataPalette,n.dataPalette)),r=Ct(Ge(e.dataRamps,n.dataRamps)),i=Mt(e),c=new Set(i),m={};for(const g of i)m[g]=e.semanticMappings[g];for(const[g,b]of Object.entries(h??{}))b!==void 0&&(c.add(g),m[g]=b);const y=re(e.semanticMappings,h),I=Ve({angles:p,anchors:u,chroma:C,intents:x,lightness:a,seedColor:f,semanticHues:S,variantChroma:$}),D=De(t,a,y,{explicitMappings:m,actionSurfaceContrast:I}),W={};for(const[g,b]of Object.entries(D))c.has(g)||(W[g]=b);const l=re(re(e.semanticMappings,W),h),d={...e,seedColor:f,fontBody:n.fontBody??e.fontBody,fontHeadings:n.fontHeadings??e.fontHeadings,fontBrand:n.fontBrand??e.fontBrand,fontMonospace:n.fontMonospace??e.fontMonospace,fontWeightBody:String(n.fontWeightBody??e.fontWeightBody),fontWeightHeadings:String(n.fontWeightHeadings??e.fontWeightHeadings),fontWeightBrand:String(n.fontWeightBrand??e.fontWeightBrand),fontWeightMonospace:String(n.fontWeightMonospace??e.fontWeightMonospace),stylesheets:n.stylesheets??[...e.stylesheets],rootFontSize:n.rootFontSize??e.rootFontSize,typeRatio:n.typeRatio??e.typeRatio,spaceRatio:n.spaceRatio??e.spaceRatio,borderRadius:n.borderRadius??e.borderRadius,viewportMin:n.viewportMin??e.viewportMin,viewportMax:n.viewportMax??e.viewportMax,angles:p,semanticHues:S,variantChroma:$,intents:x,lightness:a,chroma:C,semanticMappings:l,anchors:u,roles:t,contexts:s,dataPalette:o,dataRamps:r};return n.pageBackgroundImage!==void 0&&(d.pageBackgroundImage=n.pageBackgroundImage),n.pageBackgroundImageOpacity!==void 0&&(d.pageBackgroundImageOpacity=n.pageBackgroundImageOpacity),n.boxBackgroundImage!==void 0&&(d.boxBackgroundImage=n.boxBackgroundImage),n.boxBackgroundImageOpacity!==void 0&&(d.boxBackgroundImageOpacity=n.boxBackgroundImageOpacity),n.vellumOpacity!==void 0&&(d.vellumOpacity=n.vellumOpacity),n.vellumBackgroundImage!==void 0&&(d.vellumBackgroundImage=n.vellumBackgroundImage),n.vellumBackgroundImageOpacity!==void 0&&(d.vellumBackgroundImageOpacity=n.vellumBackgroundImageOpacity),ce.set(d,new Set(c)),d}function re(e,n){if(!n)return{...e};const t={...e};for(const s of Object.keys(n)){const a=n[s];a!==void 0&&(t[s]=a)}return t}function ke(e){let n;try{n=atob(e)}catch{return{error:"Failed to decode Base64 string."}}let t;try{t=JSON.parse(n)}catch{return{error:"Decoded string is not valid JSON."}}return typeof t!="object"||t===null||Array.isArray(t)?{error:"Theme must be a JSON object."}:{value:t}}function Nt(e){const n=ke(e);return n.error!==void 0?{valid:!1,errors:[n.error],warnings:[]}:Ae(n.value)}function Ae(e,n=Se){const t=[],s=[];"seedColor"in e&&(typeof e.seedColor!="string"?t.push("seedColor must be a string."):N(e.seedColor)||t.push(`seedColor is not a valid CSS color: "${e.seedColor}". Accepted forms: ${ee}.`));for(const o of["fontBody","fontHeadings","fontBrand","fontMonospace"])o in e&&typeof e[o]!="string"&&t.push(`${o} must be a string.`);const a=["normal","bold","lighter","bolder"],u=["inherit","initial","unset","revert","revert-layer"];for(const o of["fontWeightBody","fontWeightHeadings","fontWeightBrand","fontWeightMonospace"])if(o in e){const r=e[o];if(typeof r=="number")(r<1||r>1e3)&&t.push(`${o} numeric value must be 1\u20131000 (got ${r}).`);else if(typeof r=="string"){const i=a.includes(r)||u.includes(r);if(/^\d+$/.test(r)){const m=Number(r);(m<1||m>1e3)&&t.push(`${o} numeric value must be 1\u20131000 (got "${r}").`)}else i||s.push(`${o} = "${r}" is not a standard font-weight value.`)}else t.push(`${o} must be a string or number.`)}"stylesheets"in e&&(Array.isArray(e.stylesheets)?e.stylesheets.some(o=>typeof o!="string")&&t.push("Every entry in stylesheets must be a string."):t.push("stylesheets must be an array of strings."));const f=[["rootFontSize",1,100],["borderRadius",0,10],["viewportMin",100,1e4],["viewportMax",200,1e4]];for(const[o,r,i]of f)if(o in e)if(typeof e[o]!="number"||!isFinite(e[o]))t.push(`${o} must be a finite number.`);else{const c=e[o];r!==void 0&&c<r&&t.push(`${o} must be \u2265 ${r} (got ${c}).`),i!==void 0&&c>i&&s.push(`${o} = ${c} is unusually high (max ${i}).`)}for(const o of["typeRatio","spaceRatio"])if(o in e)if(typeof e[o]!="number"||!isFinite(e[o]))t.push(`${o} must be a finite number.`);else{const r=e[o];r<=1&&t.push(`${o} must be > 1 (got ${r}).`);const i=o==="typeRatio"?1.3:2;r>i&&s.push(`${o} = ${r} is very high (max ${i}); scales may be extreme.`)}if("viewportMin"in e&&"viewportMax"in e){const o=e.viewportMin,r=e.viewportMax;typeof o=="number"&&typeof r=="number"&&o>=r&&t.push(`viewportMin (${o}) must be less than viewportMax (${r}).`)}if("angles"in e)if(typeof e.angles!="object"||e.angles===null)t.push("angles must be an object.");else{const o=e.angles;for(const r of["analogous","complementary","splitComplementary","triadic"])if(r in o)if(typeof o[r]!="number"||!isFinite(o[r]))t.push(`angles.${r} must be a finite number.`);else{const i=o[r];(i<0||i>360)&&s.push(`angles.${r} = ${i} is outside 0\u2013360.`)}}if("semanticHues"in e)if(typeof e.semanticHues!="object"||e.semanticHues===null)t.push("semanticHues must be an object.");else{const o=e.semanticHues;for(const r of["danger","success","warning","info"])if(r in o)if(typeof o[r]!="number"||!isFinite(o[r]))t.push(`semanticHues.${r} must be a finite number.`);else{const i=o[r];(i<0||i>360)&&s.push(`semanticHues.${r} = ${i} is outside 0\u2013360.`)}}if("variantChroma"in e)if(typeof e.variantChroma!="object"||e.variantChroma===null)t.push("variantChroma must be an object.");else{const o=e.variantChroma;for(const r of yt)if(r in o)if(typeof o[r]!="number"||!isFinite(o[r]))t.push(`variantChroma["${r}"] must be a finite number.`);else{const i=o[r];i<0&&t.push(`variantChroma["${r}"] must be \u2265 0 (got ${i}).`),i>G&&s.push(`variantChroma["${r}"] = ${i} exceeds ${G}.`)}}function h(o,r){if(typeof o!="object"||o===null||Array.isArray(o)){t.push(`${r} must be an object.`);return}const i=o;for(const c of U)if(c in i)if(typeof i[c]!="number"||!isFinite(i[c]))t.push(`${r}.${c} must be a finite number.`);else{const m=i[c];(m<0||m>1)&&t.push(`${r}.${c} must be 0\u20131 (got ${m}).`)}}if("lightness"in e&&h(e.lightness,"lightness"),"chroma"in e)if(typeof e.chroma!="object"||e.chroma===null)t.push("chroma must be an object.");else{const o=e.chroma,r=gt(e,n);for(const i of ge)if(i in o){const c=o[i];if(typeof c!="object"||c===null){t.push(`chroma.${i} must be { min, max }.`);continue}const m=c;for(const I of r.get(i)??[])I.chroma!==void 0&&typeof m.min=="number"&&typeof m.max=="number"&&(I.chroma<m.min-1e-9||I.chroma>m.max+1e-9)&&s.push(`chroma.${i} clamps the anchor-sourced token ${i} ("${I.source}", effective in ${I.where}) and moves it off its declared swatch. Remove the band if that is unintended \u2014 anchors otherwise keep their own chroma.`);const y=c;(typeof y.min!="number"||y.min<0)&&t.push(`chroma.${i}.min must be \u2265 0.`),(typeof y.max!="number"||y.max<0||y.max>G)&&t.push(`chroma.${i}.max must be 0\u2013${G}.`),typeof y.min=="number"&&typeof y.max=="number"&&y.min>y.max&&t.push(`chroma.${i}.min (${y.min}) must be \u2264 max (${y.max}).`)}}if("anchors"in e)if(typeof e.anchors!="object"||e.anchors===null||Array.isArray(e.anchors))t.push("anchors must be an object of named colors.");else for(const[o,r]of Object.entries(e.anchors))if(A(o)?z.test(o)||t.push(`anchors: "${o}" is not a valid anchor name; use a lowercase slug (letters, digits, hyphens).`):t.push(`anchors: "${o}" is a reserved JavaScript property name and cannot be an anchor name; rename it.`),ye.includes(o)&&t.push(`anchors: "${o}" collides with a reserved color source name.`),typeof r=="string")N(r)||t.push(`anchors.${o} is not a valid CSS color: "${r}". Accepted forms: ${ee}.`);else if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const i=r;typeof i.color!="string"&&t.push(`anchors.${o} must declare its base "color".`);for(const[c,m]of Object.entries(i))A(c)?c!=="color"&&!z.test(c)&&t.push(`anchors.${o}: "${c}" is not a valid slot name; use a lowercase slug.`):t.push(`anchors.${o}: "${c}" is a reserved JavaScript property name and cannot be a slot name; rename it.`),typeof m!="string"?t.push(`anchors.${o}.${c} must be a CSS color string.`):N(m)||t.push(`anchors.${o}.${c} is not a valid CSS color: "${m}". Accepted forms: ${ee}.`)}else t.push(`anchors.${o} must be a color string or a { color, \u2026slots } object.`);const p=new Map;if("anchors"in e&&typeof e.anchors=="object"&&e.anchors!==null&&!Array.isArray(e.anchors))for(const[o,r]of Object.entries(e.anchors))p.set(o,r);function S(o,r){const i=de(o);if(!i){t.push(`${r} "${o}" is not valid anchor syntax; use anchor:<name> or anchor:<name>.<slot>.`);return}if(!p.has(i.name)){const c=[...p.keys()];t.push(`${r} references undeclared anchor "${i.name}". Declared anchors: ${c.length>0?c.join(", "):"(none)"}.`);return}if(i.slot!==void 0){const c=p.get(i.name);if(typeof(typeof c=="object"&&c!==null&&!Array.isArray(c)?c[i.slot]:void 0)!="string"){const y=typeof c=="object"&&c!==null?Object.keys(c).filter(I=>I!=="color"):[];t.push(`${r} references unknown slot "${i.slot}" on anchor "${i.name}". Declared slots: ${y.length>0?y.join(", "):"(none)"}.`)}}}function $(o,r){if(o.startsWith("anchor:")){S(o,r);return}ye.includes(o)||t.push(`${r} must be one of: ${ye.join(", ")}, or a declared anchor as anchor:<name> / anchor:<name>.<slot>.`)}if("intents"in e)if(typeof e.intents!="object"||e.intents===null||Array.isArray(e.intents))t.push("intents must be an object.");else for(const[o,r]of Object.entries(e.intents)){const i=`intents.${o}`;if(!Q.includes(o)){t.push(`${i} is not a status family; expected one of: ${Q.join(", ")}.`);continue}if(typeof r!="string"){t.push(`${i} must be a string (a CSS color or an anchor: reference).`);continue}if(r.startsWith("anchor:")){S(r,i);continue}N(r)||t.push(`${i} "${r}" is not a supported color form or anchor: reference. Accepted forms: ${ee}, or anchor:<name> / anchor:<name>.<slot>. An override retunes a family with a declared color; it never points one family at another \u2014 retune, never reassign.`)}function x(o,r){if(o.startsWith("anchor:")){S(o,r);return}N(o)||t.push(`${r} is not a valid CSS color: "${o}". Accepted forms: ${ee}, or a declared anchor as anchor:<name> / anchor:<name>.<slot>.`)}if("dataPalette"in e)if(typeof e.dataPalette!="object"||e.dataPalette===null||Array.isArray(e.dataPalette))t.push("dataPalette must be an object with series1\u2013series8 color values.");else{const o=e.dataPalette;for(const[r,i]of Object.entries(o)){if(!ie.includes(r)){t.push(`dataPalette.${r} is not a series slot; expected one of: ${ie.join(", ")}.`);continue}typeof i!="string"?t.push(`dataPalette.${r} must be a CSS color or anchor reference string.`):x(i,`dataPalette.${r}`)}}if("dataRamps"in e)if(typeof e.dataRamps!="object"||e.dataRamps===null||Array.isArray(e.dataRamps))t.push("dataRamps must be an object of named ramp declarations.");else for(const[o,r]of Object.entries(e.dataRamps)){if(A(o)?z.test(o)||t.push(`dataRamps: "${o}" is not a valid ramp name; use a lowercase slug (letters, digits, hyphens).`):t.push(`dataRamps: "${o}" is a reserved JavaScript property name and cannot be a ramp name; rename it.`),typeof r!="object"||r===null||Array.isArray(r)){t.push(`dataRamps.${o} must be a sequential or diverging ramp object.`);continue}const i=r,c=i.steps??ct;if((typeof c!="number"||!Number.isInteger(c)||c<he||c>me)&&t.push(`dataRamps.${o}.steps must be an integer from ${he} through ${me}.`),i.type==="sequential"){typeof i.source!="string"?t.push(`dataRamps.${o}.source must be a CSS color or anchor reference string.`):x(i.source,`dataRamps.${o}.source`);const m=i.lightnessStart??.95,y=i.lightnessEnd??.25;for(const[I,D]of[["lightnessStart",m],["lightnessEnd",y]])(typeof D!="number"||!Number.isFinite(D)||D<0||D>1)&&t.push(`dataRamps.${o}.${I} must be a finite number from 0 through 1.`);typeof m=="number"&&typeof y=="number"&&m<=y?t.push(`dataRamps.${o}.lightnessStart must be greater than lightnessEnd.`):typeof m=="number"&&Number.isFinite(m)&&typeof y=="number"&&Number.isFinite(y)&&typeof c=="number"&&Number.isInteger(c)&&c>=he&&c<=me&&(m-y)/(c-1)<=Ie&&t.push(`dataRamps.${o} lightness bounds must leave more than ${Ie} lightness between serialized stops.`);continue}if(i.type==="diverging"){typeof c=="number"&&Number.isInteger(c)&&c%2===0&&t.push(`dataRamps.${o}.steps must be odd so the neutral is the exact midpoint.`);for(const m of["start","end"])typeof i[m]!="string"?t.push(`dataRamps.${o}.${m} must be a CSS color or anchor reference string.`):x(i[m],`dataRamps.${o}.${m}`);"neutral"in i&&(typeof i.neutral!="string"?t.push(`dataRamps.${o}.neutral must be a CSS color or anchor reference string.`):x(i.neutral,`dataRamps.${o}.neutral`));continue}t.push(`dataRamps.${o}.type must be "sequential" or "diverging".`)}if("dataPalette"in e&&t.length===0){const o=se(Se,e),r={};let i=!0;for(const c of ie){const m=ut(o.dataPalette[c],o.anchors);if(!m){i=!1;break}r[c]=m}if(i)for(const c of it(r))s.push(`dataPalette.${c.series[0]} and dataPalette.${c.series[1]} are only ${c.distance.toFixed(4)} apart under ${c.simulation} simulation (minimum ${c.threshold.toFixed(4)}); also distinguish the series with labels, shapes, or patterns.`)}function C(o,r){if(typeof o!="object"||o===null||Array.isArray(o)){t.push(`${r} must be an object.`);return}const i=o;for(const[c,m]of Object.entries(i)){const y=`${r}.${c}`;if(!Z.includes(c)){t.push(`${y} is not a role; expected one of: ${Z.join(", ")}. (The status family is reserved and is not a role.)`);continue}const I=c,D=He[I];if(typeof m=="string"){$(m,y);continue}if(typeof m!="object"||m===null||Array.isArray(m)){t.push(`${y} must be a color source or a { color, \u2026slots } object.`);continue}const W=m;typeof W.color!="string"&&t.push(`${y} must declare its base "color".`);for(const[l,d]of Object.entries(W)){if(!Object.prototype.hasOwnProperty.call(D,l)||!A(l)){const g=Object.keys(D).filter(b=>b!=="color");t.push(`${y}.${l} is not a slot of the ${I} role. Declared slots: ${g.length>0?g.join(", "):"(none)"}.`);continue}typeof d!="string"?t.push(`${y}.${l} must be a color source string.`):$(d,`${y}.${l}`)}}}if("roles"in e&&C(e.roles,"roles"),"contexts"in e)if(typeof e.contexts!="object"||e.contexts===null||Array.isArray(e.contexts))t.push("contexts must be an object.");else for(const[o,r]of Object.entries(e.contexts)){if(!A(o)||!z.test(o)){t.push(`contexts.${o} must be a lowercase slug matching ${z.source}.`);continue}if(typeof r!="object"||r===null||Array.isArray(r)){C(r,`contexts.${o}`);continue}const i=r,c=Object.fromEntries(Object.entries(i).filter(([m])=>m!=="lightness"));C(c,`contexts.${o}`),"lightness"in i&&h(i.lightness,`contexts.${o}.lightness`)}if("semanticMappings"in e)if(typeof e.semanticMappings!="object"||e.semanticMappings===null)t.push("semanticMappings must be an object.");else{const o=e.semanticMappings;for(const r of ge)if(r in o){const i=o[r];if(typeof i!="object"||i===null){t.push(`semanticMappings.${r} must be { source, lightness }.`);continue}const c=i;typeof c.source!="string"?t.push(`semanticMappings.${r}.source must be a string.`):$(c.source,`semanticMappings.${r}.source`),(typeof c.lightness!="string"||!U.includes(c.lightness))&&t.push(`semanticMappings.${r}.lightness must be one of: ${U.join(", ")}.`)}}for(const o of["pageBackgroundImage","boxBackgroundImage","vellumBackgroundImage"])o in e&&typeof e[o]!="string"&&t.push(`${o} must be a string.`);for(const o of["pageBackgroundImageOpacity","boxBackgroundImageOpacity","vellumOpacity","vellumBackgroundImageOpacity"])if(o in e)if(typeof e[o]!="number"||!isFinite(e[o]))t.push(`${o} must be a finite number.`);else{const r=e[o];(r<0||r>1)&&t.push(`${o} must be 0\u20131 (got ${r}).`)}return s.push(...Bt(e,n)),{valid:t.length===0,errors:t,warnings:s}}const O=.045;function Bt(e,n){try{return wt(e,n)}catch{return[]}}function wt(e,n){const t=se(n,e),s=qe(t),a=[...s],u=new Set(s);for(const[f,h]of Object.entries(t.contexts)){const p={};for(const $ of Z){const x=h[$];x!==void 0&&(p[$]=x)}const S=se(t,{lightness:h.lightness,roles:p});for(const $ of qe(S))u.has($)||a.push(`contexts.${f}: ${$}`)}return a}function Tt(e){const n=nt(fe(e)),t=st(n);return tt({r:le(t.r),g:le(t.g),b:le(t.b)})}function q(e,n){return Math.hypot(e.L-n.L,e.a-n.a,e.b-n.b)}function V(e){return Tt(N(ae(fe(e))))}function Je(e){return(Math.floor(e*1e4)/1e4).toFixed(4)}const X=2,Ye=1e-4;function qe(e){const n=N(e.seedColor);if(!n)return[];const t=Te(n,e),s=e.semanticMappings.actionBackground,a=e.chroma.actionBackground,u=e.lightness[s.lightness],f=(l,d,g,b)=>fe(we(l,d,g,b)),h=Q.map(l=>({name:l,base:t[l]})),p=[];if(Q.includes(s.source))p.push(`actionBackground is sourced from the "${s.source}" status family: ordinary and ${s.source}-intent action surfaces render identically (their labels may still differ). Remap the action to a non-status source \u2014 retuning "${s.source}" via intents moves both colors together.`);else{const l=Ee(s.source,t,e.anchors);l&&h.push({name:"action",base:l})}const S=_e(h.map(({name:l,base:d})=>[l,ae(f(d,u,a.min,a.max))]),O,["normal"]);if(S.length===0)return p;const $=new Map,x=(l,d)=>{const g=`${l}:${d}`;let b=$.get(g);if(!b){b=[];for(let w=0;w<360;w+=X)b.push(V({l,c:d,h:w}));$.set(g,b)}return b},C=O-.002,o=(l,d,g,b)=>{const w=Math.hypot(l.a,l.b),M=Math.atan2(l.b,l.a)*180/Math.PI+180;let E=0;for(const B of g===b?[b]:[g,b]){if(B+w<O-1e-4)continue;let L=M,R=q(V({l:d,c:B,h:M}),l);if(R>=O)return R;const P=x(d,B);for(let v=0;v<P.length;v+=1){const k=q(P[v],l);if(k>=O)return k;k>R&&(R=k,L=v*X)}let H=L;for(let v=L-X;v<=L+X;v+=.1){const k=q(V({l:d,c:B,h:v}),l);if(k>=O)return k;k>R&&(R=k,H=v)}if(R>=C)for(let v=H-.1;v<=H+.1;v+=.001){const k=q(V({l:d,c:B,h:v}),l);if(k>=O)return k;k>R&&(R=k)}R>E&&(E=R)}return E},r=(l,d,g)=>{const b=d===g?[g]:[d,g];let w=0;for(const M of b)for(const E of b){if(M+E<O-1e-4)continue;const B=x(l,M),L=x(l,E);let R=0,P=0,H=-1;for(let _=0;_<B.length;_+=1)for(let F=0;F<L.length;F+=1){const j=q(B[_],L[F]);if(j>=O)return j;j>H&&(H=j,R=_*X,P=F*X)}const v=(_,F,j,ve)=>{const Re=[];for(let K=F-j;K<=F+j;K+=ve)Re.push({h:K,lab:V({l,c:E,h:K})});let ue=-1,Oe=_,Ce=F;for(let K=_-j;K<=_+j;K+=ve){const Qe=V({l,c:M,h:K});for(const Me of Re){const Be=q(Qe,Me.lab);Be>ue&&(ue=Be,Oe=K,Ce=Me.h)}}return{distance:ue,hueA:Oe,hueB:Ce}},k=v(R,P,X,.1);if(k.distance>=O)return k.distance;let T=Math.max(H,k.distance);if(T>=C){const _=v(k.hueA,k.hueB,.1,.001);if(_.distance>T&&(T=_.distance),T>=O)return T}T>w&&(w=T)}return w},i=l=>Q.includes(l),c=(l,d,g,b,w)=>{const M=V(f(l.base,g,b,w)),E=V(f(d.base,g,b,w));if(q(M,E)>=O)return{outcome:"direct"};const B=i(l.name)&&i(d.name),L=[l,d].filter(H=>i(H.name)),R=B?"one of them":`"${i(l.name)?l.name:d.name}"`;let P;for(const H of L){const v=o(H===l?E:M,g,b,w);if(v>=O)return{outcome:"retune",target:R};v>=O-Ye&&(P=P??R)}if(B){const H=r(g,b,w);if(H>=O)return{outcome:"retune",target:"both"};H>=O-Ye&&(P=P??"both")}return P!==void 0?{outcome:"near",target:P}:{outcome:"no"}},m=l=>l.outcome==="direct"?4:l.outcome==="retune"?l.target==="both"?2:3:l.outcome==="near"?1:0,y=l=>[...l].sort().join("|"),I=new Set(_e(h.map(({name:l,base:d})=>[l,ae(f(d,u,0,G))]),O,["normal"]).map(l=>y(l.pair))),D=new Map(h.map(l=>[l.name,l])),W=new Map;for(const{pair:l,distance:d}of S){const g=D.get(l[0]),b=D.get(l[1]),w=i(g.name)&&i(b.name),M=c(g,b,u,a.min,a.max);if(M.outcome==="direct"||M.outcome==="retune"){const T=M.target??(w?"one of them":`"${i(g.name)?g.name:b.name}"`);I.has(y(l))?p.push(`Status colors "${l[0]}" and "${l[1]}" are hard to distinguish under normal vision (distance ${Je(d)} < ${O}); status meanings must stay distinguishable \u2014 retune ${T} via intents.`):p.push(`Status colors "${l[0]}" and "${l[1]}" are hard to distinguish as rendered (distance ${Je(d)} < ${O}); the actionBackground chroma band ({ min: ${a.min}, max: ${a.max} }) pushes them together \u2014 widen the band, or retune ${T} via intents.`);continue}const E=c(g,b,u,0,G);let B={outcome:"no"};for(let T=1;T<=19&&B.outcome!=="direct";T+=1){const _=T*.05;if(Math.abs(_-u)<.001)continue;const F=c(g,b,_,a.min,a.max);m(F)>m(B)&&(B=F)}let L={outcome:"no"};const R=E.outcome==="direct"||E.outcome==="retune",P=B.outcome==="direct"||B.outcome==="retune";if(!R&&!P)for(let T=1;T<=19&&L.outcome!=="direct";T+=1){const _=c(g,b,T*.05,0,G);m(_)>m(L)&&(L=_)}const H=Et(E,B,L),v=`${M.outcome}|${H}`;let k=W.get(v);k||(k=[],W.set(v,k)),k.push(l)}for(const[l,d]of W){const g=l.indexOf("|"),b=l.slice(0,g),w=l.slice(g+1),M=d.map(([L,R])=>`"${L}"/"${R}"`),E=M.length>1?`${M.slice(0,-1).join(", ")} and ${M[M.length-1]}`:M[0],B=b==="near"?`Status colors ${E} may not separate by retuning as rendered: at the action stop's lightness (${u}) with the actionBackground chroma band ({ min: ${a.min}, max: ${a.max} }), the closest reachable retune found comes within the audit's search margin of the ${O} threshold`:`Status colors ${E} cannot be separated as rendered: at the action stop's lightness (${u}) with the actionBackground chroma band ({ min: ${a.min}, max: ${a.max} }), no intent retuning can pull ${d.length>1?"these pairs":"the pair"} ${O} apart`;p.push(B+w)}return p}function Et(e,n,t){if(e.outcome==="direct"&&n.outcome==="direct")return" \u2014 widen the chroma band or move the action lightness stop.";if(e.outcome==="direct")return n.outcome==="no"?"; no other action lightness stop can help while the band holds \u2014 widen the chroma band.":" \u2014 widen the chroma band.";if(n.outcome==="direct")return e.outcome==="no"?"; no wider chroma band can help at this lightness \u2014 move the action lightness stop.":" \u2014 move the action lightness stop.";if(e.outcome==="retune"&&n.outcome==="retune")return` \u2014 widen the chroma band or move the action lightness stop, then retune ${e.target} via intents.`;if(e.outcome==="retune")return n.outcome==="no"?`; no other action lightness stop can help while the band holds \u2014 widen the chroma band, then retune ${e.target} via intents.`:` \u2014 widen the chroma band, then retune ${e.target} via intents.`;if(n.outcome==="retune")return e.outcome==="no"?`; no wider chroma band can help at this lightness \u2014 move the action lightness stop, then retune ${n.target} via intents.`:` \u2014 move the action lightness stop, then retune ${n.target} via intents.`;const s=e.outcome==="no"&&n.outcome==="no"?"; neither a wider chroma band alone nor another stop alone can help":"; neither a wider chroma band alone nor another stop alone provably helps";return t.outcome==="direct"?`${s} \u2014 change the band and the stop together.`:t.outcome==="retune"?`${s} \u2014 change the band and the stop together, then retune ${t.target} via intents.`:"; no explored band or stop change provably separates this pair."}function Ft(e,n){const t=ke(e),s=ke(n),a=t.error!==void 0?{valid:!1,errors:[t.error],warnings:[]}:Ae(t.value),u=s.error!==void 0?{valid:!1,errors:[s.error],warnings:[]}:Ae(s.value,We),f=[...a.errors.map(p=>`light: ${p}`),...u.errors.map(p=>`dark: ${p}`)],h=[...a.warnings.map(p=>`light: ${p}`),...u.warnings.map(p=>`dark: ${p}`)];if(a.valid&&u.valid){const p=new Set(Object.keys(t.value?.contexts??{})),S=new Set(Object.keys(s.value?.contexts??{})),$=[...S].filter(C=>!p.has(C)).sort(),x=[...p].filter(C=>!S.has(C)).sort();($.length>0||x.length>0)&&f.push(`contexts must declare the same names in both schemes. Missing from light: ${$.join(", ")||"(none)"}. Missing from dark: ${x.join(", ")||"(none)"}.`)}return{valid:f.length===0,errors:f,warnings:h}}const _t=["anchors","angles","contexts","dataPalette","dataRamps","intents","roles","chroma","lightness","semanticHues","semanticMappings","variantChroma"];function It(e,n){const t={};for(const[s,a]of Object.entries(e))A(s)&&(t[s]=a);for(const[s,a]of Object.entries(n))a!==void 0&&A(s)&&(t[s]=a);for(const s of _t){const a=e[s],u=n[s];if(a&&typeof a=="object"&&!Array.isArray(a)&&u&&typeof u=="object"&&!Array.isArray(u)){if(s==="anchors"){t[s]=Ke(a,u);continue}if(s==="contexts"){t[s]=vt(a,u);continue}if(s==="dataRamps"){t[s]=Ge(a,u);continue}const f={};for(const[h,p]of Object.entries(a))A(h)&&(f[h]=p);for(const[h,p]of Object.entries(u))p!==void 0&&A(h)&&(f[h]=p);t[s]=f}}return t}function Wt(...e){let n={};for(const t of e){if(!t)continue;const s=xt(t);s&&(n=It(n,s))}return xe(n)}function Xe(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")}const Ze={borderRadius:.1,fontBody:'"Noto Sans", sans-serif',fontWeightBody:"normal",fontHeadings:'"Inika", serif',fontWeightHeadings:"normal",fontBrand:'"Inika", serif',fontWeightBrand:"normal",fontMonospace:'"JetBrains Mono", monospace',fontWeightMonospace:"normal",seedColor:"oklch(.07 0.15 216)"};function jt(e){return xe({...Ze,pageBackgroundImage:`url("${Xe(e)}")`,pageBackgroundImageOpacity:.5})}function Kt(e){return xe({...Ze,pageBackgroundImage:`url("${Xe(e)}")`,pageBackgroundImageOpacity:.55})}export{z as ANCHOR_SLUG_PATTERN,ye as COLOR_SOURCES,$t as DEFAULT_DARK_LIGHTNESS,We as DEFAULT_DARK_THEME,bt as DEFAULT_LIGHT_LIGHTNESS,Se as DEFAULT_LIGHT_THEME,be as DEFAULT_SEMANTIC_MAPPINGS,U as LIGHTNESS_KEYS,_t as NESTED_THEME_KEYS,Z as ROLE_NAMES,pt as ROLE_PAIRED_INK,He as ROLE_TOKEN_PLAN,ge as SEMANTIC_COLOR_NAMES,Q as STATUS_COLOR_SOURCES,Ne as TOKEN_PAIRINGS,yt as VARIANT_COLOR_SOURCES,Kt as buildTaprootDarkTheme,jt as buildTaprootLightTheme,De as compileRoles,xe as encodeTheme,Wt as layerThemes,It as mergePartials,se as mergeTheme,de as parseAnchorSource,xt as parseTheme,Le as resolveAnchorColor,ut as resolveDataColorSource,Dt as semanticToCSS,Nt as validateTheme,Ft as validateThemePair};
|
|
1
|
+
import{UNSAFE_KEYS as st,isSafeKey as v}from"./unsafe-keys.js";import{ACCEPTED_COLOR_FORMS as te,apcaContrast as rt,clampChannel as me,deltaEOK as at,deriveSemantic as ae,gamutMapToSRGB as de,linearRgbToOklab as it,oklchToSRGB as ct,parseCssColor as W,parseOklch as ut,serializeOklch as ie,srgbToLinearRGB as ft}from"./color-engine.js";import{computeVariants as he,parseAnchorSource as lt,resolveAnchorColor as pt,resolveMappingSource as ce}from"./variant-engine.js";import{auditColorDistances as He,auditDataPalette as mt,DATA_SERIES_KEYS as ue,DEFAULT_DATA_PALETTE as ge,DEFAULT_DATA_RAMP_STEPS as dt,MAX_DATA_RAMP_STEPS as ye,MIN_DATA_RAMP_LIGHTNESS_STEP as Le,MIN_DATA_RAMP_STEPS as be}from"./data-colors.js";const V=/^[a-z][a-z0-9-]*$/;function $e(e){return lt(e)}function Pe(e,n){return pt(e,n)}function ht(e,n){const t=$e(e);if(t){const o=Pe(n,t);return o&&W(o)?o:null}return W(e)?e:null}const ne=["canvas","ink","accent","action","structure"],Se={canvas:{color:[["background","surface"],["layer1","raised1"],["layer2","raised2"],["layer3","raised3"],["layer4","raised4"]]},ink:{color:[["text","text"],["inputSelection","text"]],heading:[["headings","muted"],["headingsHover","ink"]]},accent:{color:[["linkHoverBg","raised2"],["inputSelectionBg","raised2"],["inputCaret","ink"]],text:[["link","accent"]],hover:[["linkHover","text"]]},action:{color:[["actionBackground","muted"]],ink:[["actionText","surface"]]},structure:{color:[["border","border"],["shadow","shadow"]]}},gt=new Set(["action.color"]),yt={canvas:"background",ink:"text",accent:"link",action:"actionBackground",structure:"border"},bt={"action.ink":{role:"canvas",slot:"color"}},$t=.45,St=.045;function De(e,n,t){const o=We.actionText,a=[...j].sort((g,x)=>e[g]-e[x]||j.indexOf(g)-j.indexOf(x)),c=n?a.filter(g=>n(g)>=o.targetLc):a,f=t?c.filter(g=>t(g)>=St):c,p=f.length>0?f:c,m=p.length>0?p:a;let O,k=1/0;for(const g of m){const x=Math.abs(e[g]-$t);x<k&&(k=x,O=g)}return O??"muted"}function kt(e,n){const t=n[e]>.5;let o=j[0];for(const a of j)(t?n[a]<n[o]:n[a]>n[o])&&(o=a);return o}const xt={"accent.hover":"text"};function At(e,n){const t=new Map;try{const o=le(n,e),a=(c,f,p,m)=>{const O=$e(f),k=O?Pe(m,O):null,g=k===null?null:W(k),x=t.get(c)??[];x.some(P=>P.source===f&&P.chroma===g?.c)||(x.push({source:f,where:p,chroma:g?.c}),t.set(c,x))};for(const[c,f]of Object.entries(o.semanticMappings))f.source.startsWith("anchor:")&&a(c,f.source,"the root table",o.anchors);for(const c of Object.keys(o.contexts)){const f=Xe(o,c);if(f)for(const[p,m]of Object.entries(f.semanticMappings))m.source.startsWith("anchor:")&&a(p,m.source,`contexts.${c}`,f.anchors)}}catch{return new Map}return t}function q(e,n){if(e===void 0)return;if(typeof e=="string")return n==="color"?e:void 0;const t=e[n];return typeof t=="string"?t:void 0}function Ne(e,n,t,o={}){const a={},c={};for(const[f,p]of Object.entries(o.explicitMappings??{}))p!==void 0&&(c[f]=p.lightness);for(const f of ne){const p=e[f];if(p!==void 0)for(const[m,O]of Object.entries(Se[f])){const k=bt[`${f}.${m}`];let g=q(p,m),x=!1;if(g===void 0){k&&(g=q(e[k.role],k.slot),g??=t[yt[k.role]]?.source,x=g!==void 0);const P=xt[`${f}.${m}`];P!==void 0&&(g??=q(p,P)),g??=q(p,"color")}if(g!==void 0)for(const[P,s]of O){let r=s;if(gt.has(`${f}.${m}`))r=De(n,o.actionSurfaceContrast?i=>o.actionSurfaceContrast(g,i):void 0,o.actionSurfaceSeparation?i=>o.actionSurfaceSeparation(g,i):void 0);else if(x&&k){const i=We[P],u=(i&&c[i.bg])??De(n,o.actionSurfaceContrast?d=>o.actionSurfaceContrast(q(p,"color"),d):void 0,o.actionSurfaceSeparation?d=>o.actionSurfaceSeparation(q(p,"color"),d):void 0);r=kt(u,n)}a[P]={source:g,lightness:r}}}}return a}const We={text:{bg:"background",targetLc:75},dangerText:{bg:"background",targetLc:75},headings:{bg:"background",targetLc:60},headingsHover:{bg:"background",targetLc:60},link:{bg:"background",targetLc:75},linkHover:{bg:"linkHoverBg",targetLc:75},actionText:{bg:"actionBackground",targetLc:75},inputCaret:{bg:"layer2",targetLc:60},inputSelection:{bg:"inputSelectionBg",targetLc:60}},Q=["background","layer1","layer2","layer3","layer4","actionBackground","actionText","border","shadow","text","dangerText","headings","headingsHover","link","linkHover","linkHoverBg","inputCaret","inputSelection","inputSelectionBg"],ke=["primary","analogous-left","analogous-right","complementary","split-complementary-left","split-complementary-right","triadic-left","triadic-right","danger","success","warning","info"],ee=["danger","success","warning","info"],Mt=["analogous-left","analogous-right","complementary","split-complementary-left","split-complementary-right","triadic-left","triadic-right","danger","success","warning","info"],j=["surface","raised1","raised2","raised3","raised4","accent","muted","text","border","ink","shadow"],vt={surface:.99,raised1:.97,raised2:.9,raised3:.8,raised4:.72,accent:.5,muted:.45,text:.35,border:.3,ink:.25,shadow:.2},Ot={surface:.15,raised1:.2,raised2:.3,raised3:.4,raised4:.36,accent:.6,muted:.75,text:.85,border:.7,ink:.95,shadow:.6},xe={background:{source:"primary",lightness:"surface"},layer1:{source:"primary",lightness:"raised1"},layer2:{source:"primary",lightness:"raised2"},layer3:{source:"primary",lightness:"raised3"},layer4:{source:"primary",lightness:"raised4"},actionBackground:{source:"primary",lightness:"raised3"},actionText:{source:"primary",lightness:"ink"},border:{source:"primary",lightness:"border"},shadow:{source:"primary",lightness:"shadow"},text:{source:"primary",lightness:"text"},dangerText:{source:"danger",lightness:"text"},headings:{source:"primary",lightness:"muted"},headingsHover:{source:"primary",lightness:"text"},link:{source:"complementary",lightness:"accent"},linkHover:{source:"complementary",lightness:"text"},linkHoverBg:{source:"triadic-left",lightness:"raised2"},inputCaret:{source:"triadic-right",lightness:"ink"},inputSelection:{source:"complementary",lightness:"text"},inputSelectionBg:{source:"triadic-left",lightness:"raised2"}},J=.4;function Ae(){const e={};for(const n of Q)e[n]={min:0,max:J};return e}const Fe={seedColor:"oklch(0.7 0.125 216)",fontBody:"",fontHeadings:"",fontBrand:"",fontMonospace:"",fontWeightBody:"normal",fontWeightHeadings:"bold",fontWeightBrand:"bold",fontWeightMonospace:"normal",stylesheets:[],rootFontSize:16,typeRatio:1.25,spaceRatio:1.618,borderRadius:.2,viewportMin:320,viewportMax:1200,angles:{analogous:30,complementary:180,splitComplementary:30,triadic:120},semanticHues:{danger:27,success:150,warning:90,info:244},variantChroma:{},intents:{},chroma:Ae(),semanticMappings:{...xe},anchors:{},roles:{},contexts:{},dataPalette:{...ge},dataRamps:{}},Me={...Fe,chroma:Ae(),semanticMappings:{...xe},anchors:{},roles:{},contexts:{},dataPalette:{...ge},dataRamps:{},lightness:{...vt}},je={...Fe,chroma:Ae(),semanticMappings:{...xe},anchors:{},roles:{},contexts:{},dataPalette:{...ge},dataRamps:{},lightness:{...Ot}},fe=new WeakMap;fe.set(Me,new Set),fe.set(je,new Set);function Rt(e,n){return st.has(e)?void 0:n}function Jt(e){return`--esp-color-${e.replace(/([A-Z])/g,"-$1").replace(/(\d)/g,"-$1").toLowerCase()}`}function Ct(e){try{const n=Ke(e),t=JSON.parse(n,Rt);return typeof t!="object"||t===null||Array.isArray(t)?null:t}catch{return null}}const ve="\xEF\xBB\xBF";function Tt(e){if(/^[\u0000-\u007f]*$/.test(e))return btoa(e);const n=new TextEncoder().encode(e);let t=ve;for(const o of n)t+=String.fromCharCode(o);return btoa(t)}function Ke(e){const n=atob(e);if(!n.startsWith(ve))return n;const t=Uint8Array.from(n.slice(ve.length),o=>o.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function Oe(e){return Tt(JSON.stringify(e))}function Bt(e){const n={};for(const t of ee){const o=e[t];typeof o=="string"&&(n[t]=o.startsWith("anchor:")?o:oe(o))}return n}function oe(e){if(ut(e))return e;const n=W(e);return n?ie(n):e}function Ue(e,n){const t={};for(const[o,a]of Object.entries(e))v(o)&&(t[o]=a);if(!n)return t;for(const[o,a]of Object.entries(n)){if(a===void 0||!v(o))continue;const c=t[o];if(c!==void 0&&typeof a=="object"&&a!==null){const f={};if(typeof c=="string")f.color=c;else for(const[p,m]of Object.entries(c))v(p)&&(f[p]=m);for(const[p,m]of Object.entries(a))m!==void 0&&v(p)&&(f[p]=m);t[o]=f;continue}t[o]=a}return t}function ze(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const n=e,t={};for(const o of ne){const a=n[o];a!==void 0&&(t[o]=a)}if(typeof n.lightness=="object"&&n.lightness!==null&&!Array.isArray(n.lightness)){const o={};for(const a of j){const c=n.lightness[a];c!==void 0&&(o[a]=c)}t.lightness=o}if(typeof n.semanticMappings=="object"&&n.semanticMappings!==null&&!Array.isArray(n.semanticMappings)){const o={};for(const[a,c]of Object.entries(n.semanticMappings)){if(!v(a)||!Q.includes(a)||typeof c!="object"||c===null||Array.isArray(c))continue;const{source:f,lightness:p}=c;typeof f=="string"&&(typeof p!="string"||!j.includes(p)||(o[a]={source:f,lightness:p}))}Object.keys(o).length>0&&(t.semanticMappings=o)}return t}function wt(e,n){const t={};for(const[o,a]of Object.entries(e)){if(!v(o)||!V.test(o))continue;const c=ze(a);c&&(t[o]=c)}if(!n)return t;for(const[o,a]of Object.entries(n)){if(!v(o)||!V.test(o)||a===void 0)continue;const c=ze(a);if(!c)continue;const f=t[o];t[o]={...f??{},...c,...f?.lightness||c.lightness?{lightness:{...f?.lightness,...c.lightness}}:{},...f?.semanticMappings||c.semanticMappings?{semanticMappings:{...f?.semanticMappings,...c.semanticMappings}}:{}}}return t}function K(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function U(e){const n={};for(const[t,o]of Object.entries(e))o!==void 0&&v(t)&&(n[t]=o);return n}function Ge(e){if(!K(e))return e;const n=U(e);return K(e.lightness)&&(n.lightness=U(e.lightness)),n}function Et(e,n){const t={};for(const[o,a]of Object.entries(e))v(o)&&(t[o]=Ge(a));if(!n)return t;for(const[o,a]of Object.entries(n)){if(!v(o)||a===void 0)continue;const c=t[o];if(!K(c)||!K(a)){t[o]=Ge(a);continue}const f={...U(c),...U(a)};K(c.lightness)&&K(a.lightness)?f.lightness={...U(c.lightness),...U(a.lightness)}:K(a.lightness)&&(f.lightness=U(a.lightness)),K(c.semanticMappings)&&K(a.semanticMappings)?f.semanticMappings={...U(c.semanticMappings),...U(a.semanticMappings)}:K(a.semanticMappings)&&(f.semanticMappings=U(a.semanticMappings)),t[o]=f}return t}function _t(e){const n={};for(const[t,o]of Object.entries(e)){if(!v(t))continue;if(typeof o=="string"){n[t]=oe(o);continue}const a={};for(const[c,f]of Object.entries(o))v(c)&&(a[c]=typeof f=="string"?oe(f):f);n[t]=a}return n}function se(e){return typeof e!="string"?"":e.startsWith("anchor:")?e:oe(e)}function It(e){const n={};for(const t of ue)n[t]=se(e[t]);return n}function Ve(e,n){const t={};for(const[o,a]of Object.entries(e))v(o)&&V.test(o)&&a&&typeof a=="object"&&!Array.isArray(a)&&(t[o]={...a});if(!n)return t;for(const[o,a]of Object.entries(n)){if(!v(o)||!V.test(o)||!a||typeof a!="object"||Array.isArray(a))continue;const c=t[o],f=c!==void 0&&a.type!==void 0&&a.type!==c.type;t[o]={...f?{}:c??{},...a}}return t}function Ht(e){const n={};for(const[t,o]of Object.entries(e))if(v(t)){if(o.type==="sequential"&&typeof o.source=="string"){n[t]={...o,source:se(o.source)};continue}if(o.type==="diverging"&&typeof o.start=="string"&&typeof o.end=="string"){n[t]={...o,start:se(o.start),end:se(o.end),...typeof o.neutral=="string"?{neutral:se(o.neutral)}:{}};continue}n[t]={...o}}return n}function Je(e){const n=W(e.seedColor);if(!n)return;const t=he(n,e);return(o,a)=>{const c=ce(o,t,e.anchors)??t.primary,f=e.chroma.actionBackground,p=ae(c,e.lightness[a],f.min,f.max),m={l:p.l>.5?0:1,c:0,h:0};return Math.abs(rt(m,p))}}function Lt(e,n,t){if(n?.background)return n.background;const o=q(e.canvas,"color");if(o!==void 0){const a=Se.canvas.color?.find(([c])=>c==="background");if(a)return{source:o,lightness:a[1]}}return t.background}function Ye(e,n){const t=W(e.seedColor);if(!t||!n)return;const o=he(t,e),a=ce(n.source,o,e.anchors)??o.primary,c=e.chroma.background,f=ae(a,e.lightness[n.lightness],c.min,c.max);return(p,m)=>{const O=ce(p,o,e.anchors)??o.primary,k=e.chroma.actionBackground,g=ae(O,e.lightness[m],k.min,k.max);return at(g,f)}}function Pt(e){const n=fe.get(e);if(n)return new Set(n);const t=new Set,o=Ne(e.roles,e.lightness,e.semanticMappings,{actionSurfaceContrast:Je(e),actionSurfaceSeparation:Ye(e,e.semanticMappings.background)});for(const[a,c]of Object.entries(o)){const f=e.semanticMappings[a];(f.source!==c.source||f.lightness!==c.lightness)&&t.add(a)}return t}function le(e,n){const t={...e.roles,...n.roles},o=wt(e.contexts,n.contexts),a={...e.lightness,...n.lightness},c=_t(Ue(e.anchors,n.anchors)),f=typeof n.seedColor=="string"?oe(n.seedColor):e.seedColor,p=n.semanticMappings,m={...e.angles,...n.angles},O={...e.semanticHues,...n.semanticHues},k={...e.variantChroma,...n.variantChroma},g=Bt({...e.intents,...n.intents}),x=re(e.chroma,n.chroma),P=It(re(e.dataPalette,n.dataPalette)),s=Ht(Ve(e.dataRamps,n.dataRamps)),r=Pt(e),i=new Set(r),u={};for(const S of r)u[S]=e.semanticMappings[S];for(const[S,A]of Object.entries(p??{}))A!==void 0&&(i.add(S),u[S]=A);const d=re(e.semanticMappings,p),y={angles:m,anchors:c,chroma:x,intents:g,lightness:a,seedColor:f,semanticHues:O,variantChroma:k},E=Je(y),D=Ye(y,Lt(t,u,d)),l=Ne(t,a,d,{explicitMappings:u,actionSurfaceContrast:E,actionSurfaceSeparation:D}),b={};for(const[S,A]of Object.entries(l))i.has(S)||(b[S]=A);const $=re(re(e.semanticMappings,b),p),h={...e,seedColor:f,fontBody:n.fontBody??e.fontBody,fontHeadings:n.fontHeadings??e.fontHeadings,fontBrand:n.fontBrand??e.fontBrand,fontMonospace:n.fontMonospace??e.fontMonospace,fontWeightBody:String(n.fontWeightBody??e.fontWeightBody),fontWeightHeadings:String(n.fontWeightHeadings??e.fontWeightHeadings),fontWeightBrand:String(n.fontWeightBrand??e.fontWeightBrand),fontWeightMonospace:String(n.fontWeightMonospace??e.fontWeightMonospace),stylesheets:n.stylesheets??[...e.stylesheets],rootFontSize:n.rootFontSize??e.rootFontSize,typeRatio:n.typeRatio??e.typeRatio,spaceRatio:n.spaceRatio??e.spaceRatio,borderRadius:n.borderRadius??e.borderRadius,viewportMin:n.viewportMin??e.viewportMin,viewportMax:n.viewportMax??e.viewportMax,angles:m,semanticHues:O,variantChroma:k,intents:g,lightness:a,chroma:x,semanticMappings:$,anchors:c,roles:t,contexts:o,dataPalette:P,dataRamps:s};return n.pageBackgroundImage!==void 0&&(h.pageBackgroundImage=n.pageBackgroundImage),n.pageBackgroundImageOpacity!==void 0&&(h.pageBackgroundImageOpacity=n.pageBackgroundImageOpacity),n.boxBackgroundImage!==void 0&&(h.boxBackgroundImage=n.boxBackgroundImage),n.boxBackgroundImageOpacity!==void 0&&(h.boxBackgroundImageOpacity=n.boxBackgroundImageOpacity),n.vellumOpacity!==void 0&&(h.vellumOpacity=n.vellumOpacity),n.vellumBackgroundImage!==void 0&&(h.vellumBackgroundImage=n.vellumBackgroundImage),n.vellumBackgroundImageOpacity!==void 0&&(h.vellumBackgroundImageOpacity=n.vellumBackgroundImageOpacity),fe.set(h,new Set(i)),h}const qe=new WeakMap;function Xe(e,n){const t=e.contexts&&Object.prototype.hasOwnProperty.call(e.contexts,n)?e.contexts[n]:void 0;if(!t)return null;let o=qe.get(e);const a=o?.get(n);if(a)return a;const c={};for(const p of ne){const m=t[p];m!==void 0&&(c[p]=m)}const f=le(e,{lightness:t.lightness,roles:c,semanticMappings:t.semanticMappings});return o||(o=new Map,qe.set(e,o)),o.set(n,f),f}function re(e,n){if(!n)return{...e};const t={...e};for(const o of Object.keys(n)){const a=n[o];a!==void 0&&(t[o]=a)}return t}function Re(e){let n;try{n=Ke(e)}catch{return{error:"Failed to decode Base64 string."}}let t;try{t=JSON.parse(n)}catch{return{error:"Decoded string is not valid JSON."}}return typeof t!="object"||t===null||Array.isArray(t)?{error:"Theme must be a JSON object."}:{value:t}}function Yt(e){const n=Re(e);return n.error!==void 0?{valid:!1,errors:[n.error],warnings:[]}:Ce(n.value)}function Ce(e,n=Me){const t=[],o=[];"seedColor"in e&&(typeof e.seedColor!="string"?t.push("seedColor must be a string."):W(e.seedColor)||t.push(`seedColor is not a valid CSS color: "${e.seedColor}". Accepted forms: ${te}.`));for(const s of["fontBody","fontHeadings","fontBrand","fontMonospace"])s in e&&typeof e[s]!="string"&&t.push(`${s} must be a string.`);const a=["normal","bold","lighter","bolder"],c=["inherit","initial","unset","revert","revert-layer"];for(const s of["fontWeightBody","fontWeightHeadings","fontWeightBrand","fontWeightMonospace"])if(s in e){const r=e[s];if(typeof r=="number")(r<1||r>1e3)&&t.push(`${s} numeric value must be 1\u20131000 (got ${r}).`);else if(typeof r=="string"){const i=a.includes(r)||c.includes(r);if(/^\d+$/.test(r)){const d=Number(r);(d<1||d>1e3)&&t.push(`${s} numeric value must be 1\u20131000 (got "${r}").`)}else i||o.push(`${s} = "${r}" is not a standard font-weight value.`)}else t.push(`${s} must be a string or number.`)}"stylesheets"in e&&(Array.isArray(e.stylesheets)?e.stylesheets.some(s=>typeof s!="string")&&t.push("Every entry in stylesheets must be a string."):t.push("stylesheets must be an array of strings."));const f=[["rootFontSize",1,100],["borderRadius",0,10],["viewportMin",100,1e4],["viewportMax",200,1e4]];for(const[s,r,i]of f)if(s in e)if(typeof e[s]!="number"||!isFinite(e[s]))t.push(`${s} must be a finite number.`);else{const u=e[s];r!==void 0&&u<r&&t.push(`${s} must be \u2265 ${r} (got ${u}).`),i!==void 0&&u>i&&o.push(`${s} = ${u} is unusually high (max ${i}).`)}for(const s of["typeRatio","spaceRatio"])if(s in e)if(typeof e[s]!="number"||!isFinite(e[s]))t.push(`${s} must be a finite number.`);else{const r=e[s];r<=1&&t.push(`${s} must be > 1 (got ${r}).`);const i=s==="typeRatio"?1.3:2;r>i&&o.push(`${s} = ${r} is very high (max ${i}); scales may be extreme.`)}if("viewportMin"in e&&"viewportMax"in e){const s=e.viewportMin,r=e.viewportMax;typeof s=="number"&&typeof r=="number"&&s>=r&&t.push(`viewportMin (${s}) must be less than viewportMax (${r}).`)}if("angles"in e)if(typeof e.angles!="object"||e.angles===null)t.push("angles must be an object.");else{const s=e.angles;for(const r of["analogous","complementary","splitComplementary","triadic"])if(r in s)if(typeof s[r]!="number"||!isFinite(s[r]))t.push(`angles.${r} must be a finite number.`);else{const i=s[r];(i<0||i>360)&&o.push(`angles.${r} = ${i} is outside 0\u2013360.`)}}if("semanticHues"in e)if(typeof e.semanticHues!="object"||e.semanticHues===null)t.push("semanticHues must be an object.");else{const s=e.semanticHues;for(const r of["danger","success","warning","info"])if(r in s)if(typeof s[r]!="number"||!isFinite(s[r]))t.push(`semanticHues.${r} must be a finite number.`);else{const i=s[r];(i<0||i>360)&&o.push(`semanticHues.${r} = ${i} is outside 0\u2013360.`)}}if("variantChroma"in e)if(typeof e.variantChroma!="object"||e.variantChroma===null)t.push("variantChroma must be an object.");else{const s=e.variantChroma;for(const r of Mt)if(r in s)if(typeof s[r]!="number"||!isFinite(s[r]))t.push(`variantChroma["${r}"] must be a finite number.`);else{const i=s[r];i<0&&t.push(`variantChroma["${r}"] must be \u2265 0 (got ${i}).`),i>J&&o.push(`variantChroma["${r}"] = ${i} exceeds ${J}.`)}}function p(s,r){if(typeof s!="object"||s===null||Array.isArray(s)){t.push(`${r} must be an object.`);return}const i=s;for(const u of j)if(u in i)if(typeof i[u]!="number"||!isFinite(i[u]))t.push(`${r}.${u} must be a finite number.`);else{const d=i[u];(d<0||d>1)&&t.push(`${r}.${u} must be 0\u20131 (got ${d}).`)}}if("lightness"in e&&p(e.lightness,"lightness"),"chroma"in e)if(typeof e.chroma!="object"||e.chroma===null)t.push("chroma must be an object.");else{const s=e.chroma,r=At(e,n);for(const i of Q)if(i in s){const u=s[i];if(typeof u!="object"||u===null){t.push(`chroma.${i} must be { min, max }.`);continue}const d=u;for(const E of r.get(i)??[])E.chroma!==void 0&&typeof d.min=="number"&&typeof d.max=="number"&&(E.chroma<d.min-1e-9||E.chroma>d.max+1e-9)&&o.push(`chroma.${i} clamps the anchor-sourced token ${i} ("${E.source}", effective in ${E.where}) and moves it off its declared swatch. Remove the band if that is unintended \u2014 anchors otherwise keep their own chroma.`);const y=u;(typeof y.min!="number"||y.min<0)&&t.push(`chroma.${i}.min must be \u2265 0.`),(typeof y.max!="number"||y.max<0||y.max>J)&&t.push(`chroma.${i}.max must be 0\u2013${J}.`),typeof y.min=="number"&&typeof y.max=="number"&&y.min>y.max&&t.push(`chroma.${i}.min (${y.min}) must be \u2264 max (${y.max}).`)}}if("anchors"in e)if(typeof e.anchors!="object"||e.anchors===null||Array.isArray(e.anchors))t.push("anchors must be an object of named colors.");else for(const[s,r]of Object.entries(e.anchors))if(v(s)?V.test(s)||t.push(`anchors: "${s}" is not a valid anchor name; use a lowercase slug (letters, digits, hyphens).`):t.push(`anchors: "${s}" is a reserved JavaScript property name and cannot be an anchor name; rename it.`),ke.includes(s)&&t.push(`anchors: "${s}" collides with a reserved color source name.`),typeof r=="string")W(r)||t.push(`anchors.${s} is not a valid CSS color: "${r}". Accepted forms: ${te}.`);else if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const i=r;typeof i.color!="string"&&t.push(`anchors.${s} must declare its base "color".`);for(const[u,d]of Object.entries(i))v(u)?u!=="color"&&!V.test(u)&&t.push(`anchors.${s}: "${u}" is not a valid slot name; use a lowercase slug.`):t.push(`anchors.${s}: "${u}" is a reserved JavaScript property name and cannot be a slot name; rename it.`),typeof d!="string"?t.push(`anchors.${s}.${u} must be a CSS color string.`):W(d)||t.push(`anchors.${s}.${u} is not a valid CSS color: "${d}". Accepted forms: ${te}.`)}else t.push(`anchors.${s} must be a color string or a { color, \u2026slots } object.`);const m=new Map;if("anchors"in e&&typeof e.anchors=="object"&&e.anchors!==null&&!Array.isArray(e.anchors))for(const[s,r]of Object.entries(e.anchors))m.set(s,r);function O(s,r){const i=$e(s);if(!i){t.push(`${r} "${s}" is not valid anchor syntax; use anchor:<name> or anchor:<name>.<slot>.`);return}if(!m.has(i.name)){const u=[...m.keys()];t.push(`${r} references undeclared anchor "${i.name}". Declared anchors: ${u.length>0?u.join(", "):"(none)"}.`);return}if(i.slot!==void 0){const u=m.get(i.name);if(typeof(typeof u=="object"&&u!==null&&!Array.isArray(u)?u[i.slot]:void 0)!="string"){const y=typeof u=="object"&&u!==null?Object.keys(u).filter(E=>E!=="color"):[];t.push(`${r} references unknown slot "${i.slot}" on anchor "${i.name}". Declared slots: ${y.length>0?y.join(", "):"(none)"}.`)}}}function k(s,r){if(s.startsWith("anchor:")){O(s,r);return}ke.includes(s)||t.push(`${r} must be one of: ${ke.join(", ")}, or a declared anchor as anchor:<name> / anchor:<name>.<slot>.`)}if("intents"in e)if(typeof e.intents!="object"||e.intents===null||Array.isArray(e.intents))t.push("intents must be an object.");else for(const[s,r]of Object.entries(e.intents)){const i=`intents.${s}`;if(!ee.includes(s)){t.push(`${i} is not a status family; expected one of: ${ee.join(", ")}.`);continue}if(typeof r!="string"){t.push(`${i} must be a string (a CSS color or an anchor: reference).`);continue}if(r.startsWith("anchor:")){O(r,i);continue}W(r)||t.push(`${i} "${r}" is not a supported color form or anchor: reference. Accepted forms: ${te}, or anchor:<name> / anchor:<name>.<slot>. An override retunes a family with a declared color; it never points one family at another \u2014 retune, never reassign.`)}function g(s,r){if(s.startsWith("anchor:")){O(s,r);return}W(s)||t.push(`${r} is not a valid CSS color: "${s}". Accepted forms: ${te}, or a declared anchor as anchor:<name> / anchor:<name>.<slot>.`)}if("dataPalette"in e)if(typeof e.dataPalette!="object"||e.dataPalette===null||Array.isArray(e.dataPalette))t.push("dataPalette must be an object with series1\u2013series8 color values.");else{const s=e.dataPalette;for(const[r,i]of Object.entries(s)){if(!ue.includes(r)){t.push(`dataPalette.${r} is not a series slot; expected one of: ${ue.join(", ")}.`);continue}typeof i!="string"?t.push(`dataPalette.${r} must be a CSS color or anchor reference string.`):g(i,`dataPalette.${r}`)}}if("dataRamps"in e)if(typeof e.dataRamps!="object"||e.dataRamps===null||Array.isArray(e.dataRamps))t.push("dataRamps must be an object of named ramp declarations.");else for(const[s,r]of Object.entries(e.dataRamps)){if(v(s)?V.test(s)||t.push(`dataRamps: "${s}" is not a valid ramp name; use a lowercase slug (letters, digits, hyphens).`):t.push(`dataRamps: "${s}" is a reserved JavaScript property name and cannot be a ramp name; rename it.`),typeof r!="object"||r===null||Array.isArray(r)){t.push(`dataRamps.${s} must be a sequential or diverging ramp object.`);continue}const i=r,u=i.steps??dt;if((typeof u!="number"||!Number.isInteger(u)||u<be||u>ye)&&t.push(`dataRamps.${s}.steps must be an integer from ${be} through ${ye}.`),i.type==="sequential"){typeof i.source!="string"?t.push(`dataRamps.${s}.source must be a CSS color or anchor reference string.`):g(i.source,`dataRamps.${s}.source`);const d=i.lightnessStart??.95,y=i.lightnessEnd??.25;for(const[E,D]of[["lightnessStart",d],["lightnessEnd",y]])(typeof D!="number"||!Number.isFinite(D)||D<0||D>1)&&t.push(`dataRamps.${s}.${E} must be a finite number from 0 through 1.`);typeof d=="number"&&typeof y=="number"&&d<=y?t.push(`dataRamps.${s}.lightnessStart must be greater than lightnessEnd.`):typeof d=="number"&&Number.isFinite(d)&&typeof y=="number"&&Number.isFinite(y)&&typeof u=="number"&&Number.isInteger(u)&&u>=be&&u<=ye&&(d-y)/(u-1)<=Le&&t.push(`dataRamps.${s} lightness bounds must leave more than ${Le} lightness between serialized stops.`);continue}if(i.type==="diverging"){typeof u=="number"&&Number.isInteger(u)&&u%2===0&&t.push(`dataRamps.${s}.steps must be odd so the neutral is the exact midpoint.`);for(const d of["start","end"])typeof i[d]!="string"?t.push(`dataRamps.${s}.${d} must be a CSS color or anchor reference string.`):g(i[d],`dataRamps.${s}.${d}`);"neutral"in i&&(typeof i.neutral!="string"?t.push(`dataRamps.${s}.neutral must be a CSS color or anchor reference string.`):g(i.neutral,`dataRamps.${s}.neutral`));continue}t.push(`dataRamps.${s}.type must be "sequential" or "diverging".`)}if("dataPalette"in e&&t.length===0){const s=le(Me,e),r={};let i=!0;for(const u of ue){const d=ht(s.dataPalette[u],s.anchors);if(!d){i=!1;break}r[u]=d}if(i)for(const u of mt(r))o.push(`dataPalette.${u.series[0]} and dataPalette.${u.series[1]} are only ${u.distance.toFixed(4)} apart under ${u.simulation} simulation (minimum ${u.threshold.toFixed(4)}); also distinguish the series with labels, shapes, or patterns.`)}function x(s,r){if(typeof s!="object"||s===null||Array.isArray(s)){t.push(`${r} must be an object.`);return}const i=s;for(const[u,d]of Object.entries(i)){const y=`${r}.${u}`;if(!ne.includes(u)){t.push(`${y} is not a role; expected one of: ${ne.join(", ")}. (The status family is reserved and is not a role.)`);continue}const E=u,D=Se[E];if(typeof d=="string"){k(d,y);continue}if(typeof d!="object"||d===null||Array.isArray(d)){t.push(`${y} must be a color source or a { color, \u2026slots } object.`);continue}const l=d;typeof l.color!="string"&&t.push(`${y} must declare its base "color".`);for(const[b,$]of Object.entries(l)){if(!Object.prototype.hasOwnProperty.call(D,b)||!v(b)){const h=Object.keys(D).filter(S=>S!=="color");t.push(`${y}.${b} is not a slot of the ${E} role. Declared slots: ${h.length>0?h.join(", "):"(none)"}.`);continue}typeof $!="string"?t.push(`${y}.${b} must be a color source string.`):k($,`${y}.${b}`)}}}if("roles"in e&&x(e.roles,"roles"),"contexts"in e)if(typeof e.contexts!="object"||e.contexts===null||Array.isArray(e.contexts))t.push("contexts must be an object.");else for(const[s,r]of Object.entries(e.contexts)){if(!v(s)||!V.test(s)){t.push(`contexts.${s} must be a lowercase slug matching ${V.source}.`);continue}if(typeof r!="object"||r===null||Array.isArray(r)){x(r,`contexts.${s}`);continue}const i=r,u=Object.fromEntries(Object.entries(i).filter(([d])=>d!=="lightness"&&d!=="semanticMappings"));x(u,`contexts.${s}`),"lightness"in i&&p(i.lightness,`contexts.${s}.lightness`),"semanticMappings"in i&&P(i.semanticMappings,`contexts.${s}.semanticMappings`)}function P(s,r){if(typeof s!="object"||s===null||Array.isArray(s)){t.push(`${r} must be an object.`);return}const i=s;for(const u of Object.keys(i))Q.includes(u)||t.push(`${r}.${u} is not a semantic token; expected one of: ${Q.join(", ")}.`);for(const u of Q)if(u in i){const d=i[u];if(typeof d!="object"||d===null){t.push(`${r}.${u} must be { source, lightness }.`);continue}const y=d;typeof y.source!="string"?t.push(`${r}.${u}.source must be a string.`):k(y.source,`${r}.${u}.source`),(typeof y.lightness!="string"||!j.includes(y.lightness))&&t.push(`${r}.${u}.lightness must be one of: ${j.join(", ")}.`)}}"semanticMappings"in e&&P(e.semanticMappings,"semanticMappings");for(const s of["pageBackgroundImage","boxBackgroundImage","vellumBackgroundImage"])s in e&&typeof e[s]!="string"&&t.push(`${s} must be a string.`);for(const s of["pageBackgroundImageOpacity","boxBackgroundImageOpacity","vellumOpacity","vellumBackgroundImageOpacity"])if(s in e)if(typeof e[s]!="number"||!isFinite(e[s]))t.push(`${s} must be a finite number.`);else{const r=e[s];(r<0||r>1)&&t.push(`${s} must be 0\u20131 (got ${r}).`)}return o.push(...Dt(e,n)),{valid:t.length===0,errors:t,warnings:o}}const T=.045;function Dt(e,n){try{return Nt(e,n)}catch{return[]}}function Nt(e,n){const t=le(n,e),o=et(t),a=[...o],c=new Set(o);for(const f of Object.keys(t.contexts)){const p=Xe(t,f);if(p)for(const m of et(p))c.has(m)||a.push(`contexts.${f}: ${m}`)}return a}function Wt(e){const n=ct(de(e)),t=ft(n);return it({r:me(t.r),g:me(t.g),b:me(t.b)})}function X(e,n){return Math.hypot(e.L-n.L,e.a-n.a,e.b-n.b)}function Y(e){return Wt(W(ie(de(e))))}function Ze(e){return(Math.floor(e*1e4)/1e4).toFixed(4)}const Z=2,Qe=1e-4;function et(e){const n=W(e.seedColor);if(!n)return[];const t=he(n,e),o=e.semanticMappings.actionBackground,a=e.chroma.actionBackground,c=e.lightness[o.lightness],f=(l,b,$,h)=>de(ae(l,b,$,h)),p=ee.map(l=>({name:l,base:t[l]})),m=[];if(ee.includes(o.source))m.push(`actionBackground is sourced from the "${o.source}" status family: ordinary and ${o.source}-intent action surfaces render identically (their labels may still differ). Remap the action to a non-status source \u2014 retuning "${o.source}" via intents moves both colors together.`);else{const l=ce(o.source,t,e.anchors);l&&p.push({name:"action",base:l})}const O=He(p.map(({name:l,base:b})=>[l,ie(f(b,c,a.min,a.max))]),T,["normal"]);if(O.length===0)return m;const k=new Map,g=(l,b)=>{const $=`${l}:${b}`;let h=k.get($);if(!h){h=[];for(let S=0;S<360;S+=Z)h.push(Y({l,c:b,h:S}));k.set($,h)}return h},x=T-.002,P=(l,b,$,h)=>{const S=Math.hypot(l.a,l.b),A=Math.atan2(l.b,l.a)*180/Math.PI+180;let _=0;for(const B of $===h?[h]:[$,h]){if(B+S<T-1e-4)continue;let H=A,C=X(Y({l:b,c:B,h:A}),l);if(C>=T)return C;const N=g(b,B);for(let R=0;R<N.length;R+=1){const M=X(N[R],l);if(M>=T)return M;M>C&&(C=M,H=R*Z)}let L=H;for(let R=H-Z;R<=H+Z;R+=.1){const M=X(Y({l:b,c:B,h:R}),l);if(M>=T)return M;M>C&&(C=M,L=R)}if(C>=x)for(let R=L-.1;R<=L+.1;R+=.001){const M=X(Y({l:b,c:B,h:R}),l);if(M>=T)return M;M>C&&(C=M)}C>_&&(_=C)}return _},s=(l,b,$)=>{const h=b===$?[$]:[b,$];let S=0;for(const A of h)for(const _ of h){if(A+_<T-1e-4)continue;const B=g(l,A),H=g(l,_);let C=0,N=0,L=-1;for(let I=0;I<B.length;I+=1)for(let F=0;F<H.length;F+=1){const z=X(B[I],H[F]);if(z>=T)return z;z>L&&(L=z,C=I*Z,N=F*Z)}const R=(I,F,z,Te)=>{const Be=[];for(let G=F-z;G<=F+z;G+=Te)Be.push({h:G,lab:Y({l,c:_,h:G})});let pe=-1,we=I,Ee=F;for(let G=I-z;G<=I+z;G+=Te){const ot=Y({l,c:A,h:G});for(const _e of Be){const Ie=X(ot,_e.lab);Ie>pe&&(pe=Ie,we=G,Ee=_e.h)}}return{distance:pe,hueA:we,hueB:Ee}},M=R(C,N,Z,.1);if(M.distance>=T)return M.distance;let w=Math.max(L,M.distance);if(w>=x){const I=R(M.hueA,M.hueB,.1,.001);if(I.distance>w&&(w=I.distance),w>=T)return w}w>S&&(S=w)}return S},r=l=>ee.includes(l),i=(l,b,$,h,S)=>{const A=Y(f(l.base,$,h,S)),_=Y(f(b.base,$,h,S));if(X(A,_)>=T)return{outcome:"direct"};const B=r(l.name)&&r(b.name),H=[l,b].filter(L=>r(L.name)),C=B?"one of them":`"${r(l.name)?l.name:b.name}"`;let N;for(const L of H){const R=P(L===l?_:A,$,h,S);if(R>=T)return{outcome:"retune",target:C};R>=T-Qe&&(N=N??C)}if(B){const L=s($,h,S);if(L>=T)return{outcome:"retune",target:"both"};L>=T-Qe&&(N=N??"both")}return N!==void 0?{outcome:"near",target:N}:{outcome:"no"}},u=l=>l.outcome==="direct"?4:l.outcome==="retune"?l.target==="both"?2:3:l.outcome==="near"?1:0,d=l=>[...l].sort().join("|"),y=new Set(He(p.map(({name:l,base:b})=>[l,ie(f(b,c,0,J))]),T,["normal"]).map(l=>d(l.pair))),E=new Map(p.map(l=>[l.name,l])),D=new Map;for(const{pair:l,distance:b}of O){const $=E.get(l[0]),h=E.get(l[1]),S=r($.name)&&r(h.name),A=i($,h,c,a.min,a.max);if(A.outcome==="direct"||A.outcome==="retune"){const w=A.target??(S?"one of them":`"${r($.name)?$.name:h.name}"`);y.has(d(l))?m.push(`Status colors "${l[0]}" and "${l[1]}" are hard to distinguish under normal vision (distance ${Ze(b)} < ${T}); status meanings must stay distinguishable \u2014 retune ${w} via intents.`):m.push(`Status colors "${l[0]}" and "${l[1]}" are hard to distinguish as rendered (distance ${Ze(b)} < ${T}); the actionBackground chroma band ({ min: ${a.min}, max: ${a.max} }) pushes them together \u2014 widen the band, or retune ${w} via intents.`);continue}const _=i($,h,c,0,J);let B={outcome:"no"};for(let w=1;w<=19&&B.outcome!=="direct";w+=1){const I=w*.05;if(Math.abs(I-c)<.001)continue;const F=i($,h,I,a.min,a.max);u(F)>u(B)&&(B=F)}let H={outcome:"no"};const C=_.outcome==="direct"||_.outcome==="retune",N=B.outcome==="direct"||B.outcome==="retune";if(!C&&!N)for(let w=1;w<=19&&H.outcome!=="direct";w+=1){const I=i($,h,w*.05,0,J);u(I)>u(H)&&(H=I)}const L=Ft(_,B,H),R=`${A.outcome}|${L}`;let M=D.get(R);M||(M=[],D.set(R,M)),M.push(l)}for(const[l,b]of D){const $=l.indexOf("|"),h=l.slice(0,$),S=l.slice($+1),A=b.map(([H,C])=>`"${H}"/"${C}"`),_=A.length>1?`${A.slice(0,-1).join(", ")} and ${A[A.length-1]}`:A[0],B=h==="near"?`Status colors ${_} may not separate by retuning as rendered: at the action stop's lightness (${c}) with the actionBackground chroma band ({ min: ${a.min}, max: ${a.max} }), the closest reachable retune found comes within the audit's search margin of the ${T} threshold`:`Status colors ${_} cannot be separated as rendered: at the action stop's lightness (${c}) with the actionBackground chroma band ({ min: ${a.min}, max: ${a.max} }), no intent retuning can pull ${b.length>1?"these pairs":"the pair"} ${T} apart`;m.push(B+S)}return m}function Ft(e,n,t){if(e.outcome==="direct"&&n.outcome==="direct")return" \u2014 widen the chroma band or move the action lightness stop.";if(e.outcome==="direct")return n.outcome==="no"?"; no other action lightness stop can help while the band holds \u2014 widen the chroma band.":" \u2014 widen the chroma band.";if(n.outcome==="direct")return e.outcome==="no"?"; no wider chroma band can help at this lightness \u2014 move the action lightness stop.":" \u2014 move the action lightness stop.";if(e.outcome==="retune"&&n.outcome==="retune")return` \u2014 widen the chroma band or move the action lightness stop, then retune ${e.target} via intents.`;if(e.outcome==="retune")return n.outcome==="no"?`; no other action lightness stop can help while the band holds \u2014 widen the chroma band, then retune ${e.target} via intents.`:` \u2014 widen the chroma band, then retune ${e.target} via intents.`;if(n.outcome==="retune")return e.outcome==="no"?`; no wider chroma band can help at this lightness \u2014 move the action lightness stop, then retune ${n.target} via intents.`:` \u2014 move the action lightness stop, then retune ${n.target} via intents.`;const o=e.outcome==="no"&&n.outcome==="no"?"; neither a wider chroma band alone nor another stop alone can help":"; neither a wider chroma band alone nor another stop alone provably helps";return t.outcome==="direct"?`${o} \u2014 change the band and the stop together.`:t.outcome==="retune"?`${o} \u2014 change the band and the stop together, then retune ${t.target} via intents.`:"; no explored band or stop change provably separates this pair."}function qt(e,n){const t=Re(e),o=Re(n),a=t.error!==void 0?{valid:!1,errors:[t.error],warnings:[]}:Ce(t.value),c=o.error!==void 0?{valid:!1,errors:[o.error],warnings:[]}:Ce(o.value,je),f=[...a.errors.map(m=>`light: ${m}`),...c.errors.map(m=>`dark: ${m}`)],p=[...a.warnings.map(m=>`light: ${m}`),...c.warnings.map(m=>`dark: ${m}`)];if(a.valid&&c.valid){const m=new Set(Object.keys(t.value?.contexts??{})),O=new Set(Object.keys(o.value?.contexts??{})),k=[...O].filter(x=>!m.has(x)).sort(),g=[...m].filter(x=>!O.has(x)).sort();(k.length>0||g.length>0)&&f.push(`contexts must declare the same names in both schemes. Missing from light: ${k.join(", ")||"(none)"}. Missing from dark: ${g.join(", ")||"(none)"}.`)}return{valid:f.length===0,errors:f,warnings:p}}const jt=["anchors","angles","contexts","dataPalette","dataRamps","intents","roles","chroma","lightness","semanticHues","semanticMappings","variantChroma"];function Kt(e,n){const t={};for(const[o,a]of Object.entries(e))v(o)&&(t[o]=a);for(const[o,a]of Object.entries(n))a!==void 0&&v(o)&&(t[o]=a);for(const o of jt){const a=e[o],c=n[o];if(a&&typeof a=="object"&&!Array.isArray(a)&&c&&typeof c=="object"&&!Array.isArray(c)){if(o==="anchors"){t[o]=Ue(a,c);continue}if(o==="contexts"){t[o]=Et(a,c);continue}if(o==="dataRamps"){t[o]=Ve(a,c);continue}const f={};for(const[p,m]of Object.entries(a))v(p)&&(f[p]=m);for(const[p,m]of Object.entries(c))m!==void 0&&v(p)&&(f[p]=m);t[o]=f}}return t}function Xt(...e){let n={};for(const t of e){if(!t)continue;const o=Ct(t);o&&(n=Kt(n,o))}return Oe(n)}function tt(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")}const nt={borderRadius:.1,fontBody:'"Noto Sans", sans-serif',fontWeightBody:"normal",fontHeadings:'"Inika", serif',fontWeightHeadings:"normal",fontBrand:'"Inika", serif',fontWeightBrand:"normal",fontMonospace:'"JetBrains Mono", monospace',fontWeightMonospace:"normal",seedColor:"oklch(.07 0.15 216)"};function Zt(e){return Oe({...nt,pageBackgroundImage:`url("${tt(e)}")`,pageBackgroundImageOpacity:.5})}function Qt(e){return Oe({...nt,pageBackgroundImage:`url("${tt(e)}")`,pageBackgroundImageOpacity:.55})}export{V as ANCHOR_SLUG_PATTERN,ke as COLOR_SOURCES,Ot as DEFAULT_DARK_LIGHTNESS,je as DEFAULT_DARK_THEME,vt as DEFAULT_LIGHT_LIGHTNESS,Me as DEFAULT_LIGHT_THEME,xe as DEFAULT_SEMANTIC_MAPPINGS,j as LIGHTNESS_KEYS,jt as NESTED_THEME_KEYS,ne as ROLE_NAMES,bt as ROLE_PAIRED_INK,Se as ROLE_TOKEN_PLAN,Q as SEMANTIC_COLOR_NAMES,ee as STATUS_COLOR_SOURCES,We as TOKEN_PAIRINGS,Mt as VARIANT_COLOR_SOURCES,Qt as buildTaprootDarkTheme,Zt as buildTaprootLightTheme,Ne as compileRoles,Oe as encodeTheme,Pt as explicitMappingTokens,Xt as layerThemes,Kt as mergePartials,le as mergeTheme,$e as parseAnchorSource,Ct as parseTheme,Pe as resolveAnchorColor,Xe as resolveContextTheme,ht as resolveDataColorSource,Jt as semanticToCSS,Yt as validateTheme,qt as validateThemePair};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o=new Set(["__proto__","constructor","prototype"]);function e(t){return!o.has(t)}export{o as UNSAFE_KEYS,e as isSafeKey};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { EspalierElementBase } from "../shared/esp-element-base.js";
|
|
2
|
+
declare const STACK_GAPS: readonly ["none", "tiny", "small", "normal", "medium", "big", "large", "huge"];
|
|
3
|
+
/** A named gap step accepted by `esp-stack` and `esp-row`. */
|
|
4
|
+
export type EspalierGap = (typeof STACK_GAPS)[number];
|
|
5
|
+
declare const STACK_ALIGNS: readonly ["start", "center", "end", "stretch"];
|
|
6
|
+
/** A cross-axis alignment accepted by `esp-stack` and `esp-row`. */
|
|
7
|
+
export type EspalierAlign = (typeof STACK_ALIGNS)[number];
|
|
8
|
+
export { STACK_GAPS, STACK_ALIGNS };
|
|
9
|
+
/**
|
|
10
|
+
* A vertical flow: children stack in a column with a themed gap —
|
|
11
|
+
* "column, gap X" without writing flexbox (ADR-010's micro half).
|
|
12
|
+
*
|
|
13
|
+
* ```html
|
|
14
|
+
* <esp-stack gap="medium">
|
|
15
|
+
* <h2>Title</h2>
|
|
16
|
+
* <p>Copy under it.</p>
|
|
17
|
+
* <esp-button label="Act"></esp-button>
|
|
18
|
+
* </esp-stack>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* The default cross-axis alignment is `stretch`, matching normal block
|
|
22
|
+
* flow: grids, form fields, and text fill the column — with one
|
|
23
|
+
* deliberate exception: slotted `esp-button` and `esp-button-group`
|
|
24
|
+
* keep their natural width, because a field should fill its column
|
|
25
|
+
* while the submit button under it should not. That is the pairing a
|
|
26
|
+
* plain flex column cannot express with any single `align-items`
|
|
27
|
+
* value. An explicit `align` — `align="stretch"` included, authored as
|
|
28
|
+
* an attribute or assigned to the property — governs every child
|
|
29
|
+
* uniformly; removing the attribute restores the default state, and
|
|
30
|
+
* `align-self` on any child overrides either way.
|
|
31
|
+
*
|
|
32
|
+
* @customElement esp-stack
|
|
33
|
+
* @slot - The stacked children.
|
|
34
|
+
* @csspart stack - The flex column.
|
|
35
|
+
* @cssprop --esp-stack-gap - Overrides the gap between children. Defaults to the `gap` attribute's step, `normal` when unset.
|
|
36
|
+
* @docPageTitle Stack
|
|
37
|
+
* @docUrl /components/stack
|
|
38
|
+
* @menuGroup Structure
|
|
39
|
+
* @menuIcon layout
|
|
40
|
+
*/
|
|
41
|
+
export declare class EspalierStack extends EspalierElementBase {
|
|
42
|
+
/**
|
|
43
|
+
* Gap between children as a space-scale step name
|
|
44
|
+
* (`none`, `tiny`, `small`, `normal`, `medium`, `big`, `large`,
|
|
45
|
+
* `huge`).
|
|
46
|
+
* @default "normal"
|
|
47
|
+
*/
|
|
48
|
+
gap: EspalierGap;
|
|
49
|
+
/**
|
|
50
|
+
* Cross-axis alignment of children: `start`, `center`, `end`, or
|
|
51
|
+
* `stretch`.
|
|
52
|
+
* @default "stretch"
|
|
53
|
+
*/
|
|
54
|
+
align: EspalierAlign;
|
|
55
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
56
|
+
static styles: import("lit").CSSResult[];
|
|
57
|
+
}
|
|
58
|
+
declare global {
|
|
59
|
+
interface HTMLElementTagNameMap {
|
|
60
|
+
"esp-stack": EspalierStack;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var o=function(l,t,a,r){var n=arguments.length,e=n<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,a):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")e=Reflect.decorate(l,t,a,r);else for(var p=l.length-1;p>=0;p--)(i=l[p])&&(e=(n<3?i(e):n>3?i(t,a,e):i(t,a))||e);return n>3&&e&&Object.defineProperty(t,a,e),e};import{css as u,html as h}from"lit";import{customElement as f,property as c}from"lit/decorators.js";import{EspalierElementBase as g}from"../shared/esp-element-base.js";const m=["none","tiny","small","normal","medium","big","large","huge"],d=["start","center","end","stretch"];let s=class extends g{constructor(){super(...arguments),this.gap="normal",this.align="stretch"}render(){return h`
|
|
2
|
+
<div class="esp-stack" part="stack">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</div>
|
|
5
|
+
`}};s.styles=[...g.styles,u`
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
--_esp-stack-gap: var(--esp-size-normal);
|
|
9
|
+
--_esp-stack-align: stretch;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:host([gap="none"]) {
|
|
13
|
+
--_esp-stack-gap: 0px;
|
|
14
|
+
}
|
|
15
|
+
:host([gap="tiny"]) {
|
|
16
|
+
--_esp-stack-gap: var(--esp-size-tiny);
|
|
17
|
+
}
|
|
18
|
+
:host([gap="small"]) {
|
|
19
|
+
--_esp-stack-gap: var(--esp-size-small);
|
|
20
|
+
}
|
|
21
|
+
:host([gap="medium"]) {
|
|
22
|
+
--_esp-stack-gap: var(--esp-size-medium);
|
|
23
|
+
}
|
|
24
|
+
:host([gap="big"]) {
|
|
25
|
+
--_esp-stack-gap: var(--esp-size-big);
|
|
26
|
+
}
|
|
27
|
+
:host([gap="large"]) {
|
|
28
|
+
--_esp-stack-gap: var(--esp-size-large);
|
|
29
|
+
}
|
|
30
|
+
:host([gap="huge"]) {
|
|
31
|
+
--_esp-stack-gap: var(--esp-size-huge);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([align="start"]) {
|
|
35
|
+
--_esp-stack-align: flex-start;
|
|
36
|
+
}
|
|
37
|
+
:host([align="center"]) {
|
|
38
|
+
--_esp-stack-align: center;
|
|
39
|
+
}
|
|
40
|
+
:host([align="end"]) {
|
|
41
|
+
--_esp-stack-align: flex-end;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.esp-stack {
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
gap: var(--esp-stack-gap, var(--_esp-stack-gap));
|
|
48
|
+
align-items: var(--_esp-stack-align);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
:host(:not([align])) ::slotted(esp-button),
|
|
53
|
+
:host(:not([align])) ::slotted(esp-button-group) {
|
|
54
|
+
align-self: flex-start;
|
|
55
|
+
}
|
|
56
|
+
`],o([c({reflect:!0,useDefault:!0})],s.prototype,"gap",void 0),o([c({reflect:!0,useDefault:!0})],s.prototype,"align",void 0),s=o([f("esp-stack")],s);export{s as EspalierStack,d as STACK_ALIGNS,m as STACK_GAPS};
|