@aperturesyndicate/synx-format 3.6.0 → 3.6.1

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.
@@ -1,28 +1,28 @@
1
- var et=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(n,s)=>(typeof require<"u"?require:n)[s]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});function F(t){if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;let n=t.length;if(n===0)return t;let s=t.charCodeAt(0);if(s===40&&n>2){let u=t.indexOf(")");if(u>1){let l=t.substring(1,u),e=t.substring(u+1);switch(l){case"int":{let p=parseInt(e,10);return isNaN(p)?0:p}case"float":{let p=parseFloat(e);return isNaN(p)?0:p}case"bool":return e.trim()==="true";case"string":return e;case"random":return Math.floor(Math.random()*2147483647);case"random:int":return Math.floor(Math.random()*2147483647);case"random:float":return Math.random();case"random:bool":return Math.random()<.5}}}let r=0,c=s;if(c===45){if(n===1)return t;r=1,c=t.charCodeAt(1)}if(c>=48&&c<=57){let u=!0,l=-1;for(let e=r+1;e<n;e++){let p=t.charCodeAt(e);if(p===46){if(l!==-1){u=!1;break}l=e}else if(p<48||p>57){u=!1;break}}if(u){if(l===-1)return parseInt(t,10);if(l>r&&l<n-1)return parseFloat(t)}}return t}function X(t){if(t.indexOf(" ")===-1)return t;let n=t,s=n.indexOf(" //");s!==-1&&(n=n.substring(0,s));let r=n.indexOf(" #");return r!==-1&&(n=n.substring(0,r)),n.trimEnd()}function pt(t){let n={},s=0;for(;s<t.length;){let r=t.indexOf(",",s);r===-1&&(r=t.length);let c=t.substring(s,r).trim();if(s=r+1,!!c)if(c==="required")n.required=!0;else if(c==="readonly")n.readonly=!0;else{let u=c.indexOf(":");if(u!==-1){let l=c.substring(0,u).trim(),e=c.substring(u+1).trim();switch(l){case"min":n.min=Number(e);break;case"max":n.max=Number(e);break;case"type":n.type=e;break;case"pattern":n.pattern=e;break;case"enum":n.enum=e.split("|");break}}}}return n}function U(t,n,s,r,c,u,l){if(u!=="active"||s.length===0&&!c&&!l)return;let e;t.__synx?e=t.__synx:(e={},Object.defineProperty(t,"__synx",{value:e,enumerable:!1,writable:!0,configurable:!0}));let p={markers:s};r.length>0&&(p.args=r),c&&(p.constraints=c),l&&(p.typeHint=l),e[n]=p}var nt=/^([^\s\[:\-#/(][^\s\[:(]*)(?:\(([\w:]+)\))?(?:\[([^\]]*)\])?(?::([^\s]+))?\s*(.*)$/;function R(t){let n=t.split(`
2
- `),s={},r=[{indent:-1,obj:s}],c="static",u=!1,l=[],e=null,p=null,o=!1;for(let O=0;O<n.length;O++){let a=n[O],f=a.length,i=0;for(;i<f;){let y=a.charCodeAt(i);if(y!==32&&y!==9&&y!==13)break;i++}if(i===f)continue;let d=a.charCodeAt(i);if(d===35&&a.substring(i).trimEnd()==="###"){o=!o;continue}if(o)continue;if(d===35){f-i>7&&a.charCodeAt(i+1)===33&&a.substring(i,i+7)==="#!mode:"&&(c=a.substring(i+7,f).trim()==="active"?"active":"static");continue}if(d===47&&i+1<f&&a.charCodeAt(i+1)===47)continue;let g=f;for(;g>i;){let y=a.charCodeAt(g-1);if(y!==32&&y!==9&&y!==13&&y!==10)break;g--}let h=a.substring(i,g),A=h.length;if(d===33){if(h==="!active"){c="active";continue}if(h==="!lock"){u=!0;continue}if(h.startsWith("!include ")){let y=h.substring(9).trim().split(/\s+/),m=y[0],x=y[1]||m.replace(/^.*[\/\\]/,"").replace(/\.synx$/i,"");l.push({path:m,alias:x});continue}}if(e&&i>e.indent){let y=h;e.obj[e.key]+=(e.obj[e.key]?`
3
- `:"")+y;continue}else e=null;if(d===45&&A>1&&h.charCodeAt(1)===32){if(p&&i>p.indent){let y=X(h.substring(2).trim()),m=O+1;for(;m<n.length;){let x=n[m],$=0;for(;$<x.length&&(x.charCodeAt($)===32||x.charCodeAt($)===9||x.charCodeAt($)===13);)$++;if($<x.length)break;m++}if(m<n.length){let x=n[m],$=0;for(;$<x.length&&(x.charCodeAt($)===32||x.charCodeAt($)===9||x.charCodeAt($)===13);)$++;let z=x.charCodeAt($);if($>i&&$<x.length&&z!==45&&z!==35&&!(z===47&&$+1<x.length&&x.charCodeAt($+1)===47)){let V={},j=y.match(nt);if(j){let[,ft,tt,,,dt]=j,L=dt||"";tt&&(L=`(${tt})${L}`),V[ft]=L?F(X(L)):{}}else V._value=F(y);p.arr.push(V),r.push({indent:i,obj:V});continue}}p.arr.push(F(y));continue}continue}if(p&&i<=p.indent&&(p=null),d===91||d===40||d===58||d===47)continue;let S,N,I,P,w,Q=!1,T=-1;for(let y=0;y<A;y++){let m=h.charCodeAt(y);if(m===32||m===9){T=y;break}if(m===40||m===91||m===58){Q=!0;break}}if(Q){let y=h.match(nt);if(!y)continue;[,S,N,I,P,w]=y,w=w?X(w.trim()):""}else{if(T===-1)S=h,w="";else{S=h.substring(0,T);let y=T;for(;y<A&&(h.charCodeAt(y)===32||h.charCodeAt(y)===9);)y++;w=y<A?X(h.substring(y)):""}N=void 0,I=void 0,P=void 0}N&&(w=`(${N})${w}`);let E=[],v=[];if(P&&(E=P.split(":")),E.length>0&&E.includes("random")&&w){let y=w.split(/\s+/).filter(m=>/^\d+(\.\d+)?$/.test(m));y.length>0&&(v=y,w="")}let D=I?pt(I):void 0;for(;r.length>1&&r[r.length-1].indent>=i;)r.pop();let C=r[r.length-1].obj;if(!(S==="__proto__"||S==="constructor"||S==="prototype"))if(w==="|")C[S]="",e={indent:i,obj:C,key:S},U(C,S,E,v,D,c,N);else if(!w&&E.length>0&&(E.includes("random")||E.includes("unique")||E.includes("geo")||E.includes("join")))C[S]=[],p={indent:i,arr:C[S]},U(C,S,E,v,D,c,N);else if(w)C[S]=F(w),U(C,S,E,v,D,c,N);else{C[S]={},r.push({indent:i,obj:C[S]});let y=O+1;for(;y<n.length;){let m=n[y],x=0;for(;x<m.length&&(m.charCodeAt(x)===32||m.charCodeAt(x)===9||m.charCodeAt(x)===13);)x++;if(x<m.length)break;y++}if(y<n.length){let m=n[y],x=0;for(;x<m.length&&(m.charCodeAt(x)===32||m.charCodeAt(x)===9||m.charCodeAt(x)===13);)x++;x+1<m.length&&m.charCodeAt(x)===45&&m.charCodeAt(x+1)===32&&(C[S]=[],r[r.length-1]={indent:i,obj:C[S]},p={indent:i,arr:C[S]})}U(C,S,E,v,D,c,N)}}return{root:s,mode:c,locked:u,includes:l.length>0?l:void 0}}function yt(t){let n=[],s=0;for(;s<t.length;){let r=t[s];if(r===" "||r===" "){s++;continue}if(r>="0"&&r<="9"||r==="."&&s+1<t.length&&t[s+1]>="0"&&t[s+1]<="9"||r==="-"&&(n.length===0||n[n.length-1].type==="op"||n[n.length-1].type==="paren"&&n[n.length-1].value==="(")){let c="";for(r==="-"&&(c+="-",s++);s<t.length&&(t[s]>="0"&&t[s]<="9"||t[s]===".");)c+=t[s],s++;n.push({type:"number",value:parseFloat(c)});continue}if("+-*/%".includes(r)){n.push({type:"op",value:r}),s++;continue}if(r==="("||r===")"){n.push({type:"paren",value:r}),s++;continue}throw new Error(`SYNX :calc \u2014 unexpected character: '${r}' in expression "${t}"`)}return n}var H=class{constructor(n){this.tokens=n,this.pos=0}parse(){let n=this.expr();if(this.pos<this.tokens.length)throw new Error(`SYNX :calc \u2014 unexpected token at position ${this.pos}`);return n}expr(){let n=this.term();for(;this.pos<this.tokens.length&&this.tokens[this.pos].type==="op"&&(this.tokens[this.pos].value==="+"||this.tokens[this.pos].value==="-");){let s=this.tokens[this.pos].value;this.pos++;let r=this.term();n=s==="+"?n+r:n-r}return n}term(){let n=this.factor();for(;this.pos<this.tokens.length&&this.tokens[this.pos].type==="op"&&"*/%".includes(this.tokens[this.pos].value);){let s=this.tokens[this.pos].value;this.pos++;let r=this.factor();if(s==="*")n=n*r;else if(s==="/"){if(r===0)throw new Error("SYNX :calc \u2014 division by zero");n=n/r}else{if(r===0)throw new Error("SYNX :calc \u2014 division by zero");n=n%r}}return n}factor(){let n=this.tokens[this.pos];if(!n)throw new Error("SYNX :calc \u2014 unexpected end of expression");if(n.type==="number")return this.pos++,n.value;if(n.type==="paren"&&n.value==="("){this.pos++;let s=this.expr();if(!this.tokens[this.pos]||this.tokens[this.pos].type!=="paren"||this.tokens[this.pos].value!==")")throw new Error("SYNX :calc \u2014 missing closing parenthesis");return this.pos++,s}throw new Error(`SYNX :calc \u2014 unexpected token: ${JSON.stringify(n)}`)}};function Y(t){let n=yt(t.trim());return n.length===0?0:new H(n).parse()}var b,k;try{b=et("fs"),k=et("path")}catch{}var rt=4096,st=10*1024*1024,K=16,gt=512;function q(t,n){if(!k)throw new Error("path module not available");if(k.isAbsolute(n))throw new Error(`absolute path not allowed: ${n}`);let s=k.resolve(t,n),r=k.resolve(t);if(!s.startsWith(r+k.sep)&&s!==r)throw new Error(`path escapes base directory: ${n}`);return s}function B(t){if(!b)return;let n=b.statSync(t);if(n.size>st)throw new Error(`file too large (${n.size} bytes, max ${st})`)}var G=class{constructor(n){this._value=n}toString(){return"[SECRET]"}toJSON(){return"[SECRET]"}reveal(){return this._value}[Symbol.toPrimitive](n){return n==="number"?NaN:"[SECRET]"}},W=new Map;function _(t,n={},s,r,c=0,u=""){if(!s){s=t,ht(t);for(let e of Object.keys(t))e.startsWith("_")&&delete t[e];!r&&n._includes&&(r=mt(n._includes,n))}if(c>=gt){for(let e of Object.keys(t))e!=="__synx"&&(t[e]="NESTING_ERR: maximum object nesting depth exceeded");return t}let l=t.__synx;for(let e of Object.keys(t)){if(e==="__synx")continue;let p=t[e];if(p&&typeof p=="object"&&!Array.isArray(p)&&_(p,n,s,r,c+1,u?`${u}.${e}`:e),Array.isArray(p))for(let a of p)a&&typeof a=="object"&&!Array.isArray(a)&&_(a,n,s,r,c+1,u?`${u}.${e}`:e);if(!l||!l[e])continue;let{markers:o,args:O}=l[e];if(o.includes("spam")){let a=o.indexOf("spam"),f=parseInt(o[a+1]??"0",10),i=Math.max(1,parseInt(o[a+2]??"1",10)||1);if(!Number.isFinite(f)||f<=0){t[e]="SPAM_ERR: invalid limit, use :spam:MAX[:WINDOW_SEC]";continue}let d=String(t[e]??e),g=`${e}::${d}`;if(!Nt(g,f,i)){t[e]=`SPAM_ERR: '${d}' exceeded ${f} calls per ${i}s`;continue}let h=M(s,d)??M(t,d);h!==void 0&&(t[e]=h)}if(o.includes("include")&&typeof t[e]=="string"){if(!b||!k){t[e]="INCLUDE_ERR: :include is not supported in browser";continue}let a=n.maxIncludeDepth??K,f=n._includeDepth??0;if(f>=a){t[e]=`INCLUDE_ERR: max include depth (${a}) exceeded`;continue}let i=String(t[e]),d=n.basePath||(typeof process<"u"?process.cwd():".");try{let g=q(d,i);B(g);let h=b.readFileSync(g,"utf-8"),{root:A,mode:S}=R(h);S==="active"&&_(A,{...n,basePath:k.dirname(g),_includeDepth:f+1},s),t[e]=A}catch(g){t[e]=`INCLUDE_ERR: ${g.message}`}continue}if(o.includes("env")){let a=String(p),i=(n.env||(typeof process<"u"?process.env:{}))[a],d=o.indexOf("default"),g=l[e]?.typeHint==="string";if(i!==void 0&&i!=="")t[e]=g||isNaN(Number(i))?i:Number(i);else if(d!==-1&&o.length>d+1){let h=o.slice(d+1).join(":");t[e]=g||isNaN(Number(h))?h:Number(h)}else t[e]=null}if(o.includes("random")&&Array.isArray(t[e])){let a=t[e];if(a.length===0){t[e]=null;continue}if(O&&O.length>0){let f=O.map(Number);t[e]=Ct(a,f)}else t[e]=a[Math.floor(Math.random()*a.length)]}if(o.includes("ref")&&typeof t[e]=="string"){let a=t[e],f=M(s,a)??M(t,a);if(f!==void 0){if(t[e]=f,o.includes("calc")){let i=o.indexOf("calc"),d=o[i+1]??"";if(d&&typeof f=="number"){let g=d.charAt(0);if("+-*/%".includes(g)){let h=`${f} ${d}`;try{t[e]=Y(h)}catch{t[e]=f}}}}}else t[e]=null}if(o.includes("i18n")&&t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])){let a=t[e],f=n.lang||"en",i=a[f]??a.en??Object.values(a)[0]??null;t[e]=i}if(o.includes("calc")&&typeof t[e]=="string"){let a=t[e];if(a.length>rt){t[e]=`CALC_ERR: expression too long (${a.length} chars, max ${rt})`;continue}let f=new Map;for(let i of Object.keys(s))typeof s[i]=="number"&&f.set(i,String(s[i]));for(let i of Object.keys(t))i!==e&&typeof t[i]=="number"&&f.set(i,String(t[i]));f.size>0&&(a=Et(a,f));try{t[e]=Y(a)}catch(i){t[e]=`CALC_ERR: ${i.message}`}}if(o.includes("alias")&&typeof t[e]=="string"){let a=t[e],f=u?`${u}.${e}`:e;if(a===e||a===f)t[e]=`ALIAS_ERR: self-referential alias: ${f} \u2192 ${a}`;else{let i=M(s,a),d=a.lastIndexOf("."),g=d>=0?a.slice(0,d):"",h=d>=0?a.slice(d+1):a,A=g?M(s,g):s;((A!=null&&typeof A=="object"?A.__synx:void 0)?.[h]?.markers?.includes("alias")??!1)&&typeof i=="string"&&i===e?t[e]=`ALIAS_ERR: circular alias detected: ${e} \u2192 ${a}`:t[e]=i??null}}if(o.includes("secret")&&(t[e]=new G(String(t[e]))),o.includes("unique")&&Array.isArray(t[e])){let a=new Set;t[e]=t[e].filter(f=>{let i=String(f);return a.has(i)?!1:(a.add(i),!0)})}if(o.includes("geo")&&Array.isArray(t[e])){let a=n.region||"US",f=t[e],i=f.find(d=>String(d).startsWith(a+" "));if(i)t[e]=i.substring(a.length+1).trim();else{let d=f[0];typeof d=="string"&&d.includes(" ")?t[e]=d.substring(d.indexOf(" ")+1).trim():t[e]=d??null}}if(o.includes("split")&&typeof t[e]=="string"){let a=o.indexOf("split"),f=a+1<o.length?o[a+1]:",",i=ct(f);t[e]=t[e].split(i).map(d=>d.trim()).filter(d=>d!=="").map(d=>at(d))}if(o.includes("join")&&Array.isArray(t[e])){let a=o.indexOf("join"),f=a+1<o.length?o[a+1]:",",i=ct(f);t[e]=t[e].map(d=>String(d)).join(i)}if(o.includes("default")&&!o.includes("env")&&(t[e]===null||t[e]===void 0||t[e]==="")){let a=o.indexOf("default");if(a!==-1&&o.length>a+1){let f=o.slice(a+1).join(":"),i=l[e]?.typeHint==="string";t[e]=i||isNaN(Number(f))?f:Number(f)}}if(o.includes("clamp")){let a=o.indexOf("clamp"),f=parseFloat(o[a+1]??""),i=parseFloat(o[a+2]??"");!isNaN(f)&&!isNaN(i)&&(f>i?t[e]=`CONSTRAINT_ERR: clamp min (${f}) > max (${i})`:typeof t[e]=="number"&&(t[e]=Math.min(i,Math.max(f,t[e]))))}if(o.includes("round")){let a=o.indexOf("round"),f=parseInt(o[a+1]??"0",10)||0;if(typeof t[e]=="number"){let i=Math.pow(10,f);t[e]=Math.round(t[e]*i)/i}}if(o.includes("map")&&Array.isArray(t[e])){let a=o.indexOf("map"),f=o[a+1]??"",i=String(f?M(s,f)??M(t,f)??"":""),g=t[e].find(h=>{let A=String(h),S=A.indexOf(" ");return S!==-1&&A.substring(0,S).trim()===i});t[e]=g?at(g.substring(g.indexOf(" ")+1).trim()):null}if(o.includes("format")){let a=o.indexOf("format"),f=o[a+1]??"%s";t[e]=Ot(f,t[e])}if(o.includes("fallback")){let a=o.indexOf("fallback"),f=o[a+1]??"",i=t[e],d=i==null||i==="";if(!d&&typeof i=="string"&&b&&k&&n.basePath)try{let g=q(n.basePath,i);d=!b.existsSync(g)}catch{d=!0}d&&f&&(t[e]=f)}if(o.includes("once")){let a=o.indexOf("once"),f=o[a+1]??"uuid",i=k&&n.basePath?k.resolve(n.basePath,".synx.lock"):".synx.lock",d=At(i,e);if(d!==null)t[e]=d;else{let g;f==="uuid"?g=it():f==="timestamp"?g=String(Date.now()):f==="random"?g=String(Math.floor(Math.random()*2147483647)):g=it(),$t(i,e,g),t[e]=g}}if(o.includes("version")&&typeof t[e]=="string"){let a=o.indexOf("version"),f=o[a+1]??">=",i=o[a+2]??"0";t[e]=bt(t[e],f,i)}if(o.includes("watch")&&typeof t[e]=="string")if(!b||!k)t[e]="WATCH_ERR: not supported in browser";else{let a=n.maxIncludeDepth??K;if((n._includeDepth??0)>=a)t[e]=`WATCH_ERR: max include depth (${a}) exceeded`;else{let i=t[e],d=n.basePath||(typeof process<"u"?process.cwd():"."),g=o.indexOf("watch"),h=o[g+1];try{let A=q(d,i);B(A);let S=b.readFileSync(A,"utf-8"),N=k.extname(A).slice(1);h?t[e]=wt(S,h,N):t[e]=S.trim()}catch(A){t[e]=`WATCH_ERR: ${A.message}`}}}if(o.includes("prompt")){let a=o.indexOf("prompt"),f=o[a+1]??e,i=t[e],d=lt(i,0);t[e]=`${f} (SYNX):
1
+ var nt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(n,s)=>(typeof require<"u"?require:n)[s]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});function X(t){if(t==="true")return!0;if(t==="false")return!1;if(t==="null")return null;let n=t.length;if(n===0)return t;let s=t.charCodeAt(0);if(s===40&&n>2){let o=t.indexOf(")");if(o>1){let l=t.substring(1,o),e=t.substring(o+1);switch(l){case"int":{let p=parseInt(e,10);return isNaN(p)?0:p}case"float":{let p=parseFloat(e);return isNaN(p)?0:p}case"bool":return e.trim()==="true";case"string":return e;case"random":return Math.floor(Math.random()*2147483647);case"random:int":return Math.floor(Math.random()*2147483647);case"random:float":return Math.random();case"random:bool":return Math.random()<.5}}}let r=0,a=s;if(a===45){if(n===1)return t;r=1,a=t.charCodeAt(1)}if(a>=48&&a<=57){let o=!0,l=-1;for(let e=r+1;e<n;e++){let p=t.charCodeAt(e);if(p===46){if(l!==-1){o=!1;break}l=e}else if(p<48||p>57){o=!1;break}}if(o){if(l===-1)return parseInt(t,10);if(l>r&&l<n-1)return parseFloat(t)}}return t}function U(t){if(t.indexOf(" ")===-1)return t;let n=t,s=n.indexOf(" //");s!==-1&&(n=n.substring(0,s));let r=n.indexOf(" #");return r!==-1&&(n=n.substring(0,r)),n.trimEnd()}function yt(t){let n={},s=0;for(;s<t.length;){let r=t.indexOf(",",s);r===-1&&(r=t.length);let a=t.substring(s,r).trim();if(s=r+1,!!a)if(a==="required")n.required=!0;else if(a==="readonly")n.readonly=!0;else{let o=a.indexOf(":");if(o!==-1){let l=a.substring(0,o).trim(),e=a.substring(o+1).trim();switch(l){case"min":n.min=Number(e);break;case"max":n.max=Number(e);break;case"type":n.type=e;break;case"pattern":n.pattern=e;break;case"enum":n.enum=e.split("|");break}}}}return n}function W(t,n,s,r,a,o,l){if(o!=="active"||s.length===0&&!a&&!l)return;let e;t.__synx?e=t.__synx:(e={},Object.defineProperty(t,"__synx",{value:e,enumerable:!1,writable:!0,configurable:!0}));let p={markers:s};r.length>0&&(p.args=r),a&&(p.constraints=a),l&&(p.typeHint=l),e[n]=p}var rt=/^([^\s\[:\-#/(][^\s\[:(]*)(?:\(([\w:]+)\))?(?:\[([^\]]*)\])?(?::([^\s]+))?\s*(.*)$/;function _(t){let n=t.split(`
2
+ `),s={},r=[{indent:-1,obj:s}],a="static",o=!1,l=!1,e=[],p=null,i=null,A=!1;for(let c=0;c<n.length;c++){let u=n[c],d=u.length,f=0;for(;f<d;){let y=u.charCodeAt(f);if(y!==32&&y!==9&&y!==13)break;f++}if(f===d)continue;let g=u.charCodeAt(f);if(g===35&&u.substring(f).trimEnd()==="###"){A=!A;continue}if(A)continue;if(g===35){d-f>7&&u.charCodeAt(f+1)===33&&u.substring(f,f+7)==="#!mode:"&&(a=u.substring(f+7,d).trim()==="active"?"active":"static");continue}if(g===47&&f+1<d&&u.charCodeAt(f+1)===47)continue;let S=d;for(;S>f;){let y=u.charCodeAt(S-1);if(y!==32&&y!==9&&y!==13&&y!==10)break;S--}let h=u.substring(f,S),M=h.length;if(g===33){if(h==="!active"){a="active";continue}if(h==="!lock"){o=!0;continue}if(h==="!llm"){l=!0;continue}if(h.startsWith("!include ")){let y=h.substring(9).trim().split(/\s+/),m=y[0],x=y[1]||m.replace(/^.*[\/\\]/,"").replace(/\.synx$/i,"");e.push({path:m,alias:x});continue}}if(p&&f>p.indent){let y=h;p.obj[p.key]+=(p.obj[p.key]?`
3
+ `:"")+y;continue}else p=null;if(g===45&&M>1&&h.charCodeAt(1)===32){if(i&&f>i.indent){let y=U(h.substring(2).trim()),m=c+1;for(;m<n.length;){let x=n[m],$=0;for(;$<x.length&&(x.charCodeAt($)===32||x.charCodeAt($)===9||x.charCodeAt($)===13);)$++;if($<x.length)break;m++}if(m<n.length){let x=n[m],$=0;for(;$<x.length&&(x.charCodeAt($)===32||x.charCodeAt($)===9||x.charCodeAt($)===13);)$++;let H=x.charCodeAt($);if($>f&&$<x.length&&H!==45&&H!==35&&!(H===47&&$+1<x.length&&x.charCodeAt($+1)===47)){let L={},tt=y.match(rt);if(tt){let[,dt,et,,,pt]=tt,F=pt||"";et&&(F=`(${et})${F}`),L[dt]=F?X(U(F)):{}}else L._value=X(y);i.arr.push(L),r.push({indent:f,obj:L});continue}}i.arr.push(X(y));continue}continue}if(i&&f<=i.indent&&(i=null),g===91||g===40||g===58||g===47)continue;let O,R,P,T,w,j=!1,D=-1;for(let y=0;y<M;y++){let m=h.charCodeAt(y);if(m===32||m===9){D=y;break}if(m===40||m===91||m===58){j=!0;break}}if(j){let y=h.match(rt);if(!y)continue;[,O,R,P,T,w]=y,w=w?U(w.trim()):""}else{if(D===-1)O=h,w="";else{O=h.substring(0,D);let y=D;for(;y<M&&(h.charCodeAt(y)===32||h.charCodeAt(y)===9);)y++;w=y<M?U(h.substring(y)):""}R=void 0,P=void 0,T=void 0}R&&(w=`(${R})${w}`);let N=[],v=[];if(T&&(N=T.split(":")),N.length>0&&N.includes("random")&&w){let y=w.split(/\s+/).filter(m=>/^\d+(\.\d+)?$/.test(m));y.length>0&&(v=y,w="")}let V=P?yt(P):void 0;for(;r.length>1&&r[r.length-1].indent>=f;)r.pop();let C=r[r.length-1].obj;if(!(O==="__proto__"||O==="constructor"||O==="prototype"))if(w==="|")C[O]="",p={indent:f,obj:C,key:O},W(C,O,N,v,V,a,R);else if(!w&&N.length>0&&(N.includes("random")||N.includes("unique")||N.includes("geo")||N.includes("join")))C[O]=[],i={indent:f,arr:C[O]},W(C,O,N,v,V,a,R);else if(w)C[O]=X(w),W(C,O,N,v,V,a,R);else{C[O]={},r.push({indent:f,obj:C[O]});let y=c+1;for(;y<n.length;){let m=n[y],x=0;for(;x<m.length&&(m.charCodeAt(x)===32||m.charCodeAt(x)===9||m.charCodeAt(x)===13);)x++;if(x<m.length)break;y++}if(y<n.length){let m=n[y],x=0;for(;x<m.length&&(m.charCodeAt(x)===32||m.charCodeAt(x)===9||m.charCodeAt(x)===13);)x++;x+1<m.length&&m.charCodeAt(x)===45&&m.charCodeAt(x+1)===32&&(C[O]=[],r[r.length-1]={indent:f,obj:C[O]},i={indent:f,arr:C[O]})}W(C,O,N,v,V,a,R)}}return{root:s,mode:a,locked:o,...l?{llm:!0}:{},includes:e.length>0?e:void 0}}function gt(t){let n=[],s=0;for(;s<t.length;){let r=t[s];if(r===" "||r===" "){s++;continue}if(r>="0"&&r<="9"||r==="."&&s+1<t.length&&t[s+1]>="0"&&t[s+1]<="9"||r==="-"&&(n.length===0||n[n.length-1].type==="op"||n[n.length-1].type==="paren"&&n[n.length-1].value==="(")){let a="";for(r==="-"&&(a+="-",s++);s<t.length&&(t[s]>="0"&&t[s]<="9"||t[s]===".");)a+=t[s],s++;n.push({type:"number",value:parseFloat(a)});continue}if("+-*/%".includes(r)){n.push({type:"op",value:r}),s++;continue}if(r==="("||r===")"){n.push({type:"paren",value:r}),s++;continue}throw new Error(`SYNX :calc \u2014 unexpected character: '${r}' in expression "${t}"`)}return n}var Y=class{constructor(n){this.tokens=n,this.pos=0}parse(){let n=this.expr();if(this.pos<this.tokens.length)throw new Error(`SYNX :calc \u2014 unexpected token at position ${this.pos}`);return n}expr(){let n=this.term();for(;this.pos<this.tokens.length&&this.tokens[this.pos].type==="op"&&(this.tokens[this.pos].value==="+"||this.tokens[this.pos].value==="-");){let s=this.tokens[this.pos].value;this.pos++;let r=this.term();n=s==="+"?n+r:n-r}return n}term(){let n=this.factor();for(;this.pos<this.tokens.length&&this.tokens[this.pos].type==="op"&&"*/%".includes(this.tokens[this.pos].value);){let s=this.tokens[this.pos].value;this.pos++;let r=this.factor();if(s==="*")n=n*r;else if(s==="/"){if(r===0)throw new Error("SYNX :calc \u2014 division by zero");n=n/r}else{if(r===0)throw new Error("SYNX :calc \u2014 division by zero");n=n%r}}return n}factor(){let n=this.tokens[this.pos];if(!n)throw new Error("SYNX :calc \u2014 unexpected end of expression");if(n.type==="number")return this.pos++,n.value;if(n.type==="paren"&&n.value==="("){this.pos++;let s=this.expr();if(!this.tokens[this.pos]||this.tokens[this.pos].type!=="paren"||this.tokens[this.pos].value!==")")throw new Error("SYNX :calc \u2014 missing closing parenthesis");return this.pos++,s}throw new Error(`SYNX :calc \u2014 unexpected token: ${JSON.stringify(n)}`)}};function K(t){let n=gt(t.trim());return n.length===0?0:new Y(n).parse()}var b,k;try{b=nt("fs"),k=nt("path")}catch{}var st=4096,it=10*1024*1024,B=16,ht=512;function z(t,n){if(!k)throw new Error("path module not available");if(k.isAbsolute(n))throw new Error(`absolute path not allowed: ${n}`);let s=k.resolve(t,n),r=k.resolve(t);if(!s.startsWith(r+k.sep)&&s!==r)throw new Error(`path escapes base directory: ${n}`);return s}function G(t){if(!b)return;let n=b.statSync(t);if(n.size>it)throw new Error(`file too large (${n.size} bytes, max ${it})`)}var J=class{constructor(n){this._value=n}toString(){return"[SECRET]"}toJSON(){return"[SECRET]"}reveal(){return this._value}[Symbol.toPrimitive](n){return n==="number"?NaN:"[SECRET]"}},q=new Map;function I(t,n={},s,r,a=0,o=""){if(!s){s=t,xt(t);for(let e of Object.keys(t))e.startsWith("_")&&delete t[e];!r&&n._includes&&(r=St(n._includes,n))}if(a>=ht){for(let e of Object.keys(t))e!=="__synx"&&(t[e]="NESTING_ERR: maximum object nesting depth exceeded");return t}let l=t.__synx;for(let e of Object.keys(t)){if(e==="__synx")continue;let p=t[e];if(p&&typeof p=="object"&&!Array.isArray(p)&&I(p,n,s,r,a+1,o?`${o}.${e}`:e),Array.isArray(p))for(let c of p)c&&typeof c=="object"&&!Array.isArray(c)&&I(c,n,s,r,a+1,o?`${o}.${e}`:e);if(!l||!l[e])continue;let{markers:i,args:A}=l[e];if(i.includes("spam")){let c=i.indexOf("spam"),u=parseInt(i[c+1]??"0",10),d=Math.max(1,parseInt(i[c+2]??"1",10)||1);if(!Number.isFinite(u)||u<=0){t[e]="SPAM_ERR: invalid limit, use :spam:MAX[:WINDOW_SEC]";continue}let f=String(t[e]??e),g=`${e}::${f}`;if(!Rt(g,u,d)){t[e]=`SPAM_ERR: '${f}' exceeded ${u} calls per ${d}s`;continue}let S=E(s,f)??E(t,f);S!==void 0&&(t[e]=S)}if(i.includes("include")&&typeof t[e]=="string"){if(!b||!k){t[e]="INCLUDE_ERR: :include is not supported in browser";continue}let c=n.maxIncludeDepth??B,u=n._includeDepth??0;if(u>=c){t[e]=`INCLUDE_ERR: max include depth (${c}) exceeded`;continue}let d=String(t[e]),f=n.basePath||(typeof process<"u"?process.cwd():".");try{let g=z(f,d);G(g);let S=b.readFileSync(g,"utf-8"),{root:h,mode:M}=_(S);M==="active"&&I(h,{...n,basePath:k.dirname(g),_includeDepth:u+1},s),t[e]=h}catch(g){t[e]=`INCLUDE_ERR: ${g.message}`}continue}if(i.includes("env")){let c=String(p),d=(n.env||(typeof process<"u"?process.env:{}))[c],f=i.indexOf("default"),g=l[e]?.typeHint==="string";if(d!==void 0&&d!=="")t[e]=g||isNaN(Number(d))?d:Number(d);else if(f!==-1&&i.length>f+1){let S=i.slice(f+1).join(":");t[e]=g||isNaN(Number(S))?S:Number(S)}else t[e]=null}if(i.includes("random")&&Array.isArray(t[e])){let c=t[e];if(c.length===0){t[e]=null;continue}if(A&&A.length>0){let u=A.map(Number);t[e]=Mt(c,u)}else t[e]=c[Math.floor(Math.random()*c.length)]}if(i.includes("ref")&&typeof t[e]=="string"){let c=t[e],u=E(s,c)??E(t,c);if(u!==void 0){if(t[e]=u,i.includes("calc")){let d=i.indexOf("calc"),f=i[d+1]??"";if(f&&typeof u=="number"){let g=f.charAt(0);if("+-*/%".includes(g)){let S=`${u} ${f}`;try{t[e]=K(S)}catch{t[e]=u}}}}}else t[e]=null}if(i.includes("i18n")&&t[e]&&typeof t[e]=="object"&&!Array.isArray(t[e])){let c=t[e],u=n.lang||"en",d=c[u]??c.en??Object.values(c)[0]??null;t[e]=d}if(i.includes("calc")&&typeof t[e]=="string"){let c=t[e];if(c.length>st){t[e]=`CALC_ERR: expression too long (${c.length} chars, max ${st})`;continue}let u=new Map;for(let d of Object.keys(s))typeof s[d]=="number"&&u.set(d,String(s[d]));for(let d of Object.keys(t))d!==e&&typeof t[d]=="number"&&u.set(d,String(t[d]));u.size>0&&(c=Nt(c,u));try{t[e]=K(c)}catch(d){t[e]=`CALC_ERR: ${d.message}`}}if(i.includes("alias")&&typeof t[e]=="string"){let c=t[e],u=o?`${o}.${e}`:e;if(c===e||c===u)t[e]=`ALIAS_ERR: self-referential alias: ${u} \u2192 ${c}`;else{let d=E(s,c),f=c.lastIndexOf("."),g=f>=0?c.slice(0,f):"",S=f>=0?c.slice(f+1):c,h=g?E(s,g):s;((h!=null&&typeof h=="object"?h.__synx:void 0)?.[S]?.markers?.includes("alias")??!1)&&typeof d=="string"&&d===e?t[e]=`ALIAS_ERR: circular alias detected: ${e} \u2192 ${c}`:t[e]=d??null}}if(i.includes("secret")&&(t[e]=new J(String(t[e]))),i.includes("unique")&&Array.isArray(t[e])){let c=new Set;t[e]=t[e].filter(u=>{let d=String(u);return c.has(d)?!1:(c.add(d),!0)})}if(i.includes("geo")&&Array.isArray(t[e])){let c=n.region||"US",u=t[e],d=u.find(f=>String(f).startsWith(c+" "));if(d)t[e]=d.substring(c.length+1).trim();else{let f=u[0];typeof f=="string"&&f.includes(" ")?t[e]=f.substring(f.indexOf(" ")+1).trim():t[e]=f??null}}if(i.includes("split")&&typeof t[e]=="string"){let c=i.indexOf("split"),u=c+1<i.length?i[c+1]:",",d=ot(u);t[e]=t[e].split(d).map(f=>f.trim()).filter(f=>f!=="").map(f=>ct(f))}if(i.includes("join")&&Array.isArray(t[e])){let c=i.indexOf("join"),u=c+1<i.length?i[c+1]:",",d=ot(u);t[e]=t[e].map(f=>String(f)).join(d)}if(i.includes("default")&&!i.includes("env")&&(t[e]===null||t[e]===void 0||t[e]==="")){let c=i.indexOf("default");if(c!==-1&&i.length>c+1){let u=i.slice(c+1).join(":"),d=l[e]?.typeHint==="string";t[e]=d||isNaN(Number(u))?u:Number(u)}}if(i.includes("clamp")){let c=i.indexOf("clamp"),u=parseFloat(i[c+1]??""),d=parseFloat(i[c+2]??"");!isNaN(u)&&!isNaN(d)&&(u>d?t[e]=`CONSTRAINT_ERR: clamp min (${u}) > max (${d})`:typeof t[e]=="number"&&(t[e]=Math.min(d,Math.max(u,t[e]))))}if(i.includes("round")){let c=i.indexOf("round"),u=parseInt(i[c+1]??"0",10)||0;if(typeof t[e]=="number"){let d=Math.pow(10,u);t[e]=Math.round(t[e]*d)/d}}if(i.includes("map")&&Array.isArray(t[e])){let c=i.indexOf("map"),u=i[c+1]??"",d=String(u?E(s,u)??E(t,u)??"":""),g=t[e].find(S=>{let h=String(S),M=h.indexOf(" ");return M!==-1&&h.substring(0,M).trim()===d});t[e]=g?ct(g.substring(g.indexOf(" ")+1).trim()):null}if(i.includes("format")){let c=i.indexOf("format"),u=i[c+1]??"%s";t[e]=At(u,t[e])}if(i.includes("fallback")){let c=i.indexOf("fallback"),u=i[c+1]??"",d=t[e],f=d==null||d==="";if(!f&&typeof d=="string"&&b&&k&&n.basePath)try{let g=z(n.basePath,d);f=!b.existsSync(g)}catch{f=!0}f&&u&&(t[e]=u)}if(i.includes("once")){let c=i.indexOf("once"),u=i[c+1]??"uuid",d=k&&n.basePath?k.resolve(n.basePath,".synx.lock"):".synx.lock",f=$t(d,e);if(f!==null)t[e]=f;else{let g;u==="uuid"?g=at():u==="timestamp"?g=String(Date.now()):u==="random"?g=String(Math.floor(Math.random()*2147483647)):g=at(),bt(d,e,g),t[e]=g}}if(i.includes("version")&&typeof t[e]=="string"){let c=i.indexOf("version"),u=i[c+1]??">=",d=i[c+2]??"0";t[e]=wt(t[e],u,d)}if(i.includes("watch")&&typeof t[e]=="string")if(!b||!k)t[e]="WATCH_ERR: not supported in browser";else{let c=n.maxIncludeDepth??B;if((n._includeDepth??0)>=c)t[e]=`WATCH_ERR: max include depth (${c}) exceeded`;else{let d=t[e],f=n.basePath||(typeof process<"u"?process.cwd():"."),g=i.indexOf("watch"),S=i[g+1];try{let h=z(f,d);G(h);let M=b.readFileSync(h,"utf-8"),O=k.extname(h).slice(1);S?t[e]=kt(M,S,O):t[e]=M.trim()}catch(h){t[e]=`WATCH_ERR: ${h.message}`}}}if(i.includes("prompt")){let c=i.indexOf("prompt"),u=i[c+1]??e,d=t[e],f=ut(d,0);t[e]=`${u} (SYNX):
4
4
  \`\`\`synx
5
- ${d}\`\`\``}l&&l[e]?.constraints&&St(t,e,l[e].constraints)}for(let e of Object.keys(t))e!=="__synx"&&typeof t[e]=="string"&&t[e].includes("{")&&(t[e]=xt(t[e],s,t,r));return t}function ht(t){let n=t.__synx;if(n)for(let s of Object.keys(t)){if(s==="__synx")continue;let r=n[s];if(!r||!r.markers.includes("inherit"))continue;let c=r.markers.indexOf("inherit"),u=r.markers[c+1];if(!u)continue;let l=t[u];if(!l||typeof l!="object"||Array.isArray(l))continue;let e=t[s];if(!e||typeof e!="object"||Array.isArray(e))continue;let p={...l,...e},o=l.__synx,O=e.__synx;if(o||O){let a={...o||{},...O||{}};Object.defineProperty(p,"__synx",{value:a,enumerable:!1,writable:!0,configurable:!0})}t[s]=p}}function xt(t,n,s,r){return t.replace(/\{(\w+(?:\.\w+)*)(?::(\w+(?:[./\\][\w./\\]*)?))?\}/g,(c,u,l)=>{if(l){if(l==="include"){if(!r||r.size===0)return c;if(r.size>1)return"INCLUDE_ERR: multiple !include \u2014 specify alias";let p=r.values().next().value,o=M(p,u);return o!=null?String(o):c}if(r){let p=r.get(l);if(p){let o=M(p,u);return o!=null?String(o):c}}return c}let e=M(n,u)??M(s,u);return e!=null?String(e):c})}function mt(t,n){let s=new Map;if(!b||!k)return s;let r=n.basePath||(typeof process<"u"?process.cwd():"."),c=n.maxIncludeDepth??K,u=n._includeDepth??0;if(u>=c)return s;for(let l of t)try{let e=q(r,l.path);B(e);let p=b.readFileSync(e,"utf-8"),{root:o,mode:O}=R(p);O==="active"&&_(o,{...n,basePath:k.dirname(e),_includeDepth:u+1},void 0,s),s.set(l.alias,o)}catch{}return s}function St(t,n,s){let r=t[n];if(s.required&&(r==null||r==="")){t[n]=`CONSTRAINT_ERR: '${n}' is required`;return}if(r==null)return;if(s.type&&!(()=>{switch(s.type){case"int":return typeof r=="number"&&Number.isInteger(r);case"float":return typeof r=="number";case"bool":return typeof r=="boolean";case"string":return typeof r=="string";default:return!0}})()){t[n]=`CONSTRAINT_ERR: '${n}' expected type '${s.type}'`;return}if(s.enum){let u=String(r);if(!s.enum.includes(u)){t[n]=`CONSTRAINT_ERR: '${n}' must be one of [${s.enum.join("|")}]`;return}}let c=typeof r=="number"?r:typeof r=="string"&&(s.min!==void 0||s.max!==void 0)?r.length:null;if(c!==null){if(s.min!==void 0&&c<s.min){t[n]=`CONSTRAINT_ERR: '${n}' value ${c} is below min ${s.min}`;return}if(s.max!==void 0&&c>s.max){t[n]=`CONSTRAINT_ERR: '${n}' value ${c} exceeds max ${s.max}`;return}}if(s.pattern&&typeof r=="string"){if(s.pattern.length>128)return;try{if(!new RegExp(s.pattern).test(r)){t[n]=`CONSTRAINT_ERR: '${n}' does not match pattern /${s.pattern}/`;return}}catch{}}}function Ot(t,n){let s=typeof n=="number"?n:parseFloat(String(n));if(isNaN(s))return String(n);let r=t.match(/^%\.(\d+)f$/);if(r)return s.toFixed(parseInt(r[1],10));let c=t.match(/^%0(\d+)d$/);if(c)return String(Math.round(s)).padStart(parseInt(c[1],10),"0");let u=t.match(/^%(\d+)d$/);return u?String(Math.round(s)).padStart(parseInt(u[1],10)):t==="%e"?s.toExponential():String(n)}function At(t,n){if(!b)return null;try{let s=b.readFileSync(t,"utf-8");for(let r of s.split(/\r?\n/))if(r.startsWith(n+" "))return r.substring(n.length+1)}catch{}return null}function $t(t,n,s){if(!b)return;let r=[];try{r=b.readFileSync(t,"utf-8").split(/\r?\n/)}catch{}let c=`${n} ${s}`,u=r.findIndex(l=>l.startsWith(n+" "));u!==-1?r[u]=c:r.push(c);try{b.writeFileSync(t,r.filter(Boolean).join(`
5
+ ${f}\`\`\``}l&&l[e]?.constraints&&Ot(t,e,l[e].constraints)}for(let e of Object.keys(t))e!=="__synx"&&typeof t[e]=="string"&&t[e].includes("{")&&(t[e]=mt(t[e],s,t,r));return t}function xt(t){let n=t.__synx;if(n)for(let s of Object.keys(t)){if(s==="__synx")continue;let r=n[s];if(!r||!r.markers.includes("inherit"))continue;let a=r.markers.indexOf("inherit"),o=r.markers[a+1];if(!o)continue;let l=t[o];if(!l||typeof l!="object"||Array.isArray(l))continue;let e=t[s];if(!e||typeof e!="object"||Array.isArray(e))continue;let p={...l,...e},i=l.__synx,A=e.__synx;if(i||A){let c={...i||{},...A||{}};Object.defineProperty(p,"__synx",{value:c,enumerable:!1,writable:!0,configurable:!0})}t[s]=p}}function mt(t,n,s,r){return t.replace(/\{(\w+(?:\.\w+)*)(?::(\w+(?:[./\\][\w./\\]*)?))?\}/g,(a,o,l)=>{if(l){if(l==="include"){if(!r||r.size===0)return a;if(r.size>1)return"INCLUDE_ERR: multiple !include \u2014 specify alias";let p=r.values().next().value,i=E(p,o);return i!=null?String(i):a}if(r){let p=r.get(l);if(p){let i=E(p,o);return i!=null?String(i):a}}return a}let e=E(n,o)??E(s,o);return e!=null?String(e):a})}function St(t,n){let s=new Map;if(!b||!k)return s;let r=n.basePath||(typeof process<"u"?process.cwd():"."),a=n.maxIncludeDepth??B,o=n._includeDepth??0;if(o>=a)return s;for(let l of t)try{let e=z(r,l.path);G(e);let p=b.readFileSync(e,"utf-8"),{root:i,mode:A}=_(p);A==="active"&&I(i,{...n,basePath:k.dirname(e),_includeDepth:o+1},void 0,s),s.set(l.alias,i)}catch{}return s}function Ot(t,n,s){let r=t[n];if(s.required&&(r==null||r==="")){t[n]=`CONSTRAINT_ERR: '${n}' is required`;return}if(r==null)return;if(s.type&&!(()=>{switch(s.type){case"int":return typeof r=="number"&&Number.isInteger(r);case"float":return typeof r=="number";case"bool":return typeof r=="boolean";case"string":return typeof r=="string";default:return!0}})()){t[n]=`CONSTRAINT_ERR: '${n}' expected type '${s.type}'`;return}if(s.enum){let o=String(r);if(!s.enum.includes(o)){t[n]=`CONSTRAINT_ERR: '${n}' must be one of [${s.enum.join("|")}]`;return}}let a=typeof r=="number"?r:typeof r=="string"&&(s.min!==void 0||s.max!==void 0)?r.length:null;if(a!==null){if(s.min!==void 0&&a<s.min){t[n]=`CONSTRAINT_ERR: '${n}' value ${a} is below min ${s.min}`;return}if(s.max!==void 0&&a>s.max){t[n]=`CONSTRAINT_ERR: '${n}' value ${a} exceeds max ${s.max}`;return}}if(s.pattern&&typeof r=="string"){if(s.pattern.length>128)return;try{if(!new RegExp(s.pattern).test(r)){t[n]=`CONSTRAINT_ERR: '${n}' does not match pattern /${s.pattern}/`;return}}catch{}}}function At(t,n){let s=typeof n=="number"?n:parseFloat(String(n));if(isNaN(s))return String(n);let r=t.match(/^%\.(\d+)f$/);if(r)return s.toFixed(parseInt(r[1],10));let a=t.match(/^%0(\d+)d$/);if(a)return String(Math.round(s)).padStart(parseInt(a[1],10),"0");let o=t.match(/^%(\d+)d$/);return o?String(Math.round(s)).padStart(parseInt(o[1],10)):t==="%e"?s.toExponential():String(n)}function $t(t,n){if(!b)return null;try{let s=b.readFileSync(t,"utf-8");for(let r of s.split(/\r?\n/))if(r.startsWith(n+" "))return r.substring(n.length+1)}catch{}return null}function bt(t,n,s){if(!b)return;let r=[];try{r=b.readFileSync(t,"utf-8").split(/\r?\n/)}catch{}let a=`${n} ${s}`,o=r.findIndex(l=>l.startsWith(n+" "));o!==-1?r[o]=a:r.push(a);try{b.writeFileSync(t,r.filter(Boolean).join(`
6
6
  `)+`
7
- `,"utf-8")}catch{}}function it(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)})}function bt(t,n,s){let r=p=>p.split(".").map(o=>parseInt(o,10)||0),c=r(t),u=r(s),l=Math.max(c.length,u.length),e=0;for(let p=0;p<l;p++){let o=c[p]??0,O=u[p]??0;if(o!==O){e=o>O?1:-1;break}}switch(n){case">=":return e>=0;case"<=":return e<=0;case">":return e>0;case"<":return e<0;case"==":case"=":return e===0;case"!=":return e!==0;default:return!1}}function wt(t,n,s){if(s==="json")try{let r=JSON.parse(t);return n.split(".").reduce((c,u)=>c?.[u],r)??null}catch{return null}try{let{root:r}=R(t);return M(r,n)??null}catch{return null}}function lt(t,n){let s=" ".repeat(n);if(t==null)return`${s}null
7
+ `,"utf-8")}catch{}}function at(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{let n=Math.random()*16|0;return(t==="x"?n:n&3|8).toString(16)})}function wt(t,n,s){let r=p=>p.split(".").map(i=>parseInt(i,10)||0),a=r(t),o=r(s),l=Math.max(a.length,o.length),e=0;for(let p=0;p<l;p++){let i=a[p]??0,A=o[p]??0;if(i!==A){e=i>A?1:-1;break}}switch(n){case">=":return e>=0;case"<=":return e<=0;case">":return e>0;case"<":return e<0;case"==":case"=":return e===0;case"!=":return e!==0;default:return!1}}function kt(t,n,s){if(s==="json")try{let r=JSON.parse(t);return n.split(".").reduce((a,o)=>a?.[o],r)??null}catch{return null}try{let{root:r}=_(t);return E(r,n)??null}catch{return null}}function ut(t,n){let s=" ".repeat(n);if(t==null)return`${s}null
8
8
  `;if(typeof t=="boolean"||typeof t=="number")return`${s}${t}
9
9
  `;if(typeof t=="string")return`${s}${t}
10
- `;if(Array.isArray(t)){let r="";for(let c of t)r+=`${s} - ${String(c)}
11
- `;return r}if(typeof t=="object"){let r="";for(let[c,u]of Object.entries(t))if(c!=="__synx")if(u&&typeof u=="object"&&!Array.isArray(u))r+=`${s}${c}
12
- `,r+=lt(u,n+2);else if(Array.isArray(u)){r+=`${s}${c}
13
- `;for(let l of u)r+=`${s} - ${String(l)}
14
- `}else r+=`${s}${c} ${u??"null"}
10
+ `;if(Array.isArray(t)){let r="";for(let a of t)r+=`${s} - ${String(a)}
11
+ `;return r}if(typeof t=="object"){let r="";for(let[a,o]of Object.entries(t))if(a!=="__synx")if(o&&typeof o=="object"&&!Array.isArray(o))r+=`${s}${a}
12
+ `,r+=ut(o,n+2);else if(Array.isArray(o)){r+=`${s}${a}
13
+ `;for(let l of o)r+=`${s} - ${String(l)}
14
+ `}else r+=`${s}${a} ${o??"null"}
15
15
  `;return r}return`${s}${String(t)}
16
- `}function at(t){return t==="true"?!0:t==="false"?!1:t==="null"?null:/^-?\d+$/.test(t)?parseInt(t,10):/^-?\d+\.\d+$/.test(t)?parseFloat(t):t}var kt={space:" ",pipe:"|",dash:"-",dot:".",semi:";",tab:" ",slash:"/"};function ct(t){return kt[t]||t}function Ct(t,n){let s=[...n];if(s.length<t.length){let l=s.reduce((p,o)=>p+o,0),e=l<100?(100-l)/(t.length-s.length):l/s.length;for(;s.length<t.length;)s.push(e)}let r=s.reduce((l,e)=>l+e,0);if(r<=0)return t[Math.floor(Math.random()*t.length)];let c=Math.random(),u=0;for(let l=0;l<t.length;l++)if(u+=s[l]/r,c<=u)return t[l];return t[t.length-1]}function ot(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95}function Mt(t,n,s){let r=n.length,c=t.length,u="",l=0;for(;l<=c-r;){if(t.slice(l,l+r)===n){let e=l===0||!ot(t.charCodeAt(l-1)),p=l+r>=c||!ot(t.charCodeAt(l+r));if(e&&p){u+=s,l+=r;continue}}u+=t[l++]}for(;l<c;)u+=t[l++];return u}function Et(t,n){let s=[...n.entries()].sort((c,u)=>u[0].length-c[0].length),r=t;for(let[c,u]of s)r=Mt(r,c,u);return r}function Nt(t,n,s){let r=Date.now(),c=s*1e3,u=W.get(t)??[],l=u.filter(e=>r-e<=c);return l.length>=n?(W.set(t,l),!1):(l.length===0&&u.length>0&&W.delete(t),l.push(r),W.set(t,l),!0)}function M(t,n){if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let s=n.split("."),r=t;for(let c of s){if(r==null||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,c))return;r=r[c]}return r}var J=class extends Error{constructor(n){super(n),this.name="SynxError";let s=n.indexOf(":");this.code=s!==-1?n.slice(0,s):"SYNX_ERR"}};var Z=class{static parse(n,s={}){let{root:r,mode:c}=R(n);return c==="active"&&_(r,s),r}static stringify(n,s=!1){let r="";return s&&(r+=`!active
17
- `),r+=ut(n,0),r}};function ut(t,n){let s="",r=" ".repeat(n);for(let[c,u]of Object.entries(t))if(Array.isArray(u)){s+=`${r}${c}
18
- `;for(let l of u)if(l&&typeof l=="object"&&!Array.isArray(l)){let e=Object.entries(l);if(e.length>0){let[p,o]=e[0];s+=`${r} - ${p} ${o}
19
- `;for(let O=1;O<e.length;O++)s+=`${r} ${e[O][0]} ${e[O][1]}
16
+ `}function ct(t){return t==="true"?!0:t==="false"?!1:t==="null"?null:/^-?\d+$/.test(t)?parseInt(t,10):/^-?\d+\.\d+$/.test(t)?parseFloat(t):t}var Ct={space:" ",pipe:"|",dash:"-",dot:".",semi:";",tab:" ",slash:"/"};function ot(t){return Ct[t]||t}function Mt(t,n){let s=[...n];if(s.length<t.length){let l=s.reduce((p,i)=>p+i,0),e=l<100?(100-l)/(t.length-s.length):l/s.length;for(;s.length<t.length;)s.push(e)}let r=s.reduce((l,e)=>l+e,0);if(r<=0)return t[Math.floor(Math.random()*t.length)];let a=Math.random(),o=0;for(let l=0;l<t.length;l++)if(o+=s[l]/r,a<=o)return t[l];return t[t.length-1]}function lt(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===95}function Et(t,n,s){let r=n.length,a=t.length,o="",l=0;for(;l<=a-r;){if(t.slice(l,l+r)===n){let e=l===0||!lt(t.charCodeAt(l-1)),p=l+r>=a||!lt(t.charCodeAt(l+r));if(e&&p){o+=s,l+=r;continue}}o+=t[l++]}for(;l<a;)o+=t[l++];return o}function Nt(t,n){let s=[...n.entries()].sort((a,o)=>o[0].length-a[0].length),r=t;for(let[a,o]of s)r=Et(r,a,o);return r}function Rt(t,n,s){let r=Date.now(),a=s*1e3,o=q.get(t)??[],l=o.filter(e=>r-e<=a);return l.length>=n?(q.set(t,l),!1):(l.length===0&&o.length>0&&q.delete(t),l.push(r),q.set(t,l),!0)}function E(t,n){if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let s=n.split("."),r=t;for(let a of s){if(r==null||typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,a))return;r=r[a]}return r}var Z=class extends Error{constructor(n){super(n),this.name="SynxError";let s=n.indexOf(":");this.code=s!==-1?n.slice(0,s):"SYNX_ERR"}};var Q=class{static parse(n,s={}){let{root:r,mode:a}=_(n);return a==="active"&&I(r,s),r}static stringify(n,s=!1){let r="";return s&&(r+=`!active
17
+ `),r+=ft(n,0),r}};function ft(t,n){let s="",r=" ".repeat(n);for(let[a,o]of Object.entries(t))if(Array.isArray(o)){s+=`${r}${a}
18
+ `;for(let l of o)if(l&&typeof l=="object"&&!Array.isArray(l)){let e=Object.entries(l);if(e.length>0){let[p,i]=e[0];s+=`${r} - ${p} ${i}
19
+ `;for(let A=1;A<e.length;A++)s+=`${r} ${e[A][0]} ${e[A][1]}
20
20
  `}}else s+=`${r} - ${l}
21
- `}else if(u&&typeof u=="object")s+=`${r}${c}
22
- `,s+=ut(u,n+2);else if(typeof u=="string"&&u.includes(`
23
- `)){s+=`${r}${c} |
24
- `;for(let l of u.split(`
21
+ `}else if(o&&typeof o=="object")s+=`${r}${a}
22
+ `,s+=ft(o,n+2);else if(typeof o=="string"&&o.includes(`
23
+ `)){s+=`${r}${a} |
24
+ `;for(let l of o.split(`
25
25
  `))s+=`${r} ${l}
26
- `}else s+=`${r}${c} ${u}
27
- `;return s}var Ft=Z;export{Z as Synx,J as SynxError,Ft as default};
26
+ `}else s+=`${r}${a} ${o}
27
+ `;return s}var Xt=Q;export{Q as Synx,Z as SynxError,Xt as default};
28
28
  //# sourceMappingURL=synx.browser.mjs.map