stoop 0.4.1 → 0.5.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/README.md CHANGED
@@ -61,10 +61,15 @@ const Button = styled("button", {
61
61
 
62
62
  ## Documentation
63
63
 
64
- - **[GUIDE.md](./docs/GUIDE.md)** - Step-by-step setup and usage guide
65
- - **[API.md](./docs/API.md)** - Complete API reference
66
- - **[ARCHITECTURE.md](./docs/ARCHITECTURE.md)** - Internal implementation details
67
- - **[TESTING.md](./docs/TESTING.md)** - Testing guide and test suite documentation
64
+ 📚 **[Full Documentation →](https://stoop.dolmios.com)**
65
+
66
+ - [Installation](https://stoop.dolmios.com/installation)
67
+ - [Theme Setup](https://stoop.dolmios.com/theme-setup)
68
+ - [Creating Components](https://stoop.dolmios.com/creating-components)
69
+ - [SSR Guide](https://stoop.dolmios.com/ssr)
70
+ - [API Reference](https://stoop.dolmios.com/api)
71
+
72
+ For internal architecture details, see [ARCHITECTURE.md](./ARCHITECTURE.md) (developer-only).
68
73
 
69
74
  ## API Overview
70
75
 
@@ -32,3 +32,4 @@ export declare function createCSSFunction(defaultTheme: Theme, prefix?: string,
32
32
  * @returns Function that accepts keyframes objects and returns animation names
33
33
  */
34
34
  export declare function createKeyframesFunction(prefix?: string, theme?: Theme, themeMap?: Record<string, ThemeScale>): (keyframes: Record<string, CSS>) => string;
35
+ export declare function createGlobalCSSFunction(defaultTheme: Theme, prefix?: string, media?: Record<string, string>, utils?: Record<string, UtilityFunction>, themeMap?: Record<string, ThemeScale>): (styles: CSS) => () => void;
@@ -4,7 +4,7 @@
4
4
  * and CSS prop merging. Supports component targeting via selector references.
5
5
  */
6
6
  import { forwardRef, type Context } from "react";
7
- import type { CSS, StyledComponentProps, StyledComponentRef, StylableElement, Theme, ThemeContextValue, ThemeScale, UtilityFunction, Variants } from "../types";
7
+ import type { CSS, CSSWithVariants, StyledComponentProps, StyledComponentRef, StylableElement, Theme, ThemeContextValue, ThemeScale, UtilityFunction } from "../types";
8
8
  /**
9
9
  * Creates a styled component reference for selector targeting.
10
10
  *
@@ -12,11 +12,6 @@ import type { CSS, StyledComponentProps, StyledComponentRef, StylableElement, Th
12
12
  * @returns StyledComponentRef for use in CSS selectors
13
13
  */
14
14
  export declare function createStyledComponentRef(className: string): StyledComponentRef;
15
- type CSSWithVariants = {
16
- [K in keyof CSS]: CSS[K];
17
- } & {
18
- variants: Variants;
19
- };
20
15
  /**
21
16
  * Creates a styled component factory function.
22
17
  * Supports polymorphic components, variants, theme awareness, and CSS prop merging.
@@ -33,8 +28,7 @@ export declare function createStyledFunction(defaultTheme: Theme, prefix?: strin
33
28
  <DefaultElement extends StylableElement, BaseStyles extends CSSWithVariants>(defaultElement: DefaultElement, baseStyles: BaseStyles): ReturnType<typeof forwardRef<unknown, StyledComponentProps<DefaultElement, BaseStyles["variants"]>>> & {
34
29
  selector: StyledComponentRef;
35
30
  };
36
- <DefaultElement extends StylableElement, VariantsConfig extends Variants = {}>(defaultElement: DefaultElement, baseStyles?: CSS, variants?: VariantsConfig): ReturnType<typeof forwardRef<unknown, StyledComponentProps<DefaultElement, VariantsConfig>>> & {
31
+ <DefaultElement extends StylableElement>(defaultElement: DefaultElement, baseStyles?: CSS): ReturnType<typeof forwardRef<unknown, StyledComponentProps<DefaultElement, {}>>> & {
37
32
  selector: StyledComponentRef;
38
33
  };
39
34
  };
40
- export {};
@@ -17,7 +17,6 @@ export declare const classNameCache: LRUCache<string, string>;
17
17
  export declare const cssStringCache: LRUCache<string, string>;
18
18
  /**
19
19
  * Checks if a CSS string has been injected.
20
- * Uses a Set for O(1) lookup.
21
20
  *
22
21
  * @param css - CSS string to check
23
22
  * @returns True if CSS has been injected
@@ -0,0 +1,19 @@
1
+ /**
2
+ * CSS property name stringification utilities.
3
+ * Handles conversion of camelCase CSS property names to kebab-case,
4
+ * including proper vendor prefix detection and normalization.
5
+ */
6
+ /**
7
+ * Sanitizes CSS property names to prevent injection attacks.
8
+ * Handles vendor prefixes, camelCase conversion, and edge cases.
9
+ *
10
+ * Vendor prefix patterns handled:
11
+ * - Moz* → -moz-*
12
+ * - Webkit* → -webkit-*
13
+ * - ms* → -ms-*
14
+ * - O* → -o-*
15
+ *
16
+ * @param propertyName - Property name to sanitize
17
+ * @returns Sanitized property name
18
+ */
19
+ export declare function sanitizeCSSPropertyName(propertyName: string): string;
@@ -1,8 +1,6 @@
1
1
  /**
2
2
  * Theme variable management.
3
- * Updates CSS custom properties when theme changes.
4
- * Ensures CSS variables are injected and kept in sync with theme updates.
5
- * Automatically merges themes with the default theme when applied.
3
+ * Updates CSS custom properties when theme changes and merges themes with the default theme.
6
4
  */
7
5
  import type { Theme } from "../types";
8
6
  /**
@@ -21,9 +19,7 @@ export declare function registerDefaultTheme(theme: Theme, prefix?: string): voi
21
19
  */
22
20
  export declare function getDefaultTheme(prefix?: string): Theme | null;
23
21
  /**
24
- * Core theme merging logic.
25
22
  * Merges source theme into target theme, handling nested objects.
26
- * Shared implementation used by both mergeWithDefaultTheme and createTheme.
27
23
  *
28
24
  * @param target - Target theme to merge into
29
25
  * @param source - Source theme to merge from
@@ -31,9 +27,7 @@ export declare function getDefaultTheme(prefix?: string): Theme | null;
31
27
  */
32
28
  export declare function mergeThemes(target: Theme, source: Theme | Partial<Theme>): Theme;
33
29
  /**
34
- * Merges a theme with the default theme if it's not already the default theme.
35
- * This ensures all themes extend the default theme, keeping all original properties.
36
- * Uses caching to avoid repeated merging of the same theme objects.
30
+ * Merges a theme with the default theme, ensuring all themes extend the default theme.
37
31
  *
38
32
  * @param theme - Theme to merge
39
33
  * @param prefix - Optional prefix for theme scoping
@@ -42,9 +36,7 @@ export declare function mergeThemes(target: Theme, source: Theme | Partial<Theme
42
36
  export declare function mergeWithDefaultTheme(theme: Theme, prefix?: string): Theme;
43
37
  /**
44
38
  * Injects CSS variables for all themes using attribute selectors.
45
- * This allows all themes to be available simultaneously, with theme switching
46
- * handled by changing the data-theme attribute. This prevents layout shifts
47
- * and eliminates the need to replace CSS variables on theme change.
39
+ * All themes are available simultaneously, with theme switching handled by changing the data-theme attribute.
48
40
  *
49
41
  * @param themes - Map of theme names to theme objects
50
42
  * @param prefix - Optional prefix for CSS variable names
@@ -4,24 +4,22 @@
4
4
  * React types are only imported conditionally when creating client instances.
5
5
  */
6
6
  import type { CSS, StoopConfig, Theme, ThemeScale } from "./types";
7
- import { createCSSFunction, createKeyframesFunction } from "./api/core-api";
8
- import { createGlobalCSSFunction } from "./api/global-css";
7
+ import { createCSSFunction, createKeyframesFunction, createGlobalCSSFunction } from "./api/core-api";
9
8
  /**
10
9
  * Shared implementation for creating Stoop instances.
11
10
  * Handles common setup logic for both client and server instances.
12
- * Exported for use in SSR entry point.
13
11
  */
14
12
  export declare function createStoopBase(config: StoopConfig): {
15
13
  config: StoopConfig;
16
14
  createTheme: (overrides?: Partial<Theme>) => Theme;
17
15
  css: ReturnType<typeof createCSSFunction>;
18
- getCssText: (theme?: string | Theme) => string;
16
+ getCssText: () => string;
19
17
  globalCss: ReturnType<typeof createGlobalCSSFunction>;
20
18
  globalCssConfig: StoopConfig["globalCss"];
21
19
  keyframes: ReturnType<typeof createKeyframesFunction>;
22
20
  media: StoopConfig["media"];
23
21
  mergedThemeMap: Record<string, ThemeScale>;
24
- preloadTheme: (theme: string | Theme) => void;
22
+ preloadTheme: () => void;
25
23
  sanitizedPrefix: string;
26
24
  theme: Theme;
27
25
  utils: StoopConfig["utils"];
@@ -2,8 +2,6 @@
2
2
  * SSR-safe entry point for Stoop.
3
3
  * Exports only server-safe APIs that don't require React.
4
4
  * Use this import in Server Components: import { createStoop } from "stoop/ssr"
5
- *
6
- * This file does NOT import React types or create React components.
7
5
  */
8
6
  import type { StoopConfig, StoopServerInstance } from "./types";
9
7
  export type { CSS, Theme, StoopConfig, StoopServerInstance, UtilityFunction, ThemeScale, DefaultTheme, } from "./types";
@@ -1,16 +1,16 @@
1
- var J0=Object.freeze({}),j=1e4,GJ=5000,QJ=10,FJ=500,P=1000;var c=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],N={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},ZJ=Symbol.for("stoop.component");class L extends Map{maxSize;constructor(J){super();this.maxSize=J}get(J){let $=super.get(J);if($!==void 0)super.delete(J),super.set(J,$);return $}set(J,$){if(super.has(J))super.delete(J);else if(this.size>=this.maxSize){let Y=this.keys().next().value;if(Y!==void 0)super.delete(Y)}return super.set(J,$),this}}var WJ=new L(GJ),n=new L(j);function K(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function g(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function v(J){return typeof J==="object"&&J!==null}function p(J){return typeof J==="object"&&J!==null&&"__isStoopStyled"in J&&"__stoopClassName"in J&&J.__isStoopStyled===!0}function m(J){return v(J)&&!p(J)}function o(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function x(J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("[Stoop] Theme must be a non-null object");if(g())return J;let $=J,Y=[];for(let q in $){if(q==="media")continue;if(!c.includes(q))Y.push(q)}if(Y.length>0){let q=`[Stoop] Theme contains invalid scales: ${Y.join(", ")}. Only these scales are allowed: ${c.join(", ")}`;throw new Error(q)}return J}function z(J,$){if(!$||!J||typeof J!=="object")return J;let Y={},q=Object.keys($);for(let X in J){let F=J[X];if(q.includes(X)&&$[X])try{let Q=$[X](F);if(Q&&typeof Q==="object")for(let Z in Q)Y[Z]=Q[Z]}catch{Y[X]=F}else if(v(F))Y[X]=z(F,$);else Y[X]=F}return Y}var l=null,DJ=new L(P),wJ=new L(P),Z0=new L(P),HJ=new L(P);function b(J){let q=2166136261;for(let X=0;X<J.length;X++)q^=J.charCodeAt(X),q=Math.imul(q,16777619);return q^=J.length,(q>>>0).toString(36)}function T(J){try{return b(JSON.stringify(J))}catch{return b(String(J))}}function cJ(J){return J.replace(/([A-Z])/g,"-$1").toLowerCase()}function UJ(J,$=!1){let q=String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if($)q=q.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return q}function BJ(J){return UJ(J,!1)}function I(J){let $=DJ.get(J);if($!==void 0)return $;let Y=J.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),q=!Y.trim()||/^[>+~:.#[\]&@()\s]+$/.test(Y)?"":Y;return DJ.set(J,q),q}function R(J){let $=HJ.get(J);if($!==void 0)return $;let X=J.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return HJ.set(J,X),X}function LJ(J){return UJ(J,!0)}function B(J){if(!J)return"stoop";return J.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function _J(J){if(!J||typeof J!=="string")return"";let $=J.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!$.trim()||!/[a-zA-Z]/.test($))return"";return $}function C(J){if(!J||typeof J!=="string")return"";let $=wJ.get(J);if($!==void 0)return $;let X=cJ(J).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return wJ.set(J,X),X}function AJ(J){if(!J||typeof J!=="string")return!1;if(J==="from"||J==="to")return!0;if(/^\d+(\.\d+)?%$/.test(J)){let Y=parseFloat(J);return Y>=0&&Y<=100}return!1}function KJ(J=""){if(!l){let Y=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");l=new RegExp(`${Y}\\s*\\{[\\s\\S]*\\}`)}return l}function nJ(J){if(J.includes("Color")||J==="fill"||J==="stroke"||J==="accentColor"||J==="caretColor"||J==="border"||J==="outline"||J.includes("background")&&!J.includes("Size")&&!J.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test(J)||J.includes("Block")||J.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test(J)||J.includes("BlockSize")||J.includes("InlineSize"))return"sizes";if(J==="fontSize"||J==="font"&&!J.includes("Family"))return"fontSizes";if(J==="fontFamily"||J.includes("FontFamily"))return"fonts";if(J==="fontWeight"||J.includes("FontWeight"))return"fontWeights";if(J==="letterSpacing"||J.includes("LetterSpacing"))return"letterSpacings";if(J.includes("Radius")||J.includes("radius"))return"radii";if(J.includes("Shadow")||J.includes("shadow")||J==="filter"||J==="backdropFilter")return"shadows";if(J==="zIndex"||J.includes("ZIndex")||J.includes("z-index"))return"zIndices";if(J==="opacity"||J.includes("Opacity"))return"opacities";if(J.startsWith("transition")||J.startsWith("animation")||J.includes("Transition")||J.includes("Animation"))return"transitions";return}function OJ(J,$){if($&&J in $)return $[J];if(J in N)return N[J];return nJ(J)}var r=new Map;function S(J){return r.has(J)}function f(J,$){r.set(J,$)}var i=new L(j);function MJ(J){if(!i.has(J))i.set(J,!0)}function IJ(){return Array.from(i.keys()).join(`
2
- `)}var k=new Map;var RJ=new Map;function EJ(J="stoop"){if(!K())throw new Error("Cannot access document in SSR context");let $=B(J),Y=k.get($);if(!Y||!Y.parentNode){let q=document.getElementById("stoop-ssr");if(q){let X=q.getAttribute("data-stoop");if(!X||X===$)return Y=q,Y.setAttribute("data-stoop",$),k.set($,Y),Y}Y=document.createElement("style"),Y.setAttribute("data-stoop",$),Y.setAttribute("id",`stoop-${$}`),document.head.appendChild(Y),k.set($,Y)}return Y}function a(J){let $=J,Y=KJ("");$=$.replace(Y,"").trim();let q=$.indexOf("[data-theme=");while(q!==-1){let X=$.indexOf("{",q);if(X===-1)break;let F=1,Q=X+1;while(Q<$.length&&F>0){if($[Q]==="{")F++;else if($[Q]==="}")F--;Q++}if(F===0){let Z=$.substring(0,q).trim(),G=$.substring(Q).trim();$=(Z+`
3
- `+G).trim()}else break;q=$.indexOf("[data-theme=")}return $.trim()}function VJ(J,$="stoop"){if(!J)return;let Y=B($),q=`__all_theme_vars_${Y}`;if((RJ.get(q)??null)===J)return;if(RJ.set(q,J),!K()){MJ(J);return}let F=EJ(Y),Q=F.textContent||"",Z=Q.includes(":root")||Q.includes("[data-theme=");if(S(q)||Z){let G=a(Q);F.textContent=J+(G?`
1
+ var $0=Object.freeze({}),x=1e4,QJ=5000,ZJ=10,WJ=500,E=1000;var c=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],z={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},DJ=Symbol.for("stoop.component");class L extends Map{maxSize;constructor(J){super();this.maxSize=J}get(J){let $=super.get(J);if($!==void 0)super.delete(J),super.set(J,$);return $}set(J,$){if(super.has(J))super.delete(J);else if(this.size>=this.maxSize){let Y=this.keys().next().value;if(Y!==void 0)super.delete(Y)}return super.set(J,$),this}}var wJ=new L(QJ),o=new L(x);function R(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function v(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function N(J){return typeof J==="object"&&J!==null}function m(J){return typeof J==="object"&&J!==null&&"__isStoopStyled"in J&&"__stoopClassName"in J&&J.__isStoopStyled===!0}function p(J){return N(J)&&!m(J)}function i(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function T(J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("[Stoop] Theme must be a non-null object");if(v())return J;let $=J,Y=[];for(let q in $){if(q==="media")continue;if(!c.includes(q))Y.push(q)}if(Y.length>0){let q=`[Stoop] Theme contains invalid scales: ${Y.join(", ")}. Only these scales are allowed: ${c.join(", ")}`;throw new Error(q)}return J}function j(J,$){if(!$||!J||typeof J!=="object")return J;let Y={},q=Object.keys($);for(let X in J){let Z=J[X];if(q.includes(X)&&$[X])try{let G=$[X](Z);if(G&&typeof G==="object")for(let Q in G)Y[Q]=G[Q]}catch{Y[X]=Z}else if(N(Z))Y[X]=j(Z,$);else Y[X]=Z}return Y}var l=null,UJ=new L(E),W0=new L(E),HJ=new L(E);function b(J){let q=2166136261;for(let X=0;X<J.length;X++)q^=J.charCodeAt(X),q=Math.imul(q,16777619);return q^=J.length,(q>>>0).toString(36)}function r(J){try{return b(JSON.stringify(J))}catch{return b(String(J))}}function BJ(J,$=!1){let q=String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if($)q=q.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return q}function LJ(J){return BJ(J,!1)}function O(J){let $=UJ.get(J);if($!==void 0)return $;let Y=J.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),q=!Y.trim()||/^[>+~:.#[\]&@()\s]+$/.test(Y)?"":Y;return UJ.set(J,q),q}function M(J){let $=HJ.get(J);if($!==void 0)return $;let X=J.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return HJ.set(J,X),X}function _J(J){return BJ(J,!0)}function B(J){if(!J)return"stoop";return J.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function AJ(J){if(!J||typeof J!=="string")return"";let $=J.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!$.trim()||!/[a-zA-Z]/.test($))return"";return $}function IJ(J){if(!J||typeof J!=="string")return!1;if(J==="from"||J==="to")return!0;if(/^\d+(\.\d+)?%$/.test(J)){let Y=parseFloat(J);return Y>=0&&Y<=100}return!1}function RJ(J=""){if(!l){let Y=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");l=new RegExp(`${Y}\\s*\\{[\\s\\S]*\\}`)}return l}function hJ(J){if(J.includes("Color")||J==="fill"||J==="stroke"||J==="accentColor"||J==="caretColor"||J==="border"||J==="outline"||J.includes("background")&&!J.includes("Size")&&!J.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test(J)||J.includes("Block")||J.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test(J)||J.includes("BlockSize")||J.includes("InlineSize"))return"sizes";if(J==="fontSize"||J==="font"&&!J.includes("Family"))return"fontSizes";if(J==="fontFamily"||J.includes("FontFamily"))return"fonts";if(J==="fontWeight"||J.includes("FontWeight"))return"fontWeights";if(J==="letterSpacing"||J.includes("LetterSpacing"))return"letterSpacings";if(J.includes("Radius")||J.includes("radius"))return"radii";if(J.includes("Shadow")||J.includes("shadow")||J==="filter"||J==="backdropFilter")return"shadows";if(J==="zIndex"||J.includes("ZIndex")||J.includes("z-index"))return"zIndices";if(J==="opacity"||J.includes("Opacity"))return"opacities";if(J.startsWith("transition")||J.startsWith("animation")||J.includes("Transition")||J.includes("Animation"))return"transitions";return}function KJ(J,$){if($&&J in $)return $[J];if(J in z)return z[J];return hJ(J)}var a=new Map;function k(J){return a.has(J)}function C(J,$){a.set(J,$)}var s=new L(x);function EJ(J){if(!s.has(J))s.set(J,!0)}function OJ(){return Array.from(s.keys()).join(`
2
+ `)}var f=new Map;var MJ=new Map;function VJ(J="stoop"){if(!R())throw new Error("Cannot access document in SSR context");let $=B(J),Y=f.get($);if(!Y||!Y.parentNode){let q=document.getElementById("stoop-ssr");if(q){let X=q.getAttribute("data-stoop");if(!X||X===$)return Y=q,Y.setAttribute("data-stoop",$),f.set($,Y),Y}Y=document.createElement("style"),Y.setAttribute("data-stoop",$),Y.setAttribute("id",`stoop-${$}`),document.head.appendChild(Y),f.set($,Y)}return Y}function t(J){let $=J,Y=RJ("");$=$.replace(Y,"").trim();let q=$.indexOf("[data-theme=");while(q!==-1){let X=$.indexOf("{",q);if(X===-1)break;let Z=1,G=X+1;while(G<$.length&&Z>0){if($[G]==="{")Z++;else if($[G]==="}")Z--;G++}if(Z===0){let Q=$.substring(0,q).trim(),F=$.substring(G).trim();$=(Q+`
3
+ `+F).trim()}else break;q=$.indexOf("[data-theme=")}return $.trim()}function PJ(J,$="stoop"){if(!J)return;let Y=B($),q=`__all_theme_vars_${Y}`;if((MJ.get(q)??null)===J)return;if(MJ.set(q,J),!R()){EJ(J);return}let Z=VJ(Y),G=Z.textContent||"",Q=G.includes(":root")||G.includes("[data-theme=");if(k(q)||Q){let F=t(G);Z.textContent=J+(F?`
4
4
 
5
- `+G:""),f(q,J)}else F.textContent=J+(Q?`
5
+ `+F:""),C(q,J)}else Z.textContent=J+(G?`
6
6
 
7
- `+Q:""),f(q,J)}function pJ(J,$,Y="stoop"){if(!K())return;let q=B(Y);if(S($))return;let X=EJ(q),F=X.textContent||"";X.textContent=F+(F?`
8
- `:"")+J,f($,J)}function mJ(J,$,Y="stoop"){if(S($))return;let q=B(Y);pJ(J,$,q)}function oJ(J="stoop"){let $=B(J);return k.get($)||null}function lJ(){return new Map(r)}function M(J,$="stoop",Y){let q=Y||J;if(!K()){if(!S(q))f(q,J);MJ(J);return}mJ(J,q,$)}function PJ(J="stoop"){if(K()){let $=B(J),Y=oJ($);if(Y&&Y.parentNode){let q=Y.textContent||"";if(!q&&lJ().size>0)return IJ();return q}}return IJ()}var iJ=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g;function t(J){let $=new Map;function Y(q,X=[]){let F=Object.keys(q);for(let Q of F){let Z=q[Q],G=[...X,Q];if(o(Z))Y(Z,G);else{let D=$.get(Q);if(D)D.push(G);else $.set(Q,[G])}}}Y(J);for(let[,q]of $.entries())if(q.length>1)q.sort((X,F)=>{let Q=X.length-F.length;if(Q!==0)return Q;let Z=X.join("."),G=F.join(".");return Z.localeCompare(G)});return $}function rJ(J,$){let Y=Object.keys(J).filter((X)=>X!=="media"),q=Object.keys($).filter((X)=>X!=="media");if(Y.length!==q.length)return!1;for(let X of Y)if(!(X in $))return!1;return!0}function zJ(J,$){if(J===$)return!0;if(!J||!$)return!1;if(!rJ(J,$))return!1;let Y={...J},q={...$};return delete Y.media,delete q.media,JSON.stringify(Y)===JSON.stringify(q)}function s(J,$,Y){if(Y&&Y in J){let F=J[Y];if(F&&typeof F==="object"&&!Array.isArray(F)&&$ in F)return[Y,$]}let X=t(J).get($);if(!X||X.length===0)return null;return X[0]}function NJ(J,$,Y,q){if(!J.startsWith("$"))return J;let X=J.slice(1);if(X.includes("$")||X.includes("."))return`var(${`--${(X.includes("$")?X.split("$"):X.split(".")).map((W)=>R(W)).join("-")}`})`;if($&&Y){let Z=OJ(Y,q);if(Z){let w=s($,X,Z);if(w)return`var(${`--${w.map((A)=>R(A)).join("-")}`})`}let D=t($).get(X);if(D&&D.length>1){if(!g()){let w=Z?`Property "${Y}" maps to "${Z}" scale, but token not found there. `:`No scale mapping found for property "${Y}". `;console.warn(`[Stoop] Ambiguous token "$${X}" found in multiple categories: ${D.map((H)=>H.join(".")).join(", ")}. ${w}Using "${D[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${D[0].join(".")}" to be explicit.`)}}let W=s($,X);if(W)return`var(${`--${W.map((U)=>R(U)).join("-")}`})`}else if($){let G=t($).get(X);if(G&&G.length>1){if(!g())console.warn(`[Stoop] Ambiguous token "$${X}" found in multiple categories: ${G.map((W)=>W.join(".")).join(", ")}. Using "${G[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${G[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}let D=s($,X);if(D)return`var(${`--${D.map((H)=>R(H)).join("-")}`})`}return`var(${`--${R(X)}`})`}function e(J,$="stoop",Y){let q=Y||":root",X=[];function F(Q,Z=[]){let G=Object.keys(Q).sort();for(let D of G){if(D==="media")continue;let W=Q[D],w=[...Z,D];if(o(W))F(W,w);else{let U=`--${w.map((y)=>R(y)).join("-")}`,A=typeof W==="string"||typeof W==="number"?LJ(W):String(W);X.push(` ${U}: ${A};`)}}}if(F(J),X.length===0)return"";return`${q} {
7
+ `+G:""),C(q,J)}function cJ(J,$,Y="stoop"){if(!R())return;let q=B(Y);if(k($))return;let X=VJ(q),Z=X.textContent||"";X.textContent=Z+(Z?`
8
+ `:"")+J,C($,J)}function oJ(J,$,Y="stoop"){if(k($))return;let q=B(Y);cJ(J,$,q)}function mJ(J="stoop"){let $=B(J);return f.get($)||null}function pJ(){return new Map(a)}function V(J,$="stoop",Y){let q=Y||J;if(!R()){if(!k(q))C(q,J);EJ(J);return}oJ(J,q,$)}function gJ(J="stoop"){if(R()){let $=B(J),Y=mJ($);if(Y&&Y.parentNode){let q=Y.textContent||"";if(!q&&pJ().size>0)return OJ();return q}}return OJ()}var iJ=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g;function JJ(J){let $=new Map;function Y(q,X=[]){let Z=Object.keys(q);for(let G of Z){let Q=q[G],F=[...X,G];if(i(Q))Y(Q,F);else{let D=$.get(G);if(D)D.push(F);else $.set(G,[F])}}}Y(J);for(let[,q]of $.entries())if(q.length>1)q.sort((X,Z)=>{let G=X.length-Z.length;if(G!==0)return G;let Q=X.join("."),F=Z.join(".");return Q.localeCompare(F)});return $}function lJ(J,$){let Y=Object.keys(J).filter((X)=>X!=="media"),q=Object.keys($).filter((X)=>X!=="media");if(Y.length!==q.length)return!1;for(let X of Y)if(!(X in $))return!1;return!0}function jJ(J,$){if(J===$)return!0;if(!J||!$)return!1;if(!lJ(J,$))return!1;let Y={...J},q={...$};return delete Y.media,delete q.media,JSON.stringify(Y)===JSON.stringify(q)}function e(J,$,Y){if(Y&&Y in J){let Z=J[Y];if(Z&&typeof Z==="object"&&!Array.isArray(Z)&&$ in Z)return[Y,$]}let X=JJ(J).get($);if(!X||X.length===0)return null;return X[0]}function zJ(J,$,Y,q){if(!J.startsWith("$"))return J;let X=J.slice(1);if(X.includes("$")||X.includes("."))return`var(${`--${(X.includes("$")?X.split("$"):X.split(".")).map((W)=>M(W)).join("-")}`})`;if($&&Y){let Q=KJ(Y,q);if(Q){let w=e($,X,Q);if(w)return`var(${`--${w.map((I)=>M(I)).join("-")}`})`}let D=JJ($).get(X);if(D&&D.length>1){if(!v()){let w=Q?`Property "${Y}" maps to "${Q}" scale, but token not found there. `:`No scale mapping found for property "${Y}". `;console.warn(`[Stoop] Ambiguous token "$${X}" found in multiple categories: ${D.map((U)=>U.join(".")).join(", ")}. ${w}Using "${D[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${D[0].join(".")}" to be explicit.`)}}let W=e($,X);if(W)return`var(${`--${W.map((H)=>M(H)).join("-")}`})`}else if($){let F=JJ($).get(X);if(F&&F.length>1){if(!v())console.warn(`[Stoop] Ambiguous token "$${X}" found in multiple categories: ${F.map((W)=>W.join(".")).join(", ")}. Using "${F[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${F[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}let D=e($,X);if(D)return`var(${`--${D.map((U)=>M(U)).join("-")}`})`}return`var(${`--${M(X)}`})`}function $J(J,$="stoop",Y){let q=Y||":root",X=[];function Z(G,Q=[]){let F=Object.keys(G).sort();for(let D of F){if(D==="media")continue;let W=G[D],w=[...Q,D];if(i(W))Z(W,w);else{let H=`--${w.map((n)=>M(n)).join("-")}`,I=typeof W==="string"||typeof W==="number"?_J(W):String(W);X.push(` ${H}: ${I};`)}}}if(Z(J),X.length===0)return"";return`${q} {
9
9
  ${X.join(`
10
10
  `)}
11
- }`}function d(J,$="stoop",Y="data-theme"){let q=[];for(let[X,F]of Object.entries(J)){let Q=`[${Y}="${X}"]`,Z=e(F,$,Q);if(Z)q.push(Z)}return q.join(`
11
+ }`}function S(J,$="stoop",Y="data-theme"){let q=[];for(let[X,Z]of Object.entries(J)){let G=`[${Y}="${X}"]`,Q=$J(Z,$,G);if(Q)q.push(Q)}return q.join(`
12
12
 
13
- `)}function E(J,$,Y,q){if(!J||typeof J!=="object")return J;let X={},F=!1,Q=Object.keys(J).sort();for(let Z of Q){let G=J[Z];if(v(G)){let D=E(G,$,Y,void 0);if(X[Z]=D,D!==G)F=!0}else if(typeof G==="string"&&G.includes("$")){F=!0;let D=q||Z;X[Z]=G.replace(iJ,(W)=>{if(W.startsWith("-$")){let w=W.slice(1);return`calc(-1 * ${NJ(w,$,D,Y)})`}return NJ(W,$,D,Y)})}else X[Z]=G}if(!F)return J;return X}function aJ(J,$){if(typeof J==="symbol"&&J===ZJ)return!0;if(p($))return!0;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function sJ(J,$){if(typeof $==="object"&&$!==null&&"__stoopClassName"in $&&typeof $.__stoopClassName==="string")return $.__stoopClassName;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return J.replace("__STOOP_COMPONENT_","");return""}function _(J,$="",Y=0,q){if(!J||typeof J!=="object")return"";if(Y>QJ)return"";let X=[],F=[],Q=Object.keys(J).sort();for(let G of Q){let D=J[G];if(aJ(G,D)){let W=sJ(G,D);if(!W)continue;let w=I(W);if(!w)continue;let H=$?`${$} .${w}`:`.${w}`,U=m(D)?_(D,H,Y+1,q):"";if(U)F.push(U);continue}if(m(D))if(q&&G in q){let W=_J(q[G]);if(W){let w=_(D,$,Y+1,q);if(w)F.push(`${W} { ${w} }`)}}else if(G.startsWith("@")){let W=I(G);if(W){let w=_(D,$,Y+1,q);if(w)F.push(`${W} { ${w} }`)}}else if(G.includes("&")){let W=I(G);if(W){let H=W.split("&").join($),U=_(D,H,Y+1,q);if(U)F.push(U)}}else if(G.startsWith(":")){let W=I(G);if(W){let w=`${$}${W}`,H=_(D,w,Y+1,q);if(H)F.push(H)}}else if(G.includes(" ")||G.includes(">")||G.includes("+")||G.includes("~")){let W=I(G);if(W){let H=/^[\s>+~]/.test(W.trim())?`${$}${W}`:`${$} ${W}`,U=_(D,H,Y+1,q);if(U)F.push(U)}}else{let W=I(G);if(W){let w=$?`${$} ${W}`:W,H=_(D,w,Y+1,q);if(H)F.push(H)}}else if(D!==void 0){let W=C(G);if(W&&(typeof D==="string"||typeof D==="number")){let w=BJ(D);X.push(`${W}: ${w};`)}}}let Z=[];if(X.length>0)Z.push(`${$} { ${X.join(" ")} }`);return Z.push(...F),Z.join("")}function u(J,$,Y="stoop",q,X,F){let Q=B(Y),Z=z(J,X),G=E(Z,$,F),D=_(G,"",0,q),W=b(D),w=Q?`${Q}-${W}`:`css-${W}`,H=`${Q}:${w}`,U=n.get(H);if(U)return M(U,Q,H),w;let A=_(G,`.${w}`,0,q);return n.set(H,A),WJ.set(H,w),M(A,Q,H),w}var jJ=new Map;function gJ(J,$="stoop"){let Y=$||"";jJ.set(Y,J)}function tJ(J="stoop"){let $=J||"";return jJ.get($)||null}function JJ(J,$){let Y={...J},q=Object.keys($);for(let X of q){if(X==="media")continue;let F=$[X],Q=J[X];if(F&&typeof F==="object"&&!Array.isArray(F)&&Q&&typeof Q==="object"&&!Array.isArray(Q))Y[X]={...Q,...F};else if(F!==void 0)Y[X]=F}return Y}function $J(J,$="stoop"){let Y=tJ($);if(!Y)return J;if(zJ(J,Y))return J;return JJ(Y,J)}function vJ(J,$="stoop",Y="data-theme"){if(!K())return;let q={};for(let[F,Q]of Object.entries(J))q[F]=$J(Q,$);let X=d(q,$,Y);VJ(X,$)}function xJ(J){return function $(Y={}){let q=x(Y);return JJ(J,q)}}function bJ(J,$="stoop",Y,q,X){return function F(Q){return u(Q,J,$,Y,q,X)}}function eJ(J,$,Y,q){let X=`@keyframes ${$} {`,F=Object.keys(J).sort((Q,Z)=>{let G=parseFloat(Q.replace("%","")),D=parseFloat(Z.replace("%",""));if(Q==="from")return-1;if(Z==="from")return 1;if(Q==="to")return 1;if(Z==="to")return-1;return G-D});for(let Q of F){if(!AJ(Q))continue;let Z=J[Q];if(!Z||typeof Z!=="object")continue;X+=` ${Q} {`;let G=E(Z,Y,q),D=Object.keys(G).sort();for(let W of D){let w=G[W];if(w!==void 0&&(typeof w==="string"||typeof w==="number")){let H=C(W);if(H){let U=String(w);X+=` ${H}: ${U};`}}}X+=" }"}return X+=" }",X}function TJ(J="stoop",$,Y){let q=B(J),X=new L(FJ);return function F(Q){let Z=T(Q),G=X.get(Z);if(G)return G;let D=Z.slice(0,8),W=q?`${q}-${D}`:`stoop-${D}`,w=eJ(Q,W,$,Y),H=`__keyframes_${W}`;return M(w,q,H),X.set(Z,W),W}}var YJ=new Set;function CJ(J,$="stoop",Y,q,X){return function F(Q){let Z=T(Q);if(YJ.has(Z))return()=>{};YJ.add(Z);let G=B($),D=z(Q,q),W=E(D,J,X),w=_(W,"",0,Y);return M(w,G,`__global_${Z}`),()=>{YJ.delete(Z)}}}function kJ(J){let{globalCss:$,media:Y,prefix:q="stoop",theme:X,themeMap:F,utils:Q}=J,Z=B(q),G=x(X),D=G.media||Y,W={...N,...F};gJ(G,Z);let w=bJ(G,Z,D,Q,W),H=xJ(G),U=CJ(G,Z,D,Q,W),A=TJ(Z,G,W),y=Object.freeze({...G});function fJ(h){for(let O of h)try{u(O,G,Z,D,Q,W)}catch{}}function SJ(h){if(!J.themes||Object.keys(J.themes).length===0)return;vJ(J.themes,Z)}function dJ(h){let O="";if(J.themes&&Object.keys(J.themes).length>0){let V={};for(let[yJ,hJ]of Object.entries(J.themes))V[yJ]=$J(hJ,Z);let XJ=d(V,Z,"data-theme");if(XJ)O+=XJ+`
14
- `}else{let V=e(G,Z);if(V)O+=V+`
15
- `}let uJ=PJ(),qJ=a(uJ).trim();if(qJ)O+=(O?`
16
- `:"")+qJ;return O}return{config:{...J,prefix:Z},createTheme:H,css:w,getCssText:dJ,globalCss:U,globalCssConfig:$,keyframes:A,media:D,mergedThemeMap:W,preloadTheme:SJ,sanitizedPrefix:Z,theme:y,utils:Q,validatedTheme:G,warmCache:fJ}}function Y1(J){let $=kJ(J);return{config:{...$.config,prefix:$.sanitizedPrefix},createTheme:$.createTheme,css:$.css,getCssText:$.getCssText,globalCss:$.globalCss,keyframes:$.keyframes,preloadTheme:$.preloadTheme,theme:$.theme,warmCache:$.warmCache}}export{Y1 as createStoop};
13
+ `)}function P(J,$,Y,q){if(!J||typeof J!=="object")return J;let X={},Z=!1,G=Object.keys(J).sort();for(let Q of G){let F=J[Q];if(N(F)){let D=P(F,$,Y,void 0);if(X[Q]=D,D!==F)Z=!0}else if(typeof F==="string"&&F.includes("$")){Z=!0;let D=q||Q;X[Q]=F.replace(iJ,(W)=>{if(W.startsWith("-$")){let w=W.slice(1);return`calc(-1 * ${zJ(w,$,D,Y)})`}return zJ(W,$,D,Y)})}else X[Q]=F}if(!Z)return J;return X}var _=new L(E);function rJ(J){return J.replace(/([A-Z])/g,"-$1").toLowerCase()}function sJ(J){if(J===J.toUpperCase()&&J.length>1)return J.charAt(0)+J.slice(1).toLowerCase();return J}function d(J){if(!J)return"";return J.charAt(0).toLowerCase()+J.slice(1).replace(/([A-Z])/g,"-$1").toLowerCase()}function u(J){if(!J||typeof J!=="string")return"";let $=_.get(J);if($!==void 0)return $;if(/^-[a-z]+-/.test(J))return _.set(J,J),J;let Y=sJ(J);if(/^[Mm]oz/i.test(Y)){if(Y.length===3||Y.toLowerCase()==="moz")return _.set(J,"-moz"),"-moz";let G=Y.match(/^[Mm]oz(.+)$/i);if(G&&G[1]){let[,Q]=G,F=d(Q);if(F){let D=`-moz-${F}`;return _.set(J,D),D}}}if(/^[Ww]ebkit/i.test(Y)){if(Y.length===6||Y.toLowerCase()==="webkit")return _.set(J,"-webkit"),"-webkit";let G=Y.match(/^[Ww]ebkit(.+)$/i);if(G&&G[1]){let[,Q]=G,F=d(Q);if(F){let D=`-webkit-${F}`;return _.set(J,D),D}}}if(/^[Mm]s/i.test(Y)){if(Y.length===2||Y.toLowerCase()==="ms")return _.set(J,"-ms"),"-ms";let G=Y.match(/^[Mm]s(.+)$/i);if(G&&G[1]){let[,Q]=G,F=d(Q);if(F){let D=`-ms-${F}`;return _.set(J,D),D}}}if(/^O/i.test(Y)){if(Y.length===1||Y.toLowerCase()==="o")return _.set(J,"-o"),"-o";if(/^O[A-Z]/.test(Y)){let G=Y.substring(1),Q=d(G);if(Q){let F=`-o-${Q}`;return _.set(J,F),F}}}let Z=rJ(Y).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return _.set(J,Z),Z}function aJ(J,$){if(typeof J==="symbol"&&J===DJ)return!0;if(m($))return!0;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function tJ(J,$){if(typeof $==="object"&&$!==null&&"__stoopClassName"in $&&typeof $.__stoopClassName==="string")return $.__stoopClassName;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return J.replace("__STOOP_COMPONENT_","");return""}function A(J,$="",Y=0,q){if(!J||typeof J!=="object")return"";if(Y>ZJ)return"";let X=[],Z=[],G=Object.keys(J).sort();for(let F of G){let D=J[F];if(aJ(F,D)){let W=tJ(F,D);if(!W)continue;let w=O(W);if(!w)continue;let U=$?`${$} .${w}`:`.${w}`,H=p(D)?A(D,U,Y+1,q):"";if(H)Z.push(H);continue}if(p(D))if(q&&F in q){let W=AJ(q[F]);if(W){let w=A(D,$,Y+1,q);if(w)Z.push(`${W} { ${w} }`)}}else if(F.startsWith("@")){let W=O(F);if(W){let w=A(D,$,Y+1,q);if(w)Z.push(`${W} { ${w} }`)}}else if(F.includes("&")){let W=O(F);if(W){let U=W.split("&").join($),H=A(D,U,Y+1,q);if(H)Z.push(H)}}else if(F.startsWith(":")){let W=O(F);if(W){let w=`${$}${W}`,U=A(D,w,Y+1,q);if(U)Z.push(U)}}else if(F.includes(" ")||F.includes(">")||F.includes("+")||F.includes("~")){let W=O(F);if(W){let U=/^[\s>+~]/.test(W.trim())?`${$}${W}`:`${$} ${W}`,H=A(D,U,Y+1,q);if(H)Z.push(H)}}else{let W=O(F);if(W){let w=$?`${$} ${W}`:W,U=A(D,w,Y+1,q);if(U)Z.push(U)}}else if(D!==void 0){let W=u(F);if(W&&(typeof D==="string"||typeof D==="number")){let w=LJ(D);X.push(`${W}: ${w};`)}}}let Q=[];if(X.length>0)Q.push(`${$} { ${X.join(" ")} }`);return Q.push(...Z),Q.join("")}function y(J,$,Y="stoop",q,X,Z){let G=B(Y),Q=j(J,X),F=P(Q,$,Z),D=A(F,"",0,q),W=b(D),w=G?`${G}-${W}`:`css-${W}`,U=`${G}:${w}`,H=o.get(U);if(H)return V(H,G,U),w;let I=A(F,`.${w}`,0,q);return o.set(U,I),wJ.set(U,w),V(I,G,U),w}var xJ=new Map;function vJ(J,$="stoop"){let Y=$||"";xJ.set(Y,J)}function eJ(J="stoop"){let $=J||"";return xJ.get($)||null}function YJ(J,$){let Y={...J},q=Object.keys($);for(let X of q){if(X==="media")continue;let Z=$[X],G=J[X];if(Z&&typeof Z==="object"&&!Array.isArray(Z)&&G&&typeof G==="object"&&!Array.isArray(G))Y[X]={...G,...Z};else if(Z!==void 0)Y[X]=Z}return Y}function qJ(J,$="stoop"){let Y=eJ($);if(!Y)return J;if(jJ(J,Y))return J;return YJ(Y,J)}function NJ(J,$="stoop",Y="data-theme"){if(!R())return;let q={};for(let[Z,G]of Object.entries(J))q[Z]=qJ(G,$);let X=S(q,$,Y);PJ(X,$)}function TJ(J){return function $(Y={}){let q=T(Y);return YJ(J,q)}}function bJ(J,$="stoop",Y,q,X){return function Z(G){return y(G,J,$,Y,q,X)}}function J0(J,$,Y,q){let X=`@keyframes ${$} {`,Z=Object.keys(J).sort((G,Q)=>{let F=parseFloat(G.replace("%","")),D=parseFloat(Q.replace("%",""));if(G==="from")return-1;if(Q==="from")return 1;if(G==="to")return 1;if(Q==="to")return-1;return F-D});for(let G of Z){if(!IJ(G))continue;let Q=J[G];if(!Q||typeof Q!=="object")continue;X+=` ${G} {`;let F=P(Q,Y,q),D=Object.keys(F).sort();for(let W of D){let w=F[W];if(w!==void 0&&(typeof w==="string"||typeof w==="number")){let U=u(W);if(U){let H=String(w);X+=` ${U}: ${H};`}}}X+=" }"}return X+=" }",X}function fJ(J="stoop",$,Y){let q=B(J),X=new L(WJ);return function Z(G){let Q=r(G),F=X.get(Q);if(F)return F;let D=Q.slice(0,8),W=q?`${q}-${D}`:`stoop-${D}`,w=J0(G,W,$,Y),U=`__keyframes_${W}`;return V(w,q,U),X.set(Q,W),W}}var XJ=new Set;function CJ(J,$="stoop",Y,q,X){return function Z(G){let Q=r(G);if(XJ.has(Q))return()=>{};XJ.add(Q);let F=B($),D=j(G,q),W=P(D,J,X),w=A(W,"",0,Y);return V(w,F,`__global_${Q}`),()=>{XJ.delete(Q)}}}function kJ(J){let{globalCss:$,media:Y,prefix:q="stoop",theme:X,themeMap:Z,utils:G}=J,Q=B(q),F=T(X),D=F.media||Y,W={...z,...Z};vJ(F,Q);let w=bJ(F,Q,D,G,W),U=TJ(F),H=CJ(F,Q,D,G,W),I=fJ(Q,F,W),n=Object.freeze({...F});function SJ(K){for(let h of K)try{y(h,F,Q,D,G,W)}catch{}}function dJ(){if(!J.themes||Object.keys(J.themes).length===0)return;NJ(J.themes,Q)}function uJ(){let K="";if(J.themes&&Object.keys(J.themes).length>0){let g={};for(let[yJ,nJ]of Object.entries(J.themes))g[yJ]=qJ(nJ,Q);let FJ=S(g,Q,"data-theme");if(FJ)K+=FJ+`
14
+ `}else{let g=$J(F,Q);if(g)K+=g+`
15
+ `}let h=gJ(),GJ=t(h).trim();if(GJ)K+=(K?`
16
+ `:"")+GJ;return K}return{config:{...J,prefix:Q},createTheme:U,css:w,getCssText:uJ,globalCss:H,globalCssConfig:$,keyframes:I,media:D,mergedThemeMap:W,preloadTheme:dJ,sanitizedPrefix:Q,theme:n,utils:G,validatedTheme:F,warmCache:SJ}}function $1(J){let $=kJ(J);return{config:{...$.config,prefix:$.sanitizedPrefix},createTheme:$.createTheme,css:$.css,getCssText:$.getCssText,globalCss:$.globalCss,keyframes:$.keyframes,preloadTheme:$.preloadTheme,theme:$.theme,warmCache:$.warmCache}}export{$1 as createStoop};
@@ -1,27 +1,24 @@
1
1
  /**
2
2
  * Factory function that creates a Stoop instance.
3
3
  * Supports both client-side (with React APIs) and server-side (without React) usage.
4
- * Automatically detects environment and includes appropriate APIs.
5
4
  */
6
5
  import type { CSS, StoopConfig, StoopInstance, Theme, ThemeScale } from "./types";
7
- import { createCSSFunction, createKeyframesFunction } from "./api/core-api";
8
- import { createGlobalCSSFunction } from "./api/global-css";
6
+ import { createCSSFunction, createKeyframesFunction, createGlobalCSSFunction } from "./api/core-api";
9
7
  /**
10
8
  * Shared implementation for creating Stoop instances.
11
9
  * Handles common setup logic for both client and server instances.
12
- * Exported for use in SSR entry point.
13
10
  */
14
11
  export declare function createStoopBase(config: StoopConfig): {
15
12
  config: StoopConfig;
16
13
  createTheme: (overrides?: Partial<Theme>) => Theme;
17
14
  css: ReturnType<typeof createCSSFunction>;
18
- getCssText: (theme?: string | Theme) => string;
15
+ getCssText: () => string;
19
16
  globalCss: ReturnType<typeof createGlobalCSSFunction>;
20
17
  globalCssConfig: StoopConfig["globalCss"];
21
18
  keyframes: ReturnType<typeof createKeyframesFunction>;
22
19
  media: StoopConfig["media"];
23
20
  mergedThemeMap: Record<string, ThemeScale>;
24
- preloadTheme: (theme: string | Theme) => void;
21
+ preloadTheme: () => void;
25
22
  sanitizedPrefix: string;
26
23
  theme: Theme;
27
24
  utils: StoopConfig["utils"];
@@ -31,7 +28,6 @@ export declare function createStoopBase(config: StoopConfig): {
31
28
  /**
32
29
  * Creates a Stoop instance with the provided configuration.
33
30
  * Includes all APIs: styled, Provider, useTheme, etc.
34
- * In server contexts without React, React APIs will be undefined.
35
31
  *
36
32
  * @param config - Configuration object containing theme, media queries, utilities, and optional prefix/themeMap
37
33
  * @returns StoopInstance with all API functions
@@ -1,16 +1,16 @@
1
- var r=Object.freeze({}),s=1e4,T0=5000,C0=10,f0=500,c=1000,k0=31536000,S0="/",W0=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],n={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},a=Symbol.for("stoop.component");class E extends Map{maxSize;constructor($){super();this.maxSize=$}get($){let J=super.get($);if(J!==void 0)super.delete($),super.set($,J);return J}set($,J){if(super.has($))super.delete($);else if(this.size>=this.maxSize){let q=this.keys().next().value;if(q!==void 0)super.delete(q)}return super.set($,J),this}}var d0=new E(T0),D0=new E(s);function w(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function u(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function t($){return typeof $==="object"&&$!==null}function m($){return typeof $==="object"&&$!==null&&"__isStoopStyled"in $&&"__stoopClassName"in $&&$.__isStoopStyled===!0}function U0($){return t($)&&!m($)}function H0($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function e($){if(!$||typeof $!=="object"||Array.isArray($))throw new Error("[Stoop] Theme must be a non-null object");if(u())return $;let J=$,q=[];for(let X in J){if(X==="media")continue;if(!W0.includes(X))q.push(X)}if(q.length>0){let X=`[Stoop] Theme contains invalid scales: ${q.join(", ")}. Only these scales are allowed: ${W0.join(", ")}`;throw new Error(X)}return $}function i($,J){if(!J||!$||typeof $!=="object")return $;let q={},X=Object.keys(J);for(let Y in $){let Q=$[Y];if(X.includes(Y)&&J[Y])try{let G=J[Y](Q);if(G&&typeof G==="object")for(let Z in G)q[Z]=G[Z]}catch{q[Y]=Q}else if(t(Q))q[Y]=i(Q,J);else q[Y]=Q}return q}var F0=null,u0=new E(c),y0=new E(c),p0=new E(c),h0=new E(c);function y($){let X=2166136261;for(let Y=0;Y<$.length;Y++)X^=$.charCodeAt(Y),X=Math.imul(X,16777619);return X^=$.length,(X>>>0).toString(36)}function $0($){try{return y(JSON.stringify($))}catch{return y(String($))}}function O1($){return $.replace(/([A-Z])/g,"-$1").toLowerCase()}function c0($,J=!1){let X=String($).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if(J)X=X.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return X}function n0($){return c0($,!1)}function T($){let J=u0.get($);if(J!==void 0)return J;let q=$.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),X=!q.trim()||/^[>+~:.#[\]&@()\s]+$/.test(q)?"":q;return u0.set($,X),X}function C($){let J=h0.get($);if(J!==void 0)return J;let Y=$.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return h0.set($,Y),Y}function m0($){return c0($,!0)}function R($){if(!$)return"stoop";return $.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function i0($){if(!$||typeof $!=="string")return"";let J=$.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!J.trim()||!/[a-zA-Z]/.test(J))return"";return J}function o0($){if(!$||typeof $!=="string")return"";let J=p0.get($);if(J!==void 0)return J;let q=$.trim().split(/\s+/),X=[];for(let Q of q){if(!Q)continue;let Z=Q.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^\d+/,"");if(Z&&/^[a-zA-Z-_]/.test(Z))X.push(Z)}let Y=X.join(" ");return p0.set($,Y),Y}function J0($){if(!$||typeof $!=="string")return"";let J=y0.get($);if(J!==void 0)return J;let Y=O1($).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return y0.set($,Y),Y}function l0($){if(!$||typeof $!=="string")return!1;if($==="from"||$==="to")return!0;if(/^\d+(\.\d+)?%$/.test($)){let q=parseFloat($);return q>=0&&q<=100}return!1}function r0($=""){if(!F0){let q=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");F0=new RegExp(`${q}\\s*\\{[\\s\\S]*\\}`)}return F0}function M1($){if($.includes("Color")||$==="fill"||$==="stroke"||$==="accentColor"||$==="caretColor"||$==="border"||$==="outline"||$.includes("background")&&!$.includes("Size")&&!$.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test($)||$.includes("Block")||$.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test($)||$.includes("BlockSize")||$.includes("InlineSize"))return"sizes";if($==="fontSize"||$==="font"&&!$.includes("Family"))return"fontSizes";if($==="fontFamily"||$.includes("FontFamily"))return"fonts";if($==="fontWeight"||$.includes("FontWeight"))return"fontWeights";if($==="letterSpacing"||$.includes("LetterSpacing"))return"letterSpacings";if($.includes("Radius")||$.includes("radius"))return"radii";if($.includes("Shadow")||$.includes("shadow")||$==="filter"||$==="backdropFilter")return"shadows";if($==="zIndex"||$.includes("ZIndex")||$.includes("z-index"))return"zIndices";if($==="opacity"||$.includes("Opacity"))return"opacities";if($.startsWith("transition")||$.startsWith("animation")||$.includes("Transition")||$.includes("Animation"))return"transitions";return}function s0($,J){if(J&&$ in J)return J[$];if($ in n)return n[$];return M1($)}var w0=new Map;function Y0($){return w0.has($)}function X0($,J){w0.set($,J)}var L0=new E(s);function e0($){if(!L0.has($))L0.set($,!0)}function a0(){return Array.from(L0.keys()).join(`
2
- `)}var q0=new Map;var t0=new Map;function $1($="stoop"){if(!w())throw new Error("Cannot access document in SSR context");let J=R($),q=q0.get(J);if(!q||!q.parentNode){let X=document.getElementById("stoop-ssr");if(X){let Y=X.getAttribute("data-stoop");if(!Y||Y===J)return q=X,q.setAttribute("data-stoop",J),q0.set(J,q),q}q=document.createElement("style"),q.setAttribute("data-stoop",J),q.setAttribute("id",`stoop-${J}`),document.head.appendChild(q),q0.set(J,q)}return q}function B0($){let J=$,q=r0("");J=J.replace(q,"").trim();let X=J.indexOf("[data-theme=");while(X!==-1){let Y=J.indexOf("{",X);if(Y===-1)break;let Q=1,G=Y+1;while(G<J.length&&Q>0){if(J[G]==="{")Q++;else if(J[G]==="}")Q--;G++}if(Q===0){let Z=J.substring(0,X).trim(),W=J.substring(G).trim();J=(Z+`
3
- `+W).trim()}else break;X=J.indexOf("[data-theme=")}return J.trim()}function J1($,J="stoop"){if(!$)return;let q=R(J),X=`__all_theme_vars_${q}`;if((t0.get(X)??null)===$)return;if(t0.set(X,$),!w()){e0($);return}let Q=$1(q),G=Q.textContent||"",Z=G.includes(":root")||G.includes("[data-theme=");if(Y0(X)||Z){let W=B0(G);Q.textContent=$+(W?`
1
+ var r=Object.freeze({}),s=1e4,CJ=5000,fJ=10,SJ=500,S=1000,dJ=31536000,uJ="/",WJ=["colors","opacities","space","radii","sizes","fonts","fontWeights","fontSizes","lineHeights","letterSpacings","shadows","zIndices","transitions"],n={accentColor:"colors",animation:"transitions",animationDelay:"transitions",animationDuration:"transitions",animationTimingFunction:"transitions",backdropFilter:"shadows",background:"colors",backgroundColor:"colors",blockSize:"sizes",border:"colors",borderBlockColor:"colors",borderBlockEndColor:"colors",borderBlockStartColor:"colors",borderBottomColor:"colors",borderBottomLeftRadius:"radii",borderBottomRightRadius:"radii",borderColor:"colors",borderEndEndRadius:"radii",borderEndStartRadius:"radii",borderInlineColor:"colors",borderInlineEndColor:"colors",borderInlineStartColor:"colors",borderLeftColor:"colors",borderRadius:"radii",borderRightColor:"colors",borderStartEndRadius:"radii",borderStartStartRadius:"radii",borderTopColor:"colors",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",bottom:"space",boxShadow:"shadows",caretColor:"colors",color:"colors",columnGap:"space",columnRuleColor:"colors",fill:"colors",filter:"shadows",flexBasis:"sizes",floodColor:"colors",font:"fontSizes",fontFamily:"fonts",fontSize:"fontSizes",fontWeight:"fontWeights",gap:"space",gridColumnGap:"space",gridGap:"space",gridRowGap:"space",height:"sizes",inlineSize:"sizes",inset:"space",insetBlock:"space",insetBlockEnd:"space",insetBlockStart:"space",insetInline:"space",insetInlineEnd:"space",insetInlineStart:"space",left:"space",letterSpacing:"letterSpacings",lightingColor:"colors",lineHeight:"lineHeights",margin:"space",marginBlock:"space",marginBlockEnd:"space",marginBlockStart:"space",marginBottom:"space",marginInline:"space",marginInlineEnd:"space",marginInlineStart:"space",marginLeft:"space",marginRight:"space",marginTop:"space",maxBlockSize:"sizes",maxHeight:"sizes",maxInlineSize:"sizes",maxWidth:"sizes",minBlockSize:"sizes",minHeight:"sizes",minInlineSize:"sizes",minWidth:"sizes",opacity:"opacities",outline:"colors",outlineColor:"colors",padding:"space",paddingBlock:"space",paddingBlockEnd:"space",paddingBlockStart:"space",paddingBottom:"space",paddingInline:"space",paddingInlineEnd:"space",paddingInlineStart:"space",paddingLeft:"space",paddingRight:"space",paddingTop:"space",right:"space",rowGap:"space",size:"sizes",stopColor:"colors",stroke:"colors",textDecorationColor:"colors",textEmphasisColor:"colors",textShadow:"shadows",top:"space",transition:"transitions",transitionDelay:"transitions",transitionDuration:"transitions",transitionProperty:"transitions",transitionTimingFunction:"transitions",width:"sizes",zIndex:"zIndices"},a=Symbol.for("stoop.component");class V extends Map{maxSize;constructor(J){super();this.maxSize=J}get(J){let $=super.get(J);if($!==void 0)super.delete(J),super.set(J,$);return $}set(J,$){if(super.has(J))super.delete(J);else if(this.size>=this.maxSize){let q=this.keys().next().value;if(q!==void 0)super.delete(q)}return super.set(J,$),this}}var yJ=new V(CJ),DJ=new V(s);function w(){return typeof window!=="undefined"&&typeof document!=="undefined"&&typeof window.document==="object"&&typeof document.createElement==="function"}function d(){return typeof process!=="undefined"&&process.env?.NODE_ENV==="production"}function t(J){return typeof J==="object"&&J!==null}function m(J){return typeof J==="object"&&J!==null&&"__isStoopStyled"in J&&"__stoopClassName"in J&&J.__isStoopStyled===!0}function UJ(J){return t(J)&&!m(J)}function FJ(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function e(J){if(!J||typeof J!=="object"||Array.isArray(J))throw new Error("[Stoop] Theme must be a non-null object");if(d())return J;let $=J,q=[];for(let X in $){if(X==="media")continue;if(!WJ.includes(X))q.push(X)}if(q.length>0){let X=`[Stoop] Theme contains invalid scales: ${q.join(", ")}. Only these scales are allowed: ${WJ.join(", ")}`;throw new Error(X)}return J}function i(J,$){if(!$||!J||typeof J!=="object")return J;let q={},X=Object.keys($);for(let Y in J){let W=J[Y];if(X.includes(Y)&&$[Y])try{let G=$[Y](W);if(G&&typeof G==="object")for(let Z in G)q[Z]=G[Z]}catch{q[Y]=W}else if(t(W))q[Y]=i(W,$);else q[Y]=W}return q}var HJ=null,hJ=new V(S),cJ=new V(S),pJ=new V(S);function u(J){let X=2166136261;for(let Y=0;Y<J.length;Y++)X^=J.charCodeAt(Y),X=Math.imul(X,16777619);return X^=J.length,(X>>>0).toString(36)}function LJ(J){try{return u(JSON.stringify(J))}catch{return u(String(J))}}function nJ(J,$=!1){let X=String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/'/g,"\\'").replace(/;/g,"\\;").replace(/\n/g,"\\A ").replace(/\r/g,"").replace(/\f/g,"\\C ");if($)X=X.replace(/\{/g,"\\7B ").replace(/\}/g,"\\7D ");return X}function mJ(J){return nJ(J,!1)}function k(J){let $=hJ.get(J);if($!==void 0)return $;let q=J.replace(/[^a-zA-Z0-9\s\-_>+~:.#[\]&@()]/g,""),X=!q.trim()||/^[>+~:.#[\]&@()\s]+$/.test(q)?"":q;return hJ.set(J,X),X}function b(J){let $=pJ.get(J);if($!==void 0)return $;let Y=J.replace(/[^a-zA-Z0-9-_]/g,"-").replace(/^[\d-]+/,"").replace(/^-+/,"")||"invalid";return pJ.set(J,Y),Y}function iJ(J){return nJ(J,!0)}function M(J){if(!J)return"stoop";return J.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^[\d-]+/,"").replace(/^-+/,"")||"stoop"}function oJ(J){if(!J||typeof J!=="string")return"";let $=J.replace(/[^a-zA-Z0-9\s():,<>=\-@]/g,"");if(!$.trim()||!/[a-zA-Z]/.test($))return"";return $}function lJ(J){if(!J||typeof J!=="string")return"";let $=cJ.get(J);if($!==void 0)return $;let q=J.trim().split(/\s+/),X=[];for(let W of q){if(!W)continue;let Z=W.replace(/[^a-zA-Z0-9-_]/g,"").replace(/^\d+/,"");if(Z&&/^[a-zA-Z-_]/.test(Z))X.push(Z)}let Y=X.join(" ");return cJ.set(J,Y),Y}function rJ(J){if(!J||typeof J!=="string")return!1;if(J==="from"||J==="to")return!0;if(/^\d+(\.\d+)?%$/.test(J)){let q=parseFloat(J);return q>=0&&q<=100}return!1}function sJ(J=""){if(!HJ){let q=":root".replace(/[.*+?^${}()|[\]\\]/g,"\\$&");HJ=new RegExp(`${q}\\s*\\{[\\s\\S]*\\}`)}return HJ}function O0(J){if(J.includes("Color")||J==="fill"||J==="stroke"||J==="accentColor"||J==="caretColor"||J==="border"||J==="outline"||J.includes("background")&&!J.includes("Size")&&!J.includes("Image"))return"colors";if(/^(margin|padding|gap|inset|top|right|bottom|left|rowGap|columnGap|gridGap|gridRowGap|gridColumnGap)/.test(J)||J.includes("Block")||J.includes("Inline"))return"space";if(/(width|height|size|basis)$/i.test(J)||J.includes("BlockSize")||J.includes("InlineSize"))return"sizes";if(J==="fontSize"||J==="font"&&!J.includes("Family"))return"fontSizes";if(J==="fontFamily"||J.includes("FontFamily"))return"fonts";if(J==="fontWeight"||J.includes("FontWeight"))return"fontWeights";if(J==="letterSpacing"||J.includes("LetterSpacing"))return"letterSpacings";if(J.includes("Radius")||J.includes("radius"))return"radii";if(J.includes("Shadow")||J.includes("shadow")||J==="filter"||J==="backdropFilter")return"shadows";if(J==="zIndex"||J.includes("ZIndex")||J.includes("z-index"))return"zIndices";if(J==="opacity"||J.includes("Opacity"))return"opacities";if(J.startsWith("transition")||J.startsWith("animation")||J.includes("Transition")||J.includes("Animation"))return"transitions";return}function aJ(J,$){if($&&J in $)return $[J];if(J in n)return n[J];return O0(J)}var BJ=new Map;function qJ(J){return BJ.has(J)}function $J(J,$){BJ.set(J,$)}var wJ=new V(s);function J0(J){if(!wJ.has(J))wJ.set(J,!0)}function tJ(){return Array.from(wJ.keys()).join(`
2
+ `)}var JJ=new Map;var eJ=new Map;function $0(J="stoop"){if(!w())throw new Error("Cannot access document in SSR context");let $=M(J),q=JJ.get($);if(!q||!q.parentNode){let X=document.getElementById("stoop-ssr");if(X){let Y=X.getAttribute("data-stoop");if(!Y||Y===$)return q=X,q.setAttribute("data-stoop",$),JJ.set($,q),q}q=document.createElement("style"),q.setAttribute("data-stoop",$),q.setAttribute("id",`stoop-${$}`),document.head.appendChild(q),JJ.set($,q)}return q}function _J(J){let $=J,q=sJ("");$=$.replace(q,"").trim();let X=$.indexOf("[data-theme=");while(X!==-1){let Y=$.indexOf("{",X);if(Y===-1)break;let W=1,G=Y+1;while(G<$.length&&W>0){if($[G]==="{")W++;else if($[G]==="}")W--;G++}if(W===0){let Z=$.substring(0,X).trim(),Q=$.substring(G).trim();$=(Z+`
3
+ `+Q).trim()}else break;X=$.indexOf("[data-theme=")}return $.trim()}function q0(J,$="stoop"){if(!J)return;let q=M($),X=`__all_theme_vars_${q}`;if((eJ.get(X)??null)===J)return;if(eJ.set(X,J),!w()){J0(J);return}let W=$0(q),G=W.textContent||"",Z=G.includes(":root")||G.includes("[data-theme=");if(qJ(X)||Z){let Q=_J(G);W.textContent=J+(Q?`
4
4
 
5
- `+W:""),X0(X,$)}else Q.textContent=$+(G?`
5
+ `+Q:""),$J(X,J)}else W.textContent=J+(G?`
6
6
 
7
- `+G:""),X0(X,$)}function z1($,J,q="stoop"){if(!w())return;let X=R(q);if(Y0(J))return;let Y=$1(X),Q=Y.textContent||"";Y.textContent=Q+(Q?`
8
- `:"")+$,X0(J,$)}function E1($,J,q="stoop"){if(Y0(J))return;let X=R(q);z1($,J,X)}function K1($="stoop"){let J=R($);return q0.get(J)||null}function j1(){return new Map(w0)}function f($,J="stoop",q){let X=q||$;if(!w()){if(!Y0(X))X0(X,$);e0($);return}E1($,X,J)}function q1($="stoop"){if(w()){let J=R($),q=K1(J);if(q&&q.parentNode){let X=q.textContent||"";if(!X&&j1().size>0)return a0();return X}}return a0()}var P1=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g;function _0($){let J=new Map;function q(X,Y=[]){let Q=Object.keys(X);for(let G of Q){let Z=X[G],W=[...Y,G];if(H0(Z))q(Z,W);else{let U=J.get(G);if(U)U.push(W);else J.set(G,[W])}}}q($);for(let[,X]of J.entries())if(X.length>1)X.sort((Y,Q)=>{let G=Y.length-Q.length;if(G!==0)return G;let Z=Y.join("."),W=Q.join(".");return Z.localeCompare(W)});return J}function V1($,J){let q=Object.keys($).filter((Y)=>Y!=="media"),X=Object.keys(J).filter((Y)=>Y!=="media");if(q.length!==X.length)return!1;for(let Y of q)if(!(Y in J))return!1;return!0}function Y1($,J){if($===J)return!0;if(!$||!J)return!1;if(!V1($,J))return!1;let q={...$},X={...J};return delete q.media,delete X.media,JSON.stringify(q)===JSON.stringify(X)}function A0($,J,q){if(q&&q in $){let Q=$[q];if(Q&&typeof Q==="object"&&!Array.isArray(Q)&&J in Q)return[q,J]}let Y=_0($).get(J);if(!Y||Y.length===0)return null;return Y[0]}function X1($,J,q,X){if(!$.startsWith("$"))return $;let Y=$.slice(1);if(Y.includes("$")||Y.includes("."))return`var(${`--${(Y.includes("$")?Y.split("$"):Y.split(".")).map((D)=>C(D)).join("-")}`})`;if(J&&q){let Z=s0(q,X);if(Z){let H=A0(J,Y,Z);if(H)return`var(${`--${H.map((O)=>C(O)).join("-")}`})`}let U=_0(J).get(Y);if(U&&U.length>1){if(!u()){let H=Z?`Property "${q}" maps to "${Z}" scale, but token not found there. `:`No scale mapping found for property "${q}". `;console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${U.map((F)=>F.join(".")).join(", ")}. ${H}Using "${U[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${U[0].join(".")}" to be explicit.`)}}let D=A0(J,Y);if(D)return`var(${`--${D.map((L)=>C(L)).join("-")}`})`}else if(J){let W=_0(J).get(Y);if(W&&W.length>1){if(!u())console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${W.map((D)=>D.join(".")).join(", ")}. Using "${W[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${W[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}let U=A0(J,Y);if(U)return`var(${`--${U.map((F)=>C(F)).join("-")}`})`}return`var(${`--${C(Y)}`})`}function I0($,J="stoop",q){let X=q||":root",Y=[];function Q(G,Z=[]){let W=Object.keys(G).sort();for(let U of W){if(U==="media")continue;let D=G[U],H=[...Z,U];if(H0(D))Q(D,H);else{let L=`--${H.map((_)=>C(_)).join("-")}`,O=typeof D==="string"||typeof D==="number"?m0(D):String(D);Y.push(` ${L}: ${O};`)}}}if(Q($),Y.length===0)return"";return`${X} {
7
+ `+G:""),$J(X,J)}function M0(J,$,q="stoop"){if(!w())return;let X=M(q);if(qJ($))return;let Y=$0(X),W=Y.textContent||"";Y.textContent=W+(W?`
8
+ `:"")+J,$J($,J)}function E0(J,$,q="stoop"){if(qJ($))return;let X=M(q);M0(J,$,X)}function V0(J="stoop"){let $=M(J);return JJ.get($)||null}function K0(){return new Map(BJ)}function y(J,$="stoop",q){let X=q||J;if(!w()){if(!qJ(X))$J(X,J);J0(J);return}E0(J,X,$)}function X0(J="stoop"){if(w()){let $=M(J),q=V0($);if(q&&q.parentNode){let X=q.textContent||"";if(!X&&K0().size>0)return tJ();return X}}return tJ()}var z0=/(-?\$[a-zA-Z][a-zA-Z0-9]*(?:\$[a-zA-Z][a-zA-Z0-9]*)?(?:\.[a-zA-Z][a-zA-Z0-9]*)?)/g;function IJ(J){let $=new Map;function q(X,Y=[]){let W=Object.keys(X);for(let G of W){let Z=X[G],Q=[...Y,G];if(FJ(Z))q(Z,Q);else{let D=$.get(G);if(D)D.push(Q);else $.set(G,[Q])}}}q(J);for(let[,X]of $.entries())if(X.length>1)X.sort((Y,W)=>{let G=Y.length-W.length;if(G!==0)return G;let Z=Y.join("."),Q=W.join(".");return Z.localeCompare(Q)});return $}function P0(J,$){let q=Object.keys(J).filter((Y)=>Y!=="media"),X=Object.keys($).filter((Y)=>Y!=="media");if(q.length!==X.length)return!1;for(let Y of q)if(!(Y in $))return!1;return!0}function G0(J,$){if(J===$)return!0;if(!J||!$)return!1;if(!P0(J,$))return!1;let q={...J},X={...$};return delete q.media,delete X.media,JSON.stringify(q)===JSON.stringify(X)}function AJ(J,$,q){if(q&&q in J){let W=J[q];if(W&&typeof W==="object"&&!Array.isArray(W)&&$ in W)return[q,$]}let Y=IJ(J).get($);if(!Y||Y.length===0)return null;return Y[0]}function Y0(J,$,q,X){if(!J.startsWith("$"))return J;let Y=J.slice(1);if(Y.includes("$")||Y.includes("."))return`var(${`--${(Y.includes("$")?Y.split("$"):Y.split(".")).map((U)=>b(U)).join("-")}`})`;if($&&q){let Z=aJ(q,X);if(Z){let F=AJ($,Y,Z);if(F)return`var(${`--${F.map((O)=>b(O)).join("-")}`})`}let D=IJ($).get(Y);if(D&&D.length>1){if(!d()){let F=Z?`Property "${q}" maps to "${Z}" scale, but token not found there. `:`No scale mapping found for property "${q}". `;console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${D.map((H)=>H.join(".")).join(", ")}. ${F}Using "${D[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${D[0].join(".")}" to be explicit.`)}}let U=AJ($,Y);if(U)return`var(${`--${U.map((L)=>b(L)).join("-")}`})`}else if($){let Q=IJ($).get(Y);if(Q&&Q.length>1){if(!d())console.warn(`[Stoop] Ambiguous token "$${Y}" found in multiple categories: ${Q.map((U)=>U.join(".")).join(", ")}. Using "${Q[0].join(".")}" (deterministic: shorter paths first, then alphabetical). Use full path "$${Q[0].join(".")}" to be explicit, or use with a CSS property for automatic resolution.`)}let D=AJ($,Y);if(D)return`var(${`--${D.map((H)=>b(H)).join("-")}`})`}return`var(${`--${b(Y)}`})`}function RJ(J,$="stoop",q){let X=q||":root",Y=[];function W(G,Z=[]){let Q=Object.keys(G).sort();for(let D of Q){if(D==="media")continue;let U=G[D],F=[...Z,D];if(FJ(U))W(U,F);else{let L=`--${F.map((_)=>b(_)).join("-")}`,O=typeof U==="string"||typeof U==="number"?iJ(U):String(U);Y.push(` ${L}: ${O};`)}}}if(W(J),Y.length===0)return"";return`${X} {
9
9
  ${Y.join(`
10
10
  `)}
11
- }`}function G0($,J="stoop",q="data-theme"){let X=[];for(let[Y,Q]of Object.entries($)){let G=`[${q}="${Y}"]`,Z=I0(Q,J,G);if(Z)X.push(Z)}return X.join(`
11
+ }`}function XJ(J,$="stoop",q="data-theme"){let X=[];for(let[Y,W]of Object.entries(J)){let G=`[${q}="${Y}"]`,Z=RJ(W,$,G);if(Z)X.push(Z)}return X.join(`
12
12
 
13
- `)}function k($,J,q,X){if(!$||typeof $!=="object")return $;let Y={},Q=!1,G=Object.keys($).sort();for(let Z of G){let W=$[Z];if(t(W)){let U=k(W,J,q,void 0);if(Y[Z]=U,U!==W)Q=!0}else if(typeof W==="string"&&W.includes("$")){Q=!0;let U=X||Z;Y[Z]=W.replace(P1,(D)=>{if(D.startsWith("-$")){let H=D.slice(1);return`calc(-1 * ${X1(H,J,U,q)})`}return X1(D,J,U,q)})}else Y[Z]=W}if(!Q)return $;return Y}function N1($,J){if(typeof $==="symbol"&&$===a)return!0;if(m(J))return!0;if(typeof $==="string"&&$.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function x1($,J){if(typeof J==="object"&&J!==null&&"__stoopClassName"in J&&typeof J.__stoopClassName==="string")return J.__stoopClassName;if(typeof $==="string"&&$.startsWith("__STOOP_COMPONENT_"))return $.replace("__STOOP_COMPONENT_","");return""}function K($,J="",q=0,X){if(!$||typeof $!=="object")return"";if(q>C0)return"";let Y=[],Q=[],G=Object.keys($).sort();for(let W of G){let U=$[W];if(N1(W,U)){let D=x1(W,U);if(!D)continue;let H=T(D);if(!H)continue;let F=J?`${J} .${H}`:`.${H}`,L=U0(U)?K(U,F,q+1,X):"";if(L)Q.push(L);continue}if(U0(U))if(X&&W in X){let D=i0(X[W]);if(D){let H=K(U,J,q+1,X);if(H)Q.push(`${D} { ${H} }`)}}else if(W.startsWith("@")){let D=T(W);if(D){let H=K(U,J,q+1,X);if(H)Q.push(`${D} { ${H} }`)}}else if(W.includes("&")){let D=T(W);if(D){let F=D.split("&").join(J),L=K(U,F,q+1,X);if(L)Q.push(L)}}else if(W.startsWith(":")){let D=T(W);if(D){let H=`${J}${D}`,F=K(U,H,q+1,X);if(F)Q.push(F)}}else if(W.includes(" ")||W.includes(">")||W.includes("+")||W.includes("~")){let D=T(W);if(D){let F=/^[\s>+~]/.test(D.trim())?`${J}${D}`:`${J} ${D}`,L=K(U,F,q+1,X);if(L)Q.push(L)}}else{let D=T(W);if(D){let H=J?`${J} ${D}`:D,F=K(U,H,q+1,X);if(F)Q.push(F)}}else if(U!==void 0){let D=J0(W);if(D&&(typeof U==="string"||typeof U==="number")){let H=n0(U);Y.push(`${D}: ${H};`)}}}let Z=[];if(Y.length>0)Z.push(`${J} { ${Y.join(" ")} }`);return Z.push(...Q),Z.join("")}function p($,J,q="stoop",X,Y,Q){let G=R(q),Z=i($,Y),W=k(Z,J,Q),U=K(W,"",0,X),D=y(U),H=G?`${G}-${D}`:`css-${D}`,F=`${G}:${H}`,L=D0.get(F);if(L)return f(L,G,F),H;let O=K(W,`.${H}`,0,X);return D0.set(F,O),d0.set(F,H),f(O,G,F),H}var G1=new Map;function Q1($,J="stoop"){let q=J||"";G1.set(q,$)}function v1($="stoop"){let J=$||"";return G1.get(J)||null}function R0($,J){let q={...$},X=Object.keys(J);for(let Y of X){if(Y==="media")continue;let Q=J[Y],G=$[Y];if(Q&&typeof Q==="object"&&!Array.isArray(Q)&&G&&typeof G==="object"&&!Array.isArray(G))q[Y]={...G,...Q};else if(Q!==void 0)q[Y]=Q}return q}function O0($,J="stoop"){let q=v1(J);if(!q)return $;if(Y1($,q))return $;return R0(q,$)}function Q0($,J="stoop",q="data-theme"){if(!w())return;let X={};for(let[Q,G]of Object.entries($))X[Q]=O0(G,J);let Y=G0(X,J,q);J1(Y,J)}function Z1($){return function J(q={}){let X=e(q);return R0($,X)}}function W1($,J="stoop",q,X,Y){return function Q(G){return p(G,$,J,q,X,Y)}}function b1($,J,q,X){let Y=`@keyframes ${J} {`,Q=Object.keys($).sort((G,Z)=>{let W=parseFloat(G.replace("%","")),U=parseFloat(Z.replace("%",""));if(G==="from")return-1;if(Z==="from")return 1;if(G==="to")return 1;if(Z==="to")return-1;return W-U});for(let G of Q){if(!l0(G))continue;let Z=$[G];if(!Z||typeof Z!=="object")continue;Y+=` ${G} {`;let W=k(Z,q,X),U=Object.keys(W).sort();for(let D of U){let H=W[D];if(H!==void 0&&(typeof H==="string"||typeof H==="number")){let F=J0(D);if(F){let L=String(H);Y+=` ${F}: ${L};`}}}Y+=" }"}return Y+=" }",Y}function D1($="stoop",J,q){let X=R($),Y=new E(f0);return function Q(G){let Z=$0(G),W=Y.get(Z);if(W)return W;let U=Z.slice(0,8),D=X?`${X}-${U}`:`stoop-${U}`,H=b1(G,D,J,q),F=`__keyframes_${D}`;return f(H,X,F),Y.set(Z,D),D}}var M0=new Set;function U1($,J="stoop",q,X,Y){return function Q(G){let Z=$0(G);if(M0.has(Z))return()=>{};M0.add(Z);let W=R(J),U=i(G,X),D=k(U,$,Y),H=K(D,"",0,q);return f(H,W,`__global_${Z}`),()=>{M0.delete(Z)}}}import{useMemo as Z0,forwardRef as g1,createElement as T1,useContext as C1,createContext as f1}from"react";function H1($,J,q){let X=!1,Y=[];for(let G in $){let Z=J[G];if(Z===void 0)continue;let W=$[G],U=Z===!0?"true":Z===!1?"false":String(Z);if(W[U])Y.push(W[U]),X=!0}if(!X)return q;let Q={...Y[0]};for(let G=1;G<Y.length;G++)Object.assign(Q,Y[G]);return{...q,...Q}}var z0=null;function k1(){if(!z0)z0=f1(null);return z0}function S1($){return{__isStoopStyled:!0,__stoopClassName:$,[a]:$,toString:()=>`__STOOP_COMPONENT_${$}`}}function d1($){return m($)}var u1=new Set(["alignContent","alignItems","alignSelf","animation","animationDelay","animationDirection","animationDuration","animationFillMode","animationIterationCount","animationName","animationPlayState","animationTimingFunction","aspectRatio","backdropFilter","backfaceVisibility","background","backgroundAttachment","backgroundBlendMode","backgroundClip","backgroundColor","backgroundImage","backgroundOrigin","backgroundPosition","backgroundRepeat","backgroundSize","border","borderBottom","borderBottomColor","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStyle","borderBottomWidth","borderCollapse","borderColor","borderImage","borderImageOutset","borderImageRepeat","borderImageSlice","borderImageSource","borderImageWidth","borderLeft","borderLeftColor","borderLeftStyle","borderLeftWidth","borderRadius","borderRight","borderRightColor","borderRightStyle","borderRightWidth","borderSpacing","borderStyle","borderTop","borderTopColor","borderTopLeftRadius","borderTopRightRadius","borderTopStyle","borderTopWidth","borderWidth","bottom","boxShadow","boxSizing","captionSide","caretColor","clear","clip","clipPath","color","columnCount","columnFill","columnGap","columnRule","columnRuleColor","columnRuleStyle","columnRuleWidth","columnSpan","columnWidth","columns","content","counterIncrement","counterReset","cursor","direction","display","emptyCells","filter","flex","flexBasis","flexDirection","flexFlow","flexGrow","flexShrink","flexWrap","float","font","fontFamily","fontFeatureSettings","fontKerning","fontLanguageOverride","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontSynthesis","fontVariant","fontVariantAlternates","fontVariantCaps","fontVariantEastAsian","fontVariantLigatures","fontVariantNumeric","fontVariantPosition","fontWeight","gap","grid","gridArea","gridAutoColumns","gridAutoFlow","gridAutoRows","gridColumn","gridColumnEnd","gridColumnGap","gridColumnStart","gridGap","gridRow","gridRowEnd","gridRowGap","gridRowStart","gridTemplate","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","height","hyphens","imageOrientation","imageRendering","imageResolution","imeMode","inlineSize","isolation","justifyContent","justifyItems","justifySelf","left","letterSpacing","lineHeight","listStyle","listStyleImage","listStylePosition","listStyleType","margin","marginBottom","marginLeft","marginRight","marginTop","maxHeight","maxWidth","minHeight","minWidth","objectFit","objectPosition","opacity","order","orphans","outline","outlineColor","outlineOffset","outlineStyle","outlineWidth","overflow","overflowWrap","overflowX","overflowY","padding","paddingBottom","paddingLeft","paddingRight","paddingTop","pageBreakAfter","pageBreakBefore","pageBreakInside","perspective","perspectiveOrigin","placeContent","placeItems","placeSelf","pointerEvents","position","quotes","resize","right","rowGap","scrollBehavior","tabSize","tableLayout","textAlign","textAlignLast","textDecoration","textDecorationColor","textDecorationLine","textDecorationStyle","textIndent","textJustify","textOverflow","textShadow","textTransform","textUnderlinePosition","top","transform","transformOrigin","transformStyle","transition","transitionDelay","transitionDuration","transitionProperty","transitionTimingFunction","unicodeBidi","userSelect","verticalAlign","visibility","whiteSpace","width","wordBreak","wordSpacing","wordWrap","writingMode","zIndex"]);function y1($){return u1.has($)}function p1($,J){let q=J?new Set(Object.keys(J)):new Set,X={},Y={},Q={};for(let G in $)if(q.has(G))X[G]=$[G];else if(y1(G))Y[G]=$[G];else Q[G]=$[G];return{cssProps:Y,elementProps:Q,variantProps:X}}function F1($,J="stoop",q,X,Y,Q){return function G(Z,W,U){let D=W||r,H=U;if(W&&"variants"in W&&typeof W.variants==="object"){H=W.variants;let{variants:v,...x}=W;D=x}let F;if(typeof Z!=="string"&&d1(Z))F=Z.__stoopClassName;let L=g1(function v(x,j){let{as:z,className:P,css:M,...N}=x,b=z||Z,g=Z0(()=>M&&typeof M==="object"&&M!==null?M:r,[M]),{cssProps:B,elementProps:V,variantProps:S}=p1(N,H),l=C1(Q||k1())?.theme||$,x0=l.media?{...q,...l.media}:q,v0=Z0(()=>{if(!H)return"";let I=Object.entries(S);if(I.length===0)return"";return I.sort(([d],[h])=>d.localeCompare(h)).map(([d,h])=>`${d}:${String(h)}`).join("|")},[S]),b0=Z0(()=>{let I=D;if(H&&v0)I=H1(H,S,D);if(Object.keys(B).length>0)I=Object.assign({},I,B);if(g!==r)I=Object.assign({},I,g);return I},[v0,g,B,D,H,S]),R1=Z0(()=>{let I=[];if(F)I.push(F);let d=p(b0,l,J,x0,X,Y);if(d)I.push(d);if(P){let h=typeof P==="string"?P:String(P),g0=o0(h);if(g0)I.push(g0)}return I.length>0?I.join(" "):void 0},[b0,P,F,l,J,x0,X,Y]);return T1(b,{...V,className:R1,ref:j})}),O=y(JSON.stringify(D)),_=`${J}-${O}`,A=L;return A.selector=S1(_),A}}import{createContext as w1,useCallback as B1,useContext as h1,useLayoutEffect as o,useMemo as P0,useRef as V0,useState as c1}from"react";function E0($){if(!w())return{error:"Not in browser environment",success:!1,value:null};try{return{source:"localStorage",success:!0,value:localStorage.getItem($)}}catch(J){return{error:J instanceof Error?J.message:"localStorage access failed",success:!1,value:null}}}function K0($,J){if(!w())return{error:"Not in browser environment",success:!1,value:void 0};try{return localStorage.setItem($,J),{success:!0,value:void 0}}catch(q){return{error:q instanceof Error?q.message:"localStorage write failed",success:!1,value:void 0}}}function j0($){if(!w())return null;let q=`; ${document.cookie}`.split(`; ${$}=`);if(q.length===2)return q.pop()?.split(";").shift()||null;return null}function L1($,J,q={}){if(!w())return!1;let{maxAge:X=k0,path:Y=S0,secure:Q=!1}=q;try{return document.cookie=`${$}=${J}; path=${Y}; max-age=${X}${Q?"; secure":""}`,!0}catch{return!1}}import{jsx as A1}from"react/jsx-runtime";function N0($,J,q){if(!w())return;let X=J?j0(J):null,Y=E0(q),Q=Y.success?Y.value:null;if(X===$&&Q!==$)K0(q,$);if(Q===$&&J&&X!==$)L1(J,$)}function n1($,J,q){if(!w())return null;if($!==void 0){let Q=j0($);if(Q&&q[Q])return Q}let X=E0(J),Y=X.success?X.value:null;if(Y&&q[Y])return Y;return null}function _1($,J,q="stoop",X,Y){let Q=w1(null),G=w1(null),Z=Object.keys($),W=Z[0]||"default",U=X&&Y?Y(X):void 0;function D({attribute:H="data-theme",children:F,cookieKey:L,defaultTheme:O,storageKey:_="stoop-theme"}){let[A,v]=c1(O||W),x=V0(!1);o(()=>{if(!w()||x.current)return;let B=n1(L,_,$);if(B){if(N0(B,L,_),B!==A)v(B)}x.current=!0},[L,_,$]),o(()=>{if(!w())return;let B=(V)=>{if(V.key===_&&V.newValue&&$[V.newValue]&&V.newValue!==A)v(V.newValue),N0(V.newValue,L,_)};return window.addEventListener("storage",B),()=>{window.removeEventListener("storage",B)}},[_,L,A,$]);let j=P0(()=>{return $[A]||$[O||W]||J},[A,O,W,$,J]),z=V0(!1),P=V0(!1);o(()=>{if(!w()||z.current)return;Q0($,q,H),z.current=!0},[$,q,H]),o(()=>{if(!w()||P.current)return;if(U)U(),P.current=!0},[U]),o(()=>{if(!w())return;if(H)document.documentElement.setAttribute(H,A)},[A,H]);let M=B1((B)=>{if($[B])v(B),K0(_,B),N0(B,L,_);else if(!u())console.warn(`[Stoop] Theme "${B}" not found. Available themes: ${Z.join(", ")}`)},[_,L,$,Z,A]),N=P0(()=>({theme:j,themeName:A}),[j,A]),b=B1(()=>{let V=(Z.indexOf(A)+1)%Z.length,S=Z[V];M(S)},[A,M,Z]),g=P0(()=>({availableThemes:Z,setTheme:M,theme:j,themeName:A,toggleTheme:b}),[j,A,M,b]);return A1(Q.Provider,{value:N,children:A1(G.Provider,{value:g,children:F})})}return{Provider:D,ThemeContext:Q,ThemeManagementContext:G}}function I1($){return function J(){let q=h1($);if(!q)throw new Error("useTheme must be used within a Provider");return q}}function m1($){let{globalCss:J,media:q,prefix:X="stoop",theme:Y,themeMap:Q,utils:G}=$,Z=R(X),W=e(Y),U=W.media||q,D={...n,...Q};Q1(W,Z);let H=W1(W,Z,U,G,D),F=Z1(W),L=U1(W,Z,U,G,D),O=D1(Z,W,D),_=Object.freeze({...W});function A(j){for(let z of j)try{p(z,W,Z,U,G,D)}catch{}}function v(j){if(!$.themes||Object.keys($.themes).length===0)return;Q0($.themes,Z)}function x(j){let z="";if($.themes&&Object.keys($.themes).length>0){let N={};for(let[g,B]of Object.entries($.themes))N[g]=O0(B,Z);let b=G0(N,Z,"data-theme");if(b)z+=b+`
14
- `}else{let N=I0(W,Z);if(N)z+=N+`
15
- `}let P=q1(),M=B0(P).trim();if(M)z+=(z?`
16
- `:"")+M;return z}return{config:{...$,prefix:Z},createTheme:F,css:H,getCssText:x,globalCss:L,globalCssConfig:J,keyframes:O,media:U,mergedThemeMap:D,preloadTheme:v,sanitizedPrefix:Z,theme:_,utils:G,validatedTheme:W,warmCache:A}}function U5($){let J=m1($),q,X,Y;if($.themes){let G={};for(let[D,H]of Object.entries($.themes))G[D]=J.createTheme(H);let{Provider:Z,ThemeContext:W,ThemeManagementContext:U}=_1(G,J.validatedTheme,J.sanitizedPrefix,J.globalCssConfig,J.globalCss);Y=W,q=Z,X=I1(U)}let Q=F1(J.validatedTheme,J.sanitizedPrefix,J.media,J.utils,J.mergedThemeMap,Y);return{config:J.config,createTheme:J.createTheme,css:J.css,getCssText:J.getCssText,globalCss:J.globalCss,keyframes:J.keyframes,preloadTheme:J.preloadTheme,Provider:q,styled:Q,theme:J.theme,useTheme:X,warmCache:J.warmCache}}export{m1 as createStoopBase,U5 as createStoop};
13
+ `)}function h(J,$,q,X){if(!J||typeof J!=="object")return J;let Y={},W=!1,G=Object.keys(J).sort();for(let Z of G){let Q=J[Z];if(t(Q)){let D=h(Q,$,q,void 0);if(Y[Z]=D,D!==Q)W=!0}else if(typeof Q==="string"&&Q.includes("$")){W=!0;let D=X||Z;Y[Z]=Q.replace(z0,(U)=>{if(U.startsWith("-$")){let F=U.slice(1);return`calc(-1 * ${Y0(F,$,D,q)})`}return Y0(U,$,D,q)})}else Y[Z]=Q}if(!W)return J;return Y}var x=new V(S);function j0(J){return J.replace(/([A-Z])/g,"-$1").toLowerCase()}function x0(J){if(J===J.toUpperCase()&&J.length>1)return J.charAt(0)+J.slice(1).toLowerCase();return J}function YJ(J){if(!J)return"";return J.charAt(0).toLowerCase()+J.slice(1).replace(/([A-Z])/g,"-$1").toLowerCase()}function GJ(J){if(!J||typeof J!=="string")return"";let $=x.get(J);if($!==void 0)return $;if(/^-[a-z]+-/.test(J))return x.set(J,J),J;let q=x0(J);if(/^[Mm]oz/i.test(q)){if(q.length===3||q.toLowerCase()==="moz")return x.set(J,"-moz"),"-moz";let G=q.match(/^[Mm]oz(.+)$/i);if(G&&G[1]){let[,Z]=G,Q=YJ(Z);if(Q){let D=`-moz-${Q}`;return x.set(J,D),D}}}if(/^[Ww]ebkit/i.test(q)){if(q.length===6||q.toLowerCase()==="webkit")return x.set(J,"-webkit"),"-webkit";let G=q.match(/^[Ww]ebkit(.+)$/i);if(G&&G[1]){let[,Z]=G,Q=YJ(Z);if(Q){let D=`-webkit-${Q}`;return x.set(J,D),D}}}if(/^[Mm]s/i.test(q)){if(q.length===2||q.toLowerCase()==="ms")return x.set(J,"-ms"),"-ms";let G=q.match(/^[Mm]s(.+)$/i);if(G&&G[1]){let[,Z]=G,Q=YJ(Z);if(Q){let D=`-ms-${Q}`;return x.set(J,D),D}}}if(/^O/i.test(q)){if(q.length===1||q.toLowerCase()==="o")return x.set(J,"-o"),"-o";if(/^O[A-Z]/.test(q)){let G=q.substring(1),Z=YJ(G);if(Z){let Q=`-o-${Z}`;return x.set(J,Q),Q}}}let W=j0(q).replace(/[^a-zA-Z0-9-]/g,"").replace(/^-+|-+$/g,"").replace(/^\d+/,"")||"";return x.set(J,W),W}function N0(J,$){if(typeof J==="symbol"&&J===a)return!0;if(m($))return!0;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return!0;return!1}function v0(J,$){if(typeof $==="object"&&$!==null&&"__stoopClassName"in $&&typeof $.__stoopClassName==="string")return $.__stoopClassName;if(typeof J==="string"&&J.startsWith("__STOOP_COMPONENT_"))return J.replace("__STOOP_COMPONENT_","");return""}function N(J,$="",q=0,X){if(!J||typeof J!=="object")return"";if(q>fJ)return"";let Y=[],W=[],G=Object.keys(J).sort();for(let Q of G){let D=J[Q];if(N0(Q,D)){let U=v0(Q,D);if(!U)continue;let F=k(U);if(!F)continue;let H=$?`${$} .${F}`:`.${F}`,L=UJ(D)?N(D,H,q+1,X):"";if(L)W.push(L);continue}if(UJ(D))if(X&&Q in X){let U=oJ(X[Q]);if(U){let F=N(D,$,q+1,X);if(F)W.push(`${U} { ${F} }`)}}else if(Q.startsWith("@")){let U=k(Q);if(U){let F=N(D,$,q+1,X);if(F)W.push(`${U} { ${F} }`)}}else if(Q.includes("&")){let U=k(Q);if(U){let H=U.split("&").join($),L=N(D,H,q+1,X);if(L)W.push(L)}}else if(Q.startsWith(":")){let U=k(Q);if(U){let F=`${$}${U}`,H=N(D,F,q+1,X);if(H)W.push(H)}}else if(Q.includes(" ")||Q.includes(">")||Q.includes("+")||Q.includes("~")){let U=k(Q);if(U){let H=/^[\s>+~]/.test(U.trim())?`${$}${U}`:`${$} ${U}`,L=N(D,H,q+1,X);if(L)W.push(L)}}else{let U=k(Q);if(U){let F=$?`${$} ${U}`:U,H=N(D,F,q+1,X);if(H)W.push(H)}}else if(D!==void 0){let U=GJ(Q);if(U&&(typeof D==="string"||typeof D==="number")){let F=mJ(D);Y.push(`${U}: ${F};`)}}}let Z=[];if(Y.length>0)Z.push(`${$} { ${Y.join(" ")} }`);return Z.push(...W),Z.join("")}function c(J,$,q="stoop",X,Y,W){let G=M(q),Z=i(J,Y),Q=h(Z,$,W),D=N(Q,"",0,X),U=u(D),F=G?`${G}-${U}`:`css-${U}`,H=`${G}:${F}`,L=DJ.get(H);if(L)return y(L,G,H),F;let O=N(Q,`.${F}`,0,X);return DJ.set(H,O),yJ.set(H,F),y(O,G,H),F}var Q0=new Map;function Z0(J,$="stoop"){let q=$||"";Q0.set(q,J)}function g0(J="stoop"){let $=J||"";return Q0.get($)||null}function OJ(J,$){let q={...J},X=Object.keys($);for(let Y of X){if(Y==="media")continue;let W=$[Y],G=J[Y];if(W&&typeof W==="object"&&!Array.isArray(W)&&G&&typeof G==="object"&&!Array.isArray(G))q[Y]={...G,...W};else if(W!==void 0)q[Y]=W}return q}function MJ(J,$="stoop"){let q=g0($);if(!q)return J;if(G0(J,q))return J;return OJ(q,J)}function QJ(J,$="stoop",q="data-theme"){if(!w())return;let X={};for(let[W,G]of Object.entries(J))X[W]=MJ(G,$);let Y=XJ(X,$,q);q0(Y,$)}function W0(J){return function $(q={}){let X=e(q);return OJ(J,X)}}function D0(J,$="stoop",q,X,Y){return function W(G){return c(G,J,$,q,X,Y)}}function T0(J,$,q,X){let Y=`@keyframes ${$} {`,W=Object.keys(J).sort((G,Z)=>{let Q=parseFloat(G.replace("%","")),D=parseFloat(Z.replace("%",""));if(G==="from")return-1;if(Z==="from")return 1;if(G==="to")return 1;if(Z==="to")return-1;return Q-D});for(let G of W){if(!rJ(G))continue;let Z=J[G];if(!Z||typeof Z!=="object")continue;Y+=` ${G} {`;let Q=h(Z,q,X),D=Object.keys(Q).sort();for(let U of D){let F=Q[U];if(F!==void 0&&(typeof F==="string"||typeof F==="number")){let H=GJ(U);if(H){let L=String(F);Y+=` ${H}: ${L};`}}}Y+=" }"}return Y+=" }",Y}function U0(J="stoop",$,q){let X=M(J),Y=new V(SJ);return function W(G){let Z=LJ(G),Q=Y.get(Z);if(Q)return Q;let D=Z.slice(0,8),U=X?`${X}-${D}`:`stoop-${D}`,F=T0(G,U,$,q),H=`__keyframes_${U}`;return y(F,X,H),Y.set(Z,U),U}}var EJ=new Set;function F0(J,$="stoop",q,X,Y){return function W(G){let Z=LJ(G);if(EJ.has(Z))return()=>{};EJ.add(Z);let Q=M($),D=i(G,X),U=h(D,J,Y),F=N(U,"",0,q);return y(F,Q,`__global_${Z}`),()=>{EJ.delete(Z)}}}import{useMemo as ZJ,forwardRef as k0,createElement as b0,useContext as C0,createContext as f0}from"react";function S0(J,$,q){let X=[];for(let W in J){let G=$[W];if(G===void 0)continue;let Z=J[W],Q=G===!0?"true":G===!1?"false":String(G);if(Z[Q])X.push(Z[Q])}if(X.length===0)return q;if(X.length===1)return{...q,...X[0]};let Y={...X[0]};for(let W=1;W<X.length;W++)Object.assign(Y,X[W]);return{...q,...Y}}var VJ=null;function d0(){if(!VJ)VJ=f0(null);return VJ}function u0(J){return{__isStoopStyled:!0,__stoopClassName:J,[a]:J,toString:()=>`__STOOP_COMPONENT_${J}`}}function y0(J){return m(J)}var h0=new Set(["alignContent","alignItems","alignSelf","animation","animationDelay","animationDirection","animationDuration","animationFillMode","animationIterationCount","animationName","animationPlayState","animationTimingFunction","aspectRatio","backdropFilter","backfaceVisibility","background","backgroundAttachment","backgroundBlendMode","backgroundClip","backgroundColor","backgroundImage","backgroundOrigin","backgroundPosition","backgroundRepeat","backgroundSize","border","borderBottom","borderBottomColor","borderBottomLeftRadius","borderBottomRightRadius","borderBottomStyle","borderBottomWidth","borderCollapse","borderColor","borderImage","borderImageOutset","borderImageRepeat","borderImageSlice","borderImageSource","borderImageWidth","borderLeft","borderLeftColor","borderLeftStyle","borderLeftWidth","borderRadius","borderRight","borderRightColor","borderRightStyle","borderRightWidth","borderSpacing","borderStyle","borderTop","borderTopColor","borderTopLeftRadius","borderTopRightRadius","borderTopStyle","borderTopWidth","borderWidth","bottom","boxShadow","boxSizing","captionSide","caretColor","clear","clip","clipPath","color","columnCount","columnFill","columnGap","columnRule","columnRuleColor","columnRuleStyle","columnRuleWidth","columnSpan","columnWidth","columns","content","counterIncrement","counterReset","cursor","direction","display","emptyCells","filter","flex","flexBasis","flexDirection","flexFlow","flexGrow","flexShrink","flexWrap","float","font","fontFamily","fontFeatureSettings","fontKerning","fontLanguageOverride","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontSynthesis","fontVariant","fontVariantAlternates","fontVariantCaps","fontVariantEastAsian","fontVariantLigatures","fontVariantNumeric","fontVariantPosition","fontWeight","gap","grid","gridArea","gridAutoColumns","gridAutoFlow","gridAutoRows","gridColumn","gridColumnEnd","gridColumnGap","gridColumnStart","gridGap","gridRow","gridRowEnd","gridRowGap","gridRowStart","gridTemplate","gridTemplateAreas","gridTemplateColumns","gridTemplateRows","height","hyphens","imageOrientation","imageRendering","imageResolution","imeMode","inlineSize","isolation","justifyContent","justifyItems","justifySelf","left","letterSpacing","lineHeight","listStyle","listStyleImage","listStylePosition","listStyleType","margin","marginBottom","marginLeft","marginRight","marginTop","maxHeight","maxWidth","minHeight","minWidth","objectFit","objectPosition","opacity","order","orphans","outline","outlineColor","outlineOffset","outlineStyle","outlineWidth","overflow","overflowWrap","overflowX","overflowY","padding","paddingBottom","paddingLeft","paddingRight","paddingTop","pageBreakAfter","pageBreakBefore","pageBreakInside","perspective","perspectiveOrigin","placeContent","placeItems","placeSelf","pointerEvents","position","quotes","resize","right","rowGap","scrollBehavior","tabSize","tableLayout","textAlign","textAlignLast","textDecoration","textDecorationColor","textDecorationLine","textDecorationStyle","textIndent","textJustify","textOverflow","textShadow","textTransform","textUnderlinePosition","top","transform","transformOrigin","transformStyle","transition","transitionDelay","transitionDuration","transitionProperty","transitionTimingFunction","unicodeBidi","userSelect","verticalAlign","visibility","whiteSpace","width","wordBreak","wordSpacing","wordWrap","writingMode","zIndex"]);function c0(J){return h0.has(J)}function p0(J,$){let q=$?new Set(Object.keys($)):new Set,X={},Y={},W={};for(let G in J)if(q.has(G))X[G]=J[G];else if(c0(G))Y[G]=J[G];else W[G]=J[G];return{cssProps:Y,elementProps:W,variantProps:X}}function H0(J,$="stoop",q,X,Y,W){return function G(Z,Q){let D=Q||r,U;if(Q&&"variants"in Q&&typeof Q.variants==="object"&&Q.variants!==null&&!Array.isArray(Q.variants)){let B=Q.variants;if(Object.keys(B).length>0&&Object.values(B).every((P)=>typeof P==="object"&&P!==null&&!Array.isArray(P))){U=Q.variants;let{variants:P,...A}=Q;D=A}}let F;if(typeof Z!=="string"&&y0(Z))F=Z.__stoopClassName;let H=k0(function B(v,P){let{as:A,className:K,css:j,...z}=v,C=A||Z,g=ZJ(()=>j&&typeof j==="object"&&j!==null?j:r,[j]),{cssProps:T,elementProps:I,variantProps:E}=p0(z,U),l=C0(W||d0())?.theme||J,gJ=l.media?{...q,...l.media}:q,TJ=ZJ(()=>{if(!U)return"";let R=Object.entries(E);if(R.length===0)return"";return R.sort(([f],[p])=>f.localeCompare(p)).map(([f,p])=>`${f}:${String(p)}`).join("|")},[E]),kJ=ZJ(()=>{let R=D;if(U&&TJ)R=S0(U,E,D);if(Object.keys(T).length>0)R=Object.assign({},R,T);if(g!==r)R=Object.assign({},R,g);return R},[TJ,g,T,D,U,E]),R0=ZJ(()=>{let R=[];if(F)R.push(F);let f=c(kJ,l,$,gJ,X,Y);if(f)R.push(f);if(K){let p=typeof K==="string"?K:String(K),bJ=lJ(p);if(bJ)R.push(bJ)}return R.length>0?R.join(" "):void 0},[kJ,K,F,l,$,gJ,X,Y]);return b0(C,{...I,className:R0,ref:P})}),L=u(JSON.stringify(D)),O=`${$}-${L}`,_=H;return _.selector=u0(O),_}}import{createContext as w0,useCallback as B0,useContext as n0,useLayoutEffect as o,useMemo as jJ,useRef as xJ,useState as m0}from"react";function KJ(J){if(!w())return{error:"Not in browser environment",success:!1,value:null};try{return{source:"localStorage",success:!0,value:localStorage.getItem(J)}}catch($){return{error:$ instanceof Error?$.message:"localStorage access failed",success:!1,value:null}}}function zJ(J,$){if(!w())return{error:"Not in browser environment",success:!1,value:void 0};try{return localStorage.setItem(J,$),{success:!0,value:void 0}}catch(q){return{error:q instanceof Error?q.message:"localStorage write failed",success:!1,value:void 0}}}function PJ(J){if(!w())return null;let q=`; ${document.cookie}`.split(`; ${J}=`);if(q.length===2)return q.pop()?.split(";").shift()||null;return null}function L0(J,$,q={}){if(!w())return!1;let{maxAge:X=dJ,path:Y=uJ,secure:W=!1}=q;try{return document.cookie=`${J}=${$}; path=${Y}; max-age=${X}${W?"; secure":""}`,!0}catch{return!1}}import{jsx as _0}from"react/jsx-runtime";function NJ(J,$,q){if(!w())return;let X=$?PJ($):null,Y=KJ(q),W=Y.success?Y.value:null;if(X===J&&W!==J)zJ(q,J);if(W===J&&$&&X!==J)L0($,J)}function i0(J,$,q){if(!w())return null;if(J!==void 0){let W=PJ(J);if(W&&q[W])return W}let X=KJ($),Y=X.success?X.value:null;if(Y&&q[Y])return Y;return null}function A0(J,$,q="stoop",X,Y){let W=w0(null),G=w0(null),Z=Object.keys(J),Q=Z[0]||"default",D=X&&Y?Y(X):void 0;function U({attribute:F="data-theme",children:H,cookieKey:L,defaultTheme:O,storageKey:_="stoop-theme"}){let[B,v]=m0(O||Q),P=xJ(!1);o(()=>{if(!w()||P.current)return;let I=i0(L,_,J);if(I){if(NJ(I,L,_),I!==B)v(I)}P.current=!0},[L,_,J]),o(()=>{if(!w())return;let I=(E)=>{if(E.key===_&&E.newValue&&J[E.newValue]&&E.newValue!==B)v(E.newValue),NJ(E.newValue,L,_)};return window.addEventListener("storage",I),()=>{window.removeEventListener("storage",I)}},[_,L,B,J]);let A=jJ(()=>{return J[B]||J[O||Q]||$},[B,O,Q,J,$]),K=xJ(!1),j=xJ(!1);o(()=>{if(!w()||K.current)return;QJ(J,q,F),K.current=!0},[J,q,F]),o(()=>{if(!w()||j.current)return;if(D)D(),j.current=!0},[D]),o(()=>{if(!w())return;if(F)document.documentElement.setAttribute(F,B)},[B,F]);let z=B0((I)=>{if(J[I])v(I),zJ(_,I),NJ(I,L,_);else if(!d())console.warn(`[Stoop] Theme "${I}" not found. Available themes: ${Z.join(", ")}`)},[_,L,J,Z,B]),C=jJ(()=>({theme:A,themeName:B}),[A,B]),g=B0(()=>{let E=(Z.indexOf(B)+1)%Z.length,vJ=Z[E];z(vJ)},[B,z,Z]),T=jJ(()=>({availableThemes:Z,setTheme:z,theme:A,themeName:B,toggleTheme:g}),[A,B,z,g]);return _0(W.Provider,{value:C,children:_0(G.Provider,{value:T,children:H})})}return{Provider:U,ThemeContext:W,ThemeManagementContext:G}}function I0(J){return function $(){let q=n0(J);if(!q)throw new Error("useTheme must be used within a Provider");return q}}function o0(J){let{globalCss:$,media:q,prefix:X="stoop",theme:Y,themeMap:W,utils:G}=J,Z=M(X),Q=e(Y),D=Q.media||q,U={...n,...W};Z0(Q,Z);let F=D0(Q,Z,D,G,U),H=W0(Q),L=F0(Q,Z,D,G,U),O=U0(Z,Q,U),_=Object.freeze({...Q});function B(A){for(let K of A)try{c(K,Q,Z,D,G,U)}catch{}}function v(){if(!J.themes||Object.keys(J.themes).length===0)return;QJ(J.themes,Z)}function P(){let A="";if(J.themes&&Object.keys(J.themes).length>0){let z={};for(let[g,T]of Object.entries(J.themes))z[g]=MJ(T,Z);let C=XJ(z,Z,"data-theme");if(C)A+=C+`
14
+ `}else{let z=RJ(Q,Z);if(z)A+=z+`
15
+ `}let K=X0(),j=_J(K).trim();if(j)A+=(A?`
16
+ `:"")+j;return A}return{config:{...J,prefix:Z},createTheme:H,css:F,getCssText:P,globalCss:L,globalCssConfig:$,keyframes:O,media:D,mergedThemeMap:U,preloadTheme:v,sanitizedPrefix:Z,theme:_,utils:G,validatedTheme:Q,warmCache:B}}function Z4(J){let $=o0(J),q,X,Y;if(J.themes){let G={};for(let[U,F]of Object.entries(J.themes))G[U]=$.createTheme(F);let{Provider:Z,ThemeContext:Q,ThemeManagementContext:D}=A0(G,$.validatedTheme,$.sanitizedPrefix,$.globalCssConfig,$.globalCss);Y=Q,q=Z,X=I0(D)}let W=H0($.validatedTheme,$.sanitizedPrefix,$.media,$.utils,$.mergedThemeMap,Y);return{config:$.config,createTheme:$.createTheme,css:$.css,getCssText:$.getCssText,globalCss:$.globalCss,keyframes:$.keyframes,preloadTheme:$.preloadTheme,Provider:q,styled:W,theme:$.theme,useTheme:X,warmCache:$.warmCache}}export{o0 as createStoopBase,Z4 as createStoop};
package/dist/inject.d.ts CHANGED
@@ -43,7 +43,6 @@ export declare function isInSSRCache(css: string): boolean;
43
43
  /**
44
44
  * Gets or creates the stylesheet element for CSS injection.
45
45
  * Reuses the SSR stylesheet if it exists to prevent FOUC.
46
- * Supports multiple Stoop instances with different prefixes.
47
46
  *
48
47
  * @param prefix - Optional prefix for stylesheet identification
49
48
  * @returns HTMLStyleElement
@@ -59,8 +58,7 @@ export declare function getStylesheet(prefix?: string): HTMLStyleElement;
59
58
  export declare function removeThemeVariableBlocks(css: string): string;
60
59
  /**
61
60
  * Injects CSS variables for all themes using attribute selectors.
62
- * This allows all themes to be available simultaneously, with theme switching
63
- * handled by changing the data-theme attribute.
61
+ * All themes are available simultaneously, with theme switching handled by changing the data-theme attribute.
64
62
  *
65
63
  * @param allThemeVars - CSS string containing all theme CSS variables
66
64
  * @param prefix - Optional prefix for CSS variables
@@ -90,7 +88,7 @@ export declare function injectBrowserCSS(css: string, ruleKey: string, prefix?:
90
88
  */
91
89
  export declare function getStylesheetElement(prefix?: string): HTMLStyleElement | null;
92
90
  /**
93
- * Gets all injected rules (for internal use).
91
+ * Gets all injected rules.
94
92
  */
95
93
  export declare function getAllInjectedRules(): Map<string, string>;
96
94
  /**
@@ -26,6 +26,17 @@ export type StylableElement = HTMLElements | ElementType;
26
26
  export interface StyledBaseProps {
27
27
  css?: CSS;
28
28
  }
29
+ /**
30
+ * CSS object that includes variants configuration.
31
+ * Used for styled component definitions that combine base styles with variants.
32
+ * This type explicitly requires the `variants` property to be present and of type Variants.
33
+ * We exclude variants from the CSS index signature to make it distinct.
34
+ */
35
+ export type CSSWithVariants = {
36
+ [K in keyof CSS as K extends "variants" ? never : K]: CSS[K];
37
+ } & {
38
+ variants: Variants;
39
+ };
29
40
  export type UtilityFunction = (value: CSSPropertyValue | CSS | undefined) => CSS;
30
41
  /**
31
42
  * Theme scale type - represents valid keys from DefaultTheme.
@@ -95,10 +106,10 @@ export interface StoopServerInstance {
95
106
  };
96
107
  createTheme: (themeOverride: Partial<Theme>) => Theme;
97
108
  css: (styles: CSS) => string;
98
- getCssText: (theme?: string | Theme) => string;
109
+ getCssText: () => string;
99
110
  globalCss: (...args: CSS[]) => () => void;
100
111
  keyframes: (definition: Record<string, CSS>) => string;
101
- preloadTheme: (theme: string | Theme) => void;
112
+ preloadTheme: () => void;
102
113
  theme: Theme;
103
114
  warmCache: (styles: CSS[]) => void;
104
115
  }
@@ -194,9 +205,11 @@ export type StyledComponent<DefaultElement extends ElementType, VariantsConfig e
194
205
  };
195
206
  /**
196
207
  * Styled function type - the main styled() function signature
208
+ * Variants must be embedded in the baseStyles object, matching Stitches API.
197
209
  */
198
210
  export interface StyledFunction {
199
- <DefaultElement extends StylableElement, VariantsConfig extends Variants = {}>(defaultElement: DefaultElement, baseStyles?: CSS, variants?: VariantsConfig): StyledComponent<DefaultElement, VariantsConfig>;
211
+ <DefaultElement extends StylableElement, BaseStyles extends CSSWithVariants>(defaultElement: DefaultElement, baseStyles: BaseStyles): StyledComponent<DefaultElement, BaseStyles["variants"]>;
212
+ <DefaultElement extends StylableElement>(defaultElement: DefaultElement, baseStyles?: CSS): StyledComponent<DefaultElement, {}>;
200
213
  }
201
214
  export interface GetCssTextOptions {
202
215
  theme?: Theme;
@@ -248,10 +261,9 @@ export interface StoopInstance {
248
261
  * Gets all generated CSS text for server-side rendering.
249
262
  * Always includes theme CSS variables.
250
263
  *
251
- * @param theme - Deprecated parameter, kept for backward compatibility but ignored
252
264
  * @returns CSS text string with theme variables and component styles
253
265
  */
254
- getCssText: (theme?: string | Theme) => string;
266
+ getCssText: () => string;
255
267
  config: StoopConfig;
256
268
  /**
257
269
  * Pre-compiles CSS objects to warm the cache.
@@ -261,12 +273,11 @@ export interface StoopInstance {
261
273
  */
262
274
  warmCache: (styles: CSS[]) => void;
263
275
  /**
264
- * Preloads a theme by injecting its CSS variables before React renders.
276
+ * Preloads themes by injecting CSS variables before React renders.
265
277
  * Useful for preventing FOUC when loading a non-default theme from localStorage.
266
- *
267
- * @param theme - Theme to preload (theme name string or Theme object)
278
+ * Always injects all configured themes.
268
279
  */
269
- preloadTheme: (theme: string | Theme) => void;
280
+ preloadTheme: () => void;
270
281
  /**
271
282
  * Provider component for managing theme state and updates.
272
283
  * Available when themes are provided in createStoop config.
@@ -11,7 +11,6 @@ import type { CSS, DefaultTheme, StyledComponentRef, Theme, UtilityFunction } fr
11
11
  export declare function isBrowser(): boolean;
12
12
  /**
13
13
  * Checks if running in production mode.
14
- * Extracted to helper function for consistency.
15
14
  *
16
15
  * @returns True if running in production mode
17
16
  */
@@ -25,7 +24,6 @@ export declare function isProduction(): boolean;
25
24
  export declare function isCSSObject(value: unknown): value is CSS;
26
25
  /**
27
26
  * Checks if a value is a styled component reference.
28
- * Consolidated function used across the codebase.
29
27
  *
30
28
  * @param value - Value to check
31
29
  * @returns True if value is a styled component reference
@@ -47,7 +45,6 @@ export declare function isValidCSSObject(value: unknown): value is CSS;
47
45
  export declare function isThemeObject(value: unknown): value is Theme;
48
46
  /**
49
47
  * Validates that a theme object only contains approved scales.
50
- * In production, skips all validation for performance.
51
48
  *
52
49
  * @param theme - Theme object to validate
53
50
  * @returns Validated theme as DefaultTheme
@@ -1,9 +1,8 @@
1
1
  /**
2
2
  * Storage and theme detection utilities.
3
- * Provides simplified localStorage and cookie management, plus automatic theme selection.
4
- * Supports SSR compatibility and error handling.
3
+ * Provides simplified localStorage and cookie management with SSR compatibility and error handling.
5
4
  */
6
- import type { ThemeDetectionOptions, ThemeDetectionResult, StorageOptions, StorageResult } from "../types";
5
+ import type { StorageOptions, StorageResult } from "../types";
7
6
  /**
8
7
  * Safely gets a value from localStorage.
9
8
  *
@@ -54,95 +53,3 @@ export declare function setCookie(name: string, value: string, options?: Omit<St
54
53
  * @returns Success status
55
54
  */
56
55
  export declare function removeCookie(name: string, path?: string): boolean;
57
- /**
58
- * Unified storage API that works with both localStorage and cookies.
59
- *
60
- * @param key - Storage key
61
- * @param options - Storage options
62
- * @returns Storage result
63
- */
64
- export declare function getStorage(key: string, options?: StorageOptions): StorageResult<string | null>;
65
- /**
66
- * Unified storage API that works with both localStorage and cookies.
67
- *
68
- * @param key - Storage key
69
- * @param value - Value to store
70
- * @param options - Storage options
71
- * @returns Storage result
72
- */
73
- export declare function setStorage(key: string, value: string, options?: StorageOptions): StorageResult<void>;
74
- /**
75
- * Unified storage API that works with both localStorage and cookies.
76
- *
77
- * @param key - Storage key
78
- * @param options - Storage options
79
- * @returns Storage result
80
- */
81
- export declare function removeStorage(key: string, options?: StorageOptions): StorageResult<void>;
82
- /**
83
- * Gets a JSON value from storage with automatic parsing.
84
- *
85
- * @param key - Storage key
86
- * @param fallback - Fallback value if parsing fails or key not found
87
- * @param options - Storage options
88
- * @returns Parsed JSON value or fallback
89
- */
90
- export declare function getJsonFromStorage<T>(key: string, fallback: T, options?: StorageOptions): StorageResult<T>;
91
- /**
92
- * Sets a JSON value in storage with automatic serialization.
93
- *
94
- * @param key - Storage key
95
- * @param value - Value to serialize and store
96
- * @param options - Storage options
97
- * @returns Storage result
98
- */
99
- export declare function setJsonInStorage<T>(key: string, value: T, options?: StorageOptions): StorageResult<void>;
100
- /**
101
- * Creates a typed storage interface for a specific key.
102
- *
103
- * @param key - Storage key
104
- * @param options - Storage options
105
- * @returns Typed storage interface
106
- */
107
- export declare function createStorage<T = string>(key: string, options?: StorageOptions): {
108
- get: () => StorageResult<string | null>;
109
- getJson: (fallback: T) => StorageResult<T>;
110
- remove: () => StorageResult<void>;
111
- set: (value: string) => StorageResult<void>;
112
- setJson: (value: T) => StorageResult<void>;
113
- };
114
- /**
115
- * Detects the best theme to use based on multiple sources with priority.
116
- *
117
- * Priority order (highest to lowest):
118
- * 1. Explicit localStorage preference
119
- * 2. Cookie preference (for SSR compatibility)
120
- * 3. System color scheme preference
121
- * 4. Default theme
122
- *
123
- * @param options - Theme detection options
124
- * @returns Theme detection result
125
- */
126
- export declare function detectTheme(options?: ThemeDetectionOptions): ThemeDetectionResult;
127
- /**
128
- * Creates a theme detector function with pre-configured options.
129
- *
130
- * @param options - Theme detection options
131
- * @returns Theme detection function
132
- */
133
- export declare function createThemeDetector(options: ThemeDetectionOptions): () => ThemeDetectionResult;
134
- /**
135
- * Auto-detects theme for SSR contexts (server-side or during hydration).
136
- * Uses only cookie and default sources since localStorage isn't available.
137
- *
138
- * @param options - Theme detection options
139
- * @returns Theme name
140
- */
141
- export declare function detectThemeForSSR(options?: ThemeDetectionOptions): string;
142
- /**
143
- * Listens for system theme changes and calls callback when changed.
144
- *
145
- * @param callback - Function to call when system theme changes
146
- * @returns Cleanup function
147
- */
148
- export declare function onSystemThemeChange(callback: (theme: "dark" | "light") => void): () => void;
@@ -36,7 +36,6 @@ export declare function escapeCSSValue(value: string | number): string;
36
36
  /**
37
37
  * Validates and sanitizes CSS selectors to prevent injection attacks.
38
38
  * Only allows safe selector characters. Returns empty string for invalid selectors.
39
- * Uses memoization for performance.
40
39
  *
41
40
  * @param selector - Selector to sanitize
42
41
  * @returns Sanitized selector string or empty string if invalid
@@ -45,7 +44,6 @@ export declare function sanitizeCSSSelector(selector: string): string;
45
44
  /**
46
45
  * Validates and sanitizes CSS variable names to prevent injection attacks.
47
46
  * CSS custom properties must start with -- and contain only valid characters.
48
- * Uses memoization for performance.
49
47
  *
50
48
  * @param name - Variable name to sanitize
51
49
  * @returns Sanitized variable name
@@ -78,20 +76,11 @@ export declare function sanitizeMediaQuery(mediaQuery: string): string;
78
76
  /**
79
77
  * Sanitizes CSS class names to prevent injection attacks.
80
78
  * Only allows valid CSS class name characters.
81
- * Uses memoization for performance.
82
79
  *
83
80
  * @param className - Class name(s) to sanitize
84
81
  * @returns Sanitized class name string
85
82
  */
86
83
  export declare function sanitizeClassName(className: string): string;
87
- /**
88
- * Sanitizes CSS property names to prevent injection attacks.
89
- * Uses memoization for performance.
90
- *
91
- * @param propertyName - Property name to sanitize
92
- * @returns Sanitized property name
93
- */
94
- export declare function sanitizeCSSPropertyName(propertyName: string): string;
95
84
  /**
96
85
  * Validates keyframe percentage keys (e.g., "0%", "50%", "from", "to").
97
86
  *
@@ -101,7 +90,6 @@ export declare function sanitizeCSSPropertyName(propertyName: string): string;
101
90
  export declare function validateKeyframeKey(key: string): boolean;
102
91
  /**
103
92
  * Gets a pre-compiled regex for matching :root CSS selector blocks.
104
- * Uses caching for performance.
105
93
  *
106
94
  * @param prefix - Optional prefix (unused, kept for API compatibility)
107
95
  * @returns RegExp for matching :root selector blocks
@@ -109,7 +97,6 @@ export declare function validateKeyframeKey(key: string): boolean;
109
97
  export declare function getRootRegex(prefix?: string): RegExp;
110
98
  /**
111
99
  * Auto-detects theme scale from CSS property name using pattern matching.
112
- * Used as fallback when property is not in DEFAULT_THEME_MAP.
113
100
  *
114
101
  * @param property - CSS property name
115
102
  * @returns Theme scale name or undefined if no pattern matches
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Theme token resolution utilities.
3
3
  * Converts theme tokens to CSS variables for runtime theme switching.
4
- * Uses cached token index for efficient lookups and theme comparison.
5
4
  */
6
5
  import type { CSS, Theme, ThemeScale } from "../types";
7
6
  /**
@@ -34,8 +33,7 @@ export declare function tokenToCSSVar(token: string, theme?: Theme, property?: s
34
33
  export declare function generateCSSVariables(theme: Theme, prefix?: string, attributeSelector?: string): string;
35
34
  /**
36
35
  * Generates CSS custom properties for all themes using attribute selectors.
37
- * This allows all themes to be available simultaneously, with theme switching
38
- * handled by changing the data-theme attribute.
36
+ * All themes are available simultaneously, with theme switching handled by changing the data-theme attribute.
39
37
  *
40
38
  * @param themes - Map of theme names to theme objects
41
39
  * @param prefix - Optional prefix for CSS variable names
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stoop",
3
3
  "description": "CSS-in-JS library with type inference, theme creation, and variants support.",
4
- "version": "0.4.1",
4
+ "version": "0.5.0",
5
5
  "author": "Jackson Dolman <mail@dolmios.com>",
6
6
  "main": "./dist/create-stoop.js",
7
7
  "types": "./dist/create-stoop.d.ts",
@@ -17,10 +17,13 @@
17
17
  "react-polymorphic-types": "^2.0.0"
18
18
  },
19
19
  "devDependencies": {
20
+ "@stitches/stringify": "^1.2.8",
20
21
  "@types/node": "^25.0.3",
21
22
  "@types/react": "^19.2.7",
22
23
  "@types/react-dom": "^19.2.3",
23
24
  "bun-types": "^1.3.5",
25
+ "style-object-to-css-string": "^1.1.3",
26
+ "to-css": "^1.2.1",
24
27
  "typescript": "^5.9.3"
25
28
  },
26
29
  "exports": {
@@ -36,12 +39,6 @@
36
39
  "require": "./dist/utils/storage.js",
37
40
  "default": "./dist/utils/storage.js"
38
41
  },
39
- "./utils/auto-preload": {
40
- "types": "./dist/utils/auto-preload.d.ts",
41
- "import": "./dist/utils/auto-preload.js",
42
- "require": "./dist/utils/auto-preload.js",
43
- "default": "./dist/utils/auto-preload.js"
44
- },
45
42
  "./types": {
46
43
  "types": "./dist/types/index.d.ts",
47
44
  "import": "./dist/types/index.js",
@@ -112,4 +109,3 @@
112
109
  "sideEffects": false,
113
110
  "type": "module"
114
111
  }
115
-
@@ -1,7 +0,0 @@
1
- /**
2
- * Global CSS injection API.
3
- * Creates a function that injects global styles into the document.
4
- * Supports media queries, nested selectors, and theme tokens.
5
- */
6
- import type { CSS, Theme, ThemeScale, UtilityFunction } from "../types";
7
- export declare function createGlobalCSSFunction(defaultTheme: Theme, prefix?: string, media?: Record<string, string>, utils?: Record<string, UtilityFunction>, themeMap?: Record<string, ThemeScale>): (styles: CSS) => () => void;
@@ -1,15 +0,0 @@
1
- /**
2
- * Variant application logic.
3
- * Merges variant styles with base styles based on component props.
4
- * Optimized to avoid unnecessary object spreads when no variants are applied.
5
- */
6
- import type { CSS, Variants, VariantProps } from "../types";
7
- /**
8
- * Applies variant styles to base styles based on component props.
9
- *
10
- * @param variants - Variant configuration object
11
- * @param props - Component props containing variant values
12
- * @param baseStyles - Base styles to merge with variant styles
13
- * @returns Merged CSS object
14
- */
15
- export declare function applyVariants(variants: Variants, props: VariantProps, baseStyles: CSS): CSS;
@@ -1,45 +0,0 @@
1
- /**
2
- * Auto-preloading utilities for cache warming and theme preloading.
3
- * Helps eliminate FOUC (Flash of Unstyled Content) by pre-compiling styles and preloading themes.
4
- */
5
- import type { CSS, Theme, ThemeDetectionOptions, ThemeDetectionResult, AutoPreloadOptions, AutoPreloadResult } from "../types";
6
- /**
7
- * Common UI component styles that are frequently used.
8
- * These represent typical design system patterns.
9
- */
10
- export declare const COMMON_UI_STYLES: CSS[];
11
- /**
12
- * Automatically warms the cache with common styles.
13
- *
14
- * @param warmCacheFn - The warmCache function from Stoop instance
15
- * @param styles - Styles to warm (defaults to COMMON_UI_STYLES)
16
- * @returns Promise that resolves when warming is complete
17
- */
18
- export declare function autoWarmCache(warmCacheFn: (styles: CSS[]) => void, styles?: CSS[]): Promise<void>;
19
- /**
20
- * Automatically preloads a detected theme.
21
- *
22
- * @param preloadThemeFn - The preloadTheme function from Stoop instance
23
- * @param options - Theme detection options
24
- * @param ssr - Whether running in SSR context
25
- * @returns Promise that resolves when preloading is complete
26
- */
27
- export declare function autoPreloadTheme(preloadThemeFn: (theme: string | Theme) => void, options?: ThemeDetectionOptions, ssr?: boolean): Promise<ThemeDetectionResult>;
28
- /**
29
- * Performs automatic preloading operations based on configuration.
30
- *
31
- * @param warmCacheFn - The warmCache function from Stoop instance
32
- * @param preloadThemeFn - The preloadTheme function from Stoop instance
33
- * @param options - Auto-preload options
34
- * @returns Promise that resolves with preload results
35
- */
36
- export declare function autoPreload(warmCacheFn: (styles: CSS[]) => void, preloadThemeFn: (theme: string | Theme) => void, options?: AutoPreloadOptions): Promise<AutoPreloadResult>;
37
- /**
38
- * Creates an auto-preloader with pre-configured options.
39
- *
40
- * @param warmCacheFn - The warmCache function from Stoop instance
41
- * @param preloadThemeFn - The preloadTheme function from Stoop instance
42
- * @param defaultOptions - Default auto-preload options
43
- * @returns Auto-preloader function
44
- */
45
- export declare function createAutoPreloader(warmCacheFn: (styles: CSS[]) => void, preloadThemeFn: (theme: string | Theme) => void, defaultOptions?: AutoPreloadOptions): (options?: Partial<AutoPreloadOptions>) => Promise<AutoPreloadResult>;