8 lines
10 KiB
JavaScript
8 lines
10 KiB
JavaScript
import{c as Q,o as I,q as O}from"./chunk-QTLWQ5AJ.js";var Y=Q(o=>{"use strict";I();O();Object.defineProperty(o,"__esModule",{value:!0});o.bytes=o.stringToBytes=o.str=o.bytesToString=o.hex=o.utf8=o.bech32m=o.bech32=o.base58check=o.createBase58check=o.base58xmr=o.base58xrp=o.base58flickr=o.base58=o.base64urlnopad=o.base64url=o.base64nopad=o.base64=o.base32crockford=o.base32hexnopad=o.base32hex=o.base32nopad=o.base32=o.base16=o.utils=void 0;o.assertNumber=g;function g(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}function v(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function d(...e){let r=t=>t,n=(t,i)=>l=>t(i(l)),s=e.map(t=>t.encode).reduceRight(n,r),c=e.map(t=>t.decode).reduce(n,r);return{encode:s,decode:c}}function f(e){return{encode:r=>{if(!Array.isArray(r)||r.length&&typeof r[0]!="number")throw new Error("alphabet.encode input should be an array of numbers");return r.map(n=>{if(g(n),n<0||n>=e.length)throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);return e[n]})},decode:r=>{if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("alphabet.decode input should be array of strings");return r.map(n=>{if(typeof n!="string")throw new Error(`alphabet.decode: not string element=${n}`);let s=e.indexOf(n);if(s===-1)throw new Error(`Unknown letter: "${n}". Allowed: ${e}`);return s})}}}function u(e=""){if(typeof e!="string")throw new Error("join separator should be string");return{encode:r=>{if(!Array.isArray(r)||r.length&&typeof r[0]!="string")throw new Error("join.encode input should be array of strings");for(let n of r)if(typeof n!="string")throw new Error(`join.encode: non-string input=${n}`);return r.join(e)},decode:r=>{if(typeof r!="string")throw new Error("join.decode input should be string");return r.split(e)}}}function $(e,r="="){if(g(e),typeof r!="string")throw new Error("padding chr should be string");return{encode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let s of n)if(typeof s!="string")throw new Error(`padding.encode: non-string input=${s}`);for(;n.length*e%8;)n.push(r);return n},decode(n){if(!Array.isArray(n)||n.length&&typeof n[0]!="string")throw new Error("padding.encode input should be array of strings");for(let c of n)if(typeof c!="string")throw new Error(`padding.decode: non-string input=${c}`);let s=n.length;if(s*e%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;s>0&&n[s-1]===r;s--)if(!((s-1)*e%8))throw new Error("Invalid padding: string has too much padding");return n.slice(0,s)}}}function M(e){if(typeof e!="function")throw new Error("normalize fn should be function");return{encode:r=>r,decode:r=>e(r)}}function C(e,r,n){if(r<2)throw new Error(`convertRadix: wrong from=${r}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(e))throw new Error("convertRadix: data should be array");if(!e.length)return[];let s=0,c=[],t=Array.from(e);for(t.forEach(i=>{if(g(i),i<0||i>=r)throw new Error(`Wrong integer: ${i}`)});;){let i=0,l=!0;for(let b=s;b<t.length;b++){let T=t[b],p=r*i+T;if(!Number.isSafeInteger(p)||r*i/r!==i||p-T!==r*i)throw new Error("convertRadix: carry overflow");i=p%n;let a=Math.floor(p/n);if(t[b]=a,!Number.isSafeInteger(a)||a*n+i!==p)throw new Error("convertRadix: carry overflow");if(l)a?l=!1:s=b;else continue}if(c.push(i),l)break}for(let i=0;i<e.length-1&&e[i]===0;i++)c.push(0);return c.reverse()}var F=(e,r)=>r?F(r,e%r):e,k=(e,r)=>e+(r-F(e,r));function B(e,r,n,s){if(!Array.isArray(e))throw new Error("convertRadix2: data should be array");if(r<=0||r>32)throw new Error(`convertRadix2: wrong from=${r}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(k(r,n)>32)throw new Error(`convertRadix2: carry overflow from=${r} to=${n} carryBits=${k(r,n)}`);let c=0,t=0,i=2**n-1,l=[];for(let b of e){if(g(b),b>=2**r)throw new Error(`convertRadix2: invalid data word=${b} from=${r}`);if(c=c<<r|b,t+r>32)throw new Error(`convertRadix2: carry overflow pos=${t} from=${r}`);for(t+=r;t>=n;t-=n)l.push((c>>t-n&i)>>>0);c&=2**t-1}if(c=c<<n-t&i,!s&&t>=r)throw new Error("Excess padding");if(!s&&c)throw new Error(`Non-zero padding: ${c}`);return s&&t>0&&l.push(c>>>0),l}function G(e){return g(e),{encode:r=>{if(!v(r))throw new Error("radix.encode input should be Uint8Array");return C(Array.from(r),2**8,e)},decode:r=>{if(!Array.isArray(r)||r.length&&typeof r[0]!="number")throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(C(r,e,2**8))}}}function w(e,r=!1){if(g(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(k(8,e)>32||k(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!v(n))throw new Error("radix2.encode input should be Uint8Array");return B(Array.from(n),8,e,!r)},decode:n=>{if(!Array.isArray(n)||n.length&&typeof n[0]!="number")throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(B(n,e,8,r))}}}function D(e){if(typeof e!="function")throw new Error("unsafeWrapper fn should be function");return function(...r){try{return e.apply(null,r)}catch{}}}function H(e,r){if(g(e),typeof r!="function")throw new Error("checksum fn should be function");return{encode(n){if(!v(n))throw new Error("checksum.encode: input should be Uint8Array");let s=r(n).slice(0,e),c=new Uint8Array(n.length+e);return c.set(n),c.set(s,n.length),c},decode(n){if(!v(n))throw new Error("checksum.decode: input should be Uint8Array");let s=n.slice(0,-e),c=r(s).slice(0,e),t=n.slice(-e);for(let i=0;i<e;i++)if(c[i]!==t[i])throw new Error("Invalid checksum");return s}}}o.utils={alphabet:f,chain:d,checksum:H,convertRadix:C,convertRadix2:B,radix:G,radix2:w,join:u,padding:$};o.base16=d(w(4),f("0123456789ABCDEF"),u(""));o.base32=d(w(5),f("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),$(5),u(""));o.base32nopad=d(w(5),f("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),u(""));o.base32hex=d(w(5),f("0123456789ABCDEFGHIJKLMNOPQRSTUV"),$(5),u(""));o.base32hexnopad=d(w(5),f("0123456789ABCDEFGHIJKLMNOPQRSTUV"),u(""));o.base32crockford=d(w(5),f("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),u(""),M(e=>e.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")));o.base64=d(w(6),f("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),$(6),u(""));o.base64nopad=d(w(6),f("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),u(""));o.base64url=d(w(6),f("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),$(6),u(""));o.base64urlnopad=d(w(6),f("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),u(""));var S=e=>d(G(58),f(e),u(""));o.base58=S("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");o.base58flickr=S("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");o.base58xrp=S("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");var W=[0,2,3,5,6,7,9,10,11];o.base58xmr={encode(e){let r="";for(let n=0;n<e.length;n+=8){let s=e.subarray(n,n+8);r+=o.base58.encode(s).padStart(W[s.length],"1")}return r},decode(e){let r=[];for(let n=0;n<e.length;n+=11){let s=e.slice(n,n+11),c=W.indexOf(s.length),t=o.base58.decode(s);for(let i=0;i<t.length-c;i++)if(t[i]!==0)throw new Error("base58xmr: wrong padding");r=r.concat(Array.from(t.slice(t.length-c)))}return Uint8Array.from(r)}};var V=e=>d(H(4,r=>e(e(r))),o.base58);o.createBase58check=V;o.base58check=o.createBase58check;var U=d(f("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),u("")),j=[996825010,642813549,513874426,1027748829,705979059];function m(e){let r=e>>25,n=(e&33554431)<<5;for(let s=0;s<j.length;s++)(r>>s&1)===1&&(n^=j[s]);return n}function P(e,r,n=1){let s=e.length,c=1;for(let t=0;t<s;t++){let i=e.charCodeAt(t);if(i<33||i>126)throw new Error(`Invalid prefix (${e})`);c=m(c)^i>>5}c=m(c);for(let t=0;t<s;t++)c=m(c)^e.charCodeAt(t)&31;for(let t of r)c=m(c)^t;for(let t=0;t<6;t++)c=m(c);return c^=n,U.encode(B([c%2**30],30,5,!1))}function K(e){let r=e==="bech32"?1:734539939,n=w(5),s=n.decode,c=n.encode,t=D(s);function i(a,h,y=90){if(typeof a!="string")throw new Error(`bech32.encode prefix should be string, not ${typeof a}`);if(h instanceof Uint8Array&&(h=Array.from(h)),!Array.isArray(h)||h.length&&typeof h[0]!="number")throw new Error(`bech32.encode words should be array of numbers, not ${typeof h}`);if(a.length===0)throw new TypeError(`Invalid prefix length ${a.length}`);let E=a.length+7+h.length;if(y!==!1&&E>y)throw new TypeError(`Length ${E} exceeds limit ${y}`);let x=a.toLowerCase(),A=P(x,h,r);return`${x}1${U.encode(h)}${A}`}function l(a,h=90){if(typeof a!="string")throw new Error(`bech32.decode input should be string, not ${typeof a}`);if(a.length<8||h!==!1&&a.length>h)throw new TypeError(`Wrong string length: ${a.length} (${a}). Expected (8..${h})`);let y=a.toLowerCase();if(a!==y&&a!==a.toUpperCase())throw new Error("String must be lowercase or uppercase");let E=y.lastIndexOf("1");if(E===0||E===-1)throw new Error('Letter "1" must be present between prefix and data only');let x=y.slice(0,E),A=y.slice(E+1);if(A.length<6)throw new Error("Data must be at least 6 characters long");let L=U.decode(A).slice(0,-6),N=P(x,L,r);if(!A.endsWith(N))throw new Error(`Invalid checksum in ${a}: expected "${N}"`);return{prefix:x,words:L}}let b=D(l);function T(a){let{prefix:h,words:y}=l(a,!1);return{prefix:h,words:y,bytes:s(y)}}function p(a,h){return i(a,c(h))}return{encode:i,decode:l,encodeFromBytes:p,decodeToBytes:T,decodeUnsafe:b,fromWords:s,fromWordsUnsafe:t,toWords:c}}o.bech32=K("bech32");o.bech32m=K("bech32m");o.utf8={encode:e=>new TextDecoder().decode(e),decode:e=>new TextEncoder().encode(e)};o.hex=d(w(4),f("0123456789abcdef"),u(""),M(e=>{if(typeof e!="string"||e.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);return e.toLowerCase()}));var R={utf8:o.utf8,hex:o.hex,base16:o.base16,base32:o.base32,base64:o.base64,base64url:o.base64url,base58:o.base58,base58xmr:o.base58xmr},J="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr",z=(e,r)=>{if(typeof e!="string"||!R.hasOwnProperty(e))throw new TypeError(J);if(!v(r))throw new TypeError("bytesToString() expects Uint8Array");return R[e].encode(r)};o.bytesToString=z;o.str=o.bytesToString;var X=(e,r)=>{if(!R.hasOwnProperty(e))throw new TypeError(J);if(typeof r!="string")throw new TypeError("stringToBytes() expects string");return R[e].decode(r)};o.stringToBytes=X;o.bytes=o.stringToBytes});export{Y as a};
|
|
|
|
window.inOKXExtension = true;
|
|
window.inMiniApp = false;
|
|
window.ASSETS_BUILD_TYPE = "publish";
|
|
|
|
//# sourceMappingURL=chunk-CF3IVMMG.js.map
|