@theme-registry/refract 0.1.11 → 0.1.12
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 +10 -5
- 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 +326 -173
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
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"),i=require("node:readline/promises"),s=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),d=(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}},p=r=>{const n=t.join(d(),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")},u=["transpileModule","createProgram"];async function f(){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=u.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 f();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)$/,""),v=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:[]},i=n.createCompilerHost(o),s=n.createProgram([r],o,i),a=new Map,l=e=>!e.isDeclarationFile&&!e.fileName.includes("/node_modules/")&&/\.(ts|tsx|mts|cts)$/.test(e.fileName);for(const e of s.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 s=t.resolve(r.fileName),l=e.factory,c=e=>{const r=((e,t)=>{var r;if(!e.startsWith("."))return;const s=null===(r=n.resolveModuleName(e,t,o,i).resolvedModule)||void 0===r?void 0:r.resolvedFileName;return s?a.get(g(s)):void 0})(e,s);return r?l.createStringLiteral(`./${t.basename(r)}`):void 0},d=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,d,e)};return n.visitNode(r,d)},d=[],p=(t,r)=>{const n=a.get(g(t));n&&(e.writeFileSync(n,r,"utf8"),d.push(n))},u=()=>{for(const t of d)e.rmSync(t,{force:!0})};try{s.emit(void 0,p,void 0,!1,{before:[c]})}catch(e){throw u(),e}const m=a.get(g(r));if(!m||!e.existsSync(m))throw u(),new Error(`refract: failed to compile the \`.ts\` config graph for "${r}".`);return{entry:m,cleanup:u}},b=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:i}=e;if(i.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=i.slice(0,60);for(const t of e)o.push(`| \`${b(`${t.subsystem}.${t.group}.${t.variant}`)}\` | \`${b(t.name)}\` |`);if(i.length>e.length){const t=i.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",i=void 0===r.manifestFile?"manifest.json":r.manifestFile,s={[o]:y(e,r,i)};if(i){const n={schema:1,format:e.format,files:r.files,packageName:r.packageName,recipes:e.recipes,tokens:t};s[i]=`${JSON.stringify(n,null,2)}\n`}return{files:s}}const $=new Set([3,6]),x=(e,t,r)=>Math.min(r,Math.max(t,e)),k=e=>x(e,0,255),j=e=>Math.round(1e3*x(e,0,1))/1e3,S=e=>{const t=e.replace(/^\s*#|\s*$/g,"");if(!$.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)]},A=e=>{if(3!==e.length)throw new Error(`Expected RGB tuple of length 3, received ${e.length}`);return`#${e.map(e=>{const t=k(Math.round(e)).toString(16);return 1===t.length?`0${t}`:t}).join("")}`},E=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/i,R=e=>{const t=e.trim(),r=E.exec(t);return r?{rgb:[Number(r[1]),Number(r[2]),Number(r[3])],a:void 0===r[4]?1:j(Number(r[4]))}:{rgb:S(t),a:1}},C=(e,t=1)=>{const r=j(t),[n,o,i]=e,s=k(Math.round(n)),a=k(Math.round(o)),l=k(Math.round(i));return r>=1?`rgb(${s}, ${a}, ${l})`:`rgba(${s}, ${a}, ${l}, ${r})`},O=180/Math.PI,T=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),F=e=>e>=.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,N=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,i=.0883024619*e+.2817188376*t+.6299787005*r,s=Math.cbrt(n),a=Math.cbrt(o),l=Math.cbrt(i);return{L:.2104542553*s+.793617785*a-.0040720468*l,a:1.9779984951*s-2.428592205*a+.4505937099*l,b:.0259040371*s+.7827717662*a-.808675766*l}})(T(t/255),T(r/255),T(n/255)),i=Math.sqrt(o.a*o.a+o.b*o.b);let s=Math.atan2(o.b,o.a)*O;return s<0&&(s+=360),{L:100*o.L,C:i,h:s}},_=e=>{const t=x(e.L,0,100)/100,r=e.h/O,n=Math.cos(r),o=Math.sin(r),i=e=>((e,t,r)=>{const n=e+.3963377774*t+.2158037573*r,o=e-.1055613458*t-.0638541728*r,i=e-.0894841775*t-1.291485548*r,s=n*n*n,a=o*o*o,l=i*i*i;return[4.0767416621*s-3.3077115913*a+.2309699292*l,-1.2684380046*s+2.6097574011*a-.3413193965*l,-.0041960863*s-.7034186147*a+1.707614701*l]})(t,e*n,e*o),s=e=>e.every(e=>e>=-1e-6&&e<=1.000001);let a=i(e.C);if(!s(a)){let t=0,r=e.C;for(let e=0;e<24;e++){const e=(t+r)/2;s(i(e))?t=e:r=e}a=i(t)}return[255*F(x(a[0],0,1)),255*F(x(a[1],0,1)),255*F(x(a[2],0,1))]},z=(e,t)=>{const{rgb:r,a:n}=R(e);return C(_(t(N(r))),n)},P=(e,t)=>z(e,e=>({...e,L:x(e.L+t,0,100)})),M=(e,t)=>z(e,e=>({...e,L:x(e.L-t,0,100)})),q=(e,t)=>z(e,e=>({...e,L:x(t,0,100)})),L=(e,t)=>z(e,e=>({...e,h:((e.h+t)%360+360)%360})),I=(e,t)=>z(e,e=>({L:void 0===t.l?e.L:x(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})),B=e=>{const{rgb:t,a:r}=R(e),n=A(t);if(r>=1)return n;return`${n}${k(Math.round(255*r)).toString(16).padStart(2,"0")}`},U=(e,t)=>{const{rgb:r}=R(e);return C(r,(e=>x(e,0,100))(t)/100)},W=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),D=e=>W(String(e).replace(/[;{}<>]/g,"").trim()),V=e=>e.replace(/<\/(?=[a-zA-Z])/g,"<\\/");function H(e,t,r,n){if(!e||"object"!=typeof e||Array.isArray(e))return;const o=e,i="string"==typeof o.$type?o.$type:r;if("$value"in o)n.push({path:t,type:i,value:o.$value});else for(const[e,r]of Object.entries(o))e.startsWith("$")||H(r,[...t,e],i,n)}const G=[{id:"palette",title:"Colour",eyebrow:"Palette",note:"Every rung is a token you can reference. A ladder is an absolute lightness scale and the seed is <em>not</em> snapped onto it — the marked rung is where the family's <code>base</code> lands, not a rung it equals. Click any identifier to copy it."},{id:"type",title:"Type scale",eyebrow:"Typography"},{id:"space",title:"Spacing and size",eyebrow:"Space",note:"There is no separate <code>padding</code> token — spacing <em>is</em> the padding scale, so it is shown both as a measure and as an applied inset."},{id:"shape",title:"Borders, radius and elevation",eyebrow:"Shape & depth"},{id:"motion",title:"Transitions",eyebrow:"Motion"},{id:"layout",title:"Breakpoints",eyebrow:"Layout",note:"These drive the Width control at the top — pick one to reflow the whole specimen at that viewport."},{id:"other",title:"Other tokens",eyebrow:"Additional"}],Y={color:"palette",typography:"type",spacing:"space",gutters:"space",sizes:"space",aspectRatio:"space",radius:"shape",borderWidth:"shape",borderStyle:"shape",outlineOffset:"shape",shadow:"shape",blur:"shape",opacity:"shape",zIndex:"shape",transition:"motion",breakpoint:"layout"},J="Precision is a design decision",K=(e,t)=>`<button class="rfp-id" type="button">${W(e)}</button>`+(t?`<span class="rfp-var">${W(t)}</span>`:""),X=e=>e.path.join("."),Z=(e,t,r,n=!1)=>`<div class="rfp-row${n?" rfp-centred":""}"><div>${e}</div>${t}<div class="rfp-rowval">${W(r)}</div></div>`,Q=e=>/^\d+$/.test(e);function ee(e,t){const r=void 0===e?void 0:function(e){if(/^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(e.trim()))try{return N(S(e.trim())).L}catch{return}}(e);if(void 0===r||0===t.length)return;const n=e=>(1e3-Number(e))/10;return t.reduce((e,[t])=>Math.abs(n(t)-r)<Math.abs(n(e)-r)?t:e,t[0][0])}function te(e){const t=/^(-?[\d.]+)\s*(px|rem|em)?$/.exec(String(e).trim());if(!t)return;const r=Number(t[1]);return Number.isFinite(r)?"rem"===t[2]||"em"===t[2]?16*r:r:void 0}function re(e,t){var r,n,o;const i=new Map;for(const t of e){const e=null!==(r=t.path[1])&&void 0!==r?r:"color",n=t.path.slice(2).join(".")||"base",o=i.get(e);o?o.push([n,String(t.value)]):i.set(e,[[n,String(t.value)]])}const s=[],a=[];for(const[e,r]of i){const i=r.filter(([e])=>Q(e)),l=null===(n=r.find(([e])=>"base"===e))||void 0===n?void 0:n[1];if(i.length>=3){i.sort((e,t)=>Number(e[0])-Number(t[0]));const r=ee(l,i),n=i.map(([t,n])=>{const o=void 0!==r&&t===r;return'<div class="rfp-rung"'+(o?' data-lands="true"':"")+` title="colors.${W(e)}.${W(t)} · ${W(n)}${o?" · base lands here":""}">`+`<div class="rfp-rung-chip" data-hex="${W(n)}" style="background:${D(n)}"></div>`+`<div class="rfp-rung-foot">${W(t)}</div></div>`}).join("");s.push(`<div class="rfp-ladder"><div><div class="rfp-ladder-name">${W(e)}</div>`+(l?`<div class="rfp-ladder-base">base · ${W(l)}`+(r?`<br>lands ≈ ${W(r)}`:"")+"</div>":"")+K(`colors.${e}`,null==t?void 0:t(`colors.${e}`))+`</div><div class="rfp-rungs">${n}</div></div>`);continue}const c=null===(o=r.find(([e])=>"text"===e))||void 0===o?void 0:o[1];for(const[n,o]of r){if("text"===n)continue;const r="base"===n,i=r?c:void 0,s=r?`colors.${e}`:`colors.${e}.${n}`;a.push(`<div class="rfp-pair"><div class="rfp-pair-swatch" data-bg="${W(o)}"${i?` data-fg="${W(i)}"`:""} style="background:${D(o)}${i?`;color:${D(i)}`:""}">`+(i?'<span class="rfp-pair-sample">Aa</span><span class="rfp-pair-ratio"></span>':"")+`</div><div class="rfp-pair-foot">${K(s,null==t?void 0:t(s))}`+`<span class="rfp-hex">${W(o)}${i?` on ${W(i)}`:""}</span></div></div>`)}}let l="";return s.length&&(l+=le("Families",`${s.length} · ${e.length} tokens`,s.join(""))),a.length&&(l+=le("Swatches","contrast scored only where a <code>text</code> pairing is declared — derived tints carry none",`<div class="rfp-pairs">${a.join("")}</div>`)),l}function ne(e,t){var r;const n=new Map;for(const t of e){const e=null!==(r=t.path[1])&&void 0!==r?r:"typography",o=n.get(e);o?o.push(t):n.set(e,[t])}const o=[];for(const[e,r]of n){const n=r.map(r=>{const n=X(r),o=K(n,null==t?void 0:t(n)),i=String(r.value);return Z(o,"fontSize"===e?`<div class="rfp-specimen" style="font-size:${D(i)}">${J}</div>`:"fontFamily"===e?`<div class="rfp-specimen" style="font-family:${D(i)}">${J}</div>`:"fontWeight"===e?`<div class="rfp-specimen" style="font-weight:${D(i)}">${J}</div>`:"lineHeight"===e?`<div class="rfp-leading" style="line-height:${D(i)}">Leading is the quiet half of a type scale. Two lines are the minimum needed to judge it, so this specimen wraps.</div>`:"letterSpacing"===e?`<div class="rfp-specimen" style="font-size:22px;letter-spacing:${D(i)}">${J}</div>`:`<div class="rfp-specimen">${W(i)}</div>`,i)}).join("");o.push(le(`typography.${e}`,`${r.length} token(s)`,`<div class="rfp-rows">${n}</div>`))}return o.join("")}function oe(e,t){const r=[];for(const n of["spacing","gutters","sizes","aspectRatio"]){const o=e.get(n);if(!(null==o?void 0:o.length))continue;if("aspectRatio"===n){const e=o.map(e=>{const r=X(e),n=String(e.value);return ce(`<div class="rfp-obj" style="width:84px;aspect-ratio:${D(n)};height:auto;border-radius:4px"></div>`,K(r,null==t?void 0:t(r)),n)}).join("");r.push(le(`layout.${n}`,`${o.length} token(s)`,`<div class="rfp-tiles">${e}</div>`));continue}const i=Math.max(...o.map(e=>{var t;return null!==(t=te(e.value))&&void 0!==t?t:0}),1),s=o.map(e=>{const r=X(e),o=te(e.value),s=void 0===o?"100%":`${Math.max(1,o/i*100)}%`;return Z(K(r,null==t?void 0:t(r)),`<div class="rfp-bar${"spacing"===n?"":" rfp-ghost"}" style="width:${s}"></div>`,String(e.value),!0)}).join("");if(r.push(le(`layout.${n}`,`${o.length} steps · measure`,`<div class="rfp-rows">${s}</div>`)),"spacing"===n){const e=o.filter(e=>{var t;return(null!==(t=te(e.value))&&void 0!==t?t:0)>0}).slice(0,6);if(e.length){const o=e.map(e=>{const r=X(e);return`<div class="rfp-tile"><div class="rfp-inset" style="padding:${D(e.value)}"><div class="rfp-inset-core">${W(String(e.value))}</div></div><div>${K(r,null==t?void 0:t(r))}</div></div>`}).join("");r.push(le(`layout.${n}`,"applied as padding — hatching is the inset, solid is the content box",`<div class="rfp-tiles">${o}</div>`));const i=e.slice(0,4).map(e=>Z(K(X(e),null==t?void 0:t(X(e))),`<div class="rfp-gap" style="gap:${D(e.value)}"><i></i><i></i><i></i><i></i></div>`,String(e.value),!0)).join("");r.push(le(`layout.${n}`,"applied as gap",`<div class="rfp-rows">${i}</div>`))}}}return r.join("")}function ie(e,t){const r=[],n=(n,o,i)=>{const s=e.get(n);if(!(null==s?void 0:s.length))return;const a=s.map(e=>ce(o(e),K(X(e),null==t?void 0:t(X(e))),String(e.value))).join("");r.push(le(n,null!=i?i:`${s.length} token(s)`,`<div class="rfp-tiles">${a}</div>`))};return n("radius",e=>`<div class="rfp-obj" style="border-radius:${D(e.value)}"></div>`),n("borderWidth",e=>`<div class="rfp-obj rfp-outlined" style="border:${D(e.value)} solid currentColor;border-radius:8px"></div>`),n("borderStyle",e=>`<div class="rfp-obj rfp-outlined" style="border:3px ${D(e.value)} currentColor;border-radius:8px"></div>`),n("outlineOffset",e=>`<div class="rfp-obj rfp-outlined" style="border-radius:8px;outline:2px solid currentColor;outline-offset:${D(e.value)}"></div>`),n("shadow",e=>`<div class="rfp-obj rfp-raised" style="border-radius:8px;box-shadow:${D(e.value)}"></div>`),n("blur",e=>`<div class="rfp-obj rfp-accent" style="border-radius:8px;filter:blur(${D(e.value)})"></div>`),n("opacity",e=>`<div class="rfp-obj rfp-accent" style="border-radius:8px;opacity:${D(e.value)}"></div>`),n("zIndex",e=>`<span class="rfp-numeral">${W(String(e.value))}</span>`),r.join("")}function se(e,t){const r=e.map(e=>{const r=X(e),n=String(e.value);return Z(K(r,null==t?void 0:t(r)),`<div class="rfp-track"><i class="rfp-dot" style="transition:transform ${D(n)}"></i></div>`,n,!0)}).join("");return le("effects.transitions",`${e.length} token(s)`,`<div class="rfp-rows">${r}</div>`,'<button class="rfp-play" type="button" id="rfp-play">Play</button>')}function ae(e,t,r){const n=t.map(e=>Z(K(X(e),null==r?void 0:r(X(e))),`<div class="rfp-specimen">${W((e=>e.path.slice(1).join(".")||e.path[0])(e))}</div>`,String(e.value))).join("");return le(e,`${t.length} token(s)`,`<div class="rfp-rows">${n}</div>`)}const le=(e,t,r,n="")=>`<section class="rfp-plate"><div class="rfp-plate-head"><span class="rfp-plate-name">${W(e)}</span><span class="rfp-plate-sub">${t}</span>${n}</div>${r}</section>`,ce=(e,t,r)=>`<div class="rfp-tile"><div class="rfp-stage">${e}</div><div>${t}<span class="rfp-hex">${W(r)}</span></div></div>`;function de(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 pe=e=>{if(e&&void 0!==e.value&&null!==e.value&&"object"!=typeof e.value)return String(e.value)};function ue(e,t,r){const n=de(e);if(!n.length)return"";const{changes:o,skipped:i}=function(e){var t;const r=[];let n=0;const o=(e,t,o)=>{var i,s,a,l,c,d,p;for(const u of null!==(i=o.modes)&&void 0!==i?i:[])if(u.mode)for(const[i,f]of Object.entries(null!==(s=u.overrides)&&void 0!==s?s:{})){const s=pe(f),m=[u.target,"base"===i?void 0:i].filter(Boolean).join("."),h=`${e}.${t}${m?`.${m}`:""}`;if(void 0===s){n+=1;continue}const g="base"!==i||u.target?null!==(l=pe(null===(a=o.extras)||void 0===a?void 0:a[i]))&&void 0!==l?l:pe(null===(p=null===(c=o.variants)||void 0===c?void 0:c[null!==(d=u.target)&&void 0!==d?d:""])||void 0===p?void 0:p.base):pe(o.base);r.push({path:h,mode:u.mode,from:g,to:s})}};for(const[r,n]of Object.entries(e.subsystems))for(const[e,i]of Object.entries(null!==(t=n.properties)&&void 0!==t?t:{}))o(r,e,i);return{changes:r,skipped:n}}(e);if(!o.length&&!i)return"";const s=o.map(e=>`<tr><td>${K(e.path,null==r?void 0:r(e.path))}</td><td>${fe(e.from)}</td><td class="rfp-arrow">→</td><td>${fe(e.to)}</td></tr>`).join(""),a=i?`<p class="rfp-note-sm">${i} further override(s) resolve through a derivation, so they carry no single literal to show here.</p>`:"";return`<section class="rfp-section" id="rfp-modes"><div class="rfp-section-head"><div><div class="rfp-eyebrow">Appearance</div><h2>What changes in ${W(n.join(" / "))}</h2></div><span class="rfp-tag">${n.length} mode(s) declared</span></div><p class="rfp-note">Flipping the toggle shows you the result; this shows the cause. Only these tokens carry an override — everything else is inherited.</p>`+le(`mode: ${n.join(", ")}`,`${o.length} of ${t} tokens overridden`,`<div class="rfp-scroll"><table class="rfp-diff"><thead><tr><th>Token</th><th>Base</th><th></th><th>Override</th></tr></thead><tbody>${s}</tbody></table></div>${a}`)+"</section>"}const fe=e=>{if(void 0===e)return'<span class="rfp-hex">—</span>';return'<span class="rfp-swatch-cell">'+(/^(#|rgb|hsl|oklch|color\()/i.test(e.trim())?`<i class="rfp-chip" style="background:${D(e)}"></i>`:"")+`<span class="rfp-hex">${W(e)}</span></span>`};function me(e,t,r){var n,o,i;const s=null===(n=null==t?void 0:t.markup)||void 0===n?void 0:n.call(t,e);if(!s)return;const a=null!==(o=s.tag)&&void 0!==o?o:function(e){const t=e.group.toLowerCase();return t.includes("button")||t.includes("btn")?"button":t.includes("input")||t.includes("field")?"input":t.includes("link")||t.includes("anchor")?"a":t.includes("badge")||t.includes("chip")||t.includes("tag")||t.includes("label")?"span":"div"}(e),l={...s.attrs};r&&(l.class=`${null!==(i=l.class)&&void 0!==i?i:""} ${r}`.trim());const c=Object.entries(l).map(([e,t])=>` ${W(e)}="${W(t)}"`).join("");return"input"===a?`<input${c} value="${W(e.variant)}" readonly aria-label="${W(e.variant)}">`:`<${a}${c}>${W(e.variant)}</${a}>`}function he(e,t){if(!(null==t?void 0:t.composition))return"";for(const r of e){const e=t.composition(r);if(!e||e.length<2)continue;const n=e.map((e,t)=>(t?'<span class="rfp-plus">+</span>':"")+`<span class="rfp-cls"><b>${W(e.className)}</b>`+`<span>${e.from?` · from ${W(e.from)}`:" · own delta"}</span></span>`).join("");return le("Composition",`why <code>${W(r.variant)}</code> carries ${e.length} classes`,`<div class="rfp-compose">${n}</div><p class="rfp-note-sm">Order matters — the delta lands last, so it wins on equal specificity.</p>`)}return""}const ge='\n.rfp{--rfp-ground:#fff;--rfp-panel:#f7f8fa;--rfp-panel-2:#eef0f4;--rfp-ink:#14171c;--rfp-ink-2:#4d5563;\n --rfp-ink-3:#79818f;--rfp-rule:#e4e7ec;--rfp-rule-2:#d3d8e0;--rfp-focus:#3b4ea8;--rfp-live:#2f9e6d;\n --rfp-spec:#97a1b0;--rfp-spec-2:#c2c9d4;--rfp-hatch:#d7dce4;--rfp-stage:#f2f4f7;--rfp-raised:#fff;\n --rfp-accent:#6b7a99;\n --rfp-mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;\n --rfp-ui:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;\n font-family:var(--rfp-ui);font-size:14px;line-height:1.55;color:var(--rfp-ink);\n background:var(--rfp-ground);-webkit-font-smoothing:antialiased;\n display:grid;grid-template-columns:216px minmax(0,1fr);gap:56px;width:100%;min-height:100vh;\n padding:0 40px 96px;align-items:start;box-sizing:border-box}\n/* Full-bleed geometry. :where() gives these ZERO specificity, so a theme\'s own globals rules\n still win - the chrome resets the UA gutter and declares a scheme without ever outranking the\n theme it is displaying. The ground is painted by .rfp itself, which now fills the viewport. */\n:where(html){color-scheme:light dark}\n:where(body){margin:0}\n@media (prefers-color-scheme:dark){.rfp{--rfp-ground:#0f1114;--rfp-panel:#1a1e24;--rfp-panel-2:#232830;\n --rfp-ink:#e9ebef;--rfp-ink-2:#a8b0bd;--rfp-ink-3:#7b8492;--rfp-rule:#2b313a;--rfp-rule-2:#3b434f;\n --rfp-focus:#8ea2ff;--rfp-live:#4ec48d;--rfp-spec:#8791a0;--rfp-spec-2:#4a5361;--rfp-hatch:#333b46;\n --rfp-stage:#14181d;--rfp-raised:#232830;--rfp-accent:#8e9dbb}}\n.rfp *{box-sizing:border-box}\n.rfp *:focus-visible{outline:2px solid var(--rfp-focus);outline-offset:2px;border-radius:3px}\n.rfp-rail{position:sticky;top:0;padding:32px 0;max-height:100vh;overflow-y:auto}\n.rfp-brand{font-family:var(--rfp-mono);font-size:11px;letter-spacing:.14em;text-transform:uppercase;\n color:var(--rfp-ink-3);padding-bottom:14px;margin-bottom:14px;border-bottom:1px solid var(--rfp-rule)}\n.rfp-nav{display:flex;flex-direction:column;gap:1px}\n.rfp-nav a{display:flex;justify-content:space-between;align-items:baseline;gap:10px;padding:5px 8px;\n border-radius:4px;color:var(--rfp-ink-2);text-decoration:none;font-size:13px}\n.rfp-nav a:hover{background:var(--rfp-panel);color:var(--rfp-ink)}\n.rfp-nav a[aria-current="true"]{background:var(--rfp-ink);color:var(--rfp-ground)}\n.rfp-nav .rfp-n{font-family:var(--rfp-mono);font-size:11px;font-variant-numeric:tabular-nums;color:var(--rfp-ink-3)}\n.rfp-nav a[aria-current="true"] .rfp-n{color:var(--rfp-ground);opacity:.65}\n.rfp-main{padding-top:32px;min-width:0}\n.rfp-masthead{padding-bottom:28px;border-bottom:1px solid var(--rfp-rule)}\n.rfp-eyebrow{font-family:var(--rfp-mono);font-size:11px;letter-spacing:.14em;text-transform:uppercase;color:var(--rfp-ink-3)}\n.rfp-masthead h1{font-size:34px;line-height:1.1;letter-spacing:-.025em;font-weight:640;margin:10px 0 0;text-wrap:balance}\n.rfp-meta{display:flex;flex-wrap:wrap;gap:6px 10px;margin-top:16px;font-family:var(--rfp-mono);font-size:11.5px;color:var(--rfp-ink-2)}\n.rfp-meta span{display:inline-flex;align-items:center;gap:6px}\n.rfp-meta span+span::before{content:"";width:1px;height:11px;background:var(--rfp-rule-2)}\n.rfp-meta b{font-weight:600;color:var(--rfp-ink)}\n.rfp-dot{width:6px;height:6px;border-radius:50%;background:var(--rfp-live)}\n.rfp-controls{display:flex;flex-wrap:wrap;gap:24px;padding:18px 0;border-bottom:1px solid var(--rfp-rule);\n position:sticky;top:0;background:var(--rfp-ground);z-index:5}\n.rfp-ctl{display:flex;align-items:center;gap:8px}\n.rfp-ctl-label{font-family:var(--rfp-mono);font-size:10.5px;letter-spacing:.12em;text-transform:uppercase;color:var(--rfp-ink-3)}\n.rfp-seg{display:flex;border:1px solid var(--rfp-rule-2);border-radius:6px;overflow:hidden}\n.rfp-seg button{font:inherit;font-family:var(--rfp-mono);font-size:11.5px;padding:4px 10px;border:0;\n border-left:1px solid var(--rfp-rule-2);background:var(--rfp-ground);color:var(--rfp-ink-2);cursor:pointer}\n.rfp-seg button:first-child{border-left:0}\n.rfp-seg button:hover{background:var(--rfp-panel);color:var(--rfp-ink)}\n.rfp-seg button[aria-pressed="true"]{background:var(--rfp-ink);color:var(--rfp-ground)}\n.rfp-section{padding-top:52px;scroll-margin-top:72px}\n.rfp-section-head{display:flex;align-items:baseline;justify-content:space-between;gap:16px;flex-wrap:wrap}\n.rfp-section-head h2{font-size:21px;letter-spacing:-.018em;font-weight:620;margin:6px 0 0}\n.rfp-note{color:var(--rfp-ink-2);max-width:64ch;margin:8px 0 0;font-size:13.5px}\n.rfp-note-sm{color:var(--rfp-ink-3);font-size:12.5px;margin:10px 0 0;max-width:64ch}\n.rfp-tag{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);border:1px solid var(--rfp-rule-2);border-radius:3px;padding:1px 6px}\n.rfp-plate{margin-top:22px;border-top:1px solid var(--rfp-rule);padding-top:18px}\n.rfp-plate-head{display:flex;align-items:baseline;gap:10px;margin-bottom:14px;flex-wrap:wrap}\n.rfp-plate-name{font-family:var(--rfp-mono);font-size:12.5px;font-weight:600;color:var(--rfp-ink)}\n.rfp-plate-sub{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3)}\n.rfp-id{font-family:var(--rfp-mono);font-size:11.5px;color:var(--rfp-ink-2);background:none;border:0;\n padding:1px 4px;margin-left:-4px;border-radius:3px;cursor:copy;text-align:left;display:inline-block}\n.rfp-id:hover{background:var(--rfp-panel-2);color:var(--rfp-ink)}\n.rfp-id.rfp-copied{background:var(--rfp-ink);color:var(--rfp-ground)}\n.rfp-var{font-family:var(--rfp-mono);font-size:10.5px;color:var(--rfp-ink-3);display:block;margin-top:1px}\n.rfp-hex{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);font-variant-numeric:tabular-nums;display:block;margin-top:1px}\n.rfp-ladder{display:grid;grid-template-columns:150px minmax(0,1fr);gap:20px;align-items:start}\n.rfp-ladder+.rfp-ladder{margin-top:18px}\n.rfp-ladder-name{font-family:var(--rfp-mono);font-size:12.5px;font-weight:600}\n.rfp-ladder-base{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);margin-top:2px}\n.rfp-rungs{display:flex;border-radius:6px;overflow:hidden;border:1px solid var(--rfp-rule)}\n.rfp-rung{flex:1 1 0;min-width:0}\n.rfp-rung-chip{height:52px}\n.rfp-rung[data-lands="true"] .rfp-rung-foot{color:var(--rfp-ink);font-weight:600}\n.rfp-rung[data-lands="true"] .rfp-rung-foot::before{content:"◆ "}\n.rfp-rung-foot{padding:5px 2px 6px;text-align:center;background:var(--rfp-panel);border-top:1px solid var(--rfp-rule);\n font-family:var(--rfp-mono);font-size:10px;font-variant-numeric:tabular-nums;color:var(--rfp-ink-2)}\n.rfp-pairs{display:grid;grid-template-columns:repeat(auto-fill,minmax(184px,1fr));gap:12px}\n.rfp-pair{border:1px solid var(--rfp-rule);border-radius:6px;overflow:hidden}\n.rfp-pair-swatch{padding:16px 14px 14px;display:flex;flex-direction:column;gap:10px;min-height:92px}\n.rfp-pair-sample{font-size:14px;font-weight:600}\n.rfp-pair-ratio{align-self:flex-start;font-family:var(--rfp-mono);font-size:10.5px;font-variant-numeric:tabular-nums;\n padding:1px 6px;border-radius:3px;border:1px solid currentColor}\n.rfp-pair-foot{padding:8px 12px;background:var(--rfp-panel);border-top:1px solid var(--rfp-rule)}\n.rfp-rows{display:flex;flex-direction:column}\n.rfp-row{display:grid;grid-template-columns:190px minmax(0,1fr) 108px;gap:20px;align-items:baseline;\n padding:11px 0;border-top:1px solid var(--rfp-rule)}\n.rfp-row:first-child{border-top:0}\n.rfp-row.rfp-centred{align-items:center}\n.rfp-rowval{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);font-variant-numeric:tabular-nums;text-align:right;overflow-wrap:anywhere}\n.rfp-specimen{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.015em}\n.rfp-leading{font-size:13px;color:var(--rfp-ink-2);max-width:52ch}\n.rfp-bar{height:12px;background:var(--rfp-spec);border-radius:2px;max-width:100%}\n.rfp-bar.rfp-ghost{background:var(--rfp-spec-2)}\n.rfp-gap{display:flex;align-items:stretch;border:1px dashed var(--rfp-rule-2);border-radius:6px;padding:10px}\n.rfp-gap>i{flex:1 1 0;height:30px;background:var(--rfp-spec-2);border-radius:3px}\n.rfp-inset{border:1px solid var(--rfp-rule);border-radius:6px;\n background:repeating-linear-gradient(-45deg,var(--rfp-hatch) 0 4px,transparent 4px 8px)}\n.rfp-inset-core{background:var(--rfp-spec);color:var(--rfp-ground);border-radius:3px;font-family:var(--rfp-mono);\n font-size:10.5px;font-weight:600;text-align:center;padding:8px 4px}\n.rfp-tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:14px}\n.rfp-tile{display:flex;flex-direction:column;gap:10px}\n.rfp-stage{height:82px;display:grid;place-items:center;background:var(--rfp-stage);border-radius:6px;\n border:1px solid var(--rfp-rule);color:var(--rfp-spec)}\n.rfp-obj{width:62px;height:62px;background:var(--rfp-spec)}\n.rfp-obj.rfp-outlined{background:transparent}\n.rfp-obj.rfp-raised{background:var(--rfp-raised)}\n.rfp-obj.rfp-accent{background:var(--rfp-accent)}\n.rfp-numeral{font-family:var(--rfp-mono);font-size:20px;font-variant-numeric:tabular-nums;color:var(--rfp-ink-2)}\n.rfp-track{height:34px;border-radius:6px;background:var(--rfp-stage);border:1px solid var(--rfp-rule);position:relative;overflow:hidden}\n.rfp-dot{position:absolute;top:6px;left:6px;width:22px;height:22px;border-radius:5px;background:var(--rfp-spec)}\n.rfp-play{font:inherit;font-family:var(--rfp-mono);font-size:11.5px;padding:3px 10px;border-radius:4px;\n border:1px solid var(--rfp-rule-2);background:var(--rfp-panel);color:var(--rfp-ink);cursor:pointer;margin-left:auto}\n.rfp-scroll{overflow-x:auto}\n.rfp-diff{width:100%;border-collapse:collapse;font-size:13px}\n.rfp-diff th{text-align:left;font-family:var(--rfp-mono);font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;\n color:var(--rfp-ink-3);font-weight:500;padding:0 12px 8px 0;white-space:nowrap}\n.rfp-diff td{padding:7px 12px 7px 0;border-top:1px solid var(--rfp-rule);vertical-align:middle}\n.rfp-swatch-cell{display:flex;align-items:center;gap:8px}\n.rfp-chip{width:18px;height:18px;border-radius:4px;border:1px solid var(--rfp-rule-2);flex:none}\n.rfp-arrow{color:var(--rfp-ink-3);font-family:var(--rfp-mono)}\n.rfp-prose{border:1px solid var(--rfp-rule);border-radius:6px;padding:26px 28px;overflow:hidden}\n.rfp-matrix{border-collapse:collapse;min-width:560px;width:100%}\n.rfp-matrix th{font-family:var(--rfp-mono);font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;\n color:var(--rfp-ink-3);font-weight:500;text-align:center;padding:0 8px 10px}\n.rfp-matrix th:first-child{text-align:left}\n.rfp-matrix td{padding:12px 8px;border-top:1px solid var(--rfp-rule);text-align:center}\n.rfp-matrix td:first-child{text-align:left;width:210px}\n.rfp-none{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);opacity:.6}\n.rfp-recipes{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:14px}\n.rfp-recipe{border:1px solid var(--rfp-rule);border-radius:6px;overflow:hidden}\n.rfp-recipe-stage{min-height:96px;display:grid;place-items:center;padding:20px 16px;\n background:linear-gradient(45deg,var(--rfp-panel) 25%,transparent 25%,transparent 75%,var(--rfp-panel) 75%),\n linear-gradient(45deg,var(--rfp-panel) 25%,transparent 25%,transparent 75%,var(--rfp-panel) 75%);\n background-size:14px 14px;background-position:0 0,7px 7px}\n.rfp-recipe-foot{padding:9px 12px;border-top:1px solid var(--rfp-rule);background:var(--rfp-panel)}\n.rfp-addr{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);display:block}\n.rfp-compose{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.rfp-cls{font-family:var(--rfp-mono);font-size:11.5px;padding:3px 8px;border-radius:4px;\n border:1px solid var(--rfp-rule-2);background:var(--rfp-panel)}\n.rfp-cls b{font-weight:600;color:var(--rfp-ink)}\n.rfp-cls span{color:var(--rfp-ink-3)}\n.rfp-plus{color:var(--rfp-ink-3);font-family:var(--rfp-mono)}\n.rfp-notice{display:grid;grid-template-columns:auto minmax(0,1fr);gap:12px;align-items:start;padding:14px 16px;\n border:1px solid var(--rfp-rule-2);border-radius:6px;background:var(--rfp-panel);margin-top:18px}\n.rfp-notice-mark{font-family:var(--rfp-mono);font-size:10px;letter-spacing:.1em;text-transform:uppercase;\n padding:2px 6px;border-radius:3px;background:var(--rfp-ink);color:var(--rfp-ground);white-space:nowrap}\n.rfp-notice p{margin:0;color:var(--rfp-ink-2);font-size:13px;max-width:68ch}\n.rfp-notice p+p{margin-top:6px}\n.rfp-notice strong{color:var(--rfp-ink);font-weight:600}\n.rfp-frame{margin:0 auto}\n@media (prefers-reduced-motion:reduce){.rfp *{transition:none!important;animation:none!important}}\n@media (max-width:900px){\n .rfp{grid-template-columns:minmax(0,1fr);gap:0;padding:0 20px 72px}\n .rfp-rail{position:static;max-height:none;padding:24px 0 0}\n .rfp-nav{flex-direction:row;overflow-x:auto;gap:4px;padding-bottom:4px}\n .rfp-nav a{white-space:nowrap}\n .rfp-ladder{grid-template-columns:minmax(0,1fr);gap:10px}\n .rfp-row{grid-template-columns:130px minmax(0,1fr)}\n .rfp-rowval{grid-column:1/-1;text-align:left}\n}\n'.trim(),ve='\n(function(){\n var root=document.documentElement;\n function srgb(c){c/=255;return c<=0.03928?c/12.92:Math.pow((c+0.055)/1.055,2.4);}\n function lum(hex){var m=/^#([0-9a-f]{6})$/i.exec(hex.trim());if(!m)return null;var n=parseInt(m[1],16);\n return 0.2126*srgb((n>>16)&255)+0.7152*srgb((n>>8)&255)+0.0722*srgb(n&255);}\n // Contrast is computed here rather than baked in, so it can never drift from the swatch beside it.\n document.querySelectorAll(".rfp-pair-swatch[data-fg]").forEach(function(el){\n var out=el.querySelector(".rfp-pair-ratio");if(!out)return;\n var a=lum(el.getAttribute("data-bg")||""),b=lum(el.getAttribute("data-fg")||"");\n if(a===null||b===null){out.remove();return;}\n var r=(Math.max(a,b)+0.05)/(Math.min(a,b)+0.05);\n out.textContent=r.toFixed(2)+":1 · "+(r>=7?"AAA":r>=4.5?"AA":r>=3?"AA large":"fail");\n });\n function bind(sel,onPick){\n var btns=[].slice.call(document.querySelectorAll(sel));\n btns.forEach(function(b){b.addEventListener("click",function(){\n btns.forEach(function(o){o.setAttribute("aria-pressed",String(o===b));});\n onPick(b.getAttribute("data-value"));});});\n }\n bind("[data-rfp-mode]",function(v){\n var attr=root.getAttribute("data-rfp-mode-attr");if(!attr)return;\n if(v)root.setAttribute(attr,v);else root.removeAttribute(attr);});\n bind("[data-rfp-width]",function(v){\n var frame=document.getElementById("rfp-frame");if(frame)frame.style.maxWidth=v?v+"px":"";});\n var play=document.getElementById("rfp-play"),running=false;\n if(play)play.addEventListener("click",function(){\n running=!running;play.textContent=running?"Reset":"Play";\n document.querySelectorAll(".rfp-dot").forEach(function(d){\n d.style.transform=running?"translateX("+(d.parentElement.clientWidth-34)+"px)":"translateX(0)";});});\n document.addEventListener("click",function(e){\n var btn=e.target.closest?e.target.closest(".rfp-id"):null;if(!btn)return;\n var text=btn.textContent.trim();\n var done=function(){var prev=btn.textContent;btn.classList.add("rfp-copied");btn.textContent="copied";\n setTimeout(function(){btn.classList.remove("rfp-copied");btn.textContent=prev;},900);};\n if(navigator.clipboard){navigator.clipboard.writeText(text).then(done,done);}else{done();}});\n var links=[].slice.call(document.querySelectorAll(".rfp-nav a"));\n if(window.IntersectionObserver){\n var io=new IntersectionObserver(function(es){es.forEach(function(en){if(!en.isIntersecting)return;\n links.forEach(function(a){a.setAttribute("aria-current",String(a.getAttribute("href")==="#"+en.target.id));});});},\n {rootMargin:"-10% 0px -80% 0px"});\n document.querySelectorAll(".rfp-section").forEach(function(s){io.observe(s);});\n }\n})();\n'.trim();function be(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="./${W(e)}">`:`<style data-rfp-source="${W(e)}">\n${V(n)}\n</style>`}).join("\n")}function ye(e,t){var r,n,o,i,s,a,l,c,d,p;const{usage:u,preview:f,tokens:m,model:h}=e,g=null!==(r=t.file)&&void 0!==r?r:"preview.html",v=null===(n=t.inline)||void 0===n||n,b=new Set(t.files),y=(null!==(o=null==f?void 0:f.stylesheets)&&void 0!==o?o:[]).filter(e=>b.has(e)),w=y.length>0,$=null==f?void 0:f.tokenName,x=[];H(m,[],void 0,x);const k=function(e){var t;const r=new Map;for(const n of e){const e=null!==(t=n.path[0])&&void 0!==t?t:"tokens",o=r.get(e);o?o.push(n):r.set(e,[n])}return r}(x),j=new Map,S=new Map;for(const[e,t]of k){const r=null!==(i=Y[e])&&void 0!==i?i:"other";S.set(r,(null!==(s=S.get(r))&&void 0!==s?s:0)+t.length)}for(const e of G){const t=[...k.entries()].filter(([t])=>{var r;return(null!==(r=Y[t])&&void 0!==r?r:"other")===e.id});if(!t.length)continue;let r="";r="palette"===e.id?re(t.flatMap(([,e])=>e),$):"type"===e.id?ne(t.flatMap(([,e])=>e),$):"space"===e.id?oe(new Map(t),$):"shape"===e.id?ie(new Map(t),$):"motion"===e.id?se(t.flatMap(([,e])=>e),$):t.map(([e,t])=>ae(e,t,$)).join(""),r&&j.set(e.id,r)}const A=ue(h,x.length,$),E=function(e,t){var r,n;const o=null===(r=e.subsystems.globals)||void 0===r?void 0:r.ruleSets;if(!o||!t)return"";const i=Object.keys(null!==(n=o.elements)&&void 0!==n?n:{});if(!i.length)return"";const s=e=>i.some(t=>t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}:`)),a=[];return s("h1")&&a.push("<h1>Shipping a theme</h1>"),a.push("<p>A theme compiles once and lowers to every format you target — the same source produces CSS custom properties, Sass partials, a JSON document, or styled-components modules"+(s("a")?' <a href="#rfp-recipes">without re-authoring a single value</a>':"")+".</p>"),s("h2")&&a.push("<h2>Why bare elements matter</h2>"),a.push("<p>Content you don't control — a CMS body field, rendered markdown, a third-party embed — arrives without your class names. Theming the elements themselves is what keeps it consistent.</p>"),s("ul")&&a.push("<ul><li>Headings inherit the type scale and its derived leading</li><li>Links pick up the brand colour and its underline treatment</li><li>Variants emit only the delta from their base rule</li></ul>"),s("blockquote")&&a.push("<blockquote>Structural devices should encode something true about the content, not decorate it.</blockquote>"),s("hr")&&a.push("<hr>"),s("h3")&&a.push("<h3>Variants are structural deltas</h3>"),'<section class="rfp-section" id="rfp-globals"><div class="rfp-section-head"><div><div class="rfp-eyebrow">Base elements</div><h2>Unclassed markup</h2></div><span class="rfp-tag">globals.elements</span></div><p class="rfp-note">These style bare elements with no class involved, so plain HTML from a CMS or a markdown pipeline already looks right. Nothing else in this document renders without a class.</p>'+le("globals.elements",`${i.length} selector(s) · ${W(i.join(", "))}`,`<div class="rfp-prose">${a.join("")}</div>`)+"</section>"}(h,w),R=[];w||R.push(null!==(a=null==f?void 0:f.unavailable)&&void 0!==a?a:`This theme was built with the ${u.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==f?void 0:f.notes)&&void 0!==l?l:[])R.push(e);const C=[];for(const e of G)j.has(e.id)&&C.push(`<a href="#rfp-${e.id}">${e.eyebrow}<span class="rfp-n">${null!==(c=S.get(e.id))&&void 0!==c?c:0}</span></a>`);A&&C.push('<a href="#rfp-modes">Appearance</a>'),E&&C.push('<a href="#rfp-globals">Base elements</a>'),C.push(`<a href="#rfp-recipes">Components<span class="rfp-n">${u.recipes.length}</span></a>`);const O=null!==(d=t.title)&&void 0!==d?d:`${u.format} theme`,T=t.files.reduce((e,r)=>{var n,o,i;return e+(null!==(i=null===(o=null===(n=t.contents)||void 0===n?void 0:n[r])||void 0===o?void 0:o.length)&&void 0!==i?i:0)},0),F=[`<span><i class="rfp-dot"></i> ${W(u.format)} · ${w?"live":"tokens only"}</span>`,`<span>emit <b>${W(t.plan.type)}</b></span>`,`<span>${x.length} tokens</span>`,`<span>${u.recipes.length} recipes</span>`,T?`<span>${t.files.length} file(s) · ${N=T,N<1024?`${N} B`:`${(N/1024).toFixed(1)} KB`}</span>`:""].filter(Boolean);var N;const _=null==f?void 0:f.modeAttribute,z=de(h),P=null!==(p=h.breakpoints)&&void 0!==p?p:{},M=[];if(_&&z.length){const e=['<button type="button" data-rfp-mode data-value="" aria-pressed="true">auto</button>'].concat(z.map(e=>`<button type="button" data-rfp-mode data-value="${W(e)}" aria-pressed="false">${W(e)}</button>`)).join("");M.push(`<div class="rfp-ctl"><span class="rfp-ctl-label">Appearance</span><div class="rfp-seg" role="group" aria-label="Appearance mode">${e}</div></div>`)}const q=Object.entries(P);if(q.length){const e=['<button type="button" data-rfp-width data-value="" aria-pressed="true">full</button>'].concat(q.map(([e,t])=>`<button type="button" data-rfp-width data-value="${W(String(t))}" aria-pressed="false">${W(e)}</button>`)).join("");M.push(`<div class="rfp-ctl"><span class="rfp-ctl-label">Width</span><div class="rfp-seg" role="group" aria-label="Viewport width">${e}</div></div>`)}const L=G.filter(e=>j.has(e.id)).map(e=>`<section class="rfp-section" id="rfp-${e.id}"><div class="rfp-section-head"><div><div class="rfp-eyebrow">${e.eyebrow}</div><h2>${e.title}</h2></div></div>`+(e.note?`<p class="rfp-note">${e.note}</p>`:"")+j.get(e.id)+"</section>").join(""),I=['<meta charset="utf-8">','<meta name="viewport" content="width=device-width,initial-scale=1">',`<title>${W(O)}</title>`,be(y,t.contents,v),(null==f?void 0:f.statePinCss)&&w?`<style data-rfp-state-pins>\n${V(f.statePinCss)}\n</style>`:"",`<style>\n${ge}\n</style>`].filter(Boolean).join("\n"),B=`<div class="rfp"><aside class="rfp-rail"><div class="rfp-brand">refract preview</div><nav class="rfp-nav">${C.join("")}</nav></aside><main class="rfp-main"><header class="rfp-masthead"><div class="rfp-eyebrow">Theme specimen</div><h1>${W(O)}</h1><div class="rfp-meta">${F.join("")}</div></header>`+(M.length?`<div class="rfp-controls">${M.join("")}</div>`:"")+R.map(e=>`<p class="rfp-note">${W(e)}</p>`).join("")+'<div class="rfp-frame" id="rfp-frame">'+L+A+E+'<section class="rfp-section" id="rfp-recipes"><div class="rfp-section-head"><div>'+`<div class="rfp-eyebrow">Components</div><h2>Recipes${w?" and their states":""}</h2></div>`+`<span class="rfp-tag">${w?"rendered live":"names only"}</span></div>`+function(e,t,r){var n,o;if(0===e.recipes.length)return'<div class="rfp-notice"><span class="rfp-notice-mark">Empty</span><div><p><strong>No recipes yet — this theme is tokens only.</strong> Tokens are values; recipes are the rule-sets that turn them into styled components. Add a <code>recipes</code> block to a subsystem in your raw theme and rebuild — they\'ll render here.</p></div></div>';const i=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:`${r.subsystem}.${r.group}`,s=i.get(e);s?s.push(r):i.set(e,[r])}const s=[];for(const[e,n]of i){const o=r?[...new Set(n.flatMap(e=>{var r,n;return null!==(n=null===(r=null==t?void 0:t.states)||void 0===r?void 0:r.call(t,e))&&void 0!==n?n:[]}))].filter(e=>{var r;return null===(r=null==t?void 0:t.statePinClass)||void 0===r?void 0:r.call(t,e)}):[];if(o.length&&(null==t?void 0:t.markup)){const r=["base",...o].map(e=>`<th>${W(e)}</th>`).join(""),i=n.map(e=>{var r,n;const i=null!==(n=null===(r=t.states)||void 0===r?void 0:r.call(t,e))&&void 0!==n?n:[],s=["base",...o].map(r=>{var n,o;if("base"!==r&&!i.includes(r))return'<td class="rfp-none">—</td>';const s="base"===r||null===(n=t.statePinClass)||void 0===n?void 0:n.call(t,r);return`<td>${null!==(o=me(e,t,s))&&void 0!==o?o:""}</td>`}).join("");return`<tr><td><span class="rfp-addr">${W(`${e.subsystem}.${e.group}.${e.variant}`)}</span><button class="rfp-id" type="button">${W(e.name)}</button></td>${s}</tr>`}).join("");s.push(le(e,`${n.length} variant(s) × ${o.length} state(s)`,`<div class="rfp-scroll"><table class="rfp-matrix"><thead><tr><th>Variant</th>${r}</tr></thead><tbody>${i}</tbody></table></div>`)),s.push(he(n,t));continue}const i=n.map(e=>{const n=r?me(e,t):void 0;return'<div class="rfp-recipe">'+(n?`<div class="rfp-recipe-stage">${n}</div>`:"")+'<div class="rfp-recipe-foot"><span class="rfp-addr">'+W(`${e.subsystem}.${e.group}.${e.variant}`)+`</span><button class="rfp-id" type="button">${W(e.name)}</button></div></div>`}).join("");s.push(le(e,`${n.length} variant(s)`,`<div class="rfp-recipes">${i}</div>`)),s.push(he(n,t))}return s.join("")}(u,f,w)+"</section></div></main></div>"+`<script>\n${ve}\n<\/script>`,U=`<!doctype html>\n<html lang="en"${_?` data-rfp-mode-attr="${W(_)}"`:""}>\n<head>\n${I}\n</head>\n<body>\n${B}\n</body>\n</html>\n`;return{files:{[g]:U}}}class we extends Error{constructor(e,t,r){super(t),this.name="RefractError",this.code=e,r&&(this.failures=r),Object.setPrototypeOf(this,we.prototype)}}const $e=e=>"string"==typeof e||"number"==typeof e,xe=e=>Array.isArray(e),ke=e=>({value:e}),je=(e,t)=>{if(!t)return ke(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},Se=new Set(["mode","target","base","derive"]),Ae=(e,t,r)=>{const n={},o=e.derive,i=e.base;if(o){if(void 0===o.ref)throw new we("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=je($e(i)?i:void 0,o)}else $e(i)?n.base=ke(i):xe(i)&&(n.base={struct:i});for(const[t,r]of Object.entries(e))Se.has(t)||$e(r)&&(n[t]=ke(r));return n},Ee=(e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||$e(o)&&(r[n]=ke(o));return r},Re=new Set(["base","derive"]),Ce=new Set(["base","responsive","variants","modes","external"]),Oe=new Set(["breakpoint","query","state","orientation","ref","modifiers","mode","variant","target","derive","ratio","step","steps"]),Te=(e,t="property")=>{var r;const n={base:void 0!==e.external?{value:`var(${e.external})`,external:e.external}:(o=e.base,xe(o)?{struct:o}:ke(o))};var o;const i=Ee(e,Ce);if(Object.keys(i).length&&(n.extras=i),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($e(n.base)?e=je(n.base,o):xe(n.base)?e={struct:n.base}:void 0!==(null==o?void 0:o.ref)&&(e=je(void 0,o)),!e)continue;const i=Ee(n,Re);t[r]=Object.keys(i).length?{base:e,extras:i}:{base:e}}Object.keys(t).length&&(n.variants=t)}const s=e.modes;if(s&&s.length){const e=[];for(const r of s){const n=r.mode,o=Ae(r,t,n);if(!Object.keys(o).length)continue;const i={mode:n,overrides:o};"string"==typeof r.target&&(i.target=r.target),e.push(i)}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)||($e(o)?r[n]=ke(o):xe(o)&&(r[n]={struct:o}));return r})(t,Oe),o=t.derive;return o&&n.base&&void 0!==n.base.value&&(n.base=je(n.base.value,o)),Object.keys(n).length&&(r.overrides=n),r});n.responsive=t}return n},Fe=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})}),Ne=(e,t)=>{const r=Fe(e);return r.kind="recipe",t.length&&(r.references=t),r},_e=new Set(["colors","typography","layout","effects","borders"]),ze=e=>!!e&&Object.keys(e).length>0,Pe=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]=Te(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}),ze(e.ruleSetGroups)&&(r.ruleSets=e.ruleSetGroups),ze(e.keyframes)&&(r.keyframes=e.keyframes),Object.keys(r).length?r:void 0},Me=e=>{var t,r,n,o;const i={};for(const[s,a]of Object.entries(e.subsystems))for(const[e,l]of Object.entries(null!==(t=a.properties)&&void 0!==t?t:{})){const t=`${s}.${e}`;i[t]=l.base;for(const[e,o]of Object.entries(null!==(r=l.variants)&&void 0!==r?r:{})){i[`${t}.${e}`]=o.base;for(const[r,s]of Object.entries(null!==(n=o.extras)&&void 0!==n?n:{}))i[`${t}.${e}.${r}`]=s}for(const[e,r]of Object.entries(null!==(o=l.extras)&&void 0!==o?o:{}))i[`${t}.${e}`]=r}return i},qe=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"]),Le=/^-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?$/i,Ie=/^(-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?)([a-z%]+)$/i,Be=e=>{if("number"==typeof e)return{value:e};const t=e.trim();if(Le.test(t))return{value:Number(t)};const r=Ie.exec(t);if(r){const t=r[2].toLowerCase();if(qe.has(t))return{value:Number(r[1]),unit:t};throw new we("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}},Ue={"typography.lineHeight":"none","typography.letterSpacing":"em"},We=(e,t)=>{var r,n,o,i;const s=e.slice(0,e.indexOf("."));return null!==(i=null!==(o=null!==(n=null!==(r=null==t?void 0:t[e])&&void 0!==r?r:Ue[e])&&void 0!==n?n:null==t?void 0:t[s])&&void 0!==o?o:null==t?void 0:t.default)&&void 0!==i?i:"px"},De=(e,t)=>Number((e/t).toFixed(4)),Ve=(e,t,r)=>"none"===t?{value:e}:"rem"===t?{value:De(e,r),unit:"rem"}:{value:e,unit:t},He=(e,t,r)=>{if("number"==typeof e){const{value:n,unit:o}=Ve(e,t,r);return void 0===o?e:{value:n,unit:o}}return e},Ge={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"}},Ye=(e,t)=>{let r=!1;const n={};for(const[o,i]of Object.entries(e)){const e=t(i);e!==i&&(r=!0),n[o]=e}return r?n:e},Je=(e,t,r)=>{const n=t(e.base),o=e.variants?((e,t)=>{let r=!1;const n={};for(const[o,i]of Object.entries(e)){const e=t(i.base),s=i.extras?Ye(i.extras,t):void 0;e===i.base&&s===i.extras||(r=!0),n[o]=s?{base:e,extras:s}:{base:e}}return r?n:e})(e.variants,t):void 0,i=r&&e.extras?Ye(e.extras,t):e.extras,s=e.modes?((e,t)=>{let r=!1;const n=e.map(e=>{if(!e.overrides)return e;const n=Ye(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=Ye(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&&i===e.extras&&s===e.modes&&a===e.responsive)return e;const l={...e,base:n};return void 0!==o&&(l.variants=o),void 0!==i&&(l.extras=i),void 0!==s&&(l.modes=s),void 0!==a&&(l.responsive=a),l},Ke=(e,t,r,n)=>{const o="shadow"===t?e=>{if(!e.struct)return e;const t=e.struct;let o=!1;const i=t.map(e=>{const t=((e,t,r)=>{const n={...e};let o=!1;for(const i of["offsetX","offsetY","blur","spread"]){const s=e[i];if(void 0===s)continue;const a=He(s,t,r);a!==s&&(n[i]=a,o=!0)}return o?n:e})(e,r,n);return t!==e&&(o=!0),t});return o?{...e,struct:i}: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:i}=Ve(n,t,r);return void 0===i?e:{...e,value:o,unit:i}}if("string"==typeof n){const o=Be(n);if("raw"in o)return e;if(void 0!==o.unit)return{...e,value:o.value,unit:o.unit};const{value:i,unit:s}=Ve(o.value,t,r);return void 0===s?{...e,value:i}:{...e,value:i,unit:s}}return e})(e,r,n);return Je(e,o,!1)},Xe=(e,t={})=>{var r;const n=null!==(r=t.baseFontSize)&&void 0!==r?r:16;let o=!1;const i={};for(const[r,s]of Object.entries(e.subsystems)){const e=Ge[r];if(!e||!s.properties){i[r]=s;continue}let a=!1;const l={};for(const[o,i]of Object.entries(s.properties)){const s=e[o];if(!s){l[o]=i;continue}const c=We(`${r}.${o}`,t.units),d=Ke(i,s,c,n);d!==i&&(a=!0),l[o]=d}a?(i[r]={...s,properties:l},o=!0):i[r]=s}return o?{...e,subsystems:i}:e},Ze=e=>(null==e?void 0:e.propertyPath)?` for "${e.propertyPath}"`:"",Qe=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e));function et(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 we("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown variant "${t.ref}" (ref).`);if(t.target&&!n.has(t.target))throw new we("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown target "${t.target}".`)}}const tt=e=>"object"==typeof e&&null!==e&&Array.isArray(e.modifiers),rt=(e,t)=>{if(!Array.isArray(e)||0===e.length)throw new we("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 we("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 we("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must have exactly one fn key; got [${n.join(", ")}].`);return{fn:n[0],arg:e[n[0]]}})},nt=new Set(["breakpoint","query","ref","modifiers","mode","target","orientation"]),ot=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),it=(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 we("REFRACT_E_PROPERTY",`Unable to resolve base value${i=r.propertyPath,i?` for "${i}"`:""}.`);var i;return r.coerceValue?r.coerceValue(o):o},st=(e,t)=>{const r=new Set(t),n={},o={};let i=!1;for(const[t,s]of Object.entries(e))r.has(t)?(n[t]=s,i=!0):o[t]=s;return{base:i?n:void 0,extra:o}},at=(e,t,r,n)=>{var o;if(void 0===e&&(null===(o=n.leafFields)||void 0===o?void 0:o.length)){const e=st(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:it(e,r,n),extra:t}},lt=(e,t,r,n)=>{const o=r.propertyPath?`${r.propertyPath}.variants.${e}`:`variants.${e}`,i=ot(t)?t:{base:t},{base:s,...a}=i,{base:l,extra:c}=at(s,a,n,{...r,propertyPath:o});return{...c,base:l}},ct=(e,t={})=>{var r;const n=ot(e)?e:{base:e},{base:o,responsive:i,variants:s,modes:a,...l}=n,{base:c,extra:d}=at(o,l,t.fallbackBase,t),p=s?Object.fromEntries(Object.entries(s).map(([e,r])=>[e,lt(e,r,t,c)])):void 0,u=a?a.map(e=>((e,t)=>{const{mode:r,target:n,...o}=e,i=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)&&!tt(o)){const{base:e,extra:r}=st(o,t.leafFields);if(void 0!==e){const n={...r};return n.base=t.coerceValue?t.coerceValue(e):e,n}}if(tt(o)){const{ref:e,modifiers:t,...r}=o,n={...r};return n.derive={...void 0!==e?{ref:e}:{},modifiers:rt(t,i)},n}const{base:r,...n}=o,s={...n};if(void 0!==r&&(s.base=Array.isArray(r)||!t.coerceValue?r:t.coerceValue(r)),void 0===s.base&&!s.derive&&!Object.keys(n).length)throw new we("REFRACT_E_MODE",`Appearance mode "${i}" overrides nothing.`);return s})()}})(e,t)):void 0,f={propertyPath:t.propertyPath,allowedBreakpoints:t.allowedBreakpoints},m=(g=f,(null==(h=i)?void 0:h.length)?h.map(e=>{if(!e.breakpoint)throw new we("REFRACT_E_BREAKPOINT",`Responsive entry${Ze(g)} is missing a "breakpoint" value.`);if((null==g?void 0:g.allowedBreakpoints)&&!Qe(e.breakpoint,g.allowedBreakpoints))throw new we("REFRACT_E_BREAKPOINT",`Responsive entry${Ze(g)} references unknown breakpoint "${e.breakpoint}".`);if(e.ref&&!Qe(e.ref,null==g?void 0:g.allowedVariants))throw new we("REFRACT_E_RESPONSIVE",`Responsive entry${Ze(g)} references unknown variant "${e.ref}" (ref).`);if(e.target&&!Qe(e.target,null==g?void 0:g.allowedTargets))throw new we("REFRACT_E_RESPONSIVE",`Responsive entry${Ze(g)} references unknown target "${e.target}".`);const{query:t,...r}=e;return{...r,query:null!=t?t:"exact"}}):[]);var h,g;const v=(null===(r=t.leafFields)||void 0===r?void 0:r.length)?m.map(e=>((e,t)=>{const r={},n={};let o;for(const[t,i]of Object.entries(e))nt.has(t)?r[t]=i:"base"===t?o=i:n[t]=i;const i=t.leafFields.some(e=>e in n);if(void 0===o&&!i)return e;const{base:s,extra:a}=at(o,n,void 0,t);return{...r,...a,base:s}})(e,t)):m;return{...d,base:c,responsive:v,variants:p,modes:u}},dt=["orientation","height","aspectRatio"],pt=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e)),ut=e=>e?` for "${e}"`:"",ft="responsive",mt="states",ht="css",gt="variants",vt=e=>Array.isArray(e)?e:e&&"object"==typeof e?Object.entries(e).map(([e,t])=>({state:e,...t})):[],bt=e=>{var t;return`${e.state}\0${null!==(t=e.target)&&void 0!==t?t:""}`},yt=(e,t)=>{const r=vt(e).map(e=>({...e})),n=new Map(r.map((e,t)=>[bt(e),t]));for(const e of vt(t)){const t=bt(e),o=n.get(t);void 0!==o?r[o]={...r[o],...e}:(n.set(t,r.length),r.push({...e}))}return r},wt=(e,t)=>{var r,n;const o={...e};for(const[i,s]of Object.entries(t))null!==s?i===ft?o[ft]=[...null!==(r=e[ft])&&void 0!==r?r:[],...s]:i===mt?o[mt]=yt(e[mt],s):i===ht?o[ht]={...null!==(n=e[ht])&&void 0!==n?n:{},...s}:o[i]=s:delete o[i];return o},$t=(e,t={})=>{const r=((e,t)=>{if(!Object.values(e).some(e=>null!=e&&"object"==typeof e&&null!=e[gt]))return e;const r={},n=(e,n)=>{if(e in r)throw new we("REFRACT_E_VARIANT",`Recipe variant expansion${ut(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{[gt]:e,...o}=r;if(n(t,o),null!=e){const r=null!=o[mt]?{...o,[mt]:vt(o[mt]).filter(e=>!e.target)}:o;for(const[o,i]of Object.entries(e))n(`${t}-${o}`,wt(r,i))}}return r})(e,t.propertyPath),n=Object.keys(r),o=n.length?new Set(n):void 0,i={};return n.forEach(e=>{var n;const s=r[e];i[e]=xt(`${null!==(n=t.propertyPath)&&void 0!==n?n:"recipes"}.${e}`,s,{allowedBreakpoints:t.allowedBreakpoints,allowedStates:t.allowedStates,allowedTargets:o,allowedVariants:o,allowedContainers:t.allowedContainers,recipeName:e})}),i},xt=(e,t,r)=>{const{responsive:n,states:o,...i}=t;return{base:i,responsive:[...kt(o,e,r),...jt(n,e,r)]}},kt=(e,t,r)=>vt(e).map(e=>{const{state:n,...o}=e;if(r.allowedStates&&!pt(n,r.allowedStates))throw new we("REFRACT_E_STATE",`Recipe state entry${ut(t)} references unknown state "${n}".`);if(o.target&&r.allowedTargets){const e=r.recipeName?`${r.recipeName}-${o.target}`:o.target;if(!pt(e,r.allowedTargets))throw new we("REFRACT_E_RESPONSIVE",`Recipe state entry${ut(t)} references unknown target "${o.target}".`)}return{...o,state:n}}),jt=(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 we("REFRACT_E_RESPONSIVE",`Responsive entry${ut(t)} cannot set both "variant" and "target".`);if(void 0!==e.container)return St(e,t,r);if(!e.breakpoint)throw new we("REFRACT_E_BREAKPOINT",`Responsive recipe entry${ut(t)} is missing a "breakpoint" value.`);if(r.allowedBreakpoints&&!pt(e.breakpoint,r.allowedBreakpoints))throw new we("REFRACT_E_BREAKPOINT",`Responsive recipe entry${ut(t)} references unknown breakpoint "${e.breakpoint}".`);if(e.state&&r.allowedStates&&!pt(e.state,r.allowedStates))throw new we("REFRACT_E_STATE",`Responsive recipe entry${ut(t)} references unknown state "${e.state}".`);if(e.variant&&!pt(e.variant,r.allowedVariants))throw new we("REFRACT_E_RESPONSIVE",`Responsive recipe entry${ut(t)} references unknown variant "${e.variant}".`);if(e.target&&!pt(e.target,r.allowedTargets))throw new we("REFRACT_E_RESPONSIVE",`Responsive recipe entry${ut(t)} references unknown target "${e.target}".`);return{...e,query:null!==(n=e.query)&&void 0!==n?n:"exact"}}):[],St=(e,t,r)=>{var n,o;const i=e.container;for(const r of dt)if(void 0!==e[r])throw new we("REFRACT_E_CONTAINER",`Container recipe entry${ut(t)} cannot use "${r}" — container queries respond to a container's inline size, not orientation/height/aspect-ratio.`);const s=null===(n=r.allowedContainers)||void 0===n?void 0:n.get(i);if(r.allowedContainers&&!s)throw new we("REFRACT_E_CONTAINER",`Container recipe entry${ut(t)} references unknown container "${i}".`);if(void 0===e.size)throw new we("REFRACT_E_CONTAINER",`Container recipe entry${ut(t)} for container "${i}" is missing a "size" value.`);if(s&&!s.has(e.size))throw new we("REFRACT_E_CONTAINER",`Container recipe entry${ut(t)} references unknown size "${e.size}" on container "${i}".`);return{...e,query:null!==(o=e.query)&&void 0!==o?o:"min"}},At=(e,t,r={})=>{var n;const o=new Map,i=[],s=null!==(n=r.groupPath)&&void 0!==n?n:"recipes",a=r=>{if(o.has(r))return o.get(r);if(i.includes(r)){const e=[...i,r].join(" -> ");throw new we("REFRACT_E_CYCLE",`Cyclic recipe reference in "${s}": ${e}`)}const n=e[r];if(!n)throw new we("REFRACT_E_REFERENCE",`Recipe variant "${r}" is not defined in "${s}".`);i.push(r);try{const e=t(r,n,a);return o.set(r,e),e}finally{i.pop()}};return{resolve:a,resolveAll:()=>{const t={};for(const r of Object.keys(e))t[r]=a(r);return t}}},Et=(e,t,r,n=new Map,o=new Set)=>{const i=n.get(r);if(void 0!==i)return i;const s=e[r];if(!s)throw new we("REFRACT_E_TOKEN_PATH",`Unknown token path "${r}".`);if(void 0!==s.external){const e=`var(${s.external})`;return n.set(r,e),e}if(void 0===s.ref){if(void 0===s.value)throw new we("REFRACT_E_TOKEN_PATH",`Token "${r}" has neither "ref" nor "value".`);return n.set(r,s.value),s.value}if(o.has(r))throw new we("REFRACT_E_CYCLE",`Cyclic token reference: ${[...o,r].join(" -> ")}`);o.add(r);const a=Et(e,t,s.ref,n,o);let l;if(void 0!==s.modifiers)l=s.modifiers.reduce((e,n)=>{const o=t[n.fn];if(!o)throw new we("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${n.fn}" for token "${r}".`);return o(e,n.arg)},a);else if(void 0!==s.fn){const e=t[s.fn];if(!e)throw new we("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${s.fn}" for token "${r}".`);l=e(a,s.arg)}else l=a;return o.delete(r),n.set(r,l),l},Rt=(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),Ct=(e,t,r,n,o)=>{let i;try{i=Et(t,r,e.ref,n)}catch{throw new we("REFRACT_E_VALIDATION",`${o}: cross-property derivation references unknown token '${e.ref}'.`)}const s=(e,t)=>{const n=r[e];if(!n)throw new we("REFRACT_E_VALIDATION",`${o}: unknown derivation fn '${e}'.`);return n(i,t)};if(void 0!==e.modifiers)for(const t of e.modifiers)i=s(t.fn,t.arg);else void 0!==e.fn&&(i=s(e.fn,e.arg));return{...e,value:i}},Ot=(e,t,r,n,o,i)=>{let s;for(const[a,l]of Object.entries(e))Rt(l,t)&&(s=null!=s?s:{...e},s[a]=Ct(l,r,n,o,`${i}.${a}`));return s},Tt=(e,t,r,n,o)=>{const i=e.variants?((e,t,r,n,o)=>{let i;for(const[s,a]of Object.entries(e)){const l=`${t}.variants.${s}`,c=Rt(a.base,t)?Ct(a.base,r,n,o,l):a.base,d=a.extras?Ot(a.extras,t,r,n,o,`${l} extra`):void 0;(c!==a.base||d)&&(i=null!=i?i:{...e},i[s]=d?{base:c,extras:d}:{...a,base:c})}return i})(e.variants,t,r,n,o):void 0;let s;if(e.modes)for(let i=0;i<e.modes.length;i++){const a=e.modes[i];if(!a.overrides)continue;const l=Ot(a.overrides,t,r,n,o,`${t}.modes.${a.mode}`);l&&(s=null!=s?s:[...e.modes],s[i]={...a,overrides:l})}if(!i&&!s)return;const a={...e};return i&&(a.variants=i),s&&(a.modes=s),a},Ft=(e,t)=>{var r;const n=Me(e),o=new Map;let i=!1;const s={};for(const[a,l]of Object.entries(e.subsystems)){let e,c=!1;for(const[i,s]of Object.entries(null!==(r=l.properties)&&void 0!==r?r:{})){const r=Tt(s,`${a}.${i}`,n,t,o);r&&(e=null!=e?e:{...l.properties},e[i]=r,c=!0)}c?(s[a]={...l,properties:e},i=!0):s[a]=l}return i?{...e,subsystems:s}:e},Nt=["min","max","exact","between"],_t=e=>void 0===e?void 0:e-.02,zt=(e,t)=>{const r=(e=>Object.keys(e).sort((t,r)=>e[t]-e[r]))(e);(e=>{const t=e.filter(e=>Nt.includes(e));if(t.length)throw new we("REFRACT_E_BREAKPOINT",`Breakpoint names conflict with reserved keys: ${t.map(e=>`"${e}"`).join(", ")}. Reserved: ${Nt.map(e=>`"${e}"`).join(", ")}.`)})(r);const n=e=>r[r.indexOf(e)+1],o=r.reduce((r,o)=>{const i=e[o],s=n(o),a=void 0!==s?e[s]:void 0;return r[o]=Pt({own:i,next:a},t),r},{}),i=e=>{const t=o[e];if(!t)throw new we("REFRACT_E_BREAKPOINT",`Breakpoint "${e}" is not defined.`);return t};return{...o,min:(r,n)=>{const o=i(r);return n?t({min:e[r],...n}):o.min},max:(r,o)=>{const s=i(r);if(!o)return s.max;const a=n(r),l=void 0!==a?e[a]:void 0;return t({max:_t(l),...o})},exact:(r,o)=>{const s=i(r);if(!o)return s.exact;const a=n(r),l=void 0!==a?e[a]:void 0;return t({min:e[r],max:_t(l),...o})},between:(r,n,o)=>{const i=e[r],s=e[n];if(void 0===i||void 0===s)throw new we("REFRACT_E_BREAKPOINT",`Cannot build media query between "${r}" and "${n}" breakpoints.`);return t({min:i,max:s-.02,...o})}}},Pt=({own:e,next:t},r)=>{const n=_t(t);return{min:r({min:e}),max:void 0===n?"":r({max:n}),exact:r({min:e,max:n})}},Mt="px",qt=16,Lt=e=>{var t;return{unit:null!==(t=null==e?void 0:e.unit)&&void 0!==t?t:Mt,baseFontSize:(null==e?void 0:e.baseFontSize)&&e.baseFontSize>0?e.baseFontSize:qt}},It=(e,t)=>{if("px"===t.unit)return`${e}px`;const r=e/t.baseFontSize;return`${Number(r.toFixed(4))}${t.unit}`},Bt=({min:e,max:t,orientation:r},n)=>{const o=[];if(void 0!==e&&void 0!==t&&e>t)throw new we("REFRACT_E_MEDIA","Invalid media query: `min` cannot be greater than `max`.");return void 0!==e&&o.push(`(min-width: ${It(e,n)})`),void 0!==t&&o.push(`(max-width: ${It(t,n)})`),r&&o.push(`(orientation: ${r})`),o.length?`@media ${o.join(" and ")}`:""},Ut=(e,{min:t,max:r},n)=>{const o=[];if(void 0!==t&&void 0!==r&&t>r)throw new we("REFRACT_E_MEDIA","Invalid container query: `min` cannot be greater than `max`.");return void 0!==t&&o.push(`(min-width: ${It(t,n)})`),void 0!==r&&o.push(`(max-width: ${It(r,n)})`),o.length?`@container ${e} ${o.join(" and ")}`:""},Wt={xs:0,sm:576,md:768,lg:992,xl:1280},Dt=(e,t)=>{const r=Lt(t),n={};for(const[t,o]of Object.entries(null!=e?e:{}))n[t]=zt(o.sizes,e=>Ut(t,{min:e.min,max:e.max},r));return n},Vt={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"},Ht=e=>Math.round(1e3*Math.min(1,Math.max(0,e)))/1e3,Gt=(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)),i=o*(1-Math.abs(n%2-1)),s=Math.min(1,Math.max(0,r))-o/2,[a,l,c]=n<1?[o,i,0]:n<2?[i,o,0]:n<3?[0,o,i]:n<4?[0,i,o]:n<5?[i,0,o]:[o,0,i];return[255*(a+s),255*(l+s),255*(c+s)]},Yt=/^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*(?:\/\s*([\d.]+)(%?)\s*)?\)$/i,Jt=/^hsla?\(\s*([\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[,/]\s*([\d.]+)(%?)\s*)?\)$/i,Kt=e=>{if("string"==typeof e){const t=(e=>{const t=e.trim(),r=Yt.exec(t);if(r){const e="%"===r[2]?Number(r[1]):100*Number(r[1]),t=void 0===r[5]?1:Ht("%"===r[6]?Number(r[5])/100:Number(r[5]));return{rgb:_({L:e,C:Number(r[3]),h:Number(r[4])}),a:t}}const n=Jt.exec(t);if(n){const e=void 0===n[4]?1:Ht("%"===n[5]?Number(n[4])/100:Number(n[4]));return{rgb:Gt(Number(n[1]),Number(n[2])/100,Number(n[3])/100),a:e}}const o=Vt[t.toLowerCase()];if(o)return{rgb:S(o),a:1};try{return R(t)}catch{return null}})(e);if(!t)throw new we("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 C(t.rgb,t.a)}if(!Array.isArray(e)||3!==e.length||e.some(e=>"number"!=typeof e))throw new we("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 C([t,r,n])},Xt={lighten:(e,t)=>P(e,Number(t)),darken:(e,t)=>M(e,Number(t)),alpha:(e,t)=>U(e,Number(t)),setL:(e,t)=>q(e,Number(t)),rotateHue:(e,t)=>L(e,Number(t)),adjust:(e,t)=>I(e,t)},Zt=["light","lighter"],Qt=["dark","darker"],er=(e,t)=>{if(!e||!e.includes("."))return!1;const[r,n]=e.split(".");return`${r}.${n}`!=`colors.${t}`},tr=(e,t)=>{try{return Kt(e)}catch(e){throw new we("REFRACT_E_COLOR_INPUT",`colors.${t}.text — ${e.message}`)}},rr=(e,t,r={})=>{var n;const o=((e,t)=>{let r=t;if(void 0!==t.text&&(r={...r,text:tr(t.text,e)}),t.variants){let n=!1;const o={};for(const[r,i]of Object.entries(t.variants))void 0!==i.text?(o[r]={...i,text:tr(i.text,`${e}.variants.${r}`)},n=!0):o[r]=i;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:tr(t.text,`${e}.modes.${t.mode}`)}):t);n&&(r={...r,modes:o})}return r})(e,t),i=(e=>{try{return R(e),!0}catch{return!1}})(o.base),s=!(!o.steps||!o.steps.length),a=Object.keys(r).length>0,l=void 0!==o.harmony;if((s||a||l)&&!i)throw new we("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=i?ir(o,e):{},d=i?ar(o,e):{},p=null!==(n=o.variants)&&void 0!==n?n:{},u={...c,...d,...p},f=fr(e,o.base,u,r),m={...c,...d,...p,...f},h=or(o,e,m),g=nr(o,e,m);return Object.keys(m).length||h||g?{...o,...Object.keys(m).length?{variants:m}:{},...h?{modes:h}:{},...g?{responsive:g}:{}}:o},nr=(e,t,r)=>{const n=e.responsive;if(!n||!n.length)return;let o=!1;const i=n.map((e,n)=>{const i=e.ref,s=e.modifiers;if(!i||!Array.isArray(s)||!s.length){let t;for(const r of["base","text"]){const n=e[r];if("string"==typeof n||Array.isArray(n)){const o=Kt(n);o!==n&&(t=null!=t?t:{...e},t[r]=o)}}return t&&(o=!0),null!=t?t:e}const a=r[i];if(!a)throw new we("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references unknown variant "${i}".`);if(void 0===a.base)throw new we("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references "${i}", a cross-property derivation — not supported.`);const l=ur({modifiers:s},t,`responsive[${n}]`);let c=a.base;for(const e of l)c=Xt[e.fn](c,e.arg);o=!0;const{ref:d,modifiers:p,...u}=e;return{...u,base:c,derive:{ref:`colors.${t}.${i}`,modifiers:l}}});return o?i:n},or=(e,t,r)=>{const n=e.modes;if(!n||!n.length)return;return n.map(n=>{var o;const i=n.mode,s=n.derive;if(!s)return n;const a=null!==(o=s.modifiers)&&void 0!==o?o:s.fn?[{fn:s.fn,arg:s.arg}]:[];if(er(s.ref,t)){const{base:e,derive:t,...r}=n;return{...r,derive:{ref:s.ref,modifiers:a}}}const l=((n,o)=>{if(!n||n===`colors.${t}`)return{value:e.base,path:`colors.${t}`};const i=n.includes(".")?n.slice(`colors.${t}.`.length):n,s=r[i];if(!s||void 0===s.base)throw new we("REFRACT_E_VARIANT_REF",`colors.${t}.modes.${o} references unknown variant "${n}".`);return{value:s.base,path:`colors.${t}.${i}`}})(s.ref,i);let c=l.value;for(const e of a){const r=Xt[e.fn];if(!r)throw new we("REFRACT_E_VARIANT_REF",`Unknown derivation fn "${e.fn}" for appearance mode "colors.${t}.modes.${i}".`);c=r(c,e.arg)}return{...n,base:c,derive:{ref:l.path,modifiers:a}}})},ir=(e,t)=>e.steps&&e.steps.length?pr(e,t):cr(e,t),sr={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}]},ar=(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 we("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 we("REFRACT_E_HARMONY",`colors.${t}.harmony object form must name exactly one scheme; got [${e.join(", ")}].`);n=e[0],o=r[n]}}const i=sr[n];if(!i)throw new we("REFRACT_E_HARMONY",`colors.${t}.harmony: unknown scheme "${n}". Use one of ${Object.keys(sr).join(", ")}.`);const s={};return i.forEach((r,n)=>{var i;const a=null!==(i=null==o?void 0:o[n])&&void 0!==i?i:r.name;s[a]={base:L(e.base,r.deg),derive:{ref:`colors.${t}`,fn:"rotateHue",arg:r.deg}}}),s},lr=(e,t,r,n,o,i,s,a)=>{var l;const c=e=>e?`colors.${r}.${e}`:`colors.${r}`;let d,p=t.base;for(const t of o){if(void 0!==(null===(l=n[t])||void 0===l?void 0:l.base)){p=n[t].base,d=t;continue}const r=i(p,a);e[t]={base:r,derive:{ref:c(d),fn:s,arg:a}},p=r,d=t}},cr=(e,t)=>{var r,n,o;const i=null!==(r=e.variants)&&void 0!==r?r:{},s={},a=null!==(n=e.lightenBy)&&void 0!==n?n:10,l=null!==(o=e.darkenBy)&&void 0!==o?o:10;return lr(s,e,t,i,Zt,P,"lighten",a),lr(s,e,t,i,Qt,M,"darken",l),s},dr=e=>e<=0?100:e>=1e3?0:Math.min(98,Math.max(5,(1e3-e)/10)),pr=(e,t)=>{var r,n;const o=null!==(r=e.steps)&&void 0!==r?r:[],i=o.find(e=>"number"!=typeof e||isNaN(e)||e<0||e>1e3);if(void 0!==i)throw new we("REFRACT_E_STEPS",`colors.${t}.steps must be numbers in 0–1000 (e.g. [50, …, 950]); got ${JSON.stringify(i)}.`);const s=null!==(n=e.variants)&&void 0!==n?n:{},a={};for(const r of o){const n=r.toString();if(s[n])continue;const o=dr(r);a[n]={base:q(e.base,o),derive:{ref:`colors.${t}`,fn:"setL",arg:o}}}return a},ur=(e,t,r)=>{const n=`colors.${t}.variants.${r}`,o=e.modifiers;if(!Array.isArray(o)||0===o.length)throw new we("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 we("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must be a single-key object like { darken: 10 }.`);const i=Object.keys(e);if(1!==i.length)throw new we("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must have exactly one fn key; got [${i.join(", ")}].`);const s=i[0];if(!Xt[s])throw new we("REFRACT_E_VARIANT",`${n}.modifiers[${o}] unknown fn "${s}"; use ${Object.keys(Xt).join(" / ")}.`);const a=e[s],l="adjust"===s?((e,t,r)=>{const n=`colors.${t}.variants.${r}.adjust`;if("object"!=typeof e||null===e||Array.isArray(e))throw new we("REFRACT_E_ADJUST",`${n} must be an object with numeric l / c / h dials.`);const{l:o,c:i,h:s}=e,a={};if(void 0!==o){if("number"!=typeof o||isNaN(o)||o<0||o>100)throw new we("REFRACT_E_ADJUST",`${n}.l must be an absolute OKLCH lightness in 0–100; got ${JSON.stringify(o)}.`);a.l=o}if(void 0!==i){if("number"!=typeof i||isNaN(i)||i<0)throw new we("REFRACT_E_ADJUST",`${n}.c must be a non-negative chroma multiplier (1 keeps, 0 greys); got ${JSON.stringify(i)}.`);a.c=i}if(void 0!==s){if("number"!=typeof s||isNaN(s))throw new we("REFRACT_E_ADJUST",`${n}.h must be a numeric hue rotation in degrees; got ${JSON.stringify(s)}.`);a.h=s}return a})(a,t,r):Number(a);return{fn:s,arg:l}})},fr=(e,t,r,n)=>{const o={},i=new Set,s=(t,r)=>{if(void 0===t.base)throw new we("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(i.has(l))throw new we("REFRACT_E_CYCLE",`Cyclic colour variant derivation at colors.${e}.${l}.`);i.add(l);const d=ur(c,e,l);if(er(c.ref,e))return o[l]={derive:{ref:c.ref,modifiers:d}},void i.delete(l);const p=(i=>{if(!i)return{value:t,path:`colors.${e}`};if(o[i])return{value:s(o[i],i),path:`colors.${e}.${i}`};if(r[i])return{value:s(r[i],i),path:`colors.${e}.${i}`};if(n[i])return a(i,n[i]),{value:s(o[i],i),path:`colors.${e}.${i}`};throw new we("REFRACT_E_VARIANT_REF",`colors.${e} variant references unknown source "${i}".`)})(c.ref);let u=p.value;for(const e of d)u=Xt[e.fn](u,e.arg);o[l]={base:u,derive:{ref:p.path,modifiers:d}},i.delete(l)}for(const[e,t]of Object.entries(n))a(e,t);return o},mr=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(" ")),hr=/^-(webkit|moz|ms|o)-/,gr=e=>{if(e.startsWith("--"))return!0;const t=e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return!!hr.test(t)||mr.has(t)},vr=new Set(["breakpoint","query","state","variant","target","orientation"]),br=(e,t,r)=>{const n={};if(!e)return n;for(const[o,i]of Object.entries(e)){if(void 0===i||vr.has(o))continue;if(!gr(o))throw new we("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=yr(i,t,r,o);void 0!==e&&(n[wr(o)]=e)}return n},yr=(e,t,r,n)=>{var o;if("number"==typeof e)return{value:e};const i=e.trim();if(!i)return;const s=i.split("."),a=s[0],l=t.properties[a];if(!l)return{value:i};const c=s.length>1?s.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 we("REFRACT_E_VARIANT_REF",`Unknown palette variant reference "${a}.${c}" in ${r}.${n}.`);return{ref:`colors.${a}.${c}`}},wr=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),$r=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),xr=([e,t,r])=>.2126*$r(e/255)+.7152*$r(t/255)+.0722*$r(r/255),kr={fail:0,"AA-large":1,AA:2,AAA:3},jr=2.4,Sr=.2126729,Ar=.7151522,Er=.072175,Rr=.56,Cr=.57,Or=.62,Tr=.65,Fr=.022,Nr=1.414,_r=1.14,zr=.027,Pr=1.14,Mr=.027,qr=5e-4,Lr=.1,Ir=([e,t,r])=>Sr*Math.pow(e/255,jr)+Ar*Math.pow(t/255,jr)+Er*Math.pow(r/255,jr),Br=(e,t)=>{const r=e=>e>Fr?e:e+Math.pow(Fr-e,Nr),n=r(Ir(e)),o=r(Ir(t));if(Math.abs(o-n)<qr)return 0;let i;if(o>n){const e=(Math.pow(o,Rr)-Math.pow(n,Cr))*_r;i=e<Lr?0:e-zr}else{const e=(Math.pow(o,Tr)-Math.pow(n,Or))*Pr;i=e>-Lr?0:e+Mr}return 100*i},Ur=(e,t)=>{const r=10**t;return Math.round(e*r)/r},Wr=(e,t)=>{if(void 0!==t.ref)try{return String(e.resolveToken(t.ref))}catch{return}if("string"==typeof t.value)return t.value},Dr="color",Vr=["background-color","background"],Hr=e=>{if(e)for(const t of Vr)if(e[t])return e[t]},Gr=(e,t,r,n,o)=>{let i,s;try{void 0!==r&&(i=R(r).rgb)}catch{}try{void 0!==n&&(s=R(n).rgb)}catch{}if(!i||!s)return{kind:e,label:t,fg:r,bg:n,skipped:i||s?i?"bg not a colour":"fg not a colour":"no derivable fg/bg"};const a=((e,t)=>{const r=xr(e),n=xr(t);return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)})(i,s),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=kr[l]>=kr[o.minWcag];return{kind:e,label:t,fg:r,bg:n,wcagRatio:Ur(a,2),wcagLevel:l,apcaLc:Ur(Br(i,s),1),pass:c}},Yr=(e,t={})=>{var r,n,o,i,s,a,l,c,d,p,u;const f={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===(i=t.includePalettes)||void 0===i||i)for(const t of Object.keys(e.tokens)){const r=/^colors\.([^.]+)\.text$/.exec(t);if(!r)continue;const n=`colors.${r[1]}`;let o,i;try{o=String(e.resolveToken(t))}catch{}try{i=String(e.resolveToken(n))}catch{}h.push(Gr("palette",n,o,i,f))}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,i]of Object.entries(o)){const o=i.declarations[Dr],m=Hr(i.declarations),g=`${t}.${n}.${r}`;o&&m&&h.push(Gr("recipe",g,Wr(e,o),Wr(e,m),f));for(const t of null!==(s=i.overrides)&&void 0!==s?s:[]){const r=null!==(l=null===(a=t.declarations)||void 0===a?void 0:a[Dr])&&void 0!==l?l:o,n=null!==(c=Hr(t.declarations))&&void 0!==c?c:m;if(!t.declarations||!t.declarations[Dr]&&!Hr(t.declarations))continue;if(!r||!n)continue;const i=null!==(u=null!==(p=null!==(d=t.state)&&void 0!==d?d:t.breakpoint)&&void 0!==p?p:t.query)&&void 0!==u?u:"override";h.push(Gr("recipe",`${g} (${i})`,Wr(e,r),Wr(e,n),f))}}const g=h.filter(e=>!e.skipped),v=g.filter(e=>!1===e.pass),b=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-v.length,failed:v.length,skipped:h.length-g.length,worst:b},ok:0===v.length};if(t.strict&&v.length>0){const e=v.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`).join(", ");throw new we("REFRACT_E_AUDIT",`refract audit: ${v.length} pairing(s) fail WCAG ${f.minWcag} — ${e}. Adjust the colour(s), lower --min-wcag, or drop --strict to report without failing.`,v.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`))}return y},Jr=new Set(["recipes"]),Kr=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("base"in e)&&Array.isArray(e.modifiers),Xr=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))Kr(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}},Zr={key:"colors",derivations:{lighten:(e,t)=>P(String(e),Number(t)),darken:(e,t)=>M(String(e),Number(t)),alpha:(e,t)=>U(String(e),Number(t)),setL:(e,t)=>q(String(e),Number(t)),rotateHue:(e,t)=>L(String(e),Number(t)),adjust:(e,t)=>I(String(e),t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Jr.has(n))continue;const{value:e,specs:i}=Xr(o),s=ct(e,{propertyPath:`colors.${n}`,allowedBreakpoints:t.allowedBreakpoints,coerceValue:Kt}),a=rr(n,s,i);et(a,{propertyPath:`colors.${n}`}),r[n]=a}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{const n=`${r.groupPath}.${e}`;return{base:br(t.base,r,n),responsive:t.responsive.map(e=>{const{breakpoint:t,query:o,state:i,variant:s,target:a,orientation:l,container:c,size:d,...p}=e,u={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...br(p,r,`${n}.responsive`)}};return t&&(u.breakpoint=t,u.query=null!=o?o:"exact"),c&&(u.container=c,d&&(u.size=d),u.query=null!=o?o:"min"),i&&(u.state=i),l&&(u.orientation=l),a&&(u.target=a),u})}})(e,t,r)},Qr={"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},en={xs:-2,sm:-1,md:0,lg:1,xl:2,"2xl":3,"3xl":4,"4xl":5},tn=(e,t)=>"fontSize"!==e?t:rn(t),rn=e=>{var t,r,n,o;const i=e.ratio;if(!i)return e;const s=Qr[i];if(!s)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,d=null!==(n=e.variants)&&void 0!==n?n:{},p={};let u=null;for(const[e,t]of Object.entries(en)){if(d[e]){u=null!==(o=d[e].base)&&void 0!==o?o:null;continue}let r;r=c?c(a,e,t,u):a*Math.pow(s,t);const n=Number(r.toFixed(l));u=n,p[e]={base:n}}return{...e,variants:{...p,...d}}},nn=new Set(["breakpoint","query","state","variant","target","orientation"]),on={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"},sn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||nn.has(r))continue;const e=on[r];e&&(t[e]={ref:an(r,n)})}return t},an=(e,t)=>"base"===t?`typography.${e}`:`typography.${e}.${t}`,ln=new Set(["recipes"]),cn={key:"typography",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(ln.has(n))continue;const e=ct(o,{propertyPath:`typography.${n}`,allowedBreakpoints:t.allowedBreakpoints}),i=tn(n,e);et(i,{propertyPath:`typography.${n}`}),r[n]=i}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:sn(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:i,target:s,orientation:a,container:l,size:c,...d}=e,p={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...sn(d)}};return t&&(p.breakpoint=t,p.query=null!=n?n:"exact"),l&&(p.container=l,c&&(p.size=c),p.query=null!=n?n:"min"),o&&(p.state=o),s&&(p.target=s),a&&(p.orientation=a),p})}))(0,t,r)},dn=["spacing","gutters","aspectRatio","sizes"],pn=new Set(["spacing","gutters","sizes"]),un=new Set(["spacing","gutters"]),fn=["xs","sm","md","lg","xl","2xl","3xl","4xl"],mn=e=>Number(e.toFixed(4)),hn=(e,t)=>{var r;if(!pn.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 we("REFRACT_E_LAYOUT",`layout.${e}: declare only one of "ratio" (geometric) or "step" (linear) scale, not both.`);const i=r.steps;if(n){let t;if(void 0===i)t=fn;else{if(!Array.isArray(i))throw new we("REFRACT_E_LAYOUT",`layout.${e}: a geometric scale ("ratio") needs "steps" as an ordered name array, e.g. ["sm","md","lg"].`);t=i.map(String)}const n=t.map((e,t)=>({name:e,exp:t}));return{curve:"geometric",ratio:Number(r.ratio),specs:n}}let s;if(void 0===i)s=fn.map((e,t)=>({name:e,exp:t,mult:t+1}));else{if(Array.isArray(i)||"object"!=typeof i||null===i)throw new we("REFRACT_E_LAYOUT",`layout.${e}: a linear scale ("step") needs "steps" as a name→multiplier map, e.g. { sm:1, md:2, lg:3 }.`);s=Object.entries(i).map(([e,t],r)=>({name:e,exp:r,mult:Number(t)}))}return{curve:"linear",step:Number(r.step),specs:s}})(e,t);if(!n)return un.has(e)?gn(t):t;const o=((e,t,r)=>{const n=`layout.${e}`,o={};for(const e of r.specs)if("geometric"===r.curve){const i=mn(Number(t)*Math.pow(r.ratio,e.exp));o[e.name]={base:i,derive:{ref:n,fn:"scaleStep",arg:{curve:"geometric",ratio:r.ratio,exp:e.exp}}}}else{const t=mn(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 i={...o,...null!==(r=t.variants)&&void 0!==r?r:{}};un.has(e)&&(i={...i,none:{base:0}});const s=((e,t,r,n)=>{if(!(null==r?void 0:r.length))return r;const o=`layout.${e}`,i=[];let s=!1;for(const a of r){const r=a;if(void 0===r.ratio&&void 0===r.step){i.push(r);continue}if(s=!0,void 0!==r.ratio&&void 0!==r.step)throw new we("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry may set only "ratio" or "step", not both.`);if(!n)throw new we("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:d}=r,p=void 0!==r.ratio;for(const s of n.specs){let n,a;if(p){const e=Number(r.ratio),o=void 0!==r.base,i=Number(o?r.base:t);n=mn(i*Math.pow(e,s.exp)),a={curve:"geometric",ratio:e,exp:s.exp,...o?{base:i}:{}}}else{if(void 0===s.mult)throw new we("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=mn(t*s.mult),a={curve:"linear",step:t,mult:s.mult}}const u={breakpoint:l,query:c,target:s.name,base:n,derive:{ref:o,fn:"scaleStep",arg:a}};void 0!==d&&(u.orientation=d),i.push(u)}}return s?i:r})(e,t.base,t.responsive,n);return(e=>{const{ratio:t,step:r,steps:n,...o}=e;return o})({...t,variants:i,responsive:s})},gn=e=>{var t;const r=null!==(t=e.variants)&&void 0!==t?t:{};return{...e,variants:{...r,none:{base:0}}}},vn=new Set(["breakpoint","query","state","variant","target","orientation"]),bn={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"]},yn={paddingY:"spacing",paddingX:"spacing",marginY:"spacing",marginX:"spacing",gap:"spacing",width:"sizes",minWidth:"sizes",maxWidth:"sizes",height:"sizes",minHeight:"sizes",maxHeight:"sizes",background:"literal"},wn=(e,t)=>"base"===t?`layout.${e}`:`layout.${e}.${t}`,$n=(e,t)=>{const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(vn.has(n))continue;if(!o)continue;const e=bn[n];if(!e)throw new we("REFRACT_E_LAYOUT",`Unknown layout recipe property "${n}" in ${t}. Known verbs: ${Object.keys(bn).join(", ")}. For arbitrary CSS use a component \`css\` delta.`);const i=yn[n];for(const t of e)r[t]="literal"===i?{value:o}:{ref:wn(i,o)}}return r},xn=e=>({ref:"base"===e?"layout.spacing":`layout.spacing.${e}`}),kn=e=>({ref:"base"===e?"layout.gutters":`layout.gutters.${e}`}),jn=e=>({ref:`layout.${e}`}),Sn=e=>({value:e}),An=e=>Object.keys(e).sort((t,r)=>e[t]-e[r]),En=[["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"]],Rn=(e,t)=>{const r={};t&&(r.display=Sn("grid"));for(const[t,n]of En){const o=e[t];o&&(r[n]=Sn(o))}return e.gap&&(r.gap=xn(e.gap)),r},Cn=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}},On=(e,t,r=new Set,n)=>{var o,i,s,a;const l=Lt(n),c=e=>It(e,l),d={},p={},u=An(t),f=e&&"object"==typeof e?e:void 0,m=f?{mode:null!==(o=f.base)&&void 0!==o?o:"fixed",inset:f.inset,gutter:f.gutter,direction:f.direction,align:f.align,justify:f.justify,maxWidth:f.maxWidth}:Cn(null!=e?e:"fixed"),h=null!==(i=null==f?void 0:f.variants)&&void 0!==i?i:{},g=null!==(s=null==f?void 0:f.responsive)&&void 0!==s?s:[],v=e=>e?`container-${e}`:"container",b=(e,n)=>{var o,i,s,a,l,f,h,g,b;const y=e?`--${e}`:"",w=`container${y}--inset`,$=`container${y}--gutter`,x=null!==(i=null!==(o=n.inset)&&void 0!==o?o:m.inset)&&void 0!==i?i:"base",k=null!==(s=n.gutter)&&void 0!==s?s:m.gutter,j=null!==(l=null!==(a=n.mode)&&void 0!==a?a:m.mode)&&void 0!==l?l:"fixed",S=null!==(f=n.direction)&&void 0!==f?f:m.direction,A=null!==(h=n.align)&&void 0!==h?h:m.align,E=null!==(g=n.justify)&&void 0!==g?g:m.justify,R=null!==(b=n.maxWidth)&&void 0!==b?b:e?m.maxWidth:void 0;d[w]={base:xn(x)},k&&(d[$]={base:kn(k)});const C={"box-sizing":Sn("border-box"),width:Sn("100%"),"margin-left":Sn("auto"),"margin-right":Sn("auto"),"padding-left":jn(w),"padding-right":jn(w)};k&&(C.gap=jn($)),S&&(C.display=Sn("flex"),C["flex-direction"]=Sn(S)),A&&(C["align-items"]=Sn(A)),E&&(C["justify-content"]=Sn(E));const O=[];if("fixed"===j){const e="string"==typeof R&&void 0!==t[R]?R:void 0,r=e?u.indexOf(e):-1;for(let n=0;n<u.length;n++){const o=u[n],i=t[r>=0&&n>r?e:o];0!==i?0===n?C["max-width"]=Sn(c(i)):O.push({breakpoint:o,query:"min",declarations:{"max-width":Sn(c(i))}}):0===n&&(C["max-width"]=Sn("none"))}}else"fluid"===j?void 0!==R&&(C["max-width"]=((e,t,r)=>{return"number"==typeof e?Sn(`${e}px`):t.has(e)?{ref:"base"===(n=e)?"layout.sizes":`layout.sizes.${n}`}:void 0!==r[e]?Sn(`${r[e]}px`):Sn(e);var n})(R,r,t)):C["max-width"]=Sn("number"==typeof j?`${j}px`:j);p[v(e)]={kind:"recipe",declarations:C,overrides:O}};b(null,m);for(const[e,t]of Object.entries(h))b(e,Cn(t));for(const e of g){const t=e.target,r=v(null!=t?t:null),n=p[r];if(!n)continue;const o={};if(e.direction&&(o["flex-direction"]=Sn(e.direction)),e.align&&(o["align-items"]=Sn(e.align)),e.justify&&(o["justify-content"]=Sn(e.justify)),e.inset){const e=t?`container--${t}--inset`:"container--inset";o["padding-left"]=jn(e),o["padding-right"]=jn(e)}if(e.gutter){const e=t?`container--${t}--gutter`:"container--gutter";o.gap=jn(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:p},configProperties:d}},Tn=(e,t,r)=>{const n={},o={},i=e=>{e&&(Object.assign(n,e.ruleSetGroups),Object.assign(o,e.configProperties))};return i(((e,t)=>{var r,n;if(!e)return;const o="number"==typeof e?{size:e}:e,i=o.size,s=null!==(r=o.gutter)&&void 0!==r?r:"base",a=null!==(n=o.inset)&&void 0!==n?n:"none",l={"columns--size":{base:Sn(String(i))},"columns--gutter":{base:kn(s)},"columns--inset":{base:xn(a)}},c={},d=Array.from({length:i},(e,t)=>t+1);for(const e of An(t))for(const r of d){const n=`col-${e}-${r}`,o=`offset-${e}-${r}`,i={"grid-column-end":Sn(`span ${r}`)},s={"grid-column-start":Sn(String(r+1))};0===t[e]?(c[n]={kind:"utility",declarations:i,overrides:[]},c[o]={kind:"utility",declarations:s,overrides:[]}):(c[n]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:i}]},c[o]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:s}]})}return{ruleSetGroups:{columns:c},configProperties:l}})(e.columns,t)),i((e=>{var t,r;if(!e||!Object.keys(e).length)return;const n={};for(const[o,i]of Object.entries(e)){const e=Rn(i,!0),s=[];for(const e of null!==(t=i.responsive)&&void 0!==t?t:[]){const t=Rn(e,!1);Object.keys(t).length&&s.push({breakpoint:e.breakpoint,query:null!==(r=e.query)&&void 0!==r?r:"exact",declarations:t})}n[`grid-${o}`]={kind:"recipe",declarations:e,overrides:s}}return{ruleSetGroups:{grids:n},configProperties:{}}})(e.grids)),i((e=>{var t,r,n;if(!e||!Object.keys(e).length)return;const o={};for(const[i,s]of Object.entries(e)){const e={display:Sn(s.inline?"inline-flex":"flex"),"flex-direction":Sn(null!==(t=s.direction)&&void 0!==t?t:"column")};s.align&&(e["align-items"]=Sn(s.align)),s.justify&&(e["justify-content"]=Sn(s.justify)),s.wrap&&(e["flex-wrap"]=Sn(s.wrap)),s.gap&&(e.gap=xn(s.gap));const a=[];for(const e of null!==(r=s.responsive)&&void 0!==r?r:[]){const t={};void 0!==e.inline&&(t.display=Sn(e.inline?"inline-flex":"flex")),e.direction&&(t["flex-direction"]=Sn(e.direction)),e.align&&(t["align-items"]=Sn(e.align)),e.justify&&(t["justify-content"]=Sn(e.justify)),e.wrap&&(t["flex-wrap"]=Sn(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-${i}`]={kind:"recipe",declarations:e,overrides:a}}return{ruleSetGroups:{stacks:o},configProperties:{}}})(e.stacks)),i(On(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}},Fn=new Set(dn),Nn={key:"layout",derivations:{scaleStep:(e,t)=>((e,t)=>{const r=null!=t?t:{};if("linear"===r.curve)return mn(Number(r.step)*Number(r.mult));const n=void 0!==r.base?Number(r.base):Number(e);return mn(n*Math.pow(Number(r.ratio),Number(r.exp)))})(e,t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const n of dn){const o=e[n];if(void 0===o||!Fn.has(n))continue;const i=ct(o,{propertyPath:`layout.${n}`,allowedBreakpoints:t.allowedBreakpoints}),s=hn(n,i);et(s,{propertyPath:`layout.${n}`}),r[n]=s}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:$n(t.base,o),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:i,variant:s,target:a,orientation:l,container:c,size:d,...p}=e,u={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...$n(p,o)}};return t&&(u.breakpoint=t,u.query=null!=n?n:"exact"),c&&(u.container=c,d&&(u.size=d),u.query=null!=n?n:"min"),i&&(u.state=i),a&&(u.target=a),l&&(u.orientation=l),u})}})(e,t,r),buildStructural:(e,t)=>Tn(e,t.breakpoints,t.mediaConfig)},_n=new Set(["breakpoint","query","state","variant","target","orientation"]),zn={boxShadow:"box-shadow",opacity:"opacity",blur:"filter",transition:"transition",zIndex:"z-index"},Pn={boxShadow:"shadow",opacity:"opacity",blur:"blur",transition:"transitions",zIndex:"zIndex"},Mn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||_n.has(r))continue;const e=zn[r],o=Pn[r];if(!e||!o)continue;const i={ref:qn(o,n)};"blur"===r&&(i.wrap="blur"),t[e]=i}return t},qn=(e,t)=>"base"===t?`effects.${e}`:`effects.${e}.${t}`,Ln=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),In=(e,t)=>{if(void 0!==e){if("number"!=typeof e||Number.isNaN(e))throw new we("REFRACT_E_EFFECTS",`${t} must be a number, received ${JSON.stringify(e)}.`);return e}},Bn=(e,t)=>{if(void 0!==e){if("number"==typeof e){if(Number.isNaN(e))throw new we("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`);return e}if("string"==typeof e){const r=Be(e);if("raw"in r)throw new we("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 we("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`)}},Un=new Set(["offsetX","offsetY","blur","spread","color","inset"]),Wn=(e,t)=>{if(!Ln(e))throw new we("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 we("REFRACT_E_EFFECTS",`${t} has unknown shadow field "${r}" (allowed: ${[...Un].join(", ")}).`);const r={},n=Bn(e.offsetX,`${t}.offsetX`),o=Bn(e.offsetY,`${t}.offsetY`),i=Bn(e.blur,`${t}.blur`),s=Bn(e.spread,`${t}.spread`);if(void 0!==n&&(r.offsetX=n),void 0!==o&&(r.offsetY=o),void 0!==i&&(r.blur=i),void 0!==s&&(r.spread=s),void 0!==e.color){if("string"!=typeof e.color||!e.color)throw new we("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 we("REFRACT_E_EFFECTS",`${t}.inset must be a boolean.`);e.inset&&(r.inset=!0)}return r},Dn=new Set(["property","duration","timingFunction","delay"]),Vn=(e,t)=>{if(!Ln(e))throw new we("REFRACT_E_EFFECTS",`${t} must be a transition-part object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!Dn.has(r))throw new we("REFRACT_E_EFFECTS",`${t} has unknown transition field "${r}" (allowed: ${[...Dn].join(", ")}).`);if("string"!=typeof e.property||!e.property)throw new we("REFRACT_E_EFFECTS",`${t}.property is required (the CSS property to transition).`);const r={property:e.property},n=In(e.duration,`${t}.duration`),o=In(e.delay,`${t}.delay`);if(void 0!==n&&(r.duration=n),void 0!==e.timingFunction){if("string"!=typeof e.timingFunction||!e.timingFunction)throw new we("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},Hn=new Set(["recipes"]),Gn={shadow:["offsetX","offsetY","blur","spread","color","inset"],transitions:["property","duration","timingFunction","delay"]},Yn=e=>"shadow"===e?t=>((e,t="effects.shadow")=>{if("string"==typeof e){if("none"===e)return"none";throw new we("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 we("REFRACT_E_EFFECTS",`${t} is an empty shadow-layer array.`);return e.map((e,r)=>Wn(e,`${t}[${r}]`))}return[Wn(e,t)]})(t,`effects.${e}`):"transitions"===e?t=>((e,t="effects.transitions")=>{if("string"==typeof e){if("none"===e)return"none";throw new we("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 we("REFRACT_E_EFFECTS",`${t} is an empty transition-part array.`);return e.map((e,r)=>Vn(e,`${t}[${r}]`))}return[Vn(e,t)]})(t,`effects.${e}`):void 0,Jn={key:"effects",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Hn.has(n))continue;const e=Gn[n],i=Yn(n),s=ct(o,{propertyPath:`effects.${n}`,allowedBreakpoints:t.allowedBreakpoints,...e?{leafFields:e}:{},...i?{coerceValue:i}:{},...e?{fallbackBase:"none"}:{}});et(s,{propertyPath:`effects.${n}`}),r[n]=s}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:Mn(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:i,target:s,orientation:a,container:l,size:c,...d}=e,p={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...Mn(d)}};return t&&(p.breakpoint=t,p.query=null!=n?n:"exact"),l&&(p.container=l,c&&(p.size=c),p.query=null!=n?n:"min"),o&&(p.state=o),s&&(p.target=s),a&&(p.orientation=a),p})}))(0,t,r)},Kn=new Set(["breakpoint","query","state","variant","target","orientation","container","size"]),Xn=new Set(["as","side"]),Zn=new Set(["width","style","offset","radius","color"]),Qn=(e,t,r)=>"radius"===r?"border-radius":"offset"===r?"outline-offset":"outline"===e?`outline-${r}`:t?`border-${t}-${r}`:`border-${r}`,eo=(e,t)=>"color"===e?{ref:t}:{ref:"base"===t?`borders.${e}`:`borders.${e}.${t}`},to=(e,t,r)=>{const n={};if(!e)return n;for(const[o,i]of Object.entries(e))i&&!Kn.has(o)&&!Xn.has(o)&&Zn.has(o)&&(n[Qn(t,r,o)]=eo(o,i));return n},ro=new Set(["recipes"]),no={key:"borders",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(ro.has(n))continue;const e=ct(o,{propertyPath:`borders.${n}`,allowedBreakpoints:t.allowedBreakpoints});et(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",i=t.base.side,s=to(t.base,o,i),a=t.responsive.map(e=>{var t,n;const{breakpoint:s,query:a,state:l,variant:c,target:d,orientation:p,container:u,size:f,as:m,side:h,...g}=e,v=null!==(t=m)&&void 0!==t?t:o,b=null!==(n=h)&&void 0!==n?n:i,y={declarations:{...c?{...r.resolveRecipeVariant(c).base}:{},...to(g,v,b)}};return s&&(y.breakpoint=s,y.query=null!=a?a:"exact"),u&&(y.container=u,f&&(y.size=f),y.query=null!=a?a:"min"),l&&(y.state=l),p&&(y.orientation=p),d&&(y.target=d),y});return{base:s,responsive:a}})(0,t,r)},oo=new Set(["breakpoint","query","state","variant","target","orientation"]),io={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"},so={duration:"duration",easing:"easing",delay:"delay"},ao=(e,t)=>"base"===t?`animation.${e}`:`animation.${e}.${t}`,lo=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(void 0===n||""===n||oo.has(r))continue;const e=io[r];e&&(t[e]="keyframes"===r?{ref:`animation.keyframes.${n}`}:so[r]?{ref:ao(so[r],String(n))}:{value:n})}return t},co=new Set(["keyframes","recipes"]),po=e=>e&&"object"==typeof e&&"ref"in e?{ref:String(e.ref)}:"string"==typeof e||"number"==typeof e?{value:e}:void 0,uo=e=>{const t={};for(const[r,n]of Object.entries(e)){const e=po(n);e&&(t[r]=e)}return t},fo=e=>{const t=[];for(const[r,n]of Object.entries(e))t.push({stop:r,declarations:uo(n)});return{steps:t}},mo=e=>{if(!e||"object"!=typeof e)return{};const t={};for(const[r,n]of Object.entries(e))n&&"object"==typeof n&&(t[r]=fo(n));return t},ho={key:"animation",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(co.has(n))continue;const e=ct(o,{propertyPath:`animation.${n}`,allowedBreakpoints:t.allowedBreakpoints});et(e,{propertyPath:`animation.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:lo(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:i,target:s,orientation:a,container:l,size:c,...d}=e,p={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...lo(d)}};return t&&(p.breakpoint=t,p.query=null!=n?n:"exact"),l&&(p.container=l,c&&(p.size=c),p.query=null!=n?n:"min"),o&&(p.state=o),s&&(p.target=s),a&&(p.orientation=a),p})}))(0,t,r),buildStructural:e=>({ruleSetGroups:{},configProperties:{},keyframes:mo(e.keyframes)})},go=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e))t[bo(r)]=vo(n);return t},vo=e=>"object"==typeof e?{ref:e.ref}:{value:e},bo=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),yo={key:"components",normalizeProperties:()=>({}),interpretRecipe:(e,t,r)=>((e,t)=>({base:go(t.base.css),responsive:t.responsive.map(e=>{var t,r;const n=e,o={declarations:go(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))_e.has(r)&&"string"==typeof n&&n.includes(".")&&t.push(`${r}:${n}`);return t})(e)},wo=e=>({value:e}),$o=e=>({ref:e}),xo=(e,t)=>({kind:"reset",selector:e,declarations:t,overrides:[]}),ko=e=>{const t={};for(const[r,n,o]of e){const e={};for(const[t,r]of Object.entries(o))e[t]=wo(r);t[r]=xo(n,e)}return t},jo=[["h1","4xl"],["h2","3xl"],["h3","2xl"],["h4","xl"],["h5","lg"],["h6","md"]],So={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}},Ao=Object.keys(So),Eo=e=>{if(!1===e)return{};const t=So[e];if(!t)throw new we("REFRACT_E_PRESET",`globals: unknown preset "${e}" — expected one of ${Ao.join(", ")} or false`);const r={static:ko(t.static)};return t.headings&&(r.defaults=(()=>{const e={};for(const[t,r]of jo)e[t]=xo(t,{"font-size":$o(`typography.fontSize.${r}`)});return e})()),r},Ro=new Set(["state","breakpoint","query","orientation","container","size","variant","target"]),Co=e=>null!==e&&"object"==typeof e?{ref:e.ref}:{value:e},Oo=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),To=e=>{const t={};for(const[r,n]of Object.entries(e))null==n||Ro.has(r)||(t[Oo(r)]=Co(n));return t},Fo=e=>{const t={declarations:To(e)},r=e;for(const e of Ro)void 0!==r[e]&&(t[e]=r[e]);return t},No=(e,t,r)=>(e=>({declarations:To(e.base),overrides:e.responsive.map(Fo)}))($t({[e]:t},r)[e]),_o=(e,t)=>{const r=null!=e?e:{},n={};if(void 0!==r.preset){const e=Eo(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,i]of Object.entries(e)){if(!i||"object"!=typeof i)continue;const e={propertyPath:`globals.elements.${o}`,allowedBreakpoints:r,allowedStates:t.allowedStates,allowedContainers:t.allowedContainers},{variants:s,...a}=i,l=No(o,a,e),c={kind:"globals",selector:o,declarations:l.declarations,overrides:l.overrides};if(s&&"object"==typeof s&&Object.keys(s).length){const t={};for(const[r,n]of Object.entries(s))n&&"object"==typeof n&&(t[r]=No(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},zo=[Zr,cn,Nn,Jn,no,ho,yo,{key:"globals",normalizeProperties:()=>({}),buildStructural:(e,t)=>({ruleSetGroups:_o(e,t),configProperties:{}})}];const Po=(e,t)=>zt(e,e=>Bt(e,Lt(t))),Mo=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},qo=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},Lo=(e,t)=>{if(e.startsWith("--"))return e;const r=e.split(".").join("-").toLowerCase();return t?`--${t}-${r}`:`--${r}`};function Io(e,t,r){const{clean:n,externals:o}=((e,t)=>{if(!e)return{clean:e,externals:{}};const r={},n={};for(const[o,i]of Object.entries(e))if(null===i||"object"!=typeof i||Array.isArray(i)||"string"!=typeof i.external)r[o]=i;else{const e=Lo(i.external,t);n[o]={base:`var(${e})`,external:e,responsive:[]}}return{clean:r,externals:n}})(t,r.extendsPrefix),i=e.normalizeProperties(n,{allowedBreakpoints:r.allowedBreakpoints});Object.assign(i,o);const s=r.inheritedProperties?{...r.inheritedProperties,...i}:i,a=function(e,t,r){var n,o;if(!e.interpretRecipe||!t||!Object.keys(t).length)return{};const i={};for(const[s,a]of Object.entries(t)){const t=`${e.key}.recipes.${s}`,l=$t(a,{propertyPath:t,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers}),c=At(l,(n,o,i)=>e.interpretRecipe(n,o,{breakpoints:r.breakpoints,media:r.media,properties:r.properties,resolveRecipeVariant:i,groupPath:t}),{groupPath:t}).resolveAll(),d={};for(const[t,r]of Object.entries(c))if(e.extractReferences){const i=e.extractReferences(null!==(o=null===(n=l[t])||void 0===n?void 0:n.base)&&void 0!==o?o:{});d[t]=Ne(r,i)}else d[t]=Fe(r);i[s]=d}return i}(e,null==t?void 0:t.recipes,{breakpoints:r.breakpoints,media:r.media,properties:s,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});let l,c,d=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});d={...n.ruleSetGroups,...a},Object.keys(n.configProperties).length&&(l=n.configProperties),n.keyframes&&Object.keys(n.keyframes).length&&(c=n.keyframes)}const p={};return Object.keys(i).length&&(p.properties=i),Object.keys(d).length&&(p.ruleSetGroups=d),l&&(p.extraProperties=l),c&&(p.keyframes=c),p}function Bo(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 Uo(e,t){var r,n,o,i,s;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,s]of Object.entries(t.ruleSets))r[n]={...null!==(i=null===(o=e.ruleSets)||void 0===o?void 0:o[n])&&void 0!==i?i:{},...s};a.ruleSets=r}return t.keyframes&&(a.keyframes={...null!==(s=e.keyframes)&&void 0!==s?s:{},...t.keyframes}),a}function Wo(e,t){var r,n,o,i;const{adapter:s}=t,a=e,l=null!==(r=a.breakpoints)&&void 0!==r?r:Wt,c=Object.keys(l),d=null!==(o=null===(n=a.extends)||void 0===n?void 0:n.prefix)&&void 0!==o?o:"dt",p=s.allowedStates,u=new Set(null!==(i=a.modes)&&void 0!==i?i:["dark","light"]),f=t.media,m=Po(l,f),h=Mo(a.containers),g=qo(h),v={};for(const e of zo){const t=Io(e,a[e.key],{breakpoints:l,extendsPrefix:d,media:m,mediaConfig:f,allowedBreakpoints:c,allowedStates:p,allowedContainers:g});Object.keys(t).length&&(v[e.key]=t)}const b=(e=>{var t;const r={},n=Pe(e.colors);n&&(r.colors=n);const o=Pe(e.typography);o&&(r.typography=o);const i=Pe(e.layout);i&&(r.layout=i);const s=Pe(e.effects);s&&(r.effects=s);const a=Pe(e.borders);a&&(r.borders=a);const l=Pe(e.animation);l&&(r.animation=l),ze(null===(t=e.components)||void 0===t?void 0:t.ruleSetGroups)&&(r.components={ruleSets:e.components.ruleSetGroups});const c=Pe(e.globals);c&&(r.globals=c);const d={breakpoints:e.breakpoints,subsystems:r};return e.containers&&Object.keys(e.containers).length&&(d.containers=e.containers),d})({breakpoints:l,containers:h,...v}),y={units:t.units,baseFontSize:t.baseFontSize},w=function(e,t){var r;const{propertiesOverlay:n,ruleSetsOverlay:o,keyframesOverlay:i,containersOverlay:s}=t;if(!(n||o||i||s))return e;const a={...e.subsystems},l=new Set([...Object.keys(null!=n?n:{}),...Object.keys(null!=o?o:{}),...Object.keys(null!=i?i:{})]);for(const e of l)a[e]=Uo(a[e],{properties:null==n?void 0:n[e],ruleSets:null==o?void 0:o[e],keyframes:null==i?void 0:i[e]});const c={...e,subsystems:a};return s&&(c.containers={...null!==(r=e.containers)&&void 0!==r?r:{},...s}),c}(Xe(b,y),t),$=(e=>{const t={};for(const r of e)for(const[e,n]of Object.entries(r)){if(e in t)throw new we("REFRACT_E_TOKEN_PATH",`Duplicate derivation fn "${e}" registered by two subsystems.`);t[e]=n}return t})(zo.flatMap(e=>e.derivations?[e.derivations]:[])),x=Ft(w,$),k=[...Vo(x),...Ho(x),...Go(x),...Do(x,u)];if(k.length>0){const e=k.map(e=>` - ${e}`).join("\n");throw new we("REFRACT_E_VALIDATION",`refract: ${k.length} validation error(s):\n${e}`,k)}return Yo(x,{adapter:s,derivationRegistry:$,allowedStates:p,mediaConfig:f,unitConfig:y})}function Do(e,t){var r,n,o;const i=[],s=(e,r,n,o)=>{t.has(n)||i.push(`${e}.${r}${o}: unknown appearance mode '${n}' — declare it in the top-level 'modes' registry (known: ${[...t].join(", ")})`)};for(const[t,i]of Object.entries(e.subsystems))for(const[e,a]of Object.entries(null!==(r=i.properties)&&void 0!==r?r:{})){for(const r of null!==(n=a.modes)&&void 0!==n?n:[])r.mode&&s(t,e,r.mode,"");for(const r of null!==(o=a.responsive)&&void 0!==o?o:[])r.mode&&s(t,e,r.mode," (responsive)")}return i}function Vo(e){var t,r,n,o,i;const s=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!s)return[];const a=[];for(const[t,l]of Object.entries(s))for(const[s,c]of Object.entries(l))for(const l of null!==(r=c.references)&&void 0!==r?r:[]){const[r,c=""]=l.split(":"),d=c.indexOf("."),p=d>=0?c.slice(0,d):c,u=d>=0?c.slice(d+1):"";(null===(i=null===(o=null===(n=e.subsystems[r])||void 0===n?void 0:n.ruleSets)||void 0===o?void 0:o[p])||void 0===i?void 0:i[u])||a.push(`components.${t}.${s}: Recipe variant "${u}" is not defined in "${r}:${p}". Check the subsystem:group.variant reference against what the subsystem declares.`)}return a}function Ho(e){var t,r;const n=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!n)return[];const o=Me(e),i=[],s=(e,t,r,n)=>{for(const[s,a]of Object.entries(null!=e?e:{}))void 0===a.ref||a.ref in o||i.push(`components.${t}.${r}: css '${s}'${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)){s(o.declarations,e,n,"");for(const t of null!==(r=o.overrides)&&void 0!==r?r:[])s(t.declarations,e,n," (override)")}return i}function Go(e){var t,r,n,o,i;const s=null===(t=e.subsystems.globals)||void 0===t?void 0:t.ruleSets;if(!s)return[];const a=Me(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(s))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!==(i=n.overrides)&&void 0!==i?i:[])c(r.declarations,e,`${t} (override)`)}}return l}function Yo(e,t){var r;const n=Po(e.breakpoints,t.mediaConfig),o=Dt(e.containers,t.mediaConfig),i=new WeakMap,s=()=>{let t=i.get(e);return t||(t=Me(e),i.set(e,t)),t},a=e=>Et(s(),t.derivationRegistry,e),l={media:n,containers:o,resolve:a},c=t.adapter.bind(e,l),d={model:e,get tokens(){return s()},resolveToken:a,override:r=>function(e,t,r){var n,o,i;const s=t.breakpoints,a=s?{...e.breakpoints,...s}:e.breakpoints,l=Object.keys(a),c=Po(a,r.mediaConfig),d=Mo(t.containers),p=d?{...null!==(n=e.containers)&&void 0!==n?n:{},...d}:e.containers,u=qo(p),f={...e.subsystems};for(const n of zo){const s=t[n.key];if(void 0===s)continue;const d=Bo(e.subsystems[n.key]),p=Io(n,s,{breakpoints:a,extendsPrefix:null!==(i=null===(o=t.extends)||void 0===o?void 0:o.prefix)&&void 0!==i?i:"dt",media:c,mediaConfig:r.mediaConfig,allowedBreakpoints:l,allowedStates:r.allowedStates,allowedContainers:u,inheritedProperties:d}),m=Pe(p);m&&(f[n.key]=Uo(e.subsystems[n.key],m))}const m={breakpoints:a,subsystems:f};p&&Object.keys(p).length&&(m.containers=p);const h=Xe(m,r.unitConfig),g=Ft(h,r.derivationRegistry);return Yo(g,r)}(e,r,t)},p=null===(r=c.extend)||void 0===r?void 0:r.call(c,d);return p&&Object.defineProperties(d,Object.getOwnPropertyDescriptors(p)),d}const Jo="theme.css",Ko="styles.css",Xo="variables.css",Zo=(e,t)=>"variables"===t?`${e}.variables.css`:`${e}.css`,Qo=e=>`${e.group}-${e.variant}.css`,ei="variables.css";function ti(e){var t,r,n,o,i,s,a,l;if(void 0===e)return{type:"single",file:Jo};if("string"==typeof e)switch(e){case"single":return{type:"single",file:Jo};case"split":return{type:"split",file:Ko,variables:Xo};case"subsystem":return{type:"subsystem",filename:Zo};case"components":return{type:"components",inline:!0,filename:Qo,variables:ei}}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:Jo};case"split":{const t=e;return{type:"split",file:null!==(n=t.file)&&void 0!==n?n:Ko,variables:null!==(o=t.variables)&&void 0!==o?o:Xo}}case"subsystem":return{type:"subsystem",filename:null!==(i=e.filename)&&void 0!==i?i:Zo};case"components":{const t=e;return{type:"components",inline:null===(s=t.inline)||void 0===s||s,filename:null!==(a=t.filename)&&void 0!==a?a:Qo,variables:null!==(l=t.variables)&&void 0!==l?l:ei}}}throw new Error("resolveEmitPlan: unrecognized emit directive.")}const ri="com.theme-registry.refract",ni=e=>"object"==typeof e&&null!==e&&"$value"in e,oi=/^\{([^}]+)\}$/,ii=(e,t,r=new Set)=>{if("string"==typeof e){const n=e.match(oi);if(n){const o=n[1];if(r.has(o))throw new we("REFRACT_E_CYCLE",`Circular token reference: ${o}`);const i=t.get(o);return i?(r.add(o),ii(i.value,t,r)):e}return e}if(Array.isArray(e))return e.map(e=>ii(e,t,new Set(r)));if("object"==typeof e&&null!==e){const n={};for(const[o,i]of Object.entries(e))n[o]=ii(i,t,new Set(r));return n}return e};function si(e){var t;const r=[];for(const[n,o]of Object.entries(e.subsystems))for(const[e,i]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(i))r.push({subsystem:n,group:e,variant:t});return r}function ai(){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,i,s;const a=e.bind(t,r),l=null!==(n=a.renderAllRecipes)&&void 0!==n?n:()=>a.join(si(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))),d=null!==(i=a.renderAll)&&void 0!==i?i:()=>a.join([c(),l()]),p=null!==(s=a.describeUsage)&&void 0!==s?s:()=>({format:e.name,summary:[`This theme was built with the "${e.name}" refract adapter.`],recipes:si(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:d,describeUsage:p}}};var e}const li=(e,t)=>{var r,n,o;const i=(e=>{const t=[],r=new Map,n=(e,o,i)=>{var s,a,l;const c=null!==(s=e.$type)&&void 0!==s?s:i;for(const[i,s]of Object.entries(e)){if(i.startsWith("$"))continue;if("object"!=typeof s||null===s)continue;const e=[...o,i];if(ni(s)){const n=s,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(s,e,c)}};n(e,[]);for(const e of t)e.value=ii(e.value,r);return t})(e),s=null!==(r=null==t?void 0:t.groupMapping)&&void 0!==r?r:{},a={},l={},c={},d={},p={};let u=null!==(n=null==t?void 0:t.breakpoints)&&void 0!==n?n:{};const f=new Map;for(const e of i){const t=e.path[0];f.has(t)||f.set(t,[]),f.get(t).push(e)}const m=null==t?void 0:t.breakpointGroup;if(m&&f.has(m)){u={};for(const e of f.get(m)){u[e.path[e.path.length-1]]=ji(e.value)}f.delete(m)}for(const[e,t]of f){const r=null!==(o=s[e])&&void 0!==o?o:ci(e,t);if("ignore"!==r)switch(r){case"colors":ui(t,e,a);break;case"typography":mi(t,e,l);break;case"effects":vi(t,e,c);break;case"borders":yi(t,e,d);break;case"layout":$i(t,e,p)}}const h={};return Object.keys(u).length&&(h.breakpoints=u),Object.keys(a).length&&(h.colors=a),Object.keys(l).length&&(h.typography=l),Object.keys(c).length&&(h.effects=c),Object.keys(d).length&&(h.borders=d),Object.keys(p).length&&(h.layout=p),h},ci=(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"},di=/^\{([^}]+)\}$/,pi=e=>{if("string"!=typeof e)return;const t=e.match(di);if(!t)return;const r=t[1],n=r.indexOf("."),o=n<0?r:r.slice(0,n),i=n<0?"":r.slice(n+1),s="color"===o?"colors":o;return i?`${s}.${i}`:s},ui=(e,t,r)=>{var n;const o=new Map,i=[];for(const t of e)if(t.path.length<=2)i.push(t);else{const e=t.path[1];o.has(e)||o.set(e,[]),o.get(e).push(t)}for(const e of i){const t=e.path[e.path.length-1];if(!r[t]){const n=pi(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],i={};for(const e of t){if(e===o)continue;i[e.path.slice(2).join("-")]=String(e.value)}r[e]={base:String(o.value),...Object.keys(i).length?{variants:i}:{}}}},fi={fontfamily:"fontFamily",fontsize:"fontSize",fontweight:"fontWeight",lineheight:"lineHeight",letterspacing:"letterSpacing",fontstyle:"fontStyle",texttransform:"textTransform",textdecoration:"textDecoration",textalign:"textAlign"},mi=(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&&hi(r,"fontFamily",Array.isArray(e.fontFamily)?e.fontFamily.join(", "):e.fontFamily,t),e.fontSize&&hi(r,"fontSize",Si(e.fontSize),t),void 0!==e.fontWeight&&hi(r,"fontWeight",e.fontWeight,t),void 0!==e.lineHeight&&hi(r,"lineHeight",e.lineHeight,t),e.letterSpacing&&hi(r,"letterSpacing",e.letterSpacing,t)}else{const e=gi(n,t);if(!e)continue;const o=n.path[n.path.length-1],i="fontFamily"===n.type&&Array.isArray(n.value)?n.value.join(", "):"dimension"===n.type?Si(n.value):n.value;hi(r,e,i,o)}},hi=(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},gi=(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(fi))if(r.includes(e))return t;const n=t.toLowerCase();for(const[e,t]of Object.entries(fi))if(n.includes(e))return t;return null},vi=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"shadow":{const n=xi(t.value);bi(r,"shadow",n,e);break}case"transition":{const n=t.value,o=n.timingFunction?`cubic-bezier(${n.timingFunction.join(", ")})`:"ease",i=`all ${n.duration} ${o}`;bi(r,"transitions",i,e);break}case"dimension":t.path.join(".").toLowerCase().includes("blur")&&bi(r,"blur",Si(t.value),e);break;case"number":{const n=t.path.join(".").toLowerCase();n.includes("opacity")?bi(r,"opacity",t.value,e):(n.includes("z-index")||n.includes("zindex"))&&bi(r,"zIndex",t.value,e);break}}}},bi=(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},yi=(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;wi(r,"width",Si(n.width),e),n.style&&wi(r,"style",n.style,e);break}case"strokeStyle":wi(r,"style",String(t.value),e);break;case"dimension":{const n=t.path.join(".").toLowerCase();n.includes("radius")?wi(r,"radius",Si(t.value),e):n.includes("offset")?wi(r,"offset",Si(t.value),e):n.includes("width")&&wi(r,"width",Si(t.value),e);break}}}},wi=(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},$i=(e,t,r)=>{for(const t of e){if("dimension"!==t.type)continue;const e=t.path[t.path.length-1],n=ji(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}},xi=e=>Array.isArray(e)?e.map(e=>ki(e)).join(", "):ki(e),ki=e=>{const t=[];return e.inset&&t.push("inset"),t.push(e.offsetX,e.offsetY,e.blur,e.spread,e.color),t.join(" ")},ji=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?0:e.endsWith("rem")?Math.round(16*t):t},Si=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?e:e.endsWith("px")?t:e},Ai=(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 i=Ri(e),s=t=>{try{return String(e.resolveToken(t))}catch{return t}},a=i.get("colors");if(a){const e={$type:"color"};for(const[t,r]of a){const n={};void 0!==r.base&&(n.base={$value:B(String(r.base))});for(const[e,t]of Object.entries(r.members))n[e]={$value:B(String(t))};e[t]=n}n.color=e}const l=i.get("typography");if(l){const e={};for(const[t,r]of l){const n={$type:Ci(t)};void 0!==r.base&&(n.base={$value:Oi(r.base,r.baseUnit)});for(const[e,t]of Object.entries(r.members))n[e]={$value:Oi(t,r.memberUnits[e])};e[t]=n}n.typography=e}const c=i.get("effects");if(c)for(const[e,t]of c){const{groupName:r,type:o}=Ti(e);n[r]||(n[r]={$type:o});const i=n[r];void 0!==t.base&&(i.base={$value:Fi(e,t.base,s,t.baseUnit)});for(const[r,n]of Object.entries(t.members))i[r]={$value:Fi(e,n,s,t.memberUnits[r])}}const d=i.get("borders");if(d)for(const[e,t]of d){const{groupName:r,type:o}=Ni(e);n[r]||(n[r]={$type:o});const i=n[r];void 0!==t.base&&(i.base={$value:_i(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))i[e]={$value:_i(r,t.memberUnits[e])}}const p=i.get("layout");if(p)for(const[e,t]of p){if(e.includes("--"))continue;const r=e;n[r]||(n[r]={$type:"dimension"});const o=n[r];void 0!==t.base&&(o.base={$value:zi(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))o[e]={$value:zi(r,t.memberUnits[e])}}if(null==t?void 0:t.includeRecipes){const t=(e=>{const t={},r={},n={};for(const[o,i]of Object.entries(e.subsystems))i.properties&&Object.keys(i.properties).length&&(t[o]=i.properties),i.ruleSets&&Object.keys(i.ruleSets).length&&(r[o]=i.ruleSets),i.keyframes&&Object.keys(i.keyframes).length&&(n[o]=i.keyframes);const o=Object.keys(t).length>0,i=Object.keys(r).length>0,s=Object.keys(n).length>0,a=!!e.containers&&Object.keys(e.containers).length>0;if(o||i||s||a)return{version:1,...o?{properties:t}:{},...i?{ruleSets:r}:{},...s?{keyframes:n}:{},...a?{containers:e.containers}:{}}})(e.model);t&&(n.$extensions={...null!==(r=n.$extensions)&&void 0!==r?r:{},[ri]:t})}return n},Ei=(e,t)=>void 0!==t?`${e}${t}`:e,Ri=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),i=r.slice(n+1),s=i.indexOf("."),a=s<0?i:i.slice(0,s),l=s<0?void 0:i.slice(s+1),c=e.tokens[r];if(void 0!==(null==c?void 0:c.external))continue;let d;if(void 0!==(null==c?void 0:c.struct))d=c.struct;else try{d=e.resolveToken(r)}catch{continue}const p=null==c?void 0:c.unit;let u=t.get(o);u||(u=new Map,t.set(o,u));let f=u.get(a);f||(f={members:{},memberUnits:{}},u.set(a,f)),void 0===l?(f.base=d,void 0!==p&&(f.baseUnit=p)):(f.members[l]=d,void 0!==p&&(f.memberUnits[l]=p))}return t},Ci=e=>{switch(e){case"fontFamily":return"fontFamily";case"fontWeight":return"fontWeight";case"fontSize":case"letterSpacing":return"dimension";default:return"number"}},Oi=(e,t)=>Ei(e,t),Ti=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"}}},Fi=(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):Ei(t,n),Ni=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"}}},_i=(e,t)=>Ei(e,t),zi=(e,t)=>Ei(e,t);async function Pi(r){var n,o;const{raw:i,adapter:s,outDir:a,helpers:d=[],emit:u,media:f,units:h,baseFontSize:g,guide:v,preview:b}=r,y=Wo(i,{adapter:s,media:f,units:h,baseFontSize:g}),$=zt(y.model.breakpoints,e=>Bt(e,Lt(f))),x=Dt(y.model.containers,f),k=s.bind(y.model,{media:$,containers:x,resolve:y.resolveToken});if(!k.emit)throw new Error(`Adapter "${s.name}" does not implement emit(); it cannot build to disk.`);const j=ti(u),S=k.emit(j),A=[];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"),A.push(o)};for(const[e,t]of Object.entries(S.files))E(e,t);for(const[e,t]of Object.entries(null!==(n=S.vendorHelpers)&&void 0!==n?n:{}))E(e,t);for(const e of d){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(p(t.source)))}if(v){const e=!0===v?{}:v,t=w(k.describeUsage(),Ai(y),{files:Object.keys(S.files),packageName:e.packageName,llmsFile:e.llmsFile,manifestFile:e.manifestFile});for(const[e,r]of Object.entries(t.files))E(e,r)}if(b){const e=!0===b?{}:b,t=Object.keys(S.files),r=ye({usage:k.describeUsage(),preview:null===(o=k.describePreview)||void 0===o?void 0:o.call(k,j,t),tokens:Ai(y),model:y.model},{files:t,contents:S.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:A}}const Mi="theme.config",qi=[".ts",".mjs",".js"],Li=(r=process.cwd())=>{for(const n of qi){const o=t.join(r,`${Mi}${n}`);if(e.existsSync(o))return o}};let Ii=0;async function Bi(n={}){var o,i,s;const a=null!==(o=n.cwd)&&void 0!==o?o:process.cwd(),l=n.configPath?t.resolve(a,n.configPath):Li(a);if(!l||!e.existsSync(l)){const e=n.configPath?`"${n.configPath}"`:`${Mi}.(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=${++Ii}`;return await import(t)}const{entry:n,cleanup:o}=await v(e);try{return await import(r.pathToFileURL(n).href)}finally{o()}}(l),d=null!==(s=null!==(i=c.default)&&void 0!==i?i:c.config)&&void 0!==s?s:c;if(!d||"object"!=typeof d||!Array.isArray(d.targets))throw new Error(`"${l}" must export (default) a defineConfig({ raw, targets }) object.`);return{config:d,path:l}}const Ui="@theme-registry/refract-css";function Wi(){var r;const n=t.join(d(),"package.json");return null!==(r=JSON.parse(e.readFileSync(n,"utf8")).name)&&void 0!==r?r:"@theme-registry/refract"}const Di="theme.raw",Vi=[".ts",".mts",".mjs",".js",".json"],Hi=(r=process.cwd())=>{for(const n of Vi){const o=t.join(r,`${Di}${n}`);if(e.existsSync(o))return{path:o,filename:`${Di}${n}`,ext:n}}};function Gi(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?`./${Di}`:`./${e.filename}`}";\n`,expression:"raw"}}function Yi(e,t){const{head:r,expression:n}=Gi(t);return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${Ui}";\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 Ji(e){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${Ui}";\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 Ki(r={}){var n,o,i,s;const a=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),l=null!==(o=r.variant)&&void 0!==o?o:"ts",c=null!==(i=r.packageName)&&void 0!==i?i:Wi(),d=t.join(a,`theme.config.${l}`);if(e.existsSync(d)&&!r.force)throw new Error(`theme.config.${l} already exists at "${d}". Pass --force to overwrite it.`);const p=null===r.rawTheme?void 0:null!==(s=r.rawTheme)&&void 0!==s?s:Hi(a),u=p?Yi(c,p):Ji(c);return e.writeFileSync(d,u,"utf8"),{path:d,variant:l,packageName:c,rawTheme:p}}const Xi=[["xs",-2],["sm",-1],["md",0],["lg",1],["xl",2],["2xl",3],["3xl",4],["4xl",5]],Zi={"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},Qi={complement:[180],analogous:[-30,30],"split-complement":[150,210],triadic:[120,240],tetradic:[90,180,270],pentadic:[72,144,216,288]},es=["primary","secondary","tertiary","quaternary","quinary"],ts=[["success","#2f9e44","#ffffff"],["info","#1c7ed6","#ffffff"],["warning","#e89012","#1f2733"],["danger","#e03131","#ffffff"]],rs=[50,100,200,300,400,500,600,700,800,900],ns=[8,14,22],os="system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",is="ui-monospace, 'SF Mono', Menlo, Consolas, monospace",ss={neutral:{label:"Neutral",blurb:"system type, comfortable spacing, soft corners",fontFamily:{base:os,mono:is},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:os,mono:is},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:is},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:is,mono:is},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"}},as=(e,t)=>Number(e.toFixed(t)),ls=e=>A(R(e).rgb),cs=e=>as(Math.min(1.7,Math.max(1.1,1.5*Math.pow(16/e,.22))),2),ds=e=>`${as(.36/e-.0225,3)}em`,ps=e=>{const t=1e3-10*e;let r=rs[0];for(const e of rs)Math.abs(e-t)<Math.abs(r-t)&&(r=e);return r},us=e=>{if(!(e<=1))return 2===e?"complement":3===e?"triadic":4===e?"tetradic":"pentadic"},fs=e=>Object.keys(Qi).filter(t=>Qi[t].length===e-1);function ms(e){var t,r,n,o,i,s,a,l,c;const d=null!==(t=e.mode)&&void 0!==t?t:"auto",p=ss[null!==(r=e.feel)&&void 0!==r?r:"neutral"],u=Math.min(5,Math.max(1,null!==(n=e.brandCount)&&void 0!==n?n:2)),f=null!==(o=e.baseFontSize)&&void 0!==o?o:16,m=null!==(i=e.ratio)&&void 0!==i?i:p.ratio,h=Zi[m];if(!h)throw new Error(`Unknown type ratio "${m}". Use one of: ${Object.keys(Zi).join(", ")}.`);const g=ls(e.seed),v=[{name:es[0],hex:g,rotation:0}];if("manual"===d)(null!==(s=e.extraColors)&&void 0!==s?s:[]).slice(0,es.length-1).forEach((e,t)=>{v.push({name:es[t+1],hex:ls(e),rotation:0})});else if(u>1){const t=null!==(a=e.scheme)&&void 0!==a?a:us(u),r=Qi[t];if(!r)throw new Error(`Unknown harmony scheme "${t}".`);r.slice(0,u-1).forEach((e,t)=>{v.push({name:es[t+1],hex:ls(L(g,e)),rotation:e})})}const b=null!==(l=e.contrast)&&void 0!==l?l:"AA",y=[...v.map(e=>({name:e.name,base:e.hex,text:"#ffffff"})),...!1===e.semantics?[]:ts.map(([e,t,r])=>({name:e,base:t,text:r})),...!1===e.neutral?[]:[{name:"neutral",base:"#6b7280",text:"#ffffff"}]],{palettes:w,adjustments:$}="none"===b?{palettes:y,adjustments:[]}:function(e,t){var r;const n=e.map(e=>({...e})),o=new Map(n.map(e=>[e.name,0])),i=new Map,s=()=>{var e,r;const o={};for(const e of n)o[e.name]={base:e.base,text:e.text};const i=Wo({colors:o},{adapter:ai()}),s=Yr(i,{minWcag:t,includeRecipes:!1}),a=new Map;for(const t of s.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=s();for(const[e,t]of a)i.has(e)||i.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=ls(M(t.base,1)),o.set(t.name,(null!==(r=o.get(t.name))&&void 0!==r?r:0)+1);a=s()}const l=n.map((t,r)=>{var n,s,l,c;const d=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:as(null!==(s=i.get(t.name))&&void 0!==s?s:0,2),ratioAfter:as(null!==(l=null==d?void 0:d.ratio)&&void 0!==l?l:0,2),levelAfter:null!==(c=null==d?void 0:d.level)&&void 0!==c?c:"fail",unresolved:!!d&&!d.pass}});return{palettes:n,adjustments:l}}(y,b),x={};for(const e of w)x[e.name]={base:e.base,text:e.text,steps:[...rs]};if(!1!==e.shadows){const e={};for(const t of ns)e[`a${String(t).padStart(2,"0")}`]={modifiers:[{alpha:t}]};x.shadow={base:"#18274b",variants:e}}const k=Xi.map(([e,t])=>({step:e,px:as(f*Math.pow(h,t),2)})),j={},S={};for(const{step:e,px:t}of k)"md"!==e&&(j[e]=cs(t),S[e]=ds(t));S.caps="0.06em";const A={fontFamily:{base:p.fontFamily.base,variants:{mono:p.fontFamily.mono}},fontWeight:{base:400,variants:{medium:500,semibold:600,bold:700}},fontSize:{base:f,ratio:m},lineHeight:{base:cs(f),variants:j},letterSpacing:{base:"0em",variants:S}},E={spacing:{base:4,step:4,steps:{...p.spacing}}},C={width:{base:1,variants:{thick:2}},style:{base:"solid"},radius:{base:p.radius.base,variants:{...p.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"}}},T={colors:x,typography:A,layout:E,borders:C,...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"}}},F=as(N(R(g).rgb).L,1);return{raw:T,report:{seedLightness:F,nearestStep:ps(F),brand:v.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:k.map(({step:e,px:t})=>({step:e,px:t,leading:cs(t),tracking:ds(t)})),spacing:Object.entries(p.spacing).map(([e,t])=>({step:e,px:4*t}))}}}const hs="theme.raw",gs=/^[A-Za-z_$][A-Za-z0-9_$]*$/,vs=e=>JSON.stringify(e);function bs(e,t=0){const r=" ".repeat(t),n=" ".repeat(t+1);if(null===e)return"null";if("string"==typeof e)return vs(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=>bs(e)).join(", ")}]`;if(r.length+t.length<=76)return t}return`[\n${e.map(e=>`${n}${bs(e,t+1)}`).join(",\n")}\n${r}]`}const o=Object.entries(e);if(!o.length)return"{}";return`{\n${o.map(([e,r])=>{const o=gs.test(e)?e:vs(e);return`${n}${o}: ${bs(r,t+1)}`}).join(",\n")}\n${r}}`}const ys=(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 ws(e,t){if("json"===t.format)return`${JSON.stringify(e,null,2)}\n`;const r=bs(e);return"js"===t.format?`${ys(t.seed,t.detail)}\n/** @type {import("${t.packageName}/build").RawTheme} */\nexport const raw = ${r};\n`:`${ys(t.seed,t.detail)}import type { RawTheme } from "${t.packageName}/build";\n\nexport const raw = ${r} satisfies RawTheme;\n`}function $s(e){var t,r,n,o,i,s;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!==(i=e.feel)&&void 0!==i?i:"neutral"),"none"!==e.contrast&&a.push(`WCAG ${null!==(s=e.contrast)&&void 0!==s?s:"AA"}`),a.join(" · ")}function xs(r){var n,o,i,s;const a=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),l=null!==(o=r.format)&&void 0!==o?o:"ts",c=null!==(i=r.out)&&void 0!==i?i:`${hs}.${l}`,d=t.join(a,c);if(e.existsSync(d)&&!r.force)throw new Error(`"${c}" already exists. Re-run with --force to overwrite it.`);const{raw:p,report:u}=ms(r),f=ws(p,{format:l,packageName:null!==(s=r.packageName)&&void 0!==s?s:Wi(),seed:r.seed,detail:$s(r)});return e.writeFileSync(d,f,"utf8"),{path:d,format:l,raw:p,report:u,sections:Object.keys(p)}}const ks=()=>Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,js=(e,t)=>ks()?`[${e}m${t}[0m`:t,Ss=e=>js("1",e),As=e=>js("2",e),Es=e=>js("36",e),Rs=e=>js("32",e),Cs=e=>js("33",e),Os=e=>e>0?`[${e}A`:"",Ts="[0J";function Fs(e,t=2){if(!ks())return"";const r=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!r)return"";const n=parseInt(r[1],16),[o,i,s]=[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};${i};${s}`:`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,i,s)}`;var l;return`[${a}m${" ".repeat(t)}[0m`}function Ns(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 _s(e){const t=[];for(let r=0;r<e.length;)""===e[r]&&"["===e[r+1]&&r+2<e.length?(t.push(Ns(e.slice(r,r+3))),r+=3):(t.push(Ns(e[r])),r+=1);return t}function zs(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 Ps=()=>Boolean(process.stdin.isTTY)&&"function"==typeof process.stdin.setRawMode;class Ms{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(`${Es("?")} ${Ss(e)} ${As(`(${t})`)} `)).trim()||t,o=null==r?void 0:r(n);if(!o)return n;this.write(` ${Cs("!")} ${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,i;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(Ps()){return t[null!==(i=(await this.runList(e,t,{multi:!1,cursor:r,selected:new Set}))[0])&&void 0!==i?i: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(Ps()){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 i={cursor:Math.max(0,Math.min(r.cursor,t.length-1)),selected:r.selected,done:!1,cancelled:!1},s=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=()=>{s&&this.out(Os(s)+Ts);const r=(()=>{const r=t.map((e,t)=>{var r;const n=t===i.cursor,s=n?Rs("❯"):" ",a=o?i.selected.has(t)?Rs("[✓]"):As("[ ]"):"",c=n?Ss(e.label):e.label,d=" ".repeat(Math.max(0,l-e.label.length)),p=(null!==(r=e.swatches)&&void 0!==r?r:[]).map(e=>Fs(e)).filter(Boolean).join(" ");return` ${s} ${a?`${a} `:""}${c}${d}${p?` ${p}`:""}${e.hint?` ${As(e.hint)}`:""}`});return[`${Es("?")} ${Ss(e)} ${As(a)}`,...r].join("\n")})();this.out(`${r}\n`),s=r.split("\n").length};return new Promise((r,a)=>{const l=()=>{n.removeListener("data",p),n.removeListener("end",d),n.isTTY&&n.setRawMode(!1),n.pause(),this.out("[?25h")},d=()=>{const e=o?[...i.selected].sort((e,t)=>e-t):[i.cursor];this.out(Os(s)+Ts),l(),r(e)},p=n=>{for(const e of _s(n))if(i=zs(i,e,t.length,o),i.done||i.cancelled)break;if(i.cancelled)return this.out(Os(s)+Ts),l(),void a(new Error("Cancelled."));if(i.done){const n=o?[...i.selected].sort((e,t)=>e-t):[i.cursor];this.out(Os(s)+Ts);const a=n.length?n.map(e=>t[e].label).join(", "):"none";return this.write(`${Es("?")} ${Ss(e)} ${As("›")} ${Rs(a)}`),l(),void r(n)}c()};n.setRawMode(!0),n.resume(),n.setEncoding("utf8"),this.out("[?25l"),n.on("data",p),n.on("end",d),c()})}async selectByNumber(e,t,r){for(this.write(`${Es("?")} ${Ss(e)}`),t.forEach((e,t)=>{const n=t===r?Rs("❯"):" ",o=e.hint?` ${As(`— ${e.hint}`)}`:"";this.write(` ${n} ${As(`${t+1}.`)} ${t===r?Ss(e.label):e.label}${o}`)});;){const e=(await this.question(` ${As(`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(` ${Cs("!")} Enter a number between 1 and ${t.length}.`)}}async multiselectByNumber(e,t,r){for(this.write(`${Es("?")} ${Ss(e)} ${As('(comma-separated, blank = keep, "none" = clear)')}`),t.forEach((e,t)=>{const n=r.includes(t),o=e.hint?` ${As(`— ${e.hint}`)}`:"";this.write(` ${n?Rs("◉"):As("◯")} ${As(`${t+1}.`)} ${e.label}${o}`)});;){const e=(await this.question(` ${As(`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(` ${Cs("!")} Enter numbers between 1 and ${t.length}, separated by commas.`)}}}const qs={complement:[180],analogous:[-30,30],"split-complement":[150,210],triadic:[120,240],tetradic:[90,180,270],pentadic:[72,144,216,288]},Ls=(e,t)=>{var r;return(null!==(r=qs[t])&&void 0!==r?r:[]).map(t=>A(R(L(e,t)).rgb))},Is={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"},Bs=[["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"]],Us=e=>{try{return void R(e)}catch{return`"${e}" isn't a colour refract can parse. Try a hex like #4c6ef5.`}};async function Ws(e,t={}){var r,n,o,i,s,a,l,c;const d=null!==(r=t.seed)&&void 0!==r?r:await e.text("Primary colour","#4c6ef5",Us),p=Math.round(10*N(R(d).rgb).L)/10,u=A(R(d).rgb),f=Fs(u,3);e.write(` ${f?`${f} `:""}${As(`${u} · lightness ${p}% — lands at ≈${ps(p)} on the ladder`)}`),e.write();const m=Boolean(t.manual);let h,g=2,v=[];if(m){if(v=(null!==(n=t.colors)&&void 0!==n?n:"").split(",").map(e=>e.trim()).filter(Boolean),!v.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++)v.push(await e.text(`Brand colour ${r+1}`,"#e64980",Us))}g=v.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=fs(g);h=null!==(o=t.scheme)&&void 0!==o?o:us(g),!t.scheme&&r.length>1&&(h=await e.select("Harmony scheme",r.map(e=>({value:e,label:e,hint:Is[e],swatches:[u,...Ls(u,e)]})),Math.max(0,r.indexOf(h)))),h&&g>1&&(e.write(` ${As(`→ ${h} · each member becomes its own palette with a full ladder`)}`),e.write())}const b=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!==(i=t.contrast)&&void 0!==i?i: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!==(s=t.feel)&&void 0!==s?s:await e.select("Overall feel",Object.keys(ss).map(e=>({value:e,label:ss[e].label,hint:ss[e].blurb}))),x=null!==(a=t.ratio)&&void 0!==a?a:await e.select("Type scale",Bs.map(([e,t])=>({value:e,label:e,hint:t})),Math.max(0,Bs.findIndex(([e])=>e===ss[$].ratio))),k=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:d,mode:m?"manual":"auto",brandCount:g,scheme:h,extraColors:v,...b,contrast:y,baseFontSize:w,ratio:x,feel:$,reset:k,format:j}}function Ds(e,t){const r=[],{contrast:n}=e.report;if(n.length){r.push(` ${As(`Contrast · ${n.length} pairings checked`)}`);for(const e of n){const t=e.nudge>0?`${Cs(`−${e.nudge}`)} ${Rs(`${e.ratioAfter} ${e.levelAfter}`)}`:As("unchanged"),n=e.unresolved?` ${Cs("! 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(` ${As(`${e.sections.length} subsystems · ${t} variables · 0 recipes`)}`),o&&r.push(` ${As(`${o} colour${1===o?"":"s"} darkened to clear the contrast bar`)}`),r}const Vs="theme.config.ts";function Hs(e){const t={};for(const r of e.split(",")){const[e,n]=r.split(":"),o=null==e?void 0:e.trim(),i=Number.parseFloat((null!=n?n:"").trim());o&&Number.isFinite(i)&&(t[o]=i)}return t}function Gs(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 Ys(e,t){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${Ui}";\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 Js(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 Ks(r){var n,o;const i=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),s=null!==(o=r.packageName)&&void 0!==o?o:Wi(),a=t.isAbsolute(r.input)?r.input:t.resolve(i,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 d=li(l,c),p=r.out?t.isAbsolute(r.out)?r.out:t.resolve(i,r.out):t.resolve(i,"theme.raw.ts");if(e.existsSync(p)&&!r.force)throw new Error(`${t.basename(p)} already exists at "${p}". Pass --force to overwrite it.`);let u;if(e.mkdirSync(t.dirname(p),{recursive:!0}),e.writeFileSync(p,Gs(s,d,JSON.stringify(t.basename(a))),"utf8"),!r.rawOnly){if(u=t.resolve(t.dirname(p),Vs),e.existsSync(u)&&!r.force)throw new Error(`${Vs} already exists at "${u}". Pass --force to overwrite it, or --raw-only to skip writing a config.`);const n=`./${t.basename(p).replace(/\.(ts|mts|cts|tsx)$/,"")}`;e.writeFileSync(u,Ys(s,n),"utf8")}return{inputFile:a,rawFile:p,configFile:u,sections:Object.keys(d),counts:Js(d)}}async function Xs(e={}){var r;const n=null!==(r=e.cwd)&&void 0!==r?r:process.cwd(),{config:o,path:i}=await Bi({cwd:n,configPath:e.configPath});if(!o.targets.length)throw new Error(`"${i}" has no targets to build.`);const s=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&&s.length>1)throw new Error(`--out is ambiguous across ${s.length} targets; pass --target to pick one first.`);const a=t.dirname(i),l=[];for(const r of s){const i=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),s=await Pi({raw:o.raw,adapter:r.adapter,outDir:i,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:s.outDir,files:s.files})}return{configPath:i,targets:l}}async function Zs(r={}){var n;const o=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),{config:i,path:s}=await Bi({cwd:o,configPath:r.configPath}),a=Wo(i.raw,{adapter:ai()}),l=Ai(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:s,outFile:c,groupCount:Object.keys(l).filter(e=>!e.startsWith("$")).length}}async function Qs(e={}){var t;const r=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:n,path:o}=await Bi({cwd:r,configPath:e.configPath}),i=Wo(n.raw,{adapter:ai()});return{configPath:o,result:Yr(i,{strict:e.strict,minWcag:e.minWcag,largeText:e.largeText})}}const ea=(e,t)=>{try{return String(e.resolveToken(t))}catch{return null}},ta=e=>{var t;const r=[];for(const[n,o]of Object.entries(e.model.subsystems))for(const[e,i]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(i))r.push({subsystem:n,group:e,variant:t});return r},ra=(e,t,r,n)=>{var o,i,s;return Boolean(null===(s=null===(i=null===(o=e.model.subsystems[t])||void 0===o?void 0:o.ruleSets)||void 0===i?void 0:i[r])||void 0===s?void 0:s[n])};function na(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,i=o in t.tokens,s=r?ea(e,o):null,a=i?ea(t,o):null;r&&!i?n.push({path:o,before:s,after:null,kind:"removed"}):!r&&i?n.push({path:o,before:null,after:a,kind:"added"}):s!==a&&n.push({path:o,before:s,after:a,kind:"changed"})}return n.sort((e,t)=>e.path.localeCompare(t.path))})(e,t),n=((e,t)=>{var r,n,o,i,s,a,l,c;const d=e,p=t;if(!d.renderRecipe&&!p.renderRecipe)return[];const u=new Set,f=[...ta(e),...ta(t)].filter(e=>{const t=`${e.subsystem}.${e.group}.${e.variant}`;return!u.has(t)&&(u.add(t),!0)}),m=[];for(const{subsystem:u,group:h,variant:g}of f){const f=ra(e,u,h,g),v=ra(t,u,h,g),b=null!==(i=null!==(n=null===(r=p.getClass)||void 0===r?void 0:r.call(p,u,h,g))&&void 0!==n?n:null===(o=d.getClass)||void 0===o?void 0:o.call(d,u,h,g))&&void 0!==i?i:`${u}.${h}.${g}`;f&&!v?m.push({name:b,kind:"removed"}):!f&&v?m.push({name:b,kind:"added"}):(null!==(a=null===(s=d.renderRecipe)||void 0===s?void 0:s.call(d,u,h,g))&&void 0!==a?a:"")!==(null!==(c=null===(l=p.renderRecipe)||void 0===l?void 0:l.call(p,u,h,g))&&void 0!==c?c:"")&&m.push({name:b,kind:"changed"})}return m.sort((e,t)=>e.name.localeCompare(t.name))})(e,t),o=((e,t)=>{var r,n,o,i;const s=e=>e?{ratio:e.wcagRatio,level:e.wcagLevel,pass:e.pass}:null,a=e=>new Map(e.map(e=>[e.label,e])),l=a(Yr(e).pairings),c=a(Yr(t).pairings),d=new Set([...l.keys(),...c.keys()]),p=[];for(const e of d){const t=l.get(e),a=c.get(e),d=s(t),u=s(a);if((null==d?void 0:d.ratio)===(null==u?void 0:u.ratio)&&(null==d?void 0:d.level)===(null==u?void 0:u.level)&&Boolean(t)===Boolean(a))continue;const f=(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!==(i=null==a?void 0:a.wcagLevel)&&void 0!==i?i:null);p.push({label:e,before:d,after:u,crossed:f})}return p.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 oa={fail:0,"AA-large":1,AA:2,AAA:3};let ia=0;async function sa(n){var o,i,s,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 v(n);try{const t=await import(r.pathToFileURL(e).href);l=null!==(i=null!==(o=t.default)&&void 0!==o?o:t.raw)&&void 0!==i?i:t}finally{t()}}else{const e=await import(`${r.pathToFileURL(n).href}?v=${++ia}`);l=null!==(a=null!==(s=e.default)&&void 0!==s?s: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 we("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 we("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 aa(e){var r,n,o,i,s,a,l,c;const d=null!==(r=e.cwd)&&void 0!==r?r:process.cwd(),{config:p,path:u}=await Bi({cwd:d,configPath:e.configPath}),f=t.resolve(d,e.candidatePath),m=await sa(f),h={units:p.units,baseFontSize:p.baseFontSize,media:p.media},g=p.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}}),v=g.map(({name:e,adapter:t})=>{var r;try{return Wo(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)]}}}),b=null!==(o=null!==(n=g.find(({adapter:e})=>"function"==typeof Wo(p.raw,{adapter:e,...h}).renderRecipe))&&void 0!==n?n:g[0])&&void 0!==o?o:{name:"noop",adapter:ai()},y=Wo(p.raw,{adapter:b.adapter,...h});let w={tokens:[],classes:[],contrast:[],summary:{tokensChanged:0,classesChanged:0,pairingsCrossed:0}};try{w=na(y,Wo(m,{adapter:b.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!==(i=oa[e.failBelow])&&void 0!==i?i:0;for(const r of w.contrast){const n=(null===(s=r.after)||void 0===s?void 0:s.level)&&null!==(a=oa[r.after.level])&&void 0!==a?a:0,o=(null===(l=r.before)||void 0===l?void 0:l.level)&&null!==(c=oa[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 x=v.filter(e=>!e.ok).map(e=>e.name);return x.length&&$.push(`candidate no longer builds for: ${x.join(", ")}`),{configPath:u,candidatePath:f,diff:w,targets:v,ok:0===$.length,violations:$}}const la=["claude","codex","opencode","github-copilot","cursor","generic"],ca={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"}},da="\x3c!-- refract-skills:start --\x3e",pa="\x3c!-- refract-skills:end --\x3e",ua=t.join(".refract","skills.lock"),fa=t.join(".refract","skills");function ma(e){return null!=e?e:t.join(d(),"skills")}function ha(r){const n=ma(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,i;const s=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(e),a=s?s[1]:"",l=s?e.slice(s[0].length).replace(/^\s+/,""):e,c=e=>{const t=new RegExp(`^${e}:\\s*(.*)$`,"m").exec(a);return t?t[1].trim():void 0},d=null!==(o=null!==(n=c("name"))&&void 0!==n?n:t.dirname(r).split(/[\\/]/).pop())&&void 0!==o?o:"unnamed",p="optional"===c("tier")?"optional":"core";return{name:d,description:null!==(i=c("description"))&&void 0!==i?i:"",tier:p,raw:e,body:l,sourcePath:r}}(e.readFileSync(r,"utf8"),r)).sort((e,t)=>e.name.localeCompare(t.name))}function ga(e){const t=e.map(e=>`| [${e.name}](${fa}/${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[da,"","## 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,"",pa].join("\n")}function va(e,t){const r=e.indexOf(da),n=e.indexOf(pa);if(-1!==r&&-1!==n&&n>r)return e.slice(0,r)+t+e.slice(n+pa.length);const o=e.replace(/\s+$/,"");return o?`${o}\n\n${t}\n`:`${t}\n`}function ba(r,n){e.mkdirSync(t.dirname(r),{recursive:!0}),e.writeFileSync(r,n,"utf8")}function ya(r){var n,i,s;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(i=r.home)&&void 0!==i?i:o.homedir():null!==(s=r.cwd)&&void 0!==s?s: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)}(ha(r.catalogDir),r);if(0===r.agents.length)throw new Error("Pick at least one agent target.");const p=new Set;if(r.agents.some(e=>"agents-md"===ca[e].kind))for(const e of c){const r=t.join(l,fa,`${e.name}.md`);ba(r,e.body),p.add(r)}for(const n of r.agents){const r=ca[n];if("claude"===r.kind)for(const e of c){const n=t.join(l,r.routerFile,e.name,"SKILL.md");ba(n,e.raw),p.add(n)}else{const n=t.join(l,r.routerFile);ba(n,va(e.existsSync(n)?e.readFileSync(n,"utf8"):"",ga(c))),p.add(n)}}const{name:u,version:f}=function(){var r,n;const o=JSON.parse(e.readFileSync(t.join(d(),"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:u,refractVersion:f,scope:a,agents:[...r.agents],skills:c.map(e=>e.name)},h=t.join(l,ua);return ba(h,`${JSON.stringify(m,null,2)}\n`),{scope:a,agents:[...r.agents],skills:c.map(e=>e.name),files:[...p].sort(),manifestPath:h}}function wa(r={}){var n,i,s;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(i=r.home)&&void 0!==i?i:o.homedir():null!==(s=r.cwd)&&void 0!==s?s:process.cwd(),c=t.join(l,ua);if(!e.existsSync(c))throw new Error(`No skills manifest at "${c}". Run \`refract skills install\` first.`);const d=JSON.parse(e.readFileSync(c,"utf8"));return ya({agents:d.agents,scope:a,skills:d.skills,cwd:r.cwd,home:r.home,catalogDir:r.catalogDir})}const $a="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 xa(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 ka(e){var t;const{values:r}=s.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 Ms(!r.yes&&void 0);try{n.write(),n.write(` ${Ss("refract")} ${As("· raw-theme scaffold")}`),n.write();const e=xs({...await Ws(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 Ds(e,function(e){try{const t=Wo(e,{adapter:ai()});return Object.keys(t.tokens).length}catch{return 0}}(e.raw)))n.write(t);return n.write(),n.write(` ${Ss(null!==(t=e.path.split(/[\\/]/).pop())&&void 0!==t?t:"")} written`),n.write(),n.write(` ${As("Next — wire up a build:")} ${Ss("refract init")}`),n.write(),0}catch(e){return xa("create",e)}finally{n.close()}}const ja=new Set(["AAA","AA","AA-large"]);async function Sa(e){const[t,...r]=e;if("list"===t)try{for(const e of ha())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 xa("skills list",e)}const{values:n}=s.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=wa({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[...la];const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=t.filter(e=>!la.includes(e));if(r.length>0)throw new Error(`unknown agent(s) ${r.map(e=>`"${e}"`).join(", ")}. Known: ${la.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=i.createInterface({input:process.stdin,output:process.stdout});try{process.stdout.write("Install refract skills for which agent(s)?\n"),la.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()?[...la]:t.split(",").map(e=>la[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 s=ya({agents:e,scope:r,skills:n.only?n.only.split(",").map(e=>e.trim()).filter(Boolean):void 0,includeOptional:t});process.stdout.write(`Installed ${s.skills.length} skill(s) for ${s.agents.join(", ")} (${s.scope}):\n`);for(const e of s.files)process.stdout.write(` ${e}\n`);return process.stdout.write(` manifest → ${s.manifestPath}\n`),0}return process.stderr.write(`refract skills: unknown subcommand "${t}". Use install | list | update.\n`),1}catch(e){return xa("skills",e)}}async function Aa(e){const[t,...r]=e;switch(t){case"create":return ka(r);case"init":return async function(e){const{values:t}=s.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=Ki({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 xa("init",e)}}(r);case"import":return async function(e){const{values:t,positionals:r}=s.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=Ks({input:n,out:t.out,rawOnly:Boolean(t["raw-only"]),force:Boolean(t.force),breakpointGroup:t["breakpoint-group"],breakpoints:t.breakpoints?Hs(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 xa("import",e)}}(r);case"build":return async function(e){const{values:t}=s.parseArgs({args:e,options:{config:{type:"string"},target:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await Xs({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 xa("build",e)}}(r);case"tokens":return async function(e){const{values:t}=s.parseArgs({args:e,options:{config:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await Zs({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 xa("tokens",e)}}(r);case"diff":return async function(e){var t,r,n,o;const{values:i,positionals:a}=s.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=i["fail-below"];if(void 0!==c&&!ja.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 aa({configPath:i.config,candidatePath:l,maxClassChanges:void 0!==i["max-class-changes"]?Number(i["max-class-changes"]):void 0,maxTokenChanges:void 0!==i["max-token-changes"]?Number(i["max-token-changes"]):void 0,failBelow:c}),{diff:s}=e;process.stdout.write(`Diffed ${e.candidatePath}\n vs ${e.configPath}\n`),process.stdout.write(` ${s.summary.tokensChanged} token(s), ${s.summary.classesChanged} class(es), ${s.summary.pairingsCrossed} pairing(s) crossed a threshold\n`);for(const e of s.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`)}s.tokens.length>20&&process.stdout.write(` … +${s.tokens.length-20} more token(s)\n`);for(const e of s.classes)process.stdout.write(` class ${e.kind.padEnd(7)} ${e.name}\n`);for(const e of s.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 xa("diff",e)}}(r);case"audit":return async function(e){const{values:t}=s.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&&!ja.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 Qs({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 xa("audit",e)}}(r);case"skills":return Sa(r);case void 0:case"help":case"--help":case"-h":return process.stdout.write($a),0;default:return process.stderr.write(`refract: unknown command "${t}".\n\n${$a}`),1}}"undefined"!=typeof require&&"undefined"!=typeof module&&require.main===module&&Aa(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=la,exports.CSS_ADAPTER_PACKAGE=Ui,exports.DEFAULT_RAW_BASENAME=hs,exports.FEEL_PRESETS=ss,exports.Prompter=Ms,exports.SCHEME_HINTS=Is,exports.TYPE_SCALE_CHOICES=Bs,exports.VENDOR_HELPERS=l,exports.applyKey=zs,exports.bold=Ss,exports.buildGuide=w,exports.buildPreview=ye,exports.collectModes=de,exports.compileTsConfigGraph=v,exports.createReportLines=Ds,exports.cyan=Es,exports.decodeKey=Ns,exports.decodeKeys=_s,exports.defaultSchemeFor=us,exports.defineConfig=e=>e,exports.deriveLeading=cs,exports.deriveTracking=ds,exports.diffThemes=na,exports.dim=As,exports.emitTheme=Pi,exports.findConfigFile=Li,exports.findPackageRoot=d,exports.findRawTheme=Hi,exports.findVendorHelper=c,exports.green=Rs,exports.listSkills=ha,exports.loadConfig=Bi,exports.main=Aa,exports.nearestLadderStep=ps,exports.parseBreakpointsFlag=Hs,exports.promptCreateAnswers=Ws,exports.rawThemeImport=Gi,exports.readOwnPackageName=Wi,exports.readVendorSource=p,exports.renderRawTheme=ws,exports.resolveEmitPlan=ti,exports.runAudit=Qs,exports.runBuild=Xs,exports.runCreate=xs,exports.runDiff=aa,exports.runImport=Ks,exports.runInit=Ki,exports.runSkillsInstall=ya,exports.runSkillsUpdate=wa,exports.runTokens=Zs,exports.scaffoldConfig=Ji,exports.scaffoldConfigForRaw=Yi,exports.scaffoldImportConfig=Ys,exports.scaffoldRaw=Gs,exports.scaffoldTheme=ms,exports.schemesFor=fs,exports.skillsCatalogDir=ma,exports.swatch=Fs,exports.transpileToEsm=m,exports.yellow=Cs;
|
|
1
|
+
"use strict";var e=require("node:fs"),t=require("node:path"),r=require("node:url"),n=require("node:readline"),o=require("node:os"),i=require("node:readline/promises"),s=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),d=(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}},p=r=>{const n=t.join(d(),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 u(){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 u();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)$/,""),v=async r=>{const n=await u(),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:[]},i=n.createCompilerHost(o),s=n.createProgram([r],o,i),a=new Map,l=e=>!e.isDeclarationFile&&!e.fileName.includes("/node_modules/")&&/\.(ts|tsx|mts|cts)$/.test(e.fileName);for(const e of s.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 s=t.resolve(r.fileName),l=e.factory,c=e=>{const r=((e,t)=>{var r;if(!e.startsWith("."))return;const s=null===(r=n.resolveModuleName(e,t,o,i).resolvedModule)||void 0===r?void 0:r.resolvedFileName;return s?a.get(g(s)):void 0})(e,s);return r?l.createStringLiteral(`./${t.basename(r)}`):void 0},d=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,d,e)};return n.visitNode(r,d)},d=[],p=(t,r)=>{const n=a.get(g(t));n&&(e.writeFileSync(n,r,"utf8"),d.push(n))},f=()=>{for(const t of d)e.rmSync(t,{force:!0})};try{s.emit(void 0,p,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}},b=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:i}=e;if(i.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=i.slice(0,60);for(const t of e)o.push(`| \`${b(`${t.subsystem}.${t.group}.${t.variant}`)}\` | \`${b(t.name)}\` |`);if(i.length>e.length){const t=i.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",i=void 0===r.manifestFile?"manifest.json":r.manifestFile,s={[o]:y(e,r,i)};if(i){const n={schema:1,format:e.format,files:r.files,packageName:r.packageName,recipes:e.recipes,tokens:t};s[i]=`${JSON.stringify(n,null,2)}\n`}return{files:s}}const $=new Set([3,6]),x=(e,t,r)=>Math.min(r,Math.max(t,e)),k=e=>x(e,0,255),j=e=>Math.round(1e3*x(e,0,1))/1e3,S=e=>{const t=e.replace(/^\s*#|\s*$/g,"");if(!$.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)]},A=e=>{if(3!==e.length)throw new Error(`Expected RGB tuple of length 3, received ${e.length}`);return`#${e.map(e=>{const t=k(Math.round(e)).toString(16);return 1===t.length?`0${t}`:t}).join("")}`},E=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/i,R=e=>{const t=e.trim(),r=E.exec(t);return r?{rgb:[Number(r[1]),Number(r[2]),Number(r[3])],a:void 0===r[4]?1:j(Number(r[4]))}:{rgb:S(t),a:1}},C=(e,t=1)=>{const r=j(t),[n,o,i]=e,s=k(Math.round(n)),a=k(Math.round(o)),l=k(Math.round(i));return r>=1?`rgb(${s}, ${a}, ${l})`:`rgba(${s}, ${a}, ${l}, ${r})`},O=180/Math.PI,T=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),F=e=>e>=.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,N=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,i=.0883024619*e+.2817188376*t+.6299787005*r,s=Math.cbrt(n),a=Math.cbrt(o),l=Math.cbrt(i);return{L:.2104542553*s+.793617785*a-.0040720468*l,a:1.9779984951*s-2.428592205*a+.4505937099*l,b:.0259040371*s+.7827717662*a-.808675766*l}})(T(t/255),T(r/255),T(n/255)),i=Math.sqrt(o.a*o.a+o.b*o.b);let s=Math.atan2(o.b,o.a)*O;return s<0&&(s+=360),{L:100*o.L,C:i,h:s}},_=e=>{const t=x(e.L,0,100)/100,r=e.h/O,n=Math.cos(r),o=Math.sin(r),i=e=>((e,t,r)=>{const n=e+.3963377774*t+.2158037573*r,o=e-.1055613458*t-.0638541728*r,i=e-.0894841775*t-1.291485548*r,s=n*n*n,a=o*o*o,l=i*i*i;return[4.0767416621*s-3.3077115913*a+.2309699292*l,-1.2684380046*s+2.6097574011*a-.3413193965*l,-.0041960863*s-.7034186147*a+1.707614701*l]})(t,e*n,e*o),s=e=>e.every(e=>e>=-1e-6&&e<=1.000001);let a=i(e.C);if(!s(a)){let t=0,r=e.C;for(let e=0;e<24;e++){const e=(t+r)/2;s(i(e))?t=e:r=e}a=i(t)}return[255*F(x(a[0],0,1)),255*F(x(a[1],0,1)),255*F(x(a[2],0,1))]},z=(e,t)=>{const{rgb:r,a:n}=R(e);return C(_(t(N(r))),n)},P=(e,t)=>z(e,e=>({...e,L:x(e.L+t,0,100)})),M=(e,t)=>z(e,e=>({...e,L:x(e.L-t,0,100)})),q=(e,t)=>z(e,e=>({...e,L:x(t,0,100)})),L=(e,t)=>z(e,e=>({...e,h:((e.h+t)%360+360)%360})),I=(e,t)=>z(e,e=>({L:void 0===t.l?e.L:x(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})),B=e=>{const{rgb:t,a:r}=R(e),n=A(t);if(r>=1)return n;return`${n}${k(Math.round(255*r)).toString(16).padStart(2,"0")}`},U=(e,t)=>{const{rgb:r}=R(e);return C(r,(e=>x(e,0,100))(t)/100)},W=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),D=e=>W(String(e).replace(/[;{}<>]/g,"").trim()),V=e=>e.replace(/<\/(?=[a-zA-Z])/g,"<\\/");function H(e,t,r,n){if(!e||"object"!=typeof e||Array.isArray(e))return;const o=e,i="string"==typeof o.$type?o.$type:r;if("$value"in o)n.push({path:t,type:i,value:o.$value});else for(const[e,r]of Object.entries(o))e.startsWith("$")||H(r,[...t,e],i,n)}const G=[{id:"palette",title:"Colour",eyebrow:"Palette",note:"Every rung is a token you can reference. A ladder is an absolute lightness scale and the seed is <em>not</em> snapped onto it — the marked rung is where the family's <code>base</code> lands, not a rung it equals. Click any identifier to copy it."},{id:"type",title:"Type scale",eyebrow:"Typography"},{id:"space",title:"Spacing and size",eyebrow:"Space",note:"There is no separate <code>padding</code> token — spacing <em>is</em> the padding scale, so it is shown both as a measure and as an applied inset."},{id:"shape",title:"Borders, radius and elevation",eyebrow:"Shape & depth"},{id:"motion",title:"Transitions",eyebrow:"Motion"},{id:"layout",title:"Breakpoints",eyebrow:"Layout",note:"These drive the Width control at the top — pick one to reflow the whole specimen at that viewport."},{id:"other",title:"Other tokens",eyebrow:"Additional"}],Y={color:"palette",typography:"type",spacing:"space",gutters:"space",sizes:"space",aspectRatio:"space",radius:"shape",borderWidth:"shape",borderStyle:"shape",outlineOffset:"shape",shadow:"shape",blur:"shape",opacity:"shape",zIndex:"shape",transition:"motion",breakpoint:"layout"},J="Precision is a design decision",K=(e,t)=>`<button class="rfp-id" type="button">${W(e)}</button>`+(t?`<span class="rfp-var">${W(t)}</span>`:""),X=e=>e.path.join("."),Z=(e,t,r,n=!1)=>`<div class="rfp-row${n?" rfp-centred":""}"><div>${e}</div>${t}<div class="rfp-rowval">${W(r)}</div></div>`,Q=e=>/^\d+$/.test(e);function ee(e){if(/^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(e.trim()))try{return N(S(e.trim())).L}catch{return}}function te(e){const t=e.trim();if(!/^#[0-9a-f]{6}$/i.test(t))return;const r=parseInt(t.slice(1),16),n=e=>{const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)};return.2126*n(r>>16&255)+.7152*n(r>>8&255)+.0722*n(255&r)}function re(e,t){const r=te(e),n=te(t);if(void 0!==r&&void 0!==n)return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)}function ne(e,t){const r=void 0===e?void 0:ee(e);if(void 0===r||0===t.length)return;const n=e=>(1e3-Number(e))/10;return t.reduce((e,[t])=>Math.abs(n(t)-r)<Math.abs(n(e)-r)?t:e,t[0][0])}function oe(e){const t=/^(-?[\d.]+)\s*(px|rem|em)?$/.exec(String(e).trim());if(!t)return;const r=Number(t[1]);return Number.isFinite(r)?"rem"===t[2]||"em"===t[2]?16*r:r:void 0}function ie(e,t,r){var n,o,i;const s=function(e){var t,r,n,o;const i=new Map,s=null!==(r=null===(t=e.subsystems.colors)||void 0===t?void 0:t.properties)&&void 0!==r?r:{},a=(e,t)=>{var r,n;if(!t)return;const o=void 0!==t.ref||void 0!==t.fn||(null!==(n=null===(r=t.modifiers)||void 0===r?void 0:r.length)&&void 0!==n?n:0)>0;i.set(e,o?"gen":"src")};for(const[e,t]of Object.entries(s)){a(`colors.${e}`,t.base);for(const[r,o]of Object.entries(null!==(n=t.extras)&&void 0!==n?n:{}))a(`colors.${e}.${r}`,o);for(const[r,n]of Object.entries(null!==(o=t.variants)&&void 0!==o?o:{}))a(`colors.${e}.${r}`,n.base)}return i}(t),a=e=>{const t=s.get(e);return t?`<span class="rfp-tag rfp-${t}">${t}</span>`:""},l=new Map;for(const t of e){const e=null!==(n=t.path[1])&&void 0!==n?n:"color",r=t.path.slice(2).join(".")||"base",o=l.get(e);o?o.push([r,String(t.value)]):l.set(e,[[r,String(t.value)]])}const c=[],d=[];let p=0,f=0;for(const[e,t]of l){const n=t.filter(([e])=>Q(e)).sort((e,t)=>Number(e[0])-Number(t[0])),s=null===(o=t.find(([e])=>"base"===e))||void 0===o?void 0:o[1],l=null===(i=t.find(([e])=>"text"===e))||void 0===i?void 0:i[1],u=`colors.${e}`;if(s&&l){const e=re(s,l);void 0!==e&&(p+=1,e>=4.5&&(f+=1))}if(n.length>=3){const o=ne(s,n),i=n.map(([t,r])=>{const n=void 0!==o&&t===o;return'<div class="rfp-rung"'+(n?" data-lands":"")+` title="colors.${W(e)}.${W(t)} · ${W(r)}${n?" · base lands here":""}">`+`<div class="rfp-sw" style="background:${D(r)}"></div>`+`<div class="rfp-rung-foot">${W(t)}</div></div>`}).join(""),l=t.filter(([e])=>!Q(e)&&"base"!==e).map(([e,t])=>se(`${u}.${e}`,e,t,a(`${u}.${e}`),r)).join("");c.push(`<section class="rfp-card"><div class="rfp-pal-top"><div class="rfp-pal-base" style="background:${D(null!=s?s:n[Math.floor(n.length/2)][1])}"></div><h3 class="rfp-pal-name">${W(e)}<small>${s?`base ${W(s)}`:""}${o?` · lands ≈ ${W(o)}`:""} · ${n.length} rungs</small>`+K(u,null==r?void 0:r(u))+"</h3></div>"+`<div class="rfp-row-label">Lightness ladder ${a(`${u}.${n[0][0]}`)||'<span class="rfp-tag rfp-gen">gen</span>'}</div>`+`<div class="rfp-rungs">${i}</div>`+(l?`<div class="rfp-row-label">Declared members</div><div class="rfp-chips">${l}</div>`:"")+"</section>");continue}for(const[n,o]of t){if("text"===n)continue;const t="base"===n,i=t?u:`${u}.${n}`;d.push(se(i,t?e:n,o,a(i),r,t?l:void 0))}}let u=c.join("");return d.length&&(u+=`<section class="rfp-card"><div class="rfp-card-head"><span class="rfp-card-name">Semantic</span><span class="rfp-card-sub">contrast scored only where a <code>text</code> pairing is declared</span></div><div class="rfp-chips">${d.join("")}</div></section>`),{html:u,pairings:{total:p,passing:f}}}function se(e,t,r,n,o,i){return'<div class="rfp-chip"><div class="rfp-sw rfp-chip-sw"'+(i?` data-bg="${W(r)}" data-fg="${W(i)}"`:"")+` style="background:${D(r)}${i?`;color:${D(i)}`:""}">`+(i?'<span class="rfp-ratio"></span>':"")+`</div><div class="rfp-cap"><div class="rfp-lbl">${W(t)}${n}</div>`+`<div class="rfp-val-sm">${W(r)}${i?` on ${W(i)}`:""}</div>`+K(e,null==o?void 0:o(e))+"</div></div>"}function ae(e,t){var r;const n=new Map;for(const t of e){const e=null!==(r=t.path[1])&&void 0!==r?r:"typography",o=n.get(e);o?o.push(t):n.set(e,[t])}const o=[];for(const[e,r]of n){const n=r.map(r=>{const n=X(r),o=K(n,null==t?void 0:t(n)),i=String(r.value);return Z(o,"fontSize"===e?`<div class="rfp-specimen" style="font-size:${D(i)}">${J}</div>`:"fontFamily"===e?`<div class="rfp-specimen" style="font-family:${D(i)}">${J}</div>`:"fontWeight"===e?`<div class="rfp-specimen" style="font-weight:${D(i)}">${J}</div>`:"lineHeight"===e?`<div class="rfp-leading" style="line-height:${D(i)}">Leading is the quiet half of a type scale. Two lines are the minimum needed to judge it, so this specimen wraps.</div>`:"letterSpacing"===e?`<div class="rfp-specimen" style="font-size:22px;letter-spacing:${D(i)}">${J}</div>`:`<div class="rfp-specimen">${W(i)}</div>`,i)}).join("");o.push(fe(`typography.${e}`,`${r.length} token(s)`,`<div class="rfp-rows">${n}</div>`))}return o.join("")}function le(e,t){const r=[];for(const n of["spacing","gutters","sizes","aspectRatio"]){const o=e.get(n);if(!(null==o?void 0:o.length))continue;if("aspectRatio"===n){const e=o.map(e=>{const r=X(e),n=String(e.value);return ue(`<div class="rfp-obj" style="width:84px;aspect-ratio:${D(n)};height:auto;border-radius:4px"></div>`,K(r,null==t?void 0:t(r)),n)}).join("");r.push(fe(`layout.${n}`,`${o.length} token(s)`,`<div class="rfp-tiles">${e}</div>`));continue}const i=Math.max(...o.map(e=>{var t;return null!==(t=oe(e.value))&&void 0!==t?t:0}),1),s=o.map(e=>{const r=X(e),o=oe(e.value),s=void 0===o?"100%":`${Math.max(1,o/i*100)}%`;return Z(K(r,null==t?void 0:t(r)),`<div class="rfp-bar${"spacing"===n?"":" rfp-ghost"}" style="width:${s}"></div>`,String(e.value),!0)}).join("");if(r.push(fe(`layout.${n}`,`${o.length} steps · measure`,`<div class="rfp-rows">${s}</div>`)),"spacing"===n){const e=o.filter(e=>{var t;return(null!==(t=oe(e.value))&&void 0!==t?t:0)>0}).slice(0,6);if(e.length){const o=e.map(e=>{const r=X(e);return`<div class="rfp-tile"><div class="rfp-inset" style="padding:${D(e.value)}"><div class="rfp-inset-core">${W(String(e.value))}</div></div><div>${K(r,null==t?void 0:t(r))}</div></div>`}).join("");r.push(fe(`layout.${n}`,"applied as padding — hatching is the inset, solid is the content box",`<div class="rfp-tiles">${o}</div>`));const i=e.slice(0,4).map(e=>Z(K(X(e),null==t?void 0:t(X(e))),`<div class="rfp-gap" style="gap:${D(e.value)}"><i></i><i></i><i></i><i></i></div>`,String(e.value),!0)).join("");r.push(fe(`layout.${n}`,"applied as gap",`<div class="rfp-rows">${i}</div>`))}}}return r.join("")}function ce(e,t){const r=[],n=(n,o,i)=>{const s=e.get(n);if(!(null==s?void 0:s.length))return;const a=s.map(e=>ue(o(e),K(X(e),null==t?void 0:t(X(e))),String(e.value))).join("");r.push(fe(n,null!=i?i:`${s.length} token(s)`,`<div class="rfp-tiles">${a}</div>`))};return n("radius",e=>`<div class="rfp-obj" style="border-radius:${D(e.value)}"></div>`),n("borderWidth",e=>`<div class="rfp-obj rfp-outlined" style="border:${D(e.value)} solid currentColor;border-radius:8px"></div>`),n("borderStyle",e=>`<div class="rfp-obj rfp-outlined" style="border:3px ${D(e.value)} currentColor;border-radius:8px"></div>`),n("outlineOffset",e=>`<div class="rfp-obj rfp-outlined" style="border-radius:8px;outline:2px solid currentColor;outline-offset:${D(e.value)}"></div>`),n("shadow",e=>`<div class="rfp-obj rfp-raised" style="border-radius:8px;box-shadow:${D(e.value)}"></div>`),n("blur",e=>`<div class="rfp-obj rfp-accent" style="border-radius:8px;filter:blur(${D(e.value)})"></div>`),n("opacity",e=>`<div class="rfp-obj rfp-accent" style="border-radius:8px;opacity:${D(e.value)}"></div>`),n("zIndex",e=>`<span class="rfp-numeral">${W(String(e.value))}</span>`),r.join("")}function de(e,t){const r=e.map(e=>{const r=X(e),n=String(e.value);return Z(K(r,null==t?void 0:t(r)),`<div class="rfp-track"><i class="rfp-dot" style="transition:transform ${D(n)}"></i></div>`,n,!0)}).join("");return fe("effects.transitions",`${e.length} token(s)`,`<div class="rfp-rows">${r}</div>`,'<button class="rfp-play" type="button" id="rfp-play">Play</button>')}function pe(e,t,r){const n=t.map(e=>Z(K(X(e),null==r?void 0:r(X(e))),`<div class="rfp-specimen">${W((e=>e.path.slice(1).join(".")||e.path[0])(e))}</div>`,String(e.value))).join("");return fe(e,`${t.length} token(s)`,`<div class="rfp-rows">${n}</div>`)}const fe=(e,t,r,n="")=>`<section class="rfp-plate"><div class="rfp-plate-head"><span class="rfp-plate-name">${W(e)}</span><span class="rfp-plate-sub">${t}</span>${n}</div>${r}</section>`,ue=(e,t,r)=>`<div class="rfp-tile"><div class="rfp-stage">${e}</div><div>${t}<span class="rfp-hex">${W(r)}</span></div></div>`;function me(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 he=e=>{if(e&&void 0!==e.value&&null!==e.value&&"object"!=typeof e.value)return String(e.value)};function ge(e,t,r){const n=me(e);if(!n.length)return"";const{changes:o,skipped:i}=function(e){var t;const r=[];let n=0;const o=(e,t,o)=>{var i,s,a,l,c,d,p;for(const f of null!==(i=o.modes)&&void 0!==i?i:[])if(f.mode)for(const[i,u]of Object.entries(null!==(s=f.overrides)&&void 0!==s?s:{})){const s=he(u),m=[f.target,"base"===i?void 0:i].filter(Boolean).join("."),h=`${e}.${t}${m?`.${m}`:""}`;if(void 0===s){n+=1;continue}const g="base"!==i||f.target?null!==(l=he(null===(a=o.extras)||void 0===a?void 0:a[i]))&&void 0!==l?l:he(null===(p=null===(c=o.variants)||void 0===c?void 0:c[null!==(d=f.target)&&void 0!==d?d:""])||void 0===p?void 0:p.base):he(o.base);r.push({path:h,mode:f.mode,from:g,to:s})}};for(const[r,n]of Object.entries(e.subsystems))for(const[e,i]of Object.entries(null!==(t=n.properties)&&void 0!==t?t:{}))o(r,e,i);return{changes:r,skipped:n}}(e);if(!o.length&&!i)return"";const s=o.map(e=>`<tr><td>${K(e.path,null==r?void 0:r(e.path))}</td><td>${ve(e.from)}</td><td class="rfp-arrow">→</td><td>${ve(e.to)}</td></tr>`).join(""),a=i?`<p class="rfp-note-sm">${i} further override(s) resolve through a derivation, so they carry no single literal to show here.</p>`:"";return`<section class="rfp-section" id="rfp-modes"><div class="rfp-section-head"><div><div class="rfp-eyebrow">Appearance</div><h2>What changes in ${W(n.join(" / "))}</h2></div><span class="rfp-tag">${n.length} mode(s) declared</span></div><p class="rfp-note">Flipping the toggle shows you the result; this shows the cause. Only these tokens carry an override — everything else is inherited.</p>`+fe(`mode: ${n.join(", ")}`,`${o.length} of ${t} tokens overridden`,`<div class="rfp-scroll"><table class="rfp-diff"><thead><tr><th>Token</th><th>Base</th><th></th><th>Override</th></tr></thead><tbody>${s}</tbody></table></div>${a}`)+"</section>"}const ve=e=>{if(void 0===e)return'<span class="rfp-hex">—</span>';return'<span class="rfp-swatch-cell">'+(/^(#|rgb|hsl|oklch|color\()/i.test(e.trim())?`<i class="rfp-chip" style="background:${D(e)}"></i>`:"")+`<span class="rfp-hex">${W(e)}</span></span>`};function be(e,t,r){var n,o,i;const s=null===(n=null==t?void 0:t.markup)||void 0===n?void 0:n.call(t,e);if(!s)return;const a=null!==(o=s.tag)&&void 0!==o?o:function(e){const t=e.group.toLowerCase();return t.includes("button")||t.includes("btn")?"button":t.includes("input")||t.includes("field")?"input":t.includes("link")||t.includes("anchor")?"a":t.includes("badge")||t.includes("chip")||t.includes("tag")||t.includes("label")?"span":"div"}(e),l={...s.attrs};r&&(l.class=`${null!==(i=l.class)&&void 0!==i?i:""} ${r}`.trim());const c=Object.entries(l).map(([e,t])=>` ${W(e)}="${W(t)}"`).join("");return"input"===a?`<input${c} value="${W(e.variant)}" readonly aria-label="${W(e.variant)}">`:`<${a}${c}>${W(e.variant)}</${a}>`}function ye(e,t){if(!(null==t?void 0:t.composition))return"";for(const r of e){const e=t.composition(r);if(!e||e.length<2)continue;const n=e.map((e,t)=>(t?'<span class="rfp-plus">+</span>':"")+`<span class="rfp-cls"><b>${W(e.className)}</b>`+`<span>${e.from?` · from ${W(e.from)}`:" · own delta"}</span></span>`).join("");return fe("Composition",`why <code>${W(r.variant)}</code> carries ${e.length} classes`,`<div class="rfp-compose">${n}</div><p class="rfp-note-sm">Order matters — the delta lands last, so it wins on equal specificity.</p>`)}return""}const we='\n.rfp{--rfp-paper:#f5f6f8;--rfp-card:#fff;--rfp-sunk:#f0f2f5;--rfp-ink:#14171c;--rfp-ink-2:#4d5563;\n --rfp-ink-3:#79818f;--rfp-line:#e3e6ea;--rfp-line-2:#d0d5dd;--rfp-focus:#3b4ea8;\n --rfp-spec:#97a1b0;--rfp-spec-2:#c2c9d4;--rfp-hatch:#dfe3e9;\n --rfp-mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;\n --rfp-ui:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;\n font-family:var(--rfp-ui);font-size:14px;line-height:1.55;color:var(--rfp-ink);\n background:var(--rfp-paper);-webkit-font-smoothing:antialiased;\n width:100%;min-height:100vh;box-sizing:border-box}\n/* Full-bleed geometry. :where() gives these ZERO specificity, so a theme\'s own globals rules still\n win - the chrome resets the UA gutter without ever outranking the theme it is displaying.\n color-scheme is pinned to light: this sheet does NOT follow the OS (see below). */\n:where(html){color-scheme:light}\n:where(body){margin:0}\n.rfp *{box-sizing:border-box}\n.rfp *:focus-visible{outline:2px solid var(--rfp-focus);outline-offset:2px;border-radius:3px}\n/* ── Masthead: the theme wearing its own first palette ── */\n.rfp-masthead{padding:52px 40px 36px}\n.rfp-kicker{font-family:var(--rfp-mono);font-size:11px;letter-spacing:.16em;text-transform:uppercase;opacity:.75;margin:0 0 12px}\n.rfp-masthead h1{margin:0;font-size:38px;font-weight:680;letter-spacing:-.028em;text-wrap:balance}\n.rfp-lede{margin:12px 0 0;max-width:66ch;opacity:.88;font-size:15px}\n.rfp-metrics{margin-top:28px;display:flex;gap:34px;flex-wrap:wrap}\n.rfp-metric b{display:block;font-size:26px;font-weight:700;line-height:1.1;font-variant-numeric:tabular-nums}\n.rfp-metric span{font-size:12px;opacity:.72;font-family:var(--rfp-mono)}\n/* ── Shell ── */\n.rfp-shell{display:grid;grid-template-columns:204px minmax(0,1fr);gap:44px;padding:0 40px 96px;align-items:start}\n.rfp-rail{position:sticky;top:0;padding:28px 0;max-height:100vh;overflow-y:auto}\n.rfp-brand{font-family:var(--rfp-mono);font-size:10.5px;letter-spacing:.14em;text-transform:uppercase;\n color:var(--rfp-ink-3);padding-bottom:12px;margin-bottom:12px;border-bottom:1px solid var(--rfp-line)}\n.rfp-nav{display:flex;flex-direction:column;gap:1px}\n.rfp-nav a{display:flex;justify-content:space-between;align-items:baseline;gap:10px;padding:5px 8px;\n border-radius:5px;color:var(--rfp-ink-2);text-decoration:none;font-size:13px}\n.rfp-nav a:hover{background:var(--rfp-card);color:var(--rfp-ink)}\n.rfp-nav a[aria-current="true"]{background:var(--rfp-ink);color:var(--rfp-paper)}\n.rfp-nav .rfp-n{font-family:var(--rfp-mono);font-size:11px;font-variant-numeric:tabular-nums;color:var(--rfp-ink-3)}\n.rfp-nav a[aria-current="true"] .rfp-n{color:var(--rfp-paper);opacity:.6}\n.rfp-main{padding-top:28px;min-width:0}\n.rfp-controls{display:flex;flex-wrap:wrap;gap:22px;padding:14px 0 18px;position:sticky;top:0;background:var(--rfp-paper);z-index:5}\n.rfp-ctl{display:flex;align-items:center;gap:8px}\n.rfp-ctl-label{font-family:var(--rfp-mono);font-size:10.5px;letter-spacing:.12em;text-transform:uppercase;color:var(--rfp-ink-3)}\n.rfp-seg{display:flex;border:1px solid var(--rfp-line-2);border-radius:7px;overflow:hidden;background:var(--rfp-card)}\n.rfp-seg button{font:inherit;font-family:var(--rfp-mono);font-size:11.5px;padding:4px 11px;border:0;\n border-left:1px solid var(--rfp-line-2);background:transparent;color:var(--rfp-ink-2);cursor:pointer}\n.rfp-seg button:first-child{border-left:0}\n.rfp-seg button:hover{background:var(--rfp-sunk);color:var(--rfp-ink)}\n.rfp-seg button[aria-pressed="true"]{background:var(--rfp-ink);color:var(--rfp-card)}\n/* ── Sections + cards ── */\n.rfp-section{padding-top:44px;scroll-margin-top:64px}\n.rfp-section-head{display:flex;align-items:baseline;gap:12px;flex-wrap:wrap}\n.rfp-section-head h2{margin:0;font-size:21px;letter-spacing:-.018em;font-weight:640}\n.rfp-count{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-2);background:var(--rfp-card);\n border:1px solid var(--rfp-line);border-radius:999px;padding:2px 10px;white-space:nowrap}\n.rfp-note{margin:8px 0 20px;color:var(--rfp-ink-2);font-size:13.5px;max-width:72ch}\n.rfp-note-sm{color:var(--rfp-ink-3);font-size:12.5px;margin:10px 0 0;max-width:64ch}\n.rfp-card{background:var(--rfp-card);border:1px solid var(--rfp-line);border-radius:14px;padding:18px 20px;margin-top:14px}\n.rfp-card-head{display:flex;align-items:baseline;gap:10px;margin-bottom:14px;flex-wrap:wrap}\n.rfp-card-name{font-family:var(--rfp-mono);font-size:12.5px;font-weight:600}\n.rfp-card-sub{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3)}\n.rfp-row-label{font-family:var(--rfp-mono);font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;\n color:var(--rfp-ink-3);margin:16px 0 9px;display:flex;align-items:center;gap:8px}\n.rfp-divider{display:flex;align-items:center;gap:14px;margin:52px 0 4px}\n.rfp-divider span{font-family:var(--rfp-mono);font-size:10.5px;letter-spacing:.18em;text-transform:uppercase;\n color:var(--rfp-ink-3);white-space:nowrap}\n.rfp-divider::before,.rfp-divider::after{content:"";height:1px;background:var(--rfp-line);flex:1}\n/* ── Index cover ── */\n.rfp-index{display:grid;grid-template-columns:repeat(auto-fill,minmax(272px,1fr));gap:14px}\n.rfp-idx{position:relative;background:var(--rfp-card);border:1px solid var(--rfp-line);border-radius:14px;\n padding:18px 18px 15px 22px;overflow:hidden}\n.rfp-idx .rfp-accent{position:absolute;inset:0 auto 0 0;width:5px}\n.rfp-idx .rfp-no{font-family:var(--rfp-mono);font-size:10.5px;font-weight:700;letter-spacing:.12em;color:var(--rfp-ink-3)}\n.rfp-idx h3{margin:6px 0 2px;font-size:18px;letter-spacing:-.015em;font-weight:620}\n.rfp-idx h3 span{font-family:var(--rfp-mono);font-size:11px;font-weight:500;color:var(--rfp-ink-3)}\n.rfp-idx p{margin:7px 0 0;font-size:12.5px;color:var(--rfp-ink-2)}\n/* ── Identifiers ── */\n.rfp-id{font-family:var(--rfp-mono);font-size:11.5px;color:var(--rfp-ink-2);background:none;border:0;\n padding:1px 4px;margin-left:-4px;border-radius:3px;cursor:copy;text-align:left;display:inline-block}\n.rfp-id:hover{background:var(--rfp-sunk);color:var(--rfp-ink)}\n.rfp-id.rfp-copied{background:var(--rfp-ink);color:var(--rfp-card)}\n.rfp-var{font-family:var(--rfp-mono);font-size:10.5px;color:var(--rfp-ink-3);display:block;margin-top:1px}\n.rfp-hex{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);font-variant-numeric:tabular-nums;display:block;margin-top:1px}\n/* ── Provenance tags ── */\n.rfp-tag{font-family:var(--rfp-mono);font-size:9px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;\n padding:1px 5px;border-radius:4px}\n.rfp-src{background:color-mix(in srgb,var(--rfp-focus) 12%,transparent);color:var(--rfp-focus)}\n.rfp-gen{background:var(--rfp-sunk);color:var(--rfp-ink-3);border:1px solid var(--rfp-line)}\n/* ── Palette ── */\n.rfp-pal-top{display:flex;align-items:center;gap:16px}\n.rfp-pal-base{width:84px;height:84px;border-radius:12px;flex:none;box-shadow:inset 0 0 0 1px rgba(0,0,0,.1)}\n.rfp-pal-name{margin:0;font-size:18px;font-weight:680;letter-spacing:-.015em}\n.rfp-pal-name small{display:block;font-family:var(--rfp-mono);font-weight:400;color:var(--rfp-ink-3);font-size:11.5px;margin-top:4px}\n.rfp-rungs{display:flex;border-radius:9px;overflow:hidden;border:1px solid var(--rfp-line)}\n.rfp-rung{flex:1 1 0;min-width:0}\n.rfp-rung .rfp-sw{height:54px}\n.rfp-rung-foot{padding:6px 2px 7px;text-align:center;background:var(--rfp-sunk);border-top:1px solid var(--rfp-line);\n font-family:var(--rfp-mono);font-size:10px;font-variant-numeric:tabular-nums;color:var(--rfp-ink-2)}\n.rfp-rung[data-lands] .rfp-rung-foot{color:var(--rfp-ink);font-weight:700}\n.rfp-rung[data-lands] .rfp-rung-foot::before{content:"◆ "}\n.rfp-chips{display:grid;grid-template-columns:repeat(auto-fill,minmax(132px,1fr));gap:10px}\n.rfp-chip{border:1px solid var(--rfp-line);border-radius:10px;overflow:hidden;background:var(--rfp-card)}\n.rfp-chip-sw{height:50px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.05);display:flex;align-items:flex-end;padding:6px}\n.rfp-cap{padding:8px 9px 9px}\n.rfp-lbl{font-size:12px;font-weight:600;display:flex;align-items:center;gap:6px;justify-content:space-between}\n.rfp-val-sm{font-family:var(--rfp-mono);font-size:10.5px;color:var(--rfp-ink-3);margin-top:3px;font-variant-numeric:tabular-nums}\n.rfp-ratio{font-family:var(--rfp-mono);font-size:10px;padding:1px 6px;border-radius:4px;border:1px solid currentColor}\n/* ── Rows ── */\n.rfp-rows{display:flex;flex-direction:column}\n.rfp-row{display:grid;grid-template-columns:200px minmax(0,1fr) 104px;gap:20px;align-items:baseline;\n padding:11px 0;border-top:1px solid var(--rfp-line)}\n.rfp-row:first-child{border-top:0}\n.rfp-row.rfp-centred{align-items:center}\n.rfp-rowval{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);font-variant-numeric:tabular-nums;text-align:right;overflow-wrap:anywhere}\n.rfp-specimen{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.015em}\n.rfp-leading{font-size:13px;color:var(--rfp-ink-2);max-width:52ch}\n.rfp-bar{height:13px;background:var(--rfp-spec);border-radius:3px;max-width:100%}\n.rfp-bar.rfp-ghost{background:var(--rfp-spec-2)}\n.rfp-gap{display:flex;border:1px dashed var(--rfp-line-2);border-radius:8px;padding:10px;background:var(--rfp-sunk)}\n.rfp-gap>i{flex:1 1 0;height:30px;background:var(--rfp-spec-2);border-radius:3px}\n.rfp-inset{border:1px solid var(--rfp-line-2);border-radius:10px;\n background:repeating-linear-gradient(-45deg,var(--rfp-hatch) 0 4px,transparent 4px 8px)}\n.rfp-inset-core{background:var(--rfp-spec);color:var(--rfp-card);border-radius:4px;font-family:var(--rfp-mono);\n font-size:10.5px;font-weight:700;text-align:center;padding:9px 4px}\n/* ── Tiles ── */\n.rfp-tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(146px,1fr));gap:12px}\n.rfp-tile{border:1px solid var(--rfp-line);border-radius:12px;padding:14px;background:var(--rfp-card)}\n.rfp-stage{height:76px;display:grid;place-items:center;background:var(--rfp-sunk);border-radius:8px;\n margin-bottom:11px;color:var(--rfp-spec)}\n.rfp-obj{width:60px;height:60px;background:var(--rfp-spec)}\n.rfp-obj.rfp-outlined{background:transparent}\n.rfp-obj.rfp-raised{background:var(--rfp-card)}\n.rfp-obj.rfp-accent{background:var(--rfp-spec)}\n.rfp-numeral{font-family:var(--rfp-mono);font-size:19px;font-variant-numeric:tabular-nums;color:var(--rfp-ink-2)}\n.rfp-track{height:34px;border-radius:8px;background:var(--rfp-sunk);border:1px solid var(--rfp-line);position:relative;overflow:hidden}\n.rfp-dot{position:absolute;top:6px;left:6px;width:22px;height:22px;border-radius:5px;background:var(--rfp-spec)}\n.rfp-play{font:inherit;font-family:var(--rfp-mono);font-size:11.5px;padding:3px 10px;border-radius:5px;\n border:1px solid var(--rfp-line-2);background:var(--rfp-sunk);color:var(--rfp-ink);cursor:pointer;margin-left:auto}\n/* ── Tables ── */\n.rfp-scroll{overflow-x:auto}\n.rfp-diff,.rfp-matrix{border-collapse:collapse;width:100%}\n.rfp-diff th,.rfp-matrix th{text-align:left;font-family:var(--rfp-mono);font-size:10.5px;letter-spacing:.1em;\n text-transform:uppercase;color:var(--rfp-ink-3);font-weight:500;padding:0 12px 9px 0;white-space:nowrap}\n.rfp-diff td{padding:9px 12px 9px 0;border-top:1px solid var(--rfp-line);vertical-align:middle}\n.rfp-matrix{min-width:560px}\n.rfp-matrix th{text-align:center;padding:0 8px 10px}\n.rfp-matrix th:first-child{text-align:left}\n.rfp-matrix td{padding:13px 8px;border-top:1px solid var(--rfp-line);text-align:center}\n.rfp-matrix td:first-child{text-align:left;width:208px}\n.rfp-none{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);opacity:.55}\n.rfp-swatch-cell{display:flex;align-items:center;gap:8px}\n.rfp-chip-sm{width:18px;height:18px;border-radius:5px;border:1px solid var(--rfp-line-2);flex:none}\n.rfp-arrow{color:var(--rfp-ink-3);font-family:var(--rfp-mono)}\n/* ── Recipes + prose ── */\n.rfp-recipes{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px}\n.rfp-recipe{border:1px solid var(--rfp-line);border-radius:12px;overflow:hidden;background:var(--rfp-card)}\n.rfp-recipe-stage{min-height:92px;display:grid;place-items:center;padding:18px;background:var(--rfp-sunk)}\n.rfp-recipe-foot{padding:9px 12px;border-top:1px solid var(--rfp-line)}\n.rfp-addr{font-family:var(--rfp-mono);font-size:11px;color:var(--rfp-ink-3);display:block}\n.rfp-compose{display:flex;flex-wrap:wrap;align-items:center;gap:8px}\n.rfp-cls{font-family:var(--rfp-mono);font-size:11.5px;padding:3px 9px;border-radius:6px;\n border:1px solid var(--rfp-line);background:var(--rfp-sunk)}\n.rfp-cls b{font-weight:600;color:var(--rfp-ink)}\n.rfp-cls span{color:var(--rfp-ink-3)}\n.rfp-plus{color:var(--rfp-ink-3);font-family:var(--rfp-mono)}\n.rfp-prose{border:1px solid var(--rfp-line);border-radius:14px;padding:26px 28px;background:var(--rfp-card);overflow:hidden}\n.rfp-notice{display:grid;grid-template-columns:auto minmax(0,1fr);gap:12px;padding:14px 16px;\n border:1px solid var(--rfp-line-2);border-radius:12px;background:var(--rfp-card);margin-top:16px}\n.rfp-notice-mark{font-family:var(--rfp-mono);font-size:10px;letter-spacing:.1em;text-transform:uppercase;\n padding:2px 7px;border-radius:5px;background:var(--rfp-ink);color:var(--rfp-card);white-space:nowrap;height:fit-content}\n.rfp-notice p{margin:0;color:var(--rfp-ink-2);font-size:13px;max-width:68ch}\n.rfp-notice p+p{margin-top:6px}\n.rfp-notice strong{color:var(--rfp-ink)}\n.rfp-frame{margin:0 auto}\n@media (prefers-reduced-motion:reduce){.rfp *{transition:none!important;animation:none!important}}\n@media (max-width:900px){\n .rfp-shell{grid-template-columns:minmax(0,1fr);gap:0;padding:0 20px 72px}\n .rfp-masthead{padding:36px 20px 28px}\n .rfp-rail{position:static;max-height:none;padding:20px 0 0}\n .rfp-nav{flex-direction:row;overflow-x:auto;gap:4px;padding-bottom:4px}\n .rfp-nav a{white-space:nowrap}\n .rfp-row{grid-template-columns:130px minmax(0,1fr)}\n .rfp-rowval{grid-column:1/-1;text-align:left}\n}\n'.trim(),$e='\n(function(){\n var root=document.documentElement;\n function srgb(c){c/=255;return c<=0.03928?c/12.92:Math.pow((c+0.055)/1.055,2.4);}\n function lum(hex){var m=/^#([0-9a-f]{6})$/i.exec(hex.trim());if(!m)return null;var n=parseInt(m[1],16);\n return 0.2126*srgb((n>>16)&255)+0.7152*srgb((n>>8)&255)+0.0722*srgb(n&255);}\n // Contrast is computed here rather than baked in, so it can never drift from the swatch beside it.\n document.querySelectorAll(".rfp-pair-swatch[data-fg]").forEach(function(el){\n var out=el.querySelector(".rfp-pair-ratio");if(!out)return;\n var a=lum(el.getAttribute("data-bg")||""),b=lum(el.getAttribute("data-fg")||"");\n if(a===null||b===null){out.remove();return;}\n var r=(Math.max(a,b)+0.05)/(Math.min(a,b)+0.05);\n out.textContent=r.toFixed(2)+":1 · "+(r>=7?"AAA":r>=4.5?"AA":r>=3?"AA large":"fail");\n });\n function bind(sel,onPick){\n var btns=[].slice.call(document.querySelectorAll(sel));\n btns.forEach(function(b){b.addEventListener("click",function(){\n btns.forEach(function(o){o.setAttribute("aria-pressed",String(o===b));});\n onPick(b.getAttribute("data-value"));});});\n }\n bind("[data-rfp-mode]",function(v){\n var attr=root.getAttribute("data-rfp-mode-attr");if(!attr)return;\n if(v)root.setAttribute(attr,v);else root.removeAttribute(attr);});\n bind("[data-rfp-width]",function(v){\n var frame=document.getElementById("rfp-frame");if(frame)frame.style.maxWidth=v?v+"px":"";});\n var play=document.getElementById("rfp-play"),running=false;\n if(play)play.addEventListener("click",function(){\n running=!running;play.textContent=running?"Reset":"Play";\n document.querySelectorAll(".rfp-dot").forEach(function(d){\n d.style.transform=running?"translateX("+(d.parentElement.clientWidth-34)+"px)":"translateX(0)";});});\n document.addEventListener("click",function(e){\n var btn=e.target.closest?e.target.closest(".rfp-id"):null;if(!btn)return;\n var text=btn.textContent.trim();\n var done=function(){var prev=btn.textContent;btn.classList.add("rfp-copied");btn.textContent="copied";\n setTimeout(function(){btn.classList.remove("rfp-copied");btn.textContent=prev;},900);};\n if(navigator.clipboard){navigator.clipboard.writeText(text).then(done,done);}else{done();}});\n var links=[].slice.call(document.querySelectorAll(".rfp-nav a"));\n if(window.IntersectionObserver){\n var io=new IntersectionObserver(function(es){es.forEach(function(en){if(!en.isIntersecting)return;\n links.forEach(function(a){a.setAttribute("aria-current",String(a.getAttribute("href")==="#"+en.target.id));});});},\n {rootMargin:"-10% 0px -80% 0px"});\n document.querySelectorAll(".rfp-section").forEach(function(s){io.observe(s);});\n }\n})();\n'.trim();function xe(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="./${W(e)}">`:`<style data-rfp-source="${W(e)}">\n${V(n)}\n</style>`}).join("\n")}function ke(e,t){var r,n,o,i,s,a,l,c,d,p,f,u,m,h;const{usage:g,preview:v,tokens:b,model:y}=e,w=null!==(r=t.file)&&void 0!==r?r:"preview.html",$=null===(n=t.inline)||void 0===n||n,x=new Set(t.files),k=(null!==(o=null==v?void 0:v.stylesheets)&&void 0!==o?o:[]).filter(e=>x.has(e)),j=k.length>0,S=null==v?void 0:v.tokenName,A=[];H(b,[],void 0,A);const E=function(e){var t;const r=new Map;for(const n of e){const e=null!==(t=n.path[0])&&void 0!==t?t:"tokens",o=r.get(e);o?o.push(n):r.set(e,[n])}return r}(A),R=new Map,C=new Map;let O={total:0,passing:0};for(const[e,t]of E){const r=null!==(i=Y[e])&&void 0!==i?i:"other";C.set(r,(null!==(s=C.get(r))&&void 0!==s?s:0)+t.length)}for(const e of G){const t=[...E.entries()].filter(([t])=>{var r;return(null!==(r=Y[t])&&void 0!==r?r:"other")===e.id});if(!t.length)continue;let r="";if("palette"===e.id){const e=ie(t.flatMap(([,e])=>e),y,S);r=e.html,O=e.pairings}else r="type"===e.id?ae(t.flatMap(([,e])=>e),S):"space"===e.id?le(new Map(t),S):"shape"===e.id?ce(new Map(t),S):"motion"===e.id?de(t.flatMap(([,e])=>e),S):t.map(([e,t])=>pe(e,t,S)).join("");r&&R.set(e.id,r)}const T=ge(y,A.length,S),F=function(e,t){var r,n;const o=null===(r=e.subsystems.globals)||void 0===r?void 0:r.ruleSets;if(!o||!t)return"";const i=Object.keys(null!==(n=o.elements)&&void 0!==n?n:{});if(!i.length)return"";const s=e=>i.some(t=>t===e||t.startsWith(`${e}.`)||t.startsWith(`${e}:`)),a=[];return s("h1")&&a.push("<h1>Shipping a theme</h1>"),a.push("<p>A theme compiles once and lowers to every format you target — the same source produces CSS custom properties, Sass partials, a JSON document, or styled-components modules"+(s("a")?' <a href="#rfp-recipes">without re-authoring a single value</a>':"")+".</p>"),s("h2")&&a.push("<h2>Why bare elements matter</h2>"),a.push("<p>Content you don't control — a CMS body field, rendered markdown, a third-party embed — arrives without your class names. Theming the elements themselves is what keeps it consistent.</p>"),s("ul")&&a.push("<ul><li>Headings inherit the type scale and its derived leading</li><li>Links pick up the brand colour and its underline treatment</li><li>Variants emit only the delta from their base rule</li></ul>"),s("blockquote")&&a.push("<blockquote>Structural devices should encode something true about the content, not decorate it.</blockquote>"),s("hr")&&a.push("<hr>"),s("h3")&&a.push("<h3>Variants are structural deltas</h3>"),'<section class="rfp-section" id="rfp-globals"><div class="rfp-section-head"><div><div class="rfp-eyebrow">Base elements</div><h2>Unclassed markup</h2></div><span class="rfp-tag">globals.elements</span></div><p class="rfp-note">These style bare elements with no class involved, so plain HTML from a CMS or a markdown pipeline already looks right. Nothing else in this document renders without a class.</p>'+fe("globals.elements",`${i.length} selector(s) · ${W(i.join(", "))}`,`<div class="rfp-prose">${a.join("")}</div>`)+"</section>"}(y,j),N=[];j||N.push(null!==(a=null==v?void 0:v.unavailable)&&void 0!==a?a:`This theme was built with the ${g.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==v?void 0:v.notes)&&void 0!==l?l:[])N.push(e);const _=[];for(const e of G)R.has(e.id)&&_.push(`<a href="#rfp-${e.id}">${W(e.eyebrow)}<span class="rfp-n">${null!==(c=C.get(e.id))&&void 0!==c?c:0}</span></a>`);T&&_.push('<a href="#rfp-modes">Appearance</a>'),F&&_.push('<a href="#rfp-globals">Base elements</a>'),_.push(`<a href="#rfp-recipes">Components<span class="rfp-n">${g.recipes.length}</span></a>`);const z=null!==(d=t.title)&&void 0!==d?d:`${g.format} theme`,P=t.files.reduce((e,r)=>{var n,o,i;return e+(null!==(i=null===(o=null===(n=t.contents)||void 0===n?void 0:n[r])||void 0===o?void 0:o.length)&&void 0!==i?i:0)},0),M=Object.keys(y.subsystems).length,q=Object.keys(null!==(u=null===(f=null===(p=y.subsystems.globals)||void 0===p?void 0:p.ruleSets)||void 0===f?void 0:f.elements)&&void 0!==u?u:{}).length,L=[{value:String(A.length),label:"tokens"},{value:String(M),label:"subsystems"},{value:`${g.recipes.length}${q?` + ${q}`:""}`,label:q?"recipes + elements":"recipes"},O.total?{value:`${O.passing}/${O.total}`,label:"WCAG AA+ pairings"}:void 0,P?{value:(I=P,I<1024?`${I} B`:`${(I/1024).toFixed(1)} KB`),label:null!==(m=t.files[0])&&void 0!==m?m:"output"}:void 0].filter(e=>void 0!==e);var I;const B=null==v?void 0:v.modeAttribute,U=me(y),J=null!==(h=y.breakpoints)&&void 0!==h?h:{},K=[];if(B&&U.length){const e=['<button type="button" data-rfp-mode data-value="" aria-pressed="true">auto</button>'].concat(U.map(e=>`<button type="button" data-rfp-mode data-value="${W(e)}" aria-pressed="false">${W(e)}</button>`)).join("");K.push(`<div class="rfp-ctl"><span class="rfp-ctl-label">Appearance</span><div class="rfp-seg" role="group" aria-label="Appearance mode">${e}</div></div>`)}const X=Object.entries(J);if(X.length){const e=['<button type="button" data-rfp-width data-value="" aria-pressed="true">full</button>'].concat(X.map(([e,t])=>`<button type="button" data-rfp-width data-value="${W(String(t))}" aria-pressed="false">${W(e)}</button>`)).join("");K.push(`<div class="rfp-ctl"><span class="rfp-ctl-label">Width</span><div class="rfp-seg" role="group" aria-label="Viewport width">${e}</div></div>`)}const Z=G.filter(e=>R.has(e.id)).map(e=>{var t;return`<section class="rfp-section" id="rfp-${e.id}"><div class="rfp-section-head"><h2>${e.title}</h2><span class="rfp-count">${null!==(t=C.get(e.id))&&void 0!==t?t:0} token(s)</span></div>`+(e.note?`<p class="rfp-note">${e.note}</p>`:"")+R.get(e.id)+"</section>"}).join(""),Q=['<meta charset="utf-8">','<meta name="viewport" content="width=device-width,initial-scale=1">',`<title>${W(z)}</title>`,xe(k,t.contents,$),(null==v?void 0:v.statePinCss)&&j?`<style data-rfp-state-pins>\n${V(v.statePinCss)}\n</style>`:"",`<style>\n${we}\n</style>`].filter(Boolean).join("\n"),te=function(e){var t;const r=e=>"color"===e.type&&/^#[0-9a-f]{6}$/i.test(String(e.value).trim()),n=null!==(t=e.find(e=>r(e)&&"base"===e.path[e.path.length-1]))&&void 0!==t?t:e.find(r);if(!n)return;const o=String(n.value).trim(),i=ee(o);return{bg:o,fg:void 0!==i&&i>62?"#14171c":"#ffffff"}}(A),re=te?` style="background:${D(te.bg)};color:${D(te.fg)}"`:' style="background:var(--rfp-ink);color:var(--rfp-card)"',ne=function(e,t,r){const n=G.filter(t=>e.has(t.id));if(n.length<2)return"";const o=n.map((e,n)=>{var o;const i=String(n+1).padStart(2,"0"),s=null!==(o=t.get(e.id))&&void 0!==o?o:0;return`<a class="rfp-idx" href="#rfp-${e.id}" style="text-decoration:none;color:inherit"><span class="rfp-accent" style="background:${r?D(r):"var(--rfp-spec)"}"></span><div class="rfp-no">${i} · ${W(e.eyebrow.toUpperCase())}</div><h3>${e.title} <span>${s} token(s)</span></h3>`+(e.note?`<p>${e.note}</p>`:"")+"</a>"}).join("");return`<section class="rfp-section" id="rfp-index"><div class="rfp-section-head"><h2>Index</h2><span class="rfp-count">${n.length} sections</span></div><p class="rfp-note">A section appears only when the theme has tokens of that kind, so this list is the shape of the theme rather than a fixed table of contents.</p><div class="rfp-index">${o}</div></section>`}(R,C,null==te?void 0:te.bg),oe=`<div class="rfp"><header class="rfp-masthead"${re}><p class="rfp-kicker">Theme specimen · ${W(g.format)} · ${W(t.plan.type)}${j?"":" · tokens only"}</p><h1>${W(z)}</h1><div class="rfp-metrics">`+L.map(e=>`<div class="rfp-metric"><b>${W(e.value)}</b><span>${W(e.label)}</span></div>`).join("")+'</div></header><div class="rfp-shell"><aside class="rfp-rail"><div class="rfp-brand">refract preview</div>'+`<nav class="rfp-nav">${_.join("")}</nav></aside><main class="rfp-main">`+(K.length?`<div class="rfp-controls">${K.join("")}</div>`:"")+N.map(e=>`<p class="rfp-note">${W(e)}</p>`).join("")+'<div class="rfp-frame" id="rfp-frame">'+ne+Z+T+F+'<section class="rfp-section" id="rfp-recipes"><div class="rfp-section-head"><div>'+`<div class="rfp-eyebrow">Components</div><h2>Recipes${j?" and their states":""}</h2></div>`+`<span class="rfp-tag">${j?"rendered live":"names only"}</span></div>`+function(e,t,r){var n,o;if(0===e.recipes.length)return'<div class="rfp-notice"><span class="rfp-notice-mark">Empty</span><div><p><strong>No recipes yet — this theme is tokens only.</strong> Tokens are values; recipes are the rule-sets that turn them into styled components. Add a <code>recipes</code> block to a subsystem in your raw theme and rebuild — they\'ll render here.</p></div></div>';const i=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:`${r.subsystem}.${r.group}`,s=i.get(e);s?s.push(r):i.set(e,[r])}const s=[];for(const[e,n]of i){const o=r?[...new Set(n.flatMap(e=>{var r,n;return null!==(n=null===(r=null==t?void 0:t.states)||void 0===r?void 0:r.call(t,e))&&void 0!==n?n:[]}))].filter(e=>{var r;return null===(r=null==t?void 0:t.statePinClass)||void 0===r?void 0:r.call(t,e)}):[];if(o.length&&(null==t?void 0:t.markup)){const r=["base",...o].map(e=>`<th>${W(e)}</th>`).join(""),i=n.map(e=>{var r,n;const i=null!==(n=null===(r=t.states)||void 0===r?void 0:r.call(t,e))&&void 0!==n?n:[],s=["base",...o].map(r=>{var n,o;if("base"!==r&&!i.includes(r))return'<td class="rfp-none">—</td>';const s="base"===r||null===(n=t.statePinClass)||void 0===n?void 0:n.call(t,r);return`<td>${null!==(o=be(e,t,s))&&void 0!==o?o:""}</td>`}).join("");return`<tr><td><span class="rfp-addr">${W(`${e.subsystem}.${e.group}.${e.variant}`)}</span><button class="rfp-id" type="button">${W(e.name)}</button></td>${s}</tr>`}).join("");s.push(fe(e,`${n.length} variant(s) × ${o.length} state(s)`,`<div class="rfp-scroll"><table class="rfp-matrix"><thead><tr><th>Variant</th>${r}</tr></thead><tbody>${i}</tbody></table></div>`)),s.push(ye(n,t));continue}const i=n.map(e=>{const n=r?be(e,t):void 0;return'<div class="rfp-recipe">'+(n?`<div class="rfp-recipe-stage">${n}</div>`:"")+'<div class="rfp-recipe-foot"><span class="rfp-addr">'+W(`${e.subsystem}.${e.group}.${e.variant}`)+`</span><button class="rfp-id" type="button">${W(e.name)}</button></div></div>`}).join("");s.push(fe(e,`${n.length} variant(s)`,`<div class="rfp-recipes">${i}</div>`)),s.push(ye(n,t))}return s.join("")}(g,v,j)+"</section></div></main></div></div>"+`<script>\n${$e}\n<\/script>`,se=`<!doctype html>\n<html lang="en"${B?` data-rfp-mode-attr="${W(B)}"`:""}>\n<head>\n${Q}\n</head>\n<body>\n${oe}\n</body>\n</html>\n`;return{files:{[w]:se}}}class je extends Error{constructor(e,t,r){super(t),this.name="RefractError",this.code=e,r&&(this.failures=r),Object.setPrototypeOf(this,je.prototype)}}const Se=e=>"string"==typeof e||"number"==typeof e,Ae=e=>Array.isArray(e),Ee=e=>({value:e}),Re=(e,t)=>{if(!t)return Ee(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},Ce=new Set(["mode","target","base","derive"]),Oe=(e,t,r)=>{const n={},o=e.derive,i=e.base;if(o){if(void 0===o.ref)throw new je("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=Re(Se(i)?i:void 0,o)}else Se(i)?n.base=Ee(i):Ae(i)&&(n.base={struct:i});for(const[t,r]of Object.entries(e))Ce.has(t)||Se(r)&&(n[t]=Ee(r));return n},Te=(e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||Se(o)&&(r[n]=Ee(o));return r},Fe=new Set(["base","derive"]),Ne=new Set(["base","responsive","variants","modes","external"]),_e=new Set(["breakpoint","query","state","orientation","ref","modifiers","mode","variant","target","derive","ratio","step","steps"]),ze=(e,t="property")=>{var r;const n={base:void 0!==e.external?{value:`var(${e.external})`,external:e.external}:(o=e.base,Ae(o)?{struct:o}:Ee(o))};var o;const i=Te(e,Ne);if(Object.keys(i).length&&(n.extras=i),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(Se(n.base)?e=Re(n.base,o):Ae(n.base)?e={struct:n.base}:void 0!==(null==o?void 0:o.ref)&&(e=Re(void 0,o)),!e)continue;const i=Te(n,Fe);t[r]=Object.keys(i).length?{base:e,extras:i}:{base:e}}Object.keys(t).length&&(n.variants=t)}const s=e.modes;if(s&&s.length){const e=[];for(const r of s){const n=r.mode,o=Oe(r,t,n);if(!Object.keys(o).length)continue;const i={mode:n,overrides:o};"string"==typeof r.target&&(i.target=r.target),e.push(i)}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)||(Se(o)?r[n]=Ee(o):Ae(o)&&(r[n]={struct:o}));return r})(t,_e),o=t.derive;return o&&n.base&&void 0!==n.base.value&&(n.base=Re(n.base.value,o)),Object.keys(n).length&&(r.overrides=n),r});n.responsive=t}return n},Pe=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})}),Me=(e,t)=>{const r=Pe(e);return r.kind="recipe",t.length&&(r.references=t),r},qe=new Set(["colors","typography","layout","effects","borders"]),Le=e=>!!e&&Object.keys(e).length>0,Ie=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]=ze(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}),Le(e.ruleSetGroups)&&(r.ruleSets=e.ruleSetGroups),Le(e.keyframes)&&(r.keyframes=e.keyframes),Object.keys(r).length?r:void 0},Be=e=>{var t,r,n,o;const i={};for(const[s,a]of Object.entries(e.subsystems))for(const[e,l]of Object.entries(null!==(t=a.properties)&&void 0!==t?t:{})){const t=`${s}.${e}`;i[t]=l.base;for(const[e,o]of Object.entries(null!==(r=l.variants)&&void 0!==r?r:{})){i[`${t}.${e}`]=o.base;for(const[r,s]of Object.entries(null!==(n=o.extras)&&void 0!==n?n:{}))i[`${t}.${e}.${r}`]=s}for(const[e,r]of Object.entries(null!==(o=l.extras)&&void 0!==o?o:{}))i[`${t}.${e}`]=r}return i},Ue=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"]),We=/^-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?$/i,De=/^(-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?)([a-z%]+)$/i,Ve=e=>{if("number"==typeof e)return{value:e};const t=e.trim();if(We.test(t))return{value:Number(t)};const r=De.exec(t);if(r){const t=r[2].toLowerCase();if(Ue.has(t))return{value:Number(r[1]),unit:t};throw new je("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}},He={"typography.lineHeight":"none","typography.letterSpacing":"em"},Ge=(e,t)=>{var r,n,o,i;const s=e.slice(0,e.indexOf("."));return null!==(i=null!==(o=null!==(n=null!==(r=null==t?void 0:t[e])&&void 0!==r?r:He[e])&&void 0!==n?n:null==t?void 0:t[s])&&void 0!==o?o:null==t?void 0:t.default)&&void 0!==i?i:"px"},Ye=(e,t)=>Number((e/t).toFixed(4)),Je=(e,t,r)=>"none"===t?{value:e}:"rem"===t?{value:Ye(e,r),unit:"rem"}:{value:e,unit:t},Ke=(e,t,r)=>{if("number"==typeof e){const{value:n,unit:o}=Je(e,t,r);return void 0===o?e:{value:n,unit:o}}return e},Xe={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"}},Ze=(e,t)=>{let r=!1;const n={};for(const[o,i]of Object.entries(e)){const e=t(i);e!==i&&(r=!0),n[o]=e}return r?n:e},Qe=(e,t,r)=>{const n=t(e.base),o=e.variants?((e,t)=>{let r=!1;const n={};for(const[o,i]of Object.entries(e)){const e=t(i.base),s=i.extras?Ze(i.extras,t):void 0;e===i.base&&s===i.extras||(r=!0),n[o]=s?{base:e,extras:s}:{base:e}}return r?n:e})(e.variants,t):void 0,i=r&&e.extras?Ze(e.extras,t):e.extras,s=e.modes?((e,t)=>{let r=!1;const n=e.map(e=>{if(!e.overrides)return e;const n=Ze(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=Ze(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&&i===e.extras&&s===e.modes&&a===e.responsive)return e;const l={...e,base:n};return void 0!==o&&(l.variants=o),void 0!==i&&(l.extras=i),void 0!==s&&(l.modes=s),void 0!==a&&(l.responsive=a),l},et=(e,t,r,n)=>{const o="shadow"===t?e=>{if(!e.struct)return e;const t=e.struct;let o=!1;const i=t.map(e=>{const t=((e,t,r)=>{const n={...e};let o=!1;for(const i of["offsetX","offsetY","blur","spread"]){const s=e[i];if(void 0===s)continue;const a=Ke(s,t,r);a!==s&&(n[i]=a,o=!0)}return o?n:e})(e,r,n);return t!==e&&(o=!0),t});return o?{...e,struct:i}: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:i}=Je(n,t,r);return void 0===i?e:{...e,value:o,unit:i}}if("string"==typeof n){const o=Ve(n);if("raw"in o)return e;if(void 0!==o.unit)return{...e,value:o.value,unit:o.unit};const{value:i,unit:s}=Je(o.value,t,r);return void 0===s?{...e,value:i}:{...e,value:i,unit:s}}return e})(e,r,n);return Qe(e,o,!1)},tt=(e,t={})=>{var r;const n=null!==(r=t.baseFontSize)&&void 0!==r?r:16;let o=!1;const i={};for(const[r,s]of Object.entries(e.subsystems)){const e=Xe[r];if(!e||!s.properties){i[r]=s;continue}let a=!1;const l={};for(const[o,i]of Object.entries(s.properties)){const s=e[o];if(!s){l[o]=i;continue}const c=Ge(`${r}.${o}`,t.units),d=et(i,s,c,n);d!==i&&(a=!0),l[o]=d}a?(i[r]={...s,properties:l},o=!0):i[r]=s}return o?{...e,subsystems:i}:e},rt=e=>(null==e?void 0:e.propertyPath)?` for "${e.propertyPath}"`:"",nt=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e));function ot(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 je("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown variant "${t.ref}" (ref).`);if(t.target&&!n.has(t.target))throw new je("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown target "${t.target}".`)}}const it=e=>"object"==typeof e&&null!==e&&Array.isArray(e.modifiers),st=(e,t)=>{if(!Array.isArray(e)||0===e.length)throw new je("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 je("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 je("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must have exactly one fn key; got [${n.join(", ")}].`);return{fn:n[0],arg:e[n[0]]}})},at=new Set(["breakpoint","query","ref","modifiers","mode","target","orientation"]),lt=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),ct=(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 je("REFRACT_E_PROPERTY",`Unable to resolve base value${i=r.propertyPath,i?` for "${i}"`:""}.`);var i;return r.coerceValue?r.coerceValue(o):o},dt=(e,t)=>{const r=new Set(t),n={},o={};let i=!1;for(const[t,s]of Object.entries(e))r.has(t)?(n[t]=s,i=!0):o[t]=s;return{base:i?n:void 0,extra:o}},pt=(e,t,r,n)=>{var o;if(void 0===e&&(null===(o=n.leafFields)||void 0===o?void 0:o.length)){const e=dt(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:ct(e,r,n),extra:t}},ft=(e,t,r,n)=>{const o=r.propertyPath?`${r.propertyPath}.variants.${e}`:`variants.${e}`,i=lt(t)?t:{base:t},{base:s,...a}=i,{base:l,extra:c}=pt(s,a,n,{...r,propertyPath:o});return{...c,base:l}},ut=(e,t={})=>{var r;const n=lt(e)?e:{base:e},{base:o,responsive:i,variants:s,modes:a,...l}=n,{base:c,extra:d}=pt(o,l,t.fallbackBase,t),p=s?Object.fromEntries(Object.entries(s).map(([e,r])=>[e,ft(e,r,t,c)])):void 0,f=a?a.map(e=>((e,t)=>{const{mode:r,target:n,...o}=e,i=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)&&!it(o)){const{base:e,extra:r}=dt(o,t.leafFields);if(void 0!==e){const n={...r};return n.base=t.coerceValue?t.coerceValue(e):e,n}}if(it(o)){const{ref:e,modifiers:t,...r}=o,n={...r};return n.derive={...void 0!==e?{ref:e}:{},modifiers:st(t,i)},n}const{base:r,...n}=o,s={...n};if(void 0!==r&&(s.base=Array.isArray(r)||!t.coerceValue?r:t.coerceValue(r)),void 0===s.base&&!s.derive&&!Object.keys(n).length)throw new je("REFRACT_E_MODE",`Appearance mode "${i}" overrides nothing.`);return s})()}})(e,t)):void 0,u={propertyPath:t.propertyPath,allowedBreakpoints:t.allowedBreakpoints},m=(g=u,(null==(h=i)?void 0:h.length)?h.map(e=>{if(!e.breakpoint)throw new je("REFRACT_E_BREAKPOINT",`Responsive entry${rt(g)} is missing a "breakpoint" value.`);if((null==g?void 0:g.allowedBreakpoints)&&!nt(e.breakpoint,g.allowedBreakpoints))throw new je("REFRACT_E_BREAKPOINT",`Responsive entry${rt(g)} references unknown breakpoint "${e.breakpoint}".`);if(e.ref&&!nt(e.ref,null==g?void 0:g.allowedVariants))throw new je("REFRACT_E_RESPONSIVE",`Responsive entry${rt(g)} references unknown variant "${e.ref}" (ref).`);if(e.target&&!nt(e.target,null==g?void 0:g.allowedTargets))throw new je("REFRACT_E_RESPONSIVE",`Responsive entry${rt(g)} references unknown target "${e.target}".`);const{query:t,...r}=e;return{...r,query:null!=t?t:"exact"}}):[]);var h,g;const v=(null===(r=t.leafFields)||void 0===r?void 0:r.length)?m.map(e=>((e,t)=>{const r={},n={};let o;for(const[t,i]of Object.entries(e))at.has(t)?r[t]=i:"base"===t?o=i:n[t]=i;const i=t.leafFields.some(e=>e in n);if(void 0===o&&!i)return e;const{base:s,extra:a}=pt(o,n,void 0,t);return{...r,...a,base:s}})(e,t)):m;return{...d,base:c,responsive:v,variants:p,modes:f}},mt=["orientation","height","aspectRatio"],ht=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e)),gt=e=>e?` for "${e}"`:"",vt="responsive",bt="states",yt="css",wt="variants",$t=e=>Array.isArray(e)?e:e&&"object"==typeof e?Object.entries(e).map(([e,t])=>({state:e,...t})):[],xt=e=>{var t;return`${e.state}\0${null!==(t=e.target)&&void 0!==t?t:""}`},kt=(e,t)=>{const r=$t(e).map(e=>({...e})),n=new Map(r.map((e,t)=>[xt(e),t]));for(const e of $t(t)){const t=xt(e),o=n.get(t);void 0!==o?r[o]={...r[o],...e}:(n.set(t,r.length),r.push({...e}))}return r},jt=(e,t)=>{var r,n;const o={...e};for(const[i,s]of Object.entries(t))null!==s?i===vt?o[vt]=[...null!==(r=e[vt])&&void 0!==r?r:[],...s]:i===bt?o[bt]=kt(e[bt],s):i===yt?o[yt]={...null!==(n=e[yt])&&void 0!==n?n:{},...s}:o[i]=s:delete o[i];return o},St=(e,t={})=>{const r=((e,t)=>{if(!Object.values(e).some(e=>null!=e&&"object"==typeof e&&null!=e[wt]))return e;const r={},n=(e,n)=>{if(e in r)throw new je("REFRACT_E_VARIANT",`Recipe variant expansion${gt(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{[wt]:e,...o}=r;if(n(t,o),null!=e){const r=null!=o[bt]?{...o,[bt]:$t(o[bt]).filter(e=>!e.target)}:o;for(const[o,i]of Object.entries(e))n(`${t}-${o}`,jt(r,i))}}return r})(e,t.propertyPath),n=Object.keys(r),o=n.length?new Set(n):void 0,i={};return n.forEach(e=>{var n;const s=r[e];i[e]=At(`${null!==(n=t.propertyPath)&&void 0!==n?n:"recipes"}.${e}`,s,{allowedBreakpoints:t.allowedBreakpoints,allowedStates:t.allowedStates,allowedTargets:o,allowedVariants:o,allowedContainers:t.allowedContainers,recipeName:e})}),i},At=(e,t,r)=>{const{responsive:n,states:o,...i}=t;return{base:i,responsive:[...Et(o,e,r),...Rt(n,e,r)]}},Et=(e,t,r)=>$t(e).map(e=>{const{state:n,...o}=e;if(r.allowedStates&&!ht(n,r.allowedStates))throw new je("REFRACT_E_STATE",`Recipe state entry${gt(t)} references unknown state "${n}".`);if(o.target&&r.allowedTargets){const e=r.recipeName?`${r.recipeName}-${o.target}`:o.target;if(!ht(e,r.allowedTargets))throw new je("REFRACT_E_RESPONSIVE",`Recipe state entry${gt(t)} references unknown target "${o.target}".`)}return{...o,state:n}}),Rt=(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 je("REFRACT_E_RESPONSIVE",`Responsive entry${gt(t)} cannot set both "variant" and "target".`);if(void 0!==e.container)return Ct(e,t,r);if(!e.breakpoint)throw new je("REFRACT_E_BREAKPOINT",`Responsive recipe entry${gt(t)} is missing a "breakpoint" value.`);if(r.allowedBreakpoints&&!ht(e.breakpoint,r.allowedBreakpoints))throw new je("REFRACT_E_BREAKPOINT",`Responsive recipe entry${gt(t)} references unknown breakpoint "${e.breakpoint}".`);if(e.state&&r.allowedStates&&!ht(e.state,r.allowedStates))throw new je("REFRACT_E_STATE",`Responsive recipe entry${gt(t)} references unknown state "${e.state}".`);if(e.variant&&!ht(e.variant,r.allowedVariants))throw new je("REFRACT_E_RESPONSIVE",`Responsive recipe entry${gt(t)} references unknown variant "${e.variant}".`);if(e.target&&!ht(e.target,r.allowedTargets))throw new je("REFRACT_E_RESPONSIVE",`Responsive recipe entry${gt(t)} references unknown target "${e.target}".`);return{...e,query:null!==(n=e.query)&&void 0!==n?n:"exact"}}):[],Ct=(e,t,r)=>{var n,o;const i=e.container;for(const r of mt)if(void 0!==e[r])throw new je("REFRACT_E_CONTAINER",`Container recipe entry${gt(t)} cannot use "${r}" — container queries respond to a container's inline size, not orientation/height/aspect-ratio.`);const s=null===(n=r.allowedContainers)||void 0===n?void 0:n.get(i);if(r.allowedContainers&&!s)throw new je("REFRACT_E_CONTAINER",`Container recipe entry${gt(t)} references unknown container "${i}".`);if(void 0===e.size)throw new je("REFRACT_E_CONTAINER",`Container recipe entry${gt(t)} for container "${i}" is missing a "size" value.`);if(s&&!s.has(e.size))throw new je("REFRACT_E_CONTAINER",`Container recipe entry${gt(t)} references unknown size "${e.size}" on container "${i}".`);return{...e,query:null!==(o=e.query)&&void 0!==o?o:"min"}},Ot=(e,t,r={})=>{var n;const o=new Map,i=[],s=null!==(n=r.groupPath)&&void 0!==n?n:"recipes",a=r=>{if(o.has(r))return o.get(r);if(i.includes(r)){const e=[...i,r].join(" -> ");throw new je("REFRACT_E_CYCLE",`Cyclic recipe reference in "${s}": ${e}`)}const n=e[r];if(!n)throw new je("REFRACT_E_REFERENCE",`Recipe variant "${r}" is not defined in "${s}".`);i.push(r);try{const e=t(r,n,a);return o.set(r,e),e}finally{i.pop()}};return{resolve:a,resolveAll:()=>{const t={};for(const r of Object.keys(e))t[r]=a(r);return t}}},Tt=(e,t,r,n=new Map,o=new Set)=>{const i=n.get(r);if(void 0!==i)return i;const s=e[r];if(!s)throw new je("REFRACT_E_TOKEN_PATH",`Unknown token path "${r}".`);if(void 0!==s.external){const e=`var(${s.external})`;return n.set(r,e),e}if(void 0===s.ref){if(void 0===s.value)throw new je("REFRACT_E_TOKEN_PATH",`Token "${r}" has neither "ref" nor "value".`);return n.set(r,s.value),s.value}if(o.has(r))throw new je("REFRACT_E_CYCLE",`Cyclic token reference: ${[...o,r].join(" -> ")}`);o.add(r);const a=Tt(e,t,s.ref,n,o);let l;if(void 0!==s.modifiers)l=s.modifiers.reduce((e,n)=>{const o=t[n.fn];if(!o)throw new je("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${n.fn}" for token "${r}".`);return o(e,n.arg)},a);else if(void 0!==s.fn){const e=t[s.fn];if(!e)throw new je("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${s.fn}" for token "${r}".`);l=e(a,s.arg)}else l=a;return o.delete(r),n.set(r,l),l},Ft=(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),Nt=(e,t,r,n,o)=>{let i;try{i=Tt(t,r,e.ref,n)}catch{throw new je("REFRACT_E_VALIDATION",`${o}: cross-property derivation references unknown token '${e.ref}'.`)}const s=(e,t)=>{const n=r[e];if(!n)throw new je("REFRACT_E_VALIDATION",`${o}: unknown derivation fn '${e}'.`);return n(i,t)};if(void 0!==e.modifiers)for(const t of e.modifiers)i=s(t.fn,t.arg);else void 0!==e.fn&&(i=s(e.fn,e.arg));return{...e,value:i}},_t=(e,t,r,n,o,i)=>{let s;for(const[a,l]of Object.entries(e))Ft(l,t)&&(s=null!=s?s:{...e},s[a]=Nt(l,r,n,o,`${i}.${a}`));return s},zt=(e,t,r,n,o)=>{const i=e.variants?((e,t,r,n,o)=>{let i;for(const[s,a]of Object.entries(e)){const l=`${t}.variants.${s}`,c=Ft(a.base,t)?Nt(a.base,r,n,o,l):a.base,d=a.extras?_t(a.extras,t,r,n,o,`${l} extra`):void 0;(c!==a.base||d)&&(i=null!=i?i:{...e},i[s]=d?{base:c,extras:d}:{...a,base:c})}return i})(e.variants,t,r,n,o):void 0;let s;if(e.modes)for(let i=0;i<e.modes.length;i++){const a=e.modes[i];if(!a.overrides)continue;const l=_t(a.overrides,t,r,n,o,`${t}.modes.${a.mode}`);l&&(s=null!=s?s:[...e.modes],s[i]={...a,overrides:l})}if(!i&&!s)return;const a={...e};return i&&(a.variants=i),s&&(a.modes=s),a},Pt=(e,t)=>{var r;const n=Be(e),o=new Map;let i=!1;const s={};for(const[a,l]of Object.entries(e.subsystems)){let e,c=!1;for(const[i,s]of Object.entries(null!==(r=l.properties)&&void 0!==r?r:{})){const r=zt(s,`${a}.${i}`,n,t,o);r&&(e=null!=e?e:{...l.properties},e[i]=r,c=!0)}c?(s[a]={...l,properties:e},i=!0):s[a]=l}return i?{...e,subsystems:s}:e},Mt=["min","max","exact","between"],qt=e=>void 0===e?void 0:e-.02,Lt=(e,t)=>{const r=(e=>Object.keys(e).sort((t,r)=>e[t]-e[r]))(e);(e=>{const t=e.filter(e=>Mt.includes(e));if(t.length)throw new je("REFRACT_E_BREAKPOINT",`Breakpoint names conflict with reserved keys: ${t.map(e=>`"${e}"`).join(", ")}. Reserved: ${Mt.map(e=>`"${e}"`).join(", ")}.`)})(r);const n=e=>r[r.indexOf(e)+1],o=r.reduce((r,o)=>{const i=e[o],s=n(o),a=void 0!==s?e[s]:void 0;return r[o]=It({own:i,next:a},t),r},{}),i=e=>{const t=o[e];if(!t)throw new je("REFRACT_E_BREAKPOINT",`Breakpoint "${e}" is not defined.`);return t};return{...o,min:(r,n)=>{const o=i(r);return n?t({min:e[r],...n}):o.min},max:(r,o)=>{const s=i(r);if(!o)return s.max;const a=n(r),l=void 0!==a?e[a]:void 0;return t({max:qt(l),...o})},exact:(r,o)=>{const s=i(r);if(!o)return s.exact;const a=n(r),l=void 0!==a?e[a]:void 0;return t({min:e[r],max:qt(l),...o})},between:(r,n,o)=>{const i=e[r],s=e[n];if(void 0===i||void 0===s)throw new je("REFRACT_E_BREAKPOINT",`Cannot build media query between "${r}" and "${n}" breakpoints.`);return t({min:i,max:s-.02,...o})}}},It=({own:e,next:t},r)=>{const n=qt(t);return{min:r({min:e}),max:void 0===n?"":r({max:n}),exact:r({min:e,max:n})}},Bt="px",Ut=16,Wt=e=>{var t;return{unit:null!==(t=null==e?void 0:e.unit)&&void 0!==t?t:Bt,baseFontSize:(null==e?void 0:e.baseFontSize)&&e.baseFontSize>0?e.baseFontSize:Ut}},Dt=(e,t)=>{if("px"===t.unit)return`${e}px`;const r=e/t.baseFontSize;return`${Number(r.toFixed(4))}${t.unit}`},Vt=({min:e,max:t,orientation:r},n)=>{const o=[];if(void 0!==e&&void 0!==t&&e>t)throw new je("REFRACT_E_MEDIA","Invalid media query: `min` cannot be greater than `max`.");return void 0!==e&&o.push(`(min-width: ${Dt(e,n)})`),void 0!==t&&o.push(`(max-width: ${Dt(t,n)})`),r&&o.push(`(orientation: ${r})`),o.length?`@media ${o.join(" and ")}`:""},Ht=(e,{min:t,max:r},n)=>{const o=[];if(void 0!==t&&void 0!==r&&t>r)throw new je("REFRACT_E_MEDIA","Invalid container query: `min` cannot be greater than `max`.");return void 0!==t&&o.push(`(min-width: ${Dt(t,n)})`),void 0!==r&&o.push(`(max-width: ${Dt(r,n)})`),o.length?`@container ${e} ${o.join(" and ")}`:""},Gt={xs:0,sm:576,md:768,lg:992,xl:1280},Yt=(e,t)=>{const r=Wt(t),n={};for(const[t,o]of Object.entries(null!=e?e:{}))n[t]=Lt(o.sizes,e=>Ht(t,{min:e.min,max:e.max},r));return n},Jt={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"},Kt=e=>Math.round(1e3*Math.min(1,Math.max(0,e)))/1e3,Xt=(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)),i=o*(1-Math.abs(n%2-1)),s=Math.min(1,Math.max(0,r))-o/2,[a,l,c]=n<1?[o,i,0]:n<2?[i,o,0]:n<3?[0,o,i]:n<4?[0,i,o]:n<5?[i,0,o]:[o,0,i];return[255*(a+s),255*(l+s),255*(c+s)]},Zt=/^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*(?:\/\s*([\d.]+)(%?)\s*)?\)$/i,Qt=/^hsla?\(\s*([\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[,/]\s*([\d.]+)(%?)\s*)?\)$/i,er=e=>{if("string"==typeof e){const t=(e=>{const t=e.trim(),r=Zt.exec(t);if(r){const e="%"===r[2]?Number(r[1]):100*Number(r[1]),t=void 0===r[5]?1:Kt("%"===r[6]?Number(r[5])/100:Number(r[5]));return{rgb:_({L:e,C:Number(r[3]),h:Number(r[4])}),a:t}}const n=Qt.exec(t);if(n){const e=void 0===n[4]?1:Kt("%"===n[5]?Number(n[4])/100:Number(n[4]));return{rgb:Xt(Number(n[1]),Number(n[2])/100,Number(n[3])/100),a:e}}const o=Jt[t.toLowerCase()];if(o)return{rgb:S(o),a:1};try{return R(t)}catch{return null}})(e);if(!t)throw new je("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 C(t.rgb,t.a)}if(!Array.isArray(e)||3!==e.length||e.some(e=>"number"!=typeof e))throw new je("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 C([t,r,n])},tr={lighten:(e,t)=>P(e,Number(t)),darken:(e,t)=>M(e,Number(t)),alpha:(e,t)=>U(e,Number(t)),setL:(e,t)=>q(e,Number(t)),rotateHue:(e,t)=>L(e,Number(t)),adjust:(e,t)=>I(e,t)},rr=["light","lighter"],nr=["dark","darker"],or=(e,t)=>{if(!e||!e.includes("."))return!1;const[r,n]=e.split(".");return`${r}.${n}`!=`colors.${t}`},ir=(e,t)=>{try{return er(e)}catch(e){throw new je("REFRACT_E_COLOR_INPUT",`colors.${t}.text — ${e.message}`)}},sr=(e,t,r={})=>{var n;const o=((e,t)=>{let r=t;if(void 0!==t.text&&(r={...r,text:ir(t.text,e)}),t.variants){let n=!1;const o={};for(const[r,i]of Object.entries(t.variants))void 0!==i.text?(o[r]={...i,text:ir(i.text,`${e}.variants.${r}`)},n=!0):o[r]=i;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:ir(t.text,`${e}.modes.${t.mode}`)}):t);n&&(r={...r,modes:o})}return r})(e,t),i=(e=>{try{return R(e),!0}catch{return!1}})(o.base),s=!(!o.steps||!o.steps.length),a=Object.keys(r).length>0,l=void 0!==o.harmony;if((s||a||l)&&!i)throw new je("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=i?cr(o,e):{},d=i?pr(o,e):{},p=null!==(n=o.variants)&&void 0!==n?n:{},f={...c,...d,...p},u=vr(e,o.base,f,r),m={...c,...d,...p,...u},h=lr(o,e,m),g=ar(o,e,m);return Object.keys(m).length||h||g?{...o,...Object.keys(m).length?{variants:m}:{},...h?{modes:h}:{},...g?{responsive:g}:{}}:o},ar=(e,t,r)=>{const n=e.responsive;if(!n||!n.length)return;let o=!1;const i=n.map((e,n)=>{const i=e.ref,s=e.modifiers;if(!i||!Array.isArray(s)||!s.length){let t;for(const r of["base","text"]){const n=e[r];if("string"==typeof n||Array.isArray(n)){const o=er(n);o!==n&&(t=null!=t?t:{...e},t[r]=o)}}return t&&(o=!0),null!=t?t:e}const a=r[i];if(!a)throw new je("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references unknown variant "${i}".`);if(void 0===a.base)throw new je("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references "${i}", a cross-property derivation — not supported.`);const l=gr({modifiers:s},t,`responsive[${n}]`);let c=a.base;for(const e of l)c=tr[e.fn](c,e.arg);o=!0;const{ref:d,modifiers:p,...f}=e;return{...f,base:c,derive:{ref:`colors.${t}.${i}`,modifiers:l}}});return o?i:n},lr=(e,t,r)=>{const n=e.modes;if(!n||!n.length)return;return n.map(n=>{var o;const i=n.mode,s=n.derive;if(!s)return n;const a=null!==(o=s.modifiers)&&void 0!==o?o:s.fn?[{fn:s.fn,arg:s.arg}]:[];if(or(s.ref,t)){const{base:e,derive:t,...r}=n;return{...r,derive:{ref:s.ref,modifiers:a}}}const l=((n,o)=>{if(!n||n===`colors.${t}`)return{value:e.base,path:`colors.${t}`};const i=n.includes(".")?n.slice(`colors.${t}.`.length):n,s=r[i];if(!s||void 0===s.base)throw new je("REFRACT_E_VARIANT_REF",`colors.${t}.modes.${o} references unknown variant "${n}".`);return{value:s.base,path:`colors.${t}.${i}`}})(s.ref,i);let c=l.value;for(const e of a){const r=tr[e.fn];if(!r)throw new je("REFRACT_E_VARIANT_REF",`Unknown derivation fn "${e.fn}" for appearance mode "colors.${t}.modes.${i}".`);c=r(c,e.arg)}return{...n,base:c,derive:{ref:l.path,modifiers:a}}})},cr=(e,t)=>e.steps&&e.steps.length?hr(e,t):ur(e,t),dr={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}]},pr=(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 je("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 je("REFRACT_E_HARMONY",`colors.${t}.harmony object form must name exactly one scheme; got [${e.join(", ")}].`);n=e[0],o=r[n]}}const i=dr[n];if(!i)throw new je("REFRACT_E_HARMONY",`colors.${t}.harmony: unknown scheme "${n}". Use one of ${Object.keys(dr).join(", ")}.`);const s={};return i.forEach((r,n)=>{var i;const a=null!==(i=null==o?void 0:o[n])&&void 0!==i?i:r.name;s[a]={base:L(e.base,r.deg),derive:{ref:`colors.${t}`,fn:"rotateHue",arg:r.deg}}}),s},fr=(e,t,r,n,o,i,s,a)=>{var l;const c=e=>e?`colors.${r}.${e}`:`colors.${r}`;let d,p=t.base;for(const t of o){if(void 0!==(null===(l=n[t])||void 0===l?void 0:l.base)){p=n[t].base,d=t;continue}const r=i(p,a);e[t]={base:r,derive:{ref:c(d),fn:s,arg:a}},p=r,d=t}},ur=(e,t)=>{var r,n,o;const i=null!==(r=e.variants)&&void 0!==r?r:{},s={},a=null!==(n=e.lightenBy)&&void 0!==n?n:10,l=null!==(o=e.darkenBy)&&void 0!==o?o:10;return fr(s,e,t,i,rr,P,"lighten",a),fr(s,e,t,i,nr,M,"darken",l),s},mr=e=>e<=0?100:e>=1e3?0:Math.min(98,Math.max(5,(1e3-e)/10)),hr=(e,t)=>{var r,n;const o=null!==(r=e.steps)&&void 0!==r?r:[],i=o.find(e=>"number"!=typeof e||isNaN(e)||e<0||e>1e3);if(void 0!==i)throw new je("REFRACT_E_STEPS",`colors.${t}.steps must be numbers in 0–1000 (e.g. [50, …, 950]); got ${JSON.stringify(i)}.`);const s=null!==(n=e.variants)&&void 0!==n?n:{},a={};for(const r of o){const n=r.toString();if(s[n])continue;const o=mr(r);a[n]={base:q(e.base,o),derive:{ref:`colors.${t}`,fn:"setL",arg:o}}}return a},gr=(e,t,r)=>{const n=`colors.${t}.variants.${r}`,o=e.modifiers;if(!Array.isArray(o)||0===o.length)throw new je("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 je("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must be a single-key object like { darken: 10 }.`);const i=Object.keys(e);if(1!==i.length)throw new je("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must have exactly one fn key; got [${i.join(", ")}].`);const s=i[0];if(!tr[s])throw new je("REFRACT_E_VARIANT",`${n}.modifiers[${o}] unknown fn "${s}"; use ${Object.keys(tr).join(" / ")}.`);const a=e[s],l="adjust"===s?((e,t,r)=>{const n=`colors.${t}.variants.${r}.adjust`;if("object"!=typeof e||null===e||Array.isArray(e))throw new je("REFRACT_E_ADJUST",`${n} must be an object with numeric l / c / h dials.`);const{l:o,c:i,h:s}=e,a={};if(void 0!==o){if("number"!=typeof o||isNaN(o)||o<0||o>100)throw new je("REFRACT_E_ADJUST",`${n}.l must be an absolute OKLCH lightness in 0–100; got ${JSON.stringify(o)}.`);a.l=o}if(void 0!==i){if("number"!=typeof i||isNaN(i)||i<0)throw new je("REFRACT_E_ADJUST",`${n}.c must be a non-negative chroma multiplier (1 keeps, 0 greys); got ${JSON.stringify(i)}.`);a.c=i}if(void 0!==s){if("number"!=typeof s||isNaN(s))throw new je("REFRACT_E_ADJUST",`${n}.h must be a numeric hue rotation in degrees; got ${JSON.stringify(s)}.`);a.h=s}return a})(a,t,r):Number(a);return{fn:s,arg:l}})},vr=(e,t,r,n)=>{const o={},i=new Set,s=(t,r)=>{if(void 0===t.base)throw new je("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(i.has(l))throw new je("REFRACT_E_CYCLE",`Cyclic colour variant derivation at colors.${e}.${l}.`);i.add(l);const d=gr(c,e,l);if(or(c.ref,e))return o[l]={derive:{ref:c.ref,modifiers:d}},void i.delete(l);const p=(i=>{if(!i)return{value:t,path:`colors.${e}`};if(o[i])return{value:s(o[i],i),path:`colors.${e}.${i}`};if(r[i])return{value:s(r[i],i),path:`colors.${e}.${i}`};if(n[i])return a(i,n[i]),{value:s(o[i],i),path:`colors.${e}.${i}`};throw new je("REFRACT_E_VARIANT_REF",`colors.${e} variant references unknown source "${i}".`)})(c.ref);let f=p.value;for(const e of d)f=tr[e.fn](f,e.arg);o[l]={base:f,derive:{ref:p.path,modifiers:d}},i.delete(l)}for(const[e,t]of Object.entries(n))a(e,t);return o},br=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(" ")),yr=/^-(webkit|moz|ms|o)-/,wr=e=>{if(e.startsWith("--"))return!0;const t=e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return!!yr.test(t)||br.has(t)},$r=new Set(["breakpoint","query","state","variant","target","orientation"]),xr=(e,t,r)=>{const n={};if(!e)return n;for(const[o,i]of Object.entries(e)){if(void 0===i||$r.has(o))continue;if(!wr(o))throw new je("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=kr(i,t,r,o);void 0!==e&&(n[jr(o)]=e)}return n},kr=(e,t,r,n)=>{var o;if("number"==typeof e)return{value:e};const i=e.trim();if(!i)return;const s=i.split("."),a=s[0],l=t.properties[a];if(!l)return{value:i};const c=s.length>1?s.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 je("REFRACT_E_VARIANT_REF",`Unknown palette variant reference "${a}.${c}" in ${r}.${n}.`);return{ref:`colors.${a}.${c}`}},jr=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Sr=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),Ar=([e,t,r])=>.2126*Sr(e/255)+.7152*Sr(t/255)+.0722*Sr(r/255),Er={fail:0,"AA-large":1,AA:2,AAA:3},Rr=2.4,Cr=.2126729,Or=.7151522,Tr=.072175,Fr=.56,Nr=.57,_r=.62,zr=.65,Pr=.022,Mr=1.414,qr=1.14,Lr=.027,Ir=1.14,Br=.027,Ur=5e-4,Wr=.1,Dr=([e,t,r])=>Cr*Math.pow(e/255,Rr)+Or*Math.pow(t/255,Rr)+Tr*Math.pow(r/255,Rr),Vr=(e,t)=>{const r=e=>e>Pr?e:e+Math.pow(Pr-e,Mr),n=r(Dr(e)),o=r(Dr(t));if(Math.abs(o-n)<Ur)return 0;let i;if(o>n){const e=(Math.pow(o,Fr)-Math.pow(n,Nr))*qr;i=e<Wr?0:e-Lr}else{const e=(Math.pow(o,zr)-Math.pow(n,_r))*Ir;i=e>-Wr?0:e+Br}return 100*i},Hr=(e,t)=>{const r=10**t;return Math.round(e*r)/r},Gr=(e,t)=>{if(void 0!==t.ref)try{return String(e.resolveToken(t.ref))}catch{return}if("string"==typeof t.value)return t.value},Yr="color",Jr=["background-color","background"],Kr=e=>{if(e)for(const t of Jr)if(e[t])return e[t]},Xr=(e,t,r,n,o)=>{let i,s;try{void 0!==r&&(i=R(r).rgb)}catch{}try{void 0!==n&&(s=R(n).rgb)}catch{}if(!i||!s)return{kind:e,label:t,fg:r,bg:n,skipped:i||s?i?"bg not a colour":"fg not a colour":"no derivable fg/bg"};const a=((e,t)=>{const r=Ar(e),n=Ar(t);return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)})(i,s),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=Er[l]>=Er[o.minWcag];return{kind:e,label:t,fg:r,bg:n,wcagRatio:Hr(a,2),wcagLevel:l,apcaLc:Hr(Vr(i,s),1),pass:c}},Zr=(e,t={})=>{var r,n,o,i,s,a,l,c,d,p,f;const u={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===(i=t.includePalettes)||void 0===i||i)for(const t of Object.keys(e.tokens)){const r=/^colors\.([^.]+)\.text$/.exec(t);if(!r)continue;const n=`colors.${r[1]}`;let o,i;try{o=String(e.resolveToken(t))}catch{}try{i=String(e.resolveToken(n))}catch{}h.push(Xr("palette",n,o,i,u))}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,i]of Object.entries(o)){const o=i.declarations[Yr],m=Kr(i.declarations),g=`${t}.${n}.${r}`;o&&m&&h.push(Xr("recipe",g,Gr(e,o),Gr(e,m),u));for(const t of null!==(s=i.overrides)&&void 0!==s?s:[]){const r=null!==(l=null===(a=t.declarations)||void 0===a?void 0:a[Yr])&&void 0!==l?l:o,n=null!==(c=Kr(t.declarations))&&void 0!==c?c:m;if(!t.declarations||!t.declarations[Yr]&&!Kr(t.declarations))continue;if(!r||!n)continue;const i=null!==(f=null!==(p=null!==(d=t.state)&&void 0!==d?d:t.breakpoint)&&void 0!==p?p:t.query)&&void 0!==f?f:"override";h.push(Xr("recipe",`${g} (${i})`,Gr(e,r),Gr(e,n),u))}}const g=h.filter(e=>!e.skipped),v=g.filter(e=>!1===e.pass),b=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-v.length,failed:v.length,skipped:h.length-g.length,worst:b},ok:0===v.length};if(t.strict&&v.length>0){const e=v.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`).join(", ");throw new je("REFRACT_E_AUDIT",`refract audit: ${v.length} pairing(s) fail WCAG ${u.minWcag} — ${e}. Adjust the colour(s), lower --min-wcag, or drop --strict to report without failing.`,v.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`))}return y},Qr=new Set(["recipes"]),en=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("base"in e)&&Array.isArray(e.modifiers),tn=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))en(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}},rn={key:"colors",derivations:{lighten:(e,t)=>P(String(e),Number(t)),darken:(e,t)=>M(String(e),Number(t)),alpha:(e,t)=>U(String(e),Number(t)),setL:(e,t)=>q(String(e),Number(t)),rotateHue:(e,t)=>L(String(e),Number(t)),adjust:(e,t)=>I(String(e),t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Qr.has(n))continue;const{value:e,specs:i}=tn(o),s=ut(e,{propertyPath:`colors.${n}`,allowedBreakpoints:t.allowedBreakpoints,coerceValue:er}),a=sr(n,s,i);ot(a,{propertyPath:`colors.${n}`}),r[n]=a}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{const n=`${r.groupPath}.${e}`;return{base:xr(t.base,r,n),responsive:t.responsive.map(e=>{const{breakpoint:t,query:o,state:i,variant:s,target:a,orientation:l,container:c,size:d,...p}=e,f={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...xr(p,r,`${n}.responsive`)}};return t&&(f.breakpoint=t,f.query=null!=o?o:"exact"),c&&(f.container=c,d&&(f.size=d),f.query=null!=o?o:"min"),i&&(f.state=i),l&&(f.orientation=l),a&&(f.target=a),f})}})(e,t,r)},nn={"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},on={xs:-2,sm:-1,md:0,lg:1,xl:2,"2xl":3,"3xl":4,"4xl":5},sn=(e,t)=>"fontSize"!==e?t:an(t),an=e=>{var t,r,n,o;const i=e.ratio;if(!i)return e;const s=nn[i];if(!s)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,d=null!==(n=e.variants)&&void 0!==n?n:{},p={};let f=null;for(const[e,t]of Object.entries(on)){if(d[e]){f=null!==(o=d[e].base)&&void 0!==o?o:null;continue}let r;r=c?c(a,e,t,f):a*Math.pow(s,t);const n=Number(r.toFixed(l));f=n,p[e]={base:n}}return{...e,variants:{...p,...d}}},ln=new Set(["breakpoint","query","state","variant","target","orientation"]),cn={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"},dn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||ln.has(r))continue;const e=cn[r];e&&(t[e]={ref:pn(r,n)})}return t},pn=(e,t)=>"base"===t?`typography.${e}`:`typography.${e}.${t}`,fn=new Set(["recipes"]),un={key:"typography",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(fn.has(n))continue;const e=ut(o,{propertyPath:`typography.${n}`,allowedBreakpoints:t.allowedBreakpoints}),i=sn(n,e);ot(i,{propertyPath:`typography.${n}`}),r[n]=i}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:dn(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:i,target:s,orientation:a,container:l,size:c,...d}=e,p={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...dn(d)}};return t&&(p.breakpoint=t,p.query=null!=n?n:"exact"),l&&(p.container=l,c&&(p.size=c),p.query=null!=n?n:"min"),o&&(p.state=o),s&&(p.target=s),a&&(p.orientation=a),p})}))(0,t,r)},mn=["spacing","gutters","aspectRatio","sizes"],hn=new Set(["spacing","gutters","sizes"]),gn=new Set(["spacing","gutters"]),vn=["xs","sm","md","lg","xl","2xl","3xl","4xl"],bn=e=>Number(e.toFixed(4)),yn=(e,t)=>{var r;if(!hn.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 je("REFRACT_E_LAYOUT",`layout.${e}: declare only one of "ratio" (geometric) or "step" (linear) scale, not both.`);const i=r.steps;if(n){let t;if(void 0===i)t=vn;else{if(!Array.isArray(i))throw new je("REFRACT_E_LAYOUT",`layout.${e}: a geometric scale ("ratio") needs "steps" as an ordered name array, e.g. ["sm","md","lg"].`);t=i.map(String)}const n=t.map((e,t)=>({name:e,exp:t}));return{curve:"geometric",ratio:Number(r.ratio),specs:n}}let s;if(void 0===i)s=vn.map((e,t)=>({name:e,exp:t,mult:t+1}));else{if(Array.isArray(i)||"object"!=typeof i||null===i)throw new je("REFRACT_E_LAYOUT",`layout.${e}: a linear scale ("step") needs "steps" as a name→multiplier map, e.g. { sm:1, md:2, lg:3 }.`);s=Object.entries(i).map(([e,t],r)=>({name:e,exp:r,mult:Number(t)}))}return{curve:"linear",step:Number(r.step),specs:s}})(e,t);if(!n)return gn.has(e)?wn(t):t;const o=((e,t,r)=>{const n=`layout.${e}`,o={};for(const e of r.specs)if("geometric"===r.curve){const i=bn(Number(t)*Math.pow(r.ratio,e.exp));o[e.name]={base:i,derive:{ref:n,fn:"scaleStep",arg:{curve:"geometric",ratio:r.ratio,exp:e.exp}}}}else{const t=bn(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 i={...o,...null!==(r=t.variants)&&void 0!==r?r:{}};gn.has(e)&&(i={...i,none:{base:0}});const s=((e,t,r,n)=>{if(!(null==r?void 0:r.length))return r;const o=`layout.${e}`,i=[];let s=!1;for(const a of r){const r=a;if(void 0===r.ratio&&void 0===r.step){i.push(r);continue}if(s=!0,void 0!==r.ratio&&void 0!==r.step)throw new je("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry may set only "ratio" or "step", not both.`);if(!n)throw new je("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:d}=r,p=void 0!==r.ratio;for(const s of n.specs){let n,a;if(p){const e=Number(r.ratio),o=void 0!==r.base,i=Number(o?r.base:t);n=bn(i*Math.pow(e,s.exp)),a={curve:"geometric",ratio:e,exp:s.exp,...o?{base:i}:{}}}else{if(void 0===s.mult)throw new je("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=bn(t*s.mult),a={curve:"linear",step:t,mult:s.mult}}const f={breakpoint:l,query:c,target:s.name,base:n,derive:{ref:o,fn:"scaleStep",arg:a}};void 0!==d&&(f.orientation=d),i.push(f)}}return s?i:r})(e,t.base,t.responsive,n);return(e=>{const{ratio:t,step:r,steps:n,...o}=e;return o})({...t,variants:i,responsive:s})},wn=e=>{var t;const r=null!==(t=e.variants)&&void 0!==t?t:{};return{...e,variants:{...r,none:{base:0}}}},$n=new Set(["breakpoint","query","state","variant","target","orientation"]),xn={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"]},kn={paddingY:"spacing",paddingX:"spacing",marginY:"spacing",marginX:"spacing",gap:"spacing",width:"sizes",minWidth:"sizes",maxWidth:"sizes",height:"sizes",minHeight:"sizes",maxHeight:"sizes",background:"literal"},jn=(e,t)=>"base"===t?`layout.${e}`:`layout.${e}.${t}`,Sn=(e,t)=>{const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if($n.has(n))continue;if(!o)continue;const e=xn[n];if(!e)throw new je("REFRACT_E_LAYOUT",`Unknown layout recipe property "${n}" in ${t}. Known verbs: ${Object.keys(xn).join(", ")}. For arbitrary CSS use a component \`css\` delta.`);const i=kn[n];for(const t of e)r[t]="literal"===i?{value:o}:{ref:jn(i,o)}}return r},An=e=>({ref:"base"===e?"layout.spacing":`layout.spacing.${e}`}),En=e=>({ref:"base"===e?"layout.gutters":`layout.gutters.${e}`}),Rn=e=>({ref:`layout.${e}`}),Cn=e=>({value:e}),On=e=>Object.keys(e).sort((t,r)=>e[t]-e[r]),Tn=[["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"]],Fn=(e,t)=>{const r={};t&&(r.display=Cn("grid"));for(const[t,n]of Tn){const o=e[t];o&&(r[n]=Cn(o))}return e.gap&&(r.gap=An(e.gap)),r},Nn=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}},_n=(e,t,r=new Set,n)=>{var o,i,s,a;const l=Wt(n),c=e=>Dt(e,l),d={},p={},f=On(t),u=e&&"object"==typeof e?e:void 0,m=u?{mode:null!==(o=u.base)&&void 0!==o?o:"fixed",inset:u.inset,gutter:u.gutter,direction:u.direction,align:u.align,justify:u.justify,maxWidth:u.maxWidth}:Nn(null!=e?e:"fixed"),h=null!==(i=null==u?void 0:u.variants)&&void 0!==i?i:{},g=null!==(s=null==u?void 0:u.responsive)&&void 0!==s?s:[],v=e=>e?`container-${e}`:"container",b=(e,n)=>{var o,i,s,a,l,u,h,g,b;const y=e?`--${e}`:"",w=`container${y}--inset`,$=`container${y}--gutter`,x=null!==(i=null!==(o=n.inset)&&void 0!==o?o:m.inset)&&void 0!==i?i:"base",k=null!==(s=n.gutter)&&void 0!==s?s:m.gutter,j=null!==(l=null!==(a=n.mode)&&void 0!==a?a:m.mode)&&void 0!==l?l:"fixed",S=null!==(u=n.direction)&&void 0!==u?u:m.direction,A=null!==(h=n.align)&&void 0!==h?h:m.align,E=null!==(g=n.justify)&&void 0!==g?g:m.justify,R=null!==(b=n.maxWidth)&&void 0!==b?b:e?m.maxWidth:void 0;d[w]={base:An(x)},k&&(d[$]={base:En(k)});const C={"box-sizing":Cn("border-box"),width:Cn("100%"),"margin-left":Cn("auto"),"margin-right":Cn("auto"),"padding-left":Rn(w),"padding-right":Rn(w)};k&&(C.gap=Rn($)),S&&(C.display=Cn("flex"),C["flex-direction"]=Cn(S)),A&&(C["align-items"]=Cn(A)),E&&(C["justify-content"]=Cn(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],i=t[r>=0&&n>r?e:o];0!==i?0===n?C["max-width"]=Cn(c(i)):O.push({breakpoint:o,query:"min",declarations:{"max-width":Cn(c(i))}}):0===n&&(C["max-width"]=Cn("none"))}}else"fluid"===j?void 0!==R&&(C["max-width"]=((e,t,r)=>{return"number"==typeof e?Cn(`${e}px`):t.has(e)?{ref:"base"===(n=e)?"layout.sizes":`layout.sizes.${n}`}:void 0!==r[e]?Cn(`${r[e]}px`):Cn(e);var n})(R,r,t)):C["max-width"]=Cn("number"==typeof j?`${j}px`:j);p[v(e)]={kind:"recipe",declarations:C,overrides:O}};b(null,m);for(const[e,t]of Object.entries(h))b(e,Nn(t));for(const e of g){const t=e.target,r=v(null!=t?t:null),n=p[r];if(!n)continue;const o={};if(e.direction&&(o["flex-direction"]=Cn(e.direction)),e.align&&(o["align-items"]=Cn(e.align)),e.justify&&(o["justify-content"]=Cn(e.justify)),e.inset){const e=t?`container--${t}--inset`:"container--inset";o["padding-left"]=Rn(e),o["padding-right"]=Rn(e)}if(e.gutter){const e=t?`container--${t}--gutter`:"container--gutter";o.gap=Rn(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:p},configProperties:d}},zn=(e,t,r)=>{const n={},o={},i=e=>{e&&(Object.assign(n,e.ruleSetGroups),Object.assign(o,e.configProperties))};return i(((e,t)=>{var r,n;if(!e)return;const o="number"==typeof e?{size:e}:e,i=o.size,s=null!==(r=o.gutter)&&void 0!==r?r:"base",a=null!==(n=o.inset)&&void 0!==n?n:"none",l={"columns--size":{base:Cn(String(i))},"columns--gutter":{base:En(s)},"columns--inset":{base:An(a)}},c={},d=Array.from({length:i},(e,t)=>t+1);for(const e of On(t))for(const r of d){const n=`col-${e}-${r}`,o=`offset-${e}-${r}`,i={"grid-column-end":Cn(`span ${r}`)},s={"grid-column-start":Cn(String(r+1))};0===t[e]?(c[n]={kind:"utility",declarations:i,overrides:[]},c[o]={kind:"utility",declarations:s,overrides:[]}):(c[n]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:i}]},c[o]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:s}]})}return{ruleSetGroups:{columns:c},configProperties:l}})(e.columns,t)),i((e=>{var t,r;if(!e||!Object.keys(e).length)return;const n={};for(const[o,i]of Object.entries(e)){const e=Fn(i,!0),s=[];for(const e of null!==(t=i.responsive)&&void 0!==t?t:[]){const t=Fn(e,!1);Object.keys(t).length&&s.push({breakpoint:e.breakpoint,query:null!==(r=e.query)&&void 0!==r?r:"exact",declarations:t})}n[`grid-${o}`]={kind:"recipe",declarations:e,overrides:s}}return{ruleSetGroups:{grids:n},configProperties:{}}})(e.grids)),i((e=>{var t,r,n;if(!e||!Object.keys(e).length)return;const o={};for(const[i,s]of Object.entries(e)){const e={display:Cn(s.inline?"inline-flex":"flex"),"flex-direction":Cn(null!==(t=s.direction)&&void 0!==t?t:"column")};s.align&&(e["align-items"]=Cn(s.align)),s.justify&&(e["justify-content"]=Cn(s.justify)),s.wrap&&(e["flex-wrap"]=Cn(s.wrap)),s.gap&&(e.gap=An(s.gap));const a=[];for(const e of null!==(r=s.responsive)&&void 0!==r?r:[]){const t={};void 0!==e.inline&&(t.display=Cn(e.inline?"inline-flex":"flex")),e.direction&&(t["flex-direction"]=Cn(e.direction)),e.align&&(t["align-items"]=Cn(e.align)),e.justify&&(t["justify-content"]=Cn(e.justify)),e.wrap&&(t["flex-wrap"]=Cn(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-${i}`]={kind:"recipe",declarations:e,overrides:a}}return{ruleSetGroups:{stacks:o},configProperties:{}}})(e.stacks)),i(_n(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}},Pn=new Set(mn),Mn={key:"layout",derivations:{scaleStep:(e,t)=>((e,t)=>{const r=null!=t?t:{};if("linear"===r.curve)return bn(Number(r.step)*Number(r.mult));const n=void 0!==r.base?Number(r.base):Number(e);return bn(n*Math.pow(Number(r.ratio),Number(r.exp)))})(e,t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const n of mn){const o=e[n];if(void 0===o||!Pn.has(n))continue;const i=ut(o,{propertyPath:`layout.${n}`,allowedBreakpoints:t.allowedBreakpoints}),s=yn(n,i);ot(s,{propertyPath:`layout.${n}`}),r[n]=s}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:Sn(t.base,o),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:i,variant:s,target:a,orientation:l,container:c,size:d,...p}=e,f={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...Sn(p,o)}};return t&&(f.breakpoint=t,f.query=null!=n?n:"exact"),c&&(f.container=c,d&&(f.size=d),f.query=null!=n?n:"min"),i&&(f.state=i),a&&(f.target=a),l&&(f.orientation=l),f})}})(e,t,r),buildStructural:(e,t)=>zn(e,t.breakpoints,t.mediaConfig)},qn=new Set(["breakpoint","query","state","variant","target","orientation"]),Ln={boxShadow:"box-shadow",opacity:"opacity",blur:"filter",transition:"transition",zIndex:"z-index"},In={boxShadow:"shadow",opacity:"opacity",blur:"blur",transition:"transitions",zIndex:"zIndex"},Bn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||qn.has(r))continue;const e=Ln[r],o=In[r];if(!e||!o)continue;const i={ref:Un(o,n)};"blur"===r&&(i.wrap="blur"),t[e]=i}return t},Un=(e,t)=>"base"===t?`effects.${e}`:`effects.${e}.${t}`,Wn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),Dn=(e,t)=>{if(void 0!==e){if("number"!=typeof e||Number.isNaN(e))throw new je("REFRACT_E_EFFECTS",`${t} must be a number, received ${JSON.stringify(e)}.`);return e}},Vn=(e,t)=>{if(void 0!==e){if("number"==typeof e){if(Number.isNaN(e))throw new je("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`);return e}if("string"==typeof e){const r=Ve(e);if("raw"in r)throw new je("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 je("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`)}},Hn=new Set(["offsetX","offsetY","blur","spread","color","inset"]),Gn=(e,t)=>{if(!Wn(e))throw new je("REFRACT_E_EFFECTS",`${t} must be a shadow-layer object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!Hn.has(r))throw new je("REFRACT_E_EFFECTS",`${t} has unknown shadow field "${r}" (allowed: ${[...Hn].join(", ")}).`);const r={},n=Vn(e.offsetX,`${t}.offsetX`),o=Vn(e.offsetY,`${t}.offsetY`),i=Vn(e.blur,`${t}.blur`),s=Vn(e.spread,`${t}.spread`);if(void 0!==n&&(r.offsetX=n),void 0!==o&&(r.offsetY=o),void 0!==i&&(r.blur=i),void 0!==s&&(r.spread=s),void 0!==e.color){if("string"!=typeof e.color||!e.color)throw new je("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 je("REFRACT_E_EFFECTS",`${t}.inset must be a boolean.`);e.inset&&(r.inset=!0)}return r},Yn=new Set(["property","duration","timingFunction","delay"]),Jn=(e,t)=>{if(!Wn(e))throw new je("REFRACT_E_EFFECTS",`${t} must be a transition-part object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!Yn.has(r))throw new je("REFRACT_E_EFFECTS",`${t} has unknown transition field "${r}" (allowed: ${[...Yn].join(", ")}).`);if("string"!=typeof e.property||!e.property)throw new je("REFRACT_E_EFFECTS",`${t}.property is required (the CSS property to transition).`);const r={property:e.property},n=Dn(e.duration,`${t}.duration`),o=Dn(e.delay,`${t}.delay`);if(void 0!==n&&(r.duration=n),void 0!==e.timingFunction){if("string"!=typeof e.timingFunction||!e.timingFunction)throw new je("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},Kn=new Set(["recipes"]),Xn={shadow:["offsetX","offsetY","blur","spread","color","inset"],transitions:["property","duration","timingFunction","delay"]},Zn=e=>"shadow"===e?t=>((e,t="effects.shadow")=>{if("string"==typeof e){if("none"===e)return"none";throw new je("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 je("REFRACT_E_EFFECTS",`${t} is an empty shadow-layer array.`);return e.map((e,r)=>Gn(e,`${t}[${r}]`))}return[Gn(e,t)]})(t,`effects.${e}`):"transitions"===e?t=>((e,t="effects.transitions")=>{if("string"==typeof e){if("none"===e)return"none";throw new je("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 je("REFRACT_E_EFFECTS",`${t} is an empty transition-part array.`);return e.map((e,r)=>Jn(e,`${t}[${r}]`))}return[Jn(e,t)]})(t,`effects.${e}`):void 0,Qn={key:"effects",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Kn.has(n))continue;const e=Xn[n],i=Zn(n),s=ut(o,{propertyPath:`effects.${n}`,allowedBreakpoints:t.allowedBreakpoints,...e?{leafFields:e}:{},...i?{coerceValue:i}:{},...e?{fallbackBase:"none"}:{}});ot(s,{propertyPath:`effects.${n}`}),r[n]=s}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:Bn(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:i,target:s,orientation:a,container:l,size:c,...d}=e,p={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...Bn(d)}};return t&&(p.breakpoint=t,p.query=null!=n?n:"exact"),l&&(p.container=l,c&&(p.size=c),p.query=null!=n?n:"min"),o&&(p.state=o),s&&(p.target=s),a&&(p.orientation=a),p})}))(0,t,r)},eo=new Set(["breakpoint","query","state","variant","target","orientation","container","size"]),to=new Set(["as","side"]),ro=new Set(["width","style","offset","radius","color"]),no=(e,t,r)=>"radius"===r?"border-radius":"offset"===r?"outline-offset":"outline"===e?`outline-${r}`:t?`border-${t}-${r}`:`border-${r}`,oo=(e,t)=>"color"===e?{ref:t}:{ref:"base"===t?`borders.${e}`:`borders.${e}.${t}`},io=(e,t,r)=>{const n={};if(!e)return n;for(const[o,i]of Object.entries(e))i&&!eo.has(o)&&!to.has(o)&&ro.has(o)&&(n[no(t,r,o)]=oo(o,i));return n},so=new Set(["recipes"]),ao={key:"borders",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(so.has(n))continue;const e=ut(o,{propertyPath:`borders.${n}`,allowedBreakpoints:t.allowedBreakpoints});ot(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",i=t.base.side,s=io(t.base,o,i),a=t.responsive.map(e=>{var t,n;const{breakpoint:s,query:a,state:l,variant:c,target:d,orientation:p,container:f,size:u,as:m,side:h,...g}=e,v=null!==(t=m)&&void 0!==t?t:o,b=null!==(n=h)&&void 0!==n?n:i,y={declarations:{...c?{...r.resolveRecipeVariant(c).base}:{},...io(g,v,b)}};return s&&(y.breakpoint=s,y.query=null!=a?a:"exact"),f&&(y.container=f,u&&(y.size=u),y.query=null!=a?a:"min"),l&&(y.state=l),p&&(y.orientation=p),d&&(y.target=d),y});return{base:s,responsive:a}})(0,t,r)},lo=new Set(["breakpoint","query","state","variant","target","orientation"]),co={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"},po={duration:"duration",easing:"easing",delay:"delay"},fo=(e,t)=>"base"===t?`animation.${e}`:`animation.${e}.${t}`,uo=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(void 0===n||""===n||lo.has(r))continue;const e=co[r];e&&(t[e]="keyframes"===r?{ref:`animation.keyframes.${n}`}:po[r]?{ref:fo(po[r],String(n))}:{value:n})}return t},mo=new Set(["keyframes","recipes"]),ho=e=>e&&"object"==typeof e&&"ref"in e?{ref:String(e.ref)}:"string"==typeof e||"number"==typeof e?{value:e}:void 0,go=e=>{const t={};for(const[r,n]of Object.entries(e)){const e=ho(n);e&&(t[r]=e)}return t},vo=e=>{const t=[];for(const[r,n]of Object.entries(e))t.push({stop:r,declarations:go(n)});return{steps:t}},bo=e=>{if(!e||"object"!=typeof e)return{};const t={};for(const[r,n]of Object.entries(e))n&&"object"==typeof n&&(t[r]=vo(n));return t},yo={key:"animation",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(mo.has(n))continue;const e=ut(o,{propertyPath:`animation.${n}`,allowedBreakpoints:t.allowedBreakpoints});ot(e,{propertyPath:`animation.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:uo(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:i,target:s,orientation:a,container:l,size:c,...d}=e,p={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...uo(d)}};return t&&(p.breakpoint=t,p.query=null!=n?n:"exact"),l&&(p.container=l,c&&(p.size=c),p.query=null!=n?n:"min"),o&&(p.state=o),s&&(p.target=s),a&&(p.orientation=a),p})}))(0,t,r),buildStructural:e=>({ruleSetGroups:{},configProperties:{},keyframes:bo(e.keyframes)})},wo=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e))t[xo(r)]=$o(n);return t},$o=e=>"object"==typeof e?{ref:e.ref}:{value:e},xo=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ko={key:"components",normalizeProperties:()=>({}),interpretRecipe:(e,t,r)=>((e,t)=>({base:wo(t.base.css),responsive:t.responsive.map(e=>{var t,r;const n=e,o={declarations:wo(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))qe.has(r)&&"string"==typeof n&&n.includes(".")&&t.push(`${r}:${n}`);return t})(e)},jo=e=>({value:e}),So=e=>({ref:e}),Ao=(e,t)=>({kind:"reset",selector:e,declarations:t,overrides:[]}),Eo=e=>{const t={};for(const[r,n,o]of e){const e={};for(const[t,r]of Object.entries(o))e[t]=jo(r);t[r]=Ao(n,e)}return t},Ro=[["h1","4xl"],["h2","3xl"],["h3","2xl"],["h4","xl"],["h5","lg"],["h6","md"]],Co={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}},Oo=Object.keys(Co),To=e=>{if(!1===e)return{};const t=Co[e];if(!t)throw new je("REFRACT_E_PRESET",`globals: unknown preset "${e}" — expected one of ${Oo.join(", ")} or false`);const r={static:Eo(t.static)};return t.headings&&(r.defaults=(()=>{const e={};for(const[t,r]of Ro)e[t]=Ao(t,{"font-size":So(`typography.fontSize.${r}`)});return e})()),r},Fo=new Set(["state","breakpoint","query","orientation","container","size","variant","target"]),No=e=>null!==e&&"object"==typeof e?{ref:e.ref}:{value:e},_o=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),zo=e=>{const t={};for(const[r,n]of Object.entries(e))null==n||Fo.has(r)||(t[_o(r)]=No(n));return t},Po=e=>{const t={declarations:zo(e)},r=e;for(const e of Fo)void 0!==r[e]&&(t[e]=r[e]);return t},Mo=(e,t,r)=>(e=>({declarations:zo(e.base),overrides:e.responsive.map(Po)}))(St({[e]:t},r)[e]),qo=(e,t)=>{const r=null!=e?e:{},n={};if(void 0!==r.preset){const e=To(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,i]of Object.entries(e)){if(!i||"object"!=typeof i)continue;const e={propertyPath:`globals.elements.${o}`,allowedBreakpoints:r,allowedStates:t.allowedStates,allowedContainers:t.allowedContainers},{variants:s,...a}=i,l=Mo(o,a,e),c={kind:"globals",selector:o,declarations:l.declarations,overrides:l.overrides};if(s&&"object"==typeof s&&Object.keys(s).length){const t={};for(const[r,n]of Object.entries(s))n&&"object"==typeof n&&(t[r]=Mo(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},Lo=[rn,un,Mn,Qn,ao,yo,ko,{key:"globals",normalizeProperties:()=>({}),buildStructural:(e,t)=>({ruleSetGroups:qo(e,t),configProperties:{}})}];const Io=(e,t)=>Lt(e,e=>Vt(e,Wt(t))),Bo=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},Uo=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},Wo=(e,t)=>{if(e.startsWith("--"))return e;const r=e.split(".").join("-").toLowerCase();return t?`--${t}-${r}`:`--${r}`};function Do(e,t,r){const{clean:n,externals:o}=((e,t)=>{if(!e)return{clean:e,externals:{}};const r={},n={};for(const[o,i]of Object.entries(e))if(null===i||"object"!=typeof i||Array.isArray(i)||"string"!=typeof i.external)r[o]=i;else{const e=Wo(i.external,t);n[o]={base:`var(${e})`,external:e,responsive:[]}}return{clean:r,externals:n}})(t,r.extendsPrefix),i=e.normalizeProperties(n,{allowedBreakpoints:r.allowedBreakpoints});Object.assign(i,o);const s=r.inheritedProperties?{...r.inheritedProperties,...i}:i,a=function(e,t,r){var n,o;if(!e.interpretRecipe||!t||!Object.keys(t).length)return{};const i={};for(const[s,a]of Object.entries(t)){const t=`${e.key}.recipes.${s}`,l=St(a,{propertyPath:t,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers}),c=Ot(l,(n,o,i)=>e.interpretRecipe(n,o,{breakpoints:r.breakpoints,media:r.media,properties:r.properties,resolveRecipeVariant:i,groupPath:t}),{groupPath:t}).resolveAll(),d={};for(const[t,r]of Object.entries(c))if(e.extractReferences){const i=e.extractReferences(null!==(o=null===(n=l[t])||void 0===n?void 0:n.base)&&void 0!==o?o:{});d[t]=Me(r,i)}else d[t]=Pe(r);i[s]=d}return i}(e,null==t?void 0:t.recipes,{breakpoints:r.breakpoints,media:r.media,properties:s,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});let l,c,d=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});d={...n.ruleSetGroups,...a},Object.keys(n.configProperties).length&&(l=n.configProperties),n.keyframes&&Object.keys(n.keyframes).length&&(c=n.keyframes)}const p={};return Object.keys(i).length&&(p.properties=i),Object.keys(d).length&&(p.ruleSetGroups=d),l&&(p.extraProperties=l),c&&(p.keyframes=c),p}function Vo(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 Ho(e,t){var r,n,o,i,s;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,s]of Object.entries(t.ruleSets))r[n]={...null!==(i=null===(o=e.ruleSets)||void 0===o?void 0:o[n])&&void 0!==i?i:{},...s};a.ruleSets=r}return t.keyframes&&(a.keyframes={...null!==(s=e.keyframes)&&void 0!==s?s:{},...t.keyframes}),a}function Go(e,t){var r,n,o,i;const{adapter:s}=t,a=e,l=null!==(r=a.breakpoints)&&void 0!==r?r:Gt,c=Object.keys(l),d=null!==(o=null===(n=a.extends)||void 0===n?void 0:n.prefix)&&void 0!==o?o:"dt",p=s.allowedStates,f=new Set(null!==(i=a.modes)&&void 0!==i?i:["dark","light"]),u=t.media,m=Io(l,u),h=Bo(a.containers),g=Uo(h),v={};for(const e of Lo){const t=Do(e,a[e.key],{breakpoints:l,extendsPrefix:d,media:m,mediaConfig:u,allowedBreakpoints:c,allowedStates:p,allowedContainers:g});Object.keys(t).length&&(v[e.key]=t)}const b=(e=>{var t;const r={},n=Ie(e.colors);n&&(r.colors=n);const o=Ie(e.typography);o&&(r.typography=o);const i=Ie(e.layout);i&&(r.layout=i);const s=Ie(e.effects);s&&(r.effects=s);const a=Ie(e.borders);a&&(r.borders=a);const l=Ie(e.animation);l&&(r.animation=l),Le(null===(t=e.components)||void 0===t?void 0:t.ruleSetGroups)&&(r.components={ruleSets:e.components.ruleSetGroups});const c=Ie(e.globals);c&&(r.globals=c);const d={breakpoints:e.breakpoints,subsystems:r};return e.containers&&Object.keys(e.containers).length&&(d.containers=e.containers),d})({breakpoints:l,containers:h,...v}),y={units:t.units,baseFontSize:t.baseFontSize},w=function(e,t){var r;const{propertiesOverlay:n,ruleSetsOverlay:o,keyframesOverlay:i,containersOverlay:s}=t;if(!(n||o||i||s))return e;const a={...e.subsystems},l=new Set([...Object.keys(null!=n?n:{}),...Object.keys(null!=o?o:{}),...Object.keys(null!=i?i:{})]);for(const e of l)a[e]=Ho(a[e],{properties:null==n?void 0:n[e],ruleSets:null==o?void 0:o[e],keyframes:null==i?void 0:i[e]});const c={...e,subsystems:a};return s&&(c.containers={...null!==(r=e.containers)&&void 0!==r?r:{},...s}),c}(tt(b,y),t),$=(e=>{const t={};for(const r of e)for(const[e,n]of Object.entries(r)){if(e in t)throw new je("REFRACT_E_TOKEN_PATH",`Duplicate derivation fn "${e}" registered by two subsystems.`);t[e]=n}return t})(Lo.flatMap(e=>e.derivations?[e.derivations]:[])),x=Pt(w,$),k=[...Jo(x),...Ko(x),...Xo(x),...Yo(x,f)];if(k.length>0){const e=k.map(e=>` - ${e}`).join("\n");throw new je("REFRACT_E_VALIDATION",`refract: ${k.length} validation error(s):\n${e}`,k)}return Zo(x,{adapter:s,derivationRegistry:$,allowedStates:p,mediaConfig:u,unitConfig:y})}function Yo(e,t){var r,n,o;const i=[],s=(e,r,n,o)=>{t.has(n)||i.push(`${e}.${r}${o}: unknown appearance mode '${n}' — declare it in the top-level 'modes' registry (known: ${[...t].join(", ")})`)};for(const[t,i]of Object.entries(e.subsystems))for(const[e,a]of Object.entries(null!==(r=i.properties)&&void 0!==r?r:{})){for(const r of null!==(n=a.modes)&&void 0!==n?n:[])r.mode&&s(t,e,r.mode,"");for(const r of null!==(o=a.responsive)&&void 0!==o?o:[])r.mode&&s(t,e,r.mode," (responsive)")}return i}function Jo(e){var t,r,n,o,i;const s=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!s)return[];const a=[];for(const[t,l]of Object.entries(s))for(const[s,c]of Object.entries(l))for(const l of null!==(r=c.references)&&void 0!==r?r:[]){const[r,c=""]=l.split(":"),d=c.indexOf("."),p=d>=0?c.slice(0,d):c,f=d>=0?c.slice(d+1):"";(null===(i=null===(o=null===(n=e.subsystems[r])||void 0===n?void 0:n.ruleSets)||void 0===o?void 0:o[p])||void 0===i?void 0:i[f])||a.push(`components.${t}.${s}: Recipe variant "${f}" is not defined in "${r}:${p}". Check the subsystem:group.variant reference against what the subsystem declares.`)}return a}function Ko(e){var t,r;const n=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!n)return[];const o=Be(e),i=[],s=(e,t,r,n)=>{for(const[s,a]of Object.entries(null!=e?e:{}))void 0===a.ref||a.ref in o||i.push(`components.${t}.${r}: css '${s}'${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)){s(o.declarations,e,n,"");for(const t of null!==(r=o.overrides)&&void 0!==r?r:[])s(t.declarations,e,n," (override)")}return i}function Xo(e){var t,r,n,o,i;const s=null===(t=e.subsystems.globals)||void 0===t?void 0:t.ruleSets;if(!s)return[];const a=Be(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(s))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!==(i=n.overrides)&&void 0!==i?i:[])c(r.declarations,e,`${t} (override)`)}}return l}function Zo(e,t){var r;const n=Io(e.breakpoints,t.mediaConfig),o=Yt(e.containers,t.mediaConfig),i=new WeakMap,s=()=>{let t=i.get(e);return t||(t=Be(e),i.set(e,t)),t},a=e=>Tt(s(),t.derivationRegistry,e),l={media:n,containers:o,resolve:a},c=t.adapter.bind(e,l),d={model:e,get tokens(){return s()},resolveToken:a,override:r=>function(e,t,r){var n,o,i;const s=t.breakpoints,a=s?{...e.breakpoints,...s}:e.breakpoints,l=Object.keys(a),c=Io(a,r.mediaConfig),d=Bo(t.containers),p=d?{...null!==(n=e.containers)&&void 0!==n?n:{},...d}:e.containers,f=Uo(p),u={...e.subsystems};for(const n of Lo){const s=t[n.key];if(void 0===s)continue;const d=Vo(e.subsystems[n.key]),p=Do(n,s,{breakpoints:a,extendsPrefix:null!==(i=null===(o=t.extends)||void 0===o?void 0:o.prefix)&&void 0!==i?i:"dt",media:c,mediaConfig:r.mediaConfig,allowedBreakpoints:l,allowedStates:r.allowedStates,allowedContainers:f,inheritedProperties:d}),m=Ie(p);m&&(u[n.key]=Ho(e.subsystems[n.key],m))}const m={breakpoints:a,subsystems:u};p&&Object.keys(p).length&&(m.containers=p);const h=tt(m,r.unitConfig),g=Pt(h,r.derivationRegistry);return Zo(g,r)}(e,r,t)},p=null===(r=c.extend)||void 0===r?void 0:r.call(c,d);return p&&Object.defineProperties(d,Object.getOwnPropertyDescriptors(p)),d}const Qo="theme.css",ei="styles.css",ti="variables.css",ri=(e,t)=>"variables"===t?`${e}.variables.css`:`${e}.css`,ni=e=>`${e.group}-${e.variant}.css`,oi="variables.css";function ii(e){var t,r,n,o,i,s,a,l;if(void 0===e)return{type:"single",file:Qo};if("string"==typeof e)switch(e){case"single":return{type:"single",file:Qo};case"split":return{type:"split",file:ei,variables:ti};case"subsystem":return{type:"subsystem",filename:ri};case"components":return{type:"components",inline:!0,filename:ni,variables:oi}}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:Qo};case"split":{const t=e;return{type:"split",file:null!==(n=t.file)&&void 0!==n?n:ei,variables:null!==(o=t.variables)&&void 0!==o?o:ti}}case"subsystem":return{type:"subsystem",filename:null!==(i=e.filename)&&void 0!==i?i:ri};case"components":{const t=e;return{type:"components",inline:null===(s=t.inline)||void 0===s||s,filename:null!==(a=t.filename)&&void 0!==a?a:ni,variables:null!==(l=t.variables)&&void 0!==l?l:oi}}}throw new Error("resolveEmitPlan: unrecognized emit directive.")}const si="com.theme-registry.refract",ai=e=>"object"==typeof e&&null!==e&&"$value"in e,li=/^\{([^}]+)\}$/,ci=(e,t,r=new Set)=>{if("string"==typeof e){const n=e.match(li);if(n){const o=n[1];if(r.has(o))throw new je("REFRACT_E_CYCLE",`Circular token reference: ${o}`);const i=t.get(o);return i?(r.add(o),ci(i.value,t,r)):e}return e}if(Array.isArray(e))return e.map(e=>ci(e,t,new Set(r)));if("object"==typeof e&&null!==e){const n={};for(const[o,i]of Object.entries(e))n[o]=ci(i,t,new Set(r));return n}return e};function di(e){var t;const r=[];for(const[n,o]of Object.entries(e.subsystems))for(const[e,i]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(i))r.push({subsystem:n,group:e,variant:t});return r}function pi(){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,i,s;const a=e.bind(t,r),l=null!==(n=a.renderAllRecipes)&&void 0!==n?n:()=>a.join(di(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))),d=null!==(i=a.renderAll)&&void 0!==i?i:()=>a.join([c(),l()]),p=null!==(s=a.describeUsage)&&void 0!==s?s:()=>({format:e.name,summary:[`This theme was built with the "${e.name}" refract adapter.`],recipes:di(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:d,describeUsage:p}}};var e}const fi=(e,t)=>{var r,n,o;const i=(e=>{const t=[],r=new Map,n=(e,o,i)=>{var s,a,l;const c=null!==(s=e.$type)&&void 0!==s?s:i;for(const[i,s]of Object.entries(e)){if(i.startsWith("$"))continue;if("object"!=typeof s||null===s)continue;const e=[...o,i];if(ai(s)){const n=s,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(s,e,c)}};n(e,[]);for(const e of t)e.value=ci(e.value,r);return t})(e),s=null!==(r=null==t?void 0:t.groupMapping)&&void 0!==r?r:{},a={},l={},c={},d={},p={};let f=null!==(n=null==t?void 0:t.breakpoints)&&void 0!==n?n:{};const u=new Map;for(const e of i){const t=e.path[0];u.has(t)||u.set(t,[]),u.get(t).push(e)}const m=null==t?void 0:t.breakpointGroup;if(m&&u.has(m)){f={};for(const e of u.get(m)){f[e.path[e.path.length-1]]=Ri(e.value)}u.delete(m)}for(const[e,t]of u){const r=null!==(o=s[e])&&void 0!==o?o:ui(e,t);if("ignore"!==r)switch(r){case"colors":gi(t,e,a);break;case"typography":bi(t,e,l);break;case"effects":$i(t,e,c);break;case"borders":ki(t,e,d);break;case"layout":Si(t,e,p)}}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(d).length&&(h.borders=d),Object.keys(p).length&&(h.layout=p),h},ui=(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"},mi=/^\{([^}]+)\}$/,hi=e=>{if("string"!=typeof e)return;const t=e.match(mi);if(!t)return;const r=t[1],n=r.indexOf("."),o=n<0?r:r.slice(0,n),i=n<0?"":r.slice(n+1),s="color"===o?"colors":o;return i?`${s}.${i}`:s},gi=(e,t,r)=>{var n;const o=new Map,i=[];for(const t of e)if(t.path.length<=2)i.push(t);else{const e=t.path[1];o.has(e)||o.set(e,[]),o.get(e).push(t)}for(const e of i){const t=e.path[e.path.length-1];if(!r[t]){const n=hi(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],i={};for(const e of t){if(e===o)continue;i[e.path.slice(2).join("-")]=String(e.value)}r[e]={base:String(o.value),...Object.keys(i).length?{variants:i}:{}}}},vi={fontfamily:"fontFamily",fontsize:"fontSize",fontweight:"fontWeight",lineheight:"lineHeight",letterspacing:"letterSpacing",fontstyle:"fontStyle",texttransform:"textTransform",textdecoration:"textDecoration",textalign:"textAlign"},bi=(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&&yi(r,"fontFamily",Array.isArray(e.fontFamily)?e.fontFamily.join(", "):e.fontFamily,t),e.fontSize&&yi(r,"fontSize",Ci(e.fontSize),t),void 0!==e.fontWeight&&yi(r,"fontWeight",e.fontWeight,t),void 0!==e.lineHeight&&yi(r,"lineHeight",e.lineHeight,t),e.letterSpacing&&yi(r,"letterSpacing",e.letterSpacing,t)}else{const e=wi(n,t);if(!e)continue;const o=n.path[n.path.length-1],i="fontFamily"===n.type&&Array.isArray(n.value)?n.value.join(", "):"dimension"===n.type?Ci(n.value):n.value;yi(r,e,i,o)}},yi=(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},wi=(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(vi))if(r.includes(e))return t;const n=t.toLowerCase();for(const[e,t]of Object.entries(vi))if(n.includes(e))return t;return null},$i=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"shadow":{const n=Ai(t.value);xi(r,"shadow",n,e);break}case"transition":{const n=t.value,o=n.timingFunction?`cubic-bezier(${n.timingFunction.join(", ")})`:"ease",i=`all ${n.duration} ${o}`;xi(r,"transitions",i,e);break}case"dimension":t.path.join(".").toLowerCase().includes("blur")&&xi(r,"blur",Ci(t.value),e);break;case"number":{const n=t.path.join(".").toLowerCase();n.includes("opacity")?xi(r,"opacity",t.value,e):(n.includes("z-index")||n.includes("zindex"))&&xi(r,"zIndex",t.value,e);break}}}},xi=(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},ki=(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;ji(r,"width",Ci(n.width),e),n.style&&ji(r,"style",n.style,e);break}case"strokeStyle":ji(r,"style",String(t.value),e);break;case"dimension":{const n=t.path.join(".").toLowerCase();n.includes("radius")?ji(r,"radius",Ci(t.value),e):n.includes("offset")?ji(r,"offset",Ci(t.value),e):n.includes("width")&&ji(r,"width",Ci(t.value),e);break}}}},ji=(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},Si=(e,t,r)=>{for(const t of e){if("dimension"!==t.type)continue;const e=t.path[t.path.length-1],n=Ri(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}},Ai=e=>Array.isArray(e)?e.map(e=>Ei(e)).join(", "):Ei(e),Ei=e=>{const t=[];return e.inset&&t.push("inset"),t.push(e.offsetX,e.offsetY,e.blur,e.spread,e.color),t.join(" ")},Ri=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?0:e.endsWith("rem")?Math.round(16*t):t},Ci=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?e:e.endsWith("px")?t:e},Oi=(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 i=Fi(e),s=t=>{try{return String(e.resolveToken(t))}catch{return t}},a=i.get("colors");if(a){const e={$type:"color"};for(const[t,r]of a){const n={};void 0!==r.base&&(n.base={$value:B(String(r.base))});for(const[e,t]of Object.entries(r.members))n[e]={$value:B(String(t))};e[t]=n}n.color=e}const l=i.get("typography");if(l){const e={};for(const[t,r]of l){const n={$type:Ni(t)};void 0!==r.base&&(n.base={$value:_i(r.base,r.baseUnit)});for(const[e,t]of Object.entries(r.members))n[e]={$value:_i(t,r.memberUnits[e])};e[t]=n}n.typography=e}const c=i.get("effects");if(c)for(const[e,t]of c){const{groupName:r,type:o}=zi(e);n[r]||(n[r]={$type:o});const i=n[r];void 0!==t.base&&(i.base={$value:Pi(e,t.base,s,t.baseUnit)});for(const[r,n]of Object.entries(t.members))i[r]={$value:Pi(e,n,s,t.memberUnits[r])}}const d=i.get("borders");if(d)for(const[e,t]of d){const{groupName:r,type:o}=Mi(e);n[r]||(n[r]={$type:o});const i=n[r];void 0!==t.base&&(i.base={$value:qi(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))i[e]={$value:qi(r,t.memberUnits[e])}}const p=i.get("layout");if(p)for(const[e,t]of p){if(e.includes("--"))continue;const r=e;n[r]||(n[r]={$type:"dimension"});const o=n[r];void 0!==t.base&&(o.base={$value:Li(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))o[e]={$value:Li(r,t.memberUnits[e])}}if(null==t?void 0:t.includeRecipes){const t=(e=>{const t={},r={},n={};for(const[o,i]of Object.entries(e.subsystems))i.properties&&Object.keys(i.properties).length&&(t[o]=i.properties),i.ruleSets&&Object.keys(i.ruleSets).length&&(r[o]=i.ruleSets),i.keyframes&&Object.keys(i.keyframes).length&&(n[o]=i.keyframes);const o=Object.keys(t).length>0,i=Object.keys(r).length>0,s=Object.keys(n).length>0,a=!!e.containers&&Object.keys(e.containers).length>0;if(o||i||s||a)return{version:1,...o?{properties:t}:{},...i?{ruleSets:r}:{},...s?{keyframes:n}:{},...a?{containers:e.containers}:{}}})(e.model);t&&(n.$extensions={...null!==(r=n.$extensions)&&void 0!==r?r:{},[si]:t})}return n},Ti=(e,t)=>void 0!==t?`${e}${t}`:e,Fi=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),i=r.slice(n+1),s=i.indexOf("."),a=s<0?i:i.slice(0,s),l=s<0?void 0:i.slice(s+1),c=e.tokens[r];if(void 0!==(null==c?void 0:c.external))continue;let d;if(void 0!==(null==c?void 0:c.struct))d=c.struct;else try{d=e.resolveToken(r)}catch{continue}const p=null==c?void 0:c.unit;let f=t.get(o);f||(f=new Map,t.set(o,f));let u=f.get(a);u||(u={members:{},memberUnits:{}},f.set(a,u)),void 0===l?(u.base=d,void 0!==p&&(u.baseUnit=p)):(u.members[l]=d,void 0!==p&&(u.memberUnits[l]=p))}return t},Ni=e=>{switch(e){case"fontFamily":return"fontFamily";case"fontWeight":return"fontWeight";case"fontSize":case"letterSpacing":return"dimension";default:return"number"}},_i=(e,t)=>Ti(e,t),zi=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"}}},Pi=(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):Ti(t,n),Mi=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"}}},qi=(e,t)=>Ti(e,t),Li=(e,t)=>Ti(e,t);async function Ii(r){var n,o;const{raw:i,adapter:s,outDir:a,helpers:d=[],emit:f,media:u,units:h,baseFontSize:g,guide:v,preview:b}=r,y=Go(i,{adapter:s,media:u,units:h,baseFontSize:g}),$=Lt(y.model.breakpoints,e=>Vt(e,Wt(u))),x=Yt(y.model.containers,u),k=s.bind(y.model,{media:$,containers:x,resolve:y.resolveToken});if(!k.emit)throw new Error(`Adapter "${s.name}" does not implement emit(); it cannot build to disk.`);const j=ii(f),S=k.emit(j),A=[];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"),A.push(o)};for(const[e,t]of Object.entries(S.files))E(e,t);for(const[e,t]of Object.entries(null!==(n=S.vendorHelpers)&&void 0!==n?n:{}))E(e,t);for(const e of d){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(p(t.source)))}if(v){const e=!0===v?{}:v,t=w(k.describeUsage(),Oi(y),{files:Object.keys(S.files),packageName:e.packageName,llmsFile:e.llmsFile,manifestFile:e.manifestFile});for(const[e,r]of Object.entries(t.files))E(e,r)}if(b){const e=!0===b?{}:b,t=Object.keys(S.files),r=ke({usage:k.describeUsage(),preview:null===(o=k.describePreview)||void 0===o?void 0:o.call(k,j,t),tokens:Oi(y),model:y.model},{files:t,contents:S.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:A}}const Bi="theme.config",Ui=[".ts",".mjs",".js"],Wi=(r=process.cwd())=>{for(const n of Ui){const o=t.join(r,`${Bi}${n}`);if(e.existsSync(o))return o}};let Di=0;async function Vi(n={}){var o,i,s;const a=null!==(o=n.cwd)&&void 0!==o?o:process.cwd(),l=n.configPath?t.resolve(a,n.configPath):Wi(a);if(!l||!e.existsSync(l)){const e=n.configPath?`"${n.configPath}"`:`${Bi}.(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=${++Di}`;return await import(t)}const{entry:n,cleanup:o}=await v(e);try{return await import(r.pathToFileURL(n).href)}finally{o()}}(l),d=null!==(s=null!==(i=c.default)&&void 0!==i?i:c.config)&&void 0!==s?s:c;if(!d||"object"!=typeof d||!Array.isArray(d.targets))throw new Error(`"${l}" must export (default) a defineConfig({ raw, targets }) object.`);return{config:d,path:l}}const Hi="@theme-registry/refract-css";function Gi(){var r;const n=t.join(d(),"package.json");return null!==(r=JSON.parse(e.readFileSync(n,"utf8")).name)&&void 0!==r?r:"@theme-registry/refract"}const Yi="theme.raw",Ji=[".ts",".mts",".mjs",".js",".json"],Ki=(r=process.cwd())=>{for(const n of Ji){const o=t.join(r,`${Yi}${n}`);if(e.existsSync(o))return{path:o,filename:`${Yi}${n}`,ext:n}}};function Xi(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?`./${Yi}`:`./${e.filename}`}";\n`,expression:"raw"}}function Zi(e,t){const{head:r,expression:n}=Xi(t);return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${Hi}";\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 Qi(e){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${Hi}";\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 es(r={}){var n,o,i,s;const a=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),l=null!==(o=r.variant)&&void 0!==o?o:"ts",c=null!==(i=r.packageName)&&void 0!==i?i:Gi(),d=t.join(a,`theme.config.${l}`);if(e.existsSync(d)&&!r.force)throw new Error(`theme.config.${l} already exists at "${d}". Pass --force to overwrite it.`);const p=null===r.rawTheme?void 0:null!==(s=r.rawTheme)&&void 0!==s?s:Ki(a),f=p?Zi(c,p):Qi(c);return e.writeFileSync(d,f,"utf8"),{path:d,variant:l,packageName:c,rawTheme:p}}const ts=[["xs",-2],["sm",-1],["md",0],["lg",1],["xl",2],["2xl",3],["3xl",4],["4xl",5]],rs={"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},ns={complement:[180],analogous:[-30,30],"split-complement":[150,210],triadic:[120,240],tetradic:[90,180,270],pentadic:[72,144,216,288]},os=["primary","secondary","tertiary","quaternary","quinary"],is=[["success","#2f9e44","#ffffff"],["info","#1c7ed6","#ffffff"],["warning","#e89012","#1f2733"],["danger","#e03131","#ffffff"]],ss=[50,100,200,300,400,500,600,700,800,900],as=[8,14,22],ls="system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",cs="ui-monospace, 'SF Mono', Menlo, Consolas, monospace",ds={neutral:{label:"Neutral",blurb:"system type, comfortable spacing, soft corners",fontFamily:{base:ls,mono:cs},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:ls,mono:cs},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:cs},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:cs,mono:cs},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"}},ps=(e,t)=>Number(e.toFixed(t)),fs=e=>A(R(e).rgb),us=e=>ps(Math.min(1.7,Math.max(1.1,1.5*Math.pow(16/e,.22))),2),ms=e=>`${ps(.36/e-.0225,3)}em`,hs=e=>{const t=1e3-10*e;let r=ss[0];for(const e of ss)Math.abs(e-t)<Math.abs(r-t)&&(r=e);return r},gs=e=>{if(!(e<=1))return 2===e?"complement":3===e?"triadic":4===e?"tetradic":"pentadic"},vs=e=>Object.keys(ns).filter(t=>ns[t].length===e-1);function bs(e){var t,r,n,o,i,s,a,l,c;const d=null!==(t=e.mode)&&void 0!==t?t:"auto",p=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)),u=null!==(o=e.baseFontSize)&&void 0!==o?o:16,m=null!==(i=e.ratio)&&void 0!==i?i:p.ratio,h=rs[m];if(!h)throw new Error(`Unknown type ratio "${m}". Use one of: ${Object.keys(rs).join(", ")}.`);const g=fs(e.seed),v=[{name:os[0],hex:g,rotation:0}];if("manual"===d)(null!==(s=e.extraColors)&&void 0!==s?s:[]).slice(0,os.length-1).forEach((e,t)=>{v.push({name:os[t+1],hex:fs(e),rotation:0})});else if(f>1){const t=null!==(a=e.scheme)&&void 0!==a?a:gs(f),r=ns[t];if(!r)throw new Error(`Unknown harmony scheme "${t}".`);r.slice(0,f-1).forEach((e,t)=>{v.push({name:os[t+1],hex:fs(L(g,e)),rotation:e})})}const b=null!==(l=e.contrast)&&void 0!==l?l:"AA",y=[...v.map(e=>({name:e.name,base:e.hex,text:"#ffffff"})),...!1===e.semantics?[]:is.map(([e,t,r])=>({name:e,base:t,text:r})),...!1===e.neutral?[]:[{name:"neutral",base:"#6b7280",text:"#ffffff"}]],{palettes:w,adjustments:$}="none"===b?{palettes:y,adjustments:[]}:function(e,t){var r;const n=e.map(e=>({...e})),o=new Map(n.map(e=>[e.name,0])),i=new Map,s=()=>{var e,r;const o={};for(const e of n)o[e.name]={base:e.base,text:e.text};const i=Go({colors:o},{adapter:pi()}),s=Zr(i,{minWcag:t,includeRecipes:!1}),a=new Map;for(const t of s.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=s();for(const[e,t]of a)i.has(e)||i.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=fs(M(t.base,1)),o.set(t.name,(null!==(r=o.get(t.name))&&void 0!==r?r:0)+1);a=s()}const l=n.map((t,r)=>{var n,s,l,c;const d=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:ps(null!==(s=i.get(t.name))&&void 0!==s?s:0,2),ratioAfter:ps(null!==(l=null==d?void 0:d.ratio)&&void 0!==l?l:0,2),levelAfter:null!==(c=null==d?void 0:d.level)&&void 0!==c?c:"fail",unresolved:!!d&&!d.pass}});return{palettes:n,adjustments:l}}(y,b),x={};for(const e of w)x[e.name]={base:e.base,text:e.text,steps:[...ss]};if(!1!==e.shadows){const e={};for(const t of as)e[`a${String(t).padStart(2,"0")}`]={modifiers:[{alpha:t}]};x.shadow={base:"#18274b",variants:e}}const k=ts.map(([e,t])=>({step:e,px:ps(u*Math.pow(h,t),2)})),j={},S={};for(const{step:e,px:t}of k)"md"!==e&&(j[e]=us(t),S[e]=ms(t));S.caps="0.06em";const A={fontFamily:{base:p.fontFamily.base,variants:{mono:p.fontFamily.mono}},fontWeight:{base:400,variants:{medium:500,semibold:600,bold:700}},fontSize:{base:u,ratio:m},lineHeight:{base:us(u),variants:j},letterSpacing:{base:"0em",variants:S}},E={spacing:{base:4,step:4,steps:{...p.spacing}}},C={width:{base:1,variants:{thick:2}},style:{base:"solid"},radius:{base:p.radius.base,variants:{...p.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"}}},T={colors:x,typography:A,layout:E,borders:C,...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"}}},F=ps(N(R(g).rgb).L,1);return{raw:T,report:{seedLightness:F,nearestStep:hs(F),brand:v.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:k.map(({step:e,px:t})=>({step:e,px:t,leading:us(t),tracking:ms(t)})),spacing:Object.entries(p.spacing).map(([e,t])=>({step:e,px:4*t}))}}}const ys="theme.raw",ws=/^[A-Za-z_$][A-Za-z0-9_$]*$/,$s=e=>JSON.stringify(e);function xs(e,t=0){const r=" ".repeat(t),n=" ".repeat(t+1);if(null===e)return"null";if("string"==typeof e)return $s(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=>xs(e)).join(", ")}]`;if(r.length+t.length<=76)return t}return`[\n${e.map(e=>`${n}${xs(e,t+1)}`).join(",\n")}\n${r}]`}const o=Object.entries(e);if(!o.length)return"{}";return`{\n${o.map(([e,r])=>{const o=ws.test(e)?e:$s(e);return`${n}${o}: ${xs(r,t+1)}`}).join(",\n")}\n${r}}`}const ks=(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 js(e,t){if("json"===t.format)return`${JSON.stringify(e,null,2)}\n`;const r=xs(e);return"js"===t.format?`${ks(t.seed,t.detail)}\n/** @type {import("${t.packageName}/build").RawTheme} */\nexport const raw = ${r};\n`:`${ks(t.seed,t.detail)}import type { RawTheme } from "${t.packageName}/build";\n\nexport const raw = ${r} satisfies RawTheme;\n`}function Ss(e){var t,r,n,o,i,s;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!==(i=e.feel)&&void 0!==i?i:"neutral"),"none"!==e.contrast&&a.push(`WCAG ${null!==(s=e.contrast)&&void 0!==s?s:"AA"}`),a.join(" · ")}function As(r){var n,o,i,s;const a=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),l=null!==(o=r.format)&&void 0!==o?o:"ts",c=null!==(i=r.out)&&void 0!==i?i:`${ys}.${l}`,d=t.join(a,c);if(e.existsSync(d)&&!r.force)throw new Error(`"${c}" already exists. Re-run with --force to overwrite it.`);const{raw:p,report:f}=bs(r),u=js(p,{format:l,packageName:null!==(s=r.packageName)&&void 0!==s?s:Gi(),seed:r.seed,detail:Ss(r)});return e.writeFileSync(d,u,"utf8"),{path:d,format:l,raw:p,report:f,sections:Object.keys(p)}}const Es=()=>Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR,Rs=(e,t)=>Es()?`[${e}m${t}[0m`:t,Cs=e=>Rs("1",e),Os=e=>Rs("2",e),Ts=e=>Rs("36",e),Fs=e=>Rs("32",e),Ns=e=>Rs("33",e),_s=e=>e>0?`[${e}A`:"",zs="[0J";function Ps(e,t=2){if(!Es())return"";const r=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!r)return"";const n=parseInt(r[1],16),[o,i,s]=[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};${i};${s}`:`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,i,s)}`;var l;return`[${a}m${" ".repeat(t)}[0m`}function Ms(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 qs(e){const t=[];for(let r=0;r<e.length;)""===e[r]&&"["===e[r+1]&&r+2<e.length?(t.push(Ms(e.slice(r,r+3))),r+=3):(t.push(Ms(e[r])),r+=1);return t}function Ls(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 Is=()=>Boolean(process.stdin.isTTY)&&"function"==typeof process.stdin.setRawMode;class Bs{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(`${Ts("?")} ${Cs(e)} ${Os(`(${t})`)} `)).trim()||t,o=null==r?void 0:r(n);if(!o)return n;this.write(` ${Ns("!")} ${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,i;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(Is()){return t[null!==(i=(await this.runList(e,t,{multi:!1,cursor:r,selected:new Set}))[0])&&void 0!==i?i: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(Is()){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 i={cursor:Math.max(0,Math.min(r.cursor,t.length-1)),selected:r.selected,done:!1,cancelled:!1},s=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=()=>{s&&this.out(_s(s)+zs);const r=(()=>{const r=t.map((e,t)=>{var r;const n=t===i.cursor,s=n?Fs("❯"):" ",a=o?i.selected.has(t)?Fs("[✓]"):Os("[ ]"):"",c=n?Cs(e.label):e.label,d=" ".repeat(Math.max(0,l-e.label.length)),p=(null!==(r=e.swatches)&&void 0!==r?r:[]).map(e=>Ps(e)).filter(Boolean).join(" ");return` ${s} ${a?`${a} `:""}${c}${d}${p?` ${p}`:""}${e.hint?` ${Os(e.hint)}`:""}`});return[`${Ts("?")} ${Cs(e)} ${Os(a)}`,...r].join("\n")})();this.out(`${r}\n`),s=r.split("\n").length};return new Promise((r,a)=>{const l=()=>{n.removeListener("data",p),n.removeListener("end",d),n.isTTY&&n.setRawMode(!1),n.pause(),this.out("[?25h")},d=()=>{const e=o?[...i.selected].sort((e,t)=>e-t):[i.cursor];this.out(_s(s)+zs),l(),r(e)},p=n=>{for(const e of qs(n))if(i=Ls(i,e,t.length,o),i.done||i.cancelled)break;if(i.cancelled)return this.out(_s(s)+zs),l(),void a(new Error("Cancelled."));if(i.done){const n=o?[...i.selected].sort((e,t)=>e-t):[i.cursor];this.out(_s(s)+zs);const a=n.length?n.map(e=>t[e].label).join(", "):"none";return this.write(`${Ts("?")} ${Cs(e)} ${Os("›")} ${Fs(a)}`),l(),void r(n)}c()};n.setRawMode(!0),n.resume(),n.setEncoding("utf8"),this.out("[?25l"),n.on("data",p),n.on("end",d),c()})}async selectByNumber(e,t,r){for(this.write(`${Ts("?")} ${Cs(e)}`),t.forEach((e,t)=>{const n=t===r?Fs("❯"):" ",o=e.hint?` ${Os(`— ${e.hint}`)}`:"";this.write(` ${n} ${Os(`${t+1}.`)} ${t===r?Cs(e.label):e.label}${o}`)});;){const e=(await this.question(` ${Os(`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(` ${Ns("!")} Enter a number between 1 and ${t.length}.`)}}async multiselectByNumber(e,t,r){for(this.write(`${Ts("?")} ${Cs(e)} ${Os('(comma-separated, blank = keep, "none" = clear)')}`),t.forEach((e,t)=>{const n=r.includes(t),o=e.hint?` ${Os(`— ${e.hint}`)}`:"";this.write(` ${n?Fs("◉"):Os("◯")} ${Os(`${t+1}.`)} ${e.label}${o}`)});;){const e=(await this.question(` ${Os(`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(` ${Ns("!")} Enter numbers between 1 and ${t.length}, separated by commas.`)}}}const Us={complement:[180],analogous:[-30,30],"split-complement":[150,210],triadic:[120,240],tetradic:[90,180,270],pentadic:[72,144,216,288]},Ws=(e,t)=>{var r;return(null!==(r=Us[t])&&void 0!==r?r:[]).map(t=>A(R(L(e,t)).rgb))},Ds={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"},Vs=[["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"]],Hs=e=>{try{return void R(e)}catch{return`"${e}" isn't a colour refract can parse. Try a hex like #4c6ef5.`}};async function Gs(e,t={}){var r,n,o,i,s,a,l,c;const d=null!==(r=t.seed)&&void 0!==r?r:await e.text("Primary colour","#4c6ef5",Hs),p=Math.round(10*N(R(d).rgb).L)/10,f=A(R(d).rgb),u=Ps(f,3);e.write(` ${u?`${u} `:""}${Os(`${f} · lightness ${p}% — lands at ≈${hs(p)} on the ladder`)}`),e.write();const m=Boolean(t.manual);let h,g=2,v=[];if(m){if(v=(null!==(n=t.colors)&&void 0!==n?n:"").split(",").map(e=>e.trim()).filter(Boolean),!v.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++)v.push(await e.text(`Brand colour ${r+1}`,"#e64980",Hs))}g=v.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=vs(g);h=null!==(o=t.scheme)&&void 0!==o?o:gs(g),!t.scheme&&r.length>1&&(h=await e.select("Harmony scheme",r.map(e=>({value:e,label:e,hint:Ds[e],swatches:[f,...Ws(f,e)]})),Math.max(0,r.indexOf(h)))),h&&g>1&&(e.write(` ${Os(`→ ${h} · each member becomes its own palette with a full ladder`)}`),e.write())}const b=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!==(i=t.contrast)&&void 0!==i?i: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!==(s=t.feel)&&void 0!==s?s:await e.select("Overall feel",Object.keys(ds).map(e=>({value:e,label:ds[e].label,hint:ds[e].blurb}))),x=null!==(a=t.ratio)&&void 0!==a?a:await e.select("Type scale",Vs.map(([e,t])=>({value:e,label:e,hint:t})),Math.max(0,Vs.findIndex(([e])=>e===ds[$].ratio))),k=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:d,mode:m?"manual":"auto",brandCount:g,scheme:h,extraColors:v,...b,contrast:y,baseFontSize:w,ratio:x,feel:$,reset:k,format:j}}function Ys(e,t){const r=[],{contrast:n}=e.report;if(n.length){r.push(` ${Os(`Contrast · ${n.length} pairings checked`)}`);for(const e of n){const t=e.nudge>0?`${Ns(`−${e.nudge}`)} ${Fs(`${e.ratioAfter} ${e.levelAfter}`)}`:Os("unchanged"),n=e.unresolved?` ${Ns("! 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(` ${Os(`${e.sections.length} subsystems · ${t} variables · 0 recipes`)}`),o&&r.push(` ${Os(`${o} colour${1===o?"":"s"} darkened to clear the contrast bar`)}`),r}const Js="theme.config.ts";function Ks(e){const t={};for(const r of e.split(",")){const[e,n]=r.split(":"),o=null==e?void 0:e.trim(),i=Number.parseFloat((null!=n?n:"").trim());o&&Number.isFinite(i)&&(t[o]=i)}return t}function Xs(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 Zs(e,t){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${Hi}";\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 Qs(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 ea(r){var n,o;const i=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),s=null!==(o=r.packageName)&&void 0!==o?o:Gi(),a=t.isAbsolute(r.input)?r.input:t.resolve(i,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 d=fi(l,c),p=r.out?t.isAbsolute(r.out)?r.out:t.resolve(i,r.out):t.resolve(i,"theme.raw.ts");if(e.existsSync(p)&&!r.force)throw new Error(`${t.basename(p)} already exists at "${p}". Pass --force to overwrite it.`);let f;if(e.mkdirSync(t.dirname(p),{recursive:!0}),e.writeFileSync(p,Xs(s,d,JSON.stringify(t.basename(a))),"utf8"),!r.rawOnly){if(f=t.resolve(t.dirname(p),Js),e.existsSync(f)&&!r.force)throw new Error(`${Js} already exists at "${f}". Pass --force to overwrite it, or --raw-only to skip writing a config.`);const n=`./${t.basename(p).replace(/\.(ts|mts|cts|tsx)$/,"")}`;e.writeFileSync(f,Zs(s,n),"utf8")}return{inputFile:a,rawFile:p,configFile:f,sections:Object.keys(d),counts:Qs(d)}}async function ta(e={}){var r;const n=null!==(r=e.cwd)&&void 0!==r?r:process.cwd(),{config:o,path:i}=await Vi({cwd:n,configPath:e.configPath});if(!o.targets.length)throw new Error(`"${i}" has no targets to build.`);const s=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&&s.length>1)throw new Error(`--out is ambiguous across ${s.length} targets; pass --target to pick one first.`);const a=t.dirname(i),l=[];for(const r of s){const i=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),s=await Ii({raw:o.raw,adapter:r.adapter,outDir:i,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:s.outDir,files:s.files})}return{configPath:i,targets:l}}async function ra(r={}){var n;const o=null!==(n=r.cwd)&&void 0!==n?n:process.cwd(),{config:i,path:s}=await Vi({cwd:o,configPath:r.configPath}),a=Go(i.raw,{adapter:pi()}),l=Oi(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:s,outFile:c,groupCount:Object.keys(l).filter(e=>!e.startsWith("$")).length}}async function na(e={}){var t;const r=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:n,path:o}=await Vi({cwd:r,configPath:e.configPath}),i=Go(n.raw,{adapter:pi()});return{configPath:o,result:Zr(i,{strict:e.strict,minWcag:e.minWcag,largeText:e.largeText})}}const oa=(e,t)=>{try{return String(e.resolveToken(t))}catch{return null}},ia=e=>{var t;const r=[];for(const[n,o]of Object.entries(e.model.subsystems))for(const[e,i]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(i))r.push({subsystem:n,group:e,variant:t});return r},sa=(e,t,r,n)=>{var o,i,s;return Boolean(null===(s=null===(i=null===(o=e.model.subsystems[t])||void 0===o?void 0:o.ruleSets)||void 0===i?void 0:i[r])||void 0===s?void 0:s[n])};function aa(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,i=o in t.tokens,s=r?oa(e,o):null,a=i?oa(t,o):null;r&&!i?n.push({path:o,before:s,after:null,kind:"removed"}):!r&&i?n.push({path:o,before:null,after:a,kind:"added"}):s!==a&&n.push({path:o,before:s,after:a,kind:"changed"})}return n.sort((e,t)=>e.path.localeCompare(t.path))})(e,t),n=((e,t)=>{var r,n,o,i,s,a,l,c;const d=e,p=t;if(!d.renderRecipe&&!p.renderRecipe)return[];const f=new Set,u=[...ia(e),...ia(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 u){const u=sa(e,f,h,g),v=sa(t,f,h,g),b=null!==(i=null!==(n=null===(r=p.getClass)||void 0===r?void 0:r.call(p,f,h,g))&&void 0!==n?n:null===(o=d.getClass)||void 0===o?void 0:o.call(d,f,h,g))&&void 0!==i?i:`${f}.${h}.${g}`;u&&!v?m.push({name:b,kind:"removed"}):!u&&v?m.push({name:b,kind:"added"}):(null!==(a=null===(s=d.renderRecipe)||void 0===s?void 0:s.call(d,f,h,g))&&void 0!==a?a:"")!==(null!==(c=null===(l=p.renderRecipe)||void 0===l?void 0:l.call(p,f,h,g))&&void 0!==c?c:"")&&m.push({name:b,kind:"changed"})}return m.sort((e,t)=>e.name.localeCompare(t.name))})(e,t),o=((e,t)=>{var r,n,o,i;const s=e=>e?{ratio:e.wcagRatio,level:e.wcagLevel,pass:e.pass}:null,a=e=>new Map(e.map(e=>[e.label,e])),l=a(Zr(e).pairings),c=a(Zr(t).pairings),d=new Set([...l.keys(),...c.keys()]),p=[];for(const e of d){const t=l.get(e),a=c.get(e),d=s(t),f=s(a);if((null==d?void 0:d.ratio)===(null==f?void 0:f.ratio)&&(null==d?void 0:d.level)===(null==f?void 0:f.level)&&Boolean(t)===Boolean(a))continue;const u=(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!==(i=null==a?void 0:a.wcagLevel)&&void 0!==i?i:null);p.push({label:e,before:d,after:f,crossed:u})}return p.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 la={fail:0,"AA-large":1,AA:2,AAA:3};let ca=0;async function da(n){var o,i,s,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 v(n);try{const t=await import(r.pathToFileURL(e).href);l=null!==(i=null!==(o=t.default)&&void 0!==o?o:t.raw)&&void 0!==i?i:t}finally{t()}}else{const e=await import(`${r.pathToFileURL(n).href}?v=${++ca}`);l=null!==(a=null!==(s=e.default)&&void 0!==s?s: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 je("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 je("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 pa(e){var r,n,o,i,s,a,l,c;const d=null!==(r=e.cwd)&&void 0!==r?r:process.cwd(),{config:p,path:f}=await Vi({cwd:d,configPath:e.configPath}),u=t.resolve(d,e.candidatePath),m=await da(u),h={units:p.units,baseFontSize:p.baseFontSize,media:p.media},g=p.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}}),v=g.map(({name:e,adapter:t})=>{var r;try{return Go(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)]}}}),b=null!==(o=null!==(n=g.find(({adapter:e})=>"function"==typeof Go(p.raw,{adapter:e,...h}).renderRecipe))&&void 0!==n?n:g[0])&&void 0!==o?o:{name:"noop",adapter:pi()},y=Go(p.raw,{adapter:b.adapter,...h});let w={tokens:[],classes:[],contrast:[],summary:{tokensChanged:0,classesChanged:0,pairingsCrossed:0}};try{w=aa(y,Go(m,{adapter:b.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!==(i=la[e.failBelow])&&void 0!==i?i:0;for(const r of w.contrast){const n=(null===(s=r.after)||void 0===s?void 0:s.level)&&null!==(a=la[r.after.level])&&void 0!==a?a:0,o=(null===(l=r.before)||void 0===l?void 0:l.level)&&null!==(c=la[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 x=v.filter(e=>!e.ok).map(e=>e.name);return x.length&&$.push(`candidate no longer builds for: ${x.join(", ")}`),{configPath:f,candidatePath:u,diff:w,targets:v,ok:0===$.length,violations:$}}const fa=["claude","codex","opencode","github-copilot","cursor","generic"],ua={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"}},ma="\x3c!-- refract-skills:start --\x3e",ha="\x3c!-- refract-skills:end --\x3e",ga=t.join(".refract","skills.lock"),va=t.join(".refract","skills");function ba(e){return null!=e?e:t.join(d(),"skills")}function ya(r){const n=ba(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,i;const s=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(e),a=s?s[1]:"",l=s?e.slice(s[0].length).replace(/^\s+/,""):e,c=e=>{const t=new RegExp(`^${e}:\\s*(.*)$`,"m").exec(a);return t?t[1].trim():void 0},d=null!==(o=null!==(n=c("name"))&&void 0!==n?n:t.dirname(r).split(/[\\/]/).pop())&&void 0!==o?o:"unnamed",p="optional"===c("tier")?"optional":"core";return{name:d,description:null!==(i=c("description"))&&void 0!==i?i:"",tier:p,raw:e,body:l,sourcePath:r}}(e.readFileSync(r,"utf8"),r)).sort((e,t)=>e.name.localeCompare(t.name))}function wa(e){const t=e.map(e=>`| [${e.name}](${va}/${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[ma,"","## 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,"",ha].join("\n")}function $a(e,t){const r=e.indexOf(ma),n=e.indexOf(ha);if(-1!==r&&-1!==n&&n>r)return e.slice(0,r)+t+e.slice(n+ha.length);const o=e.replace(/\s+$/,"");return o?`${o}\n\n${t}\n`:`${t}\n`}function xa(r,n){e.mkdirSync(t.dirname(r),{recursive:!0}),e.writeFileSync(r,n,"utf8")}function ka(r){var n,i,s;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(i=r.home)&&void 0!==i?i:o.homedir():null!==(s=r.cwd)&&void 0!==s?s: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)}(ya(r.catalogDir),r);if(0===r.agents.length)throw new Error("Pick at least one agent target.");const p=new Set;if(r.agents.some(e=>"agents-md"===ua[e].kind))for(const e of c){const r=t.join(l,va,`${e.name}.md`);xa(r,e.body),p.add(r)}for(const n of r.agents){const r=ua[n];if("claude"===r.kind)for(const e of c){const n=t.join(l,r.routerFile,e.name,"SKILL.md");xa(n,e.raw),p.add(n)}else{const n=t.join(l,r.routerFile);xa(n,$a(e.existsSync(n)?e.readFileSync(n,"utf8"):"",wa(c))),p.add(n)}}const{name:f,version:u}=function(){var r,n;const o=JSON.parse(e.readFileSync(t.join(d(),"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:u,scope:a,agents:[...r.agents],skills:c.map(e=>e.name)},h=t.join(l,ga);return xa(h,`${JSON.stringify(m,null,2)}\n`),{scope:a,agents:[...r.agents],skills:c.map(e=>e.name),files:[...p].sort(),manifestPath:h}}function ja(r={}){var n,i,s;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(i=r.home)&&void 0!==i?i:o.homedir():null!==(s=r.cwd)&&void 0!==s?s:process.cwd(),c=t.join(l,ga);if(!e.existsSync(c))throw new Error(`No skills manifest at "${c}". Run \`refract skills install\` first.`);const d=JSON.parse(e.readFileSync(c,"utf8"));return ka({agents:d.agents,scope:a,skills:d.skills,cwd:r.cwd,home:r.home,catalogDir:r.catalogDir})}const Sa="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 Aa(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 Ea(e){var t;const{values:r}=s.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 Bs(!r.yes&&void 0);try{n.write(),n.write(` ${Cs("refract")} ${Os("· raw-theme scaffold")}`),n.write();const e=As({...await Gs(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 Ys(e,function(e){try{const t=Go(e,{adapter:pi()});return Object.keys(t.tokens).length}catch{return 0}}(e.raw)))n.write(t);return n.write(),n.write(` ${Cs(null!==(t=e.path.split(/[\\/]/).pop())&&void 0!==t?t:"")} written`),n.write(),n.write(` ${Os("Next — wire up a build:")} ${Cs("refract init")}`),n.write(),0}catch(e){return Aa("create",e)}finally{n.close()}}const Ra=new Set(["AAA","AA","AA-large"]);async function Ca(e){const[t,...r]=e;if("list"===t)try{for(const e of ya())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 Aa("skills list",e)}const{values:n}=s.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=ja({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[...fa];const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=t.filter(e=>!fa.includes(e));if(r.length>0)throw new Error(`unknown agent(s) ${r.map(e=>`"${e}"`).join(", ")}. Known: ${fa.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=i.createInterface({input:process.stdin,output:process.stdout});try{process.stdout.write("Install refract skills for which agent(s)?\n"),fa.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()?[...fa]:t.split(",").map(e=>fa[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 s=ka({agents:e,scope:r,skills:n.only?n.only.split(",").map(e=>e.trim()).filter(Boolean):void 0,includeOptional:t});process.stdout.write(`Installed ${s.skills.length} skill(s) for ${s.agents.join(", ")} (${s.scope}):\n`);for(const e of s.files)process.stdout.write(` ${e}\n`);return process.stdout.write(` manifest → ${s.manifestPath}\n`),0}return process.stderr.write(`refract skills: unknown subcommand "${t}". Use install | list | update.\n`),1}catch(e){return Aa("skills",e)}}async function Oa(e){const[t,...r]=e;switch(t){case"create":return Ea(r);case"init":return async function(e){const{values:t}=s.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=es({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 Aa("init",e)}}(r);case"import":return async function(e){const{values:t,positionals:r}=s.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=ea({input:n,out:t.out,rawOnly:Boolean(t["raw-only"]),force:Boolean(t.force),breakpointGroup:t["breakpoint-group"],breakpoints:t.breakpoints?Ks(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 Aa("import",e)}}(r);case"build":return async function(e){const{values:t}=s.parseArgs({args:e,options:{config:{type:"string"},target:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await ta({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 Aa("build",e)}}(r);case"tokens":return async function(e){const{values:t}=s.parseArgs({args:e,options:{config:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await ra({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 Aa("tokens",e)}}(r);case"diff":return async function(e){var t,r,n,o;const{values:i,positionals:a}=s.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=i["fail-below"];if(void 0!==c&&!Ra.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 pa({configPath:i.config,candidatePath:l,maxClassChanges:void 0!==i["max-class-changes"]?Number(i["max-class-changes"]):void 0,maxTokenChanges:void 0!==i["max-token-changes"]?Number(i["max-token-changes"]):void 0,failBelow:c}),{diff:s}=e;process.stdout.write(`Diffed ${e.candidatePath}\n vs ${e.configPath}\n`),process.stdout.write(` ${s.summary.tokensChanged} token(s), ${s.summary.classesChanged} class(es), ${s.summary.pairingsCrossed} pairing(s) crossed a threshold\n`);for(const e of s.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`)}s.tokens.length>20&&process.stdout.write(` … +${s.tokens.length-20} more token(s)\n`);for(const e of s.classes)process.stdout.write(` class ${e.kind.padEnd(7)} ${e.name}\n`);for(const e of s.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 Aa("diff",e)}}(r);case"audit":return async function(e){const{values:t}=s.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&&!Ra.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 na({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 Aa("audit",e)}}(r);case"skills":return Ca(r);case void 0:case"help":case"--help":case"-h":return process.stdout.write(Sa),0;default:return process.stderr.write(`refract: unknown command "${t}".\n\n${Sa}`),1}}"undefined"!=typeof require&&"undefined"!=typeof module&&require.main===module&&Oa(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=fa,exports.CSS_ADAPTER_PACKAGE=Hi,exports.DEFAULT_RAW_BASENAME=ys,exports.FEEL_PRESETS=ds,exports.Prompter=Bs,exports.SCHEME_HINTS=Ds,exports.TYPE_SCALE_CHOICES=Vs,exports.VENDOR_HELPERS=l,exports.applyKey=Ls,exports.bold=Cs,exports.buildGuide=w,exports.buildPreview=ke,exports.collectModes=me,exports.compileTsConfigGraph=v,exports.createReportLines=Ys,exports.cyan=Ts,exports.decodeKey=Ms,exports.decodeKeys=qs,exports.defaultSchemeFor=gs,exports.defineConfig=e=>e,exports.deriveLeading=us,exports.deriveTracking=ms,exports.diffThemes=aa,exports.dim=Os,exports.emitTheme=Ii,exports.findConfigFile=Wi,exports.findPackageRoot=d,exports.findRawTheme=Ki,exports.findVendorHelper=c,exports.green=Fs,exports.listSkills=ya,exports.loadConfig=Vi,exports.main=Oa,exports.nearestLadderStep=hs,exports.parseBreakpointsFlag=Ks,exports.promptCreateAnswers=Gs,exports.rawThemeImport=Xi,exports.readOwnPackageName=Gi,exports.readVendorSource=p,exports.renderRawTheme=js,exports.resolveEmitPlan=ii,exports.runAudit=na,exports.runBuild=ta,exports.runCreate=As,exports.runDiff=pa,exports.runImport=ea,exports.runInit=es,exports.runSkillsInstall=ka,exports.runSkillsUpdate=ja,exports.runTokens=ra,exports.scaffoldConfig=Qi,exports.scaffoldConfigForRaw=Zi,exports.scaffoldImportConfig=Zs,exports.scaffoldRaw=Xs,exports.scaffoldTheme=bs,exports.schemesFor=vs,exports.skillsCatalogDir=ba,exports.swatch=Ps,exports.transpileToEsm=m,exports.yellow=Ns;
|
|
2
2
|
//# sourceMappingURL=build.cjs.js.map
|