relq 1.0.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 (305) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +862 -0
  3. package/dist/addons/buffer.js +1869 -0
  4. package/dist/addons/pg-cursor.js +1425 -0
  5. package/dist/addons/pg-format.js +2248 -0
  6. package/dist/addons/pg.js +4790 -0
  7. package/dist/bin/relq.js +2 -0
  8. package/dist/cjs/cache/index.cjs +9 -0
  9. package/dist/cjs/cache/query-cache.cjs +311 -0
  10. package/dist/cjs/cli/commands/add.cjs +82 -0
  11. package/dist/cjs/cli/commands/commit.cjs +145 -0
  12. package/dist/cjs/cli/commands/diff.cjs +84 -0
  13. package/dist/cjs/cli/commands/export.cjs +333 -0
  14. package/dist/cjs/cli/commands/fetch.cjs +59 -0
  15. package/dist/cjs/cli/commands/generate.cjs +242 -0
  16. package/dist/cjs/cli/commands/history.cjs +165 -0
  17. package/dist/cjs/cli/commands/import.cjs +524 -0
  18. package/dist/cjs/cli/commands/init.cjs +437 -0
  19. package/dist/cjs/cli/commands/introspect.cjs +142 -0
  20. package/dist/cjs/cli/commands/log.cjs +62 -0
  21. package/dist/cjs/cli/commands/migrate.cjs +167 -0
  22. package/dist/cjs/cli/commands/pull.cjs +410 -0
  23. package/dist/cjs/cli/commands/push.cjs +165 -0
  24. package/dist/cjs/cli/commands/rollback.cjs +169 -0
  25. package/dist/cjs/cli/commands/status.cjs +110 -0
  26. package/dist/cjs/cli/commands/sync.cjs +79 -0
  27. package/dist/cjs/cli/index.cjs +275 -0
  28. package/dist/cjs/cli/utils/change-tracker.cjs +446 -0
  29. package/dist/cjs/cli/utils/commit-manager.cjs +239 -0
  30. package/dist/cjs/cli/utils/config-loader.cjs +127 -0
  31. package/dist/cjs/cli/utils/env-loader.cjs +62 -0
  32. package/dist/cjs/cli/utils/fast-introspect.cjs +398 -0
  33. package/dist/cjs/cli/utils/git-utils.cjs +404 -0
  34. package/dist/cjs/cli/utils/migration-generator.cjs +269 -0
  35. package/dist/cjs/cli/utils/relqignore.cjs +114 -0
  36. package/dist/cjs/cli/utils/repo-manager.cjs +515 -0
  37. package/dist/cjs/cli/utils/schema-comparator.cjs +313 -0
  38. package/dist/cjs/cli/utils/schema-diff.cjs +284 -0
  39. package/dist/cjs/cli/utils/schema-hash.cjs +108 -0
  40. package/dist/cjs/cli/utils/schema-introspect.cjs +455 -0
  41. package/dist/cjs/cli/utils/snapshot-manager.cjs +223 -0
  42. package/dist/cjs/cli/utils/spinner.cjs +108 -0
  43. package/dist/cjs/cli/utils/sql-generator.cjs +520 -0
  44. package/dist/cjs/cli/utils/sql-parser.cjs +999 -0
  45. package/dist/cjs/cli/utils/type-generator.cjs +2061 -0
  46. package/dist/cjs/condition/array-condition-builder.cjs +503 -0
  47. package/dist/cjs/condition/array-numeric-condition-builder.cjs +186 -0
  48. package/dist/cjs/condition/array-specialized-condition-builder.cjs +206 -0
  49. package/dist/cjs/condition/array-string-condition-builder.cjs +146 -0
  50. package/dist/cjs/condition/base-condition-builder.cjs +2 -0
  51. package/dist/cjs/condition/condition-collector.cjs +284 -0
  52. package/dist/cjs/condition/fulltext-condition-builder.cjs +61 -0
  53. package/dist/cjs/condition/geometric-condition-builder.cjs +208 -0
  54. package/dist/cjs/condition/index.cjs +25 -0
  55. package/dist/cjs/condition/jsonb-condition-builder.cjs +160 -0
  56. package/dist/cjs/condition/network-condition-builder.cjs +230 -0
  57. package/dist/cjs/condition/range-condition-builder.cjs +82 -0
  58. package/dist/cjs/config/config.cjs +190 -0
  59. package/dist/cjs/config/index.cjs +9 -0
  60. package/dist/cjs/constants/pg-values.cjs +68 -0
  61. package/dist/cjs/copy/copy-builder.cjs +316 -0
  62. package/dist/cjs/copy/index.cjs +6 -0
  63. package/dist/cjs/core/query-builder.cjs +440 -0
  64. package/dist/cjs/core/relq-client.cjs +1831 -0
  65. package/dist/cjs/core/typed-kuery-client.cjs +2 -0
  66. package/dist/cjs/count/count-builder.cjs +88 -0
  67. package/dist/cjs/count/index.cjs +5 -0
  68. package/dist/cjs/cte/cte-builder.cjs +89 -0
  69. package/dist/cjs/cte/index.cjs +5 -0
  70. package/dist/cjs/ddl/function.cjs +48 -0
  71. package/dist/cjs/ddl/index.cjs +7 -0
  72. package/dist/cjs/ddl/sql.cjs +54 -0
  73. package/dist/cjs/delete/delete-builder.cjs +135 -0
  74. package/dist/cjs/delete/index.cjs +5 -0
  75. package/dist/cjs/errors/relq-errors.cjs +329 -0
  76. package/dist/cjs/examples/fulltext-search-test.cjs +122 -0
  77. package/dist/cjs/explain/explain-builder.cjs +99 -0
  78. package/dist/cjs/explain/index.cjs +5 -0
  79. package/dist/cjs/function/create-function-builder.cjs +196 -0
  80. package/dist/cjs/function/index.cjs +6 -0
  81. package/dist/cjs/functions/advanced-functions.cjs +241 -0
  82. package/dist/cjs/functions/case-builder.cjs +66 -0
  83. package/dist/cjs/functions/geometric-functions.cjs +104 -0
  84. package/dist/cjs/functions/index.cjs +184 -0
  85. package/dist/cjs/functions/network-functions.cjs +86 -0
  86. package/dist/cjs/functions/sql-functions.cjs +431 -0
  87. package/dist/cjs/index.cjs +164 -0
  88. package/dist/cjs/indexing/create-index-builder.cjs +187 -0
  89. package/dist/cjs/indexing/drop-index-builder.cjs +89 -0
  90. package/dist/cjs/indexing/index-types.cjs +2 -0
  91. package/dist/cjs/indexing/index.cjs +8 -0
  92. package/dist/cjs/insert/conflict-builder.cjs +173 -0
  93. package/dist/cjs/insert/index.cjs +5 -0
  94. package/dist/cjs/insert/insert-builder.cjs +254 -0
  95. package/dist/cjs/introspect/index.cjs +229 -0
  96. package/dist/cjs/maintenance/index.cjs +6 -0
  97. package/dist/cjs/maintenance/vacuum-builder.cjs +166 -0
  98. package/dist/cjs/pubsub/index.cjs +7 -0
  99. package/dist/cjs/pubsub/listen-notify-builder.cjs +57 -0
  100. package/dist/cjs/pubsub/listener-connection.cjs +180 -0
  101. package/dist/cjs/raw/index.cjs +5 -0
  102. package/dist/cjs/raw/raw-query-builder.cjs +27 -0
  103. package/dist/cjs/schema/index.cjs +15 -0
  104. package/dist/cjs/schema/schema-builder.cjs +1167 -0
  105. package/dist/cjs/schema-builder.cjs +21 -0
  106. package/dist/cjs/schema-definition/column-types.cjs +829 -0
  107. package/dist/cjs/schema-definition/index.cjs +62 -0
  108. package/dist/cjs/schema-definition/introspection.cjs +620 -0
  109. package/dist/cjs/schema-definition/partitions.cjs +129 -0
  110. package/dist/cjs/schema-definition/pg-enum.cjs +76 -0
  111. package/dist/cjs/schema-definition/pg-function.cjs +91 -0
  112. package/dist/cjs/schema-definition/pg-sequence.cjs +56 -0
  113. package/dist/cjs/schema-definition/pg-trigger.cjs +108 -0
  114. package/dist/cjs/schema-definition/relations.cjs +98 -0
  115. package/dist/cjs/schema-definition/sql-expressions.cjs +202 -0
  116. package/dist/cjs/schema-definition/table-definition.cjs +636 -0
  117. package/dist/cjs/select/aggregate-builder.cjs +179 -0
  118. package/dist/cjs/select/index.cjs +5 -0
  119. package/dist/cjs/select/select-builder.cjs +233 -0
  120. package/dist/cjs/sequence/index.cjs +7 -0
  121. package/dist/cjs/sequence/sequence-builder.cjs +264 -0
  122. package/dist/cjs/table/alter-table-builder.cjs +146 -0
  123. package/dist/cjs/table/constraint-builder.cjs +102 -0
  124. package/dist/cjs/table/create-table-builder.cjs +248 -0
  125. package/dist/cjs/table/index.cjs +17 -0
  126. package/dist/cjs/table/partition-builder.cjs +131 -0
  127. package/dist/cjs/table/truncate-builder.cjs +70 -0
  128. package/dist/cjs/transaction/index.cjs +6 -0
  129. package/dist/cjs/transaction/transaction-builder.cjs +78 -0
  130. package/dist/cjs/trigger/create-trigger-builder.cjs +174 -0
  131. package/dist/cjs/trigger/index.cjs +6 -0
  132. package/dist/cjs/types/aggregate-types.cjs +2 -0
  133. package/dist/cjs/types/config-types.cjs +40 -0
  134. package/dist/cjs/types/inference-types.cjs +18 -0
  135. package/dist/cjs/types/pagination-types.cjs +7 -0
  136. package/dist/cjs/types/result-types.cjs +2 -0
  137. package/dist/cjs/types/schema-types.cjs +2 -0
  138. package/dist/cjs/types/subscription-types.cjs +2 -0
  139. package/dist/cjs/types.cjs +2 -0
  140. package/dist/cjs/update/array-update-builder.cjs +205 -0
  141. package/dist/cjs/update/index.cjs +13 -0
  142. package/dist/cjs/update/update-builder.cjs +195 -0
  143. package/dist/cjs/utils/case-converter.cjs +58 -0
  144. package/dist/cjs/utils/environment-detection.cjs +120 -0
  145. package/dist/cjs/utils/index.cjs +10 -0
  146. package/dist/cjs/utils/pool-defaults.cjs +106 -0
  147. package/dist/cjs/utils/type-coercion.cjs +118 -0
  148. package/dist/cjs/view/create-view-builder.cjs +180 -0
  149. package/dist/cjs/view/index.cjs +7 -0
  150. package/dist/cjs/window/index.cjs +5 -0
  151. package/dist/cjs/window/window-builder.cjs +80 -0
  152. package/dist/config.cjs +1 -0
  153. package/dist/config.d.ts +655 -0
  154. package/dist/config.js +1 -0
  155. package/dist/esm/cache/index.js +1 -0
  156. package/dist/esm/cache/query-cache.js +303 -0
  157. package/dist/esm/cli/commands/add.js +78 -0
  158. package/dist/esm/cli/commands/commit.js +109 -0
  159. package/dist/esm/cli/commands/diff.js +81 -0
  160. package/dist/esm/cli/commands/export.js +297 -0
  161. package/dist/esm/cli/commands/fetch.js +56 -0
  162. package/dist/esm/cli/commands/generate.js +206 -0
  163. package/dist/esm/cli/commands/history.js +129 -0
  164. package/dist/esm/cli/commands/import.js +488 -0
  165. package/dist/esm/cli/commands/init.js +401 -0
  166. package/dist/esm/cli/commands/introspect.js +106 -0
  167. package/dist/esm/cli/commands/log.js +59 -0
  168. package/dist/esm/cli/commands/migrate.js +131 -0
  169. package/dist/esm/cli/commands/pull.js +374 -0
  170. package/dist/esm/cli/commands/push.js +129 -0
  171. package/dist/esm/cli/commands/rollback.js +133 -0
  172. package/dist/esm/cli/commands/status.js +107 -0
  173. package/dist/esm/cli/commands/sync.js +76 -0
  174. package/dist/esm/cli/index.js +240 -0
  175. package/dist/esm/cli/utils/change-tracker.js +405 -0
  176. package/dist/esm/cli/utils/commit-manager.js +191 -0
  177. package/dist/esm/cli/utils/config-loader.js +86 -0
  178. package/dist/esm/cli/utils/env-loader.js +57 -0
  179. package/dist/esm/cli/utils/fast-introspect.js +362 -0
  180. package/dist/esm/cli/utils/git-utils.js +347 -0
  181. package/dist/esm/cli/utils/migration-generator.js +263 -0
  182. package/dist/esm/cli/utils/relqignore.js +74 -0
  183. package/dist/esm/cli/utils/repo-manager.js +444 -0
  184. package/dist/esm/cli/utils/schema-comparator.js +307 -0
  185. package/dist/esm/cli/utils/schema-diff.js +276 -0
  186. package/dist/esm/cli/utils/schema-hash.js +69 -0
  187. package/dist/esm/cli/utils/schema-introspect.js +418 -0
  188. package/dist/esm/cli/utils/snapshot-manager.js +179 -0
  189. package/dist/esm/cli/utils/spinner.js +101 -0
  190. package/dist/esm/cli/utils/sql-generator.js +504 -0
  191. package/dist/esm/cli/utils/sql-parser.js +992 -0
  192. package/dist/esm/cli/utils/type-generator.js +2058 -0
  193. package/dist/esm/condition/array-condition-builder.js +495 -0
  194. package/dist/esm/condition/array-numeric-condition-builder.js +182 -0
  195. package/dist/esm/condition/array-specialized-condition-builder.js +200 -0
  196. package/dist/esm/condition/array-string-condition-builder.js +142 -0
  197. package/dist/esm/condition/base-condition-builder.js +1 -0
  198. package/dist/esm/condition/condition-collector.js +275 -0
  199. package/dist/esm/condition/fulltext-condition-builder.js +53 -0
  200. package/dist/esm/condition/geometric-condition-builder.js +200 -0
  201. package/dist/esm/condition/index.js +7 -0
  202. package/dist/esm/condition/jsonb-condition-builder.js +152 -0
  203. package/dist/esm/condition/network-condition-builder.js +222 -0
  204. package/dist/esm/condition/range-condition-builder.js +74 -0
  205. package/dist/esm/config/config.js +150 -0
  206. package/dist/esm/config/index.js +1 -0
  207. package/dist/esm/constants/pg-values.js +63 -0
  208. package/dist/esm/copy/copy-builder.js +308 -0
  209. package/dist/esm/copy/index.js +1 -0
  210. package/dist/esm/core/query-builder.js +426 -0
  211. package/dist/esm/core/relq-client.js +1791 -0
  212. package/dist/esm/core/typed-kuery-client.js +1 -0
  213. package/dist/esm/count/count-builder.js +81 -0
  214. package/dist/esm/count/index.js +1 -0
  215. package/dist/esm/cte/cte-builder.js +82 -0
  216. package/dist/esm/cte/index.js +1 -0
  217. package/dist/esm/ddl/function.js +45 -0
  218. package/dist/esm/ddl/index.js +2 -0
  219. package/dist/esm/ddl/sql.js +51 -0
  220. package/dist/esm/delete/delete-builder.js +128 -0
  221. package/dist/esm/delete/index.js +1 -0
  222. package/dist/esm/errors/relq-errors.js +310 -0
  223. package/dist/esm/examples/fulltext-search-test.js +117 -0
  224. package/dist/esm/explain/explain-builder.js +95 -0
  225. package/dist/esm/explain/index.js +1 -0
  226. package/dist/esm/function/create-function-builder.js +188 -0
  227. package/dist/esm/function/index.js +1 -0
  228. package/dist/esm/functions/advanced-functions.js +231 -0
  229. package/dist/esm/functions/case-builder.js +58 -0
  230. package/dist/esm/functions/geometric-functions.js +97 -0
  231. package/dist/esm/functions/index.js +171 -0
  232. package/dist/esm/functions/network-functions.js +79 -0
  233. package/dist/esm/functions/sql-functions.js +421 -0
  234. package/dist/esm/index.js +34 -0
  235. package/dist/esm/indexing/create-index-builder.js +180 -0
  236. package/dist/esm/indexing/drop-index-builder.js +81 -0
  237. package/dist/esm/indexing/index-types.js +1 -0
  238. package/dist/esm/indexing/index.js +2 -0
  239. package/dist/esm/insert/conflict-builder.js +162 -0
  240. package/dist/esm/insert/index.js +1 -0
  241. package/dist/esm/insert/insert-builder.js +247 -0
  242. package/dist/esm/introspect/index.js +224 -0
  243. package/dist/esm/maintenance/index.js +1 -0
  244. package/dist/esm/maintenance/vacuum-builder.js +158 -0
  245. package/dist/esm/pubsub/index.js +1 -0
  246. package/dist/esm/pubsub/listen-notify-builder.js +48 -0
  247. package/dist/esm/pubsub/listener-connection.js +173 -0
  248. package/dist/esm/raw/index.js +1 -0
  249. package/dist/esm/raw/raw-query-builder.js +20 -0
  250. package/dist/esm/schema/index.js +1 -0
  251. package/dist/esm/schema/schema-builder.js +1150 -0
  252. package/dist/esm/schema-builder.js +2 -0
  253. package/dist/esm/schema-definition/column-types.js +738 -0
  254. package/dist/esm/schema-definition/index.js +10 -0
  255. package/dist/esm/schema-definition/introspection.js +614 -0
  256. package/dist/esm/schema-definition/partitions.js +123 -0
  257. package/dist/esm/schema-definition/pg-enum.js +70 -0
  258. package/dist/esm/schema-definition/pg-function.js +85 -0
  259. package/dist/esm/schema-definition/pg-sequence.js +50 -0
  260. package/dist/esm/schema-definition/pg-trigger.js +102 -0
  261. package/dist/esm/schema-definition/relations.js +90 -0
  262. package/dist/esm/schema-definition/sql-expressions.js +193 -0
  263. package/dist/esm/schema-definition/table-definition.js +630 -0
  264. package/dist/esm/select/aggregate-builder.js +172 -0
  265. package/dist/esm/select/index.js +1 -0
  266. package/dist/esm/select/select-builder.js +226 -0
  267. package/dist/esm/sequence/index.js +1 -0
  268. package/dist/esm/sequence/sequence-builder.js +255 -0
  269. package/dist/esm/table/alter-table-builder.js +138 -0
  270. package/dist/esm/table/constraint-builder.js +95 -0
  271. package/dist/esm/table/create-table-builder.js +241 -0
  272. package/dist/esm/table/index.js +5 -0
  273. package/dist/esm/table/partition-builder.js +121 -0
  274. package/dist/esm/table/truncate-builder.js +63 -0
  275. package/dist/esm/transaction/index.js +1 -0
  276. package/dist/esm/transaction/transaction-builder.js +70 -0
  277. package/dist/esm/trigger/create-trigger-builder.js +166 -0
  278. package/dist/esm/trigger/index.js +1 -0
  279. package/dist/esm/types/aggregate-types.js +1 -0
  280. package/dist/esm/types/config-types.js +36 -0
  281. package/dist/esm/types/inference-types.js +12 -0
  282. package/dist/esm/types/pagination-types.js +4 -0
  283. package/dist/esm/types/result-types.js +1 -0
  284. package/dist/esm/types/schema-types.js +1 -0
  285. package/dist/esm/types/subscription-types.js +1 -0
  286. package/dist/esm/types.js +1 -0
  287. package/dist/esm/update/array-update-builder.js +192 -0
  288. package/dist/esm/update/index.js +2 -0
  289. package/dist/esm/update/update-builder.js +188 -0
  290. package/dist/esm/utils/case-converter.js +55 -0
  291. package/dist/esm/utils/environment-detection.js +113 -0
  292. package/dist/esm/utils/index.js +2 -0
  293. package/dist/esm/utils/pool-defaults.js +100 -0
  294. package/dist/esm/utils/type-coercion.js +110 -0
  295. package/dist/esm/view/create-view-builder.js +171 -0
  296. package/dist/esm/view/index.js +1 -0
  297. package/dist/esm/window/index.js +1 -0
  298. package/dist/esm/window/window-builder.js +73 -0
  299. package/dist/index.cjs +1 -0
  300. package/dist/index.d.ts +10341 -0
  301. package/dist/index.js +1 -0
  302. package/dist/schema-builder.cjs +1 -0
  303. package/dist/schema-builder.d.ts +2272 -0
  304. package/dist/schema-builder.js +1 -0
  305. package/package.json +55 -0
