@theme-registry/refract 0.1.6 → 0.1.8
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 +25 -1
- package/dist/build/config.d.ts +9 -0
- package/dist/build/emitTheme.d.ts +3 -0
- package/dist/build/index.d.ts +1 -0
- package/dist/build/preview.d.ts +73 -0
- package/dist/build.cjs.js +1 -1
- package/dist/build.cjs.js.map +1 -1
- package/dist/build.esm.js +1 -1
- package/dist/build.esm.js.map +1 -1
- package/dist/cli.js +403 -8
- package/dist/cli.js.map +1 -1
- package/dist/core/ThemeAdapter.d.ts +58 -0
- package/package.json +2 -2
- package/skills/adapter-scaffold/SKILL.md +10 -0
- package/skills/build-config/SKILL.md +29 -2
- package/skills/consuming-the-output/SKILL.md +5 -0
package/dist/build.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("node:fs"),t=require("node:path"),r=require("node:url"),n=require("node:readline"),o=require("node:os"),s=require("node:readline/promises"),i=require("node:util"),a="undefined"!=typeof document?document.currentScript:null;const l=[{id:"color-math",outfile:"color-math.js",source:"src/subsystems/colors/utils.ts",exports:["lighten","darken","alpha","setL","rotateHue","complement","adjust","rgbToOklch","oklchToRgb","toHexColor","toOklchColor","convertHexToRGB","convertRgbToHex"],description:"Pure OKLCH colour math — the exact lighten/darken/setL/rotateHue/complement/adjust (+ OKLCH and hex converters) refract synthesizes palette steps/variants with, so a value computed live in the consumer matches the emitted CSS variables."}],c=e=>l.find(t=>t.id===e),u=(n=(()=>"undefined"!=typeof __dirname?__dirname:t.dirname(r.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("build.cjs.js",document.baseURI).href)))())=>{let o=n;for(;;){if(e.existsSync(t.join(o,"package.json")))return o;const r=t.dirname(o);if(r===o)throw new Error(`No package.json found walking up from "${n}".`);o=r}},d=r=>{const n=t.join(u(),r);if(!e.existsSync(n))throw new Error(`Vendor helper source "${r}" not found at "${n}". Ensure it is listed in package.json "files" so it ships with the package.`);return e.readFileSync(n,"utf8")};async function f(){var e;try{const t=await import("typescript");return null!==(e=t.default)&&void 0!==e?e:t}catch{throw new Error('refract: the optional peer dependency "typescript" is required to transpile a `.ts` theme.config or vendor a shared helper module, but it could not be resolved. Install it (`npm i -D typescript`), or use a `.mjs`/`.js` config and avoid the `helpers` opt-in.')}}const p=async e=>{const t=await f();return t.transpileModule(e,{compilerOptions:{module:t.ModuleKind.ESNext,target:t.ScriptTarget.ES2020}}).outputText};let m=0;const h=e=>t.resolve(e).replace(/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/,""),g=async r=>{const n=await f(),o={module:n.ModuleKind.ESNext,target:n.ScriptTarget.ES2020,moduleResolution:n.ModuleResolutionKind.Bundler,resolveJsonModule:!0,allowJs:!1,noLib:!0,skipLibCheck:!0,noEmitOnError:!1,declaration:!1,sourceMap:!1,types:[]},s=n.createCompilerHost(o),i=n.createProgram([r],o,s),a=new Map,l=e=>!e.isDeclarationFile&&!e.fileName.includes("/node_modules/")&&/\.(ts|tsx|mts|cts)$/.test(e.fileName);for(const e of i.getSourceFiles()){if(!l(e))continue;const r=t.resolve(e.fileName),n=t.basename(r).replace(/\.(ts|tsx|mts|cts)$/,"");a.set(h(r),t.join(t.dirname(r),`.${n}.${process.pid}-${m++}.mjs`))}const c=e=>r=>{const i=t.resolve(r.fileName),l=e.factory,c=e=>{const r=((e,t)=>{var r;if(!e.startsWith("."))return;const i=null===(r=n.resolveModuleName(e,t,o,s).resolvedModule)||void 0===r?void 0:r.resolvedFileName;return i?a.get(h(i)):void 0})(e,i);return r?l.createStringLiteral(`./${t.basename(r)}`):void 0},u=t=>{if(n.isImportDeclaration(t)&&n.isStringLiteral(t.moduleSpecifier)){const e=c(t.moduleSpecifier.text);if(e)return l.updateImportDeclaration(t,t.modifiers,t.importClause,e,t.attributes)}else if(n.isExportDeclaration(t)&&t.moduleSpecifier&&n.isStringLiteral(t.moduleSpecifier)){const e=c(t.moduleSpecifier.text);if(e)return l.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,e,t.attributes)}else if(n.isCallExpression(t)&&t.expression.kind===n.SyntaxKind.ImportKeyword&&t.arguments.length&&n.isStringLiteral(t.arguments[0])){const e=c(t.arguments[0].text);if(e)return l.updateCallExpression(t,t.expression,t.typeArguments,[e,...t.arguments.slice(1)])}return n.visitEachChild(t,u,e)};return n.visitNode(r,u)},u=[],d=(t,r)=>{const n=a.get(h(t));n&&(e.writeFileSync(n,r,"utf8"),u.push(n))},p=()=>{for(const t of u)e.rmSync(t,{force:!0})};try{i.emit(void 0,d,void 0,!1,{before:[c]})}catch(e){throw p(),e}const g=a.get(h(r));if(!g||!e.existsSync(g))throw p(),new Error(`refract: failed to compile the \`.ts\` config graph for "${r}".`);return{entry:g,cleanup:p}},b=e=>e.replace(/\|/g,"\\|");function v(e,t,r){var n;const o=[];if(o.push(`# Theme consumption guide (${e.format})`),o.push(""),o.push("This folder is a self-contained theme built with refract. You do NOT need refract to use it —","everything below refers to files in THIS folder (relative paths), so it works whether the theme","was installed as a package, unzipped from an artifact, or vendored into a repo."),o.push(""),t.files.length>0){o.push("## Files"),o.push("");for(const e of t.files)o.push(`- \`./${e}\``);o.push("")}o.push("## How to use"),o.push("");for(const t of e.summary)o.push(t);t.packageName&&(o.push(""),o.push(`If this theme is installed as the \`${t.packageName}\` package, you may import the same`,`files by specifier (e.g. \`${t.packageName}/${null!==(n=t.files[0])&&void 0!==n?n:"theme.css"}\`) instead of by relative path.`)),o.push("");const{recipes:s}=e;if(s.length>0){o.push("## Recipes — real names"),o.push(""),o.push("Use these exact identities; do not invent names."),o.push(""),o.push("| Recipe | Identity |"),o.push("| --- | --- |");const e=s.slice(0,60);for(const t of e)o.push(`| \`${b(`${t.subsystem}.${t.group}.${t.variant}`)}\` | \`${b(t.name)}\` |`);if(s.length>e.length){const t=s.length-e.length;o.push(""),o.push(`_(+${t} more recipe(s) — the complete list is in ${r?`\`./${r}\``:"the manifest"}.)_`)}o.push("")}return r&&(o.push("## Machine-readable index"),o.push(""),o.push(`See \`./${r}\` for the full recipe index and the theme's tokens (DTCG format).`),o.push("")),o.join("\n")}function y(e,t,r){var n;const o=null!==(n=r.llmsFile)&&void 0!==n?n:"llms.txt",s=void 0===r.manifestFile?"manifest.json":r.manifestFile,i={[o]:v(e,r,s)};if(s){const n={schema:1,format:e.format,files:r.files,packageName:r.packageName,recipes:e.recipes,tokens:t};i[s]=`${JSON.stringify(n,null,2)}\n`}return{files:i}}class w extends Error{constructor(e,t,r){super(t),this.name="RefractError",this.code=e,r&&(this.failures=r),Object.setPrototypeOf(this,w.prototype)}}const $=e=>"string"==typeof e||"number"==typeof e,k=e=>Array.isArray(e),x=e=>({value:e}),j=(e,t)=>{if(!t)return x(e);const r={ref:t.ref};return void 0!==t.fn&&(r.fn=t.fn),void 0!==t.arg&&(r.arg=t.arg),void 0!==t.modifiers&&(r.modifiers=t.modifiers),void 0!==e&&(r.value=e),r},A=new Set(["mode","target","base","derive"]),S=(e,t,r)=>{const n={},o=e.derive,s=e.base;if(o){if(void 0===o.ref)throw new w("REFRACT_E_REFERENCE",`Derived appearance mode "${t}.modes.${r}" was not baked — derived modes require a subsystem that resolves them (colors). Use a literal value instead.`);n.base=j($(s)?s:void 0,o)}else $(s)?n.base=x(s):k(s)&&(n.base={struct:s});for(const[t,r]of Object.entries(e))A.has(t)||$(r)&&(n[t]=x(r));return n},E=(e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||$(o)&&(r[n]=x(o));return r},R=new Set(["base","derive"]),C=new Set(["base","responsive","variants","modes","external"]),O=new Set(["breakpoint","query","state","orientation","ref","modifiers","mode","variant","target","derive","ratio","step","steps"]),T=(e,t="property")=>{var r;const n={base:void 0!==e.external?{value:`var(${e.external})`,external:e.external}:(o=e.base,k(o)?{struct:o}:x(o))};var o;const s=E(e,C);if(Object.keys(s).length&&(n.extras=s),e.variants&&Object.keys(e.variants).length){const t={};for(const[r,n]of Object.entries(e.variants)){let e;const o=n.derive;if($(n.base)?e=j(n.base,o):k(n.base)?e={struct:n.base}:void 0!==(null==o?void 0:o.ref)&&(e=j(void 0,o)),!e)continue;const s=E(n,R);t[r]=Object.keys(s).length?{base:e,extras:s}:{base:e}}Object.keys(t).length&&(n.variants=t)}const i=e.modes;if(i&&i.length){const e=[];for(const r of i){const n=r.mode,o=S(r,t,n);if(!Object.keys(o).length)continue;const s={mode:n,overrides:o};"string"==typeof r.target&&(s.target=r.target),e.push(s)}e.length&&(n.modes=e)}if(null===(r=e.responsive)||void 0===r?void 0:r.length){const t=e.responsive.map(e=>{const t=e,r={breakpoint:t.breakpoint};"string"==typeof t.query&&(r.query=t.query),"string"==typeof t.orientation&&(r.orientation=t.orientation),"string"==typeof t.ref&&(r.ref=t.ref),"string"==typeof t.mode&&(r.mode=t.mode),"string"==typeof t.target&&(r.target=t.target);const n=((e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||($(o)?r[n]=x(o):k(o)&&(r[n]={struct:o}));return r})(t,O),o=t.derive;return o&&n.base&&void 0!==n.base.value&&(n.base=j(n.base.value,o)),Object.keys(n).length&&(r.overrides=n),r});n.responsive=t}return n},F=e=>({kind:"recipe",declarations:{...e.base},overrides:e.responsive.map(e=>{const t={};return void 0!==e.state&&(t.state=e.state),void 0!==e.breakpoint&&(t.breakpoint=e.breakpoint),void 0!==e.query&&(t.query=e.query),void 0!==e.orientation&&(t.orientation=e.orientation),void 0!==e.container&&(t.container=e.container),void 0!==e.size&&(t.size=e.size),void 0!==e.variant&&(t.variant=e.variant),void 0!==e.target&&(t.target=e.target),Object.keys(e.declarations).length&&(t.declarations={...e.declarations}),t})}),_=(e,t)=>{const r=F(e);return r.kind="recipe",t.length&&(r.references=t),r},N=new Set(["colors","typography","layout","effects","borders"]),P=e=>!!e&&Object.keys(e).length>0,z=e=>{var t;if(!e)return;const r={};return e.properties&&Object.keys(e.properties).length&&(r.properties=(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]=T(n,r);return t})(e.properties)),e.extraProperties&&Object.keys(e.extraProperties).length&&(r.properties={...null!==(t=r.properties)&&void 0!==t?t:{},...e.extraProperties}),P(e.ruleSetGroups)&&(r.ruleSets=e.ruleSetGroups),P(e.keyframes)&&(r.keyframes=e.keyframes),Object.keys(r).length?r:void 0},M=e=>{var t,r,n,o;const s={};for(const[i,a]of Object.entries(e.subsystems))for(const[e,l]of Object.entries(null!==(t=a.properties)&&void 0!==t?t:{})){const t=`${i}.${e}`;s[t]=l.base;for(const[e,o]of Object.entries(null!==(r=l.variants)&&void 0!==r?r:{})){s[`${t}.${e}`]=o.base;for(const[r,i]of Object.entries(null!==(n=o.extras)&&void 0!==n?n:{}))s[`${t}.${e}.${r}`]=i}for(const[e,r]of Object.entries(null!==(o=l.extras)&&void 0!==o?o:{}))s[`${t}.${e}`]=r}return s},L=new Set(["px","cm","mm","q","in","pc","pt","rem","em","ex","cap","ch","ic","lh","rlh","%","vw","vh","vi","vb","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh","cqw","cqh","cqi","cqb","cqmin","cqmax"]),q=/^-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?$/i,I=/^(-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?)([a-z%]+)$/i,B=e=>{if("number"==typeof e)return{value:e};const t=e.trim();if(q.test(t))return{value:Number(t)};const r=I.exec(t);if(r){const t=r[2].toLowerCase();if(L.has(t))return{value:Number(r[1]),unit:t};throw new w("REFRACT_E_UNITS",`Unknown length unit "${r[2]}" in "${e}". Use a CSS unit, or wrap functions/keywords (calc(), clamp(), var(), a keyword) — those pass through as raw strings.`)}return{raw:e}},U={"typography.lineHeight":"none","typography.letterSpacing":"em"},D=(e,t)=>{var r,n,o,s;const i=e.slice(0,e.indexOf("."));return null!==(s=null!==(o=null!==(n=null!==(r=null==t?void 0:t[e])&&void 0!==r?r:U[e])&&void 0!==n?n:null==t?void 0:t[i])&&void 0!==o?o:null==t?void 0:t.default)&&void 0!==s?s:"px"},V=(e,t)=>Number((e/t).toFixed(4)),W=(e,t,r)=>"none"===t?{value:e}:"rem"===t?{value:V(e,r),unit:"rem"}:{value:e,unit:t},H=(e,t,r)=>{if("number"==typeof e){const{value:n,unit:o}=W(e,t,r);return void 0===o?e:{value:n,unit:o}}return e},G={typography:{fontSize:"length",letterSpacing:"length",lineHeight:"length"},layout:{spacing:"length",gutters:"length",sizes:"length"},borders:{width:"length",offset:"length",radius:"length"},effects:{blur:"length",shadow:"shadow"}},Y=(e,t)=>{let r=!1;const n={};for(const[o,s]of Object.entries(e)){const e=t(s);e!==s&&(r=!0),n[o]=e}return r?n:e},J=(e,t,r)=>{const n=t(e.base),o=e.variants?((e,t)=>{let r=!1;const n={};for(const[o,s]of Object.entries(e)){const e=t(s.base),i=s.extras?Y(s.extras,t):void 0;e===s.base&&i===s.extras||(r=!0),n[o]=i?{base:e,extras:i}:{base:e}}return r?n:e})(e.variants,t):void 0,s=r&&e.extras?Y(e.extras,t):e.extras,i=e.modes?((e,t)=>{let r=!1;const n=e.map(e=>{if(!e.overrides)return e;const n=Y(e.overrides,t);return n===e.overrides?e:(r=!0,{...e,overrides:n})});return r?n:e})(e.modes,t):void 0,a=((e,t)=>{if(!e.responsive)return;let r=!1;const n=e.responsive.map(e=>{if(!e.overrides)return e;const n=Y(e.overrides,t);return n===e.overrides?e:(r=!0,{...e,overrides:n})});return r?n:e.responsive})(e,t);if(n===e.base&&o===e.variants&&s===e.extras&&i===e.modes&&a===e.responsive)return e;const l={...e,base:n};return void 0!==o&&(l.variants=o),void 0!==s&&(l.extras=s),void 0!==i&&(l.modes=i),void 0!==a&&(l.responsive=a),l},K=(e,t,r,n)=>{const o="shadow"===t?e=>{if(!e.struct)return e;const t=e.struct;let o=!1;const s=t.map(e=>{const t=((e,t,r)=>{const n={...e};let o=!1;for(const s of["offsetX","offsetY","blur","spread"]){const i=e[s];if(void 0===i)continue;const a=H(i,t,r);a!==i&&(n[s]=a,o=!0)}return o?n:e})(e,r,n);return t!==e&&(o=!0),t});return o?{...e,struct:s}:e}:e=>((e,t,r)=>{if(void 0!==e.unit)return e;if(void 0!==e.ref&&void 0===e.value)return e;const n=e.value;if("number"==typeof n){const{value:o,unit:s}=W(n,t,r);return void 0===s?e:{...e,value:o,unit:s}}if("string"==typeof n){const o=B(n);if("raw"in o)return e;if(void 0!==o.unit)return{...e,value:o.value,unit:o.unit};const{value:s,unit:i}=W(o.value,t,r);return void 0===i?{...e,value:s}:{...e,value:s,unit:i}}return e})(e,r,n);return J(e,o,!1)},X=(e,t={})=>{var r;const n=null!==(r=t.baseFontSize)&&void 0!==r?r:16;let o=!1;const s={};for(const[r,i]of Object.entries(e.subsystems)){const e=G[r];if(!e||!i.properties){s[r]=i;continue}let a=!1;const l={};for(const[o,s]of Object.entries(i.properties)){const i=e[o];if(!i){l[o]=s;continue}const c=D(`${r}.${o}`,t.units),u=K(s,i,c,n);u!==s&&(a=!0),l[o]=u}a?(s[r]={...i,properties:l},o=!0):s[r]=i}return o?{...e,subsystems:s}:e},Z=e=>(null==e?void 0:e.propertyPath)?` for "${e.propertyPath}"`:"",Q=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e));function ee(e,t){const r=e.variants?Object.keys(e.variants):[];if(!r.length)return;const n=new Set(r),o=(null==t?void 0:t.propertyPath)?` for "${t.propertyPath}"`:"";for(const t of e.responsive){if(t.ref&&!n.has(t.ref))throw new w("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown variant "${t.ref}" (ref).`);if(t.target&&!n.has(t.target))throw new w("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown target "${t.target}".`)}}const te=e=>"object"==typeof e&&null!==e&&Array.isArray(e.modifiers),re=(e,t)=>{if(!Array.isArray(e)||0===e.length)throw new w("REFRACT_E_VARIANT",`Derivation "${t}" needs a non-empty "modifiers" array.`);return e.map((e,r)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new w("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must be a single-key object like { darken: 10 }.`);const n=Object.keys(e);if(1!==n.length)throw new w("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must have exactly one fn key; got [${n.join(", ")}].`);return{fn:n[0],arg:e[n[0]]}})},ne=new Set(["breakpoint","query","ref","modifiers","mode","target","orientation"]),oe=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),se=(e,t,r)=>{var n;const o=null!==(n=null!=e?e:t)&&void 0!==n?n:r.fallbackBase;if(void 0===o)throw new w("REFRACT_E_PROPERTY",`Unable to resolve base value${s=r.propertyPath,s?` for "${s}"`:""}.`);var s;return r.coerceValue?r.coerceValue(o):o},ie=(e,t)=>{const r=new Set(t),n={},o={};let s=!1;for(const[t,i]of Object.entries(e))r.has(t)?(n[t]=i,s=!0):o[t]=i;return{base:s?n:void 0,extra:o}},ae=(e,t,r,n)=>{var o;if(void 0===e&&(null===(o=n.leafFields)||void 0===o?void 0:o.length)){const e=ie(t,n.leafFields);if(void 0!==e.base){const t=e.base;return{base:n.coerceValue?n.coerceValue(t):t,extra:e.extra}}}return{base:se(e,r,n),extra:t}},le=(e,t,r,n)=>{const o=r.propertyPath?`${r.propertyPath}.variants.${e}`:`variants.${e}`,s=oe(t)?t:{base:t},{base:i,...a}=s,{base:l,extra:c}=ae(i,a,n,{...r,propertyPath:o});return{...c,base:l}},ce=(e,t={})=>{var r;const n=oe(e)?e:{base:e},{base:o,responsive:s,variants:i,modes:a,...l}=n,{base:c,extra:u}=ae(o,l,t.fallbackBase,t),d=i?Object.fromEntries(Object.entries(i).map(([e,r])=>[e,le(e,r,t,c)])):void 0,f=a?a.map(e=>((e,t)=>{const{mode:r,target:n,...o}=e,s=t.propertyPath?`${t.propertyPath}.modes.${r}`:`modes.${r}`;return{mode:r,...void 0!==n?{target:n}:{},...(()=>{var e;if((null===(e=t.leafFields)||void 0===e?void 0:e.length)&&!("base"in o)&&!te(o)){const{base:e,extra:r}=ie(o,t.leafFields);if(void 0!==e){const n={...r};return n.base=t.coerceValue?t.coerceValue(e):e,n}}if(te(o)){const{ref:e,modifiers:t,...r}=o,n={...r};return n.derive={...void 0!==e?{ref:e}:{},modifiers:re(t,s)},n}const{base:r,...n}=o,i={...n};if(void 0!==r&&(i.base=Array.isArray(r)||!t.coerceValue?r:t.coerceValue(r)),void 0===i.base&&!i.derive&&!Object.keys(n).length)throw new w("REFRACT_E_MODE",`Appearance mode "${s}" overrides nothing.`);return i})()}})(e,t)):void 0,p={propertyPath:t.propertyPath,allowedBreakpoints:t.allowedBreakpoints},m=(g=p,(null==(h=s)?void 0:h.length)?h.map(e=>{if(!e.breakpoint)throw new w("REFRACT_E_BREAKPOINT",`Responsive entry${Z(g)} is missing a "breakpoint" value.`);if((null==g?void 0:g.allowedBreakpoints)&&!Q(e.breakpoint,g.allowedBreakpoints))throw new w("REFRACT_E_BREAKPOINT",`Responsive entry${Z(g)} references unknown breakpoint "${e.breakpoint}".`);if(e.ref&&!Q(e.ref,null==g?void 0:g.allowedVariants))throw new w("REFRACT_E_RESPONSIVE",`Responsive entry${Z(g)} references unknown variant "${e.ref}" (ref).`);if(e.target&&!Q(e.target,null==g?void 0:g.allowedTargets))throw new w("REFRACT_E_RESPONSIVE",`Responsive entry${Z(g)} references unknown target "${e.target}".`);const{query:t,...r}=e;return{...r,query:null!=t?t:"exact"}}):[]);var h,g;const b=(null===(r=t.leafFields)||void 0===r?void 0:r.length)?m.map(e=>((e,t)=>{const r={},n={};let o;for(const[t,s]of Object.entries(e))ne.has(t)?r[t]=s:"base"===t?o=s:n[t]=s;const s=t.leafFields.some(e=>e in n);if(void 0===o&&!s)return e;const{base:i,extra:a}=ae(o,n,void 0,t);return{...r,...a,base:i}})(e,t)):m;return{...u,base:c,responsive:b,variants:d,modes:f}},ue=["orientation","height","aspectRatio"],de=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e)),fe=e=>e?` for "${e}"`:"",pe="responsive",me="states",he="css",ge="variants",be=e=>Array.isArray(e)?e:e&&"object"==typeof e?Object.entries(e).map(([e,t])=>({state:e,...t})):[],ve=e=>{var t;return`${e.state}\0${null!==(t=e.target)&&void 0!==t?t:""}`},ye=(e,t)=>{const r=be(e).map(e=>({...e})),n=new Map(r.map((e,t)=>[ve(e),t]));for(const e of be(t)){const t=ve(e),o=n.get(t);void 0!==o?r[o]={...r[o],...e}:(n.set(t,r.length),r.push({...e}))}return r},we=(e,t)=>{var r,n;const o={...e};for(const[s,i]of Object.entries(t))null!==i?s===pe?o[pe]=[...null!==(r=e[pe])&&void 0!==r?r:[],...i]:s===me?o[me]=ye(e[me],i):s===he?o[he]={...null!==(n=e[he])&&void 0!==n?n:{},...i}:o[s]=i:delete o[s];return o},$e=(e,t={})=>{const r=((e,t)=>{if(!Object.values(e).some(e=>null!=e&&"object"==typeof e&&null!=e[ge]))return e;const r={},n=(e,n)=>{if(e in r)throw new w("REFRACT_E_VARIANT",`Recipe variant expansion${fe(t)} produced a duplicate recipe name "${e}" — a desugared "<recipe>-<variant>" collides with an existing sibling recipe.`);r[e]=n};for(const[t,r]of Object.entries(e)){const{[ge]:e,...o}=r;if(n(t,o),null!=e){const r=null!=o[me]?{...o,[me]:be(o[me]).filter(e=>!e.target)}:o;for(const[o,s]of Object.entries(e))n(`${t}-${o}`,we(r,s))}}return r})(e,t.propertyPath),n=Object.keys(r),o=n.length?new Set(n):void 0,s={};return n.forEach(e=>{var n;const i=r[e];s[e]=ke(`${null!==(n=t.propertyPath)&&void 0!==n?n:"recipes"}.${e}`,i,{allowedBreakpoints:t.allowedBreakpoints,allowedStates:t.allowedStates,allowedTargets:o,allowedVariants:o,allowedContainers:t.allowedContainers,recipeName:e})}),s},ke=(e,t,r)=>{const{responsive:n,states:o,...s}=t;return{base:s,responsive:[...xe(o,e,r),...je(n,e,r)]}},xe=(e,t,r)=>be(e).map(e=>{const{state:n,...o}=e;if(r.allowedStates&&!de(n,r.allowedStates))throw new w("REFRACT_E_STATE",`Recipe state entry${fe(t)} references unknown state "${n}".`);if(o.target&&r.allowedTargets){const e=r.recipeName?`${r.recipeName}-${o.target}`:o.target;if(!de(e,r.allowedTargets))throw new w("REFRACT_E_RESPONSIVE",`Recipe state entry${fe(t)} references unknown target "${o.target}".`)}return{...o,state:n}}),je=(e,t,r)=>(null==e?void 0:e.length)?e.map(e=>{var n;if(void 0!==e.variant&&void 0!==e.target)throw new w("REFRACT_E_RESPONSIVE",`Responsive entry${fe(t)} cannot set both "variant" and "target".`);if(void 0!==e.container)return Ae(e,t,r);if(!e.breakpoint)throw new w("REFRACT_E_BREAKPOINT",`Responsive recipe entry${fe(t)} is missing a "breakpoint" value.`);if(r.allowedBreakpoints&&!de(e.breakpoint,r.allowedBreakpoints))throw new w("REFRACT_E_BREAKPOINT",`Responsive recipe entry${fe(t)} references unknown breakpoint "${e.breakpoint}".`);if(e.state&&r.allowedStates&&!de(e.state,r.allowedStates))throw new w("REFRACT_E_STATE",`Responsive recipe entry${fe(t)} references unknown state "${e.state}".`);if(e.variant&&!de(e.variant,r.allowedVariants))throw new w("REFRACT_E_RESPONSIVE",`Responsive recipe entry${fe(t)} references unknown variant "${e.variant}".`);if(e.target&&!de(e.target,r.allowedTargets))throw new w("REFRACT_E_RESPONSIVE",`Responsive recipe entry${fe(t)} references unknown target "${e.target}".`);return{...e,query:null!==(n=e.query)&&void 0!==n?n:"exact"}}):[],Ae=(e,t,r)=>{var n,o;const s=e.container;for(const r of ue)if(void 0!==e[r])throw new w("REFRACT_E_CONTAINER",`Container recipe entry${fe(t)} cannot use "${r}" — container queries respond to a container's inline size, not orientation/height/aspect-ratio.`);const i=null===(n=r.allowedContainers)||void 0===n?void 0:n.get(s);if(r.allowedContainers&&!i)throw new w("REFRACT_E_CONTAINER",`Container recipe entry${fe(t)} references unknown container "${s}".`);if(void 0===e.size)throw new w("REFRACT_E_CONTAINER",`Container recipe entry${fe(t)} for container "${s}" is missing a "size" value.`);if(i&&!i.has(e.size))throw new w("REFRACT_E_CONTAINER",`Container recipe entry${fe(t)} references unknown size "${e.size}" on container "${s}".`);return{...e,query:null!==(o=e.query)&&void 0!==o?o:"min"}},Se=(e,t,r={})=>{var n;const o=new Map,s=[],i=null!==(n=r.groupPath)&&void 0!==n?n:"recipes",a=r=>{if(o.has(r))return o.get(r);if(s.includes(r)){const e=[...s,r].join(" -> ");throw new w("REFRACT_E_CYCLE",`Cyclic recipe reference in "${i}": ${e}`)}const n=e[r];if(!n)throw new w("REFRACT_E_REFERENCE",`Recipe variant "${r}" is not defined in "${i}".`);s.push(r);try{const e=t(r,n,a);return o.set(r,e),e}finally{s.pop()}};return{resolve:a,resolveAll:()=>{const t={};for(const r of Object.keys(e))t[r]=a(r);return t}}},Ee=(e,t,r,n=new Map,o=new Set)=>{const s=n.get(r);if(void 0!==s)return s;const i=e[r];if(!i)throw new w("REFRACT_E_TOKEN_PATH",`Unknown token path "${r}".`);if(void 0!==i.external){const e=`var(${i.external})`;return n.set(r,e),e}if(void 0===i.ref){if(void 0===i.value)throw new w("REFRACT_E_TOKEN_PATH",`Token "${r}" has neither "ref" nor "value".`);return n.set(r,i.value),i.value}if(o.has(r))throw new w("REFRACT_E_CYCLE",`Cyclic token reference: ${[...o,r].join(" -> ")}`);o.add(r);const a=Ee(e,t,i.ref,n,o);let l;if(void 0!==i.modifiers)l=i.modifiers.reduce((e,n)=>{const o=t[n.fn];if(!o)throw new w("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${n.fn}" for token "${r}".`);return o(e,n.arg)},a);else if(void 0!==i.fn){const e=t[i.fn];if(!e)throw new w("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${i.fn}" for token "${r}".`);l=e(a,i.arg)}else l=a;return o.delete(r),n.set(r,l),l},Re=(e,t)=>!!(null==e?void 0:e.ref)&&((void 0!==e.modifiers||void 0!==e.fn)&&(e=>{const[t,r]=e.split(".");return`${t}.${r}`})(e.ref)!==t),Ce=(e,t,r,n,o)=>{let s;try{s=Ee(t,r,e.ref,n)}catch{throw new w("REFRACT_E_VALIDATION",`${o}: cross-property derivation references unknown token '${e.ref}'.`)}const i=(e,t)=>{const n=r[e];if(!n)throw new w("REFRACT_E_VALIDATION",`${o}: unknown derivation fn '${e}'.`);return n(s,t)};if(void 0!==e.modifiers)for(const t of e.modifiers)s=i(t.fn,t.arg);else void 0!==e.fn&&(s=i(e.fn,e.arg));return{...e,value:s}},Oe=(e,t,r,n,o,s)=>{let i;for(const[a,l]of Object.entries(e))Re(l,t)&&(i=null!=i?i:{...e},i[a]=Ce(l,r,n,o,`${s}.${a}`));return i},Te=(e,t,r,n,o)=>{const s=e.variants?((e,t,r,n,o)=>{let s;for(const[i,a]of Object.entries(e)){const l=`${t}.variants.${i}`,c=Re(a.base,t)?Ce(a.base,r,n,o,l):a.base,u=a.extras?Oe(a.extras,t,r,n,o,`${l} extra`):void 0;(c!==a.base||u)&&(s=null!=s?s:{...e},s[i]=u?{base:c,extras:u}:{...a,base:c})}return s})(e.variants,t,r,n,o):void 0;let i;if(e.modes)for(let s=0;s<e.modes.length;s++){const a=e.modes[s];if(!a.overrides)continue;const l=Oe(a.overrides,t,r,n,o,`${t}.modes.${a.mode}`);l&&(i=null!=i?i:[...e.modes],i[s]={...a,overrides:l})}if(!s&&!i)return;const a={...e};return s&&(a.variants=s),i&&(a.modes=i),a},Fe=(e,t)=>{var r;const n=M(e),o=new Map;let s=!1;const i={};for(const[a,l]of Object.entries(e.subsystems)){let e,c=!1;for(const[s,i]of Object.entries(null!==(r=l.properties)&&void 0!==r?r:{})){const r=Te(i,`${a}.${s}`,n,t,o);r&&(e=null!=e?e:{...l.properties},e[s]=r,c=!0)}c?(i[a]={...l,properties:e},s=!0):i[a]=l}return s?{...e,subsystems:i}:e},_e=["min","max","exact","between"],Ne=e=>void 0===e?void 0:e-.02,Pe=(e,t)=>{const r=(e=>Object.keys(e).sort((t,r)=>e[t]-e[r]))(e);(e=>{const t=e.filter(e=>_e.includes(e));if(t.length)throw new w("REFRACT_E_BREAKPOINT",`Breakpoint names conflict with reserved keys: ${t.map(e=>`"${e}"`).join(", ")}. Reserved: ${_e.map(e=>`"${e}"`).join(", ")}.`)})(r);const n=e=>r[r.indexOf(e)+1],o=r.reduce((r,o)=>{const s=e[o],i=n(o),a=void 0!==i?e[i]:void 0;return r[o]=ze({own:s,next:a},t),r},{}),s=e=>{const t=o[e];if(!t)throw new w("REFRACT_E_BREAKPOINT",`Breakpoint "${e}" is not defined.`);return t};return{...o,min:(r,n)=>{const o=s(r);return n?t({min:e[r],...n}):o.min},max:(r,o)=>{const i=s(r);if(!o)return i.max;const a=n(r),l=void 0!==a?e[a]:void 0;return t({max:Ne(l),...o})},exact:(r,o)=>{const i=s(r);if(!o)return i.exact;const a=n(r),l=void 0!==a?e[a]:void 0;return t({min:e[r],max:Ne(l),...o})},between:(r,n,o)=>{const s=e[r],i=e[n];if(void 0===s||void 0===i)throw new w("REFRACT_E_BREAKPOINT",`Cannot build media query between "${r}" and "${n}" breakpoints.`);return t({min:s,max:i-.02,...o})}}},ze=({own:e,next:t},r)=>{const n=Ne(t);return{min:r({min:e}),max:void 0===n?"":r({max:n}),exact:r({min:e,max:n})}},Me="px",Le=16,qe=e=>{var t;return{unit:null!==(t=null==e?void 0:e.unit)&&void 0!==t?t:Me,baseFontSize:(null==e?void 0:e.baseFontSize)&&e.baseFontSize>0?e.baseFontSize:Le}},Ie=(e,t)=>{if("px"===t.unit)return`${e}px`;const r=e/t.baseFontSize;return`${Number(r.toFixed(4))}${t.unit}`},Be=({min:e,max:t,orientation:r},n)=>{const o=[];if(void 0!==e&&void 0!==t&&e>t)throw new w("REFRACT_E_MEDIA","Invalid media query: `min` cannot be greater than `max`.");return void 0!==e&&o.push(`(min-width: ${Ie(e,n)})`),void 0!==t&&o.push(`(max-width: ${Ie(t,n)})`),r&&o.push(`(orientation: ${r})`),o.length?`@media ${o.join(" and ")}`:""},Ue=(e,{min:t,max:r},n)=>{const o=[];if(void 0!==t&&void 0!==r&&t>r)throw new w("REFRACT_E_MEDIA","Invalid container query: `min` cannot be greater than `max`.");return void 0!==t&&o.push(`(min-width: ${Ie(t,n)})`),void 0!==r&&o.push(`(max-width: ${Ie(r,n)})`),o.length?`@container ${e} ${o.join(" and ")}`:""},De={xs:0,sm:576,md:768,lg:992,xl:1280},Ve=(e,t)=>{const r=qe(t),n={};for(const[t,o]of Object.entries(null!=e?e:{}))n[t]=Pe(o.sizes,e=>Ue(t,{min:e.min,max:e.max},r));return n},We=new Set([3,6]),He=(e,t,r)=>Math.min(r,Math.max(t,e)),Ge=e=>He(e,0,255),Ye=e=>Math.round(1e3*He(e,0,1))/1e3,Je=e=>{const t=e.replace(/^\s*#|\s*$/g,"");if(!We.has(t.length))throw new Error(`Unsupported hex length: "${t}". Use 3 or 6 digits.`);const r=3===t.length?t.replace(/(.)/g,"$1$1"):t;return[parseInt(r.substring(0,2),16),parseInt(r.substring(2,4),16),parseInt(r.substring(4,6),16)]},Ke=e=>{if(3!==e.length)throw new Error(`Expected RGB tuple of length 3, received ${e.length}`);return`#${e.map(e=>{const t=Ge(Math.round(e)).toString(16);return 1===t.length?`0${t}`:t}).join("")}`},Xe=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/i,Ze=e=>{const t=e.trim(),r=Xe.exec(t);return r?{rgb:[Number(r[1]),Number(r[2]),Number(r[3])],a:void 0===r[4]?1:Ye(Number(r[4]))}:{rgb:Je(t),a:1}},Qe=(e,t=1)=>{const r=Ye(t),[n,o,s]=e,i=Ge(Math.round(n)),a=Ge(Math.round(o)),l=Ge(Math.round(s));return r>=1?`rgb(${i}, ${a}, ${l})`:`rgba(${i}, ${a}, ${l}, ${r})`},et=180/Math.PI,tt=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),rt=e=>e>=.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,nt=e=>{const[t,r,n]=e,o=((e,t,r)=>{const n=.4122214708*e+.5363325363*t+.0514459929*r,o=.2119034982*e+.6806995451*t+.1073969566*r,s=.0883024619*e+.2817188376*t+.6299787005*r,i=Math.cbrt(n),a=Math.cbrt(o),l=Math.cbrt(s);return{L:.2104542553*i+.793617785*a-.0040720468*l,a:1.9779984951*i-2.428592205*a+.4505937099*l,b:.0259040371*i+.7827717662*a-.808675766*l}})(tt(t/255),tt(r/255),tt(n/255)),s=Math.sqrt(o.a*o.a+o.b*o.b);let i=Math.atan2(o.b,o.a)*et;return i<0&&(i+=360),{L:100*o.L,C:s,h:i}},ot=e=>{const t=He(e.L,0,100)/100,r=e.h/et,n=Math.cos(r),o=Math.sin(r),s=e=>((e,t,r)=>{const n=e+.3963377774*t+.2158037573*r,o=e-.1055613458*t-.0638541728*r,s=e-.0894841775*t-1.291485548*r,i=n*n*n,a=o*o*o,l=s*s*s;return[4.0767416621*i-3.3077115913*a+.2309699292*l,-1.2684380046*i+2.6097574011*a-.3413193965*l,-.0041960863*i-.7034186147*a+1.707614701*l]})(t,e*n,e*o),i=e=>e.every(e=>e>=-1e-6&&e<=1.000001);let a=s(e.C);if(!i(a)){let t=0,r=e.C;for(let e=0;e<24;e++){const e=(t+r)/2;i(s(e))?t=e:r=e}a=s(t)}return[255*rt(He(a[0],0,1)),255*rt(He(a[1],0,1)),255*rt(He(a[2],0,1))]},st=(e,t)=>{const{rgb:r,a:n}=Ze(e);return Qe(ot(t(nt(r))),n)},it=(e,t)=>st(e,e=>({...e,L:He(e.L+t,0,100)})),at=(e,t)=>st(e,e=>({...e,L:He(e.L-t,0,100)})),lt=(e,t)=>st(e,e=>({...e,L:He(t,0,100)})),ct=(e,t)=>st(e,e=>({...e,h:((e.h+t)%360+360)%360})),ut=(e,t)=>st(e,e=>({L:void 0===t.l?e.L:He(t.l,0,100),C:void 0===t.c?e.C:Math.max(0,e.C*t.c),h:void 0===t.h?e.h:((e.h+t.h)%360+360)%360})),dt=e=>{const{rgb:t,a:r}=Ze(e),n=Ke(t);if(r>=1)return n;return`${n}${Ge(Math.round(255*r)).toString(16).padStart(2,"0")}`},ft=(e,t)=>{const{rgb:r}=Ze(e);return Qe(r,(e=>He(e,0,100))(t)/100)},pt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},mt=e=>Math.round(1e3*Math.min(1,Math.max(0,e)))/1e3,ht=(e,t,r)=>{const n=(e%360+360)%360/60,o=(1-Math.abs(2*Math.min(1,Math.max(0,r))-1))*Math.min(1,Math.max(0,t)),s=o*(1-Math.abs(n%2-1)),i=Math.min(1,Math.max(0,r))-o/2,[a,l,c]=n<1?[o,s,0]:n<2?[s,o,0]:n<3?[0,o,s]:n<4?[0,s,o]:n<5?[s,0,o]:[o,0,s];return[255*(a+i),255*(l+i),255*(c+i)]},gt=/^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*(?:\/\s*([\d.]+)(%?)\s*)?\)$/i,bt=/^hsla?\(\s*([\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[,/]\s*([\d.]+)(%?)\s*)?\)$/i,vt=e=>{if("string"==typeof e){const t=(e=>{const t=e.trim(),r=gt.exec(t);if(r){const e="%"===r[2]?Number(r[1]):100*Number(r[1]),t=void 0===r[5]?1:mt("%"===r[6]?Number(r[5])/100:Number(r[5]));return{rgb:ot({L:e,C:Number(r[3]),h:Number(r[4])}),a:t}}const n=bt.exec(t);if(n){const e=void 0===n[4]?1:mt("%"===n[5]?Number(n[4])/100:Number(n[4]));return{rgb:ht(Number(n[1]),Number(n[2])/100,Number(n[3])/100),a:e}}const o=pt[t.toLowerCase()];if(o)return{rgb:Je(o),a:1};try{return Ze(t)}catch{return null}})(e);if(!t)throw new w("REFRACT_E_COLOR_INPUT",`Invalid colour "${e}". Author a colour as a hex string ("#4dabf7"), an [r, g, b] tuple, or a CSS colour — oklch(), hsl()/hsla(), rgb()/rgba(), or a named keyword (e.g. "rebeccapurple"). A var(--…) can't be tonally derived at build time.`);return Qe(t.rgb,t.a)}if(!Array.isArray(e)||3!==e.length||e.some(e=>"number"!=typeof e))throw new w("REFRACT_E_COLOR_TUPLE",`Invalid colour tuple ${JSON.stringify(e)}. Use an [r, g, b] tuple with 0–255 channels (alpha comes from an \`alpha\` variant, not the base).`);const[t,r,n]=e;return Qe([t,r,n])},yt={lighten:(e,t)=>it(e,Number(t)),darken:(e,t)=>at(e,Number(t)),alpha:(e,t)=>ft(e,Number(t)),setL:(e,t)=>lt(e,Number(t)),rotateHue:(e,t)=>ct(e,Number(t)),adjust:(e,t)=>ut(e,t)},wt=["light","lighter"],$t=["dark","darker"],kt=(e,t)=>{if(!e||!e.includes("."))return!1;const[r,n]=e.split(".");return`${r}.${n}`!=`colors.${t}`},xt=(e,t)=>{try{return vt(e)}catch(e){throw new w("REFRACT_E_COLOR_INPUT",`colors.${t}.text — ${e.message}`)}},jt=(e,t,r={})=>{var n;const o=((e,t)=>{let r=t;if(void 0!==t.text&&(r={...r,text:xt(t.text,e)}),t.variants){let n=!1;const o={};for(const[r,s]of Object.entries(t.variants))void 0!==s.text?(o[r]={...s,text:xt(s.text,`${e}.variants.${r}`)},n=!0):o[r]=s;n&&(r={...r,variants:o})}if(t.modes){let n=!1;const o=t.modes.map(t=>void 0!==t.text?(n=!0,{...t,text:xt(t.text,`${e}.modes.${t.mode}`)}):t);n&&(r={...r,modes:o})}return r})(e,t),s=(e=>{try{return Ze(e),!0}catch{return!1}})(o.base),i=!(!o.steps||!o.steps.length),a=Object.keys(r).length>0,l=void 0!==o.harmony;if((i||a||l)&&!s)throw new w("REFRACT_E_STEPS",`colors.${e} declares derived steps/variants but its base "${o.base}" is not a hex or [r,g,b] colour.`);const c=s?Et(o,e):{},u=s?Ct(o,e):{},d=null!==(n=o.variants)&&void 0!==n?n:{},f={...c,...u,...d},p=Pt(e,o.base,f,r),m={...c,...u,...d,...p},h=St(o,e,m),g=At(o,e,m);return Object.keys(m).length||h||g?{...o,...Object.keys(m).length?{variants:m}:{},...h?{modes:h}:{},...g?{responsive:g}:{}}:o},At=(e,t,r)=>{const n=e.responsive;if(!n||!n.length)return;let o=!1;const s=n.map((e,n)=>{const s=e.ref,i=e.modifiers;if(!s||!Array.isArray(i)||!i.length){let t;for(const r of["base","text"]){const n=e[r];if("string"==typeof n||Array.isArray(n)){const o=vt(n);o!==n&&(t=null!=t?t:{...e},t[r]=o)}}return t&&(o=!0),null!=t?t:e}const a=r[s];if(!a)throw new w("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references unknown variant "${s}".`);if(void 0===a.base)throw new w("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references "${s}", a cross-property derivation — not supported.`);const l=Nt({modifiers:i},t,`responsive[${n}]`);let c=a.base;for(const e of l)c=yt[e.fn](c,e.arg);o=!0;const{ref:u,modifiers:d,...f}=e;return{...f,base:c,derive:{ref:`colors.${t}.${s}`,modifiers:l}}});return o?s:n},St=(e,t,r)=>{const n=e.modes;if(!n||!n.length)return;return n.map(n=>{var o;const s=n.mode,i=n.derive;if(!i)return n;const a=null!==(o=i.modifiers)&&void 0!==o?o:i.fn?[{fn:i.fn,arg:i.arg}]:[];if(kt(i.ref,t)){const{base:e,derive:t,...r}=n;return{...r,derive:{ref:i.ref,modifiers:a}}}const l=((n,o)=>{if(!n||n===`colors.${t}`)return{value:e.base,path:`colors.${t}`};const s=n.includes(".")?n.slice(`colors.${t}.`.length):n,i=r[s];if(!i||void 0===i.base)throw new w("REFRACT_E_VARIANT_REF",`colors.${t}.modes.${o} references unknown variant "${n}".`);return{value:i.base,path:`colors.${t}.${s}`}})(i.ref,s);let c=l.value;for(const e of a){const r=yt[e.fn];if(!r)throw new w("REFRACT_E_VARIANT_REF",`Unknown derivation fn "${e.fn}" for appearance mode "colors.${t}.modes.${s}".`);c=r(c,e.arg)}return{...n,base:c,derive:{ref:l.path,modifiers:a}}})},Et=(e,t)=>e.steps&&e.steps.length?_t(e,t):Tt(e,t),Rt={complement:[{name:"complement",deg:180}],analogous:[{name:"analogous1",deg:-30},{name:"analogous2",deg:30}],"split-complement":[{name:"split1",deg:150},{name:"split2",deg:210}],triadic:[{name:"triadic1",deg:120},{name:"triadic2",deg:240}],tetradic:[{name:"tetradic1",deg:90},{name:"complement",deg:180},{name:"tetradic2",deg:270}]},Ct=(e,t)=>{const r=e.harmony;if(void 0===r)return{};let n,o;if("string"==typeof r)n=r;else{if("object"!=typeof r||null===r||Array.isArray(r))throw new w("REFRACT_E_HARMONY",`colors.${t}.harmony must be a scheme name or a { scheme: [names] } object.`);{const e=Object.keys(r);if(1!==e.length)throw new w("REFRACT_E_HARMONY",`colors.${t}.harmony object form must name exactly one scheme; got [${e.join(", ")}].`);n=e[0],o=r[n]}}const s=Rt[n];if(!s)throw new w("REFRACT_E_HARMONY",`colors.${t}.harmony: unknown scheme "${n}". Use one of ${Object.keys(Rt).join(", ")}.`);const i={};return s.forEach((r,n)=>{var s;const a=null!==(s=null==o?void 0:o[n])&&void 0!==s?s:r.name;i[a]={base:ct(e.base,r.deg),derive:{ref:`colors.${t}`,fn:"rotateHue",arg:r.deg}}}),i},Ot=(e,t,r,n,o,s,i,a)=>{var l;const c=e=>e?`colors.${r}.${e}`:`colors.${r}`;let u,d=t.base;for(const t of o){if(void 0!==(null===(l=n[t])||void 0===l?void 0:l.base)){d=n[t].base,u=t;continue}const r=s(d,a);e[t]={base:r,derive:{ref:c(u),fn:i,arg:a}},d=r,u=t}},Tt=(e,t)=>{var r,n,o;const s=null!==(r=e.variants)&&void 0!==r?r:{},i={},a=null!==(n=e.lightenBy)&&void 0!==n?n:10,l=null!==(o=e.darkenBy)&&void 0!==o?o:10;return Ot(i,e,t,s,wt,it,"lighten",a),Ot(i,e,t,s,$t,at,"darken",l),i},Ft=e=>e<=0?100:e>=1e3?0:Math.min(98,Math.max(5,(1e3-e)/10)),_t=(e,t)=>{var r,n;const o=null!==(r=e.steps)&&void 0!==r?r:[],s=o.find(e=>"number"!=typeof e||isNaN(e)||e<0||e>1e3);if(void 0!==s)throw new w("REFRACT_E_STEPS",`colors.${t}.steps must be numbers in 0–1000 (e.g. [50, …, 950]); got ${JSON.stringify(s)}.`);const i=null!==(n=e.variants)&&void 0!==n?n:{},a={};for(const r of o){const n=r.toString();if(i[n])continue;const o=Ft(r);a[n]={base:lt(e.base,o),derive:{ref:`colors.${t}`,fn:"setL",arg:o}}}return a},Nt=(e,t,r)=>{const n=`colors.${t}.variants.${r}`,o=e.modifiers;if(!Array.isArray(o)||0===o.length)throw new w("REFRACT_E_VARIANT",`${n} needs a non-empty "modifiers" array (e.g. [{ darken: 10 }]).`);return o.map((e,o)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new w("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must be a single-key object like { darken: 10 }.`);const s=Object.keys(e);if(1!==s.length)throw new w("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must have exactly one fn key; got [${s.join(", ")}].`);const i=s[0];if(!yt[i])throw new w("REFRACT_E_VARIANT",`${n}.modifiers[${o}] unknown fn "${i}"; use ${Object.keys(yt).join(" / ")}.`);const a=e[i],l="adjust"===i?((e,t,r)=>{const n=`colors.${t}.variants.${r}.adjust`;if("object"!=typeof e||null===e||Array.isArray(e))throw new w("REFRACT_E_ADJUST",`${n} must be an object with numeric l / c / h dials.`);const{l:o,c:s,h:i}=e,a={};if(void 0!==o){if("number"!=typeof o||isNaN(o)||o<0||o>100)throw new w("REFRACT_E_ADJUST",`${n}.l must be an absolute OKLCH lightness in 0–100; got ${JSON.stringify(o)}.`);a.l=o}if(void 0!==s){if("number"!=typeof s||isNaN(s)||s<0)throw new w("REFRACT_E_ADJUST",`${n}.c must be a non-negative chroma multiplier (1 keeps, 0 greys); got ${JSON.stringify(s)}.`);a.c=s}if(void 0!==i){if("number"!=typeof i||isNaN(i))throw new w("REFRACT_E_ADJUST",`${n}.h must be a numeric hue rotation in degrees; got ${JSON.stringify(i)}.`);a.h=i}return a})(a,t,r):Number(a);return{fn:i,arg:l}})},Pt=(e,t,r,n)=>{const o={},s=new Set,i=(t,r)=>{if(void 0===t.base)throw new w("REFRACT_E_VARIANT_REF",`colors.${e} variant chains off "${r}", which is a cross-property derivation — not supported.`);return t.base};function a(l,c){if(o[l])return;if(s.has(l))throw new w("REFRACT_E_CYCLE",`Cyclic colour variant derivation at colors.${e}.${l}.`);s.add(l);const u=Nt(c,e,l);if(kt(c.ref,e))return o[l]={derive:{ref:c.ref,modifiers:u}},void s.delete(l);const d=(s=>{if(!s)return{value:t,path:`colors.${e}`};if(o[s])return{value:i(o[s],s),path:`colors.${e}.${s}`};if(r[s])return{value:i(r[s],s),path:`colors.${e}.${s}`};if(n[s])return a(s,n[s]),{value:i(o[s],s),path:`colors.${e}.${s}`};throw new w("REFRACT_E_VARIANT_REF",`colors.${e} variant references unknown source "${s}".`)})(c.ref);let f=d.value;for(const e of u)f=yt[e.fn](f,e.arg);o[l]={base:f,derive:{ref:d.path,modifiers:u}},s.delete(l)}for(const[e,t]of Object.entries(n))a(e,t);return o},zt=new Set("display position top right bottom left inset inset-block inset-block-start inset-block-end inset-inline inset-inline-start inset-inline-end float clear z-index visibility overflow overflow-x overflow-y overflow-block overflow-inline overflow-clip-margin overflow-anchor box-sizing width height min-width min-height max-width max-height block-size inline-size min-block-size min-inline-size max-block-size max-inline-size aspect-ratio margin margin-top margin-right margin-bottom margin-left margin-block margin-block-start margin-block-end margin-inline margin-inline-start margin-inline-end margin-trim padding padding-top padding-right padding-bottom padding-left padding-block padding-block-start padding-block-end padding-inline padding-inline-start padding-inline-end flex flex-grow flex-shrink flex-basis flex-direction flex-flow flex-wrap order justify-content justify-items justify-self align-content align-items align-self place-content place-items place-self gap row-gap column-gap grid grid-area grid-template grid-template-areas grid-template-columns grid-template-rows grid-auto-columns grid-auto-rows grid-auto-flow grid-column grid-column-start grid-column-end grid-row grid-row-start grid-row-end columns column-count column-width column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-fill color opacity accent-color caret-color color-scheme forced-color-adjust print-color-adjust background background-color background-image background-position background-position-x background-position-y background-size background-repeat background-origin background-clip background-attachment background-blend-mode mix-blend-mode isolation border border-width border-style border-color border-top border-top-width border-top-style border-top-color border-right border-right-width border-right-style border-right-color border-bottom border-bottom-width border-bottom-style border-bottom-color border-left border-left-width border-left-style border-left-color border-block border-block-width border-block-style border-block-color border-block-start border-block-start-width border-block-start-style border-block-start-color border-block-end border-block-end-width border-block-end-style border-block-end-color border-inline border-inline-width border-inline-style border-inline-color border-inline-start border-inline-start-width border-inline-start-style border-inline-start-color border-inline-end border-inline-end-width border-inline-end-style border-inline-end-color border-radius border-top-left-radius border-top-right-radius border-bottom-right-radius border-bottom-left-radius border-start-start-radius border-start-end-radius border-end-start-radius border-end-end-radius border-image border-image-source border-image-slice border-image-width border-image-outset border-image-repeat border-collapse border-spacing outline outline-width outline-style outline-color outline-offset box-shadow filter backdrop-filter clip-path mask mask-image mask-mode mask-repeat mask-position mask-clip mask-origin mask-size mask-composite mask-type opacity transform transform-origin transform-box transform-style perspective perspective-origin backface-visibility rotate scale translate transition transition-property transition-duration transition-timing-function transition-delay transition-behavior animation animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction animation-fill-mode animation-play-state animation-composition animation-timeline will-change font font-family font-size font-size-adjust font-weight font-style font-variant font-variant-caps font-variant-numeric font-variant-ligatures font-variant-east-asian font-variant-alternates font-variant-position font-feature-settings font-variation-settings font-kerning font-stretch font-optical-sizing font-synthesis font-display line-height letter-spacing word-spacing text-align text-align-last text-decoration text-decoration-line text-decoration-color text-decoration-style text-decoration-thickness text-decoration-skip-ink text-underline-offset text-underline-position text-transform text-indent text-overflow text-shadow text-rendering text-wrap text-wrap-mode text-wrap-style text-emphasis text-emphasis-color text-emphasis-style text-emphasis-position text-orientation text-combine-upright text-justify white-space white-space-collapse word-break word-wrap overflow-wrap hyphens hyphenate-character line-break tab-size vertical-align writing-mode direction unicode-bidi quotes content list-style list-style-type list-style-position list-style-image counter-reset counter-increment counter-set cursor pointer-events user-select touch-action resize appearance caret scroll-behavior scroll-margin scroll-margin-top scroll-margin-right scroll-margin-bottom scroll-margin-left scroll-padding scroll-padding-top scroll-padding-right scroll-padding-bottom scroll-padding-left scroll-snap-type scroll-snap-align scroll-snap-stop overscroll-behavior overscroll-behavior-x overscroll-behavior-y scrollbar-width scrollbar-color scrollbar-gutter table-layout caption-side empty-cells vertical-align object-fit object-position image-rendering fill fill-opacity fill-rule stroke stroke-width stroke-opacity stroke-linecap stroke-linejoin stroke-dasharray stroke-dashoffset stroke-miterlimit paint-order shape-rendering stop-color flood-color lighting-color container container-type container-name contain content-visibility break-before break-after break-inside page-break-before page-break-after page-break-inside orphans widows all cx cy r rx ry d".split(" ")),Mt=/^-(webkit|moz|ms|o)-/,Lt=e=>{if(e.startsWith("--"))return!0;const t=e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return!!Mt.test(t)||zt.has(t)},qt=new Set(["breakpoint","query","state","variant","target","orientation"]),It=(e,t,r)=>{const n={};if(!e)return n;for(const[o,s]of Object.entries(e)){if(void 0===s||qt.has(o))continue;if(!Lt(o))throw new w("REFRACT_E_RECIPE_PROPERTY",`Unknown recipe property "${o}" in ${r} — expected a CSS property or a reserved key (variant, target, state, breakpoint, query, orientation, container, size).`);const e=Bt(s,t,r,o);void 0!==e&&(n[Ut(o)]=e)}return n},Bt=(e,t,r,n)=>{var o;if("number"==typeof e)return{value:e};const s=e.trim();if(!s)return;const i=s.split("."),a=i[0],l=t.properties[a];if(!l)return{value:s};const c=i.length>1?i.slice(1).join("."):void 0;if(!c)return{ref:`colors.${a}`};if("text"===c)return{ref:`colors.${a}.text`};if(!(null===(o=l.variants)||void 0===o?void 0:o[c]))throw new w("REFRACT_E_VARIANT_REF",`Unknown palette variant reference "${a}.${c}" in ${r}.${n}.`);return{ref:`colors.${a}.${c}`}},Ut=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Dt=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),Vt=([e,t,r])=>.2126*Dt(e/255)+.7152*Dt(t/255)+.0722*Dt(r/255),Wt={fail:0,"AA-large":1,AA:2,AAA:3},Ht=2.4,Gt=.2126729,Yt=.7151522,Jt=.072175,Kt=.56,Xt=.57,Zt=.62,Qt=.65,er=.022,tr=1.414,rr=1.14,nr=.027,or=1.14,sr=.027,ir=5e-4,ar=.1,lr=([e,t,r])=>Gt*Math.pow(e/255,Ht)+Yt*Math.pow(t/255,Ht)+Jt*Math.pow(r/255,Ht),cr=(e,t)=>{const r=e=>e>er?e:e+Math.pow(er-e,tr),n=r(lr(e)),o=r(lr(t));if(Math.abs(o-n)<ir)return 0;let s;if(o>n){const e=(Math.pow(o,Kt)-Math.pow(n,Xt))*rr;s=e<ar?0:e-nr}else{const e=(Math.pow(o,Qt)-Math.pow(n,Zt))*or;s=e>-ar?0:e+sr}return 100*s},ur=(e,t)=>{const r=10**t;return Math.round(e*r)/r},dr=(e,t)=>{if(void 0!==t.ref)try{return String(e.resolveToken(t.ref))}catch{return}if("string"==typeof t.value)return t.value},fr="color",pr=["background-color","background"],mr=e=>{if(e)for(const t of pr)if(e[t])return e[t]},hr=(e,t,r,n,o)=>{let s,i;try{void 0!==r&&(s=Ze(r).rgb)}catch{}try{void 0!==n&&(i=Ze(n).rgb)}catch{}if(!s||!i)return{kind:e,label:t,fg:r,bg:n,skipped:s||i?s?"bg not a colour":"fg not a colour":"no derivable fg/bg"};const a=((e,t)=>{const r=Vt(e),n=Vt(t);return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)})(s,i),l=((e,t)=>t?e>=4.5?"AAA":e>=3?"AA":"fail":e>=7?"AAA":e>=4.5?"AA":e>=3?"AA-large":"fail")(a,o.largeText),c=Wt[l]>=Wt[o.minWcag];return{kind:e,label:t,fg:r,bg:n,wcagRatio:ur(a,2),wcagLevel:l,apcaLc:ur(cr(s,i),1),pass:c}},gr=(e,t={})=>{var r,n,o,s,i,a,l,c,u,d,f;const p={largeText:null!==(r=t.largeText)&&void 0!==r&&r,minWcag:null!==(n=t.minWcag)&&void 0!==n?n:"AA"},m=null===(o=t.includeRecipes)||void 0===o||o,h=[];if(null===(s=t.includePalettes)||void 0===s||s)for(const t of Object.keys(e.tokens)){const r=/^colors\.([^.]+)\.text$/.exec(t);if(!r)continue;const n=`colors.${r[1]}`;let o,s;try{o=String(e.resolveToken(t))}catch{}try{s=String(e.resolveToken(n))}catch{}h.push(hr("palette",n,o,s,p))}if(m)for(const[t,r]of Object.entries(e.model.subsystems))if(r.ruleSets)for(const[n,o]of Object.entries(r.ruleSets))for(const[r,s]of Object.entries(o)){const o=s.declarations[fr],m=mr(s.declarations),g=`${t}.${n}.${r}`;o&&m&&h.push(hr("recipe",g,dr(e,o),dr(e,m),p));for(const t of null!==(i=s.overrides)&&void 0!==i?i:[]){const r=null!==(l=null===(a=t.declarations)||void 0===a?void 0:a[fr])&&void 0!==l?l:o,n=null!==(c=mr(t.declarations))&&void 0!==c?c:m;if(!t.declarations||!t.declarations[fr]&&!mr(t.declarations))continue;if(!r||!n)continue;const s=null!==(f=null!==(d=null!==(u=t.state)&&void 0!==u?u:t.breakpoint)&&void 0!==d?d:t.query)&&void 0!==f?f:"override";h.push(hr("recipe",`${g} (${s})`,dr(e,r),dr(e,n),p))}}const g=h.filter(e=>!e.skipped),b=g.filter(e=>!1===e.pass),v=g.reduce((e,t)=>{var r,n;return void 0===e||(null!==(r=t.wcagRatio)&&void 0!==r?r:1/0)<(null!==(n=e.wcagRatio)&&void 0!==n?n:1/0)?t:e},void 0),y={pairings:h,summary:{total:g.length,passed:g.length-b.length,failed:b.length,skipped:h.length-g.length,worst:v},ok:0===b.length};if(t.strict&&b.length>0){const e=b.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`).join(", ");throw new w("REFRACT_E_AUDIT",`refract audit: ${b.length} pairing(s) fail WCAG ${p.minWcag} — ${e}. Adjust the colour(s), lower --min-wcag, or drop --strict to report without failing.`,b.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`))}return y},br=new Set(["recipes"]),vr=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("base"in e)&&Array.isArray(e.modifiers),yr=e=>{if("object"!=typeof e||null===e||Array.isArray(e)||!e.variants)return{value:e,specs:{}};const t=e.variants,r={},n={};for(const[e,o]of Object.entries(t))vr(o)?r[e]=o:n[e]=o;if(!Object.keys(r).length)return{value:e,specs:r};const o=Object.keys(n).length?n:void 0;return{value:{...e,variants:o},specs:r}},wr={key:"colors",derivations:{lighten:(e,t)=>it(String(e),Number(t)),darken:(e,t)=>at(String(e),Number(t)),alpha:(e,t)=>ft(String(e),Number(t)),setL:(e,t)=>lt(String(e),Number(t)),rotateHue:(e,t)=>ct(String(e),Number(t)),adjust:(e,t)=>ut(String(e),t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(br.has(n))continue;const{value:e,specs:s}=yr(o),i=ce(e,{propertyPath:`colors.${n}`,allowedBreakpoints:t.allowedBreakpoints,coerceValue:vt}),a=jt(n,i,s);ee(a,{propertyPath:`colors.${n}`}),r[n]=a}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{const n=`${r.groupPath}.${e}`;return{base:It(t.base,r,n),responsive:t.responsive.map(e=>{const{breakpoint:t,query:o,state:s,variant:i,target:a,orientation:l,container:c,size:u,...d}=e,f={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...It(d,r,`${n}.responsive`)}};return t&&(f.breakpoint=t,f.query=null!=o?o:"exact"),c&&(f.container=c,u&&(f.size=u),f.query=null!=o?o:"min"),s&&(f.state=s),l&&(f.orientation=l),a&&(f.target=a),f})}})(e,t,r)},$r={"minor-second":1.067,"major-second":1.125,"minor-third":1.2,"major-third":1.25,"perfect-fourth":1.333,"augmented-fourth":1.414,"perfect-fifth":1.5,golden:1.618},kr={xs:-2,sm:-1,md:0,lg:1,xl:2,"2xl":3,"3xl":4,"4xl":5},xr=(e,t)=>"fontSize"!==e?t:jr(t),jr=e=>{var t,r,n,o;const s=e.ratio;if(!s)return e;const i=$r[s];if(!i)return e;const a=null!==(t=e.baseFontSize)&&void 0!==t?t:e.base,l=null!==(r=e.precision)&&void 0!==r?r:4,c=e.algorithm,u=null!==(n=e.variants)&&void 0!==n?n:{},d={};let f=null;for(const[e,t]of Object.entries(kr)){if(u[e]){f=null!==(o=u[e].base)&&void 0!==o?o:null;continue}let r;r=c?c(a,e,t,f):a*Math.pow(i,t);const n=Number(r.toFixed(l));f=n,d[e]={base:n}}return{...e,variants:{...d,...u}}},Ar=new Set(["breakpoint","query","state","variant","target","orientation"]),Sr={fontFamily:"font-family",fontSize:"font-size",fontWeight:"font-weight",lineHeight:"line-height",letterSpacing:"letter-spacing",fontStyle:"font-style",textTransform:"text-transform",textDecoration:"text-decoration",textAlign:"text-align"},Er=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||Ar.has(r))continue;const e=Sr[r];e&&(t[e]={ref:Rr(r,n)})}return t},Rr=(e,t)=>"base"===t?`typography.${e}`:`typography.${e}.${t}`,Cr=new Set(["recipes"]),Or={key:"typography",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Cr.has(n))continue;const e=ce(o,{propertyPath:`typography.${n}`,allowedBreakpoints:t.allowedBreakpoints}),s=xr(n,e);ee(s,{propertyPath:`typography.${n}`}),r[n]=s}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:Er(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:s,target:i,orientation:a,container:l,size:c,...u}=e,d={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...Er(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),i&&(d.target=i),a&&(d.orientation=a),d})}))(0,t,r)},Tr=["spacing","gutters","aspectRatio","sizes"],Fr=new Set(["spacing","gutters","sizes"]),_r=new Set(["spacing","gutters"]),Nr=["xs","sm","md","lg","xl","2xl","3xl","4xl"],Pr=e=>Number(e.toFixed(4)),zr=(e,t)=>{var r;if(!Fr.has(e))return t;const n=((e,t)=>{const r=t,n=void 0!==r.ratio,o=void 0!==r.step;if(!n&&!o)return;if(n&&o)throw new w("REFRACT_E_LAYOUT",`layout.${e}: declare only one of "ratio" (geometric) or "step" (linear) scale, not both.`);const s=r.steps;if(n){let t;if(void 0===s)t=Nr;else{if(!Array.isArray(s))throw new w("REFRACT_E_LAYOUT",`layout.${e}: a geometric scale ("ratio") needs "steps" as an ordered name array, e.g. ["sm","md","lg"].`);t=s.map(String)}const n=t.map((e,t)=>({name:e,exp:t}));return{curve:"geometric",ratio:Number(r.ratio),specs:n}}let i;if(void 0===s)i=Nr.map((e,t)=>({name:e,exp:t,mult:t+1}));else{if(Array.isArray(s)||"object"!=typeof s||null===s)throw new w("REFRACT_E_LAYOUT",`layout.${e}: a linear scale ("step") needs "steps" as a name→multiplier map, e.g. { sm:1, md:2, lg:3 }.`);i=Object.entries(s).map(([e,t],r)=>({name:e,exp:r,mult:Number(t)}))}return{curve:"linear",step:Number(r.step),specs:i}})(e,t);if(!n)return _r.has(e)?Mr(t):t;const o=((e,t,r)=>{const n=`layout.${e}`,o={};for(const e of r.specs)if("geometric"===r.curve){const s=Pr(Number(t)*Math.pow(r.ratio,e.exp));o[e.name]={base:s,derive:{ref:n,fn:"scaleStep",arg:{curve:"geometric",ratio:r.ratio,exp:e.exp}}}}else{const t=Pr(r.step*e.mult);o[e.name]={base:t,derive:{ref:n,fn:"scaleStep",arg:{curve:"linear",step:r.step,mult:e.mult}}}}return o})(e,t.base,n);let s={...o,...null!==(r=t.variants)&&void 0!==r?r:{}};_r.has(e)&&(s={...s,none:{base:0}});const i=((e,t,r,n)=>{if(!(null==r?void 0:r.length))return r;const o=`layout.${e}`,s=[];let i=!1;for(const a of r){const r=a;if(void 0===r.ratio&&void 0===r.step){s.push(r);continue}if(i=!0,void 0!==r.ratio&&void 0!==r.step)throw new w("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry may set only "ratio" or "step", not both.`);if(!n)throw new w("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry needs a base scale — declare a top-level "ratio"/"step" (+ "steps") first.`);const{breakpoint:l,query:c,orientation:u}=r,d=void 0!==r.ratio;for(const i of n.specs){let n,a;if(d){const e=Number(r.ratio),o=void 0!==r.base,s=Number(o?r.base:t);n=Pr(s*Math.pow(e,i.exp)),a={curve:"geometric",ratio:e,exp:i.exp,...o?{base:s}:{}}}else{if(void 0===i.mult)throw new w("REFRACT_E_LAYOUT",`layout.${e}: a linear responsive ramp ("step") requires a linear base scale (a name→multiplier "steps").`);const t=Number(r.step);n=Pr(t*i.mult),a={curve:"linear",step:t,mult:i.mult}}const f={breakpoint:l,query:c,target:i.name,base:n,derive:{ref:o,fn:"scaleStep",arg:a}};void 0!==u&&(f.orientation=u),s.push(f)}}return i?s:r})(e,t.base,t.responsive,n);return(e=>{const{ratio:t,step:r,steps:n,...o}=e;return o})({...t,variants:s,responsive:i})},Mr=e=>{var t;const r=null!==(t=e.variants)&&void 0!==t?t:{};return{...e,variants:{...r,none:{base:0}}}},Lr=new Set(["breakpoint","query","state","variant","target","orientation"]),qr={paddingY:["padding-top","padding-bottom"],paddingX:["padding-left","padding-right"],marginY:["margin-top","margin-bottom"],marginX:["margin-left","margin-right"],gap:["gap"],background:["background"],width:["width"],minWidth:["min-width"],maxWidth:["max-width"],height:["height"],minHeight:["min-height"],maxHeight:["max-height"]},Ir={paddingY:"spacing",paddingX:"spacing",marginY:"spacing",marginX:"spacing",gap:"spacing",width:"sizes",minWidth:"sizes",maxWidth:"sizes",height:"sizes",minHeight:"sizes",maxHeight:"sizes",background:"literal"},Br=(e,t)=>"base"===t?`layout.${e}`:`layout.${e}.${t}`,Ur=(e,t)=>{const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Lr.has(n))continue;if(!o)continue;const e=qr[n];if(!e)throw new w("REFRACT_E_LAYOUT",`Unknown layout recipe property "${n}" in ${t}. Known verbs: ${Object.keys(qr).join(", ")}. For arbitrary CSS use a component \`css\` delta.`);const s=Ir[n];for(const t of e)r[t]="literal"===s?{value:o}:{ref:Br(s,o)}}return r},Dr=e=>({ref:"base"===e?"layout.spacing":`layout.spacing.${e}`}),Vr=e=>({ref:"base"===e?"layout.gutters":`layout.gutters.${e}`}),Wr=e=>({ref:`layout.${e}`}),Hr=e=>({value:e}),Gr=e=>Object.keys(e).sort((t,r)=>e[t]-e[r]),Yr=[["templateColumns","grid-template-columns"],["templateRows","grid-template-rows"],["autoRows","grid-auto-rows"],["autoColumns","grid-auto-columns"],["justifyItems","justify-items"],["alignItems","align-items"],["justifyContent","justify-content"],["alignContent","align-content"]],Jr=(e,t)=>{const r={};t&&(r.display=Hr("grid"));for(const[t,n]of Yr){const o=e[t];o&&(r[n]=Hr(o))}return e.gap&&(r.gap=Dr(e.gap)),r},Kr=e=>{var t,r;if(!e||"string"==typeof e)return{mode:null!==(t=e)&&void 0!==t?t:"fixed"};const n=e;return{mode:null!==(r=n.base)&&void 0!==r?r:"fixed",inset:n.inset,gutter:n.gutter,direction:n.direction,align:n.align,justify:n.justify,maxWidth:n.maxWidth}},Xr=(e,t,r=new Set,n)=>{var o,s,i,a;const l=qe(n),c=e=>Ie(e,l),u={},d={},f=Gr(t),p=e&&"object"==typeof e?e:void 0,m=p?{mode:null!==(o=p.base)&&void 0!==o?o:"fixed",inset:p.inset,gutter:p.gutter,direction:p.direction,align:p.align,justify:p.justify,maxWidth:p.maxWidth}:Kr(null!=e?e:"fixed"),h=null!==(s=null==p?void 0:p.variants)&&void 0!==s?s:{},g=null!==(i=null==p?void 0:p.responsive)&&void 0!==i?i:[],b=e=>e?`container-${e}`:"container",v=(e,n)=>{var o,s,i,a,l,p,h,g,v;const y=e?`--${e}`:"",w=`container${y}--inset`,$=`container${y}--gutter`,k=null!==(s=null!==(o=n.inset)&&void 0!==o?o:m.inset)&&void 0!==s?s:"base",x=null!==(i=n.gutter)&&void 0!==i?i:m.gutter,j=null!==(l=null!==(a=n.mode)&&void 0!==a?a:m.mode)&&void 0!==l?l:"fixed",A=null!==(p=n.direction)&&void 0!==p?p:m.direction,S=null!==(h=n.align)&&void 0!==h?h:m.align,E=null!==(g=n.justify)&&void 0!==g?g:m.justify,R=null!==(v=n.maxWidth)&&void 0!==v?v:e?m.maxWidth:void 0;u[w]={base:Dr(k)},x&&(u[$]={base:Vr(x)});const C={"box-sizing":Hr("border-box"),width:Hr("100%"),"margin-left":Hr("auto"),"margin-right":Hr("auto"),"padding-left":Wr(w),"padding-right":Wr(w)};x&&(C.gap=Wr($)),A&&(C.display=Hr("flex"),C["flex-direction"]=Hr(A)),S&&(C["align-items"]=Hr(S)),E&&(C["justify-content"]=Hr(E));const O=[];if("fixed"===j){const e="string"==typeof R&&void 0!==t[R]?R:void 0,r=e?f.indexOf(e):-1;for(let n=0;n<f.length;n++){const o=f[n],s=t[r>=0&&n>r?e:o];0!==s?0===n?C["max-width"]=Hr(c(s)):O.push({breakpoint:o,query:"min",declarations:{"max-width":Hr(c(s))}}):0===n&&(C["max-width"]=Hr("none"))}}else"fluid"===j?void 0!==R&&(C["max-width"]=((e,t,r)=>{return"number"==typeof e?Hr(`${e}px`):t.has(e)?{ref:"base"===(n=e)?"layout.sizes":`layout.sizes.${n}`}:void 0!==r[e]?Hr(`${r[e]}px`):Hr(e);var n})(R,r,t)):C["max-width"]=Hr("number"==typeof j?`${j}px`:j);d[b(e)]={kind:"recipe",declarations:C,overrides:O}};v(null,m);for(const[e,t]of Object.entries(h))v(e,Kr(t));for(const e of g){const t=e.target,r=b(null!=t?t:null),n=d[r];if(!n)continue;const o={};if(e.direction&&(o["flex-direction"]=Hr(e.direction)),e.align&&(o["align-items"]=Hr(e.align)),e.justify&&(o["justify-content"]=Hr(e.justify)),e.inset){const e=t?`container--${t}--inset`:"container--inset";o["padding-left"]=Wr(e),o["padding-right"]=Wr(e)}if(e.gutter){const e=t?`container--${t}--gutter`:"container--gutter";o.gap=Wr(e)}Object.keys(o).length&&n.overrides.push({breakpoint:e.breakpoint,query:null!==(a=e.query)&&void 0!==a?a:"exact",declarations:o})}return{ruleSetGroups:{container:d},configProperties:u}},Zr=(e,t,r)=>{const n={},o={},s=e=>{e&&(Object.assign(n,e.ruleSetGroups),Object.assign(o,e.configProperties))};return s(((e,t)=>{var r,n;if(!e)return;const o="number"==typeof e?{size:e}:e,s=o.size,i=null!==(r=o.gutter)&&void 0!==r?r:"base",a=null!==(n=o.inset)&&void 0!==n?n:"none",l={"columns--size":{base:Hr(String(s))},"columns--gutter":{base:Vr(i)},"columns--inset":{base:Dr(a)}},c={},u=Array.from({length:s},(e,t)=>t+1);for(const e of Gr(t))for(const r of u){const n=`col-${e}-${r}`,o=`offset-${e}-${r}`,s={"grid-column-end":Hr(`span ${r}`)},i={"grid-column-start":Hr(String(r+1))};0===t[e]?(c[n]={kind:"utility",declarations:s,overrides:[]},c[o]={kind:"utility",declarations:i,overrides:[]}):(c[n]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:s}]},c[o]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:i}]})}return{ruleSetGroups:{columns:c},configProperties:l}})(e.columns,t)),s((e=>{var t,r;if(!e||!Object.keys(e).length)return;const n={};for(const[o,s]of Object.entries(e)){const e=Jr(s,!0),i=[];for(const e of null!==(t=s.responsive)&&void 0!==t?t:[]){const t=Jr(e,!1);Object.keys(t).length&&i.push({breakpoint:e.breakpoint,query:null!==(r=e.query)&&void 0!==r?r:"exact",declarations:t})}n[`grid-${o}`]={kind:"recipe",declarations:e,overrides:i}}return{ruleSetGroups:{grids:n},configProperties:{}}})(e.grids)),s((e=>{var t,r,n;if(!e||!Object.keys(e).length)return;const o={};for(const[s,i]of Object.entries(e)){const e={display:Hr(i.inline?"inline-flex":"flex"),"flex-direction":Hr(null!==(t=i.direction)&&void 0!==t?t:"column")};i.align&&(e["align-items"]=Hr(i.align)),i.justify&&(e["justify-content"]=Hr(i.justify)),i.wrap&&(e["flex-wrap"]=Hr(i.wrap)),i.gap&&(e.gap=Dr(i.gap));const a=[];for(const e of null!==(r=i.responsive)&&void 0!==r?r:[]){const t={};void 0!==e.inline&&(t.display=Hr(e.inline?"inline-flex":"flex")),e.direction&&(t["flex-direction"]=Hr(e.direction)),e.align&&(t["align-items"]=Hr(e.align)),e.justify&&(t["justify-content"]=Hr(e.justify)),e.wrap&&(t["flex-wrap"]=Hr(e.wrap)),Object.keys(t).length&&a.push({breakpoint:e.breakpoint,query:null!==(n=e.query)&&void 0!==n?n:"exact",declarations:t})}o[`stack-${s}`]={kind:"recipe",declarations:e,overrides:a}}return{ruleSetGroups:{stacks:o},configProperties:{}}})(e.stacks)),s(Xr(e.container,t,(e=>{const t=new Set;if(e&&"object"==typeof e&&!Array.isArray(e)){const r=e;"base"in r&&t.add("base");const n=r.variants;if(n&&"object"==typeof n)for(const e of Object.keys(n))t.add(e)}return t})(e.sizes),r)),{ruleSetGroups:n,configProperties:o}},Qr=new Set(Tr),en={key:"layout",derivations:{scaleStep:(e,t)=>((e,t)=>{const r=null!=t?t:{};if("linear"===r.curve)return Pr(Number(r.step)*Number(r.mult));const n=void 0!==r.base?Number(r.base):Number(e);return Pr(n*Math.pow(Number(r.ratio),Number(r.exp)))})(e,t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const n of Tr){const o=e[n];if(void 0===o||!Qr.has(n))continue;const s=ce(o,{propertyPath:`layout.${n}`,allowedBreakpoints:t.allowedBreakpoints}),i=zr(n,s);ee(i,{propertyPath:`layout.${n}`}),r[n]=i}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{var n;const o=`${null!==(n=r.groupPath)&&void 0!==n?n:"layout.recipes"}.${e}`;return{base:Ur(t.base,o),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:s,variant:i,target:a,orientation:l,container:c,size:u,...d}=e,f={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...Ur(d,o)}};return t&&(f.breakpoint=t,f.query=null!=n?n:"exact"),c&&(f.container=c,u&&(f.size=u),f.query=null!=n?n:"min"),s&&(f.state=s),a&&(f.target=a),l&&(f.orientation=l),f})}})(e,t,r),buildStructural:(e,t)=>Zr(e,t.breakpoints,t.mediaConfig)},tn=new Set(["breakpoint","query","state","variant","target","orientation"]),rn={boxShadow:"box-shadow",opacity:"opacity",blur:"filter",transition:"transition",zIndex:"z-index"},nn={boxShadow:"shadow",opacity:"opacity",blur:"blur",transition:"transitions",zIndex:"zIndex"},on=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||tn.has(r))continue;const e=rn[r],o=nn[r];if(!e||!o)continue;const s={ref:sn(o,n)};"blur"===r&&(s.wrap="blur"),t[e]=s}return t},sn=(e,t)=>"base"===t?`effects.${e}`:`effects.${e}.${t}`,an=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),ln=(e,t)=>{if(void 0!==e){if("number"!=typeof e||Number.isNaN(e))throw new w("REFRACT_E_EFFECTS",`${t} must be a number, received ${JSON.stringify(e)}.`);return e}},cn=(e,t)=>{if(void 0!==e){if("number"==typeof e){if(Number.isNaN(e))throw new w("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`);return e}if("string"==typeof e){const r=B(e);if("raw"in r)throw new w("REFRACT_E_EFFECTS",`${t} must be a number or a <number><unit> length (received ${JSON.stringify(e)}).`);return void 0===r.unit?r.value:{value:r.value,unit:r.unit}}throw new w("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`)}},un=new Set(["offsetX","offsetY","blur","spread","color","inset"]),dn=(e,t)=>{if(!an(e))throw new w("REFRACT_E_EFFECTS",`${t} must be a shadow-layer object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!un.has(r))throw new w("REFRACT_E_EFFECTS",`${t} has unknown shadow field "${r}" (allowed: ${[...un].join(", ")}).`);const r={},n=cn(e.offsetX,`${t}.offsetX`),o=cn(e.offsetY,`${t}.offsetY`),s=cn(e.blur,`${t}.blur`),i=cn(e.spread,`${t}.spread`);if(void 0!==n&&(r.offsetX=n),void 0!==o&&(r.offsetY=o),void 0!==s&&(r.blur=s),void 0!==i&&(r.spread=i),void 0!==e.color){if("string"!=typeof e.color||!e.color)throw new w("REFRACT_E_EFFECTS",`${t}.color must be a "colors.*" token-path string.`);r.color=e.color}if(void 0!==e.inset){if("boolean"!=typeof e.inset)throw new w("REFRACT_E_EFFECTS",`${t}.inset must be a boolean.`);e.inset&&(r.inset=!0)}return r},fn=new Set(["property","duration","timingFunction","delay"]),pn=(e,t)=>{if(!an(e))throw new w("REFRACT_E_EFFECTS",`${t} must be a transition-part object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!fn.has(r))throw new w("REFRACT_E_EFFECTS",`${t} has unknown transition field "${r}" (allowed: ${[...fn].join(", ")}).`);if("string"!=typeof e.property||!e.property)throw new w("REFRACT_E_EFFECTS",`${t}.property is required (the CSS property to transition).`);const r={property:e.property},n=ln(e.duration,`${t}.duration`),o=ln(e.delay,`${t}.delay`);if(void 0!==n&&(r.duration=n),void 0!==e.timingFunction){if("string"!=typeof e.timingFunction||!e.timingFunction)throw new w("REFRACT_E_EFFECTS",`${t}.timingFunction must be a keyword or cubic-bezier(...) string.`);r.timingFunction=e.timingFunction}return void 0!==o&&(r.delay=o),r},mn=new Set(["recipes"]),hn={shadow:["offsetX","offsetY","blur","spread","color","inset"],transitions:["property","duration","timingFunction","delay"]},gn=e=>"shadow"===e?t=>((e,t="effects.shadow")=>{if("string"==typeof e){if("none"===e)return"none";throw new w("REFRACT_E_EFFECTS",`${t} must be structured shadow layer(s) or "none" — raw CSS strings are not accepted (received ${JSON.stringify(e)}).`)}if(Array.isArray(e)){if(!e.length)throw new w("REFRACT_E_EFFECTS",`${t} is an empty shadow-layer array.`);return e.map((e,r)=>dn(e,`${t}[${r}]`))}return[dn(e,t)]})(t,`effects.${e}`):"transitions"===e?t=>((e,t="effects.transitions")=>{if("string"==typeof e){if("none"===e)return"none";throw new w("REFRACT_E_EFFECTS",`${t} must be structured transition part(s) or "none" — raw CSS strings are not accepted (received ${JSON.stringify(e)}).`)}if(Array.isArray(e)){if(!e.length)throw new w("REFRACT_E_EFFECTS",`${t} is an empty transition-part array.`);return e.map((e,r)=>pn(e,`${t}[${r}]`))}return[pn(e,t)]})(t,`effects.${e}`):void 0,bn={key:"effects",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(mn.has(n))continue;const e=hn[n],s=gn(n),i=ce(o,{propertyPath:`effects.${n}`,allowedBreakpoints:t.allowedBreakpoints,...e?{leafFields:e}:{},...s?{coerceValue:s}:{},...e?{fallbackBase:"none"}:{}});ee(i,{propertyPath:`effects.${n}`}),r[n]=i}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:on(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:s,target:i,orientation:a,container:l,size:c,...u}=e,d={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...on(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),i&&(d.target=i),a&&(d.orientation=a),d})}))(0,t,r)},vn=new Set(["breakpoint","query","state","variant","target","orientation","container","size"]),yn=new Set(["as","side"]),wn=new Set(["width","style","offset","radius","color"]),$n=(e,t,r)=>"radius"===r?"border-radius":"offset"===r?"outline-offset":"outline"===e?`outline-${r}`:t?`border-${t}-${r}`:`border-${r}`,kn=(e,t)=>"color"===e?{ref:t}:{ref:"base"===t?`borders.${e}`:`borders.${e}.${t}`},xn=(e,t,r)=>{const n={};if(!e)return n;for(const[o,s]of Object.entries(e))s&&!vn.has(o)&&!yn.has(o)&&wn.has(o)&&(n[$n(t,r,o)]=kn(o,s));return n},jn=new Set(["recipes"]),An={key:"borders",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(jn.has(n))continue;const e=ce(o,{propertyPath:`borders.${n}`,allowedBreakpoints:t.allowedBreakpoints});ee(e,{propertyPath:`borders.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{var n;const o=null!==(n=t.base.as)&&void 0!==n?n:"border",s=t.base.side,i=xn(t.base,o,s),a=t.responsive.map(e=>{var t,n;const{breakpoint:i,query:a,state:l,variant:c,target:u,orientation:d,container:f,size:p,as:m,side:h,...g}=e,b=null!==(t=m)&&void 0!==t?t:o,v=null!==(n=h)&&void 0!==n?n:s,y={declarations:{...c?{...r.resolveRecipeVariant(c).base}:{},...xn(g,b,v)}};return i&&(y.breakpoint=i,y.query=null!=a?a:"exact"),f&&(y.container=f,p&&(y.size=p),y.query=null!=a?a:"min"),l&&(y.state=l),d&&(y.orientation=d),u&&(y.target=u),y});return{base:i,responsive:a}})(0,t,r)},Sn=new Set(["breakpoint","query","state","variant","target","orientation"]),En={keyframes:"animation-name",duration:"animation-duration",easing:"animation-timing-function",delay:"animation-delay",iterationCount:"animation-iteration-count",direction:"animation-direction",fillMode:"animation-fill-mode",playState:"animation-play-state"},Rn={duration:"duration",easing:"easing",delay:"delay"},Cn=(e,t)=>"base"===t?`animation.${e}`:`animation.${e}.${t}`,On=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(void 0===n||""===n||Sn.has(r))continue;const e=En[r];e&&(t[e]="keyframes"===r?{ref:`animation.keyframes.${n}`}:Rn[r]?{ref:Cn(Rn[r],String(n))}:{value:n})}return t},Tn=new Set(["keyframes","recipes"]),Fn=e=>e&&"object"==typeof e&&"ref"in e?{ref:String(e.ref)}:"string"==typeof e||"number"==typeof e?{value:e}:void 0,_n=e=>{const t={};for(const[r,n]of Object.entries(e)){const e=Fn(n);e&&(t[r]=e)}return t},Nn=e=>{const t=[];for(const[r,n]of Object.entries(e))t.push({stop:r,declarations:_n(n)});return{steps:t}},Pn=e=>{if(!e||"object"!=typeof e)return{};const t={};for(const[r,n]of Object.entries(e))n&&"object"==typeof n&&(t[r]=Nn(n));return t},zn={key:"animation",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Tn.has(n))continue;const e=ce(o,{propertyPath:`animation.${n}`,allowedBreakpoints:t.allowedBreakpoints});ee(e,{propertyPath:`animation.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:On(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:s,target:i,orientation:a,container:l,size:c,...u}=e,d={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...On(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),i&&(d.target=i),a&&(d.orientation=a),d})}))(0,t,r),buildStructural:e=>({ruleSetGroups:{},configProperties:{},keyframes:Pn(e.keyframes)})},Mn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e))t[qn(r)]=Ln(n);return t},Ln=e=>"object"==typeof e?{ref:e.ref}:{value:e},qn=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),In={key:"components",normalizeProperties:()=>({}),interpretRecipe:(e,t,r)=>((e,t)=>({base:Mn(t.base.css),responsive:t.responsive.map(e=>{var t,r;const n=e,o={declarations:Mn(n.css)};return n.breakpoint&&(o.breakpoint=n.breakpoint,o.query=null!==(t=n.query)&&void 0!==t?t:"exact"),n.container&&(o.container=n.container,n.size&&(o.size=n.size),o.query=null!==(r=n.query)&&void 0!==r?r:"min"),n.state&&(o.state=n.state),n.orientation&&(o.orientation=n.orientation),n.target&&(o.target=n.target),o})}))(0,t),extractReferences:e=>(e=>{const t=[];for(const[r,n]of Object.entries(e))N.has(r)&&"string"==typeof n&&n.includes(".")&&t.push(`${r}:${n}`);return t})(e)},Bn=e=>({value:e}),Un=e=>({ref:e}),Dn=(e,t)=>({kind:"reset",selector:e,declarations:t,overrides:[]}),Vn=e=>{const t={};for(const[r,n,o]of e){const e={};for(const[t,r]of Object.entries(o))e[t]=Bn(r);t[r]=Dn(n,e)}return t},Wn=[["h1","4xl"],["h2","3xl"],["h3","2xl"],["h4","xl"],["h5","lg"],["h6","md"]],Hn={preflight:{static:[["box","*,::before,::after",{"box-sizing":"border-box","border-width":"0","border-style":"solid"}],["body","body",{margin:"0","line-height":"inherit"}],["headings","h1,h2,h3,h4,h5,h6",{"font-size":"inherit","font-weight":"inherit",margin:"0"}],["blocks","p,figure,blockquote,dl,dd",{margin:"0"}],["lists","ul,ol",{"list-style":"none",margin:"0",padding:"0"}],["media","img,picture,video,canvas,svg",{display:"block","max-width":"100%"}],["forms","button,input,select,textarea",{font:"inherit",color:"inherit"}],["anchors","a",{color:"inherit","text-decoration":"inherit"}]],headings:!0},normalize:{static:[["box","*,::before,::after",{"box-sizing":"border-box"}],["body","body",{margin:"0"}],["media","img,picture,video,canvas,svg",{"max-width":"100%"}]],headings:!1},reset:{static:[["box","*,::before,::after",{"box-sizing":"border-box"}],["all","*",{margin:"0",padding:"0",border:"0",font:"inherit","vertical-align":"baseline"}],["headings","h1,h2,h3,h4,h5,h6",{"font-size":"inherit","font-weight":"inherit"}],["lists","ul,ol",{"list-style":"none"}],["media","img,picture,video,canvas,svg",{display:"block","max-width":"100%"}]],headings:!0}},Gn=Object.keys(Hn),Yn=e=>{if(!1===e)return{};const t=Hn[e];if(!t)throw new w("REFRACT_E_PRESET",`globals: unknown preset "${e}" — expected one of ${Gn.join(", ")} or false`);const r={static:Vn(t.static)};return t.headings&&(r.defaults=(()=>{const e={};for(const[t,r]of Wn)e[t]=Dn(t,{"font-size":Un(`typography.fontSize.${r}`)});return e})()),r},Jn=new Set(["state","breakpoint","query","orientation","container","size","variant","target"]),Kn=e=>null!==e&&"object"==typeof e?{ref:e.ref}:{value:e},Xn=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Zn=e=>{const t={};for(const[r,n]of Object.entries(e))null==n||Jn.has(r)||(t[Xn(r)]=Kn(n));return t},Qn=e=>{const t={declarations:Zn(e)},r=e;for(const e of Jn)void 0!==r[e]&&(t[e]=r[e]);return t},eo=(e,t,r)=>(e=>({declarations:Zn(e.base),overrides:e.responsive.map(Qn)}))($e({[e]:t},r)[e]),to=(e,t)=>{const r=null!=e?e:{},n={};if(void 0!==r.preset){const e=Yn(r.preset);e.static&&(n.static=e.static),e.defaults&&(n.defaults=e.defaults)}const o=((e,t)=>{if(!e||!Object.keys(e).length)return;const r=Object.keys(t.breakpoints),n={};for(const[o,s]of Object.entries(e)){if(!s||"object"!=typeof s)continue;const e={propertyPath:`globals.elements.${o}`,allowedBreakpoints:r,allowedStates:t.allowedStates,allowedContainers:t.allowedContainers},{variants:i,...a}=s,l=eo(o,a,e),c={kind:"globals",selector:o,declarations:l.declarations,overrides:l.overrides};if(i&&"object"==typeof i&&Object.keys(i).length){const t={};for(const[r,n]of Object.entries(i))n&&"object"==typeof n&&(t[r]=eo(r,n,{...e,propertyPath:`${e.propertyPath}.variants.${r}`}));Object.keys(t).length&&(c.variants=t)}n[o]=c}return Object.keys(n).length?n:void 0})(r.elements,t);return o&&(n.elements=o),n},ro=[wr,Or,en,bn,An,zn,In,{key:"globals",normalizeProperties:()=>({}),buildStructural:(e,t)=>({ruleSetGroups:to(e,t),configProperties:{}})}];const no=(e,t)=>Pe(e,e=>Be(e,qe(t))),oo=e=>{var t;if(!e||"object"!=typeof e)return;const r={};for(const[n,o]of Object.entries(e))o&&"object"==typeof o&&o.sizes&&Object.keys(o.sizes).length&&(r[n]={type:null!==(t=o.type)&&void 0!==t?t:"inline-size",sizes:{...o.sizes}});return Object.keys(r).length?r:void 0},so=e=>{if(!e)return;const t=new Map;for(const[r,n]of Object.entries(e))t.set(r,new Set(Object.keys(n.sizes)));return t},io=(e,t)=>{if(e.startsWith("--"))return e;const r=e.split(".").join("-").toLowerCase();return t?`--${t}-${r}`:`--${r}`};function ao(e,t,r){const{clean:n,externals:o}=((e,t)=>{if(!e)return{clean:e,externals:{}};const r={},n={};for(const[o,s]of Object.entries(e))if(null===s||"object"!=typeof s||Array.isArray(s)||"string"!=typeof s.external)r[o]=s;else{const e=io(s.external,t);n[o]={base:`var(${e})`,external:e,responsive:[]}}return{clean:r,externals:n}})(t,r.extendsPrefix),s=e.normalizeProperties(n,{allowedBreakpoints:r.allowedBreakpoints});Object.assign(s,o);const i=r.inheritedProperties?{...r.inheritedProperties,...s}:s,a=function(e,t,r){var n,o;if(!e.interpretRecipe||!t||!Object.keys(t).length)return{};const s={};for(const[i,a]of Object.entries(t)){const t=`${e.key}.recipes.${i}`,l=$e(a,{propertyPath:t,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers}),c=Se(l,(n,o,s)=>e.interpretRecipe(n,o,{breakpoints:r.breakpoints,media:r.media,properties:r.properties,resolveRecipeVariant:s,groupPath:t}),{groupPath:t}).resolveAll(),u={};for(const[t,r]of Object.entries(c))if(e.extractReferences){const s=e.extractReferences(null!==(o=null===(n=l[t])||void 0===n?void 0:n.base)&&void 0!==o?o:{});u[t]=_(r,s)}else u[t]=F(r);s[i]=u}return s}(e,null==t?void 0:t.recipes,{breakpoints:r.breakpoints,media:r.media,properties:i,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});let l,c,u=a;if(e.buildStructural&&t){const n=e.buildStructural(t,{breakpoints:r.breakpoints,media:r.media,mediaConfig:r.mediaConfig,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});u={...n.ruleSetGroups,...a},Object.keys(n.configProperties).length&&(l=n.configProperties),n.keyframes&&Object.keys(n.keyframes).length&&(c=n.keyframes)}const d={};return Object.keys(s).length&&(d.properties=s),Object.keys(u).length&&(d.ruleSetGroups=u),l&&(d.extraProperties=l),c&&(d.keyframes=c),d}function lo(e){const t={};if(!(null==e?void 0:e.properties))return t;for(const[r,n]of Object.entries(e.properties)){const e={base:n.base.value};if(n.variants&&Object.keys(n.variants).length){const t={};for(const[e,r]of Object.entries(n.variants)){const n={base:r.base.value};if(r.extras)for(const[e,t]of Object.entries(r.extras))n[e]=t.value;t[e]=n}e.variants=t}if(n.extras)for(const[t,r]of Object.entries(n.extras))e[t]=r.value;t[r]=e}return t}function co(e,t){var r,n,o,s,i;if(!e)return t;const a={...e};if(t.properties&&(a.properties={...null!==(r=e.properties)&&void 0!==r?r:{},...t.properties}),t.ruleSets){const r={...null!==(n=e.ruleSets)&&void 0!==n?n:{}};for(const[n,i]of Object.entries(t.ruleSets))r[n]={...null!==(s=null===(o=e.ruleSets)||void 0===o?void 0:o[n])&&void 0!==s?s:{},...i};a.ruleSets=r}return t.keyframes&&(a.keyframes={...null!==(i=e.keyframes)&&void 0!==i?i:{},...t.keyframes}),a}function uo(e,t){var r,n,o,s;const{adapter:i}=t,a=e,l=null!==(r=a.breakpoints)&&void 0!==r?r:De,c=Object.keys(l),u=null!==(o=null===(n=a.extends)||void 0===n?void 0:n.prefix)&&void 0!==o?o:"dt",d=i.allowedStates,f=new Set(null!==(s=a.modes)&&void 0!==s?s:["dark","light"]),p=t.media,m=no(l,p),h=oo(a.containers),g=so(h),b={};for(const e of ro){const t=ao(e,a[e.key],{breakpoints:l,extendsPrefix:u,media:m,mediaConfig:p,allowedBreakpoints:c,allowedStates:d,allowedContainers:g});Object.keys(t).length&&(b[e.key]=t)}const v=(e=>{var t;const r={},n=z(e.colors);n&&(r.colors=n);const o=z(e.typography);o&&(r.typography=o);const s=z(e.layout);s&&(r.layout=s);const i=z(e.effects);i&&(r.effects=i);const a=z(e.borders);a&&(r.borders=a);const l=z(e.animation);l&&(r.animation=l),P(null===(t=e.components)||void 0===t?void 0:t.ruleSetGroups)&&(r.components={ruleSets:e.components.ruleSetGroups});const c=z(e.globals);c&&(r.globals=c);const u={breakpoints:e.breakpoints,subsystems:r};return e.containers&&Object.keys(e.containers).length&&(u.containers=e.containers),u})({breakpoints:l,containers:h,...b}),y={units:t.units,baseFontSize:t.baseFontSize},$=function(e,t){var r;const{propertiesOverlay:n,ruleSetsOverlay:o,keyframesOverlay:s,containersOverlay:i}=t;if(!(n||o||s||i))return e;const a={...e.subsystems},l=new Set([...Object.keys(null!=n?n:{}),...Object.keys(null!=o?o:{}),...Object.keys(null!=s?s:{})]);for(const e of l)a[e]=co(a[e],{properties:null==n?void 0:n[e],ruleSets:null==o?void 0:o[e],keyframes:null==s?void 0:s[e]});const c={...e,subsystems:a};return i&&(c.containers={...null!==(r=e.containers)&&void 0!==r?r:{},...i}),c}(X(v,y),t),k=(e=>{const t={};for(const r of e)for(const[e,n]of Object.entries(r)){if(e in t)throw new w("REFRACT_E_TOKEN_PATH",`Duplicate derivation fn "${e}" registered by two subsystems.`);t[e]=n}return t})(ro.flatMap(e=>e.derivations?[e.derivations]:[])),x=Fe($,k),j=[...po(x),...mo(x),...ho(x),...fo(x,f)];if(j.length>0){const e=j.map(e=>` - ${e}`).join("\n");throw new w("REFRACT_E_VALIDATION",`refract: ${j.length} validation error(s):\n${e}`,j)}return go(x,{adapter:i,derivationRegistry:k,allowedStates:d,mediaConfig:p,unitConfig:y})}function fo(e,t){var r,n,o;const s=[],i=(e,r,n,o)=>{t.has(n)||s.push(`${e}.${r}${o}: unknown appearance mode '${n}' — declare it in the top-level 'modes' registry (known: ${[...t].join(", ")})`)};for(const[t,s]of Object.entries(e.subsystems))for(const[e,a]of Object.entries(null!==(r=s.properties)&&void 0!==r?r:{})){for(const r of null!==(n=a.modes)&&void 0!==n?n:[])r.mode&&i(t,e,r.mode,"");for(const r of null!==(o=a.responsive)&&void 0!==o?o:[])r.mode&&i(t,e,r.mode," (responsive)")}return s}function po(e){var t,r,n,o,s;const i=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!i)return[];const a=[];for(const[t,l]of Object.entries(i))for(const[i,c]of Object.entries(l))for(const l of null!==(r=c.references)&&void 0!==r?r:[]){const[r,c=""]=l.split(":"),u=c.indexOf("."),d=u>=0?c.slice(0,u):c,f=u>=0?c.slice(u+1):"";(null===(s=null===(o=null===(n=e.subsystems[r])||void 0===n?void 0:n.ruleSets)||void 0===o?void 0:o[d])||void 0===s?void 0:s[f])||a.push(`components.${t}.${i}: Recipe variant "${f}" is not defined in "${r}:${d}". Check the subsystem:group.variant reference against what the subsystem declares.`)}return a}function mo(e){var t,r;const n=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!n)return[];const o=M(e),s=[],i=(e,t,r,n)=>{for(const[i,a]of Object.entries(null!=e?e:{}))void 0===a.ref||a.ref in o||s.push(`components.${t}.${r}: css '${i}'${n} references unknown token '${a.ref}' — check the token path, or use a bare string / number for a raw CSS value`)};for(const[e,t]of Object.entries(n))for(const[n,o]of Object.entries(t)){i(o.declarations,e,n,"");for(const t of null!==(r=o.overrides)&&void 0!==r?r:[])i(t.declarations,e,n," (override)")}return s}function ho(e){var t,r,n,o,s;const i=null===(t=e.subsystems.globals)||void 0===t?void 0:t.ruleSets;if(!i)return[];const a=M(e),l=[],c=(e,t,r)=>{for(const[n,o]of Object.entries(null!=e?e:{}))void 0===o.ref||o.ref in a||l.push(`globals element '${t}'${r}: '${n}' references unknown token '${o.ref}' — check the token path, or use a bare string / number for a raw CSS value`)};for(const e of Object.values(i))for(const t of Object.values(e)){if("globals"!==t.kind)continue;const e=null!==(r=t.selector)&&void 0!==r?r:"";c(t.declarations,e,"");for(const r of null!==(n=t.overrides)&&void 0!==n?n:[])c(r.declarations,e," (override)");for(const[r,n]of Object.entries(null!==(o=t.variants)&&void 0!==o?o:{})){const t=` (variant '${r}')`;c(n.declarations,e,t);for(const r of null!==(s=n.overrides)&&void 0!==s?s:[])c(r.declarations,e,`${t} (override)`)}}return l}function go(e,t){var r;const n=no(e.breakpoints,t.mediaConfig),o=Ve(e.containers,t.mediaConfig),s=new WeakMap,i=()=>{let t=s.get(e);return t||(t=M(e),s.set(e,t)),t},a=e=>Ee(i(),t.derivationRegistry,e),l={media:n,containers:o,resolve:a},c=t.adapter.bind(e,l),u={model:e,get tokens(){return i()},resolveToken:a,override:r=>function(e,t,r){var n,o,s;const i=t.breakpoints,a=i?{...e.breakpoints,...i}:e.breakpoints,l=Object.keys(a),c=no(a,r.mediaConfig),u=oo(t.containers),d=u?{...null!==(n=e.containers)&&void 0!==n?n:{},...u}:e.containers,f=so(d),p={...e.subsystems};for(const n of ro){const i=t[n.key];if(void 0===i)continue;const u=lo(e.subsystems[n.key]),d=ao(n,i,{breakpoints:a,extendsPrefix:null!==(s=null===(o=t.extends)||void 0===o?void 0:o.prefix)&&void 0!==s?s:"dt",media:c,mediaConfig:r.mediaConfig,allowedBreakpoints:l,allowedStates:r.allowedStates,allowedContainers:f,inheritedProperties:u}),m=z(d);m&&(p[n.key]=co(e.subsystems[n.key],m))}const m={breakpoints:a,subsystems:p};d&&Object.keys(d).length&&(m.containers=d);const h=X(m,r.unitConfig),g=Fe(h,r.derivationRegistry);return go(g,r)}(e,r,t)},d=null===(r=c.extend)||void 0===r?void 0:r.call(c,u);return d&&Object.defineProperties(u,Object.getOwnPropertyDescriptors(d)),u}const bo="theme.css",vo="styles.css",yo="variables.css",wo=(e,t)=>"variables"===t?`${e}.variables.css`:`${e}.css`,$o=e=>`${e.group}-${e.variant}.css`,ko="variables.css";function xo(e){var t,r,n,o,s,i,a,l;if(void 0===e)return{type:"single",file:bo};if("string"==typeof e)switch(e){case"single":return{type:"single",file:bo};case"split":return{type:"split",file:vo,variables:yo};case"subsystem":return{type:"subsystem",filename:wo};case"components":return{type:"components",inline:!0,filename:$o,variables:ko}}switch(null!==(t=e.type)&&void 0!==t?t:"variables"in e?"split":"single"){case"single":return{type:"single",file:null!==(r=e.file)&&void 0!==r?r:bo};case"split":{const t=e;return{type:"split",file:null!==(n=t.file)&&void 0!==n?n:vo,variables:null!==(o=t.variables)&&void 0!==o?o:yo}}case"subsystem":return{type:"subsystem",filename:null!==(s=e.filename)&&void 0!==s?s:wo};case"components":{const t=e;return{type:"components",inline:null===(i=t.inline)||void 0===i||i,filename:null!==(a=t.filename)&&void 0!==a?a:$o,variables:null!==(l=t.variables)&&void 0!==l?l:ko}}}throw new Error("resolveEmitPlan: unrecognized emit directive.")}const jo="com.theme-registry.refract",Ao=e=>"object"==typeof e&&null!==e&&"$value"in e,So=/^\{([^}]+)\}$/,Eo=(e,t,r=new Set)=>{if("string"==typeof e){const n=e.match(So);if(n){const o=n[1];if(r.has(o))throw new w("REFRACT_E_CYCLE",`Circular token reference: ${o}`);const s=t.get(o);return s?(r.add(o),Eo(s.value,t,r)):e}return e}if(Array.isArray(e))return e.map(e=>Eo(e,t,new Set(r)));if("object"==typeof e&&null!==e){const n={};for(const[o,s]of Object.entries(e))n[o]=Eo(s,t,new Set(r));return n}return e};function Ro(e){var t;const r=[];for(const[n,o]of Object.entries(e.subsystems))for(const[e,s]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(s))r.push({subsystem:n,group:e,variant:t});return r}function Co(){return{name:(e={name:"noop",version:1,bind:()=>({recipeName:()=>"",renderRecipe:()=>"",renderVariables:()=>"",join:e=>e.join(""),emit:()=>({files:{}})})}).name,version:e.version,allowedStates:e.allowedStates,bind(t,r){var n,o,s,i;const a=e.bind(t,r),l=null!==(n=a.renderAllRecipes)&&void 0!==n?n:()=>a.join(Ro(t).map(({subsystem:e,group:t,variant:r})=>a.renderRecipe(e,t,r))),c=null!==(o=a.renderAllVariables)&&void 0!==o?o:()=>a.join(Object.keys(t.subsystems).map(e=>a.renderVariables(e))),u=null!==(s=a.renderAll)&&void 0!==s?s:()=>a.join([c(),l()]),d=null!==(i=a.describeUsage)&&void 0!==i?i:()=>({format:e.name,summary:[`This theme was built with the "${e.name}" refract adapter.`],recipes:Ro(t).map(({subsystem:e,group:t,variant:r})=>({subsystem:e,group:t,variant:r,name:a.recipeName(e,t,r)}))});return{...a,renderAllRecipes:l,renderAllVariables:c,renderAll:u,describeUsage:d}}};var e}const Oo=(e,t)=>{var r,n,o;const s=(e=>{const t=[],r=new Map,n=(e,o,s)=>{var i,a,l;const c=null!==(i=e.$type)&&void 0!==i?i:s;for(const[s,i]of Object.entries(e)){if(s.startsWith("$"))continue;if("object"!=typeof i||null===i)continue;const e=[...o,s];if(Ao(i)){const n=i,o={path:e,type:null!==(l=null!==(a=n.$type)&&void 0!==a?a:c)&&void 0!==l?l:"color",value:n.$value,description:n.$description,extensions:n.$extensions};t.push(o),r.set(e.join("."),o)}else n(i,e,c)}};n(e,[]);for(const e of t)e.value=Eo(e.value,r);return t})(e),i=null!==(r=null==t?void 0:t.groupMapping)&&void 0!==r?r:{},a={},l={},c={},u={},d={};let f=null!==(n=null==t?void 0:t.breakpoints)&&void 0!==n?n:{};const p=new Map;for(const e of s){const t=e.path[0];p.has(t)||p.set(t,[]),p.get(t).push(e)}const m=null==t?void 0:t.breakpointGroup;if(m&&p.has(m)){f={};for(const e of p.get(m)){f[e.path[e.path.length-1]]=Ho(e.value)}p.delete(m)}for(const[e,t]of p){const r=null!==(o=i[e])&&void 0!==o?o:To(e,t);if("ignore"!==r)switch(r){case"colors":No(t,e,a);break;case"typography":zo(t,e,l);break;case"effects":qo(t,e,c);break;case"borders":Bo(t,e,u);break;case"layout":Do(t,e,d)}}const h={};return Object.keys(f).length&&(h.breakpoints=f),Object.keys(a).length&&(h.colors=a),Object.keys(l).length&&(h.typography=l),Object.keys(c).length&&(h.effects=c),Object.keys(u).length&&(h.borders=u),Object.keys(d).length&&(h.layout=d),h},To=(e,t)=>{var r;const n=null===(r=t[0])||void 0===r?void 0:r.type;if("color"===n)return"colors";if("typography"===n)return"typography";if("shadow"===n)return"effects";if("border"===n)return"borders";if("strokeStyle"===n)return"borders";if("transition"===n)return"effects";const o=e.toLowerCase();if(o.includes("color")||o.includes("palette"))return"colors";if(o.includes("font")||o.includes("typo")||o.includes("text"))return"typography";if(o.includes("spacing")||o.includes("space")||o.includes("gutter"))return"layout";if(o.includes("radius")||o.includes("border")||o.includes("outline"))return"borders";if(o.includes("shadow")||o.includes("blur")||o.includes("opacity")||o.includes("z-index")||o.includes("zindex")||o.includes("transition")||o.includes("effect"))return"effects";if("dimension"===n){if(o.includes("spacing")||o.includes("gap"))return"layout";if(o.includes("radius")||o.includes("border"))return"borders";if(o.includes("font")||o.includes("size"))return"typography"}return"ignore"},Fo=/^\{([^}]+)\}$/,_o=e=>{if("string"!=typeof e)return;const t=e.match(Fo);if(!t)return;const r=t[1],n=r.indexOf("."),o=n<0?r:r.slice(0,n),s=n<0?"":r.slice(n+1),i="color"===o?"colors":o;return s?`${i}.${s}`:i},No=(e,t,r)=>{var n;const o=new Map,s=[];for(const t of e)if(t.path.length<=2)s.push(t);else{const e=t.path[1];o.has(e)||o.set(e,[]),o.get(e).push(t)}for(const e of s){const t=e.path[e.path.length-1];if(!r[t]){const n=_o(e.value);r[t]=n?{external:n}:{base:String(e.value)}}}for(const[e,t]of o)if(1===t.length){const n=t[0],o=n.path[n.path.length-1];o===e?r[e]={base:String(n.value)}:(r[e]||(r[e]={base:String(t[0].value)}),r[e].variants={[o]:String(n.value)})}else{const o=null!==(n=t.find(e=>{const t=e.path[e.path.length-1];return"base"===t||"default"===t||"500"===t}))&&void 0!==n?n:t[0],s={};for(const e of t){if(e===o)continue;s[e.path.slice(2).join("-")]=String(e.value)}r[e]={base:String(o.value),...Object.keys(s).length?{variants:s}:{}}}},Po={fontfamily:"fontFamily",fontsize:"fontSize",fontweight:"fontWeight",lineheight:"lineHeight",letterspacing:"letterSpacing",fontstyle:"fontStyle",texttransform:"textTransform",textdecoration:"textDecoration",textalign:"textAlign"},zo=(e,t,r)=>{for(const n of e)if("typography"===n.type){const e=n.value,t=n.path.slice(1).join("-")||n.path[n.path.length-1];e.fontFamily&&Mo(r,"fontFamily",Array.isArray(e.fontFamily)?e.fontFamily.join(", "):e.fontFamily,t),e.fontSize&&Mo(r,"fontSize",Go(e.fontSize),t),void 0!==e.fontWeight&&Mo(r,"fontWeight",e.fontWeight,t),void 0!==e.lineHeight&&Mo(r,"lineHeight",e.lineHeight,t),e.letterSpacing&&Mo(r,"letterSpacing",e.letterSpacing,t)}else{const e=Lo(n,t);if(!e)continue;const o=n.path[n.path.length-1],s="fontFamily"===n.type&&Array.isArray(n.value)?n.value.join(", "):"dimension"===n.type?Go(n.value):n.value;Mo(r,e,s,o)}},Mo=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Lo=(e,t)=>{if("fontFamily"===e.type)return"fontFamily";if("fontWeight"===e.type)return"fontWeight";const r=e.path.join(".").toLowerCase();for(const[e,t]of Object.entries(Po))if(r.includes(e))return t;const n=t.toLowerCase();for(const[e,t]of Object.entries(Po))if(n.includes(e))return t;return null},qo=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"shadow":{const n=Vo(t.value);Io(r,"shadow",n,e);break}case"transition":{const n=t.value,o=n.timingFunction?`cubic-bezier(${n.timingFunction.join(", ")})`:"ease",s=`all ${n.duration} ${o}`;Io(r,"transitions",s,e);break}case"dimension":t.path.join(".").toLowerCase().includes("blur")&&Io(r,"blur",Go(t.value),e);break;case"number":{const n=t.path.join(".").toLowerCase();n.includes("opacity")?Io(r,"opacity",t.value,e):(n.includes("z-index")||n.includes("zindex"))&&Io(r,"zIndex",t.value,e);break}}}},Io=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Bo=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"border":{const n=t.value;Uo(r,"width",Go(n.width),e),n.style&&Uo(r,"style",n.style,e);break}case"strokeStyle":Uo(r,"style",String(t.value),e);break;case"dimension":{const n=t.path.join(".").toLowerCase();n.includes("radius")?Uo(r,"radius",Go(t.value),e):n.includes("offset")?Uo(r,"offset",Go(t.value),e):n.includes("width")&&Uo(r,"width",Go(t.value),e);break}}}},Uo=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Do=(e,t,r)=>{for(const t of e){if("dimension"!==t.type)continue;const e=t.path[t.path.length-1],n=Ho(t.value);r.spacing||(r.spacing={base:n,variants:{}});const o=r.spacing;"base"===e||"default"===e||"4"===e?o.base=n:o.variants[e]=n}},Vo=e=>Array.isArray(e)?e.map(e=>Wo(e)).join(", "):Wo(e),Wo=e=>{const t=[];return e.inset&&t.push("inset"),t.push(e.offsetX,e.offsetY,e.blur,e.spread,e.color),t.join(" ")},Ho=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?0:e.endsWith("rem")?Math.round(16*t):t},Go=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?e:e.endsWith("px")?t:e},Yo=(e,t)=>{var r;const n={};(null==t?void 0:t.name)&&(n.$name=t.name);const o=e.model.breakpoints;if(!1!==(null==t?void 0:t.includeBreakpoints)&&o&&Object.keys(o).length){const e={$type:"dimension"};for(const[t,r]of Object.entries(o))e[t]={$value:`${r}px`};n.breakpoint=e}const s=Ko(e),i=t=>{try{return String(e.resolveToken(t))}catch{return t}},a=s.get("colors");if(a){const e={$type:"color"};for(const[t,r]of a){const n={};void 0!==r.base&&(n.base={$value:dt(String(r.base))});for(const[e,t]of Object.entries(r.members))n[e]={$value:dt(String(t))};e[t]=n}n.color=e}const l=s.get("typography");if(l){const e={};for(const[t,r]of l){const n={$type:Xo(t)};void 0!==r.base&&(n.base={$value:Zo(r.base,r.baseUnit)});for(const[e,t]of Object.entries(r.members))n[e]={$value:Zo(t,r.memberUnits[e])};e[t]=n}n.typography=e}const c=s.get("effects");if(c)for(const[e,t]of c){const{groupName:r,type:o}=Qo(e);n[r]||(n[r]={$type:o});const s=n[r];void 0!==t.base&&(s.base={$value:es(e,t.base,i,t.baseUnit)});for(const[r,n]of Object.entries(t.members))s[r]={$value:es(e,n,i,t.memberUnits[r])}}const u=s.get("borders");if(u)for(const[e,t]of u){const{groupName:r,type:o}=ts(e);n[r]||(n[r]={$type:o});const s=n[r];void 0!==t.base&&(s.base={$value:rs(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))s[e]={$value:rs(r,t.memberUnits[e])}}const d=s.get("layout");if(d)for(const[e,t]of d){if(e.includes("--"))continue;const r=e;n[r]||(n[r]={$type:"dimension"});const o=n[r];void 0!==t.base&&(o.base={$value:ns(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))o[e]={$value:ns(r,t.memberUnits[e])}}if(null==t?void 0:t.includeRecipes){const t=(e=>{const t={},r={},n={};for(const[o,s]of Object.entries(e.subsystems))s.properties&&Object.keys(s.properties).length&&(t[o]=s.properties),s.ruleSets&&Object.keys(s.ruleSets).length&&(r[o]=s.ruleSets),s.keyframes&&Object.keys(s.keyframes).length&&(n[o]=s.keyframes);const o=Object.keys(t).length>0,s=Object.keys(r).length>0,i=Object.keys(n).length>0,a=!!e.containers&&Object.keys(e.containers).length>0;if(o||s||i||a)return{version:1,...o?{properties:t}:{},...s?{ruleSets:r}:{},...i?{keyframes:n}:{},...a?{containers:e.containers}:{}}})(e.model);t&&(n.$extensions={...null!==(r=n.$extensions)&&void 0!==r?r:{},[jo]:t})}return n},Jo=(e,t)=>void 0!==t?`${e}${t}`:e,Ko=e=>{const t=new Map;for(const r of Object.keys(e.tokens)){const n=r.indexOf(".");if(n<0)continue;const o=r.slice(0,n),s=r.slice(n+1),i=s.indexOf("."),a=i<0?s:s.slice(0,i),l=i<0?void 0:s.slice(i+1),c=e.tokens[r];if(void 0!==(null==c?void 0:c.external))continue;let u;if(void 0!==(null==c?void 0:c.struct))u=c.struct;else try{u=e.resolveToken(r)}catch{continue}const d=null==c?void 0:c.unit;let f=t.get(o);f||(f=new Map,t.set(o,f));let p=f.get(a);p||(p={members:{},memberUnits:{}},f.set(a,p)),void 0===l?(p.base=u,void 0!==d&&(p.baseUnit=d)):(p.members[l]=u,void 0!==d&&(p.memberUnits[l]=d))}return t},Xo=e=>{switch(e){case"fontFamily":return"fontFamily";case"fontWeight":return"fontWeight";case"fontSize":case"letterSpacing":return"dimension";default:return"number"}},Zo=(e,t)=>Jo(e,t),Qo=e=>{switch(e){case"shadow":return{groupName:"shadow",type:"shadow"};case"transitions":return{groupName:"transition",type:"transition"};case"blur":default:return{groupName:e,type:"dimension"};case"opacity":case"zIndex":return{groupName:e,type:"number"}}},es=(e,t,r,n)=>Array.isArray(t)?"transitions"===e?t.map(e=>{var t;const r=[e.property];return null==e.duration&&null==e.delay||r.push(`${null!==(t=e.duration)&&void 0!==t?t:0}ms`),e.timingFunction&&r.push(e.timingFunction),null!=e.delay&&r.push(`${e.delay}ms`),r.join(" ")}).join(", "):((e,t)=>e.map(e=>{const r=`0${(e=>{for(const t of[e.offsetX,e.offsetY,e.blur,e.spread])if(void 0!==t&&"number"!=typeof t)return t.unit;return"px"})(e)}`,n=e=>void 0===e?r:(e=>"number"==typeof e?`${e}px`:`${e.value}${e.unit}`)(e),o=[];return e.inset&&o.push("inset"),o.push(n(e.offsetX),n(e.offsetY)),null!=e.spread?o.push(n(e.blur),n(e.spread)):null!=e.blur&&o.push(n(e.blur)),e.color&&o.push(t(e.color)),o.join(" ")}).join(", "))(t,r):Jo(t,n),ts=e=>{switch(e){case"radius":return{groupName:"radius",type:"dimension"};case"width":return{groupName:"borderWidth",type:"dimension"};case"offset":return{groupName:"outlineOffset",type:"dimension"};case"style":return{groupName:"borderStyle",type:"strokeStyle"};default:return{groupName:e,type:"dimension"}}},rs=(e,t)=>Jo(e,t),ns=(e,t)=>Jo(e,t);async function os(r){var n;const{raw:o,adapter:s,outDir:i,helpers:a=[],emit:u,media:f,units:m,baseFontSize:h,guide:g}=r,b=uo(o,{adapter:s,media:f,units:m,baseFontSize:h}),v=Pe(b.model.breakpoints,e=>Be(e,qe(f))),w=Ve(b.model.containers,f),$=s.bind(b.model,{media:v,containers:w,resolve:b.resolveToken});if(!$.emit)throw new Error(`Adapter "${s.name}" does not implement emit(); it cannot build to disk.`);const k=$.emit(xo(u)),x=[];e.mkdirSync(i,{recursive:!0});const j=(r,n)=>{const o=t.join(i,r);e.mkdirSync(t.dirname(o),{recursive:!0}),e.writeFileSync(o,n,"utf8"),x.push(o)};for(const[e,t]of Object.entries(k.files))j(e,t);for(const[e,t]of Object.entries(null!==(n=k.vendorHelpers)&&void 0!==n?n:{}))j(e,t);for(const e of a){const t=c(e);if(!t)throw new Error(`Unknown vendor helper "${e}". Known: ${l.map(e=>e.id).join(", ")}.`);j(t.outfile,await p(d(t.source)))}if(g){const e=!0===g?{}:g,t=y($.describeUsage(),Yo(b),{files:Object.keys(k.files),packageName:e.packageName,llmsFile:e.llmsFile,manifestFile:e.manifestFile});for(const[e,r]of Object.entries(t.files))j(e,r)}return{outDir:i,files:x}}const ss="theme.config",is=[".ts",".mjs",".js"],as=(r=process.cwd())=>{for(const n of is){const o=t.join(r,`${ss}${n}`);if(e.existsSync(o))return o}};let ls=0;async function cs(n={}){var o,s,i;const a=null!==(o=n.cwd)&&void 0!==o?o:process.cwd(),l=n.configPath?t.resolve(a,n.configPath):as(a);if(!l||!e.existsSync(l)){const e=n.configPath?`"${n.configPath}"`:`${ss}.(ts|mjs|js) in "${a}"`;throw new Error(`No theme config found at ${e}.`)}const c=await async function(e){if(".ts"!==t.extname(e)){const t=`${r.pathToFileURL(e).href}?v=${++ls}`;return await import(t)}const{entry:n,cleanup:o}=await g(e);try{return await import(r.pathToFileURL(n).href)}finally{o()}}(l),u=null!==(i=null!==(s=c.default)&&void 0!==s?s:c.config)&&void 0!==i?i:c;if(!u||"object"!=typeof u||!Array.isArray(u.targets))throw new Error(`"${l}" must export (default) a defineConfig({ raw, targets }) object.`);return{config:u,path:l}}const us="@theme-registry/refract-css";function ds(){var r;const n=t.join(u(),"package.json");return null!==(r=JSON.parse(e.readFileSync(n,"utf8")).name)&&void 0!==r?r:"@theme-registry/refract"}const fs="theme.raw",ps=[".ts",".mts",".mjs",".js",".json"],ms=(r=process.cwd())=>{for(const n of ps){const o=t.join(r,`${fs}${n}`);if(e.existsSync(o))return{path:o,filename:`${fs}${n}`,ext:n}}};function hs(e){if(".json"===e.ext)return{head:`import { readFileSync } from "node:fs";\n\n// The theme is JSON, so it's read rather than imported — no module-attribute support needed.\nconst raw = JSON.parse(readFileSync(new URL("./${e.filename}", import.meta.url), "utf8"));\n`,expression:"raw"};return{head:`import { raw } from "${".ts"===e.ext||".mts"===e.ext?`./${fs}`:`./${e.filename}`}";\n`,expression:"raw"}}function gs(e,t){const{head:r,expression:n}=hs(t);return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${us}";\n${r}\n// refract build config. \`refract build\` reads this file, builds the theme once, and writes each\n// target's emitted files into that target's \`outDir\`. The config is your code: it \`import\`s the\n// adapters it wants and passes their options at construction (not via CLI flags).\n//\n// Your tokens live in \`${t.filename}\` — edit them there, not here.\nexport default defineConfig({\n raw: ${n},\n targets: [\n // The CSS adapter (from @theme-registry/refract-css). Pass its options here, at construction.\n { adapter: createCssAdapter(/* { colors: { prefix: "app" } } */), outDir: "dist/theme" },\n\n // Add another adapter target once its package is installed, e.g.:\n // import { createStyledComponentsAdapter } from "@theme-registry/refract-styled-components";\n // { adapter: createStyledComponentsAdapter(), outDir: "dist/theme-sc" },\n ],\n});\n`}function bs(e){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${us}";\n\n// refract build config. \`refract build\` reads this file, builds the theme once, and writes\n// each target's emitted files into that target's \`outDir\`. The config is your code: it \`import\`s\n// the adapters it wants and passes their options at construction (not via CLI flags).\nexport default defineConfig({\n // The raw theme — authored in refract's nested slices. Extend with typography/effects/layout.\n raw: {\n breakpoints: { sm: 576, md: 768, lg: 1024, xl: 1280 },\n colors: {\n // Starter palette passes its own contrast audit (WCAG AA): white text clears 4.5:1 on both\n // bases. Keep that when you retune — the auditor is a shipped feature; the default should model it.\n primary: { base: "#1864ab", text: "#fff", variants: { dark: "#0b4a86", light: "#a5d8ff" } },\n neutral: { base: "#495057", text: "#fff", variants: { light: "#f1f3f5", dark: "#212529" } },\n recipes: {\n solid: {\n primary: { background: "primary", color: "primary.text" },\n neutral: { background: "neutral.light", color: "neutral.dark" },\n },\n },\n },\n },\n targets: [\n // The CSS adapter (from @theme-registry/refract-css). Pass its options here, at construction.\n { adapter: createCssAdapter(/* { colors: { prefix: "app" } } */), outDir: "dist/theme" },\n\n // Add another adapter target once its package is installed, e.g.:\n // import { createStyledComponentsAdapter } from "@theme-registry/refract-styled-components";\n // { adapter: createStyledComponentsAdapter(), outDir: "dist/theme-sc" },\n ],\n});\n`}function vs(r={}){var n,o,s,i;const a=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),l=null!==(o=r.variant)&&void 0!==o?o:"ts",c=null!==(s=r.packageName)&&void 0!==s?s:ds(),u=t.join(a,`theme.config.${l}`);if(e.existsSync(u)&&!r.force)throw new Error(`theme.config.${l} already exists at "${u}". Pass --force to overwrite it.`);const d=null===r.rawTheme?void 0:null!==(i=r.rawTheme)&&void 0!==i?i:ms(a),f=d?gs(c,d):bs(c);return e.writeFileSync(u,f,"utf8"),{path:u,variant:l,packageName:c,rawTheme:d}}const ys=[["xs",-2],["sm",-1],["md",0],["lg",1],["xl",2],["2xl",3],["3xl",4],["4xl",5]],ws={"minor-second":1.067,"major-second":1.125,"minor-third":1.2,"major-third":1.25,"perfect-fourth":1.333,"augmented-fourth":1.414,"perfect-fifth":1.5,golden:1.618},$s={complement:[180],analogous:[-30,30],"split-complement":[150,210],triadic:[120,240],tetradic:[90,180,270],pentadic:[72,144,216,288]},ks=["primary","secondary","tertiary","quaternary","quinary"],xs=[["success","#2f9e44","#ffffff"],["info","#1c7ed6","#ffffff"],["warning","#e89012","#1f2733"],["danger","#e03131","#ffffff"]],js=[50,100,200,300,400,500,600,700,800,900],As=[8,14,22],Ss="system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Es="ui-monospace, 'SF Mono', Menlo, Consolas, monospace",Rs={neutral:{label:"Neutral",blurb:"system type, comfortable spacing, soft corners",fontFamily:{base:Ss,mono:Es},spacing:{xs:1,sm:2,md:4,lg:6,xl:8,"2xl":12},radius:{base:8,variants:{none:0,sm:4,lg:14,pill:"9999px"}},ratio:"major-third"},compact:{label:"Compact",blurb:"dense UI, tight scale, small radius",fontFamily:{base:Ss,mono:Es},spacing:{xs:1,sm:2,md:3,lg:4,xl:6,"2xl":8},radius:{base:4,variants:{none:0,sm:2,lg:8,pill:"9999px"}},ratio:"major-second"},editorial:{label:"Editorial",blurb:"serif display, spacious, generous leading",fontFamily:{base:"'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif",mono:Es},spacing:{xs:2,sm:4,md:6,lg:8,xl:12,"2xl":16},radius:{base:2,variants:{none:0,sm:1,lg:4,pill:"9999px"}},ratio:"perfect-fourth"},technical:{label:"Technical",blurb:"mono accents, compact, sharp corners",fontFamily:{base:Es,mono:Es},spacing:{xs:1,sm:2,md:3,lg:4,xl:6,"2xl":8},radius:{base:0,variants:{none:0,sm:0,lg:2,pill:"9999px"}},ratio:"minor-third"}},Cs=(e,t)=>Number(e.toFixed(t)),Os=e=>Ke(Ze(e).rgb),Ts=e=>Cs(Math.min(1.7,Math.max(1.1,1.5*Math.pow(16/e,.22))),2),Fs=e=>`${Cs(.36/e-.0225,3)}em`,_s=e=>{const t=1e3-10*e;let r=js[0];for(const e of js)Math.abs(e-t)<Math.abs(r-t)&&(r=e);return r},Ns=e=>{if(!(e<=1))return 2===e?"complement":3===e?"triadic":4===e?"tetradic":"pentadic"},Ps=e=>Object.keys($s).filter(t=>$s[t].length===e-1);function zs(e){var t,r,n,o,s,i,a,l,c;const u=null!==(t=e.mode)&&void 0!==t?t:"auto",d=Rs[null!==(r=e.feel)&&void 0!==r?r:"neutral"],f=Math.min(5,Math.max(1,null!==(n=e.brandCount)&&void 0!==n?n:2)),p=null!==(o=e.baseFontSize)&&void 0!==o?o:16,m=null!==(s=e.ratio)&&void 0!==s?s:d.ratio,h=ws[m];if(!h)throw new Error(`Unknown type ratio "${m}". Use one of: ${Object.keys(ws).join(", ")}.`);const g=Os(e.seed),b=[{name:ks[0],hex:g,rotation:0}];if("manual"===u)(null!==(i=e.extraColors)&&void 0!==i?i:[]).slice(0,ks.length-1).forEach((e,t)=>{b.push({name:ks[t+1],hex:Os(e),rotation:0})});else if(f>1){const t=null!==(a=e.scheme)&&void 0!==a?a:Ns(f),r=$s[t];if(!r)throw new Error(`Unknown harmony scheme "${t}".`);r.slice(0,f-1).forEach((e,t)=>{b.push({name:ks[t+1],hex:Os(ct(g,e)),rotation:e})})}const v=null!==(l=e.contrast)&&void 0!==l?l:"AA",y=[...b.map(e=>({name:e.name,base:e.hex,text:"#ffffff"})),...!1===e.semantics?[]:xs.map(([e,t,r])=>({name:e,base:t,text:r})),...!1===e.neutral?[]:[{name:"neutral",base:"#6b7280",text:"#ffffff"}]],{palettes:w,adjustments:$}="none"===v?{palettes:y,adjustments:[]}:function(e,t){var r;const n=e.map(e=>({...e})),o=new Map(n.map(e=>[e.name,0])),s=new Map,i=()=>{var e,r;const o={};for(const e of n)o[e.name]={base:e.base,text:e.text};const s=uo({colors:o},{adapter:Co()}),i=gr(s,{minWcag:t,includeRecipes:!1}),a=new Map;for(const t of i.pairings){if(t.skipped||void 0===t.wcagRatio)continue;const n=t.label.replace(/^colors\./,"");a.set(n,{ratio:t.wcagRatio,level:null!==(e=t.wcagLevel)&&void 0!==e?e:"fail",pass:null!==(r=t.pass)&&void 0!==r&&r})}return a};let a=i();for(const[e,t]of a)s.has(e)||s.set(e,t.ratio);for(let e=0;e<40;e++){const e=n.filter(e=>a.get(e.name)&&!a.get(e.name).pass);if(!e.length)break;for(const t of e)t.base=Os(at(t.base,1)),o.set(t.name,(null!==(r=o.get(t.name))&&void 0!==r?r:0)+1);a=i()}const l=n.map((t,r)=>{var n,i,l,c;const u=a.get(t.name);return{name:t.name,seed:e[r].base,final:t.base,nudge:null!==(n=o.get(t.name))&&void 0!==n?n:0,ratioBefore:Cs(null!==(i=s.get(t.name))&&void 0!==i?i:0,2),ratioAfter:Cs(null!==(l=null==u?void 0:u.ratio)&&void 0!==l?l:0,2),levelAfter:null!==(c=null==u?void 0:u.level)&&void 0!==c?c:"fail",unresolved:!!u&&!u.pass}});return{palettes:n,adjustments:l}}(y,v),k={};for(const e of w)k[e.name]={base:e.base,text:e.text,steps:[...js]};if(!1!==e.shadows){const e={};for(const t of As)e[`a${String(t).padStart(2,"0")}`]={modifiers:[{alpha:t}]};k.shadow={base:"#18274b",variants:e}}const x=ys.map(([e,t])=>({step:e,px:Cs(p*Math.pow(h,t),2)})),j={},A={};for(const{step:e,px:t}of x)"md"!==e&&(j[e]=Ts(t),A[e]=Fs(t));A.caps="0.06em";const S={fontFamily:{base:d.fontFamily.base,variants:{mono:d.fontFamily.mono}},fontWeight:{base:400,variants:{medium:500,semibold:600,bold:700}},fontSize:{base:p,ratio:m},lineHeight:{base:Ts(p),variants:j},letterSpacing:{base:"0em",variants:A}},E={spacing:{base:4,step:4,steps:{...d.spacing}}},R={width:{base:1,variants:{thick:2}},style:{base:"solid"},radius:{base:d.radius.base,variants:{...d.radius.variants}}},C=!1===e.shadows?void 0:{shadow:{offsetY:1,blur:3,color:"colors.shadow.a08",variants:{md:{offsetY:6,blur:16,color:"colors.shadow.a14"},lg:{offsetY:14,blur:34,color:"colors.shadow.a22"},none:"none"}}},O={colors:k,typography:S,layout:E,borders:R,...C?{effects:C}:{},animation:{duration:{base:200,variants:{fast:120,slow:400}},easing:{base:"cubic-bezier(.2,.7,.3,1)",variants:{out:"cubic-bezier(.16,.84,.44,1)"}}},..."none"===e.reset?{}:{globals:{preset:null!==(c=e.reset)&&void 0!==c?c:"preflight"}}},T=Cs(nt(Ze(g).rgb).L,1);return{raw:O,report:{seedLightness:T,nearestStep:_s(T),brand:b.map(e=>{var t;const r=$.find(t=>t.name===e.name);return{name:e.name,hex:null!==(t=null==r?void 0:r.final)&&void 0!==t?t:e.hex,rotation:e.rotation}}),contrast:$,type:x.map(({step:e,px:t})=>({step:e,px:t,leading:Ts(t),tracking:Fs(t)})),spacing:Object.entries(d.spacing).map(([e,t])=>({step:e,px:4*t}))}}}const Ms="theme.raw",Ls=/^[A-Za-z_$][A-Za-z0-9_$]*$/,qs=e=>JSON.stringify(e);function Is(e,t=0){const r=" ".repeat(t),n=" ".repeat(t+1);if(null===e)return"null";if("string"==typeof e)return qs(e);if("number"==typeof e||"boolean"==typeof e)return String(e);if(Array.isArray(e)){if(!e.length)return"[]";if(e.every(e=>null===e||"object"!=typeof e)){const t=`[${e.map(e=>Is(e)).join(", ")}]`;if(r.length+t.length<=76)return t}return`[\n${e.map(e=>`${n}${Is(e,t+1)}`).join(",\n")}\n${r}]`}const o=Object.entries(e);if(!o.length)return"{}";return`{\n${o.map(([e,r])=>{const o=Ls.test(e)?e:qs(e);return`${n}${o}: ${Is(r,t+1)}`}).join(",\n")}\n${r}}`}const Bs=(e,t)=>`// Generated by \`refract create\` — seed ${e} · ${t}.\n// This is YOUR theme now: every value is a literal you can read, edit and delete. The generator\n// does not run again. Tonal ladders, the type scale and the spacing ramp are synthesized by the\n// engine from the declarations below — re-tune a scale by editing one word, not eight numbers.\n`;function Us(e,t){if("json"===t.format)return`${JSON.stringify(e,null,2)}\n`;const r=Is(e);return"js"===t.format?`${Bs(t.seed,t.detail)}\n/** @type {import("${t.packageName}/build").RawTheme} */\nexport const raw = ${r};\n`:`${Bs(t.seed,t.detail)}import type { RawTheme } from "${t.packageName}/build";\n\nexport const raw = ${r} satisfies RawTheme;\n`}function Ds(e){var t,r,n,o,s,i;const a=[],l="manual"===e.mode?(null!==(r=null===(t=e.extraColors)||void 0===t?void 0:t.length)&&void 0!==r?r:0)+1:null!==(n=e.brandCount)&&void 0!==n?n:2;return a.push(`${l} brand colour${1===l?"":"s"}`),"manual"!==e.mode&&l>1&&a.push(null!==(o=e.scheme)&&void 0!==o?o:"auto"),a.push(null!==(s=e.feel)&&void 0!==s?s:"neutral"),"none"!==e.contrast&&a.push(`WCAG ${null!==(i=e.contrast)&&void 0!==i?i:"AA"}`),a.join(" · ")}function Vs(r){var n,o,s,i;const a=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),l=null!==(o=r.format)&&void 0!==o?o:"ts",c=null!==(s=r.out)&&void 0!==s?s:`${Ms}.${l}`,u=t.join(a,c);if(e.existsSync(u)&&!r.force)throw new Error(`"${c}" already exists. Re-run with --force to overwrite it.`);const{raw:d,report:f}=zs(r),p=Us(d,{format:l,packageName:null!==(i=r.packageName)&&void 0!==i?i:ds(),seed:r.seed,detail:Ds(r)});return e.writeFileSync(u,p,"utf8"),{path:u,format:l,raw:d,report:f,sections:Object.keys(d)}}const Ws=()=>Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,Hs=(e,t)=>Ws()?`[${e}m${t}[0m`:t,Gs=e=>Hs("1",e),Ys=e=>Hs("2",e),Js=e=>Hs("36",e),Ks=e=>Hs("32",e),Xs=e=>Hs("33",e),Zs=e=>e>0?`[${e}A`:"",Qs="[0J";function ei(e,t=2){if(!Ws())return"";const r=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!r)return"";const n=parseInt(r[1],16),[o,s,i]=[n>>16&255,n>>8&255,255&n],a=/truecolor|24bit/i.test(null!==(l=process.env.COLORTERM)&&void 0!==l?l:"")?`48;2;${o};${s};${i}`:`48;5;${((e,t,r)=>{const n=e=>e<48?0:e<114?1:Math.min(5,Math.round((e-35)/40));return 16+36*n(e)+6*n(t)+n(r)})(o,s,i)}`;var l;return`[${a}m${" ".repeat(t)}[0m`}function ti(e){switch(e){case"[A":case"k":return"up";case"[B":case"j":return"down";case" ":return"space";case"\r":case"\n":return"submit";case"a":return"all";case"":case"":return"cancel";default:return"none"}}function ri(e){const t=[];for(let r=0;r<e.length;)""===e[r]&&"["===e[r+1]&&r+2<e.length?(t.push(ti(e.slice(r,r+3))),r+=3):(t.push(ti(e[r])),r+=1);return t}function ni(e,t,r,n){if(e.done||e.cancelled||0===r)return e;switch(t){case"up":return{...e,cursor:(e.cursor-1+r)%r};case"down":return{...e,cursor:(e.cursor+1)%r};case"space":{if(!n)return e;const t=new Set(e.selected);return t.has(e.cursor)?t.delete(e.cursor):t.add(e.cursor),{...e,selected:t}}case"all":{if(!n)return e;const t=e.selected.size===r;return{...e,selected:t?new Set:new Set(Array.from({length:r},(e,t)=>t))}}case"submit":return{...e,done:!0};case"cancel":return{...e,cancelled:!0};default:return e}}const oi=()=>Boolean(process.stdin.isTTY)&&"function"==typeof process.stdin.setRawMode;class si{constructor(e=Boolean(process.stdin.isTTY)&&Boolean(process.stdout.isTTY)){this.interactive=e}get io(){return this.rl||(this.rl=n.createInterface({input:process.stdin,output:process.stdout})),this.rl}close(){var e;null===(e=this.rl)||void 0===e||e.close(),this.rl=void 0}question(e){return new Promise(t=>this.io.question(e,e=>t(e)))}out(e){process.stdout.write(e)}write(e=""){process.stdout.write(`${e}\n`)}async text(e,t,r){if(!this.interactive)return t;for(;;){const n=(await this.question(`${Js("?")} ${Gs(e)} ${Ys(`(${t})`)} `)).trim()||t,o=null==r?void 0:r(n);if(!o)return n;this.write(` ${Xs("!")} ${o}`)}}async number(e,t,r){const n=await this.text(e,String(t),e=>{const t=Number(e);return Number.isFinite(t)?null==r?void 0:r(t):`"${e}" is not a number.`});return Number(n)}async select(e,t,r=0){var n,o,s;if(!this.interactive||1===t.length)return null!==(o=null===(n=t[r])||void 0===n?void 0:n.value)&&void 0!==o?o:t[0].value;if(oi()){return t[null!==(s=(await this.runList(e,t,{multi:!1,cursor:r,selected:new Set}))[0])&&void 0!==s?s:r].value}return this.selectByNumber(e,t,r)}async multiselect(e,t,r){var n;if(!this.interactive)return r.map(e=>t[e].value);if(oi()){return(await this.runList(e,t,{multi:!0,cursor:null!==(n=r[0])&&void 0!==n?n:0,selected:new Set(r)})).map(e=>t[e].value)}return this.multiselectByNumber(e,t,r)}runList(e,t,r){this.close();const n=process.stdin,{multi:o}=r;let s={cursor:Math.max(0,Math.min(r.cursor,t.length-1)),selected:r.selected,done:!1,cancelled:!1},i=0;const a=o?"↑↓ move · space toggle · a all · enter confirm":"↑↓ move · enter select",l=t.reduce((e,t)=>Math.max(e,t.label.length),0),c=()=>{i&&this.out(Zs(i)+Qs);const r=(()=>{const r=t.map((e,t)=>{var r;const n=t===s.cursor,i=n?Ks("❯"):" ",a=o?s.selected.has(t)?Ks("[✓]"):Ys("[ ]"):"",c=n?Gs(e.label):e.label,u=" ".repeat(Math.max(0,l-e.label.length)),d=(null!==(r=e.swatches)&&void 0!==r?r:[]).map(e=>ei(e)).filter(Boolean).join(" ");return` ${i} ${a?`${a} `:""}${c}${u}${d?` ${d}`:""}${e.hint?` ${Ys(e.hint)}`:""}`});return[`${Js("?")} ${Gs(e)} ${Ys(a)}`,...r].join("\n")})();this.out(`${r}\n`),i=r.split("\n").length};return new Promise((r,a)=>{const l=()=>{n.removeListener("data",d),n.removeListener("end",u),n.isTTY&&n.setRawMode(!1),n.pause(),this.out("[?25h")},u=()=>{const e=o?[...s.selected].sort((e,t)=>e-t):[s.cursor];this.out(Zs(i)+Qs),l(),r(e)},d=n=>{for(const e of ri(n))if(s=ni(s,e,t.length,o),s.done||s.cancelled)break;if(s.cancelled)return this.out(Zs(i)+Qs),l(),void a(new Error("Cancelled."));if(s.done){const n=o?[...s.selected].sort((e,t)=>e-t):[s.cursor];this.out(Zs(i)+Qs);const a=n.length?n.map(e=>t[e].label).join(", "):"none";return this.write(`${Js("?")} ${Gs(e)} ${Ys("›")} ${Ks(a)}`),l(),void r(n)}c()};n.setRawMode(!0),n.resume(),n.setEncoding("utf8"),this.out("[?25l"),n.on("data",d),n.on("end",u),c()})}async selectByNumber(e,t,r){for(this.write(`${Js("?")} ${Gs(e)}`),t.forEach((e,t)=>{const n=t===r?Ks("❯"):" ",o=e.hint?` ${Ys(`— ${e.hint}`)}`:"";this.write(` ${n} ${Ys(`${t+1}.`)} ${t===r?Gs(e.label):e.label}${o}`)});;){const e=(await this.question(` ${Ys(`1–${t.length}`)} `)).trim();if(!e)return t[r].value;const n=Number(e)-1;if(Number.isInteger(n)&&n>=0&&n<t.length)return t[n].value;this.write(` ${Xs("!")} Enter a number between 1 and ${t.length}.`)}}async multiselectByNumber(e,t,r){for(this.write(`${Js("?")} ${Gs(e)} ${Ys('(comma-separated, blank = keep, "none" = clear)')}`),t.forEach((e,t)=>{const n=r.includes(t),o=e.hint?` ${Ys(`— ${e.hint}`)}`:"";this.write(` ${n?Ks("◉"):Ys("◯")} ${Ys(`${t+1}.`)} ${e.label}${o}`)});;){const e=(await this.question(` ${Ys(`1–${t.length}`)} `)).trim().toLowerCase();if(!e)return r.map(e=>t[e].value);if("none"===e)return[];const n=e.split(",").map(e=>Number(e.trim())-1);if(n.every(e=>Number.isInteger(e)&&e>=0&&e<t.length))return n.map(e=>t[e].value);this.write(` ${Xs("!")} Enter numbers between 1 and ${t.length}, separated by commas.`)}}}const ii={complement:[180],analogous:[-30,30],"split-complement":[150,210],triadic:[120,240],tetradic:[90,180,270],pentadic:[72,144,216,288]},ai=(e,t)=>{var r;return(null!==(r=ii[t])&&void 0!==r?r:[]).map(t=>Ke(Ze(ct(e,t)).rgb))},li={complement:"one companion, 180° opposite — maximum separation",analogous:"two neighbours, ±30° — quiet and cohesive","split-complement":"the complement's neighbours — contrast with less tension",triadic:"even thirds, ±120° — three colours of equal weight",tetradic:"two complementary pairs — the most range",pentadic:"five evenly spaced hues — needs a dominant colour picked by hand"},ci=[["major-second","1.125 · 16 · 18 · 20 · 23 · 26 · 29"],["minor-third","1.2 · 16 · 19 · 23 · 28 · 33 · 40"],["major-third","1.25 · 16 · 20 · 25 · 31 · 39 · 49"],["perfect-fourth","1.333 · 16 · 21 · 28 · 38 · 51 · 67"],["perfect-fifth","1.5 · 16 · 24 · 36 · 54 · 81 · 122"],["golden","1.618 · 16 · 26 · 42 · 68 · 110 · 178"]],ui=e=>{try{return void Ze(e)}catch{return`"${e}" isn't a colour refract can parse. Try a hex like #4c6ef5.`}};async function di(e,t={}){var r,n,o,s,i,a,l,c;const u=null!==(r=t.seed)&&void 0!==r?r:await e.text("Primary colour","#4c6ef5",ui),d=Math.round(10*nt(Ze(u).rgb).L)/10,f=Ke(Ze(u).rgb),p=ei(f,3);e.write(` ${p?`${p} `:""}${Ys(`${f} · lightness ${d}% — lands at ≈${_s(d)} on the ladder`)}`),e.write();const m=Boolean(t.manual);let h,g=2,b=[];if(m){if(b=(null!==(n=t.colors)&&void 0!==n?n:"").split(",").map(e=>e.trim()).filter(Boolean),!b.length&&e.interactive){const t=await e.number("How many brand colours in total?",2,e=>Number.isInteger(e)&&e>=1&&e<=5?void 0:"Pick a whole number from 1 to 5.");for(let r=1;r<t;r++)b.push(await e.text(`Brand colour ${r+1}`,"#e64980",ui))}g=b.length+1}else{g=t.colors?Number(t.colors):await e.number("How many brand colours? (including the primary)",2,e=>Number.isInteger(e)&&e>=1&&e<=5?void 0:"Pick a whole number from 1 to 5.");const r=Ps(g);h=null!==(o=t.scheme)&&void 0!==o?o:Ns(g),!t.scheme&&r.length>1&&(h=await e.select("Harmony scheme",r.map(e=>({value:e,label:e,hint:li[e],swatches:[f,...ai(f,e)]})),Math.max(0,r.indexOf(h)))),h&&g>1&&(e.write(` ${Ys(`→ ${h} · each member becomes its own palette with a full ladder`)}`),e.write())}const v=t.noSemantics||t.noNeutral||t.noShadows||!e.interactive?{semantics:!t.noSemantics,neutral:!t.noNeutral,shadows:!t.noShadows}:await(async()=>{const t=await e.multiselect("Also add",[{value:"semantics",label:"Semantic colours",hint:"success · info · warning · danger"},{value:"neutral",label:"Neutral ramp",hint:"50 … 900"},{value:"shadows",label:"Shadow tints",hint:"3 alpha levels + the effects ramp"}],[0,1,2]);return{semantics:t.includes("semantics"),neutral:t.includes("neutral"),shadows:t.includes("shadows")}})(),y=null!==(s=t.contrast)&&void 0!==s?s:await e.select("Contrast target",[{value:"AA",label:"WCAG AA",hint:"4.5:1 body text"},{value:"AAA",label:"WCAG AAA",hint:"7:1 — expect heavier nudges"},{value:"none",label:"Skip",hint:"write the colours exactly as given"}]),w=void 0!==t.baseSize?Number(t.baseSize):await e.number("Base font size (px)",16,e=>e>0?void 0:"Must be greater than zero."),$=null!==(i=t.feel)&&void 0!==i?i:await e.select("Overall feel",Object.keys(Rs).map(e=>({value:e,label:Rs[e].label,hint:Rs[e].blurb}))),k=null!==(a=t.ratio)&&void 0!==a?a:await e.select("Type scale",ci.map(([e,t])=>({value:e,label:e,hint:t})),Math.max(0,ci.findIndex(([e])=>e===Rs[$].ratio))),x=null!==(l=t.reset)&&void 0!==l?l:await e.select("CSS reset",[{value:"preflight",label:"preflight",hint:"full normalization + an h1–h6 size map"},{value:"normalize",label:"normalize",hint:"the classic, no heading map"},{value:"none",label:"none",hint:"you already ship one"}]),j=null!==(c=t.format)&&void 0!==c?c:await e.select("Format",[{value:"ts",label:"theme.raw.ts",hint:"typed, `satisfies RawTheme`"},{value:"js",label:"theme.raw.js",hint:"plain ESM, no build step"},{value:"json",label:"theme.raw.json",hint:"portable, no code at all"}]);return{seed:u,mode:m?"manual":"auto",brandCount:g,scheme:h,extraColors:b,...v,contrast:y,baseFontSize:w,ratio:k,feel:$,reset:x,format:j}}function fi(e,t){const r=[],{contrast:n}=e.report;if(n.length){r.push(` ${Ys(`Contrast · ${n.length} pairings checked`)}`);for(const e of n){const t=e.nudge>0?`${Xs(`−${e.nudge}`)} ${Ks(`${e.ratioAfter} ${e.levelAfter}`)}`:Ys("unchanged"),n=e.unresolved?` ${Xs("! still short of the bar")}`:"";r.push(` ${e.name.padEnd(10)} ${String(e.ratioBefore).padStart(5)} ${t}${n}`)}r.push("")}const o=n.filter(e=>e.nudge>0).length;return r.push(` ${Ys(`${e.sections.length} subsystems · ${t} variables · 0 recipes`)}`),o&&r.push(` ${Ys(`${o} colour${1===o?"":"s"} darkened to clear the contrast bar`)}`),r}const pi="theme.config.ts";function mi(e){const t={};for(const r of e.split(",")){const[e,n]=r.split(":"),o=null==e?void 0:e.trim(),s=Number.parseFloat((null!=n?n:"").trim());o&&Number.isFinite(s)&&(t[o]=s)}return t}function hi(e,t,r){return`// Generated by \`refract import\` from ${r}.\n// DTCG carries property tokens ONLY — recipes, components, composition, and states are not imported.\n// The mapping is heuristic (subsystem inferred from \`$type\`/name; \`border\` composite colors dropped;\n// rem rounded to px). Review the seeded tokens, then hand-author the rest of your theme below.\nimport type { RawTheme } from "${e}/build";\n\nexport const raw: RawTheme = ${JSON.stringify(t,null,2)};\n`}function gi(e,t){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${us}";\nimport { raw } from "${t}";\n\n// Generated by \`refract import\`. This is your build config — edit it freely. Add adapter options at\n// construction (\`createCssAdapter({ … })\`) and extra targets (SC/JSON/…) as their packages install.\nexport default defineConfig({\n raw,\n targets: [\n { adapter: createCssAdapter(), outDir: "dist/theme" },\n ],\n});\n`}function bi(e){const t={};for(const[r,n]of Object.entries(e))"breakpoints"!==r&&(t[r]=n&&"object"==typeof n?Object.keys(n).length:0);return t}function vi(r){var n,o;const s=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),i=null!==(o=r.packageName)&&void 0!==o?o:ds(),a=t.isAbsolute(r.input)?r.input:t.resolve(s,r.input);if(!e.existsSync(a))throw new Error(`No DTCG document found at "${r.input}" (resolved to "${a}").`);let l;try{l=JSON.parse(e.readFileSync(a,"utf8"))}catch(e){throw new Error(`"${a}" is not valid JSON: ${e.message}`)}const c={};r.breakpointGroup&&(c.breakpointGroup=r.breakpointGroup),r.breakpoints&&Object.keys(r.breakpoints).length&&(c.breakpoints=r.breakpoints);const u=Oo(l,c),d=r.out?t.isAbsolute(r.out)?r.out:t.resolve(s,r.out):t.resolve(s,"theme.raw.ts");if(e.existsSync(d)&&!r.force)throw new Error(`${t.basename(d)} already exists at "${d}". Pass --force to overwrite it.`);let f;if(e.mkdirSync(t.dirname(d),{recursive:!0}),e.writeFileSync(d,hi(i,u,JSON.stringify(t.basename(a))),"utf8"),!r.rawOnly){if(f=t.resolve(t.dirname(d),pi),e.existsSync(f)&&!r.force)throw new Error(`${pi} already exists at "${f}". Pass --force to overwrite it, or --raw-only to skip writing a config.`);const n=`./${t.basename(d).replace(/\.(ts|mts|cts|tsx)$/,"")}`;e.writeFileSync(f,gi(i,n),"utf8")}return{inputFile:a,rawFile:d,configFile:f,sections:Object.keys(u),counts:bi(u)}}async function yi(e={}){var r;const n=null!==(r=e.cwd)&&void 0!==r?r:process.cwd(),{config:o,path:s}=await cs({cwd:n,configPath:e.configPath});if(!o.targets.length)throw new Error(`"${s}" has no targets to build.`);const i=function(e,t){if(void 0===t)return[...e];const r=e.filter(e=>e.name===t);if(r.length)return r;if(/^\d+$/.test(t)){const r=Number(t);if(r>=0&&r<e.length)return[e[r]]}const n=e.filter(e=>e.outDir===t);if(n.length)return n;throw new Error(`No target matched "${t}". Config has ${e.length} target(s): `+e.map((e,t)=>{var r;return null!==(r=e.name)&&void 0!==r?r:`#${t} (${e.outDir})`}).join(", ")+".")}(o.targets,e.target);if(void 0!==e.out&&i.length>1)throw new Error(`--out is ambiguous across ${i.length} targets; pass --target to pick one first.`);const a=t.dirname(s),l=[];for(const r of i){const s=void 0!==e.out?t.isAbsolute(e.out)?e.out:t.resolve(n,e.out):t.isAbsolute(r.outDir)?r.outDir:t.resolve(a,r.outDir),i=await os({raw:o.raw,adapter:r.adapter,outDir:s,helpers:r.helpers,emit:r.emit,media:o.media,units:o.units,baseFontSize:o.baseFontSize,guide:r.guide});l.push({name:r.name,adapter:r.adapter.name,outDir:i.outDir,files:i.files})}return{configPath:s,targets:l}}async function wi(r={}){var n;const o=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),{config:s,path:i}=await cs({cwd:o,configPath:r.configPath}),a=uo(s.raw,{adapter:Co()}),l=Yo(a),c=r.out?t.isAbsolute(r.out)?r.out:t.resolve(o,r.out):t.resolve(o,"tokens.json");e.mkdirSync(t.dirname(c),{recursive:!0}),e.writeFileSync(c,`${JSON.stringify(l,null,2)}\n`,"utf8");return{configPath:i,outFile:c,groupCount:Object.keys(l).filter(e=>!e.startsWith("$")).length}}async function $i(e={}){var t;const r=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:n,path:o}=await cs({cwd:r,configPath:e.configPath}),s=uo(n.raw,{adapter:Co()});return{configPath:o,result:gr(s,{strict:e.strict,minWcag:e.minWcag,largeText:e.largeText})}}const ki=(e,t)=>{try{return String(e.resolveToken(t))}catch{return null}},xi=e=>{var t;const r=[];for(const[n,o]of Object.entries(e.model.subsystems))for(const[e,s]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(s))r.push({subsystem:n,group:e,variant:t});return r},ji=(e,t,r,n)=>{var o,s,i;return Boolean(null===(i=null===(s=null===(o=e.model.subsystems[t])||void 0===o?void 0:o.ruleSets)||void 0===s?void 0:s[r])||void 0===i?void 0:i[n])};function Ai(e,t){const r=((e,t)=>{const r=new Set([...Object.keys(e.tokens),...Object.keys(t.tokens)]),n=[];for(const o of r){const r=o in e.tokens,s=o in t.tokens,i=r?ki(e,o):null,a=s?ki(t,o):null;r&&!s?n.push({path:o,before:i,after:null,kind:"removed"}):!r&&s?n.push({path:o,before:null,after:a,kind:"added"}):i!==a&&n.push({path:o,before:i,after:a,kind:"changed"})}return n.sort((e,t)=>e.path.localeCompare(t.path))})(e,t),n=((e,t)=>{var r,n,o,s,i,a,l,c;const u=e,d=t;if(!u.renderRecipe&&!d.renderRecipe)return[];const f=new Set,p=[...xi(e),...xi(t)].filter(e=>{const t=`${e.subsystem}.${e.group}.${e.variant}`;return!f.has(t)&&(f.add(t),!0)}),m=[];for(const{subsystem:f,group:h,variant:g}of p){const p=ji(e,f,h,g),b=ji(t,f,h,g),v=null!==(s=null!==(n=null===(r=d.getClass)||void 0===r?void 0:r.call(d,f,h,g))&&void 0!==n?n:null===(o=u.getClass)||void 0===o?void 0:o.call(u,f,h,g))&&void 0!==s?s:`${f}.${h}.${g}`;p&&!b?m.push({name:v,kind:"removed"}):!p&&b?m.push({name:v,kind:"added"}):(null!==(a=null===(i=u.renderRecipe)||void 0===i?void 0:i.call(u,f,h,g))&&void 0!==a?a:"")!==(null!==(c=null===(l=d.renderRecipe)||void 0===l?void 0:l.call(d,f,h,g))&&void 0!==c?c:"")&&m.push({name:v,kind:"changed"})}return m.sort((e,t)=>e.name.localeCompare(t.name))})(e,t),o=((e,t)=>{var r,n,o,s;const i=e=>e?{ratio:e.wcagRatio,level:e.wcagLevel,pass:e.pass}:null,a=e=>new Map(e.map(e=>[e.label,e])),l=a(gr(e).pairings),c=a(gr(t).pairings),u=new Set([...l.keys(),...c.keys()]),d=[];for(const e of u){const t=l.get(e),a=c.get(e),u=i(t),f=i(a);if((null==u?void 0:u.ratio)===(null==f?void 0:f.ratio)&&(null==u?void 0:u.level)===(null==f?void 0:f.level)&&Boolean(t)===Boolean(a))continue;const p=(null!==(r=null==t?void 0:t.pass)&&void 0!==r?r:null)!==(null!==(n=null==a?void 0:a.pass)&&void 0!==n?n:null)||(null!==(o=null==t?void 0:t.wcagLevel)&&void 0!==o?o:null)!==(null!==(s=null==a?void 0:a.wcagLevel)&&void 0!==s?s:null);d.push({label:e,before:u,after:f,crossed:p})}return d.sort((e,t)=>e.label.localeCompare(t.label))})(e,t);return{tokens:r,classes:n,contrast:o,summary:{tokensChanged:r.length,classesChanged:n.length,pairingsCrossed:o.filter(e=>e.crossed).length}}}const Si={fail:0,"AA-large":1,AA:2,AAA:3};let Ei=0;async function Ri(n){var o,s,i,a;if(!e.existsSync(n))throw new Error(`candidate theme not found at "${n}".`);let l;if(".json"===t.extname(n))l=JSON.parse(e.readFileSync(n,"utf8"));else if(".ts"===t.extname(n)){const{entry:e,cleanup:t}=await g(n);try{const t=await import(r.pathToFileURL(e).href);l=null!==(s=null!==(o=t.default)&&void 0!==o?o:t.raw)&&void 0!==s?s:t}finally{t()}}else{const e=await import(`${r.pathToFileURL(n).href}?v=${++Ei}`);l=null!==(a=null!==(i=e.default)&&void 0!==i?i:e.raw)&&void 0!==a?a:e}return function(e,t){const r=t?` (${t})`:"";if(null===e||"object"!=typeof e||Array.isArray(e)){const t=Array.isArray(e)?"an array":null===e?"null":typeof e;throw new w("REFRACT_E_RAW_SHAPE",`Expected a RawTheme object${r}, got ${t}. Pass the raw theme (a module's default export, or a .json raw theme).`)}if(Array.isArray(e.targets))throw new w("REFRACT_E_RAW_SHAPE",`Expected a RawTheme object${r}, but got what looks like a defineConfig({ raw, targets }). Pass its \`raw\` (or a module that default-exports the raw theme), not the whole config.`)}(l,n),l}async function Ci(e){var r,n,o,s,i,a,l,c;const u=null!==(r=e.cwd)&&void 0!==r?r:process.cwd(),{config:d,path:f}=await cs({cwd:u,configPath:e.configPath}),p=t.resolve(u,e.candidatePath),m=await Ri(p),h={units:d.units,baseFontSize:d.baseFontSize,media:d.media},g=d.targets.map((e,t)=>{var r,n;return{name:null!==(n=null!==(r=e.name)&&void 0!==r?r:e.outDir)&&void 0!==n?n:`target-${t}`,adapter:e.adapter}}),b=g.map(({name:e,adapter:t})=>{var r;try{return uo(m,{adapter:t,...h}),{name:e,ok:!0,errors:[]}}catch(t){const n=t;return{name:e,ok:!1,errors:n.failures?[...n.failures]:[null!==(r=n.message)&&void 0!==r?r:String(t)]}}}),v=null!==(o=null!==(n=g.find(({adapter:e})=>"function"==typeof uo(d.raw,{adapter:e,...h}).renderRecipe))&&void 0!==n?n:g[0])&&void 0!==o?o:{name:"noop",adapter:Co()},y=uo(d.raw,{adapter:v.adapter,...h});let w={tokens:[],classes:[],contrast:[],summary:{tokensChanged:0,classesChanged:0,pairingsCrossed:0}};try{w=Ai(y,uo(m,{adapter:v.adapter,...h}))}catch{}const $=[];if(void 0!==e.maxClassChanges&&w.summary.classesChanged>e.maxClassChanges&&$.push(`${w.summary.classesChanged} classes changed (max ${e.maxClassChanges})`),void 0!==e.maxTokenChanges&&w.summary.tokensChanged>e.maxTokenChanges&&$.push(`${w.summary.tokensChanged} tokens changed (max ${e.maxTokenChanges})`),e.failBelow){const t=null!==(s=Si[e.failBelow])&&void 0!==s?s:0;for(const r of w.contrast){const n=(null===(i=r.after)||void 0===i?void 0:i.level)&&null!==(a=Si[r.after.level])&&void 0!==a?a:0,o=(null===(l=r.before)||void 0===l?void 0:l.level)&&null!==(c=Si[r.before.level])&&void 0!==c?c:0;r.after&&n<t&&n<o&&$.push(`${r.label} drops to ${r.after.level} (below ${e.failBelow})`)}}const k=b.filter(e=>!e.ok).map(e=>e.name);return k.length&&$.push(`candidate no longer builds for: ${k.join(", ")}`),{configPath:f,candidatePath:p,diff:w,targets:b,ok:0===$.length,violations:$}}const Oi=["claude","codex","opencode","github-copilot","cursor","generic"],Ti={claude:{kind:"claude",routerFile:".claude/skills"},codex:{kind:"agents-md",routerFile:"AGENTS.md"},opencode:{kind:"agents-md",routerFile:"AGENTS.md"},"github-copilot":{kind:"agents-md",routerFile:".github/copilot-instructions.md"},cursor:{kind:"agents-md",routerFile:".cursor/rules/refract-skills.mdc"},generic:{kind:"agents-md",routerFile:"AGENTS.md"}},Fi="\x3c!-- refract-skills:start --\x3e",_i="\x3c!-- refract-skills:end --\x3e",Ni=t.join(".refract","skills.lock"),Pi=t.join(".refract","skills");function zi(e){return null!=e?e:t.join(u(),"skills")}function Mi(r){const n=zi(r);if(!e.existsSync(n))throw new Error(`Skills catalog not found at "${n}". Reinstall @theme-registry/refract.`);return e.readdirSync(n,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>t.join(n,e.name,"SKILL.md")).filter(e.existsSync).map(r=>function(e,r){var n,o,s;const i=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(e),a=i?i[1]:"",l=i?e.slice(i[0].length).replace(/^\s+/,""):e,c=e=>{const t=new RegExp(`^${e}:\\s*(.*)$`,"m").exec(a);return t?t[1].trim():void 0},u=null!==(o=null!==(n=c("name"))&&void 0!==n?n:t.dirname(r).split(/[\\/]/).pop())&&void 0!==o?o:"unnamed",d="optional"===c("tier")?"optional":"core";return{name:u,description:null!==(s=c("description"))&&void 0!==s?s:"",tier:d,raw:e,body:l,sourcePath:r}}(e.readFileSync(r,"utf8"),r)).sort((e,t)=>e.name.localeCompare(t.name))}function Li(e){const t=e.map(e=>`| [${e.name}](${Pi}/${e.name}.md) | ${function(e){const t=e.description.split(/\s*Triggers:/)[0].trim();return(t.split(/\.\s/)[0].trim()||t).replace(/\|/g,"\\|")}(e)} |`).join("\n");return[Fi,"","## refract theme skills","","These skills document the [refract](https://github.com/theme-registry/refract) theme toolkit.","When a task matches a row below, read the linked file before working.","","| Skill | Use it for |","| --- | --- |",t,"",_i].join("\n")}function qi(e,t){const r=e.indexOf(Fi),n=e.indexOf(_i);if(-1!==r&&-1!==n&&n>r)return e.slice(0,r)+t+e.slice(n+_i.length);const o=e.replace(/\s+$/,"");return o?`${o}\n\n${t}\n`:`${t}\n`}function Ii(r,n){e.mkdirSync(t.dirname(r),{recursive:!0}),e.writeFileSync(r,n,"utf8")}function Bi(r){var n,s,i;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(s=r.home)&&void 0!==s?s:o.homedir():null!==(i=r.cwd)&&void 0!==i?i:process.cwd(),c=function(e,t){if(t.skills&&t.skills.length>0){const r=new Map(e.map(e=>[e.name,e])),n=[];for(const o of t.skills){const t=r.get(o);if(!t)throw new Error(`Unknown skill "${o}". Available: ${e.map(e=>e.name).join(", ")}.`);n.push(t)}return n}return e.filter(e=>"core"===e.tier||t.includeOptional)}(Mi(r.catalogDir),r);if(0===r.agents.length)throw new Error("Pick at least one agent target.");const d=new Set;if(r.agents.some(e=>"agents-md"===Ti[e].kind))for(const e of c){const r=t.join(l,Pi,`${e.name}.md`);Ii(r,e.body),d.add(r)}for(const n of r.agents){const r=Ti[n];if("claude"===r.kind)for(const e of c){const n=t.join(l,r.routerFile,e.name,"SKILL.md");Ii(n,e.raw),d.add(n)}else{const n=t.join(l,r.routerFile);Ii(n,qi(e.existsSync(n)?e.readFileSync(n,"utf8"):"",Li(c))),d.add(n)}}const{name:f,version:p}=function(){var r,n;const o=JSON.parse(e.readFileSync(t.join(u(),"package.json"),"utf8"));return{name:null!==(r=o.name)&&void 0!==r?r:"@theme-registry/refract",version:null!==(n=o.version)&&void 0!==n?n:"0.0.0"}}(),m={schema:1,packageName:f,refractVersion:p,scope:a,agents:[...r.agents],skills:c.map(e=>e.name)},h=t.join(l,Ni);return Ii(h,`${JSON.stringify(m,null,2)}\n`),{scope:a,agents:[...r.agents],skills:c.map(e=>e.name),files:[...d].sort(),manifestPath:h}}function Ui(r={}){var n,s,i;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(s=r.home)&&void 0!==s?s:o.homedir():null!==(i=r.cwd)&&void 0!==i?i:process.cwd(),c=t.join(l,Ni);if(!e.existsSync(c))throw new Error(`No skills manifest at "${c}". Run \`refract skills install\` first.`);const u=JSON.parse(e.readFileSync(c,"utf8"));return Bi({agents:u.agents,scope:a,skills:u.skills,cwd:r.cwd,home:r.home,catalogDir:r.catalogDir})}const Di="refract — build a refract theme to disk.\n\nUsage:\n refract create [--seed <color>] [--colors <n|list>] [--scheme <name>] [--manual]\n [--feel <neutral|compact|editorial|technical>] [--ratio <name>]\n [--base-size <px>] [--contrast <AA|AAA|none>] [--reset <name>]\n [--format <ts|js|json>] [--out <file>] [--no-semantics]\n [--no-neutral] [--no-shadows] [--yes] [--force]\n refract init [--js | --mjs] [--force]\n refract import <tokens.json> [--out <file>] [--raw-only] [--force]\n [--breakpoint-group <name>] [--breakpoints <n:px,…>]\n refract build [--config <path>] [--target <name|index>] [--out <dir>]\n refract tokens [--config <path>] [--out <file>]\n refract diff <candidate> [--config <path>] [--max-class-changes <n>]\n [--max-token-changes <n>] [--fail-below <AA|AAA|AA-large>]\n refract audit [--config <path>] [--strict] [--min-wcag <AA|AAA|AA-large>] [--large]\n refract skills <install|list|update> [--agent <a,b|all>] [--global|--local]\n [--only <names>] [--optional]\n refract help\n\nCommands:\n create Design a theme.raw.(ts|js|json) from one seed colour and a short interview.\n init Scaffold a runnable theme.config.(ts|js|mjs) in the current directory.\n import Seed a theme.raw.ts (+ theme.config.ts) from a DTCG tokens.json (one-shot).\n build Load the config and emit every target's files to its outDir.\n tokens Export the theme's tokens as a DTCG tokens.json (adapter-free).\n diff Show a candidate theme's blast radius vs the config (tokens/classes/contrast); thresholds gate CI.\n audit Score colour pairings for WCAG-2 contrast (+ advisory APCA). Reports; --strict fails.\n skills Install the bundled AI skills into your agent CLI(s) (claude/codex/…).\n";function Vi(e,t){var r;const n=t,o="string"==typeof n.code&&n.code.startsWith("REFRACT_E_")?`[${n.code}] `:"";if(process.stderr.write(`refract ${e}: ${o}${null!==(r=n.message)&&void 0!==r?r:String(t)}\n`),n.failures)for(const e of n.failures)process.stderr.write(` - ${e}\n`);return 1}async function Wi(e){var t;const{values:r}=i.parseArgs({args:e,options:{seed:{type:"string"},colors:{type:"string"},scheme:{type:"string"},manual:{type:"boolean",default:!1},feel:{type:"string"},ratio:{type:"string"},"base-size":{type:"string"},contrast:{type:"string"},reset:{type:"string"},format:{type:"string"},out:{type:"string"},"no-semantics":{type:"boolean",default:!1},"no-neutral":{type:"boolean",default:!1},"no-shadows":{type:"boolean",default:!1},yes:{type:"boolean",default:!1},force:{type:"boolean",default:!1}},allowPositionals:!1}),n=new si(!r.yes&&void 0);try{n.write(),n.write(` ${Gs("refract")} ${Ys("· raw-theme scaffold")}`),n.write();const e=Vs({...await di(n,{seed:r.seed,colors:r.colors,scheme:r.scheme,manual:r.manual,feel:r.feel,ratio:r.ratio,baseSize:r["base-size"],contrast:r.contrast,reset:r.reset,format:r.format,noSemantics:r["no-semantics"],noNeutral:r["no-neutral"],noShadows:r["no-shadows"]}),out:r.out,force:Boolean(r.force)});n.write();for(const t of fi(e,function(e){try{const t=uo(e,{adapter:Co()});return Object.keys(t.tokens).length}catch{return 0}}(e.raw)))n.write(t);return n.write(),n.write(` ${Gs(null!==(t=e.path.split(/[\\/]/).pop())&&void 0!==t?t:"")} written`),n.write(),n.write(` ${Ys("Next — wire up a build:")} ${Gs("refract init")}`),n.write(),0}catch(e){return Vi("create",e)}finally{n.close()}}const Hi=new Set(["AAA","AA","AA-large"]);async function Gi(e){const[t,...r]=e;if("list"===t)try{for(const e of Mi())process.stdout.write(` ${e.name.padEnd(26)} [${e.tier}] ${e.description.split(/\s*Triggers:/)[0].trim().slice(0,80)}\n`);return 0}catch(e){return Vi("skills list",e)}const{values:n}=i.parseArgs({args:r,options:{agent:{type:"string"},global:{type:"boolean",default:!1},local:{type:"boolean",default:!1},only:{type:"string"},optional:{type:"boolean",default:!1}},allowPositionals:!1});if(n.global&&n.local)return process.stderr.write("refract skills: pass at most one of --global / --local.\n"),1;const o=n.global?"global":"local";try{if("update"===t){const e=Ui({scope:o});return process.stdout.write(`Updated ${e.skills.length} skill(s) for ${e.agents.join(", ")} (${e.scope}).\n`),0}if("install"===t||void 0===t){let e,t=Boolean(n.optional),r=o;if(n.agent)e=function(e){if("all"===e.trim())return[...Oi];const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=t.filter(e=>!Oi.includes(e));if(r.length>0)throw new Error(`unknown agent(s) ${r.map(e=>`"${e}"`).join(", ")}. Known: ${Oi.join(", ")}.`);return t}(n.agent);else{if(!process.stdin.isTTY)return process.stderr.write("refract skills install: pass --agent <a,b|all> (no TTY for prompts).\n"),1;{const o=await async function(){const e=s.createInterface({input:process.stdin,output:process.stdout});try{process.stdout.write("Install refract skills for which agent(s)?\n"),Oi.forEach((e,t)=>process.stdout.write(` ${t+1}) ${e}\n`));const t=await e.question("Enter numbers (comma-separated), or 'all': "),r="all"===t.trim()||""===t.trim()?[...Oi]:t.split(",").map(e=>Oi[Number(e.trim())-1]).filter(e=>Boolean(e));if(0===r.length)throw new Error("no agents selected.");return{agents:r,scope:(await e.question("Scope — [l]ocal (project) or [g]lobal (home)? [l]: ")).trim().toLowerCase().startsWith("g")?"global":"local",includeOptional:(await e.question("Include optional skills (adapter-scaffold, troubleshooting)? [y/N]: ")).trim().toLowerCase().startsWith("y")}}finally{e.close()}}();e=o.agents,t=o.includeOptional,n.global||n.local||(r=o.scope)}}const i=Bi({agents:e,scope:r,skills:n.only?n.only.split(",").map(e=>e.trim()).filter(Boolean):void 0,includeOptional:t});process.stdout.write(`Installed ${i.skills.length} skill(s) for ${i.agents.join(", ")} (${i.scope}):\n`);for(const e of i.files)process.stdout.write(` ${e}\n`);return process.stdout.write(` manifest → ${i.manifestPath}\n`),0}return process.stderr.write(`refract skills: unknown subcommand "${t}". Use install | list | update.\n`),1}catch(e){return Vi("skills",e)}}async function Yi(e){const[t,...r]=e;switch(t){case"create":return Wi(r);case"init":return async function(e){const{values:t}=i.parseArgs({args:e,options:{js:{type:"boolean",default:!1},mjs:{type:"boolean",default:!1},force:{type:"boolean",default:!1}},allowPositionals:!1});if(t.js&&t.mjs)return process.stderr.write("refract init: pass at most one of --js / --mjs.\n"),1;const r=t.mjs?"mjs":t.js?"js":"ts";try{const e=vs({variant:r,force:Boolean(t.force)});return e.rawTheme&&process.stdout.write(`Found ${e.rawTheme.filename} — wired it up.\n`),process.stdout.write(`Created ${e.path}\n`),process.stdout.write(e.rawTheme?"Next: run `refract build`.\n":"Next: edit the starter theme in the config (or run `refract create` to design one), then `refract build`.\n"),0}catch(e){return Vi("init",e)}}(r);case"import":return async function(e){const{values:t,positionals:r}=i.parseArgs({args:e,options:{out:{type:"string"},"raw-only":{type:"boolean",default:!1},force:{type:"boolean",default:!1},"breakpoint-group":{type:"string"},breakpoints:{type:"string"}},allowPositionals:!0}),n=r[0];if(!n)return process.stderr.write("refract import: pass the DTCG document to import, e.g. `refract import tokens.json`.\n"),1;if(r.length>1)return process.stderr.write(`refract import: unexpected extra argument "${r[1]}".\n`),1;try{const e=vi({input:n,out:t.out,rawOnly:Boolean(t["raw-only"]),force:Boolean(t.force),breakpointGroup:t["breakpoint-group"],breakpoints:t.breakpoints?mi(t.breakpoints):void 0});process.stdout.write(`Imported ${e.inputFile}\n`),process.stdout.write(` raw → ${e.rawFile}\n`),e.configFile&&process.stdout.write(` config → ${e.configFile}\n`);const r=Object.entries(e.counts).map(([e,t])=>`${e} (${t})`).join(", ");return r&&process.stdout.write(` seeded: ${r}\n`),process.stdout.write("Next: review the inferred tokens, then add recipes/components and run `refract build`.\n"),0}catch(e){return Vi("import",e)}}(r);case"build":return async function(e){const{values:t}=i.parseArgs({args:e,options:{config:{type:"string"},target:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await yi({configPath:t.config,target:t.target,out:t.out});process.stdout.write(`Built from ${e.configPath}\n`);for(const t of e.targets){const e=t.name?`${t.name} [${t.adapter}]`:t.adapter;process.stdout.write(` ${e} → ${t.outDir} (${t.files.length} file(s))\n`);for(const e of t.files)process.stdout.write(` ${e}\n`)}return 0}catch(e){return Vi("build",e)}}(r);case"tokens":return async function(e){const{values:t}=i.parseArgs({args:e,options:{config:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await wi({configPath:t.config,out:t.out});return process.stdout.write(`Exported tokens from ${e.configPath}\n`),process.stdout.write(` ${e.groupCount} group(s) → ${e.outFile}\n`),0}catch(e){return Vi("tokens",e)}}(r);case"diff":return async function(e){var t,r,n,o;const{values:s,positionals:a}=i.parseArgs({args:e,options:{config:{type:"string"},"max-class-changes":{type:"string"},"max-token-changes":{type:"string"},"fail-below":{type:"string"}},allowPositionals:!0}),l=a[0];if(!l)return process.stderr.write("refract diff: pass the candidate theme, e.g. `refract diff candidate.ts`.\n"),1;const c=s["fail-below"];if(void 0!==c&&!Hi.has(c))return process.stderr.write(`refract diff: --fail-below must be one of AAA | AA | AA-large (got "${c}").\n`),1;try{const e=await Ci({configPath:s.config,candidatePath:l,maxClassChanges:void 0!==s["max-class-changes"]?Number(s["max-class-changes"]):void 0,maxTokenChanges:void 0!==s["max-token-changes"]?Number(s["max-token-changes"]):void 0,failBelow:c}),{diff:i}=e;process.stdout.write(`Diffed ${e.candidatePath}\n vs ${e.configPath}\n`),process.stdout.write(` ${i.summary.tokensChanged} token(s), ${i.summary.classesChanged} class(es), ${i.summary.pairingsCrossed} pairing(s) crossed a threshold\n`);for(const e of i.tokens.slice(0,20)){const t="changed"===e.kind?`${e.before} → ${e.after}`:"added"===e.kind?`+ ${e.after}`:`- ${e.before}`;process.stdout.write(` token ${e.path}: ${t}\n`)}i.tokens.length>20&&process.stdout.write(` … +${i.tokens.length-20} more token(s)\n`);for(const e of i.classes)process.stdout.write(` class ${e.kind.padEnd(7)} ${e.name}\n`);for(const e of i.contrast.filter(e=>e.crossed))process.stdout.write(` contrast ${e.label}: ${null!==(r=null===(t=e.before)||void 0===t?void 0:t.level)&&void 0!==r?r:"—"} → ${null!==(o=null===(n=e.after)||void 0===n?void 0:n.level)&&void 0!==o?o:"—"}\n`);if(e.violations.length){process.stderr.write("✗ diff gate failed:\n");for(const t of e.violations)process.stderr.write(` ${t}\n`);return 1}return 0}catch(e){return Vi("diff",e)}}(r);case"audit":return async function(e){const{values:t}=i.parseArgs({args:e,options:{config:{type:"string"},strict:{type:"boolean",default:!1},"min-wcag":{type:"string"},large:{type:"boolean",default:!1}},allowPositionals:!1}),r=t["min-wcag"];if(void 0!==r&&!Hi.has(r))return process.stderr.write(`refract audit: --min-wcag must be one of AAA | AA | AA-large (got "${r}").\n`),1;try{const{configPath:e,result:n}=await $i({configPath:t.config,strict:t.strict,minWcag:r,largeText:t.large});process.stdout.write(`Audited ${e}\n`);for(const e of n.pairings)if(e.skipped)process.stdout.write(` ~ ${e.label} — skipped (${e.skipped})\n`);else{const t=e.pass?"✓":"✗";process.stdout.write(` ${t} ${e.label} — ${e.wcagRatio}:1 ${e.wcagLevel} · APCA Lc ${e.apcaLc}\n`)}const o=n.summary;return process.stdout.write(`${o.passed}/${o.total} pass, ${o.failed} fail, ${o.skipped} skipped\n`),0}catch(e){return Vi("audit",e)}}(r);case"skills":return Gi(r);case void 0:case"help":case"--help":case"-h":return process.stdout.write(Di),0;default:return process.stderr.write(`refract: unknown command "${t}".\n\n${Di}`),1}}"undefined"!=typeof require&&"undefined"!=typeof module&&require.main===module&&Yi(process.argv.slice(2)).then(e=>process.exit(e),e=>{var t;process.stderr.write(`refract: ${null!==(t=e.stack)&&void 0!==t?t:e}\n`),process.exit(1)}),exports.AGENT_TARGETS=Oi,exports.CSS_ADAPTER_PACKAGE=us,exports.DEFAULT_RAW_BASENAME=Ms,exports.FEEL_PRESETS=Rs,exports.Prompter=si,exports.SCHEME_HINTS=li,exports.TYPE_SCALE_CHOICES=ci,exports.VENDOR_HELPERS=l,exports.applyKey=ni,exports.bold=Gs,exports.buildGuide=y,exports.compileTsConfigGraph=g,exports.createReportLines=fi,exports.cyan=Js,exports.decodeKey=ti,exports.decodeKeys=ri,exports.defaultSchemeFor=Ns,exports.defineConfig=e=>e,exports.deriveLeading=Ts,exports.deriveTracking=Fs,exports.diffThemes=Ai,exports.dim=Ys,exports.emitTheme=os,exports.findConfigFile=as,exports.findPackageRoot=u,exports.findRawTheme=ms,exports.findVendorHelper=c,exports.green=Ks,exports.listSkills=Mi,exports.loadConfig=cs,exports.main=Yi,exports.nearestLadderStep=_s,exports.parseBreakpointsFlag=mi,exports.promptCreateAnswers=di,exports.rawThemeImport=hs,exports.readOwnPackageName=ds,exports.readVendorSource=d,exports.renderRawTheme=Us,exports.resolveEmitPlan=xo,exports.runAudit=$i,exports.runBuild=yi,exports.runCreate=Vs,exports.runDiff=Ci,exports.runImport=vi,exports.runInit=vs,exports.runSkillsInstall=Bi,exports.runSkillsUpdate=Ui,exports.runTokens=wi,exports.scaffoldConfig=bs,exports.scaffoldConfigForRaw=gs,exports.scaffoldImportConfig=gi,exports.scaffoldRaw=hi,exports.scaffoldTheme=zs,exports.schemesFor=Ps,exports.skillsCatalogDir=zi,exports.swatch=ei,exports.transpileToEsm=p,exports.yellow=Xs;
|
|
1
|
+
"use strict";var e=require("node:fs"),t=require("node:path"),r=require("node:url"),n=require("node:readline"),o=require("node:os"),s=require("node:readline/promises"),i=require("node:util"),a="undefined"!=typeof document?document.currentScript:null;const l=[{id:"color-math",outfile:"color-math.js",source:"src/subsystems/colors/utils.ts",exports:["lighten","darken","alpha","setL","rotateHue","complement","adjust","rgbToOklch","oklchToRgb","toHexColor","toOklchColor","convertHexToRGB","convertRgbToHex"],description:"Pure OKLCH colour math — the exact lighten/darken/setL/rotateHue/complement/adjust (+ OKLCH and hex converters) refract synthesizes palette steps/variants with, so a value computed live in the consumer matches the emitted CSS variables."}],c=e=>l.find(t=>t.id===e),u=(n=(()=>"undefined"!=typeof __dirname?__dirname:t.dirname(r.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("build.cjs.js",document.baseURI).href)))())=>{let o=n;for(;;){if(e.existsSync(t.join(o,"package.json")))return o;const r=t.dirname(o);if(r===o)throw new Error(`No package.json found walking up from "${n}".`);o=r}},d=r=>{const n=t.join(u(),r);if(!e.existsSync(n))throw new Error(`Vendor helper source "${r}" not found at "${n}". Ensure it is listed in package.json "files" so it ships with the package.`);return e.readFileSync(n,"utf8")},f=["transpileModule","createProgram"];async function p(){var e;let t;try{t=await import("typescript")}catch{throw new Error('refract: the optional peer dependency "typescript" is required to transpile a `.ts` theme.config or vendor a shared helper module, but it could not be resolved. Install it (`npm i -D typescript@5`), or use a `.mjs`/`.js` config and avoid the `helpers` opt-in.')}const r=null!==(e=t.default)&&void 0!==e?e:t,n=f.filter(e=>"function"!=typeof(null==r?void 0:r[e]));if(n.length>0){const e=null==r?void 0:r.version;throw new Error(`refract: the installed "typescript" (${null!=e?e:"unknown version"}) does not expose the compiler API refract needs (missing: ${n.join(", ")}). TypeScript 7 moved these behind \`./unstable/*\` subpaths, which are explicitly not a stability promise, so refract does not use them. Install \`typescript@5\` (\`npm i -D typescript@5\`), or switch to a \`.mjs\`/\`.js\` theme.config — those are imported directly and never load typescript.`)}return r}const m=async e=>{const t=await p();return t.transpileModule(e,{compilerOptions:{module:t.ModuleKind.ESNext,target:t.ScriptTarget.ES2020}}).outputText};let h=0;const g=e=>t.resolve(e).replace(/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/,""),b=async r=>{const n=await p(),o={module:n.ModuleKind.ESNext,target:n.ScriptTarget.ES2020,moduleResolution:n.ModuleResolutionKind.Bundler,resolveJsonModule:!0,allowJs:!1,noLib:!0,skipLibCheck:!0,noEmitOnError:!1,declaration:!1,sourceMap:!1,types:[]},s=n.createCompilerHost(o),i=n.createProgram([r],o,s),a=new Map,l=e=>!e.isDeclarationFile&&!e.fileName.includes("/node_modules/")&&/\.(ts|tsx|mts|cts)$/.test(e.fileName);for(const e of i.getSourceFiles()){if(!l(e))continue;const r=t.resolve(e.fileName),n=t.basename(r).replace(/\.(ts|tsx|mts|cts)$/,"");a.set(g(r),t.join(t.dirname(r),`.${n}.${process.pid}-${h++}.mjs`))}const c=e=>r=>{const i=t.resolve(r.fileName),l=e.factory,c=e=>{const r=((e,t)=>{var r;if(!e.startsWith("."))return;const i=null===(r=n.resolveModuleName(e,t,o,s).resolvedModule)||void 0===r?void 0:r.resolvedFileName;return i?a.get(g(i)):void 0})(e,i);return r?l.createStringLiteral(`./${t.basename(r)}`):void 0},u=t=>{if(n.isImportDeclaration(t)&&n.isStringLiteral(t.moduleSpecifier)){const e=c(t.moduleSpecifier.text);if(e)return l.updateImportDeclaration(t,t.modifiers,t.importClause,e,t.attributes)}else if(n.isExportDeclaration(t)&&t.moduleSpecifier&&n.isStringLiteral(t.moduleSpecifier)){const e=c(t.moduleSpecifier.text);if(e)return l.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,e,t.attributes)}else if(n.isCallExpression(t)&&t.expression.kind===n.SyntaxKind.ImportKeyword&&t.arguments.length&&n.isStringLiteral(t.arguments[0])){const e=c(t.arguments[0].text);if(e)return l.updateCallExpression(t,t.expression,t.typeArguments,[e,...t.arguments.slice(1)])}return n.visitEachChild(t,u,e)};return n.visitNode(r,u)},u=[],d=(t,r)=>{const n=a.get(g(t));n&&(e.writeFileSync(n,r,"utf8"),u.push(n))},f=()=>{for(const t of u)e.rmSync(t,{force:!0})};try{i.emit(void 0,d,void 0,!1,{before:[c]})}catch(e){throw f(),e}const m=a.get(g(r));if(!m||!e.existsSync(m))throw f(),new Error(`refract: failed to compile the \`.ts\` config graph for "${r}".`);return{entry:m,cleanup:f}},v=e=>e.replace(/\|/g,"\\|");function y(e,t,r){var n;const o=[];if(o.push(`# Theme consumption guide (${e.format})`),o.push(""),o.push("This folder is a self-contained theme built with refract. You do NOT need refract to use it —","everything below refers to files in THIS folder (relative paths), so it works whether the theme","was installed as a package, unzipped from an artifact, or vendored into a repo."),o.push(""),t.files.length>0){o.push("## Files"),o.push("");for(const e of t.files)o.push(`- \`./${e}\``);o.push("")}o.push("## How to use"),o.push("");for(const t of e.summary)o.push(t);t.packageName&&(o.push(""),o.push(`If this theme is installed as the \`${t.packageName}\` package, you may import the same`,`files by specifier (e.g. \`${t.packageName}/${null!==(n=t.files[0])&&void 0!==n?n:"theme.css"}\`) instead of by relative path.`)),o.push("");const{recipes:s}=e;if(s.length>0){o.push("## Recipes — real names"),o.push(""),o.push("Use these exact identities; do not invent names."),o.push(""),o.push("| Recipe | Identity |"),o.push("| --- | --- |");const e=s.slice(0,60);for(const t of e)o.push(`| \`${v(`${t.subsystem}.${t.group}.${t.variant}`)}\` | \`${v(t.name)}\` |`);if(s.length>e.length){const t=s.length-e.length;o.push(""),o.push(`_(+${t} more recipe(s) — the complete list is in ${r?`\`./${r}\``:"the manifest"}.)_`)}o.push("")}return r&&(o.push("## Machine-readable index"),o.push(""),o.push(`See \`./${r}\` for the full recipe index and the theme's tokens (DTCG format).`),o.push("")),o.join("\n")}function w(e,t,r){var n;const o=null!==(n=r.llmsFile)&&void 0!==n?n:"llms.txt",s=void 0===r.manifestFile?"manifest.json":r.manifestFile,i={[o]:y(e,r,s)};if(s){const n={schema:1,format:e.format,files:r.files,packageName:r.packageName,recipes:e.recipes,tokens:t};i[s]=`${JSON.stringify(n,null,2)}\n`}return{files:i}}const $=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),k=e=>$(String(e).replace(/[;{}<>]/g,"").trim());function x(e,t,r,n){if(!e||"object"!=typeof e||Array.isArray(e))return;const o=e,s="string"==typeof o.$type?o.$type:r;if("$value"in o)n.push({path:t,type:s,value:o.$value});else for(const[e,r]of Object.entries(o))e.startsWith("$")||x(r,[...t,e],s,n)}const j="The quick brown fox";function A(e){const t=e.value,r=`<code class="rfp-val">${$(String(t))}</code>`;switch(e.type){case"color":return`<span class="rfp-chip" style="background:${k(t)}"></span>${r}`;case"shadow":return`<span class="rfp-box" style="box-shadow:${k(t)}"></span>${r}`;case"border":return`<span class="rfp-box" style="border:${k(t)}"></span>${r}`;case"fontFamily":return`<span class="rfp-specimen" style="font-family:${k(t)}">${j}</span>${r}`;case"fontWeight":return`<span class="rfp-specimen" style="font-weight:${k(t)}">${j}</span>${r}`;case"dimension":return"typography"===e.path[0]&&"fontSize"===e.path[1]?`<span class="rfp-specimen" style="font-size:${k(t)}">${j}</span>${r}`:`<span class="rfp-bar" style="width:${k(t)}"></span>${r}`;default:return r}}function S(e){var t;const r=[];if(x(e,[],void 0,r),0===r.length)return'<p class="rfp-note">This theme declares no tokens.</p>';const n=new Map;for(const e of r){const r=null!==(t=e.path[0])&&void 0!==t?t:"tokens",o=n.get(r);o?o.push(e):n.set(r,[e])}const o=[];for(const[e,t]of n){const r=t.map(t=>`<li class="rfp-row"><span class="rfp-name">${$(t.path.slice(1).join(".")||e)}</span><span class="rfp-swatch">${A(t)}</span></li>`).join("\n");o.push(`<section class="rfp-plate">\n<h3 class="rfp-plate-title">${$(e)} <span class="rfp-count">${t.length}</span></h3>\n<ul class="rfp-rows">\n${r}\n</ul>\n</section>`)}return o.join("\n")}function E(e,t){var r,n;const o=null===(r=null==t?void 0:t.markup)||void 0===r?void 0:r.call(t,e);if(!o)return;const s=null!==(n=o.tag)&&void 0!==n?n:function(e){const t=e.group.toLowerCase();return t.includes("button")||t.includes("btn")?"button":t.includes("link")||t.includes("anchor")?"a":t.includes("badge")||t.includes("chip")||t.includes("tag")||t.includes("label")?"span":"div"}(e);return`<${s}${Object.entries(o.attrs).map(([e,t])=>` ${$(e)}="${$(t)}"`).join("")}>${$(e.variant)}</${s}>`}function R(e,t,r){var n,o;if(0===e.recipes.length)return'<p class="rfp-note"><strong>No recipes yet — this theme is tokens only.</strong> Tokens are values; recipes are the rule-sets that turn them into styled components (a button, a card). Add a <code>recipes</code> block to a subsystem in your raw theme and rebuild — they\'ll render here.</p>';const s=new Map;for(const r of e.recipes){const e=null!==(o=null===(n=null==t?void 0:t.groupBy)||void 0===n?void 0:n.call(t,r))&&void 0!==o?o:"",i=s.get(e);i?i.push(r):s.set(e,[r])}const i=[];for(const[e,n]of s){const o=n.map(e=>{const n=r?E(e,t):void 0,o=`${e.subsystem}.${e.group}.${e.variant}`;return'<li class="rfp-recipe">'+(n?`<div class="rfp-stage">${n}</div>`:"")+`<div class="rfp-meta"><span class="rfp-name">${$(o)}</span>`+`<code class="rfp-val">${$(e.name)}</code></div></li>`}).join("\n"),s=e?`<h3 class="rfp-plate-title">${$(e)} <span class="rfp-count">${n.length}</span></h3>\n`:"";i.push(`<section class="rfp-plate">\n${s}<ul class="rfp-recipes">\n${o}\n</ul>\n</section>`)}return i.join("\n")}function O(e){var t,r;const n=[];for(const o of Object.values(e.subsystems))for(const e of Object.values(null!==(t=o.properties)&&void 0!==t?t:{}))for(const t of null!==(r=e.modes)&&void 0!==r?r:[])t.mode&&!n.includes(t.mode)&&n.push(t.mode);return n}const C='\n.rfp-root{font:14px/1.5 ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;color:#111;background:#fff;\n max-width:1100px;margin:0 auto;padding:24px;box-sizing:border-box}\n.rfp-head{display:flex;flex-wrap:wrap;gap:12px;align-items:baseline;justify-content:space-between;\n border-bottom:1px solid #e5e5e5;padding-bottom:12px;margin-bottom:20px}\n.rfp-title{font-size:20px;font-weight:600;margin:0}\n.rfp-sub{color:#666;font-size:12px}\n.rfp-controls{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:20px}\n.rfp-controls button{font:inherit;font-size:12px;padding:4px 10px;border:1px solid #ccc;border-radius:6px;\n background:#fafafa;color:#111;cursor:pointer}\n.rfp-controls button[aria-pressed="true"]{background:#111;border-color:#111;color:#fff}\n.rfp-group-label{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:#888;align-self:center;\n margin-right:4px}\n.rfp-section-title{font-size:15px;font-weight:600;margin:28px 0 10px}\n.rfp-plate{border:1px solid #e5e5e5;border-radius:8px;padding:14px 16px;margin-bottom:14px;background:#fff}\n.rfp-plate-title{font-size:13px;font-weight:600;margin:0 0 10px;color:#333}\n.rfp-count{color:#999;font-weight:400}\n.rfp-rows,.rfp-recipes{list-style:none;margin:0;padding:0}\n.rfp-row{display:grid;grid-template-columns:minmax(120px,220px) 1fr;gap:12px;align-items:center;\n padding:5px 0;border-top:1px solid #f2f2f2}\n.rfp-row:first-child{border-top:0}\n.rfp-name{font-size:12px;color:#444;overflow-wrap:anywhere}\n.rfp-swatch{display:flex;align-items:center;gap:10px;min-width:0;overflow:hidden}\n.rfp-val{font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;color:#666;background:#f6f6f6;\n padding:1px 5px;border-radius:4px;white-space:nowrap}\n.rfp-chip{width:28px;height:28px;border-radius:5px;border:1px solid rgba(0,0,0,.15);flex:none}\n.rfp-box{width:44px;height:28px;border-radius:5px;background:#fff;border:1px solid rgba(0,0,0,.08);flex:none}\n.rfp-bar{height:10px;background:#111;border-radius:2px;flex:none;max-width:100%}\n.rfp-specimen{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}\n.rfp-recipes{display:flex;flex-wrap:wrap;gap:14px}\n.rfp-recipe{border:1px solid #eee;border-radius:8px;padding:12px;min-width:160px;background:#fff}\n.rfp-stage{display:flex;align-items:center;justify-content:center;min-height:56px;margin-bottom:8px}\n.rfp-meta{display:flex;flex-direction:column;gap:3px;align-items:flex-start}\n.rfp-note{font-size:13px;color:#555;background:#f8f8f8;border:1px solid #ececec;border-left:3px solid #bbb;\n border-radius:0 6px 6px 0;padding:10px 14px;margin:0 0 14px}\n.rfp-frame{margin:0 auto;transition:max-width .15s ease}\n.rfp-files{font-size:12px;color:#666;margin:0 0 16px}\n.rfp-files code{font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}\n@media (prefers-color-scheme:dark){\n .rfp-root{color:#eee;background:#151515}\n .rfp-head{border-bottom-color:#2c2c2c}\n .rfp-plate,.rfp-recipe{background:#1c1c1c;border-color:#2c2c2c}\n .rfp-plate-title{color:#ddd}.rfp-name{color:#bbb}.rfp-sub,.rfp-files{color:#999}\n .rfp-val{background:#262626;color:#aaa}\n .rfp-controls button{background:#222;border-color:#3a3a3a;color:#eee}\n .rfp-controls button[aria-pressed="true"]{background:#eee;border-color:#eee;color:#111}\n .rfp-note{background:#1d1d1d;border-color:#2c2c2c;border-left-color:#555;color:#bbb}\n .rfp-row{border-top-color:#242424}\n .rfp-bar{background:#eee}\n}\n'.trim(),T='\n(function(){\n var root=document.documentElement;\n function bind(sel,onPick){\n var btns=[].slice.call(document.querySelectorAll(sel));\n btns.forEach(function(b){\n b.addEventListener("click",function(){\n btns.forEach(function(o){o.setAttribute("aria-pressed",String(o===b));});\n onPick(b.getAttribute("data-value"));\n });\n });\n }\n bind("[data-rfp-mode]",function(v){\n var attr=root.getAttribute("data-rfp-mode-attr");\n if(!attr)return;\n if(v)root.setAttribute(attr,v);else root.removeAttribute(attr);\n });\n bind("[data-rfp-width]",function(v){\n var frame=document.getElementById("rfp-frame");\n if(frame)frame.style.maxWidth=v?v+"px":"";\n });\n})();\n'.trim();function F(e,t,r){const n=[];if(t&&e.length>0){const t=['<button type="button" data-rfp-mode data-value="" aria-pressed="true">auto</button>'].concat(e.map(e=>`<button type="button" data-rfp-mode data-value="${$(e)}" aria-pressed="false">${$(e)}</button>`)).join("");n.push(`<div class="rfp-controls"><span class="rfp-group-label">mode</span>${t}</div>`)}const o=Object.entries(r);if(o.length>0){const e=['<button type="button" data-rfp-width data-value="" aria-pressed="true">full</button>'].concat(o.map(([e,t])=>`<button type="button" data-rfp-width data-value="${$(String(t))}" aria-pressed="false">${$(e)} · ${$(String(t))}px</button>`)).join("");n.push(`<div class="rfp-controls"><span class="rfp-group-label">width</span>${e}</div>`)}return n.join("\n")}function N(e,t,r){return e.map(e=>{const n=r?null==t?void 0:t[e]:void 0;return void 0===n?`<link rel="stylesheet" href="./${$(e)}">`:`<style data-rfp-source="${$(e)}">\n${o=n,o.replace(/<\/(?=[a-zA-Z])/g,"<\\/")}\n</style>`;var o}).join("\n")}function _(e,t){var r,n,o,s,i,a,l;const{usage:c,preview:u,tokens:d,model:f}=e,p=null!==(r=t.file)&&void 0!==r?r:"preview.html",m=null===(n=t.inline)||void 0===n||n,h=new Set(t.files),g=(null!==(o=null==u?void 0:u.stylesheets)&&void 0!==o?o:[]).filter(e=>h.has(e)),b=g.length>0,v=O(f),y=null!==(s=f.breakpoints)&&void 0!==s?s:{},w=null!==(i=t.title)&&void 0!==i?i:`${c.format} theme preview`,k=[];b||k.push(null!==(a=null==u?void 0:u.unavailable)&&void 0!==a?a:`This theme was built with the ${c.format} adapter, whose output a browser can't load directly — token values below are exact, but recipes are listed by name only.`);for(const e of null!==(l=null==u?void 0:u.notes)&&void 0!==l?l:[])k.push(e);const x=['<meta charset="utf-8">','<meta name="viewport" content="width=device-width,initial-scale=1">',`<title>${$(w)}</title>`,N(g,t.contents,m),`<style>\n${C}\n</style>`].filter(Boolean).join("\n"),j=null==u?void 0:u.modeAttribute,A=t.files.length?`<p class="rfp-files">Built files: ${t.files.map(e=>`<code>${$(e)}</code>`).join(" · ")}</p>`:"",E=['<div class="rfp-root">','<header class="rfp-head">',`<h1 class="rfp-title">${$(w)}</h1>`,`<span class="rfp-sub">format <strong>${$(c.format)}</strong> · emit <strong>${$(t.plan.type)}</strong> · ${c.recipes.length} recipe(s)</span>`,"</header>",A,k.map(e=>`<p class="rfp-note">${$(e)}</p>`).join("\n"),F(v,j,y),'<div class="rfp-frame" id="rfp-frame">','<h2 class="rfp-section-title">Tokens</h2>',S(d),'<h2 class="rfp-section-title">Recipes</h2>',R(c,u,b),"</div>","</div>",`<script>\n${T}\n<\/script>`].filter(Boolean).join("\n"),_=`<!doctype html>\n<html lang="en"${j?` data-rfp-mode-attr="${$(j)}"`:""}>\n<head>\n${x}\n</head>\n<body>\n${E}\n</body>\n</html>\n`;return{files:{[p]:_}}}class P extends Error{constructor(e,t,r){super(t),this.name="RefractError",this.code=e,r&&(this.failures=r),Object.setPrototypeOf(this,P.prototype)}}const z=e=>"string"==typeof e||"number"==typeof e,M=e=>Array.isArray(e),q=e=>({value:e}),L=(e,t)=>{if(!t)return q(e);const r={ref:t.ref};return void 0!==t.fn&&(r.fn=t.fn),void 0!==t.arg&&(r.arg=t.arg),void 0!==t.modifiers&&(r.modifiers=t.modifiers),void 0!==e&&(r.value=e),r},I=new Set(["mode","target","base","derive"]),B=(e,t,r)=>{const n={},o=e.derive,s=e.base;if(o){if(void 0===o.ref)throw new P("REFRACT_E_REFERENCE",`Derived appearance mode "${t}.modes.${r}" was not baked — derived modes require a subsystem that resolves them (colors). Use a literal value instead.`);n.base=L(z(s)?s:void 0,o)}else z(s)?n.base=q(s):M(s)&&(n.base={struct:s});for(const[t,r]of Object.entries(e))I.has(t)||z(r)&&(n[t]=q(r));return n},U=(e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||z(o)&&(r[n]=q(o));return r},D=new Set(["base","derive"]),W=new Set(["base","responsive","variants","modes","external"]),V=new Set(["breakpoint","query","state","orientation","ref","modifiers","mode","variant","target","derive","ratio","step","steps"]),H=(e,t="property")=>{var r;const n={base:void 0!==e.external?{value:`var(${e.external})`,external:e.external}:(o=e.base,M(o)?{struct:o}:q(o))};var o;const s=U(e,W);if(Object.keys(s).length&&(n.extras=s),e.variants&&Object.keys(e.variants).length){const t={};for(const[r,n]of Object.entries(e.variants)){let e;const o=n.derive;if(z(n.base)?e=L(n.base,o):M(n.base)?e={struct:n.base}:void 0!==(null==o?void 0:o.ref)&&(e=L(void 0,o)),!e)continue;const s=U(n,D);t[r]=Object.keys(s).length?{base:e,extras:s}:{base:e}}Object.keys(t).length&&(n.variants=t)}const i=e.modes;if(i&&i.length){const e=[];for(const r of i){const n=r.mode,o=B(r,t,n);if(!Object.keys(o).length)continue;const s={mode:n,overrides:o};"string"==typeof r.target&&(s.target=r.target),e.push(s)}e.length&&(n.modes=e)}if(null===(r=e.responsive)||void 0===r?void 0:r.length){const t=e.responsive.map(e=>{const t=e,r={breakpoint:t.breakpoint};"string"==typeof t.query&&(r.query=t.query),"string"==typeof t.orientation&&(r.orientation=t.orientation),"string"==typeof t.ref&&(r.ref=t.ref),"string"==typeof t.mode&&(r.mode=t.mode),"string"==typeof t.target&&(r.target=t.target);const n=((e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||(z(o)?r[n]=q(o):M(o)&&(r[n]={struct:o}));return r})(t,V),o=t.derive;return o&&n.base&&void 0!==n.base.value&&(n.base=L(n.base.value,o)),Object.keys(n).length&&(r.overrides=n),r});n.responsive=t}return n},G=e=>({kind:"recipe",declarations:{...e.base},overrides:e.responsive.map(e=>{const t={};return void 0!==e.state&&(t.state=e.state),void 0!==e.breakpoint&&(t.breakpoint=e.breakpoint),void 0!==e.query&&(t.query=e.query),void 0!==e.orientation&&(t.orientation=e.orientation),void 0!==e.container&&(t.container=e.container),void 0!==e.size&&(t.size=e.size),void 0!==e.variant&&(t.variant=e.variant),void 0!==e.target&&(t.target=e.target),Object.keys(e.declarations).length&&(t.declarations={...e.declarations}),t})}),Y=(e,t)=>{const r=G(e);return r.kind="recipe",t.length&&(r.references=t),r},J=new Set(["colors","typography","layout","effects","borders"]),K=e=>!!e&&Object.keys(e).length>0,X=e=>{var t;if(!e)return;const r={};return e.properties&&Object.keys(e.properties).length&&(r.properties=(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]=H(n,r);return t})(e.properties)),e.extraProperties&&Object.keys(e.extraProperties).length&&(r.properties={...null!==(t=r.properties)&&void 0!==t?t:{},...e.extraProperties}),K(e.ruleSetGroups)&&(r.ruleSets=e.ruleSetGroups),K(e.keyframes)&&(r.keyframes=e.keyframes),Object.keys(r).length?r:void 0},Z=e=>{var t,r,n,o;const s={};for(const[i,a]of Object.entries(e.subsystems))for(const[e,l]of Object.entries(null!==(t=a.properties)&&void 0!==t?t:{})){const t=`${i}.${e}`;s[t]=l.base;for(const[e,o]of Object.entries(null!==(r=l.variants)&&void 0!==r?r:{})){s[`${t}.${e}`]=o.base;for(const[r,i]of Object.entries(null!==(n=o.extras)&&void 0!==n?n:{}))s[`${t}.${e}.${r}`]=i}for(const[e,r]of Object.entries(null!==(o=l.extras)&&void 0!==o?o:{}))s[`${t}.${e}`]=r}return s},Q=new Set(["px","cm","mm","q","in","pc","pt","rem","em","ex","cap","ch","ic","lh","rlh","%","vw","vh","vi","vb","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh","cqw","cqh","cqi","cqb","cqmin","cqmax"]),ee=/^-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?$/i,te=/^(-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?)([a-z%]+)$/i,re=e=>{if("number"==typeof e)return{value:e};const t=e.trim();if(ee.test(t))return{value:Number(t)};const r=te.exec(t);if(r){const t=r[2].toLowerCase();if(Q.has(t))return{value:Number(r[1]),unit:t};throw new P("REFRACT_E_UNITS",`Unknown length unit "${r[2]}" in "${e}". Use a CSS unit, or wrap functions/keywords (calc(), clamp(), var(), a keyword) — those pass through as raw strings.`)}return{raw:e}},ne={"typography.lineHeight":"none","typography.letterSpacing":"em"},oe=(e,t)=>{var r,n,o,s;const i=e.slice(0,e.indexOf("."));return null!==(s=null!==(o=null!==(n=null!==(r=null==t?void 0:t[e])&&void 0!==r?r:ne[e])&&void 0!==n?n:null==t?void 0:t[i])&&void 0!==o?o:null==t?void 0:t.default)&&void 0!==s?s:"px"},se=(e,t)=>Number((e/t).toFixed(4)),ie=(e,t,r)=>"none"===t?{value:e}:"rem"===t?{value:se(e,r),unit:"rem"}:{value:e,unit:t},ae=(e,t,r)=>{if("number"==typeof e){const{value:n,unit:o}=ie(e,t,r);return void 0===o?e:{value:n,unit:o}}return e},le={typography:{fontSize:"length",letterSpacing:"length",lineHeight:"length"},layout:{spacing:"length",gutters:"length",sizes:"length"},borders:{width:"length",offset:"length",radius:"length"},effects:{blur:"length",shadow:"shadow"}},ce=(e,t)=>{let r=!1;const n={};for(const[o,s]of Object.entries(e)){const e=t(s);e!==s&&(r=!0),n[o]=e}return r?n:e},ue=(e,t,r)=>{const n=t(e.base),o=e.variants?((e,t)=>{let r=!1;const n={};for(const[o,s]of Object.entries(e)){const e=t(s.base),i=s.extras?ce(s.extras,t):void 0;e===s.base&&i===s.extras||(r=!0),n[o]=i?{base:e,extras:i}:{base:e}}return r?n:e})(e.variants,t):void 0,s=r&&e.extras?ce(e.extras,t):e.extras,i=e.modes?((e,t)=>{let r=!1;const n=e.map(e=>{if(!e.overrides)return e;const n=ce(e.overrides,t);return n===e.overrides?e:(r=!0,{...e,overrides:n})});return r?n:e})(e.modes,t):void 0,a=((e,t)=>{if(!e.responsive)return;let r=!1;const n=e.responsive.map(e=>{if(!e.overrides)return e;const n=ce(e.overrides,t);return n===e.overrides?e:(r=!0,{...e,overrides:n})});return r?n:e.responsive})(e,t);if(n===e.base&&o===e.variants&&s===e.extras&&i===e.modes&&a===e.responsive)return e;const l={...e,base:n};return void 0!==o&&(l.variants=o),void 0!==s&&(l.extras=s),void 0!==i&&(l.modes=i),void 0!==a&&(l.responsive=a),l},de=(e,t,r,n)=>{const o="shadow"===t?e=>{if(!e.struct)return e;const t=e.struct;let o=!1;const s=t.map(e=>{const t=((e,t,r)=>{const n={...e};let o=!1;for(const s of["offsetX","offsetY","blur","spread"]){const i=e[s];if(void 0===i)continue;const a=ae(i,t,r);a!==i&&(n[s]=a,o=!0)}return o?n:e})(e,r,n);return t!==e&&(o=!0),t});return o?{...e,struct:s}:e}:e=>((e,t,r)=>{if(void 0!==e.unit)return e;if(void 0!==e.ref&&void 0===e.value)return e;const n=e.value;if("number"==typeof n){const{value:o,unit:s}=ie(n,t,r);return void 0===s?e:{...e,value:o,unit:s}}if("string"==typeof n){const o=re(n);if("raw"in o)return e;if(void 0!==o.unit)return{...e,value:o.value,unit:o.unit};const{value:s,unit:i}=ie(o.value,t,r);return void 0===i?{...e,value:s}:{...e,value:s,unit:i}}return e})(e,r,n);return ue(e,o,!1)},fe=(e,t={})=>{var r;const n=null!==(r=t.baseFontSize)&&void 0!==r?r:16;let o=!1;const s={};for(const[r,i]of Object.entries(e.subsystems)){const e=le[r];if(!e||!i.properties){s[r]=i;continue}let a=!1;const l={};for(const[o,s]of Object.entries(i.properties)){const i=e[o];if(!i){l[o]=s;continue}const c=oe(`${r}.${o}`,t.units),u=de(s,i,c,n);u!==s&&(a=!0),l[o]=u}a?(s[r]={...i,properties:l},o=!0):s[r]=i}return o?{...e,subsystems:s}:e},pe=e=>(null==e?void 0:e.propertyPath)?` for "${e.propertyPath}"`:"",me=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e));function he(e,t){const r=e.variants?Object.keys(e.variants):[];if(!r.length)return;const n=new Set(r),o=(null==t?void 0:t.propertyPath)?` for "${t.propertyPath}"`:"";for(const t of e.responsive){if(t.ref&&!n.has(t.ref))throw new P("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown variant "${t.ref}" (ref).`);if(t.target&&!n.has(t.target))throw new P("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown target "${t.target}".`)}}const ge=e=>"object"==typeof e&&null!==e&&Array.isArray(e.modifiers),be=(e,t)=>{if(!Array.isArray(e)||0===e.length)throw new P("REFRACT_E_VARIANT",`Derivation "${t}" needs a non-empty "modifiers" array.`);return e.map((e,r)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new P("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must be a single-key object like { darken: 10 }.`);const n=Object.keys(e);if(1!==n.length)throw new P("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must have exactly one fn key; got [${n.join(", ")}].`);return{fn:n[0],arg:e[n[0]]}})},ve=new Set(["breakpoint","query","ref","modifiers","mode","target","orientation"]),ye=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),we=(e,t,r)=>{var n;const o=null!==(n=null!=e?e:t)&&void 0!==n?n:r.fallbackBase;if(void 0===o)throw new P("REFRACT_E_PROPERTY",`Unable to resolve base value${s=r.propertyPath,s?` for "${s}"`:""}.`);var s;return r.coerceValue?r.coerceValue(o):o},$e=(e,t)=>{const r=new Set(t),n={},o={};let s=!1;for(const[t,i]of Object.entries(e))r.has(t)?(n[t]=i,s=!0):o[t]=i;return{base:s?n:void 0,extra:o}},ke=(e,t,r,n)=>{var o;if(void 0===e&&(null===(o=n.leafFields)||void 0===o?void 0:o.length)){const e=$e(t,n.leafFields);if(void 0!==e.base){const t=e.base;return{base:n.coerceValue?n.coerceValue(t):t,extra:e.extra}}}return{base:we(e,r,n),extra:t}},xe=(e,t,r,n)=>{const o=r.propertyPath?`${r.propertyPath}.variants.${e}`:`variants.${e}`,s=ye(t)?t:{base:t},{base:i,...a}=s,{base:l,extra:c}=ke(i,a,n,{...r,propertyPath:o});return{...c,base:l}},je=(e,t={})=>{var r;const n=ye(e)?e:{base:e},{base:o,responsive:s,variants:i,modes:a,...l}=n,{base:c,extra:u}=ke(o,l,t.fallbackBase,t),d=i?Object.fromEntries(Object.entries(i).map(([e,r])=>[e,xe(e,r,t,c)])):void 0,f=a?a.map(e=>((e,t)=>{const{mode:r,target:n,...o}=e,s=t.propertyPath?`${t.propertyPath}.modes.${r}`:`modes.${r}`;return{mode:r,...void 0!==n?{target:n}:{},...(()=>{var e;if((null===(e=t.leafFields)||void 0===e?void 0:e.length)&&!("base"in o)&&!ge(o)){const{base:e,extra:r}=$e(o,t.leafFields);if(void 0!==e){const n={...r};return n.base=t.coerceValue?t.coerceValue(e):e,n}}if(ge(o)){const{ref:e,modifiers:t,...r}=o,n={...r};return n.derive={...void 0!==e?{ref:e}:{},modifiers:be(t,s)},n}const{base:r,...n}=o,i={...n};if(void 0!==r&&(i.base=Array.isArray(r)||!t.coerceValue?r:t.coerceValue(r)),void 0===i.base&&!i.derive&&!Object.keys(n).length)throw new P("REFRACT_E_MODE",`Appearance mode "${s}" overrides nothing.`);return i})()}})(e,t)):void 0,p={propertyPath:t.propertyPath,allowedBreakpoints:t.allowedBreakpoints},m=(g=p,(null==(h=s)?void 0:h.length)?h.map(e=>{if(!e.breakpoint)throw new P("REFRACT_E_BREAKPOINT",`Responsive entry${pe(g)} is missing a "breakpoint" value.`);if((null==g?void 0:g.allowedBreakpoints)&&!me(e.breakpoint,g.allowedBreakpoints))throw new P("REFRACT_E_BREAKPOINT",`Responsive entry${pe(g)} references unknown breakpoint "${e.breakpoint}".`);if(e.ref&&!me(e.ref,null==g?void 0:g.allowedVariants))throw new P("REFRACT_E_RESPONSIVE",`Responsive entry${pe(g)} references unknown variant "${e.ref}" (ref).`);if(e.target&&!me(e.target,null==g?void 0:g.allowedTargets))throw new P("REFRACT_E_RESPONSIVE",`Responsive entry${pe(g)} references unknown target "${e.target}".`);const{query:t,...r}=e;return{...r,query:null!=t?t:"exact"}}):[]);var h,g;const b=(null===(r=t.leafFields)||void 0===r?void 0:r.length)?m.map(e=>((e,t)=>{const r={},n={};let o;for(const[t,s]of Object.entries(e))ve.has(t)?r[t]=s:"base"===t?o=s:n[t]=s;const s=t.leafFields.some(e=>e in n);if(void 0===o&&!s)return e;const{base:i,extra:a}=ke(o,n,void 0,t);return{...r,...a,base:i}})(e,t)):m;return{...u,base:c,responsive:b,variants:d,modes:f}},Ae=["orientation","height","aspectRatio"],Se=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e)),Ee=e=>e?` for "${e}"`:"",Re="responsive",Oe="states",Ce="css",Te="variants",Fe=e=>Array.isArray(e)?e:e&&"object"==typeof e?Object.entries(e).map(([e,t])=>({state:e,...t})):[],Ne=e=>{var t;return`${e.state}\0${null!==(t=e.target)&&void 0!==t?t:""}`},_e=(e,t)=>{const r=Fe(e).map(e=>({...e})),n=new Map(r.map((e,t)=>[Ne(e),t]));for(const e of Fe(t)){const t=Ne(e),o=n.get(t);void 0!==o?r[o]={...r[o],...e}:(n.set(t,r.length),r.push({...e}))}return r},Pe=(e,t)=>{var r,n;const o={...e};for(const[s,i]of Object.entries(t))null!==i?s===Re?o[Re]=[...null!==(r=e[Re])&&void 0!==r?r:[],...i]:s===Oe?o[Oe]=_e(e[Oe],i):s===Ce?o[Ce]={...null!==(n=e[Ce])&&void 0!==n?n:{},...i}:o[s]=i:delete o[s];return o},ze=(e,t={})=>{const r=((e,t)=>{if(!Object.values(e).some(e=>null!=e&&"object"==typeof e&&null!=e[Te]))return e;const r={},n=(e,n)=>{if(e in r)throw new P("REFRACT_E_VARIANT",`Recipe variant expansion${Ee(t)} produced a duplicate recipe name "${e}" — a desugared "<recipe>-<variant>" collides with an existing sibling recipe.`);r[e]=n};for(const[t,r]of Object.entries(e)){const{[Te]:e,...o}=r;if(n(t,o),null!=e){const r=null!=o[Oe]?{...o,[Oe]:Fe(o[Oe]).filter(e=>!e.target)}:o;for(const[o,s]of Object.entries(e))n(`${t}-${o}`,Pe(r,s))}}return r})(e,t.propertyPath),n=Object.keys(r),o=n.length?new Set(n):void 0,s={};return n.forEach(e=>{var n;const i=r[e];s[e]=Me(`${null!==(n=t.propertyPath)&&void 0!==n?n:"recipes"}.${e}`,i,{allowedBreakpoints:t.allowedBreakpoints,allowedStates:t.allowedStates,allowedTargets:o,allowedVariants:o,allowedContainers:t.allowedContainers,recipeName:e})}),s},Me=(e,t,r)=>{const{responsive:n,states:o,...s}=t;return{base:s,responsive:[...qe(o,e,r),...Le(n,e,r)]}},qe=(e,t,r)=>Fe(e).map(e=>{const{state:n,...o}=e;if(r.allowedStates&&!Se(n,r.allowedStates))throw new P("REFRACT_E_STATE",`Recipe state entry${Ee(t)} references unknown state "${n}".`);if(o.target&&r.allowedTargets){const e=r.recipeName?`${r.recipeName}-${o.target}`:o.target;if(!Se(e,r.allowedTargets))throw new P("REFRACT_E_RESPONSIVE",`Recipe state entry${Ee(t)} references unknown target "${o.target}".`)}return{...o,state:n}}),Le=(e,t,r)=>(null==e?void 0:e.length)?e.map(e=>{var n;if(void 0!==e.variant&&void 0!==e.target)throw new P("REFRACT_E_RESPONSIVE",`Responsive entry${Ee(t)} cannot set both "variant" and "target".`);if(void 0!==e.container)return Ie(e,t,r);if(!e.breakpoint)throw new P("REFRACT_E_BREAKPOINT",`Responsive recipe entry${Ee(t)} is missing a "breakpoint" value.`);if(r.allowedBreakpoints&&!Se(e.breakpoint,r.allowedBreakpoints))throw new P("REFRACT_E_BREAKPOINT",`Responsive recipe entry${Ee(t)} references unknown breakpoint "${e.breakpoint}".`);if(e.state&&r.allowedStates&&!Se(e.state,r.allowedStates))throw new P("REFRACT_E_STATE",`Responsive recipe entry${Ee(t)} references unknown state "${e.state}".`);if(e.variant&&!Se(e.variant,r.allowedVariants))throw new P("REFRACT_E_RESPONSIVE",`Responsive recipe entry${Ee(t)} references unknown variant "${e.variant}".`);if(e.target&&!Se(e.target,r.allowedTargets))throw new P("REFRACT_E_RESPONSIVE",`Responsive recipe entry${Ee(t)} references unknown target "${e.target}".`);return{...e,query:null!==(n=e.query)&&void 0!==n?n:"exact"}}):[],Ie=(e,t,r)=>{var n,o;const s=e.container;for(const r of Ae)if(void 0!==e[r])throw new P("REFRACT_E_CONTAINER",`Container recipe entry${Ee(t)} cannot use "${r}" — container queries respond to a container's inline size, not orientation/height/aspect-ratio.`);const i=null===(n=r.allowedContainers)||void 0===n?void 0:n.get(s);if(r.allowedContainers&&!i)throw new P("REFRACT_E_CONTAINER",`Container recipe entry${Ee(t)} references unknown container "${s}".`);if(void 0===e.size)throw new P("REFRACT_E_CONTAINER",`Container recipe entry${Ee(t)} for container "${s}" is missing a "size" value.`);if(i&&!i.has(e.size))throw new P("REFRACT_E_CONTAINER",`Container recipe entry${Ee(t)} references unknown size "${e.size}" on container "${s}".`);return{...e,query:null!==(o=e.query)&&void 0!==o?o:"min"}},Be=(e,t,r={})=>{var n;const o=new Map,s=[],i=null!==(n=r.groupPath)&&void 0!==n?n:"recipes",a=r=>{if(o.has(r))return o.get(r);if(s.includes(r)){const e=[...s,r].join(" -> ");throw new P("REFRACT_E_CYCLE",`Cyclic recipe reference in "${i}": ${e}`)}const n=e[r];if(!n)throw new P("REFRACT_E_REFERENCE",`Recipe variant "${r}" is not defined in "${i}".`);s.push(r);try{const e=t(r,n,a);return o.set(r,e),e}finally{s.pop()}};return{resolve:a,resolveAll:()=>{const t={};for(const r of Object.keys(e))t[r]=a(r);return t}}},Ue=(e,t,r,n=new Map,o=new Set)=>{const s=n.get(r);if(void 0!==s)return s;const i=e[r];if(!i)throw new P("REFRACT_E_TOKEN_PATH",`Unknown token path "${r}".`);if(void 0!==i.external){const e=`var(${i.external})`;return n.set(r,e),e}if(void 0===i.ref){if(void 0===i.value)throw new P("REFRACT_E_TOKEN_PATH",`Token "${r}" has neither "ref" nor "value".`);return n.set(r,i.value),i.value}if(o.has(r))throw new P("REFRACT_E_CYCLE",`Cyclic token reference: ${[...o,r].join(" -> ")}`);o.add(r);const a=Ue(e,t,i.ref,n,o);let l;if(void 0!==i.modifiers)l=i.modifiers.reduce((e,n)=>{const o=t[n.fn];if(!o)throw new P("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${n.fn}" for token "${r}".`);return o(e,n.arg)},a);else if(void 0!==i.fn){const e=t[i.fn];if(!e)throw new P("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${i.fn}" for token "${r}".`);l=e(a,i.arg)}else l=a;return o.delete(r),n.set(r,l),l},De=(e,t)=>!!(null==e?void 0:e.ref)&&((void 0!==e.modifiers||void 0!==e.fn)&&(e=>{const[t,r]=e.split(".");return`${t}.${r}`})(e.ref)!==t),We=(e,t,r,n,o)=>{let s;try{s=Ue(t,r,e.ref,n)}catch{throw new P("REFRACT_E_VALIDATION",`${o}: cross-property derivation references unknown token '${e.ref}'.`)}const i=(e,t)=>{const n=r[e];if(!n)throw new P("REFRACT_E_VALIDATION",`${o}: unknown derivation fn '${e}'.`);return n(s,t)};if(void 0!==e.modifiers)for(const t of e.modifiers)s=i(t.fn,t.arg);else void 0!==e.fn&&(s=i(e.fn,e.arg));return{...e,value:s}},Ve=(e,t,r,n,o,s)=>{let i;for(const[a,l]of Object.entries(e))De(l,t)&&(i=null!=i?i:{...e},i[a]=We(l,r,n,o,`${s}.${a}`));return i},He=(e,t,r,n,o)=>{const s=e.variants?((e,t,r,n,o)=>{let s;for(const[i,a]of Object.entries(e)){const l=`${t}.variants.${i}`,c=De(a.base,t)?We(a.base,r,n,o,l):a.base,u=a.extras?Ve(a.extras,t,r,n,o,`${l} extra`):void 0;(c!==a.base||u)&&(s=null!=s?s:{...e},s[i]=u?{base:c,extras:u}:{...a,base:c})}return s})(e.variants,t,r,n,o):void 0;let i;if(e.modes)for(let s=0;s<e.modes.length;s++){const a=e.modes[s];if(!a.overrides)continue;const l=Ve(a.overrides,t,r,n,o,`${t}.modes.${a.mode}`);l&&(i=null!=i?i:[...e.modes],i[s]={...a,overrides:l})}if(!s&&!i)return;const a={...e};return s&&(a.variants=s),i&&(a.modes=i),a},Ge=(e,t)=>{var r;const n=Z(e),o=new Map;let s=!1;const i={};for(const[a,l]of Object.entries(e.subsystems)){let e,c=!1;for(const[s,i]of Object.entries(null!==(r=l.properties)&&void 0!==r?r:{})){const r=He(i,`${a}.${s}`,n,t,o);r&&(e=null!=e?e:{...l.properties},e[s]=r,c=!0)}c?(i[a]={...l,properties:e},s=!0):i[a]=l}return s?{...e,subsystems:i}:e},Ye=["min","max","exact","between"],Je=e=>void 0===e?void 0:e-.02,Ke=(e,t)=>{const r=(e=>Object.keys(e).sort((t,r)=>e[t]-e[r]))(e);(e=>{const t=e.filter(e=>Ye.includes(e));if(t.length)throw new P("REFRACT_E_BREAKPOINT",`Breakpoint names conflict with reserved keys: ${t.map(e=>`"${e}"`).join(", ")}. Reserved: ${Ye.map(e=>`"${e}"`).join(", ")}.`)})(r);const n=e=>r[r.indexOf(e)+1],o=r.reduce((r,o)=>{const s=e[o],i=n(o),a=void 0!==i?e[i]:void 0;return r[o]=Xe({own:s,next:a},t),r},{}),s=e=>{const t=o[e];if(!t)throw new P("REFRACT_E_BREAKPOINT",`Breakpoint "${e}" is not defined.`);return t};return{...o,min:(r,n)=>{const o=s(r);return n?t({min:e[r],...n}):o.min},max:(r,o)=>{const i=s(r);if(!o)return i.max;const a=n(r),l=void 0!==a?e[a]:void 0;return t({max:Je(l),...o})},exact:(r,o)=>{const i=s(r);if(!o)return i.exact;const a=n(r),l=void 0!==a?e[a]:void 0;return t({min:e[r],max:Je(l),...o})},between:(r,n,o)=>{const s=e[r],i=e[n];if(void 0===s||void 0===i)throw new P("REFRACT_E_BREAKPOINT",`Cannot build media query between "${r}" and "${n}" breakpoints.`);return t({min:s,max:i-.02,...o})}}},Xe=({own:e,next:t},r)=>{const n=Je(t);return{min:r({min:e}),max:void 0===n?"":r({max:n}),exact:r({min:e,max:n})}},Ze="px",Qe=16,et=e=>{var t;return{unit:null!==(t=null==e?void 0:e.unit)&&void 0!==t?t:Ze,baseFontSize:(null==e?void 0:e.baseFontSize)&&e.baseFontSize>0?e.baseFontSize:Qe}},tt=(e,t)=>{if("px"===t.unit)return`${e}px`;const r=e/t.baseFontSize;return`${Number(r.toFixed(4))}${t.unit}`},rt=({min:e,max:t,orientation:r},n)=>{const o=[];if(void 0!==e&&void 0!==t&&e>t)throw new P("REFRACT_E_MEDIA","Invalid media query: `min` cannot be greater than `max`.");return void 0!==e&&o.push(`(min-width: ${tt(e,n)})`),void 0!==t&&o.push(`(max-width: ${tt(t,n)})`),r&&o.push(`(orientation: ${r})`),o.length?`@media ${o.join(" and ")}`:""},nt=(e,{min:t,max:r},n)=>{const o=[];if(void 0!==t&&void 0!==r&&t>r)throw new P("REFRACT_E_MEDIA","Invalid container query: `min` cannot be greater than `max`.");return void 0!==t&&o.push(`(min-width: ${tt(t,n)})`),void 0!==r&&o.push(`(max-width: ${tt(r,n)})`),o.length?`@container ${e} ${o.join(" and ")}`:""},ot={xs:0,sm:576,md:768,lg:992,xl:1280},st=(e,t)=>{const r=et(t),n={};for(const[t,o]of Object.entries(null!=e?e:{}))n[t]=Ke(o.sizes,e=>nt(t,{min:e.min,max:e.max},r));return n},it=new Set([3,6]),at=(e,t,r)=>Math.min(r,Math.max(t,e)),lt=e=>at(e,0,255),ct=e=>Math.round(1e3*at(e,0,1))/1e3,ut=e=>{const t=e.replace(/^\s*#|\s*$/g,"");if(!it.has(t.length))throw new Error(`Unsupported hex length: "${t}". Use 3 or 6 digits.`);const r=3===t.length?t.replace(/(.)/g,"$1$1"):t;return[parseInt(r.substring(0,2),16),parseInt(r.substring(2,4),16),parseInt(r.substring(4,6),16)]},dt=e=>{if(3!==e.length)throw new Error(`Expected RGB tuple of length 3, received ${e.length}`);return`#${e.map(e=>{const t=lt(Math.round(e)).toString(16);return 1===t.length?`0${t}`:t}).join("")}`},ft=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/i,pt=e=>{const t=e.trim(),r=ft.exec(t);return r?{rgb:[Number(r[1]),Number(r[2]),Number(r[3])],a:void 0===r[4]?1:ct(Number(r[4]))}:{rgb:ut(t),a:1}},mt=(e,t=1)=>{const r=ct(t),[n,o,s]=e,i=lt(Math.round(n)),a=lt(Math.round(o)),l=lt(Math.round(s));return r>=1?`rgb(${i}, ${a}, ${l})`:`rgba(${i}, ${a}, ${l}, ${r})`},ht=180/Math.PI,gt=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),bt=e=>e>=.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,vt=e=>{const[t,r,n]=e,o=((e,t,r)=>{const n=.4122214708*e+.5363325363*t+.0514459929*r,o=.2119034982*e+.6806995451*t+.1073969566*r,s=.0883024619*e+.2817188376*t+.6299787005*r,i=Math.cbrt(n),a=Math.cbrt(o),l=Math.cbrt(s);return{L:.2104542553*i+.793617785*a-.0040720468*l,a:1.9779984951*i-2.428592205*a+.4505937099*l,b:.0259040371*i+.7827717662*a-.808675766*l}})(gt(t/255),gt(r/255),gt(n/255)),s=Math.sqrt(o.a*o.a+o.b*o.b);let i=Math.atan2(o.b,o.a)*ht;return i<0&&(i+=360),{L:100*o.L,C:s,h:i}},yt=e=>{const t=at(e.L,0,100)/100,r=e.h/ht,n=Math.cos(r),o=Math.sin(r),s=e=>((e,t,r)=>{const n=e+.3963377774*t+.2158037573*r,o=e-.1055613458*t-.0638541728*r,s=e-.0894841775*t-1.291485548*r,i=n*n*n,a=o*o*o,l=s*s*s;return[4.0767416621*i-3.3077115913*a+.2309699292*l,-1.2684380046*i+2.6097574011*a-.3413193965*l,-.0041960863*i-.7034186147*a+1.707614701*l]})(t,e*n,e*o),i=e=>e.every(e=>e>=-1e-6&&e<=1.000001);let a=s(e.C);if(!i(a)){let t=0,r=e.C;for(let e=0;e<24;e++){const e=(t+r)/2;i(s(e))?t=e:r=e}a=s(t)}return[255*bt(at(a[0],0,1)),255*bt(at(a[1],0,1)),255*bt(at(a[2],0,1))]},wt=(e,t)=>{const{rgb:r,a:n}=pt(e);return mt(yt(t(vt(r))),n)},$t=(e,t)=>wt(e,e=>({...e,L:at(e.L+t,0,100)})),kt=(e,t)=>wt(e,e=>({...e,L:at(e.L-t,0,100)})),xt=(e,t)=>wt(e,e=>({...e,L:at(t,0,100)})),jt=(e,t)=>wt(e,e=>({...e,h:((e.h+t)%360+360)%360})),At=(e,t)=>wt(e,e=>({L:void 0===t.l?e.L:at(t.l,0,100),C:void 0===t.c?e.C:Math.max(0,e.C*t.c),h:void 0===t.h?e.h:((e.h+t.h)%360+360)%360})),St=e=>{const{rgb:t,a:r}=pt(e),n=dt(t);if(r>=1)return n;return`${n}${lt(Math.round(255*r)).toString(16).padStart(2,"0")}`},Et=(e,t)=>{const{rgb:r}=pt(e);return mt(r,(e=>at(e,0,100))(t)/100)},Rt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},Ot=e=>Math.round(1e3*Math.min(1,Math.max(0,e)))/1e3,Ct=(e,t,r)=>{const n=(e%360+360)%360/60,o=(1-Math.abs(2*Math.min(1,Math.max(0,r))-1))*Math.min(1,Math.max(0,t)),s=o*(1-Math.abs(n%2-1)),i=Math.min(1,Math.max(0,r))-o/2,[a,l,c]=n<1?[o,s,0]:n<2?[s,o,0]:n<3?[0,o,s]:n<4?[0,s,o]:n<5?[s,0,o]:[o,0,s];return[255*(a+i),255*(l+i),255*(c+i)]},Tt=/^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*(?:\/\s*([\d.]+)(%?)\s*)?\)$/i,Ft=/^hsla?\(\s*([\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[,/]\s*([\d.]+)(%?)\s*)?\)$/i,Nt=e=>{if("string"==typeof e){const t=(e=>{const t=e.trim(),r=Tt.exec(t);if(r){const e="%"===r[2]?Number(r[1]):100*Number(r[1]),t=void 0===r[5]?1:Ot("%"===r[6]?Number(r[5])/100:Number(r[5]));return{rgb:yt({L:e,C:Number(r[3]),h:Number(r[4])}),a:t}}const n=Ft.exec(t);if(n){const e=void 0===n[4]?1:Ot("%"===n[5]?Number(n[4])/100:Number(n[4]));return{rgb:Ct(Number(n[1]),Number(n[2])/100,Number(n[3])/100),a:e}}const o=Rt[t.toLowerCase()];if(o)return{rgb:ut(o),a:1};try{return pt(t)}catch{return null}})(e);if(!t)throw new P("REFRACT_E_COLOR_INPUT",`Invalid colour "${e}". Author a colour as a hex string ("#4dabf7"), an [r, g, b] tuple, or a CSS colour — oklch(), hsl()/hsla(), rgb()/rgba(), or a named keyword (e.g. "rebeccapurple"). A var(--…) can't be tonally derived at build time.`);return mt(t.rgb,t.a)}if(!Array.isArray(e)||3!==e.length||e.some(e=>"number"!=typeof e))throw new P("REFRACT_E_COLOR_TUPLE",`Invalid colour tuple ${JSON.stringify(e)}. Use an [r, g, b] tuple with 0–255 channels (alpha comes from an \`alpha\` variant, not the base).`);const[t,r,n]=e;return mt([t,r,n])},_t={lighten:(e,t)=>$t(e,Number(t)),darken:(e,t)=>kt(e,Number(t)),alpha:(e,t)=>Et(e,Number(t)),setL:(e,t)=>xt(e,Number(t)),rotateHue:(e,t)=>jt(e,Number(t)),adjust:(e,t)=>At(e,t)},Pt=["light","lighter"],zt=["dark","darker"],Mt=(e,t)=>{if(!e||!e.includes("."))return!1;const[r,n]=e.split(".");return`${r}.${n}`!=`colors.${t}`},qt=(e,t)=>{try{return Nt(e)}catch(e){throw new P("REFRACT_E_COLOR_INPUT",`colors.${t}.text — ${e.message}`)}},Lt=(e,t,r={})=>{var n;const o=((e,t)=>{let r=t;if(void 0!==t.text&&(r={...r,text:qt(t.text,e)}),t.variants){let n=!1;const o={};for(const[r,s]of Object.entries(t.variants))void 0!==s.text?(o[r]={...s,text:qt(s.text,`${e}.variants.${r}`)},n=!0):o[r]=s;n&&(r={...r,variants:o})}if(t.modes){let n=!1;const o=t.modes.map(t=>void 0!==t.text?(n=!0,{...t,text:qt(t.text,`${e}.modes.${t.mode}`)}):t);n&&(r={...r,modes:o})}return r})(e,t),s=(e=>{try{return pt(e),!0}catch{return!1}})(o.base),i=!(!o.steps||!o.steps.length),a=Object.keys(r).length>0,l=void 0!==o.harmony;if((i||a||l)&&!s)throw new P("REFRACT_E_STEPS",`colors.${e} declares derived steps/variants but its base "${o.base}" is not a hex or [r,g,b] colour.`);const c=s?Ut(o,e):{},u=s?Wt(o,e):{},d=null!==(n=o.variants)&&void 0!==n?n:{},f={...c,...u,...d},p=Kt(e,o.base,f,r),m={...c,...u,...d,...p},h=Bt(o,e,m),g=It(o,e,m);return Object.keys(m).length||h||g?{...o,...Object.keys(m).length?{variants:m}:{},...h?{modes:h}:{},...g?{responsive:g}:{}}:o},It=(e,t,r)=>{const n=e.responsive;if(!n||!n.length)return;let o=!1;const s=n.map((e,n)=>{const s=e.ref,i=e.modifiers;if(!s||!Array.isArray(i)||!i.length){let t;for(const r of["base","text"]){const n=e[r];if("string"==typeof n||Array.isArray(n)){const o=Nt(n);o!==n&&(t=null!=t?t:{...e},t[r]=o)}}return t&&(o=!0),null!=t?t:e}const a=r[s];if(!a)throw new P("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references unknown variant "${s}".`);if(void 0===a.base)throw new P("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references "${s}", a cross-property derivation — not supported.`);const l=Jt({modifiers:i},t,`responsive[${n}]`);let c=a.base;for(const e of l)c=_t[e.fn](c,e.arg);o=!0;const{ref:u,modifiers:d,...f}=e;return{...f,base:c,derive:{ref:`colors.${t}.${s}`,modifiers:l}}});return o?s:n},Bt=(e,t,r)=>{const n=e.modes;if(!n||!n.length)return;return n.map(n=>{var o;const s=n.mode,i=n.derive;if(!i)return n;const a=null!==(o=i.modifiers)&&void 0!==o?o:i.fn?[{fn:i.fn,arg:i.arg}]:[];if(Mt(i.ref,t)){const{base:e,derive:t,...r}=n;return{...r,derive:{ref:i.ref,modifiers:a}}}const l=((n,o)=>{if(!n||n===`colors.${t}`)return{value:e.base,path:`colors.${t}`};const s=n.includes(".")?n.slice(`colors.${t}.`.length):n,i=r[s];if(!i||void 0===i.base)throw new P("REFRACT_E_VARIANT_REF",`colors.${t}.modes.${o} references unknown variant "${n}".`);return{value:i.base,path:`colors.${t}.${s}`}})(i.ref,s);let c=l.value;for(const e of a){const r=_t[e.fn];if(!r)throw new P("REFRACT_E_VARIANT_REF",`Unknown derivation fn "${e.fn}" for appearance mode "colors.${t}.modes.${s}".`);c=r(c,e.arg)}return{...n,base:c,derive:{ref:l.path,modifiers:a}}})},Ut=(e,t)=>e.steps&&e.steps.length?Yt(e,t):Ht(e,t),Dt={complement:[{name:"complement",deg:180}],analogous:[{name:"analogous1",deg:-30},{name:"analogous2",deg:30}],"split-complement":[{name:"split1",deg:150},{name:"split2",deg:210}],triadic:[{name:"triadic1",deg:120},{name:"triadic2",deg:240}],tetradic:[{name:"tetradic1",deg:90},{name:"complement",deg:180},{name:"tetradic2",deg:270}]},Wt=(e,t)=>{const r=e.harmony;if(void 0===r)return{};let n,o;if("string"==typeof r)n=r;else{if("object"!=typeof r||null===r||Array.isArray(r))throw new P("REFRACT_E_HARMONY",`colors.${t}.harmony must be a scheme name or a { scheme: [names] } object.`);{const e=Object.keys(r);if(1!==e.length)throw new P("REFRACT_E_HARMONY",`colors.${t}.harmony object form must name exactly one scheme; got [${e.join(", ")}].`);n=e[0],o=r[n]}}const s=Dt[n];if(!s)throw new P("REFRACT_E_HARMONY",`colors.${t}.harmony: unknown scheme "${n}". Use one of ${Object.keys(Dt).join(", ")}.`);const i={};return s.forEach((r,n)=>{var s;const a=null!==(s=null==o?void 0:o[n])&&void 0!==s?s:r.name;i[a]={base:jt(e.base,r.deg),derive:{ref:`colors.${t}`,fn:"rotateHue",arg:r.deg}}}),i},Vt=(e,t,r,n,o,s,i,a)=>{var l;const c=e=>e?`colors.${r}.${e}`:`colors.${r}`;let u,d=t.base;for(const t of o){if(void 0!==(null===(l=n[t])||void 0===l?void 0:l.base)){d=n[t].base,u=t;continue}const r=s(d,a);e[t]={base:r,derive:{ref:c(u),fn:i,arg:a}},d=r,u=t}},Ht=(e,t)=>{var r,n,o;const s=null!==(r=e.variants)&&void 0!==r?r:{},i={},a=null!==(n=e.lightenBy)&&void 0!==n?n:10,l=null!==(o=e.darkenBy)&&void 0!==o?o:10;return Vt(i,e,t,s,Pt,$t,"lighten",a),Vt(i,e,t,s,zt,kt,"darken",l),i},Gt=e=>e<=0?100:e>=1e3?0:Math.min(98,Math.max(5,(1e3-e)/10)),Yt=(e,t)=>{var r,n;const o=null!==(r=e.steps)&&void 0!==r?r:[],s=o.find(e=>"number"!=typeof e||isNaN(e)||e<0||e>1e3);if(void 0!==s)throw new P("REFRACT_E_STEPS",`colors.${t}.steps must be numbers in 0–1000 (e.g. [50, …, 950]); got ${JSON.stringify(s)}.`);const i=null!==(n=e.variants)&&void 0!==n?n:{},a={};for(const r of o){const n=r.toString();if(i[n])continue;const o=Gt(r);a[n]={base:xt(e.base,o),derive:{ref:`colors.${t}`,fn:"setL",arg:o}}}return a},Jt=(e,t,r)=>{const n=`colors.${t}.variants.${r}`,o=e.modifiers;if(!Array.isArray(o)||0===o.length)throw new P("REFRACT_E_VARIANT",`${n} needs a non-empty "modifiers" array (e.g. [{ darken: 10 }]).`);return o.map((e,o)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new P("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must be a single-key object like { darken: 10 }.`);const s=Object.keys(e);if(1!==s.length)throw new P("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must have exactly one fn key; got [${s.join(", ")}].`);const i=s[0];if(!_t[i])throw new P("REFRACT_E_VARIANT",`${n}.modifiers[${o}] unknown fn "${i}"; use ${Object.keys(_t).join(" / ")}.`);const a=e[i],l="adjust"===i?((e,t,r)=>{const n=`colors.${t}.variants.${r}.adjust`;if("object"!=typeof e||null===e||Array.isArray(e))throw new P("REFRACT_E_ADJUST",`${n} must be an object with numeric l / c / h dials.`);const{l:o,c:s,h:i}=e,a={};if(void 0!==o){if("number"!=typeof o||isNaN(o)||o<0||o>100)throw new P("REFRACT_E_ADJUST",`${n}.l must be an absolute OKLCH lightness in 0–100; got ${JSON.stringify(o)}.`);a.l=o}if(void 0!==s){if("number"!=typeof s||isNaN(s)||s<0)throw new P("REFRACT_E_ADJUST",`${n}.c must be a non-negative chroma multiplier (1 keeps, 0 greys); got ${JSON.stringify(s)}.`);a.c=s}if(void 0!==i){if("number"!=typeof i||isNaN(i))throw new P("REFRACT_E_ADJUST",`${n}.h must be a numeric hue rotation in degrees; got ${JSON.stringify(i)}.`);a.h=i}return a})(a,t,r):Number(a);return{fn:i,arg:l}})},Kt=(e,t,r,n)=>{const o={},s=new Set,i=(t,r)=>{if(void 0===t.base)throw new P("REFRACT_E_VARIANT_REF",`colors.${e} variant chains off "${r}", which is a cross-property derivation — not supported.`);return t.base};function a(l,c){if(o[l])return;if(s.has(l))throw new P("REFRACT_E_CYCLE",`Cyclic colour variant derivation at colors.${e}.${l}.`);s.add(l);const u=Jt(c,e,l);if(Mt(c.ref,e))return o[l]={derive:{ref:c.ref,modifiers:u}},void s.delete(l);const d=(s=>{if(!s)return{value:t,path:`colors.${e}`};if(o[s])return{value:i(o[s],s),path:`colors.${e}.${s}`};if(r[s])return{value:i(r[s],s),path:`colors.${e}.${s}`};if(n[s])return a(s,n[s]),{value:i(o[s],s),path:`colors.${e}.${s}`};throw new P("REFRACT_E_VARIANT_REF",`colors.${e} variant references unknown source "${s}".`)})(c.ref);let f=d.value;for(const e of u)f=_t[e.fn](f,e.arg);o[l]={base:f,derive:{ref:d.path,modifiers:u}},s.delete(l)}for(const[e,t]of Object.entries(n))a(e,t);return o},Xt=new Set("display position top right bottom left inset inset-block inset-block-start inset-block-end inset-inline inset-inline-start inset-inline-end float clear z-index visibility overflow overflow-x overflow-y overflow-block overflow-inline overflow-clip-margin overflow-anchor box-sizing width height min-width min-height max-width max-height block-size inline-size min-block-size min-inline-size max-block-size max-inline-size aspect-ratio margin margin-top margin-right margin-bottom margin-left margin-block margin-block-start margin-block-end margin-inline margin-inline-start margin-inline-end margin-trim padding padding-top padding-right padding-bottom padding-left padding-block padding-block-start padding-block-end padding-inline padding-inline-start padding-inline-end flex flex-grow flex-shrink flex-basis flex-direction flex-flow flex-wrap order justify-content justify-items justify-self align-content align-items align-self place-content place-items place-self gap row-gap column-gap grid grid-area grid-template grid-template-areas grid-template-columns grid-template-rows grid-auto-columns grid-auto-rows grid-auto-flow grid-column grid-column-start grid-column-end grid-row grid-row-start grid-row-end columns column-count column-width column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-fill color opacity accent-color caret-color color-scheme forced-color-adjust print-color-adjust background background-color background-image background-position background-position-x background-position-y background-size background-repeat background-origin background-clip background-attachment background-blend-mode mix-blend-mode isolation border border-width border-style border-color border-top border-top-width border-top-style border-top-color border-right border-right-width border-right-style border-right-color border-bottom border-bottom-width border-bottom-style border-bottom-color border-left border-left-width border-left-style border-left-color border-block border-block-width border-block-style border-block-color border-block-start border-block-start-width border-block-start-style border-block-start-color border-block-end border-block-end-width border-block-end-style border-block-end-color border-inline border-inline-width border-inline-style border-inline-color border-inline-start border-inline-start-width border-inline-start-style border-inline-start-color border-inline-end border-inline-end-width border-inline-end-style border-inline-end-color border-radius border-top-left-radius border-top-right-radius border-bottom-right-radius border-bottom-left-radius border-start-start-radius border-start-end-radius border-end-start-radius border-end-end-radius border-image border-image-source border-image-slice border-image-width border-image-outset border-image-repeat border-collapse border-spacing outline outline-width outline-style outline-color outline-offset box-shadow filter backdrop-filter clip-path mask mask-image mask-mode mask-repeat mask-position mask-clip mask-origin mask-size mask-composite mask-type opacity transform transform-origin transform-box transform-style perspective perspective-origin backface-visibility rotate scale translate transition transition-property transition-duration transition-timing-function transition-delay transition-behavior animation animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction animation-fill-mode animation-play-state animation-composition animation-timeline will-change font font-family font-size font-size-adjust font-weight font-style font-variant font-variant-caps font-variant-numeric font-variant-ligatures font-variant-east-asian font-variant-alternates font-variant-position font-feature-settings font-variation-settings font-kerning font-stretch font-optical-sizing font-synthesis font-display line-height letter-spacing word-spacing text-align text-align-last text-decoration text-decoration-line text-decoration-color text-decoration-style text-decoration-thickness text-decoration-skip-ink text-underline-offset text-underline-position text-transform text-indent text-overflow text-shadow text-rendering text-wrap text-wrap-mode text-wrap-style text-emphasis text-emphasis-color text-emphasis-style text-emphasis-position text-orientation text-combine-upright text-justify white-space white-space-collapse word-break word-wrap overflow-wrap hyphens hyphenate-character line-break tab-size vertical-align writing-mode direction unicode-bidi quotes content list-style list-style-type list-style-position list-style-image counter-reset counter-increment counter-set cursor pointer-events user-select touch-action resize appearance caret scroll-behavior scroll-margin scroll-margin-top scroll-margin-right scroll-margin-bottom scroll-margin-left scroll-padding scroll-padding-top scroll-padding-right scroll-padding-bottom scroll-padding-left scroll-snap-type scroll-snap-align scroll-snap-stop overscroll-behavior overscroll-behavior-x overscroll-behavior-y scrollbar-width scrollbar-color scrollbar-gutter table-layout caption-side empty-cells vertical-align object-fit object-position image-rendering fill fill-opacity fill-rule stroke stroke-width stroke-opacity stroke-linecap stroke-linejoin stroke-dasharray stroke-dashoffset stroke-miterlimit paint-order shape-rendering stop-color flood-color lighting-color container container-type container-name contain content-visibility break-before break-after break-inside page-break-before page-break-after page-break-inside orphans widows all cx cy r rx ry d".split(" ")),Zt=/^-(webkit|moz|ms|o)-/,Qt=e=>{if(e.startsWith("--"))return!0;const t=e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return!!Zt.test(t)||Xt.has(t)},er=new Set(["breakpoint","query","state","variant","target","orientation"]),tr=(e,t,r)=>{const n={};if(!e)return n;for(const[o,s]of Object.entries(e)){if(void 0===s||er.has(o))continue;if(!Qt(o))throw new P("REFRACT_E_RECIPE_PROPERTY",`Unknown recipe property "${o}" in ${r} — expected a CSS property or a reserved key (variant, target, state, breakpoint, query, orientation, container, size).`);const e=rr(s,t,r,o);void 0!==e&&(n[nr(o)]=e)}return n},rr=(e,t,r,n)=>{var o;if("number"==typeof e)return{value:e};const s=e.trim();if(!s)return;const i=s.split("."),a=i[0],l=t.properties[a];if(!l)return{value:s};const c=i.length>1?i.slice(1).join("."):void 0;if(!c)return{ref:`colors.${a}`};if("text"===c)return{ref:`colors.${a}.text`};if(!(null===(o=l.variants)||void 0===o?void 0:o[c]))throw new P("REFRACT_E_VARIANT_REF",`Unknown palette variant reference "${a}.${c}" in ${r}.${n}.`);return{ref:`colors.${a}.${c}`}},nr=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),or=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),sr=([e,t,r])=>.2126*or(e/255)+.7152*or(t/255)+.0722*or(r/255),ir={fail:0,"AA-large":1,AA:2,AAA:3},ar=2.4,lr=.2126729,cr=.7151522,ur=.072175,dr=.56,fr=.57,pr=.62,mr=.65,hr=.022,gr=1.414,br=1.14,vr=.027,yr=1.14,wr=.027,$r=5e-4,kr=.1,xr=([e,t,r])=>lr*Math.pow(e/255,ar)+cr*Math.pow(t/255,ar)+ur*Math.pow(r/255,ar),jr=(e,t)=>{const r=e=>e>hr?e:e+Math.pow(hr-e,gr),n=r(xr(e)),o=r(xr(t));if(Math.abs(o-n)<$r)return 0;let s;if(o>n){const e=(Math.pow(o,dr)-Math.pow(n,fr))*br;s=e<kr?0:e-vr}else{const e=(Math.pow(o,mr)-Math.pow(n,pr))*yr;s=e>-kr?0:e+wr}return 100*s},Ar=(e,t)=>{const r=10**t;return Math.round(e*r)/r},Sr=(e,t)=>{if(void 0!==t.ref)try{return String(e.resolveToken(t.ref))}catch{return}if("string"==typeof t.value)return t.value},Er="color",Rr=["background-color","background"],Or=e=>{if(e)for(const t of Rr)if(e[t])return e[t]},Cr=(e,t,r,n,o)=>{let s,i;try{void 0!==r&&(s=pt(r).rgb)}catch{}try{void 0!==n&&(i=pt(n).rgb)}catch{}if(!s||!i)return{kind:e,label:t,fg:r,bg:n,skipped:s||i?s?"bg not a colour":"fg not a colour":"no derivable fg/bg"};const a=((e,t)=>{const r=sr(e),n=sr(t);return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)})(s,i),l=((e,t)=>t?e>=4.5?"AAA":e>=3?"AA":"fail":e>=7?"AAA":e>=4.5?"AA":e>=3?"AA-large":"fail")(a,o.largeText),c=ir[l]>=ir[o.minWcag];return{kind:e,label:t,fg:r,bg:n,wcagRatio:Ar(a,2),wcagLevel:l,apcaLc:Ar(jr(s,i),1),pass:c}},Tr=(e,t={})=>{var r,n,o,s,i,a,l,c,u,d,f;const p={largeText:null!==(r=t.largeText)&&void 0!==r&&r,minWcag:null!==(n=t.minWcag)&&void 0!==n?n:"AA"},m=null===(o=t.includeRecipes)||void 0===o||o,h=[];if(null===(s=t.includePalettes)||void 0===s||s)for(const t of Object.keys(e.tokens)){const r=/^colors\.([^.]+)\.text$/.exec(t);if(!r)continue;const n=`colors.${r[1]}`;let o,s;try{o=String(e.resolveToken(t))}catch{}try{s=String(e.resolveToken(n))}catch{}h.push(Cr("palette",n,o,s,p))}if(m)for(const[t,r]of Object.entries(e.model.subsystems))if(r.ruleSets)for(const[n,o]of Object.entries(r.ruleSets))for(const[r,s]of Object.entries(o)){const o=s.declarations[Er],m=Or(s.declarations),g=`${t}.${n}.${r}`;o&&m&&h.push(Cr("recipe",g,Sr(e,o),Sr(e,m),p));for(const t of null!==(i=s.overrides)&&void 0!==i?i:[]){const r=null!==(l=null===(a=t.declarations)||void 0===a?void 0:a[Er])&&void 0!==l?l:o,n=null!==(c=Or(t.declarations))&&void 0!==c?c:m;if(!t.declarations||!t.declarations[Er]&&!Or(t.declarations))continue;if(!r||!n)continue;const s=null!==(f=null!==(d=null!==(u=t.state)&&void 0!==u?u:t.breakpoint)&&void 0!==d?d:t.query)&&void 0!==f?f:"override";h.push(Cr("recipe",`${g} (${s})`,Sr(e,r),Sr(e,n),p))}}const g=h.filter(e=>!e.skipped),b=g.filter(e=>!1===e.pass),v=g.reduce((e,t)=>{var r,n;return void 0===e||(null!==(r=t.wcagRatio)&&void 0!==r?r:1/0)<(null!==(n=e.wcagRatio)&&void 0!==n?n:1/0)?t:e},void 0),y={pairings:h,summary:{total:g.length,passed:g.length-b.length,failed:b.length,skipped:h.length-g.length,worst:v},ok:0===b.length};if(t.strict&&b.length>0){const e=b.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`).join(", ");throw new P("REFRACT_E_AUDIT",`refract audit: ${b.length} pairing(s) fail WCAG ${p.minWcag} — ${e}. Adjust the colour(s), lower --min-wcag, or drop --strict to report without failing.`,b.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`))}return y},Fr=new Set(["recipes"]),Nr=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("base"in e)&&Array.isArray(e.modifiers),_r=e=>{if("object"!=typeof e||null===e||Array.isArray(e)||!e.variants)return{value:e,specs:{}};const t=e.variants,r={},n={};for(const[e,o]of Object.entries(t))Nr(o)?r[e]=o:n[e]=o;if(!Object.keys(r).length)return{value:e,specs:r};const o=Object.keys(n).length?n:void 0;return{value:{...e,variants:o},specs:r}},Pr={key:"colors",derivations:{lighten:(e,t)=>$t(String(e),Number(t)),darken:(e,t)=>kt(String(e),Number(t)),alpha:(e,t)=>Et(String(e),Number(t)),setL:(e,t)=>xt(String(e),Number(t)),rotateHue:(e,t)=>jt(String(e),Number(t)),adjust:(e,t)=>At(String(e),t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Fr.has(n))continue;const{value:e,specs:s}=_r(o),i=je(e,{propertyPath:`colors.${n}`,allowedBreakpoints:t.allowedBreakpoints,coerceValue:Nt}),a=Lt(n,i,s);he(a,{propertyPath:`colors.${n}`}),r[n]=a}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{const n=`${r.groupPath}.${e}`;return{base:tr(t.base,r,n),responsive:t.responsive.map(e=>{const{breakpoint:t,query:o,state:s,variant:i,target:a,orientation:l,container:c,size:u,...d}=e,f={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...tr(d,r,`${n}.responsive`)}};return t&&(f.breakpoint=t,f.query=null!=o?o:"exact"),c&&(f.container=c,u&&(f.size=u),f.query=null!=o?o:"min"),s&&(f.state=s),l&&(f.orientation=l),a&&(f.target=a),f})}})(e,t,r)},zr={"minor-second":1.067,"major-second":1.125,"minor-third":1.2,"major-third":1.25,"perfect-fourth":1.333,"augmented-fourth":1.414,"perfect-fifth":1.5,golden:1.618},Mr={xs:-2,sm:-1,md:0,lg:1,xl:2,"2xl":3,"3xl":4,"4xl":5},qr=(e,t)=>"fontSize"!==e?t:Lr(t),Lr=e=>{var t,r,n,o;const s=e.ratio;if(!s)return e;const i=zr[s];if(!i)return e;const a=null!==(t=e.baseFontSize)&&void 0!==t?t:e.base,l=null!==(r=e.precision)&&void 0!==r?r:4,c=e.algorithm,u=null!==(n=e.variants)&&void 0!==n?n:{},d={};let f=null;for(const[e,t]of Object.entries(Mr)){if(u[e]){f=null!==(o=u[e].base)&&void 0!==o?o:null;continue}let r;r=c?c(a,e,t,f):a*Math.pow(i,t);const n=Number(r.toFixed(l));f=n,d[e]={base:n}}return{...e,variants:{...d,...u}}},Ir=new Set(["breakpoint","query","state","variant","target","orientation"]),Br={fontFamily:"font-family",fontSize:"font-size",fontWeight:"font-weight",lineHeight:"line-height",letterSpacing:"letter-spacing",fontStyle:"font-style",textTransform:"text-transform",textDecoration:"text-decoration",textAlign:"text-align"},Ur=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||Ir.has(r))continue;const e=Br[r];e&&(t[e]={ref:Dr(r,n)})}return t},Dr=(e,t)=>"base"===t?`typography.${e}`:`typography.${e}.${t}`,Wr=new Set(["recipes"]),Vr={key:"typography",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Wr.has(n))continue;const e=je(o,{propertyPath:`typography.${n}`,allowedBreakpoints:t.allowedBreakpoints}),s=qr(n,e);he(s,{propertyPath:`typography.${n}`}),r[n]=s}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:Ur(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:s,target:i,orientation:a,container:l,size:c,...u}=e,d={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...Ur(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),i&&(d.target=i),a&&(d.orientation=a),d})}))(0,t,r)},Hr=["spacing","gutters","aspectRatio","sizes"],Gr=new Set(["spacing","gutters","sizes"]),Yr=new Set(["spacing","gutters"]),Jr=["xs","sm","md","lg","xl","2xl","3xl","4xl"],Kr=e=>Number(e.toFixed(4)),Xr=(e,t)=>{var r;if(!Gr.has(e))return t;const n=((e,t)=>{const r=t,n=void 0!==r.ratio,o=void 0!==r.step;if(!n&&!o)return;if(n&&o)throw new P("REFRACT_E_LAYOUT",`layout.${e}: declare only one of "ratio" (geometric) or "step" (linear) scale, not both.`);const s=r.steps;if(n){let t;if(void 0===s)t=Jr;else{if(!Array.isArray(s))throw new P("REFRACT_E_LAYOUT",`layout.${e}: a geometric scale ("ratio") needs "steps" as an ordered name array, e.g. ["sm","md","lg"].`);t=s.map(String)}const n=t.map((e,t)=>({name:e,exp:t}));return{curve:"geometric",ratio:Number(r.ratio),specs:n}}let i;if(void 0===s)i=Jr.map((e,t)=>({name:e,exp:t,mult:t+1}));else{if(Array.isArray(s)||"object"!=typeof s||null===s)throw new P("REFRACT_E_LAYOUT",`layout.${e}: a linear scale ("step") needs "steps" as a name→multiplier map, e.g. { sm:1, md:2, lg:3 }.`);i=Object.entries(s).map(([e,t],r)=>({name:e,exp:r,mult:Number(t)}))}return{curve:"linear",step:Number(r.step),specs:i}})(e,t);if(!n)return Yr.has(e)?Zr(t):t;const o=((e,t,r)=>{const n=`layout.${e}`,o={};for(const e of r.specs)if("geometric"===r.curve){const s=Kr(Number(t)*Math.pow(r.ratio,e.exp));o[e.name]={base:s,derive:{ref:n,fn:"scaleStep",arg:{curve:"geometric",ratio:r.ratio,exp:e.exp}}}}else{const t=Kr(r.step*e.mult);o[e.name]={base:t,derive:{ref:n,fn:"scaleStep",arg:{curve:"linear",step:r.step,mult:e.mult}}}}return o})(e,t.base,n);let s={...o,...null!==(r=t.variants)&&void 0!==r?r:{}};Yr.has(e)&&(s={...s,none:{base:0}});const i=((e,t,r,n)=>{if(!(null==r?void 0:r.length))return r;const o=`layout.${e}`,s=[];let i=!1;for(const a of r){const r=a;if(void 0===r.ratio&&void 0===r.step){s.push(r);continue}if(i=!0,void 0!==r.ratio&&void 0!==r.step)throw new P("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry may set only "ratio" or "step", not both.`);if(!n)throw new P("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry needs a base scale — declare a top-level "ratio"/"step" (+ "steps") first.`);const{breakpoint:l,query:c,orientation:u}=r,d=void 0!==r.ratio;for(const i of n.specs){let n,a;if(d){const e=Number(r.ratio),o=void 0!==r.base,s=Number(o?r.base:t);n=Kr(s*Math.pow(e,i.exp)),a={curve:"geometric",ratio:e,exp:i.exp,...o?{base:s}:{}}}else{if(void 0===i.mult)throw new P("REFRACT_E_LAYOUT",`layout.${e}: a linear responsive ramp ("step") requires a linear base scale (a name→multiplier "steps").`);const t=Number(r.step);n=Kr(t*i.mult),a={curve:"linear",step:t,mult:i.mult}}const f={breakpoint:l,query:c,target:i.name,base:n,derive:{ref:o,fn:"scaleStep",arg:a}};void 0!==u&&(f.orientation=u),s.push(f)}}return i?s:r})(e,t.base,t.responsive,n);return(e=>{const{ratio:t,step:r,steps:n,...o}=e;return o})({...t,variants:s,responsive:i})},Zr=e=>{var t;const r=null!==(t=e.variants)&&void 0!==t?t:{};return{...e,variants:{...r,none:{base:0}}}},Qr=new Set(["breakpoint","query","state","variant","target","orientation"]),en={paddingY:["padding-top","padding-bottom"],paddingX:["padding-left","padding-right"],marginY:["margin-top","margin-bottom"],marginX:["margin-left","margin-right"],gap:["gap"],background:["background"],width:["width"],minWidth:["min-width"],maxWidth:["max-width"],height:["height"],minHeight:["min-height"],maxHeight:["max-height"]},tn={paddingY:"spacing",paddingX:"spacing",marginY:"spacing",marginX:"spacing",gap:"spacing",width:"sizes",minWidth:"sizes",maxWidth:"sizes",height:"sizes",minHeight:"sizes",maxHeight:"sizes",background:"literal"},rn=(e,t)=>"base"===t?`layout.${e}`:`layout.${e}.${t}`,nn=(e,t)=>{const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Qr.has(n))continue;if(!o)continue;const e=en[n];if(!e)throw new P("REFRACT_E_LAYOUT",`Unknown layout recipe property "${n}" in ${t}. Known verbs: ${Object.keys(en).join(", ")}. For arbitrary CSS use a component \`css\` delta.`);const s=tn[n];for(const t of e)r[t]="literal"===s?{value:o}:{ref:rn(s,o)}}return r},on=e=>({ref:"base"===e?"layout.spacing":`layout.spacing.${e}`}),sn=e=>({ref:"base"===e?"layout.gutters":`layout.gutters.${e}`}),an=e=>({ref:`layout.${e}`}),ln=e=>({value:e}),cn=e=>Object.keys(e).sort((t,r)=>e[t]-e[r]),un=[["templateColumns","grid-template-columns"],["templateRows","grid-template-rows"],["autoRows","grid-auto-rows"],["autoColumns","grid-auto-columns"],["justifyItems","justify-items"],["alignItems","align-items"],["justifyContent","justify-content"],["alignContent","align-content"]],dn=(e,t)=>{const r={};t&&(r.display=ln("grid"));for(const[t,n]of un){const o=e[t];o&&(r[n]=ln(o))}return e.gap&&(r.gap=on(e.gap)),r},fn=e=>{var t,r;if(!e||"string"==typeof e)return{mode:null!==(t=e)&&void 0!==t?t:"fixed"};const n=e;return{mode:null!==(r=n.base)&&void 0!==r?r:"fixed",inset:n.inset,gutter:n.gutter,direction:n.direction,align:n.align,justify:n.justify,maxWidth:n.maxWidth}},pn=(e,t,r=new Set,n)=>{var o,s,i,a;const l=et(n),c=e=>tt(e,l),u={},d={},f=cn(t),p=e&&"object"==typeof e?e:void 0,m=p?{mode:null!==(o=p.base)&&void 0!==o?o:"fixed",inset:p.inset,gutter:p.gutter,direction:p.direction,align:p.align,justify:p.justify,maxWidth:p.maxWidth}:fn(null!=e?e:"fixed"),h=null!==(s=null==p?void 0:p.variants)&&void 0!==s?s:{},g=null!==(i=null==p?void 0:p.responsive)&&void 0!==i?i:[],b=e=>e?`container-${e}`:"container",v=(e,n)=>{var o,s,i,a,l,p,h,g,v;const y=e?`--${e}`:"",w=`container${y}--inset`,$=`container${y}--gutter`,k=null!==(s=null!==(o=n.inset)&&void 0!==o?o:m.inset)&&void 0!==s?s:"base",x=null!==(i=n.gutter)&&void 0!==i?i:m.gutter,j=null!==(l=null!==(a=n.mode)&&void 0!==a?a:m.mode)&&void 0!==l?l:"fixed",A=null!==(p=n.direction)&&void 0!==p?p:m.direction,S=null!==(h=n.align)&&void 0!==h?h:m.align,E=null!==(g=n.justify)&&void 0!==g?g:m.justify,R=null!==(v=n.maxWidth)&&void 0!==v?v:e?m.maxWidth:void 0;u[w]={base:on(k)},x&&(u[$]={base:sn(x)});const O={"box-sizing":ln("border-box"),width:ln("100%"),"margin-left":ln("auto"),"margin-right":ln("auto"),"padding-left":an(w),"padding-right":an(w)};x&&(O.gap=an($)),A&&(O.display=ln("flex"),O["flex-direction"]=ln(A)),S&&(O["align-items"]=ln(S)),E&&(O["justify-content"]=ln(E));const C=[];if("fixed"===j){const e="string"==typeof R&&void 0!==t[R]?R:void 0,r=e?f.indexOf(e):-1;for(let n=0;n<f.length;n++){const o=f[n],s=t[r>=0&&n>r?e:o];0!==s?0===n?O["max-width"]=ln(c(s)):C.push({breakpoint:o,query:"min",declarations:{"max-width":ln(c(s))}}):0===n&&(O["max-width"]=ln("none"))}}else"fluid"===j?void 0!==R&&(O["max-width"]=((e,t,r)=>{return"number"==typeof e?ln(`${e}px`):t.has(e)?{ref:"base"===(n=e)?"layout.sizes":`layout.sizes.${n}`}:void 0!==r[e]?ln(`${r[e]}px`):ln(e);var n})(R,r,t)):O["max-width"]=ln("number"==typeof j?`${j}px`:j);d[b(e)]={kind:"recipe",declarations:O,overrides:C}};v(null,m);for(const[e,t]of Object.entries(h))v(e,fn(t));for(const e of g){const t=e.target,r=b(null!=t?t:null),n=d[r];if(!n)continue;const o={};if(e.direction&&(o["flex-direction"]=ln(e.direction)),e.align&&(o["align-items"]=ln(e.align)),e.justify&&(o["justify-content"]=ln(e.justify)),e.inset){const e=t?`container--${t}--inset`:"container--inset";o["padding-left"]=an(e),o["padding-right"]=an(e)}if(e.gutter){const e=t?`container--${t}--gutter`:"container--gutter";o.gap=an(e)}Object.keys(o).length&&n.overrides.push({breakpoint:e.breakpoint,query:null!==(a=e.query)&&void 0!==a?a:"exact",declarations:o})}return{ruleSetGroups:{container:d},configProperties:u}},mn=(e,t,r)=>{const n={},o={},s=e=>{e&&(Object.assign(n,e.ruleSetGroups),Object.assign(o,e.configProperties))};return s(((e,t)=>{var r,n;if(!e)return;const o="number"==typeof e?{size:e}:e,s=o.size,i=null!==(r=o.gutter)&&void 0!==r?r:"base",a=null!==(n=o.inset)&&void 0!==n?n:"none",l={"columns--size":{base:ln(String(s))},"columns--gutter":{base:sn(i)},"columns--inset":{base:on(a)}},c={},u=Array.from({length:s},(e,t)=>t+1);for(const e of cn(t))for(const r of u){const n=`col-${e}-${r}`,o=`offset-${e}-${r}`,s={"grid-column-end":ln(`span ${r}`)},i={"grid-column-start":ln(String(r+1))};0===t[e]?(c[n]={kind:"utility",declarations:s,overrides:[]},c[o]={kind:"utility",declarations:i,overrides:[]}):(c[n]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:s}]},c[o]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:i}]})}return{ruleSetGroups:{columns:c},configProperties:l}})(e.columns,t)),s((e=>{var t,r;if(!e||!Object.keys(e).length)return;const n={};for(const[o,s]of Object.entries(e)){const e=dn(s,!0),i=[];for(const e of null!==(t=s.responsive)&&void 0!==t?t:[]){const t=dn(e,!1);Object.keys(t).length&&i.push({breakpoint:e.breakpoint,query:null!==(r=e.query)&&void 0!==r?r:"exact",declarations:t})}n[`grid-${o}`]={kind:"recipe",declarations:e,overrides:i}}return{ruleSetGroups:{grids:n},configProperties:{}}})(e.grids)),s((e=>{var t,r,n;if(!e||!Object.keys(e).length)return;const o={};for(const[s,i]of Object.entries(e)){const e={display:ln(i.inline?"inline-flex":"flex"),"flex-direction":ln(null!==(t=i.direction)&&void 0!==t?t:"column")};i.align&&(e["align-items"]=ln(i.align)),i.justify&&(e["justify-content"]=ln(i.justify)),i.wrap&&(e["flex-wrap"]=ln(i.wrap)),i.gap&&(e.gap=on(i.gap));const a=[];for(const e of null!==(r=i.responsive)&&void 0!==r?r:[]){const t={};void 0!==e.inline&&(t.display=ln(e.inline?"inline-flex":"flex")),e.direction&&(t["flex-direction"]=ln(e.direction)),e.align&&(t["align-items"]=ln(e.align)),e.justify&&(t["justify-content"]=ln(e.justify)),e.wrap&&(t["flex-wrap"]=ln(e.wrap)),Object.keys(t).length&&a.push({breakpoint:e.breakpoint,query:null!==(n=e.query)&&void 0!==n?n:"exact",declarations:t})}o[`stack-${s}`]={kind:"recipe",declarations:e,overrides:a}}return{ruleSetGroups:{stacks:o},configProperties:{}}})(e.stacks)),s(pn(e.container,t,(e=>{const t=new Set;if(e&&"object"==typeof e&&!Array.isArray(e)){const r=e;"base"in r&&t.add("base");const n=r.variants;if(n&&"object"==typeof n)for(const e of Object.keys(n))t.add(e)}return t})(e.sizes),r)),{ruleSetGroups:n,configProperties:o}},hn=new Set(Hr),gn={key:"layout",derivations:{scaleStep:(e,t)=>((e,t)=>{const r=null!=t?t:{};if("linear"===r.curve)return Kr(Number(r.step)*Number(r.mult));const n=void 0!==r.base?Number(r.base):Number(e);return Kr(n*Math.pow(Number(r.ratio),Number(r.exp)))})(e,t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const n of Hr){const o=e[n];if(void 0===o||!hn.has(n))continue;const s=je(o,{propertyPath:`layout.${n}`,allowedBreakpoints:t.allowedBreakpoints}),i=Xr(n,s);he(i,{propertyPath:`layout.${n}`}),r[n]=i}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{var n;const o=`${null!==(n=r.groupPath)&&void 0!==n?n:"layout.recipes"}.${e}`;return{base:nn(t.base,o),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:s,variant:i,target:a,orientation:l,container:c,size:u,...d}=e,f={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...nn(d,o)}};return t&&(f.breakpoint=t,f.query=null!=n?n:"exact"),c&&(f.container=c,u&&(f.size=u),f.query=null!=n?n:"min"),s&&(f.state=s),a&&(f.target=a),l&&(f.orientation=l),f})}})(e,t,r),buildStructural:(e,t)=>mn(e,t.breakpoints,t.mediaConfig)},bn=new Set(["breakpoint","query","state","variant","target","orientation"]),vn={boxShadow:"box-shadow",opacity:"opacity",blur:"filter",transition:"transition",zIndex:"z-index"},yn={boxShadow:"shadow",opacity:"opacity",blur:"blur",transition:"transitions",zIndex:"zIndex"},wn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||bn.has(r))continue;const e=vn[r],o=yn[r];if(!e||!o)continue;const s={ref:$n(o,n)};"blur"===r&&(s.wrap="blur"),t[e]=s}return t},$n=(e,t)=>"base"===t?`effects.${e}`:`effects.${e}.${t}`,kn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),xn=(e,t)=>{if(void 0!==e){if("number"!=typeof e||Number.isNaN(e))throw new P("REFRACT_E_EFFECTS",`${t} must be a number, received ${JSON.stringify(e)}.`);return e}},jn=(e,t)=>{if(void 0!==e){if("number"==typeof e){if(Number.isNaN(e))throw new P("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`);return e}if("string"==typeof e){const r=re(e);if("raw"in r)throw new P("REFRACT_E_EFFECTS",`${t} must be a number or a <number><unit> length (received ${JSON.stringify(e)}).`);return void 0===r.unit?r.value:{value:r.value,unit:r.unit}}throw new P("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`)}},An=new Set(["offsetX","offsetY","blur","spread","color","inset"]),Sn=(e,t)=>{if(!kn(e))throw new P("REFRACT_E_EFFECTS",`${t} must be a shadow-layer object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!An.has(r))throw new P("REFRACT_E_EFFECTS",`${t} has unknown shadow field "${r}" (allowed: ${[...An].join(", ")}).`);const r={},n=jn(e.offsetX,`${t}.offsetX`),o=jn(e.offsetY,`${t}.offsetY`),s=jn(e.blur,`${t}.blur`),i=jn(e.spread,`${t}.spread`);if(void 0!==n&&(r.offsetX=n),void 0!==o&&(r.offsetY=o),void 0!==s&&(r.blur=s),void 0!==i&&(r.spread=i),void 0!==e.color){if("string"!=typeof e.color||!e.color)throw new P("REFRACT_E_EFFECTS",`${t}.color must be a "colors.*" token-path string.`);r.color=e.color}if(void 0!==e.inset){if("boolean"!=typeof e.inset)throw new P("REFRACT_E_EFFECTS",`${t}.inset must be a boolean.`);e.inset&&(r.inset=!0)}return r},En=new Set(["property","duration","timingFunction","delay"]),Rn=(e,t)=>{if(!kn(e))throw new P("REFRACT_E_EFFECTS",`${t} must be a transition-part object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!En.has(r))throw new P("REFRACT_E_EFFECTS",`${t} has unknown transition field "${r}" (allowed: ${[...En].join(", ")}).`);if("string"!=typeof e.property||!e.property)throw new P("REFRACT_E_EFFECTS",`${t}.property is required (the CSS property to transition).`);const r={property:e.property},n=xn(e.duration,`${t}.duration`),o=xn(e.delay,`${t}.delay`);if(void 0!==n&&(r.duration=n),void 0!==e.timingFunction){if("string"!=typeof e.timingFunction||!e.timingFunction)throw new P("REFRACT_E_EFFECTS",`${t}.timingFunction must be a keyword or cubic-bezier(...) string.`);r.timingFunction=e.timingFunction}return void 0!==o&&(r.delay=o),r},On=new Set(["recipes"]),Cn={shadow:["offsetX","offsetY","blur","spread","color","inset"],transitions:["property","duration","timingFunction","delay"]},Tn=e=>"shadow"===e?t=>((e,t="effects.shadow")=>{if("string"==typeof e){if("none"===e)return"none";throw new P("REFRACT_E_EFFECTS",`${t} must be structured shadow layer(s) or "none" — raw CSS strings are not accepted (received ${JSON.stringify(e)}).`)}if(Array.isArray(e)){if(!e.length)throw new P("REFRACT_E_EFFECTS",`${t} is an empty shadow-layer array.`);return e.map((e,r)=>Sn(e,`${t}[${r}]`))}return[Sn(e,t)]})(t,`effects.${e}`):"transitions"===e?t=>((e,t="effects.transitions")=>{if("string"==typeof e){if("none"===e)return"none";throw new P("REFRACT_E_EFFECTS",`${t} must be structured transition part(s) or "none" — raw CSS strings are not accepted (received ${JSON.stringify(e)}).`)}if(Array.isArray(e)){if(!e.length)throw new P("REFRACT_E_EFFECTS",`${t} is an empty transition-part array.`);return e.map((e,r)=>Rn(e,`${t}[${r}]`))}return[Rn(e,t)]})(t,`effects.${e}`):void 0,Fn={key:"effects",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(On.has(n))continue;const e=Cn[n],s=Tn(n),i=je(o,{propertyPath:`effects.${n}`,allowedBreakpoints:t.allowedBreakpoints,...e?{leafFields:e}:{},...s?{coerceValue:s}:{},...e?{fallbackBase:"none"}:{}});he(i,{propertyPath:`effects.${n}`}),r[n]=i}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:wn(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:s,target:i,orientation:a,container:l,size:c,...u}=e,d={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...wn(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),i&&(d.target=i),a&&(d.orientation=a),d})}))(0,t,r)},Nn=new Set(["breakpoint","query","state","variant","target","orientation","container","size"]),_n=new Set(["as","side"]),Pn=new Set(["width","style","offset","radius","color"]),zn=(e,t,r)=>"radius"===r?"border-radius":"offset"===r?"outline-offset":"outline"===e?`outline-${r}`:t?`border-${t}-${r}`:`border-${r}`,Mn=(e,t)=>"color"===e?{ref:t}:{ref:"base"===t?`borders.${e}`:`borders.${e}.${t}`},qn=(e,t,r)=>{const n={};if(!e)return n;for(const[o,s]of Object.entries(e))s&&!Nn.has(o)&&!_n.has(o)&&Pn.has(o)&&(n[zn(t,r,o)]=Mn(o,s));return n},Ln=new Set(["recipes"]),In={key:"borders",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Ln.has(n))continue;const e=je(o,{propertyPath:`borders.${n}`,allowedBreakpoints:t.allowedBreakpoints});he(e,{propertyPath:`borders.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{var n;const o=null!==(n=t.base.as)&&void 0!==n?n:"border",s=t.base.side,i=qn(t.base,o,s),a=t.responsive.map(e=>{var t,n;const{breakpoint:i,query:a,state:l,variant:c,target:u,orientation:d,container:f,size:p,as:m,side:h,...g}=e,b=null!==(t=m)&&void 0!==t?t:o,v=null!==(n=h)&&void 0!==n?n:s,y={declarations:{...c?{...r.resolveRecipeVariant(c).base}:{},...qn(g,b,v)}};return i&&(y.breakpoint=i,y.query=null!=a?a:"exact"),f&&(y.container=f,p&&(y.size=p),y.query=null!=a?a:"min"),l&&(y.state=l),d&&(y.orientation=d),u&&(y.target=u),y});return{base:i,responsive:a}})(0,t,r)},Bn=new Set(["breakpoint","query","state","variant","target","orientation"]),Un={keyframes:"animation-name",duration:"animation-duration",easing:"animation-timing-function",delay:"animation-delay",iterationCount:"animation-iteration-count",direction:"animation-direction",fillMode:"animation-fill-mode",playState:"animation-play-state"},Dn={duration:"duration",easing:"easing",delay:"delay"},Wn=(e,t)=>"base"===t?`animation.${e}`:`animation.${e}.${t}`,Vn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(void 0===n||""===n||Bn.has(r))continue;const e=Un[r];e&&(t[e]="keyframes"===r?{ref:`animation.keyframes.${n}`}:Dn[r]?{ref:Wn(Dn[r],String(n))}:{value:n})}return t},Hn=new Set(["keyframes","recipes"]),Gn=e=>e&&"object"==typeof e&&"ref"in e?{ref:String(e.ref)}:"string"==typeof e||"number"==typeof e?{value:e}:void 0,Yn=e=>{const t={};for(const[r,n]of Object.entries(e)){const e=Gn(n);e&&(t[r]=e)}return t},Jn=e=>{const t=[];for(const[r,n]of Object.entries(e))t.push({stop:r,declarations:Yn(n)});return{steps:t}},Kn=e=>{if(!e||"object"!=typeof e)return{};const t={};for(const[r,n]of Object.entries(e))n&&"object"==typeof n&&(t[r]=Jn(n));return t},Xn={key:"animation",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Hn.has(n))continue;const e=je(o,{propertyPath:`animation.${n}`,allowedBreakpoints:t.allowedBreakpoints});he(e,{propertyPath:`animation.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:Vn(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:s,target:i,orientation:a,container:l,size:c,...u}=e,d={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...Vn(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),i&&(d.target=i),a&&(d.orientation=a),d})}))(0,t,r),buildStructural:e=>({ruleSetGroups:{},configProperties:{},keyframes:Kn(e.keyframes)})},Zn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e))t[eo(r)]=Qn(n);return t},Qn=e=>"object"==typeof e?{ref:e.ref}:{value:e},eo=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),to={key:"components",normalizeProperties:()=>({}),interpretRecipe:(e,t,r)=>((e,t)=>({base:Zn(t.base.css),responsive:t.responsive.map(e=>{var t,r;const n=e,o={declarations:Zn(n.css)};return n.breakpoint&&(o.breakpoint=n.breakpoint,o.query=null!==(t=n.query)&&void 0!==t?t:"exact"),n.container&&(o.container=n.container,n.size&&(o.size=n.size),o.query=null!==(r=n.query)&&void 0!==r?r:"min"),n.state&&(o.state=n.state),n.orientation&&(o.orientation=n.orientation),n.target&&(o.target=n.target),o})}))(0,t),extractReferences:e=>(e=>{const t=[];for(const[r,n]of Object.entries(e))J.has(r)&&"string"==typeof n&&n.includes(".")&&t.push(`${r}:${n}`);return t})(e)},ro=e=>({value:e}),no=e=>({ref:e}),oo=(e,t)=>({kind:"reset",selector:e,declarations:t,overrides:[]}),so=e=>{const t={};for(const[r,n,o]of e){const e={};for(const[t,r]of Object.entries(o))e[t]=ro(r);t[r]=oo(n,e)}return t},io=[["h1","4xl"],["h2","3xl"],["h3","2xl"],["h4","xl"],["h5","lg"],["h6","md"]],ao={preflight:{static:[["box","*,::before,::after",{"box-sizing":"border-box","border-width":"0","border-style":"solid"}],["body","body",{margin:"0","line-height":"inherit"}],["headings","h1,h2,h3,h4,h5,h6",{"font-size":"inherit","font-weight":"inherit",margin:"0"}],["blocks","p,figure,blockquote,dl,dd",{margin:"0"}],["lists","ul,ol",{"list-style":"none",margin:"0",padding:"0"}],["media","img,picture,video,canvas,svg",{display:"block","max-width":"100%"}],["forms","button,input,select,textarea",{font:"inherit",color:"inherit"}],["anchors","a",{color:"inherit","text-decoration":"inherit"}]],headings:!0},normalize:{static:[["box","*,::before,::after",{"box-sizing":"border-box"}],["body","body",{margin:"0"}],["media","img,picture,video,canvas,svg",{"max-width":"100%"}]],headings:!1},reset:{static:[["box","*,::before,::after",{"box-sizing":"border-box"}],["all","*",{margin:"0",padding:"0",border:"0",font:"inherit","vertical-align":"baseline"}],["headings","h1,h2,h3,h4,h5,h6",{"font-size":"inherit","font-weight":"inherit"}],["lists","ul,ol",{"list-style":"none"}],["media","img,picture,video,canvas,svg",{display:"block","max-width":"100%"}]],headings:!0}},lo=Object.keys(ao),co=e=>{if(!1===e)return{};const t=ao[e];if(!t)throw new P("REFRACT_E_PRESET",`globals: unknown preset "${e}" — expected one of ${lo.join(", ")} or false`);const r={static:so(t.static)};return t.headings&&(r.defaults=(()=>{const e={};for(const[t,r]of io)e[t]=oo(t,{"font-size":no(`typography.fontSize.${r}`)});return e})()),r},uo=new Set(["state","breakpoint","query","orientation","container","size","variant","target"]),fo=e=>null!==e&&"object"==typeof e?{ref:e.ref}:{value:e},po=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),mo=e=>{const t={};for(const[r,n]of Object.entries(e))null==n||uo.has(r)||(t[po(r)]=fo(n));return t},ho=e=>{const t={declarations:mo(e)},r=e;for(const e of uo)void 0!==r[e]&&(t[e]=r[e]);return t},go=(e,t,r)=>(e=>({declarations:mo(e.base),overrides:e.responsive.map(ho)}))(ze({[e]:t},r)[e]),bo=(e,t)=>{const r=null!=e?e:{},n={};if(void 0!==r.preset){const e=co(r.preset);e.static&&(n.static=e.static),e.defaults&&(n.defaults=e.defaults)}const o=((e,t)=>{if(!e||!Object.keys(e).length)return;const r=Object.keys(t.breakpoints),n={};for(const[o,s]of Object.entries(e)){if(!s||"object"!=typeof s)continue;const e={propertyPath:`globals.elements.${o}`,allowedBreakpoints:r,allowedStates:t.allowedStates,allowedContainers:t.allowedContainers},{variants:i,...a}=s,l=go(o,a,e),c={kind:"globals",selector:o,declarations:l.declarations,overrides:l.overrides};if(i&&"object"==typeof i&&Object.keys(i).length){const t={};for(const[r,n]of Object.entries(i))n&&"object"==typeof n&&(t[r]=go(r,n,{...e,propertyPath:`${e.propertyPath}.variants.${r}`}));Object.keys(t).length&&(c.variants=t)}n[o]=c}return Object.keys(n).length?n:void 0})(r.elements,t);return o&&(n.elements=o),n},vo=[Pr,Vr,gn,Fn,In,Xn,to,{key:"globals",normalizeProperties:()=>({}),buildStructural:(e,t)=>({ruleSetGroups:bo(e,t),configProperties:{}})}];const yo=(e,t)=>Ke(e,e=>rt(e,et(t))),wo=e=>{var t;if(!e||"object"!=typeof e)return;const r={};for(const[n,o]of Object.entries(e))o&&"object"==typeof o&&o.sizes&&Object.keys(o.sizes).length&&(r[n]={type:null!==(t=o.type)&&void 0!==t?t:"inline-size",sizes:{...o.sizes}});return Object.keys(r).length?r:void 0},$o=e=>{if(!e)return;const t=new Map;for(const[r,n]of Object.entries(e))t.set(r,new Set(Object.keys(n.sizes)));return t},ko=(e,t)=>{if(e.startsWith("--"))return e;const r=e.split(".").join("-").toLowerCase();return t?`--${t}-${r}`:`--${r}`};function xo(e,t,r){const{clean:n,externals:o}=((e,t)=>{if(!e)return{clean:e,externals:{}};const r={},n={};for(const[o,s]of Object.entries(e))if(null===s||"object"!=typeof s||Array.isArray(s)||"string"!=typeof s.external)r[o]=s;else{const e=ko(s.external,t);n[o]={base:`var(${e})`,external:e,responsive:[]}}return{clean:r,externals:n}})(t,r.extendsPrefix),s=e.normalizeProperties(n,{allowedBreakpoints:r.allowedBreakpoints});Object.assign(s,o);const i=r.inheritedProperties?{...r.inheritedProperties,...s}:s,a=function(e,t,r){var n,o;if(!e.interpretRecipe||!t||!Object.keys(t).length)return{};const s={};for(const[i,a]of Object.entries(t)){const t=`${e.key}.recipes.${i}`,l=ze(a,{propertyPath:t,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers}),c=Be(l,(n,o,s)=>e.interpretRecipe(n,o,{breakpoints:r.breakpoints,media:r.media,properties:r.properties,resolveRecipeVariant:s,groupPath:t}),{groupPath:t}).resolveAll(),u={};for(const[t,r]of Object.entries(c))if(e.extractReferences){const s=e.extractReferences(null!==(o=null===(n=l[t])||void 0===n?void 0:n.base)&&void 0!==o?o:{});u[t]=Y(r,s)}else u[t]=G(r);s[i]=u}return s}(e,null==t?void 0:t.recipes,{breakpoints:r.breakpoints,media:r.media,properties:i,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});let l,c,u=a;if(e.buildStructural&&t){const n=e.buildStructural(t,{breakpoints:r.breakpoints,media:r.media,mediaConfig:r.mediaConfig,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});u={...n.ruleSetGroups,...a},Object.keys(n.configProperties).length&&(l=n.configProperties),n.keyframes&&Object.keys(n.keyframes).length&&(c=n.keyframes)}const d={};return Object.keys(s).length&&(d.properties=s),Object.keys(u).length&&(d.ruleSetGroups=u),l&&(d.extraProperties=l),c&&(d.keyframes=c),d}function jo(e){const t={};if(!(null==e?void 0:e.properties))return t;for(const[r,n]of Object.entries(e.properties)){const e={base:n.base.value};if(n.variants&&Object.keys(n.variants).length){const t={};for(const[e,r]of Object.entries(n.variants)){const n={base:r.base.value};if(r.extras)for(const[e,t]of Object.entries(r.extras))n[e]=t.value;t[e]=n}e.variants=t}if(n.extras)for(const[t,r]of Object.entries(n.extras))e[t]=r.value;t[r]=e}return t}function Ao(e,t){var r,n,o,s,i;if(!e)return t;const a={...e};if(t.properties&&(a.properties={...null!==(r=e.properties)&&void 0!==r?r:{},...t.properties}),t.ruleSets){const r={...null!==(n=e.ruleSets)&&void 0!==n?n:{}};for(const[n,i]of Object.entries(t.ruleSets))r[n]={...null!==(s=null===(o=e.ruleSets)||void 0===o?void 0:o[n])&&void 0!==s?s:{},...i};a.ruleSets=r}return t.keyframes&&(a.keyframes={...null!==(i=e.keyframes)&&void 0!==i?i:{},...t.keyframes}),a}function So(e,t){var r,n,o,s;const{adapter:i}=t,a=e,l=null!==(r=a.breakpoints)&&void 0!==r?r:ot,c=Object.keys(l),u=null!==(o=null===(n=a.extends)||void 0===n?void 0:n.prefix)&&void 0!==o?o:"dt",d=i.allowedStates,f=new Set(null!==(s=a.modes)&&void 0!==s?s:["dark","light"]),p=t.media,m=yo(l,p),h=wo(a.containers),g=$o(h),b={};for(const e of vo){const t=xo(e,a[e.key],{breakpoints:l,extendsPrefix:u,media:m,mediaConfig:p,allowedBreakpoints:c,allowedStates:d,allowedContainers:g});Object.keys(t).length&&(b[e.key]=t)}const v=(e=>{var t;const r={},n=X(e.colors);n&&(r.colors=n);const o=X(e.typography);o&&(r.typography=o);const s=X(e.layout);s&&(r.layout=s);const i=X(e.effects);i&&(r.effects=i);const a=X(e.borders);a&&(r.borders=a);const l=X(e.animation);l&&(r.animation=l),K(null===(t=e.components)||void 0===t?void 0:t.ruleSetGroups)&&(r.components={ruleSets:e.components.ruleSetGroups});const c=X(e.globals);c&&(r.globals=c);const u={breakpoints:e.breakpoints,subsystems:r};return e.containers&&Object.keys(e.containers).length&&(u.containers=e.containers),u})({breakpoints:l,containers:h,...b}),y={units:t.units,baseFontSize:t.baseFontSize},w=function(e,t){var r;const{propertiesOverlay:n,ruleSetsOverlay:o,keyframesOverlay:s,containersOverlay:i}=t;if(!(n||o||s||i))return e;const a={...e.subsystems},l=new Set([...Object.keys(null!=n?n:{}),...Object.keys(null!=o?o:{}),...Object.keys(null!=s?s:{})]);for(const e of l)a[e]=Ao(a[e],{properties:null==n?void 0:n[e],ruleSets:null==o?void 0:o[e],keyframes:null==s?void 0:s[e]});const c={...e,subsystems:a};return i&&(c.containers={...null!==(r=e.containers)&&void 0!==r?r:{},...i}),c}(fe(v,y),t),$=(e=>{const t={};for(const r of e)for(const[e,n]of Object.entries(r)){if(e in t)throw new P("REFRACT_E_TOKEN_PATH",`Duplicate derivation fn "${e}" registered by two subsystems.`);t[e]=n}return t})(vo.flatMap(e=>e.derivations?[e.derivations]:[])),k=Ge(w,$),x=[...Ro(k),...Oo(k),...Co(k),...Eo(k,f)];if(x.length>0){const e=x.map(e=>` - ${e}`).join("\n");throw new P("REFRACT_E_VALIDATION",`refract: ${x.length} validation error(s):\n${e}`,x)}return To(k,{adapter:i,derivationRegistry:$,allowedStates:d,mediaConfig:p,unitConfig:y})}function Eo(e,t){var r,n,o;const s=[],i=(e,r,n,o)=>{t.has(n)||s.push(`${e}.${r}${o}: unknown appearance mode '${n}' — declare it in the top-level 'modes' registry (known: ${[...t].join(", ")})`)};for(const[t,s]of Object.entries(e.subsystems))for(const[e,a]of Object.entries(null!==(r=s.properties)&&void 0!==r?r:{})){for(const r of null!==(n=a.modes)&&void 0!==n?n:[])r.mode&&i(t,e,r.mode,"");for(const r of null!==(o=a.responsive)&&void 0!==o?o:[])r.mode&&i(t,e,r.mode," (responsive)")}return s}function Ro(e){var t,r,n,o,s;const i=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!i)return[];const a=[];for(const[t,l]of Object.entries(i))for(const[i,c]of Object.entries(l))for(const l of null!==(r=c.references)&&void 0!==r?r:[]){const[r,c=""]=l.split(":"),u=c.indexOf("."),d=u>=0?c.slice(0,u):c,f=u>=0?c.slice(u+1):"";(null===(s=null===(o=null===(n=e.subsystems[r])||void 0===n?void 0:n.ruleSets)||void 0===o?void 0:o[d])||void 0===s?void 0:s[f])||a.push(`components.${t}.${i}: Recipe variant "${f}" is not defined in "${r}:${d}". Check the subsystem:group.variant reference against what the subsystem declares.`)}return a}function Oo(e){var t,r;const n=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!n)return[];const o=Z(e),s=[],i=(e,t,r,n)=>{for(const[i,a]of Object.entries(null!=e?e:{}))void 0===a.ref||a.ref in o||s.push(`components.${t}.${r}: css '${i}'${n} references unknown token '${a.ref}' — check the token path, or use a bare string / number for a raw CSS value`)};for(const[e,t]of Object.entries(n))for(const[n,o]of Object.entries(t)){i(o.declarations,e,n,"");for(const t of null!==(r=o.overrides)&&void 0!==r?r:[])i(t.declarations,e,n," (override)")}return s}function Co(e){var t,r,n,o,s;const i=null===(t=e.subsystems.globals)||void 0===t?void 0:t.ruleSets;if(!i)return[];const a=Z(e),l=[],c=(e,t,r)=>{for(const[n,o]of Object.entries(null!=e?e:{}))void 0===o.ref||o.ref in a||l.push(`globals element '${t}'${r}: '${n}' references unknown token '${o.ref}' — check the token path, or use a bare string / number for a raw CSS value`)};for(const e of Object.values(i))for(const t of Object.values(e)){if("globals"!==t.kind)continue;const e=null!==(r=t.selector)&&void 0!==r?r:"";c(t.declarations,e,"");for(const r of null!==(n=t.overrides)&&void 0!==n?n:[])c(r.declarations,e," (override)");for(const[r,n]of Object.entries(null!==(o=t.variants)&&void 0!==o?o:{})){const t=` (variant '${r}')`;c(n.declarations,e,t);for(const r of null!==(s=n.overrides)&&void 0!==s?s:[])c(r.declarations,e,`${t} (override)`)}}return l}function To(e,t){var r;const n=yo(e.breakpoints,t.mediaConfig),o=st(e.containers,t.mediaConfig),s=new WeakMap,i=()=>{let t=s.get(e);return t||(t=Z(e),s.set(e,t)),t},a=e=>Ue(i(),t.derivationRegistry,e),l={media:n,containers:o,resolve:a},c=t.adapter.bind(e,l),u={model:e,get tokens(){return i()},resolveToken:a,override:r=>function(e,t,r){var n,o,s;const i=t.breakpoints,a=i?{...e.breakpoints,...i}:e.breakpoints,l=Object.keys(a),c=yo(a,r.mediaConfig),u=wo(t.containers),d=u?{...null!==(n=e.containers)&&void 0!==n?n:{},...u}:e.containers,f=$o(d),p={...e.subsystems};for(const n of vo){const i=t[n.key];if(void 0===i)continue;const u=jo(e.subsystems[n.key]),d=xo(n,i,{breakpoints:a,extendsPrefix:null!==(s=null===(o=t.extends)||void 0===o?void 0:o.prefix)&&void 0!==s?s:"dt",media:c,mediaConfig:r.mediaConfig,allowedBreakpoints:l,allowedStates:r.allowedStates,allowedContainers:f,inheritedProperties:u}),m=X(d);m&&(p[n.key]=Ao(e.subsystems[n.key],m))}const m={breakpoints:a,subsystems:p};d&&Object.keys(d).length&&(m.containers=d);const h=fe(m,r.unitConfig),g=Ge(h,r.derivationRegistry);return To(g,r)}(e,r,t)},d=null===(r=c.extend)||void 0===r?void 0:r.call(c,u);return d&&Object.defineProperties(u,Object.getOwnPropertyDescriptors(d)),u}const Fo="theme.css",No="styles.css",_o="variables.css",Po=(e,t)=>"variables"===t?`${e}.variables.css`:`${e}.css`,zo=e=>`${e.group}-${e.variant}.css`,Mo="variables.css";function qo(e){var t,r,n,o,s,i,a,l;if(void 0===e)return{type:"single",file:Fo};if("string"==typeof e)switch(e){case"single":return{type:"single",file:Fo};case"split":return{type:"split",file:No,variables:_o};case"subsystem":return{type:"subsystem",filename:Po};case"components":return{type:"components",inline:!0,filename:zo,variables:Mo}}switch(null!==(t=e.type)&&void 0!==t?t:"variables"in e?"split":"single"){case"single":return{type:"single",file:null!==(r=e.file)&&void 0!==r?r:Fo};case"split":{const t=e;return{type:"split",file:null!==(n=t.file)&&void 0!==n?n:No,variables:null!==(o=t.variables)&&void 0!==o?o:_o}}case"subsystem":return{type:"subsystem",filename:null!==(s=e.filename)&&void 0!==s?s:Po};case"components":{const t=e;return{type:"components",inline:null===(i=t.inline)||void 0===i||i,filename:null!==(a=t.filename)&&void 0!==a?a:zo,variables:null!==(l=t.variables)&&void 0!==l?l:Mo}}}throw new Error("resolveEmitPlan: unrecognized emit directive.")}const Lo="com.theme-registry.refract",Io=e=>"object"==typeof e&&null!==e&&"$value"in e,Bo=/^\{([^}]+)\}$/,Uo=(e,t,r=new Set)=>{if("string"==typeof e){const n=e.match(Bo);if(n){const o=n[1];if(r.has(o))throw new P("REFRACT_E_CYCLE",`Circular token reference: ${o}`);const s=t.get(o);return s?(r.add(o),Uo(s.value,t,r)):e}return e}if(Array.isArray(e))return e.map(e=>Uo(e,t,new Set(r)));if("object"==typeof e&&null!==e){const n={};for(const[o,s]of Object.entries(e))n[o]=Uo(s,t,new Set(r));return n}return e};function Do(e){var t;const r=[];for(const[n,o]of Object.entries(e.subsystems))for(const[e,s]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(s))r.push({subsystem:n,group:e,variant:t});return r}function Wo(){return{name:(e={name:"noop",version:1,bind:()=>({recipeName:()=>"",renderRecipe:()=>"",renderVariables:()=>"",join:e=>e.join(""),emit:()=>({files:{}})})}).name,version:e.version,allowedStates:e.allowedStates,bind(t,r){var n,o,s,i;const a=e.bind(t,r),l=null!==(n=a.renderAllRecipes)&&void 0!==n?n:()=>a.join(Do(t).map(({subsystem:e,group:t,variant:r})=>a.renderRecipe(e,t,r))),c=null!==(o=a.renderAllVariables)&&void 0!==o?o:()=>a.join(Object.keys(t.subsystems).map(e=>a.renderVariables(e))),u=null!==(s=a.renderAll)&&void 0!==s?s:()=>a.join([c(),l()]),d=null!==(i=a.describeUsage)&&void 0!==i?i:()=>({format:e.name,summary:[`This theme was built with the "${e.name}" refract adapter.`],recipes:Do(t).map(({subsystem:e,group:t,variant:r})=>({subsystem:e,group:t,variant:r,name:a.recipeName(e,t,r)}))});return{...a,renderAllRecipes:l,renderAllVariables:c,renderAll:u,describeUsage:d}}};var e}const Vo=(e,t)=>{var r,n,o;const s=(e=>{const t=[],r=new Map,n=(e,o,s)=>{var i,a,l;const c=null!==(i=e.$type)&&void 0!==i?i:s;for(const[s,i]of Object.entries(e)){if(s.startsWith("$"))continue;if("object"!=typeof i||null===i)continue;const e=[...o,s];if(Io(i)){const n=i,o={path:e,type:null!==(l=null!==(a=n.$type)&&void 0!==a?a:c)&&void 0!==l?l:"color",value:n.$value,description:n.$description,extensions:n.$extensions};t.push(o),r.set(e.join("."),o)}else n(i,e,c)}};n(e,[]);for(const e of t)e.value=Uo(e.value,r);return t})(e),i=null!==(r=null==t?void 0:t.groupMapping)&&void 0!==r?r:{},a={},l={},c={},u={},d={};let f=null!==(n=null==t?void 0:t.breakpoints)&&void 0!==n?n:{};const p=new Map;for(const e of s){const t=e.path[0];p.has(t)||p.set(t,[]),p.get(t).push(e)}const m=null==t?void 0:t.breakpointGroup;if(m&&p.has(m)){f={};for(const e of p.get(m)){f[e.path[e.path.length-1]]=as(e.value)}p.delete(m)}for(const[e,t]of p){const r=null!==(o=i[e])&&void 0!==o?o:Ho(e,t);if("ignore"!==r)switch(r){case"colors":Jo(t,e,a);break;case"typography":Xo(t,e,l);break;case"effects":es(t,e,c);break;case"borders":rs(t,e,u);break;case"layout":os(t,e,d)}}const h={};return Object.keys(f).length&&(h.breakpoints=f),Object.keys(a).length&&(h.colors=a),Object.keys(l).length&&(h.typography=l),Object.keys(c).length&&(h.effects=c),Object.keys(u).length&&(h.borders=u),Object.keys(d).length&&(h.layout=d),h},Ho=(e,t)=>{var r;const n=null===(r=t[0])||void 0===r?void 0:r.type;if("color"===n)return"colors";if("typography"===n)return"typography";if("shadow"===n)return"effects";if("border"===n)return"borders";if("strokeStyle"===n)return"borders";if("transition"===n)return"effects";const o=e.toLowerCase();if(o.includes("color")||o.includes("palette"))return"colors";if(o.includes("font")||o.includes("typo")||o.includes("text"))return"typography";if(o.includes("spacing")||o.includes("space")||o.includes("gutter"))return"layout";if(o.includes("radius")||o.includes("border")||o.includes("outline"))return"borders";if(o.includes("shadow")||o.includes("blur")||o.includes("opacity")||o.includes("z-index")||o.includes("zindex")||o.includes("transition")||o.includes("effect"))return"effects";if("dimension"===n){if(o.includes("spacing")||o.includes("gap"))return"layout";if(o.includes("radius")||o.includes("border"))return"borders";if(o.includes("font")||o.includes("size"))return"typography"}return"ignore"},Go=/^\{([^}]+)\}$/,Yo=e=>{if("string"!=typeof e)return;const t=e.match(Go);if(!t)return;const r=t[1],n=r.indexOf("."),o=n<0?r:r.slice(0,n),s=n<0?"":r.slice(n+1),i="color"===o?"colors":o;return s?`${i}.${s}`:i},Jo=(e,t,r)=>{var n;const o=new Map,s=[];for(const t of e)if(t.path.length<=2)s.push(t);else{const e=t.path[1];o.has(e)||o.set(e,[]),o.get(e).push(t)}for(const e of s){const t=e.path[e.path.length-1];if(!r[t]){const n=Yo(e.value);r[t]=n?{external:n}:{base:String(e.value)}}}for(const[e,t]of o)if(1===t.length){const n=t[0],o=n.path[n.path.length-1];o===e?r[e]={base:String(n.value)}:(r[e]||(r[e]={base:String(t[0].value)}),r[e].variants={[o]:String(n.value)})}else{const o=null!==(n=t.find(e=>{const t=e.path[e.path.length-1];return"base"===t||"default"===t||"500"===t}))&&void 0!==n?n:t[0],s={};for(const e of t){if(e===o)continue;s[e.path.slice(2).join("-")]=String(e.value)}r[e]={base:String(o.value),...Object.keys(s).length?{variants:s}:{}}}},Ko={fontfamily:"fontFamily",fontsize:"fontSize",fontweight:"fontWeight",lineheight:"lineHeight",letterspacing:"letterSpacing",fontstyle:"fontStyle",texttransform:"textTransform",textdecoration:"textDecoration",textalign:"textAlign"},Xo=(e,t,r)=>{for(const n of e)if("typography"===n.type){const e=n.value,t=n.path.slice(1).join("-")||n.path[n.path.length-1];e.fontFamily&&Zo(r,"fontFamily",Array.isArray(e.fontFamily)?e.fontFamily.join(", "):e.fontFamily,t),e.fontSize&&Zo(r,"fontSize",ls(e.fontSize),t),void 0!==e.fontWeight&&Zo(r,"fontWeight",e.fontWeight,t),void 0!==e.lineHeight&&Zo(r,"lineHeight",e.lineHeight,t),e.letterSpacing&&Zo(r,"letterSpacing",e.letterSpacing,t)}else{const e=Qo(n,t);if(!e)continue;const o=n.path[n.path.length-1],s="fontFamily"===n.type&&Array.isArray(n.value)?n.value.join(", "):"dimension"===n.type?ls(n.value):n.value;Zo(r,e,s,o)}},Zo=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Qo=(e,t)=>{if("fontFamily"===e.type)return"fontFamily";if("fontWeight"===e.type)return"fontWeight";const r=e.path.join(".").toLowerCase();for(const[e,t]of Object.entries(Ko))if(r.includes(e))return t;const n=t.toLowerCase();for(const[e,t]of Object.entries(Ko))if(n.includes(e))return t;return null},es=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"shadow":{const n=ss(t.value);ts(r,"shadow",n,e);break}case"transition":{const n=t.value,o=n.timingFunction?`cubic-bezier(${n.timingFunction.join(", ")})`:"ease",s=`all ${n.duration} ${o}`;ts(r,"transitions",s,e);break}case"dimension":t.path.join(".").toLowerCase().includes("blur")&&ts(r,"blur",ls(t.value),e);break;case"number":{const n=t.path.join(".").toLowerCase();n.includes("opacity")?ts(r,"opacity",t.value,e):(n.includes("z-index")||n.includes("zindex"))&&ts(r,"zIndex",t.value,e);break}}}},ts=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},rs=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"border":{const n=t.value;ns(r,"width",ls(n.width),e),n.style&&ns(r,"style",n.style,e);break}case"strokeStyle":ns(r,"style",String(t.value),e);break;case"dimension":{const n=t.path.join(".").toLowerCase();n.includes("radius")?ns(r,"radius",ls(t.value),e):n.includes("offset")?ns(r,"offset",ls(t.value),e):n.includes("width")&&ns(r,"width",ls(t.value),e);break}}}},ns=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},os=(e,t,r)=>{for(const t of e){if("dimension"!==t.type)continue;const e=t.path[t.path.length-1],n=as(t.value);r.spacing||(r.spacing={base:n,variants:{}});const o=r.spacing;"base"===e||"default"===e||"4"===e?o.base=n:o.variants[e]=n}},ss=e=>Array.isArray(e)?e.map(e=>is(e)).join(", "):is(e),is=e=>{const t=[];return e.inset&&t.push("inset"),t.push(e.offsetX,e.offsetY,e.blur,e.spread,e.color),t.join(" ")},as=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?0:e.endsWith("rem")?Math.round(16*t):t},ls=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?e:e.endsWith("px")?t:e},cs=(e,t)=>{var r;const n={};(null==t?void 0:t.name)&&(n.$name=t.name);const o=e.model.breakpoints;if(!1!==(null==t?void 0:t.includeBreakpoints)&&o&&Object.keys(o).length){const e={$type:"dimension"};for(const[t,r]of Object.entries(o))e[t]={$value:`${r}px`};n.breakpoint=e}const s=ds(e),i=t=>{try{return String(e.resolveToken(t))}catch{return t}},a=s.get("colors");if(a){const e={$type:"color"};for(const[t,r]of a){const n={};void 0!==r.base&&(n.base={$value:St(String(r.base))});for(const[e,t]of Object.entries(r.members))n[e]={$value:St(String(t))};e[t]=n}n.color=e}const l=s.get("typography");if(l){const e={};for(const[t,r]of l){const n={$type:fs(t)};void 0!==r.base&&(n.base={$value:ps(r.base,r.baseUnit)});for(const[e,t]of Object.entries(r.members))n[e]={$value:ps(t,r.memberUnits[e])};e[t]=n}n.typography=e}const c=s.get("effects");if(c)for(const[e,t]of c){const{groupName:r,type:o}=ms(e);n[r]||(n[r]={$type:o});const s=n[r];void 0!==t.base&&(s.base={$value:hs(e,t.base,i,t.baseUnit)});for(const[r,n]of Object.entries(t.members))s[r]={$value:hs(e,n,i,t.memberUnits[r])}}const u=s.get("borders");if(u)for(const[e,t]of u){const{groupName:r,type:o}=gs(e);n[r]||(n[r]={$type:o});const s=n[r];void 0!==t.base&&(s.base={$value:bs(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))s[e]={$value:bs(r,t.memberUnits[e])}}const d=s.get("layout");if(d)for(const[e,t]of d){if(e.includes("--"))continue;const r=e;n[r]||(n[r]={$type:"dimension"});const o=n[r];void 0!==t.base&&(o.base={$value:vs(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))o[e]={$value:vs(r,t.memberUnits[e])}}if(null==t?void 0:t.includeRecipes){const t=(e=>{const t={},r={},n={};for(const[o,s]of Object.entries(e.subsystems))s.properties&&Object.keys(s.properties).length&&(t[o]=s.properties),s.ruleSets&&Object.keys(s.ruleSets).length&&(r[o]=s.ruleSets),s.keyframes&&Object.keys(s.keyframes).length&&(n[o]=s.keyframes);const o=Object.keys(t).length>0,s=Object.keys(r).length>0,i=Object.keys(n).length>0,a=!!e.containers&&Object.keys(e.containers).length>0;if(o||s||i||a)return{version:1,...o?{properties:t}:{},...s?{ruleSets:r}:{},...i?{keyframes:n}:{},...a?{containers:e.containers}:{}}})(e.model);t&&(n.$extensions={...null!==(r=n.$extensions)&&void 0!==r?r:{},[Lo]:t})}return n},us=(e,t)=>void 0!==t?`${e}${t}`:e,ds=e=>{const t=new Map;for(const r of Object.keys(e.tokens)){const n=r.indexOf(".");if(n<0)continue;const o=r.slice(0,n),s=r.slice(n+1),i=s.indexOf("."),a=i<0?s:s.slice(0,i),l=i<0?void 0:s.slice(i+1),c=e.tokens[r];if(void 0!==(null==c?void 0:c.external))continue;let u;if(void 0!==(null==c?void 0:c.struct))u=c.struct;else try{u=e.resolveToken(r)}catch{continue}const d=null==c?void 0:c.unit;let f=t.get(o);f||(f=new Map,t.set(o,f));let p=f.get(a);p||(p={members:{},memberUnits:{}},f.set(a,p)),void 0===l?(p.base=u,void 0!==d&&(p.baseUnit=d)):(p.members[l]=u,void 0!==d&&(p.memberUnits[l]=d))}return t},fs=e=>{switch(e){case"fontFamily":return"fontFamily";case"fontWeight":return"fontWeight";case"fontSize":case"letterSpacing":return"dimension";default:return"number"}},ps=(e,t)=>us(e,t),ms=e=>{switch(e){case"shadow":return{groupName:"shadow",type:"shadow"};case"transitions":return{groupName:"transition",type:"transition"};case"blur":default:return{groupName:e,type:"dimension"};case"opacity":case"zIndex":return{groupName:e,type:"number"}}},hs=(e,t,r,n)=>Array.isArray(t)?"transitions"===e?t.map(e=>{var t;const r=[e.property];return null==e.duration&&null==e.delay||r.push(`${null!==(t=e.duration)&&void 0!==t?t:0}ms`),e.timingFunction&&r.push(e.timingFunction),null!=e.delay&&r.push(`${e.delay}ms`),r.join(" ")}).join(", "):((e,t)=>e.map(e=>{const r=`0${(e=>{for(const t of[e.offsetX,e.offsetY,e.blur,e.spread])if(void 0!==t&&"number"!=typeof t)return t.unit;return"px"})(e)}`,n=e=>void 0===e?r:(e=>"number"==typeof e?`${e}px`:`${e.value}${e.unit}`)(e),o=[];return e.inset&&o.push("inset"),o.push(n(e.offsetX),n(e.offsetY)),null!=e.spread?o.push(n(e.blur),n(e.spread)):null!=e.blur&&o.push(n(e.blur)),e.color&&o.push(t(e.color)),o.join(" ")}).join(", "))(t,r):us(t,n),gs=e=>{switch(e){case"radius":return{groupName:"radius",type:"dimension"};case"width":return{groupName:"borderWidth",type:"dimension"};case"offset":return{groupName:"outlineOffset",type:"dimension"};case"style":return{groupName:"borderStyle",type:"strokeStyle"};default:return{groupName:e,type:"dimension"}}},bs=(e,t)=>us(e,t),vs=(e,t)=>us(e,t);async function ys(r){var n,o;const{raw:s,adapter:i,outDir:a,helpers:u=[],emit:f,media:p,units:h,baseFontSize:g,guide:b,preview:v}=r,y=So(s,{adapter:i,media:p,units:h,baseFontSize:g}),$=Ke(y.model.breakpoints,e=>rt(e,et(p))),k=st(y.model.containers,p),x=i.bind(y.model,{media:$,containers:k,resolve:y.resolveToken});if(!x.emit)throw new Error(`Adapter "${i.name}" does not implement emit(); it cannot build to disk.`);const j=qo(f),A=x.emit(j),S=[];e.mkdirSync(a,{recursive:!0});const E=(r,n)=>{const o=t.join(a,r);e.mkdirSync(t.dirname(o),{recursive:!0}),e.writeFileSync(o,n,"utf8"),S.push(o)};for(const[e,t]of Object.entries(A.files))E(e,t);for(const[e,t]of Object.entries(null!==(n=A.vendorHelpers)&&void 0!==n?n:{}))E(e,t);for(const e of u){const t=c(e);if(!t)throw new Error(`Unknown vendor helper "${e}". Known: ${l.map(e=>e.id).join(", ")}.`);E(t.outfile,await m(d(t.source)))}if(b){const e=!0===b?{}:b,t=w(x.describeUsage(),cs(y),{files:Object.keys(A.files),packageName:e.packageName,llmsFile:e.llmsFile,manifestFile:e.manifestFile});for(const[e,r]of Object.entries(t.files))E(e,r)}if(v){const e=!0===v?{}:v,t=Object.keys(A.files),r=_({usage:x.describeUsage(),preview:null===(o=x.describePreview)||void 0===o?void 0:o.call(x,j,t),tokens:cs(y),model:y.model},{files:t,contents:A.files,plan:j,file:e.file,inline:e.inline,title:e.title});for(const[e,t]of Object.entries(r.files))E(e,t)}return{outDir:a,files:S}}const ws="theme.config",$s=[".ts",".mjs",".js"],ks=(r=process.cwd())=>{for(const n of $s){const o=t.join(r,`${ws}${n}`);if(e.existsSync(o))return o}};let xs=0;async function js(n={}){var o,s,i;const a=null!==(o=n.cwd)&&void 0!==o?o:process.cwd(),l=n.configPath?t.resolve(a,n.configPath):ks(a);if(!l||!e.existsSync(l)){const e=n.configPath?`"${n.configPath}"`:`${ws}.(ts|mjs|js) in "${a}"`;throw new Error(`No theme config found at ${e}.`)}const c=await async function(e){if(".ts"!==t.extname(e)){const t=`${r.pathToFileURL(e).href}?v=${++xs}`;return await import(t)}const{entry:n,cleanup:o}=await b(e);try{return await import(r.pathToFileURL(n).href)}finally{o()}}(l),u=null!==(i=null!==(s=c.default)&&void 0!==s?s:c.config)&&void 0!==i?i:c;if(!u||"object"!=typeof u||!Array.isArray(u.targets))throw new Error(`"${l}" must export (default) a defineConfig({ raw, targets }) object.`);return{config:u,path:l}}const As="@theme-registry/refract-css";function Ss(){var r;const n=t.join(u(),"package.json");return null!==(r=JSON.parse(e.readFileSync(n,"utf8")).name)&&void 0!==r?r:"@theme-registry/refract"}const Es="theme.raw",Rs=[".ts",".mts",".mjs",".js",".json"],Os=(r=process.cwd())=>{for(const n of Rs){const o=t.join(r,`${Es}${n}`);if(e.existsSync(o))return{path:o,filename:`${Es}${n}`,ext:n}}};function Cs(e){if(".json"===e.ext)return{head:`import { readFileSync } from "node:fs";\n\n// The theme is JSON, so it's read rather than imported — no module-attribute support needed.\nconst raw = JSON.parse(readFileSync(new URL("./${e.filename}", import.meta.url), "utf8"));\n`,expression:"raw"};return{head:`import { raw } from "${".ts"===e.ext||".mts"===e.ext?`./${Es}`:`./${e.filename}`}";\n`,expression:"raw"}}function Ts(e,t){const{head:r,expression:n}=Cs(t);return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${As}";\n${r}\n// refract build config. \`refract build\` reads this file, builds the theme once, and writes each\n// target's emitted files into that target's \`outDir\`. The config is your code: it \`import\`s the\n// adapters it wants and passes their options at construction (not via CLI flags).\n//\n// Your tokens live in \`${t.filename}\` — edit them there, not here.\nexport default defineConfig({\n raw: ${n},\n targets: [\n // The CSS adapter (from @theme-registry/refract-css). Pass its options here, at construction.\n { adapter: createCssAdapter(/* { colors: { prefix: "app" } } */), outDir: "dist/theme" },\n\n // Add another adapter target once its package is installed, e.g.:\n // import { createStyledComponentsAdapter } from "@theme-registry/refract-styled-components";\n // { adapter: createStyledComponentsAdapter(), outDir: "dist/theme-sc" },\n ],\n});\n`}function Fs(e){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${As}";\n\n// refract build config. \`refract build\` reads this file, builds the theme once, and writes\n// each target's emitted files into that target's \`outDir\`. The config is your code: it \`import\`s\n// the adapters it wants and passes their options at construction (not via CLI flags).\nexport default defineConfig({\n // The raw theme — authored in refract's nested slices. Extend with typography/effects/layout.\n raw: {\n breakpoints: { sm: 576, md: 768, lg: 1024, xl: 1280 },\n colors: {\n // Starter palette passes its own contrast audit (WCAG AA): white text clears 4.5:1 on both\n // bases. Keep that when you retune — the auditor is a shipped feature; the default should model it.\n primary: { base: "#1864ab", text: "#fff", variants: { dark: "#0b4a86", light: "#a5d8ff" } },\n neutral: { base: "#495057", text: "#fff", variants: { light: "#f1f3f5", dark: "#212529" } },\n recipes: {\n solid: {\n primary: { background: "primary", color: "primary.text" },\n neutral: { background: "neutral.light", color: "neutral.dark" },\n },\n },\n },\n },\n targets: [\n // The CSS adapter (from @theme-registry/refract-css). Pass its options here, at construction.\n { adapter: createCssAdapter(/* { colors: { prefix: "app" } } */), outDir: "dist/theme" },\n\n // Add another adapter target once its package is installed, e.g.:\n // import { createStyledComponentsAdapter } from "@theme-registry/refract-styled-components";\n // { adapter: createStyledComponentsAdapter(), outDir: "dist/theme-sc" },\n ],\n});\n`}function Ns(r={}){var n,o,s,i;const a=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),l=null!==(o=r.variant)&&void 0!==o?o:"ts",c=null!==(s=r.packageName)&&void 0!==s?s:Ss(),u=t.join(a,`theme.config.${l}`);if(e.existsSync(u)&&!r.force)throw new Error(`theme.config.${l} already exists at "${u}". Pass --force to overwrite it.`);const d=null===r.rawTheme?void 0:null!==(i=r.rawTheme)&&void 0!==i?i:Os(a),f=d?Ts(c,d):Fs(c);return e.writeFileSync(u,f,"utf8"),{path:u,variant:l,packageName:c,rawTheme:d}}const _s=[["xs",-2],["sm",-1],["md",0],["lg",1],["xl",2],["2xl",3],["3xl",4],["4xl",5]],Ps={"minor-second":1.067,"major-second":1.125,"minor-third":1.2,"major-third":1.25,"perfect-fourth":1.333,"augmented-fourth":1.414,"perfect-fifth":1.5,golden:1.618},zs={complement:[180],analogous:[-30,30],"split-complement":[150,210],triadic:[120,240],tetradic:[90,180,270],pentadic:[72,144,216,288]},Ms=["primary","secondary","tertiary","quaternary","quinary"],qs=[["success","#2f9e44","#ffffff"],["info","#1c7ed6","#ffffff"],["warning","#e89012","#1f2733"],["danger","#e03131","#ffffff"]],Ls=[50,100,200,300,400,500,600,700,800,900],Is=[8,14,22],Bs="system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Us="ui-monospace, 'SF Mono', Menlo, Consolas, monospace",Ds={neutral:{label:"Neutral",blurb:"system type, comfortable spacing, soft corners",fontFamily:{base:Bs,mono:Us},spacing:{xs:1,sm:2,md:4,lg:6,xl:8,"2xl":12},radius:{base:8,variants:{none:0,sm:4,lg:14,pill:"9999px"}},ratio:"major-third"},compact:{label:"Compact",blurb:"dense UI, tight scale, small radius",fontFamily:{base:Bs,mono:Us},spacing:{xs:1,sm:2,md:3,lg:4,xl:6,"2xl":8},radius:{base:4,variants:{none:0,sm:2,lg:8,pill:"9999px"}},ratio:"major-second"},editorial:{label:"Editorial",blurb:"serif display, spacious, generous leading",fontFamily:{base:"'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif",mono:Us},spacing:{xs:2,sm:4,md:6,lg:8,xl:12,"2xl":16},radius:{base:2,variants:{none:0,sm:1,lg:4,pill:"9999px"}},ratio:"perfect-fourth"},technical:{label:"Technical",blurb:"mono accents, compact, sharp corners",fontFamily:{base:Us,mono:Us},spacing:{xs:1,sm:2,md:3,lg:4,xl:6,"2xl":8},radius:{base:0,variants:{none:0,sm:0,lg:2,pill:"9999px"}},ratio:"minor-third"}},Ws=(e,t)=>Number(e.toFixed(t)),Vs=e=>dt(pt(e).rgb),Hs=e=>Ws(Math.min(1.7,Math.max(1.1,1.5*Math.pow(16/e,.22))),2),Gs=e=>`${Ws(.36/e-.0225,3)}em`,Ys=e=>{const t=1e3-10*e;let r=Ls[0];for(const e of Ls)Math.abs(e-t)<Math.abs(r-t)&&(r=e);return r},Js=e=>{if(!(e<=1))return 2===e?"complement":3===e?"triadic":4===e?"tetradic":"pentadic"},Ks=e=>Object.keys(zs).filter(t=>zs[t].length===e-1);function Xs(e){var t,r,n,o,s,i,a,l,c;const u=null!==(t=e.mode)&&void 0!==t?t:"auto",d=Ds[null!==(r=e.feel)&&void 0!==r?r:"neutral"],f=Math.min(5,Math.max(1,null!==(n=e.brandCount)&&void 0!==n?n:2)),p=null!==(o=e.baseFontSize)&&void 0!==o?o:16,m=null!==(s=e.ratio)&&void 0!==s?s:d.ratio,h=Ps[m];if(!h)throw new Error(`Unknown type ratio "${m}". Use one of: ${Object.keys(Ps).join(", ")}.`);const g=Vs(e.seed),b=[{name:Ms[0],hex:g,rotation:0}];if("manual"===u)(null!==(i=e.extraColors)&&void 0!==i?i:[]).slice(0,Ms.length-1).forEach((e,t)=>{b.push({name:Ms[t+1],hex:Vs(e),rotation:0})});else if(f>1){const t=null!==(a=e.scheme)&&void 0!==a?a:Js(f),r=zs[t];if(!r)throw new Error(`Unknown harmony scheme "${t}".`);r.slice(0,f-1).forEach((e,t)=>{b.push({name:Ms[t+1],hex:Vs(jt(g,e)),rotation:e})})}const v=null!==(l=e.contrast)&&void 0!==l?l:"AA",y=[...b.map(e=>({name:e.name,base:e.hex,text:"#ffffff"})),...!1===e.semantics?[]:qs.map(([e,t,r])=>({name:e,base:t,text:r})),...!1===e.neutral?[]:[{name:"neutral",base:"#6b7280",text:"#ffffff"}]],{palettes:w,adjustments:$}="none"===v?{palettes:y,adjustments:[]}:function(e,t){var r;const n=e.map(e=>({...e})),o=new Map(n.map(e=>[e.name,0])),s=new Map,i=()=>{var e,r;const o={};for(const e of n)o[e.name]={base:e.base,text:e.text};const s=So({colors:o},{adapter:Wo()}),i=Tr(s,{minWcag:t,includeRecipes:!1}),a=new Map;for(const t of i.pairings){if(t.skipped||void 0===t.wcagRatio)continue;const n=t.label.replace(/^colors\./,"");a.set(n,{ratio:t.wcagRatio,level:null!==(e=t.wcagLevel)&&void 0!==e?e:"fail",pass:null!==(r=t.pass)&&void 0!==r&&r})}return a};let a=i();for(const[e,t]of a)s.has(e)||s.set(e,t.ratio);for(let e=0;e<40;e++){const e=n.filter(e=>a.get(e.name)&&!a.get(e.name).pass);if(!e.length)break;for(const t of e)t.base=Vs(kt(t.base,1)),o.set(t.name,(null!==(r=o.get(t.name))&&void 0!==r?r:0)+1);a=i()}const l=n.map((t,r)=>{var n,i,l,c;const u=a.get(t.name);return{name:t.name,seed:e[r].base,final:t.base,nudge:null!==(n=o.get(t.name))&&void 0!==n?n:0,ratioBefore:Ws(null!==(i=s.get(t.name))&&void 0!==i?i:0,2),ratioAfter:Ws(null!==(l=null==u?void 0:u.ratio)&&void 0!==l?l:0,2),levelAfter:null!==(c=null==u?void 0:u.level)&&void 0!==c?c:"fail",unresolved:!!u&&!u.pass}});return{palettes:n,adjustments:l}}(y,v),k={};for(const e of w)k[e.name]={base:e.base,text:e.text,steps:[...Ls]};if(!1!==e.shadows){const e={};for(const t of Is)e[`a${String(t).padStart(2,"0")}`]={modifiers:[{alpha:t}]};k.shadow={base:"#18274b",variants:e}}const x=_s.map(([e,t])=>({step:e,px:Ws(p*Math.pow(h,t),2)})),j={},A={};for(const{step:e,px:t}of x)"md"!==e&&(j[e]=Hs(t),A[e]=Gs(t));A.caps="0.06em";const S={fontFamily:{base:d.fontFamily.base,variants:{mono:d.fontFamily.mono}},fontWeight:{base:400,variants:{medium:500,semibold:600,bold:700}},fontSize:{base:p,ratio:m},lineHeight:{base:Hs(p),variants:j},letterSpacing:{base:"0em",variants:A}},E={spacing:{base:4,step:4,steps:{...d.spacing}}},R={width:{base:1,variants:{thick:2}},style:{base:"solid"},radius:{base:d.radius.base,variants:{...d.radius.variants}}},O=!1===e.shadows?void 0:{shadow:{offsetY:1,blur:3,color:"colors.shadow.a08",variants:{md:{offsetY:6,blur:16,color:"colors.shadow.a14"},lg:{offsetY:14,blur:34,color:"colors.shadow.a22"},none:"none"}}},C={colors:k,typography:S,layout:E,borders:R,...O?{effects:O}:{},animation:{duration:{base:200,variants:{fast:120,slow:400}},easing:{base:"cubic-bezier(.2,.7,.3,1)",variants:{out:"cubic-bezier(.16,.84,.44,1)"}}},..."none"===e.reset?{}:{globals:{preset:null!==(c=e.reset)&&void 0!==c?c:"preflight"}}},T=Ws(vt(pt(g).rgb).L,1);return{raw:C,report:{seedLightness:T,nearestStep:Ys(T),brand:b.map(e=>{var t;const r=$.find(t=>t.name===e.name);return{name:e.name,hex:null!==(t=null==r?void 0:r.final)&&void 0!==t?t:e.hex,rotation:e.rotation}}),contrast:$,type:x.map(({step:e,px:t})=>({step:e,px:t,leading:Hs(t),tracking:Gs(t)})),spacing:Object.entries(d.spacing).map(([e,t])=>({step:e,px:4*t}))}}}const Zs="theme.raw",Qs=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ei=e=>JSON.stringify(e);function ti(e,t=0){const r=" ".repeat(t),n=" ".repeat(t+1);if(null===e)return"null";if("string"==typeof e)return ei(e);if("number"==typeof e||"boolean"==typeof e)return String(e);if(Array.isArray(e)){if(!e.length)return"[]";if(e.every(e=>null===e||"object"!=typeof e)){const t=`[${e.map(e=>ti(e)).join(", ")}]`;if(r.length+t.length<=76)return t}return`[\n${e.map(e=>`${n}${ti(e,t+1)}`).join(",\n")}\n${r}]`}const o=Object.entries(e);if(!o.length)return"{}";return`{\n${o.map(([e,r])=>{const o=Qs.test(e)?e:ei(e);return`${n}${o}: ${ti(r,t+1)}`}).join(",\n")}\n${r}}`}const ri=(e,t)=>`// Generated by \`refract create\` — seed ${e} · ${t}.\n// This is YOUR theme now: every value is a literal you can read, edit and delete. The generator\n// does not run again. Tonal ladders, the type scale and the spacing ramp are synthesized by the\n// engine from the declarations below — re-tune a scale by editing one word, not eight numbers.\n`;function ni(e,t){if("json"===t.format)return`${JSON.stringify(e,null,2)}\n`;const r=ti(e);return"js"===t.format?`${ri(t.seed,t.detail)}\n/** @type {import("${t.packageName}/build").RawTheme} */\nexport const raw = ${r};\n`:`${ri(t.seed,t.detail)}import type { RawTheme } from "${t.packageName}/build";\n\nexport const raw = ${r} satisfies RawTheme;\n`}function oi(e){var t,r,n,o,s,i;const a=[],l="manual"===e.mode?(null!==(r=null===(t=e.extraColors)||void 0===t?void 0:t.length)&&void 0!==r?r:0)+1:null!==(n=e.brandCount)&&void 0!==n?n:2;return a.push(`${l} brand colour${1===l?"":"s"}`),"manual"!==e.mode&&l>1&&a.push(null!==(o=e.scheme)&&void 0!==o?o:"auto"),a.push(null!==(s=e.feel)&&void 0!==s?s:"neutral"),"none"!==e.contrast&&a.push(`WCAG ${null!==(i=e.contrast)&&void 0!==i?i:"AA"}`),a.join(" · ")}function si(r){var n,o,s,i;const a=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),l=null!==(o=r.format)&&void 0!==o?o:"ts",c=null!==(s=r.out)&&void 0!==s?s:`${Zs}.${l}`,u=t.join(a,c);if(e.existsSync(u)&&!r.force)throw new Error(`"${c}" already exists. Re-run with --force to overwrite it.`);const{raw:d,report:f}=Xs(r),p=ni(d,{format:l,packageName:null!==(i=r.packageName)&&void 0!==i?i:Ss(),seed:r.seed,detail:oi(r)});return e.writeFileSync(u,p,"utf8"),{path:u,format:l,raw:d,report:f,sections:Object.keys(d)}}const ii=()=>Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,ai=(e,t)=>ii()?`[${e}m${t}[0m`:t,li=e=>ai("1",e),ci=e=>ai("2",e),ui=e=>ai("36",e),di=e=>ai("32",e),fi=e=>ai("33",e),pi=e=>e>0?`[${e}A`:"",mi="[0J";function hi(e,t=2){if(!ii())return"";const r=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!r)return"";const n=parseInt(r[1],16),[o,s,i]=[n>>16&255,n>>8&255,255&n],a=/truecolor|24bit/i.test(null!==(l=process.env.COLORTERM)&&void 0!==l?l:"")?`48;2;${o};${s};${i}`:`48;5;${((e,t,r)=>{const n=e=>e<48?0:e<114?1:Math.min(5,Math.round((e-35)/40));return 16+36*n(e)+6*n(t)+n(r)})(o,s,i)}`;var l;return`[${a}m${" ".repeat(t)}[0m`}function gi(e){switch(e){case"[A":case"k":return"up";case"[B":case"j":return"down";case" ":return"space";case"\r":case"\n":return"submit";case"a":return"all";case"":case"":return"cancel";default:return"none"}}function bi(e){const t=[];for(let r=0;r<e.length;)""===e[r]&&"["===e[r+1]&&r+2<e.length?(t.push(gi(e.slice(r,r+3))),r+=3):(t.push(gi(e[r])),r+=1);return t}function vi(e,t,r,n){if(e.done||e.cancelled||0===r)return e;switch(t){case"up":return{...e,cursor:(e.cursor-1+r)%r};case"down":return{...e,cursor:(e.cursor+1)%r};case"space":{if(!n)return e;const t=new Set(e.selected);return t.has(e.cursor)?t.delete(e.cursor):t.add(e.cursor),{...e,selected:t}}case"all":{if(!n)return e;const t=e.selected.size===r;return{...e,selected:t?new Set:new Set(Array.from({length:r},(e,t)=>t))}}case"submit":return{...e,done:!0};case"cancel":return{...e,cancelled:!0};default:return e}}const yi=()=>Boolean(process.stdin.isTTY)&&"function"==typeof process.stdin.setRawMode;class wi{constructor(e=Boolean(process.stdin.isTTY)&&Boolean(process.stdout.isTTY)){this.interactive=e}get io(){return this.rl||(this.rl=n.createInterface({input:process.stdin,output:process.stdout})),this.rl}close(){var e;null===(e=this.rl)||void 0===e||e.close(),this.rl=void 0}question(e){return new Promise(t=>this.io.question(e,e=>t(e)))}out(e){process.stdout.write(e)}write(e=""){process.stdout.write(`${e}\n`)}async text(e,t,r){if(!this.interactive)return t;for(;;){const n=(await this.question(`${ui("?")} ${li(e)} ${ci(`(${t})`)} `)).trim()||t,o=null==r?void 0:r(n);if(!o)return n;this.write(` ${fi("!")} ${o}`)}}async number(e,t,r){const n=await this.text(e,String(t),e=>{const t=Number(e);return Number.isFinite(t)?null==r?void 0:r(t):`"${e}" is not a number.`});return Number(n)}async select(e,t,r=0){var n,o,s;if(!this.interactive||1===t.length)return null!==(o=null===(n=t[r])||void 0===n?void 0:n.value)&&void 0!==o?o:t[0].value;if(yi()){return t[null!==(s=(await this.runList(e,t,{multi:!1,cursor:r,selected:new Set}))[0])&&void 0!==s?s:r].value}return this.selectByNumber(e,t,r)}async multiselect(e,t,r){var n;if(!this.interactive)return r.map(e=>t[e].value);if(yi()){return(await this.runList(e,t,{multi:!0,cursor:null!==(n=r[0])&&void 0!==n?n:0,selected:new Set(r)})).map(e=>t[e].value)}return this.multiselectByNumber(e,t,r)}runList(e,t,r){this.close();const n=process.stdin,{multi:o}=r;let s={cursor:Math.max(0,Math.min(r.cursor,t.length-1)),selected:r.selected,done:!1,cancelled:!1},i=0;const a=o?"↑↓ move · space toggle · a all · enter confirm":"↑↓ move · enter select",l=t.reduce((e,t)=>Math.max(e,t.label.length),0),c=()=>{i&&this.out(pi(i)+mi);const r=(()=>{const r=t.map((e,t)=>{var r;const n=t===s.cursor,i=n?di("❯"):" ",a=o?s.selected.has(t)?di("[✓]"):ci("[ ]"):"",c=n?li(e.label):e.label,u=" ".repeat(Math.max(0,l-e.label.length)),d=(null!==(r=e.swatches)&&void 0!==r?r:[]).map(e=>hi(e)).filter(Boolean).join(" ");return` ${i} ${a?`${a} `:""}${c}${u}${d?` ${d}`:""}${e.hint?` ${ci(e.hint)}`:""}`});return[`${ui("?")} ${li(e)} ${ci(a)}`,...r].join("\n")})();this.out(`${r}\n`),i=r.split("\n").length};return new Promise((r,a)=>{const l=()=>{n.removeListener("data",d),n.removeListener("end",u),n.isTTY&&n.setRawMode(!1),n.pause(),this.out("[?25h")},u=()=>{const e=o?[...s.selected].sort((e,t)=>e-t):[s.cursor];this.out(pi(i)+mi),l(),r(e)},d=n=>{for(const e of bi(n))if(s=vi(s,e,t.length,o),s.done||s.cancelled)break;if(s.cancelled)return this.out(pi(i)+mi),l(),void a(new Error("Cancelled."));if(s.done){const n=o?[...s.selected].sort((e,t)=>e-t):[s.cursor];this.out(pi(i)+mi);const a=n.length?n.map(e=>t[e].label).join(", "):"none";return this.write(`${ui("?")} ${li(e)} ${ci("›")} ${di(a)}`),l(),void r(n)}c()};n.setRawMode(!0),n.resume(),n.setEncoding("utf8"),this.out("[?25l"),n.on("data",d),n.on("end",u),c()})}async selectByNumber(e,t,r){for(this.write(`${ui("?")} ${li(e)}`),t.forEach((e,t)=>{const n=t===r?di("❯"):" ",o=e.hint?` ${ci(`— ${e.hint}`)}`:"";this.write(` ${n} ${ci(`${t+1}.`)} ${t===r?li(e.label):e.label}${o}`)});;){const e=(await this.question(` ${ci(`1–${t.length}`)} `)).trim();if(!e)return t[r].value;const n=Number(e)-1;if(Number.isInteger(n)&&n>=0&&n<t.length)return t[n].value;this.write(` ${fi("!")} Enter a number between 1 and ${t.length}.`)}}async multiselectByNumber(e,t,r){for(this.write(`${ui("?")} ${li(e)} ${ci('(comma-separated, blank = keep, "none" = clear)')}`),t.forEach((e,t)=>{const n=r.includes(t),o=e.hint?` ${ci(`— ${e.hint}`)}`:"";this.write(` ${n?di("◉"):ci("◯")} ${ci(`${t+1}.`)} ${e.label}${o}`)});;){const e=(await this.question(` ${ci(`1–${t.length}`)} `)).trim().toLowerCase();if(!e)return r.map(e=>t[e].value);if("none"===e)return[];const n=e.split(",").map(e=>Number(e.trim())-1);if(n.every(e=>Number.isInteger(e)&&e>=0&&e<t.length))return n.map(e=>t[e].value);this.write(` ${fi("!")} Enter numbers between 1 and ${t.length}, separated by commas.`)}}}const $i={complement:[180],analogous:[-30,30],"split-complement":[150,210],triadic:[120,240],tetradic:[90,180,270],pentadic:[72,144,216,288]},ki=(e,t)=>{var r;return(null!==(r=$i[t])&&void 0!==r?r:[]).map(t=>dt(pt(jt(e,t)).rgb))},xi={complement:"one companion, 180° opposite — maximum separation",analogous:"two neighbours, ±30° — quiet and cohesive","split-complement":"the complement's neighbours — contrast with less tension",triadic:"even thirds, ±120° — three colours of equal weight",tetradic:"two complementary pairs — the most range",pentadic:"five evenly spaced hues — needs a dominant colour picked by hand"},ji=[["major-second","1.125 · 16 · 18 · 20 · 23 · 26 · 29"],["minor-third","1.2 · 16 · 19 · 23 · 28 · 33 · 40"],["major-third","1.25 · 16 · 20 · 25 · 31 · 39 · 49"],["perfect-fourth","1.333 · 16 · 21 · 28 · 38 · 51 · 67"],["perfect-fifth","1.5 · 16 · 24 · 36 · 54 · 81 · 122"],["golden","1.618 · 16 · 26 · 42 · 68 · 110 · 178"]],Ai=e=>{try{return void pt(e)}catch{return`"${e}" isn't a colour refract can parse. Try a hex like #4c6ef5.`}};async function Si(e,t={}){var r,n,o,s,i,a,l,c;const u=null!==(r=t.seed)&&void 0!==r?r:await e.text("Primary colour","#4c6ef5",Ai),d=Math.round(10*vt(pt(u).rgb).L)/10,f=dt(pt(u).rgb),p=hi(f,3);e.write(` ${p?`${p} `:""}${ci(`${f} · lightness ${d}% — lands at ≈${Ys(d)} on the ladder`)}`),e.write();const m=Boolean(t.manual);let h,g=2,b=[];if(m){if(b=(null!==(n=t.colors)&&void 0!==n?n:"").split(",").map(e=>e.trim()).filter(Boolean),!b.length&&e.interactive){const t=await e.number("How many brand colours in total?",2,e=>Number.isInteger(e)&&e>=1&&e<=5?void 0:"Pick a whole number from 1 to 5.");for(let r=1;r<t;r++)b.push(await e.text(`Brand colour ${r+1}`,"#e64980",Ai))}g=b.length+1}else{g=t.colors?Number(t.colors):await e.number("How many brand colours? (including the primary)",2,e=>Number.isInteger(e)&&e>=1&&e<=5?void 0:"Pick a whole number from 1 to 5.");const r=Ks(g);h=null!==(o=t.scheme)&&void 0!==o?o:Js(g),!t.scheme&&r.length>1&&(h=await e.select("Harmony scheme",r.map(e=>({value:e,label:e,hint:xi[e],swatches:[f,...ki(f,e)]})),Math.max(0,r.indexOf(h)))),h&&g>1&&(e.write(` ${ci(`→ ${h} · each member becomes its own palette with a full ladder`)}`),e.write())}const v=t.noSemantics||t.noNeutral||t.noShadows||!e.interactive?{semantics:!t.noSemantics,neutral:!t.noNeutral,shadows:!t.noShadows}:await(async()=>{const t=await e.multiselect("Also add",[{value:"semantics",label:"Semantic colours",hint:"success · info · warning · danger"},{value:"neutral",label:"Neutral ramp",hint:"50 … 900"},{value:"shadows",label:"Shadow tints",hint:"3 alpha levels + the effects ramp"}],[0,1,2]);return{semantics:t.includes("semantics"),neutral:t.includes("neutral"),shadows:t.includes("shadows")}})(),y=null!==(s=t.contrast)&&void 0!==s?s:await e.select("Contrast target",[{value:"AA",label:"WCAG AA",hint:"4.5:1 body text"},{value:"AAA",label:"WCAG AAA",hint:"7:1 — expect heavier nudges"},{value:"none",label:"Skip",hint:"write the colours exactly as given"}]),w=void 0!==t.baseSize?Number(t.baseSize):await e.number("Base font size (px)",16,e=>e>0?void 0:"Must be greater than zero."),$=null!==(i=t.feel)&&void 0!==i?i:await e.select("Overall feel",Object.keys(Ds).map(e=>({value:e,label:Ds[e].label,hint:Ds[e].blurb}))),k=null!==(a=t.ratio)&&void 0!==a?a:await e.select("Type scale",ji.map(([e,t])=>({value:e,label:e,hint:t})),Math.max(0,ji.findIndex(([e])=>e===Ds[$].ratio))),x=null!==(l=t.reset)&&void 0!==l?l:await e.select("CSS reset",[{value:"preflight",label:"preflight",hint:"full normalization + an h1–h6 size map"},{value:"normalize",label:"normalize",hint:"the classic, no heading map"},{value:"none",label:"none",hint:"you already ship one"}]),j=null!==(c=t.format)&&void 0!==c?c:await e.select("Format",[{value:"ts",label:"theme.raw.ts",hint:"typed, `satisfies RawTheme`"},{value:"js",label:"theme.raw.js",hint:"plain ESM, no build step"},{value:"json",label:"theme.raw.json",hint:"portable, no code at all"}]);return{seed:u,mode:m?"manual":"auto",brandCount:g,scheme:h,extraColors:b,...v,contrast:y,baseFontSize:w,ratio:k,feel:$,reset:x,format:j}}function Ei(e,t){const r=[],{contrast:n}=e.report;if(n.length){r.push(` ${ci(`Contrast · ${n.length} pairings checked`)}`);for(const e of n){const t=e.nudge>0?`${fi(`−${e.nudge}`)} ${di(`${e.ratioAfter} ${e.levelAfter}`)}`:ci("unchanged"),n=e.unresolved?` ${fi("! still short of the bar")}`:"";r.push(` ${e.name.padEnd(10)} ${String(e.ratioBefore).padStart(5)} ${t}${n}`)}r.push("")}const o=n.filter(e=>e.nudge>0).length;return r.push(` ${ci(`${e.sections.length} subsystems · ${t} variables · 0 recipes`)}`),o&&r.push(` ${ci(`${o} colour${1===o?"":"s"} darkened to clear the contrast bar`)}`),r}const Ri="theme.config.ts";function Oi(e){const t={};for(const r of e.split(",")){const[e,n]=r.split(":"),o=null==e?void 0:e.trim(),s=Number.parseFloat((null!=n?n:"").trim());o&&Number.isFinite(s)&&(t[o]=s)}return t}function Ci(e,t,r){return`// Generated by \`refract import\` from ${r}.\n// DTCG carries property tokens ONLY — recipes, components, composition, and states are not imported.\n// The mapping is heuristic (subsystem inferred from \`$type\`/name; \`border\` composite colors dropped;\n// rem rounded to px). Review the seeded tokens, then hand-author the rest of your theme below.\nimport type { RawTheme } from "${e}/build";\n\nexport const raw: RawTheme = ${JSON.stringify(t,null,2)};\n`}function Ti(e,t){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${As}";\nimport { raw } from "${t}";\n\n// Generated by \`refract import\`. This is your build config — edit it freely. Add adapter options at\n// construction (\`createCssAdapter({ … })\`) and extra targets (SC/JSON/…) as their packages install.\nexport default defineConfig({\n raw,\n targets: [\n { adapter: createCssAdapter(), outDir: "dist/theme" },\n ],\n});\n`}function Fi(e){const t={};for(const[r,n]of Object.entries(e))"breakpoints"!==r&&(t[r]=n&&"object"==typeof n?Object.keys(n).length:0);return t}function Ni(r){var n,o;const s=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),i=null!==(o=r.packageName)&&void 0!==o?o:Ss(),a=t.isAbsolute(r.input)?r.input:t.resolve(s,r.input);if(!e.existsSync(a))throw new Error(`No DTCG document found at "${r.input}" (resolved to "${a}").`);let l;try{l=JSON.parse(e.readFileSync(a,"utf8"))}catch(e){throw new Error(`"${a}" is not valid JSON: ${e.message}`)}const c={};r.breakpointGroup&&(c.breakpointGroup=r.breakpointGroup),r.breakpoints&&Object.keys(r.breakpoints).length&&(c.breakpoints=r.breakpoints);const u=Vo(l,c),d=r.out?t.isAbsolute(r.out)?r.out:t.resolve(s,r.out):t.resolve(s,"theme.raw.ts");if(e.existsSync(d)&&!r.force)throw new Error(`${t.basename(d)} already exists at "${d}". Pass --force to overwrite it.`);let f;if(e.mkdirSync(t.dirname(d),{recursive:!0}),e.writeFileSync(d,Ci(i,u,JSON.stringify(t.basename(a))),"utf8"),!r.rawOnly){if(f=t.resolve(t.dirname(d),Ri),e.existsSync(f)&&!r.force)throw new Error(`${Ri} already exists at "${f}". Pass --force to overwrite it, or --raw-only to skip writing a config.`);const n=`./${t.basename(d).replace(/\.(ts|mts|cts|tsx)$/,"")}`;e.writeFileSync(f,Ti(i,n),"utf8")}return{inputFile:a,rawFile:d,configFile:f,sections:Object.keys(u),counts:Fi(u)}}async function _i(e={}){var r;const n=null!==(r=e.cwd)&&void 0!==r?r:process.cwd(),{config:o,path:s}=await js({cwd:n,configPath:e.configPath});if(!o.targets.length)throw new Error(`"${s}" has no targets to build.`);const i=function(e,t){if(void 0===t)return[...e];const r=e.filter(e=>e.name===t);if(r.length)return r;if(/^\d+$/.test(t)){const r=Number(t);if(r>=0&&r<e.length)return[e[r]]}const n=e.filter(e=>e.outDir===t);if(n.length)return n;throw new Error(`No target matched "${t}". Config has ${e.length} target(s): `+e.map((e,t)=>{var r;return null!==(r=e.name)&&void 0!==r?r:`#${t} (${e.outDir})`}).join(", ")+".")}(o.targets,e.target);if(void 0!==e.out&&i.length>1)throw new Error(`--out is ambiguous across ${i.length} targets; pass --target to pick one first.`);const a=t.dirname(s),l=[];for(const r of i){const s=void 0!==e.out?t.isAbsolute(e.out)?e.out:t.resolve(n,e.out):t.isAbsolute(r.outDir)?r.outDir:t.resolve(a,r.outDir),i=await ys({raw:o.raw,adapter:r.adapter,outDir:s,helpers:r.helpers,emit:r.emit,media:o.media,units:o.units,baseFontSize:o.baseFontSize,guide:r.guide,preview:r.preview});l.push({name:r.name,adapter:r.adapter.name,outDir:i.outDir,files:i.files})}return{configPath:s,targets:l}}async function Pi(r={}){var n;const o=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),{config:s,path:i}=await js({cwd:o,configPath:r.configPath}),a=So(s.raw,{adapter:Wo()}),l=cs(a),c=r.out?t.isAbsolute(r.out)?r.out:t.resolve(o,r.out):t.resolve(o,"tokens.json");e.mkdirSync(t.dirname(c),{recursive:!0}),e.writeFileSync(c,`${JSON.stringify(l,null,2)}\n`,"utf8");return{configPath:i,outFile:c,groupCount:Object.keys(l).filter(e=>!e.startsWith("$")).length}}async function zi(e={}){var t;const r=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:n,path:o}=await js({cwd:r,configPath:e.configPath}),s=So(n.raw,{adapter:Wo()});return{configPath:o,result:Tr(s,{strict:e.strict,minWcag:e.minWcag,largeText:e.largeText})}}const Mi=(e,t)=>{try{return String(e.resolveToken(t))}catch{return null}},qi=e=>{var t;const r=[];for(const[n,o]of Object.entries(e.model.subsystems))for(const[e,s]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(s))r.push({subsystem:n,group:e,variant:t});return r},Li=(e,t,r,n)=>{var o,s,i;return Boolean(null===(i=null===(s=null===(o=e.model.subsystems[t])||void 0===o?void 0:o.ruleSets)||void 0===s?void 0:s[r])||void 0===i?void 0:i[n])};function Ii(e,t){const r=((e,t)=>{const r=new Set([...Object.keys(e.tokens),...Object.keys(t.tokens)]),n=[];for(const o of r){const r=o in e.tokens,s=o in t.tokens,i=r?Mi(e,o):null,a=s?Mi(t,o):null;r&&!s?n.push({path:o,before:i,after:null,kind:"removed"}):!r&&s?n.push({path:o,before:null,after:a,kind:"added"}):i!==a&&n.push({path:o,before:i,after:a,kind:"changed"})}return n.sort((e,t)=>e.path.localeCompare(t.path))})(e,t),n=((e,t)=>{var r,n,o,s,i,a,l,c;const u=e,d=t;if(!u.renderRecipe&&!d.renderRecipe)return[];const f=new Set,p=[...qi(e),...qi(t)].filter(e=>{const t=`${e.subsystem}.${e.group}.${e.variant}`;return!f.has(t)&&(f.add(t),!0)}),m=[];for(const{subsystem:f,group:h,variant:g}of p){const p=Li(e,f,h,g),b=Li(t,f,h,g),v=null!==(s=null!==(n=null===(r=d.getClass)||void 0===r?void 0:r.call(d,f,h,g))&&void 0!==n?n:null===(o=u.getClass)||void 0===o?void 0:o.call(u,f,h,g))&&void 0!==s?s:`${f}.${h}.${g}`;p&&!b?m.push({name:v,kind:"removed"}):!p&&b?m.push({name:v,kind:"added"}):(null!==(a=null===(i=u.renderRecipe)||void 0===i?void 0:i.call(u,f,h,g))&&void 0!==a?a:"")!==(null!==(c=null===(l=d.renderRecipe)||void 0===l?void 0:l.call(d,f,h,g))&&void 0!==c?c:"")&&m.push({name:v,kind:"changed"})}return m.sort((e,t)=>e.name.localeCompare(t.name))})(e,t),o=((e,t)=>{var r,n,o,s;const i=e=>e?{ratio:e.wcagRatio,level:e.wcagLevel,pass:e.pass}:null,a=e=>new Map(e.map(e=>[e.label,e])),l=a(Tr(e).pairings),c=a(Tr(t).pairings),u=new Set([...l.keys(),...c.keys()]),d=[];for(const e of u){const t=l.get(e),a=c.get(e),u=i(t),f=i(a);if((null==u?void 0:u.ratio)===(null==f?void 0:f.ratio)&&(null==u?void 0:u.level)===(null==f?void 0:f.level)&&Boolean(t)===Boolean(a))continue;const p=(null!==(r=null==t?void 0:t.pass)&&void 0!==r?r:null)!==(null!==(n=null==a?void 0:a.pass)&&void 0!==n?n:null)||(null!==(o=null==t?void 0:t.wcagLevel)&&void 0!==o?o:null)!==(null!==(s=null==a?void 0:a.wcagLevel)&&void 0!==s?s:null);d.push({label:e,before:u,after:f,crossed:p})}return d.sort((e,t)=>e.label.localeCompare(t.label))})(e,t);return{tokens:r,classes:n,contrast:o,summary:{tokensChanged:r.length,classesChanged:n.length,pairingsCrossed:o.filter(e=>e.crossed).length}}}const Bi={fail:0,"AA-large":1,AA:2,AAA:3};let Ui=0;async function Di(n){var o,s,i,a;if(!e.existsSync(n))throw new Error(`candidate theme not found at "${n}".`);let l;if(".json"===t.extname(n))l=JSON.parse(e.readFileSync(n,"utf8"));else if(".ts"===t.extname(n)){const{entry:e,cleanup:t}=await b(n);try{const t=await import(r.pathToFileURL(e).href);l=null!==(s=null!==(o=t.default)&&void 0!==o?o:t.raw)&&void 0!==s?s:t}finally{t()}}else{const e=await import(`${r.pathToFileURL(n).href}?v=${++Ui}`);l=null!==(a=null!==(i=e.default)&&void 0!==i?i:e.raw)&&void 0!==a?a:e}return function(e,t){const r=t?` (${t})`:"";if(null===e||"object"!=typeof e||Array.isArray(e)){const t=Array.isArray(e)?"an array":null===e?"null":typeof e;throw new P("REFRACT_E_RAW_SHAPE",`Expected a RawTheme object${r}, got ${t}. Pass the raw theme (a module's default export, or a .json raw theme).`)}if(Array.isArray(e.targets))throw new P("REFRACT_E_RAW_SHAPE",`Expected a RawTheme object${r}, but got what looks like a defineConfig({ raw, targets }). Pass its \`raw\` (or a module that default-exports the raw theme), not the whole config.`)}(l,n),l}async function Wi(e){var r,n,o,s,i,a,l,c;const u=null!==(r=e.cwd)&&void 0!==r?r:process.cwd(),{config:d,path:f}=await js({cwd:u,configPath:e.configPath}),p=t.resolve(u,e.candidatePath),m=await Di(p),h={units:d.units,baseFontSize:d.baseFontSize,media:d.media},g=d.targets.map((e,t)=>{var r,n;return{name:null!==(n=null!==(r=e.name)&&void 0!==r?r:e.outDir)&&void 0!==n?n:`target-${t}`,adapter:e.adapter}}),b=g.map(({name:e,adapter:t})=>{var r;try{return So(m,{adapter:t,...h}),{name:e,ok:!0,errors:[]}}catch(t){const n=t;return{name:e,ok:!1,errors:n.failures?[...n.failures]:[null!==(r=n.message)&&void 0!==r?r:String(t)]}}}),v=null!==(o=null!==(n=g.find(({adapter:e})=>"function"==typeof So(d.raw,{adapter:e,...h}).renderRecipe))&&void 0!==n?n:g[0])&&void 0!==o?o:{name:"noop",adapter:Wo()},y=So(d.raw,{adapter:v.adapter,...h});let w={tokens:[],classes:[],contrast:[],summary:{tokensChanged:0,classesChanged:0,pairingsCrossed:0}};try{w=Ii(y,So(m,{adapter:v.adapter,...h}))}catch{}const $=[];if(void 0!==e.maxClassChanges&&w.summary.classesChanged>e.maxClassChanges&&$.push(`${w.summary.classesChanged} classes changed (max ${e.maxClassChanges})`),void 0!==e.maxTokenChanges&&w.summary.tokensChanged>e.maxTokenChanges&&$.push(`${w.summary.tokensChanged} tokens changed (max ${e.maxTokenChanges})`),e.failBelow){const t=null!==(s=Bi[e.failBelow])&&void 0!==s?s:0;for(const r of w.contrast){const n=(null===(i=r.after)||void 0===i?void 0:i.level)&&null!==(a=Bi[r.after.level])&&void 0!==a?a:0,o=(null===(l=r.before)||void 0===l?void 0:l.level)&&null!==(c=Bi[r.before.level])&&void 0!==c?c:0;r.after&&n<t&&n<o&&$.push(`${r.label} drops to ${r.after.level} (below ${e.failBelow})`)}}const k=b.filter(e=>!e.ok).map(e=>e.name);return k.length&&$.push(`candidate no longer builds for: ${k.join(", ")}`),{configPath:f,candidatePath:p,diff:w,targets:b,ok:0===$.length,violations:$}}const Vi=["claude","codex","opencode","github-copilot","cursor","generic"],Hi={claude:{kind:"claude",routerFile:".claude/skills"},codex:{kind:"agents-md",routerFile:"AGENTS.md"},opencode:{kind:"agents-md",routerFile:"AGENTS.md"},"github-copilot":{kind:"agents-md",routerFile:".github/copilot-instructions.md"},cursor:{kind:"agents-md",routerFile:".cursor/rules/refract-skills.mdc"},generic:{kind:"agents-md",routerFile:"AGENTS.md"}},Gi="\x3c!-- refract-skills:start --\x3e",Yi="\x3c!-- refract-skills:end --\x3e",Ji=t.join(".refract","skills.lock"),Ki=t.join(".refract","skills");function Xi(e){return null!=e?e:t.join(u(),"skills")}function Zi(r){const n=Xi(r);if(!e.existsSync(n))throw new Error(`Skills catalog not found at "${n}". Reinstall @theme-registry/refract.`);return e.readdirSync(n,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>t.join(n,e.name,"SKILL.md")).filter(e.existsSync).map(r=>function(e,r){var n,o,s;const i=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(e),a=i?i[1]:"",l=i?e.slice(i[0].length).replace(/^\s+/,""):e,c=e=>{const t=new RegExp(`^${e}:\\s*(.*)$`,"m").exec(a);return t?t[1].trim():void 0},u=null!==(o=null!==(n=c("name"))&&void 0!==n?n:t.dirname(r).split(/[\\/]/).pop())&&void 0!==o?o:"unnamed",d="optional"===c("tier")?"optional":"core";return{name:u,description:null!==(s=c("description"))&&void 0!==s?s:"",tier:d,raw:e,body:l,sourcePath:r}}(e.readFileSync(r,"utf8"),r)).sort((e,t)=>e.name.localeCompare(t.name))}function Qi(e){const t=e.map(e=>`| [${e.name}](${Ki}/${e.name}.md) | ${function(e){const t=e.description.split(/\s*Triggers:/)[0].trim();return(t.split(/\.\s/)[0].trim()||t).replace(/\|/g,"\\|")}(e)} |`).join("\n");return[Gi,"","## refract theme skills","","These skills document the [refract](https://github.com/theme-registry/refract) theme toolkit.","When a task matches a row below, read the linked file before working.","","| Skill | Use it for |","| --- | --- |",t,"",Yi].join("\n")}function ea(e,t){const r=e.indexOf(Gi),n=e.indexOf(Yi);if(-1!==r&&-1!==n&&n>r)return e.slice(0,r)+t+e.slice(n+Yi.length);const o=e.replace(/\s+$/,"");return o?`${o}\n\n${t}\n`:`${t}\n`}function ta(r,n){e.mkdirSync(t.dirname(r),{recursive:!0}),e.writeFileSync(r,n,"utf8")}function ra(r){var n,s,i;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(s=r.home)&&void 0!==s?s:o.homedir():null!==(i=r.cwd)&&void 0!==i?i:process.cwd(),c=function(e,t){if(t.skills&&t.skills.length>0){const r=new Map(e.map(e=>[e.name,e])),n=[];for(const o of t.skills){const t=r.get(o);if(!t)throw new Error(`Unknown skill "${o}". Available: ${e.map(e=>e.name).join(", ")}.`);n.push(t)}return n}return e.filter(e=>"core"===e.tier||t.includeOptional)}(Zi(r.catalogDir),r);if(0===r.agents.length)throw new Error("Pick at least one agent target.");const d=new Set;if(r.agents.some(e=>"agents-md"===Hi[e].kind))for(const e of c){const r=t.join(l,Ki,`${e.name}.md`);ta(r,e.body),d.add(r)}for(const n of r.agents){const r=Hi[n];if("claude"===r.kind)for(const e of c){const n=t.join(l,r.routerFile,e.name,"SKILL.md");ta(n,e.raw),d.add(n)}else{const n=t.join(l,r.routerFile);ta(n,ea(e.existsSync(n)?e.readFileSync(n,"utf8"):"",Qi(c))),d.add(n)}}const{name:f,version:p}=function(){var r,n;const o=JSON.parse(e.readFileSync(t.join(u(),"package.json"),"utf8"));return{name:null!==(r=o.name)&&void 0!==r?r:"@theme-registry/refract",version:null!==(n=o.version)&&void 0!==n?n:"0.0.0"}}(),m={schema:1,packageName:f,refractVersion:p,scope:a,agents:[...r.agents],skills:c.map(e=>e.name)},h=t.join(l,Ji);return ta(h,`${JSON.stringify(m,null,2)}\n`),{scope:a,agents:[...r.agents],skills:c.map(e=>e.name),files:[...d].sort(),manifestPath:h}}function na(r={}){var n,s,i;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(s=r.home)&&void 0!==s?s:o.homedir():null!==(i=r.cwd)&&void 0!==i?i:process.cwd(),c=t.join(l,Ji);if(!e.existsSync(c))throw new Error(`No skills manifest at "${c}". Run \`refract skills install\` first.`);const u=JSON.parse(e.readFileSync(c,"utf8"));return ra({agents:u.agents,scope:a,skills:u.skills,cwd:r.cwd,home:r.home,catalogDir:r.catalogDir})}const oa="refract — build a refract theme to disk.\n\nUsage:\n refract create [--seed <color>] [--colors <n|list>] [--scheme <name>] [--manual]\n [--feel <neutral|compact|editorial|technical>] [--ratio <name>]\n [--base-size <px>] [--contrast <AA|AAA|none>] [--reset <name>]\n [--format <ts|js|json>] [--out <file>] [--no-semantics]\n [--no-neutral] [--no-shadows] [--yes] [--force]\n refract init [--js | --mjs] [--force]\n refract import <tokens.json> [--out <file>] [--raw-only] [--force]\n [--breakpoint-group <name>] [--breakpoints <n:px,…>]\n refract build [--config <path>] [--target <name|index>] [--out <dir>]\n refract tokens [--config <path>] [--out <file>]\n refract diff <candidate> [--config <path>] [--max-class-changes <n>]\n [--max-token-changes <n>] [--fail-below <AA|AAA|AA-large>]\n refract audit [--config <path>] [--strict] [--min-wcag <AA|AAA|AA-large>] [--large]\n refract skills <install|list|update> [--agent <a,b|all>] [--global|--local]\n [--only <names>] [--optional]\n refract help\n\nCommands:\n create Design a theme.raw.(ts|js|json) from one seed colour and a short interview.\n init Scaffold a runnable theme.config.(ts|js|mjs) in the current directory.\n import Seed a theme.raw.ts (+ theme.config.ts) from a DTCG tokens.json (one-shot).\n build Load the config and emit every target's files to its outDir.\n tokens Export the theme's tokens as a DTCG tokens.json (adapter-free).\n diff Show a candidate theme's blast radius vs the config (tokens/classes/contrast); thresholds gate CI.\n audit Score colour pairings for WCAG-2 contrast (+ advisory APCA). Reports; --strict fails.\n skills Install the bundled AI skills into your agent CLI(s) (claude/codex/…).\n";function sa(e,t){var r;const n=t,o="string"==typeof n.code&&n.code.startsWith("REFRACT_E_")?`[${n.code}] `:"";if(process.stderr.write(`refract ${e}: ${o}${null!==(r=n.message)&&void 0!==r?r:String(t)}\n`),n.failures)for(const e of n.failures)process.stderr.write(` - ${e}\n`);return 1}async function ia(e){var t;const{values:r}=i.parseArgs({args:e,options:{seed:{type:"string"},colors:{type:"string"},scheme:{type:"string"},manual:{type:"boolean",default:!1},feel:{type:"string"},ratio:{type:"string"},"base-size":{type:"string"},contrast:{type:"string"},reset:{type:"string"},format:{type:"string"},out:{type:"string"},"no-semantics":{type:"boolean",default:!1},"no-neutral":{type:"boolean",default:!1},"no-shadows":{type:"boolean",default:!1},yes:{type:"boolean",default:!1},force:{type:"boolean",default:!1}},allowPositionals:!1}),n=new wi(!r.yes&&void 0);try{n.write(),n.write(` ${li("refract")} ${ci("· raw-theme scaffold")}`),n.write();const e=si({...await Si(n,{seed:r.seed,colors:r.colors,scheme:r.scheme,manual:r.manual,feel:r.feel,ratio:r.ratio,baseSize:r["base-size"],contrast:r.contrast,reset:r.reset,format:r.format,noSemantics:r["no-semantics"],noNeutral:r["no-neutral"],noShadows:r["no-shadows"]}),out:r.out,force:Boolean(r.force)});n.write();for(const t of Ei(e,function(e){try{const t=So(e,{adapter:Wo()});return Object.keys(t.tokens).length}catch{return 0}}(e.raw)))n.write(t);return n.write(),n.write(` ${li(null!==(t=e.path.split(/[\\/]/).pop())&&void 0!==t?t:"")} written`),n.write(),n.write(` ${ci("Next — wire up a build:")} ${li("refract init")}`),n.write(),0}catch(e){return sa("create",e)}finally{n.close()}}const aa=new Set(["AAA","AA","AA-large"]);async function la(e){const[t,...r]=e;if("list"===t)try{for(const e of Zi())process.stdout.write(` ${e.name.padEnd(26)} [${e.tier}] ${e.description.split(/\s*Triggers:/)[0].trim().slice(0,80)}\n`);return 0}catch(e){return sa("skills list",e)}const{values:n}=i.parseArgs({args:r,options:{agent:{type:"string"},global:{type:"boolean",default:!1},local:{type:"boolean",default:!1},only:{type:"string"},optional:{type:"boolean",default:!1}},allowPositionals:!1});if(n.global&&n.local)return process.stderr.write("refract skills: pass at most one of --global / --local.\n"),1;const o=n.global?"global":"local";try{if("update"===t){const e=na({scope:o});return process.stdout.write(`Updated ${e.skills.length} skill(s) for ${e.agents.join(", ")} (${e.scope}).\n`),0}if("install"===t||void 0===t){let e,t=Boolean(n.optional),r=o;if(n.agent)e=function(e){if("all"===e.trim())return[...Vi];const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=t.filter(e=>!Vi.includes(e));if(r.length>0)throw new Error(`unknown agent(s) ${r.map(e=>`"${e}"`).join(", ")}. Known: ${Vi.join(", ")}.`);return t}(n.agent);else{if(!process.stdin.isTTY)return process.stderr.write("refract skills install: pass --agent <a,b|all> (no TTY for prompts).\n"),1;{const o=await async function(){const e=s.createInterface({input:process.stdin,output:process.stdout});try{process.stdout.write("Install refract skills for which agent(s)?\n"),Vi.forEach((e,t)=>process.stdout.write(` ${t+1}) ${e}\n`));const t=await e.question("Enter numbers (comma-separated), or 'all': "),r="all"===t.trim()||""===t.trim()?[...Vi]:t.split(",").map(e=>Vi[Number(e.trim())-1]).filter(e=>Boolean(e));if(0===r.length)throw new Error("no agents selected.");return{agents:r,scope:(await e.question("Scope — [l]ocal (project) or [g]lobal (home)? [l]: ")).trim().toLowerCase().startsWith("g")?"global":"local",includeOptional:(await e.question("Include optional skills (adapter-scaffold, troubleshooting)? [y/N]: ")).trim().toLowerCase().startsWith("y")}}finally{e.close()}}();e=o.agents,t=o.includeOptional,n.global||n.local||(r=o.scope)}}const i=ra({agents:e,scope:r,skills:n.only?n.only.split(",").map(e=>e.trim()).filter(Boolean):void 0,includeOptional:t});process.stdout.write(`Installed ${i.skills.length} skill(s) for ${i.agents.join(", ")} (${i.scope}):\n`);for(const e of i.files)process.stdout.write(` ${e}\n`);return process.stdout.write(` manifest → ${i.manifestPath}\n`),0}return process.stderr.write(`refract skills: unknown subcommand "${t}". Use install | list | update.\n`),1}catch(e){return sa("skills",e)}}async function ca(e){const[t,...r]=e;switch(t){case"create":return ia(r);case"init":return async function(e){const{values:t}=i.parseArgs({args:e,options:{js:{type:"boolean",default:!1},mjs:{type:"boolean",default:!1},force:{type:"boolean",default:!1}},allowPositionals:!1});if(t.js&&t.mjs)return process.stderr.write("refract init: pass at most one of --js / --mjs.\n"),1;const r=t.mjs?"mjs":t.js?"js":"ts";try{const e=Ns({variant:r,force:Boolean(t.force)});return e.rawTheme&&process.stdout.write(`Found ${e.rawTheme.filename} — wired it up.\n`),process.stdout.write(`Created ${e.path}\n`),process.stdout.write(e.rawTheme?"Next: run `refract build`.\n":"Next: edit the starter theme in the config (or run `refract create` to design one), then `refract build`.\n"),0}catch(e){return sa("init",e)}}(r);case"import":return async function(e){const{values:t,positionals:r}=i.parseArgs({args:e,options:{out:{type:"string"},"raw-only":{type:"boolean",default:!1},force:{type:"boolean",default:!1},"breakpoint-group":{type:"string"},breakpoints:{type:"string"}},allowPositionals:!0}),n=r[0];if(!n)return process.stderr.write("refract import: pass the DTCG document to import, e.g. `refract import tokens.json`.\n"),1;if(r.length>1)return process.stderr.write(`refract import: unexpected extra argument "${r[1]}".\n`),1;try{const e=Ni({input:n,out:t.out,rawOnly:Boolean(t["raw-only"]),force:Boolean(t.force),breakpointGroup:t["breakpoint-group"],breakpoints:t.breakpoints?Oi(t.breakpoints):void 0});process.stdout.write(`Imported ${e.inputFile}\n`),process.stdout.write(` raw → ${e.rawFile}\n`),e.configFile&&process.stdout.write(` config → ${e.configFile}\n`);const r=Object.entries(e.counts).map(([e,t])=>`${e} (${t})`).join(", ");return r&&process.stdout.write(` seeded: ${r}\n`),process.stdout.write("Next: review the inferred tokens, then add recipes/components and run `refract build`.\n"),0}catch(e){return sa("import",e)}}(r);case"build":return async function(e){const{values:t}=i.parseArgs({args:e,options:{config:{type:"string"},target:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await _i({configPath:t.config,target:t.target,out:t.out});process.stdout.write(`Built from ${e.configPath}\n`);for(const t of e.targets){const e=t.name?`${t.name} [${t.adapter}]`:t.adapter;process.stdout.write(` ${e} → ${t.outDir} (${t.files.length} file(s))\n`);for(const e of t.files)process.stdout.write(` ${e}\n`)}return 0}catch(e){return sa("build",e)}}(r);case"tokens":return async function(e){const{values:t}=i.parseArgs({args:e,options:{config:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await Pi({configPath:t.config,out:t.out});return process.stdout.write(`Exported tokens from ${e.configPath}\n`),process.stdout.write(` ${e.groupCount} group(s) → ${e.outFile}\n`),0}catch(e){return sa("tokens",e)}}(r);case"diff":return async function(e){var t,r,n,o;const{values:s,positionals:a}=i.parseArgs({args:e,options:{config:{type:"string"},"max-class-changes":{type:"string"},"max-token-changes":{type:"string"},"fail-below":{type:"string"}},allowPositionals:!0}),l=a[0];if(!l)return process.stderr.write("refract diff: pass the candidate theme, e.g. `refract diff candidate.ts`.\n"),1;const c=s["fail-below"];if(void 0!==c&&!aa.has(c))return process.stderr.write(`refract diff: --fail-below must be one of AAA | AA | AA-large (got "${c}").\n`),1;try{const e=await Wi({configPath:s.config,candidatePath:l,maxClassChanges:void 0!==s["max-class-changes"]?Number(s["max-class-changes"]):void 0,maxTokenChanges:void 0!==s["max-token-changes"]?Number(s["max-token-changes"]):void 0,failBelow:c}),{diff:i}=e;process.stdout.write(`Diffed ${e.candidatePath}\n vs ${e.configPath}\n`),process.stdout.write(` ${i.summary.tokensChanged} token(s), ${i.summary.classesChanged} class(es), ${i.summary.pairingsCrossed} pairing(s) crossed a threshold\n`);for(const e of i.tokens.slice(0,20)){const t="changed"===e.kind?`${e.before} → ${e.after}`:"added"===e.kind?`+ ${e.after}`:`- ${e.before}`;process.stdout.write(` token ${e.path}: ${t}\n`)}i.tokens.length>20&&process.stdout.write(` … +${i.tokens.length-20} more token(s)\n`);for(const e of i.classes)process.stdout.write(` class ${e.kind.padEnd(7)} ${e.name}\n`);for(const e of i.contrast.filter(e=>e.crossed))process.stdout.write(` contrast ${e.label}: ${null!==(r=null===(t=e.before)||void 0===t?void 0:t.level)&&void 0!==r?r:"—"} → ${null!==(o=null===(n=e.after)||void 0===n?void 0:n.level)&&void 0!==o?o:"—"}\n`);if(e.violations.length){process.stderr.write("✗ diff gate failed:\n");for(const t of e.violations)process.stderr.write(` ${t}\n`);return 1}return 0}catch(e){return sa("diff",e)}}(r);case"audit":return async function(e){const{values:t}=i.parseArgs({args:e,options:{config:{type:"string"},strict:{type:"boolean",default:!1},"min-wcag":{type:"string"},large:{type:"boolean",default:!1}},allowPositionals:!1}),r=t["min-wcag"];if(void 0!==r&&!aa.has(r))return process.stderr.write(`refract audit: --min-wcag must be one of AAA | AA | AA-large (got "${r}").\n`),1;try{const{configPath:e,result:n}=await zi({configPath:t.config,strict:t.strict,minWcag:r,largeText:t.large});process.stdout.write(`Audited ${e}\n`);for(const e of n.pairings)if(e.skipped)process.stdout.write(` ~ ${e.label} — skipped (${e.skipped})\n`);else{const t=e.pass?"✓":"✗";process.stdout.write(` ${t} ${e.label} — ${e.wcagRatio}:1 ${e.wcagLevel} · APCA Lc ${e.apcaLc}\n`)}const o=n.summary;return process.stdout.write(`${o.passed}/${o.total} pass, ${o.failed} fail, ${o.skipped} skipped\n`),0}catch(e){return sa("audit",e)}}(r);case"skills":return la(r);case void 0:case"help":case"--help":case"-h":return process.stdout.write(oa),0;default:return process.stderr.write(`refract: unknown command "${t}".\n\n${oa}`),1}}"undefined"!=typeof require&&"undefined"!=typeof module&&require.main===module&&ca(process.argv.slice(2)).then(e=>process.exit(e),e=>{var t;process.stderr.write(`refract: ${null!==(t=e.stack)&&void 0!==t?t:e}\n`),process.exit(1)}),exports.AGENT_TARGETS=Vi,exports.CSS_ADAPTER_PACKAGE=As,exports.DEFAULT_RAW_BASENAME=Zs,exports.FEEL_PRESETS=Ds,exports.Prompter=wi,exports.SCHEME_HINTS=xi,exports.TYPE_SCALE_CHOICES=ji,exports.VENDOR_HELPERS=l,exports.applyKey=vi,exports.bold=li,exports.buildGuide=w,exports.buildPreview=_,exports.collectModes=O,exports.compileTsConfigGraph=b,exports.createReportLines=Ei,exports.cyan=ui,exports.decodeKey=gi,exports.decodeKeys=bi,exports.defaultSchemeFor=Js,exports.defineConfig=e=>e,exports.deriveLeading=Hs,exports.deriveTracking=Gs,exports.diffThemes=Ii,exports.dim=ci,exports.emitTheme=ys,exports.findConfigFile=ks,exports.findPackageRoot=u,exports.findRawTheme=Os,exports.findVendorHelper=c,exports.green=di,exports.listSkills=Zi,exports.loadConfig=js,exports.main=ca,exports.nearestLadderStep=Ys,exports.parseBreakpointsFlag=Oi,exports.promptCreateAnswers=Si,exports.rawThemeImport=Cs,exports.readOwnPackageName=Ss,exports.readVendorSource=d,exports.renderRawTheme=ni,exports.resolveEmitPlan=qo,exports.runAudit=zi,exports.runBuild=_i,exports.runCreate=si,exports.runDiff=Wi,exports.runImport=Ni,exports.runInit=Ns,exports.runSkillsInstall=ra,exports.runSkillsUpdate=na,exports.runTokens=Pi,exports.scaffoldConfig=Fs,exports.scaffoldConfigForRaw=Ts,exports.scaffoldImportConfig=Ti,exports.scaffoldRaw=Ci,exports.scaffoldTheme=Xs,exports.schemesFor=Ks,exports.skillsCatalogDir=Xi,exports.swatch=hi,exports.transpileToEsm=m,exports.yellow=fi;
|
|
2
2
|
//# sourceMappingURL=build.cjs.js.map
|