@ddunigma/node 6.0.1 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +64 -2
  2. package/CONTRIBUTING.md +137 -0
  3. package/README.md +54 -39
  4. package/ROADMAP.md +12 -11
  5. package/dist/BrowserAdapter-FJYE5LZO.js +1 -0
  6. package/dist/BrowserAdapter-NXLXZCJX.cjs +1 -0
  7. package/dist/{ObfuscationLayer-DTlA723P.d.ts → ObfuscationLayer-C5TQHpYX.d.cts} +9 -11
  8. package/dist/{ObfuscationLayer-4rCOCRWH.d.cts → ObfuscationLayer-DmlvbjTB.d.ts} +9 -11
  9. package/dist/{WebStreams-C16QV2Dz.d.ts → WebStreams-DY1ovJBp.d.cts} +5 -9
  10. package/dist/{WebStreams-CY9E19f5.d.cts → WebStreams-DynLi09H.d.ts} +5 -9
  11. package/dist/browser.cjs +1 -1
  12. package/dist/browser.d.cts +12 -21
  13. package/dist/browser.d.ts +12 -21
  14. package/dist/browser.js +1 -1
  15. package/dist/chunk-B4QRMN45.js +9 -0
  16. package/dist/chunk-BUR4IORD.cjs +1 -0
  17. package/dist/chunk-C2AT5XRJ.js +1 -0
  18. package/dist/chunk-DAHLP6QA.cjs +1 -0
  19. package/dist/chunk-GR2WPLDK.js +1 -0
  20. package/dist/chunk-JATMOMX5.cjs +9 -0
  21. package/dist/chunk-XVV2OPRV.js +1 -0
  22. package/dist/chunk-ZMNWFYGY.cjs +1 -0
  23. package/dist/{core-BsIwjJK-.d.cts → core-DCeItMgU.d.cts} +35 -53
  24. package/dist/{core-BsIwjJK-.d.ts → core-DCeItMgU.d.ts} +35 -53
  25. package/dist/core.cjs +1 -1
  26. package/dist/core.d.cts +1 -1
  27. package/dist/core.d.ts +1 -1
  28. package/dist/core.js +1 -1
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.d.cts +21 -26
  31. package/dist/index.d.ts +21 -26
  32. package/dist/index.js +1 -1
  33. package/dist/secure.browser.cjs +1 -1
  34. package/dist/secure.browser.d.cts +4 -4
  35. package/dist/secure.browser.d.ts +4 -4
  36. package/dist/secure.browser.js +1 -1
  37. package/dist/secure.cjs +1 -1
  38. package/dist/secure.d.cts +9 -9
  39. package/dist/secure.d.ts +9 -9
  40. package/dist/secure.js +1 -1
  41. package/docs/REFERENCE.md +45 -32
  42. package/package.json +22 -16
  43. package/dist/BrowserAdapter-A6RBN4N3.js +0 -1
  44. package/dist/BrowserAdapter-NWASGV3D.cjs +0 -1
  45. package/dist/chunk-6N7QYPEJ.js +0 -1
  46. package/dist/chunk-6ZYMNHFT.js +0 -1
  47. package/dist/chunk-7KUEHTG2.js +0 -1
  48. package/dist/chunk-BDP7E7K3.cjs +0 -1
  49. package/dist/chunk-HUUB5BUS.cjs +0 -1
  50. package/dist/chunk-JBUTKSCC.cjs +0 -9
  51. package/dist/chunk-LCOYWJWO.cjs +0 -1
  52. package/dist/chunk-VW2SZR2Z.js +0 -9
@@ -1,38 +1,29 @@
1
- import { D as Ddu64Core, a as DduBaseConstructorOptions, b as DduBaseOptions, c as DduEncodeStats } from './core-BsIwjJK-.cjs';
2
- export { C as CharSetConfig, d as CharSetInfo, e as CharsetBuilder, f as Ddu64AdapterError, g as Ddu64CharsetError, h as Ddu64ChecksumError, i as Ddu64CompressionError, j as Ddu64DecodeError, k as Ddu64DecompressionError, l as Ddu64DecryptionError, m as Ddu64EncodeError, n as Ddu64EncryptionError, o as Ddu64Error, p as Ddu64ErrorCode, q as Ddu64ErrorOptions, r as Ddu64InvalidInputError, s as Ddu64LimitError, t as Ddu64ObfuscationError, u as Ddu64Operation, v as Ddu64StreamError, w as DduProgressInfo, x as DduSetSymbol, y as DduSetSymbolInput, E as EncodingProfile, O as ObfuscationLayer, z as isDdu64Error } from './core-BsIwjJK-.cjs';
3
- export { H as HangulObfuscationLayer, c as createEncoderObfuscationLayer, d as detectRuntime } from './ObfuscationLayer-4rCOCRWH.cjs';
1
+ import { D as Ddu64Core, a as DduSecureConstructorOptions, b as DduOptions, c as DduEncodeStats } from './core-DCeItMgU.cjs';
2
+ export { C as CharSetConfig, d as CharSetInfo, e as CharsetBuilder, f as Ddu64AdapterError, g as Ddu64CharsetError, h as Ddu64ChecksumError, i as Ddu64CompressionError, j as Ddu64DecodeError, k as Ddu64DecompressionError, l as Ddu64DecryptionError, m as Ddu64EncodeError, n as Ddu64EncryptionError, o as Ddu64Error, p as Ddu64ErrorCode, q as Ddu64ErrorOptions, r as Ddu64InvalidInputError, s as Ddu64LimitError, t as Ddu64ObfuscationError, u as Ddu64Operation, v as Ddu64StreamError, w as DduBaseConstructorOptions, x as DduBaseOptions, y as DduConstructorOptions, z as DduProgressInfo, A as DduSecureOptions, B as DduSetSymbol, E as DduSetSymbolInput, F as EncodingProfile, K as KeyDerivationAlgorithm, G as KeyDerivationOptions, O as ObfuscationLayer, P as PlatformAdapter, H as isDdu64Error } from './core-DCeItMgU.cjs';
3
+ export { H as HangulObfuscationLayer, c as createEncoderObfuscationLayer, d as detectRuntime } from './ObfuscationLayer-C5TQHpYX.cjs';
4
4
 
5
5
  /**
6
- * Browser 전용 기본(lean) Ddu64 래퍼.
6
+ * Browser 전용 기본 Ddu64 래퍼.
7
7
  *
8
8
  * Ddu64Core를 확장하여 인코딩 + 한글 난독화(라이브러리 주목적)를 제공합니다:
9
9
  * - HangulObfuscationLayer 자동 주입 → 키 없는 한글 난독화 사용 가능
10
10
  *
11
- * 6.0: 어댑터(BrowserAdapter)주입하지 않습니다. 압축/암호화/체크섬/스트림이 필요하면
12
- * secure 진입점(`@ddunigma/node/secure`)의 `Ddu64SecureBrowser`를 사용하세요.
11
+ * 기본 경로는 BrowserAdapter를 정적 import하지 않습니다. 비동기 압축/암복호화가 실제로
12
+ * 실행될 어댑터만 동적 import해 현재 core 인스턴스에 주입합니다.
13
13
  * Node.js 내장 모듈도, WebCrypto/CompressionStream 어댑터도 정적 import하지 않습니다.
14
14
  *
15
15
  * @module Ddu64Browser
16
16
  */
17
17
 
18
18
  declare class Ddu64Browser extends Ddu64Core {
19
- constructor(dduChar?: string[] | string | DduBaseConstructorOptions, paddingChar?: string, dduOptions?: DduBaseConstructorOptions);
19
+ #private;
20
+ constructor(dduChar?: string[] | string | DduSecureConstructorOptions, paddingChar?: string, dduOptions?: DduSecureConstructorOptions);
20
21
  /** @group Sync */
21
- encode(input: Uint8Array | string, options?: DduBaseOptions): string;
22
- /** @group Async */
23
- encodeAsync(input: Uint8Array | string, options?: DduBaseOptions): Promise<string>;
22
+ encode(input: Uint8Array | string, options?: DduOptions): string;
24
23
  /** @group Sync */
25
- decode(input: string, options?: DduBaseOptions): string;
26
- /** @group Async */
27
- decodeAsync(input: string, options?: DduBaseOptions): Promise<string>;
28
- /** @group Sync */
29
- decodeToUint8Array(input: string, options?: DduBaseOptions): Uint8Array;
30
- /** @group Async */
31
- decodeToUint8ArrayAsync(input: string, options?: DduBaseOptions): Promise<Uint8Array>;
32
- /** @group Introspection */
33
- getStats(input: Uint8Array | string, options?: DduBaseOptions): DduEncodeStats;
24
+ decodeToUint8Array(input: string, options?: DduOptions): Uint8Array;
34
25
  /** @group Introspection */
35
- getStatsAsync(input: Uint8Array | string, options?: DduBaseOptions): Promise<DduEncodeStats>;
26
+ getStats(input: Uint8Array | string, options?: DduOptions): DduEncodeStats;
36
27
  }
37
28
 
38
- export { Ddu64Browser as Ddu64, Ddu64Browser, Ddu64Core, DduBaseConstructorOptions, DduBaseOptions, DduEncodeStats };
29
+ export { Ddu64Browser as Ddu64, Ddu64Browser, Ddu64Core, DduEncodeStats, DduOptions, DduSecureConstructorOptions };
package/dist/browser.d.ts CHANGED
@@ -1,38 +1,29 @@
1
- import { D as Ddu64Core, a as DduBaseConstructorOptions, b as DduBaseOptions, c as DduEncodeStats } from './core-BsIwjJK-.js';
2
- export { C as CharSetConfig, d as CharSetInfo, e as CharsetBuilder, f as Ddu64AdapterError, g as Ddu64CharsetError, h as Ddu64ChecksumError, i as Ddu64CompressionError, j as Ddu64DecodeError, k as Ddu64DecompressionError, l as Ddu64DecryptionError, m as Ddu64EncodeError, n as Ddu64EncryptionError, o as Ddu64Error, p as Ddu64ErrorCode, q as Ddu64ErrorOptions, r as Ddu64InvalidInputError, s as Ddu64LimitError, t as Ddu64ObfuscationError, u as Ddu64Operation, v as Ddu64StreamError, w as DduProgressInfo, x as DduSetSymbol, y as DduSetSymbolInput, E as EncodingProfile, O as ObfuscationLayer, z as isDdu64Error } from './core-BsIwjJK-.js';
3
- export { H as HangulObfuscationLayer, c as createEncoderObfuscationLayer, d as detectRuntime } from './ObfuscationLayer-DTlA723P.js';
1
+ import { D as Ddu64Core, a as DduSecureConstructorOptions, b as DduOptions, c as DduEncodeStats } from './core-DCeItMgU.js';
2
+ export { C as CharSetConfig, d as CharSetInfo, e as CharsetBuilder, f as Ddu64AdapterError, g as Ddu64CharsetError, h as Ddu64ChecksumError, i as Ddu64CompressionError, j as Ddu64DecodeError, k as Ddu64DecompressionError, l as Ddu64DecryptionError, m as Ddu64EncodeError, n as Ddu64EncryptionError, o as Ddu64Error, p as Ddu64ErrorCode, q as Ddu64ErrorOptions, r as Ddu64InvalidInputError, s as Ddu64LimitError, t as Ddu64ObfuscationError, u as Ddu64Operation, v as Ddu64StreamError, w as DduBaseConstructorOptions, x as DduBaseOptions, y as DduConstructorOptions, z as DduProgressInfo, A as DduSecureOptions, B as DduSetSymbol, E as DduSetSymbolInput, F as EncodingProfile, K as KeyDerivationAlgorithm, G as KeyDerivationOptions, O as ObfuscationLayer, P as PlatformAdapter, H as isDdu64Error } from './core-DCeItMgU.js';
3
+ export { H as HangulObfuscationLayer, c as createEncoderObfuscationLayer, d as detectRuntime } from './ObfuscationLayer-DmlvbjTB.js';
4
4
 
5
5
  /**
6
- * Browser 전용 기본(lean) Ddu64 래퍼.
6
+ * Browser 전용 기본 Ddu64 래퍼.
7
7
  *
8
8
  * Ddu64Core를 확장하여 인코딩 + 한글 난독화(라이브러리 주목적)를 제공합니다:
9
9
  * - HangulObfuscationLayer 자동 주입 → 키 없는 한글 난독화 사용 가능
10
10
  *
11
- * 6.0: 어댑터(BrowserAdapter)주입하지 않습니다. 압축/암호화/체크섬/스트림이 필요하면
12
- * secure 진입점(`@ddunigma/node/secure`)의 `Ddu64SecureBrowser`를 사용하세요.
11
+ * 기본 경로는 BrowserAdapter를 정적 import하지 않습니다. 비동기 압축/암복호화가 실제로
12
+ * 실행될 어댑터만 동적 import해 현재 core 인스턴스에 주입합니다.
13
13
  * Node.js 내장 모듈도, WebCrypto/CompressionStream 어댑터도 정적 import하지 않습니다.
14
14
  *
15
15
  * @module Ddu64Browser
16
16
  */
17
17
 
18
18
  declare class Ddu64Browser extends Ddu64Core {
19
- constructor(dduChar?: string[] | string | DduBaseConstructorOptions, paddingChar?: string, dduOptions?: DduBaseConstructorOptions);
19
+ #private;
20
+ constructor(dduChar?: string[] | string | DduSecureConstructorOptions, paddingChar?: string, dduOptions?: DduSecureConstructorOptions);
20
21
  /** @group Sync */
21
- encode(input: Uint8Array | string, options?: DduBaseOptions): string;
22
- /** @group Async */
23
- encodeAsync(input: Uint8Array | string, options?: DduBaseOptions): Promise<string>;
22
+ encode(input: Uint8Array | string, options?: DduOptions): string;
24
23
  /** @group Sync */
25
- decode(input: string, options?: DduBaseOptions): string;
26
- /** @group Async */
27
- decodeAsync(input: string, options?: DduBaseOptions): Promise<string>;
28
- /** @group Sync */
29
- decodeToUint8Array(input: string, options?: DduBaseOptions): Uint8Array;
30
- /** @group Async */
31
- decodeToUint8ArrayAsync(input: string, options?: DduBaseOptions): Promise<Uint8Array>;
32
- /** @group Introspection */
33
- getStats(input: Uint8Array | string, options?: DduBaseOptions): DduEncodeStats;
24
+ decodeToUint8Array(input: string, options?: DduOptions): Uint8Array;
34
25
  /** @group Introspection */
35
- getStatsAsync(input: Uint8Array | string, options?: DduBaseOptions): Promise<DduEncodeStats>;
26
+ getStats(input: Uint8Array | string, options?: DduOptions): DduEncodeStats;
36
27
  }
37
28
 
