@ddunigma/node 3.1.0 → 5.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 (47) hide show
  1. package/README.md +107 -281
  2. package/dist/BrowserAdapter-HORDDCOE.js +2 -0
  3. package/dist/BrowserAdapter-PB4J6FHX.cjs +2 -0
  4. package/dist/NodeAdapter-5FBNCJSG.js +2 -0
  5. package/dist/NodeAdapter-EQ73FGEJ.cjs +2 -0
  6. package/dist/{ObfuscationLayer-D-xl5d7P.d.ts → ObfuscationLayer-BDr-0s1M.d.ts} +31 -15
  7. package/dist/{ObfuscationLayer-DAVKTnHf.d.cts → ObfuscationLayer-BgL73E5F.d.cts} +31 -15
  8. package/dist/browser.cjs +1 -1
  9. package/dist/browser.d.cts +5 -4
  10. package/dist/browser.d.ts +5 -4
  11. package/dist/browser.js +1 -1
  12. package/dist/chunk-5NSHXTMN.cjs +2 -0
  13. package/dist/chunk-7RWUNW5S.js +2 -0
  14. package/dist/chunk-AMOZHHMB.cjs +2 -0
  15. package/dist/chunk-CQATQOBZ.js +2 -0
  16. package/dist/chunk-HTZT725P.js +10 -0
  17. package/dist/chunk-HZJ7PU7X.cjs +2 -0
  18. package/dist/chunk-KS6PRP5Y.js +2 -0
  19. package/dist/chunk-OQXMQIE3.js +2 -0
  20. package/dist/chunk-UMA4JEN4.cjs +10 -0
  21. package/dist/chunk-WCXD5LRF.cjs +2 -0
  22. package/dist/core.cjs +1 -1
  23. package/dist/core.d.cts +40 -1
  24. package/dist/core.d.ts +40 -1
  25. package/dist/core.js +1 -1
  26. package/dist/{core-DYSnygnp.d.cts → errors-DNICpo4L.d.cts} +188 -139
  27. package/dist/{core-DYSnygnp.d.ts → errors-DNICpo4L.d.ts} +188 -139
  28. package/dist/index.cjs +1 -1
  29. package/dist/index.d.cts +23 -8
  30. package/dist/index.d.ts +23 -8
  31. package/dist/index.js +1 -1
  32. package/dist/wasm/codec.wasm +0 -0
  33. package/package.json +46 -5
  34. package/dist/BrowserAdapter-BHHWPUTB.js +0 -2
  35. package/dist/BrowserAdapter-M7PUHVGS.cjs +0 -2
  36. package/dist/NodeAdapter-JB2EZ3T4.js +0 -2
  37. package/dist/NodeAdapter-JRRSYUJT.cjs +0 -2
  38. package/dist/chunk-5RZDTEOZ.js +0 -2
  39. package/dist/chunk-JUBMOKKH.js +0 -2
  40. package/dist/chunk-JZSHJ6KN.cjs +0 -9
  41. package/dist/chunk-KEWLOPEV.js +0 -9
  42. package/dist/chunk-M6LY6DIE.js +0 -2
  43. package/dist/chunk-NFMYVNOG.cjs +0 -2
  44. package/dist/chunk-NY4FGVF3.cjs +0 -2
  45. package/dist/chunk-PHMARSJE.cjs +0 -2
  46. package/dist/chunk-QR43FNIY.js +0 -2
  47. package/dist/chunk-TJTDYO65.cjs +0 -2
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { D as Ddu64Core, a as DduConstructorOptions, e as DduOptions, P as PlatformAdapter, i as KeyDerivationOptions } from './core-DYSnygnp.js';
2
- export { C as CharSetConfig, b as CharSetInfo, c as CharsetBuilder, d as DduEncodeStats, f as DduProgressInfo, g as DduSetSymbol, h as DduTextEncoding, E as EncodingProfile, K as KeyDerivationAlgorithm, O as ObfuscationLayer, T as TestVector, W as WasmCodec, j as getWasmCodec, k as getWasmCodecSync, p as preloadWasm } from './core-DYSnygnp.js';
3
- export { B as BrowserAdapter, H as HangulObfuscationLayer, c as createObfuscationLayer, a as createReadableDecodeStream, b as createReadableEncodeStream, d as detectRuntime } from './ObfuscationLayer-D-xl5d7P.js';
1
+ import { D as Ddu64Core, a as DduConstructorOptions, u as DduOptions, P as PlatformAdapter, y as KeyDerivationOptions, W as WasmCodec } from './errors-DNICpo4L.js';
2
+ export { C as CharSetConfig, b as CharSetInfo, c as CharsetBuilder, d as Ddu64AdapterError, e as Ddu64CharsetError, f as Ddu64ChecksumError, g as Ddu64CompressionError, h as Ddu64DecodeError, i as Ddu64DecompressionError, j as Ddu64DecryptionError, k as Ddu64EncodeError, l as Ddu64EncryptionError, m as Ddu64Error, n as Ddu64ErrorCode, o as Ddu64ErrorOptions, p as Ddu64LimitError, q as Ddu64ObfuscationError, r as Ddu64Operation, s as Ddu64StreamError, t as DduEncodeStats, v as DduProgressInfo, w as DduSetSymbol, x as DduTextEncoding, E as EncodingProfile, K as KeyDerivationAlgorithm, O as ObfuscationLayer, z as isDdu64Error } from './errors-DNICpo4L.js';
3
+ export { B as BrowserAdapter, H as HangulObfuscationLayer, c as createEncoderObfuscationLayer, a as createObfuscationLayer, b as createReadableDecodeStream, d as createReadableEncodeStream, e as detectRuntime } from './ObfuscationLayer-BDr-0s1M.js';
4
4
 
5
5
  /**
6
6
  * Node.js 전용 Ddu64 래퍼.
@@ -36,6 +36,7 @@ declare class Ddu64Node extends Ddu64Core {
36
36
  * @param input - 디코딩할 인코딩된 문자열
37
37
  * @param options - 디코딩 옵션
38
38
  * @returns 디코딩된 Buffer
39
+ * @group Sync
39
40
  */
40
41
  decodeToBuffer(input: string, options?: DduOptions): Buffer;
41
42
  /**
@@ -44,6 +45,7 @@ declare class Ddu64Node extends Ddu64Core {
44
45
  * @param input - 디코딩할 인코딩된 문자열
45
46
  * @param options - 디코딩 옵션
46
47
  * @returns 디코딩된 Buffer로 resolve되는 Promise
48
+ * @group Async
47
49
  */
48
50
  decodeToBufferAsync(input: string, options?: DduOptions): Promise<Buffer>;
49
51
  }
