@teacss/rule-helpers 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -22,15 +22,17 @@ import {
|
|
|
22
22
|
h,
|
|
23
23
|
makeArbitraryValueRule,
|
|
24
24
|
makeGlobalRules,
|
|
25
|
-
makeShorthandRules,
|
|
26
25
|
makeStaticRules,
|
|
27
26
|
routeGlobalKeywordsToExactRules,
|
|
28
27
|
} from "@teacss/rule-helpers";
|
|
29
28
|
```
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
`
|
|
30
|
+
`makeStaticRules` produces `property:value` enum rules. `makeGlobalRules`
|
|
31
|
+
also accepts CSS-wide keywords. Both reject empty enum values, `false` prefixes,
|
|
32
|
+
and the removed `bareExclude` option. Bare names belong in Core `shortcuts`;
|
|
33
|
+
`makeShorthandRules` is no longer exported.
|
|
34
|
+
|
|
35
|
+
Use `routeGlobalKeywordsToExactRules` before appending user rules so broad
|
|
34
36
|
fallbacks cannot shadow exact keyword rules.
|
|
35
37
|
|
|
36
38
|
`h` is a first-match handler chain for bracket values, variables, global
|
package/dist/index.d.ts
CHANGED
|
@@ -79,14 +79,10 @@ type StaticRuleValueMapEntry = StaticRuleValue | StaticRuleBody;
|
|
|
79
79
|
type StaticRuleValueMapStore = Readonly<Record<string, StaticRuleValueMapEntry>> | ReadonlyMap<string, StaticRuleValueMapEntry>;
|
|
80
80
|
type StaticRuleValueMapResolver = (value: string) => StaticRuleValueMapEntry | undefined;
|
|
81
81
|
type StaticRuleValueMap = StaticRuleValueMapStore | StaticRuleValueMapResolver;
|
|
82
|
-
type ShorthandRuleNames = string | readonly string[];
|
|
83
|
-
type ShorthandRuleValue = string | number | undefined;
|
|
84
82
|
interface StaticRuleOptions {
|
|
85
83
|
property?: StaticRuleProperty;
|
|
86
84
|
valueMap?: StaticRuleValueMap;
|
|
87
85
|
meta?: RuleMeta;
|
|
88
|
-
/** Extra values to skip in `false` bare mode (global keywords are always skipped). E.g. `["none"]` for display. */
|
|
89
|
-
bareExclude?: readonly StaticRuleValue[];
|
|
90
86
|
/**
|
|
91
87
|
* Append one `name:[…]` / `name:$var` fallback rule per prefix. The escape
|
|
92
88
|
* hatch is validated syntactically only — never against the enum — so a
|
|
@@ -95,16 +91,10 @@ interface StaticRuleOptions {
|
|
|
95
91
|
*/
|
|
96
92
|
escapeHatch?: boolean;
|
|
97
93
|
}
|
|
98
|
-
/** A
|
|
99
|
-
type StaticRulePrefix = string
|
|
100
|
-
/** One prefix, or several. The first
|
|
94
|
+
/** A declaration prefix. */
|
|
95
|
+
type StaticRulePrefix = string;
|
|
96
|
+
/** One prefix, or several. The first prefix supplies the default CSS property. */
|
|
101
97
|
type StaticRuleNames = StaticRulePrefix | readonly StaticRulePrefix[];
|
|
102
|
-
interface ShorthandRuleOptions extends Omit<RuleMeta, "layer"> {
|
|
103
|
-
/** CSS property to emit. Defaults to the first shorthand name. */
|
|
104
|
-
property?: StaticRuleProperty;
|
|
105
|
-
}
|
|
106
|
-
/** Create bare shorthand rules that belong in the primitives layer by default. */
|
|
107
|
-
export declare function makeShorthandRules(names: ShorthandRuleNames, value: ShorthandRuleValue, options?: ShorthandRuleOptions): StaticRule[];
|
|
108
98
|
export declare function propsToValueMap(arr: readonly StaticRuleValue[], transform?: (key: string) => StaticRuleValueMapEntry, options?: {
|
|
109
99
|
as?: "record" | "map";
|
|
110
100
|
dedupe?: boolean;
|
|
@@ -116,15 +106,8 @@ export declare function hyphenToSpace(arr: readonly StaticRuleValue[], options?:
|
|
|
116
106
|
ignores?: readonly StaticRuleValue[];
|
|
117
107
|
}): StaticRuleValueMapStore;
|
|
118
108
|
/**
|
|
119
|
-
* Create
|
|
120
|
-
*
|
|
121
|
-
* @param names one prefix (`"cursor"`) or several (`["display", "d"]`); the first
|
|
122
|
-
* string prefix is primary and supplies the default CSS property. Include `false`
|
|
123
|
-
* (e.g. `["display", "d", false]`) to also emit each value as a bare, prefix-less
|
|
124
|
-
* class (`flex` → `display:flex`); global keywords are always skipped, plus any
|
|
125
|
-
* `options.bareExclude` values.
|
|
126
|
-
* @param values enum values
|
|
127
|
-
* @param options `property` (defaults to the first prefix), `valueMap`, `meta`, `bareExclude`
|
|
109
|
+
* Create `name:value` enum rules. The first prefix supplies the default CSS
|
|
110
|
+
* property; `property`, `valueMap`, and `meta` customize the emitted rules.
|
|
128
111
|
*/
|
|
129
112
|
export declare function makeStaticRules(names: StaticRuleNames, values: readonly StaticRuleValue[], options?: StaticRuleOptions): StaticRule[];
|
|
130
113
|
//#endregion
|
|
@@ -283,4 +266,4 @@ export declare function getBracket(str: string, open: string, close: string): st
|
|
|
283
266
|
export declare function getStringComponent(str: string, open: string, close: string, separators: string | string[]): string[] | undefined;
|
|
284
267
|
export declare function getStringComponents(str: string, separators: string | string[], limit?: number, open?: string, close?: string): string[] | undefined;
|
|
285
268
|
//#endregion
|
|
286
|
-
export { type CSSColorValue, type CSSCustomPropertyName, type DefinePropertyOptions, type RGBAColorValue, type
|
|
269
|
+
export { type CSSColorValue, type CSSCustomPropertyName, type DefinePropertyOptions, type RGBAColorValue, type StaticRuleBody, type StaticRuleName, type StaticRuleNames, type StaticRuleOptions, type StaticRulePrefix, type StaticRuleProperty, type StaticRuleValue, type StaticRuleValueMap, type StaticRuleValueMapEntry, type StaticRuleValueMapResolver, type StaticRuleValueMapStore, type ValueHandler, type ValueHandlerCallback, type ValueHandlerResult, cssLengthPercentageUnitRESource, cssLengthUnitRESource, cssLengthUnits, cssNamedColors, globalKeywords };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cssLengthPercentageUnitRESource as e,cssLengthUnitRESource as t,cssLengthUnits as n,cssNamedColors as r,globalKeywords as i}from"./constants.js";import{a,c as o,i as s,n as c,o as l,r as u,s as d,t as ee}from"./css-identifier-4yDg85cV.js";import{_ as te,a as f,b as ne,d as p,f as m,g as re,h as ie,i as ae,l as oe,m as se,n as h,o as g,p as ce,r as le,s as _,t as v,u as y,v as b,x as ue,y as de}from"./standard-value-handler-YFojajHy.js";import{LAYER_PRIMITIVES as fe,LAYER_PROPERTIES as pe,escapeRegExp as x,isStaticRule as me,isString as he,symbols as S,toArray as ge}from"@teacss/core";function _e(e){let t=e.match(/^-?\d+\.?\d*/)?.[0]||``,n=e.slice(t.length);if(n===`px`){let r=Number.parseFloat(t)-.1;return Number.isNaN(r)?e:`${r}${n}`}return`calc(${e} - 0.1px)`}function ve(e,t,n){if(e===``)return;let r=e.length,i=0,a=!1,o=0;for(let s=0;s<r;s++)switch(e[s]){case t:a||(a=!0,o=s),i++;break;case n:if(--i,i<0)return;if(i===0)return[e.slice(o,s+1),e.slice(s+1),e.slice(0,o)]}}function C(e,t,n,r){if(e===``||(he(r)&&(r=[r]),r.length===0))return;let i=e.length,a=0;for(let o=0;o<i;o++)switch(e[o]){case t:a++;break;case n:if(--a<0)return;break;default:for(let t of r){let n=t.length;if(n&&t===e.slice(o,o+n)&&a===0)return o===0||o===i-n?void 0:[e.slice(0,o),e.slice(o+n)]}}if(a===0)return[e,``]}function w(e,t,n,r=`(`,i=`)`){n??=10;let a=[],o=0;for(;e!==``;){if(++o>n)return;let s=C(e,r,i,t);if(!s)return;let[c,l]=s;a.push(c),e=l}if(a.length>0)return a}const T=[`hsl`,`hsla`,`hwb`,`lab`,`lch`,`oklab`,`oklch`,`rgb`,`rgba`],E=[`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`],D=[`hsl`,`hwb`,`lch`,`oklch`],O=[`shorter`,`longer`,`increasing`,`decreasing`],k=[`%alpha`,`<alpha-value>`],A=new RegExp(k.map(e=>x(e)).join(`|`),`g`),j=new Set([...E,...D,...O]);function M(e){if(!e)return!1;let t=-1;for(let n=0;n<=e.length;n++){if(e[n]===`\\`||l(e[n])){t<0&&(t=n);continue}if(t>=0&&j.has(e.slice(t,n).toLowerCase()))return!0;t=-1}return!1}function N(e=``){let t=L(e);if(t!=null){let{components:e,alpha:n}=t;return n==null?e:[...e,n]}}function P(e=``){let t=ye(e);if(t==null||t===!1)return;let{type:n,components:r,alpha:i}=t,a=n.toLowerCase();if(r.length!==0&&(!T.includes(a)||[1,3].includes(r.length)))return{type:a,components:r.map(e=>typeof e==`string`?e.trim():e),alpha:typeof i==`string`?i.trim():i}}function F(e){let t=e.alpha??1;return typeof t==`string`&&k.includes(t)?1:t}function I(e,t){if(typeof e==`string`)return e.replace(A,`${t??1}`);let{components:n}=e,{alpha:r,type:i}=e;return r=t??r,i=i.toLowerCase(),[`hsla`,`rgba`].includes(i)?`${i}(${n.join(`, `)}${r==null?``:`, ${r}`})`:(r=r==null?``:` / ${r}`,T.includes(i)?`${i}(${n.join(` `)}${r})`:`color(${i} ${n.join(` `)}${r})`)}function ye(e){if(!e)return;let t=L(e);if(t!=null||(t=z(e),t!=null)||(t=xe(e),t!=null)||(t=Ce(e),t!=null)||(t=we(e),t!=null))return t}function L(e){let[,t]=e.match(/^#([\da-f]+)$/i)||[];if(t)switch(t.length){case 3:case 4:{let e=Array.from(t,e=>Number.parseInt(e,16)).map(e=>e<<4|e);return{type:`rgb`,components:e.slice(0,3),alpha:t.length===3?void 0:R(e[3])}}case 6:case 8:{let e=Number.parseInt(t,16);return{type:`rgb`,components:t.length===6?[e>>16&255,e>>8&255,e&255]:[e>>24&255,e>>16&255,e>>8&255],alpha:t.length===6?void 0:R(e&255)}}}}function R(e){return Math.round(e/255*1e4)/1e4}const be={rebeccapurple:[102,51,153,1]};function z(e){let t=p(be,e);if(t!=null)return{type:`rgb`,components:t.slice(0,3),alpha:t[3]}}function xe(e){let t=e.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);if(!t)return;let[,n,r]=t,i=w(r,`,`,5);if(i){if([3,4].includes(i.length))return{type:n,components:i.slice(0,3),alpha:i[3]};if(i.length!==1)return!1}}const Se=RegExp(`^(${T.join(`|`)})\\((.+)\\)$`,`i`);function Ce(e){let t=e.match(Se);if(!t)return;let[,n,r]=t,i=B(`${n} ${r}`);if(i){let{alpha:e,components:[t,...n]}=i;return{type:t,components:n,alpha:e}}}function we(e){let t=e.match(/^color\((.+)\)$/);if(!t)return;let n=B(t[1]);if(n){let{alpha:e,components:[t,...r]}=n;return{type:t,components:r,alpha:e}}}function B(e){let t=w(e,` `);if(!t)return;let n=t.length;if(t[n-2]===`/`)return{components:t.slice(0,n-2),alpha:t[n-1]};if(t[n-2]!=null&&(t[n-2].endsWith(`/`)||t[n-1].startsWith(`/`))){let e=t.splice(n-2);t.push(e.join(` `)),--n}let r=w(t[n-1],`/`,2);if(!r)return;if(r.length===1||r[r.length-1]===``)return{components:t};let i=r.pop();return t[n-1]=r.join(`/`),{components:t,alpha:i}}function Te(e,t={}){let{syntax:n=`*`,inherits:r=!1,initialValue:i}=t,a={[S.shortcutsNoMerge]:!0,[S.noMerge]:!0,[S.variants]:()=>[{parent:``,layer:pe,selector:()=>`@property ${e}`}],syntax:JSON.stringify(n),inherits:r?`true`:`false`};return i!=null&&(a[`initial-value`]=i),a}function V(e){return y(e,`theme`)}function Ee(e){return y(e,`icon`)}function H(e,t,n=!0){if(!V(e))return e;let r=[],i=0,a=0;for(;a<e.length;){let o=oe(e,`theme`,a);if(o===-1)break;let s=De(e,o);if(!s)break;if(a=s.end,!s.valid)continue;if(!s.argument)throw Error(`theme() expect exact one argument, but got 0`);let c=G(s.argument,t,s.fallback===void 0&&n)??(s.fallback===void 0?void 0:H(s.fallback,t,n));c!==void 0&&(r.push(e.slice(i,o),c),i=s.end)}return i===0?e:(r.push(e.slice(i)),r.join(``))}function U(e,t){let n=0,r=-1,i;for(let a=t;a<e.length;a++){let t=e[a];if(i!=null){t===`\\`?a++:t===i&&(i=void 0);continue}if(t===`"`||t===`'`)i=t;else if(t===`(`)n++;else if(t===`)`){if(n===0)return{end:a,separator:r};n--}else t===`,`&&n===0&&r===-1&&(r=a)}return{end:-1,separator:-1}}function W(e,t,n,r){let i=e.slice(n,r).trim();return i?{argument:t,fallback:i,end:r+1,valid:!0}:{argument:t,end:r+1,valid:!0}}function De(e,t){let n=t+6;for(;/\s/.test(e[n]??``);)n++;let r=e[n]===`"`||e[n]===`'`?e[n++]:void 0,i=n;if(r){for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t===r)break;n++}if(n>=e.length)return;let t=e.slice(i,n);for(n++;/\s/.test(e[n]??``);)n++;if(e[n]===`)`)return{argument:t,end:n+1,valid:!0};if(e[n]!==`,`)return{argument:t,end:Oe(e,n),valid:!1};let a=U(e,n+1);return a.end===-1?void 0:W(e,t,n+1,a.end)}let a=U(e,n);if(a.end!==-1)return a.separator===-1?{argument:e.slice(i,a.end).trim(),end:a.end+1,valid:!0}:W(e,e.slice(i,a.separator).trim(),a.separator+1,a.end)}function Oe(e,t){let n=e.indexOf(`)`,t);return n===-1?e.length:n+1}function G(e,t,n=!0){let r=e.indexOf(`/`),i=r<0?e:e.slice(0,r),a=r<0?void 0:e.slice(r+1),o=i.trim().split(`.`),s=t;for(let e of o){if(typeof s!=`object`||!s){s=void 0;break}s=p(s,e)}if(typeof s==`object`&&s&&(s=p(s,`DEFAULT`)),typeof s==`number`&&Number.isFinite(s)&&a==null)return String(s);if(typeof s==`string`){if(!a)return s;let e=ke(a),t=P(s);return t?I(t,e):`color-mix(in oklab, ${s} ${e}, transparent)`}if(n)throw Error(`theme("${e}") was not found`)}function ke(e){let t=e.trim();return/^\d{1,3}$/.test(t)&&Number(t)<=100?`${Number(t)}%`:t}function K(e){return f(e)??g(e)}function Ae(e){return K(e)??_(e)}function je(e,t,n){return[e,([,e])=>({[t]:K(e)}),{autocomplete:n}]}function Me(e,t,n){return[e,([,e])=>({[t]:Ae(e)}),{autocomplete:n}]}const Ne=new Set(i);function Pe(e,t,n){Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!0,writable:!0})}function Fe(e,t,n={}){let r=J(typeof e==`string`?[e]:e);if(r.length===0)return[];let{property:i,...a}=n,o=(i??r[0]??``).trim();if(!o)throw Error(`makeShorthandRules requires a non-empty property`);return r.map(e=>[e,{[o]:t},{...a,layer:fe}])}function q(e,t,n={}){let{as:r=`record`,dedupe:i=!0,ignores:a=[]}=n,o=new Set,s=a.length?new Set(a.map(String)):void 0,c=t??(e=>e);if(r===`map`){let t=new Map;for(let n of e){let e=String(n);s?.has(e)||i&&o.has(e)||(o.add(e),t.set(e,c(e)))}return t}let l={};for(let t of e){let e=String(t);if(s?.has(e)||i&&o.has(e))continue;o.add(e);let n=c(e);e===`__proto__`?Pe(l,e,n):l[e]=n}return l}function Ie(e,t={}){return q(e,e=>e.includes(`-`)?e.replaceAll(`-`,` `):e,t)}function J(e){let t=new Set,n=[];for(let r of e)r&&(t.has(r)||(t.add(r),n.push(r)));return n}function Le(e){let t=new Set,n=[];for(let r of e){let e=String(r);t.has(e)||(t.add(e),n.push(e))}return n}function Re(e){if(!e)return()=>void 0;if(typeof e==`function`)return e;if(e instanceof Map)return t=>e.get(t);let t=e;return e=>p(t,e)}function Y(e,t){let n=(e??``).trim(),r=Re(t);return e=>{let t=r(e);if(t!=null&&typeof t!=`string`&&typeof t!=`number`)return t;if(!n)throw Error(`makeStaticRules requires a non-empty property`);return{[n]:t??e}}}function X(e,t,n={}){let{valueMap:r,meta:i}=n,a=typeof e==`string`||e===!1?[e]:e,o=a.includes(!1),s=J(a.filter(e=>typeof e==`string`));if(s.length===0&&!o)return[];let c=Le(t);if(c.length===0)return[];let l=Y(n.property??s[0],r),u=[],d=(e,t)=>u.push(i?[e,l(t),i]:[e,l(t)]);for(let e of s)for(let t of c)d(t?`${e}:${t}`:e,t);if(o){let e=new Set([...Ne,...(n.bareExclude??[]).map(String)]);for(let t of c)t&&!e.has(t)&&d(t,t)}return u}const ze=i.join(`|`),Z=new Set(i),Q=Symbol.for(`@teacss/rule-helpers/global-rule-name`);function $(e){return e[2]?.[Q]}function Be(e){if(e.flags)return;let t=e.source;if(!t.startsWith(`^`))return;let n=1;for(;n<t.length&&/[A-Za-z0-9_-]/.test(t[n]);)n++;return t[n]===`:`?t.slice(1,n):void 0}function Ve(e,t,n={}){let r=J((typeof e==`string`||e===!1?[e]:e).filter(e=>typeof e==`string`)),i=X(e,t.filter(e=>!Z.has(String(e))),n);if(r.length===0)return i;let a=Y(n.property??r[0],n.valueMap),o=n.meta?.autocomplete,s=typeof o==`string`?[o]:o??[],c=n.meta?.prefix==null?[``]:ge(n.meta.prefix);for(let e of r){let t={...n.meta,autocomplete:[...s,...c.map(t=>`${t}${e}:<globalKeyword>`)],[Q]:e},r=[RegExp(`^${x(e)}:(${ze})$`),([,e])=>a(e),t];i.push(r)}if(n.escapeHatch){let e=(n.property??r[0]??``).trim();if(!e)throw Error(`escapeHatch requires a rule name or property`);for(let t of r){let r={...n.meta,autocomplete:[...s,...c.map(e=>`${e}${t}:[]`)]};i.push([RegExp(`^${x(t)}:(.+)$`),([,t])=>({[e]:f(t)??g(t)}),r])}}return i}function He(e,t){let n=e.lastIndexOf(`:`);return n<=0||!Z.has(e.slice(n+1))?!1:t.has(e.slice(0,n))}function Ue(e){let t=new Set;for(let n of e){let e=$(n);e!=null&&t.add(e)}return t.size===0?[...e]:e.map(e=>{if(me(e)||$(e)!=null)return e;let[n,r,i]=e,a=Be(n);if(a!=null&&!t.has(a))return e;let o=(e,n)=>{if(!He(e[0],t))return r(e,n)};return i==null?[n,o]:[n,o,i]})}function We(e){let t=`>:not(:last-child)`;return e.includes(t)?`:where(${e})`:`:where(${e}${t})`}export{k as alphaPlaceholders,A as alphaPlaceholdersRE,se as angleRE,ie as bracketTypeRe,_e as calcMaxWidthBySize,F as colorOpacityToString,I as colorToString,ee as consumeCssEscape,c as consumeCssIdentifier,u as consumeCssName,ae as createValueHandler,T as cssColorFunctions,e as cssLengthPercentageUnitRESource,t as cssLengthUnitRESource,n as cssLengthUnits,r as cssNamedColors,m as decodeArbitraryValue,s as decodeCssIdentifier,Te as defineProperty,ve as getBracket,p as getOwn,C as getStringComponent,w as getStringComponents,i as globalKeywords,v as h,h as handler,Ee as hasIconFn,V as hasThemeFn,N as hex2rgba,O as hueInterpolationMethods,Ie as hyphenToSpace,ce as isBareDashedIdentifier,a as isCssIdentifier,l as isCssNameCharacter,d as isCssNameStartCharacter,o as isCssWhitespace,M as isInterpolatedMethod,re as lengthRE,je as makeArbitraryValueRule,Ve as makeGlobalRules,Me as makeGlobalValueRule,Fe as makeShorthandRules,X as makeStaticRules,We as notLastChildSelector,te as numberRE,b as numberWithUnitRE,P as parseCssColor,de as percentRE,D as polarColorSpace,q as propsToValueMap,E as rectangularColorSpace,Ue as routeGlobalKeywordsToExactRules,H as transformThemeFn,G as transformThemeString,ne as unitOnlyMap,ue as unitOnlyRE,le as valueHandlers};
|
|
1
|
+
import{cssLengthPercentageUnitRESource as e,cssLengthUnitRESource as t,cssLengthUnits as n,cssNamedColors as r,globalKeywords as i}from"./constants.js";import{a,c as o,i as s,n as c,o as l,r as u,s as ee,t as te}from"./css-identifier-4yDg85cV.js";import{_ as ne,a as d,b as f,d as p,f as re,g as ie,h as m,i as ae,l as oe,m as se,n as h,o as g,p as _,r as v,s as y,t as ce,u as b,v as le,x as ue,y as de}from"./standard-value-handler-idWIIPjr.js";import{LAYER_PROPERTIES as fe,escapeRegExp as x,isStaticRule as pe,isString as me,symbols as S,toArray as he}from"@teacss/core";function ge(e){let t=e.match(/^-?\d+\.?\d*/)?.[0]||``,n=e.slice(t.length);if(n===`px`){let r=Number.parseFloat(t)-.1;return Number.isNaN(r)?e:`${r}${n}`}return`calc(${e} - 0.1px)`}function _e(e,t,n){if(e===``)return;let r=e.length,i=0,a=!1,o=0;for(let s=0;s<r;s++)switch(e[s]){case t:a||(a=!0,o=s),i++;break;case n:if(--i,i<0)return;if(i===0)return[e.slice(o,s+1),e.slice(s+1),e.slice(0,o)]}}function C(e,t,n,r){if(e===``||(me(r)&&(r=[r]),r.length===0))return;let i=e.length,a=0;for(let o=0;o<i;o++)switch(e[o]){case t:a++;break;case n:if(--a<0)return;break;default:for(let t of r){let n=t.length;if(n&&t===e.slice(o,o+n)&&a===0)return o===0||o===i-n?void 0:[e.slice(0,o),e.slice(o+n)]}}if(a===0)return[e,``]}function w(e,t,n,r=`(`,i=`)`){n??=10;let a=[],o=0;for(;e!==``;){if(++o>n)return;let s=C(e,r,i,t);if(!s)return;let[c,l]=s;a.push(c),e=l}if(a.length>0)return a}const T=[`hsl`,`hsla`,`hwb`,`lab`,`lch`,`oklab`,`oklch`,`rgb`,`rgba`],E=[`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`],D=[`hsl`,`hwb`,`lch`,`oklch`],O=[`shorter`,`longer`,`increasing`,`decreasing`],k=[`%alpha`,`<alpha-value>`],A=new RegExp(k.map(e=>x(e)).join(`|`),`g`),j=new Set([...E,...D,...O]);function M(e){if(!e)return!1;let t=-1;for(let n=0;n<=e.length;n++){if(e[n]===`\\`||l(e[n])){t<0&&(t=n);continue}if(t>=0&&j.has(e.slice(t,n).toLowerCase()))return!0;t=-1}return!1}function N(e=``){let t=L(e);if(t!=null){let{components:e,alpha:n}=t;return n==null?e:[...e,n]}}function P(e=``){let t=ve(e);if(t==null||t===!1)return;let{type:n,components:r,alpha:i}=t,a=n.toLowerCase();if(r.length!==0&&(!T.includes(a)||[1,3].includes(r.length)))return{type:a,components:r.map(e=>typeof e==`string`?e.trim():e),alpha:typeof i==`string`?i.trim():i}}function F(e){let t=e.alpha??1;return typeof t==`string`&&k.includes(t)?1:t}function I(e,t){if(typeof e==`string`)return e.replace(A,`${t??1}`);let{components:n}=e,{alpha:r,type:i}=e;return r=t??r,i=i.toLowerCase(),[`hsla`,`rgba`].includes(i)?`${i}(${n.join(`, `)}${r==null?``:`, ${r}`})`:(r=r==null?``:` / ${r}`,T.includes(i)?`${i}(${n.join(` `)}${r})`:`color(${i} ${n.join(` `)}${r})`)}function ve(e){if(!e)return;let t=L(e);if(t!=null||(t=be(e),t!=null)||(t=z(e),t!=null)||(t=Se(e),t!=null)||(t=Ce(e),t!=null))return t}function L(e){let[,t]=e.match(/^#([\da-f]+)$/i)||[];if(t)switch(t.length){case 3:case 4:{let e=Array.from(t,e=>Number.parseInt(e,16)).map(e=>e<<4|e);return{type:`rgb`,components:e.slice(0,3),alpha:t.length===3?void 0:R(e[3])}}case 6:case 8:{let e=Number.parseInt(t,16);return{type:`rgb`,components:t.length===6?[e>>16&255,e>>8&255,e&255]:[e>>24&255,e>>16&255,e>>8&255],alpha:t.length===6?void 0:R(e&255)}}}}function R(e){return Math.round(e/255*1e4)/1e4}const ye={rebeccapurple:[102,51,153,1]};function be(e){let t=p(ye,e);if(t!=null)return{type:`rgb`,components:t.slice(0,3),alpha:t[3]}}function z(e){let t=e.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);if(!t)return;let[,n,r]=t,i=w(r,`,`,5);if(i){if([3,4].includes(i.length))return{type:n,components:i.slice(0,3),alpha:i[3]};if(i.length!==1)return!1}}const xe=RegExp(`^(${T.join(`|`)})\\((.+)\\)$`,`i`);function Se(e){let t=e.match(xe);if(!t)return;let[,n,r]=t,i=B(`${n} ${r}`);if(i){let{alpha:e,components:[t,...n]}=i;return{type:t,components:n,alpha:e}}}function Ce(e){let t=e.match(/^color\((.+)\)$/);if(!t)return;let n=B(t[1]);if(n){let{alpha:e,components:[t,...r]}=n;return{type:t,components:r,alpha:e}}}function B(e){let t=w(e,` `);if(!t)return;let n=t.length;if(t[n-2]===`/`)return{components:t.slice(0,n-2),alpha:t[n-1]};if(t[n-2]!=null&&(t[n-2].endsWith(`/`)||t[n-1].startsWith(`/`))){let e=t.splice(n-2);t.push(e.join(` `)),--n}let r=w(t[n-1],`/`,2);if(!r)return;if(r.length===1||r[r.length-1]===``)return{components:t};let i=r.pop();return t[n-1]=r.join(`/`),{components:t,alpha:i}}function we(e,t={}){let{syntax:n=`*`,inherits:r=!1,initialValue:i}=t,a={[S.shortcutsNoMerge]:!0,[S.noMerge]:!0,[S.variants]:()=>[{parent:``,layer:fe,selector:()=>`@property ${e}`}],syntax:JSON.stringify(n),inherits:r?`true`:`false`};return i!=null&&(a[`initial-value`]=i),a}function V(e){return b(e,`theme`)}function Te(e){return b(e,`icon`)}function H(e,t,n=!0){if(!V(e))return e;let r=[],i=0,a=0;for(;a<e.length;){let o=oe(e,`theme`,a);if(o===-1)break;let s=Ee(e,o);if(!s)break;if(a=s.end,!s.valid)continue;if(!s.argument)throw Error(`theme() expect exact one argument, but got 0`);let c=G(s.argument,t,s.fallback===void 0&&n)??(s.fallback===void 0?void 0:H(s.fallback,t,n));c!==void 0&&(r.push(e.slice(i,o),c),i=s.end)}return i===0?e:(r.push(e.slice(i)),r.join(``))}function U(e,t){let n=0,r=-1,i;for(let a=t;a<e.length;a++){let t=e[a];if(i!=null){t===`\\`?a++:t===i&&(i=void 0);continue}if(t===`"`||t===`'`)i=t;else if(t===`(`)n++;else if(t===`)`){if(n===0)return{end:a,separator:r};n--}else t===`,`&&n===0&&r===-1&&(r=a)}return{end:-1,separator:-1}}function W(e,t,n,r){let i=e.slice(n,r).trim();return i?{argument:t,fallback:i,end:r+1,valid:!0}:{argument:t,end:r+1,valid:!0}}function Ee(e,t){let n=t+6;for(;/\s/.test(e[n]??``);)n++;let r=e[n]===`"`||e[n]===`'`?e[n++]:void 0,i=n;if(r){for(;n<e.length;){let t=e[n];if(t===`\\`){n+=2;continue}if(t===r)break;n++}if(n>=e.length)return;let t=e.slice(i,n);for(n++;/\s/.test(e[n]??``);)n++;if(e[n]===`)`)return{argument:t,end:n+1,valid:!0};if(e[n]!==`,`)return{argument:t,end:De(e,n),valid:!1};let a=U(e,n+1);return a.end===-1?void 0:W(e,t,n+1,a.end)}let a=U(e,n);if(a.end!==-1)return a.separator===-1?{argument:e.slice(i,a.end).trim(),end:a.end+1,valid:!0}:W(e,e.slice(i,a.separator).trim(),a.separator+1,a.end)}function De(e,t){let n=e.indexOf(`)`,t);return n===-1?e.length:n+1}function G(e,t,n=!0){let r=e.indexOf(`/`),i=r<0?e:e.slice(0,r),a=r<0?void 0:e.slice(r+1),o=i.trim().split(`.`),s=t;for(let e of o){if(typeof s!=`object`||!s){s=void 0;break}s=p(s,e)}if(typeof s==`object`&&s&&(s=p(s,`DEFAULT`)),typeof s==`number`&&Number.isFinite(s)&&a==null)return String(s);if(typeof s==`string`){if(!a)return s;let e=Oe(a),t=P(s);return t?I(t,e):`color-mix(in oklab, ${s} ${e}, transparent)`}if(n)throw Error(`theme("${e}") was not found`)}function Oe(e){let t=e.trim();return/^\d{1,3}$/.test(t)&&Number(t)<=100?`${Number(t)}%`:t}function K(e){return d(e)??g(e)}function ke(e){return K(e)??y(e)}function Ae(e,t,n){return[e,([,e])=>({[t]:K(e)}),{autocomplete:n}]}function je(e,t,n){return[e,([,e])=>({[t]:ke(e)}),{autocomplete:n}]}function Me(e,t,n){Object.defineProperty(e,t,{value:n,configurable:!0,enumerable:!0,writable:!0})}function q(e,t,n={}){let{as:r=`record`,dedupe:i=!0,ignores:a=[]}=n,o=new Set,s=a.length?new Set(a.map(String)):void 0,c=t??(e=>e);if(r===`map`){let t=new Map;for(let n of e){let e=String(n);s?.has(e)||i&&o.has(e)||(o.add(e),t.set(e,c(e)))}return t}let l={};for(let t of e){let e=String(t);if(s?.has(e)||i&&o.has(e))continue;o.add(e);let n=c(e);e===`__proto__`?Me(l,e,n):l[e]=n}return l}function Ne(e,t={}){return q(e,e=>e.includes(`-`)?e.replaceAll(`-`,` `):e,t)}function J(e){let t=new Set,n=[];for(let r of e)r&&(t.has(r)||(t.add(r),n.push(r)));return n}function Pe(e){let t=new Set,n=[];for(let r of e){let e=String(r);if(!e)throw TypeError(`makeStaticRules requires non-empty enum values; use shortcuts for bare names`);t.has(e)||(t.add(e),n.push(e))}return n}function Fe(e){if(!e)return()=>void 0;if(typeof e==`function`)return e;if(e instanceof Map)return t=>e.get(t);let t=e;return e=>p(t,e)}function Y(e,t){let n=(e??``).trim(),r=Fe(t);return e=>{let t=r(e);if(t!=null&&typeof t!=`string`&&typeof t!=`number`)return t;if(!n)throw Error(`makeStaticRules requires a non-empty property`);return{[n]:t??e}}}function X(e,t,n={}){if(`bareExclude`in n)throw TypeError(`makeStaticRules no longer accepts bareExclude; use shortcuts for bare names`);let r=typeof e==`string`?[e]:e;if(!Array.isArray(r)||r.some(e=>typeof e!=`string`))throw TypeError(`makeStaticRules requires declaration prefixes; false is no longer supported, use shortcuts for bare names`);let{valueMap:i,meta:a}=n,o=J(r),s=Pe(t);if(o.length===0||s.length===0)return[];let c=Y(n.property??o[0],i),l=[];for(let e of o)for(let t of s){let n=`${e}:${t}`;l.push(a?[n,c(t),a]:[n,c(t)])}return l}const Ie=i.join(`|`),Z=new Set(i),Q=Symbol.for(`@teacss/rule-helpers/global-rule-name`);function $(e){return e[2]?.[Q]}function Le(e){if(e.flags)return;let t=e.source;if(!t.startsWith(`^`))return;let n=1;for(;n<t.length&&/[A-Za-z0-9_-]/.test(t[n]);)n++;return t[n]===`:`?t.slice(1,n):void 0}function Re(e,t,n={}){let r=X(e,t.filter(e=>!Z.has(String(e))),n),i=J(typeof e==`string`?[e]:e);if(i.length===0)return r;let a=Y(n.property??i[0],n.valueMap),o=n.meta?.autocomplete,s=typeof o==`string`?[o]:o??[],c=n.meta?.prefix==null?[``]:he(n.meta.prefix);for(let e of i){let t={...n.meta,autocomplete:[...s,...c.map(t=>`${t}${e}:<globalKeyword>`)],[Q]:e},i=[RegExp(`^${x(e)}:(${Ie})$`),([,e])=>a(e),t];r.push(i)}if(n.escapeHatch){let e=(n.property??i[0]??``).trim();if(!e)throw Error(`escapeHatch requires a rule name or property`);for(let t of i){let i={...n.meta,autocomplete:[...s,...c.map(e=>`${e}${t}:[]`)]};r.push([RegExp(`^${x(t)}:(.+)$`),([,t])=>({[e]:d(t)??g(t)}),i])}}return r}function ze(e,t){let n=e.lastIndexOf(`:`);return n<=0||!Z.has(e.slice(n+1))?!1:t.has(e.slice(0,n))}function Be(e){let t=new Set;for(let n of e){let e=$(n);e!=null&&t.add(e)}return t.size===0?[...e]:e.map(e=>{if(pe(e)||$(e)!=null)return e;let[n,r,i]=e,a=Le(n);if(a!=null&&!t.has(a))return e;let o=(e,n)=>{if(!ze(e[0],t))return r(e,n)};return i==null?[n,o]:[n,o,i]})}function Ve(e){let t=`>:not(:last-child)`;return e.includes(t)?`:where(${e})`:`:where(${e}${t})`}export{k as alphaPlaceholders,A as alphaPlaceholdersRE,se as angleRE,m as bracketTypeRe,ge as calcMaxWidthBySize,F as colorOpacityToString,I as colorToString,te as consumeCssEscape,c as consumeCssIdentifier,u as consumeCssName,ae as createValueHandler,T as cssColorFunctions,e as cssLengthPercentageUnitRESource,t as cssLengthUnitRESource,n as cssLengthUnits,r as cssNamedColors,re as decodeArbitraryValue,s as decodeCssIdentifier,we as defineProperty,_e as getBracket,p as getOwn,C as getStringComponent,w as getStringComponents,i as globalKeywords,ce as h,h as handler,Te as hasIconFn,V as hasThemeFn,N as hex2rgba,O as hueInterpolationMethods,Ne as hyphenToSpace,_ as isBareDashedIdentifier,a as isCssIdentifier,l as isCssNameCharacter,ee as isCssNameStartCharacter,o as isCssWhitespace,M as isInterpolatedMethod,ie as lengthRE,Ae as makeArbitraryValueRule,Re as makeGlobalRules,je as makeGlobalValueRule,X as makeStaticRules,Ve as notLastChildSelector,ne as numberRE,le as numberWithUnitRE,P as parseCssColor,de as percentRE,D as polarColorSpace,q as propsToValueMap,E as rectangularColorSpace,Be as routeGlobalKeywordsToExactRules,H as transformThemeFn,G as transformThemeString,f as unitOnlyMap,ue as unitOnlyRE,v as valueHandlers};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{cssLengthUnitRESource as e,cssLengthUnits as t,globalKeywords as n}from"./constants.js";import{a as r,c as i,i as a,n as o,o as s,t as c}from"./css-identifier-4yDg85cV.js";import{escapeSelector as l}from"@teacss/core";const ee=`(?:${t.join(`|`)})`,u=RegExp(`^([+-]?\\d*(?:\\.\\d+)?(?:e[+-]?\\d+)?)(${ee})?$`,`i`),d=/^([+-]?\d*(?:\.\d+)?(?:e[+-]?\d+)?)$/i,f=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(?:deg|grad|rad|turn)$/i,p=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?%$/i,te=RegExp(`^[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:e[+-]?\\d+)?${e}$`,`i`),m={px:1,vw:100,vh:100,svw:100,svh:100,dvw:100,dvh:100,lvh:100,lvw:100},h=RegExp(`^(${Object.keys(m).join(`|`)})$`,`i`),g=/^\[(color|image|length|size|position|quoted|string):/i,_=new Set([...t,`angle`,`color`,`dpcm`,`deg`,`dpi`,`dppx`,`flex`,`fr`,`frequency`,`grad`,`hz`,`integer`,`khz`,`length`,`ms`,`number`,`percentage`,`rad`,`raw-string`,`resolution`,`s`,`string`,`time`,`turn`,`url`,`x`]);function v(e){return e.length>2&&e.startsWith(`--`)&&r(e)}function ne(e){let t=0,n,r=-1;for(let i=0;i<e.length;i++){let a=e[i];if(n){a===`\\`?i++:a===n&&(n=void 0,r=-1);continue}if(a===`"`||a===`'`)n=a,r=i;else if(a===`\\`)i++;else if(a===`[`)t++;else if(a===`]`&&--t<0)return!1}if(r>=0){for(let n=r+1;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===`[`)t++;else if(e[n]===`]`&&--t<0)return!1}return t===0}function y(e){let t=[],n;for(let r=0;r<e.length;r++){let s=e[r];if(!n&&T(e,r)){let t=o(e,r);if(t!=null){if(e[r-1]!==`#`&&e[r-1]!==`@`&&e[t]===`(`&&a(e.slice(r,t)).toLowerCase()===`url`){let n=t+1;for(;i(e[n]);)n++;if(e[n]!==`"`&&e[n]!==`'`){let t=b(e,n);if(t==null)return!1;r=t-1;continue}}r=t-1;continue}}if(s===`\\`){if(n&&/[\n\r\f]/.test(e[r+1]??``)){r+=e[r+1]===`\r`&&e[r+2]===`
|
|
2
|
+
`?2:1;continue}let t=c(e,r);if(t==null)return!1;r=t-1;continue}if(n){if(s===n)n=void 0;else if(/[\n\r\f]/.test(s))return!1;continue}if(s===`"`||s===`'`)n=s;else if(s===`/`&&e[r+1]===`*`){let t=e.indexOf(`*/`,r+2);if(t===-1)return!1;r=t+1}else if(s===`*`&&e[r+1]===`/`)return!1;else if(s===`(`||s===`[`||s===`{`)t.push(s===`(`?`)`:s===`[`?`]`:`}`);else if(s===`)`||s===`]`||s===`}`){if(t.pop()!==s)return!1}else if(s===`;`&&t.length===0)return!1}return n==null&&t.length===0}function b(e,t){for(let n=t;n<e.length;n++){if(e[n]===`)`)return n+1;if(e[n]===`\\`){let t=c(e,n);if(t==null)return;n=t-1}}}function x(e){return`"${e.replace(/[\0-\x1f\x7f"\\]/g,e=>e===`\0`?`�`:e===`"`||e===`\\`?`\\${e}`:`\\${e.charCodeAt(0).toString(16)} `)}"`}function S(e){if(!e)return;let t=e.length-1;if(!(t<2||e.charCodeAt(0)!==91||e.charCodeAt(t)!==93)&&(e.charCodeAt(1)!==45||e.charCodeAt(2)!==45)){for(let n=1;n<t;n++)switch(e.charCodeAt(n)){case 34:case 39:case 40:case 41:case 58:case 59:case 91:case 92:case 93:case 95:case 96:case 123:case 125:return;case 42:case 47:if(e.charCodeAt(n+1)===42||e.charCodeAt(n+1)===47)return}return e.slice(1,t)}}function C(e){let t=``;for(let n=0;n<e.length;n++)e[n]===`\\`&&e[n+1]===`_`?(t+=`_`,n++):t+=e[n]===`_`?` `:e[n];return t}function w(e,t){let n=0;for(;t>0&&e[--t]===`\\`;)n++;return n%2==1}function T(e,t){if(t===0)return!0;let n=e[t-1];return n===`_`&&!w(e,t-1)||n!==`\\`&&!s(n)}function re(e,t,n,r){for(let i=t;i<n;i++)e[i]===`_`&&!w(e,i)&&!ie(e,i)&&r.add(i)}function ie(e,t){let n=t-1,r=0;for(;n>=0&&r<6&&/[0-9a-f]/i.test(e[n]);)n--,r++;return r>0&&e[n]===`\\`&&!w(e,n)}function E(e,t,n){let r=e.lastIndexOf(`_`,n-1);for(;r>=t&&w(e,r);)r=e.lastIndexOf(`_`,r-1);return r}function ae(e,t,n){let r=E(e,t,n);if(r<t)return n;if(r===n-1&&e[n]===`%`)return r;let i=a(e.slice(r+1,n)).toLowerCase();return _.has(i)||i===`type`&&e[n]===`(`?r:n}function D(e){return e!=null&&e>=`0`&&e<=`9`}function oe(e,t,n){let r=D(e[n])||e[n]===`+`&&D(e[n+1]);if(e[n-1]===`_`&&!w(e,n-1)&&r)return n-1;let i=n;for(;i>t&&D(e[i-1]);)i--;if(i===n)return n;let a=n;for(;i>t&&e[i-1]===`_`&&!w(e,i-1);){a=--i;let n=i;for(;i>t&&D(e[i-1]);)i--;if(i===n)break}return a}function se(e){let t=[];return e.replace(/var\((--.+?)[,)]/g,(e,n)=>(t.push(n),e.replace(n,`--calc`))).replace(/(-?\d*\.?\d(?!-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,`$1 $2 `).replace(/--calc/g,()=>t.shift())}function ce(e){let t=[],n=/(?:calc|clamp|max|min)\(/gi,r=0,i;for(;(i=n.exec(e))!==null;){if(!T(e,i.index))continue;let a=A(e,n.lastIndex);a!=null&&(t.push(e.slice(r,i.index),se(e.slice(i.index,a))),r=a,n.lastIndex=a)}return r===0?e:(t.push(e.slice(r)),t.join(``))}function O(e,t){let n=e[t];if(n===`"`||n===`'`){for(let r=t+1;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===n)return r+1;return e.length}if(e[t]===`/`&&e[t+1]===`*`){let n=e.indexOf(`*/`,t+2);return n<0?e.length:n+2}}function le(e,t){let n=t;for(;n<e.length;){if(i(e[n])||e[n]===`_`&&!w(e,n)){n++;continue}if(e[n]!==`/`||e[n+1]!==`*`)return n;let t=O(e,n);if(t==null)return n;n=t}return n}function ue(e){let t=new Set,n=[];for(let r=0;r<e.length;){let i=O(e,r);if(i!=null){r=i;continue}let s=o(e,r);if(s==null){r++;continue}if(!T(e,r)){if(e[s]!==`(`){r=s;continue}let t=e.lastIndexOf(`_`,s-1);r=t>r?t+1:s;continue}if(e[s]!==`(`){r=s;continue}let c=E(e,r,s);if(c>=r){r=c+1;continue}let l=a(e.slice(r,s)).toLowerCase();if(l===`url`){let t=A(e,s+1);if(t==null)break;n.push({start:r,end:t}),r=t;continue}if(l===`attr`||l===`env`||l===`var`){let n=le(e,s+1),r=o(e,n);r!=null&&re(e,n,l===`attr`?ae(e,n,r):l===`env`?oe(e,n,r):r,t)}r=s+1}return{indexes:t,literals:n}}function k(e){let t=ue(e),n=0,r=``;for(let i=0;i<e.length;i++){let a=t.literals[n];if(a&&i===a.start){r+=e.slice(a.start,a.end),i=a.end-1,n++;continue}if(e[i]===`\\`&&e[i+1]===`_`){r+=`_`,i++;continue}r+=e[i]===`_`&&!t.indexes.has(i)?` `:e[i]}return r}function A(e,t){let n=1,r;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`){i++;continue}if(r)t===r&&(r=void 0);else if(t===`"`||t===`'`)r=t;else if(t===`(`)n++;else if(t===`)`&&--n===0)return i+1}}function j(e){let t=S(e);if(t!==void 0)return t;if(!e?.startsWith(`[`)||!e.endsWith(`]`))return;let n=e.match(g),r=e.slice(n?.[0].length??1,-1);if(!r||r===`=""`)return;let i=n?.[1];if(i===`quoted`)return ne(r)?x(C(r)):void 0;if(!y(r))return;if(i===`string`){let e=C(r);return y(e)?e:void 0}v(r)&&(r=`var(${r})`);let a=ce(k(r));return y(a)?a:void 0}function M(e){return j(e)}function N(e,t){if(e!=null&&Object.hasOwn(e,t))return e[t]}function P(e,t,n=0){let r=`${t}(`,i;for(let t=n;t<=e.length-r.length;t++){let n=e[t];if(i!=null){n===`\\`?t=(c(e,t)??t+1)-1:n===i&&(i=void 0);continue}if(n===`'`||n===`"`){i=n;continue}if(n===`\\`){t=(c(e,t)??t+1)-1;continue}if(n===`/`&&e[t+1]===`*`){let n=e.indexOf(`*/`,t+2);if(n===-1)return-1;t=n+1;continue}if(!e.startsWith(r,t))continue;let a=e[t-1];if(t===0||!s(a))return t}return-1}function F(e,t){let n=P(e,t);return n>=0&&e.indexOf(`)`,n+t.length+1)>=0}function I(e,t,n=!1){if(e.length<=t.length+1||e[t.length]!==`(`||e.at(-1)!==`)`)return!1;let r=e.slice(0,t.length);if(n?r.toLowerCase()!==t.toLowerCase():r!==t)return!1;let i=1,a;for(let n=t.length+1;n<e.length;n++){let t=e[n];if(t===`\\`){n++;continue}if(a!=null){t===a&&(a=void 0);continue}if(t===`'`||t===`"`){a=t;continue}if(t===`(`)i++;else if(t===`)`&&--i===0)return n===e.length-1}return!1}const L=new Set(n),R=String.raw`[+-]?(?:\d+|\d*\.\d+)(?:[eE][+-]?\d+)?`,z=RegExp(`^${R}$`),B=RegExp(`^${R}%$`),V=RegExp(`^(${R})(s|ms)?$`,`i`),H=RegExp(`^(${R})(deg|rad|grad|turn)?$`,`i`),U=`color.border-color.background-color.outline-color.text-decoration-color.flex-grow.flex.flex-shrink.caret-color.font.gap.opacity.visibility.z-index.font-weight.zoom.text-shadow.transform.box-shadow.border.background-position.left.right.top.bottom.object-position.max-height.min-height.max-width.min-width.height.width.border-width.margin.padding.outline-width.outline-offset.font-size.line-height.text-indent.vertical-align.border-spacing.letter-spacing.word-spacing.stroke.filter.backdrop-filter.fill.mask.mask-size.mask-border.clip-path.clip.border-radius`.split(`.`);function W(e){return+e.toFixed(10)}function de(e){let t=e.match(u);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(r&&Number.isFinite(i))return`${W(i)}${r}`}function fe(e){if(e===`auto`)return`auto`}function pe(e){if(e===`empty`)return`""`}function me(e){if(e===`square`)return`1/1`}function he(e){if(e===`video`)return`16/9`}function ge(e){if(!e)return;if(h.test(e))return`${m[e.toLowerCase()]}${e}`;let t=e.match(u);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(Number.isFinite(i))return i===0?`0`:r?`${W(i)}${r}`:`${W(i/4)}rem`}function _e(e){if(h.test(e))return`${m[e.toLowerCase()]}${e}`;let t=e?.match(u);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(Number.isFinite(i))return r?`${W(i)}${r}`:`${W(i)}px`}function G(e){if(!d.test(e))return;let t=Number.parseFloat(e);if(Number.isFinite(t))return W(t)}function ve(e){if(/^-?\d+$/.test(e))return e}function ye(e){if(/^[1-9]\d*$/.test(e))return e}function be(e){if(!r(e))return;let t=a(e).toLowerCase();if(!(t==="default"||L.has(t)))return e}function xe(e){if(e.length>5&&I(e,`url`,!0))return e}function K(e){if(B.test(e))return e;if(d.test(e)){let t=Number.parseFloat(e);if(Number.isFinite(t))return`${W(t)}%`}}function Se(e){return/^\d*\.\d+$/.test(e)?e:K(e)}function Ce(e){if(!e)return;let t=e.indexOf(`/`);if(t<=0||t!==e.lastIndexOf(`/`)||t===e.length-1)return;let n=e.slice(0,t),r=e.slice(t+1);if(!z.test(n)||!z.test(r))return;let i=Number(r);if(i===0)return;let a=Number(n)/i;if(Number.isFinite(a))return a===0?`0`:`${W(a*100)}%`}function we(e){let t=G(e);if(t!=null)return Number(t)===0?`0`:`calc(var(--spacing) * ${t})`}function q(e){return M(e)}function J(e){if(!/^\$[^\s'"`;{}]/.test(e))return;let t=e.slice(1),n=t.indexOf(`|`),r=n===-1?t:t.slice(0,n),i=n===-1?void 0:t.slice(n+1);if(!r||/[,@\s'"`;{}]/.test(r)||n!==-1&&!i)return;let a=i;if(i?.startsWith(`$`)){if(a=J(i),a==null)return}else if(i!=null&&!y(i))return;return`var(--${l(r)}${a?`, ${a}`:``})`}function Y(e){let t=e.match(V);if(!t)return;let[,n,r]=t,i=Number(n);if(Number.isFinite(i))return i===0&&!r?`0s`:r?`${W(i)}${r}`:`${W(i)}ms`}function Te(e){let t=e.match(H);if(!t)return;let[,n,r]=t,i=Number(n);if(Number.isFinite(i))return i===0&&!r?`0`:r?`${W(i)}${r}`:`${W(i)}deg`}function X(e){if(L.has(e))return e}function Ee(e){if(e.split(`,`).every(e=>U.includes(e)))return e}function De(e){if([`top`,`left`,`right`,`bottom`,`center`].includes(e))return e}function Oe(e){if([`top`,`bottom`,`left`,`right`,`center`,`top-left`,`top-right`,`bottom-left`,`bottom-right`].includes(e))return e}function ke(e){if(e===`none`)return`none`}function Ae(e){if(e===`none`||e===`zero`)return`0`}function Z(e){if(Object.hasOwn(e,`__options`))throw Error(`"__options" is a reserved createValueHandler name`);let t=Object.keys(e),n=Object.create(Function.prototype),r=new WeakMap;function i(t){let i=Object.freeze([...t]),a=((t,n)=>{for(let r of i){let i=e[r](t,n);if(i!=null)return i}});return Object.defineProperty(a,"__options",{enumerable:!0,value:Object.freeze({sequence:Object.freeze([...i])})}),r.set(a,i),Object.setPrototypeOf(a,n),a}function a(e){for(let n of t)Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get(){let e=i([...r.get(this)??[],n]);return Object.defineProperty(this,n,{enumerable:!0,configurable:!0,value:e}),e}})}a(n);let o=i([]);return a(o),o}const Q=Object.freeze({alpha:Se,auto:fe,bracket:q,cssvar:J,customIdent:be,degree:Te,empty:pe,fraction:Ce,global:X,integer:ve,none:ke,number:G,numberWithUnit:de,percent:K,placement:Oe,position:De,positiveInteger:ye,properties:Ee,px:_e,rem:ge,spacing:we,square:me,time:Y,url:xe,video:he,zero:Ae}),$=Z(Q),je=$;export{d as _,q as a,m as b,W as c,N as d,M as f,te as g,g as h,Z as i,P as l,f as m,$ as n,J as o,v as p,Q as r,X as s,je as t,F as u,u as v,h as x,p as y};
|
package/dist/value-resolvers.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cssLengthUnitRESource as e,globalKeywords as t}from"./constants.js";import{findLastTopLevelDelimiter as n,splitTopLevelCommas as r,topLevelWhitespaceSpans as i}from"./css-syntax.js";import{c as a,g as o,h as s,n as c,u as l}from"./css-value-syntax-BRbCuvQw.js";import{c as u,d,f,n as p,t as m,x as h}from"./standard-value-handler-
|
|
1
|
+
import{cssLengthUnitRESource as e,globalKeywords as t}from"./constants.js";import{findLastTopLevelDelimiter as n,splitTopLevelCommas as r,topLevelWhitespaceSpans as i}from"./css-syntax.js";import{c as a,g as o,h as s,n as c,u as l}from"./css-value-syntax-BRbCuvQw.js";import{c as u,d,f,n as p,t as m,x as h}from"./standard-value-handler-idWIIPjr.js";function g(e){return/^\d{1,3}$/.test(e)&&Number(e)<=100}function _(e){let t=m.global.cssvar(e);if(t!=null)return t;let n=m.bracket(e);return n==null?a.test(e)?`${e}%`:m.alpha(e):o(n)?n:void 0}function v(e,t){if(t==null)return e;if(!g(t))throw Error(`applyOpacity received an invalid opacity modifier: ${t}`);return`color-mix(in oklab, ${e} ${Number(t)}%, transparent)`}function y(e){let t=n(e,`/`);return t<0?[e]:[e.slice(0,t),e.slice(t+1)]}function b(e){return m.cssvar(e)!=null}function x(e,t){return m.cssvar.global(e)??m.bracket(e)??(t.has(e)?e:void 0)}function S(e,t){return m.cssvar.global(e)??(t.has(e)?e:m.bracket(e))}function C(e,t){let n=p.fraction.number(e)??t;if(n==null)return;let r=String(n);return r.endsWith(`%`)?u(Number(r.slice(0,-1))/100):Number(n)}const w=RegExp(`^([+-]?(?:\\d+|\\d*\\.\\d+)(?:e[+-]?\\d+)?)(${e})?$`,`i`),T=/^[+-]?(?:\d+|\d*\.\d+)(?:e[+-]?\d+)?%$/i,E=new Set(t);function D(e){return i(e).map(e=>e.value)}function O(e){return/rpx$/i.test(e)||T.test(e)?!1:h.test(e)||w.test(e)}function k(e){if(/rpx$/i.test(e))return;let t=m.px(e);if(t!=null)return t;let n=e.match(w);if(!n)return;let r=Number(n[1]);if(!Number.isFinite(r))return;let i=Number(r.toFixed(10));return n[2]?`${i}${n[2]}`:`${i}px`}function A(e){let t=f(e);return t==null?e.startsWith(`[`)||e.endsWith(`]`)?!1:b(e)?!0:e.startsWith(`-`)||E.has(e)?!1:O(e):j(t).length===1&&D(t).length===1&&s(t)&&!l(t)}function j(e){return r(e)}function M(e){return j(e).some(e=>D(e).filter(e=>w.test(e)).slice(2,4).some(e=>Number(e.match(w)?.[1])<0))}const N=new Set;function P(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function F(e){return typeof e==`string`?e:e.join(`-`)}function I(e,t,n,r,i=N){let a=d(e,t);if(!a)return;let o=F(n),s=d(a,o);if(s!=null)return i.has(o)?typeof s==`string`?s:s.join(` `):`var(--${r??P(t)}-${o})`}function L(e){return e.replace(/\/\*[\s\S]*?\*\//g,` `).trim()}function R(e,t=[]){let n=m.bracket(e);if(n!=null){let e=r(n);return e.length>0&&e.every(e=>{let n=L(e);return t.includes(n)||c(n)&&!V(n)})?n:void 0}let i=m.cssvar.global(e);if(i!=null)return i;if(t.includes(e))return e;let a=m.time(e);return a?.startsWith(`-`)?void 0:a}function z(e){let t=m.bracket(e);if(t!=null){let e=r(t);return e.length>0&&e.every(e=>c(L(e)))?t:void 0}return m.cssvar.global.time(e)}const B=/^([+-]?(?:\d+|\d*\.\d+)(?:e[+-]?\d+)?)(?:ms|s)?$/i;function V(e){let t=e.match(B);return t!=null&&Number(t[1])<0}export{v as applyOpacity,P as camelToKebab,M as hasInvalidTextShadowRadius,b as isCssVariableToken,A as isNonnegativeLengthValue,g as isValidOpacityModifier,k as normalizeShadowLength,_ as resolveAlphaValue,x as resolveKeyword,S as resolveKeywordList,R as resolveNonnegativeTime,C as resolveNumber,I as resolveThemeVariable,z as resolveTime,y as splitOpacity,j as splitShadowLayers};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teacss/rule-helpers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Helpers for authoring TeaCSS preset rules — static/dynamic rule builders and value resolvers.",
|
|
5
5
|
"homepage": "https://css.teasim.com",
|
|
6
6
|
"funding": "https://github.com/sponsors/billgo",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dev": "tsdown --watch"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@teacss/core": "0.
|
|
29
|
+
"@teacss/core": "0.6.0"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
32
|
"node": ">=22.12.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{cssLengthUnitRESource as e,cssLengthUnits as t,globalKeywords as n}from"./constants.js";import{a as r,c as i,i as a,n as o,o as s,t as c}from"./css-identifier-4yDg85cV.js";import{escapeSelector as l}from"@teacss/core";const u=`(?:${t.join(`|`)})`,d=RegExp(`^([+-]?\\d*(?:\\.\\d+)?(?:e[+-]?\\d+)?)(${u})?$`,`i`),f=/^([+-]?\d*(?:\.\d+)?(?:e[+-]?\d+)?)$/i,p=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(?:deg|grad|rad|turn)$/i,m=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?%$/i,h=RegExp(`^[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:e[+-]?\\d+)?${e}$`,`i`),g={px:1,vw:100,vh:100,svw:100,svh:100,dvw:100,dvh:100,lvh:100,lvw:100},_=RegExp(`^(${Object.keys(g).join(`|`)})$`,`i`),v=/^\[(color|image|length|size|position|quoted|string):/i,ee=new Set([...t,`angle`,`color`,`dpcm`,`deg`,`dpi`,`dppx`,`flex`,`fr`,`frequency`,`grad`,`hz`,`integer`,`khz`,`length`,`ms`,`number`,`percentage`,`rad`,`raw-string`,`resolution`,`s`,`string`,`time`,`turn`,`url`,`x`]);function y(e){return e.length>2&&e.startsWith(`--`)&&r(e)}function te(e){let t=0,n,r=-1;for(let i=0;i<e.length;i++){let a=e[i];if(n){a===`\\`?i++:a===n&&(n=void 0,r=-1);continue}if(a===`"`||a===`'`)n=a,r=i;else if(a===`\\`)i++;else if(a===`[`)t++;else if(a===`]`&&--t<0)return!1}if(r>=0){for(let n=r+1;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===`[`)t++;else if(e[n]===`]`&&--t<0)return!1}return t===0}function b(e){let t=(t,n)=>{let r=[],i;for(let a=t;a<e.length;a++){let t=e[a];if(i){t===`\\`?a++:t===i&&(i=void 0);continue}if(n&&(t===`"`||t===`'`))i=t;else if(t===`\\`)a++;else if(t===`/`&&e[a+1]===`*`){let t=e.indexOf(`*/`,a+2);if(t===-1)return!1;a=t+1}else if(t===`*`&&e[a+1]===`/`)return!1;else if(t===`(`)r.push(`)`);else if(t===`{`)r.push(`}`);else if(t===`)`||t===`}`){if(r.pop()!==t)return!1}else if(t===`;`&&r.length===0)return!1}return i===void 0?r.length===0:e.length},n=t(0,!0);return typeof n==`boolean`?n:t(0,!1)===!0}function ne(e){if(!e)return;let t=e.length-1;if(!(t<2||e.charCodeAt(0)!==91||e.charCodeAt(t)!==93)&&(e.charCodeAt(1)!==45||e.charCodeAt(2)!==45)){for(let n=1;n<t;n++)switch(e.charCodeAt(n)){case 34:case 39:case 40:case 41:case 58:case 59:case 91:case 92:case 93:case 95:case 96:case 123:case 125:return;case 42:case 47:if(e.charCodeAt(n+1)===42||e.charCodeAt(n+1)===47)return}return e.slice(1,t)}}function x(e){let t=``;for(let n=0;n<e.length;n++)e[n]===`\\`&&e[n+1]===`_`?(t+=`_`,n++):t+=e[n]===`_`?` `:e[n];return t}function S(e,t){let n=0;for(;t>0&&e[--t]===`\\`;)n++;return n%2==1}function C(e,t){if(t===0)return!0;let n=e[t-1];return n===`_`&&!S(e,t-1)||n!==`\\`&&!s(n)}function re(e,t,n,r){for(let i=t;i<n;i++)e[i]===`_`&&!S(e,i)&&!w(e,i)&&r.add(i)}function w(e,t){let n=t-1,r=0;for(;n>=0&&r<6&&/[0-9a-f]/i.test(e[n]);)n--,r++;return r>0&&e[n]===`\\`&&!S(e,n)}function T(e,t,n){let r=e.lastIndexOf(`_`,n-1);for(;r>=t&&S(e,r);)r=e.lastIndexOf(`_`,r-1);return r}function E(e,t,n){let r=T(e,t,n);if(r<t)return n;if(r===n-1&&e[n]===`%`)return r;let i=a(e.slice(r+1,n)).toLowerCase();return ee.has(i)||i===`type`&&e[n]===`(`?r:n}function D(e){return e!=null&&e>=`0`&&e<=`9`}function ie(e,t,n){let r=D(e[n])||e[n]===`+`&&D(e[n+1]);if(e[n-1]===`_`&&!S(e,n-1)&&r)return n-1;let i=n;for(;i>t&&D(e[i-1]);)i--;if(i===n)return n;let a=n;for(;i>t&&e[i-1]===`_`&&!S(e,i-1);){a=--i;let n=i;for(;i>t&&D(e[i-1]);)i--;if(i===n)break}return a}function ae(e){let t=[];return e.replace(/var\((--.+?)[,)]/g,(e,n)=>(t.push(n),e.replace(n,`--calc`))).replace(/(-?\d*\.?\d(?!-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,`$1 $2 `).replace(/--calc/g,()=>t.shift())}function oe(e){let t=[],n=/(?:calc|clamp|max|min)\(/gi,r=0,i;for(;(i=n.exec(e))!==null;){if(!C(e,i.index))continue;let a=k(e,n.lastIndex);a!=null&&(t.push(e.slice(r,i.index),ae(e.slice(i.index,a))),r=a,n.lastIndex=a)}return r===0?e:(t.push(e.slice(r)),t.join(``))}function O(e,t){let n=e[t];if(n===`"`||n===`'`){for(let r=t+1;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===n)return r+1;return e.length}if(e[t]===`/`&&e[t+1]===`*`){let n=e.indexOf(`*/`,t+2);return n<0?e.length:n+2}}function se(e,t){let n=t;for(;n<e.length;){if(i(e[n])||e[n]===`_`&&!S(e,n)){n++;continue}if(e[n]!==`/`||e[n+1]!==`*`)return n;let t=O(e,n);if(t==null)return n;n=t}return n}function ce(e){let t=new Set,n=[];for(let r=0;r<e.length;){let i=O(e,r);if(i!=null){r=i;continue}let s=o(e,r);if(s==null){r++;continue}if(!C(e,r)){if(e[s]!==`(`){r=s;continue}let t=e.lastIndexOf(`_`,s-1);r=t>r?t+1:s;continue}if(e[s]!==`(`){r=s;continue}let c=T(e,r,s);if(c>=r){r=c+1;continue}let l=a(e.slice(r,s)).toLowerCase();if(l===`url`){let t=k(e,s+1);if(t==null)break;n.push({start:r,end:t}),r=t;continue}if(l===`attr`||l===`env`||l===`var`){let n=se(e,s+1),r=o(e,n);r!=null&&re(e,n,l===`attr`?E(e,n,r):l===`env`?ie(e,n,r):r,t)}r=s+1}return{indexes:t,literals:n}}function le(e){let t=ce(e),n=0,r=``;for(let i=0;i<e.length;i++){let a=t.literals[n];if(a&&i===a.start){r+=e.slice(a.start,a.end),i=a.end-1,n++;continue}if(e[i]===`\\`&&e[i+1]===`_`){r+=`_`,i++;continue}r+=e[i]===`_`&&!t.indexes.has(i)?` `:e[i]}return r}function k(e,t){let n=1,r;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`){i++;continue}if(r)t===r&&(r=void 0);else if(t===`"`||t===`'`)r=t;else if(t===`(`)n++;else if(t===`)`&&--n===0)return i+1}}function A(e){let t=ne(e);if(t!==void 0)return t;if(!e?.startsWith(`[`)||!e.endsWith(`]`))return;let n=e.match(v),r=e.slice(n?.[0].length??1,-1);if(!r||r===`=""`||!te(r))return;let i=n?.[1];if(i===`quoted`)return`"${x(r).replace(/(["\\])/g,`\\$1`)}"`;if(b(r))return i===`string`?x(r):(y(r)&&(r=`var(${r})`),oe(le(r)))}function j(e){return A(e)}function M(e,t){if(e!=null&&Object.hasOwn(e,t))return e[t]}function N(e,t,n=0){let r=`${t}(`,i;for(let t=n;t<=e.length-r.length;t++){let n=e[t];if(i!=null){n===`\\`?t=(c(e,t)??t+1)-1:n===i&&(i=void 0);continue}if(n===`'`||n===`"`){i=n;continue}if(n===`\\`){t=(c(e,t)??t+1)-1;continue}if(n===`/`&&e[t+1]===`*`){let n=e.indexOf(`*/`,t+2);if(n===-1)return-1;t=n+1;continue}if(!e.startsWith(r,t))continue;let a=e[t-1];if(t===0||!s(a))return t}return-1}function P(e,t){let n=N(e,t);return n>=0&&e.indexOf(`)`,n+t.length+1)>=0}function F(e,t,n=!1){if(e.length<=t.length+1||e[t.length]!==`(`||e.at(-1)!==`)`)return!1;let r=e.slice(0,t.length);if(n?r.toLowerCase()!==t.toLowerCase():r!==t)return!1;let i=1,a;for(let n=t.length+1;n<e.length;n++){let t=e[n];if(t===`\\`){n++;continue}if(a!=null){t===a&&(a=void 0);continue}if(t===`'`||t===`"`){a=t;continue}if(t===`(`)i++;else if(t===`)`&&--i===0)return n===e.length-1}return!1}const I=new Set(n),L=String.raw`[+-]?(?:\d+|\d*\.\d+)(?:[eE][+-]?\d+)?`,R=RegExp(`^${L}$`),z=RegExp(`^${L}%$`),B=RegExp(`^(${L})(s|ms)?$`,`i`),V=RegExp(`^(${L})(deg|rad|grad|turn)?$`,`i`),H=`color.border-color.background-color.outline-color.text-decoration-color.flex-grow.flex.flex-shrink.caret-color.font.gap.opacity.visibility.z-index.font-weight.zoom.text-shadow.transform.box-shadow.border.background-position.left.right.top.bottom.object-position.max-height.min-height.max-width.min-width.height.width.border-width.margin.padding.outline-width.outline-offset.font-size.line-height.text-indent.vertical-align.border-spacing.letter-spacing.word-spacing.stroke.filter.backdrop-filter.fill.mask.mask-size.mask-border.clip-path.clip.border-radius`.split(`.`);function U(e){return+e.toFixed(10)}function W(e){let t=e.match(d);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(r&&Number.isFinite(i))return`${U(i)}${r}`}function ue(e){if(e===`auto`)return`auto`}function de(e){if(e===`empty`)return`""`}function fe(e){if(e===`square`)return`1/1`}function pe(e){if(e===`video`)return`16/9`}function me(e){if(!e)return;if(_.test(e))return`${g[e.toLowerCase()]}${e}`;let t=e.match(d);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(Number.isFinite(i))return i===0?`0`:r?`${U(i)}${r}`:`${U(i/4)}rem`}function he(e){if(_.test(e))return`${g[e.toLowerCase()]}${e}`;let t=e?.match(d);if(!t)return;let[,n,r]=t,i=Number.parseFloat(n);if(Number.isFinite(i))return r?`${U(i)}${r}`:`${U(i)}px`}function G(e){if(!f.test(e))return;let t=Number.parseFloat(e);if(Number.isFinite(t))return U(t)}function ge(e){if(/^-?\d+$/.test(e))return e}function _e(e){if(/^[1-9]\d*$/.test(e))return e}function ve(e){if(!r(e))return;let t=a(e).toLowerCase();if(!(t==="default"||I.has(t)))return e}function ye(e){if(e.length>5&&F(e,`url`,!0))return e}function K(e){if(z.test(e))return e;if(f.test(e)){let t=Number.parseFloat(e);if(Number.isFinite(t))return`${U(t)}%`}}function be(e){return/^\d*\.\d+$/.test(e)?e:K(e)}function xe(e){if(!e)return;let t=e.indexOf(`/`);if(t<=0||t!==e.lastIndexOf(`/`)||t===e.length-1)return;let n=e.slice(0,t),r=e.slice(t+1);if(!R.test(n)||!R.test(r))return;let i=Number(r);if(i===0)return;let a=Number(n)/i;if(Number.isFinite(a))return a===0?`0`:`${U(a*100)}%`}function Se(e){let t=G(e);if(t!=null)return Number(t)===0?`0`:`calc(var(--spacing) * ${t})`}function q(e){return j(e)}function J(e){if(!/^\$[^\s'"`;{}]/.test(e))return;let t=e.slice(1),n=t.indexOf(`|`),r=n===-1?t:t.slice(0,n),i=n===-1?void 0:t.slice(n+1);if(!r||/[,@\s'"`;{}]/.test(r)||n!==-1&&!i)return;let a=i;if(i?.startsWith(`$`)){if(a=J(i),a==null)return}else if(i!=null&&!b(i))return;return`var(--${l(r)}${a?`, ${a}`:``})`}function Ce(e){let t=e.match(B);if(!t)return;let[,n,r]=t,i=Number(n);if(Number.isFinite(i))return i===0&&!r?`0s`:r?`${U(i)}${r}`:`${U(i)}ms`}function we(e){let t=e.match(V);if(!t)return;let[,n,r]=t,i=Number(n);if(Number.isFinite(i))return i===0&&!r?`0`:r?`${U(i)}${r}`:`${U(i)}deg`}function Y(e){if(I.has(e))return e}function Te(e){if(e.split(`,`).every(e=>H.includes(e)))return e}function Ee(e){if([`top`,`left`,`right`,`bottom`,`center`].includes(e))return e}function De(e){if([`top`,`bottom`,`left`,`right`,`center`,`top-left`,`top-right`,`bottom-left`,`bottom-right`].includes(e))return e}function Oe(e){if(e===`none`)return`none`}function ke(e){if(e===`none`||e===`zero`)return`0`}function X(e){if(Object.hasOwn(e,`__options`))throw Error(`"__options" is a reserved createValueHandler name`);let t=Object.keys(e),n=Object.create(Function.prototype),r=new WeakMap;function i(t){let i=Object.freeze([...t]),a=((t,n)=>{for(let r of i){let i=e[r](t,n);if(i!=null)return i}});return Object.defineProperty(a,"__options",{enumerable:!0,value:Object.freeze({sequence:Object.freeze([...i])})}),r.set(a,i),Object.setPrototypeOf(a,n),a}function a(e){for(let n of t)Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get(){let e=i([...r.get(this)??[],n]);return Object.defineProperty(this,n,{enumerable:!0,configurable:!0,value:e}),e}})}a(n);let o=i([]);return a(o),o}const Z=Object.freeze({alpha:be,auto:ue,bracket:q,cssvar:J,customIdent:ve,degree:we,empty:de,fraction:xe,global:Y,integer:ge,none:Oe,number:G,numberWithUnit:W,percent:K,placement:De,position:Ee,positiveInteger:_e,properties:Te,px:he,rem:me,spacing:Se,square:fe,time:Ce,url:ye,video:pe,zero:ke}),Q=X(Z),$=Q;export{f as _,q as a,g as b,U as c,M as d,j as f,h as g,v as h,X as i,N as l,p as m,Q as n,J as o,y as p,Z as r,Y as s,$ as t,P as u,d as v,_ as x,m as y};
|