@master/css 2.0.0-beta.135 → 2.0.0-beta.137

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{START_SYMBOL as b}from"../constants/start-symbol.mjs";import{BOX_UNDERNEATH as v}from"../constants/box-underneath.mjs";import{CONTENT_EXTREMA as f}from"../constants/content-extrema.mjs";import{SIZING_VALUES as g}from"../constants/sizing-values.mjs";import{cssEscape as C}from"../utils/css-escape.mjs";var S={group:{match:"^(?:.+?[*_>~+])?\\{.+?\\}",analyze(e){let t=0;for(;t<e.length&&!(e[t]==="{"&&e[t-1]!=="\\");t++);return[e.slice(t),e.slice(0,t)]},declare(e){let t={},r=(i,a)=>{let n=a.indexOf(":");if(n!==-1){i in t||(t[i]={});let d=t[i],h=a.slice(0,n);h in d||(d[h]=a.slice(n+1))}},s=i=>{let a=(n,d)=>{let h=d.slice(C(i.className).length).match(/\{(.*)\}/)[1].split(";");for(let w of h)r(n,w)};if(this.theme){let n=i.natives.find(d=>d.theme===this.theme)??i.natives.find(d=>!d.theme);n&&a(this.theme,n.text)}else for(let n of i.natives)a(n.theme,n.text)},l=[],o="",c=()=>{o&&(l.push(o.replace(/ /g,"")),o="")},m=1;(function i(a){for(;m<e.length;m++){let n=e[m];if(!a){if(n===";"){c();continue}if(n==="}")break}if(o+=n,a===n){if(a==="'"||a==='"'){let d=0;for(let h=o.length-2;o[h]==="\\";h--)d++;if(d%2)continue}break}else n in b&&a!=="'"&&a!=='"'&&(m++,i(b[n]))}})(void 0),c();for(let i of l){let a=this.css.create(i);if(Array.isArray(a))for(let n of a)s(n);else a?s(a):r(this.theme??"",i)}let u={};for(let i in t)for(let[a,n]of Object.entries(t[i]))a in u?u[a][i]=n:u[a]={[i]:n};return u}},variable:{match:"^\\$[^ (){}A-Z]+:[^ ]",declare(e){return{["--"+this.prefix.slice(1,-1)]:e}}},fontSize:{match:"^f(?:ont)?:(?:[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},fontWeight:{match:"^f(?:ont)?:(?:bolder|$values)(?!\\|)",native:!0,values:{thin:100,extralight:200,light:300,regular:400,medium:500,semibold:600,bold:700,extrabold:800,heavy:900}},fontFamily:{match:"^f(?:ont)?:(?:$values)(?!\\|)",native:!0,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:{match:"^f(?:ont)?:(?:antialiased|subpixel-antialiased|$values)(?!\\|)",declare(e){let t={};switch(e){case"subpixel-antialiased":t["-webkit-font-smoothing"]=t["-moz-osx-font-smoothing"]="auto";break;case"antialiased":t["-webkit-font-smoothing"]="antialiased",t["-moz-osx-font-smoothing"]="grayscale";break}return t}},fontStyle:{match:"^f(?:ont)?:(?:normal|italic|oblique|$values)(?!\\|)",native:!0,unit:"deg"},fontVariantNumeric:{match:"^f(?:ont)?:(?:ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions|$values)(?!\\|)",native:!0},fontFeatureSettings:{match:"^font-feature:.",native:!0},font:{match:"^f:.",native:!0,order:-1},color:{match:"^(?:color|fg|foreground):.",native:!0,colored:!0,values:{current:"currentColor"}},margin:{match:"^m(?:argin(?:-(?:left|right|top|bottom))?|[xytblr]?):.",unit:"rem",declare(e,t){return $.call(this,e+t)},get order(){return this.prefix==="margin:"||this.prefix==="m:"?-1:0}},padding:{match:"^p(?:adding(?:-(?:left|right|top|bottom))?|[xytblr]?):.",unit:"rem",declare(e,t){return $.call(this,e+t)},get order(){return this.prefix==="padding:"||this.prefix==="p:"?-1:0}},flexBasis:{values:g,unit:"rem",native:!0},flexWrap:{match:"^flex:(?:wrap(?:-reverse)?|nowrap|$values)(?!\\|)",native:!0},flexGrow:{native:!0},flexShrink:{native:!0},flexDirection:{match:"^flex:(?:(?:row|column)(?:-reverse)?|$values)(?!\\|)",native:!0,values:{col:"column","col-reverse":"column-reverse"}},flex:{native:!0,order:-1},display:{match:"^d:.",native:!0},width:{match:"^w:.",unit:"rem",native:!0,values:g},height:{match:"^h:.",unit:"rem",native:!0,values:g},minWidth:{match:"^min-w:.",unit:"rem",native:!0,values:g},minHeight:{match:"^min-h:.",unit:"rem",native:!0,values:g},box:{match:"^(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",unit:"rem",separators:["x"],analyze(e){return[e]},declare(e){let[t,r]=e.split(" x ");return{width:t,height:r}}},minBox:{match:"^min:(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",unit:"rem",separators:["x"],analyze(e){return[e.slice(4)]},declare(e){let[t,r]=e.split(" x ");return{"min-width":t,"min-height":r}}},maxBox:{match:"^max:(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",unit:"rem",separators:["x"],analyze(e){return[e.slice(4)]},declare(e){let[t,r]=e.split(" x ");return{"max-width":t,"max-height":r}}},contain:{native:!0},content:{native:!0},counterIncrement:{native:!0},counterReset:{native:!0},letterSpacing:{match:"^ls:.",native:!0,unit:"em"},lineHeight:{match:"^lh:.",native:!0},objectFit:{match:"^(?:object|obj):(?:contain|cover|fill|scale-down|$values)",native:!0},objectPosition:{match:"^(?:object|obj):(?:top|bottom|right|left|center|$values)",native:!0},textAlign:{match:"^t(?:ext)?:(?:justify|center|left|right|start|end|$values)(?!\\|)",native:!0},textDecorationColor:{match:"^text-decoration:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},textDecorationStyle:{match:"^t(?:ext)?:(?:solid|double|dotted|dashed|wavy|$values)(?!\\|)",native:!0},textDecorationThickness:{match:"^text-decoration:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|from-font|$values)[^|]*$",native:!0,unit:"em"},textDecorationLine:{match:"^t(?:ext)?:(?:none|underline|overline|line-through|$values)(?!\\|)",native:!0},textDecoration:{match:"^t(?:ext)?:(?:underline|line-through|overline)",unit:"rem",native:!0,colored:!0,values:{current:"currentColor"},order:-1},textUnderlineOffset:{unit:"rem",native:!0},textOverflow:{match:"^(?:text-(?:overflow|ovf):.|t(?:ext)?:(?:ellipsis|clip|$values)(?!\\|))",native:!0},textOrientation:{match:"^t(?:ext)?:(?:mixed|upright|sideways-right|sideways|use-glyph-orientation|$values)(?!\\|)",native:!0},textTransform:{match:"^t(?:ext)?:(?:uppercase|lowercase|capitalize|$values)(?!\\|)",native:!0},textRendering:{match:"^t(?:ext)?:(?:optimizeSpeed|optimizeLegibility|geometricPrecision|$values)(?!\\|)",native:!0},textIndent:{unit:"rem",native:!0},verticalAlign:{match:"^(?:v|vertical):.",native:!0},columns:{match:"^(?:columns|cols):.",native:!0,order:-1},whiteSpace:{native:!0},inset:{match:"^(?:top|bottom|left|right):.",unit:"rem",native:!0,declare(e,t){return{[this.prefix.slice(0,-1)]:e+t}}},lines:{match:"^lines:.",declare(e,t){return{overflow:"hidden",display:"-webkit-box","overflow-wrap":"break-word","text-overflow":"ellipsis","-webkit-box-orient":"vertical","-webkit-line-clamp":e+t}}},maxHeight:{match:"^max-h:.",unit:"rem",native:!0,values:g},maxWidth:{match:"^max-w:.",unit:"rem",native:!0,values:g},boxSizing:{match:"^box:(?:$values)(?!\\|)",native:!0,values:{content:"content-box",border:"border-box"}},opacity:{native:!0},visibility:{native:!0},clear:{native:!0},float:{native:!0},isolation:{native:!0},overflow:{match:"^overflow(?:-x|-y)?:(?:visible|overlay|hidden|scroll|auto|clip|inherit|initial|revert|revert-layer|unset|\\$|var|$values)",declare(e,t){if(this.prefix)switch(this.prefix.slice(-2,-1)){case"x":return{"overflow-x":e+t};case"y":return{"overflow-y":e+t}}return{overflow:e+t}},get order(){return-1}},overscrollBehavior:{match:"^overscroll-behavior(?:-[xy])?:",declare(e,t){switch(this.prefix.slice(-2,-1)){case"x":return{"overscroll-behavior-x":e+t};case"y":return{"overscroll-behavior-y":e+t};default:return{"overscroll-behavior":e+t}}}},zIndex:{match:"^z:.",native:!0},position:{native:!0,values:{abs:"absolute",rel:"relative"}},cursor:{native:!0},pointerEvents:{native:!0},resize:{native:!0},touchAction:{native:!0},wordBreak:{native:!0},wordSpacing:{native:!0,unit:"em"},userDrag:{declare(e,t){return{"user-drag":e+t,"-webkit-user-drag":e+t}}},userSelect:{native:!0,declare(e,t){return{"user-select":e+t,"-webkit-user-select":e+t}}},textShadow:{unit:"rem",native:!0,colored:!0,values:{current:"currentColor"}},textSize:{match:"^t(?:ext)?:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",declare(e,t){return{"font-size":e+t,"line-height":t==="em"?e+.875+t:`calc(${e}${t} + ${.875}em)`}}},textFillColor:{native:!0,match:"^(?:text-fill|text|t):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",colored:!0,values:{current:"currentColor"},declare(e,t){return{"-webkit-text-fill-color":e+t}}},textStrokeWidth:{match:"^text-stroke(:(thin|medium|thick|\\.?[0-9]+|$values)(?!\\|)|-width:.)",unit:"rem",declare(e,t){return{"-webkit-text-stroke-width":e+t}}},textStrokeColor:{match:"^text-stroke:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"},declare(e,t){return{"-webkit-text-stroke-color":e+t}}},textStroke:{unit:"rem",native:!0,declare(e,t){return{"-webkit-text-stroke":e+t}}},boxShadow:{match:"^s(?:hadow)?:.",unit:"rem",native:!0,colored:!0,values:{current:"currentColor"}},tableLayout:{native:!0},transformBox:{match:"^transform:(?:$values)(?!\\|)",native:!0,values:{...v,fill:"fill-box",stroke:"stroke-box",view:"view-box"}},transformStyle:{match:"^transform:(?:flat|preserve-3d|$values)(?!\\|)",native:!0},transformOrigin:{match:"^transform:(?:top|bottom|right|left|center|[0-9]|$values)",native:!0,unit:"px"},transform:{match:"^(?:translate|scale|skew|rotate|perspective|matrix)(?:3d|[XYZ])?\\(",native:!0},transitionProperty:{match:"^~property:.",native:!0},transitionTimingFunction:{match:"^~easing:.",native:!0},transitionDuration:{match:"^~duration:.",native:!0,unit:"ms"},transitionDelay:{match:"^~delay:.",native:!0,unit:"ms"},transition:{symbol:"~",native:!0,order:-1},animationDelay:{match:"^@delay:.",native:!0,unit:"ms"},animationDirection:{match:"^@direction:.",native:!0},animationDuration:{match:"^@duration:.",native:!0,unit:"ms"},animationFillMode:{match:"^@fill-mode:.",native:!0},animationIterationCount:{match:"^@iteration-count:.",native:!0},animationName:{match:"^@name:.",native:!0,create(e){return x.call(this,e)},delete(e){return y.call(this,e)},insert(){return k.call(this)}},animationPlayState:{match:"^@play-state:.",native:!0},animationTimingFunction:{match:"^@easing:.",native:!0},animation:{symbol:"@",native:!0,order:-1,create(e){return x.call(this,e)},delete(e){return y.call(this,e)},insert(){return k.call(this)}},borderColor:{match:"^b(?:[xytblr]|(?:order(?:-(?:left|right|top|bottom))?))?(?:-color)?:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",colored:!0,values:{current:"currentColor"},declare(e,t){return p(this.prefix,e+t,"color")},get order(){return this.prefix==="border-color:"||this.prefix==="b:"||this.prefix==="border:"?-1:0}},borderRadius:{match:"^(?:r[tblr]?[tblr]?|border(?:-(?:top|bottom)-(?:left|right))?-radius):.",unit:"rem",declare(e,t){if(this.prefix){let s="",l=this.prefix.split("-");if(l.length>1)for(let o=1;o<l.length-1;o++)s+=l[o][0];else s=this.prefix.slice(1,-1);switch(s){case"t":return{"border-top-left-radius":e+t,"border-top-right-radius":e+t};case"tl":case"lt":return{"border-top-left-radius":e+t};case"rt":case"tr":return{"border-top-right-radius":e+t};case"b":return{"border-bottom-left-radius":e+t,"border-bottom-right-radius":e+t};case"bl":case"lb":return{"border-bottom-left-radius":e+t};case"br":case"rb":return{"border-bottom-right-radius":e+t};case"l":return{"border-top-left-radius":e+t,"border-bottom-left-radius":e+t};case"r":return{"border-top-right-radius":e+t,"border-bottom-right-radius":e+t};default:return{"border-radius":e+t}}}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+t}},get order(){return this.prefix==="border-radius:"||this.prefix==="r:"?-1:0}},borderStyle:{match:"^(?:border(?:-(?:left|right|top|bottom))?-style:.|b(?:[xytblr]|order(?:-(?:left|right|top|bottom))?)?:(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|))",declare(e,t){return p(this.prefix,e+t,"style")},get order(){return this.prefix==="border-style:"||this.prefix==="b:"||this.prefix==="border:"?-1:0}},borderWidth:{match:"^(?:border(?:-(?:left|right|top|bottom))?-width:.|b(?:[xytblr]|order(?:-(?:left|right|top|bottom))?)?:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$)",unit:"rem",declare(e,t){return p(this.prefix,e+t,"width")},get order(){return this.prefix==="border-width:"||this.prefix==="b:"||this.prefix==="border:"?-1:0}},borderCollapse:{match:"^b(?:order)?:(?:collapse|separate|$values)(?!\\|)",native:!0},borderSpacing:{unit:"rem",native:!0},borderImageOutset:{unit:"rem",native:!0},borderImageRepeat:{match:"^border-image:(?:stretch|repeat|round|space|$values)(?!\\|)",native:!0},borderImageSlice:{native:!0},borderImageSource:{match:"^border-image:(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)",native:!0},borderImageWidth:{match:"^border-image:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},borderImage:{native:!0},border:{match:"^b(?:[xytblr]?|order(?:-(?:left|right|top|bottom))?):.",unit:"rem",colored:!0,values:{current:"currentColor"},declare(e,t){return p(this.prefix,e+t)},get order(){return this.prefix==="border:"||this.prefix==="b:"?-2:-1}},backgroundAttachment:{match:"^(?:bg|background):(?:fixed|local|scroll|$values)(?!\\|)",native:!0},backgroundBlendMode:{native:!0},backgroundColor:{match:"^(?:bg|background):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},backgroundClip:{match:"^(?:bg|background):(?:text|$values)(?!\\|)",native:!0,declare(e,t){return{"-webkit-background-clip":e+t,"background-clip":e+t}},values:v},backgroundOrigin:{match:"^(?:bg|background):(?:$values)(?!\\|)",native:!0,values:v},backgroundPosition:{match:"^(?:bg|background):(?:top|bottom|right|left|center|$values)(?!\\|)",native:!0,unit:"px"},backgroundRepeat:{match:"^(?:bg|background):(?:space|round|repeat|no-repeat|repeat-x|repeat-y|$values)(?![|a-zA-Z])",native:!0},backgroundSize:{match:"^(?:bg|background):(?:\\.?\\[0-9]+|auto|cover|contain|$values)(?!\\|)",unit:"rem",native:!0},backgroundImage:{match:"^(?:bg|background):(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)",native:!0,colored:!0,values:{current:"currentColor"}},background:{match:"^bg:.",native:!0,colored:!0,values:{current:"currentColor"},order:-1},mixBlendMode:{match:"^blend:.",native:!0},backdropFilter:{match:"^bd:.",native:!0,colored:!0,values:{current:"currentColor"},declare(e,t){return{"backdrop-filter":e+t,"-webkit-backdrop-filter":e+t}}},filter:{match:"^(?:blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\\(",native:!0,colored:!0,values:{current:"currentColor"}},fill:{match:"^fill:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},strokeDasharray:{native:!0},strokeDashoffset:{native:!0},strokeWidth:{match:"^stroke:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",native:!0},stroke:{native:!0,colored:!0,values:{current:"currentColor"}},x:{native:!0},y:{native:!0},cx:{native:!0},cy:{native:!0},rx:{native:!0},ry:{native:!0},gridColumnStart:{match:"^grid-col-start:.",native:!0},gridColumnEnd:{match:"^grid-col-end:.",native:!0},gridColumn:{match:"^grid-col(?:umn)?(?:-span)?:.",native:!0,order:-1,transform(e){return this.prefix.slice(-5,-1)==="span"&&e!=="auto"?"span "+e+"/span "+e:e}},gridColumns:{match:"^grid-cols:.",declare(e,t){return{display:"grid","grid-template-columns":"repeat("+e+t+",minmax(0,1fr))"}}},gridRowStart:{native:!0},gridRowEnd:{native:!0},gridRow:{match:"^grid-row-span:.",native:!0,order:-1,transform(e){return this.prefix.slice(-5,-1)==="span"&&e!=="auto"?"span "+e+"/span "+e:e}},gridRows:{declare(e,t){return{display:"grid","grid-auto-flow":"column","grid-template-rows":"repeat("+e+t+",minmax(0,1fr))"}}},gridAutoColumns:{match:"^grid-auto-cols:.",native:!0,values:f},gridAutoFlow:{match:"^grid-flow:.",native:!0},gridAutoRows:{values:f,native:!0},gridTemplateAreas:{native:!0},gridTemplateColumns:{match:"^grid-template-cols:.",native:!0,unit:"rem",values:f},gridTemplateRows:{native:!0,unit:"rem",values:f},gridTemplate:{native:!0,order:-1},gridArea:{native:!0,order:-1},grid:{native:!0,order:-1},gap:{match:"^gap(?:-x|-y)?:.",unit:"rem",order:-1,declare(e,t){switch(this.prefix[4]){case"x":return{"column-gap":e+t};case"y":return{"row-gap":e+t};default:return{gap:e+t}}}},order:{match:"^o:.",native:!0,values:{first:-999999,last:999999}},breakInside:{native:!0},breakBefore:{native:!0},breakAfter:{native:!0},boxDecorationBreak:{match:"^box:(?:slice|clone|$values)(?!\\|)",native:!0,declare(e,t){return{"box-decoration-break":e+t,"-webkit-box-decoration-break":e+t}}},aspectRatio:{match:"^aspect:.",native:!0},columnSpan:{match:"^col-span:.",native:!0},alignContent:{match:"^ac:.",native:!0},alignItems:{match:"^ai:.",native:!0},alignSelf:{match:"^as:",native:!0},justifyContent:{match:"^jc:.",native:!0},justifyItems:{match:"^ji:.",native:!0},justifySelf:{match:"^js:.",native:!0},placeContent:{native:!0,order:-1},placeItems:{native:!0,order:-1},placeSelf:{native:!0,order:-1},listStylePosition:{match:"^list-style:(?:inside|outside|$values)(?!\\|)",native:!0},listStyleType:{match:"^list-style:(?:disc|decimal|$values)(?!\\|)",native:!0},listStyleImage:{match:"^list-style:(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)",native:!0},listStyle:{native:!0,order:-1},outlineColor:{match:"^outline:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},outlineOffset:{unit:"rem",native:!0},outlineStyle:{match:"^outline:(?:none|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)",native:!0},outlineWidth:{match:"^outline:(?:\\.?[0-9]|medium|thick|thin|(max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},outline:{native:!0,unit:"rem",order:-1,colored:!0,values:{current:"currentColor"}},accentColor:{match:"^accent:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},appearance:{native:!0},caretColor:{match:"^caret:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},scrollBehavior:{native:!0},scrollMargin:{match:"^scroll-m(?:[xytblr]|argin(?:-(?:top|bottom|left|right))?)?:.",unit:"rem",declare(e,t){if(this.prefix.slice(-3,-2)==="m")switch(this.prefix.slice(-2,-1)){case"x":return{"scroll-margin-left":e+t,"scroll-margin-right":e+t};case"y":return{"scroll-margin-top":e+t,"scroll-margin-bottom":e+t};case"l":return{"scroll-margin-left":e+t};case"r":return{"scroll-margin-right":e+t};case"t":return{"scroll-margin-top":e+t};case"b":return{"scroll-margin-bottom":e+t}}else return{[this.prefix.replace(/-m(?!argin)/,"-margin").slice(0,-1)]:e+t}},get order(){return this.prefix==="scroll-margin:"||this.prefix==="scroll-m:"?-1:0}},scrollPadding:{match:"^scroll-p(?:[xytblr]|adding(?:-(?:top|bottom|left|right))?)?:.",unit:"rem",declare(e,t){if(this.prefix.slice(-3,-2)==="p")switch(this.prefix.slice(-2,-1)){case"x":return{"scroll-padding-left":e+t,"scroll-padding-right":e+t};case"y":return{"scroll-padding-top":e+t,"scroll-padding-bottom":e+t};case"l":return{"scroll-padding-left":e+t};case"r":return{"scroll-padding-right":e+t};case"t":return{"scroll-padding-top":e+t};case"b":return{"scroll-padding-bottom":e+t}}else return{[this.prefix.replace(/-p(?!adding)/,"-padding").slice(0,-1)]:e+t}},get order(){return this.prefix==="scroll-padding:"||this.prefix==="scroll-p:"?-1:0}},scrollSnapAlign:{match:"^scroll-snap:(?:start|end|center|$values)",native:!0},scrollSnapStop:{match:"^scroll-snap:(?:normal|always|$values)(?!\\|)",native:!0},scrollSnapType:{match:"^scroll-snap:(?:(?:[xy]|block|inline|both)(?:\\|(?:proximity|mandatory))?|$values)(?!\\|)",native:!0},willChange:{native:!0},writingMode:{match:"^writing:.",native:!0},direction:{native:!0},shapeOutside:{match:"^shape:(?:(?:inset|circle|ellipse|polygon|url|linear-gradient)\\(.*\\)|$values)(?!\\|)",native:!0,values:{...v,margin:"margin-box"}},shapeMargin:{match:"^shape:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},shapeImageThreshold:{native:!0},clipPath:{match:"^clip:.",native:!0,values:{...v,margin:"margin-box",fill:"fill-box",stroke:"stroke-box",view:"view-box"}},quotes:{native:!0},maskImage:{native:!0,declare(e,t){return{"mask-image":e+t,"-webkit-mask-image":e+t}}}},z=S;function x(e){if(!this.css.config.keyframes)return;let t=(this.meta.origin==="symbol"?e.slice(this.meta.config.symbol.length):e.slice(e.indexOf(":")+1)).split("|").filter(r=>r in this.css.config.keyframes);t?.length&&(this.keyframeNames=t)}function y(){if(this.keyframeNames?.length){let e=this.css.rules[0];for(let t of this.keyframeNames){let r=this.css.keyframes[t];if(!--r.count){let s=e.natives.indexOf(r.native);this.css.style.sheet.deleteRule(s),e.natives.splice(s,1),delete this.css.keyframes[t]}}e.natives.length||this.css.rules.splice(0,1)}}function k(){if(this.keyframeNames){let{config:e,keyframes:t,style:r,rules:s}=this.css,l=r?.sheet;for(let o of this.keyframeNames)if(o in t)t[o].count++;else{let c={text:`@keyframes ${o} {`+Object.entries(e.keyframes[o]).map(([u,i])=>`${u} {${Object.entries(i).map(([a,n])=>a+": "+n).join(";")}}`).join(",")+"}",theme:""},m;if(Object.keys(t).length?(m=s[0]).natives.push(c):s.splice(0,0,m={natives:[c],get text(){return this.natives.map(u=>u.text).join("")}}),l){let u;for(let i=0;i<l.cssRules.length;i++){let a=l.cssRules[i];if(a.constructor.name!=="CSSKeyframesRule")break;if(a.name===o){u=a;break}}if(u)c.cssRule=u;else{let i=m.natives.length-1;l.insertRule(c.text,i),c.cssRule=l.cssRules[i]}}t[o]={native:c,count:1}}}}function $(e){if(this.prefix.includes("-"))return{[this.prefix.slice(0,-1)]:e};let r=this.prefix[0]==="m"?"margin":"padding",s=r+"-left",l=r+"-right",o=r+"-top",c=r+"-bottom";switch(this.prefix[1]){case"x":return{[s]:e,[l]:e};case"y":return{[o]:e,[c]:e};case"l":return{[s]:e};case"r":return{[l]:e};case"t":return{[o]:e};case"b":return{[c]:e};default:return{[r]:e}}}function p(e,t,r=""){let s="border-";r&&(r="-"+r);let l=/^b(order)?-?(.)?/.exec(e)[2],o=s+"left"+r,c=s+"right"+r,m=s+"top"+r,u=s+"bottom"+r;switch(l){case"x":return{[o]:t,[c]:t};case"y":return{[m]:t,[u]:t};case"l":return{[o]:t};case"r":return{[c]:t};case"t":return{[m]:t};case"b":return{[u]:t};default:return{["border"+r]:t}}}export{z as rules};
1
+ import{START_SYMBOL as v}from"../constants/start-symbol.mjs";import{cssEscape as x}from"../utils/css-escape.mjs";var $={group:{match:"^(?:.+?[*_>~+])?\\{.+?\\}",analyze(e){let t=0;for(;t<e.length&&!(e[t]==="{"&&e[t-1]!=="\\");t++);return[e.slice(t),e.slice(0,t)]},declare(e){let t={},i=(a,r)=>{let n=r.indexOf(":");if(n!==-1){a in t||(t[a]={});let c=t[a],h=r.slice(0,n);h in c||(c[h]=r.slice(n+1))}},s=a=>{let r=(n,c)=>{let h=c.slice(x(a.className).length).match(/\{(.*)\}/)[1].split(";");for(let f of h)i(n,f)};if(this.theme){let n=a.natives.find(c=>c.theme===this.theme)??a.natives.find(c=>!c.theme);n&&r(this.theme,n.text)}else for(let n of a.natives)r(n.theme,n.text)},m=[],o="",u=()=>{o&&(m.push(o.replace(/ /g,"")),o="")},d=1;(function a(r){for(;d<e.length;d++){let n=e[d];if(!r){if(n===";"){u();continue}if(n==="}")break}if(o+=n,r===n){if(r==="'"||r==='"'){let c=0;for(let h=o.length-2;o[h]==="\\";h--)c++;if(c%2)continue}break}else n in v&&r!=="'"&&r!=='"'&&(d++,a(v[n]))}})(void 0),u();for(let a of m){let r=this.css.create(a);if(Array.isArray(r))for(let n of r)s(n);else r?s(r):i(this.theme??"",a)}let l={};for(let a in t)for(let[r,n]of Object.entries(t[a]))r in l?l[r][a]=n:l[r]={[a]:n};return l}},variable:{match:"^\\$[^ (){}A-Z]+:[^ ]",declare(e){return{["--"+this.prefix.slice(1,-1)]:e}}},fontSize:{match:"^f(?:ont)?:(?:[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},fontWeight:{match:"^f(?:ont)?:(?:bolder|$values)(?!\\|)",native:!0,values:{thin:100,extralight:200,light:300,regular:400,medium:500,semibold:600,bold:700,extrabold:800,heavy:900}},fontFamily:{match:"^f(?:ont)?:(?:$values)(?!\\|)",native:!0,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:{match:"^f(?:ont)?:(?:antialiased|subpixel-antialiased|$values)(?!\\|)",declare(e){switch(e){case"subpixel-antialiased":return{"-webkit-font-smoothing":"auto","-moz-osx-font-smoothing":"auto"};case"antialiased":return{"-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale"}}}},fontStyle:{match:"^f(?:ont)?:(?:normal|italic|oblique|$values)(?!\\|)",native:!0,unit:"deg"},fontVariantNumeric:{match:"^f(?:ont)?:(?:ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions|$values)(?!\\|)",native:!0},fontFeatureSettings:{match:"^font-feature:.",native:!0},font:{match:"^f:.",native:!0,order:-1},color:{match:"^(?:color|fg|foreground):.",native:!0,colored:!0,values:{current:"currentColor"}},marginLeft:{match:"^ml:.",native:!0,unit:"rem"},marginRight:{match:"^mr:.",native:!0,unit:"rem"},marginTop:{match:"^mt:.",native:!0,unit:"rem"},marginBottom:{match:"^mb:.",native:!0,unit:"rem"},marginX:{match:"^(?:mx|margin-x):.",unit:"rem",order:-.5,declare(e,t){return{"margin-left":e+t,"margin-right":e+t}}},marginY:{match:"^(?:my|margin-y):.",unit:"rem",order:-.5,declare(e,t){return{"margin-top":e+t,"margin-bottom":e+t}}},margin:{match:"^m:.",native:!0,unit:"rem",order:-1},paddingLeft:{match:"^pl:.",native:!0,unit:"rem"},paddingRight:{match:"^pr:.",native:!0,unit:"rem"},paddingTop:{match:"^pt:.",native:!0,unit:"rem"},paddingBottom:{match:"^pb:.",native:!0,unit:"rem"},paddingX:{match:"^(?:px|padding-x):.",unit:"rem",order:-.5,declare(e,t){return{"padding-left":e+t,"padding-right":e+t}}},paddingY:{match:"^(?:py|padding-y):.",unit:"rem",order:-.5,declare(e,t){return{"padding-top":e+t,"padding-bottom":e+t}}},padding:{match:"^p:.",native:!0,unit:"rem",order:-1},flexBasis:{values:{full:"100%",fit:"fit-content",max:"max-content",min:"min-content","3xs":360,"2xs":480,xs:600,sm:768,md:1024,lg:1280,xl:1440,"2xl":1600,"3xl":1920,"4xl":2560},unit:"rem",native:!0},flexWrap:{match:"^flex:(?:wrap(?:-reverse)?|nowrap|$values)(?!\\|)",native:!0},flexGrow:{native:!0},flexShrink:{native:!0},flexDirection:{match:"^flex:(?:(?:row|column)(?:-reverse)?|$values)(?!\\|)",native:!0,values:{col:"column","col-reverse":"column-reverse"}},flex:{native:!0,order:-1},display:{match:"^d:.",native:!0},width:{match:"^w:.",unit:"rem",native:!0,values:{full:"100%",fit:"fit-content",max:"max-content",min:"min-content","3xs":360,"2xs":480,xs:600,sm:768,md:1024,lg:1280,xl:1440,"2xl":1600,"3xl":1920,"4xl":2560}},height:{match:"^h:.",unit:"rem",native:!0,values:{full:"100%",fit:"fit-content",max:"max-content",min:"min-content","3xs":360,"2xs":480,xs:600,sm:768,md:1024,lg:1280,xl:1440,"2xl":1600,"3xl":1920,"4xl":2560}},minWidth:{match:"^min-w:.",unit:"rem",native:!0,values:{full:"100%",fit:"fit-content",max:"max-content",min:"min-content","3xs":360,"2xs":480,xs:600,sm:768,md:1024,lg:1280,xl:1440,"2xl":1600,"3xl":1920,"4xl":2560}},minHeight:{match:"^min-h:.",unit:"rem",native:!0,values:{full:"100%",fit:"fit-content",max:"max-content",min:"min-content","3xs":360,"2xs":480,xs:600,sm:768,md:1024,lg:1280,xl:1440,"2xl":1600,"3xl":1920,"4xl":2560}},box:{match:"^(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",unit:"rem",separators:["x"],analyze(e){return[e]},declare(e){let[t,i]=e.split(" x ");return{width:t,height:i}}},minBox:{match:"^min:(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",unit:"rem",separators:["x"],analyze(e){return[e.slice(4)]},declare(e){let[t,i]=e.split(" x ");return{"min-width":t,"min-height":i}}},maxBox:{match:"^max:(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)x(?:(?:max|min|clamp|calc)\\(.+\\)|[0-9]+[a-z]*?)",unit:"rem",separators:["x"],analyze(e){return[e.slice(4)]},declare(e){let[t,i]=e.split(" x ");return{"max-width":t,"max-height":i}}},contain:{native:!0},content:{native:!0},counterIncrement:{native:!0},counterReset:{native:!0},letterSpacing:{match:"^ls:.",native:!0,unit:"em"},lineHeight:{match:"^lh:.",native:!0},objectFit:{match:"^(?:object|obj):(?:contain|cover|fill|scale-down|$values)",native:!0},objectPosition:{match:"^(?:object|obj):(?:top|bottom|right|left|center|$values)",native:!0},textAlign:{match:"^t(?:ext)?:(?:justify|center|left|right|start|end|$values)(?!\\|)",native:!0},textDecorationColor:{match:"^text-decoration:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},textDecorationStyle:{match:"^t(?:ext)?:(?:solid|double|dotted|dashed|wavy|$values)(?!\\|)",native:!0},textDecorationThickness:{match:"^text-decoration:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|from-font|$values)[^|]*$",native:!0,unit:"em"},textDecorationLine:{match:"^t(?:ext)?:(?:none|underline|overline|line-through|$values)(?!\\|)",native:!0},textDecoration:{match:"^t(?:ext)?:(?:underline|line-through|overline)",unit:"rem",native:!0,colored:!0,values:{current:"currentColor"},order:-1},textUnderlineOffset:{unit:"rem",native:!0},textOverflow:{match:"^(?:text-(?:overflow|ovf):.|t(?:ext)?:(?:ellipsis|clip|$values)(?!\\|))",native:!0},textOrientation:{match:"^t(?:ext)?:(?:mixed|upright|sideways-right|sideways|use-glyph-orientation|$values)(?!\\|)",native:!0},textTransform:{match:"^t(?:ext)?:(?:uppercase|lowercase|capitalize|$values)(?!\\|)",native:!0},textRendering:{match:"^t(?:ext)?:(?:optimizeSpeed|optimizeLegibility|geometricPrecision|$values)(?!\\|)",native:!0},textIndent:{unit:"rem",native:!0},verticalAlign:{match:"^(?:v|vertical):.",native:!0},columns:{match:"^(?:columns|cols):.",native:!0,order:-1},whiteSpace:{native:!0},top:{native:!0,unit:"rem"},bottom:{native:!0,unit:"rem"},left:{native:!0,unit:"rem"},right:{native:!0,unit:"rem"},inset:{native:!0,unit:"rem",order:-1},lines:{match:"^lines:.",declare(e,t){return{overflow:"hidden",display:"-webkit-box","overflow-wrap":"break-word","text-overflow":"ellipsis","-webkit-box-orient":"vertical","-webkit-line-clamp":e+t}}},maxHeight:{match:"^max-h:.",unit:"rem",native:!0,values:{full:"100%",fit:"fit-content",max:"max-content",min:"min-content","3xs":360,"2xs":480,xs:600,sm:768,md:1024,lg:1280,xl:1440,"2xl":1600,"3xl":1920,"4xl":2560}},maxWidth:{match:"^max-w:.",unit:"rem",native:!0,values:{full:"100%",fit:"fit-content",max:"max-content",min:"min-content","3xs":360,"2xs":480,xs:600,sm:768,md:1024,lg:1280,xl:1440,"2xl":1600,"3xl":1920,"4xl":2560}},boxSizing:{match:"^box:(?:$values)(?!\\|)",native:!0,values:{content:"content-box",border:"border-box"}},opacity:{native:!0},visibility:{native:!0},clear:{native:!0},float:{native:!0},isolation:{native:!0},overflowX:{native:!0},overflowY:{native:!0},overflow:{native:!0,order:-1},overscrollBehaviorX:{native:!0},overscrollBehaviorY:{native:!0},overscrollBehavior:{native:!0,order:-1},zIndex:{match:"^z:.",native:!0},position:{native:!0,values:{abs:"absolute",rel:"relative"}},cursor:{native:!0},pointerEvents:{native:!0},resize:{native:!0},touchAction:{native:!0},wordBreak:{native:!0},wordSpacing:{native:!0,unit:"em"},userDrag:{declare(e,t){return{"user-drag":e+t,"-webkit-user-drag":e+t}}},userSelect:{native:!0,declare(e,t){return{"user-select":e+t,"-webkit-user-select":e+t}}},textShadow:{unit:"rem",native:!0,colored:!0,values:{current:"currentColor"}},textSize:{match:"^t(?:ext)?:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",declare(e,t){return{"font-size":e+t,"line-height":t==="em"?e+.875+t:`calc(${e}${t} + ${.875}em)`}}},textFillColor:{native:!0,match:"^(?:text-fill|text|t):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",colored:!0,values:{current:"currentColor"},declare(e,t){return{"-webkit-text-fill-color":e+t}}},textStrokeWidth:{match:"^text-stroke(:(thin|medium|thick|\\.?[0-9]+|$values)(?!\\|)|-width:.)",unit:"rem",declare(e,t){return{"-webkit-text-stroke-width":e+t}}},textStrokeColor:{match:"^text-stroke:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"},declare(e,t){return{"-webkit-text-stroke-color":e+t}}},textStroke:{unit:"rem",native:!0,declare(e,t){return{"-webkit-text-stroke":e+t}}},boxShadow:{match:"^s(?:hadow)?:.",unit:"rem",native:!0,colored:!0,values:{current:"currentColor"}},tableLayout:{native:!0},transformBox:{match:"^transform:(?:$values)(?!\\|)",native:!0,values:{content:"content-box",border:"border-box",padding:"padding-box",fill:"fill-box",stroke:"stroke-box",view:"view-box"}},transformStyle:{match:"^transform:(?:flat|preserve-3d|$values)(?!\\|)",native:!0},transformOrigin:{match:"^transform:(?:top|bottom|right|left|center|[0-9]|$values)",native:!0,unit:"px"},transform:{match:"^(?:translate|scale|skew|rotate|perspective|matrix)(?:3d|[XYZ])?\\(",native:!0},transitionProperty:{match:"^~property:.",native:!0},transitionTimingFunction:{match:"^~easing:.",native:!0},transitionDuration:{match:"^~duration:.",native:!0,unit:"ms"},transitionDelay:{match:"^~delay:.",native:!0,unit:"ms"},transition:{symbol:"~",native:!0,order:-1},animationDelay:{match:"^@delay:.",native:!0,unit:"ms"},animationDirection:{match:"^@direction:.",native:!0},animationDuration:{match:"^@duration:.",native:!0,unit:"ms"},animationFillMode:{match:"^@fill-mode:.",native:!0},animationIterationCount:{match:"^@iteration-count:.",native:!0},animationName:{match:"^@name:.",native:!0,create(e){return g.call(this,e)},delete(e){return b.call(this,e)},insert(){return p.call(this)}},animationPlayState:{match:"^@play-state:.",native:!0},animationTimingFunction:{match:"^@easing:.",native:!0},animation:{symbol:"@",native:!0,order:-1,create(e){return g.call(this,e)},delete(e){return b.call(this,e)},insert(){return p.call(this)}},borderCollapse:{match:"^b(?:order)?:(?:collapse|separate|$values)(?!\\|)",native:!0},borderSpacing:{unit:"rem",native:!0},borderTopColor:{match:"^b(?:t|order-top(?:-color)?):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))[^|]*$",native:!0,colored:!0,values:{current:"currentColor"}},borderBottomColor:{match:"^b(?:b|order-bottom(?:-color)?):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))[^|]*$",native:!0,colored:!0,values:{current:"currentColor"}},borderLeftColor:{match:"^b(?:l|order-left(?:-color)?):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))[^|]*$",native:!0,colored:!0,values:{current:"currentColor"}},borderRightColor:{match:"^b(?:r|order-right(?:-color)?):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))[^|]*$",native:!0,colored:!0,values:{current:"currentColor"}},borderXColor:{match:"^b(?:x|order-x(?:-color)?):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))[^|]*$",order:-.5,colored:!0,values:{current:"currentColor"},declare(e,t){return{"border-left-color":e+t,"border-right-color":e+t}}},borderYColor:{match:"^b(?:y|order-y(?:-color)?):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))[^|]*$",order:-.5,colored:!0,values:{current:"currentColor"},declare(e,t){return{"border-top-color":e+t,"border-bottom-color":e+t}}},borderColor:{match:"^b(?:order)?(?:-color)?:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))[^|]*$",native:!0,order:-1,colored:!0,values:{current:"currentColor"}},borderTopLeftRadius:{match:"^r(?:tl|lt):.",unit:"rem",native:!0},borderTopRightRadius:{match:"^r(?:tr|rt):.",unit:"rem",native:!0},borderBottomLeftRadius:{match:"^r(?:bl|lb):.",unit:"rem",native:!0},borderBottomRightRadius:{match:"^r(?:br|rb):.",unit:"rem",native:!0},borderTopRadius:{match:"^rt:.",unit:"rem",order:-.5,declare(e,t){return{"border-top-left-radius":e+t,"border-top-right-radius":e+t}}},borderBottomRadius:{match:"^rb:.",unit:"rem",order:-.5,declare(e,t){return{"border-bottom-left-radius":e+t,"border-bottom-right-radius":e+t}}},borderLeftRadius:{match:"^rl:.",unit:"rem",order:-.5,declare(e,t){return{"border-top-left-radius":e+t,"border-bottom-left-radius":e+t}}},borderRightRadius:{match:"^rr:.",unit:"rem",order:-.5,declare(e,t){return{"border-top-right-radius":e+t,"border-bottom-right-radius":e+t}}},borderRadius:{match:"^r:.",unit:"rem",native:!0,order:-1},borderTopStyle:{match:"^b(?:t|order-top(?:-style)?):(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)",native:!0},borderBottomStyle:{match:"^b(?:b|order-bottom(?:-style)?):(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)",native:!0},borderLeftStyle:{match:"^b(?:l|order-left(?:-style)?):(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)",native:!0},borderRightStyle:{match:"^b(?:r|order-right(?:-style)?):(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)",native:!0},borderXStyle:{match:"^b(?:x|order-x(?:-style)?):(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)",order:-.5,declare(e,t){return{"border-left-style":e+t,"border-right-style":e+t}}},borderYStyle:{match:"^b(?:y|order-y(?:-style)?):(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)",order:-.5,declare(e,t){return{"border-top-style":e+t,"border-bottom-style":e+t}}},borderStyle:{match:"^b(?:order)?(?:-style)?:(?:none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)",native:!0,order:-1},borderTopWidth:{match:"^b(?:t|order-top(?:-width)?):(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},borderBottomWidth:{match:"^b(?:b|order-bottom(?:-width)?):(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},borderLeftWidth:{match:"^b(?:l|order-left(?:-width)?):(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},borderRightWidth:{match:"^b(?:r|order-right(?:-width)?):(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},borderXWidth:{match:"^b(?:x|order-x(?:-width)?):(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",order:-.5,declare(e,t){return{"border-left-width":e+t,"border-right-width":e+t}}},borderYWidth:{match:"^b(?:y|order-y(?:-width)?):(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",order:-.5,declare(e,t){return{"border-top-width":e+t,"border-bottom-width":e+t}}},borderWidth:{match:"^b(?:order)?(?:-width)?:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0,order:-1},borderImageOutset:{unit:"rem",native:!0},borderImageRepeat:{match:"^border-image:(?:stretch|repeat|round|space|$values)(?!\\|)",native:!0},borderImageSlice:{native:!0},borderImageSource:{match:"^border-image:(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)",native:!0},borderImageWidth:{match:"^border-image:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},borderImage:{native:!0,order:-1},borderTop:{match:"^bt:.",native:!0,unit:"rem",colored:!0,values:{current:"currentColor"}},borderBottom:{match:"^bb:.",native:!0,unit:"rem",colored:!0,values:{current:"currentColor"}},borderLeft:{match:"^bl:.",native:!0,unit:"rem",colored:!0,values:{current:"currentColor"}},borderRight:{match:"^br:.",native:!0,unit:"rem",colored:!0,values:{current:"currentColor"}},borderX:{match:"^(?:bx|border-x):.",unit:"rem",colored:!0,order:-.5,values:{current:"currentColor"},declare(e){return{"border-left":e,"border-right":e}}},borderY:{match:"^(?:by|border-y):.",unit:"rem",colored:!0,order:-.5,values:{current:"currentColor"},declare(e){return{"border-top":e,"border-bottom":e}}},border:{match:"^b:.",native:!0,unit:"rem",colored:!0,values:{current:"currentColor"},order:-2},backgroundAttachment:{match:"^(?:bg|background):(?:fixed|local|scroll|$values)(?!\\|)",native:!0},backgroundBlendMode:{native:!0},backgroundColor:{match:"^(?:bg|background):(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},backgroundClip:{match:"^(?:bg|background):(?:text|$values)(?!\\|)",native:!0,declare(e,t){return{"-webkit-background-clip":e+t,"background-clip":e+t}},values:{content:"content-box",border:"border-box",padding:"padding-box"}},backgroundOrigin:{match:"^(?:bg|background):(?:$values)(?!\\|)",native:!0,values:{content:"content-box",border:"border-box",padding:"padding-box"}},backgroundPosition:{match:"^(?:bg|background):(?:top|bottom|right|left|center|$values)(?!\\|)",native:!0,unit:"px"},backgroundRepeat:{match:"^(?:bg|background):(?:space|round|repeat|no-repeat|repeat-x|repeat-y|$values)(?![|a-zA-Z])",native:!0},backgroundSize:{match:"^(?:bg|background):(?:\\.?\\[0-9]+|auto|cover|contain|$values)(?!\\|)",unit:"rem",native:!0},backgroundImage:{match:"^(?:bg|background):(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)",native:!0,colored:!0,values:{current:"currentColor"}},background:{match:"^bg:.",native:!0,colored:!0,values:{current:"currentColor"},order:-1},mixBlendMode:{match:"^blend:.",native:!0},backdropFilter:{match:"^bd:.",native:!0,colored:!0,values:{current:"currentColor"},declare(e,t){return{"backdrop-filter":e+t,"-webkit-backdrop-filter":e+t}}},filter:{match:"^(?:blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|opacity|saturate|sepia)\\(",native:!0,colored:!0,values:{current:"currentColor"}},fill:{match:"^fill:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},strokeDasharray:{native:!0},strokeDashoffset:{native:!0},strokeWidth:{match:"^stroke:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",native:!0},stroke:{native:!0,colored:!0,values:{current:"currentColor"}},x:{native:!0},y:{native:!0},cx:{native:!0},cy:{native:!0},rx:{native:!0},ry:{native:!0},gridColumnStart:{match:"^grid-col-start:.",native:!0},gridColumnEnd:{match:"^grid-col-end:.",native:!0},gridColumn:{match:"^grid-col(?:umn)?(?:-span)?:.",native:!0,order:-1,transform(e){return this.prefix.slice(-5,-1)==="span"&&e!=="auto"?"span "+e+"/span "+e:e}},gridColumns:{match:"^grid-cols:.",declare(e,t){return{display:"grid","grid-template-columns":"repeat("+e+t+",minmax(0,1fr))"}}},gridRowStart:{native:!0},gridRowEnd:{native:!0},gridRow:{match:"^grid-row-span:.",native:!0,order:-1,transform(e){return this.prefix.slice(-5,-1)==="span"&&e!=="auto"?"span "+e+"/span "+e:e}},gridRows:{declare(e,t){return{display:"grid","grid-auto-flow":"column","grid-template-rows":"repeat("+e+t+",minmax(0,1fr))"}}},gridAutoColumns:{match:"^grid-auto-cols:.",native:!0,values:{min:"min-content",max:"max-content"}},gridAutoFlow:{match:"^grid-flow:.",native:!0},gridAutoRows:{values:{min:"min-content",max:"max-content"},native:!0},gridTemplateAreas:{native:!0},gridTemplateColumns:{match:"^grid-template-cols:.",native:!0,unit:"rem",values:{min:"min-content",max:"max-content"}},gridTemplateRows:{native:!0,unit:"rem",values:{min:"min-content",max:"max-content"}},gridTemplate:{native:!0,order:-1},gridArea:{native:!0,order:-1},grid:{native:!0,order:-1},gapX:{unit:"rem",native:!0},gapY:{unit:"rem",native:!0},gap:{unit:"rem",native:!0,order:-1},order:{match:"^o:.",native:!0,values:{first:-999999,last:999999}},breakInside:{native:!0},breakBefore:{native:!0},breakAfter:{native:!0},boxDecorationBreak:{match:"^box:(?:slice|clone|$values)(?!\\|)",native:!0,declare(e,t){return{"box-decoration-break":e+t,"-webkit-box-decoration-break":e+t}}},aspectRatio:{match:"^aspect:.",native:!0},columnSpan:{match:"^col-span:.",native:!0},alignContent:{match:"^ac:.",native:!0},alignItems:{match:"^ai:.",native:!0},alignSelf:{match:"^as:",native:!0},justifyContent:{match:"^jc:.",native:!0},justifyItems:{match:"^ji:.",native:!0},justifySelf:{match:"^js:.",native:!0},placeContent:{native:!0,order:-1},placeItems:{native:!0,order:-1},placeSelf:{native:!0,order:-1},listStylePosition:{match:"^list-style:(?:inside|outside|$values)(?!\\|)",native:!0},listStyleType:{match:"^list-style:(?:disc|decimal|$values)(?!\\|)",native:!0},listStyleImage:{match:"^list-style:(?:(?:url|linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|conic-gradient)\\(.*\\)|$values)(?!\\|)",native:!0},listStyle:{native:!0,order:-1},outlineColor:{match:"^outline:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},outlineOffset:{unit:"rem",native:!0},outlineStyle:{match:"^outline:(?:none|dotted|dashed|solid|double|groove|ridge|inset|outset|$values)(?!\\|)",native:!0},outlineWidth:{match:"^outline:(?:\\.?[0-9]|medium|thick|thin|(max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},outline:{native:!0,unit:"rem",order:-1,colored:!0,values:{current:"currentColor"}},accentColor:{match:"^accent:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},appearance:{native:!0},caretColor:{match:"^caret:(?:(?:#|(rgb|hsl)\\(.*\\))((?!\\|).)*$|(?:transparent|currentColor|inherit|$values|$colors))",native:!0,colored:!0,values:{current:"currentColor"}},scrollBehavior:{native:!0},scrollMarginLeft:{match:"^sml:.",native:!0,unit:"rem"},scrollMarginRight:{match:"^smr:.",native:!0,unit:"rem"},scrollMarginTop:{match:"^smt:.",native:!0,unit:"rem"},scrollMarginBottom:{match:"^smb:.",native:!0,unit:"rem"},scrollMarginX:{match:"^(?:smx|scroll-margin-x):.",unit:"rem",order:-.5,declare(e,t){return{"scroll-margin-left":e+t,"scroll-margin-right":e+t}}},scrollMarginY:{match:"^(?:smy|scroll-margin-y):.",unit:"rem",order:-.5,declare(e,t){return{"scroll-margin-top":e+t,"scroll-margin-bottom":e+t}}},scrollMargin:{match:"^sm:.",native:!0,unit:"rem",order:-1},scrollPaddingLeft:{match:"^spl:.",native:!0,unit:"rem"},scrollPaddingRight:{match:"^spr:.",native:!0,unit:"rem"},scrollPaddingTop:{match:"^spt:.",native:!0,unit:"rem"},scrollPaddingBottom:{match:"^spb:.",native:!0,unit:"rem"},scrollPaddingX:{match:"^(?:spx|scroll-padding-x):.",unit:"rem",order:-.5,declare(e,t){return{"scroll-padding-left":e+t,"scroll-padding-right":e+t}}},scrollPaddingY:{match:"^(?:spy|scroll-padding-y):.",unit:"rem",order:-.5,declare(e,t){return{"scroll-padding-top":e+t,"scroll-padding-bottom":e+t}}},scrollPadding:{match:"^sp:.",native:!0,unit:"rem",order:-1},scrollSnapAlign:{match:"^scroll-snap:(?:start|end|center|$values)",native:!0},scrollSnapStop:{match:"^scroll-snap:(?:normal|always|$values)(?!\\|)",native:!0},scrollSnapType:{match:"^scroll-snap:(?:(?:[xy]|block|inline|both)(?:\\|(?:proximity|mandatory))?|$values)(?!\\|)",native:!0},willChange:{native:!0},writingMode:{match:"^writing:.",native:!0},direction:{native:!0},shapeOutside:{match:"^shape:(?:(?:inset|circle|ellipse|polygon|url|linear-gradient)\\(.*\\)|$values)(?!\\|)",native:!0,values:{content:"content-box",border:"border-box",padding:"padding-box",margin:"margin-box"}},shapeMargin:{match:"^shape:(?:\\.?[0-9]|(?:max|min|calc|clamp)\\(.*\\)|$values)[^|]*$",unit:"rem",native:!0},shapeImageThreshold:{native:!0},clipPath:{match:"^clip:.",native:!0,values:{content:"content-box",border:"border-box",padding:"padding-box",margin:"margin-box",fill:"fill-box",stroke:"stroke-box",view:"view-box"}},quotes:{native:!0},maskImage:{native:!0,declare(e,t){return{"mask-image":e+t,"-webkit-mask-image":e+t}}}},C=$;function g(e){if(!this.css.config.keyframes)return;let t=(this.meta.origin==="symbol"?e.slice(this.meta.config.symbol.length):e.slice(e.indexOf(":")+1)).split("|").filter(i=>i in this.css.config.keyframes);t?.length&&(this.keyframeNames=t)}function b(){if(this.keyframeNames?.length){let e=this.css.rules[0];for(let t of this.keyframeNames){let i=this.css.keyframes[t];if(!--i.count){let s=e.natives.indexOf(i.native);this.css.style.sheet.deleteRule(s),e.natives.splice(s,1),delete this.css.keyframes[t]}}e.natives.length||this.css.rules.splice(0,1)}}function p(){if(this.keyframeNames){let{config:e,keyframes:t,style:i,rules:s}=this.css,m=i?.sheet;for(let o of this.keyframeNames)if(o in t)t[o].count++;else{let u={text:`@keyframes ${o} {`+Object.entries(e.keyframes[o]).map(([l,a])=>`${l} {${Object.entries(a).map(([r,n])=>r+": "+n).join(";")}}`).join(",")+"}",theme:""},d;if(Object.keys(t).length?(d=s[0]).natives.push(u):s.splice(0,0,d={natives:[u],get text(){return this.natives.map(l=>l.text).join("")}}),m){let l;for(let a=0;a<m.cssRules.length;a++){let r=m.cssRules[a];if(r.constructor.name!=="CSSKeyframesRule")break;if(r.name===o){l=r;break}}if(l)u.cssRule=l;else{let a=d.natives.length-1;m.insertRule(u.text,a),u.cssRule=m.cssRules[a]}}t[o]={native:u,count:1}}}}export{C as rules};
@@ -1 +1 @@
1
- var i={square:{"aspect-ratio":"1/1"},video:{"aspect-ratio":"16/9"},rounded:{"border-radius":"1e9em"},round:{"border-radius":"50%"},hidden:{display:"none"},hide:{display:"none"},block:{display:"block"},table:{display:"table"},flex:{display:"flex"},grid:{display:"grid"},contents:{display:"contents"},inline:{display:"inline"},"inline-block":{display:"inline-block"},"inline-flex":{display:"inline-flex"},"inline-grid":{display:"inline-grid"},"inline-table":{display:"inline-table"},"table-cell":{display:"table-cell"},"table-caption":{display:"table-caption"},"flow-root":{display:"flow-root"},"list-item":{display:"list-item"},"table-row":{display:"table-row"},"table-column":{display:"table-column"},"table-row-group":{display:"table-row-group"},"table-column-group":{display:"table-column-group"},"table-header-group":{display:"table-header-group"},"table-footer-group":{display:"table-footer-group"},italic:{"font-style":"italic"},oblique:{"font-style":"oblique"},isolate:{isolation:"isolate"},overflow:{overflow:"visible"},untouchable:{"pointer-events":"none"},static:{position:"static"},fixed:{position:"fixed"},abs:{position:"absolute"},rel:{position:"relative"},sticky:{position:"sticky"},uppercase:{"text-transform":"uppercase"},lowercase:{"text-transform":"lowercase"},capitalize:{"text-transform":"capitalize"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},vw:{width:"100vw"},vh:{height:"100vh"},"max-vw":{"max-width":"100vw"},"max-vh":{"max-height":"100vh"},"min-vw":{"min-width":"100vw"},"min-vh":{"min-height":"100vh"},"center-content":{"justify-content":"center","align-items":"center"},"sr-only":{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)","white-space":"nowrap","border-width":"0"},full:{width:"100%",height:"100%"},center:{left:0,right:0,"margin-left":"auto","margin-right":"auto"},middle:{top:0,bottom:0,"margin-top":"auto","margin-bottom":"auto"},"break-spaces":{"white-space":"break-spaces"},"break-word":{"overflow-wrap":"break-word",overflow:"hidden"}};export{i as semantics};
1
+ var i={square:{"aspect-ratio":"1/1"},video:{"aspect-ratio":"16/9"},rounded:{"border-radius":"1e9em"},round:{"border-radius":"50%"},hidden:{display:"none"},hide:{display:"none"},block:{display:"block"},table:{display:"table"},flex:{display:"flex"},grid:{display:"grid"},contents:{display:"contents"},inline:{display:"inline"},"inline-block":{display:"inline-block"},"inline-flex":{display:"inline-flex"},"inline-grid":{display:"inline-grid"},"inline-table":{display:"inline-table"},"table-cell":{display:"table-cell"},"table-caption":{display:"table-caption"},"flow-root":{display:"flow-root"},"list-item":{display:"list-item"},"table-row":{display:"table-row"},"table-column":{display:"table-column"},"table-row-group":{display:"table-row-group"},"table-column-group":{display:"table-column-group"},"table-header-group":{display:"table-header-group"},"table-footer-group":{display:"table-footer-group"},italic:{"font-style":"italic"},oblique:{"font-style":"oblique"},isolate:{isolation:"isolate"},overflowed:{overflow:"visible"},untouchable:{"pointer-events":"none"},static:{position:"static"},fixed:{position:"fixed"},abs:{position:"absolute"},rel:{position:"relative"},sticky:{position:"sticky"},uppercase:{"text-transform":"uppercase"},lowercase:{"text-transform":"lowercase"},capitalize:{"text-transform":"capitalize"},visible:{visibility:"visible"},invisible:{visibility:"hidden"},vw:{width:"100vw"},vh:{height:"100vh"},"max-vw":{"max-width":"100vw"},"max-vh":{"max-height":"100vh"},"min-vw":{"min-width":"100vw"},"min-vh":{"min-height":"100vh"},"center-content":{"justify-content":"center","align-items":"center"},"sr-only":{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)","white-space":"nowrap","border-width":"0"},full:{width:"100%",height:"100%"},center:{left:0,right:0,"margin-left":"auto","margin-right":"auto"},middle:{top:0,bottom:0,"margin-top":"auto","margin-bottom":"auto"},"break-spaces":{"white-space":"break-spaces"},"break-word":{"overflow-wrap":"break-word",overflow:"hidden"}};export{i as semantics};
package/dist/esm/css.mjs CHANGED
@@ -1 +1 @@
1
- var D=Object.defineProperty;var H=(w,s,r)=>s in w?D(w,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):w[s]=r;var A=(w,s,r)=>(H(w,typeof s!="symbol"?s+"":s,r),r);function L(w){let s=typeof Buffer<"u"?Buffer:null;return!!(s&&w instanceof s||w instanceof Date||w instanceof RegExp)}function F(w){if(typeof Buffer<"u"&&Buffer&&w instanceof Buffer){let s=Buffer.alloc(w.length);return w.copy(s),s}else{if(w instanceof Date)return new Date(w.getTime());if(w instanceof RegExp)return new RegExp(w);throw new Error("Unexpected situation")}}function I(w){let s=[];return w.forEach(function(r,n){typeof r=="object"&&r!==null?Array.isArray(r)?s[n]=I(r):L(r)?s[n]=F(r):s[n]=W({},r):s[n]=r}),s}function N(w,s){return s==="__proto__"?void 0:w[s]}function W(...w){let s={},r,n;return w.forEach(function(u){typeof u!="object"||u===null||Array.isArray(u)||Object.keys(u).forEach(function(x){if(n=N(s,x),r=N(u,x),r!==s)if(typeof r!="object"||r===null){s[x]=r;return}else if(Array.isArray(r)){s[x]=I(r);return}else if(L(r)){s[x]=F(r);return}else if(typeof n!="object"||n===null||Array.isArray(n)){s[x]=W({},r);return}else{s[x]=W(n,r);return}})}),s}import{Rule as Q}from"./rule.mjs";import{config as T}from"./config/index.mjs";import{rgbToHex as z}from"./utils/rgb-to-hex.mjs";import{SELECTOR_SYMBOLS as _}from"./constants/selector-symbols.mjs";var O=typeof window<"u",$=()=>{let w=document.createElement("style");return w.id="master",w},j=class{constructor(s){this.config=s;this.config?.override||(this.config=W(T,s)),this.cache(),O&&this.config.observe&&this.observe(document),j.instances.push(this)}rules=[];ruleBy={};countBy={};observing=!1;observer;e;cache(){this.semantics=[],this.classes={},this.colorThemesMap={},this.themeAffectedClassesBy={},this.classesBy={},this.colorNames=[],this.themeNames=[""],this.selectors={},this.values={},this.globalValues={},this.breakpoints={},this.mediaQueries={},this.matches={},this.keyframes={};let{semantics:s,classes:r,selectors:n,themes:u,colors:x,values:E,breakpoints:b,mediaQueries:g,rules:C}=this.config;function M(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function o(e,t,i="",c={}){let a=v=>v?(i?i+"-":"")+v:i,y=Object.entries(e),R=[],B=[];for(let v of y){let k=v[1];(typeof k=="object"&&!Array.isArray(k)?R:B).push(v)}for(let[v,k]of R)o(k,t,a(v),c);if(t&&i)B.length&&(c[i]=B.reduce((v,[k,V])=>(v[k]=V,v),{}));else for(let[v,k]of B)c[a(v)]=k;return c}if(s)for(let[e,t]of Object.entries(o(s,!0)))this.semantics.push([new RegExp("^"+M(e)+"(?=!|\\*|>|\\+|~|:|\\[|@|_|\\.|$)","m"),[e,t]]);if(n)for(let[e,t]of Object.entries(o(n,!1))){let i=new RegExp(M(e)+"(?![a-z-])");for(let c of Array.isArray(t)?t:[t]){let a=c.match(/^::-[a-z]+-/m)?.[0]??"",y=this.selectors[a];y||(y=this.selectors[a]=[]);let R=y.find(([B])=>B===i);R||(R=[i,[]],y.push(R)),R[1].push(c)}}E&&(this.globalValues=o(E,!1)),b&&(this.breakpoints=o(b,!1)),g&&(this.mediaQueries=o(g,!1));let h=r?o(r,!1):{},p=u&&!Array.isArray(u)?Object.entries(u).filter(([,{classes:e}])=>e).reduce((e,[t,{classes:i}])=>(e[t]=o(i,!1),e),{}):{},f=[...Object.keys(h),...Object.entries(p).flatMap(([e,t])=>Object.keys(t))],m=e=>{if(e in this.classes)return;let t=this.classes[e]=[],i=(c,a)=>{if(!a)return;let y=Array.isArray(a)?a:a.replace(/(?:\n(?:\s*))+/g," ").trim().split(" ");for(let R of y){let B=v=>{v in this.themeAffectedClassesBy?c in this.themeAffectedClassesBy[v]?this.themeAffectedClassesBy[v][c].push(e):this.themeAffectedClassesBy[v][c]=[e]:this.themeAffectedClassesBy[v]={[c]:[e]},t.includes(v)||t.push(v)};if(f.includes(R)){m(R);for(let v of this.classes[R])B(v)}else B(R)}};i("",h?.[e]);for(let[c,a]of Object.entries(p))i(c,a?.[e])};for(let e of f)m(e);for(let e in this.themeAffectedClassesBy){let t=this.classesBy[e]=[];for(let i of Object.values(this.themeAffectedClassesBy[e]))for(let c of i)t.includes(c)||t.push(c)}let l=(e,t)=>{if(!t)return;let i=o(t,!0);for(let[c,a]of Object.entries(i)){let y=typeof a=="string"?{"":a}:a;for(let[R,B]of Object.entries(y)){let v=c+(R?"-"+R:"");v in this.colorThemesMap?this.colorThemesMap[v][e]=B:this.colorThemesMap[v]={[e]:B}}}for(let c in t)this.colorNames.includes(c)||this.colorNames.push(c)};if(l("",x),u)if(Array.isArray(u))this.themeNames.push(...u);else for(let e in u){let t=u[e];l(e,t.colors),this.themeNames.push(e)}let d=e=>{for(let[t,i]of Object.entries(this.colorThemesMap))for(let[c,a]of Object.entries(i))a.startsWith("#")||e(t,i,c,a)};if(d((e,t,i,c)=>{let a=/^rgba?\( *([0-9]{1,3}) *(?: |,) *([0-9]{1,3}) *(?: |,) *([0-9]{1,3}) *(?:(?:\/|,) *0?(\.[0-9]))?\)$/.exec(c);if(a){let y="#"+z(+a[1],+a[2],+a[3]);a[4]&&(y+=Math.round(255*+a[4]).toString(16)),t[i]=y}}),d((e,t,i,c)=>{let[a,y]=c.split("/"),R=this.colorThemesMap[a];if(R){let B=(i?R[i]:void 0)??R[""];t[i]=y?B.slice(0,7)+Math.round(255*+y).toString(16):B}else console.warn(`\`${c}\` doesn't exist in the extended config \`.colors\``),delete t[i],Object.keys(t).length||delete this.colorThemesMap[e]}),C)for(let e in C){let t=C[e],{native:i,values:c,colored:a}=t,y=t.match;if(t.id=e,t.native=i===!0?e.replace(/(?!^)[A-Z]/g,R=>"-"+R).toLowerCase():void 0,c&&(this.values[e]=o(c,!1)),y){let R=Object.keys(this.values[e]??{});y.includes("$values")&&(y=R.length?y.replace(/\$values/,R.join("|")):y.replace(/(?:\|)?\$values/,"")),a&&y.includes("$colors")&&(y=this.colorNames.length?y.replace(/\$colors/,"(?:"+this.colorNames.join("|")+")(?![0-9A-Za-z])"):y.replace(/(?:\|)?\$colors/,"")),this.matches[e]=new RegExp(y)}}}observe(s,r={subtree:!0,childList:!0}){if(this.root!==s){if(O&&s){this.root=s;let n=s===document;n&&(j.root=this),this.host=n?document.documentElement:root.host;let u=n?document.head:s,x=n?document.styleSheets:s.styleSheets;for(let b of x){let{href:g,ownerNode:C}=b;(C.id==="master"||g&&g.startsWith(window.location.origin)&&/master(?:\..+)?\.css/.test(g))&&(this.style=C)}if(this.style)for(let b=0;b<this.style.sheet.cssRules.length;b++){let g=this.style.sheet.cssRules[b];if(g.constructor.name==="CSSKeyframesRule")continue;let C=o=>{if(o.selectorText){let p=o.selectorText.split(", ")[0].split(" ");for(let f=0;f<p.length;f++){let m=p[f];if(m[0]==="."){let l=m.slice(1),d="";for(let e=0;e<l.length;e++){let t=l[e],i=l[e+1];if(t==="\\"){if(e++,i!=="\\"){d+=i;continue}}else if(_.includes(t))break;d+=t}if(!(d in this.ruleBy)&&!(d in this.classes)){let e=this.create(d)[0];if(e)return e}}}}else if(o.cssRules)for(let h=0;h<o.cssRules.length;h++){let p=C(o.cssRules[h]);if(p)return p}},M=C(g);if(M){this.rules.push(M),this.ruleBy[M.className]=M;for(let o=0;o<M.natives.length;o++)M.natives[o].cssRule=this.style.sheet.cssRules[b+o];b+=M.natives.length-1,M.config.insert?.call(M)}}else this.style=$();u.append(this.style);let E=b=>{b.forEach(g=>{g in this.countBy?this.countBy[g]++:(this.countBy[g]=1,this.insert(g))})};E(this.host.classList),r.subtree&&this.host.querySelectorAll("[class]").forEach(b=>E(b.classList)),this.observer=new MutationObserver(b=>{let g={},C=[],M=[],o=[],h=(l,d)=>{d?l.classList.forEach(f):l.classList.forEach(p);let e=l.children;for(let t=0;t<e.length;t++){let i=e[t];i.classList&&(M.push(i),h(i,d))}},p=l=>{l in g?g[l]++:g[l]=1},f=l=>{l in g?g[l]--:l in this.countBy&&(g[l]=-1)},m=(l,d)=>{for(let e=0;e<l.length;e++){let t=l[e];t.classList&&!M.includes(t)&&!o.includes(t)&&(t.isConnected!==d?(M.push(t),h(t,d)):o.push(t))}};for(let l=0;l<b.length;l++){let d=b[l],{addedNodes:e,removedNodes:t,type:i,target:c}=d;if(i==="attributes"){if(C.find(a=>a.target===c))continue;C.push(d)}else m(e,!1),(!c.isConnected||!M.includes(c))&&m(t,!0)}if(!(!C.length&&!Object.keys(g).length)){for(let{oldValue:l,target:d}of C){let e=M.includes(d),t=d.classList,i=l?l.split(" "):[];if(e){if(d.isConnected)continue;for(let c of i)t.contains(c)||f(c)}else if(d.isConnected){t.forEach(c=>{i.includes(c)||p(c)});for(let c of i)t.contains(c)||f(c)}}for(let l in g){let d=g[l],e=(this.countBy[l]||0)+d;e===0?(delete this.countBy[l],this.delete(l)):(l in this.countBy||this.insert(l),this.countBy[l]=e)}}}),this.observer.observe(s,{...r,attributes:!0,attributeOldValue:!0,attributeFilter:["class"]}),this.e=new MutationObserver(b=>{for(let g of b)for(let C of g.addedNodes)if(C.nodeName==="STYLE"||C.nodeName==="LINK"&&C.rel==="stylesheet"){let M=this.root.styleSheets;if(M.item(M.length-1).ownerNode!==this.style){let p=this.style.sheet.cssRules;u.append(this.style);for(let f of p)this.style.sheet.insertRule(f.cssText)}}}),this.e.observe(u,{childList:!0}),this.host.style.display=null,this.observing=!0}return this}}disconnect(){this.observer&&(this.observer.disconnect(),this.observer=null),this.e&&(this.e.disconnect(),this.e=null),this.observing=!1,this.ruleBy={},this.countBy={},this.rules.length=0;let s=this.style?.sheet;if(s?.cssRules)for(let r=s.cssRules.length-1;r>=0;r--)s.deleteRule(r);this.style?.remove(),this.style=null,this.root=null}match(s){for(let r in this.config.rules){let n=this.config.rules[r],u=this.matches[r],{symbol:x,native:E}=n;if(u&&u.test(s))return{origin:"match",config:n};if(x&&s.startsWith(x))return{origin:"symbol",config:n};if(E&&s.startsWith(E+":"))return{origin:"match",config:n}}for(let r of this.semantics)if(s.match(r[0]))return{origin:"semantics",value:r[1]}}create(s){let r=n=>{if(n in this.ruleBy)return this.ruleBy[n];let u=this.match(n);if(u)return new Q(n,u,this)};return(s in this.classes?this.classes[s].map(n=>r(n)):[r(s)]).filter(n=>n&&n.text)}refresh(s){if(s?.override?this.config=s:this.config=W(T,s),this.cache(),!this.style)return;let r=$();this.style.replaceWith(r),this.style=r,this.rules.length=0,this.ruleBy={};for(let n in this.countBy)this.insert(n)}destroy(){let s=j.instances;this.disconnect(),s.splice(s.indexOf(this),1)}delete(s){let r=this.style?.sheet,n=u=>{let x=this.ruleBy[u];if(!(!x||u in this.classesBy&&this.classesBy[u].some(E=>E in this.countBy))){if(r&&x.natives.length){let E=x.natives[0];for(let b=0;b<r.cssRules.length;b++)if(r.cssRules[b]===E.cssRule){for(let C=0;C<x.natives.length;C++)r.deleteRule(b);break}}this.rules.splice(this.rules.indexOf(x),1),delete this.ruleBy[u],x.config.delete&&x.config.delete.call(x,u)}};if(s in this.classes){for(let u of this.classes[s])u in this.countBy||n(u);delete this.ruleBy[s]}else n(s)}insert(s){let r=this.create(s);return r.length?(this.insertRules(r),!0):!1}insertRules(s){for(let r of s){if(this.ruleBy[r.className])continue;let n,u=this.rules.length-1,{media:x,order:E,priority:b,hasWhere:g,className:C}=r,M=(o,h,p,f)=>{let m=0,l;h&&(m=o.findIndex(h)),p&&(l=o.findIndex(p)),m===-1&&(m=o.length),(l===void 0||l===-1)&&(l=o.length);let d=o.slice(m,l);for(let e=0;e<d.length;e++){let t=d[e];if(!(t.priority===-1||f&&f(t))&&(t.priority<b||t.priority===b&&(g&&!t.hasWhere||t.order>=E)))return m+e}return m+d.length};if(x){let o=this.rules.findIndex(h=>h.media);if(o!==-1){let h=x.features["max-width"],p=x.features["min-width"];if(h&&p){let f=h.value-p.value;for(let m=u;m>=o;m--){n=m;let l=this.rules[m],d=l.media,e=d.features["max-width"],t=d.features["min-width"];if(!e||!t){n++;break}let i=e.value-t.value;if(i===f){if(g!==l.hasWhere)continue;if(b!==-1){let c=[this.rules[m]];for(let a=m-1;a>=o;a--){let y=this.rules[a];if(y.hasWhere!==g)break;let R=y.media,B=R.features["max-width"],v=R.features["min-width"];if(!B||!v||B.value-v.value!==i)break;c.unshift(this.rules[a])}n=M(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(p)for(let f=o;f<=u;f++){n=f;let m=this.rules[f],l=m.media,d=l.features["max-width"],e=l.features["min-width"];if(d){if(e)break;continue}let t=e?.value;if(t===p.value){if(!g&&m.hasWhere){n++;continue}if(b!==-1)n=M(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<=u;i++){let c=this.rules[i],a=c.media,y=a.features["min-width"];if(!a.features["max-width"]){if(c.hasWhere!==g||y.value!==t||c.order>=E)break;n=i+1}}break}else{if(t>p.value)break;n++}}else if(h)for(let f=u;f>=o;f--){n=f;let m=this.rules[f],l=m.media,d=l.features["max-width"];if(l.features["min-width"])continue;let t=d?.value;if(!t||t>h.value){n++;break}else if(t===h.value){if(g&&!m.hasWhere)continue;if(b!==-1)n=M(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 c=f-1;c>=o;c--){let a=this.rules[c],y=a.media,R=y.features["min-width"],B=y.features["max-width"];if(!R&&(!B||B.value!==t||a.hasWhere!==g))break;i.unshift(a)}for(let c=0;c<i.length;c++){let a=i[c];if(!a.media.features["min-width"]){if(a.order>=E)break;n=f-i.length+2+c}}}break}}}if(n===void 0)if(o===-1)n=u+1;else if(b!==-1)n=o+M(this.rules.slice(o),void 0,h=>h.media.features["max-width"]||h.media.features["min-width"]);else if(g){let h=o;for(;h<this.rules.length;h++){let p=this.rules[h];if(p.priority!==-1||!p.hasWhere||p.order>=E){n=h;break}}n===void 0&&(n=h)}else for(let h=o;h<=u;h++){n=h;let p=this.rules[h],f=p.media;if(p.priority!==-1||f.features["max-width"]||f.features["min-width"])break;if(p.hasWhere)n++;else if(p.order>=E)break}}else if(b===-1){if(g)n=this.rules.findIndex(o=>!o.hasWhere||o.media||o.priority!==-1||o.order>=E),n===-1&&(n=u+1);else{let o=0;for(;o<this.rules.length;o++){let h=this.rules[o];if(h.media||!h.hasWhere&&(h.order>=E||h.priority!==-1)){n=o;break}}n===void 0&&(n=o)}!n&&Object.keys(this.keyframes).length&&n++}else n=M(this.rules,void 0,o=>o.media);if(this.rules.splice(n,0,r),this.ruleBy[C]=r,this.style){let o=this.style.sheet,h=0,p=f=>{let m=this.rules[f];if(m){if(!m.natives.length)return p(f-1);let l=m.natives[m.natives.length-1].cssRule;for(let d=0;d<o.cssRules.length;d++)if(o.cssRules[d]===l){h=d+1;break}}};p(n-1);for(let f=0;f<r.natives.length;)try{let m=r.natives[f];o.insertRule(m.text,h),m.cssRule=o.cssRules[h++],f++}catch(m){console.error(m),r.natives.splice(f,1)}}r.config.insert?.call(r)}}get text(){return this.rules.map(s=>s.text).join("")}},S=j;A(S,"root"),A(S,"config",T),A(S,"instances",[]),A(S,"refresh",s=>{for(let r of j.instances)r.refresh(s)});O&&(window.MasterCSS=S);export{S as MasterCSS};
1
+ var D=Object.defineProperty;var H=(M,t,r)=>t in M?D(M,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):M[t]=r;var O=(M,t,r)=>(H(M,typeof t!="symbol"?t+"":t,r),r);function L(M){let t=typeof Buffer<"u"?Buffer:null;return!!(t&&M instanceof t||M instanceof Date||M instanceof RegExp)}function F(M){if(typeof Buffer<"u"&&Buffer&&M instanceof Buffer){let t=Buffer.alloc(M.length);return M.copy(t),t}else{if(M instanceof Date)return new Date(M.getTime());if(M instanceof RegExp)return new RegExp(M);throw new Error("Unexpected situation")}}function I(M){let t=[];return M.forEach(function(r,n){typeof r=="object"&&r!==null?Array.isArray(r)?t[n]=I(r):L(r)?t[n]=F(r):t[n]=j({},r):t[n]=r}),t}function N(M,t){return t==="__proto__"?void 0:M[t]}function j(...M){let t={},r,n;return M.forEach(function(d){typeof d!="object"||d===null||Array.isArray(d)||Object.keys(d).forEach(function(x){if(n=N(t,x),r=N(d,x),r!==t)if(typeof r!="object"||r===null){t[x]=r;return}else if(Array.isArray(r)){t[x]=I(r);return}else if(L(r)){t[x]=F(r);return}else if(typeof n!="object"||n===null||Array.isArray(n)){t[x]=j({},r);return}else{t[x]=j(n,r);return}})}),t}import{Rule as Q}from"./rule.mjs";import{config as T}from"./config/index.mjs";import{rgbToHex as z}from"./utils/rgb-to-hex.mjs";import{SELECTOR_SYMBOLS as _}from"./constants/selector-symbols.mjs";var S=typeof window<"u",$=()=>{let M=document.createElement("style");return M.id="master",M},A=class{constructor(t=T){this.config=t;t?.override||(this.config=j(T,t),"keyframes"in t&&Object.assign(this.config.keyframes,t.keyframes)),this.cache(),S&&this.config.observe&&this.observe(document),A.instances.push(this)}rules=[];ruleBy={};countBy={};observing=!1;observer;cache(){this.semantics=[],this.classes={},this.colorThemesMap={},this.themeAffectedClassesBy={},this.classesBy={},this.colorNames=[],this.themeNames=[""],this.selectors={},this.values={},this.globalValues={},this.breakpoints={},this.mediaQueries={},this.matches={},this.keyframes={};let{semantics:t,classes:r,selectors:n,themes:d,colors:x,values:B,breakpoints:b,mediaQueries:g,rules:k}=this.config;function w(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function o(e,s,i="",c={}){let a=v=>v?(i?i+"-":"")+v:i,y=Object.entries(e),R=[],C=[];for(let v of y){let E=v[1];(typeof E=="object"&&!Array.isArray(E)?R:C).push(v)}for(let[v,E]of R)o(E,s,a(v),c);if(s&&i)C.length&&(c[i]=C.reduce((v,[E,V])=>(v[E]=V,v),{}));else for(let[v,E]of C)c[a(v)]=E;return c}if(t)for(let[e,s]of Object.entries(o(t,!0)))this.semantics.push([new RegExp("^"+w(e)+"(?=!|\\*|>|\\+|~|:|\\[|@|_|\\.|$)","m"),[e,s]]);if(n)for(let[e,s]of Object.entries(o(n,!1))){let i=new RegExp(w(e)+"(?![a-z-])");for(let c of Array.isArray(s)?s:[s]){let a=c.match(/^::-[a-z]+-/m)?.[0]??"",y=this.selectors[a];y||(y=this.selectors[a]=[]);let R=y.find(([C])=>C===i);R||(R=[i,[]],y.push(R)),R[1].push(c)}}B&&(this.globalValues=o(B,!1)),b&&(this.breakpoints=o(b,!1)),g&&(this.mediaQueries=o(g,!1));let h=r?o(r,!1):{},p=d&&!Array.isArray(d)?Object.entries(d).filter(([,{classes:e}])=>e).reduce((e,[s,{classes:i}])=>(e[s]=o(i,!1),e),{}):{},f=[...Object.keys(h),...Object.entries(p).flatMap(([e,s])=>Object.keys(s))],m=e=>{if(e in this.classes)return;let s=this.classes[e]=[],i=(c,a)=>{if(!a)return;let y=Array.isArray(a)?a:a.replace(/(?:\n(?:\s*))+/g," ").trim().split(" ");for(let R of y){let C=v=>{v in this.themeAffectedClassesBy?c in this.themeAffectedClassesBy[v]?this.themeAffectedClassesBy[v][c].push(e):this.themeAffectedClassesBy[v][c]=[e]:this.themeAffectedClassesBy[v]={[c]:[e]},s.includes(v)||s.push(v)};if(f.includes(R)){m(R);for(let v of this.classes[R])C(v)}else C(R)}};i("",h?.[e]);for(let[c,a]of Object.entries(p))i(c,a?.[e])};for(let e of f)m(e);for(let e in this.themeAffectedClassesBy){let s=this.classesBy[e]=[];for(let i of Object.values(this.themeAffectedClassesBy[e]))for(let c of i)s.includes(c)||s.push(c)}let l=(e,s)=>{if(!s)return;let i=o(s,!0);for(let[c,a]of Object.entries(i)){let y=typeof a=="string"?{"":a}:a;for(let[R,C]of Object.entries(y)){let v=c+(R?"-"+R:"");v in this.colorThemesMap?this.colorThemesMap[v][e]=C:this.colorThemesMap[v]={[e]:C}}}for(let c in s)this.colorNames.includes(c)||this.colorNames.push(c)};if(l("",x),d)if(Array.isArray(d))this.themeNames.push(...d);else for(let e in d){let s=d[e];l(e,s.colors),this.themeNames.push(e)}let u=e=>{for(let[s,i]of Object.entries(this.colorThemesMap))for(let[c,a]of Object.entries(i))a.startsWith("#")||e(s,i,c,a)};if(u((e,s,i,c)=>{let a=/^rgba?\( *([0-9]{1,3}) *(?: |,) *([0-9]{1,3}) *(?: |,) *([0-9]{1,3}) *(?:(?:\/|,) *0?(\.[0-9]))?\)$/.exec(c);if(a){let y="#"+z(+a[1],+a[2],+a[3]);a[4]&&(y+=Math.round(255*+a[4]).toString(16)),s[i]=y}}),u((e,s,i,c)=>{let[a,y]=c.split("/"),R=this.colorThemesMap[a];if(R){let C=(i?R[i]:void 0)??R[""];s[i]=y?C.slice(0,7)+Math.round(255*+y).toString(16):C}else console.warn(`\`${c}\` doesn't exist in the extended config \`.colors\``),delete s[i],Object.keys(s).length||delete this.colorThemesMap[e]}),k)for(let e in k){let s=k[e],{native:i,values:c,colored:a}=s,y=s.match;if(s.id=e,s.native=i===!0?e.replace(/(?!^)[A-Z]/g,R=>"-"+R).toLowerCase():void 0,c&&(this.values[e]=o(c,!1)),y){let R=Object.keys(this.values[e]??{});y.includes("$values")&&(y=R.length?y.replace(/\$values/,R.join("|")):y.replace(/(?:\|)?\$values/,"")),a&&y.includes("$colors")&&(y=this.colorNames.length?y.replace(/\$colors/,"(?:"+this.colorNames.join("|")+")(?![0-9A-Za-z])"):y.replace(/(?:\|)?\$colors/,"")),this.matches[e]=new RegExp(y)}}}observe(t,r={subtree:!0,childList:!0}){if(this.root!==t){if(S&&t){this.root=t;let n=t===document;n&&(A.root=this),this.host=n?document.documentElement:root.host;let d=n?document.head:t,x=n?document.styleSheets:t.styleSheets;for(let b of x){let{href:g,ownerNode:k}=b;if(k.id==="master"||g&&g.startsWith(window.location.origin)&&/master(?:\..+)?\.css/.test(g)){this.style=k;break}}if(this.style)for(let b=0;b<this.style.sheet.cssRules.length;b++){let g=this.style.sheet.cssRules[b];if(g.constructor.name==="CSSKeyframesRule")continue;let k=o=>{if(o.selectorText){let p=o.selectorText.split(", ")[0].split(" ");for(let f=0;f<p.length;f++){let m=p[f];if(m[0]==="."){let l=m.slice(1),u="";for(let e=0;e<l.length;e++){let s=l[e],i=l[e+1];if(s==="\\"){if(e++,i!=="\\"){u+=i;continue}}else if(_.includes(s))break;u+=s}if(!(u in this.ruleBy)&&!(u in this.classes)){let e=this.create(u)[0];if(e)return e}}}}else if(o.cssRules)for(let h=0;h<o.cssRules.length;h++){let p=k(o.cssRules[h]);if(p)return p}},w=k(g);if(w){this.rules.push(w),this.ruleBy[w.className]=w;for(let o=0;o<w.natives.length;o++)w.natives[o].cssRule=this.style.sheet.cssRules[b+o];b+=w.natives.length-1,w.config.insert?.call(w)}}else this.style=$(),d.append(this.style);let B=b=>{b.forEach(g=>{g in this.countBy?this.countBy[g]++:(this.countBy[g]=1,this.insert(g))})};B(this.host.classList),r.subtree&&this.host.querySelectorAll("[class]").forEach(b=>B(b.classList)),this.observer=new MutationObserver(b=>{let g={},k=[],w=[],o=[],h=(l,u)=>{u?l.classList.forEach(f):l.classList.forEach(p);let e=l.children;for(let s=0;s<e.length;s++){let i=e[s];i.classList&&(w.push(i),h(i,u))}},p=l=>{l in g?g[l]++:g[l]=1},f=l=>{l in g?g[l]--:l in this.countBy&&(g[l]=-1)},m=(l,u)=>{for(let e=0;e<l.length;e++){let s=l[e];s.classList&&!w.includes(s)&&!o.includes(s)&&(s.isConnected!==u?(w.push(s),h(s,u)):o.push(s))}};for(let l=0;l<b.length;l++){let u=b[l],{addedNodes:e,removedNodes:s,type:i,target:c}=u;if(i==="attributes"){if(k.find(a=>a.target===c))continue;k.push(u)}else m(e,!1),(!c.isConnected||!w.includes(c))&&m(s,!0)}if(!(!k.length&&!Object.keys(g).length)){for(let{oldValue:l,target:u}of k){let e=w.includes(u),s=u.classList,i=l?l.split(" "):[];if(e){if(u.isConnected)continue;for(let c of i)s.contains(c)||f(c)}else if(u.isConnected){s.forEach(c=>{i.includes(c)||p(c)});for(let c of i)s.contains(c)||f(c)}}for(let l in g){let u=g[l],e=(this.countBy[l]||0)+u;e===0?(delete this.countBy[l],this.delete(l)):(l in this.countBy||this.insert(l),this.countBy[l]=e)}}}),this.observer.observe(t,{...r,attributes:!0,attributeOldValue:!0,attributeFilter:["class"]}),this.host.style.display=null,this.observing=!0}return this}}disconnect(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observing=!1,this.ruleBy={},this.countBy={},this.rules.length=0;let t=this.style?.sheet;if(t?.cssRules)for(let r=t.cssRules.length-1;r>=0;r--)t.deleteRule(r);this.style?.remove(),this.style=null,this.root=null}match(t){for(let r in this.config.rules){let n=this.config.rules[r],d=this.matches[r],{symbol:x,native:B}=n;if(d&&d.test(t))return{origin:"match",config:n};if(x&&t.startsWith(x))return{origin:"symbol",config:n};if(B&&t.startsWith(B+":"))return{origin:"match",config:n}}for(let r of this.semantics)if(t.match(r[0]))return{origin:"semantics",value:r[1]}}create(t){let r=n=>{if(n in this.ruleBy)return this.ruleBy[n];let d=this.match(n);if(d)return new Q(n,d,this)};return(t in this.classes?this.classes[t].map(n=>r(n)):[r(t)]).filter(n=>n&&n.text)}refresh(t){if(t?.override?this.config=t:this.config=j(T,t),this.cache(),!this.style)return;let r=$();this.style.replaceWith(r),this.style=r,this.rules.length=0,this.ruleBy={};for(let n in this.countBy)this.insert(n)}destroy(){let t=A.instances;this.disconnect(),t.splice(t.indexOf(this),1)}delete(t){let r=this.style?.sheet,n=d=>{let x=this.ruleBy[d];if(!(!x||d in this.classesBy&&this.classesBy[d].some(B=>B in this.countBy))){if(r&&x.natives.length){let B=x.natives[0];for(let b=0;b<r.cssRules.length;b++)if(r.cssRules[b]===B.cssRule){for(let k=0;k<x.natives.length;k++)r.deleteRule(b);break}}this.rules.splice(this.rules.indexOf(x),1),delete this.ruleBy[d],x.config.delete&&x.config.delete.call(x,d)}};if(t in this.classes){for(let d of this.classes[t])d in this.countBy||n(d);delete this.ruleBy[t]}else n(t)}insert(t){let r=this.create(t);return r.length?(this.insertRules(r),!0):!1}insertRules(t){for(let r of t){if(this.ruleBy[r.className])continue;let n,d=this.rules.length-1,{media:x,order:B,priority:b,hasWhere:g,className:k}=r,w=(o,h,p,f)=>{let m=0,l;h&&(m=o.findIndex(h)),p&&(l=o.findIndex(p)),m===-1&&(m=o.length),(l===void 0||l===-1)&&(l=o.length);let u=o.slice(m,l);for(let e=0;e<u.length;e++){let s=u[e];if(!(s.priority===-1||f&&f(s))&&(s.priority<b||s.priority===b&&(g&&!s.hasWhere||s.order>=B)))return m+e}return m+u.length};if(x){let o=this.rules.findIndex(h=>h.media);if(o!==-1){let h=x.features["max-width"],p=x.features["min-width"];if(h&&p){let f=h.value-p.value;for(let m=d;m>=o;m--){n=m;let l=this.rules[m],u=l.media,e=u.features["max-width"],s=u.features["min-width"];if(!e||!s){n++;break}let i=e.value-s.value;if(i===f){if(g!==l.hasWhere)continue;if(b!==-1){let c=[this.rules[m]];for(let a=m-1;a>=o;a--){let y=this.rules[a];if(y.hasWhere!==g)break;let R=y.media,C=R.features["max-width"],v=R.features["min-width"];if(!C||!v||C.value-v.value!==i)break;c.unshift(this.rules[a])}n=w(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(p)for(let f=o;f<=d;f++){n=f;let m=this.rules[f],l=m.media,u=l.features["max-width"],e=l.features["min-width"];if(u){if(e)break;continue}let s=e?.value;if(s===p.value){if(!g&&m.hasWhere){n++;continue}if(b!==-1)n=w(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 c=this.rules[i],a=c.media,y=a.features["min-width"];if(!a.features["max-width"]){if(c.hasWhere!==g||y.value!==s||c.order>=B)break;n=i+1}}break}else{if(s>p.value)break;n++}}else if(h)for(let f=d;f>=o;f--){n=f;let m=this.rules[f],l=m.media,u=l.features["max-width"];if(l.features["min-width"])continue;let s=u?.value;if(!s||s>h.value){n++;break}else if(s===h.value){if(g&&!m.hasWhere)continue;if(b!==-1)n=w(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 c=f-1;c>=o;c--){let a=this.rules[c],y=a.media,R=y.features["min-width"],C=y.features["max-width"];if(!R&&(!C||C.value!==s||a.hasWhere!==g))break;i.unshift(a)}for(let c=0;c<i.length;c++){let a=i[c];if(!a.media.features["min-width"]){if(a.order>=B)break;n=f-i.length+2+c}}}break}}}if(n===void 0)if(o===-1)n=d+1;else if(b!==-1)n=o+w(this.rules.slice(o),void 0,h=>h.media.features["max-width"]||h.media.features["min-width"]);else if(g){let h=o;for(;h<this.rules.length;h++){let p=this.rules[h];if(p.priority!==-1||!p.hasWhere||p.order>=B){n=h;break}}n===void 0&&(n=h)}else for(let h=o;h<=d;h++){n=h;let p=this.rules[h],f=p.media;if(p.priority!==-1||f.features["max-width"]||f.features["min-width"])break;if(p.hasWhere)n++;else if(p.order>=B)break}}else if(b===-1){if(g)n=this.rules.findIndex(o=>!o.hasWhere||o.media||o.priority!==-1||o.order>=B),n===-1&&(n=d+1);else{let o=0;for(;o<this.rules.length;o++){let h=this.rules[o];if(h.media||!h.hasWhere&&(h.order>=B||h.priority!==-1)){n=o;break}}n===void 0&&(n=o)}!n&&Object.keys(this.keyframes).length&&n++}else n=w(this.rules,void 0,o=>o.media);if(this.rules.splice(n,0,r),this.ruleBy[k]=r,this.style){let o=this.style.sheet,h=0,p=f=>{let m=this.rules[f];if(m){if(!m.natives.length)return p(f-1);let l=m.natives[m.natives.length-1].cssRule;for(let u=0;u<o.cssRules.length;u++)if(o.cssRules[u]===l){h=u+1;break}}};p(n-1);for(let f=0;f<r.natives.length;)try{let m=r.natives[f];o.insertRule(m.text,h),m.cssRule=o.cssRules[h++],f++}catch(m){console.error(m),r.natives.splice(f,1)}}r.config.insert?.call(r)}}get text(){return this.rules.map(t=>t.text).join("")}},W=A;O(W,"root"),O(W,"config",T),O(W,"instances",[]),O(W,"refresh",t=>{for(let r of A.instances)r.refresh(t)});S&&(window.MasterCSS=W);export{W as MasterCSS};
package/dist/esm/rule.mjs CHANGED
@@ -1 +1 @@
1
- import{SORTED_SELECTORS as re}from"./constants/sorted-selectors.mjs";import{START_SYMBOL as oe}from"./constants/start-symbol.mjs";import{cssEscape as ue}from"./utils/css-escape.mjs";function ie(y){let n=typeof Buffer<"u"?Buffer:null;return!!(n&&y instanceof n||y instanceof Date||y instanceof RegExp)}function ne(y){if(typeof Buffer<"u"&&Buffer&&y instanceof Buffer){let n=Buffer.alloc(y.length);return y.copy(n),n}else{if(y instanceof Date)return new Date(y.getTime());if(y instanceof RegExp)return new RegExp(y);throw new Error("Unexpected situation")}}function se(y){let n=[];return y.forEach(function(l,S){typeof l=="object"&&l!==null?Array.isArray(l)?n[S]=se(l):ie(l)?n[S]=ne(l):n[S]=A({},l):n[S]=l}),n}function te(y,n){return n==="__proto__"?void 0:y[n]}function A(...y){let n={},l,S;return y.forEach(function(T){typeof T!="object"||T===null||Array.isArray(T)||Object.keys(T).forEach(function(j){if(S=te(n,j),l=te(T,j),l!==n)if(typeof l!="object"||l===null){n[j]=l;return}else if(Array.isArray(l)){n[j]=se(l);return}else if(ie(l)){n[j]=ne(l);return}else if(typeof S!="object"||S===null||Array.isArray(S)){n[j]=A({},l);return}else{n[j]=A(S,l);return}})}),n}var he={unit:"",order:0,separators:[","]},le=class{constructor(n,l={},S){this.className=n;this.meta=l;this.css=S;this.config=A(he,l.config);let{unit:T,order:j,colored:C,native:N,analyze:Q,transform:q,declare:$,create:F}=this.config,{scope:Y,important:fe,functions:ce}=S.config,{themeNames:Z,colorNames:H,colorThemesMap:J,selectors:W,breakpoints:K,mediaQueries:z,themeAffectedClassesBy:ae,globalValues:D}=S,X=ae[n];this.order=j,F&&F.call(this,n);let _,G,I,B,w;if(l.origin==="semantics"){let[h,f]=l.value;B=n.slice(h.length),_=f}else{let h;if(Q)[h,I]=Q.call(this,n);else if(l.origin==="match"){let s=n.indexOf(":");this.prefix=n.slice(0,s+1),this.prefix.includes("(")?(this.prefix=void 0,h=n):h=n.slice(s+1)}else l.origin==="symbol"&&(this.symbol=n[0],h=n.slice(1));w=[];let f=this,a=this.values,p=[","];this.config.separators.length&&p.push(...this.config.separators);let i="",t=0;(function s(e,c,o,r=void 0,u=[],v=[],g){let R=r===void 0,x,M=d=>d==="'"||d==='"',V=()=>x=i.length,O=()=>{if(i){let d=i,m=R?d:i.slice(x);if(i="",k="",a&&m in a&&!u.includes(m)){let b=t;t=0,s(a[m].toString(),c,void 0,r,[...u,m],v,g),t=b,R||(i=i.slice(0,x)+i)}else if(D&&m in D&&!v.includes(m)){let b=t;t=0,s(D[m].toString(),c,void 0,r,u,[...v,m],g),t=b,R||(i=i.slice(0,x)+i)}else if(R){let b=!g&&f.analyzeUnitValue(m,c);w.push({value:b?.value??m,unit:b?.unit})}else{let b=!g&&f.analyzeUnitValue(m,c);i=b?d.slice(0,x)+b.value+b.unit:d}V()}},E=M(o);V();let k="";for(;t<e.length;t++){let d=e[t];if(d===o){if(E){i+=d;let m=0;for(let b=i.length-2;i[b]==="\\";b--)m++;if(m%2)continue}else O(),i+=d;return}else if(!E&&d in oe){let m=d==="("&&k&&ce?.[k];m?.name&&(i=i.slice(0,i.length-k.length)+m.name,k=m.name),i+=d,t++;let b=oe[d];s(e,m?.unit??c,b,k||r||"",u,v,g||!!m?.transform),m?.transform&&(i=i.slice(0,x+k.length+1)+m.transform.call(f,i.slice(x+k.length+1,-1))+i.slice(-1)),R&&(M(b)?(w.push(i),i=""):O()),k=""}else if((d==="|"||d===" ")&&o!=="}"&&(!E||r==="path"))O(),R||(i+=" ",x++);else{if(!E){if(d==="."){if(isNaN(+e[t+1]))break;e[t-1]==="-"&&(i+="0")}else if(p.includes(d)){O(),R?w.push(d):(i+=d,x++);continue}else if(R&&(d==="#"&&(i||w.length&&e[t-1]!=="|"&&w[t-1]!==" ")||["!","*",">","+","~",":","[","@","_"].includes(d)))break;k+=d}i+=d}}r===void 0&&O()})(h,T),B=h.slice(t)}B[0]==="!"&&(this.important=!0,B=B.slice(1));let ee=h=>{let f=h.split(/(\\'(?:.*?)[^\\]\\')(?=[*_>~+,)])|(\[[^=]+='(?:.*?)[^\\]'\])/).map((t,s)=>s%3?t:t.replace(/_/g," ")).join(""),a=[],p="",i=0;for(let t=0;t<f.length;t++){let s=f[t];if(s==="\\"){p+=s+f[++t];continue}!i&&s===","?(a.push(p),p=""):(p+=s,i&&s===")"?i--:s==="("&&i++)}return p&&a.push(p),a};this.prefixSelectors=I?ee(I):[""];let P=B.split("@"),U=P[0];if(U){this.vendorSuffixSelectors={};let h=(t,s,e,c)=>{for(let[o,r]of s)if(o.test(t)){for(let u of r)h(t.replace(o,u),s,e,!0);return}c&&e.push(t)},f=[];""in W?h(U,W[""],f,!0):f.push(U);let a={};for(let[t,s]of Object.entries(W)){if(!t)continue;let e=[];for(let c of f)h(c,s,e,!1);e.length&&(a[t]=e)}let p=(t,s)=>{let e=s.reduce((c,o)=>(c.push(...ee(o)),c),[]);t in this.vendorSuffixSelectors?this.vendorSuffixSelectors[t].push(...e):this.vendorSuffixSelectors[t]=e},i=Object.keys(a);if(i.length)for(let t of i)p(t,a[t]);else p("",f);for(let t of Object.values(this.vendorSuffixSelectors))for(let s of t){this.hasWhere!==!1&&(this.hasWhere=s.includes(":where("));for(let e=0;e<re.length;e++)if(s.includes(re[e])){(this.priority===-1||this.priority>e)&&(this.priority=e);break}}}else this.vendorSuffixSelectors={"":[""]};for(let h=1;h<P.length;h++){let f=P[h];if(f)if(Z.includes(f))this.theme=f;else if(f==="rtl"||f==="ltr")this.direction=f;else{let a,p,i=f.indexOf("_");if(i!==-1)a=f.slice(0,i),p=f.slice(i);else{let t=f.indexOf("(");t!==-1&&(a=f.slice(0,t),p=f.slice(t))}if(!a){a="media";let t=[];this.media={token:f,features:{}};let s=f.split("&");for(let e of s)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(z&&e in z)t.push(z[e]);else{let c={token:e},o="",r="",u=0;e.startsWith("<=")?(r="<=",o="max-width"):e.startsWith(">=")||K[e]?(r=">=",o="min-width"):e.startsWith(">")?(r=">",o="min-width",u=.02):e.startsWith("<")&&(r="<",o="max-width",u=-.02);let v=r?e.replace(r,""):e,g=K[v];switch(o){case"max-width":case"min-width":g?Object.assign(c,this.analyzeUnitValue(g.toString(),"px")):Object.assign(c,this.analyzeUnitValue(v,"px")),c.unit==="px"&&(c.value+=u),this.media.features[o]=c,t.push("("+o+":"+(c.value+c.unit)+")");break}}p="",this.media.type&&(p=this.media.type),t.length&&(p+=(p?" and ":"")+t.join(" and "))}p&&(this.at[a]=(a in this.at?this.at[a]+" and ":"")+p.replace(/_/g," "))}}let L=(h,f)=>{let a,p=(s,e,c)=>{let o="";this.direction&&(o+="[dir="+this.direction+"] ");let r=this.prefixSelectors.map(g=>g+o),u=(g,R)=>r.map(x=>(g?"."+g+" ":"")+(Y?Y+" ":"")+x).reduce((x,M)=>(x.push(c.reduce((V,O)=>(V.push(M+"."+ue(R)+O),V),[]).join(",")),x),[]).join(","),v=u(e,n)+(X?Object.entries(X).filter(([g])=>this.theme||!C||!e||!g||g===e).map(([g,R])=>R.reduce((x,M)=>x+","+u(this.theme??((C||G)&&e||g),M),"")).join(""):"")+"{"+s+"}";for(let g of Object.keys(this.at).sort((R,x)=>x==="supports"?-1:1))v="@"+g+" "+this.at[g]+"{"+v+"}";return v},i=[];if(w){let s=this.theme?[this.theme,""]:[h],e,c;for(let o of w)if(typeof o=="string")i.push(o);else{let r=o.value;if(o.unit)r+=o.unit;else if(C&&J&&H){let u=!1,v=!1;r=r.replace(new RegExp(`(^|,| |\\()((?:${H.join("|")})(?:-(?:[0-9A-Za-z-]+))?)(?:\\/(\\.?[0-9]+%?))?(?=(\\)|\\}|,| |$))`,"gm"),(g,R,x,M)=>{v=!0;let V=J[x];if(V){let O;for(let E of s)if(O=V[E])break;if(O){u=!0;let E=O;if(M){let k=M.endsWith("%")?parseFloat(M)/100:+M;k=isNaN(k)?1:Math.min(Math.max(k,0),1),E+=Math.round(k*255).toString(16).toUpperCase().padStart(2,"0")}return R+E}}return g}),v&&(c=u)}c!==void 0&&!e&&(e=c),i.push(r)}if(f&&(e===void 0?h:!e))return;if(a=i.reduce((o,r,u)=>o+r+(r===","||w[u+1]===","||u===w.length-1?"":" "),""),q&&(a=q.call(this,a,this.css.config)),C&&a==="current"&&(a="currentColor"),$){let o,r;if(w.length===1){let u=w[0];typeof u=="object"&&(o=u.value,r=u.unit)}_=$.call(this,r?o:a,r||"")}else _={[N]:a}}let t={};for(let s in _){let e=(r,u)=>{let v=u+((this.important||fe)&&!u.endsWith("!important")?"!important":"");r in t?t[r].push(v):t[r]=[v]},c=s+":",o=_[s];if(typeof o=="object"){G=!0;for(let r in o)e(r,c+o[r])}else e(h,c+o.toString())}for(let s of Object.values(this.vendorSuffixSelectors))for(let e in t)this.natives.push({text:p(t[e].join(";"),e,s),theme:e})};if(this.theme)L(this.theme,!1);else if(C)for(let h of Z)L(h,!0);else L("",!1)}at={};priority=-1;natives=[];keyframeNames;config;get values(){return this.css.values[this.config.id]}get text(){return this.natives.map(n=>n.text).join("")}resolveValue(n,l){return Number.isNaN(+n)?n:n/(l==="rem"||l==="em"?this.css.config.rootSize:1)+l}analyzeUnitValue(n,l){let S=l??this.config.unit;if(S){let T="",j=n.match(/^([+-.]?\d+(\.?\d+)?)(.*)?/);if(j)if(n.includes("/")){let[C,N]=n.split("/");return{value:+C/+N*100+"%",unit:T}}else{let C=+j[1];return T=j[3]||"",T||((S==="rem"||S==="em")&&(C=C/this.css.config.rootSize),T=S||""),{value:C,unit:T}}}}};export{le as Rule};
1
+ import{SORTED_SELECTORS as re}from"./constants/sorted-selectors.mjs";import{START_SYMBOL as oe}from"./constants/start-symbol.mjs";import{cssEscape as ue}from"./utils/css-escape.mjs";function ie(y){let n=typeof Buffer<"u"?Buffer:null;return!!(n&&y instanceof n||y instanceof Date||y instanceof RegExp)}function ne(y){if(typeof Buffer<"u"&&Buffer&&y instanceof Buffer){let n=Buffer.alloc(y.length);return y.copy(n),n}else{if(y instanceof Date)return new Date(y.getTime());if(y instanceof RegExp)return new RegExp(y);throw new Error("Unexpected situation")}}function se(y){let n=[];return y.forEach(function(l,S){typeof l=="object"&&l!==null?Array.isArray(l)?n[S]=se(l):ie(l)?n[S]=ne(l):n[S]=A({},l):n[S]=l}),n}function te(y,n){return n==="__proto__"?void 0:y[n]}function A(...y){let n={},l,S;return y.forEach(function(j){typeof j!="object"||j===null||Array.isArray(j)||Object.keys(j).forEach(function(R){if(S=te(n,R),l=te(j,R),l!==n)if(typeof l!="object"||l===null){n[R]=l;return}else if(Array.isArray(l)){n[R]=se(l);return}else if(ie(l)){n[R]=ne(l);return}else if(typeof S!="object"||S===null||Array.isArray(S)){n[R]=A({},l);return}else{n[R]=A(S,l);return}})}),n}var he={unit:"",order:0,separators:[","]},le=class{constructor(n,l={},S){this.className=n;this.meta=l;this.css=S;this.config=A(he,l.config);let{unit:j,order:R,colored:C,native:N,analyze:Q,transform:q,declare:$,create:F}=this.config,{scope:Y,important:fe,functions:ce}=S.config,{themeNames:Z,colorNames:H,colorThemesMap:J,selectors:W,breakpoints:K,mediaQueries:z,themeAffectedClassesBy:ae,globalValues:D}=S,X=ae[n];F&&F.call(this,n);let _,G,I,B,w;if(l.origin==="semantics"){let[h,f]=l.value;B=n.slice(h.length),_=f}else{let h;if(Q)[h,I]=Q.call(this,n);else if(l.origin==="match"){let s=n.indexOf(":");this.prefix=n.slice(0,s+1),this.prefix.includes("(")?(this.prefix=void 0,h=n):h=n.slice(s+1)}else l.origin==="symbol"&&(this.symbol=n[0],h=n.slice(1));w=[];let f=this,a=this.values,p=[","];this.config.separators.length&&p.push(...this.config.separators);let i="",t=0;(function s(e,c,o,r=void 0,u=[],v=[],g){let k=r===void 0,x,M=d=>d==="'"||d==='"',V=()=>x=i.length,O=()=>{if(i){let d=i,m=k?d:i.slice(x);if(i="",T="",a&&m in a&&!u.includes(m)){let b=t;t=0,s(a[m].toString(),c,void 0,r,[...u,m],v,g),t=b,k||(i=i.slice(0,x)+i)}else if(D&&m in D&&!v.includes(m)){let b=t;t=0,s(D[m].toString(),c,void 0,r,u,[...v,m],g),t=b,k||(i=i.slice(0,x)+i)}else if(k){let b=!g&&f.analyzeUnitValue(m,c);w.push({value:b?.value??m,unit:b?.unit})}else{let b=!g&&f.analyzeUnitValue(m,c);i=b?d.slice(0,x)+b.value+b.unit:d}V()}},E=M(o);V();let T="";for(;t<e.length;t++){let d=e[t];if(d===o){if(E){i+=d;let m=0;for(let b=i.length-2;i[b]==="\\";b--)m++;if(m%2)continue}else O(),i+=d;return}else if(!E&&d in oe){let m=d==="("&&T&&ce?.[T];m?.name&&(i=i.slice(0,i.length-T.length)+m.name,T=m.name),i+=d,t++;let b=oe[d];s(e,m?.unit??c,b,T||r||"",u,v,g||!!m?.transform),m?.transform&&(i=i.slice(0,x+T.length+1)+m.transform.call(f,i.slice(x+T.length+1,-1))+i.slice(-1)),k&&(M(b)?(w.push(i),i=""):O()),T=""}else if((d==="|"||d===" ")&&o!=="}"&&(!E||r==="path"))O(),k||(i+=" ",x++);else{if(!E){if(d==="."){if(isNaN(+e[t+1]))break;e[t-1]==="-"&&(i+="0")}else if(p.includes(d)){O(),k?w.push(d):(i+=d,x++);continue}else if(k&&(d==="#"&&(i||w.length&&e[t-1]!=="|"&&w[t-1]!==" ")||["!","*",">","+","~",":","[","@","_"].includes(d)))break;T+=d}i+=d}}r===void 0&&O()})(h,j),B=h.slice(t)}this.order=typeof R=="function"?R.call(this,this.prefix):R,B[0]==="!"&&(this.important=!0,B=B.slice(1));let ee=h=>{let f=h.split(/(\\'(?:.*?)[^\\]\\')(?=[*_>~+,)])|(\[[^=]+='(?:.*?)[^\\]'\])/).map((t,s)=>s%3?t:t.replace(/_/g," ")).join(""),a=[],p="",i=0;for(let t=0;t<f.length;t++){let s=f[t];if(s==="\\"){p+=s+f[++t];continue}!i&&s===","?(a.push(p),p=""):(p+=s,i&&s===")"?i--:s==="("&&i++)}return p&&a.push(p),a};this.prefixSelectors=I?ee(I):[""];let P=B.split("@"),U=P[0];if(U){this.vendorSuffixSelectors={};let h=(t,s,e,c)=>{for(let[o,r]of s)if(o.test(t)){for(let u of r)h(t.replace(o,u),s,e,!0);return}c&&e.push(t)},f=[];""in W?h(U,W[""],f,!0):f.push(U);let a={};for(let[t,s]of Object.entries(W)){if(!t)continue;let e=[];for(let c of f)h(c,s,e,!1);e.length&&(a[t]=e)}let p=(t,s)=>{let e=s.reduce((c,o)=>(c.push(...ee(o)),c),[]);t in this.vendorSuffixSelectors?this.vendorSuffixSelectors[t].push(...e):this.vendorSuffixSelectors[t]=e},i=Object.keys(a);if(i.length)for(let t of i)p(t,a[t]);else p("",f);for(let t of Object.values(this.vendorSuffixSelectors))for(let s of t){this.hasWhere!==!1&&(this.hasWhere=s.includes(":where("));for(let e=0;e<re.length;e++)if(s.includes(re[e])){(this.priority===-1||this.priority>e)&&(this.priority=e);break}}}else this.vendorSuffixSelectors={"":[""]};for(let h=1;h<P.length;h++){let f=P[h];if(f)if(Z.includes(f))this.theme=f;else if(f==="rtl"||f==="ltr")this.direction=f;else{let a,p,i=f.indexOf("_");if(i!==-1)a=f.slice(0,i),p=f.slice(i);else{let t=f.indexOf("(");t!==-1&&(a=f.slice(0,t),p=f.slice(t))}if(!a){a="media";let t=[];this.media={token:f,features:{}};let s=f.split("&");for(let e of s)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(z&&e in z)t.push(z[e]);else{let c={token:e},o="",r="",u=0;e.startsWith("<=")?(r="<=",o="max-width"):e.startsWith(">=")||K[e]?(r=">=",o="min-width"):e.startsWith(">")?(r=">",o="min-width",u=.02):e.startsWith("<")&&(r="<",o="max-width",u=-.02);let v=r?e.replace(r,""):e,g=K[v];switch(o){case"max-width":case"min-width":g?Object.assign(c,this.analyzeUnitValue(g.toString(),"px")):Object.assign(c,this.analyzeUnitValue(v,"px")),c.unit==="px"&&(c.value+=u),this.media.features[o]=c,t.push("("+o+":"+(c.value+c.unit)+")");break}}p="",this.media.type&&(p=this.media.type),t.length&&(p+=(p?" and ":"")+t.join(" and "))}p&&(this.at[a]=(a in this.at?this.at[a]+" and ":"")+p.replace(/_/g," "))}}let L=(h,f)=>{let a,p=(s,e,c)=>{let o="";this.direction&&(o+="[dir="+this.direction+"] ");let r=this.prefixSelectors.map(g=>g+o),u=(g,k)=>r.map(x=>(g?"."+g+" ":"")+(Y?Y+" ":"")+x).reduce((x,M)=>(x.push(c.reduce((V,O)=>(V.push(M+"."+ue(k)+O),V),[]).join(",")),x),[]).join(","),v=u(e,n)+(X?Object.entries(X).filter(([g])=>this.theme||!C||!e||!g||g===e).map(([g,k])=>k.reduce((x,M)=>x+","+u(this.theme??((C||G)&&e||g),M),"")).join(""):"")+"{"+s+"}";for(let g of Object.keys(this.at).sort((k,x)=>x==="supports"?-1:1))v="@"+g+" "+this.at[g]+"{"+v+"}";return v},i=[];if(w){let s=this.theme?[this.theme,""]:[h],e,c;for(let o of w)if(typeof o=="string")i.push(o);else{let r=o.value;if(o.unit)r+=o.unit;else if(C&&J&&H){let u=!1,v=!1;r=r.replace(new RegExp(`(^|,| |\\()((?:${H.join("|")})(?:-(?:[0-9A-Za-z-]+))?)(?:\\/(\\.?[0-9]+%?))?(?=(\\)|\\}|,| |$))`,"gm"),(g,k,x,M)=>{v=!0;let V=J[x];if(V){let O;for(let E of s)if(O=V[E])break;if(O){u=!0;let E=O;if(M){let T=M.endsWith("%")?parseFloat(M)/100:+M;T=isNaN(T)?1:Math.min(Math.max(T,0),1),E+=Math.round(T*255).toString(16).toUpperCase().padStart(2,"0")}return k+E}}return g}),v&&(c=u)}c!==void 0&&!e&&(e=c),i.push(r)}if(f&&(e===void 0?h:!e))return;if(a=i.reduce((o,r,u)=>o+r+(r===","||w[u+1]===","||u===w.length-1?"":" "),""),q&&(a=q.call(this,a,this.css.config)),C&&a==="current"&&(a="currentColor"),$){let o,r;if(w.length===1){let u=w[0];typeof u=="object"&&(o=u.value,r=u.unit)}_=$.call(this,r?o:a,r||"")}else _={[N]:a}}let t={};for(let s in _){let e=(r,u)=>{let v=u+((this.important||fe)&&!u.endsWith("!important")?"!important":"");r in t?t[r].push(v):t[r]=[v]},c=s+":",o=_[s];if(typeof o=="object"){G=!0;for(let r in o)e(r,c+o[r])}else e(h,c+o.toString())}for(let s of Object.values(this.vendorSuffixSelectors))for(let e in t)this.natives.push({text:p(t[e].join(";"),e,s),theme:e})};if(this.theme)L(this.theme,!1);else if(C)for(let h of Z)L(h,!0);else L("",!1)}at={};priority=-1;natives=[];keyframeNames;config;get values(){return this.css.values[this.config.id]}get text(){return this.natives.map(n=>n.text).join("")}resolveValue(n,l){return Number.isNaN(+n)?n:n/(l==="rem"||l==="em"?this.css.config.rootSize:1)+l}analyzeUnitValue(n,l){let S=l??this.config.unit;if(S){let j="",R=n.match(/^([+-.]?\d+(\.?\d+)?)(.*)?/);if(R)if(n.includes("/")){let[C,N]=n.split("/");return{value:+C/+N*100+"%",unit:j}}else{let C=+R[1];return j=R[3]||"",j||((S==="rem"||S==="em")&&(C=C/this.css.config.rootSize),j=S||""),{value:C,unit:j}}}}};export{le as Rule};