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