@tenoxui/browser
Version:
A JavaScript library for creating highly customized, flexible, and extensible utility-first CSS framework
17 lines (16 loc) • 29.6 kB
JavaScript
var __tenoxui_browser__=function(E){"use strict";var M=Object.defineProperty,S=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,P=(h,s,e)=>s in h?M(h,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[s]=e,z=(h,s)=>{for(var e in s||(s={}))U.call(s,e)&&P(h,e,s[e]);if(S)for(var e of S(s))F.call(s,e)&&P(h,e,s[e]);return h};function k(h){return h.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}function W(h){if(/^(webkit|moz|ms|o)[A-Z]/.test(h)){const s=h.match(/^(webkit|moz|ms|o)/);if(s){const e=s[0];return`-${e}${h.slice(e.length).replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}}return h.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}function R(h,s,e,t,r,i){return`${h?`${h}:`:""}${s}${e?"-":""}${e}${t}${r?`/${r}${i}`:""}`}function V(h){return h.replace(/[.*+?^${}()|[\]\\/\\-]/g,"\\$&")}function D(h){if(!h)return[];const s=new Set;return Object.entries(h).forEach(([e,t])=>{t&&typeof t=="object"&&Object.keys(t).forEach(r=>{s.add(r)})}),Array.from(s)}function q({safelist:h=[],property:s={},classes:e={}}={}){const t=e,r=Object.keys(s);if(!t)return[...r,...h].sort((n,o)=>o.length-n.length);const i=[...D(t)];return[...r,...i,...h].sort((n,o)=>o.length-n.length)}function Q({inputPrefixChars:h=[],safelist:s=[],property:e={},classes:t={}}={}){let r=q({safelist:s,property:e,classes:t}).map(V);r.length>0&&(r=r.join("|")+"|");const i="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",o="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c=`[${["a-zA-Z0-9_\\-",...h].join("")}]`,a=c+"+|"+c+"+(?:-(?:"+i+"|"+n+"|"+o+"))|"+c+"+(?:-(?:"+i+"|"+n+"|"+o+"))?(?:\\/[a-zA-Z0-9_\\-]+)|"+i+"|"+n+"|"+o,u=`(${r}\\[[^\\]]+\\])`,l="(?:-)",p="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+i+"|"+o+"|"+n+"|(?:\\$[^\\s\\/]+))",g="([a-zA-Z%]*)",f="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+i+"|"+o+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:a,type:u,separator:l,value:p,unit:g,secondValuePattern:f,all:"^(?:("+a+"):)?"+u+l+p+g+f+"$"}}class K{constructor({property:s={},values:e={},classes:t={},prefixChars:r=[]}={}){this.property=s,this.values=e,this.classes=t,this.prefixChars=r.map(V)}parse(s,e){const t=Q({safelist:e,property:this.property,classes:this.classes,inputPrefixChars:this.prefixChars}),r=s.match(new RegExp(t.all));if(r){const[,n,o,c,a,u,l]=r;return[n,o,c,a||"",u,l]}const i=s.match(new RegExp(`^(?:(${t.prefix}):)?${t.type}$`));return i?[i[1],i[2],"","",void 0,void 0]:null}processValue(s,e,t){if(!s)return"";const r=i=>i.replace(/\{([^}]+)\}/g,(n,o)=>{const c=this.values,a=c!==null?typeof c[t]=="object"?c[t][o]:c[o]:void 0;return typeof a=="string"?a:n});if(typeof this.values=="object"&&this.values!==null&&(this.values[t]&&typeof this.values[t]=="object"&&this.values[t][s]||this.values[s]))return typeof this.values[t]=="object"&&this.values[t]!==null?this.values[t][s]:this.values[s];if(s.startsWith("$"))return`var(--${s.slice(1)})`;if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")){const i=s.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return i.includes("{")?r(i):i.startsWith("--")?`var(${i})`:i}return s+(e||"")}processShorthand(s="",e="",t="",r,i="",n="",o="",c){const a=this.property[s];if(typeof a=="object"&&!Array.isArray(a)&&!("property"in a))return null;const u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let l=null,p=e||"";const g=p.match(u);if(g&&(l=g[1].trim(),p=g[2].trim()),(typeof a=="string"&&!a.includes(":")||Array.isArray(a))&&(!e||e.includes(l+":")||i))return null;let f;e.includes(l+":")?f=e.startsWith("(")?`(${p})`:`[${p}]`:f=e;const d=this.processValue(f,t,s),m=this.processValue(i,n,s);if(s.startsWith("[")&&s.endsWith("]")){if(!e||i)return null;const y=s.slice(1,-1).split(",").map(A=>A.trim().startsWith("--")?String(A.trim()):W(String(A.trim())));return{className:R(r,s,e,t),cssRules:y.length===1?y[0]:y,value:d,prefix:r}}if(a){if(typeof a=="object"&&"property"in a){const A=a.group&&this.values[a.group][d]?this.values[a.group][d]:t?e:d,v=typeof a.property=="function"?a.property({value:e.startsWith("[")?d:A,unit:e.startsWith("[")?"":t,secondValue:e.startsWith("[")?"":n?i:m,secondUnit:e.startsWith("[")?"":n,key:l,raw:c}):a.property;if(v&&typeof v=="object"&&!Array.isArray(v)&&"cssRules"in v){const{className:C,cssRules:x,value:I,prefix:N}=v;return{className:C||o,cssRules:x,value:I,prefix:N||r,isCustom:!!C}}const $=a.value||"{0}";let b;if(typeof $=="function")b=$({value:A,unit:t,secondValue:n?i:m,secondUnit:n,key:l,raw:c});else if(typeof $=="string"){const C=a.group||s,x=this.processValue(f,t,C);this.values[C]&&typeof this.values[C]=="object"&&this.values[C][f]?b=this.values[C][f]:$.includes("{")?b=this.parseValuePattern(C,$,x,"",m,""):typeof $=="string"&&!$.includes("{")?b=$:b=d}else if(Array.isArray($)){if(!$.includes(e+t)||i)return null;b=e+t}else b=null;return(typeof a.property=="string"||Array.isArray(a.property))&&typeof $=="string"&&(e.includes(l+":")||!$.includes("{1")&&i)||(typeof a.property=="string"||Array.isArray(a.property))&&$===null||typeof a.property=="string"&&a.property.includes(":")&&e||(typeof a.property=="string"||Array.isArray(a.property))&&typeof a.value=="string"&&!a.value.includes("{")&&e?null:{className:R(r,s,e,t,i,n),cssRules:v?Array.isArray(v)?v:typeof v=="string"&&(v.includes(":")||v.includes("value:"))&&v.includes("value:")?v.slice(6):W(String(v)):null,value:$===null||v===null||v.includes(":")||v.includes("value:")?null:e.startsWith("[")?d:b,prefix:r}}const y=typeof a=="function"?a({value:e.startsWith("[")?d:t?e:d,unit:e.startsWith("[")?"":t,secondValue:e.startsWith("[")?"":n?i:m,secondUnit:e.startsWith("[")?"":n,key:l,raw:c}):a;if(y&&typeof y=="object"&&!Array.isArray(y)&&"cssRules"in y){const{className:A,cssRules:v,value:$,prefix:b}=y;return{className:A||o,cssRules:v,value:$,prefix:b||r,isCustom:!!A}}return{className:R(r,s,e,t,i,n),cssRules:y?Array.isArray(a)?y:typeof y=="string"&&(y.includes(":")||y.startsWith("value:"))&&y.startsWith("value:")?y.slice(6):W(String(y)):null,value:typeof y=="string"&&y.includes(":")?null:d,prefix:r}}return null}parseValuePattern(s,e,t,r,i,n){if(!e.includes("{0}")&&!e.includes("{1")&&!e.includes("||"))return e;const[o,c]=e.split("||").map(l=>l.trim()),a=this.processValue(t,r,s),u=this.processValue(i,n,s);if(e.includes("{0}")&&e.includes("{1")||e.includes("{1")){let l=o;if(t&&(l=l.replace(/\{0\}/g,a)),e.includes("{1")){e.includes("{1}")&&(i?l=i.startsWith("[")?u:l.replace(/\{1\}/g,u):l=c||o);const p=/\{1([^}]*)\}/g;let g;for(;(g=p.exec(l))!==null;){const f=g[0],d=g[1].trim();let m=u;!m&&d.includes("|")?m=d.split("|")[1].trim():m||(m=""),l=t.startsWith("[")?a:l.replace(f,m)}}return t?l:c||o}else return t?t.startsWith("[")?a:o.replace(/\{0\}/g,a):c||o}getParentClass(s){return Object.keys(this.classes).filter(e=>Object.prototype.hasOwnProperty.call(this.classes[e],s))}processCustomClass(s,e="",t="",r="",i="",n=""){if(!s)return null;const o=this.getParentClass(s),c=e&&s.endsWith(`-${e}${t}`);if(o.length>0){const a=o.map(u=>{const l=this.classes[u];if(!l||e&&!c&&l[s]&&!l[s].includes("{0}")&&!l[s].includes("|"))return null;const p=this.parseValuePattern(s,l[s]||"",e,t,i,n);return`${W(String(u))}: ${p}`}).filter(Boolean).join("; ");return{className:c?s:R(r,s,e,t,i,n),cssRules:a,value:null,prefix:r}}return null}process(s){try{const e=Array.isArray(s)?s:s.split(/\s+/),t=[];for(const r of e)try{if(!r)continue;const i=this.parse(r);if(!i)continue;const[n,o,c,a,u,l]=i;if(!o)continue;const p=[...i,R(n,o,c,a,u,l)],g=this.getParentClass(`${o}-${c}`).length>0?`${o}-${c}`:o;try{const f=this.processCustomClass(g,c,a,n,u,l);if(f){const{className:d,cssRules:m,prefix:y}=f;if(!m||m==="null")continue;t.push({className:k(d),cssRules:m,value:null,prefix:y,raw:p});continue}}catch(f){console.warn(`Error processing custom class "${r}":`,f)}try{const f=this.processShorthand(o,c,a,n,u,l,r,p);if(f){const{className:d,cssRules:m,value:y,prefix:A,isCustom:v}=f;if(!m||m==="null")continue;t.push({className:v?d:k(d),cssRules:m,value:y,prefix:A,raw:p})}}catch(f){console.warn(`Error processing shorthand "${r}":`,f)}}catch(i){console.warn(`Failed to process class \`${r}\`:`,i)}return t}catch(e){return console.error("Critical error in process method:",e),[]}}}/*!
* @nousantx/someutils v0.7.1 | MIT License
*
* Copyright (c) 2024-present NOuSantx <nousantx@gmail.com>
*
* Built Date: Mon May 05 2025 06:00:21 GMT+0700 (Western Indonesia Time)
*/function O(...h){return h.reduce((s,e)=>(Object.keys(e).forEach(t=>{const r=t;typeof e[r]=="object"&&e[r]!==null&&!Array.isArray(e[r])?s[r]=O(s[r]||{},e[r]):s[r]=e[r]}),s),{})}function _(h){const s=h;if(/^(webkit|moz|ms|o)[A-Z]/.test(s)){const e=s.match(/^(webkit|moz|ms|o)/);if(e){const t=e[0];return`-${t}${s.slice(t.length).replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}`}}return s.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}class G{constructor({property:s={},values:e={},classes:t={},aliases:r={},breakpoints:i={},variants:n={},tenoxui:o=K,tenoxuiOptions:c={},reservedVariantChars:a=[],prefixLoaderOptions:u={}}={}){this.engine=o,this.variants=n,this.property=s,this.values=e,this.classes=t,this.aliases=r,this.breakpoints=i,this.tuiConfig=O({property:this.property,values:this.values,classes:this.classes,prefixChars:a},c),this.main=new this.engine(this.tuiConfig);const{property:l={}}=u;this.variantRules=z(z({},this.variants),l),this.prefixLoader=new this.engine(O({property:this.variantRules,values:this.breakpoints,prefixChars:a},u))}createEngine(s={}){return new this.engine(s)}getConfig(){return this.tuiConfig}getBreakpointQuery(s){if(s.startsWith("min-")){const e=s.substring(4);if(this.breakpoints[e])return`@media (width >= ${this.breakpoints[e]})`}else if(s.startsWith("max-")){const e=s.substring(4);if(this.breakpoints[e])return`@media (width < ${this.breakpoints[e]})`}else if(this.breakpoints[s])return`@media (width >= ${this.breakpoints[s]})`;return null}processCustomPrefix(s){try{const e=this.prefixLoader.process(s);if((e==null?void 0:e.length)>0)return e[0].cssRules}catch(e){console.error(`Failed to process prefix ${s}:`,e)}return null}generatePrefix(s){const e=this.variantRules[s];if(e&&typeof e=="string")return e.startsWith("value:")?e.substring(6):e;const t=this.prefixLoader.parse(s);if(t){if(typeof this.variantRules[t[1]]=="string"&&t[2])return null;const i=this.processCustomPrefix(s);if(i&&typeof i=="string")return i.startsWith("value:")?i.substring(6):i}return s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")?this.prefixLoader.processValue(s,"",""):this.getBreakpointQuery(s)||null}isImportantClass(s,e,t){const r=`${s}:${e}`;return t[r]||!1}parseImportantClassNames(s){const e=[],t={},r=Array.isArray(s)?s:s.split(/\s+/).filter(Boolean),i=[];return r.forEach((n,o)=>{if(n.startsWith("!")){const c=n.slice(1);i.push({name:c,isImportant:!0,originalIndex:o})}else i.push({name:n,isImportant:!1,originalIndex:o})}),i.forEach(({name:n,isImportant:o,originalIndex:c})=>{e.push(n);const a=`${n}:${c}`;t[a]=o}),{parsedClassNames:e,importantMap:t}}processAlias(s,e,t,r=!1){if(!s||!this.aliases[s])return null;let i=k(e?`${e}:${s}`:s);const n=[],o=[],{parsedClassNames:c,importantMap:a}=this.parseImportantClassNames(this.aliases[s]);this.main.process(c).map((l,p)=>{const{cssRules:g,value:f,prefix:d,raw:m}=l,y=this.isImportantClass(m[6],p,a),A=d?{prefix:d,data:this.generatePrefix(d)}:null;if(!A)n.push({cssRules:g,value:f,isImportant:y});else{if(A&&A.prefix===e||!A.data)return;o.push({className:A.data.includes("&")?A.data.replace("&",i):i,cssRules:g,value:f,isImportant:y,variant:A.data})}});const u=Object.values(o.reduce((l,p)=>{const g=`${p.className}|${p.variant}`;return l[g]||(l[g]={className:p.className,rules:[],variant:p.variant}),l[g].rules.push({cssRules:p.cssRules,value:p.value,isImportant:p.isImportant}),l},{}));return{className:(r?"\\!":"")+i,rules:n,isImportant:r,prefix:e?{name:e,data:this.generatePrefix(e)}:null,variants:u.length>0?u:null,raw:t||[]}}process(s){const e=s?Array.isArray(s)?s:s.split(/\s+/).filter(Boolean):[],{parsedClassNames:t,importantMap:r}=this.parseImportantClassNames(e);if(!t||t.length===0)return null;const i=[];return t.forEach((n,o)=>{const c=this.main.parse(n,Object.keys(this.aliases)),a=this.isImportantClass(n,o,r),u=c&&c[0]?n.slice(c[0].length+1):n;if(c&&c[1]&&this.aliases[u]){const[l]=c;if(l&&!this.generatePrefix(l))return null;const p=this.processAlias(u,l,c,a);p&&i.push(p)}else this.main.process(n).forEach(l=>{const{className:p,cssRules:g,value:f,prefix:d,raw:m}=l;d&&!this.generatePrefix(d)||i.push({className:(a?"\\!":"")+p,isImportant:a,cssRules:g,value:f,variants:d?{name:d,data:this.generatePrefix(d)}:null,raw:m||null})})}),i}}function Z(h){return h.replace(/^(\d)/,"\\3$1 ").replace(/([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"\\$1")}function j(h){if(/^(webkit|moz|ms|o)[A-Z]/.test(h)){const s=h.match(/^(webkit|moz|ms|o)/);if(s){const e=s[0];return`-${e}${h.slice(e.length).replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}}return h.replace(/[A-Z]/g,s=>`-${s.toLowerCase()}`)}function w(h,s,e,t,r,i){return`${h?`${h}:`:""}${s}${e?"-":""}${e}${t}${r?`/${r}${i}`:""}`}function B(h){return h.replace(/[.*+?^${}()|[\]\\/\\-]/g,"\\$&")}function H(h){if(!h)return[];const s=new Set;return Object.entries(h).forEach(([e,t])=>{t&&typeof t=="object"&&Object.keys(t).forEach(r=>{s.add(r)})}),Array.from(s)}function J({safelist:h=[],property:s={},classes:e={}}={}){const t=e,r=Object.keys(s);if(!t)return[...r,...h].sort((n,o)=>o.length-n.length);const i=[...H(t)];return[...r,...i,...h].sort((n,o)=>o.length-n.length)}function X({inputPrefixChars:h=[],safelist:s=[],property:e={},classes:t={}}={}){let r=J({safelist:s,property:e,classes:t}).map(B);r.length>0&&(r=r.join("|")+"|");const i="\\[[^\\]]+\\]",n="\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)",o="\\{[^{}]*(?:\\{[^{}]*\\}[^{}]*)*\\}",c=`[${["a-zA-Z0-9_\\-",...h].join("")}]`,a=c+"+|"+c+"+(?:-(?:"+i+"|"+n+"|"+o+"))|"+c+"+(?:-(?:"+i+"|"+n+"|"+o+"))?(?:\\/[a-zA-Z0-9_\\-]+)|"+i+"|"+n+"|"+o,u=`(${r}\\[[^\\]]+\\])`,l="(?:-)",p="(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+i+"|"+o+"|"+n+"|(?:\\$[^\\s\\/]+))",g="([a-zA-Z%]*)",f="(?:\\/(-?(?:\\d+(?:\\.\\d+)?)|(?:[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*(?:-[a-zA-Z0-9_]+)*)|(?:#[0-9a-fA-F]+)|"+i+"|"+o+"|"+n+"|(?:\\$[^\\s\\/]+))([a-zA-Z%]*))?";return{prefix:a,type:u,separator:l,value:p,unit:g,secondValuePattern:f,all:"^(?:("+a+"):)?"+u+l+p+g+f+"$"}}class L{constructor({property:s={},values:e={},classes:t={},prefixChars:r=[]}={}){this.property=s,this.values=e,this.classes=t,this.prefixChars=r.map(B)}regexp(s){return X({safelist:s,property:this.property,classes:this.classes,inputPrefixChars:this.prefixChars})}parse(s,e){const t=this.regexp(e),r=s.match(new RegExp(t.all));if(r){const[,n,o,c,a,u,l]=r;return[n,o,c,a||"",u,l]}const i=s.match(new RegExp(`^(?:(${t.prefix}):)?${t.type}$`));return i?[i[1],i[2],"","",void 0,void 0]:null}processValue(s,e,t){if(!s)return"";const r=i=>i.replace(/\{([^}]+)\}/g,(n,o)=>{const c=this.values,a=c!==null?typeof c[t]=="object"?c[t][o]:c[o]:void 0;return typeof a=="string"?a:n});if(typeof this.values=="object"&&this.values!==null&&(this.values[t]&&typeof this.values[t]=="object"&&this.values[t][s]||this.values[s]))return typeof this.values[t]=="object"&&this.values[t]!==null?this.values[t][s]:this.values[s];if(s.startsWith("$"))return`var(--${s.slice(1)})`;if(s.startsWith("[")&&s.endsWith("]")||s.startsWith("(")&&s.endsWith(")")){const i=s.slice(1,-1).replace(/\\\_/g,"m0x13c55").replace(/\_/g," ").replace(/m0x13c55/g,"_");return i.includes("{")?r(i):i.startsWith("--")?`var(${i})`:i}return s+(e||"")}processShorthand(s="",e="",t="",r,i="",n="",o="",c){const a=this.property[s];if(typeof a=="object"&&!Array.isArray(a)&&!("property"in a))return null;const u=/^(?:\(|\[)([^:]+):(.+)(?:\)|\])$/;let l=null,p=e||"";const g=p.match(u);if(g&&(l=g[1].trim(),p=g[2].trim()),(typeof a=="string"&&!a.includes(":")||Array.isArray(a))&&(!e||e.includes(l+":")||i))return null;let f;e.includes(l+":")?f=e.startsWith("(")?`(${p})`:`[${p}]`:f=e;const d=this.processValue(f,t,s),m=this.processValue(i,n,s);if(s.startsWith("[")&&s.endsWith("]")){if(!e||i)return null;const y=s.slice(1,-1).split(",").map(A=>A.trim().startsWith("--")?String(A.trim()):j(String(A.trim())));return{className:w(r,s,e,t),cssRules:y.length===1?y[0]:y,value:d,prefix:r}}if(a){if(typeof a=="object"&&"property"in a){const A=a.group&&this.values[a.group][d]?this.values[a.group][d]:t?e:d,v=typeof a.property=="function"?a.property({value:e.startsWith("[")?d:A,unit:e.startsWith("[")?"":t,secondValue:e.startsWith("[")?"":n?i:m,secondUnit:e.startsWith("[")?"":n,key:l,raw:c}):a.property;if(v&&typeof v=="object"&&!Array.isArray(v)&&"cssRules"in v){const{className:C,cssRules:x=null,value:I=null,prefix:N}=v;return{className:C||o,cssRules:x,value:I,prefix:N||r,isCustom:!!C}}const $=a.value||"{0}";let b;if(typeof $=="function")b=$({value:A,unit:t,secondValue:n?i:m,secondUnit:n,key:l,raw:c});else if(typeof $=="string"){const C=a.group||s,x=this.processValue(f,t,C);this.values[C]&&typeof this.values[C]=="object"&&this.values[C][f]?b=this.values[C][f]:$.includes("{")?b=this.parseValuePattern(C,$,x,"",m,""):typeof $=="string"&&!$.includes("{")?b=$:b=d}else if(Array.isArray($)){if(!$.includes(e+t)||i)return null;b=e+t}else b=null;return(typeof a.property=="string"||Array.isArray(a.property))&&typeof $=="string"&&(e.includes(l+":")||!$.includes("{1")&&i)||(typeof a.property=="string"||Array.isArray(a.property))&&$===null||typeof a.property=="string"&&a.property.includes(":")&&e||(typeof a.property=="string"||Array.isArray(a.property))&&typeof a.value=="string"&&!a.value.includes("{")&&e?null:{className:w(r,s,e,t,i,n),cssRules:v?Array.isArray(v)?v:typeof v=="string"&&(v.includes(":")||v.includes("value:"))&&v.includes("value:")?v.slice(6):j(String(v)):null,value:$===null||v===null||v.includes(":")||v.includes("value:")?null:e.startsWith("[")?d:b,prefix:r}}const y=typeof a=="function"?a({value:e.startsWith("[")?d:t?e:d,unit:e.startsWith("[")?"":t,secondValue:e.startsWith("[")?"":n?i:m,secondUnit:e.startsWith("[")?"":n,key:l,raw:c}):a;if(y&&typeof y=="object"&&!Array.isArray(y)&&"cssRules"in y){const{className:A,cssRules:v=null,value:$=null,prefix:b}=y;return{className:A||o,cssRules:v,value:$,prefix:b||r,isCustom:!!A}}return{className:w(r,s,e,t,i,n),cssRules:y?Array.isArray(y)?y:typeof y=="string"&&(y.includes(":")||y.startsWith("value:"))&&y.startsWith("value:")?y.slice(6):j(String(y)):null,value:typeof y=="string"&&y.includes(":")?null:d,prefix:r}}return null}parseValuePattern(s,e,t,r,i,n){if(!e.includes("{0}")&&!e.includes("{1")&&!e.includes("||"))return e;const[o,c]=e.split("||").map(l=>l.trim()),a=this.processValue(t,r,s),u=this.processValue(i,n,s);if(e.includes("{0}")&&e.includes("{1")||e.includes("{1")){let l=o;if(t&&(l=l.replace(/\{0\}/g,a)),e.includes("{1")){e.includes("{1}")&&(i?l=i.startsWith("[")?u:l.replace(/\{1\}/g,u):l=c||o);const p=/\{1([^}]*)\}/g;let g;for(;(g=p.exec(l))!==null;){const f=g[0],d=g[1].trim();let m=u;!m&&d.includes("|")?m=d.split("|")[1].trim():m||(m=""),l=t.startsWith("[")?a:l.replace(f,m)}}return t?l:c||o}else return t?t.startsWith("[")?a:o.replace(/\{0\}/g,a):c||o}getParentClass(s){return Object.keys(this.classes).filter(e=>Object.prototype.hasOwnProperty.call(this.classes[e],s))}processCustomClass(s,e="",t="",r="",i="",n=""){if(!s)return null;const o=this.getParentClass(s),c=e&&s.endsWith(`-${e}${t}`);if(o.length>0){const a=o.map(u=>{const l=this.classes[u];if(!l||e&&!c&&l[s]&&!l[s].includes("{0}")&&!l[s].includes("|"))return null;const p=this.parseValuePattern(s,l[s]||"",e,t,i,n);return`${j(String(u))}: ${p}`}).filter(Boolean).join("; ");return{className:c?s:w(r,s,e,t,i,n),cssRules:a,value:null,prefix:r}}return null}process(s){try{const e=Array.isArray(s)?s:s.split(/\s+/),t=[];for(const r of e)try{if(!r)continue;const i=this.parse(r);if(!i)continue;const[n,o,c,a,u,l]=i;if(!o)continue;const p=[...i,w(n,o,c,a,u,l)],g=this.getParentClass(`${o}-${c}`).length>0?`${o}-${c}`:o;try{const f=this.processCustomClass(g,c,a,n,u,l);if(f){const{className:d,cssRules:m,prefix:y}=f;if(!m||m==="null")continue;t.push({className:Z(d),cssRules:m,value:null,prefix:y,raw:p});continue}}catch(f){console.warn(`Error processing custom class "${r}":`,f)}try{const f=this.processShorthand(o,c,a,n,u,l,r,p);if(f){const{className:d,cssRules:m,value:y,prefix:A,isCustom:v}=f;if(!m||m==="null")continue;t.push({className:v?d:Z(d),cssRules:m,value:y,prefix:A,raw:p})}}catch(f){console.warn(`Error processing shorthand "${r}":`,f)}}catch(i){console.warn(`Failed to process class \`${r}\`:`,i)}return t}catch(e){return console.error("Critical error in process method:",e),[]}}}class Y extends G{constructor({property:s={},values:e={},classes:t={},aliases:r={},breakpoints:i={},variants:n={},safelist:o=[],tabSize:c=2,moxie:a=L,moxieOptions:u={},prefixLoaderOptions:l={},reservedVariantChars:p=[],typeOrder:g=[],selectorPrefix:f=""}={}){super({property:s,values:e,classes:t,aliases:r,breakpoints:i,tenoxui:a,tenoxuiOptions:u,prefixLoaderOptions:l,reservedVariantChars:p,variants:n}),this.safelist=o,this.tabSize=c,this.typeOrder=g,this.selectorPrefix=f}addTabs(s,e=2,t=!1){const r=" ".repeat(t?e:this.tabSize);return s.split(`
`).filter(i=>i.trim()!=="").map(i=>`${r}${i}`).join(`
`)}beautifyRules(s,e=!1){let t=0,r=[];const i=(e?s.replace(/\s*!important\s*/g,""):s).split(";"),n=e?" !important;":";";for(let o=0;o<i.length;o++){let c=i[o].trim();if(c!=="")if(c.includes("}")){const a=c.split("}");for(let u=0;u<a.length;u++){let l=a[u].trim();l!==""&&r.push((t>0?this.addTabs(l):l)+n),u<a.length-1&&(t=Math.max(0,t-1),r.push(t>0?this.addTabs("}"):"}"))}}else if(c.includes("{")){const a=c.split("{");for(let u=0;u<a.length;u++){let l=a[u].trim();if(l!==""){const p=u<a.length-1?" {":n;r.push((t>0?this.addTabs(l):l)+p)}u<a.length-1&&t++}}else r.push((t>0?this.addTabs(c):c)+n)}return r.join(`
`)}formatRules(s,e){return Array.isArray(s)&&e!==null?s.map(t=>e?`${_(String(t))}: ${e}`:_(String(t))).join("; "):s}formatAliasRules(s){return s.map(e=>{const t=this.formatRules(e.cssRules,e.value),r=Array.isArray(e.cssRules)||e.value===null?"":`: ${e.value}`;return`${t}${r}${e.isImportant?" !important":""}`}).join("; ")}createCssBlock(s,e,t=!0){return`${t?this.selectorPrefix:""}${s} {
${this.addTabs(e)}
}`}replaceAmpersand(s,e){return s.replace(/&/g,`.${e}`)}processApplyObject(s){const e=[];for(const[t,r]of Object.entries(s)){const i=this.process(r);if(!i||0>i.length)return[];const n=[],o=[];if(i.forEach(c=>{if("rules"in c){const a=this.formatAliasRules(c.rules);n.push(a),c.variants&&Array.isArray(c.variants)&&c.variants.forEach(u=>{const l=this.beautifyRules(this.formatAliasRules(u.rules)),p=u.variant;if(p.includes("&")){const g=p.replace(/&/g,t);o.push(this.createCssBlock(g,l))}else{const g=this.createCssBlock(t,l);o.push(this.createCssBlock(p,g,!1))}})}else{const{cssRules:a,value:u,variants:l,isImportant:p}=c,g=this.formatRules(a,u),f=Array.isArray(a)||u===null?"":`: ${u}`;if(!l)n.push(this.beautifyRules(g+f,p));else if(l&&l.data)if(l.data.includes("&")){const d=l.data.replace(/&/g,t),m=this.beautifyRules(g+f,p);o.push(this.createCssBlock(d,m))}else{const d=this.beautifyRules(g+f,p),m=this.createCssBlock(t,d);o.push(this.createCssBlock(l.data,m,!1))}}}),n.length>0){const c=this.beautifyRules(n.join("; "));e.push(this.createCssBlock(t,c))}o.length>0&&e.push(...o)}return e}processAliasItem(s,e){const t=[],r=this.beautifyRules(this.formatAliasRules(s.rules),s.isImportant),i=e||s.className;if(s.prefix&&s.prefix.data)if(s.prefix.data.includes("&")){const n=this.replaceAmpersand(s.prefix.data,i);t.push(this.createCssBlock(n,r))}else{const n=this.createCssBlock(`.${i}`,r);t.push(this.createCssBlock(s.prefix.data,n,!1))}else t.push(this.createCssBlock(`.${i}`,r));return s.variants&&Array.isArray(s.variants)&&s.variants.forEach(n=>{const o=this.beautifyRules(this.formatAliasRules(n.rules),s.isImportant),c=n.className,a=n.variant;if(a.includes("&")){const u=this.replaceAmpersand(a,i);t.push(this.createCssBlock(u,o))}else{const u=this.createCssBlock(`.${c}`,o);t.push(this.createCssBlock(a,u,!1))}}),t}processShorthandItem(s){const{className:e,cssRules:t,value:r,variants:i,isImportant:n}=s,o=this.formatRules(t,r),c=Array.isArray(t)||r===null?"":`: ${r}`,a=this.beautifyRules(o+c,n);if(!i)return this.createCssBlock(`.${e}`,a);if(i.data&&i.data.includes("&")){const u=this.replaceAmpersand(i.data,e);return this.createCssBlock(u,a)}else{const u=this.createCssBlock(`.${e}`,a);return this.createCssBlock(i.data,u,!1)}}sortedClassNameItem(s){const e=this.process(s);return!e||e.length===0?null:[...e].sort((t,r)=>{const i=t.raw||[],n=r.raw||[],o=i[1]||"",c=n[1]||"",a=this.typeOrder.indexOf(o),u=this.typeOrder.indexOf(c);return a!==-1&&u!==-1?a-u:a!==-1?-1:u!==-1?1:0})}getRulesData(...s){let e=[];const t=r=>{const i=this.sortedClassNameItem(r);i&&i.length>0&&i.forEach(n=>{"rules"in n?e.push(...this.processAliasItem(n)):e.push(this.processShorthandItem(n))})};return this.safelist.length>0&&t(this.safelist),s.forEach(r=>{r!=null&&(typeof r=="object"&&!Array.isArray(r)?e=e.concat(this.processApplyObject(r)):(Array.isArray(r)||typeof r=="string")&&r.length>0&&t(r))}),e}render(...s){return this.getRulesData(...s).join(`
`)}}function ss(h){return h.replace(/\\3(\d) /g,"$1").replace(/\\([#{}.:;?%&,@+*~'"!^$[\]()=>|/])/g,"$1")}class T extends Y{constructor({moxie:s=L,tabSize:e=2,values:t={},classes:r={},aliases:i={},property:n={},variants:o={},safelist:c=[],typeOrder:a=[],breakpoints:u={},moxieOptions:l={},selectorPrefix:p="",prefixLoaderOptions:g={},reservedVariantChars:f=[],apply:d={},watch:m=!0,debounceDelay:y=10,processExisting:A=!0,selector:v="[class]",styleId:$="tenoxui-browser-id"}={}){super({moxie:s,values:t,aliases:i,classes:r,tabSize:e,property:n,variants:o,safelist:c,typeOrder:a,breakpoints:u,moxieOptions:l,selectorPrefix:p,prefixLoaderOptions:g,reservedVariantChars:f}),this.apply=d,this.watch=m,this.styleId=$,this.selector=v,this.updateTimeout=null,this.debounceDelay=y,this.processExisting=A,this.observer=null,this.styleElement=null,this.isInitialized=!1,this.processedClasses=new Set}init(){return this.isInitialized?(console.warn("TenoxUI is already initialized"),this):(this.createStyleElement(),this.processExisting&&this.scanAndProcessClasses(),this.watch&&this.startObserving(),this.isInitialized=!0,this)}createStyleElement(){return this.styleElement=document.getElementById(this.styleId),this.styleElement||(this.styleElement=document.createElement("style"),this.styleElement.id=this.styleId,this.styleElement.setAttribute("data-tenoxui","true"),document.head.appendChild(this.styleElement)),this.styleElement}scanAndProcessClasses(){const s=document.querySelectorAll(this.selector),e=new Set;s.forEach(t=>{const r=t.classList;r.length>0&&r.forEach(i=>{i.trim()&&e.add(i)})}),e.size>0&&this.processClasses(Array.from(e))}createStyles(s){const e=this.render(this.apply);return this.injectCSS(e+`
`+s)}processClasses(s){const e=s.filter(t=>!this.processedClasses.has(t));e.length!==0&&(e.forEach(t=>this.processedClasses.add(t)),this.createStyles(this.render(e)))}injectCSS(s){return this.styleElement&&s.trim()&&(this.styleElement.textContent+=`
`+s),this}startObserving(){if(!window.MutationObserver){console.warn("MutationObserver not supported, dynamic class detection disabled");return}this.observer=new MutationObserver(s=>{this.debouncedUpdate(()=>{this.handleMutations(s)})}),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]})}handleMutations(s){const e=new Set;s.forEach(t=>{if(t.type==="attributes"&&t.attributeName==="class"){const r=t.target;r.classList&&r.classList.forEach(i=>{i.trim()&&!this.processedClasses.has(i)&&e.add(i)})}t.type==="childList"&&t.addedNodes.length>0&&t.addedNodes.forEach(r=>{r.nodeType===Node.ELEMENT_NODE&&this.extractClassesFromElement(r,e)})}),e.size>0&&this.processClasses(Array.from(e))}extractClassesFromElement(s,e){s.classList&&s.classList.forEach(r=>{r.trim()&&!this.processedClasses.has(r)&&e.add(r)}),s.querySelectorAll("[class]").forEach(r=>{r.classList.forEach(i=>{i.trim()&&!this.processedClasses.has(i)&&e.add(i)})})}debouncedUpdate(s){this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=setTimeout(s,this.debounceDelay)}addClass(...s){const e=[];for(const t of s)Array.isArray(t)?e.push(...t):t&&e.push(t);return this.processClasses(e),this}rescan(){return this.scanAndProcessClasses(),this}refresh(){return this.processedClasses.clear(),this.styleElement&&(this.styleElement.textContent=""),this.scanAndProcessClasses(),this}stopObserving(){return this.observer&&(this.observer.disconnect(),this.observer=null),this}destroy(){return this.stopObserving(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null),this.updateTimeout&&(clearTimeout(this.updateTimeout),this.updateTimeout=null),this.processedClasses.clear(),this.isInitialized=!1,this}status(){const s=Array.from(this.processedClasses),e=this.getRulesData(s),t=this.process(s);return{processedClasses:[s.length,s],validClasses:[e.length,t?t.map(r=>ss(r.className)):[]],isObserving:!!this.observer,isInitialized:this.isInitialized,styleElementExists:!!this.styleElement}}}return E.TenoxUI=T,E.default=T,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),E}({});
//# sourceMappingURL=bundle.iife.js.map