@symbo.ls/scratch 3.14.769 → 3.14.773

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @symbo.ls/scratch
2
2
 
3
+ ## 3.14.773
4
+
5
+ ### Patch Changes
6
+
7
+ - Auto-generated cross-repo patch release.
8
+
9
+ ## 3.14.771
10
+
11
+ ### Patch Changes
12
+
13
+ - Auto-generated cross-repo patch release.
14
+
3
15
  ## 3.14.769
4
16
 
5
17
  ### Patch Changes
@@ -1 +1 @@
1
- "use strict";var T=Object.create;var p=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var o in t)p(e,o,{get:t[o],enumerable:!0})},b=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of x(t))!V.call(e,n)&&n!==o&&p(e,n,{get:()=>t[n],enumerable:!(r=d(t,n))||r.enumerable});return e};var F=(e,t,o)=>(o=e!=null?T(O(e)):{},b(t||!e||!e.__esModule?p(o,"default",{value:e,enumerable:!0}):o,e)),D=e=>b(p({},"__esModule",{value:!0}),e);var U={};y(U,{CONFIG:()=>f,FACTORY:()=>c,activateConfig:()=>R,createConfig:()=>k,cssMediaVars:()=>C,cssVars:()=>S,defineThemeSignal:()=>u,getActiveConfig:()=>A,getThemeSignal:()=>P,popConfig:()=>L,pushConfig:()=>M,setActiveConfig:()=>j,toCamel:()=>v});module.exports=D(U);var s=require("@symbo.ls/utils"),h=require("@symbo.ls/signal"),I=F(require("./defaultConfig/index.js"),1);const S={},C={},g=I,m={},v=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in g){const t=e.toLowerCase();m[t]=g[e];const o=v(t);o!==t&&(m[o]=g[e]),t!==e&&(m[e]=g[e])}const f={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:S,cssMediaVars:C,CSS_VARS:S,CSS_MEDIA_VARS:C,_scratchConfig:!0,...m},u=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return(0,s.isDefined)(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=(0,s.isDefined)(t)?t:e.globalTheme,r=(0,h.createSignal)((0,s.isDefined)(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return r.get()},set(n){r.set(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:r,enumerable:!1,configurable:!0,writable:!0}),r},P=e=>e?u(e):null;u(f);const _=(0,s.deepClone)(f),c={active:"0",0:f},R=e=>((0,s.isDefined)(e)&&(c.active=e),c[e||c.active]),l=[],M=e=>{e&&e._scratchConfig&&l.push(e)},L=()=>{l.pop()},A=e=>l.length?l[l.length-1]:c[e||c.active]||f,j=e=>{if((0,s.isObject)(e))return c.active="1",c[1]=(0,s.deepMerge)(e,(0,s.deepClone)(_)),u(c[1]),e},G=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],w=["useVariable","globalTheme","verbose"],E=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],N=e=>{for(const t of E){let o;for(const r of t){const n=e[r];(0,s.isObject)(n)&&(o=o?(0,s.deepMerge)(n,o):n)}if(o)for(const r of t)(0,s.isObject)(e[r])&&(e[r]=o)}},k=(e,t,{cleanBase:o=!1}={})=>{const r=o?null:A(),n=(0,s.deepClone)(!o&&r&&r._scratchConfig?r:_);for(const i of G)delete n[i];for(const i of w)Object.prototype.hasOwnProperty.call(_,i)?n[i]=_[i]:delete n[i];const a=(0,s.deepMerge)(t||{},n);return a.cssVars={},a.cssMediaVars={},a.CSS_VARS=a.cssVars,a.CSS_MEDIA_VARS=a.cssMediaVars,a._scratchConfig=!0,N(a),u(a),e&&(c[e]=a),a};
1
+ "use strict";var x=Object.create;var m=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var P=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},d=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of O(t))!V.call(e,n)&&n!==o&&m(e,n,{get:()=>t[n],enumerable:!(s=A(t,n))||s.enumerable});return e};var R=(e,t,o)=>(o=e!=null?x(y(e)):{},d(t||!e||!e.__esModule?m(o,"default",{value:e,enumerable:!0}):o,e)),F=e=>d(m({},"__esModule",{value:!0}),e);var B={};P(B,{CONFIG:()=>i,FACTORY:()=>l,activateConfig:()=>j,createConfig:()=>z,cssMediaVars:()=>v,cssVars:()=>h,defineResolvedThemeSignal:()=>p,defineThemeSignal:()=>f,getActiveConfig:()=>T,getResolvedThemeSignal:()=>M,getThemeSignal:()=>I,popConfig:()=>w,pushConfig:()=>L,setActiveConfig:()=>G,toCamel:()=>C});module.exports=F(B);var r=require("@symbo.ls/utils"),b=require("@symbo.ls/signal"),D=R(require("./defaultConfig/index.js"),1);const h={},v={},g=D,_={},C=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in g){const t=e.toLowerCase();_[t]=g[e];const o=C(t);o!==t&&(_[o]=g[e]),t!==e&&(_[e]=g[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:h,cssMediaVars:v,CSS_VARS:h,CSS_MEDIA_VARS:v,_scratchConfig:!0,..._},f=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return(0,r.isDefined)(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=(0,r.isDefined)(t)?t:e.globalTheme,s=(0,b.createSignal)((0,r.isDefined)(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},I=e=>e?f(e):null,p=(e,t)=>{if(!e)return null;if(e.__resolvedThemeSignal)return(0,r.isDefined)(t)&&e.__resolvedThemeSignal.set(t),e.__resolvedThemeSignal;const o=(0,r.isDefined)(t)?t:e.resolvedTheme,s=(0,b.createSignal)((0,r.isDefined)(o)?o:null);return Object.defineProperty(e,"resolvedTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"__resolvedThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},M=e=>e?p(e):null;f(i),p(i);const S=(0,r.deepClone)(i),l={active:"0",0:i},j=e=>((0,r.isDefined)(e)&&(l.active=e),l[e||l.active]),u=[],L=e=>{e&&e._scratchConfig&&u.push(e)},w=()=>{u.pop()},T=e=>u.length?u[u.length-1]:l[e||l.active]||i,G=e=>{if((0,r.isObject)(e))return l.active="1",l[1]=(0,r.deepMerge)(e,(0,r.deepClone)(S)),f(l[1]),p(l[1]),e},E=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],N=["useVariable","globalTheme","verbose"],k=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],U=e=>{for(const t of k){let o;for(const s of t){const n=e[s];(0,r.isObject)(n)&&(o=o?(0,r.deepMerge)(n,o):n)}if(o)for(const s of t)(0,r.isObject)(e[s])&&(e[s]=o)}},z=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:T(),n=(0,r.deepClone)(!o&&s&&s._scratchConfig?s:S);for(const c of E)delete n[c];for(const c of N)Object.prototype.hasOwnProperty.call(S,c)?n[c]=S[c]:delete n[c];const a=(0,r.deepMerge)(t||{},n);return a.cssVars={},a.cssMediaVars={},a.CSS_VARS=a.cssVars,a.CSS_MEDIA_VARS=a.cssMediaVars,a._scratchConfig=!0,U(a),f(a),p(a),e&&(l[e]=a),a};
@@ -1 +1 @@
1
- "use strict";var x=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var W=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},N=(t,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let n of q(s))!G.call(t,n)&&n!==e&&x(t,n,{get:()=>s[n],enumerable:!(c=j(s,n))||c.enumerable});return t};var H=t=>N(x({},"__esModule",{value:!0}),t);var J={};W(J,{VALUE_TRANSFORMERS:()=>D,changeGlobalTheme:()=>z,set:()=>U,setEach:()=>M,setValue:()=>k});module.exports=H(J);var b=require("./factory.js"),o=require("./system/index.js"),S=require("@symbo.ls/utils"),u=require("./utils/host.js");const Y=(t,s)=>{const e=(0,b.getActiveConfig)(),{cssVars:c}=e,n=s.startsWith("--")?s:`--${s}`;return c[n]=t,t},l=t=>t,D={color:o.setColor,gradient:o.setGradient,font:o.setFont,fontFamily:o.setFontFamily,fontfamily:o.setFontFamily,theme:o.setTheme,icons:o.setSvgIcon,semanticIcons:l,semanticicons:l,svg:o.setSVG,svgData:l,typography:l,shadow:o.setShadow,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:Y,sizes:l,shape:l},$=(t,s,e,c)=>{(0,u.parkHostObject)(t,e,s);const n={};for(const r of c)t[r]===s&&(t[r]=n);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),n},k=(t,s,e)=>{const c=(0,b.getActiveConfig)(),n=(0,b.toCamel)(t),r=n.toLowerCase(),d=c[n]||c[r]||c[t],i=(0,u.isHostObject)(d)?$(c,d,r,[n,r,t]):d,m=D[n]||D[r];if(m)try{const a=m(s,e);return i&&(i[e]=a),i}catch(a){c.verbose&&console.warn("Error setting",r,"value",s,e,a)}if(!m){const a=i||(c[r]={});return a[e]=s,a}c.verbose&&console.warn("Can not find",r,"method in scratch")},M=(t,s)=>{const e=(0,b.getActiveConfig)(),c=t.toLowerCase();return(0,u.isHostObject)(s)?((0,u.parkHostObject)(e,c,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",c,"design-system family"),e[c]||e[t]):(Object.keys(s).sort((r,d)=>{const i=(0,S.isObject)(s[r])||(0,S.isArray)(s[r])?1:0,m=(0,S.isObject)(s[d])||(0,S.isArray)(s[d])?1:0;return i-m}).forEach(r=>{try{return k(c,s[r],r)}catch(d){e.verbose&&console.warn("Error setting",c,"value",s[r],r,d)}}),e[c]||e[t])},z=(t,s)=>{const e=s||(0,b.getActiveConfig)();e.globalTheme=t;const n=(0,u.resolveConfigDocument)(e)||(typeof document<"u"?document:null),r=n&&n.defaultView||(typeof window<"u"?window:null);if(n){const i=e.themeRoot||n.documentElement;if(t&&t!=="auto")i.setAttribute("data-theme",t),t==="dark"||t==="light"?i.style.colorScheme=t:i.style.colorScheme="light dark";else if(r&&r.matchMedia){const a=p=>{i.setAttribute("data-theme",p.matches?"dark":"light")},h=r.matchMedia("(prefers-color-scheme: dark)");if(a(h),i.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=a;try{h.addEventListener("change",a)}catch{h.addListener(a)}}}else i.setAttribute("data-theme","light"),i.style.colorScheme="light"}const d=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const i in e.cssVars)i.startsWith(d)&&delete e.cssVars[i];for(const i in e.cssMediaVars)delete e.cssMediaVars[i];if(n&&e.cssVars){const i=e.scopeSelector||":root",m=n.styleSheets;for(let a=0;a<m.length;a++)try{const h=m[a].cssRules;for(let p=0;p<h.length;p++)if(h[p].selectorText===i){for(const w in e.cssVars)h[p].style.setProperty(w,e.cssVars[w]);return e}}catch{}}return e},B={},U=(t,s=B)=>{let e=s.config||(0,b.getActiveConfig)();const{version:c,verbose:n,useVariable:r,useReset:d,useSvgSprite:i,useFontImport:m,useIconSprite:a,globalTheme:h,themeRoot:p,useDocumentTheme:w,useDefaultConfig:E,semanticIcons:R,hoverMedia:A,files:L,assets:F,...y}=t;s.newConfig&&(e=(0,b.setActiveConfig)(s.newConfig)),(0,u.isDomDocument)(y.document)&&(e.__domDocument=y.document,delete y.document),(0,u.isDomDocument)(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),L!==void 0&&(e.files=L),F!==void 0&&(e.assets=F),n!==void 0&&(e.verbose=n),r!==void 0&&(e.useVariable=r),d!==void 0&&(e.useReset=d),m!==void 0&&(e.useFontImport=m),i!==void 0&&(e.useSvgSprite=i),a!==void 0&&(e.useIconSprite=a),w!==void 0&&(e.useDocumentTheme=w),h!==void 0&&(e.globalTheme=h),p!==void 0&&(e.themeRoot=p),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),E!==void 0&&(e.useDefaultConfig=E),R!==void 0&&(e.semanticIcons=R),A!==void 0&&(e.hoverMedia=A),e.verbose&&console.log(e);const C=(0,u.resolveConfigDocument)(e)||(typeof document<"u"?document:null),_=C&&C.defaultView||(typeof window<"u"?window:null),v=C&&(e.themeRoot||C.documentElement);if(v&&typeof v.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")v.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?v.style.colorScheme=e.globalTheme:v.style.colorScheme="light dark";else if(_&&_.matchMedia){const g=P=>{v.setAttribute("data-theme",P.matches?"dark":"light")},V=_.matchMedia("(prefers-color-scheme: dark)");if(g(V),v.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=g;try{V.addEventListener("change",g)}catch{V.addListener(g)}}}else v.setAttribute("data-theme","light"),v.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const T=Object.keys(y).filter(f=>!f.startsWith("__")),I=new Set(T);if(T.forEach(f=>{const g=f.toLowerCase();g!==f&&I.has(g)&&(0,S.deepMerge)(y[g],y[f])}),T.map(f=>{const g=f.toLowerCase();if(!(g!==f&&I.has(g)))return M(f,y[f])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),y.typography)try{(0,o.applyTypographySequence)()}catch(f){e.verbose&&console.warn("Error applying typography sequence",f)}if(y.spacing)try{(0,o.applySpacingSequence)()}catch(f){e.verbose&&console.warn("Error applying spacing sequence",f)}if(y.timing)try{(0,o.applyTimingSequence)()}catch(f){e.verbose&&console.warn("Error applying timing sequence",f)}(0,o.applyDocument)();const O=(0,o.applyReset)();return O&&(e.reset=O),e};
1
+ "use strict";var x=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var N=(t,s)=>{for(var e in s)x(t,e,{get:s[e],enumerable:!0})},H=(t,s,e,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of G(s))!W.call(t,r)&&r!==e&&x(t,r,{get:()=>s[r],enumerable:!(c=q(s,r))||c.enumerable});return t};var Y=t=>H(x({},"__esModule",{value:!0}),t);var K={};N(K,{VALUE_TRANSFORMERS:()=>D,changeGlobalTheme:()=>B,set:()=>J,setEach:()=>j,setValue:()=>M});module.exports=Y(K);var v=require("./factory.js"),o=require("./system/index.js"),T=require("@symbo.ls/utils"),u=require("./utils/host.js");const $=(t,s)=>{const e=(0,v.getActiveConfig)(),{cssVars:c}=e,r=s.startsWith("--")?s:`--${s}`;return c[r]=t,t},f=t=>t,D={color:o.setColor,gradient:o.setGradient,font:o.setFont,fontFamily:o.setFontFamily,fontfamily:o.setFontFamily,theme:o.setTheme,icons:o.setSvgIcon,semanticIcons:f,semanticicons:f,svg:o.setSVG,svgData:f,typography:f,shadow:o.setShadow,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:$,sizes:f,shape:f},z=(t,s,e,c)=>{(0,u.parkHostObject)(t,e,s);const r={};for(const n of c)t[n]===s&&(t[n]=r);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),r},M=(t,s,e)=>{const c=(0,v.getActiveConfig)(),r=(0,v.toCamel)(t),n=r.toLowerCase(),d=c[r]||c[n]||c[t],i=(0,u.isHostObject)(d)?z(c,d,n,[r,n,t]):d,m=D[r]||D[n];if(m)try{const a=m(s,e);return i&&(i[e]=a),i}catch(a){c.verbose&&console.warn("Error setting",n,"value",s,e,a)}if(!m){const a=i||(c[n]={});return a[e]=s,a}c.verbose&&console.warn("Can not find",n,"method in scratch")},j=(t,s)=>{const e=(0,v.getActiveConfig)(),c=t.toLowerCase();return(0,u.isHostObject)(s)?((0,u.parkHostObject)(e,c,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",c,"design-system family"),e[c]||e[t]):(Object.keys(s).sort((n,d)=>{const i=(0,T.isObject)(s[n])||(0,T.isArray)(s[n])?1:0,m=(0,T.isObject)(s[d])||(0,T.isArray)(s[d])?1:0;return i-m}).forEach(n=>{try{return M(c,s[n],n)}catch(d){e.verbose&&console.warn("Error setting",c,"value",s[n],n,d)}}),e[c]||e[t])},B=(t,s)=>{const e=s||(0,v.getActiveConfig)();e.globalTheme=t;const r=(0,u.resolveConfigDocument)(e)||(typeof document<"u"?document:null),n=r&&r.defaultView||(typeof window<"u"?window:null);if(r){const i=e.themeRoot||r.documentElement;if(t&&t!=="auto")i.setAttribute("data-theme",t),e.resolvedTheme=t,t==="dark"||t==="light"?i.style.colorScheme=t:i.style.colorScheme="light dark";else if(n&&n.matchMedia){const a=p=>{const S=p.matches?"dark":"light";i.setAttribute("data-theme",S),e.resolvedTheme=S},h=n.matchMedia("(prefers-color-scheme: dark)");if(a(h),i.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=a;try{h.addEventListener("change",a)}catch{h.addListener(a)}}}else i.setAttribute("data-theme","light"),e.resolvedTheme="light",i.style.colorScheme="light"}const d=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const i in e.cssVars)i.startsWith(d)&&delete e.cssVars[i];for(const i in e.cssMediaVars)delete e.cssMediaVars[i];if(r&&e.cssVars){const i=e.scopeSelector||":root",m=r.styleSheets;for(let a=0;a<m.length;a++)try{const h=m[a].cssRules;for(let p=0;p<h.length;p++)if(h[p].selectorText===i){for(const S in e.cssVars)h[p].style.setProperty(S,e.cssVars[S]);return e}}catch{}}return e},U={},J=(t,s=U)=>{let e=s.config||(0,v.getActiveConfig)();const{version:c,verbose:r,useVariable:n,useReset:d,useSvgSprite:i,useFontImport:m,useIconSprite:a,globalTheme:h,themeRoot:p,useDocumentTheme:S,useDefaultConfig:E,semanticIcons:R,hoverMedia:A,files:L,assets:F,...y}=t;s.newConfig&&(e=(0,v.setActiveConfig)(s.newConfig)),(0,u.isDomDocument)(y.document)&&(e.__domDocument=y.document,delete y.document),(0,u.isDomDocument)(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),L!==void 0&&(e.files=L),F!==void 0&&(e.assets=F),r!==void 0&&(e.verbose=r),n!==void 0&&(e.useVariable=n),d!==void 0&&(e.useReset=d),m!==void 0&&(e.useFontImport=m),i!==void 0&&(e.useSvgSprite=i),a!==void 0&&(e.useIconSprite=a),S!==void 0&&(e.useDocumentTheme=S),h!==void 0&&(e.globalTheme=h),p!==void 0&&(e.themeRoot=p),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),E!==void 0&&(e.useDefaultConfig=E),R!==void 0&&(e.semanticIcons=R),A!==void 0&&(e.hoverMedia=A),e.verbose&&console.log(e);const w=(0,u.resolveConfigDocument)(e)||(typeof document<"u"?document:null),C=w&&w.defaultView||(typeof window<"u"?window:null),b=w&&(e.themeRoot||w.documentElement);if(b&&typeof b.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")b.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,e.globalTheme==="dark"||e.globalTheme==="light"?b.style.colorScheme=e.globalTheme:b.style.colorScheme="light dark";else if(C&&C.matchMedia){const g=P=>{const k=P.matches?"dark":"light";b.setAttribute("data-theme",k),e.resolvedTheme=k},V=C.matchMedia("(prefers-color-scheme: dark)");if(g(V),b.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=g;try{V.addEventListener("change",g)}catch{V.addListener(g)}}}else b.setAttribute("data-theme","light"),e.resolvedTheme="light",b.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const _=Object.keys(y).filter(l=>!l.startsWith("__")),I=new Set(_);if(_.forEach(l=>{const g=l.toLowerCase();g!==l&&I.has(g)&&(0,T.deepMerge)(y[g],y[l])}),_.map(l=>{const g=l.toLowerCase();if(!(g!==l&&I.has(g)))return j(l,y[l])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),y.typography)try{(0,o.applyTypographySequence)()}catch(l){e.verbose&&console.warn("Error applying typography sequence",l)}if(y.spacing)try{(0,o.applySpacingSequence)()}catch(l){e.verbose&&console.warn("Error applying spacing sequence",l)}if(y.timing)try{(0,o.applyTimingSequence)()}catch(l){e.verbose&&console.warn("Error applying timing sequence",l)}(0,o.applyDocument)();const O=(0,o.applyReset)();return O&&(e.reset=O),e};
@@ -1 +1 @@
1
- "use strict";var w=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var q=(r,s)=>{for(var d in s)w(r,d,{get:s[d],enumerable:!0})},O=(r,s,d,e)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of j(s))!L.call(r,u)&&u!==d&&w(r,u,{get:()=>s[u],enumerable:!(e=T(s,u))||e.enumerable});return r};var _=r=>O(w({},"__esModule",{value:!0}),r);var Q={};q(Q,{STANDARD_SCHEME_QUERIES:()=>P,getColor:()=>C,getMediaColor:()=>H,setAdaptiveSchemeVar:()=>E,setColor:()=>M,setGradient:()=>D});module.exports=_(Q);var a=require("@symbo.ls/utils"),x=require("../factory.js"),b=require("../utils/index.js");const P={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},C=(r,s,d)=>{const e=d||(0,x.getActiveConfig)();if(!(0,a.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,b.isCSSVar)(r))return`var(${r})`;s&&r[s]&&(r=r[s]);let u,f,o;if((0,a.isArray)(r))[u,f,o]=r;else{const n=(0,b.parseColorToken)(r);if(!n){const{color:V,gradient:A}=e;let $=A[r]||V[r];return $?(s&&$[s]&&($=$[s]),e.useVariable?`var(${$.var})`:$.value):r}if(n.passthrough)return n.passthrough;if(n.cssVar)return`var(${n.cssVar})`;u=n.name,f=n.alpha,o=n.tone}const{color:g,gradient:h}=e;let t=g[u]||h[u];if(!t)return e.verbose&&console.warn("Can't find color ",u),r;if(s)if(t[s]!==void 0)t=t[s];else if((0,a.isArray)(t)){const n=s.charCodeAt(0)===64?s.slice(1):s;n==="dark"?t=t[1]!==void 0?t[1]:t[0]:(n!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",s),t=t[0])}else e.verbose&&console.warn(r," - does not have ",s);if((0,a.isString)(t))return C(t,null,d);let l=t.rgb;if(!l){const n=e.useVariable?`var(${t.var})`:t.value;if((f||o)&&n){const V=f!==void 0?f:1;if(!o)return`rgb(from ${n} r g b / ${V})`;if(o.charCodeAt(0)===43||o.charCodeAt(0)===45){const $=parseFloat(o),c=$<0?"-":"+",i=Math.abs($);return`rgb(from ${n} calc(r ${c} ${i}) calc(g ${c} ${i}) calc(b ${c} ${i}) / ${V})`}return`hsl(from ${n} h s ${o}% / ${V})`}return n}return o&&!t[o]&&(l=(0,b.getRgbTone)(l,o),t[o]={rgb:l,var:`${t.var}-${o}`}),t[o]&&(l=t[o].rgb),f?`rgba(${l}, ${f})`:o?`rgba(${l}, 1)`:e.useVariable?`var(${t.var})`:`rgb(${l})`},H=(r,s,d)=>{const e=d||(0,x.getActiveConfig)();if(s||(s=e.globalTheme==="auto"?null:e.globalTheme),!(0,a.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,b.isCSSVar)(r))return`var(${r})`;let u,f,o;if((0,a.isArray)(r))u=r[0];else{const n=(0,b.parseColorToken)(r);if(n){if(n.passthrough)return n.passthrough;if(n.cssVar)return`var(${n.cssVar})`;u=n.name,f=n.alpha,o=n.tone}else u=r}const{color:g,gradient:h}=e,t=g[u]||h[u],l=(0,a.isObject)(t);if(l&&t.value)return C(r,`@${s}`,d);if(l){if(e.useVariable&&t.var)return f||o?C(r,null,d):`var(${t.var})`;if(s)return C(r,`@${s}`,d);{const n={};for(const V in t){if(V.charCodeAt(0)!==64)continue;const A=V.slice(1),$=e.media&&e.media[A]||P[A];if(!$)continue;const c="@media "+($==="print"?`${$}`:`screen and ${$}`);n[c]=C(r,V,d)}return n}}else return e.verbose&&console.warn("Can't find color",r),r},E=(r,s,d,e)=>{const f=`--${e.varPrefix?e.varPrefix+"-":""}${s}-${d}`;let o;const g={};for(const h in r){if(h.charCodeAt(0)!==64)continue;const t=h.slice(1),l=r[h],n=l&&(l.value||l);!n||typeof n!="string"||(g[t]=n,(t==="light"||o===void 0)&&(o=n))}if(o!==void 0){e.cssVars[f]=o,e.cssMediaVars||(e.cssMediaVars={});for(const h in g){const t=`[data-theme="${h}"]`;if(e.cssMediaVars[t]||(e.cssMediaVars[t]={}),e.cssMediaVars[t][f]=g[h],h==="light"||h==="dark"){const l=`@media (prefers-color-scheme: ${h})`;e.cssMediaVars[l]||(e.cssMediaVars[l]={}),e.cssMediaVars[l][f]=g[h]}}return r.var=f,f}},M=(r,s,d)=>{const e=(0,x.getActiveConfig)();if((0,a.isObject)(r)&&r.value!==void 0&&(r.rgb!==void 0||r.var!==void 0))return e.useVariable&&r.var&&(e.cssVars[r.var]=r.value),r;if((0,a.isString)(r)&&(0,b.isCSSVar)(r)){const c=r.slice(2);if(r=C(c),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const i=c.split(" ");let p=e.color[i[0]];if(p&&!p.value&&!p.rgb&&((0,a.isString)(p)||(0,a.isArray)(p)||(0,a.isObject)(p))&&(e.color[i[0]]=M(p,i[0]),p=e.color[i[0]]),p&&p.value){let m=p.rgb;const S=i[1]!==void 0?i[1]:"1",R=i[2];R&&(m=(0,b.getRgbTone)(m,R)),r=`rgba(${m}, ${S})`}else{const m=i[2],S=i[1]!==void 0?i[1]:"1";if(m)try{const R=(0,b.colorStringToRgbaArray)(i[0]);R&&R.length>=3?r=`rgba(${(0,b.getRgbTone)(R.slice(0,3).join(", "),m)}, ${S})`:r=i[0]}catch{r=i[0]}else r=i[0]}}}if((0,a.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,a.isObject)(r)){const c={};for(const i in r)i!=="var"&&(c[i]=M(r[i],s,i.slice(0,1)==="@"?i.slice(1):i));return e.useVariable&&E(c,"color",s,e),c}const f=`--${e.varPrefix?e.varPrefix+"-":""}color-${s}`+(d?`-${d}`:"");let o=r.value||r;if((0,a.isString)(o)&&!o.includes("(")&&!o.startsWith("#")){const c=(0,b.parseColorToken)(o);if(c&&c.name&&!c.passthrough&&!c.cssVar){const i=e.color[c.name];i&&!i.value&&!i.rgb&&((0,a.isString)(i)||(0,a.isArray)(i)||(0,a.isObject)(i))&&(e.color[c.name]=M(i,c.name));const p=e.color[c.name];if(p&&p.rgb){let m=p.rgb;c.tone&&(m=(0,b.getRgbTone)(m,c.tone));const S=c.alpha?parseFloat(c.alpha):1;o=`rgba(${m}, ${S})`}}}const g=(0,b.colorStringToRgbaArray)(o),[h,t,l,n=1]=g,V=parseFloat(n.toFixed(2)),A=`${h}, ${t}, ${l}`,$=`rgba(${A}, ${V})`;return e.useVariable&&(e.cssVars[f]=$),{var:f,rgb:A,alpha:V,value:$}},D=(r,s,d)=>{const e=(0,x.getActiveConfig)();if((0,a.isObject)(r)&&r.value!==void 0&&r.var!==void 0)return e.useVariable&&(e.cssVars[r.var]=r.value),r;if((0,a.isString)(r)&&(0,b.isCSSVar)(r)&&(r=C(r.slice(2))),(0,a.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,a.isObject)(r)){const o={};for(const g in r)g!=="var"&&(o[g]=D(r[g],s,g.slice(0,1)==="@"?g.slice(1):g));return e.useVariable&&E(o,"gradient",s,e),o}const f=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${s}`+(d?`-${d}`:"");return e.useVariable&&(e.cssVars[f]=r.value||r),{var:f,value:r.value||r}};
1
+ "use strict";var w=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var F=(r,t)=>{for(var g in t)w(r,g,{get:t[g],enumerable:!0})},q=(r,t,g,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of O(t))!j.call(r,a)&&a!==g&&w(r,a,{get:()=>t[a],enumerable:!(e=L(t,a))||e.enumerable});return r};var _=r=>q(w({},"__esModule",{value:!0}),r);var N={};F(N,{STANDARD_SCHEME_QUERIES:()=>P,getColor:()=>A,getMediaColor:()=>H,resolveColorRgb:()=>D,setAdaptiveSchemeVar:()=>E,setColor:()=>M,setGradient:()=>T});module.exports=_(N);var d=require("@symbo.ls/utils"),S=require("../factory.js"),h=require("../utils/index.js");const P={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},A=(r,t,g)=>{const e=g||(0,S.getActiveConfig)();if(!(0,d.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,h.isCSSVar)(r))return`var(${r})`;t&&r[t]&&(r=r[t]);let a,l,o;if((0,d.isArray)(r))[a,l,o]=r;else{const s=(0,h.parseColorToken)(r);if(!s){const{color:i,gradient:C}=e;let $=C[r]||i[r];return $?(t&&$[t]&&($=$[t]),e.useVariable?`var(${$.var})`:$.value):r}if(s.passthrough)return s.passthrough;if(s.cssVar)return`var(${s.cssVar})`;a=s.name,l=s.alpha,o=s.tone}const{color:b,gradient:f}=e;let n=b[a]||f[a];if(!n)return e.verbose&&console.warn("Can't find color ",a),r;if(t)if(n[t]!==void 0)n=n[t];else if((0,d.isArray)(n)){const s=t.charCodeAt(0)===64?t.slice(1):t;s==="dark"?n=n[1]!==void 0?n[1]:n[0]:(s!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",t),n=n[0])}else e.verbose&&console.warn(r," - does not have ",t);if((0,d.isString)(n))return A(n,null,g);let p=n.rgb;if(!p){const s=e.useVariable?`var(${n.var})`:n.value;if((l||o)&&s){const i=l!==void 0?l:1;if(!o)return`rgb(from ${s} r g b / ${i})`;if(o.charCodeAt(0)===43||o.charCodeAt(0)===45){const $=parseFloat(o),u=$<0?"-":"+",c=Math.abs($);return`rgb(from ${s} calc(r ${u} ${c}) calc(g ${u} ${c}) calc(b ${u} ${c}) / ${i})`}return`hsl(from ${s} h s ${o}% / ${i})`}return s}return o&&!n[o]&&(p=(0,h.getRgbTone)(p,o),n[o]={rgb:p,var:`${n.var}-${o}`}),n[o]&&(p=n[o].rgb),l?`rgba(${p}, ${l})`:o?`rgba(${p}, 1)`:e.useVariable?`var(${n.var})`:`rgb(${p})`},D=(r,t,g)=>{const e=t||(0,S.getActiveConfig)();if(!(0,d.isString)(r))return null;const a=(0,h.parseColorToken)(r);if(a){if(a.passthrough){const i=(0,h.colorStringToRgbaArray)(a.passthrough);return i&&i.length>=3?{rgb:[i[0],i[1],i[2]],alpha:i[3]!==void 0?i[3]:1}:null}if(a.cssVar)return null}const l=a?a.name:r,{color:o,gradient:b}=e;let f=o[l]||b[l];if(!f){const i=(0,h.colorStringToRgbaArray)(r);return!i||i.length<3||i[0]===0&&i[1]===0&&i[2]===0&&i[3]===0&&r.toLowerCase()!=="transparent"?null:{rgb:[i[0],i[1],i[2]],alpha:i[3]!==void 0?i[3]:1}}if((0,d.isString)(f))return D(f,e,g);if(f.rgb===void 0&&(0,d.isObject)(f)){const i=`@${g||"light"}`;f=f[i]!==void 0?f[i]:f["@light"]}if(!f||f.rgb===void 0)return null;let n=f.rgb;a&&a.tone&&(n=(0,h.getRgbTone)(n,a.tone));const p=(0,d.isString)(n)?n.split(",").map(i=>parseFloat(i.trim())):n,s=a&&a.alpha!==void 0?parseFloat(a.alpha):f.alpha!==void 0?f.alpha:1;return{rgb:p,alpha:s}},H=(r,t,g)=>{const e=g||(0,S.getActiveConfig)();if(t||(t=e.globalTheme==="auto"?null:e.globalTheme),!(0,d.isString)(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if((0,h.isCSSVar)(r))return`var(${r})`;let a,l,o;if((0,d.isArray)(r))a=r[0];else{const s=(0,h.parseColorToken)(r);if(s){if(s.passthrough)return s.passthrough;if(s.cssVar)return`var(${s.cssVar})`;a=s.name,l=s.alpha,o=s.tone}else a=r}const{color:b,gradient:f}=e,n=b[a]||f[a],p=(0,d.isObject)(n);if(p&&n.value)return A(r,`@${t}`,g);if(p){if(e.useVariable&&n.var)return l||o?A(r,null,g):`var(${n.var})`;if(t)return A(r,`@${t}`,g);{const s={};for(const i in n){if(i.charCodeAt(0)!==64)continue;const C=i.slice(1),$=e.media&&e.media[C]||P[C];if(!$)continue;const u="@media "+($==="print"?`${$}`:`screen and ${$}`);s[u]=A(r,i,g)}return s}}else return e.verbose&&console.warn("Can't find color",r),r},E=(r,t,g,e)=>{const l=`--${e.varPrefix?e.varPrefix+"-":""}${t}-${g}`;let o;const b={};for(const f in r){if(f.charCodeAt(0)!==64)continue;const n=f.slice(1),p=r[f],s=p&&(p.value||p);!s||typeof s!="string"||(b[n]=s,(n==="light"||o===void 0)&&(o=s))}if(o!==void 0){e.cssVars[l]=o,e.cssMediaVars||(e.cssMediaVars={});for(const f in b){const n=`[data-theme="${f}"]`;if(e.cssMediaVars[n]||(e.cssMediaVars[n]={}),e.cssMediaVars[n][l]=b[f],f==="light"||f==="dark"){const p=`@media (prefers-color-scheme: ${f})`;e.cssMediaVars[p]||(e.cssMediaVars[p]={}),e.cssMediaVars[p][l]=b[f]}}return r.var=l,l}},M=(r,t,g)=>{const e=(0,S.getActiveConfig)();if((0,d.isObject)(r)&&r.value!==void 0&&(r.rgb!==void 0||r.var!==void 0))return e.useVariable&&r.var&&(e.cssVars[r.var]=r.value),r;if((0,d.isString)(r)&&(0,h.isCSSVar)(r)){const u=r.slice(2);if(r=A(u),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const c=u.split(" ");let m=e.color[c[0]];if(m&&!m.value&&!m.rgb&&((0,d.isString)(m)||(0,d.isArray)(m)||(0,d.isObject)(m))&&(e.color[c[0]]=M(m,c[0]),m=e.color[c[0]]),m&&m.value){let V=m.rgb;const x=c[1]!==void 0?c[1]:"1",R=c[2];R&&(V=(0,h.getRgbTone)(V,R)),r=`rgba(${V}, ${x})`}else{const V=c[2],x=c[1]!==void 0?c[1]:"1";if(V)try{const R=(0,h.colorStringToRgbaArray)(c[0]);R&&R.length>=3?r=`rgba(${(0,h.getRgbTone)(R.slice(0,3).join(", "),V)}, ${x})`:r=c[0]}catch{r=c[0]}else r=c[0]}}}if((0,d.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,d.isObject)(r)){const u={};for(const c in r)c!=="var"&&(u[c]=M(r[c],t,c.slice(0,1)==="@"?c.slice(1):c));return e.useVariable&&E(u,"color",t,e),u}const l=`--${e.varPrefix?e.varPrefix+"-":""}color-${t}`+(g?`-${g}`:"");let o=r.value||r;if((0,d.isString)(o)&&!o.includes("(")&&!o.startsWith("#")){const u=(0,h.parseColorToken)(o);if(u&&u.name&&!u.passthrough&&!u.cssVar){const c=e.color[u.name];c&&!c.value&&!c.rgb&&((0,d.isString)(c)||(0,d.isArray)(c)||(0,d.isObject)(c))&&(e.color[u.name]=M(c,u.name));const m=e.color[u.name];if(m&&m.rgb){let V=m.rgb;u.tone&&(V=(0,h.getRgbTone)(V,u.tone));const x=u.alpha?parseFloat(u.alpha):1;o=`rgba(${V}, ${x})`}}}const b=(0,h.colorStringToRgbaArray)(o),[f,n,p,s=1]=b,i=parseFloat(s.toFixed(2)),C=`${f}, ${n}, ${p}`,$=`rgba(${C}, ${i})`;return e.useVariable&&(e.cssVars[l]=$),{var:l,rgb:C,alpha:i,value:$}},T=(r,t,g)=>{const e=(0,S.getActiveConfig)();if((0,d.isObject)(r)&&r.value!==void 0&&r.var!==void 0)return e.useVariable&&(e.cssVars[r.var]=r.value),r;if((0,d.isString)(r)&&(0,h.isCSSVar)(r)&&(r=A(r.slice(2))),(0,d.isArray)(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),(0,d.isObject)(r)){const o={};for(const b in r)b!=="var"&&(o[b]=T(r[b],t,b.slice(0,1)==="@"?b.slice(1):b));return e.useVariable&&E(o,"gradient",t,e),o}const l=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${t}`+(g?`-${g}`:"");return e.useVariable&&(e.cssVars[l]=r.value||r),{var:l,value:r.value||r}};
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./color.js"),module.exports);o(r,require("./theme.js"),module.exports);o(r,require("./font.js"),module.exports);o(r,require("./typography.js"),module.exports);o(r,require("./spacing.js"),module.exports);o(r,require("./shape.js"),module.exports);o(r,require("./shadow.js"),module.exports);o(r,require("./timing.js"),module.exports);o(r,require("./document.js"),module.exports);o(r,require("./svg.js"),module.exports);o(r,require("./reset.js"),module.exports);
1
+ "use strict";var s=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var p=(e,t,m,x)=>{if(t&&typeof t=="object"||typeof t=="function")for(let f of i(t))!u.call(e,f)&&f!==m&&s(e,f,{get:()=>t[f],enumerable:!(x=c(t,f))||x.enumerable});return e},o=(e,t,m)=>(p(e,t,"default"),m&&p(m,t,"default"));var a=e=>p(s({},"__esModule",{value:!0}),e);var r={};module.exports=a(r);o(r,require("./color.js"),module.exports);o(r,require("./ink.js"),module.exports);o(r,require("./theme.js"),module.exports);o(r,require("./font.js"),module.exports);o(r,require("./typography.js"),module.exports);o(r,require("./spacing.js"),module.exports);o(r,require("./shape.js"),module.exports);o(r,require("./shadow.js"),module.exports);o(r,require("./timing.js"),module.exports);o(r,require("./document.js"),module.exports);o(r,require("./svg.js"),module.exports);o(r,require("./reset.js"),module.exports);
@@ -0,0 +1 @@
1
+ "use strict";var I=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var _=(a,e)=>{for(var i in e)I(a,i,{get:e[i],enumerable:!0})},ee=(a,e,i,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Y(e))!Z.call(a,r)&&r!==i&&I(a,r,{get:()=>e[r],enumerable:!(c=X(e,r))||c.enumerable});return a};var te=a=>ee(I({},"__esModule",{value:!0}),a);var re={};_(re,{getSafeInk:()=>j,getSafeInkInfo:()=>oe});module.exports=te(re);var A=require("@symbo.ls/utils"),D=require("../factory.js"),o=require("../utils/index.js"),g=require("./color.js");const j=(a,e,i={},c)=>{const r=c||(0,D.getActiveConfig)(),{min:F=4.5,large:G=!1,scheme:K,meta:N=!1,maxIterations:V=15}=i,v=G?3:F,u=K||(r.globalTheme&&r.globalTheme!=="auto"?r.globalTheme:"light"),R=(0,A.isString)(e)?e:String(e),b=(0,o.parseColorToken)(a),O=b&&!b.passthrough&&!b.cssVar?b.name:null,h=(t,n)=>N?{value:t,...n}:t;if(O){const t=r.color[`${O}Safe`];if(t){const n=`${R}@${u}`,s=t[n]!==void 0?t[n]:t[R];if(s!==void 0){const W=s&&s.rgb!==void 0?r.useVariable&&s.var?`var(${s.var})`:s.value:(0,g.getColor)(s,null,r);return h(W,{ratio:null,deviation:0,derived:!1,overridden:!0})}}}const k=(0,g.getColor)(a,u?`@${u}`:null,r),l=(0,g.resolveColorRgb)(a,r,u),p=(0,g.resolveColorRgb)(e,r,u);if(!l||!p)return r.verbose&&console.warn("getSafeInk: could not resolve",a,e,"\u2014 returning hue unchanged"),h(k,{ratio:null,deviation:0,derived:!1,overridden:!1,unresolved:!0});const m=(0,o.compositeOverBackdrop)(p.rgb,p.alpha),w=(0,o.compositeOverBackdrop)(l.rgb,l.alpha,m),S=(0,o.contrastRatio)(w,m);if(S>=v-.02)return h(k,{ratio:S,deviation:0,derived:!1,overridden:!1});const[d,B,E]=(0,o.srgbToOklab)(l.rgb),[,H,P]=(0,o.oklabToOklch)([d,B,E]),x=(0,o.relativeLuminance)(m)>.5,q=x?d:1-d,y=t=>{const n=x?d-t:d+t,s=Math.max(0,Math.min(1,n));return{rgb:(0,o.oklchToGamutSafeSrgb)(s,H,P),L:s}},C=t=>{const{rgb:n}=y(t),s=(0,o.compositeOverBackdrop)(n,l.alpha,m);return(0,o.contrastRatio)(s,m)};let L=0,f=q;const M=C(f)>=v;if(M)for(let t=0;t<V;t++){const n=(L+f)/2;C(n)>=v?f=n:L=n}else L=f;const{rgb:z,L:J}=y(f),$=z.map(t=>Math.round(t)),Q=C(f),T=l.alpha<1?`rgba(${$.join(", ")}, ${l.alpha})`:`rgb(${$.join(", ")})`,U=Math.abs(J-d)*100;return h(T,{rgb:$,ratio:Q,startRatio:S,deviation:U,derived:!0,overridden:!1,reachable:M})},oe=(a,e,i={},c)=>j(a,e,{...i,meta:!0},c);
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var S=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!M.call(t,n)&&n!==r&&c(t,n,{get:()=>e[n],enumerable:!(s=R(e,n))||s.enumerable});return t};var I=t=>$(c({},"__esModule",{value:!0}),t);var X={};S(X,{CSS_NATIVE_COLOR_REGEX:()=>b,changeLightness:()=>_,colorStringToRgbaArray:()=>p,getColorShade:()=>m,getRgbTone:()=>G,hexToRgb:()=>E,hexToRgbArray:()=>h,hexToRgba:()=>A,hslToRgb:()=>g,isCSSVar:()=>d,isResolvedColor:()=>V,mixTwoColors:()=>O,mixTwoRgb:()=>F,mixTwoRgba:()=>x,opacify:()=>H,parseColorToken:()=>j,rgbArrayToHex:()=>u,rgbToHSL:()=>f,rgbToHex:()=>L,splitTopLevelCommas:()=>z});module.exports=I(X);var i=require("@symbo.ls/utils");const p=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&i.document&&i.window){const e=i.document.body.appendChild(i.document.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){i.document.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return i.document.body.removeChild(e),[0,0,0,0];t=i.window.getComputedStyle(e).color,i.document.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},O=(t,e,r=.5)=>(t=p(t),e=p(e),x(t,e,r)),E=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgb(${r},${s},${n})`},h=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return[r,s,n]},L=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),u=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgba(${r},${s},${n},${e})`},F=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},_=(t,e)=>{const[r,s,n]=e,a=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,a]},f=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),a=1-Math.abs(s+s-n-1),o=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(o<0?o+6:o),a?n/a:0,(s+s-n)/2]},g=(t,e,r,s=e*Math.min(r,1-r),n=(a,o=(a+t/30)%12)=>r-s*Math.max(Math.min(o-3,9-o,1),-1))=>[n(0),n(8),n(4)],m=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let a=(r&255)+e;return a>255?a=255:a<0&&(a=0),((a|n<<8|s<<16)+16777216).toString(16).slice(1)},x=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const a=n===3?o=>o:Math.round;s[n]=a(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},H=(t,e)=>{const r=p(t);if(!r){(0,i.isNotProduction)()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},d=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,b=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,N=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,j=t=>{if(!(0,i.isString)(t))return null;if(b.test(t))return{passthrough:t};if(d(t))return{cssVar:t};const e=t.match(N);if(!e)return null;const[,r,s,n]=e,a=s!==void 0?`0.${s}`:void 0,o=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:a,tone:o}},V=t=>(0,i.isString)(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),z=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},G=(t,e)=>{(0,i.isString)(t)&&t.includes("rgb")&&(t=p(t).join(", ")),(0,i.isString)(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),(0,i.isNumber)(e)&&(e+="");const r=u(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=m(r,parseFloat(e));return h(n).join(", ")}else{const[n,a,o]=t,[l,w]=f(n/255,a/255,o/255),C=Math.max(0,Math.min(100,parseFloat(e)))/100;return g(l,w,C).map(T=>Math.round(Math.max(0,Math.min(1,T))*255)).join(", ")}};
1
+ "use strict";var x=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var E=(t,n)=>{for(var r in n)x(t,r,{get:n[r],enumerable:!0})},F=(t,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of L(n))!k.call(t,e)&&e!==r&&x(t,e,{get:()=>n[e],enumerable:!(s=_(n,e))||s.enumerable});return t};var A=t=>F(x({},"__esModule",{value:!0}),t);var B={};E(B,{CSS_NATIVE_COLOR_REGEX:()=>R,changeLightness:()=>V,colorStringToRgbaArray:()=>m,compositeOverBackdrop:()=>W,contrastRatio:()=>K,getColorShade:()=>w,getRgbTone:()=>Y,hexToRgb:()=>H,hexToRgbArray:()=>b,hexToRgba:()=>j,hslToRgb:()=>T,isCSSVar:()=>S,isResolvedColor:()=>q,linearChannelToSrgb:()=>$,mixTwoColors:()=>G,mixTwoRgb:()=>P,mixTwoRgba:()=>C,oklabToLinearSrgb:()=>I,oklabToOklch:()=>Q,oklchToGamutSafeSrgb:()=>U,oklchToOklab:()=>O,opacify:()=>z,parseColorToken:()=>Z,relativeLuminance:()=>g,rgbArrayToHex:()=>d,rgbToHSL:()=>M,rgbToHex:()=>N,splitTopLevelCommas:()=>D,srgbChannelToLinear:()=>y,srgbToOklab:()=>J,toLinearChannel:()=>f});module.exports=A(B);var i=require("@symbo.ls/utils");const m=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&i.document&&i.window){const n=i.document.body.appendChild(i.document.createElement("fictum")),r="rgb(1, 2, 3)";if(n.style.color=r,n.style.color!==r){i.document.body.removeChild(n);return}if(n.style.color=t,n.style.color===r||n.style.color==="")return i.document.body.removeChild(n),[0,0,0,0];t=i.window.getComputedStyle(n).color,i.document.body.removeChild(n)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(n=>+n)):[0,0,0,0]},G=(t,n,r=.5)=>(t=m(t),n=m(n),C(t,n,r)),H=(t,n=1)=>{const[r,s,e]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgb(${r},${s},${e})`},b=(t,n=1)=>{const[r,s,e]=t.match(/\w\w/g).map(o=>parseInt(o,16));return[r,s,e]},N=(t,n,r)=>"#"+(1<<24|t<<16|n<<8|r).toString(16).slice(1),d=([t,n,r])=>((1<<24)+(t<<16)+(n<<8)+r).toString(16).slice(1),j=(t,n=1)=>{const[r,s,e]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgba(${r},${s},${e},${n})`},P=(t,n,r=.5)=>{const s=[];for(let e=0;e<3;e++)s[e]=~~(t[e]+(n[e]-t[e])*r);return`rgb(${s})`},V=(t,n)=>{const[r,s,e]=n,o=Math.max(0,Math.min(100,e+parseFloat(t)));return[r,s,o]},M=(t,n,r)=>{const s=Math.max(t,n,r),e=s-Math.min(t,n,r),o=1-Math.abs(s+s-e-1),a=e&&(s==t?(n-r)/e:s==n?2+(r-t)/e:4+(t-n)/e);return[60*(a<0?a+6:a),o?e/o:0,(s+s-e)/2]},T=(t,n,r,s=n*Math.min(r,1-r),e=(o,a=(o+t/30)%12)=>r-s*Math.max(Math.min(a-3,9-a,1),-1))=>[e(0),e(8),e(4)],w=(t,n)=>{const r=parseInt(t,16);let s=(r>>16)+n;s>255?s=255:s<0&&(s=0);let e=(r>>8&255)+n;e>255?e=255:e<0&&(e=0);let o=(r&255)+n;return o>255?o=255:o<0&&(o=0),((o|e<<8|s<<16)+16777216).toString(16).slice(1)},C=(t,n,r=.5)=>{const s=[];for(let e=0;e<4;e++){const o=e===3?a=>a:Math.round;s[e]=o(t[e]+(n[e]-t[e])*r)}return`rgba(${s})`},z=(t,n)=>{const r=m(t);if(!r){(0,i.isNotProduction)()&&console.warn(t+" color is not rgba");return}return r[3]=n,`rgba(${r})`},S=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,R=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,X=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,Z=t=>{if(!(0,i.isString)(t))return null;if(R.test(t))return{passthrough:t};if(S(t))return{cssVar:t};const n=t.match(X);if(!n)return null;const[,r,s,e]=n,o=s!==void 0?`0.${s}`:void 0,a=e&&e[0]==="="?e.slice(1):e;return{name:r,alpha:o,tone:a}},q=t=>(0,i.isString)(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),D=t=>{const n=[];let r="",s=0;for(const e of t){if(e==="("?s+=1:e===")"&&s>0&&(s-=1),e===","&&s===0){n.push(r),r="";continue}r+=e}return(r.length||!n.length)&&n.push(r),n},f=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),g=t=>.2126*f(t[0])+.7152*f(t[1])+.0722*f(t[2]),K=(t,n)=>{const r=g(t)+.05,s=g(n)+.05;return r>s?r/s:s/r},y=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),$=t=>(t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055)*255,J=([t,n,r])=>{const[s,e,o]=[t,n,r].map(y),a=.4122214708*s+.5363325363*e+.0514459929*o,c=.2119034982*s+.6806995451*e+.1073969566*o,h=.0883024619*s+.2817188376*e+.6299787005*o,p=Math.cbrt(a),u=Math.cbrt(c),l=Math.cbrt(h);return[.2104542553*p+.793617785*u-.0040720468*l,1.9779984951*p-2.428592205*u+.4505937099*l,.0259040371*p+.7827717662*u-.808675766*l]},I=([t,n,r])=>{const s=t+.3963377774*n+.2158037573*r,e=t-.1055613458*n-.0638541728*r,o=t-.0894841775*n-1.291485548*r,a=s**3,c=e**3,h=o**3;return[4.0767416621*a-3.3077115913*c+.2309699292*h,-1.2684380046*a+2.6097574011*c-.3413193965*h,-.0041960863*a-.7034186147*c+1.707614701*h]},Q=([t,n,r])=>{let s=Math.atan2(r,n)*180/Math.PI;return s<0&&(s+=360),[t,Math.sqrt(n*n+r*r),s]},O=([t,n,r])=>{const s=r*Math.PI/180;return[t,n*Math.cos(s),n*Math.sin(s)]},U=(t,n,r,s=24)=>{const e=c=>I(O([t,c,r])),o=c=>c.every(h=>h>=-1e-4&&h<=1.0001);let a=e(n);if(!o(a)){let c=0,h=n;for(let p=0;p<s;p++){const u=(c+h)/2;o(e(u))?c=u:h=u}a=e(c)}return a.map(c=>$(Math.max(0,Math.min(1,c))))},W=(t,n=1,r=[255,255,255])=>n>=1?t:t.map((s,e)=>s*n+r[e]*(1-n)),Y=(t,n)=>{(0,i.isString)(t)&&t.includes("rgb")&&(t=m(t).join(", ")),(0,i.isString)(t)&&(t=t.split(",").map(e=>parseFloat(e.trim()))),(0,i.isNumber)(n)&&(n+="");const r=d(t),s=n.slice(0,1);if(s==="-"||s==="+"){const e=w(r,parseFloat(n));return b(e).join(", ")}else{const[e,o,a]=t,[c,h]=M(e/255,o/255,a/255),p=Math.max(0,Math.min(100,parseFloat(n)))/100;return T(c,h,p).map(l=>Math.round(Math.max(0,Math.min(1,l))*255)).join(", ")}};
@@ -1 +1 @@
1
- import{deepClone as _,deepMerge as S,isDefined as l,isObject as C}from"@symbo.ls/utils";import{createSignal as v}from"@symbo.ls/signal";import*as A from"./defaultConfig/index.js";const b={},h={},f=A,u={},T=e=>e.replace(/_([a-z])/g,(o,t)=>t.toUpperCase());for(const e in f){const o=e.toLowerCase();u[o]=f[e];const t=T(o);t!==o&&(u[t]=f[e]),o!==e&&(u[e]=f[e])}const p={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:b,cssMediaVars:h,CSS_VARS:b,CSS_MEDIA_VARS:h,_scratchConfig:!0,...u},g=(e,o)=>{if(!e)return null;if(e.__globalThemeSignal)return l(o)&&e.__globalThemeSignal.set(o),e.__globalThemeSignal;const t=l(o)?o:e.globalTheme,s=v(l(t)?t:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(n){s.set(n)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},I=e=>e?g(e):null;g(p);const m=_(p),a={active:"0",0:p},P=e=>(l(e)&&(a.active=e),a[e||a.active]),i=[],R=e=>{e&&e._scratchConfig&&i.push(e)},M=()=>{i.pop()},d=e=>i.length?i[i.length-1]:a[e||a.active]||p,L=e=>{if(C(e))return a.active="1",a[1]=S(e,_(m)),g(a[1]),e},x=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],O=["useVariable","globalTheme","verbose"],V=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],y=e=>{for(const o of V){let t;for(const s of o){const n=e[s];C(n)&&(t=t?S(n,t):n)}if(t)for(const s of o)C(e[s])&&(e[s]=t)}},j=(e,o,{cleanBase:t=!1}={})=>{const s=t?null:d(),n=_(!t&&s&&s._scratchConfig?s:m);for(const c of x)delete n[c];for(const c of O)Object.prototype.hasOwnProperty.call(m,c)?n[c]=m[c]:delete n[c];const r=S(o||{},n);return r.cssVars={},r.cssMediaVars={},r.CSS_VARS=r.cssVars,r.CSS_MEDIA_VARS=r.cssMediaVars,r._scratchConfig=!0,y(r),g(r),e&&(a[e]=r),r};export{p as CONFIG,a as FACTORY,P as activateConfig,j as createConfig,h as cssMediaVars,b as cssVars,g as defineThemeSignal,d as getActiveConfig,I as getThemeSignal,M as popConfig,R as pushConfig,L as setActiveConfig,T as toCamel};
1
+ import{deepClone as S,deepMerge as b,isDefined as l,isObject as h}from"@symbo.ls/utils";import{createSignal as v}from"@symbo.ls/signal";import*as T from"./defaultConfig/index.js";const d={},C={},f=T,p={},x=e=>e.replace(/_([a-z])/g,(t,o)=>o.toUpperCase());for(const e in f){const t=e.toLowerCase();p[t]=f[e];const o=x(t);o!==t&&(p[o]=f[e]),t!==e&&(p[e]=f[e])}const i={verbose:!1,useVariable:!0,useReset:!0,globalTheme:"auto",cssVars:d,cssMediaVars:C,CSS_VARS:d,CSS_MEDIA_VARS:C,_scratchConfig:!0,...p},m=(e,t)=>{if(!e)return null;if(e.__globalThemeSignal)return l(t)&&e.__globalThemeSignal.set(t),e.__globalThemeSignal;const o=l(t)?t:e.globalTheme,s=v(l(o)?o:"auto");return Object.defineProperty(e,"globalTheme",{get(){return s.get()},set(r){s.set(r)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"__globalThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},D=e=>e?m(e):null,g=(e,t)=>{if(!e)return null;if(e.__resolvedThemeSignal)return l(t)&&e.__resolvedThemeSignal.set(t),e.__resolvedThemeSignal;const o=l(t)?t:e.resolvedTheme,s=v(l(o)?o:null);return Object.defineProperty(e,"resolvedTheme",{get(){return s.get()},set(r){s.set(r)},enumerable:!1,configurable:!0}),Object.defineProperty(e,"__resolvedThemeSignal",{value:s,enumerable:!1,configurable:!0,writable:!0}),s},I=e=>e?g(e):null;m(i),g(i);const _=S(i),a={active:"0",0:i},M=e=>(l(e)&&(a.active=e),a[e||a.active]),u=[],j=e=>{e&&e._scratchConfig&&u.push(e)},L=()=>{u.pop()},A=e=>u.length?u[u.length-1]:a[e||a.active]||i,w=e=>{if(h(e))return a.active="1",a[1]=b(e,S(_)),m(a[1]),g(a[1]),e},O=["useReset","useFontImport","useIconSprite","useSvgSprite","useDocumentTheme","useDefaultIcons","useDefaultConfig"],y=["useVariable","globalTheme","verbose"],V=[["fontfamily","fontFamily","font_family"],["fontfamilytypes","fontFamilyTypes"],["semanticicons","semanticIcons"],["svgdata","svgData"]],P=e=>{for(const t of V){let o;for(const s of t){const r=e[s];h(r)&&(o=o?b(r,o):r)}if(o)for(const s of t)h(e[s])&&(e[s]=o)}},G=(e,t,{cleanBase:o=!1}={})=>{const s=o?null:A(),r=S(!o&&s&&s._scratchConfig?s:_);for(const c of O)delete r[c];for(const c of y)Object.prototype.hasOwnProperty.call(_,c)?r[c]=_[c]:delete r[c];const n=b(t||{},r);return n.cssVars={},n.cssMediaVars={},n.CSS_VARS=n.cssVars,n.CSS_MEDIA_VARS=n.cssMediaVars,n._scratchConfig=!0,P(n),m(n),g(n),e&&(a[e]=n),n};export{i as CONFIG,a as FACTORY,M as activateConfig,G as createConfig,C as cssMediaVars,d as cssVars,g as defineResolvedThemeSignal,m as defineThemeSignal,A as getActiveConfig,I as getResolvedThemeSignal,D as getThemeSignal,L as popConfig,j as pushConfig,w as setActiveConfig,x as toCamel};
@@ -1 +1 @@
1
- import{getActiveConfig as b,setActiveConfig as q,toCamel as G}from"./factory.js";import{setColor as W,setGradient as N,setFont as H,setFontFamily as L,setTheme as Y,setSvgIcon as $,setSVG as z,applyTypographySequence as B,applySpacingSequence as U,applyReset as J,applyTimingSequence as K,applyDocument as Q,setShadow as X}from"./system/index.js";import{deepMerge as Z,isObject as F,isArray as I}from"@symbo.ls/utils";import{isDomDocument as O,isHostObject as P,parkHostObject as k,resolveConfigDocument as M}from"./utils/host.js";const ee=(t,s)=>{const e=b(),{cssVars:r}=e,i=s.startsWith("--")?s:`--${s}`;return r[i]=t,t},f=t=>t,j={color:W,gradient:N,font:H,fontFamily:L,fontfamily:L,theme:Y,icons:$,semanticIcons:f,semanticicons:f,svg:z,svgData:f,typography:f,shadow:X,spacing:f,media:f,grid:f,class:f,timing:f,reset:f,unit:f,animation:f,vars:ee,sizes:f,shape:f},te=(t,s,e,r)=>{k(t,e,s);const i={};for(const o of r)t[o]===s&&(t[o]=i);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),i},se=(t,s,e)=>{const r=b(),i=G(t),o=i.toLowerCase(),l=r[i]||r[o]||r[t],n=P(l)?te(r,l,o,[i,o,t]):l,d=j[i]||j[o];if(d)try{const c=d(s,e);return n&&(n[e]=c),n}catch(c){r.verbose&&console.warn("Error setting",o,"value",s,e,c)}if(!d){const c=n||(r[o]={});return c[e]=s,c}r.verbose&&console.warn("Can not find",o,"method in scratch")},oe=(t,s)=>{const e=b(),r=t.toLowerCase();return P(s)?(k(e,r,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",r,"design-system family"),e[r]||e[t]):(Object.keys(s).sort((o,l)=>{const n=F(s[o])||I(s[o])?1:0,d=F(s[l])||I(s[l])?1:0;return n-d}).forEach(o=>{try{return se(r,s[o],o)}catch(l){e.verbose&&console.warn("Error setting",r,"value",s[o],o,l)}}),e[r]||e[t])},de=(t,s)=>{const e=s||b();e.globalTheme=t;const i=M(e)||(typeof document<"u"?document:null),o=i&&i.defaultView||(typeof window<"u"?window:null);if(i){const n=e.themeRoot||i.documentElement;if(t&&t!=="auto")n.setAttribute("data-theme",t),t==="dark"||t==="light"?n.style.colorScheme=t:n.style.colorScheme="light dark";else if(o&&o.matchMedia){const c=h=>{n.setAttribute("data-theme",h.matches?"dark":"light")},m=o.matchMedia("(prefers-color-scheme: dark)");if(c(m),n.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=c;try{m.addEventListener("change",c)}catch{m.addListener(c)}}}else n.setAttribute("data-theme","light"),n.style.colorScheme="light"}const l=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const n in e.cssVars)n.startsWith(l)&&delete e.cssVars[n];for(const n in e.cssMediaVars)delete e.cssMediaVars[n];if(i&&e.cssVars){const n=e.scopeSelector||":root",d=i.styleSheets;for(let c=0;c<d.length;c++)try{const m=d[c].cssRules;for(let h=0;h<m.length;h++)if(m[h].selectorText===n){for(const y in e.cssVars)m[h].style.setProperty(y,e.cssVars[y]);return e}}catch{}}return e},ne={},me=(t,s=ne)=>{let e=s.config||b();const{version:r,verbose:i,useVariable:o,useReset:l,useSvgSprite:n,useFontImport:d,useIconSprite:c,globalTheme:m,themeRoot:h,useDocumentTheme:y,useDefaultConfig:_,semanticIcons:T,hoverMedia:V,files:x,assets:D,...g}=t;s.newConfig&&(e=q(s.newConfig)),O(g.document)&&(e.__domDocument=g.document,delete g.document),O(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),x!==void 0&&(e.files=x),D!==void 0&&(e.assets=D),i!==void 0&&(e.verbose=i),o!==void 0&&(e.useVariable=o),l!==void 0&&(e.useReset=l),d!==void 0&&(e.useFontImport=d),n!==void 0&&(e.useSvgSprite=n),c!==void 0&&(e.useIconSprite=c),y!==void 0&&(e.useDocumentTheme=y),m!==void 0&&(e.globalTheme=m),h!==void 0&&(e.themeRoot=h),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),_!==void 0&&(e.useDefaultConfig=_),T!==void 0&&(e.semanticIcons=T),V!==void 0&&(e.hoverMedia=V),e.verbose&&console.log(e);const v=M(e)||(typeof document<"u"?document:null),S=v&&v.defaultView||(typeof window<"u"?window:null),p=v&&(e.themeRoot||v.documentElement);if(p&&typeof p.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")p.setAttribute("data-theme",e.globalTheme),e.globalTheme==="dark"||e.globalTheme==="light"?p.style.colorScheme=e.globalTheme:p.style.colorScheme="light dark";else if(S&&S.matchMedia){const u=A=>{p.setAttribute("data-theme",A.matches?"dark":"light")},C=S.matchMedia("(prefers-color-scheme: dark)");if(u(C),p.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=u;try{C.addEventListener("change",u)}catch{C.addListener(u)}}}else p.setAttribute("data-theme","light"),p.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const w=Object.keys(g).filter(a=>!a.startsWith("__")),E=new Set(w);if(w.forEach(a=>{const u=a.toLowerCase();u!==a&&E.has(u)&&Z(g[u],g[a])}),w.map(a=>{const u=a.toLowerCase();if(!(u!==a&&E.has(u)))return oe(a,g[a])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),g.typography)try{B()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(g.spacing)try{U()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(g.timing)try{K()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}Q();const R=J();return R&&(e.reset=R),e};export{j as VALUE_TRANSFORMERS,de as changeGlobalTheme,me as set,oe as setEach,se as setValue};
1
+ import{getActiveConfig as v,setActiveConfig as G,toCamel as W}from"./factory.js";import{setColor as N,setGradient as H,setFont as Y,setFontFamily as F,setTheme as $,setSvgIcon as z,setSVG as B,applyTypographySequence as U,applySpacingSequence as J,applyReset as K,applyTimingSequence as Q,applyDocument as X,setShadow as Z}from"./system/index.js";import{deepMerge as ee,isObject as I,isArray as O}from"@symbo.ls/utils";import{isDomDocument as P,isHostObject as k,parkHostObject as M,resolveConfigDocument as j}from"./utils/host.js";const te=(t,s)=>{const e=v(),{cssVars:n}=e,i=s.startsWith("--")?s:`--${s}`;return n[i]=t,t},l=t=>t,q={color:N,gradient:H,font:Y,fontFamily:F,fontfamily:F,theme:$,icons:z,semanticIcons:l,semanticicons:l,svg:B,svgData:l,typography:l,shadow:Z,spacing:l,media:l,grid:l,class:l,timing:l,reset:l,unit:l,animation:l,vars:te,sizes:l,shape:l},se=(t,s,e,n)=>{M(t,e,s);const i={};for(const o of n)t[o]===s&&(t[o]=i);return t.verbose&&console.warn("[scratch] design-system family",e,"resolved to a host object; parked it and allocated a plain bucket"),i},oe=(t,s,e)=>{const n=v(),i=W(t),o=i.toLowerCase(),f=n[i]||n[o]||n[t],r=k(f)?se(n,f,o,[i,o,t]):f,d=q[i]||q[o];if(d)try{const c=d(s,e);return r&&(r[e]=c),r}catch(c){n.verbose&&console.warn("Error setting",o,"value",s,e,c)}if(!d){const c=r||(n[o]={});return c[e]=s,c}n.verbose&&console.warn("Can not find",o,"method in scratch")},re=(t,s)=>{const e=v(),n=t.toLowerCase();return k(s)?(M(e,n,s),e.verbose&&console.warn("[scratch] ignoring host object passed as the",n,"design-system family"),e[n]||e[t]):(Object.keys(s).sort((o,f)=>{const r=I(s[o])||O(s[o])?1:0,d=I(s[f])||O(s[f])?1:0;return r-d}).forEach(o=>{try{return oe(n,s[o],o)}catch(f){e.verbose&&console.warn("Error setting",n,"value",s[o],o,f)}}),e[n]||e[t])},me=(t,s)=>{const e=s||v();e.globalTheme=t;const i=j(e)||(typeof document<"u"?document:null),o=i&&i.defaultView||(typeof window<"u"?window:null);if(i){const r=e.themeRoot||i.documentElement;if(t&&t!=="auto")r.setAttribute("data-theme",t),e.resolvedTheme=t,t==="dark"||t==="light"?r.style.colorScheme=t:r.style.colorScheme="light dark";else if(o&&o.matchMedia){const c=h=>{const y=h.matches?"dark":"light";r.setAttribute("data-theme",y),e.resolvedTheme=y},m=o.matchMedia("(prefers-color-scheme: dark)");if(c(m),r.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=c;try{m.addEventListener("change",c)}catch{m.addListener(c)}}}else r.setAttribute("data-theme","light"),e.resolvedTheme="light",r.style.colorScheme="light"}const f=e.varPrefix?`--${e.varPrefix}-theme-`:"--theme-";for(const r in e.cssVars)r.startsWith(f)&&delete e.cssVars[r];for(const r in e.cssMediaVars)delete e.cssMediaVars[r];if(i&&e.cssVars){const r=e.scopeSelector||":root",d=i.styleSheets;for(let c=0;c<d.length;c++)try{const m=d[c].cssRules;for(let h=0;h<m.length;h++)if(m[h].selectorText===r){for(const y in e.cssVars)m[h].style.setProperty(y,e.cssVars[y]);return e}}catch{}}return e},ne={},ue=(t,s=ne)=>{let e=s.config||v();const{version:n,verbose:i,useVariable:o,useReset:f,useSvgSprite:r,useFontImport:d,useIconSprite:c,globalTheme:m,themeRoot:h,useDocumentTheme:y,useDefaultConfig:C,semanticIcons:_,hoverMedia:V,files:x,assets:D,...g}=t;s.newConfig&&(e=G(s.newConfig)),P(g.document)&&(e.__domDocument=g.document,delete g.document),P(e.document)&&(e.__domDocument||(e.__domDocument=e.document),e.document={}),x!==void 0&&(e.files=x),D!==void 0&&(e.assets=D),i!==void 0&&(e.verbose=i),o!==void 0&&(e.useVariable=o),f!==void 0&&(e.useReset=f),d!==void 0&&(e.useFontImport=d),r!==void 0&&(e.useSvgSprite=r),c!==void 0&&(e.useIconSprite=c),y!==void 0&&(e.useDocumentTheme=y),m!==void 0&&(e.globalTheme=m),h!==void 0&&(e.themeRoot=h),t.useThemeSuffixedVars!==void 0&&(e.useThemeSuffixedVars=t.useThemeSuffixedVars),C!==void 0&&(e.useDefaultConfig=C),_!==void 0&&(e.semanticIcons=_),V!==void 0&&(e.hoverMedia=V),e.verbose&&console.log(e);const b=j(e)||(typeof document<"u"?document:null),S=b&&b.defaultView||(typeof window<"u"?window:null),p=b&&(e.themeRoot||b.documentElement);if(p&&typeof p.setAttribute=="function")if(e.globalTheme&&e.globalTheme!=="auto")p.setAttribute("data-theme",e.globalTheme),e.resolvedTheme=e.globalTheme,e.globalTheme==="dark"||e.globalTheme==="light"?p.style.colorScheme=e.globalTheme:p.style.colorScheme="light dark";else if(S&&S.matchMedia){const u=A=>{const L=A.matches?"dark":"light";p.setAttribute("data-theme",L),e.resolvedTheme=L},w=S.matchMedia("(prefers-color-scheme: dark)");if(u(w),p.style.colorScheme="light dark",!e.__prefersListener){e.__prefersListener=u;try{w.addEventListener("change",u)}catch{w.addListener(u)}}}else p.setAttribute("data-theme","light"),e.resolvedTheme="light",p.style.colorScheme="light";e.__svgCache||(e.__svgCache={});const T=Object.keys(g).filter(a=>!a.startsWith("__")),E=new Set(T);if(T.forEach(a=>{const u=a.toLowerCase();u!==a&&E.has(u)&&ee(g[u],g[a])}),T.map(a=>{const u=a.toLowerCase();if(!(u!==a&&E.has(u)))return re(a,g[a])}),e.varPrefix&&(e.typography&&(e.typography.varPrefix=e.varPrefix),e.spacing&&(e.spacing.varPrefix=e.varPrefix),e.timing&&(e.timing.varPrefix=e.varPrefix)),g.typography)try{U()}catch(a){e.verbose&&console.warn("Error applying typography sequence",a)}if(g.spacing)try{J()}catch(a){e.verbose&&console.warn("Error applying spacing sequence",a)}if(g.timing)try{Q()}catch(a){e.verbose&&console.warn("Error applying timing sequence",a)}X();const R=K();return R&&(e.reset=R),e};export{q as VALUE_TRANSFORMERS,me as changeGlobalTheme,ue as set,re as setEach,oe as setValue};
@@ -1 +1 @@
1
- import{isObject as C,isArray as R,isString as m}from"@symbo.ls/utils";import{getActiveConfig as M}from"../factory.js";import{colorStringToRgbaArray as T,getRgbTone as w,isCSSVar as E,parseColorToken as P}from"../utils/index.js";const L={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},S=(r,i,u)=>{const e=u||M();if(!m(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(E(r))return`var(${r})`;i&&r[i]&&(r=r[i]);let b,a,n;if(R(r))[b,a,n]=r;else{const t=P(r);if(!t){const{color:h,gradient:V}=e;let l=V[r]||h[r];return l?(i&&l[i]&&(l=l[i]),e.useVariable?`var(${l.var})`:l.value):r}if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;b=t.name,a=t.alpha,n=t.tone}const{color:d,gradient:g}=e;let s=d[b]||g[b];if(!s)return e.verbose&&console.warn("Can't find color ",b),r;if(i)if(s[i]!==void 0)s=s[i];else if(R(s)){const t=i.charCodeAt(0)===64?i.slice(1):i;t==="dark"?s=s[1]!==void 0?s[1]:s[0]:(t!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",i),s=s[0])}else e.verbose&&console.warn(r," - does not have ",i);if(m(s))return S(s,null,u);let f=s.rgb;if(!f){const t=e.useVariable?`var(${s.var})`:s.value;if((a||n)&&t){const h=a!==void 0?a:1;if(!n)return`rgb(from ${t} r g b / ${h})`;if(n.charCodeAt(0)===43||n.charCodeAt(0)===45){const l=parseFloat(n),c=l<0?"-":"+",o=Math.abs(l);return`rgb(from ${t} calc(r ${c} ${o}) calc(g ${c} ${o}) calc(b ${c} ${o}) / ${h})`}return`hsl(from ${t} h s ${n}% / ${h})`}return t}return n&&!s[n]&&(f=w(f,n),s[n]={rgb:f,var:`${s.var}-${n}`}),s[n]&&(f=s[n].rgb),a?`rgba(${f}, ${a})`:n?`rgba(${f}, 1)`:e.useVariable?`var(${s.var})`:`rgb(${f})`},U=(r,i,u)=>{const e=u||M();if(i||(i=e.globalTheme==="auto"?null:e.globalTheme),!m(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(E(r))return`var(${r})`;let b,a,n;if(R(r))b=r[0];else{const t=P(r);if(t){if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;b=t.name,a=t.alpha,n=t.tone}else b=r}const{color:d,gradient:g}=e,s=d[b]||g[b],f=C(s);if(f&&s.value)return S(r,`@${i}`,u);if(f){if(e.useVariable&&s.var)return a||n?S(r,null,u):`var(${s.var})`;if(i)return S(r,`@${i}`,u);{const t={};for(const h in s){if(h.charCodeAt(0)!==64)continue;const V=h.slice(1),l=e.media&&e.media[V]||L[V];if(!l)continue;const c="@media "+(l==="print"?`${l}`:`screen and ${l}`);t[c]=S(r,h,u)}return t}}else return e.verbose&&console.warn("Can't find color",r),r},j=(r,i,u,e)=>{const a=`--${e.varPrefix?e.varPrefix+"-":""}${i}-${u}`;let n;const d={};for(const g in r){if(g.charCodeAt(0)!==64)continue;const s=g.slice(1),f=r[g],t=f&&(f.value||f);!t||typeof t!="string"||(d[s]=t,(s==="light"||n===void 0)&&(n=t))}if(n!==void 0){e.cssVars[a]=n,e.cssMediaVars||(e.cssMediaVars={});for(const g in d){const s=`[data-theme="${g}"]`;if(e.cssMediaVars[s]||(e.cssMediaVars[s]={}),e.cssMediaVars[s][a]=d[g],g==="light"||g==="dark"){const f=`@media (prefers-color-scheme: ${g})`;e.cssMediaVars[f]||(e.cssMediaVars[f]={}),e.cssMediaVars[f][a]=d[g]}}return r.var=a,a}},D=(r,i,u)=>{const e=M();if(C(r)&&r.value!==void 0&&(r.rgb!==void 0||r.var!==void 0))return e.useVariable&&r.var&&(e.cssVars[r.var]=r.value),r;if(m(r)&&E(r)){const c=r.slice(2);if(r=S(c),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const o=c.split(" ");let $=e.color[o[0]];if($&&!$.value&&!$.rgb&&(m($)||R($)||C($))&&(e.color[o[0]]=D($,o[0]),$=e.color[o[0]]),$&&$.value){let p=$.rgb;const x=o[1]!==void 0?o[1]:"1",A=o[2];A&&(p=w(p,A)),r=`rgba(${p}, ${x})`}else{const p=o[2],x=o[1]!==void 0?o[1]:"1";if(p)try{const A=T(o[0]);A&&A.length>=3?r=`rgba(${w(A.slice(0,3).join(", "),p)}, ${x})`:r=o[0]}catch{r=o[0]}else r=o[0]}}}if(R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),C(r)){const c={};for(const o in r)o!=="var"&&(c[o]=D(r[o],i,o.slice(0,1)==="@"?o.slice(1):o));return e.useVariable&&j(c,"color",i,e),c}const a=`--${e.varPrefix?e.varPrefix+"-":""}color-${i}`+(u?`-${u}`:"");let n=r.value||r;if(m(n)&&!n.includes("(")&&!n.startsWith("#")){const c=P(n);if(c&&c.name&&!c.passthrough&&!c.cssVar){const o=e.color[c.name];o&&!o.value&&!o.rgb&&(m(o)||R(o)||C(o))&&(e.color[c.name]=D(o,c.name));const $=e.color[c.name];if($&&$.rgb){let p=$.rgb;c.tone&&(p=w(p,c.tone));const x=c.alpha?parseFloat(c.alpha):1;n=`rgba(${p}, ${x})`}}}const d=T(n),[g,s,f,t=1]=d,h=parseFloat(t.toFixed(2)),V=`${g}, ${s}, ${f}`,l=`rgba(${V}, ${h})`;return e.useVariable&&(e.cssVars[a]=l),{var:a,rgb:V,alpha:h,value:l}},q=(r,i,u)=>{const e=M();if(C(r)&&r.value!==void 0&&r.var!==void 0)return e.useVariable&&(e.cssVars[r.var]=r.value),r;if(m(r)&&E(r)&&(r=S(r.slice(2))),R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),C(r)){const n={};for(const d in r)d!=="var"&&(n[d]=q(r[d],i,d.slice(0,1)==="@"?d.slice(1):d));return e.useVariable&&j(n,"gradient",i,e),n}const a=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${i}`+(u?`-${u}`:"");return e.useVariable&&(e.cssVars[a]=r.value||r),{var:a,value:r.value||r}};export{L as STANDARD_SCHEME_QUERIES,S as getColor,U as getMediaColor,j as setAdaptiveSchemeVar,D as setColor,q as setGradient};
1
+ import{isObject as C,isArray as R,isString as $}from"@symbo.ls/utils";import{getActiveConfig as M}from"../factory.js";import{colorStringToRgbaArray as E,getRgbTone as w,isCSSVar as P,parseColorToken as D}from"../utils/index.js";const O={light:"(prefers-color-scheme: light)",dark:"(prefers-color-scheme: dark)"},S=(r,a,g)=>{const e=g||M();if(!$(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(P(r))return`var(${r})`;a&&r[a]&&(r=r[a]);let f,d,s;if(R(r))[f,d,s]=r;else{const t=D(r);if(!t){const{color:o,gradient:V}=e;let h=V[r]||o[r];return h?(a&&h[a]&&(h=h[a]),e.useVariable?`var(${h.var})`:h.value):r}if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;f=t.name,d=t.alpha,s=t.tone}const{color:p,gradient:c}=e;let n=p[f]||c[f];if(!n)return e.verbose&&console.warn("Can't find color ",f),r;if(a)if(n[a]!==void 0)n=n[a];else if(R(n)){const t=a.charCodeAt(0)===64?a.slice(1):a;t==="dark"?n=n[1]!==void 0?n[1]:n[0]:(t!=="light"&&e.verbose&&console.warn(r," - array-form color tokens only support light/dark; falling back to the light slot for scheme",a),n=n[0])}else e.verbose&&console.warn(r," - does not have ",a);if($(n))return S(n,null,g);let u=n.rgb;if(!u){const t=e.useVariable?`var(${n.var})`:n.value;if((d||s)&&t){const o=d!==void 0?d:1;if(!s)return`rgb(from ${t} r g b / ${o})`;if(s.charCodeAt(0)===43||s.charCodeAt(0)===45){const h=parseFloat(s),l=h<0?"-":"+",i=Math.abs(h);return`rgb(from ${t} calc(r ${l} ${i}) calc(g ${l} ${i}) calc(b ${l} ${i}) / ${o})`}return`hsl(from ${t} h s ${s}% / ${o})`}return t}return s&&!n[s]&&(u=w(u,s),n[s]={rgb:u,var:`${n.var}-${s}`}),n[s]&&(u=n[s].rgb),d?`rgba(${u}, ${d})`:s?`rgba(${u}, 1)`:e.useVariable?`var(${n.var})`:`rgb(${u})`},j=(r,a,g)=>{const e=a||M();if(!$(r))return null;const f=D(r);if(f){if(f.passthrough){const o=E(f.passthrough);return o&&o.length>=3?{rgb:[o[0],o[1],o[2]],alpha:o[3]!==void 0?o[3]:1}:null}if(f.cssVar)return null}const d=f?f.name:r,{color:s,gradient:p}=e;let c=s[d]||p[d];if(!c){const o=E(r);return!o||o.length<3||o[0]===0&&o[1]===0&&o[2]===0&&o[3]===0&&r.toLowerCase()!=="transparent"?null:{rgb:[o[0],o[1],o[2]],alpha:o[3]!==void 0?o[3]:1}}if($(c))return j(c,e,g);if(c.rgb===void 0&&C(c)){const o=`@${g||"light"}`;c=c[o]!==void 0?c[o]:c["@light"]}if(!c||c.rgb===void 0)return null;let n=c.rgb;f&&f.tone&&(n=w(n,f.tone));const u=$(n)?n.split(",").map(o=>parseFloat(o.trim())):n,t=f&&f.alpha!==void 0?parseFloat(f.alpha):c.alpha!==void 0?c.alpha:1;return{rgb:u,alpha:t}},Q=(r,a,g)=>{const e=g||M();if(a||(a=e.globalTheme==="auto"?null:e.globalTheme),!$(r)){e.verbose&&console.warn(r,"- type for color is not valid");return}if(P(r))return`var(${r})`;let f,d,s;if(R(r))f=r[0];else{const t=D(r);if(t){if(t.passthrough)return t.passthrough;if(t.cssVar)return`var(${t.cssVar})`;f=t.name,d=t.alpha,s=t.tone}else f=r}const{color:p,gradient:c}=e,n=p[f]||c[f],u=C(n);if(u&&n.value)return S(r,`@${a}`,g);if(u){if(e.useVariable&&n.var)return d||s?S(r,null,g):`var(${n.var})`;if(a)return S(r,`@${a}`,g);{const t={};for(const o in n){if(o.charCodeAt(0)!==64)continue;const V=o.slice(1),h=e.media&&e.media[V]||O[V];if(!h)continue;const l="@media "+(h==="print"?`${h}`:`screen and ${h}`);t[l]=S(r,o,g)}return t}}else return e.verbose&&console.warn("Can't find color",r),r},L=(r,a,g,e)=>{const d=`--${e.varPrefix?e.varPrefix+"-":""}${a}-${g}`;let s;const p={};for(const c in r){if(c.charCodeAt(0)!==64)continue;const n=c.slice(1),u=r[c],t=u&&(u.value||u);!t||typeof t!="string"||(p[n]=t,(n==="light"||s===void 0)&&(s=t))}if(s!==void 0){e.cssVars[d]=s,e.cssMediaVars||(e.cssMediaVars={});for(const c in p){const n=`[data-theme="${c}"]`;if(e.cssMediaVars[n]||(e.cssMediaVars[n]={}),e.cssMediaVars[n][d]=p[c],c==="light"||c==="dark"){const u=`@media (prefers-color-scheme: ${c})`;e.cssMediaVars[u]||(e.cssMediaVars[u]={}),e.cssMediaVars[u][d]=p[c]}}return r.var=d,d}},T=(r,a,g)=>{const e=M();if(C(r)&&r.value!==void 0&&(r.rgb!==void 0||r.var!==void 0))return e.useVariable&&r.var&&(e.cssVars[r.var]=r.value),r;if($(r)&&P(r)){const l=r.slice(2);if(r=S(l),!(r.includes("rgb")||r.includes("var")||r.includes("#"))){const i=l.split(" ");let b=e.color[i[0]];if(b&&!b.value&&!b.rgb&&($(b)||R(b)||C(b))&&(e.color[i[0]]=T(b,i[0]),b=e.color[i[0]]),b&&b.value){let m=b.rgb;const x=i[1]!==void 0?i[1]:"1",A=i[2];A&&(m=w(m,A)),r=`rgba(${m}, ${x})`}else{const m=i[2],x=i[1]!==void 0?i[1]:"1";if(m)try{const A=E(i[0]);A&&A.length>=3?r=`rgba(${w(A.slice(0,3).join(", "),m)}, ${x})`:r=i[0]}catch{r=i[0]}else r=i[0]}}}if(R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),C(r)){const l={};for(const i in r)i!=="var"&&(l[i]=T(r[i],a,i.slice(0,1)==="@"?i.slice(1):i));return e.useVariable&&L(l,"color",a,e),l}const d=`--${e.varPrefix?e.varPrefix+"-":""}color-${a}`+(g?`-${g}`:"");let s=r.value||r;if($(s)&&!s.includes("(")&&!s.startsWith("#")){const l=D(s);if(l&&l.name&&!l.passthrough&&!l.cssVar){const i=e.color[l.name];i&&!i.value&&!i.rgb&&($(i)||R(i)||C(i))&&(e.color[l.name]=T(i,l.name));const b=e.color[l.name];if(b&&b.rgb){let m=b.rgb;l.tone&&(m=w(m,l.tone));const x=l.alpha?parseFloat(l.alpha):1;s=`rgba(${m}, ${x})`}}}const p=E(s),[c,n,u,t=1]=p,o=parseFloat(t.toFixed(2)),V=`${c}, ${n}, ${u}`,h=`rgba(${V}, ${o})`;return e.useVariable&&(e.cssVars[d]=h),{var:d,rgb:V,alpha:o,value:h}},F=(r,a,g)=>{const e=M();if(C(r)&&r.value!==void 0&&r.var!==void 0)return e.useVariable&&(e.cssVars[r.var]=r.value),r;if($(r)&&P(r)&&(r=S(r.slice(2))),R(r)&&(r={"@light":r[0],"@dark":r[1]!==void 0?r[1]:r[0]}),C(r)){const s={};for(const p in r)p!=="var"&&(s[p]=F(r[p],a,p.slice(0,1)==="@"?p.slice(1):p));return e.useVariable&&L(s,"gradient",a,e),s}const d=`--${e.varPrefix?e.varPrefix+"-":""}gradient-${a}`+(g?`-${g}`:"");return e.useVariable&&(e.cssVars[d]=r.value||r),{var:d,value:r.value||r}};export{O as STANDARD_SCHEME_QUERIES,S as getColor,Q as getMediaColor,j as resolveColorRgb,L as setAdaptiveSchemeVar,T as setColor,F as setGradient};
@@ -1 +1 @@
1
- export*from"./color.js";export*from"./theme.js";export*from"./font.js";export*from"./typography.js";export*from"./spacing.js";export*from"./shape.js";export*from"./shadow.js";export*from"./timing.js";export*from"./document.js";export*from"./svg.js";export*from"./reset.js";
1
+ export*from"./color.js";export*from"./ink.js";export*from"./theme.js";export*from"./font.js";export*from"./typography.js";export*from"./spacing.js";export*from"./shape.js";export*from"./shadow.js";export*from"./timing.js";export*from"./document.js";export*from"./svg.js";export*from"./reset.js";
@@ -0,0 +1 @@
1
+ import{isString as U}from"@symbo.ls/utils";import{getActiveConfig as W}from"../factory.js";import{parseColorToken as X,srgbToOklab as Y,oklabToOklch as Z,oklchToGamutSafeSrgb as _,relativeLuminance as ee,contrastRatio as y,compositeOverBackdrop as L}from"../utils/index.js";import{getColor as M,resolveColorRgb as A}from"./color.js";const te=(s,a,u={},m)=>{const r=m||W(),{min:D=4.5,large:j=!1,scheme:F,meta:G=!1,maxIterations:K=15}=u,b=j?3:D,c=F||(r.globalTheme&&r.globalTheme!=="auto"?r.globalTheme:"light"),$=U(a)?a:String(a),f=X(s),I=f&&!f.passthrough&&!f.cssVar?f.name:null,g=(e,t)=>G?{value:e,...t}:e;if(I){const e=r.color[`${I}Safe`];if(e){const t=`${$}@${c}`,o=e[t]!==void 0?e[t]:e[$];if(o!==void 0){const T=o&&o.rgb!==void 0?r.useVariable&&o.var?`var(${o.var})`:o.value:M(o,null,r);return g(T,{ratio:null,deviation:0,derived:!1,overridden:!0})}}}const R=M(s,c?`@${c}`:null,r),n=A(s,r,c),h=A(a,r,c);if(!n||!h)return r.verbose&&console.warn("getSafeInk: could not resolve",s,a,"\u2014 returning hue unchanged"),g(R,{ratio:null,deviation:0,derived:!1,overridden:!1,unresolved:!0});const d=L(h.rgb,h.alpha),N=L(n.rgb,n.alpha,d),v=y(N,d);if(v>=b-.02)return g(R,{ratio:v,deviation:0,derived:!1,overridden:!1});const[i,V,w]=Y(n.rgb),[,B,E]=Z([i,V,w]),O=ee(d)>.5,H=O?i:1-i,k=e=>{const t=O?i-e:i+e,o=Math.max(0,Math.min(1,t));return{rgb:_(o,B,E),L:o}},p=e=>{const{rgb:t}=k(e),o=L(t,n.alpha,d);return y(o,d)};let S=0,l=H;const x=p(l)>=b;if(x)for(let e=0;e<K;e++){const t=(S+l)/2;p(t)>=b?l=t:S=t}else S=l;const{rgb:P,L:q}=k(l),C=P.map(e=>Math.round(e)),z=p(l),J=n.alpha<1?`rgba(${C.join(", ")}, ${n.alpha})`:`rgb(${C.join(", ")})`,Q=Math.abs(q-i)*100;return g(J,{rgb:C,ratio:z,startRatio:v,deviation:Q,derived:!0,overridden:!1,reachable:x})},se=(s,a,u={},m)=>te(s,a,{...u,meta:!0},m);export{te as getSafeInk,se as getSafeInkInfo};
@@ -1 +1 @@
1
- import{document as o,window as h,isString as p,isNumber as x,isNotProduction as d}from"@symbo.ls/utils";const c=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&o&&h){const e=o.body.appendChild(o.createElement("fictum")),r="rgb(1, 2, 3)";if(e.style.color=r,e.style.color!==r){o.body.removeChild(e);return}if(e.style.color=t,e.style.color===r||e.style.color==="")return o.body.removeChild(e),[0,0,0,0];t=h.getComputedStyle(e).color,o.body.removeChild(e)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(e=>+e)):[0,0,0,0]},O=(t,e,r=.5)=>(t=c(t),e=c(e),R(t,e,r)),E=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgb(${r},${s},${n})`},b=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return[r,s,n]},L=(t,e,r)=>"#"+(1<<24|t<<16|e<<8|r).toString(16).slice(1),l=([t,e,r])=>((1<<24)+(t<<16)+(e<<8)+r).toString(16).slice(1),A=(t,e=1)=>{const[r,s,n]=t.match(/\w\w/g).map(a=>parseInt(a,16));return`rgba(${r},${s},${n},${e})`},F=(t,e,r=.5)=>{const s=[];for(let n=0;n<3;n++)s[n]=~~(t[n]+(e[n]-t[n])*r);return`rgb(${s})`},_=(t,e)=>{const[r,s,n]=e,a=Math.max(0,Math.min(100,n+parseFloat(t)));return[r,s,a]},w=(t,e,r)=>{const s=Math.max(t,e,r),n=s-Math.min(t,e,r),a=1-Math.abs(s+s-n-1),i=n&&(s==t?(e-r)/n:s==e?2+(r-t)/n:4+(t-e)/n);return[60*(i<0?i+6:i),a?n/a:0,(s+s-n)/2]},C=(t,e,r,s=e*Math.min(r,1-r),n=(a,i=(a+t/30)%12)=>r-s*Math.max(Math.min(i-3,9-i,1),-1))=>[n(0),n(8),n(4)],T=(t,e)=>{const r=parseInt(t,16);let s=(r>>16)+e;s>255?s=255:s<0&&(s=0);let n=(r>>8&255)+e;n>255?n=255:n<0&&(n=0);let a=(r&255)+e;return a>255?a=255:a<0&&(a=0),((a|n<<8|s<<16)+16777216).toString(16).slice(1)},R=(t,e,r=.5)=>{const s=[];for(let n=0;n<4;n++){const a=n===3?i=>i:Math.round;s[n]=a(t[n]+(e[n]-t[n])*r)}return`rgba(${s})`},H=(t,e)=>{const r=c(t);if(!r){d()&&console.warn(t+" color is not rgba");return}return r[3]=e,`rgba(${r})`},y=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,M=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,S=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,N=t=>{if(!p(t))return null;if(M.test(t))return{passthrough:t};if(y(t))return{cssVar:t};const e=t.match(S);if(!e)return null;const[,r,s,n]=e,a=s!==void 0?`0.${s}`:void 0,i=n&&n[0]==="="?n.slice(1):n;return{name:r,alpha:a,tone:i}},j=t=>p(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),V=t=>{const e=[];let r="",s=0;for(const n of t){if(n==="("?s+=1:n===")"&&s>0&&(s-=1),n===","&&s===0){e.push(r),r="";continue}r+=n}return(r.length||!e.length)&&e.push(r),e},z=(t,e)=>{p(t)&&t.includes("rgb")&&(t=c(t).join(", ")),p(t)&&(t=t.split(",").map(n=>parseFloat(n.trim()))),x(e)&&(e+="");const r=l(t),s=e.slice(0,1);if(s==="-"||s==="+"){const n=T(r,parseFloat(e));return b(n).join(", ")}else{const[n,a,i]=t,[u,f]=w(n/255,a/255,i/255),g=Math.max(0,Math.min(100,parseFloat(e)))/100;return C(u,f,g).map(m=>Math.round(Math.max(0,Math.min(1,m))*255)).join(", ")}};export{M as CSS_NATIVE_COLOR_REGEX,_ as changeLightness,c as colorStringToRgbaArray,T as getColorShade,z as getRgbTone,E as hexToRgb,b as hexToRgbArray,A as hexToRgba,C as hslToRgb,y as isCSSVar,j as isResolvedColor,O as mixTwoColors,F as mixTwoRgb,R as mixTwoRgba,H as opacify,N as parseColorToken,l as rgbArrayToHex,w as rgbToHSL,L as rgbToHex,V as splitTopLevelCommas};
1
+ import{document as u,window as g,isString as m,isNumber as d,isNotProduction as M}from"@symbo.ls/utils";const f=t=>{if(t==="")return[0,0,0,0];if(t.toLowerCase()==="transparent")return[0,0,0,0];if(t[0]==="#")return t.length<7&&(t="#"+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]+(t.length>4?t[4]+t[4]:"")),[parseInt(t.substr(1,2),16),parseInt(t.substr(3,2),16),parseInt(t.substr(5,2),16),t.length>7?parseInt(t.substr(7,2),16)/255:1];if(t.indexOf("rgb")===-1&&u&&g){const n=u.body.appendChild(u.createElement("fictum")),e="rgb(1, 2, 3)";if(n.style.color=e,n.style.color!==e){u.body.removeChild(n);return}if(n.style.color=t,n.style.color===e||n.style.color==="")return u.body.removeChild(n),[0,0,0,0];t=g.getComputedStyle(n).color,u.body.removeChild(n)}return t.indexOf("rgb")===0?(t.indexOf("rgba")===-1&&(t=`${t}, 1`),t.match(/[\.\d]+/g).map(n=>+n)):[0,0,0,0]},A=(t,n,e=.5)=>(t=f(t),n=f(n),y(t,n,e)),G=(t,n=1)=>{const[e,s,r]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgb(${e},${s},${r})`},T=(t,n=1)=>{const[e,s,r]=t.match(/\w\w/g).map(o=>parseInt(o,16));return[e,s,r]},H=(t,n,e)=>"#"+(1<<24|t<<16|n<<8|e).toString(16).slice(1),w=([t,n,e])=>((1<<24)+(t<<16)+(n<<8)+e).toString(16).slice(1),N=(t,n=1)=>{const[e,s,r]=t.match(/\w\w/g).map(o=>parseInt(o,16));return`rgba(${e},${s},${r},${n})`},j=(t,n,e=.5)=>{const s=[];for(let r=0;r<3;r++)s[r]=~~(t[r]+(n[r]-t[r])*e);return`rgb(${s})`},P=(t,n)=>{const[e,s,r]=n,o=Math.max(0,Math.min(100,r+parseFloat(t)));return[e,s,o]},C=(t,n,e)=>{const s=Math.max(t,n,e),r=s-Math.min(t,n,e),o=1-Math.abs(s+s-r-1),a=r&&(s==t?(n-e)/r:s==n?2+(e-t)/r:4+(t-n)/r);return[60*(a<0?a+6:a),o?r/o:0,(s+s-r)/2]},S=(t,n,e,s=n*Math.min(e,1-e),r=(o,a=(o+t/30)%12)=>e-s*Math.max(Math.min(a-3,9-a,1),-1))=>[r(0),r(8),r(4)],R=(t,n)=>{const e=parseInt(t,16);let s=(e>>16)+n;s>255?s=255:s<0&&(s=0);let r=(e>>8&255)+n;r>255?r=255:r<0&&(r=0);let o=(e&255)+n;return o>255?o=255:o<0&&(o=0),((o|r<<8|s<<16)+16777216).toString(16).slice(1)},y=(t,n,e=.5)=>{const s=[];for(let r=0;r<4;r++){const o=r===3?a=>a:Math.round;s[r]=o(t[r]+(n[r]-t[r])*e)}return`rgba(${s})`},V=(t,n)=>{const e=f(t);if(!e){M()&&console.warn(t+" color is not rgba");return}return e[3]=n,`rgba(${e})`},$=t=>t.charCodeAt(0)===45&&t.charCodeAt(1)===45,I=/(?:rgba?\(|hsla?\(|#[0-9a-fA-F]{3,8}\b)/,O=/^([a-zA-Z]\w*(?:-[a-zA-Z]\w*)*)(?:\.(\d+))?(?:([+-]\d+|=\d+))?$/,z=t=>{if(!m(t))return null;if(I.test(t))return{passthrough:t};if($(t))return{cssVar:t};const n=t.match(O);if(!n)return null;const[,e,s,r]=n,o=s!==void 0?`0.${s}`:void 0,a=r&&r[0]==="="?r.slice(1):r;return{name:e,alpha:o,tone:a}},X=t=>m(t)&&(t.includes("rgb")||t.includes("var(")||t.includes("#")),Z=t=>{const n=[];let e="",s=0;for(const r of t){if(r==="("?s+=1:r===")"&&s>0&&(s-=1),r===","&&s===0){n.push(e),e="";continue}e+=r}return(e.length||!n.length)&&n.push(e),n},x=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),b=t=>.2126*x(t[0])+.7152*x(t[1])+.0722*x(t[2]),q=(t,n)=>{const e=b(t)+.05,s=b(n)+.05;return e>s?e/s:s/e},_=t=>(t/=255,t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)),L=t=>(t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055)*255,D=([t,n,e])=>{const[s,r,o]=[t,n,e].map(_),a=.4122214708*s+.5363325363*r+.0514459929*o,i=.2119034982*s+.6806995451*r+.1073969566*o,c=.0883024619*s+.2817188376*r+.6299787005*o,h=Math.cbrt(a),p=Math.cbrt(i),l=Math.cbrt(c);return[.2104542553*h+.793617785*p-.0040720468*l,1.9779984951*h-2.428592205*p+.4505937099*l,.0259040371*h+.7827717662*p-.808675766*l]},k=([t,n,e])=>{const s=t+.3963377774*n+.2158037573*e,r=t-.1055613458*n-.0638541728*e,o=t-.0894841775*n-1.291485548*e,a=s**3,i=r**3,c=o**3;return[4.0767416621*a-3.3077115913*i+.2309699292*c,-1.2684380046*a+2.6097574011*i-.3413193965*c,-.0041960863*a-.7034186147*i+1.707614701*c]},K=([t,n,e])=>{let s=Math.atan2(e,n)*180/Math.PI;return s<0&&(s+=360),[t,Math.sqrt(n*n+e*e),s]},E=([t,n,e])=>{const s=e*Math.PI/180;return[t,n*Math.cos(s),n*Math.sin(s)]},J=(t,n,e,s=24)=>{const r=i=>k(E([t,i,e])),o=i=>i.every(c=>c>=-1e-4&&c<=1.0001);let a=r(n);if(!o(a)){let i=0,c=n;for(let h=0;h<s;h++){const p=(i+c)/2;o(r(p))?i=p:c=p}a=r(i)}return a.map(i=>L(Math.max(0,Math.min(1,i))))},Q=(t,n=1,e=[255,255,255])=>n>=1?t:t.map((s,r)=>s*n+e[r]*(1-n)),U=(t,n)=>{m(t)&&t.includes("rgb")&&(t=f(t).join(", ")),m(t)&&(t=t.split(",").map(r=>parseFloat(r.trim()))),d(n)&&(n+="");const e=w(t),s=n.slice(0,1);if(s==="-"||s==="+"){const r=R(e,parseFloat(n));return T(r).join(", ")}else{const[r,o,a]=t,[i,c]=C(r/255,o/255,a/255),h=Math.max(0,Math.min(100,parseFloat(n)))/100;return S(i,c,h).map(l=>Math.round(Math.max(0,Math.min(1,l))*255)).join(", ")}};export{I as CSS_NATIVE_COLOR_REGEX,P as changeLightness,f as colorStringToRgbaArray,Q as compositeOverBackdrop,q as contrastRatio,R as getColorShade,U as getRgbTone,G as hexToRgb,T as hexToRgbArray,N as hexToRgba,S as hslToRgb,$ as isCSSVar,X as isResolvedColor,L as linearChannelToSrgb,A as mixTwoColors,j as mixTwoRgb,y as mixTwoRgba,k as oklabToLinearSrgb,K as oklabToOklch,J as oklchToGamutSafeSrgb,E as oklchToOklab,V as opacify,z as parseColorToken,b as relativeLuminance,w as rgbArrayToHex,C as rgbToHSL,H as rgbToHex,Z as splitTopLevelCommas,_ as srgbChannelToLinear,D as srgbToOklab,x as toLinearChannel};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "3.14.769",
5
+ "version": "3.14.773",
6
6
  "files": [
7
7
  "dist",
8
8
  "*.js",