@tachui/responsive 0.8.8 → 0.8.10-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("@tachui/registry"),ae=require("@tachui/modifiers"),u=require("@tachui/core"),g={Clean:0,Check:1,Dirty:2,Disposed:3};let ke=0;const $e=Math.random().toString(36).substr(2,6);let te=null,ie=null;const Me=new Set;Me.add($e);const I={get currentComputation(){return te},set currentComputation(s){te=s},get currentOwner(){return ie},set currentOwner(s){ie=s}};function ce(){return I.currentComputation}function Oe(){return I.currentOwner}class Ve{id;owner;fn;sources=new Set;observers=new Set;state=g.Dirty;value=void 0;constructor(e,t=null){this.id=++ke,this.fn=e,this.owner=t,t&&!t.disposed&&t.sources.add(this)}execute(){if(this.state===g.Disposed)return this.value;for(const t of this.sources)t&&typeof t=="object"&&"removeObserver"in t&&t.removeObserver(this);this.sources.clear();const e=I.currentComputation;I.currentComputation=this;try{return this.state=g.Clean,this.value=this.fn(),this.value}catch(t){throw this.state=g.Disposed,(typeof process>"u"||process.env.NODE_ENV!=="test")&&console.error("Error in computation:",t),t}finally{I.currentComputation=e}}dispose(){if(this.state!==g.Disposed){this.state=g.Disposed;for(const e of this.sources)e&&typeof e=="object"&&"removeObserver"in e&&e.removeObserver(this);this.sources.clear();for(const e of this.observers)e.sources.delete(this);this.observers.clear(),this.owner&&!this.owner.disposed&&this.owner.sources.delete(this)}}}typeof globalThis.__DEV__>"u"&&(globalThis.__DEV__=process.env.NODE_ENV!=="production");const Ee=(s,e)=>s===e;var H=(s=>(s[s.Immediate=0]="Immediate",s[s.High=1]="High",s[s.Normal=2]="Normal",s[s.Low=3]="Low",s[s.Idle=4]="Idle",s))(H||{});class Ie extends Ve{type="computed";priority;_hasValue=!1;_error=null;equalsFn;options;constructor(e,t={},i=Oe()){super(e,i),this.priority=t.priority??H.Normal,this.equalsFn=t.equals??Ee,this.options=t}getValue(){const e=ce();return e&&e.state!==g.Disposed&&(this.observers.add(e),e.sources.add(this)),(this.state===g.Dirty||!this._hasValue)&&(this.execute(),this._hasValue=!0),this.value}peek(){return(this.state===g.Dirty||!this._hasValue)&&(this.execute(),this._hasValue=!0),this.value}removeObserver(e){this.observers.delete(e),this.options.releaseOnNoObservers===!0&&this.observers.size===0&&e.state===g.Disposed&&this.releaseSources()}releaseSources(){for(const e of this.sources)"removeObserver"in e&&e.removeObserver(this);this.sources.clear(),this._hasValue=!1,this.state=g.Dirty}execute(){const e=this._hasValue?this.value:void 0,t=super.execute();if(!this._hasValue||!this.equalsFn(e,t))for(const i of this.observers)i.state!==g.Disposed&&(i.state=g.Dirty,"execute"in i&&typeof i.execute=="function"&&queueMicrotask(()=>{i.state===g.Dirty&&i.execute()}));return t}notify(){this.execute()}cleanup(){for(const e of this.sources)"removeObserver"in e&&e.removeObserver(this);this.sources.clear();for(const e of this.observers)e.sources.delete(this);this.observers.clear(),this._hasValue=!1,this._error=null,this.state=g.Disposed}dispose(){this.cleanup(),super.dispose()}[Symbol.for("tachui.debug")](){return{id:this.id,type:this.type,value:this._hasValue?this.value:void 0,hasValue:this._hasValue,error:this._error?.message,state:this.state,sourceCount:this.sources.size,observerCount:this.observers.size,priority:H[this.priority],debugName:this.options.debugName,equalsFn:this.equalsFn.name||"anonymous"}}toString(){return`Computed(${this.options.debugName||this.id}): ${this._hasValue?this.value:"no value"}`}}function Te(s,e){const t=new Ie(s,e),i=t.getValue.bind(t);return i.peek=t.peek.bind(t),Object.defineProperty(i,Symbol.for("tachui.computed"),{value:t,enumerable:!1}),i}let je=0;class Pe{id;observers=new Set;_value;constructor(e){this.id=++je,this._value=e}getValue(){const e=ce();return e&&e.state!==g.Disposed&&(this.observers.add(e),e.sources.add(this)),this._value}peek(){return this._value}set(e){const t=typeof e=="function"?e(this._value):e;return t!==this._value&&(this._value=t,this.notify()),t}notify(){for(const e of this.observers)e.state!==g.Disposed&&(e.state=g.Dirty,De(e))}removeObserver(e){this.observers.delete(e)}[Symbol.for("tachui.debug")](){return{id:this.id,value:this._value,observerCount:this.observers.size,type:"Signal"}}}const z=new Set;let N=!1;function De(s){z.add(s),N||queueMicrotask(_e)}function _e(){if(!N){N=!0;try{for(;z.size>0;){const s=Array.from(z).sort((e,t)=>e.id-t.id);z.clear();for(const e of s)e.state===g.Dirty&&e.execute()}}finally{N=!1}}}function ze(s){const e=new Pe(s),t=e.getValue.bind(e);t.peek=e.peek.bind(e);const i=e.set.bind(e);return Object.defineProperty(t,Symbol.for("tachui.signal"),{value:e,enumerable:!1}),[t,i]}const[Ne,Ct]=ze("light");Te(()=>{const s=Ne();return s==="system"?qe():s});function qe(){return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}process.env.NODE_ENV,process.env.NODE_ENV;process.env.NODE_ENV==="development"&&console.log("📤 Created RegistryAdapter for globalModifierRegistry",{registryId:Q.globalModifierRegistry.instanceId,currentSize:Q.globalModifierRegistry.list().length});const Le="0.8.8",Ae=Le,re=new WeakSet,se=new WeakMap,Qe={name:"@tachui/core",version:Ae,author:"TachUI Team",verified:!0};function He(s){re.has(s)||(s.setFeatureFlags({metadataRegistration:!0}),re.add(s))}function We(s,e){let t=se.get(s);t||(t=new Set,se.set(s,t)),!t.has(e.name)&&(s.registerPlugin(e),t.add(e.name))}function Fe(s,e,t,i=Q.globalModifierRegistry,r=Qe){He(i),We(i,r),i.has(s)||i.register(s,e),i.getMetadata(s)||i.registerMetadata({...t,name:s,plugin:r.name})}const Ge="0.8.8",Ue=Ge,U={base:"0px",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function S(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)&&Object.keys(s).some(e=>["base","sm","md","lg","xl","2xl"].includes(e))}function W(s){return["base","sm","md","lg","xl","2xl"].includes(s)}let P={...U};const[de,ne]=u.createSignal("base"),[ue,Ke]=u.createSignal({width:0,height:0});function Ze(s){it(s),P={...U,...s},T(),typeof window<"u"&&window.addEventListener("resize",T)}function V(){return{...P}}function x(){return de}function Ye(){return ue}function Xe(){typeof window>"u"||(A(),T(),window.addEventListener("resize",()=>{A(),T()}),window.addEventListener("orientationchange",()=>{setTimeout(()=>{A(),T()},100)}))}function w(){const s=de(),e=ue();return{current:s,width:e.width,height:e.height,isAbove:t=>F(s,t),isBelow:t=>G(s,t),isBetween:(t,i)=>F(s,t)&&G(s,i),matches:t=>window.matchMedia(t).matches}}function q(s){const e=P[s];return e.endsWith("px")?parseInt(e,10):e.endsWith("em")||e.endsWith("rem")?parseInt(e,10)*16:parseInt(e,10)||0}function b(s){return["base","sm","md","lg","xl","2xl"].indexOf(s)}function F(s,e){return b(s)>b(e)}function G(s,e){return b(s)<b(e)}function le(s){return s==="base"?"":`(min-width: ${P[s]})`}function Je(s,e){const t=[];if(s!=="base"&&t.push(`(min-width: ${P[s]})`),e&&e!=="2xl"){const i=["sm","md","lg","xl","2xl"],r=i.indexOf(e);if(r>=0&&r<i.length-1){const o=i[r+1],n=`${q(o)-1}px`;t.push(`(max-width: ${n})`)}}return t.length>0?t.join(" and "):""}function D(){return["base","sm","md","lg","xl","2xl"]}function et(s){const e=D(),t=e.indexOf(s);return t>=0?e.slice(t+1):[]}function tt(s){const e=D(),t=e.indexOf(s);return t>0?e.slice(0,t):[]}function T(){if(typeof window>"u")return;const s=window.innerWidth,e=D().reverse();for(const t of e)if(t==="base"||s>=q(t)){ne(t);return}ne("base")}function A(){typeof window<"u"&&Ke({width:window.innerWidth,height:window.innerHeight})}function it(s){for(const[t,i]of Object.entries(s)){if(!W(t))throw new Error(`Invalid breakpoint key: "${t}". Valid keys are: base, sm, md, lg, xl, 2xl`);if(typeof i!="string")throw new Error(`Breakpoint value for "${t}" must be a string (e.g., "768px")`);if(!i.match(/^\d+(\.\d+)?(px|em|rem|%)$/))throw new Error(`Invalid breakpoint value for "${t}": "${i}". Must be a valid CSS length (e.g., "768px", "48em")`)}const e=Object.keys(s).filter(W).sort((t,i)=>b(t)-b(i));for(let t=1;t<e.length;t++){const i=e[t-1],r=e[t],o=s[i],n=s[r];if(q(i)>=parseInt(n,10))throw new Error(`Breakpoint "${r}" (${n}) must be larger than "${i}" (${o})`)}}const rt={tailwind:{sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},bootstrap:{sm:"576px",md:"768px",lg:"992px",xl:"1200px","2xl":"1400px"},material:{sm:"600px",md:"960px",lg:"1280px",xl:"1920px","2xl":"2560px"},mobileFocus:{sm:"480px",md:"768px",lg:"1024px",xl:"1200px","2xl":"1440px"}};class K{options;constructor(e){this.options={generateMinified:!1,includeComments:!0,optimizeOutput:!0,mobileFirst:!0,...e}}generateResponsiveCSS(e){const t=[],i=[],r={};let o=!1;for(const[n,a]of Object.entries(e))if(S(a)){o=!0;const c=this.generatePropertyMediaQueries(n,a);t.push(...c.mediaQueries),c.baseStyles&&Object.assign(r,c.baseStyles)}else r[this.toCSSPropertyName(n)]=this.formatCSSValue(n,a);return i.push(...this.generateCSSRules(t,r)),{cssRules:i,mediaQueries:t,fallbackStyles:r,hasResponsiveStyles:o}}generatePropertyMediaQueries(e,t){const i=[],r={},o=D();for(const n of o){const a=t[n];if(a===void 0)continue;const c=this.toCSSPropertyName(e),d=this.formatCSSValue(e,a);if(n==="base")r[c]=d;else{const p=le(n),h={[c]:d};i.push({breakpoint:n,query:p,styles:h,selector:this.options.selector})}}return{mediaQueries:i,baseStyles:Object.keys(r).length>0?r:void 0}}generateCSSRules(e,t){const i=[];if(Object.keys(t).length>0){const o=this.generateCSSRule(this.options.selector,t);i.push(o)}const r=this.groupQueriesByMediaQuery(e);for(const[o,n]of Object.entries(r)){if(o==="")continue;const a={};for(const d of n)Object.assign(a,d.styles);const c=this.generateMediaQueryRule(o,this.options.selector,a);i.push(c)}return i}groupQueriesByMediaQuery(e){const t={};for(const i of e)t[i.query]||(t[i.query]=[]),t[i.query].push(i);return t}generateCSSRule(e,t){const{generateMinified:i,includeComments:r}=this.options,o=i?"":" ",n=i?"":`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("@tachui/registry"),ae=require("@tachui/modifiers"),u=require("@tachui/core"),g={Clean:0,Check:1,Dirty:2,Disposed:3};let ke=0;const $e=Math.random().toString(36).substr(2,6);let te=null,ie=null;const Me=new Set;Me.add($e);const I={get currentComputation(){return te},set currentComputation(s){te=s},get currentOwner(){return ie},set currentOwner(s){ie=s}};function ce(){return I.currentComputation}function Oe(){return I.currentOwner}class Ve{id;owner;fn;sources=new Set;observers=new Set;state=g.Dirty;value=void 0;constructor(e,t=null){this.id=++ke,this.fn=e,this.owner=t,t&&!t.disposed&&t.sources.add(this)}execute(){if(this.state===g.Disposed)return this.value;for(const t of this.sources)t&&typeof t=="object"&&"removeObserver"in t&&t.removeObserver(this);this.sources.clear();const e=I.currentComputation;I.currentComputation=this;try{return this.state=g.Clean,this.value=this.fn(),this.value}catch(t){throw this.state=g.Disposed,(typeof process>"u"||process.env.NODE_ENV!=="test")&&console.error("Error in computation:",t),t}finally{I.currentComputation=e}}dispose(){if(this.state!==g.Disposed){this.state=g.Disposed;for(const e of this.sources)e&&typeof e=="object"&&"removeObserver"in e&&e.removeObserver(this);this.sources.clear();for(const e of this.observers)e.sources.delete(this);this.observers.clear(),this.owner&&!this.owner.disposed&&this.owner.sources.delete(this)}}}typeof globalThis.__DEV__>"u"&&(globalThis.__DEV__=process.env.NODE_ENV!=="production");const Ee=(s,e)=>s===e;var H=(s=>(s[s.Immediate=0]="Immediate",s[s.High=1]="High",s[s.Normal=2]="Normal",s[s.Low=3]="Low",s[s.Idle=4]="Idle",s))(H||{});class Ie extends Ve{type="computed";priority;_hasValue=!1;_error=null;equalsFn;options;constructor(e,t={},i=Oe()){super(e,i),this.priority=t.priority??H.Normal,this.equalsFn=t.equals??Ee,this.options=t}getValue(){const e=ce();return e&&e.state!==g.Disposed&&(this.observers.add(e),e.sources.add(this)),(this.state===g.Dirty||!this._hasValue)&&(this.execute(),this._hasValue=!0),this.value}peek(){return(this.state===g.Dirty||!this._hasValue)&&(this.execute(),this._hasValue=!0),this.value}removeObserver(e){this.observers.delete(e),this.options.releaseOnNoObservers===!0&&this.observers.size===0&&e.state===g.Disposed&&this.releaseSources()}releaseSources(){for(const e of this.sources)"removeObserver"in e&&e.removeObserver(this);this.sources.clear(),this._hasValue=!1,this.state=g.Dirty}execute(){const e=this._hasValue?this.value:void 0,t=super.execute();if(!this._hasValue||!this.equalsFn(e,t))for(const i of this.observers)i.state!==g.Disposed&&(i.state=g.Dirty,"execute"in i&&typeof i.execute=="function"&&queueMicrotask(()=>{i.state===g.Dirty&&i.execute()}));return t}notify(){this.execute()}cleanup(){for(const e of this.sources)"removeObserver"in e&&e.removeObserver(this);this.sources.clear();for(const e of this.observers)e.sources.delete(this);this.observers.clear(),this._hasValue=!1,this._error=null,this.state=g.Disposed}dispose(){this.cleanup(),super.dispose()}[Symbol.for("tachui.debug")](){return{id:this.id,type:this.type,value:this._hasValue?this.value:void 0,hasValue:this._hasValue,error:this._error?.message,state:this.state,sourceCount:this.sources.size,observerCount:this.observers.size,priority:H[this.priority],debugName:this.options.debugName,equalsFn:this.equalsFn.name||"anonymous"}}toString(){return`Computed(${this.options.debugName||this.id}): ${this._hasValue?this.value:"no value"}`}}function Te(s,e){const t=new Ie(s,e),i=t.getValue.bind(t);return i.peek=t.peek.bind(t),Object.defineProperty(i,Symbol.for("tachui.computed"),{value:t,enumerable:!1}),i}let je=0;class Pe{id;observers=new Set;_value;constructor(e){this.id=++je,this._value=e}getValue(){const e=ce();return e&&e.state!==g.Disposed&&(this.observers.add(e),e.sources.add(this)),this._value}peek(){return this._value}set(e){const t=typeof e=="function"?e(this._value):e;return t!==this._value&&(this._value=t,this.notify()),t}notify(){for(const e of this.observers)e.state!==g.Disposed&&(e.state=g.Dirty,De(e))}removeObserver(e){this.observers.delete(e)}[Symbol.for("tachui.debug")](){return{id:this.id,value:this._value,observerCount:this.observers.size,type:"Signal"}}}const z=new Set;let N=!1;function De(s){z.add(s),N||queueMicrotask(_e)}function _e(){if(!N){N=!0;try{for(;z.size>0;){const s=Array.from(z).sort((e,t)=>e.id-t.id);z.clear();for(const e of s)e.state===g.Dirty&&e.execute()}}finally{N=!1}}}function ze(s){const e=new Pe(s),t=e.getValue.bind(e);t.peek=e.peek.bind(e);const i=e.set.bind(e);return Object.defineProperty(t,Symbol.for("tachui.signal"),{value:e,enumerable:!1}),[t,i]}const[Ne,Ct]=ze("light");Te(()=>{const s=Ne();return s==="system"?qe():s});function qe(){return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}process.env.NODE_ENV,process.env.NODE_ENV;process.env.NODE_ENV==="development"&&console.log("📤 Created RegistryAdapter for globalModifierRegistry",{registryId:Q.globalModifierRegistry.instanceId,currentSize:Q.globalModifierRegistry.list().length});const Le="0.8.10-alpha.0",Ae=Le,re=new WeakSet,se=new WeakMap,Qe={name:"@tachui/core",version:Ae,author:"TachUI Team",verified:!0};function He(s){re.has(s)||(s.setFeatureFlags({metadataRegistration:!0}),re.add(s))}function We(s,e){let t=se.get(s);t||(t=new Set,se.set(s,t)),!t.has(e.name)&&(s.registerPlugin(e),t.add(e.name))}function Fe(s,e,t,i=Q.globalModifierRegistry,r=Qe){He(i),We(i,r),i.has(s)||i.register(s,e),i.getMetadata(s)||i.registerMetadata({...t,name:s,plugin:r.name})}const Ge="0.8.10-alpha.0",Ue=Ge,U={base:"0px",sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function S(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)&&Object.keys(s).some(e=>["base","sm","md","lg","xl","2xl"].includes(e))}function W(s){return["base","sm","md","lg","xl","2xl"].includes(s)}let P={...U};const[de,ne]=u.createSignal("base"),[ue,Ke]=u.createSignal({width:0,height:0});function Ze(s){it(s),P={...U,...s},T(),typeof window<"u"&&window.addEventListener("resize",T)}function V(){return{...P}}function x(){return de}function Ye(){return ue}function Xe(){typeof window>"u"||(A(),T(),window.addEventListener("resize",()=>{A(),T()}),window.addEventListener("orientationchange",()=>{setTimeout(()=>{A(),T()},100)}))}function w(){const s=de(),e=ue();return{current:s,width:e.width,height:e.height,isAbove:t=>F(s,t),isBelow:t=>G(s,t),isBetween:(t,i)=>F(s,t)&&G(s,i),matches:t=>window.matchMedia(t).matches}}function q(s){const e=P[s];return e.endsWith("px")?parseInt(e,10):e.endsWith("em")||e.endsWith("rem")?parseInt(e,10)*16:parseInt(e,10)||0}function b(s){return["base","sm","md","lg","xl","2xl"].indexOf(s)}function F(s,e){return b(s)>b(e)}function G(s,e){return b(s)<b(e)}function le(s){return s==="base"?"":`(min-width: ${P[s]})`}function Je(s,e){const t=[];if(s!=="base"&&t.push(`(min-width: ${P[s]})`),e&&e!=="2xl"){const i=["sm","md","lg","xl","2xl"],r=i.indexOf(e);if(r>=0&&r<i.length-1){const o=i[r+1],n=`${q(o)-1}px`;t.push(`(max-width: ${n})`)}}return t.length>0?t.join(" and "):""}function D(){return["base","sm","md","lg","xl","2xl"]}function et(s){const e=D(),t=e.indexOf(s);return t>=0?e.slice(t+1):[]}function tt(s){const e=D(),t=e.indexOf(s);return t>0?e.slice(0,t):[]}function T(){if(typeof window>"u")return;const s=window.innerWidth,e=D().reverse();for(const t of e)if(t==="base"||s>=q(t)){ne(t);return}ne("base")}function A(){typeof window<"u"&&Ke({width:window.innerWidth,height:window.innerHeight})}function it(s){for(const[t,i]of Object.entries(s)){if(!W(t))throw new Error(`Invalid breakpoint key: "${t}". Valid keys are: base, sm, md, lg, xl, 2xl`);if(typeof i!="string")throw new Error(`Breakpoint value for "${t}" must be a string (e.g., "768px")`);if(!i.match(/^\d+(\.\d+)?(px|em|rem|%)$/))throw new Error(`Invalid breakpoint value for "${t}": "${i}". Must be a valid CSS length (e.g., "768px", "48em")`)}const e=Object.keys(s).filter(W).sort((t,i)=>b(t)-b(i));for(let t=1;t<e.length;t++){const i=e[t-1],r=e[t],o=s[i],n=s[r];if(q(i)>=parseInt(n,10))throw new Error(`Breakpoint "${r}" (${n}) must be larger than "${i}" (${o})`)}}const rt={tailwind:{sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"},bootstrap:{sm:"576px",md:"768px",lg:"992px",xl:"1200px","2xl":"1400px"},material:{sm:"600px",md:"960px",lg:"1280px",xl:"1920px","2xl":"2560px"},mobileFocus:{sm:"480px",md:"768px",lg:"1024px",xl:"1200px","2xl":"1440px"}};class K{options;constructor(e){this.options={generateMinified:!1,includeComments:!0,optimizeOutput:!0,mobileFirst:!0,...e}}generateResponsiveCSS(e){const t=[],i=[],r={};let o=!1;for(const[n,a]of Object.entries(e))if(S(a)){o=!0;const c=this.generatePropertyMediaQueries(n,a);t.push(...c.mediaQueries),c.baseStyles&&Object.assign(r,c.baseStyles)}else r[this.toCSSPropertyName(n)]=this.formatCSSValue(n,a);return i.push(...this.generateCSSRules(t,r)),{cssRules:i,mediaQueries:t,fallbackStyles:r,hasResponsiveStyles:o}}generatePropertyMediaQueries(e,t){const i=[],r={},o=D();for(const n of o){const a=t[n];if(a===void 0)continue;const c=this.toCSSPropertyName(e),d=this.formatCSSValue(e,a);if(n==="base")r[c]=d;else{const p=le(n),h={[c]:d};i.push({breakpoint:n,query:p,styles:h,selector:this.options.selector})}}return{mediaQueries:i,baseStyles:Object.keys(r).length>0?r:void 0}}generateCSSRules(e,t){const i=[];if(Object.keys(t).length>0){const o=this.generateCSSRule(this.options.selector,t);i.push(o)}const r=this.groupQueriesByMediaQuery(e);for(const[o,n]of Object.entries(r)){if(o==="")continue;const a={};for(const d of n)Object.assign(a,d.styles);const c=this.generateMediaQueryRule(o,this.options.selector,a);i.push(c)}return i}groupQueriesByMediaQuery(e){const t={};for(const i of e)t[i.query]||(t[i.query]=[]),t[i.query].push(i);return t}generateCSSRule(e,t){const{generateMinified:i,includeComments:r}=this.options,o=i?"":" ",n=i?"":`
2
2
  `,a=i?"":" ";let c=`${e}${a}{${n}`;for(const[d,p]of Object.entries(t))c+=`${o}${d}:${a}${p};${n}`;return c+=`}${n}`,r&&!i&&(c=`/* Base styles (mobile-first) */${n}${c}`),c}generateMediaQueryRule(e,t,i){const{generateMinified:r,includeComments:o}=this.options,n=r?"":" ",a=r?"":" ",c=r?"":`
3
3
  `,d=r?"":" ";let p=`@media ${e}${d}{${c}`;p+=`${n}${t}${d}{${c}`;for(const[h,m]of Object.entries(i))p+=`${a}${h}:${d}${m};${c}`;return p+=`${n}}${c}`,p+=`}${c}`,o&&!r&&(p=`/* ${this.getBreakpointFromQuery(e)} styles */${c}${p}`),p}toCSSProperty(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}formatCSSValue(e,t){if(t==null)return"inherit";if(typeof t=="number"){const i=["opacity","z-index","font-weight","line-height","flex-grow","flex-shrink","order","grid-column-start","grid-column-end","grid-row-start","grid-row-end"],r=this.toCSSProperty(e);if(i.includes(r))return this.addImportantIfNeeded(e,t.toString());if(["width","height","min-width","max-width","min-height","max-height","padding","margin","border-width","border-radius","top","right","bottom","left","font-size","letter-spacing","text-indent"].some(n=>r.includes(n)))return this.addImportantIfNeeded(e,`${t}px`)}return this.addImportantIfNeeded(e,t.toString())}addImportantIfNeeded(e,t){const i=["flexDirection","flex-direction","justifyContent","justify-content","alignItems","align-items","display"],r=this.toCSSProperty(e);return i.includes(e)||i.includes(r)?`${t} !important`:t}toCSSPropertyName(e){return this.toCSSProperty(e)}getBreakpointFromQuery(e){const t=V();for(const[i,r]of Object.entries(t))if(e.includes(r))return i;return"custom"}}function st(s,e,t,i){if(!S(t)){const a=e.replace(/[A-Z]/g,d=>`-${d.toLowerCase()}`),c=typeof t=="number"?`${t}px`:t.toString();return[`${s} { ${a}: ${c}; }`]}const r=new K({selector:s,...i}),o={[e]:t};return r.generateResponsiveCSS(o).cssRules}function nt(s,e,t){const{generateMinified:i=!1}=t||{},r=i?"":" ",o=i?"":`
4
4
  `,n=i?"":" ";let a=`@media ${e.query}${n}{${o}`;a+=`${r}${s}${n}{${o}`;for(const[c,d]of Object.entries(e.styles)){const p=c.replace(/[A-Z]/g,m=>`-${m.toLowerCase()}`),h=typeof d=="number"?`${d}px`:d.toString();a+=`${r}${r}${p}:${n}${h};${o}`}return a+=`${r}}${o}`,a+=`}${o}`,a}class Z{static styleSheet=null;static injectedRules=new Set;static getStyleSheet(){if(this.styleSheet)return this.styleSheet;const e=document.createElement("style");return e.setAttribute("data-tachui-responsive","true"),document.head.appendChild(e),this.styleSheet=e.sheet,this.styleSheet}static injectCSS(e){if(typeof document>"u")return;const t=this.getStyleSheet();for(const i of e)if(!this.injectedRules.has(i))try{t.insertRule(i,t.cssRules.length),this.injectedRules.add(i)}catch(r){console.warn("Failed to inject CSS rule:",i,r)}}static clearCSS(){if(this.styleSheet){for(;this.styleSheet.cssRules.length>0;)this.styleSheet.deleteRule(0);this.injectedRules.clear()}}static hasRule(e){return this.injectedRules.has(e)}}class ot{cache=new Map;hitCount=0;missCount=0;get(e){const t=this.cache.get(e);return t?this.hitCount++:this.missCount++,t}set(e,t){this.cache.set(e,t)}clear(){this.cache.clear(),this.hitCount=0,this.missCount=0}getStats(){return{size:this.cache.size,hitRate:this.hitCount/(this.hitCount+this.missCount)||0,hits:this.hitCount,misses:this.missCount}}}const k=new ot;class at{static BATCH_SIZE=50;static ruleQueue=[];static flushTimer=null;static generateOptimizedCSS(e,t,i={}){const{minify:r=process.env.NODE_ENV==="production",batch:o=!0,deduplicate:n=!0}=i,a=this.createCacheKey(e,t,{minify:r});if(n){const d=k.get(a);if(d)return d}const c=this.generateCSS(e,t,{minify:r});return n&&k.set(a,c),o&&c.trim()?(this.addToBatch(c),""):c}static createCacheKey(e,t,i){return JSON.stringify({selector:e,config:t,options:i})}static generateCSS(e,t,i){const{minify:r=!1}=i,o=r?"":" ",n=r?"":`