@hashgraphonline/standards-sdk 0.0.60 → 0.0.61

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 (43) hide show
  1. package/dist/es/standards-sdk.es14.js +9 -9
  2. package/dist/es/standards-sdk.es14.js.map +1 -1
  3. package/dist/es/standards-sdk.es24.js +1 -1
  4. package/dist/es/standards-sdk.es26.js +1041 -5
  5. package/dist/es/standards-sdk.es26.js.map +1 -1
  6. package/dist/es/standards-sdk.es27.js +5 -1041
  7. package/dist/es/standards-sdk.es27.js.map +1 -1
  8. package/dist/es/standards-sdk.es34.js +1 -1
  9. package/dist/es/standards-sdk.es4.js +1 -1
  10. package/dist/es/standards-sdk.es51.js +4 -3
  11. package/dist/es/standards-sdk.es51.js.map +1 -1
  12. package/dist/es/standards-sdk.es52.js +3 -4
  13. package/dist/es/standards-sdk.es52.js.map +1 -1
  14. package/dist/es/standards-sdk.es65.js +3 -3
  15. package/dist/es/standards-sdk.es73.js +2 -2
  16. package/dist/es/standards-sdk.es74.js +2 -2
  17. package/dist/es/standards-sdk.es77.js +419 -3
  18. package/dist/es/standards-sdk.es77.js.map +1 -1
  19. package/dist/es/standards-sdk.es78.js +2 -2
  20. package/dist/es/standards-sdk.es78.js.map +1 -1
  21. package/dist/es/standards-sdk.es79.js +120 -2
  22. package/dist/es/standards-sdk.es79.js.map +1 -1
  23. package/dist/es/standards-sdk.es80.js +3 -34
  24. package/dist/es/standards-sdk.es80.js.map +1 -1
  25. package/dist/es/standards-sdk.es81.js +2 -33
  26. package/dist/es/standards-sdk.es81.js.map +1 -1
  27. package/dist/es/standards-sdk.es82.js +2 -9
  28. package/dist/es/standards-sdk.es82.js.map +1 -1
  29. package/dist/es/standards-sdk.es83.js +32 -32
  30. package/dist/es/standards-sdk.es83.js.map +1 -1
  31. package/dist/es/standards-sdk.es84.js +28 -414
  32. package/dist/es/standards-sdk.es84.js.map +1 -1
  33. package/dist/es/standards-sdk.es85.js +9 -2
  34. package/dist/es/standards-sdk.es85.js.map +1 -1
  35. package/dist/es/standards-sdk.es86.js +30 -116
  36. package/dist/es/standards-sdk.es86.js.map +1 -1
  37. package/dist/es/utils/logger.d.ts +4 -4
  38. package/dist/es/utils/logger.d.ts.map +1 -1
  39. package/dist/umd/standards-sdk.umd.js +1 -1
  40. package/dist/umd/standards-sdk.umd.js.map +1 -1
  41. package/dist/umd/utils/logger.d.ts +4 -4
  42. package/dist/umd/utils/logger.d.ts.map +1 -1
  43. package/package.json +2 -3
