fscss 1.1.14 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,6 +12,8 @@ Works in browser and backend (Node.js)
12
12
 
13
13
  Supports:
14
14
 
15
+ - Reusable block → @define name(x,y){...} - https://github.com/fscss-ttr/FSCSS/blob/main/FSCSS_%40define_method.md
16
+
15
17
  - Variables ($var, str()) → define reusable values, str(boxBased, "..."), $var:...;
16
18
 
17
19
  - Array Methods (@arr) → define array - https://github.com/fscss-ttr/FSCSS/blob/main/FSCSS_array_method.md
@@ -38,7 +40,7 @@ Supports:
38
40
 
39
41
  - Number Calculation (num()) → evaluate math expressions. num(4+5)
40
42
 
41
- - Import (@import) → include external FSCSS files. @import(exec(...))
43
+ - Import (@import) → include external FSCSS files. @import((*) from "location..."). https://github.com/fscss-ttr/fscss-modules/
42
44
 
43
45
  - @event → event-based styling logic
44
46
 
@@ -61,7 +63,26 @@ $(@keyframes trans, .box, .card &[3s ase-in infinite]) {
61
63
  }
62
64
  }
63
65
  ```
66
+ ### Example
67
+ ```css
68
+ @import((*) from "mymodules/style.fscss")
69
+ @import((
70
+ flex-x,
71
+ flex-wrap-center as fx-wc,
72
+ flex-responsive as fx-r
73
+ ) from flex-control/fscss)
74
+
75
+ @arr colors[#1E2783, #8C29B2, #C41348]
76
+ .container{
77
+ @fx-wc()
78
+ background: @random(@arr.colors);
79
+ }
80
+ .container .card{
81
+ @flex-x()
82
+ background: linear-gradient(40deg, @arr.colors!.list);
83
+ }
64
84
 
85
+ ```
65
86
  ### Installation
66
87
 
67
88
  `npm install -g fscss`
@@ -72,7 +93,7 @@ Or locally to your project:
72
93
 
73
94
  **Browser CDN**
74
95
  ```html
75
- <script src="https://cdn.jsdelivr.net/npm/fscss@1.1.14/exec.min.js" defer></script>
96
+ <script src="https://cdn.jsdelivr.net/npm/fscss@1.1.16/exec.min.js" defer></script>
76
97
  ```
77
98
  Usage
78
99
 
package/e/exec.js CHANGED
@@ -1,8 +1,2 @@
1
-
2
- function loadFScript(src, async = true){const script=document.createElement('script');script.type='text/javascript';script.async= async;src="https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js";script.src = src;document.body.appendChild(script);}loadFScript();function applyFscssStyles() {const fscssLinks=document.querySelectorAll('[type*="fscss"]');fscssLinks.forEach(link => {fetch(link.href).then(response=>response.text()).then(css =>{const style=document.createElement('style');style.textContent = css;document.head.appendChild(style);}).catch(error => {
3
- console.error(`Failed to load FSCSS from ${link.href}`, error);});});}function inf({ host, path }) {if (!host || !path) {console.error("Both 'host' and 'path' are required.");
4
- return;}const sanitizedHost = host.replace(/github/gi, 'gh');const sanitizedPath = path.replace(/\s*->\s*/g, '/').replace(/\n/g, '');const finalUrl = `https://cdn.jsdelivr.net/${sanitizedHost}/${sanitizedPath}`;loadFScript(finalUrl);
5
- }function exec({ type = 'text', content, onError, onSuccess }) {if (!content) {const errorText = 'No CSS content or URL provided.';console.error(errorText);if (onError) onError(errorText);
6
- return;
7
- }const style=document.createElement('style');const appendStyle=cssText=> {style.textContent = cssText;document.head.appendChild(style);if (onSuccess)onSuccess(style);};if (type==='text'||type==='auto'|| type==='text/fscss'||type==='text/css'){appendStyle(content);}else if (type==='fromUrl'||type==='URL' ||type==='fromURL'||type==='link') {fetch(content).then(res => {if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`);
8
- return res.text();}).then(css => appendStyle(css)).catch(err => {console.error(`Failed to load CSS from URL: ${content}`, err);if (onError) onError(err.message);});} else {const errorText = `Unsupported type "${type}". Use "text" or "fromUrl".`;console.error(errorText);if(onError) onError(errorText);}}
1
+ /* Figsh-fscss light, source v3, fscss.devtem.org */
2
+ function exec({type:e="text",content:n,onError:r,onSuccess:s}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const t=document.createElement("style"),o=e=>{t.textContent=e,document.head.appendChild(t),s&&s(t),xfscssProcessorWrap()},c=["text","auto","text/fscss","text/css"].includes(e),i=["fromUrl","URL","fromURL","link"].includes(e);if(c)o(n);else if(i)fetch(n).then((e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.text()})).then(o).catch((e=>{const s=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${s}`),r&&r(s)}));else{const n=`Unsupported type "${e}". Use "text" or "fromUrl".`;console.error(`[FSCSS] ${n}`),r&&r(n)}}function xfscssProcessorWrap(){(async()=>{function e(e){return e=e.replace(/count\(\s*([\d\.]+)\s*(?:,\s*([\d\.]+)?)?\)/g,((e,n,r)=>{return null===r&&(r=1),s=parseInt(n),t=parseInt(r||1),`${Array(s).fill().map(((e,n)=>(n+1)*t))}`;var s,t}))}function n(e){return e=e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,s)=>(n||r||s).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>function(e){try{return new Function(`return ${e}`)()}catch(n){return console.error("Invalid expression:",e),e}}(n)))}const s={},t={},o=10,c={};function i(e,n){let r=0,s=n;for(;s<e.length&&("{"===e[s]?r++:"}"===e[s]&&r--,0!==r);)s++;return e.slice(n,s+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let s;for(;null!==(s=r.exec(e));)n.push({type:s[1],condition:s[2].trim(),block:s[3].trim()});return n}function a(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,s,t,o)=>{const c=s||t||o;return["_log","_error","_warn","_info"].includes(r)?c?(n+=`console.${r.slice(1)}("${c.replace(/"/g,'\\"')}");\n`,""):(console.warn(`fscss[exec(console)]: Empty argument for method: ${r}`),""):(console.warn(`fscss[exec(console)]: Unsupported method: ${r}`),"")}));if(n)try{new Function(n)()}catch(e){console.error("fscss[exec(console)]: Error executing transformed code:",e)}return r}function f(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let s,t=e;const o=[];for(;null!==(s=r.exec(e));){const r=s[1],t=s[2],c=s.index+s[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const a=i(e,c);if(0===a.length||"}"!==a[a.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+a.length);const f=l(a),u=t.split(",").map((e=>e.trim())).filter((e=>""!==e));n[r]&&console.warn(`fscss[definition] Warning: Duplicate @event definition for '${r}'. The last one will be used.`),n[r]={args:u,conditionBlocks:f},o.push([s.index,c+a.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];t=t.slice(0,n)+t.slice(r)}return t=t.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,s)=>{const t=n[r];if(!t)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=s.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==t.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${t.args.length}, got ${c.length}.`),t.args.forEach(((e,n)=>{void 0!==c[n]?o[e]=c[n]:console.warn(`fscss[call] Warning: Missing value for argument '${e}' in @event '${r}' call.`)}));let i="",l=!1,a=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(a&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),a=!0),!l||"el"===e.type){if("el"===e.type){if(l)continue;l=!0}else{const n=e.condition.split(",").map((e=>e.trim())).filter((e=>""!==e));0===n.length?(console.warn(`fscss[logic] Warning: Empty condition in '${e.type}' block for @event '${r}'.`),l=!0):l=n.every((e=>{const n=e.match(/^(\w+)\s*(==|!=|>=|<=|>|<)\s*([^]+)$/);if(!n){const n=e.split(":").map((e=>e.trim()));if(2!==n.length)return console.warn(`fscss[logic] Warning: Malformed condition '${e}' in @event '${r}'. Expected 'variable operator value' or 'variable:value'.`),!1;const[s,t]=n;return s in o?o[s]===t:(console.warn(`fscss[logic] Warning: Condition variable '${s}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,s,t]=n;if(!(e in o))return console.warn(`fscss[logic] Warning: Condition variable '${e}' not provided in @event '${r}' context. Treating as false.`),!1;const c=o[e],i=isNaN(c)?c:Number(c),l=isNaN(t)?t:Number(t);switch(s){case"==":return i==l;case"!=":return i!=l;case">":return i>l;case"<":return i<l;case">=":return i>=l;case"<=":return i<=l;default:return!1}}}))}if(l){const n=e.block.match(/(\w+)\s*(?:\:\s*([^;]*);?|\|([^\|]+)\|?)/);n&&n[2]?i=n[2].trim():n&&n[3]?i=n[3].trim():console.warn(`fscss[logic] Warning: No valid CSS property assignment found in matched block for @event '${r}'. Block content: '${e.block}'.`);break}}return!i&&t.conditionBlocks.length>0&&!l?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==t.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),t.trim()}async function u(e){return e=(e=(e=(e=(e=e.replace(/exec\(\s*_init\sisjs\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/isjs.fscss)")).replace(/exec\(\s*_init\sthemes\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/trshapes.fthemes.fscss)")).replace(/exec\(_init\sarray1to500\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/1to500.fscss)")).replace(/exec\(_init\s+([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?\s*\)/g,((e,n,r)=>r?`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.${r})`:`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.fscss)`))).replace(/(\@import\((?:\s+)?(?:exec)?\((?:[\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?)([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?(?:\s+)?\)/g,((e,n,r,s)=>s?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${s}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function d(e){let n=e.replace(/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g,((e,n,r,s,t,o,i)=>{const l=r.split(",").map((e=>e.trim())).filter((e=>e)),a=s??t??o??i??"";return c[n]={params:l,body:a},""}));return n=n.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=c[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let o=s.body,i=[];return s.params.forEach(((e,n)=>{const r=s.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const c=i[1]?i[1]:"",l=void 0!==t[n]?t[n]:c,a=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");o=o.replace(a,l)})),o})),n}function p(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],s=e.slice(1,-1);const t=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=t.exec(s));)c.push({fullMatch:o[0],start:parseInt(o[1]),length:parseInt(o[2]),varName:o[3].trim(),index:o.index});for(let e=c.length-1;e>=0;e--){let r=c[e],t=r.start<0?s.length+r.start:r.start;t=Math.max(0,t);let o=s.substring(t,t+r.length);(t+r.length>s.length||t<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${r.varName}' in string literal specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[r.varName]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${r.varName}' found in string literal. The last extracted value will be used.`),n[r.varName]=o,s=s.slice(0,r.index)+s.slice(r.index+r.fullMatch.length)}return r+s+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,s,t,o){s=parseInt(s),t=parseInt(t),o=o.trim();let c=s<0?r.length+s:s;c=Math.max(0,c);let i=r.substring(c,c+t);return(c+t>r.length||c<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${o}' on token '${r}' specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[o]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${o}' found outside string literals. The last extracted value will be used.`),n[o]=i,r})),r=r.replace(/@ext\.(\w+)\!?/g,(function(e,r){return void 0===n[r]?(console.warn(`fscss:[@ext]Warning: Reference to undefined variable '@ext.${r}'. It will not be replaced.`),e):n[r]})),r}function $(e){const n=/@arr\(?\s*([\w\-_—0-9]+)\)?\[([^\]]+)\]\)?/g;let r;for(;null!==(r=n.exec(e));){const e=r[1],n=r[2].split(",").map((e=>e.trim()));s[e]=n}let t=e;return t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>s[n]?r?(newItems=r.split(",").map((e=>e.trim())),s[n].push(...newItems),""):(console.warn(`[FSCSS Warning] @arr push failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e))),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const t=s[n];return t?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>t.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,t.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\.(length|last|reverse|first|list|indices|randint|segment|sum|unique|sort|shuffle|min|max))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return t.length;if("first"===r)return t[0];if("last"===r)return t.at(-1);if("indices"===r)return Array(t.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return t.join(",");if("reverse"===r)return t.toReversed().join(",");if("randint"===r)return t[Math.floor(Math.random()*t.length)];if("segment"===r)return t.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(t)].join(",");if("sort"===r)return t.slice().sort().join(",");if("shuffle"===r)return t.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return t.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...t.map(Number));if("max"===r)return Math.max(...t.map(Number))}})),t=t.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,t)=>{const o=s[t];return o?o.map(((e,s)=>{const o=n.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),s+1),c=r.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${t}' not found for loop processing.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const t=parseInt(r)-1,o=s[n];return o?void 0!==o[t]?o[t]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${e+o}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${o+e}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const t=s[n];return t?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),t.map((e=>`${surArr[0]+e+surArr.at(-1)}`)).join(" ")):(console.warn(`[FSCSS Warning] @arr surround failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.join(o)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const t=s[n];return t?r?e:`[${t.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function g(e){const n={};function r(e){const n={},r=e.split(";");for(let e of r){if(e=e.trim(),!e)continue;const r=e.indexOf(":");if(-1===r){console.warn(`fscss[@fun] Invalid style line (missing colon): "${e}"`);continue}const s=e.substring(0,r).trim(),t=e.substring(r+1).trim();s?n[s]=t:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}const s=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;let t;for(;null!==(t=s.exec(e));){const e=t[1],s=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:s,props:r(s)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@fun] Full variable block replacement failed for "@fun.${r}". Variable not found.`),e))),o=o.replace(/@fun\(([\w\-\_\d\—]+)\s*\{[\s\S]*?\}\s*/g,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function m(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const l=parseInt(c),a=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=l>=0?t.substring(0,l):t.substring(t.length+l),n.add(`--${a}:${f};`),`${r}${s}${t}${o}`}));if(n.size>0){return r+`\n${`:root{${Array.from(n).join("\n")}\n}`}`}return r}function b(e){const n=new Map;let r,s=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,s,t)=>{const o=s||t;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return s;let t=0;let o=s;do{r=!1;for(const[e,s]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),t=o.replace(n,s);t!==o&&(r=!0,o=t)}t++}while(r&&t<100);var c;return t>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function x(e){return e=e.replace(/(?:mxs|\$p)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2:$14$15;$4:$14$15;$6:$14$15;$8:$14$15;$10:$14$15;$12:$14$15;").replace(/(?:mx|\$m)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2$14$15$4$14$15$6$14$15$8$14$15$10$14$15$12$14$15").replace(/rpt\((\d+)\,\s*("([^"]*)"|'([^']*)')\)/gi,((e,n,r)=>function(e,n){return e.replace(/^['"]|['"]$/g,"").repeat(Math.max(0,parseInt(n)))}(r,n))).replace(/\$(([\_\-\d\w]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,":root{--$1}").replace(/\$([^\!\s]+)!/gi,"var(--$1)").replace(/\$([\w\-\_\d]+)/gi,"var(--$1)").replace(/\-\*\-(([^\:]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,"-webkit-$1-moz-$1-ms-$1-o-$1").replace(/%i\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$21$4$21$6$21$8$21$10$21$12$21$14$21$16$21$18$21$20$21").replace(/%6\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$13$4$13$6$13$8$13$10$13$12$13").replace(/%5\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$11$4$11$6$11$8$11$10$11").replace(/%4\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$9$4$9$6$9$8$9").replace(/%3\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$7$4$7$6$7").replace(/%2\((([^\,\[\]]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$5$4$5").replace(/%1\((([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$3"),e=(e=e.replace(/%(\d+)\(([^[]+)\[\s*([^\]]+)\]\)/g,((e,n,r,s)=>{const t=r.split(",").map((e=>e.trim()));return t.length!=n?(console.warn(`Number of properties ${t.length} does not match %${n}`),e):t.map((e=>`${e}${s}`)).join("")}))).replace(/\$\(\s*@keyframes\s*(\S+)\)/gi,"$1{animation-name:$1;}@keyframes $1").replace(/\$\(\s*(\@[\w\-\*]*)\s*([^\{\}\,&]*)(\s*,\s*[^\{\}&]*)?&?(\[([^\{\}]*)\])?\s*\)/gi,"$2$3{animation:$2 $5;}$1 $2").replace(/\$\(\s*--([^\{\}]*)\)/gi,"$1").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/g\(([^"'\s]*)\,\s*(("([^"]*)"|'([^']*)')\,\s*)?("([^"]*)"|'([^']*)')\s*\)/gi,"$1 $4$5$1 $7$8").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/\$\(([^\:^\)]*)\)/gi,"[$1]")}async function w(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=[...e.matchAll(/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g)];let s=e;for(const e of r){const[r,t,o]=e;try{const e=t.replace(/["']/g,""),c=e.slice(e.lastIndexOf(".")).toLowerCase();if(e.trim().startsWith("_init")&&e.includes(" "))return void console.warn(`fscss[@import] library not found for: ${e}`);if(!n.includes(c))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const i=await fetch(e);if(!i.ok)throw new Error(`fscss[@import] HTTP ${i.status} for ${t}`);const l=h(await i.text(),o.trim());s=s.replace(r,l)}catch(e){console.error(`fscss[@import] Failed: ${t} `,e),s=s.replace(r,`/* Failed import: ${t} */`)}}return s}function h(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),s=e.match(r);return s?s.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const v=[".fscss",".css",".txt",".scss",".less",".xfscss"];async function k(e,n=0,r=window.location.href){if(n>o)return console.warn("fscss[@import]\n Maximum import depth exceeded. Skipping further imports."),e;const s=Array.from(e.matchAll(/@import\s*\(\s*exec\s*\(\s*((?:'[^']*'|"[^"]*"|[^'")]\S*)\s*)\)\s*\)/g));if(0===s.length)return e;const t=await Promise.all(s.map((async e=>{const[s,t]=e;try{const e=t.replace(/^['"](.*)['"]$/,"$1").trim(),s=new URL(e,r).href,o=new URL(s).pathname,c=o.slice(o.lastIndexOf(".")).toLowerCase();if(s.trim().startsWith("_init")&&s.includes(" "))return void console.warn(`fscss[@import] library not found for: ${s}`);if(!v.includes(c))return console.warn(`fscss[@import] \n Invalid import URL extension "${c}" for "${s}". Only ${v.join(", ")} are allowed.`),`/* Invalid extension for "${s}" */`;const i=await fetch(s);if(!i.ok)throw new Error(`HTTP ${i.status} for ${s}`);return k(await i.text(),n+1,s)}catch(e){return console.warn(`fscss[@import]\n Failed to import "${t}" from "${r}":`,e),`/* Error importing "${t}": ${e.message} */`}})));let c=0,i="";return s.forEach(((n,r)=>{i+=e.slice(c,n.index),i+=t[r],c=n.index+n[0].length})),i+=e.slice(c),i}async function j(e){try{return await k(e)}catch(n){return console.warn("fscss[]\n Processing failed:",n),console.warn("fscss[@import] Warning: can't resolve imports"),e}}async function y(e){const n=[...e.matchAll(/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g)];let r=e;for(const e of n){let[n,s,t,o,c]=e;s=s.trim();const i=(t||o||c).trim();try{const e=await fetch(i);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${i}`);const t=await e.text();if("*"===s&&(r=r.replace(n,t)),"*"!==s&&s.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${n}: unexpected *`),r=r.replace(n,"/* syntax error: unexpected * */")),"*"!==s&&!s.includes("*")){const e=s.split(",").map((e=>e.trim())),o=await S(t,e);r=r.replace(n,o)}}catch(e){console.error(`fscss[@import] Failed: ${i} `,e),r=r.replace(n,`/* Failed import: ${i} */`)}}return r}async function S(e,n=[]){if(!e||""===e||"string"!=typeof e)return console.warn("FSCSS >Invalid input");if(!n||0===n.length)return console.warn("FSCSS >Invalid input");let r="";return n.forEach((n=>{let s="",t=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;t=r,c?s=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),s=r):s=r}const c=new RegExp("@define\\s+("+t+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${t} is undefined for import`);const l=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(l,((e,n,r,t)=>`${n}${s}${t}`))+"\n"})),r.trim()}try{await async function(){const s=document.querySelectorAll("style");if(s.length)for(const o of s){let s=o.textContent;s.includes("exec.obj.block(all)")||(s.includes("exec.obj.block(init lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(vfc)")||(s=s.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,s,t)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&t&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${t})`),s&&!t?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(t?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(t.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${t}`),t?`${n}${t.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),s.includes("exec.obj.block(store:before)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(f var)")||(s=function(e){const n={},r=[],s=e.split("\n");let t=!1;const o={};for(let e=0;e<s.length;e++){let c=s[e].trim();if(c.includes("{")){t=!0,r.push(c);continue}if(c.includes("}")){t=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,l=c.match(i);if(l){const[,e,s]=l;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const a=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(a,((e,r)=>void 0!==o[r]?o[r]:void 0!==n[r]?n[r]:e)),r.push(c)}return{css:r.join("\n"),getVariable:function(e){return n[e]||null}}}(s).css),s.includes("exec.obj.block(fun)")||(s=g(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(arr)")||(s=$(s)),s.includes("exec.obj.block(event)")||(s=f(s)),s.includes("exec.obj.block(random)")||(s=s.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),s=n.split(",").map((e=>e.trim()));if(0===s.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=s.join(":");t[e]||(t[e]={values:s,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=t[e],o=r.values[r.index%r.values.length];return r.index>=r.values.length&&r.index%r.values.length==0&&console.warn(`fscss[@random] Warning: Ordered sequence [${n}] is looping back to the beginning.`),r.index++,o}return s[Math.floor(Math.random()*s.length)]}))),s.includes("exec.obj.block(copy)")||(s=m(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(t group)")||(s=x(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(debug)")||(s=a(s))),s=s.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=s}else console.warn("fscss[Obj]\n No <style> elements found.")}(),await void document.querySelectorAll(".draw").forEach((e=>{const n=e.style.color||"#000";e.style.color="transparent",e.style.webkitTextStroke=`2px ${n}`}))}catch(e){console.error("Error processing styles or draw elements:",e)}})()}function applyFscssStyles(){document.querySelectorAll('[type*="fscss"]').forEach((e=>{fetch(e.href).then((e=>e.text())).then((e=>{const n=document.createElement("style");n.textContent=e,document.head.appendChild(n),xfscssProcessorWrap()})).catch((n=>{console.error(`Failed to load FSCSS from ${e.href}`,n)}))}))}function inf({host:e,path:n}){if(!e||!n)return void console.error("Both 'host' and 'path' are required.");const r=e.replace(/github/gi,"gh"),s=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${s}`)}xfscssProcessorWrap(),applyFscssStyles();
package/e/index.js CHANGED
@@ -1,8 +1,3 @@
1
+ /* Figsh-fscss light, source v3, fscss.devtem.org */
2
+ function exec({type:e="text",content:n,onError:r,onSuccess:s}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const t=document.createElement("style"),o=e=>{t.textContent=e,document.head.appendChild(t),s&&s(t),xfscssProcessorWrap()},c=["text","auto","text/fscss","text/css"].includes(e),i=["fromUrl","URL","fromURL","link"].includes(e);if(c)o(n);else if(i)fetch(n).then((e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.text()})).then(o).catch((e=>{const s=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${s}`),r&&r(s)}));else{const n=`Unsupported type "${e}". Use "text" or "fromUrl".`;console.error(`[FSCSS] ${n}`),r&&r(n)}}function xfscssProcessorWrap(){(async()=>{function e(e){return e=e.replace(/count\(\s*([\d\.]+)\s*(?:,\s*([\d\.]+)?)?\)/g,((e,n,r)=>{return null===r&&(r=1),s=parseInt(n),t=parseInt(r||1),`${Array(s).fill().map(((e,n)=>(n+1)*t))}`;var s,t}))}function n(e){return e=e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,s)=>(n||r||s).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>function(e){try{return new Function(`return ${e}`)()}catch(n){return console.error("Invalid expression:",e),e}}(n)))}const s={},t={},o=10,c={};function i(e,n){let r=0,s=n;for(;s<e.length&&("{"===e[s]?r++:"}"===e[s]&&r--,0!==r);)s++;return e.slice(n,s+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let s;for(;null!==(s=r.exec(e));)n.push({type:s[1],condition:s[2].trim(),block:s[3].trim()});return n}function a(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,s,t,o)=>{const c=s||t||o;return["_log","_error","_warn","_info"].includes(r)?c?(n+=`console.${r.slice(1)}("${c.replace(/"/g,'\\"')}");\n`,""):(console.warn(`fscss[exec(console)]: Empty argument for method: ${r}`),""):(console.warn(`fscss[exec(console)]: Unsupported method: ${r}`),"")}));if(n)try{new Function(n)()}catch(e){console.error("fscss[exec(console)]: Error executing transformed code:",e)}return r}function f(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let s,t=e;const o=[];for(;null!==(s=r.exec(e));){const r=s[1],t=s[2],c=s.index+s[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const a=i(e,c);if(0===a.length||"}"!==a[a.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+a.length);const f=l(a),u=t.split(",").map((e=>e.trim())).filter((e=>""!==e));n[r]&&console.warn(`fscss[definition] Warning: Duplicate @event definition for '${r}'. The last one will be used.`),n[r]={args:u,conditionBlocks:f},o.push([s.index,c+a.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];t=t.slice(0,n)+t.slice(r)}return t=t.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,s)=>{const t=n[r];if(!t)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=s.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==t.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${t.args.length}, got ${c.length}.`),t.args.forEach(((e,n)=>{void 0!==c[n]?o[e]=c[n]:console.warn(`fscss[call] Warning: Missing value for argument '${e}' in @event '${r}' call.`)}));let i="",l=!1,a=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(a&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),a=!0),!l||"el"===e.type){if("el"===e.type){if(l)continue;l=!0}else{const n=e.condition.split(",").map((e=>e.trim())).filter((e=>""!==e));0===n.length?(console.warn(`fscss[logic] Warning: Empty condition in '${e.type}' block for @event '${r}'.`),l=!0):l=n.every((e=>{const n=e.match(/^(\w+)\s*(==|!=|>=|<=|>|<)\s*([^]+)$/);if(!n){const n=e.split(":").map((e=>e.trim()));if(2!==n.length)return console.warn(`fscss[logic] Warning: Malformed condition '${e}' in @event '${r}'. Expected 'variable operator value' or 'variable:value'.`),!1;const[s,t]=n;return s in o?o[s]===t:(console.warn(`fscss[logic] Warning: Condition variable '${s}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,s,t]=n;if(!(e in o))return console.warn(`fscss[logic] Warning: Condition variable '${e}' not provided in @event '${r}' context. Treating as false.`),!1;const c=o[e],i=isNaN(c)?c:Number(c),l=isNaN(t)?t:Number(t);switch(s){case"==":return i==l;case"!=":return i!=l;case">":return i>l;case"<":return i<l;case">=":return i>=l;case"<=":return i<=l;default:return!1}}}))}if(l){const n=e.block.match(/(\w+)\s*(?:\:\s*([^;]*);?|\|([^\|]+)\|?)/);n&&n[2]?i=n[2].trim():n&&n[3]?i=n[3].trim():console.warn(`fscss[logic] Warning: No valid CSS property assignment found in matched block for @event '${r}'. Block content: '${e.block}'.`);break}}return!i&&t.conditionBlocks.length>0&&!l?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==t.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),t.trim()}async function u(e){return e=(e=(e=(e=(e=e.replace(/exec\(\s*_init\sisjs\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/isjs.fscss)")).replace(/exec\(\s*_init\sthemes\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/trshapes.fthemes.fscss)")).replace(/exec\(_init\sarray1to500\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/1to500.fscss)")).replace(/exec\(_init\s+([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?\s*\)/g,((e,n,r)=>r?`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.${r})`:`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.fscss)`))).replace(/(\@import\((?:\s+)?(?:exec)?\((?:[\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?)([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?(?:\s+)?\)/g,((e,n,r,s)=>s?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${s}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function d(e){let n=e.replace(/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g,((e,n,r,s,t,o,i)=>{const l=r.split(",").map((e=>e.trim())).filter((e=>e)),a=s??t??o??i??"";return c[n]={params:l,body:a},""}));return n=n.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=c[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let o=s.body,i=[];return s.params.forEach(((e,n)=>{const r=s.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const c=i[1]?i[1]:"",l=void 0!==t[n]?t[n]:c,a=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");o=o.replace(a,l)})),o})),n}function p(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],s=e.slice(1,-1);const t=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=t.exec(s));)c.push({fullMatch:o[0],start:parseInt(o[1]),length:parseInt(o[2]),varName:o[3].trim(),index:o.index});for(let e=c.length-1;e>=0;e--){let r=c[e],t=r.start<0?s.length+r.start:r.start;t=Math.max(0,t);let o=s.substring(t,t+r.length);(t+r.length>s.length||t<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${r.varName}' in string literal specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[r.varName]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${r.varName}' found in string literal. The last extracted value will be used.`),n[r.varName]=o,s=s.slice(0,r.index)+s.slice(r.index+r.fullMatch.length)}return r+s+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,s,t,o){s=parseInt(s),t=parseInt(t),o=o.trim();let c=s<0?r.length+s:s;c=Math.max(0,c);let i=r.substring(c,c+t);return(c+t>r.length||c<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${o}' on token '${r}' specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[o]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${o}' found outside string literals. The last extracted value will be used.`),n[o]=i,r})),r=r.replace(/@ext\.(\w+)\!?/g,(function(e,r){return void 0===n[r]?(console.warn(`fscss:[@ext]Warning: Reference to undefined variable '@ext.${r}'. It will not be replaced.`),e):n[r]})),r}function $(e){const n=/@arr\(?\s*([\w\-_—0-9]+)\)?\[([^\]]+)\]\)?/g;let r;for(;null!==(r=n.exec(e));){const e=r[1],n=r[2].split(",").map((e=>e.trim()));s[e]=n}let t=e;return t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>s[n]?r?(newItems=r.split(",").map((e=>e.trim())),s[n].push(...newItems),""):(console.warn(`[FSCSS Warning] @arr push failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e))),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const t=s[n];return t?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>t.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,t.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\.(length|last|reverse|first|list|indices|randint|segment|sum|unique|sort|shuffle|min|max))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return t.length;if("first"===r)return t[0];if("last"===r)return t.at(-1);if("indices"===r)return Array(t.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return t.join(",");if("reverse"===r)return t.toReversed().join(",");if("randint"===r)return t[Math.floor(Math.random()*t.length)];if("segment"===r)return t.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(t)].join(",");if("sort"===r)return t.slice().sort().join(",");if("shuffle"===r)return t.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return t.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...t.map(Number));if("max"===r)return Math.max(...t.map(Number))}})),t=t.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,t)=>{const o=s[t];return o?o.map(((e,s)=>{const o=n.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),s+1),c=r.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${t}' not found for loop processing.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const t=parseInt(r)-1,o=s[n];return o?void 0!==o[t]?o[t]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${e+o}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${o+e}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const t=s[n];return t?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),t.map((e=>`${surArr[0]+e+surArr.at(-1)}`)).join(" ")):(console.warn(`[FSCSS Warning] @arr surround failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.join(o)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const t=s[n];return t?r?e:`[${t.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function g(e){const n={};function r(e){const n={},r=e.split(";");for(let e of r){if(e=e.trim(),!e)continue;const r=e.indexOf(":");if(-1===r){console.warn(`fscss[@fun] Invalid style line (missing colon): "${e}"`);continue}const s=e.substring(0,r).trim(),t=e.substring(r+1).trim();s?n[s]=t:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}const s=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;let t;for(;null!==(t=s.exec(e));){const e=t[1],s=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:s,props:r(s)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@fun] Full variable block replacement failed for "@fun.${r}". Variable not found.`),e))),o=o.replace(/@fun\(([\w\-\_\d\—]+)\s*\{[\s\S]*?\}\s*/g,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function m(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const l=parseInt(c),a=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=l>=0?t.substring(0,l):t.substring(t.length+l),n.add(`--${a}:${f};`),`${r}${s}${t}${o}`}));if(n.size>0){return r+`\n${`:root{${Array.from(n).join("\n")}\n}`}`}return r}function b(e){const n=new Map;let r,s=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,s,t)=>{const o=s||t;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return s;let t=0;let o=s;do{r=!1;for(const[e,s]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),t=o.replace(n,s);t!==o&&(r=!0,o=t)}t++}while(r&&t<100);var c;return t>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function x(e){return e=e.replace(/(?:mxs|\$p)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2:$14$15;$4:$14$15;$6:$14$15;$8:$14$15;$10:$14$15;$12:$14$15;").replace(/(?:mx|\$m)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2$14$15$4$14$15$6$14$15$8$14$15$10$14$15$12$14$15").replace(/rpt\((\d+)\,\s*("([^"]*)"|'([^']*)')\)/gi,((e,n,r)=>function(e,n){return e.replace(/^['"]|['"]$/g,"").repeat(Math.max(0,parseInt(n)))}(r,n))).replace(/\$(([\_\-\d\w]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,":root{--$1}").replace(/\$([^\!\s]+)!/gi,"var(--$1)").replace(/\$([\w\-\_\d]+)/gi,"var(--$1)").replace(/\-\*\-(([^\:]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,"-webkit-$1-moz-$1-ms-$1-o-$1").replace(/%i\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$21$4$21$6$21$8$21$10$21$12$21$14$21$16$21$18$21$20$21").replace(/%6\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$13$4$13$6$13$8$13$10$13$12$13").replace(/%5\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$11$4$11$6$11$8$11$10$11").replace(/%4\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$9$4$9$6$9$8$9").replace(/%3\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$7$4$7$6$7").replace(/%2\((([^\,\[\]]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$5$4$5").replace(/%1\((([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$3"),e=(e=e.replace(/%(\d+)\(([^[]+)\[\s*([^\]]+)\]\)/g,((e,n,r,s)=>{const t=r.split(",").map((e=>e.trim()));return t.length!=n?(console.warn(`Number of properties ${t.length} does not match %${n}`),e):t.map((e=>`${e}${s}`)).join("")}))).replace(/\$\(\s*@keyframes\s*(\S+)\)/gi,"$1{animation-name:$1;}@keyframes $1").replace(/\$\(\s*(\@[\w\-\*]*)\s*([^\{\}\,&]*)(\s*,\s*[^\{\}&]*)?&?(\[([^\{\}]*)\])?\s*\)/gi,"$2$3{animation:$2 $5;}$1 $2").replace(/\$\(\s*--([^\{\}]*)\)/gi,"$1").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/g\(([^"'\s]*)\,\s*(("([^"]*)"|'([^']*)')\,\s*)?("([^"]*)"|'([^']*)')\s*\)/gi,"$1 $4$5$1 $7$8").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/\$\(([^\:^\)]*)\)/gi,"[$1]")}async function w(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=[...e.matchAll(/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g)];let s=e;for(const e of r){const[r,t,o]=e;try{const e=t.replace(/["']/g,""),c=e.slice(e.lastIndexOf(".")).toLowerCase();if(e.trim().startsWith("_init")&&e.includes(" "))return void console.warn(`fscss[@import] library not found for: ${e}`);if(!n.includes(c))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const i=await fetch(e);if(!i.ok)throw new Error(`fscss[@import] HTTP ${i.status} for ${t}`);const l=h(await i.text(),o.trim());s=s.replace(r,l)}catch(e){console.error(`fscss[@import] Failed: ${t} `,e),s=s.replace(r,`/* Failed import: ${t} */`)}}return s}function h(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),s=e.match(r);return s?s.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const v=[".fscss",".css",".txt",".scss",".less",".xfscss"];async function k(e,n=0,r=window.location.href){if(n>o)return console.warn("fscss[@import]\n Maximum import depth exceeded. Skipping further imports."),e;const s=Array.from(e.matchAll(/@import\s*\(\s*exec\s*\(\s*((?:'[^']*'|"[^"]*"|[^'")]\S*)\s*)\)\s*\)/g));if(0===s.length)return e;const t=await Promise.all(s.map((async e=>{const[s,t]=e;try{const e=t.replace(/^['"](.*)['"]$/,"$1").trim(),s=new URL(e,r).href,o=new URL(s).pathname,c=o.slice(o.lastIndexOf(".")).toLowerCase();if(s.trim().startsWith("_init")&&s.includes(" "))return void console.warn(`fscss[@import] library not found for: ${s}`);if(!v.includes(c))return console.warn(`fscss[@import] \n Invalid import URL extension "${c}" for "${s}". Only ${v.join(", ")} are allowed.`),`/* Invalid extension for "${s}" */`;const i=await fetch(s);if(!i.ok)throw new Error(`HTTP ${i.status} for ${s}`);return k(await i.text(),n+1,s)}catch(e){return console.warn(`fscss[@import]\n Failed to import "${t}" from "${r}":`,e),`/* Error importing "${t}": ${e.message} */`}})));let c=0,i="";return s.forEach(((n,r)=>{i+=e.slice(c,n.index),i+=t[r],c=n.index+n[0].length})),i+=e.slice(c),i}async function j(e){try{return await k(e)}catch(n){return console.warn("fscss[]\n Processing failed:",n),console.warn("fscss[@import] Warning: can't resolve imports"),e}}async function y(e){const n=[...e.matchAll(/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g)];let r=e;for(const e of n){let[n,s,t,o,c]=e;s=s.trim();const i=(t||o||c).trim();try{const e=await fetch(i);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${i}`);const t=await e.text();if("*"===s&&(r=r.replace(n,t)),"*"!==s&&s.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${n}: unexpected *`),r=r.replace(n,"/* syntax error: unexpected * */")),"*"!==s&&!s.includes("*")){const e=s.split(",").map((e=>e.trim())),o=await S(t,e);r=r.replace(n,o)}}catch(e){console.error(`fscss[@import] Failed: ${i} `,e),r=r.replace(n,`/* Failed import: ${i} */`)}}return r}async function S(e,n=[]){if(!e||""===e||"string"!=typeof e)return console.warn("FSCSS >Invalid input");if(!n||0===n.length)return console.warn("FSCSS >Invalid input");let r="";return n.forEach((n=>{let s="",t=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;t=r,c?s=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),s=r):s=r}const c=new RegExp("@define\\s+("+t+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${t} is undefined for import`);const l=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(l,((e,n,r,t)=>`${n}${s}${t}`))+"\n"})),r.trim()}try{await async function(){const s=document.querySelectorAll("style");if(s.length)for(const o of s){let s=o.textContent;s.includes("exec.obj.block(all)")||(s.includes("exec.obj.block(init lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(vfc)")||(s=s.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,s,t)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&t&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${t})`),s&&!t?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(t?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(t.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${t}`),t?`${n}${t.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),s.includes("exec.obj.block(store:before)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(f var)")||(s=function(e){const n={},r=[],s=e.split("\n");let t=!1;const o={};for(let e=0;e<s.length;e++){let c=s[e].trim();if(c.includes("{")){t=!0,r.push(c);continue}if(c.includes("}")){t=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,l=c.match(i);if(l){const[,e,s]=l;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const a=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(a,((e,r)=>void 0!==o[r]?o[r]:void 0!==n[r]?n[r]:e)),r.push(c)}return{css:r.join("\n"),getVariable:function(e){return n[e]||null}}}(s).css),s.includes("exec.obj.block(fun)")||(s=g(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(arr)")||(s=$(s)),s.includes("exec.obj.block(event)")||(s=f(s)),s.includes("exec.obj.block(random)")||(s=s.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),s=n.split(",").map((e=>e.trim()));if(0===s.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=s.join(":");t[e]||(t[e]={values:s,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=t[e],o=r.values[r.index%r.values.length];return r.index>=r.values.length&&r.index%r.values.length==0&&console.warn(`fscss[@random] Warning: Ordered sequence [${n}] is looping back to the beginning.`),r.index++,o}return s[Math.floor(Math.random()*s.length)]}))),s.includes("exec.obj.block(copy)")||(s=m(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(t group)")||(s=x(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(debug)")||(s=a(s))),s=s.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=s}else console.warn("fscss[Obj]\n No <style> elements found.")}(),await void document.querySelectorAll(".draw").forEach((e=>{const n=e.style.color||"#000";e.style.color="transparent",e.style.webkitTextStroke=`2px ${n}`}))}catch(e){console.error("Error processing styles or draw elements:",e)}})()}function applyFscssStyles(){document.querySelectorAll('[type*="fscss"]').forEach((e=>{fetch(e.href).then((e=>e.text())).then((e=>{const n=document.createElement("style");n.textContent=e,document.head.appendChild(n),xfscssProcessorWrap()})).catch((n=>{console.error(`Failed to load FSCSS from ${e.href}`,n)}))}))}function inf({host:e,path:n}){if(!e||!n)return void console.error("Both 'host' and 'path' are required.");const r=e.replace(/github/gi,"gh"),s=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${s}`)}xfscssProcessorWrap(),applyFscssStyles();
1
3
 
2
- function loadFScript(src, async = true){const script=document.createElement('script');script.type='text/javascript';script.async= async;src="https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js";script.src = src;document.body.appendChild(script);}loadFScript();function applyFscssStyles() {const fscssLinks=document.querySelectorAll('[type*="fscss"]');fscssLinks.forEach(link => {fetch(link.href).then(response=>response.text()).then(css =>{const style=document.createElement('style');style.textContent = css;document.head.appendChild(style);}).catch(error => {
3
- console.error(`Failed to load FSCSS from ${link.href}`, error);});});}function inf({ host, path }) {if (!host || !path) {console.error("Both 'host' and 'path' are required.");
4
- return;}const sanitizedHost = host.replace(/github/gi, 'gh');const sanitizedPath = path.replace(/\s*->\s*/g, '/').replace(/\n/g, '');const finalUrl = `https://cdn.jsdelivr.net/${sanitizedHost}/${sanitizedPath}`;loadFScript(finalUrl);
5
- }function exec({ type = 'text', content, onError, onSuccess }) {if (!content) {const errorText = 'No CSS content or URL provided.';console.error(errorText);if (onError) onError(errorText);
6
- return;
7
- }const style=document.createElement('style');const appendStyle=cssText=> {style.textContent = cssText;document.head.appendChild(style);if (onSuccess)onSuccess(style);};if (type==='text'||type==='auto'|| type==='text/fscss'||type==='text/css'){appendStyle(content);}else if (type==='fromUrl'||type==='URL' ||type==='fromURL'||type==='link') {fetch(content).then(res => {if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`);
8
- return res.text();}).then(css => appendStyle(css)).catch(err => {console.error(`Failed to load CSS from URL: ${content}`, err);if (onError) onError(err.message);});} else {const errorText = `Unsupported type "${type}". Use "text" or "fromUrl".`;console.error(errorText);if(onError) onError(errorText);}}
package/e/xfscss.js CHANGED
@@ -1,7 +1,3 @@
1
- function loadFScript(src, async = true){const script=document.createElement('script');script.type='text/javascript';script.async= async;src="https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js";script.src = src;document.body.appendChild(script);}loadFScript();export function applyFscssStyles() {const fscssLinks=document.querySelectorAll('[type*="fscss"]');fscssLinks.forEach(link => {fetch(link.href).then(response=>response.text()).then(css =>{const style=document.createElement('style');style.textContent = css;document.head.appendChild(style);}).catch(error => {
2
- console.error(`Failed to load FSCSS from ${link.href}`, error);});});}export function inf({ host, path }) {if (!host || !path) {console.error("Both 'host' and 'path' are required.");
3
- return;}const sanitizedHost = host.replace(/github/gi, 'gh');const sanitizedPath = path.replace(/\s*->\s*/g, '/').replace(/\n/g, '');const finalUrl = `https://cdn.jsdelivr.net/${sanitizedHost}/${sanitizedPath}`;loadFScript(finalUrl);
4
- }export function exec({ type = 'text', content, onError, onSuccess }) {if (!content) {const errorText = 'No CSS content or URL provided.';console.error(errorText);if (onError) onError(errorText);
5
- return;
6
- }const style=document.createElement('style');const appendStyle=cssText=> {style.textContent = cssText;document.head.appendChild(style);if (onSuccess)onSuccess(style);};if (type==='text'||type==='auto'|| type==='text/fscss'||type==='text/css'){appendStyle(content);}else if (type==='fromUrl'||type==='URL' ||type==='fromURL'||type==='link') {fetch(content).then(res => {if (!res.ok) throw new Error(`HTTP error! Status: ${res.status}`);
7
- return res.text();}).then(css => appendStyle(css)).catch(err => {console.error(`Failed to load CSS from URL: ${content}`, err);if (onError) onError(err.message);});} else {const errorText = `Unsupported type "${type}". Use "text" or "fromUrl".`;console.error(errorText);if(onError) onError(errorText);}}
1
+ /* FIGSH-FSCSS light, source v3, fscss.devtem.org */
2
+ export function exec({type:e="text",content:n,onError:r,onSuccess:s}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const t=document.createElement("style"),o=e=>{t.textContent=e,document.head.appendChild(t),s&&s(t),xfscssProcessorWrap()},c=["text","auto","text/fscss","text/css"].includes(e),i=["fromUrl","URL","fromURL","link"].includes(e);if(c)o(n);else if(i)fetch(n).then((e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.text()})).then(o).catch((e=>{const s=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${s}`),r&&r(s)}));else{const n=`Unsupported type "${e}". Use "text" or "fromUrl".`;console.error(`[FSCSS] ${n}`),r&&r(n)}}function xfscssProcessorWrap(){(async()=>{function e(e){return e=e.replace(/count\(\s*([\d\.]+)\s*(?:,\s*([\d\.]+)?)?\)/g,((e,n,r)=>{return null===r&&(r=1),s=parseInt(n),t=parseInt(r||1),`${Array(s).fill().map(((e,n)=>(n+1)*t))}`;var s,t}))}function n(e){return e=e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,s)=>(n||r||s).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>function(e){try{return new Function(`return ${e}`)()}catch(n){return console.error("Invalid expression:",e),e}}(n)))}const s={},t={},o=10,c={};function i(e,n){let r=0,s=n;for(;s<e.length&&("{"===e[s]?r++:"}"===e[s]&&r--,0!==r);)s++;return e.slice(n,s+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let s;for(;null!==(s=r.exec(e));)n.push({type:s[1],condition:s[2].trim(),block:s[3].trim()});return n}function a(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,s,t,o)=>{const c=s||t||o;return["_log","_error","_warn","_info"].includes(r)?c?(n+=`console.${r.slice(1)}("${c.replace(/"/g,'\\"')}");\n`,""):(console.warn(`fscss[exec(console)]: Empty argument for method: ${r}`),""):(console.warn(`fscss[exec(console)]: Unsupported method: ${r}`),"")}));if(n)try{new Function(n)()}catch(e){console.error("fscss[exec(console)]: Error executing transformed code:",e)}return r}function f(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let s,t=e;const o=[];for(;null!==(s=r.exec(e));){const r=s[1],t=s[2],c=s.index+s[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const a=i(e,c);if(0===a.length||"}"!==a[a.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+a.length);const f=l(a),u=t.split(",").map((e=>e.trim())).filter((e=>""!==e));n[r]&&console.warn(`fscss[definition] Warning: Duplicate @event definition for '${r}'. The last one will be used.`),n[r]={args:u,conditionBlocks:f},o.push([s.index,c+a.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];t=t.slice(0,n)+t.slice(r)}return t=t.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,s)=>{const t=n[r];if(!t)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=s.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==t.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${t.args.length}, got ${c.length}.`),t.args.forEach(((e,n)=>{void 0!==c[n]?o[e]=c[n]:console.warn(`fscss[call] Warning: Missing value for argument '${e}' in @event '${r}' call.`)}));let i="",l=!1,a=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(a&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),a=!0),!l||"el"===e.type){if("el"===e.type){if(l)continue;l=!0}else{const n=e.condition.split(",").map((e=>e.trim())).filter((e=>""!==e));0===n.length?(console.warn(`fscss[logic] Warning: Empty condition in '${e.type}' block for @event '${r}'.`),l=!0):l=n.every((e=>{const n=e.match(/^(\w+)\s*(==|!=|>=|<=|>|<)\s*([^]+)$/);if(!n){const n=e.split(":").map((e=>e.trim()));if(2!==n.length)return console.warn(`fscss[logic] Warning: Malformed condition '${e}' in @event '${r}'. Expected 'variable operator value' or 'variable:value'.`),!1;const[s,t]=n;return s in o?o[s]===t:(console.warn(`fscss[logic] Warning: Condition variable '${s}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,s,t]=n;if(!(e in o))return console.warn(`fscss[logic] Warning: Condition variable '${e}' not provided in @event '${r}' context. Treating as false.`),!1;const c=o[e],i=isNaN(c)?c:Number(c),l=isNaN(t)?t:Number(t);switch(s){case"==":return i==l;case"!=":return i!=l;case">":return i>l;case"<":return i<l;case">=":return i>=l;case"<=":return i<=l;default:return!1}}}))}if(l){const n=e.block.match(/(\w+)\s*(?:\:\s*([^;]*);?|\|([^\|]+)\|?)/);n&&n[2]?i=n[2].trim():n&&n[3]?i=n[3].trim():console.warn(`fscss[logic] Warning: No valid CSS property assignment found in matched block for @event '${r}'. Block content: '${e.block}'.`);break}}return!i&&t.conditionBlocks.length>0&&!l?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==t.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),t.trim()}async function u(e){return e=(e=(e=(e=(e=e.replace(/exec\(\s*_init\sisjs\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/isjs.fscss)")).replace(/exec\(\s*_init\sthemes\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/trshapes.fthemes.fscss)")).replace(/exec\(_init\sarray1to500\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/1to500.fscss)")).replace(/exec\(_init\s+([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?\s*\)/g,((e,n,r)=>r?`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.${r})`:`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.fscss)`))).replace(/(\@import\((?:\s+)?(?:exec)?\((?:[\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?)([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?(?:\s+)?\)/g,((e,n,r,s)=>s?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${s}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function d(e){let n=e.replace(/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g,((e,n,r,s,t,o,i)=>{const l=r.split(",").map((e=>e.trim())).filter((e=>e)),a=s??t??o??i??"";return c[n]={params:l,body:a},""}));return n=n.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=c[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let o=s.body,i=[];return s.params.forEach(((e,n)=>{const r=s.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const c=i[1]?i[1]:"",l=void 0!==t[n]?t[n]:c,a=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");o=o.replace(a,l)})),o})),n}function p(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],s=e.slice(1,-1);const t=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=t.exec(s));)c.push({fullMatch:o[0],start:parseInt(o[1]),length:parseInt(o[2]),varName:o[3].trim(),index:o.index});for(let e=c.length-1;e>=0;e--){let r=c[e],t=r.start<0?s.length+r.start:r.start;t=Math.max(0,t);let o=s.substring(t,t+r.length);(t+r.length>s.length||t<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${r.varName}' in string literal specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[r.varName]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${r.varName}' found in string literal. The last extracted value will be used.`),n[r.varName]=o,s=s.slice(0,r.index)+s.slice(r.index+r.fullMatch.length)}return r+s+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,s,t,o){s=parseInt(s),t=parseInt(t),o=o.trim();let c=s<0?r.length+s:s;c=Math.max(0,c);let i=r.substring(c,c+t);return(c+t>r.length||c<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${o}' on token '${r}' specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[o]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${o}' found outside string literals. The last extracted value will be used.`),n[o]=i,r})),r=r.replace(/@ext\.(\w+)\!?/g,(function(e,r){return void 0===n[r]?(console.warn(`fscss:[@ext]Warning: Reference to undefined variable '@ext.${r}'. It will not be replaced.`),e):n[r]})),r}function $(e){const n=/@arr\(?\s*([\w\-_—0-9]+)\)?\[([^\]]+)\]\)?/g;let r;for(;null!==(r=n.exec(e));){const e=r[1],n=r[2].split(",").map((e=>e.trim()));s[e]=n}let t=e;return t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>s[n]?r?(newItems=r.split(",").map((e=>e.trim())),s[n].push(...newItems),""):(console.warn(`[FSCSS Warning] @arr push failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e))),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const t=s[n];return t?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>t.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,t.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\.(length|last|reverse|first|list|indices|randint|segment|sum|unique|sort|shuffle|min|max))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return t.length;if("first"===r)return t[0];if("last"===r)return t.at(-1);if("indices"===r)return Array(t.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return t.join(",");if("reverse"===r)return t.toReversed().join(",");if("randint"===r)return t[Math.floor(Math.random()*t.length)];if("segment"===r)return t.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(t)].join(",");if("sort"===r)return t.slice().sort().join(",");if("shuffle"===r)return t.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return t.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...t.map(Number));if("max"===r)return Math.max(...t.map(Number))}})),t=t.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,t)=>{const o=s[t];return o?o.map(((e,s)=>{const o=n.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),s+1),c=r.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${t}' not found for loop processing.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const t=parseInt(r)-1,o=s[n];return o?void 0!==o[t]?o[t]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${e+o}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${o+e}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const t=s[n];return t?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),t.map((e=>`${surArr[0]+e+surArr.at(-1)}`)).join(" ")):(console.warn(`[FSCSS Warning] @arr surround failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.join(o)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const t=s[n];return t?r?e:`[${t.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function g(e){const n={};function r(e){const n={},r=e.split(";");for(let e of r){if(e=e.trim(),!e)continue;const r=e.indexOf(":");if(-1===r){console.warn(`fscss[@fun] Invalid style line (missing colon): "${e}"`);continue}const s=e.substring(0,r).trim(),t=e.substring(r+1).trim();s?n[s]=t:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}const s=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;let t;for(;null!==(t=s.exec(e));){const e=t[1],s=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:s,props:r(s)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@fun] Full variable block replacement failed for "@fun.${r}". Variable not found.`),e))),o=o.replace(/@fun\(([\w\-\_\d\—]+)\s*\{[\s\S]*?\}\s*/g,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function m(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const l=parseInt(c),a=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=l>=0?t.substring(0,l):t.substring(t.length+l),n.add(`--${a}:${f};`),`${r}${s}${t}${o}`}));if(n.size>0){return r+`\n${`:root{${Array.from(n).join("\n")}\n}`}`}return r}function b(e){const n=new Map;let r,s=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,s,t)=>{const o=s||t;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return s;let t=0;let o=s;do{r=!1;for(const[e,s]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),t=o.replace(n,s);t!==o&&(r=!0,o=t)}t++}while(r&&t<100);var c;return t>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function x(e){return e=e.replace(/(?:mxs|\$p)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2:$14$15;$4:$14$15;$6:$14$15;$8:$14$15;$10:$14$15;$12:$14$15;").replace(/(?:mx|\$m)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2$14$15$4$14$15$6$14$15$8$14$15$10$14$15$12$14$15").replace(/rpt\((\d+)\,\s*("([^"]*)"|'([^']*)')\)/gi,((e,n,r)=>function(e,n){return e.replace(/^['"]|['"]$/g,"").repeat(Math.max(0,parseInt(n)))}(r,n))).replace(/\$(([\_\-\d\w]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,":root{--$1}").replace(/\$([^\!\s]+)!/gi,"var(--$1)").replace(/\$([\w\-\_\d]+)/gi,"var(--$1)").replace(/\-\*\-(([^\:]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,"-webkit-$1-moz-$1-ms-$1-o-$1").replace(/%i\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$21$4$21$6$21$8$21$10$21$12$21$14$21$16$21$18$21$20$21").replace(/%6\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$13$4$13$6$13$8$13$10$13$12$13").replace(/%5\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$11$4$11$6$11$8$11$10$11").replace(/%4\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$9$4$9$6$9$8$9").replace(/%3\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$7$4$7$6$7").replace(/%2\((([^\,\[\]]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$5$4$5").replace(/%1\((([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$3"),e=(e=e.replace(/%(\d+)\(([^[]+)\[\s*([^\]]+)\]\)/g,((e,n,r,s)=>{const t=r.split(",").map((e=>e.trim()));return t.length!=n?(console.warn(`Number of properties ${t.length} does not match %${n}`),e):t.map((e=>`${e}${s}`)).join("")}))).replace(/\$\(\s*@keyframes\s*(\S+)\)/gi,"$1{animation-name:$1;}@keyframes $1").replace(/\$\(\s*(\@[\w\-\*]*)\s*([^\{\}\,&]*)(\s*,\s*[^\{\}&]*)?&?(\[([^\{\}]*)\])?\s*\)/gi,"$2$3{animation:$2 $5;}$1 $2").replace(/\$\(\s*--([^\{\}]*)\)/gi,"$1").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/g\(([^"'\s]*)\,\s*(("([^"]*)"|'([^']*)')\,\s*)?("([^"]*)"|'([^']*)')\s*\)/gi,"$1 $4$5$1 $7$8").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/\$\(([^\:^\)]*)\)/gi,"[$1]")}async function w(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=[...e.matchAll(/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g)];let s=e;for(const e of r){const[r,t,o]=e;try{const e=t.replace(/["']/g,""),c=e.slice(e.lastIndexOf(".")).toLowerCase();if(e.trim().startsWith("_init")&&e.includes(" "))return void console.warn(`fscss[@import] library not found for: ${e}`);if(!n.includes(c))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const i=await fetch(e);if(!i.ok)throw new Error(`fscss[@import] HTTP ${i.status} for ${t}`);const l=h(await i.text(),o.trim());s=s.replace(r,l)}catch(e){console.error(`fscss[@import] Failed: ${t} `,e),s=s.replace(r,`/* Failed import: ${t} */`)}}return s}function h(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),s=e.match(r);return s?s.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const v=[".fscss",".css",".txt",".scss",".less",".xfscss"];async function k(e,n=0,r=window.location.href){if(n>o)return console.warn("fscss[@import]\n Maximum import depth exceeded. Skipping further imports."),e;const s=Array.from(e.matchAll(/@import\s*\(\s*exec\s*\(\s*((?:'[^']*'|"[^"]*"|[^'")]\S*)\s*)\)\s*\)/g));if(0===s.length)return e;const t=await Promise.all(s.map((async e=>{const[s,t]=e;try{const e=t.replace(/^['"](.*)['"]$/,"$1").trim(),s=new URL(e,r).href,o=new URL(s).pathname,c=o.slice(o.lastIndexOf(".")).toLowerCase();if(s.trim().startsWith("_init")&&s.includes(" "))return void console.warn(`fscss[@import] library not found for: ${s}`);if(!v.includes(c))return console.warn(`fscss[@import] \n Invalid import URL extension "${c}" for "${s}". Only ${v.join(", ")} are allowed.`),`/* Invalid extension for "${s}" */`;const i=await fetch(s);if(!i.ok)throw new Error(`HTTP ${i.status} for ${s}`);return k(await i.text(),n+1,s)}catch(e){return console.warn(`fscss[@import]\n Failed to import "${t}" from "${r}":`,e),`/* Error importing "${t}": ${e.message} */`}})));let c=0,i="";return s.forEach(((n,r)=>{i+=e.slice(c,n.index),i+=t[r],c=n.index+n[0].length})),i+=e.slice(c),i}async function j(e){try{return await k(e)}catch(n){return console.warn("fscss[]\n Processing failed:",n),console.warn("fscss[@import] Warning: can't resolve imports"),e}}async function y(e){const n=[...e.matchAll(/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g)];let r=e;for(const e of n){let[n,s,t,o,c]=e;s=s.trim();const i=(t||o||c).trim();try{const e=await fetch(i);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${i}`);const t=await e.text();if("*"===s&&(r=r.replace(n,t)),"*"!==s&&s.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${n}: unexpected *`),r=r.replace(n,"/* syntax error: unexpected * */")),"*"!==s&&!s.includes("*")){const e=s.split(",").map((e=>e.trim())),o=await S(t,e);r=r.replace(n,o)}}catch(e){console.error(`fscss[@import] Failed: ${i} `,e),r=r.replace(n,`/* Failed import: ${i} */`)}}return r}async function S(e,n=[]){if(!e||""===e||"string"!=typeof e)return console.warn("FSCSS >Invalid input");if(!n||0===n.length)return console.warn("FSCSS >Invalid input");let r="";return n.forEach((n=>{let s="",t=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;t=r,c?s=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),s=r):s=r}const c=new RegExp("@define\\s+("+t+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${t} is undefined for import`);const l=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(l,((e,n,r,t)=>`${n}${s}${t}`))+"\n"})),r.trim()}try{await async function(){const s=document.querySelectorAll("style");if(s.length)for(const o of s){let s=o.textContent;s.includes("exec.obj.block(all)")||(s.includes("exec.obj.block(init lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(vfc)")||(s=s.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,s,t)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&t&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${t})`),s&&!t?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(t?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(t.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${t}`),t?`${n}${t.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),s.includes("exec.obj.block(store:before)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(f var)")||(s=function(e){const n={},r=[],s=e.split("\n");let t=!1;const o={};for(let e=0;e<s.length;e++){let c=s[e].trim();if(c.includes("{")){t=!0,r.push(c);continue}if(c.includes("}")){t=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,l=c.match(i);if(l){const[,e,s]=l;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const a=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(a,((e,r)=>void 0!==o[r]?o[r]:void 0!==n[r]?n[r]:e)),r.push(c)}return{css:r.join("\n"),getVariable:function(e){return n[e]||null}}}(s).css),s.includes("exec.obj.block(fun)")||(s=g(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(arr)")||(s=$(s)),s.includes("exec.obj.block(event)")||(s=f(s)),s.includes("exec.obj.block(random)")||(s=s.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),s=n.split(",").map((e=>e.trim()));if(0===s.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=s.join(":");t[e]||(t[e]={values:s,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=t[e],o=r.values[r.index%r.values.length];return r.index>=r.values.length&&r.index%r.values.length==0&&console.warn(`fscss[@random] Warning: Ordered sequence [${n}] is looping back to the beginning.`),r.index++,o}return s[Math.floor(Math.random()*s.length)]}))),s.includes("exec.obj.block(copy)")||(s=m(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(t group)")||(s=x(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(debug)")||(s=a(s))),s=s.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=s}else console.warn("fscss[Obj]\n No <style> elements found.")}(),await void document.querySelectorAll(".draw").forEach((e=>{const n=e.style.color||"#000";e.style.color="transparent",e.style.webkitTextStroke=`2px ${n}`}))}catch(e){console.error("Error processing styles or draw elements:",e)}})()}function applyFscssStyles(){document.querySelectorAll('[type*="fscss"]').forEach((e=>{fetch(e.href).then((e=>e.text())).then((e=>{const n=document.createElement("style");n.textContent=e,document.head.appendChild(n),xfscssProcessorWrap()})).catch((n=>{console.error(`Failed to load FSCSS from ${e.href}`,n)}))}))}export function inf({host:e,path:n}){if(!e||!n)return void console.error("Both 'host' and 'path' are required.");const r=e.replace(/github/gi,"gh"),s=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${s}`)}xfscssProcessorWrap(),applyFscssStyles();
3
+
package/example.fscss CHANGED
@@ -1,16 +1,16 @@
1
- @import(exec(_init themes))
2
- @import(exec(style.fscss).pick(body))
1
+ @import((*) from "style.fscss")
2
+ @import((
3
+ flex-x,
4
+ flex-wrap-center as fx-wc,
5
+ flex-responsive as fx-r
6
+ ) from flex-control/fscss)
3
7
  @arr colors[#1E2783, #8C29B2, #C41348]
4
- $colors: @arr.colors!;
5
- div{
6
- background: @event.theme(forest);
7
- %2(width, height[: 200px;])
8
- tr Shape: @event.shape(star);
9
- }
10
- .box{
11
- background: radial-gradient(40deg, $colors.list);
12
- }
13
- .box-b{
14
- background: radial-gradient(40deg, $colors.reverse);
15
- }
16
- exec(_log, "Hello World!")
8
+ .container{
9
+ @fx-wc()
10
+ background: @random(@arr.colors);
11
+ }
12
+ .container .card{
13
+ @flex-x()
14
+ background: linear-gradient(40deg, @arr.colors!.list);
15
+ }
16
+
package/exec.js CHANGED
@@ -1,10 +1,3 @@
1
- const DOMFSCSSEng = (async ()=>{var fsTc=document.createElement('script');fsTc.type = 'text/javascript';fsTc.async='true';fsTc.src='https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';var sTcZB=document.createElement('script');sTcZB.type = 'text/javascript';sTcZB.async='true';sTcZB.text='fs_cssText = (0);';document.body.appendChild(fsTc);fstylesheet=document.querySelectorAll("[type*='fscss']");for(c=0;c<fstylesheet.length;c++){fetch(fstylesheet[c].href).then(response => response.text()).then(data => {document.body.innerHTML+=`<style>${data}</style>`;}).catch(error => {});}
2
- var text ='text';var url ='fromUrl';var fromUrl = 'fromUrl';var write = 'text';function inf(host,jsdl){if(typeof jsdl!=='undefined'&&host!=='undefined'){var ht=host.replace(/github/gi, 'gh');var cov=jsdl.replace(/\s*-\>\s*/g, '/').replace(/\n/g, '');var url=`https://cdn.jsdelivr.net/${ht}/${cov}`;var ScrT=document.createElement('script');ScrT.type='text/javascript';ScrT.async='true';ScrT.src=url;document.body.appendChild(ScrT);}}function exec(text,fscss_style_sheet){if(typeof fscss_style_sheet!=='undefined'&&text=='text'){var doc=document;
3
- const AJWinDocStyleElement = document.createElement("style");
4
- AJWinDocStyleElement.innerHTML = `${fscss_style_sheet}`;
5
- document.head.appendChild(AJWinDocStyleElement);
6
- }else if(typeof fscss_style_sheet!=='undefined'&&text=='fromUrl'){var doc=document;fetch(fscss_style_sheet).then(response =>response.text()).then(data=>{const AJWinDocStyleElement = document.createElement("style");
7
- AJWinDocStyleElement.innerHTML = `${data}`;
8
- document.head.appendChild(AJWinDocStyleElement);}).catch(error=>{});}}
9
- })()
1
+ /* Figsh-fscss light, source v3, fscss.devtem.org */
2
+ function exec({type:e="text",content:n,onError:r,onSuccess:s}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const t=document.createElement("style"),o=e=>{t.textContent=e,document.head.appendChild(t),s&&s(t),xfscssProcessorWrap()},c=["text","auto","text/fscss","text/css"].includes(e),i=["fromUrl","URL","fromURL","link"].includes(e);if(c)o(n);else if(i)fetch(n).then((e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.text()})).then(o).catch((e=>{const s=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${s}`),r&&r(s)}));else{const n=`Unsupported type "${e}". Use "text" or "fromUrl".`;console.error(`[FSCSS] ${n}`),r&&r(n)}}function xfscssProcessorWrap(){(async()=>{function e(e){return e=e.replace(/count\(\s*([\d\.]+)\s*(?:,\s*([\d\.]+)?)?\)/g,((e,n,r)=>{return null===r&&(r=1),s=parseInt(n),t=parseInt(r||1),`${Array(s).fill().map(((e,n)=>(n+1)*t))}`;var s,t}))}function n(e){return e=e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,s)=>(n||r||s).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>function(e){try{return new Function(`return ${e}`)()}catch(n){return console.error("Invalid expression:",e),e}}(n)))}const s={},t={},o=10,c={};function i(e,n){let r=0,s=n;for(;s<e.length&&("{"===e[s]?r++:"}"===e[s]&&r--,0!==r);)s++;return e.slice(n,s+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let s;for(;null!==(s=r.exec(e));)n.push({type:s[1],condition:s[2].trim(),block:s[3].trim()});return n}function a(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,s,t,o)=>{const c=s||t||o;return["_log","_error","_warn","_info"].includes(r)?c?(n+=`console.${r.slice(1)}("${c.replace(/"/g,'\\"')}");\n`,""):(console.warn(`fscss[exec(console)]: Empty argument for method: ${r}`),""):(console.warn(`fscss[exec(console)]: Unsupported method: ${r}`),"")}));if(n)try{new Function(n)()}catch(e){console.error("fscss[exec(console)]: Error executing transformed code:",e)}return r}function f(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let s,t=e;const o=[];for(;null!==(s=r.exec(e));){const r=s[1],t=s[2],c=s.index+s[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const a=i(e,c);if(0===a.length||"}"!==a[a.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+a.length);const f=l(a),u=t.split(",").map((e=>e.trim())).filter((e=>""!==e));n[r]&&console.warn(`fscss[definition] Warning: Duplicate @event definition for '${r}'. The last one will be used.`),n[r]={args:u,conditionBlocks:f},o.push([s.index,c+a.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];t=t.slice(0,n)+t.slice(r)}return t=t.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,s)=>{const t=n[r];if(!t)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=s.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==t.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${t.args.length}, got ${c.length}.`),t.args.forEach(((e,n)=>{void 0!==c[n]?o[e]=c[n]:console.warn(`fscss[call] Warning: Missing value for argument '${e}' in @event '${r}' call.`)}));let i="",l=!1,a=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(a&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),a=!0),!l||"el"===e.type){if("el"===e.type){if(l)continue;l=!0}else{const n=e.condition.split(",").map((e=>e.trim())).filter((e=>""!==e));0===n.length?(console.warn(`fscss[logic] Warning: Empty condition in '${e.type}' block for @event '${r}'.`),l=!0):l=n.every((e=>{const n=e.match(/^(\w+)\s*(==|!=|>=|<=|>|<)\s*([^]+)$/);if(!n){const n=e.split(":").map((e=>e.trim()));if(2!==n.length)return console.warn(`fscss[logic] Warning: Malformed condition '${e}' in @event '${r}'. Expected 'variable operator value' or 'variable:value'.`),!1;const[s,t]=n;return s in o?o[s]===t:(console.warn(`fscss[logic] Warning: Condition variable '${s}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,s,t]=n;if(!(e in o))return console.warn(`fscss[logic] Warning: Condition variable '${e}' not provided in @event '${r}' context. Treating as false.`),!1;const c=o[e],i=isNaN(c)?c:Number(c),l=isNaN(t)?t:Number(t);switch(s){case"==":return i==l;case"!=":return i!=l;case">":return i>l;case"<":return i<l;case">=":return i>=l;case"<=":return i<=l;default:return!1}}}))}if(l){const n=e.block.match(/(\w+)\s*(?:\:\s*([^;]*);?|\|([^\|]+)\|?)/);n&&n[2]?i=n[2].trim():n&&n[3]?i=n[3].trim():console.warn(`fscss[logic] Warning: No valid CSS property assignment found in matched block for @event '${r}'. Block content: '${e.block}'.`);break}}return!i&&t.conditionBlocks.length>0&&!l?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==t.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),t.trim()}async function u(e){return e=(e=(e=(e=(e=e.replace(/exec\(\s*_init\sisjs\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/isjs.fscss)")).replace(/exec\(\s*_init\sthemes\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/trshapes.fthemes.fscss)")).replace(/exec\(_init\sarray1to500\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/1to500.fscss)")).replace(/exec\(_init\s+([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?\s*\)/g,((e,n,r)=>r?`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.${r})`:`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.fscss)`))).replace(/(\@import\((?:\s+)?(?:exec)?\((?:[\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?)([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?(?:\s+)?\)/g,((e,n,r,s)=>s?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${s}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function d(e){let n=e.replace(/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g,((e,n,r,s,t,o,i)=>{const l=r.split(",").map((e=>e.trim())).filter((e=>e)),a=s??t??o??i??"";return c[n]={params:l,body:a},""}));return n=n.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=c[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let o=s.body,i=[];return s.params.forEach(((e,n)=>{const r=s.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const c=i[1]?i[1]:"",l=void 0!==t[n]?t[n]:c,a=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");o=o.replace(a,l)})),o})),n}function p(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],s=e.slice(1,-1);const t=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=t.exec(s));)c.push({fullMatch:o[0],start:parseInt(o[1]),length:parseInt(o[2]),varName:o[3].trim(),index:o.index});for(let e=c.length-1;e>=0;e--){let r=c[e],t=r.start<0?s.length+r.start:r.start;t=Math.max(0,t);let o=s.substring(t,t+r.length);(t+r.length>s.length||t<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${r.varName}' in string literal specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[r.varName]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${r.varName}' found in string literal. The last extracted value will be used.`),n[r.varName]=o,s=s.slice(0,r.index)+s.slice(r.index+r.fullMatch.length)}return r+s+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,s,t,o){s=parseInt(s),t=parseInt(t),o=o.trim();let c=s<0?r.length+s:s;c=Math.max(0,c);let i=r.substring(c,c+t);return(c+t>r.length||c<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${o}' on token '${r}' specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[o]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${o}' found outside string literals. The last extracted value will be used.`),n[o]=i,r})),r=r.replace(/@ext\.(\w+)\!?/g,(function(e,r){return void 0===n[r]?(console.warn(`fscss:[@ext]Warning: Reference to undefined variable '@ext.${r}'. It will not be replaced.`),e):n[r]})),r}function $(e){const n=/@arr\(?\s*([\w\-_—0-9]+)\)?\[([^\]]+)\]\)?/g;let r;for(;null!==(r=n.exec(e));){const e=r[1],n=r[2].split(",").map((e=>e.trim()));s[e]=n}let t=e;return t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>s[n]?r?(newItems=r.split(",").map((e=>e.trim())),s[n].push(...newItems),""):(console.warn(`[FSCSS Warning] @arr push failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e))),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const t=s[n];return t?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>t.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,t.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\.(length|last|reverse|first|list|indices|randint|segment|sum|unique|sort|shuffle|min|max))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return t.length;if("first"===r)return t[0];if("last"===r)return t.at(-1);if("indices"===r)return Array(t.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return t.join(",");if("reverse"===r)return t.toReversed().join(",");if("randint"===r)return t[Math.floor(Math.random()*t.length)];if("segment"===r)return t.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(t)].join(",");if("sort"===r)return t.slice().sort().join(",");if("shuffle"===r)return t.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return t.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...t.map(Number));if("max"===r)return Math.max(...t.map(Number))}})),t=t.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,t)=>{const o=s[t];return o?o.map(((e,s)=>{const o=n.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),s+1),c=r.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${t}' not found for loop processing.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const t=parseInt(r)-1,o=s[n];return o?void 0!==o[t]?o[t]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${e+o}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${o+e}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const t=s[n];return t?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),t.map((e=>`${surArr[0]+e+surArr.at(-1)}`)).join(" ")):(console.warn(`[FSCSS Warning] @arr surround failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.join(o)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const t=s[n];return t?r?e:`[${t.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function g(e){const n={};function r(e){const n={},r=e.split(";");for(let e of r){if(e=e.trim(),!e)continue;const r=e.indexOf(":");if(-1===r){console.warn(`fscss[@fun] Invalid style line (missing colon): "${e}"`);continue}const s=e.substring(0,r).trim(),t=e.substring(r+1).trim();s?n[s]=t:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}const s=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;let t;for(;null!==(t=s.exec(e));){const e=t[1],s=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:s,props:r(s)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@fun] Full variable block replacement failed for "@fun.${r}". Variable not found.`),e))),o=o.replace(/@fun\(([\w\-\_\d\—]+)\s*\{[\s\S]*?\}\s*/g,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function m(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const l=parseInt(c),a=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=l>=0?t.substring(0,l):t.substring(t.length+l),n.add(`--${a}:${f};`),`${r}${s}${t}${o}`}));if(n.size>0){return r+`\n${`:root{${Array.from(n).join("\n")}\n}`}`}return r}function b(e){const n=new Map;let r,s=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,s,t)=>{const o=s||t;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return s;let t=0;let o=s;do{r=!1;for(const[e,s]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),t=o.replace(n,s);t!==o&&(r=!0,o=t)}t++}while(r&&t<100);var c;return t>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function x(e){return e=e.replace(/(?:mxs|\$p)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2:$14$15;$4:$14$15;$6:$14$15;$8:$14$15;$10:$14$15;$12:$14$15;").replace(/(?:mx|\$m)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2$14$15$4$14$15$6$14$15$8$14$15$10$14$15$12$14$15").replace(/rpt\((\d+)\,\s*("([^"]*)"|'([^']*)')\)/gi,((e,n,r)=>function(e,n){return e.replace(/^['"]|['"]$/g,"").repeat(Math.max(0,parseInt(n)))}(r,n))).replace(/\$(([\_\-\d\w]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,":root{--$1}").replace(/\$([^\!\s]+)!/gi,"var(--$1)").replace(/\$([\w\-\_\d]+)/gi,"var(--$1)").replace(/\-\*\-(([^\:]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,"-webkit-$1-moz-$1-ms-$1-o-$1").replace(/%i\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$21$4$21$6$21$8$21$10$21$12$21$14$21$16$21$18$21$20$21").replace(/%6\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$13$4$13$6$13$8$13$10$13$12$13").replace(/%5\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$11$4$11$6$11$8$11$10$11").replace(/%4\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$9$4$9$6$9$8$9").replace(/%3\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$7$4$7$6$7").replace(/%2\((([^\,\[\]]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$5$4$5").replace(/%1\((([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$3"),e=(e=e.replace(/%(\d+)\(([^[]+)\[\s*([^\]]+)\]\)/g,((e,n,r,s)=>{const t=r.split(",").map((e=>e.trim()));return t.length!=n?(console.warn(`Number of properties ${t.length} does not match %${n}`),e):t.map((e=>`${e}${s}`)).join("")}))).replace(/\$\(\s*@keyframes\s*(\S+)\)/gi,"$1{animation-name:$1;}@keyframes $1").replace(/\$\(\s*(\@[\w\-\*]*)\s*([^\{\}\,&]*)(\s*,\s*[^\{\}&]*)?&?(\[([^\{\}]*)\])?\s*\)/gi,"$2$3{animation:$2 $5;}$1 $2").replace(/\$\(\s*--([^\{\}]*)\)/gi,"$1").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/g\(([^"'\s]*)\,\s*(("([^"]*)"|'([^']*)')\,\s*)?("([^"]*)"|'([^']*)')\s*\)/gi,"$1 $4$5$1 $7$8").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/\$\(([^\:^\)]*)\)/gi,"[$1]")}async function w(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=[...e.matchAll(/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g)];let s=e;for(const e of r){const[r,t,o]=e;try{const e=t.replace(/["']/g,""),c=e.slice(e.lastIndexOf(".")).toLowerCase();if(e.trim().startsWith("_init")&&e.includes(" "))return void console.warn(`fscss[@import] library not found for: ${e}`);if(!n.includes(c))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const i=await fetch(e);if(!i.ok)throw new Error(`fscss[@import] HTTP ${i.status} for ${t}`);const l=h(await i.text(),o.trim());s=s.replace(r,l)}catch(e){console.error(`fscss[@import] Failed: ${t} `,e),s=s.replace(r,`/* Failed import: ${t} */`)}}return s}function h(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),s=e.match(r);return s?s.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const v=[".fscss",".css",".txt",".scss",".less",".xfscss"];async function k(e,n=0,r=window.location.href){if(n>o)return console.warn("fscss[@import]\n Maximum import depth exceeded. Skipping further imports."),e;const s=Array.from(e.matchAll(/@import\s*\(\s*exec\s*\(\s*((?:'[^']*'|"[^"]*"|[^'")]\S*)\s*)\)\s*\)/g));if(0===s.length)return e;const t=await Promise.all(s.map((async e=>{const[s,t]=e;try{const e=t.replace(/^['"](.*)['"]$/,"$1").trim(),s=new URL(e,r).href,o=new URL(s).pathname,c=o.slice(o.lastIndexOf(".")).toLowerCase();if(s.trim().startsWith("_init")&&s.includes(" "))return void console.warn(`fscss[@import] library not found for: ${s}`);if(!v.includes(c))return console.warn(`fscss[@import] \n Invalid import URL extension "${c}" for "${s}". Only ${v.join(", ")} are allowed.`),`/* Invalid extension for "${s}" */`;const i=await fetch(s);if(!i.ok)throw new Error(`HTTP ${i.status} for ${s}`);return k(await i.text(),n+1,s)}catch(e){return console.warn(`fscss[@import]\n Failed to import "${t}" from "${r}":`,e),`/* Error importing "${t}": ${e.message} */`}})));let c=0,i="";return s.forEach(((n,r)=>{i+=e.slice(c,n.index),i+=t[r],c=n.index+n[0].length})),i+=e.slice(c),i}async function j(e){try{return await k(e)}catch(n){return console.warn("fscss[]\n Processing failed:",n),console.warn("fscss[@import] Warning: can't resolve imports"),e}}async function y(e){const n=[...e.matchAll(/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g)];let r=e;for(const e of n){let[n,s,t,o,c]=e;s=s.trim();const i=(t||o||c).trim();try{const e=await fetch(i);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${i}`);const t=await e.text();if("*"===s&&(r=r.replace(n,t)),"*"!==s&&s.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${n}: unexpected *`),r=r.replace(n,"/* syntax error: unexpected * */")),"*"!==s&&!s.includes("*")){const e=s.split(",").map((e=>e.trim())),o=await S(t,e);r=r.replace(n,o)}}catch(e){console.error(`fscss[@import] Failed: ${i} `,e),r=r.replace(n,`/* Failed import: ${i} */`)}}return r}async function S(e,n=[]){if(!e||""===e||"string"!=typeof e)return console.warn("FSCSS >Invalid input");if(!n||0===n.length)return console.warn("FSCSS >Invalid input");let r="";return n.forEach((n=>{let s="",t=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;t=r,c?s=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),s=r):s=r}const c=new RegExp("@define\\s+("+t+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${t} is undefined for import`);const l=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(l,((e,n,r,t)=>`${n}${s}${t}`))+"\n"})),r.trim()}try{await async function(){const s=document.querySelectorAll("style");if(s.length)for(const o of s){let s=o.textContent;s.includes("exec.obj.block(all)")||(s.includes("exec.obj.block(init lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(vfc)")||(s=s.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,s,t)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&t&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${t})`),s&&!t?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(t?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(t.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${t}`),t?`${n}${t.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),s.includes("exec.obj.block(store:before)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(f var)")||(s=function(e){const n={},r=[],s=e.split("\n");let t=!1;const o={};for(let e=0;e<s.length;e++){let c=s[e].trim();if(c.includes("{")){t=!0,r.push(c);continue}if(c.includes("}")){t=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,l=c.match(i);if(l){const[,e,s]=l;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const a=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(a,((e,r)=>void 0!==o[r]?o[r]:void 0!==n[r]?n[r]:e)),r.push(c)}return{css:r.join("\n"),getVariable:function(e){return n[e]||null}}}(s).css),s.includes("exec.obj.block(fun)")||(s=g(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(arr)")||(s=$(s)),s.includes("exec.obj.block(event)")||(s=f(s)),s.includes("exec.obj.block(random)")||(s=s.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),s=n.split(",").map((e=>e.trim()));if(0===s.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=s.join(":");t[e]||(t[e]={values:s,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=t[e],o=r.values[r.index%r.values.length];return r.index>=r.values.length&&r.index%r.values.length==0&&console.warn(`fscss[@random] Warning: Ordered sequence [${n}] is looping back to the beginning.`),r.index++,o}return s[Math.floor(Math.random()*s.length)]}))),s.includes("exec.obj.block(copy)")||(s=m(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(t group)")||(s=x(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(debug)")||(s=a(s))),s=s.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=s}else console.warn("fscss[Obj]\n No <style> elements found.")}(),await void document.querySelectorAll(".draw").forEach((e=>{const n=e.style.color||"#000";e.style.color="transparent",e.style.webkitTextStroke=`2px ${n}`}))}catch(e){console.error("Error processing styles or draw elements:",e)}})()}function applyFscssStyles(){document.querySelectorAll('[type*="fscss"]').forEach((e=>{fetch(e.href).then((e=>e.text())).then((e=>{const n=document.createElement("style");n.textContent=e,document.head.appendChild(n),xfscssProcessorWrap()})).catch((n=>{console.error(`Failed to load FSCSS from ${e.href}`,n)}))}))}function inf({host:e,path:n}){if(!e||!n)return void console.error("Both 'host' and 'path' are required.");const r=e.replace(/github/gi,"gh"),s=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${s}`)}xfscssProcessorWrap(),applyFscssStyles();
10
3
 
package/index.js CHANGED
@@ -1,10 +1,4 @@
1
- const DOMFSCSSEng = (async ()=>{var fsTc=document.createElement('script');fsTc.type = 'text/javascript';fsTc.async='true';fsTc.src='https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';var sTcZB=document.createElement('script');sTcZB.type = 'text/javascript';sTcZB.async='true';sTcZB.text='fs_cssText = (0);';document.body.appendChild(fsTc);fstylesheet=document.querySelectorAll("[type*='fscss']");for(c=0;c<fstylesheet.length;c++){fetch(fstylesheet[c].href).then(response => response.text()).then(data => {document.body.innerHTML+=`<style>${data}</style>`;}).catch(error => {});}
2
- var text ='text';var url ='fromUrl';var fromUrl = 'fromUrl';var write = 'text';function inf(host,jsdl){if(typeof jsdl!=='undefined'&&host!=='undefined'){var ht=host.replace(/github/gi, 'gh');var cov=jsdl.replace(/\s*-\>\s*/g, '/').replace(/\n/g, '');var url=`https://cdn.jsdelivr.net/${ht}/${cov}`;var ScrT=document.createElement('script');ScrT.type='text/javascript';ScrT.async='true';ScrT.src=url;document.body.appendChild(ScrT);}}function exec(text,fscss_style_sheet){if(typeof fscss_style_sheet!=='undefined'&&text=='text'){var doc=document;
3
- const AJWinDocStyleElement = document.createElement("style");
4
- AJWinDocStyleElement.innerHTML = `${fscss_style_sheet}`;
5
- document.head.appendChild(AJWinDocStyleElement);
6
- }else if(typeof fscss_style_sheet!=='undefined'&&text=='fromUrl'){var doc=document;fetch(fscss_style_sheet).then(response =>response.text()).then(data=>{const AJWinDocStyleElement = document.createElement("style");
7
- AJWinDocStyleElement.innerHTML = `${data}`;
8
- document.head.appendChild(AJWinDocStyleElement);}).catch(error=>{});}}
9
- })()
1
+ /* Figsh-fscss light, source v3, fscss.devtem.org */
2
+ function exec({type:e="text",content:n,onError:r,onSuccess:s}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const t=document.createElement("style"),o=e=>{t.textContent=e,document.head.appendChild(t),s&&s(t),xfscssProcessorWrap()},c=["text","auto","text/fscss","text/css"].includes(e),i=["fromUrl","URL","fromURL","link"].includes(e);if(c)o(n);else if(i)fetch(n).then((e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.text()})).then(o).catch((e=>{const s=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${s}`),r&&r(s)}));else{const n=`Unsupported type "${e}". Use "text" or "fromUrl".`;console.error(`[FSCSS] ${n}`),r&&r(n)}}function xfscssProcessorWrap(){(async()=>{function e(e){return e=e.replace(/count\(\s*([\d\.]+)\s*(?:,\s*([\d\.]+)?)?\)/g,((e,n,r)=>{return null===r&&(r=1),s=parseInt(n),t=parseInt(r||1),`${Array(s).fill().map(((e,n)=>(n+1)*t))}`;var s,t}))}function n(e){return e=e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,s)=>(n||r||s).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>function(e){try{return new Function(`return ${e}`)()}catch(n){return console.error("Invalid expression:",e),e}}(n)))}const s={},t={},o=10,c={};function i(e,n){let r=0,s=n;for(;s<e.length&&("{"===e[s]?r++:"}"===e[s]&&r--,0!==r);)s++;return e.slice(n,s+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let s;for(;null!==(s=r.exec(e));)n.push({type:s[1],condition:s[2].trim(),block:s[3].trim()});return n}function a(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,s,t,o)=>{const c=s||t||o;return["_log","_error","_warn","_info"].includes(r)?c?(n+=`console.${r.slice(1)}("${c.replace(/"/g,'\\"')}");\n`,""):(console.warn(`fscss[exec(console)]: Empty argument for method: ${r}`),""):(console.warn(`fscss[exec(console)]: Unsupported method: ${r}`),"")}));if(n)try{new Function(n)()}catch(e){console.error("fscss[exec(console)]: Error executing transformed code:",e)}return r}function f(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let s,t=e;const o=[];for(;null!==(s=r.exec(e));){const r=s[1],t=s[2],c=s.index+s[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const a=i(e,c);if(0===a.length||"}"!==a[a.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+a.length);const f=l(a),u=t.split(",").map((e=>e.trim())).filter((e=>""!==e));n[r]&&console.warn(`fscss[definition] Warning: Duplicate @event definition for '${r}'. The last one will be used.`),n[r]={args:u,conditionBlocks:f},o.push([s.index,c+a.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];t=t.slice(0,n)+t.slice(r)}return t=t.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,s)=>{const t=n[r];if(!t)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=s.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==t.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${t.args.length}, got ${c.length}.`),t.args.forEach(((e,n)=>{void 0!==c[n]?o[e]=c[n]:console.warn(`fscss[call] Warning: Missing value for argument '${e}' in @event '${r}' call.`)}));let i="",l=!1,a=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(a&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),a=!0),!l||"el"===e.type){if("el"===e.type){if(l)continue;l=!0}else{const n=e.condition.split(",").map((e=>e.trim())).filter((e=>""!==e));0===n.length?(console.warn(`fscss[logic] Warning: Empty condition in '${e.type}' block for @event '${r}'.`),l=!0):l=n.every((e=>{const n=e.match(/^(\w+)\s*(==|!=|>=|<=|>|<)\s*([^]+)$/);if(!n){const n=e.split(":").map((e=>e.trim()));if(2!==n.length)return console.warn(`fscss[logic] Warning: Malformed condition '${e}' in @event '${r}'. Expected 'variable operator value' or 'variable:value'.`),!1;const[s,t]=n;return s in o?o[s]===t:(console.warn(`fscss[logic] Warning: Condition variable '${s}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,s,t]=n;if(!(e in o))return console.warn(`fscss[logic] Warning: Condition variable '${e}' not provided in @event '${r}' context. Treating as false.`),!1;const c=o[e],i=isNaN(c)?c:Number(c),l=isNaN(t)?t:Number(t);switch(s){case"==":return i==l;case"!=":return i!=l;case">":return i>l;case"<":return i<l;case">=":return i>=l;case"<=":return i<=l;default:return!1}}}))}if(l){const n=e.block.match(/(\w+)\s*(?:\:\s*([^;]*);?|\|([^\|]+)\|?)/);n&&n[2]?i=n[2].trim():n&&n[3]?i=n[3].trim():console.warn(`fscss[logic] Warning: No valid CSS property assignment found in matched block for @event '${r}'. Block content: '${e.block}'.`);break}}return!i&&t.conditionBlocks.length>0&&!l?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==t.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),t.trim()}async function u(e){return e=(e=(e=(e=(e=e.replace(/exec\(\s*_init\sisjs\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/isjs.fscss)")).replace(/exec\(\s*_init\sthemes\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/trshapes.fthemes.fscss)")).replace(/exec\(_init\sarray1to500\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/1to500.fscss)")).replace(/exec\(_init\s+([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?\s*\)/g,((e,n,r)=>r?`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.${r})`:`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.fscss)`))).replace(/(\@import\((?:\s+)?(?:exec)?\((?:[\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?)([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?(?:\s+)?\)/g,((e,n,r,s)=>s?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${s}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function d(e){let n=e.replace(/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g,((e,n,r,s,t,o,i)=>{const l=r.split(",").map((e=>e.trim())).filter((e=>e)),a=s??t??o??i??"";return c[n]={params:l,body:a},""}));return n=n.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=c[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let o=s.body,i=[];return s.params.forEach(((e,n)=>{const r=s.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const c=i[1]?i[1]:"",l=void 0!==t[n]?t[n]:c,a=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");o=o.replace(a,l)})),o})),n}function p(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],s=e.slice(1,-1);const t=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=t.exec(s));)c.push({fullMatch:o[0],start:parseInt(o[1]),length:parseInt(o[2]),varName:o[3].trim(),index:o.index});for(let e=c.length-1;e>=0;e--){let r=c[e],t=r.start<0?s.length+r.start:r.start;t=Math.max(0,t);let o=s.substring(t,t+r.length);(t+r.length>s.length||t<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${r.varName}' in string literal specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[r.varName]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${r.varName}' found in string literal. The last extracted value will be used.`),n[r.varName]=o,s=s.slice(0,r.index)+s.slice(r.index+r.fullMatch.length)}return r+s+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,s,t,o){s=parseInt(s),t=parseInt(t),o=o.trim();let c=s<0?r.length+s:s;c=Math.max(0,c);let i=r.substring(c,c+t);return(c+t>r.length||c<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${o}' on token '${r}' specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[o]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${o}' found outside string literals. The last extracted value will be used.`),n[o]=i,r})),r=r.replace(/@ext\.(\w+)\!?/g,(function(e,r){return void 0===n[r]?(console.warn(`fscss:[@ext]Warning: Reference to undefined variable '@ext.${r}'. It will not be replaced.`),e):n[r]})),r}function $(e){const n=/@arr\(?\s*([\w\-_—0-9]+)\)?\[([^\]]+)\]\)?/g;let r;for(;null!==(r=n.exec(e));){const e=r[1],n=r[2].split(",").map((e=>e.trim()));s[e]=n}let t=e;return t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>s[n]?r?(newItems=r.split(",").map((e=>e.trim())),s[n].push(...newItems),""):(console.warn(`[FSCSS Warning] @arr push failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e))),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const t=s[n];return t?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>t.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,t.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\.(length|last|reverse|first|list|indices|randint|segment|sum|unique|sort|shuffle|min|max))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return t.length;if("first"===r)return t[0];if("last"===r)return t.at(-1);if("indices"===r)return Array(t.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return t.join(",");if("reverse"===r)return t.toReversed().join(",");if("randint"===r)return t[Math.floor(Math.random()*t.length)];if("segment"===r)return t.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(t)].join(",");if("sort"===r)return t.slice().sort().join(",");if("shuffle"===r)return t.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return t.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...t.map(Number));if("max"===r)return Math.max(...t.map(Number))}})),t=t.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,t)=>{const o=s[t];return o?o.map(((e,s)=>{const o=n.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),s+1),c=r.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${t}' not found for loop processing.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const t=parseInt(r)-1,o=s[n];return o?void 0!==o[t]?o[t]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${e+o}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${o+e}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const t=s[n];return t?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),t.map((e=>`${surArr[0]+e+surArr.at(-1)}`)).join(" ")):(console.warn(`[FSCSS Warning] @arr surround failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.join(o)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const t=s[n];return t?r?e:`[${t.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function g(e){const n={};function r(e){const n={},r=e.split(";");for(let e of r){if(e=e.trim(),!e)continue;const r=e.indexOf(":");if(-1===r){console.warn(`fscss[@fun] Invalid style line (missing colon): "${e}"`);continue}const s=e.substring(0,r).trim(),t=e.substring(r+1).trim();s?n[s]=t:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}const s=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;let t;for(;null!==(t=s.exec(e));){const e=t[1],s=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:s,props:r(s)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@fun] Full variable block replacement failed for "@fun.${r}". Variable not found.`),e))),o=o.replace(/@fun\(([\w\-\_\d\—]+)\s*\{[\s\S]*?\}\s*/g,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function m(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const l=parseInt(c),a=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=l>=0?t.substring(0,l):t.substring(t.length+l),n.add(`--${a}:${f};`),`${r}${s}${t}${o}`}));if(n.size>0){return r+`\n${`:root{${Array.from(n).join("\n")}\n}`}`}return r}function b(e){const n=new Map;let r,s=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,s,t)=>{const o=s||t;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return s;let t=0;let o=s;do{r=!1;for(const[e,s]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),t=o.replace(n,s);t!==o&&(r=!0,o=t)}t++}while(r&&t<100);var c;return t>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function x(e){return e=e.replace(/(?:mxs|\$p)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2:$14$15;$4:$14$15;$6:$14$15;$8:$14$15;$10:$14$15;$12:$14$15;").replace(/(?:mx|\$m)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2$14$15$4$14$15$6$14$15$8$14$15$10$14$15$12$14$15").replace(/rpt\((\d+)\,\s*("([^"]*)"|'([^']*)')\)/gi,((e,n,r)=>function(e,n){return e.replace(/^['"]|['"]$/g,"").repeat(Math.max(0,parseInt(n)))}(r,n))).replace(/\$(([\_\-\d\w]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,":root{--$1}").replace(/\$([^\!\s]+)!/gi,"var(--$1)").replace(/\$([\w\-\_\d]+)/gi,"var(--$1)").replace(/\-\*\-(([^\:]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,"-webkit-$1-moz-$1-ms-$1-o-$1").replace(/%i\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$21$4$21$6$21$8$21$10$21$12$21$14$21$16$21$18$21$20$21").replace(/%6\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$13$4$13$6$13$8$13$10$13$12$13").replace(/%5\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$11$4$11$6$11$8$11$10$11").replace(/%4\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$9$4$9$6$9$8$9").replace(/%3\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$7$4$7$6$7").replace(/%2\((([^\,\[\]]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$5$4$5").replace(/%1\((([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$3"),e=(e=e.replace(/%(\d+)\(([^[]+)\[\s*([^\]]+)\]\)/g,((e,n,r,s)=>{const t=r.split(",").map((e=>e.trim()));return t.length!=n?(console.warn(`Number of properties ${t.length} does not match %${n}`),e):t.map((e=>`${e}${s}`)).join("")}))).replace(/\$\(\s*@keyframes\s*(\S+)\)/gi,"$1{animation-name:$1;}@keyframes $1").replace(/\$\(\s*(\@[\w\-\*]*)\s*([^\{\}\,&]*)(\s*,\s*[^\{\}&]*)?&?(\[([^\{\}]*)\])?\s*\)/gi,"$2$3{animation:$2 $5;}$1 $2").replace(/\$\(\s*--([^\{\}]*)\)/gi,"$1").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/g\(([^"'\s]*)\,\s*(("([^"]*)"|'([^']*)')\,\s*)?("([^"]*)"|'([^']*)')\s*\)/gi,"$1 $4$5$1 $7$8").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/\$\(([^\:^\)]*)\)/gi,"[$1]")}async function w(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=[...e.matchAll(/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g)];let s=e;for(const e of r){const[r,t,o]=e;try{const e=t.replace(/["']/g,""),c=e.slice(e.lastIndexOf(".")).toLowerCase();if(e.trim().startsWith("_init")&&e.includes(" "))return void console.warn(`fscss[@import] library not found for: ${e}`);if(!n.includes(c))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const i=await fetch(e);if(!i.ok)throw new Error(`fscss[@import] HTTP ${i.status} for ${t}`);const l=h(await i.text(),o.trim());s=s.replace(r,l)}catch(e){console.error(`fscss[@import] Failed: ${t} `,e),s=s.replace(r,`/* Failed import: ${t} */`)}}return s}function h(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),s=e.match(r);return s?s.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const v=[".fscss",".css",".txt",".scss",".less",".xfscss"];async function k(e,n=0,r=window.location.href){if(n>o)return console.warn("fscss[@import]\n Maximum import depth exceeded. Skipping further imports."),e;const s=Array.from(e.matchAll(/@import\s*\(\s*exec\s*\(\s*((?:'[^']*'|"[^"]*"|[^'")]\S*)\s*)\)\s*\)/g));if(0===s.length)return e;const t=await Promise.all(s.map((async e=>{const[s,t]=e;try{const e=t.replace(/^['"](.*)['"]$/,"$1").trim(),s=new URL(e,r).href,o=new URL(s).pathname,c=o.slice(o.lastIndexOf(".")).toLowerCase();if(s.trim().startsWith("_init")&&s.includes(" "))return void console.warn(`fscss[@import] library not found for: ${s}`);if(!v.includes(c))return console.warn(`fscss[@import] \n Invalid import URL extension "${c}" for "${s}". Only ${v.join(", ")} are allowed.`),`/* Invalid extension for "${s}" */`;const i=await fetch(s);if(!i.ok)throw new Error(`HTTP ${i.status} for ${s}`);return k(await i.text(),n+1,s)}catch(e){return console.warn(`fscss[@import]\n Failed to import "${t}" from "${r}":`,e),`/* Error importing "${t}": ${e.message} */`}})));let c=0,i="";return s.forEach(((n,r)=>{i+=e.slice(c,n.index),i+=t[r],c=n.index+n[0].length})),i+=e.slice(c),i}async function j(e){try{return await k(e)}catch(n){return console.warn("fscss[]\n Processing failed:",n),console.warn("fscss[@import] Warning: can't resolve imports"),e}}async function y(e){const n=[...e.matchAll(/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g)];let r=e;for(const e of n){let[n,s,t,o,c]=e;s=s.trim();const i=(t||o||c).trim();try{const e=await fetch(i);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${i}`);const t=await e.text();if("*"===s&&(r=r.replace(n,t)),"*"!==s&&s.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${n}: unexpected *`),r=r.replace(n,"/* syntax error: unexpected * */")),"*"!==s&&!s.includes("*")){const e=s.split(",").map((e=>e.trim())),o=await S(t,e);r=r.replace(n,o)}}catch(e){console.error(`fscss[@import] Failed: ${i} `,e),r=r.replace(n,`/* Failed import: ${i} */`)}}return r}async function S(e,n=[]){if(!e||""===e||"string"!=typeof e)return console.warn("FSCSS >Invalid input");if(!n||0===n.length)return console.warn("FSCSS >Invalid input");let r="";return n.forEach((n=>{let s="",t=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;t=r,c?s=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),s=r):s=r}const c=new RegExp("@define\\s+("+t+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${t} is undefined for import`);const l=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(l,((e,n,r,t)=>`${n}${s}${t}`))+"\n"})),r.trim()}try{await async function(){const s=document.querySelectorAll("style");if(s.length)for(const o of s){let s=o.textContent;s.includes("exec.obj.block(all)")||(s.includes("exec.obj.block(init lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(vfc)")||(s=s.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,s,t)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&t&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${t})`),s&&!t?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(t?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(t.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${t}`),t?`${n}${t.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),s.includes("exec.obj.block(store:before)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(f var)")||(s=function(e){const n={},r=[],s=e.split("\n");let t=!1;const o={};for(let e=0;e<s.length;e++){let c=s[e].trim();if(c.includes("{")){t=!0,r.push(c);continue}if(c.includes("}")){t=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,l=c.match(i);if(l){const[,e,s]=l;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const a=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(a,((e,r)=>void 0!==o[r]?o[r]:void 0!==n[r]?n[r]:e)),r.push(c)}return{css:r.join("\n"),getVariable:function(e){return n[e]||null}}}(s).css),s.includes("exec.obj.block(fun)")||(s=g(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(arr)")||(s=$(s)),s.includes("exec.obj.block(event)")||(s=f(s)),s.includes("exec.obj.block(random)")||(s=s.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),s=n.split(",").map((e=>e.trim()));if(0===s.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=s.join(":");t[e]||(t[e]={values:s,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=t[e],o=r.values[r.index%r.values.length];return r.index>=r.values.length&&r.index%r.values.length==0&&console.warn(`fscss[@random] Warning: Ordered sequence [${n}] is looping back to the beginning.`),r.index++,o}return s[Math.floor(Math.random()*s.length)]}))),s.includes("exec.obj.block(copy)")||(s=m(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(t group)")||(s=x(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(debug)")||(s=a(s))),s=s.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=s}else console.warn("fscss[Obj]\n No <style> elements found.")}(),await void document.querySelectorAll(".draw").forEach((e=>{const n=e.style.color||"#000";e.style.color="transparent",e.style.webkitTextStroke=`2px ${n}`}))}catch(e){console.error("Error processing styles or draw elements:",e)}})()}function applyFscssStyles(){document.querySelectorAll('[type*="fscss"]').forEach((e=>{fetch(e.href).then((e=>e.text())).then((e=>{const n=document.createElement("style");n.textContent=e,document.head.appendChild(n),xfscssProcessorWrap()})).catch((n=>{console.error(`Failed to load FSCSS from ${e.href}`,n)}))}))}function inf({host:e,path:n}){if(!e||!n)return void console.error("Both 'host' and 'path' are required.");const r=e.replace(/github/gi,"gh"),s=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${s}`)}xfscssProcessorWrap(),applyFscssStyles();
3
+
10
4
 
@@ -38,10 +38,12 @@ const processedCSS = css.replace(regex, (match, expression) => {
38
38
 
39
39
  return (processedCSS);
40
40
  }
41
- const arraysExfscss = {}; // Renamed the global variable
41
+ const arraysExfscss = {}; //the global variable
42
42
  const orderedxFscssRandom = {};
43
43
 
44
44
  const exfMAX_DEPTH = 10; // Prevent infinite recursion
45
+ const defExfscss = {};
46
+
45
47
  function extractBlock(css, startIndex) {
46
48
  let depth = 0;
47
49
  let i = startIndex;
@@ -260,20 +262,71 @@ function procExC(css) {
260
262
 
261
263
  return modifiedCSS.trim();
262
264
  }
263
-
264
- function initlibraries(css){
265
+ async function initlibraries(css){
265
266
  css = css.replace(/exec\(\s*_init\sisjs\s*\)/g, "exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/isjs.fscss)");
266
267
  css = css.replace(/exec\(\s*_init\sthemes\s*\)/g, "exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/trshapes.fthemes.fscss)")
267
268
  css = css.replace(/exec\(_init\sarray1to500\s*\)/g, "exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/1to500.fscss)");
268
269
  css = css.replace(/exec\(_init\s+([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?\s*\)/g, (match, impName, impType)=>{
269
270
  if(!impType){
270
- //`
271
271
  return `exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${impName}.fscss)`;
272
272
  }
273
273
  return `exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${impName}.${impType})`;
274
274
  });
275
+ css = css.replace(/(\@import\((?:\s+)?(?:exec)?\((?:[\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?)([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?(?:\s+)?\)/g, (match, state, impName, impType) => {
276
+ if (!impType) {
277
+ return `${state}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${impName}.fscss')`;
278
+ }
279
+ return `${state}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${impName}.${impType}')`;
280
+ });
275
281
  return css;
276
282
  }
283
+
284
+ function procDef(fscss) {
285
+ // First, extract all @define blocks and store them in defExfscss. FIGSH-FSCSS
286
+ let processed = fscss.replace(
287
+ /@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g,
288
+ (match, name, paramsStr, body1, body2, body3, body4) => {
289
+ const params = paramsStr.split(',').map(p =>p.trim()).filter(p =>p);
290
+ const body = body1 ?? body2 ?? body3 ?? body4 ?? '';
291
+ defExfscss[name] = { params, body };
292
+ return ''; // Remove the define block from the output. FIGSH-FSCSS
293
+ }
294
+ );
295
+
296
+ // Now replace all @name(...) usages with their expanded bodies. FIGSH-FSCSS
297
+ processed = processed.replace(
298
+ /@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,
299
+ (match, name, argsStr) => {
300
+ const def = defExfscss[name];
301
+ if (!def){
302
+ return match;
303
+ }// Leave unknown Def macros unchanged. FIGSH-FSCSS
304
+
305
+ const args = argsStr?.split(',').map(a => a.trim());
306
+ if(args[0]==='') args[0] = undefined;
307
+ let result = def.body;
308
+
309
+ /* Replace each @use(param) with the corresponding argument. FIGSH-FSCSS */
310
+ let xfVal = [];
311
+ def.params.forEach((param, index) => {
312
+ const df = def.params[index];
313
+ if(df&&df.includes(':')){
314
+ xfVal = df?.split(':')?.map(i=>i.trim()).filter(i=>i);
315
+ }
316
+
317
+ const dfv = xfVal[1]?xfVal[1]:'';
318
+
319
+ const arg = args[index] !== (undefined) ? args[index] : dfv;
320
+ const regex = new RegExp(`@use\\(\\s*${param.replace(/(\s+)?(\:(\s+)?.*)/g, '')}\\s*\\)`, 'g');
321
+ result = result.replace(regex, arg);
322
+ });
323
+
324
+ return result;
325
+ }
326
+ );
327
+
328
+ return processed;
329
+ }
277
330
  function procVar(vcss) {
278
331
  function processSCSS(scssCode) {
279
332
  const globalVars = {};
@@ -656,7 +709,7 @@ if (obj === "max") {
656
709
  if(fos){
657
710
  return match;
658
711
  }
659
- return arr.join(' ');
712
+ return `[${arr.join(',')}]`;
660
713
  })
661
714
  // Clean up array declarations
662
715
  return output
@@ -1266,6 +1319,6 @@ function execObj(css){
1266
1319
  }
1267
1320
 
1268
1321
  export { initlibraries,
1269
- impSel, procImp, replaceRe, procExt, procVar,procFun, procArr, procEv, procRan, transformCssValues, procNum, vfc, applyFscssTransformations,procExC, procCnt, procChe, execObj
1322
+ impSel, procImp, replaceRe, procExt, procVar,procFun, procArr, procEv, procRan, transformCssValues, procNum, vfc, applyFscssTransformations,procExC, procCnt, procDef, procChe, execObj
1270
1323
  }
1271
1324
 
@@ -0,0 +1,101 @@
1
+ // lip/functions/impFrom.js
2
+
3
+ import fs from "fs/promises";
4
+ import path from "path";
5
+
6
+
7
+ export async function impFrom(text, {inputDir=process.cwd()} = {}) {
8
+
9
+ const regex = /\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g;
10
+
11
+ const matches = [...text.matchAll(regex)]
12
+
13
+ let result = text;
14
+
15
+ for (const match of matches) {
16
+ let [fullMatch, blocks, url1, url2, url3] = match;
17
+
18
+ blocks = blocks.trim();
19
+
20
+ const impUrl = (url1 || url2 || url3).trim();
21
+
22
+ try {
23
+ let resRegex;
24
+ let resText;
25
+ if(/^https?:\/\//.test(impUrl)){
26
+ // remote
27
+ const response = await fetch(impUrl);
28
+
29
+ if (!response.ok) throw new Error(`fscss[@import] HTTP ${response.status} for ${impUrl}`);
30
+
31
+ resText = await response.text();
32
+ }
33
+ else{
34
+ // local
35
+ const fillPath = path.resolve(inputDir, impUrl);
36
+ resText = await fs.readFile(fillPath, 'utf8');
37
+ }
38
+ if (blocks === '*') {
39
+ result = result.replace(fullMatch, resText);
40
+ }
41
+ if (blocks !== '*' && blocks.includes('*')) {
42
+ console.warn(`[FSCSS Warning] syntax error at ${fullMatch}: unexpected *`);
43
+ result = result.replace(fullMatch, `/* syntax error: unexpected * */`);
44
+ }
45
+ if (blocks !== '*' && !blocks.includes('*')) {
46
+ const arblock = blocks.split(",").map(a => a.trim());
47
+ const exblocks = await findBlock(resText, arblock);
48
+ result = result.replace(fullMatch, exblocks);
49
+ }
50
+
51
+ } catch (error) {
52
+ console.error(`fscss[@import] Failed: ${impUrl} `, error);
53
+
54
+ result = result.replace(fullMatch, `/* Failed import: ${impUrl} */`);
55
+
56
+ }
57
+ }
58
+ return result;
59
+ }
60
+
61
+ async function findBlock(text, blocks = []) {
62
+ if (!text || text === "" || typeof text !== "string") return console.warn("FSCSS >Invalid input");
63
+ if (!blocks || blocks.length === 0) return console.warn("FSCSS >Invalid input");
64
+ let resBlock = '';
65
+
66
+ blocks.forEach(key => {
67
+ let blk = '';
68
+ let keyname = key;
69
+
70
+ //Captures the source, the 'as' keyword, and
71
+ const aliasRegex = /([^\s]+)(?:\s+as\s+([^\s]+))?/;
72
+ const matchAs = key.trim().match(aliasRegex);
73
+
74
+ if (matchAs) {
75
+ const [_, name, alias] = matchAs;
76
+ keyname = name;
77
+ if (alias) {
78
+ blk = alias;
79
+ } else if (key.includes(' as')) {
80
+ // Handles the "func as " (missing alias) case
81
+ console.warn(`[FSCSS Warning] Can't assign @${name} to invalid or empty value`);
82
+ blk = name;
83
+ } else {
84
+ blk = name;
85
+ }
86
+ }
87
+
88
+ const regex = new RegExp('@define\\s+(' + keyname + ')\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:"([^"]*)"|\'([^\']*)\'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}', "g");
89
+
90
+ const match = text.match(regex);
91
+ if (!match) {
92
+ return console.warn(`[FSCSS Warning] @${keyname} is undefined for import`);
93
+ }
94
+ const resRegex = new RegExp('(@define\\s+)(' + keyname + ')(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:"([^"]*)"|\'([^\']*)\'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})', 'g');
95
+
96
+ resBlock += (match.join('\n')).replace(resRegex, (m, g1, g2, g3) => {
97
+ return `${g1}${blk}${g3}`;
98
+ }) + '\n';
99
+ })
100
+ return resBlock.trim();
101
+ }
package/lib/processor.js CHANGED
@@ -13,22 +13,46 @@ import {
13
13
  vfc,
14
14
  applyFscssTransformations,
15
15
  procExC,
16
- procCnt,
16
+ procCnt,
17
+ procDef,
17
18
  procChe,
18
19
  execObj
19
20
  } from "./functions/all.js";
20
21
  import { procImp } from "./functions/procImp.js";
21
22
  import { impSel } from "./functions/impSel.js";
23
+ import { impFrom } from "./functions/impFrom.js";
22
24
  export async function processFscss(css, options = {}) {
23
25
  const { inputDir = process.cwd() } = options;
24
26
 
25
27
  if (!css.includes("exec.obj.block(all)")) {
26
- if(!css.includes("exec.obj.block(init lab)"))css = initlibraries(css);
28
+ if(!css.includes("exec.obj.block(init lab)"))css = await initlibraries(css);
27
29
  if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import pick)")){css = await impSel(css, {inputDir});}
30
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import from)")){css = await impFrom(css, {inputDir});}
28
31
  if(!css.includes("exec.obj.block(f import)")){css = await procImp(css, {inputDir});}
29
- if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css = initlibraries(css);
32
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
33
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import from)")){css = await impFrom(css, {inputDir});}
34
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
35
+ if(!css.includes("exec.obj.block(f import)")){css = await procImp(css, {inputDir});}
36
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
37
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import pick)")){css = await impSel(css, {inputDir});}
38
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
39
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import from)")){css = await impFrom(css, {inputDir});}
40
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
41
+ if(!css.includes("exec.obj.block(f import)")){css = await procImp(css, {inputDir});}
42
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
43
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import pick)")){css = await impSel(css, {inputDir});}
44
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
45
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import from)")){css = await impFrom(css, {inputDir});}
46
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
47
+ if(!css.includes("exec.obj.block(f import)")){css = await procImp(css, {inputDir});}
48
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
49
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import pick)")){css = await impSel(css, {inputDir});}
50
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
51
+ if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import from)")){css = await impFrom(css, {inputDir});}
52
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
53
+ if(!css.includes("exec.obj.block(f import)")){css = await procImp(css, {inputDir});}
54
+ if(!css.includes("exec.obj.block(init lab)")||css.includes("exec.obj.block(exInit lab)"))css =await initlibraries(css);
30
55
  if(!css.includes("exec.obj.block(f import)")||!css.includes("exec.obj.block(f import pick)")){css = await impSel(css, {inputDir});}
31
- if(!css.includes("exec.obj.block(f import)")){css = await procImp(css, {inputDir});}
32
56
  if(!css.includes("exec.obj.block(vfc)")) css = vfc(css);
33
57
  if(!css.includes("exec.obj.block(store:before)")||!css.includes("exec.obj.block(store)"))css = replaceRe(css);
34
58
  if(!css.includes("exec.obj.block(ext:before)")||!css.includes("exec.obj.block(ext)"))css = procExt(css);
@@ -36,6 +60,10 @@ export async function processFscss(css, options = {}) {
36
60
  if(!css.includes("exec.obj.block(fun)"))css = procFun(css);
37
61
  if(!css.includes("exec.obj.block(length)"))css = procChe(css);
38
62
  if(!css.includes("exec.obj.block(count)"))css = procCnt(css);
63
+ if(!css.includes("exec.obj.block(define)"))css = procDef(css);
64
+ if(!css.includes("exec.obj.block(define)"))css = procDef(css);
65
+ if(!css.includes("exec.obj.block(define)"))css = procDef(css);
66
+ if(!css.includes("exec.obj.block(define)"))css = procDef(css);
39
67
  if(!css.includes("exec.obj.block(arr)"))css = procArr(css);
40
68
  if(!css.includes("exec.obj.block(event)"))css = procEv(css);
41
69
  if(!css.includes("exec.obj.block(random)"))css = procRan(css);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fscss",
3
3
  "description": "Figured Shorthand Cascading Style Sheet",
4
- "version": "1.1.14",
4
+ "version": "1.1.16",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "bin": {
@@ -18,10 +18,11 @@
18
18
  "keywords": [
19
19
  "node",
20
20
  "figsh_css",
21
- "fs-css",
21
+ "css",
22
22
  "fscss",
23
23
  "xfscss",
24
- "preprocessor"
24
+ "preprocessor",
25
+ "lightweight"
25
26
  ],
26
27
  "author": "Figsh",
27
28
  "license": "MIT",
package/style.fscss CHANGED
@@ -1,4 +1,6 @@
1
+ @import((*) from themes)
2
+
1
3
  body{
2
4
  Background: @event.theme(light);
3
- color: blue;
5
+ color: @event.theme(dark);
4
6
  }
package/xfscss.js CHANGED
@@ -1,5 +1 @@
1
- export var text='text';export var url='fromUrl';export var external='fromUrl';export var fromUrl='fromUrl';export var write='text';function inf(host,jsdl){if(typeof jsdl!=='undefined'&&host!=='undefined'){var ht=host.replace(/github/gi, 'gh');var cov=jsdl.replace(/\s*-\>\s*/g, '/').replace(/\n/g, '');var url=`https://cdn.jsdelivr.net/${ht}/${cov}`;var ScrT=document.createElement('script');ScrT.type='text/javascript';ScrT.async='true';ScrT.src=url;document.body.appendChild(ScrT);}}function exec(text,fscss_style_sheet){if(typeof fscss_style_sheet !== 'undefined' && text == 'text'){var doc=document;var SrT = doc.createElement('script');
2
- SrT.type='text/javascript';SrT.async='true';SrT.src='https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';doc.body.appendChild(SrT);doc.body.innerHTML += (`<style>${fscss_style_sheet}</style>`);}else if(typeof fscss_style_sheet!=='undefined'&&text=='fromUrl'){var doc=document;var SrT=doc.createElement('script');SrT.type = 'text/javascript';SrT.async='true';SrT.src= 'https://cdn.jsdelivr.net/gh/Figsh/FSCSS@main/rtF4.js';doc.body.appendChild(SrT);fetch(fscss_style_sheet).then(response =>response.text()).then(data=>{const AJWinDocStyleElement = document.createElement("style");
3
- AJWinDocStyleElement.innerHTML = `${data}`;
4
- document.head.appendChild(AJWinDocStyleElement);}).catch(error=>{});}}export{ inf };export{ exec };
5
-
1
+ export function exec({type:e="text",content:n,onError:r,onSuccess:s}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const t=document.createElement("style"),o=e=>{t.textContent=e,document.head.appendChild(t),s&&s(t),xfscssProcessorWrap()},c=["text","auto","text/fscss","text/css"].includes(e),i=["fromUrl","URL","fromURL","link"].includes(e);if(c)o(n);else if(i)fetch(n).then((e=>{if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.text()})).then(o).catch((e=>{const s=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${s}`),r&&r(s)}));else{const n=`Unsupported type "${e}". Use "text" or "fromUrl".`;console.error(`[FSCSS] ${n}`),r&&r(n)}}function xfscssProcessorWrap(){(async()=>{function e(e){return e=e.replace(/count\(\s*([\d\.]+)\s*(?:,\s*([\d\.]+)?)?\)/g,((e,n,r)=>{return null===r&&(r=1),s=parseInt(n),t=parseInt(r||1),`${Array(s).fill().map(((e,n)=>(n+1)*t))}`;var s,t}))}function n(e){return e=e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,s)=>(n||r||s).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>function(e){try{return new Function(`return ${e}`)()}catch(n){return console.error("Invalid expression:",e),e}}(n)))}const s={},t={},o=10,c={};function i(e,n){let r=0,s=n;for(;s<e.length&&("{"===e[s]?r++:"}"===e[s]&&r--,0!==r);)s++;return e.slice(n,s+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let s;for(;null!==(s=r.exec(e));)n.push({type:s[1],condition:s[2].trim(),block:s[3].trim()});return n}function a(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,s,t,o)=>{const c=s||t||o;return["_log","_error","_warn","_info"].includes(r)?c?(n+=`console.${r.slice(1)}("${c.replace(/"/g,'\\"')}");\n`,""):(console.warn(`fscss[exec(console)]: Empty argument for method: ${r}`),""):(console.warn(`fscss[exec(console)]: Unsupported method: ${r}`),"")}));if(n)try{new Function(n)()}catch(e){console.error("fscss[exec(console)]: Error executing transformed code:",e)}return r}function f(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let s,t=e;const o=[];for(;null!==(s=r.exec(e));){const r=s[1],t=s[2],c=s.index+s[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const a=i(e,c);if(0===a.length||"}"!==a[a.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+a.length);const f=l(a),u=t.split(",").map((e=>e.trim())).filter((e=>""!==e));n[r]&&console.warn(`fscss[definition] Warning: Duplicate @event definition for '${r}'. The last one will be used.`),n[r]={args:u,conditionBlocks:f},o.push([s.index,c+a.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];t=t.slice(0,n)+t.slice(r)}return t=t.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,s)=>{const t=n[r];if(!t)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=s.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==t.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${t.args.length}, got ${c.length}.`),t.args.forEach(((e,n)=>{void 0!==c[n]?o[e]=c[n]:console.warn(`fscss[call] Warning: Missing value for argument '${e}' in @event '${r}' call.`)}));let i="",l=!1,a=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(a&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),a=!0),!l||"el"===e.type){if("el"===e.type){if(l)continue;l=!0}else{const n=e.condition.split(",").map((e=>e.trim())).filter((e=>""!==e));0===n.length?(console.warn(`fscss[logic] Warning: Empty condition in '${e.type}' block for @event '${r}'.`),l=!0):l=n.every((e=>{const n=e.match(/^(\w+)\s*(==|!=|>=|<=|>|<)\s*([^]+)$/);if(!n){const n=e.split(":").map((e=>e.trim()));if(2!==n.length)return console.warn(`fscss[logic] Warning: Malformed condition '${e}' in @event '${r}'. Expected 'variable operator value' or 'variable:value'.`),!1;const[s,t]=n;return s in o?o[s]===t:(console.warn(`fscss[logic] Warning: Condition variable '${s}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,s,t]=n;if(!(e in o))return console.warn(`fscss[logic] Warning: Condition variable '${e}' not provided in @event '${r}' context. Treating as false.`),!1;const c=o[e],i=isNaN(c)?c:Number(c),l=isNaN(t)?t:Number(t);switch(s){case"==":return i==l;case"!=":return i!=l;case">":return i>l;case"<":return i<l;case">=":return i>=l;case"<=":return i<=l;default:return!1}}}))}if(l){const n=e.block.match(/(\w+)\s*(?:\:\s*([^;]*);?|\|([^\|]+)\|?)/);n&&n[2]?i=n[2].trim():n&&n[3]?i=n[3].trim():console.warn(`fscss[logic] Warning: No valid CSS property assignment found in matched block for @event '${r}'. Block content: '${e.block}'.`);break}}return!i&&t.conditionBlocks.length>0&&!l?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==t.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),t.trim()}async function u(e){return e=(e=(e=(e=(e=e.replace(/exec\(\s*_init\sisjs\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/isjs.fscss)")).replace(/exec\(\s*_init\sthemes\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/trshapes.fthemes.fscss)")).replace(/exec\(_init\sarray1to500\s*\)/g,"exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/1to500.fscss)")).replace(/exec\(_init\s+([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?\s*\)/g,((e,n,r)=>r?`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.${r})`:`exec(https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${n}.fscss)`))).replace(/(\@import\((?:\s+)?(?:exec)?\((?:[\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?)([\w\d\._—\-\%\*\+\&\$\=]+)(?:\/([\w\-]+))?(?:\s+)?\)/g,((e,n,r,s)=>s?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${s}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function d(e){let n=e.replace(/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g,((e,n,r,s,t,o,i)=>{const l=r.split(",").map((e=>e.trim())).filter((e=>e)),a=s??t??o??i??"";return c[n]={params:l,body:a},""}));return n=n.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=c[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let o=s.body,i=[];return s.params.forEach(((e,n)=>{const r=s.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const c=i[1]?i[1]:"",l=void 0!==t[n]?t[n]:c,a=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");o=o.replace(a,l)})),o})),n}function p(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],s=e.slice(1,-1);const t=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=t.exec(s));)c.push({fullMatch:o[0],start:parseInt(o[1]),length:parseInt(o[2]),varName:o[3].trim(),index:o.index});for(let e=c.length-1;e>=0;e--){let r=c[e],t=r.start<0?s.length+r.start:r.start;t=Math.max(0,t);let o=s.substring(t,t+r.length);(t+r.length>s.length||t<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${r.varName}' in string literal specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[r.varName]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${r.varName}' found in string literal. The last extracted value will be used.`),n[r.varName]=o,s=s.slice(0,r.index)+s.slice(r.index+r.fullMatch.length)}return r+s+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,s,t,o){s=parseInt(s),t=parseInt(t),o=o.trim();let c=s<0?r.length+s:s;c=Math.max(0,c);let i=r.substring(c,c+t);return(c+t>r.length||c<0)&&console.warn(`fscss:[@ext]Warning: @ext directive for variable '${o}' on token '${r}' specifies an out-of-bounds range. Extraction may be incomplete or incorrect.`),void 0!==n[o]&&console.warn(`fscss:[@ext]Warning: Duplicate variable name '${o}' found outside string literals. The last extracted value will be used.`),n[o]=i,r})),r=r.replace(/@ext\.(\w+)\!?/g,(function(e,r){return void 0===n[r]?(console.warn(`fscss:[@ext]Warning: Reference to undefined variable '@ext.${r}'. It will not be replaced.`),e):n[r]})),r}function $(e){const n=/@arr\(?\s*([\w\-_—0-9]+)\)?\[([^\]]+)\]\)?/g;let r;for(;null!==(r=n.exec(e));){const e=r[1],n=r[2].split(",").map((e=>e.trim()));s[e]=n}let t=e;return t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>s[n]?r?(newItems=r.split(",").map((e=>e.trim())),s[n].push(...newItems),""):(console.warn(`[FSCSS Warning] @arr push failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e))),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const t=s[n];return t?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>t.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,t.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\.(length|last|reverse|first|list|indices|randint|segment|sum|unique|sort|shuffle|min|max))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return t.length;if("first"===r)return t[0];if("last"===r)return t.at(-1);if("indices"===r)return Array(t.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return t.join(",");if("reverse"===r)return t.toReversed().join(",");if("randint"===r)return t[Math.floor(Math.random()*t.length)];if("segment"===r)return t.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(t)].join(",");if("sort"===r)return t.slice().sort().join(",");if("shuffle"===r)return t.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return t.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...t.map(Number));if("max"===r)return Math.max(...t.map(Number))}})),t=t.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,t)=>{const o=s[t];return o?o.map(((e,s)=>{const o=n.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),s+1),c=r.replace(new RegExp(`@arr\\.${t}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${t}' not found for loop processing.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const t=parseInt(r)-1,o=s[n];return o?void 0!==o[t]?o[t]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${e+o}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.map((e=>`${o+e}`)).join(",")})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const t=s[n];return t?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),t.map((e=>`${surArr[0]+e+surArr.at(-1)}`)).join(" ")):(console.warn(`[FSCSS Warning] @arr surround failed → Invalid or empty value at "${e}"`),e):(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const t=s[n];if(!t)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return t.join(o)})),t=t.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const t=s[n];return t?r?e:`[${t.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),t.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function g(e){const n={};function r(e){const n={},r=e.split(";");for(let e of r){if(e=e.trim(),!e)continue;const r=e.indexOf(":");if(-1===r){console.warn(`fscss[@fun] Invalid style line (missing colon): "${e}"`);continue}const s=e.substring(0,r).trim(),t=e.substring(r+1).trim();s?n[s]=t:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}const s=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;let t;for(;null!==(t=s.exec(e));){const e=t[1],s=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:s,props:r(s)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@fun] Full variable block replacement failed for "@fun.${r}". Variable not found.`),e))),o=o.replace(/@fun\(([\w\-\_\d\—]+)\s*\{[\s\S]*?\}\s*/g,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function m(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const l=parseInt(c),a=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=l>=0?t.substring(0,l):t.substring(t.length+l),n.add(`--${a}:${f};`),`${r}${s}${t}${o}`}));if(n.size>0){return r+`\n${`:root{${Array.from(n).join("\n")}\n}`}`}return r}function b(e){const n=new Map;let r,s=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,s,t)=>{const o=s||t;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return s;let t=0;let o=s;do{r=!1;for(const[e,s]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),t=o.replace(n,s);t!==o&&(r=!0,o=t)}t++}while(r&&t<100);var c;return t>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function x(e){return e=e.replace(/(?:mxs|\$p)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2:$14$15;$4:$14$15;$6:$14$15;$8:$14$15;$10:$14$15;$12:$14$15;").replace(/(?:mx|\$m)\((([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,)?(([^\,]*)\,\s*)?("([^"]*)"|'([^']*)')\)/gi,"$2$14$15$4$14$15$6$14$15$8$14$15$10$14$15$12$14$15").replace(/rpt\((\d+)\,\s*("([^"]*)"|'([^']*)')\)/gi,((e,n,r)=>function(e,n){return e.replace(/^['"]|['"]$/g,"").repeat(Math.max(0,parseInt(n)))}(r,n))).replace(/\$(([\_\-\d\w]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,":root{--$1}").replace(/\$([^\!\s]+)!/gi,"var(--$1)").replace(/\$([\w\-\_\d]+)/gi,"var(--$1)").replace(/\-\*\-(([^\:]+)\:(\"[^\"]*\"|\'[^\']*\'|[^\;]*)\;)/gi,"-webkit-$1-moz-$1-ms-$1-o-$1").replace(/%i\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$21$4$21$6$21$8$21$10$21$12$21$14$21$16$21$18$21$20$21").replace(/%6\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$13$4$13$6$13$8$13$10$13$12$13").replace(/%5\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\]\[]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$11$4$11$6$11$8$11$10$11").replace(/%4\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$9$4$9$6$9$8$9").replace(/%3\((([^\,\[\]]*)\,)?(([^\,\[\]]*)\,)?(([^\,\[\]]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$7$4$7$6$7").replace(/%2\((([^\,\[\]]*)\,)?(([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$5$4$5").replace(/%1\((([^\,\]\[]*))?\s*\[([^\]\[]*)\]\)/gi,"$2$3"),e=(e=e.replace(/%(\d+)\(([^[]+)\[\s*([^\]]+)\]\)/g,((e,n,r,s)=>{const t=r.split(",").map((e=>e.trim()));return t.length!=n?(console.warn(`Number of properties ${t.length} does not match %${n}`),e):t.map((e=>`${e}${s}`)).join("")}))).replace(/\$\(\s*@keyframes\s*(\S+)\)/gi,"$1{animation-name:$1;}@keyframes $1").replace(/\$\(\s*(\@[\w\-\*]*)\s*([^\{\}\,&]*)(\s*,\s*[^\{\}&]*)?&?(\[([^\{\}]*)\])?\s*\)/gi,"$2$3{animation:$2 $5;}$1 $2").replace(/\$\(\s*--([^\{\}]*)\)/gi,"$1").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/g\(([^"'\s]*)\,\s*(("([^"]*)"|'([^']*)')\,\s*)?("([^"]*)"|'([^']*)')\s*\)/gi,"$1 $4$5$1 $7$8").replace(/\$\(([^\:]*):\s*([^\)\:]*)\)/gi,"[$1='$2']").replace(/\$\(([^\:^\)]*)\)/gi,"[$1]")}async function w(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=[...e.matchAll(/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g)];let s=e;for(const e of r){const[r,t,o]=e;try{const e=t.replace(/["']/g,""),c=e.slice(e.lastIndexOf(".")).toLowerCase();if(e.trim().startsWith("_init")&&e.includes(" "))return void console.warn(`fscss[@import] library not found for: ${e}`);if(!n.includes(c))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const i=await fetch(e);if(!i.ok)throw new Error(`fscss[@import] HTTP ${i.status} for ${t}`);const l=h(await i.text(),o.trim());s=s.replace(r,l)}catch(e){console.error(`fscss[@import] Failed: ${t} `,e),s=s.replace(r,`/* Failed import: ${t} */`)}}return s}function h(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),s=e.match(r);return s?s.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const v=[".fscss",".css",".txt",".scss",".less",".xfscss"];async function k(e,n=0,r=window.location.href){if(n>o)return console.warn("fscss[@import]\n Maximum import depth exceeded. Skipping further imports."),e;const s=Array.from(e.matchAll(/@import\s*\(\s*exec\s*\(\s*((?:'[^']*'|"[^"]*"|[^'")]\S*)\s*)\)\s*\)/g));if(0===s.length)return e;const t=await Promise.all(s.map((async e=>{const[s,t]=e;try{const e=t.replace(/^['"](.*)['"]$/,"$1").trim(),s=new URL(e,r).href,o=new URL(s).pathname,c=o.slice(o.lastIndexOf(".")).toLowerCase();if(s.trim().startsWith("_init")&&s.includes(" "))return void console.warn(`fscss[@import] library not found for: ${s}`);if(!v.includes(c))return console.warn(`fscss[@import] \n Invalid import URL extension "${c}" for "${s}". Only ${v.join(", ")} are allowed.`),`/* Invalid extension for "${s}" */`;const i=await fetch(s);if(!i.ok)throw new Error(`HTTP ${i.status} for ${s}`);return k(await i.text(),n+1,s)}catch(e){return console.warn(`fscss[@import]\n Failed to import "${t}" from "${r}":`,e),`/* Error importing "${t}": ${e.message} */`}})));let c=0,i="";return s.forEach(((n,r)=>{i+=e.slice(c,n.index),i+=t[r],c=n.index+n[0].length})),i+=e.slice(c),i}async function j(e){try{return await k(e)}catch(n){return console.warn("fscss[]\n Processing failed:",n),console.warn("fscss[@import] Warning: can't resolve imports"),e}}async function y(e){const n=[...e.matchAll(/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g)];let r=e;for(const e of n){let[n,s,t,o,c]=e;s=s.trim();const i=(t||o||c).trim();try{const e=await fetch(i);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${i}`);const t=await e.text();if("*"===s&&(r=r.replace(n,t)),"*"!==s&&s.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${n}: unexpected *`),r=r.replace(n,"/* syntax error: unexpected * */")),"*"!==s&&!s.includes("*")){const e=s.split(",").map((e=>e.trim())),o=await S(t,e);r=r.replace(n,o)}}catch(e){console.error(`fscss[@import] Failed: ${i} `,e),r=r.replace(n,`/* Failed import: ${i} */`)}}return r}async function S(e,n=[]){if(!e||""===e||"string"!=typeof e)return console.warn("FSCSS >Invalid input");if(!n||0===n.length)return console.warn("FSCSS >Invalid input");let r="";return n.forEach((n=>{let s="",t=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;t=r,c?s=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),s=r):s=r}const c=new RegExp("@define\\s+("+t+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${t} is undefined for import`);const l=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(l,((e,n,r,t)=>`${n}${s}${t}`))+"\n"})),r.trim()}try{await async function(){const s=document.querySelectorAll("style");if(s.length)for(const o of s){let s=o.textContent;s.includes("exec.obj.block(all)")||(s.includes("exec.obj.block(init lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await y(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await w(s)),s.includes("exec.obj.block(init lab)")&&!s.includes("exec.obj.block(exInit lab)")||(s=await u(s)),s.includes("exec.obj.block(f import)")||(s=await j(s)),s.includes("exec.obj.block(vfc)")||(s=s.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,s,t)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&t&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${t})`),s&&!t?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(t?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(t.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${t}`),t?`${n}${t.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),s.includes("exec.obj.block(store:before)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(f var)")||(s=function(e){const n={},r=[],s=e.split("\n");let t=!1;const o={};for(let e=0;e<s.length;e++){let c=s[e].trim();if(c.includes("{")){t=!0,r.push(c);continue}if(c.includes("}")){t=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,l=c.match(i);if(l){const[,e,s]=l;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const a=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(a,((e,r)=>void 0!==o[r]?o[r]:void 0!==n[r]?n[r]:e)),r.push(c)}return{css:r.join("\n"),getVariable:function(e){return n[e]||null}}}(s).css),s.includes("exec.obj.block(fun)")||(s=g(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(define)")||(s=d(s)),s.includes("exec.obj.block(arr)")||(s=$(s)),s.includes("exec.obj.block(event)")||(s=f(s)),s.includes("exec.obj.block(random)")||(s=s.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),s=n.split(",").map((e=>e.trim()));if(0===s.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=s.join(":");t[e]||(t[e]={values:s,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=t[e],o=r.values[r.index%r.values.length];return r.index>=r.values.length&&r.index%r.values.length==0&&console.warn(`fscss[@random] Warning: Ordered sequence [${n}] is looping back to the beginning.`),r.index++,o}return s[Math.floor(Math.random()*s.length)]}))),s.includes("exec.obj.block(copy)")||(s=m(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=b(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=p(s)),s.includes("exec.obj.block(t group)")||(s=x(s)),s.includes("exec.obj.block(length)")||(s=n(s)),s.includes("exec.obj.block(count)")||(s=e(s)),s.includes("exec.obj.block(debug)")||(s=a(s))),s=s.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=s}else console.warn("fscss[Obj]\n No <style> elements found.")}(),await void document.querySelectorAll(".draw").forEach((e=>{const n=e.style.color||"#000";e.style.color="transparent",e.style.webkitTextStroke=`2px ${n}`}))}catch(e){console.error("Error processing styles or draw elements:",e)}})()}function applyFscssStyles(){document.querySelectorAll('[type*="fscss"]').forEach((e=>{fetch(e.href).then((e=>e.text())).then((e=>{const n=document.createElement("style");n.textContent=e,document.head.appendChild(n),xfscssProcessorWrap()})).catch((n=>{console.error(`Failed to load FSCSS from ${e.href}`,n)}))}))}export function inf({host:e,path:n}){if(!e||!n)return void console.error("Both 'host' and 'path' are required.");const r=e.replace(/github/gi,"gh"),s=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${s}`)}xfscssProcessorWrap(),applyFscssStyles();