@drincs/pixi-vn-ink 0.7.5 → 0.8.0

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.
Files changed (33) hide show
  1. package/dist/functions/choice-info-converter.cjs +3 -3
  2. package/dist/functions/choice-info-converter.js +3 -3
  3. package/dist/functions/hashtag-script.cjs +1 -1
  4. package/dist/functions/hashtag-script.js +1 -1
  5. package/dist/functions/importer.cjs +22 -22
  6. package/dist/functions/importer.js +22 -22
  7. package/dist/functions/index.cjs +22 -22
  8. package/dist/functions/index.js +22 -22
  9. package/dist/functions/ink-to-pixivn.cjs +5 -5
  10. package/dist/functions/ink-to-pixivn.js +6 -6
  11. package/dist/functions/labels-converter.cjs +3 -3
  12. package/dist/functions/labels-converter.js +3 -3
  13. package/dist/index.cjs +22 -22
  14. package/dist/index.js +22 -22
  15. package/dist/managers/HashtagScriptManager.cjs +1 -1
  16. package/dist/managers/HashtagScriptManager.js +1 -1
  17. package/dist/parser/adding-elements.cjs +2 -2
  18. package/dist/parser/adding-elements.js +2 -2
  19. package/dist/parser/arithmetic-parser.cjs +2 -2
  20. package/dist/parser/arithmetic-parser.js +2 -2
  21. package/dist/parser/conditiona-aritmetic-parser.cjs +2 -2
  22. package/dist/parser/conditiona-aritmetic-parser.js +2 -2
  23. package/dist/parser/conditional-statements-parser.cjs +3 -3
  24. package/dist/parser/conditional-statements-parser.js +3 -3
  25. package/dist/parser/label-parser.cjs +3 -3
  26. package/dist/parser/label-parser.js +3 -3
  27. package/dist/parser/switch-parser.cjs +3 -3
  28. package/dist/parser/switch-parser.js +3 -3
  29. package/dist/utility/divert-utility.cjs +1 -1
  30. package/dist/utility/divert-utility.js +1 -1
  31. package/dist/utility/value-utility.cjs +2 -2
  32. package/dist/utility/value-utility.js +2 -2
  33. package/package.json +5 -5
