@apollion-dsi/tokens 5.6.0 → 5.7.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/README.md +5 -0
- package/lib/build.cjs +10 -9
- package/lib/build.esm.js +10 -9
- package/lib/builders/colors.d.ts +27 -0
- package/lib/cli.mjs +13 -12
- package/lib/config-loader.cjs +1 -1
- package/lib/config-loader.esm.js +2 -2
- package/lib/config-schema.cjs +1 -1
- package/lib/runtime/v1.cjs +1 -1
- package/lib/runtime/v1.esm.js +1 -1
- package/package.json +1 -1
- package/src/build.ts +28 -1
- package/src/builders/colors.ts +34 -3
- package/src/builders/ladder.ts +116 -0
- package/src/config-schema-runtime.ts +1 -0
- package/src/config-schema.ts +5 -0
- package/src/ir.ts +23 -0
- package/src/renderers/css.ts +48 -0
- package/src/renderers/tailwind.ts +2 -2
- package/src/theme-factory.ts +5 -1
- package/src/token-meta.ts +9 -0
package/README.md
CHANGED
|
@@ -53,6 +53,11 @@ The build step emits, per variant (light/dark):
|
|
|
53
53
|
below 1).
|
|
54
54
|
- `dimension` → `{ "value": <number>, "unit": "rem" }`.
|
|
55
55
|
- **`dist/ts/*.d.ts`** — typed token surfaces (string-based, hex / `rem`).
|
|
56
|
+
- **`dist/css/<brand>.<surface>.<dimension>.modes.css`** — opt-in via the
|
|
57
|
+
`output.cssModes` flag: both modes in one file, scoped by
|
|
58
|
+
`html[data-apollion-mode]` (+ `prefers-color-scheme` fallback), the same
|
|
59
|
+
switch the core mode engine writes — the CSS-only dark mode for pages
|
|
60
|
+
without React (ADR-024).
|
|
56
61
|
- **`dist/tailwind/preset.mjs` + `dist/tailwind/tw-merge.mjs`** — opt-in via
|
|
57
62
|
the `output.tailwind` config flag: a generated Tailwind preset mapping
|
|
58
63
|
foundation tokens to theme keys over `var(--apollion-*)`, plus a
|
package/lib/build.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var xn=Object.getOwnPropertyNames;var wn=Object.prototype.hasOwnProperty;var s=(e,n)=>P(e,"name",{value:n,configurable:!0});var Tn=(e,n)=>{for(var o in n)P(e,o,{get:n[o],enumerable:!0})},vn=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of xn(n))!wn.call(e,t)&&t!==o&&P(e,t,{get:()=>n[t],enumerable:!(r=Sn(n,t))||r.enumerable});return e};var Dn=e=>vn(P({},"__esModule",{value:!0}),e);var lo={};Tn(lo,{build:()=>so,check:()=>ao});module.exports=Dn(lo);var b=require("node:fs/promises"),kn=require("node:os"),v=require("node:path");var U=require("culori");var N=require("@apollion-dsi/core/themes/border"),Re=require("@apollion-dsi/core/themes/colors"),J=require("@apollion-dsi/core/themes/depth"),T=require("@apollion-dsi/core/themes/font"),ie=require("@apollion-dsi/core/themes/spacing"),M=require("culori");var be=require("@apollion-dsi/core/themes/dimension");function _({multiplier:e=.25,alias:n},o){let r=o!==void 0?be.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(_,"createSpacing");var re={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function te(e){let n=Object.keys(re).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(te,"assertTokenMetaResolves");var $n=(0,M.converter)("oklch");function h(e){return typeof e.type=="string"&&"value"in e}s(h,"isToken");function S(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(S,"kebab");function Ie(e){return e.split(".").map(S).join(".")}s(Ie,"kebabPath");function E(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(E,"rawValue");function B(e,n){return Number(e.toFixed(n))||0}s(B,"round");function ae(e){let n=$n((0,M.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[B(n.l,4),B(n.c,4),B(n.h??0,2)],r=(0,M.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:B(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ae,"toColorValue");var ke=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function O(e){let n=ke.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(O,"toDimensionValue");function k(e){return{type:"color",value:ae(e)}}s(k,"colorToken");function se(e){let n={};for(let[o,r]of Object.entries(e))n[o]=k(r);return n}s(se,"recordColorGroup");function Se(e){let n=(0,Re.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=k(t);return o.neutral=se(n.neutral),o}s(Se,"buildReadableTextGroup");var Cn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function xe(e){let n={};for(let o of Cn){let r=e[o];n[o]={base:k(r.base),dark:k(r.dark),action:k(r.action),active:k(r.active),light:k(r.light),onLight:k(r.onLight)}}return n.grayscale=se(e.grayscale),n.neutral=se(e.neutral),n.baseDark=k(e.baseDark??"#000000"),n.baseLight=k(e.baseLight??"#ffffff"),n.deepDark=k(e.deepDark??"#000000"),n.deepLight=k(e.deepLight??"#ffffff"),n}s(xe,"buildColorPrimitives");function we(e){let n=_(ie.defaultInputSpacing,e),o={};for(let r of Object.keys(ie.defaultInputSpacing.alias))o[r]={type:"dimension",value:O(n(r))};return o}s(we,"buildSpacePrimitives");function Te(){let e={};for(let[n,o]of Object.entries(N.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:O(o)};return e}s(Te,"buildBorderWidthPrimitives");function Vn(e,n){return{color:xe(e),space:we(n),borderWidth:Te()}}s(Vn,"buildPrimitives");var ve={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},De={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function On(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(On,"lookupPrimitive");function H(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?On(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ae(i)}}:k(i)}return r}s(H,"colorRefGroup");var $e={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},En={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function Gn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!h(t)&&i in t)t=t[i];else return;return t&&h(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(Gn,"lookupDimensionPrimitive");function ce(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Gn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:O(i)}}:{type:"dimension",value:O(i)}}return r}s(ce,"dimensionRefGroup");function Ce(e){let n={},o={};for(let[i,a]of Object.entries(N.defaultInputBorder.borderRadius))ke.test(a)?n[i]={type:"dimension",value:O(a)}:o[i]=a;let r=ce(N.defaultInputBorder.borderWidth,e,En),t={};for(let[i,a]of Object.entries(N.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Ce,"buildBorder");function Ve(e){let n=(0,T.createFont)(T.defaultInputFont,e),o={};for(let[c,l]of Object.entries(T.defaultInputFont.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:O(l)};let t={};for(let[c,l]of Object.entries(T.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(T.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:T.defaultInputFont.letterSpacing,textTransform:T.defaultInputFont.textTransform,fontStyle:T.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Ve,"buildFont");var Mn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function jn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(Mn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>O(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ae(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(jn,"parseShadow");function Oe(e){let n=(0,J.createDeth)(e),o={};for(let r of Object.keys(J.levelValues))o[r]={type:"shadow",value:jn(n(r))};return o}s(Oe,"buildShadow");function W(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${S(t)}`:S(t);if(h(i)){o.add(a);let c=re[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=W(i,a,o)}return r}s(W,"decorateGroup");function An(e){let n=new Set,o=W(e.primitives,"",n),r=W(e.groups,"",n);return te(n),{...e,primitives:o,groups:r}}s(An,"decorateMeta");function z(e,n){return W(e,"",n)}s(z,"decorateSlice");function Ee(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${S(r)}`:S(r);h(t)?o.add(i):Ee(t,i,o)}}s(Ee,"collectPaths");function Ge(e){let n=new Set;for(let o of e)Ee(o.groups,"",n);te(n)}s(Ge,"assertSlicesMetaComplete");function Me(){let e=Te(),o=Ce({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:z({"border-width":e,border:o.group},t),extensions:r}}s(Me,"buildBaseIR");function je(e){let n=Ve(e),o=new Set;return{groups:z({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(je,"buildFontIR");function Ae(e,n){let o=xe(n),r=new Set;return{groups:z({color:o,bg:H(e.bg,n,ve),text:H(e.text,n,De),tx:Se(n),shadow:Oe(n)},r),extensions:{}}}s(Ae,"buildColorIR");function Ne(e,n){let o=we(n),r={space:o},t=new Set;return{groups:z({space:o,spacing:ce(e.spacing,r,$e)},t),extensions:{}}}s(Ne,"buildSpacingIR");function Nn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=Vn(n,o.dimension),i=Ce(t),a=Ve(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:H(e.bg,n,ve),text:H(e.text,n,De),tx:Se(n),spacing:ce(e.spacing,t,$e),border:i.group,font:a.group,shadow:Oe(n)},extensions:c};return An(l)}s(Nn,"buildIR");var q=Nn;var Fn=(0,U.converter)("rgb"),Fe="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function le(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(le,"colorPayload");function ue(e){return e.alpha===void 0}s(ue,"isOpaqueColor");function Le(e){let n=Fn((0,U.parse)(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Le,"rgbTriplet");function X(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,S(r)];if(h(t))o.set(i.join("-"),t);else for(let[a,c]of X(t,i))o.set(a,c)}return o}s(X,"flatTokens");function y(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||h(o))return{};o=o[r]}return o&&!h(o)?o:{}}s(y,"groupAt");function Pe(e){let n=[];for(let o of["bg","text","tx"])for(let[r,t]of X(y(e.groups,o),[o])){let i=le(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:ue(i)})}return n}s(Pe,"colorEntries");function $(e,n){return[...X(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s($,"varEntries");function C(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s(C,"pushScale");function _e(e){let n=[Fe,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Pe(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),C(n,"spacing",$(y(e.groups,"spacing"),["spacing"])),C(n,"borderRadius",$(y(e.groups,"border","radius"),["border","radius"])),C(n,"borderWidth",$(y(e.groups,"border","width"),["border","width"])),C(n,"fontFamily",$(y(e.groups,"font","family"),["font","family"])),C(n,"fontSize",$(y(e.groups,"font","size"),["font","size"])),C(n,"fontWeight",$(y(e.groups,"font","weight"),["font","weight"])),C(n,"lineHeight",$(y(e.groups,"font","lineHeight"),["font","line-height"])),C(n,"boxShadow",$(y(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`)}s(
|
|
4
|
-
`)}s(
|
|
1
|
+
"use strict";var K=Object.defineProperty;var Mn=Object.getOwnPropertyDescriptor;var Gn=Object.getOwnPropertyNames;var On=Object.prototype.hasOwnProperty;var s=(e,n)=>K(e,"name",{value:n,configurable:!0});var En=(e,n)=>{for(var o in n)K(e,o,{get:n[o],enumerable:!0})},Nn=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Gn(n))!On.call(e,t)&&t!==o&&K(e,t,{get:()=>n[t],enumerable:!(r=Mn(n,t))||r.enumerable});return e};var jn=e=>Nn(K({},"__esModule",{value:!0}),e);var To={};En(To,{build:()=>vo,check:()=>wo});module.exports=jn(To);var S=require("node:fs/promises"),An=require("node:os"),$=require("node:path");var ee=require("culori");var H=require("@apollion-dsi/core/themes/border"),Ce=require("@apollion-dsi/core/themes/colors"),Z=require("@apollion-dsi/core/themes/depth"),T=require("@apollion-dsi/core/themes/font"),me=require("@apollion-dsi/core/themes/spacing"),P=require("culori");var $e=require("@apollion-dsi/core/themes/dimension");function U({multiplier:e=.25,alias:n},o){let r=o!==void 0?$e.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(U,"createSpacing");var pe={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"bg.canvas":{description:"Page ground \u2014 the theme canvas (never pure black in dark)."},"bg.paper":{description:"Component ground (cards, inputs, tables) \u2014 lighter than the canvas in both modes."},"bg.overlay":{description:"Top of the elevation ladder \u2014 modal / dialog panels."},"text.primary":{description:"Primary neutral ink \u2014 AA + APCA Lc \u2265 75 over bg.paper and bg.canvas."},"text.muted":{description:"Muted neutral ink \u2014 AA + APCA Lc \u2265 45 over bg.paper."},"edge.border":{description:"Default control outline \u2014 primary ink at 20 % alpha, legible on any ground."},"edge.hairline":{description:"Dividers and card outlines \u2014 primary ink at 10 % alpha."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function fe(e){let n=Object.keys(pe).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(fe,"assertTokenMetaResolves");var Fn=(0,P.converter)("oklch");function b(e){return typeof e.type=="string"&&"value"in e}s(b,"isToken");function v(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(v,"kebab");function Ve(e){return e.split(".").map(v).join(".")}s(Ve,"kebabPath");function N(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(N,"rawValue");function X(e,n){return Number(e.toFixed(n))||0}s(X,"round");function ge(e){let n=Fn((0,P.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[X(n.l,4),X(n.c,4),X(n.h??0,2)],r=(0,P.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:X(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ge,"toColorValue");var Le=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function E(e){let n=Le.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(E,"toDimensionValue");function x(e){return{type:"color",value:ge(e)}}s(x,"colorToken");function O(e){let n={};for(let[o,r]of Object.entries(e))n[o]=x(r);return n}s(O,"recordColorGroup");function Ae(e){let n=(0,Ce.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=x(t);return o.neutral=O(n.neutral),o}s(Ae,"buildReadableTextGroup");var Pn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function Me(e){let n={};for(let o of Pn){let r=e[o];n[o]={base:x(r.base),dark:x(r.dark),action:x(r.action),active:x(r.active),light:x(r.light),onLight:x(r.onLight)}}return n.grayscale=O(e.grayscale),n.neutral=O(e.neutral),n.surface=O(e.surface),n.ink=O(e.ink),n.edge=O(e.edge),n.wash=O(e.wash),n.baseDark=x(e.baseDark??"#000000"),n.baseLight=x(e.baseLight??"#ffffff"),n.deepDark=x(e.deepDark??"#000000"),n.deepLight=x(e.deepLight??"#ffffff"),n}s(Me,"buildColorPrimitives");function Ge(e){let n=U(me.defaultInputSpacing,e),o={};for(let r of Object.keys(me.defaultInputSpacing.alias))o[r]={type:"dimension",value:E(n(r))};return o}s(Ge,"buildSpacePrimitives");function Oe(){let e={};for(let[n,o]of Object.entries(H.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:E(o)};return e}s(Oe,"buildBorderWidthPrimitives");function _n(e,n){return{color:Me(e),space:Ge(n),borderWidth:Oe()}}s(_n,"buildPrimitives");var Ee={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base",canvas:"color.surface.canvas",sunken:"color.surface.sunken",paper:"color.surface.paper",raised:"color.surface.raised",overlay:"color.surface.overlay"},Ne={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight",primary:"color.ink.primary",secondary:"color.ink.secondary",muted:"color.ink.muted",disabled:"color.ink.disabled"},je={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function Bn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(Bn,"lookupPrimitive");function F(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Bn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ge(i)}}:x(i)}return r}s(F,"colorRefGroup");var Fe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Hn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function Wn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!b(t)&&i in t)t=t[i];else return;return t&&b(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(Wn,"lookupDimensionPrimitive");function he(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Wn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:E(i)}}:{type:"dimension",value:E(i)}}return r}s(he,"dimensionRefGroup");function Pe(e){let n={},o={};for(let[i,a]of Object.entries(H.defaultInputBorder.borderRadius))Le.test(a)?n[i]={type:"dimension",value:E(a)}:o[i]=a;let r=he(H.defaultInputBorder.borderWidth,e,Hn),t={};for(let[i,a]of Object.entries(H.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Pe,"buildBorder");function _e(e){let n=(0,T.createFont)(T.defaultInputFont,e),o={};for(let[c,l]of Object.entries(T.defaultInputFont.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:E(l)};let t={};for(let[c,l]of Object.entries(T.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(T.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:T.defaultInputFont.letterSpacing,textTransform:T.defaultInputFont.textTransform,fontStyle:T.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(_e,"buildFont");var Jn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function qn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(Jn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>E(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ge(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(qn,"parseShadow");function Be(e){let n=(0,Z.createDeth)(e),o={};for(let r of Object.keys(Z.levelValues))o[r]={type:"shadow",value:qn(n(r))};return o}s(Be,"buildShadow");function Y(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${v(t)}`:v(t);if(b(i)){o.add(a);let c=pe[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=Y(i,a,o)}return r}s(Y,"decorateGroup");function zn(e){let n=new Set,o=Y(e.primitives,"",n),r=Y(e.groups,"",n);return fe(n),{...e,primitives:o,groups:r}}s(zn,"decorateMeta");function Q(e,n){return Y(e,"",n)}s(Q,"decorateSlice");function He(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${v(r)}`:v(r);b(t)?o.add(i):He(t,i,o)}}s(He,"collectPaths");function We(e){let n=new Set;for(let o of e)He(o.groups,"",n);fe(n)}s(We,"assertSlicesMetaComplete");function Je(){let e=Oe(),o=Pe({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:Q({"border-width":e,border:o.group},t),extensions:r}}s(Je,"buildBaseIR");function qe(e){let n=_e(e),o=new Set;return{groups:Q({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(qe,"buildFontIR");function ze(e,n){let o=Me(n),r=new Set;return{groups:Q({color:o,bg:F(e.bg,n,Ee),text:F(e.text,n,Ne),edge:F(e.edge,n,je),tx:Ae(n),shadow:Be(n)},r),extensions:{}}}s(ze,"buildColorIR");function Ke(e,n){let o=Ge(n),r={space:o},t=new Set;return{groups:Q({space:o,spacing:he(e.spacing,r,Fe)},t),extensions:{}}}s(Ke,"buildSpacingIR");function Kn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=_n(n,o.dimension),i=Pe(t),a=_e(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:F(e.bg,n,Ee),text:F(e.text,n,Ne),edge:F(e.edge,n,je),tx:Ae(n),spacing:he(e.spacing,t,Fe),border:i.group,font:a.group,shadow:Be(n)},extensions:c};return zn(l)}s(Kn,"buildIR");var _=Kn;var Un=(0,ee.converter)("rgb"),Ue="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function ye(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(ye,"colorPayload");function be(e){return e.alpha===void 0}s(be,"isOpaqueColor");function Xe(e){let n=Un((0,ee.parse)(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Xe,"rgbTriplet");function ne(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];if(b(t))o.set(i.join("-"),t);else for(let[a,c]of ne(t,i))o.set(a,c)}return o}s(ne,"flatTokens");function I(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||b(o))return{};o=o[r]}return o&&!b(o)?o:{}}s(I,"groupAt");function Ye(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of ne(I(e.groups,o),[o])){let i=ye(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:be(i)})}return n}s(Ye,"colorEntries");function L(e,n){return[...ne(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(L,"varEntries");function A(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s(A,"pushScale");function Ze(e){let n=[Ue,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Ye(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),A(n,"spacing",L(I(e.groups,"spacing"),["spacing"])),A(n,"borderRadius",L(I(e.groups,"border","radius"),["border","radius"])),A(n,"borderWidth",L(I(e.groups,"border","width"),["border","width"])),A(n,"fontFamily",L(I(e.groups,"font","family"),["font","family"])),A(n,"fontSize",L(I(e.groups,"font","size"),["font","size"])),A(n,"fontWeight",L(I(e.groups,"font","weight"),["font","weight"])),A(n,"lineHeight",L(I(e.groups,"font","lineHeight"),["font","line-height"])),A(n,"boxShadow",L(I(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
+
`)}s(Ze,"renderTailwindPreset");function Qe(e){let n=s(t=>[...ne(t).keys()],"keys"),o=s(t=>`[${t.map(i=>JSON.stringify(i)).join(", ")}]`,"list");return[Ue,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(Ye(e).map(t=>t.key))},`,` spacing: ${o(n(I(e.groups,"spacing")))},`,` borderRadius: ${o(n(I(e.groups,"border","radius")))},`,` borderWidth: ${o(n(I(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(I(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(I(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(I(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(I(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(I(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
|
|
3
|
+
`)}s(Qe,"renderTwMergeExtension");var en="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function oe(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];b(t)?o.push(` --apollion-${i.join("-")}: ${N(t.value)};`):oe(t,i,o)}}s(oe,"emitVars");function re(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];if(!b(t)){re(t,i,o);continue}let a=ye(t);a&&be(a)&&o.push(` --apollion-${i.join("-")}-rgb: ${Xe(a)};`)}}s(re,"emitRgbVars");function Re(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];b(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${N(t.value)}; }`):Re(t,i,o)}}s(Re,"emitProperties");function nn(e,n={}){let{brand:o,mode:r,surface:t,dimension:i}=e.meta,a=[en,""];return a.push(`/* Variant: brand=${o} mode=${r} surface=${t} dimension=${i} */`,"",":root {"),oe(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),re(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Re(e.groups,[],a),a.push("}",""),a.join(`
|
|
4
|
+
`)}s(nn,"renderCss");function on(e,n,o={}){let{attribute:r="data-apollion-mode",rgbCompanions:t}=o,{brand:i,surface:a,dimension:c}=e.meta,l=[en,""],m=s((w,d,u)=>{l.push(`${w} {`,` color-scheme: ${u};`),oe(d.groups,[],l),t&&re(d.groups,[],l),l.push("}","")},"block");l.push(`/* Variant: brand=${i} surface=${a} dimension=${c} modes=light+dark (attribute ${r}) */`,""),m(`:root, html[${r}="light"]`,e,"light"),m(`html[${r}="dark"]`,n,"dark"),l.push("@media (prefers-color-scheme: dark) {"),l.push(` html:not([${r}]) {`," color-scheme: dark;");let R=[];oe(n.groups,[],R),t&&re(n.groups,[],R);for(let w of R)l.push(` ${w}`);return l.push(" }","}",""),l.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),Re(e.groups,[],l),l.push("}",""),l.join(`
|
|
5
|
+
`)}s(on,"renderCssModes");var Xn="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function ke(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${r}`:r;b(t)?o.push([i,N(t.value)]):ke(t,i,o)}}s(ke,"flatten");function Yn(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}s(Yn,"yamlEscape");function Zn(e){let{mode:n,surface:o,dimension:r}=e.meta;return`${n}.${o}.${r}`}s(Zn,"variantKey");function rn(e,n){if(n.length===0)throw new Error(`renderDesignMd: no variants for brand "${e}"`);let o=["---",`brand: '${e}'`,"generator: apollion-tokens","variants:"];for(let t of n){let i=[];ke(t.groups,"",i),o.push(` ${Zn(t)}:`);for(let[a,c]of i)o.push(` ${a}: ${Yn(c)}`)}o.push("---");let r=["",Xn,"",`# Design.md \u2014 ${e}`,"","Resolved design-token values for this brand, one section per variant.","Consumption rules (which token to reach for, layer boundaries) live in the","package `llms.txt`; this file carries the values those rules reference.","Regenerate with `apollion-tokens build` \u2014 never edit.",""];for(let t of n){let{mode:i,surface:a,dimension:c}=t.meta;r.push(`## Variant \`${i} \xB7 ${a} \xB7 ${c}\``,"");let l=[];ke(t.groups,"",l);let m=new Map;for(let[R,w]of l){let d=R.split(".")[0]??R,u=m.get(d)??[];u.push([R,w]),m.set(d,u)}for(let[R,w]of m){r.push(`### ${R}`,"","| Token | Value |","| --- | --- |");for(let[d,u]of w)r.push(`| \`${d}\` | \`${u}\` |`);r.push("")}}return`${o.join(`
|
|
5
6
|
`)}
|
|
6
7
|
${r.join(`
|
|
7
|
-
`)}`}s(
|
|
8
|
-
`}s(
|
|
9
|
-
`}s(
|
|
10
|
-
`)}s(
|
|
11
|
-
`}s(an,"serializeManifest");var Kn="json/sets",cn="json/resolver.json";function Q(e){return`${Kn}/${e}.json`}s(Q,"setFile");function Zn(e,n,o){return`${e}.color.${n}.${o}`}s(Zn,"colorSetName");function Qn(e){return`spacing.${e}`}s(Qn,"spacingSetName");function eo(e){return`font.${e}`}s(eo,"fontSetName");function ee(e,n){e.includes(n)||e.push(n)}s(ee,"pushUnique");function ln(e){let n=K(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],I=new Set,D=[];for(let u of n){ee(o,u.brand),ee(r,u.mode),ee(t,u.surface),ee(i,u.dimension);let f=Zn(u.brand,u.mode,u.surface);a.has(f)||(a.add(f),c.push({kind:"color",name:f,file:Q(f),brand:u.brand,mode:u.mode,surface:u.surface}));let x=Qn(u.dimension);l.has(x)||(l.add(x),m.push({kind:"spacing",name:x,file:Q(x),dimension:u.dimension}));let p=eo(u.dimension);I.has(p)||(I.add(p),D.push({kind:"font",name:p,file:Q(p),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:Q("base")},spacing:m,font:D,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(ln,"planSets");var yn=require("@apollion-dsi/core/themes/colors"),ye=require("@apollion-dsi/core/themes/foundation"),bn=require("@apollion-dsi/core/themes/semantic"),Rn=require("@apollion-dsi/core/themes/spacing"),In=require("@apollion-dsi/core/themes/surface");var g=require("culori");var he=(0,g.converter)("oklch");function d(e,n,o){let r=(0,g.parse)(e),t=(0,g.parse)(n);if(!r||!t)return e;let i=(0,g.interpolate)([r,t],"oklch");return(0,g.formatHex)(i(o))??e}s(d,"mixOklch");function no(e){return e?typeof e=="string"?e:e.base:"#000"}s(no,"coerceToHex");var ne=1.3,oo=.05,un=.04,V=s((e,n)=>{let o=(0,g.parse)(e),r=(0,g.parse)(n);return!o||!r?1:(0,g.wcagContrast)(o,r)},"contrastRatio"),ge=s(e=>{let n=he((0,g.parse)(e));return n?n.l??0:null},"oklchLightness"),ro=4.5;function dn(e,n,o=ro){let r=(0,g.parse)(n),t=he((0,g.parse)(e));if(!r||!t)return e;let i=V("#fff",n)>=V("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=(0,g.formatHex)(t)??e,l=(0,g.parse)(c);if(l&&(0,g.wcagContrast)(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return(0,g.formatHex)(t)??e}s(dn,"readableColor");var pn=s((e,n)=>{if(V(e,n)>=ne)return!0;let o=ge(e),r=ge(n);return o!==null&&r!==null&&Math.abs(o-r)>=oo},"isPerceptibleState"),to=s(e=>e?V("#fff",e)>V("#000",e):!1,"isDarkSurface");function fn(e,n,o){let r=he((0,g.parse)(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?un:-un;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=(0,g.formatHex)(t);if(l&&V(e,l)>=ne)return l}return(0,g.formatHex)(t)??null}s(fn,"derivePerceptibleState");function mn(e,n,o){let r=fn(e,n,o);if(r&&V(e,r)>=ne)return r;let t=fn(e,!n);return t&&V(e,t)>=ne?t:r??t}s(mn,"perceptibleStateFor");function w(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=no(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:d(r,t,.6),action:d(r,t,.2),active:d(r,i,.6),light:d(r,i,.9),onLight:r};if((0,g.parse)(r)){let c=to(n.baseLight),l=pn(r,a.action);if(l||(a.action=mn(r,c)??a.action),!pn(r,a.active)){let m=l?void 0:ge(a.action)??void 0;a.active=mn(r,c,m)??a.active}}if(a.onLight=dn(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:r,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??dn(c,l)}}return a}s(w,"mountSingleColor");function gn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:d(n,o,.05),10:d(n,o,.1),20:d(n,o,.2),30:d(n,o,.3),40:d(n,o,.4),50:d(n,o,.5),60:d(n,o,.6),70:d(n,o,.7),80:d(n,o,.8),90:d(n,o,.9),100:d(n,o,1)}}s(gn,"mountGreyscaleColors");function hn(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=d(r,o,.5);return{0:d(i,n,t(18)),5:d(i,n,t(17.5)),10:d(i,n,t(17)),20:d(i,n,t(16)),30:d(i,n,t(15)),40:d(i,n,t(14)),50:d(i,n,t(13)),60:d(i,n,t(12)),70:d(i,n,t(11)),80:d(i,n,t(10)),90:d(i,n,t(9)),100:d(i,n,t(8)),110:d(i,n,t(7)),120:d(i,n,t(6)),130:d(i,n,t(5)),140:d(i,n,t(4)),150:d(i,n,t(3)),160:d(i,n,t(2)),170:i,180:d(i,o,.25)}}s(hn,"mountNeutralColors");function io(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:hn(e),grayscale:gn(e),main:w(e.main,e),opposite:w(e.opposite,e),complementary:w(e.complementary,e),danger:w(e.danger,e),information:w(e.information,e),success:w(e.success,e),warning:w(e.warning,e),primary:w(e.primary,e),secondary:w(e.secondary,e),tertiary:w(e.tertiary,e)}}s(io,"composeColors");function j(e,n=Rn.defaultInputSpacing){let o=e.mode==="dark"?(0,yn.toDarkColors)(e.colors):e.colors,r=io(o),t=_(n,e.dimension),i=(0,bn.createSemantic)({colors:r,spacing:t}),a=(0,ye.createFoundation)(i);return e.surface==="negative"&&(a=(0,ye.createFoundation)((0,In.invertForSurface)({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(j,"buildVariantThemes");async function so(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=K(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await(0,b.mkdtemp)((0,v.join)((0,kn.tmpdir)(),"apollion-tokens-"));try{let l=[],m=s(async(u,f)=>{await co(c,u,f),l.push({path:u,sha256:Z(f)}),t&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=ln(n),f=[],x=Me();f.push(x),await m(u.base.file,Xe(x));for(let p of u.spacing){let R=i.find(L=>L.dimension===p.dimension),{foundation:A}=j(R),G=Ne(A,p.dimension);f.push(G),await m(p.file,Ke(G,p.dimension))}for(let p of u.font){let R=je(p.dimension);f.push(R),await m(p.file,Ze(R,p.dimension))}for(let p of u.color){let R=i.find(oe=>oe.brand===p.brand&&oe.mode===p.mode&&oe.surface===p.surface),{foundation:A,colors:G}=j(R),L=Ae(A,G);f.push(L),await m(p.file,Ye(L,p.brand,p.mode,p.surface))}Ge(f),await m(cn,Qe(n,u))}if(a.css||a.ts)for(let u of i){let{foundation:f,colors:x}=j(u),p=q(f,x,u),R=on(u);a.css&&await m(`css/${R}.css`,ze(p,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${R}.d.ts`,nn(p))}if(a.tailwind){let u=i[0],{foundation:f,colors:x}=j(u),p=q(f,x,u);await m("tailwind/preset.mjs",_e(p)),await m("tailwind/tw-merge.mjs",Be(p))}if(a.designMd){let u=[...new Set(i.map(f=>f.brand))];for(let f of u){let p=i.filter(R=>R.brand===f).map(R=>{let{foundation:A,colors:G}=j(R);return q(A,G,R)});await m(`design/${f}.design.md`,qe(f,p))}}let I={configHash:me(n),files:l,gitCommit:tn(r),buildEnv:sn()},D=an(I);return await(0,b.writeFile)((0,v.join)(c,"manifest.json"),D),await(0,b.rm)(o,{recursive:!0,force:!0}),await(0,b.mkdir)((0,v.dirname)(o),{recursive:!0}),await(0,b.rename)(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:I,outDir:o}}catch(l){throw await(0,b.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(so,"build");async function ao(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,b.readFile)((0,v.join)(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==me(n))return!1;for(let t of r.files){let i;try{i=await(0,b.readFile)((0,v.join)(o,t.path))}catch{return!1}if(Z(i)!==t.sha256)return!1}return!0}s(ao,"check");async function co(e,n,o){let r=(0,v.join)(e,n);await(0,b.mkdir)((0,v.dirname)(r),{recursive:!0}),await(0,b.writeFile)(r,o)}s(co,"writeAt");0&&(module.exports={build,check});
|
|
8
|
+
`)}`}s(rn,"renderDesignMd");function tn(e){return e.alpha!==void 0?{colorSpace:"oklch",components:[...e.components],alpha:e.alpha,hex:e.hex}:{colorSpace:"oklch",components:[...e.components],hex:e.hex}}s(tn,"colorValue");function W(e){return{value:e.value,unit:e.unit}}s(W,"dimensionValue");function Qn(e){let n=e.shadow,o={color:tn(n.color),offsetX:W(n.offsetX),offsetY:W(n.offsetY),blur:W(n.blur),spread:W(n.spread)};return n.inset&&(o.inset=!0),o}s(Qn,"shadowValue");function eo(e){switch(e.kind){case"ref":return`{${Ve(e.path)}}`;case"color":return tn(e);case"dimension":return W(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return Qn(e)}}s(eo,"projectValue");function no(e){let n={$value:eo(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(no,"projectToken");function Ie(e){let n={};for(let[o,r]of Object.entries(e))n[v(o)]=b(r)?no(r):Ie(r);return n}s(Ie,"projectGroup");function te(e,n){let o={$description:n,...Ie(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
9
|
+
`}s(te,"renderSet");function sn(e){return te(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(sn,"renderBaseSet");function an(e,n,o,r){return te(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(an,"renderColorSet");function cn(e,n){return te(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(cn,"renderSpacingSet");function ln(e,n){return te(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(ln,"renderFontSet");function dn(e,n){let{modifiers:o}=n,r=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],i={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:r,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(i,null,2)}
|
|
10
|
+
`}s(dn,"renderResolver");var oo="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function ro(e,n,o){let r=[];if(e.description!==void 0&&r.push(e.description),e.deprecated===!0?r.push("@deprecated"):typeof e.deprecated=="string"&&r.push(`@deprecated ${e.deprecated}`),r.length!==0){o.push(`${n}/**`);for(let t of r)o.push(`${n} * ${t.replace(/\*\//g,"*\\/")}`);o.push(`${n} */`)}}s(ro,"emitDoc");function un(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))b(i)?(ro(i,r,o),o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(N(i.value))},`)):(o.push(`${r}${t}: {`),un(i,n+1,o),o.push(`${r}},`))}s(un,"emitGroup");function pn(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[oo,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return un(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
11
|
+
`)}s(pn,"renderTs");var to=["light","dark"],io=["positive","negative"],so=["compact","normal","spacious"];function ie(e){let n=e.modes??to,o=e.surfaces??io,r=e.dimensions??so,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let l of n)for(let m of o)for(let R of r)i.push({brand:a,colors:c,mode:l,surface:m,dimension:R});return i}s(ie,"expandVariants");function fn(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(fn,"variantName");var mn=require("node:crypto");function se(e){return(0,mn.createHash)("sha256").update(e).digest("hex")}s(se,"sha256");function xe(e){return se(Se(e))}s(xe,"hashConfig");function Se(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Se).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${Se(e[r])}`).join(",")}}`}s(Se,"stableStringify");function gn(e){try{let{execSync:n}=require("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(gn,"detectGitCommit");function hn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(hn,"buildEnv");function yn(e){let n=[...e.files].sort((r,t)=>r.path.localeCompare(t.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
12
|
+
`}s(yn,"serializeManifest");var ao="json/sets",bn="json/resolver.json";function ae(e){return`${ao}/${e}.json`}s(ae,"setFile");function co(e,n,o){return`${e}.color.${n}.${o}`}s(co,"colorSetName");function lo(e){return`spacing.${e}`}s(lo,"spacingSetName");function uo(e){return`font.${e}`}s(uo,"fontSetName");function ce(e,n){e.includes(n)||e.push(n)}s(ce,"pushUnique");function Rn(e){let n=ie(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],R=new Set,w=[];for(let d of n){ce(o,d.brand),ce(r,d.mode),ce(t,d.surface),ce(i,d.dimension);let u=co(d.brand,d.mode,d.surface);a.has(u)||(a.add(u),c.push({kind:"color",name:u,file:ae(u),brand:d.brand,mode:d.mode,surface:d.surface}));let y=lo(d.dimension);l.has(y)||(l.add(y),m.push({kind:"spacing",name:y,file:ae(y),dimension:d.dimension}));let f=uo(d.dimension);R.has(f)||(R.add(f),w.push({kind:"font",name:f,file:ae(f),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:ae("base")},spacing:m,font:w,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(Rn,"planSets");var $n=require("@apollion-dsi/core/themes/colors"),Te=require("@apollion-dsi/core/themes/foundation"),Cn=require("@apollion-dsi/core/themes/semantic"),Vn=require("@apollion-dsi/core/themes/spacing"),Ln=require("@apollion-dsi/core/themes/surface");var h=require("culori");var q=(0,h.converter)("oklch"),po=(0,h.converter)("rgb");function p(e,n,o){let r=(0,h.parse)(e),t=(0,h.parse)(n);if(!r||!t)return e;let i=(0,h.interpolate)([r,t],"oklch");return(0,h.formatHex)(i(o))??e}s(p,"mixOklch");function fo(e){return e?typeof e=="string"?e:e.base:"#000"}s(fo,"coerceToHex");var le=1.3,mo=.05,kn=.04,M=s((e,n)=>{let o=(0,h.parse)(e),r=(0,h.parse)(n);return!o||!r?1:(0,h.wcagContrast)(o,r)},"contrastRatio"),ve=s(e=>{let n=q((0,h.parse)(e));return n?n.l??0:null},"oklchLightness"),go=4.5;function J(e,n,o=go){let r=(0,h.parse)(n),t=q((0,h.parse)(e));if(!r||!t)return e;let i=M("#fff",n)>=M("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=(0,h.formatHex)(t)??e,l=(0,h.parse)(c);if(l&&(0,h.wcagContrast)(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return(0,h.formatHex)(t)??e}s(J,"readableColor");var In=s((e,n)=>{if(M(e,n)>=le)return!0;let o=ve(e),r=ve(n);return o!==null&&r!==null&&Math.abs(o-r)>=mo},"isPerceptibleState"),we=s(e=>e?M("#fff",e)>M("#000",e):!1,"isDarkSurface");function Sn(e,n,o){let r=q((0,h.parse)(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?kn:-kn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=(0,h.formatHex)(t);if(l&&M(e,l)>=le)return l}return(0,h.formatHex)(t)??null}s(Sn,"derivePerceptibleState");function xn(e,n,o){let r=Sn(e,n,o);if(r&&M(e,r)>=le)return r;let t=Sn(e,!n);return t&&M(e,t)>=le?t:r??t}s(xn,"perceptibleStateFor");function D(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=fo(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:p(r,t,.6),action:p(r,t,.2),active:p(r,i,.6),light:p(r,i,.9),onLight:r};if((0,h.parse)(r)){let c=we(n.baseLight),l=In(r,a.action);if(l||(a.action=xn(r,c)??a.action),!In(r,a.active)){let m=l?void 0:ve(a.action)??void 0;a.active=xn(r,c,m)??a.active}}if(a.onLight=J(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:r,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??J(c,l)}}return a}s(D,"mountSingleColor");function vn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:p(n,o,.05),10:p(n,o,.1),20:p(n,o,.2),30:p(n,o,.3),40:p(n,o,.4),50:p(n,o,.5),60:p(n,o,.6),70:p(n,o,.7),80:p(n,o,.8),90:p(n,o,.9),100:p(n,o,1)}}s(vn,"mountGreyscaleColors");function wn(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=p(r,o,.5);return{0:p(i,n,t(18)),5:p(i,n,t(17.5)),10:p(i,n,t(17)),20:p(i,n,t(16)),30:p(i,n,t(15)),40:p(i,n,t(14)),50:p(i,n,t(13)),60:p(i,n,t(12)),70:p(i,n,t(11)),80:p(i,n,t(10)),90:p(i,n,t(9)),100:p(i,n,t(8)),110:p(i,n,t(7)),120:p(i,n,t(6)),130:p(i,n,t(5)),140:p(i,n,t(4)),150:p(i,n,t(3)),160:p(i,n,t(2)),170:i,180:p(i,o,.25)}}s(wn,"mountNeutralColors");function B(e,n){let o=q((0,h.parse)(e));if(!o)return e;let r=Math.min(1,Math.max(0,(o.l??0)+n));return(0,h.formatHex)({...o,l:r})??e}s(B,"shiftLightness");function de(e,n){let o=q((0,h.parse)(e));if(!o)return e;let r=o.l??0,t=n.min??0,i=n.max??1;return r>=t&&r<=i?e:(0,h.formatHex)({...o,l:Math.min(i,Math.max(t,r))})??e}s(de,"clampLightness");function j(e,n){let o=po((0,h.parse)(e));if(!o)return e;let r=Math.min(1,Math.max(0,n)),t=s(i=>Math.round((i??0)*255),"channel");return`rgba(${t(o.r)}, ${t(o.g)}, ${t(o.b)}, ${r})`}s(j,"toRgbaString");var g=require("@apollion-dsi/core/themes/colors");var ho="#FFFFFF",De="#000000";function yo(e){return we(e.baseLight)?"dark":"light"}s(yo,"resolvePolarity");function Dn(e,n,o){if(Math.abs((0,g.apcaContrast)(e,n))>=o)return e;let r=Math.abs((0,g.apcaContrast)("#ffffff",n))>=Math.abs((0,g.apcaContrast)("#000000",n)),t=e;for(let i=0;i<40;i+=1){let a=B(t,r?.02:-.02);if(a===t||(t=a,Math.abs((0,g.apcaContrast)(t,n))>=o))break}return t}s(Dn,"ensureApca");function bo(e,n){let o=e.baseLight??ho,r=n==="dark",t=r?de(o,{min:g.HALATION_FLOORS.CANVAS_MIN_L}):o,i=B(t,g.LADDER_DELTAS.sunken);return{canvas:t,sunken:r?de(i,{min:g.HALATION_FLOORS.CANVAS_MIN_L}):i,paper:B(t,g.LADDER_DELTAS.paper),raised:B(t,g.LADDER_DELTAS.raised),overlay:B(t,g.LADDER_DELTAS.overlay),scrim:r?e.deepLight??De:e.neutral?.["180"]??e.baseDark??De}}s(bo,"deriveSurface");function Ro(e,n){let o=e.baseDark??De,r=de(Dn(J(o,n.paper,g.MIN_CONTRAST_AA),n.paper,g.INK_APCA_MIN.primary),{max:g.HALATION_FLOORS.INK_MAX_L}),t=s((i,a)=>Dn(J(p(r,n.canvas,i),n.paper,g.MIN_CONTRAST_AA),n.paper,a),"tier");return{primary:r,secondary:t(g.INK_MIX.secondary,g.INK_APCA_MIN.secondary),muted:t(g.INK_MIX.muted,g.INK_APCA_MIN.muted),disabled:p(r,n.canvas,g.INK_MIX.disabled)}}s(Ro,"deriveInk");function ko(e){return{hairline:j(e.primary,g.EDGE_ALPHA.hairline),border:j(e.primary,g.EDGE_ALPHA.border),strong:j(e.primary,g.EDGE_ALPHA.strong)}}s(ko,"deriveEdge");function Io(e,n){let o=g.WASH_ALPHA[n];return{hover:j(e.primary,o.hover),pressed:j(e.primary,o.pressed),selected:j(e.primary,o.selected)}}s(Io,"deriveWash");function So(e,n){return n?{surface:{...e.surface,...n.surface},ink:{...e.ink,...n.ink},edge:{...e.edge,...n.edge},wash:{...e.wash,...n.wash}}:e}s(So,"applyOverride");function Tn(e,n){let o=yo(e),r=bo(e,o),t=Ro(e,r),i={surface:r,ink:t,edge:ko(t),wash:Io(t,o)};return So(i,n?.[o])}s(Tn,"resolveSurfaceLadder");function xo(e){let n=wn(e);return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:n,grayscale:vn(e),...Tn({...e,neutral:n},e.ladder),main:D(e.main,e),opposite:D(e.opposite,e),complementary:D(e.complementary,e),danger:D(e.danger,e),information:D(e.information,e),success:D(e.success,e),warning:D(e.warning,e),primary:D(e.primary,e),secondary:D(e.secondary,e),tertiary:D(e.tertiary,e)}}s(xo,"composeColors");function G(e,n=Vn.defaultInputSpacing){let o=e.mode==="dark"?(0,$n.toDarkColors)(e.colors):e.colors,r=xo(o),t=U(n,e.dimension),i=(0,Cn.createSemantic)({colors:r,spacing:t}),a=(0,Te.createFoundation)(i);return e.surface==="negative"&&(a=(0,Te.createFoundation)((0,Ln.invertForSurface)({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(G,"buildVariantThemes");async function vo(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=ie(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await(0,S.mkdtemp)((0,$.join)((0,An.tmpdir)(),"apollion-tokens-"));try{let l=[],m=s(async(d,u)=>{await Do(c,d,u),l.push({path:d,sha256:se(u)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=Rn(n),u=[],y=Je();u.push(y),await m(d.base.file,sn(y));for(let f of d.spacing){let k=i.find(z=>z.dimension===f.dimension),{foundation:C}=G(k),V=Ke(C,f.dimension);u.push(V),await m(f.file,cn(V,f.dimension))}for(let f of d.font){let k=qe(f.dimension);u.push(k),await m(f.file,ln(k,f.dimension))}for(let f of d.color){let k=i.find(ue=>ue.brand===f.brand&&ue.mode===f.mode&&ue.surface===f.surface),{foundation:C,colors:V}=G(k),z=ze(C,V);u.push(z),await m(f.file,an(z,f.brand,f.mode,f.surface))}We(u),await m(bn,dn(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:u,colors:y}=G(d),f=_(u,y,d),k=fn(d);a.css&&await m(`css/${k}.css`,nn(f,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${k}.d.ts`,pn(f))}if(a.cssModes){let d=new Map;for(let u of i){let y=`${u.brand}.${u.surface}.${u.dimension}`,f=d.get(y)??{};f[u.mode]=u,d.set(y,f)}for(let[u,{light:y,dark:f}]of d){if(!y||!f)throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${u} (config.modes)`);let k=G(y),C=G(f),V=on(_(k.foundation,k.colors,y),_(C.foundation,C.colors,f),{rgbCompanions:a.tailwind});await m(`css/${u}.modes.css`,V)}}if(a.tailwind){let d=i[0],{foundation:u,colors:y}=G(d),f=_(u,y,d);await m("tailwind/preset.mjs",Ze(f)),await m("tailwind/tw-merge.mjs",Qe(f))}if(a.designMd){let d=[...new Set(i.map(u=>u.brand))];for(let u of d){let f=i.filter(k=>k.brand===u).map(k=>{let{foundation:C,colors:V}=G(k);return _(C,V,k)});await m(`design/${u}.design.md`,rn(u,f))}}let R={configHash:xe(n),files:l,gitCommit:gn(r),buildEnv:hn()},w=yn(R);return await(0,S.writeFile)((0,$.join)(c,"manifest.json"),w),await(0,S.rm)(o,{recursive:!0,force:!0}),await(0,S.mkdir)((0,$.dirname)(o),{recursive:!0}),await(0,S.rename)(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:R,outDir:o}}catch(l){throw await(0,S.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(vo,"build");async function wo(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,S.readFile)((0,$.join)(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==xe(n))return!1;for(let t of r.files){let i;try{i=await(0,S.readFile)((0,$.join)(o,t.path))}catch{return!1}if(se(i)!==t.sha256)return!1}return!0}s(wo,"check");async function Do(e,n,o){let r=(0,$.join)(e,n);await(0,S.mkdir)((0,$.dirname)(r),{recursive:!0}),await(0,S.writeFile)(r,o)}s(Do,"writeAt");0&&(module.exports={build,check});
|
package/lib/build.esm.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
var hn=Object.defineProperty;var s=(e,n)=>hn(e,"name",{value:n,configurable:!0}),yn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{mkdir as fn,mkdtemp as mo,readFile as dn,rename as go,rm as pn,writeFile as mn}from"node:fs/promises";import{tmpdir as ho}from"node:os";import{dirname as gn,join as A}from"node:path";import{converter as An,parse as Nn}from"culori";import{defaultInputBorder as P}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as Rn}from"@apollion-dsi/core/themes/colors";import{createDeth as In,levelValues as kn}from"@apollion-dsi/core/themes/depth";import{createFont as Sn,defaultInputFont as $}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as pe}from"@apollion-dsi/core/themes/spacing";import{converter as xn,formatHex as wn,parse as Tn}from"culori";import{DIMENSION_MULTIPLIERS as bn}from"@apollion-dsi/core/themes/dimension";function F({multiplier:e=.25,alias:n},o){let r=o!==void 0?bn[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(F,"createSpacing");var Q={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function ee(e){let n=Object.keys(Q).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(ee,"assertTokenMetaResolves");var vn=xn("oklch");function g(e){return typeof e.type=="string"&&"value"in e}s(g,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function fe(e){return e.split(".").map(I).join(".")}s(fe,"kebabPath");function V(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(V,"rawValue");function L(e,n){return Number(e.toFixed(n))||0}s(L,"round");function oe(e){let n=vn(Tn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[L(n.l,4),L(n.c,4),L(n.h??0,2)],r=wn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:L(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(oe,"toColorValue");var me=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function C(e){let n=me.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(C,"toDimensionValue");function R(e){return{type:"color",value:oe(e)}}s(R,"colorToken");function ne(e){let n={};for(let[o,r]of Object.entries(e))n[o]=R(r);return n}s(ne,"recordColorGroup");function ge(e){let n=Rn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=R(t);return o.neutral=ne(n.neutral),o}s(ge,"buildReadableTextGroup");var Dn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function he(e){let n={};for(let o of Dn){let r=e[o];n[o]={base:R(r.base),dark:R(r.dark),action:R(r.action),active:R(r.active),light:R(r.light),onLight:R(r.onLight)}}return n.grayscale=ne(e.grayscale),n.neutral=ne(e.neutral),n.baseDark=R(e.baseDark??"#000000"),n.baseLight=R(e.baseLight??"#ffffff"),n.deepDark=R(e.deepDark??"#000000"),n.deepLight=R(e.deepLight??"#ffffff"),n}s(he,"buildColorPrimitives");function ye(e){let n=F(pe,e),o={};for(let r of Object.keys(pe.alias))o[r]={type:"dimension",value:C(n(r))};return o}s(ye,"buildSpacePrimitives");function be(){let e={};for(let[n,o]of Object.entries(P.borderWidth))e[n]={type:"dimension",value:C(o)};return e}s(be,"buildBorderWidthPrimitives");function $n(e,n){return{color:he(e),space:ye(n),borderWidth:be()}}s($n,"buildPrimitives");var Re={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},Ie={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Cn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(Cn,"lookupPrimitive");function _(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Cn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:oe(i)}}:R(i)}return r}s(_,"colorRefGroup");var ke={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Vn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function On(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!g(t)&&i in t)t=t[i];else return;return t&&g(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(On,"lookupDimensionPrimitive");function re(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?On(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:C(i)}}:{type:"dimension",value:C(i)}}return r}s(re,"dimensionRefGroup");function Se(e){let n={},o={};for(let[i,a]of Object.entries(P.borderRadius))me.test(a)?n[i]={type:"dimension",value:C(a)}:o[i]=a;let r=re(P.borderWidth,e,Vn),t={};for(let[i,a]of Object.entries(P.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Se,"buildBorder");function xe(e){let n=Sn($,e),o={};for(let[c,l]of Object.entries($.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:C(l)};let t={};for(let[c,l]of Object.entries($.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries($.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:$.letterSpacing,textTransform:$.textTransform,fontStyle:$.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(xe,"buildFont");var En=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Gn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(En),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>C(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:oe(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(Gn,"parseShadow");function we(e){let n=In(e),o={};for(let r of Object.keys(kn))o[r]={type:"shadow",value:Gn(n(r))};return o}s(we,"buildShadow");function B(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${I(t)}`:I(t);if(g(i)){o.add(a);let c=Q[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=B(i,a,o)}return r}s(B,"decorateGroup");function Mn(e){let n=new Set,o=B(e.primitives,"",n),r=B(e.groups,"",n);return ee(n),{...e,primitives:o,groups:r}}s(Mn,"decorateMeta");function H(e,n){return B(e,"",n)}s(H,"decorateSlice");function Te(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${I(r)}`:I(r);g(t)?o.add(i):Te(t,i,o)}}s(Te,"collectPaths");function ve(e){let n=new Set;for(let o of e)Te(o.groups,"",n);ee(n)}s(ve,"assertSlicesMetaComplete");function De(){let e=be(),o=Se({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:H({"border-width":e,border:o.group},t),extensions:r}}s(De,"buildBaseIR");function $e(e){let n=xe(e),o=new Set;return{groups:H({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s($e,"buildFontIR");function Ce(e,n){let o=he(n),r=new Set;return{groups:H({color:o,bg:_(e.bg,n,Re),text:_(e.text,n,Ie),tx:ge(n),shadow:we(n)},r),extensions:{}}}s(Ce,"buildColorIR");function Ve(e,n){let o=ye(n),r={space:o},t=new Set;return{groups:H({space:o,spacing:re(e.spacing,r,ke)},t),extensions:{}}}s(Ve,"buildSpacingIR");function jn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=$n(n,o.dimension),i=Se(t),a=xe(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:_(e.bg,n,Re),text:_(e.text,n,Ie),tx:ge(n),spacing:re(e.spacing,t,ke),border:i.group,font:a.group,shadow:we(n)},extensions:c};return Mn(l)}s(jn,"buildIR");var W=jn;var Fn=An("rgb"),Oe="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function te(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(te,"colorPayload");function ie(e){return e.alpha===void 0}s(ie,"isOpaqueColor");function Ee(e){let n=Fn(Nn(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Ee,"rgbTriplet");function J(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(g(t))o.set(i.join("-"),t);else for(let[a,c]of J(t,i))o.set(a,c)}return o}s(J,"flatTokens");function h(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||g(o))return{};o=o[r]}return o&&!g(o)?o:{}}s(h,"groupAt");function Ge(e){let n=[];for(let o of["bg","text","tx"])for(let[r,t]of J(h(e.groups,o),[o])){let i=te(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:ie(i)})}return n}s(Ge,"colorEntries");function T(e,n){return[...J(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(T,"varEntries");function v(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s(v,"pushScale");function Me(e){let n=[Oe,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Ge(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),v(n,"spacing",T(h(e.groups,"spacing"),["spacing"])),v(n,"borderRadius",T(h(e.groups,"border","radius"),["border","radius"])),v(n,"borderWidth",T(h(e.groups,"border","width"),["border","width"])),v(n,"fontFamily",T(h(e.groups,"font","family"),["font","family"])),v(n,"fontSize",T(h(e.groups,"font","size"),["font","size"])),v(n,"fontWeight",T(h(e.groups,"font","weight"),["font","weight"])),v(n,"lineHeight",T(h(e.groups,"font","lineHeight"),["font","line-height"])),v(n,"boxShadow",T(h(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`)}s(
|
|
4
|
-
`)}s(
|
|
1
|
+
var Gn=Object.defineProperty;var s=(e,n)=>Gn(e,"name",{value:n,configurable:!0}),On=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{mkdir as Ln,mkdtemp as jo,readFile as Cn,rename as Fo,rm as Vn,writeFile as An}from"node:fs/promises";import{tmpdir as Po}from"node:os";import{dirname as Mn,join as H}from"node:path";import{converter as eo,parse as no}from"culori";import{defaultInputBorder as z}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as Nn}from"@apollion-dsi/core/themes/colors";import{createDeth as jn,levelValues as Fn}from"@apollion-dsi/core/themes/depth";import{createFont as Pn,defaultInputFont as L}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as Te}from"@apollion-dsi/core/themes/spacing";import{converter as _n,formatHex as Bn,parse as Hn}from"culori";import{DIMENSION_MULTIPLIERS as En}from"@apollion-dsi/core/themes/dimension";function J({multiplier:e=.25,alias:n},o){let r=o!==void 0?En[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(J,"createSpacing");var le={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"bg.canvas":{description:"Page ground \u2014 the theme canvas (never pure black in dark)."},"bg.paper":{description:"Component ground (cards, inputs, tables) \u2014 lighter than the canvas in both modes."},"bg.overlay":{description:"Top of the elevation ladder \u2014 modal / dialog panels."},"text.primary":{description:"Primary neutral ink \u2014 AA + APCA Lc \u2265 75 over bg.paper and bg.canvas."},"text.muted":{description:"Muted neutral ink \u2014 AA + APCA Lc \u2265 45 over bg.paper."},"edge.border":{description:"Default control outline \u2014 primary ink at 20 % alpha, legible on any ground."},"edge.hairline":{description:"Dividers and card outlines \u2014 primary ink at 10 % alpha."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function de(e){let n=Object.keys(le).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(de,"assertTokenMetaResolves");var Wn=_n("oklch");function h(e){return typeof e.type=="string"&&"value"in e}s(h,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function $e(e){return e.split(".").map(I).join(".")}s($e,"kebabPath");function G(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(G,"rawValue");function q(e,n){return Number(e.toFixed(n))||0}s(q,"round");function ue(e){let n=Wn(Hn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[q(n.l,4),q(n.c,4),q(n.h??0,2)],r=Bn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:q(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ue,"toColorValue");var Ce=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function M(e){let n=Ce.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(M,"toDimensionValue");function k(e){return{type:"color",value:ue(e)}}s(k,"colorToken");function A(e){let n={};for(let[o,r]of Object.entries(e))n[o]=k(r);return n}s(A,"recordColorGroup");function Ve(e){let n=Nn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=k(t);return o.neutral=A(n.neutral),o}s(Ve,"buildReadableTextGroup");var Jn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function Le(e){let n={};for(let o of Jn){let r=e[o];n[o]={base:k(r.base),dark:k(r.dark),action:k(r.action),active:k(r.active),light:k(r.light),onLight:k(r.onLight)}}return n.grayscale=A(e.grayscale),n.neutral=A(e.neutral),n.surface=A(e.surface),n.ink=A(e.ink),n.edge=A(e.edge),n.wash=A(e.wash),n.baseDark=k(e.baseDark??"#000000"),n.baseLight=k(e.baseLight??"#ffffff"),n.deepDark=k(e.deepDark??"#000000"),n.deepLight=k(e.deepLight??"#ffffff"),n}s(Le,"buildColorPrimitives");function Ae(e){let n=J(Te,e),o={};for(let r of Object.keys(Te.alias))o[r]={type:"dimension",value:M(n(r))};return o}s(Ae,"buildSpacePrimitives");function Me(){let e={};for(let[n,o]of Object.entries(z.borderWidth))e[n]={type:"dimension",value:M(o)};return e}s(Me,"buildBorderWidthPrimitives");function qn(e,n){return{color:Le(e),space:Ae(n),borderWidth:Me()}}s(qn,"buildPrimitives");var Ge={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base",canvas:"color.surface.canvas",sunken:"color.surface.sunken",paper:"color.surface.paper",raised:"color.surface.raised",overlay:"color.surface.overlay"},Oe={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight",primary:"color.ink.primary",secondary:"color.ink.secondary",muted:"color.ink.muted",disabled:"color.ink.disabled"},Ee={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function zn(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}s(zn,"lookupPrimitive");function N(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?zn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ue(i)}}:k(i)}return r}s(N,"colorRefGroup");var Ne={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Kn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function Un(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!h(t)&&i in t)t=t[i];else return;return t&&h(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(Un,"lookupDimensionPrimitive");function pe(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Un(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:M(i)}}:{type:"dimension",value:M(i)}}return r}s(pe,"dimensionRefGroup");function je(e){let n={},o={};for(let[i,a]of Object.entries(z.borderRadius))Ce.test(a)?n[i]={type:"dimension",value:M(a)}:o[i]=a;let r=pe(z.borderWidth,e,Kn),t={};for(let[i,a]of Object.entries(z.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(je,"buildBorder");function Fe(e){let n=Pn(L,e),o={};for(let[c,l]of Object.entries(L.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:M(l)};let t={};for(let[c,l]of Object.entries(L.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(L.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:L.letterSpacing,textTransform:L.textTransform,fontStyle:L.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Fe,"buildFont");var Xn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Yn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(Xn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>M(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ue(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(Yn,"parseShadow");function Pe(e){let n=jn(e),o={};for(let r of Object.keys(Fn))o[r]={type:"shadow",value:Yn(n(r))};return o}s(Pe,"buildShadow");function K(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${I(t)}`:I(t);if(h(i)){o.add(a);let c=le[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else r[t]=K(i,a,o)}return r}s(K,"decorateGroup");function Zn(e){let n=new Set,o=K(e.primitives,"",n),r=K(e.groups,"",n);return de(n),{...e,primitives:o,groups:r}}s(Zn,"decorateMeta");function U(e,n){return K(e,"",n)}s(U,"decorateSlice");function _e(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${I(r)}`:I(r);h(t)?o.add(i):_e(t,i,o)}}s(_e,"collectPaths");function Be(e){let n=new Set;for(let o of e)_e(o.groups,"",n);de(n)}s(Be,"assertSlicesMetaComplete");function He(){let e=Me(),o=je({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:U({"border-width":e,border:o.group},t),extensions:r}}s(He,"buildBaseIR");function We(e){let n=Fe(e),o=new Set;return{groups:U({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(We,"buildFontIR");function Je(e,n){let o=Le(n),r=new Set;return{groups:U({color:o,bg:N(e.bg,n,Ge),text:N(e.text,n,Oe),edge:N(e.edge,n,Ee),tx:Ve(n),shadow:Pe(n)},r),extensions:{}}}s(Je,"buildColorIR");function qe(e,n){let o=Ae(n),r={space:o},t=new Set;return{groups:U({space:o,spacing:pe(e.spacing,r,Ne)},t),extensions:{}}}s(qe,"buildSpacingIR");function Qn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=qn(n,o.dimension),i=je(t),a=Fe(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:N(e.bg,n,Ge),text:N(e.text,n,Oe),edge:N(e.edge,n,Ee),tx:Ve(n),spacing:pe(e.spacing,t,Ne),border:i.group,font:a.group,shadow:Pe(n)},extensions:c};return Zn(l)}s(Qn,"buildIR");var j=Qn;var oo=eo("rgb"),ze="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function fe(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(fe,"colorPayload");function me(e){return e.alpha===void 0}s(me,"isOpaqueColor");function Ke(e){let n=oo(no(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Ke,"rgbTriplet");function X(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(h(t))o.set(i.join("-"),t);else for(let[a,c]of X(t,i))o.set(a,c)}return o}s(X,"flatTokens");function R(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||h(o))return{};o=o[r]}return o&&!h(o)?o:{}}s(R,"groupAt");function Ue(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of X(R(e.groups,o),[o])){let i=fe(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:me(i)})}return n}s(Ue,"colorEntries");function T(e,n){return[...X(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(T,"varEntries");function $(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}s($,"pushScale");function Xe(e){let n=[ze,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Ue(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),$(n,"spacing",T(R(e.groups,"spacing"),["spacing"])),$(n,"borderRadius",T(R(e.groups,"border","radius"),["border","radius"])),$(n,"borderWidth",T(R(e.groups,"border","width"),["border","width"])),$(n,"fontFamily",T(R(e.groups,"font","family"),["font","family"])),$(n,"fontSize",T(R(e.groups,"font","size"),["font","size"])),$(n,"fontWeight",T(R(e.groups,"font","weight"),["font","weight"])),$(n,"lineHeight",T(R(e.groups,"font","lineHeight"),["font","line-height"])),$(n,"boxShadow",T(R(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
+
`)}s(Xe,"renderTailwindPreset");function Ye(e){let n=s(t=>[...X(t).keys()],"keys"),o=s(t=>`[${t.map(i=>JSON.stringify(i)).join(", ")}]`,"list");return[ze,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(Ue(e).map(t=>t.key))},`,` spacing: ${o(n(R(e.groups,"spacing")))},`,` borderRadius: ${o(n(R(e.groups,"border","radius")))},`,` borderWidth: ${o(n(R(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(R(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(R(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(R(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(R(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(R(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
|
|
3
|
+
`)}s(Ye,"renderTwMergeExtension");var Ze="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Y(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?o.push(` --apollion-${i.join("-")}: ${G(t.value)};`):Y(t,i,o)}}s(Y,"emitVars");function Z(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(!h(t)){Z(t,i,o);continue}let a=fe(t);a&&me(a)&&o.push(` --apollion-${i.join("-")}-rgb: ${Ke(a)};`)}}s(Z,"emitRgbVars");function ge(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${G(t.value)}; }`):ge(t,i,o)}}s(ge,"emitProperties");function Qe(e,n={}){let{brand:o,mode:r,surface:t,dimension:i}=e.meta,a=[Ze,""];return a.push(`/* Variant: brand=${o} mode=${r} surface=${t} dimension=${i} */`,"",":root {"),Y(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),Z(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ge(e.groups,[],a),a.push("}",""),a.join(`
|
|
4
|
+
`)}s(Qe,"renderCss");function en(e,n,o={}){let{attribute:r="data-apollion-mode",rgbCompanions:t}=o,{brand:i,surface:a,dimension:c}=e.meta,l=[Ze,""],m=s((x,d,u)=>{l.push(`${x} {`,` color-scheme: ${u};`),Y(d.groups,[],l),t&&Z(d.groups,[],l),l.push("}","")},"block");l.push(`/* Variant: brand=${i} surface=${a} dimension=${c} modes=light+dark (attribute ${r}) */`,""),m(`:root, html[${r}="light"]`,e,"light"),m(`html[${r}="dark"]`,n,"dark"),l.push("@media (prefers-color-scheme: dark) {"),l.push(` html:not([${r}]) {`," color-scheme: dark;");let y=[];Y(n.groups,[],y),t&&Z(n.groups,[],y);for(let x of y)l.push(` ${x}`);return l.push(" }","}",""),l.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ge(e.groups,[],l),l.push("}",""),l.join(`
|
|
5
|
+
`)}s(en,"renderCssModes");var ro="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function he(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${r}`:r;h(t)?o.push([i,G(t.value)]):he(t,i,o)}}s(he,"flatten");function to(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}s(to,"yamlEscape");function io(e){let{mode:n,surface:o,dimension:r}=e.meta;return`${n}.${o}.${r}`}s(io,"variantKey");function nn(e,n){if(n.length===0)throw new Error(`renderDesignMd: no variants for brand "${e}"`);let o=["---",`brand: '${e}'`,"generator: apollion-tokens","variants:"];for(let t of n){let i=[];he(t.groups,"",i),o.push(` ${io(t)}:`);for(let[a,c]of i)o.push(` ${a}: ${to(c)}`)}o.push("---");let r=["",ro,"",`# Design.md \u2014 ${e}`,"","Resolved design-token values for this brand, one section per variant.","Consumption rules (which token to reach for, layer boundaries) live in the","package `llms.txt`; this file carries the values those rules reference.","Regenerate with `apollion-tokens build` \u2014 never edit.",""];for(let t of n){let{mode:i,surface:a,dimension:c}=t.meta;r.push(`## Variant \`${i} \xB7 ${a} \xB7 ${c}\``,"");let l=[];he(t.groups,"",l);let m=new Map;for(let[y,x]of l){let d=y.split(".")[0]??y,u=m.get(d)??[];u.push([y,x]),m.set(d,u)}for(let[y,x]of m){r.push(`### ${y}`,"","| Token | Value |","| --- | --- |");for(let[d,u]of x)r.push(`| \`${d}\` | \`${u}\` |`);r.push("")}}return`${o.join(`
|
|
5
6
|
`)}
|
|
6
7
|
${r.join(`
|
|
7
|
-
`)}`}s(
|
|
8
|
-
`}s(
|
|
9
|
-
`}s(
|
|
10
|
-
`)}s(
|
|
11
|
-
`}s(
|
|
8
|
+
`)}`}s(nn,"renderDesignMd");function on(e){return e.alpha!==void 0?{colorSpace:"oklch",components:[...e.components],alpha:e.alpha,hex:e.hex}:{colorSpace:"oklch",components:[...e.components],hex:e.hex}}s(on,"colorValue");function P(e){return{value:e.value,unit:e.unit}}s(P,"dimensionValue");function so(e){let n=e.shadow,o={color:on(n.color),offsetX:P(n.offsetX),offsetY:P(n.offsetY),blur:P(n.blur),spread:P(n.spread)};return n.inset&&(o.inset=!0),o}s(so,"shadowValue");function ao(e){switch(e.kind){case"ref":return`{${$e(e.path)}}`;case"color":return on(e);case"dimension":return P(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return so(e)}}s(ao,"projectValue");function co(e){let n={$value:ao(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(co,"projectToken");function ye(e){let n={};for(let[o,r]of Object.entries(e))n[I(o)]=h(r)?co(r):ye(r);return n}s(ye,"projectGroup");function Q(e,n){let o={$description:n,...ye(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
9
|
+
`}s(Q,"renderSet");function rn(e){return Q(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(rn,"renderBaseSet");function tn(e,n,o,r){return Q(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(tn,"renderColorSet");function sn(e,n){return Q(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(sn,"renderSpacingSet");function an(e,n){return Q(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(an,"renderFontSet");function cn(e,n){let{modifiers:o}=n,r=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],i={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:r,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(i,null,2)}
|
|
10
|
+
`}s(cn,"renderResolver");var lo="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function uo(e,n,o){let r=[];if(e.description!==void 0&&r.push(e.description),e.deprecated===!0?r.push("@deprecated"):typeof e.deprecated=="string"&&r.push(`@deprecated ${e.deprecated}`),r.length!==0){o.push(`${n}/**`);for(let t of r)o.push(`${n} * ${t.replace(/\*\//g,"*\\/")}`);o.push(`${n} */`)}}s(uo,"emitDoc");function ln(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))h(i)?(uo(i,r,o),o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(G(i.value))},`)):(o.push(`${r}${t}: {`),ln(i,n+1,o),o.push(`${r}},`))}s(ln,"emitGroup");function dn(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[lo,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return ln(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
11
|
+
`)}s(dn,"renderTs");var po=["light","dark"],fo=["positive","negative"],mo=["compact","normal","spacious"];function ee(e){let n=e.modes??po,o=e.surfaces??fo,r=e.dimensions??mo,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let l of n)for(let m of o)for(let y of r)i.push({brand:a,colors:c,mode:l,surface:m,dimension:y});return i}s(ee,"expandVariants");function un(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(un,"variantName");import{createHash as go}from"node:crypto";function ne(e){return go("sha256").update(e).digest("hex")}s(ne,"sha256");function Re(e){return ne(be(e))}s(Re,"hashConfig");function be(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(be).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${be(e[r])}`).join(",")}}`}s(be,"stableStringify");function pn(e){try{let{execSync:n}=On("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(pn,"detectGitCommit");function fn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(fn,"buildEnv");function mn(e){let n=[...e.files].sort((r,t)=>r.path.localeCompare(t.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
|
|
12
|
+
`}s(mn,"serializeManifest");var ho="json/sets",gn="json/resolver.json";function oe(e){return`${ho}/${e}.json`}s(oe,"setFile");function yo(e,n,o){return`${e}.color.${n}.${o}`}s(yo,"colorSetName");function bo(e){return`spacing.${e}`}s(bo,"spacingSetName");function Ro(e){return`font.${e}`}s(Ro,"fontSetName");function re(e,n){e.includes(n)||e.push(n)}s(re,"pushUnique");function hn(e){let n=ee(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],y=new Set,x=[];for(let d of n){re(o,d.brand),re(r,d.mode),re(t,d.surface),re(i,d.dimension);let u=yo(d.brand,d.mode,d.surface);a.has(u)||(a.add(u),c.push({kind:"color",name:u,file:oe(u),brand:d.brand,mode:d.mode,surface:d.surface}));let g=bo(d.dimension);l.has(g)||(l.add(g),m.push({kind:"spacing",name:g,file:oe(g),dimension:d.dimension}));let f=Ro(d.dimension);y.has(f)||(y.add(f),x.push({kind:"font",name:f,file:oe(f),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:oe("base")},spacing:m,font:x,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(hn,"planSets");import{toDarkColors as Mo}from"@apollion-dsi/core/themes/colors";import{createFoundation as $n}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Go}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as Oo}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Eo}from"@apollion-dsi/core/themes/surface";import{converter as In,formatHex as O,interpolate as ko,parse as S,wcagContrast as Sn}from"culori";var B=In("oklch"),Io=In("rgb");function p(e,n,o){let r=S(e),t=S(n);if(!r||!t)return e;let i=ko([r,t],"oklch");return O(i(o))??e}s(p,"mixOklch");function So(e){return e?typeof e=="string"?e:e.base:"#000"}s(So,"coerceToHex");var te=1.3,xo=.05,yn=.04,C=s((e,n)=>{let o=S(e),r=S(n);return!o||!r?1:Sn(o,r)},"contrastRatio"),ke=s(e=>{let n=B(S(e));return n?n.l??0:null},"oklchLightness"),vo=4.5;function _(e,n,o=vo){let r=S(n),t=B(S(e));if(!r||!t)return e;let i=C("#fff",n)>=C("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=O(t)??e,l=S(c);if(l&&Sn(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return O(t)??e}s(_,"readableColor");var bn=s((e,n)=>{if(C(e,n)>=te)return!0;let o=ke(e),r=ke(n);return o!==null&&r!==null&&Math.abs(o-r)>=xo},"isPerceptibleState"),Ie=s(e=>e?C("#fff",e)>C("#000",e):!1,"isDarkSurface");function Rn(e,n,o){let r=B(S(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?yn:-yn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=O(t);if(l&&C(e,l)>=te)return l}return O(t)??null}s(Rn,"derivePerceptibleState");function kn(e,n,o){let r=Rn(e,n,o);if(r&&C(e,r)>=te)return r;let t=Rn(e,!n);return t&&C(e,t)>=te?t:r??t}s(kn,"perceptibleStateFor");function v(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=So(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:p(r,t,.6),action:p(r,t,.2),active:p(r,i,.6),light:p(r,i,.9),onLight:r};if(S(r)){let c=Ie(n.baseLight),l=bn(r,a.action);if(l||(a.action=kn(r,c)??a.action),!bn(r,a.active)){let m=l?void 0:ke(a.action)??void 0;a.active=kn(r,c,m)??a.active}}if(a.onLight=_(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:r,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??_(c,l)}}return a}s(v,"mountSingleColor");function xn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:p(n,o,.05),10:p(n,o,.1),20:p(n,o,.2),30:p(n,o,.3),40:p(n,o,.4),50:p(n,o,.5),60:p(n,o,.6),70:p(n,o,.7),80:p(n,o,.8),90:p(n,o,.9),100:p(n,o,1)}}s(xn,"mountGreyscaleColors");function vn(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=p(r,o,.5);return{0:p(i,n,t(18)),5:p(i,n,t(17.5)),10:p(i,n,t(17)),20:p(i,n,t(16)),30:p(i,n,t(15)),40:p(i,n,t(14)),50:p(i,n,t(13)),60:p(i,n,t(12)),70:p(i,n,t(11)),80:p(i,n,t(10)),90:p(i,n,t(9)),100:p(i,n,t(8)),110:p(i,n,t(7)),120:p(i,n,t(6)),130:p(i,n,t(5)),140:p(i,n,t(4)),150:p(i,n,t(3)),160:p(i,n,t(2)),170:i,180:p(i,o,.25)}}s(vn,"mountNeutralColors");function F(e,n){let o=B(S(e));if(!o)return e;let r=Math.min(1,Math.max(0,(o.l??0)+n));return O({...o,l:r})??e}s(F,"shiftLightness");function ie(e,n){let o=B(S(e));if(!o)return e;let r=o.l??0,t=n.min??0,i=n.max??1;return r>=t&&r<=i?e:O({...o,l:Math.min(i,Math.max(t,r))})??e}s(ie,"clampLightness");function E(e,n){let o=Io(S(e));if(!o)return e;let r=Math.min(1,Math.max(0,n)),t=s(i=>Math.round((i??0)*255),"channel");return`rgba(${t(o.r)}, ${t(o.g)}, ${t(o.b)}, ${r})`}s(E,"toRgbaString");import{apcaContrast as se,EDGE_ALPHA as Se,HALATION_FLOORS as we,INK_APCA_MIN as xe,INK_MIX as ve,LADDER_DELTAS as ae,MIN_CONTRAST_AA as wn,WASH_ALPHA as wo}from"@apollion-dsi/core/themes/colors";var Do="#FFFFFF",De="#000000";function To(e){return Ie(e.baseLight)?"dark":"light"}s(To,"resolvePolarity");function Dn(e,n,o){if(Math.abs(se(e,n))>=o)return e;let r=Math.abs(se("#ffffff",n))>=Math.abs(se("#000000",n)),t=e;for(let i=0;i<40;i+=1){let a=F(t,r?.02:-.02);if(a===t||(t=a,Math.abs(se(t,n))>=o))break}return t}s(Dn,"ensureApca");function $o(e,n){let o=e.baseLight??Do,r=n==="dark",t=r?ie(o,{min:we.CANVAS_MIN_L}):o,i=F(t,ae.sunken);return{canvas:t,sunken:r?ie(i,{min:we.CANVAS_MIN_L}):i,paper:F(t,ae.paper),raised:F(t,ae.raised),overlay:F(t,ae.overlay),scrim:r?e.deepLight??De:e.neutral?.["180"]??e.baseDark??De}}s($o,"deriveSurface");function Co(e,n){let o=e.baseDark??De,r=ie(Dn(_(o,n.paper,wn),n.paper,xe.primary),{max:we.INK_MAX_L}),t=s((i,a)=>Dn(_(p(r,n.canvas,i),n.paper,wn),n.paper,a),"tier");return{primary:r,secondary:t(ve.secondary,xe.secondary),muted:t(ve.muted,xe.muted),disabled:p(r,n.canvas,ve.disabled)}}s(Co,"deriveInk");function Vo(e){return{hairline:E(e.primary,Se.hairline),border:E(e.primary,Se.border),strong:E(e.primary,Se.strong)}}s(Vo,"deriveEdge");function Lo(e,n){let o=wo[n];return{hover:E(e.primary,o.hover),pressed:E(e.primary,o.pressed),selected:E(e.primary,o.selected)}}s(Lo,"deriveWash");function Ao(e,n){return n?{surface:{...e.surface,...n.surface},ink:{...e.ink,...n.ink},edge:{...e.edge,...n.edge},wash:{...e.wash,...n.wash}}:e}s(Ao,"applyOverride");function Tn(e,n){let o=To(e),r=$o(e,o),t=Co(e,r),i={surface:r,ink:t,edge:Vo(t),wash:Lo(t,o)};return Ao(i,n?.[o])}s(Tn,"resolveSurfaceLadder");function No(e){let n=vn(e);return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:n,grayscale:xn(e),...Tn({...e,neutral:n},e.ladder),main:v(e.main,e),opposite:v(e.opposite,e),complementary:v(e.complementary,e),danger:v(e.danger,e),information:v(e.information,e),success:v(e.success,e),warning:v(e.warning,e),primary:v(e.primary,e),secondary:v(e.secondary,e),tertiary:v(e.tertiary,e)}}s(No,"composeColors");function V(e,n=Oo){let o=e.mode==="dark"?Mo(e.colors):e.colors,r=No(o),t=J(n,e.dimension),i=Go({colors:r,spacing:t}),a=$n(i);return e.surface==="negative"&&(a=$n(Eo({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(V,"buildVariantThemes");async function ct(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=ee(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await jo(H(Po(),"apollion-tokens-"));try{let l=[],m=s(async(d,u)=>{await _o(c,d,u),l.push({path:d,sha256:ne(u)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=hn(n),u=[],g=He();u.push(g),await m(d.base.file,rn(g));for(let f of d.spacing){let b=i.find(W=>W.dimension===f.dimension),{foundation:w}=V(b),D=qe(w,f.dimension);u.push(D),await m(f.file,sn(D,f.dimension))}for(let f of d.font){let b=We(f.dimension);u.push(b),await m(f.file,an(b,f.dimension))}for(let f of d.color){let b=i.find(ce=>ce.brand===f.brand&&ce.mode===f.mode&&ce.surface===f.surface),{foundation:w,colors:D}=V(b),W=Je(w,D);u.push(W),await m(f.file,tn(W,f.brand,f.mode,f.surface))}Be(u),await m(gn,cn(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:u,colors:g}=V(d),f=j(u,g,d),b=un(d);a.css&&await m(`css/${b}.css`,Qe(f,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${b}.d.ts`,dn(f))}if(a.cssModes){let d=new Map;for(let u of i){let g=`${u.brand}.${u.surface}.${u.dimension}`,f=d.get(g)??{};f[u.mode]=u,d.set(g,f)}for(let[u,{light:g,dark:f}]of d){if(!g||!f)throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${u} (config.modes)`);let b=V(g),w=V(f),D=en(j(b.foundation,b.colors,g),j(w.foundation,w.colors,f),{rgbCompanions:a.tailwind});await m(`css/${u}.modes.css`,D)}}if(a.tailwind){let d=i[0],{foundation:u,colors:g}=V(d),f=j(u,g,d);await m("tailwind/preset.mjs",Xe(f)),await m("tailwind/tw-merge.mjs",Ye(f))}if(a.designMd){let d=[...new Set(i.map(u=>u.brand))];for(let u of d){let f=i.filter(b=>b.brand===u).map(b=>{let{foundation:w,colors:D}=V(b);return j(w,D,b)});await m(`design/${u}.design.md`,nn(u,f))}}let y={configHash:Re(n),files:l,gitCommit:pn(r),buildEnv:fn()},x=mn(y);return await An(H(c,"manifest.json"),x),await Vn(o,{recursive:!0,force:!0}),await Ln(Mn(o),{recursive:!0}),await Fo(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:y,outDir:o}}catch(l){throw await Vn(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(ct,"build");async function lt(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await Cn(H(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==Re(n))return!1;for(let t of r.files){let i;try{i=await Cn(H(o,t.path))}catch{return!1}if(ne(i)!==t.sha256)return!1}return!0}s(lt,"check");async function _o(e,n,o){let r=H(e,n);await Ln(Mn(r),{recursive:!0}),await An(r,o)}s(_o,"writeAt");export{ct as build,lt as check};
|
package/lib/builders/colors.d.ts
CHANGED
|
@@ -25,8 +25,24 @@
|
|
|
25
25
|
* @see ../../docs/prd/PRD-002-v4-epic-execution.md §S4
|
|
26
26
|
*/
|
|
27
27
|
import type { AcceptColorType, ColorPalleteInterface, ColorPalleteOverrideInterface, ColorsInput, GrayscaleColorsType, NeutralColorsType } from '@apollion-dsi/core/themes/colors';
|
|
28
|
+
/**
|
|
29
|
+
* OKLch perceptual lerp wrapper. See core's S2 docs for rationale.
|
|
30
|
+
*
|
|
31
|
+
* Validation: `spike/culori-oklch-lerp-parity` (preservada local — ADR-006
|
|
32
|
+
* §11.5) confirmou 0 unexpected regressions em 68 deltas; greyscale ramp
|
|
33
|
+
* 19× mais uniforme em OKLAB L space.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mixOklch(a: string, b: string, t: number): string;
|
|
28
36
|
/** Rotate hue 180° in OKLch space. Semantic shift vs HSL — see core for details. */
|
|
29
37
|
export declare function getOppositeColor(color: AcceptColorType): string;
|
|
38
|
+
/**
|
|
39
|
+
* Adjusts the OKLch L of `color` until it passes `minRatio` against `background`,
|
|
40
|
+
* preserving hue/chroma — **byte-for-byte mirror** of the core's `readableColor`
|
|
41
|
+
* (`Colors.helpers.ts`; parity.test.ts). Used to derive the tonal ink
|
|
42
|
+
* `onLight` (APOLLION-CONTRAST-GUARANTEE).
|
|
43
|
+
*/
|
|
44
|
+
export declare function readableColor(color: string, background: string, minRatio?: number): string;
|
|
45
|
+
export declare const isDarkSurface: (baseLight?: string) => boolean;
|
|
30
46
|
/**
|
|
31
47
|
* Derive `{ base, dark, action, active, light }` via OKLch lerp, with a
|
|
32
48
|
* mode-aware perceptual state floor on the interaction states — byte-for-byte
|
|
@@ -37,3 +53,14 @@ export declare function mountSingleColor(color: AcceptColorType | ColorPalleteOv
|
|
|
37
53
|
export declare function mountGreyscaleColors(colors: ColorsInput): Record<GrayscaleColorsType, string>;
|
|
38
54
|
/** 20-step neutral ramp anchored at n170 (primary mixed with darker). */
|
|
39
55
|
export declare function mountNeutralColors(colors: ColorsInput): Record<NeutralColorsType, string>;
|
|
56
|
+
/**
|
|
57
|
+
* Ladder primitives — Strangler Fig mirror of core's `shiftLightness` /
|
|
58
|
+
* `clampLightness` / `toRgbaString` (APOLLION-DARK-MODE-ENGINE S0). Byte parity
|
|
59
|
+
* enforced in `__tests__/parity.test.ts`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function shiftLightness(color: string, delta: number): string;
|
|
62
|
+
export declare function clampLightness(color: string, range: {
|
|
63
|
+
min?: number;
|
|
64
|
+
max?: number;
|
|
65
|
+
}): string;
|
|
66
|
+
export declare function toRgbaString(color: string, alpha: number): string;
|