lse e.writeVarint32(r);e.append(t.buffer)},mo=ho(),zt=(o,e)=>(t,r)=>{t.writeVarint32(r.length);for(const[n,s]of r)o(t,n),e(t,s)},K=o=>(e,t)=>{e.writeVarint32(t.length);for(const r of t)o(e,r)},me=o=>(e,t)=>{for(const[r,n]of o)try{n(e,t[r])}catch(s){throw s.message=`${r}: ${s.message}`,s}},Ve=o=>(e,t)=>{t!==void 0?(e.writeByte(1),o(e,t)):e.writeByte(0)},G=me([["weight_threshold",te],["account_auths",zt(g,he)],["key_auths",zt(ke,he)]]),Hn=me([["account",g],["weight",he]]),tr=me([["base",z],["quote",z]]),zn=me([["account_creation_fee",z],["maximum_block_size",te],["hbd_interest_rate",he]]),M=(o,e)=>{const t=me(e);return(r,n)=>{r.writeVarint32(o),t(r,n)}},I={};I.account_create=M($.account_create,[["fee",z],["creator",g],["new_account_name",g],["owner",G],["active",G],["posting",G],["memo_key",ke],["json_metadata",g]]);I.account_create_with_delegation=M($.account_create_with_delegation,[["fee",z],["delegation",z],["creator",g],["new_account_name",g],["owner",G],["active",G],["posting",G],["memo_key",ke],["json_metadata",g],["extensions",K(le)]]);I.account_update=M($.account_update,[["account",g],["owner",Ve(G)],["active",Ve(G)],["posting",Ve(G)],["memo_key",ke],["json_metadata",g]]);I.account_witness_proxy=M($.account_witness_proxy,[["account",g],["proxy",g]]);I.account_witness_vote=M($.account_witness_vote,[["account",g],["witness",g],["approve",Ee]]);I.cancel_transfer_from_savings=M($.cancel_transfer_from_savings,[["from",g],["request_id",te]]);I.change_recovery_account=M($.change_recovery_account,[["account_to_recover",g],["new_recovery_account",g],["extensions",K(le)]]);I.claim_account=M($.claim_account,[["creator",g],["fee",z],["extensions",K(le)]]);I.claim_reward_balance=M($.claim_reward_balance,[["account",g],["reward_hive",z],["reward_hbd",z],["reward_vests",z]]);I.comment=M($.comment,[["parent_author",g],["parent_permlink",g],["author",g],["permlink",g],["title",g],["body",g],["json_metadata",g]]);I.comment_options=M($.comment_options,[["author",g],["permlink",g],["max_accepted_payout",z],["percent_hbd",he],["allow_votes",Ee],["allow_curation_rewards",Ee],["extensions",K(fo([me([["beneficiaries",K(Hn)]])]))]]);I.convert=M($.convert,[["owner",g],["requestid",te],["amount",z]]);I.create_claimed_account=M($.create_claimed_account,[["creator",g],["new_account_name",g],["owner",G],["active",G],["posting",G],["memo_key",ke],["json_metadata",g],["extensions",K(le)]]);I.custom=M($.custom,[["required_auths",K(g)],["id",he],["data",mo]]);I.custom_json=M($.custom_json,[["required_auths",K(g)],["required_posting_auths",K(g)],["id",g],["json",g]]);I.decline_voting_rights=M($.decline_voting_rights,[["account",g],["decline",Ee]]);I.delegate_vesting_shares=M($.delegate_vesting_shares,[["delegator",g],["delegatee",g],["vesting_shares",z]]);I.delete_comment=M($.delete_comment,[["author",g],["permlink",g]]);I.escrow_approve=M($.escrow_approve,[["from",g],["to",g],["agent",g],["who",g],["escrow_id",te],["approve",Ee]]);I.escrow_dispute=M($.escrow_dispute,[["from",g],["to",g],["agent",g],["who",g],["escrow_id",te]]);I.escrow_release=M($.escrow_release,[["from",g],["to",g],["agent",g],["who",g],["receiver",g],["escrow_id",te],["hbd_amount",z],["hive_amount",z]]);I.escrow_transfer=M($.escrow_transfer,[["from",g],["to",g],["hbd_amount",z],["hive_amount",z],["escrow_id",te],["agent",g],["fee",z],["json_meta",g],["ratification_deadline",Ne],["escrow_expiration",Ne]]);I.feed_publish=M($.feed_publish,[["publisher",g],["exchange_rate",tr]]);I.limit_order_cancel=M($.limit_order_cancel,[["owner",g],["orderid",te]]);I.limit_order_create=M($.limit_order_create,[["owner",g],["orderid",te],["amount_to_sell",z],["min_to_receive",z],["fill_or_kill",Ee],["expiration",Ne]]);I.limit_order_create2=M($.limit_order_create2,[["owner",g],["orderid",te],["amount_to_sell",z],["exchange_rate",tr],["fill_or_kill",Ee],["expiration",Ne]]);I.recover_account=M($.recover_account,[["account_to_recover",g],["new_owner_authority",G],["recent_owner_authority",G],["extensions",K(le)]]);I.request_account_recovery=M($.request_account_recovery,[["recovery_account",g],["account_to_recover",g],["new_owner_authority",G],["extensions",K(le)]]);I.reset_account=M($.reset_account,[["reset_account",g],["account_to_reset",g],["new_owner_authority",G]]);I.set_reset_account=M($.set_reset_account,[["account",g],["current_reset_account",g],["reset_account",g]]);I.set_withdraw_vesting_route=M($.set_withdraw_vesting_route,[["from_account",g],["to_account",g],["percent",he],["auto_vest",Ee]]);I.transfer=M($.transfer,[["from",g],["to",g],["amount",z],["memo",g]]);I.transfer_from_savings=M($.transfer_from_savings,[["from",g],["request_id",te],["to",g],["amount",z],["memo",g]]);I.transfer_to_savings=M($.transfer_to_savings,[["from",g],["to",g],["amount",z],["memo",g]]);I.transfer_to_vesting=M($.transfer_to_vesting,[["from",g],["to",g],["amount",z]]);I.vote=M($.vote,[["voter",g],["author",g],["permlink",g],["weight",Dn]]);I.withdraw_vesting=M($.withdraw_vesting,[["account",g],["vesting_shares",z]]);I.witness_update=M($.witness_update,[["owner",g],["url",g],["block_signing_key",ke],["props",zn],["fee",z]]);I.witness_set_properties=M($.witness_set_properties,[["owner",g],["props",zt(g,mo)],["extensions",K(le)]]);I.account_update2=M($.account_update2,[["account",g],["owner",Ve(G)],["active",Ve(G)],["posting",Ve(G)],["memo_key",Ve(ke)],["json_metadata",g],["posting_json_metadata",g],["extensions",K(le)]]);I.create_proposal=M($.create_proposal,[["creator",g],["receiver",g],["start_date",Ne],["end_date",Ne],["daily_pay",z],["subject",g],["permlink",g],["extensions",K(le)]]);I.update_proposal_votes=M($.update_proposal_votes,[["voter",g],["proposal_ids",K(lo)],["approve",Ee],["extensions",K(le)]]);I.remove_proposal=M($.remove_proposal,[["proposal_owner",g],["proposal_ids",K(lo)],["extensions",K(le)]]);const Vn=me([["end_date",Ne]]);I.update_proposal=M($.update_proposal,[["proposal_id",uo],["creator",g],["daily_pay",z],["subject",g],["permlink",g],["extensions",K(fo([le,Vn]))]]);I.collateralized_convert=M($.collateralized_convert,[["owner",g],["requestid",te],["amount",z]]);I.recurrent_transfer=M($.recurrent_transfer,[["from",g],["to",g],["amount",z],["memo",g],["recurrence",he],["executions",he],["extensions",K(me([["type",_r],["value",me([["pair_id",_r]])]]))]]);const Fn=(o,e)=>{const t=I[e[0]];if(!t)throw new Error(`No serializer for operation: ${e[0]}`);try{t(o,e[1])}catch(r){throw r.message=`${e[0]}: ${r.message}`,r}},jn=me([["ref_block_num",he],["ref_block_prefix",te],["expiration",Ne],["operations",K(Fn)],["extensions",K(g)]]),Wn=me([["from",ke],["to",ke],["nonce",uo],["check",te],["encrypted",ho()]]),wo={Asset:z,Memo:Wn,Price:tr,PublicKey:ke,String:g,Transaction:jn,UInt16:he,UInt32:te};let Vt=0,Cr=0;class vt extends Error{constructor(e){super(e.message),this.name="RPCError",this.stack=void 0,this.code=e.code,"data"in e&&(this.data=e.data)}}const po=async(o,e,t,r=ae.timeout,n=!1)=>{const s=Math.floor(Math.random()*1e8),i={jsonrpc:"2.0",method:e,params:t,id:s};try{const a=await(await fetch(o,{method:"POST",body:JSON.stringify(i),headers:{"Content-Type":"application/json"},signal:AbortSignal.timeout(r)})).json();if(!a||typeof a.id>"u"||a.id!==s||a.jsonrpc!=="2.0")throw new Error("JSONRPC id missmatch");if("result"in a)return a.result;if("error"in a){const l=a.error;throw"message"in l&&"code"in l?new vt(l):a.error}throw a}catch(c){if(c instanceof vt)throw c;if(n)return po(o,e,t,r,!1);throw c}},bt=async(o,e=[],t=ae.timeout,r=ae.retry)=>{if(!Array.isArray(ae.nodes))throw new Error("config.nodes is not an array");const n=ae.nodes[Vt];try{return await po(n,o,e,t)}catch(s){if(s instanceof vt||(Cr++,Cr>r))throw s;return Kn(),bt(o,e,t,r)}},Kn=(o=Vt+1)=>{o>ae.nodes.length-1&&(o=0),Vt=o},xr=o=>new Promise(e=>setTimeout(e,o)),Zn=ye(ae.chain_id);class rr{constructor(e){this.expiration=6e4,this.createTransaction=async t=>{const r=await bt("condenser_api.get_dynamic_global_properties",[]),n=ye(r.head_block_id),s=Number(new Uint32Array(n.buffer,n.byteOffset+4,1)[0]),i=new Date(Date.now()+t).toISOString().slice(0,-5);this.transaction={expiration:i,extensions:[],operations:[],ref_block_num:r.head_block_number&65535,ref_block_prefix:s,signatures:[]}},e?.transaction&&(e.transaction instanceof rr?(this.transaction=e.transaction.transaction,this.expiration=e.transaction.expiration):this.transaction=e.transaction,this.txId=this.digest().txId),e?.expiration&&(this.expiration=e.expiration)}async addOperation(e,t){this.transaction||await this.createTransaction(this.expiration),this.transaction.operations.push([e,t])}sign(e){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");if(this.transaction){const{digest:t,txId:r}=this.digest();Array.isArray(e)||(e=[e]);for(const n of e){const s=n.sign(t);this.transaction.signatures.push(s.customToString())}return this.txId=r,this.transaction}else throw new Error("No transaction to sign")}async broadcast(e=!1){if(!this.transaction)throw new Error("Attempted to broadcast an empty transaction. Add operations by .addOperation()");if(this.transaction.signatures.length===0)throw new Error("Attempted to broadcast a transaction with no signatures. Sign using .sign(keys)");try{await bt("condenser_api.broadcast_transaction",[this.transaction])}catch(n){if(!(n instanceof vt&&n.message.includes("Duplicate transaction check failed")))throw n}if(this.txId||(this.txId=this.digest().txId),!e)return{tx_id:this.txId,status:"unknown"};await xr(1e3);let t=await this.checkStatus(),r=1;for(;t?.status!=="within_irreversible_block"&&t?.status!=="expired_irreversible"&&t?.status!=="too_old";)await xr(1e3+r*300),t=await this.checkStatus(),r++;return{tx_id:this.txId,status:t.status}}digest(){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");const e=new T(T.DEFAULT_CAPACITY,T.LITTLE_ENDIAN),t={...this.transaction};try{wo.Transaction(e,t)}catch(i){throw new Error("Unable to serialize transaction: "+i)}e.flip();const r=new Uint8Array(e.toBuffer()),n=be(Ke(r)).slice(0,40);return{digest:Ke(new Uint8Array([...Zn,...r])),txId:n}}addSignature(e){if(!this.transaction)throw new Error("First create a transaction by .create(operations)");if(typeof e!="string")throw new Error("Signature must be string");if(e.length!==130)throw new Error("Signature must be 130 characters long");return this.transaction.signatures.push(e),this.transaction}async checkStatus(){return this.txId||(this.txId=this.digest().txId),bt("transaction_status_api.find_transaction",{transaction_id:this.txId,expiration:this.transaction?.expiration})}}const go=new Uint8Array([128]);class _e{constructor(e){this.key=e;try{xe.getPublicKey(e)}catch{throw new Error("invalid private key")}}static from(e){return typeof e=="string"?_e.fromString(e):new _e(e)}static fromString(e){return new _e(Yn(e).subarray(1))}static fromSeed(e){return typeof e=="string"&&(/^[0-9a-fA-F]+$/.test(e)?e=ye(e):e=new TextEncoder().encode(e)),new _e(Ke(e))}static fromLogin(e,t,r="active"){const n=e+r+t;return _e.fromSeed(n)}sign(e){const t=xe.sign(e,this.key,{extraEntropy:!0,format:"recovered",prehash:!1}),r=parseInt(be(t.subarray(0,1)),16);return Et.from((r+31).toString(16)+be(t.subarray(1)))}createPublic(e){return new ce(xe.getPublicKey(this.key),e)}toString(){return Xn(new Uint8Array([...go,...this.key]))}inspect(){const e=this.toString();return`PrivateKey: ${e.slice(0,6)}...${e.slice(-6)}`}getSharedSecret(e){const t=xe.getSharedSecret(this.key,e.key);return Hr(t.subarray(1))}static randomKey(){return new _e(xe.keygen().secretKey)}}const bo=o=>Ke(Ke(o)),Xn=o=>{const e=bo(o);return rt.encode(new Uint8Array([...o,...e.slice(0,4)]))},Yn=o=>{const e=rt.decode(o);if(!Pr(e.slice(0,1),go))throw new Error("Private key network id mismatch");const t=e.slice(-4),r=e.slice(0,-4),n=bo(r).slice(0,4);if(!Pr(t,n))throw new Error("Private key checksum mismatch");return r},Pr=(o,e)=>{if(o===e)return!0;if(o.byteLength!==e.byteLength)return!1;const t=o.byteLength;let r=0;for(;r<t&&o[r]===e[r];)r++;return r===t};/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function Gn(o){return o instanceof Uint8Array||ArrayBuffer.isView(o)&&o.constructor.name==="Uint8Array"}function Ce(o,e,t=""){const r=Gn(o),n=o?.length,s=e!==void 0;if(!r||s&&n!==e){const i=t&&`"${t}" `,c=s?` of length ${e}`:"",a=r?`length=${n}`:`type=${typeof o}`;throw new Error(i+"expected Uint8Array"+c+", got "+a)}return o}function Ue(o){return new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4))}function nt(...o){for(let e=0;e<o.length;e++)o[e].fill(0)}const Qn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Jn(o,e){return o.buffer===e.buffer&&o.byteOffset<e.byteOffset+e.byteLength&&e.byteOffset<o.byteOffset+o.byteLength}function yo(o,e){if(Jn(o,e)&&o.byteOffset<e.byteOffset)throw new Error("complex overlap of input and output is not supported")}const es=(o,e)=>{function t(r,...n){if(Ce(r,void 0,"key"),!Qn)throw new Error("Non little-endian hardware is not yet supported");if(o.nonceLength!==void 0){const d=n[0];Ce(d,o.varSizeNonce?void 0:o.nonceLength,"nonce")}const s=o.tagLength;s&&n[1]!==void 0&&Ce(n[1],void 0,"AAD");const i=e(r,...n),c=(d,u)=>{if(u!==void 0){if(d!==2)throw new Error("cipher output not supported");Ce(u,void 0,"output")}};let a=!1;return{encrypt(d,u){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,Ce(d),c(i.encrypt.length,u),i.encrypt(d,u)},decrypt(d,u){if(Ce(d),s&&d.length<s)throw new Error('"ciphertext" expected length bigger than tagLength='+s);return c(i.decrypt.length,u),i.decrypt(d,u)}}}return Object.assign(t,o),t};function ko(o,e,t=!0){if(e===void 0)return new Uint8Array(o);if(e.length!==o)throw new Error('"output" expected Uint8Array of length '+o+", got: "+e.length);if(t&&!et(e))throw new Error("invalid output, must be aligned");return e}function et(o){return o.byteOffset%4===0}function ot(o){return Uint8Array.from(o)}const Re=16,ts=283;function rs(o){if(![16,24,32].includes(o.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+o.length)}function or(o){return o<<1^ts&-(o>>7)}function Qe(o,e){let t=0;for(;e>0;e>>=1)t^=o&-(e&1),o=or(o);return t}const Ft=(()=>{const o=new Uint8Array(256);for(let t=0,r=1;t<256;t++,r^=or(r))o[t]=r;const e=new Uint8Array(256);e[0]=99;for(let t=0;t<255;t++){let r=o[255-t];r|=r<<8,e[o[t]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return nt(o),e})(),os=Ft.map((o,e)=>Ft.indexOf(e)),ns=o=>o<<24|o>>>8,Mt=o=>o<<8|o>>>24;function Bo(o,e){if(o.length!==256)throw new Error("Wrong sbox length");const t=new Uint32Array(256).map((l,d)=>e(o[d])),r=t.map(Mt),n=r.map(Mt),s=n.map(Mt),i=new Uint32Array(256*256),c=new Uint32Array(256*256),a=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let d=0;d<256;d++){const u=l*256+d;i[u]=t[l]^r[d],c[u]=n[l]^s[d],a[u]=o[l]<<8|o[d]}return{sbox:o,sbox2:a,T0:t,T1:r,T2:n,T3:s,T01:i,T23:c}}const nr=Bo(Ft,o=>Qe(o,3)<<24|o<<16|o<<8|Qe(o,2)),vo=Bo(os,o=>Qe(o,11)<<24|Qe(o,13)<<16|Qe(o,9)<<8|Qe(o,14)),ss=(()=>{const o=new Uint8Array(16);for(let e=0,t=1;e<16;e++,t=or(t))o[e]=t;return o})();function _o(o){Ce(o);const e=o.length;rs(o);const{sbox2:t}=nr,r=[];et(o)||r.push(o=ot(o));const n=Ue(o),s=n.length,i=a=>ge(t,a,a,a,a),c=new Uint32Array(e+28);c.set(n);for(let a=s;a<c.length;a++){let l=c[a-1];a%s===0?l=i(ns(l))^ss[a/s-1]:s>6&&a%s===4&&(l=i(l)),c[a]=c[a-s]^l}return nt(...r),c}function is(o){const e=_o(o),t=e.slice(),r=e.length,{sbox2:n}=nr,{T0:s,T1:i,T2:c,T3:a}=vo;for(let l=0;l<r;l+=4)for(let d=0;d<4;d++)t[l+d]=e[r-l-4+d];nt(e);for(let l=4;l<r-4;l++){const d=t[l],u=ge(n,d,d,d,d);t[l]=s[u&255]^i[u>>>8&255]^c[u>>>16&255]^a[u>>>24]}return t}function Te(o,e,t,r,n,s){return o[t<<8&65280|r>>>8&255]^e[n>>>8&65280|s>>>24&255]}function ge(o,e,t,r,n){return o[e&255|t&65280]|o[r>>>16&255|n>>>16&65280]<<16}function Er(o,e,t,r,n){const{sbox2:s,T01:i,T23:c}=nr;let a=0;e^=o[a++],t^=o[a++],r^=o[a++],n^=o[a++];const l=o.length/4-2;for(let p=0;p<l;p++){const b=o[a++]^Te(i,c,e,t,r,n),w=o[a++]^Te(i,c,t,r,n,e),k=o[a++]^Te(i,c,r,n,e,t),B=o[a++]^Te(i,c,n,e,t,r);e=b,t=w,r=k,n=B}const d=o[a++]^ge(s,e,t,r,n),u=o[a++]^ge(s,t,r,n,e),f=o[a++]^ge(s,r,n,e,t),h=o[a++]^ge(s,n,e,t,r);return{s0:d,s1:u,s2:f,s3:h}}function as(o,e,t,r,n){const{sbox2:s,T01:i,T23:c}=vo;let a=0;e^=o[a++],t^=o[a++],r^=o[a++],n^=o[a++];const l=o.length/4-2;for(let p=0;p<l;p++){const b=o[a++]^Te(i,c,e,n,r,t),w=o[a++]^Te(i,c,t,e,n,r),k=o[a++]^Te(i,c,r,t,e,n),B=o[a++]^Te(i,c,n,r,t,e);e=b,t=w,r=k,n=B}const d=o[a++]^ge(s,e,n,r,t),u=o[a++]^ge(s,t,e,n,r),f=o[a++]^ge(s,r,t,e,n),h=o[a++]^ge(s,n,r,t,e);return{s0:d,s1:u,s2:f,s3:h}}function cs(o){if(Ce(o),o.length%Re!==0)throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size "+Re)}function ls(o,e,t){Ce(o);let r=o.length;const n=r%Re;if(!e&&n!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");et(o)||(o=ot(o));const s=Ue(o);if(e){let c=Re-n;c||(c=Re),r=r+c}t=ko(r,t),yo(o,t);const i=Ue(t);return{b:s,o:i,out:t}}function ds(o,e){if(!e)return o;const t=o.length;if(!t)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=o[t-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");const n=o.subarray(0,-r);for(let s=0;s<r;s++)if(o[t-s-1]!==r)throw new Error("aes/pcks5: wrong padding");return n}function us(o){const e=new Uint8Array(16),t=Ue(e);e.set(o);const r=Re-o.length;for(let n=Re-r;n<Re;n++)e[n]=r;return t}const Co=es({blockSize:16,nonceLength:16},function(e,t,r={}){const n=!r.disablePadding;return{encrypt(s,i){const c=_o(e),{b:a,o:l,out:d}=ls(s,n,i);let u=t;const f=[c];et(u)||f.push(u=ot(u));const h=Ue(u);let p=h[0],b=h[1],w=h[2],k=h[3],B=0;for(;B+4<=a.length;)p^=a[B+0],b^=a[B+1],w^=a[B+2],k^=a[B+3],{s0:p,s1:b,s2:w,s3:k}=Er(c,p,b,w,k),l[B++]=p,l[B++]=b,l[B++]=w,l[B++]=k;if(n){const C=us(s.subarray(B*4));p^=C[0],b^=C[1],w^=C[2],k^=C[3],{s0:p,s1:b,s2:w,s3:k}=Er(c,p,b,w,k),l[B++]=p,l[B++]=b,l[B++]=w,l[B++]=k}return nt(...f),d},decrypt(s,i){cs(s);const c=is(e);let a=t;const l=[c];et(a)||l.push(a=ot(a));const d=Ue(a);i=ko(s.length,i),et(s)||l.push(s=ot(s)),yo(s,i);const u=Ue(s),f=Ue(i);let h=d[0],p=d[1],b=d[2],w=d[3];for(let k=0;k+4<=u.length;){const B=h,C=p,E=b,R=w;h=u[k+0],p=u[k+1],b=u[k+2],w=u[k+3];const{s0:V,s1:oe,s2:X,s3:U}=as(c,h,p,b,w);f[k++]=V^B,f[k++]=oe^C,f[k++]=X^E,f[k++]=U^R}return nt(...l),ds(i,n)}}}),fs=(o,e,t,r=ps())=>xo(o,e,r,t),hs=(o,e,t,r,n)=>xo(o,e,t,r,n).message,xo=(o,e,t,r,n)=>{const s=typeof t=="bigint"?t:BigInt(t),i=o.getSharedSecret(e);let c=new T(T.DEFAULT_CAPACITY,T.LITTLE_ENDIAN);c.writeUint64(s),c.append(i),c.flip();const a=Hr(new Uint8Array(c.toBuffer())),l=a.subarray(32,48),d=a.subarray(0,32),u=Ke(a).subarray(0,4),f=new T(T.DEFAULT_CAPACITY,T.LITTLE_ENDIAN);f.append(u),f.flip();const h=f.readUint32();if(n){if(h!==n)throw new Error("Invalid key");r=ms(r,d,l)}else r=ws(r,d,l);return{nonce:s,message:r,checksum:h}},ms=(o,e,t)=>{let r=o;return r=Co(e,t).decrypt(r),r},ws=(o,e,t)=>{let r=o;return r=Co(e,t).encrypt(r),r};let Ot=null;const ps=()=>{if(Ot===null){const t=xe.utils.randomSecretKey();Ot=Math.round(t[0]<<8|t[1])}let o=BigInt(Date.now());const e=++Ot%65535;return o=o<<BigInt(16)|BigInt(e),o},Sr=o=>{const e=Bs(o,33);return new ce(e)},gs=o=>o.readUint64(),bs=o=>o.readUint32(),ys=o=>{const e=o.readVarint32(),t=o.copy(o.offset,o.offset+e);return o.skip(e),new Uint8Array(t.toBuffer())},ks=o=>e=>{const t={},r=new T(T.DEFAULT_CAPACITY,T.LITTLE_ENDIAN);r.append(e),r.flip();for(const[n,s]of o)try{t[n]=s(r)}catch(i){throw i.message=`${n}: ${i.message}`,i}return t};function Bs(o,e){if(o){const t=o.copy(o.offset,o.offset+e);return o.skip(e),new Uint8Array(t.toBuffer())}else throw Error("No buffer found on first parameter")}const vs=ks([["from",Sr],["to",Sr],["nonce",gs],["check",bs],["encrypted",ys]]),_s={Memo:vs},Po=(o,e,t,r)=>{if(!t.startsWith("#"))return t;t=t.substring(1),So(),o=Ao(o),e=Cs(e);const n=new T(T.DEFAULT_CAPACITY,T.LITTLE_ENDIAN);n.writeVString(t);const s=new Uint8Array(n.copy(0,n.offset).toBuffer()),{nonce:i,message:c,checksum:a}=fs(o,e,s,r),l=new T(T.DEFAULT_CAPACITY,T.LITTLE_ENDIAN);wo.Memo(l,{check:a,encrypted:c,from:o.createPublic(),nonce:i,to:e}),l.flip();const d=new Uint8Array(l.toBuffer());return"#"+rt.encode(d)},Eo=(o,e)=>{if(!e.startsWith("#"))return e;e=e.substring(1),So(),o=Ao(o);let t=_s.Memo(rt.decode(e));const{from:r,to:n,nonce:s,check:i,encrypted:c}=t,l=o.createPublic().toString()===new ce(r.key).toString()?new ce(n.key):new ce(r.key);t=hs(o,l,s,c,i);const d=new T(T.DEFAULT_CAPACITY,T.LITTLE_ENDIAN);return d.append(t),d.flip(),"#"+d.readVString()};let pt;const So=()=>{if(pt===void 0){let o;pt=!0;try{const e="5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw",r=Po(e,"STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA","#memo爱");o=Eo(e,r)}finally{pt=o==="#memo爱"}}if(pt===!1)throw new Error("This environment does not support encryption.")},Ao=o=>typeof o=="string"?_e.fromString(o):o,Cs=o=>typeof o=="string"?ce.fromString(o):o,xs={decode:Eo,encode:Po};class Ps{timeout;constructor(e=1e4){this.timeout=e}async send(e,t){const r=new AbortController,n=setTimeout(()=>r.abort(),this.timeout);try{const s=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:r.signal});if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText}`);return await s.json()}finally{clearTimeout(n)}}}class Es{endpoints;currentIndex=0;transport;requestId=1;constructor(e,t){this.endpoints=e??["https://api.hive.blog","https://api.deathwing.me","https://hive-api.arcange.eu"],this.transport=t??new Ps,ae.nodes=[this.endpoints[0]]}get currentEndpoint(){return this.endpoints[this.currentIndex]}getEndpoints(){return this.endpoints.map((e,t)=>this.endpoints[(this.currentIndex+t)%this.endpoints.length])}setEndpoints(e){if(e.length===0)throw new Error("At least one endpoint required");this.endpoints=e,this.currentIndex=0,ae.nodes=[e[0]]}setTransport(e){this.transport=e}async call(e,t=[]){const r=this.endpoints.length;let n;for(let s=0;s<r;s++){const i=this.endpoints[(this.currentIndex+s)%this.endpoints.length],c={jsonrpc:"2.0",method:e,params:t,id:this.requestId++};try{const a=await this.transport.send(i,c);if(a.error)throw new Error(`RPC error ${a.error.code}: ${a.error.message}`);return this.currentIndex=(this.currentIndex+s)%this.endpoints.length,ae.nodes=[this.endpoints[this.currentIndex]],a.result}catch(a){n=a instanceof Error?a:new Error(String(a)),console.warn(`RPC call to ${i} failed: ${n.message}`)}}throw new Error(`All RPC endpoints failed. Last error: ${n?.message}`)}async healthCheck(){try{return await this.call("condenser_api.get_dynamic_global_properties"),!0}catch{return!1}}async getAccounts(e){return this.call("condenser_api.get_accounts",[e])}async getDynamicGlobalProperties(){return this.call("condenser_api.get_dynamic_global_properties")}async broadcastTransaction(e){return this.call("condenser_api.broadcast_transaction_synchronous",[e])}async getAccountHistory(e,t=-1,r=100){return this.call("condenser_api.get_account_history",[e,t,r])}}let Ut;function De(){return Ut||(Ut=new Es),Ut}function st(o){const e=_e.from(o),t=e.createPublic();return{private:e,public:t}}function Ss(o,e){const t=o.toString();return e.active.key_auths.some(([r])=>r===t)?"active":e.posting.key_auths.some(([r])=>r===t)?"posting":e.owner.key_auths.some(([r])=>r===t)?"owner":e.memo_key===t?"memo":null}async function Ar(o,e){const t=st(o),n=await De().getAccounts([e]);if(n.length===0)throw new Error(`Account @${e} not found`);const s=n[0],i=Ss(t.public,s);if(!i)throw new Error(`Key does not match any authority on @${e}`);return{...t,role:i,account:s}}function Fe(o){const e=o.trim().split(" ");if(e.length!==2)throw new Error(`Invalid asset format: ${o}`);return{amount:parseFloat(e[0]),symbol:e[1]}}function je(o,e){return`${o.toFixed(3)} ${e}`}const As=1;function Ls(){return As>=2}function jt(){return!1}function Lo(o,e){if(!o.startsWith("#"))return o;const t=xs.decode(e,o);return t.startsWith("#")?t.slice(1):t}const Is=["haa-service"];async function $s(o,e,t=Is,r=500){const n=De(),s=[],i=new Set(t.map(l=>l.toLowerCase())),c=Math.min(r,1e3),a=await n.getAccountHistory(o,-1,c);for(const[l,d]of a){const[u,f]=d.op;if(u!=="transfer")continue;const{from:h,to:p,memo:b}=f;if(p.toLowerCase()===o.toLowerCase()&&i.has(h.toLowerCase())&&!(!b||!b.startsWith("#")))try{const w=Lo(b,e),k=JSON.parse(w);if(!Os(k)||new Date(k.expires)<new Date)continue;s.push({payload:k,timestamp:d.timestamp,trxId:d.trx_id,from:h})}catch{continue}}return s.sort((l,d)=>new Date(d.timestamp).getTime()-new Date(l.timestamp).getTime()),s}async function Ms(o,e,t){const r=await $s(o,e,t);return r.length>0?r[0].payload:null}function Os(o){if(typeof o!="object"||o===null)return!1;const e=o;return typeof e.v=="number"&&Array.isArray(e.endpoints)&&e.endpoints.length>0&&e.endpoints.every(t=>typeof t=="string")&&typeof e.expires=="string"}const Us=["https://api.hive.blog","https://api.deathwing.me","https://hive-api.arcange.eu"],Tt="propolis_manual_endpoints";class Ts{endpoints=[];discoveryInterval=null;healthInterval=null;serviceAccounts;lastPayload=null;lastDiscoveryTime=0;discoveryAttempted=!1;constructor(e=["haa-service"]){this.serviceAccounts=e,this.loadManualEndpoints(),this.addFallbacks()}hasProxyEndpoints(){return this.endpoints.some(e=>e.source==="discovered"||e.source==="manual")}get allEndpoints(){return[...this.endpoints]}get healthyEndpoints(){const e={discovered:0,manual:1,fallback:2};return this.endpoints.filter(t=>t.healthy).sort((t,r)=>e[t.source]-e[r.source]).map(t=>t.url)}addManualEndpoint(e){this.endpoints.some(t=>t.url===e)||(this.endpoints.push({url:e,source:"manual",healthy:!0,lastCheck:0}),this.saveManualEndpoints(),this.applyToClient())}removeManualEndpoint(e){this.endpoints=this.endpoints.filter(t=>!(t.url===e&&t.source==="manual")),this.saveManualEndpoints(),this.applyToClient()}async discover(e,t){this.discoveryAttempted=!0;try{const r=await Ms(e,t,this.serviceAccounts);if(r){this.lastPayload=r,this.lastDiscoveryTime=Date.now(),this.endpoints=this.endpoints.filter(n=>n.source!=="discovered");for(const n of r.endpoints)this.endpoints.push({url:n,source:"discovered",healthy:!0,lastCheck:0});return this.applyToClient(),!0}return!1}catch(r){return console.warn("Endpoint discovery failed:",r),!1}}async healthCheckAll(){const t=(jt()?this.endpoints.filter(r=>r.source!=="fallback"):this.endpoints).map(async r=>{try{const n=new AbortController,s=setTimeout(()=>n.abort(),8e3),i=await fetch(r.url,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:"condenser_api.get_dynamic_global_properties",params:[],id:1}),signal:n.signal});clearTimeout(s),r.healthy=i.ok}catch{r.healthy=!1}r.lastCheck=Date.now()});await Promise.allSettled(t),this.applyToClient()}startPeriodicChecks(e,t,r=30*6e4,n=5*6e4){this.stopPeriodicChecks(),this.discover(e,t),this.discoveryInterval=setInterval(()=>this.discover(e,t),r),setTimeout(()=>{this.healthCheckAll(),this.healthInterval=setInterval(()=>this.healthCheckAll(),n)},15e3)}stopPeriodicChecks(){this.discoveryInterval&&(clearInterval(this.discoveryInterval),this.discoveryInterval=null),this.healthInterval&&(clearInterval(this.healthInterval),this.healthInterval=null)}applyToClient(){const e={discovered:0,manual:1,fallback:2};let t=this.endpoints.filter(n=>n.healthy);jt()&&(t=t.filter(n=>n.source!=="fallback"));const r=t.sort((n,s)=>e[n.source]-e[s.source]).map(n=>n.url);if(r.length>0)try{De().setEndpoints(r)}catch{}}loadManualEndpoints(){try{const e=localStorage.getItem(Tt);if(!e)return;const t=JSON.parse(e);for(const r of t)this.endpoints.some(n=>n.url===r)||this.endpoints.push({url:r,source:"manual",healthy:!0,lastCheck:0})}catch{}}saveManualEndpoints(){const e=this.endpoints.filter(t=>t.source==="manual").map(t=>t.url);e.length>0?localStorage.setItem(Tt,JSON.stringify(e)):localStorage.removeItem(Tt)}addFallbacks(){for(const e of Us)this.endpoints.some(t=>t.url===e)||this.endpoints.push({url:e,source:"fallback",healthy:!0,lastCheck:0})}}let Rt;function it(){return Rt||(Rt=new Ts),Rt}function fe(o,...e){return e.reduce((t,r,n)=>t.replace(`%${n+1}`,String(r)),o)}const m={html_lang:"ar",html_dir:"rtl",app_title:"محفظة Propolis",nav_balance:"الرصيد",nav_transfer:"تحويل",nav_savings:"المدخرات",nav_settings:"الإعدادات",loading:"جارٍ التحميل…",amount:"المبلغ",confirm:"تأكيد",cancel:"إلغاء",broadcasting:"جارٍ البث…",invalid_url:"رابط غير صالح.",https_required:"يجب أن يستخدم رابط الوكيل HTTPS.",enter_proxy_url:"أدخل رابط الوكيل.",amount_positive:"يجب أن يكون المبلغ أكبر من صفر.",username_placeholder:"اسم المستخدم",key_placeholder:"5K...",proxy_placeholder:"https://proxy.example.com",rpc_placeholder:"https://proxy.example.com/rpc",confirm_direct_mode:"الوضع المباشر يكشف حركة مرور Hive. هل تريد المتابعة؟",confirm_logout:"تسجيل الخروج وحذف المفاتيح؟",login_title:"تسجيل الدخول",login_info:"أدخل اسم حساب Hive والمفتاح الخاص Active. مفتاحك لا يغادر هذا الجهاز أبداً.",account_name:"اسم الحساب",private_active_key:"المفتاح الخاص Active",private_memo_key:"المفتاح الخاص Memo (اختياري)",memo_key_placeholder:"5K... (للرسائل المشفرة)",remember_keys:"تذكر المفاتيح",remember_warning:"يتم تخزين المفاتيح في localStorage. استخدم فقط على جهاز موثوق.",login_btn:"دخول",account_key_required:"اسم الحساب ومفتاح Active مطلوبان.",validating:"جارٍ التحقق…",wrong_key_role:"هذا مفتاح %1. مفتاح Active مطلوب.",wrong_memo_role:"المفتاح الثاني هو %1، وليس Memo.",scan_qr:"مسح رمز QR",qr_scanning:"وجّه الكاميرا نحو رمز QR",qr_filled_all:"تم المسح! تم ملء الحساب والمفاتيح.",qr_filled_active:"تم المسح! تم ملء مفتاح Active.",qr_filled_memo:"تم المسح! تم ملء مفتاح Memo.",qr_unknown:"صيغة رمز QR غير معروفة",qr_no_camera:"تم رفض الوصول إلى الكاميرا",proxy_setup:"إعداد الوكيل",proxy_required:"الوكيل مطلوب",proxy_desc_reconnect:"وضع التمويه مفعّل لكن لم يتم تعيين وكيل. أدخل رابط الوكيل لإعادة الاتصال.",proxy_desc_connect:"وضع التمويه مفعّل. أدخل رابط الوكيل للاتصال.",proxy_url:"رابط الوكيل",connect:"اتصال",switch_direct_link:"أو التبديل إلى الوضع المباشر",paste_memo_prefix:"أو الصق مذكرة مشفرة من",block_explorer:"مستكشف الكتل",paste_memo_suffix:":",memo_textarea_placeholder:"#encrypted_memo...",decrypt_connect:"فك التشفير والاتصال",paste_memo_error:"الصق المذكرة المشفرة.",memo_key_required:"مفتاح Memo مطلوب لفك التشفير.",private_memo_key_label:"المفتاح الخاص Memo",memo_not_hash:"يجب أن تبدأ المذكرة بـ #",memo_bad_json:"المذكرة المفكّكة ليست JSON صالح.",memo_bad_payload:"المذكرة لا تحتوي على بيانات نقاط الاتصال.",memo_expired:"بيانات نقطة الاتصال منتهية الصلاحية.",account_label:"الحساب",account_not_found:"الحساب غير موجود.",refresh:"تحديث",hive:"HIVE",hbd:"HBD",hive_savings:"مدخرات HIVE",hbd_savings:"مدخرات HBD",est_interest:"الفائدة التقديرية (~٢٠٪ سنوياً):",hbd_yr:"HBD/سنة",pending_withdrawals:"%1 عمليات سحب معلّقة",rpc_label:"RPC:",obfuscated:"مموّه",direct:"مباشر",send_transfer:"إرسال تحويل",recipient:"المستلم",currency:"العملة",memo_optional:"مذكرة (اختياري)",public_memo:"مذكرة عامة",send:"إرسال",recipient_required:"المستلم مطلوب.",confirm_send:"إرسال %1 إلى @%2؟",sent_tx:"تم الإرسال! TX: %1… (%2)",deposit_heading:"إيداع في المدخرات",withdraw_heading:"سحب من المدخرات",three_day_wait:"فترة انتظار ٣ أيام للأمان.",deposit_btn:"إيداع في المدخرات",withdraw_btn:"سحب من المدخرات",pending_heading:"معلّق",cancel_latest:"إلغاء الأخير",available_hbd:"متاح: %1 HBD",apr_estimate:"~%1 HBD/سنة (~٢٠٪ سنوياً)",n_pending:"%1 معلّق",cancelled:"تم الإلغاء. (%1)",confirm_deposit:"إيداع %1؟",confirm_withdraw:"سحب (انتظار ٣ أيام) %1؟",deposited:"تم الإيداع",withdrawal_initiated:"تم بدء السحب",not_found:"غير موجود.",privacy:"الخصوصية",mode_label:"الوضع:",mode_obfuscated:"مموّه",mode_direct:"مباشر",traffic_disguised:"حركة المرور متخفية كطلبات ويب عادية.",traffic_plain:"JSON-RPC مكشوف — مرئي لمراقبي الشبكة.",switch_to_direct:"التبديل إلى المباشر",switch_to_obfuscated:"التبديل إلى المموّه",rpc_endpoint:"نقطة اتصال RPC",current_label:"الحالي:",custom_endpoint:"نقطة اتصال مخصصة",set_btn:"تعيين",reset_btn:"إعادة تعيين",check_btn:"فحص",enter_url:"أدخل رابطاً.",added:"تمت الإضافة.",reset_done:"تمت إعادة التعيين.",discovery:"اكتشاف",status_label:"الحالة:",n_found:"تم العثور على %1",none_found:"لم يتم العثور على شيء",checking:"جارٍ الفحص…",expires_label:"ينتهي: %1",discover:"اكتشاف",check_all:"فحص الكل",no_memo_key:"لا يوجد مفتاح Memo — الاكتشاف معطّل.",add_memo_hint:"أضف مفتاح Memo عند الدخول لاكتشاف نقاط اتصال الوكيل.",found_n:"تم العثور على %1",none_found_dot:"لم يتم العثور على شيء.",done:"تم.",endpoints:"نقاط الاتصال",none:"لا يوجد.",account_heading:"الحساب",active_check:"Active:",memo_check:"Memo:",persistent:"دائم",session:"جلسة",logout:"خروج",about:"حول",about_text:"محفظة Propolis الإصدار ١.٠.٠ — المفاتيح لا تغادر هذا الجهاز أبداً.",err_missing_active_auth:"مفتاح Active ليس لديه صلاحية لهذا الحساب.",err_missing_posting_auth:"مفتاح Posting ليس لديه صلاحية لهذا الحساب.",err_missing_owner_auth:"مفتاح Owner ليس لديه صلاحية لهذا الحساب.",err_key_mismatch:"المفتاح لا يتطابق مع هذا الحساب.",err_insufficient_rc:"أرصدة الموارد غير كافية. انتظر الاستعادة أو اطلب تفويض HP.",err_account_not_found:"الحساب غير موجود على البلوكتشين.",err_tx_expired:"انتهت صلاحية المعاملة. يرجى المحاولة مرة أخرى.",err_duplicate_tx:"معاملة مكررة — تمت معالجتها بالفعل.",err_all_endpoints_failed:"تعذّر الاتصال بأي عقدة RPC. تحقق من اتصال الشبكة.",err_http_error:"خطأ في الخادم. حاول مرة أخرى أو غيّر عقدة RPC.",err_network:"خطأ في الشبكة. تحقق من اتصال الإنترنت.",err_timeout:"انتهت مهلة الطلب. حاول مرة أخرى أو غيّر عقدة RPC.",err_unknown:"فشلت العملية. يرجى المحاولة مرة أخرى."};function qt(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}const Rs=[[/missing required active authority/i,()=>m.err_missing_active_auth],[/missing required posting authority/i,()=>m.err_missing_posting_auth],[/missing required owner authority/i,()=>m.err_missing_owner_auth],[/does not match any authority/i,()=>m.err_key_mismatch],[/insufficient Resource Credits/i,()=>m.err_insufficient_rc],[/Account.+not found/i,()=>m.err_account_not_found],[/uniqueness constraint/i,()=>m.err_duplicate_tx],[/All RPC endpoints failed/i,()=>m.err_all_endpoints_failed],[/HTTP [45]\d\d/i,()=>m.err_http_error],[/Failed to fetch|NetworkError|ERR_/i,()=>m.err_network],[/AbortError|timed?\s*out/i,()=>m.err_timeout],[/expir/i,()=>m.err_tx_expired]];function sr(o){const e=qt(o);for(const[t,r]of Rs)if(t.test(o))return`${qt(r())}<br><span class="xs" style="opacity:0.7;word-break:break-all">${e}</span>`;return`${qt(m.err_unknown)}<br><span class="xs" style="opacity:0.7;word-break:break-all">${e}</span>`}function _t(o,e){o.innerHTML=sr(e instanceof Error?e.message:String(e)),o.classList.remove("hidden")}const qs="modulepreload",Ns=function(o,e){return new URL(o,e).href},Lr={},Ds=function(e,t,r){let n=Promise.resolve();if(t&&t.length>0){let i=function(d){return Promise.all(d.map(u=>Promise.resolve(u).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const c=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");n=i(t.map(d=>{if(d=Ns(d,r),d in Lr)return;Lr[d]=!0;const u=d.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(!!r)for(let b=c.length-1;b>=0;b--){const w=c[b];if(w.href===d&&(!u||w.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${d}"]${f}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":qs,u||(p.as="script"),p.crossOrigin="",p.href=d,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((b,w)=>{p.addEventListener("load",b),p.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${d}`)))})}))}function s(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return n.then(i=>{for(const c of i||[])c.status==="rejected"&&s(c.reason);return e().catch(s)})};class N{constructor(e,t,r,n,s){this._legacyCanvasSize=N.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=e,this.$canvas=document.createElement("canvas"),r&&typeof r=="object"?this._onDecode=t:(console.warn(r||n||s?"You're using a deprecated version of the QrScanner constructor which will be removed in the future":"Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=t),t=typeof r=="object"?r:{},this._onDecodeError=t.onDecodeError||(typeof r=="function"?r:this._onDecodeError),this._calculateScanRegion=t.calculateScanRegion||(typeof n=="function"?n:this._calculateScanRegion),this._preferredCamera=t.preferredCamera||s||this._preferredCamera,this._legacyCanvasSize=typeof r=="number"?r:typeof n=="number"?n:this._legacyCanvasSize,this._maxScansPerSecond=t.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),e.disablePictureInPicture=!0,e.playsInline=!0,e.muted=!0;let i=!1;if(e.hidden&&(e.hidden=!1,i=!0),document.body.contains(e)||(document.body.appendChild(e),i=!0),r=e.parentElement,t.highlightScanRegion||t.highlightCodeOutline){if(n=!!t.overlay,this.$overlay=t.overlay||document.createElement("div"),s=this.$overlay.style,s.position="absolute",s.display="none",s.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!n&&t.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch{}r.insertBefore(this.$overlay,this.$video.nextSibling)}t.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(e),requestAnimationFrame(()=>{let c=window.getComputedStyle(e);c.display==="none"&&(e.style.setProperty("display","block","important"),i=!0),c.visibility!=="visible"&&(e.style.setProperty("visibility","visible","important"),i=!0),i&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),e.style.opacity="0",e.style.width="0",e.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()}),e.addEventListener("play",this._onPlay),e.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=N.createQrEngine()}static set WORKER_PATH(e){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await N.listCameras(!1)).length}catch{return!1}}static async listCameras(e=!1){if(!navigator.mediaDevices)return[];let t=async()=>(await navigator.mediaDevices.enumerateDevices()).filter(n=>n.kind==="videoinput"),r;try{e&&(await t()).every(n=>!n.label)&&(r=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch{}try{return(await t()).map((n,s)=>({id:n.deviceId,label:n.label||(s===0?"Default Camera":`Camera ${s+1}`)}))}finally{r&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),N._stopVideoStream(r))}}async hasFlash(){let e;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;e=this.$video.srcObject}else e=(await this._getCameraStream()).stream;return"torch"in e.getVideoTracks()[0].getSettings()}catch{return!1}finally{e&&e!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),N._stopVideoStream(e))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!await this.hasFlash())throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(e){throw this._flashOn=!1,e}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),N._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&(window.location.protocol!=="https:"&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:e,facingMode:t}=await this._getCameraStream();!this._active||this._paused?N._stopVideoStream(e):(this._setVideoMirror(t),this.$video.srcObject=e,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch(()=>{})))}catch(e){if(!this._paused)throw this._active=!1,e}}stop(){this.pause(),this._active=!1}async pause(e=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let t=()=>{this.$video.srcObject instanceof MediaStream&&(N._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return e?(t(),!0):(await new Promise(r=>setTimeout(r,300)),this._paused?(t(),!0):!1)}async setCamera(e){e!==this._preferredCamera&&(this._preferredCamera=e,await this._restartVideoStream())}static async scanImage(e,t,r,n,s=!1,i=!1){let c,a=!1;t&&("scanRegion"in t||"qrEngine"in t||"canvas"in t||"disallowCanvasResizing"in t||"alsoTryWithoutScanRegion"in t||"returnDetailedScanResult"in t)?(c=t.scanRegion,r=t.qrEngine,n=t.canvas,s=t.disallowCanvasResizing||!1,i=t.alsoTryWithoutScanRegion||!1,a=!0):console.warn(t||r||n||s||i?"You're using a deprecated api for scanImage which will be removed in the future.":"Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),t=!!r;try{let l,d;[r,l]=await Promise.all([r||N.createQrEngine(),N._loadImage(e)]),[n,d]=N._drawToCanvas(l,c,n,s);let u;if(r instanceof Worker){let f=r;t||N._postWorkerMessageSync(f,"inversionMode","both"),u=await new Promise((h,p)=>{let b,w,k,B=-1;w=E=>{E.data.id===B&&(f.removeEventListener("message",w),f.removeEventListener("error",k),clearTimeout(b),E.data.data!==null?h({data:E.data.data,cornerPoints:N._convertPoints(E.data.cornerPoints,c)}):p(N.NO_QR_CODE_FOUND))},k=E=>{f.removeEventListener("message",w),f.removeEventListener("error",k),clearTimeout(b),p("Scanner error: "+(E?E.message||E:"Unknown Error"))},f.addEventListener("message",w),f.addEventListener("error",k),b=setTimeout(()=>k("timeout"),1e4);let C=d.getImageData(0,0,n.width,n.height);B=N._postWorkerMessageSync(f,"decode",C,[C.data.buffer])})}else u=await Promise.race([new Promise((f,h)=>window.setTimeout(()=>h("Scanner error: timeout"),1e4)),(async()=>{try{var[f]=await r.detect(n);if(!f)throw N.NO_QR_CODE_FOUND;return{data:f.rawValue,cornerPoints:N._convertPoints(f.cornerPoints,c)}}catch(h){if(f=h.message||h,/not implemented|service unavailable/.test(f))return N._disableBarcodeDetector=!0,N.scanImage(e,{scanRegion:c,canvas:n,disallowCanvasResizing:s,alsoTryWithoutScanRegion:i});throw`Scanner error: ${f}`}})()]);return a?u:u.data}catch(l){if(!c||!i)throw l;let d=await N.scanImage(e,{qrEngine:r,canvas:n,disallowCanvasResizing:s});return a?d:d.data}finally{t||N._postWorkerMessage(r,"close")}}setGrayscaleWeights(e,t,r,n=!0){N._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:e,green:t,blue:r,useIntegerApproximation:n})}setInversionMode(e){N._postWorkerMessage(this._qrEnginePromise,"inversionMode",e)}static async createQrEngine(e){if(e&&console.warn("Specifying a worker path is not required and not supported anymore."),e=()=>Ds(()=>Promise.resolve().then(()=>ci),void 0,import.meta.url).then(r=>r.createWorker()),!(!N._disableBarcodeDetector&&"BarcodeDetector"in window&&BarcodeDetector.getSupportedFormats&&(await BarcodeDetector.getSupportedFormats()).includes("qr_code")))return e();let t=navigator.userAgentData;return t&&t.brands.some(({brand:r})=>/Chromium/i.test(r))&&/mac ?OS/i.test(t.platform)&&await t.getHighEntropyValues(["architecture","platformVersion"]).then(({architecture:r,platformVersion:n})=>/arm/i.test(r||"arm")&&13<=parseInt(n||"13")).catch(()=>!0)?e():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(e){let t=Math.round(.6666666666666666*Math.min(e.videoWidth,e.videoHeight));return{x:Math.round((e.videoWidth-t)/2),y:Math.round((e.videoHeight-t)/2),width:t,height:t,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame(()=>{if(this.$overlay){var e=this.$video,t=e.videoWidth,r=e.videoHeight,n=e.offsetWidth,s=e.offsetHeight,i=e.offsetLeft,c=e.offsetTop,a=window.getComputedStyle(e),l=a.objectFit,d=t/r,u=n/s;switch(l){case"none":var f=t,h=r;break;case"fill":f=n,h=s;break;default:(l==="cover"?d>u:d<u)?(h=s,f=h*d):(f=n,h=f/d),l==="scale-down"&&(f=Math.min(f,t),h=Math.min(h,r))}var[p,b]=a.objectPosition.split(" ").map((k,B)=>{const C=parseFloat(k);return k.endsWith("%")?(B?s-h:n-f)*C/100:C});a=this._scanRegion.width||t,u=this._scanRegion.height||r,l=this._scanRegion.x||0;var w=this._scanRegion.y||0;d=this.$overlay.style,d.width=`${a/t*f}px`,d.height=`${u/r*h}px`,d.top=`${c+b+w/r*h}px`,r=/scaleX\(-1\)/.test(e.style.transform),d.left=`${i+(r?n-p-f:p)+(r?t-l-a:l)/t*f}px`,d.transform=e.style.transform}})}static _convertPoints(e,t){if(!t)return e;let r=t.x||0,n=t.y||0,s=t.width&&t.downScaledWidth?t.width/t.downScaledWidth:1;t=t.height&&t.downScaledHeight?t.height/t.downScaledHeight:1;for(let i of e)i.x=i.x*s+r,i.y=i.y*t+n;return e}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)(async()=>{if(!(1>=this.$video.readyState)){var e=Date.now()-this._lastScanTimestamp,t=1e3/this._maxScansPerSecond;e<t&&await new Promise(n=>setTimeout(n,t-e)),this._lastScanTimestamp=Date.now();try{var r=await N.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(n){if(!this._active)return;this._onDecodeError(n)}!N._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=N.createQrEngine()),r?(this._onDecode?this._onDecode(r):this._legacyOnDecode&&this._legacyOnDecode(r.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",r.cornerPoints.map(({x:n,y:s})=>`${n},${s}`).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout(()=>this.$codeOutlineHighlight.style.display="none",100))}this._scanFrame()})}_onDecodeError(e){e!==N.NO_QR_CODE_FOUND&&console.log(e)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let e=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",t=[{width:{min:1024}},{width:{min:768}},{}],r=t.map(n=>Object.assign({},n,{[e]:{exact:this._preferredCamera}}));for(let n of[...r,...t])try{let s=await navigator.mediaDevices.getUserMedia({video:n,audio:!1}),i=this._getFacingMode(s)||(n.facingMode?this._preferredCamera:this._preferredCamera==="environment"?"user":"environment");return{stream:s,facingMode:i}}catch{}throw"Camera not found."}async _restartVideoStream(){let e=this._paused;await this.pause(!0)&&!e&&this._active&&await this.start()}static _stopVideoStream(e){for(let t of e.getTracks())t.stop(),e.removeTrack(t)}_setVideoMirror(e){this.$video.style.transform="scaleX("+(e==="user"?-1:1)+")"}_getFacingMode(e){return(e=e.getVideoTracks()[0])?/rear|back|environment/i.test(e.label)?"environment":/front|user|face/i.test(e.label)?"user":null:null}static _drawToCanvas(e,t,r,n=!1){r=r||document.createElement("canvas");let s=t&&t.x?t.x:0,i=t&&t.y?t.y:0,c=t&&t.width?t.width:e.videoWidth||e.width,a=t&&t.height?t.height:e.videoHeight||e.height;return n||(n=t&&t.downScaledWidth?t.downScaledWidth:c,t=t&&t.downScaledHeight?t.downScaledHeight:a,r.width!==n&&(r.width=n),r.height!==t&&(r.height=t)),t=r.getContext("2d",{alpha:!1}),t.imageSmoothingEnabled=!1,t.drawImage(e,s,i,c,a,0,0,r.width,r.height),[r,t]}static async _loadImage(e){if(e instanceof Image)return await N._awaitImageLoad(e),e;if(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e instanceof SVGImageElement||"OffscreenCanvas"in window&&e instanceof OffscreenCanvas||"ImageBitmap"in window&&e instanceof ImageBitmap)return e;if(e instanceof File||e instanceof Blob||e instanceof URL||typeof e=="string"){let t=new Image;t.src=e instanceof File||e instanceof Blob?URL.createObjectURL(e):e.toString();try{return await N._awaitImageLoad(t),t}finally{(e instanceof File||e instanceof Blob)&&URL.revokeObjectURL(t.src)}}else throw"Unsupported image type."}static async _awaitImageLoad(e){e.complete&&e.naturalWidth!==0||await new Promise((t,r)=>{let n=s=>{e.removeEventListener("load",n),e.removeEventListener("error",n),s instanceof ErrorEvent?r("Image load error"):t()};e.addEventListener("load",n),e.addEventListener("error",n)})}static async _postWorkerMessage(e,t,r,n){return N._postWorkerMessageSync(await e,t,r,n)}static _postWorkerMessageSync(e,t,r,n){if(!(e instanceof Worker))return-1;let s=N._workerMessageId++;return e.postMessage({id:s,type:t,data:r},n),s}}N.DEFAULT_CANVAS_SIZE=400;N.NO_QR_CODE_FOUND="No QR code found";N._disableBarcodeDetector=!1;N._workerMessageId=0;function Hs(){return!!navigator.mediaDevices?.getUserMedia}const zs=/^[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+$/;function Vs(o){const e=o.trim();if(e.startsWith("propolis://login"))try{const t=new URL(e.replace("propolis://","https://")),r=t.searchParams.get("a"),n=t.searchParams.get("k"),s=t.searchParams.get("m")||void 0;if(r&&n)return{type:"combined",account:r,activeWif:n,memoWif:s}}catch{}return e.length===51&&e[0]==="5"&&zs.test(e)?{type:"wif",key:e}:{type:"unknown"}}function Fs(){return new Promise(o=>{const e=document.createElement("div");e.style.cssText="position:fixed;inset:0;z-index:9999;background:rgba(0,0,0,0.92);display:flex;flex-direction:column;align-items:center;justify-content:center;";const t=document.createElement("button");t.textContent="×",t.style.cssText="position:absolute;top:12px;right:16px;background:none;border:none;color:#fff;font-size:2rem;cursor:pointer;z-index:10000;width:auto;padding:4px 12px;";const r=document.createElement("video");r.setAttribute("playsinline",""),r.setAttribute("autoplay",""),r.muted=!0,r.style.cssText="width:80vw;max-height:60vh;min-height:200px;border-radius:8px;border:2px solid #4ecca3;object-fit:cover;background:#000;";const n=document.createElement("p");n.textContent=m.qr_scanning,n.style.cssText="color:#a0a0b0;font-size:0.85rem;margin-top:12px;text-align:center;padding:0 1rem;",e.appendChild(t),e.appendChild(r),e.appendChild(n),document.body.appendChild(e);let s=null,i=!1;const c=()=>{s&&(s.destroy(),s=null),e.parentNode&&e.parentNode.removeChild(e)},a=d=>{i||(i=!0,c(),o(d))},l=d=>{n.textContent=d,n.style.color="#ff6b6b"};t.addEventListener("click",()=>a(null)),navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}}).then(d=>{d.getTracks().forEach(u=>u.stop()),s=new N(r,u=>{a(u.data)},{preferredCamera:"environment",maxScansPerSecond:5,returnDetailedScanResult:!0,onDecodeError:()=>{}}),s.start().catch(u=>{l(u instanceof Error?u.message:m.qr_no_camera)})}).catch(d=>{const u=d instanceof Error&&d.name==="NotAllowedError"?m.qr_no_camera:d instanceof Error?d.message:m.qr_no_camera;l(u)})})}const $e=(o,e)=>e.querySelector(o);async function js(o,e,t){it(),e.account;let r=null;try{r=localStorage.getItem("propolis_bootstrap_memo_key"),r&&localStorage.removeItem("propolis_bootstrap_memo_key")}catch{}o.innerHTML=`<div class="card"><h2>${m.login_title}</h2>
<p class="sm mt mb">${m.login_info}</p>
${Hs()?`<button class="btn-s mb" id="qr" type="button">${m.scan_qr}</button>`:""}
<label>${m.account_name}</label><input id="a" placeholder="${m.username_placeholder}" autocomplete="off" spellcheck="false">
<label>${m.private_active_key}</label><input type="password" id="k" placeholder="${m.key_placeholder}" autocomplete="off">
<label>${m.private_memo_key}</label><input type="password" id="m" placeholder="${m.memo_key_placeholder}" autocomplete="off">
<div class="mb"><label class="fx" style="cursor:pointer"><input type="checkbox" id="p" style="width:auto;margin:0"><span class="sm">${m.remember_keys}</span></label>
<p class="wrn hidden" id="pw">${m.remember_warning}</p></div>
<button id="b">${m.login_btn}</button><p class="err hidden" id="e"></p><p class="ok hidden" id="s"></p></div>`;const n=$e("#a",o),s=$e("#k",o),i=$e("#m",o),c=$e("#p",o),a=$e("#pw",o),l=$e("#b",o),d=$e("#e",o),u=$e("#s",o);n.addEventListener("blur",()=>{n.
Sort: Trending