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