@@ -1,3 +1,3 @@
1
- 'use strict';require('@drincs/pixi-vn');var T="_|_";function N(i,e){if(i.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",T);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+T+"g-"+n[n.length-1]}let l=0;for(;new RegExp(/^\.\^.*$/).test(i);)l++,i=i.substring(2);if(l=l-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,l)+T+n.replaceAll(".",T)}return i.replaceAll(".",T)||_(e,l).replaceAll(".",T)}function _(i,e=0){let l=i.split(T);for(;l.length>1&&e>0;)l.pop()?.includes("g-")&&e--,e--;return l.join(T)}var w="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function C(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",w),i=i.replaceAll("\\n",`
2
- `),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(w,"\\\\"),i}var V;(r=>(r.log=(a,...u)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...u),r.warn=(a,...u)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...u),r.error=(a,...u)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...u),r.info=(a,...u)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...u)))(V||={});var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],$=["+","-","/","*","%","POW","RANDOM"],W=["INT","FLOOR","FLOAT"],H=["==",">","<",">=","<=","!=","CONTAINS"];function J(i,e,l){i=i.map(r=>{if(typeof r=="string"){if(r==="rnd")return "RANDOM";if(r==="?")return "CONTAINS"}return r});let n=[];return i.forEach(r=>{if(typeof r=="object"&&"CNT?"in r)if(new RegExp(/.*\.[0-9]\..*/).test(r["CNT?"])){let a=r["CNT?"].split("."),u=a.pop(),c=a.pop();if(c===void 0||u===void 0){V.error("Error parsing ink file: Conditional statement is not valid",i);return}let h=parseInt(c),s=a.join(".");if(s.includes("^.")){let g=s.split("."),p=g[g.length-1].replaceAll(".",T);g.pop(),s=g.join(".")+"."+p,u.includes("c-")&&(s=s+T+u);}else s=s.replaceAll(".",T);let o=N(s,e);if(!o)return;n.push({type:"compare",leftValue:q(o),operator:">=",rightValue:{type:"value",value:h}});}else {let a=N(r["CNT?"],e);if(!a)return;n.push(q(a));}else if(typeof r=="object"&&"VAR?"in r)n.push(R(r["VAR?"],l));else if(r==="&&"||r==="||"){if(n.length>=2){let a={type:"union",unionType:r==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(a);}}else if(r==="!")if(n.length===0)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=a;}else if(r&&typeof r=="string"&&H.includes(r))if(n.length<2)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"compare",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(a);}else if(r&&typeof r=="string"&&$.includes(r))if(n.length<2)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"arithmetic",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(a);}else if(r&&typeof r=="string"&&W.includes(r)){let a={type:"arithmeticsingle",operator:r,leftValue:n[n.length-1]};n.pop(),n.push(a);}else r&&typeof r=="string"?r.startsWith("^")&&n.push(C(r)):typeof r=="object"&&"^->"in r?r["^->"].includes("$r")||n.push(r["^->"]):n.push(r);}),n}function q(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function Y(i,e,l){return J(i,e,l)}function R(i,e,l="storage"){let n=e.indexOf(i);return n>=0?{type:"value",storageType:"params",storageOperationType:"get",key:n}:{type:"value",storageOperationType:"get",storageType:l,key:i}}function D(i,e,l,n="storage"){let r=e.indexOf(i);return r>=0?{type:"value",storageType:"params",storageOperationType:"set",key:r,value:l}:{type:"value",storageOperationType:"set",storageType:n,key:i,value:l}}function L(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(C(e)):typeof e=="object"&&"type"in e&&e.type!=="value"&&i.push(e));}function j(i,e,l,n=true,r=false){return Q(i,e,l,n,r)}function Q(i,e,l,n,r=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type=="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(C(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function E(i,e,l){if(i.length===0){V.error("Error parsing ink file: Arithmetic statement is not valid",i);return}let n=J(i,e,l);if(n.length===1){let r=n[0];return r&&typeof r=="object"&&"type"in r?{type:"value",storageType:"logic",storageOperationType:"get",operation:r}:r}}function O(i,e,l,n="",r,a,u=void 0){let c=[],h="sequential",s=false,o=true;i.forEach(x=>{x==="%"&&(h="loop"),x==="seq"&&(h="random"),x==="MIN"&&(s=true);});let g=i[i.length-1];return Object.keys(g).forEach(x=>{let y=g[x];if(Array.isArray(y)&&y.length>3){y=y.slice(1,y.length-2);let S=[];m(y,n,r,S,e,e,l,F,u,true,a),S.length===1?c.push(S[0]):c.push({type:"resulttocombine",combine:"cross",secondConditionalItem:S});}else Array.isArray(y)&&y.length===3&&(o=false);}),h==="sequential"?{type:"stepswitch",elements:c,choiceType:h,end:o?"lastItem":void 0,nestedId:u}:s&&h==="random"?{type:"stepswitch",elements:c,choiceType:"sequentialrandom",end:o?"lastItem":void 0,nestedId:u}:{type:"stepswitch",elements:c,choiceType:h}}function m(i,e,l,n=[],r,a,u,c,h=void 0,s=true,o=[]){let g=false,p=[],x=false,y=false,S=[],b=[];if(l.preDialog[e]&&(s=false,r(n,"^"+l.preDialog[e].text,e,o,s,y),l.preDialog[e].glue&&r(n,"<>",e,o,s,y),delete l.preDialog[e]),i.includes("visit")){let t=O(i,a,u,e,l,o,h);t&&(!s&&n.length>0&&r(n,"<>",e,o,s,y),r(n,t,e,o,s,y));return}let v=i[0];if(v&&typeof v=="object"&&"temp="in v){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)o.push(i[0]["temp="]),i.shift();o=o.reverse();}if(i.forEach((t,P)=>{if(y){if(typeof t=="string"&&t=="/#"){let f=[];m(b,e,l,f,j,j,u,c,h,s),r(n,f,e,o,s,y),y=false,b=[];}else b.push(t);return}else if(g)if(Array.isArray(t))p.push(t);else if(t&&typeof t=="object")if("CNT?"in t)P>0&&i[P-1]=="ev"?(x=true,S.push(t)):x?S.push(t):(p.push(t),s=false);else if("VAR="in t||"temp="in t){let f=D("VAR="in t?t["VAR="]:t["temp="],o,i[P-1],"VAR="in t?"storage":"tempstorage");if(f.value&&typeof f.value=="string"&&f.value=="/str"&&(f.value=i[P-2]),f.value&&typeof f.value=="object"&&"^->"in f.value&&(f.value=f.value["^->"]),p.length>1){let d=E(p,e,o);p=[],d&&typeof d=="object"&&"type"in d&&d.type=="value"&&"storageType"in d&&d.storageType=="logic"&&(f.value=d.operation);}(typeof f.key!="string"||!f.key.includes("$r"))&&(r(n,f,e,o,s,y),s=true);}else "VAR?"in t?p.push(t):"^->"in t&&(t["^->"].includes("$r")||p.push(t));else if(typeof t=="string"&&t=="/ev")x&&S.push(t),g=false,p.push(t);else if(typeof t=="string"&&t=="out"){if(p.length>0){let f=p[p.length-1];if(f&&typeof f=="object"&&"VAR?"in f){p.pop();let d=R(f["VAR?"],o,"storage");r(n,d,e,o,s,y);}else {let d=[];for(;p.length>0&&p[p.length-1]!="/ev";)d.push(p.pop());d=d.reverse();let A=E(d,e,o);p=[],A&&typeof A=="object"&&"type"in A&&A.type=="value"&&"storageType"in A&&A.storageType=="logic"?r(n,{storageOperationType:"get",storageType:"logic",operation:A.operation,type:"value"},e,o,s,y):(r(n,"<>",e,o,s,y),A=`^${A}`,r(n,A,e,o,s,y));}s=false;}}else p.push(t);else if(typeof t=="string")if(t.startsWith("^"))r(n,t,e,o,s,y),s=false;else if(t=="ev")g=true;else if(t==`
3
- `)s=true;else if(t=="done"||t=="end")r(n,t,e,o,s,y),s=false;else if(t=="<>")r(n,t,e,o,s,y),s=false;else if(t=="nop"&&x){let f=U(S,a,u,e,l,o,h);f&&r(n,f,e,o,s,y),x=false,S=[];}else t=="#"&&(y=true);else if(t instanceof Array)if(x)S.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){p.pop();let f=[],d=[];for(;p.length>0&&p[p.length-1]!="/ev";)f.push(p.pop());S=[...S,...f.reverse()],x=true,d.push(t.pop()),d.push(t.pop()),S=[...S,...t],S.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let f=t.pop();if(!f){V.error("Error parsing ink file: el is undefined");return}let d=f["#n"];delete f["#n"],t.push(f),r(n,{"->":e?e+T+d:d},e,o,s,y),u({[d]:t},e,l);}else m(t,e,l,n,r,a,u,c,h,s);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let f=[];p.length>0&&(f=Y(["ev",...p],e,o)),t.params=f,r(n,t,e,o,s,y),s=false;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(p.push(t),s=false);else if("s"in t&&t.s instanceof Array)p.push(t),s=false;else if("CNT?"in t)p.push(t),s=false;else if("VAR="in t||"temp="in t){let f=[],d=D("VAR="in t?t["VAR="]:t["temp="],o,void 0,"VAR="in t?"storage":"tempstorage");if(d.key!=="$r"){for(p.pop(),p[p.length-1]=="/ev"&&p.pop();p.length>0&&p[p.length-1]!="/ev";)f.push(p.pop());f=f.reverse(),d.value=E(f,e,o),p=[],(d.value!==void 0||d.value!==null)&&r(n,d,e,o,s,y),s=false;}}else u(t,e,l);}),c(p,n,e,l,o),e.includes(T)&&n.length==2){let t=n[0],P=n[1];t&&P&&typeof t=="object"&&"dialogue"in t&&typeof P=="object"&&"labelToOpen"in P&&t.dialogue==" "&&P.labelToOpen&&(n.shift(),delete P.glueEnabled,n[0]=P);}}function M(i,e,l,n,r){if(e.length===0)return;let a=J(e,n,l);if(a.length===1){let u={type:"ifelse",condition:a[0],then:i,else:r};return u.else||delete u.else,u}else if(a.length>1){let u={type:"ifelse",condition:{type:"union",unionType:"and",conditions:a},then:i,else:r};return u.else||delete u.else,u}}function U(i,e,l,n,r,a,u=void 0){if(i.length===0){V.error("Error parsing ink file: Conditional statement is not valid",i);return}let c=[],h=[];if(i.forEach(g=>{Array.isArray(g)?h.push(g):typeof g=="string"&&g==="du"?r.du?c.push(r.du):r.du=c[c.length-1]:(typeof g!="string"||g!=="/ev")&&c.push(g);}),h.length===0){V.error("Error parsing ink file: Conditional statement is not valid",h);return}let s=k(h[0],e,l,n+T+"then",r,a,`${u||""}then`),o;return h.length===2?o=k(h[1],e,l,n+T+"else",r,a,`${u||""}else`):h.length>2&&(h.shift(),h.push("nop"),h=[{b:h}],o=k(h,e,l,n+T+"else",r,a,`${u||""}else`)),r.du=void 0,M(s,c,a,n,o)}function k(i,e,l,n,r,a,u=void 0){let c=[];for(let s of i)typeof s=="object"&&"b"in s&&(s.b=s.b.filter(o=>o!==null&&!(typeof o=="object"&&"->"in o&&new RegExp(/.*\.[0-9]/).test(o["->"]))),m(s.b,n,r,c,e,e,l,F,u,true,a));return c.length===1?c[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:c}}function B(i="",e=""){let l=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...l,...n])]}function F(i,e,l,n,r){if(i.length>0){let a={};X(i,a,r);for(let[u,c]of Object.entries(a)){let h=l+T+u,s={text:c.text.length===1?c.text[0]:c.text,label:h,props:{},type:"jump",oneTime:c.onetime};c.text.length===0&&(s.onlyHaveNoChoice=true,s.autoSelect=true),s.oneTime===false&&delete s.oneTime;let o=M(s,c.conditions,r,l)||s,g=e[e.length-1];if(typeof g=="object"&&g&&"type"in g&&(g={conditionalStep:g}),e.length>0&&typeof g=="object"&&g&&"choices"in g&&g.choices){let p=g.choices;p&&Array.isArray(p)?p.push(o):V.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",c,p),g.choices=p.sort((x,y)=>{try{let S=x.label.split("."),b=S[S.length-1].replaceAll(".",T),v=y.label.split("."),t=v[v.length-1].replaceAll(".",T);if(b.includes("c-")&&t.includes("c-")){let P=b.split("c-")[1],f=parseInt(P),d=t.split("c-")[1],A=parseInt(d);return f-A}}catch{}return 0});}else e.push({choices:[o]});c.preDialog&&(n.preDialog[h]={...c.preDialog});}}}function X(i,e,l,n){let r=[],a="",u="",c=false,h=[];for(let s=0;s<i.length;s++){let o=i[s];if(typeof o=="string")o.startsWith("^")?r.push(C(o)):G.includes(o)&&h.push(o);else if(Array.isArray(o)&&o.includes("visit")){let g=O(o,L,(p,x,y)=>{},n,{preDialog:{}},l);r.push(g);}else if(o&&typeof o=="object")if("*"in o&&typeof o["*"]&&typeof o["*"]=="string")o["*"].includes("c")&&(a="c"+o["*"].split("c")[1],o.flg&16&&(c=true));else if("s"in o&&o.s instanceof Array){let g=z(o.s),p=o.s.includes("<>");g&&(n&&e[n]?(e[n].preDialog={text:g,glue:p},e[n].text=B(g,e[n].text)):(r.push(g),u=g));}else "CNT?"in o&&h.push(o);else h.push(o);if(a){e[a]?e[a].text=B(r,e[a].text):e[a]={text:r,onetime:c,conditions:h},u&&(e[a].preDialog={text:u,glue:false});let g=i.slice(s+1);X(g,e,l,a);return}}}function z(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return C(e)}else if(e instanceof Array){let l=z(e);if(l)return l}}exports.addChoiseIntoList=F;exports.getLabelChoice=X;
1
+ 'use strict';require('@drincs/pixi-vn');function N(i,e){if(i.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+"_|_"+"g-"+n[n.length-1]}let l=0;for(;new RegExp(/^\.\^.*$/).test(i);)l++,i=i.substring(2);if(l=l-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,l)+"_|_"+n.replaceAll(".","_|_")}return i.replaceAll(".","_|_")||_(e,l).replaceAll(".","_|_")}function _(i,e=0){let l=i.split("_|_");for(;l.length>1&&e>0;)l.pop()?.includes("g-")&&e--,e--;return l.join("_|_")}var B="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function C(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",B),i=i.replaceAll("\\n",`
2
+ `),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(B,"\\\\"),i}var V;(r=>(r.log=(a,...u)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...u),r.warn=(a,...u)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...u),r.error=(a,...u)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...u),r.info=(a,...u)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...u)))(V||={});var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],$=["+","-","/","*","%","POW","RANDOM"],W=["INT","FLOOR","FLOAT"],H=["==",">","<",">=","<=","!=","CONTAINS"];function J(i,e,l){i=i.map(r=>{if(typeof r=="string"){if(r==="rnd")return "RANDOM";if(r==="?")return "CONTAINS"}return r});let n=[];return i.forEach(r=>{if(typeof r=="object"&&"CNT?"in r)if(new RegExp(/.*\.[0-9]\..*/).test(r["CNT?"])){let a=r["CNT?"].split("."),u=a.pop(),c=a.pop();if(c===void 0||u===void 0){V.error("Error parsing ink file: Conditional statement is not valid",i);return}let h=parseInt(c),s=a.join(".");if(s.includes("^.")){let g=s.split("."),p=g[g.length-1].replaceAll(".","_|_");g.pop(),s=g.join(".")+"."+p,u.includes("c-")&&(s=s+"_|_"+u);}else s=s.replaceAll(".","_|_");let o=N(s,e);if(!o)return;n.push({type:"compare",leftValue:q(o),operator:">=",rightValue:{type:"value",value:h}});}else {let a=N(r["CNT?"],e);if(!a)return;n.push(q(a));}else if(typeof r=="object"&&"VAR?"in r)n.push(R(r["VAR?"],l));else if(r==="&&"||r==="||"){if(n.length>=2){let a={type:"union",unionType:r==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(a);}}else if(r==="!")if(n.length===0)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=a;}else if(r&&typeof r=="string"&&H.includes(r))if(n.length<2)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"compare",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(a);}else if(r&&typeof r=="string"&&$.includes(r))if(n.length<2)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"arithmetic",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(a);}else if(r&&typeof r=="string"&&W.includes(r)){let a={type:"arithmeticsingle",operator:r,leftValue:n[n.length-1]};n.pop(),n.push(a);}else r&&typeof r=="string"?r.startsWith("^")&&n.push(C(r)):typeof r=="object"&&"^->"in r?r["^->"].includes("$r")||n.push(r["^->"]):n.push(r);}),n}function q(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function Y(i,e,l){return J(i,e,l)}function R(i,e,l="storage"){let n=e.indexOf(i);return n>=0?{type:"value",storageType:"params",storageOperationType:"get",key:n}:{type:"value",storageOperationType:"get",storageType:l,key:i}}function D(i,e,l,n="storage"){let r=e.indexOf(i);return r>=0?{type:"value",storageType:"params",storageOperationType:"set",key:r,value:l}:{type:"value",storageOperationType:"set",storageType:n,key:i,value:l}}function L(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(C(e)):typeof e=="object"&&"type"in e&&e.type!=="value"&&i.push(e));}function j(i,e,l,n=true,r=false){return Q(i,e,l,n,r)}function Q(i,e,l,n,r=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type=="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(C(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function E(i,e,l){if(i.length===0){V.error("Error parsing ink file: Arithmetic statement is not valid",i);return}let n=J(i,e,l);if(n.length===1){let r=n[0];return r&&typeof r=="object"&&"type"in r?{type:"value",storageType:"logic",storageOperationType:"get",operation:r}:r}}function O(i,e,l,n="",r,a,u=void 0){let c=[],h="sequential",s=false,o=true;i.forEach(x=>{x==="%"&&(h="loop"),x==="seq"&&(h="random"),x==="MIN"&&(s=true);});let g=i[i.length-1];return Object.keys(g).forEach(x=>{let y=g[x];if(Array.isArray(y)&&y.length>3){y=y.slice(1,y.length-2);let S=[];m(y,n,r,S,e,e,l,F,u,true,a),S.length===1?c.push(S[0]):c.push({type:"resulttocombine",combine:"cross",secondConditionalItem:S});}else Array.isArray(y)&&y.length===3&&(o=false);}),h==="sequential"?{type:"stepswitch",elements:c,choiceType:h,end:o?"lastItem":void 0,nestedId:u}:s&&h==="random"?{type:"stepswitch",elements:c,choiceType:"sequentialrandom",end:o?"lastItem":void 0,nestedId:u}:{type:"stepswitch",elements:c,choiceType:h}}function m(i,e,l,n=[],r,a,u,c,h=void 0,s=true,o=[]){let g=false,p=[],x=false,y=false,S=[],b=[];if(l.preDialog[e]&&(s=false,r(n,"^"+l.preDialog[e].text,e,o,s,y),l.preDialog[e].glue&&r(n,"<>",e,o,s,y),delete l.preDialog[e]),i.includes("visit")){let t=O(i,a,u,e,l,o,h);t&&(!s&&n.length>0&&r(n,"<>",e,o,s,y),r(n,t,e,o,s,y));return}let v=i[0];if(v&&typeof v=="object"&&"temp="in v){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)o.push(i[0]["temp="]),i.shift();o=o.reverse();}if(i.forEach((t,P)=>{if(y){if(typeof t=="string"&&t=="/#"){let f=[];m(b,e,l,f,j,j,u,c,h,s),r(n,f,e,o,s,y),y=false,b=[];}else b.push(t);return}else if(g)if(Array.isArray(t))p.push(t);else if(t&&typeof t=="object")if("CNT?"in t)P>0&&i[P-1]=="ev"?(x=true,S.push(t)):x?S.push(t):(p.push(t),s=false);else if("VAR="in t||"temp="in t){let f=D("VAR="in t?t["VAR="]:t["temp="],o,i[P-1],"VAR="in t?"storage":"tempstorage");if(f.value&&typeof f.value=="string"&&f.value=="/str"&&(f.value=i[P-2]),f.value&&typeof f.value=="object"&&"^->"in f.value&&(f.value=f.value["^->"]),p.length>1){let d=E(p,e,o);p=[],d&&typeof d=="object"&&"type"in d&&d.type=="value"&&"storageType"in d&&d.storageType=="logic"&&(f.value=d.operation);}(typeof f.key!="string"||!f.key.includes("$r"))&&(r(n,f,e,o,s,y),s=true);}else "VAR?"in t?p.push(t):"^->"in t&&(t["^->"].includes("$r")||p.push(t));else if(typeof t=="string"&&t=="/ev")x&&S.push(t),g=false,p.push(t);else if(typeof t=="string"&&t=="out"){if(p.length>0){let f=p[p.length-1];if(f&&typeof f=="object"&&"VAR?"in f){p.pop();let d=R(f["VAR?"],o,"storage");r(n,d,e,o,s,y);}else {let d=[];for(;p.length>0&&p[p.length-1]!="/ev";)d.push(p.pop());d=d.reverse();let A=E(d,e,o);p=[],A&&typeof A=="object"&&"type"in A&&A.type=="value"&&"storageType"in A&&A.storageType=="logic"?r(n,{storageOperationType:"get",storageType:"logic",operation:A.operation,type:"value"},e,o,s,y):(r(n,"<>",e,o,s,y),A=`^${A}`,r(n,A,e,o,s,y));}s=false;}}else p.push(t);else if(typeof t=="string")if(t.startsWith("^"))r(n,t,e,o,s,y),s=false;else if(t=="ev")g=true;else if(t==`
3
+ `)s=true;else if(t=="done"||t=="end")r(n,t,e,o,s,y),s=false;else if(t=="<>")r(n,t,e,o,s,y),s=false;else if(t=="nop"&&x){let f=U(S,a,u,e,l,o,h);f&&r(n,f,e,o,s,y),x=false,S=[];}else t=="#"&&(y=true);else if(t instanceof Array)if(x)S.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){p.pop();let f=[],d=[];for(;p.length>0&&p[p.length-1]!="/ev";)f.push(p.pop());S=[...S,...f.reverse()],x=true,d.push(t.pop()),d.push(t.pop()),S=[...S,...t],S.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let f=t.pop();if(!f){V.error("Error parsing ink file: el is undefined");return}let d=f["#n"];delete f["#n"],t.push(f),r(n,{"->":e?e+"_|_"+d:d},e,o,s,y),u({[d]:t},e,l);}else m(t,e,l,n,r,a,u,c,h,s);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let f=[];p.length>0&&(f=Y(["ev",...p],e,o)),t.params=f,r(n,t,e,o,s,y),s=false;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(p.push(t),s=false);else if("s"in t&&t.s instanceof Array)p.push(t),s=false;else if("CNT?"in t)p.push(t),s=false;else if("VAR="in t||"temp="in t){let f=[],d=D("VAR="in t?t["VAR="]:t["temp="],o,void 0,"VAR="in t?"storage":"tempstorage");if(d.key!=="$r"){for(p.pop(),p[p.length-1]=="/ev"&&p.pop();p.length>0&&p[p.length-1]!="/ev";)f.push(p.pop());f=f.reverse(),d.value=E(f,e,o),p=[],(d.value!==void 0||d.value!==null)&&r(n,d,e,o,s,y),s=false;}}else u(t,e,l);}),c(p,n,e,l,o),e.includes("_|_")&&n.length==2){let t=n[0],P=n[1];t&&P&&typeof t=="object"&&"dialogue"in t&&typeof P=="object"&&"labelToOpen"in P&&t.dialogue==" "&&P.labelToOpen&&(n.shift(),delete P.glueEnabled,n[0]=P);}}function M(i,e,l,n,r){if(e.length===0)return;let a=J(e,n,l);if(a.length===1){let u={type:"ifelse",condition:a[0],then:i,else:r};return u.else||delete u.else,u}else if(a.length>1){let u={type:"ifelse",condition:{type:"union",unionType:"and",conditions:a},then:i,else:r};return u.else||delete u.else,u}}function U(i,e,l,n,r,a,u=void 0){if(i.length===0){V.error("Error parsing ink file: Conditional statement is not valid",i);return}let c=[],h=[];if(i.forEach(g=>{Array.isArray(g)?h.push(g):typeof g=="string"&&g==="du"?r.du?c.push(r.du):r.du=c[c.length-1]:(typeof g!="string"||g!=="/ev")&&c.push(g);}),h.length===0){V.error("Error parsing ink file: Conditional statement is not valid",h);return}let s=k(h[0],e,l,n+"_|_"+"then",r,a,`${u||""}then`),o;return h.length===2?o=k(h[1],e,l,n+"_|_"+"else",r,a,`${u||""}else`):h.length>2&&(h.shift(),h.push("nop"),h=[{b:h}],o=k(h,e,l,n+"_|_"+"else",r,a,`${u||""}else`)),r.du=void 0,M(s,c,a,n,o)}function k(i,e,l,n,r,a,u=void 0){let c=[];for(let s of i)typeof s=="object"&&"b"in s&&(s.b=s.b.filter(o=>o!==null&&!(typeof o=="object"&&"->"in o&&new RegExp(/.*\.[0-9]/).test(o["->"]))),m(s.b,n,r,c,e,e,l,F,u,true,a));return c.length===1?c[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:c}}function w(i="",e=""){let l=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...l,...n])]}function F(i,e,l,n,r){if(i.length>0){let a={};X(i,a,r);for(let[u,c]of Object.entries(a)){let h=l+"_|_"+u,s={text:c.text.length===1?c.text[0]:c.text,label:h,props:{},type:"jump",oneTime:c.onetime};c.text.length===0&&(s.onlyHaveNoChoice=true,s.autoSelect=true),s.oneTime===false&&delete s.oneTime;let o=M(s,c.conditions,r,l)||s,g=e[e.length-1];if(typeof g=="object"&&g&&"type"in g&&(g={conditionalStep:g}),e.length>0&&typeof g=="object"&&g&&"choices"in g&&g.choices){let p=g.choices;p&&Array.isArray(p)?p.push(o):V.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",c,p),g.choices=p.sort((x,y)=>{try{let S=x.label.split("."),b=S[S.length-1].replaceAll(".","_|_"),v=y.label.split("."),t=v[v.length-1].replaceAll(".","_|_");if(b.includes("c-")&&t.includes("c-")){let P=b.split("c-")[1],f=parseInt(P),d=t.split("c-")[1],A=parseInt(d);return f-A}}catch{}return 0});}else e.push({choices:[o]});c.preDialog&&(n.preDialog[h]={...c.preDialog});}}}function X(i,e,l,n){let r=[],a="",u="",c=false,h=[];for(let s=0;s<i.length;s++){let o=i[s];if(typeof o=="string")o.startsWith("^")?r.push(C(o)):G.includes(o)&&h.push(o);else if(Array.isArray(o)&&o.includes("visit")){let g=O(o,L,(p,x,y)=>{},n,{preDialog:{}},l);r.push(g);}else if(o&&typeof o=="object")if("*"in o&&typeof o["*"]&&typeof o["*"]=="string")o["*"].includes("c")&&(a="c"+o["*"].split("c")[1],o.flg&16&&(c=true));else if("s"in o&&o.s instanceof Array){let g=z(o.s),p=o.s.includes("<>");g&&(n&&e[n]?(e[n].preDialog={text:g,glue:p},e[n].text=w(g,e[n].text)):(r.push(g),u=g));}else "CNT?"in o&&h.push(o);else h.push(o);if(a){e[a]?e[a].text=w(r,e[a].text):e[a]={text:r,onetime:c,conditions:h},u&&(e[a].preDialog={text:u,glue:false});let g=i.slice(s+1);X(g,e,l,a);return}}}function z(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return C(e)}else if(e instanceof Array){let l=z(e);if(l)return l}}exports.addChoiseIntoList=F;exports.getLabelChoice=X;
@@ -1,3 +1,3 @@
1
- import'@drincs/pixi-vn';var T="_|_";function N(i,e){if(i.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",T);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+T+"g-"+n[n.length-1]}let l=0;for(;new RegExp(/^\.\^.*$/).test(i);)l++,i=i.substring(2);if(l=l-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,l)+T+n.replaceAll(".",T)}return i.replaceAll(".",T)||_(e,l).replaceAll(".",T)}function _(i,e=0){let l=i.split(T);for(;l.length>1&&e>0;)l.pop()?.includes("g-")&&e--,e--;return l.join(T)}var w="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function C(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",w),i=i.replaceAll("\\n",`
2
- `),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(w,"\\\\"),i}var V;(r=>(r.log=(a,...u)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...u),r.warn=(a,...u)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...u),r.error=(a,...u)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...u),r.info=(a,...u)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...u)))(V||={});var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],$=["+","-","/","*","%","POW","RANDOM"],W=["INT","FLOOR","FLOAT"],H=["==",">","<",">=","<=","!=","CONTAINS"];function J(i,e,l){i=i.map(r=>{if(typeof r=="string"){if(r==="rnd")return "RANDOM";if(r==="?")return "CONTAINS"}return r});let n=[];return i.forEach(r=>{if(typeof r=="object"&&"CNT?"in r)if(new RegExp(/.*\.[0-9]\..*/).test(r["CNT?"])){let a=r["CNT?"].split("."),u=a.pop(),c=a.pop();if(c===void 0||u===void 0){V.error("Error parsing ink file: Conditional statement is not valid",i);return}let h=parseInt(c),s=a.join(".");if(s.includes("^.")){let g=s.split("."),p=g[g.length-1].replaceAll(".",T);g.pop(),s=g.join(".")+"."+p,u.includes("c-")&&(s=s+T+u);}else s=s.replaceAll(".",T);let o=N(s,e);if(!o)return;n.push({type:"compare",leftValue:q(o),operator:">=",rightValue:{type:"value",value:h}});}else {let a=N(r["CNT?"],e);if(!a)return;n.push(q(a));}else if(typeof r=="object"&&"VAR?"in r)n.push(R(r["VAR?"],l));else if(r==="&&"||r==="||"){if(n.length>=2){let a={type:"union",unionType:r==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(a);}}else if(r==="!")if(n.length===0)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=a;}else if(r&&typeof r=="string"&&H.includes(r))if(n.length<2)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"compare",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(a);}else if(r&&typeof r=="string"&&$.includes(r))if(n.length<2)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"arithmetic",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(a);}else if(r&&typeof r=="string"&&W.includes(r)){let a={type:"arithmeticsingle",operator:r,leftValue:n[n.length-1]};n.pop(),n.push(a);}else r&&typeof r=="string"?r.startsWith("^")&&n.push(C(r)):typeof r=="object"&&"^->"in r?r["^->"].includes("$r")||n.push(r["^->"]):n.push(r);}),n}function q(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function Y(i,e,l){return J(i,e,l)}function R(i,e,l="storage"){let n=e.indexOf(i);return n>=0?{type:"value",storageType:"params",storageOperationType:"get",key:n}:{type:"value",storageOperationType:"get",storageType:l,key:i}}function D(i,e,l,n="storage"){let r=e.indexOf(i);return r>=0?{type:"value",storageType:"params",storageOperationType:"set",key:r,value:l}:{type:"value",storageOperationType:"set",storageType:n,key:i,value:l}}function L(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(C(e)):typeof e=="object"&&"type"in e&&e.type!=="value"&&i.push(e));}function j(i,e,l,n=true,r=false){return Q(i,e,l,n,r)}function Q(i,e,l,n,r=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type=="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(C(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function E(i,e,l){if(i.length===0){V.error("Error parsing ink file: Arithmetic statement is not valid",i);return}let n=J(i,e,l);if(n.length===1){let r=n[0];return r&&typeof r=="object"&&"type"in r?{type:"value",storageType:"logic",storageOperationType:"get",operation:r}:r}}function O(i,e,l,n="",r,a,u=void 0){let c=[],h="sequential",s=false,o=true;i.forEach(x=>{x==="%"&&(h="loop"),x==="seq"&&(h="random"),x==="MIN"&&(s=true);});let g=i[i.length-1];return Object.keys(g).forEach(x=>{let y=g[x];if(Array.isArray(y)&&y.length>3){y=y.slice(1,y.length-2);let S=[];m(y,n,r,S,e,e,l,F,u,true,a),S.length===1?c.push(S[0]):c.push({type:"resulttocombine",combine:"cross",secondConditionalItem:S});}else Array.isArray(y)&&y.length===3&&(o=false);}),h==="sequential"?{type:"stepswitch",elements:c,choiceType:h,end:o?"lastItem":void 0,nestedId:u}:s&&h==="random"?{type:"stepswitch",elements:c,choiceType:"sequentialrandom",end:o?"lastItem":void 0,nestedId:u}:{type:"stepswitch",elements:c,choiceType:h}}function m(i,e,l,n=[],r,a,u,c,h=void 0,s=true,o=[]){let g=false,p=[],x=false,y=false,S=[],b=[];if(l.preDialog[e]&&(s=false,r(n,"^"+l.preDialog[e].text,e,o,s,y),l.preDialog[e].glue&&r(n,"<>",e,o,s,y),delete l.preDialog[e]),i.includes("visit")){let t=O(i,a,u,e,l,o,h);t&&(!s&&n.length>0&&r(n,"<>",e,o,s,y),r(n,t,e,o,s,y));return}let v=i[0];if(v&&typeof v=="object"&&"temp="in v){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)o.push(i[0]["temp="]),i.shift();o=o.reverse();}if(i.forEach((t,P)=>{if(y){if(typeof t=="string"&&t=="/#"){let f=[];m(b,e,l,f,j,j,u,c,h,s),r(n,f,e,o,s,y),y=false,b=[];}else b.push(t);return}else if(g)if(Array.isArray(t))p.push(t);else if(t&&typeof t=="object")if("CNT?"in t)P>0&&i[P-1]=="ev"?(x=true,S.push(t)):x?S.push(t):(p.push(t),s=false);else if("VAR="in t||"temp="in t){let f=D("VAR="in t?t["VAR="]:t["temp="],o,i[P-1],"VAR="in t?"storage":"tempstorage");if(f.value&&typeof f.value=="string"&&f.value=="/str"&&(f.value=i[P-2]),f.value&&typeof f.value=="object"&&"^->"in f.value&&(f.value=f.value["^->"]),p.length>1){let d=E(p,e,o);p=[],d&&typeof d=="object"&&"type"in d&&d.type=="value"&&"storageType"in d&&d.storageType=="logic"&&(f.value=d.operation);}(typeof f.key!="string"||!f.key.includes("$r"))&&(r(n,f,e,o,s,y),s=true);}else "VAR?"in t?p.push(t):"^->"in t&&(t["^->"].includes("$r")||p.push(t));else if(typeof t=="string"&&t=="/ev")x&&S.push(t),g=false,p.push(t);else if(typeof t=="string"&&t=="out"){if(p.length>0){let f=p[p.length-1];if(f&&typeof f=="object"&&"VAR?"in f){p.pop();let d=R(f["VAR?"],o,"storage");r(n,d,e,o,s,y);}else {let d=[];for(;p.length>0&&p[p.length-1]!="/ev";)d.push(p.pop());d=d.reverse();let A=E(d,e,o);p=[],A&&typeof A=="object"&&"type"in A&&A.type=="value"&&"storageType"in A&&A.storageType=="logic"?r(n,{storageOperationType:"get",storageType:"logic",operation:A.operation,type:"value"},e,o,s,y):(r(n,"<>",e,o,s,y),A=`^${A}`,r(n,A,e,o,s,y));}s=false;}}else p.push(t);else if(typeof t=="string")if(t.startsWith("^"))r(n,t,e,o,s,y),s=false;else if(t=="ev")g=true;else if(t==`
3
- `)s=true;else if(t=="done"||t=="end")r(n,t,e,o,s,y),s=false;else if(t=="<>")r(n,t,e,o,s,y),s=false;else if(t=="nop"&&x){let f=U(S,a,u,e,l,o,h);f&&r(n,f,e,o,s,y),x=false,S=[];}else t=="#"&&(y=true);else if(t instanceof Array)if(x)S.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){p.pop();let f=[],d=[];for(;p.length>0&&p[p.length-1]!="/ev";)f.push(p.pop());S=[...S,...f.reverse()],x=true,d.push(t.pop()),d.push(t.pop()),S=[...S,...t],S.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let f=t.pop();if(!f){V.error("Error parsing ink file: el is undefined");return}let d=f["#n"];delete f["#n"],t.push(f),r(n,{"->":e?e+T+d:d},e,o,s,y),u({[d]:t},e,l);}else m(t,e,l,n,r,a,u,c,h,s);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let f=[];p.length>0&&(f=Y(["ev",...p],e,o)),t.params=f,r(n,t,e,o,s,y),s=false;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(p.push(t),s=false);else if("s"in t&&t.s instanceof Array)p.push(t),s=false;else if("CNT?"in t)p.push(t),s=false;else if("VAR="in t||"temp="in t){let f=[],d=D("VAR="in t?t["VAR="]:t["temp="],o,void 0,"VAR="in t?"storage":"tempstorage");if(d.key!=="$r"){for(p.pop(),p[p.length-1]=="/ev"&&p.pop();p.length>0&&p[p.length-1]!="/ev";)f.push(p.pop());f=f.reverse(),d.value=E(f,e,o),p=[],(d.value!==void 0||d.value!==null)&&r(n,d,e,o,s,y),s=false;}}else u(t,e,l);}),c(p,n,e,l,o),e.includes(T)&&n.length==2){let t=n[0],P=n[1];t&&P&&typeof t=="object"&&"dialogue"in t&&typeof P=="object"&&"labelToOpen"in P&&t.dialogue==" "&&P.labelToOpen&&(n.shift(),delete P.glueEnabled,n[0]=P);}}function M(i,e,l,n,r){if(e.length===0)return;let a=J(e,n,l);if(a.length===1){let u={type:"ifelse",condition:a[0],then:i,else:r};return u.else||delete u.else,u}else if(a.length>1){let u={type:"ifelse",condition:{type:"union",unionType:"and",conditions:a},then:i,else:r};return u.else||delete u.else,u}}function U(i,e,l,n,r,a,u=void 0){if(i.length===0){V.error("Error parsing ink file: Conditional statement is not valid",i);return}let c=[],h=[];if(i.forEach(g=>{Array.isArray(g)?h.push(g):typeof g=="string"&&g==="du"?r.du?c.push(r.du):r.du=c[c.length-1]:(typeof g!="string"||g!=="/ev")&&c.push(g);}),h.length===0){V.error("Error parsing ink file: Conditional statement is not valid",h);return}let s=k(h[0],e,l,n+T+"then",r,a,`${u||""}then`),o;return h.length===2?o=k(h[1],e,l,n+T+"else",r,a,`${u||""}else`):h.length>2&&(h.shift(),h.push("nop"),h=[{b:h}],o=k(h,e,l,n+T+"else",r,a,`${u||""}else`)),r.du=void 0,M(s,c,a,n,o)}function k(i,e,l,n,r,a,u=void 0){let c=[];for(let s of i)typeof s=="object"&&"b"in s&&(s.b=s.b.filter(o=>o!==null&&!(typeof o=="object"&&"->"in o&&new RegExp(/.*\.[0-9]/).test(o["->"]))),m(s.b,n,r,c,e,e,l,F,u,true,a));return c.length===1?c[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:c}}function B(i="",e=""){let l=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...l,...n])]}function F(i,e,l,n,r){if(i.length>0){let a={};X(i,a,r);for(let[u,c]of Object.entries(a)){let h=l+T+u,s={text:c.text.length===1?c.text[0]:c.text,label:h,props:{},type:"jump",oneTime:c.onetime};c.text.length===0&&(s.onlyHaveNoChoice=true,s.autoSelect=true),s.oneTime===false&&delete s.oneTime;let o=M(s,c.conditions,r,l)||s,g=e[e.length-1];if(typeof g=="object"&&g&&"type"in g&&(g={conditionalStep:g}),e.length>0&&typeof g=="object"&&g&&"choices"in g&&g.choices){let p=g.choices;p&&Array.isArray(p)?p.push(o):V.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",c,p),g.choices=p.sort((x,y)=>{try{let S=x.label.split("."),b=S[S.length-1].replaceAll(".",T),v=y.label.split("."),t=v[v.length-1].replaceAll(".",T);if(b.includes("c-")&&t.includes("c-")){let P=b.split("c-")[1],f=parseInt(P),d=t.split("c-")[1],A=parseInt(d);return f-A}}catch{}return 0});}else e.push({choices:[o]});c.preDialog&&(n.preDialog[h]={...c.preDialog});}}}function X(i,e,l,n){let r=[],a="",u="",c=false,h=[];for(let s=0;s<i.length;s++){let o=i[s];if(typeof o=="string")o.startsWith("^")?r.push(C(o)):G.includes(o)&&h.push(o);else if(Array.isArray(o)&&o.includes("visit")){let g=O(o,L,(p,x,y)=>{},n,{preDialog:{}},l);r.push(g);}else if(o&&typeof o=="object")if("*"in o&&typeof o["*"]&&typeof o["*"]=="string")o["*"].includes("c")&&(a="c"+o["*"].split("c")[1],o.flg&16&&(c=true));else if("s"in o&&o.s instanceof Array){let g=z(o.s),p=o.s.includes("<>");g&&(n&&e[n]?(e[n].preDialog={text:g,glue:p},e[n].text=B(g,e[n].text)):(r.push(g),u=g));}else "CNT?"in o&&h.push(o);else h.push(o);if(a){e[a]?e[a].text=B(r,e[a].text):e[a]={text:r,onetime:c,conditions:h},u&&(e[a].preDialog={text:u,glue:false});let g=i.slice(s+1);X(g,e,l,a);return}}}function z(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return C(e)}else if(e instanceof Array){let l=z(e);if(l)return l}}export{F as addChoiseIntoList,X as getLabelChoice};
1
+ import'@drincs/pixi-vn';function N(i,e){if(i.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+"_|_"+"g-"+n[n.length-1]}let l=0;for(;new RegExp(/^\.\^.*$/).test(i);)l++,i=i.substring(2);if(l=l-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,l)+"_|_"+n.replaceAll(".","_|_")}return i.replaceAll(".","_|_")||_(e,l).replaceAll(".","_|_")}function _(i,e=0){let l=i.split("_|_");for(;l.length>1&&e>0;)l.pop()?.includes("g-")&&e--,e--;return l.join("_|_")}var B="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function C(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",B),i=i.replaceAll("\\n",`
2
+ `),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(B,"\\\\"),i}var V;(r=>(r.log=(a,...u)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...u),r.warn=(a,...u)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...u),r.error=(a,...u)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...u),r.info=(a,...u)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...u)))(V||={});var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],$=["+","-","/","*","%","POW","RANDOM"],W=["INT","FLOOR","FLOAT"],H=["==",">","<",">=","<=","!=","CONTAINS"];function J(i,e,l){i=i.map(r=>{if(typeof r=="string"){if(r==="rnd")return "RANDOM";if(r==="?")return "CONTAINS"}return r});let n=[];return i.forEach(r=>{if(typeof r=="object"&&"CNT?"in r)if(new RegExp(/.*\.[0-9]\..*/).test(r["CNT?"])){let a=r["CNT?"].split("."),u=a.pop(),c=a.pop();if(c===void 0||u===void 0){V.error("Error parsing ink file: Conditional statement is not valid",i);return}let h=parseInt(c),s=a.join(".");if(s.includes("^.")){let g=s.split("."),p=g[g.length-1].replaceAll(".","_|_");g.pop(),s=g.join(".")+"."+p,u.includes("c-")&&(s=s+"_|_"+u);}else s=s.replaceAll(".","_|_");let o=N(s,e);if(!o)return;n.push({type:"compare",leftValue:q(o),operator:">=",rightValue:{type:"value",value:h}});}else {let a=N(r["CNT?"],e);if(!a)return;n.push(q(a));}else if(typeof r=="object"&&"VAR?"in r)n.push(R(r["VAR?"],l));else if(r==="&&"||r==="||"){if(n.length>=2){let a={type:"union",unionType:r==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(a);}}else if(r==="!")if(n.length===0)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=a;}else if(r&&typeof r=="string"&&H.includes(r))if(n.length<2)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"compare",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(a);}else if(r&&typeof r=="string"&&$.includes(r))if(n.length<2)V.error("Error parsing ink file: Conditional statement is not valid",i);else {let a={type:"arithmetic",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(a);}else if(r&&typeof r=="string"&&W.includes(r)){let a={type:"arithmeticsingle",operator:r,leftValue:n[n.length-1]};n.pop(),n.push(a);}else r&&typeof r=="string"?r.startsWith("^")&&n.push(C(r)):typeof r=="object"&&"^->"in r?r["^->"].includes("$r")||n.push(r["^->"]):n.push(r);}),n}function q(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function Y(i,e,l){return J(i,e,l)}function R(i,e,l="storage"){let n=e.indexOf(i);return n>=0?{type:"value",storageType:"params",storageOperationType:"get",key:n}:{type:"value",storageOperationType:"get",storageType:l,key:i}}function D(i,e,l,n="storage"){let r=e.indexOf(i);return r>=0?{type:"value",storageType:"params",storageOperationType:"set",key:r,value:l}:{type:"value",storageOperationType:"set",storageType:n,key:i,value:l}}function L(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(C(e)):typeof e=="object"&&"type"in e&&e.type!=="value"&&i.push(e));}function j(i,e,l,n=true,r=false){return Q(i,e,l,n,r)}function Q(i,e,l,n,r=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type=="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(C(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function E(i,e,l){if(i.length===0){V.error("Error parsing ink file: Arithmetic statement is not valid",i);return}let n=J(i,e,l);if(n.length===1){let r=n[0];return r&&typeof r=="object"&&"type"in r?{type:"value",storageType:"logic",storageOperationType:"get",operation:r}:r}}function O(i,e,l,n="",r,a,u=void 0){let c=[],h="sequential",s=false,o=true;i.forEach(x=>{x==="%"&&(h="loop"),x==="seq"&&(h="random"),x==="MIN"&&(s=true);});let g=i[i.length-1];return Object.keys(g).forEach(x=>{let y=g[x];if(Array.isArray(y)&&y.length>3){y=y.slice(1,y.length-2);let S=[];m(y,n,r,S,e,e,l,F,u,true,a),S.length===1?c.push(S[0]):c.push({type:"resulttocombine",combine:"cross",secondConditionalItem:S});}else Array.isArray(y)&&y.length===3&&(o=false);}),h==="sequential"?{type:"stepswitch",elements:c,choiceType:h,end:o?"lastItem":void 0,nestedId:u}:s&&h==="random"?{type:"stepswitch",elements:c,choiceType:"sequentialrandom",end:o?"lastItem":void 0,nestedId:u}:{type:"stepswitch",elements:c,choiceType:h}}function m(i,e,l,n=[],r,a,u,c,h=void 0,s=true,o=[]){let g=false,p=[],x=false,y=false,S=[],b=[];if(l.preDialog[e]&&(s=false,r(n,"^"+l.preDialog[e].text,e,o,s,y),l.preDialog[e].glue&&r(n,"<>",e,o,s,y),delete l.preDialog[e]),i.includes("visit")){let t=O(i,a,u,e,l,o,h);t&&(!s&&n.length>0&&r(n,"<>",e,o,s,y),r(n,t,e,o,s,y));return}let v=i[0];if(v&&typeof v=="object"&&"temp="in v){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)o.push(i[0]["temp="]),i.shift();o=o.reverse();}if(i.forEach((t,P)=>{if(y){if(typeof t=="string"&&t=="/#"){let f=[];m(b,e,l,f,j,j,u,c,h,s),r(n,f,e,o,s,y),y=false,b=[];}else b.push(t);return}else if(g)if(Array.isArray(t))p.push(t);else if(t&&typeof t=="object")if("CNT?"in t)P>0&&i[P-1]=="ev"?(x=true,S.push(t)):x?S.push(t):(p.push(t),s=false);else if("VAR="in t||"temp="in t){let f=D("VAR="in t?t["VAR="]:t["temp="],o,i[P-1],"VAR="in t?"storage":"tempstorage");if(f.value&&typeof f.value=="string"&&f.value=="/str"&&(f.value=i[P-2]),f.value&&typeof f.value=="object"&&"^->"in f.value&&(f.value=f.value["^->"]),p.length>1){let d=E(p,e,o);p=[],d&&typeof d=="object"&&"type"in d&&d.type=="value"&&"storageType"in d&&d.storageType=="logic"&&(f.value=d.operation);}(typeof f.key!="string"||!f.key.includes("$r"))&&(r(n,f,e,o,s,y),s=true);}else "VAR?"in t?p.push(t):"^->"in t&&(t["^->"].includes("$r")||p.push(t));else if(typeof t=="string"&&t=="/ev")x&&S.push(t),g=false,p.push(t);else if(typeof t=="string"&&t=="out"){if(p.length>0){let f=p[p.length-1];if(f&&typeof f=="object"&&"VAR?"in f){p.pop();let d=R(f["VAR?"],o,"storage");r(n,d,e,o,s,y);}else {let d=[];for(;p.length>0&&p[p.length-1]!="/ev";)d.push(p.pop());d=d.reverse();let A=E(d,e,o);p=[],A&&typeof A=="object"&&"type"in A&&A.type=="value"&&"storageType"in A&&A.storageType=="logic"?r(n,{storageOperationType:"get",storageType:"logic",operation:A.operation,type:"value"},e,o,s,y):(r(n,"<>",e,o,s,y),A=`^${A}`,r(n,A,e,o,s,y));}s=false;}}else p.push(t);else if(typeof t=="string")if(t.startsWith("^"))r(n,t,e,o,s,y),s=false;else if(t=="ev")g=true;else if(t==`
3
+ `)s=true;else if(t=="done"||t=="end")r(n,t,e,o,s,y),s=false;else if(t=="<>")r(n,t,e,o,s,y),s=false;else if(t=="nop"&&x){let f=U(S,a,u,e,l,o,h);f&&r(n,f,e,o,s,y),x=false,S=[];}else t=="#"&&(y=true);else if(t instanceof Array)if(x)S.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){p.pop();let f=[],d=[];for(;p.length>0&&p[p.length-1]!="/ev";)f.push(p.pop());S=[...S,...f.reverse()],x=true,d.push(t.pop()),d.push(t.pop()),S=[...S,...t],S.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let f=t.pop();if(!f){V.error("Error parsing ink file: el is undefined");return}let d=f["#n"];delete f["#n"],t.push(f),r(n,{"->":e?e+"_|_"+d:d},e,o,s,y),u({[d]:t},e,l);}else m(t,e,l,n,r,a,u,c,h,s);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let f=[];p.length>0&&(f=Y(["ev",...p],e,o)),t.params=f,r(n,t,e,o,s,y),s=false;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(p.push(t),s=false);else if("s"in t&&t.s instanceof Array)p.push(t),s=false;else if("CNT?"in t)p.push(t),s=false;else if("VAR="in t||"temp="in t){let f=[],d=D("VAR="in t?t["VAR="]:t["temp="],o,void 0,"VAR="in t?"storage":"tempstorage");if(d.key!=="$r"){for(p.pop(),p[p.length-1]=="/ev"&&p.pop();p.length>0&&p[p.length-1]!="/ev";)f.push(p.pop());f=f.reverse(),d.value=E(f,e,o),p=[],(d.value!==void 0||d.value!==null)&&r(n,d,e,o,s,y),s=false;}}else u(t,e,l);}),c(p,n,e,l,o),e.includes("_|_")&&n.length==2){let t=n[0],P=n[1];t&&P&&typeof t=="object"&&"dialogue"in t&&typeof P=="object"&&"labelToOpen"in P&&t.dialogue==" "&&P.labelToOpen&&(n.shift(),delete P.glueEnabled,n[0]=P);}}function M(i,e,l,n,r){if(e.length===0)return;let a=J(e,n,l);if(a.length===1){let u={type:"ifelse",condition:a[0],then:i,else:r};return u.else||delete u.else,u}else if(a.length>1){let u={type:"ifelse",condition:{type:"union",unionType:"and",conditions:a},then:i,else:r};return u.else||delete u.else,u}}function U(i,e,l,n,r,a,u=void 0){if(i.length===0){V.error("Error parsing ink file: Conditional statement is not valid",i);return}let c=[],h=[];if(i.forEach(g=>{Array.isArray(g)?h.push(g):typeof g=="string"&&g==="du"?r.du?c.push(r.du):r.du=c[c.length-1]:(typeof g!="string"||g!=="/ev")&&c.push(g);}),h.length===0){V.error("Error parsing ink file: Conditional statement is not valid",h);return}let s=k(h[0],e,l,n+"_|_"+"then",r,a,`${u||""}then`),o;return h.length===2?o=k(h[1],e,l,n+"_|_"+"else",r,a,`${u||""}else`):h.length>2&&(h.shift(),h.push("nop"),h=[{b:h}],o=k(h,e,l,n+"_|_"+"else",r,a,`${u||""}else`)),r.du=void 0,M(s,c,a,n,o)}function k(i,e,l,n,r,a,u=void 0){let c=[];for(let s of i)typeof s=="object"&&"b"in s&&(s.b=s.b.filter(o=>o!==null&&!(typeof o=="object"&&"->"in o&&new RegExp(/.*\.[0-9]/).test(o["->"]))),m(s.b,n,r,c,e,e,l,F,u,true,a));return c.length===1?c[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:c}}function w(i="",e=""){let l=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...l,...n])]}function F(i,e,l,n,r){if(i.length>0){let a={};X(i,a,r);for(let[u,c]of Object.entries(a)){let h=l+"_|_"+u,s={text:c.text.length===1?c.text[0]:c.text,label:h,props:{},type:"jump",oneTime:c.onetime};c.text.length===0&&(s.onlyHaveNoChoice=true,s.autoSelect=true),s.oneTime===false&&delete s.oneTime;let o=M(s,c.conditions,r,l)||s,g=e[e.length-1];if(typeof g=="object"&&g&&"type"in g&&(g={conditionalStep:g}),e.length>0&&typeof g=="object"&&g&&"choices"in g&&g.choices){let p=g.choices;p&&Array.isArray(p)?p.push(o):V.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",c,p),g.choices=p.sort((x,y)=>{try{let S=x.label.split("."),b=S[S.length-1].replaceAll(".","_|_"),v=y.label.split("."),t=v[v.length-1].replaceAll(".","_|_");if(b.includes("c-")&&t.includes("c-")){let P=b.split("c-")[1],f=parseInt(P),d=t.split("c-")[1],A=parseInt(d);return f-A}}catch{}return 0});}else e.push({choices:[o]});c.preDialog&&(n.preDialog[h]={...c.preDialog});}}}function X(i,e,l,n){let r=[],a="",u="",c=false,h=[];for(let s=0;s<i.length;s++){let o=i[s];if(typeof o=="string")o.startsWith("^")?r.push(C(o)):G.includes(o)&&h.push(o);else if(Array.isArray(o)&&o.includes("visit")){let g=O(o,L,(p,x,y)=>{},n,{preDialog:{}},l);r.push(g);}else if(o&&typeof o=="object")if("*"in o&&typeof o["*"]&&typeof o["*"]=="string")o["*"].includes("c")&&(a="c"+o["*"].split("c")[1],o.flg&16&&(c=true));else if("s"in o&&o.s instanceof Array){let g=z(o.s),p=o.s.includes("<>");g&&(n&&e[n]?(e[n].preDialog={text:g,glue:p},e[n].text=w(g,e[n].text)):(r.push(g),u=g));}else "CNT?"in o&&h.push(o);else h.push(o);if(a){e[a]?e[a].text=w(r,e[a].text):e[a]={text:r,onetime:c,conditions:h},u&&(e[a].preDialog={text:u,glue:false});let g=i.slice(s+1);X(g,e,l,a);return}}}function z(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return C(e)}else if(e instanceof Array){let l=z(e);if(l)return l}}export{F as addChoiseIntoList,X as getLabelChoice};
@@ -1 +1 @@
1
- 'use strict';var d;(t=>(t.log=(o,...a)=>console.log(`[Pixi\u2019VN Ink] ${o}`,...a),t.warn=(o,...a)=>console.warn(`[Pixi\u2019VN Ink] ${o}`,...a),t.error=(o,...a)=>console.error(`[Pixi\u2019VN Ink] ${o}`,...a),t.info=(o,...a)=>console.info(`[Pixi\u2019VN Ink] ${o}`,...a)))(d||={});function N(s){}exports.onInkHashtagScript=N;
1
+ 'use strict';var g;(t=>(t.log=(o,...a)=>console.log(`[Pixi\u2019VN Ink] ${o}`,...a),t.warn=(o,...a)=>console.warn(`[Pixi\u2019VN Ink] ${o}`,...a),t.error=(o,...a)=>console.error(`[Pixi\u2019VN Ink] ${o}`,...a),t.info=(o,...a)=>console.info(`[Pixi\u2019VN Ink] ${o}`,...a)))(g||={});function A(s){}exports.onInkHashtagScript=A;
@@ -1 +1 @@
1
- var d;(t=>(t.log=(o,...a)=>console.log(`[Pixi\u2019VN Ink] ${o}`,...a),t.warn=(o,...a)=>console.warn(`[Pixi\u2019VN Ink] ${o}`,...a),t.error=(o,...a)=>console.error(`[Pixi\u2019VN Ink] ${o}`,...a),t.info=(o,...a)=>console.info(`[Pixi\u2019VN Ink] ${o}`,...a)))(d||={});function N(s){}export{N as onInkHashtagScript};
1
+ var g;(t=>(t.log=(o,...a)=>console.log(`[Pixi\u2019VN Ink] ${o}`,...a),t.warn=(o,...a)=>console.warn(`[Pixi\u2019VN Ink] ${o}`,...a),t.error=(o,...a)=>console.error(`[Pixi\u2019VN Ink] ${o}`,...a),t.info=(o,...a)=>console.info(`[Pixi\u2019VN Ink] ${o}`,...a)))(g||={});function A(s){}export{A as onInkHashtagScript};