@@ -67,10 +69,10 @@ declare class NodeAdapter implements PlatformAdapter {
67
69
  readonly runtime: "node";
68
70
  deriveKey(key: string, options?: KeyDerivationOptions): Promise<Uint8Array>;
69
71
  deriveKeySync(key: string, options?: KeyDerivationOptions): Uint8Array;
70
- encrypt(data: Uint8Array, keyHash: Uint8Array): Promise<Uint8Array>;
71
- encryptSync(data: Uint8Array, keyHash: Uint8Array): Uint8Array;
72
- decrypt(data: Uint8Array, keyHash: Uint8Array): Promise<Uint8Array>;
73
- decryptSync(data: Uint8Array, keyHash: Uint8Array): Uint8Array;
72
+ encrypt(data: Uint8Array, keyHash: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
73
+ encryptSync(data: Uint8Array, keyHash: Uint8Array, aad?: Uint8Array): Uint8Array;
74
+ decrypt(data: Uint8Array, keyHash: Uint8Array, aad?: Uint8Array): Promise<Uint8Array>;
75
+ decryptSync(data: Uint8Array, keyHash: Uint8Array, aad?: Uint8Array): Uint8Array;
74
76
  randomBytes(length: number): Uint8Array;
75
77
  deflate(data: Uint8Array, level?: number): Promise<Uint8Array>;
76
78
  deflateSync(data: Uint8Array, level?: number): Uint8Array;
@@ -103,4 +105,17 @@ declare class NodeAdapter implements PlatformAdapter {
103
105
  */
104
106
  declare function getAdapter(): Promise<PlatformAdapter>;
105
107
 
106
- export { Ddu64Node as Ddu64, Ddu64Core, Ddu64Node, DduConstructorOptions, DduOptions, KeyDerivationOptions, NodeAdapter, PlatformAdapter, getAdapter };
108
+ /**
109
+ * Node.js 파일시스템 기반 WASM 로더.
110
+ *
111
+ * 브라우저/core 엔트리에서 Node.js 내장 모듈이 번들에 섞이지 않도록
112
+ * Node 전용 진입점(`@ddunigma/node`)에서만 이 모듈을 가져옵니다.
113
+ *
114
+ * @module wasm/WasmCodecNode
115
+ */
116
+
117
+ declare function preloadWasm(): Promise<void>;
118
+ declare function getWasmCodec(): WasmCodec | null;
119
+ declare function getWasmCodecSync(): WasmCodec | null;
120
+
121
+ export { Ddu64Node as Ddu64, Ddu64Core, Ddu64Node, DduConstructorOptions, DduOptions, KeyDerivationOptions, NodeAdapter, PlatformAdapter, WasmCodec, getAdapter, getWasmCodec, getWasmCodecSync, preloadWasm };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import {a as a$1}from'./chunk-JUBMOKKH.js';export{c as createReadableDecodeStream,b as createReadableEncodeStream,a as detectRuntime}from'./chunk-JUBMOKKH.js';import {j,k}from'./chunk-KEWLOPEV.js';export{l as CharsetBuilder,k as Ddu64Core,d as DduSetSymbol,e as HangulObfuscationLayer,f as createObfuscationLayer,h as getWasmCodec,i as getWasmCodecSync,g as preloadWasm}from'./chunk-KEWLOPEV.js';export{a as BrowserAdapter}from'./chunk-5RZDTEOZ.js';import {a}from'./chunk-M6LY6DIE.js';export{a as NodeAdapter}from'./chunk-M6LY6DIE.js';import'./chunk-QR43FNIY.js';import {readFile}from'fs/promises';import {dirname,join}from'path';import {fileURLToPath}from'url';var s=class extends k{constructor(e,r,t){e!=null&&typeof e=="object"&&!Array.isArray(e)&&(t=e,e=void 0,r=void 0);let p={...t,adapter:t?.adapter??new a};super(e,r,p);}decodeToBuffer(e,r){let t=this.decodeToUint8Array(e,r);return Buffer.from(t.buffer,t.byteOffset,t.byteLength)}async decodeToBufferAsync(e,r){let t=await this.decodeToUint8ArrayAsync(e,r);return Buffer.from(t.buffer,t.byteOffset,t.byteLength)}};async function O(){switch(a$1()){case "node":{let{NodeAdapter:e}=await import('./NodeAdapter-JB2EZ3T4.js');return new e}case "deno":case "bun":case "browser":case "edge":{let{BrowserAdapter:e}=await import('./BrowserAdapter-BHHWPUTB.js');return new e}default:throw new Error("[ddunigma] No suitable crypto provider found. Detected runtime lacks both Node.js crypto module and Web Crypto API (SubtleCrypto).")}}async function B(o){try{let e=await readFile(o);return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}catch{return null}}async function C(){let o=dirname(fileURLToPath(import.meta.url)),e=[join(o,"wasm","codec.wasm"),join(o,"codec.wasm"),join(o,"..","wasm","codec.wasm")];for(let r of e){let t=await B(r);if(t)return t}return null}j(C);export{s as Ddu64,s as Ddu64Node,O as getAdapter};//# sourceMappingURL=index.js.map
1
+ import {a as a$1}from'./chunk-KS6PRP5Y.js';export{c as createReadableDecodeStream,b as createReadableEncodeStream,a as detectRuntime}from'./chunk-KS6PRP5Y.js';import {C,B,h,i,j,k}from'./chunk-HTZT725P.js';export{D as CharsetBuilder,w as Ddu64AdapterError,u as Ddu64CharsetError,t as Ddu64ChecksumError,p as Ddu64CompressionError,C as Ddu64Core,o as Ddu64DecodeError,q as Ddu64DecompressionError,s as Ddu64DecryptionError,n as Ddu64EncodeError,r as Ddu64EncryptionError,m as Ddu64Error,l as Ddu64ErrorCode,v as Ddu64LimitError,x as Ddu64ObfuscationError,y as Ddu64StreamError,a as DduSetSymbol,e as HangulObfuscationLayer,g as createEncoderObfuscationLayer,f as createObfuscationLayer,z as isDdu64Error}from'./chunk-HTZT725P.js';export{a as BrowserAdapter}from'./chunk-CQATQOBZ.js';import {a}from'./chunk-7RWUNW5S.js';export{a as NodeAdapter}from'./chunk-7RWUNW5S.js';import'./chunk-OQXMQIE3.js';import {readFile}from'fs/promises';import {dirname,join}from'path';import {fileURLToPath}from'url';var s=class extends C{constructor(r,t,e){let d=B(r,t,e),C={...d.dduOptions,...d.dduChar!==void 0?{dduChar:d.dduChar}:{},...d.paddingChar!==void 0?{paddingChar:d.paddingChar}:{},adapter:d.dduOptions?.adapter??new a};super(C);}decodeToBuffer(r,t){let e=this.decodeToUint8Array(r,t);return Buffer.from(e.buffer,e.byteOffset,e.byteLength)}async decodeToBufferAsync(r,t){let e=await this.decodeToUint8ArrayAsync(r,t);return Buffer.from(e.buffer,e.byteOffset,e.byteLength)}};async function U(){let o=a$1();switch(o){case "node":{let{NodeAdapter:r}=await import('./NodeAdapter-5FBNCJSG.js');return new r}case "deno":case "bun":case "browser":case "edge":{let{BrowserAdapter:r}=await import('./BrowserAdapter-HORDDCOE.js');return new r(o)}default:throw new Error("[ddunigma] No suitable crypto provider found. Detected runtime lacks both Node.js crypto module and Web Crypto API (SubtleCrypto).")}}var D=false;async function q(o){try{let r=await readFile(o);return r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}catch{return null}}async function z(){let o=dirname(fileURLToPath(import.meta.url)),r=[join(o,"wasm","codec.wasm"),join(o,"codec.wasm"),join(o,"..","wasm","codec.wasm")];for(let t of r){let e=await q(t);if(e)return e}return null}function c(){D||(k(z),D=true);}async function G(){return c(),h()}function J(){return c(),i()}function Q(){return c(),j()}export{s as Ddu64,s as Ddu64Node,U as getAdapter,J as getWasmCodec,Q as getWasmCodecSync,G as preloadWasm};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
Binary file
package/package.json CHANGED
@@ -1,21 +1,28 @@
1
1
  {
2
2
  "name": "@ddunigma/node",
3
- "version": "3.1.0",
3
+ "version": "5.0.0",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "browser": "./dist/browser.js",
7
8
  "type": "module",
8
9
  "sideEffects": false,
9
10
  "engines": {
10
- "node": ">=18.0.0"
11
+ "node": ">=22.0.0"
11
12
  },
12
13
  "scripts": {
13
14
  "build": "tsup",
14
15
  "bench": "node --expose-gc --import tsx benchmarks/encoding-benchmark.ts",
16
+ "bench:micro": "node --expose-gc --import tsx benchmarks/micro-benchmark.ts",
17
+ "bench:threshold": "node --expose-gc --import tsx benchmarks/wasm-threshold-benchmark.ts",
18
+ "bench:guard": "node --expose-gc --import tsx benchmarks/perf-guard.ts",
19
+ "gen:v5-vectors": "node --import tsx scripts/gen-v5-vectors.ts",
15
20
  "pack:check": "node scripts/verify-pack.mjs",
21
+ "prepublishOnly": "pnpm typecheck && pnpm lint && pnpm test && pnpm build && pnpm pack:check",
16
22
  "test": "vitest run",
17
23
  "test:watch": "vitest",
18
24
  "test:coverage": "vitest run --coverage",
25
+ "typecheck": "tsc --noEmit && tsc -p tsconfig.test.json",
19
26
  "lint": "eslint src eslint.config.mjs tsup.config.ts",
20
27
  "lint:fix": "eslint src eslint.config.mjs tsup.config.ts --fix",
21
28
  "format": "prettier --write src/",
@@ -23,14 +30,48 @@
23
30
  },
24
31
  "exports": {
25
32
  ".": {
33
+ "browser": {
34
+ "types": "./dist/browser.d.ts",
35
+ "import": "./dist/browser.js",
36
+ "require": "./dist/browser.cjs"
37
+ },
38
+ "worker": {
39
+ "types": "./dist/browser.d.ts",
40
+ "import": "./dist/browser.js",
41
+ "require": "./dist/browser.cjs"
42
+ },
43
+ "workerd": {
44
+ "types": "./dist/browser.d.ts",
45
+ "default": "./dist/browser.js"
46
+ },
47
+ "deno": {
48
+ "types": "./dist/browser.d.ts",
49
+ "default": "./dist/browser.js"
50
+ },
51
+ "bun": {
52
+ "types": "./dist/browser.d.ts",
53
+ "import": "./dist/browser.js",
54
+ "require": "./dist/browser.cjs"
55
+ },
56
+ "node": {
57
+ "import": {
58
+ "types": "./dist/index.d.ts",
59
+ "default": "./dist/index.js"
60
+ },
61
+ "require": {
62
+ "types": "./dist/index.d.cts",
63
+ "default": "./dist/index.cjs"
64
+ }
65
+ },
26
66
  "import": {
27
- "types": "./dist/index.d.ts",
28
- "default": "./dist/index.js"
67
+ "types": "./dist/browser.d.ts",
68
+ "default": "./dist/browser.js"
29
69
  },
30
70
  "require": {
31
71
  "types": "./dist/index.d.cts",
32
72
  "default": "./dist/index.cjs"
33
- }
73
+ },
74
+ "default": "./dist/browser.js"
34
75
  },
35
76
  "./browser": {
36
77
  "import": {
@@ -1,2 +0,0 @@
1
- export{a as BrowserAdapter}from'./chunk-5RZDTEOZ.js';import'./chunk-QR43FNIY.js';//# sourceMappingURL=BrowserAdapter-BHHWPUTB.js.map
2
- //# sourceMappingURL=BrowserAdapter-BHHWPUTB.js.map
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkNFMYVNOG_cjs=require('./chunk-NFMYVNOG.cjs');require('./chunk-NY4FGVF3.cjs');Object.defineProperty(exports,"BrowserAdapter",{enumerable:true,get:function(){return chunkNFMYVNOG_cjs.a}});//# sourceMappingURL=BrowserAdapter-M7PUHVGS.cjs.map
2
- //# sourceMappingURL=BrowserAdapter-M7PUHVGS.cjs.map
@@ -1,2 +0,0 @@
1
- export{a as NodeAdapter}from'./chunk-M6LY6DIE.js';import'./chunk-QR43FNIY.js';//# sourceMappingURL=NodeAdapter-JB2EZ3T4.js.map
2
- //# sourceMappingURL=NodeAdapter-JB2EZ3T4.js.map
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkTJTDYO65_cjs=require('./chunk-TJTDYO65.cjs');require('./chunk-NY4FGVF3.cjs');Object.defineProperty(exports,"NodeAdapter",{enumerable:true,get:function(){return chunkTJTDYO65_cjs.a}});//# sourceMappingURL=NodeAdapter-JRRSYUJT.cjs.map
2
- //# sourceMappingURL=NodeAdapter-JRRSYUJT.cjs.map
@@ -1,2 +0,0 @@
1
- import {c,a,d}from'./chunk-QR43FNIY.js';var y=new Map;function m(r){if(r.buffer instanceof ArrayBuffer)return r.byteOffset===0&&r.byteLength===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);let e=new Uint8Array(r.byteLength);return e.set(r),e.buffer}function h(r){let e=y.get(r);if(e!==void 0)return e;if(typeof CompressionStream>"u"||typeof DecompressionStream>"u")return y.set(r,false),false;try{return new CompressionStream(r),new DecompressionStream(r),y.set(r,!0),!0}catch{return y.set(r,false),false}}function u(r,e){if(!h(r)){let n=r==="brotli"?"Brotli":"Deflate raw";throw new Error(`[Ddu64 ${e}] ${n} ${e}ion is unsupported in the current runtime. CompressionStream/DecompressionStream does not support "${r}".`)}return r}var w=class{supportsSyncCrypto=false;supportsSyncCompression=false;supportsBrotli=h("brotli");runtime="browser";async deriveKey(e,n){let t=new TextEncoder().encode(e);if(n?.algorithm==="pbkdf2"){let o=await crypto.subtle.importKey("raw",t,"PBKDF2",false,["deriveBits"]),i=await crypto.subtle.deriveBits({name:"PBKDF2",salt:d(n.salt),iterations:a(n.iterations),hash:c(n.hash)},o,256);return new Uint8Array(i)}let a$1=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(a$1)}async encrypt(e,n){let s=crypto.getRandomValues(new Uint8Array(12)),t=await crypto.subtle.importKey("raw",m(n),{name:"AES-GCM"},false,["encrypt"]),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:s,tagLength:128},t,m(e)),o=new Uint8Array(a),i=o.slice(0,o.length-16),c=o.slice(o.length-16),p=new Uint8Array(28+i.length);return p.set(s,0),p.set(c,12),p.set(i,28),p}async decrypt(e,n){if(e.length<28)throw new Error("[Ddu64 decrypt] Encrypted data is invalid. Payload must be at least 28 bytes (12 IV + 16 authTag + ciphertext).");let s=e.slice(0,12),t=e.slice(12,28),a=e.slice(28),o=new Uint8Array(a.length+16);o.set(a,0),o.set(t,a.length);let i=await crypto.subtle.importKey("raw",m(n),{name:"AES-GCM"},false,["decrypt"]);try{let c=await crypto.subtle.decrypt({name:"AES-GCM",iv:s,tagLength:128},i,m(o));return new Uint8Array(c)}catch{throw new Error("[Ddu64 decrypt] Decryption failed: data tampering or incorrect key.")}}randomBytes(e){return crypto.getRandomValues(new Uint8Array(e))}async deflate(e,n){if(typeof CompressionStream>"u")throw new Error("[Ddu64 compress] Deflate compression is unsupported in the current runtime. CompressionStream API is not available.");let s=this.getDeflateFormat("compress"),t=new CompressionStream(s);return this.writeAndReadStream(t,e)}async inflate(e,n){if(typeof DecompressionStream>"u")throw new Error("[Ddu64 decompress] Deflate decompression is unsupported in the current runtime. DecompressionStream API is not available.");let s=this.getDeflateFormat("decompress"),t=new DecompressionStream(s);return this.writeAndReadStream(t,e,n)}async brotliCompress(e,n){let s=u("brotli","compress"),t=new CompressionStream(s);return this.writeAndReadStream(t,e)}async brotliDecompress(e,n){let s=u("brotli","decompress"),t=new DecompressionStream(s);return this.writeAndReadStream(t,e,n)}getDeflateFormat(e){return u("deflate-raw",e)}async writeAndReadStream(e,n,s){let t=e.writable.getWriter(),a=e.readable.getReader(),o=(async()=>{await t.write(new Uint8Array(m(n))),await t.close();})(),i=this.readAllChunks(a,s);try{let[c]=await Promise.all([i,o]);return c}catch(c){throw await a.cancel(c).catch(()=>{}),await t.abort(c).catch(()=>{}),c}}async readAllChunks(e,n){let s=[],t=0;for(;;){let{done:i,value:c}=await e.read();if(i)break;if(t+=c.length,n!==void 0&&t>n)throw new Error(`[Ddu64 decompress] Decompressed size exceeds limit. Estimated ${t}+ bytes exceeds maximum of ${n} bytes.`);s.push(c);}let a=new Uint8Array(t),o=0;for(let i of s)a.set(i,o),o+=i.length;return a}};export{w as a};//# sourceMappingURL=chunk-5RZDTEOZ.js.map
2
- //# sourceMappingURL=chunk-5RZDTEOZ.js.map
@@ -1,2 +0,0 @@
1
- import {b,a,c}from'./chunk-KEWLOPEV.js';function I(){let e=globalThis;if(e.Deno?.version?.deno)return "deno";if(e.Bun?.version)return "bun";if(e.process?.versions?.node)return "node";if(typeof e.crypto<"u"&&e.crypto?.subtle)return "browser";throw new Error("[ddunigma] No suitable crypto provider found. Detected runtime lacks both Node.js crypto module and Web Crypto API (SubtleCrypto).")}function v(e,n){let a=e.getCharSetInfo(),h=n?.compress??a.defaultCompress,p=(n?.encrypt??true)&&a.hasEncryptionKey,g=n?.checksum??a.defaultChecksum,r=h?n?.compressionAlgorithm??a.defaultCompressionAlgorithm:void 0,m=a.paddingChar,d=C(a,{compressed:h,encrypted:p,checksum:g}),y=false,u=[],s=0,o=null;return new TransformStream({async transform(t,c){if(d){if(!y){let k=b(m,{compressionAlgorithm:void 0,encrypted:false});c.enqueue(k),y=true;}let i;o&&o.length>0?(i=new Uint8Array(o.length+t.length),i.set(o,0),i.set(t,o.length)):i=t;let l=a.bitLength,S=E(l,8)/8,f=Math.floor(i.length/S)*S;if(f>0){let k=i.subarray(0,f),D=await e.encodeAsync(k,{compress:false,encrypt:false,checksum:false,chunkSize:void 0,chunkSeparator:void 0,omitFooter:true});c.enqueue(D);}f<i.length?o=i.slice(f):o=null;}else u.push(t),s+=t.length;},async flush(t){try{if(d){if(!y){let c=b(m,{compressionAlgorithm:void 0,encrypted:!1});t.enqueue(c);}if(o&&o.length>0){let c=await e.encodeAsync(o,{compress:!1,encrypt:!1,checksum:!1,chunkSize:void 0,chunkSeparator:void 0});t.enqueue(c);}o=null;}else {let c=b(m,{compressionAlgorithm:r,encrypted:p});if(t.enqueue(c),s>0){let i=new Uint8Array(s),l=0;for(let f of u)i.set(f,l),l+=f.length;let S=await e.encodeAsync(i,{...n,compress:h,encrypt:p,checksum:g,chunkSize:void 0,chunkSeparator:void 0});t.enqueue(S);}u=[],s=0;}}catch(c){t.error(c instanceof Error?c:new Error(String(c)));}}})}function L(e,n){let a$1=e.getCharSetInfo(),h=a$1.paddingChar,p=a(h),g=n?.checksum??a$1.defaultChecksum,r="",m=false,d=null,y=false;return new TransformStream({async transform(u,s){if(r+=u,!m&&r.length>=p){if(!r.startsWith(h)){s.error(new Error("[WebStreams decode] Invalid or missing stream header"));return}if(d=c(r,h),d===null){s.error(new Error("[WebStreams decode] Invalid or missing stream header"));return}if(d.encrypted&&!a$1.hasEncryptionKey){s.error(new Error("[WebStreams decode] Encrypted stream requires an encryptionKey"));return}m=true,y=C(a$1,{compressed:!!d.compressionAlgorithm,encrypted:d.encrypted,checksum:g}),r=r.slice(p);}if(m&&y&&r.length>0){let o=a$1.bitLength,t=E(o,8)/o,c=Math.floor(r.length/t)*t;if(c>0){let i=r.slice(0,c);r=r.slice(c);try{let l=await e.decodeToUint8ArrayAsync(i,{compress:!1,encrypt:!1,checksum:!1,chunkSize:void 0,chunkSeparator:void 0});l.length>0&&s.enqueue(l);}catch{r=i+r;}}}},async flush(u){try{if(!m){if(r.length===0)return;u.error(new Error("[WebStreams decode] Incomplete stream header"));return}if(r.length===0)return;let s=d.compressionAlgorithm,o=d.encrypted,t=await e.decodeToUint8ArrayAsync(r,{...n,compress:!!s,compressionAlgorithm:s,encrypt:o,checksum:g,chunkSize:void 0,chunkSeparator:void 0});t.length>0&&u.enqueue(t),r="";}catch(s){u.error(s instanceof Error?s:new Error(String(s)));}}})}function C(e,n){return e.usePowerOfTwo&&!n.compressed&&!n.encrypted&&!n.checksum}function E(e,n){return e*n/U(e,n)}function U(e,n){for(;n!==0;){let a=n;n=e%n,e=a;}return e}export{I as a,v as b,L as c};//# sourceMappingURL=chunk-JUBMOKKH.js.map
2
- //# sourceMappingURL=chunk-JUBMOKKH.js.map
@@ -1,9 +0,0 @@
1
- 'use strict';var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var z=(r=>(r.DDU="ddu",r.DDU_V1="ddu_v1",r.ONECHARSET="oneCharSet",r))(z||{}),_={dduSetSymbol:"ddu",usePowerOfTwo:true,requiredLength:64,bitLength:6};function W(n){if(n.length===0)throw new Error("[Ddu64 obfuscation] Alphabet must not be empty.");if(n.length>11172)throw new Error(`[Ddu64 obfuscation] Alphabet size (${n.length}) exceeds available Hangul syllables (11172).`);let e=Math.floor(11172/n.length),t=new Map;for(let r=0;r<n.length;r++)t.set(n[r],r);return {alphabet:n,syllablesPerChar:e,charToIndex:t}}function $(n,e,t){let r=44032+n*t.syllablesPerChar,o=e%t.syllablesPerChar;return r+o}function Y(n,e){if(n<44032||n>55203)return -1;let t=n-44032,r=Math.floor(t/e.syllablesPerChar);return r>=e.alphabet.length?-1:r}var L=class{config;constructor(e){this.config=W(e);}obfuscate(e){if(e.length===0)return "";let t=new Array(e.length);for(let r=0;r<e.length;r++){let o=e[r],s=this.config.charToIndex.get(o);if(s===void 0)throw new Error(`[Ddu64 obfuscation] Character "${o}" (U+${o.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase()}) not found in obfuscation alphabet.`);let a=$(s,r,this.config);t[r]=String.fromCharCode(a);}return t.join("")}deobfuscate(e){if(e.length===0)return "";let t=new Array(e.length);for(let r=0;r<e.length;r++){let o=e.charCodeAt(r),s=Y(o,this.config);if(s===-1)throw new Error(`[Ddu64 obfuscation] Invalid syllable at position ${r}: U+${o.toString(16).padStart(4,"0").toUpperCase()} is not in the mapped range.`);t[r]=this.config.alphabet[s];}return t.join("")}};function Ke(n,e){let t=new Set(n);t.add(e);let r=[...t];return new L(r)}var A=null,x=false,w=false,C=null,F=le,M=class{exports;constructor(e){this.exports=e;}get ready(){return true}encode(e,t){let{exports:r}=this;if(e.length===0)return {indices:new Uint16Array(0),paddingBits:0};let o=r.alloc(e.length);new Uint8Array(r.memory.buffer).set(e,o);let a=1<<t,i=1;try{let c=r.encode(o,e.length,t,a,i),u=r.get_result_ptr(),d=new Uint16Array(r.memory.buffer,u,c),h=new Uint16Array(c);return h.set(d),{indices:h,paddingBits:r.get_padding_bits()}}finally{r.dealloc(o,e.length);}}decode(e,t,r){let{exports:o}=this;if(e.length===0)return new Uint8Array(0);let s=e.length*2,a=o.alloc(s);new Uint16Array(o.memory.buffer,a,e.length).set(e);let c=1<<t,u=1;try{let d=o.decode(a,e.length,t,c,u,r);if(d===4294967295)throw new Error("[WasmCodec decode] Invalid index in input");let h=o.get_result_ptr(),l=new Uint8Array(o.memory.buffer,h,d),f=new Uint8Array(d);return f.set(l),f}finally{o.dealloc(a,s);}}};async function le(){try{if(typeof fetch!="function")return null;let n=await fetch(new URL("./wasm/codec.wasm",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-JZSHJ6KN.cjs', document.baseURI).href))));return n.ok?await n.arrayBuffer():null}catch{return null}}async function ue(n){try{if(n.byteLength<16)return null;let e=new Uint8Array(n,0,4);if(e[0]!==0||e[1]!==97||e[2]!==115||e[3]!==109)return null;let t;try{t=await WebAssembly.compile(n);}catch{return null}let o=(await WebAssembly.instantiate(t,{})).exports;return typeof o.alloc!="function"||typeof o.dealloc!="function"||typeof o.encode!="function"||typeof o.decode!="function"||typeof o.get_result_ptr!="function"||typeof o.get_result_len!="function"||typeof o.get_padding_bits!="function"||!o.memory?null:o}catch{return null}}async function q(){try{if(A)return !0;if(w)return !1;let n=await F();if(!n)return w=!0,!1;let e=await ue(n);return e?(A=new M(e),!0):(w=!0,!1)}catch{return w=true,false}}function he(n,e){let t;return {promise:new Promise((s,a)=>{t=setTimeout(()=>a(new Error(e)),n);}),clear:()=>clearTimeout(t)}}async function He(){if(A)return;if(C)return C;let n=he(1e4,"[Ddu64 wasm] WASM initialization timed out (10s)"),e=async()=>{try{if(!await q())throw new Error("[Ddu64 wasm] WASM initialization failed")}finally{n.clear();}};return C=Promise.race([e(),n.promise]).finally(()=>{C=null,x=true;}),C}function ze(){if(A)return A;if(w)return null;if(!x&&!C){x=true;let n;C=new Promise(e=>{n=setTimeout(()=>{w=true,e();},5e3),q().then(t=>{t||(w=true);}).catch(()=>{w=true;}).finally(()=>{n!==void 0&&clearTimeout(n),e();});}).finally(()=>{C=null;});}return null}function O(){return A}function V(n){if(!Number.isFinite(n))throw new Error(`[Ddu64 config] wasmThreshold must be a finite number, got ${n}`);return Math.max(1024,Math.min(1048576,Math.round(n)))}function We(n){F=n,!A&&!C&&(x=false,w=false);}function G(n,e){let{bitLength:t,usePowerOfTwo:r,charsetSize:o}=e,s=n.length;if(s===0)return {indices:[],paddingBits:0};let a=s*8,i=Math.ceil(a/t),c=r?i:i*2,u=new Array(c),d=0,h=0,l=0;if(r){let p=(1<<t)-1;for(let m=0;m<s;m++)for(h=h<<8|n[m],l+=8;l>=t;)l-=t,u[d++]=h>>l&p,h&=(1<<l)-1;}else for(let p=0;p<s;p++)for(h=h<<8|n[p],l+=8;l>=t;){l-=t;let m=h>>l,g=m/o|0;u[d++]=g,u[d++]=m-g*o,h&=(1<<l)-1;}let f=0;if(l>0){f=t-l;let p=h<<f;if(r)u[d++]=p;else {let m=p/o|0;u[d++]=m,u[d++]=p-m*o;}}return u.length=d,{indices:u,paddingBits:f}}function j(n,e,t){let{bitLength:r,usePowerOfTwo:o,charsetSize:s}=t,a=n.length;if(a===0)return new Uint8Array(0);let i=o?1:2,c=Math.ceil(a/i),u=r<31?1<<r:Math.pow(2,r),d=Math.ceil((c*r-e)/8),h=new Uint8Array(d+1),l=0,f=0,p=0;if(o)for(let m=0;m<a;m+=i){let g=n[m];if(g<0||g>=s)throw new Error(`[BitPack decode] Invalid index ${g} at position ${m}`);for(f=f<<r|g,p+=r,m+i>=a&&e>0&&(f>>=e,p-=e);p>=8;)p-=8,h[l++]=f>>p&255,f&=(1<<p)-1;}else for(let m=0;m<a;m+=i){let g=n[m],y=n[m+1];if(g<0||g>=s)throw new Error(`[BitPack decode] Invalid index ${g} at position ${m}`);if(y===void 0||y<0||y>=s)throw new Error(`[BitPack decode] Invalid index ${y} at position ${m+1}`);let b=g*s+y;if(b>=u)throw new Error(`[BitPack decode] Value ${b} exceeds range at position ${m}`);for(f=f<<r|b,p+=r,m+i>=a&&e>0&&(f>>=e,p-=e);p>=8;)p-=8,h[l++]=f>>p&255,f&=(1<<p)-1;}return h.subarray(0,l)}var D="DDS1",P="ELYSIA",E="GRISEO";function X(n,e,t,r=2){let o=n.length,s=e.length,a={cleanedInput:n,paddingBits:0,isEncrypted:false,pipelineVersion:2};if(o<s)return a;let c=Math.max(0,t-1).toString().length;for(let u=Math.min(c,o);u>=1;u--){let d=o-u,h=true;for(let B=d;B<o;B++){let H=n.charCodeAt(B);if(H<48||H>57){h=false;break}}if(!h)continue;let l=n.substring(d),f=parseInt(l,10);if(Number.isNaN(f)||f<0||f>=t||l!==f.toString())continue;let p=d,m=false,g,y=2;p>=2&&n.substring(p-2,p)==="V3"&&(y=3,p-=2),p>=3&&n.substring(p-3,p)==="ENC"&&(m=true,p-=3),p>=P.length&&n.substring(p-P.length,p)===P?(g="deflate",p-=P.length):p>=E.length&&n.substring(p-E.length,p)===E&&(g="brotli",p-=E.length);let b=p-s;if(b>=0&&n.substring(b,p)===e)return {cleanedInput:n.substring(0,b),paddingBits:f,compressionAlgorithm:g,isEncrypted:m,pipelineVersion:y}}if(n.endsWith(e)){let u=0,d=o;for(;d>=s&&n.substring(d-s,d)===e;)u++,d-=s;if(u>0){let h=u*r;if(h<t)return {cleanedInput:n.substring(0,d),paddingBits:h,isEncrypted:false,pipelineVersion:2}}}return a}function Z(n){let e=n.lastIndexOf("CHK");if(e===-1)return {data:n,checksum:null};let t=n.slice(e+3);return t.length!==8||!/^[0-9a-f]+$/i.test(t)?{data:n,checksum:null}:{data:n.slice(0,e),checksum:t.toLowerCase()}}function fe(n){return n.length*2+D.length+2}function Fe(n,e){let t=e.compressionAlgorithm==="brotli"?"B":e.compressionAlgorithm==="deflate"?"D":"N",r=e.encrypted?"1":"0";return `${n}${D}${t}${r}${n}`}function qe(n,e){let t=fe(e);if(n.length<t||!n.startsWith(e))return null;let r=e.length;if(n.slice(r,r+D.length)!==D)throw new Error("[wireFormat] Invalid stream header magic");let s=n[r+D.length],a=n[r+D.length+1];if(n.slice(t-e.length,t)!==e)throw new Error("[wireFormat] Invalid stream header terminator");let c=s==="B"?"brotli":s==="D"?"deflate":s==="N"?void 0:null;if(c===null)throw new Error("[wireFormat] Invalid stream header compression flag");if(a!=="0"&&a!=="1")throw new Error("[wireFormat] Invalid stream header encryption flag");return {compressionAlgorithm:c,encrypted:a==="1"}}function J(n){let{paddingBits:e,compressionAlgorithm:t,isEncrypted:r,paddingChar:o,useRepeatPadding:s,bitsPerPadChar:a=2,pipelineVersion:i=2}=n;if(e===0&&!t&&!r&&i===2)return "";if(s&&!t&&!r&&i===2&&e>0&&e%a===0){let u=e/a;return o.repeat(u)}return o+(t==="deflate"?P:t==="brotli"?E:"")+(r?"ENC":"")+(i===3?"V3":"")+e.toString()}var pe=(()=>{let n=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let r=0;r<8;r++)t=t>>>1^(t&1?3988292384:0);n[e]=t;}return n})();function v(n){let e=4294967295;for(let t=0;t<n.length;t++)e=e>>>8^pe[(e^n[t])&255];return ((e^4294967295)>>>0).toString(16).padStart(8,"0")}var Q=["-","_","."];function ee(n){return n.length===0?n:n.replaceAll("+","-").replaceAll("/","_").replaceAll("=",".")}function te(n){return n.length===0?n:n.replaceAll("-","+").replaceAll("_","/").replaceAll(".","=")}function re(n,e,t){if(e<=0||n.length<=e)return n;let r=Math.ceil(n.length/e),o=new Array(r*2-1),s=0;for(let a=0;a<n.length;a+=e)o[s++]=n.slice(a,a+e),a+e<n.length&&(o[s++]=t);return o.join("")}function ne(n,e){if(n.length===0)return n;let t=n.replace(/[\r\n]/g,""),r=e&&e!==`
2
- `&&e!==`\r
3
- `&&e!=="\r"?e:"";return r.length>0&&t.includes(r)&&(t=t.replaceAll(r,"")),t}var me={"":0,\u3131:1,\u3132:2,\u3133:3,\u3134:4,\u3135:5,\u3136:6,\u3137:7,\u3139:8,\u313A:9,\u313B:10,\u313C:11,\u313D:12,\u313E:13,\u313F:14,\u3140:15,\u3141:16,\u3142:17,\u3144:18,\u3145:19,\u3146:20,\u3147:21,\u3148:22,\u314A:23,\u314B:24,\u314C:25,\u314D:26,\u314E:27};function ge(n,e){let t=n.charCodeAt(0);if(t<44032||t>55203)return n;let r=t-(t-44032)%28,o=me[e]??0;return String.fromCharCode(r+o)}function U(n,e){let t=new Array(n.length*e.length),r=0;for(let o of n)for(let s of e)t[r++]=ge(o,s);return t}function T(n,e){let r=n===void 0||!Number.isFinite(n)?6:Math.floor(n);return Math.min(e==="brotli"?11:9,Math.max(0,r))}var ye=new TextEncoder,be=new TextDecoder;function k(n){return ye.encode(n)}function I(n){return be.decode(n)}var Ce={symbol:"ddu",charSet:["\uB70C","\uB568","\uC774","\uC6B0","\uC57C","\uB4C0","\uB31C","\uB3A8"],codaChar:["","\u3131","\u3132","\u3137","\u3148","\u3147","\u3145","\u3146"],maxRequiredLength:64,bitLength:6,paddingChar:"\uBB50",useRepeatPadding:true},we={symbol:"ddu_v1",charSet:["\uB70C","\uB568","\uC774","\uC6B0","\uC57C","!","?","."],maxRequiredLength:8,bitLength:6,paddingChar:"\uBB50",useRepeatPadding:true,usePowerOfTwo:false,encodingProfile:{bitLength:6,usePowerOfTwo:false,bitsPerPadChar:2}},Se={symbol:"oneCharSet",charSet:["A","s","q","r","0","z","3","t","y","1","5","2","4","E","B","C","Q","F","R","T","U","W","V","X","Y","Z","b","a","c","d","D","G","L","H","I","-","J","K","M","O","N","f","e","h","g","P","i","S","k","l","m","u","j","v","n","o","p","9","w","6","7","8","x","_"],paddingChar:"=",maxRequiredLength:64,bitLength:6};function R(n){switch(n){case "ddu":return Ce;case "ddu_v1":return we;case "oneCharSet":return Se;default:return}}var Ae=65536;function oe(n,e,t,r){let o=(s,a,i,c,u)=>{if(Pe(i,t?.usePowerOfTwo)&&i>0){let l=Math.floor(Math.log2(i)),f=1<<l;return {charSet:s.length===f?s:s.slice(0,f),padding:a,requiredLength:f,bitLength:l,isPredefined:c,useRepeatPadding:u}}return {charSet:s.length===i?s:s.slice(0,i),padding:a,requiredLength:i,bitLength:i>0?Math.ceil(Math.log2(i)):0,isPredefined:c,useRepeatPadding:u}};try{let s=n??t?.dduChar,a=e??t?.paddingChar;if(s){if(!a)throw new Error("[Ddu64 Constructor] paddingChar is required when dduChar is provided.");let l=typeof s=="string"?[...s]:[...s],f=t?.codaChar,p=f?!0:t?.useRepeatPadding??!1;if(f&&f.length>0&&(l=U(l,f)),r&&new Set(l).size!==l.length){let y=l.filter((b,B)=>l.indexOf(b)!==B);throw new Error(`[Ddu64 Constructor] Character set contains duplicate characters: [${[...new Set(y)].join(", ")}]`)}let m=t?.requiredLength??l.length;if(l.length<m)throw new Error("[Ddu64 Constructor] Insufficient characters.");return o(l,a,m,!1,p)}let i=t?.dduSetSymbol??_.dduSetSymbol??"ddu",c=Ee(i),u=c.codaChar?U(c.charSet,c.codaChar):c.charSet,d=o(u,c.paddingChar,c.maxRequiredLength,!0,c.useRepeatPadding),h=c.encodingProfile;return h?(d.encodingProfile=h,d.bitLength=h.bitLength,d.usePowerOfTwo=h.usePowerOfTwo,d.bitsPerPadChar=h.bitsPerPadChar):(d.bitsPerPadChar=c.bitsPerPadChar,d.usePowerOfTwo=c.usePowerOfTwo,c.usePowerOfTwo===!1&&(d.bitLength=c.bitLength)),d}catch(s){if(r)throw s;return K(t)}}function se(n,e,t){let r=[n,null];for(let s of r){let a=s?{...s}:K(t);try{let i=a.charSet,c=a.requiredLength,u=Array.from(new Set(i));if(u.length!==i.length){if(e){let l=i.filter((f,p)=>i.indexOf(f)!==p);throw new Error(`[Ddu64 normalizeCharSet] Character set contains duplicate characters: [${[...new Set(l)].join(", ")}]`)}i=u,a.isPredefined||(c=i.length);}if(i.length<c)throw new Error(`[Ddu64 normalizeCharSet] Insufficient characters. Required: ${c}, Has: ${i.length}`);if(c<2)throw new Error("[Ddu64 normalizeCharSet] At least 2 unique characters required.");if(i.length===0)throw new Error("[Ddu64 normalizeCharSet] Empty charset.");if(i.find(l=>l.length!==1)){if(e)throw new Error("[Ddu64 normalizeCharSet] Multi-character symbols are not supported.");continue}if(i.length>Ae){if(e)throw new Error("[Ddu64 normalizeCharSet] Charset size exceeds maximum supported size of 65536.");continue}if(a.padding.length!==1)throw new Error(`[Ddu64 normalizeCharSet] Padding length mismatch. Expected 1, got ${a.padding.length}`);if(i.includes(a.padding)){if(e)throw new Error(`[Ddu64 normalizeCharSet] Padding character "${a.padding}" conflicts with charset.`);i=i.filter(l=>l!==a.padding);}for(let l of i)if(l.includes(`
4
- `)||l.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(a.padding.includes(`
5
- `)||a.padding.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");return {charSet:i.length===c?i:i.slice(0,c),padding:a.padding,isPredefined:a.isPredefined}}catch(i){if(e)throw i}}let o=K(t);return {charSet:o.charSet.slice(0,o.requiredLength),padding:o.padding,isPredefined:true}}function ie(n,e,t){for(let r of Q){for(let o of n)if(o.includes(r)){let s=`[Ddu64 Constructor] URL-Safe mode conflict: charset character "${o}" contains "${r}".`;if(t)throw new Error(s);return false}if(e.includes(r)){let o=`[Ddu64 Constructor] URL-Safe mode conflict: padding character "${e}" contains "${r}".`;if(t)throw new Error(o);return false}}return true}function ae(n,e,t){if(t>256)return;let r=Math.min(n.length,t),o=n.slice(0,r),s=new Set;for(let i=0;i<o.length;i++)s.add(o[i]);s.add(e);for(let i=0;i<o.length;i++){let c=o[i];for(let h=0;h<o.length;h++){let l=c+o[h];if(s.has(l))throw new Error(`Combination conflict: "${c}" + "${o[h]}"`);s.add(l);}let u=c+e;if(s.has(u))throw new Error(`Combination conflict: "${c}" + padding`);s.add(u);let d=e+c;if(s.has(d))throw new Error(`Combination conflict: padding + "${c}"`);s.add(d);}let a=e+e;if(s.has(a))throw new Error("Combination conflict: double padding");s.add(a);}function Pe(n,e){return e!==void 0?e?n>0:false:n>0&&(n&n-1)===0}function Ee(n){let e=R(n);if(!e)throw new Error(`CharSet with symbol ${n} not found`);return e}function K(n){let e=n?.dduSetSymbol??_.dduSetSymbol??"oneCharSet",t=R(e)??R("oneCharSet");if(!t)throw new Error("Critical: No fallback CharSet available");return {charSet:t.codaChar?U(t.charSet,t.codaChar):t.charSet,padding:t.paddingChar,requiredLength:t.maxRequiredLength,bitLength:t.encodingProfile?.bitLength??t.bitLength,isPredefined:true,useRepeatPadding:t.useRepeatPadding,bitsPerPadChar:t.encodingProfile?.bitsPerPadChar??t.bitsPerPadChar,usePowerOfTwo:t.encodingProfile?.usePowerOfTwo??t.usePowerOfTwo,encodingProfile:t.encodingProfile}}var ve=8,Ue=4096,S=8192,Te=1<<20,ke=64*1024*1024,Re=64*1024*1024,_e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",N="=",ce=class{dduChar;dduCharCodes;paddingChar;bitLength;usePowerOfTwo;dduCharCodeLookup;isPredefinedCharSet;defaultCompress;defaultMaxDecodedBytes;defaultMaxDecompressedBytes;urlSafe;encryptionKey;keyDerivation;encryptionKeyHash;defaultChecksum;defaultChunkSize;defaultChunkSeparator;defaultCompressionLevel;defaultCompressionAlgorithm;useRepeatPadding;bitsPerPadChar;bitPackConfig;wasmThreshold;canUseNativeBase64;adapter;defaultObfuscate;_obfuscationLayer;constructor(e,t,r){e!=null&&typeof e=="object"&&!Array.isArray(e)&&(r=e,e=void 0,t=void 0);let o=r?.throwOnError??r?.useBuildErrorReturn??false;r?.adapter?this.adapter=r.adapter:this.adapter=void 0;let s=oe(e,t,r,o),a=se(s,o,r);this.dduChar=a.charSet,this.paddingChar=a.padding,this.isPredefinedCharSet=a.isPredefined,this.defaultCompress=r?.compress??false,this.defaultMaxDecodedBytes=this.normalizeLimit(r?.maxDecodedBytes,ke,o,"maxDecodedBytes"),this.defaultMaxDecompressedBytes=this.normalizeLimit(r?.maxDecompressedBytes,Re,o,"maxDecompressedBytes");let i=this.dduChar.length,c=i>0&&(i&i-1)===0,u=r?.usePowerOfTwo,d=s.encodingProfile;this.usePowerOfTwo=d?.usePowerOfTwo??s.usePowerOfTwo??(u!==void 0?u&&c:c);let h=d?.bitLength??(s.isPredefined&&s.usePowerOfTwo!==void 0?s.bitLength:void 0);this.bitLength=h??(this.usePowerOfTwo?Math.floor(Math.log2(i)):Math.ceil(Math.log2(i))),this.dduCharCodeLookup=new Int32Array(65536),this.dduCharCodeLookup.fill(-1);for(let f=0;f<i;f++){let p=this.dduChar[f];this.dduCharCodeLookup[p.charCodeAt(0)]=f;}this.dduCharCodes=new Uint16Array(i);for(let f=0;f<i;f++)this.dduCharCodes[f]=this.dduChar[f].charCodeAt(0);this.isPredefinedCharSet||ae(this.dduChar,this.paddingChar,i);let l=r?.urlSafe??false;if(this.urlSafe=l?ie(this.dduChar,this.paddingChar,o):false,this.encryptionKey=r?.encryptionKey,this.keyDerivation=r?.keyDerivation,this.encryptionKey&&this.adapter?.deriveKeySync&&(this.encryptionKeyHash=this.adapter.deriveKeySync(this.encryptionKey,this.keyDerivation)),this.defaultChecksum=r?.checksum??false,this.defaultChunkSize=r?.chunkSize,this.defaultChunkSeparator=r?.chunkSeparator??`
6
- `,this.defaultCompressionAlgorithm=r?.compressionAlgorithm??"deflate",this.defaultCompressionLevel=T(r?.compressionLevel,this.defaultCompressionAlgorithm),this.useRepeatPadding=r?.useRepeatPadding??s.useRepeatPadding??false,this.bitsPerPadChar=d?.bitsPerPadChar??s.bitsPerPadChar??2,this.defaultObfuscate=r?.obfuscate??false,this.defaultObfuscate&&!this.encryptionKey)throw new Error("[Ddu64 obfuscation] Obfuscation requires encryption to be enabled.");this.bitPackConfig={bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,charsetSize:i},this.wasmThreshold=V(r?.wasmThreshold??4096),this.canUseNativeBase64=this.usePowerOfTwo&&this.bitLength===6&&this.paddingChar===N&&this.dduChar.join("")===_e;}encode(e,t){return this.encodeInternal(e,t).encoded}decode(e,t){let r=this.decodeToUint8Array(e,t);return I(r)}decodeToUint8Array(e,t){let r=this.decodePrelude(e,t),{extractedChecksum:o,compressionAlgorithm:s,isEncrypted:a,pipelineVersion:i}=r,{allowInternalDecompress:c,allowInternalDecrypt:u}=r,d=r.decoded;if(i===3&&a&&this.encryptionKey&&u&&(this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:55,stage:"decrypt"}),d=this.decryptSync(d)),this.shouldDecompress(s,c,a,i,u)){let h=this.normalizeLimit(t?.maxDecompressedBytes,this.defaultMaxDecompressedBytes,true,"maxDecompressedBytes");this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:70,stage:"decompress"}),d=this.decompressSync(d,s,h);}return this.verifyDecodedChecksum(d,o,a,i,u,t),i===2&&a&&this.encryptionKey&&u&&(this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:90,stage:"decrypt"}),d=this.decryptSync(d)),this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:100,stage:"done"}),d}async encodeAsync(e,t){let{shouldCompress:r,shouldChecksum:o,shouldEncrypt:s,chunkSize:a,chunkSeparator:i}=this.resolveEncodeSettings(t),c=typeof e=="string"?k(e):e;this.reportProgress(t,{processedBytes:0,totalBytes:c.length,percent:0,stage:"start"});let u="";o&&(u=v(c));let d;if(r){let l=t?.compressionAlgorithm??this.defaultCompressionAlgorithm,f=T(t?.compressionLevel??this.defaultCompressionLevel,l),p=await this.getAdapterAsync();this.reportProgress(t,{processedBytes:c.length,totalBytes:c.length,percent:20,stage:"compress"});let m;if(l==="brotli"){if(!p.brotliCompress)throw new Error("[Ddu64 compress] Brotli compression is unavailable in the current runtime.");m=await p.brotliCompress(c,f);}else m=await p.deflate(c,f);m.length<c.length&&(c=m,d=l);}let h=false;if(s){let l=await this.getAdapterAsync(),f=await this.getKeyHashAsync(l);this.reportProgress(t,{processedBytes:c.length,totalBytes:c.length,percent:45,stage:"encrypt"}),c=await l.encrypt(c,f),h=true;}return this.finalizeEncode(c,d,h,u,o,a,i,t)}async decodeAsync(e,t){let r=await this.decodeToUint8ArrayAsync(e,t);return I(r)}async decodeToUint8ArrayAsync(e,t){let r=this.decodePrelude(e,t),{extractedChecksum:o,compressionAlgorithm:s,isEncrypted:a,pipelineVersion:i}=r,{allowInternalDecompress:c,allowInternalDecrypt:u}=r,d=r.decoded;if(i===3&&a&&this.encryptionKey&&u){let h=await this.getAdapterAsync(),l=await this.getKeyHashAsync(h);this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:55,stage:"decrypt"}),d=await h.decrypt(d,l);}if(this.shouldDecompress(s,c,a,i,u)){let h=this.normalizeLimit(t?.maxDecompressedBytes,this.defaultMaxDecompressedBytes,true,"maxDecompressedBytes"),l=await this.getAdapterAsync();if(this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:70,stage:"decompress"}),s==="brotli"){if(!l.brotliDecompress)throw new Error("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.");d=await l.brotliDecompress(d,h);}else d=await l.inflate(d,h);}if(this.verifyDecodedChecksum(d,o,a,i,u,t),i===2&&a&&this.encryptionKey&&u){let h=await this.getAdapterAsync(),l=await this.getKeyHashAsync(h);this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:90,stage:"decrypt"}),d=await h.decrypt(d,l);}return this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:100,stage:"done"}),d}getCharSetInfo(){return {charSet:[...this.dduChar],paddingChar:this.paddingChar,bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,encoding:"utf-8",defaultCompress:this.defaultCompress,defaultMaxDecodedBytes:this.defaultMaxDecodedBytes,defaultMaxDecompressedBytes:this.defaultMaxDecompressedBytes,urlSafe:this.urlSafe,hasEncryptionKey:!!this.encryptionKey,defaultChecksum:this.defaultChecksum,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm}}getStats(e,t){let o=(typeof e=="string"?k(e):e).length,{encoded:s,compressedSize:a}=this.encodeInternal(e,t),i=s.length,c=o>0?i/o:0,d=(t?.compress??this.defaultCompress)&&a!==void 0&&o>0?a/o:void 0;return {originalSize:o,encodedSize:i,compressedSize:a,compressionRatio:d,expansionRatio:c,charsetSize:this.dduChar.length,bitLength:this.bitLength}}encodeInternal(e,t){let{shouldCompress:r,shouldChecksum:o,shouldEncrypt:s,chunkSize:a,chunkSeparator:i}=this.resolveEncodeSettings(t),c=typeof e=="string"?k(e):e;this.reportProgress(t,{processedBytes:0,totalBytes:c.length,percent:0,stage:"start"});let u="";o&&(u=v(c));let d,h;if(r){let p=t?.compressionAlgorithm??this.defaultCompressionAlgorithm,m=T(t?.compressionLevel??this.defaultCompressionLevel,p);this.reportProgress(t,{processedBytes:c.length,totalBytes:c.length,percent:20,stage:"compress"});let g=this.compressSync(c,p,m);h=g.length,g.length<c.length&&(c=g,d=p);}let l=false;return s&&(this.reportProgress(t,{processedBytes:c.length,totalBytes:c.length,percent:45,stage:"encrypt"}),c=this.encryptSync(c),l=true),{encoded:this.finalizeEncode(c,d,l,u,o,a,i,t),compressedSize:h}}resolveEncodeSettings(e){return {shouldCompress:e?.compress??this.defaultCompress,shouldChecksum:e?.checksum??this.defaultChecksum,shouldEncrypt:(e?.encrypt??true)&&!!this.encryptionKey,chunkSize:e?.chunkSize??this.defaultChunkSize,chunkSeparator:e?.chunkSeparator??this.defaultChunkSeparator}}finalizeEncode(e,t,r,o,s,a,i,c){this.reportProgress(c,{processedBytes:e.length,totalBytes:e.length,percent:70,stage:"encode"});let u=this.encodeBytes(e,t,r,c);return u=this.applyPostEncoding(u,c,o,s,a,i),this.reportProgress(c,{processedBytes:e.length,totalBytes:e.length,percent:100,stage:"done"}),u}applyPostEncoding(e,t,r,o,s,a){let i=e;return this.shouldObfuscate(t)&&(i=this.getObfuscationLayer().obfuscate(i)),o&&r&&(i=i+"CHK"+r),this.urlSafe&&(i=ee(i)),s&&s>0&&(this.assertSafeChunkSeparator(i,a),i=re(i,s,a)),i}encodeBytes(e,t,r,o){if(e.length===0)return "";let s=this.encodeBytesWithNativeBase64(e),a,i;if(s)a=s.paddingBits,i=s.payload;else {let u,d=this.shouldUseWasm(e.length)?O():null;if(d?.ready&&this.usePowerOfTwo){let l=d.encode(e,this.bitLength);u=l.indices,a=l.paddingBits;}else {let l=G(e,this.bitPackConfig);u=l.indices,a=l.paddingBits;}let h=u.length;if(h<=Te){let l=new Uint16Array(h);for(let f=0;f<h;f++)l[f]=this.dduCharCodes[u[f]];if(h<=S)i=String.fromCharCode.apply(null,l);else {let f=new Array(Math.ceil(h/S)),p=0;for(let m=0;m<h;m+=S){let g=l.subarray(m,Math.min(m+S,h));f[p++]=String.fromCharCode.apply(null,g);}i=f.join("");}}else {let l=new Uint16Array(S),f=new Array(Math.ceil(h/S)),p=0;for(let m=0;m<h;m+=S){let g=Math.min(S,h-m);for(let b=0;b<g;b++)l[b]=this.dduCharCodes[u[m+b]];let y=g===l.length?l:l.subarray(0,g);f[p++]=String.fromCharCode.apply(null,y);}i=f.join("");}}let c=o?.omitFooter?"":J({paddingBits:a,compressionAlgorithm:t,isEncrypted:!!r,paddingChar:this.paddingChar,useRepeatPadding:this.useRepeatPadding&&!t&&!r,bitsPerPadChar:this.bitsPerPadChar,pipelineVersion:r?3:2});return i+c}decodePrelude(e,t){let r=t?.checksum??this.defaultChecksum,o=t?.compress!==false,s=t?.encrypt!==false,a=e;this.reportProgress(t,{processedBytes:0,totalBytes:e.length,percent:0,stage:"start"});let i=t?.chunkSeparator??this.defaultChunkSeparator;a=ne(a,i),this.urlSafe&&(a=te(a));let c=null;if(r){let y=Z(a);c=y.checksum,a=y.data;}this.shouldObfuscate(t)&&(a=this.getObfuscationLayer().deobfuscate(a));let{cleanedInput:u,paddingBits:d,compressionAlgorithm:h,isEncrypted:l,pipelineVersion:f}=X(a,this.paddingChar,this.bitLength,this.bitsPerPadChar);if(l&&s&&!this.encryptionKey)throw new Error("[Ddu64 decode] Encrypted payload requires an encryptionKey");this.assertEncodedInputAligned(u),this.assertCanonicalPadding(u,d);let p=this.normalizeLimit(t?.maxDecodedBytes,this.defaultMaxDecodedBytes,true,"maxDecodedBytes"),m=this.estimateDecodedBytes(u.length,d);if(m>p)throw new Error(`[Ddu64 decode] Decoded output exceeds limit. Estimated: ${m} bytes, Limit: ${p} bytes`);return this.reportProgress(t,{processedBytes:u.length,totalBytes:e.length,percent:30,stage:"decode"}),{decoded:this.decodeChars(u,d),extractedChecksum:c,compressionAlgorithm:h,isEncrypted:l,pipelineVersion:f,allowInternalDecompress:o,allowInternalDecrypt:s}}shouldDecompress(e,t,r,o,s){return !!e&&t&&(o===2||!r||s)}verifyDecodedChecksum(e,t,r,o,s,a){if(!t||!(o===2||!r||s))return;this.reportProgress(a,{processedBytes:e.length,totalBytes:e.length,percent:85,stage:"checksum"});let i=v(e);if(i!==t)throw new Error(`[Ddu64 decode] Checksum mismatch. Expected: ${t}, Got: ${i}`)}decodeChars(e,t){let r=e.length;if(r===0)return new Uint8Array(0);let o=this.decodeCharsWithNativeBase64(e,t);if(o)return o;let s=r>=this.wasmThreshold||r>=Ue?new Uint16Array(r):new Array(r);for(let i=0;i<r;i++){let c=this.dduCharCodeLookup[e.charCodeAt(i)];if(c<0)throw new Error(`[Ddu64 decode] Invalid character "${e[i]}" at ${i}`);s[i]=c;}let a=this.shouldUseWasm(r)?O():null;if(a?.ready&&this.usePowerOfTwo){let i=s instanceof Uint16Array?s:Uint16Array.from(s);return a.decode(i,this.bitLength,t)}return j(s,t,this.bitPackConfig)}encodeBytesWithNativeBase64(e){if(!this.canUseNativeBase64)return null;let t=this.bytesToBase64(e);if(t===null)return null;let r=0,o=t.length;for(;o>0&&t[o-1]===N;)r++,o--;return {payload:t.slice(0,o),paddingBits:r===2?4:r===1?2:0}}decodeCharsWithNativeBase64(e,t){if(!this.canUseNativeBase64)return null;let r=t===4?2:t===2?1:t===0?0:-1;if(r<0)return null;for(let o=0;o<e.length;o++)if(this.dduCharCodeLookup[e.charCodeAt(o)]<0)return null;return this.base64ToBytes(e+N.repeat(r))}bytesToBase64(e){let t=e.toBase64;if(typeof t=="function")return t.call(e);let r=globalThis.Buffer;return r?.from?r.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"):null}base64ToBytes(e){let t=Uint8Array;if(typeof t.fromBase64=="function")return t.fromBase64(e);let r=globalThis.Buffer;if(r?.from){let o=r.from(e,"base64");return new Uint8Array(o.buffer,o.byteOffset,o.byteLength)}return null}shouldUseWasm(e){return e>=this.wasmThreshold}reportProgress(e,t){e?.onProgress?.(t);}requireSyncAdapter(){if(!this.adapter)throw new Error("[Ddu64 adapter] No platform adapter available. Use encodeAsync()/decodeAsync() in browser environments, or provide an adapter via options.adapter.");return this.adapter}encryptSync(e){let t=this.requireSyncAdapter();if(!t.encryptSync)throw new Error("[Ddu64 encrypt] Sync encryption unavailable. Use encodeAsync() in browser environments.");if(!this.encryptionKeyHash){if(!t.deriveKeySync)throw new Error("[Ddu64 encrypt] Sync key derivation unavailable. Use encodeAsync() in browser environments.");this.encryptionKeyHash=t.deriveKeySync(this.encryptionKey,this.keyDerivation);}return t.encryptSync(e,this.encryptionKeyHash)}decryptSync(e){let t=this.requireSyncAdapter();if(!t.decryptSync)throw new Error("[Ddu64 decrypt] Sync decryption unavailable. Use decodeAsync() in browser environments.");if(!this.encryptionKeyHash){if(!t.deriveKeySync)throw new Error("[Ddu64 decrypt] Sync key derivation unavailable. Use decodeAsync() in browser environments.");this.encryptionKeyHash=t.deriveKeySync(this.encryptionKey,this.keyDerivation);}return t.decryptSync(e,this.encryptionKeyHash)}compressSync(e,t,r){let o=this.requireSyncAdapter();if(t==="brotli"){if(!o.brotliCompressSync)throw new Error("[Ddu64 compress] Brotli compression is unavailable in the current runtime.");return o.brotliCompressSync(e,r)}if(!o.deflateSync)throw new Error("[Ddu64 compress] Sync compression unavailable. Use encodeAsync() in browser environments.");return o.deflateSync(e,r)}decompressSync(e,t,r){let o=this.requireSyncAdapter();if(t==="brotli"){if(!o.brotliDecompressSync)throw new Error("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.");return o.brotliDecompressSync(e,r)}if(!o.inflateSync)throw new Error("[Ddu64 decompress] Sync decompression unavailable. Use decodeAsync() in browser environments.");return o.inflateSync(e,r)}async getAdapterAsync(){if(this.adapter)return this.adapter;throw new Error("[Ddu64 adapter] No platform adapter available. Use @ddunigma/node or @ddunigma/node/browser, or provide an adapter via options.adapter.")}async getKeyHashAsync(e){return this.encryptionKeyHash?this.encryptionKeyHash:(this.encryptionKeyHash=await e.deriveKey(this.encryptionKey,this.keyDerivation),this.encryptionKeyHash)}getObfuscationLayer(){if(!this._obfuscationLayer){let e=new Set(this.dduChar);e.add(this.paddingChar);let t=P+E+"ENC"+"V3";for(let o of t)e.add(o);for(let o of "0123456789")e.add(o);let r=[...e];this._obfuscationLayer=new L(r);}return this._obfuscationLayer}shouldObfuscate(e){let t=e?.obfuscate??this.defaultObfuscate;if(t&&!this.encryptionKey)throw new Error("[Ddu64 obfuscation] Obfuscation requires encryption to be enabled.");return t}normalizeLimit(e,t,r,o){if(e===void 0)return t;if(e===Number.POSITIVE_INFINITY)return Number.POSITIVE_INFINITY;if(!Number.isFinite(e)||e<=0){if(r)throw new Error(`[Ddu64 options] Invalid ${o}. Must be a positive finite number or Infinity.`);return t}return Math.floor(e)}assertSafeChunkSeparator(e,t){if(!(t.length===0||this.isLineBreakSeparator(t))&&e.includes(t))throw new Error(`[Ddu64 chunking] Unsafe chunkSeparator "${t}" appears in encoded output. Use a separator that cannot be produced by the charset, footer, checksum, or URL-safe output.`)}isLineBreakSeparator(e){return e===`
7
- `||e===`\r
8
- `||e==="\r"}estimateDecodedBytes(e,t){if(e===0)return 0;if(t<0||t>=this.bitLength)throw new Error(`[Ddu64 decode] Invalid padding bits: ${t}`);let r=this.usePowerOfTwo?1:2,s=Math.ceil(e/r)*this.bitLength-t;if(s<0)throw new Error("[Ddu64 decode] Invalid decoded bit length");return Math.ceil(s/ve)}assertEncodedInputAligned(e){if(!this.usePowerOfTwo&&e.length%2!==0)throw new Error(`[Ddu64 decode] Invalid encoded length for variable charset. Expected multiple of 2, got ${e.length}`)}assertCanonicalPadding(e,t){if(t===0)return;if(e.length===0)throw new Error("[Ddu64 decode] Invalid padding bits without payload");let r=(1<<t)-1,o;if(this.usePowerOfTwo){let s=e[e.length-1],a=this.dduCharCodeLookup[s.charCodeAt(0)];if(a<0)throw new Error(`[Ddu64 decode] Invalid character "${s}" at ${e.length-1}`);o=a;}else {let s=e[e.length-2],a=e[e.length-1],i=this.dduCharCodeLookup[s.charCodeAt(0)],c=this.dduCharCodeLookup[a.charCodeAt(0)];if(i<0||c<0)throw new Error("[Ddu64 decode] Invalid character in final encoded chunk");o=i*this.dduChar.length+c;}if((o&r)!==0)throw new Error("[Ddu64 decode] Invalid non-zero padding bits in final symbol")}};var de=class n{chars=[];constructor(){}static create(){return new n}static fromUnicodeRange(e,t){return new n().addUnicodeRange(e,t)}static fromString(e){return new n().addString(e)}static base64(){return new n().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")}static base32(){return new n().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")}static uppercase(){return n.fromUnicodeRange(65,90)}static lowercase(){return n.fromUnicodeRange(97,122)}static digits(){return n.fromUnicodeRange(48,57)}static hangulJamo(){return new n().addUnicodeRange(4352,4370).addUnicodeRange(4449,4469).addUnicodeRange(4520,4546)}addUnicodeRange(e,t){for(let r=e;r<=t;r++)this.chars.push(String.fromCodePoint(r));return this}addString(e){return typeof e=="string"?this.chars.push(...e):this.chars.push(...e),this}add(...e){return this.chars.push(...e),this}excludeConfusing(){let e=new Set(["0","O","o","1","l","I","i","|","L"]);return this.chars=this.chars.filter(t=>!e.has(t)),this}exclude(...e){let t=new Set(e);return this.chars=this.chars.filter(r=>!t.has(r)),this}excludeUrlUnsafe(){let e=new Set(["+","/","=","?","&","#","%"," "]);return this.chars=this.chars.filter(t=>!e.has(t)),this}unique(){return this.chars=[...new Set(this.chars)],this}shuffle(e){let t=e!==void 0?this.seededRandom(e):Math.random;for(let r=this.chars.length-1;r>0;r--){let o=Math.floor(t()*(r+1));[this.chars[r],this.chars[o]]=[this.chars[o],this.chars[r]];}return this}seededRandom(e){let t=e|0||1;return ()=>(t^=t<<13,t^=t>>17,t^=t<<5,(t>>>0)/4294967296)}limit(e){return this.chars=this.chars.slice(0,e),this}limitToPowerOfTwo(){let e=this.chars.length;if(e===0)return this;let t=1<<Math.floor(Math.log2(e));return this.chars=this.chars.slice(0,t),this}sort(){return this.chars.sort(),this}reverse(){return this.chars.reverse(),this}get length(){return this.chars.length}buildString(){return this.chars.join("")}build(){return [...this.chars]}buildWithPadding(e){let t=[...this.chars],r=e;if(!r){let o=["=",".","_","-","~","!"];for(let s of o)if(!t.includes(s)){r=s;break}if(!r)throw new Error("Cannot find suitable padding character")}return {charset:t,padding:r}}};exports.a=fe;exports.b=Fe;exports.c=qe;exports.d=z;exports.e=L;exports.f=Ke;exports.g=He;exports.h=ze;exports.i=O;exports.j=We;exports.k=ce;exports.l=de;//# sourceMappingURL=chunk-JZSHJ6KN.cjs.map
9
- //# sourceMappingURL=chunk-JZSHJ6KN.cjs.map
@@ -1,9 +0,0 @@
1
- var z=(r=>(r.DDU="ddu",r.DDU_V1="ddu_v1",r.ONECHARSET="oneCharSet",r))(z||{}),_={dduSetSymbol:"ddu",usePowerOfTwo:true,requiredLength:64,bitLength:6};function W(n){if(n.length===0)throw new Error("[Ddu64 obfuscation] Alphabet must not be empty.");if(n.length>11172)throw new Error(`[Ddu64 obfuscation] Alphabet size (${n.length}) exceeds available Hangul syllables (11172).`);let e=Math.floor(11172/n.length),t=new Map;for(let r=0;r<n.length;r++)t.set(n[r],r);return {alphabet:n,syllablesPerChar:e,charToIndex:t}}function $(n,e,t){let r=44032+n*t.syllablesPerChar,o=e%t.syllablesPerChar;return r+o}function Y(n,e){if(n<44032||n>55203)return -1;let t=n-44032,r=Math.floor(t/e.syllablesPerChar);return r>=e.alphabet.length?-1:r}var L=class{config;constructor(e){this.config=W(e);}obfuscate(e){if(e.length===0)return "";let t=new Array(e.length);for(let r=0;r<e.length;r++){let o=e[r],s=this.config.charToIndex.get(o);if(s===void 0)throw new Error(`[Ddu64 obfuscation] Character "${o}" (U+${o.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase()}) not found in obfuscation alphabet.`);let a=$(s,r,this.config);t[r]=String.fromCharCode(a);}return t.join("")}deobfuscate(e){if(e.length===0)return "";let t=new Array(e.length);for(let r=0;r<e.length;r++){let o=e.charCodeAt(r),s=Y(o,this.config);if(s===-1)throw new Error(`[Ddu64 obfuscation] Invalid syllable at position ${r}: U+${o.toString(16).padStart(4,"0").toUpperCase()} is not in the mapped range.`);t[r]=this.config.alphabet[s];}return t.join("")}};function Ke(n,e){let t=new Set(n);t.add(e);let r=[...t];return new L(r)}var A=null,x=false,w=false,C=null,F=le,M=class{exports;constructor(e){this.exports=e;}get ready(){return true}encode(e,t){let{exports:r}=this;if(e.length===0)return {indices:new Uint16Array(0),paddingBits:0};let o=r.alloc(e.length);new Uint8Array(r.memory.buffer).set(e,o);let a=1<<t,i=1;try{let c=r.encode(o,e.length,t,a,i),u=r.get_result_ptr(),d=new Uint16Array(r.memory.buffer,u,c),h=new Uint16Array(c);return h.set(d),{indices:h,paddingBits:r.get_padding_bits()}}finally{r.dealloc(o,e.length);}}decode(e,t,r){let{exports:o}=this;if(e.length===0)return new Uint8Array(0);let s=e.length*2,a=o.alloc(s);new Uint16Array(o.memory.buffer,a,e.length).set(e);let c=1<<t,u=1;try{let d=o.decode(a,e.length,t,c,u,r);if(d===4294967295)throw new Error("[WasmCodec decode] Invalid index in input");let h=o.get_result_ptr(),l=new Uint8Array(o.memory.buffer,h,d),f=new Uint8Array(d);return f.set(l),f}finally{o.dealloc(a,s);}}};async function le(){try{if(typeof fetch!="function")return null;let n=await fetch(new URL("./wasm/codec.wasm",import.meta.url));return n.ok?await n.arrayBuffer():null}catch{return null}}async function ue(n){try{if(n.byteLength<16)return null;let e=new Uint8Array(n,0,4);if(e[0]!==0||e[1]!==97||e[2]!==115||e[3]!==109)return null;let t;try{t=await WebAssembly.compile(n);}catch{return null}let o=(await WebAssembly.instantiate(t,{})).exports;return typeof o.alloc!="function"||typeof o.dealloc!="function"||typeof o.encode!="function"||typeof o.decode!="function"||typeof o.get_result_ptr!="function"||typeof o.get_result_len!="function"||typeof o.get_padding_bits!="function"||!o.memory?null:o}catch{return null}}async function q(){try{if(A)return !0;if(w)return !1;let n=await F();if(!n)return w=!0,!1;let e=await ue(n);return e?(A=new M(e),!0):(w=!0,!1)}catch{return w=true,false}}function he(n,e){let t;return {promise:new Promise((s,a)=>{t=setTimeout(()=>a(new Error(e)),n);}),clear:()=>clearTimeout(t)}}async function He(){if(A)return;if(C)return C;let n=he(1e4,"[Ddu64 wasm] WASM initialization timed out (10s)"),e=async()=>{try{if(!await q())throw new Error("[Ddu64 wasm] WASM initialization failed")}finally{n.clear();}};return C=Promise.race([e(),n.promise]).finally(()=>{C=null,x=true;}),C}function ze(){if(A)return A;if(w)return null;if(!x&&!C){x=true;let n;C=new Promise(e=>{n=setTimeout(()=>{w=true,e();},5e3),q().then(t=>{t||(w=true);}).catch(()=>{w=true;}).finally(()=>{n!==void 0&&clearTimeout(n),e();});}).finally(()=>{C=null;});}return null}function O(){return A}function V(n){if(!Number.isFinite(n))throw new Error(`[Ddu64 config] wasmThreshold must be a finite number, got ${n}`);return Math.max(1024,Math.min(1048576,Math.round(n)))}function We(n){F=n,!A&&!C&&(x=false,w=false);}function G(n,e){let{bitLength:t,usePowerOfTwo:r,charsetSize:o}=e,s=n.length;if(s===0)return {indices:[],paddingBits:0};let a=s*8,i=Math.ceil(a/t),c=r?i:i*2,u=new Array(c),d=0,h=0,l=0;if(r){let p=(1<<t)-1;for(let m=0;m<s;m++)for(h=h<<8|n[m],l+=8;l>=t;)l-=t,u[d++]=h>>l&p,h&=(1<<l)-1;}else for(let p=0;p<s;p++)for(h=h<<8|n[p],l+=8;l>=t;){l-=t;let m=h>>l,g=m/o|0;u[d++]=g,u[d++]=m-g*o,h&=(1<<l)-1;}let f=0;if(l>0){f=t-l;let p=h<<f;if(r)u[d++]=p;else {let m=p/o|0;u[d++]=m,u[d++]=p-m*o;}}return u.length=d,{indices:u,paddingBits:f}}function j(n,e,t){let{bitLength:r,usePowerOfTwo:o,charsetSize:s}=t,a=n.length;if(a===0)return new Uint8Array(0);let i=o?1:2,c=Math.ceil(a/i),u=r<31?1<<r:Math.pow(2,r),d=Math.ceil((c*r-e)/8),h=new Uint8Array(d+1),l=0,f=0,p=0;if(o)for(let m=0;m<a;m+=i){let g=n[m];if(g<0||g>=s)throw new Error(`[BitPack decode] Invalid index ${g} at position ${m}`);for(f=f<<r|g,p+=r,m+i>=a&&e>0&&(f>>=e,p-=e);p>=8;)p-=8,h[l++]=f>>p&255,f&=(1<<p)-1;}else for(let m=0;m<a;m+=i){let g=n[m],y=n[m+1];if(g<0||g>=s)throw new Error(`[BitPack decode] Invalid index ${g} at position ${m}`);if(y===void 0||y<0||y>=s)throw new Error(`[BitPack decode] Invalid index ${y} at position ${m+1}`);let b=g*s+y;if(b>=u)throw new Error(`[BitPack decode] Value ${b} exceeds range at position ${m}`);for(f=f<<r|b,p+=r,m+i>=a&&e>0&&(f>>=e,p-=e);p>=8;)p-=8,h[l++]=f>>p&255,f&=(1<<p)-1;}return h.subarray(0,l)}var D="DDS1",P="ELYSIA",E="GRISEO";function X(n,e,t,r=2){let o=n.length,s=e.length,a={cleanedInput:n,paddingBits:0,isEncrypted:false,pipelineVersion:2};if(o<s)return a;let c=Math.max(0,t-1).toString().length;for(let u=Math.min(c,o);u>=1;u--){let d=o-u,h=true;for(let B=d;B<o;B++){let H=n.charCodeAt(B);if(H<48||H>57){h=false;break}}if(!h)continue;let l=n.substring(d),f=parseInt(l,10);if(Number.isNaN(f)||f<0||f>=t||l!==f.toString())continue;let p=d,m=false,g,y=2;p>=2&&n.substring(p-2,p)==="V3"&&(y=3,p-=2),p>=3&&n.substring(p-3,p)==="ENC"&&(m=true,p-=3),p>=P.length&&n.substring(p-P.length,p)===P?(g="deflate",p-=P.length):p>=E.length&&n.substring(p-E.length,p)===E&&(g="brotli",p-=E.length);let b=p-s;if(b>=0&&n.substring(b,p)===e)return {cleanedInput:n.substring(0,b),paddingBits:f,compressionAlgorithm:g,isEncrypted:m,pipelineVersion:y}}if(n.endsWith(e)){let u=0,d=o;for(;d>=s&&n.substring(d-s,d)===e;)u++,d-=s;if(u>0){let h=u*r;if(h<t)return {cleanedInput:n.substring(0,d),paddingBits:h,isEncrypted:false,pipelineVersion:2}}}return a}function Z(n){let e=n.lastIndexOf("CHK");if(e===-1)return {data:n,checksum:null};let t=n.slice(e+3);return t.length!==8||!/^[0-9a-f]+$/i.test(t)?{data:n,checksum:null}:{data:n.slice(0,e),checksum:t.toLowerCase()}}function fe(n){return n.length*2+D.length+2}function Fe(n,e){let t=e.compressionAlgorithm==="brotli"?"B":e.compressionAlgorithm==="deflate"?"D":"N",r=e.encrypted?"1":"0";return `${n}${D}${t}${r}${n}`}function qe(n,e){let t=fe(e);if(n.length<t||!n.startsWith(e))return null;let r=e.length;if(n.slice(r,r+D.length)!==D)throw new Error("[wireFormat] Invalid stream header magic");let s=n[r+D.length],a=n[r+D.length+1];if(n.slice(t-e.length,t)!==e)throw new Error("[wireFormat] Invalid stream header terminator");let c=s==="B"?"brotli":s==="D"?"deflate":s==="N"?void 0:null;if(c===null)throw new Error("[wireFormat] Invalid stream header compression flag");if(a!=="0"&&a!=="1")throw new Error("[wireFormat] Invalid stream header encryption flag");return {compressionAlgorithm:c,encrypted:a==="1"}}function J(n){let{paddingBits:e,compressionAlgorithm:t,isEncrypted:r,paddingChar:o,useRepeatPadding:s,bitsPerPadChar:a=2,pipelineVersion:i=2}=n;if(e===0&&!t&&!r&&i===2)return "";if(s&&!t&&!r&&i===2&&e>0&&e%a===0){let u=e/a;return o.repeat(u)}return o+(t==="deflate"?P:t==="brotli"?E:"")+(r?"ENC":"")+(i===3?"V3":"")+e.toString()}var pe=(()=>{let n=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let r=0;r<8;r++)t=t>>>1^(t&1?3988292384:0);n[e]=t;}return n})();function v(n){let e=4294967295;for(let t=0;t<n.length;t++)e=e>>>8^pe[(e^n[t])&255];return ((e^4294967295)>>>0).toString(16).padStart(8,"0")}var Q=["-","_","."];function ee(n){return n.length===0?n:n.replaceAll("+","-").replaceAll("/","_").replaceAll("=",".")}function te(n){return n.length===0?n:n.replaceAll("-","+").replaceAll("_","/").replaceAll(".","=")}function re(n,e,t){if(e<=0||n.length<=e)return n;let r=Math.ceil(n.length/e),o=new Array(r*2-1),s=0;for(let a=0;a<n.length;a+=e)o[s++]=n.slice(a,a+e),a+e<n.length&&(o[s++]=t);return o.join("")}function ne(n,e){if(n.length===0)return n;let t=n.replace(/[\r\n]/g,""),r=e&&e!==`
2
- `&&e!==`\r
3
- `&&e!=="\r"?e:"";return r.length>0&&t.includes(r)&&(t=t.replaceAll(r,"")),t}var me={"":0,\u3131:1,\u3132:2,\u3133:3,\u3134:4,\u3135:5,\u3136:6,\u3137:7,\u3139:8,\u313A:9,\u313B:10,\u313C:11,\u313D:12,\u313E:13,\u313F:14,\u3140:15,\u3141:16,\u3142:17,\u3144:18,\u3145:19,\u3146:20,\u3147:21,\u3148:22,\u314A:23,\u314B:24,\u314C:25,\u314D:26,\u314E:27};function ge(n,e){let t=n.charCodeAt(0);if(t<44032||t>55203)return n;let r=t-(t-44032)%28,o=me[e]??0;return String.fromCharCode(r+o)}function U(n,e){let t=new Array(n.length*e.length),r=0;for(let o of n)for(let s of e)t[r++]=ge(o,s);return t}function T(n,e){let r=n===void 0||!Number.isFinite(n)?6:Math.floor(n);return Math.min(e==="brotli"?11:9,Math.max(0,r))}var ye=new TextEncoder,be=new TextDecoder;function k(n){return ye.encode(n)}function I(n){return be.decode(n)}var Ce={symbol:"ddu",charSet:["\uB70C","\uB568","\uC774","\uC6B0","\uC57C","\uB4C0","\uB31C","\uB3A8"],codaChar:["","\u3131","\u3132","\u3137","\u3148","\u3147","\u3145","\u3146"],maxRequiredLength:64,bitLength:6,paddingChar:"\uBB50",useRepeatPadding:true},we={symbol:"ddu_v1",charSet:["\uB70C","\uB568","\uC774","\uC6B0","\uC57C","!","?","."],maxRequiredLength:8,bitLength:6,paddingChar:"\uBB50",useRepeatPadding:true,usePowerOfTwo:false,encodingProfile:{bitLength:6,usePowerOfTwo:false,bitsPerPadChar:2}},Se={symbol:"oneCharSet",charSet:["A","s","q","r","0","z","3","t","y","1","5","2","4","E","B","C","Q","F","R","T","U","W","V","X","Y","Z","b","a","c","d","D","G","L","H","I","-","J","K","M","O","N","f","e","h","g","P","i","S","k","l","m","u","j","v","n","o","p","9","w","6","7","8","x","_"],paddingChar:"=",maxRequiredLength:64,bitLength:6};function R(n){switch(n){case "ddu":return Ce;case "ddu_v1":return we;case "oneCharSet":return Se;default:return}}var Ae=65536;function oe(n,e,t,r){let o=(s,a,i,c,u)=>{if(Pe(i,t?.usePowerOfTwo)&&i>0){let l=Math.floor(Math.log2(i)),f=1<<l;return {charSet:s.length===f?s:s.slice(0,f),padding:a,requiredLength:f,bitLength:l,isPredefined:c,useRepeatPadding:u}}return {charSet:s.length===i?s:s.slice(0,i),padding:a,requiredLength:i,bitLength:i>0?Math.ceil(Math.log2(i)):0,isPredefined:c,useRepeatPadding:u}};try{let s=n??t?.dduChar,a=e??t?.paddingChar;if(s){if(!a)throw new Error("[Ddu64 Constructor] paddingChar is required when dduChar is provided.");let l=typeof s=="string"?[...s]:[...s],f=t?.codaChar,p=f?!0:t?.useRepeatPadding??!1;if(f&&f.length>0&&(l=U(l,f)),r&&new Set(l).size!==l.length){let y=l.filter((b,B)=>l.indexOf(b)!==B);throw new Error(`[Ddu64 Constructor] Character set contains duplicate characters: [${[...new Set(y)].join(", ")}]`)}let m=t?.requiredLength??l.length;if(l.length<m)throw new Error("[Ddu64 Constructor] Insufficient characters.");return o(l,a,m,!1,p)}let i=t?.dduSetSymbol??_.dduSetSymbol??"ddu",c=Ee(i),u=c.codaChar?U(c.charSet,c.codaChar):c.charSet,d=o(u,c.paddingChar,c.maxRequiredLength,!0,c.useRepeatPadding),h=c.encodingProfile;return h?(d.encodingProfile=h,d.bitLength=h.bitLength,d.usePowerOfTwo=h.usePowerOfTwo,d.bitsPerPadChar=h.bitsPerPadChar):(d.bitsPerPadChar=c.bitsPerPadChar,d.usePowerOfTwo=c.usePowerOfTwo,c.usePowerOfTwo===!1&&(d.bitLength=c.bitLength)),d}catch(s){if(r)throw s;return K(t)}}function se(n,e,t){let r=[n,null];for(let s of r){let a=s?{...s}:K(t);try{let i=a.charSet,c=a.requiredLength,u=Array.from(new Set(i));if(u.length!==i.length){if(e){let l=i.filter((f,p)=>i.indexOf(f)!==p);throw new Error(`[Ddu64 normalizeCharSet] Character set contains duplicate characters: [${[...new Set(l)].join(", ")}]`)}i=u,a.isPredefined||(c=i.length);}if(i.length<c)throw new Error(`[Ddu64 normalizeCharSet] Insufficient characters. Required: ${c}, Has: ${i.length}`);if(c<2)throw new Error("[Ddu64 normalizeCharSet] At least 2 unique characters required.");if(i.length===0)throw new Error("[Ddu64 normalizeCharSet] Empty charset.");if(i.find(l=>l.length!==1)){if(e)throw new Error("[Ddu64 normalizeCharSet] Multi-character symbols are not supported.");continue}if(i.length>Ae){if(e)throw new Error("[Ddu64 normalizeCharSet] Charset size exceeds maximum supported size of 65536.");continue}if(a.padding.length!==1)throw new Error(`[Ddu64 normalizeCharSet] Padding length mismatch. Expected 1, got ${a.padding.length}`);if(i.includes(a.padding)){if(e)throw new Error(`[Ddu64 normalizeCharSet] Padding character "${a.padding}" conflicts with charset.`);i=i.filter(l=>l!==a.padding);}for(let l of i)if(l.includes(`
4
- `)||l.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(a.padding.includes(`
5
- `)||a.padding.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");return {charSet:i.length===c?i:i.slice(0,c),padding:a.padding,isPredefined:a.isPredefined}}catch(i){if(e)throw i}}let o=K(t);return {charSet:o.charSet.slice(0,o.requiredLength),padding:o.padding,isPredefined:true}}function ie(n,e,t){for(let r of Q){for(let o of n)if(o.includes(r)){let s=`[Ddu64 Constructor] URL-Safe mode conflict: charset character "${o}" contains "${r}".`;if(t)throw new Error(s);return false}if(e.includes(r)){let o=`[Ddu64 Constructor] URL-Safe mode conflict: padding character "${e}" contains "${r}".`;if(t)throw new Error(o);return false}}return true}function ae(n,e,t){if(t>256)return;let r=Math.min(n.length,t),o=n.slice(0,r),s=new Set;for(let i=0;i<o.length;i++)s.add(o[i]);s.add(e);for(let i=0;i<o.length;i++){let c=o[i];for(let h=0;h<o.length;h++){let l=c+o[h];if(s.has(l))throw new Error(`Combination conflict: "${c}" + "${o[h]}"`);s.add(l);}let u=c+e;if(s.has(u))throw new Error(`Combination conflict: "${c}" + padding`);s.add(u);let d=e+c;if(s.has(d))throw new Error(`Combination conflict: padding + "${c}"`);s.add(d);}let a=e+e;if(s.has(a))throw new Error("Combination conflict: double padding");s.add(a);}function Pe(n,e){return e!==void 0?e?n>0:false:n>0&&(n&n-1)===0}function Ee(n){let e=R(n);if(!e)throw new Error(`CharSet with symbol ${n} not found`);return e}function K(n){let e=n?.dduSetSymbol??_.dduSetSymbol??"oneCharSet",t=R(e)??R("oneCharSet");if(!t)throw new Error("Critical: No fallback CharSet available");return {charSet:t.codaChar?U(t.charSet,t.codaChar):t.charSet,padding:t.paddingChar,requiredLength:t.maxRequiredLength,bitLength:t.encodingProfile?.bitLength??t.bitLength,isPredefined:true,useRepeatPadding:t.useRepeatPadding,bitsPerPadChar:t.encodingProfile?.bitsPerPadChar??t.bitsPerPadChar,usePowerOfTwo:t.encodingProfile?.usePowerOfTwo??t.usePowerOfTwo,encodingProfile:t.encodingProfile}}var ve=8,Ue=4096,S=8192,Te=1<<20,ke=64*1024*1024,Re=64*1024*1024,_e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",N="=",ce=class{dduChar;dduCharCodes;paddingChar;bitLength;usePowerOfTwo;dduCharCodeLookup;isPredefinedCharSet;defaultCompress;defaultMaxDecodedBytes;defaultMaxDecompressedBytes;urlSafe;encryptionKey;keyDerivation;encryptionKeyHash;defaultChecksum;defaultChunkSize;defaultChunkSeparator;defaultCompressionLevel;defaultCompressionAlgorithm;useRepeatPadding;bitsPerPadChar;bitPackConfig;wasmThreshold;canUseNativeBase64;adapter;defaultObfuscate;_obfuscationLayer;constructor(e,t,r){e!=null&&typeof e=="object"&&!Array.isArray(e)&&(r=e,e=void 0,t=void 0);let o=r?.throwOnError??r?.useBuildErrorReturn??false;r?.adapter?this.adapter=r.adapter:this.adapter=void 0;let s=oe(e,t,r,o),a=se(s,o,r);this.dduChar=a.charSet,this.paddingChar=a.padding,this.isPredefinedCharSet=a.isPredefined,this.defaultCompress=r?.compress??false,this.defaultMaxDecodedBytes=this.normalizeLimit(r?.maxDecodedBytes,ke,o,"maxDecodedBytes"),this.defaultMaxDecompressedBytes=this.normalizeLimit(r?.maxDecompressedBytes,Re,o,"maxDecompressedBytes");let i=this.dduChar.length,c=i>0&&(i&i-1)===0,u=r?.usePowerOfTwo,d=s.encodingProfile;this.usePowerOfTwo=d?.usePowerOfTwo??s.usePowerOfTwo??(u!==void 0?u&&c:c);let h=d?.bitLength??(s.isPredefined&&s.usePowerOfTwo!==void 0?s.bitLength:void 0);this.bitLength=h??(this.usePowerOfTwo?Math.floor(Math.log2(i)):Math.ceil(Math.log2(i))),this.dduCharCodeLookup=new Int32Array(65536),this.dduCharCodeLookup.fill(-1);for(let f=0;f<i;f++){let p=this.dduChar[f];this.dduCharCodeLookup[p.charCodeAt(0)]=f;}this.dduCharCodes=new Uint16Array(i);for(let f=0;f<i;f++)this.dduCharCodes[f]=this.dduChar[f].charCodeAt(0);this.isPredefinedCharSet||ae(this.dduChar,this.paddingChar,i);let l=r?.urlSafe??false;if(this.urlSafe=l?ie(this.dduChar,this.paddingChar,o):false,this.encryptionKey=r?.encryptionKey,this.keyDerivation=r?.keyDerivation,this.encryptionKey&&this.adapter?.deriveKeySync&&(this.encryptionKeyHash=this.adapter.deriveKeySync(this.encryptionKey,this.keyDerivation)),this.defaultChecksum=r?.checksum??false,this.defaultChunkSize=r?.chunkSize,this.defaultChunkSeparator=r?.chunkSeparator??`
6
- `,this.defaultCompressionAlgorithm=r?.compressionAlgorithm??"deflate",this.defaultCompressionLevel=T(r?.compressionLevel,this.defaultCompressionAlgorithm),this.useRepeatPadding=r?.useRepeatPadding??s.useRepeatPadding??false,this.bitsPerPadChar=d?.bitsPerPadChar??s.bitsPerPadChar??2,this.defaultObfuscate=r?.obfuscate??false,this.defaultObfuscate&&!this.encryptionKey)throw new Error("[Ddu64 obfuscation] Obfuscation requires encryption to be enabled.");this.bitPackConfig={bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,charsetSize:i},this.wasmThreshold=V(r?.wasmThreshold??4096),this.canUseNativeBase64=this.usePowerOfTwo&&this.bitLength===6&&this.paddingChar===N&&this.dduChar.join("")===_e;}encode(e,t){return this.encodeInternal(e,t).encoded}decode(e,t){let r=this.decodeToUint8Array(e,t);return I(r)}decodeToUint8Array(e,t){let r=this.decodePrelude(e,t),{extractedChecksum:o,compressionAlgorithm:s,isEncrypted:a,pipelineVersion:i}=r,{allowInternalDecompress:c,allowInternalDecrypt:u}=r,d=r.decoded;if(i===3&&a&&this.encryptionKey&&u&&(this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:55,stage:"decrypt"}),d=this.decryptSync(d)),this.shouldDecompress(s,c,a,i,u)){let h=this.normalizeLimit(t?.maxDecompressedBytes,this.defaultMaxDecompressedBytes,true,"maxDecompressedBytes");this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:70,stage:"decompress"}),d=this.decompressSync(d,s,h);}return this.verifyDecodedChecksum(d,o,a,i,u,t),i===2&&a&&this.encryptionKey&&u&&(this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:90,stage:"decrypt"}),d=this.decryptSync(d)),this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:100,stage:"done"}),d}async encodeAsync(e,t){let{shouldCompress:r,shouldChecksum:o,shouldEncrypt:s,chunkSize:a,chunkSeparator:i}=this.resolveEncodeSettings(t),c=typeof e=="string"?k(e):e;this.reportProgress(t,{processedBytes:0,totalBytes:c.length,percent:0,stage:"start"});let u="";o&&(u=v(c));let d;if(r){let l=t?.compressionAlgorithm??this.defaultCompressionAlgorithm,f=T(t?.compressionLevel??this.defaultCompressionLevel,l),p=await this.getAdapterAsync();this.reportProgress(t,{processedBytes:c.length,totalBytes:c.length,percent:20,stage:"compress"});let m;if(l==="brotli"){if(!p.brotliCompress)throw new Error("[Ddu64 compress] Brotli compression is unavailable in the current runtime.");m=await p.brotliCompress(c,f);}else m=await p.deflate(c,f);m.length<c.length&&(c=m,d=l);}let h=false;if(s){let l=await this.getAdapterAsync(),f=await this.getKeyHashAsync(l);this.reportProgress(t,{processedBytes:c.length,totalBytes:c.length,percent:45,stage:"encrypt"}),c=await l.encrypt(c,f),h=true;}return this.finalizeEncode(c,d,h,u,o,a,i,t)}async decodeAsync(e,t){let r=await this.decodeToUint8ArrayAsync(e,t);return I(r)}async decodeToUint8ArrayAsync(e,t){let r=this.decodePrelude(e,t),{extractedChecksum:o,compressionAlgorithm:s,isEncrypted:a,pipelineVersion:i}=r,{allowInternalDecompress:c,allowInternalDecrypt:u}=r,d=r.decoded;if(i===3&&a&&this.encryptionKey&&u){let h=await this.getAdapterAsync(),l=await this.getKeyHashAsync(h);this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:55,stage:"decrypt"}),d=await h.decrypt(d,l);}if(this.shouldDecompress(s,c,a,i,u)){let h=this.normalizeLimit(t?.maxDecompressedBytes,this.defaultMaxDecompressedBytes,true,"maxDecompressedBytes"),l=await this.getAdapterAsync();if(this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:70,stage:"decompress"}),s==="brotli"){if(!l.brotliDecompress)throw new Error("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.");d=await l.brotliDecompress(d,h);}else d=await l.inflate(d,h);}if(this.verifyDecodedChecksum(d,o,a,i,u,t),i===2&&a&&this.encryptionKey&&u){let h=await this.getAdapterAsync(),l=await this.getKeyHashAsync(h);this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:90,stage:"decrypt"}),d=await h.decrypt(d,l);}return this.reportProgress(t,{processedBytes:d.length,totalBytes:d.length,percent:100,stage:"done"}),d}getCharSetInfo(){return {charSet:[...this.dduChar],paddingChar:this.paddingChar,bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,encoding:"utf-8",defaultCompress:this.defaultCompress,defaultMaxDecodedBytes:this.defaultMaxDecodedBytes,defaultMaxDecompressedBytes:this.defaultMaxDecompressedBytes,urlSafe:this.urlSafe,hasEncryptionKey:!!this.encryptionKey,defaultChecksum:this.defaultChecksum,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm}}getStats(e,t){let o=(typeof e=="string"?k(e):e).length,{encoded:s,compressedSize:a}=this.encodeInternal(e,t),i=s.length,c=o>0?i/o:0,d=(t?.compress??this.defaultCompress)&&a!==void 0&&o>0?a/o:void 0;return {originalSize:o,encodedSize:i,compressedSize:a,compressionRatio:d,expansionRatio:c,charsetSize:this.dduChar.length,bitLength:this.bitLength}}encodeInternal(e,t){let{shouldCompress:r,shouldChecksum:o,shouldEncrypt:s,chunkSize:a,chunkSeparator:i}=this.resolveEncodeSettings(t),c=typeof e=="string"?k(e):e;this.reportProgress(t,{processedBytes:0,totalBytes:c.length,percent:0,stage:"start"});let u="";o&&(u=v(c));let d,h;if(r){let p=t?.compressionAlgorithm??this.defaultCompressionAlgorithm,m=T(t?.compressionLevel??this.defaultCompressionLevel,p);this.reportProgress(t,{processedBytes:c.length,totalBytes:c.length,percent:20,stage:"compress"});let g=this.compressSync(c,p,m);h=g.length,g.length<c.length&&(c=g,d=p);}let l=false;return s&&(this.reportProgress(t,{processedBytes:c.length,totalBytes:c.length,percent:45,stage:"encrypt"}),c=this.encryptSync(c),l=true),{encoded:this.finalizeEncode(c,d,l,u,o,a,i,t),compressedSize:h}}resolveEncodeSettings(e){return {shouldCompress:e?.compress??this.defaultCompress,shouldChecksum:e?.checksum??this.defaultChecksum,shouldEncrypt:(e?.encrypt??true)&&!!this.encryptionKey,chunkSize:e?.chunkSize??this.defaultChunkSize,chunkSeparator:e?.chunkSeparator??this.defaultChunkSeparator}}finalizeEncode(e,t,r,o,s,a,i,c){this.reportProgress(c,{processedBytes:e.length,totalBytes:e.length,percent:70,stage:"encode"});let u=this.encodeBytes(e,t,r,c);return u=this.applyPostEncoding(u,c,o,s,a,i),this.reportProgress(c,{processedBytes:e.length,totalBytes:e.length,percent:100,stage:"done"}),u}applyPostEncoding(e,t,r,o,s,a){let i=e;return this.shouldObfuscate(t)&&(i=this.getObfuscationLayer().obfuscate(i)),o&&r&&(i=i+"CHK"+r),this.urlSafe&&(i=ee(i)),s&&s>0&&(this.assertSafeChunkSeparator(i,a),i=re(i,s,a)),i}encodeBytes(e,t,r,o){if(e.length===0)return "";let s=this.encodeBytesWithNativeBase64(e),a,i;if(s)a=s.paddingBits,i=s.payload;else {let u,d=this.shouldUseWasm(e.length)?O():null;if(d?.ready&&this.usePowerOfTwo){let l=d.encode(e,this.bitLength);u=l.indices,a=l.paddingBits;}else {let l=G(e,this.bitPackConfig);u=l.indices,a=l.paddingBits;}let h=u.length;if(h<=Te){let l=new Uint16Array(h);for(let f=0;f<h;f++)l[f]=this.dduCharCodes[u[f]];if(h<=S)i=String.fromCharCode.apply(null,l);else {let f=new Array(Math.ceil(h/S)),p=0;for(let m=0;m<h;m+=S){let g=l.subarray(m,Math.min(m+S,h));f[p++]=String.fromCharCode.apply(null,g);}i=f.join("");}}else {let l=new Uint16Array(S),f=new Array(Math.ceil(h/S)),p=0;for(let m=0;m<h;m+=S){let g=Math.min(S,h-m);for(let b=0;b<g;b++)l[b]=this.dduCharCodes[u[m+b]];let y=g===l.length?l:l.subarray(0,g);f[p++]=String.fromCharCode.apply(null,y);}i=f.join("");}}let c=o?.omitFooter?"":J({paddingBits:a,compressionAlgorithm:t,isEncrypted:!!r,paddingChar:this.paddingChar,useRepeatPadding:this.useRepeatPadding&&!t&&!r,bitsPerPadChar:this.bitsPerPadChar,pipelineVersion:r?3:2});return i+c}decodePrelude(e,t){let r=t?.checksum??this.defaultChecksum,o=t?.compress!==false,s=t?.encrypt!==false,a=e;this.reportProgress(t,{processedBytes:0,totalBytes:e.length,percent:0,stage:"start"});let i=t?.chunkSeparator??this.defaultChunkSeparator;a=ne(a,i),this.urlSafe&&(a=te(a));let c=null;if(r){let y=Z(a);c=y.checksum,a=y.data;}this.shouldObfuscate(t)&&(a=this.getObfuscationLayer().deobfuscate(a));let{cleanedInput:u,paddingBits:d,compressionAlgorithm:h,isEncrypted:l,pipelineVersion:f}=X(a,this.paddingChar,this.bitLength,this.bitsPerPadChar);if(l&&s&&!this.encryptionKey)throw new Error("[Ddu64 decode] Encrypted payload requires an encryptionKey");this.assertEncodedInputAligned(u),this.assertCanonicalPadding(u,d);let p=this.normalizeLimit(t?.maxDecodedBytes,this.defaultMaxDecodedBytes,true,"maxDecodedBytes"),m=this.estimateDecodedBytes(u.length,d);if(m>p)throw new Error(`[Ddu64 decode] Decoded output exceeds limit. Estimated: ${m} bytes, Limit: ${p} bytes`);return this.reportProgress(t,{processedBytes:u.length,totalBytes:e.length,percent:30,stage:"decode"}),{decoded:this.decodeChars(u,d),extractedChecksum:c,compressionAlgorithm:h,isEncrypted:l,pipelineVersion:f,allowInternalDecompress:o,allowInternalDecrypt:s}}shouldDecompress(e,t,r,o,s){return !!e&&t&&(o===2||!r||s)}verifyDecodedChecksum(e,t,r,o,s,a){if(!t||!(o===2||!r||s))return;this.reportProgress(a,{processedBytes:e.length,totalBytes:e.length,percent:85,stage:"checksum"});let i=v(e);if(i!==t)throw new Error(`[Ddu64 decode] Checksum mismatch. Expected: ${t}, Got: ${i}`)}decodeChars(e,t){let r=e.length;if(r===0)return new Uint8Array(0);let o=this.decodeCharsWithNativeBase64(e,t);if(o)return o;let s=r>=this.wasmThreshold||r>=Ue?new Uint16Array(r):new Array(r);for(let i=0;i<r;i++){let c=this.dduCharCodeLookup[e.charCodeAt(i)];if(c<0)throw new Error(`[Ddu64 decode] Invalid character "${e[i]}" at ${i}`);s[i]=c;}let a=this.shouldUseWasm(r)?O():null;if(a?.ready&&this.usePowerOfTwo){let i=s instanceof Uint16Array?s:Uint16Array.from(s);return a.decode(i,this.bitLength,t)}return j(s,t,this.bitPackConfig)}encodeBytesWithNativeBase64(e){if(!this.canUseNativeBase64)return null;let t=this.bytesToBase64(e);if(t===null)return null;let r=0,o=t.length;for(;o>0&&t[o-1]===N;)r++,o--;return {payload:t.slice(0,o),paddingBits:r===2?4:r===1?2:0}}decodeCharsWithNativeBase64(e,t){if(!this.canUseNativeBase64)return null;let r=t===4?2:t===2?1:t===0?0:-1;if(r<0)return null;for(let o=0;o<e.length;o++)if(this.dduCharCodeLookup[e.charCodeAt(o)]<0)return null;return this.base64ToBytes(e+N.repeat(r))}bytesToBase64(e){let t=e.toBase64;if(typeof t=="function")return t.call(e);let r=globalThis.Buffer;return r?.from?r.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"):null}base64ToBytes(e){let t=Uint8Array;if(typeof t.fromBase64=="function")return t.fromBase64(e);let r=globalThis.Buffer;if(r?.from){let o=r.from(e,"base64");return new Uint8Array(o.buffer,o.byteOffset,o.byteLength)}return null}shouldUseWasm(e){return e>=this.wasmThreshold}reportProgress(e,t){e?.onProgress?.(t);}requireSyncAdapter(){if(!this.adapter)throw new Error("[Ddu64 adapter] No platform adapter available. Use encodeAsync()/decodeAsync() in browser environments, or provide an adapter via options.adapter.");return this.adapter}encryptSync(e){let t=this.requireSyncAdapter();if(!t.encryptSync)throw new Error("[Ddu64 encrypt] Sync encryption unavailable. Use encodeAsync() in browser environments.");if(!this.encryptionKeyHash){if(!t.deriveKeySync)throw new Error("[Ddu64 encrypt] Sync key derivation unavailable. Use encodeAsync() in browser environments.");this.encryptionKeyHash=t.deriveKeySync(this.encryptionKey,this.keyDerivation);}return t.encryptSync(e,this.encryptionKeyHash)}decryptSync(e){let t=this.requireSyncAdapter();if(!t.decryptSync)throw new Error("[Ddu64 decrypt] Sync decryption unavailable. Use decodeAsync() in browser environments.");if(!this.encryptionKeyHash){if(!t.deriveKeySync)throw new Error("[Ddu64 decrypt] Sync key derivation unavailable. Use decodeAsync() in browser environments.");this.encryptionKeyHash=t.deriveKeySync(this.encryptionKey,this.keyDerivation);}return t.decryptSync(e,this.encryptionKeyHash)}compressSync(e,t,r){let o=this.requireSyncAdapter();if(t==="brotli"){if(!o.brotliCompressSync)throw new Error("[Ddu64 compress] Brotli compression is unavailable in the current runtime.");return o.brotliCompressSync(e,r)}if(!o.deflateSync)throw new Error("[Ddu64 compress] Sync compression unavailable. Use encodeAsync() in browser environments.");return o.deflateSync(e,r)}decompressSync(e,t,r){let o=this.requireSyncAdapter();if(t==="brotli"){if(!o.brotliDecompressSync)throw new Error("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.");return o.brotliDecompressSync(e,r)}if(!o.inflateSync)throw new Error("[Ddu64 decompress] Sync decompression unavailable. Use decodeAsync() in browser environments.");return o.inflateSync(e,r)}async getAdapterAsync(){if(this.adapter)return this.adapter;throw new Error("[Ddu64 adapter] No platform adapter available. Use @ddunigma/node or @ddunigma/node/browser, or provide an adapter via options.adapter.")}async getKeyHashAsync(e){return this.encryptionKeyHash?this.encryptionKeyHash:(this.encryptionKeyHash=await e.deriveKey(this.encryptionKey,this.keyDerivation),this.encryptionKeyHash)}getObfuscationLayer(){if(!this._obfuscationLayer){let e=new Set(this.dduChar);e.add(this.paddingChar);let t=P+E+"ENC"+"V3";for(let o of t)e.add(o);for(let o of "0123456789")e.add(o);let r=[...e];this._obfuscationLayer=new L(r);}return this._obfuscationLayer}shouldObfuscate(e){let t=e?.obfuscate??this.defaultObfuscate;if(t&&!this.encryptionKey)throw new Error("[Ddu64 obfuscation] Obfuscation requires encryption to be enabled.");return t}normalizeLimit(e,t,r,o){if(e===void 0)return t;if(e===Number.POSITIVE_INFINITY)return Number.POSITIVE_INFINITY;if(!Number.isFinite(e)||e<=0){if(r)throw new Error(`[Ddu64 options] Invalid ${o}. Must be a positive finite number or Infinity.`);return t}return Math.floor(e)}assertSafeChunkSeparator(e,t){if(!(t.length===0||this.isLineBreakSeparator(t))&&e.includes(t))throw new Error(`[Ddu64 chunking] Unsafe chunkSeparator "${t}" appears in encoded output. Use a separator that cannot be produced by the charset, footer, checksum, or URL-safe output.`)}isLineBreakSeparator(e){return e===`
7
- `||e===`\r
8
- `||e==="\r"}estimateDecodedBytes(e,t){if(e===0)return 0;if(t<0||t>=this.bitLength)throw new Error(`[Ddu64 decode] Invalid padding bits: ${t}`);let r=this.usePowerOfTwo?1:2,s=Math.ceil(e/r)*this.bitLength-t;if(s<0)throw new Error("[Ddu64 decode] Invalid decoded bit length");return Math.ceil(s/ve)}assertEncodedInputAligned(e){if(!this.usePowerOfTwo&&e.length%2!==0)throw new Error(`[Ddu64 decode] Invalid encoded length for variable charset. Expected multiple of 2, got ${e.length}`)}assertCanonicalPadding(e,t){if(t===0)return;if(e.length===0)throw new Error("[Ddu64 decode] Invalid padding bits without payload");let r=(1<<t)-1,o;if(this.usePowerOfTwo){let s=e[e.length-1],a=this.dduCharCodeLookup[s.charCodeAt(0)];if(a<0)throw new Error(`[Ddu64 decode] Invalid character "${s}" at ${e.length-1}`);o=a;}else {let s=e[e.length-2],a=e[e.length-1],i=this.dduCharCodeLookup[s.charCodeAt(0)],c=this.dduCharCodeLookup[a.charCodeAt(0)];if(i<0||c<0)throw new Error("[Ddu64 decode] Invalid character in final encoded chunk");o=i*this.dduChar.length+c;}if((o&r)!==0)throw new Error("[Ddu64 decode] Invalid non-zero padding bits in final symbol")}};var de=class n{chars=[];constructor(){}static create(){return new n}static fromUnicodeRange(e,t){return new n().addUnicodeRange(e,t)}static fromString(e){return new n().addString(e)}static base64(){return new n().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")}static base32(){return new n().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")}static uppercase(){return n.fromUnicodeRange(65,90)}static lowercase(){return n.fromUnicodeRange(97,122)}static digits(){return n.fromUnicodeRange(48,57)}static hangulJamo(){return new n().addUnicodeRange(4352,4370).addUnicodeRange(4449,4469).addUnicodeRange(4520,4546)}addUnicodeRange(e,t){for(let r=e;r<=t;r++)this.chars.push(String.fromCodePoint(r));return this}addString(e){return typeof e=="string"?this.chars.push(...e):this.chars.push(...e),this}add(...e){return this.chars.push(...e),this}excludeConfusing(){let e=new Set(["0","O","o","1","l","I","i","|","L"]);return this.chars=this.chars.filter(t=>!e.has(t)),this}exclude(...e){let t=new Set(e);return this.chars=this.chars.filter(r=>!t.has(r)),this}excludeUrlUnsafe(){let e=new Set(["+","/","=","?","&","#","%"," "]);return this.chars=this.chars.filter(t=>!e.has(t)),this}unique(){return this.chars=[...new Set(this.chars)],this}shuffle(e){let t=e!==void 0?this.seededRandom(e):Math.random;for(let r=this.chars.length-1;r>0;r--){let o=Math.floor(t()*(r+1));[this.chars[r],this.chars[o]]=[this.chars[o],this.chars[r]];}return this}seededRandom(e){let t=e|0||1;return ()=>(t^=t<<13,t^=t>>17,t^=t<<5,(t>>>0)/4294967296)}limit(e){return this.chars=this.chars.slice(0,e),this}limitToPowerOfTwo(){let e=this.chars.length;if(e===0)return this;let t=1<<Math.floor(Math.log2(e));return this.chars=this.chars.slice(0,t),this}sort(){return this.chars.sort(),this}reverse(){return this.chars.reverse(),this}get length(){return this.chars.length}buildString(){return this.chars.join("")}build(){return [...this.chars]}buildWithPadding(e){let t=[...this.chars],r=e;if(!r){let o=["=",".","_","-","~","!"];for(let s of o)if(!t.includes(s)){r=s;break}if(!r)throw new Error("Cannot find suitable padding character")}return {charset:t,padding:r}}};export{fe as a,Fe as b,qe as c,z as d,L as e,Ke as f,He as g,ze as h,O as i,We as j,ce as k,de as l};//# sourceMappingURL=chunk-KEWLOPEV.js.map
9
- //# sourceMappingURL=chunk-KEWLOPEV.js.map
@@ -1,2 +0,0 @@
1
- import {d,a,b as b$1}from'./chunk-QR43FNIY.js';import {pbkdf2,pbkdf2Sync,createHash,randomBytes,createCipheriv,createDecipheriv}from'crypto';import {deflateRaw,inflateRaw,brotliCompress,brotliDecompress,deflateRawSync,inflateRawSync,constants,brotliCompressSync,brotliDecompressSync}from'zlib';import {promisify}from'util';var k=promisify(deflateRaw),U=promisify(inflateRaw),C=promisify(brotliCompress),b=promisify(brotliDecompress),N=promisify(pbkdf2);function v(i){let n=i,r=String(n?.message??"").toLowerCase();return String(n?.code??"")==="ERR_BUFFER_TOO_LARGE"||r.includes("output length")||r.includes("buffer too large")||r.includes("cannot create a buffer larger")}function u(i,n,r){throw v(i)?new Error(`[Ddu64 ${r}] Decompressed data exceeds limit. Limit: ${n} bytes`,{cause:i}):i}var w=class{supportsSyncCrypto=true;supportsSyncCompression=true;supportsBrotli=true;runtime="node";async deriveKey(n,r){if(r?.algorithm==="pbkdf2"){let t=await N(n,d(r.salt),a(r.iterations),32,b$1(r.hash));return new Uint8Array(t)}return this.deriveKeySync(n,r)}deriveKeySync(n,r){return r?.algorithm==="pbkdf2"?new Uint8Array(pbkdf2Sync(n,d(r.salt),a(r.iterations),32,b$1(r.hash))):new Uint8Array(createHash("sha256").update(n).digest())}async encrypt(n,r){return this.encryptSync(n,r)}encryptSync(n,r){let t=randomBytes(12),e=createCipheriv("aes-256-gcm",r,t),c=Buffer.concat([e.update(n),e.final()]),s=e.getAuthTag(),o=new Uint8Array(28+c.length);return o.set(t,0),o.set(s,12),o.set(c,28),o}async decrypt(n,r){return this.decryptSync(n,r)}decryptSync(n,r){if(n.length<28)throw new Error("[Ddu64 decrypt] Invalid encrypted data: too short");let t=n.subarray(0,12),e=n.subarray(12,28),c=n.subarray(28),s=createDecipheriv("aes-256-gcm",r,t);s.setAuthTag(e);let o=Buffer.concat([s.update(c),s.final()]);return new Uint8Array(o)}randomBytes(n){return new Uint8Array(randomBytes(n))}async deflate(n,r){let t={};r!==void 0&&(t.level=r);let e=await k(Buffer.from(n),t);return new Uint8Array(e)}deflateSync(n,r){let t={};return r!==void 0&&(t.level=r),new Uint8Array(deflateRawSync(Buffer.from(n),t))}async inflate(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY){let e=await U(Buffer.from(n));return new Uint8Array(e)}let t={maxOutputLength:r};try{let e=await U(Buffer.from(n),t);return new Uint8Array(e)}catch(e){u(e,r,"inflate");}}inflateSync(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY)return new Uint8Array(inflateRawSync(Buffer.from(n)));try{return new Uint8Array(inflateRawSync(Buffer.from(n),{maxOutputLength:r}))}catch(t){u(t,r,"inflate");}}async brotliCompress(n,r){let t={};r!==void 0&&(t.params={[constants.BROTLI_PARAM_QUALITY]:Math.max(0,Math.min(11,r))});let e=await C(Buffer.from(n),t);return new Uint8Array(e)}brotliCompressSync(n,r){let t={};return r!==void 0&&(t.params={[constants.BROTLI_PARAM_QUALITY]:Math.max(0,Math.min(11,r))}),new Uint8Array(brotliCompressSync(Buffer.from(n),t))}async brotliDecompress(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY){let t=await b(Buffer.from(n));return new Uint8Array(t)}try{let t=await b(Buffer.from(n),{maxOutputLength:r});return new Uint8Array(t)}catch(t){u(t,r,"brotli");}}brotliDecompressSync(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY)return new Uint8Array(brotliDecompressSync(Buffer.from(n)));try{return new Uint8Array(brotliDecompressSync(Buffer.from(n),{maxOutputLength:r}))}catch(t){u(t,r,"brotli");}}};export{w as a};//# sourceMappingURL=chunk-M6LY6DIE.js.map
2
- //# sourceMappingURL=chunk-M6LY6DIE.js.map
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkNY4FGVF3_cjs=require('./chunk-NY4FGVF3.cjs');var y=new Map;function m(r){if(r.buffer instanceof ArrayBuffer)return r.byteOffset===0&&r.byteLength===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);let e=new Uint8Array(r.byteLength);return e.set(r),e.buffer}function h(r){let e=y.get(r);if(e!==void 0)return e;if(typeof CompressionStream>"u"||typeof DecompressionStream>"u")return y.set(r,false),false;try{return new CompressionStream(r),new DecompressionStream(r),y.set(r,!0),!0}catch{return y.set(r,false),false}}function u(r,e){if(!h(r)){let n=r==="brotli"?"Brotli":"Deflate raw";throw new Error(`[Ddu64 ${e}] ${n} ${e}ion is unsupported in the current runtime. CompressionStream/DecompressionStream does not support "${r}".`)}return r}var w=class{supportsSyncCrypto=false;supportsSyncCompression=false;supportsBrotli=h("brotli");runtime="browser";async deriveKey(e,n){let t=new TextEncoder().encode(e);if(n?.algorithm==="pbkdf2"){let o=await crypto.subtle.importKey("raw",t,"PBKDF2",false,["deriveBits"]),i=await crypto.subtle.deriveBits({name:"PBKDF2",salt:chunkNY4FGVF3_cjs.d(n.salt),iterations:chunkNY4FGVF3_cjs.a(n.iterations),hash:chunkNY4FGVF3_cjs.c(n.hash)},o,256);return new Uint8Array(i)}let a=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(a)}async encrypt(e,n){let s=crypto.getRandomValues(new Uint8Array(12)),t=await crypto.subtle.importKey("raw",m(n),{name:"AES-GCM"},false,["encrypt"]),a=await crypto.subtle.encrypt({name:"AES-GCM",iv:s,tagLength:128},t,m(e)),o=new Uint8Array(a),i=o.slice(0,o.length-16),c=o.slice(o.length-16),p=new Uint8Array(28+i.length);return p.set(s,0),p.set(c,12),p.set(i,28),p}async decrypt(e,n){if(e.length<28)throw new Error("[Ddu64 decrypt] Encrypted data is invalid. Payload must be at least 28 bytes (12 IV + 16 authTag + ciphertext).");let s=e.slice(0,12),t=e.slice(12,28),a=e.slice(28),o=new Uint8Array(a.length+16);o.set(a,0),o.set(t,a.length);let i=await crypto.subtle.importKey("raw",m(n),{name:"AES-GCM"},false,["decrypt"]);try{let c=await crypto.subtle.decrypt({name:"AES-GCM",iv:s,tagLength:128},i,m(o));return new Uint8Array(c)}catch{throw new Error("[Ddu64 decrypt] Decryption failed: data tampering or incorrect key.")}}randomBytes(e){return crypto.getRandomValues(new Uint8Array(e))}async deflate(e,n){if(typeof CompressionStream>"u")throw new Error("[Ddu64 compress] Deflate compression is unsupported in the current runtime. CompressionStream API is not available.");let s=this.getDeflateFormat("compress"),t=new CompressionStream(s);return this.writeAndReadStream(t,e)}async inflate(e,n){if(typeof DecompressionStream>"u")throw new Error("[Ddu64 decompress] Deflate decompression is unsupported in the current runtime. DecompressionStream API is not available.");let s=this.getDeflateFormat("decompress"),t=new DecompressionStream(s);return this.writeAndReadStream(t,e,n)}async brotliCompress(e,n){let s=u("brotli","compress"),t=new CompressionStream(s);return this.writeAndReadStream(t,e)}async brotliDecompress(e,n){let s=u("brotli","decompress"),t=new DecompressionStream(s);return this.writeAndReadStream(t,e,n)}getDeflateFormat(e){return u("deflate-raw",e)}async writeAndReadStream(e,n,s){let t=e.writable.getWriter(),a=e.readable.getReader(),o=(async()=>{await t.write(new Uint8Array(m(n))),await t.close();})(),i=this.readAllChunks(a,s);try{let[c]=await Promise.all([i,o]);return c}catch(c){throw await a.cancel(c).catch(()=>{}),await t.abort(c).catch(()=>{}),c}}async readAllChunks(e,n){let s=[],t=0;for(;;){let{done:i,value:c}=await e.read();if(i)break;if(t+=c.length,n!==void 0&&t>n)throw new Error(`[Ddu64 decompress] Decompressed size exceeds limit. Estimated ${t}+ bytes exceeds maximum of ${n} bytes.`);s.push(c);}let a=new Uint8Array(t),o=0;for(let i of s)a.set(i,o),o+=i.length;return a}};exports.a=w;//# sourceMappingURL=chunk-NFMYVNOG.cjs.map
2
- //# sourceMappingURL=chunk-NFMYVNOG.cjs.map
@@ -1,2 +0,0 @@
1
- 'use strict';var n="ddunigma:pbkdf2:v1";function r(e){return e===void 0||!Number.isFinite(e)||e<=0?21e4:Math.max(1e4,Math.floor(e))}function o(e){return (e??"SHA-256").toLowerCase().replace("-","")}function t(e){return e??"SHA-256"}function i(e){return e===void 0?new TextEncoder().encode(n):typeof e=="string"?new TextEncoder().encode(e):e}exports.a=r;exports.b=o;exports.c=t;exports.d=i;//# sourceMappingURL=chunk-NY4FGVF3.cjs.map
2
- //# sourceMappingURL=chunk-NY4FGVF3.cjs.map
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkJZSHJ6KN_cjs=require('./chunk-JZSHJ6KN.cjs');function I(){let e=globalThis;if(e.Deno?.version?.deno)return "deno";if(e.Bun?.version)return "bun";if(e.process?.versions?.node)return "node";if(typeof e.crypto<"u"&&e.crypto?.subtle)return "browser";throw new Error("[ddunigma] No suitable crypto provider found. Detected runtime lacks both Node.js crypto module and Web Crypto API (SubtleCrypto).")}function v(e,n){let a=e.getCharSetInfo(),h=n?.compress??a.defaultCompress,p=(n?.encrypt??true)&&a.hasEncryptionKey,g=n?.checksum??a.defaultChecksum,r=h?n?.compressionAlgorithm??a.defaultCompressionAlgorithm:void 0,m=a.paddingChar,d=C(a,{compressed:h,encrypted:p,checksum:g}),y=false,u=[],s=0,o=null;return new TransformStream({async transform(t,c){if(d){if(!y){let k=chunkJZSHJ6KN_cjs.b(m,{compressionAlgorithm:void 0,encrypted:false});c.enqueue(k),y=true;}let i;o&&o.length>0?(i=new Uint8Array(o.length+t.length),i.set(o,0),i.set(t,o.length)):i=t;let l=a.bitLength,S=E(l,8)/8,f=Math.floor(i.length/S)*S;if(f>0){let k=i.subarray(0,f),D=await e.encodeAsync(k,{compress:false,encrypt:false,checksum:false,chunkSize:void 0,chunkSeparator:void 0,omitFooter:true});c.enqueue(D);}f<i.length?o=i.slice(f):o=null;}else u.push(t),s+=t.length;},async flush(t){try{if(d){if(!y){let c=chunkJZSHJ6KN_cjs.b(m,{compressionAlgorithm:void 0,encrypted:!1});t.enqueue(c);}if(o&&o.length>0){let c=await e.encodeAsync(o,{compress:!1,encrypt:!1,checksum:!1,chunkSize:void 0,chunkSeparator:void 0});t.enqueue(c);}o=null;}else {let c=chunkJZSHJ6KN_cjs.b(m,{compressionAlgorithm:r,encrypted:p});if(t.enqueue(c),s>0){let i=new Uint8Array(s),l=0;for(let f of u)i.set(f,l),l+=f.length;let S=await e.encodeAsync(i,{...n,compress:h,encrypt:p,checksum:g,chunkSize:void 0,chunkSeparator:void 0});t.enqueue(S);}u=[],s=0;}}catch(c){t.error(c instanceof Error?c:new Error(String(c)));}}})}function L(e,n){let a=e.getCharSetInfo(),h=a.paddingChar,p=chunkJZSHJ6KN_cjs.a(h),g=n?.checksum??a.defaultChecksum,r="",m=false,d=null,y=false;return new TransformStream({async transform(u,s){if(r+=u,!m&&r.length>=p){if(!r.startsWith(h)){s.error(new Error("[WebStreams decode] Invalid or missing stream header"));return}if(d=chunkJZSHJ6KN_cjs.c(r,h),d===null){s.error(new Error("[WebStreams decode] Invalid or missing stream header"));return}if(d.encrypted&&!a.hasEncryptionKey){s.error(new Error("[WebStreams decode] Encrypted stream requires an encryptionKey"));return}m=true,y=C(a,{compressed:!!d.compressionAlgorithm,encrypted:d.encrypted,checksum:g}),r=r.slice(p);}if(m&&y&&r.length>0){let o=a.bitLength,t=E(o,8)/o,c=Math.floor(r.length/t)*t;if(c>0){let i=r.slice(0,c);r=r.slice(c);try{let l=await e.decodeToUint8ArrayAsync(i,{compress:!1,encrypt:!1,checksum:!1,chunkSize:void 0,chunkSeparator:void 0});l.length>0&&s.enqueue(l);}catch{r=i+r;}}}},async flush(u){try{if(!m){if(r.length===0)return;u.error(new Error("[WebStreams decode] Incomplete stream header"));return}if(r.length===0)return;let s=d.compressionAlgorithm,o=d.encrypted,t=await e.decodeToUint8ArrayAsync(r,{...n,compress:!!s,compressionAlgorithm:s,encrypt:o,checksum:g,chunkSize:void 0,chunkSeparator:void 0});t.length>0&&u.enqueue(t),r="";}catch(s){u.error(s instanceof Error?s:new Error(String(s)));}}})}function C(e,n){return e.usePowerOfTwo&&!n.compressed&&!n.encrypted&&!n.checksum}function E(e,n){return e*n/U(e,n)}function U(e,n){for(;n!==0;){let a=n;n=e%n,e=a;}return e}exports.a=I;exports.b=v;exports.c=L;//# sourceMappingURL=chunk-PHMARSJE.cjs.map
2
- //# sourceMappingURL=chunk-PHMARSJE.cjs.map
@@ -1,2 +0,0 @@
1
- var n="ddunigma:pbkdf2:v1";function r(e){return e===void 0||!Number.isFinite(e)||e<=0?21e4:Math.max(1e4,Math.floor(e))}function o(e){return (e??"SHA-256").toLowerCase().replace("-","")}function t(e){return e??"SHA-256"}function i(e){return e===void 0?new TextEncoder().encode(n):typeof e=="string"?new TextEncoder().encode(e):e}export{r as a,o as b,t as c,i as d};//# sourceMappingURL=chunk-QR43FNIY.js.map
2
- //# sourceMappingURL=chunk-QR43FNIY.js.map
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkNY4FGVF3_cjs=require('./chunk-NY4FGVF3.cjs'),crypto=require('crypto'),zlib=require('zlib'),util=require('util');var k=util.promisify(zlib.deflateRaw),U=util.promisify(zlib.inflateRaw),C=util.promisify(zlib.brotliCompress),b=util.promisify(zlib.brotliDecompress),N=util.promisify(crypto.pbkdf2);function v(i){let n=i,r=String(n?.message??"").toLowerCase();return String(n?.code??"")==="ERR_BUFFER_TOO_LARGE"||r.includes("output length")||r.includes("buffer too large")||r.includes("cannot create a buffer larger")}function u(i,n,r){throw v(i)?new Error(`[Ddu64 ${r}] Decompressed data exceeds limit. Limit: ${n} bytes`,{cause:i}):i}var w=class{supportsSyncCrypto=true;supportsSyncCompression=true;supportsBrotli=true;runtime="node";async deriveKey(n,r){if(r?.algorithm==="pbkdf2"){let t=await N(n,chunkNY4FGVF3_cjs.d(r.salt),chunkNY4FGVF3_cjs.a(r.iterations),32,chunkNY4FGVF3_cjs.b(r.hash));return new Uint8Array(t)}return this.deriveKeySync(n,r)}deriveKeySync(n,r){return r?.algorithm==="pbkdf2"?new Uint8Array(crypto.pbkdf2Sync(n,chunkNY4FGVF3_cjs.d(r.salt),chunkNY4FGVF3_cjs.a(r.iterations),32,chunkNY4FGVF3_cjs.b(r.hash))):new Uint8Array(crypto.createHash("sha256").update(n).digest())}async encrypt(n,r){return this.encryptSync(n,r)}encryptSync(n,r){let t=crypto.randomBytes(12),e=crypto.createCipheriv("aes-256-gcm",r,t),c=Buffer.concat([e.update(n),e.final()]),s=e.getAuthTag(),o=new Uint8Array(28+c.length);return o.set(t,0),o.set(s,12),o.set(c,28),o}async decrypt(n,r){return this.decryptSync(n,r)}decryptSync(n,r){if(n.length<28)throw new Error("[Ddu64 decrypt] Invalid encrypted data: too short");let t=n.subarray(0,12),e=n.subarray(12,28),c=n.subarray(28),s=crypto.createDecipheriv("aes-256-gcm",r,t);s.setAuthTag(e);let o=Buffer.concat([s.update(c),s.final()]);return new Uint8Array(o)}randomBytes(n){return new Uint8Array(crypto.randomBytes(n))}async deflate(n,r){let t={};r!==void 0&&(t.level=r);let e=await k(Buffer.from(n),t);return new Uint8Array(e)}deflateSync(n,r){let t={};return r!==void 0&&(t.level=r),new Uint8Array(zlib.deflateRawSync(Buffer.from(n),t))}async inflate(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY){let e=await U(Buffer.from(n));return new Uint8Array(e)}let t={maxOutputLength:r};try{let e=await U(Buffer.from(n),t);return new Uint8Array(e)}catch(e){u(e,r,"inflate");}}inflateSync(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY)return new Uint8Array(zlib.inflateRawSync(Buffer.from(n)));try{return new Uint8Array(zlib.inflateRawSync(Buffer.from(n),{maxOutputLength:r}))}catch(t){u(t,r,"inflate");}}async brotliCompress(n,r){let t={};r!==void 0&&(t.params={[zlib.constants.BROTLI_PARAM_QUALITY]:Math.max(0,Math.min(11,r))});let e=await C(Buffer.from(n),t);return new Uint8Array(e)}brotliCompressSync(n,r){let t={};return r!==void 0&&(t.params={[zlib.constants.BROTLI_PARAM_QUALITY]:Math.max(0,Math.min(11,r))}),new Uint8Array(zlib.brotliCompressSync(Buffer.from(n),t))}async brotliDecompress(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY){let t=await b(Buffer.from(n));return new Uint8Array(t)}try{let t=await b(Buffer.from(n),{maxOutputLength:r});return new Uint8Array(t)}catch(t){u(t,r,"brotli");}}brotliDecompressSync(n,r){if(r===void 0||r===Number.POSITIVE_INFINITY)return new Uint8Array(zlib.brotliDecompressSync(Buffer.from(n)));try{return new Uint8Array(zlib.brotliDecompressSync(Buffer.from(n),{maxOutputLength:r}))}catch(t){u(t,r,"brotli");}}};exports.a=w;//# sourceMappingURL=chunk-TJTDYO65.cjs.map
2
- //# sourceMappingURL=chunk-TJTDYO65.cjs.map