@@ -1,123 +1,37 @@
1
- var quickFormatUnescaped;
2
- var hasRequiredQuickFormatUnescaped;
3
- function requireQuickFormatUnescaped() {
4
- if (hasRequiredQuickFormatUnescaped) return quickFormatUnescaped;
5
- hasRequiredQuickFormatUnescaped = 1;
6
- function tryStringify(o) {
7
- try {
8
- return JSON.stringify(o);
9
- } catch (e) {
10
- return '"[Circular]"';
1
+ import utils from "./standards-sdk.es34.js";
2
+ import platform from "./standards-sdk.es60.js";
3
+ const cookies = platform.hasStandardBrowserEnv ? (
4
+ // Standard browser envs support document.cookie
5
+ {
6
+ write(name, value, expires, path, domain, secure) {
7
+ const cookie = [name + "=" + encodeURIComponent(value)];
8
+ utils.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
9
+ utils.isString(path) && cookie.push("path=" + path);
10
+ utils.isString(domain) && cookie.push("domain=" + domain);
11
+ secure === true && cookie.push("secure");
12
+ document.cookie = cookie.join("; ");
13
+ },
14
+ read(name) {
15
+ const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
16
+ return match ? decodeURIComponent(match[3]) : null;
17
+ },
18
+ remove(name) {
19
+ this.write(name, "", Date.now() - 864e5);
11
20
  }
12
21
  }
13
- quickFormatUnescaped = format;
14
- function format(f, args, opts) {
15
- var ss = opts && opts.stringify || tryStringify;
16
- var offset = 1;
17
- if (typeof f === "object" && f !== null) {
18
- var len = args.length + offset;
19
- if (len === 1) return f;
20
- var objects = new Array(len);
21
- objects[0] = ss(f);
22
- for (var index = 1; index < len; index++) {
23
- objects[index] = ss(args[index]);
24
- }
25
- return objects.join(" ");
22
+ ) : (
23
+ // Non-standard browser env (web workers, react-native) lack needed support.
24
+ {
25
+ write() {
26
+ },
27
+ read() {
28
+ return null;
29
+ },
30
+ remove() {
26
31
  }
27
- if (typeof f !== "string") {
28
- return f;
29
- }
30
- var argLen = args.length;
31
- if (argLen === 0) return f;
32
- var str = "";
33
- var a = 1 - offset;
34
- var lastPos = -1;
35
- var flen = f && f.length || 0;
36
- for (var i = 0; i < flen; ) {
37
- if (f.charCodeAt(i) === 37 && i + 1 < flen) {
38
- lastPos = lastPos > -1 ? lastPos : 0;
39
- switch (f.charCodeAt(i + 1)) {
40
- case 100:
41
- // 'd'
42
- case 102:
43
- if (a >= argLen)
44
- break;
45
- if (args[a] == null) break;
46
- if (lastPos < i)
47
- str += f.slice(lastPos, i);
48
- str += Number(args[a]);
49
- lastPos = i + 2;
50
- i++;
51
- break;
52
- case 105:
53
- if (a >= argLen)
54
- break;
55
- if (args[a] == null) break;
56
- if (lastPos < i)
57
- str += f.slice(lastPos, i);
58
- str += Math.floor(Number(args[a]));
59
- lastPos = i + 2;
60
- i++;
61
- break;
62
- case 79:
63
- // 'O'
64
- case 111:
65
- // 'o'
66
- case 106:
67
- if (a >= argLen)
68
- break;
69
- if (args[a] === void 0) break;
70
- if (lastPos < i)
71
- str += f.slice(lastPos, i);
72
- var type = typeof args[a];
73
- if (type === "string") {
74
- str += "'" + args[a] + "'";
75
- lastPos = i + 2;
76
- i++;
77
- break;
78
- }
79
- if (type === "function") {
80
- str += args[a].name || "<anonymous>";
81
- lastPos = i + 2;
82
- i++;
83
- break;
84
- }
85
- str += ss(args[a]);
86
- lastPos = i + 2;
87
- i++;
88
- break;
89
- case 115:
90
- if (a >= argLen)
91
- break;
92
- if (lastPos < i)
93
- str += f.slice(lastPos, i);
94
- str += String(args[a]);
95
- lastPos = i + 2;
96
- i++;
97
- break;
98
- case 37:
99
- if (lastPos < i)
100
- str += f.slice(lastPos, i);
101
- str += "%";
102
- lastPos = i + 2;
103
- i++;
104
- a--;
105
- break;
106
- }
107
- ++a;
108
- }
109
- ++i;
110
- }
111
- if (lastPos === -1)
112
- return f;
113
- else if (lastPos < flen) {
114
- str += f.slice(lastPos);
115
- }
116
- return str;
117
32
  }
118
- return quickFormatUnescaped;
119
- }
33
+ );
120
34
  export {
121
- requireQuickFormatUnescaped as __require
35
+ cookies as default
122
36
  };
123
37
  //# sourceMappingURL=standards-sdk.es86.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"standards-sdk.es86.js","sources":["../../node_modules/quick-format-unescaped/index.js"],"sourcesContent":["'use strict'\nfunction tryStringify (o) {\n try { return JSON.stringify(o) } catch(e) { return '\"[Circular]\"' }\n}\n\nmodule.exports = format\n\nfunction format(f, args, opts) {\n var ss = (opts && opts.stringify) || tryStringify\n var offset = 1\n if (typeof f === 'object' && f !== null) {\n var len = args.length + offset\n if (len === 1) return f\n var objects = new Array(len)\n objects[0] = ss(f)\n for (var index = 1; index < len; index++) {\n objects[index] = ss(args[index])\n }\n return objects.join(' ')\n }\n if (typeof f !== 'string') {\n return f\n }\n var argLen = args.length\n if (argLen === 0) return f\n var str = ''\n var a = 1 - offset\n var lastPos = -1\n var flen = (f && f.length) || 0\n for (var i = 0; i < flen;) {\n if (f.charCodeAt(i) === 37 && i + 1 < flen) {\n lastPos = lastPos > -1 ? lastPos : 0\n switch (f.charCodeAt(i + 1)) {\n case 100: // 'd'\n case 102: // 'f'\n if (a >= argLen)\n break\n if (args[a] == null) break\n if (lastPos < i)\n str += f.slice(lastPos, i)\n str += Number(args[a])\n lastPos = i + 2\n i++\n break\n case 105: // 'i'\n if (a >= argLen)\n break\n if (args[a] == null) break\n if (lastPos < i)\n str += f.slice(lastPos, i)\n str += Math.floor(Number(args[a]))\n lastPos = i + 2\n i++\n break\n case 79: // 'O'\n case 111: // 'o'\n case 106: // 'j'\n if (a >= argLen)\n break\n if (args[a] === undefined) break\n if (lastPos < i)\n str += f.slice(lastPos, i)\n var type = typeof args[a]\n if (type === 'string') {\n str += '\\'' + args[a] + '\\''\n lastPos = i + 2\n i++\n break\n }\n if (type === 'function') {\n str += args[a].name || '<anonymous>'\n lastPos = i + 2\n i++\n break\n }\n str += ss(args[a])\n lastPos = i + 2\n i++\n break\n case 115: // 's'\n if (a >= argLen)\n break\n if (lastPos < i)\n str += f.slice(lastPos, i)\n str += String(args[a])\n lastPos = i + 2\n i++\n break\n case 37: // '%'\n if (lastPos < i)\n str += f.slice(lastPos, i)\n str += '%'\n lastPos = i + 2\n i++\n a--\n break\n }\n ++a\n }\n ++i\n }\n if (lastPos === -1)\n return f\n else if (lastPos < flen) {\n str += f.slice(lastPos)\n }\n\n return str\n}\n"],"names":[],"mappings":";;;;;AACA,WAAS,aAAc,GAAG;AACxB,QAAI;AAAE,aAAO,KAAK,UAAU,CAAC;AAAA,IAAC,SAAS,GAAG;AAAE,aAAO;AAAA,IAAc;AAAA,EACnE;AAEA,yBAAiB;AAEjB,WAAS,OAAO,GAAG,MAAM,MAAM;AAC7B,QAAI,KAAM,QAAQ,KAAK,aAAc;AACrC,QAAI,SAAS;AACb,QAAI,OAAO,MAAM,YAAY,MAAM,MAAM;AACvC,UAAI,MAAM,KAAK,SAAS;AACxB,UAAI,QAAQ,EAAG,QAAO;AACtB,UAAI,UAAU,IAAI,MAAM,GAAG;AAC3B,cAAQ,CAAC,IAAI,GAAG,CAAC;AACjB,eAAS,QAAQ,GAAG,QAAQ,KAAK,SAAS;AACxC,gBAAQ,KAAK,IAAI,GAAG,KAAK,KAAK,CAAC;AAAA,MACrC;AACI,aAAO,QAAQ,KAAK,GAAG;AAAA,IAC3B;AACE,QAAI,OAAO,MAAM,UAAU;AACzB,aAAO;AAAA,IACX;AACE,QAAI,SAAS,KAAK;AAClB,QAAI,WAAW,EAAG,QAAO;AACzB,QAAI,MAAM;AACV,QAAI,IAAI,IAAI;AACZ,QAAI,UAAU;AACd,QAAI,OAAQ,KAAK,EAAE,UAAW;AAC9B,aAAS,IAAI,GAAG,IAAI,QAAO;AACzB,UAAI,EAAE,WAAW,CAAC,MAAM,MAAM,IAAI,IAAI,MAAM;AAC1C,kBAAU,UAAU,KAAK,UAAU;AACnC,gBAAQ,EAAE,WAAW,IAAI,CAAC,GAAC;AAAA,UACzB,KAAK;AAAA;AAAA,UACL,KAAK;AACH,gBAAI,KAAK;AACP;AACF,gBAAI,KAAK,CAAC,KAAK,KAAO;AACtB,gBAAI,UAAU;AACZ,qBAAO,EAAE,MAAM,SAAS,CAAC;AAC3B,mBAAO,OAAO,KAAK,CAAC,CAAC;AACrB,sBAAU,IAAI;AACd;AACA;AAAA,UACF,KAAK;AACH,gBAAI,KAAK;AACP;AACF,gBAAI,KAAK,CAAC,KAAK,KAAO;AACtB,gBAAI,UAAU;AACZ,qBAAO,EAAE,MAAM,SAAS,CAAC;AAC3B,mBAAO,KAAK,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC;AACjC,sBAAU,IAAI;AACd;AACA;AAAA,UACF,KAAK;AAAA;AAAA,UACL,KAAK;AAAA;AAAA,UACL,KAAK;AACH,gBAAI,KAAK;AACP;AACF,gBAAI,KAAK,CAAC,MAAM,OAAW;AAC3B,gBAAI,UAAU;AACZ,qBAAO,EAAE,MAAM,SAAS,CAAC;AAC3B,gBAAI,OAAO,OAAO,KAAK,CAAC;AACxB,gBAAI,SAAS,UAAU;AACrB,qBAAO,MAAO,KAAK,CAAC,IAAI;AACxB,wBAAU,IAAI;AACd;AACA;AAAA,YACZ;AACU,gBAAI,SAAS,YAAY;AACvB,qBAAO,KAAK,CAAC,EAAE,QAAQ;AACvB,wBAAU,IAAI;AACd;AACA;AAAA,YACZ;AACU,mBAAO,GAAG,KAAK,CAAC,CAAC;AACjB,sBAAU,IAAI;AACd;AACA;AAAA,UACF,KAAK;AACH,gBAAI,KAAK;AACP;AACF,gBAAI,UAAU;AACZ,qBAAO,EAAE,MAAM,SAAS,CAAC;AAC3B,mBAAO,OAAO,KAAK,CAAC,CAAC;AACrB,sBAAU,IAAI;AACd;AACA;AAAA,UACF,KAAK;AACH,gBAAI,UAAU;AACZ,qBAAO,EAAE,MAAM,SAAS,CAAC;AAC3B,mBAAO;AACP,sBAAU,IAAI;AACd;AACA;AACA;AAAA,QACV;AACM,UAAE;AAAA,MACR;AACI,QAAE;AAAA,IACN;AACE,QAAI,YAAY;AACd,aAAO;AAAA,aACA,UAAU,MAAM;AACvB,aAAO,EAAE,MAAM,OAAO;AAAA,IAC1B;AAEE,WAAO;AAAA,EACT;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"standards-sdk.es86.js","sources":["../../node_modules/axios/lib/helpers/cookies.js"],"sourcesContent":["import utils from './../utils.js';\nimport platform from '../platform/index.js';\n\nexport default platform.hasStandardBrowserEnv ?\n\n // Standard browser envs support document.cookie\n {\n write(name, value, expires, path, domain, secure) {\n const cookie = [name + '=' + encodeURIComponent(value)];\n\n utils.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());\n\n utils.isString(path) && cookie.push('path=' + path);\n\n utils.isString(domain) && cookie.push('domain=' + domain);\n\n secure === true && cookie.push('secure');\n\n document.cookie = cookie.join('; ');\n },\n\n read(name) {\n const match = document.cookie.match(new RegExp('(^|;\\\\s*)(' + name + ')=([^;]*)'));\n return (match ? decodeURIComponent(match[3]) : null);\n },\n\n remove(name) {\n this.write(name, '', Date.now() - 86400000);\n }\n }\n\n :\n\n // Non-standard browser env (web workers, react-native) lack needed support.\n {\n write() {},\n read() {\n return null;\n },\n remove() {}\n };\n\n"],"names":[],"mappings":";;AAGA,MAAe,UAAA,SAAS;AAAA;AAAA,EAGtB;AAAA,IACE,MAAM,MAAM,OAAO,SAAS,MAAM,QAAQ,QAAQ;AAChD,YAAM,SAAS,CAAC,OAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtD,YAAM,SAAS,OAAO,KAAK,OAAO,KAAK,aAAa,IAAI,KAAK,OAAO,EAAE,YAAW,CAAE;AAEnF,YAAM,SAAS,IAAI,KAAK,OAAO,KAAK,UAAU,IAAI;AAElD,YAAM,SAAS,MAAM,KAAK,OAAO,KAAK,YAAY,MAAM;AAExD,iBAAW,QAAQ,OAAO,KAAK,QAAQ;AAEvC,eAAS,SAAS,OAAO,KAAK,IAAI;AAAA,IACnC;AAAA,IAED,KAAK,MAAM;AACT,YAAM,QAAQ,SAAS,OAAO,MAAM,IAAI,OAAO,eAAe,OAAO,WAAW,CAAC;AACjF,aAAQ,QAAQ,mBAAmB,MAAM,CAAC,CAAC,IAAI;AAAA,IAChD;AAAA,IAED,OAAO,MAAM;AACX,WAAK,MAAM,MAAM,IAAI,KAAK,IAAK,IAAG,KAAQ;AAAA,IAChD;AAAA,EACA;AAAA;AAAA;AAAA,EAKE;AAAA,IACE,QAAQ;AAAA,IAAE;AAAA,IACV,OAAO;AACL,aAAO;AAAA,IACR;AAAA,IACD,SAAS;AAAA,IAAA;AAAA,EACV;AAAA;","x_google_ignoreList":[0]}
@@ -14,9 +14,9 @@ export declare class Logger {
14
14
  setLogLevel(level: LogLevel): void;
15
15
  setSilent(silent: boolean): void;
16
16
  setModule(module: string): void;
17
- debug(message: string, data?: any): void;
18
- info(message: string, data?: any): void;
19
- warn(message: string, data?: any): void;
20
- error(message: string, data?: any): void;
17
+ debug(...args: any[]): void;
18
+ info(...args: any[]): void;
19
+ warn(...args: any[]): void;
20
+ error(...args: any[]): void;
21
21
  }
22
22
  //# sourceMappingURL=logger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkC;IAC1D,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,GAAE,aAAkB;IAuBvC,MAAM,CAAC,WAAW,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM;IAUvD,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAIlC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAMhC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIxC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIvC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;IAIvC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI;CAGzC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAkC;IAC1D,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,aAAa,CAAS;gBAElB,OAAO,GAAE,aAAkB;IAuBvC,MAAM,CAAC,WAAW,CAAC,OAAO,GAAE,aAAkB,GAAG,MAAM;IAUvD,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAIlC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAMhC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI3B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI1B,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI1B,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAG5B"}
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).StandardsSDK={})}(this,(function(exports){"use strict";var __defProp2=Object.defineProperty,__typeError=e=>{throw TypeError(e)},__defNormalProp2=(e,t,r)=>t in e?__defProp2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__publicField2=(e,t,r)=>__defNormalProp2(e,"symbol"!=typeof t?t+"":t,r),__accessCheck=(e,t,r)=>t.has(e)||__typeError("Cannot "+r),__privateGet=(e,t,r)=>(__accessCheck(e,t,"read from private field"),r?r.call(e):t.get(e)),__privateAdd=(e,t,r)=>t.has(e)?__typeError("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),__privateSet=(e,t,r,n)=>(__accessCheck(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),__privateMethod=(e,t,r)=>(__accessCheck(e,t,"access private method"),r),__privateWrapper=(e,t,r,n)=>({set _(n){__privateSet(e,t,n,r)},get _(){return __privateGet(e,t,n)}}),_a2,_names,_data,_dataLength,_Writer_instances,writeData_fn,_data2,_offset,_bytesRead,_parent,_maxInflation,_Reader_instances,incrementBytesRead_fn,peekBytes_fn,_options,_offset2,_tokens,_TokenString_instances,subTokenString_fn,_ParamType_instances,walkAsync_fn,_AbiCoder_instances,getCoder_fn,_errors,_events,_functions,_abiCoder,_Interface_instances,getFunction_fn,getEvent_fn;function _mergeNamespaces(e,t){for(var r=0;r<t.length;r++){const n=t[r];if("string"!=typeof n&&!Array.isArray(n))for(const t in n)if("default"!==t&&!(t in e)){const r=Object.getOwnPropertyDescriptor(n,t);r&&Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs$2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var browser$e={exports:{}},quickFormatUnescaped,hasRequiredQuickFormatUnescaped,hasRequiredBrowser$d;function requireQuickFormatUnescaped(){if(hasRequiredQuickFormatUnescaped)return quickFormatUnescaped;function e(e){try{return JSON.stringify(e)}catch(t){return'"[Circular]"'}}return hasRequiredQuickFormatUnescaped=1,quickFormatUnescaped=function(t,r,n){var o=n&&n.stringify||e;if("object"==typeof t&&null!==t){var i=r.length+1;if(1===i)return t;var a=new Array(i);a[0]=o(t);for(var s=1;s<i;s++)a[s]=o(r[s]);return a.join(" ")}if("string"!=typeof t)return t;var c=r.length;if(0===c)return t;for(var u="",l=0,d=-1,p=t&&t.length||0,h=0;h<p;){if(37===t.charCodeAt(h)&&h+1<p){switch(d=d>-1?d:0,t.charCodeAt(h+1)){case 100:case 102:if(l>=c)break;if(null==r[l])break;d<h&&(u+=t.slice(d,h)),u+=Number(r[l]),d=h+2,h++;break;case 105:if(l>=c)break;if(null==r[l])break;d<h&&(u+=t.slice(d,h)),u+=Math.floor(Number(r[l])),d=h+2,h++;break;case 79:case 111:case 106:if(l>=c)break;if(void 0===r[l])break;d<h&&(u+=t.slice(d,h));var f=typeof r[l];if("string"===f){u+="'"+r[l]+"'",d=h+2,h++;break}if("function"===f){u+=r[l].name||"<anonymous>",d=h+2,h++;break}u+=o(r[l]),d=h+2,h++;break;case 115:if(l>=c)break;d<h&&(u+=t.slice(d,h)),u+=String(r[l]),d=h+2,h++;break;case 37:d<h&&(u+=t.slice(d,h)),u+="%",d=h+2,h++,l--}++l}++h}if(-1===d)return t;d<p&&(u+=t.slice(d));return u}}function requireBrowser$d(){if(hasRequiredBrowser$d)return browser$e.exports;hasRequiredBrowser$d=1;const e=requireQuickFormatUnescaped();browser$e.exports=c;const t=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},r={mapHttpRequest:f,mapHttpResponse:f,wrapRequestSerializer:m,wrapResponseSerializer:m,wrapErrorSerializer:m,req:f,res:f,err:p,errWithCause:p};function n(e,t){return"silent"===e?1/0:t.levels.values[e]}const o=Symbol("pino.logFuncs"),i=Symbol("pino.hierarchy"),a={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function s(e,t){const r={logger:t,parent:e[i]};t[i]=r}function c(e){(e=e||{}).browser=e.browser||{};const r=e.browser.transmit;if(r&&"function"!=typeof r.send)throw Error("pino: transmit option must have a send function");const i=e.browser.write||t;e.browser.write&&(e.browser.asObject=!0);const p=e.serializers||{},f=function(e,t){if(Array.isArray(e))return e.filter((function(e){return"!stdSerializers.err"!==e}));return!0===e&&Object.keys(t)}(e.browser.serialize,p);let m=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(m=!1);const g=Object.keys(e.customLevels||{}),b=["error","fatal","warn","info","debug","trace"].concat(g);"function"==typeof i&&b.forEach((function(e){i[e]=i})),(!1===e.enabled||e.browser.disabled)&&(e.level="silent");const v=e.level||"info",w=Object.create(i);w.log||(w.log=y),function(e,r,n){const i={};r.forEach((e=>{i[e]=n[e]?n[e]:t[e]||t[a[e]||"log"]||y})),e[o]=i}(w,b,i),s({},w),Object.defineProperty(w,"levelVal",{get:function(){return n(this.level,this)}}),Object.defineProperty(w,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,u(this,k,w,"error"),u(this,k,w,"fatal"),u(this,k,w,"warn"),u(this,k,w,"info"),u(this,k,w,"debug"),u(this,k,w,"trace"),g.forEach((e=>{u(this,k,w,e)}))}});const k={transmit:r,serialize:f,asObject:e.browser.asObject,formatters:e.browser.formatters,levels:b,timestamp:h(e),messageKey:e.messageKey||"msg",onChild:e.onChild||y};function _(t,n,o){if(!n)throw new Error("missing bindings for child Pino");o=o||{},f&&n.serializers&&(o.serializers=n.serializers);const i=o.serializers;if(f&&i){var a=Object.assign({},p,i),c=!0===e.browser.serialize?Object.keys(a):f;delete n.serializers,l([n],c,a,this._stdErrSerialize)}function u(e){this._childLevel=1+(0|e._childLevel),this.bindings=n,a&&(this.serializers=a,this._serialize=c),r&&(this._logEvent=d([].concat(e._logEvent.bindings,n)))}u.prototype=this;const h=new u(this);return s(this,h),h.child=function(...e){return _.call(this,t,...e)},h.level=o.level||this.level,t.onChild(h),h}return w.levels=function(e){const t=e.customLevels||{},r=Object.assign({},c.levels.values,t),n=Object.assign({},c.levels.labels,function(e){const t={};return Object.keys(e).forEach((function(r){t[e[r]]=r})),t}(t));return{values:r,labels:n}}(e),w.level=v,w.setMaxListeners=w.getMaxListeners=w.emit=w.addListener=w.on=w.prependListener=w.once=w.prependOnceListener=w.removeListener=w.removeAllListeners=w.listeners=w.listenerCount=w.eventNames=w.write=w.flush=y,w.serializers=p,w._serialize=f,w._stdErrSerialize=m,w.child=function(...e){return _.call(this,k,...e)},r&&(w._logEvent=d()),w}function u(r,a,s,c){if(Object.defineProperty(r,c,{value:n(r.level,s)>n(c,s)?y:s[o][c],writable:!0,enumerable:!0,configurable:!0}),r[c]===y){if(!a.transmit)return;const e=n(a.transmit.level||r.level,s);if(n(c,s)<e)return}r[c]=function(r,i,a,s){return function(o){return function(){const c=i.timestamp(),u=new Array(arguments.length),p=Object.getPrototypeOf&&Object.getPrototypeOf(this)===t?t:this;for(var h=0;h<u.length;h++)u[h]=arguments[h];var f=!1;if(i.serialize&&(l(u,this._serialize,this.serializers,this._stdErrSerialize),f=!0),i.asObject||i.formatters?o.call(p,function(t,r,n,o,i){const{level:a,log:s=e=>e}=i.formatters||{},c=n.slice();let u=c[0];const l={};o&&(l.time=o);if(a){const e=a(r,t.levels.values[r]);Object.assign(l,e)}else l.level=t.levels.values[r];let d=1+(0|t._childLevel);d<1&&(d=1);if(null!==u&&"object"==typeof u){for(;d--&&"object"==typeof c[0];)Object.assign(l,c.shift());u=c.length?e(c.shift(),c):void 0}else"string"==typeof u&&(u=e(c.shift(),c));void 0!==u&&(l[i.messageKey]=u);return s(l)}(this,s,u,c,i)):o.apply(p,u),i.transmit){const e=n(i.transmit.level||r._level,a),t=n(s,a);if(t<e)return;!function(e,t,r,n=!1){const o=t.send,i=t.ts,a=t.methodLevel,s=t.methodValue,c=t.val,u=e._logEvent.bindings;n||l(r,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize);e._logEvent.ts=i,e._logEvent.messages=r.filter((function(e){return-1===u.indexOf(e)})),e._logEvent.level.label=a,e._logEvent.level.value=s,o(a,e._logEvent,c),e._logEvent=d(u)}(this,{ts:c,methodLevel:s,methodValue:t,transmitValue:a.levels.values[i.transmit.level||r._level],send:i.transmit.send,val:n(r._level,a)},u,f)}}}(r[o][s])}(r,a,s,c);const u=function(e){const t=[];e.bindings&&t.push(e.bindings);let r=e[i];for(;r.parent;)r=r.parent,r.logger.bindings&&t.push(r.logger.bindings);return t.reverse()}(r);0!==u.length&&(r[c]=function(e,t){return function(){return t.apply(this,[...e,...arguments])}}(u,r[c]))}function l(e,t,r,n){for(const o in e)if(n&&e[o]instanceof Error)e[o]=c.stdSerializers.err(e[o]);else if("object"==typeof e[o]&&!Array.isArray(e[o])&&t)for(const n in e[o])t.indexOf(n)>-1&&n in r&&(e[o][n]=r[n](e[o][n]))}function d(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function p(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t}function h(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?g:b}function f(){return{}}function m(e){return e}function y(){}function g(){return!1}function b(){return Date.now()}return c.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},c.stdSerializers=r,c.stdTimeFunctions=Object.assign({},{nullTime:g,epochTime:b,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}}),browser$e.exports.default=c,browser$e.exports.pino=c,browser$e.exports}var browserExports$2=requireBrowser$d();const e$c=getDefaultExportFromCjs$2(browserExports$2);let Logger$2=(_a2=class{constructor(e={}){const t=e.level||"info";this.moduleContext=e.module||"app";const r={level:t,enabled:!e.silent,transport:!1!==e.prettyPrint?{target:"pino-pretty",options:{colorize:!0,translateTime:"SYS:standard",ignore:"pid,hostname"}}:void 0};this.logger=e$c(r)}static getInstance(e={}){const t=e.module||"default";return _a2.instances.has(t)||_a2.instances.set(t,new _a2(e)),_a2.instances.get(t)}setLogLevel(e){this.logger.level=e}setSilent(e){e&&(this.logger.level="silent")}setModule(e){this.moduleContext=e}debug(e,t){this.logger.debug({module:this.moduleContext},e,t)}info(e,t){this.logger.info({module:this.moduleContext},e,t)}warn(e,t){this.logger.warn({module:this.moduleContext},e,t)}error(e,t){this.logger.error({module:this.moduleContext},e,t)}},_a2.instances=new Map,_a2);const sleep$1=e=>new Promise((t=>setTimeout(t,e)));class HCS{constructor(){this.modelViewerLoaded=!1,this.modelViewerLoading=null,this.config={cdnUrl:"https://kiloscribe.com/api/inscription-cdn/",network:"mainnet",retryAttempts:3,retryBackoff:300,debug:!1,showLoadingIndicator:!1,loadingCallbackName:null},this.configMapping={hcsCdnUrl:"cdnUrl",hcsNetwork:"network",hcsRetryAttempts:"retryAttempts",hcsRetryBackoff:"retryBackoff",hcsDebug:"debug",hcsShowLoadingIndicator:"showLoadingIndicator",hcsLoadingCallbackName:"loadingCallbackName"},this.LoadedScripts={},this.LoadedWasm={},this.LoadedImages={},this.LoadedVideos={},this.LoadedAudios={},this.LoadedAudioUrls={},this.LoadedGLBs={},this.scriptLoadedEvent=new Event("HCSScriptLoaded"),this.loadQueue=[],this.isProcessingQueue=!1;try{this.logger=Logger$2.getInstance({module:"HCS-3",level:this.config.debug?"debug":"error"})}catch(e){this.logger=this.createFallbackLogger()}}createFallbackLogger(){return{debug:(...e)=>this.config.debug&&console.debug("[HCS-3]",...e),info:(...e)=>this.config.debug&&console.info("[HCS-3]",...e),warn:(...e)=>console.warn("[HCS-3]",...e),error:(...e)=>console.error("[HCS-3]",...e),setLogLevel:e=>{this.config.debug="debug"===e}}}log(...e){if(0===e.length)this.logger.debug("");else if(1===e.length)this.logger.debug(String(e[0]));else{const t=String(e[0]),r=e.slice(1);this.logger.debug(t,r)}}error(...e){if(0===e.length)this.logger.error("");else if(1===e.length)this.logger.error(String(e[0]));else{const t=String(e[0]),r=e.slice(1);this.logger.error(t,r)}}loadConfigFromHTML(){const e=document.querySelector("script[data-hcs-config]");e&&(Object.keys(this.configMapping).forEach((t=>{if(e.dataset[t]){const r=this.configMapping[t];let n=e.dataset[t];"true"===n&&(n=!0),"false"===n&&(n=!1),isNaN(Number(n))||""===n||(n=Number(n)),this.config[r]=n}})),this.logger.setLogLevel(this.config.debug?"debug":"error")),this.log("Loaded config:",this.config)}updateLoadingStatus(e,t){if("loaded"!==this.LoadedScripts[e]&&(this.config.showLoadingIndicator&&console.log("[HCS Loading] "+e+" : "+t),this.LoadedScripts[e]=t,this.config.loadingCallbackName&&"function"==typeof window[this.config.loadingCallbackName])){const r=window[this.config.loadingCallbackName];"function"==typeof r&&r(e,t)}}async fetchWithRetry(e,t=this.config.retryAttempts,r=this.config.retryBackoff){try{const t=await fetch(e);if(!t.ok)throw new Error("HTTP error! status: "+t.status);return t}catch(n){if(t>0)return this.log("Retrying fetch for "+e+" Attempts left: "+(t-1)),await this.sleep(r),this.fetchWithRetry(e,t-1,2*r);throw n}}sleep(e){return new Promise((t=>setTimeout(t,e)))}isDuplicate(e){return!!this.LoadedScripts[e]}async retrieveHCS1Data(e,t=this.config.cdnUrl,r=this.config.network){const n=r.replace(/['"]+/g,""),o=await this.fetchWithRetry(t+e+"?network="+n);return await o.blob()}async loadScript(e){const t=e.getAttribute("data-src"),r=e.getAttribute("data-script-id"),n=t?.split("/").pop(),o=e.getAttribute("type"),i=e.hasAttribute("data-required"),a="module"===e.getAttribute("type");if(!this.isDuplicate(n||"")){this.updateLoadingStatus(r,"loading");try{const t=e.getAttribute("data-cdn-url")||this.config.cdnUrl,s=e.getAttribute("data-network")||this.config.network,c=await this.retrieveHCS1Data(n,t,s);if("wasm"===o){const t=await c.arrayBuffer(),n=await WebAssembly.compile(t);this.LoadedWasm[r]=await WebAssembly.instantiate(n,{env:{},...e.dataset}),this.updateLoadingStatus(r,"loaded"),window.dispatchEvent(this.scriptLoadedEvent),this.log("Loaded wasm: "+r)}else{const e=await c.text(),t=document.createElement("script");if(t.textContent=e,t.className="hcs-inline-script",r&&t.setAttribute("data-loaded-script-id",r),a){t.type="module";const r=new Blob([e],{type:"application/javascript"});t.src=URL.createObjectURL(r)}document.body.appendChild(t),this.updateLoadingStatus(r,"loaded"),window.dispatchEvent(this.scriptLoadedEvent),this.log("Loaded script: "+r),t.onerror=e=>{if(this.error("Failed to load "+o+": "+r,e),this.updateLoadingStatus(r,"failed"),i)throw e}}}catch(s){if(this.error("Failed to load "+o+": "+r,s),this.updateLoadingStatus(r,"failed"),i)throw s}}}async loadModuleExports(e){const t=document.querySelector('script[data-loaded-script-id="'+e+'"]');if(!t)throw new Error("Module script with id "+e+" not found");const r=t.getAttribute("src");if(!r)throw new Error("Module script "+e+" has no src attribute");try{return await import(r)}catch(n){throw this.error("Failed to import module",n),n}}async loadStylesheet(e){const t=e.getAttribute("data-src"),r=e.getAttribute("data-script-id"),n=t?.split("/").pop(),o=e.hasAttribute("data-required");if(!this.isDuplicate(n||"")){this.updateLoadingStatus(r,"loading");try{const t=e.getAttribute("data-cdn-url")||this.config.cdnUrl,o=e.getAttribute("data-network")||this.config.network,i=await this.retrieveHCS1Data(n,t,o),a=await i.text(),s=document.createElement("style");s.textContent=a,document.head.appendChild(s),this.updateLoadingStatus(r,"loaded"),window.dispatchEvent(this.scriptLoadedEvent),this.log("Loaded and inlined stylesheet: "+r)}catch(i){if(this.error("Failed to load stylesheet: "+r,i),this.updateLoadingStatus(r,"failed"),o)throw i}}}async loadImage(e){const t=e.getAttribute("data-src"),r=t?.split("/").pop();this.log("Loading image: "+r),this.updateLoadingStatus("Image: "+r,"loaded");try{const t=e.getAttribute("data-cdn-url")||this.config.cdnUrl,n=e.getAttribute("data-network")||this.config.network,o=await this.retrieveHCS1Data(r,t,n),i=URL.createObjectURL(o);e.src=i,this.LoadedImages[r]=i,this.updateLoadingStatus("Image: "+r,"loaded"),this.log("Loaded image: "+r)}catch(n){this.error("Failed to load image: "+r,n),this.updateLoadingStatus("Image: "+r,"failed")}}async loadMedia(e,t){const r=e.getAttribute("data-src"),n=r?.split("/").pop();this.log("Loading "+t+": "+n),this.updateLoadingStatus(t+": "+n,"loading");try{const r=e.getAttribute("data-cdn-url")||this.config.cdnUrl,o=e.getAttribute("data-network")||this.config.network,i=await this.retrieveHCS1Data(n,r,o),a=URL.createObjectURL(i);e.src=a,"video"===t?this.LoadedVideos[n]=a:this.LoadedAudioUrls[n]=a,this.updateLoadingStatus(t+": "+n,"loaded"),this.log("Loaded "+t+": "+n)}catch(o){this.error("Failed to load "+t+": "+n,o),this.updateLoadingStatus(t+": "+n,"failed")}}async loadModelViewer(){return this.modelViewerLoading?this.modelViewerLoading:this.modelViewerLoaded?Promise.resolve():(this.modelViewerLoading=new Promise((e=>{const t=document.createElement("script");t.setAttribute("data-src","hcs://1/0.0.7293044"),t.setAttribute("data-script-id","model-viewer"),t.setAttribute("type","module"),window.addEventListener("HCSScriptLoaded",(()=>{this.modelViewerLoaded=!0,e()}),{once:!0}),this.loadScript(t)})),this.modelViewerLoading)}async loadGLB(e){await this.loadModelViewer();const t=e.getAttribute("data-src"),r=t?.split("/").pop();this.log("Loading GLB: "+r),this.updateLoadingStatus("GLB: "+r,"loading");try{const t=e.getAttribute("data-cdn-url")||this.config.cdnUrl,n=e.getAttribute("data-network")||this.config.network;let o;"model-viewer"!==e.tagName.toLowerCase()?(o=document.createElement("model-viewer"),Array.from(e.attributes).forEach((e=>{o.setAttribute(e.name,e.value)})),o.setAttribute("camera-controls",""),o.setAttribute("auto-rotate",""),o.setAttribute("ar",""),e.parentNode?.replaceChild(o,e)):o=e;const i=await this.retrieveHCS1Data(r,t,n),a=URL.createObjectURL(i);o.setAttribute("src",a),this.LoadedGLBs[r]=a,this.updateLoadingStatus("GLB: "+r,"loaded"),this.log("Loaded GLB: "+r)}catch(n){this.error("Failed to load GLB: "+r,n),this.updateLoadingStatus("GLB: "+r,"failed")}}async loadResource(e,t,r){return new Promise((n=>{this.loadQueue.push({element:e,type:t,order:r,resolve:n}),this.processQueue()}))}async processQueue(){if(!this.isProcessingQueue){for(this.isProcessingQueue=!0;this.loadQueue.length>0;){const t=this.loadQueue.shift();try{"script"===t.type?await this.loadScript(t.element):"image"===t.type?await this.loadImage(t.element):"video"===t.type||"audio"===t.type?await this.loadMedia(t.element,t.type):"glb"===t.type?await this.loadGLB(t.element):"css"===t.type&&await this.loadStylesheet(t.element),t.resolve()}catch(e){if(this.error("Error processing queue item:",e),"script"===t.type&&t.element.hasAttribute("data-required"))break}}this.isProcessingQueue=!1}}async replaceHCSInStyle(e){let t=e,r=t.indexOf("hcs://");for(;-1!==r;){let e=r;for(;e<t.length&&!["'",'"'," ",")"].includes(t[e]);)e++;const o=t.substring(r,e),i=o.split("/").pop();try{const n=this.config.cdnUrl,a=this.config.network,s=await this.retrieveHCS1Data(i,n,a),c=URL.createObjectURL(s);t=t.substring(0,r)+c+t.substring(e),this.LoadedImages[i]=c,this.log("Replaced CSS HCS URL: "+o+" with "+c)}catch(n){this.error("Failed to load CSS image: "+i,n)}r=t.indexOf("hcs://",r+1)}return t}async processInlineStyles(){const e=document.querySelectorAll('[style*="hcs://"]');this.log("Found "+e.length+" elements with HCS style references");for(const r of Array.from(e)){const e=r.getAttribute("style");if(e){this.log("Processing style: "+e);const t=await this.replaceHCSInStyle(e);e!==t&&(r.setAttribute("style",t),this.log("Updated style to: "+t))}}const t=document.querySelectorAll("style");for(const r of Array.from(t))if(r.textContent?.includes("hcs://")){const e=await this.replaceHCSInStyle(r.textContent);r.textContent!==e&&(r.textContent=e)}}async init(){return this.loadConfigFromHTML(),new Promise((e=>{const t=async()=>{const t=document.querySelectorAll('script[data-src^="hcs://"]'),r=document.querySelectorAll('img[data-src^="hcs://"], img[src^="hcs://"]'),n=document.querySelectorAll('video[data-src^="hcs://"], video[src^="hcs://"]'),o=document.querySelectorAll('audio[data-src^="hcs://"], audio[src^="hcs://"]'),i=document.querySelectorAll('model-viewer[data-src^="hcs://"]'),a=document.querySelectorAll('link[data-src^="hcs://"]');document.querySelectorAll('[src^="hcs://"]').forEach((e=>{const t=e.getAttribute("src");t&&(e.setAttribute("data-src",t),e.removeAttribute("src"))})),await this.processInlineStyles();const s=[];[{elements:t,type:"script"},{elements:r,type:"image"},{elements:n,type:"video"},{elements:o,type:"audio"},{elements:i,type:"glb"},{elements:a,type:"css"}].forEach((({elements:e,type:t})=>{e.forEach((e=>{const r=parseInt(e.getAttribute("data-load-order")||"")||1/0;s.push(this.loadResource(e,t,r))}))})),await Promise.all(s);const c=new MutationObserver((e=>{e.forEach((e=>{if(e.addedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.getAttribute("style")?.includes("hcs://")&&this.processInlineStyles(),"style"===t.tagName.toLowerCase()&&t.textContent?.includes("hcs://")&&this.processInlineStyles(),t.getAttribute("src")?.startsWith("hcs://")){const e=t.getAttribute("src");t.setAttribute("data-src",e),t.removeAttribute("src");switch(t.tagName.toLowerCase()){case"img":this.loadResource(t,"image",1/0);break;case"video":this.loadResource(t,"video",1/0);break;case"audio":this.loadResource(t,"audio",1/0);break;case"script":this.loadResource(t,"script",1/0)}}t.matches('script[data-src^="hcs://"]')?this.loadResource(t,"script",1/0):t.matches('img[data-src^="hcs://"]')?this.loadResource(t,"image",1/0):t.matches('video[data-src^="hcs://"]')?this.loadResource(t,"video",1/0):t.matches('audio[data-src^="hcs://"]')?this.loadResource(t,"audio",1/0):t.matches('model-viewer[data-src^="hcs://"]')?this.loadResource(t,"glb",1/0):t.matches('link[data-src^="hcs://"]')&&this.loadResource(t,"css",1/0);t.querySelectorAll('[data-src^="hcs://"], [src^="hcs://"]').forEach((e=>{const t=e,r=t.tagName.toLowerCase(),n=t.getAttribute("src");switch(n?.startsWith("hcs://")&&(t.setAttribute("data-src",n),t.removeAttribute("src")),r){case"script":this.loadResource(t,"script",1/0);break;case"img":this.loadResource(t,"image",1/0);break;case"video":this.loadResource(t,"video",1/0);break;case"audio":this.loadResource(t,"audio",1/0);break;case"model-viewer":this.loadResource(t,"glb",1/0);break;case"link":this.loadResource(t,"css",1/0)}}))}})),"attributes"===e.type){const t=e.target;if("style"===e.attributeName&&t.getAttribute("style")?.includes("hcs://"))this.processInlineStyles();else if("src"===e.attributeName){const e=t.getAttribute("src");if(e?.startsWith("hcs://")){t.setAttribute("data-src",e),t.removeAttribute("src");const r=t.tagName.toLowerCase();["img","video","audio"].includes(r)&&this.loadResource(t,r,1/0)}}}}))}));document.body?c.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","src","data-src"]}):document.addEventListener("DOMContentLoaded",(()=>{c.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","src","data-src"]})})),e()};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}))}async preloadImage(e){this.log("Loading image:"+e),this.updateLoadingStatus("image: "+e,"loading");const t=await this.retrieveHCS1Data(e),r=URL.createObjectURL(t);return this.LoadedImages[e]=r,this.updateLoadingStatus("image: "+e,"loaded"),r}async preloadAudio(e){const t=document.createElement("audio");t.setAttribute("data-topic-id",e),t.setAttribute("data-src","hcs://1/"+e),document.body.appendChild(t),await this.loadMedia(t,"audio");const r=document.querySelector('audio[data-topic-id="'+e+'"]');return r?this.LoadedAudioUrls[e]=r.src:console.error("Failed to preload audio: "+e),this.LoadedAudioUrls[e]}async playAudio(e,t=1){const r=this.LoadedAudioUrls[e];if(r){const n=new Audio(r);n.volume=t,this.LoadedAudios[e]=n,n.play().catch((e=>{console.error("Failed to play audio:",e)})),n.addEventListener("ended",(()=>{n.remove(),delete this.LoadedAudios[e]}))}else console.error("Audio not preloaded: "+e)}async pauseAudio(e){const t=document.querySelector('audio[data-topic-id="'+e+'"]');t?(console.log("found element",t),t.pause(),this.LoadedAudios[e]?.pause()):this.LoadedAudios[e]?.pause()}async loadAndPlayAudio(e,t=!1,r=1){let n=document.querySelector('audio[data-topic-id="'+e+'"]');if(n)n.volume=r,await n.play();else{const o=document.createElement("audio");o.volume=r,t&&o.setAttribute("autoplay","autoplay"),o.setAttribute("data-topic-id",e),o.setAttribute("data-src","hcs://1/"+e),document.body.appendChild(o),await this.loadMedia(o,"audio"),n=document.querySelector('audio[data-topic-id="'+e+'"]'),t||await n.play()}}}const isServer="undefined"==typeof window;isServer||(window.HCS=new HCS,window.HCS.init().then((()=>{console.log("All HCS resources loaded"),"function"==typeof window.HCSReady&&(console.log("Running HCSReady..."),window.HCSReady())})));class WasmBridge{constructor(){this.wasm=null,this.WASM_VECTOR_LEN=0,this.cachedUint8Memory=null,this.cachedDataViewMemory=null,this.textEncoder=new TextEncoder,this.textDecoder=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),this.textDecoder.decode(),this.logger=Logger$2.getInstance({module:"WasmBridge"})}setLogLevel(e){this.logger.setLogLevel(e)}get wasmInstance(){if(!this.wasm)throw new Error("WASM not initialized");return this.wasm}getUint8Memory(){if(!this.wasm)throw new Error("WASM not initialized");return null!==this.cachedUint8Memory&&0!==this.cachedUint8Memory.byteLength||(this.cachedUint8Memory=new Uint8Array(this.wasm.memory.buffer)),this.cachedUint8Memory}getDataViewMemory(){if(!this.wasm)throw new Error("WASM not initialized");return null!==this.cachedDataViewMemory&&this.cachedDataViewMemory.buffer===this.wasm.memory.buffer||(this.cachedDataViewMemory=new DataView(this.wasm.memory.buffer)),this.cachedDataViewMemory}encodeString(e,t){if(0===e.length)return{read:0,written:0};const r=this.textEncoder.encode(e);return t.set(r),{read:e.length,written:r.length}}passStringToWasm(e,t,r){if(void 0===r){const r=this.textEncoder.encode(e),n=t(r.length,1);return this.getUint8Memory().set(r,n),this.WASM_VECTOR_LEN=r.length,n}let n=this.textEncoder.encode(e).length,o=t(n,1);const i=this.getUint8Memory();let a=0;for(;a<n;a++){const t=e.charCodeAt(a);if(t>127)break;i[o+a]=t}if(a!==n){0!==a&&(e=e.slice(a)),o=r(o,n,n=a+3*this.textEncoder.encode(e).length,1);const t=this.getUint8Memory().subarray(o+a,o+n);a+=this.encodeString(e,t).written}return this.WASM_VECTOR_LEN=a,o}getStringFromWasm(e,t){return e>>>=0,this.textDecoder.decode(this.getUint8Memory().subarray(e,e+t))}createWasmFunction(e){if(!this.wasm)throw new Error("WASM not initialized");return(...t)=>{const r=this.wasm.__wbindgen_add_to_stack_pointer(-16);let n=[0,0];try{const o=[r,...t.map((e=>[this.passStringToWasm(e,this.wasm.__wbindgen_malloc,this.wasm.__wbindgen_realloc),this.WASM_VECTOR_LEN])).flat()];e.apply(this.wasm,o);const i=this.getDataViewMemory().getInt32(r+0,!0),a=this.getDataViewMemory().getInt32(r+4,!0);return n=[i,a],this.getStringFromWasm(i,a)}finally{this.wasm.__wbindgen_add_to_stack_pointer(16),this.wasm.__wbindgen_free(n[0],n[1],1)}}}async initWasm(e){const t=this,r={__wbindgen_placeholder__:{__wbindgen_throw:function(e,r){const n=t.getStringFromWasm(e,r);throw t.logger.error(`WASM error: ${n}`),new Error(n)}}};try{this.logger.debug("Compiling WASM module");const t=await WebAssembly.compile(e);this.logger.debug("Instantiating WASM module");const n=await WebAssembly.instantiate(t,r);return this.wasm=n.exports,this.logger.info("WASM module initialized successfully"),this.wasm}catch(n){throw this.logger.error("Failed to initialize WASM module",n),n}}createStateData(e,t={}){let r={};return e?.c?.inputType?.stateData&&(t.latestRoundData&&Object.keys(e.c.inputType.stateData).every((e=>e in t.latestRoundData))?(r.latestRoundData={},Object.entries(e.c.inputType.stateData).forEach((([e,n])=>{r.latestRoundData[e]=String(t.latestRoundData[e])}))):Object.entries(e.c.inputType.stateData).forEach((([e,n])=>{const o=t[e];o&&"object"==typeof o&&"values"in o&&o.values.length>0?r[e]=String(o.values[0]):r[e]=this.getDefaultValueForType(n)}))),r}getDefaultValueForType(e){return e.startsWith("uint")||e.startsWith("int")||"number"===e?"0":"bool"===e?"false":""}executeWasm(e,t){if(!this.wasm)throw this.logger.error("WASM not initialized"),new Error("WASM not initialized");try{this.logger.debug("Executing WASM with stateData",e);return this.createWasmFunction(this.wasmInstance.process_state)(JSON.stringify(e),JSON.stringify(t))}catch(r){throw this.logger.error("Error executing WASM",r),r}}getParams(){return this.createWasmFunction(this.wasmInstance.get_params)()}}
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).StandardsSDK={})}(this,(function(exports){"use strict";var __defProp2=Object.defineProperty,__typeError=e=>{throw TypeError(e)},__defNormalProp2=(e,t,r)=>t in e?__defProp2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__publicField2=(e,t,r)=>__defNormalProp2(e,"symbol"!=typeof t?t+"":t,r),__accessCheck=(e,t,r)=>t.has(e)||__typeError("Cannot "+r),__privateGet=(e,t,r)=>(__accessCheck(e,t,"read from private field"),r?r.call(e):t.get(e)),__privateAdd=(e,t,r)=>t.has(e)?__typeError("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),__privateSet=(e,t,r,n)=>(__accessCheck(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),__privateMethod=(e,t,r)=>(__accessCheck(e,t,"access private method"),r),__privateWrapper=(e,t,r,n)=>({set _(n){__privateSet(e,t,n,r)},get _(){return __privateGet(e,t,n)}}),_a2,_names,_data,_dataLength,_Writer_instances,writeData_fn,_data2,_offset,_bytesRead,_parent,_maxInflation,_Reader_instances,incrementBytesRead_fn,peekBytes_fn,_options,_offset2,_tokens,_TokenString_instances,subTokenString_fn,_ParamType_instances,walkAsync_fn,_AbiCoder_instances,getCoder_fn,_errors,_events,_functions,_abiCoder,_Interface_instances,getFunction_fn,getEvent_fn;function _mergeNamespaces(e,t){for(var r=0;r<t.length;r++){const n=t[r];if("string"!=typeof n&&!Array.isArray(n))for(const t in n)if("default"!==t&&!(t in e)){const r=Object.getOwnPropertyDescriptor(n,t);r&&Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs$2(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var browser$e={exports:{}},quickFormatUnescaped,hasRequiredQuickFormatUnescaped,hasRequiredBrowser$d;function requireQuickFormatUnescaped(){if(hasRequiredQuickFormatUnescaped)return quickFormatUnescaped;function e(e){try{return JSON.stringify(e)}catch(t){return'"[Circular]"'}}return hasRequiredQuickFormatUnescaped=1,quickFormatUnescaped=function(t,r,n){var o=n&&n.stringify||e;if("object"==typeof t&&null!==t){var i=r.length+1;if(1===i)return t;var a=new Array(i);a[0]=o(t);for(var s=1;s<i;s++)a[s]=o(r[s]);return a.join(" ")}if("string"!=typeof t)return t;var c=r.length;if(0===c)return t;for(var u="",l=0,d=-1,p=t&&t.length||0,h=0;h<p;){if(37===t.charCodeAt(h)&&h+1<p){switch(d=d>-1?d:0,t.charCodeAt(h+1)){case 100:case 102:if(l>=c)break;if(null==r[l])break;d<h&&(u+=t.slice(d,h)),u+=Number(r[l]),d=h+2,h++;break;case 105:if(l>=c)break;if(null==r[l])break;d<h&&(u+=t.slice(d,h)),u+=Math.floor(Number(r[l])),d=h+2,h++;break;case 79:case 111:case 106:if(l>=c)break;if(void 0===r[l])break;d<h&&(u+=t.slice(d,h));var f=typeof r[l];if("string"===f){u+="'"+r[l]+"'",d=h+2,h++;break}if("function"===f){u+=r[l].name||"<anonymous>",d=h+2,h++;break}u+=o(r[l]),d=h+2,h++;break;case 115:if(l>=c)break;d<h&&(u+=t.slice(d,h)),u+=String(r[l]),d=h+2,h++;break;case 37:d<h&&(u+=t.slice(d,h)),u+="%",d=h+2,h++,l--}++l}++h}if(-1===d)return t;d<p&&(u+=t.slice(d));return u}}function requireBrowser$d(){if(hasRequiredBrowser$d)return browser$e.exports;hasRequiredBrowser$d=1;const e=requireQuickFormatUnescaped();browser$e.exports=c;const t=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},r={mapHttpRequest:f,mapHttpResponse:f,wrapRequestSerializer:m,wrapResponseSerializer:m,wrapErrorSerializer:m,req:f,res:f,err:p,errWithCause:p};function n(e,t){return"silent"===e?1/0:t.levels.values[e]}const o=Symbol("pino.logFuncs"),i=Symbol("pino.hierarchy"),a={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function s(e,t){const r={logger:t,parent:e[i]};t[i]=r}function c(e){(e=e||{}).browser=e.browser||{};const r=e.browser.transmit;if(r&&"function"!=typeof r.send)throw Error("pino: transmit option must have a send function");const i=e.browser.write||t;e.browser.write&&(e.browser.asObject=!0);const p=e.serializers||{},f=function(e,t){if(Array.isArray(e))return e.filter((function(e){return"!stdSerializers.err"!==e}));return!0===e&&Object.keys(t)}(e.browser.serialize,p);let m=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(m=!1);const g=Object.keys(e.customLevels||{}),b=["error","fatal","warn","info","debug","trace"].concat(g);"function"==typeof i&&b.forEach((function(e){i[e]=i})),(!1===e.enabled||e.browser.disabled)&&(e.level="silent");const v=e.level||"info",w=Object.create(i);w.log||(w.log=y),function(e,r,n){const i={};r.forEach((e=>{i[e]=n[e]?n[e]:t[e]||t[a[e]||"log"]||y})),e[o]=i}(w,b,i),s({},w),Object.defineProperty(w,"levelVal",{get:function(){return n(this.level,this)}}),Object.defineProperty(w,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,u(this,k,w,"error"),u(this,k,w,"fatal"),u(this,k,w,"warn"),u(this,k,w,"info"),u(this,k,w,"debug"),u(this,k,w,"trace"),g.forEach((e=>{u(this,k,w,e)}))}});const k={transmit:r,serialize:f,asObject:e.browser.asObject,formatters:e.browser.formatters,levels:b,timestamp:h(e),messageKey:e.messageKey||"msg",onChild:e.onChild||y};function _(t,n,o){if(!n)throw new Error("missing bindings for child Pino");o=o||{},f&&n.serializers&&(o.serializers=n.serializers);const i=o.serializers;if(f&&i){var a=Object.assign({},p,i),c=!0===e.browser.serialize?Object.keys(a):f;delete n.serializers,l([n],c,a,this._stdErrSerialize)}function u(e){this._childLevel=1+(0|e._childLevel),this.bindings=n,a&&(this.serializers=a,this._serialize=c),r&&(this._logEvent=d([].concat(e._logEvent.bindings,n)))}u.prototype=this;const h=new u(this);return s(this,h),h.child=function(...e){return _.call(this,t,...e)},h.level=o.level||this.level,t.onChild(h),h}return w.levels=function(e){const t=e.customLevels||{},r=Object.assign({},c.levels.values,t),n=Object.assign({},c.levels.labels,function(e){const t={};return Object.keys(e).forEach((function(r){t[e[r]]=r})),t}(t));return{values:r,labels:n}}(e),w.level=v,w.setMaxListeners=w.getMaxListeners=w.emit=w.addListener=w.on=w.prependListener=w.once=w.prependOnceListener=w.removeListener=w.removeAllListeners=w.listeners=w.listenerCount=w.eventNames=w.write=w.flush=y,w.serializers=p,w._serialize=f,w._stdErrSerialize=m,w.child=function(...e){return _.call(this,k,...e)},r&&(w._logEvent=d()),w}function u(r,a,s,c){if(Object.defineProperty(r,c,{value:n(r.level,s)>n(c,s)?y:s[o][c],writable:!0,enumerable:!0,configurable:!0}),r[c]===y){if(!a.transmit)return;const e=n(a.transmit.level||r.level,s);if(n(c,s)<e)return}r[c]=function(r,i,a,s){return function(o){return function(){const c=i.timestamp(),u=new Array(arguments.length),p=Object.getPrototypeOf&&Object.getPrototypeOf(this)===t?t:this;for(var h=0;h<u.length;h++)u[h]=arguments[h];var f=!1;if(i.serialize&&(l(u,this._serialize,this.serializers,this._stdErrSerialize),f=!0),i.asObject||i.formatters?o.call(p,function(t,r,n,o,i){const{level:a,log:s=e=>e}=i.formatters||{},c=n.slice();let u=c[0];const l={};o&&(l.time=o);if(a){const e=a(r,t.levels.values[r]);Object.assign(l,e)}else l.level=t.levels.values[r];let d=1+(0|t._childLevel);d<1&&(d=1);if(null!==u&&"object"==typeof u){for(;d--&&"object"==typeof c[0];)Object.assign(l,c.shift());u=c.length?e(c.shift(),c):void 0}else"string"==typeof u&&(u=e(c.shift(),c));void 0!==u&&(l[i.messageKey]=u);return s(l)}(this,s,u,c,i)):o.apply(p,u),i.transmit){const e=n(i.transmit.level||r._level,a),t=n(s,a);if(t<e)return;!function(e,t,r,n=!1){const o=t.send,i=t.ts,a=t.methodLevel,s=t.methodValue,c=t.val,u=e._logEvent.bindings;n||l(r,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize);e._logEvent.ts=i,e._logEvent.messages=r.filter((function(e){return-1===u.indexOf(e)})),e._logEvent.level.label=a,e._logEvent.level.value=s,o(a,e._logEvent,c),e._logEvent=d(u)}(this,{ts:c,methodLevel:s,methodValue:t,transmitValue:a.levels.values[i.transmit.level||r._level],send:i.transmit.send,val:n(r._level,a)},u,f)}}}(r[o][s])}(r,a,s,c);const u=function(e){const t=[];e.bindings&&t.push(e.bindings);let r=e[i];for(;r.parent;)r=r.parent,r.logger.bindings&&t.push(r.logger.bindings);return t.reverse()}(r);0!==u.length&&(r[c]=function(e,t){return function(){return t.apply(this,[...e,...arguments])}}(u,r[c]))}function l(e,t,r,n){for(const o in e)if(n&&e[o]instanceof Error)e[o]=c.stdSerializers.err(e[o]);else if("object"==typeof e[o]&&!Array.isArray(e[o])&&t)for(const n in e[o])t.indexOf(n)>-1&&n in r&&(e[o][n]=r[n](e[o][n]))}function d(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function p(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const r in e)void 0===t[r]&&(t[r]=e[r]);return t}function h(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?g:b}function f(){return{}}function m(e){return e}function y(){}function g(){return!1}function b(){return Date.now()}return c.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},c.stdSerializers=r,c.stdTimeFunctions=Object.assign({},{nullTime:g,epochTime:b,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}}),browser$e.exports.default=c,browser$e.exports.pino=c,browser$e.exports}var browserExports$2=requireBrowser$d();const e$c=getDefaultExportFromCjs$2(browserExports$2);let Logger$2=(_a2=class{constructor(e={}){const t=e.level||"info";this.moduleContext=e.module||"app";const r={level:t,enabled:!e.silent,transport:!1!==e.prettyPrint?{target:"pino-pretty",options:{colorize:!0,translateTime:"SYS:standard",ignore:"pid,hostname"}}:void 0};this.logger=e$c(r)}static getInstance(e={}){const t=e.module||"default";return _a2.instances.has(t)||_a2.instances.set(t,new _a2(e)),_a2.instances.get(t)}setLogLevel(e){this.logger.level=e}setSilent(e){e&&(this.logger.level="silent")}setModule(e){this.moduleContext=e}debug(...e){this.logger.debug({module:this.moduleContext},...e)}info(...e){this.logger.info({module:this.moduleContext},...e)}warn(...e){this.logger.warn({module:this.moduleContext},...e)}error(...e){this.logger.error({module:this.moduleContext},...e)}},_a2.instances=new Map,_a2);const sleep$1=e=>new Promise((t=>setTimeout(t,e)));class HCS{constructor(){this.modelViewerLoaded=!1,this.modelViewerLoading=null,this.config={cdnUrl:"https://kiloscribe.com/api/inscription-cdn/",network:"mainnet",retryAttempts:3,retryBackoff:300,debug:!1,showLoadingIndicator:!1,loadingCallbackName:null},this.configMapping={hcsCdnUrl:"cdnUrl",hcsNetwork:"network",hcsRetryAttempts:"retryAttempts",hcsRetryBackoff:"retryBackoff",hcsDebug:"debug",hcsShowLoadingIndicator:"showLoadingIndicator",hcsLoadingCallbackName:"loadingCallbackName"},this.LoadedScripts={},this.LoadedWasm={},this.LoadedImages={},this.LoadedVideos={},this.LoadedAudios={},this.LoadedAudioUrls={},this.LoadedGLBs={},this.scriptLoadedEvent=new Event("HCSScriptLoaded"),this.loadQueue=[],this.isProcessingQueue=!1;try{this.logger=Logger$2.getInstance({module:"HCS-3",level:this.config.debug?"debug":"error"})}catch(e){this.logger=this.createFallbackLogger()}}createFallbackLogger(){return{debug:(...e)=>this.config.debug&&console.debug("[HCS-3]",...e),info:(...e)=>this.config.debug&&console.info("[HCS-3]",...e),warn:(...e)=>console.warn("[HCS-3]",...e),error:(...e)=>console.error("[HCS-3]",...e),setLogLevel:e=>{this.config.debug="debug"===e}}}log(...e){if(0===e.length)this.logger.debug("");else if(1===e.length)this.logger.debug(String(e[0]));else{const t=String(e[0]),r=e.slice(1);this.logger.debug(t,r)}}error(...e){if(0===e.length)this.logger.error("");else if(1===e.length)this.logger.error(String(e[0]));else{const t=String(e[0]),r=e.slice(1);this.logger.error(t,r)}}loadConfigFromHTML(){const e=document.querySelector("script[data-hcs-config]");e&&(Object.keys(this.configMapping).forEach((t=>{if(e.dataset[t]){const r=this.configMapping[t];let n=e.dataset[t];"true"===n&&(n=!0),"false"===n&&(n=!1),isNaN(Number(n))||""===n||(n=Number(n)),this.config[r]=n}})),this.logger.setLogLevel(this.config.debug?"debug":"error")),this.log("Loaded config:",this.config)}updateLoadingStatus(e,t){if("loaded"!==this.LoadedScripts[e]&&(this.config.showLoadingIndicator&&console.log("[HCS Loading] "+e+" : "+t),this.LoadedScripts[e]=t,this.config.loadingCallbackName&&"function"==typeof window[this.config.loadingCallbackName])){const r=window[this.config.loadingCallbackName];"function"==typeof r&&r(e,t)}}async fetchWithRetry(e,t=this.config.retryAttempts,r=this.config.retryBackoff){try{const t=await fetch(e);if(!t.ok)throw new Error("HTTP error! status: "+t.status);return t}catch(n){if(t>0)return this.log("Retrying fetch for "+e+" Attempts left: "+(t-1)),await this.sleep(r),this.fetchWithRetry(e,t-1,2*r);throw n}}sleep(e){return new Promise((t=>setTimeout(t,e)))}isDuplicate(e){return!!this.LoadedScripts[e]}async retrieveHCS1Data(e,t=this.config.cdnUrl,r=this.config.network){const n=r.replace(/['"]+/g,""),o=await this.fetchWithRetry(t+e+"?network="+n);return await o.blob()}async loadScript(e){const t=e.getAttribute("data-src"),r=e.getAttribute("data-script-id"),n=t?.split("/").pop(),o=e.getAttribute("type"),i=e.hasAttribute("data-required"),a="module"===e.getAttribute("type");if(!this.isDuplicate(n||"")){this.updateLoadingStatus(r,"loading");try{const t=e.getAttribute("data-cdn-url")||this.config.cdnUrl,s=e.getAttribute("data-network")||this.config.network,c=await this.retrieveHCS1Data(n,t,s);if("wasm"===o){const t=await c.arrayBuffer(),n=await WebAssembly.compile(t);this.LoadedWasm[r]=await WebAssembly.instantiate(n,{env:{},...e.dataset}),this.updateLoadingStatus(r,"loaded"),window.dispatchEvent(this.scriptLoadedEvent),this.log("Loaded wasm: "+r)}else{const e=await c.text(),t=document.createElement("script");if(t.textContent=e,t.className="hcs-inline-script",r&&t.setAttribute("data-loaded-script-id",r),a){t.type="module";const r=new Blob([e],{type:"application/javascript"});t.src=URL.createObjectURL(r)}document.body.appendChild(t),this.updateLoadingStatus(r,"loaded"),window.dispatchEvent(this.scriptLoadedEvent),this.log("Loaded script: "+r),t.onerror=e=>{if(this.error("Failed to load "+o+": "+r,e),this.updateLoadingStatus(r,"failed"),i)throw e}}}catch(s){if(this.error("Failed to load "+o+": "+r,s),this.updateLoadingStatus(r,"failed"),i)throw s}}}async loadModuleExports(e){const t=document.querySelector('script[data-loaded-script-id="'+e+'"]');if(!t)throw new Error("Module script with id "+e+" not found");const r=t.getAttribute("src");if(!r)throw new Error("Module script "+e+" has no src attribute");try{return await import(r)}catch(n){throw this.error("Failed to import module",n),n}}async loadStylesheet(e){const t=e.getAttribute("data-src"),r=e.getAttribute("data-script-id"),n=t?.split("/").pop(),o=e.hasAttribute("data-required");if(!this.isDuplicate(n||"")){this.updateLoadingStatus(r,"loading");try{const t=e.getAttribute("data-cdn-url")||this.config.cdnUrl,o=e.getAttribute("data-network")||this.config.network,i=await this.retrieveHCS1Data(n,t,o),a=await i.text(),s=document.createElement("style");s.textContent=a,document.head.appendChild(s),this.updateLoadingStatus(r,"loaded"),window.dispatchEvent(this.scriptLoadedEvent),this.log("Loaded and inlined stylesheet: "+r)}catch(i){if(this.error("Failed to load stylesheet: "+r,i),this.updateLoadingStatus(r,"failed"),o)throw i}}}async loadImage(e){const t=e.getAttribute("data-src"),r=t?.split("/").pop();this.log("Loading image: "+r),this.updateLoadingStatus("Image: "+r,"loaded");try{const t=e.getAttribute("data-cdn-url")||this.config.cdnUrl,n=e.getAttribute("data-network")||this.config.network,o=await this.retrieveHCS1Data(r,t,n),i=URL.createObjectURL(o);e.src=i,this.LoadedImages[r]=i,this.updateLoadingStatus("Image: "+r,"loaded"),this.log("Loaded image: "+r)}catch(n){this.error("Failed to load image: "+r,n),this.updateLoadingStatus("Image: "+r,"failed")}}async loadMedia(e,t){const r=e.getAttribute("data-src"),n=r?.split("/").pop();this.log("Loading "+t+": "+n),this.updateLoadingStatus(t+": "+n,"loading");try{const r=e.getAttribute("data-cdn-url")||this.config.cdnUrl,o=e.getAttribute("data-network")||this.config.network,i=await this.retrieveHCS1Data(n,r,o),a=URL.createObjectURL(i);e.src=a,"video"===t?this.LoadedVideos[n]=a:this.LoadedAudioUrls[n]=a,this.updateLoadingStatus(t+": "+n,"loaded"),this.log("Loaded "+t+": "+n)}catch(o){this.error("Failed to load "+t+": "+n,o),this.updateLoadingStatus(t+": "+n,"failed")}}async loadModelViewer(){return this.modelViewerLoading?this.modelViewerLoading:this.modelViewerLoaded?Promise.resolve():(this.modelViewerLoading=new Promise((e=>{const t=document.createElement("script");t.setAttribute("data-src","hcs://1/0.0.7293044"),t.setAttribute("data-script-id","model-viewer"),t.setAttribute("type","module"),window.addEventListener("HCSScriptLoaded",(()=>{this.modelViewerLoaded=!0,e()}),{once:!0}),this.loadScript(t)})),this.modelViewerLoading)}async loadGLB(e){await this.loadModelViewer();const t=e.getAttribute("data-src"),r=t?.split("/").pop();this.log("Loading GLB: "+r),this.updateLoadingStatus("GLB: "+r,"loading");try{const t=e.getAttribute("data-cdn-url")||this.config.cdnUrl,n=e.getAttribute("data-network")||this.config.network;let o;"model-viewer"!==e.tagName.toLowerCase()?(o=document.createElement("model-viewer"),Array.from(e.attributes).forEach((e=>{o.setAttribute(e.name,e.value)})),o.setAttribute("camera-controls",""),o.setAttribute("auto-rotate",""),o.setAttribute("ar",""),e.parentNode?.replaceChild(o,e)):o=e;const i=await this.retrieveHCS1Data(r,t,n),a=URL.createObjectURL(i);o.setAttribute("src",a),this.LoadedGLBs[r]=a,this.updateLoadingStatus("GLB: "+r,"loaded"),this.log("Loaded GLB: "+r)}catch(n){this.error("Failed to load GLB: "+r,n),this.updateLoadingStatus("GLB: "+r,"failed")}}async loadResource(e,t,r){return new Promise((n=>{this.loadQueue.push({element:e,type:t,order:r,resolve:n}),this.processQueue()}))}async processQueue(){if(!this.isProcessingQueue){for(this.isProcessingQueue=!0;this.loadQueue.length>0;){const t=this.loadQueue.shift();try{"script"===t.type?await this.loadScript(t.element):"image"===t.type?await this.loadImage(t.element):"video"===t.type||"audio"===t.type?await this.loadMedia(t.element,t.type):"glb"===t.type?await this.loadGLB(t.element):"css"===t.type&&await this.loadStylesheet(t.element),t.resolve()}catch(e){if(this.error("Error processing queue item:",e),"script"===t.type&&t.element.hasAttribute("data-required"))break}}this.isProcessingQueue=!1}}async replaceHCSInStyle(e){let t=e,r=t.indexOf("hcs://");for(;-1!==r;){let e=r;for(;e<t.length&&!["'",'"'," ",")"].includes(t[e]);)e++;const o=t.substring(r,e),i=o.split("/").pop();try{const n=this.config.cdnUrl,a=this.config.network,s=await this.retrieveHCS1Data(i,n,a),c=URL.createObjectURL(s);t=t.substring(0,r)+c+t.substring(e),this.LoadedImages[i]=c,this.log("Replaced CSS HCS URL: "+o+" with "+c)}catch(n){this.error("Failed to load CSS image: "+i,n)}r=t.indexOf("hcs://",r+1)}return t}async processInlineStyles(){const e=document.querySelectorAll('[style*="hcs://"]');this.log("Found "+e.length+" elements with HCS style references");for(const r of Array.from(e)){const e=r.getAttribute("style");if(e){this.log("Processing style: "+e);const t=await this.replaceHCSInStyle(e);e!==t&&(r.setAttribute("style",t),this.log("Updated style to: "+t))}}const t=document.querySelectorAll("style");for(const r of Array.from(t))if(r.textContent?.includes("hcs://")){const e=await this.replaceHCSInStyle(r.textContent);r.textContent!==e&&(r.textContent=e)}}async init(){return this.loadConfigFromHTML(),new Promise((e=>{const t=async()=>{const t=document.querySelectorAll('script[data-src^="hcs://"]'),r=document.querySelectorAll('img[data-src^="hcs://"], img[src^="hcs://"]'),n=document.querySelectorAll('video[data-src^="hcs://"], video[src^="hcs://"]'),o=document.querySelectorAll('audio[data-src^="hcs://"], audio[src^="hcs://"]'),i=document.querySelectorAll('model-viewer[data-src^="hcs://"]'),a=document.querySelectorAll('link[data-src^="hcs://"]');document.querySelectorAll('[src^="hcs://"]').forEach((e=>{const t=e.getAttribute("src");t&&(e.setAttribute("data-src",t),e.removeAttribute("src"))})),await this.processInlineStyles();const s=[];[{elements:t,type:"script"},{elements:r,type:"image"},{elements:n,type:"video"},{elements:o,type:"audio"},{elements:i,type:"glb"},{elements:a,type:"css"}].forEach((({elements:e,type:t})=>{e.forEach((e=>{const r=parseInt(e.getAttribute("data-load-order")||"")||1/0;s.push(this.loadResource(e,t,r))}))})),await Promise.all(s);const c=new MutationObserver((e=>{e.forEach((e=>{if(e.addedNodes.forEach((e=>{if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.getAttribute("style")?.includes("hcs://")&&this.processInlineStyles(),"style"===t.tagName.toLowerCase()&&t.textContent?.includes("hcs://")&&this.processInlineStyles(),t.getAttribute("src")?.startsWith("hcs://")){const e=t.getAttribute("src");t.setAttribute("data-src",e),t.removeAttribute("src");switch(t.tagName.toLowerCase()){case"img":this.loadResource(t,"image",1/0);break;case"video":this.loadResource(t,"video",1/0);break;case"audio":this.loadResource(t,"audio",1/0);break;case"script":this.loadResource(t,"script",1/0)}}t.matches('script[data-src^="hcs://"]')?this.loadResource(t,"script",1/0):t.matches('img[data-src^="hcs://"]')?this.loadResource(t,"image",1/0):t.matches('video[data-src^="hcs://"]')?this.loadResource(t,"video",1/0):t.matches('audio[data-src^="hcs://"]')?this.loadResource(t,"audio",1/0):t.matches('model-viewer[data-src^="hcs://"]')?this.loadResource(t,"glb",1/0):t.matches('link[data-src^="hcs://"]')&&this.loadResource(t,"css",1/0);t.querySelectorAll('[data-src^="hcs://"], [src^="hcs://"]').forEach((e=>{const t=e,r=t.tagName.toLowerCase(),n=t.getAttribute("src");switch(n?.startsWith("hcs://")&&(t.setAttribute("data-src",n),t.removeAttribute("src")),r){case"script":this.loadResource(t,"script",1/0);break;case"img":this.loadResource(t,"image",1/0);break;case"video":this.loadResource(t,"video",1/0);break;case"audio":this.loadResource(t,"audio",1/0);break;case"model-viewer":this.loadResource(t,"glb",1/0);break;case"link":this.loadResource(t,"css",1/0)}}))}})),"attributes"===e.type){const t=e.target;if("style"===e.attributeName&&t.getAttribute("style")?.includes("hcs://"))this.processInlineStyles();else if("src"===e.attributeName){const e=t.getAttribute("src");if(e?.startsWith("hcs://")){t.setAttribute("data-src",e),t.removeAttribute("src");const r=t.tagName.toLowerCase();["img","video","audio"].includes(r)&&this.loadResource(t,r,1/0)}}}}))}));document.body?c.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","src","data-src"]}):document.addEventListener("DOMContentLoaded",(()=>{c.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","src","data-src"]})})),e()};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()}))}async preloadImage(e){this.log("Loading image:"+e),this.updateLoadingStatus("image: "+e,"loading");const t=await this.retrieveHCS1Data(e),r=URL.createObjectURL(t);return this.LoadedImages[e]=r,this.updateLoadingStatus("image: "+e,"loaded"),r}async preloadAudio(e){const t=document.createElement("audio");t.setAttribute("data-topic-id",e),t.setAttribute("data-src","hcs://1/"+e),document.body.appendChild(t),await this.loadMedia(t,"audio");const r=document.querySelector('audio[data-topic-id="'+e+'"]');return r?this.LoadedAudioUrls[e]=r.src:console.error("Failed to preload audio: "+e),this.LoadedAudioUrls[e]}async playAudio(e,t=1){const r=this.LoadedAudioUrls[e];if(r){const n=new Audio(r);n.volume=t,this.LoadedAudios[e]=n,n.play().catch((e=>{console.error("Failed to play audio:",e)})),n.addEventListener("ended",(()=>{n.remove(),delete this.LoadedAudios[e]}))}else console.error("Audio not preloaded: "+e)}async pauseAudio(e){const t=document.querySelector('audio[data-topic-id="'+e+'"]');t?(console.log("found element",t),t.pause(),this.LoadedAudios[e]?.pause()):this.LoadedAudios[e]?.pause()}async loadAndPlayAudio(e,t=!1,r=1){let n=document.querySelector('audio[data-topic-id="'+e+'"]');if(n)n.volume=r,await n.play();else{const o=document.createElement("audio");o.volume=r,t&&o.setAttribute("autoplay","autoplay"),o.setAttribute("data-topic-id",e),o.setAttribute("data-src","hcs://1/"+e),document.body.appendChild(o),await this.loadMedia(o,"audio"),n=document.querySelector('audio[data-topic-id="'+e+'"]'),t||await n.play()}}}const isServer="undefined"==typeof window;isServer||(window.HCS=new HCS,window.HCS.init().then((()=>{console.log("All HCS resources loaded"),"function"==typeof window.HCSReady&&(console.log("Running HCSReady..."),window.HCSReady())})));class WasmBridge{constructor(){this.wasm=null,this.WASM_VECTOR_LEN=0,this.cachedUint8Memory=null,this.cachedDataViewMemory=null,this.textEncoder=new TextEncoder,this.textDecoder=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),this.textDecoder.decode(),this.logger=Logger$2.getInstance({module:"WasmBridge"})}setLogLevel(e){this.logger.setLogLevel(e)}get wasmInstance(){if(!this.wasm)throw new Error("WASM not initialized");return this.wasm}getUint8Memory(){if(!this.wasm)throw new Error("WASM not initialized");return null!==this.cachedUint8Memory&&0!==this.cachedUint8Memory.byteLength||(this.cachedUint8Memory=new Uint8Array(this.wasm.memory.buffer)),this.cachedUint8Memory}getDataViewMemory(){if(!this.wasm)throw new Error("WASM not initialized");return null!==this.cachedDataViewMemory&&this.cachedDataViewMemory.buffer===this.wasm.memory.buffer||(this.cachedDataViewMemory=new DataView(this.wasm.memory.buffer)),this.cachedDataViewMemory}encodeString(e,t){if(0===e.length)return{read:0,written:0};const r=this.textEncoder.encode(e);return t.set(r),{read:e.length,written:r.length}}passStringToWasm(e,t,r){if(void 0===r){const r=this.textEncoder.encode(e),n=t(r.length,1);return this.getUint8Memory().set(r,n),this.WASM_VECTOR_LEN=r.length,n}let n=this.textEncoder.encode(e).length,o=t(n,1);const i=this.getUint8Memory();let a=0;for(;a<n;a++){const t=e.charCodeAt(a);if(t>127)break;i[o+a]=t}if(a!==n){0!==a&&(e=e.slice(a)),o=r(o,n,n=a+3*this.textEncoder.encode(e).length,1);const t=this.getUint8Memory().subarray(o+a,o+n);a+=this.encodeString(e,t).written}return this.WASM_VECTOR_LEN=a,o}getStringFromWasm(e,t){return e>>>=0,this.textDecoder.decode(this.getUint8Memory().subarray(e,e+t))}createWasmFunction(e){if(!this.wasm)throw new Error("WASM not initialized");return(...t)=>{const r=this.wasm.__wbindgen_add_to_stack_pointer(-16);let n=[0,0];try{const o=[r,...t.map((e=>[this.passStringToWasm(e,this.wasm.__wbindgen_malloc,this.wasm.__wbindgen_realloc),this.WASM_VECTOR_LEN])).flat()];e.apply(this.wasm,o);const i=this.getDataViewMemory().getInt32(r+0,!0),a=this.getDataViewMemory().getInt32(r+4,!0);return n=[i,a],this.getStringFromWasm(i,a)}finally{this.wasm.__wbindgen_add_to_stack_pointer(16),this.wasm.__wbindgen_free(n[0],n[1],1)}}}async initWasm(e){const t=this,r={__wbindgen_placeholder__:{__wbindgen_throw:function(e,r){const n=t.getStringFromWasm(e,r);throw t.logger.error(`WASM error: ${n}`),new Error(n)}}};try{this.logger.debug("Compiling WASM module");const t=await WebAssembly.compile(e);this.logger.debug("Instantiating WASM module");const n=await WebAssembly.instantiate(t,r);return this.wasm=n.exports,this.logger.info("WASM module initialized successfully"),this.wasm}catch(n){throw this.logger.error("Failed to initialize WASM module",n),n}}createStateData(e,t={}){let r={};return e?.c?.inputType?.stateData&&(t.latestRoundData&&Object.keys(e.c.inputType.stateData).every((e=>e in t.latestRoundData))?(r.latestRoundData={},Object.entries(e.c.inputType.stateData).forEach((([e,n])=>{r.latestRoundData[e]=String(t.latestRoundData[e])}))):Object.entries(e.c.inputType.stateData).forEach((([e,n])=>{const o=t[e];o&&"object"==typeof o&&"values"in o&&o.values.length>0?r[e]=String(o.values[0]):r[e]=this.getDefaultValueForType(n)}))),r}getDefaultValueForType(e){return e.startsWith("uint")||e.startsWith("int")||"number"===e?"0":"bool"===e?"false":""}executeWasm(e,t){if(!this.wasm)throw this.logger.error("WASM not initialized"),new Error("WASM not initialized");try{this.logger.debug("Executing WASM with stateData",e);return this.createWasmFunction(this.wasmInstance.process_state)(JSON.stringify(e),JSON.stringify(t))}catch(r){throw this.logger.error("Error executing WASM",r),r}}getParams(){return this.createWasmFunction(this.wasmInstance.get_params)()}}
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2009 The Closure Library Authors