From e4871084cfe0cbd96a9af934fc0f25de1c09ee42 Mon Sep 17 00:00:00 2001 From: Marius Sarca Date: Fri, 15 Apr 2022 16:39:32 +0300 Subject: [PATCH] Added wave-clip virtual property --- dist/assembler.cjs.js | 36 +++++++++++++++++++++++++++++++++--- dist/assembler.es.js | 36 +++++++++++++++++++++++++++++++++--- dist/assembler.js | 36 +++++++++++++++++++++++++++++++++--- dist/assembler.min.js | 2 +- package.json | 2 +- src/StyleHandler.ts | 2 +- src/list.ts | 42 ++++++++++++++++++++++++++++++++++++++++-- types/list.d.ts | 4 ++++ 8 files changed, 146 insertions(+), 14 deletions(-) diff --git a/dist/assembler.cjs.js b/dist/assembler.cjs.js index 5476f5f..a6da717 100644 --- a/dist/assembler.cjs.js +++ b/dist/assembler.cjs.js @@ -26,6 +26,9 @@ const shadow_regex = /^[1-6]$/; const letter_spacing_regex = /^(tighter|tight|normal|wide|wider|widest)$/; const radius_regex = /^(xs|sm|md|lg|xl|pill)$/; const order_regex = /^(first|last|none)$/; +// do not match comma inside parenthesis +// 2px, linear-gradient(blue, red), inline => [2px, linear-gradient(blue, red), inline] +const args_delimiter = /\s*,\s*(?![^(]*\))/gm; const PROPERTY_LIST = [ "align-content", "align-items", @@ -347,6 +350,7 @@ const ALIASES = { "capitalize": "text-transform", "normal-case": "text-transform", "variant": "font-variant-numeric", + "wave-clip": "clip-path", }; const DEFAULT_VALUES = { "border": ["1px solid transparent"], @@ -377,7 +381,8 @@ const DEFAULT_VALUES = { "capitalize": "capitalize", "normal-case": "none", "radius": "sm", - "shadow": "1" + "shadow": "1", + "wave-clip": "50, 2, 50" }; const unit = v => number_regex.test(v) ? `calc(${v} * @unit-size)` : v; const positive_unit = v => positive_number_regex.test(v) ? `calc(${v} * @unit-size)` : v; @@ -411,6 +416,30 @@ const orderCallback = v => { return "9999"; return "0"; }; +const waveClipIds = new Set(); +const generateWave = (value, original, media, state, handler) => { + const args = value.split(args_delimiter).map(v => v.trim()).map(v => parseInt(v)); + let [amplitude, frequency, precision] = args; + amplitude = amplitude !== null && amplitude !== void 0 ? amplitude : 50; + frequency = frequency !== null && frequency !== void 0 ? frequency : 2; + precision = precision !== null && precision !== void 0 ? precision : 50; + const id = amplitude + '-' + frequency + '-' + precision; + if (waveClipIds.has(id)) { + return '@wave-clip-' + id; + } + waveClipIds.add(id); + const units = Math.PI * 2 * frequency; + const factor = precision / 100; + amplitude /= 2; + let polygon = 'polygon(100% 0%, 0% 0%'; + for (let i = 0; i <= precision; i++) { + const val = Math.abs((amplitude * Math.cos((i / precision) * units) - amplitude)).toFixed(2); + polygon += ', ' + (i / factor) + '% calc(100% - ' + val + 'px)'; + } + polygon += ')'; + handler.style.cssRules[0].style.setProperty('--wave-clip-' + id, polygon); + return '@wave-clip-' + id; +}; const VALUE_WRAPPER = { "img": v => `url(${v})`, "gradient": (value) => `linear-gradient(${value})`, @@ -477,7 +506,8 @@ const VALUE_WRAPPER = { "min-width": positive_unit, "max-width": positive_unit, "min-height": positive_unit, - "max-height": positive_unit + "max-height": positive_unit, + "wave-clip": generateWave, }; /* @@ -1226,7 +1256,7 @@ class StyleHandler { value = DEFAULT_VALUES[original] || ''; } if (VALUE_WRAPPER.hasOwnProperty(original)) { - value = VALUE_WRAPPER[original](value, original, media, state); + value = VALUE_WRAPPER[original](value, original, media, state, this); } if (!Array.isArray(value)) { value = Array(properties.length).fill(value.replace(VAR_REGEX, "var(--$1)")); diff --git a/dist/assembler.es.js b/dist/assembler.es.js index 722ed1d..e7612a6 100644 --- a/dist/assembler.es.js +++ b/dist/assembler.es.js @@ -22,6 +22,9 @@ const shadow_regex = /^[1-6]$/; const letter_spacing_regex = /^(tighter|tight|normal|wide|wider|widest)$/; const radius_regex = /^(xs|sm|md|lg|xl|pill)$/; const order_regex = /^(first|last|none)$/; +// do not match comma inside parenthesis +// 2px, linear-gradient(blue, red), inline => [2px, linear-gradient(blue, red), inline] +const args_delimiter = /\s*,\s*(?![^(]*\))/gm; const PROPERTY_LIST = [ "align-content", "align-items", @@ -343,6 +346,7 @@ const ALIASES = { "capitalize": "text-transform", "normal-case": "text-transform", "variant": "font-variant-numeric", + "wave-clip": "clip-path", }; const DEFAULT_VALUES = { "border": ["1px solid transparent"], @@ -373,7 +377,8 @@ const DEFAULT_VALUES = { "capitalize": "capitalize", "normal-case": "none", "radius": "sm", - "shadow": "1" + "shadow": "1", + "wave-clip": "50, 2, 50" }; const unit = v => number_regex.test(v) ? `calc(${v} * @unit-size)` : v; const positive_unit = v => positive_number_regex.test(v) ? `calc(${v} * @unit-size)` : v; @@ -407,6 +412,30 @@ const orderCallback = v => { return "9999"; return "0"; }; +const waveClipIds = new Set(); +const generateWave = (value, original, media, state, handler) => { + const args = value.split(args_delimiter).map(v => v.trim()).map(v => parseInt(v)); + let [amplitude, frequency, precision] = args; + amplitude = amplitude !== null && amplitude !== void 0 ? amplitude : 50; + frequency = frequency !== null && frequency !== void 0 ? frequency : 2; + precision = precision !== null && precision !== void 0 ? precision : 50; + const id = amplitude + '-' + frequency + '-' + precision; + if (waveClipIds.has(id)) { + return '@wave-clip-' + id; + } + waveClipIds.add(id); + const units = Math.PI * 2 * frequency; + const factor = precision / 100; + amplitude /= 2; + let polygon = 'polygon(100% 0%, 0% 0%'; + for (let i = 0; i <= precision; i++) { + const val = Math.abs((amplitude * Math.cos((i / precision) * units) - amplitude)).toFixed(2); + polygon += ', ' + (i / factor) + '% calc(100% - ' + val + 'px)'; + } + polygon += ')'; + handler.style.cssRules[0].style.setProperty('--wave-clip-' + id, polygon); + return '@wave-clip-' + id; +}; const VALUE_WRAPPER = { "img": v => `url(${v})`, "gradient": (value) => `linear-gradient(${value})`, @@ -473,7 +502,8 @@ const VALUE_WRAPPER = { "min-width": positive_unit, "max-width": positive_unit, "min-height": positive_unit, - "max-height": positive_unit + "max-height": positive_unit, + "wave-clip": generateWave, }; /* @@ -1222,7 +1252,7 @@ class StyleHandler { value = DEFAULT_VALUES[original] || ''; } if (VALUE_WRAPPER.hasOwnProperty(original)) { - value = VALUE_WRAPPER[original](value, original, media, state); + value = VALUE_WRAPPER[original](value, original, media, state, this); } if (!Array.isArray(value)) { value = Array(properties.length).fill(value.replace(VAR_REGEX, "var(--$1)")); diff --git a/dist/assembler.js b/dist/assembler.js index ffc2c69..fe3b566 100644 --- a/dist/assembler.js +++ b/dist/assembler.js @@ -28,6 +28,9 @@ const letter_spacing_regex = /^(tighter|tight|normal|wide|wider|widest)$/; const radius_regex = /^(xs|sm|md|lg|xl|pill)$/; const order_regex = /^(first|last|none)$/; + // do not match comma inside parenthesis + // 2px, linear-gradient(blue, red), inline => [2px, linear-gradient(blue, red), inline] + const args_delimiter = /\s*,\s*(?![^(]*\))/gm; const PROPERTY_LIST = [ "align-content", "align-items", @@ -349,6 +352,7 @@ "capitalize": "text-transform", "normal-case": "text-transform", "variant": "font-variant-numeric", + "wave-clip": "clip-path", }; const DEFAULT_VALUES = { "border": ["1px solid transparent"], @@ -379,7 +383,8 @@ "capitalize": "capitalize", "normal-case": "none", "radius": "sm", - "shadow": "1" + "shadow": "1", + "wave-clip": "50, 2, 50" }; const unit = v => number_regex.test(v) ? `calc(${v} * @unit-size)` : v; const positive_unit = v => positive_number_regex.test(v) ? `calc(${v} * @unit-size)` : v; @@ -413,6 +418,30 @@ return "9999"; return "0"; }; + const waveClipIds = new Set(); + const generateWave = (value, original, media, state, handler) => { + const args = value.split(args_delimiter).map(v => v.trim()).map(v => parseInt(v)); + let [amplitude, frequency, precision] = args; + amplitude = amplitude !== null && amplitude !== void 0 ? amplitude : 50; + frequency = frequency !== null && frequency !== void 0 ? frequency : 2; + precision = precision !== null && precision !== void 0 ? precision : 50; + const id = amplitude + '-' + frequency + '-' + precision; + if (waveClipIds.has(id)) { + return '@wave-clip-' + id; + } + waveClipIds.add(id); + const units = Math.PI * 2 * frequency; + const factor = precision / 100; + amplitude /= 2; + let polygon = 'polygon(100% 0%, 0% 0%'; + for (let i = 0; i <= precision; i++) { + const val = Math.abs((amplitude * Math.cos((i / precision) * units) - amplitude)).toFixed(2); + polygon += ', ' + (i / factor) + '% calc(100% - ' + val + 'px)'; + } + polygon += ')'; + handler.style.cssRules[0].style.setProperty('--wave-clip-' + id, polygon); + return '@wave-clip-' + id; + }; const VALUE_WRAPPER = { "img": v => `url(${v})`, "gradient": (value) => `linear-gradient(${value})`, @@ -479,7 +508,8 @@ "min-width": positive_unit, "max-width": positive_unit, "min-height": positive_unit, - "max-height": positive_unit + "max-height": positive_unit, + "wave-clip": generateWave, }; /* @@ -1228,7 +1258,7 @@ value = DEFAULT_VALUES[original] || ''; } if (VALUE_WRAPPER.hasOwnProperty(original)) { - value = VALUE_WRAPPER[original](value, original, media, state); + value = VALUE_WRAPPER[original](value, original, media, state, this); } if (!Array.isArray(value)) { value = Array(properties.length).fill(value.replace(VAR_REGEX, "var(--$1)")); diff --git a/dist/assembler.min.js b/dist/assembler.min.js index d2556c6..3761400 100644 --- a/dist/assembler.min.js +++ b/dist/assembler.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).AssemblerCSS={})}(this,(function(e){"use strict";const t=/^[0-9]+(\.5)?$/,r=/^-?[0-9]+(\.5)?$/,o=/^(xs|sm|base|lg|([2-9])?xl)$/,i=/^(none|tight|snug|normal|relaxed|loose)$/,s=/^[0-9]|1[0-9]|2[0-4]$/,n=/^[1-6]$/,a=/^(tighter|tight|normal|wide|wider|widest)$/,l=/^(xs|sm|md|lg|xl|pill)$/,p=/^(first|last|none)$/,c=["align-content","align-items","align-self","animation","appearance","backdrop-filter","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-position","background-repeat","background-size","backface-visibility","border","border-bottom","border-bottom-color","border-bottom-style","border-bottom-width","border-bottom-left-radius","border-bottom-right-radius","border-collapse","border-color","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-style","border-top","border-top-color","border-top-style","border-top-width","border-top-left-radius","border-top-right-radius","border-width","bottom","box-orient","box-shadow","box-sizing","clear","clip","clip-path","color","column-gap","content","cursor","display","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","font-family","font-size","font-style","font-weight","font-variant-numeric","gap","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","height","isolation","justify-content","justify-items","justify-self","left","letter-spacing","line-break","line-clamp","line-height","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","max-height","max-width","min-height","min-width","object-fit","object-position","opacity","order","outline","outline-offset","overflow","overflow-wrap","overflow-x","overflow-y","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y","padding","padding-bottom","padding-left","padding-right","padding-top","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","resize","right","row-gap","table-layout","text-align","text-decoration","text-decoration-style","text-fill-color","text-overflow","text-shadow","text-transform","top","transform","transform-box","transform-origin","transform-style","transition","user-select","vertical-align","visibility","white-space","width","word-break","z-index"],d={animation:["-webkit-animation"],appearance:["-webkit-appearance","-moz-appearance"],"background-clip":["-webkit-background-clip","-moz-background-clip"],"backdrop-filter":["-webkit-backdrop-filter"],"box-orient":["-webkit-box-orient"],"clip-path":["-webkit-clip-path"],"column-gap":["-moz-column-gap"],"line-clamp":["-webkit-line-clamp"],"user-select":["-webkit-user-select","-moz-user-select"],"text-fill-color":["-webkit-text-fill-color","-moz-text-fill-color"]},x=["normal","link","visited","empty","placeholder-shown","default","checked","indeterminate","valid","invalid","required","optional","out-of-range","in-range","hover","focus","focus-within","focus-visible","active","read-only","read-write","disabled","enabled"],m={backdrop:"backdrop-filter",bg:"background","bg-attachment":"background-attachment","bg-blend":"background-blend-mode","bg-clip":"background-clip","bg-color":"background-color","bg-image":"background-image","bg-position":"background-position","bg-repeat":"background-repeat","bg-size":"background-size",radius:"border-radius","radius-top":["border-top-left-radius","border-top-right-radius"],"radius-bottom":["border-bottom-left-radius","border-bottom-right-radius"],"radius-left":["border-bottom-left-radius","border-top-left-radius"],"radius-right":["border-bottom-right-radius","border-top-right-radius"],"radius-bl":"border-bottom-left-radius","radius-br":"border-bottom-right-radius","radius-tl":"border-top-left-radius","radius-tr":"border-top-right-radius",b:"border",bc:"border-color",bs:"border-style",bw:"border-width",bt:"border-top",bl:"border-left",br:"border-right",bb:"border-bottom","bt-color":"border-top-color","bt-style":"border-top-style","bt-width":"border-top-width","bl-color":"border-left-color","bl-style":"border-left-style","bl-width":"border-left-width","br-color":"border-right-color","br-style":"border-right-style","br-width":"border-right-width","bb-color":"border-bottom-color","bb-style":"border-bottom-style","bb-width":"border-bottom-width",m:"margin",mt:"margin-top",mb:"margin-bottom",ml:"margin-left",mr:"margin-right",mx:["margin-left","margin-right"],my:["margin-top","margin-bottom"],p:"padding",pt:"padding-top",pb:"padding-bottom",pl:"padding-left",pr:"padding-right",px:["padding-left","padding-right"],py:["padding-top","padding-bottom"],"min-w":"min-width","max-w":"max-width","min-h":"min-height","max-h":"max-height",w:"width",h:"height",img:"background-image",gradient:"background-image","radial-gradient":"background-image","conic-gradient":"background-image","flex-dir":"flex-direction","col-reverse":"flex-direction","row-reverse":"flex-direction","grid-rows":"grid-template-rows","grid-flow":"grid-auto-flow","row-start":"grid-row-start","row-span":"grid-row-end","grid-cols":"grid-template-columns","col-start":"grid-column-start","col-span":"grid-column-end","col-gap":"column-gap","auto-cols":"grid-auto-columns","auto-rows":"grid-auto-rows",e:"box-shadow",shadow:"box-shadow",overscroll:"overscroll-behavior","overscroll-x":"overscroll-behavior-x","overscroll-y":"overscroll-behavior-y",inset:["top","bottom","left","right"],"inset-x":["left","right"],"inset-y":["top","bottom"],z:"z-index",decoration:"text-decoration","v-align":"vertical-align",ws:"white-space",ring:"box-shadow",leading:"line-height",tracking:"letter-spacing",break:e=>"words"===e?["overflow-wrap"]:"all"===e?["word-break"]:["overflow-wrap","word-break"],truncate:["overflow","text-overflow","white-space"],flex:e=>e?"flex":"display","inline-flex":"display",grid:"display","inline-grid":"display",hidden:"display",block:"display","inline-block":"display",static:"position",fixed:"position",absolute:"position",relative:"position",sticky:"position",visible:"visibility",invisible:"visibility","flex-row":"flex-direction","flex-col":"flex-direction",list:e=>"inside"===e||"outside"===e?"list-style-position":"list-style-type",text:e=>o.test(e)?["font-size","line-height"]:"font-size",uppercase:"text-transform",lowercase:"text-transform",capitalize:"text-transform","normal-case":"text-transform",variant:"font-variant-numeric"},u={border:["1px solid transparent"],truncate:["hidden","ellipsis","nowrap"],flex:"flex","inline-flex":"inline-flex",grid:"grid","inline-grid":"inline-grid",hidden:"none",block:"block","inline-block":"inline-block",static:"static",fixed:"fixed",absolute:"absolute",relative:"relative",sticky:"sticky",visible:"visible",invisible:"hidden","flex-row":"row","flex-col":"column","flex-wrap":"wrap","flex-grow":"1","flex-shrink":"1","col-reverse":"column-reverse","row-reverse":"row-reverse",uppercase:"uppercase",lowercase:"lowercase",capitalize:"capitalize","normal-case":"none",radius:"sm",shadow:"1"},b=e=>r.test(e)?`calc(${e} * @unit-size)`:e,g=e=>t.test(e)?`calc(${e} * @unit-size)`:e,h=e=>`repeat(${e}, minmax(0, 1fr))`,f=e=>`span ${e}`,w=e=>l.test(e)?"@border-radius-"+e:e,y={img:e=>`url(${e})`,gradient:e=>`linear-gradient(${e})`,"radial-gradient":e=>`radial-gradient(${e})`,"conic-gradient":e=>`conic-gradient(${e})`,"grid-rows":h,"row-span":f,"grid-cols":h,"col-span":f,e:e=>s.test(e)?`@elevation-${e}`:e,shadow:e=>n.test(e)?`@shadow-${e}`:e,ring:e=>`0 0 0 ${e}`,"font-size":e=>o.test(e)?"@font-size-"+e:e,leading:e=>t.test(e)?`calc(${e} * @unit-size)`:i.test(e)?"@line-height-"+e:e,tracking:e=>a.test(e)?"@letter-spacing-"+e:e,text:e=>o.test(e)?["@font-size-"+e,"@font-size-leading-"+e]:e,radius:w,"radius-top":w,"radius-left":w,"radius-bottom":w,"radius-right":w,"radius-tl":w,"radius-bl":w,"radius-tr":w,"radius-br":w,"border-radius":w,break:e=>"all"===e?"break-all":"words"===e?"break-word":["normal","normal"],"flex-wrap":e=>"reverse"===e?"wrap-reverse":e,"flex-row":e=>"reverse"===e?"row-reverse":e,"flex-col":e=>"reverse"===e?"column-reverse":e,order:e=>p.test(e)?"first"===e?"-9999":"last"===e?"9999":"0":e,padding:g,"padding-top":g,"padding-bottom":g,"padding-left":g,"padding-right":g,p:g,pt:g,pb:g,pl:g,pr:g,px:g,py:g,margin:b,"margin-top":b,"margin-bottom":b,"margin-left":b,"margin-right":b,m:b,mt:b,mb:b,ml:b,mr:b,mx:b,my:b,w:g,h:g,width:g,height:g,"min-w":g,"max-w":g,"min-h":g,"max-h":g,"min-width":g,"max-width":g,"min-height":g,"max-height":g},v=["0px 0px 0px 0px","0px 2px 1px -1px","0px 3px 1px -2px","0px 3px 3px -2px","0px 2px 4px -1px","0px 3px 5px -1px","0px 3px 5px -1px","0px 4px 5px -2px","0px 5px 5px -3px","0px 5px 6px -3px","0px 6px 6px -3px","0px 6px 7px -4px","0px 7px 8px -4px","0px 7px 8px -4px","0px 7px 9px -4px","0px 8px 9px -5px","0px 8px 10px -5px","0px 8px 11px -5px","0px 9px 11px -5px","0px 9px 12px -6px","0px 10px 13px -6px","0px 10px 13px -6px","0px 10px 14px -6px","0px 11px 14px -7px","0px 11px 15px -7px"],k=["0px 0px 0px 0px","0px 1px 1px 0px","0px 2px 2px 0px","0px 3px 4px 0px","0px 4px 5px 0px","0px 5px 8px 0px","0px 6px 10px 0px","0px 7px 10px 1px","0px 8px 10px 1px","0px 9px 12px 1px","0px 10px 14px 1px","0px 11px 15px 1px","0px 12px 17px 2px","0px 13px 19px 2px","0px 14px 21px 2px","0px 15px 22px 2px","0px 16px 24px 2px","0px 17px 26px 2px","0px 18px 28px 2px","0px 19px 29px 2px","0px 20px 31px 3px","0px 21px 33px 3px","0px 22px 35px 3px","0px 23px 36px 3px","0px 24px 38px 3px"],$=["0px 0px 0px 0px","0px 1px 3px 0px","0px 1px 5px 0px","0px 1px 8px 0px","0px 1px 10px 0px","0px 1px 14px 0px","0px 1px 18px 0px","0px 2px 16px 1px","0px 3px 14px 2px","0px 3px 16px 2px","0px 4px 18px 3px","0px 4px 20px 3px","0px 5px 22px 4px","0px 5px 24px 4px","0px 5px 26px 4px","0px 6px 28px 5px","0px 6px 30px 5px","0px 6px 32px 5px","0px 7px 34px 6px","0px 7px 36px 6px","0px 8px 38px 7px","0px 8px 40px 7px","0px 8px 42px 7px","0px 9px 44px 8px","0px 9px 46px 8px"],S={none:"0",xs:"0.125rem",sm:"0.25rem",md:"0.5rem",lg:"0.75rem",xl:"1rem",pill:"9999px"},A={tighter:"-0.05rem",tight:"-0.025rem",normal:"0",wide:"0.025rem",wider:"0.05rem",widest:"0.1rem"},z={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},O={xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem","5xl":"3rem","6xl":"3.75rem","7xl":"4.5rem","8xl":"6rem","9xl":"8rem"},E={xs:"1rem",sm:"1.25rem",base:"1.5rem",lg:"1.75rem",xl:"1.75rem","2xl":"2rem","3xl":"2.25rem","4xl":"2.5rem","5xl":"1","6xl":"1","7xl":"1","8xl":"1","9xl":"1"},j={"sans-serif":"-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol",serif:"Georgia, Cambria, Times New Roman, Times, serif",monospace:"Lucida Console, Monaco, monospace"},C=["0px 2px 4px 0px hsla(0, 0%, 20%, 0.1), 0px 6px 6px -8px hsla(0, 0%, 0%, 15%)","0px 2px 8px -1px hsla(0, 0%, 20%, 0.1), 0px 16px 16px -12px hsla(0, 0%, 0%, 15%)","0px 2px 16px -2px hsla(0, 0%, 20%, 0.1), 0px 22px 18px -16px hsla(0, 0%, 0%, 15%)","0px 2px 20px -3px hsla(0, 0%, 20%, 0.1), 0px 28px 22px -18px hsla(0, 0%, 0%, 15%)","0px 2px 32px -2px hsla(0, 0%, 20%, 0.1), 0px 32px 26px -18px hsla(0, 0%, 0%, 15%)","0px 2px 36px -1px hsla(0, 0%, 20%, 0.1), 0px 42px 34px -24px hsla(0, 0%, 0%, 15%)"];function P(e){let t="--elevation-umbra: rgba(0, 0, 0, .2);--elevation-penumbra: rgba(0, 0, 0, .14);--elevation-ambient: rgba(0, 0, 0, .12);";for(let e=0;e<25;e++)t+=`--elevation-${e}:${v[e]} var(--elevation-umbra), ${k[e]} var(--elevation-penumbra), ${$[e]} var(--elevation-ambient);`;for(let e=0;e<6;e++)t+=`--shadow-${e+1}:${C[e]};`;for(const[e,r]of Object.entries(S))t+=`--border-radius-${e}:${r};`;for(const[e,r]of Object.entries(A))t+=`--letter-spacing-${e}:${r};`;for(const[e,r]of Object.entries(z))t+=`--line-height-${e}:${r};`;for(const[e,r]of Object.entries(j))t+=`--${e}:${r};`;for(const[e,r]of Object.entries(O))t+=`--font-size-${e}:${r};`;for(const[e,r]of Object.entries(E))t+=`--font-size-leading-${e}:${r};`;for(const r of e.breakpoints)"all"!==r&&(t+=`--breakpoint-${r}: ${e.media[r]};`);return t+="--unit-size:0.25rem;",":root{"+t+"}"}const R=/\\\n/g,I=/^--([a-zA-Z0-9-_]+)--(scope|mixin|register)$/;const M=new class{constructor(){this.cache=new Map,this.scopes=["","text-clip","selection","placeholder","before","after","first-letter","first-line","l1","l2","marker-l1","marker","sibling","child","even","odd","first","last","dark","light","landscape","portrait","motion-reduce","motion-safe"],this.registeredProperties=[];const{cache:e}=this;e.set("--text-clip--scope","$selector {-webkit-background-clip: text !important;-moz-background-clip:text !important;background-clip:text !important;}"),e.set("--l1--scope","$selector > * {$body}"),e.set("--l2--scope","$selector > * > * {$body}"),e.set("--sibling--scope","$selector > * + * {$body}"),e.set("--child--scope","$selector > $class {$body}"),e.set("--selection--scope","$selector::selection {$body}"),e.set("--placeholder--scope","$selector::placeholder {$body}"),e.set("--marker--scope","$selector::marker {$body}"),e.set("--marker-l1--scope","$selector > *::marker {$body}"),e.set("--before--scope","$selector::before {$body}"),e.set("--after--scope","$selector::after {$body}"),e.set("--even--scope","$selector:nth-child(even) {$body}"),e.set("--odd--scope","$selector:nth-child(odd) {$body}"),e.set("--first--scope","$selector:first-child {$body}"),e.set("--last--scope","$selector:last-child {$body}"),e.set("--first-letter--scope","$selector::first-letter {$body}"),e.set("--first-line--scope","$selector::first-line {$body}"),e.set("--dark--scope","@media(prefers-color-scheme: dark) {$selector {$body}}"),e.set("--light--scope","@media(prefers-color-scheme: light) {$selector {$body}}"),e.set("--landscape--scope","@media(orientation: landscape) {$selector {$body}}"),e.set("--portrait--scope","@media(orientation: portrait) {$selector {$body}}"),e.set("--motion-reduce--scope","@media(prefers-reduced-motion: reduce) {$selector {$body}}"),e.set("--motion-safe--scope","@media(prefers-reduced-motion: no-preference) {$selector {$body}}"),this.initialize()}initialize(){const{cache:e,scopes:t,registeredProperties:r}=this;for(const o of this.getComputedStyles())for(const i of o){const s=I.exec(i);if(null==s)continue;const n=s[1],a=this.getValue(o,i);switch(e.set(i,a),s[2]){case"scope":-1===t.indexOf(n)&&t.push(n);break;case"register":if("true"===a||""===a)r.push({name:n,aliases:[]});else{const e=a.split(",").map((e=>e.trim())).filter((e=>""!==e));r.push({name:n,aliases:e})}}}}getComputedStyles(){const e=[];for(let t=0,r=document.styleSheets.length;t[a-z]{2})\|)?(?:(?[-a-zA-Z0-9]+)!)?(?[-a-z]+)(?:\.(?[-a-z]+))?$/m;function N(e){const t=void 0===e.enabled||"true"===e.enabled,r=void 0!==e.generate&&"true"===e.generate,o=void 0===e.constructable||"true"===e.constructable,i=void 0!==e.mode&&"desktop-first"===e.mode,s=void 0===e.selectorAttribute?"class":e.selectorAttribute,n=void 0===e.cache?null:e.cache,a=void 0===e.cacheKey?"assembler-css-cache":e.cacheKey,l=M.getRegisteredProperties(),p=M.getRegisteredScopes();for(let e=0,t=l.length;e0&&(d[t.name]=t.aliases)}let x=["xs","sm","md","lg","xl"];i?(x.pop(),x.reverse()):x.shift(),x.unshift("all");const m=void 0===e.states?["normal","hover"]:function(e,t=!0){const r=e.replace(/[,;]/g," ").split(/\s\s*/g).map(T).filter(V);return t?r.filter(W):r}(e.states.toLowerCase());-1===m.indexOf("normal")&&m.unshift("normal");return{enabled:t,generate:r,constructable:o,cache:n,cacheKey:a,desktopFirst:i,scopes:p,states:m,breakpoints:x,media:{xs:e.breakpointXs||"512px",sm:e.breakpointSm||(i?"768px":"512px"),md:e.breakpointMd||(i?"1024px":"768px"),lg:e.breakpointLg||(i?"1280px":"1024px"),xl:e.breakpointXl||"1280px"},xStyleAttribute:e.xStyleAttribute||"x-style",selectorAttribute:s,registeredProperties:l}}function F(e){if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(F).join(";");const t=[];for(const r in e){const o=e[r];if(void 0===o)continue;const i=r.replace(_,"$1-$2").toLowerCase();t.push(null===o?i:i+":"+o)}return t.join(";")}function T(e){return e.trim()}function V(e){return""!==e}function W(e,t,r){return r.indexOf(e)===t}function U(e){if(e.cache){const t=localStorage.getItem(e.cacheKey+":"+e.cache);if(null!==t){const e=JSON.parse(t);return e.tracker=new Set(e.tracker),e}const r=localStorage.getItem(e.cacheKey);null!==r&&localStorage.removeItem(e.cacheKey+":"+r),localStorage.setItem(e.cacheKey,e.cache)}else{const t=localStorage.getItem(e.cacheKey);null!==t&&(localStorage.removeItem(e.cacheKey+":"+t),localStorage.removeItem(e.cacheKey))}const t=x.length,r=[],o=e.breakpoints,i=e.media,s=e.desktopFirst,n=e.states,a=new Set,l=e.selectorAttribute,p="class"===l?".asm\\#":"["+l+'~="'+"asm#",m="class"===l?"":'"]';r.push(P(e));for(let e=0,l=o.length;e0?l+"--":"")+o+(n>0?"__"+i[n]:"");a.add(c);let g=d[o],h="";if(g)for(let e=0,t=g.length;e0?":"+s:""}{${h}${o}:var(${b}) !important}`}}0!==e&&(u+="}"),r.push(u)}const u={content:r.join(""),tracker:a};return e.cache&&(localStorage.setItem(e.cacheKey,e.cache),localStorage.setItem(e.cacheKey+":"+e.cache,JSON.stringify({content:u.content,tracker:[...a]}))),u}let Z=null,H=null,B=null;const D=new WeakMap;function J(e,t){for(let r=e;null!=r;r=r.nextElementSibling)D.has(r)?J(r.firstElementChild,t):X(r,t)}function X(e,t){if(D.has(e))return;const r=e.attributes.getNamedItem(t.userSettings.xStyleAttribute);D.set(e,r?t.handleStyleChange(e,r.value,[]):[]),function(e,t){null===H&&(H=new MutationObserver((function(e){for(const r of e){const e=r.target;D.set(e,t.handleStyleChange(e,e.getAttribute(r.attributeName),D.get(e)))}}))),H.observe(e,{attributes:!0,attributeOldValue:!0,childList:!1,attributeFilter:[t.userSettings.xStyleAttribute]})}(e,t);for(let r=e.firstElementChild;null!=r;r=r.nextElementSibling)X(r,t)}const q=new Map,G=/\${([0-9]+)(?:=([^}]+))?}/g;function Y(e,t,r){return q.has(t)?F(q.get(t)(e.userSettings,...r)):F(((e,t,r)=>{if(t.startsWith(".")){if(null!==e.currentElement){const o="data-mixin-"+(t=t.substring(1));for(let t=e.currentElement.parentElement;null!=t;t=t.parentElement)if(t.hasAttribute(o))return t.getAttribute(o).replace(G,((e,t,o)=>r[parseInt(t)]||o||""))}return""}return M.getPropertyValue("--"+t+"--mixin").replace(G,((e,t,o)=>r[parseInt(t)]||o||""))})(e,t,r))}q.set("space-x",(function(e,t,r){return"true"===r?`sibling!mr:${t||"0"}`:`sibling!ml:${t||"0"}`})),q.set("space-y",(function(e,t,r){return"true"===r?`sibling!mb:${t||"0"}`:`sibling!mt:${t||"0"}`})),q.set("grid",(function(){return"grid; l1!wb:break-all; l2!max-w:100%; child!justify-self:normal; child!align-self:normal"})),q.set("stack",(function(){return'grid; grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr); \n grid-template-areas:"stackarea"; l1!grid-area:stackarea; l1!z:0; w:100%; h:100%'})),q.set("sr-only",(function(){return"absolute; w:1px; h:1px; p:0; m:-1px; bw:0; overflow:hidden; clip:rect(0, 0, 0, 0); left:-9999px"})),q.set("container",(function(e){return e.desktopFirst?"px: 1rem; mx:auto; max-w:@breakpoint-lg; lg|max-w:@breakpoint-md; md|max-w:@breakpoint-sm; sm|max-w:@breakpoint-xs; xs|max-w:100%":"px: 1rem; mx:auto; max-w:100%; sm|max-w:@breakpoint-sm; md|max-w:@breakpoint-md; lg|max-w:@breakpoint-lg; xl|max-w:@breakpoint-xl"}));const Q=/@([a-zA-Z0-9\-_]+)/g,ee=/\$(selector|body|class|value|property|state|variants|var)/g,te=/;/,re=/\s*,\s*(?![^(]*\))/gm;class oe{constructor(e,t,r){this._currentElement=null,this.style=t,this.settings=e,this.tracker=r,this.mediaSettings=e.media,this.desktopFirst=e.desktopFirst,this.breakpoints=e.breakpoints,this.rules=[],this.padding=t.cssRules.length,this.selectorAttribute=e.selectorAttribute}get userSettings(){return this.settings}get currentElement(){return this._currentElement}handleStyleChange(e,t,r){if(this._currentElement=e,null===t)return this.handleStyleRemoved(e,r);const o=this.getStyleEntries(t),i=e.hasAttribute(this.selectorAttribute)?e.getAttribute(this.selectorAttribute).split(" "):[],s=[];for(const{n:t,p:s,e:n}of r)if(!o.has(t)){const t=i.indexOf(n);t>=0&&i.splice(t,1),e.style.removeProperty(s)}for(const t of o.values()){const{entry:r,property:o,hash:n,value:a,name:l}=t;i.indexOf(r)<0&&i.push(r),this.tracker.has(n)||this.generateCSS(t),e.style.setProperty(o,a),s.push({e:r,n:l,p:o})}return e.setAttribute(this.selectorAttribute,i.join(" ")),this._currentElement=null,s}handleStyleRemoved(e,t){this._currentElement=null;const r=e.hasAttribute(this.selectorAttribute)?e.getAttribute(this.selectorAttribute).split(" "):[];for(const{p:o,e:i}of t){const t=r.indexOf(i);t>=0&&r.splice(t,1),e.style.removeProperty(o)}return e.setAttribute(this.selectorAttribute,r.join(" ")),[]}extract(e,t=null){var r;const o=null===(r=K.exec(e))||void 0===r?void 0:r.groups;if(!o||!o.property)return[];const i=this.breakpoints.indexOf(o.media||"all"),s=x.indexOf(o.state||"normal");if(i<0||s<0)return[];let n=o.property;const a=n,l=this.settings.scopes;m.hasOwnProperty(n)&&(n=m[n],"function"==typeof n&&(n=n(t))),Array.isArray(n)||(n=[n]),null===t&&(t=u[a]||""),y.hasOwnProperty(a)&&(t=y[a](t,a,i,s)),t=Array.isArray(t)?t.map((e=>e.replace(Q,"var(--$1)"))):Array(n.length).fill(t.replace(Q,"var(--$1)"));const p=[],d=x.length;let b=-1;for(const e of n){b++;const r=c.indexOf(e);if(r<0)continue;const n=o.scope||"",a=(r*d+i)*d+s,x=a.toString(16)+(n?`-${n}`:""),m=1e5*l.indexOf(n),u=(o.media?o.media+"--":"")+(n?n+"__":"")+e+(o.state?"__"+o.state:"");p.push({name:(o.media?o.media+"|":"")+(n?n+"!":"")+e+(o.state?"."+o.state:""),property:L+u,entry:"asm#"+x,value:t[b],media:o.media||"",state:o.state||"",cssProperty:e,hash:x,scope:n,rank:m<0?-1:a+m})}return p}getStyleEntries(e){const t=new Map;for(let r of this.getResolvedProperties(e)){let e=null;const o=r.indexOf(":");o>=0&&(e=r.substr(o+1),r=r.substr(0,o).trim());for(const o of this.extract(r,e))t.set(o.name,o)}return t}getResolvedProperties(e,t=[]){const r=[];for(let o of e.split(te))if(o=o.trim(),""!==o)if(o.startsWith("^")){const e=o.indexOf(":");let i,s;if(e<0?(i=o.substr(1),s=[]):(i=o.substr(1,e-1),s=o.substr(e+1).split(re).map(T)),t.indexOf(i)>=0)throw t.push(i),new Error("Recursive mixin detected: "+t.join("->"));t.push(i),r.push(...this.getResolvedProperties(Y(this,i,s),t)),t.pop()}else r.push(o);return r}generateCSS(e){const{tracker:t,mediaSettings:r,desktopFirst:o,style:i}=this,{hash:s,media:n,state:a,cssProperty:l,property:p,scope:c,rank:x}=e,m=""!==n,u=this.settings.selectorAttribute,b="class"===u?".asm\\#":"["+u+'~="'+"asm#",g="class"===u?"":'"]';if(t.add(s),x<0)return;let h="";m&&(h+=o?`@media only screen and (max-width: ${r[n]}) {`:`@media only screen and (min-width: ${r[n]}) {`);let f=d[l],w="";if(f)for(let e=0,t=f.length;e{switch(t){case"selector":return`${b+s+g}${a?":"+a:""}`;case"body":return w+l+": var("+p+") !important";case"variants":return w;case"property":return l;case"value":return`var(${p})`;case"class":return b+s+g;case"state":return a?":"+a:"";case"var":return p}return t}))}else h+=`${b+s+g}${a?":"+a:""}{${w}${l}: var(${p}) !important}`;m&&(h+="}");const y=this.getRuleIndex(x);this.rules.splice(y,0,x);try{i.insertRule(h,this.padding+y)}catch(e){this.rules.splice(y,1),console.warn("Unsupported rule:",h)}}getRuleIndex(e){const{rules:t}=this;for(let r=0,o=t.length;r"words"===e?["overflow-wrap"]:"all"===e?["word-break"]:["overflow-wrap","word-break"],truncate:["overflow","text-overflow","white-space"],flex:e=>e?"flex":"display","inline-flex":"display",grid:"display","inline-grid":"display",hidden:"display",block:"display","inline-block":"display",static:"position",fixed:"position",absolute:"position",relative:"position",sticky:"position",visible:"visibility",invisible:"visibility","flex-row":"flex-direction","flex-col":"flex-direction",list:e=>"inside"===e||"outside"===e?"list-style-position":"list-style-type",text:e=>o.test(e)?["font-size","line-height"]:"font-size",uppercase:"text-transform",lowercase:"text-transform",capitalize:"text-transform","normal-case":"text-transform",variant:"font-variant-numeric","wave-clip":"clip-path"},b={border:["1px solid transparent"],truncate:["hidden","ellipsis","nowrap"],flex:"flex","inline-flex":"inline-flex",grid:"grid","inline-grid":"inline-grid",hidden:"none",block:"block","inline-block":"inline-block",static:"static",fixed:"fixed",absolute:"absolute",relative:"relative",sticky:"sticky",visible:"visible",invisible:"hidden","flex-row":"row","flex-col":"column","flex-wrap":"wrap","flex-grow":"1","flex-shrink":"1","col-reverse":"column-reverse","row-reverse":"row-reverse",uppercase:"uppercase",lowercase:"lowercase",capitalize:"capitalize","normal-case":"none",radius:"sm",shadow:"1","wave-clip":"50, 2, 50"},g=e=>r.test(e)?`calc(${e} * @unit-size)`:e,h=e=>t.test(e)?`calc(${e} * @unit-size)`:e,f=e=>`repeat(${e}, minmax(0, 1fr))`,w=e=>`span ${e}`,y=e=>a.test(e)?"@border-radius-"+e:e,v=new Set,k={img:e=>`url(${e})`,gradient:e=>`linear-gradient(${e})`,"radial-gradient":e=>`radial-gradient(${e})`,"conic-gradient":e=>`conic-gradient(${e})`,"grid-rows":f,"row-span":w,"grid-cols":f,"col-span":w,e:e=>s.test(e)?`@elevation-${e}`:e,shadow:e=>n.test(e)?`@shadow-${e}`:e,ring:e=>`0 0 0 ${e}`,"font-size":e=>o.test(e)?"@font-size-"+e:e,leading:e=>t.test(e)?`calc(${e} * @unit-size)`:i.test(e)?"@line-height-"+e:e,tracking:e=>l.test(e)?"@letter-spacing-"+e:e,text:e=>o.test(e)?["@font-size-"+e,"@font-size-leading-"+e]:e,radius:y,"radius-top":y,"radius-left":y,"radius-bottom":y,"radius-right":y,"radius-tl":y,"radius-bl":y,"radius-tr":y,"radius-br":y,"border-radius":y,break:e=>"all"===e?"break-all":"words"===e?"break-word":["normal","normal"],"flex-wrap":e=>"reverse"===e?"wrap-reverse":e,"flex-row":e=>"reverse"===e?"row-reverse":e,"flex-col":e=>"reverse"===e?"column-reverse":e,order:e=>p.test(e)?"first"===e?"-9999":"last"===e?"9999":"0":e,padding:h,"padding-top":h,"padding-bottom":h,"padding-left":h,"padding-right":h,p:h,pt:h,pb:h,pl:h,pr:h,px:h,py:h,margin:g,"margin-top":g,"margin-bottom":g,"margin-left":g,"margin-right":g,m:g,mt:g,mb:g,ml:g,mr:g,mx:g,my:g,w:h,h:h,width:h,height:h,"min-w":h,"max-w":h,"min-h":h,"max-h":h,"min-width":h,"max-width":h,"min-height":h,"max-height":h,"wave-clip":(e,t,r,o,i)=>{const s=e.split(c).map((e=>e.trim())).map((e=>parseInt(e)));let[n,l,a]=s;n=null!=n?n:50,l=null!=l?l:2,a=null!=a?a:50;const p=n+"-"+l+"-"+a;if(v.has(p))return"@wave-clip-"+p;v.add(p);const d=2*Math.PI*l,x=a/100;n/=2;let m="polygon(100% 0%, 0% 0%";for(let e=0;e<=a;e++){m+=", "+e/x+"% calc(100% - "+Math.abs(n*Math.cos(e/a*d)-n).toFixed(2)+"px)"}return m+=")",i.style.cssRules[0].style.setProperty("--wave-clip-"+p,m),"@wave-clip-"+p}},$=["0px 0px 0px 0px","0px 2px 1px -1px","0px 3px 1px -2px","0px 3px 3px -2px","0px 2px 4px -1px","0px 3px 5px -1px","0px 3px 5px -1px","0px 4px 5px -2px","0px 5px 5px -3px","0px 5px 6px -3px","0px 6px 6px -3px","0px 6px 7px -4px","0px 7px 8px -4px","0px 7px 8px -4px","0px 7px 9px -4px","0px 8px 9px -5px","0px 8px 10px -5px","0px 8px 11px -5px","0px 9px 11px -5px","0px 9px 12px -6px","0px 10px 13px -6px","0px 10px 13px -6px","0px 10px 14px -6px","0px 11px 14px -7px","0px 11px 15px -7px"],S=["0px 0px 0px 0px","0px 1px 1px 0px","0px 2px 2px 0px","0px 3px 4px 0px","0px 4px 5px 0px","0px 5px 8px 0px","0px 6px 10px 0px","0px 7px 10px 1px","0px 8px 10px 1px","0px 9px 12px 1px","0px 10px 14px 1px","0px 11px 15px 1px","0px 12px 17px 2px","0px 13px 19px 2px","0px 14px 21px 2px","0px 15px 22px 2px","0px 16px 24px 2px","0px 17px 26px 2px","0px 18px 28px 2px","0px 19px 29px 2px","0px 20px 31px 3px","0px 21px 33px 3px","0px 22px 35px 3px","0px 23px 36px 3px","0px 24px 38px 3px"],A=["0px 0px 0px 0px","0px 1px 3px 0px","0px 1px 5px 0px","0px 1px 8px 0px","0px 1px 10px 0px","0px 1px 14px 0px","0px 1px 18px 0px","0px 2px 16px 1px","0px 3px 14px 2px","0px 3px 16px 2px","0px 4px 18px 3px","0px 4px 20px 3px","0px 5px 22px 4px","0px 5px 24px 4px","0px 5px 26px 4px","0px 6px 28px 5px","0px 6px 30px 5px","0px 6px 32px 5px","0px 7px 34px 6px","0px 7px 36px 6px","0px 8px 38px 7px","0px 8px 40px 7px","0px 8px 42px 7px","0px 9px 44px 8px","0px 9px 46px 8px"],z={none:"0",xs:"0.125rem",sm:"0.25rem",md:"0.5rem",lg:"0.75rem",xl:"1rem",pill:"9999px"},O={tighter:"-0.05rem",tight:"-0.025rem",normal:"0",wide:"0.025rem",wider:"0.05rem",widest:"0.1rem"},E={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2"},P={xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem","4xl":"2.25rem","5xl":"3rem","6xl":"3.75rem","7xl":"4.5rem","8xl":"6rem","9xl":"8rem"},j={xs:"1rem",sm:"1.25rem",base:"1.5rem",lg:"1.75rem",xl:"1.75rem","2xl":"2rem","3xl":"2.25rem","4xl":"2.5rem","5xl":"1","6xl":"1","7xl":"1","8xl":"1","9xl":"1"},C={"sans-serif":"-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol",serif:"Georgia, Cambria, Times New Roman, Times, serif",monospace:"Lucida Console, Monaco, monospace"},R=["0px 2px 4px 0px hsla(0, 0%, 20%, 0.1), 0px 6px 6px -8px hsla(0, 0%, 0%, 15%)","0px 2px 8px -1px hsla(0, 0%, 20%, 0.1), 0px 16px 16px -12px hsla(0, 0%, 0%, 15%)","0px 2px 16px -2px hsla(0, 0%, 20%, 0.1), 0px 22px 18px -16px hsla(0, 0%, 0%, 15%)","0px 2px 20px -3px hsla(0, 0%, 20%, 0.1), 0px 28px 22px -18px hsla(0, 0%, 0%, 15%)","0px 2px 32px -2px hsla(0, 0%, 20%, 0.1), 0px 32px 26px -18px hsla(0, 0%, 0%, 15%)","0px 2px 36px -1px hsla(0, 0%, 20%, 0.1), 0px 42px 34px -24px hsla(0, 0%, 0%, 15%)"];function I(e){let t="--elevation-umbra: rgba(0, 0, 0, .2);--elevation-penumbra: rgba(0, 0, 0, .14);--elevation-ambient: rgba(0, 0, 0, .12);";for(let e=0;e<25;e++)t+=`--elevation-${e}:${$[e]} var(--elevation-umbra), ${S[e]} var(--elevation-penumbra), ${A[e]} var(--elevation-ambient);`;for(let e=0;e<6;e++)t+=`--shadow-${e+1}:${R[e]};`;for(const[e,r]of Object.entries(z))t+=`--border-radius-${e}:${r};`;for(const[e,r]of Object.entries(O))t+=`--letter-spacing-${e}:${r};`;for(const[e,r]of Object.entries(E))t+=`--line-height-${e}:${r};`;for(const[e,r]of Object.entries(C))t+=`--${e}:${r};`;for(const[e,r]of Object.entries(P))t+=`--font-size-${e}:${r};`;for(const[e,r]of Object.entries(j))t+=`--font-size-leading-${e}:${r};`;for(const r of e.breakpoints)"all"!==r&&(t+=`--breakpoint-${r}: ${e.media[r]};`);return t+="--unit-size:0.25rem;",":root{"+t+"}"}const M=/\\\n/g,_=/^--([a-zA-Z0-9-_]+)--(scope|mixin|register)$/;const L=new class{constructor(){this.cache=new Map,this.scopes=["","text-clip","selection","placeholder","before","after","first-letter","first-line","l1","l2","marker-l1","marker","sibling","child","even","odd","first","last","dark","light","landscape","portrait","motion-reduce","motion-safe"],this.registeredProperties=[];const{cache:e}=this;e.set("--text-clip--scope","$selector {-webkit-background-clip: text !important;-moz-background-clip:text !important;background-clip:text !important;}"),e.set("--l1--scope","$selector > * {$body}"),e.set("--l2--scope","$selector > * > * {$body}"),e.set("--sibling--scope","$selector > * + * {$body}"),e.set("--child--scope","$selector > $class {$body}"),e.set("--selection--scope","$selector::selection {$body}"),e.set("--placeholder--scope","$selector::placeholder {$body}"),e.set("--marker--scope","$selector::marker {$body}"),e.set("--marker-l1--scope","$selector > *::marker {$body}"),e.set("--before--scope","$selector::before {$body}"),e.set("--after--scope","$selector::after {$body}"),e.set("--even--scope","$selector:nth-child(even) {$body}"),e.set("--odd--scope","$selector:nth-child(odd) {$body}"),e.set("--first--scope","$selector:first-child {$body}"),e.set("--last--scope","$selector:last-child {$body}"),e.set("--first-letter--scope","$selector::first-letter {$body}"),e.set("--first-line--scope","$selector::first-line {$body}"),e.set("--dark--scope","@media(prefers-color-scheme: dark) {$selector {$body}}"),e.set("--light--scope","@media(prefers-color-scheme: light) {$selector {$body}}"),e.set("--landscape--scope","@media(orientation: landscape) {$selector {$body}}"),e.set("--portrait--scope","@media(orientation: portrait) {$selector {$body}}"),e.set("--motion-reduce--scope","@media(prefers-reduced-motion: reduce) {$selector {$body}}"),e.set("--motion-safe--scope","@media(prefers-reduced-motion: no-preference) {$selector {$body}}"),this.initialize()}initialize(){const{cache:e,scopes:t,registeredProperties:r}=this;for(const o of this.getComputedStyles())for(const i of o){const s=_.exec(i);if(null==s)continue;const n=s[1],l=this.getValue(o,i);switch(e.set(i,l),s[2]){case"scope":-1===t.indexOf(n)&&t.push(n);break;case"register":if("true"===l||""===l)r.push({name:n,aliases:[]});else{const e=l.split(",").map((e=>e.trim())).filter((e=>""!==e));r.push({name:n,aliases:e})}}}}getComputedStyles(){const e=[];for(let t=0,r=document.styleSheets.length;t[a-z]{2})\|)?(?:(?[-a-zA-Z0-9]+)!)?(?[-a-z]+)(?:\.(?[-a-z]+))?$/m;function T(e){const t=void 0===e.enabled||"true"===e.enabled,r=void 0!==e.generate&&"true"===e.generate,o=void 0===e.constructable||"true"===e.constructable,i=void 0!==e.mode&&"desktop-first"===e.mode,s=void 0===e.selectorAttribute?"class":e.selectorAttribute,n=void 0===e.cache?null:e.cache,l=void 0===e.cacheKey?"assembler-css-cache":e.cacheKey,a=L.getRegisteredProperties(),p=L.getRegisteredScopes();for(let e=0,t=a.length;e0&&(x[t.name]=t.aliases)}let c=["xs","sm","md","lg","xl"];i?(c.pop(),c.reverse()):c.shift(),c.unshift("all");const m=void 0===e.states?["normal","hover"]:function(e,t=!0){const r=e.replace(/[,;]/g," ").split(/\s\s*/g).map(W).filter(U);return t?r.filter(Z):r}(e.states.toLowerCase());-1===m.indexOf("normal")&&m.unshift("normal");return{enabled:t,generate:r,constructable:o,cache:n,cacheKey:l,desktopFirst:i,scopes:p,states:m,breakpoints:c,media:{xs:e.breakpointXs||"512px",sm:e.breakpointSm||(i?"768px":"512px"),md:e.breakpointMd||(i?"1024px":"768px"),lg:e.breakpointLg||(i?"1280px":"1024px"),xl:e.breakpointXl||"1280px"},xStyleAttribute:e.xStyleAttribute||"x-style",selectorAttribute:s,registeredProperties:a}}function V(e){if("string"==typeof e)return e.trim();if(Array.isArray(e))return e.map(V).join(";");const t=[];for(const r in e){const o=e[r];if(void 0===o)continue;const i=r.replace(K,"$1-$2").toLowerCase();t.push(null===o?i:i+":"+o)}return t.join(";")}function W(e){return e.trim()}function U(e){return""!==e}function Z(e,t,r){return r.indexOf(e)===t}function H(e){if(e.cache){const t=localStorage.getItem(e.cacheKey+":"+e.cache);if(null!==t){const e=JSON.parse(t);return e.tracker=new Set(e.tracker),e}const r=localStorage.getItem(e.cacheKey);null!==r&&localStorage.removeItem(e.cacheKey+":"+r),localStorage.setItem(e.cacheKey,e.cache)}else{const t=localStorage.getItem(e.cacheKey);null!==t&&(localStorage.removeItem(e.cacheKey+":"+t),localStorage.removeItem(e.cacheKey))}const t=m.length,r=[],o=e.breakpoints,i=e.media,s=e.desktopFirst,n=e.states,l=new Set,a=e.selectorAttribute,p="class"===a?".asm\\#":"["+a+'~="'+"asm#",c="class"===a?"":'"]';r.push(I(e));for(let e=0,a=o.length;e0?a+"--":"")+o+(n>0?"__"+i[n]:"");l.add(d);let g=x[o],h="";if(g)for(let e=0,t=g.length;e0?":"+s:""}{${h}${o}:var(${b}) !important}`}}0!==e&&(u+="}"),r.push(u)}const u={content:r.join(""),tracker:l};return e.cache&&(localStorage.setItem(e.cacheKey,e.cache),localStorage.setItem(e.cacheKey+":"+e.cache,JSON.stringify({content:u.content,tracker:[...l]}))),u}let B=null,D=null,J=null;const X=new WeakMap;function q(e,t){for(let r=e;null!=r;r=r.nextElementSibling)X.has(r)?q(r.firstElementChild,t):G(r,t)}function G(e,t){if(X.has(e))return;const r=e.attributes.getNamedItem(t.userSettings.xStyleAttribute);X.set(e,r?t.handleStyleChange(e,r.value,[]):[]),function(e,t){null===D&&(D=new MutationObserver((function(e){for(const r of e){const e=r.target;X.set(e,t.handleStyleChange(e,e.getAttribute(r.attributeName),X.get(e)))}}))),D.observe(e,{attributes:!0,attributeOldValue:!0,childList:!1,attributeFilter:[t.userSettings.xStyleAttribute]})}(e,t);for(let r=e.firstElementChild;null!=r;r=r.nextElementSibling)G(r,t)}const Y=new Map,Q=/\${([0-9]+)(?:=([^}]+))?}/g;function ee(e,t,r){return Y.has(t)?V(Y.get(t)(e.userSettings,...r)):V(((e,t,r)=>{if(t.startsWith(".")){if(null!==e.currentElement){const o="data-mixin-"+(t=t.substring(1));for(let t=e.currentElement.parentElement;null!=t;t=t.parentElement)if(t.hasAttribute(o))return t.getAttribute(o).replace(Q,((e,t,o)=>r[parseInt(t)]||o||""))}return""}return L.getPropertyValue("--"+t+"--mixin").replace(Q,((e,t,o)=>r[parseInt(t)]||o||""))})(e,t,r))}Y.set("space-x",(function(e,t,r){return"true"===r?`sibling!mr:${t||"0"}`:`sibling!ml:${t||"0"}`})),Y.set("space-y",(function(e,t,r){return"true"===r?`sibling!mb:${t||"0"}`:`sibling!mt:${t||"0"}`})),Y.set("grid",(function(){return"grid; l1!wb:break-all; l2!max-w:100%; child!justify-self:normal; child!align-self:normal"})),Y.set("stack",(function(){return'grid; grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr); \n grid-template-areas:"stackarea"; l1!grid-area:stackarea; l1!z:0; w:100%; h:100%'})),Y.set("sr-only",(function(){return"absolute; w:1px; h:1px; p:0; m:-1px; bw:0; overflow:hidden; clip:rect(0, 0, 0, 0); left:-9999px"})),Y.set("container",(function(e){return e.desktopFirst?"px: 1rem; mx:auto; max-w:@breakpoint-lg; lg|max-w:@breakpoint-md; md|max-w:@breakpoint-sm; sm|max-w:@breakpoint-xs; xs|max-w:100%":"px: 1rem; mx:auto; max-w:100%; sm|max-w:@breakpoint-sm; md|max-w:@breakpoint-md; lg|max-w:@breakpoint-lg; xl|max-w:@breakpoint-xl"}));const te=/@([a-zA-Z0-9\-_]+)/g,re=/\$(selector|body|class|value|property|state|variants|var)/g,oe=/;/,ie=/\s*,\s*(?![^(]*\))/gm;class se{constructor(e,t,r){this._currentElement=null,this.style=t,this.settings=e,this.tracker=r,this.mediaSettings=e.media,this.desktopFirst=e.desktopFirst,this.breakpoints=e.breakpoints,this.rules=[],this.padding=t.cssRules.length,this.selectorAttribute=e.selectorAttribute}get userSettings(){return this.settings}get currentElement(){return this._currentElement}handleStyleChange(e,t,r){if(this._currentElement=e,null===t)return this.handleStyleRemoved(e,r);const o=this.getStyleEntries(t),i=e.hasAttribute(this.selectorAttribute)?e.getAttribute(this.selectorAttribute).split(" "):[],s=[];for(const{n:t,p:s,e:n}of r)if(!o.has(t)){const t=i.indexOf(n);t>=0&&i.splice(t,1),e.style.removeProperty(s)}for(const t of o.values()){const{entry:r,property:o,hash:n,value:l,name:a}=t;i.indexOf(r)<0&&i.push(r),this.tracker.has(n)||this.generateCSS(t),e.style.setProperty(o,l),s.push({e:r,n:a,p:o})}return e.setAttribute(this.selectorAttribute,i.join(" ")),this._currentElement=null,s}handleStyleRemoved(e,t){this._currentElement=null;const r=e.hasAttribute(this.selectorAttribute)?e.getAttribute(this.selectorAttribute).split(" "):[];for(const{p:o,e:i}of t){const t=r.indexOf(i);t>=0&&r.splice(t,1),e.style.removeProperty(o)}return e.setAttribute(this.selectorAttribute,r.join(" ")),[]}extract(e,t=null){var r;const o=null===(r=F.exec(e))||void 0===r?void 0:r.groups;if(!o||!o.property)return[];const i=this.breakpoints.indexOf(o.media||"all"),s=m.indexOf(o.state||"normal");if(i<0||s<0)return[];let n=o.property;const l=n,a=this.settings.scopes;u.hasOwnProperty(n)&&(n=u[n],"function"==typeof n&&(n=n(t))),Array.isArray(n)||(n=[n]),null===t&&(t=b[l]||""),k.hasOwnProperty(l)&&(t=k[l](t,l,i,s,this)),t=Array.isArray(t)?t.map((e=>e.replace(te,"var(--$1)"))):Array(n.length).fill(t.replace(te,"var(--$1)"));const p=[],c=m.length;let x=-1;for(const e of n){x++;const r=d.indexOf(e);if(r<0)continue;const n=o.scope||"",l=(r*c+i)*c+s,m=l.toString(16)+(n?`-${n}`:""),u=1e5*a.indexOf(n),b=(o.media?o.media+"--":"")+(n?n+"__":"")+e+(o.state?"__"+o.state:"");p.push({name:(o.media?o.media+"|":"")+(n?n+"!":"")+e+(o.state?"."+o.state:""),property:N+b,entry:"asm#"+m,value:t[x],media:o.media||"",state:o.state||"",cssProperty:e,hash:m,scope:n,rank:u<0?-1:l+u})}return p}getStyleEntries(e){const t=new Map;for(let r of this.getResolvedProperties(e)){let e=null;const o=r.indexOf(":");o>=0&&(e=r.substr(o+1),r=r.substr(0,o).trim());for(const o of this.extract(r,e))t.set(o.name,o)}return t}getResolvedProperties(e,t=[]){const r=[];for(let o of e.split(oe))if(o=o.trim(),""!==o)if(o.startsWith("^")){const e=o.indexOf(":");let i,s;if(e<0?(i=o.substr(1),s=[]):(i=o.substr(1,e-1),s=o.substr(e+1).split(ie).map(W)),t.indexOf(i)>=0)throw t.push(i),new Error("Recursive mixin detected: "+t.join("->"));t.push(i),r.push(...this.getResolvedProperties(ee(this,i,s),t)),t.pop()}else r.push(o);return r}generateCSS(e){const{tracker:t,mediaSettings:r,desktopFirst:o,style:i}=this,{hash:s,media:n,state:l,cssProperty:a,property:p,scope:c,rank:d}=e,m=""!==n,u=this.settings.selectorAttribute,b="class"===u?".asm\\#":"["+u+'~="'+"asm#",g="class"===u?"":'"]';if(t.add(s),d<0)return;let h="";m&&(h+=o?`@media only screen and (max-width: ${r[n]}) {`:`@media only screen and (min-width: ${r[n]}) {`);let f=x[a],w="";if(f)for(let e=0,t=f.length;e{switch(t){case"selector":return`${b+s+g}${l?":"+l:""}`;case"body":return w+a+": var("+p+") !important";case"variants":return w;case"property":return a;case"value":return`var(${p})`;case"class":return b+s+g;case"state":return l?":"+l:"";case"var":return p}return t}))}else h+=`${b+s+g}${l?":"+l:""}{${w}${a}: var(${p}) !important}`;m&&(h+="}");const y=this.getRuleIndex(d);this.rules.splice(y,0,d);try{i.insertRule(h,this.padding+y)}catch(e){this.rules.splice(y,1),console.warn("Unsupported rule:",h)}}getRuleIndex(e){const{rules:t}=this;for(let r=0,o=t.length;r [2px, linear-gradient(blue, red), inline] +const args_delimiter = /\s*,\s*(?![^(]*\))/gm; + export const PROPERTY_LIST = [ "align-content", "align-items", @@ -353,6 +359,7 @@ export const ALIASES = { "capitalize": "text-transform", "normal-case": "text-transform", "variant": "font-variant-numeric", + "wave-clip": "clip-path", }; export const DEFAULT_VALUES = { "border": ["1px solid transparent"], @@ -383,7 +390,8 @@ export const DEFAULT_VALUES = { "capitalize": "capitalize", "normal-case": "none", "radius": "sm", - "shadow": "1" + "shadow": "1", + "wave-clip": "50, 2, 50" } const unit = v => number_regex.test(v) ? `calc(${v} * @unit-size)` : v; @@ -415,6 +423,35 @@ const orderCallback = v => { return "0"; } +const waveClipIds = new Set(); +const generateWave = (value: string, original: string, media: string, state: string, handler: StyleHandler) => { + const args = value.split(args_delimiter).map(v => v.trim()).map(v => parseInt(v)); + let [amplitude, frequency, precision] = args; + + amplitude = amplitude ?? 50; + frequency = frequency ?? 2; + precision = precision ?? 50; + + const id = amplitude + '-' + frequency + '-' + precision; + if (waveClipIds.has(id)) { + return '@wave-clip-' + id; + } + + waveClipIds.add(id); + const units = Math.PI * 2 * frequency; + const factor = precision / 100; + amplitude /= 2; + + let polygon = 'polygon(100% 0%, 0% 0%'; + for (let i = 0; i <= precision; i++) { + const val = Math.abs((amplitude * Math.cos((i / precision) * units) - amplitude)).toFixed(2); + polygon += ', ' + (i / factor) + '% calc(100% - ' + val + 'px)'; + } + polygon += ')'; + (handler.style.cssRules[0] as CSSStyleRule).style.setProperty('--wave-clip-' + id, polygon); + return '@wave-clip-' + id; +} + export const VALUE_WRAPPER = { "img": v => `url(${v})`, "gradient": (value) => `linear-gradient(${value})`, @@ -481,5 +518,6 @@ export const VALUE_WRAPPER = { "min-width": positive_unit, "max-width": positive_unit, "min-height": positive_unit, - "max-height": positive_unit + "max-height": positive_unit, + "wave-clip": generateWave, }; diff --git a/types/list.d.ts b/types/list.d.ts index e0e045d..a7e3c61 100644 --- a/types/list.d.ts +++ b/types/list.d.ts @@ -1,3 +1,4 @@ +import type StyleHandler from "./StyleHandler"; export declare const PROPERTY_LIST: string[]; export declare const PROPERTY_VARIANTS: { animation: string[]; @@ -129,6 +130,7 @@ export declare const ALIASES: { capitalize: string; "normal-case": string; variant: string; + "wave-clip": string; }; export declare const DEFAULT_VALUES: { border: string[]; @@ -160,6 +162,7 @@ export declare const DEFAULT_VALUES: { "normal-case": string; radius: string; shadow: string; + "wave-clip": string; }; export declare const VALUE_WRAPPER: { img: (v: any) => string; @@ -228,4 +231,5 @@ export declare const VALUE_WRAPPER: { "max-width": (v: any) => any; "min-height": (v: any) => any; "max-height": (v: any) => any; + "wave-clip": (value: string, original: string, media: string, state: string, handler: StyleHandler) => string; };