fscss 1.1.20 → 1.1.21
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 +10 -1
- package/bin/fscss.js +0 -0
- package/e/exec.js +2 -2
- package/e/xfscss.js +2 -2
- package/exec.js +2 -2
- package/lib/functions/all.js +69 -128
- package/package.json +6 -6
- package/xfscss.js +1 -1
package/README.md
CHANGED
|
@@ -115,7 +115,16 @@ https://github.com/fscss-ttr/fscss-modules/
|
|
|
115
115
|
- `@event` → conditional styling
|
|
116
116
|
- `exec()` → debugging tools
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
```css
|
|
119
|
+
@event theme(mode){
|
|
120
|
+
if mode:dark{
|
|
121
|
+
return: #1a1a1a;
|
|
122
|
+
}
|
|
123
|
+
el{
|
|
124
|
+
return: #f8f8f8;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
```
|
|
119
128
|
|
|
120
129
|
---
|
|
121
130
|
|
package/bin/fscss.js
CHANGED
|
File without changes
|
package/e/exec.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* Figsh-fscss light, source v3
|
|
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.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.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={},c=new Set,i=new Set;function a(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 f(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 u(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 i=a(e,c);if(0===i.length||"}"!==i[i.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+i.length);const f=l(i),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+i.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="",a=!1,l=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(l&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),l=!0),!a||"el"===e.type){if("el"===e.type){if(a)continue;a=!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}'.`),a=!0):a=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),a=isNaN(t)?t:Number(t);switch(s){case"==":return i==a;case"!=":return i!=a;case">":return i>a;case"<":return i<a;case">=":return i>=a;case"<=":return i<=a;default:return!1}}}))}if(a){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&&!a?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 p(e){return(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 $(e){const n=/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g;let r=e.replace(n,((e,n,r,s,t,c,i)=>{const a=r.split(",").map((e=>e.trim())).filter((e=>e)),l=s??t??c??i??"";return o[n]={params:a,body:l},""}));return r=r.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=o[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let c=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 o=i[1]?i[1]:"",a=void 0!==t[n]?t[n]:o,l=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");c=c.replace(l,a)})),c})),n.test(r)?$(r):r}function d(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 g(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 m(e){const n={},r=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;function s(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}let t;for(;null!==(t=r.exec(e));){const e=t[1],r=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:s(r)}}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(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function w(e){const n={},r=/@obj\s+([\w\-\_\—0-9]+)\s*\{([\s\S]*?)\}\s*/g;function s(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[@obj] 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[@obj] Empty property name in line: "${e}"`)}return n}let t;for(;null!==(t=r.exec(e));){const e=t[1],r=t[2].trim();n[e]&&console.warn(`fscss[@obj] Duplicate @obj variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:s(r)}}let o=e;return o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@obj] Value extraction failed for "@obj.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@obj] Single property rule failed for "@obj.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@obj] Full variable block replacement failed for "@obj.${r}". Variable not found.`),e))),o=o.replace(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function h(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const a=parseInt(c),l=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=a>=0?t.substring(0,a):t.substring(t.length+a),n.add(`--${l}:${f};`),`${r}${s}${t}${o}`}));return n.size>0?r+`\n:root{${Array.from(n).join("\n")}\n}`:r}function x(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,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 b(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.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 v(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g,s=[...(e=await p(e)).matchAll(r)];let t=e,o=null;for(const r of s){const[s,c,a]=r;if(o=c,i.has(o)){const e=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("@import\\(exec\\(("+e+")\\)\\s*\\.\\s*(?:pick|find)\\(([^)]+)\\)\\)","g");t=t.replace(n,`/* Can't import ${o} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${o} multiple times at `)}try{const e=c.replace(/["']/g,""),r=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(r))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const o=await fetch(e);if(!o.ok)throw new Error(`fscss[@import] HTTP ${o.status} for ${c}`);const i=S(await o.text(),a.trim());t=t.replace(s,i)}catch(e){console.error(`fscss[@import] Failed: ${c} `,e),t=t.replace(s,`/* Failed import: ${c} */`)}}return t.match(r)?(i.add(o),v(t)):t}function S(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 y=new Set;async function j(e){const n=/\@import\((?:\s+)?exec\((?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`|([^\)]+)(?:\s+)?)\)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let s=e,t=null;for(const n of r){let[r,o,c,i,a]=n;const l=(o||c||i||a).trim();if(t=l,y.has(t)){const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?exec\\((?:\\s+)?(?:"('+e+")\"|'("+e+")'|`("+e+")`|("+e+")(?:\\s+)?)\\)(?:\\s+)?\\)","g");s=s.replace(n,`/* Can't import ${t} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${t} multiple times at `)}try{const e=await fetch(l);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${l}`);const n=await e.text();s=s.replace(r,n)}catch(e){console.error(`fscss[@import] Failed: ${l} `,e),s=s.replace(r,`/* Failed import: ${l} */`)}}return s.match(n)?(y.add(t),j(s)):s}async function k(e){const n=/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let s=e,t=null;for(const n of r){let[r,o,i,a,l]=n;o=o.trim();const f=(i||a||l).trim();if(t=f,c.has(t)){const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?(?:exec)?\\(([\\w\\d\\.\\@\\—\\-_*\\#\\$\\s\\,]+)\\)(?:\\s+)?from(?:\\s+)?(?:"((?:\\s+)?'+e+"(?:\\s+)?)\"|'((?:\\s+)?"+e+"(?:\\s+)?)'|`((?:\\s+)?"+e+"(?:\\s+)?)`)(?:\\s+)?\\)","g");s=s.replace(n,`/* Can't import ${t} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${t} multiple times at `)}try{const e=await fetch(f);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${f}`);const n=await e.text();if("*"===o&&(s=s.replace(r,n)),"*"!==o&&o.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${r}: unexpected *`),s=s.replace(r,"/* syntax error: unexpected * */")),"*"!==o&&!o.includes("*")){const e=_(n,o.split(",").map((e=>e.trim())));s=s.replace(r,e)}}catch(e){console.error(`fscss[@import] Failed: ${f} `,e),s=s.replace(r,`/* Failed import: ${f} */`)}}return s.match(n)?(c.add(t),k(s)):s}function _(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 a=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(a,((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(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await v(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await k(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=x(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=d(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*([^;]+);/,a=c.match(i);if(a){const[,e,s]=a;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const l=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(l,((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=m(s)),s.includes("exec.obj.block(obj)")||(s=w(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=$(s)),s.includes("exec.obj.block(arr)")||(s=g(s)),s.includes("exec.obj.block(event)")||(s=u(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=h(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=x(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=d(s)),s.includes("exec.obj.block(t group)")||(s=b(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=f(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
|
+
/* Figsh-fscss light, source v3., fscss.devtem.org */
|
|
2
|
+
function exec({type:e="text",content:n,onError:r,onSuccess:t}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const s=document.createElement("style"),o=e=>{s.textContent=e,document.head.appendChild(s),t&&t(s),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 t=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${t}`),r&&r(t)}));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.replace(/count\(\s*([\d\.]+)\s*(?:,\s*([\d\.]+)?)?\)/g,((e,n,r)=>{return null===r&&(r=1),t=parseInt(n),s=parseInt(r||1),`${Array(t).fill().map(((e,n)=>(n+1)*s))}`;var t,s}))}function n(e){return e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,t)=>(n||r||t).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>{try{return function(e){const n=e.replace(/\s+/g,"");let r=0;function t(){let e=s();for(;r<n.length&&("+"===n[r]||"-"===n[r]);){const t=n[r++],o=s();e="+"===t?e+o:e-o}return e}function s(){let e=o();for(;r<n.length&&("*"===n[r]||"/"===n[r]);){const t=n[r++],s=o();e="*"===t?e*s:e/s}return e}function o(){let e=c();if(r<n.length&&"*"===n[r]&&"*"===n[r+1]){r+=2;const n=c();return Math.pow(e,n)}return e}function c(){return"-"===n[r]?(r++,-i()):"+"===n[r]?(r++,i()):i()}function i(){if("("===n[r]){r++;const e=t();if(")"!==n[r])throw new Error("Missing closing )");return r++,e}const e=n.slice(r).match(/^[0-9]*\.?[0-9]+/);if(!e)throw new Error(`Unexpected token at pos ${r}: "${n[r]}"`);return r+=e[0].length,parseFloat(e[0])}const a=t();if(r!==n.length)throw new Error(`Unexpected token: "${n[r]}"`);return a}(n)}catch(e){return console.error("Invalid math expression:",n),n}}))}const t={},s={},o={},c=new Set,i=new Set;function a(e,n){let r=0,t=n;for(;t<e.length&&("{"===e[t]?r++:"}"===e[t]&&r--,0!==r);)t++;return e.slice(n,t+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let t;for(;null!==(t=r.exec(e));)n.push({type:t[1],condition:t[2].trim(),block:t[3].trim()});return n}function f(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,t,s,o)=>{const c=t||s||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 u(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let t,s=e;const o=[];for(;null!==(t=r.exec(e));){const r=t[1],s=t[2],c=t.index+t[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const i=a(e,c);if(0===i.length||"}"!==i[i.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(t.index,c+i.length);const f=l(i),u=s.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([t.index,c+i.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];s=s.slice(0,n)+s.slice(r)}return s=s.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,t)=>{const s=n[r];if(!s)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=t.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==s.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${s.args.length}, got ${c.length}.`),s.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="",a=!1,l=!1;for(const e of s.conditionBlocks)if("el"===e.type&&(l&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),l=!0),!a||"el"===e.type){if("el"===e.type){if(a)continue;a=!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}'.`),a=!0):a=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[t,s]=n;return t in o?o[t]===s:(console.warn(`fscss[logic] Warning: Condition variable '${t}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,t,s]=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),a=isNaN(s)?s:Number(s);switch(t){case"==":return i==a;case"!=":return i!=a;case">":return i>a;case"<":return i<a;case">=":return i>=a;case"<=":return i<=a;default:return!1}}}))}if(a){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&&s.conditionBlocks.length>0&&!a?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==s.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),s.trim()}async function p(e){return(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,t)=>t?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${t}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function $(e){const n=/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g;let r=e.replace(n,((e,n,r,t,s,c,i)=>{const a=r.split(",").map((e=>e.trim())).filter((e=>e)),l=t??s??c??i??"";return o[n]={params:a,body:l},""}));return r=r.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const t=o[n];if(!t)return e;const s=r?.split(",").map((e=>e.trim()));""===s[0]&&(s[0]=void 0);let c=t.body,i=[];return t.params.forEach(((e,n)=>{const r=t.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const o=i[1]?i[1]:"",a=void 0!==s[n]?s[n]:o,l=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");c=c.replace(l,a)})),c})),n.test(r)?$(r):r}function d(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],t=e.slice(1,-1);const s=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=s.exec(t));)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],s=r.start<0?t.length+r.start:r.start;s=Math.max(0,s);let o=t.substring(s,s+r.length);(s+r.length>t.length||s<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,t=t.slice(0,r.index)+t.slice(r.index+r.fullMatch.length)}return r+t+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,t,s,o){t=parseInt(t),s=parseInt(s),o=o.trim();let c=t<0?r.length+t:t;c=Math.max(0,c);let i=r.substring(c,c+s);return(c+s>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 g(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()));t[e]=n}let s=e;return s=s.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>t[n]?r?(newItems=r.split(",").map((e=>e.trim())),t[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))),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const s=t[n];return s?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>s.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,s.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),s=s.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 s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return s.length;if("first"===r)return s[0];if("last"===r)return s.at(-1);if("indices"===r)return Array(s.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return s.join(",");if("reverse"===r)return s.toReversed().join(",");if("randint"===r)return s[Math.floor(Math.random()*s.length)];if("segment"===r)return s.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(s)].join(",");if("sort"===r)return s.slice().sort().join(",");if("shuffle"===r)return s.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return s.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...s.map(Number));if("max"===r)return Math.max(...s.map(Number))}})),s=s.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,s)=>{const o=t[s];return o?o.map(((e,t)=>{const o=n.replace(new RegExp(`@arr\\.${s}\\[\\]`,"g"),t+1),c=r.replace(new RegExp(`@arr\\.${s}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${s}' not found for loop processing.`),e)})),s=s.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const s=parseInt(r)-1,o=t[n];return o?void 0!==o[s]?o[s]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.map((e=>`${e+o}`)).join(",")})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.map((e=>`${o+e}`)).join(",")})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const s=t[n];return s?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),s.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)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.join(o)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const s=t[n];return s?r?e:`[${s.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),s.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function m(e){const n={},r=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;function t(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 t=e.substring(0,r).trim(),s=e.substring(r+1).trim();t?n[t]=s:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}let s;for(;null!==(s=r.exec(e));){const e=s[1],r=s[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:t(r)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?n[r].props[t]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${t}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?`${t}: ${n[r].props[t]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${t}". 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(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function w(e){const n={},r=/@obj\s+([\w\-\_\—0-9]+)\s*\{([\s\S]*?)\}\s*/g;function t(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[@obj] Invalid style line (missing colon): "${e}"`);continue}const t=e.substring(0,r).trim(),s=e.substring(r+1).trim();t?n[t]=s:console.warn(`fscss[@obj] Empty property name in line: "${e}"`)}return n}let s;for(;null!==(s=r.exec(e));){const e=s[1],r=s[2].trim();n[e]&&console.warn(`fscss[@obj] Duplicate @obj variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:t(r)}}let o=e;return o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?n[r].props[t]:(console.warn(`fscss[@obj] Value extraction failed for "@obj.${r}.${t}.value". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?`${t}: ${n[r].props[t]};`:(console.warn(`fscss[@obj] Single property rule failed for "@obj.${r}.${t}". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@obj] Full variable block replacement failed for "@obj.${r}". Variable not found.`),e))),o=o.replace(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function h(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,t,s,o,c,i)=>{const a=parseInt(c),l=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=a>=0?s.substring(0,a):s.substring(s.length+a),n.add(`--${l}:${f};`),`${r}${t}${s}${o}`}));return n.size>0?r+`\n:root{${Array.from(n).join("\n")}\n}`:r}function x(e){const n=new Map;let r,t=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,t,s)=>{const o=t||s;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return t;let s=0,o=t;do{r=!1;for(const[e,t]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),s=o.replace(n,t);s!==o&&(r=!0,o=s)}s++}while(r&&s<100);var c;return s>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function b(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.replace(/%(\d+)\(([^[]+)\[\s*([^\]]+)\]\)/g,((e,n,r,t)=>{const s=r.split(",").map((e=>e.trim()));return s.length!=n?(console.warn(`Number of properties ${s.length} does not match %${n}`),e):s.map((e=>`${e}${t}`)).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 v(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g,t=[...(e=await p(e)).matchAll(r)];let s=e,o=null;for(const r of t){const[t,c,a]=r;if(o=c,i.has(o)){const e=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("@import\\(exec\\(("+e+")\\)\\s*\\.\\s*(?:pick|find)\\(([^)]+)\\)\\)","g");s=s.replace(n,`/* Can't import ${o} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${o} multiple times at `)}try{const e=c.replace(/["']/g,""),r=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(r))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const o=await fetch(e);if(!o.ok)throw new Error(`fscss[@import] HTTP ${o.status} for ${c}`);const i=S(await o.text(),a.trim());s=s.replace(t,i)}catch(e){console.error(`fscss[@import] Failed: ${c} `,e),s=s.replace(t,`/* Failed import: ${c} */`)}}return s.match(r)?(i.add(o),v(s)):s}function S(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),t=e.match(r);return t?t.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const y=new Set;async function j(e){const n=/\@import\((?:\s+)?exec\((?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`|([^\)]+)(?:\s+)?)\)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let t=e,s=null;for(const n of r){let[r,o,c,i,a]=n;const l=(o||c||i||a).trim();if(s=l,y.has(s)){const e=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?exec\\((?:\\s+)?(?:"('+e+")\"|'("+e+")'|`("+e+")`|("+e+")(?:\\s+)?)\\)(?:\\s+)?\\)","g");t=t.replace(n,`/* Can't import ${s} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${s} multiple times at `)}try{const e=await fetch(l);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${l}`);const n=await e.text();t=t.replace(r,n)}catch(e){console.error(`fscss[@import] Failed: ${l} `,e),t=t.replace(r,`/* Failed import: ${l} */`)}}return t.match(n)?(y.add(s),j(t)):t}async function k(e){const n=/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let t=e,s=null;for(const n of r){let[r,o,i,a,l]=n;o=o.trim();const f=(i||a||l).trim();if(s=f,c.has(s)){const e=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?(?:exec)?\\(([\\w\\d\\.\\@\\—\\-_*\\#\\$\\s\\,]+)\\)(?:\\s+)?from(?:\\s+)?(?:"((?:\\s+)?'+e+"(?:\\s+)?)\"|'((?:\\s+)?"+e+"(?:\\s+)?)'|`((?:\\s+)?"+e+"(?:\\s+)?)`)(?:\\s+)?\\)","g");t=t.replace(n,`/* Can't import ${s} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${s} multiple times at `)}try{const e=await fetch(f);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${f}`);const n=await e.text();if("*"===o&&(t=t.replace(r,n)),"*"!==o&&o.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${r}: unexpected *`),t=t.replace(r,"/* syntax error: unexpected * */")),"*"!==o&&!o.includes("*")){const e=_(n,o.split(",").map((e=>e.trim())));t=t.replace(r,e)}}catch(e){console.error(`fscss[@import] Failed: ${f} `,e),t=t.replace(r,`/* Failed import: ${f} */`)}}return t.match(n)?(c.add(s),k(t)):t}function _(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 t="",s=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;s=r,c?t=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),t=r):t=r}const c=new RegExp("@define\\s+("+s+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${s} is undefined for import`);const a=new RegExp("(@define\\s+)("+s+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(a,((e,n,r,s)=>`${n}${t}${s}`))+"\n"})),r.trim()}try{await async function(){const t=document.querySelectorAll("style");if(t.length)for(const o of t){let t=o.textContent;t.includes("exec.obj.block(all)")||(t.includes("exec.obj.block(f import)")&&t.includes("exec.obj.block(f import pick)")||(t=await v(t)),t.includes("exec.obj.block(f import)")&&t.includes("exec.obj.block(f import from)")||(t=await k(t)),t.includes("exec.obj.block(f import)")||(t=await j(t)),t.includes("exec.obj.block(vfc)")||(t=t.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,t,s)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&s&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${s})`),t&&!s?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(s?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(s.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${s}`),s?`${n}${s.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),t.includes("exec.obj.block(store:before)")&&t.includes("exec.obj.block(store)")||(t=x(t)),t.includes("exec.obj.block(ext:before)")&&t.includes("exec.obj.block(ext)")||(t=d(t)),t.includes("exec.obj.block(f var)")||(t=function(e){const n={},r=[],t=e.split("\n");let s=!1;const o={};for(let e=0;e<t.length;e++){let c=t[e].trim();if(c.includes("{")){s=!0,r.push(c);continue}if(c.includes("}")){s=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,a=c.match(i);if(a){const[,e,t]=a;s?o[e]=t.trim():(n[e]=t.trim(),r.push(c));continue}const l=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(l,((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}}}(t).css),t.includes("exec.obj.block(fun)")||(t=m(t)),t.includes("exec.obj.block(obj)")||(t=w(t)),t.includes("exec.obj.block(length)")||(t=n(t)),t.includes("exec.obj.block(count)")||(t=e(t)),t.includes("exec.obj.block(define)")||(t=$(t)),t.includes("exec.obj.block(arr)")||(t=g(t)),t.includes("exec.obj.block(event)")||(t=u(t)),t.includes("exec.obj.block(random)")||(t=t.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),t=n.split(",").map((e=>e.trim()));if(0===t.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=t.join(":");s[e]||(s[e]={values:t,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=s[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 t[Math.floor(Math.random()*t.length)]}))),t.includes("exec.obj.block(copy)")||(t=h(t)),t.includes("exec.obj.block(store:after)")&&t.includes("exec.obj.block(store)")||(t=x(t)),t.includes("exec.obj.block(num)")||(t=r(t)),t.includes("exec.obj.block(ext:after)")&&t.includes("exec.obj.block(ext)")||(t=d(t)),t.includes("exec.obj.block(t group)")||(t=b(t)),t.includes("exec.obj.block(length)")||(t=n(t)),t.includes("exec.obj.block(count)")||(t=e(t)),t.includes("exec.obj.block(debug)")||(t=f(t))),t=t.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=t}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"),t=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${t}`)}xfscssProcessorWrap(),applyFscssStyles();
|
package/e/xfscss.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* FIGSH-FSCSS light, source v3
|
|
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.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.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={},c=new Set,i=new Set;function a(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 f(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 u(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 i=a(e,c);if(0===i.length||"}"!==i[i.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+i.length);const f=l(i),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+i.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="",a=!1,l=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(l&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),l=!0),!a||"el"===e.type){if("el"===e.type){if(a)continue;a=!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}'.`),a=!0):a=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),a=isNaN(t)?t:Number(t);switch(s){case"==":return i==a;case"!=":return i!=a;case">":return i>a;case"<":return i<a;case">=":return i>=a;case"<=":return i<=a;default:return!1}}}))}if(a){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&&!a?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 p(e){return(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 $(e){const n=/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g;let r=e.replace(n,((e,n,r,s,t,c,i)=>{const a=r.split(",").map((e=>e.trim())).filter((e=>e)),l=s??t??c??i??"";return o[n]={params:a,body:l},""}));return r=r.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=o[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let c=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 o=i[1]?i[1]:"",a=void 0!==t[n]?t[n]:o,l=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");c=c.replace(l,a)})),c})),n.test(r)?$(r):r}function d(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 g(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 m(e){const n={},r=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;function s(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}let t;for(;null!==(t=r.exec(e));){const e=t[1],r=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:s(r)}}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(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function w(e){const n={},r=/@obj\s+([\w\-\_\—0-9]+)\s*\{([\s\S]*?)\}\s*/g;function s(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[@obj] 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[@obj] Empty property name in line: "${e}"`)}return n}let t;for(;null!==(t=r.exec(e));){const e=t[1],r=t[2].trim();n[e]&&console.warn(`fscss[@obj] Duplicate @obj variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:s(r)}}let o=e;return o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@obj] Value extraction failed for "@obj.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@obj] Single property rule failed for "@obj.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@obj] Full variable block replacement failed for "@obj.${r}". Variable not found.`),e))),o=o.replace(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function h(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const a=parseInt(c),l=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=a>=0?t.substring(0,a):t.substring(t.length+a),n.add(`--${l}:${f};`),`${r}${s}${t}${o}`}));return n.size>0?r+`\n:root{${Array.from(n).join("\n")}\n}`:r}function x(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,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 b(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.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 v(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g,s=[...(e=await p(e)).matchAll(r)];let t=e,o=null;for(const r of s){const[s,c,a]=r;if(o=c,i.has(o)){const e=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("@import\\(exec\\(("+e+")\\)\\s*\\.\\s*(?:pick|find)\\(([^)]+)\\)\\)","g");t=t.replace(n,`/* Can't import ${o} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${o} multiple times at `)}try{const e=c.replace(/["']/g,""),r=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(r))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const o=await fetch(e);if(!o.ok)throw new Error(`fscss[@import] HTTP ${o.status} for ${c}`);const i=S(await o.text(),a.trim());t=t.replace(s,i)}catch(e){console.error(`fscss[@import] Failed: ${c} `,e),t=t.replace(s,`/* Failed import: ${c} */`)}}return t.match(r)?(i.add(o),v(t)):t}function S(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 y=new Set;async function j(e){const n=/\@import\((?:\s+)?exec\((?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`|([^\)]+)(?:\s+)?)\)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let s=e,t=null;for(const n of r){let[r,o,c,i,a]=n;const l=(o||c||i||a).trim();if(t=l,y.has(t)){const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?exec\\((?:\\s+)?(?:"('+e+")\"|'("+e+")'|`("+e+")`|("+e+")(?:\\s+)?)\\)(?:\\s+)?\\)","g");s=s.replace(n,`/* Can't import ${t} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${t} multiple times at `)}try{const e=await fetch(l);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${l}`);const n=await e.text();s=s.replace(r,n)}catch(e){console.error(`fscss[@import] Failed: ${l} `,e),s=s.replace(r,`/* Failed import: ${l} */`)}}return s.match(n)?(y.add(t),j(s)):s}async function k(e){const n=/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let s=e,t=null;for(const n of r){let[r,o,i,a,l]=n;o=o.trim();const f=(i||a||l).trim();if(t=f,c.has(t)){const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?(?:exec)?\\(([\\w\\d\\.\\@\\—\\-_*\\#\\$\\s\\,]+)\\)(?:\\s+)?from(?:\\s+)?(?:"((?:\\s+)?'+e+"(?:\\s+)?)\"|'((?:\\s+)?"+e+"(?:\\s+)?)'|`((?:\\s+)?"+e+"(?:\\s+)?)`)(?:\\s+)?\\)","g");s=s.replace(n,`/* Can't import ${t} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${t} multiple times at `)}try{const e=await fetch(f);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${f}`);const n=await e.text();if("*"===o&&(s=s.replace(r,n)),"*"!==o&&o.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${r}: unexpected *`),s=s.replace(r,"/* syntax error: unexpected * */")),"*"!==o&&!o.includes("*")){const e=_(n,o.split(",").map((e=>e.trim())));s=s.replace(r,e)}}catch(e){console.error(`fscss[@import] Failed: ${f} `,e),s=s.replace(r,`/* Failed import: ${f} */`)}}return s.match(n)?(c.add(t),k(s)):s}function _(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 a=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(a,((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(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await v(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await k(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=x(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=d(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*([^;]+);/,a=c.match(i);if(a){const[,e,s]=a;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const l=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(l,((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=m(s)),s.includes("exec.obj.block(obj)")||(s=w(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=$(s)),s.includes("exec.obj.block(arr)")||(s=g(s)),s.includes("exec.obj.block(event)")||(s=u(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=h(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=x(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=d(s)),s.includes("exec.obj.block(t group)")||(s=b(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=f(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();
|
|
1
|
+
/* FIGSH-FSCSS light, source v3., fscss.devtem.org */
|
|
2
|
+
export function exec({type:e="text",content:n,onError:r,onSuccess:t}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const s=document.createElement("style"),o=e=>{s.textContent=e,document.head.appendChild(s),t&&t(s),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 t=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${t}`),r&&r(t)}));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),t=parseInt(n),s=parseInt(r||1),`${Array(t).fill().map(((e,n)=>(n+1)*s))}`;var t,s}))}function n(e){return e=e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,t)=>(n||r||t).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>{try{return function(e){const n=e.replace(/\s+/g,"");let r=0;function t(){let e=s();for(;r<n.length&&("+"===n[r]||"-"===n[r]);){const t=n[r++],o=s();e="+"===t?e+o:e-o}return e}function s(){let e=o();for(;r<n.length&&("*"===n[r]||"/"===n[r]);){const t=n[r++],s=o();e="*"===t?e*s:e/s}return e}function o(){let e=c();if(r<n.length&&"*"===n[r]&&"*"===n[r+1]){r+=2;const n=c();return Math.pow(e,n)}return e}function c(){return"-"===n[r]?(r++,-i()):"+"===n[r]?(r++,i()):i()}function i(){if("("===n[r]){r++;const e=t();if(")"!==n[r])throw new Error("Missing closing )");return r++,e}const e=n.slice(r).match(/^[0-9]*\.?[0-9]+/);if(!e)throw new Error(`Unexpected token at pos ${r}: "${n[r]}"`);return r+=e[0].length,parseFloat(e[0])}const a=t();if(r!==n.length)throw new Error(`Unexpected token: "${n[r]}"`);return a}(n)}catch(e){return console.error("Invalid math expression:",n),n}}))}const t={},s={},o={},c=new Set,i=new Set;function a(e,n){let r=0,t=n;for(;t<e.length&&("{"===e[t]?r++:"}"===e[t]&&r--,0!==r);)t++;return e.slice(n,t+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let t;for(;null!==(t=r.exec(e));)n.push({type:t[1],condition:t[2].trim(),block:t[3].trim()});return n}function f(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,t,s,o)=>{const c=t||s||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 u(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let t,s=e;const o=[];for(;null!==(t=r.exec(e));){const r=t[1],s=t[2],c=t.index+t[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const i=a(e,c);if(0===i.length||"}"!==i[i.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(t.index,c+i.length);const f=l(i),u=s.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([t.index,c+i.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];s=s.slice(0,n)+s.slice(r)}return s=s.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,t)=>{const s=n[r];if(!s)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=t.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==s.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${s.args.length}, got ${c.length}.`),s.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="",a=!1,l=!1;for(const e of s.conditionBlocks)if("el"===e.type&&(l&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),l=!0),!a||"el"===e.type){if("el"===e.type){if(a)continue;a=!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}'.`),a=!0):a=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[t,s]=n;return t in o?o[t]===s:(console.warn(`fscss[logic] Warning: Condition variable '${t}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,t,s]=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),a=isNaN(s)?s:Number(s);switch(t){case"==":return i==a;case"!=":return i!=a;case">":return i>a;case"<":return i<a;case">=":return i>=a;case"<=":return i<=a;default:return!1}}}))}if(a){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&&s.conditionBlocks.length>0&&!a?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==s.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),s.trim()}async function p(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,t)=>t?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${t}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function $(e){const n=/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g;let r=e.replace(n,((e,n,r,t,s,c,i)=>{const a=r.split(",").map((e=>e.trim())).filter((e=>e)),l=t??s??c??i??"";return o[n]={params:a,body:l},""}));return r=r.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const t=o[n];if(!t)return e;const s=r?.split(",").map((e=>e.trim()));""===s[0]&&(s[0]=void 0);let c=t.body,i=[];return t.params.forEach(((e,n)=>{const r=t.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const o=i[1]?i[1]:"",a=void 0!==s[n]?s[n]:o,l=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");c=c.replace(l,a)})),c})),n.test(r)?$(r):r}function d(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],t=e.slice(1,-1);const s=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=s.exec(t));)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],s=r.start<0?t.length+r.start:r.start;s=Math.max(0,s);let o=t.substring(s,s+r.length);(s+r.length>t.length||s<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,t=t.slice(0,r.index)+t.slice(r.index+r.fullMatch.length)}return r+t+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,t,s,o){t=parseInt(t),s=parseInt(s),o=o.trim();let c=t<0?r.length+t:t;c=Math.max(0,c);let i=r.substring(c,c+s);return(c+s>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 g(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()));t[e]=n}let s=e;return s=s.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>t[n]?r?(newItems=r.split(",").map((e=>e.trim())),t[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))),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const s=t[n];return s?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>s.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,s.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),s=s.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 s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return s.length;if("first"===r)return s[0];if("last"===r)return s.at(-1);if("indices"===r)return Array(s.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return s.join(",");if("reverse"===r)return s.toReversed().join(",");if("randint"===r)return s[Math.floor(Math.random()*s.length)];if("segment"===r)return s.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(s)].join(",");if("sort"===r)return s.slice().sort().join(",");if("shuffle"===r)return s.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return s.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...s.map(Number));if("max"===r)return Math.max(...s.map(Number))}})),s=s.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,s)=>{const o=t[s];return o?o.map(((e,t)=>{const o=n.replace(new RegExp(`@arr\\.${s}\\[\\]`,"g"),t+1),c=r.replace(new RegExp(`@arr\\.${s}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${s}' not found for loop processing.`),e)})),s=s.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const s=parseInt(r)-1,o=t[n];return o?void 0!==o[s]?o[s]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.map((e=>`${e+o}`)).join(",")})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.map((e=>`${o+e}`)).join(",")})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const s=t[n];return s?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),s.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)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.join(o)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const s=t[n];return s?r?e:`[${s.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),s.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function m(e){const n={},r=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;function t(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 t=e.substring(0,r).trim(),s=e.substring(r+1).trim();t?n[t]=s:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}let s;for(;null!==(s=r.exec(e));){const e=s[1],r=s[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:t(r)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?n[r].props[t]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${t}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?`${t}: ${n[r].props[t]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${t}". 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(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function w(e){const n={},r=/@obj\s+([\w\-\_\—0-9]+)\s*\{([\s\S]*?)\}\s*/g;function t(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[@obj] Invalid style line (missing colon): "${e}"`);continue}const t=e.substring(0,r).trim(),s=e.substring(r+1).trim();t?n[t]=s:console.warn(`fscss[@obj] Empty property name in line: "${e}"`)}return n}let s;for(;null!==(s=r.exec(e));){const e=s[1],r=s[2].trim();n[e]&&console.warn(`fscss[@obj] Duplicate @obj variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:t(r)}}let o=e;return o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?n[r].props[t]:(console.warn(`fscss[@obj] Value extraction failed for "@obj.${r}.${t}.value". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?`${t}: ${n[r].props[t]};`:(console.warn(`fscss[@obj] Single property rule failed for "@obj.${r}.${t}". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@obj] Full variable block replacement failed for "@obj.${r}". Variable not found.`),e))),o=o.replace(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function h(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,t,s,o,c,i)=>{const a=parseInt(c),l=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=a>=0?s.substring(0,a):s.substring(s.length+a),n.add(`--${l}:${f};`),`${r}${t}${s}${o}`}));if(n.size>0){return r+`\n${`:root{${Array.from(n).join("\n")}\n}`}`}return r}function x(e){const n=new Map;let r,t=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,t,s)=>{const o=t||s;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return t;let s=0;let o=t;do{r=!1;for(const[e,t]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),s=o.replace(n,t);s!==o&&(r=!0,o=s)}s++}while(r&&s<100);var c;return s>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function b(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,t)=>{const s=r.split(",").map((e=>e.trim()));return s.length!=n?(console.warn(`Number of properties ${s.length} does not match %${n}`),e):s.map((e=>`${e}${t}`)).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 v(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g,t=[...(e=await p(e)).matchAll(r)];let s=e,o=null;for(const e of t){const[r,t,c]=e;if(o=t,i.has(o)){const e=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("@import\\(exec\\(("+e+")\\)\\s*\\.\\s*(?:pick|find)\\(([^)]+)\\)\\)","g");s=s.replace(n,`/* Can't import ${o} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${o} multiple times at `)}try{const e=t.replace(/["']/g,""),o=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(o))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 a=S(await i.text(),c.trim());s=s.replace(r,a)}catch(e){console.error(`fscss[@import] Failed: ${t} `,e),s=s.replace(r,`/* Failed import: ${t} */`)}}return s.match(r)?(i.add(o),v(s)):s}function S(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),t=e.match(r);return t?t.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const y=new Set;async function j(e){const n=/\@import\((?:\s+)?exec\((?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`|([^\)]+)(?:\s+)?)\)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let t=e,s=null;for(const e of r){let[n,r,o,c,i]=e;const a=(r||o||c||i).trim();if(s=a,y.has(s)){const e=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?exec\\((?:\\s+)?(?:"('+e+")\"|'("+e+")'|`("+e+")`|("+e+")(?:\\s+)?)\\)(?:\\s+)?\\)","g");t=t.replace(n,`/* Can't import ${s} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${s} multiple times at `)}try{const e=await fetch(a);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${a}`);const r=await e.text();t=t.replace(n,r)}catch(e){console.error(`fscss[@import] Failed: ${a} `,e),t=t.replace(n,`/* Failed import: ${a} */`)}}return t.match(n)?(y.add(s),j(t)):t}async function k(e){const n=/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let t=e,s=null;for(const e of r){let[n,r,o,i,a]=e;r=r.trim();const l=(o||i||a).trim();if(s=l,c.has(s)){const e=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?(?:exec)?\\(([\\w\\d\\.\\@\\—\\-_*\\#\\$\\s\\,]+)\\)(?:\\s+)?from(?:\\s+)?(?:"((?:\\s+)?'+e+"(?:\\s+)?)\"|'((?:\\s+)?"+e+"(?:\\s+)?)'|`((?:\\s+)?"+e+"(?:\\s+)?)`)(?:\\s+)?\\)","g");t=t.replace(n,`/* Can't import ${s} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${s} multiple times at `)}try{const e=await fetch(l);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${l}`);const s=await e.text();if("*"===r&&(t=t.replace(n,s)),"*"!==r&&r.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${n}: unexpected *`),t=t.replace(n,"/* syntax error: unexpected * */")),"*"!==r&&!r.includes("*")){const e=_(s,r.split(",").map((e=>e.trim())));t=t.replace(n,e)}}catch(e){console.error(`fscss[@import] Failed: ${l} `,e),t=t.replace(n,`/* Failed import: ${l} */`)}}return t.match(n)?(c.add(s),k(t)):t}function _(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 t="",s=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;s=r,c?t=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),t=r):t=r}const c=new RegExp("@define\\s+("+s+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${s} is undefined for import`);const a=new RegExp("(@define\\s+)("+s+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(a,((e,n,r,s)=>`${n}${t}${s}`))+"\n"})),r.trim()}try{await async function(){const t=document.querySelectorAll("style");if(t.length)for(const o of t){let t=o.textContent;t.includes("exec.obj.block(all)")||(t.includes("exec.obj.block(f import)")&&t.includes("exec.obj.block(f import pick)")||(t=await v(t)),t.includes("exec.obj.block(f import)")&&t.includes("exec.obj.block(f import from)")||(t=await k(t)),t.includes("exec.obj.block(f import)")||(t=await j(t)),t.includes("exec.obj.block(vfc)")||(t=t.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,t,s)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&s&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${s})`),t&&!s?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(s?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(s.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${s}`),s?`${n}${s.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),t.includes("exec.obj.block(store:before)")&&t.includes("exec.obj.block(store)")||(t=x(t)),t.includes("exec.obj.block(ext:before)")&&t.includes("exec.obj.block(ext)")||(t=d(t)),t.includes("exec.obj.block(f var)")||(t=function(e){const n={},r=[],t=e.split("\n");let s=!1;const o={};for(let e=0;e<t.length;e++){let c=t[e].trim();if(c.includes("{")){s=!0,r.push(c);continue}if(c.includes("}")){s=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,a=c.match(i);if(a){const[,e,t]=a;s?o[e]=t.trim():(n[e]=t.trim(),r.push(c));continue}const l=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(l,((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}}}(t).css),t.includes("exec.obj.block(fun)")||(t=m(t)),t.includes("exec.obj.block(obj)")||(t=w(t)),t.includes("exec.obj.block(length)")||(t=n(t)),t.includes("exec.obj.block(count)")||(t=e(t)),t.includes("exec.obj.block(define)")||(t=$(t)),t.includes("exec.obj.block(arr)")||(t=g(t)),t.includes("exec.obj.block(event)")||(t=u(t)),t.includes("exec.obj.block(random)")||(t=t.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),t=n.split(",").map((e=>e.trim()));if(0===t.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=t.join(":");s[e]||(s[e]={values:t,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=s[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 t[Math.floor(Math.random()*t.length)]}))),t.includes("exec.obj.block(copy)")||(t=h(t)),t.includes("exec.obj.block(store:after)")&&t.includes("exec.obj.block(store)")||(t=x(t)),t.includes("exec.obj.block(num)")||(t=r(t)),t.includes("exec.obj.block(ext:after)")&&t.includes("exec.obj.block(ext)")||(t=d(t)),t.includes("exec.obj.block(t group)")||(t=b(t)),t.includes("exec.obj.block(length)")||(t=n(t)),t.includes("exec.obj.block(count)")||(t=e(t)),t.includes("exec.obj.block(debug)")||(t=f(t))),t=t.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=t}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"),t=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${t}`)}xfscssProcessorWrap(),applyFscssStyles();
|
package/exec.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* Figsh-fscss light, source v3
|
|
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.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.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={},c=new Set,i=new Set;function a(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 f(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 u(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 i=a(e,c);if(0===i.length||"}"!==i[i.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+i.length);const f=l(i),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+i.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="",a=!1,l=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(l&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),l=!0),!a||"el"===e.type){if("el"===e.type){if(a)continue;a=!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}'.`),a=!0):a=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),a=isNaN(t)?t:Number(t);switch(s){case"==":return i==a;case"!=":return i!=a;case">":return i>a;case"<":return i<a;case">=":return i>=a;case"<=":return i<=a;default:return!1}}}))}if(a){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&&!a?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 p(e){return(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 $(e){const n=/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g;let r=e.replace(n,((e,n,r,s,t,c,i)=>{const a=r.split(",").map((e=>e.trim())).filter((e=>e)),l=s??t??c??i??"";return o[n]={params:a,body:l},""}));return r=r.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=o[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let c=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 o=i[1]?i[1]:"",a=void 0!==t[n]?t[n]:o,l=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");c=c.replace(l,a)})),c})),n.test(r)?$(r):r}function d(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 g(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 m(e){const n={},r=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;function s(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}let t;for(;null!==(t=r.exec(e));){const e=t[1],r=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:s(r)}}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(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function w(e){const n={},r=/@obj\s+([\w\-\_\—0-9]+)\s*\{([\s\S]*?)\}\s*/g;function s(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[@obj] 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[@obj] Empty property name in line: "${e}"`)}return n}let t;for(;null!==(t=r.exec(e));){const e=t[1],r=t[2].trim();n[e]&&console.warn(`fscss[@obj] Duplicate @obj variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:s(r)}}let o=e;return o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@obj] Value extraction failed for "@obj.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@obj] Single property rule failed for "@obj.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@obj] Full variable block replacement failed for "@obj.${r}". Variable not found.`),e))),o=o.replace(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function h(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const a=parseInt(c),l=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=a>=0?t.substring(0,a):t.substring(t.length+a),n.add(`--${l}:${f};`),`${r}${s}${t}${o}`}));return n.size>0?r+`\n:root{${Array.from(n).join("\n")}\n}`:r}function x(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,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 b(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.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 v(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g,s=[...(e=await p(e)).matchAll(r)];let t=e,o=null;for(const r of s){const[s,c,a]=r;if(o=c,i.has(o)){const e=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("@import\\(exec\\(("+e+")\\)\\s*\\.\\s*(?:pick|find)\\(([^)]+)\\)\\)","g");t=t.replace(n,`/* Can't import ${o} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${o} multiple times at `)}try{const e=c.replace(/["']/g,""),r=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(r))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const o=await fetch(e);if(!o.ok)throw new Error(`fscss[@import] HTTP ${o.status} for ${c}`);const i=S(await o.text(),a.trim());t=t.replace(s,i)}catch(e){console.error(`fscss[@import] Failed: ${c} `,e),t=t.replace(s,`/* Failed import: ${c} */`)}}return t.match(r)?(i.add(o),v(t)):t}function S(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 y=new Set;async function j(e){const n=/\@import\((?:\s+)?exec\((?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`|([^\)]+)(?:\s+)?)\)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let s=e,t=null;for(const n of r){let[r,o,c,i,a]=n;const l=(o||c||i||a).trim();if(t=l,y.has(t)){const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?exec\\((?:\\s+)?(?:"('+e+")\"|'("+e+")'|`("+e+")`|("+e+")(?:\\s+)?)\\)(?:\\s+)?\\)","g");s=s.replace(n,`/* Can't import ${t} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${t} multiple times at `)}try{const e=await fetch(l);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${l}`);const n=await e.text();s=s.replace(r,n)}catch(e){console.error(`fscss[@import] Failed: ${l} `,e),s=s.replace(r,`/* Failed import: ${l} */`)}}return s.match(n)?(y.add(t),j(s)):s}async function k(e){const n=/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let s=e,t=null;for(const n of r){let[r,o,i,a,l]=n;o=o.trim();const f=(i||a||l).trim();if(t=f,c.has(t)){const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?(?:exec)?\\(([\\w\\d\\.\\@\\—\\-_*\\#\\$\\s\\,]+)\\)(?:\\s+)?from(?:\\s+)?(?:"((?:\\s+)?'+e+"(?:\\s+)?)\"|'((?:\\s+)?"+e+"(?:\\s+)?)'|`((?:\\s+)?"+e+"(?:\\s+)?)`)(?:\\s+)?\\)","g");s=s.replace(n,`/* Can't import ${t} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${t} multiple times at `)}try{const e=await fetch(f);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${f}`);const n=await e.text();if("*"===o&&(s=s.replace(r,n)),"*"!==o&&o.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${r}: unexpected *`),s=s.replace(r,"/* syntax error: unexpected * */")),"*"!==o&&!o.includes("*")){const e=_(n,o.split(",").map((e=>e.trim())));s=s.replace(r,e)}}catch(e){console.error(`fscss[@import] Failed: ${f} `,e),s=s.replace(r,`/* Failed import: ${f} */`)}}return s.match(n)?(c.add(t),k(s)):s}function _(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 a=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(a,((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(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await v(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await k(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=x(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=d(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*([^;]+);/,a=c.match(i);if(a){const[,e,s]=a;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const l=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(l,((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=m(s)),s.includes("exec.obj.block(obj)")||(s=w(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=$(s)),s.includes("exec.obj.block(arr)")||(s=g(s)),s.includes("exec.obj.block(event)")||(s=u(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=h(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=x(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=d(s)),s.includes("exec.obj.block(t group)")||(s=b(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=f(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
|
+
/* Figsh-fscss light, source v3., fscss.devtem.org */
|
|
2
|
+
function exec({type:e="text",content:n,onError:r,onSuccess:t}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const s=document.createElement("style"),o=e=>{s.textContent=e,document.head.appendChild(s),t&&t(s),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 t=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${t}`),r&&r(t)}));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.replace(/count\(\s*([\d\.]+)\s*(?:,\s*([\d\.]+)?)?\)/g,((e,n,r)=>{return null===r&&(r=1),t=parseInt(n),s=parseInt(r||1),`${Array(t).fill().map(((e,n)=>(n+1)*s))}`;var t,s}))}function n(e){return e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,t)=>(n||r||t).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>{try{return function(e){const n=e.replace(/\s+/g,"");let r=0;function t(){let e=s();for(;r<n.length&&("+"===n[r]||"-"===n[r]);){const t=n[r++],o=s();e="+"===t?e+o:e-o}return e}function s(){let e=o();for(;r<n.length&&("*"===n[r]||"/"===n[r]);){const t=n[r++],s=o();e="*"===t?e*s:e/s}return e}function o(){let e=c();if(r<n.length&&"*"===n[r]&&"*"===n[r+1]){r+=2;const n=c();return Math.pow(e,n)}return e}function c(){return"-"===n[r]?(r++,-i()):"+"===n[r]?(r++,i()):i()}function i(){if("("===n[r]){r++;const e=t();if(")"!==n[r])throw new Error("Missing closing )");return r++,e}const e=n.slice(r).match(/^[0-9]*\.?[0-9]+/);if(!e)throw new Error(`Unexpected token at pos ${r}: "${n[r]}"`);return r+=e[0].length,parseFloat(e[0])}const a=t();if(r!==n.length)throw new Error(`Unexpected token: "${n[r]}"`);return a}(n)}catch(e){return console.error("Invalid math expression:",n),n}}))}const t={},s={},o={},c=new Set,i=new Set;function a(e,n){let r=0,t=n;for(;t<e.length&&("{"===e[t]?r++:"}"===e[t]&&r--,0!==r);)t++;return e.slice(n,t+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let t;for(;null!==(t=r.exec(e));)n.push({type:t[1],condition:t[2].trim(),block:t[3].trim()});return n}function f(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,t,s,o)=>{const c=t||s||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 u(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let t,s=e;const o=[];for(;null!==(t=r.exec(e));){const r=t[1],s=t[2],c=t.index+t[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const i=a(e,c);if(0===i.length||"}"!==i[i.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(t.index,c+i.length);const f=l(i),u=s.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([t.index,c+i.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];s=s.slice(0,n)+s.slice(r)}return s=s.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,t)=>{const s=n[r];if(!s)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=t.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==s.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${s.args.length}, got ${c.length}.`),s.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="",a=!1,l=!1;for(const e of s.conditionBlocks)if("el"===e.type&&(l&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),l=!0),!a||"el"===e.type){if("el"===e.type){if(a)continue;a=!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}'.`),a=!0):a=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[t,s]=n;return t in o?o[t]===s:(console.warn(`fscss[logic] Warning: Condition variable '${t}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,t,s]=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),a=isNaN(s)?s:Number(s);switch(t){case"==":return i==a;case"!=":return i!=a;case">":return i>a;case"<":return i<a;case">=":return i>=a;case"<=":return i<=a;default:return!1}}}))}if(a){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&&s.conditionBlocks.length>0&&!a?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==s.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),s.trim()}async function p(e){return(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,t)=>t?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${t}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function $(e){const n=/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g;let r=e.replace(n,((e,n,r,t,s,c,i)=>{const a=r.split(",").map((e=>e.trim())).filter((e=>e)),l=t??s??c??i??"";return o[n]={params:a,body:l},""}));return r=r.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const t=o[n];if(!t)return e;const s=r?.split(",").map((e=>e.trim()));""===s[0]&&(s[0]=void 0);let c=t.body,i=[];return t.params.forEach(((e,n)=>{const r=t.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const o=i[1]?i[1]:"",a=void 0!==s[n]?s[n]:o,l=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");c=c.replace(l,a)})),c})),n.test(r)?$(r):r}function d(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],t=e.slice(1,-1);const s=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=s.exec(t));)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],s=r.start<0?t.length+r.start:r.start;s=Math.max(0,s);let o=t.substring(s,s+r.length);(s+r.length>t.length||s<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,t=t.slice(0,r.index)+t.slice(r.index+r.fullMatch.length)}return r+t+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,t,s,o){t=parseInt(t),s=parseInt(s),o=o.trim();let c=t<0?r.length+t:t;c=Math.max(0,c);let i=r.substring(c,c+s);return(c+s>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 g(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()));t[e]=n}let s=e;return s=s.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>t[n]?r?(newItems=r.split(",").map((e=>e.trim())),t[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))),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const s=t[n];return s?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>s.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,s.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),s=s.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 s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return s.length;if("first"===r)return s[0];if("last"===r)return s.at(-1);if("indices"===r)return Array(s.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return s.join(",");if("reverse"===r)return s.toReversed().join(",");if("randint"===r)return s[Math.floor(Math.random()*s.length)];if("segment"===r)return s.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(s)].join(",");if("sort"===r)return s.slice().sort().join(",");if("shuffle"===r)return s.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return s.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...s.map(Number));if("max"===r)return Math.max(...s.map(Number))}})),s=s.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,s)=>{const o=t[s];return o?o.map(((e,t)=>{const o=n.replace(new RegExp(`@arr\\.${s}\\[\\]`,"g"),t+1),c=r.replace(new RegExp(`@arr\\.${s}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${s}' not found for loop processing.`),e)})),s=s.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const s=parseInt(r)-1,o=t[n];return o?void 0!==o[s]?o[s]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.map((e=>`${e+o}`)).join(",")})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.map((e=>`${o+e}`)).join(",")})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const s=t[n];return s?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),s.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)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.join(o)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const s=t[n];return s?r?e:`[${s.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),s.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function m(e){const n={},r=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;function t(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 t=e.substring(0,r).trim(),s=e.substring(r+1).trim();t?n[t]=s:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}let s;for(;null!==(s=r.exec(e));){const e=s[1],r=s[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:t(r)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?n[r].props[t]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${t}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?`${t}: ${n[r].props[t]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${t}". 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(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function w(e){const n={},r=/@obj\s+([\w\-\_\—0-9]+)\s*\{([\s\S]*?)\}\s*/g;function t(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[@obj] Invalid style line (missing colon): "${e}"`);continue}const t=e.substring(0,r).trim(),s=e.substring(r+1).trim();t?n[t]=s:console.warn(`fscss[@obj] Empty property name in line: "${e}"`)}return n}let s;for(;null!==(s=r.exec(e));){const e=s[1],r=s[2].trim();n[e]&&console.warn(`fscss[@obj] Duplicate @obj variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:t(r)}}let o=e;return o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?n[r].props[t]:(console.warn(`fscss[@obj] Value extraction failed for "@obj.${r}.${t}.value". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?`${t}: ${n[r].props[t]};`:(console.warn(`fscss[@obj] Single property rule failed for "@obj.${r}.${t}". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@obj] Full variable block replacement failed for "@obj.${r}". Variable not found.`),e))),o=o.replace(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function h(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,t,s,o,c,i)=>{const a=parseInt(c),l=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=a>=0?s.substring(0,a):s.substring(s.length+a),n.add(`--${l}:${f};`),`${r}${t}${s}${o}`}));return n.size>0?r+`\n:root{${Array.from(n).join("\n")}\n}`:r}function x(e){const n=new Map;let r,t=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,t,s)=>{const o=t||s;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return t;let s=0,o=t;do{r=!1;for(const[e,t]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),s=o.replace(n,t);s!==o&&(r=!0,o=s)}s++}while(r&&s<100);var c;return s>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function b(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.replace(/%(\d+)\(([^[]+)\[\s*([^\]]+)\]\)/g,((e,n,r,t)=>{const s=r.split(",").map((e=>e.trim()));return s.length!=n?(console.warn(`Number of properties ${s.length} does not match %${n}`),e):s.map((e=>`${e}${t}`)).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 v(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g,t=[...(e=await p(e)).matchAll(r)];let s=e,o=null;for(const r of t){const[t,c,a]=r;if(o=c,i.has(o)){const e=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("@import\\(exec\\(("+e+")\\)\\s*\\.\\s*(?:pick|find)\\(([^)]+)\\)\\)","g");s=s.replace(n,`/* Can't import ${o} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${o} multiple times at `)}try{const e=c.replace(/["']/g,""),r=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(r))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const o=await fetch(e);if(!o.ok)throw new Error(`fscss[@import] HTTP ${o.status} for ${c}`);const i=S(await o.text(),a.trim());s=s.replace(t,i)}catch(e){console.error(`fscss[@import] Failed: ${c} `,e),s=s.replace(t,`/* Failed import: ${c} */`)}}return s.match(r)?(i.add(o),v(s)):s}function S(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),t=e.match(r);return t?t.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const y=new Set;async function j(e){const n=/\@import\((?:\s+)?exec\((?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`|([^\)]+)(?:\s+)?)\)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let t=e,s=null;for(const n of r){let[r,o,c,i,a]=n;const l=(o||c||i||a).trim();if(s=l,y.has(s)){const e=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?exec\\((?:\\s+)?(?:"('+e+")\"|'("+e+")'|`("+e+")`|("+e+")(?:\\s+)?)\\)(?:\\s+)?\\)","g");t=t.replace(n,`/* Can't import ${s} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${s} multiple times at `)}try{const e=await fetch(l);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${l}`);const n=await e.text();t=t.replace(r,n)}catch(e){console.error(`fscss[@import] Failed: ${l} `,e),t=t.replace(r,`/* Failed import: ${l} */`)}}return t.match(n)?(y.add(s),j(t)):t}async function k(e){const n=/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let t=e,s=null;for(const n of r){let[r,o,i,a,l]=n;o=o.trim();const f=(i||a||l).trim();if(s=f,c.has(s)){const e=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?(?:exec)?\\(([\\w\\d\\.\\@\\—\\-_*\\#\\$\\s\\,]+)\\)(?:\\s+)?from(?:\\s+)?(?:"((?:\\s+)?'+e+"(?:\\s+)?)\"|'((?:\\s+)?"+e+"(?:\\s+)?)'|`((?:\\s+)?"+e+"(?:\\s+)?)`)(?:\\s+)?\\)","g");t=t.replace(n,`/* Can't import ${s} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${s} multiple times at `)}try{const e=await fetch(f);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${f}`);const n=await e.text();if("*"===o&&(t=t.replace(r,n)),"*"!==o&&o.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${r}: unexpected *`),t=t.replace(r,"/* syntax error: unexpected * */")),"*"!==o&&!o.includes("*")){const e=_(n,o.split(",").map((e=>e.trim())));t=t.replace(r,e)}}catch(e){console.error(`fscss[@import] Failed: ${f} `,e),t=t.replace(r,`/* Failed import: ${f} */`)}}return t.match(n)?(c.add(s),k(t)):t}function _(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 t="",s=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;s=r,c?t=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),t=r):t=r}const c=new RegExp("@define\\s+("+s+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${s} is undefined for import`);const a=new RegExp("(@define\\s+)("+s+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(a,((e,n,r,s)=>`${n}${t}${s}`))+"\n"})),r.trim()}try{await async function(){const t=document.querySelectorAll("style");if(t.length)for(const o of t){let t=o.textContent;t.includes("exec.obj.block(all)")||(t.includes("exec.obj.block(f import)")&&t.includes("exec.obj.block(f import pick)")||(t=await v(t)),t.includes("exec.obj.block(f import)")&&t.includes("exec.obj.block(f import from)")||(t=await k(t)),t.includes("exec.obj.block(f import)")||(t=await j(t)),t.includes("exec.obj.block(vfc)")||(t=t.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,t,s)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&s&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${s})`),t&&!s?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(s?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(s.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${s}`),s?`${n}${s.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),t.includes("exec.obj.block(store:before)")&&t.includes("exec.obj.block(store)")||(t=x(t)),t.includes("exec.obj.block(ext:before)")&&t.includes("exec.obj.block(ext)")||(t=d(t)),t.includes("exec.obj.block(f var)")||(t=function(e){const n={},r=[],t=e.split("\n");let s=!1;const o={};for(let e=0;e<t.length;e++){let c=t[e].trim();if(c.includes("{")){s=!0,r.push(c);continue}if(c.includes("}")){s=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,a=c.match(i);if(a){const[,e,t]=a;s?o[e]=t.trim():(n[e]=t.trim(),r.push(c));continue}const l=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(l,((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}}}(t).css),t.includes("exec.obj.block(fun)")||(t=m(t)),t.includes("exec.obj.block(obj)")||(t=w(t)),t.includes("exec.obj.block(length)")||(t=n(t)),t.includes("exec.obj.block(count)")||(t=e(t)),t.includes("exec.obj.block(define)")||(t=$(t)),t.includes("exec.obj.block(arr)")||(t=g(t)),t.includes("exec.obj.block(event)")||(t=u(t)),t.includes("exec.obj.block(random)")||(t=t.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),t=n.split(",").map((e=>e.trim()));if(0===t.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=t.join(":");s[e]||(s[e]={values:t,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=s[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 t[Math.floor(Math.random()*t.length)]}))),t.includes("exec.obj.block(copy)")||(t=h(t)),t.includes("exec.obj.block(store:after)")&&t.includes("exec.obj.block(store)")||(t=x(t)),t.includes("exec.obj.block(num)")||(t=r(t)),t.includes("exec.obj.block(ext:after)")&&t.includes("exec.obj.block(ext)")||(t=d(t)),t.includes("exec.obj.block(t group)")||(t=b(t)),t.includes("exec.obj.block(length)")||(t=n(t)),t.includes("exec.obj.block(count)")||(t=e(t)),t.includes("exec.obj.block(debug)")||(t=f(t))),t=t.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=t}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"),t=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${t}`)}xfscssProcessorWrap(),applyFscssStyles();
|
package/lib/functions/all.js
CHANGED
|
@@ -18,26 +18,79 @@ function procCntInit(ntc,stc){
|
|
|
18
18
|
})
|
|
19
19
|
return text;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
function parseMath(expr) {
|
|
22
|
+
const str = expr.replace(/\s+/g, '');
|
|
23
|
+
let pos = 0;
|
|
24
|
+
|
|
25
|
+
function parseExpr() {
|
|
26
|
+
let left = parseTerm();
|
|
27
|
+
while (pos < str.length && (str[pos] === '+' || str[pos] === '-')) {
|
|
28
|
+
const op = str[pos++];
|
|
29
|
+
const right = parseTerm();
|
|
30
|
+
left = op === '+' ? left + right : left - right;
|
|
31
|
+
}
|
|
32
|
+
return left;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseTerm() {
|
|
36
|
+
let left = parsePower();
|
|
37
|
+
while (pos < str.length && (str[pos] === '*' || str[pos] === '/')) {
|
|
38
|
+
const op = str[pos++];
|
|
39
|
+
const right = parsePower();
|
|
40
|
+
left = op === '*' ? left * right : left / right;
|
|
41
|
+
}
|
|
42
|
+
return left;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function parsePower() {
|
|
46
|
+
let base = parseUnary();
|
|
47
|
+
if (pos < str.length && str[pos] === '*' && str[pos + 1] === '*') {
|
|
48
|
+
pos += 2;
|
|
49
|
+
const exp = parseUnary(); // right-associative
|
|
50
|
+
return Math.pow(base, exp);
|
|
51
|
+
}
|
|
52
|
+
return base;
|
|
30
53
|
}
|
|
54
|
+
|
|
55
|
+
function parseUnary() {
|
|
56
|
+
if (str[pos] === '-') { pos++; return -parsePrimary(); }
|
|
57
|
+
if (str[pos] === '+') { pos++; return parsePrimary(); }
|
|
58
|
+
return parsePrimary();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function parsePrimary() {
|
|
62
|
+
if (str[pos] === '(') {
|
|
63
|
+
pos++; // skip '('
|
|
64
|
+
const val = parseExpr();
|
|
65
|
+
if (str[pos] !== ')') throw new Error('Missing closing )');
|
|
66
|
+
pos++; // skip ')'
|
|
67
|
+
return val;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const numMatch = str.slice(pos).match(/^[0-9]*\.?[0-9]+/);
|
|
71
|
+
if (!numMatch) throw new Error(`Unexpected token at pos ${pos}: "${str[pos]}"`);
|
|
72
|
+
pos += numMatch[0].length;
|
|
73
|
+
return parseFloat(numMatch[0]);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const result = parseExpr();
|
|
77
|
+
if (pos !== str.length) throw new Error(`Unexpected token: "${str[pos]}"`);
|
|
78
|
+
return result;
|
|
31
79
|
}
|
|
32
80
|
|
|
81
|
+
function procNum(css) {
|
|
82
|
+
const regex = /num\((.*?)\)/g;
|
|
33
83
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
84
|
+
return css.replace(regex, (match, expression) => {
|
|
85
|
+
try {
|
|
86
|
+
return parseMath(expression);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
console.error('Invalid math expression:', expression);
|
|
89
|
+
return expression;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
38
93
|
|
|
39
|
-
return (processedCSS);
|
|
40
|
-
}
|
|
41
94
|
const arraysExfscss = {}; //the global variable
|
|
42
95
|
const orderedxFscssRandom = {};
|
|
43
96
|
|
|
@@ -1286,124 +1339,12 @@ function applyFscssTransformations(css) {
|
|
|
1286
1339
|
.replace(/\$\(([^\:^\)]*)\)/gi, '[$1]');
|
|
1287
1340
|
return css;
|
|
1288
1341
|
}
|
|
1289
|
-
async function impSel(text) {
|
|
1290
|
-
const validImpExt = [".fscss", ".css", ".txt", ".scss", ".less", "xfscss"]
|
|
1291
|
-
const regex = /@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g;
|
|
1292
|
-
const matches = [...text.matchAll(regex)];
|
|
1293
|
-
|
|
1294
|
-
let result = text;
|
|
1295
|
-
|
|
1296
|
-
for (const match of matches) {
|
|
1297
|
-
const [fullMatch, urlSrc, part] = match;
|
|
1298
|
-
try {
|
|
1299
|
-
const impUrl = urlSrc.replace(/["']/g, "");
|
|
1300
|
-
const impExt = impUrl.slice(impUrl.lastIndexOf(".")).toLowerCase();
|
|
1301
|
-
if (impUrl.trim().startsWith("_init") && impUrl.includes(" ")) {
|
|
1302
|
-
console.warn(`fscss[@import] library not found for: ${impUrl}`);
|
|
1303
|
-
return;
|
|
1304
|
-
}
|
|
1305
1342
|
|
|
1306
|
-
if (!validImpExt.includes(impExt)) {
|
|
1307
|
-
console.warn(`fscss[@import] invalid extension for: ${impUrl}`);
|
|
1308
|
-
return;
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1311
|
-
const response = await fetch(impUrl);
|
|
1312
|
-
if (!response.ok) throw new Error(`fscss[@import] HTTP ${response.status} for ${urlSrc}`);
|
|
1313
|
-
const resText = await response.text();
|
|
1314
|
-
const extracted = extractOnlyBlock(resText, part.trim());
|
|
1315
|
-
result = result.replace(fullMatch, extracted);
|
|
1316
|
-
} catch (err) {
|
|
1317
|
-
console.error(`fscss[@import] Failed: ${urlSrc} `, err);
|
|
1318
|
-
result = result.replace(fullMatch, `/* Failed import: ${urlSrc} */`);
|
|
1319
|
-
|
|
1320
|
-
}
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
return result;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
function extractOnlyBlock(cssText, blockName) {
|
|
1327
|
-
const regex = new RegExp(`${blockName}\\s*{[^}]*}`, "g");
|
|
1328
|
-
const match = cssText.match(regex);
|
|
1329
|
-
return match ? match.join("\n") : console.warn(`fscss[@import pick] No block matches: ${blockName} `);
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
const VALID_EXTENSIONS = ['.fscss', '.css', '.txt', '.scss', '.less', '.xfscss'];
|
|
1333
|
-
|
|
1334
|
-
async function processImports(cssText, depth = 0, baseURL = window.location.href) {
|
|
1335
|
-
if (depth > exfMAX_DEPTH) {
|
|
1336
|
-
console.warn('fscss[@import]\n Maximum import depth exceeded. Skipping further imports.');
|
|
1337
|
-
return cssText;
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
const importRegex = /@import\s*\(\s*exec\s*\(\s*((?:'[^']*'|"[^"]*"|[^'")]\S*)\s*)\)\s*\)/g;
|
|
1341
|
-
const matches = Array.from(cssText.matchAll(importRegex));
|
|
1342
|
-
|
|
1343
|
-
if (matches.length === 0) return cssText;
|
|
1344
|
-
|
|
1345
|
-
const fetchedContents = await Promise.all(
|
|
1346
|
-
matches.map(async (match) => {
|
|
1347
|
-
const [fullMatch, urlSpec] = match;
|
|
1348
|
-
try {
|
|
1349
|
-
const cleanUrl = urlSpec.replace(/^['"](.*)['"]$/, '$1').trim();
|
|
1350
|
-
const absoluteUrl = new URL(cleanUrl, baseURL).href;
|
|
1351
|
-
|
|
1352
|
-
// --- New code for extension validation ---
|
|
1353
|
-
const urlPath = new URL(absoluteUrl).pathname;
|
|
1354
|
-
const extension = urlPath.slice(urlPath.lastIndexOf('.')).toLowerCase();
|
|
1355
|
-
|
|
1356
|
-
if (absoluteUrl.trim().startsWith("_init") && absoluteUrl.includes(" ")){
|
|
1357
|
-
console.warn(`fscss[@import] library not found for: ${absoluteUrl}`);
|
|
1358
|
-
return;
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
if (!VALID_EXTENSIONS.includes(extension)) {
|
|
1362
|
-
console.warn(`fscss[@import] \n Invalid import URL extension "${extension}" for "${absoluteUrl}". Only ${VALID_EXTENSIONS.join(', ')} are allowed.`);
|
|
1363
|
-
return `/* Invalid extension for "${absoluteUrl}" */`;
|
|
1364
|
-
}
|
|
1365
|
-
// --- End of new code ---
|
|
1366
|
-
|
|
1367
|
-
const response = await fetch(absoluteUrl);
|
|
1368
|
-
if (!response.ok) throw new Error(`HTTP ${response.status} for ${absoluteUrl}`);
|
|
1369
|
-
|
|
1370
|
-
const importedText = await response.text();
|
|
1371
|
-
return processImports(importedText, depth + 1, absoluteUrl);
|
|
1372
|
-
} catch (error) {
|
|
1373
|
-
console.warn(`fscss[@import]\n Failed to import "${urlSpec}" from "${baseURL}":`, error);
|
|
1374
|
-
return `/* Error importing "${urlSpec}": ${error.message} */`;
|
|
1375
|
-
}
|
|
1376
|
-
})
|
|
1377
|
-
);
|
|
1378
|
-
|
|
1379
|
-
let lastIndex = 0;
|
|
1380
|
-
let result = '';
|
|
1381
|
-
matches.forEach((match, i) => {
|
|
1382
|
-
result += cssText.slice(lastIndex, match.index);
|
|
1383
|
-
result += fetchedContents[i];
|
|
1384
|
-
lastIndex = match.index + match[0].length;
|
|
1385
|
-
});
|
|
1386
|
-
result += cssText.slice(lastIndex);
|
|
1387
|
-
|
|
1388
|
-
return result;
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
async function procImp(css) {
|
|
1392
|
-
try {
|
|
1393
|
-
const processedCSS = await processImports(css);
|
|
1394
|
-
return processedCSS;
|
|
1395
|
-
} catch (error) {
|
|
1396
|
-
console.warn('fscss[]\n Processing failed:', error);
|
|
1397
|
-
console.warn(`fscss[@import] Warning: can't resolve imports`);
|
|
1398
|
-
return css;
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
1343
|
function execObj(css){
|
|
1403
1344
|
return css.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g, "");
|
|
1404
1345
|
}
|
|
1405
1346
|
|
|
1406
1347
|
export { initlibraries,
|
|
1407
|
-
|
|
1348
|
+
replaceRe, procExt, procVar,procFun, procFunObj, procArr, procEv, procRan, transformCssValues, procNum, vfc, applyFscssTransformations,procExC, procCnt, procDef, procChe, execObj
|
|
1408
1349
|
}
|
|
1409
1350
|
|
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.
|
|
4
|
+
"version": "1.1.21",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"bin": {
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"bugs": {
|
|
30
30
|
"url": "https://github.com/Figsh/xfscss/issues"
|
|
31
31
|
},
|
|
32
|
-
"homepage": "https://
|
|
32
|
+
"homepage": "https://fscss.devtem.org",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"dotenv": "^16.0.3",
|
|
35
|
+
"express": "^4.18.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
38
|
+
"chai": "^4.3.4",
|
|
39
|
+
"mocha": "^10.0.0"
|
|
40
40
|
},
|
|
41
41
|
"directories": {
|
|
42
42
|
"lib": "lib"
|
package/xfscss.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
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.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.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={},c=new Set,i=new Set;function a(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 f(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 u(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 i=a(e,c);if(0===i.length||"}"!==i[i.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(s.index,c+i.length);const f=l(i),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+i.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="",a=!1,l=!1;for(const e of t.conditionBlocks)if("el"===e.type&&(l&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),l=!0),!a||"el"===e.type){if("el"===e.type){if(a)continue;a=!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}'.`),a=!0):a=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),a=isNaN(t)?t:Number(t);switch(s){case"==":return i==a;case"!=":return i!=a;case">":return i>a;case"<":return i<a;case">=":return i>=a;case"<=":return i<=a;default:return!1}}}))}if(a){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&&!a?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 p(e){return(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 $(e){const n=/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g;let r=e.replace(n,((e,n,r,s,t,c,i)=>{const a=r.split(",").map((e=>e.trim())).filter((e=>e)),l=s??t??c??i??"";return o[n]={params:a,body:l},""}));return r=r.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const s=o[n];if(!s)return e;const t=r?.split(",").map((e=>e.trim()));""===t[0]&&(t[0]=void 0);let c=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 o=i[1]?i[1]:"",a=void 0!==t[n]?t[n]:o,l=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");c=c.replace(l,a)})),c})),n.test(r)?$(r):r}function d(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 g(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 m(e){const n={},r=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;function s(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}let t;for(;null!==(t=r.exec(e));){const e=t[1],r=t[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:s(r)}}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(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function w(e){const n={},r=/@obj\s+([\w\-\_\—0-9]+)\s*\{([\s\S]*?)\}\s*/g;function s(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[@obj] 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[@obj] Empty property name in line: "${e}"`)}return n}let t;for(;null!==(t=r.exec(e));){const e=t[1],r=t[2].trim();n[e]&&console.warn(`fscss[@obj] Duplicate @obj variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:s(r)}}let o=e;return o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?n[r].props[s]:(console.warn(`fscss[@obj] Value extraction failed for "@obj.${r}.${s}.value". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,s)=>n[r]&&n[r].props[s]?`${s}: ${n[r].props[s]};`:(console.warn(`fscss[@obj] Single property rule failed for "@obj.${r}.${s}". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@obj] Full variable block replacement failed for "@obj.${r}". Variable not found.`),e))),o=o.replace(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function h(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,s,t,o,c,i)=>{const a=parseInt(c),l=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=a>=0?t.substring(0,a):t.substring(t.length+a),n.add(`--${l}:${f};`),`${r}${s}${t}${o}`}));return n.size>0?r+`\n:root{${Array.from(n).join("\n")}\n}`:r}function x(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,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 b(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.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 v(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g,s=[...(e=await p(e)).matchAll(r)];let t=e,o=null;for(const r of s){const[s,c,a]=r;if(o=c,i.has(o)){const e=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("@import\\(exec\\(("+e+")\\)\\s*\\.\\s*(?:pick|find)\\(([^)]+)\\)\\)","g");t=t.replace(n,`/* Can't import ${o} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${o} multiple times at `)}try{const e=c.replace(/["']/g,""),r=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(r))return void console.warn(`fscss[@import] invalid extension for: ${e}`);const o=await fetch(e);if(!o.ok)throw new Error(`fscss[@import] HTTP ${o.status} for ${c}`);const i=S(await o.text(),a.trim());t=t.replace(s,i)}catch(e){console.error(`fscss[@import] Failed: ${c} `,e),t=t.replace(s,`/* Failed import: ${c} */`)}}return t.match(r)?(i.add(o),v(t)):t}function S(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 y=new Set;async function j(e){const n=/\@import\((?:\s+)?exec\((?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`|([^\)]+)(?:\s+)?)\)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let s=e,t=null;for(const n of r){let[r,o,c,i,a]=n;const l=(o||c||i||a).trim();if(t=l,y.has(t)){const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?exec\\((?:\\s+)?(?:"('+e+")\"|'("+e+")'|`("+e+")`|("+e+")(?:\\s+)?)\\)(?:\\s+)?\\)","g");s=s.replace(n,`/* Can't import ${t} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${t} multiple times at `)}try{const e=await fetch(l);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${l}`);const n=await e.text();s=s.replace(r,n)}catch(e){console.error(`fscss[@import] Failed: ${l} `,e),s=s.replace(r,`/* Failed import: ${l} */`)}}return s.match(n)?(y.add(t),j(s)):s}async function k(e){const n=/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let s=e,t=null;for(const n of r){let[r,o,i,a,l]=n;o=o.trim();const f=(i||a||l).trim();if(t=f,c.has(t)){const e=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?(?:exec)?\\(([\\w\\d\\.\\@\\—\\-_*\\#\\$\\s\\,]+)\\)(?:\\s+)?from(?:\\s+)?(?:"((?:\\s+)?'+e+"(?:\\s+)?)\"|'((?:\\s+)?"+e+"(?:\\s+)?)'|`((?:\\s+)?"+e+"(?:\\s+)?)`)(?:\\s+)?\\)","g");s=s.replace(n,`/* Can't import ${t} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${t} multiple times at `)}try{const e=await fetch(f);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${f}`);const n=await e.text();if("*"===o&&(s=s.replace(r,n)),"*"!==o&&o.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${r}: unexpected *`),s=s.replace(r,"/* syntax error: unexpected * */")),"*"!==o&&!o.includes("*")){const e=_(n,o.split(",").map((e=>e.trim())));s=s.replace(r,e)}}catch(e){console.error(`fscss[@import] Failed: ${f} `,e),s=s.replace(r,`/* Failed import: ${f} */`)}}return s.match(n)?(c.add(t),k(s)):s}function _(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 a=new RegExp("(@define\\s+)("+t+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(a,((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(f import)")&&s.includes("exec.obj.block(f import pick)")||(s=await v(s)),s.includes("exec.obj.block(f import)")&&s.includes("exec.obj.block(f import from)")||(s=await k(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=x(s)),s.includes("exec.obj.block(ext:before)")&&s.includes("exec.obj.block(ext)")||(s=d(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*([^;]+);/,a=c.match(i);if(a){const[,e,s]=a;t?o[e]=s.trim():(n[e]=s.trim(),r.push(c));continue}const l=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(l,((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=m(s)),s.includes("exec.obj.block(obj)")||(s=w(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=$(s)),s.includes("exec.obj.block(arr)")||(s=g(s)),s.includes("exec.obj.block(event)")||(s=u(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=h(s)),s.includes("exec.obj.block(store:after)")&&s.includes("exec.obj.block(store)")||(s=x(s)),s.includes("exec.obj.block(num)")||(s=r(s)),s.includes("exec.obj.block(ext:after)")&&s.includes("exec.obj.block(ext)")||(s=d(s)),s.includes("exec.obj.block(t group)")||(s=b(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=f(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();
|
|
2
|
+
export function exec({type:e="text",content:n,onError:r,onSuccess:t}){if(!n){const e="No CSS content or URL provided.";return console.error(`[FSCSS] ${e}`),void(r&&r(e))}const s=document.createElement("style"),o=e=>{s.textContent=e,document.head.appendChild(s),t&&t(s),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 t=`Failed to load CSS from: ${n}. ${e.message}`;console.error(`[FSCSS] ${t}`),r&&r(t)}));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),t=parseInt(n),s=parseInt(r||1),`${Array(t).fill().map(((e,n)=>(n+1)*s))}`;var t,s}))}function n(e){return e=e.replace(/length\((?:([^\)]+)|\s*"([^"]*)"\s*|\s*'([^']*)'\s*)\)/g,((e,n,r,t)=>(n||r||t).length))}function r(e){return e.replace(/num\((.*?)\)/g,((e,n)=>{try{return function(e){const n=e.replace(/\s+/g,"");let r=0;function t(){let e=s();for(;r<n.length&&("+"===n[r]||"-"===n[r]);){const t=n[r++],o=s();e="+"===t?e+o:e-o}return e}function s(){let e=o();for(;r<n.length&&("*"===n[r]||"/"===n[r]);){const t=n[r++],s=o();e="*"===t?e*s:e/s}return e}function o(){let e=c();if(r<n.length&&"*"===n[r]&&"*"===n[r+1]){r+=2;const n=c();return Math.pow(e,n)}return e}function c(){return"-"===n[r]?(r++,-i()):"+"===n[r]?(r++,i()):i()}function i(){if("("===n[r]){r++;const e=t();if(")"!==n[r])throw new Error("Missing closing )");return r++,e}const e=n.slice(r).match(/^[0-9]*\.?[0-9]+/);if(!e)throw new Error(`Unexpected token at pos ${r}: "${n[r]}"`);return r+=e[0].length,parseFloat(e[0])}const a=t();if(r!==n.length)throw new Error(`Unexpected token: "${n[r]}"`);return a}(n)}catch(e){return console.error("Invalid math expression:",n),n}}))}const t={},s={},o={},c=new Set,i=new Set;function a(e,n){let r=0,t=n;for(;t<e.length&&("{"===e[t]?r++:"}"===e[t]&&r--,0!==r);)t++;return e.slice(n,t+1)}function l(e){const n=[],r=/(if|el-if|el)\s*([^{}]*?)\s*\{([\s\S]*?)\}/g;let t;for(;null!==(t=r.exec(e));)n.push({type:t[1],condition:t[2].trim(),block:t[3].trim()});return n}function f(e){let n="";const r=e.replace(/exec\((_log|_error|_warn|_info),\s*(?:"([^"]*)"|'([^']*)'|([^)]*))\)/g,((e,r,t,s,o)=>{const c=t||s||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 u(e){const n={},r=/@event\s+([\w-]+)\(([^)]*)\)\s*:?{/g;let t,s=e;const o=[];for(;null!==(t=r.exec(e));){const r=t[1],s=t[2],c=t.index+t[0].length-1;if(c>=e.length){console.warn(`fscss[parsing] Warning: Unexpected end of CSS after @event ${r} definition.`);continue}const i=a(e,c);if(0===i.length||"}"!==i[i.length-1]){console.warn(`fscss[parsing] Warning: Malformed block for @event '${r}'. Missing closing '}'.`);continue}e.slice(t.index,c+i.length);const f=l(i),u=s.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([t.index,c+i.length])}for(let e=o.length-1;e>=0;e--){const[n,r]=o[e];s=s.slice(0,n)+s.slice(r)}return s=s.replace(/@event\.([\w-]+)\(([^)]*)\)/g,((e,r,t)=>{const s=n[r];if(!s)return console.warn(`fscss[call] Warning: @event function '${r}' not found during call.`),e;const o={},c=t.split(",").map((e=>e.trim())).filter((e=>""!==e));c.length!==s.args.length&&console.warn(`fscss[call] Warning: Argument count mismatch for @event '${r}'. Expected ${s.args.length}, got ${c.length}.`),s.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="",a=!1,l=!1;for(const e of s.conditionBlocks)if("el"===e.type&&(l&&console.warn(`fscss[logic] Warning: Multiple 'el' (else) blocks found in @event '${r}'. Only the first 'el' block will be considered.`),l=!0),!a||"el"===e.type){if("el"===e.type){if(a)continue;a=!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}'.`),a=!0):a=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[t,s]=n;return t in o?o[t]===s:(console.warn(`fscss[logic] Warning: Condition variable '${t}' not provided in @event '${r}' context. Treating as false.`),!1)}{const[,e,t,s]=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),a=isNaN(s)?s:Number(s);switch(t){case"==":return i==a;case"!=":return i!=a;case">":return i>a;case"<":return i<a;case">=":return i>=a;case"<=":return i<=a;default:return!1}}}))}if(a){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&&s.conditionBlocks.length>0&&!a?console.warn(`fscss[call] Warning: No condition matched for @event '${r}' with provided arguments. Returning original call string.`):i||0!==s.conditionBlocks.length||console.warn(`fscss[definition] Warning: @event '${r}' has no condition blocks defined. Returning original call string.`),i||e})),s.trim()}async function p(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,t)=>t?`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.${t}')`:`${n}'https://cdn.jsdelivr.net/gh/fscss-ttr/FSCSS@main/xf/styles/${r}.fscss')`))}function $(e){const n=/@define\s+([\w\_\-\—]+)\s*\(([^)]*)\)\s*\$?\{\s*(?:"([^"]*)"|'([^']*)'|`([^`]*)`|([^\}^\{]*?))\s*\}/g;let r=e.replace(n,((e,n,r,t,s,c,i)=>{const a=r.split(",").map((e=>e.trim())).filter((e=>e)),l=t??s??c??i??"";return o[n]={params:a,body:l},""}));return r=r.replace(/@([\w\_\-\—]+)\s*\(([\s\S]*?)\)/g,((e,n,r)=>{const t=o[n];if(!t)return e;const s=r?.split(",").map((e=>e.trim()));""===s[0]&&(s[0]=void 0);let c=t.body,i=[];return t.params.forEach(((e,n)=>{const r=t.params[n];r&&r.includes(":")&&(i=r?.split(":")?.map((e=>e.trim())).filter((e=>e)));const o=i[1]?i[1]:"",a=void 0!==s[n]?s[n]:o,l=new RegExp(`@use\\(\\s*${e.replace(/(\s+)?(\:(\s+)?.*)/g,"")}\\s*\\)`,"g");c=c.replace(l,a)})),c})),n.test(r)?$(r):r}function d(e){let n={},r=e;return r=r.replace(/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')/g,(function(e){let r=e[0],t=e.slice(1,-1);const s=/@ext\((-?\d+),(\d+):\s*([^)]+)\)/g;let o,c=[];for(;null!==(o=s.exec(t));)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],s=r.start<0?t.length+r.start:r.start;s=Math.max(0,s);let o=t.substring(s,s+r.length);(s+r.length>t.length||s<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,t=t.slice(0,r.index)+t.slice(r.index+r.fullMatch.length)}return r+t+r})),r=r.replace(/([#.\w-]+)\s*@ext\((-?\d+),(\d+):\s*([^)]+)\)/g,(function(e,r,t,s,o){t=parseInt(t),s=parseInt(s),o=o.trim();let c=t<0?r.length+t:t;c=Math.max(0,c);let i=r.substring(c,c+s);return(c+s>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 g(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()));t[e]=n}let s=e;return s=s.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\+\s*\[([^\]]+)?\])/g,((e,n,r)=>t[n]?r?(newItems=r.split(",").map((e=>e.trim())),t[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))),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:\!\s*\-\s*\[([\d\w\-_—\s]+)?\])/g,((e,n,r)=>{const s=t[n];return s?!(r=Number(r?.trim()))||r<1||!Number(r)?(console.warn(`[FSCSS Warning] @arr splice failed → Invalid or empty index at "${e}"`),e):r>s.length?(console.warn(`[FSCSS Warning] @arr → @arr.${n}[${r}] is undefined at "${e}"`),""):(r-=1,s.splice(r,1),""):(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),s=s.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 s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e;if(r){if("length"===r)return s.length;if("first"===r)return s[0];if("last"===r)return s.at(-1);if("indices"===r)return Array(s.length).fill().map(((e,n)=>1*(n+1)));if("list"===r)return s.join(",");if("reverse"===r)return s.toReversed().join(",");if("randint"===r)return s[Math.floor(Math.random()*s.length)];if("segment"===r)return s.map((e=>`[${e}]`)).join("");if("unique"===r)return[...new Set(s)].join(",");if("sort"===r)return s.slice().sort().join(",");if("shuffle"===r)return s.slice().sort((()=>Math.random()-.5)).join(",");if("sum"===r)return s.reduce(((e,n)=>e+Number(n)),0);if("min"===r)return Math.min(...s.map(Number));if("max"===r)return Math.max(...s.map(Number))}})),s=s.replace(/([^\{\}]+)\{\s*([^}]*@arr\.([\w\-_—0-9]+)\[\][^}]*)\s*\}/g,((e,n,r,s)=>{const o=t[s];return o?o.map(((e,t)=>{const o=n.replace(new RegExp(`@arr\\.${s}\\[\\]`,"g"),t+1),c=r.replace(new RegExp(`@arr\\.${s}\\[\\]`,"g"),e);return`${o.trim()} {\n ${c.trim()}\n}`})).join("\n"):(console.warn(`fscss[@arr] Warning: Array '${s}' not found for loop processing.`),e)})),s=s.replace(/@arr\.([\w\-_—0-9]+)\[(\d+)\]/g,((e,n,r)=>{const s=parseInt(r)-1,o=t[n];return o?void 0!==o[s]?o[s]:e:(console.warn(`fscss[@arr] Warning: Array '${n}' not found.`),e)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.unit)(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.map((e=>`${e+o}`)).join(",")})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.prefix)(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.map((e=>`${o+e}`)).join(",")})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.surround)(?:\(([^)]+)\))/g,((e,n,r)=>{const s=t[n];return s?r&&void 0!==r&&""!==r&&r.includes(",")?(surArr=r.split(","),s.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)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(?:!\s*\.join)?(?:\(([^)]*)\))/g,((e,n,r)=>{const s=t[n];if(!s)return console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e;const o=void 0!==r&&""!==r?r:" ";return s.join(o)})),s=s.replace(/@arr\.([\w\-_—0-9]+)(!)?/g,((e,n,r)=>{const s=t[n];return s?r?e:`[${s.join(",")}]`:(console.warn(`fscss[@arr] Warning: Array '${n}' not found for direct access.`),e)})),s.replace(n,"").replace(/\n{3,}/g,"\n\n").trim()}function m(e){const n={},r=/@fun\(([\w\-\_\—0-9]+)\)\s*\{([\s\S]*?)\}\s*/g;function t(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 t=e.substring(0,r).trim(),s=e.substring(r+1).trim();t?n[t]=s:console.warn(`fscss[@fun] Empty property name in line: "${e}"`)}return n}let s;for(;null!==(s=r.exec(e));){const e=s[1],r=s[2].trim();n[e]&&console.warn(`fscss[@fun] Duplicate @fun variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:t(r)}}let o=e;return o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?n[r].props[t]:(console.warn(`fscss[@fun] Value extraction failed for "@fun.${r}.${t}.value". Variable or property not found.`),e))),o=o.replace(/@fun\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?`${t}: ${n[r].props[t]};`:(console.warn(`fscss[@fun] Single property rule failed for "@fun.${r}.${t}". 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(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function w(e){const n={},r=/@obj\s+([\w\-\_\—0-9]+)\s*\{([\s\S]*?)\}\s*/g;function t(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[@obj] Invalid style line (missing colon): "${e}"`);continue}const t=e.substring(0,r).trim(),s=e.substring(r+1).trim();t?n[t]=s:console.warn(`fscss[@obj] Empty property name in line: "${e}"`)}return n}let s;for(;null!==(s=r.exec(e));){const e=s[1],r=s[2].trim();n[e]&&console.warn(`fscss[@obj] Duplicate @obj variable declaration: "${e}". The last one will overwrite previous declarations.`),n[e]={raw:r,props:t(r)}}let o=e;return o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\.value\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?n[r].props[t]:(console.warn(`fscss[@obj] Value extraction failed for "@obj.${r}.${t}.value". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)\.([\w\-\_\—0-9]+)\!?/g,((e,r,t)=>n[r]&&n[r].props[t]?`${t}: ${n[r].props[t]};`:(console.warn(`fscss[@obj] Single property rule failed for "@obj.${r}.${t}". Variable or property not found.`),e))),o=o.replace(/@obj\.([\w\-\_\—0-9]+)(?=[\s;}])\!?/g,((e,r)=>n[r]?n[r].raw:(console.warn(`[@obj] Full variable block replacement failed for "@obj.${r}". Variable not found.`),e))),o=o.replace(r,""),o=o.replace(/^\s*[\r\n]/gm,""),o=o.trim(),o}function h(e){const n=new Set,r=e.replace(/(:\s*)(["']?)(.*?)(["']?)\s*copy\(([-]?\d+),\s*([^\;^\)^\(^,^ ]*)\)/g,((e,r,t,s,o,c,i)=>{const a=parseInt(c),l=i.replace(/[^a-zA-Z0-9_-]/g,"");let f="";return f=a>=0?s.substring(0,a):s.substring(s.length+a),n.add(`--${l}:${f};`),`${r}${t}${s}${o}`}));if(n.size>0){return r+`\n${`:root{${Array.from(n).join("\n")}\n}`}`}return r}function x(e){const n=new Map;let r,t=e.replace(/(?:store|str|re)\(\s*([^:,]+)\s*[,:]\s*(?:"([^"]*)"|'([^']*)')\s*\)/gi,((e,r,t,s)=>{const o=t||s;return r=r.trim(),n.set(r,o),""}));if(0===n.size)return t;let s=0;let o=t;do{r=!1;for(const[e,t]of n.entries()){const n=new RegExp(`\\b${c=e,c.replace(/[.*+?^${}|[\]\\]/g,"\\$&")}\\b`,"g"),s=o.replace(n,t);s!==o&&(r=!0,o=s)}s++}while(r&&s<100);var c;return s>=100&&console.warn("Maximum iterations reached. Possible circular dependency."),o}function b(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,t)=>{const s=r.split(",").map((e=>e.trim()));return s.length!=n?(console.warn(`Number of properties ${s.length} does not match %${n}`),e):s.map((e=>`${e}${t}`)).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 v(e){const n=[".fscss",".css",".txt",".scss",".less","xfscss"],r=/@import\(exec\(([^)]+)\)\s*\.\s*(?:pick|find)\(([^)]+)\)\)/g,t=[...(e=await p(e)).matchAll(r)];let s=e,o=null;for(const e of t){const[r,t,c]=e;if(o=t,i.has(o)){const e=o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("@import\\(exec\\(("+e+")\\)\\s*\\.\\s*(?:pick|find)\\(([^)]+)\\)\\)","g");s=s.replace(n,`/* Can't import ${o} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${o} multiple times at `)}try{const e=t.replace(/["']/g,""),o=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(o))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 a=S(await i.text(),c.trim());s=s.replace(r,a)}catch(e){console.error(`fscss[@import] Failed: ${t} `,e),s=s.replace(r,`/* Failed import: ${t} */`)}}return s.match(r)?(i.add(o),v(s)):s}function S(e,n){const r=new RegExp(`${n}\\s*{[^}]*}`,"g"),t=e.match(r);return t?t.join("\n"):console.warn(`fscss[@import pick] No block matches: ${n} `)}const y=new Set;async function j(e){const n=/\@import\((?:\s+)?exec\((?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`|([^\)]+)(?:\s+)?)\)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let t=e,s=null;for(const e of r){let[n,r,o,c,i]=e;const a=(r||o||c||i).trim();if(s=a,y.has(s)){const e=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?exec\\((?:\\s+)?(?:"('+e+")\"|'("+e+")'|`("+e+")`|("+e+")(?:\\s+)?)\\)(?:\\s+)?\\)","g");t=t.replace(n,`/* Can't import ${s} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${s} multiple times at `)}try{const e=await fetch(a);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${a}`);const r=await e.text();t=t.replace(n,r)}catch(e){console.error(`fscss[@import] Failed: ${a} `,e),t=t.replace(n,`/* Failed import: ${a} */`)}}return t.match(n)?(y.add(s),j(t)):t}async function k(e){const n=/\@import\((?:\s+)?(?:exec)?\(([\w\d\.\@\—\-_*\#\$\s\,]+)\)(?:\s+)?from(?:\s+)?(?:"([^"]+)"|'([^']+)'|`([^`]+)`)(?:\s+)?\)/g,r=[...(e=await p(e)).matchAll(n)];let t=e,s=null;for(const e of r){let[n,r,o,i,a]=e;r=r.trim();const l=(o||i||a).trim();if(s=l,c.has(s)){const e=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp('\\@import\\((?:\\s+)?(?:exec)?\\(([\\w\\d\\.\\@\\—\\-_*\\#\\$\\s\\,]+)\\)(?:\\s+)?from(?:\\s+)?(?:"((?:\\s+)?'+e+"(?:\\s+)?)\"|'((?:\\s+)?"+e+"(?:\\s+)?)'|`((?:\\s+)?"+e+"(?:\\s+)?)`)(?:\\s+)?\\)","g");t=t.replace(n,`/* Can't import ${s} multiple times */`),console.warn(`[FSCSS Warning] Can't import ${s} multiple times at `)}try{const e=await fetch(l);if(!e.ok)throw new Error(`fscss[@import] HTTP ${e.status} for ${l}`);const s=await e.text();if("*"===r&&(t=t.replace(n,s)),"*"!==r&&r.includes("*")&&(console.warn(`[FSCSS Warning] syntax error at ${n}: unexpected *`),t=t.replace(n,"/* syntax error: unexpected * */")),"*"!==r&&!r.includes("*")){const e=_(s,r.split(",").map((e=>e.trim())));t=t.replace(n,e)}}catch(e){console.error(`fscss[@import] Failed: ${l} `,e),t=t.replace(n,`/* Failed import: ${l} */`)}}return t.match(n)?(c.add(s),k(t)):t}function _(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 t="",s=n;const o=n.trim().match(/([^\s]+)(?:\s+as\s+([^\s]+))?/);if(o){const[e,r,c]=o;s=r,c?t=c:n.includes(" as")?(console.warn(`[FSCSS Warning] Can't assign @${r} to invalid or empty value`),t=r):t=r}const c=new RegExp("@define\\s+("+s+")\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\}","g"),i=e.match(c);if(!i)return console.warn(`[FSCSS Warning] @${s} is undefined for import`);const a=new RegExp("(@define\\s+)("+s+")(\\s*\\(([^)]*)\\)\\s*\\$?\\{\\s*(?:\"([^\"]*)\"|'([^']*)'|`([^`]*)`|([^\\}^\\{]*?))\\s*\\})","g");r+=i.join("\n").replace(a,((e,n,r,s)=>`${n}${t}${s}`))+"\n"})),r.trim()}try{await async function(){const t=document.querySelectorAll("style");if(t.length)for(const o of t){let t=o.textContent;t.includes("exec.obj.block(all)")||(t.includes("exec.obj.block(f import)")&&t.includes("exec.obj.block(f import pick)")||(t=await v(t)),t.includes("exec.obj.block(f import)")&&t.includes("exec.obj.block(f import from)")||(t=await k(t)),t.includes("exec.obj.block(f import)")||(t=await j(t)),t.includes("exec.obj.block(vfc)")||(t=t.replace(/([\w-]+:\s*)(\$\/?[\w-]+!?)(\s*\|\|\s*([^\n\};]+))?/g,((e,n,r,t,s)=>/^\$\/[\w-]+!?$/.test(r)?(r.endsWith("!")&&s&&console.warn(`fscss[VFC]: Required variable "${r}" should not have fallback (${s})`),t&&!s?.trim()?(console.warn(`fscss[VFC]: Empty fallback in -> ${e}`),e):(s?.includes("$/")&&!/^\$\/[\w-]+!?$/.test(s.trim())&&console.warn(`fscss[VFC]: Invalid fallback variable syntax -> ${s}`),s?`${n}${s.trim()};${n}${r}`:`${n}${r}`)):(console.warn(`fscss[VFC]: Invalid variable escape syntax -> ${r} at ${e}`),e)))),t.includes("exec.obj.block(store:before)")&&t.includes("exec.obj.block(store)")||(t=x(t)),t.includes("exec.obj.block(ext:before)")&&t.includes("exec.obj.block(ext)")||(t=d(t)),t.includes("exec.obj.block(f var)")||(t=function(e){const n={},r=[],t=e.split("\n");let s=!1;const o={};for(let e=0;e<t.length;e++){let c=t[e].trim();if(c.includes("{")){s=!0,r.push(c);continue}if(c.includes("}")){s=!1;for(const e in o)delete o[e];r.push(c);continue}const i=/^\s*\$([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/,a=c.match(i);if(a){const[,e,t]=a;s?o[e]=t.trim():(n[e]=t.trim(),r.push(c));continue}const l=/\$\/?([a-zA-Z0-9_-]+)(!)?/g;c=c.replace(l,((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}}}(t).css),t.includes("exec.obj.block(fun)")||(t=m(t)),t.includes("exec.obj.block(obj)")||(t=w(t)),t.includes("exec.obj.block(length)")||(t=n(t)),t.includes("exec.obj.block(count)")||(t=e(t)),t.includes("exec.obj.block(define)")||(t=$(t)),t.includes("exec.obj.block(arr)")||(t=g(t)),t.includes("exec.obj.block(event)")||(t=u(t)),t.includes("exec.obj.block(random)")||(t=t.replace(/@random\(\[([^\]]+)\](?:, *ordered)?\)/g,((e,n)=>{const r=/, *ordered\)/.test(e),t=n.split(",").map((e=>e.trim()));if(0===t.length)return console.warn("fscss[@random] Warning: Empty array provided for @random. Returning empty string."),"";if(r){const e=t.join(":");s[e]||(s[e]={values:t,index:0},console.warn(`fscss[@random] Warning: New ordered sequence created for [${n}].`));const r=s[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 t[Math.floor(Math.random()*t.length)]}))),t.includes("exec.obj.block(copy)")||(t=h(t)),t.includes("exec.obj.block(store:after)")&&t.includes("exec.obj.block(store)")||(t=x(t)),t.includes("exec.obj.block(num)")||(t=r(t)),t.includes("exec.obj.block(ext:after)")&&t.includes("exec.obj.block(ext)")||(t=d(t)),t.includes("exec.obj.block(t group)")||(t=b(t)),t.includes("exec.obj.block(length)")||(t=n(t)),t.includes("exec.obj.block(count)")||(t=e(t)),t.includes("exec.obj.block(debug)")||(t=f(t))),t=t.replace(/exec\.obj\.block\([^\)\n]*\)\;?/g,""),o.innerHTML=t}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"),t=n.replace(/\s*->\s*/g,"/").replace(/\n/g,"");loadFScript(`https://cdn.jsdelivr.net/${r}/${t}`)}xfscssProcessorWrap(),applyFscssStyles();
|