@master/css 2.0.0-beta.122 → 2.0.0-beta.123

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.
@@ -1 +1 @@
1
- import{analyzeValueToken as f}from"../utils/analyze-value-token";import{getBorderProps as b}from"../utils/get-border-props";import{parseValueUnit as y}from"../utils/parse-value-unit";import{START_SYMBOL as v}from"../constants/start-symbol";import{BOX_UNDERNEATH as d}from"../constants/box-underneath";import{CONTENT_EXTREMA as x}from"../constants/content-extrema";import{SIZING_VALUES as h}from"../constants/sizing-values";import"../polyfills/css-escape";import{cssEscape as w}from"../utils/css-escape";var P={group:{matches:"^(?:.+?[*_>~+])?\\{.+?\\}",unit:"",prop:!1,analyzeToken(e,r,t){let s=0;for(;s<e.length&&!(e[s]==="{"&&e[s-1]!=="\\");s++);return[e.slice(0,s),...f(e.slice(s),r,t)]},getThemeProps(e,r){let t={},s=(o,a)=>{let i=a.indexOf(":");if(i!==-1){o in t||(t[o]={});let c=t[o],g=a.slice(0,i);g in c||(c[g]=a.slice(i+1))}},l=o=>{let a=(i,c)=>{let g=c.slice(w(o.className).length).match(/\{(.*)\}/)[1].split(";");for(let k of g)s(i,k)};if(this.theme){let i=o.natives.find(c=>c.theme===this.theme)??o.natives.find(c=>!c.theme);i&&a(this.theme,i.text)}else for(let i of o.natives)a(i.theme,i.text)},u=[],n="",p=()=>{n&&(u.push(n.replace(/ /g,"")),n="")},m=1;(function o(a){for(;m<e.value.length;m++){let i=e.value[m];if(!a){if(i===";"){p();continue}if(i==="}")break}if(n+=i,a===i){if(a==="'"||a==='"'){let c=0;for(let g=n.length-2;n[g]==="\\";g--)c++;if(c%2)continue}break}else i in v&&a!=="'"&&a!=='"'&&(m++,o(v[i]))}})(void 0),p();for(let o of u){let a=r.create(o);if(Array.isArray(a))for(let i of a)l(i);else a?l(a):s(this.theme??"",o)}return t}},variable:{matches:"^\\$[^ (){}A-Z]+:[^ ]",unit:"",prop:!1,get(e){return{["--"+this.prefix.slice(1,-1)]:e}}},fontSize:{matches:"^f(?:ont)?:(?:[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},fontWeight:{matches:"^f(?:ont)?:(?:bolder|$values)(?!\\|)",unit:"",values:{thin:100,extralight:200,light:300,regular:400,medium:500,semibold:600,bold:700,extrabold:800,heavy:900}},fontFamily:{matches:"^f(?:ont)?:(?:$values)(?!\\|)",values:{mono:"ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace",sans:"ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji",serif:"ui-serif,Georgia,Cambria,Times New Roman,Times,serif"}},fontSmoothing:{matches:"^f(?:ont)?:(?:antialiased|subpixel-antialiased|$values)(?!\\|)",unit:"",prop:!1,get(e){let r={};switch(e.value){case"subpixel-antialiased":r["-webkit-font-smoothing"]=r["-moz-osx-font-smoothing"]={...e,value:"auto"};break;case"antialiased":r["-webkit-font-smoothing"]={...e,value:"antialiased"},r["-moz-osx-font-smoothing"]={...e,value:"grayscale"};break}return r}},fontStyle:{matches:"^f(?:ont)?:(?:normal|italic|oblique|$values)(?!\\|)",unit:"deg"},fontVariantNumeric:{matches:"^f(?:ont)?:(?:ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions|$values)(?!\\|)"},fontFeatureSettings:{matches:"^font-feature:."},font:{matches:"^f:.",unit:"",order:-1},color:{matches:"^(?:color|fg|foreground):.",colorful:!0,unit:""},spacing:{matches:"^[pm][xytblr]?:.",prop:!1,get(e){let t=this.prefix[0]==="m"?"margin":"padding",s=t+"-left",l=t+"-right",u=t+"-top",n=t+"-bottom";switch(this.prefix[1]){case"x":return{[s]:e,[l]:e};case"y":return{[u]:e,[n]:e};case"l":return{[s]:e};case"r":return{[l]:e};case"t":return{[u]:e};case"b":return{[n]:e};default:return{[t]:e}}},get order(){return this.prefix==="p:"||this.prefix==="m:"?-1:0}},margin:{matches:"^margin(?:-(?:left|right|top|bottom))?:.",prop:!1,get(e){return{[this.prefix.slice(0,-1)]:e}},get order(){return this.prefix==="margin:"?-1:0}},padding:{matches:"^padding(?:-(?:left|right|top|bottom))?:.",prop:!1,get(e){return{[this.prefix.slice(0,-1)]:e}},get order(){return this.prefix==="padding:"?-1:0}},flexBasis:{values:h},flexWrap:{matches:"^flex:(?:wrap(?:-reverse)?|nowrap|$values)(?!\\|)"},flexGrow:{unit:""},flexShrink:{unit:""},flexDirection:{matches:"^flex:(?:(?:row|column)(?:-reverse)?|$values)(?!\\|)",values:{col:"column","col-reverse":"column-reverse"}},flex:{unit:"",order:-1},display:{matches:"^d:."},width:{matches:"^w:.",values:h},height:{matches:"^h:.",values:h},minWidth:{matches:"^min-w:.",values:h},minHeight:{matches:"^min-h:.",values:h},wH:{matches:"^(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",prop:!1,analyzeToken(e,r,t){return["",...f(e,r,t,["x"])]},get(e){let[r,t]=e.value.split(" x ");return{width:{...e,value:r},height:{...e,value:t}}}},minWH:{matches:"^min:(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",prop:!1,analyzeToken(e,r,t){return["",...f(e.slice(4),r,t,["x"])]},get(e){let[r,t]=e.value.split(" x ");return{"min-width":{...e,value:r},"min-height":{...e,value:t}}}},maxWH:{matches:"^max:(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",prop:!1,analyzeToken(e,r,t){return["",...f(e.slice(4),r,t,["x"])]},get(e){let[r,t]=e.value.split(" x ");return{"max-width":{...e,value:r},"max-height":{...e,value:t}}}},contain:{},content:{},counterIncrement:{unit:""},counterReset:{unit:""},letterSpacing:{matches:"^ls:.",unit:"em"},lineHeight:{matches:"^lh:.",unit:""},objectFit:{matches:"^(?:object|obj):(?:contain|cover|fill|scale-down|$values)"},objectPosition:{matches:"^(?:object|obj):(?:top|bottom|right|left|center|$values)"},textAlign:{matches:"^t(?:ext)?:(?:justify|center|left|right|start|end|$values)(?!\\|)"},textDecorationColor:{colorStarts:"text-decoration:",colorful:!0},textDecorationStyle:{matches:"^t(?:ext)?:(?:solid|double|dotted|dashed|wavy|$values)(?!\\|)"},textDecorationThickness:{matches:"^text-decoration:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|from-font|$values)[^|]*$",unit:"em"},textDecorationLine:{matches:"^t(?:ext)?:(?:none|underline|overline|line-through|$values)(?!\\|)"},textDecoration:{matches:"^t(?:ext)?:(?:underline|line-through|overline|$values)",colorful:!0,order:-1},textUnderlineOffset:{},textOverflow:{matches:"^(?:text-(?:overflow|ovf):.|t(?:ext)?:(?:ellipsis|clip|$values)(?!\\|))"},textOrientation:{matches:"^t(?:ext)?:(?:mixed|upright|sideways-right|sideways|use-glyph-orientation|$values)(?!\\|)"},textTransform:{matches:"^t(?:ext)?:(?:uppercase|lowercase|capitalize|$values)(?!\\|)"},textRendering:{matches:"^t(?:ext)?:(?:optimizeSpeed|optimizeLegibility|geometricPrecision|$values)(?!\\|)"},textIndent:{},verticalAlign:{matches:"^(?:v|vertical):."},columns:{matches:"^(?:columns|cols):.",unit:"",order:-1},whiteSpace:{unit:""},inset:{matches:"^(?:top|bottom|left|right):.",get(e){return{[this.prefix.slice(0,-1)]:e}}},lines:{matches:"^lines:.",unit:"",prop:!1,get(e){return{overflow:{...e,value:"hidden"},display:{...e,value:"-webkit-box"},"overflow-wrap":{...e,value:"break-word"},"text-overflow":{...e,value:"ellipsis"},"-webkit-box-orient":{...e,value:"vertical"},"-webkit-line-clamp":e}}},maxHeight:{matches:"^max-h:.",values:h},maxWidth:{matches:"^max-w:.",values:h},boxSizing:{matches:"^box:(?:$values)(?!\\|)",values:{content:"content-box",border:"border-box"}},opacity:{unit:""},visibility:{},clear:{},float:{},isolation:{},overflow:{matches:"^overflow(?:-x|-y)?:(?:visible|overlay|hidden|scroll|auto|clip|inherit|initial|revert|revert-layer|unset|\\$|var|$values)",prop:!1,get(e){if(this.prefix)switch(this.prefix.slice(-2,-1)){case"x":return{"overflow-x":e};case"y":return{"overflow-y":e}}return{overflow:e}},get order(){return-1}},overscrollBehavior:{matches:"^overscroll-behavior(?:-[xy])?:",prop:!1,get(e){switch(this.prefix.slice(-2,-1)){case"x":return{"overscroll-behavior-x":e};case"y":return{"overscroll-behavior-y":e};default:return{"overscroll-behavior":e}}}},zIndex:{matches:"^z:.",unit:""},position:{values:{abs:"absolute",rel:"relative"}},cursor:{},pointerEvents:{},resize:{},touchAction:{},wordBreak:{unit:""},wordSpacing:{unit:"em"},userDrag:{get(e){return{"user-drag":e,"-webkit-user-drag":e}}},userSelect:{get(e){return{"user-select":e,"-webkit-user-select":e}}},textShadow:{colorful:!0},textSize:{matches:"^t(?:ext)?:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",prop:!1,get(e){let{unit:r,value:t}=e,s=.75;return{"font-size":e,"line-height":{...e,value:r==="em"?t+s+r:`calc(${t}${r} + ${s}em)`,unit:""}}}},textFillColor:{matches:"^text-fill-color:.",colorStarts:"(?:text-fill|text|t):",colorful:!0,prop:!1,get(e){return{"-webkit-text-fill-color":e}}},textStrokeWidth:{matches:"^text-stroke(:(thin|medium|thick|\\.?[0-9]+|$values)(?!\\|)|-width:.)",prop:!1,get(e){return{"-webkit-text-stroke-width":e}}},textStrokeColor:{matches:"^text-stroke-color:.",colorStarts:"text-stroke:",colorful:!0,prop:!1,get(e){return{"-webkit-text-stroke-color":e}}},textStroke:{matches:"^text-stroke:.",prop:!1,get(e){return{"-webkit-text-stroke":e}}},boxShadow:{matches:"^s(?:hadow)?:.",colorful:!0},tableLayout:{},transformBox:{matches:"^transform:(?:$values)(?!\\|)",values:{...d,fill:"fill-box",stroke:"stroke-box",view:"view-box"}},transformStyle:{matches:"^transform:(?:flat|preserve-3d|$values)(?!\\|)"},transformOrigin:{matches:"^transform:(?:top|bottom|right|left|center|[0-9]|$values)",unit:"px"},transform:{matches:"^(?:translate|scale|skew|rotate|perspective|matrix)(?:3d|[XYZ])?\\(",unit:"",parseValue(e,{rootSize:r}){return e.replace(/(translate|scale|skew|rotate|perspective|matrix)(3d|[XYZ])?\((.*?)\)/g,(t,s,l,u)=>{let n,p;switch(s){case"translate":n="rem";break;case"skew":n="deg";break;case"rotate":l==="3d"&&(p=!0),n="deg";break;default:return t}let m=u.split(",");return t.replace(u,m.map((o,a)=>!p||m.length-1===a?Number.isNaN(+o)?o:o/(n==="rem"?r:1)+n:o).join(","))})}},transitionProperty:{matches:"^~property:."},transitionTimingFunction:{matches:"^~easing:."},transitionDuration:{matches:"^~duration:.",unit:"ms"},transitionDelay:{matches:"^~delay:.",unit:"ms"},transition:{symbol:"~",order:-1},animationDelay:{matches:"^@delay:.",unit:"ms"},animationDirection:{matches:"^@direction:."},animationDuration:{matches:"^@duration:.",unit:"ms"},animationFillMode:{matches:"^@fill-mode:."},animationIterationCount:{matches:"^@iteration-count:.",unit:""},animationName:{matches:"^@name:."},animationPlayState:{matches:"^@play-state:."},animationTimingFunction:{matches:"^@easing:."},animation:{symbol:"@",unit:"",order:-1},borderColor:{matches:"^border(?:-(?:left|right|top|bottom))?-color:.",colorStarts:"b(?:[xytblr]|(?:order(?:-(?:left|right|top|bottom))?))?:",colorful:!0,prop:!1,get(e){return b(this.prefix,e,"color")},get order(){return this.prefix==="border-color:"||this.prefix==="b:"||this.prefix==="border:"?-1:0}},borderRadius:{matches:"^(?:r[tblr]?[tblr]?|border(?:-(?:top|bottom)-(?:left|right))?-radius):.",prop:!1,get(e){if(this.prefix){let t="",s=this.prefix.split("-");if(s.length>1)for(let l=1;l<s.length-1;l++)t+=s[l][0];else t=this.prefix.slice(1,-1);switch(t){case"t":return{"border-top-left-radius":e,"border-top-right-radius":e};case"tl":case"lt":return{"border-top-left-radius":e};case"rt":case"tr":return{"border-top-right-radius":e};case"b":return{"border-bottom-left-radius":e,"border-bottom-right-radius":e};case"bl":case"lb":return{"border-bottom-left-radius":e};case"br":case"rb":return{"border-bottom-right-radius":e};case"l":return{"border-top-left-radius":e,"border-bottom-left-radius":e};case"r":return{"border-top-right-radius":e,"border-bottom-right-radius":e};default:return{"border-radius":e}}}let r=this.prefix?.slice(0,-1);return{[["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].includes(r)?r:"border-radius"]:e}},get order(){return this.prefix==="border-radius:"||this.prefix==="r:"?-1:0}},borderStyle:{matches:"^(?:border(?:-(?:left|right|top|bottom))?-style:.|b(?:[xytblr]|order(?:-(?:left|right|top|bottom))?)?:(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|))",prop:!1,get(e){return b(this.prefix,e,"style")},get order(){return this.prefix==="border-style:"||this.prefix==="b:"||this.prefix==="border:"?-1:0}},borderWidth:{matches:"^(?:border(?:-(?:left|right|top|bottom))?-width:.|b(?:[xytblr]|order(?:-(?:left|right|top|bottom))?)?:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$)",prop:!1,get(e){return b(this.prefix,e,"width")},get order(){return this.prefix==="border-width:"||this.prefix==="b:"||this.prefix==="border:"?-1:0}},borderCollapse:{matches:"^b(?:order)?:(?:collapse|separate|$values)(?!\\|)"},borderSpacing:{},borderImageOutset:{},borderImageRepeat:{matches:"^border-image:(?:stretch|repeat|round|space|$values)(?!\\|)"},borderImageSlice:{unit:""},borderImageSource:{matches:"^border-image:(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)"},borderImageWidth:{matches:"^border-image:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},borderImage:{unit:""},border:{matches:"^b(?:[xytblr]?|order(?:-(?:left|right|top|bottom))?):.",colorful:!0,prop:!1,get(e){return b(this.prefix,e)},get order(){return this.prefix==="border:"||this.prefix==="b:"?-2:-1}},backgroundAttachment:{matches:"^(?:bg|background):(?:fixed|local|scroll|$values)(?!\\|)"},backgroundBlendMode:{},backgroundColor:{colorStarts:"(?:bg|background):",unit:"",colorful:!0},backgroundClip:{matches:"^(?:bg|background):(?:text|$values)(?!\\|)",get(e){return{"-webkit-background-clip":e,"background-clip":e}},values:d},backgroundOrigin:{matches:"^(?:bg|background):(?:$values)(?!\\|)",values:d},backgroundPosition:{matches:"^(?:bg|background):(?:top|bottom|right|left|center|$values)(?!\\|)",unit:"px"},backgroundRepeat:{matches:"^(?:bg|background):(?:space|round|repeat|no-repeat|repeat-x|repeat-y|$values)(?![|a-zA-Z])"},backgroundSize:{matches:"^(?:bg|background):(?:\\.?\\[0-9]+|auto|cover|contain|$values)(?!\\|)"},backgroundImage:{matches:"^(?:bg|background):(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)",colorful:!0},background:{matches:"^bg:.",colorful:!0,order:-1},mixBlendMode:{matches:"^blend:."},backdropFilter:{matches:"^bd:.",colorful:!0,get(e){return{"backdrop-filter":e,"-webkit-backdrop-filter":e}},parseValue(e,r){return y(e,t=>{switch(t){case"blur":case"drop-shadow":return"rem";case"hue-rotate":return"deg"}return""},r)}},filter:{matches:"^(?:blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\\(",colorful:!0,parseValue(e,r){return y(e,t=>{switch(t){case"blur":case"drop-shadow":return"rem";case"hue-rotate":return"deg"}return""},r)}},fill:{colorStarts:"fill:",colorful:!0},strokeDasharray:{},strokeDashoffset:{},strokeWidth:{matches:"^stroke:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},stroke:{colorful:!0},x:{unit:""},y:{unit:""},cx:{unit:""},cy:{unit:""},rx:{unit:""},ry:{unit:""},gridColumnStart:{matches:"^grid-col-start:.",unit:""},gridColumnEnd:{matches:"^grid-col-end:.",unit:""},gridColumn:{matches:"^grid-col(?:umn)?(?:-span)?:.",unit:"",order:-1,parseValue(e){return this.prefix.slice(-5,-1)==="span"&&e!=="auto"?"span "+e+"/span "+e:e}},gridColumns:{matches:"^grid-cols:.",unit:"",get(e){return{display:{...e,value:"grid"},"grid-template-columns":{...this,value:"repeat("+e.value+",minmax("+0+","+1+"fr))"}}}},gridRowStart:{unit:""},gridRowEnd:{unit:""},gridRow:{matches:"^grid-row-span:.",unit:"",order:-1,parseValue(e){return this.prefix.slice(-5,-1)==="span"&&e!=="auto"?"span "+e+"/span "+e:e}},gridRows:{unit:"",get(e){return{display:{...e,value:"grid"},"grid-auto-flow":{...e,value:"column"},"grid-template-rows":{...e,value:"repeat("+e.value+",minmax("+0+","+1+"fr))"}}}},gridAutoColumns:{matches:"^grid-auto-cols:.",values:x},gridAutoFlow:{matches:"^grid-flow:."},gridAutoRows:{values:x},gridTemplateAreas:{},gridTemplateColumns:{matches:"^grid-template-cols:.",values:x},gridTemplateRows:{values:x},gridTemplate:{order:-1},gridArea:{unit:"",order:-1},grid:{order:-1},gap:{matches:"^gap(?:-x|-y)?:.",order:-1,prop:!1,get(e){switch(this.prefix[4]){case"x":return{"column-gap":e};case"y":return{"row-gap":e};default:return{gap:e}}}},order:{matches:"^o:.",unit:"",values:{first:-999999,last:999999}},breakInside:{},breakBefore:{},breakAfter:{},boxDecorationBreak:{matches:"^box:(?:slice|clone|$values)(?!\\|)",get(e){return{"box-decoration-break":e,"-webkit-box-decoration-break":e}}},aspectRatio:{matches:"^aspect:.",unit:""},columnSpan:{matches:"^col-span:."},alignContent:{matches:"^ac:."},alignItems:{matches:"^ai:."},alignSelf:{matches:"^as:"},justifyContent:{matches:"^jc:."},justifyItems:{matches:"^ji:."},justifySelf:{matches:"^js:."},placeContent:{order:-1},placeItems:{order:-1},placeSelf:{order:-1},listStylePosition:{matches:"^list-style:(?:inside|outside|$values)(?!\\|)"},listStyleType:{matches:"^list-style:(?:disc|decimal|$values)(?!\\|)"},listStyleImage:{matches:"^list-style:(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)"},listStyle:{order:-1},outlineColor:{colorStarts:"outline:",colorful:!0},outlineOffset:{},outlineStyle:{matches:"^outline:(?:none|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)"},outlineWidth:{matches:"^outline:(?:\\.?[0-9]|medium|thick|thin|(max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},outline:{order:-1,colorful:!0},accentColor:{colorStarts:"accent:",colorful:!0},appearance:{},caretColor:{colorStarts:"caret:",colorful:!0},scrollBehavior:{},scrollMargin:{matches:"^scroll-m(?:[xytblr]|argin(?:-(?:top|bottom|left|right))?)?:.",prop:!1,get(e){if(this.prefix.slice(-3,-2)==="m")switch(this.prefix.slice(-2,-1)){case"x":return{"scroll-margin-left":e,"scroll-margin-right":e};case"y":return{"scroll-margin-top":e,"scroll-margin-bottom":e};case"l":return{"scroll-margin-left":e};case"r":return{"scroll-margin-right":e};case"t":return{"scroll-margin-top":e};case"b":return{"scroll-margin-bottom":e}}else return{[this.prefix.replace(/-m(?!argin)/,"-margin").slice(0,-1)]:e}},get order(){return this.prefix==="scroll-margin:"||this.prefix==="scroll-m:"?-1:0}},scrollPadding:{matches:"^scroll-p(?:[xytblr]|adding(?:-(?:top|bottom|left|right))?)?:.",prop:!1,get(e){if(this.prefix.slice(-3,-2)==="p")switch(this.prefix.slice(-2,-1)){case"x":return{"scroll-padding-left":e,"scroll-padding-right":e};case"y":return{"scroll-padding-top":e,"scroll-padding-bottom":e};case"l":return{"scroll-padding-left":e};case"r":return{"scroll-padding-right":e};case"t":return{"scroll-padding-top":e};case"b":return{"scroll-padding-bottom":e}}else return{[this.prefix.replace(/-p(?!adding)/,"-padding").slice(0,-1)]:e}},get order(){return this.prefix==="scroll-padding:"||this.prefix==="scroll-p:"?-1:0}},scrollSnapAlign:{matches:"^scroll-snap:(?:start|end|center|$values)"},scrollSnapStop:{matches:"^scroll-snap:(?:normal|always|$values)(?!\\|)"},scrollSnapType:{matches:"^scroll-snap:(?:(?:[xy]|block|inline|both)(?:\\|(?:proximity|mandatory))?|$values)(?!\\|)"},willChange:{},writingMode:{matches:"^writing:."},direction:{},shapeOutside:{matches:"^shape:(?:(?:inset|circle|ellipse|polygon|url|linear-gradient)\\(.*\\)|$values)(?!\\|)",values:{...d,margin:"margin-box"}},shapeMargin:{matches:"^shape:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},shapeImageThreshold:{unit:""},clipPath:{matches:"^clip:.",values:{...d,margin:"margin-box",fill:"fill-box",stroke:"stroke-box",view:"view-box"}},quotes:{},maskImage:{get(e){return{"mask-image":e,"-webkit-mask-image":e}}}};export{P as rules};
1
+ import{analyzeValueToken as f}from"../utils/analyze-value-token.js";import{getBorderProps as b}from"../utils/get-border-props.js";import{parseValueUnit as y}from"../utils/parse-value-unit.js";import{START_SYMBOL as v}from"../constants/start-symbol.js";import{BOX_UNDERNEATH as d}from"../constants/box-underneath.js";import{CONTENT_EXTREMA as x}from"../constants/content-extrema.js";import{SIZING_VALUES as h}from"../constants/sizing-values.js";import"../polyfills/css-escape.js";import{cssEscape as w}from"../utils/css-escape.js";var P={group:{matches:"^(?:.+?[*_>~+])?\\{.+?\\}",unit:"",prop:!1,analyzeToken(e,r,t){let s=0;for(;s<e.length&&!(e[s]==="{"&&e[s-1]!=="\\");s++);return[e.slice(0,s),...f(e.slice(s),r,t)]},getThemeProps(e,r){let t={},s=(o,a)=>{let i=a.indexOf(":");if(i!==-1){o in t||(t[o]={});let c=t[o],g=a.slice(0,i);g in c||(c[g]=a.slice(i+1))}},l=o=>{let a=(i,c)=>{let g=c.slice(w(o.className).length).match(/\{(.*)\}/)[1].split(";");for(let k of g)s(i,k)};if(this.theme){let i=o.natives.find(c=>c.theme===this.theme)??o.natives.find(c=>!c.theme);i&&a(this.theme,i.text)}else for(let i of o.natives)a(i.theme,i.text)},u=[],n="",p=()=>{n&&(u.push(n.replace(/ /g,"")),n="")},m=1;(function o(a){for(;m<e.value.length;m++){let i=e.value[m];if(!a){if(i===";"){p();continue}if(i==="}")break}if(n+=i,a===i){if(a==="'"||a==='"'){let c=0;for(let g=n.length-2;n[g]==="\\";g--)c++;if(c%2)continue}break}else i in v&&a!=="'"&&a!=='"'&&(m++,o(v[i]))}})(void 0),p();for(let o of u){let a=r.create(o);if(Array.isArray(a))for(let i of a)l(i);else a?l(a):s(this.theme??"",o)}return t}},variable:{matches:"^\\$[^ (){}A-Z]+:[^ ]",unit:"",prop:!1,get(e){return{["--"+this.prefix.slice(1,-1)]:e}}},fontSize:{matches:"^f(?:ont)?:(?:[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},fontWeight:{matches:"^f(?:ont)?:(?:bolder|$values)(?!\\|)",unit:"",values:{thin:100,extralight:200,light:300,regular:400,medium:500,semibold:600,bold:700,extrabold:800,heavy:900}},fontFamily:{matches:"^f(?:ont)?:(?:$values)(?!\\|)",values:{mono:"ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace",sans:"ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji",serif:"ui-serif,Georgia,Cambria,Times New Roman,Times,serif"}},fontSmoothing:{matches:"^f(?:ont)?:(?:antialiased|subpixel-antialiased|$values)(?!\\|)",unit:"",prop:!1,get(e){let r={};switch(e.value){case"subpixel-antialiased":r["-webkit-font-smoothing"]=r["-moz-osx-font-smoothing"]={...e,value:"auto"};break;case"antialiased":r["-webkit-font-smoothing"]={...e,value:"antialiased"},r["-moz-osx-font-smoothing"]={...e,value:"grayscale"};break}return r}},fontStyle:{matches:"^f(?:ont)?:(?:normal|italic|oblique|$values)(?!\\|)",unit:"deg"},fontVariantNumeric:{matches:"^f(?:ont)?:(?:ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions|$values)(?!\\|)"},fontFeatureSettings:{matches:"^font-feature:."},font:{matches:"^f:.",unit:"",order:-1},color:{matches:"^(?:color|fg|foreground):.",colorful:!0,unit:""},spacing:{matches:"^[pm][xytblr]?:.",prop:!1,get(e){let t=this.prefix[0]==="m"?"margin":"padding",s=t+"-left",l=t+"-right",u=t+"-top",n=t+"-bottom";switch(this.prefix[1]){case"x":return{[s]:e,[l]:e};case"y":return{[u]:e,[n]:e};case"l":return{[s]:e};case"r":return{[l]:e};case"t":return{[u]:e};case"b":return{[n]:e};default:return{[t]:e}}},get order(){return this.prefix==="p:"||this.prefix==="m:"?-1:0}},margin:{matches:"^margin(?:-(?:left|right|top|bottom))?:.",prop:!1,get(e){return{[this.prefix.slice(0,-1)]:e}},get order(){return this.prefix==="margin:"?-1:0}},padding:{matches:"^padding(?:-(?:left|right|top|bottom))?:.",prop:!1,get(e){return{[this.prefix.slice(0,-1)]:e}},get order(){return this.prefix==="padding:"?-1:0}},flexBasis:{values:h},flexWrap:{matches:"^flex:(?:wrap(?:-reverse)?|nowrap|$values)(?!\\|)"},flexGrow:{unit:""},flexShrink:{unit:""},flexDirection:{matches:"^flex:(?:(?:row|column)(?:-reverse)?|$values)(?!\\|)",values:{col:"column","col-reverse":"column-reverse"}},flex:{unit:"",order:-1},display:{matches:"^d:."},width:{matches:"^w:.",values:h},height:{matches:"^h:.",values:h},minWidth:{matches:"^min-w:.",values:h},minHeight:{matches:"^min-h:.",values:h},wH:{matches:"^(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",prop:!1,analyzeToken(e,r,t){return["",...f(e,r,t,["x"])]},get(e){let[r,t]=e.value.split(" x ");return{width:{...e,value:r},height:{...e,value:t}}}},minWH:{matches:"^min:(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",prop:!1,analyzeToken(e,r,t){return["",...f(e.slice(4),r,t,["x"])]},get(e){let[r,t]=e.value.split(" x ");return{"min-width":{...e,value:r},"min-height":{...e,value:t}}}},maxWH:{matches:"^max:(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",prop:!1,analyzeToken(e,r,t){return["",...f(e.slice(4),r,t,["x"])]},get(e){let[r,t]=e.value.split(" x ");return{"max-width":{...e,value:r},"max-height":{...e,value:t}}}},contain:{},content:{},counterIncrement:{unit:""},counterReset:{unit:""},letterSpacing:{matches:"^ls:.",unit:"em"},lineHeight:{matches:"^lh:.",unit:""},objectFit:{matches:"^(?:object|obj):(?:contain|cover|fill|scale-down|$values)"},objectPosition:{matches:"^(?:object|obj):(?:top|bottom|right|left|center|$values)"},textAlign:{matches:"^t(?:ext)?:(?:justify|center|left|right|start|end|$values)(?!\\|)"},textDecorationColor:{colorStarts:"text-decoration:",colorful:!0},textDecorationStyle:{matches:"^t(?:ext)?:(?:solid|double|dotted|dashed|wavy|$values)(?!\\|)"},textDecorationThickness:{matches:"^text-decoration:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|from-font|$values)[^|]*$",unit:"em"},textDecorationLine:{matches:"^t(?:ext)?:(?:none|underline|overline|line-through|$values)(?!\\|)"},textDecoration:{matches:"^t(?:ext)?:(?:underline|line-through|overline|$values)",colorful:!0,order:-1},textUnderlineOffset:{},textOverflow:{matches:"^(?:text-(?:overflow|ovf):.|t(?:ext)?:(?:ellipsis|clip|$values)(?!\\|))"},textOrientation:{matches:"^t(?:ext)?:(?:mixed|upright|sideways-right|sideways|use-glyph-orientation|$values)(?!\\|)"},textTransform:{matches:"^t(?:ext)?:(?:uppercase|lowercase|capitalize|$values)(?!\\|)"},textRendering:{matches:"^t(?:ext)?:(?:optimizeSpeed|optimizeLegibility|geometricPrecision|$values)(?!\\|)"},textIndent:{},verticalAlign:{matches:"^(?:v|vertical):."},columns:{matches:"^(?:columns|cols):.",unit:"",order:-1},whiteSpace:{unit:""},inset:{matches:"^(?:top|bottom|left|right):.",get(e){return{[this.prefix.slice(0,-1)]:e}}},lines:{matches:"^lines:.",unit:"",prop:!1,get(e){return{overflow:{...e,value:"hidden"},display:{...e,value:"-webkit-box"},"overflow-wrap":{...e,value:"break-word"},"text-overflow":{...e,value:"ellipsis"},"-webkit-box-orient":{...e,value:"vertical"},"-webkit-line-clamp":e}}},maxHeight:{matches:"^max-h:.",values:h},maxWidth:{matches:"^max-w:.",values:h},boxSizing:{matches:"^box:(?:$values)(?!\\|)",values:{content:"content-box",border:"border-box"}},opacity:{unit:""},visibility:{},clear:{},float:{},isolation:{},overflow:{matches:"^overflow(?:-x|-y)?:(?:visible|overlay|hidden|scroll|auto|clip|inherit|initial|revert|revert-layer|unset|\\$|var|$values)",prop:!1,get(e){if(this.prefix)switch(this.prefix.slice(-2,-1)){case"x":return{"overflow-x":e};case"y":return{"overflow-y":e}}return{overflow:e}},get order(){return-1}},overscrollBehavior:{matches:"^overscroll-behavior(?:-[xy])?:",prop:!1,get(e){switch(this.prefix.slice(-2,-1)){case"x":return{"overscroll-behavior-x":e};case"y":return{"overscroll-behavior-y":e};default:return{"overscroll-behavior":e}}}},zIndex:{matches:"^z:.",unit:""},position:{values:{abs:"absolute",rel:"relative"}},cursor:{},pointerEvents:{},resize:{},touchAction:{},wordBreak:{unit:""},wordSpacing:{unit:"em"},userDrag:{get(e){return{"user-drag":e,"-webkit-user-drag":e}}},userSelect:{get(e){return{"user-select":e,"-webkit-user-select":e}}},textShadow:{colorful:!0},textSize:{matches:"^t(?:ext)?:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",prop:!1,get(e){let{unit:r,value:t}=e,s=.75;return{"font-size":e,"line-height":{...e,value:r==="em"?t+s+r:`calc(${t}${r} + ${s}em)`,unit:""}}}},textFillColor:{matches:"^text-fill-color:.",colorStarts:"(?:text-fill|text|t):",colorful:!0,prop:!1,get(e){return{"-webkit-text-fill-color":e}}},textStrokeWidth:{matches:"^text-stroke(:(thin|medium|thick|\\.?[0-9]+|$values)(?!\\|)|-width:.)",prop:!1,get(e){return{"-webkit-text-stroke-width":e}}},textStrokeColor:{matches:"^text-stroke-color:.",colorStarts:"text-stroke:",colorful:!0,prop:!1,get(e){return{"-webkit-text-stroke-color":e}}},textStroke:{matches:"^text-stroke:.",prop:!1,get(e){return{"-webkit-text-stroke":e}}},boxShadow:{matches:"^s(?:hadow)?:.",colorful:!0},tableLayout:{},transformBox:{matches:"^transform:(?:$values)(?!\\|)",values:{...d,fill:"fill-box",stroke:"stroke-box",view:"view-box"}},transformStyle:{matches:"^transform:(?:flat|preserve-3d|$values)(?!\\|)"},transformOrigin:{matches:"^transform:(?:top|bottom|right|left|center|[0-9]|$values)",unit:"px"},transform:{matches:"^(?:translate|scale|skew|rotate|perspective|matrix)(?:3d|[XYZ])?\\(",unit:"",parseValue(e,{rootSize:r}){return e.replace(/(translate|scale|skew|rotate|perspective|matrix)(3d|[XYZ])?\((.*?)\)/g,(t,s,l,u)=>{let n,p;switch(s){case"translate":n="rem";break;case"skew":n="deg";break;case"rotate":l==="3d"&&(p=!0),n="deg";break;default:return t}let m=u.split(",");return t.replace(u,m.map((o,a)=>!p||m.length-1===a?Number.isNaN(+o)?o:o/(n==="rem"?r:1)+n:o).join(","))})}},transitionProperty:{matches:"^~property:."},transitionTimingFunction:{matches:"^~easing:."},transitionDuration:{matches:"^~duration:.",unit:"ms"},transitionDelay:{matches:"^~delay:.",unit:"ms"},transition:{symbol:"~",order:-1},animationDelay:{matches:"^@delay:.",unit:"ms"},animationDirection:{matches:"^@direction:."},animationDuration:{matches:"^@duration:.",unit:"ms"},animationFillMode:{matches:"^@fill-mode:."},animationIterationCount:{matches:"^@iteration-count:.",unit:""},animationName:{matches:"^@name:."},animationPlayState:{matches:"^@play-state:."},animationTimingFunction:{matches:"^@easing:."},animation:{symbol:"@",unit:"",order:-1},borderColor:{matches:"^border(?:-(?:left|right|top|bottom))?-color:.",colorStarts:"b(?:[xytblr]|(?:order(?:-(?:left|right|top|bottom))?))?:",colorful:!0,prop:!1,get(e){return b(this.prefix,e,"color")},get order(){return this.prefix==="border-color:"||this.prefix==="b:"||this.prefix==="border:"?-1:0}},borderRadius:{matches:"^(?:r[tblr]?[tblr]?|border(?:-(?:top|bottom)-(?:left|right))?-radius):.",prop:!1,get(e){if(this.prefix){let t="",s=this.prefix.split("-");if(s.length>1)for(let l=1;l<s.length-1;l++)t+=s[l][0];else t=this.prefix.slice(1,-1);switch(t){case"t":return{"border-top-left-radius":e,"border-top-right-radius":e};case"tl":case"lt":return{"border-top-left-radius":e};case"rt":case"tr":return{"border-top-right-radius":e};case"b":return{"border-bottom-left-radius":e,"border-bottom-right-radius":e};case"bl":case"lb":return{"border-bottom-left-radius":e};case"br":case"rb":return{"border-bottom-right-radius":e};case"l":return{"border-top-left-radius":e,"border-bottom-left-radius":e};case"r":return{"border-top-right-radius":e,"border-bottom-right-radius":e};default:return{"border-radius":e}}}let r=this.prefix?.slice(0,-1);return{[["border-top-left-radius","border-top-right-radius","border-bottom-left-radius","border-bottom-right-radius"].includes(r)?r:"border-radius"]:e}},get order(){return this.prefix==="border-radius:"||this.prefix==="r:"?-1:0}},borderStyle:{matches:"^(?:border(?:-(?:left|right|top|bottom))?-style:.|b(?:[xytblr]|order(?:-(?:left|right|top|bottom))?)?:(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|))",prop:!1,get(e){return b(this.prefix,e,"style")},get order(){return this.prefix==="border-style:"||this.prefix==="b:"||this.prefix==="border:"?-1:0}},borderWidth:{matches:"^(?:border(?:-(?:left|right|top|bottom))?-width:.|b(?:[xytblr]|order(?:-(?:left|right|top|bottom))?)?:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$)",prop:!1,get(e){return b(this.prefix,e,"width")},get order(){return this.prefix==="border-width:"||this.prefix==="b:"||this.prefix==="border:"?-1:0}},borderCollapse:{matches:"^b(?:order)?:(?:collapse|separate|$values)(?!\\|)"},borderSpacing:{},borderImageOutset:{},borderImageRepeat:{matches:"^border-image:(?:stretch|repeat|round|space|$values)(?!\\|)"},borderImageSlice:{unit:""},borderImageSource:{matches:"^border-image:(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)"},borderImageWidth:{matches:"^border-image:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},borderImage:{unit:""},border:{matches:"^b(?:[xytblr]?|order(?:-(?:left|right|top|bottom))?):.",colorful:!0,prop:!1,get(e){return b(this.prefix,e)},get order(){return this.prefix==="border:"||this.prefix==="b:"?-2:-1}},backgroundAttachment:{matches:"^(?:bg|background):(?:fixed|local|scroll|$values)(?!\\|)"},backgroundBlendMode:{},backgroundColor:{colorStarts:"(?:bg|background):",unit:"",colorful:!0},backgroundClip:{matches:"^(?:bg|background):(?:text|$values)(?!\\|)",get(e){return{"-webkit-background-clip":e,"background-clip":e}},values:d},backgroundOrigin:{matches:"^(?:bg|background):(?:$values)(?!\\|)",values:d},backgroundPosition:{matches:"^(?:bg|background):(?:top|bottom|right|left|center|$values)(?!\\|)",unit:"px"},backgroundRepeat:{matches:"^(?:bg|background):(?:space|round|repeat|no-repeat|repeat-x|repeat-y|$values)(?![|a-zA-Z])"},backgroundSize:{matches:"^(?:bg|background):(?:\\.?\\[0-9]+|auto|cover|contain|$values)(?!\\|)"},backgroundImage:{matches:"^(?:bg|background):(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)",colorful:!0},background:{matches:"^bg:.",colorful:!0,order:-1},mixBlendMode:{matches:"^blend:."},backdropFilter:{matches:"^bd:.",colorful:!0,get(e){return{"backdrop-filter":e,"-webkit-backdrop-filter":e}},parseValue(e,r){return y(e,t=>{switch(t){case"blur":case"drop-shadow":return"rem";case"hue-rotate":return"deg"}return""},r)}},filter:{matches:"^(?:blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\\(",colorful:!0,parseValue(e,r){return y(e,t=>{switch(t){case"blur":case"drop-shadow":return"rem";case"hue-rotate":return"deg"}return""},r)}},fill:{colorStarts:"fill:",colorful:!0},strokeDasharray:{},strokeDashoffset:{},strokeWidth:{matches:"^stroke:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},stroke:{colorful:!0},x:{unit:""},y:{unit:""},cx:{unit:""},cy:{unit:""},rx:{unit:""},ry:{unit:""},gridColumnStart:{matches:"^grid-col-start:.",unit:""},gridColumnEnd:{matches:"^grid-col-end:.",unit:""},gridColumn:{matches:"^grid-col(?:umn)?(?:-span)?:.",unit:"",order:-1,parseValue(e){return this.prefix.slice(-5,-1)==="span"&&e!=="auto"?"span "+e+"/span "+e:e}},gridColumns:{matches:"^grid-cols:.",unit:"",get(e){return{display:{...e,value:"grid"},"grid-template-columns":{...this,value:"repeat("+e.value+",minmax(0,1fr))"}}}},gridRowStart:{unit:""},gridRowEnd:{unit:""},gridRow:{matches:"^grid-row-span:.",unit:"",order:-1,parseValue(e){return this.prefix.slice(-5,-1)==="span"&&e!=="auto"?"span "+e+"/span "+e:e}},gridRows:{unit:"",get(e){return{display:{...e,value:"grid"},"grid-auto-flow":{...e,value:"column"},"grid-template-rows":{...e,value:"repeat("+e.value+",minmax(0,1fr))"}}}},gridAutoColumns:{matches:"^grid-auto-cols:.",values:x},gridAutoFlow:{matches:"^grid-flow:."},gridAutoRows:{values:x},gridTemplateAreas:{},gridTemplateColumns:{matches:"^grid-template-cols:.",values:x},gridTemplateRows:{values:x},gridTemplate:{order:-1},gridArea:{unit:"",order:-1},grid:{order:-1},gap:{matches:"^gap(?:-x|-y)?:.",order:-1,prop:!1,get(e){switch(this.prefix[4]){case"x":return{"column-gap":e};case"y":return{"row-gap":e};default:return{gap:e}}}},order:{matches:"^o:.",unit:"",values:{first:-999999,last:999999}},breakInside:{},breakBefore:{},breakAfter:{},boxDecorationBreak:{matches:"^box:(?:slice|clone|$values)(?!\\|)",get(e){return{"box-decoration-break":e,"-webkit-box-decoration-break":e}}},aspectRatio:{matches:"^aspect:.",unit:""},columnSpan:{matches:"^col-span:."},alignContent:{matches:"^ac:."},alignItems:{matches:"^ai:."},alignSelf:{matches:"^as:"},justifyContent:{matches:"^jc:."},justifyItems:{matches:"^ji:."},justifySelf:{matches:"^js:."},placeContent:{order:-1},placeItems:{order:-1},placeSelf:{order:-1},listStylePosition:{matches:"^list-style:(?:inside|outside|$values)(?!\\|)"},listStyleType:{matches:"^list-style:(?:disc|decimal|$values)(?!\\|)"},listStyleImage:{matches:"^list-style:(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)"},listStyle:{order:-1},outlineColor:{colorStarts:"outline:",colorful:!0},outlineOffset:{},outlineStyle:{matches:"^outline:(?:none|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)"},outlineWidth:{matches:"^outline:(?:\\.?[0-9]|medium|thick|thin|(max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},outline:{order:-1,colorful:!0},accentColor:{colorStarts:"accent:",colorful:!0},appearance:{},caretColor:{colorStarts:"caret:",colorful:!0},scrollBehavior:{},scrollMargin:{matches:"^scroll-m(?:[xytblr]|argin(?:-(?:top|bottom|left|right))?)?:.",prop:!1,get(e){if(this.prefix.slice(-3,-2)==="m")switch(this.prefix.slice(-2,-1)){case"x":return{"scroll-margin-left":e,"scroll-margin-right":e};case"y":return{"scroll-margin-top":e,"scroll-margin-bottom":e};case"l":return{"scroll-margin-left":e};case"r":return{"scroll-margin-right":e};case"t":return{"scroll-margin-top":e};case"b":return{"scroll-margin-bottom":e}}else return{[this.prefix.replace(/-m(?!argin)/,"-margin").slice(0,-1)]:e}},get order(){return this.prefix==="scroll-margin:"||this.prefix==="scroll-m:"?-1:0}},scrollPadding:{matches:"^scroll-p(?:[xytblr]|adding(?:-(?:top|bottom|left|right))?)?:.",prop:!1,get(e){if(this.prefix.slice(-3,-2)==="p")switch(this.prefix.slice(-2,-1)){case"x":return{"scroll-padding-left":e,"scroll-padding-right":e};case"y":return{"scroll-padding-top":e,"scroll-padding-bottom":e};case"l":return{"scroll-padding-left":e};case"r":return{"scroll-padding-right":e};case"t":return{"scroll-padding-top":e};case"b":return{"scroll-padding-bottom":e}}else return{[this.prefix.replace(/-p(?!adding)/,"-padding").slice(0,-1)]:e}},get order(){return this.prefix==="scroll-padding:"||this.prefix==="scroll-p:"?-1:0}},scrollSnapAlign:{matches:"^scroll-snap:(?:start|end|center|$values)"},scrollSnapStop:{matches:"^scroll-snap:(?:normal|always|$values)(?!\\|)"},scrollSnapType:{matches:"^scroll-snap:(?:(?:[xy]|block|inline|both)(?:\\|(?:proximity|mandatory))?|$values)(?!\\|)"},willChange:{},writingMode:{matches:"^writing:."},direction:{},shapeOutside:{matches:"^shape:(?:(?:inset|circle|ellipse|polygon|url|linear-gradient)\\(.*\\)|$values)(?!\\|)",values:{...d,margin:"margin-box"}},shapeMargin:{matches:"^shape:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$"},shapeImageThreshold:{unit:""},clipPath:{matches:"^clip:.",values:{...d,margin:"margin-box",fill:"fill-box",stroke:"stroke-box",view:"view-box"}},quotes:{},maskImage:{get(e){return{"mask-image":e,"-webkit-mask-image":e}}}};export{P as rules};
@@ -1 +1 @@
1
- import{breakpoints as n}from"../config";var o={full:"100%",fit:"fit-content",max:"max-content",min:"min-content"};for(let t in n)o[t]=n[t]/16+"rem";export{o as SIZING_VALUES};
1
+ import{breakpoints as n}from"../config/index.js";var o={full:"100%",fit:"fit-content",max:"max-content",min:"min-content"};for(let t in n)o[t]=n[t]/16+"rem";export{o as SIZING_VALUES};
package/dist/esm/css.js CHANGED
@@ -1 +1 @@
1
- var $=Object.defineProperty;var D=(O,e,t)=>e in O?$(O,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):O[e]=t;var S=(O,e,t)=>(D(O,typeof e!="symbol"?e+"":e,t),t);function L(O){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&O instanceof e||O instanceof Date||O instanceof RegExp)}function N(O){if(typeof Buffer<"u"&&Buffer&&O instanceof Buffer){let e=Buffer.alloc(O.length);return O.copy(e),e}else{if(O instanceof Date)return new Date(O.getTime());if(O instanceof RegExp)return new RegExp(O);throw new Error("Unexpected situation")}}function I(O){let e=[];return O.forEach(function(t,s){typeof t=="object"&&t!==null?Array.isArray(t)?e[s]=I(t):L(t)?e[s]=N(t):e[s]=W({},t):e[s]=t}),e}function F(O,e){return e==="__proto__"?void 0:O[e]}function W(...O){let e={},t,s;return O.forEach(function(d){typeof d!="object"||d===null||Array.isArray(d)||Object.keys(d).forEach(function(x){if(s=F(e,x),t=F(d,x),t!==e)if(typeof t!="object"||t===null){e[x]=t;return}else if(Array.isArray(t)){e[x]=I(t);return}else if(L(t)){e[x]=N(t);return}else if(typeof s!="object"||s===null||Array.isArray(s)){e[x]=W({},t);return}else{e[x]=W(s,t);return}})}),e}import{Rule as H}from"./rule";import{config as B}from"./config";import{Theme as Q}from"./theme";import{rgbToHex as z}from"./utils/rgb-to-hex";import{SELECTOR_SYMBOLS as _}from"./constants/selector-symbols";var A=typeof window<"u",j=class{constructor(e){this.config=e;this.config?.override||(this.config=W(B,e)),this.cache(),A&&this.config.observe&&this.observe(document),j.instances.push(this),this.ready=!0}rules=[];ruleOfClass={};countOfClass={};ready=!1;e=A?new MutationObserver(e=>{let t={},s=[],d=[],x=[],w=(c,n)=>{n?c.classList.forEach(y):c.classList.forEach(g);let l=c.children;for(let m=0;m<l.length;m++){let f=l[m];f.classList&&(d.push(f),w(f,n))}},g=c=>{c in t?t[c]++:t[c]=1},y=c=>{c in t?t[c]--:c in this.countOfClass&&(t[c]=-1)},M=(c,n)=>{for(let l=0;l<c.length;l++){let m=c[l];m.classList&&!d.includes(m)&&!x.includes(m)&&(m.isConnected!==n?(d.push(m),w(m,n)):x.push(m))}};for(let c=0;c<e.length;c++){let n=e[c],{addedNodes:l,removedNodes:m,type:f,target:h}=n;if(f==="attributes"){if(s.find(C=>C.target===h))continue;s.push(n)}else M(l,!1),(!h.isConnected||!d.includes(h))&&M(m,!0)}if(!(!s.length&&!Object.keys(t).length)){for(let{oldValue:c,target:n}of s){let l=d.includes(n),m=n.classList,f=c?c.split(" "):[];if(l){if(n.isConnected)continue;for(let h of f)m.contains(h)||y(h)}else if(n.isConnected){m.forEach(h=>{f.includes(h)||g(h)});for(let h of f)m.contains(h)||y(h)}}for(let c in t){let n=t[c],l=(this.countOfClass[c]||0)+n;l===0?(delete this.countOfClass[c],this.delete(c)):(c in this.countOfClass||this.insert(c),this.countOfClass[c]=l)}}}):null;cache(){this.semantics=[],this.classes={},this.colorThemesMap={},this.relationThemesMap={},this.relations={},this.colorNames=[],this.themeNames=[""],this.selectors={},this.values={},this.globalValues={},this.breakpoints={},this.mediaQueries={},this.matches={};let{semantics:e,classes:t,selectors:s,themes:d,colors:x,values:w,breakpoints:g,mediaQueries:y,rules:M}=this.config;function c(r){return r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function n(r,o,i="",u={}){let a=R=>R?(i?i+"-":"")+R:i,b=Object.entries(r),p=[],T=[];for(let R of b){let E=R[1];(typeof E=="object"&&!Array.isArray(E)?p:T).push(R)}for(let[R,E]of p)n(E,o,a(R),u);if(o&&i)T.length&&(u[i]=T.reduce((R,[E,V])=>(R[E]=V,R),{}));else for(let[R,E]of T)u[a(R)]=E;return u}if(e)for(let[r,o]of Object.entries(n(e,!0)))this.semantics.push([new RegExp("^"+c(r)+"(?=!|\\*|>|\\+|~|:|\\[|@|_|\\.|$)","m"),[r,o]]);if(s)for(let[r,o]of Object.entries(n(s,!1))){let i=new RegExp(c(r)+"(?![a-z-])");for(let u of Array.isArray(o)?o:[o]){let a=u.match(/^::-[a-z]+-/m)?.[0]??"",b=this.selectors[a];b||(b=this.selectors[a]=[]);let p=b.find(([T])=>T===i);p||(p=[i,[]],b.push(p)),p[1].push(u)}}w&&(this.globalValues=n(w,!1)),g&&(this.breakpoints=n(g,!1)),y&&(this.mediaQueries=n(y,!1));let l=t?n(t,!1):{},m=d&&!Array.isArray(d)?Object.entries(d).filter(([,{classes:r}])=>r).reduce((r,[o,{classes:i}])=>(r[o]=n(i,!1),r),{}):{},f=[...Object.keys(l),...Object.entries(m).flatMap(([r,o])=>Object.keys(o))],h=r=>{if(r in this.classes)return;let o=this.classes[r]=[],i=(u,a)=>{if(!a)return;let b=Array.isArray(a)?a:a.replace(/(?:\n(?:\s*))+/g," ").trim().split(" ");for(let p of b){let T=R=>{R in this.relationThemesMap?u in this.relationThemesMap[R]?this.relationThemesMap[R][u].push(r):this.relationThemesMap[R][u]=[r]:this.relationThemesMap[R]={[u]:[r]},o.includes(R)||o.push(R)};if(f.includes(p)){h(p);for(let R of this.classes[p])T(R)}else T(p)}};i("",l?.[r]);for(let[u,a]of Object.entries(m))i(u,a?.[r])};for(let r of f)h(r);for(let r in this.relationThemesMap){let o=this.relations[r]=[];for(let i of Object.values(this.relationThemesMap[r]))for(let u of i)o.includes(u)||o.push(u)}let C=(r,o)=>{if(!o)return;let i=n(o,!0);for(let[u,a]of Object.entries(i)){let b=typeof a=="string"?{"":a}:a;for(let[p,T]of Object.entries(b)){let R=u+(p?"-"+p:"");R in this.colorThemesMap?this.colorThemesMap[R][r]=T:this.colorThemesMap[R]={[r]:T}}}for(let u in o)this.colorNames.includes(u)||this.colorNames.push(u)};if(C("",x),d)if(Array.isArray(d))this.themeNames.push(...d);else for(let r in d){let o=d[r];C(r,o.colors),this.themeNames.push(r)}let v=r=>{for(let[o,i]of Object.entries(this.colorThemesMap))for(let[u,a]of Object.entries(i))a.startsWith("#")||r(o,i,u,a)};if(v((r,o,i,u)=>{let a=/^rgba?\( *([0-9]{1,3}) *(?: |,) *([0-9]{1,3}) *(?: |,) *([0-9]{1,3}) *(?:(?:\/|,) *0?(\.[0-9]))?\)$/.exec(u);if(a){let b="#"+z(+a[1],+a[2],+a[3]);a[4]&&(b+=Math.round(255*+a[4]).toString(16)),o[i]=b}}),v((r,o,i,u)=>{let[a,b]=u.split("/"),p=this.colorThemesMap[a];if(p){let T=(i?p[i]:void 0)??p[""];o[i]=b?T.slice(0,7)+Math.round(255*+b).toString(16):T}else console.warn(`\`${u}\` doesn't exist in the extended config \`.colors\``),delete o[i],Object.keys(o).length||delete this.colorThemesMap[r]}),M)for(let r in M){let o=M[r],{matches:i,prop:u,values:a}=o;if(o.id=r,o.prop=u===!1?"":r.replace(/(?!^)[A-Z]/g,b=>"-"+b).toLowerCase(),a&&(this.values[r]=n(a,!1)),i){let b=Object.keys(this.values[r]??{}),p=i.indexOf("$values");this.matches[r]=new RegExp(p===-1?i:b.length?i.slice(0,p)+b.join("|")+i.slice(p+7):i.slice(0,p-(i[p-1]==="|"?1:0))+i.slice(p+7+(i[p+7]==="|"?1:0)))}}}observe(e,t={subtree:!0,childList:!0}){if(A&&e){this.root=e;let s=e===document;s&&(j.root=this),this.host=s?document.documentElement:root.host,this.theme=new Q(this.host,this.config.theme);let d=s?document.head:e,x=s?document.styleSheets:e.styleSheets;for(let g of x){let{title:y,href:M,ownerNode:c}=g;(y==="master"||M&&M.startsWith(window.location.origin)&&/master(?:\..+)?\.css/.test(M))&&(this.style=c)}if(this.style)for(let g=0;g<this.style.sheet.cssRules.length;g++){let y=c=>{if(c.selectorText){let l=c.selectorText.split(", ")[0].split(" ");for(let m=0;m<l.length;m++){let f=l[m];if(f[0]==="."){let h=f.slice(1),C="";for(let v=0;v<h.length;v++){let r=h[v],o=h[v+1];if(r==="\\"){if(v++,o!=="\\"){C+=o;continue}}else if(_.includes(r))break;C+=r}if(!(C in this.ruleOfClass)&&!(C in this.classes)){let v=this.create(C)[0];if(v)return v}}}}else if(c.cssRules)for(let n=0;n<c.cssRules.length;n++){let l=y(c.cssRules[n]);if(l)return l}},M=y(this.style.sheet.cssRules[g]);if(M){this.rules.push(M),this.ruleOfClass[M.className]=M;for(let c=0;c<M.natives.length;c++)M.natives[c].cssRule=this.style.sheet.cssRules[g+c];g+=M.natives.length-1}}else{this.style=document.createElement("style"),this.style.title="master";let g=d.querySelector('link[rel="styleSheet"], style');g?g.before(this.style):d.append(this.style)}let w=g=>{g.forEach(y=>{y in this.countOfClass?this.countOfClass[y]++:(this.countOfClass[y]=1,this.insert(y))})};w(this.host.classList),t.subtree&&this.host.querySelectorAll("[class]").forEach(g=>w(g.classList)),this.e.observe(e,{...t,attributes:!0,attributeOldValue:!0,attributeFilter:["class"]})}return this}disconnect(){this.e.disconnect(),this.ruleOfClass={},this.countOfClass={},this.rules.length=0;let e=this.style.sheet;if(e)for(let t=e.cssRules.length-1;t>=0;t--)e.deleteRule(t);this.style.remove(),this.style=null,this.theme?.destroy(),this.theme=null}match(e){for(let t in this.config.rules){let s=this.config.rules[t],d=this.matches[t],{colorStarts:x,symbol:w,prop:g}=s,{colorNames:y,colorThemesMap:M}=this;if(d&&d.test(e))return{origin:"matches",config:s};if(x){if(e.match("^"+x+"(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|current|inherit))"))return{origin:"matches",config:s};if(y.length&&e.indexOf("|")===-1){let c=e.match("^"+x+"((?:"+y.join("|")+")[0-9a-zA-Z-]*)");if(c&&c[1]in M)return{origin:"matches",config:s}}}if(w&&e.startsWith(w))return{origin:"symbol",config:s};if(g&&e.startsWith(g+":"))return{origin:"matches",config:s}}for(let t of this.semantics)if(e.match(t[0]))return{origin:"semantics",value:t[1]}}create(e){let t=s=>{if(s in this.ruleOfClass)return this.ruleOfClass[s];let d=this.match(s);if(d)return new H(s,d,this)};return(e in this.classes?this.classes[e].map(s=>t(s)):[t(e)]).filter(s=>s&&s.text)}refresh(e){if(e?.override?this.config=e:this.config=W(B,e),this.cache(),!this.style)return;let t=document.createElement("style");t.title="master",this.style.replaceWith(t),this.style=t,this.rules.length=0,this.ruleOfClass={};for(let s in this.countOfClass)this.insert(s)}destroy(){let e=j.instances;this.disconnect(),e.splice(e.indexOf(this),1)}delete(e){let t=this.style.sheet,s=d=>{let x=this.ruleOfClass[d];if(!(!x||d in this.relations&&this.relations[d].some(w=>w in this.countOfClass))){if(x.natives.length){let w=x.natives[0];for(let g=0;g<t.cssRules.length;g++)if(t.cssRules[g]===w.cssRule){for(let M=0;M<x.natives.length;M++)t.deleteRule(g);this.rules.splice(this.rules.indexOf(x),1);break}}delete this.ruleOfClass[d]}};if(e in this.classes){for(let d of this.classes[e])d in this.countOfClass||s(d);delete this.ruleOfClass[e]}else s(e)}insert(e){let t=this.create(e);return t.length?(this.insertRules(t),!0):!1}insertRules(e){for(let t of e){if(this.ruleOfClass[t.className])continue;let s,d=this.rules.length-1,{media:x,order:w,priority:g,hasWhere:y,className:M}=t,c=(n,l,m,f)=>{let h=0,C;l&&(h=n.findIndex(l)),m&&(C=n.findIndex(m)),h===-1&&(h=n.length),(C===void 0||C===-1)&&(C=n.length);let v=n.slice(h,C);for(let r=0;r<v.length;r++){let o=v[r];if(!(o.priority===-1||f&&f(o))&&(o.priority<g||o.priority===g&&(y&&!o.hasWhere||o.order>=w)))return h+r}return h+v.length};if(x){let n=this.rules.findIndex(l=>l.media);if(n!==-1){let l=x.features["max-width"],m=x.features["min-width"];if(l&&m){let f=l.value-m.value;for(let h=d;h>=n;h--){s=h;let C=this.rules[h],v=C.media,r=v.features["max-width"],o=v.features["min-width"];if(!r||!o){s++;break}let i=r.value-o.value;if(i===f){if(y!==C.hasWhere)continue;if(g!==-1){let u=[this.rules[h]];for(let a=h-1;a>=n;a--){let b=this.rules[a];if(b.hasWhere!==y)break;let p=b.media,T=p.features["max-width"],R=p.features["min-width"];if(!T||!R||T.value-R.value!==i)break;u.unshift(this.rules[a])}s=c(this.rules,a=>a.media&&a.priority!==-1&&a.media.features["min-width"]&&a.media.features["max-width"])}break}else if(i>f)break}}else if(m)for(let f=n;f<=d;f++){s=f;let h=this.rules[f],C=h.media,v=C.features["max-width"],r=C.features["min-width"];if(v){if(r)break;continue}let o=r?.value;if(o===m.value){if(!y&&h.hasWhere){s++;continue}if(g!==-1)s=c(this.rules,i=>i.media,i=>i.media&&i.priority!==-1&&i.media.features["min-width"]&&i.media.features["max-width"],i=>!i.media.features["min-width"]&&!i.media.features["max-width"]);else for(let i=f;i<=d;i++){let u=this.rules[i],a=u.media,b=a.features["min-width"];if(!a.features["max-width"]){if(u.hasWhere!==y||b.value!==o||u.order>=w)break;s=i+1}}break}else{if(o>m.value)break;s++}}else if(l)for(let f=d;f>=n;f--){s=f;let h=this.rules[f],C=h.media,v=C.features["max-width"];if(C.features["min-width"])continue;let o=v?.value;if(!o||o>l.value){s++;break}else if(o===l.value){if(y&&!h.hasWhere)continue;if(g!==-1)s=c(this.rules,i=>i.media,i=>i.media&&i.priority!==-1&&i.media.features["min-width"]&&i.media.features["max-width"],i=>!i.media.features["min-width"]&&!i.media.features["max-width"]);else{let i=[this.rules[f]];for(let u=f-1;u>=n;u--){let a=this.rules[u],b=a.media,p=b.features["min-width"],T=b.features["max-width"];if(!p&&(!T||T.value!==o||a.hasWhere!==y))break;i.unshift(a)}for(let u=0;u<i.length;u++){let a=i[u];if(!a.media.features["min-width"]){if(a.order>=w)break;s=f-i.length+2+u}}}break}}}if(s===void 0)if(n===-1)s=d+1;else if(g!==-1)s=n+c(this.rules.slice(n),void 0,l=>l.media.features["max-width"]||l.media.features["min-width"]);else if(y){let l=n;for(;l<this.rules.length;l++){let m=this.rules[l];if(m.priority!==-1||!m.hasWhere||m.order>=w){s=l;break}}s===void 0&&(s=l)}else for(let l=n;l<=d;l++){s=l;let m=this.rules[l],f=m.media;if(m.priority!==-1||f.features["max-width"]||f.features["min-width"])break;if(m.hasWhere)s++;else if(m.order>=w)break}}else if(g===-1)if(y)s=this.rules.findIndex(n=>!n.hasWhere||n.media||n.priority!==-1||n.order>=w),s===-1&&(s=d+1);else{let n=0;for(;n<this.rules.length;n++){let l=this.rules[n];if(l.media||!l.hasWhere&&(l.order>=w||l.priority!==-1)){s=n;break}}s===void 0&&(s=n)}else s=c(this.rules,void 0,n=>n.media);if(this.rules.splice(s,0,t),this.ruleOfClass[M]=t,this.style){let n=this.style.sheet,l=0,m=f=>{let h=this.rules[f];if(h){if(!h.natives.length)return m(f-1);let C=h.natives[h.natives.length-1].cssRule;for(let v=0;v<n.cssRules.length;v++)if(n.cssRules[v]===C){l=v+1;break}}};m(s-1);for(let f=0;f<t.natives.length;)try{let h=t.natives[f];n.insertRule(h.text,l),h.cssRule=n.cssRules[l++],f++}catch(h){console.error(h),t.natives.splice(f,1)}}}}get text(){return this.rules.map(e=>e.text).join("")}},k=j;S(k,"root"),S(k,"instances",[]),S(k,"refresh",e=>{for(let t of j.instances)t.refresh(e)});A&&(window.MasterCSS=k);export{k as MasterCSS};
1
+ var $=Object.defineProperty;var D=(O,e,t)=>e in O?$(O,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):O[e]=t;var S=(O,e,t)=>(D(O,typeof e!="symbol"?e+"":e,t),t);function N(O){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&O instanceof e||O instanceof Date||O instanceof RegExp)}function I(O){if(typeof Buffer<"u"&&Buffer&&O instanceof Buffer){let e=Buffer.alloc(O.length);return O.copy(e),e}else{if(O instanceof Date)return new Date(O.getTime());if(O instanceof RegExp)return new RegExp(O);throw new Error("Unexpected situation")}}function B(O){let e=[];return O.forEach(function(t,s){typeof t=="object"&&t!==null?Array.isArray(t)?e[s]=B(t):N(t)?e[s]=I(t):e[s]=k({},t):e[s]=t}),e}function L(O,e){return e==="__proto__"?void 0:O[e]}function k(...O){let e={},t,s;return O.forEach(function(d){typeof d!="object"||d===null||Array.isArray(d)||Object.keys(d).forEach(function(x){if(s=L(e,x),t=L(d,x),t!==e)if(typeof t!="object"||t===null){e[x]=t;return}else if(Array.isArray(t)){e[x]=B(t);return}else if(N(t)){e[x]=I(t);return}else if(typeof s!="object"||s===null||Array.isArray(s)){e[x]=k({},t);return}else{e[x]=k(s,t);return}})}),e}import{Rule as H}from"./rule.js";import{config as F}from"./config/index.js";import{Theme as Q}from"./theme.js";import{rgbToHex as z}from"./utils/rgb-to-hex.js";import{SELECTOR_SYMBOLS as _}from"./constants/selector-symbols.js";var A=typeof window<"u",j=class{constructor(e){this.config=e;this.config?.override||(this.config=k(F,e)),this.cache(),A&&this.config.observe&&this.observe(document),j.instances.push(this),this.ready=!0}rules=[];ruleOfClass={};countOfClass={};ready=!1;e=A?new MutationObserver(e=>{let t={},s=[],d=[],x=[],w=(c,n)=>{n?c.classList.forEach(y):c.classList.forEach(g);let l=c.children;for(let m=0;m<l.length;m++){let f=l[m];f.classList&&(d.push(f),w(f,n))}},g=c=>{c in t?t[c]++:t[c]=1},y=c=>{c in t?t[c]--:c in this.countOfClass&&(t[c]=-1)},M=(c,n)=>{for(let l=0;l<c.length;l++){let m=c[l];m.classList&&!d.includes(m)&&!x.includes(m)&&(m.isConnected!==n?(d.push(m),w(m,n)):x.push(m))}};for(let c=0;c<e.length;c++){let n=e[c],{addedNodes:l,removedNodes:m,type:f,target:h}=n;if(f==="attributes"){if(s.find(C=>C.target===h))continue;s.push(n)}else M(l,!1),(!h.isConnected||!d.includes(h))&&M(m,!0)}if(!(!s.length&&!Object.keys(t).length)){for(let{oldValue:c,target:n}of s){let l=d.includes(n),m=n.classList,f=c?c.split(" "):[];if(l){if(n.isConnected)continue;for(let h of f)m.contains(h)||y(h)}else if(n.isConnected){m.forEach(h=>{f.includes(h)||g(h)});for(let h of f)m.contains(h)||y(h)}}for(let c in t){let n=t[c],l=(this.countOfClass[c]||0)+n;l===0?(delete this.countOfClass[c],this.delete(c)):(c in this.countOfClass||this.insert(c),this.countOfClass[c]=l)}}}):null;cache(){this.semantics=[],this.classes={},this.colorThemesMap={},this.relationThemesMap={},this.relations={},this.colorNames=[],this.themeNames=[""],this.selectors={},this.values={},this.globalValues={},this.breakpoints={},this.mediaQueries={},this.matches={};let{semantics:e,classes:t,selectors:s,themes:d,colors:x,values:w,breakpoints:g,mediaQueries:y,rules:M}=this.config;function c(r){return r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function n(r,o,i="",u={}){let a=R=>R?(i?i+"-":"")+R:i,b=Object.entries(r),p=[],T=[];for(let R of b){let E=R[1];(typeof E=="object"&&!Array.isArray(E)?p:T).push(R)}for(let[R,E]of p)n(E,o,a(R),u);if(o&&i)T.length&&(u[i]=T.reduce((R,[E,V])=>(R[E]=V,R),{}));else for(let[R,E]of T)u[a(R)]=E;return u}if(e)for(let[r,o]of Object.entries(n(e,!0)))this.semantics.push([new RegExp("^"+c(r)+"(?=!|\\*|>|\\+|~|:|\\[|@|_|\\.|$)","m"),[r,o]]);if(s)for(let[r,o]of Object.entries(n(s,!1))){let i=new RegExp(c(r)+"(?![a-z-])");for(let u of Array.isArray(o)?o:[o]){let a=u.match(/^::-[a-z]+-/m)?.[0]??"",b=this.selectors[a];b||(b=this.selectors[a]=[]);let p=b.find(([T])=>T===i);p||(p=[i,[]],b.push(p)),p[1].push(u)}}w&&(this.globalValues=n(w,!1)),g&&(this.breakpoints=n(g,!1)),y&&(this.mediaQueries=n(y,!1));let l=t?n(t,!1):{},m=d&&!Array.isArray(d)?Object.entries(d).filter(([,{classes:r}])=>r).reduce((r,[o,{classes:i}])=>(r[o]=n(i,!1),r),{}):{},f=[...Object.keys(l),...Object.entries(m).flatMap(([r,o])=>Object.keys(o))],h=r=>{if(r in this.classes)return;let o=this.classes[r]=[],i=(u,a)=>{if(!a)return;let b=Array.isArray(a)?a:a.replace(/(?:\n(?:\s*))+/g," ").trim().split(" ");for(let p of b){let T=R=>{R in this.relationThemesMap?u in this.relationThemesMap[R]?this.relationThemesMap[R][u].push(r):this.relationThemesMap[R][u]=[r]:this.relationThemesMap[R]={[u]:[r]},o.includes(R)||o.push(R)};if(f.includes(p)){h(p);for(let R of this.classes[p])T(R)}else T(p)}};i("",l?.[r]);for(let[u,a]of Object.entries(m))i(u,a?.[r])};for(let r of f)h(r);for(let r in this.relationThemesMap){let o=this.relations[r]=[];for(let i of Object.values(this.relationThemesMap[r]))for(let u of i)o.includes(u)||o.push(u)}let C=(r,o)=>{if(!o)return;let i=n(o,!0);for(let[u,a]of Object.entries(i)){let b=typeof a=="string"?{"":a}:a;for(let[p,T]of Object.entries(b)){let R=u+(p?"-"+p:"");R in this.colorThemesMap?this.colorThemesMap[R][r]=T:this.colorThemesMap[R]={[r]:T}}}for(let u in o)this.colorNames.includes(u)||this.colorNames.push(u)};if(C("",x),d)if(Array.isArray(d))this.themeNames.push(...d);else for(let r in d){let o=d[r];C(r,o.colors),this.themeNames.push(r)}let v=r=>{for(let[o,i]of Object.entries(this.colorThemesMap))for(let[u,a]of Object.entries(i))a.startsWith("#")||r(o,i,u,a)};if(v((r,o,i,u)=>{let a=/^rgba?\( *([0-9]{1,3}) *(?: |,) *([0-9]{1,3}) *(?: |,) *([0-9]{1,3}) *(?:(?:\/|,) *0?(\.[0-9]))?\)$/.exec(u);if(a){let b="#"+z(+a[1],+a[2],+a[3]);a[4]&&(b+=Math.round(255*+a[4]).toString(16)),o[i]=b}}),v((r,o,i,u)=>{let[a,b]=u.split("/"),p=this.colorThemesMap[a];if(p){let T=(i?p[i]:void 0)??p[""];o[i]=b?T.slice(0,7)+Math.round(255*+b).toString(16):T}else console.warn(`\`${u}\` doesn't exist in the extended config \`.colors\``),delete o[i],Object.keys(o).length||delete this.colorThemesMap[r]}),M)for(let r in M){let o=M[r],{matches:i,prop:u,values:a}=o;if(o.id=r,o.prop=u===!1?"":r.replace(/(?!^)[A-Z]/g,b=>"-"+b).toLowerCase(),a&&(this.values[r]=n(a,!1)),i){let b=Object.keys(this.values[r]??{}),p=i.indexOf("$values");this.matches[r]=new RegExp(p===-1?i:b.length?i.slice(0,p)+b.join("|")+i.slice(p+7):i.slice(0,p-(i[p-1]==="|"?1:0))+i.slice(p+7+(i[p+7]==="|"?1:0)))}}}observe(e,t={subtree:!0,childList:!0}){if(A&&e){this.root=e;let s=e===document;s&&(j.root=this),this.host=s?document.documentElement:root.host,this.theme=new Q(this.host,this.config.theme);let d=s?document.head:e,x=s?document.styleSheets:e.styleSheets;for(let g of x){let{title:y,href:M,ownerNode:c}=g;(y==="master"||M&&M.startsWith(window.location.origin)&&/master(?:\..+)?\.css/.test(M))&&(this.style=c)}if(this.style)for(let g=0;g<this.style.sheet.cssRules.length;g++){let y=c=>{if(c.selectorText){let l=c.selectorText.split(", ")[0].split(" ");for(let m=0;m<l.length;m++){let f=l[m];if(f[0]==="."){let h=f.slice(1),C="";for(let v=0;v<h.length;v++){let r=h[v],o=h[v+1];if(r==="\\"){if(v++,o!=="\\"){C+=o;continue}}else if(_.includes(r))break;C+=r}if(!(C in this.ruleOfClass)&&!(C in this.classes)){let v=this.create(C)[0];if(v)return v}}}}else if(c.cssRules)for(let n=0;n<c.cssRules.length;n++){let l=y(c.cssRules[n]);if(l)return l}},M=y(this.style.sheet.cssRules[g]);if(M){this.rules.push(M),this.ruleOfClass[M.className]=M;for(let c=0;c<M.natives.length;c++)M.natives[c].cssRule=this.style.sheet.cssRules[g+c];g+=M.natives.length-1}}else{this.style=document.createElement("style"),this.style.title="master";let g=d.querySelector('link[rel="styleSheet"], style');g?g.before(this.style):d.append(this.style)}let w=g=>{g.forEach(y=>{y in this.countOfClass?this.countOfClass[y]++:(this.countOfClass[y]=1,this.insert(y))})};w(this.host.classList),t.subtree&&this.host.querySelectorAll("[class]").forEach(g=>w(g.classList)),this.e.observe(e,{...t,attributes:!0,attributeOldValue:!0,attributeFilter:["class"]})}return this}disconnect(){this.e.disconnect(),this.ruleOfClass={},this.countOfClass={},this.rules.length=0;let e=this.style.sheet;if(e)for(let t=e.cssRules.length-1;t>=0;t--)e.deleteRule(t);this.style.remove(),this.style=null,this.theme?.destroy(),this.theme=null}match(e){for(let t in this.config.rules){let s=this.config.rules[t],d=this.matches[t],{colorStarts:x,symbol:w,prop:g}=s,{colorNames:y,colorThemesMap:M}=this;if(d&&d.test(e))return{origin:"matches",config:s};if(x){if(e.match("^"+x+"(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|current|inherit))"))return{origin:"matches",config:s};if(y.length&&e.indexOf("|")===-1){let c=e.match("^"+x+"((?:"+y.join("|")+")[0-9a-zA-Z-]*)");if(c&&c[1]in M)return{origin:"matches",config:s}}}if(w&&e.startsWith(w))return{origin:"symbol",config:s};if(g&&e.startsWith(g+":"))return{origin:"matches",config:s}}for(let t of this.semantics)if(e.match(t[0]))return{origin:"semantics",value:t[1]}}create(e){let t=s=>{if(s in this.ruleOfClass)return this.ruleOfClass[s];let d=this.match(s);if(d)return new H(s,d,this)};return(e in this.classes?this.classes[e].map(s=>t(s)):[t(e)]).filter(s=>s&&s.text)}refresh(e){if(e?.override?this.config=e:this.config=k(F,e),this.cache(),!this.style)return;let t=document.createElement("style");t.title="master",this.style.replaceWith(t),this.style=t,this.rules.length=0,this.ruleOfClass={};for(let s in this.countOfClass)this.insert(s)}destroy(){let e=j.instances;this.disconnect(),e.splice(e.indexOf(this),1)}delete(e){let t=this.style.sheet,s=d=>{let x=this.ruleOfClass[d];if(!(!x||d in this.relations&&this.relations[d].some(w=>w in this.countOfClass))){if(x.natives.length){let w=x.natives[0];for(let g=0;g<t.cssRules.length;g++)if(t.cssRules[g]===w.cssRule){for(let M=0;M<x.natives.length;M++)t.deleteRule(g);this.rules.splice(this.rules.indexOf(x),1);break}}delete this.ruleOfClass[d]}};if(e in this.classes){for(let d of this.classes[e])d in this.countOfClass||s(d);delete this.ruleOfClass[e]}else s(e)}insert(e){let t=this.create(e);return t.length?(this.insertRules(t),!0):!1}insertRules(e){for(let t of e){if(this.ruleOfClass[t.className])continue;let s,d=this.rules.length-1,{media:x,order:w,priority:g,hasWhere:y,className:M}=t,c=(n,l,m,f)=>{let h=0,C;l&&(h=n.findIndex(l)),m&&(C=n.findIndex(m)),h===-1&&(h=n.length),(C===void 0||C===-1)&&(C=n.length);let v=n.slice(h,C);for(let r=0;r<v.length;r++){let o=v[r];if(!(o.priority===-1||f&&f(o))&&(o.priority<g||o.priority===g&&(y&&!o.hasWhere||o.order>=w)))return h+r}return h+v.length};if(x){let n=this.rules.findIndex(l=>l.media);if(n!==-1){let l=x.features["max-width"],m=x.features["min-width"];if(l&&m){let f=l.value-m.value;for(let h=d;h>=n;h--){s=h;let C=this.rules[h],v=C.media,r=v.features["max-width"],o=v.features["min-width"];if(!r||!o){s++;break}let i=r.value-o.value;if(i===f){if(y!==C.hasWhere)continue;if(g!==-1){let u=[this.rules[h]];for(let a=h-1;a>=n;a--){let b=this.rules[a];if(b.hasWhere!==y)break;let p=b.media,T=p.features["max-width"],R=p.features["min-width"];if(!T||!R||T.value-R.value!==i)break;u.unshift(this.rules[a])}s=c(this.rules,a=>a.media&&a.priority!==-1&&a.media.features["min-width"]&&a.media.features["max-width"])}break}else if(i>f)break}}else if(m)for(let f=n;f<=d;f++){s=f;let h=this.rules[f],C=h.media,v=C.features["max-width"],r=C.features["min-width"];if(v){if(r)break;continue}let o=r?.value;if(o===m.value){if(!y&&h.hasWhere){s++;continue}if(g!==-1)s=c(this.rules,i=>i.media,i=>i.media&&i.priority!==-1&&i.media.features["min-width"]&&i.media.features["max-width"],i=>!i.media.features["min-width"]&&!i.media.features["max-width"]);else for(let i=f;i<=d;i++){let u=this.rules[i],a=u.media,b=a.features["min-width"];if(!a.features["max-width"]){if(u.hasWhere!==y||b.value!==o||u.order>=w)break;s=i+1}}break}else{if(o>m.value)break;s++}}else if(l)for(let f=d;f>=n;f--){s=f;let h=this.rules[f],C=h.media,v=C.features["max-width"];if(C.features["min-width"])continue;let o=v?.value;if(!o||o>l.value){s++;break}else if(o===l.value){if(y&&!h.hasWhere)continue;if(g!==-1)s=c(this.rules,i=>i.media,i=>i.media&&i.priority!==-1&&i.media.features["min-width"]&&i.media.features["max-width"],i=>!i.media.features["min-width"]&&!i.media.features["max-width"]);else{let i=[this.rules[f]];for(let u=f-1;u>=n;u--){let a=this.rules[u],b=a.media,p=b.features["min-width"],T=b.features["max-width"];if(!p&&(!T||T.value!==o||a.hasWhere!==y))break;i.unshift(a)}for(let u=0;u<i.length;u++){let a=i[u];if(!a.media.features["min-width"]){if(a.order>=w)break;s=f-i.length+2+u}}}break}}}if(s===void 0)if(n===-1)s=d+1;else if(g!==-1)s=n+c(this.rules.slice(n),void 0,l=>l.media.features["max-width"]||l.media.features["min-width"]);else if(y){let l=n;for(;l<this.rules.length;l++){let m=this.rules[l];if(m.priority!==-1||!m.hasWhere||m.order>=w){s=l;break}}s===void 0&&(s=l)}else for(let l=n;l<=d;l++){s=l;let m=this.rules[l],f=m.media;if(m.priority!==-1||f.features["max-width"]||f.features["min-width"])break;if(m.hasWhere)s++;else if(m.order>=w)break}}else if(g===-1)if(y)s=this.rules.findIndex(n=>!n.hasWhere||n.media||n.priority!==-1||n.order>=w),s===-1&&(s=d+1);else{let n=0;for(;n<this.rules.length;n++){let l=this.rules[n];if(l.media||!l.hasWhere&&(l.order>=w||l.priority!==-1)){s=n;break}}s===void 0&&(s=n)}else s=c(this.rules,void 0,n=>n.media);if(this.rules.splice(s,0,t),this.ruleOfClass[M]=t,this.style){let n=this.style.sheet,l=0,m=f=>{let h=this.rules[f];if(h){if(!h.natives.length)return m(f-1);let C=h.natives[h.natives.length-1].cssRule;for(let v=0;v<n.cssRules.length;v++)if(n.cssRules[v]===C){l=v+1;break}}};m(s-1);for(let f=0;f<t.natives.length;)try{let h=t.natives[f];n.insertRule(h.text,l),h.cssRule=n.cssRules[l++],f++}catch(h){console.error(h),t.natives.splice(f,1)}}}}get text(){return this.rules.map(e=>e.text).join("")}},W=j;S(W,"root"),S(W,"config",F),S(W,"instances",[]),S(W,"refresh",e=>{for(let t of j.instances)t.refresh(e)});A&&(window.MasterCSS=W);export{W as MasterCSS};
@@ -1 +1 @@
1
- import{MasterCSS as e}from"./css";new e(window.masterCSSConfig);
1
+ import{MasterCSS as e}from"./css.js";new e(window.masterCSSConfig);
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./css";export*from"./rule";export*from"./theme";import{MasterCSS as h}from"./css";function i(t){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&t instanceof e||t instanceof Date||t instanceof RegExp)}function l(t){if(typeof Buffer<"u"&&Buffer&&t instanceof Buffer){let e=Buffer.alloc(t.length);return t.copy(e),e}else{if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t);throw new Error("Unexpected situation")}}function c(t){let e=[];return t.forEach(function(r,n){typeof r=="object"&&r!==null?Array.isArray(r)?e[n]=c(r):i(r)?e[n]=l(r):e[n]=u({},r):e[n]=r}),e}function a(t,e){return e==="__proto__"?void 0:t[e]}function u(...t){let e={},r,n;return t.forEach(function(f){typeof f!="object"||f===null||Array.isArray(f)||Object.keys(f).forEach(function(o){if(n=a(e,o),r=a(f,o),r!==e)if(typeof r!="object"||r===null){e[o]=r;return}else if(Array.isArray(r)){e[o]=c(r);return}else if(i(r)){e[o]=l(r);return}else if(typeof n!="object"||n===null||Array.isArray(n)){e[o]=u({},r);return}else{e[o]=u(n,r);return}})}),e}export*from"./methods";export*from"./config";export{h as default,u as extend};
1
+ export*from"./css.js";export*from"./rule.js";export*from"./theme.js";import{MasterCSS as h}from"./css.js";function i(t){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&t instanceof e||t instanceof Date||t instanceof RegExp)}function l(t){if(typeof Buffer<"u"&&Buffer&&t instanceof Buffer){let e=Buffer.alloc(t.length);return t.copy(e),e}else{if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t);throw new Error("Unexpected situation")}}function c(t){let e=[];return t.forEach(function(r,n){typeof r=="object"&&r!==null?Array.isArray(r)?e[n]=c(r):i(r)?e[n]=l(r):e[n]=u({},r):e[n]=r}),e}function a(t,e){return e==="__proto__"?void 0:t[e]}function u(...t){let e={},r,n;return t.forEach(function(f){typeof f!="object"||f===null||Array.isArray(f)||Object.keys(f).forEach(function(o){if(n=a(e,o),r=a(f,o),r!==e)if(typeof r!="object"||r===null){e[o]=r;return}else if(Array.isArray(r)){e[o]=c(r);return}else if(i(r)){e[o]=l(r);return}else if(typeof n!="object"||n===null||Array.isArray(n)){e[o]=u({},r);return}else{e[o]=u(n,r);return}})}),e}export*from"./methods/index.js";export*from"./config/index.js";export{h as default,u as extend};
@@ -1 +1 @@
1
- import{hexToRgb as s}from"../utils/hex-to-rgb";import{rgbToHex as L}from"../utils/rgb-to-hex";function x(e){typeof e=="string"&&(e={"":e});let h=""in e,t=!1;for(let o in e)if(o&&+o>=100){t=!0;break}if(!t&&(!h||Object.keys(e).length>1)){let o=0,i="0"in e?s(e[0]):[0,0,0],c,r,l=[],b=()=>{let n=c-o,v=r.map((f,g)=>(f-i[g])/n);for(let f of l){let g=f-o,p=i.map((m,u)=>Math.round(m+v[u]*g));e[f]="#"+L.call(this,...p)}};for(let n=1;n<100;n++)n in e?(l.length?(c=n,r=s(e[n]),b(),l.length=0,i=r):i=s(e[n]),o=n):l.push(n);l.length&&(c=100,r="100"in e?s(e[100]):[255,255,255],b())}return h||(e[""]=e[t?"500":"50"]),e}export{x as fillColorScale};
1
+ import{hexToRgb as s}from"../utils/hex-to-rgb.js";import{rgbToHex as L}from"../utils/rgb-to-hex.js";function x(e){typeof e=="string"&&(e={"":e});let h=""in e,t=!1;for(let o in e)if(o&&+o>=100){t=!0;break}if(!t&&(!h||Object.keys(e).length>1)){let o=0,i="0"in e?s(e[0]):[0,0,0],c,r,l=[],b=()=>{let n=c-o,v=r.map((f,g)=>(f-i[g])/n);for(let f of l){let g=f-o,p=i.map((m,u)=>Math.round(m+v[u]*g));e[f]="#"+L.call(this,...p)}};for(let n=1;n<100;n++)n in e?(l.length?(c=n,r=s(e[n]),b(),l.length=0,i=r):i=s(e[n]),o=n):l.push(n);l.length&&(c=100,r="100"in e?s(e[100]):[255,255,255],b())}return h||(e[""]=e[t?"500":"50"]),e}export{x as fillColorScale};
@@ -1 +1 @@
1
- export*from"./render";export*from"./render-from-html";export*from"./render-into-html";export*from"./fill-color-scale";export*from"./define-content";export*from"./get-sync-with-stored-theme-script";
1
+ export*from"./render.js";export*from"./render-from-html.js";export*from"./render-into-html.js";export*from"./fill-color-scale.js";export*from"./define-content.js";export*from"./get-sync-with-stored-theme-script.js";
@@ -1 +1 @@
1
- import{MasterCSS as c}from"../css";function a(r,n){if(!r)return;let e=new c({...n,observe:!1}),o=/\sclass="([^"]*)"/gm,t;for(;t=o.exec(r);){let i=t[1].replace(/\n/g,"").split(" ").filter(s=>s);for(let s of i)s in e.countOfClass||(e.insert(s),e.countOfClass[s]=1)}return e.text}export{a as renderFromHTML};
1
+ import{MasterCSS as c}from"../css.js";function a(r,n){if(!r)return;let e=new c({...n,observe:!1}),o=/\sclass="([^"]*)"/gm,t;for(;t=o.exec(r);){let i=t[1].replace(/\n/g,"").split(" ").filter(s=>s);for(let s of i)s in e.countOfClass||(e.insert(s),e.countOfClass[s]=1)}return e.text}export{a as renderFromHTML};
@@ -1 +1 @@
1
- import{renderFromHTML as t}from"./render-from-html";function i(e,r){if(e)return e.replace(/(<link[^>]*?rel="styleSheet".*?>|<style.*?>|<\/head>)/,`<style title="master">${t(e,r)}</style>$1`)}export{i as renderIntoHTML};
1
+ import{renderFromHTML as t}from"./render-from-html.js";function i(e,r){if(e)return e.replace(/(<link[^>]*?rel="styleSheet".*?>|<style.*?>|<\/head>)/,`<style title="master">${t(e,r)}</style>$1`)}export{i as renderIntoHTML};
@@ -1 +1 @@
1
- import{MasterCSS as e}from"../css";function i(r,o){if(!r?.length)return;let n=new e({...o,observe:!1});for(let t of r)t in n.countOfClass||n.insert(t)&&(n.countOfClass[t]=1);return n.text}export{i as render};
1
+ import{MasterCSS as o}from"../css.js";function i(r,e){if(!r?.length)return;let n=new o({...e,observe:!1});for(let t of r)t in n.countOfClass||n.insert(t)&&(n.countOfClass[t]=1);return n.text}export{i as render};
package/dist/esm/rule.js CHANGED
@@ -1 +1 @@
1
- import{getCssPropertyText as N}from"./utils/get-css-property-text";import{analyzeValueToken as ie}from"./utils/analyze-value-token";import{parseRuleValue as E}from"./utils/parse-rule-value";import{SORTED_SELECTORS as G}from"./constants/sorted-selectors";import{cssEscape as se}from"./utils/css-escape";var H=class{constructor(y,v,b){this.className=y;this.meta=v;this.css=b;let{id:J,unit:K="rem",order:X=0,colorful:x,prop:Y,analyzeToken:z,getThemeProps:T,parseValue:D,get:F}=v.config||{},{rootSize:Z,scope:P,important:j}=b.config,{themeNames:_,colorNames:$,colorThemesMap:ee,selectors:O,globalValues:Q,breakpoints:q,mediaQueries:M}=b,I=b.values[J],U=b.relationThemesMap[y],h=y;this.order=X;let A,C,m,S;if(v.origin==="semantics"){let[l,r]=v.value;m=h.slice(l.length),A=r}else if(z)[C,S,m]=z.call(this,h,I,Q);else{let l;if(v.origin==="matches"){let r=h.indexOf(":");this.prefix=h.slice(0,r+1),this.prefix.includes("(")?(this.prefix=void 0,l=h):l=h.slice(r+1)}else v.origin==="symbol"&&(this.symbol=h[0],l=h.slice(1));[S,m]=ie(l,I,Q)}m[0]==="!"&&(this.important=!0,m=m.slice(1));let B=l=>{let r=l.split(/(\\'(?:.*?)[^\\]\\')(?=[*_>~+,)])|(\[[^=]+='(?:.*?)[^\\]'\])/).map((t,i)=>i%3?t:t.replace(/_/g," ")).join(""),s=[],o="",u=0;for(let t=0;t<r.length;t++){let i=r[t];if(i==="\\"){o+=i+r[++t];continue}!u&&i===","?(s.push(o),o=""):(o+=i,u&&i===")"?u--:i==="("&&u++)}return o&&s.push(o),s};this.prefixSelectors=C?B(C):[""];let w=m.split("@"),V=w[0];if(V){this.vendorSuffixSelectors={};let l=(t,i,e,n)=>{for(let[a,f]of i)if(a.test(t)){for(let g of f)l(t.replace(a,g),i,e,!0);return}n&&e.push(t)},r=[];""in O?l(V,O[""],r,!0):r.push(V);let s={};for(let[t,i]of Object.entries(O)){if(!t)continue;let e=[];for(let n of r)l(n,i,e,!1);e.length&&(s[t]=e)}let o=(t,i)=>{let e=i.reduce((n,a)=>(n.push(...B(a)),n),[]);t in this.vendorSuffixSelectors?this.vendorSuffixSelectors[t].push(...e):this.vendorSuffixSelectors[t]=e},u=Object.keys(s);if(u.length)for(let t of u)o(t,s[t]);else o("",r);for(let t of Object.values(this.vendorSuffixSelectors))for(let i of t){this.hasWhere!==!1&&(this.hasWhere=i.includes(":where("));for(let e=0;e<G.length;e++)if(i.includes(G[e])){(this.priority===-1||this.priority>e)&&(this.priority=e);break}}}else this.vendorSuffixSelectors={"":[""]};for(let l=1;l<w.length;l++){let r=w[l];if(r)if(_.includes(r))this.theme=r;else if(r==="rtl"||r==="ltr")this.direction=r;else{let s,o,u=r.indexOf("_");if(u!==-1)s=r.slice(0,u),o=r.slice(u);else{let t=r.indexOf("(");t!==-1&&(s=r.slice(0,t),o=r.slice(t))}if(!s){s="media";let t=[];this.media={token:r,features:{}};let i=r.split("&");for(let e of i)if(e==="all"||e==="print"||e==="screen"||e==="speech")this.media.type=e;else if(e==="\u{1F5A8}")this.media.type="print";else if(e==="landscape"||e==="portrait")t.push("(orientation:"+e+")");else if(e==="motion"||e==="reduced-motion")t.push("(prefers-reduced-motion:"+(e==="motion"?"no-preference":"reduce")+")");else if(M&&e in M)t.push(M[e]);else{let n={token:e},a="",f="",g=0;e.startsWith("<=")?(f="<=",a="max-width"):e.startsWith(">=")||q[e]?(f=">=",a="min-width"):e.startsWith(">")?(f=">",a="min-width",g=.02):e.startsWith("<")&&(f="<",a="max-width",g=-.02);let p=f?e.replace(f,""):e,c=q[p];switch(a){case"max-width":case"min-width":c?Object.assign(n,E(c,"px")):Object.assign(n,E(p,"px")),n.unit==="px"&&(n.value+=g),this.media.features[a]=n,t.push("("+a+":"+(n.value+n.unit)+")");break}}o="",this.media.type&&(o=this.media.type),t.length&&(o+=(o?" and ":"")+t.join(" and "))}o&&(this.at[s]=(s in this.at?this.at[s]+" and ":"")+o.replace(/_/g," "))}}let k=(l,r)=>{let s,o,u=(i,e,n)=>{let a="";this.direction&&(a+="[dir="+this.direction+"] ");let f=this.prefixSelectors.map(c=>c+a),g=(c,R)=>f.map(d=>(c?"."+c+" ":"")+(P?P+" ":"")+d).reduce((d,W)=>(d.push(n.reduce((L,te)=>(L.push(W+"."+se(R)+te),L),[]).join(",")),d),[]).join(","),p=g(e,y)+(U?Object.entries(U).filter(([c])=>this.theme||!x||!e||!c||c===e).map(([c,R])=>R.reduce((d,W)=>d+","+g(this.theme??((x||T)&&e||c),W),"")).join(""):"")+"{"+i+"}";for(let c of Object.keys(this.at).sort((R,d)=>d==="supports"?-1:1))p="@"+c+" "+this.at[c]+"{"+p+"}";return p},t=[];if(S){let i,e;for(let n of S)typeof n=="string"?t.push(n):(i=E(n.value,K,x&&$,x&&ee,Z,this.theme?[this.theme,""]:[l]),i.colorMatched!==void 0&&e!==!0&&(e=i.colorMatched),t.push(i.value+i.unit));if(r&&(e===void 0?l:!e))return;if(t.length===1?i?(s=i.value,o=i.unit):s=t[0]:s=t.reduce((n,a,f)=>n+a+(a===","||S[f+1]===","||f===S.length-1?"":" "),""),typeof s!="object"){D&&(s=D.call(this,s,this.css.config)),x&&s==="current"&&(s="currentColor");let n={unit:o,value:s,important:this.important};if(T){let a=T.call(this,n,b);for(let f in a)for(let g of Object.values(this.vendorSuffixSelectors))this.natives.push({unit:o,value:s,text:u(Object.entries(a[f]).map(([p,c])=>N(p,{important:(this.important||j)&&!c.endsWith("!important"),unit:"",value:c})).join(";"),f,g),theme:f});return}else F&&(s=F.call(this,n))}}else s=A;for(let i of Object.values(this.vendorSuffixSelectors))this.natives.push({unit:o,value:s,text:u(typeof s=="object"?Object.entries(s).map(([e,n])=>N(e,{...typeof n=="object"?n:{unit:"",value:n},important:this.important||j})).join(";"):N(Y,{unit:o,value:s,important:this.important||j}),l,i),theme:l})};if(T)k(void 0,!1);else if(this.theme)k(this.theme,!1);else if(x)for(let l of _)k(l,!0);else k("",!1)}at={};priority=-1;natives=[];get text(){return this.natives.map(y=>y.text).join("")}};export{H as Rule};
1
+ import{getCssPropertyText as N}from"./utils/get-css-property-text.js";import{analyzeValueToken as ie}from"./utils/analyze-value-token.js";import{parseRuleValue as E}from"./utils/parse-rule-value.js";import{SORTED_SELECTORS as G}from"./constants/sorted-selectors.js";import{cssEscape as se}from"./utils/css-escape.js";var H=class{constructor(y,v,b){this.className=y;this.meta=v;this.css=b;let{id:J,unit:K="rem",order:X=0,colorful:x,prop:Y,analyzeToken:z,getThemeProps:T,parseValue:D,get:F}=v.config||{},{rootSize:Z,scope:P,important:j}=b.config,{themeNames:_,colorNames:$,colorThemesMap:ee,selectors:O,globalValues:Q,breakpoints:q,mediaQueries:M}=b,I=b.values[J],U=b.relationThemesMap[y],h=y;this.order=X;let A,C,m,S;if(v.origin==="semantics"){let[l,r]=v.value;m=h.slice(l.length),A=r}else if(z)[C,S,m]=z.call(this,h,I,Q);else{let l;if(v.origin==="matches"){let r=h.indexOf(":");this.prefix=h.slice(0,r+1),this.prefix.includes("(")?(this.prefix=void 0,l=h):l=h.slice(r+1)}else v.origin==="symbol"&&(this.symbol=h[0],l=h.slice(1));[S,m]=ie(l,I,Q)}m[0]==="!"&&(this.important=!0,m=m.slice(1));let B=l=>{let r=l.split(/(\\'(?:.*?)[^\\]\\')(?=[*_>~+,)])|(\[[^=]+='(?:.*?)[^\\]'\])/).map((t,i)=>i%3?t:t.replace(/_/g," ")).join(""),s=[],o="",u=0;for(let t=0;t<r.length;t++){let i=r[t];if(i==="\\"){o+=i+r[++t];continue}!u&&i===","?(s.push(o),o=""):(o+=i,u&&i===")"?u--:i==="("&&u++)}return o&&s.push(o),s};this.prefixSelectors=C?B(C):[""];let w=m.split("@"),V=w[0];if(V){this.vendorSuffixSelectors={};let l=(t,i,e,n)=>{for(let[a,f]of i)if(a.test(t)){for(let g of f)l(t.replace(a,g),i,e,!0);return}n&&e.push(t)},r=[];""in O?l(V,O[""],r,!0):r.push(V);let s={};for(let[t,i]of Object.entries(O)){if(!t)continue;let e=[];for(let n of r)l(n,i,e,!1);e.length&&(s[t]=e)}let o=(t,i)=>{let e=i.reduce((n,a)=>(n.push(...B(a)),n),[]);t in this.vendorSuffixSelectors?this.vendorSuffixSelectors[t].push(...e):this.vendorSuffixSelectors[t]=e},u=Object.keys(s);if(u.length)for(let t of u)o(t,s[t]);else o("",r);for(let t of Object.values(this.vendorSuffixSelectors))for(let i of t){this.hasWhere!==!1&&(this.hasWhere=i.includes(":where("));for(let e=0;e<G.length;e++)if(i.includes(G[e])){(this.priority===-1||this.priority>e)&&(this.priority=e);break}}}else this.vendorSuffixSelectors={"":[""]};for(let l=1;l<w.length;l++){let r=w[l];if(r)if(_.includes(r))this.theme=r;else if(r==="rtl"||r==="ltr")this.direction=r;else{let s,o,u=r.indexOf("_");if(u!==-1)s=r.slice(0,u),o=r.slice(u);else{let t=r.indexOf("(");t!==-1&&(s=r.slice(0,t),o=r.slice(t))}if(!s){s="media";let t=[];this.media={token:r,features:{}};let i=r.split("&");for(let e of i)if(e==="all"||e==="print"||e==="screen"||e==="speech")this.media.type=e;else if(e==="\u{1F5A8}")this.media.type="print";else if(e==="landscape"||e==="portrait")t.push("(orientation:"+e+")");else if(e==="motion"||e==="reduced-motion")t.push("(prefers-reduced-motion:"+(e==="motion"?"no-preference":"reduce")+")");else if(M&&e in M)t.push(M[e]);else{let n={token:e},a="",f="",g=0;e.startsWith("<=")?(f="<=",a="max-width"):e.startsWith(">=")||q[e]?(f=">=",a="min-width"):e.startsWith(">")?(f=">",a="min-width",g=.02):e.startsWith("<")&&(f="<",a="max-width",g=-.02);let p=f?e.replace(f,""):e,c=q[p];switch(a){case"max-width":case"min-width":c?Object.assign(n,E(c,"px")):Object.assign(n,E(p,"px")),n.unit==="px"&&(n.value+=g),this.media.features[a]=n,t.push("("+a+":"+(n.value+n.unit)+")");break}}o="",this.media.type&&(o=this.media.type),t.length&&(o+=(o?" and ":"")+t.join(" and "))}o&&(this.at[s]=(s in this.at?this.at[s]+" and ":"")+o.replace(/_/g," "))}}let k=(l,r)=>{let s,o,u=(i,e,n)=>{let a="";this.direction&&(a+="[dir="+this.direction+"] ");let f=this.prefixSelectors.map(c=>c+a),g=(c,R)=>f.map(d=>(c?"."+c+" ":"")+(P?P+" ":"")+d).reduce((d,W)=>(d.push(n.reduce((L,te)=>(L.push(W+"."+se(R)+te),L),[]).join(",")),d),[]).join(","),p=g(e,y)+(U?Object.entries(U).filter(([c])=>this.theme||!x||!e||!c||c===e).map(([c,R])=>R.reduce((d,W)=>d+","+g(this.theme??((x||T)&&e||c),W),"")).join(""):"")+"{"+i+"}";for(let c of Object.keys(this.at).sort((R,d)=>d==="supports"?-1:1))p="@"+c+" "+this.at[c]+"{"+p+"}";return p},t=[];if(S){let i,e;for(let n of S)typeof n=="string"?t.push(n):(i=E(n.value,K,x&&$,x&&ee,Z,this.theme?[this.theme,""]:[l]),i.colorMatched!==void 0&&e!==!0&&(e=i.colorMatched),t.push(i.value+i.unit));if(r&&(e===void 0?l:!e))return;if(t.length===1?i?(s=i.value,o=i.unit):s=t[0]:s=t.reduce((n,a,f)=>n+a+(a===","||S[f+1]===","||f===S.length-1?"":" "),""),typeof s!="object"){D&&(s=D.call(this,s,this.css.config)),x&&s==="current"&&(s="currentColor");let n={unit:o,value:s,important:this.important};if(T){let a=T.call(this,n,b);for(let f in a)for(let g of Object.values(this.vendorSuffixSelectors))this.natives.push({unit:o,value:s,text:u(Object.entries(a[f]).map(([p,c])=>N(p,{important:(this.important||j)&&!c.endsWith("!important"),unit:"",value:c})).join(";"),f,g),theme:f});return}else F&&(s=F.call(this,n))}}else s=A;for(let i of Object.values(this.vendorSuffixSelectors))this.natives.push({unit:o,value:s,text:u(typeof s=="object"?Object.entries(s).map(([e,n])=>N(e,{...typeof n=="object"?n:{unit:"",value:n},important:this.important||j})).join(";"):N(Y,{unit:o,value:s,important:this.important||j}),l,i),theme:l})};if(T)k(void 0,!1);else if(this.theme)k(this.theme,!1);else if(x)for(let l of _)k(l,!0);else k("",!1)}at={};priority=-1;natives=[];get text(){return this.natives.map(y=>y.text).join("")}};export{H as Rule};
package/dist/esm/theme.js CHANGED
@@ -1 +1 @@
1
- function h(s){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&s instanceof e||s instanceof Date||s instanceof RegExp)}function f(s){if(typeof Buffer<"u"&&Buffer&&s instanceof Buffer){let e=Buffer.alloc(s.length);return s.copy(e),e}else{if(s instanceof Date)return new Date(s.getTime());if(s instanceof RegExp)return new RegExp(s);throw new Error("Unexpected situation")}}function l(s){let e=[];return s.forEach(function(t,i){typeof t=="object"&&t!==null?Array.isArray(t)?e[i]=l(t):h(t)?e[i]=f(t):e[i]=n({},t):e[i]=t}),e}function a(s,e){return e==="__proto__"?void 0:s[e]}function n(...s){let e={},t,i;return s.forEach(function(o){typeof o!="object"||o===null||Array.isArray(o)||Object.keys(o).forEach(function(r){if(i=a(e,r),t=a(o,r),t!==e)if(typeof t!="object"||t===null){e[r]=t;return}else if(Array.isArray(t)){e[r]=l(t);return}else if(h(t)){e[r]=f(t);return}else if(typeof i!="object"||i===null||Array.isArray(i)){e[r]=n({},t);return}else{e[r]=n(i,t);return}})}),e}import{theme as u}from"./config/theme";var c=class{constructor(e=typeof document<"u"?document.documentElement:null,t){this.host=e;this.options=t;this.options=n(u,t),this.options.store&&this.storage?this.syncWithStorage():this.options.default&&this.set(this.options.default,{emit:!1,store:!1})}darkMQL=typeof window<"u"?window.matchMedia?.("(prefers-color-scheme:dark)"):void 0;get storage(){let{store:e}=this.options;if(e)return localStorage.getItem(e)}current;value;set(e,t={store:!0,emit:!0}){if(e!==this.value){let i;e==="system"?(this.darkMQL?.addEventListener?.("change",this.onThemeChange),i=this.darkMQL?.matches?"dark":"light"):(this.removeDarkMQLListener(),i=e),i&&(this.host.classList.remove(this.current),this.host.classList.add(i),this.host.style&&(this.host.style.colorScheme=i)),this.current=i,this.value=e,t.store,this.storage,this.options.store&&localStorage.setItem(this.options.store,e),t.emit&&this.host.dispatchEvent(new CustomEvent("theme",{detail:this}))}}syncWithStorage(){if(typeof window<"u"&&this.options.store){let e=this.storage;(e==="system"&&(e=this.darkMQL?.matches?"dark":"light")||e)&&(this.host.classList.add(e),this.host.style.colorScheme=e,this.set(e,{emit:!1,store:!1}))}}removeDarkMQLListener(){this.darkMQL?.removeEventListener("change",this.onThemeChange)}onThemeChange=e=>{this.set(e.matches?"dark":"light")};destroy(){this.darkMQL?.removeEventListener("change",this.onThemeChange)}};export{c as Theme};
1
+ function h(s){let e=typeof Buffer<"u"?Buffer:null;return!!(e&&s instanceof e||s instanceof Date||s instanceof RegExp)}function f(s){if(typeof Buffer<"u"&&Buffer&&s instanceof Buffer){let e=Buffer.alloc(s.length);return s.copy(e),e}else{if(s instanceof Date)return new Date(s.getTime());if(s instanceof RegExp)return new RegExp(s);throw new Error("Unexpected situation")}}function l(s){let e=[];return s.forEach(function(t,i){typeof t=="object"&&t!==null?Array.isArray(t)?e[i]=l(t):h(t)?e[i]=f(t):e[i]=n({},t):e[i]=t}),e}function a(s,e){return e==="__proto__"?void 0:s[e]}function n(...s){let e={},t,i;return s.forEach(function(o){typeof o!="object"||o===null||Array.isArray(o)||Object.keys(o).forEach(function(r){if(i=a(e,r),t=a(o,r),t!==e)if(typeof t!="object"||t===null){e[r]=t;return}else if(Array.isArray(t)){e[r]=l(t);return}else if(h(t)){e[r]=f(t);return}else if(typeof i!="object"||i===null||Array.isArray(i)){e[r]=n({},t);return}else{e[r]=n(i,t);return}})}),e}import{theme as u}from"./config/theme.js";var c=class{constructor(e=typeof document<"u"?document.documentElement:null,t){this.host=e;this.options=t;this.options=n(u,t),this.options.store&&this.storage?this.syncWithStorage():this.options.default&&this.set(this.options.default,{emit:!1,store:!1})}darkMQL=typeof window<"u"?window.matchMedia?.("(prefers-color-scheme:dark)"):void 0;get storage(){let{store:e}=this.options;if(e)return localStorage.getItem(e)}current;value;set(e,t={store:!0,emit:!0}){if(e!==this.value){let i;e==="system"?(this.darkMQL?.addEventListener?.("change",this.onThemeChange),i=this.darkMQL?.matches?"dark":"light"):(this.removeDarkMQLListener(),i=e),i&&(this.host.classList.remove(this.current),this.host.classList.add(i),this.host.style&&(this.host.style.colorScheme=i)),this.current=i,this.value=e,t.store,this.storage,this.options.store&&localStorage.setItem(this.options.store,e),t.emit&&this.host.dispatchEvent(new CustomEvent("theme",{detail:this}))}}syncWithStorage(){if(typeof window<"u"&&this.options.store){let e=this.storage;(e==="system"&&(e=this.darkMQL?.matches?"dark":"light")||e)&&(this.host.classList.add(e),this.host.style.colorScheme=e,this.set(e,{emit:!1,store:!1}))}}removeDarkMQLListener(){this.darkMQL?.removeEventListener("change",this.onThemeChange)}onThemeChange=e=>{this.set(e.matches?"dark":"light")};destroy(){this.darkMQL?.removeEventListener("change",this.onThemeChange)}};export{c as Theme};
@@ -1 +1 @@
1
- import{START_SYMBOL as a}from"../constants/start-symbol";function R(x,h,S,b=[]){let A=[",",...b],f=[],n="",e=0;return function p(r,t,g,l="",o=[],d=[]){let u,c=!1;t&&(t===")"&&n.slice(-1)==="$"?u=n.length-1:(t==="'"||t==='"')&&(c=!0),n+=r[e++]);let m=()=>{let i=n;if(n="",h&&i in h&&!o.includes(i)){let s=e;e=0,p(h[i].toString(),void 0,void 0,void 0,[...o,i],d),e=s}else if(S&&i in S&&!d.includes(i)){let s=e;e=0,p(S[i].toString(),void 0,void 0,void 0,o,[...d,i]),e=s}else f.push({value:i})};for(;e<r.length;e++){let i=r[e];if(i===t){if(n+=i,c){let s=0;for(let y=n.length-2;n[y]==="\\";y--)s++;if(s%2)continue}u!==void 0&&(n=n.slice(0,u)+n.slice(u).replace(/\$\((.*)\)/,"var(--$1)")),g||(c?f.push(n):m(),l="",n="");break}else if(!c&&i in a)p(r,a[i],g===void 0?0:g+1,l,o,d);else if((i==="|"||i===" ")&&t!=="}"&&(!c||l==="path"))t?n+=" ":m();else{if(!t){if(i==="."){if(isNaN(+r[e+1]))break;r[e-1]==="-"&&(n+="0")}else if(A.includes(i)){n&&m(),f.push(i);continue}else if(i==="#"&&(n||f.length&&r[e-1]!=="|"&&f[e-1]!==" ")||["!","*",">","+","~",":","[","@","_"].includes(i))break;l+=i}n+=i}}g===void 0&&n&&m()}(x),[f,x.slice(e)]}export{R as analyzeValueToken};
1
+ import{START_SYMBOL as a}from"../constants/start-symbol.js";function R(x,h,S,b=[]){let A=[",",...b],f=[],n="",e=0;return function p(r,t,g,l="",o=[],d=[]){let u,c=!1;t&&(t===")"&&n.slice(-1)==="$"?u=n.length-1:(t==="'"||t==='"')&&(c=!0),n+=r[e++]);let m=()=>{let i=n;if(n="",h&&i in h&&!o.includes(i)){let s=e;e=0,p(h[i].toString(),void 0,void 0,void 0,[...o,i],d),e=s}else if(S&&i in S&&!d.includes(i)){let s=e;e=0,p(S[i].toString(),void 0,void 0,void 0,o,[...d,i]),e=s}else f.push({value:i})};for(;e<r.length;e++){let i=r[e];if(i===t){if(n+=i,c){let s=0;for(let y=n.length-2;n[y]==="\\";y--)s++;if(s%2)continue}u!==void 0&&(n=n.slice(0,u)+n.slice(u).replace(/\$\((.*)\)/,"var(--$1)")),g||(c?f.push(n):m(),l="",n="");break}else if(!c&&i in a)p(r,a[i],g===void 0?0:g+1,l,o,d);else if((i==="|"||i===" ")&&t!=="}"&&(!c||l==="path"))t?n+=" ":m();else{if(!t){if(i==="."){if(isNaN(+r[e+1]))break;r[e-1]==="-"&&(n+="0")}else if(A.includes(i)){n&&m(),f.push(i);continue}else if(i==="#"&&(n||f.length&&r[e-1]!=="|"&&f[e-1]!==" ")||["!","*",">","+","~",":","[","@","_"].includes(i))break;l+=i}n+=i}}g===void 0&&n&&m()}(x),[f,x.slice(e)]}export{R as analyzeValueToken};
@@ -1 +1 @@
1
- import{getType as e}from"./get-type";function n(t){return e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}export{n as isPlainObject};
1
+ import{getType as e}from"./get-type.js";function n(t){return e(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}export{n as isPlainObject};
@@ -1 +1 @@
1
- import{getType as y}from"./get-type";function r(o){return y(o)==="Symbol"}export{r as isSymbol};
1
+ import{getType as y}from"./get-type.js";function r(o){return y(o)==="Symbol"}export{r as isSymbol};
@@ -1 +1 @@
1
- import{analyzeUnitValue as k}from"./analyze-unit-value";function p(a,c,g){let u=t=>t==="+"||t==="-"||t==="*"||t==="/",s="",n,i="",o=!1,l=!1;function r(t,e="",b=""){if(n===2&&!l){let f=k(i,c,g);f&&(i=f.value+f.unit)}s+=i+e+t+b,n=null,l=!1,i=""}for(let t=0;t<a.length;t++){let e=a[t];if(e==="("||e===")")o=e===")",r(e);else if(e===",")r(e,""," ");else{switch(n){case 1:break;case 2:if(u(e)){r(e," "," ");continue}else/[0-9]/.test(e)||(l=!0);break;default:o&&(s+=" "),isNaN(+e)?u(e)||(n=1):n=2;break}n?i+=e:s+=e}}return i&&(s+=i),s}export{p as normalizeCssCalcText};
1
+ import{analyzeUnitValue as k}from"./analyze-unit-value.js";function p(a,c,g){let u=t=>t==="+"||t==="-"||t==="*"||t==="/",s="",n,i="",o=!1,l=!1;function r(t,e="",b=""){if(n===2&&!l){let f=k(i,c,g);f&&(i=f.value+f.unit)}s+=i+e+t+b,n=null,l=!1,i=""}for(let t=0;t<a.length;t++){let e=a[t];if(e==="("||e===")")o=e===")",r(e);else if(e===",")r(e,""," ");else{switch(n){case 1:break;case 2:if(u(e)){r(e," "," ");continue}else/[0-9]/.test(e)||(l=!0);break;default:o&&(s+=" "),isNaN(+e)?u(e)||(n=1):n=2;break}n?i+=e:s+=e}}return i&&(s+=i),s}export{p as normalizeCssCalcText};
@@ -1 +1 @@
1
- import{analyzeUnitValue as C}from"./analyze-unit-value";import{normalizeCssCalcText as R}from"./normalize-css-calc-text";function w(e,n,p,s,o,d){let l="",u="",f;if(typeof e=="number")l=e,u=n||"";else{if(s){let g=!1,m=!1;e=e.replace(new RegExp(`(^|,| |\\()((?:${p.join("|")})(?:-(?:[0-9A-Za-z-]+))?)(?:\\/(\\.?[0-9]+%?))?(?=(\\)|\\}|,| |$))`,"gm"),(b,M,x,r)=>{m=!0;let h=s[x];if(h){let i;for(let a of d)if(i=h[a])break;if(i){g=!0;let a=i;if(r){let t=r.endsWith("%")?parseFloat(r)/100:+r;t=isNaN(t)?1:Math.min(Math.max(t,0),1),a+=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")}return M+a}}return b}),m&&(f=g)}let c=C(e,o,n);if(c)return c;l=(e.indexOf("calc(")===-1?e:R(e,o,n)).replace(/\$\(((\w|-)+)\)/g,"var(--$1)")}return{value:l,unit:u,colorMatched:f}}export{w as parseRuleValue};
1
+ import{analyzeUnitValue as C}from"./analyze-unit-value.js";import{normalizeCssCalcText as R}from"./normalize-css-calc-text.js";function w(e,n,p,s,o,d){let l="",u="",f;if(typeof e=="number")l=e,u=n||"";else{if(s){let g=!1,m=!1;e=e.replace(new RegExp(`(^|,| |\\()((?:${p.join("|")})(?:-(?:[0-9A-Za-z-]+))?)(?:\\/(\\.?[0-9]+%?))?(?=(\\)|\\}|,| |$))`,"gm"),(b,M,x,r)=>{m=!0;let h=s[x];if(h){let i;for(let a of d)if(i=h[a])break;if(i){g=!0;let a=i;if(r){let t=r.endsWith("%")?parseFloat(r)/100:+r;t=isNaN(t)?1:Math.min(Math.max(t,0),1),a+=Math.round(t*255).toString(16).toUpperCase().padStart(2,"0")}return M+a}}return b}),m&&(f=g)}let c=C(e,o,n);if(c)return c;l=(e.indexOf("calc(")===-1?e:R(e,o,n)).replace(/\$\(((\w|-)+)\)/g,"var(--$1)")}return{value:l,unit:u,colorMatched:f}}export{w as parseRuleValue};
@@ -1 +1 @@
1
- function a(i,g,{rootSize:c}){let n="",r=0;return function o(l,u){let t="",s=u?g(u):"",f=()=>{t&&(n+=!s||Number.isNaN(+t)?t:+t/(s==="rem"?c:1)+s,t="")};for(;r<i.length;r++){let e=i[r];if(e===l&&(l!=="'"||i[r+1]===")")){f(),n+=e;break}else e===","||e===" "?(f(),n+=e):!t&&e==="'"?(n+=e,r++,o(e),t=""):t&&e==="("?(n+=t+e,r++,o(")",t),t=""):t+=e}f()}(),n}export{a as parseValueUnit};
1
+ function a(r,g,{rootSize:c}){let n="",i=0;return function o(l,u){let e="",s=u?g(u):"",f=()=>{e&&(n+=!s||Number.isNaN(+e)?e:+e/(s==="rem"?c:1)+s,e="")};for(;i<r.length;i++){let t=r[i];if(t===l&&(l!=="'"||r[i+1]===")")){f(),n+=t;break}else t===","||t===" "?(f(),n+=t):!e&&t==="'"?(n+=t,i++,o(t),e=""):e&&t==="("?(n+=e+t,i++,o(")",e),e=""):e+=t}f()}(),n}export{a as parseValueUnit};