@master/css-runtime 2.0.0-rc.85 → 2.0.0-rc.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.d.ts +2 -2
- package/dist/css-runtime.d.ts +0 -1
- package/dist/debuggers/class-count.d.ts +0 -1
- package/dist/debuggers/index.d.ts +0 -1
- package/dist/debuggers/lifecycle.d.ts +1 -1
- package/dist/debuggers/log.d.ts +1 -1
- package/dist/default-manifest.json +1 -1
- package/dist/generated-rule.d.ts +0 -1
- package/dist/global.min.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/layer.d.ts +0 -1
- package/dist/native-declaration.d.ts +0 -1
- package/dist/register-global.d.ts +0 -1
- package/dist/theme-layer.d.ts +0 -1
- package/dist/types/hydrate-result.d.ts +0 -1
- package/dist/utility-layer.d.ts +0 -1
- package/package.json +7 -7
package/dist/generated-rule.d.ts
CHANGED
package/dist/global.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
function e(e){if(typeof CSS<`u`)return CSS.escape(e);if(arguments.length==0)throw TypeError("`CSS.escape` requires an argument.");let t=String(e),n=t.length,r=-1,i=``,a,o=t.charCodeAt(0);if(n==1&&o==45)return`\\`+t;for(;++r<n;){if(a=t.charCodeAt(r),a==0){i+=`�`;continue}if(a>=1&&a<=31||a==127||r==0&&a>=48&&a<=57||r==1&&a>=48&&a<=57&&o==45){i+=`\\`+a.toString(16)+` `;continue}if(a>=128||a==45||a==95||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122){i+=t.charAt(r);continue}i+=`\\`+t.charAt(r)}return i}const t=`%.cm.mm.q.in.pt.pc.px.em.rem.ex.rex.cap.rcap.ch.rch.ic.ric.lh.rlh.vw.svw.lvw.dvw.vh.svh.lvh.dvh.vi.svi.lvi.dvi.vb.svb.lvb.dvb.vmin.svmin.lvmin.dvmin.vmax.svmax.lvmax.dvmax.cqw.cqh.cqi.cqb.cqmin.cqmax.deg.grad.rad.turn.s.ms.hz.khz.dpi.dpcm.dppx.x.fr.db.st`.split(`.`),n=t.join(`|`),r={Semantic:-2,Shorthand:-1,Normal:0},i={"(":`)`,"'":`'`,'"':`"`,"{":`}`},a=/^([+-]?(?:\d+(?:\.?\d+)?|\.\d+))x$/m,o=[`_`,`>`,`+`,`~`];[...t];const s=RegExp(`^([+-.]?\\d+(?:\\.?\\d+)?)(${n})?$`),c=new Set([`!`,`*`,`>`,`+`,`~`,`:`,`[`,`@`,`_`,`.`]),l=[`>=`,`<=`,`>`,`<`,`=`],u={"&":`and`,"!":`not`,not:`not`,and:`and`,or:`or`,only:`only`,",":`or`},d=[`container`,`starting-style`,`supports`,`media`,`layer`],f=[`width`,`height`,`resolution`],p={w:`width`,h:`height`};function m(e,t=``,n=1){let r=typeof e==`number`,i=t;if(r)return{unit:i,type:`number`,value:i===`rem`||i===`em`?e/n:e};let a=e.match(s);if(a){let t=parseFloat(a[1]),r=a[2]||``;return!r&&(i===`rem`||i===`em`)&&(t/=n,r=i),{token:e,value:t,unit:r||i,type:`number`}}return{token:e,value:e,type:`string`}}function h(e,t=`(`,n=`)`){let r=[],i=null,a=null;for(let o=0;o<e.length;o++){let s=e[o],c=e[o-1];if(s===`\\`){o++;continue}if((s===`"`||s===`'`)&&c!==`\\`){a===s?a=null:a||=s;continue}if(!a){if(e.startsWith(t,o))r.push({start:o}),o+=t.length-1;else if(e.startsWith(n,o)){let a=r.pop();a&&(i={start:a.start,end:o,pre:e.slice(r.length>0?r[r.length-1].start+t.length:0,a.start),body:e.slice(a.start+t.length,o),post:e.slice(o+n.length)}),o+=n.length-1}}}return i}function g(e,t,n){let r=``,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o],c=e[o-1];s===`'`&&c!==`\\`&&!a?i=!i:s===`"`&&c!==`\\`&&!i&&(a=!a),s===t&&!i&&!a?r+=n:r+=s}return r}function _(e,t){let n=[],r=``,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o],c=e[o-1];s===`'`&&!a&&c!==`\\`?i=!i:s===`"`&&!i&&c!==`\\`&&(a=!a),s===t&&!i&&!a?(n.push(r.trim()),r=``):r+=s}return r&&n.push(r.trim()),n}function v(e){return p[e]||e}function y(e){return f.includes(v(e))}function b(e){return d.includes(e)}function ee(e,t,n=!0){let r,i,a=e=>{let a=[...e.matchAll(/([a-zA-Z0-9-:%|]+|[&|!|,|>|<|=][=]?)/g)].map(e=>e[0]),o=[],s=e=>{let t=o[o.length-1];e.type===`number`&&!e.name&&(t?.type===`comparison`?(e.operator=t.value,e.raw&&t.raw&&(e.raw=t.raw+e.raw),o.pop(),t=o[o.length-1],t?.type===`string`?(e.name=v(t.value),e.raw&&t.raw&&(e.raw=t.raw+e.raw),o.pop()):e.name=`width`):(e.name=`width`,e.operator=`>=`)),o.push(e)};return a.forEach((e,c)=>{if(l.includes(e)){let t={type:`comparison`,value:e};n&&(t.raw=e),o.push(t);return}else if(e in u){let t={type:`logical`,value:u[e]};n&&(t.raw=e),o.push(t);return}let d=r===`container`?t.containerAtRules.get(e)||(t.breakpointAtRules.has(e)?void 0:t.atRules.get(e)):t.atRules.get(e);if(!r&&!i)if(i=e,b(i)){r=i;return}else r=d?d.id:y(i)?`media`:i.charAt(0).match(/[a-zA-Z-]/)?`container`:`media`;let f={type:`string`};if(n&&(f.raw=e),d){d.nodes.length===1?s({...d.nodes[0],raw:e}):d.nodes.length&&s({raw:e,children:d.nodes});return}else{let[i,o]=_(e,`:`);if(o?(f.name=v(i),f.value=o):f.value=v(i),r===`container`||r===`media`){let r=String(f.value);if(!o&&y(r)){l.includes(a[c+1])?s(f):s({type:`boolean`,name:r,...n&&{raw:e}});return}else{let{token:e,...n}=m(f.value,`rem`,t.settings.rootSize);Object.assign(f,n)}}s(f)}}),o},o=e=>{let t=[],n=h(e);if(n){if(n.pre&&t.push(...o(n.pre)),n.body)if(r===`supports`)t.push({type:`group`,children:[{type:`string`,value:g(n.body,`|`,` `)}]});else{let e=o(n.body);e.length>1?t.push({type:`group`,children:o(n.body)}):t.push(...e)}n.post&&t.push(...o(n.post))}else t.push(...a(e));return t};return{nodes:o(e),id:r||`media`}}function te(e){let t=n=>n.map(e=>{let n=``;if(`children`in e){let r=t(e.children);n=e.type===`group`?`(`+r+`)`:r}else{if(e.type===`boolean`)return n=`(${e.name})`,n;let t=e.type===`number`?String(e.value)+(e.unit||``):e.value;n=`name`in e?`operator`in e?`(${e.name}${e.operator}${t})`:`(${e.name}:${t})`:t}return n}).filter(Boolean).join(e.id===`layer`?`.`:` `),n=t(e.nodes);return`@`+e.id+(n?` `+n:``)}const ne=RegExp(`(?:[a-zA-Z0-9-]+)|([${o.join(``)}#.:,*])|(a-zA-Z0-9-)`,`g`),re=new Set([`before`,`after`,`first-letter`,`first-line`]);function x(e,t,n=!0){let r=e=>{let r=[],i=``,a=0;for(let s of e.matchAll(ne)){let c=s[0];if(a+=c.length,c===`:`||c===`.`||c===`#`){i+=c;continue}let l,u=c,d=t.selectors.get(i+c);if(d){let e=d[d.length-1];r.push(d.length===1&&e.type?{...e,raw:i+c}:{children:d,raw:i+c}),i=``;continue}if(o.includes(c)){if(l=`combinator`,c===`_`){let t=e[a];e[a-c.length-1]!==`_`&&t!==`_`&&(u=` `)}}else c===`,`?l=`separator`:c===`*`?l=`universal`:i===`:`?l=re.has(c)?`pseudo-element`:`pseudo-class`:i===`::`?l=`pseudo-element`:i===`.`?l=`class`:i===`#`&&(l=`id`);r.push({value:u,...n&&{raw:i+c},...l&&{type:l}}),i=``}return r},i=(e,t=[])=>{let a=h(e);if(a){let{pre:e,body:n,post:o}=a,s;if(n){let t=e.lastIndexOf(`:`);if(t!==-1){let n=t;for(;n>0&&e[n-1]===`:`;)n--;s=e.slice(n),e=e.slice(0,n)}}if(e&&t.push(...i(e)),n){let e=i(n);if(s){let n=r(s)[0];e.length&&(n.children=e),t.push(n)}else t.push(...e)}return o&&t.push(...i(o)),t}let o=h(e,`[`,`]`);if(o){let{pre:e,body:r,post:a}=o;return e&&t.push(...i(e)),t.push({value:r,type:`attribute`,...n&&{raw:`[${r}]`}}),a&&t.push(...i(a)),t}return r(e)};return i(e)}const ie={class:`.`,"pseudo-class":`:`,"pseudo-element":`::`,attribute:``,combinator:``,id:`#`};function ae(e,t=``){let n=e=>{if(e.type===`attribute`)return`[${e.value}]`;if(e.type===`combinator`)return e.value;let t=e.type&&ie[e.type]||``,r=e.value?t+e.value:``;if(`children`in e&&e.children?.length){let t=e.children.map(n).join(``);return e.value?r+`(${t})`:r+t}return r},r=``,i=``,a=[];if(e.flatMap(e=>!(`value`in e)&&`children`in e&&e.children?.length?e.children:e).forEach(e=>{e.value===`,`?(a.push(i),i=``):e.value===`of`&&`children`in e?r+=e.children.map(n).join(``):i+=n(e)}),i&&a.push(i),r){let e=r.charAt(r.length-1);!o.includes(e)&&e!==` `&&(r+=` `)}return a.length?a.map(e=>r+t+e).join(`,`):r+t}var S=new Intl.Collator(void 0,{numeric:!0}).compare;const oe={hover:1,focus:2,"focus-visible":2,active:3,disabled:4};function se(e=[]){let t=0;for(let n of e)`value`in n&&typeof n.value==`string`&&(t+=oe[n.value]??0),`children`in n&&Array.isArray(n.children)&&(t+=se(n.children));return t}const ce={">=":`<`,"<=":`>`,">":`<=`,"<":`>=`};function le(e){let t=new Map,n=(e,r=!1)=>{(e??[]).forEach((e,i,a)=>{let o=a[i-1];if(`operator`in e){let n=t.get(e.name)??{},i=e.operator;switch(r&&(i=ce[i]),o?.type===`logical`&&o.value===`not`&&(i=ce[i]),i){case`>`:n.min=e.value+.02;break;case`>=`:n.min=e.value;break;case`<`:n.max=e.value-.02;break;case`<=`:n.max=e.value;break}t.set(e.name,n)}`children`in e&&Array.isArray(e.children)&&n(e.children,o?.type===`logical`&&o.value===`not`)})};return n(e),t}function ue(e){let t=[],n=e=>{let n=le(e);for(let[e,r]of n.entries()){let n=r.max??2**53-1,i=r.min??0;t.push([e,i,n])}};return e.atRules?.media&&n(e.atRules.media),e.atRules?.container&&n(e.atRules.container),t.sort(([e],[t])=>S(e,t)),{features:t,selector:se(e.selectorNodes??[])}}function de(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(!n)return-1;if(!i)return 1;let[a,o,s]=n,[c,l,u]=i,d=S(a,c);if(d!==0)return d;let f=s-o,p=u-l;if(f!==p)return p-f;if(o!==l)return l-o;if(s!==u)return u-s}return 0}function fe(e){if(typeof e.sortTier==`number`)return e.sortTier;let t=e.selectorNodes?.length,n=!!e.atRules,r=!!e.mode;return n?3:r?2:+!!t}function C(e,t){let n=fe(e),r=fe(t);if(n!==r)return n-r;let i=de(e.priority.features||[],t.priority.features||[]);if(i!==0)return i;let a=e.priority.selector-t.priority.selector;if(a!==0)return a;let o=e.type-t.type;return o===0?S(e.key,t.key):o}const pe=/var\(\s*--([_a-zA-Z0-9-]+)\b/g;function w(e,t,n){let r=`var(--${e}${n?`,`+n:``})`;return t===void 0?r:me(r,t)}function me(e,t){return`color-mix(in oklab,${e} ${Number(t)*100}%,transparent)`}function he(e,t,n=16){return w(e.name)}function ge(e,t,n=16){return`calc(${w(e.name)} * -1)`}function _e(e){let t=new Set;for(let n of e.matchAll(pe))t.add(n[1]);return t}function ve(e,t){let n=``,r=``;for(let i=0;i<e.length;){let a=e[i];if(r){if(n+=a,a===`\\`){n+=e[i+1]||``,i+=2;continue}a===r&&(r=``),i++;continue}if(a===`"`||a===`'`){r=a,n+=a,i++;continue}if(e.startsWith(`var(`,i)){let r=i+4;for(;e[r]===` `;)r++;if(e.slice(r,r+2)!==`--`){n+=a,i++;continue}r+=2;let o=r;for(;/[_a-zA-Z0-9-]/.test(e[r]||``);)r++;let s=e.slice(o,r);if(!s){n+=a,i++;continue}let c=1,l=``,u=-1;for(let t=r;t<e.length;t++){let n=e[t];if(l){if(n===`\\`){t++;continue}n===l&&(l=``);continue}if(n===`"`||n===`'`){l=n;continue}if(n===`(`){c++;continue}if(n===`)`&&(c--,c===0)){u=t;break}}if(u===-1){n+=e.slice(i);break}let d=e.slice(i,u+1);n+=t(s,d)??d,i=u+1;continue}n+=a,i++}return n}function ye(e,t){if(e[t+1]===`(`){let n=t+2,r=``;for(;n<e.length&&e[n]!==`)`;n++)r+=e[n];return r?{name:r,end:n+1}:void 0}let n=t+1,r=``;for(;n<e.length;n++){let t=e[n];if(!/[a-zA-Z0-9-]/.test(t))break;r+=t}return r?{name:r,end:n}:void 0}function be(e,t){let n=t;for(;e[n]===` `;)n++;if(e[n]!==`/`)return;for(n++;e[n]===` `;)n++;let r=n;for(;n<e.length&&!/[\s,);|]/.test(e[n]);n++);let i=e.slice(r,n);return i?{alpha:Number(i),end:n}:void 0}function T(e){if(typeof e==`number`)return{value:String(e),dependencies:new Set};let t=``,n=!1,r=!1,i=new Set;for(let a=0;a<e.length;a++){let o=e[a],s=e[a-1];if(o===`'`&&s!==`\\`&&!r){n=!n,t+=o;continue}if(o===`"`&&s!==`\\`&&!n){r=!r,t+=o;continue}if(!n&&!r){if(o===`|`){t+=` `;continue}if(o===`$`){let n=ye(e,a);if(n){let r=be(e,n.end);i.add(n.name),t+=w(n.name,r?.alpha),a=(r?.end??n.end)-1;continue}}}t+=o}for(let e of _e(t))i.add(e);return{value:t,dependencies:i}}function xe(e,t){let n=new Set;for(let r in e){let i=e[r];if(i)for(let e of String(i).matchAll(pe)){let r=t.get(e[1]);r&&!r.inline&&n.add(e[1])}}return n.size?n:void 0}function Se(e,t){if(!t?.length)return e;for(let n=t.length-1;n>=0;n--){let r=t[n]?.trim();r&&(e=`${r}{${e}}`)}return e}function Ce(e){return e===`animation`||e===`animation-name`}function we(e,t,n){t.has(n)&&e.add(n)}function E(e,t){let n=new Set;if(e===void 0)return n;let r=new Set(t);if(!r.size)return n;let i=T(e).value;for(let e of i.split(/[\s,]+/))we(n,r,e);return n}function Te(e,t,n,r,i=new Set){if(!(!t||i.has(t.name))){i.add(t.name);for(let r of E(t.value,n))e.add(r);for(let r of Object.values(t.modes||{}))for(let t of E(r.value,n))e.add(t);t.dependencies?.forEach(t=>{Te(e,r?.get(t),n,r,i)})}}function Ee(e,t,n){let r=new Set;if(!Ce(e))return r;let i=new Set(n.animationNames);if(!i.size)return r;for(let e of E(t,i))r.add(e);for(let e of n.variableNames||[])Te(r,n.variables?.get(e),i,n.variables);return r}function De(e,t){let n=new Set;for(let r in e){let i=e[r];for(let e of Ee(r,i,t))n.add(e)}return n.size?n:void 0}function Oe(e){return/^:{1,2}[-_a-zA-Z][-_a-zA-Z0-9]*$/.test(e)||/^@[-_a-zA-Z][-_a-zA-Z0-9]*$/.test(e)}function ke(e,t){if(!e.startsWith(t))return!1;let n=e[t.length];return n===void 0||n===`!`||n===`*`||n===`>`||n===`+`||n===`~`||n===`:`||n===`[`||n===`@`||n===`_`||n===`.`}function Ae(e,t){if(t.type===`pattern`)for(let n of t.values){let r=t.prefix+n;if(ke(e,r))return{value:n,length:r.length}}}function je(e,t){for(let n of t.matchers){let t=Ae(e,n);if(t)return t}}function Me(e,t){for(let n of t.matchers)if(n.type===`static`&&ke(e,n.name))return{length:n.name.length}}const D=new Set([`animation`,`animation-name`]);function Ne(e){let t=e.emit;switch(t.type){case`declarations`:return t.declarations.some(e=>D.has(e));case`property`:return D.has(t.property);case`template`:return Object.keys(t.declarations).some(e=>D.has(e));case`static`:return t.rules.some(e=>Object.keys(e.declarations).some(e=>D.has(e)));default:return!1}}function Pe(e,t,n){let r=e*t/n;return String(Object.is(r,-0)?0:r).replace(/^(-?)0\./,`$1.`)+`rem`}function Fe(e,t){return!t||t===`&`?e:t.replace(/&/g,e||`&`)}function Ie(e){if(!e)return;let t={};for(let n of d){let r=e[n];r?.length&&(t[n]=[...r])}return t}function Le(e,t){let n=Ie(e)||{};return n[t.id]=[...n[t.id]||[],...t.nodes],n}function Re(e,t,n,r){let i=Ie(e.atRules);for(let e of t.atRuleNodes||[])i=Le(i,e);if(!t.atRuleNodes?.length)for(let e of t.atRules||[]){let t=ee(e,n);i=Le(i,t)}if(t.selectorNodes?.length&&!t.selector)return{...e,key:e.key+r,selectorNodes:t.selectorNodes,...i?{atRules:i}:{},...t.layer||e.layer?{layer:t.layer||e.layer}:{},valid:e.valid!==!1&&!(e.layer&&t.layer&&e.layer!==t.layer)};let a=t.layer||e.layer;return{...e,key:e.key+r,selectorTemplate:Fe(e.selectorTemplate,t.selector),...i?{atRules:i}:{},...a?{layer:a}:{},valid:e.valid!==!1&&!(e.layer&&t.layer&&e.layer!==t.layer)}}function ze(e,t){let n=0,r=``;for(let i=t;i<e.length;i++){let t=e[i];if(r){t===`\\`?i++:t===r&&(r=``);continue}if(t===`"`||t===`'`){r=t;continue}if(t===`(`&&n++,t===`)`&&(n--,n===0))return i}return-1}function Be(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?n++:a===`)`?n--:a===`,`&&n===0&&(t.push(e.slice(r,i),a),r=i+1)}return t.push(e.slice(r)),t}function Ve(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r===`(`)t++;else if(r===`)`)t--;else if(t===0&&(r===`+`||r===`-`||r===`*`||r===`/`)){let t=n-1;for(;e[t]===` `;)t--;let i=e[t];if((r===`+`||r===`-`)&&(!i||i===`(`||i===`,`||i===` `))continue;return!0}}return!1}function He(e){return Be(e).map(e=>{if(e===`,`)return e;let t=e.trim();return!t||/^(?:calc|clamp|min|max|var)\(/.test(t)||!Ve(t)?e:`${e.match(/^\s*/)[0]}calc(${t})${e.match(/\s*$/)[0]}`}).join(``)}var O=class{name;css;registeredUtility;fixedClass;native;nodes;atRules;priority;type=r.Normal;declarations;declarationRules;layer;layerName;explicitLayerName;valid=!0;animationNames;variableNames;branchIndex;branchCount=1;selectorTemplate;variantBranchKey;invalidValueSyntax=!1;constructor(e,t,n,r,i,a=0){this.name=e,this.css=t,this.registeredUtility=n,this.fixedClass=r,this.branchIndex=a,this.mode=i,this.layerName=n.layer||`utilities`;let{name:o,key:s,layer:c,atRules:l,...u}=n;Object.assign(this,u);let{id:d,type:f}=n;this.type=f;let p=``,m=Me(e,n);if(m)p=e.slice(m.length);else{let t,r=je(e,n);if(r)t=r.value,p=e.slice(r.length),this.keyToken=e.slice(0,r.length-r.value.length);else if(d.endsWith(`()`))t=e;else if(d===`group`)t=e;else{let n=e.indexOf(`:`);this.keyToken=e.slice(0,n+1),t=e.slice(n+1)}this.valueComponents=[];let i=this.parseValues(this.valueComponents,0,t,``,``,void 0,!1,Ne(n)?Array.from(this.css.animations.keys()):[]);if(this.invalidValueSyntax){this.valid=!1;return}this.valueToken=t.slice(0,i),r?i!==t.length&&(p=t.slice(i)+p):p=t.slice(i)}p[0]===`!`&&(this.important=!0,p=p.slice(1)),this.stateToken=p;let h=this.resolveStateBranches(p);this.branchCount=h.length;let g=h[a];if(!g){this.valid=!1;return}if(g.mode&&(this.mode=g.mode),g.selectorNodes?.length&&(this.selectorNodes=g.selectorNodes),g.selectorTemplate&&(this.selectorTemplate=g.selectorTemplate),g.atRules&&(this.atRules=g.atRules),g.valid===!1&&(this.valid=!1),this.variantBranchKey=g.key,this.mode&&t.settings.modeTrigger===`media`){let e={name:`prefers-color-scheme`,value:this.mode};this.atRules?.media?this.atRules.media.push(e):this.atRules={media:[e]}}this.atRules?.layer&&this.atRules.layer.length>1&&(this.valid=!1),g.layer&&(this.explicitLayerName&&this.explicitLayerName!==g.layer&&(this.valid=!1),this.layerName=g.layer,this.explicitLayerName=g.layer);let _=this.atRules?.layer?.length===1&&this.atRules.layer[0];if(_){let e=String(_.value);(e===`base`||e===`defaults`||e===`components`||e===`utilities`)&&(this.layerName=e,this.explicitLayerName=e,this.atRules.layer=void 0)}this.layer=t.getUtilityLayer(this.layerName);let v;if(this.valueComponents){if(v=this.resolveValue(this.valueComponents,``,[],!1),this.invalidValueSyntax){this.valid=!1;return}let e=this.emitDynamicDeclarationRules(v);if(e)this.declarations=e[0]?.declarations,(e.length>1||e.some(({atRules:e,selector:t})=>e?.length||t))&&(this.declarationRules=e);else{let e=this.emitDynamicDeclarations(v);this.declarations=e,e&&n.atRules?.length&&(this.declarationRules=[{declarations:e,atRules:n.atRules}])}}else{let e=n.emit.type===`static`?n.emit.rules.map(({declarations:e,atRules:t,selector:n})=>({declarations:e,atRules:t,selector:n})):[];this.declarations=e[0]?.declarations,(e.length>1||e.some(({atRules:e,selector:t})=>e?.length||t))&&(this.declarationRules=e)}let y=this.declarationRules||(this.declarations?[{declarations:this.declarations}]:[]);if(!y.some(({declarations:e})=>Object.entries(e??{}).length))this.valid=!1;else{for(let{declarations:e}of y){let t=xe(e,this.css.variables);if(t)for(let e of t)this.variableNames?this.variableNames.add(e):this.variableNames=new Set([e]);let n=De(e,{animationNames:this.css.animations.keys(),variables:this.css.variables,variableNames:t});if(n)for(let e of n)this.animationNames?this.animationNames.add(e):this.animationNames=new Set([e])}this.priority=ue(this),y.length>1&&(this.nodes=y.map(({declarations:e,atRules:t,selector:n})=>new Ue(this,e,t,n)))}}resolveVariableAlias(e){let t=this.variables?.get(e)||this.css.variables.get(e);if(t)return{name:t.name??e,variable:t};if(e[0]!==`-`)return;let n=e.slice(1),r=this.variables?.get(n)||this.css.variables.get(n);if(r?.type===`number`)return{name:r.name??n,variable:r,negative:!0}}resolveDynamicDeclarationValue(e,t){return e===null?t:Array.isArray(e)?e.map(e=>e===null?t:e).join(``):e}resolveDynamicDeclarations(e,t){let n={};for(let r in e)n[r]=this.resolveDynamicDeclarationValue(e[r],t);return n}emitDynamicDeclarationRules(e){let t=this.registeredUtility.emit;if(t.type===`static`)return t.rules.map(({declarations:t,atRules:n,selector:r})=>({declarations:this.resolveDynamicDeclarations(t,e),atRules:n,selector:r}))}emitDynamicDeclarations(e){let t=this.registeredUtility.emit;switch(t.type){case`declarations`:{let n={};for(let r of t.declarations)n[r]=e;return n}case`template`:{let n={};for(let r in t.declarations){let i=t.declarations[r];n[r]=i==null?e:Array.isArray(i)?i.map(t=>t??e).join(``):i}return n}case`group`:return this.emitGroupDeclarations(e);case`property`:return{[t.property]:e};case`static`:return}}emitGroupDeclarations(e){let t={},n=e=>{let n=e.indexOf(`:`);if(n!==-1){let r=e.slice(0,n);t[r]=e.slice(n+1).replace(/\|/g,` `)}},r=e=>{let n=e.declarations;for(let r in n){let i=String(n[r]);(`important`in e&&e.important||e.css.settings.important)&&!i.endsWith(`!important`)&&(i+=`!important`),t[r]=i}if(e.animationNames){this.animationNames||=new Set;for(let t of e.animationNames)this.animationNames.add(t)}if(e.variableNames)if(this.variableNames)for(let t of e.variableNames)this.variableNames.add(t);else this.variableNames=new Set(e.variableNames)},a=[],o=``,s=()=>{o&&=(a.push(o.replace(/ /g,`|`)),``)},c=1;(function t(n){for(;c<e.length;c++){let r=e[c];if(!n){if(r===`;`){s();continue}if(r===`}`)break}if(o+=r,n===r){if(n===`'`||n===`"`){let e=0;for(let t=o.length-2;o[t]===`\\`;t--)e++;if(e%2)continue}break}else r in i&&n!==`'`&&n!==`"`&&(c++,t(i[r]))}})(``),s();for(let e of a){let t=this.css.generate(e,this.mode);if(t.length)for(let e of t)r(e);else n(e)}return t}resolveStateBranches(e){let[t=``,...n]=e.split(`@`),r=[{key:``}];r=this.applySelectorTokenBranches(r,t);for(let e of n){if(this.css.modes.includes(e)){r=r.map(t=>({...t,mode:e,key:t.key+`@`+e}));continue}this.atToken=(this.atToken||``)+`@`+e;let t=`@${e}`,n=this.css.resolveVariant(t);if(n){r=r.flatMap(e=>n.map((n,r)=>Re(e,n,this.css,`${t}#${r}`)));continue}let i=ee(e,this.css);r=r.map(t=>({...t,key:t.key+`@`+e,atRules:Le(t.atRules,i)}))}return r.length?r:[{key:``}]}applySelectorTokenBranches(e,t){if(!t)return e;let n=[...this.css.variants.keys()].filter(e=>e.startsWith(`:`)).sort((e,t)=>t.length-e.length),r=0,i=``,a=()=>{if(!i)return;let t=ae(x(i,this.css),`&`);e=e.map(e=>({...e,key:e.key+i,selectorTemplate:Fe(e.selectorTemplate,t),selectorNodes:x(e.selectorTemplate?Fe(e.selectorTemplate,t)?.replace(/&/g,``)||``:i,this.css)})),i=``};for(;r<t.length;){if(t[r]===`(`){let e=ze(t,r);if(e!==-1){i+=t.slice(r,e+1),r=e+1;continue}}let o=n.find(e=>{if(!t.startsWith(e,r))return!1;let n=t[r+e.length];return n===void 0||n===`(`||!/[-_a-zA-Z0-9]/.test(n)});if(!o||!Oe(o)){i+=t[r++];continue}let s=this.css.resolveVariant(o);if(!s){i+=t[r++];continue}a(),r+=o.length;let c=``;if(t[r]===`(`){let e=ze(t,r);e!==-1&&(c=t.slice(r,e+1),r=e+1)}e=e.flatMap(e=>s.map((t,n)=>{let r=t.selector&&c?t.selector+c:t.selector,i=Re(e,{...t,...r?{selector:r}:{}},this.css,`${o}#${n}${c}`),a=i.selectorTemplate;return{...i,...a?{selectorNodes:x(a.replace(/&/g,``),this.css)}:{}}}))}return a(),e}get text(){return this.valid?this.nodes?this.nodes.map(({text:e})=>e).join(``):this.declarationRules?this.declarationRules.map(({declarations:e,atRules:t,selector:n})=>this.createRuleText(e,t,n)).join(``):this.createRuleText(this.declarations):``}createRuleText(e,t,n){let r=[];for(let t in e){let n=e[t],i=t+`:`+String(n);r.push(i+((this.important||this.css.settings.important)&&!i.endsWith(`!important`)?`!important`:``))}let i=this.createSelectorText(n)+`{`+r.join(`;`)+`}`;return this.atRules!==void 0&&d.forEach(e=>{let t=this.atRules?.[e];t&&(i=te({id:e,nodes:t})+`{`+i+`}`)}),Se(i,t)}get selectorText(){return this.createSelectorText()}createSelectorText(t){let n=``;if(this.css.settings.scope&&(n=this.css.settings.scope+` `+n),this.mode){let e=this.css.getModeSelector(this.mode);e&&(n=e+` `+n)}let r=n+`.`+e(this.fixedClass??this.name),i=this.selectorTemplate?r:this.selectorNodes?ae(this.selectorNodes,r):r;return this.selectorTemplate&&(i=this.selectorTemplate.replace(/&/g,i)),t?t.replace(/&/g,i):i}resolveValue=(e,t,n,r)=>{let a=``,o=e=>{this.variableNames?this.variableNames.add(e):this.variableNames=new Set([e])},s=e=>{let n=this.parseValue(e,t);return n.type===`number`?String(n.value)+(n.unit||``):n.value},c=(e,t=[])=>{let i=t.indexOf(e.name);if(i!==-1)throw Error(`Circular inline variable reference: ${[...t.slice(i),e.name].join(` -> `)}`);if(e.value===void 0)return w(e.name);let a=[...t,e.name];return ve(e.type===`number`&&typeof e.value==`number`&&!r?s(e.value):T(e.value).value,e=>{let t=this.css.variables.get(e);if(t){if(t.inline)return c(t,a);n.includes(e)||o(e)}})},l=e=>`calc(${e} * -1)`;for(let s of e)switch(s.type){case`function`:if(s.name===`$`){this.invalidValueSyntax=!0;break}!s.bypassTransform&&s.name===`calc`?a+=s.token=s.text=this.resolveMathFunction(this.stringifyValueComponents(s.children),n):!s.bypassTransform&&s.name===`clamp`?a+=s.token=s.text=this.resolveMathFunction(this.stringifyValueComponents(s.children),n,{name:`clamp`,wrapArguments:!0}):a+=s.token=s.text=s.name+s.symbol+this.resolveValue(s.children,t,n,r)+i[s.symbol];break;case`variable`:let e=this.resolveVariableAlias(s.name),u=e?.variable,d=e?.name??s.name,f=s.negative||e?.negative,p=()=>{if(!s.fallback)return;let e=[];return this.parseValues(e,0,s.fallback,t,``,void 0,r,n),this.resolveValue(e,t,n,r)},m=e=>{if(e?.type===`number`&&s.alpha===void 0){if(f)return r?l(w(e.name)):ge(e,t,this.css.settings.rootSize);if(!r)return he(e,t,this.css.settings.rootSize)}return w(d,s.alpha,p())};if(u?.inline){let e=c(u);a+=s.text=s.alpha===void 0?f?l(e):e:me(e,s.alpha)}else u?(o(d),a+=s.text=m(u)):a+=s.text=m();break;case`separator`:a+=s.text?s.text:s.text=s.value;break;case`number`:a+=s.text=s.value+(s.unit||``);break;default:a+=s.text=s.value;break}return a};stringifyValueComponents(e){let t=``;for(let n of e)switch(n.type){case`function`:t+=n.name+n.symbol+this.stringifyValueComponents(n.children)+i[n.symbol];break;case`separator`:t+=n.value;break;case`variable`:t+=n.token||`$`+n.name;break;case`number`:t+=n.token||String(n.value)+(n.unit||``);break;default:t+=n.token||n.value;break}return t}resolveMathFunction(e,t,n){let r=n?.name??`calc`,i=[],o=0,s=(t,n,r,c,l)=>{let u=i!==t,d=[],f=!1,p=!1,m=!1,h=!1,g,_=``,v=(i,s=``,c=``)=>{if(_){if(!l){let e=a.exec(_);e&&(_=Pe(+e[1],this.css.settings.baseUnit??1,this.css.settings.rootSize))}if(!f&&!r){let e={...this.parseValue(_),token:_};if(!p&&isNaN(+_)&&e.type===`number`&&(p=!0),h)isNaN(+_)?e.type===`number`?(t.push(e),m=!0):t.push(e):t.push({type:`number`,value:+_,token:_});else if(u){let e={type:`string`,value:_,token:_};d.push(e),t.push(e)}else t.push(e)}else t.push({type:`string`,value:_,token:_});_=``}i&&((i===`+`||i===`-`)&&b(),s&&e[o-1]===` `&&(s=``),c&&e[o+1]===` `&&(c=``),n?t.push({type:`separator`,value:i,text:i,token:i}):t.push({type:`separator`,value:i,text:s+i+c,token:i})),f=!1},y=()=>{t.push({type:`separator`,value:`*`,text:` * `,token:`*`},{type:`number`,value:1,unit:``,token:``})},b=()=>{h&&!m&&!c&&(!u||p)&&y(),h=!1,m=!1};for(;o<e.length;o++){let n=e[o];if(n===`(`){let e=/^([+-])/.exec(_);e&&t.push({type:`string`,value:e[1],token:e[1]});let r=e?_.slice(1):_,i={type:`function`,name:r,symbol:n,children:[],bypassTransform:r===`calc`,token:_};t.push(i),_=``,o++,r===`$`&&(this.invalidValueSyntax=!0);let a=r===`var`;g=s(i.children,a,f||a||h&&m,h,a)||r===`var`,g&&(p=!0,m=!0)}else if(n===`)`){if(v(``),p)for(let e of d)Object.assign(e,this.parseValue(e.value));return p}else if(n===`,`)v(n,``,` `);else if(n===` `)v(n);else{let t=e[o-1];switch(n){case`+`:!_&&t!==`)`?_+=n:v(n,` `,` `);break;case`-`:!_&&t!==`)`?_+=n:v(n,` `,` `);break;case`*`:v(n,` `,` `);break;case`/`:v(n,` `,` `),f=!0;break;default:_+=n;break}}}v(``),b()};s(i,!1,!1,!1,!1);let c=this.resolveValue(i,``,t,!0);return n?.wrapArguments&&(c=He(c)),r+`(`+c+`)`}parseValues=(e,t,n,r,o,s,c=!1,l=[])=>{let u=s===void 0,d=!u&&s.endsWith(`var`),f=(e=>e===`'`||e===`"`)(o),p=[`,`];this.registeredUtility.separators?.length&&p.push(...this.registeredUtility.separators);let m=``,h=()=>{if(m){let t=!1;if(!d||e.length){let n=(t,n,r=m,i)=>{let a={type:`variable`,name:t,variable:this.css.variables.get(t),token:r};n&&(a.alpha=Number(n)),i&&(a.negative=!0),e.push(a)},r=(e,r)=>{let i=this.resolveVariableAlias(e);if(i&&(!i.negative||r===void 0)){let{name:e,negative:a}=i;l.includes(e)||(t=!0,n(e,r,m,a))}};if(/^\$[a-zA-Z0-9-]+(?:\/[^\/]+)?$/.test(m)){let[e,i]=m.slice(1).split(`/`);r(e,i),!t&&!l.includes(e)&&(t=!0,n(e,i))}else if(r(m),!t){let[e,t]=m.split(`/`);r(e,t)}}if(!t){if(!d){let e=a.exec(m);e&&(m=Pe(+e[1],this.css.settings.baseUnit??1,this.css.settings.rootSize))}if(c)e.push({type:`string`,value:m,token:m});else{let t=this.parseValue(m,r);e.push({...t,token:m})}}m=``}};for(;t<n.length;t++){let a=n[t];if(a===o){if(f){let e=0;for(let t=m.length-1;m[t]===`\\`;t--)e++;if(e%2){m+=a;continue}else h()}else h();return t}else if(!f&&a in i){let o=m;if(a===`(`&&o===`$`)return this.invalidValueSyntax=!0,n.length;let l={type:`function`,name:o,symbol:a,children:[],token:``};e.push(l),m=``,t=this.parseValues(l.children,++t,n,r,i[a],o||s||``,c||o===`calc`)}else if((a===`|`||a===` `)&&o!==`}`&&(!f||s===`path`))h(),e.push({type:`separator`,value:` `,token:a});else{if(!f){if(a===`.`)if(isNaN(+n[t+1])){if(u)break}else n[t-1]===`-`&&(m+=`0`);else if(p.includes(a)){h(),e.push({type:`separator`,value:a,text:(a===`,`?``:` `)+a+(a===`,`?``:` `),token:a});continue}else if(u&&(a===`#`&&(m||e.length&&e[e.length-1].type!==`separator`)||[`!`,`*`,`>`,`+`,`~`,`:`,`[`,`@`,`_`].includes(a)))break}m+=a}}return h(),t};parseValue(e,t=``){return m(e,t,this.css.settings.rootSize)}get key(){return(this.fixedClass?this.fixedClass+` `:``)+this.name+(this.variantBranchKey?`\0`+this.variantBranchKey:``)}},Ue=class{rule;declarations;atRules;selector;native;constructor(e,t,n,r){this.rule=e,this.declarations=t,this.atRules=n,this.selector=r}get text(){return this.rule.createRuleText(this.declarations,this.atRules,this.selector)}};const We=new WeakMap;function Ge(e){let t=We.get(e);return t||(t=new Map,We.set(e,t)),t}function k(e){let t=Ge(e);if(t.size!==e.rules.length){t.clear();for(let n of e.rules)t.set(n.key,n)}return t}var A=class{name;css;rules=[];tokenCounts=new Map;constructor(e,t){this.name=e,this.css=t}attach(){this.css.rules.push(this)}detach(){this.css.rules.splice(this.css.rules.indexOf(this),1)}get(e){return k(this).get(e)}insert(e,t=this.rules.length){let n=k(this);if(!n.has(e.key))return this.rules.splice(t,0,e),n.set(e.key,e),this.css.rules.includes(this)||this.attach(),t}delete(e){let t=k(this),n=t.get(e);if(!n)return;let r=this.rules.indexOf(n);if(r!==-1)return this.rules.splice(r,1),t.delete(e),this.rules.length===0&&this.detach(),n}reset(){this.rules.length=0;let e=this.css.rules.indexOf(this);e!==-1&&this.css.rules.splice(e,1),this.tokenCounts.clear(),Ge(this).clear()}get text(){let e=this.rules.map(({text:e})=>e).join(``);return e?`@layer `+this.name+`{`+e+`}`:``}};function Ke(e){return e.replace(/\s*,\s*/g,`,`).replace(/\s+/g,` `).trim()}var qe=class extends A{name;css;rules=[];constructor(e,t){super(e,t),this.name=e,this.css=t}getBucketRank(e){if(e.mediaText)return 2;let t=e.selectorText.split(`,`).map(e=>e.trim());return t.includes(`:root`)||t.includes(`:host`)?0:1}getModeSelectorText(e,t=!1){switch(this.css.settings.modeTrigger){case`host`:return`:host(.${e})${t?`,:host`:``}`;case`class`:return`.${e}${t?`,:root`:``}`;default:return`:root`}}matchesModeSelectorText(e,t){let n=Ke(t),r=[this.getModeSelectorText(e)];return this.css.settings.defaultMode!==`none`&&this.css.settings.defaultMode===e&&r.push(this.getModeSelectorText(e,!0)),r.map(e=>Ke(e)).includes(n)}getBucketColorScheme(e){if(!(this.css.settings.modeTrigger!==`class`&&this.css.settings.modeTrigger!==`host`)&&!e.mediaText&&!(e.mode!==`light`&&e.mode!==`dark`)&&this.matchesModeSelectorText(e.mode,e.selectorText))return e.mode}getBucketSyntheticDeclarations(e){let t=this.getBucketColorScheme(e);return t?[{name:`color-scheme`,value:t}]:[]}compareBuckets(e,t){return this.getBucketRank(e)-this.getBucketRank(t)||e.order-t.order}shouldInsertBucketBefore(e,t){return this.getBucketRank(e)<this.getBucketRank(t)}getBuckets(){let e=new Map;for(let t of this.rules)for(let n of t.nodes){let t=n.mediaText+`
|
|
2
|
-
`+n.selectorText,r=e.get(t);r||(r={mediaText:n.mediaText,mode:n.mode,selectorText:n.selectorText,order:e.size,nodes:[]},e.set(t,r)),r.nodes.push(n)}return Array.from(e.values()).sort((e,t)=>this.compareBuckets(e,t))}getBucketText(e){let t=[...this.getBucketSyntheticDeclarations(e).map(({name:e,value:t})=>`${e}:${t}`),...e.nodes.map(({declarationText:e})=>e)],n=`${e.selectorText}{${t.join(`;`)}}`;return e.mediaText?`${e.mediaText}{${n}}`:n}get text(){let e=this.getBuckets().map(e=>this.getBucketText(e)).join(``);return e?`@layer `+this.name+`{`+e+`}`:``}},j=class{name;keyframes;css;native;variableNames;constructor(e,t,n){this.name=e,this.keyframes=t,this.css=n;for(let e of Object.values(t)){let t=xe(e,n.variables);if(t)for(let e of t)this.variableNames?this.variableNames.add(e):this.variableNames=new Set([e])}}get key(){return this.name}get text(){return`@keyframes ${this.name}{`+Object.entries(this.keyframes).reduce((e,[t,n])=>e+`${t}{${Object.entries(n).map(([e,t])=>`${e}:${t}`).join(`;`)}}`,``)+`}`}},M=class{name;variable;css;nodes=[];constructor(e,t,n){this.name=e,this.variable=t,this.css=n;let r=t.value!==void 0;if(r&&this.nodes.push(new Je(this,t,n)),t.modes&&this.css.settings.modeTrigger)for(let e in t.modes){let i=t.modes[e],a=new Je(this,i,n,e),o=r?!1:this.css.settings.defaultMode!==`none`&&this.css.settings.defaultMode===e;a.isDefaultMode=o,o?this.nodes.unshift(a):this.nodes.push(a)}}get key(){return this.name}get text(){return this.nodes.map(({text:e})=>e).join(``)}},Je=class{rule;variable;css;mode;native;isDefaultMode=!1;constructor(e,t,n,r){this.rule=e,this.variable=t,this.css=n,this.mode=r}get selectorText(){let e=this.isDefaultMode;if(this.mode)switch(this.css.settings.modeTrigger){case`host`:return`:host(.${this.mode})${e?`,:host`:``}`;case`class`:return`.${this.mode}${e?`,:root`:``}`;default:return`:root`}else return`:root`}get declarationName(){return`--${this.rule.name}`}get declarationValue(){let e=(t,n)=>ve(T(t).value,t=>{let r=this.css.variables.get(t);if(!r?.inline||r.value===void 0)return;let i=n.indexOf(t);if(i!==-1)throw Error(`Circular inline variable reference: ${[...n.slice(i),t].join(` -> `)}`);return e(r.value,[...n,t])});return e(this.variable.value,[this.rule.name])}get declarationText(){return`${this.declarationName}:${this.declarationValue}`}get mediaText(){return this.css.settings.modeTrigger===`media`&&this.mode?`@media (prefers-color-scheme:${this.mode})`:``}get text(){let e=`${this.selectorText}{${this.declarationText}}`;return this.css.settings.modeTrigger===`media`&&this.mode&&(e=`@media (prefers-color-scheme:${this.mode}){${e}}`),e}};function Ye(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(!(a instanceof O))return Xe(e,t);C(t,a)<0?r=i:n=i+1}return n}function Xe(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r instanceof O&&C(t,r)<0)return n}return e.length}var N=class extends A{rules=[];insert(e){if(this.get(e.key)||`valid`in e&&!e.valid)return;let t=this.rules.length;e instanceof O&&(t=Ye(this.rules,e));let n=super.insert(e,t);if(n!==void 0)return this.insertVariables(e),this.insertAnimations(e),n}delete(e){let t=super.delete(e);if(!t)return;let n=(e,t,r=new Set)=>{if(r.has(e))return;r.add(e);let i=t.tokenCounts.get(e)??0,a=t===this.css.themeLayer?this.css.variables.get(e):void 0;if(i<=1){let i=t.delete(e);return t.tokenCounts.delete(e),a?.dependencies?.forEach(e=>n(e,t,r)),i}else t.tokenCounts.set(e,i-1),a?.dependencies?.forEach(e=>n(e,t,r))};return`variableNames`in t&&t.variableNames?.forEach(e=>{n(e,this.css.themeLayer)}),`animationNames`in t&&t.animationNames?.forEach(e=>{let t=n(e,this.css.animationsNonLayer),r=t&&`variableNames`in t?t.variableNames:void 0;r&&r.forEach(e=>{n(e,this.css.themeLayer)})}),t}insertVariables(e){if(!(`variableNames`in e))return;let t=(e,n=new Set)=>{if(n.has(e))return;n.add(e);let r=this.css.variables.get(e);if(!(!r||r.inline)){if(this.css.themeLayer.rules.find(({name:t})=>t===e)||this.css.isEmittedGlobalsVariable(e)){let t=this.css.themeLayer.tokenCounts.get(e)||0;this.css.themeLayer.tokenCounts.set(e,t+1)}else{let t=new M(e,r,this.css);this.css.themeLayer.insert(t),this.css.themeLayer.tokenCounts.set(e,1)}r.dependencies?.forEach(e=>t(e,n))}};e.variableNames?.forEach(e=>t(e))}insertAnimations(e){`animationNames`in e&&e.animationNames?.forEach(e=>{if(this.css.animationsNonLayer.rules.find(({name:t})=>t===e)||this.css.isEmittedGlobalsAnimation(e)){let t=this.css.animationsNonLayer.tokenCounts.get(e)||0;this.css.animationsNonLayer.tokenCounts.set(e,t+1)}else{let t=this.css.animations.get(e);if(!t)return;let n=new j(e,t,this.css);this.css.animationsNonLayer.insert(n),this.css.animationsNonLayer.tokenCounts.set(e,1),this.insertVariables(n)}})}};function Ze(e,t){for(let n=0;n<e.length;n++)if(e[n]===t)return n;return-1}var Qe=class{css;rules=[];tokenCounts=new Map;constructor(e){this.css=e}insert(e){if(this.rules.includes(e))return;let t=this.css.style?.sheet;if(t)try{let n=t.insertRule(e.text,t.cssRules.length);e.native=t.cssRules[n]}catch(e){console.error(e)}this.rules.push(e),this.css.rules.push(e)}delete(e){let t=this.rules.find(t=>t.name===e);if(!t)return;let n=this.css.style?.sheet;if(n){let e=Ze(n.cssRules,t.native);e!==-1&&n.deleteRule(e)}return this.rules.splice(this.rules.indexOf(t),1),this.css.rules.splice(this.css.rules.indexOf(t),1),t}get text(){return this.rules.map(({text:e})=>e).join(``)}reset(){for(let e of this.rules){let t=this.css.rules.indexOf(e);t!==-1&&this.css.rules.splice(t,1)}this.rules.length=0,this.tokenCounts.clear()}};const $e=new Set(`all.animation.animation-range.background.background-position.background-repeat.border.border-block.border-block-color.border-block-end.border-block-start.border-block-style.border-block-width.border-bottom.border-color.border-image.border-inline.border-inline-color.border-inline-end.border-inline-start.border-inline-style.border-inline-width.border-left.border-radius.border-right.border-style.border-top.border-width.column-rule.columns.contain-intrinsic-size.container.flex.flex-flow.font.font-synthesis.font-variant.gap.grid.grid-area.grid-column.grid-row.grid-template.inset.inset-block.inset-inline.line-clamp.list-style.margin.margin-block.margin-inline.mask.mask-border.mask-position.mask-repeat.offset.outline.overflow.overscroll-behavior.padding.padding-block.padding-inline.place-content.place-items.place-self.scroll-margin.scroll-margin-block.scroll-margin-inline.scroll-padding.scroll-padding-block.scroll-padding-inline.scroll-timeline.text-decoration.text-emphasis.text-wrap.transition.view-timeline.white-space`.split(`.`));function et(e){return $e.has(e)}function tt(e,t){return t.name||(e?`${e}${t.key?`-`+t.key:``}`:t.key)}function nt(e){let t=[];for(let[n,r]of Object.entries(e||{}))for(let e of r){let r=e.type||(typeof e.value==`number`?`number`:`string`);t.push({...e,name:tt(n,e),...n?{namespace:n}:{},type:r})}return t}const rt=Object.freeze({fg:`color`,bg:`background`,"gap-x":`column-gap`,"gap-y":`row-gap`,"grid-col":`grid-column`,"grid-col-end":`grid-column-end`,"grid-col-start":`grid-column-start`,b:`border`,bb:`border-bottom`,bl:`border-left`,br:`border-right`,bt:`border-top`,bx:`border-inline`,by:`border-block`,h:`height`,ix:`inset-inline`,ixe:`inset-inline-end`,ixs:`inset-inline-start`,iy:`inset-block`,iye:`inset-block-end`,iys:`inset-block-start`,leading:`line-height`,m:`margin`,max:`max-size`,"max-h":`max-height`,"max-size-x":`max-inline-size`,"max-size-y":`max-block-size`,"max-w":`max-width`,mb:`margin-bottom`,min:`min-size`,"min-h":`min-height`,"min-size-x":`min-inline-size`,"min-size-y":`min-block-size`,"min-w":`min-width`,ml:`margin-left`,mr:`margin-right`,mt:`margin-top`,mx:`margin-inline`,mxe:`margin-inline-end`,mxs:`margin-inline-start`,my:`margin-block`,mye:`margin-block-end`,mys:`margin-block-start`,p:`padding`,pb:`padding-bottom`,pl:`padding-left`,pr:`padding-right`,pt:`padding-top`,px:`padding-inline`,pxe:`padding-inline-end`,pxs:`padding-inline-start`,py:`padding-block`,pye:`padding-block-end`,pys:`padding-block-start`,r:`border-radius`,rbl:`border-bottom-left-radius`,rbr:`border-bottom-right-radius`,rtl:`border-top-left-radius`,rtr:`border-top-right-radius`,"scroll-m":`scroll-margin`,"scroll-mb":`scroll-margin-bottom`,"scroll-ml":`scroll-margin-left`,"scroll-mr":`scroll-margin-right`,"scroll-mt":`scroll-margin-top`,"scroll-mx":`scroll-margin-inline`,"scroll-mxe":`scroll-margin-inline-end`,"scroll-mxs":`scroll-margin-inline-start`,"scroll-my":`scroll-margin-block`,"scroll-mye":`scroll-margin-block-end`,"scroll-mys":`scroll-margin-block-start`,"scroll-p":`scroll-padding`,"scroll-pb":`scroll-padding-bottom`,"scroll-pl":`scroll-padding-left`,"scroll-pr":`scroll-padding-right`,"scroll-pt":`scroll-padding-top`,"scroll-px":`scroll-padding-inline`,"scroll-pxe":`scroll-padding-inline-end`,"scroll-pxs":`scroll-padding-inline-start`,"scroll-py":`scroll-padding-block`,"scroll-pye":`scroll-padding-block-end`,"scroll-pys":`scroll-padding-block-start`,shadow:`box-shadow`,"size-x":`inline-size`,"size-y":`block-size`,"line-clamp":`-webkit-line-clamp`,"text-fill-color":`-webkit-text-fill-color`,"text-stroke-color":`-webkit-text-stroke-color`,"text-stroke-width":`-webkit-text-stroke-width`,tracking:`letter-spacing`,w:`width`,z:`z-index`}),it=Object.freeze([`animate`,`breakpoint`,`color`,`color-line`,`color-surface`,`color-text`,`container`,`content`,`duration`,`easing`,`font`,`font-family`,`font-feature`,`font-size`,`font-weight`,`leading`,`order`,`radius`,`shadow`,`spacing`,`tracking`]);function P(e,t=!1){return`${t?`=`:`~`}${e}`}new Set(it);function F(e){return Object.freeze(e.properties),Object.freeze(e.variableAliasRefs),Object.freeze(e)}const at=Object.freeze(`background-position.bottom.border-spacing.column-gap.gap.inset.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.left.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.mask-position.object-position.outline-offset.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.perspective.perspective-origin.right.row-gap.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.shape-margin.text-indent.text-underline-offset.top.translate.transform-origin.word-spacing`.split(`.`)),ot=Object.freeze([`cx`,`cy`,`stroke-dashoffset`,`x`,`y`]),st=Object.freeze([`background-size`,`block-size`,`contain-intrinsic-block-size`,`contain-intrinsic-inline-size`,`flex-basis`,`height`,`inline-size`,`max-block-size`,`max-height`,`max-inline-size`,`max-width`,`min-block-size`,`min-height`,`min-inline-size`,`min-width`,`mask-size`,`width`]),ct=Object.freeze([`border-bottom-left-radius`,`border-bottom-right-radius`,`border-end-end-radius`,`border-end-start-radius`,`border-radius`,`border-start-end-radius`,`border-start-start-radius`,`border-top-left-radius`,`border-top-right-radius`]),lt=Object.freeze([`border`,`border-block`,`border-block-color`,`border-block-end`,`border-block-end-color`,`border-block-start`,`border-block-start-color`,`border-bottom`,`border-bottom-color`,`border-color`,`border-inline`,`border-inline-color`,`border-inline-end`,`border-inline-end-color`,`border-inline-start`,`border-inline-start-color`,`border-left`,`border-left-color`,`border-right`,`border-right-color`,`border-top`,`border-top-color`,`outline`,`outline-color`]),ut=Object.freeze([F({properties:at,variableAliasRefs:[P(`spacing`)]}),F({properties:ot,variableAliasRefs:[P(`spacing`)]}),F({properties:st,variableAliasRefs:[P(`container`)]}),F({properties:ct,variableAliasRefs:[P(`radius`)]}),F({properties:lt,variableAliasRefs:[P(`color-line`),P(`color`)]}),F({properties:Object.freeze([`accent-color`,`background-color`,`fill`,`filter`]),variableAliasRefs:[P(`color`)]}),F({properties:Object.freeze([`caret-color`]),variableAliasRefs:[P(`color-text`),P(`color`)]}),F({properties:Object.freeze([`stroke`]),variableAliasRefs:[P(`color-line`),P(`color`)]}),F({properties:Object.freeze([`color`]),variableAliasRefs:[P(`color`,!0),P(`color-text`),P(`color`)]}),F({properties:Object.freeze([`-webkit-text-fill-color`,`text-decoration-color`]),variableAliasRefs:[P(`color-text`),P(`color`)]}),F({properties:Object.freeze([`-webkit-text-stroke-color`]),variableAliasRefs:[P(`color`)]}),F({properties:Object.freeze([`text-shadow`]),variableAliasRefs:[P(`color`)]}),F({properties:Object.freeze([`box-shadow`]),variableAliasRefs:[P(`shadow`),P(`color`)]}),F({properties:Object.freeze([`animation-delay`,`animation-duration`,`transition-delay`,`transition-duration`]),variableAliasRefs:[P(`duration`)]}),F({properties:Object.freeze([`animation-timing-function`,`transition-timing-function`]),variableAliasRefs:[P(`easing`)]}),F({properties:Object.freeze([`animation`,`transition`]),variableAliasRefs:[P(`duration`),P(`easing`)]}),F({properties:Object.freeze([`content`]),variableAliasRefs:[P(`content`,!0)]}),F({properties:Object.freeze([`font-feature-settings`]),variableAliasRefs:[P(`font-feature`,!0)]}),F({properties:Object.freeze([`font-family`]),variableAliasRefs:[P(`font-family`,!0)]}),F({properties:Object.freeze([`font-size`]),variableAliasRefs:[P(`font-size`,!0)]}),F({properties:Object.freeze([`font-weight`]),variableAliasRefs:[P(`font-weight`,!0)]}),F({properties:Object.freeze([`letter-spacing`]),variableAliasRefs:[P(`tracking`)]}),F({properties:Object.freeze([`line-height`]),variableAliasRefs:[P(`leading`)]}),F({properties:Object.freeze([`order`]),variableAliasRefs:[P(`order`,!0)]})]),dt={rootSize:16,baseUnit:4,defaultMode:`light`,modeTrigger:`media`,modes:[`light`,`dark`]},ft=new WeakMap;function pt(e){if(!e||e.version!==1)throw TypeError(`Unsupported MasterCSSManifest version. Expected version 1.`);if(Array.isArray(e.variables))throw TypeError(`Unsupported MasterCSSManifest variables format. Expected namespace-grouped variables.`);if(`utilityBuckets`in e)throw TypeError(`Unsupported MasterCSSManifest utilityBuckets field. Matcher indexes are engine-derived.`)}function mt(e,t){for(let n of t)e.includes(n)||e.push(n)}function ht(e){let t=e.keys?[...e.keys]:[],n=e.aliasGroups?[...e.aliasGroups]:[];for(let r of e.matchers)r.type===`key`?mt(t,r.keys):(r.type===`variable`||r.type===`value`)&&mt(n,r.keys);t.length&&!e.keys&&(e.keys=t),n.length&&!e.aliasGroups&&(e.aliasGroups=n),e.key||=t[0]||n[0]}function gt(e){return e.emit.type===`property`&&e.id===e.emit.property&&e.name===e.emit.property&&!e.variableAliasRefs?.length&&!e.variableAliases?.length&&!e.kind&&!e.atRules?.length}function _t(e,t){let n=e.startsWith(`-`),r=n?e.slice(1):e;if(r!==t&&!r.startsWith(t+`-`))return;let i=r===t?``:r.slice(t.length+1);return n?`-`+i:i}function I(e){for(let t=0;t<e.length;t++)if(c.has(e[t]))return!1;return!0}function vt(e,t,n){let r=e.get(t);r?r.includes(n)||r.push(n):e.set(t,[n])}function L(e,t){let n=new Map;for(let r of e)for(let e of r.matchers)if(e.type===t)for(let t of e.keys)vt(n,t,r);return n}function yt(e){let t=new Map;for(let n of e)for(let e of n.matchers)if(e.type===`pattern`)for(let r of e.values){let i=e.prefix+r;I(i)&&vt(t,i,n)}return t}function bt(e){return e.every(e=>e.matchers.every(e=>e.type!==`pattern`||e.values.every(t=>I(e.prefix+t))))}function xt(e){let t=new Map;for(let n of e)for(let e of n.matchers)e.type===`static`&&I(e.name)&&vt(t,e.name,n);return t}function St(e){return e.every(e=>e.matchers.length&&e.matchers.every(e=>e.type===`static`&&I(e.name)))}function Ct(e){return{...dt,...e.settings||{},modes:e.settings?.modes?[...e.settings.modes]:[...dt.modes]}}function wt(e){return{...e,modes:[...e.modes]}}function Tt(){let e=new Map;for(let[t,n]of Object.entries(rt))t&&n&&t!==n&&e.set(t,n);return e}function Et(e){let t=new Map;for(let n of nt(e.variables))!n.name||!n.type||n.value===!1||t.set(n.name,{name:n.name,key:n.key,type:n.type,...n.namespace?{namespace:n.namespace}:{},...n.value===void 0?{}:{value:Array.isArray(n.value)?n.value.join(`,`):n.value},...n.numeric?{numeric:{...n.numeric}}:{},...n.modes?{modes:{...n.modes}}:{},...n.dependencies?.length?{dependencies:new Set(n.dependencies)}:{},...n.inline?{inline:!0}:{},...n.static?{static:!0}:{}});return t}function Dt(e){let t=new Map;if(!e.animations)return t;for(let n in e.animations){let r={};t.set(n,r);let i=e.animations[n];for(let e in i){let t=r[e]={},n=i[e];for(let e in n)t[e]=n[e]}}return t}function R(e){let t=new Map;if(!e)return t;for(let[n,r]of Object.entries(e))t.set(n,{id:r.id,nodes:r.nodes});return t}function Ot(e){let t=new Map;if(e.selectors)for(let[n,r]of Object.entries(e.selectors))t.set(n,r);let n=new Map;for(let t of e.variants||[])n.set(t.token,t.branches.map(e=>({...e,...e.selectorNodes?.length?{selectorNodes:e.selectorNodes}:{},...e.atRules?.length?{atRules:[...e.atRules]}:{},...e.atRuleNodes?.length?{atRuleNodes:e.atRuleNodes.map(e=>({id:e.id,nodes:e.nodes}))}:{}})));return{selectors:t,variants:n}}function kt(e){let t=new Map;return n=>{let r=t.get(n);if(r)return r;let i=n[0]===`=`||n[0]===`~`?n.slice(1):``,a=[],o=new Set;if(i)for(let t of e.values()){let e=_t(t.name,i);e===void 0||o.has(e)||(o.add(e),a.push([e,t.name]))}return t.set(n,a),a}}function At(e,t,n,r=0,i=1){let a={...e,name:e.name||e.id,order:e.order??i-r-1,layer:e.layer||`utilities`,matchers:e.matchers.map(e=>({...e}))},o=[...e.variableAliases||[],...(e.variableAliasRefs||[]).flatMap(n)];if(o.length){a.variables=new Map;for(let[e,n]of o){if(a.variables.has(e))continue;let r=t.get(n);r&&a.variables.set(e,r)}}return ht(a),a}function jt(e,t){return{id:e,name:e,type:et(e)?r.Shorthand:r.Normal,order:0,variableAliasRefs:[...t.variableAliasRefs],emit:{type:`property`,property:e},matchers:[{type:`key`,keys:[e]}]}}function Mt(e,t){let n=new Map;for(let r of ut)if(!(!r.properties?.length||!r.variableAliasRefs?.length))for(let i of r.properties){if(!i||n.has(i))continue;let a=At(jt(i,r),e,t);n.set(i,a)}return n}function Nt(e,t){let n=gt(t);for(let r of t.matchers)if(!(r.type!==`key`&&r.type!==`value`&&r.type!==`variable`))for(let i of r.keys)n&&i===t.emit.property||e.add(i)}function z(e,t){e.includes(t)||e.push(t)}function Pt(e,t){for(let n of e.matchers)switch(n.type){case`variable`:(e.variableAliases?.length||e.variableAliasRefs?.length)&&z(t.variableMatcherUtilities,e);break;case`value`:e.kind&&z(t.valueMatcherUtilities,e);break;case`key`:z(t.keyMatcherUtilities,e);break;case`pattern`:z(t.patternMatcherUtilities,e);break;default:z(t.arbitraryMatcherUtilities,e);break}}function Ft(e,t,n){let r=[],i=[],a=[],o=[],s=[],c=[],l=new Set,u=e.utilities||[];for(let e=0;e<u.length;e++){let d=u[e],f=At(d,t,n,e,u.length);Nt(l,f),r.push(f),Pt(f,{variableMatcherUtilities:i,valueMatcherUtilities:a,keyMatcherUtilities:o,patternMatcherUtilities:s,arbitraryMatcherUtilities:c})}return{definedUtilities:r,variableMatcherUtilities:i,valueMatcherUtilities:a,keyMatcherUtilities:o,patternMatcherUtilities:s,arbitraryMatcherUtilities:c,variableMatcherIndex:L(i,`variable`),valueMatcherIndex:L(a,`value`),keyMatcherIndex:L(o,`key`),patternMatcherIndex:bt(s)?yt(s):void 0,arbitraryStaticMatcherIndex:St(c)?xt(c):void 0,nativeDeclarationFastPathBlockedProperties:l}}function It(e){pt(e);let t=Ct(e),n=Et(e),r=Dt(e),{selectors:i,variants:a}=Ot(e),o=kt(n),s=Mt(n,o),c=Ft(e,n,o);return{manifest:e,settings:t,definedUtilities:c.definedUtilities,variableMatcherUtilities:c.variableMatcherUtilities,valueMatcherUtilities:c.valueMatcherUtilities,keyMatcherUtilities:c.keyMatcherUtilities,patternMatcherUtilities:c.patternMatcherUtilities,arbitraryMatcherUtilities:c.arbitraryMatcherUtilities,variableMatcherIndex:c.variableMatcherIndex,valueMatcherIndex:c.valueMatcherIndex,keyMatcherIndex:c.keyMatcherIndex,patternMatcherIndex:c.patternMatcherIndex,arbitraryStaticMatcherIndex:c.arbitraryStaticMatcherIndex,selectors:i,variables:n,modes:[...t.modes],atRules:R(e.atRules),variants:a,breakpointAtRules:R(e.breakpointAtRules),containerAtRules:R(e.containerAtRules),animations:r,nativeDeclarationFastPathBlockedProperties:c.nativeDeclarationFastPathBlockedProperties,nativeValueNamespaceUtilities:s,keyAliases:Tt()}}function Lt(e){let t=ft.get(e);if(t)return t;let n=It(e);return ft.set(e,n),n}const B={id:`group`,name:`group`,type:r.Shorthand,order:0,emit:{type:`group`},matchers:[]};function V(e){return e===void 0||!/[a-zA-Z0-9-]/.test(e)}function H(e,t){for(let n of t){let t=n+`:`;if(e.startsWith(t)&&e.length>t.length)return e.slice(t.length)}}function U(e,t){if(!e.startsWith(t))return!1;let n=e[t.length];return n===void 0||n===`!`||n===`*`||n===`>`||n===`+`||n===`~`||n===`:`||n===`[`||n===`@`||n===`_`||n===`.`}function W(e){return/^-{0,2}([_a-zA-Z][-_a-zA-Z0-9]*)\(/.exec(e)?.[1]}function Rt(e){let t=W(e);return t===`calc`||t===`clamp`||t===`min`||t===`max`}function zt(e){let t=W(e);return t?t===`url`||t===`element`||t===`paint`||t===`cross-fade`||t.endsWith(`-gradient`)||t.includes(`image`):!1}function Bt(e){return!!W(e)&&!Rt(e)&&!zt(e)}function Vt(e){let t=0,n=``;for(let r=0;r<e.length;r++){let i=e[r];if(n){i===`\\`?r++:i===n&&(n=``);continue}if(i===`"`||i===`'`){n=i;continue}if(i===`(`||i===`[`||i===`{`){t++;continue}if(i===`)`||i===`]`||i===`}`){t>0&&t--;continue}if(i===`|`&&t===0)return!0}return!1}function Ht(e,t){return t.type!==`variable`&&t.type!==`value`||t.segments===`multiple`||!Vt(e)}function G(e){if(e[0]===`{`)return;let t=e.indexOf(`:`);if(!(t<=0))return e.slice(0,t)}function K(e){for(let t=0;t<e.length;t++)if(c.has(e[t]))return t?e.slice(0,t):e;return e}var Ut=class e{options;definedUtilities=[];variableMatcherUtilities=[];valueMatcherUtilities=[];keyMatcherUtilities=[];patternMatcherUtilities=[];arbitraryMatcherUtilities=[];variableMatcherIndex=new Map;valueMatcherIndex=new Map;keyMatcherIndex=new Map;patternMatcherIndex;arbitraryStaticMatcherIndex;settings;rules=[];classUtilities=new Map;animationsNonLayer=new Qe(this);baseLayer=new N(`base`,this);themeLayer=new qe(`theme`,this);defaultsLayer=new N(`defaults`,this);componentsLayer=new N(`components`,this);utilitiesLayer=new N(`utilities`,this);selectors=new Map;variables=new Map;modes=[];atRules=new Map;variants=new Map;breakpointAtRules=new Map;containerAtRules=new Map;animations=new Map;staticVariableTokens=new Set;staticAnimationTokens=new Set;emittedGlobals={variables:{},animations:{}};nativeDeclarationFastPathBlockedProperties=new Set;nativeDeclarationMatches=new Map;nativeDeclarationUtilities=new Map;nativeValueNamespaceUtilities=new Map;keyAliases=new Map;manifest;static create(e){let{manifest:t,emittedGlobals:n,...r}=e;return new this(t,n,r)}constructor(t,n,r={}){this.options=r,this.loadManifest(t),this.registerEmittedGlobals(n),new.target===e&&this.insertStaticResources()}get text(){return this.rules.sort((e,t)=>{let n=[`theme`,`base`,`defaults`,`components`,`utilities`];return(n.indexOf(e.name)===-1?1/0:n.indexOf(e.name))-(n.indexOf(t.name)===-1?1/0:n.indexOf(t.name))}).map(({text:e})=>e).join(``)}getUtilityLayer(e=`utilities`){switch(e){case`base`:return this.baseLayer;case`defaults`:return this.defaultsLayer;case`components`:return this.componentsLayer;case`utilities`:return this.utilitiesLayer;default:throw Error(`Unsupported utility layer: ${e}`)}}getUtilityLayers(){return[this.baseLayer,this.defaultsLayer,this.componentsLayer,this.utilitiesLayer]}loadManifest(e){let t=Lt(e);this.manifest=t.manifest,this.settings=wt(t.settings),this.definedUtilities=t.definedUtilities,this.variableMatcherUtilities=t.variableMatcherUtilities,this.valueMatcherUtilities=t.valueMatcherUtilities,this.keyMatcherUtilities=t.keyMatcherUtilities,this.patternMatcherUtilities=t.patternMatcherUtilities,this.arbitraryMatcherUtilities=t.arbitraryMatcherUtilities,this.variableMatcherIndex=t.variableMatcherIndex,this.valueMatcherIndex=t.valueMatcherIndex,this.keyMatcherIndex=t.keyMatcherIndex,this.patternMatcherIndex=t.patternMatcherIndex,this.arbitraryStaticMatcherIndex=t.arbitraryStaticMatcherIndex,this.selectors=t.selectors,this.variables=t.variables,this.modes=[...t.modes],this.atRules=t.atRules,this.variants=t.variants,this.breakpointAtRules=t.breakpointAtRules,this.containerAtRules=t.containerAtRules,this.animations=t.animations,this.nativeDeclarationFastPathBlockedProperties=t.nativeDeclarationFastPathBlockedProperties,this.nativeValueNamespaceUtilities=t.nativeValueNamespaceUtilities,this.keyAliases=t.keyAliases}applyEmittedGlobalsCounts(e){for(let[t,n]of Object.entries(e.variables||{}))n&&this.themeLayer.tokenCounts.set(t,(this.themeLayer.tokenCounts.get(t)||0)+n);for(let[t,n]of Object.entries(e.animations||{}))n&&this.animationsNonLayer.tokenCounts.set(t,(this.animationsNonLayer.tokenCounts.get(t)||0)+n)}registerEmittedGlobals(e){if(e){for(let[t,n]of Object.entries(e.variables||{}))n&&(this.emittedGlobals.variables[t]=(this.emittedGlobals.variables[t]||0)+n);for(let[t,n]of Object.entries(e.animations||{}))n&&(this.emittedGlobals.animations[t]=(this.emittedGlobals.animations[t]||0)+n);this.applyEmittedGlobalsCounts(e)}}isEmittedGlobalsVariable(e){return!!this.emittedGlobals.variables[e]}isEmittedGlobalsAnimation(e){return!!this.emittedGlobals.animations[e]}insertStaticVariable(e,t=new Set){if(t.has(e))return;t.add(e);let n=this.variables.get(e);if(!(!n||n.inline)){if(!this.staticVariableTokens.has(e)){if(!this.isEmittedGlobalsVariable(e)){this.themeLayer.get(e)||this.themeLayer.insert(new M(e,n,this));let t=this.themeLayer.tokenCounts.get(e)||0;this.themeLayer.tokenCounts.set(e,t+1)}this.staticVariableTokens.add(e)}n.dependencies?.forEach(e=>this.insertStaticVariable(e,t))}}insertStaticAnimation(e){if(this.staticAnimationTokens.has(e))return;let t=this.animations.get(e);if(!t)return;let n=this.animationsNonLayer.rules.find(t=>t.name===e);if(this.isEmittedGlobalsAnimation(e))n||=new j(e,t,this);else{n||(n=new j(e,t,this),this.animationsNonLayer.insert(n));let r=this.animationsNonLayer.tokenCounts.get(e)||0;this.animationsNonLayer.tokenCounts.set(e,r+1)}this.staticAnimationTokens.add(e),n.variableNames?.forEach(e=>this.insertStaticVariable(e))}insertStaticResources(){for(let[e,t]of this.variables)t.static&&this.insertStaticVariable(e);for(let e of this.animations.keys())this.manifest.animationOptions?.[e]?.static&&this.insertStaticAnimation(e);return this}resolveVariant(e){return this.variants.get(e)}parseValue(e,t=``){return m(e,t,this.settings.rootSize)}matchesMatcher(e,t,n){switch(n.type){case`static`:return U(e,n.name);case`key`:return H(e,n.keys)!==void 0;case`variable`:{let r=H(e,n.keys);if(r===void 0||!t.variables?.size||!Ht(r,n))return!1;for(let[e,n]of t.variables){if(r.startsWith(e)&&V(r[e.length]))return!0;let t=`-`+e;if(e[0]!==`-`&&n.type===`number`&&r.startsWith(t)&&V(r[t.length]))return!0}return!1}case`value`:{let r=H(e,n.keys);if(r===void 0||!Ht(r,n))return!1;switch(t.kind){case`color`:return r[0]===`#`||Bt(r)||r.startsWith(`currentColor`)&&V(r[12])||r.startsWith(`transparent`)&&V(r[11]);case`number`:return/[\d.]/.test(r[0])||Rt(r);case`image`:return zt(r);default:return!1}}case`pattern`:return n.values.some(t=>U(e,n.prefix+t))}}matchesUtility(e,t,n){return t.matchers.some(r=>(!n||r.type===n)&&this.matchesMatcher(e,t,r))}matchesExactUtilityDefinition(e,t){return t.matchers.some(t=>t.type===`static`&&U(e,t.name))}hasClassKey(e){let t=G(e);return!!(t&&!t.startsWith(`--`))}isGroupClassName(e){return e[0]===`{`&&e.includes(`}`)}getClassKeyAlias(e){let t=G(e);if(!t||t.startsWith(`--`))return;let n=this.keyAliases.get(t);if(n)return{canonicalKey:n,indexOfColon:t.length,key:t}}canonicalizeClassName(e,t){let n=this.getClassKeyAlias(e);return n?{className:n.canonicalKey+e.slice(n.indexOfColon),fixedClass:t}:{className:e,fixedClass:t}}matchResolvedClassName(e){let t=G(e);for(let n of t&&this.variableMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`variable`))return n;for(let n of t&&this.valueMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`value`))return n;for(let n of t&&this.keyMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`key`))return n;if(this.arbitraryStaticMatcherIndex){for(let t of this.arbitraryStaticMatcherIndex.get(K(e))||[])if(this.matchesUtility(e,t))return t}else for(let t of this.arbitraryMatcherUtilities)if(this.matchesUtility(e,t))return t;if(this.patternMatcherIndex){for(let t of this.patternMatcherIndex.get(K(e))||[])if(this.matchesUtility(e,t,`pattern`))return t}else for(let t of this.patternMatcherUtilities)if(this.matchesUtility(e,t,`pattern`))return t}createGroupUtility(e,t,n,r=0){if(this.isGroupClassName(e))return this.createRuleWithDefinition(e,B,t,n,r)}createAllGroupUtilities(e,t,n){let r=this.createGroupUtility(e,t,n);if(!r?.valid)return[];let i=[r];for(let a=1;a<r.branchCount;a++){let r=this.createGroupUtility(e,t,n,a);r?.valid&&i.push(r)}return i}matchRawManagedClassName(e){let t=G(e);if(t){for(let n of this.variableMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`variable`))return n;for(let n of this.valueMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`value`))return n;for(let n of this.keyMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`key`))return n;if(this.patternMatcherIndex){for(let t of this.patternMatcherIndex.get(K(e))||[])if(this.matchesUtility(e,t,`pattern`))return t}else for(let t of this.patternMatcherUtilities)if(this.matchesUtility(e,t,`pattern`))return t}}match(e){if(this.isGroupClassName(e))return B;if(this.hasClassKey(e)){let t=this.matchRawManagedClassName(e);if(t)return t}return this.matchResolvedClassName(this.canonicalizeClassName(e).className)}matchAllResolvedClassName(e){let t=G(e);for(let n of t&&this.variableMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`variable`))return[n];for(let n of t&&this.valueMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`value`))return[n];for(let n of t&&this.keyMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`key`))return[n];let n=[];if(this.arbitraryStaticMatcherIndex)for(let t of this.arbitraryStaticMatcherIndex.get(K(e))||[])this.matchesUtility(e,t)&&n.push(t);else for(let t of this.arbitraryMatcherUtilities)if(this.matchesUtility(e,t)){if(t.matchers.some(e=>e.type===`static`)){n.push(t);continue}return[t]}if(n.length)return n;if(this.patternMatcherIndex){for(let t of this.patternMatcherIndex.get(K(e))||[])if(this.matchesUtility(e,t,`pattern`))return[t]}else for(let t of this.patternMatcherUtilities)if(this.matchesUtility(e,t,`pattern`))return[t];return[]}matchAllRawManagedClassName(e){let t=G(e);if(!t)return[];for(let n of this.variableMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`variable`))return[n];for(let n of this.valueMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`value`))return[n];for(let n of this.keyMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`key`))return[n];if(this.patternMatcherIndex){for(let t of this.patternMatcherIndex.get(K(e))||[])if(this.matchesUtility(e,t,`pattern`))return[t]}else for(let t of this.patternMatcherUtilities)if(this.matchesUtility(e,t,`pattern`))return[t];return[]}matchAll(e){if(this.isGroupClassName(e))return[B];if(this.hasClassKey(e)){let t=this.matchAllRawManagedClassName(e);if(t.length)return t}return this.matchAllResolvedClassName(this.canonicalizeClassName(e).className)}parseNativeDeclarationProperty(e){let t=e.indexOf(`:`);if(t<=0)return;let n=e.slice(0,t);if(/^(?:--[-_a-zA-Z0-9]+|-?[_a-zA-Z][-_a-zA-Z0-9]*)$/.test(n))return n}getNativeDeclarationUtility(e){let t=this.nativeDeclarationUtilities.get(e);if(t)return t;let n={id:e,name:e,type:et(e)?r.Shorthand:r.Normal,order:0,emit:{type:`property`,property:e},matchers:[{type:`key`,keys:[e]}]};return this.nativeDeclarationUtilities.set(e,n),n}matchNativeDeclaration(e){if(e.property.startsWith(`--`))return!0;let t=this.options.nativeDeclarationMatcher;if(!t)return!1;let n=e.property+`\0`+e.value,r=this.nativeDeclarationMatches.get(n);if(r!==void 0)return r;let i=t(e);return this.nativeDeclarationMatches.set(n,i),i}isNativeDeclarationUtility(e){let t=Object.entries(e.declarations||{});if(t.length!==1)return!1;let[[n,r]]=t;return this.matchNativeDeclaration({property:n,value:String(r)})}shouldValidateNativeDeclarationUtility(e){return this.options.nativeDeclarationMatcher?gt(e)&&e.matchers.every(e=>e.type===`key`):!1}createNativeDeclarationFallback(e,t,n,r=e){if(!this.options.nativeDeclarationMatcher)return[];let i=this.parseNativeDeclarationProperty(e);if(!i)return[];let a=this.getNativeDeclarationUtility(i),o=this.createRuleWithDefinition(r,a,t,n);if(!o?.valid||!this.isNativeDeclarationUtility(o))return[];let s=[o];for(let e=1;e<o.branchCount;e++){let i=this.createRuleWithDefinition(r,a,t,n,e);i?.valid&&this.isNativeDeclarationUtility(i)&&s.push(i)}return s}createNativeValueNamespaceFallback(e,t,n,r=e){let i=this.parseNativeDeclarationProperty(e);if(!i)return[];let a=this.nativeValueNamespaceUtilities.get(i);if(!a)return[];let o=this.createRuleWithDefinition(r,a,t,n);if(!o?.valid||this.options.nativeDeclarationMatcher&&!this.isNativeDeclarationUtility(o))return[];let s=[o];for(let e=1;e<o.branchCount;e++){let i=this.createRuleWithDefinition(r,a,t,n,e);i?.valid&&(!this.options.nativeDeclarationMatcher||this.isNativeDeclarationUtility(i))&&s.push(i)}return s}createNativeValueNamespaceFastPath(e,t,n,r=e){let i=this.parseNativeDeclarationProperty(e);return!i||this.nativeDeclarationFastPathBlockedProperties.has(i)?[]:this.createNativeValueNamespaceFallback(e,t,n,r)}createNativeDeclarationFastPath(e,t,n,r=e){let i=this.parseNativeDeclarationProperty(e);return!i||!i.startsWith(`--`)&&this.nativeDeclarationFastPathBlockedProperties.has(i)?[]:this.createNativeDeclarationFallback(e,t,n,r)}generate(e,t){return this.createRules(e,void 0,t)}createRule(e,t,n){let r=this.createGroupUtility(e,t,n);if(r)return r;let i=e;if(this.hasClassKey(e)){let r=this.matchRawManagedClassName(e);if(r){let e=this.createRuleWithDefinition(i,r,t,n);if(e?.valid)return e}}let a=this.canonicalizeClassName(e,t);e=a.className,t=a.fixedClass;let o=this.createNativeValueNamespaceFastPath(e,t,n,i);if(o.length)return o[0];let s=this.createNativeDeclarationFastPath(e,t,n,i);if(s.length)return s[0];let c=this.matchResolvedClassName(e);if(c&&this.matchesExactUtilityDefinition(e,c)){let r=this.createNativeValueNamespaceFallback(e,t,n,i);if(r.length)return r[0];let a=this.createNativeDeclarationFallback(e,t,n,i);if(a.length)return a[0]}return c?this.createRuleWithDefinition(i,c,t,n):this.createNativeValueNamespaceFallback(e,t,n,i)[0]||this.createNativeDeclarationFallback(e,t,n,i)[0]}createRules(e,t,n){let r=this.createAllGroupUtilities(e,t,n);if(r.length)return r;let i=e;if(this.hasClassKey(e)){let r=this.matchAllRawManagedClassName(e),a=[];for(let e of r){let r=this.createRuleWithDefinition(i,e,t,n);if(r&&r.valid){a.push(r);for(let o=1;o<r.branchCount;o++){let r=this.createRuleWithDefinition(i,e,t,n,o);r?.valid&&a.push(r)}}}if(a.length)return a}let a=this.canonicalizeClassName(e,t);e=a.className,t=a.fixedClass;let o=this.createNativeValueNamespaceFastPath(e,t,n,i);if(o.length)return o;let s=this.createNativeDeclarationFastPath(e,t,n,i);if(s.length)return s;let c=this.matchAllResolvedClassName(e);if(c.length&&c.every(t=>this.matchesExactUtilityDefinition(e,t))){let r=this.createNativeValueNamespaceFallback(e,t,n,i);if(r.length)return r;let a=this.createNativeDeclarationFallback(e,t,n,i);if(a.length)return a}let l=[];for(let e of c){let r=this.createRuleWithDefinition(i,e,t,n);if(r&&r.valid){l.push(r);for(let a=1;a<r.branchCount;a++){let r=this.createRuleWithDefinition(i,e,t,n,a);r?.valid&&l.push(r)}}}if(l.length)return l;let u=this.createNativeValueNamespaceFallback(e,t,n,i);return u.length?u:this.createNativeDeclarationFallback(e,t,n,i)}createRuleWithDefinition(e,t,n,r,i=0){let a=new O(e,this,t,n,r,i);if(!(a.valid&&this.shouldValidateNativeDeclarationUtility(t)&&!this.isNativeDeclarationUtility(a))){for(let e of this.getUtilityLayers()){let n=e.get(a.key),r=n instanceof O&&n.registeredUtility===t?n:void 0;if(r)return r}return a}}createRulesFromSelectorText(e,t){let n=e.split(` `),r=/[.#\[!\*>+~:,\s]/;for(let e=0;e<n.length;e++){let i=n[e],a=this.getModeSelector(i);if(!(e===0&&i===a||(e===0||e===1)&&i===this.settings.scope)&&i.startsWith(`.`)){let e=i.slice(1),n=``,a=0;for(;a<e.length;){let t=e[a],i=e[a+1];if(t===`\\`&&i){n+=i,a+=2;continue}if(r.test(t))break;n+=t,a++}let o=this.generate(n).filter(e=>!t||e.layerName===t);if(o.length)return o}}}refresh(e=this.manifest){return this.reset(),this.loadManifest(e),this.applyEmittedGlobalsCounts(this.emittedGlobals),this.insertStaticResources(),this}reset(){return this.classUtilities.clear(),this.staticVariableTokens.clear(),this.staticAnimationTokens.clear(),this.baseLayer.reset(),this.themeLayer.reset(),this.defaultsLayer.reset(),this.componentsLayer.reset(),this.utilitiesLayer.reset(),this.animationsNonLayer.reset(),this}destroy(){return this.reset(),this}ensureClassRules(...e){for(let t of e){if(this.classUtilities.get(t))continue;let e=this.generate(t);e.length&&(e.forEach(e=>e.layer.insert(e)),this.classUtilities.set(t,e))}return this}deleteClassRules(...e){for(let t of e){let e=this.classUtilities.get(t);e&&(e.forEach(e=>e.layer.delete(e.key)),this.classUtilities.delete(t))}}getModeSelector(e){switch(this.settings.modeTrigger){case`class`:return`.`+e;case`host`:return`:host(.`+e+`)`}}};const q=`master-css`;function Wt(e){globalThis.MasterCSSRuntime||(globalThis.MasterCSSRuntime=e)}function J(e,t){for(let n=0;n<e.length;n++)if(e[n]===t)return n;return-1}function Y(e){let t=e.nodes;return Array.isArray(t)?t:void 0}var Gt=class extends A{name;cssRuntime;rules=[];tokenCounts=new Map;native=null;constructor(e,t){super(e,t),this.name=e,this.cssRuntime=t}attach(){super.attach();let e=this.cssRuntime.style?.sheet;if(e&&!this.native?.parentStyleSheet){let t=e.insertRule(this.text,e.cssRules.length);this.native=e.cssRules.item(t)}}insert(e,t=this.rules.length){let n=!!this.native?.parentStyleSheet,r=this.rules.length===0,i=super.insert(e,t);if(i===void 0||!this.native)return;let a=this.getNativeInsertIndex(i),o=!n&&r,s=(t,n)=>{if(o)return this.native.cssRules.item(n);try{let e=this.native.insertRule(t,n);return this.native.cssRules.item(e)}catch(t){console.error(t,e),this.rules.splice(i,1);return}},c=Y(e);if(c){let e=a;c.forEach(t=>{t.native=s(t.text,e),t.native&&e++})}else e.native=s(e.text,a);return i}getNativeInsertIndex(e){let t=0;for(let n=0;n<e;n++){let e=this.rules[n];t+=Y(e)?.length??1}return t}detach(){super.detach();let e=this.cssRuntime.style?.sheet;if(e&&this.native?.parentStyleSheet){let t=J(e.cssRules,this.native);t!==-1&&e.deleteRule(t)}}delete(e){let t=super.delete(e);if(!t||!this.native)return;let n=e=>{if(!e)return;let t=J(this.native.cssRules,e);if(t!==-1)try{this.native.deleteRule(t)}catch(t){console.error(t,e)}},r=Y(t);return r?r.forEach(e=>n(e.native)):n(t.native),t}reset(){super.reset();let e=this.cssRuntime.style?.sheet;if(this.native&&e){let t=J(e.cssRules,this.native);t!==-1&&e.deleteRule(t),this.native=null}}};function Kt(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(!(`priority`in a))return qt(e,t);C(t,a)<0?r=i:n=i+1}return n}function qt(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(`priority`in r&&C(t,r)<0)return n}return e.length}var X=class extends Gt{rules=[];insert(e){if(this.get(e.key)||`valid`in e&&!e.valid)return;let t=this.rules.length;`priority`in e&&(t=Kt(this.rules,e));let n=super.insert(e,t);if(n!==void 0)return this.insertVariables(e),this.insertAnimations(e),n}delete(e){let t=super.delete(e);if(!t)return;let n=(e,t,r=new Set)=>{if(r.has(e))return;r.add(e);let i=t.tokenCounts.get(e)??0,a=t===this.css.themeLayer?this.css.variables.get(e):void 0;if(i<=1){let i=t.delete(e);return t.tokenCounts.delete(e),a?.dependencies?.forEach(e=>n(e,t,r)),i}else t.tokenCounts.set(e,i-1),a?.dependencies?.forEach(e=>n(e,t,r))};return`variableNames`in t&&t.variableNames?.forEach(e=>{n(e,this.css.themeLayer)}),`animationNames`in t&&t.animationNames?.forEach(e=>{let t=n(e,this.css.animationsNonLayer),r=t&&`variableNames`in t?t.variableNames:void 0;r&&r.forEach(e=>{n(e,this.css.themeLayer)})}),t}insertVariables(e){if(!(`variableNames`in e))return;let t=(e,n=new Set)=>{if(n.has(e))return;n.add(e);let r=this.css.variables.get(e);if(!(!r||r.inline)){if(this.css.themeLayer.rules.find(({name:t})=>t===e)||this.css.isEmittedGlobalsVariable(e)){let t=this.css.themeLayer.tokenCounts.get(e)||0;this.css.themeLayer.tokenCounts.set(e,t+1)}else{let t=new M(e,r,this.css);this.css.themeLayer.insert(t),this.css.themeLayer.tokenCounts.set(e,1)}r.dependencies?.forEach(e=>t(e,n))}};e.variableNames?.forEach(e=>t(e))}insertAnimations(e){`animationNames`in e&&e.animationNames?.forEach(e=>{let t=this.css.animationsNonLayer.rules.find(({name:t})=>t===e);if(t||this.css.isEmittedGlobalsAnimation(e)){let n=this.css.animationsNonLayer.tokenCounts.get(e)||0;this.css.animationsNonLayer.tokenCounts.set(e,n+1),t&&this.insertVariables(t)}else{let t=this.css.animations.get(e);if(!t)return;let n=new j(e,t,this.css);this.css.animationsNonLayer.insert(n),this.css.animationsNonLayer.tokenCounts.set(e,1),this.insertVariables(n)}})}},Jt=class extends qe{name;cssRuntime;native=null;nativeBuckets=new Map;constructor(e,t){super(e,t),this.name=e,this.cssRuntime=t}attach(){super.attach();let e=this.cssRuntime.style?.sheet;if(e&&!this.native?.parentStyleSheet){let t=e.insertRule(this.text,e.cssRules.length);this.native=e.cssRules.item(t),this.syncNativeBuckets()}}getBucketKey(e,t){let n=e.replace(/\s*:\s*/g,`:`).replace(/\s+/g,` `).trim(),r=t.replace(/\s*,\s*/g,`,`).replace(/\s+/g,` `).trim();return n+`
|
|
3
|
-
`+r}setBucketSyntheticDeclarations(e,t){for(let{name:n,value:r}of this.getBucketSyntheticDeclarations({mediaText:e.mediaText,mode:t,selectorText:e.selectorText}))e.styleRule.style.setProperty(n,r)}hasVariableDeclarations(e){for(let t=0;t<e.style.length;t++)if(e.style.item(t).startsWith(`--`))return!0;return!1}getStyleRule(e){if(e instanceof CSSStyleRule)return e;if(e instanceof CSSGroupingRule)return e.cssRules.item(0)}syncNativeBuckets(){if(this.nativeBuckets.clear(),this.native)for(let e of this.native.cssRules){let t=this.getStyleRule(e);if(!t)continue;let n=e instanceof CSSMediaRule?e.conditionText:``,r=n?`@media ${n}`:``,i=this.getBucketKey(r,t.selectorText);this.nativeBuckets.set(i,{key:i,mediaText:r,selectorText:t.selectorText,nativeRule:e,styleRule:t})}}ensureNativeBucket(e,t,n){if(!this.native)return;let r=this.getBucketKey(e,t),i=this.nativeBuckets.get(r);if(i)return this.setBucketSyntheticDeclarations(i,n),i;let a=this.getBucketSyntheticDeclarations({mediaText:e,mode:n,selectorText:t}).map(({name:e,value:t})=>`${e}:${t}`).join(`;`),o=e?`${e}{${t}{${a}}}`:`${t}{${a}}`,s=this.native.insertRule(o,this.getNativeBucketInsertIndex(e,t)),c=this.native.cssRules.item(s);if(!c)return;let l=this.getStyleRule(c);if(!l)return;let u={key:r,mediaText:e,mode:n,selectorText:t,nativeRule:c,styleRule:l};return this.nativeBuckets.set(r,u),u}getNativeBucketInsertIndex(e,t){if(!this.native)return 0;let n={mediaText:e,selectorText:t};for(let e=0;e<this.native.cssRules.length;e++){let t=this.native.cssRules.item(e);if(!t)continue;let r=this.getStyleRule(t);if(!r)continue;let i=t instanceof CSSMediaRule?`@media ${t.conditionText}`:``;if(this.shouldInsertBucketBefore(n,{mediaText:i,selectorText:r.selectorText}))return e}return this.native.cssRules.length}insert(e,t=this.rules.length){let n=this.rules.length===0,r=super.insert(e,t);if(r===void 0||!this.native||n)return r;for(let t of e.nodes){let e=this.ensureNativeBucket(t.mediaText,t.selectorText,t.mode);e&&(this.setBucketSyntheticDeclarations(e,t.mode),e.styleRule.style.setProperty(t.declarationName,t.declarationValue),t.native=e.styleRule)}return r}delete(e){let t=this.rules.find(t=>t.key===e),n=super.delete(e);if(!t||!n||!this.native)return n;for(let e of t.nodes){let t=this.getBucketKey(e.mediaText,e.selectorText),n=this.nativeBuckets.get(t);if(n&&(n.styleRule.style.removeProperty(e.declarationName),!this.hasVariableDeclarations(n.styleRule))){let e=J(this.native.cssRules,n.nativeRule);e!==-1&&this.native.deleteRule(e),this.nativeBuckets.delete(t)}}return n}detach(){super.detach();let e=this.cssRuntime.style?.sheet;if(e&&this.native?.parentStyleSheet){let t=J(e.cssRules,this.native);t!==-1&&e.deleteRule(t)}this.native=null,this.nativeBuckets.clear()}reset(){super.reset();let e=this.cssRuntime.style?.sheet;if(this.native&&e){let t=J(e.cssRules,this.native);t!==-1&&e.deleteRule(t)}this.native=null,this.nativeBuckets.clear()}};function Z(e,t,n){let r=(e.get(t)||0)+n;r?e.set(t,r):e.delete(t)}function Yt(e,t,n){let r=[e];for(;r.length;){let e=r.pop();if(!t.has(e)){t.add(e),n(e);for(let t=e.lastElementChild;t;t=t.previousElementSibling)r.push(t)}}}var Xt=class{snapshots=new WeakMap;reset(){this.snapshots=new WeakMap}collectConnected(e,t){this.reset();let n=new Set;for(let r of e.querySelectorAll(`[class]`)){let e=this.snapshotElement(r);if(e)for(let r of e){let e=t.get(r)||0;e||n.add(r),t.set(r,e+1)}}return n}collectMutations(e){let t=new Map,n=new Map,r=new Set,i=new WeakSet,a=(e,t)=>{let r=(n.get(e)||0)+t;r?n.set(e,r):n.delete(e)};for(let t of e)if(t.type===`childList`){for(let e of t.addedNodes)e instanceof Element&&e.isConnected&&a(e,1);for(let e of t.removedNodes)e instanceof Element&&!e.isConnected&&a(e,-1)}else if(t.type===`attributes`&&t.attributeName===`class`){let e=t.target;e instanceof Element&&r.add(e)}for(let[e,r]of n)r>0?Yt(e,i,e=>this.diffElement(e,t)):r<0&&!e.isConnected&&Yt(e,i,e=>this.removeElement(e,t));for(let e of r)i.has(e)||this.diffElement(e,t);return t}snapshotElement(e){let t=e.classList;if(!t.length){this.snapshots.delete(e);return}let n=new Set;for(let e=0;e<t.length;e++)n.add(t.item(e));return this.snapshots.set(e,n),n}diffElement(e,t){let n=this.snapshots.get(e),r=e.classList,i;for(let e=0;e<r.length;e++){let a=r.item(e);n?.has(a)||Z(t,a,1),(i??=new Set).add(a)}if(n)for(let e of n)i?.has(e)||Z(t,e,-1);i?this.snapshots.set(e,i):this.snapshots.delete(e)}removeElement(e,t){let n=this.snapshots.get(e);if(n){for(let e of n)Z(t,e,-1);this.snapshots.delete(e)}}};function Zt(e){let t=new Set;for(let n of e.matchAll(/var\(\s*--([_a-zA-Z0-9-]+)/g))t.add(n[1]);return t}var Qt=class{text;native;constructor(e){this.text=e}},$t=class{ir;layer;native;name;key;layerName;type;sortTier;priority;text;valid=!0;fixedClass;nodes;variableNames;animationNames;selectorText;constructor(e,t){this.ir=e,this.layer=t,this.name=e.className,this.key=e.key,this.layerName=e.layer,this.type=e.type,this.sortTier=e.sortTier,this.priority=e.priority,this.text=e.text,this.selectorText=e.selectorText,e.nodes?.length&&(this.nodes=e.nodes.map(e=>new Qt(e.text)));let n=Zt(e.text);e.nodes?.forEach(e=>{Zt(e.text).forEach(e=>n.add(e))}),e.variableNames?.forEach(e=>n.add(e)),n.size&&(this.variableNames=n),e.animationNames?.length&&(this.animationNames=new Set(e.animationNames))}};const en=new Map,tn=({property:e,value:t})=>{if(e.startsWith(`--`))return!0;let n=e+`\0`+t,r=en.get(n);if(r!==void 0)return r;let i=!!globalThis.CSS?.supports(e,t);return en.set(n,i),i},Q=`style#${q}`;function $(e){let t=e?.constructor.name;return t===`HTMLDocument`||t===`Document`}function nn(e,t){return $(e)?e.getElementById(t):`querySelector`in e?e.querySelector(`#${t}`):void 0}function rn(e){return e?.version===1&&Array.isArray(e?.rules)?e:void 0}function an(e){try{return rn(JSON.parse(e))}catch{}}function on(e){let t=nn(e,`master-css-hydration-manifest`)?.textContent?.trim();if(t)return an(t)}function sn(e){let t=nn(e,q),n=globalThis.HTMLStyleElement;return n&&t instanceof n?t.getAttribute(`data-master-css-hydration-manifest`):void 0}function cn(e,t){let n=$(e)?e:e.ownerDocument;return new URL(t,n.baseURI).href}async function ln(e){return rn((await globalThis.Function(`specifier`,`return import(specifier, { with: { type: 'json' } })`)(e)).default)}var un=class e extends Ut{root;hydrationManifest;static instances=new WeakMap;host;container;baseLayer=new X(`base`,this);themeLayer=new Jt(`theme`,this);defaultsLayer=new X(`defaults`,this);componentsLayer=new X(`components`,this);utilitiesLayer=new X(`utilities`,this);classCounts=new Map;retainedClassNames=new Set;classTracker=new Xt;pendingAddedClassNames=new Set;pendingRemovedClassNames=new Set;retainedClassRules=new Map;pendingAdditionFrame;pendingRemovalFrame;pendingRemovalFlushFrame;retainedCleanupIdleHandle;retainedCleanupTimeoutHandle;hydrationFailureReason;observer;progressive=!1;observing=!1;static create(t){let{manifest:n,root:r=document,emittedGlobals:i,hydrationManifest:a}=t,o=a===void 0?on(r):a,s=globalThis.MasterCSSRuntime.instances.get(r);return s?(s.registerEmittedGlobals(i),o!==void 0&&s.setHydrationManifest(o),s):new e(r,n,i,o).register()}constructor(e=document,t,n,r){super(t,n,{nativeDeclarationMatcher:tn}),this.root=e,this.hydrationManifest=r,$(e)?(this.container=e.head,this.host=e.documentElement):(this.container=this.root,this.host=this.root.host),this.applyEmittedGlobalsCounts({variables:this.emittedGlobals.variables})}register(){return globalThis.MasterCSSRuntime.instances.get(this.root),globalThis.MasterCSSRuntime.instances.set(this.root,this),$(this.root)&&(this.root.defaultView.globalThis.masterCSSRuntime=this),this}unregister(){return globalThis.MasterCSSRuntime.instances.delete(this.root),$(this.root)&&this.root.defaultView.globalThis.masterCSSRuntime===this&&(this.root.defaultView.globalThis.masterCSSRuntime=void 0),this}setHydrationManifest(e){return this.hydrationManifest=e,this}needsHydrationManifest(){return this.hydrationManifest===void 0&&!!sn(this.root)}async loadHydrationManifest(){let e=on(this.root);if(e)return this.setHydrationManifest(e),this;let t=sn(this.root);if(!t)return this;try{this.setHydrationManifest(await ln(cn(this.root,t)))}catch{}return this}createRuntimeStyle(){let e=`createElement`in this.root?this.root:this.root.ownerDocument;this.style=e.createElement(`style`),this.style.id=q,this.style.setAttribute(`blocking`,`render`),this.container.append(this.style)}warnHydrationFallback(e){console.warn(`Master CSS progressive hydration requires a matching hydration manifest. ${e} Rebuilding ${Q} with the runtime.`)}useRuntimeStyle(e,t){t&&this.warnHydrationFallback(t),this.style?.remove(),this.style=null,this.progressive=!1,this.createRuntimeStyle(),this.insertStaticResources(),e.forEach(e=>this.ensureClassRules(e))}detectRuntimeStyle(){if(this.root.styleSheets)for(let e of this.root.styleSheets){let{ownerNode:t}=e;if(t instanceof HTMLStyleElement&&t.id===`master-css`){this.style=t,this.progressive=!0;break}}}collectConnectedClasses(){return this.classTracker.collectConnected(this.root,this.classCounts)}hydrateRuntimeStyle(e){let t=this.style?.sheet&&this.hydrate(this.style.sheet.cssRules);if(t){let n=new Set(t.allUtilities.map(({fixedClass:e,name:t})=>e||t));for(let t of e)n.has(t)||this.ensureClassRules(t)}else this.useRuntimeStyle(e,this.hydrationFailureReason||`Cannot read ${Q} CSS rules.`)}renderRuntimeStyle(e){this.createRuntimeStyle(),this.insertStaticResources(),e.forEach(e=>this.ensureClassRules(e))}getAnimationFrameWindow(){return($(this.root)?this.root:this.root.ownerDocument)?.defaultView||globalThis}cancelPendingRemovalFrames(){let e=this.getAnimationFrameWindow();this.pendingRemovalFrame!==void 0&&(e.cancelAnimationFrame(this.pendingRemovalFrame),this.pendingRemovalFrame=void 0),this.pendingRemovalFlushFrame!==void 0&&(e.cancelAnimationFrame(this.pendingRemovalFlushFrame),this.pendingRemovalFlushFrame=void 0)}cancelPendingAdditionFrame(){this.pendingAdditionFrame!==void 0&&(this.getAnimationFrameWindow().cancelAnimationFrame(this.pendingAdditionFrame),this.pendingAdditionFrame=void 0)}clearPendingAddedClassNames(){this.pendingAddedClassNames.clear(),this.cancelPendingAdditionFrame()}clearPendingRemovedClassNames(){this.pendingRemovedClassNames.clear(),this.cancelPendingRemovalFrames()}getCleanupWindow(){return this.getAnimationFrameWindow()}cancelRetainedClassRuleCleanup(){let e=this.getCleanupWindow();this.retainedCleanupIdleHandle!==void 0&&(e.cancelIdleCallback?.(this.retainedCleanupIdleHandle),this.retainedCleanupIdleHandle=void 0),this.retainedCleanupTimeoutHandle!==void 0&&(e.clearTimeout(this.retainedCleanupTimeoutHandle),this.retainedCleanupTimeoutHandle=void 0)}clearRetainedClassRules(){this.retainedClassNames.clear(),this.retainedClassRules.clear(),this.cancelRetainedClassRuleCleanup()}cancelPendingRemovedClassNames(e){if(this.pendingRemovedClassNames.size){for(let t of e)this.pendingRemovedClassNames.delete(t);this.pendingRemovedClassNames.size||this.cancelPendingRemovalFrames()}}cancelPendingAddedClassNames(e){if(this.pendingAddedClassNames.size){for(let t of e)this.pendingAddedClassNames.delete(t);this.pendingAddedClassNames.size||this.cancelPendingAdditionFrame()}}cancelRetainedClassNames(e){if(this.retainedClassNames.size){for(let t of e)this.retainedClassNames.delete(t),this.retainedClassRules.delete(t);this.retainedClassNames.size||this.cancelRetainedClassRuleCleanup()}}schedulePendingRemovalFlush(){if(!this.pendingRemovedClassNames.size||this.pendingRemovalFrame!==void 0||this.pendingRemovalFlushFrame!==void 0)return;let e=this.getAnimationFrameWindow();this.pendingRemovalFrame=e.requestAnimationFrame(()=>{this.pendingRemovalFrame=void 0,this.pendingRemovalFlushFrame=e.requestAnimationFrame(()=>{this.pendingRemovalFlushFrame=void 0,this.flushPendingRemovedClassNames()})})}queueRemovedClassNames(e){for(let t of e)this.classCounts.has(t)||this.pendingRemovedClassNames.add(t);this.schedulePendingRemovalFlush()}schedulePendingAdditionFlush(){if(!this.pendingAddedClassNames.size||this.pendingAdditionFrame!==void 0)return;let e=this.getAnimationFrameWindow();this.pendingAdditionFrame=e.requestAnimationFrame(()=>{this.pendingAdditionFrame=void 0,this.flushPendingAddedClassNames()})}queueAddedClassNames(e){for(let t of e)this.classCounts.has(t)&&this.pendingAddedClassNames.add(t);this.schedulePendingAdditionFlush()}estimateRetainedClassRule(e){let t=this.classUtilities.get(e);if(!t?.length)return;let n=0,r=0;for(let e of t){let t=e.nodes;if(t?.length)for(let e of t)n+=e.text.length,r++;else n+=e.text.length,r++}return{retainedAt:Date.now(),rawBytes:n,ruleCount:r}}getRetainedClassRuleRawBytes(){let e=0;for(let t of this.retainedClassRules.values())e+=t.rawBytes;return e}exceedsRetainedClassRuleHardLimits(){return this.retainedClassNames.size>512||this.getRetainedClassRuleRawBytes()>262144}scheduleRetainedClassRuleCleanup(){if(!this.retainedClassNames.size||this.retainedCleanupIdleHandle!==void 0||this.retainedCleanupTimeoutHandle!==void 0)return;let e=this.getCleanupWindow(),t=this.exceedsRetainedClassRuleHardLimits(),n=()=>{this.retainedCleanupIdleHandle=void 0,this.retainedCleanupTimeoutHandle=void 0,this.cleanupRetainedClassRules()},r=t?0:5e3;e.requestIdleCallback?this.retainedCleanupIdleHandle=e.requestIdleCallback(n,{timeout:r}):this.retainedCleanupTimeoutHandle=e.setTimeout(n,r)}retainRemovedClassRules(e){for(let t of e){if(this.classCounts.has(t))continue;let e=this.retainedClassRules.get(t)||this.estimateRetainedClassRule(t);e&&(this.retainedClassNames.add(t),this.retainedClassRules.set(t,e))}this.scheduleRetainedClassRuleCleanup()}getRetainedClassRuleCleanupCandidates(e=!1){let t=Date.now(),n=this.exceedsRetainedClassRuleHardLimits(),r=[];for(let i of this.retainedClassNames){if(this.classCounts.has(i)){this.retainedClassNames.delete(i),this.retainedClassRules.delete(i);continue}let a=this.retainedClassRules.get(i);if(!a){this.retainedClassNames.delete(i);continue}let o=t-a.retainedAt>=1e3;(e||n||o&&this.retainedClassNames.size>128)&&r.push([i,a])}r.sort(([,e],[,t])=>e.retainedAt-t.retainedAt);let i=n?Math.max(64,this.retainedClassNames.size-128):64;return r.slice(0,e?r.length:i).map(([e])=>e)}removeRetainedClassRules(e){let t=[];for(let n of e)this.retainedClassNames.has(n)&&(this.retainedClassNames.delete(n),this.retainedClassRules.delete(n),this.classCounts.has(n)||t.push(n));return t.length&&super.deleteClassRules(...t),t.length}cleanupRetainedClassRules(e=!1){let t=this.removeRetainedClassRules(this.getRetainedClassRuleCleanupCandidates(e));return this.retainedClassNames.size&&(e||this.retainedClassNames.size>128||this.exceedsRetainedClassRuleHardLimits())&&this.scheduleRetainedClassRuleCleanup(),t}flushRetainedClassRules(){this.cancelRetainedClassRuleCleanup();let e=this.cleanupRetainedClassRules(!0);return this.retainedClassNames.size&&this.scheduleRetainedClassRuleCleanup(),e}flushPendingRemovedClassNames(){if(!this.pendingRemovedClassNames.size)return;let e=[];for(let t of this.pendingRemovedClassNames)this.classCounts.has(t)||e.push(t);this.pendingRemovedClassNames.clear(),e.length&&this.retainRemovedClassRules(e)}flushPendingAddedClassNames(){if(!this.pendingAddedClassNames.size)return;let e=[];for(let t of this.pendingAddedClassNames)this.classCounts.has(t)&&e.push(t);this.pendingAddedClassNames.clear(),e.length&&this.ensureClassRules(...e)}handleMutationRecords(e){let t=this.classTracker.collectMutations(e),n=[],r=[],i=[];for(let[e,a]of t){let t=this.classCounts.get(e)||0,o=t+a;o>0?(this.classCounts.set(e,o),t===0&&(this.classUtilities.has(e)||this.retainedClassNames.has(e)?n.push(e):r.push(e))):(this.classCounts.delete(e),i.push(e))}n.length&&this.ensureClassRules(...n),r.length&&this.queueAddedClassNames(r),i.length&&(this.cancelPendingAddedClassNames(i),this.queueRemovedClassNames(i))}ensureClassRules(...e){return this.cancelPendingAddedClassNames(e),this.cancelPendingRemovedClassNames(e),this.cancelRetainedClassNames(e),super.ensureClassRules(...e)}deleteClassRules(...e){this.cancelPendingAddedClassNames(e),this.cancelPendingRemovedClassNames(e),this.cancelRetainedClassNames(e),super.deleteClassRules(...e)}startMutationObserver(){this.observer=new MutationObserver(e=>this.handleMutationRecords(e)),this.observer.observe(this.root,{childList:!0,attributes:!0,attributeFilter:[`class`],subtree:!0})}revealHostIfNeeded(){this.progressive||this.host.removeAttribute(`hidden`)}observe(){if(this.observing)return this;this.detectRuntimeStyle();let e=this.collectConnectedClasses();return this.progressive?this.hydrateRuntimeStyle(e):this.renderRuntimeStyle(e),this.startMutationObserver(),this.revealHostIfNeeded(),this.observing=!0,this}failHydration(e){this.hydrationFailureReason=e}getHydrationManifestLayerRules(){let e=new Map;if(!this.hydrationManifest?.rules?.length)return e;for(let t of this.hydrationManifest.rules){let n=e.get(t.layer);n?n.push(t):e.set(t.layer,[t])}return e}registerHydratedClassRule(e,t){let n=this.classUtilities,r=n.get(e);r?r.push(t):n.set(e,[t])}getUtilityLayerByName(e){switch(e){case`base`:return this.baseLayer;case`defaults`:return this.defaultsLayer;case`components`:return this.componentsLayer;case`utilities`:return this.utilitiesLayer}}collectHydrationManifestVariableNames(){let e=new Set,t=e=>{for(let t of e.matchAll(/var\(\s*--([_a-zA-Z0-9-]+)/g))n(t[1])},n=(t,r=new Set)=>{if(r.has(t))return;r.add(t);let i=this.variables.get(t);i&&(e.add(t),i.dependencies?.forEach(e=>n(e,r)))};for(let e of this.hydrationManifest?.rules||[])e.variableNames?.forEach(e=>n(e)),t(e.text),e.nodes?.forEach(e=>t(e.text)),e.animationNames?.forEach(e=>{let t=this.animations.get(e);t&&new j(e,t,this).variableNames?.forEach(e=>n(e))});for(let[e,t]of this.variables)t.static&&n(e);return e}collectHydrationManifestAnimationNames(){let e=new Set;for(let t of this.hydrationManifest?.rules||[])t.animationNames?.forEach(t=>e.add(t));for(let t of this.animations.keys())this.manifest.animationOptions?.[t]?.static&&e.add(t);return e}nativeThemeLayerHasOnlyEmittedGlobalsVariables(e){if(!e)return!1;let t=!1;for(let n of e.cssRules){let e=this.themeLayer.getStyleRule(n);if(!e)return!1;for(let r=0;r<e.style.length;r++){let i=e.style.item(r);if(!this.isSyntheticColorSchemeDeclaration(n,e,i)&&(!i.startsWith(`--`)||(t=!0,!this.isEmittedGlobalsVariable(i.slice(2)))))return!1}}return t}getVariableRuleBuckets(e){let t=new Map;for(let n of e)for(let e of n.nodes){let n=this.themeLayer.getBucketKey(e.mediaText,e.selectorText),r=t.get(n);r||(r={mediaText:e.mediaText,mode:e.mode,selectorText:e.selectorText,nodes:[]},t.set(n,r)),r.nodes.push(e)}return Array.from(t.values())}isSyntheticColorSchemeDeclaration(e,t,n){if(n!==`color-scheme`)return!1;let r=t.style.getPropertyValue(n).trim();return r===this.themeLayer.getBucketColorScheme({mediaText:e instanceof CSSMediaRule?`@media ${e.conditionText}`:``,mode:r,selectorText:t.selectorText})}getNativeThemeRuleBucketKey(e){let t=this.themeLayer.getStyleRule(e);if(!t)return;let n=e instanceof CSSMediaRule?`@media ${e.conditionText}`:``;return{key:this.themeLayer.getBucketKey(n,t.selectorText),styleRule:t}}hydrateHydrationManifestVariables(e){let t=[...this.collectHydrationManifestVariableNames()].filter(e=>!this.isEmittedGlobalsVariable(e)).map(e=>{let t=this.variables.get(e);return t&&!t.inline?new M(e,t,this):void 0}).filter(e=>!!e),n=this.getVariableRuleBuckets(t),r=e?.cssRules.length||0;if(n.length!==r)return!t.length&&this.nativeThemeLayerHasOnlyEmittedGlobalsVariables(e);if(!t.length)return!0;if(!e)return!1;this.themeLayer.native=e;let i=new Map;for(let t of e.cssRules){let e=this.getNativeThemeRuleBucketKey(t);if(!e||i.has(e.key))return!1;i.set(e.key,e.styleRule)}for(let e of n){let t=i.get(this.themeLayer.getBucketKey(e.mediaText,e.selectorText));if(!t)return!1;for(let n of e.nodes)n.native=t}return this.themeLayer.rules.push(...t),this.themeLayer.syncNativeBuckets(),this.themeLayer.rules.length&&!this.rules.includes(this.themeLayer)&&this.rules.push(this.themeLayer),!0}hydrateHydrationManifestAnimations(e){let t=this.collectHydrationManifestAnimationNames(),n=new Set;for(let r of t){if(this.isEmittedGlobalsAnimation(r)){e.has(r)&&n.add(r);continue}let t=this.animations.get(r);if(!t)continue;let i=e.get(r);if(!i)return!1;let a=new j(r,t,this);a.native=i,this.animationsNonLayer.rules.push(a),this.rules.push(a),n.add(r)}for(let t of e.keys())if(!n.has(t))return!1;return!0}hydrateHydrationManifestLayer(e,t,n,r){if(n.reduce((e,t)=>e+(t.nodes?.length||1),0)!==t.cssRules.length)return!1;e.native=t;let i=0;for(let a of n){let n=new $t(a,e),o=n.nodes;if(o?.length)for(let e of o)e.native=t.cssRules.item(i++)||void 0;else n.native=t.cssRules.item(i++)||void 0;e.rules.push(n),e.insertVariables(n),e.insertAnimations(n),this.registerHydratedClassRule(a.className,n),r.allUtilities.push(n)}return e.rules.length&&!this.rules.includes(e)&&this.rules.push(e),!0}hydrate(e){if(this.hydrationFailureReason=void 0,this.hydrationManifest?.version!==1||!Array.isArray(this.hydrationManifest.rules))return this.failHydration(`Missing or invalid hydration manifest.`);if(!this.hydrationManifest.rules.length)return this.failHydration(`Hydration manifest has no generated rules for ${Q}.`);let t={allUtilities:[]},n=this.getHydrationManifestLayerRules(),r=new Map,i=new Map,a;for(let t=0;t<e.length;t++){let n=e[t];if(n.constructor.name===`CSSLayerBlockRule`){let e=n;if(e.name===`theme`){if(a)return this.failHydration(`Duplicate theme layer in ${Q}.`);a=e;continue}let t=this.getUtilityLayerByName(e.name);if(!t)return this.failHydration(`Unknown layer \`${e.name}\` in ${Q}.`);if(r.has(t.name))return this.failHydration(`Duplicate layer \`${e.name}\` in ${Q}.`);r.set(t.name,e)}else if(n.constructor.name===`CSSKeyframesRule`){let e=n;i.set(e.name,e)}else return this.failHydration(`Unknown top-level rule \`${n.cssText}\` in ${Q}.`)}for(let[e,t]of n){let n=r.get(e);if(!n)return this.failHydration(`Missing layer \`${e}\` in ${Q}.`);if(t.reduce((e,t)=>e+(t.nodes?.length||1),0)!==n.cssRules.length)return this.failHydration(`Layer \`${e}\` does not match the hydration manifest.`)}for(let[e,t]of r)if(!n.has(e)&&t.cssRules.length)return this.failHydration(`Layer \`${e}\` has no hydration manifest rules.`);if(!this.hydrateHydrationManifestVariables(a))return this.failHydration(`Theme layer does not match the hydration manifest.`);if(!this.hydrateHydrationManifestAnimations(i))return this.failHydration(`Keyframes do not match the hydration manifest.`);for(let[e,i]of r){let r=n.get(e);if(!r?.length)continue;let a=this.getUtilityLayerByName(e);this.hydrateHydrationManifestLayer(a,i,r,t)}return t}disconnect(){if(this.clearPendingAddedClassNames(),this.clearPendingRemovedClassNames(),this.clearRetainedClassRules(),this.observing)return this.observer&&=(this.observer.disconnect(),void 0),this.observing=!1,this.reset(),this.loadManifest(this.manifest),this.classCounts.clear(),this.classTracker.reset(),this.progressive||(this.style?.remove(),this.style=null),this}refresh(e=this.manifest){if(this.clearPendingAddedClassNames(),this.clearPendingRemovedClassNames(),this.clearRetainedClassRules(),!this.observing||!this.style.sheet)return this;let t=this.style.sheet.cssRules;for(let e=t.length-1;e>=0;e--)this.style.sheet.deleteRule(e);return super.refresh(e),this.classCounts.forEach((e,t)=>{this.ensureClassRules(t)}),this}destroy(){return this.disconnect(),this.unregister(),this}};(function(e){Wt(e)})(un);function dn(e){let t=new URL(e);return t.search=``,t.hash=``,t.pathname.endsWith(`/`)?t.pathname+=`default-manifest.json`:t.pathname.endsWith(`.js`)?t.pathname=t.pathname.replace(/\/[^/]*$/,`/default-manifest.json`):t.pathname+=`/default-manifest.json`,t}async function fn(e){let t=dn(e);try{return(await import(t.href,{with:{type:`json`}})).default}catch(e){throw Error(`Cannot load Master CSS default manifest from ${t.href}.`,{cause:e})}}const pn=document.currentScript;pn?.src?fn(pn.src).then(e=>{let t=un.create({manifest:e});if(t.needsHydrationManifest())return t.loadHydrationManifest().then(()=>t.observe());t.observe()}).catch(e=>console.error(e)):console.error(`Cannot resolve the Master CSS runtime script URL.`);
|
|
1
|
+
const e=`%.cm.mm.q.in.pt.pc.px.em.rem.ex.rex.cap.rcap.ch.rch.ic.ric.lh.rlh.vw.svw.lvw.dvw.vh.svh.lvh.dvh.vi.svi.lvi.dvi.vb.svb.lvb.dvb.vmin.svmin.lvmin.dvmin.vmax.svmax.lvmax.dvmax.cqw.cqh.cqi.cqb.cqmin.cqmax.deg.grad.rad.turn.s.ms.hz.khz.dpi.dpcm.dppx.x.fr.db.st`.split(`.`),t=e.join(`|`);function n(e){if(typeof CSS<`u`)return CSS.escape(e);if(arguments.length==0)throw TypeError("`CSS.escape` requires an argument.");let t=String(e),n=t.length,r=-1,i=``,a,o=t.charCodeAt(0);if(n==1&&o==45)return`\\`+t;for(;++r<n;){if(a=t.charCodeAt(r),a==0){i+=`�`;continue}if(a>=1&&a<=31||a==127||r==0&&a>=48&&a<=57||r==1&&a>=48&&a<=57&&o==45){i+=`\\`+a.toString(16)+` `;continue}if(a>=128||a==45||a==95||a>=48&&a<=57||a>=65&&a<=90||a>=97&&a<=122){i+=t.charAt(r);continue}i+=`\\`+t.charAt(r)}return i}function r(e){return!!(e&&/[-_a-zA-Z0-9]/.test(e))}function i(e,t,n,r=e.length){for(let i=t+1;i<r;i++){if(e[i]===`\\`){i++;continue}if(e[i]===n)return i}return Math.max(t,r-1)}function a(e,t,n=e.length){let r=e.indexOf(`*/`,t+2);return r===-1||r+2>n?n:r+2}function o(e,t,n=e.length){let r=1;for(let o=t+1;o<n;o++){let t=e[o];if(t===`"`||t===`'`){o=i(e,o,t,n);continue}if(t===`/`&&e[o+1]===`*`){o=a(e,o,n)-1;continue}if(t===`(`){r++;continue}if(t===`)`&&(r--,r===0))return o+1}}function s(e,t,n,i=e.length){if(r(e[t-1])||e.slice(t,t+n.length).toLowerCase()!==n)return;let a=t+n.length;if(e[a]!==`(`)return;let s=o(e,a,i);if(!s)throw Error(`Invalid ${n}() function: missing closing ")"`);return{body:e.slice(a+1,s-1),end:s,text:e.slice(t,s)}}function c(e){let t=new Set;for(let n=0;n<e.length;){let r=e[n];if(r===`"`||r===`'`){n=i(e,n,r)+1;continue}if(r===`/`&&e[n+1]===`*`){n=a(e,n);continue}if(s(e,n,`var`)){let r=n+4;for(;e[r]===` `;)r++;if(e.slice(r,r+2)===`--`){r+=2;let n=r;for(;/[_a-zA-Z0-9-]/.test(e[r]||``);)r++;let i=e.slice(n,r);i&&t.add(i)}}n++}return t}function l(e,t){let n=``,r=``;for(let i=0;i<e.length;){let o=e[i];if(r){if(n+=o,o===`\\`){n+=e[i+1]||``,i+=2;continue}o===r&&(r=``),i++;continue}if(o===`/`&&e[i+1]===`*`){let t=a(e,i);n+=e.slice(i,t),i=t;continue}if(o===`"`||o===`'`){r=o,n+=o,i++;continue}if(e.slice(i,i+4).toLowerCase()===`var(`){let r=i+4;for(;e[r]===` `;)r++;if(e.slice(r,r+2)!==`--`){n+=o,i++;continue}r+=2;let s=r;for(;/[_a-zA-Z0-9-]/.test(e[r]||``);)r++;let c=e.slice(s,r);if(!c){n+=o,i++;continue}let l=1,u=``,d=-1;for(let t=r;t<e.length;t++){let n=e[t];if(u){if(n===`\\`){t++;continue}n===u&&(u=``);continue}if(n===`"`||n===`'`){u=n;continue}if(n===`/`&&e[t+1]===`*`){t=a(e,t)-1;continue}if(n===`(`){l++;continue}if(n===`)`&&(l--,l===0)){d=t;break}}if(d===-1){n+=e.slice(i);break}let f=e.slice(i,d+1);n+=t(c,f)??f,i=d+1;continue}n+=o,i++}return n}const u={Semantic:-2,Shorthand:-1,Normal:0},d={"(":`)`,"'":`'`,'"':`"`,"{":`}`},f=/^([+-]?(?:\d+(?:\.?\d+)?|\.\d+))x$/m,p=[`_`,`>`,`+`,`~`];[...e];const m=RegExp(`^([+-.]?\\d+(?:\\.?\\d+)?)(${t})?$`),h=new Set([`!`,`*`,`>`,`+`,`~`,`:`,`[`,`@`,`_`,`.`]),g=[`>=`,`<=`,`>`,`<`,`=`],_={"&":`and`,"!":`not`,not:`not`,and:`and`,or:`or`,only:`only`,",":`or`},v=[`container`,`starting-style`,`supports`,`media`,`layer`],y=[`width`,`height`,`resolution`],b={w:`width`,h:`height`};function ee(e,t=``,n=1){let r=typeof e==`number`,i=t;if(r)return{unit:i,type:`number`,value:i===`rem`||i===`em`?e/n:e};let a=e.match(m);if(a){let t=parseFloat(a[1]),r=a[2]||``;return!r&&(i===`rem`||i===`em`)&&(t/=n,r=i),{token:e,value:t,unit:r||i,type:`number`}}return{token:e,value:e,type:`string`}}function te(e,t=`(`,n=`)`){let r=[],i=null,a=null;for(let o=0;o<e.length;o++){let s=e[o],c=e[o-1];if(s===`\\`){o++;continue}if((s===`"`||s===`'`)&&c!==`\\`){a===s?a=null:a||=s;continue}if(!a){if(e.startsWith(t,o))r.push({start:o}),o+=t.length-1;else if(e.startsWith(n,o)){let a=r.pop();a&&(i={start:a.start,end:o,pre:e.slice(r.length>0?r[r.length-1].start+t.length:0,a.start),body:e.slice(a.start+t.length,o),post:e.slice(o+n.length)}),o+=n.length-1}}}return i}function ne(e,t,n){let r=``,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o],c=e[o-1];s===`'`&&c!==`\\`&&!a?i=!i:s===`"`&&c!==`\\`&&!i&&(a=!a),s===t&&!i&&!a?r+=n:r+=s}return r}function re(e,t){let n=[],r=``,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o],c=e[o-1];s===`'`&&!a&&c!==`\\`?i=!i:s===`"`&&!i&&c!==`\\`&&(a=!a),s===t&&!i&&!a?(n.push(r.trim()),r=``):r+=s}return r&&n.push(r.trim()),n}function x(e){return b[e]||e}function ie(e){return y.includes(x(e))}function ae(e){return v.includes(e)}function oe(e,t,n=!0){let r,i,a=e=>{let a=[...e.matchAll(/([a-zA-Z0-9-:%|]+|[&|!|,|>|<|=][=]?)/g)].map(e=>e[0]),o=[],s=e=>{let t=o[o.length-1];e.type===`number`&&!e.name&&(t?.type===`comparison`?(e.operator=t.value,e.raw&&t.raw&&(e.raw=t.raw+e.raw),o.pop(),t=o[o.length-1],t?.type===`string`?(e.name=x(t.value),e.raw&&t.raw&&(e.raw=t.raw+e.raw),o.pop()):e.name=`width`):(e.name=`width`,e.operator=`>=`)),o.push(e)};return a.forEach((e,c)=>{if(g.includes(e)){let t={type:`comparison`,value:e};n&&(t.raw=e),o.push(t);return}else if(e in _){let t={type:`logical`,value:_[e]};n&&(t.raw=e),o.push(t);return}let l=r===`container`?t.containerConditions.get(e)||(t.breakpointConditions.has(e)?void 0:t.conditions.get(e)):t.conditions.get(e);if(!r&&!i)if(i=e,ae(i)){r=i;return}else r=l?l.id:ie(i)?`media`:i.charAt(0).match(/[a-zA-Z-]/)?`container`:`media`;let u={type:`string`};if(n&&(u.raw=e),l){l.nodes.length===1?s({...l.nodes[0],raw:e}):l.nodes.length&&s({raw:e,children:l.nodes});return}else{let[i,o]=re(e,`:`);if(o?(u.name=x(i),u.value=o):u.value=x(i),r===`container`||r===`media`){let r=String(u.value);if(!o&&ie(r)){g.includes(a[c+1])?s(u):s({type:`boolean`,name:r,...n&&{raw:e}});return}else{let{token:e,...n}=ee(u.value,`rem`,t.settings.rootSize);Object.assign(u,n)}}s(u)}}),o},o=e=>{let t=[],n=te(e);if(n){if(n.pre&&t.push(...o(n.pre)),n.body)if(r===`supports`)t.push({type:`group`,children:[{type:`string`,value:ne(n.body,`|`,` `)}]});else{let e=o(n.body);e.length>1?t.push({type:`group`,children:o(n.body)}):t.push(...e)}n.post&&t.push(...o(n.post))}else t.push(...a(e));return t};return{nodes:o(e),id:r||`media`}}function se(e){let t=n=>n.map(e=>{let n=``;if(`children`in e){let r=t(e.children);n=e.type===`group`?`(`+r+`)`:r}else{if(e.type===`boolean`)return n=`(${e.name})`,n;let t=e.type===`number`?String(e.value)+(e.unit||``):e.value;n=`name`in e?`operator`in e?`(${e.name}${e.operator}${t})`:`(${e.name}:${t})`:t}return n}).filter(Boolean).join(e.id===`layer`?`.`:` `),n=t(e.nodes);return`@`+e.id+(n?` `+n:``)}const ce=RegExp(`(?:[a-zA-Z0-9-]+)|([${p.join(``)}#.:,*])|(a-zA-Z0-9-)`,`g`),le=new Set([`before`,`after`,`first-letter`,`first-line`]);function S(e,t,n=!0){let r=e=>{let r=[],i=``,a=0;for(let o of e.matchAll(ce)){let s=o[0];if(a+=s.length,s===`:`||s===`.`||s===`#`){i+=s;continue}let c,l=s,u=t.selectors.get(i+s);if(u){let e=u[u.length-1];r.push(u.length===1&&e.type?{...e,raw:i+s}:{children:u,raw:i+s}),i=``;continue}if(p.includes(s)){if(c=`combinator`,s===`_`){let t=e[a];e[a-s.length-1]!==`_`&&t!==`_`&&(l=` `)}}else s===`,`?c=`separator`:s===`*`?c=`universal`:i===`:`?c=le.has(s)?`pseudo-element`:`pseudo-class`:i===`::`?c=`pseudo-element`:i===`.`?c=`class`:i===`#`&&(c=`id`);r.push({value:l,...n&&{raw:i+s},...c&&{type:c}}),i=``}return r},i=(e,t=[])=>{let a=te(e);if(a){let{pre:e,body:n,post:o}=a,s;if(n){let t=e.lastIndexOf(`:`);if(t!==-1){let n=t;for(;n>0&&e[n-1]===`:`;)n--;s=e.slice(n),e=e.slice(0,n)}}if(e&&t.push(...i(e)),n){let e=i(n);if(s){let n=r(s)[0];e.length&&(n.children=e),t.push(n)}else t.push(...e)}return o&&t.push(...i(o)),t}let o=te(e,`[`,`]`);if(o){let{pre:e,body:r,post:a}=o;return e&&t.push(...i(e)),t.push({value:r,type:`attribute`,...n&&{raw:`[${r}]`}}),a&&t.push(...i(a)),t}return r(e)};return i(e)}const ue={class:`.`,"pseudo-class":`:`,"pseudo-element":`::`,attribute:``,combinator:``,id:`#`};function de(e,t=``){let n=e=>{if(e.type===`attribute`)return`[${e.value}]`;if(e.type===`combinator`)return e.value;let t=e.type&&ue[e.type]||``,r=e.value?t+e.value:``;if(`children`in e&&e.children?.length){let t=e.children.map(n).join(``);return e.value?r+`(${t})`:r+t}return r},r=``,i=``,a=[];if(e.flatMap(e=>!(`value`in e)&&`children`in e&&e.children?.length?e.children:e).forEach(e=>{e.value===`,`?(a.push(i),i=``):e.value===`of`&&`children`in e?r+=e.children.map(n).join(``):i+=n(e)}),i&&a.push(i),r){let e=r.charAt(r.length-1);!p.includes(e)&&e!==` `&&(r+=` `)}return a.length?a.map(e=>r+t+e).join(`,`):r+t}var fe=new Intl.Collator(void 0,{numeric:!0}).compare;const pe={hover:1,focus:2,"focus-visible":2,active:3,disabled:4};function me(e=[]){let t=0;for(let n of e)`value`in n&&typeof n.value==`string`&&(t+=pe[n.value]??0),`children`in n&&Array.isArray(n.children)&&(t+=me(n.children));return t}const he={">=":`<`,"<=":`>`,">":`<=`,"<":`>=`};function ge(e){let t=new Map,n=(e,r=!1)=>{(e??[]).forEach((e,i,a)=>{let o=a[i-1];if(`operator`in e){let n=t.get(e.name)??{},i=e.operator;switch(r&&(i=he[i]),o?.type===`logical`&&o.value===`not`&&(i=he[i]),i){case`>`:n.min=e.value+.02;break;case`>=`:n.min=e.value;break;case`<`:n.max=e.value-.02;break;case`<=`:n.max=e.value;break}t.set(e.name,n)}`children`in e&&Array.isArray(e.children)&&n(e.children,o?.type===`logical`&&o.value===`not`)})};return n(e),t}function _e(e){let t=[],n=e=>{let n=ge(e);for(let[e,r]of n.entries()){let n=r.max??2**53-1,i=r.min??0;t.push([e,i,n])}};return e.conditions?.media&&n(e.conditions.media),e.conditions?.container&&n(e.conditions.container),t.sort(([e],[t])=>fe(e,t)),{features:t,selector:me(e.selectorNodes??[])}}function ve(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=e[r],i=t[r];if(!n)return-1;if(!i)return 1;let[a,o,s]=n,[c,l,u]=i,d=fe(a,c);if(d!==0)return d;let f=s-o,p=u-l;if(f!==p)return p-f;if(o!==l)return l-o;if(s!==u)return u-s}return 0}function ye(e){if(typeof e.sortTier==`number`)return e.sortTier;let t=e.selectorNodes?.length,n=!!e.conditions,r=!!e.mode;return n?3:r?2:+!!t}function C(e,t){let n=ye(e),r=ye(t);if(n!==r)return n-r;let i=ve(e.priority.features||[],t.priority.features||[]);if(i!==0)return i;let a=e.priority.selector-t.priority.selector;if(a!==0)return a;let o=e.type-t.type;return o===0?fe(e.key,t.key):o}function be(e,t){let n=new Set;for(let r in e){let i=e[r];if(i)for(let e of c(String(i))){let r=t.get(e);r&&!r.inline&&n.add(e)}}return n.size?n:void 0}function xe(e,t){if(!t?.length)return e;for(let n=t.length-1;n>=0;n--){let r=t[n]?.trim();r&&(e=`${r}{${e}}`)}return e}function Se(e){return String(Object.is(e,-0)?0:e).replace(/^(-?)0\./,`$1.`)+`%`}function Ce(e){return typeof e==`number`?String(e):e.replace(/\|/g,` `)}function w(e,t,n){let r=`var(--${e}${n?`,`+n:``})`;return t===void 0?r:we(r,t)}function we(e,t){return`color-mix(in oklab,${e} ${Se(t*100)},transparent)`}function Te(e,t,n=16){return w(e.name)}function Ee(e,t,n=16){return`calc(${w(e.name)} * -1)`}function De(e){return e===`animation`||e===`animation-name`}function Oe(e,t,n){t.has(n)&&e.add(n)}function ke(e,t){let n=new Set;if(e===void 0)return n;let r=new Set(t);if(!r.size)return n;let i=Ce(e);for(let e of i.split(/[\s,]+/))Oe(n,r,e);return n}function Ae(e,t,n,r,i=new Set){if(!(!t||i.has(t.name))){i.add(t.name);for(let r of ke(t.value,n))e.add(r);for(let r of Object.values(t.modes||{}))for(let t of ke(r.value,n))e.add(t);t.dependencies?.forEach(t=>{Ae(e,r?.get(t),n,r,i)})}}function je(e,t,n){let r=new Set;if(!De(e))return r;let i=new Set(n.animationNames);if(!i.size)return r;for(let e of ke(t,i))r.add(e);for(let e of n.variableNames||[])Ae(r,n.variables?.get(e),i,n.variables);return r}function Me(e,t){let n=new Set;for(let r in e){let i=e[r];for(let e of je(r,i,t))n.add(e)}return n.size?n:void 0}function Ne(e){return/^:{1,2}[-_a-zA-Z][-_a-zA-Z0-9]*$/.test(e)||/^@[-_a-zA-Z][-_a-zA-Z0-9]*$/.test(e)}function Pe(e,t){if(!e.startsWith(t))return!1;let n=e[t.length];return n===void 0||n===`!`||n===`*`||n===`>`||n===`+`||n===`~`||n===`:`||n===`[`||n===`@`||n===`_`||n===`.`}function Fe(e,t){if(t.type===`pattern`)for(let n of t.values){let r=t.prefix+n;if(Pe(e,r))return{classValue:n,emittedValue:t.valueMap?.[n]||n,length:r.length}}}function Ie(e,t){for(let n of t.matchers){let t=Fe(e,n);if(t)return t}}function Le(e,t){for(let n of t.matchers)if(n.type===`static`&&Pe(e,n.name))return{length:n.name.length}}const T=new Set([`animation`,`animation-name`]),Re=/^(?:0|1|0?\.\d+|1\.0+|0\.0+)$/;function ze(e){let t=e.emit;switch(t.type){case`declarations`:return t.declarations.some(e=>T.has(e));case`property`:return T.has(t.property);case`template`:return Object.keys(t.declarations).some(e=>T.has(e));case`static`:return t.rules.some(e=>Object.keys(e.declarations).some(e=>T.has(e)));default:return!1}}function Be(e,t,n){let r=e*t/n;return String(Object.is(r,-0)?0:r).replace(/^(-?)0\./,`$1.`)+`rem`}function Ve(e){if(!Re.test(e))return;let t=Number(e);return t>=0&&t<=1?t:void 0}function He(e){return e===`color`||e?.startsWith(`color-`)}function Ue(e){return e[0]===`=`||e[0]===`~`?e.slice(1):e}function E(e,t){return!t||t===`&`?e:t.replace(/&/g,e||`&`)}function We(e){if(!e)return;let t={};for(let n of v){let r=e[n];r?.length&&(t[n]=[...r])}return t}function D(e,t){let n=We(e)||{};return n[t.id]=[...n[t.id]||[],...t.nodes],n}function Ge(e,t,n,r){let i=We(e.conditions);for(let e of t.conditionNodes||[])i=D(i,e);if(!t.conditionNodes?.length)for(let e of t.conditions||[]){let t=oe(e,n);i=D(i,t)}if(t.selectorNodes?.length&&!t.selector)return{...e,key:e.key+r,selectorNodes:t.selectorNodes,...i?{conditions:i}:{},...t.layer||e.layer?{layer:t.layer||e.layer}:{},valid:e.valid!==!1&&!(e.layer&&t.layer&&e.layer!==t.layer)};let a=t.layer||e.layer;return{...e,key:e.key+r,selectorTemplate:E(e.selectorTemplate,t.selector),...i?{conditions:i}:{},...a?{layer:a}:{},valid:e.valid!==!1&&!(e.layer&&t.layer&&e.layer!==t.layer)}}function Ke(e,t){let n=0,r=``;for(let i=t;i<e.length;i++){let t=e[i];if(r){t===`\\`?i++:t===r&&(r=``);continue}if(t===`"`||t===`'`){r=t;continue}if(t===`(`&&n++,t===`)`&&(n--,n===0))return i}return-1}function qe(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?n++:a===`)`?n--:a===`,`&&n===0&&(t.push(e.slice(r,i),a),r=i+1)}return t.push(e.slice(r)),t}function Je(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r===`(`)t++;else if(r===`)`)t--;else if(t===0&&(r===`+`||r===`-`||r===`*`||r===`/`)){let t=n-1;for(;e[t]===` `;)t--;let i=e[t];if((r===`+`||r===`-`)&&(!i||i===`(`||i===`,`||i===` `))continue;return!0}}return!1}function Ye(e){return qe(e).map(e=>{if(e===`,`)return e;let t=e.trim();return!t||/^(?:calc|clamp|min|max|var)\(/.test(t)||!Je(t)?e:`${e.match(/^\s*/)[0]}calc(${t})${e.match(/\s*$/)[0]}`}).join(``)}var O=class{name;css;registeredUtility;fixedClass;native;nodes;conditions;priority;type=u.Normal;declarations;declarationRules;layer;layerName;explicitLayerName;valid=!0;animationNames;variableNames;branchIndex;branchCount=1;selectorTemplate;variantBranchKey;invalidValueSyntax=!1;constructor(e,t,n,r,i,a=0){this.name=e,this.css=t,this.registeredUtility=n,this.fixedClass=r,this.branchIndex=a,this.mode=i,this.layerName=n.layer||`utilities`;let{name:o,key:s,layer:c,conditions:l,...u}=n;Object.assign(this,u);let{id:d,type:f}=n;this.type=f;let p=``,m=Le(e,n);if(m)p=e.slice(m.length);else{let t,r=Ie(e,n);if(r)t=r.emittedValue,p=e.slice(r.length),this.keyToken=e.slice(0,r.length-r.classValue.length);else if(d.endsWith(`()`))t=e;else if(d===`group`)t=e;else{let n=e.indexOf(`:`);this.keyToken=e.slice(0,n+1),t=e.slice(n+1)}this.valueComponents=[];let i=this.parseValues(this.valueComponents,0,t,``,``,void 0,!1,ze(n)?Array.from(this.css.animations.keys()):[]);if(this.invalidValueSyntax){this.valid=!1;return}this.valueToken=t.slice(0,i),r?i!==t.length&&(p=t.slice(i)+p):p=t.slice(i)}p[0]===`!`&&(this.important=!0,p=p.slice(1)),this.stateToken=p;let h=this.resolveStateBranches(p);this.branchCount=h.length;let g=h[a];if(!g){this.valid=!1;return}if(g.mode&&(this.mode=g.mode),g.selectorNodes?.length&&(this.selectorNodes=g.selectorNodes),g.selectorTemplate&&(this.selectorTemplate=g.selectorTemplate),g.conditions&&(this.conditions=g.conditions),g.valid===!1&&(this.valid=!1),this.variantBranchKey=g.key,this.mode&&t.settings.modeTrigger===`media`){let e={name:`prefers-color-scheme`,value:this.mode};this.conditions?.media?this.conditions.media.push(e):this.conditions={media:[e]}}this.conditions?.layer&&this.conditions.layer.length>1&&(this.valid=!1),g.layer&&(this.explicitLayerName&&this.explicitLayerName!==g.layer&&(this.valid=!1),this.layerName=g.layer,this.explicitLayerName=g.layer);let _=this.conditions?.layer?.length===1&&this.conditions.layer[0];if(_){let e=String(_.value);(e===`base`||e===`defaults`||e===`components`||e===`utilities`)&&(this.layerName=e,this.explicitLayerName=e,this.conditions.layer=void 0)}this.layer=t.getUtilityLayer(this.layerName);let v;if(this.valueComponents){if(v=this.resolveValue(this.valueComponents,``,[],!1),this.invalidValueSyntax){this.valid=!1;return}let e=this.emitDynamicDeclarationRules(v);if(e)this.declarations=e[0]?.declarations,(e.length>1||e.some(({conditions:e,selector:t})=>e?.length||t))&&(this.declarationRules=e);else{let e=this.emitDynamicDeclarations(v);this.declarations=e,e&&n.conditions?.length&&(this.declarationRules=[{declarations:e,conditions:n.conditions}])}}else{let e=n.emit.type===`static`?n.emit.rules.map(({declarations:e,conditions:t,selector:n})=>({declarations:e,conditions:t,selector:n})):[];this.declarations=e[0]?.declarations,(e.length>1||e.some(({conditions:e,selector:t})=>e?.length||t))&&(this.declarationRules=e)}let y=this.declarationRules||(this.declarations?[{declarations:this.declarations}]:[]);if(!y.some(({declarations:e})=>Object.entries(e??{}).length))this.valid=!1;else{for(let{declarations:e}of y){let t=be(e,this.css.variables);if(t)for(let e of t)this.variableNames?this.variableNames.add(e):this.variableNames=new Set([e]);let n=Me(e,{animationNames:this.css.animations.keys(),variables:this.css.variables,variableNames:t});if(n)for(let e of n)this.animationNames?this.animationNames.add(e):this.animationNames=new Set([e])}this.priority=_e(this),y.length>1&&(this.nodes=y.map(({declarations:e,conditions:t,selector:n})=>new Xe(this,e,t,n)))}}resolveVariableAlias(e){let t=this.variables?.get(e)||this.css.variables.get(e);if(t)return{name:t.name??e,variable:t};if(e[0]!==`-`)return;let n=e.slice(1),r=this.variables?.get(n)||this.css.variables.get(n);if(r?.type===`number`)return{name:r.name??n,variable:r,negative:!0}}canUseAlpha(e){return e?.type===`number`||e?.numeric?!1:this.registeredUtility.variableAliasRefs?.some(e=>He(Ue(e)))?!0:e?.namespace?He(e.namespace):!1}resolveDynamicDeclarationValue(e,t){return e===null?t:Array.isArray(e)?e.map(e=>e===null?t:e).join(``):e}resolveDynamicDeclarations(e,t){let n={};for(let r in e)n[r]=this.resolveDynamicDeclarationValue(e[r],t);return n}emitDynamicDeclarationRules(e){let t=this.registeredUtility.emit;if(t.type===`static`)return t.rules.map(({declarations:t,conditions:n,selector:r})=>({declarations:this.resolveDynamicDeclarations(t,e),conditions:n,selector:r}))}emitDynamicDeclarations(e){let t=this.registeredUtility.emit;switch(t.type){case`declarations`:{let n={};for(let r of t.declarations)n[r]=e;return n}case`template`:{let n={};for(let r in t.declarations){let i=t.declarations[r];n[r]=i==null?e:Array.isArray(i)?i.map(t=>t??e).join(``):i}return n}case`group`:return this.emitGroupDeclarations(e);case`property`:return{[t.property]:e};case`static`:return}}emitGroupDeclarations(e){let t={},n=e=>{let n=e.indexOf(`:`);if(n!==-1){let r=e.slice(0,n);t[r]=e.slice(n+1).replace(/\|/g,` `)}},r=e=>{let n=e.declarations;for(let r in n){let i=String(n[r]);(`important`in e&&e.important||e.css.settings.important)&&!i.endsWith(`!important`)&&(i+=`!important`),t[r]=i}if(e.animationNames){this.animationNames||=new Set;for(let t of e.animationNames)this.animationNames.add(t)}if(e.variableNames)if(this.variableNames)for(let t of e.variableNames)this.variableNames.add(t);else this.variableNames=new Set(e.variableNames)},i=[],a=``,o=()=>{a&&=(i.push(a.replace(/ /g,`|`)),``)},s=1;(function t(n){for(;s<e.length;s++){let r=e[s];if(!n){if(r===`;`){o();continue}if(r===`}`)break}if(a+=r,n===r){if(n===`'`||n===`"`){let e=0;for(let t=a.length-2;a[t]===`\\`;t--)e++;if(e%2)continue}break}else r in d&&n!==`'`&&n!==`"`&&(s++,t(d[r]))}})(``),o();for(let e of i){let t=this.css.generate(e,this.mode);if(t.length)for(let e of t)r(e);else n(e)}return t}resolveStateBranches(e){let[t=``,...n]=e.split(`@`),r=[{key:``}];r=this.applySelectorTokenBranches(r,t);for(let e of n){if(this.css.modes.includes(e)){r=r.map(t=>({...t,mode:e,key:t.key+`@`+e}));continue}this.conditionToken=(this.conditionToken||``)+`@`+e;let t=`@${e}`,n=this.css.resolveVariant(t);if(n){r=r.flatMap(e=>n.map((n,r)=>Ge(e,n,this.css,`${t}#${r}`)));continue}let i=oe(e,this.css);r=r.map(t=>({...t,key:t.key+`@`+e,conditions:D(t.conditions,i)}))}return r.length?r:[{key:``}]}applySelectorTokenBranches(e,t){if(!t)return e;let n=[...this.css.variants.keys()].filter(e=>e.startsWith(`:`)).sort((e,t)=>t.length-e.length),r=0,i=``,a=()=>{if(!i)return;let t=de(S(i,this.css),`&`);e=e.map(e=>({...e,key:e.key+i,selectorTemplate:E(e.selectorTemplate,t),selectorNodes:S(e.selectorTemplate?E(e.selectorTemplate,t)?.replace(/&/g,``)||``:i,this.css)})),i=``};for(;r<t.length;){if(t[r]===`(`){let e=Ke(t,r);if(e!==-1){i+=t.slice(r,e+1),r=e+1;continue}}let o=n.find(e=>{if(!t.startsWith(e,r))return!1;let n=t[r+e.length];return n===void 0||n===`(`||!/[-_a-zA-Z0-9]/.test(n)});if(!o||!Ne(o)){i+=t[r++];continue}let s=this.css.resolveVariant(o);if(!s){i+=t[r++];continue}a(),r+=o.length;let c=``;if(t[r]===`(`){let e=Ke(t,r);e!==-1&&(c=t.slice(r,e+1),r=e+1)}e=e.flatMap(e=>s.map((t,n)=>{let r=t.selector&&c?t.selector+c:t.selector,i=Ge(e,{...t,...r?{selector:r}:{}},this.css,`${o}#${n}${c}`),a=i.selectorTemplate;return{...i,...a?{selectorNodes:S(a.replace(/&/g,``),this.css)}:{}}}))}return a(),e}get text(){return this.valid?this.nodes?this.nodes.map(({text:e})=>e).join(``):this.declarationRules?this.declarationRules.map(({declarations:e,conditions:t,selector:n})=>this.createRuleText(e,t,n)).join(``):this.createRuleText(this.declarations):``}createRuleText(e,t,n){let r=[];for(let t in e){let n=e[t],i=t+`:`+String(n);r.push(i+((this.important||this.css.settings.important)&&!i.endsWith(`!important`)?`!important`:``))}let i=this.createSelectorText(n)+`{`+r.join(`;`)+`}`;return this.conditions!==void 0&&v.forEach(e=>{let t=this.conditions?.[e];t&&(i=se({id:e,nodes:t})+`{`+i+`}`)}),xe(i,t)}get selectorText(){return this.createSelectorText()}createSelectorText(e){let t=``;if(this.css.settings.scope&&(t=this.css.settings.scope+` `+t),this.mode){let e=this.css.getModeSelector(this.mode);e&&(t=e+` `+t)}let r=t+`.`+n(this.fixedClass??this.name),i=this.selectorTemplate?r:this.selectorNodes?de(this.selectorNodes,r):r;return this.selectorTemplate&&(i=this.selectorTemplate.replace(/&/g,i)),e?e.replace(/&/g,i):i}resolveValue=(e,t,n,r)=>{let i=``,a=e=>{this.variableNames?this.variableNames.add(e):this.variableNames=new Set([e])},o=e=>{let n=this.parseValue(e,t);return n.type===`number`?String(n.value)+(n.unit||``):n.value},s=(e,t=[])=>{let i=t.indexOf(e.name);if(i!==-1)throw Error(`Circular inline variable reference: ${[...t.slice(i),e.name].join(` -> `)}`);if(e.value===void 0)return w(e.name);let c=[...t,e.name];return l(e.type===`number`&&typeof e.value==`number`&&!r?o(e.value):Ce(e.value),e=>{let t=this.css.variables.get(e);if(t){if(t.inline)return s(t,c);n.includes(e)||a(e)}})},c=e=>`calc(${e} * -1)`;for(let o of e)switch(o.type){case`function`:if(o.name===`$`){this.invalidValueSyntax=!0;break}!o.bypassTransform&&o.name===`calc`?i+=o.token=o.text=this.resolveMathFunction(this.stringifyValueComponents(o.children),n):!o.bypassTransform&&o.name===`clamp`?i+=o.token=o.text=this.resolveMathFunction(this.stringifyValueComponents(o.children),n,{name:`clamp`,wrapArguments:!0}):i+=o.token=o.text=o.name+o.symbol+this.resolveValue(o.children,t,n,r)+d[o.symbol];break;case`variable`:let e=this.resolveVariableAlias(o.name),l=e?.variable,u=e?.name??o.name,f=o.negative||e?.negative,p=()=>{if(!o.fallback)return;let e=[];return this.parseValues(e,0,o.fallback,t,``,void 0,r,n),this.resolveValue(e,t,n,r)},m=e=>{if(e?.type===`number`&&o.alpha===void 0){if(f)return r?c(w(e.name)):Ee(e,t,this.css.settings.rootSize);if(!r)return Te(e,t,this.css.settings.rootSize)}return w(u,o.alpha,p())};if(l?.inline){let e=s(l);i+=o.text=o.alpha===void 0?f?c(e):e:we(e,o.alpha)}else l?(a(u),i+=o.text=m(l)):i+=o.text=m();break;case`separator`:i+=o.text?o.text:o.text=o.value;break;case`number`:i+=o.text=o.value+(o.unit||``);break;default:i+=o.text=o.value;break}return i};stringifyValueComponents(e){let t=``;for(let n of e)switch(n.type){case`function`:t+=n.name+n.symbol+this.stringifyValueComponents(n.children)+d[n.symbol];break;case`separator`:t+=n.value;break;case`variable`:t+=n.token||`$`+n.name;break;case`number`:t+=n.token||String(n.value)+(n.unit||``);break;default:t+=n.token||n.value;break}return t}resolveMathFunction(e,t,n){let r=n?.name??`calc`,i=[],a=0,o=(t,n,r,s,c)=>{let l=i!==t,u=[],d=!1,p=!1,m=!1,h=!1,g,_=``,v=(i,o=``,s=``)=>{if(_){if(!c){let e=f.exec(_);e&&(_=Be(+e[1],this.css.settings.baseUnit??1,this.css.settings.rootSize))}if(!d&&!r){let e={...this.parseValue(_),token:_};if(!p&&isNaN(+_)&&e.type===`number`&&(p=!0),h)isNaN(+_)?e.type===`number`?(t.push(e),m=!0):t.push(e):t.push({type:`number`,value:+_,token:_});else if(l){let e={type:`string`,value:_,token:_};u.push(e),t.push(e)}else t.push(e)}else t.push({type:`string`,value:_,token:_});_=``}i&&((i===`+`||i===`-`)&&b(),o&&e[a-1]===` `&&(o=``),s&&e[a+1]===` `&&(s=``),n?t.push({type:`separator`,value:i,text:i,token:i}):t.push({type:`separator`,value:i,text:o+i+s,token:i})),d=!1},y=()=>{t.push({type:`separator`,value:`*`,text:` * `,token:`*`},{type:`number`,value:1,unit:``,token:``})},b=()=>{h&&!m&&!s&&(!l||p)&&y(),h=!1,m=!1};for(;a<e.length;a++){let n=e[a];if(n===`(`){let e=/^([+-])/.exec(_);e&&t.push({type:`string`,value:e[1],token:e[1]});let r=e?_.slice(1):_,i={type:`function`,name:r,symbol:n,children:[],bypassTransform:r===`calc`,token:_};t.push(i),_=``,a++,r===`$`&&(this.invalidValueSyntax=!0);let s=r===`var`;g=o(i.children,s,d||s||h&&m,h,s)||r===`var`,g&&(p=!0,m=!0)}else if(n===`)`){if(v(``),p)for(let e of u)Object.assign(e,this.parseValue(e.value));return p}else if(n===`,`)v(n,``,` `);else if(n===` `)v(n);else{let t=e[a-1];switch(n){case`+`:!_&&t!==`)`?_+=n:v(n,` `,` `);break;case`-`:!_&&t!==`)`?_+=n:v(n,` `,` `);break;case`*`:v(n,` `,` `);break;case`/`:v(n,` `,` `),d=!0;break;default:_+=n;break}}}v(``),b()};o(i,!1,!1,!1,!1);let s=this.resolveValue(i,``,t,!0);return n?.wrapArguments&&(s=Ye(s)),r+`(`+s+`)`}parseValues=(e,t,n,r,i,a,o=!1,s=[])=>{let c=a===void 0,l=!c&&a.endsWith(`var`),u=(e=>e===`'`||e===`"`)(i),p=[`,`];this.registeredUtility.separators?.length&&p.push(...this.registeredUtility.separators);let m=``,h=()=>{if(m){let t=!1;if(this.registeredUtility.emit.type!==`group`&&(!l||e.length)){let n=(t,n,r=m,i)=>{let a={type:`variable`,name:t,variable:this.css.variables.get(t),token:r};if(n!==void 0){let e=Ve(n);if(e===void 0||!this.canUseAlpha(a.variable)){this.invalidValueSyntax=!0;return}a.alpha=e}i&&(a.negative=!0),e.push(a)},r=(e,r)=>{let i=this.resolveVariableAlias(e);if(i&&(!i.negative||r===void 0)){let{name:e,negative:a}=i;if(!s.includes(e)){if(r!==void 0&&!this.canUseAlpha(i.variable)){this.invalidValueSyntax=!0;return}t=!0,n(e,r,m,a)}}};if(/^\$[a-zA-Z0-9-]+(?:\/[^\/]+)?$/.test(m)){let[e,i]=m.slice(1).split(`/`);if(r(e,i),!t&&!s.includes(e)){if(i!==void 0&&!this.canUseAlpha()){this.invalidValueSyntax=!0;return}t=!0,n(e,i)}}else if(r(m),!t){let e=m.indexOf(`/`);if(e!==-1&&m.indexOf(`/`,e+1)!==-1){let t=m.slice(0,e);this.resolveVariableAlias(t)&&(this.invalidValueSyntax=!0)}else e!==-1&&r(m.slice(0,e),m.slice(e+1))}}if(!t){if(!l){let e=f.exec(m);e&&(m=Be(+e[1],this.css.settings.baseUnit??1,this.css.settings.rootSize))}if(o)e.push({type:`string`,value:m,token:m});else{let t=this.parseValue(m,r);e.push({...t,token:m})}}m=``}};for(;t<n.length;t++){let s=n[t];if(s===i){if(u){let e=0;for(let t=m.length-1;m[t]===`\\`;t--)e++;if(e%2){m+=s;continue}else h()}else h();return t}else if(!u&&s in d){let i=m;if(s===`(`&&i===`$`)return this.invalidValueSyntax=!0,n.length;let c={type:`function`,name:i,symbol:s,children:[],token:``};e.push(c),m=``,t=this.parseValues(c.children,++t,n,r,d[s],i||a||``,o||i===`calc`)}else if((s===`|`||s===` `)&&i!==`}`&&(!u||a===`path`))h(),e.push({type:`separator`,value:` `,token:s});else{if(!u){if(s===`.`)if(isNaN(+n[t+1])){if(c)break}else n[t-1]===`-`&&(m+=`0`);else if(p.includes(s)){h(),e.push({type:`separator`,value:s,text:(s===`,`?``:` `)+s+(s===`,`?``:` `),token:s});continue}else if(c&&(s===`#`&&(m||e.length&&e[e.length-1].type!==`separator`)||[`!`,`*`,`>`,`+`,`~`,`:`,`[`,`@`,`_`].includes(s)))break}m+=s}}return h(),t};parseValue(e,t=``){return ee(e,t,this.css.settings.rootSize)}get key(){return(this.fixedClass?this.fixedClass+` `:``)+this.name+(this.variantBranchKey?`\0`+this.variantBranchKey:``)}},Xe=class{rule;declarations;conditions;selector;native;constructor(e,t,n,r){this.rule=e,this.declarations=t,this.conditions=n,this.selector=r}get text(){return this.rule.createRuleText(this.declarations,this.conditions,this.selector)}};const Ze=new WeakMap;function Qe(e){let t=Ze.get(e);return t||(t=new Map,Ze.set(e,t)),t}function k(e){let t=Qe(e);if(t.size!==e.rules.length){t.clear();for(let n of e.rules)t.set(n.key,n)}return t}var A=class{name;css;rules=[];tokenCounts=new Map;constructor(e,t){this.name=e,this.css=t}attach(){this.css.rules.push(this)}detach(){this.css.rules.splice(this.css.rules.indexOf(this),1)}get(e){return k(this).get(e)}insert(e,t=this.rules.length){let n=k(this);if(!n.has(e.key))return this.rules.splice(t,0,e),n.set(e.key,e),this.css.rules.includes(this)||this.attach(),t}delete(e){let t=k(this),n=t.get(e);if(!n)return;let r=this.rules.indexOf(n);if(r!==-1)return this.rules.splice(r,1),t.delete(e),this.rules.length===0&&this.detach(),n}reset(){this.rules.length=0;let e=this.css.rules.indexOf(this);e!==-1&&this.css.rules.splice(e,1),this.tokenCounts.clear(),Qe(this).clear()}get text(){let e=this.rules.map(({text:e})=>e).join(``);return e?`@layer `+this.name+`{`+e+`}`:``}};function $e(e){return e.replace(/\s*,\s*/g,`,`).replace(/\s+/g,` `).trim()}var et=class extends A{name;css;rules=[];constructor(e,t){super(e,t),this.name=e,this.css=t}getBucketRank(e){if(e.mediaText)return 2;let t=e.selectorText.split(`,`).map(e=>e.trim());return t.includes(`:root`)||t.includes(`:host`)?0:1}getModeSelectorText(e,t=!1){switch(this.css.settings.modeTrigger){case`host`:return`:host(.${e})${t?`,:host`:``}`;case`class`:return`.${e}${t?`,:root`:``}`;default:return`:root`}}matchesModeSelectorText(e,t){let n=$e(t),r=[this.getModeSelectorText(e)];return this.css.settings.defaultMode!==`none`&&this.css.settings.defaultMode===e&&r.push(this.getModeSelectorText(e,!0)),r.map(e=>$e(e)).includes(n)}getBucketColorScheme(e){if(!(this.css.settings.modeTrigger!==`class`&&this.css.settings.modeTrigger!==`host`)&&!e.mediaText&&!(e.mode!==`light`&&e.mode!==`dark`)&&this.matchesModeSelectorText(e.mode,e.selectorText))return e.mode}getBucketSyntheticDeclarations(e){let t=this.getBucketColorScheme(e);return t?[{name:`color-scheme`,value:t}]:[]}compareBuckets(e,t){return this.getBucketRank(e)-this.getBucketRank(t)||e.order-t.order}shouldInsertBucketBefore(e,t){return this.getBucketRank(e)<this.getBucketRank(t)}getBuckets(){let e=new Map;for(let t of this.rules)for(let n of t.nodes){let t=n.mediaText+`
|
|
2
|
+
`+n.selectorText,r=e.get(t);r||(r={mediaText:n.mediaText,mode:n.mode,selectorText:n.selectorText,order:e.size,nodes:[]},e.set(t,r)),r.nodes.push(n)}return Array.from(e.values()).sort((e,t)=>this.compareBuckets(e,t))}getBucketText(e){let t=[...this.getBucketSyntheticDeclarations(e).map(({name:e,value:t})=>`${e}:${t}`),...e.nodes.map(({declarationText:e})=>e)],n=`${e.selectorText}{${t.join(`;`)}}`;return e.mediaText?`${e.mediaText}{${n}}`:n}get text(){let e=this.getBuckets().map(e=>this.getBucketText(e)).join(``);return e?`@layer `+this.name+`{`+e+`}`:``}},j=class{name;keyframes;css;native;variableNames;constructor(e,t,n){this.name=e,this.keyframes=t,this.css=n;for(let e of Object.values(t)){let t=be(e,n.variables);if(t)for(let e of t)this.variableNames?this.variableNames.add(e):this.variableNames=new Set([e])}}get key(){return this.name}get text(){return`@keyframes ${this.name}{`+Object.entries(this.keyframes).reduce((e,[t,n])=>e+`${t}{${Object.entries(n).map(([e,t])=>`${e}:${t}`).join(`;`)}}`,``)+`}`}},M=class{name;variable;css;nodes=[];constructor(e,t,n){this.name=e,this.variable=t,this.css=n;let r=t.value!==void 0;if(r&&this.nodes.push(new tt(this,t,n)),t.modes&&this.css.settings.modeTrigger)for(let e in t.modes){let i=t.modes[e],a=new tt(this,i,n,e),o=!r&&this.css.settings.defaultMode!==`none`&&this.css.settings.defaultMode===e;a.isDefaultMode=o,o?this.nodes.unshift(a):this.nodes.push(a)}}get key(){return this.name}get text(){return this.nodes.map(({text:e})=>e).join(``)}},tt=class{rule;variable;css;mode;native;isDefaultMode=!1;constructor(e,t,n,r){this.rule=e,this.variable=t,this.css=n,this.mode=r}get selectorText(){let e=this.isDefaultMode;if(this.mode)switch(this.css.settings.modeTrigger){case`host`:return`:host(.${this.mode})${e?`,:host`:``}`;case`class`:return`.${this.mode}${e?`,:root`:``}`;default:return`:root`}else return`:root`}get declarationName(){return`--${this.rule.name}`}get declarationValue(){let e=(t,n)=>l(Ce(t),t=>{let r=this.css.variables.get(t);if(!r?.inline||r.value===void 0)return;let i=n.indexOf(t);if(i!==-1)throw Error(`Circular inline variable reference: ${[...n.slice(i),t].join(` -> `)}`);return e(r.value,[...n,t])});return e(this.variable.value,[this.rule.name])}get declarationText(){return`${this.declarationName}:${this.declarationValue}`}get mediaText(){return this.css.settings.modeTrigger===`media`&&this.mode?`@media (prefers-color-scheme:${this.mode})`:``}get text(){let e=`${this.selectorText}{${this.declarationText}}`;return this.css.settings.modeTrigger===`media`&&this.mode&&(e=`@media (prefers-color-scheme:${this.mode}){${e}}`),e}};function nt(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(!(a instanceof O))return rt(e,t);C(t,a)<0?r=i:n=i+1}return n}function rt(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r instanceof O&&C(t,r)<0)return n}return e.length}var N=class extends A{rules=[];insert(e){if(this.get(e.key)||`valid`in e&&!e.valid)return;let t=this.rules.length;e instanceof O&&(t=nt(this.rules,e));let n=super.insert(e,t);if(n!==void 0)return this.insertVariables(e),this.insertAnimations(e),n}delete(e){let t=super.delete(e);if(!t)return;let n=(e,t,r=new Set)=>{if(r.has(e))return;r.add(e);let i=t.tokenCounts.get(e)??0,a=t===this.css.themeLayer?this.css.variables.get(e):void 0;if(i<=1){let i=t.delete(e);return t.tokenCounts.delete(e),a?.dependencies?.forEach(e=>n(e,t,r)),i}else t.tokenCounts.set(e,i-1),a?.dependencies?.forEach(e=>n(e,t,r))};return`variableNames`in t&&t.variableNames?.forEach(e=>{n(e,this.css.themeLayer)}),`animationNames`in t&&t.animationNames?.forEach(e=>{let t=n(e,this.css.animationsNonLayer),r=t&&`variableNames`in t?t.variableNames:void 0;r&&r.forEach(e=>{n(e,this.css.themeLayer)})}),t}insertVariables(e){if(!(`variableNames`in e))return;let t=(e,n=new Set)=>{if(n.has(e))return;n.add(e);let r=this.css.variables.get(e);if(!(!r||r.inline)){if(this.css.themeLayer.rules.find(({name:t})=>t===e)||this.css.isEmittedGlobalsVariable(e)){let t=this.css.themeLayer.tokenCounts.get(e)||0;this.css.themeLayer.tokenCounts.set(e,t+1)}else{let t=new M(e,r,this.css);this.css.themeLayer.insert(t),this.css.themeLayer.tokenCounts.set(e,1)}r.dependencies?.forEach(e=>t(e,n))}};e.variableNames?.forEach(e=>t(e))}insertAnimations(e){`animationNames`in e&&e.animationNames?.forEach(e=>{if(this.css.animationsNonLayer.rules.find(({name:t})=>t===e)||this.css.isEmittedGlobalsAnimation(e)){let t=this.css.animationsNonLayer.tokenCounts.get(e)||0;this.css.animationsNonLayer.tokenCounts.set(e,t+1)}else{let t=this.css.animations.get(e);if(!t)return;let n=new j(e,t,this.css);this.css.animationsNonLayer.insert(n),this.css.animationsNonLayer.tokenCounts.set(e,1),this.insertVariables(n)}})}};function it(e,t){for(let n=0;n<e.length;n++)if(e[n]===t)return n;return-1}var at=class{css;rules=[];tokenCounts=new Map;constructor(e){this.css=e}insert(e){if(this.rules.includes(e))return;let t=this.css.style?.sheet;if(t)try{let n=t.insertRule(e.text,t.cssRules.length);e.native=t.cssRules[n]}catch(e){console.error(e)}this.rules.push(e),this.css.rules.push(e)}delete(e){let t=this.rules.find(t=>t.name===e);if(!t)return;let n=this.css.style?.sheet;if(n){let e=it(n.cssRules,t.native);e!==-1&&n.deleteRule(e)}return this.rules.splice(this.rules.indexOf(t),1),this.css.rules.splice(this.css.rules.indexOf(t),1),t}get text(){return this.rules.map(({text:e})=>e).join(``)}reset(){for(let e of this.rules){let t=this.css.rules.indexOf(e);t!==-1&&this.css.rules.splice(t,1)}this.rules.length=0,this.tokenCounts.clear()}};const ot=new Set(`all.animation.animation-range.background.background-position.background-repeat.border.border-block.border-block-color.border-block-end.border-block-start.border-block-style.border-block-width.border-bottom.border-color.border-image.border-inline.border-inline-color.border-inline-end.border-inline-start.border-inline-style.border-inline-width.border-left.border-radius.border-right.border-style.border-top.border-width.column-rule.columns.contain-intrinsic-size.container.flex.flex-flow.font.font-synthesis.font-variant.gap.grid.grid-area.grid-column.grid-row.grid-template.inset.inset-block.inset-inline.line-clamp.list-style.margin.margin-block.margin-inline.mask.mask-border.mask-position.mask-repeat.offset.outline.overflow.overscroll-behavior.padding.padding-block.padding-inline.place-content.place-items.place-self.scroll-margin.scroll-margin-block.scroll-margin-inline.scroll-padding.scroll-padding-block.scroll-padding-inline.scroll-timeline.text-decoration.text-emphasis.text-wrap.transition.view-timeline.white-space`.split(`.`));function st(e){return ot.has(e)}function ct(e,t){return t.name||(e?`${e}${t.key?`-`+t.key:``}`:t.key)}function lt(e){let t=[];for(let[n,r]of Object.entries(e||{}))for(let e of r){let r=e.type||(typeof e.value==`number`?`number`:`string`);t.push({...e,name:ct(n,e),...n?{namespace:n}:{},type:r})}return t}const ut=Object.freeze({fg:`color`,bg:`background`,"gap-x":`column-gap`,"gap-y":`row-gap`,"grid-col":`grid-column`,"grid-col-end":`grid-column-end`,"grid-col-start":`grid-column-start`,b:`border`,bb:`border-bottom`,bl:`border-left`,br:`border-right`,bt:`border-top`,bx:`border-inline`,by:`border-block`,h:`height`,ix:`inset-inline`,ixe:`inset-inline-end`,ixs:`inset-inline-start`,iy:`inset-block`,iye:`inset-block-end`,iys:`inset-block-start`,leading:`line-height`,m:`margin`,max:`max-size`,"max-h":`max-height`,"max-size-x":`max-inline-size`,"max-size-y":`max-block-size`,"max-w":`max-width`,mb:`margin-bottom`,min:`min-size`,"min-h":`min-height`,"min-size-x":`min-inline-size`,"min-size-y":`min-block-size`,"min-w":`min-width`,ml:`margin-left`,mr:`margin-right`,mt:`margin-top`,mx:`margin-inline`,mxe:`margin-inline-end`,mxs:`margin-inline-start`,my:`margin-block`,mye:`margin-block-end`,mys:`margin-block-start`,p:`padding`,pb:`padding-bottom`,pl:`padding-left`,pr:`padding-right`,pt:`padding-top`,px:`padding-inline`,pxe:`padding-inline-end`,pxs:`padding-inline-start`,py:`padding-block`,pye:`padding-block-end`,pys:`padding-block-start`,r:`border-radius`,rbl:`border-bottom-left-radius`,rbr:`border-bottom-right-radius`,rtl:`border-top-left-radius`,rtr:`border-top-right-radius`,"scroll-m":`scroll-margin`,"scroll-mb":`scroll-margin-bottom`,"scroll-ml":`scroll-margin-left`,"scroll-mr":`scroll-margin-right`,"scroll-mt":`scroll-margin-top`,"scroll-mx":`scroll-margin-inline`,"scroll-mxe":`scroll-margin-inline-end`,"scroll-mxs":`scroll-margin-inline-start`,"scroll-my":`scroll-margin-block`,"scroll-mye":`scroll-margin-block-end`,"scroll-mys":`scroll-margin-block-start`,"scroll-p":`scroll-padding`,"scroll-pb":`scroll-padding-bottom`,"scroll-pl":`scroll-padding-left`,"scroll-pr":`scroll-padding-right`,"scroll-pt":`scroll-padding-top`,"scroll-px":`scroll-padding-inline`,"scroll-pxe":`scroll-padding-inline-end`,"scroll-pxs":`scroll-padding-inline-start`,"scroll-py":`scroll-padding-block`,"scroll-pye":`scroll-padding-block-end`,"scroll-pys":`scroll-padding-block-start`,shadow:`box-shadow`,"size-x":`inline-size`,"size-y":`block-size`,"line-clamp":`-webkit-line-clamp`,"text-fill-color":`-webkit-text-fill-color`,"text-stroke-color":`-webkit-text-stroke-color`,"text-stroke-width":`-webkit-text-stroke-width`,tracking:`letter-spacing`,w:`width`,z:`z-index`}),dt=Object.freeze([`animate`,`breakpoint`,`color`,`color-line`,`color-surface`,`color-text`,`container`,`content`,`duration`,`easing`,`font`,`font-family`,`font-feature`,`font-size`,`font-weight`,`leading`,`order`,`radius`,`shadow`,`spacing`,`tracking`]);function P(e,t=!1){return`${t?`=`:`~`}${e}`}new Set(dt);function F(e){return Object.freeze(e.properties),Object.freeze(e.variableAliasRefs),Object.freeze(e)}const ft=Object.freeze(`background-position.bottom.border-spacing.column-gap.gap.inset.inset-block.inset-block-end.inset-block-start.inset-inline.inset-inline-end.inset-inline-start.left.margin.margin-block.margin-block-end.margin-block-start.margin-bottom.margin-inline.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.mask-position.object-position.outline-offset.padding.padding-block.padding-block-end.padding-block-start.padding-bottom.padding-inline.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.perspective.perspective-origin.right.row-gap.scroll-margin.scroll-margin-block.scroll-margin-block-end.scroll-margin-block-start.scroll-margin-bottom.scroll-margin-inline.scroll-margin-inline-end.scroll-margin-inline-start.scroll-margin-left.scroll-margin-right.scroll-margin-top.scroll-padding.scroll-padding-block.scroll-padding-block-end.scroll-padding-block-start.scroll-padding-bottom.scroll-padding-inline.scroll-padding-inline-end.scroll-padding-inline-start.scroll-padding-left.scroll-padding-right.scroll-padding-top.shape-margin.text-indent.text-underline-offset.top.translate.transform-origin.word-spacing`.split(`.`)),pt=Object.freeze([`cx`,`cy`,`stroke-dashoffset`,`x`,`y`]),mt=Object.freeze([`background-size`,`block-size`,`contain-intrinsic-block-size`,`contain-intrinsic-inline-size`,`flex-basis`,`height`,`inline-size`,`max-block-size`,`max-height`,`max-inline-size`,`max-width`,`min-block-size`,`min-height`,`min-inline-size`,`min-width`,`mask-size`,`width`]),ht=Object.freeze([`border-bottom-left-radius`,`border-bottom-right-radius`,`border-end-end-radius`,`border-end-start-radius`,`border-radius`,`border-start-end-radius`,`border-start-start-radius`,`border-top-left-radius`,`border-top-right-radius`]),gt=Object.freeze([`border`,`border-block`,`border-block-color`,`border-block-end`,`border-block-end-color`,`border-block-start`,`border-block-start-color`,`border-bottom`,`border-bottom-color`,`border-color`,`border-inline`,`border-inline-color`,`border-inline-end`,`border-inline-end-color`,`border-inline-start`,`border-inline-start-color`,`border-left`,`border-left-color`,`border-right`,`border-right-color`,`border-top`,`border-top-color`,`outline`,`outline-color`]),_t=Object.freeze([F({properties:ft,variableAliasRefs:[P(`spacing`)]}),F({properties:pt,variableAliasRefs:[P(`spacing`)]}),F({properties:mt,variableAliasRefs:[P(`container`)]}),F({properties:ht,variableAliasRefs:[P(`radius`)]}),F({properties:gt,variableAliasRefs:[P(`color-line`),P(`color`)]}),F({properties:Object.freeze([`accent-color`,`background-color`,`fill`,`filter`]),variableAliasRefs:[P(`color`)]}),F({properties:Object.freeze([`caret-color`]),variableAliasRefs:[P(`color-text`),P(`color`)]}),F({properties:Object.freeze([`stroke`]),variableAliasRefs:[P(`color-line`),P(`color`)]}),F({properties:Object.freeze([`color`]),variableAliasRefs:[P(`color`,!0),P(`color-text`),P(`color`)]}),F({properties:Object.freeze([`-webkit-text-fill-color`,`text-decoration-color`]),variableAliasRefs:[P(`color-text`),P(`color`)]}),F({properties:Object.freeze([`-webkit-text-stroke-color`]),variableAliasRefs:[P(`color`)]}),F({properties:Object.freeze([`text-shadow`]),variableAliasRefs:[P(`color`)]}),F({properties:Object.freeze([`box-shadow`]),variableAliasRefs:[P(`shadow`),P(`color`)]}),F({properties:Object.freeze([`animation-delay`,`animation-duration`,`transition-delay`,`transition-duration`]),variableAliasRefs:[P(`duration`)]}),F({properties:Object.freeze([`animation-timing-function`,`transition-timing-function`]),variableAliasRefs:[P(`easing`)]}),F({properties:Object.freeze([`animation`,`transition`]),variableAliasRefs:[P(`duration`),P(`easing`)]}),F({properties:Object.freeze([`content`]),variableAliasRefs:[P(`content`,!0)]}),F({properties:Object.freeze([`font-feature-settings`]),variableAliasRefs:[P(`font-feature`,!0)]}),F({properties:Object.freeze([`font-family`]),variableAliasRefs:[P(`font-family`,!0)]}),F({properties:Object.freeze([`font-size`]),variableAliasRefs:[P(`font-size`,!0)]}),F({properties:Object.freeze([`font-weight`]),variableAliasRefs:[P(`font-weight`,!0)]}),F({properties:Object.freeze([`letter-spacing`]),variableAliasRefs:[P(`tracking`)]}),F({properties:Object.freeze([`line-height`]),variableAliasRefs:[P(`leading`)]}),F({properties:Object.freeze([`order`]),variableAliasRefs:[P(`order`,!0)]})]),vt={":first":[{value:`first-child`,type:`pseudo-class`}],":last":[{value:`last-child`,type:`pseudo-class`}],":even":[{value:`nth-child`,type:`pseudo-class`,children:[{value:`2n`}]}],":odd":[{value:`nth-child`,type:`pseudo-class`,children:[{value:`odd`}]}],":only":[{value:`only-child`,type:`pseudo-class`}],":rtl":[{value:`dir`,type:`pseudo-class`,children:[{value:`rtl`}]}],":ltr":[{value:`dir`,type:`pseudo-class`,children:[{value:`ltr`}]}],"::scrollbar":[{value:`-webkit-scrollbar`,type:`pseudo-element`}],"::scrollbar-thumb":[{value:`-webkit-scrollbar-thumb`,type:`pseudo-element`}],"::scrollbar-track":[{value:`-webkit-scrollbar-track`,type:`pseudo-element`}],"::slider-thumb":[{value:`-webkit-slider-thumb`,type:`pseudo-element`}],"::slider-runnable-track":[{value:`-webkit-slider-runnable-track`,type:`pseudo-element`}],"::resizer":[{value:`-webkit-resizer`,type:`pseudo-element`}]},yt={rootSize:16,baseUnit:4,defaultMode:`light`,modeTrigger:`media`,modes:[`light`,`dark`]},bt=new WeakMap;function xt(e){if(!e||e.version!==1)throw TypeError(`Unsupported MasterCSSManifest version. Expected version 1.`);if(Array.isArray(e.variables))throw TypeError(`Unsupported MasterCSSManifest variables format. Expected namespace-grouped variables.`);if(`utilityBuckets`in e)throw TypeError(`Unsupported MasterCSSManifest utilityBuckets field. Matcher indexes are engine-derived.`)}function St(e,t){for(let n of t)e.includes(n)||e.push(n)}function Ct(e){let t=e.keys?[...e.keys]:[],n=e.aliasGroups?[...e.aliasGroups]:[];for(let r of e.matchers)r.type===`key`?St(t,r.keys):(r.type===`variable`||r.type===`value`)&&St(n,r.keys);t.length&&!e.keys&&(e.keys=t),n.length&&!e.aliasGroups&&(e.aliasGroups=n),e.key||=t[0]||n[0]}function wt(e){return e.emit.type===`property`&&e.id===e.emit.property&&e.name===e.emit.property&&!e.variableAliasRefs?.length&&!e.variableAliases?.length&&!e.kind&&!e.conditions?.length}function Tt(e,t){let n=e.startsWith(`-`),r=n?e.slice(1):e;if(r!==t&&!r.startsWith(t+`-`))return;let i=r===t?``:r.slice(t.length+1);return n?`-`+i:i}function I(e){for(let t=0;t<e.length;t++)if(h.has(e[t]))return!1;return!0}function L(e,t,n){let r=e.get(t);r?r.includes(n)||r.push(n):e.set(t,[n])}function R(e,t){let n=new Map;for(let r of e)for(let e of r.matchers)if(e.type===t)for(let t of e.keys)L(n,t,r);return n}function Et(e){let t=new Map;for(let n of e)for(let e of n.matchers)if(e.type===`pattern`)for(let r of e.values){let i=e.prefix+r;I(i)&&L(t,i,n)}return t}function Dt(e){return e.every(e=>e.matchers.every(e=>e.type!==`pattern`||e.values.every(t=>I(e.prefix+t))))}function Ot(e){let t=new Map;for(let n of e)for(let e of n.matchers)e.type===`static`&&I(e.name)&&L(t,e.name,n);return t}function kt(e){return e.every(e=>e.matchers.length&&e.matchers.every(e=>e.type===`static`&&I(e.name)))}function At(e){return{...yt,...e.settings||{},modes:e.settings?.modes?[...e.settings.modes]:[...yt.modes]}}function jt(e){return{...e,modes:[...e.modes]}}function Mt(){let e=new Map;for(let[t,n]of Object.entries(ut))t&&n&&t!==n&&e.set(t,n);return e}function Nt(e){let t=new Map;for(let n of lt(e.variables))!n.name||!n.type||n.value===!1||t.set(n.name,{name:n.name,key:n.key,type:n.type,...n.namespace?{namespace:n.namespace}:{},...n.value===void 0?{}:{value:Array.isArray(n.value)?n.value.join(`,`):n.value},...n.numeric?{numeric:{...n.numeric}}:{},...n.modes?{modes:{...n.modes}}:{},...n.dependencies?.length?{dependencies:new Set(n.dependencies)}:{},...n.inline?{inline:!0}:{},...n.static?{static:!0}:{}});return t}function Pt(e){let t=new Map;if(!e.animations)return t;for(let n in e.animations){let r={};t.set(n,r);let i=e.animations[n];for(let e in i){let t=r[e]={},n=i[e];for(let e in n)t[e]=n[e]}}return t}function z(e){let t=new Map;if(!e)return t;for(let[n,r]of Object.entries(e))t.set(n,{id:r.id,nodes:r.nodes});return t}function Ft(e){let t=new Map;for(let[e,n]of Object.entries(vt))t.set(e,B(n));if(e.selectors)for(let[n,r]of Object.entries(e.selectors))t.set(n,B(r));let n=new Map;for(let t of e.variants||[])n.set(t.token,t.branches.map(e=>({...e,...e.selectorNodes?.length?{selectorNodes:e.selectorNodes}:{},...e.conditions?.length?{conditions:[...e.conditions]}:{},...e.conditionNodes?.length?{conditionNodes:e.conditionNodes.map(e=>({id:e.id,nodes:e.nodes}))}:{}})));return{selectors:t,variants:n}}function B(e){return e.map(e=>`children`in e&&e.children?.length?{...e,children:B(e.children)}:{...e})}function It(e){let t=new Map;return n=>{let r=t.get(n);if(r)return r;let i=n[0]===`=`||n[0]===`~`?n.slice(1):``,a=[],o=new Set;if(i)for(let t of e.values()){let e=Tt(t.name,i);e===void 0||o.has(e)||(o.add(e),a.push([e,t.name]))}return t.set(n,a),a}}function Lt(e,t,n,r=0,i=1){let a={...e,name:e.name||e.id,order:e.order??i-r-1,layer:e.layer||`utilities`,matchers:e.matchers.map(e=>({...e}))},o=[...e.variableAliases||[],...(e.variableAliasRefs||[]).flatMap(n)];if(o.length){a.variables=new Map;for(let[e,n]of o){if(a.variables.has(e))continue;let r=t.get(n);r&&a.variables.set(e,r)}}return Ct(a),a}function Rt(e,t){return{id:e,name:e,type:st(e)?u.Shorthand:u.Normal,order:0,variableAliasRefs:[...t.variableAliasRefs],emit:{type:`property`,property:e},matchers:[{type:`key`,keys:[e]}]}}function zt(e,t){let n=new Map;for(let r of _t)if(!(!r.properties?.length||!r.variableAliasRefs?.length))for(let i of r.properties){if(!i||n.has(i))continue;let a=Lt(Rt(i,r),e,t);n.set(i,a)}return n}function Bt(e,t){let n=wt(t);for(let r of t.matchers)if(!(r.type!==`key`&&r.type!==`value`&&r.type!==`variable`))for(let i of r.keys)n&&i===t.emit.property||e.add(i)}function V(e,t){e.includes(t)||e.push(t)}function Vt(e,t){for(let n of e.matchers)switch(n.type){case`variable`:(e.variableAliases?.length||e.variableAliasRefs?.length)&&V(t.variableMatcherUtilities,e);break;case`value`:e.kind&&V(t.valueMatcherUtilities,e);break;case`key`:V(t.keyMatcherUtilities,e);break;case`pattern`:V(t.patternMatcherUtilities,e);break;default:V(t.arbitraryMatcherUtilities,e);break}}function Ht(e,t,n){let r=[],i=[],a=[],o=[],s=[],c=[],l=new Set,u=e.utilities||[];for(let e=0;e<u.length;e++){let d=u[e],f=Lt(d,t,n,e,u.length);Bt(l,f),r.push(f),Vt(f,{variableMatcherUtilities:i,valueMatcherUtilities:a,keyMatcherUtilities:o,patternMatcherUtilities:s,arbitraryMatcherUtilities:c})}return{definedUtilities:r,variableMatcherUtilities:i,valueMatcherUtilities:a,keyMatcherUtilities:o,patternMatcherUtilities:s,arbitraryMatcherUtilities:c,variableMatcherIndex:R(i,`variable`),valueMatcherIndex:R(a,`value`),keyMatcherIndex:R(o,`key`),patternMatcherIndex:Dt(s)?Et(s):void 0,arbitraryStaticMatcherIndex:kt(c)?Ot(c):void 0,nativeDeclarationFastPathBlockedProperties:l}}function Ut(e){xt(e);let t=At(e),n=Nt(e),r=Pt(e),{selectors:i,variants:a}=Ft(e),o=It(n),s=zt(n,o),c=Ht(e,n,o);return{manifest:e,settings:t,definedUtilities:c.definedUtilities,variableMatcherUtilities:c.variableMatcherUtilities,valueMatcherUtilities:c.valueMatcherUtilities,keyMatcherUtilities:c.keyMatcherUtilities,patternMatcherUtilities:c.patternMatcherUtilities,arbitraryMatcherUtilities:c.arbitraryMatcherUtilities,variableMatcherIndex:c.variableMatcherIndex,valueMatcherIndex:c.valueMatcherIndex,keyMatcherIndex:c.keyMatcherIndex,patternMatcherIndex:c.patternMatcherIndex,arbitraryStaticMatcherIndex:c.arbitraryStaticMatcherIndex,selectors:i,variables:n,modes:[...t.modes],conditions:z(e.conditions),variants:a,breakpointConditions:z(e.breakpointConditions),containerConditions:z(e.containerConditions),animations:r,nativeDeclarationFastPathBlockedProperties:c.nativeDeclarationFastPathBlockedProperties,nativeValueNamespaceUtilities:s,keyAliases:Mt()}}function Wt(e){let t=bt.get(e);if(t)return t;let n=Ut(e);return bt.set(e,n),n}const H={id:`group`,name:`group`,type:u.Shorthand,order:0,emit:{type:`group`},matchers:[]};function U(e){return e===void 0||!/[a-zA-Z0-9-]/.test(e)}function W(e,t){for(let n of t){let t=n+`:`;if(e.startsWith(t)&&e.length>t.length)return e.slice(t.length)}}function G(e,t){if(!e.startsWith(t))return!1;let n=e[t.length];return n===void 0||n===`!`||n===`*`||n===`>`||n===`+`||n===`~`||n===`:`||n===`[`||n===`@`||n===`_`||n===`.`}function K(e){return/^-{0,2}([_a-zA-Z][-_a-zA-Z0-9]*)\(/.exec(e)?.[1]}function Gt(e){let t=K(e);return t===`calc`||t===`clamp`||t===`min`||t===`max`}function Kt(e){let t=K(e);return t?t===`url`||t===`element`||t===`paint`||t===`cross-fade`||t.endsWith(`-gradient`)||t.includes(`image`):!1}function qt(e){return!!K(e)&&!Gt(e)&&!Kt(e)}function Jt(e){let t=0,n=``;for(let r=0;r<e.length;r++){let i=e[r];if(n){i===`\\`?r++:i===n&&(n=``);continue}if(i===`"`||i===`'`){n=i;continue}if(i===`(`||i===`[`||i===`{`){t++;continue}if(i===`)`||i===`]`||i===`}`){t>0&&t--;continue}if(i===`|`&&t===0)return!0}return!1}function Yt(e,t){return t.type!==`variable`&&t.type!==`value`||t.segments===`multiple`||!Jt(e)}function q(e){if(e[0]===`{`)return;let t=e.indexOf(`:`);if(!(t<=0))return e.slice(0,t)}function J(e){for(let t=0;t<e.length;t++)if(h.has(e[t]))return t?e.slice(0,t):e;return e}var Xt=class e{options;definedUtilities=[];variableMatcherUtilities=[];valueMatcherUtilities=[];keyMatcherUtilities=[];patternMatcherUtilities=[];arbitraryMatcherUtilities=[];variableMatcherIndex=new Map;valueMatcherIndex=new Map;keyMatcherIndex=new Map;patternMatcherIndex;arbitraryStaticMatcherIndex;settings;rules=[];classUtilities=new Map;animationsNonLayer=new at(this);baseLayer=new N(`base`,this);themeLayer=new et(`theme`,this);defaultsLayer=new N(`defaults`,this);componentsLayer=new N(`components`,this);utilitiesLayer=new N(`utilities`,this);selectors=new Map;variables=new Map;modes=[];conditions=new Map;variants=new Map;breakpointConditions=new Map;containerConditions=new Map;animations=new Map;staticVariableTokens=new Set;staticAnimationTokens=new Set;emittedGlobals={variables:{},animations:{}};nativeDeclarationFastPathBlockedProperties=new Set;nativeDeclarationMatches=new Map;nativeDeclarationUtilities=new Map;nativeValueNamespaceUtilities=new Map;keyAliases=new Map;manifest;static create(e){let{manifest:t,emittedGlobals:n,...r}=e;return new this(t,n,r)}constructor(t,n,r={}){this.options=r,this.loadManifest(t),this.registerEmittedGlobals(n),new.target===e&&this.insertStaticResources()}get text(){return this.rules.sort((e,t)=>{let n=[`theme`,`base`,`defaults`,`components`,`utilities`];return(n.indexOf(e.name)===-1?1/0:n.indexOf(e.name))-(n.indexOf(t.name)===-1?1/0:n.indexOf(t.name))}).map(({text:e})=>e).join(``)}getUtilityLayer(e=`utilities`){switch(e){case`base`:return this.baseLayer;case`defaults`:return this.defaultsLayer;case`components`:return this.componentsLayer;case`utilities`:return this.utilitiesLayer;default:throw Error(`Unsupported utility layer: ${e}`)}}getUtilityLayers(){return[this.baseLayer,this.defaultsLayer,this.componentsLayer,this.utilitiesLayer]}loadManifest(e){let t=Wt(e);this.manifest=t.manifest,this.settings=jt(t.settings),this.definedUtilities=t.definedUtilities,this.variableMatcherUtilities=t.variableMatcherUtilities,this.valueMatcherUtilities=t.valueMatcherUtilities,this.keyMatcherUtilities=t.keyMatcherUtilities,this.patternMatcherUtilities=t.patternMatcherUtilities,this.arbitraryMatcherUtilities=t.arbitraryMatcherUtilities,this.variableMatcherIndex=t.variableMatcherIndex,this.valueMatcherIndex=t.valueMatcherIndex,this.keyMatcherIndex=t.keyMatcherIndex,this.patternMatcherIndex=t.patternMatcherIndex,this.arbitraryStaticMatcherIndex=t.arbitraryStaticMatcherIndex,this.selectors=t.selectors,this.variables=t.variables,this.modes=[...t.modes],this.conditions=t.conditions,this.variants=t.variants,this.breakpointConditions=t.breakpointConditions,this.containerConditions=t.containerConditions,this.animations=t.animations,this.nativeDeclarationFastPathBlockedProperties=t.nativeDeclarationFastPathBlockedProperties,this.nativeValueNamespaceUtilities=t.nativeValueNamespaceUtilities,this.keyAliases=t.keyAliases}applyEmittedGlobalsCounts(e){for(let[t,n]of Object.entries(e.variables||{}))n&&this.themeLayer.tokenCounts.set(t,(this.themeLayer.tokenCounts.get(t)||0)+n);for(let[t,n]of Object.entries(e.animations||{}))n&&this.animationsNonLayer.tokenCounts.set(t,(this.animationsNonLayer.tokenCounts.get(t)||0)+n)}registerEmittedGlobals(e){if(e){for(let[t,n]of Object.entries(e.variables||{}))n&&(this.emittedGlobals.variables[t]=(this.emittedGlobals.variables[t]||0)+n);for(let[t,n]of Object.entries(e.animations||{}))n&&(this.emittedGlobals.animations[t]=(this.emittedGlobals.animations[t]||0)+n);this.applyEmittedGlobalsCounts(e)}}isEmittedGlobalsVariable(e){return!!this.emittedGlobals.variables[e]}isEmittedGlobalsAnimation(e){return!!this.emittedGlobals.animations[e]}insertStaticVariable(e,t=new Set){if(t.has(e))return;t.add(e);let n=this.variables.get(e);if(!(!n||n.inline)){if(!this.staticVariableTokens.has(e)){if(!this.isEmittedGlobalsVariable(e)){this.themeLayer.get(e)||this.themeLayer.insert(new M(e,n,this));let t=this.themeLayer.tokenCounts.get(e)||0;this.themeLayer.tokenCounts.set(e,t+1)}this.staticVariableTokens.add(e)}n.dependencies?.forEach(e=>this.insertStaticVariable(e,t))}}insertStaticAnimation(e){if(this.staticAnimationTokens.has(e))return;let t=this.animations.get(e);if(!t)return;let n=this.animationsNonLayer.rules.find(t=>t.name===e);if(this.isEmittedGlobalsAnimation(e))n||=new j(e,t,this);else{n||(n=new j(e,t,this),this.animationsNonLayer.insert(n));let r=this.animationsNonLayer.tokenCounts.get(e)||0;this.animationsNonLayer.tokenCounts.set(e,r+1)}this.staticAnimationTokens.add(e),n.variableNames?.forEach(e=>this.insertStaticVariable(e))}insertStaticResources(){for(let[e,t]of this.variables)t.static&&this.insertStaticVariable(e);for(let e of this.animations.keys())this.manifest.animationOptions?.[e]?.static&&this.insertStaticAnimation(e);return this}resolveVariant(e){return this.variants.get(e)}parseValue(e,t=``){return ee(e,t,this.settings.rootSize)}matchesMatcher(e,t,n){switch(n.type){case`static`:return G(e,n.name);case`key`:return W(e,n.keys)!==void 0;case`variable`:{let r=W(e,n.keys);if(r===void 0||!t.variables?.size||!Yt(r,n))return!1;for(let[e,n]of t.variables){if(r.startsWith(e)&&U(r[e.length]))return!0;let t=`-`+e;if(e[0]!==`-`&&n.type===`number`&&r.startsWith(t)&&U(r[t.length]))return!0}return!1}case`value`:{let r=W(e,n.keys);if(r===void 0||!Yt(r,n))return!1;switch(t.kind){case`color`:return r[0]===`#`||qt(r)||r.startsWith(`currentColor`)&&U(r[12])||r.startsWith(`transparent`)&&U(r[11]);case`number`:return/[\d.]/.test(r[0])||Gt(r);case`image`:return Kt(r);default:return!1}}case`pattern`:return n.values.some(t=>G(e,n.prefix+t))}}matchesUtility(e,t,n){return t.matchers.some(r=>(!n||r.type===n)&&this.matchesMatcher(e,t,r))}matchesExactUtilityDefinition(e,t){return t.matchers.some(t=>t.type===`static`&&G(e,t.name))}hasClassKey(e){let t=q(e);return!!(t&&!t.startsWith(`--`))}isGroupClassName(e){return e[0]===`{`&&e.includes(`}`)}getClassKeyAlias(e){let t=q(e);if(!t||t.startsWith(`--`))return;let n=this.keyAliases.get(t);if(n)return{canonicalKey:n,indexOfColon:t.length,key:t}}canonicalizeClassName(e,t){let n=this.getClassKeyAlias(e);return n?{className:n.canonicalKey+e.slice(n.indexOfColon),fixedClass:t}:{className:e,fixedClass:t}}matchResolvedClassName(e){let t=q(e);for(let n of t&&this.variableMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`variable`))return n;for(let n of t&&this.valueMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`value`))return n;for(let n of t&&this.keyMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`key`))return n;if(this.arbitraryStaticMatcherIndex){for(let t of this.arbitraryStaticMatcherIndex.get(J(e))||[])if(this.matchesUtility(e,t))return t}else for(let t of this.arbitraryMatcherUtilities)if(this.matchesUtility(e,t))return t;if(this.patternMatcherIndex){for(let t of this.patternMatcherIndex.get(J(e))||[])if(this.matchesUtility(e,t,`pattern`))return t}else for(let t of this.patternMatcherUtilities)if(this.matchesUtility(e,t,`pattern`))return t}createGroupUtility(e,t,n,r=0){if(this.isGroupClassName(e))return this.createRuleWithDefinition(e,H,t,n,r)}createAllGroupUtilities(e,t,n){let r=this.createGroupUtility(e,t,n);if(!r?.valid)return[];let i=[r];for(let a=1;a<r.branchCount;a++){let r=this.createGroupUtility(e,t,n,a);r?.valid&&i.push(r)}return i}matchRawManagedClassName(e){let t=q(e);if(t){for(let n of this.variableMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`variable`))return n;for(let n of this.valueMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`value`))return n;for(let n of this.keyMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`key`))return n;if(this.patternMatcherIndex){for(let t of this.patternMatcherIndex.get(J(e))||[])if(this.matchesUtility(e,t,`pattern`))return t}else for(let t of this.patternMatcherUtilities)if(this.matchesUtility(e,t,`pattern`))return t}}match(e){if(this.isGroupClassName(e))return H;if(this.hasClassKey(e)){let t=this.matchRawManagedClassName(e);if(t)return t}return this.matchResolvedClassName(this.canonicalizeClassName(e).className)}matchAllResolvedClassName(e){let t=q(e);for(let n of t&&this.variableMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`variable`))return[n];for(let n of t&&this.valueMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`value`))return[n];for(let n of t&&this.keyMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`key`))return[n];let n=[];if(this.arbitraryStaticMatcherIndex)for(let t of this.arbitraryStaticMatcherIndex.get(J(e))||[])this.matchesUtility(e,t)&&n.push(t);else for(let t of this.arbitraryMatcherUtilities)if(this.matchesUtility(e,t)){if(t.matchers.some(e=>e.type===`static`)){n.push(t);continue}return[t]}if(n.length)return n;if(this.patternMatcherIndex){for(let t of this.patternMatcherIndex.get(J(e))||[])if(this.matchesUtility(e,t,`pattern`))return[t]}else for(let t of this.patternMatcherUtilities)if(this.matchesUtility(e,t,`pattern`))return[t];return[]}matchAllRawManagedClassName(e){let t=q(e);if(!t)return[];for(let n of this.variableMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`variable`))return[n];for(let n of this.valueMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`value`))return[n];for(let n of this.keyMatcherIndex.get(t)||[])if(this.matchesUtility(e,n,`key`))return[n];if(this.patternMatcherIndex){for(let t of this.patternMatcherIndex.get(J(e))||[])if(this.matchesUtility(e,t,`pattern`))return[t]}else for(let t of this.patternMatcherUtilities)if(this.matchesUtility(e,t,`pattern`))return[t];return[]}matchAll(e){if(this.isGroupClassName(e))return[H];if(this.hasClassKey(e)){let t=this.matchAllRawManagedClassName(e);if(t.length)return t}return this.matchAllResolvedClassName(this.canonicalizeClassName(e).className)}parseNativeDeclarationProperty(e){let t=e.indexOf(`:`);if(t<=0)return;let n=e.slice(0,t);if(/^(?:--[-_a-zA-Z0-9]+|-?[_a-zA-Z][-_a-zA-Z0-9]*)$/.test(n))return n}getNativeDeclarationUtility(e){let t=this.nativeDeclarationUtilities.get(e);if(t)return t;let n={id:e,name:e,type:st(e)?u.Shorthand:u.Normal,order:0,emit:{type:`property`,property:e},matchers:[{type:`key`,keys:[e]}]};return this.nativeDeclarationUtilities.set(e,n),n}matchNativeDeclaration(e){if(e.property.startsWith(`--`))return!0;let t=this.options.nativeDeclarationMatcher;if(!t)return!1;let n=e.property+`\0`+e.value,r=this.nativeDeclarationMatches.get(n);if(r!==void 0)return r;let i=t(e);return this.nativeDeclarationMatches.set(n,i),i}isNativeDeclarationUtility(e){let t=Object.entries(e.declarations||{});if(t.length!==1)return!1;let[[n,r]]=t;return this.matchNativeDeclaration({property:n,value:String(r)})}shouldValidateNativeDeclarationUtility(e){return this.options.nativeDeclarationMatcher?wt(e)&&e.matchers.every(e=>e.type===`key`):!1}createNativeDeclarationFallback(e,t,n,r=e){if(!this.options.nativeDeclarationMatcher)return[];let i=this.parseNativeDeclarationProperty(e);if(!i)return[];let a=this.getNativeDeclarationUtility(i),o=this.createRuleWithDefinition(r,a,t,n);if(!o?.valid||!this.isNativeDeclarationUtility(o))return[];let s=[o];for(let e=1;e<o.branchCount;e++){let i=this.createRuleWithDefinition(r,a,t,n,e);i?.valid&&this.isNativeDeclarationUtility(i)&&s.push(i)}return s}createNativeValueNamespaceFallback(e,t,n,r=e){let i=this.parseNativeDeclarationProperty(e);if(!i)return[];let a=this.nativeValueNamespaceUtilities.get(i);if(!a)return[];let o=this.createRuleWithDefinition(r,a,t,n);if(!o?.valid||this.options.nativeDeclarationMatcher&&!this.isNativeDeclarationUtility(o))return[];let s=[o];for(let e=1;e<o.branchCount;e++){let i=this.createRuleWithDefinition(r,a,t,n,e);i?.valid&&(!this.options.nativeDeclarationMatcher||this.isNativeDeclarationUtility(i))&&s.push(i)}return s}createNativeValueNamespaceFastPath(e,t,n,r=e){let i=this.parseNativeDeclarationProperty(e);return!i||this.nativeDeclarationFastPathBlockedProperties.has(i)?[]:this.createNativeValueNamespaceFallback(e,t,n,r)}createNativeDeclarationFastPath(e,t,n,r=e){let i=this.parseNativeDeclarationProperty(e);return!i||!i.startsWith(`--`)&&this.nativeDeclarationFastPathBlockedProperties.has(i)?[]:this.createNativeDeclarationFallback(e,t,n,r)}generate(e,t){return this.createRules(e,void 0,t)}createRule(e,t,n){let r=this.createGroupUtility(e,t,n);if(r)return r;let i=e;if(this.hasClassKey(e)){let r=this.matchRawManagedClassName(e);if(r){let e=this.createRuleWithDefinition(i,r,t,n);if(e?.valid)return e}}let a=this.canonicalizeClassName(e,t);e=a.className,t=a.fixedClass;let o=this.matchResolvedClassName(i);if(o&&!this.matchesExactUtilityDefinition(i,o)){let e=this.createRuleWithDefinition(i,o,t,n);if(e?.valid)return e;if(e?.invalidValueSyntax)return}let s=this.createNativeValueNamespaceFastPath(e,t,n,i);if(s.length)return s[0];let c=this.createNativeDeclarationFastPath(e,t,n,i);if(c.length)return c[0];let l=this.matchResolvedClassName(e);if(l&&this.matchesExactUtilityDefinition(e,l)){let r=this.createNativeValueNamespaceFallback(e,t,n,i);if(r.length)return r[0];let a=this.createNativeDeclarationFallback(e,t,n,i);if(a.length)return a[0]}return l?this.createRuleWithDefinition(i,l,t,n):this.createNativeValueNamespaceFallback(e,t,n,i)[0]||this.createNativeDeclarationFallback(e,t,n,i)[0]}createRules(e,t,n){let r=this.createAllGroupUtilities(e,t,n);if(r.length)return r;let i=e;if(this.hasClassKey(e)){let r=this.matchAllRawManagedClassName(e),a=[];for(let e of r){let r=this.createRuleWithDefinition(i,e,t,n);if(r&&r.valid){a.push(r);for(let o=1;o<r.branchCount;o++){let r=this.createRuleWithDefinition(i,e,t,n,o);r?.valid&&a.push(r)}}}if(a.length)return a}let a=this.canonicalizeClassName(e,t);e=a.className,t=a.fixedClass;let o=this.matchAllResolvedClassName(i);if(o.length&&o.some(e=>!this.matchesExactUtilityDefinition(i,e))){let e=[],r=!1;for(let a of o){if(this.matchesExactUtilityDefinition(i,a))continue;let o=this.createRuleWithDefinition(i,a,t,n);if(o?.valid){e.push(o);for(let r=1;r<o.branchCount;r++){let o=this.createRuleWithDefinition(i,a,t,n,r);o?.valid&&e.push(o)}}else o?.invalidValueSyntax&&(r=!0)}if(e.length)return e;if(r)return[]}let s=this.createNativeValueNamespaceFastPath(e,t,n,i);if(s.length)return s;let c=this.createNativeDeclarationFastPath(e,t,n,i);if(c.length)return c;let l=this.matchAllResolvedClassName(e);if(l.length&&l.every(t=>this.matchesExactUtilityDefinition(e,t))){let r=this.createNativeValueNamespaceFallback(e,t,n,i);if(r.length)return r;let a=this.createNativeDeclarationFallback(e,t,n,i);if(a.length)return a}let u=[];for(let e of l){let r=this.createRuleWithDefinition(i,e,t,n);if(r&&r.valid){u.push(r);for(let a=1;a<r.branchCount;a++){let r=this.createRuleWithDefinition(i,e,t,n,a);r?.valid&&u.push(r)}}}if(u.length)return u;let d=this.createNativeValueNamespaceFallback(e,t,n,i);return d.length?d:this.createNativeDeclarationFallback(e,t,n,i)}createRuleWithDefinition(e,t,n,r,i=0){let a=new O(e,this,t,n,r,i);if(!(a.valid&&this.shouldValidateNativeDeclarationUtility(t)&&!this.isNativeDeclarationUtility(a))){for(let e of this.getUtilityLayers()){let n=e.get(a.key),r=n instanceof O&&n.registeredUtility===t?n:void 0;if(r)return r}return a}}createRulesFromSelectorText(e,t){let n=e.split(` `),r=/[.#\[!\*>+~:,\s]/;for(let e=0;e<n.length;e++){let i=n[e],a=this.getModeSelector(i);if(!(e===0&&i===a||(e===0||e===1)&&i===this.settings.scope)&&i.startsWith(`.`)){let e=i.slice(1),n=``,a=0;for(;a<e.length;){let t=e[a],i=e[a+1];if(t===`\\`&&i){n+=i,a+=2;continue}if(r.test(t))break;n+=t,a++}let o=this.generate(n).filter(e=>!t||e.layerName===t);if(o.length)return o}}}refresh(e=this.manifest){return this.reset(),this.loadManifest(e),this.applyEmittedGlobalsCounts(this.emittedGlobals),this.insertStaticResources(),this}reset(){return this.classUtilities.clear(),this.staticVariableTokens.clear(),this.staticAnimationTokens.clear(),this.baseLayer.reset(),this.themeLayer.reset(),this.defaultsLayer.reset(),this.componentsLayer.reset(),this.utilitiesLayer.reset(),this.animationsNonLayer.reset(),this}destroy(){return this.reset(),this}ensureClassRules(...e){for(let t of e){if(this.classUtilities.get(t))continue;let e=this.generate(t);e.length&&(e.forEach(e=>e.layer.insert(e)),this.classUtilities.set(t,e))}return this}deleteClassRules(...e){for(let t of e){let e=this.classUtilities.get(t);e&&(e.forEach(e=>e.layer.delete(e.key)),this.classUtilities.delete(t))}}getModeSelector(e){switch(this.settings.modeTrigger){case`class`:return`.`+e;case`host`:return`:host(.`+e+`)`}}};const Y=`master-css`;function Zt(e){globalThis.MasterCSSRuntime||(globalThis.MasterCSSRuntime=e)}function X(e,t){for(let n=0;n<e.length;n++)if(e[n]===t)return n;return-1}function Qt(e){let t=e.nodes;return Array.isArray(t)?t:void 0}var $t=class extends A{name;cssRuntime;rules=[];tokenCounts=new Map;native=null;constructor(e,t){super(e,t),this.name=e,this.cssRuntime=t}attach(){super.attach();let e=this.cssRuntime.style?.sheet;if(e&&!this.native?.parentStyleSheet){let t=e.insertRule(this.text,e.cssRules.length);this.native=e.cssRules.item(t)}}insert(e,t=this.rules.length){let n=!!this.native?.parentStyleSheet,r=this.rules.length===0,i=super.insert(e,t);if(i===void 0||!this.native)return;let a=this.getNativeInsertIndex(i),o=!n&&r,s=(t,n)=>{if(o)return this.native.cssRules.item(n);try{let e=this.native.insertRule(t,n);return this.native.cssRules.item(e)}catch(t){console.error(t,e),this.rules.splice(i,1);return}},c=Qt(e);if(c){let e=a;c.forEach(t=>{t.native=s(t.text,e),t.native&&e++})}else e.native=s(e.text,a);return i}getNativeInsertIndex(e){let t=0;for(let n=0;n<e;n++){let e=this.rules[n];t+=Qt(e)?.length??1}return t}detach(){super.detach();let e=this.cssRuntime.style?.sheet;if(e&&this.native?.parentStyleSheet){let t=X(e.cssRules,this.native);t!==-1&&e.deleteRule(t)}}delete(e){let t=super.delete(e);if(!t||!this.native)return;let n=e=>{if(!e)return;let t=X(this.native.cssRules,e);if(t!==-1)try{this.native.deleteRule(t)}catch(t){console.error(t,e)}},r=Qt(t);return r?r.forEach(e=>n(e.native)):n(t.native),t}reset(){super.reset();let e=this.cssRuntime.style?.sheet;if(this.native&&e){let t=X(e.cssRules,this.native);t!==-1&&e.deleteRule(t),this.native=null}}};function en(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1,a=e[i];if(!(`priority`in a))return tn(e,t);C(t,a)<0?r=i:n=i+1}return n}function tn(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(`priority`in r&&C(t,r)<0)return n}return e.length}var Z=class extends $t{rules=[];insert(e){if(this.get(e.key)||`valid`in e&&!e.valid)return;let t=this.rules.length;`priority`in e&&(t=en(this.rules,e));let n=super.insert(e,t);if(n!==void 0)return this.insertVariables(e),this.insertAnimations(e),n}delete(e){let t=super.delete(e);if(!t)return;let n=(e,t,r=new Set)=>{if(r.has(e))return;r.add(e);let i=t.tokenCounts.get(e)??0,a=t===this.css.themeLayer?this.css.variables.get(e):void 0;if(i<=1){let i=t.delete(e);return t.tokenCounts.delete(e),a?.dependencies?.forEach(e=>n(e,t,r)),i}else t.tokenCounts.set(e,i-1),a?.dependencies?.forEach(e=>n(e,t,r))};return`variableNames`in t&&t.variableNames?.forEach(e=>{n(e,this.css.themeLayer)}),`animationNames`in t&&t.animationNames?.forEach(e=>{let t=n(e,this.css.animationsNonLayer),r=t&&`variableNames`in t?t.variableNames:void 0;r&&r.forEach(e=>{n(e,this.css.themeLayer)})}),t}insertVariables(e){if(!(`variableNames`in e))return;let t=(e,n=new Set)=>{if(n.has(e))return;n.add(e);let r=this.css.variables.get(e);if(!(!r||r.inline)){if(this.css.themeLayer.rules.find(({name:t})=>t===e)||this.css.isEmittedGlobalsVariable(e)){let t=this.css.themeLayer.tokenCounts.get(e)||0;this.css.themeLayer.tokenCounts.set(e,t+1)}else{let t=new M(e,r,this.css);this.css.themeLayer.insert(t),this.css.themeLayer.tokenCounts.set(e,1)}r.dependencies?.forEach(e=>t(e,n))}};e.variableNames?.forEach(e=>t(e))}insertAnimations(e){`animationNames`in e&&e.animationNames?.forEach(e=>{let t=this.css.animationsNonLayer.rules.find(({name:t})=>t===e);if(t||this.css.isEmittedGlobalsAnimation(e)){let n=this.css.animationsNonLayer.tokenCounts.get(e)||0;this.css.animationsNonLayer.tokenCounts.set(e,n+1),t&&this.insertVariables(t)}else{let t=this.css.animations.get(e);if(!t)return;let n=new j(e,t,this.css);this.css.animationsNonLayer.insert(n),this.css.animationsNonLayer.tokenCounts.set(e,1),this.insertVariables(n)}})}},nn=class extends et{name;cssRuntime;native=null;nativeBuckets=new Map;constructor(e,t){super(e,t),this.name=e,this.cssRuntime=t}attach(){super.attach();let e=this.cssRuntime.style?.sheet;if(e&&!this.native?.parentStyleSheet){let t=e.insertRule(this.text,e.cssRules.length);this.native=e.cssRules.item(t),this.syncNativeBuckets()}}getBucketKey(e,t){let n=e.replace(/\s*:\s*/g,`:`).replace(/\s+/g,` `).trim(),r=t.replace(/\s*,\s*/g,`,`).replace(/\s+/g,` `).trim();return n+`
|
|
3
|
+
`+r}setBucketSyntheticDeclarations(e,t){for(let{name:n,value:r}of this.getBucketSyntheticDeclarations({mediaText:e.mediaText,mode:t,selectorText:e.selectorText}))e.styleRule.style.setProperty(n,r)}hasVariableDeclarations(e){for(let t=0;t<e.style.length;t++)if(e.style.item(t).startsWith(`--`))return!0;return!1}getStyleRule(e){if(e instanceof CSSStyleRule)return e;if(e instanceof CSSGroupingRule)return e.cssRules.item(0)}syncNativeBuckets(){if(this.nativeBuckets.clear(),this.native)for(let e of this.native.cssRules){let t=this.getStyleRule(e);if(!t)continue;let n=e instanceof CSSMediaRule?e.conditionText:``,r=n?`@media ${n}`:``,i=this.getBucketKey(r,t.selectorText);this.nativeBuckets.set(i,{key:i,mediaText:r,selectorText:t.selectorText,nativeRule:e,styleRule:t})}}ensureNativeBucket(e,t,n){if(!this.native)return;let r=this.getBucketKey(e,t),i=this.nativeBuckets.get(r);if(i)return this.setBucketSyntheticDeclarations(i,n),i;let a=this.getBucketSyntheticDeclarations({mediaText:e,mode:n,selectorText:t}).map(({name:e,value:t})=>`${e}:${t}`).join(`;`),o=e?`${e}{${t}{${a}}}`:`${t}{${a}}`,s=this.native.insertRule(o,this.getNativeBucketInsertIndex(e,t)),c=this.native.cssRules.item(s);if(!c)return;let l=this.getStyleRule(c);if(!l)return;let u={key:r,mediaText:e,mode:n,selectorText:t,nativeRule:c,styleRule:l};return this.nativeBuckets.set(r,u),u}getNativeBucketInsertIndex(e,t){if(!this.native)return 0;let n={mediaText:e,selectorText:t};for(let e=0;e<this.native.cssRules.length;e++){let t=this.native.cssRules.item(e);if(!t)continue;let r=this.getStyleRule(t);if(!r)continue;let i=t instanceof CSSMediaRule?`@media ${t.conditionText}`:``;if(this.shouldInsertBucketBefore(n,{mediaText:i,selectorText:r.selectorText}))return e}return this.native.cssRules.length}insert(e,t=this.rules.length){let n=this.rules.length===0,r=super.insert(e,t);if(r===void 0||!this.native||n)return r;for(let t of e.nodes){let e=this.ensureNativeBucket(t.mediaText,t.selectorText,t.mode);e&&(this.setBucketSyntheticDeclarations(e,t.mode),e.styleRule.style.setProperty(t.declarationName,t.declarationValue),t.native=e.styleRule)}return r}delete(e){let t=this.rules.find(t=>t.key===e),n=super.delete(e);if(!t||!n||!this.native)return n;for(let e of t.nodes){let t=this.getBucketKey(e.mediaText,e.selectorText),n=this.nativeBuckets.get(t);if(n&&(n.styleRule.style.removeProperty(e.declarationName),!this.hasVariableDeclarations(n.styleRule))){let e=X(this.native.cssRules,n.nativeRule);e!==-1&&this.native.deleteRule(e),this.nativeBuckets.delete(t)}}return n}detach(){super.detach();let e=this.cssRuntime.style?.sheet;if(e&&this.native?.parentStyleSheet){let t=X(e.cssRules,this.native);t!==-1&&e.deleteRule(t)}this.native=null,this.nativeBuckets.clear()}reset(){super.reset();let e=this.cssRuntime.style?.sheet;if(this.native&&e){let t=X(e.cssRules,this.native);t!==-1&&e.deleteRule(t)}this.native=null,this.nativeBuckets.clear()}};function rn(e,t,n){let r=(e.get(t)||0)+n;r?e.set(t,r):e.delete(t)}function an(e,t,n){let r=[e];for(;r.length;){let e=r.pop();if(!t.has(e)){t.add(e),n(e);for(let t=e.lastElementChild;t;t=t.previousElementSibling)r.push(t)}}}var on=class{snapshots=new WeakMap;reset(){this.snapshots=new WeakMap}collectConnected(e,t){this.reset();let n=new Set;for(let r of e.querySelectorAll(`[class]`)){let e=this.snapshotElement(r);if(e)for(let r of e){let e=t.get(r)||0;e||n.add(r),t.set(r,e+1)}}return n}collectMutations(e){let t=new Map,n=new Map,r=new Set,i=new WeakSet,a=(e,t)=>{let r=(n.get(e)||0)+t;r?n.set(e,r):n.delete(e)};for(let t of e)if(t.type===`childList`){for(let e of t.addedNodes)e instanceof Element&&e.isConnected&&a(e,1);for(let e of t.removedNodes)e instanceof Element&&!e.isConnected&&a(e,-1)}else if(t.type===`attributes`&&t.attributeName===`class`){let e=t.target;e instanceof Element&&r.add(e)}for(let[e,r]of n)r>0?an(e,i,e=>this.diffElement(e,t)):r<0&&!e.isConnected&&an(e,i,e=>this.removeElement(e,t));for(let e of r)i.has(e)||this.diffElement(e,t);return t}snapshotElement(e){let t=e.classList;if(!t.length){this.snapshots.delete(e);return}let n=new Set;for(let e=0;e<t.length;e++)n.add(t.item(e));return this.snapshots.set(e,n),n}diffElement(e,t){let n=this.snapshots.get(e),r=e.classList,i;for(let e=0;e<r.length;e++){let a=r.item(e);n?.has(a)||rn(t,a,1),(i??=new Set).add(a)}if(n)for(let e of n)i?.has(e)||rn(t,e,-1);i?this.snapshots.set(e,i):this.snapshots.delete(e)}removeElement(e,t){let n=this.snapshots.get(e);if(n){for(let e of n)rn(t,e,-1);this.snapshots.delete(e)}}};function sn(e){let t=new Set;for(let n of e.matchAll(/var\(\s*--([_a-zA-Z0-9-]+)/g))t.add(n[1]);return t}var cn=class{text;native;constructor(e){this.text=e}},ln=class{ir;layer;native;name;key;layerName;type;sortTier;priority;text;valid=!0;fixedClass;nodes;variableNames;animationNames;selectorText;constructor(e,t){this.ir=e,this.layer=t,this.name=e.className,this.key=e.key,this.layerName=e.layer,this.type=e.type,this.sortTier=e.sortTier,this.priority=e.priority,this.text=e.text,this.selectorText=e.selectorText,e.nodes?.length&&(this.nodes=e.nodes.map(e=>new cn(e.text)));let n=sn(e.text);e.nodes?.forEach(e=>{sn(e.text).forEach(e=>n.add(e))}),e.variableNames?.forEach(e=>n.add(e)),n.size&&(this.variableNames=n),e.animationNames?.length&&(this.animationNames=new Set(e.animationNames))}};const un=new Map,dn=({property:e,value:t})=>{if(e.startsWith(`--`))return!0;let n=e+`\0`+t,r=un.get(n);if(r!==void 0)return r;let i=!!globalThis.CSS?.supports(e,t);return un.set(n,i),i},Q=`style#${Y}`;function $(e){let t=e?.constructor.name;return t===`HTMLDocument`||t===`Document`}function fn(e,t){return $(e)?e.getElementById(t):`querySelector`in e?e.querySelector(`#${t}`):void 0}function pn(e){return e?.version===1&&Array.isArray(e?.rules)?e:void 0}function mn(e){try{return pn(JSON.parse(e))}catch{}}function hn(e){let t=fn(e,`master-css-hydration-manifest`)?.textContent?.trim();if(t)return mn(t)}function gn(e){let t=fn(e,Y),n=globalThis.HTMLStyleElement;return n&&t instanceof n?t.getAttribute(`data-master-css-hydration-manifest`):void 0}function _n(e,t){let n=$(e)?e:e.ownerDocument;return new URL(t,n.baseURI).href}async function vn(e){return pn((await globalThis.Function(`specifier`,`return import(specifier, { with: { type: 'json' } })`)(e)).default)}var yn=class e extends Xt{root;hydrationManifest;static instances=new WeakMap;host;container;baseLayer=new Z(`base`,this);themeLayer=new nn(`theme`,this);defaultsLayer=new Z(`defaults`,this);componentsLayer=new Z(`components`,this);utilitiesLayer=new Z(`utilities`,this);classCounts=new Map;retainedClassNames=new Set;classTracker=new on;pendingAddedClassNames=new Set;pendingRemovedClassNames=new Set;retainedClassRules=new Map;pendingAdditionFrame;pendingRemovalFrame;pendingRemovalFlushFrame;retainedCleanupIdleHandle;retainedCleanupTimeoutHandle;hydrationFailureReason;observer;progressive=!1;observing=!1;static create(t){let{manifest:n,root:r=document,emittedGlobals:i,hydrationManifest:a}=t,o=a===void 0?hn(r):a,s=globalThis.MasterCSSRuntime.instances.get(r);return s?(s.registerEmittedGlobals(i),o!==void 0&&s.setHydrationManifest(o),s):new e(r,n,i,o).register()}constructor(e=document,t,n,r){super(t,n,{nativeDeclarationMatcher:dn}),this.root=e,this.hydrationManifest=r,$(e)?(this.container=e.head,this.host=e.documentElement):(this.container=this.root,this.host=this.root.host),this.applyEmittedGlobalsCounts({variables:this.emittedGlobals.variables})}register(){return globalThis.MasterCSSRuntime.instances.get(this.root),globalThis.MasterCSSRuntime.instances.set(this.root,this),$(this.root)&&(this.root.defaultView.globalThis.masterCSSRuntime=this),this}unregister(){return globalThis.MasterCSSRuntime.instances.delete(this.root),$(this.root)&&this.root.defaultView.globalThis.masterCSSRuntime===this&&(this.root.defaultView.globalThis.masterCSSRuntime=void 0),this}setHydrationManifest(e){return this.hydrationManifest=e,this}needsHydrationManifest(){return this.hydrationManifest===void 0&&!!gn(this.root)}async loadHydrationManifest(){let e=hn(this.root);if(e)return this.setHydrationManifest(e),this;let t=gn(this.root);if(!t)return this;try{this.setHydrationManifest(await vn(_n(this.root,t)))}catch{}return this}createRuntimeStyle(){let e=`createElement`in this.root?this.root:this.root.ownerDocument;this.style=e.createElement(`style`),this.style.id=Y,this.style.setAttribute(`blocking`,`render`),this.container.append(this.style)}warnHydrationFallback(e){console.warn(`Master CSS progressive hydration requires a matching hydration manifest. ${e} Rebuilding ${Q} with the runtime.`)}useRuntimeStyle(e,t){t&&this.warnHydrationFallback(t),this.style?.remove(),this.style=null,this.progressive=!1,this.createRuntimeStyle(),this.insertStaticResources(),e.forEach(e=>this.ensureClassRules(e))}detectRuntimeStyle(){if(this.root.styleSheets)for(let e of this.root.styleSheets){let{ownerNode:t}=e;if(t instanceof HTMLStyleElement&&t.id===`master-css`){this.style=t,this.progressive=!0;break}}}collectConnectedClasses(){return this.classTracker.collectConnected(this.root,this.classCounts)}hydrateRuntimeStyle(e){let t=this.style?.sheet&&this.hydrate(this.style.sheet.cssRules);if(t){let n=new Set(t.allUtilities.map(({fixedClass:e,name:t})=>e||t));for(let t of e)n.has(t)||this.ensureClassRules(t)}else this.useRuntimeStyle(e,this.hydrationFailureReason||`Cannot read ${Q} CSS rules.`)}renderRuntimeStyle(e){this.createRuntimeStyle(),this.insertStaticResources(),e.forEach(e=>this.ensureClassRules(e))}getAnimationFrameWindow(){return($(this.root)?this.root:this.root.ownerDocument)?.defaultView||globalThis}cancelPendingRemovalFrames(){let e=this.getAnimationFrameWindow();this.pendingRemovalFrame!==void 0&&(e.cancelAnimationFrame(this.pendingRemovalFrame),this.pendingRemovalFrame=void 0),this.pendingRemovalFlushFrame!==void 0&&(e.cancelAnimationFrame(this.pendingRemovalFlushFrame),this.pendingRemovalFlushFrame=void 0)}cancelPendingAdditionFrame(){this.pendingAdditionFrame!==void 0&&(this.getAnimationFrameWindow().cancelAnimationFrame(this.pendingAdditionFrame),this.pendingAdditionFrame=void 0)}clearPendingAddedClassNames(){this.pendingAddedClassNames.clear(),this.cancelPendingAdditionFrame()}clearPendingRemovedClassNames(){this.pendingRemovedClassNames.clear(),this.cancelPendingRemovalFrames()}getCleanupWindow(){return this.getAnimationFrameWindow()}cancelRetainedClassRuleCleanup(){let e=this.getCleanupWindow();this.retainedCleanupIdleHandle!==void 0&&(e.cancelIdleCallback?.(this.retainedCleanupIdleHandle),this.retainedCleanupIdleHandle=void 0),this.retainedCleanupTimeoutHandle!==void 0&&(e.clearTimeout(this.retainedCleanupTimeoutHandle),this.retainedCleanupTimeoutHandle=void 0)}clearRetainedClassRules(){this.retainedClassNames.clear(),this.retainedClassRules.clear(),this.cancelRetainedClassRuleCleanup()}cancelPendingRemovedClassNames(e){if(this.pendingRemovedClassNames.size){for(let t of e)this.pendingRemovedClassNames.delete(t);this.pendingRemovedClassNames.size||this.cancelPendingRemovalFrames()}}cancelPendingAddedClassNames(e){if(this.pendingAddedClassNames.size){for(let t of e)this.pendingAddedClassNames.delete(t);this.pendingAddedClassNames.size||this.cancelPendingAdditionFrame()}}cancelRetainedClassNames(e){if(this.retainedClassNames.size){for(let t of e)this.retainedClassNames.delete(t),this.retainedClassRules.delete(t);this.retainedClassNames.size||this.cancelRetainedClassRuleCleanup()}}schedulePendingRemovalFlush(){if(!this.pendingRemovedClassNames.size||this.pendingRemovalFrame!==void 0||this.pendingRemovalFlushFrame!==void 0)return;let e=this.getAnimationFrameWindow();this.pendingRemovalFrame=e.requestAnimationFrame(()=>{this.pendingRemovalFrame=void 0,this.pendingRemovalFlushFrame=e.requestAnimationFrame(()=>{this.pendingRemovalFlushFrame=void 0,this.flushPendingRemovedClassNames()})})}queueRemovedClassNames(e){for(let t of e)this.classCounts.has(t)||this.pendingRemovedClassNames.add(t);this.schedulePendingRemovalFlush()}schedulePendingAdditionFlush(){if(!this.pendingAddedClassNames.size||this.pendingAdditionFrame!==void 0)return;let e=this.getAnimationFrameWindow();this.pendingAdditionFrame=e.requestAnimationFrame(()=>{this.pendingAdditionFrame=void 0,this.flushPendingAddedClassNames()})}queueAddedClassNames(e){for(let t of e)this.classCounts.has(t)&&this.pendingAddedClassNames.add(t);this.schedulePendingAdditionFlush()}estimateRetainedClassRule(e){let t=this.classUtilities.get(e);if(!t?.length)return;let n=0,r=0;for(let e of t){let t=e.nodes;if(t?.length)for(let e of t)n+=e.text.length,r++;else n+=e.text.length,r++}return{retainedAt:Date.now(),rawBytes:n,ruleCount:r}}getRetainedClassRuleRawBytes(){let e=0;for(let t of this.retainedClassRules.values())e+=t.rawBytes;return e}exceedsRetainedClassRuleHardLimits(){return this.retainedClassNames.size>512||this.getRetainedClassRuleRawBytes()>262144}scheduleRetainedClassRuleCleanup(){if(!this.retainedClassNames.size||this.retainedCleanupIdleHandle!==void 0||this.retainedCleanupTimeoutHandle!==void 0)return;let e=this.getCleanupWindow(),t=this.exceedsRetainedClassRuleHardLimits(),n=()=>{this.retainedCleanupIdleHandle=void 0,this.retainedCleanupTimeoutHandle=void 0,this.cleanupRetainedClassRules()},r=t?0:5e3;e.requestIdleCallback?this.retainedCleanupIdleHandle=e.requestIdleCallback(n,{timeout:r}):this.retainedCleanupTimeoutHandle=e.setTimeout(n,r)}retainRemovedClassRules(e){for(let t of e){if(this.classCounts.has(t))continue;let e=this.retainedClassRules.get(t)||this.estimateRetainedClassRule(t);e&&(this.retainedClassNames.add(t),this.retainedClassRules.set(t,e))}this.scheduleRetainedClassRuleCleanup()}getRetainedClassRuleCleanupCandidates(e=!1){let t=Date.now(),n=this.exceedsRetainedClassRuleHardLimits(),r=[];for(let i of this.retainedClassNames){if(this.classCounts.has(i)){this.retainedClassNames.delete(i),this.retainedClassRules.delete(i);continue}let a=this.retainedClassRules.get(i);if(!a){this.retainedClassNames.delete(i);continue}let o=t-a.retainedAt>=1e3;(e||n||o&&this.retainedClassNames.size>128)&&r.push([i,a])}r.sort(([,e],[,t])=>e.retainedAt-t.retainedAt);let i=n?Math.max(64,this.retainedClassNames.size-128):64;return r.slice(0,e?r.length:i).map(([e])=>e)}removeRetainedClassRules(e){let t=[];for(let n of e)this.retainedClassNames.has(n)&&(this.retainedClassNames.delete(n),this.retainedClassRules.delete(n),this.classCounts.has(n)||t.push(n));return t.length&&super.deleteClassRules(...t),t.length}cleanupRetainedClassRules(e=!1){let t=this.removeRetainedClassRules(this.getRetainedClassRuleCleanupCandidates(e));return this.retainedClassNames.size&&(e||this.retainedClassNames.size>128||this.exceedsRetainedClassRuleHardLimits())&&this.scheduleRetainedClassRuleCleanup(),t}flushRetainedClassRules(){this.cancelRetainedClassRuleCleanup();let e=this.cleanupRetainedClassRules(!0);return this.retainedClassNames.size&&this.scheduleRetainedClassRuleCleanup(),e}flushPendingRemovedClassNames(){if(!this.pendingRemovedClassNames.size)return;let e=[];for(let t of this.pendingRemovedClassNames)this.classCounts.has(t)||e.push(t);this.pendingRemovedClassNames.clear(),e.length&&this.retainRemovedClassRules(e)}flushPendingAddedClassNames(){if(!this.pendingAddedClassNames.size)return;let e=[];for(let t of this.pendingAddedClassNames)this.classCounts.has(t)&&e.push(t);this.pendingAddedClassNames.clear(),e.length&&this.ensureClassRules(...e)}handleMutationRecords(e){let t=this.classTracker.collectMutations(e),n=[],r=[],i=[];for(let[e,a]of t){let t=this.classCounts.get(e)||0,o=t+a;o>0?(this.classCounts.set(e,o),t===0&&(this.classUtilities.has(e)||this.retainedClassNames.has(e)?n.push(e):r.push(e))):(this.classCounts.delete(e),i.push(e))}n.length&&this.ensureClassRules(...n),r.length&&this.queueAddedClassNames(r),i.length&&(this.cancelPendingAddedClassNames(i),this.queueRemovedClassNames(i))}ensureClassRules(...e){return this.cancelPendingAddedClassNames(e),this.cancelPendingRemovedClassNames(e),this.cancelRetainedClassNames(e),super.ensureClassRules(...e)}deleteClassRules(...e){this.cancelPendingAddedClassNames(e),this.cancelPendingRemovedClassNames(e),this.cancelRetainedClassNames(e),super.deleteClassRules(...e)}startMutationObserver(){this.observer=new MutationObserver(e=>this.handleMutationRecords(e)),this.observer.observe(this.root,{childList:!0,attributes:!0,attributeFilter:[`class`],subtree:!0})}revealHostIfNeeded(){this.progressive||this.host.removeAttribute(`hidden`)}observe(){if(this.observing)return this;this.detectRuntimeStyle();let e=this.collectConnectedClasses();return this.progressive?this.hydrateRuntimeStyle(e):this.renderRuntimeStyle(e),this.startMutationObserver(),this.revealHostIfNeeded(),this.observing=!0,this}failHydration(e){this.hydrationFailureReason=e}getHydrationManifestLayerRules(){let e=new Map;if(!this.hydrationManifest?.rules?.length)return e;for(let t of this.hydrationManifest.rules){let n=e.get(t.layer);n?n.push(t):e.set(t.layer,[t])}return e}registerHydratedClassRule(e,t){let n=this.classUtilities,r=n.get(e);r?r.push(t):n.set(e,[t])}getUtilityLayerByName(e){switch(e){case`base`:return this.baseLayer;case`defaults`:return this.defaultsLayer;case`components`:return this.componentsLayer;case`utilities`:return this.utilitiesLayer}}collectHydrationManifestVariableNames(){let e=new Set,t=e=>{for(let t of e.matchAll(/var\(\s*--([_a-zA-Z0-9-]+)/g))n(t[1])},n=(t,r=new Set)=>{if(r.has(t))return;r.add(t);let i=this.variables.get(t);i&&(e.add(t),i.dependencies?.forEach(e=>n(e,r)))};for(let e of this.hydrationManifest?.rules||[])e.variableNames?.forEach(e=>n(e)),t(e.text),e.nodes?.forEach(e=>t(e.text)),e.animationNames?.forEach(e=>{let t=this.animations.get(e);t&&new j(e,t,this).variableNames?.forEach(e=>n(e))});for(let[e,t]of this.variables)t.static&&n(e);return e}collectHydrationManifestAnimationNames(){let e=new Set;for(let t of this.hydrationManifest?.rules||[])t.animationNames?.forEach(t=>e.add(t));for(let t of this.animations.keys())this.manifest.animationOptions?.[t]?.static&&e.add(t);return e}nativeThemeLayerHasOnlyEmittedGlobalsVariables(e){if(!e)return!1;let t=!1;for(let n of e.cssRules){let e=this.themeLayer.getStyleRule(n);if(!e)return!1;for(let r=0;r<e.style.length;r++){let i=e.style.item(r);if(!this.isSyntheticColorSchemeDeclaration(n,e,i)&&(!i.startsWith(`--`)||(t=!0,!this.isEmittedGlobalsVariable(i.slice(2)))))return!1}}return t}getVariableRuleBuckets(e){let t=new Map;for(let n of e)for(let e of n.nodes){let n=this.themeLayer.getBucketKey(e.mediaText,e.selectorText),r=t.get(n);r||(r={mediaText:e.mediaText,mode:e.mode,selectorText:e.selectorText,nodes:[]},t.set(n,r)),r.nodes.push(e)}return Array.from(t.values())}isSyntheticColorSchemeDeclaration(e,t,n){if(n!==`color-scheme`)return!1;let r=t.style.getPropertyValue(n).trim();return r===this.themeLayer.getBucketColorScheme({mediaText:e instanceof CSSMediaRule?`@media ${e.conditionText}`:``,mode:r,selectorText:t.selectorText})}getNativeThemeRuleBucketKey(e){let t=this.themeLayer.getStyleRule(e);if(!t)return;let n=e instanceof CSSMediaRule?`@media ${e.conditionText}`:``;return{key:this.themeLayer.getBucketKey(n,t.selectorText),styleRule:t}}hydrateHydrationManifestVariables(e){let t=[...this.collectHydrationManifestVariableNames()].filter(e=>!this.isEmittedGlobalsVariable(e)).map(e=>{let t=this.variables.get(e);return t&&!t.inline?new M(e,t,this):void 0}).filter(e=>!!e),n=this.getVariableRuleBuckets(t),r=e?.cssRules.length||0;if(n.length!==r)return!t.length&&this.nativeThemeLayerHasOnlyEmittedGlobalsVariables(e);if(!t.length)return!0;if(!e)return!1;this.themeLayer.native=e;let i=new Map;for(let t of e.cssRules){let e=this.getNativeThemeRuleBucketKey(t);if(!e||i.has(e.key))return!1;i.set(e.key,e.styleRule)}for(let e of n){let t=i.get(this.themeLayer.getBucketKey(e.mediaText,e.selectorText));if(!t)return!1;for(let n of e.nodes)n.native=t}return this.themeLayer.rules.push(...t),this.themeLayer.syncNativeBuckets(),this.themeLayer.rules.length&&!this.rules.includes(this.themeLayer)&&this.rules.push(this.themeLayer),!0}hydrateHydrationManifestAnimations(e){let t=this.collectHydrationManifestAnimationNames(),n=new Set;for(let r of t){if(this.isEmittedGlobalsAnimation(r)){e.has(r)&&n.add(r);continue}let t=this.animations.get(r);if(!t)continue;let i=e.get(r);if(!i)return!1;let a=new j(r,t,this);a.native=i,this.animationsNonLayer.rules.push(a),this.rules.push(a),n.add(r)}for(let t of e.keys())if(!n.has(t))return!1;return!0}hydrateHydrationManifestLayer(e,t,n,r){if(n.reduce((e,t)=>e+(t.nodes?.length||1),0)!==t.cssRules.length)return!1;e.native=t;let i=0;for(let a of n){let n=new ln(a,e),o=n.nodes;if(o?.length)for(let e of o)e.native=t.cssRules.item(i++)||void 0;else n.native=t.cssRules.item(i++)||void 0;e.rules.push(n),e.insertVariables(n),e.insertAnimations(n),this.registerHydratedClassRule(a.className,n),r.allUtilities.push(n)}return e.rules.length&&!this.rules.includes(e)&&this.rules.push(e),!0}hydrate(e){if(this.hydrationFailureReason=void 0,this.hydrationManifest?.version!==1||!Array.isArray(this.hydrationManifest.rules))return this.failHydration(`Missing or invalid hydration manifest.`);if(!this.hydrationManifest.rules.length)return this.failHydration(`Hydration manifest has no generated rules for ${Q}.`);let t={allUtilities:[]},n=this.getHydrationManifestLayerRules(),r=new Map,i=new Map,a;for(let t=0;t<e.length;t++){let n=e[t];if(n.constructor.name===`CSSLayerBlockRule`){let e=n;if(e.name===`theme`){if(a)return this.failHydration(`Duplicate theme layer in ${Q}.`);a=e;continue}let t=this.getUtilityLayerByName(e.name);if(!t)return this.failHydration(`Unknown layer \`${e.name}\` in ${Q}.`);if(r.has(t.name))return this.failHydration(`Duplicate layer \`${e.name}\` in ${Q}.`);r.set(t.name,e)}else if(n.constructor.name===`CSSKeyframesRule`){let e=n;i.set(e.name,e)}else return this.failHydration(`Unknown top-level rule \`${n.cssText}\` in ${Q}.`)}for(let[e,t]of n){let n=r.get(e);if(!n)return this.failHydration(`Missing layer \`${e}\` in ${Q}.`);if(t.reduce((e,t)=>e+(t.nodes?.length||1),0)!==n.cssRules.length)return this.failHydration(`Layer \`${e}\` does not match the hydration manifest.`)}for(let[e,t]of r)if(!n.has(e)&&t.cssRules.length)return this.failHydration(`Layer \`${e}\` has no hydration manifest rules.`);if(!this.hydrateHydrationManifestVariables(a))return this.failHydration(`Theme layer does not match the hydration manifest.`);if(!this.hydrateHydrationManifestAnimations(i))return this.failHydration(`Keyframes do not match the hydration manifest.`);for(let[e,i]of r){let r=n.get(e);if(!r?.length)continue;let a=this.getUtilityLayerByName(e);this.hydrateHydrationManifestLayer(a,i,r,t)}return t}disconnect(){if(this.clearPendingAddedClassNames(),this.clearPendingRemovedClassNames(),this.clearRetainedClassRules(),this.observing)return this.observer&&=(this.observer.disconnect(),void 0),this.observing=!1,this.reset(),this.loadManifest(this.manifest),this.classCounts.clear(),this.classTracker.reset(),this.progressive||(this.style?.remove(),this.style=null),this}refresh(e=this.manifest){if(this.clearPendingAddedClassNames(),this.clearPendingRemovedClassNames(),this.clearRetainedClassRules(),!this.observing||!this.style.sheet)return this;let t=this.style.sheet.cssRules;for(let e=t.length-1;e>=0;e--)this.style.sheet.deleteRule(e);return super.refresh(e),this.classCounts.forEach((e,t)=>{this.ensureClassRules(t)}),this}destroy(){return this.disconnect(),this.unregister(),this}};(function(e){Zt(e)})(yn);function bn(e){let t=new URL(e);return t.search=``,t.hash=``,t.pathname.endsWith(`/`)?t.pathname+=`default-manifest.json`:t.pathname.endsWith(`.js`)?t.pathname=t.pathname.replace(/\/[^/]*$/,`/default-manifest.json`):t.pathname+=`/default-manifest.json`,t}async function xn(e){let t=bn(e);try{return(await import(t.href,{with:{type:`json`}})).default}catch(e){throw Error(`Cannot load Master CSS default manifest from ${t.href}.`,{cause:e})}}const Sn=document.currentScript;Sn?.src?xn(Sn.src).then(e=>{let t=yn.create({manifest:e});if(t.needsHydrationManifest())return t.loadHydrationManifest().then(()=>t.observe());t.observe()}).catch(e=>console.error(e)):console.error(`Cannot resolve the Master CSS runtime script URL.`);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import RuntimeUtilityLayer, { RuntimeUtilityLayerInstance } from "./utility-layer.js";
|
|
2
2
|
import { HydrateResult } from "./types/hydrate-result.js";
|
|
3
|
+
import "./types/index.js";
|
|
3
4
|
import CSSRuntime, { CSSRuntimeCreateOptions } from "./core.js";
|
|
4
5
|
import cssRuntime, { CSSRuntimeDecoratorOptions, CSSRuntimeOptions } from "./css-runtime.js";
|
|
5
6
|
import { MasterCSSEmittedGlobals } from "@master/css-engine";
|
package/dist/layer.d.ts
CHANGED
package/dist/theme-layer.d.ts
CHANGED
package/dist/utility-layer.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import RuntimeLayer from "./layer.js";
|
|
2
2
|
import HydratedGeneratedRule from "./generated-rule.js";
|
|
3
3
|
import { GeneratedRule, Rule } from "@master/css-engine";
|
|
4
|
-
|
|
5
4
|
//#region src/utility-layer.d.ts
|
|
6
5
|
type RuntimeGeneratedRule = GeneratedRule | HydratedGeneratedRule;
|
|
7
6
|
declare class RuntimeUtilityLayer extends RuntimeLayer {
|
package/package.json
CHANGED
|
@@ -48,17 +48,17 @@
|
|
|
48
48
|
"provenance": true
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@master/css-
|
|
52
|
-
"@master/css-
|
|
53
|
-
"@master/css-
|
|
51
|
+
"@master/css-engine": "^2.0.0-rc.86",
|
|
52
|
+
"@master/css-schema": "^2.0.0-rc.86",
|
|
53
|
+
"@master/css-preset": "^2.0.0-rc.86"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@playwright/test": "1.61.0",
|
|
57
|
-
"@master/css": "^2.0.0-rc.
|
|
58
|
-
"@master/css-compiler": "^2.0.0-rc.
|
|
59
|
-
"@master/css-integration": "^2.0.0-rc.
|
|
57
|
+
"@master/css": "^2.0.0-rc.86",
|
|
58
|
+
"@master/css-compiler": "^2.0.0-rc.86",
|
|
59
|
+
"@master/css-integration": "^2.0.0-rc.86"
|
|
60
60
|
},
|
|
61
|
-
"version": "2.0.0-rc.
|
|
61
|
+
"version": "2.0.0-rc.86",
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsdown",
|
|
64
64
|
"bench": "node scripts/benchmark-runtime.js",
|