@@ -0,0 +1,2248 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __reExport = (target, mod, secondTarget) => {
5
+ for (let key of __getOwnPropNames(mod))
6
+ if (!__hasOwnProp.call(target, key) && key !== "default")
7
+ __defProp(target, key, {
8
+ get: () => mod[key],
9
+ enumerable: true
10
+ });
11
+ if (secondTarget) {
12
+ for (let key of __getOwnPropNames(mod))
13
+ if (!__hasOwnProp.call(secondTarget, key) && key !== "default")
14
+ __defProp(secondTarget, key, {
15
+ get: () => mod[key],
16
+ enumerable: true
17
+ });
18
+ return secondTarget;
19
+ }
20
+ };
21
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, {
25
+ get: all[name],
26
+ enumerable: true,
27
+ configurable: true,
28
+ set: (newValue) => all[name] = () => newValue
29
+ });
30
+ };
31
+
32
+ // node_modules/base64-js/index.js
33
+ var require_base64_js = __commonJS((exports) => {
34
+ exports.byteLength = byteLength;
35
+ exports.toByteArray = toByteArray;
36
+ exports.fromByteArray = fromByteArray;
37
+ var lookup = [];
38
+ var revLookup = [];
39
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
40
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
41
+ for (i = 0, len = code.length;i < len; ++i) {
42
+ lookup[i] = code[i];
43
+ revLookup[code.charCodeAt(i)] = i;
44
+ }
45
+ var i;
46
+ var len;
47
+ revLookup[45] = 62;
48
+ revLookup[95] = 63;
49
+ function getLens(b64) {
50
+ var len2 = b64.length;
51
+ if (len2 % 4 > 0) {
52
+ throw new Error("Invalid string. Length must be a multiple of 4");
53
+ }
54
+ var validLen = b64.indexOf("=");
55
+ if (validLen === -1)
56
+ validLen = len2;
57
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
58
+ return [validLen, placeHoldersLen];
59
+ }
60
+ function byteLength(b64) {
61
+ var lens = getLens(b64);
62
+ var validLen = lens[0];
63
+ var placeHoldersLen = lens[1];
64
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
65
+ }
66
+ function _byteLength(b64, validLen, placeHoldersLen) {
67
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
68
+ }
69
+ function toByteArray(b64) {
70
+ var tmp;
71
+ var lens = getLens(b64);
72
+ var validLen = lens[0];
73
+ var placeHoldersLen = lens[1];
74
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
75
+ var curByte = 0;
76
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
77
+ var i2;
78
+ for (i2 = 0;i2 < len2; i2 += 4) {
79
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
80
+ arr[curByte++] = tmp >> 16 & 255;
81
+ arr[curByte++] = tmp >> 8 & 255;
82
+ arr[curByte++] = tmp & 255;
83
+ }
84
+ if (placeHoldersLen === 2) {
85
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
86
+ arr[curByte++] = tmp & 255;
87
+ }
88
+ if (placeHoldersLen === 1) {
89
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
90
+ arr[curByte++] = tmp >> 8 & 255;
91
+ arr[curByte++] = tmp & 255;
92
+ }
93
+ return arr;
94
+ }
95
+ function tripletToBase64(num) {
96
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
97
+ }
98
+ function encodeChunk(uint8, start, end) {
99
+ var tmp;
100
+ var output = [];
101
+ for (var i2 = start;i2 < end; i2 += 3) {
102
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
103
+ output.push(tripletToBase64(tmp));
104
+ }
105
+ return output.join("");
106
+ }
107
+ function fromByteArray(uint8) {
108
+ var tmp;
109
+ var len2 = uint8.length;
110
+ var extraBytes = len2 % 3;
111
+ var parts = [];
112
+ var maxChunkLength = 16383;
113
+ for (var i2 = 0, len22 = len2 - extraBytes;i2 < len22; i2 += maxChunkLength) {
114
+ parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
115
+ }
116
+ if (extraBytes === 1) {
117
+ tmp = uint8[len2 - 1];
118
+ parts.push(lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "==");
119
+ } else if (extraBytes === 2) {
120
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
121
+ parts.push(lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "=");
122
+ }
123
+ return parts.join("");
124
+ }
125
+ });
126
+
127
+ // node_modules/ieee754/index.js
128
+ var require_ieee754 = __commonJS((exports) => {
129
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
130
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
131
+ var e, m;
132
+ var eLen = nBytes * 8 - mLen - 1;
133
+ var eMax = (1 << eLen) - 1;
134
+ var eBias = eMax >> 1;
135
+ var nBits = -7;
136
+ var i = isLE ? nBytes - 1 : 0;
137
+ var d = isLE ? -1 : 1;
138
+ var s = buffer[offset + i];
139
+ i += d;
140
+ e = s & (1 << -nBits) - 1;
141
+ s >>= -nBits;
142
+ nBits += eLen;
143
+ for (;nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
144
+ m = e & (1 << -nBits) - 1;
145
+ e >>= -nBits;
146
+ nBits += mLen;
147
+ for (;nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
148
+ if (e === 0) {
149
+ e = 1 - eBias;
150
+ } else if (e === eMax) {
151
+ return m ? NaN : (s ? -1 : 1) * Infinity;
152
+ } else {
153
+ m = m + Math.pow(2, mLen);
154
+ e = e - eBias;
155
+ }
156
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
157
+ };
158
+ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
159
+ var e, m, c;
160
+ var eLen = nBytes * 8 - mLen - 1;
161
+ var eMax = (1 << eLen) - 1;
162
+ var eBias = eMax >> 1;
163
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
164
+ var i = isLE ? 0 : nBytes - 1;
165
+ var d = isLE ? 1 : -1;
166
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
167
+ value = Math.abs(value);
168
+ if (isNaN(value) || value === Infinity) {
169
+ m = isNaN(value) ? 1 : 0;
170
+ e = eMax;
171
+ } else {
172
+ e = Math.floor(Math.log(value) / Math.LN2);
173
+ if (value * (c = Math.pow(2, -e)) < 1) {
174
+ e--;
175
+ c *= 2;
176
+ }
177
+ if (e + eBias >= 1) {
178
+ value += rt / c;
179
+ } else {
180
+ value += rt * Math.pow(2, 1 - eBias);
181
+ }
182
+ if (value * c >= 2) {
183
+ e++;
184
+ c /= 2;
185
+ }
186
+ if (e + eBias >= eMax) {
187
+ m = 0;
188
+ e = eMax;
189
+ } else if (e + eBias >= 1) {
190
+ m = (value * c - 1) * Math.pow(2, mLen);
191
+ e = e + eBias;
192
+ } else {
193
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
194
+ e = 0;
195
+ }
196
+ }
197
+ for (;mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {}
198
+ e = e << mLen | m;
199
+ eLen += mLen;
200
+ for (;eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {}
201
+ buffer[offset + i - d] |= s * 128;
202
+ };
203
+ });
204
+
205
+ // src/addon/pg-format/reserved.ts
206
+ var reserved_default = {
207
+ AES128: true,
208
+ AES256: true,
209
+ ALL: true,
210
+ ALLOWOVERWRITE: true,
211
+ ANALYSE: true,
212
+ ANALYZE: true,
213
+ AND: true,
214
+ ANY: true,
215
+ ARRAY: true,
216
+ AS: true,
217
+ ASC: true,
218
+ AUTHORIZATION: true,
219
+ BACKUP: true,
220
+ BETWEEN: true,
221
+ BINARY: true,
222
+ BLANKSASNULL: true,
223
+ BOTH: true,
224
+ BYTEDICT: true,
225
+ CASE: true,
226
+ CAST: true,
227
+ CHECK: true,
228
+ COLLATE: true,
229
+ COLUMN: true,
230
+ CONSTRAINT: true,
231
+ CREATE: true,
232
+ CREDENTIALS: true,
233
+ CROSS: true,
234
+ CURRENT_DATE: true,
235
+ CURRENT_TIME: true,
236
+ CURRENT_TIMESTAMP: true,
237
+ CURRENT_USER: true,
238
+ CURRENT_USER_ID: true,
239
+ DEFAULT: true,
240
+ DEFERRABLE: true,
241
+ DEFLATE: true,
242
+ DEFRAG: true,
243
+ DELTA: true,
244
+ DELTA32K: true,
245
+ DESC: true,
246
+ DISABLE: true,
247
+ DISTINCT: true,
248
+ DO: true,
249
+ ELSE: true,
250
+ EMPTYASNULL: true,
251
+ ENABLE: true,
252
+ ENCODE: true,
253
+ ENCRYPT: true,
254
+ ENCRYPTION: true,
255
+ END: true,
256
+ EXCEPT: true,
257
+ EXPLICIT: true,
258
+ FALSE: true,
259
+ FOR: true,
260
+ FOREIGN: true,
261
+ FREEZE: true,
262
+ FROM: true,
263
+ FULL: true,
264
+ GLOBALDICT256: true,
265
+ GLOBALDICT64K: true,
266
+ GRANT: true,
267
+ GROUP: true,
268
+ GZIP: true,
269
+ HAVING: true,
270
+ IDENTITY: true,
271
+ IGNORE: true,
272
+ ILIKE: true,
273
+ IN: true,
274
+ INITIALLY: true,
275
+ INNER: true,
276
+ INTERSECT: true,
277
+ INTO: true,
278
+ IS: true,
279
+ ISNULL: true,
280
+ JOIN: true,
281
+ LEADING: true,
282
+ LEFT: true,
283
+ LIKE: true,
284
+ LIMIT: true,
285
+ LOCALTIME: true,
286
+ LOCALTIMESTAMP: true,
287
+ LUN: true,
288
+ LUNS: true,
289
+ LZO: true,
290
+ LZOP: true,
291
+ MINUS: true,
292
+ MOSTLY13: true,
293
+ MOSTLY32: true,
294
+ MOSTLY8: true,
295
+ NATURAL: true,
296
+ NEW: true,
297
+ NOT: true,
298
+ NOTNULL: true,
299
+ NULL: true,
300
+ NULLS: true,
301
+ OFF: true,
302
+ OFFLINE: true,
303
+ OFFSET: true,
304
+ OLD: true,
305
+ ON: true,
306
+ ONLY: true,
307
+ OPEN: true,
308
+ OR: true,
309
+ ORDER: true,
310
+ OUTER: true,
311
+ OVERLAPS: true,
312
+ PARALLEL: true,
313
+ PARTITION: true,
314
+ PERCENT: true,
315
+ PLACING: true,
316
+ PRIMARY: true,
317
+ RAW: true,
318
+ READRATIO: true,
319
+ RECOVER: true,
320
+ REFERENCES: true,
321
+ REJECTLOG: true,
322
+ RESORT: true,
323
+ RESTORE: true,
324
+ RIGHT: true,
325
+ SELECT: true,
326
+ SESSION_USER: true,
327
+ SIMILAR: true,
328
+ SOME: true,
329
+ SYSDATE: true,
330
+ SYSTEM: true,
331
+ TABLE: true,
332
+ TAG: true,
333
+ TDES: true,
334
+ TEXT255: true,
335
+ TEXT32K: true,
336
+ THEN: true,
337
+ TO: true,
338
+ TOP: true,
339
+ TRAILING: true,
340
+ TRUE: true,
341
+ TRUNCATECOLUMNS: true,
342
+ UNION: true,
343
+ UNIQUE: true,
344
+ USER: true,
345
+ USING: true,
346
+ VERBOSE: true,
347
+ WALLET: true,
348
+ WHEN: true,
349
+ WHERE: true,
350
+ WITH: true,
351
+ WITHOUT: true
352
+ };
353
+
354
+ // src/addon/buffer/index.ts
355
+ var exports_buffer2 = {};
356
+ __export(exports_buffer2, {
357
+ kMaxLength: () => $kMaxLength,
358
+ default: () => buffer_default,
359
+ SlowBuffer: () => $SlowBuffer,
360
+ INSPECT_MAX_BYTES: () => $INSPECT_MAX_BYTES,
361
+ Buffer: () => $Buffer
362
+ });
363
+
364
+ // node_modules/buffer/index.js
365
+ var exports_buffer = {};
366
+ __export(exports_buffer, {
367
+ kMaxLength: () => $kMaxLength,
368
+ SlowBuffer: () => $SlowBuffer,
369
+ INSPECT_MAX_BYTES: () => $INSPECT_MAX_BYTES,
370
+ Buffer: () => $Buffer
371
+ });
372
+ /*!
373
+ * The buffer module from node.js, for the browser.
374
+ *
375
+ * @author Feross Aboukhadijeh <https://feross.org>
376
+ * @license MIT
377
+ */
378
+ var base64 = require_base64_js();
379
+ var ieee754 = require_ieee754();
380
+ var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
381
+ var $Buffer = Buffer;
382
+ var $SlowBuffer = SlowBuffer;
383
+ var $INSPECT_MAX_BYTES = 50;
384
+ var K_MAX_LENGTH = 2147483647;
385
+ var $kMaxLength = K_MAX_LENGTH;
386
+ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
387
+ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
388
+ console.error("This browser lacks typed array (Uint8Array) support which is required by " + "`buffer` v5.x. Use `buffer` v4.x if you require old browser support.");
389
+ }
390
+ function typedArraySupport() {
391
+ try {
392
+ const arr = new Uint8Array(1);
393
+ const proto = { foo: function() {
394
+ return 42;
395
+ } };
396
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
397
+ Object.setPrototypeOf(arr, proto);
398
+ return arr.foo() === 42;
399
+ } catch (e) {
400
+ return false;
401
+ }
402
+ }
403
+ Object.defineProperty(Buffer.prototype, "parent", {
404
+ enumerable: true,
405
+ get: function() {
406
+ if (!Buffer.isBuffer(this))
407
+ return;
408
+ return this.buffer;
409
+ }
410
+ });
411
+ Object.defineProperty(Buffer.prototype, "offset", {
412
+ enumerable: true,
413
+ get: function() {
414
+ if (!Buffer.isBuffer(this))
415
+ return;
416
+ return this.byteOffset;
417
+ }
418
+ });
419
+ function createBuffer(length) {
420
+ if (length > K_MAX_LENGTH) {
421
+ throw new RangeError('The value "' + length + '" is invalid for option "size"');
422
+ }
423
+ const buf = new Uint8Array(length);
424
+ Object.setPrototypeOf(buf, Buffer.prototype);
425
+ return buf;
426
+ }
427
+ function Buffer(arg, encodingOrOffset, length) {
428
+ if (typeof arg === "number") {
429
+ if (typeof encodingOrOffset === "string") {
430
+ throw new TypeError('The "string" argument must be of type string. Received type number');
431
+ }
432
+ return allocUnsafe(arg);
433
+ }
434
+ return from(arg, encodingOrOffset, length);
435
+ }
436
+ Buffer.poolSize = 8192;
437
+ function from(value, encodingOrOffset, length) {
438
+ if (typeof value === "string") {
439
+ return fromString(value, encodingOrOffset);
440
+ }
441
+ if (ArrayBuffer.isView(value)) {
442
+ return fromArrayView(value);
443
+ }
444
+ if (value == null) {
445
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, " + "or Array-like Object. Received type " + typeof value);
446
+ }
447
+ if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
448
+ return fromArrayBuffer(value, encodingOrOffset, length);
449
+ }
450
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
451
+ return fromArrayBuffer(value, encodingOrOffset, length);
452
+ }
453
+ if (typeof value === "number") {
454
+ throw new TypeError('The "value" argument must not be of type number. Received type number');
455
+ }
456
+ const valueOf = value.valueOf && value.valueOf();
457
+ if (valueOf != null && valueOf !== value) {
458
+ return Buffer.from(valueOf, encodingOrOffset, length);
459
+ }
460
+ const b = fromObject(value);
461
+ if (b)
462
+ return b;
463
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
464
+ return Buffer.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
465
+ }
466
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, " + "or Array-like Object. Received type " + typeof value);
467
+ }
468
+ Buffer.from = function(value, encodingOrOffset, length) {
469
+ return from(value, encodingOrOffset, length);
470
+ };
471
+ Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
472
+ Object.setPrototypeOf(Buffer, Uint8Array);
473
+ function assertSize(size) {
474
+ if (typeof size !== "number") {
475
+ throw new TypeError('"size" argument must be of type number');
476
+ } else if (size < 0) {
477
+ throw new RangeError('The value "' + size + '" is invalid for option "size"');
478
+ }
479
+ }
480
+ function alloc(size, fill, encoding) {
481
+ assertSize(size);
482
+ if (size <= 0) {
483
+ return createBuffer(size);
484
+ }
485
+ if (fill !== undefined) {
486
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
487
+ }
488
+ return createBuffer(size);
489
+ }
490
+ Buffer.alloc = function(size, fill, encoding) {
491
+ return alloc(size, fill, encoding);
492
+ };
493
+ function allocUnsafe(size) {
494
+ assertSize(size);
495
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
496
+ }
497
+ Buffer.allocUnsafe = function(size) {
498
+ return allocUnsafe(size);
499
+ };
500
+ Buffer.allocUnsafeSlow = function(size) {
501
+ return allocUnsafe(size);
502
+ };
503
+ function fromString(string, encoding) {
504
+ if (typeof encoding !== "string" || encoding === "") {
505
+ encoding = "utf8";
506
+ }
507
+ if (!Buffer.isEncoding(encoding)) {
508
+ throw new TypeError("Unknown encoding: " + encoding);
509
+ }
510
+ const length = byteLength(string, encoding) | 0;
511
+ let buf = createBuffer(length);
512
+ const actual = buf.write(string, encoding);
513
+ if (actual !== length) {
514
+ buf = buf.slice(0, actual);
515
+ }
516
+ return buf;
517
+ }
518
+ function fromArrayLike(array) {
519
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
520
+ const buf = createBuffer(length);
521
+ for (let i = 0;i < length; i += 1) {
522
+ buf[i] = array[i] & 255;
523
+ }
524
+ return buf;
525
+ }
526
+ function fromArrayView(arrayView) {
527
+ if (isInstance(arrayView, Uint8Array)) {
528
+ const copy = new Uint8Array(arrayView);
529
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
530
+ }
531
+ return fromArrayLike(arrayView);
532
+ }
533
+ function fromArrayBuffer(array, byteOffset, length) {
534
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
535
+ throw new RangeError('"offset" is outside of buffer bounds');
536
+ }
537
+ if (array.byteLength < byteOffset + (length || 0)) {
538
+ throw new RangeError('"length" is outside of buffer bounds');
539
+ }
540
+ let buf;
541
+ if (byteOffset === undefined && length === undefined) {
542
+ buf = new Uint8Array(array);
543
+ } else if (length === undefined) {
544
+ buf = new Uint8Array(array, byteOffset);
545
+ } else {
546
+ buf = new Uint8Array(array, byteOffset, length);
547
+ }
548
+ Object.setPrototypeOf(buf, Buffer.prototype);
549
+ return buf;
550
+ }
551
+ function fromObject(obj) {
552
+ if (Buffer.isBuffer(obj)) {
553
+ const len = checked(obj.length) | 0;
554
+ const buf = createBuffer(len);
555
+ if (buf.length === 0) {
556
+ return buf;
557
+ }
558
+ obj.copy(buf, 0, 0, len);
559
+ return buf;
560
+ }
561
+ if (obj.length !== undefined) {
562
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
563
+ return createBuffer(0);
564
+ }
565
+ return fromArrayLike(obj);
566
+ }
567
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
568
+ return fromArrayLike(obj.data);
569
+ }
570
+ }
571
+ function checked(length) {
572
+ if (length >= K_MAX_LENGTH) {
573
+ throw new RangeError("Attempt to allocate Buffer larger than maximum " + "size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
574
+ }
575
+ return length | 0;
576
+ }
577
+ function SlowBuffer(length) {
578
+ if (+length != length) {
579
+ length = 0;
580
+ }
581
+ return Buffer.alloc(+length);
582
+ }
583
+ Buffer.isBuffer = function isBuffer(b) {
584
+ return b != null && b._isBuffer === true && b !== Buffer.prototype;
585
+ };
586
+ Buffer.compare = function compare(a, b) {
587
+ if (isInstance(a, Uint8Array))
588
+ a = Buffer.from(a, a.offset, a.byteLength);
589
+ if (isInstance(b, Uint8Array))
590
+ b = Buffer.from(b, b.offset, b.byteLength);
591
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
592
+ throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
593
+ }
594
+ if (a === b)
595
+ return 0;
596
+ let x = a.length;
597
+ let y = b.length;
598
+ for (let i = 0, len = Math.min(x, y);i < len; ++i) {
599
+ if (a[i] !== b[i]) {
600
+ x = a[i];
601
+ y = b[i];
602
+ break;
603
+ }
604
+ }
605
+ if (x < y)
606
+ return -1;
607
+ if (y < x)
608
+ return 1;
609
+ return 0;
610
+ };
611
+ Buffer.isEncoding = function isEncoding(encoding) {
612
+ switch (String(encoding).toLowerCase()) {
613
+ case "hex":
614
+ case "utf8":
615
+ case "utf-8":
616
+ case "ascii":
617
+ case "latin1":
618
+ case "binary":
619
+ case "base64":
620
+ case "ucs2":
621
+ case "ucs-2":
622
+ case "utf16le":
623
+ case "utf-16le":
624
+ return true;
625
+ default:
626
+ return false;
627
+ }
628
+ };
629
+ Buffer.concat = function concat(list, length) {
630
+ if (!Array.isArray(list)) {
631
+ throw new TypeError('"list" argument must be an Array of Buffers');
632
+ }
633
+ if (list.length === 0) {
634
+ return Buffer.alloc(0);
635
+ }
636
+ let i;
637
+ if (length === undefined) {
638
+ length = 0;
639
+ for (i = 0;i < list.length; ++i) {
640
+ length += list[i].length;
641
+ }
642
+ }
643
+ const buffer = Buffer.allocUnsafe(length);
644
+ let pos = 0;
645
+ for (i = 0;i < list.length; ++i) {
646
+ let buf = list[i];
647
+ if (isInstance(buf, Uint8Array)) {
648
+ if (pos + buf.length > buffer.length) {
649
+ if (!Buffer.isBuffer(buf))
650
+ buf = Buffer.from(buf);
651
+ buf.copy(buffer, pos);
652
+ } else {
653
+ Uint8Array.prototype.set.call(buffer, buf, pos);
654
+ }
655
+ } else if (!Buffer.isBuffer(buf)) {
656
+ throw new TypeError('"list" argument must be an Array of Buffers');
657
+ } else {
658
+ buf.copy(buffer, pos);
659
+ }
660
+ pos += buf.length;
661
+ }
662
+ return buffer;
663
+ };
664
+ function byteLength(string, encoding) {
665
+ if (Buffer.isBuffer(string)) {
666
+ return string.length;
667
+ }
668
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
669
+ return string.byteLength;
670
+ }
671
+ if (typeof string !== "string") {
672
+ throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' + "Received type " + typeof string);
673
+ }
674
+ const len = string.length;
675
+ const mustMatch = arguments.length > 2 && arguments[2] === true;
676
+ if (!mustMatch && len === 0)
677
+ return 0;
678
+ let loweredCase = false;
679
+ for (;; ) {
680
+ switch (encoding) {
681
+ case "ascii":
682
+ case "latin1":
683
+ case "binary":
684
+ return len;
685
+ case "utf8":
686
+ case "utf-8":
687
+ return utf8ToBytes(string).length;
688
+ case "ucs2":
689
+ case "ucs-2":
690
+ case "utf16le":
691
+ case "utf-16le":
692
+ return len * 2;
693
+ case "hex":
694
+ return len >>> 1;
695
+ case "base64":
696
+ return base64ToBytes(string).length;
697
+ default:
698
+ if (loweredCase) {
699
+ return mustMatch ? -1 : utf8ToBytes(string).length;
700
+ }
701
+ encoding = ("" + encoding).toLowerCase();
702
+ loweredCase = true;
703
+ }
704
+ }
705
+ }
706
+ Buffer.byteLength = byteLength;
707
+ function slowToString(encoding, start, end) {
708
+ let loweredCase = false;
709
+ if (start === undefined || start < 0) {
710
+ start = 0;
711
+ }
712
+ if (start > this.length) {
713
+ return "";
714
+ }
715
+ if (end === undefined || end > this.length) {
716
+ end = this.length;
717
+ }
718
+ if (end <= 0) {
719
+ return "";
720
+ }
721
+ end >>>= 0;
722
+ start >>>= 0;
723
+ if (end <= start) {
724
+ return "";
725
+ }
726
+ if (!encoding)
727
+ encoding = "utf8";
728
+ while (true) {
729
+ switch (encoding) {
730
+ case "hex":
731
+ return hexSlice(this, start, end);
732
+ case "utf8":
733
+ case "utf-8":
734
+ return utf8Slice(this, start, end);
735
+ case "ascii":
736
+ return asciiSlice(this, start, end);
737
+ case "latin1":
738
+ case "binary":
739
+ return latin1Slice(this, start, end);
740
+ case "base64":
741
+ return base64Slice(this, start, end);
742
+ case "ucs2":
743
+ case "ucs-2":
744
+ case "utf16le":
745
+ case "utf-16le":
746
+ return utf16leSlice(this, start, end);
747
+ default:
748
+ if (loweredCase)
749
+ throw new TypeError("Unknown encoding: " + encoding);
750
+ encoding = (encoding + "").toLowerCase();
751
+ loweredCase = true;
752
+ }
753
+ }
754
+ }
755
+ Buffer.prototype._isBuffer = true;
756
+ function swap(b, n, m) {
757
+ const i = b[n];
758
+ b[n] = b[m];
759
+ b[m] = i;
760
+ }
761
+ Buffer.prototype.swap16 = function swap16() {
762
+ const len = this.length;
763
+ if (len % 2 !== 0) {
764
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
765
+ }
766
+ for (let i = 0;i < len; i += 2) {
767
+ swap(this, i, i + 1);
768
+ }
769
+ return this;
770
+ };
771
+ Buffer.prototype.swap32 = function swap32() {
772
+ const len = this.length;
773
+ if (len % 4 !== 0) {
774
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
775
+ }
776
+ for (let i = 0;i < len; i += 4) {
777
+ swap(this, i, i + 3);
778
+ swap(this, i + 1, i + 2);
779
+ }
780
+ return this;
781
+ };
782
+ Buffer.prototype.swap64 = function swap64() {
783
+ const len = this.length;
784
+ if (len % 8 !== 0) {
785
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
786
+ }
787
+ for (let i = 0;i < len; i += 8) {
788
+ swap(this, i, i + 7);
789
+ swap(this, i + 1, i + 6);
790
+ swap(this, i + 2, i + 5);
791
+ swap(this, i + 3, i + 4);
792
+ }
793
+ return this;
794
+ };
795
+ Buffer.prototype.toString = function toString() {
796
+ const length = this.length;
797
+ if (length === 0)
798
+ return "";
799
+ if (arguments.length === 0)
800
+ return utf8Slice(this, 0, length);
801
+ return slowToString.apply(this, arguments);
802
+ };
803
+ Buffer.prototype.toLocaleString = Buffer.prototype.toString;
804
+ Buffer.prototype.equals = function equals(b) {
805
+ if (!Buffer.isBuffer(b))
806
+ throw new TypeError("Argument must be a Buffer");
807
+ if (this === b)
808
+ return true;
809
+ return Buffer.compare(this, b) === 0;
810
+ };
811
+ Buffer.prototype.inspect = function inspect() {
812
+ let str = "";
813
+ const max = $INSPECT_MAX_BYTES;
814
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
815
+ if (this.length > max)
816
+ str += " ... ";
817
+ return "<Buffer " + str + ">";
818
+ };
819
+ if (customInspectSymbol) {
820
+ Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
821
+ }
822
+ Buffer.prototype.compare = function compare2(target, start, end, thisStart, thisEnd) {
823
+ if (isInstance(target, Uint8Array)) {
824
+ target = Buffer.from(target, target.offset, target.byteLength);
825
+ }
826
+ if (!Buffer.isBuffer(target)) {
827
+ throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. ' + "Received type " + typeof target);
828
+ }
829
+ if (start === undefined) {
830
+ start = 0;
831
+ }
832
+ if (end === undefined) {
833
+ end = target ? target.length : 0;
834
+ }
835
+ if (thisStart === undefined) {
836
+ thisStart = 0;
837
+ }
838
+ if (thisEnd === undefined) {
839
+ thisEnd = this.length;
840
+ }
841
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
842
+ throw new RangeError("out of range index");
843
+ }
844
+ if (thisStart >= thisEnd && start >= end) {
845
+ return 0;
846
+ }
847
+ if (thisStart >= thisEnd) {
848
+ return -1;
849
+ }
850
+ if (start >= end) {
851
+ return 1;
852
+ }
853
+ start >>>= 0;
854
+ end >>>= 0;
855
+ thisStart >>>= 0;
856
+ thisEnd >>>= 0;
857
+ if (this === target)
858
+ return 0;
859
+ let x = thisEnd - thisStart;
860
+ let y = end - start;
861
+ const len = Math.min(x, y);
862
+ const thisCopy = this.slice(thisStart, thisEnd);
863
+ const targetCopy = target.slice(start, end);
864
+ for (let i = 0;i < len; ++i) {
865
+ if (thisCopy[i] !== targetCopy[i]) {
866
+ x = thisCopy[i];
867
+ y = targetCopy[i];
868
+ break;
869
+ }
870
+ }
871
+ if (x < y)
872
+ return -1;
873
+ if (y < x)
874
+ return 1;
875
+ return 0;
876
+ };
877
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
878
+ if (buffer.length === 0)
879
+ return -1;
880
+ if (typeof byteOffset === "string") {
881
+ encoding = byteOffset;
882
+ byteOffset = 0;
883
+ } else if (byteOffset > 2147483647) {
884
+ byteOffset = 2147483647;
885
+ } else if (byteOffset < -2147483648) {
886
+ byteOffset = -2147483648;
887
+ }
888
+ byteOffset = +byteOffset;
889
+ if (numberIsNaN(byteOffset)) {
890
+ byteOffset = dir ? 0 : buffer.length - 1;
891
+ }
892
+ if (byteOffset < 0)
893
+ byteOffset = buffer.length + byteOffset;
894
+ if (byteOffset >= buffer.length) {
895
+ if (dir)
896
+ return -1;
897
+ else
898
+ byteOffset = buffer.length - 1;
899
+ } else if (byteOffset < 0) {
900
+ if (dir)
901
+ byteOffset = 0;
902
+ else
903
+ return -1;
904
+ }
905
+ if (typeof val === "string") {
906
+ val = Buffer.from(val, encoding);
907
+ }
908
+ if (Buffer.isBuffer(val)) {
909
+ if (val.length === 0) {
910
+ return -1;
911
+ }
912
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
913
+ } else if (typeof val === "number") {
914
+ val = val & 255;
915
+ if (typeof Uint8Array.prototype.indexOf === "function") {
916
+ if (dir) {
917
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
918
+ } else {
919
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
920
+ }
921
+ }
922
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
923
+ }
924
+ throw new TypeError("val must be string, number or Buffer");
925
+ }
926
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
927
+ let indexSize = 1;
928
+ let arrLength = arr.length;
929
+ let valLength = val.length;
930
+ if (encoding !== undefined) {
931
+ encoding = String(encoding).toLowerCase();
932
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
933
+ if (arr.length < 2 || val.length < 2) {
934
+ return -1;
935
+ }
936
+ indexSize = 2;
937
+ arrLength /= 2;
938
+ valLength /= 2;
939
+ byteOffset /= 2;
940
+ }
941
+ }
942
+ function read(buf, i2) {
943
+ if (indexSize === 1) {
944
+ return buf[i2];
945
+ } else {
946
+ return buf.readUInt16BE(i2 * indexSize);
947
+ }
948
+ }
949
+ let i;
950
+ if (dir) {
951
+ let foundIndex = -1;
952
+ for (i = byteOffset;i < arrLength; i++) {
953
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
954
+ if (foundIndex === -1)
955
+ foundIndex = i;
956
+ if (i - foundIndex + 1 === valLength)
957
+ return foundIndex * indexSize;
958
+ } else {
959
+ if (foundIndex !== -1)
960
+ i -= i - foundIndex;
961
+ foundIndex = -1;
962
+ }
963
+ }
964
+ } else {
965
+ if (byteOffset + valLength > arrLength)
966
+ byteOffset = arrLength - valLength;
967
+ for (i = byteOffset;i >= 0; i--) {
968
+ let found = true;
969
+ for (let j = 0;j < valLength; j++) {
970
+ if (read(arr, i + j) !== read(val, j)) {
971
+ found = false;
972
+ break;
973
+ }
974
+ }
975
+ if (found)
976
+ return i;
977
+ }
978
+ }
979
+ return -1;
980
+ }
981
+ Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
982
+ return this.indexOf(val, byteOffset, encoding) !== -1;
983
+ };
984
+ Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
985
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
986
+ };
987
+ Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
988
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
989
+ };
990
+ function hexWrite(buf, string, offset, length) {
991
+ offset = Number(offset) || 0;
992
+ const remaining = buf.length - offset;
993
+ if (!length) {
994
+ length = remaining;
995
+ } else {
996
+ length = Number(length);
997
+ if (length > remaining) {
998
+ length = remaining;
999
+ }
1000
+ }
1001
+ const strLen = string.length;
1002
+ if (length > strLen / 2) {
1003
+ length = strLen / 2;
1004
+ }
1005
+ let i;
1006
+ for (i = 0;i < length; ++i) {
1007
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
1008
+ if (numberIsNaN(parsed))
1009
+ return i;
1010
+ buf[offset + i] = parsed;
1011
+ }
1012
+ return i;
1013
+ }
1014
+ function utf8Write(buf, string, offset, length) {
1015
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
1016
+ }
1017
+ function asciiWrite(buf, string, offset, length) {
1018
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
1019
+ }
1020
+ function base64Write(buf, string, offset, length) {
1021
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
1022
+ }
1023
+ function ucs2Write(buf, string, offset, length) {
1024
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
1025
+ }
1026
+ Buffer.prototype.write = function write(string, offset, length, encoding) {
1027
+ if (offset === undefined) {
1028
+ encoding = "utf8";
1029
+ length = this.length;
1030
+ offset = 0;
1031
+ } else if (length === undefined && typeof offset === "string") {
1032
+ encoding = offset;
1033
+ length = this.length;
1034
+ offset = 0;
1035
+ } else if (isFinite(offset)) {
1036
+ offset = offset >>> 0;
1037
+ if (isFinite(length)) {
1038
+ length = length >>> 0;
1039
+ if (encoding === undefined)
1040
+ encoding = "utf8";
1041
+ } else {
1042
+ encoding = length;
1043
+ length = undefined;
1044
+ }
1045
+ } else {
1046
+ throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
1047
+ }
1048
+ const remaining = this.length - offset;
1049
+ if (length === undefined || length > remaining)
1050
+ length = remaining;
1051
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
1052
+ throw new RangeError("Attempt to write outside buffer bounds");
1053
+ }
1054
+ if (!encoding)
1055
+ encoding = "utf8";
1056
+ let loweredCase = false;
1057
+ for (;; ) {
1058
+ switch (encoding) {
1059
+ case "hex":
1060
+ return hexWrite(this, string, offset, length);
1061
+ case "utf8":
1062
+ case "utf-8":
1063
+ return utf8Write(this, string, offset, length);
1064
+ case "ascii":
1065
+ case "latin1":
1066
+ case "binary":
1067
+ return asciiWrite(this, string, offset, length);
1068
+ case "base64":
1069
+ return base64Write(this, string, offset, length);
1070
+ case "ucs2":
1071
+ case "ucs-2":
1072
+ case "utf16le":
1073
+ case "utf-16le":
1074
+ return ucs2Write(this, string, offset, length);
1075
+ default:
1076
+ if (loweredCase)
1077
+ throw new TypeError("Unknown encoding: " + encoding);
1078
+ encoding = ("" + encoding).toLowerCase();
1079
+ loweredCase = true;
1080
+ }
1081
+ }
1082
+ };
1083
+ Buffer.prototype.toJSON = function toJSON() {
1084
+ return {
1085
+ type: "Buffer",
1086
+ data: Array.prototype.slice.call(this._arr || this, 0)
1087
+ };
1088
+ };
1089
+ function base64Slice(buf, start, end) {
1090
+ if (start === 0 && end === buf.length) {
1091
+ return base64.fromByteArray(buf);
1092
+ } else {
1093
+ return base64.fromByteArray(buf.slice(start, end));
1094
+ }
1095
+ }
1096
+ function utf8Slice(buf, start, end) {
1097
+ end = Math.min(buf.length, end);
1098
+ const res = [];
1099
+ let i = start;
1100
+ while (i < end) {
1101
+ const firstByte = buf[i];
1102
+ let codePoint = null;
1103
+ let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
1104
+ if (i + bytesPerSequence <= end) {
1105
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
1106
+ switch (bytesPerSequence) {
1107
+ case 1:
1108
+ if (firstByte < 128) {
1109
+ codePoint = firstByte;
1110
+ }
1111
+ break;
1112
+ case 2:
1113
+ secondByte = buf[i + 1];
1114
+ if ((secondByte & 192) === 128) {
1115
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
1116
+ if (tempCodePoint > 127) {
1117
+ codePoint = tempCodePoint;
1118
+ }
1119
+ }
1120
+ break;
1121
+ case 3:
1122
+ secondByte = buf[i + 1];
1123
+ thirdByte = buf[i + 2];
1124
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
1125
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
1126
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
1127
+ codePoint = tempCodePoint;
1128
+ }
1129
+ }
1130
+ break;
1131
+ case 4:
1132
+ secondByte = buf[i + 1];
1133
+ thirdByte = buf[i + 2];
1134
+ fourthByte = buf[i + 3];
1135
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
1136
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
1137
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
1138
+ codePoint = tempCodePoint;
1139
+ }
1140
+ }
1141
+ }
1142
+ }
1143
+ if (codePoint === null) {
1144
+ codePoint = 65533;
1145
+ bytesPerSequence = 1;
1146
+ } else if (codePoint > 65535) {
1147
+ codePoint -= 65536;
1148
+ res.push(codePoint >>> 10 & 1023 | 55296);
1149
+ codePoint = 56320 | codePoint & 1023;
1150
+ }
1151
+ res.push(codePoint);
1152
+ i += bytesPerSequence;
1153
+ }
1154
+ return decodeCodePointsArray(res);
1155
+ }
1156
+ var MAX_ARGUMENTS_LENGTH = 4096;
1157
+ function decodeCodePointsArray(codePoints) {
1158
+ const len = codePoints.length;
1159
+ if (len <= MAX_ARGUMENTS_LENGTH) {
1160
+ return String.fromCharCode.apply(String, codePoints);
1161
+ }
1162
+ let res = "";
1163
+ let i = 0;
1164
+ while (i < len) {
1165
+ res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
1166
+ }
1167
+ return res;
1168
+ }
1169
+ function asciiSlice(buf, start, end) {
1170
+ let ret = "";
1171
+ end = Math.min(buf.length, end);
1172
+ for (let i = start;i < end; ++i) {
1173
+ ret += String.fromCharCode(buf[i] & 127);
1174
+ }
1175
+ return ret;
1176
+ }
1177
+ function latin1Slice(buf, start, end) {
1178
+ let ret = "";
1179
+ end = Math.min(buf.length, end);
1180
+ for (let i = start;i < end; ++i) {
1181
+ ret += String.fromCharCode(buf[i]);
1182
+ }
1183
+ return ret;
1184
+ }
1185
+ function hexSlice(buf, start, end) {
1186
+ const len = buf.length;
1187
+ if (!start || start < 0)
1188
+ start = 0;
1189
+ if (!end || end < 0 || end > len)
1190
+ end = len;
1191
+ let out = "";
1192
+ for (let i = start;i < end; ++i) {
1193
+ out += hexSliceLookupTable[buf[i]];
1194
+ }
1195
+ return out;
1196
+ }
1197
+ function utf16leSlice(buf, start, end) {
1198
+ const bytes = buf.slice(start, end);
1199
+ let res = "";
1200
+ for (let i = 0;i < bytes.length - 1; i += 2) {
1201
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
1202
+ }
1203
+ return res;
1204
+ }
1205
+ Buffer.prototype.slice = function slice(start, end) {
1206
+ const len = this.length;
1207
+ start = ~~start;
1208
+ end = end === undefined ? len : ~~end;
1209
+ if (start < 0) {
1210
+ start += len;
1211
+ if (start < 0)
1212
+ start = 0;
1213
+ } else if (start > len) {
1214
+ start = len;
1215
+ }
1216
+ if (end < 0) {
1217
+ end += len;
1218
+ if (end < 0)
1219
+ end = 0;
1220
+ } else if (end > len) {
1221
+ end = len;
1222
+ }
1223
+ if (end < start)
1224
+ end = start;
1225
+ const newBuf = this.subarray(start, end);
1226
+ Object.setPrototypeOf(newBuf, Buffer.prototype);
1227
+ return newBuf;
1228
+ };
1229
+ function checkOffset(offset, ext, length) {
1230
+ if (offset % 1 !== 0 || offset < 0)
1231
+ throw new RangeError("offset is not uint");
1232
+ if (offset + ext > length)
1233
+ throw new RangeError("Trying to access beyond buffer length");
1234
+ }
1235
+ Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
1236
+ offset = offset >>> 0;
1237
+ byteLength2 = byteLength2 >>> 0;
1238
+ if (!noAssert)
1239
+ checkOffset(offset, byteLength2, this.length);
1240
+ let val = this[offset];
1241
+ let mul = 1;
1242
+ let i = 0;
1243
+ while (++i < byteLength2 && (mul *= 256)) {
1244
+ val += this[offset + i] * mul;
1245
+ }
1246
+ return val;
1247
+ };
1248
+ Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
1249
+ offset = offset >>> 0;
1250
+ byteLength2 = byteLength2 >>> 0;
1251
+ if (!noAssert) {
1252
+ checkOffset(offset, byteLength2, this.length);
1253
+ }
1254
+ let val = this[offset + --byteLength2];
1255
+ let mul = 1;
1256
+ while (byteLength2 > 0 && (mul *= 256)) {
1257
+ val += this[offset + --byteLength2] * mul;
1258
+ }
1259
+ return val;
1260
+ };
1261
+ Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
1262
+ offset = offset >>> 0;
1263
+ if (!noAssert)
1264
+ checkOffset(offset, 1, this.length);
1265
+ return this[offset];
1266
+ };
1267
+ Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
1268
+ offset = offset >>> 0;
1269
+ if (!noAssert)
1270
+ checkOffset(offset, 2, this.length);
1271
+ return this[offset] | this[offset + 1] << 8;
1272
+ };
1273
+ Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
1274
+ offset = offset >>> 0;
1275
+ if (!noAssert)
1276
+ checkOffset(offset, 2, this.length);
1277
+ return this[offset] << 8 | this[offset + 1];
1278
+ };
1279
+ Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
1280
+ offset = offset >>> 0;
1281
+ if (!noAssert)
1282
+ checkOffset(offset, 4, this.length);
1283
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
1284
+ };
1285
+ Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
1286
+ offset = offset >>> 0;
1287
+ if (!noAssert)
1288
+ checkOffset(offset, 4, this.length);
1289
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
1290
+ };
1291
+ Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
1292
+ offset = offset >>> 0;
1293
+ validateNumber(offset, "offset");
1294
+ const first = this[offset];
1295
+ const last = this[offset + 7];
1296
+ if (first === undefined || last === undefined) {
1297
+ boundsError(offset, this.length - 8);
1298
+ }
1299
+ const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
1300
+ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
1301
+ return BigInt(lo) + (BigInt(hi) << BigInt(32));
1302
+ });
1303
+ Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
1304
+ offset = offset >>> 0;
1305
+ validateNumber(offset, "offset");
1306
+ const first = this[offset];
1307
+ const last = this[offset + 7];
1308
+ if (first === undefined || last === undefined) {
1309
+ boundsError(offset, this.length - 8);
1310
+ }
1311
+ const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1312
+ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
1313
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
1314
+ });
1315
+ Buffer.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
1316
+ offset = offset >>> 0;
1317
+ byteLength2 = byteLength2 >>> 0;
1318
+ if (!noAssert)
1319
+ checkOffset(offset, byteLength2, this.length);
1320
+ let val = this[offset];
1321
+ let mul = 1;
1322
+ let i = 0;
1323
+ while (++i < byteLength2 && (mul *= 256)) {
1324
+ val += this[offset + i] * mul;
1325
+ }
1326
+ mul *= 128;
1327
+ if (val >= mul)
1328
+ val -= Math.pow(2, 8 * byteLength2);
1329
+ return val;
1330
+ };
1331
+ Buffer.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
1332
+ offset = offset >>> 0;
1333
+ byteLength2 = byteLength2 >>> 0;
1334
+ if (!noAssert)
1335
+ checkOffset(offset, byteLength2, this.length);
1336
+ let i = byteLength2;
1337
+ let mul = 1;
1338
+ let val = this[offset + --i];
1339
+ while (i > 0 && (mul *= 256)) {
1340
+ val += this[offset + --i] * mul;
1341
+ }
1342
+ mul *= 128;
1343
+ if (val >= mul)
1344
+ val -= Math.pow(2, 8 * byteLength2);
1345
+ return val;
1346
+ };
1347
+ Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
1348
+ offset = offset >>> 0;
1349
+ if (!noAssert)
1350
+ checkOffset(offset, 1, this.length);
1351
+ if (!(this[offset] & 128))
1352
+ return this[offset];
1353
+ return (255 - this[offset] + 1) * -1;
1354
+ };
1355
+ Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
1356
+ offset = offset >>> 0;
1357
+ if (!noAssert)
1358
+ checkOffset(offset, 2, this.length);
1359
+ const val = this[offset] | this[offset + 1] << 8;
1360
+ return val & 32768 ? val | 4294901760 : val;
1361
+ };
1362
+ Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
1363
+ offset = offset >>> 0;
1364
+ if (!noAssert)
1365
+ checkOffset(offset, 2, this.length);
1366
+ const val = this[offset + 1] | this[offset] << 8;
1367
+ return val & 32768 ? val | 4294901760 : val;
1368
+ };
1369
+ Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
1370
+ offset = offset >>> 0;
1371
+ if (!noAssert)
1372
+ checkOffset(offset, 4, this.length);
1373
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
1374
+ };
1375
+ Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
1376
+ offset = offset >>> 0;
1377
+ if (!noAssert)
1378
+ checkOffset(offset, 4, this.length);
1379
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
1380
+ };
1381
+ Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
1382
+ offset = offset >>> 0;
1383
+ validateNumber(offset, "offset");
1384
+ const first = this[offset];
1385
+ const last = this[offset + 7];
1386
+ if (first === undefined || last === undefined) {
1387
+ boundsError(offset, this.length - 8);
1388
+ }
1389
+ const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
1390
+ return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
1391
+ });
1392
+ Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
1393
+ offset = offset >>> 0;
1394
+ validateNumber(offset, "offset");
1395
+ const first = this[offset];
1396
+ const last = this[offset + 7];
1397
+ if (first === undefined || last === undefined) {
1398
+ boundsError(offset, this.length - 8);
1399
+ }
1400
+ const val = (first << 24) + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1401
+ return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
1402
+ });
1403
+ Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
1404
+ offset = offset >>> 0;
1405
+ if (!noAssert)
1406
+ checkOffset(offset, 4, this.length);
1407
+ return ieee754.read(this, offset, true, 23, 4);
1408
+ };
1409
+ Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
1410
+ offset = offset >>> 0;
1411
+ if (!noAssert)
1412
+ checkOffset(offset, 4, this.length);
1413
+ return ieee754.read(this, offset, false, 23, 4);
1414
+ };
1415
+ Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
1416
+ offset = offset >>> 0;
1417
+ if (!noAssert)
1418
+ checkOffset(offset, 8, this.length);
1419
+ return ieee754.read(this, offset, true, 52, 8);
1420
+ };
1421
+ Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
1422
+ offset = offset >>> 0;
1423
+ if (!noAssert)
1424
+ checkOffset(offset, 8, this.length);
1425
+ return ieee754.read(this, offset, false, 52, 8);
1426
+ };
1427
+ function checkInt(buf, value, offset, ext, max, min) {
1428
+ if (!Buffer.isBuffer(buf))
1429
+ throw new TypeError('"buffer" argument must be a Buffer instance');
1430
+ if (value > max || value < min)
1431
+ throw new RangeError('"value" argument is out of bounds');
1432
+ if (offset + ext > buf.length)
1433
+ throw new RangeError("Index out of range");
1434
+ }
1435
+ Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
1436
+ value = +value;
1437
+ offset = offset >>> 0;
1438
+ byteLength2 = byteLength2 >>> 0;
1439
+ if (!noAssert) {
1440
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1441
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1442
+ }
1443
+ let mul = 1;
1444
+ let i = 0;
1445
+ this[offset] = value & 255;
1446
+ while (++i < byteLength2 && (mul *= 256)) {
1447
+ this[offset + i] = value / mul & 255;
1448
+ }
1449
+ return offset + byteLength2;
1450
+ };
1451
+ Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
1452
+ value = +value;
1453
+ offset = offset >>> 0;
1454
+ byteLength2 = byteLength2 >>> 0;
1455
+ if (!noAssert) {
1456
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1457
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1458
+ }
1459
+ let i = byteLength2 - 1;
1460
+ let mul = 1;
1461
+ this[offset + i] = value & 255;
1462
+ while (--i >= 0 && (mul *= 256)) {
1463
+ this[offset + i] = value / mul & 255;
1464
+ }
1465
+ return offset + byteLength2;
1466
+ };
1467
+ Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
1468
+ value = +value;
1469
+ offset = offset >>> 0;
1470
+ if (!noAssert)
1471
+ checkInt(this, value, offset, 1, 255, 0);
1472
+ this[offset] = value & 255;
1473
+ return offset + 1;
1474
+ };
1475
+ Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
1476
+ value = +value;
1477
+ offset = offset >>> 0;
1478
+ if (!noAssert)
1479
+ checkInt(this, value, offset, 2, 65535, 0);
1480
+ this[offset] = value & 255;
1481
+ this[offset + 1] = value >>> 8;
1482
+ return offset + 2;
1483
+ };
1484
+ Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
1485
+ value = +value;
1486
+ offset = offset >>> 0;
1487
+ if (!noAssert)
1488
+ checkInt(this, value, offset, 2, 65535, 0);
1489
+ this[offset] = value >>> 8;
1490
+ this[offset + 1] = value & 255;
1491
+ return offset + 2;
1492
+ };
1493
+ Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
1494
+ value = +value;
1495
+ offset = offset >>> 0;
1496
+ if (!noAssert)
1497
+ checkInt(this, value, offset, 4, 4294967295, 0);
1498
+ this[offset + 3] = value >>> 24;
1499
+ this[offset + 2] = value >>> 16;
1500
+ this[offset + 1] = value >>> 8;
1501
+ this[offset] = value & 255;
1502
+ return offset + 4;
1503
+ };
1504
+ Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
1505
+ value = +value;
1506
+ offset = offset >>> 0;
1507
+ if (!noAssert)
1508
+ checkInt(this, value, offset, 4, 4294967295, 0);
1509
+ this[offset] = value >>> 24;
1510
+ this[offset + 1] = value >>> 16;
1511
+ this[offset + 2] = value >>> 8;
1512
+ this[offset + 3] = value & 255;
1513
+ return offset + 4;
1514
+ };
1515
+ function wrtBigUInt64LE(buf, value, offset, min, max) {
1516
+ checkIntBI(value, min, max, buf, offset, 7);
1517
+ let lo = Number(value & BigInt(4294967295));
1518
+ buf[offset++] = lo;
1519
+ lo = lo >> 8;
1520
+ buf[offset++] = lo;
1521
+ lo = lo >> 8;
1522
+ buf[offset++] = lo;
1523
+ lo = lo >> 8;
1524
+ buf[offset++] = lo;
1525
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1526
+ buf[offset++] = hi;
1527
+ hi = hi >> 8;
1528
+ buf[offset++] = hi;
1529
+ hi = hi >> 8;
1530
+ buf[offset++] = hi;
1531
+ hi = hi >> 8;
1532
+ buf[offset++] = hi;
1533
+ return offset;
1534
+ }
1535
+ function wrtBigUInt64BE(buf, value, offset, min, max) {
1536
+ checkIntBI(value, min, max, buf, offset, 7);
1537
+ let lo = Number(value & BigInt(4294967295));
1538
+ buf[offset + 7] = lo;
1539
+ lo = lo >> 8;
1540
+ buf[offset + 6] = lo;
1541
+ lo = lo >> 8;
1542
+ buf[offset + 5] = lo;
1543
+ lo = lo >> 8;
1544
+ buf[offset + 4] = lo;
1545
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1546
+ buf[offset + 3] = hi;
1547
+ hi = hi >> 8;
1548
+ buf[offset + 2] = hi;
1549
+ hi = hi >> 8;
1550
+ buf[offset + 1] = hi;
1551
+ hi = hi >> 8;
1552
+ buf[offset] = hi;
1553
+ return offset + 8;
1554
+ }
1555
+ Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
1556
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1557
+ });
1558
+ Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
1559
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1560
+ });
1561
+ Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
1562
+ value = +value;
1563
+ offset = offset >>> 0;
1564
+ if (!noAssert) {
1565
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1566
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1567
+ }
1568
+ let i = 0;
1569
+ let mul = 1;
1570
+ let sub = 0;
1571
+ this[offset] = value & 255;
1572
+ while (++i < byteLength2 && (mul *= 256)) {
1573
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1574
+ sub = 1;
1575
+ }
1576
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1577
+ }
1578
+ return offset + byteLength2;
1579
+ };
1580
+ Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
1581
+ value = +value;
1582
+ offset = offset >>> 0;
1583
+ if (!noAssert) {
1584
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1585
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1586
+ }
1587
+ let i = byteLength2 - 1;
1588
+ let mul = 1;
1589
+ let sub = 0;
1590
+ this[offset + i] = value & 255;
1591
+ while (--i >= 0 && (mul *= 256)) {
1592
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1593
+ sub = 1;
1594
+ }
1595
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1596
+ }
1597
+ return offset + byteLength2;
1598
+ };
1599
+ Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
1600
+ value = +value;
1601
+ offset = offset >>> 0;
1602
+ if (!noAssert)
1603
+ checkInt(this, value, offset, 1, 127, -128);
1604
+ if (value < 0)
1605
+ value = 255 + value + 1;
1606
+ this[offset] = value & 255;
1607
+ return offset + 1;
1608
+ };
1609
+ Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
1610
+ value = +value;
1611
+ offset = offset >>> 0;
1612
+ if (!noAssert)
1613
+ checkInt(this, value, offset, 2, 32767, -32768);
1614
+ this[offset] = value & 255;
1615
+ this[offset + 1] = value >>> 8;
1616
+ return offset + 2;
1617
+ };
1618
+ Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
1619
+ value = +value;
1620
+ offset = offset >>> 0;
1621
+ if (!noAssert)
1622
+ checkInt(this, value, offset, 2, 32767, -32768);
1623
+ this[offset] = value >>> 8;
1624
+ this[offset + 1] = value & 255;
1625
+ return offset + 2;
1626
+ };
1627
+ Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
1628
+ value = +value;
1629
+ offset = offset >>> 0;
1630
+ if (!noAssert)
1631
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
1632
+ this[offset] = value & 255;
1633
+ this[offset + 1] = value >>> 8;
1634
+ this[offset + 2] = value >>> 16;
1635
+ this[offset + 3] = value >>> 24;
1636
+ return offset + 4;
1637
+ };
1638
+ Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
1639
+ value = +value;
1640
+ offset = offset >>> 0;
1641
+ if (!noAssert)
1642
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
1643
+ if (value < 0)
1644
+ value = 4294967295 + value + 1;
1645
+ this[offset] = value >>> 24;
1646
+ this[offset + 1] = value >>> 16;
1647
+ this[offset + 2] = value >>> 8;
1648
+ this[offset + 3] = value & 255;
1649
+ return offset + 4;
1650
+ };
1651
+ Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
1652
+ return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1653
+ });
1654
+ Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
1655
+ return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1656
+ });
1657
+ function checkIEEE754(buf, value, offset, ext, max, min) {
1658
+ if (offset + ext > buf.length)
1659
+ throw new RangeError("Index out of range");
1660
+ if (offset < 0)
1661
+ throw new RangeError("Index out of range");
1662
+ }
1663
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
1664
+ value = +value;
1665
+ offset = offset >>> 0;
1666
+ if (!noAssert) {
1667
+ checkIEEE754(buf, value, offset, 4, 340282346638528860000000000000000000000, -340282346638528860000000000000000000000);
1668
+ }
1669
+ ieee754.write(buf, value, offset, littleEndian, 23, 4);
1670
+ return offset + 4;
1671
+ }
1672
+ Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
1673
+ return writeFloat(this, value, offset, true, noAssert);
1674
+ };
1675
+ Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
1676
+ return writeFloat(this, value, offset, false, noAssert);
1677
+ };
1678
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
1679
+ value = +value;
1680
+ offset = offset >>> 0;
1681
+ if (!noAssert) {
1682
+ checkIEEE754(buf, value, offset, 8, 179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, -179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);
1683
+ }
1684
+ ieee754.write(buf, value, offset, littleEndian, 52, 8);
1685
+ return offset + 8;
1686
+ }
1687
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
1688
+ return writeDouble(this, value, offset, true, noAssert);
1689
+ };
1690
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
1691
+ return writeDouble(this, value, offset, false, noAssert);
1692
+ };
1693
+ Buffer.prototype.copy = function copy(target, targetStart, start, end) {
1694
+ if (!Buffer.isBuffer(target))
1695
+ throw new TypeError("argument should be a Buffer");
1696
+ if (!start)
1697
+ start = 0;
1698
+ if (!end && end !== 0)
1699
+ end = this.length;
1700
+ if (targetStart >= target.length)
1701
+ targetStart = target.length;
1702
+ if (!targetStart)
1703
+ targetStart = 0;
1704
+ if (end > 0 && end < start)
1705
+ end = start;
1706
+ if (end === start)
1707
+ return 0;
1708
+ if (target.length === 0 || this.length === 0)
1709
+ return 0;
1710
+ if (targetStart < 0) {
1711
+ throw new RangeError("targetStart out of bounds");
1712
+ }
1713
+ if (start < 0 || start >= this.length)
1714
+ throw new RangeError("Index out of range");
1715
+ if (end < 0)
1716
+ throw new RangeError("sourceEnd out of bounds");
1717
+ if (end > this.length)
1718
+ end = this.length;
1719
+ if (target.length - targetStart < end - start) {
1720
+ end = target.length - targetStart + start;
1721
+ }
1722
+ const len = end - start;
1723
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
1724
+ this.copyWithin(targetStart, start, end);
1725
+ } else {
1726
+ Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
1727
+ }
1728
+ return len;
1729
+ };
1730
+ Buffer.prototype.fill = function fill(val, start, end, encoding) {
1731
+ if (typeof val === "string") {
1732
+ if (typeof start === "string") {
1733
+ encoding = start;
1734
+ start = 0;
1735
+ end = this.length;
1736
+ } else if (typeof end === "string") {
1737
+ encoding = end;
1738
+ end = this.length;
1739
+ }
1740
+ if (encoding !== undefined && typeof encoding !== "string") {
1741
+ throw new TypeError("encoding must be a string");
1742
+ }
1743
+ if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) {
1744
+ throw new TypeError("Unknown encoding: " + encoding);
1745
+ }
1746
+ if (val.length === 1) {
1747
+ const code = val.charCodeAt(0);
1748
+ if (encoding === "utf8" && code < 128 || encoding === "latin1") {
1749
+ val = code;
1750
+ }
1751
+ }
1752
+ } else if (typeof val === "number") {
1753
+ val = val & 255;
1754
+ } else if (typeof val === "boolean") {
1755
+ val = Number(val);
1756
+ }
1757
+ if (start < 0 || this.length < start || this.length < end) {
1758
+ throw new RangeError("Out of range index");
1759
+ }
1760
+ if (end <= start) {
1761
+ return this;
1762
+ }
1763
+ start = start >>> 0;
1764
+ end = end === undefined ? this.length : end >>> 0;
1765
+ if (!val)
1766
+ val = 0;
1767
+ let i;
1768
+ if (typeof val === "number") {
1769
+ for (i = start;i < end; ++i) {
1770
+ this[i] = val;
1771
+ }
1772
+ } else {
1773
+ const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding);
1774
+ const len = bytes.length;
1775
+ if (len === 0) {
1776
+ throw new TypeError('The value "' + val + '" is invalid for argument "value"');
1777
+ }
1778
+ for (i = 0;i < end - start; ++i) {
1779
+ this[i + start] = bytes[i % len];
1780
+ }
1781
+ }
1782
+ return this;
1783
+ };
1784
+ var errors = {};
1785
+ function E(sym, getMessage, Base) {
1786
+ errors[sym] = class NodeError extends Base {
1787
+ constructor() {
1788
+ super();
1789
+ Object.defineProperty(this, "message", {
1790
+ value: getMessage.apply(this, arguments),
1791
+ writable: true,
1792
+ configurable: true
1793
+ });
1794
+ this.name = `${this.name} [${sym}]`;
1795
+ this.stack;
1796
+ delete this.name;
1797
+ }
1798
+ get code() {
1799
+ return sym;
1800
+ }
1801
+ set code(value) {
1802
+ Object.defineProperty(this, "code", {
1803
+ configurable: true,
1804
+ enumerable: true,
1805
+ value,
1806
+ writable: true
1807
+ });
1808
+ }
1809
+ toString() {
1810
+ return `${this.name} [${sym}]: ${this.message}`;
1811
+ }
1812
+ };
1813
+ }
1814
+ E("ERR_BUFFER_OUT_OF_BOUNDS", function(name) {
1815
+ if (name) {
1816
+ return `${name} is outside of buffer bounds`;
1817
+ }
1818
+ return "Attempt to access memory outside buffer bounds";
1819
+ }, RangeError);
1820
+ E("ERR_INVALID_ARG_TYPE", function(name, actual) {
1821
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
1822
+ }, TypeError);
1823
+ E("ERR_OUT_OF_RANGE", function(str, range, input) {
1824
+ let msg = `The value of "${str}" is out of range.`;
1825
+ let received = input;
1826
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
1827
+ received = addNumericalSeparator(String(input));
1828
+ } else if (typeof input === "bigint") {
1829
+ received = String(input);
1830
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
1831
+ received = addNumericalSeparator(received);
1832
+ }
1833
+ received += "n";
1834
+ }
1835
+ msg += ` It must be ${range}. Received ${received}`;
1836
+ return msg;
1837
+ }, RangeError);
1838
+ function addNumericalSeparator(val) {
1839
+ let res = "";
1840
+ let i = val.length;
1841
+ const start = val[0] === "-" ? 1 : 0;
1842
+ for (;i >= start + 4; i -= 3) {
1843
+ res = `_${val.slice(i - 3, i)}${res}`;
1844
+ }
1845
+ return `${val.slice(0, i)}${res}`;
1846
+ }
1847
+ function checkBounds(buf, offset, byteLength2) {
1848
+ validateNumber(offset, "offset");
1849
+ if (buf[offset] === undefined || buf[offset + byteLength2] === undefined) {
1850
+ boundsError(offset, buf.length - (byteLength2 + 1));
1851
+ }
1852
+ }
1853
+ function checkIntBI(value, min, max, buf, offset, byteLength2) {
1854
+ if (value > max || value < min) {
1855
+ const n = typeof min === "bigint" ? "n" : "";
1856
+ let range;
1857
+ if (byteLength2 > 3) {
1858
+ if (min === 0 || min === BigInt(0)) {
1859
+ range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
1860
+ } else {
1861
+ range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ` + `${(byteLength2 + 1) * 8 - 1}${n}`;
1862
+ }
1863
+ } else {
1864
+ range = `>= ${min}${n} and <= ${max}${n}`;
1865
+ }
1866
+ throw new errors.ERR_OUT_OF_RANGE("value", range, value);
1867
+ }
1868
+ checkBounds(buf, offset, byteLength2);
1869
+ }
1870
+ function validateNumber(value, name) {
1871
+ if (typeof value !== "number") {
1872
+ throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
1873
+ }
1874
+ }
1875
+ function boundsError(value, length, type) {
1876
+ if (Math.floor(value) !== value) {
1877
+ validateNumber(value, type);
1878
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
1879
+ }
1880
+ if (length < 0) {
1881
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS;
1882
+ }
1883
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", `>= ${type ? 1 : 0} and <= ${length}`, value);
1884
+ }
1885
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1886
+ function base64clean(str) {
1887
+ str = str.split("=")[0];
1888
+ str = str.trim().replace(INVALID_BASE64_RE, "");
1889
+ if (str.length < 2)
1890
+ return "";
1891
+ while (str.length % 4 !== 0) {
1892
+ str = str + "=";
1893
+ }
1894
+ return str;
1895
+ }
1896
+ function utf8ToBytes(string, units) {
1897
+ units = units || Infinity;
1898
+ let codePoint;
1899
+ const length = string.length;
1900
+ let leadSurrogate = null;
1901
+ const bytes = [];
1902
+ for (let i = 0;i < length; ++i) {
1903
+ codePoint = string.charCodeAt(i);
1904
+ if (codePoint > 55295 && codePoint < 57344) {
1905
+ if (!leadSurrogate) {
1906
+ if (codePoint > 56319) {
1907
+ if ((units -= 3) > -1)
1908
+ bytes.push(239, 191, 189);
1909
+ continue;
1910
+ } else if (i + 1 === length) {
1911
+ if ((units -= 3) > -1)
1912
+ bytes.push(239, 191, 189);
1913
+ continue;
1914
+ }
1915
+ leadSurrogate = codePoint;
1916
+ continue;
1917
+ }
1918
+ if (codePoint < 56320) {
1919
+ if ((units -= 3) > -1)
1920
+ bytes.push(239, 191, 189);
1921
+ leadSurrogate = codePoint;
1922
+ continue;
1923
+ }
1924
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
1925
+ } else if (leadSurrogate) {
1926
+ if ((units -= 3) > -1)
1927
+ bytes.push(239, 191, 189);
1928
+ }
1929
+ leadSurrogate = null;
1930
+ if (codePoint < 128) {
1931
+ if ((units -= 1) < 0)
1932
+ break;
1933
+ bytes.push(codePoint);
1934
+ } else if (codePoint < 2048) {
1935
+ if ((units -= 2) < 0)
1936
+ break;
1937
+ bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
1938
+ } else if (codePoint < 65536) {
1939
+ if ((units -= 3) < 0)
1940
+ break;
1941
+ bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
1942
+ } else if (codePoint < 1114112) {
1943
+ if ((units -= 4) < 0)
1944
+ break;
1945
+ bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
1946
+ } else {
1947
+ throw new Error("Invalid code point");
1948
+ }
1949
+ }
1950
+ return bytes;
1951
+ }
1952
+ function asciiToBytes(str) {
1953
+ const byteArray = [];
1954
+ for (let i = 0;i < str.length; ++i) {
1955
+ byteArray.push(str.charCodeAt(i) & 255);
1956
+ }
1957
+ return byteArray;
1958
+ }
1959
+ function utf16leToBytes(str, units) {
1960
+ let c, hi, lo;
1961
+ const byteArray = [];
1962
+ for (let i = 0;i < str.length; ++i) {
1963
+ if ((units -= 2) < 0)
1964
+ break;
1965
+ c = str.charCodeAt(i);
1966
+ hi = c >> 8;
1967
+ lo = c % 256;
1968
+ byteArray.push(lo);
1969
+ byteArray.push(hi);
1970
+ }
1971
+ return byteArray;
1972
+ }
1973
+ function base64ToBytes(str) {
1974
+ return base64.toByteArray(base64clean(str));
1975
+ }
1976
+ function blitBuffer(src, dst, offset, length) {
1977
+ let i;
1978
+ for (i = 0;i < length; ++i) {
1979
+ if (i + offset >= dst.length || i >= src.length)
1980
+ break;
1981
+ dst[i + offset] = src[i];
1982
+ }
1983
+ return i;
1984
+ }
1985
+ function isInstance(obj, type) {
1986
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
1987
+ }
1988
+ function numberIsNaN(obj) {
1989
+ return obj !== obj;
1990
+ }
1991
+ var hexSliceLookupTable = function() {
1992
+ const alphabet = "0123456789abcdef";
1993
+ const table = new Array(256);
1994
+ for (let i = 0;i < 16; ++i) {
1995
+ const i16 = i * 16;
1996
+ for (let j = 0;j < 16; ++j) {
1997
+ table[i16 + j] = alphabet[i] + alphabet[j];
1998
+ }
1999
+ }
2000
+ return table;
2001
+ }();
2002
+ function defineBigIntMethod(fn) {
2003
+ return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
2004
+ }
2005
+ function BufferBigIntNotDefined() {
2006
+ throw new Error("BigInt not supported");
2007
+ }
2008
+
2009
+ // src/addon/buffer/index.ts
2010
+ __reExport(exports_buffer2, exports_buffer);
2011
+ var buffer_default = exports_buffer;
2012
+
2013
+ // src/addon/pg-format/index.ts
2014
+ var fmtPattern = {
2015
+ ident: "I",
2016
+ literal: "L",
2017
+ string: "s",
2018
+ simple: "?"
2019
+ };
2020
+ function formatDate(date) {
2021
+ return date.replace("T", " ").replace("Z", "+00");
2022
+ }
2023
+ function isReserved(value) {
2024
+ return Boolean(reserved_default[value.toUpperCase()]);
2025
+ }
2026
+ function arrayToList(useSpace, array, formatter = (value) => String(value)) {
2027
+ let sql = useSpace ? " (" : "(";
2028
+ for (let i = 0;i < array.length; i++) {
2029
+ sql += (i === 0 ? "" : ", ") + formatter(array[i]);
2030
+ }
2031
+ sql += ")";
2032
+ return sql;
2033
+ }
2034
+ function quoteIdent(value) {
2035
+ if (value === undefined || value === null) {
2036
+ throw new Error("SQL identifier cannot be null or undefined");
2037
+ }
2038
+ if (value === false) {
2039
+ return "FALSE";
2040
+ }
2041
+ if (value === true) {
2042
+ return "TRUE";
2043
+ }
2044
+ if (value instanceof Date) {
2045
+ return '"' + formatDate(value.toISOString()) + '"';
2046
+ }
2047
+ if (value instanceof $Buffer) {
2048
+ throw new Error("SQL identifier cannot be a buffer");
2049
+ }
2050
+ if (Array.isArray(value)) {
2051
+ const temp = [];
2052
+ for (let i = 0;i < value.length; i++) {
2053
+ if (Array.isArray(value[i])) {
2054
+ throw new Error("Nested array to grouped list conversion is not supported for SQL identifier");
2055
+ }
2056
+ temp.push(quoteIdent(value[i]));
2057
+ }
2058
+ return temp.join(",");
2059
+ }
2060
+ if (value === Object(value)) {
2061
+ throw new Error("SQL identifier cannot be an object");
2062
+ }
2063
+ const ident = String(value);
2064
+ if (/^[a-z_][a-z0-9_$]*$/.test(ident) && !isReserved(ident)) {
2065
+ return ident;
2066
+ }
2067
+ let quoted = '"';
2068
+ for (let i = 0;i < ident.length; i++) {
2069
+ const c = ident[i];
2070
+ if (c === '"') {
2071
+ quoted += c + c;
2072
+ } else {
2073
+ quoted += c;
2074
+ }
2075
+ }
2076
+ quoted += '"';
2077
+ return quoted;
2078
+ }
2079
+ function quoteLiteral(value) {
2080
+ if (value === undefined || value === null) {
2081
+ return "NULL";
2082
+ }
2083
+ if (value === false) {
2084
+ return "'f'";
2085
+ }
2086
+ if (value === true) {
2087
+ return "'t'";
2088
+ }
2089
+ if (value instanceof Date) {
2090
+ return "'" + formatDate(value.toISOString()) + "'";
2091
+ }
2092
+ if (value instanceof $Buffer) {
2093
+ return "E'\\\\x" + value.toString("hex") + "'";
2094
+ }
2095
+ if (Array.isArray(value)) {
2096
+ const temp = [];
2097
+ for (let i = 0;i < value.length; i++) {
2098
+ if (Array.isArray(value[i])) {
2099
+ temp.push(arrayToList(i !== 0, value[i], quoteLiteral));
2100
+ } else {
2101
+ temp.push(quoteLiteral(value[i]));
2102
+ }
2103
+ }
2104
+ return temp.join(",");
2105
+ }
2106
+ let literal;
2107
+ let explicitCast = null;
2108
+ if (value === Object(value)) {
2109
+ explicitCast = "jsonb";
2110
+ literal = JSON.stringify(value);
2111
+ } else {
2112
+ literal = String(value);
2113
+ }
2114
+ let hasBackslash = false;
2115
+ let quoted = "'";
2116
+ for (let i = 0;i < literal.length; i++) {
2117
+ const c = literal[i];
2118
+ if (c === "'") {
2119
+ quoted += c + c;
2120
+ } else if (c === "\\") {
2121
+ quoted += c + c;
2122
+ hasBackslash = true;
2123
+ } else {
2124
+ quoted += c;
2125
+ }
2126
+ }
2127
+ quoted += "'";
2128
+ if (hasBackslash) {
2129
+ quoted = "E" + quoted;
2130
+ }
2131
+ if (explicitCast) {
2132
+ quoted += "::" + explicitCast;
2133
+ }
2134
+ return quoted;
2135
+ }
2136
+ function quoteString(value) {
2137
+ if (value === undefined || value === null) {
2138
+ return "";
2139
+ }
2140
+ if (value === false) {
2141
+ return "f";
2142
+ }
2143
+ if (value === true) {
2144
+ return "t";
2145
+ }
2146
+ if (value instanceof Date) {
2147
+ return formatDate(value.toISOString());
2148
+ }
2149
+ if (value instanceof $Buffer) {
2150
+ return "\\x" + value.toString("hex");
2151
+ }
2152
+ if (Array.isArray(value)) {
2153
+ const temp = [];
2154
+ for (let i = 0;i < value.length; i++) {
2155
+ if (value[i] !== null && value[i] !== undefined) {
2156
+ if (Array.isArray(value[i])) {
2157
+ temp.push(arrayToList(i !== 0, value[i], quoteString));
2158
+ } else {
2159
+ temp.push(quoteString(value[i]));
2160
+ }
2161
+ }
2162
+ }
2163
+ return temp.join(",");
2164
+ }
2165
+ if (value === Object(value)) {
2166
+ return JSON.stringify(value);
2167
+ }
2168
+ return String(value);
2169
+ }
2170
+ function config(cfg) {
2171
+ fmtPattern.ident = "I";
2172
+ fmtPattern.literal = "L";
2173
+ fmtPattern.string = "s";
2174
+ fmtPattern.simple = "?";
2175
+ if (cfg?.pattern) {
2176
+ if (cfg.pattern.ident) {
2177
+ fmtPattern.ident = cfg.pattern.ident;
2178
+ }
2179
+ if (cfg.pattern.literal) {
2180
+ fmtPattern.literal = cfg.pattern.literal;
2181
+ }
2182
+ if (cfg.pattern.string) {
2183
+ fmtPattern.string = cfg.pattern.string;
2184
+ }
2185
+ if (cfg.pattern.simple) {
2186
+ fmtPattern.simple = cfg.pattern.simple;
2187
+ }
2188
+ }
2189
+ }
2190
+ function formatWithArray(fmt, parameters) {
2191
+ let index = 0;
2192
+ const params = parameters;
2193
+ const processedFmt = fmt.replace(/\?/g, () => {
2194
+ if (index >= params.length) {
2195
+ throw new Error("too few arguments");
2196
+ }
2197
+ const value = quoteLiteral(params[index]);
2198
+ index++;
2199
+ return value;
2200
+ });
2201
+ index = 0;
2202
+ let re = "%(%|(\\d+\\$)?[";
2203
+ re += fmtPattern.ident;
2204
+ re += fmtPattern.literal;
2205
+ re += fmtPattern.string;
2206
+ re += "])";
2207
+ const regex = new RegExp(re, "g");
2208
+ return processedFmt.replace(regex, (_, type) => {
2209
+ if (type === "%") {
2210
+ return "%";
2211
+ }
2212
+ let position = index;
2213
+ const tokens = type.split("$");
2214
+ if (tokens.length > 1) {
2215
+ position = parseInt(tokens[0], 10) - 1;
2216
+ type = tokens[1];
2217
+ }
2218
+ if (position < 0) {
2219
+ throw new Error("specified argument 0 but arguments start at 1");
2220
+ }
2221
+ if (position > params.length - 1) {
2222
+ throw new Error("too few arguments");
2223
+ }
2224
+ index = position + 1;
2225
+ if (type === fmtPattern.ident) {
2226
+ return quoteIdent(params[position]);
2227
+ }
2228
+ if (type === fmtPattern.literal) {
2229
+ return quoteLiteral(params[position]);
2230
+ }
2231
+ if (type === fmtPattern.string) {
2232
+ return quoteString(params[position]);
2233
+ }
2234
+ return "";
2235
+ });
2236
+ }
2237
+ function format(fmt, ...args) {
2238
+ return formatWithArray(fmt, args);
2239
+ }
2240
+ format.config = config;
2241
+ format.ident = quoteIdent;
2242
+ format.literal = quoteLiteral;
2243
+ format.string = quoteString;
2244
+ format.withArray = formatWithArray;
2245
+ var pg_format_default = format;
2246
+ export {
2247
+ pg_format_default as default
2248
+ };