@drincs/pixi-vn-ink 0.2.0 → 0.2.2

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 (124) hide show
  1. package/dist/{RootParserItemType-C7gjQ_67.d.mts → RootParserItemType-DV41SbdA.d.cts} +8 -8
  2. package/dist/constant.cjs +7 -0
  3. package/dist/constant.js +1 -5
  4. package/dist/functions/{ArithmeticUtility.mjs → ArithmeticUtility.cjs} +3 -1
  5. package/dist/functions/{ArithmeticUtility.d.mts → ArithmeticUtility.d.cts} +2 -2
  6. package/dist/functions/ArithmeticUtility.js +1 -3
  7. package/dist/functions/{ChoiceInfoConverter.mjs → ChoiceInfoConverter.cjs} +5 -2
  8. package/dist/functions/{ChoiceInfoConverter.d.mts → ChoiceInfoConverter.d.cts} +13 -13
  9. package/dist/functions/ChoiceInfoConverter.js +2 -5
  10. package/dist/functions/Importer.cjs +51 -0
  11. package/dist/functions/Importer.js +46 -12511
  12. package/dist/functions/{InkToPixivn.mjs → InkToPixivn.cjs} +6 -4
  13. package/dist/functions/InkToPixivn.js +4 -6
  14. package/dist/functions/StoryInfoConverter.cjs +10 -0
  15. package/dist/functions/StoryInfoConverter.d.cts +18 -0
  16. package/dist/functions/StoryInfoConverter.js +3 -6
  17. package/dist/functions/index.cjs +52 -0
  18. package/dist/functions/index.d.cts +3 -0
  19. package/dist/functions/index.js +46 -12512
  20. package/dist/index.cjs +52 -0
  21. package/dist/index.d.cts +3 -0
  22. package/dist/index.js +46 -12512
  23. package/dist/parser/{AddingElements.mjs → AddingElements.cjs} +7 -3
  24. package/dist/parser/{AddingElements.d.mts → AddingElements.d.cts} +2 -2
  25. package/dist/parser/AddingElements.js +3 -7
  26. package/dist/parser/{ConditionaAritmeticParser.mjs → ConditionaAritmeticParser.cjs} +3 -1
  27. package/dist/parser/ConditionaAritmeticParser.js +1 -3
  28. package/dist/parser/{ConditionalStatementsParser.mjs → ConditionalStatementsParser.cjs} +5 -2
  29. package/dist/parser/{ConditionalStatementsParser.d.mts → ConditionalStatementsParser.d.cts} +12 -12
  30. package/dist/parser/ConditionalStatementsParser.js +2 -5
  31. package/dist/parser/{LabelParser.mjs → LabelParser.cjs} +4 -2
  32. package/dist/parser/{LabelParser.d.mts → LabelParser.d.cts} +10 -10
  33. package/dist/parser/LabelParser.js +2 -4
  34. package/dist/parser/{SwitchParser.mjs → SwitchParser.cjs} +4 -2
  35. package/dist/parser/{SwitchParser.d.mts → SwitchParser.d.cts} +11 -11
  36. package/dist/parser/SwitchParser.js +2 -4
  37. package/dist/types/InkRootType.cjs +2 -0
  38. package/dist/types/InkRootType.d.cts +17 -0
  39. package/dist/types/InkRootType.js +0 -1
  40. package/dist/types/InkStoryType.cjs +2 -0
  41. package/dist/types/InkStoryType.d.cts +20 -0
  42. package/dist/types/InkStoryType.js +0 -1
  43. package/dist/types/LabelChoiceRes.cjs +2 -0
  44. package/dist/types/{LabelChoiceRes.d.mts → LabelChoiceRes.d.cts} +2 -2
  45. package/dist/types/LabelChoiceRes.js +0 -1
  46. package/dist/types/parserItems/ChoicePoint.cjs +2 -0
  47. package/dist/types/parserItems/ChoicePoint.d.cts +11 -0
  48. package/dist/types/parserItems/ChoicePoint.js +0 -1
  49. package/dist/types/parserItems/Cond.cjs +2 -0
  50. package/dist/types/parserItems/Cond.d.cts +17 -0
  51. package/dist/types/parserItems/Cond.js +0 -1
  52. package/dist/types/parserItems/ContainerType.cjs +2 -0
  53. package/dist/types/parserItems/{ContainerType.d.mts → ContainerType.d.cts} +2 -2
  54. package/dist/types/parserItems/ContainerType.js +0 -1
  55. package/dist/types/parserItems/ControlCommands.cjs +2 -0
  56. package/dist/types/parserItems/ControlCommands.js +0 -1
  57. package/dist/types/parserItems/Divert.cjs +2 -0
  58. package/dist/types/parserItems/Divert.js +0 -1
  59. package/dist/types/parserItems/{NativeFunctions.mjs → NativeFunctions.cjs} +6 -1
  60. package/dist/types/parserItems/NativeFunctions.js +1 -6
  61. package/dist/types/parserItems/ReadCount.cjs +2 -0
  62. package/dist/types/parserItems/ReadCount.js +0 -1
  63. package/dist/types/parserItems/RootParserItemType.cjs +2 -0
  64. package/dist/types/parserItems/RootParserItemType.d.cts +11 -0
  65. package/dist/types/parserItems/RootParserItemType.js +0 -1
  66. package/dist/types/parserItems/TextType.cjs +2 -0
  67. package/dist/types/parserItems/TextType.js +0 -1
  68. package/dist/types/parserItems/VariableAssignment.cjs +2 -0
  69. package/dist/types/parserItems/VariableAssignment.js +0 -1
  70. package/dist/types/parserItems/VariableReference.cjs +2 -0
  71. package/dist/types/parserItems/VariableReference.js +0 -1
  72. package/dist/utility/{ArrayUtility.mjs → ArrayUtility.cjs} +3 -1
  73. package/dist/utility/ArrayUtility.js +1 -3
  74. package/dist/utility/{CommandUtility.mjs → CommandUtility.cjs} +3 -1
  75. package/dist/utility/CommandUtility.js +1 -3
  76. package/dist/utility/{DivertUtility.mjs → DivertUtility.cjs} +3 -1
  77. package/dist/utility/DivertUtility.js +1 -3
  78. package/dist/utility/{TextUtility.mjs → TextUtility.cjs} +3 -1
  79. package/dist/utility/TextUtility.js +1 -3
  80. package/dist/utility/{ValueUtility.mjs → ValueUtility.cjs} +3 -1
  81. package/dist/utility/ValueUtility.js +1 -3
  82. package/package.json +8 -6
  83. package/dist/constant.mjs +0 -3
  84. package/dist/functions/Importer.mjs +0 -12512
  85. package/dist/functions/StoryInfoConverter.d.mts +0 -18
  86. package/dist/functions/StoryInfoConverter.mjs +0 -7
  87. package/dist/functions/index.d.mts +0 -3
  88. package/dist/functions/index.mjs +0 -12512
  89. package/dist/index.d.mts +0 -3
  90. package/dist/index.mjs +0 -12512
  91. package/dist/types/InkRootType.d.mts +0 -17
  92. package/dist/types/InkRootType.mjs +0 -1
  93. package/dist/types/InkStoryType.d.mts +0 -20
  94. package/dist/types/InkStoryType.mjs +0 -1
  95. package/dist/types/LabelChoiceRes.mjs +0 -1
  96. package/dist/types/parserItems/ChoicePoint.d.mts +0 -11
  97. package/dist/types/parserItems/ChoicePoint.mjs +0 -1
  98. package/dist/types/parserItems/Cond.d.mts +0 -17
  99. package/dist/types/parserItems/Cond.mjs +0 -1
  100. package/dist/types/parserItems/ContainerType.mjs +0 -1
  101. package/dist/types/parserItems/ControlCommands.mjs +0 -1
  102. package/dist/types/parserItems/Divert.mjs +0 -1
  103. package/dist/types/parserItems/ReadCount.mjs +0 -1
  104. package/dist/types/parserItems/RootParserItemType.d.mts +0 -11
  105. package/dist/types/parserItems/RootParserItemType.mjs +0 -1
  106. package/dist/types/parserItems/TextType.mjs +0 -1
  107. package/dist/types/parserItems/VariableAssignment.mjs +0 -1
  108. package/dist/types/parserItems/VariableReference.mjs +0 -1
  109. /package/dist/{constant.d.mts → constant.d.cts} +0 -0
  110. /package/dist/functions/{Importer.d.mts → Importer.d.cts} +0 -0
  111. /package/dist/functions/{InkToPixivn.d.mts → InkToPixivn.d.cts} +0 -0
  112. /package/dist/parser/{ConditionaAritmeticParser.d.mts → ConditionaAritmeticParser.d.cts} +0 -0
  113. /package/dist/types/parserItems/{ControlCommands.d.mts → ControlCommands.d.cts} +0 -0
  114. /package/dist/types/parserItems/{Divert.d.mts → Divert.d.cts} +0 -0
  115. /package/dist/types/parserItems/{NativeFunctions.d.mts → NativeFunctions.d.cts} +0 -0
  116. /package/dist/types/parserItems/{ReadCount.d.mts → ReadCount.d.cts} +0 -0
  117. /package/dist/types/parserItems/{TextType.d.mts → TextType.d.cts} +0 -0
  118. /package/dist/types/parserItems/{VariableAssignment.d.mts → VariableAssignment.d.cts} +0 -0
  119. /package/dist/types/parserItems/{VariableReference.d.mts → VariableReference.d.cts} +0 -0
  120. /package/dist/utility/{ArrayUtility.d.mts → ArrayUtility.d.cts} +0 -0
  121. /package/dist/utility/{CommandUtility.d.mts → CommandUtility.d.cts} +0 -0
  122. /package/dist/utility/{DivertUtility.d.mts → DivertUtility.d.cts} +0 -0
  123. /package/dist/utility/{TextUtility.d.mts → TextUtility.d.cts} +0 -0
  124. /package/dist/utility/{ValueUtility.d.mts → ValueUtility.d.cts} +0 -0