38
- export { Ddu64Browser as Ddu64, Ddu64Browser, Ddu64Core, DduBaseConstructorOptions, DduBaseOptions, DduEncodeStats };
29
+ export { Ddu64Browser as Ddu64, Ddu64Browser, Ddu64Core, DduEncodeStats, DduOptions, DduSecureConstructorOptions };
package/dist/browser.js CHANGED
@@ -1 +1 @@
1
- import {a as a$1}from'./chunk-6N7QYPEJ.js';export{a as HangulObfuscationLayer,b as createEncoderObfuscationLayer,c as detectRuntime}from'./chunk-6N7QYPEJ.js';import {i,b}from'./chunk-VW2SZR2Z.js';export{j as CharsetBuilder,i as Ddu64Core,a as DduSetSymbol}from'./chunk-VW2SZR2Z.js';export{m as Ddu64AdapterError,j as Ddu64CharsetError,i as Ddu64ChecksumError,e as Ddu64CompressionError,d as Ddu64DecodeError,f as Ddu64DecompressionError,h as Ddu64DecryptionError,c as Ddu64EncodeError,g as Ddu64EncryptionError,b as Ddu64Error,a as Ddu64ErrorCode,k as Ddu64InvalidInputError,l as Ddu64LimitError,n as Ddu64ObfuscationError,o as Ddu64StreamError,p as isDdu64Error}from'./chunk-IZK7KCU7.js';import {a}from'./chunk-EI7MMDWY.js';var t=class extends i{static{a(this,"Ddu64Browser");}constructor(r,o,i){let e=b(r,o,i),a={...e.dduOptions,...e.dduChar!==void 0?{dduChar:e.dduChar}:{},...e.paddingChar!==void 0?{paddingChar:e.paddingChar}:{},obfuscationLayerFactory:e.dduOptions?.obfuscationLayerFactory??(p=>new a$1(p))};super(a);}encode(r,o){return super.encode(r,o)}encodeAsync(r,o){return super.encodeAsync(r,o)}decode(r,o){return super.decode(r,o)}decodeAsync(r,o){return super.decodeAsync(r,o)}decodeToUint8Array(r,o){return super.decodeToUint8Array(r,o)}decodeToUint8ArrayAsync(r,o){return super.decodeToUint8ArrayAsync(r,o)}getStats(r,o){return super.getStats(r,o)}getStatsAsync(r,o){return super.getStatsAsync(r,o)}};export{t as Ddu64,t as Ddu64Browser};
1
+ import {a as a$1}from'./chunk-XVV2OPRV.js';export{a as HangulObfuscationLayer,b as createEncoderObfuscationLayer,c as detectRuntime}from'./chunk-XVV2OPRV.js';import {i,b}from'./chunk-B4QRMN45.js';export{j as CharsetBuilder,i as Ddu64Core,a as DduSetSymbol}from'./chunk-B4QRMN45.js';import {m}from'./chunk-IZK7KCU7.js';export{m as Ddu64AdapterError,j as Ddu64CharsetError,i as Ddu64ChecksumError,e as Ddu64CompressionError,d as Ddu64DecodeError,f as Ddu64DecompressionError,h as Ddu64DecryptionError,c as Ddu64EncodeError,g as Ddu64EncryptionError,b as Ddu64Error,a as Ddu64ErrorCode,k as Ddu64InvalidInputError,l as Ddu64LimitError,n as Ddu64ObfuscationError,o as Ddu64StreamError,p as isDdu64Error}from'./chunk-IZK7KCU7.js';import {a}from'./chunk-EI7MMDWY.js';var t=class extends i{static{a(this,"Ddu64Browser");}#o;#e;#t;constructor(o,r,d){let e=b(o,r,d),p=e.dduOptions?.adapter!==void 0||e.dduOptions?.adapterFactory!==void 0,n={...e.dduOptions,...e.dduChar!==void 0?{dduChar:e.dduChar}:{},...e.paddingChar!==void 0?{paddingChar:e.paddingChar}:{},asyncAdapterFactory:e.dduOptions?.asyncAdapterFactory??(p?void 0:()=>import('./BrowserAdapter-FJYE5LZO.js').then(({BrowserAdapter:s})=>new s)),obfuscationLayerFactory:e.dduOptions?.obfuscationLayerFactory??(s=>new a$1(s))};super(n),this.#o=n.compress===true,this.#e=n.encryptionKey!==void 0,this.#t=p;}encode(o,r){return this.#r("encode",r),super.encode(o,r)}decodeToUint8Array(o,r){return this.#r("decode",r),super.decodeToUint8Array(o,r)}getStats(o,r){return this.#r("encode",r,false),super.getStats(o,r)}#r(o,r,d=true){if(!this.#t&&((r?.compress??this.#o)===true||d&&this.#e))throw new m("@ddunigma/node/browser: use encodeAsync/decodeAsync/getStatsAsync, or @ddunigma/node/secure for secure options.",o)}};export{t as Ddu64,t as Ddu64Browser};
@@ -0,0 +1,9 @@
1
+ import {j,p,q as q$1,r,n,c,m,g,h,e,f,k,d,l,i}from'./chunk-IZK7KCU7.js';import {a}from'./chunk-EI7MMDWY.js';var be=(n=>(n.DDU="ddu",n.DDU_V1="ddu_v1",n.ONECHARSET="oneCharSet",n))(be||{}),de={dduSetSymbol:"ddu",usePowerOfTwo:true,requiredLength:64};function Ae(e,r){return e<=1?0:r?Math.floor(Math.log2(e)):Math.ceil(Math.log2(e))}a(Ae,"calculateBitLength");function we(e){return e>0&&(e&e-1)===0}a(we,"isPowerOfTwo");function Pe(e){return e<31?1<<e:Math.pow(2,e)}a(Pe,"maxValueForBitLength");var Br=(()=>{let e=new Uint32Array(256);for(let r=0;r<256;r++){let t=r;for(let n=0;n<8;n++)t=t>>>1^(t&1?3988292384:0);e[r]=t;}return e})();function R(e){let r=4294967295;for(let t=0;t<e.length;t++)r=r>>>8^Br[(r^e[t])&255];return ((r^4294967295)>>>0).toString(16).padStart(8,"0")}a(R,"calculateCRC32");function ce(e,r){let t=Math.max(e.length,r.length),n=e.length^r.length;for(let o=0;o<t;o++){let i=o<e.length?e.charCodeAt(o):0,s=o<r.length?r.charCodeAt(o):0;n|=i^s;}return n===0}a(ce,"constantTimeEquals");var Se=["-","_","."];function De(e){return e.length===0?e:e.replaceAll("+","-").replaceAll("/","_").replaceAll("=",".")}a(De,"toUrlSafe");function Ee(e){return e.length===0?e:e.replaceAll("-","+").replaceAll("_","/").replaceAll(".","=")}a(Ee,"fromUrlSafe");function ke(e,r,t){if(r<=0||e.length<=r)return e;let n=Math.ceil(e.length/r),o=new Array(n*2-1),i=0;for(let s=0;s<e.length;s+=r)o[i++]=e.slice(s,s+r),s+r<e.length&&(o[i++]=t);return o.join("")}a(ke,"splitIntoChunks");function xe(e,r){if(e.length===0)return e;let t=r&&r!==`
2
+ `&&r!==`\r
3
+ `&&r!=="\r"?r:"",n=e.includes(`
4
+ `)||e.includes("\r"),o=t.length>0&&e.includes(t);if(!n&&!o)return e;let i=n?e.replace(/[\r\n]/g,""):e;return o&&(i=i.replaceAll(t,"")),i}a(xe,"removeChunks");var ve={"":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 Be(e){return Object.prototype.hasOwnProperty.call(ve,e)}a(Be,"isKnownCodaChar");function Ur(e,r){let t=e.charCodeAt(0);if(t<44032||t>55203)return e;let n=t-(t-44032)%28,o=ve[r]??0;return String.fromCharCode(n+o)}a(Ur,"combineCoda");function X(e,r){let t=new Array(e.length*r.length),n=0;for(let o of e)for(let i of r)t[n++]=Ur(o,i);return t}a(X,"buildCodaCharset");function J(e,r){let n=e===void 0||!Number.isFinite(e)?6:Math.floor(e);return Math.min(r==="brotli"?11:9,Math.max(0,n))}a(J,"normalizeCompressionLevel");var Or=new TextEncoder,Ir=new TextDecoder;function K(e){return Or.encode(e)}a(K,"stringToBytes");function ue(e){return Ir.decode(e)}a(ue,"bytesToString");var Rr={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},Lr={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}},Tr={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 Z(e){switch(e){case "ddu":return Rr;case "ddu_v1":return Lr;case "oneCharSet":return Tr;default:return}}a(Z,"getCharSet");function Oe(e,r,t,n){let o=a((i,s,d,c,u)=>{if((t?.usePowerOfTwo===void 0?d>0&&(d&d-1)===0:t.usePowerOfTwo&&d>0)&&d>0){let f=Math.floor(Math.log2(d)),h=1<<f;return {charSet:i.length===h?i:i.slice(0,h),padding:s,requiredLength:h,bitLength:f,isPredefined:c,useRepeatPadding:u}}return {charSet:i.length===d?i:i.slice(0,d),padding:s,requiredLength:d,bitLength:d>0?Math.ceil(Math.log2(d)):0,isPredefined:c,useRepeatPadding:u}},"buildMeta");try{let i=e??t?.dduChar,s=r??t?.paddingChar;if(i!==void 0){if(!s)throw new Error("[Ddu64 Constructor] paddingChar is required when dduChar is provided.");let f=typeof i=="string"?[...i]:[...i],h=t?.codaChar,m=h!==void 0&&h.length>0,y=m?!0:t?.useRepeatPadding??!1;if(m){if(n){let D=h.filter(b=>!Be(b));if(D.length>0)throw new Error(`[Ddu64 Constructor] Unknown coda character(s): [${D.join(", ")}]. Coda must be empty ("") or a Hangul jongseong jamo (\u3131, \u3132, \u3133, \u2026 \u314E). Unknown coda collapses to no-coda and can create duplicate symbols.`)}f=X(f,h);}if(n&&new Set(f).size!==f.length){let b=f.filter((w,P)=>f.indexOf(w)!==P);throw new Error(`[Ddu64 Constructor] Character set contains duplicate characters: [${[...new Set(b)].join(", ")}]`)}let g=t?.requiredLength??f.length;if(f.length<g)throw new Error("[Ddu64 Constructor] Insufficient characters.");return o(f,s,g,!1,y)}let d=t?.dduSetSymbol??de.dduSetSymbol??"ddu",c=Z(d);if(!c)throw new Error(`CharSet with symbol ${d} not found`);let u=c.codaChar?X(c.charSet,c.codaChar):c.charSet,l=o(u,c.paddingChar,c.maxRequiredLength,!0,c.useRepeatPadding),p=c.encodingProfile;return p?(l.encodingProfile=p,l.bitLength=p.bitLength,l.usePowerOfTwo=p.usePowerOfTwo,l.bitsPerPadChar=p.bitsPerPadChar):(l.bitsPerPadChar=c.bitsPerPadChar,l.usePowerOfTwo=c.usePowerOfTwo,c.usePowerOfTwo===!1&&(l.bitLength=c.bitLength)),l}catch(i){if(n)throw i;return le(t)}}a(Oe,"resolveInitialCharSet");function Ie(e,r,t){let n=[e,null];for(let i of n){let s=i?{...i}:le(t);try{let d=s.charSet,c=s.requiredLength,u=Array.from(new Set(d));if(u.length!==d.length){if(r){let f=d.filter((h,m)=>d.indexOf(h)!==m);throw new Error(`[Ddu64 normalizeCharSet] Character set contains duplicate characters: [${[...new Set(f)].join(", ")}]`)}d=u,s.isPredefined||(c=d.length);}if(d.length<c)throw new Error(`[Ddu64 normalizeCharSet] Insufficient characters. Required: ${c}, Has: ${d.length}`);if(c<2)throw new Error("[Ddu64 normalizeCharSet] At least 2 unique characters required.");if(d.find(f=>f.length!==1)){if(r)throw new Error("[Ddu64 normalizeCharSet] Multi-character symbols are not supported.");continue}if(s.padding.length!==1)throw new Error(`[Ddu64 normalizeCharSet] Padding length mismatch. Expected 1, got ${s.padding.length}`);if(d.includes(s.padding)){if(r)throw new Error(`[Ddu64 normalizeCharSet] Padding character "${s.padding}" conflicts with charset.`);if(d=d.filter(f=>f!==s.padding),d.length<c||d.length<2)throw new Error(`[Ddu64 normalizeCharSet] Padding removal left too few characters. Required: ${c}, Has: ${d.length}`)}for(let f of d){if(f.includes(`
5
+ `)||f.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(Ue(f))throw new Error(`[Ddu64 normalizeCharSet] Lone surrogate code unit (U+${f.charCodeAt(0).toString(16).toUpperCase()}) is not allowed; it corrupts on UTF-8/URL/JSON boundaries.`)}if(s.padding.includes(`
6
+ `)||s.padding.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(Ue(s.padding))throw new Error("[Ddu64 normalizeCharSet] Padding character must not be a lone surrogate code unit.");return {charSet:d.length===c?d:d.slice(0,c),padding:s.padding,isPredefined:s.isPredefined}}catch(d){if(r)throw d}}let o=le(t);return {charSet:o.charSet.slice(0,o.requiredLength),padding:o.padding,isPredefined:true}}a(Ie,"normalizeCharSet");function Re(e,r,t){for(let n of Se){for(let o of e)if(o.includes(n)){let i=`[Ddu64 Constructor] URL-Safe mode conflict: charset character "${o}" contains "${n}".`;if(t)throw new Error(i);return false}if(r.includes(n)){let o=`[Ddu64 Constructor] URL-Safe mode conflict: padding character "${r}" contains "${n}".`;if(t)throw new Error(o);return false}}return true}a(Re,"isUrlSafeCompatible");function Ue(e){if(e.length!==1)return false;let r=e.charCodeAt(0);return r>=55296&&r<=57343}a(Ue,"isLoneSurrogate");function le(e){let r=e?.dduSetSymbol??de.dduSetSymbol??"oneCharSet",t=Z(r)??Z("oneCharSet");if(!t)throw new Error("Critical: No fallback CharSet available");return {charSet:t.codaChar?X(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}}a(le,"getFallbackCharSet");var Mr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Le(e,r,t,n){return t&&n===6&&r==="="&&e.join("")===Mr}a(Le,"canUseNativeBase64FastPath");function Te(e){let r=Kr(e);if(r===null)return null;let t=0,n=r.length;for(;n>0&&r[n-1]==="=";)t++,n--;return {payload:r.slice(0,n),paddingBits:t===2?4:t===1?2:0}}a(Te,"encodeNativeBase64");function Me(e,r,t){let n=r===4?2:r===2?1:r===0?0:-1;if(n<0)return null;for(let o=0;o<e.length;o++)if(!t(e.charCodeAt(o)))return null;return Nr(e+"=".repeat(n))}a(Me,"decodeNativeBase64");function Kr(e){let r=e.toBase64;if(typeof r=="function")return r.call(e);let t=globalThis.Buffer;return t?.from?t.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"):null}a(Kr,"bytesToBase64");function Nr(e){let r=Uint8Array;if(typeof r.fromBase64=="function")return r.fromBase64(e);let t=globalThis.Buffer;if(t?.from){let n=t.from(e,"base64");return new Uint8Array(n)}return null}a(Nr,"base64ToBytes");function Q(e,r){if(!e)throw new m("[Ddu64 adapter] No platform adapter available. Use encodeAsync()/decodeAsync() in browser environments, or provide an adapter via options.adapter.",r);return e}a(Q,"requireSyncAdapter");function Ke(e,r,t){try{let n=Q(e.adapter,"encode");if(!n.encryptSync)throw new m("[Ddu64 encrypt] Sync encryption unavailable. Use encodeAsync() in browser environments.","encode");let o=_e(e,n,"encrypt","encode");return n.encryptSync(r,o,t)}catch(n){throw p(n)?n:new g(q$1(n),n)}}a(Ke,"runEncryptSync");function Ne(e,r,t){try{let n=Q(e.adapter,"decode");if(!n.decryptSync)throw new m("[Ddu64 decrypt] Sync decryption unavailable. Use decodeAsync() in browser environments.","decode");let o=_e(e,n,"decrypt","decode");return n.decryptSync(r,o,t)}catch(n){throw p(n)?n:new h(q$1(n),n)}}a(Ne,"runDecryptSync");function he(e$1,r,t,n){try{let o=Q(e$1,"encode");if(t==="brotli"){if(!o.brotliCompressSync)throw new m("[Ddu64 compress] Brotli compression is unavailable in the current runtime.","encode");return o.brotliCompressSync(r,n)}if(!o.deflateSync)throw new m("[Ddu64 compress] Sync compression unavailable. Use encodeAsync() in browser environments.","encode");return o.deflateSync(r,n)}catch(o){throw p(o)?o:new e(q$1(o),o)}}a(he,"runCompressSync");function Fe(e,r,t,n){try{let o=Q(e,"decode");if(t==="brotli"){if(!o.brotliDecompressSync)throw new m("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.","decode");return o.brotliDecompressSync(r,n)}if(!o.inflateSync)throw new m("[Ddu64 decompress] Sync decompression unavailable. Use decodeAsync() in browser environments.","decode");return o.inflateSync(r,n)}catch(o){throw p(o)?o:new f(q$1(o),o)}}a(Fe,"runDecompressSync");function _e(e,r,t,n){if(e.encryptionKeyHash)return e.encryptionKeyHash;if(!r.deriveKeySync){let i=t==="encrypt"?"encodeAsync":"decodeAsync";throw new m(`[Ddu64 ${t}] Sync key derivation unavailable. Use ${i}() in browser environments.`,n)}let o=r.deriveKeySync(e.encryptionKey,e.keyDerivation);return e.setEncryptionKeyHash(o),o}a(_e,"getSyncKeyHash");async function $e(e,r,t){try{let n=ee(e.adapter,"encode"),o=await He(e,n);return await n.encrypt(r,o,t)}catch(n){throw re(n,"encrypt")}}a($e,"encryptAsyncWithAdapter");async function ze(e,r,t){try{let n=ee(e.adapter,"decode"),o=await He(e,n);return await n.decrypt(r,o,t)}catch(n){throw re(n,"decrypt")}}a(ze,"decryptAsyncWithAdapter");async function fe(e,r,t,n){try{let o=ee(e,"encode");if(t==="brotli"){if(!o.brotliCompress)throw new m("[Ddu64 compress] Brotli compression is unavailable in the current runtime.","encode");return await o.brotliCompress(r,n)}return await o.deflate(r,n)}catch(o){throw re(o,"compress")}}a(fe,"compressAsyncWithAdapter");async function Ve(e,r,t,n){try{let o=ee(e,"decode");if(t==="brotli"){if(!o.brotliDecompress)throw new m("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.","decode");return await o.brotliDecompress(r,n)}return await o.inflate(r,n)}catch(o){throw re(o,"decompress")}}a(Ve,"decompressAsyncWithAdapter");function ee(e,r){if(!e)throw new m("[Ddu64 adapter] No platform adapter available. Use @ddunigma/node or @ddunigma/node/browser, or provide an adapter via options.adapter.",r);return e}a(ee,"requireAsyncAdapter");async function He(e,r){if(e.encryptionKeyHash)return e.encryptionKeyHash;if(e.encryptionKeyHashPromise)return e.encryptionKeyHashPromise;let t=r.deriveKey(e.encryptionKey,e.keyDerivation).then(n=>(e.setEncryptionKeyHash(n),n)).finally(()=>{e.encryptionKeyHashPromise=void 0;});return e.encryptionKeyHashPromise=t,t}a(He,"getAsyncKeyHash");function re(e$1,r){if(p(e$1))return e$1;let t=q$1(e$1);switch(r){case "compress":return new e(t,e$1);case "decompress":return new f(t,e$1);case "encrypt":return new g(t,e$1);case "decrypt":return new h(t,e$1)}}a(re,"toAsyncGatewayError");function qe(e,r,t){return e!=null&&typeof e=="object"&&!Array.isArray(e)?{dduChar:void 0,paddingChar:void 0,dduOptions:e}:{dduChar:e,paddingChar:r,dduOptions:t}}a(qe,"resolveConstructorArgs");var Ge=new Map;function je(e,r=false){let t=r?e.join(""):void 0;if(t!==void 0){let u=Ge.get(t);if(u)return u}let n=new Uint16Array(e.length),o=65535,i=0;for(let u=0;u<e.length;u++){let l=e[u].charCodeAt(0);n[u]=l,l>i&&(i=l),l<o&&(o=l);}let s=e.length>0?o:0,d=new Int32Array(i-s+1);d.fill(-1);for(let u=0;u<e.length;u++)d[n[u]-s]=u;let c={charCodeLookup:d,charCodes:n,lookupOffset:s};return t!==void 0&&Ge.set(t,c),c}a(je,"buildCharsetLookupTables");function N(e,r,t){let n=r-t;return n>=0&&n<e.length?e[n]:-1}a(N,"lookupCharIndex");var Ye=8;function We(e,r,t,n){return Math.ceil(e/(n?1:2))*t-r}a(We,"decodedBitCount");function x(e,r,t,n){if(e===void 0)return r;if(e===Number.POSITIVE_INFINITY)return Number.POSITIVE_INFINITY;if(!Number.isFinite(e)||e<=0){if(t)throw new k(`[Ddu64 options] Invalid ${n}. Must be a positive finite number or Infinity.`);return r}return Math.floor(e)}a(x,"normalizeLimit");function Xe(e,r,t,n){if(e===0)return 0;if(r<0||r>=t)throw new d(`[Ddu64 decode] Invalid padding bits: ${r}`);let o=We(e,r,t,n);if(o<0)throw new d("[Ddu64 decode] Invalid decoded bit length");return Math.ceil(o/Ye)}a(Xe,"estimateDecodedBytes");function Je(e,r){if(!r&&e.length%2!==0)throw new d(`[Ddu64 decode] Invalid encoded length for variable charset. Expected multiple of 2, got ${e.length}`)}a(Je,"assertEncodedInputAligned");function Ze(e,r,t,n){if(e.length===0)return;let o=We(e.length,r,t,n);if(o<0||o%Ye!==0)throw new d(`[Ddu64 decode] Invalid encoded bit length. Expected a whole number of bytes, got ${o} bits.`)}a(Ze,"assertDecodedBitLength");function Qe(e,r,t,n,o,i){if(r===0)return;if(e.length===0)throw new d("[Ddu64 decode] Invalid padding bits without payload");let s=(1<<r)-1,d$1;if(t){let c=e[e.length-1],u=N(n,c.charCodeAt(0),i);if(u<0)throw new d(`[Ddu64 decode] Invalid character "${c}" at ${e.length-1}`);d$1=u;}else {let c=e[e.length-2],u=e[e.length-1],l=N(n,c.charCodeAt(0),i),p=N(n,u.charCodeAt(0),i);if(l<0||p<0)throw new d("[Ddu64 decode] Invalid character in final encoded chunk");d$1=l*o+p;}if((d$1&s)!==0)throw new d("[Ddu64 decode] Invalid non-zero padding bits in final symbol")}a(Qe,"assertCanonicalPadding");var F="DDS1",_="ELYSIA",$="GRISEO";var Fr=new TextEncoder;function L(e,r,t){let n=t-r.length;if(n<0)return false;for(let o=0;o<r.length;o++)if(e.charCodeAt(n+o)!==r.charCodeAt(o))return false;return true}a(L,"endsWithAt");function er(e,r,t,n=2){let o=e.length,i=r.length,s={cleanedInput:e,paddingBits:0,isEncrypted:false,pipelineVersion:2};if(i===0||o<i)return s;let c=Math.max(0,t-1).toString().length;for(let u=Math.min(c,o);u>=1;u--){let l=o-u,p=true;for(let b=l;b<o;b++){let w=e.charCodeAt(b);if(w<48||w>57){p=false;break}}if(!p||u>1&&e.charCodeAt(l)===48)continue;let f=0;for(let b=l;b<o;b++)f=f*10+(e.charCodeAt(b)-48);if(f>=t)continue;let h=l,m=false,y,g=2;h>=2&&L(e,"V4",h)?(g=4,h-=2):h>=2&&L(e,"V3",h)&&(g=3,h-=2),h>=3&&L(e,"ENC",h)&&(m=true,h-=3),h>=_.length&&L(e,_,h)?(y="deflate",h-=_.length):h>=$.length&&L(e,$,h)&&(y="brotli",h-=$.length);let D=h-i;if(D>=0&&L(e,r,h))return {cleanedInput:e.substring(0,D),paddingBits:f,compressionAlgorithm:y,isEncrypted:m,pipelineVersion:g}}if(L(e,r,o)){let u=0,l=o;for(;l>=i&&L(e,r,l);)u++,l-=i;if(u>0){let p=u*n;if(p<t)return {cleanedInput:e.substring(0,l),paddingBits:p,isEncrypted:false,pipelineVersion:2}}}return s}a(er,"parseFooter");function _r(e){let r=e.lastIndexOf("CHK");if(r===-1)return {data:e,checksum:null};let t=e.slice(r+3);return t.length!==8||!/^[0-9a-f]+$/i.test(t)?{data:e,checksum:null}:{data:e.slice(0,r),checksum:t.toLowerCase()}}a(_r,"extractChecksum");var $r=/^[0-9a-f]{8}$/i;function rr(e){let r=e.length;if(r>=11){let n=e.charCodeAt(r-11),o=e.charCodeAt(r-10),i=e[r-9];if(n===67&&o===75&&(i==="P"||i==="O")){let s=e.slice(r-8);if($r.test(s))return {data:e.slice(0,r-11),checksum:s.toLowerCase(),scope:i==="P"?"plaintext":"output"}}}let t=_r(e);return {data:t.data,checksum:t.checksum,scope:null}}a(rr,"extractScopedChecksum");function zr(e){return e.length*2+F.length+2}a(zr,"getStreamHeaderLength");function St(e,r){let t=r.compressionAlgorithm==="brotli"?"B":r.compressionAlgorithm==="deflate"?"D":"N",n=r.encrypted?"1":"0";return `${e}${F}${t}${n}${e}`}a(St,"buildStreamHeader");function Dt(e,r){let t=zr(r);if(e.length<t||!e.startsWith(r))return null;let n=r.length;if(e.slice(n,n+F.length)!==F)throw new Error("[wireFormat] Invalid stream header magic");let i=e[n+F.length],s=e[n+F.length+1];if(e.slice(t-r.length,t)!==r)throw new Error("[wireFormat] Invalid stream header terminator");let c=i==="B"?"brotli":i==="D"?"deflate":i==="N"?void 0:null;if(c===null)throw new Error("[wireFormat] Invalid stream header compression flag");if(s!=="0"&&s!=="1")throw new Error("[wireFormat] Invalid stream header encryption flag");return {compressionAlgorithm:c,encrypted:s==="1"}}a(Dt,"parseStreamHeader");function tr(e){let{paddingBits:r,compressionAlgorithm:t,isEncrypted:n,paddingChar:o,useRepeatPadding:i,bitsPerPadChar:s=2,pipelineVersion:d=2}=e;if(!n&&d!==2)throw new Error("[wireFormat] Pipeline version markers require encryption");if(r===0&&!t&&!n&&d===2)return "";if(i&&!t&&!n&&d===2&&r>0&&r%s===0){let u=r/s;return o.repeat(u)}return o+(t==="deflate"?_:t==="brotli"?$:"")+(n?"ENC":"")+(d===4?"V4":d===3?"V3":"")+r.toString()}a(tr,"buildFooter");function te(e){return Fr.encode(`ddunigma:wire:v4;enc=1;compress=${e.compressionAlgorithm??"none"}`)}a(te,"buildEncryptionAAD");function nr(e,r,t){let n=r?.checksum??t.defaultChecksum,o=r?.compress!==false,i$1=r?.encrypt!==false,s=e;t.reportDecodeStart(e.length);let d=x(r?.maxDecodedBytes,t.defaultMaxDecodedBytes,true,"maxDecodedBytes"),c=x(r?.maxEncodedChars,d===Number.POSITIVE_INFINITY?t.defaultMaxEncodedChars:Math.min(t.defaultMaxEncodedChars,Number.MAX_SAFE_INTEGER,d*4+1024),true,"maxEncodedChars");if(e.length>c)throw new l(`[Ddu64 decode] Encoded input exceeds limit. Length: ${e.length}, Limit: ${c} characters`,"decode");let u=r?.chunkSeparator??t.defaultChunkSeparator;s=xe(s,u),t.urlSafe&&(s=Ee(s));let l$1=null,p=null;if(n){let T=rr(s);if(l$1=T.checksum,p=T.scope,s=T.data,!l$1)throw new i("[Ddu64 checksum] Checksum verification requested, but no checksum marker was found.")}t.shouldObfuscate(r)&&(s=t.deobfuscate(s));let{cleanedInput:f,paddingBits:h$1,compressionAlgorithm:m,isEncrypted:y,pipelineVersion:g}=er(s,t.paddingChar,t.bitLength,t.bitsPerPadChar);if((r?.requireEncryption??t.defaultRequireEncryption)&&i$1&&!y)throw new h("[Ddu64 decode] Encryption is required, but the payload has no authenticated encryption footer.");if(y&&i$1&&!t.encryptionKey)throw new h("[Ddu64 decode] Encrypted payload requires an encryptionKey");let b=y&&g===4?te({compressionAlgorithm:m}):void 0;Je(f,t.usePowerOfTwo),Qe(f,h$1,t.usePowerOfTwo,t.dduCharCodeLookup,t.charSetSize,t.dduCharCodeLookupOffset),Ze(f,h$1,t.bitLength,t.usePowerOfTwo);let w=Xe(f.length,h$1,t.bitLength,t.usePowerOfTwo);if(w>d)throw new l(`[Ddu64 decode] Decoded output exceeds limit. Estimated: ${w} bytes, Limit: ${d} bytes`,"decode");return t.reportBitpackDecode(f.length,e.length),{decoded:t.decodeChars(f,h$1),extractedChecksum:l$1,extractedChecksumScope:p,compressionAlgorithm:m,isEncrypted:y,pipelineVersion:g,encryptionAAD:b,allowInternalDecompress:o,allowInternalDecrypt:i$1}}a(nr,"runDecodePrelude");function or(e){return e.omitFooter?"":tr({paddingBits:e.paddingBits,compressionAlgorithm:e.compressionAlgorithm,isEncrypted:e.isEncrypted,paddingChar:e.paddingChar,useRepeatPadding:e.useRepeatPadding&&!e.compressionAlgorithm&&!e.isEncrypted,bitsPerPadChar:e.bitsPerPadChar,pipelineVersion:e.isEncrypted?e.pipelineVersion:2})}a(or,"buildEncodeFooter");function ir(e){let r=e.encoded;if(e.shouldObfuscate(e.options)&&(r=e.getObfuscationLayer().obfuscate(r)),e.shouldChecksum&&e.checksum){let t=e.checksumScope==="plaintext"?"P":"O";r=r+"CK"+t+e.checksum;}return e.urlSafe&&(r=De(r)),e.chunkSize&&e.chunkSize>0&&(e.assertSafeChunkSeparator(r,e.chunkSeparator),r=ke(r,e.chunkSize,e.chunkSeparator)),r}a(ir,"applyPostEncoding");var pe=8192;function ar(e,r,t){if(!Number.isInteger(r)||r<1||r>16)throw new c(`[Ddu64 encode] Invalid bitLength: ${r}`);let n=e.length;if(n===0)return {payload:"",paddingBits:0};let o=Math.ceil(n*8/r),i=Math.min(o,pe),s=new Uint16Array(i),d=[],c$1=0,u=0;if(r===6){let l=0;for(;l+2<n;l+=3){let f=e[l],h=e[l+1],m=e[l+2];s[c$1++]=t[f>>>2],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0),s[c$1++]=t[(f&3)<<4|h>>>4],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0),s[c$1++]=t[(h&15)<<2|m>>>6],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0),s[c$1++]=t[m&63],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0);}let p=n-l;if(p===1){let f=e[l];s[c$1++]=t[f>>>2],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0),s[c$1++]=t[(f&3)<<4],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0),u=4;}else if(p===2){let f=e[l],h=e[l+1];s[c$1++]=t[f>>>2],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0),s[c$1++]=t[(f&3)<<4|h>>>4],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0),s[c$1++]=t[(h&15)<<2],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0),u=2;}}else if(r===8)for(let l=0;l<n;l++)s[c$1++]=t[e[l]],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0);else {let l=(1<<r)-1,p=0,f=0;for(let h=0;h<n;h++)for(p=p<<8|e[h],f+=8;f>=r;)f-=r,s[c$1++]=t[p>>f&l],c$1===i&&(d.push(String.fromCharCode.apply(null,s)),c$1=0),p&=(1<<f)-1;f>0&&(u=r-f,s[c$1++]=t[p<<u&l]);}return c$1>0&&d.push(String.fromCharCode.apply(null,s.subarray(0,c$1))),{payload:d.length===1?d[0]:d.join(""),paddingBits:u}}a(ar,"packPow2ToString");function sr(e,r,t,n,o){if(!Number.isInteger(t)||t<1||t>16)throw new d(`[Ddu64 decode] Invalid bitLength: ${t}`);let i=e.length;if(i===0)return new Uint8Array(0);let s=Math.ceil((i*t-r)/8),d$1=new Uint8Array(s+1),c=0,u=n.length;if(t===6){let h=i-i%4;h===i&&r>0&&(h-=4);let m=0;for(;m<h;m+=4){let b=e.charCodeAt(m)-o,w=b>=0&&b<u?n[b]:-1;if(w<0)throw new d(`[Ddu64 decode] Invalid character "${e[m]}" at ${m}`);let P=e.charCodeAt(m+1)-o,T=P>=0&&P<u?n[P]:-1;if(T<0)throw new d(`[Ddu64 decode] Invalid character "${e[m+1]}" at ${m+1}`);let ne=e.charCodeAt(m+2)-o,oe=ne>=0&&ne<u?n[ne]:-1;if(oe<0)throw new d(`[Ddu64 decode] Invalid character "${e[m+2]}" at ${m+2}`);let ie=e.charCodeAt(m+3)-o,ge=ie>=0&&ie<u?n[ie]:-1;if(ge<0)throw new d(`[Ddu64 decode] Invalid character "${e[m+3]}" at ${m+3}`);d$1[c++]=w<<2|T>>>4,d$1[c++]=(T&15)<<4|oe>>>2,d$1[c++]=(oe&3)<<6|ge;}let y=0,g=0,D=i-1;for(;m<i;m++){let w=e.charCodeAt(m)-o,P=w>=0&&w<u?n[w]:-1;if(P<0)throw new d(`[Ddu64 decode] Invalid character "${e[m]}" at ${m}`);for(y=y<<6|P,g+=6,m===D&&r>0&&(y>>=r,g-=r);g>=8;)g-=8,d$1[c++]=y>>g&255,y&=(1<<g)-1;}return d$1.subarray(0,c)}if(t===8&&r===0){for(let h=0;h<i;h++){let y=e.charCodeAt(h)-o,g=y>=0&&y<u?n[y]:-1;if(g<0)throw new d(`[Ddu64 decode] Invalid character "${e[h]}" at ${h}`);d$1[c++]=g;}return d$1.subarray(0,c)}let l=0,p=0,f=i-1;for(let h=0;h<i;h++){let y=e.charCodeAt(h)-o,g=y>=0&&y<u?n[y]:-1;if(g<0)throw new d(`[Ddu64 decode] Invalid character "${e[h]}" at ${h}`);for(l=l<<t|g,p+=t,h===f&&r>0&&(l>>=r,p-=r);p>=8;)p-=8,d$1[c++]=l>>p&255,l&=(1<<p)-1;}return d$1.subarray(0,c)}a(sr,"unpackPow2FromString");function dr(e,r,t,n){let o=e.length;if(o===0)return {payload:"",paddingBits:0};let i=[],s=new Uint16Array(pe),d=0,c=0,u=0,l=0,p=a(f=>{s[d++]=f,d===pe&&(i.push(String.fromCharCode.apply(null,s)),d=0);},"pushCode");for(let f=0;f<o;f++)for(c=c<<8|e[f],u+=8;u>=r;){u-=r;let h=c>>u,m=h/t|0;p(n[m]),p(n[h-m*t]),c&=(1<<u)-1;}if(u>0){l=r-u;let f=c<<l,h=f/t|0;p(n[h]),p(n[f-h*t]);}return d>0&&i.push(String.fromCharCode.apply(null,s.subarray(0,d))),{payload:i.length===1?i[0]:i.join(""),paddingBits:l}}a(dr,"packNonPow2ToString");function cr(e,r,t,n,o,i){let s=e.length;if(s===0)return new Uint8Array(0);let d$1=Math.ceil(s/2),c=Math.ceil((d$1*t-r)/8),u=new Uint8Array(c+1),l=0,p=Pe(t),f=o.length,h=0,m=0;for(let y=0;y<s;y+=2){let g=e.charCodeAt(y)-i,D=g>=0&&g<f?o[g]:-1;if(D<0)throw new d(`[Ddu64 decode] Invalid character "${e[y]}" at ${y}`);if(y+1>=s)throw new d(`[Ddu64 decode] Truncated symbol pair at ${y+1}`);let b=e.charCodeAt(y+1)-i,w=b>=0&&b<f?o[b]:-1;if(w<0)throw new d(`[Ddu64 decode] Invalid character "${e[y+1]}" at ${y+1}`);let P=D*n+w;if(P>=p)throw new d(`[Ddu64 decode] Value ${P} exceeds range at position ${y}`);for(h=h<<t|P,m+=t,y+2>=s&&r>0&&(h>>=r,m-=r);m>=8;)m-=8,u[l++]=h>>m&255,h&=(1<<m)-1;}return u.subarray(0,l)}a(cr,"unpackNonPow2FromString");function ur(e,r,t,n,o){if(e.length===0)return "";let i=o.canUseNativeBase64?Te(e):null,s,d;if(i)s=i.paddingBits,d=i.payload;else if(o.bitPackConfig.usePowerOfTwo){let u=ar(e,o.bitPackConfig.bitLength,o.dduCharCodes);s=u.paddingBits,d=u.payload;}else {let u=dr(e,o.bitPackConfig.bitLength,o.bitPackConfig.charsetSize,o.dduCharCodes);s=u.paddingBits,d=u.payload;}let c=or({paddingBits:s,compressionAlgorithm:r,isEncrypted:t,paddingChar:o.paddingChar,useRepeatPadding:o.useRepeatPadding,bitsPerPadChar:o.bitsPerPadChar,pipelineVersion:o.encryptedPipelineVersion,omitFooter:n?.omitFooter});return d+c}a(ur,"encodePayload");function lr(e,r,t){if(e.length===0)return new Uint8Array(0);let o=t.canUseNativeBase64?Me(e,r,i=>N(t.dduCharCodeLookup,i,t.dduCharCodeLookupOffset)>=0):null;return o||(t.bitPackConfig.usePowerOfTwo?sr(e,r,t.bitPackConfig.bitLength,t.dduCharCodeLookup,t.dduCharCodeLookupOffset):cr(e,r,t.bitPackConfig.bitLength,t.bitPackConfig.charsetSize,t.dduCharCodeLookup,t.dduCharCodeLookupOffset))}a(lr,"decodePayload");function hr(e,r){let t=new Set(e);t.add(r);let n=_+$+"ENC"+"V3"+"V4";for(let o of n)t.add(o);for(let o of "0123456789")t.add(o);return [...t]}a(hr,"buildObfuscationAlphabet");function B(e,r="construct"){if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e))throw new k("[Ddu64 options] Options must be an object.",r);let t=e;v(e.compress,"compress",r),v(t.encrypt,"encrypt",r),v(e.checksum,"checksum",r),v(t.omitFooter,"omitFooter",r),v(e.obfuscate,"obfuscate",r),v(e.requireEncryption,"requireEncryption",r),e.compressionLevel!==void 0&&(typeof e.compressionLevel!="number"||!Number.isFinite(e.compressionLevel))&&C(r,"compressionLevel must be a finite number"),e.onProgress!==void 0&&typeof e.onProgress!="function"&&C(r,"onProgress must be a function"),e.compressionAlgorithm!==void 0&&e.compressionAlgorithm!=="deflate"&&e.compressionAlgorithm!=="brotli"&&C(r,`compressionAlgorithm must be "deflate" or "brotli", got ${String(e.compressionAlgorithm)}`),e.checksumScope!==void 0&&e.checksumScope!=="plaintext"&&e.checksumScope!=="output"&&C(r,`checksumScope must be "plaintext" or "output", got ${String(e.checksumScope)}`),e.chunkSize!==void 0&&(!Number.isSafeInteger(e.chunkSize)||e.chunkSize<0)&&C(r,"chunkSize must be a non-negative safe integer (0 disables chunking)"),e.chunkSeparator!==void 0&&typeof e.chunkSeparator!="string"&&C(r,"chunkSeparator must be a string"),e.chunkSize!==void 0&&e.chunkSize>0&&e.chunkSeparator===""&&C(r,"chunkSeparator must not be empty when chunkSize is enabled"),V(e.maxDecodedBytes,"maxDecodedBytes",r),V(e.maxEncodedChars,"maxEncodedChars",r),V(e.maxDecompressedBytes,"maxDecompressedBytes",r),"maxBufferedBytes"in e&&V(e.maxBufferedBytes,"maxBufferedBytes",r),"maxBufferedChars"in e&&V(e.maxBufferedChars,"maxBufferedChars",r);let n=e;v(n.throwOnError,"throwOnError",r),v(n.urlSafe,"urlSafe",r),v(n.useRepeatPadding,"useRepeatPadding",r),v(n.usePowerOfTwo,"usePowerOfTwo",r),n.encryptionKey!==void 0&&(typeof n.encryptionKey!="string"||n.encryptionKey.length===0)&&C(r,"encryptionKey must be a non-empty string"),n.dduChar!==void 0&&typeof n.dduChar!="string"&&!(Array.isArray(n.dduChar)&&n.dduChar.every(i=>typeof i=="string"))&&C(r,"dduChar must be a string or string array"),n.paddingChar!==void 0&&typeof n.paddingChar!="string"&&C(r,"paddingChar must be a string"),n.codaChar!==void 0&&!(Array.isArray(n.codaChar)&&n.codaChar.every(i=>typeof i=="string"))&&C(r,"codaChar must be a string array"),n.requiredLength!==void 0&&(!Number.isSafeInteger(n.requiredLength)||n.requiredLength<=0)&&C(r,"requiredLength must be a positive safe integer"),n.adapter!==void 0&&(typeof n.adapter!="object"||n.adapter===null)&&C(r,"adapter must be an object"),n.adapterFactory!==void 0&&typeof n.adapterFactory!="function"&&C(r,"adapterFactory must be a function"),n.asyncAdapterFactory!==void 0&&typeof n.asyncAdapterFactory!="function"&&C(r,"asyncAdapterFactory must be a function"),n.obfuscationLayerFactory!==void 0&&typeof n.obfuscationLayerFactory!="function"&&C(r,"obfuscationLayerFactory must be a function");let o="keyDerivation"in e?e.keyDerivation:void 0;o!==void 0&&((typeof o!="object"||o===null)&&C(r,"keyDerivation must be an object"),o.algorithm!==void 0&&o.algorithm!=="sha256"&&o.algorithm!=="pbkdf2"&&C(r,`keyDerivation.algorithm must be "sha256" or "pbkdf2", got ${String(o.algorithm)}`),o.hash!==void 0&&o.hash!=="SHA-256"&&o.hash!=="SHA-384"&&o.hash!=="SHA-512"&&C(r,`Unsupported PBKDF2 hash: ${String(o.hash)}`),o.iterations!==void 0&&(!Number.isFinite(o.iterations)||o.iterations<=0)&&C(r,"keyDerivation.iterations must be a positive finite number"),o.salt!==void 0&&typeof o.salt!="string"&&!fr(o.salt)&&C(r,"keyDerivation.salt must be a string or Uint8Array"));}a(B,"validateRuntimeOptions");function H(e,r="encode"){if(typeof e!="string"&&!fr(e))throw new k("[Ddu64 input] Encode input must be a string or Uint8Array.",r)}a(H,"validateEncodeInput");function q(e,r="decode"){if(typeof e!="string")throw new k("[Ddu64 input] Decode input must be a string.",r)}a(q,"validateDecodeInput");function fr(e){return ArrayBuffer.isView(e)&&Object.prototype.toString.call(e)==="[object Uint8Array]"}a(fr,"isUint8Array");function v(e,r,t){e!==void 0&&typeof e!="boolean"&&C(t,`${r} must be a boolean`);}a(v,"validateBoolean");function V(e,r,t){e!==void 0&&e!==Number.POSITIVE_INFINITY&&(!Number.isSafeInteger(e)||e<=0)&&C(t,`${r} must be a positive safe integer or Infinity`);}a(V,"validatePositiveLimit");function C(e,r){throw new k(`[Ddu64 options] Invalid ${r}.`,e)}a(C,"invalid");function pr(e,r,t){let n=e.decoded,o=e.extractedChecksumScope??r?.checksumScope??"plaintext";if(o==="output"&&br(e,t),yr(e,t)&&(U(t,n.length,55,"decrypt"),n=t.decrypt(n,e.encryptionAAD)),Cr(e)){let i=x(r?.maxDecompressedBytes,t.defaultMaxDecompressedBytes,true,"maxDecompressedBytes");U(t,n.length,70,"decompress"),n=t.decompress(n,e.compressionAlgorithm,i);}return o==="plaintext"&&Ar(e,t,n),gr(e,t)&&(U(t,n.length,90,"decrypt"),n=t.decrypt(n,e.encryptionAAD)),U(t,n.length,100,"done"),n}a(pr,"runSyncDecodePipeline");async function mr(e,r,t){let n=e.decoded,o=e.extractedChecksumScope??r?.checksumScope??"plaintext";if(o==="output"&&br(e,t),yr(e,t)&&(U(t,n.length,55,"decrypt"),n=await t.decrypt(n,e.encryptionAAD)),Cr(e)){let i=x(r?.maxDecompressedBytes,t.defaultMaxDecompressedBytes,true,"maxDecompressedBytes");U(t,n.length,70,"decompress"),n=await t.decompress(n,e.compressionAlgorithm,i);}return o==="plaintext"&&Ar(e,t,n),gr(e,t)&&(U(t,n.length,90,"decrypt"),n=await t.decrypt(n,e.encryptionAAD)),U(t,n.length,100,"done"),n}a(mr,"runAsyncDecodePipeline");function yr(e,r){return (e.pipelineVersion===3||e.pipelineVersion===4)&&e.isEncrypted&&!!r.encryptionKey&&e.allowInternalDecrypt}a(yr,"shouldRunPreDecompressDecrypt");function gr(e,r){return e.pipelineVersion===2&&e.isEncrypted&&!!r.encryptionKey&&e.allowInternalDecrypt}a(gr,"shouldRunPostChecksumDecrypt");function Cr(e){return !!e.compressionAlgorithm&&e.allowInternalDecompress&&(e.pipelineVersion===2||!e.isEncrypted||e.allowInternalDecrypt)}a(Cr,"shouldDecompress");function br(e,r){if(!e.extractedChecksum)return;U(r,e.decoded.length,85,"checksum");let t=R(e.decoded);if(!ce(t,e.extractedChecksum))throw new i(`[Ddu64 decode] Checksum mismatch. Expected: ${e.extractedChecksum}, Got: ${t}`)}a(br,"verifyWireChecksum");function Ar(e,r,t){if(!e.extractedChecksum||!(e.pipelineVersion===2||!e.isEncrypted||e.allowInternalDecrypt))return;U(r,t.length,85,"checksum");let n=R(t);if(!ce(n,e.extractedChecksum))throw new i(`[Ddu64 decode] Checksum mismatch. Expected: ${e.extractedChecksum}, Got: ${n}`)}a(Ar,"verifyDecodedChecksum");function U(e,r,t,n){e.reportProgress({processedBytes:r,totalBytes:r,percent:t,stage:n});}a(U,"reportStage");function me(e,r,t){let n=Pr(r,t),o=typeof e=="string"?K(e):e;Sr(t,o.length);let i="";n.shouldChecksum&&n.checksumScope==="plaintext"&&(i=R(o));let s,d;if(n.shouldCompress){let{algo:u,level:l}=wr(r,t);Dr(t,o.length);let p=t.compress(o,u,l);p.length<o.length&&(d=p.length,o=p,s=u);}let c=false;return n.shouldEncrypt&&(Er(t,o.length),o=t.encrypt(o,t.getEncryptionAAD(s)),c=true),n.shouldChecksum&&n.checksumScope==="output"&&(i=R(o)),{encoded:t.finalize(o,s,c,i,n.shouldChecksum,n.checksumScope,n.chunkSize,n.chunkSeparator),compressedSize:d}}a(me,"runSyncEncodePipeline");async function ye(e,r,t){let n=Pr(r,t),o=typeof e=="string"?K(e):e;Sr(t,o.length);let i="";n.shouldChecksum&&n.checksumScope==="plaintext"&&(i=R(o));let s,d;if(n.shouldCompress){let{algo:u,level:l}=wr(r,t);Dr(t,o.length);let p=await t.compress(o,u,l);p.length<o.length&&(d=p.length,o=p,s=u);}let c=false;return n.shouldEncrypt&&(Er(t,o.length),o=await t.encrypt(o,t.getEncryptionAAD(s)),c=true),n.shouldChecksum&&n.checksumScope==="output"&&(i=R(o)),{encoded:t.finalize(o,s,c,i,n.shouldChecksum,n.checksumScope,n.chunkSize,n.chunkSeparator),compressedSize:d}}a(ye,"runAsyncEncodePipeline");function wr(e,r){let t=e?.compressionAlgorithm??r.defaultCompressionAlgorithm,n=J(e?.compressionLevel??r.defaultCompressionLevel,t);return {algo:t,level:n}}a(wr,"resolveCompressionParams");function Pr(e,r){let t={shouldCompress:e?.compress??r.defaultCompress,shouldChecksum:e?.checksum??r.defaultChecksum,checksumScope:e?.checksumScope??r.defaultChecksumScope,shouldEncrypt:(e?.encrypt??true)&&r.hasEncryptionKey,chunkSize:e?.chunkSize??r.defaultChunkSize,chunkSeparator:e?.chunkSeparator??r.defaultChunkSeparator};if(t.chunkSize!==void 0&&t.chunkSize>0&&t.chunkSeparator==="")throw new k("[Ddu64 options] Invalid chunkSeparator must not be empty when chunkSize is enabled.","encode");return t}a(Pr,"resolveEncodeSettings");function Sr(e,r){e.reportProgress({processedBytes:0,totalBytes:r,percent:0,stage:"start"});}a(Sr,"reportStart");function Dr(e,r){e.reportProgress({processedBytes:r,totalBytes:r,percent:20,stage:"compress"});}a(Dr,"reportCompress");function Er(e,r){e.reportProgress({processedBytes:r,totalBytes:r,percent:45,stage:"encrypt"});}a(Er,"reportEncrypt");var jr=64*1024*1024,Yr=64*1024*1024,kr=28,xr=class{static{a(this,"Ddu64Core");}dduChar;dduCharCodes;paddingChar;bitLength;usePowerOfTwo;dduCharCodeLookup;dduCharCodeLookupOffset;defaultCompress;defaultMaxDecodedBytes;defaultMaxEncodedChars;defaultMaxDecompressedBytes;urlSafe;encryptionKey;keyDerivation;encryptionKeyHash;adapterGatewayContext;defaultChecksum;defaultChecksumScope;defaultChunkSize;defaultChunkSeparator;defaultCompressionLevel;defaultCompressionAlgorithm;useRepeatPadding;bitsPerPadChar;bitPackConfig;canUseNativeBase64;payloadCodecContext;adapter;adapterFactory;asyncAdapterFactory;asyncAdapterPromise;obfuscationLayerFactory;defaultObfuscate;defaultOnProgress;defaultRequireEncryption;obfuscationLayer;constructor(r,t,n){let o=qe(r,t,n);r=o.dduChar,t=o.paddingChar,n=o.dduOptions,B(n);let i=n?.throwOnError??true;this.adapter=n?.adapter,this.adapterFactory=n?.adapterFactory,this.asyncAdapterFactory=n?.asyncAdapterFactory,this.obfuscationLayerFactory=n?.obfuscationLayerFactory;let s,d;try{s=Oe(r,t,n,i),d=Ie(s,i,n);}catch(g){throw p(g)?g:new j(q$1(g),g)}this.dduChar=d.charSet,this.paddingChar=d.padding;let c=d.isPredefined;this.defaultCompress=n?.compress??false,this.defaultMaxDecodedBytes=x(n?.maxDecodedBytes,jr,i,"maxDecodedBytes"),this.defaultMaxDecompressedBytes=x(n?.maxDecompressedBytes,Yr,i,"maxDecompressedBytes"),this.defaultMaxEncodedChars=x(n?.maxEncodedChars,this.defaultMaxDecodedBytes===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.min(Number.MAX_SAFE_INTEGER,this.defaultMaxDecodedBytes*4+1024),i,"maxEncodedChars");let u=this.dduChar.length,l=we(u),p$1=n?.usePowerOfTwo,f=s.encodingProfile;this.usePowerOfTwo=f?.usePowerOfTwo??s.usePowerOfTwo??(p$1!==void 0?p$1&&l:l);let h=f?.bitLength??(s.isPredefined&&s.usePowerOfTwo!==void 0?s.bitLength:void 0);this.bitLength=h??Ae(u,this.usePowerOfTwo);let m=je(this.dduChar,c);this.dduCharCodeLookup=m.charCodeLookup,this.dduCharCodeLookupOffset=m.lookupOffset,this.dduCharCodes=m.charCodes;try{this.urlSafe=n?.urlSafe===!0?Re(this.dduChar,this.paddingChar,i):!1;}catch(g){throw p(g)?g:new j(q$1(g),g)}this.encryptionKey=n?.encryptionKey;let y=n?.keyDerivation;this.keyDerivation=y?{...y,...y.salt!==void 0?{salt:typeof y.salt=="string"?y.salt:new Uint8Array(y.salt)}:{}}:void 0,this.defaultChecksum=n?.checksum??false,this.defaultChecksumScope=n?.checksumScope??"output",this.defaultChunkSize=n?.chunkSize,this.defaultChunkSeparator=n?.chunkSeparator??`
7
+ `,this.defaultCompressionAlgorithm=n?.compressionAlgorithm??"deflate",this.defaultCompressionLevel=J(n?.compressionLevel,this.defaultCompressionAlgorithm),this.useRepeatPadding=n?.useRepeatPadding??s.useRepeatPadding??false,this.bitsPerPadChar=f?.bitsPerPadChar??s.bitsPerPadChar??2,this.defaultObfuscate=n?.obfuscate??false,this.defaultOnProgress=n?.onProgress,this.defaultRequireEncryption=n?.requireEncryption??this.encryptionKey!==void 0,this.bitPackConfig={bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,charsetSize:u},this.canUseNativeBase64=Le(this.dduChar,this.paddingChar,this.usePowerOfTwo,this.bitLength),this.payloadCodecContext={bitPackConfig:this.bitPackConfig,canUseNativeBase64:this.canUseNativeBase64,dduCharCodes:this.dduCharCodes,dduCharCodeLookup:this.dduCharCodeLookup,dduCharCodeLookupOffset:this.dduCharCodeLookupOffset,paddingChar:this.paddingChar,useRepeatPadding:this.useRepeatPadding,bitsPerPadChar:this.bitsPerPadChar,encryptedPipelineVersion:4};}encode(r$1,t){try{return B(t,"encode"),H(r$1),me(r$1,t,{...this.buildEncodeBaseContext(t),compress:a((n,o,i)=>he(this.getAdapter(),n,o,i),"compress"),encrypt:a((n,o)=>Ke(this.getAdapterGatewayContext(),n,o),"encrypt")}).encoded}catch(n){throw r(n,"encode")}}decode(r$1,t){try{B(t,"decode"),q(r$1);let n=this.decodeToUint8Array(r$1,t);return ue(n)}catch(n){throw r(n,"decode")}}decodeToUint8Array(r$1,t){try{B(t,"decode"),q(r$1);let n=this.decodePrelude(r$1,t);return pr(n,t,{...this.buildDecodeBaseContext(t),decrypt:a((o,i)=>Ne(this.getAdapterGatewayContext(),o,i),"decrypt"),decompress:a((o,i,s)=>Fe(this.getAdapter(),o,i,s),"decompress")})}catch(n){throw r(n,"decode")}}async encodeAsync(r$1,t){try{return B(t,"encode"),H(r$1),(await ye(r$1,t,{...this.buildEncodeBaseContext(t),compress:a(async(o,i,s)=>fe(await this.getAsyncAdapter(),o,i,s),"compress"),encrypt:a(async(o,i)=>(await this.getAsyncAdapter(),$e(this.getAdapterGatewayContext(),o,i)),"encrypt")})).encoded}catch(n){throw r(n,"encode")}}async decodeAsync(r$1,t){try{B(t,"decode"),q(r$1);let n=await this.decodeToUint8ArrayAsync(r$1,t);return ue(n)}catch(n){throw r(n,"decode")}}async decodeToUint8ArrayAsync(r$1,t){try{B(t,"decode"),q(r$1);let n=this.decodePrelude(r$1,t);return await mr(n,t,{...this.buildDecodeBaseContext(t),decrypt:a(async(o,i)=>(await this.getAsyncAdapter(),ze(this.getAdapterGatewayContext(),o,i)),"decrypt"),decompress:a(async(o,i,s)=>Ve(await this.getAsyncAdapter(),o,i,s),"decompress")})}catch(n){throw r(n,"decode")}}buildDecodeBaseContext(r){return {encryptionKey:this.encryptionKey,defaultMaxDecompressedBytes:this.defaultMaxDecompressedBytes,reportProgress:a(t=>this.reportProgress(r,t),"reportProgress")}}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,defaultChecksumScope:this.defaultChecksumScope,defaultObfuscate:this.defaultObfuscate,defaultRequireEncryption:this.defaultRequireEncryption,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm}}getStats(r$1,t){try{B(t,"encode"),H(r$1);let n=typeof r$1=="string"?K(r$1):r$1,{encoded:o,compressedSize:i}=me(n,t,{...this.buildEncodeBaseContext(t),compress:a((s,d,c)=>he(this.getAdapter(),s,d,c),"compress"),encrypt:a(s=>new Uint8Array(s.length+kr),"encrypt")});return this.buildEncodeStats(n.length,o.length,i,t)}catch(n){throw r(n,"encode")}}async getStatsAsync(r$1,t){try{B(t,"encode"),H(r$1);let n=typeof r$1=="string"?K(r$1):r$1,{encoded:o,compressedSize:i}=await ye(n,t,{...this.buildEncodeBaseContext(t),compress:a(async(s,d,c)=>fe(await this.getAsyncAdapter(),s,d,c),"compress"),encrypt:a(async s=>new Uint8Array(s.length+kr),"encrypt")});return this.buildEncodeStats(n.length,o.length,i,t)}catch(n){throw r(n,"encode")}}buildEncodeStats(r,t,n,o){let i=r>0?t/r:0,d=(o?.compress??this.defaultCompress)&&n!==void 0&&r>0?n/r:void 0;return {originalSize:r,encodedSize:t,compressedSize:n,compressionRatio:d,expansionRatio:i,charsetSize:this.dduChar.length,bitLength:this.bitLength}}buildEncodeBaseContext(r){return {defaultCompress:this.defaultCompress,defaultChecksum:this.defaultChecksum,defaultChecksumScope:this.defaultChecksumScope,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm,hasEncryptionKey:!!this.encryptionKey,reportProgress:a(t=>this.reportProgress(r,t),"reportProgress"),getEncryptionAAD:a(t=>te({compressionAlgorithm:t}),"getEncryptionAAD"),finalize:a((t,n,o,i,s,d,c,u)=>this.finalizeEncode(t,n,o,i,s,d,c,u,r),"finalize")}}finalizeEncode(r,t,n,o,i,s,d,c,u){this.reportProgress(u,{processedBytes:r.length,totalBytes:r.length,percent:70,stage:"encode"});let l=ur(r,t,n,u,this.payloadCodecContext);return l=ir({encoded:l,options:u,checksum:o,shouldChecksum:i,checksumScope:s,chunkSize:d,chunkSeparator:c,urlSafe:this.urlSafe,shouldObfuscate:a(p=>this.shouldObfuscate(p),"shouldObfuscate"),getObfuscationLayer:a(()=>this.getObfuscationLayer(),"getObfuscationLayer"),assertSafeChunkSeparator:a((p,f)=>this.assertSafeChunkSeparator(p,f),"assertSafeChunkSeparator")}),this.reportProgress(u,{processedBytes:r.length,totalBytes:r.length,percent:100,stage:"done"}),l}decodePrelude(r,t){return nr(r,t,{defaultChecksum:this.defaultChecksum,defaultChunkSeparator:this.defaultChunkSeparator,defaultMaxDecodedBytes:this.defaultMaxDecodedBytes,defaultMaxEncodedChars:this.defaultMaxEncodedChars,urlSafe:this.urlSafe,paddingChar:this.paddingChar,bitLength:this.bitLength,bitsPerPadChar:this.bitsPerPadChar,usePowerOfTwo:this.usePowerOfTwo,dduCharCodeLookup:this.dduCharCodeLookup,dduCharCodeLookupOffset:this.dduCharCodeLookupOffset,charSetSize:this.dduChar.length,encryptionKey:this.encryptionKey,defaultRequireEncryption:this.defaultRequireEncryption,shouldObfuscate:a(n=>this.shouldObfuscate(n),"shouldObfuscate"),deobfuscate:a(n=>this.getObfuscationLayer().deobfuscate(n),"deobfuscate"),decodeChars:a((n,o)=>lr(n,o,this.payloadCodecContext),"decodeChars"),reportDecodeStart:a(n=>{this.reportProgress(t,{processedBytes:0,totalBytes:n,percent:0,stage:"start"});},"reportDecodeStart"),reportBitpackDecode:a((n,o)=>{this.reportProgress(t,{processedBytes:n,totalBytes:o,percent:30,stage:"decode"});},"reportBitpackDecode")})}reportProgress(r,t){(r?.onProgress??this.defaultOnProgress)?.(t);}getAdapter(){return this.adapter===void 0&&this.adapterFactory!==void 0&&(this.adapter=this.adapterFactory()),this.adapter}async getAsyncAdapter(){let r=this.getAdapter();return r!==void 0||this.asyncAdapterFactory===void 0?r:(this.asyncAdapterPromise||(this.asyncAdapterPromise=this.asyncAdapterFactory().then(t=>(this.adapter=t,this.adapterGatewayContext&&(this.adapterGatewayContext.adapter=t),t)).catch(t=>{throw this.asyncAdapterPromise=void 0,t})),this.asyncAdapterPromise)}getAdapterGatewayContext(){if(!this.adapterGatewayContext){let r={adapter:this.getAdapter(),encryptionKey:this.encryptionKey,keyDerivation:this.keyDerivation,encryptionKeyHash:this.encryptionKeyHash,setEncryptionKeyHash:a(t=>{this.encryptionKeyHash=t,r.encryptionKeyHash=t;},"setEncryptionKeyHash")};this.adapterGatewayContext=r;}return this.adapterGatewayContext}getObfuscationLayer(){if(!this.obfuscationLayer){if(!this.obfuscationLayerFactory)throw new n("[Ddu64 obfuscation] No obfuscation layer is wired. Use Ddu64Node/Ddu64Browser (preconfigured), or inject `obfuscationLayerFactory` when constructing Ddu64Core directly.");this.obfuscationLayer=this.obfuscationLayerFactory(hr(this.dduChar,this.paddingChar));}return this.obfuscationLayer}shouldObfuscate(r){return r?.obfuscate??this.defaultObfuscate}assertSafeChunkSeparator(r,t){if(!(t.length===0||t===`
8
+ `||t===`\r
9
+ `||t==="\r")&&r.includes(t))throw new c(`[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.`)}};var vr=class e{static{a(this,"CharsetBuilder");}chars=[];constructor(){}static create(){return new e}static fromUnicodeRange(r,t){return new e().addUnicodeRange(r,t)}static fromString(r){return new e().addString(r)}static base64(){return new e().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")}static base32(){return new e().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")}static uppercase(){return e.fromUnicodeRange(65,90)}static lowercase(){return e.fromUnicodeRange(97,122)}static digits(){return e.fromUnicodeRange(48,57)}static hangulJamo(){return new e().addUnicodeRange(4352,4370).addUnicodeRange(4449,4469).addUnicodeRange(4520,4546)}addUnicodeRange(r,t){if(!Number.isInteger(r)||!Number.isInteger(t)||r<0||t>1114111||r>t)throw new RangeError("Unicode range must use integer code points with 0 <= start <= end <= 0x10FFFF");for(let n=r;n<=t;n++)this.chars.push(String.fromCodePoint(n));return this}addString(r){return typeof r=="string"?this.chars.push(...r):this.chars.push(...r),this}add(...r){return this.chars.push(...r),this}excludeConfusing(){let r=new Set(["0","O","o","1","l","I","i","|","L"]);return this.chars=this.chars.filter(t=>!r.has(t)),this}exclude(...r){let t=new Set(r);return this.chars=this.chars.filter(n=>!t.has(n)),this}excludeUrlUnsafe(){let r=new Set(["+","/","=","?","&","#","%"," "]);return this.chars=this.chars.filter(t=>!r.has(t)),this}unique(){return this.chars=[...new Set(this.chars)],this}shuffle(r){let t=Math.random;if(r!==void 0){let n=r|0||1;t=a(()=>(n^=n<<13,n^=n>>17,n^=n<<5,(n>>>0)/4294967296),"random");}for(let n=this.chars.length-1;n>0;n--){let o=Math.floor(t()*(n+1));[this.chars[n],this.chars[o]]=[this.chars[o],this.chars[n]];}return this}limit(r){if(!Number.isSafeInteger(r)||r<0)throw new RangeError("Charset limit must be a non-negative safe integer");return this.chars=this.chars.slice(0,r),this}limitToPowerOfTwo(){let r=this.chars.length;if(r===0)return this;let t=1<<Math.floor(Math.log2(r));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(r){let t=[...this.chars],n=r;if(n===void 0){let o=["=",".","_","-","~","!"];for(let i of o)if(!t.includes(i)){n=i;break}if(!n)throw new Error("Cannot find suitable padding character")}if(n.length!==1)throw new Error("Padding character must be one UTF-16 code unit");if(t.includes(n))throw new Error("Padding character must not appear in charset");return {charset:t,padding:n}}};export{be as a,qe as b,x as c,zr as d,St as e,Dt as f,hr as g,B as h,xr as i,vr as j};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkJATMOMX5_cjs=require('./chunk-JATMOMX5.cjs'),chunkZTGECGM2_cjs=require('./chunk-ZTGECGM2.cjs'),chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs');var l=44032,f=55203,c=f-l+1;function g(e){if(e.length===0)throw new chunkZTGECGM2_cjs.n("[Ddu64 obfuscation] Alphabet must not be empty.");if(e.length>c)throw new chunkZTGECGM2_cjs.n(`[Ddu64 obfuscation] Alphabet size (${e.length}) exceeds available Hangul syllables (${c}).`);let t=Math.floor(c/e.length),r=new Map;for(let n=0;n<e.length;n++)r.set(e[n],n);return {alphabet:e,syllablesPerChar:t,charToIndex:r}}chunkBCUBYE76_cjs.a(g,"buildSyllableMap");var u=class{static{chunkBCUBYE76_cjs.a(this,"HangulObfuscationLayer");}config;constructor(t){this.config=g(t);}obfuscate(t){if(t.length===0)return "";let r=new Array(t.length);for(let n=0;n<t.length;n++){let o=t[n],s=this.config.charToIndex.get(o);if(s===void 0)throw new chunkZTGECGM2_cjs.n(`[Ddu64 obfuscation] Character "${o}" (U+${o.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase()}) not found in obfuscation alphabet.`);let b=l+s*this.config.syllablesPerChar+n%this.config.syllablesPerChar;r[n]=String.fromCharCode(b);}return r.join("")}deobfuscate(t){if(t.length===0)return "";let r=new Array(t.length);for(let n=0;n<t.length;n++){let o=t.charCodeAt(n),s=o<l||o>f?-1:Math.floor((o-l)/this.config.syllablesPerChar);if(s<0||s>=this.config.alphabet.length)throw new chunkZTGECGM2_cjs.n(`[Ddu64 obfuscation] Invalid syllable at position ${n}: U+${o.toString(16).padStart(4,"0").toUpperCase()} is not in the mapped range.`);r[n]=this.config.alphabet[s];}return r.join("")}};function A(e,t){return new u(chunkJATMOMX5_cjs.g(e,t))}chunkBCUBYE76_cjs.a(A,"createEncoderObfuscationLayer");function x(){let e=globalThis;return e.Deno?.version?.deno?"deno":e.Bun?.version?"bun":e.process?.versions?.node?"node":typeof e.EdgeRuntime=="string"||typeof e.WebSocketPair<"u"&&e.crypto?.subtle?"edge":typeof e.crypto<"u"&&e.crypto?.subtle?"browser":"unknown"}chunkBCUBYE76_cjs.a(x,"detectRuntime");exports.a=u;exports.b=A;exports.c=x;
@@ -0,0 +1 @@
1
+ import {m as m$1}from'./chunk-IZK7KCU7.js';import {a as a$1,d as d$1,b,e}from'./chunk-Q6SCBUV2.js';import {a}from'./chunk-EI7MMDWY.js';var u=new Set;function m(s){if(s.buffer instanceof ArrayBuffer)return s.byteOffset===0&&s.byteLength===s.buffer.byteLength?s.buffer:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);let e=new Uint8Array(s.byteLength);return e.set(s),e.buffer}a(m,"toArrayBuffer");function d(s,e){let r=`${e}:${s}`;if(!u.has(r)){try{e==="compress"&&typeof CompressionStream<"u"?(new CompressionStream(s),u.add(r)):e==="decompress"&&typeof DecompressionStream<"u"&&(new DecompressionStream(s),u.add(r));}catch{u.delete(r);}if(!u.has(r)){let n=s==="brotli"?"Brotli":"Deflate raw",t=e==="compress"?"CompressionStream":"DecompressionStream";throw new m$1(`[Ddu64 ${e}] ${n} ${e}ion is unsupported in the current runtime. ${t} does not support "${s}".`,e)}}return s}a(d,"requireCompressionFormat");var U=class{static{a(this,"BrowserAdapter");}runtime;constructor(e="browser"){this.runtime=e;}async deriveKey(e$1,r){let t=new TextEncoder().encode(e$1);if(a$1(r)==="pbkdf2"){let i=await crypto.subtle.importKey("raw",t,"PBKDF2",false,["deriveBits"]),a=await crypto.subtle.deriveBits({name:"PBKDF2",salt:e(r?.salt),iterations:b(r?.iterations),hash:d$1(r?.hash)},i,256);return new Uint8Array(a)}let c=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(c)}async encrypt(e,r,n){let t=crypto.getRandomValues(new Uint8Array(12)),c=await crypto.subtle.importKey("raw",m(r),{name:"AES-GCM"},false,["encrypt"]),i={name:"AES-GCM",iv:t,tagLength:128};n&&n.length>0&&(i.additionalData=m(n));let a=await crypto.subtle.encrypt(i,c,m(e)),o=new Uint8Array(a),y=o.subarray(0,o.length-16),f=o.subarray(o.length-16),p=new Uint8Array(28+y.length);return p.set(t,0),p.set(f,12),p.set(y,28),p}async decrypt(e,r,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 t=e.subarray(0,12),c=e.subarray(12,28),i=e.subarray(28),a=new Uint8Array(i.length+16);a.set(i,0),a.set(c,i.length);let o=await crypto.subtle.importKey("raw",m(r),{name:"AES-GCM"},false,["decrypt"]);try{let y={name:"AES-GCM",iv:m(t),tagLength:128};n&&n.length>0&&(y.additionalData=m(n));let f=await crypto.subtle.decrypt(y,o,m(a));return new Uint8Array(f)}catch{throw new Error("[Ddu64 decrypt] Decryption failed: data tampering or incorrect key.")}}randomBytes(e){return crypto.getRandomValues(new Uint8Array(e))}async deflate(e,r){let n=d("deflate-raw","compress"),t=new CompressionStream(n);return this.writeAndReadStream(t,e)}async inflate(e,r){let n=d("deflate-raw","decompress"),t=new DecompressionStream(n);return this.writeAndReadStream(t,e,r)}async brotliCompress(e,r){let n=d("brotli","compress"),t=new CompressionStream(n);return this.writeAndReadStream(t,e)}async brotliDecompress(e,r){let n=d("brotli","decompress"),t=new DecompressionStream(n);return this.writeAndReadStream(t,e,r)}async writeAndReadStream(e,r,n){let t=e.writable.getWriter(),c=e.readable.getReader(),i=(async()=>{await t.write(new Uint8Array(m(r))),await t.close();})(),a=this.readAllChunks(c,n);try{let[o]=await Promise.all([a,i]);return o}catch(o){throw await c.cancel(o).catch(()=>{}),await t.abort(o).catch(()=>{}),o}}async readAllChunks(e,r){let n=[],t=0;for(;;){let{done:a,value:o}=await e.read();if(a)break;if(t+=o.length,r!==void 0&&t>r)throw new Error(`[Ddu64 decompress] Decompressed size exceeds limit. Estimated ${t}+ bytes exceeds maximum of ${r} bytes.`);n.push(o);}if(n.length===1)return n[0];let c=new Uint8Array(t),i=0;for(let a of n)c.set(a,i),i+=a.length;return c}};export{U as a};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkBUR4IORD_cjs=require('./chunk-BUR4IORD.cjs'),chunkJATMOMX5_cjs=require('./chunk-JATMOMX5.cjs'),chunkZMNWFYGY_cjs=require('./chunk-ZMNWFYGY.cjs'),chunkZTGECGM2_cjs=require('./chunk-ZTGECGM2.cjs'),chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs');var R=class extends chunkJATMOMX5_cjs.i{static{chunkBCUBYE76_cjs.a(this,"Ddu64SecureBrowser");}constructor(e,r,c){let t=chunkJATMOMX5_cjs.b(e,r,c),p={...t.dduOptions,...t.dduChar!==void 0?{dduChar:t.dduChar}:{},...t.paddingChar!==void 0?{paddingChar:t.paddingChar}:{},adapterFactory:t.dduOptions?.adapterFactory??(()=>new chunkZMNWFYGY_cjs.a),obfuscationLayerFactory:t.dduOptions?.obfuscationLayerFactory??(y=>new chunkBUR4IORD_cjs.a(y))};super(p);}};var H=64*1024*1024,W=64*1024*1024;function G(u,e){chunkJATMOMX5_cjs.h(e,"stream");let r=u.getCharSetInfo(),c=e?.compress??r.defaultCompress,t=r.hasEncryptionKey,p=e?.checksum??r.defaultChecksum,y=c?e?.compressionAlgorithm??r.defaultCompressionAlgorithm:void 0,n=r.paddingChar,g=chunkJATMOMX5_cjs.c(e?.maxBufferedBytes,H,true,"maxBufferedBytes"),f=r.usePowerOfTwo&&!c&&!t&&!p,m=r.bitLength,i=8;for(;i!==0;){let s=m%i;m=i,i=s;}let h=r.bitLength/m,b=false,B=[],A=0,a=null;return new TransformStream({async transform(s,o){if(f){if(!b){let S=chunkJATMOMX5_cjs.e(n,{compressionAlgorithm:void 0,encrypted:false});o.enqueue(S),b=true;}let d;a&&a.length>0?(d=new Uint8Array(a.length+s.length),d.set(a,0),d.set(s,a.length)):d=s;let l=Math.floor(d.length/h)*h;if(l>0){let S=d.subarray(0,l),w=await u.encodeAsync(S,{compress:false,encrypt:false,checksum:false,chunkSize:0,chunkSeparator:void 0,omitFooter:true});o.enqueue(w);}l<d.length?a=d.slice(l):a=null;}else {if(A+s.length>g){o.error(new chunkZTGECGM2_cjs.l(`[WebStreams encode] Buffered input exceeds limit. Limit: ${g} bytes`,"stream"));return}B.push(s),A+=s.length;}},async flush(s){try{if(f){if(!b){let o=chunkJATMOMX5_cjs.e(n,{compressionAlgorithm:void 0,encrypted:!1});s.enqueue(o);}if(a&&a.length>0){let o=await u.encodeAsync(a,{compress:!1,encrypt:!1,checksum:!1,chunkSize:0,chunkSeparator:void 0});s.enqueue(o);}a=null;}else {let o=chunkJATMOMX5_cjs.e(n,{compressionAlgorithm:y,encrypted:t});s.enqueue(o);let d=new Uint8Array(A),l=0;for(let w of B)d.set(w,l),l+=w.length;let S=await u.encodeAsync(d,{...e,compress:c,encrypt:t,checksum:p,chunkSize:0,chunkSeparator:void 0});S.length>0&&s.enqueue(S),B=[],A=0;}}catch(o){s.error(chunkZTGECGM2_cjs.r(o,"stream"));}}})}chunkBCUBYE76_cjs.a(G,"createReadableEncodeStream");function J(u,e){chunkJATMOMX5_cjs.h(e,"stream");let r=u.getCharSetInfo(),c=r.paddingChar,t=chunkJATMOMX5_cjs.d(c),p=e?.checksum??r.defaultChecksum,y=chunkJATMOMX5_cjs.c(e?.maxBufferedChars,W,true,"maxBufferedChars"),n="",g=false,f=null;return new TransformStream({async transform(m,i){try{if(n+=m,n.length>y)throw new chunkZTGECGM2_cjs.l(`[WebStreams decode] Buffered encoded input exceeds limit. Limit: ${y} characters`,"stream");if(!g&&n.length>=t){if(!n.startsWith(c))throw new Error("[WebStreams decode] Invalid or missing stream header");if(f=chunkJATMOMX5_cjs.f(n,c),f===null)throw new Error("[WebStreams decode] Invalid or missing stream header");if(f.encrypted&&!r.hasEncryptionKey)throw new Error("[WebStreams decode] Encrypted stream requires an encryptionKey");g=!0,n=n.slice(t);}}catch(h){i.error(chunkZTGECGM2_cjs.r(h,"stream"));}},async flush(m){try{if(!g){if(n.length===0)return;throw new Error("[WebStreams decode] Incomplete stream header")}let i=f.compressionAlgorithm,h=await u.decodeToUint8ArrayAsync(n,{...e,compress:e?.compress,compressionAlgorithm:i,checksum:p,chunkSize:void 0,chunkSeparator:void 0});h.length>0&&m.enqueue(h),n="";}catch(i){m.error(chunkZTGECGM2_cjs.r(i,"stream"));}}})}chunkBCUBYE76_cjs.a(J,"createReadableDecodeStream");exports.a=R;exports.b=G;exports.c=J;
@@ -0,0 +1 @@
1
+ import {a as a$1}from'./chunk-XVV2OPRV.js';import {i,b,h,c,e,d,f}from'./chunk-B4QRMN45.js';import {a as a$2}from'./chunk-C2AT5XRJ.js';import {r,l}from'./chunk-IZK7KCU7.js';import {a}from'./chunk-EI7MMDWY.js';var R=class extends i{static{a(this,"Ddu64SecureBrowser");}constructor(e,r,c){let t=b(e,r,c),p={...t.dduOptions,...t.dduChar!==void 0?{dduChar:t.dduChar}:{},...t.paddingChar!==void 0?{paddingChar:t.paddingChar}:{},adapterFactory:t.dduOptions?.adapterFactory??(()=>new a$2),obfuscationLayerFactory:t.dduOptions?.obfuscationLayerFactory??(y=>new a$1(y))};super(p);}};var H=64*1024*1024,W=64*1024*1024;function G(u,e$1){h(e$1,"stream");let r$1=u.getCharSetInfo(),c$1=e$1?.compress??r$1.defaultCompress,t=r$1.hasEncryptionKey,p=e$1?.checksum??r$1.defaultChecksum,y=c$1?e$1?.compressionAlgorithm??r$1.defaultCompressionAlgorithm:void 0,n=r$1.paddingChar,g=c(e$1?.maxBufferedBytes,H,true,"maxBufferedBytes"),f=r$1.usePowerOfTwo&&!c$1&&!t&&!p,m=r$1.bitLength,i=8;for(;i!==0;){let s=m%i;m=i,i=s;}let h$1=r$1.bitLength/m,b=false,B=[],A=0,a=null;return new TransformStream({async transform(s,o){if(f){if(!b){let S=e(n,{compressionAlgorithm:void 0,encrypted:false});o.enqueue(S),b=true;}let d;a&&a.length>0?(d=new Uint8Array(a.length+s.length),d.set(a,0),d.set(s,a.length)):d=s;let l=Math.floor(d.length/h$1)*h$1;if(l>0){let S=d.subarray(0,l),w=await u.encodeAsync(S,{compress:false,encrypt:false,checksum:false,chunkSize:0,chunkSeparator:void 0,omitFooter:true});o.enqueue(w);}l<d.length?a=d.slice(l):a=null;}else {if(A+s.length>g){o.error(new l(`[WebStreams encode] Buffered input exceeds limit. Limit: ${g} bytes`,"stream"));return}B.push(s),A+=s.length;}},async flush(s){try{if(f){if(!b){let o=e(n,{compressionAlgorithm:void 0,encrypted:!1});s.enqueue(o);}if(a&&a.length>0){let o=await u.encodeAsync(a,{compress:!1,encrypt:!1,checksum:!1,chunkSize:0,chunkSeparator:void 0});s.enqueue(o);}a=null;}else {let o=e(n,{compressionAlgorithm:y,encrypted:t});s.enqueue(o);let d=new Uint8Array(A),l=0;for(let w of B)d.set(w,l),l+=w.length;let S=await u.encodeAsync(d,{...e$1,compress:c$1,encrypt:t,checksum:p,chunkSize:0,chunkSeparator:void 0});S.length>0&&s.enqueue(S),B=[],A=0;}}catch(o){s.error(r(o,"stream"));}}})}a(G,"createReadableEncodeStream");function J(u,e){h(e,"stream");let r$1=u.getCharSetInfo(),c$1=r$1.paddingChar,t=d(c$1),p=e?.checksum??r$1.defaultChecksum,y=c(e?.maxBufferedChars,W,true,"maxBufferedChars"),n="",g=false,f$1=null;return new TransformStream({async transform(m,i){try{if(n+=m,n.length>y)throw new l(`[WebStreams decode] Buffered encoded input exceeds limit. Limit: ${y} characters`,"stream");if(!g&&n.length>=t){if(!n.startsWith(c$1))throw new Error("[WebStreams decode] Invalid or missing stream header");if(f$1=f(n,c$1),f$1===null)throw new Error("[WebStreams decode] Invalid or missing stream header");if(f$1.encrypted&&!r$1.hasEncryptionKey)throw new Error("[WebStreams decode] Encrypted stream requires an encryptionKey");g=!0,n=n.slice(t);}}catch(h){i.error(r(h,"stream"));}},async flush(m){try{if(!g){if(n.length===0)return;throw new Error("[WebStreams decode] Incomplete stream header")}let i=f$1.compressionAlgorithm,h=await u.decodeToUint8ArrayAsync(n,{...e,compress:e?.compress,compressionAlgorithm:i,checksum:p,chunkSize:void 0,chunkSeparator:void 0});h.length>0&&m.enqueue(h),n="";}catch(i){m.error(r(i,"stream"));}}})}a(J,"createReadableDecodeStream");export{R as a,G as b,J as c};
@@ -0,0 +1,9 @@
1
+ 'use strict';var chunkZTGECGM2_cjs=require('./chunk-ZTGECGM2.cjs'),chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs');var be=(n=>(n.DDU="ddu",n.DDU_V1="ddu_v1",n.ONECHARSET="oneCharSet",n))(be||{}),de={dduSetSymbol:"ddu",usePowerOfTwo:true,requiredLength:64};function Ae(e,r){return e<=1?0:r?Math.floor(Math.log2(e)):Math.ceil(Math.log2(e))}chunkBCUBYE76_cjs.a(Ae,"calculateBitLength");function we(e){return e>0&&(e&e-1)===0}chunkBCUBYE76_cjs.a(we,"isPowerOfTwo");function Pe(e){return e<31?1<<e:Math.pow(2,e)}chunkBCUBYE76_cjs.a(Pe,"maxValueForBitLength");var Br=(()=>{let e=new Uint32Array(256);for(let r=0;r<256;r++){let t=r;for(let n=0;n<8;n++)t=t>>>1^(t&1?3988292384:0);e[r]=t;}return e})();function R(e){let r=4294967295;for(let t=0;t<e.length;t++)r=r>>>8^Br[(r^e[t])&255];return ((r^4294967295)>>>0).toString(16).padStart(8,"0")}chunkBCUBYE76_cjs.a(R,"calculateCRC32");function ce(e,r){let t=Math.max(e.length,r.length),n=e.length^r.length;for(let o=0;o<t;o++){let i=o<e.length?e.charCodeAt(o):0,s=o<r.length?r.charCodeAt(o):0;n|=i^s;}return n===0}chunkBCUBYE76_cjs.a(ce,"constantTimeEquals");var Se=["-","_","."];function De(e){return e.length===0?e:e.replaceAll("+","-").replaceAll("/","_").replaceAll("=",".")}chunkBCUBYE76_cjs.a(De,"toUrlSafe");function Ee(e){return e.length===0?e:e.replaceAll("-","+").replaceAll("_","/").replaceAll(".","=")}chunkBCUBYE76_cjs.a(Ee,"fromUrlSafe");function ke(e,r,t){if(r<=0||e.length<=r)return e;let n=Math.ceil(e.length/r),o=new Array(n*2-1),i=0;for(let s=0;s<e.length;s+=r)o[i++]=e.slice(s,s+r),s+r<e.length&&(o[i++]=t);return o.join("")}chunkBCUBYE76_cjs.a(ke,"splitIntoChunks");function xe(e,r){if(e.length===0)return e;let t=r&&r!==`
2
+ `&&r!==`\r
3
+ `&&r!=="\r"?r:"",n=e.includes(`
4
+ `)||e.includes("\r"),o=t.length>0&&e.includes(t);if(!n&&!o)return e;let i=n?e.replace(/[\r\n]/g,""):e;return o&&(i=i.replaceAll(t,"")),i}chunkBCUBYE76_cjs.a(xe,"removeChunks");var ve={"":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 Be(e){return Object.prototype.hasOwnProperty.call(ve,e)}chunkBCUBYE76_cjs.a(Be,"isKnownCodaChar");function Ur(e,r){let t=e.charCodeAt(0);if(t<44032||t>55203)return e;let n=t-(t-44032)%28,o=ve[r]??0;return String.fromCharCode(n+o)}chunkBCUBYE76_cjs.a(Ur,"combineCoda");function X(e,r){let t=new Array(e.length*r.length),n=0;for(let o of e)for(let i of r)t[n++]=Ur(o,i);return t}chunkBCUBYE76_cjs.a(X,"buildCodaCharset");function J(e,r){let n=e===void 0||!Number.isFinite(e)?6:Math.floor(e);return Math.min(r==="brotli"?11:9,Math.max(0,n))}chunkBCUBYE76_cjs.a(J,"normalizeCompressionLevel");var Or=new TextEncoder,Ir=new TextDecoder;function K(e){return Or.encode(e)}chunkBCUBYE76_cjs.a(K,"stringToBytes");function ue(e){return Ir.decode(e)}chunkBCUBYE76_cjs.a(ue,"bytesToString");var Rr={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},Lr={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}},Tr={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 Z(e){switch(e){case "ddu":return Rr;case "ddu_v1":return Lr;case "oneCharSet":return Tr;default:return}}chunkBCUBYE76_cjs.a(Z,"getCharSet");function Oe(e,r,t,n){let o=chunkBCUBYE76_cjs.a((i,s,d,c,u)=>{if((t?.usePowerOfTwo===void 0?d>0&&(d&d-1)===0:t.usePowerOfTwo&&d>0)&&d>0){let f=Math.floor(Math.log2(d)),h=1<<f;return {charSet:i.length===h?i:i.slice(0,h),padding:s,requiredLength:h,bitLength:f,isPredefined:c,useRepeatPadding:u}}return {charSet:i.length===d?i:i.slice(0,d),padding:s,requiredLength:d,bitLength:d>0?Math.ceil(Math.log2(d)):0,isPredefined:c,useRepeatPadding:u}},"buildMeta");try{let i=e??t?.dduChar,s=r??t?.paddingChar;if(i!==void 0){if(!s)throw new Error("[Ddu64 Constructor] paddingChar is required when dduChar is provided.");let f=typeof i=="string"?[...i]:[...i],h=t?.codaChar,m=h!==void 0&&h.length>0,y=m?!0:t?.useRepeatPadding??!1;if(m){if(n){let D=h.filter(b=>!Be(b));if(D.length>0)throw new Error(`[Ddu64 Constructor] Unknown coda character(s): [${D.join(", ")}]. Coda must be empty ("") or a Hangul jongseong jamo (\u3131, \u3132, \u3133, \u2026 \u314E). Unknown coda collapses to no-coda and can create duplicate symbols.`)}f=X(f,h);}if(n&&new Set(f).size!==f.length){let b=f.filter((w,P)=>f.indexOf(w)!==P);throw new Error(`[Ddu64 Constructor] Character set contains duplicate characters: [${[...new Set(b)].join(", ")}]`)}let g=t?.requiredLength??f.length;if(f.length<g)throw new Error("[Ddu64 Constructor] Insufficient characters.");return o(f,s,g,!1,y)}let d=t?.dduSetSymbol??de.dduSetSymbol??"ddu",c=Z(d);if(!c)throw new Error(`CharSet with symbol ${d} not found`);let u=c.codaChar?X(c.charSet,c.codaChar):c.charSet,l=o(u,c.paddingChar,c.maxRequiredLength,!0,c.useRepeatPadding),p=c.encodingProfile;return p?(l.encodingProfile=p,l.bitLength=p.bitLength,l.usePowerOfTwo=p.usePowerOfTwo,l.bitsPerPadChar=p.bitsPerPadChar):(l.bitsPerPadChar=c.bitsPerPadChar,l.usePowerOfTwo=c.usePowerOfTwo,c.usePowerOfTwo===!1&&(l.bitLength=c.bitLength)),l}catch(i){if(n)throw i;return le(t)}}chunkBCUBYE76_cjs.a(Oe,"resolveInitialCharSet");function Ie(e,r,t){let n=[e,null];for(let i of n){let s=i?{...i}:le(t);try{let d=s.charSet,c=s.requiredLength,u=Array.from(new Set(d));if(u.length!==d.length){if(r){let f=d.filter((h,m)=>d.indexOf(h)!==m);throw new Error(`[Ddu64 normalizeCharSet] Character set contains duplicate characters: [${[...new Set(f)].join(", ")}]`)}d=u,s.isPredefined||(c=d.length);}if(d.length<c)throw new Error(`[Ddu64 normalizeCharSet] Insufficient characters. Required: ${c}, Has: ${d.length}`);if(c<2)throw new Error("[Ddu64 normalizeCharSet] At least 2 unique characters required.");if(d.find(f=>f.length!==1)){if(r)throw new Error("[Ddu64 normalizeCharSet] Multi-character symbols are not supported.");continue}if(s.padding.length!==1)throw new Error(`[Ddu64 normalizeCharSet] Padding length mismatch. Expected 1, got ${s.padding.length}`);if(d.includes(s.padding)){if(r)throw new Error(`[Ddu64 normalizeCharSet] Padding character "${s.padding}" conflicts with charset.`);if(d=d.filter(f=>f!==s.padding),d.length<c||d.length<2)throw new Error(`[Ddu64 normalizeCharSet] Padding removal left too few characters. Required: ${c}, Has: ${d.length}`)}for(let f of d){if(f.includes(`
5
+ `)||f.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(Ue(f))throw new Error(`[Ddu64 normalizeCharSet] Lone surrogate code unit (U+${f.charCodeAt(0).toString(16).toUpperCase()}) is not allowed; it corrupts on UTF-8/URL/JSON boundaries.`)}if(s.padding.includes(`
6
+ `)||s.padding.includes("\r"))throw new Error("[Ddu64 normalizeCharSet] Newline and carriage return characters are reserved.");if(Ue(s.padding))throw new Error("[Ddu64 normalizeCharSet] Padding character must not be a lone surrogate code unit.");return {charSet:d.length===c?d:d.slice(0,c),padding:s.padding,isPredefined:s.isPredefined}}catch(d){if(r)throw d}}let o=le(t);return {charSet:o.charSet.slice(0,o.requiredLength),padding:o.padding,isPredefined:true}}chunkBCUBYE76_cjs.a(Ie,"normalizeCharSet");function Re(e,r,t){for(let n of Se){for(let o of e)if(o.includes(n)){let i=`[Ddu64 Constructor] URL-Safe mode conflict: charset character "${o}" contains "${n}".`;if(t)throw new Error(i);return false}if(r.includes(n)){let o=`[Ddu64 Constructor] URL-Safe mode conflict: padding character "${r}" contains "${n}".`;if(t)throw new Error(o);return false}}return true}chunkBCUBYE76_cjs.a(Re,"isUrlSafeCompatible");function Ue(e){if(e.length!==1)return false;let r=e.charCodeAt(0);return r>=55296&&r<=57343}chunkBCUBYE76_cjs.a(Ue,"isLoneSurrogate");function le(e){let r=e?.dduSetSymbol??de.dduSetSymbol??"oneCharSet",t=Z(r)??Z("oneCharSet");if(!t)throw new Error("Critical: No fallback CharSet available");return {charSet:t.codaChar?X(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}}chunkBCUBYE76_cjs.a(le,"getFallbackCharSet");var Mr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Le(e,r,t,n){return t&&n===6&&r==="="&&e.join("")===Mr}chunkBCUBYE76_cjs.a(Le,"canUseNativeBase64FastPath");function Te(e){let r=Kr(e);if(r===null)return null;let t=0,n=r.length;for(;n>0&&r[n-1]==="=";)t++,n--;return {payload:r.slice(0,n),paddingBits:t===2?4:t===1?2:0}}chunkBCUBYE76_cjs.a(Te,"encodeNativeBase64");function Me(e,r,t){let n=r===4?2:r===2?1:r===0?0:-1;if(n<0)return null;for(let o=0;o<e.length;o++)if(!t(e.charCodeAt(o)))return null;return Nr(e+"=".repeat(n))}chunkBCUBYE76_cjs.a(Me,"decodeNativeBase64");function Kr(e){let r=e.toBase64;if(typeof r=="function")return r.call(e);let t=globalThis.Buffer;return t?.from?t.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"):null}chunkBCUBYE76_cjs.a(Kr,"bytesToBase64");function Nr(e){let r=Uint8Array;if(typeof r.fromBase64=="function")return r.fromBase64(e);let t=globalThis.Buffer;if(t?.from){let n=t.from(e,"base64");return new Uint8Array(n)}return null}chunkBCUBYE76_cjs.a(Nr,"base64ToBytes");function Q(e,r){if(!e)throw new chunkZTGECGM2_cjs.m("[Ddu64 adapter] No platform adapter available. Use encodeAsync()/decodeAsync() in browser environments, or provide an adapter via options.adapter.",r);return e}chunkBCUBYE76_cjs.a(Q,"requireSyncAdapter");function Ke(e,r,t){try{let n=Q(e.adapter,"encode");if(!n.encryptSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 encrypt] Sync encryption unavailable. Use encodeAsync() in browser environments.","encode");let o=_e(e,n,"encrypt","encode");return n.encryptSync(r,o,t)}catch(n){throw chunkZTGECGM2_cjs.p(n)?n:new chunkZTGECGM2_cjs.g(chunkZTGECGM2_cjs.q(n),n)}}chunkBCUBYE76_cjs.a(Ke,"runEncryptSync");function Ne(e,r,t){try{let n=Q(e.adapter,"decode");if(!n.decryptSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 decrypt] Sync decryption unavailable. Use decodeAsync() in browser environments.","decode");let o=_e(e,n,"decrypt","decode");return n.decryptSync(r,o,t)}catch(n){throw chunkZTGECGM2_cjs.p(n)?n:new chunkZTGECGM2_cjs.h(chunkZTGECGM2_cjs.q(n),n)}}chunkBCUBYE76_cjs.a(Ne,"runDecryptSync");function he(e,r,t,n){try{let o=Q(e,"encode");if(t==="brotli"){if(!o.brotliCompressSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 compress] Brotli compression is unavailable in the current runtime.","encode");return o.brotliCompressSync(r,n)}if(!o.deflateSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 compress] Sync compression unavailable. Use encodeAsync() in browser environments.","encode");return o.deflateSync(r,n)}catch(o){throw chunkZTGECGM2_cjs.p(o)?o:new chunkZTGECGM2_cjs.e(chunkZTGECGM2_cjs.q(o),o)}}chunkBCUBYE76_cjs.a(he,"runCompressSync");function Fe(e,r,t,n){try{let o=Q(e,"decode");if(t==="brotli"){if(!o.brotliDecompressSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.","decode");return o.brotliDecompressSync(r,n)}if(!o.inflateSync)throw new chunkZTGECGM2_cjs.m("[Ddu64 decompress] Sync decompression unavailable. Use decodeAsync() in browser environments.","decode");return o.inflateSync(r,n)}catch(o){throw chunkZTGECGM2_cjs.p(o)?o:new chunkZTGECGM2_cjs.f(chunkZTGECGM2_cjs.q(o),o)}}chunkBCUBYE76_cjs.a(Fe,"runDecompressSync");function _e(e,r,t,n){if(e.encryptionKeyHash)return e.encryptionKeyHash;if(!r.deriveKeySync){let i=t==="encrypt"?"encodeAsync":"decodeAsync";throw new chunkZTGECGM2_cjs.m(`[Ddu64 ${t}] Sync key derivation unavailable. Use ${i}() in browser environments.`,n)}let o=r.deriveKeySync(e.encryptionKey,e.keyDerivation);return e.setEncryptionKeyHash(o),o}chunkBCUBYE76_cjs.a(_e,"getSyncKeyHash");async function $e(e,r,t){try{let n=ee(e.adapter,"encode"),o=await He(e,n);return await n.encrypt(r,o,t)}catch(n){throw re(n,"encrypt")}}chunkBCUBYE76_cjs.a($e,"encryptAsyncWithAdapter");async function ze(e,r,t){try{let n=ee(e.adapter,"decode"),o=await He(e,n);return await n.decrypt(r,o,t)}catch(n){throw re(n,"decrypt")}}chunkBCUBYE76_cjs.a(ze,"decryptAsyncWithAdapter");async function fe(e,r,t,n){try{let o=ee(e,"encode");if(t==="brotli"){if(!o.brotliCompress)throw new chunkZTGECGM2_cjs.m("[Ddu64 compress] Brotli compression is unavailable in the current runtime.","encode");return await o.brotliCompress(r,n)}return await o.deflate(r,n)}catch(o){throw re(o,"compress")}}chunkBCUBYE76_cjs.a(fe,"compressAsyncWithAdapter");async function Ve(e,r,t,n){try{let o=ee(e,"decode");if(t==="brotli"){if(!o.brotliDecompress)throw new chunkZTGECGM2_cjs.m("[Ddu64 decompress] Brotli decompression is unavailable in the current runtime.","decode");return await o.brotliDecompress(r,n)}return await o.inflate(r,n)}catch(o){throw re(o,"decompress")}}chunkBCUBYE76_cjs.a(Ve,"decompressAsyncWithAdapter");function ee(e,r){if(!e)throw new chunkZTGECGM2_cjs.m("[Ddu64 adapter] No platform adapter available. Use @ddunigma/node or @ddunigma/node/browser, or provide an adapter via options.adapter.",r);return e}chunkBCUBYE76_cjs.a(ee,"requireAsyncAdapter");async function He(e,r){if(e.encryptionKeyHash)return e.encryptionKeyHash;if(e.encryptionKeyHashPromise)return e.encryptionKeyHashPromise;let t=r.deriveKey(e.encryptionKey,e.keyDerivation).then(n=>(e.setEncryptionKeyHash(n),n)).finally(()=>{e.encryptionKeyHashPromise=void 0;});return e.encryptionKeyHashPromise=t,t}chunkBCUBYE76_cjs.a(He,"getAsyncKeyHash");function re(e,r){if(chunkZTGECGM2_cjs.p(e))return e;let t=chunkZTGECGM2_cjs.q(e);switch(r){case "compress":return new chunkZTGECGM2_cjs.e(t,e);case "decompress":return new chunkZTGECGM2_cjs.f(t,e);case "encrypt":return new chunkZTGECGM2_cjs.g(t,e);case "decrypt":return new chunkZTGECGM2_cjs.h(t,e)}}chunkBCUBYE76_cjs.a(re,"toAsyncGatewayError");function qe(e,r,t){return e!=null&&typeof e=="object"&&!Array.isArray(e)?{dduChar:void 0,paddingChar:void 0,dduOptions:e}:{dduChar:e,paddingChar:r,dduOptions:t}}chunkBCUBYE76_cjs.a(qe,"resolveConstructorArgs");var Ge=new Map;function je(e,r=false){let t=r?e.join(""):void 0;if(t!==void 0){let u=Ge.get(t);if(u)return u}let n=new Uint16Array(e.length),o=65535,i=0;for(let u=0;u<e.length;u++){let l=e[u].charCodeAt(0);n[u]=l,l>i&&(i=l),l<o&&(o=l);}let s=e.length>0?o:0,d=new Int32Array(i-s+1);d.fill(-1);for(let u=0;u<e.length;u++)d[n[u]-s]=u;let c={charCodeLookup:d,charCodes:n,lookupOffset:s};return t!==void 0&&Ge.set(t,c),c}chunkBCUBYE76_cjs.a(je,"buildCharsetLookupTables");function N(e,r,t){let n=r-t;return n>=0&&n<e.length?e[n]:-1}chunkBCUBYE76_cjs.a(N,"lookupCharIndex");var Ye=8;function We(e,r,t,n){return Math.ceil(e/(n?1:2))*t-r}chunkBCUBYE76_cjs.a(We,"decodedBitCount");function x(e,r,t,n){if(e===void 0)return r;if(e===Number.POSITIVE_INFINITY)return Number.POSITIVE_INFINITY;if(!Number.isFinite(e)||e<=0){if(t)throw new chunkZTGECGM2_cjs.k(`[Ddu64 options] Invalid ${n}. Must be a positive finite number or Infinity.`);return r}return Math.floor(e)}chunkBCUBYE76_cjs.a(x,"normalizeLimit");function Xe(e,r,t,n){if(e===0)return 0;if(r<0||r>=t)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid padding bits: ${r}`);let o=We(e,r,t,n);if(o<0)throw new chunkZTGECGM2_cjs.d("[Ddu64 decode] Invalid decoded bit length");return Math.ceil(o/Ye)}chunkBCUBYE76_cjs.a(Xe,"estimateDecodedBytes");function Je(e,r){if(!r&&e.length%2!==0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid encoded length for variable charset. Expected multiple of 2, got ${e.length}`)}chunkBCUBYE76_cjs.a(Je,"assertEncodedInputAligned");function Ze(e,r,t,n){if(e.length===0)return;let o=We(e.length,r,t,n);if(o<0||o%Ye!==0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid encoded bit length. Expected a whole number of bytes, got ${o} bits.`)}chunkBCUBYE76_cjs.a(Ze,"assertDecodedBitLength");function Qe(e,r,t,n,o,i){if(r===0)return;if(e.length===0)throw new chunkZTGECGM2_cjs.d("[Ddu64 decode] Invalid padding bits without payload");let s=(1<<r)-1,d;if(t){let c=e[e.length-1],u=N(n,c.charCodeAt(0),i);if(u<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${c}" at ${e.length-1}`);d=u;}else {let c=e[e.length-2],u=e[e.length-1],l=N(n,c.charCodeAt(0),i),p=N(n,u.charCodeAt(0),i);if(l<0||p<0)throw new chunkZTGECGM2_cjs.d("[Ddu64 decode] Invalid character in final encoded chunk");d=l*o+p;}if((d&s)!==0)throw new chunkZTGECGM2_cjs.d("[Ddu64 decode] Invalid non-zero padding bits in final symbol")}chunkBCUBYE76_cjs.a(Qe,"assertCanonicalPadding");var F="DDS1",_="ELYSIA",$="GRISEO";var Fr=new TextEncoder;function L(e,r,t){let n=t-r.length;if(n<0)return false;for(let o=0;o<r.length;o++)if(e.charCodeAt(n+o)!==r.charCodeAt(o))return false;return true}chunkBCUBYE76_cjs.a(L,"endsWithAt");function er(e,r,t,n=2){let o=e.length,i=r.length,s={cleanedInput:e,paddingBits:0,isEncrypted:false,pipelineVersion:2};if(i===0||o<i)return s;let c=Math.max(0,t-1).toString().length;for(let u=Math.min(c,o);u>=1;u--){let l=o-u,p=true;for(let b=l;b<o;b++){let w=e.charCodeAt(b);if(w<48||w>57){p=false;break}}if(!p||u>1&&e.charCodeAt(l)===48)continue;let f=0;for(let b=l;b<o;b++)f=f*10+(e.charCodeAt(b)-48);if(f>=t)continue;let h=l,m=false,y,g=2;h>=2&&L(e,"V4",h)?(g=4,h-=2):h>=2&&L(e,"V3",h)&&(g=3,h-=2),h>=3&&L(e,"ENC",h)&&(m=true,h-=3),h>=_.length&&L(e,_,h)?(y="deflate",h-=_.length):h>=$.length&&L(e,$,h)&&(y="brotli",h-=$.length);let D=h-i;if(D>=0&&L(e,r,h))return {cleanedInput:e.substring(0,D),paddingBits:f,compressionAlgorithm:y,isEncrypted:m,pipelineVersion:g}}if(L(e,r,o)){let u=0,l=o;for(;l>=i&&L(e,r,l);)u++,l-=i;if(u>0){let p=u*n;if(p<t)return {cleanedInput:e.substring(0,l),paddingBits:p,isEncrypted:false,pipelineVersion:2}}}return s}chunkBCUBYE76_cjs.a(er,"parseFooter");function _r(e){let r=e.lastIndexOf("CHK");if(r===-1)return {data:e,checksum:null};let t=e.slice(r+3);return t.length!==8||!/^[0-9a-f]+$/i.test(t)?{data:e,checksum:null}:{data:e.slice(0,r),checksum:t.toLowerCase()}}chunkBCUBYE76_cjs.a(_r,"extractChecksum");var $r=/^[0-9a-f]{8}$/i;function rr(e){let r=e.length;if(r>=11){let n=e.charCodeAt(r-11),o=e.charCodeAt(r-10),i=e[r-9];if(n===67&&o===75&&(i==="P"||i==="O")){let s=e.slice(r-8);if($r.test(s))return {data:e.slice(0,r-11),checksum:s.toLowerCase(),scope:i==="P"?"plaintext":"output"}}}let t=_r(e);return {data:t.data,checksum:t.checksum,scope:null}}chunkBCUBYE76_cjs.a(rr,"extractScopedChecksum");function zr(e){return e.length*2+F.length+2}chunkBCUBYE76_cjs.a(zr,"getStreamHeaderLength");function St(e,r){let t=r.compressionAlgorithm==="brotli"?"B":r.compressionAlgorithm==="deflate"?"D":"N",n=r.encrypted?"1":"0";return `${e}${F}${t}${n}${e}`}chunkBCUBYE76_cjs.a(St,"buildStreamHeader");function Dt(e,r){let t=zr(r);if(e.length<t||!e.startsWith(r))return null;let n=r.length;if(e.slice(n,n+F.length)!==F)throw new Error("[wireFormat] Invalid stream header magic");let i=e[n+F.length],s=e[n+F.length+1];if(e.slice(t-r.length,t)!==r)throw new Error("[wireFormat] Invalid stream header terminator");let c=i==="B"?"brotli":i==="D"?"deflate":i==="N"?void 0:null;if(c===null)throw new Error("[wireFormat] Invalid stream header compression flag");if(s!=="0"&&s!=="1")throw new Error("[wireFormat] Invalid stream header encryption flag");return {compressionAlgorithm:c,encrypted:s==="1"}}chunkBCUBYE76_cjs.a(Dt,"parseStreamHeader");function tr(e){let{paddingBits:r,compressionAlgorithm:t,isEncrypted:n,paddingChar:o,useRepeatPadding:i,bitsPerPadChar:s=2,pipelineVersion:d=2}=e;if(!n&&d!==2)throw new Error("[wireFormat] Pipeline version markers require encryption");if(r===0&&!t&&!n&&d===2)return "";if(i&&!t&&!n&&d===2&&r>0&&r%s===0){let u=r/s;return o.repeat(u)}return o+(t==="deflate"?_:t==="brotli"?$:"")+(n?"ENC":"")+(d===4?"V4":d===3?"V3":"")+r.toString()}chunkBCUBYE76_cjs.a(tr,"buildFooter");function te(e){return Fr.encode(`ddunigma:wire:v4;enc=1;compress=${e.compressionAlgorithm??"none"}`)}chunkBCUBYE76_cjs.a(te,"buildEncryptionAAD");function nr(e,r,t){let n=r?.checksum??t.defaultChecksum,o=r?.compress!==false,i=r?.encrypt!==false,s=e;t.reportDecodeStart(e.length);let d=x(r?.maxDecodedBytes,t.defaultMaxDecodedBytes,true,"maxDecodedBytes"),c=x(r?.maxEncodedChars,d===Number.POSITIVE_INFINITY?t.defaultMaxEncodedChars:Math.min(t.defaultMaxEncodedChars,Number.MAX_SAFE_INTEGER,d*4+1024),true,"maxEncodedChars");if(e.length>c)throw new chunkZTGECGM2_cjs.l(`[Ddu64 decode] Encoded input exceeds limit. Length: ${e.length}, Limit: ${c} characters`,"decode");let u=r?.chunkSeparator??t.defaultChunkSeparator;s=xe(s,u),t.urlSafe&&(s=Ee(s));let l=null,p=null;if(n){let T=rr(s);if(l=T.checksum,p=T.scope,s=T.data,!l)throw new chunkZTGECGM2_cjs.i("[Ddu64 checksum] Checksum verification requested, but no checksum marker was found.")}t.shouldObfuscate(r)&&(s=t.deobfuscate(s));let{cleanedInput:f,paddingBits:h,compressionAlgorithm:m,isEncrypted:y,pipelineVersion:g}=er(s,t.paddingChar,t.bitLength,t.bitsPerPadChar);if((r?.requireEncryption??t.defaultRequireEncryption)&&i&&!y)throw new chunkZTGECGM2_cjs.h("[Ddu64 decode] Encryption is required, but the payload has no authenticated encryption footer.");if(y&&i&&!t.encryptionKey)throw new chunkZTGECGM2_cjs.h("[Ddu64 decode] Encrypted payload requires an encryptionKey");let b=y&&g===4?te({compressionAlgorithm:m}):void 0;Je(f,t.usePowerOfTwo),Qe(f,h,t.usePowerOfTwo,t.dduCharCodeLookup,t.charSetSize,t.dduCharCodeLookupOffset),Ze(f,h,t.bitLength,t.usePowerOfTwo);let w=Xe(f.length,h,t.bitLength,t.usePowerOfTwo);if(w>d)throw new chunkZTGECGM2_cjs.l(`[Ddu64 decode] Decoded output exceeds limit. Estimated: ${w} bytes, Limit: ${d} bytes`,"decode");return t.reportBitpackDecode(f.length,e.length),{decoded:t.decodeChars(f,h),extractedChecksum:l,extractedChecksumScope:p,compressionAlgorithm:m,isEncrypted:y,pipelineVersion:g,encryptionAAD:b,allowInternalDecompress:o,allowInternalDecrypt:i}}chunkBCUBYE76_cjs.a(nr,"runDecodePrelude");function or(e){return e.omitFooter?"":tr({paddingBits:e.paddingBits,compressionAlgorithm:e.compressionAlgorithm,isEncrypted:e.isEncrypted,paddingChar:e.paddingChar,useRepeatPadding:e.useRepeatPadding&&!e.compressionAlgorithm&&!e.isEncrypted,bitsPerPadChar:e.bitsPerPadChar,pipelineVersion:e.isEncrypted?e.pipelineVersion:2})}chunkBCUBYE76_cjs.a(or,"buildEncodeFooter");function ir(e){let r=e.encoded;if(e.shouldObfuscate(e.options)&&(r=e.getObfuscationLayer().obfuscate(r)),e.shouldChecksum&&e.checksum){let t=e.checksumScope==="plaintext"?"P":"O";r=r+"CK"+t+e.checksum;}return e.urlSafe&&(r=De(r)),e.chunkSize&&e.chunkSize>0&&(e.assertSafeChunkSeparator(r,e.chunkSeparator),r=ke(r,e.chunkSize,e.chunkSeparator)),r}chunkBCUBYE76_cjs.a(ir,"applyPostEncoding");var pe=8192;function ar(e,r,t){if(!Number.isInteger(r)||r<1||r>16)throw new chunkZTGECGM2_cjs.c(`[Ddu64 encode] Invalid bitLength: ${r}`);let n=e.length;if(n===0)return {payload:"",paddingBits:0};let o=Math.ceil(n*8/r),i=Math.min(o,pe),s=new Uint16Array(i),d=[],c=0,u=0;if(r===6){let l=0;for(;l+2<n;l+=3){let f=e[l],h=e[l+1],m=e[l+2];s[c++]=t[f>>>2],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0),s[c++]=t[(f&3)<<4|h>>>4],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0),s[c++]=t[(h&15)<<2|m>>>6],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0),s[c++]=t[m&63],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0);}let p=n-l;if(p===1){let f=e[l];s[c++]=t[f>>>2],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0),s[c++]=t[(f&3)<<4],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0),u=4;}else if(p===2){let f=e[l],h=e[l+1];s[c++]=t[f>>>2],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0),s[c++]=t[(f&3)<<4|h>>>4],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0),s[c++]=t[(h&15)<<2],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0),u=2;}}else if(r===8)for(let l=0;l<n;l++)s[c++]=t[e[l]],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0);else {let l=(1<<r)-1,p=0,f=0;for(let h=0;h<n;h++)for(p=p<<8|e[h],f+=8;f>=r;)f-=r,s[c++]=t[p>>f&l],c===i&&(d.push(String.fromCharCode.apply(null,s)),c=0),p&=(1<<f)-1;f>0&&(u=r-f,s[c++]=t[p<<u&l]);}return c>0&&d.push(String.fromCharCode.apply(null,s.subarray(0,c))),{payload:d.length===1?d[0]:d.join(""),paddingBits:u}}chunkBCUBYE76_cjs.a(ar,"packPow2ToString");function sr(e,r,t,n,o){if(!Number.isInteger(t)||t<1||t>16)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid bitLength: ${t}`);let i=e.length;if(i===0)return new Uint8Array(0);let s=Math.ceil((i*t-r)/8),d=new Uint8Array(s+1),c=0,u=n.length;if(t===6){let h=i-i%4;h===i&&r>0&&(h-=4);let m=0;for(;m<h;m+=4){let b=e.charCodeAt(m)-o,w=b>=0&&b<u?n[b]:-1;if(w<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m]}" at ${m}`);let P=e.charCodeAt(m+1)-o,T=P>=0&&P<u?n[P]:-1;if(T<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m+1]}" at ${m+1}`);let ne=e.charCodeAt(m+2)-o,oe=ne>=0&&ne<u?n[ne]:-1;if(oe<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m+2]}" at ${m+2}`);let ie=e.charCodeAt(m+3)-o,ge=ie>=0&&ie<u?n[ie]:-1;if(ge<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m+3]}" at ${m+3}`);d[c++]=w<<2|T>>>4,d[c++]=(T&15)<<4|oe>>>2,d[c++]=(oe&3)<<6|ge;}let y=0,g=0,D=i-1;for(;m<i;m++){let w=e.charCodeAt(m)-o,P=w>=0&&w<u?n[w]:-1;if(P<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[m]}" at ${m}`);for(y=y<<6|P,g+=6,m===D&&r>0&&(y>>=r,g-=r);g>=8;)g-=8,d[c++]=y>>g&255,y&=(1<<g)-1;}return d.subarray(0,c)}if(t===8&&r===0){for(let h=0;h<i;h++){let y=e.charCodeAt(h)-o,g=y>=0&&y<u?n[y]:-1;if(g<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[h]}" at ${h}`);d[c++]=g;}return d.subarray(0,c)}let l=0,p=0,f=i-1;for(let h=0;h<i;h++){let y=e.charCodeAt(h)-o,g=y>=0&&y<u?n[y]:-1;if(g<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[h]}" at ${h}`);for(l=l<<t|g,p+=t,h===f&&r>0&&(l>>=r,p-=r);p>=8;)p-=8,d[c++]=l>>p&255,l&=(1<<p)-1;}return d.subarray(0,c)}chunkBCUBYE76_cjs.a(sr,"unpackPow2FromString");function dr(e,r,t,n){let o=e.length;if(o===0)return {payload:"",paddingBits:0};let i=[],s=new Uint16Array(pe),d=0,c=0,u=0,l=0,p=chunkBCUBYE76_cjs.a(f=>{s[d++]=f,d===pe&&(i.push(String.fromCharCode.apply(null,s)),d=0);},"pushCode");for(let f=0;f<o;f++)for(c=c<<8|e[f],u+=8;u>=r;){u-=r;let h=c>>u,m=h/t|0;p(n[m]),p(n[h-m*t]),c&=(1<<u)-1;}if(u>0){l=r-u;let f=c<<l,h=f/t|0;p(n[h]),p(n[f-h*t]);}return d>0&&i.push(String.fromCharCode.apply(null,s.subarray(0,d))),{payload:i.length===1?i[0]:i.join(""),paddingBits:l}}chunkBCUBYE76_cjs.a(dr,"packNonPow2ToString");function cr(e,r,t,n,o,i){let s=e.length;if(s===0)return new Uint8Array(0);let d=Math.ceil(s/2),c=Math.ceil((d*t-r)/8),u=new Uint8Array(c+1),l=0,p=Pe(t),f=o.length,h=0,m=0;for(let y=0;y<s;y+=2){let g=e.charCodeAt(y)-i,D=g>=0&&g<f?o[g]:-1;if(D<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[y]}" at ${y}`);if(y+1>=s)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Truncated symbol pair at ${y+1}`);let b=e.charCodeAt(y+1)-i,w=b>=0&&b<f?o[b]:-1;if(w<0)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Invalid character "${e[y+1]}" at ${y+1}`);let P=D*n+w;if(P>=p)throw new chunkZTGECGM2_cjs.d(`[Ddu64 decode] Value ${P} exceeds range at position ${y}`);for(h=h<<t|P,m+=t,y+2>=s&&r>0&&(h>>=r,m-=r);m>=8;)m-=8,u[l++]=h>>m&255,h&=(1<<m)-1;}return u.subarray(0,l)}chunkBCUBYE76_cjs.a(cr,"unpackNonPow2FromString");function ur(e,r,t,n,o){if(e.length===0)return "";let i=o.canUseNativeBase64?Te(e):null,s,d;if(i)s=i.paddingBits,d=i.payload;else if(o.bitPackConfig.usePowerOfTwo){let u=ar(e,o.bitPackConfig.bitLength,o.dduCharCodes);s=u.paddingBits,d=u.payload;}else {let u=dr(e,o.bitPackConfig.bitLength,o.bitPackConfig.charsetSize,o.dduCharCodes);s=u.paddingBits,d=u.payload;}let c=or({paddingBits:s,compressionAlgorithm:r,isEncrypted:t,paddingChar:o.paddingChar,useRepeatPadding:o.useRepeatPadding,bitsPerPadChar:o.bitsPerPadChar,pipelineVersion:o.encryptedPipelineVersion,omitFooter:n?.omitFooter});return d+c}chunkBCUBYE76_cjs.a(ur,"encodePayload");function lr(e,r,t){if(e.length===0)return new Uint8Array(0);let o=t.canUseNativeBase64?Me(e,r,i=>N(t.dduCharCodeLookup,i,t.dduCharCodeLookupOffset)>=0):null;return o||(t.bitPackConfig.usePowerOfTwo?sr(e,r,t.bitPackConfig.bitLength,t.dduCharCodeLookup,t.dduCharCodeLookupOffset):cr(e,r,t.bitPackConfig.bitLength,t.bitPackConfig.charsetSize,t.dduCharCodeLookup,t.dduCharCodeLookupOffset))}chunkBCUBYE76_cjs.a(lr,"decodePayload");function hr(e,r){let t=new Set(e);t.add(r);let n=_+$+"ENC"+"V3"+"V4";for(let o of n)t.add(o);for(let o of "0123456789")t.add(o);return [...t]}chunkBCUBYE76_cjs.a(hr,"buildObfuscationAlphabet");function B(e,r="construct"){if(e===void 0)return;if(typeof e!="object"||e===null||Array.isArray(e))throw new chunkZTGECGM2_cjs.k("[Ddu64 options] Options must be an object.",r);let t=e;v(e.compress,"compress",r),v(t.encrypt,"encrypt",r),v(e.checksum,"checksum",r),v(t.omitFooter,"omitFooter",r),v(e.obfuscate,"obfuscate",r),v(e.requireEncryption,"requireEncryption",r),e.compressionLevel!==void 0&&(typeof e.compressionLevel!="number"||!Number.isFinite(e.compressionLevel))&&C(r,"compressionLevel must be a finite number"),e.onProgress!==void 0&&typeof e.onProgress!="function"&&C(r,"onProgress must be a function"),e.compressionAlgorithm!==void 0&&e.compressionAlgorithm!=="deflate"&&e.compressionAlgorithm!=="brotli"&&C(r,`compressionAlgorithm must be "deflate" or "brotli", got ${String(e.compressionAlgorithm)}`),e.checksumScope!==void 0&&e.checksumScope!=="plaintext"&&e.checksumScope!=="output"&&C(r,`checksumScope must be "plaintext" or "output", got ${String(e.checksumScope)}`),e.chunkSize!==void 0&&(!Number.isSafeInteger(e.chunkSize)||e.chunkSize<0)&&C(r,"chunkSize must be a non-negative safe integer (0 disables chunking)"),e.chunkSeparator!==void 0&&typeof e.chunkSeparator!="string"&&C(r,"chunkSeparator must be a string"),e.chunkSize!==void 0&&e.chunkSize>0&&e.chunkSeparator===""&&C(r,"chunkSeparator must not be empty when chunkSize is enabled"),V(e.maxDecodedBytes,"maxDecodedBytes",r),V(e.maxEncodedChars,"maxEncodedChars",r),V(e.maxDecompressedBytes,"maxDecompressedBytes",r),"maxBufferedBytes"in e&&V(e.maxBufferedBytes,"maxBufferedBytes",r),"maxBufferedChars"in e&&V(e.maxBufferedChars,"maxBufferedChars",r);let n=e;v(n.throwOnError,"throwOnError",r),v(n.urlSafe,"urlSafe",r),v(n.useRepeatPadding,"useRepeatPadding",r),v(n.usePowerOfTwo,"usePowerOfTwo",r),n.encryptionKey!==void 0&&(typeof n.encryptionKey!="string"||n.encryptionKey.length===0)&&C(r,"encryptionKey must be a non-empty string"),n.dduChar!==void 0&&typeof n.dduChar!="string"&&!(Array.isArray(n.dduChar)&&n.dduChar.every(i=>typeof i=="string"))&&C(r,"dduChar must be a string or string array"),n.paddingChar!==void 0&&typeof n.paddingChar!="string"&&C(r,"paddingChar must be a string"),n.codaChar!==void 0&&!(Array.isArray(n.codaChar)&&n.codaChar.every(i=>typeof i=="string"))&&C(r,"codaChar must be a string array"),n.requiredLength!==void 0&&(!Number.isSafeInteger(n.requiredLength)||n.requiredLength<=0)&&C(r,"requiredLength must be a positive safe integer"),n.adapter!==void 0&&(typeof n.adapter!="object"||n.adapter===null)&&C(r,"adapter must be an object"),n.adapterFactory!==void 0&&typeof n.adapterFactory!="function"&&C(r,"adapterFactory must be a function"),n.asyncAdapterFactory!==void 0&&typeof n.asyncAdapterFactory!="function"&&C(r,"asyncAdapterFactory must be a function"),n.obfuscationLayerFactory!==void 0&&typeof n.obfuscationLayerFactory!="function"&&C(r,"obfuscationLayerFactory must be a function");let o="keyDerivation"in e?e.keyDerivation:void 0;o!==void 0&&((typeof o!="object"||o===null)&&C(r,"keyDerivation must be an object"),o.algorithm!==void 0&&o.algorithm!=="sha256"&&o.algorithm!=="pbkdf2"&&C(r,`keyDerivation.algorithm must be "sha256" or "pbkdf2", got ${String(o.algorithm)}`),o.hash!==void 0&&o.hash!=="SHA-256"&&o.hash!=="SHA-384"&&o.hash!=="SHA-512"&&C(r,`Unsupported PBKDF2 hash: ${String(o.hash)}`),o.iterations!==void 0&&(!Number.isFinite(o.iterations)||o.iterations<=0)&&C(r,"keyDerivation.iterations must be a positive finite number"),o.salt!==void 0&&typeof o.salt!="string"&&!fr(o.salt)&&C(r,"keyDerivation.salt must be a string or Uint8Array"));}chunkBCUBYE76_cjs.a(B,"validateRuntimeOptions");function H(e,r="encode"){if(typeof e!="string"&&!fr(e))throw new chunkZTGECGM2_cjs.k("[Ddu64 input] Encode input must be a string or Uint8Array.",r)}chunkBCUBYE76_cjs.a(H,"validateEncodeInput");function q(e,r="decode"){if(typeof e!="string")throw new chunkZTGECGM2_cjs.k("[Ddu64 input] Decode input must be a string.",r)}chunkBCUBYE76_cjs.a(q,"validateDecodeInput");function fr(e){return ArrayBuffer.isView(e)&&Object.prototype.toString.call(e)==="[object Uint8Array]"}chunkBCUBYE76_cjs.a(fr,"isUint8Array");function v(e,r,t){e!==void 0&&typeof e!="boolean"&&C(t,`${r} must be a boolean`);}chunkBCUBYE76_cjs.a(v,"validateBoolean");function V(e,r,t){e!==void 0&&e!==Number.POSITIVE_INFINITY&&(!Number.isSafeInteger(e)||e<=0)&&C(t,`${r} must be a positive safe integer or Infinity`);}chunkBCUBYE76_cjs.a(V,"validatePositiveLimit");function C(e,r){throw new chunkZTGECGM2_cjs.k(`[Ddu64 options] Invalid ${r}.`,e)}chunkBCUBYE76_cjs.a(C,"invalid");function pr(e,r,t){let n=e.decoded,o=e.extractedChecksumScope??r?.checksumScope??"plaintext";if(o==="output"&&br(e,t),yr(e,t)&&(U(t,n.length,55,"decrypt"),n=t.decrypt(n,e.encryptionAAD)),Cr(e)){let i=x(r?.maxDecompressedBytes,t.defaultMaxDecompressedBytes,true,"maxDecompressedBytes");U(t,n.length,70,"decompress"),n=t.decompress(n,e.compressionAlgorithm,i);}return o==="plaintext"&&Ar(e,t,n),gr(e,t)&&(U(t,n.length,90,"decrypt"),n=t.decrypt(n,e.encryptionAAD)),U(t,n.length,100,"done"),n}chunkBCUBYE76_cjs.a(pr,"runSyncDecodePipeline");async function mr(e,r,t){let n=e.decoded,o=e.extractedChecksumScope??r?.checksumScope??"plaintext";if(o==="output"&&br(e,t),yr(e,t)&&(U(t,n.length,55,"decrypt"),n=await t.decrypt(n,e.encryptionAAD)),Cr(e)){let i=x(r?.maxDecompressedBytes,t.defaultMaxDecompressedBytes,true,"maxDecompressedBytes");U(t,n.length,70,"decompress"),n=await t.decompress(n,e.compressionAlgorithm,i);}return o==="plaintext"&&Ar(e,t,n),gr(e,t)&&(U(t,n.length,90,"decrypt"),n=await t.decrypt(n,e.encryptionAAD)),U(t,n.length,100,"done"),n}chunkBCUBYE76_cjs.a(mr,"runAsyncDecodePipeline");function yr(e,r){return (e.pipelineVersion===3||e.pipelineVersion===4)&&e.isEncrypted&&!!r.encryptionKey&&e.allowInternalDecrypt}chunkBCUBYE76_cjs.a(yr,"shouldRunPreDecompressDecrypt");function gr(e,r){return e.pipelineVersion===2&&e.isEncrypted&&!!r.encryptionKey&&e.allowInternalDecrypt}chunkBCUBYE76_cjs.a(gr,"shouldRunPostChecksumDecrypt");function Cr(e){return !!e.compressionAlgorithm&&e.allowInternalDecompress&&(e.pipelineVersion===2||!e.isEncrypted||e.allowInternalDecrypt)}chunkBCUBYE76_cjs.a(Cr,"shouldDecompress");function br(e,r){if(!e.extractedChecksum)return;U(r,e.decoded.length,85,"checksum");let t=R(e.decoded);if(!ce(t,e.extractedChecksum))throw new chunkZTGECGM2_cjs.i(`[Ddu64 decode] Checksum mismatch. Expected: ${e.extractedChecksum}, Got: ${t}`)}chunkBCUBYE76_cjs.a(br,"verifyWireChecksum");function Ar(e,r,t){if(!e.extractedChecksum||!(e.pipelineVersion===2||!e.isEncrypted||e.allowInternalDecrypt))return;U(r,t.length,85,"checksum");let n=R(t);if(!ce(n,e.extractedChecksum))throw new chunkZTGECGM2_cjs.i(`[Ddu64 decode] Checksum mismatch. Expected: ${e.extractedChecksum}, Got: ${n}`)}chunkBCUBYE76_cjs.a(Ar,"verifyDecodedChecksum");function U(e,r,t,n){e.reportProgress({processedBytes:r,totalBytes:r,percent:t,stage:n});}chunkBCUBYE76_cjs.a(U,"reportStage");function me(e,r,t){let n=Pr(r,t),o=typeof e=="string"?K(e):e;Sr(t,o.length);let i="";n.shouldChecksum&&n.checksumScope==="plaintext"&&(i=R(o));let s,d;if(n.shouldCompress){let{algo:u,level:l}=wr(r,t);Dr(t,o.length);let p=t.compress(o,u,l);p.length<o.length&&(d=p.length,o=p,s=u);}let c=false;return n.shouldEncrypt&&(Er(t,o.length),o=t.encrypt(o,t.getEncryptionAAD(s)),c=true),n.shouldChecksum&&n.checksumScope==="output"&&(i=R(o)),{encoded:t.finalize(o,s,c,i,n.shouldChecksum,n.checksumScope,n.chunkSize,n.chunkSeparator),compressedSize:d}}chunkBCUBYE76_cjs.a(me,"runSyncEncodePipeline");async function ye(e,r,t){let n=Pr(r,t),o=typeof e=="string"?K(e):e;Sr(t,o.length);let i="";n.shouldChecksum&&n.checksumScope==="plaintext"&&(i=R(o));let s,d;if(n.shouldCompress){let{algo:u,level:l}=wr(r,t);Dr(t,o.length);let p=await t.compress(o,u,l);p.length<o.length&&(d=p.length,o=p,s=u);}let c=false;return n.shouldEncrypt&&(Er(t,o.length),o=await t.encrypt(o,t.getEncryptionAAD(s)),c=true),n.shouldChecksum&&n.checksumScope==="output"&&(i=R(o)),{encoded:t.finalize(o,s,c,i,n.shouldChecksum,n.checksumScope,n.chunkSize,n.chunkSeparator),compressedSize:d}}chunkBCUBYE76_cjs.a(ye,"runAsyncEncodePipeline");function wr(e,r){let t=e?.compressionAlgorithm??r.defaultCompressionAlgorithm,n=J(e?.compressionLevel??r.defaultCompressionLevel,t);return {algo:t,level:n}}chunkBCUBYE76_cjs.a(wr,"resolveCompressionParams");function Pr(e,r){let t={shouldCompress:e?.compress??r.defaultCompress,shouldChecksum:e?.checksum??r.defaultChecksum,checksumScope:e?.checksumScope??r.defaultChecksumScope,shouldEncrypt:(e?.encrypt??true)&&r.hasEncryptionKey,chunkSize:e?.chunkSize??r.defaultChunkSize,chunkSeparator:e?.chunkSeparator??r.defaultChunkSeparator};if(t.chunkSize!==void 0&&t.chunkSize>0&&t.chunkSeparator==="")throw new chunkZTGECGM2_cjs.k("[Ddu64 options] Invalid chunkSeparator must not be empty when chunkSize is enabled.","encode");return t}chunkBCUBYE76_cjs.a(Pr,"resolveEncodeSettings");function Sr(e,r){e.reportProgress({processedBytes:0,totalBytes:r,percent:0,stage:"start"});}chunkBCUBYE76_cjs.a(Sr,"reportStart");function Dr(e,r){e.reportProgress({processedBytes:r,totalBytes:r,percent:20,stage:"compress"});}chunkBCUBYE76_cjs.a(Dr,"reportCompress");function Er(e,r){e.reportProgress({processedBytes:r,totalBytes:r,percent:45,stage:"encrypt"});}chunkBCUBYE76_cjs.a(Er,"reportEncrypt");var jr=64*1024*1024,Yr=64*1024*1024,kr=28,xr=class{static{chunkBCUBYE76_cjs.a(this,"Ddu64Core");}dduChar;dduCharCodes;paddingChar;bitLength;usePowerOfTwo;dduCharCodeLookup;dduCharCodeLookupOffset;defaultCompress;defaultMaxDecodedBytes;defaultMaxEncodedChars;defaultMaxDecompressedBytes;urlSafe;encryptionKey;keyDerivation;encryptionKeyHash;adapterGatewayContext;defaultChecksum;defaultChecksumScope;defaultChunkSize;defaultChunkSeparator;defaultCompressionLevel;defaultCompressionAlgorithm;useRepeatPadding;bitsPerPadChar;bitPackConfig;canUseNativeBase64;payloadCodecContext;adapter;adapterFactory;asyncAdapterFactory;asyncAdapterPromise;obfuscationLayerFactory;defaultObfuscate;defaultOnProgress;defaultRequireEncryption;obfuscationLayer;constructor(r,t,n){let o=qe(r,t,n);r=o.dduChar,t=o.paddingChar,n=o.dduOptions,B(n);let i=n?.throwOnError??true;this.adapter=n?.adapter,this.adapterFactory=n?.adapterFactory,this.asyncAdapterFactory=n?.asyncAdapterFactory,this.obfuscationLayerFactory=n?.obfuscationLayerFactory;let s,d;try{s=Oe(r,t,n,i),d=Ie(s,i,n);}catch(g){throw chunkZTGECGM2_cjs.p(g)?g:new chunkZTGECGM2_cjs.j(chunkZTGECGM2_cjs.q(g),g)}this.dduChar=d.charSet,this.paddingChar=d.padding;let c=d.isPredefined;this.defaultCompress=n?.compress??false,this.defaultMaxDecodedBytes=x(n?.maxDecodedBytes,jr,i,"maxDecodedBytes"),this.defaultMaxDecompressedBytes=x(n?.maxDecompressedBytes,Yr,i,"maxDecompressedBytes"),this.defaultMaxEncodedChars=x(n?.maxEncodedChars,this.defaultMaxDecodedBytes===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:Math.min(Number.MAX_SAFE_INTEGER,this.defaultMaxDecodedBytes*4+1024),i,"maxEncodedChars");let u=this.dduChar.length,l=we(u),p=n?.usePowerOfTwo,f=s.encodingProfile;this.usePowerOfTwo=f?.usePowerOfTwo??s.usePowerOfTwo??(p!==void 0?p&&l:l);let h=f?.bitLength??(s.isPredefined&&s.usePowerOfTwo!==void 0?s.bitLength:void 0);this.bitLength=h??Ae(u,this.usePowerOfTwo);let m=je(this.dduChar,c);this.dduCharCodeLookup=m.charCodeLookup,this.dduCharCodeLookupOffset=m.lookupOffset,this.dduCharCodes=m.charCodes;try{this.urlSafe=n?.urlSafe===!0?Re(this.dduChar,this.paddingChar,i):!1;}catch(g){throw chunkZTGECGM2_cjs.p(g)?g:new chunkZTGECGM2_cjs.j(chunkZTGECGM2_cjs.q(g),g)}this.encryptionKey=n?.encryptionKey;let y=n?.keyDerivation;this.keyDerivation=y?{...y,...y.salt!==void 0?{salt:typeof y.salt=="string"?y.salt:new Uint8Array(y.salt)}:{}}:void 0,this.defaultChecksum=n?.checksum??false,this.defaultChecksumScope=n?.checksumScope??"output",this.defaultChunkSize=n?.chunkSize,this.defaultChunkSeparator=n?.chunkSeparator??`
7
+ `,this.defaultCompressionAlgorithm=n?.compressionAlgorithm??"deflate",this.defaultCompressionLevel=J(n?.compressionLevel,this.defaultCompressionAlgorithm),this.useRepeatPadding=n?.useRepeatPadding??s.useRepeatPadding??false,this.bitsPerPadChar=f?.bitsPerPadChar??s.bitsPerPadChar??2,this.defaultObfuscate=n?.obfuscate??false,this.defaultOnProgress=n?.onProgress,this.defaultRequireEncryption=n?.requireEncryption??this.encryptionKey!==void 0,this.bitPackConfig={bitLength:this.bitLength,usePowerOfTwo:this.usePowerOfTwo,charsetSize:u},this.canUseNativeBase64=Le(this.dduChar,this.paddingChar,this.usePowerOfTwo,this.bitLength),this.payloadCodecContext={bitPackConfig:this.bitPackConfig,canUseNativeBase64:this.canUseNativeBase64,dduCharCodes:this.dduCharCodes,dduCharCodeLookup:this.dduCharCodeLookup,dduCharCodeLookupOffset:this.dduCharCodeLookupOffset,paddingChar:this.paddingChar,useRepeatPadding:this.useRepeatPadding,bitsPerPadChar:this.bitsPerPadChar,encryptedPipelineVersion:4};}encode(r,t){try{return B(t,"encode"),H(r),me(r,t,{...this.buildEncodeBaseContext(t),compress:chunkBCUBYE76_cjs.a((n,o,i)=>he(this.getAdapter(),n,o,i),"compress"),encrypt:chunkBCUBYE76_cjs.a((n,o)=>Ke(this.getAdapterGatewayContext(),n,o),"encrypt")}).encoded}catch(n){throw chunkZTGECGM2_cjs.r(n,"encode")}}decode(r,t){try{B(t,"decode"),q(r);let n=this.decodeToUint8Array(r,t);return ue(n)}catch(n){throw chunkZTGECGM2_cjs.r(n,"decode")}}decodeToUint8Array(r,t){try{B(t,"decode"),q(r);let n=this.decodePrelude(r,t);return pr(n,t,{...this.buildDecodeBaseContext(t),decrypt:chunkBCUBYE76_cjs.a((o,i)=>Ne(this.getAdapterGatewayContext(),o,i),"decrypt"),decompress:chunkBCUBYE76_cjs.a((o,i,s)=>Fe(this.getAdapter(),o,i,s),"decompress")})}catch(n){throw chunkZTGECGM2_cjs.r(n,"decode")}}async encodeAsync(r,t){try{return B(t,"encode"),H(r),(await ye(r,t,{...this.buildEncodeBaseContext(t),compress:chunkBCUBYE76_cjs.a(async(o,i,s)=>fe(await this.getAsyncAdapter(),o,i,s),"compress"),encrypt:chunkBCUBYE76_cjs.a(async(o,i)=>(await this.getAsyncAdapter(),$e(this.getAdapterGatewayContext(),o,i)),"encrypt")})).encoded}catch(n){throw chunkZTGECGM2_cjs.r(n,"encode")}}async decodeAsync(r,t){try{B(t,"decode"),q(r);let n=await this.decodeToUint8ArrayAsync(r,t);return ue(n)}catch(n){throw chunkZTGECGM2_cjs.r(n,"decode")}}async decodeToUint8ArrayAsync(r,t){try{B(t,"decode"),q(r);let n=this.decodePrelude(r,t);return await mr(n,t,{...this.buildDecodeBaseContext(t),decrypt:chunkBCUBYE76_cjs.a(async(o,i)=>(await this.getAsyncAdapter(),ze(this.getAdapterGatewayContext(),o,i)),"decrypt"),decompress:chunkBCUBYE76_cjs.a(async(o,i,s)=>Ve(await this.getAsyncAdapter(),o,i,s),"decompress")})}catch(n){throw chunkZTGECGM2_cjs.r(n,"decode")}}buildDecodeBaseContext(r){return {encryptionKey:this.encryptionKey,defaultMaxDecompressedBytes:this.defaultMaxDecompressedBytes,reportProgress:chunkBCUBYE76_cjs.a(t=>this.reportProgress(r,t),"reportProgress")}}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,defaultChecksumScope:this.defaultChecksumScope,defaultObfuscate:this.defaultObfuscate,defaultRequireEncryption:this.defaultRequireEncryption,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm}}getStats(r,t){try{B(t,"encode"),H(r);let n=typeof r=="string"?K(r):r,{encoded:o,compressedSize:i}=me(n,t,{...this.buildEncodeBaseContext(t),compress:chunkBCUBYE76_cjs.a((s,d,c)=>he(this.getAdapter(),s,d,c),"compress"),encrypt:chunkBCUBYE76_cjs.a(s=>new Uint8Array(s.length+kr),"encrypt")});return this.buildEncodeStats(n.length,o.length,i,t)}catch(n){throw chunkZTGECGM2_cjs.r(n,"encode")}}async getStatsAsync(r,t){try{B(t,"encode"),H(r);let n=typeof r=="string"?K(r):r,{encoded:o,compressedSize:i}=await ye(n,t,{...this.buildEncodeBaseContext(t),compress:chunkBCUBYE76_cjs.a(async(s,d,c)=>fe(await this.getAsyncAdapter(),s,d,c),"compress"),encrypt:chunkBCUBYE76_cjs.a(async s=>new Uint8Array(s.length+kr),"encrypt")});return this.buildEncodeStats(n.length,o.length,i,t)}catch(n){throw chunkZTGECGM2_cjs.r(n,"encode")}}buildEncodeStats(r,t,n,o){let i=r>0?t/r:0,d=(o?.compress??this.defaultCompress)&&n!==void 0&&r>0?n/r:void 0;return {originalSize:r,encodedSize:t,compressedSize:n,compressionRatio:d,expansionRatio:i,charsetSize:this.dduChar.length,bitLength:this.bitLength}}buildEncodeBaseContext(r){return {defaultCompress:this.defaultCompress,defaultChecksum:this.defaultChecksum,defaultChecksumScope:this.defaultChecksumScope,defaultChunkSize:this.defaultChunkSize,defaultChunkSeparator:this.defaultChunkSeparator,defaultCompressionLevel:this.defaultCompressionLevel,defaultCompressionAlgorithm:this.defaultCompressionAlgorithm,hasEncryptionKey:!!this.encryptionKey,reportProgress:chunkBCUBYE76_cjs.a(t=>this.reportProgress(r,t),"reportProgress"),getEncryptionAAD:chunkBCUBYE76_cjs.a(t=>te({compressionAlgorithm:t}),"getEncryptionAAD"),finalize:chunkBCUBYE76_cjs.a((t,n,o,i,s,d,c,u)=>this.finalizeEncode(t,n,o,i,s,d,c,u,r),"finalize")}}finalizeEncode(r,t,n,o,i,s,d,c,u){this.reportProgress(u,{processedBytes:r.length,totalBytes:r.length,percent:70,stage:"encode"});let l=ur(r,t,n,u,this.payloadCodecContext);return l=ir({encoded:l,options:u,checksum:o,shouldChecksum:i,checksumScope:s,chunkSize:d,chunkSeparator:c,urlSafe:this.urlSafe,shouldObfuscate:chunkBCUBYE76_cjs.a(p=>this.shouldObfuscate(p),"shouldObfuscate"),getObfuscationLayer:chunkBCUBYE76_cjs.a(()=>this.getObfuscationLayer(),"getObfuscationLayer"),assertSafeChunkSeparator:chunkBCUBYE76_cjs.a((p,f)=>this.assertSafeChunkSeparator(p,f),"assertSafeChunkSeparator")}),this.reportProgress(u,{processedBytes:r.length,totalBytes:r.length,percent:100,stage:"done"}),l}decodePrelude(r,t){return nr(r,t,{defaultChecksum:this.defaultChecksum,defaultChunkSeparator:this.defaultChunkSeparator,defaultMaxDecodedBytes:this.defaultMaxDecodedBytes,defaultMaxEncodedChars:this.defaultMaxEncodedChars,urlSafe:this.urlSafe,paddingChar:this.paddingChar,bitLength:this.bitLength,bitsPerPadChar:this.bitsPerPadChar,usePowerOfTwo:this.usePowerOfTwo,dduCharCodeLookup:this.dduCharCodeLookup,dduCharCodeLookupOffset:this.dduCharCodeLookupOffset,charSetSize:this.dduChar.length,encryptionKey:this.encryptionKey,defaultRequireEncryption:this.defaultRequireEncryption,shouldObfuscate:chunkBCUBYE76_cjs.a(n=>this.shouldObfuscate(n),"shouldObfuscate"),deobfuscate:chunkBCUBYE76_cjs.a(n=>this.getObfuscationLayer().deobfuscate(n),"deobfuscate"),decodeChars:chunkBCUBYE76_cjs.a((n,o)=>lr(n,o,this.payloadCodecContext),"decodeChars"),reportDecodeStart:chunkBCUBYE76_cjs.a(n=>{this.reportProgress(t,{processedBytes:0,totalBytes:n,percent:0,stage:"start"});},"reportDecodeStart"),reportBitpackDecode:chunkBCUBYE76_cjs.a((n,o)=>{this.reportProgress(t,{processedBytes:n,totalBytes:o,percent:30,stage:"decode"});},"reportBitpackDecode")})}reportProgress(r,t){(r?.onProgress??this.defaultOnProgress)?.(t);}getAdapter(){return this.adapter===void 0&&this.adapterFactory!==void 0&&(this.adapter=this.adapterFactory()),this.adapter}async getAsyncAdapter(){let r=this.getAdapter();return r!==void 0||this.asyncAdapterFactory===void 0?r:(this.asyncAdapterPromise||(this.asyncAdapterPromise=this.asyncAdapterFactory().then(t=>(this.adapter=t,this.adapterGatewayContext&&(this.adapterGatewayContext.adapter=t),t)).catch(t=>{throw this.asyncAdapterPromise=void 0,t})),this.asyncAdapterPromise)}getAdapterGatewayContext(){if(!this.adapterGatewayContext){let r={adapter:this.getAdapter(),encryptionKey:this.encryptionKey,keyDerivation:this.keyDerivation,encryptionKeyHash:this.encryptionKeyHash,setEncryptionKeyHash:chunkBCUBYE76_cjs.a(t=>{this.encryptionKeyHash=t,r.encryptionKeyHash=t;},"setEncryptionKeyHash")};this.adapterGatewayContext=r;}return this.adapterGatewayContext}getObfuscationLayer(){if(!this.obfuscationLayer){if(!this.obfuscationLayerFactory)throw new chunkZTGECGM2_cjs.n("[Ddu64 obfuscation] No obfuscation layer is wired. Use Ddu64Node/Ddu64Browser (preconfigured), or inject `obfuscationLayerFactory` when constructing Ddu64Core directly.");this.obfuscationLayer=this.obfuscationLayerFactory(hr(this.dduChar,this.paddingChar));}return this.obfuscationLayer}shouldObfuscate(r){return r?.obfuscate??this.defaultObfuscate}assertSafeChunkSeparator(r,t){if(!(t.length===0||t===`
8
+ `||t===`\r
9
+ `||t==="\r")&&r.includes(t))throw new chunkZTGECGM2_cjs.c(`[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.`)}};var vr=class e{static{chunkBCUBYE76_cjs.a(this,"CharsetBuilder");}chars=[];constructor(){}static create(){return new e}static fromUnicodeRange(r,t){return new e().addUnicodeRange(r,t)}static fromString(r){return new e().addString(r)}static base64(){return new e().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")}static base32(){return new e().addString("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567")}static uppercase(){return e.fromUnicodeRange(65,90)}static lowercase(){return e.fromUnicodeRange(97,122)}static digits(){return e.fromUnicodeRange(48,57)}static hangulJamo(){return new e().addUnicodeRange(4352,4370).addUnicodeRange(4449,4469).addUnicodeRange(4520,4546)}addUnicodeRange(r,t){if(!Number.isInteger(r)||!Number.isInteger(t)||r<0||t>1114111||r>t)throw new RangeError("Unicode range must use integer code points with 0 <= start <= end <= 0x10FFFF");for(let n=r;n<=t;n++)this.chars.push(String.fromCodePoint(n));return this}addString(r){return typeof r=="string"?this.chars.push(...r):this.chars.push(...r),this}add(...r){return this.chars.push(...r),this}excludeConfusing(){let r=new Set(["0","O","o","1","l","I","i","|","L"]);return this.chars=this.chars.filter(t=>!r.has(t)),this}exclude(...r){let t=new Set(r);return this.chars=this.chars.filter(n=>!t.has(n)),this}excludeUrlUnsafe(){let r=new Set(["+","/","=","?","&","#","%"," "]);return this.chars=this.chars.filter(t=>!r.has(t)),this}unique(){return this.chars=[...new Set(this.chars)],this}shuffle(r){let t=Math.random;if(r!==void 0){let n=r|0||1;t=chunkBCUBYE76_cjs.a(()=>(n^=n<<13,n^=n>>17,n^=n<<5,(n>>>0)/4294967296),"random");}for(let n=this.chars.length-1;n>0;n--){let o=Math.floor(t()*(n+1));[this.chars[n],this.chars[o]]=[this.chars[o],this.chars[n]];}return this}limit(r){if(!Number.isSafeInteger(r)||r<0)throw new RangeError("Charset limit must be a non-negative safe integer");return this.chars=this.chars.slice(0,r),this}limitToPowerOfTwo(){let r=this.chars.length;if(r===0)return this;let t=1<<Math.floor(Math.log2(r));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(r){let t=[...this.chars],n=r;if(n===void 0){let o=["=",".","_","-","~","!"];for(let i of o)if(!t.includes(i)){n=i;break}if(!n)throw new Error("Cannot find suitable padding character")}if(n.length!==1)throw new Error("Padding character must be one UTF-16 code unit");if(t.includes(n))throw new Error("Padding character must not appear in charset");return {charset:t,padding:n}}};exports.a=be;exports.b=qe;exports.c=x;exports.d=zr;exports.e=St;exports.f=Dt;exports.g=hr;exports.h=B;exports.i=xr;exports.j=vr;
@@ -0,0 +1 @@
1
+ import {g as g$1}from'./chunk-B4QRMN45.js';import {n}from'./chunk-IZK7KCU7.js';import {a}from'./chunk-EI7MMDWY.js';var l=44032,f=55203,c=f-l+1;function g(e){if(e.length===0)throw new n("[Ddu64 obfuscation] Alphabet must not be empty.");if(e.length>c)throw new n(`[Ddu64 obfuscation] Alphabet size (${e.length}) exceeds available Hangul syllables (${c}).`);let t=Math.floor(c/e.length),r=new Map;for(let n=0;n<e.length;n++)r.set(e[n],n);return {alphabet:e,syllablesPerChar:t,charToIndex:r}}a(g,"buildSyllableMap");var u=class{static{a(this,"HangulObfuscationLayer");}config;constructor(t){this.config=g(t);}obfuscate(t){if(t.length===0)return "";let r=new Array(t.length);for(let n$1=0;n$1<t.length;n$1++){let o=t[n$1],s=this.config.charToIndex.get(o);if(s===void 0)throw new n(`[Ddu64 obfuscation] Character "${o}" (U+${o.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase()}) not found in obfuscation alphabet.`);let b=l+s*this.config.syllablesPerChar+n$1%this.config.syllablesPerChar;r[n$1]=String.fromCharCode(b);}return r.join("")}deobfuscate(t){if(t.length===0)return "";let r=new Array(t.length);for(let n$1=0;n$1<t.length;n$1++){let o=t.charCodeAt(n$1),s=o<l||o>f?-1:Math.floor((o-l)/this.config.syllablesPerChar);if(s<0||s>=this.config.alphabet.length)throw new n(`[Ddu64 obfuscation] Invalid syllable at position ${n$1}: U+${o.toString(16).padStart(4,"0").toUpperCase()} is not in the mapped range.`);r[n$1]=this.config.alphabet[s];}return r.join("")}};function A(e,t){return new u(g$1(e,t))}a(A,"createEncoderObfuscationLayer");function x(){let e=globalThis;return e.Deno?.version?.deno?"deno":e.Bun?.version?"bun":e.process?.versions?.node?"node":typeof e.EdgeRuntime=="string"||typeof e.WebSocketPair<"u"&&e.crypto?.subtle?"edge":typeof e.crypto<"u"&&e.crypto?.subtle?"browser":"unknown"}a(x,"detectRuntime");export{u as a,A as b,x as c};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkZTGECGM2_cjs=require('./chunk-ZTGECGM2.cjs'),chunkJY2ZPBJK_cjs=require('./chunk-JY2ZPBJK.cjs'),chunkBCUBYE76_cjs=require('./chunk-BCUBYE76.cjs');var u=new Set;function m(s){if(s.buffer instanceof ArrayBuffer)return s.byteOffset===0&&s.byteLength===s.buffer.byteLength?s.buffer:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength);let e=new Uint8Array(s.byteLength);return e.set(s),e.buffer}chunkBCUBYE76_cjs.a(m,"toArrayBuffer");function d(s,e){let r=`${e}:${s}`;if(!u.has(r)){try{e==="compress"&&typeof CompressionStream<"u"?(new CompressionStream(s),u.add(r)):e==="decompress"&&typeof DecompressionStream<"u"&&(new DecompressionStream(s),u.add(r));}catch{u.delete(r);}if(!u.has(r)){let n=s==="brotli"?"Brotli":"Deflate raw",t=e==="compress"?"CompressionStream":"DecompressionStream";throw new chunkZTGECGM2_cjs.m(`[Ddu64 ${e}] ${n} ${e}ion is unsupported in the current runtime. ${t} does not support "${s}".`,e)}}return s}chunkBCUBYE76_cjs.a(d,"requireCompressionFormat");var U=class{static{chunkBCUBYE76_cjs.a(this,"BrowserAdapter");}runtime;constructor(e="browser"){this.runtime=e;}async deriveKey(e,r){let t=new TextEncoder().encode(e);if(chunkJY2ZPBJK_cjs.a(r)==="pbkdf2"){let i=await crypto.subtle.importKey("raw",t,"PBKDF2",false,["deriveBits"]),a=await crypto.subtle.deriveBits({name:"PBKDF2",salt:chunkJY2ZPBJK_cjs.e(r?.salt),iterations:chunkJY2ZPBJK_cjs.b(r?.iterations),hash:chunkJY2ZPBJK_cjs.d(r?.hash)},i,256);return new Uint8Array(a)}let c=await crypto.subtle.digest("SHA-256",t);return new Uint8Array(c)}async encrypt(e,r,n){let t=crypto.getRandomValues(new Uint8Array(12)),c=await crypto.subtle.importKey("raw",m(r),{name:"AES-GCM"},false,["encrypt"]),i={name:"AES-GCM",iv:t,tagLength:128};n&&n.length>0&&(i.additionalData=m(n));let a=await crypto.subtle.encrypt(i,c,m(e)),o=new Uint8Array(a),y=o.subarray(0,o.length-16),f=o.subarray(o.length-16),p=new Uint8Array(28+y.length);return p.set(t,0),p.set(f,12),p.set(y,28),p}async decrypt(e,r,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 t=e.subarray(0,12),c=e.subarray(12,28),i=e.subarray(28),a=new Uint8Array(i.length+16);a.set(i,0),a.set(c,i.length);let o=await crypto.subtle.importKey("raw",m(r),{name:"AES-GCM"},false,["decrypt"]);try{let y={name:"AES-GCM",iv:m(t),tagLength:128};n&&n.length>0&&(y.additionalData=m(n));let f=await crypto.subtle.decrypt(y,o,m(a));return new Uint8Array(f)}catch{throw new Error("[Ddu64 decrypt] Decryption failed: data tampering or incorrect key.")}}randomBytes(e){return crypto.getRandomValues(new Uint8Array(e))}async deflate(e,r){let n=d("deflate-raw","compress"),t=new CompressionStream(n);return this.writeAndReadStream(t,e)}async inflate(e,r){let n=d("deflate-raw","decompress"),t=new DecompressionStream(n);return this.writeAndReadStream(t,e,r)}async brotliCompress(e,r){let n=d("brotli","compress"),t=new CompressionStream(n);return this.writeAndReadStream(t,e)}async brotliDecompress(e,r){let n=d("brotli","decompress"),t=new DecompressionStream(n);return this.writeAndReadStream(t,e,r)}async writeAndReadStream(e,r,n){let t=e.writable.getWriter(),c=e.readable.getReader(),i=(async()=>{await t.write(new Uint8Array(m(r))),await t.close();})(),a=this.readAllChunks(c,n);try{let[o]=await Promise.all([a,i]);return o}catch(o){throw await c.cancel(o).catch(()=>{}),await t.abort(o).catch(()=>{}),o}}async readAllChunks(e,r){let n=[],t=0;for(;;){let{done:a,value:o}=await e.read();if(a)break;if(t+=o.length,r!==void 0&&t>r)throw new Error(`[Ddu64 decompress] Decompressed size exceeds limit. Estimated ${t}+ bytes exceeds maximum of ${r} bytes.`);n.push(o);}if(n.length===1)return n[0];let c=new Uint8Array(t),i=0;for(let a of n)c.set(a,i),i+=a.length;return c}};exports.a=U;