@@ -1,11 +1,11 @@
1
- import { ContainerTypeN } from './types/parserItems/ContainerType.mjs';
2
- import ControlCommands from './types/parserItems/ControlCommands.mjs';
3
- import Divert from './types/parserItems/Divert.mjs';
4
- import NativeFunctions from './types/parserItems/NativeFunctions.mjs';
5
- import ReadCount from './types/parserItems/ReadCount.mjs';
6
- import TextType from './types/parserItems/TextType.mjs';
7
- import VariableAssignment from './types/parserItems/VariableAssignment.mjs';
8
- import VariableReference from './types/parserItems/VariableReference.mjs';
1
+ import { ContainerTypeN } from './types/parserItems/ContainerType.cjs';
2
+ import ControlCommands from './types/parserItems/ControlCommands.cjs';
3
+ import Divert from './types/parserItems/Divert.cjs';
4
+ import NativeFunctions from './types/parserItems/NativeFunctions.cjs';
5
+ import ReadCount from './types/parserItems/ReadCount.cjs';
6
+ import TextType from './types/parserItems/TextType.cjs';
7
+ import VariableAssignment from './types/parserItems/VariableAssignment.cjs';
8
+ import VariableReference from './types/parserItems/VariableReference.cjs';
9
9
 
10
10
  /**
11
11
  * Generates an instance of a Choice. Its exact behaviour depends on its flags. It doesn't contain any text itself, since choice text is generated at runtime and added to the evaluation stack. When a ChoicePoint is encountered, it pops content off the evaluation stack according to its flags, which indicate which texts are needed.
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var _="_|_",E="global decl",L="___external_value___";
4
+
5
+ exports.CHOISE_LABEL_KEY_SEPARATOR = _;
6
+ exports.GLOBAL_DECL = E;
7
+ exports.MY_LABEL_KER_EXTERNAL_VALUE = L;
package/dist/constant.js CHANGED
@@ -1,7 +1,3 @@
1
- 'use strict';
2
-
3
1
  var _="_|_",E="global decl",L="___external_value___";
4
2
 
5
- exports.CHOISE_LABEL_KEY_SEPARATOR = _;
6
- exports.GLOBAL_DECL = E;
7
- exports.MY_LABEL_KER_EXTERNAL_VALUE = L;
3
+ export { _ as CHOISE_LABEL_KEY_SEPARATOR, E as GLOBAL_DECL, L as MY_LABEL_KER_EXTERNAL_VALUE };
@@ -1,4 +1,6 @@
1
+ 'use strict';
2
+
1
3
  var s="_|_";var f=["+","-","/","*","%","POW","RANDOM"],h=["INT","FLOOR","FLOAT"],A=["==",">","<",">=","<=","!=","CONTAINS"];function u(i,o){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(n=>!n.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",s);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let e=i.split("g-");return c(o)+s+"g-"+e[e.length-1]}let r=0;for(;new RegExp(/^\.\^.*$/).test(i);)r++,i=i.substring(2);if(r=r-1,new RegExp(/^\..*$/).test(i)&&o){let e=i.substring(1);return c(o,r)+s+e.replaceAll(".",s)}return i.replaceAll(".",s)||c(o,r).replaceAll(".",s)}function c(i,o=0){let r=i.split(s);for(;r.length>1&&o>0;)r.pop()?.includes("g-")&&o--,o--;return r.join(s)}var y="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function V(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",y),i=i.replaceAll("\\n",`
2
4
  `),i=i.replaceAll("\\t"," "),i=i.replaceAll(y,"\\\\"),i}function d(i,o,r){i=i.map(n=>{if(typeof n=="string"){if(n==="rnd")return "RANDOM";if(n==="?")return "CONTAINS"}return n});let e=[];return i.forEach(n=>{if(typeof n=="object"&&"CNT?"in n)if(new RegExp(/.*\.[0-9]\..*/).test(n["CNT?"])){let t=n["CNT?"].split("."),a=t.pop(),g=t.pop();if(g===void 0||a===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let x=parseInt(g),l=t.join(".");if(l.includes("^.")){let p=l.split("."),E=p[p.length-1].replaceAll(".",s);p.pop(),l=p.join(".")+"."+E,a.includes("c-")&&(l=l+s+a);}else l=l.replaceAll(".",s);e.push({type:"compare",leftValue:{type:"value",storageType:"label",storageOperationType:"get",valueType:"biggeststep",label:u(l,o)},operator:">=",rightValue:{type:"value",value:x}});}else e.push({type:"value",storageType:"label",storageOperationType:"get",label:u(n["CNT?"],o)});else if(typeof n=="object"&&"VAR?"in n){let t=r.indexOf(n["VAR?"]);t>=0?e.push({type:"value",storageType:"params",storageOperationType:"get",key:t}):e.push({type:"value",storageType:"storage",storageOperationType:"get",key:n["VAR?"]});}else if(n==="&&"||n==="||")if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"union",unionType:n==="&&"?"and":"or",conditions:[e[e.length-2],e[e.length-1]]};e.pop(),e.pop(),e.push(t);}else if(n==="!")if(e.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"union",unionType:"not",condition:e[e.length-1]};e[e.length-1]=t;}else if(n&&typeof n=="string"&&A.includes(n))if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"compare",operator:n,rightValue:e[e.length-1],leftValue:e[e.length-2]};e.pop(),e.pop(),e.push(t);}else if(n&&typeof n=="string"&&f.includes(n))if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"arithmetic",operator:n,rightValue:e[e.length-1],leftValue:e[e.length-2]};e.pop(),e.pop(),e.push(t);}else if(n&&typeof n=="string"&&h.includes(n)){let t={type:"arithmeticsingle",operator:n,leftValue:e[e.length-1]};e.pop(),e.push(t);}else n&&typeof n=="string"?n.startsWith("^")&&e.push(V(n)):typeof n=="object"&&"^->"in n?n["^->"].includes("$r")||e.push(n["^->"]):e.push(n);}),e}function k(i,o,r){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let e=d(i,o,r);if(e.length===1){let n=e[0];return n&&typeof n=="object"&&"type"in n?{type:"value",storageType:"logic",storageOperationType:"get",operation:n}:n}else console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);}
3
5
 
4
- export { k as arithmeticParser };
6
+ exports.arithmeticParser = k;
@@ -1,7 +1,7 @@
1
1
  import { StorageElementType } from '@drincs/pixi-vn';
2
2
  import { PixiVNJsonValueGet } from '@drincs/pixi-vn-json';
3
- import { ArithmeticFunctions } from '../types/parserItems/NativeFunctions.mjs';
4
- import VariableReference from '../types/parserItems/VariableReference.mjs';
3
+ import { ArithmeticFunctions } from '../types/parserItems/NativeFunctions.cjs';
4
+ import VariableReference from '../types/parserItems/VariableReference.cjs';
5
5
 
6
6
  declare function arithmeticParser(data: (ArithmeticFunctions | VariableReference)[], labelKey: string, paramNames: string[]): PixiVNJsonValueGet | StorageElementType | undefined;
7
7
 
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
1
  var s="_|_";var f=["+","-","/","*","%","POW","RANDOM"],h=["INT","FLOOR","FLOAT"],A=["==",">","<",">=","<=","!=","CONTAINS"];function u(i,o){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(n=>!n.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",s);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let e=i.split("g-");return c(o)+s+"g-"+e[e.length-1]}let r=0;for(;new RegExp(/^\.\^.*$/).test(i);)r++,i=i.substring(2);if(r=r-1,new RegExp(/^\..*$/).test(i)&&o){let e=i.substring(1);return c(o,r)+s+e.replaceAll(".",s)}return i.replaceAll(".",s)||c(o,r).replaceAll(".",s)}function c(i,o=0){let r=i.split(s);for(;r.length>1&&o>0;)r.pop()?.includes("g-")&&o--,o--;return r.join(s)}var y="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function V(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",y),i=i.replaceAll("\\n",`
4
2
  `),i=i.replaceAll("\\t"," "),i=i.replaceAll(y,"\\\\"),i}function d(i,o,r){i=i.map(n=>{if(typeof n=="string"){if(n==="rnd")return "RANDOM";if(n==="?")return "CONTAINS"}return n});let e=[];return i.forEach(n=>{if(typeof n=="object"&&"CNT?"in n)if(new RegExp(/.*\.[0-9]\..*/).test(n["CNT?"])){let t=n["CNT?"].split("."),a=t.pop(),g=t.pop();if(g===void 0||a===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let x=parseInt(g),l=t.join(".");if(l.includes("^.")){let p=l.split("."),E=p[p.length-1].replaceAll(".",s);p.pop(),l=p.join(".")+"."+E,a.includes("c-")&&(l=l+s+a);}else l=l.replaceAll(".",s);e.push({type:"compare",leftValue:{type:"value",storageType:"label",storageOperationType:"get",valueType:"biggeststep",label:u(l,o)},operator:">=",rightValue:{type:"value",value:x}});}else e.push({type:"value",storageType:"label",storageOperationType:"get",label:u(n["CNT?"],o)});else if(typeof n=="object"&&"VAR?"in n){let t=r.indexOf(n["VAR?"]);t>=0?e.push({type:"value",storageType:"params",storageOperationType:"get",key:t}):e.push({type:"value",storageType:"storage",storageOperationType:"get",key:n["VAR?"]});}else if(n==="&&"||n==="||")if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"union",unionType:n==="&&"?"and":"or",conditions:[e[e.length-2],e[e.length-1]]};e.pop(),e.pop(),e.push(t);}else if(n==="!")if(e.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"union",unionType:"not",condition:e[e.length-1]};e[e.length-1]=t;}else if(n&&typeof n=="string"&&A.includes(n))if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"compare",operator:n,rightValue:e[e.length-1],leftValue:e[e.length-2]};e.pop(),e.pop(),e.push(t);}else if(n&&typeof n=="string"&&f.includes(n))if(e.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let t={type:"arithmetic",operator:n,rightValue:e[e.length-1],leftValue:e[e.length-2]};e.pop(),e.pop(),e.push(t);}else if(n&&typeof n=="string"&&h.includes(n)){let t={type:"arithmeticsingle",operator:n,leftValue:e[e.length-1]};e.pop(),e.push(t);}else n&&typeof n=="string"?n.startsWith("^")&&e.push(V(n)):typeof n=="object"&&"^->"in n?n["^->"].includes("$r")||e.push(n["^->"]):e.push(n);}),e}function k(i,o,r){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let e=d(i,o,r);if(e.length===1){let n=e[0];return n&&typeof n=="object"&&"type"in n?{type:"value",storageType:"logic",storageOperationType:"get",operation:n}:n}else console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);}
5
3
 
6
- exports.arithmeticParser = k;
4
+ export { k as arithmeticParser };
@@ -1,7 +1,10 @@
1
- import '@drincs/pixi-vn';
1
+ 'use strict';
2
+
3
+ require('@drincs/pixi-vn');
2
4
 
3
5
  var V="_|_";function N(i,e){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",V);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+V+"g-"+n[n.length-1]}let a=0;for(;new RegExp(/^\.\^.*$/).test(i);)a++,i=i.substring(2);if(a=a-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,a)+V+n.replaceAll(".",V)}return i.replaceAll(".",V)||_(e,a).replaceAll(".",V)}function _(i,e=0){let a=i.split(V);for(;a.length>1&&e>0;)a.pop()?.includes("g-")&&e--,e--;return a.join(V)}var w="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function m(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",w),i=i.replaceAll("\\n",`
4
6
  `),i=i.replaceAll("\\t"," "),i=i.replaceAll(w,"\\\\"),i}function B(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(m(e)):typeof e=="object"&&"type"in e&&i.push(e));}function D(i,e,a,n=!0,r=!1){return X(i,e,a,n,r)}function X(i,e,a,n,r=!1){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"typeVar"in e&&e.typeOperation==="get"?typeof e=="string"?i.push(m(e)):e.typeVar==="logic"?i.push({type:"value",storageType:e.typeVar,storageOperationType:"get",operation:e.value}):e.typeVar&&i.push({type:"value",storageType:e.typeVar,storageOperationType:"get",key:e.name}):typeof e=="object"&&"type"in e&&i.push(e));}var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],W=["+","-","/","*","%","POW","RANDOM"],$=["INT","FLOOR","FLOAT"],H=["==",">","<",">=","<=","!=","CONTAINS"];function b(i,e,a){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 p=r["CNT?"].split("."),c=p.pop(),g=p.pop();if(g===void 0||c===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let u=parseInt(g),o=p.join(".");if(o.includes("^.")){let s=o.split("."),f=s[s.length-1].replaceAll(".",V);s.pop(),o=s.join(".")+"."+f,c.includes("c-")&&(o=o+V+c);}else o=o.replaceAll(".",V);n.push({type:"compare",leftValue:{type:"value",storageType:"label",storageOperationType:"get",valueType:"biggeststep",label:N(o,e)},operator:">=",rightValue:{type:"value",value:u}});}else n.push({type:"value",storageType:"label",storageOperationType:"get",label:N(r["CNT?"],e)});else if(typeof r=="object"&&"VAR?"in r){let p=a.indexOf(r["VAR?"]);p>=0?n.push({type:"value",storageType:"params",storageOperationType:"get",key:p}):n.push({type:"value",storageType:"storage",storageOperationType:"get",key:r["VAR?"]});}else if(r==="&&"||r==="||")if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:r==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(p);}else if(r==="!")if(n.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=p;}else if(r&&typeof r=="string"&&H.includes(r))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"compare",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(r&&typeof r=="string"&&W.includes(r))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"arithmetic",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(r&&typeof r=="string"&&$.includes(r)){let p={type:"arithmeticsingle",operator:r,leftValue:n[n.length-1]};n.pop(),n.push(p);}else r&&typeof r=="string"?r.startsWith("^")&&n.push(m(r)):typeof r=="object"&&"^->"in r?r["^->"].includes("$r")||n.push(r["^->"]):n.push(r);}),n}function J(i,e,a){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let n=b(i,e,a);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}else console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);}function Y(i,e,a){return b(i,e,a)}function R(i,e,a,n="",r,p,c=void 0){let g=[],u="sequential",o=!1,s=!0;i.forEach(S=>{S==="%"&&(u="loop"),S==="seq"&&(u="random"),S==="MIN"&&(o=!0);});let f=i[i.length-1];return Object.keys(f).forEach(S=>{let h=f[S];if(Array.isArray(h)&&h.length>3){h=h.slice(1,h.length-2);let P=[];v(h,n,r,P,e,e,a,E,c,!0,p),P.length===1?g.push(P[0]):g.push({type:"resulttocombine",combine:"cross",secondConditionalItem:P});}else Array.isArray(h)&&h.length===3&&(s=!1);}),u==="sequential"?{type:"stepswitch",elements:g,choiceType:u,end:s?"lastItem":void 0,nestedId:c}:o&&u==="random"?{type:"stepswitch",elements:g,choiceType:"sequentialrandom",end:s?"lastItem":void 0,nestedId:c}:{type:"stepswitch",elements:g,choiceType:u}}function v(i,e,a,n=[],r,p,c,g,u=void 0,o=!0,s=[]){let f=!1,l=[],S=!1,h=!1,P=[],O=[];if(a.preDialog[e]&&(o=!1,r(n,"^"+a.preDialog[e].text,e,o,h),delete a.preDialog[e]),i.includes("visit")){let t=R(i,p,c,e,a,s,u);t&&(!o&&n.length>0&&r(n,"<>",e,o,h),r(n,t,e,o,h));return}let F=i[0];if(F&&typeof F=="object"&&"temp="in F)for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)s.push(i[0]["temp="]),i.shift();if(i.forEach((t,C)=>{if(h){if(typeof t=="string"&&t=="/#"){let y=[];v(O,e,a,y,D,D,c,g,u,o),r(n,y,e,o,h),h=!1,O=[];}else O.push(t);return}else if(f)if(Array.isArray(t))l.push(t);else if(t&&typeof t=="object")if("CNT?"in t)C>0&&i[C-1]=="ev"?(S=!0,P.push(t)):S?P.push(t):l.push(t),o=!1;else if("VAR="in t||"temp="in t){let y="VAR="in t?"storage":"tempstorage",d="VAR="in t?t["VAR="]:t["temp="],T=s.indexOf(d);T>=0&&(y="params",d=T);let x=i[C-1];if(x&&typeof x=="string"&&x=="/str"&&(x=i[C-2]),x&&typeof x=="object"&&"^->"in x&&(x=x["^->"]),l.length>1){let A=J(l,e,s);l=[],A&&typeof A=="object"&&"type"in A&&A.type=="value"&&"storageType"in A&&A.storageType=="logic"&&(x=A.operation);}(typeof d!="string"||!d.includes("$r"))&&r(n,{typeOperation:"set",typeVar:y,value:x,name:d},e,o,h);}else "VAR?"in t?l.push(t):"^->"in t&&(t["^->"].includes("$r")||l.push(t));else if(typeof t=="string"&&t=="/ev")S&&P.push(t),f=!1,l.push(t);else if(typeof t=="string"&&t=="out"){if(l.length>0){let y=l[l.length-1];if(y&&typeof y=="object"&&"VAR?"in y){l.pop();let d="storage",T=y["VAR?"],x=s.indexOf(T);x>=0&&(d="params",T=x),r(n,{typeOperation:"get",typeVar:d,name:T},e,o,h);}else {let d=[];for(;l.length>0&&l[l.length-1]!="/ev";)d.push(l.pop());d=d.reverse();let T=J(d,e,s);l=[],T&&typeof T=="object"&&"type"in T&&T.type=="value"&&"storageType"in T&&T.storageType=="logic"?r(n,{typeOperation:"get",typeVar:"logic",value:T.operation},e,o,h):(r(n,"<>",e,o,h),T=`^${T}`,r(n,T,e,o,h));}o=!1;}}else l.push(t);else if(typeof t=="string")if(t.startsWith("^"))r(n,t,e,o,h),o=!1;else if(t=="ev")f=!0;else if(t==`
5
7
  `)o=!0;else if(t=="done"||t=="end")r(n,t,e,o,h),o=!1;else if(t=="<>")r(n,t,e,o,h),o=!1;else if(t=="nop"&&S){let y=q(P,p,c,e,a,s,u);y&&r(n,y,e,o,h),S=!1,P=[];}else t=="#"&&(h=!0);else if(t instanceof Array)if(S)P.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]){l.pop();let y=[],d=[];for(;l.length>0&&l[l.length-1]!="/ev";)y.push(l.pop());P=[...P,...y.reverse()],S=!0,d.push(t.pop()),d.push(t.pop()),P=[...P,...t],P.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let y=t.pop();if(!y){console.error("[Pixi\u2019VN Ink] Error parsing ink file: el is undefined");return}let d=y["#n"];delete y["#n"],t.push(y),r(n,{"->":e?e+V+d:d},e,o,h),c({[d]:t},e,a);}else v(t,e,a,n,r,p,c,g,u,o);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let y=[];l.length>0&&(y=Y(["ev",...l],e,s)),t.params=y,r(n,t,e,o,h),o=!1;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(l.push(t),o=!1);else if("s"in t&&t.s instanceof Array)l.push(t),o=!1;else if("CNT?"in t)l.push(t),o=!1;else if("VAR="in t||"temp="in t){let y=[],d="VAR="in t?"storage":"tempstorage",T="VAR="in t?t["VAR="]:t["temp="],x=s.indexOf(T);if(x>=0&&(d="params",T=x),T!=="$r"){for(l.pop(),l[l.length-1]=="/ev"&&l.pop();l.length>0&&l[l.length-1]!="/ev";)y.push(l.pop());y=y.reverse();let A=J(y,e,s);l=[],(A!==void 0||A!==null)&&r(n,{typeOperation:"set",typeVar:d,value:A,name:T},e,o,h),o=!1;}}else c(t,e,a);}),g(l,n,e,a,s),e.includes(V)&&n.length==2){let t=n[0],C=n[1];t&&C&&typeof t=="object"&&"dialogue"in t&&typeof C=="object"&&"labelToOpen"in C&&t.dialogue==" "&&C.labelToOpen&&(n.shift(),delete C.glueEnabled,n[0]=C);}}function j(i,e,a,n,r){if(e.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",e);return}let p=b(e,n,a);if(p.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",e);else if(p.length===1){let c={type:"ifelse",condition:p[0],then:i,else:r};return c.else||delete c.else,c}else {let c={type:"ifelse",condition:{type:"union",unionType:"and",conditions:p},then:i,else:r};return c.else||delete c.else,c}}function q(i,e,a,n,r,p,c=void 0){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let g=[],u=[];if(i.forEach(f=>{Array.isArray(f)?u.push(f):typeof f=="string"&&f==="du"?r.du?g.push(r.du):r.du=g[g.length-1]:(typeof f!="string"||f!=="/ev")&&g.push(f);}),u.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",u);return}let o=k(u[0],e,a,n+V+"then",r,p,c),s;return u.length===2?s=k(u[1],e,a,n+V+"else",r,p,c):u.length>2&&(u.shift(),u.push("nop"),u=[{b:u}],s=k(u,e,a,n+V+"else",r,p,c)),r.du=void 0,j(o,g,p,n,s)}function k(i,e,a,n,r,p,c=void 0){let g=[];for(let o of i)typeof o=="object"&&"b"in o&&(o.b=o.b.filter(s=>s!==null&&!(typeof s=="object"&&"->"in s&&new RegExp(/.*\.[0-9]/).test(s["->"]))),v(o.b,n,r,g,e,e,a,E,c,!0,p));return g.length===1?g[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:g}}function M(i="",e=""){let a=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...a,...n])]}function E(i,e,a,n,r){if(i.length>0){let p={};U(i,p,r);for(let[c,g]of Object.entries(p)){let u=a+V+c,o={text:g.text.length===1?g.text[0]:g.text,label:u,props:{},type:"jump",oneTime:g.onetime},s=j(o,g.conditions,r,a)||o,f=e[e.length-1];if(typeof f=="object"&&f&&"type"in f&&(f={conditionalStep:f}),e.length>0&&typeof f=="object"&&f&&"choices"in f&&f.choices){let l=f.choices;l&&Array.isArray(l)?l.push(s):console.error("[Pixi\u2019VN Ink] Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",g,l),f.choices=l;}else e.push({choices:[s]});g.preDialog&&(n.preDialog[u]={text:g.preDialog.text});}}}function U(i,e,a,n){let r=[],p="",c="",g=!1,u=[];for(let o=0;o<i.length;o++){let s=i[o];if(typeof s=="string")s.startsWith("^")?r.push(m(s)):G.includes(s)&&u.push(s);else if(Array.isArray(s)&&s.includes("visit")){let f=R(s,B,(l,S,h)=>{},n,{preDialog:{}},a);r.push(f);}else if(s&&typeof s=="object")if("*"in s&&typeof s["*"]&&typeof s["*"]=="string")s["*"].includes("c")&&(p="c"+s["*"].split("c")[1],s.flg&16&&(g=!0));else if("s"in s&&s.s instanceof Array){let f=L(s.s);f&&(n&&e[n]?(e[n].preDialog={text:f},e[n].text=M(f,e[n].text)):(r.push(f),c=f));}else "CNT?"in s&&u.push(s);else u.push(s);if(r.length>0&&p){e[p]?e[p].text=M(r,e[p].text):e[p]={text:r,onetime:g,conditions:u},c&&(e[p].preDialog={text:c});let f=i.slice(o+1);U(f,e,a,p);return}}}function L(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return m(e)}else if(e instanceof Array){let a=L(e);if(a)return a}}
6
8
 
7
- export { E as addChoiseIntoList, U as getLabelChoice };
9
+ exports.addChoiseIntoList = E;
10
+ exports.getLabelChoice = U;
@@ -1,18 +1,18 @@
1
1
  import { PixiVNJsonConditionalStatements } from '@drincs/pixi-vn-json';
2
- import { ShareDataParserLabel } from '../parser/LabelParser.mjs';
3
- import { ConditionalList } from '../parser/SwitchParser.mjs';
4
- import LabelChoiceRes from '../types/LabelChoiceRes.mjs';
5
- import { R as RootParserItemType, C as ChoicePoint, a as ChoiceInfo } from '../RootParserItemType-C7gjQ_67.mjs';
6
- import NativeFunctions from '../types/parserItems/NativeFunctions.mjs';
7
- import ReadCount from '../types/parserItems/ReadCount.mjs';
8
- import TextType from '../types/parserItems/TextType.mjs';
9
- import '../types/InkRootType.mjs';
10
- import '../types/parserItems/Divert.mjs';
11
- import '../types/parserItems/VariableAssignment.mjs';
2
+ import { ShareDataParserLabel } from '../parser/LabelParser.cjs';
3
+ import { ConditionalList } from '../parser/SwitchParser.cjs';
4
+ import LabelChoiceRes from '../types/LabelChoiceRes.cjs';
5
+ import { R as RootParserItemType, C as ChoicePoint, a as ChoiceInfo } from '../RootParserItemType-DV41SbdA.cjs';
6
+ import NativeFunctions from '../types/parserItems/NativeFunctions.cjs';
7
+ import ReadCount from '../types/parserItems/ReadCount.cjs';
8
+ import TextType from '../types/parserItems/TextType.cjs';
9
+ import '../types/InkRootType.cjs';
10
+ import '../types/parserItems/Divert.cjs';
11
+ import '../types/parserItems/VariableAssignment.cjs';
12
12
  import '@drincs/pixi-vn';
13
- import '../types/parserItems/ContainerType.mjs';
14
- import '../types/parserItems/ControlCommands.mjs';
15
- import '../types/parserItems/VariableReference.mjs';
13
+ import '../types/parserItems/ContainerType.cjs';
14
+ import '../types/parserItems/ControlCommands.cjs';
15
+ import '../types/parserItems/VariableReference.cjs';
16
16
 
17
17
  declare function addChoiseIntoList<T>(choiseList: RootParserItemType[], itemList: (T | PixiVNJsonConditionalStatements<T>)[], labelKey: string, shareData: ShareDataParserLabel, paramNames: string[]): void;
18
18
  declare function getLabelChoice(items: (TextType | ReadCount | NativeFunctions | ChoicePoint | ChoiceInfo | ConditionalList)[], result: LabelChoiceRes, paramNames: string[], lastLabel?: string): void;
@@ -1,10 +1,7 @@
1
- 'use strict';
2
-
3
- require('@drincs/pixi-vn');
1
+ import '@drincs/pixi-vn';
4
2
 
5
3
  var V="_|_";function N(i,e){if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".",V);if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return _(e)+V+"g-"+n[n.length-1]}let a=0;for(;new RegExp(/^\.\^.*$/).test(i);)a++,i=i.substring(2);if(a=a-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return _(e,a)+V+n.replaceAll(".",V)}return i.replaceAll(".",V)||_(e,a).replaceAll(".",V)}function _(i,e=0){let a=i.split(V);for(;a.length>1&&e>0;)a.pop()?.includes("g-")&&e--,e--;return a.join(V)}var w="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function m(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",w),i=i.replaceAll("\\n",`
6
4
  `),i=i.replaceAll("\\t"," "),i=i.replaceAll(w,"\\\\"),i}function B(i,e){e&&(typeof e=="string"?e.startsWith("^")&&i.push(m(e)):typeof e=="object"&&"type"in e&&i.push(e));}function D(i,e,a,n=!0,r=!1){return X(i,e,a,n,r)}function X(i,e,a,n,r=!1){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"typeVar"in e&&e.typeOperation==="get"?typeof e=="string"?i.push(m(e)):e.typeVar==="logic"?i.push({type:"value",storageType:e.typeVar,storageOperationType:"get",operation:e.value}):e.typeVar&&i.push({type:"value",storageType:e.typeVar,storageOperationType:"get",key:e.name}):typeof e=="object"&&"type"in e&&i.push(e));}var G=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],W=["+","-","/","*","%","POW","RANDOM"],$=["INT","FLOOR","FLOAT"],H=["==",">","<",">=","<=","!=","CONTAINS"];function b(i,e,a){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 p=r["CNT?"].split("."),c=p.pop(),g=p.pop();if(g===void 0||c===void 0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let u=parseInt(g),o=p.join(".");if(o.includes("^.")){let s=o.split("."),f=s[s.length-1].replaceAll(".",V);s.pop(),o=s.join(".")+"."+f,c.includes("c-")&&(o=o+V+c);}else o=o.replaceAll(".",V);n.push({type:"compare",leftValue:{type:"value",storageType:"label",storageOperationType:"get",valueType:"biggeststep",label:N(o,e)},operator:">=",rightValue:{type:"value",value:u}});}else n.push({type:"value",storageType:"label",storageOperationType:"get",label:N(r["CNT?"],e)});else if(typeof r=="object"&&"VAR?"in r){let p=a.indexOf(r["VAR?"]);p>=0?n.push({type:"value",storageType:"params",storageOperationType:"get",key:p}):n.push({type:"value",storageType:"storage",storageOperationType:"get",key:r["VAR?"]});}else if(r==="&&"||r==="||")if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:r==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(p);}else if(r==="!")if(n.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=p;}else if(r&&typeof r=="string"&&H.includes(r))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"compare",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(r&&typeof r=="string"&&W.includes(r))if(n.length<2)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);else {let p={type:"arithmetic",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(p);}else if(r&&typeof r=="string"&&$.includes(r)){let p={type:"arithmeticsingle",operator:r,leftValue:n[n.length-1]};n.pop(),n.push(p);}else r&&typeof r=="string"?r.startsWith("^")&&n.push(m(r)):typeof r=="object"&&"^->"in r?r["^->"].includes("$r")||n.push(r["^->"]):n.push(r);}),n}function J(i,e,a){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Arithmetic statement is not valid",i);return}let n=b(i,e,a);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}else console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);}function Y(i,e,a){return b(i,e,a)}function R(i,e,a,n="",r,p,c=void 0){let g=[],u="sequential",o=!1,s=!0;i.forEach(S=>{S==="%"&&(u="loop"),S==="seq"&&(u="random"),S==="MIN"&&(o=!0);});let f=i[i.length-1];return Object.keys(f).forEach(S=>{let h=f[S];if(Array.isArray(h)&&h.length>3){h=h.slice(1,h.length-2);let P=[];v(h,n,r,P,e,e,a,E,c,!0,p),P.length===1?g.push(P[0]):g.push({type:"resulttocombine",combine:"cross",secondConditionalItem:P});}else Array.isArray(h)&&h.length===3&&(s=!1);}),u==="sequential"?{type:"stepswitch",elements:g,choiceType:u,end:s?"lastItem":void 0,nestedId:c}:o&&u==="random"?{type:"stepswitch",elements:g,choiceType:"sequentialrandom",end:s?"lastItem":void 0,nestedId:c}:{type:"stepswitch",elements:g,choiceType:u}}function v(i,e,a,n=[],r,p,c,g,u=void 0,o=!0,s=[]){let f=!1,l=[],S=!1,h=!1,P=[],O=[];if(a.preDialog[e]&&(o=!1,r(n,"^"+a.preDialog[e].text,e,o,h),delete a.preDialog[e]),i.includes("visit")){let t=R(i,p,c,e,a,s,u);t&&(!o&&n.length>0&&r(n,"<>",e,o,h),r(n,t,e,o,h));return}let F=i[0];if(F&&typeof F=="object"&&"temp="in F)for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)s.push(i[0]["temp="]),i.shift();if(i.forEach((t,C)=>{if(h){if(typeof t=="string"&&t=="/#"){let y=[];v(O,e,a,y,D,D,c,g,u,o),r(n,y,e,o,h),h=!1,O=[];}else O.push(t);return}else if(f)if(Array.isArray(t))l.push(t);else if(t&&typeof t=="object")if("CNT?"in t)C>0&&i[C-1]=="ev"?(S=!0,P.push(t)):S?P.push(t):l.push(t),o=!1;else if("VAR="in t||"temp="in t){let y="VAR="in t?"storage":"tempstorage",d="VAR="in t?t["VAR="]:t["temp="],T=s.indexOf(d);T>=0&&(y="params",d=T);let x=i[C-1];if(x&&typeof x=="string"&&x=="/str"&&(x=i[C-2]),x&&typeof x=="object"&&"^->"in x&&(x=x["^->"]),l.length>1){let A=J(l,e,s);l=[],A&&typeof A=="object"&&"type"in A&&A.type=="value"&&"storageType"in A&&A.storageType=="logic"&&(x=A.operation);}(typeof d!="string"||!d.includes("$r"))&&r(n,{typeOperation:"set",typeVar:y,value:x,name:d},e,o,h);}else "VAR?"in t?l.push(t):"^->"in t&&(t["^->"].includes("$r")||l.push(t));else if(typeof t=="string"&&t=="/ev")S&&P.push(t),f=!1,l.push(t);else if(typeof t=="string"&&t=="out"){if(l.length>0){let y=l[l.length-1];if(y&&typeof y=="object"&&"VAR?"in y){l.pop();let d="storage",T=y["VAR?"],x=s.indexOf(T);x>=0&&(d="params",T=x),r(n,{typeOperation:"get",typeVar:d,name:T},e,o,h);}else {let d=[];for(;l.length>0&&l[l.length-1]!="/ev";)d.push(l.pop());d=d.reverse();let T=J(d,e,s);l=[],T&&typeof T=="object"&&"type"in T&&T.type=="value"&&"storageType"in T&&T.storageType=="logic"?r(n,{typeOperation:"get",typeVar:"logic",value:T.operation},e,o,h):(r(n,"<>",e,o,h),T=`^${T}`,r(n,T,e,o,h));}o=!1;}}else l.push(t);else if(typeof t=="string")if(t.startsWith("^"))r(n,t,e,o,h),o=!1;else if(t=="ev")f=!0;else if(t==`
7
5
  `)o=!0;else if(t=="done"||t=="end")r(n,t,e,o,h),o=!1;else if(t=="<>")r(n,t,e,o,h),o=!1;else if(t=="nop"&&S){let y=q(P,p,c,e,a,s,u);y&&r(n,y,e,o,h),S=!1,P=[];}else t=="#"&&(h=!0);else if(t instanceof Array)if(S)P.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]){l.pop();let y=[],d=[];for(;l.length>0&&l[l.length-1]!="/ev";)y.push(l.pop());P=[...P,...y.reverse()],S=!0,d.push(t.pop()),d.push(t.pop()),P=[...P,...t],P.push(d);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let y=t.pop();if(!y){console.error("[Pixi\u2019VN Ink] Error parsing ink file: el is undefined");return}let d=y["#n"];delete y["#n"],t.push(y),r(n,{"->":e?e+V+d:d},e,o,h),c({[d]:t},e,a);}else v(t,e,a,n,r,p,c,g,u,o);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let y=[];l.length>0&&(y=Y(["ev",...l],e,s)),t.params=y,r(n,t,e,o,h),o=!1;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(l.push(t),o=!1);else if("s"in t&&t.s instanceof Array)l.push(t),o=!1;else if("CNT?"in t)l.push(t),o=!1;else if("VAR="in t||"temp="in t){let y=[],d="VAR="in t?"storage":"tempstorage",T="VAR="in t?t["VAR="]:t["temp="],x=s.indexOf(T);if(x>=0&&(d="params",T=x),T!=="$r"){for(l.pop(),l[l.length-1]=="/ev"&&l.pop();l.length>0&&l[l.length-1]!="/ev";)y.push(l.pop());y=y.reverse();let A=J(y,e,s);l=[],(A!==void 0||A!==null)&&r(n,{typeOperation:"set",typeVar:d,value:A,name:T},e,o,h),o=!1;}}else c(t,e,a);}),g(l,n,e,a,s),e.includes(V)&&n.length==2){let t=n[0],C=n[1];t&&C&&typeof t=="object"&&"dialogue"in t&&typeof C=="object"&&"labelToOpen"in C&&t.dialogue==" "&&C.labelToOpen&&(n.shift(),delete C.glueEnabled,n[0]=C);}}function j(i,e,a,n,r){if(e.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",e);return}let p=b(e,n,a);if(p.length===0)console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",e);else if(p.length===1){let c={type:"ifelse",condition:p[0],then:i,else:r};return c.else||delete c.else,c}else {let c={type:"ifelse",condition:{type:"union",unionType:"and",conditions:p},then:i,else:r};return c.else||delete c.else,c}}function q(i,e,a,n,r,p,c=void 0){if(i.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",i);return}let g=[],u=[];if(i.forEach(f=>{Array.isArray(f)?u.push(f):typeof f=="string"&&f==="du"?r.du?g.push(r.du):r.du=g[g.length-1]:(typeof f!="string"||f!=="/ev")&&g.push(f);}),u.length===0){console.error("[Pixi\u2019VN Ink] Error parsing ink file: Conditional statement is not valid",u);return}let o=k(u[0],e,a,n+V+"then",r,p,c),s;return u.length===2?s=k(u[1],e,a,n+V+"else",r,p,c):u.length>2&&(u.shift(),u.push("nop"),u=[{b:u}],s=k(u,e,a,n+V+"else",r,p,c)),r.du=void 0,j(o,g,p,n,s)}function k(i,e,a,n,r,p,c=void 0){let g=[];for(let o of i)typeof o=="object"&&"b"in o&&(o.b=o.b.filter(s=>s!==null&&!(typeof s=="object"&&"->"in s&&new RegExp(/.*\.[0-9]/).test(s["->"]))),v(o.b,n,r,g,e,e,a,E,c,!0,p));return g.length===1?g[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:g}}function M(i="",e=""){let a=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...a,...n])]}function E(i,e,a,n,r){if(i.length>0){let p={};U(i,p,r);for(let[c,g]of Object.entries(p)){let u=a+V+c,o={text:g.text.length===1?g.text[0]:g.text,label:u,props:{},type:"jump",oneTime:g.onetime},s=j(o,g.conditions,r,a)||o,f=e[e.length-1];if(typeof f=="object"&&f&&"type"in f&&(f={conditionalStep:f}),e.length>0&&typeof f=="object"&&f&&"choices"in f&&f.choices){let l=f.choices;l&&Array.isArray(l)?l.push(s):console.error("[Pixi\u2019VN Ink] Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",g,l),f.choices=l;}else e.push({choices:[s]});g.preDialog&&(n.preDialog[u]={text:g.preDialog.text});}}}function U(i,e,a,n){let r=[],p="",c="",g=!1,u=[];for(let o=0;o<i.length;o++){let s=i[o];if(typeof s=="string")s.startsWith("^")?r.push(m(s)):G.includes(s)&&u.push(s);else if(Array.isArray(s)&&s.includes("visit")){let f=R(s,B,(l,S,h)=>{},n,{preDialog:{}},a);r.push(f);}else if(s&&typeof s=="object")if("*"in s&&typeof s["*"]&&typeof s["*"]=="string")s["*"].includes("c")&&(p="c"+s["*"].split("c")[1],s.flg&16&&(g=!0));else if("s"in s&&s.s instanceof Array){let f=L(s.s);f&&(n&&e[n]?(e[n].preDialog={text:f},e[n].text=M(f,e[n].text)):(r.push(f),c=f));}else "CNT?"in s&&u.push(s);else u.push(s);if(r.length>0&&p){e[p]?e[p].text=M(r,e[p].text):e[p]={text:r,onetime:g,conditions:u},c&&(e[p].preDialog={text:c});let f=i.slice(o+1);U(f,e,a,p);return}}}function L(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return m(e)}else if(e instanceof Array){let a=L(e);if(a)return a}}
8
6
 
9
- exports.addChoiseIntoList = E;
10
- exports.getLabelChoice = U;
7
+ export { E as addChoiseIntoList, U as getLabelChoice };