diff --git a/docs/assets/index-66f84df3.js b/docs/assets/index-c5d69010.js similarity index 96% rename from docs/assets/index-66f84df3.js rename to docs/assets/index-c5d69010.js index b5d03c9..f108d8d 100644 --- a/docs/assets/index-66f84df3.js +++ b/docs/assets/index-c5d69010.js @@ -414,7 +414,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function __rest(b,_){var d={};for(var k in b)Object.prototype.hasOwnProperty.call(b,k)&&_.indexOf(k)<0&&(d[k]=b[k]);if(b!=null&&typeof Object.getOwnPropertySymbols=="function")for(var j=0,k=Object.getOwnPropertySymbols(b);j{var j,$;if(!((j=_==null?void 0:_.signal)===null||j===void 0)&&j.aborted){k(new TonConnectError("Delay aborted"));return}const et=setTimeout(()=>d(),b);($=_==null?void 0:_.signal)===null||$===void 0||$.addEventListener("abort",()=>{clearTimeout(et),k(new TonConnectError("Delay aborted"))})})})}function createAbortController(b){const _=new AbortController;return b!=null&&b.aborted?_.abort():b==null||b.addEventListener("abort",()=>_.abort(),{once:!0}),_}function callForSuccess(b,_){var d,k;return __awaiter(this,void 0,void 0,function*(){const j=(d=_==null?void 0:_.attempts)!==null&&d!==void 0?d:10,$=(k=_==null?void 0:_.delayMs)!==null&&k!==void 0?k:200,et=createAbortController(_==null?void 0:_.signal);if(typeof b!="function")throw new TonConnectError(`Expected a function, got ${typeof b}`);let tt=0,rt;for(;tt__awaiter(this,void 0,void 0,function*(){if($=at??null,et==null||et.abort(),et=createAbortController(at),et.signal.aborted)throw new TonConnectError("Resource creation was aborted");k=it??null;const dt=b(et.signal,...it);j=dt;const ut=yield dt;if(j!==dt&&ut!==d)throw yield _(ut),new TonConnectError("Resource creation was aborted by a new resource creation");return d=ut,d});return{create:tt,current:()=>d??null,dispose:()=>__awaiter(this,void 0,void 0,function*(){try{const at=d;d=null;const it=j;j=null;try{et==null||et.abort()}catch{}yield Promise.allSettled([at?_(at):Promise.resolve(),it?_(yield it):Promise.resolve()])}catch{}}),recreate:at=>__awaiter(this,void 0,void 0,function*(){const it=d,dt=j,ut=k,ht=$;if(yield delay(at),it===d&&dt===j&&ut===k&&ht===$)return yield tt($,...ut??[]);throw new TonConnectError("Resource recreation was aborted by a new resource creation")})}}function timeout(b,_){const d=_==null?void 0:_.timeout,k=_==null?void 0:_.signal,j=createAbortController(k);return new Promise(($,et)=>__awaiter(this,void 0,void 0,function*(){if(j.signal.aborted){et(new TonConnectError("Operation aborted"));return}let tt;typeof d<"u"&&(tt=setTimeout(()=>{j.abort(),et(new TonConnectError(`Timeout after ${d}ms`))},d)),j.signal.addEventListener("abort",()=>{clearTimeout(tt),et(new TonConnectError("Operation aborted"))},{once:!0});const rt={timeout:d,abort:j.signal};yield b((...nt)=>{clearTimeout(tt),$(...nt)},()=>{clearTimeout(tt),et()},rt)}))}class BridgeGateway{constructor(_,d,k,j,$){this.bridgeUrl=d,this.sessionId=k,this.listener=j,this.errorsListener=$,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=createResource$1((et,tt)=>__awaiter(this,void 0,void 0,function*(){const rt={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:et,openingDeadlineMS:tt};return yield createEventSource(rt)}),et=>__awaiter(this,void 0,void 0,function*(){et.close()})),this.bridgeGatewayStorage=new HttpBridgeGatewayStorage(_,d)}get isReady(){const _=this.eventSource.current();return(_==null?void 0:_.readyState)===EventSource.OPEN}get isClosed(){const _=this.eventSource.current();return(_==null?void 0:_.readyState)!==EventSource.OPEN}get isConnecting(){const _=this.eventSource.current();return(_==null?void 0:_.readyState)===EventSource.CONNECTING}registerSession(_){return __awaiter(this,void 0,void 0,function*(){yield this.eventSource.create(_==null?void 0:_.signal,_==null?void 0:_.openingDeadlineMS)})}send(_,d,k,j){var $;return __awaiter(this,void 0,void 0,function*(){const et={};typeof j=="number"?et.ttl=j:(et.ttl=j==null?void 0:j.ttl,et.signal=j==null?void 0:j.signal,et.attempts=j==null?void 0:j.attempts);const tt=new URL(addPathToUrl(this.bridgeUrl,this.postPath));tt.searchParams.append("client_id",this.sessionId),tt.searchParams.append("to",d),tt.searchParams.append("ttl",((et==null?void 0:et.ttl)||this.defaultTtl).toString()),tt.searchParams.append("topic",k);const rt=Base64.encode(_);yield callForSuccess(nt=>__awaiter(this,void 0,void 0,function*(){const ot=yield this.post(tt,rt,nt.signal);if(!ot.ok)throw new TonConnectError(`Bridge send failed, status ${ot.status}`)}),{attempts:($=et==null?void 0:et.attempts)!==null&&$!==void 0?$:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:et==null?void 0:et.signal})})}pause(){this.eventSource.dispose().catch(_=>logError$1(`Bridge pause failed, ${_}`))}unPause(){return __awaiter(this,void 0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return __awaiter(this,void 0,void 0,function*(){yield this.eventSource.dispose().catch(_=>logError$1(`Bridge close failed, ${_}`))})}setListener(_){this.listener=_}setErrorsListener(_){this.errorsListener=_}post(_,d,k){return __awaiter(this,void 0,void 0,function*(){const j=yield fetch(_,{method:"post",body:d,signal:k});if(!j.ok)throw new TonConnectError(`Bridge send failed, status ${j.status}`);return j})}errorsHandler(_,d){return __awaiter(this,void 0,void 0,function*(){if(this.isConnecting)throw _.close(),new TonConnectError("Bridge error, failed to connect");if(this.isReady){try{this.errorsListener(d)}catch{}return}if(this.isClosed)return _.close(),logDebug$1(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new TonConnectError("Bridge error, unknown state")})}messagesHandler(_){return __awaiter(this,void 0,void 0,function*(){if(_.data===this.heartbeatMessage||(yield this.bridgeGatewayStorage.storeLastEventId(_.lastEventId),this.isClosed))return;let d;try{d=JSON.parse(_.data)}catch(k){throw new TonConnectError(`Bridge message parse failed, message ${k.data}`)}this.listener(d)})}}function createEventSource(b){return __awaiter(this,void 0,void 0,function*(){return yield timeout((_,d,k)=>__awaiter(this,void 0,void 0,function*(){var j;const et=createAbortController(k.signal).signal;if(et.aborted){d(new TonConnectError("Bridge connection aborted"));return}const tt=new URL(addPathToUrl(b.bridgeUrl,b.ssePath));tt.searchParams.append("client_id",b.sessionId);const rt=yield b.bridgeGatewayStorage.getLastEventId();if(rt&&tt.searchParams.append("last_event_id",rt),et.aborted){d(new TonConnectError("Bridge connection aborted"));return}const nt=new EventSource(tt.toString());nt.onerror=ot=>__awaiter(this,void 0,void 0,function*(){if(et.aborted){nt.close(),d(new TonConnectError("Bridge connection aborted"));return}try{const at=yield b.errorHandler(nt,ot);at!==nt&&nt.close(),at&&at!==nt&&_(at)}catch(at){nt.close(),d(at)}}),nt.onopen=()=>{if(et.aborted){nt.close(),d(new TonConnectError("Bridge connection aborted"));return}_(nt)},nt.onmessage=ot=>{if(et.aborted){nt.close(),d(new TonConnectError("Bridge connection aborted"));return}b.messageHandler(ot)},(j=b.signal)===null||j===void 0||j.addEventListener("abort",()=>{nt.close(),d(new TonConnectError("Bridge connection aborted"))})}),{timeout:b.openingDeadlineMS,signal:b.signal})})}function isPendingConnectionHttp(b){return!("connectEvent"in b)}class BridgeConnectionStorage{constructor(_){this.storage=_,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(_){return __awaiter(this,void 0,void 0,function*(){if(_.type==="injected")return this.storage.setItem(this.storeKey,JSON.stringify(_));if(!isPendingConnectionHttp(_)){const k={sessionKeyPair:_.session.sessionCrypto.stringifyKeypair(),walletPublicKey:_.session.walletPublicKey,bridgeUrl:_.session.bridgeUrl},j={type:"http",connectEvent:_.connectEvent,session:k,lastWalletEventId:_.lastWalletEventId,nextRpcRequestId:_.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(j))}const d={type:"http",connectionSource:_.connectionSource,sessionCrypto:_.sessionCrypto.stringifyKeypair()};return this.storage.setItem(this.storeKey,JSON.stringify(d))})}removeConnection(){return __awaiter(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.storage.getItem(this.storeKey);if(!_)return null;const d=JSON.parse(_);if(d.type==="injected")return d;if("connectEvent"in d){const k=new SessionCrypto(d.session.sessionKeyPair);return{type:"http",connectEvent:d.connectEvent,lastWalletEventId:d.lastWalletEventId,nextRpcRequestId:d.nextRpcRequestId,session:{sessionCrypto:k,bridgeUrl:d.session.bridgeUrl,walletPublicKey:d.session.walletPublicKey}}}return{type:"http",sessionCrypto:new SessionCrypto(d.sessionCrypto),connectionSource:d.connectionSource}})}getHttpConnection(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(!_)throw new TonConnectError("Trying to read HTTP connection source while nothing is stored");if(_.type==="injected")throw new TonConnectError("Trying to read HTTP connection source while injected connection is stored");return _})}getHttpPendingConnection(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(!_)throw new TonConnectError("Trying to read HTTP connection source while nothing is stored");if(_.type==="injected")throw new TonConnectError("Trying to read HTTP connection source while injected connection is stored");if(!isPendingConnectionHttp(_))throw new TonConnectError("Trying to read HTTP-pending connection while http connection is stored");return _})}getInjectedConnection(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(!_)throw new TonConnectError("Trying to read Injected bridge connection source while nothing is stored");if((_==null?void 0:_.type)==="http")throw new TonConnectError("Trying to read Injected bridge connection source while HTTP connection is stored");return _})}storedConnectionType(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.storage.getItem(this.storeKey);return _?JSON.parse(_).type:null})}storeLastWalletEventId(_){return __awaiter(this,void 0,void 0,function*(){const d=yield this.getConnection();if(d&&d.type==="http"&&!isPendingConnectionHttp(d))return d.lastWalletEventId=_,this.storeConnection(d)})}getLastWalletEventId(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(_&&"lastWalletEventId"in _)return _.lastWalletEventId})}increaseNextRpcRequestId(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(_&&"nextRpcRequestId"in _){const d=_.nextRpcRequestId||0;return _.nextRpcRequestId=d+1,this.storeConnection(_)}})}getNextRpcRequestId(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();return _&&"nextRpcRequestId"in _&&_.nextRpcRequestId||0})}}const PROTOCOL_VERSION=2;class BridgeProvider{constructor(_,d){this.storage=_,this.walletConnectionSource=d,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.connectionStorage=new BridgeConnectionStorage(_)}static fromStorage(_){return __awaiter(this,void 0,void 0,function*(){const k=yield new BridgeConnectionStorage(_).getHttpConnection();return isPendingConnectionHttp(k)?new BridgeProvider(_,k.connectionSource):new BridgeProvider(_,{bridgeUrl:k.session.bridgeUrl})})}connect(_,d){var k;const j=createAbortController(d==null?void 0:d.signal);(k=this.abortController)===null||k===void 0||k.abort(),this.abortController=j,this.closeGateways();const $=new SessionCrypto;this.session={sessionCrypto:$,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:$}).then(()=>__awaiter(this,void 0,void 0,function*(){j.signal.aborted||(yield callForSuccess(tt=>{var rt;return this.openGateways($,{openingDeadlineMS:(rt=d==null?void 0:d.openingDeadlineMS)!==null&&rt!==void 0?rt:this.defaultOpeningDeadlineMS,signal:tt==null?void 0:tt.signal})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:j.signal}))}));const et="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(et,_)}restoreConnection(_){var d,k;return __awaiter(this,void 0,void 0,function*(){const j=createAbortController(_==null?void 0:_.signal);if((d=this.abortController)===null||d===void 0||d.abort(),this.abortController=j,j.signal.aborted)return;this.closeGateways();const $=yield this.connectionStorage.getHttpConnection();if(!$||j.signal.aborted)return;const et=(k=_==null?void 0:_.openingDeadlineMS)!==null&&k!==void 0?k:this.defaultOpeningDeadlineMS;if(isPendingConnectionHttp($))return this.session={sessionCrypto:$.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways($.sessionCrypto,{openingDeadlineMS:et,signal:j==null?void 0:j.signal});if(Array.isArray(this.walletConnectionSource))throw new TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=$.session,this.gateway&&(logDebug$1("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,$.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),!j.signal.aborted){this.listeners.forEach(tt=>tt($.connectEvent));try{yield callForSuccess(tt=>this.gateway.registerSession({openingDeadlineMS:et,signal:tt.signal}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:j.signal})}catch{yield this.disconnect({signal:j.signal});return}}})}sendRequest(_,d){const k={};return typeof d=="function"?k.onRequestSent=d:(k.onRequestSent=d==null?void 0:d.onRequestSent,k.signal=d==null?void 0:d.signal,k.attempts=d==null?void 0:d.attempts),new Promise((j,$)=>__awaiter(this,void 0,void 0,function*(){var et;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new TonConnectError("Trying to send bridge request without session");const tt=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),logDebug$1("Send http-bridge request:",Object.assign(Object.assign({},_),{id:tt}));const rt=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},_),{id:tt})),hexToByteArray(this.session.walletPublicKey));try{yield this.gateway.send(rt,this.session.walletPublicKey,_.method,{attempts:k==null?void 0:k.attempts,signal:k==null?void 0:k.signal}),(et=k==null?void 0:k.onRequestSent)===null||et===void 0||et.call(k),this.pendingRequests.set(tt.toString(),j)}catch(nt){$(nt)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(_){return __awaiter(this,void 0,void 0,function*(){return new Promise(d=>__awaiter(this,void 0,void 0,function*(){let k=!1,j=null;const $=()=>{k||(k=!0,this.removeBridgeAndSession().then(d))};try{this.closeGateways();const et=createAbortController(_==null?void 0:_.signal);j=setTimeout(()=>{et.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:$,signal:et.signal,attempts:1})}catch(et){logDebug$1("Disconnect error:",et),k||this.removeBridgeAndSession().then(d)}finally{j&&clearTimeout(j),$()}}))})}listen(_){return this.listeners.push(_),()=>this.listeners=this.listeners.filter(d=>d!==_)}pause(){var _;(_=this.gateway)===null||_===void 0||_.pause(),this.pendingGateways.forEach(d=>d.pause())}unPause(){return __awaiter(this,void 0,void 0,function*(){const _=this.pendingGateways.map(d=>d.unPause());this.gateway&&_.push(this.gateway.unPause()),yield Promise.all(_)})}pendingGatewaysListener(_,d,k){return __awaiter(this,void 0,void 0,function*(){if(!this.pendingGateways.includes(_)){yield _.close();return}return this.closeGateways({except:_}),this.gateway&&(logDebug$1("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=d,this.gateway=_,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(k)})}gatewayListener(_){return __awaiter(this,void 0,void 0,function*(){const d=JSON.parse(this.session.sessionCrypto.decrypt(Base64.decode(_.message).toUint8Array(),hexToByteArray(_.from)));if(logDebug$1("Wallet message received:",d),!("event"in d)){const j=d.id.toString(),$=this.pendingRequests.get(j);if(!$){logDebug$1(`Response id ${j} doesn't match any request's id`);return}$(d),this.pendingRequests.delete(j);return}if(d.id!==void 0){const j=yield this.connectionStorage.getLastWalletEventId();if(j!==void 0&&d.id<=j){logError$1(`Received event id (=${d.id}) must be greater than stored last wallet event id (=${j}) `);return}d.event!=="connect"&&(yield this.connectionStorage.storeLastWalletEventId(d.id))}const k=this.listeners;d.event==="connect"&&(yield this.updateSession(d,_.from)),d.event==="disconnect"&&(logDebug$1("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),k.forEach(j=>j(d))})}gatewayErrorsListener(_){return __awaiter(this,void 0,void 0,function*(){throw new TonConnectError(`Bridge error ${JSON.stringify(_)}`)})}updateSession(_,d){return __awaiter(this,void 0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:d});const k=_.payload.items.find($=>$.name==="ton_addr"),j=Object.assign(Object.assign({},_),{payload:Object.assign(Object.assign({},_.payload),{items:[k]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:_.id,connectEvent:j,nextRpcRequestId:0})})}removeBridgeAndSession(){return __awaiter(this,void 0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(_,d){return isTelegramUrl(_)?this.generateTGUniversalLink(_,d):this.generateRegularUniversalLink(_,d)}generateRegularUniversalLink(_,d){const k=new URL(_);return k.searchParams.append("v",PROTOCOL_VERSION.toString()),k.searchParams.append("id",this.session.sessionCrypto.sessionId),k.searchParams.append("r",JSON.stringify(d)),k.toString()}generateTGUniversalLink(_,d){const j=this.generateRegularUniversalLink("about:blank",d).split("?")[1],$="tonconnect-"+encodeTelegramUrlParameters(j),et=this.convertToDirectLink(_),tt=new URL(et);return tt.searchParams.append("startapp",$),tt.toString()}convertToDirectLink(_){const d=new URL(_);return d.searchParams.has("attach")&&(d.searchParams.delete("attach"),d.pathname+="/start"),d.toString()}openGateways(_,d){return __awaiter(this,void 0,void 0,function*(){if(Array.isArray(this.walletConnectionSource)){this.pendingGateways.map(k=>k.close().catch()),this.pendingGateways=this.walletConnectionSource.map(k=>{const j=new BridgeGateway(this.storage,k.bridgeUrl,_.sessionId,()=>{},()=>{});return j.setListener($=>this.pendingGatewaysListener(j,k.bridgeUrl,$)),j}),yield Promise.allSettled(this.pendingGateways.map(k=>callForSuccess(j=>{var $;return this.pendingGateways.some(et=>et===k)?k.registerSession({openingDeadlineMS:($=d==null?void 0:d.openingDeadlineMS)!==null&&$!==void 0?$:this.defaultOpeningDeadlineMS,signal:j.signal}):k.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:d==null?void 0:d.signal})));return}else return this.gateway&&(logDebug$1("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,_.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.gateway.registerSession({openingDeadlineMS:d==null?void 0:d.openingDeadlineMS,signal:d==null?void 0:d.signal})})}closeGateways(_){var d;(d=this.gateway)===null||d===void 0||d.close(),this.pendingGateways.filter(k=>k!==(_==null?void 0:_.except)).forEach(k=>k.close()),this.pendingGateways=[]}}function hasProperty(b,_){return hasProperties(b,[_])}function hasProperties(b,_){return!b||typeof b!="object"?!1:_.every(d=>d in b)}function isJSBridgeWithMetadata(b){try{return!hasProperty(b,"tonconnect")||!hasProperty(b.tonconnect,"walletInfo")?!1:hasProperties(b.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch{return!1}}let InMemoryStorage$1=class Xo{constructor(){this.storage={}}static getInstance(){return Xo.instance||(Xo.instance=new Xo),Xo.instance}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(_){var d;return(d=this.storage[_])!==null&&d!==void 0?d:null}key(_){var d;const k=Object.keys(this.storage);return _<0||_>=k.length?null:(d=k[_])!==null&&d!==void 0?d:null}removeItem(_){delete this.storage[_]}setItem(_,d){this.storage[_]=d}};function getWindow$2(){if(!(typeof window>"u"))return window}function tryGetWindowKeys(){const b=getWindow$2();if(!b)return[];try{return Object.keys(b)}catch{return[]}}function getDocument(){if(!(typeof document>"u"))return document}function getWebPageManifest(){var b;const _=(b=getWindow$2())===null||b===void 0?void 0:b.location.origin;return _?_+"/tonconnect-manifest.json":""}function tryGetLocalStorage$1(){if(isLocalStorageAvailable$1())return localStorage;if(isNodeJs$1())throw new TonConnectError("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return InMemoryStorage$1.getInstance()}function isLocalStorageAvailable$1(){try{return typeof localStorage<"u"}catch{return!1}}function isNodeJs$1(){return typeof process<"u"&&process.versions!=null&&process.versions.node!=null}class InjectedProvider{constructor(_,d){this.injectedWalletKey=d,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const k=InjectedProvider.window;if(!InjectedProvider.isWindowContainsWallet(k,d))throw new WalletNotInjectedError;this.connectionStorage=new BridgeConnectionStorage(_),this.injectedWallet=k[d].tonconnect}static fromStorage(_){return __awaiter(this,void 0,void 0,function*(){const k=yield new BridgeConnectionStorage(_).getInjectedConnection();return new InjectedProvider(_,k.jsBridgeKey)})}static isWalletInjected(_){return InjectedProvider.isWindowContainsWallet(this.window,_)}static isInsideWalletBrowser(_){return InjectedProvider.isWindowContainsWallet(this.window,_)?this.window[_].tonconnect.isWalletBrowser:!1}static getCurrentlyInjectedWallets(){return this.window?tryGetWindowKeys().filter(k=>isJSBridgeWithMetadata(k)).map(([k,j])=>({name:j.tonconnect.walletInfo.name,appName:j.tonconnect.walletInfo.app_name,aboutUrl:j.tonconnect.walletInfo.about_url,imageUrl:j.tonconnect.walletInfo.image,tondns:j.tonconnect.walletInfo.tondns,jsBridgeKey:k,injected:!0,embedded:j.tonconnect.isWalletBrowser,platforms:j.tonconnect.walletInfo.platforms})):[]}static isWindowContainsWallet(_,d){return!!_&&d in _&&typeof _[d]=="object"&&"tonconnect"in _[d]}connect(_){this._connect(PROTOCOL_VERSION,_)}restoreConnection(){return __awaiter(this,void 0,void 0,function*(){try{logDebug$1("Injected Provider restoring connection...");const _=yield this.injectedWallet.restoreConnection();logDebug$1("Injected Provider restoring connection response",_),_.event==="connect"?(this.makeSubscriptions(),this.listeners.forEach(d=>d(_))):yield this.connectionStorage.removeConnection()}catch(_){yield this.connectionStorage.removeConnection(),console.error(_)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return __awaiter(this,void 0,void 0,function*(){return new Promise(_=>{const d=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(_)};try{this.injectedWallet.disconnect(),d()}catch(k){logDebug$1(k),this.sendRequest({method:"disconnect",params:[]},d)}})})}closeAllListeners(){var _;this.listenSubscriptions=!1,this.listeners=[],(_=this.unsubscribeCallback)===null||_===void 0||_.call(this)}listen(_){return this.listeners.push(_),()=>this.listeners=this.listeners.filter(d=>d!==_)}sendRequest(_,d){var k;return __awaiter(this,void 0,void 0,function*(){const j={};typeof d=="function"?j.onRequestSent=d:(j.onRequestSent=d==null?void 0:d.onRequestSent,j.signal=d==null?void 0:d.signal);const $=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),logDebug$1("Send injected-bridge request:",Object.assign(Object.assign({},_),{id:$}));const et=this.injectedWallet.send(Object.assign(Object.assign({},_),{id:$}));return et.then(tt=>logDebug$1("Wallet message received:",tt)),(k=j==null?void 0:j.onRequestSent)===null||k===void 0||k.call(j),et})}_connect(_,d){return __awaiter(this,void 0,void 0,function*(){try{logDebug$1(`Injected Provider connect request: protocolVersion: ${_}, message:`,d);const k=yield this.injectedWallet.connect(_,d);logDebug$1("Injected Provider connect response:",k),k.event==="connect"&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach(j=>j(k))}catch(k){logDebug$1("Injected Provider connect error:",k);const j={event:"connect_error",payload:{code:0,message:k==null?void 0:k.toString()}};this.listeners.forEach($=>$(j))}})}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen(_=>{logDebug$1("Wallet message received:",_),this.listenSubscriptions&&this.listeners.forEach(d=>d(_)),_.event==="disconnect"&&this.disconnect()})}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}InjectedProvider.window=getWindow$2();class DefaultStorage{constructor(){this.localStorage=tryGetLocalStorage$1()}getItem(_){return __awaiter(this,void 0,void 0,function*(){return this.localStorage.getItem(_)})}removeItem(_){return __awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(_)})}setItem(_,d){return __awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(_,d)})}}function isWalletInfoCurrentlyInjected(b){return isWalletInfoInjectable(b)&&b.injected}function isWalletInfoCurrentlyEmbedded(b){return isWalletInfoCurrentlyInjected(b)&&b.embedded}function isWalletInfoInjectable(b){return"jsBridgeKey"in b}function isWalletInfoRemote(b){return"bridgeUrl"in b}const FALLBACK_WALLETS_LIST=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://walletbot.me/tonconnect-bridge/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_logo_288_mini.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect"},{app_name:"okxMiniWallet",name:"OKX Mini Wallet",image:"https://static.okx.com/cdn/assets/imgs/2411/8BE1A4A434D8F58A.png",about_url:"https://www.okx.com/web3",universal_url:"https://t.me/OKX_WALLET_BOT?attach=wallet",bridge:[{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"binanceWeb3TonWallet",name:"Binance Web3 Wallet",image:"https://public.bnbstatic.com/static/binance-w3w/ton-provider/binancew3w.png",about_url:"https://www.binance.com/en/web3wallet",deepLink:"bnc://app.binance.com/cedefi/ton-connect",bridge:[{type:"js",key:"binancew3w"},{type:"sse",url:"https://wallet.binance.com/tonbridge/bridge"}],platforms:["ios","android","macos","windows","linux"],universal_url:"https://app.binance.com/cedefi/ton-connect"},{app_name:"fintopio-tg",name:"Fintopio",image:"https://fintopio.com/tonconnect-icon.png",about_url:"https://fintopio.com",universal_url:"https://t.me/fintopio?attach=wallet",bridge:[{type:"sse",url:"https://wallet-bridge.fintopio.com/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]},{app_name:"hot",name:"HOT",image:"https://raw.githubusercontent.com/hot-dao/media/main/logo.png",about_url:"https://hot-labs.org/",universal_url:"https://t.me/herewalletbot?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.hot-labs.org"},{type:"js",key:"hotWallet"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"bybitTonWallet",name:"Bybit Wallet",image:"https://raw.githubusercontent.com/bybit-web3/bybit-web3.github.io/main/docs/images/bybit-logo.png",about_url:"https://www.bybit.com/web3",universal_url:"https://app.bybit.com/ton-connect",deepLink:"bybitapp://",bridge:[{type:"js",key:"bybitTonWallet"},{type:"sse",url:"https://api-node.bybit.com/spot/api/web3/bridge/ton/bridge"}],platforms:["ios","android","chrome"]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.dewallet.pro/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"]},{app_name:"GateWallet",name:"GateWallet",image:"https://img.gatedataimg.com/prd-ordinal-imgs/036f07bb8730716e/gateio-0925.png",about_url:"https://www.gate.io/",bridge:[{type:"js",key:"gatetonwallet"},{type:"sse",url:"https://dapp.gateio.services/tonbridge_api/bridge/v1"}],platforms:["ios","android"],universal_url:"https://gateio.go.link/gateio/web3?adj_t=1ff8khdw_1fu4ccc7"},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"]},{app_name:"BitgetWeb3",name:"BitgetWeb3",image:"https://img.bitgetimg.com/image/third/1731638059795.png",about_url:"​https://www.bitget.com",universal_url:"https://t.me/BitgetOfficialBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","windows","macos","linux"]},{app_name:"tobi",name:"Tobi",image:"https://app.tobiwallet.app/icons/logo-288.png",about_url:"https://tobi.fun",universal_url:"https://t.me/TobiCopilotBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-bridge.tobiwallet.app/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"]}];class WalletsListManager{constructor(_){this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null,this.walletsListSource="https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",_!=null&&_.walletsListSource&&(this.walletsListSource=_.walletsListSource),_!=null&&_.cacheTTLMs&&(this.cacheTTLMs=_.cacheTTLMs)}getWallets(){return __awaiter(this,void 0,void 0,function*(){return this.cacheTTLMs&&this.walletsListCacheCreationTimestamp&&Date.now()>this.walletsListCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListCache=null),this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.then(()=>{this.walletsListCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null})),this.walletsListCache})}getEmbeddedWallet(){return __awaiter(this,void 0,void 0,function*(){const d=(yield this.getWallets()).filter(isWalletInfoCurrentlyEmbedded);return d.length!==1?null:d[0]})}fetchWalletsList(){return __awaiter(this,void 0,void 0,function*(){let _=[];try{if(_=yield(yield fetch(this.walletsListSource)).json(),_.push({app_name:"hpyTonWallet",name:"HyperPay Wallet",image:"https://onchain-oss.hyperpay.online/images/logo.png",about_url:"https://www.hyperpay.tech",universal_url:"https://www.hyperpay.tech/download&deeplink=hyperpay://web3/wallet/tonconnect",bridge:[{type:"js",key:"hpyTonWallet"},{type:"sse",url:"https://onchain-wallet.hyperpay.online/bridge"}],platforms:["ios","android","macos","windows","linux"]}),_.push({app_name:"nicegramWallet",name:"Nicegram Wallet",image:"https://static.nicegram.app/icon.png",about_url:"https://nicegram.app",universal_url:"https://nicegram.app/tc",deepLink:"nicegram-tc://",bridge:[{type:"sse",url:"https://tc.nicegram.app/bridge"},{type:"js",key:"nicegramWallet"}],platforms:["ios","android","macos","windows","linux"]}),_.push({app_name:"foxwallet",name:"FoxWallet",image:"https://hc.foxwallet.com/img/logo.png",about_url:"https://foxwallet.com/",bridge:[{type:"js",key:"foxwallet"}],platforms:["ios","android","macos","windows","linux"]}),_.push({app_name:"trustwalletTon",name:"Trust",image:"https://assets-cdn.trustwallet.com/dapps/trust.logo.png",about_url:"https://trustwallet.com/about-us",deepLink:"trust://ton-connect",universal_url:"https://trustwallet.com",bridge:[{type:"js",key:"trustwalletTon"},{type:"sse",url:"https://tonconnect.trustwallet.com/bridge"}],platforms:["chrome","ios","android"]}),_.push({app_name:"jambo",name:"Jambo",image:"https://cdn-prod.jambotechnology.xyz/content/jambo_288x288_02da416a6c.png",about_url:"https://www.jambo.technology/",deepLink:"jambotc://",universal_url:"https://jambophone.xyz/",bridge:[{type:"js",key:"jambowallet"},{type:"sse",url:"https://bridge.tonapi.io/bridge"}],platforms:["android"]}),_.push({app_name:"tokenpocket",name:"TokenPocket",image:"https://hk.tpstatic.net/logo/tokenpocket.png",about_url:"https://www.tokenpocket.pro",universal_url:"https://tp-lab.tptool.pro/ton-connect/",bridge:[{type:"js",key:"tokenpocket"},{type:"sse",url:"https://ton-connect.mytokenpocket.vip/bridge"}],platforms:["ios","android"]}),!Array.isArray(_))throw new FetchWalletsError("Wrong wallets list format, wallets list must be an array.");const j=_.filter($=>!this.isCorrectWalletConfigDTO($));j.length&&(logError$1(`Wallet(s) ${j.map($=>$.name).join(", ")} config format is wrong. They were removed from the wallets list.`),_=_.filter($=>this.isCorrectWalletConfigDTO($)))}catch(k){logError$1(k),_=FALLBACK_WALLETS_LIST}let d=[];try{d=InjectedProvider.getCurrentlyInjectedWallets()}catch(k){logError$1(k)}return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(_),d)})}walletConfigDTOListToWalletConfigList(_){return _.map(d=>{const j={name:d.name,appName:d.app_name,imageUrl:d.image,aboutUrl:d.about_url,tondns:d.tondns,platforms:d.platforms};return d.bridge.forEach($=>{if($.type==="sse"&&(j.bridgeUrl=$.url,j.universalLink=d.universal_url,j.deepLink=d.deepLink),$.type==="js"){const et=$.key;j.jsBridgeKey=et,j.injected=InjectedProvider.isWalletInjected(et),j.embedded=InjectedProvider.isInsideWalletBrowser(et)}}),j})}mergeWalletsLists(_,d){return[...new Set(_.concat(d).map(j=>j.name)).values()].map(j=>{const $=_.find(tt=>tt.name===j),et=d.find(tt=>tt.name===j);return Object.assign(Object.assign({},$&&Object.assign({},$)),et&&Object.assign({},et))})}isCorrectWalletConfigDTO(_){if(!_||typeof _!="object")return!1;const d="name"in _,k="app_name"in _,j="image"in _,$="about_url"in _,et="platforms"in _;if(!d||!j||!$||!et||!k||!_.platforms||!Array.isArray(_.platforms)||!_.platforms.length||!("bridge"in _)||!Array.isArray(_.bridge)||!_.bridge.length)return!1;const tt=_.bridge;if(tt.some(ot=>!ot||typeof ot!="object"||!("type"in ot)))return!1;const rt=tt.find(ot=>ot.type==="sse");if(rt&&(!("url"in rt)||!rt.url||!_.universal_url))return!1;const nt=tt.find(ot=>ot.type==="js");return!(nt&&(!("key"in nt)||!nt.key))}}class WalletNotSupportFeatureError extends TonConnectError{get info(){return"Wallet doesn't support requested feature method."}constructor(..._){super(..._),Object.setPrototypeOf(this,WalletNotSupportFeatureError.prototype)}}function checkSendTransactionSupport(b,_){const d=b.includes("SendTransaction"),k=b.find(j=>j&&typeof j=="object"&&j.name==="SendTransaction");if(!d&&!k)throw new WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.");if(k&&k.maxMessages!==void 0){if(k.maxMessages<_.requiredMessagesNumber)throw new WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${k.maxMessages}, but ${_.requiredMessagesNumber} is required.`);return}logWarning$1("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.")}function createRequestVersionEvent(){return{type:"request-version"}}function createResponseVersionEvent(b){return{type:"response-version",version:b}}function createVersionInfo(b){return{ton_connect_sdk_lib:b.ton_connect_sdk_lib,ton_connect_ui_lib:b.ton_connect_ui_lib}}function createConnectionInfo(b,_){var d,k,j,$,et,tt,rt,nt;const at=((d=_==null?void 0:_.connectItems)===null||d===void 0?void 0:d.tonProof)&&"proof"in _.connectItems.tonProof?"ton_proof":"ton_addr";return{wallet_address:(j=(k=_==null?void 0:_.account)===null||k===void 0?void 0:k.address)!==null&&j!==void 0?j:null,wallet_type:($=_==null?void 0:_.device.appName)!==null&&$!==void 0?$:null,wallet_version:(et=_==null?void 0:_.device.appVersion)!==null&&et!==void 0?et:null,auth_type:at,custom_data:Object.assign({chain_id:(rt=(tt=_==null?void 0:_.account)===null||tt===void 0?void 0:tt.chain)!==null&&rt!==void 0?rt:null,provider:(nt=_==null?void 0:_.provider)!==null&&nt!==void 0?nt:null},createVersionInfo(b))}}function createConnectionStartedEvent(b){return{type:"connection-started",custom_data:createVersionInfo(b)}}function createConnectionCompletedEvent(b,_){return Object.assign({type:"connection-completed",is_success:!0},createConnectionInfo(b,_))}function createConnectionErrorEvent(b,_,d){return{type:"connection-error",is_success:!1,error_message:_,error_code:d??null,custom_data:createVersionInfo(b)}}function createConnectionRestoringStartedEvent(b){return{type:"connection-restoring-started",custom_data:createVersionInfo(b)}}function createConnectionRestoringCompletedEvent(b,_){return Object.assign({type:"connection-restoring-completed",is_success:!0},createConnectionInfo(b,_))}function createConnectionRestoringErrorEvent(b,_){return{type:"connection-restoring-error",is_success:!1,error_message:_,custom_data:createVersionInfo(b)}}function createTransactionInfo(b,_){var d,k,j,$;return{valid_until:(d=String(_.validUntil))!==null&&d!==void 0?d:null,from:($=(k=_.from)!==null&&k!==void 0?k:(j=b==null?void 0:b.account)===null||j===void 0?void 0:j.address)!==null&&$!==void 0?$:null,messages:_.messages.map(et=>{var tt,rt;return{address:(tt=et.address)!==null&&tt!==void 0?tt:null,amount:(rt=et.amount)!==null&&rt!==void 0?rt:null}})}}function createTransactionSentForSignatureEvent(b,_,d){return Object.assign(Object.assign({type:"transaction-sent-for-signature"},createConnectionInfo(b,_)),createTransactionInfo(_,d))}function createTransactionSignedEvent(b,_,d,k){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:k.boc},createConnectionInfo(b,_)),createTransactionInfo(_,d))}function createTransactionSigningFailedEvent(b,_,d,k,j){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:k,error_code:j??null},createConnectionInfo(b,_)),createTransactionInfo(_,d))}function createDisconnectionEvent(b,_,d){return Object.assign({type:"disconnection",scope:d},createConnectionInfo(b,_))}class BrowserEventDispatcher{constructor(){this.window=getWindow$2()}dispatchEvent(_,d){var k;return __awaiter(this,void 0,void 0,function*(){const j=new CustomEvent(_,{detail:d});(k=this.window)===null||k===void 0||k.dispatchEvent(j)})}addEventListener(_,d,k){var j;return __awaiter(this,void 0,void 0,function*(){return(j=this.window)===null||j===void 0||j.addEventListener(_,d,k),()=>{var $;return($=this.window)===null||$===void 0?void 0:$.removeEventListener(_,d)}})}}class TonConnectTracker{constructor(_){var d;this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=(d=_==null?void 0:_.eventDispatcher)!==null&&d!==void 0?d:new BrowserEventDispatcher,this.tonConnectSdkVersion=_.tonConnectSdkVersion,this.init().catch()}get version(){return createVersionInfo({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return __awaiter(this,void 0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch{}})}setRequestVersionHandler(){return __awaiter(this,void 0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>__awaiter(this,void 0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",createResponseVersionEvent(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return __awaiter(this,void 0,void 0,function*(){return new Promise((_,d)=>__awaiter(this,void 0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",k=>{_(k.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",createRequestVersionEvent())}catch(k){d(k)}}))})}dispatchUserActionEvent(_){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${_.type}`,_).catch()}catch{}}trackConnectionStarted(..._){try{const d=createConnectionStartedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionCompleted(..._){try{const d=createConnectionCompletedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionError(..._){try{const d=createConnectionErrorEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionRestoringStarted(..._){try{const d=createConnectionRestoringStartedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionRestoringCompleted(..._){try{const d=createConnectionRestoringCompletedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionRestoringError(..._){try{const d=createConnectionRestoringErrorEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackDisconnection(..._){try{const d=createDisconnectionEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackTransactionSentForSignature(..._){try{const d=createTransactionSentForSignatureEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackTransactionSigned(..._){try{const d=createTransactionSignedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackTransactionSigningFailed(..._){try{const d=createTransactionSigningFailedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}}const tonConnectSdkVersion="3.0.6-beta.0";class TonConnect{constructor(_){if(this.walletsList=new WalletsListManager,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(_==null?void 0:_.manifestUrl)||getWebPageManifest(),storage:(_==null?void 0:_.storage)||new DefaultStorage},this.walletsList=new WalletsListManager({walletsListSource:_==null?void 0:_.walletsListSource,cacheTTLMs:_==null?void 0:_.walletsListCacheTTLMs}),this.tracker=new TonConnectTracker({eventDispatcher:_==null?void 0:_.eventDispatcher,tonConnectSdkVersion}),!this.dappSettings.manifestUrl)throw new DappMetadataError("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest");this.bridgeConnectionStorage=new BridgeConnectionStorage(this.dappSettings.storage),_!=null&&_.disableAutoPauseConnection||this.addWindowFocusAndBlurSubscriptions()}static getWallets(){return this.walletsList.getWallets()}get connected(){return this._wallet!==null}get account(){var _;return((_=this._wallet)===null||_===void 0?void 0:_.account)||null}get wallet(){return this._wallet}set wallet(_){this._wallet=_,this.statusChangeSubscriptions.forEach(d=>d(this._wallet))}getWallets(){return this.walletsList.getWallets()}onStatusChange(_,d){return this.statusChangeSubscriptions.push(_),d&&this.statusChangeErrorSubscriptions.push(d),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(k=>k!==_),d&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(k=>k!==d))}}connect(_,d){var k,j;const $={};if(typeof d=="object"&&"tonProof"in d&&($.request=d),typeof d=="object"&&("openingDeadlineMS"in d||"signal"in d||"request"in d)&&($.request=d==null?void 0:d.request,$.openingDeadlineMS=d==null?void 0:d.openingDeadlineMS,$.signal=d==null?void 0:d.signal),this.connected)throw new WalletAlreadyConnectedError;const et=createAbortController($==null?void 0:$.signal);if((k=this.abortController)===null||k===void 0||k.abort(),this.abortController=et,et.signal.aborted)throw new TonConnectError("Connection was aborted");return(j=this.provider)===null||j===void 0||j.closeConnection(),this.provider=this.createProvider(_),et.signal.addEventListener("abort",()=>{var tt;(tt=this.provider)===null||tt===void 0||tt.closeConnection(),this.provider=null}),this.tracker.trackConnectionStarted(),this.provider.connect(this.createConnectRequest($==null?void 0:$.request),{openingDeadlineMS:$==null?void 0:$.openingDeadlineMS,signal:et.signal})}restoreConnection(_){var d,k;return __awaiter(this,void 0,void 0,function*(){this.tracker.trackConnectionRestoringStarted();const j=createAbortController(_==null?void 0:_.signal);if((d=this.abortController)===null||d===void 0||d.abort(),this.abortController=j,j.signal.aborted){this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}const[$,et]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(j.signal.aborted){this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}let tt=null;try{switch($){case"http":tt=yield BridgeProvider.fromStorage(this.dappSettings.storage);break;case"injected":tt=yield InjectedProvider.fromStorage(this.dappSettings.storage);break;default:if(et)tt=this.createProvider(et);else return}}catch{this.tracker.trackConnectionRestoringError("Provider is not restored"),yield this.bridgeConnectionStorage.removeConnection(),tt==null||tt.closeConnection(),tt=null;return}if(j.signal.aborted){tt==null||tt.closeConnection(),this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}if(!tt){logError$1("Provider is not restored"),this.tracker.trackConnectionRestoringError("Provider is not restored");return}(k=this.provider)===null||k===void 0||k.closeConnection(),this.provider=tt,tt.listen(this.walletEventsListener.bind(this));const rt=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted"),tt==null||tt.closeConnection(),tt=null};j.signal.addEventListener("abort",rt);const nt=callForSuccess(at=>__awaiter(this,void 0,void 0,function*(){yield tt==null?void 0:tt.restoreConnection({openingDeadlineMS:_==null?void 0:_.openingDeadlineMS,signal:at.signal}),j.signal.removeEventListener("abort",rt),this.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):this.tracker.trackConnectionRestoringError("Connection restoring failed")}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:_==null?void 0:_.signal}),ot=new Promise(at=>setTimeout(()=>at(),12e3));return Promise.race([nt,ot])})}sendTransaction(_,d){return __awaiter(this,void 0,void 0,function*(){const k={};typeof d=="function"?k.onRequestSent=d:(k.onRequestSent=d==null?void 0:d.onRequestSent,k.signal=d==null?void 0:d.signal);const j=createAbortController(k==null?void 0:k.signal);if(j.signal.aborted)throw new TonConnectError("Transaction sending was aborted");this.checkConnection(),checkSendTransactionSupport(this.wallet.device.features,{requiredMessagesNumber:_.messages.length}),this.tracker.trackTransactionSentForSignature(this.wallet,_);const{validUntil:$}=_,et=__rest(_,["validUntil"]),tt=_.from||this.account.address,rt=_.network||this.account.chain,nt=yield this.provider.sendRequest(sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},et),{valid_until:$,from:tt,network:rt})),{onRequestSent:k.onRequestSent,signal:j.signal});if(sendTransactionParser.isError(nt))return this.tracker.trackTransactionSigningFailed(this.wallet,_,nt.error.message,nt.error.code),sendTransactionParser.parseAndThrowError(nt);const ot=sendTransactionParser.convertFromRpcResponse(nt);return this.tracker.trackTransactionSigned(this.wallet,_,ot),ot})}disconnect(_){var d;return __awaiter(this,void 0,void 0,function*(){if(!this.connected)throw new WalletNotConnectedError;const k=createAbortController(_==null?void 0:_.signal),j=this.abortController;if(this.abortController=k,k.signal.aborted)throw new TonConnectError("Disconnect was aborted");this.onWalletDisconnected("dapp"),yield(d=this.provider)===null||d===void 0?void 0:d.disconnect({signal:k.signal}),j==null||j.abort()})}pauseConnection(){var _;((_=this.provider)===null||_===void 0?void 0:_.type)==="http"&&this.provider.pause()}unPauseConnection(){var _;return((_=this.provider)===null||_===void 0?void 0:_.type)!=="http"?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const _=getDocument();if(_)try{_.addEventListener("visibilitychange",()=>{_.hidden?this.pauseConnection():this.unPauseConnection().catch()})}catch(d){logError$1("Cannot subscribe to the document.visibilitychange: ",d)}}createProvider(_){let d;return!Array.isArray(_)&&isWalletConnectionSourceJS(_)?d=new InjectedProvider(this.dappSettings.storage,_.jsBridgeKey):d=new BridgeProvider(this.dappSettings.storage,_),d.listen(this.walletEventsListener.bind(this)),d}walletEventsListener(_){switch(_.event){case"connect":this.onWalletConnected(_.payload);break;case"connect_error":this.onWalletConnectError(_.payload);break;case"disconnect":this.onWalletDisconnected("wallet")}}onWalletConnected(_){const d=_.items.find($=>$.name==="ton_addr"),k=_.items.find($=>$.name==="ton_proof");if(!d)throw new TonConnectError("ton_addr connection item was not found");const j={device:_.device,provider:this.provider.type,account:{address:d.address,chain:d.network,walletStateInit:d.walletStateInit,publicKey:d.publicKey}};k&&(j.connectItems={tonProof:k}),this.wallet=j,this.tracker.trackConnectionCompleted(j)}onWalletConnectError(_){const d=connectErrorsParser.parseError(_);if(this.statusChangeErrorSubscriptions.forEach(k=>k(d)),logDebug$1(d),this.tracker.trackConnectionError(_.message,_.code),d instanceof ManifestNotFoundError||d instanceof ManifestContentErrorError)throw logError$1(d),d}onWalletDisconnected(_){this.tracker.trackDisconnection(this.wallet,_),this.wallet=null}checkConnection(){if(!this.connected)throw new WalletNotConnectedError}createConnectRequest(_){const d=[{name:"ton_addr"}];return _!=null&&_.tonProof&&d.push({name:"ton_proof",payload:_.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:d}}}TonConnect.walletsList=new WalletsListManager;TonConnect.isWalletInjected=b=>InjectedProvider.isWalletInjected(b);TonConnect.isInsideWalletBrowser=b=>InjectedProvider.isInsideWalletBrowser(b);const noBounceableTag=81,testOnlyTag=128;function toUserFriendlyAddress(b,_=!1){const{wc:d,hex:k}=parseHexAddress(b);let j=noBounceableTag;_&&(j|=testOnlyTag);const $=new Int8Array(34);$[0]=j,$[1]=d,$.set(k,2);const et=new Uint8Array(36);return et.set($),et.set(crc16($),34),Base64.encode(et).replace(/\+/g,"-").replace(/\//g,"_")}function parseHexAddress(b){if(!b.includes(":"))throw new WrongAddressError(`Wrong address ${b}. Address must include ":".`);const _=b.split(":");if(_.length!==2)throw new WrongAddressError(`Wrong address ${b}. Address must include ":" only once.`);const d=parseInt(_[0]);if(d!==0&&d!==-1)throw new WrongAddressError(`Wrong address ${b}. WC must be eq 0 or -1, but ${d} received.`);const k=_[1];if((k==null?void 0:k.length)!==64)throw new WrongAddressError(`Wrong address ${b}. Hex part must be 64bytes length, but ${k==null?void 0:k.length} received.`);return{wc:d,hex:hexToBytes(k)}}function crc16(b){let d=0;const k=new Uint8Array(b.length+2);k.set(b);for(let j of k){let $=128;for(;$>0;)d<<=1,j&$&&(d+=1),$>>=1,d>65535&&(d&=65535,d^=4129)}return new Uint8Array([Math.floor(d/256),d%256])}const toByteMap={};for(let b=0;b<=255;b++){let _=b.toString(16);_.length<2&&(_="0"+_),toByteMap[_]=b}function hexToBytes(b){b=b.toLowerCase();const _=b.length;if(_%2!==0)throw new ParseHexError("Hex string must have length a multiple of 2: "+b);const d=_/2,k=new Uint8Array(d);for(let j=0;j0?ln.length===2?typeof ln[1]==tt?this[ln[0]]=ln[1].call(this,Qn):this[ln[0]]=ln[1]:ln.length===3?typeof ln[1]===tt&&!(ln[1].exec&&ln[1].test)?this[ln[0]]=Qn?ln[1].call(this,Qn,ln[2]):k:this[ln[0]]=Qn?Qn.replace(ln[1],ln[2]):k:ln.length===4&&(this[ln[0]]=Qn?ln[3].call(this,Qn.replace(ln[1],ln[2])):k):this[ln]=Qn||k;pt+=2}},Sn=function(Kt,bt){for(var pt in bt)if(typeof bt[pt]===nt&&bt[pt].length>0){for(var yt=0;yt2&&(mn[it]="iPad",mn[ut]=st),mn},this.getEngine=function(){var mn={};return mn[dt]=k,mn[ft]=k,Un.call(mn,yt,sn.engine),mn},this.getOS=function(){var mn={};return mn[dt]=k,mn[ft]=k,Un.call(mn,yt,sn.os),ln&&!mn[dt]&&Ut&&Ut.platform&&Ut.platform!="Unknown"&&(mn[dt]=Ut.platform.replace(/chrome os/i,An).replace(/macos/i,yn)),mn},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return yt},this.setUA=function(mn){return yt=typeof mn===ot&&mn.length>Mt?Dn(mn,Mt):mn,this},this.setUA(yt),this};Fn.VERSION=j,Fn.BROWSER=vn([dt,ft,at]),Fn.CPU=vn([lt]),Fn.DEVICE=vn([it,ht,ut,ct,gt,_t,st,xt,wt]),Fn.ENGINE=Fn.OS=vn([dt,ft]),b.exports&&(_=b.exports=Fn),_.UAParser=Fn;var zn=typeof d!==rt&&(d.jQuery||d.Zepto);if(zn&&!zn.ua){var Tn=new Fn;zn.ua=Tn.getResult(),zn.ua.get=function(){return Tn.getUA()},zn.ua.set=function(Kt){Tn.setUA(Kt);var bt=Tn.getResult();for(var pt in bt)zn.ua[pt]=bt[pt]}}})(typeof window=="object"?window:commonjsGlobal)})(uaParser,uaParser.exports);var uaParserExports=uaParser.exports;const UAParser=getDefaultExportFromCjs(uaParserExports);var isMergeableObject=function b(_){return isNonNullObject(_)&&!isSpecial(_)};function isNonNullObject(b){return!!b&&typeof b=="object"}function isSpecial(b){var _=Object.prototype.toString.call(b);return _==="[object RegExp]"||_==="[object Date]"||isReactElement(b)}var canUseSymbol=typeof Symbol=="function"&&Symbol.for,REACT_ELEMENT_TYPE=canUseSymbol?Symbol.for("react.element"):60103;function isReactElement(b){return b.$$typeof===REACT_ELEMENT_TYPE}function emptyTarget(b){return Array.isArray(b)?[]:{}}function cloneUnlessOtherwiseSpecified(b,_){return _.clone!==!1&&_.isMergeableObject(b)?deepmerge(emptyTarget(b),b,_):b}function defaultArrayMerge(b,_,d){return b.concat(_).map(function(k){return cloneUnlessOtherwiseSpecified(k,d)})}function getMergeFunction(b,_){if(!_.customMerge)return deepmerge;var d=_.customMerge(b);return typeof d=="function"?d:deepmerge}function getEnumerableOwnPropertySymbols(b){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(b).filter(function(_){return Object.propertyIsEnumerable.call(b,_)}):[]}function getKeys(b){return Object.keys(b).concat(getEnumerableOwnPropertySymbols(b))}function propertyIsOnObject(b,_){try{return _ in b}catch{return!1}}function propertyIsUnsafe(b,_){return propertyIsOnObject(b,_)&&!(Object.hasOwnProperty.call(b,_)&&Object.propertyIsEnumerable.call(b,_))}function mergeObject(b,_,d){var k={};return d.isMergeableObject(b)&&getKeys(b).forEach(function(j){k[j]=cloneUnlessOtherwiseSpecified(b[j],d)}),getKeys(_).forEach(function(j){propertyIsUnsafe(b,j)||(propertyIsOnObject(b,j)&&d.isMergeableObject(_[j])?k[j]=getMergeFunction(j,d)(b[j],_[j],d):k[j]=cloneUnlessOtherwiseSpecified(_[j],d))}),k}function deepmerge(b,_,d){d=d||{},d.arrayMerge=d.arrayMerge||defaultArrayMerge,d.isMergeableObject=d.isMergeableObject||isMergeableObject,d.cloneUnlessOtherwiseSpecified=cloneUnlessOtherwiseSpecified;var k=Array.isArray(_),j=Array.isArray(b),$=k===j;return $?k?d.arrayMerge(b,_,d):mergeObject(b,_,d):cloneUnlessOtherwiseSpecified(_,d)}deepmerge.all=function b(_,d){if(!Array.isArray(_))throw new Error("first argument should be an array");return _.reduce(function(k,j){return deepmerge(k,j,d)},{})};var deepmerge_1=deepmerge,cjs=deepmerge_1;const deepmerge$1=getDefaultExportFromCjs(cjs);var classnames={exports:{}};/*! +`+_:""}`,Object.setPrototypeOf(this,TonConnectError.prototype)}get info(){return""}}TonConnectError.prefix="[TON_CONNECT_SDK_ERROR]";class DappMetadataError extends TonConnectError{get info(){return"Passed DappMetadata is in incorrect format."}constructor(..._){super(..._),Object.setPrototypeOf(this,DappMetadataError.prototype)}}class ManifestContentErrorError extends TonConnectError{get info(){return"Passed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(..._){super(..._),Object.setPrototypeOf(this,ManifestContentErrorError.prototype)}}class ManifestNotFoundError extends TonConnectError{get info(){return"Manifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest"}constructor(..._){super(..._),Object.setPrototypeOf(this,ManifestNotFoundError.prototype)}}class WalletAlreadyConnectedError extends TonConnectError{get info(){return"Wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection."}constructor(..._){super(..._),Object.setPrototypeOf(this,WalletAlreadyConnectedError.prototype)}}class WalletNotConnectedError extends TonConnectError{get info(){return"Send transaction or other protocol methods called while wallet is not connected."}constructor(..._){super(..._),Object.setPrototypeOf(this,WalletNotConnectedError.prototype)}}function isWalletConnectionSourceJS(b){return"jsBridgeKey"in b}class UserRejectsError extends TonConnectError{get info(){return"User rejects the action in the wallet."}constructor(..._){super(..._),Object.setPrototypeOf(this,UserRejectsError.prototype)}}class BadRequestError extends TonConnectError{get info(){return"Request to the wallet contains errors."}constructor(..._){super(..._),Object.setPrototypeOf(this,BadRequestError.prototype)}}class UnknownAppError extends TonConnectError{get info(){return"App tries to send rpc request to the injected wallet while not connected."}constructor(..._){super(..._),Object.setPrototypeOf(this,UnknownAppError.prototype)}}class WalletNotInjectedError extends TonConnectError{get info(){return"There is an attempt to connect to the injected wallet while it is not exists in the webpage."}constructor(..._){super(..._),Object.setPrototypeOf(this,WalletNotInjectedError.prototype)}}class FetchWalletsError extends TonConnectError{get info(){return"An error occurred while fetching the wallets list."}constructor(..._){super(..._),Object.setPrototypeOf(this,FetchWalletsError.prototype)}}class WrongAddressError extends TonConnectError{get info(){return"Passed address is in incorrect format."}constructor(..._){super(..._),Object.setPrototypeOf(this,WrongAddressError.prototype)}}class ParseHexError extends TonConnectError{get info(){return"Passed hex is in incorrect format."}constructor(..._){super(..._),Object.setPrototypeOf(this,ParseHexError.prototype)}}class UnknownError extends TonConnectError{constructor(..._){super(..._),Object.setPrototypeOf(this,UnknownError.prototype)}}const connectEventErrorsCodes={[CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]:UnknownError,[CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]:UserRejectsError,[CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]:BadRequestError,[CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]:UnknownAppError,[CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]:ManifestNotFoundError,[CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]:ManifestContentErrorError};class ConnectErrorsParser{parseError(_){let d=UnknownError;return _.code in connectEventErrorsCodes&&(d=connectEventErrorsCodes[_.code]||UnknownError),new d(_.message)}}const connectErrorsParser=new ConnectErrorsParser;class RpcParser{isError(_){return"error"in _}}const sendTransactionErrors={[SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]:UnknownError,[SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]:UserRejectsError,[SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]:BadRequestError,[SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]:UnknownAppError};class SendTransactionParser extends RpcParser{convertToRpcRequest(_){return{method:"sendTransaction",params:[JSON.stringify(_)]}}parseAndThrowError(_){let d=UnknownError;throw _.error.code in sendTransactionErrors&&(d=sendTransactionErrors[_.error.code]||UnknownError),new d(_.error.message)}convertFromRpcResponse(_){return{boc:_.result}}}const sendTransactionParser=new SendTransactionParser;class HttpBridgeGatewayStorage{constructor(_,d){this.storage=_,this.storeKey="ton-connect-storage_http-bridge-gateway::"+d}storeLastEventId(_){return __awaiter(this,void 0,void 0,function*(){return this.storage.setItem(this.storeKey,_)})}removeLastEventId(){return __awaiter(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getLastEventId(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.storage.getItem(this.storeKey);return _||null})}}function removeUrlLastSlash(b){return b.slice(-1)==="/"?b.slice(0,-1):b}function addPathToUrl(b,_){return removeUrlLastSlash(b)+"/"+_}function isTelegramUrl(b){if(!b)return!1;const _=new URL(b);return _.protocol==="tg:"||_.hostname==="t.me"}function encodeTelegramUrlParameters(b){return b.replaceAll(".","%2E").replaceAll("-","%2D").replaceAll("_","%5F").replaceAll("&","-").replaceAll("=","__").replaceAll("%","--")}function delay(b,_){return __awaiter(this,void 0,void 0,function*(){return new Promise((d,k)=>{var j,$;if(!((j=_==null?void 0:_.signal)===null||j===void 0)&&j.aborted){k(new TonConnectError("Delay aborted"));return}const et=setTimeout(()=>d(),b);($=_==null?void 0:_.signal)===null||$===void 0||$.addEventListener("abort",()=>{clearTimeout(et),k(new TonConnectError("Delay aborted"))})})})}function createAbortController(b){const _=new AbortController;return b!=null&&b.aborted?_.abort():b==null||b.addEventListener("abort",()=>_.abort(),{once:!0}),_}function callForSuccess(b,_){var d,k;return __awaiter(this,void 0,void 0,function*(){const j=(d=_==null?void 0:_.attempts)!==null&&d!==void 0?d:10,$=(k=_==null?void 0:_.delayMs)!==null&&k!==void 0?k:200,et=createAbortController(_==null?void 0:_.signal);if(typeof b!="function")throw new TonConnectError(`Expected a function, got ${typeof b}`);let tt=0,rt;for(;tt__awaiter(this,void 0,void 0,function*(){if($=at??null,et==null||et.abort(),et=createAbortController(at),et.signal.aborted)throw new TonConnectError("Resource creation was aborted");k=it??null;const dt=b(et.signal,...it);j=dt;const ut=yield dt;if(j!==dt&&ut!==d)throw yield _(ut),new TonConnectError("Resource creation was aborted by a new resource creation");return d=ut,d});return{create:tt,current:()=>d??null,dispose:()=>__awaiter(this,void 0,void 0,function*(){try{const at=d;d=null;const it=j;j=null;try{et==null||et.abort()}catch{}yield Promise.allSettled([at?_(at):Promise.resolve(),it?_(yield it):Promise.resolve()])}catch{}}),recreate:at=>__awaiter(this,void 0,void 0,function*(){const it=d,dt=j,ut=k,ht=$;if(yield delay(at),it===d&&dt===j&&ut===k&&ht===$)return yield tt($,...ut??[]);throw new TonConnectError("Resource recreation was aborted by a new resource creation")})}}function timeout(b,_){const d=_==null?void 0:_.timeout,k=_==null?void 0:_.signal,j=createAbortController(k);return new Promise(($,et)=>__awaiter(this,void 0,void 0,function*(){if(j.signal.aborted){et(new TonConnectError("Operation aborted"));return}let tt;typeof d<"u"&&(tt=setTimeout(()=>{j.abort(),et(new TonConnectError(`Timeout after ${d}ms`))},d)),j.signal.addEventListener("abort",()=>{clearTimeout(tt),et(new TonConnectError("Operation aborted"))},{once:!0});const rt={timeout:d,abort:j.signal};yield b((...nt)=>{clearTimeout(tt),$(...nt)},()=>{clearTimeout(tt),et()},rt)}))}class BridgeGateway{constructor(_,d,k,j,$){this.bridgeUrl=d,this.sessionId=k,this.listener=j,this.errorsListener=$,this.ssePath="events",this.postPath="message",this.heartbeatMessage="heartbeat",this.defaultTtl=300,this.defaultReconnectDelay=2e3,this.defaultResendDelay=5e3,this.eventSource=createResource$1((et,tt)=>__awaiter(this,void 0,void 0,function*(){const rt={bridgeUrl:this.bridgeUrl,ssePath:this.ssePath,sessionId:this.sessionId,bridgeGatewayStorage:this.bridgeGatewayStorage,errorHandler:this.errorsHandler.bind(this),messageHandler:this.messagesHandler.bind(this),signal:et,openingDeadlineMS:tt};return yield createEventSource(rt)}),et=>__awaiter(this,void 0,void 0,function*(){et.close()})),this.bridgeGatewayStorage=new HttpBridgeGatewayStorage(_,d)}get isReady(){const _=this.eventSource.current();return(_==null?void 0:_.readyState)===EventSource.OPEN}get isClosed(){const _=this.eventSource.current();return(_==null?void 0:_.readyState)!==EventSource.OPEN}get isConnecting(){const _=this.eventSource.current();return(_==null?void 0:_.readyState)===EventSource.CONNECTING}registerSession(_){return __awaiter(this,void 0,void 0,function*(){yield this.eventSource.create(_==null?void 0:_.signal,_==null?void 0:_.openingDeadlineMS)})}send(_,d,k,j){var $;return __awaiter(this,void 0,void 0,function*(){const et={};typeof j=="number"?et.ttl=j:(et.ttl=j==null?void 0:j.ttl,et.signal=j==null?void 0:j.signal,et.attempts=j==null?void 0:j.attempts);const tt=new URL(addPathToUrl(this.bridgeUrl,this.postPath));tt.searchParams.append("client_id",this.sessionId),tt.searchParams.append("to",d),tt.searchParams.append("ttl",((et==null?void 0:et.ttl)||this.defaultTtl).toString()),tt.searchParams.append("topic",k);const rt=Base64.encode(_);yield callForSuccess(nt=>__awaiter(this,void 0,void 0,function*(){const ot=yield this.post(tt,rt,nt.signal);if(!ot.ok)throw new TonConnectError(`Bridge send failed, status ${ot.status}`)}),{attempts:($=et==null?void 0:et.attempts)!==null&&$!==void 0?$:Number.MAX_SAFE_INTEGER,delayMs:this.defaultResendDelay,signal:et==null?void 0:et.signal})})}pause(){this.eventSource.dispose().catch(_=>logError$1(`Bridge pause failed, ${_}`))}unPause(){return __awaiter(this,void 0,void 0,function*(){yield this.eventSource.recreate(0)})}close(){return __awaiter(this,void 0,void 0,function*(){yield this.eventSource.dispose().catch(_=>logError$1(`Bridge close failed, ${_}`))})}setListener(_){this.listener=_}setErrorsListener(_){this.errorsListener=_}post(_,d,k){return __awaiter(this,void 0,void 0,function*(){const j=yield fetch(_,{method:"post",body:d,signal:k});if(!j.ok)throw new TonConnectError(`Bridge send failed, status ${j.status}`);return j})}errorsHandler(_,d){return __awaiter(this,void 0,void 0,function*(){if(this.isConnecting)throw _.close(),new TonConnectError("Bridge error, failed to connect");if(this.isReady){try{this.errorsListener(d)}catch{}return}if(this.isClosed)return _.close(),logDebug$1(`Bridge reconnecting, ${this.defaultReconnectDelay}ms delay`),yield this.eventSource.recreate(this.defaultReconnectDelay);throw new TonConnectError("Bridge error, unknown state")})}messagesHandler(_){return __awaiter(this,void 0,void 0,function*(){if(_.data===this.heartbeatMessage||(yield this.bridgeGatewayStorage.storeLastEventId(_.lastEventId),this.isClosed))return;let d;try{d=JSON.parse(_.data)}catch(k){throw new TonConnectError(`Bridge message parse failed, message ${k.data}`)}this.listener(d)})}}function createEventSource(b){return __awaiter(this,void 0,void 0,function*(){return yield timeout((_,d,k)=>__awaiter(this,void 0,void 0,function*(){var j;const et=createAbortController(k.signal).signal;if(et.aborted){d(new TonConnectError("Bridge connection aborted"));return}const tt=new URL(addPathToUrl(b.bridgeUrl,b.ssePath));tt.searchParams.append("client_id",b.sessionId);const rt=yield b.bridgeGatewayStorage.getLastEventId();if(rt&&tt.searchParams.append("last_event_id",rt),et.aborted){d(new TonConnectError("Bridge connection aborted"));return}const nt=new EventSource(tt.toString());nt.onerror=ot=>__awaiter(this,void 0,void 0,function*(){if(et.aborted){nt.close(),d(new TonConnectError("Bridge connection aborted"));return}try{const at=yield b.errorHandler(nt,ot);at!==nt&&nt.close(),at&&at!==nt&&_(at)}catch(at){nt.close(),d(at)}}),nt.onopen=()=>{if(et.aborted){nt.close(),d(new TonConnectError("Bridge connection aborted"));return}_(nt)},nt.onmessage=ot=>{if(et.aborted){nt.close(),d(new TonConnectError("Bridge connection aborted"));return}b.messageHandler(ot)},(j=b.signal)===null||j===void 0||j.addEventListener("abort",()=>{nt.close(),d(new TonConnectError("Bridge connection aborted"))})}),{timeout:b.openingDeadlineMS,signal:b.signal})})}function isPendingConnectionHttp(b){return!("connectEvent"in b)}class BridgeConnectionStorage{constructor(_){this.storage=_,this.storeKey="ton-connect-storage_bridge-connection"}storeConnection(_){return __awaiter(this,void 0,void 0,function*(){if(_.type==="injected")return this.storage.setItem(this.storeKey,JSON.stringify(_));if(!isPendingConnectionHttp(_)){const k={sessionKeyPair:_.session.sessionCrypto.stringifyKeypair(),walletPublicKey:_.session.walletPublicKey,bridgeUrl:_.session.bridgeUrl},j={type:"http",connectEvent:_.connectEvent,session:k,lastWalletEventId:_.lastWalletEventId,nextRpcRequestId:_.nextRpcRequestId};return this.storage.setItem(this.storeKey,JSON.stringify(j))}const d={type:"http",connectionSource:_.connectionSource,sessionCrypto:_.sessionCrypto.stringifyKeypair()};return this.storage.setItem(this.storeKey,JSON.stringify(d))})}removeConnection(){return __awaiter(this,void 0,void 0,function*(){return this.storage.removeItem(this.storeKey)})}getConnection(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.storage.getItem(this.storeKey);if(!_)return null;const d=JSON.parse(_);if(d.type==="injected")return d;if("connectEvent"in d){const k=new SessionCrypto(d.session.sessionKeyPair);return{type:"http",connectEvent:d.connectEvent,lastWalletEventId:d.lastWalletEventId,nextRpcRequestId:d.nextRpcRequestId,session:{sessionCrypto:k,bridgeUrl:d.session.bridgeUrl,walletPublicKey:d.session.walletPublicKey}}}return{type:"http",sessionCrypto:new SessionCrypto(d.sessionCrypto),connectionSource:d.connectionSource}})}getHttpConnection(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(!_)throw new TonConnectError("Trying to read HTTP connection source while nothing is stored");if(_.type==="injected")throw new TonConnectError("Trying to read HTTP connection source while injected connection is stored");return _})}getHttpPendingConnection(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(!_)throw new TonConnectError("Trying to read HTTP connection source while nothing is stored");if(_.type==="injected")throw new TonConnectError("Trying to read HTTP connection source while injected connection is stored");if(!isPendingConnectionHttp(_))throw new TonConnectError("Trying to read HTTP-pending connection while http connection is stored");return _})}getInjectedConnection(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(!_)throw new TonConnectError("Trying to read Injected bridge connection source while nothing is stored");if((_==null?void 0:_.type)==="http")throw new TonConnectError("Trying to read Injected bridge connection source while HTTP connection is stored");return _})}storedConnectionType(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.storage.getItem(this.storeKey);return _?JSON.parse(_).type:null})}storeLastWalletEventId(_){return __awaiter(this,void 0,void 0,function*(){const d=yield this.getConnection();if(d&&d.type==="http"&&!isPendingConnectionHttp(d))return d.lastWalletEventId=_,this.storeConnection(d)})}getLastWalletEventId(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(_&&"lastWalletEventId"in _)return _.lastWalletEventId})}increaseNextRpcRequestId(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();if(_&&"nextRpcRequestId"in _){const d=_.nextRpcRequestId||0;return _.nextRpcRequestId=d+1,this.storeConnection(_)}})}getNextRpcRequestId(){return __awaiter(this,void 0,void 0,function*(){const _=yield this.getConnection();return _&&"nextRpcRequestId"in _&&_.nextRpcRequestId||0})}}const PROTOCOL_VERSION=2;class BridgeProvider{constructor(_,d){this.storage=_,this.walletConnectionSource=d,this.type="http",this.standardUniversalLink="tc://",this.pendingRequests=new Map,this.session=null,this.gateway=null,this.pendingGateways=[],this.listeners=[],this.defaultOpeningDeadlineMS=12e3,this.defaultRetryTimeoutMS=2e3,this.connectionStorage=new BridgeConnectionStorage(_)}static fromStorage(_){return __awaiter(this,void 0,void 0,function*(){const k=yield new BridgeConnectionStorage(_).getHttpConnection();return isPendingConnectionHttp(k)?new BridgeProvider(_,k.connectionSource):new BridgeProvider(_,{bridgeUrl:k.session.bridgeUrl})})}connect(_,d){var k;const j=createAbortController(d==null?void 0:d.signal);(k=this.abortController)===null||k===void 0||k.abort(),this.abortController=j,this.closeGateways();const $=new SessionCrypto;this.session={sessionCrypto:$,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},this.connectionStorage.storeConnection({type:"http",connectionSource:this.walletConnectionSource,sessionCrypto:$}).then(()=>__awaiter(this,void 0,void 0,function*(){j.signal.aborted||(yield callForSuccess(tt=>{var rt;return this.openGateways($,{openingDeadlineMS:(rt=d==null?void 0:d.openingDeadlineMS)!==null&&rt!==void 0?rt:this.defaultOpeningDeadlineMS,signal:tt==null?void 0:tt.signal})},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:j.signal}))}));const et="universalLink"in this.walletConnectionSource&&this.walletConnectionSource.universalLink?this.walletConnectionSource.universalLink:this.standardUniversalLink;return this.generateUniversalLink(et,_)}restoreConnection(_){var d,k;return __awaiter(this,void 0,void 0,function*(){const j=createAbortController(_==null?void 0:_.signal);if((d=this.abortController)===null||d===void 0||d.abort(),this.abortController=j,j.signal.aborted)return;this.closeGateways();const $=yield this.connectionStorage.getHttpConnection();if(!$||j.signal.aborted)return;const et=(k=_==null?void 0:_.openingDeadlineMS)!==null&&k!==void 0?k:this.defaultOpeningDeadlineMS;if(isPendingConnectionHttp($))return this.session={sessionCrypto:$.sessionCrypto,bridgeUrl:"bridgeUrl"in this.walletConnectionSource?this.walletConnectionSource.bridgeUrl:""},yield this.openGateways($.sessionCrypto,{openingDeadlineMS:et,signal:j==null?void 0:j.signal});if(Array.isArray(this.walletConnectionSource))throw new TonConnectError("Internal error. Connection source is array while WalletConnectionSourceHTTP was expected.");if(this.session=$.session,this.gateway&&(logDebug$1("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,$.session.sessionCrypto.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),!j.signal.aborted){this.listeners.forEach(tt=>tt($.connectEvent));try{yield callForSuccess(tt=>this.gateway.registerSession({openingDeadlineMS:et,signal:tt.signal}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:j.signal})}catch{yield this.disconnect({signal:j.signal});return}}})}sendRequest(_,d){const k={};return typeof d=="function"?k.onRequestSent=d:(k.onRequestSent=d==null?void 0:d.onRequestSent,k.signal=d==null?void 0:d.signal,k.attempts=d==null?void 0:d.attempts),new Promise((j,$)=>__awaiter(this,void 0,void 0,function*(){var et;if(!this.gateway||!this.session||!("walletPublicKey"in this.session))throw new TonConnectError("Trying to send bridge request without session");const tt=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),logDebug$1("Send http-bridge request:",Object.assign(Object.assign({},_),{id:tt}));const rt=this.session.sessionCrypto.encrypt(JSON.stringify(Object.assign(Object.assign({},_),{id:tt})),hexToByteArray(this.session.walletPublicKey));try{yield this.gateway.send(rt,this.session.walletPublicKey,_.method,{attempts:k==null?void 0:k.attempts,signal:k==null?void 0:k.signal}),(et=k==null?void 0:k.onRequestSent)===null||et===void 0||et.call(k),this.pendingRequests.set(tt.toString(),j)}catch(nt){$(nt)}}))}closeConnection(){this.closeGateways(),this.listeners=[],this.session=null,this.gateway=null}disconnect(_){return __awaiter(this,void 0,void 0,function*(){return new Promise(d=>__awaiter(this,void 0,void 0,function*(){let k=!1,j=null;const $=()=>{k||(k=!0,this.removeBridgeAndSession().then(d))};try{this.closeGateways();const et=createAbortController(_==null?void 0:_.signal);j=setTimeout(()=>{et.abort()},this.defaultOpeningDeadlineMS),yield this.sendRequest({method:"disconnect",params:[]},{onRequestSent:$,signal:et.signal,attempts:1})}catch(et){logDebug$1("Disconnect error:",et),k||this.removeBridgeAndSession().then(d)}finally{j&&clearTimeout(j),$()}}))})}listen(_){return this.listeners.push(_),()=>this.listeners=this.listeners.filter(d=>d!==_)}pause(){var _;(_=this.gateway)===null||_===void 0||_.pause(),this.pendingGateways.forEach(d=>d.pause())}unPause(){return __awaiter(this,void 0,void 0,function*(){const _=this.pendingGateways.map(d=>d.unPause());this.gateway&&_.push(this.gateway.unPause()),yield Promise.all(_)})}pendingGatewaysListener(_,d,k){return __awaiter(this,void 0,void 0,function*(){if(!this.pendingGateways.includes(_)){yield _.close();return}return this.closeGateways({except:_}),this.gateway&&(logDebug$1("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.session.bridgeUrl=d,this.gateway=_,this.gateway.setErrorsListener(this.gatewayErrorsListener.bind(this)),this.gateway.setListener(this.gatewayListener.bind(this)),this.gatewayListener(k)})}gatewayListener(_){return __awaiter(this,void 0,void 0,function*(){const d=JSON.parse(this.session.sessionCrypto.decrypt(Base64.decode(_.message).toUint8Array(),hexToByteArray(_.from)));if(logDebug$1("Wallet message received:",d),!("event"in d)){const j=d.id.toString(),$=this.pendingRequests.get(j);if(!$){logDebug$1(`Response id ${j} doesn't match any request's id`);return}$(d),this.pendingRequests.delete(j);return}if(d.id!==void 0){const j=yield this.connectionStorage.getLastWalletEventId();if(j!==void 0&&d.id<=j){logError$1(`Received event id (=${d.id}) must be greater than stored last wallet event id (=${j}) `);return}d.event!=="connect"&&(yield this.connectionStorage.storeLastWalletEventId(d.id))}const k=this.listeners;d.event==="connect"&&(yield this.updateSession(d,_.from)),d.event==="disconnect"&&(logDebug$1("Removing bridge and session: received disconnect event"),yield this.removeBridgeAndSession()),k.forEach(j=>j(d))})}gatewayErrorsListener(_){return __awaiter(this,void 0,void 0,function*(){throw new TonConnectError(`Bridge error ${JSON.stringify(_)}`)})}updateSession(_,d){return __awaiter(this,void 0,void 0,function*(){this.session=Object.assign(Object.assign({},this.session),{walletPublicKey:d});const k=_.payload.items.find($=>$.name==="ton_addr"),j=Object.assign(Object.assign({},_),{payload:Object.assign(Object.assign({},_.payload),{items:[k]})});yield this.connectionStorage.storeConnection({type:"http",session:this.session,lastWalletEventId:_.id,connectEvent:j,nextRpcRequestId:0})})}removeBridgeAndSession(){return __awaiter(this,void 0,void 0,function*(){this.closeConnection(),yield this.connectionStorage.removeConnection()})}generateUniversalLink(_,d){return isTelegramUrl(_)?this.generateTGUniversalLink(_,d):this.generateRegularUniversalLink(_,d)}generateRegularUniversalLink(_,d){const k=new URL(_);return k.searchParams.append("v",PROTOCOL_VERSION.toString()),k.searchParams.append("id",this.session.sessionCrypto.sessionId),k.searchParams.append("r",JSON.stringify(d)),k.toString()}generateTGUniversalLink(_,d){const j=this.generateRegularUniversalLink("about:blank",d).split("?")[1],$="tonconnect-"+encodeTelegramUrlParameters(j),et=this.convertToDirectLink(_),tt=new URL(et);return tt.searchParams.append("startapp",$),tt.toString()}convertToDirectLink(_){const d=new URL(_);return d.searchParams.has("attach")&&(d.searchParams.delete("attach"),d.pathname+="/start"),d.toString()}openGateways(_,d){return __awaiter(this,void 0,void 0,function*(){if(Array.isArray(this.walletConnectionSource)){this.pendingGateways.map(k=>k.close().catch()),this.pendingGateways=this.walletConnectionSource.map(k=>{const j=new BridgeGateway(this.storage,k.bridgeUrl,_.sessionId,()=>{},()=>{});return j.setListener($=>this.pendingGatewaysListener(j,k.bridgeUrl,$)),j}),yield Promise.allSettled(this.pendingGateways.map(k=>callForSuccess(j=>{var $;return this.pendingGateways.some(et=>et===k)?k.registerSession({openingDeadlineMS:($=d==null?void 0:d.openingDeadlineMS)!==null&&$!==void 0?$:this.defaultOpeningDeadlineMS,signal:j.signal}):k.close()},{attempts:Number.MAX_SAFE_INTEGER,delayMs:this.defaultRetryTimeoutMS,signal:d==null?void 0:d.signal})));return}else return this.gateway&&(logDebug$1("Gateway is already opened, closing previous gateway"),yield this.gateway.close()),this.gateway=new BridgeGateway(this.storage,this.walletConnectionSource.bridgeUrl,_.sessionId,this.gatewayListener.bind(this),this.gatewayErrorsListener.bind(this)),yield this.gateway.registerSession({openingDeadlineMS:d==null?void 0:d.openingDeadlineMS,signal:d==null?void 0:d.signal})})}closeGateways(_){var d;(d=this.gateway)===null||d===void 0||d.close(),this.pendingGateways.filter(k=>k!==(_==null?void 0:_.except)).forEach(k=>k.close()),this.pendingGateways=[]}}function hasProperty(b,_){return hasProperties(b,[_])}function hasProperties(b,_){return!b||typeof b!="object"?!1:_.every(d=>d in b)}function isJSBridgeWithMetadata(b){try{return!hasProperty(b,"tonconnect")||!hasProperty(b.tonconnect,"walletInfo")?!1:hasProperties(b.tonconnect.walletInfo,["name","app_name","image","about_url","platforms"])}catch{return!1}}let InMemoryStorage$1=class Xo{constructor(){this.storage={}}static getInstance(){return Xo.instance||(Xo.instance=new Xo),Xo.instance}get length(){return Object.keys(this.storage).length}clear(){this.storage={}}getItem(_){var d;return(d=this.storage[_])!==null&&d!==void 0?d:null}key(_){var d;const k=Object.keys(this.storage);return _<0||_>=k.length?null:(d=k[_])!==null&&d!==void 0?d:null}removeItem(_){delete this.storage[_]}setItem(_,d){this.storage[_]=d}};function getWindow$2(){if(!(typeof window>"u"))return window}function tryGetWindowKeys(){const b=getWindow$2();if(!b)return[];try{return Object.keys(b)}catch{return[]}}function getDocument(){if(!(typeof document>"u"))return document}function getWebPageManifest(){var b;const _=(b=getWindow$2())===null||b===void 0?void 0:b.location.origin;return _?_+"/tonconnect-manifest.json":""}function tryGetLocalStorage$1(){if(isLocalStorageAvailable$1())return localStorage;if(isNodeJs$1())throw new TonConnectError("`localStorage` is unavailable, but it is required for TonConnect. For more details, see https://github.com/ton-connect/sdk/tree/main/packages/sdk#init-connector");return InMemoryStorage$1.getInstance()}function isLocalStorageAvailable$1(){try{return typeof localStorage<"u"}catch{return!1}}function isNodeJs$1(){return typeof process<"u"&&process.versions!=null&&process.versions.node!=null}class InjectedProvider{constructor(_,d){this.injectedWalletKey=d,this.type="injected",this.unsubscribeCallback=null,this.listenSubscriptions=!1,this.listeners=[];const k=InjectedProvider.window;if(!InjectedProvider.isWindowContainsWallet(k,d))throw new WalletNotInjectedError;this.connectionStorage=new BridgeConnectionStorage(_),this.injectedWallet=k[d].tonconnect}static fromStorage(_){return __awaiter(this,void 0,void 0,function*(){const k=yield new BridgeConnectionStorage(_).getInjectedConnection();return new InjectedProvider(_,k.jsBridgeKey)})}static isWalletInjected(_){return InjectedProvider.isWindowContainsWallet(this.window,_)}static isInsideWalletBrowser(_){return InjectedProvider.isWindowContainsWallet(this.window,_)?this.window[_].tonconnect.isWalletBrowser:!1}static getCurrentlyInjectedWallets(){return this.window?tryGetWindowKeys().filter(k=>isJSBridgeWithMetadata(k)).map(([k,j])=>({name:j.tonconnect.walletInfo.name,appName:j.tonconnect.walletInfo.app_name,aboutUrl:j.tonconnect.walletInfo.about_url,imageUrl:j.tonconnect.walletInfo.image,tondns:j.tonconnect.walletInfo.tondns,jsBridgeKey:k,injected:!0,embedded:j.tonconnect.isWalletBrowser,platforms:j.tonconnect.walletInfo.platforms})):[]}static isWindowContainsWallet(_,d){return!!_&&d in _&&typeof _[d]=="object"&&"tonconnect"in _[d]}connect(_){this._connect(PROTOCOL_VERSION,_)}restoreConnection(){return __awaiter(this,void 0,void 0,function*(){try{logDebug$1("Injected Provider restoring connection...");const _=yield this.injectedWallet.restoreConnection();logDebug$1("Injected Provider restoring connection response",_),_.event==="connect"?(this.makeSubscriptions(),this.listeners.forEach(d=>d(_))):yield this.connectionStorage.removeConnection()}catch(_){yield this.connectionStorage.removeConnection(),console.error(_)}})}closeConnection(){this.listenSubscriptions&&this.injectedWallet.disconnect(),this.closeAllListeners()}disconnect(){return __awaiter(this,void 0,void 0,function*(){return new Promise(_=>{const d=()=>{this.closeAllListeners(),this.connectionStorage.removeConnection().then(_)};try{this.injectedWallet.disconnect(),d()}catch(k){logDebug$1(k),this.sendRequest({method:"disconnect",params:[]},d)}})})}closeAllListeners(){var _;this.listenSubscriptions=!1,this.listeners=[],(_=this.unsubscribeCallback)===null||_===void 0||_.call(this)}listen(_){return this.listeners.push(_),()=>this.listeners=this.listeners.filter(d=>d!==_)}sendRequest(_,d){var k;return __awaiter(this,void 0,void 0,function*(){const j={};typeof d=="function"?j.onRequestSent=d:(j.onRequestSent=d==null?void 0:d.onRequestSent,j.signal=d==null?void 0:d.signal);const $=(yield this.connectionStorage.getNextRpcRequestId()).toString();yield this.connectionStorage.increaseNextRpcRequestId(),logDebug$1("Send injected-bridge request:",Object.assign(Object.assign({},_),{id:$}));const et=this.injectedWallet.send(Object.assign(Object.assign({},_),{id:$}));return et.then(tt=>logDebug$1("Wallet message received:",tt)),(k=j==null?void 0:j.onRequestSent)===null||k===void 0||k.call(j),et})}_connect(_,d){return __awaiter(this,void 0,void 0,function*(){try{logDebug$1(`Injected Provider connect request: protocolVersion: ${_}, message:`,d);const k=yield this.injectedWallet.connect(_,d);logDebug$1("Injected Provider connect response:",k),k.event==="connect"&&(yield this.updateSession(),this.makeSubscriptions()),this.listeners.forEach(j=>j(k))}catch(k){logDebug$1("Injected Provider connect error:",k);const j={event:"connect_error",payload:{code:0,message:k==null?void 0:k.toString()}};this.listeners.forEach($=>$(j))}})}makeSubscriptions(){this.listenSubscriptions=!0,this.unsubscribeCallback=this.injectedWallet.listen(_=>{logDebug$1("Wallet message received:",_),this.listenSubscriptions&&this.listeners.forEach(d=>d(_)),_.event==="disconnect"&&this.disconnect()})}updateSession(){return this.connectionStorage.storeConnection({type:"injected",jsBridgeKey:this.injectedWalletKey,nextRpcRequestId:0})}}InjectedProvider.window=getWindow$2();class DefaultStorage{constructor(){this.localStorage=tryGetLocalStorage$1()}getItem(_){return __awaiter(this,void 0,void 0,function*(){return this.localStorage.getItem(_)})}removeItem(_){return __awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(_)})}setItem(_,d){return __awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(_,d)})}}function isWalletInfoCurrentlyInjected(b){return isWalletInfoInjectable(b)&&b.injected}function isWalletInfoCurrentlyEmbedded(b){return isWalletInfoCurrentlyInjected(b)&&b.embedded}function isWalletInfoInjectable(b){return"jsBridgeKey"in b}function isWalletInfoRemote(b){return"bridgeUrl"in b}const FALLBACK_WALLETS_LIST=[{app_name:"telegram-wallet",name:"Wallet",image:"https://wallet.tg/images/logo-288.png",about_url:"https://wallet.tg/",universal_url:"https://t.me/wallet?attach=wallet",bridge:[{type:"sse",url:"https://walletbot.me/tonconnect-bridge/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"tonkeeper",name:"Tonkeeper",image:"https://tonkeeper.com/assets/tonconnect-icon.png",tondns:"tonkeeper.ton",about_url:"https://tonkeeper.com",universal_url:"https://app.tonkeeper.com/ton-connect",deepLink:"tonkeeper-tc://",bridge:[{type:"sse",url:"https://bridge.tonapi.io/bridge"},{type:"js",key:"tonkeeper"}],platforms:["ios","android","chrome","firefox","macos"]},{app_name:"mytonwallet",name:"MyTonWallet",image:"https://static.mytonwallet.io/icon-256.png",about_url:"https://mytonwallet.io",universal_url:"https://connect.mytonwallet.org",bridge:[{type:"js",key:"mytonwallet"},{type:"sse",url:"https://tonconnectbridge.mytonwallet.org/bridge/"}],platforms:["chrome","windows","macos","linux","ios","android","firefox"]},{app_name:"tonhub",name:"Tonhub",image:"https://tonhub.com/tonconnect_logo.png",about_url:"https://tonhub.com",universal_url:"https://tonhub.com/ton-connect",bridge:[{type:"js",key:"tonhub"},{type:"sse",url:"https://connect.tonhubapi.com/tonconnect"}],platforms:["ios","android"]},{app_name:"bitgetTonWallet",name:"Bitget Wallet",image:"https://raw.githubusercontent.com/bitgetwallet/download/refs/heads/main/logo/png/bitget_wallet_logo_288_mini.png",about_url:"https://web3.bitget.com",deepLink:"bitkeep://",bridge:[{type:"js",key:"bitgetTonWallet"},{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","chrome"],universal_url:"https://bkcode.vip/ton-connect"},{app_name:"okxMiniWallet",name:"OKX Mini Wallet",image:"https://static.okx.com/cdn/assets/imgs/2411/8BE1A4A434D8F58A.png",about_url:"https://www.okx.com/web3",universal_url:"https://t.me/OKX_WALLET_BOT?attach=wallet",bridge:[{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"binanceWeb3TonWallet",name:"Binance Web3 Wallet",image:"https://public.bnbstatic.com/static/binance-w3w/ton-provider/binancew3w.png",about_url:"https://www.binance.com/en/web3wallet",deepLink:"bnc://app.binance.com/cedefi/ton-connect",bridge:[{type:"js",key:"binancew3w"},{type:"sse",url:"https://wallet.binance.com/tonbridge/bridge"}],platforms:["ios","android","macos","windows","linux"],universal_url:"https://app.binance.com/cedefi/ton-connect"},{app_name:"fintopio-tg",name:"Fintopio",image:"https://fintopio.com/tonconnect-icon.png",about_url:"https://fintopio.com",universal_url:"https://t.me/fintopio?attach=wallet",bridge:[{type:"sse",url:"https://wallet-bridge.fintopio.com/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"okxTonWallet",name:"OKX Wallet",image:"https://static.okx.com/cdn/assets/imgs/247/58E63FEA47A2B7D7.png",about_url:"https://www.okx.com/web3",universal_url:"https://www.okx.com/download?appendQuery=true&deeplink=okx://web3/wallet/tonconnect",bridge:[{type:"js",key:"okxTonWallet"},{type:"sse",url:"https://www.okx.com/tonbridge/discover/rpc/bridge"}],platforms:["chrome","safari","firefox","ios","android"]},{app_name:"hot",name:"HOT",image:"https://raw.githubusercontent.com/hot-dao/media/main/logo.png",about_url:"https://hot-labs.org/",universal_url:"https://t.me/herewalletbot?attach=wallet",bridge:[{type:"sse",url:"https://sse-bridge.hot-labs.org"},{type:"js",key:"hotWallet"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"bybitTonWallet",name:"Bybit Wallet",image:"https://raw.githubusercontent.com/bybit-web3/bybit-web3.github.io/main/docs/images/bybit-logo.png",about_url:"https://www.bybit.com/web3",universal_url:"https://app.bybit.com/ton-connect",deepLink:"bybitapp://",bridge:[{type:"js",key:"bybitTonWallet"},{type:"sse",url:"https://api-node.bybit.com/spot/api/web3/bridge/ton/bridge"}],platforms:["ios","android","chrome"]},{app_name:"dewallet",name:"DeWallet",image:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",about_url:"https://delabwallet.com",universal_url:"https://t.me/dewallet?attach=wallet",bridge:[{type:"sse",url:"https://bridge.dewallet.pro/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"safepalwallet",name:"SafePal",image:"https://s.pvcliping.com/web/public_image/SafePal_x288.png",tondns:"",about_url:"https://www.safepal.com",universal_url:"https://link.safepal.io/ton-connect",deepLink:"safepal-tc://",bridge:[{type:"sse",url:"https://ton-bridge.safepal.com/tonbridge/v1/bridge"},{type:"js",key:"safepalwallet"}],platforms:["ios","android","chrome","firefox"]},{app_name:"GateWallet",name:"GateWallet",image:"https://img.gatedataimg.com/prd-ordinal-imgs/036f07bb8730716e/gateio-0925.png",about_url:"https://www.gate.io/",bridge:[{type:"js",key:"gatetonwallet"},{type:"sse",url:"https://dapp.gateio.services/tonbridge_api/bridge/v1"}],platforms:["ios","android"],universal_url:"https://gateio.go.link/gateio/web3?adj_t=1ff8khdw_1fu4ccc7"},{app_name:"openmask",name:"OpenMask",image:"https://raw.githubusercontent.com/OpenProduct/openmask-extension/main/public/openmask-logo-288.png",about_url:"https://www.openmask.app/",bridge:[{type:"js",key:"openmask"}],platforms:["chrome"]},{app_name:"BitgetWeb3",name:"BitgetWeb3",image:"https://img.bitgetimg.com/image/third/1731638059795.png",about_url:"​https://www.bitget.com",universal_url:"https://t.me/BitgetOfficialBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-connect-bridge.bgwapi.io/bridge"}],platforms:["ios","android","windows","macos","linux"]},{app_name:"tobi",name:"Tobi",image:"https://app.tobiwallet.app/icons/logo-288.png",about_url:"https://tobi.fun",universal_url:"https://t.me/TobiCopilotBot?attach=wallet",bridge:[{type:"sse",url:"https://ton-bridge.tobiwallet.app/bridge"}],platforms:["ios","android","macos","windows","linux"]},{app_name:"xtonwallet",name:"XTONWallet",image:"https://xtonwallet.com/assets/img/icon-256-back.png",about_url:"https://xtonwallet.com",bridge:[{type:"js",key:"xtonwallet"}],platforms:["chrome","firefox"]},{app_name:"tonwallet",name:"TON Wallet",image:"https://wallet.ton.org/assets/ui/qr-logo.png",about_url:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",bridge:[{type:"js",key:"tonwallet"}],platforms:["chrome"]}];class WalletsListManager{constructor(_){this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null,this.walletsListSource="https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json",_!=null&&_.walletsListSource&&(this.walletsListSource=_.walletsListSource),_!=null&&_.cacheTTLMs&&(this.cacheTTLMs=_.cacheTTLMs)}getWallets(){return __awaiter(this,void 0,void 0,function*(){return this.cacheTTLMs&&this.walletsListCacheCreationTimestamp&&Date.now()>this.walletsListCacheCreationTimestamp+this.cacheTTLMs&&(this.walletsListCache=null),this.walletsListCache||(this.walletsListCache=this.fetchWalletsList(),this.walletsListCache.then(()=>{this.walletsListCacheCreationTimestamp=Date.now()}).catch(()=>{this.walletsListCache=null,this.walletsListCacheCreationTimestamp=null})),this.walletsListCache})}getEmbeddedWallet(){return __awaiter(this,void 0,void 0,function*(){const d=(yield this.getWallets()).filter(isWalletInfoCurrentlyEmbedded);return d.length!==1?null:d[0]})}fetchWalletsList(){return __awaiter(this,void 0,void 0,function*(){let _=[];try{if(_=yield(yield fetch(this.walletsListSource)).json(),_.push({app_name:"hpyTonWallet",name:"HyperPay Wallet",image:"https://onchain-oss.hyperpay.online/images/logo.png",about_url:"https://www.hyperpay.tech",universal_url:"https://www.hyperpay.tech/download&deeplink=hyperpay://web3/wallet/tonconnect",bridge:[{type:"js",key:"hpyTonWallet"},{type:"sse",url:"https://onchain-wallet.hyperpay.online/bridge"}],platforms:["ios","android","macos","windows","linux"]}),_.push({app_name:"nicegramWallet",name:"Nicegram Wallet",image:"https://static.nicegram.app/icon.png",about_url:"https://nicegram.app",universal_url:"https://nicegram.app/tc",deepLink:"nicegram-tc://",bridge:[{type:"sse",url:"https://tc.nicegram.app/bridge"},{type:"js",key:"nicegramWallet"}],platforms:["ios","android","macos","windows","linux"]}),_.push({app_name:"foxwallet",name:"FoxWallet",image:"https://hc.foxwallet.com/img/logo.png",about_url:"https://foxwallet.com/",universal_url:"https://link.foxwallet.com/tc",bridge:[{type:"js",key:"foxwallet"},{type:"sse",url:"https://connect.foxwallet.com/ton/bridge"}],platforms:["ios","android"]}),_.push({app_name:"trustwalletTon",name:"Trust",image:"https://assets-cdn.trustwallet.com/dapps/trust.logo.png",about_url:"https://trustwallet.com/about-us",deepLink:"trust://ton-connect",universal_url:"https://trustwallet.com",bridge:[{type:"js",key:"trustwalletTon"},{type:"sse",url:"https://tonconnect.trustwallet.com/bridge"}],platforms:["chrome","ios","android"]}),_.push({app_name:"jambo",name:"Jambo",image:"https://cdn-prod.jambotechnology.xyz/content/jambo_288x288_02da416a6c.png",about_url:"https://www.jambo.technology/",deepLink:"jambotc://",universal_url:"https://jambophone.xyz/",bridge:[{type:"js",key:"jambowallet"},{type:"sse",url:"https://bridge.tonapi.io/bridge"}],platforms:["android"]}),_.push({app_name:"tokenpocket",name:"TokenPocket",image:"https://hk.tpstatic.net/logo/tokenpocket.png",about_url:"https://www.tokenpocket.pro",universal_url:"https://tp-lab.tptool.pro/ton-connect/",bridge:[{type:"js",key:"tokenpocket"},{type:"sse",url:"https://ton-connect.mytokenpocket.vip/bridge"}],platforms:["ios","android"]}),!Array.isArray(_))throw new FetchWalletsError("Wrong wallets list format, wallets list must be an array.");const j=_.filter($=>!this.isCorrectWalletConfigDTO($));j.length&&(logError$1(`Wallet(s) ${j.map($=>$.name).join(", ")} config format is wrong. They were removed from the wallets list.`),_=_.filter($=>this.isCorrectWalletConfigDTO($)))}catch(k){logError$1(k),_=FALLBACK_WALLETS_LIST}let d=[];try{d=InjectedProvider.getCurrentlyInjectedWallets()}catch(k){logError$1(k)}return this.mergeWalletsLists(this.walletConfigDTOListToWalletConfigList(_),d)})}walletConfigDTOListToWalletConfigList(_){return _.map(d=>{const j={name:d.name,appName:d.app_name,imageUrl:d.image,aboutUrl:d.about_url,tondns:d.tondns,platforms:d.platforms};return d.bridge.forEach($=>{if($.type==="sse"&&(j.bridgeUrl=$.url,j.universalLink=d.universal_url,j.deepLink=d.deepLink),$.type==="js"){const et=$.key;j.jsBridgeKey=et,j.injected=InjectedProvider.isWalletInjected(et),j.embedded=InjectedProvider.isInsideWalletBrowser(et)}}),j})}mergeWalletsLists(_,d){return[...new Set(_.concat(d).map(j=>j.name)).values()].map(j=>{const $=_.find(tt=>tt.name===j),et=d.find(tt=>tt.name===j);return Object.assign(Object.assign({},$&&Object.assign({},$)),et&&Object.assign({},et))})}isCorrectWalletConfigDTO(_){if(!_||typeof _!="object")return!1;const d="name"in _,k="app_name"in _,j="image"in _,$="about_url"in _,et="platforms"in _;if(!d||!j||!$||!et||!k||!_.platforms||!Array.isArray(_.platforms)||!_.platforms.length||!("bridge"in _)||!Array.isArray(_.bridge)||!_.bridge.length)return!1;const tt=_.bridge;if(tt.some(ot=>!ot||typeof ot!="object"||!("type"in ot)))return!1;const rt=tt.find(ot=>ot.type==="sse");if(rt&&(!("url"in rt)||!rt.url||!_.universal_url))return!1;const nt=tt.find(ot=>ot.type==="js");return!(nt&&(!("key"in nt)||!nt.key))}}class WalletNotSupportFeatureError extends TonConnectError{get info(){return"Wallet doesn't support requested feature method."}constructor(..._){super(..._),Object.setPrototypeOf(this,WalletNotSupportFeatureError.prototype)}}function checkSendTransactionSupport(b,_){const d=b.includes("SendTransaction"),k=b.find(j=>j&&typeof j=="object"&&j.name==="SendTransaction");if(!d&&!k)throw new WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.");if(k&&k.maxMessages!==void 0){if(k.maxMessages<_.requiredMessagesNumber)throw new WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${k.maxMessages}, but ${_.requiredMessagesNumber} is required.`);return}logWarning$1("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.")}function createRequestVersionEvent(){return{type:"request-version"}}function createResponseVersionEvent(b){return{type:"response-version",version:b}}function createVersionInfo(b){return{ton_connect_sdk_lib:b.ton_connect_sdk_lib,ton_connect_ui_lib:b.ton_connect_ui_lib}}function createConnectionInfo(b,_){var d,k,j,$,et,tt,rt,nt;const at=((d=_==null?void 0:_.connectItems)===null||d===void 0?void 0:d.tonProof)&&"proof"in _.connectItems.tonProof?"ton_proof":"ton_addr";return{wallet_address:(j=(k=_==null?void 0:_.account)===null||k===void 0?void 0:k.address)!==null&&j!==void 0?j:null,wallet_type:($=_==null?void 0:_.device.appName)!==null&&$!==void 0?$:null,wallet_version:(et=_==null?void 0:_.device.appVersion)!==null&&et!==void 0?et:null,auth_type:at,custom_data:Object.assign({chain_id:(rt=(tt=_==null?void 0:_.account)===null||tt===void 0?void 0:tt.chain)!==null&&rt!==void 0?rt:null,provider:(nt=_==null?void 0:_.provider)!==null&&nt!==void 0?nt:null},createVersionInfo(b))}}function createConnectionStartedEvent(b){return{type:"connection-started",custom_data:createVersionInfo(b)}}function createConnectionCompletedEvent(b,_){return Object.assign({type:"connection-completed",is_success:!0},createConnectionInfo(b,_))}function createConnectionErrorEvent(b,_,d){return{type:"connection-error",is_success:!1,error_message:_,error_code:d??null,custom_data:createVersionInfo(b)}}function createConnectionRestoringStartedEvent(b){return{type:"connection-restoring-started",custom_data:createVersionInfo(b)}}function createConnectionRestoringCompletedEvent(b,_){return Object.assign({type:"connection-restoring-completed",is_success:!0},createConnectionInfo(b,_))}function createConnectionRestoringErrorEvent(b,_){return{type:"connection-restoring-error",is_success:!1,error_message:_,custom_data:createVersionInfo(b)}}function createTransactionInfo(b,_){var d,k,j,$;return{valid_until:(d=String(_.validUntil))!==null&&d!==void 0?d:null,from:($=(k=_.from)!==null&&k!==void 0?k:(j=b==null?void 0:b.account)===null||j===void 0?void 0:j.address)!==null&&$!==void 0?$:null,messages:_.messages.map(et=>{var tt,rt;return{address:(tt=et.address)!==null&&tt!==void 0?tt:null,amount:(rt=et.amount)!==null&&rt!==void 0?rt:null}})}}function createTransactionSentForSignatureEvent(b,_,d){return Object.assign(Object.assign({type:"transaction-sent-for-signature"},createConnectionInfo(b,_)),createTransactionInfo(_,d))}function createTransactionSignedEvent(b,_,d,k){return Object.assign(Object.assign({type:"transaction-signed",is_success:!0,signed_transaction:k.boc},createConnectionInfo(b,_)),createTransactionInfo(_,d))}function createTransactionSigningFailedEvent(b,_,d,k,j){return Object.assign(Object.assign({type:"transaction-signing-failed",is_success:!1,error_message:k,error_code:j??null},createConnectionInfo(b,_)),createTransactionInfo(_,d))}function createDisconnectionEvent(b,_,d){return Object.assign({type:"disconnection",scope:d},createConnectionInfo(b,_))}class BrowserEventDispatcher{constructor(){this.window=getWindow$2()}dispatchEvent(_,d){var k;return __awaiter(this,void 0,void 0,function*(){const j=new CustomEvent(_,{detail:d});(k=this.window)===null||k===void 0||k.dispatchEvent(j)})}addEventListener(_,d,k){var j;return __awaiter(this,void 0,void 0,function*(){return(j=this.window)===null||j===void 0||j.addEventListener(_,d,k),()=>{var $;return($=this.window)===null||$===void 0?void 0:$.removeEventListener(_,d)}})}}class TonConnectTracker{constructor(_){var d;this.eventPrefix="ton-connect-",this.tonConnectUiVersion=null,this.eventDispatcher=(d=_==null?void 0:_.eventDispatcher)!==null&&d!==void 0?d:new BrowserEventDispatcher,this.tonConnectSdkVersion=_.tonConnectSdkVersion,this.init().catch()}get version(){return createVersionInfo({ton_connect_sdk_lib:this.tonConnectSdkVersion,ton_connect_ui_lib:this.tonConnectUiVersion})}init(){return __awaiter(this,void 0,void 0,function*(){try{yield this.setRequestVersionHandler(),this.tonConnectUiVersion=yield this.requestTonConnectUiVersion()}catch{}})}setRequestVersionHandler(){return __awaiter(this,void 0,void 0,function*(){yield this.eventDispatcher.addEventListener("ton-connect-request-version",()=>__awaiter(this,void 0,void 0,function*(){yield this.eventDispatcher.dispatchEvent("ton-connect-response-version",createResponseVersionEvent(this.tonConnectSdkVersion))}))})}requestTonConnectUiVersion(){return __awaiter(this,void 0,void 0,function*(){return new Promise((_,d)=>__awaiter(this,void 0,void 0,function*(){try{yield this.eventDispatcher.addEventListener("ton-connect-ui-response-version",k=>{_(k.detail.version)},{once:!0}),yield this.eventDispatcher.dispatchEvent("ton-connect-ui-request-version",createRequestVersionEvent())}catch(k){d(k)}}))})}dispatchUserActionEvent(_){try{this.eventDispatcher.dispatchEvent(`${this.eventPrefix}${_.type}`,_).catch()}catch{}}trackConnectionStarted(..._){try{const d=createConnectionStartedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionCompleted(..._){try{const d=createConnectionCompletedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionError(..._){try{const d=createConnectionErrorEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionRestoringStarted(..._){try{const d=createConnectionRestoringStartedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionRestoringCompleted(..._){try{const d=createConnectionRestoringCompletedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackConnectionRestoringError(..._){try{const d=createConnectionRestoringErrorEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackDisconnection(..._){try{const d=createDisconnectionEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackTransactionSentForSignature(..._){try{const d=createTransactionSentForSignatureEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackTransactionSigned(..._){try{const d=createTransactionSignedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}trackTransactionSigningFailed(..._){try{const d=createTransactionSigningFailedEvent(this.version,..._);this.dispatchUserActionEvent(d)}catch{}}}const tonConnectSdkVersion="3.0.6-beta.0";class TonConnect{constructor(_){if(this.walletsList=new WalletsListManager,this._wallet=null,this.provider=null,this.statusChangeSubscriptions=[],this.statusChangeErrorSubscriptions=[],this.dappSettings={manifestUrl:(_==null?void 0:_.manifestUrl)||getWebPageManifest(),storage:(_==null?void 0:_.storage)||new DefaultStorage},this.walletsList=new WalletsListManager({walletsListSource:_==null?void 0:_.walletsListSource,cacheTTLMs:_==null?void 0:_.walletsListCacheTTLMs}),this.tracker=new TonConnectTracker({eventDispatcher:_==null?void 0:_.eventDispatcher,tonConnectSdkVersion}),!this.dappSettings.manifestUrl)throw new DappMetadataError("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest");this.bridgeConnectionStorage=new BridgeConnectionStorage(this.dappSettings.storage),_!=null&&_.disableAutoPauseConnection||this.addWindowFocusAndBlurSubscriptions()}static getWallets(){return this.walletsList.getWallets()}get connected(){return this._wallet!==null}get account(){var _;return((_=this._wallet)===null||_===void 0?void 0:_.account)||null}get wallet(){return this._wallet}set wallet(_){this._wallet=_,this.statusChangeSubscriptions.forEach(d=>d(this._wallet))}getWallets(){return this.walletsList.getWallets()}onStatusChange(_,d){return this.statusChangeSubscriptions.push(_),d&&this.statusChangeErrorSubscriptions.push(d),()=>{this.statusChangeSubscriptions=this.statusChangeSubscriptions.filter(k=>k!==_),d&&(this.statusChangeErrorSubscriptions=this.statusChangeErrorSubscriptions.filter(k=>k!==d))}}connect(_,d){var k,j;const $={};if(typeof d=="object"&&"tonProof"in d&&($.request=d),typeof d=="object"&&("openingDeadlineMS"in d||"signal"in d||"request"in d)&&($.request=d==null?void 0:d.request,$.openingDeadlineMS=d==null?void 0:d.openingDeadlineMS,$.signal=d==null?void 0:d.signal),this.connected)throw new WalletAlreadyConnectedError;const et=createAbortController($==null?void 0:$.signal);if((k=this.abortController)===null||k===void 0||k.abort(),this.abortController=et,et.signal.aborted)throw new TonConnectError("Connection was aborted");return(j=this.provider)===null||j===void 0||j.closeConnection(),this.provider=this.createProvider(_),et.signal.addEventListener("abort",()=>{var tt;(tt=this.provider)===null||tt===void 0||tt.closeConnection(),this.provider=null}),this.tracker.trackConnectionStarted(),this.provider.connect(this.createConnectRequest($==null?void 0:$.request),{openingDeadlineMS:$==null?void 0:$.openingDeadlineMS,signal:et.signal})}restoreConnection(_){var d,k;return __awaiter(this,void 0,void 0,function*(){this.tracker.trackConnectionRestoringStarted();const j=createAbortController(_==null?void 0:_.signal);if((d=this.abortController)===null||d===void 0||d.abort(),this.abortController=j,j.signal.aborted){this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}const[$,et]=yield Promise.all([this.bridgeConnectionStorage.storedConnectionType(),this.walletsList.getEmbeddedWallet()]);if(j.signal.aborted){this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}let tt=null;try{switch($){case"http":tt=yield BridgeProvider.fromStorage(this.dappSettings.storage);break;case"injected":tt=yield InjectedProvider.fromStorage(this.dappSettings.storage);break;default:if(et)tt=this.createProvider(et);else return}}catch{this.tracker.trackConnectionRestoringError("Provider is not restored"),yield this.bridgeConnectionStorage.removeConnection(),tt==null||tt.closeConnection(),tt=null;return}if(j.signal.aborted){tt==null||tt.closeConnection(),this.tracker.trackConnectionRestoringError("Connection restoring was aborted");return}if(!tt){logError$1("Provider is not restored"),this.tracker.trackConnectionRestoringError("Provider is not restored");return}(k=this.provider)===null||k===void 0||k.closeConnection(),this.provider=tt,tt.listen(this.walletEventsListener.bind(this));const rt=()=>{this.tracker.trackConnectionRestoringError("Connection restoring was aborted"),tt==null||tt.closeConnection(),tt=null};j.signal.addEventListener("abort",rt);const nt=callForSuccess(at=>__awaiter(this,void 0,void 0,function*(){yield tt==null?void 0:tt.restoreConnection({openingDeadlineMS:_==null?void 0:_.openingDeadlineMS,signal:at.signal}),j.signal.removeEventListener("abort",rt),this.connected?this.tracker.trackConnectionRestoringCompleted(this.wallet):this.tracker.trackConnectionRestoringError("Connection restoring failed")}),{attempts:Number.MAX_SAFE_INTEGER,delayMs:2e3,signal:_==null?void 0:_.signal}),ot=new Promise(at=>setTimeout(()=>at(),12e3));return Promise.race([nt,ot])})}sendTransaction(_,d){return __awaiter(this,void 0,void 0,function*(){const k={};typeof d=="function"?k.onRequestSent=d:(k.onRequestSent=d==null?void 0:d.onRequestSent,k.signal=d==null?void 0:d.signal);const j=createAbortController(k==null?void 0:k.signal);if(j.signal.aborted)throw new TonConnectError("Transaction sending was aborted");this.checkConnection(),checkSendTransactionSupport(this.wallet.device.features,{requiredMessagesNumber:_.messages.length}),this.tracker.trackTransactionSentForSignature(this.wallet,_);const{validUntil:$}=_,et=__rest(_,["validUntil"]),tt=_.from||this.account.address,rt=_.network||this.account.chain,nt=yield this.provider.sendRequest(sendTransactionParser.convertToRpcRequest(Object.assign(Object.assign({},et),{valid_until:$,from:tt,network:rt})),{onRequestSent:k.onRequestSent,signal:j.signal});if(sendTransactionParser.isError(nt))return this.tracker.trackTransactionSigningFailed(this.wallet,_,nt.error.message,nt.error.code),sendTransactionParser.parseAndThrowError(nt);const ot=sendTransactionParser.convertFromRpcResponse(nt);return this.tracker.trackTransactionSigned(this.wallet,_,ot),ot})}disconnect(_){var d;return __awaiter(this,void 0,void 0,function*(){if(!this.connected)throw new WalletNotConnectedError;const k=createAbortController(_==null?void 0:_.signal),j=this.abortController;if(this.abortController=k,k.signal.aborted)throw new TonConnectError("Disconnect was aborted");this.onWalletDisconnected("dapp"),yield(d=this.provider)===null||d===void 0?void 0:d.disconnect({signal:k.signal}),j==null||j.abort()})}pauseConnection(){var _;((_=this.provider)===null||_===void 0?void 0:_.type)==="http"&&this.provider.pause()}unPauseConnection(){var _;return((_=this.provider)===null||_===void 0?void 0:_.type)!=="http"?Promise.resolve():this.provider.unPause()}addWindowFocusAndBlurSubscriptions(){const _=getDocument();if(_)try{_.addEventListener("visibilitychange",()=>{_.hidden?this.pauseConnection():this.unPauseConnection().catch()})}catch(d){logError$1("Cannot subscribe to the document.visibilitychange: ",d)}}createProvider(_){let d;return!Array.isArray(_)&&isWalletConnectionSourceJS(_)?d=new InjectedProvider(this.dappSettings.storage,_.jsBridgeKey):d=new BridgeProvider(this.dappSettings.storage,_),d.listen(this.walletEventsListener.bind(this)),d}walletEventsListener(_){switch(_.event){case"connect":this.onWalletConnected(_.payload);break;case"connect_error":this.onWalletConnectError(_.payload);break;case"disconnect":this.onWalletDisconnected("wallet")}}onWalletConnected(_){const d=_.items.find($=>$.name==="ton_addr"),k=_.items.find($=>$.name==="ton_proof");if(!d)throw new TonConnectError("ton_addr connection item was not found");const j={device:_.device,provider:this.provider.type,account:{address:d.address,chain:d.network,walletStateInit:d.walletStateInit,publicKey:d.publicKey}};k&&(j.connectItems={tonProof:k}),this.wallet=j,this.tracker.trackConnectionCompleted(j)}onWalletConnectError(_){const d=connectErrorsParser.parseError(_);if(this.statusChangeErrorSubscriptions.forEach(k=>k(d)),logDebug$1(d),this.tracker.trackConnectionError(_.message,_.code),d instanceof ManifestNotFoundError||d instanceof ManifestContentErrorError)throw logError$1(d),d}onWalletDisconnected(_){this.tracker.trackDisconnection(this.wallet,_),this.wallet=null}checkConnection(){if(!this.connected)throw new WalletNotConnectedError}createConnectRequest(_){const d=[{name:"ton_addr"}];return _!=null&&_.tonProof&&d.push({name:"ton_proof",payload:_.tonProof}),{manifestUrl:this.dappSettings.manifestUrl,items:d}}}TonConnect.walletsList=new WalletsListManager;TonConnect.isWalletInjected=b=>InjectedProvider.isWalletInjected(b);TonConnect.isInsideWalletBrowser=b=>InjectedProvider.isInsideWalletBrowser(b);const noBounceableTag=81,testOnlyTag=128;function toUserFriendlyAddress(b,_=!1){const{wc:d,hex:k}=parseHexAddress(b);let j=noBounceableTag;_&&(j|=testOnlyTag);const $=new Int8Array(34);$[0]=j,$[1]=d,$.set(k,2);const et=new Uint8Array(36);return et.set($),et.set(crc16($),34),Base64.encode(et).replace(/\+/g,"-").replace(/\//g,"_")}function parseHexAddress(b){if(!b.includes(":"))throw new WrongAddressError(`Wrong address ${b}. Address must include ":".`);const _=b.split(":");if(_.length!==2)throw new WrongAddressError(`Wrong address ${b}. Address must include ":" only once.`);const d=parseInt(_[0]);if(d!==0&&d!==-1)throw new WrongAddressError(`Wrong address ${b}. WC must be eq 0 or -1, but ${d} received.`);const k=_[1];if((k==null?void 0:k.length)!==64)throw new WrongAddressError(`Wrong address ${b}. Hex part must be 64bytes length, but ${k==null?void 0:k.length} received.`);return{wc:d,hex:hexToBytes(k)}}function crc16(b){let d=0;const k=new Uint8Array(b.length+2);k.set(b);for(let j of k){let $=128;for(;$>0;)d<<=1,j&$&&(d+=1),$>>=1,d>65535&&(d&=65535,d^=4129)}return new Uint8Array([Math.floor(d/256),d%256])}const toByteMap={};for(let b=0;b<=255;b++){let _=b.toString(16);_.length<2&&(_="0"+_),toByteMap[_]=b}function hexToBytes(b){b=b.toLowerCase();const _=b.length;if(_%2!==0)throw new ParseHexError("Hex string must have length a multiple of 2: "+b);const d=_/2,k=new Uint8Array(d);for(let j=0;j0?ln.length===2?typeof ln[1]==tt?this[ln[0]]=ln[1].call(this,Qn):this[ln[0]]=ln[1]:ln.length===3?typeof ln[1]===tt&&!(ln[1].exec&&ln[1].test)?this[ln[0]]=Qn?ln[1].call(this,Qn,ln[2]):k:this[ln[0]]=Qn?Qn.replace(ln[1],ln[2]):k:ln.length===4&&(this[ln[0]]=Qn?ln[3].call(this,Qn.replace(ln[1],ln[2])):k):this[ln]=Qn||k;pt+=2}},Sn=function(Kt,bt){for(var pt in bt)if(typeof bt[pt]===nt&&bt[pt].length>0){for(var yt=0;yt2&&(mn[it]="iPad",mn[ut]=st),mn},this.getEngine=function(){var mn={};return mn[dt]=k,mn[ft]=k,Un.call(mn,yt,sn.engine),mn},this.getOS=function(){var mn={};return mn[dt]=k,mn[ft]=k,Un.call(mn,yt,sn.os),ln&&!mn[dt]&&Ut&&Ut.platform&&Ut.platform!="Unknown"&&(mn[dt]=Ut.platform.replace(/chrome os/i,An).replace(/macos/i,yn)),mn},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return yt},this.setUA=function(mn){return yt=typeof mn===ot&&mn.length>Mt?Dn(mn,Mt):mn,this},this.setUA(yt),this};Fn.VERSION=j,Fn.BROWSER=vn([dt,ft,at]),Fn.CPU=vn([lt]),Fn.DEVICE=vn([it,ht,ut,ct,gt,_t,st,xt,wt]),Fn.ENGINE=Fn.OS=vn([dt,ft]),b.exports&&(_=b.exports=Fn),_.UAParser=Fn;var zn=typeof d!==rt&&(d.jQuery||d.Zepto);if(zn&&!zn.ua){var Tn=new Fn;zn.ua=Tn.getResult(),zn.ua.get=function(){return Tn.getUA()},zn.ua.set=function(Kt){Tn.setUA(Kt);var bt=Tn.getResult();for(var pt in bt)zn.ua[pt]=bt[pt]}}})(typeof window=="object"?window:commonjsGlobal)})(uaParser,uaParser.exports);var uaParserExports=uaParser.exports;const UAParser=getDefaultExportFromCjs(uaParserExports);var isMergeableObject=function b(_){return isNonNullObject(_)&&!isSpecial(_)};function isNonNullObject(b){return!!b&&typeof b=="object"}function isSpecial(b){var _=Object.prototype.toString.call(b);return _==="[object RegExp]"||_==="[object Date]"||isReactElement(b)}var canUseSymbol=typeof Symbol=="function"&&Symbol.for,REACT_ELEMENT_TYPE=canUseSymbol?Symbol.for("react.element"):60103;function isReactElement(b){return b.$$typeof===REACT_ELEMENT_TYPE}function emptyTarget(b){return Array.isArray(b)?[]:{}}function cloneUnlessOtherwiseSpecified(b,_){return _.clone!==!1&&_.isMergeableObject(b)?deepmerge(emptyTarget(b),b,_):b}function defaultArrayMerge(b,_,d){return b.concat(_).map(function(k){return cloneUnlessOtherwiseSpecified(k,d)})}function getMergeFunction(b,_){if(!_.customMerge)return deepmerge;var d=_.customMerge(b);return typeof d=="function"?d:deepmerge}function getEnumerableOwnPropertySymbols(b){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(b).filter(function(_){return Object.propertyIsEnumerable.call(b,_)}):[]}function getKeys(b){return Object.keys(b).concat(getEnumerableOwnPropertySymbols(b))}function propertyIsOnObject(b,_){try{return _ in b}catch{return!1}}function propertyIsUnsafe(b,_){return propertyIsOnObject(b,_)&&!(Object.hasOwnProperty.call(b,_)&&Object.propertyIsEnumerable.call(b,_))}function mergeObject(b,_,d){var k={};return d.isMergeableObject(b)&&getKeys(b).forEach(function(j){k[j]=cloneUnlessOtherwiseSpecified(b[j],d)}),getKeys(_).forEach(function(j){propertyIsUnsafe(b,j)||(propertyIsOnObject(b,j)&&d.isMergeableObject(_[j])?k[j]=getMergeFunction(j,d)(b[j],_[j],d):k[j]=cloneUnlessOtherwiseSpecified(_[j],d))}),k}function deepmerge(b,_,d){d=d||{},d.arrayMerge=d.arrayMerge||defaultArrayMerge,d.isMergeableObject=d.isMergeableObject||isMergeableObject,d.cloneUnlessOtherwiseSpecified=cloneUnlessOtherwiseSpecified;var k=Array.isArray(_),j=Array.isArray(b),$=k===j;return $?k?d.arrayMerge(b,_,d):mergeObject(b,_,d):cloneUnlessOtherwiseSpecified(_,d)}deepmerge.all=function b(_,d){if(!Array.isArray(_))throw new Error("first argument should be an array");return _.reduce(function(k,j){return deepmerge(k,j,d)},{})};var deepmerge_1=deepmerge,cjs=deepmerge_1;const deepmerge$1=getDefaultExportFromCjs(cjs);var classnames={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames @@ -1503,4 +1503,4 @@ PERFORMANCE OF THIS SOFTWARE. The above lifecycles should be removed. Learn more about this warning here: https://fb.me/react-async-component-lifecycle-hooks`)}if(typeof jt.getDerivedStateFromProps=="function"&&(Nt.componentWillMount=_t,Nt.componentWillReceiveProps=xt),typeof Nt.getSnapshotBeforeUpdate=="function"){if(typeof Nt.componentDidUpdate!="function")throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");Nt.componentWillUpdate=wt;var tn=Nt.componentDidUpdate;Nt.componentDidUpdate=function(Gt,xn,Gn){var er=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:Gn;tn.call(this,Gt,xn,er)}}return jt}function kt(jt,Nt){if(jt==null)return{};var Rt,Wt,Pt=function(un,tn){if(un==null)return{};var Gt,xn,Gn={},er=Object.keys(un);for(xn=0;xn=0||(Gn[Gt]=un[Gt]);return Gn}(jt,Nt);if(Object.getOwnPropertySymbols){var hn=Object.getOwnPropertySymbols(jt);for(Wt=0;Wt=0||Object.prototype.propertyIsEnumerable.call(jt,Rt)&&(Pt[Rt]=jt[Rt])}return Pt}function Ct(jt){var Nt=function(Rt){return{}.toString.call(Rt).match(/\s([a-zA-Z]+)/)[1].toLowerCase()}(jt);return Nt==="number"&&(Nt=isNaN(jt)?"nan":(0|jt)!=jt?"float":"integer"),Nt}_t.__suppressDeprecationWarning=!0,xt.__suppressDeprecationWarning=!0,wt.__suppressDeprecationWarning=!0;var Tt={scheme:"rjv-default",author:"mac gainor",base00:"rgba(0, 0, 0, 0)",base01:"rgb(245, 245, 245)",base02:"rgb(235, 235, 235)",base03:"#93a1a1",base04:"rgba(0, 0, 0, 0.3)",base05:"#586e75",base06:"#073642",base07:"#002b36",base08:"#d33682",base09:"#cb4b16",base0A:"#dc322f",base0B:"#859900",base0C:"#6c71c4",base0D:"#586e75",base0E:"#2aa198",base0F:"#268bd2"},At={scheme:"rjv-grey",author:"mac gainor",base00:"rgba(1, 1, 1, 0)",base01:"rgba(1, 1, 1, 0.1)",base02:"rgba(0, 0, 0, 0.2)",base03:"rgba(1, 1, 1, 0.3)",base04:"rgba(0, 0, 0, 0.4)",base05:"rgba(1, 1, 1, 0.5)",base06:"rgba(1, 1, 1, 0.6)",base07:"rgba(1, 1, 1, 0.7)",base08:"rgba(1, 1, 1, 0.8)",base09:"rgba(1, 1, 1, 0.8)",base0A:"rgba(1, 1, 1, 0.8)",base0B:"rgba(1, 1, 1, 0.8)",base0C:"rgba(1, 1, 1, 0.8)",base0D:"rgba(1, 1, 1, 0.8)",base0E:"rgba(1, 1, 1, 0.8)",base0F:"rgba(1, 1, 1, 0.8)"},Et={white:"#fff",black:"#000",transparent:"rgba(1, 1, 1, 0)",globalFontFamily:"monospace",globalCursor:"default",indentBlockWidth:"5px",braceFontWeight:"bold",braceCursor:"pointer",ellipsisFontSize:"18px",ellipsisLineHeight:"10px",ellipsisCursor:"pointer",keyMargin:"0px 5px",keyLetterSpacing:"0.5px",keyFontStyle:"none",keyBorderRadius:"3px",keyColonWeight:"bold",keyVerticalAlign:"top",keyOpacity:"0.85",keyOpacityHover:"1",keyValPaddingTop:"3px",keyValPaddingBottom:"3px",keyValPaddingRight:"5px",keyValBorderLeft:"1px solid",keyValBorderHover:"2px solid",keyValPaddingHover:"3px 5px 3px 4px",pushedContentMarginLeft:"6px",variableValuePaddingRight:"6px",nullFontSize:"11px",nullFontWeight:"bold",nullPadding:"1px 2px",nullBorderRadius:"3px",nanFontSize:"11px",nanFontWeight:"bold",nanPadding:"1px 2px",nanBorderRadius:"3px",undefinedFontSize:"11px",undefinedFontWeight:"bold",undefinedPadding:"1px 2px",undefinedBorderRadius:"3px",dataTypeFontSize:"11px",dataTypeMarginRight:"4px",datatypeOpacity:"0.8",objectSizeBorderRadius:"3px",objectSizeFontStyle:"italic",objectSizeMargin:"0px 6px 0px 0px",clipboardCursor:"pointer",clipboardCheckMarginLeft:"-12px",metaDataPadding:"0px 0px 0px 10px",arrayGroupMetaPadding:"0px 0px 0px 4px",iconContainerWidth:"17px",tooltipPadding:"4px",editInputMinWidth:"130px",editInputBorderRadius:"2px",editInputPadding:"5px",editInputMarginRight:"4px",editInputFontFamily:"monospace",iconCursor:"pointer",iconFontSize:"15px",iconPaddingRight:"1px",dateValueMarginLeft:"2px",iconMarginRight:"3px",detectedRowPaddingTop:"3px",addKeyCoverBackground:"rgba(255, 255, 255, 0.3)",addKeyCoverPosition:"absolute",addKeyCoverPositionPx:"0px",addKeyModalWidth:"200px",addKeyModalMargin:"auto",addKeyModalPadding:"10px",addKeyModalRadius:"3px"},Ot=$(45),Lt=function(jt){var Nt=function(Rt){return{backgroundColor:Rt.base00,ellipsisColor:Rt.base09,braceColor:Rt.base07,expandedIcon:Rt.base0D,collapsedIcon:Rt.base0E,keyColor:Rt.base07,arrayKeyColor:Rt.base0C,objectSize:Rt.base04,copyToClipboard:Rt.base0F,copyToClipboardCheck:Rt.base0D,objectBorder:Rt.base02,dataTypes:{boolean:Rt.base0E,date:Rt.base0D,float:Rt.base0B,function:Rt.base0D,integer:Rt.base0F,string:Rt.base09,nan:Rt.base08,null:Rt.base0A,undefined:Rt.base05,regexp:Rt.base0A,background:Rt.base02},editVariable:{editIcon:Rt.base0E,cancelIcon:Rt.base09,removeIcon:Rt.base09,addIcon:Rt.base0E,checkIcon:Rt.base0E,background:Rt.base01,color:Rt.base0A,border:Rt.base07},addKeyModal:{background:Rt.base05,border:Rt.base04,color:Rt.base0A,labelColor:Rt.base01},validationFailure:{background:Rt.base09,iconColor:Rt.base01,fontColor:Rt.base01}}}(jt);return{"app-container":{fontFamily:Et.globalFontFamily,cursor:Et.globalCursor,backgroundColor:Nt.backgroundColor,position:"relative"},ellipsis:{display:"inline-block",color:Nt.ellipsisColor,fontSize:Et.ellipsisFontSize,lineHeight:Et.ellipsisLineHeight,cursor:Et.ellipsisCursor},"brace-row":{display:"inline-block",cursor:"pointer"},brace:{display:"inline-block",cursor:Et.braceCursor,fontWeight:Et.braceFontWeight,color:Nt.braceColor},"expanded-icon":{color:Nt.expandedIcon},"collapsed-icon":{color:Nt.collapsedIcon},colon:{display:"inline-block",margin:Et.keyMargin,color:Nt.keyColor,verticalAlign:"top"},objectKeyVal:function(Rt,Wt){return{style:rt({paddingTop:Et.keyValPaddingTop,paddingRight:Et.keyValPaddingRight,paddingBottom:Et.keyValPaddingBottom,borderLeft:Et.keyValBorderLeft+" "+Nt.objectBorder,":hover":{paddingLeft:Wt.paddingLeft-1+"px",borderLeft:Et.keyValBorderHover+" "+Nt.objectBorder}},Wt)}},"object-key-val-no-border":{padding:Et.keyValPadding},"pushed-content":{marginLeft:Et.pushedContentMarginLeft},variableValue:function(Rt,Wt){return{style:rt({display:"inline-block",paddingRight:Et.variableValuePaddingRight,position:"relative"},Wt)}},"object-name":{display:"inline-block",color:Nt.keyColor,letterSpacing:Et.keyLetterSpacing,fontStyle:Et.keyFontStyle,verticalAlign:Et.keyVerticalAlign,opacity:Et.keyOpacity,":hover":{opacity:Et.keyOpacityHover}},"array-key":{display:"inline-block",color:Nt.arrayKeyColor,letterSpacing:Et.keyLetterSpacing,fontStyle:Et.keyFontStyle,verticalAlign:Et.keyVerticalAlign,opacity:Et.keyOpacity,":hover":{opacity:Et.keyOpacityHover}},"object-size":{color:Nt.objectSize,borderRadius:Et.objectSizeBorderRadius,fontStyle:Et.objectSizeFontStyle,margin:Et.objectSizeMargin,cursor:"default"},"data-type-label":{fontSize:Et.dataTypeFontSize,marginRight:Et.dataTypeMarginRight,opacity:Et.datatypeOpacity},boolean:{display:"inline-block",color:Nt.dataTypes.boolean},date:{display:"inline-block",color:Nt.dataTypes.date},"date-value":{marginLeft:Et.dateValueMarginLeft},float:{display:"inline-block",color:Nt.dataTypes.float},function:{display:"inline-block",color:Nt.dataTypes.function,cursor:"pointer",whiteSpace:"pre-line"},"function-value":{fontStyle:"italic"},integer:{display:"inline-block",color:Nt.dataTypes.integer},string:{display:"inline-block",color:Nt.dataTypes.string},nan:{display:"inline-block",color:Nt.dataTypes.nan,fontSize:Et.nanFontSize,fontWeight:Et.nanFontWeight,backgroundColor:Nt.dataTypes.background,padding:Et.nanPadding,borderRadius:Et.nanBorderRadius},null:{display:"inline-block",color:Nt.dataTypes.null,fontSize:Et.nullFontSize,fontWeight:Et.nullFontWeight,backgroundColor:Nt.dataTypes.background,padding:Et.nullPadding,borderRadius:Et.nullBorderRadius},undefined:{display:"inline-block",color:Nt.dataTypes.undefined,fontSize:Et.undefinedFontSize,padding:Et.undefinedPadding,borderRadius:Et.undefinedBorderRadius,backgroundColor:Nt.dataTypes.background},regexp:{display:"inline-block",color:Nt.dataTypes.regexp},"copy-to-clipboard":{cursor:Et.clipboardCursor},"copy-icon":{color:Nt.copyToClipboard,fontSize:Et.iconFontSize,marginRight:Et.iconMarginRight,verticalAlign:"top"},"copy-icon-copied":{color:Nt.copyToClipboardCheck,marginLeft:Et.clipboardCheckMarginLeft},"array-group-meta-data":{display:"inline-block",padding:Et.arrayGroupMetaPadding},"object-meta-data":{display:"inline-block",padding:Et.metaDataPadding},"icon-container":{display:"inline-block",width:Et.iconContainerWidth},tooltip:{padding:Et.tooltipPadding},removeVarIcon:{verticalAlign:"top",display:"inline-block",color:Nt.editVariable.removeIcon,cursor:Et.iconCursor,fontSize:Et.iconFontSize,marginRight:Et.iconMarginRight},addVarIcon:{verticalAlign:"top",display:"inline-block",color:Nt.editVariable.addIcon,cursor:Et.iconCursor,fontSize:Et.iconFontSize,marginRight:Et.iconMarginRight},editVarIcon:{verticalAlign:"top",display:"inline-block",color:Nt.editVariable.editIcon,cursor:Et.iconCursor,fontSize:Et.iconFontSize,marginRight:Et.iconMarginRight},"edit-icon-container":{display:"inline-block",verticalAlign:"top"},"check-icon":{display:"inline-block",cursor:Et.iconCursor,color:Nt.editVariable.checkIcon,fontSize:Et.iconFontSize,paddingRight:Et.iconPaddingRight},"cancel-icon":{display:"inline-block",cursor:Et.iconCursor,color:Nt.editVariable.cancelIcon,fontSize:Et.iconFontSize,paddingRight:Et.iconPaddingRight},"edit-input":{display:"inline-block",minWidth:Et.editInputMinWidth,borderRadius:Et.editInputBorderRadius,backgroundColor:Nt.editVariable.background,color:Nt.editVariable.color,padding:Et.editInputPadding,marginRight:Et.editInputMarginRight,fontFamily:Et.editInputFontFamily},"detected-row":{paddingTop:Et.detectedRowPaddingTop},"key-modal-request":{position:Et.addKeyCoverPosition,top:Et.addKeyCoverPositionPx,left:Et.addKeyCoverPositionPx,right:Et.addKeyCoverPositionPx,bottom:Et.addKeyCoverPositionPx,backgroundColor:Et.addKeyCoverBackground},"key-modal":{width:Et.addKeyModalWidth,backgroundColor:Nt.addKeyModal.background,marginLeft:Et.addKeyModalMargin,marginRight:Et.addKeyModalMargin,padding:Et.addKeyModalPadding,borderRadius:Et.addKeyModalRadius,marginTop:"15px",position:"relative"},"key-modal-label":{color:Nt.addKeyModal.labelColor,marginLeft:"2px",marginBottom:"5px",fontSize:"11px"},"key-modal-input-container":{overflow:"hidden"},"key-modal-input":{width:"100%",padding:"3px 6px",fontFamily:"monospace",color:Nt.addKeyModal.color,border:"none",boxSizing:"border-box",borderRadius:"2px"},"key-modal-cancel":{backgroundColor:Nt.editVariable.removeIcon,position:"absolute",top:"0px",right:"0px",borderRadius:"0px 3px 0px 3px",cursor:"pointer"},"key-modal-cancel-icon":{color:Nt.addKeyModal.labelColor,fontSize:Et.iconFontSize,transform:"rotate(45deg)"},"key-modal-submit":{color:Nt.editVariable.addIcon,fontSize:Et.iconFontSize,position:"absolute",right:"2px",top:"3px",cursor:"pointer"},"function-ellipsis":{display:"inline-block",color:Nt.ellipsisColor,fontSize:Et.ellipsisFontSize,lineHeight:Et.ellipsisLineHeight,cursor:Et.ellipsisCursor},"validation-failure":{float:"right",padding:"3px 6px",borderRadius:"2px",cursor:"pointer",color:Nt.validationFailure.fontColor,backgroundColor:Nt.validationFailure.background},"validation-failure-label":{marginRight:"6px"},"validation-failure-clear":{position:"relative",verticalAlign:"top",cursor:"pointer",color:Nt.validationFailure.iconColor,fontSize:Et.iconFontSize,transform:"rotate(45deg)"}}};function Bt(jt,Nt,Rt){return jt||console.error("theme has not been set"),function(Wt){var Pt=Tt;return Wt!==!1&&Wt!=="none"||(Pt=At),Object(Ot.createStyling)(Lt,{defaultBase16:Pt})(Wt)}(jt)(Nt,Rt)}var Zt=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=(Wt.rjvId,Wt.type_name),hn=Wt.displayDataTypes,un=Wt.theme;return hn?st.a.createElement("span",Object.assign({className:"data-type-label"},Bt(un,"data-type-label")),Pt):null}}]),Rt}(st.a.PureComponent),rn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props;return st.a.createElement("div",Bt(Wt.theme,"boolean"),st.a.createElement(Zt,Object.assign({type_name:"bool"},Wt)),Wt.value?"true":"false")}}]),Rt}(st.a.PureComponent),nn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props;return st.a.createElement("div",Bt(Wt.theme,"date"),st.a.createElement(Zt,Object.assign({type_name:"date"},Wt)),st.a.createElement("span",Object.assign({className:"date-value"},Bt(Wt.theme,"date-value")),Wt.value.toLocaleTimeString("en-us",{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})))}}]),Rt}(st.a.PureComponent),Qt=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props;return st.a.createElement("div",Bt(Wt.theme,"float"),st.a.createElement(Zt,Object.assign({type_name:"float"},Wt)),this.props.value)}}]),Rt}(st.a.PureComponent);function Vt(jt,Nt){(Nt==null||Nt>jt.length)&&(Nt=jt.length);for(var Rt=0,Wt=new Array(Nt);Rt"u"||jt[Symbol.iterator]==null){if(Array.isArray(jt)||(Rt=fn(jt))||Nt&&jt&&typeof jt.length=="number"){Rt&&(jt=Rt);var Wt=0,Pt=function(){};return{s:Pt,n:function(){return Wt>=jt.length?{done:!0}:{done:!1,value:jt[Wt++]}},e:function(Gt){throw Gt},f:Pt}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var hn,un=!0,tn=!1;return{s:function(){Rt=jt[Symbol.iterator]()},n:function(){var Gt=Rt.next();return un=Gt.done,Gt},e:function(Gt){tn=!0,hn=Gt},f:function(){try{un||Rt.return==null||Rt.return()}finally{if(tn)throw hn}}}}function On(jt){return function(Nt){if(Array.isArray(Nt))return Vt(Nt)}(jt)||function(Nt){if(typeof Symbol<"u"&&Symbol.iterator in Object(Nt))return Array.from(Nt)}(jt)||fn(jt)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}var _n=$(46),Bn=new($(47)).Dispatcher,Yn=new(function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){var Wt;nt(this,Rt);for(var Pt=arguments.length,hn=new Array(Pt),un=0;unPt&&(tn.style.cursor="pointer",this.state.collapsed&&(un=st.a.createElement("span",null,un.substring(0,Pt),st.a.createElement("span",Bt(hn,"ellipsis")," ...")))),st.a.createElement("div",Bt(hn,"string"),st.a.createElement(Zt,Object.assign({type_name:"string"},Wt)),st.a.createElement("span",Object.assign({className:"string-value"},tn,{onClick:this.toggleCollapsed}),'"',un,'"'))}}]),Rt}(st.a.PureComponent),gn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){return st.a.createElement("div",Bt(this.props.theme,"undefined"),"undefined")}}]),Rt}(st.a.PureComponent);function Ln(){return(Ln=Object.assign||function(jt){for(var Nt=1;Nt=0||(Hn[mr]=or[mr]);return Hn}(jt,["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"]),Gn,er=xn.value!==void 0,tr=Object(gt.useRef)(null),ir=Zn(tr,Nt),Kn=Object(gt.useRef)(0),rr=Object(gt.useRef)(),ur=function(){var or=tr.current,yr=Rt&&rr.current?rr.current:function(hr){var lr=window.getComputedStyle(hr);if(lr===null)return null;var sr,dr=(sr=lr,Tn.reduce(function(Mr,Ir){return Mr[Ir]=sr[Ir],Mr},{})),Ar=dr.boxSizing;return Ar===""?null:(Kt&&Ar==="border-box"&&(dr.width=parseFloat(dr.width)+parseFloat(dr.borderRightWidth)+parseFloat(dr.borderLeftWidth)+parseFloat(dr.paddingRight)+parseFloat(dr.paddingLeft)+"px"),{sizingStyle:dr,paddingSize:parseFloat(dr.paddingBottom)+parseFloat(dr.paddingTop),borderSize:parseFloat(dr.borderBottomWidth)+parseFloat(dr.borderTopWidth)})}(or);if(yr){rr.current=yr;var mr=function(hr,lr,sr,dr){sr===void 0&&(sr=1),dr===void 0&&(dr=1/0),Fn||((Fn=document.createElement("textarea")).setAttribute("tab-index","-1"),Fn.setAttribute("aria-hidden","true"),Wn(Fn)),Fn.parentNode===null&&document.body.appendChild(Fn);var Ar=hr.paddingSize,Mr=hr.borderSize,Ir=hr.sizingStyle,jr=Ir.boxSizing;Object.keys(Ir).forEach(function(Pr){var $r=Pr;Fn.style[$r]=Ir[$r]}),Wn(Fn),Fn.value=lr;var pn=function(Pr,$r){var Wr=Pr.scrollHeight;return $r.sizingStyle.boxSizing==="border-box"?Wr+$r.borderSize:Wr-$r.paddingSize}(Fn,hr);Fn.value="x";var Lr=Fn.scrollHeight-Ar,Fr=Lr*sr;jr==="border-box"&&(Fr=Fr+Ar+Mr),pn=Math.max(Fr,pn);var Dr=Lr*dr;return jr==="border-box"&&(Dr=Dr+Ar+Mr),[pn=Math.min(Dr,pn),Lr]}(yr,or.value||or.placeholder||"x",Pt,Wt),Pn=mr[0],Hn=mr[1];Kn.current!==Pn&&(Kn.current=Pn,or.style.setProperty("height",Pn+"px","important"),Gt(Pn,{rowHeight:Hn}))}};return Object(gt.useLayoutEffect)(ur),Gn=Un(ur),Object(gt.useLayoutEffect)(function(){var or=function(yr){Gn.current(yr)};return window.addEventListener("resize",or),function(){window.removeEventListener("resize",or)}},[]),Object(gt.createElement)("textarea",Ln({},xn,{onChange:function(or){er||ur(),un(or)},ref:ir}))},pt=Object(gt.forwardRef)(bt);function yt(jt){jt=jt.trim();try{if((jt=JSON.stringify(JSON.parse(jt)))[0]==="[")return Ut("array",JSON.parse(jt));if(jt[0]==="{")return Ut("object",JSON.parse(jt));if(jt.match(/\-?\d+\.\d+/)&&jt.match(/\-?\d+\.\d+/)[0]===jt)return Ut("float",parseFloat(jt));if(jt.match(/\-?\d+e-\d+/)&&jt.match(/\-?\d+e-\d+/)[0]===jt)return Ut("float",Number(jt));if(jt.match(/\-?\d+/)&&jt.match(/\-?\d+/)[0]===jt)return Ut("integer",parseInt(jt));if(jt.match(/\-?\d+e\+\d+/)&&jt.match(/\-?\d+e\+\d+/)[0]===jt)return Ut("integer",Number(jt))}catch{}switch(jt=jt.toLowerCase()){case"undefined":return Ut("undefined",void 0);case"nan":return Ut("nan",NaN);case"null":return Ut("null",null);case"true":return Ut("boolean",!0);case"false":return Ut("boolean",!1);default:if(jt=Date.parse(jt))return Ut("date",new Date(jt))}return Ut(!1,null)}function Ut(jt,Nt){return{type:jt,value:Nt}}var sn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 24 24",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("path",{d:"M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M7,13H17V11H7"})))}}]),Rt}(st.a.PureComponent),ln=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 24 24",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("path",{d:"M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M13,7H11V11H7V13H11V17H13V13H17V11H13V7Z"})))}}]),Rt}(st.a.PureComponent),mn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]),un=pr(Pt).style;return st.a.createElement("span",hn,st.a.createElement("svg",{fill:un.color,width:un.height,height:un.width,style:un,viewBox:"0 0 1792 1792"},st.a.createElement("path",{d:"M1344 800v64q0 14-9 23t-23 9h-832q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h832q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"})))}}]),Rt}(st.a.PureComponent),Qn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]),un=pr(Pt).style;return st.a.createElement("span",hn,st.a.createElement("svg",{fill:un.color,width:un.height,height:un.width,style:un,viewBox:"0 0 1792 1792"},st.a.createElement("path",{d:"M1344 800v64q0 14-9 23t-23 9h-352v352q0 14-9 23t-23 9h-64q-14 0-23-9t-9-23v-352h-352q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h352v-352q0-14 9-23t23-9h64q14 0 23 9t9 23v352h352q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"})))}}]),Rt}(st.a.PureComponent),Rn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",{style:rt(rt({},pr(Pt).style),{},{paddingLeft:"2px",verticalAlign:"top"}),viewBox:"0 0 15 15",fill:"currentColor"},st.a.createElement("path",{d:"M0 14l6-6-6-6z"})))}}]),Rt}(st.a.PureComponent),Jn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",{style:rt(rt({},pr(Pt).style),{},{paddingLeft:"2px",verticalAlign:"top"}),viewBox:"0 0 15 15",fill:"currentColor"},st.a.createElement("path",{d:"M0 5l6 6 6-6z"})))}}]),Rt}(st.a.PureComponent),Nn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m30 35h-25v-22.5h25v7.5h2.5v-12.5c0-1.4-1.1-2.5-2.5-2.5h-7.5c0-2.8-2.2-5-5-5s-5 2.2-5 5h-7.5c-1.4 0-2.5 1.1-2.5 2.5v27.5c0 1.4 1.1 2.5 2.5 2.5h25c1.4 0 2.5-1.1 2.5-2.5v-5h-2.5v5z m-20-27.5h2.5s2.5-1.1 2.5-2.5 1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5 1.3 2.5 2.5 2.5h2.5s2.5 1.1 2.5 2.5h-20c0-1.5 1.1-2.5 2.5-2.5z m-2.5 20h5v-2.5h-5v2.5z m17.5-5v-5l-10 7.5 10 7.5v-5h12.5v-5h-12.5z m-17.5 10h7.5v-2.5h-7.5v2.5z m12.5-17.5h-12.5v2.5h12.5v-2.5z m-7.5 5h-5v2.5h5v-2.5z"}))))}}]),Rt}(st.a.PureComponent),ar=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m28.6 25q0-0.5-0.4-1l-4-4 4-4q0.4-0.5 0.4-1 0-0.6-0.4-1.1l-2-2q-0.4-0.4-1-0.4-0.6 0-1 0.4l-4.1 4.1-4-4.1q-0.4-0.4-1-0.4-0.6 0-1 0.4l-2 2q-0.5 0.5-0.5 1.1 0 0.5 0.5 1l4 4-4 4q-0.5 0.5-0.5 1 0 0.7 0.5 1.1l2 2q0.4 0.4 1 0.4 0.6 0 1-0.4l4-4.1 4.1 4.1q0.4 0.4 1 0.4 0.6 0 1-0.4l2-2q0.4-0.4 0.4-1z m8.7-5q0 4.7-2.3 8.6t-6.3 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3 8.6 2.3 6.3 6.2 2.3 8.6z"}))))}}]),Rt}(st.a.PureComponent),Xn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m30.1 21.4v-2.8q0-0.6-0.4-1t-1-0.5h-5.7v-5.7q0-0.6-0.4-1t-1-0.4h-2.9q-0.6 0-1 0.4t-0.4 1v5.7h-5.7q-0.6 0-1 0.5t-0.5 1v2.8q0 0.6 0.5 1t1 0.5h5.7v5.7q0 0.5 0.4 1t1 0.4h2.9q0.6 0 1-0.4t0.4-1v-5.7h5.7q0.6 0 1-0.5t0.4-1z m7.2-1.4q0 4.7-2.3 8.6t-6.3 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3 8.6 2.3 6.3 6.2 2.3 8.6z"}))))}}]),Rt}(st.a.PureComponent),qn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m31.6 21.6h-10v10h-3.2v-10h-10v-3.2h10v-10h3.2v10h10v3.2z"}))))}}]),Rt}(st.a.PureComponent),fr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m19.8 26.4l2.6-2.6-3.4-3.4-2.6 2.6v1.3h2.2v2.1h1.2z m9.8-16q-0.3-0.4-0.7 0l-7.8 7.8q-0.4 0.4 0 0.7t0.7 0l7.8-7.8q0.4-0.4 0-0.7z m1.8 13.2v4.3q0 2.6-1.9 4.5t-4.5 1.9h-18.6q-2.6 0-4.5-1.9t-1.9-4.5v-18.6q0-2.7 1.9-4.6t4.5-1.8h18.6q1.4 0 2.6 0.5 0.3 0.2 0.4 0.5 0.1 0.4-0.2 0.7l-1.1 1.1q-0.3 0.3-0.7 0.1-0.5-0.1-1-0.1h-18.6q-1.4 0-2.5 1.1t-1 2.5v18.6q0 1.4 1 2.5t2.5 1h18.6q1.5 0 2.5-1t1.1-2.5v-2.9q0-0.2 0.2-0.4l1.4-1.5q0.3-0.3 0.8-0.1t0.4 0.6z m-2.1-16.5l6.4 6.5-15 15h-6.4v-6.5z m9.9 3l-2.1 2-6.4-6.4 2.1-2q0.6-0.7 1.5-0.7t1.5 0.7l3.4 3.4q0.6 0.6 0.6 1.5t-0.6 1.5z"}))))}}]),Rt}(st.a.PureComponent),cr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m31.7 16.4q0-0.6-0.4-1l-2.1-2.1q-0.4-0.4-1-0.4t-1 0.4l-9.1 9.1-5-5q-0.5-0.4-1-0.4t-1 0.4l-2.1 2q-0.4 0.4-0.4 1 0 0.6 0.4 1l8.1 8.1q0.4 0.4 1 0.4 0.6 0 1-0.4l12.2-12.1q0.4-0.4 0.4-1z m5.6 3.6q0 4.7-2.3 8.6t-6.3 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3 8.6 2.3 6.3 6.2 2.3 8.6z"}))))}}]),Rt}(st.a.PureComponent);function pr(jt){return jt||(jt={}),{style:rt(rt({verticalAlign:"middle"},jt),{},{color:jt.color?jt.color:"#000000",height:"1em",width:"1em"})}}var xr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;return nt(this,Rt),(Pt=Nt.call(this,Wt)).copiedTimer=null,Pt.handleCopy=function(){var hn=document.createElement("textarea"),un=Pt.props,tn=un.clickCallback,Gt=un.src,xn=un.namespace;hn.innerHTML=JSON.stringify(Pt.clipboardValue(Gt),null," "),document.body.appendChild(hn),hn.select(),document.execCommand("copy"),document.body.removeChild(hn),Pt.copiedTimer=setTimeout(function(){Pt.setState({copied:!1})},5500),Pt.setState({copied:!0},function(){typeof tn=="function"&&tn({src:Gt,namespace:xn,name:xn[xn.length-1]})})},Pt.getClippyIcon=function(){var hn=Pt.props.theme;return Pt.state.copied?st.a.createElement("span",null,st.a.createElement(Nn,Object.assign({className:"copy-icon"},Bt(hn,"copy-icon"))),st.a.createElement("span",Bt(hn,"copy-icon-copied"),"✔")):st.a.createElement(Nn,Object.assign({className:"copy-icon"},Bt(hn,"copy-icon")))},Pt.clipboardValue=function(hn){switch(Ct(hn)){case"function":case"regexp":return hn.toString();default:return hn}},Pt.state={copied:!1},Pt}return at(Rt,[{key:"componentWillUnmount",value:function(){this.copiedTimer&&(clearTimeout(this.copiedTimer),this.copiedTimer=null)}},{key:"render",value:function(){var Wt=this.props,Pt=(Wt.src,Wt.theme),hn=Wt.hidden,un=Wt.rowHovered,tn=Bt(Pt,"copy-to-clipboard").style,Gt="inline";return hn&&(Gt="none"),st.a.createElement("span",{className:"copy-to-clipboard-container",title:"Copy to clipboard",style:{verticalAlign:"top",display:un?"inline-block":"none"}},st.a.createElement("span",{style:rt(rt({},tn),{},{display:Gt}),onClick:this.handleCopy},this.getClippyIcon()))}}]),Rt}(st.a.PureComponent),kr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;return nt(this,Rt),(Pt=Nt.call(this,Wt)).getEditIcon=function(){var hn=Pt.props,un=hn.variable,tn=hn.theme;return st.a.createElement("div",{className:"click-to-edit",style:{verticalAlign:"top",display:Pt.state.hovered?"inline-block":"none"}},st.a.createElement(fr,Object.assign({className:"click-to-edit-icon"},Bt(tn,"editVarIcon"),{onClick:function(){Pt.prepopInput(un)}})))},Pt.prepopInput=function(hn){if(Pt.props.onEdit!==!1){var un=function(Gt){var xn;switch(Ct(Gt)){case"undefined":xn="undefined";break;case"nan":xn="NaN";break;case"string":xn=Gt;break;case"date":case"function":case"regexp":xn=Gt.toString();break;default:try{xn=JSON.stringify(Gt,null," ")}catch{xn=""}}return xn}(hn.value),tn=yt(un);Pt.setState({editMode:!0,editValue:un,parsedInput:{type:tn.type,value:tn.value}})}},Pt.getRemoveIcon=function(){var hn=Pt.props,un=hn.variable,tn=hn.namespace,Gt=hn.theme,xn=hn.rjvId;return st.a.createElement("div",{className:"click-to-remove",style:{verticalAlign:"top",display:Pt.state.hovered?"inline-block":"none"}},st.a.createElement(ar,Object.assign({className:"click-to-remove-icon"},Bt(Gt,"removeVarIcon"),{onClick:function(){Bn.dispatch({name:"VARIABLE_REMOVED",rjvId:xn,data:{name:un.name,namespace:tn,existing_value:un.value,variable_removed:!0}})}})))},Pt.getValue=function(hn,un){var tn=!un&&hn.type,Gt=ft(Pt).props;switch(tn){case!1:return Pt.getEditInput();case"string":return st.a.createElement(En,Object.assign({value:hn.value},Gt));case"integer":return st.a.createElement(kn,Object.assign({value:hn.value},Gt));case"float":return st.a.createElement(Qt,Object.assign({value:hn.value},Gt));case"boolean":return st.a.createElement(rn,Object.assign({value:hn.value},Gt));case"function":return st.a.createElement(An,Object.assign({value:hn.value},Gt));case"null":return st.a.createElement(In,Gt);case"nan":return st.a.createElement(yn,Gt);case"undefined":return st.a.createElement(gn,Gt);case"date":return st.a.createElement(nn,Object.assign({value:hn.value},Gt));case"regexp":return st.a.createElement(vn,Object.assign({value:hn.value},Gt));default:return st.a.createElement("div",{className:"object-value"},JSON.stringify(hn.value))}},Pt.getEditInput=function(){var hn=Pt.props.theme,un=Pt.state.editValue;return st.a.createElement("div",null,st.a.createElement(pt,Object.assign({type:"text",inputRef:function(tn){return tn&&tn.focus()},value:un,className:"variable-editor",onChange:function(tn){var Gt=tn.target.value,xn=yt(Gt);Pt.setState({editValue:Gt,parsedInput:{type:xn.type,value:xn.value}})},onKeyDown:function(tn){switch(tn.key){case"Escape":Pt.setState({editMode:!1,editValue:""});break;case"Enter":(tn.ctrlKey||tn.metaKey)&&Pt.submitEdit(!0)}tn.stopPropagation()},placeholder:"update this value",minRows:2},Bt(hn,"edit-input"))),st.a.createElement("div",Bt(hn,"edit-icon-container"),st.a.createElement(ar,Object.assign({className:"edit-cancel"},Bt(hn,"cancel-icon"),{onClick:function(){Pt.setState({editMode:!1,editValue:""})}})),st.a.createElement(cr,Object.assign({className:"edit-check string-value"},Bt(hn,"check-icon"),{onClick:function(){Pt.submitEdit()}})),st.a.createElement("div",null,Pt.showDetected())))},Pt.submitEdit=function(hn){var un=Pt.props,tn=un.variable,Gt=un.namespace,xn=un.rjvId,Gn=Pt.state,er=Gn.editValue,tr=Gn.parsedInput,ir=er;hn&&tr.type&&(ir=tr.value),Pt.setState({editMode:!1}),Bn.dispatch({name:"VARIABLE_UPDATED",rjvId:xn,data:{name:tn.name,namespace:Gt,existing_value:tn.value,new_value:ir,variable_removed:!1}})},Pt.showDetected=function(){var hn=Pt.props,un=hn.theme,tn=(hn.variable,hn.namespace,hn.rjvId,Pt.state.parsedInput),Gt=(tn.type,tn.value,Pt.getDetectedInput());if(Gt)return st.a.createElement("div",null,st.a.createElement("div",Bt(un,"detected-row"),Gt,st.a.createElement(cr,{className:"edit-check detected",style:rt({verticalAlign:"top",paddingLeft:"3px"},Bt(un,"check-icon").style),onClick:function(){Pt.submitEdit(!0)}})))},Pt.getDetectedInput=function(){var hn=Pt.state.parsedInput,un=hn.type,tn=hn.value,Gt=ft(Pt).props,xn=Gt.theme;if(un!==!1)switch(un.toLowerCase()){case"object":return st.a.createElement("span",null,st.a.createElement("span",{style:rt(rt({},Bt(xn,"brace").style),{},{cursor:"default"})},"{"),st.a.createElement("span",{style:rt(rt({},Bt(xn,"ellipsis").style),{},{cursor:"default"})},"..."),st.a.createElement("span",{style:rt(rt({},Bt(xn,"brace").style),{},{cursor:"default"})},"}"));case"array":return st.a.createElement("span",null,st.a.createElement("span",{style:rt(rt({},Bt(xn,"brace").style),{},{cursor:"default"})},"["),st.a.createElement("span",{style:rt(rt({},Bt(xn,"ellipsis").style),{},{cursor:"default"})},"..."),st.a.createElement("span",{style:rt(rt({},Bt(xn,"brace").style),{},{cursor:"default"})},"]"));case"string":return st.a.createElement(En,Object.assign({value:tn},Gt));case"integer":return st.a.createElement(kn,Object.assign({value:tn},Gt));case"float":return st.a.createElement(Qt,Object.assign({value:tn},Gt));case"boolean":return st.a.createElement(rn,Object.assign({value:tn},Gt));case"function":return st.a.createElement(An,Object.assign({value:tn},Gt));case"null":return st.a.createElement(In,Gt);case"nan":return st.a.createElement(yn,Gt);case"undefined":return st.a.createElement(gn,Gt);case"date":return st.a.createElement(nn,Object.assign({value:new Date(tn)},Gt))}},Pt.state={editMode:!1,editValue:"",hovered:!1,renameKey:!1,parsedInput:{type:!1,value:null}},Pt}return at(Rt,[{key:"render",value:function(){var Wt=this,Pt=this.props,hn=Pt.variable,un=Pt.singleIndent,tn=Pt.type,Gt=Pt.theme,xn=Pt.namespace,Gn=Pt.indentWidth,er=Pt.enableClipboard,tr=Pt.onEdit,ir=Pt.onDelete,Kn=Pt.onSelect,rr=Pt.displayArrayKey,ur=Pt.quotesOnKeys,or=this.state.editMode;return st.a.createElement("div",Object.assign({},Bt(Gt,"objectKeyVal",{paddingLeft:Gn*un}),{onMouseEnter:function(){return Wt.setState(rt(rt({},Wt.state),{},{hovered:!0}))},onMouseLeave:function(){return Wt.setState(rt(rt({},Wt.state),{},{hovered:!1}))},className:"variable-row",key:hn.name}),tn=="array"?rr?st.a.createElement("span",Object.assign({},Bt(Gt,"array-key"),{key:hn.name+"_"+xn}),hn.name,st.a.createElement("div",Bt(Gt,"colon"),":")):null:st.a.createElement("span",null,st.a.createElement("span",Object.assign({},Bt(Gt,"object-name"),{className:"object-key",key:hn.name+"_"+xn}),!!ur&&st.a.createElement("span",{style:{verticalAlign:"top"}},'"'),st.a.createElement("span",{style:{display:"inline-block"}},hn.name),!!ur&&st.a.createElement("span",{style:{verticalAlign:"top"}},'"')),st.a.createElement("span",Bt(Gt,"colon"),":")),st.a.createElement("div",Object.assign({className:"variable-value",onClick:Kn===!1&&tr===!1?null:function(yr){var mr=On(xn);(yr.ctrlKey||yr.metaKey)&&tr!==!1?Wt.prepopInput(hn):Kn!==!1&&(mr.shift(),Kn(rt(rt({},hn),{},{namespace:mr})))}},Bt(Gt,"variableValue",{cursor:Kn===!1?"default":"pointer"})),this.getValue(hn,or)),er?st.a.createElement(xr,{rowHovered:this.state.hovered,hidden:or,src:hn.value,clickCallback:er,theme:Gt,namespace:[].concat(On(xn),[hn.name])}):null,tr!==!1&&or==0?this.getEditIcon():null,ir!==!1&&or==0?this.getRemoveIcon():null)}}]),Rt}(st.a.PureComponent),Tr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){var Wt;nt(this,Rt);for(var Pt=arguments.length,hn=new Array(Pt),un=0;un0?er:null,namespace:Gn.splice(0,Gn.length-1),existing_value:tr,variable_removed:!1,key_name:null};Ct(tr)==="object"?Bn.dispatch({name:"ADD_VARIABLE_KEY_REQUEST",rjvId:ir,data:rr}):Bn.dispatch({name:"VARIABLE_ADDED",rjvId:ir,data:rt(rt({},rr),{},{new_value:[].concat(On(tr),[null])})})}})))},Wt.getRemoveObject=function(tn){var Gt=Wt.props,xn=Gt.theme,Gn=(Gt.hover,Gt.namespace),er=Gt.name,tr=Gt.src,ir=Gt.rjvId;if(Gn.length!==1)return st.a.createElement("span",{className:"click-to-remove",style:{display:tn?"inline-block":"none"}},st.a.createElement(ar,Object.assign({className:"click-to-remove-icon"},Bt(xn,"removeVarIcon"),{onClick:function(){Bn.dispatch({name:"VARIABLE_REMOVED",rjvId:ir,data:{name:er,namespace:Gn.splice(0,Gn.length-1),existing_value:tr,variable_removed:!0}})}})))},Wt.render=function(){var tn=Wt.props,Gt=tn.theme,xn=tn.onDelete,Gn=tn.onAdd,er=tn.enableClipboard,tr=tn.src,ir=tn.namespace,Kn=tn.rowHovered;return st.a.createElement("div",Object.assign({},Bt(Gt,"object-meta-data"),{className:"object-meta-data",onClick:function(rr){rr.stopPropagation()}}),Wt.getObjectSize(),er?st.a.createElement(xr,{rowHovered:Kn,clickCallback:er,src:tr,theme:Gt,namespace:ir}):null,Gn!==!1?Wt.getAddAttribute(Kn):null,xn!==!1?Wt.getRemoveObject(Kn):null)},Wt}return Rt}(st.a.PureComponent);function Br(jt){var Nt=jt.parent_type,Rt=jt.namespace,Wt=jt.quotesOnKeys,Pt=jt.theme,hn=jt.jsvRoot,un=jt.name,tn=jt.displayArrayKey,Gt=jt.name?jt.name:"";return!hn||un!==!1&&un!==null?Nt=="array"?tn?st.a.createElement("span",Object.assign({},Bt(Pt,"array-key"),{key:Rt}),st.a.createElement("span",{className:"array-key"},Gt),st.a.createElement("span",Bt(Pt,"colon"),":")):st.a.createElement("span",null):st.a.createElement("span",Object.assign({},Bt(Pt,"object-name"),{key:Rt}),st.a.createElement("span",{className:"object-key"},Wt&&st.a.createElement("span",{style:{verticalAlign:"top"}},'"'),st.a.createElement("span",null,Gt),Wt&&st.a.createElement("span",{style:{verticalAlign:"top"}},'"')),st.a.createElement("span",Bt(Pt,"colon"),":")):st.a.createElement("span",null)}function Rr(jt){var Nt=jt.theme;switch(jt.iconStyle){case"triangle":return st.a.createElement(Jn,Object.assign({},Bt(Nt,"expanded-icon"),{className:"expanded-icon"}));case"square":return st.a.createElement(mn,Object.assign({},Bt(Nt,"expanded-icon"),{className:"expanded-icon"}));default:return st.a.createElement(sn,Object.assign({},Bt(Nt,"expanded-icon"),{className:"expanded-icon"}))}}function Ur(jt){var Nt=jt.theme;switch(jt.iconStyle){case"triangle":return st.a.createElement(Rn,Object.assign({},Bt(Nt,"collapsed-icon"),{className:"collapsed-icon"}));case"square":return st.a.createElement(Qn,Object.assign({},Bt(Nt,"collapsed-icon"),{className:"collapsed-icon"}));default:return st.a.createElement(ln,Object.assign({},Bt(Nt,"collapsed-icon"),{className:"collapsed-icon"}))}}var Qr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;return nt(this,Rt),(Pt=Nt.call(this,Wt)).toggleCollapsed=function(hn){var un=[];for(var tn in Pt.state.expanded)un.push(Pt.state.expanded[tn]);un[hn]=!un[hn],Pt.setState({expanded:un})},Pt.state={expanded:[]},Pt}return at(Rt,[{key:"getExpandedIcon",value:function(Wt){var Pt=this.props,hn=Pt.theme,un=Pt.iconStyle;return this.state.expanded[Wt]?st.a.createElement(Rr,{theme:hn,iconStyle:un}):st.a.createElement(Ur,{theme:hn,iconStyle:un})}},{key:"render",value:function(){var Wt=this,Pt=this.props,hn=Pt.src,un=Pt.groupArraysAfterLength,tn=(Pt.depth,Pt.name),Gt=Pt.theme,xn=Pt.jsvRoot,Gn=Pt.namespace,er=(Pt.parent_type,kt(Pt,["src","groupArraysAfterLength","depth","name","theme","jsvRoot","namespace","parent_type"])),tr=0,ir=5*this.props.indentWidth;xn||(tr=5*this.props.indentWidth);var Kn=un,rr=Math.ceil(hn.length/Kn);return st.a.createElement("div",Object.assign({className:"object-key-val"},Bt(Gt,xn?"jsv-root":"objectKeyVal",{paddingLeft:tr})),st.a.createElement(Br,this.props),st.a.createElement("span",null,st.a.createElement(Tr,Object.assign({size:hn.length},this.props))),On(Array(rr)).map(function(ur,or){return st.a.createElement("div",Object.assign({key:or,className:"object-key-val array-group"},Bt(Gt,"objectKeyVal",{marginLeft:6,paddingLeft:ir})),st.a.createElement("span",Bt(Gt,"brace-row"),st.a.createElement("div",Object.assign({className:"icon-container"},Bt(Gt,"icon-container"),{onClick:function(yr){Wt.toggleCollapsed(or)}}),Wt.getExpandedIcon(or)),Wt.state.expanded[or]?st.a.createElement(St,Object.assign({key:tn+or,depth:0,name:!1,collapsed:!1,groupArraysAfterLength:Kn,index_offset:or*Kn,src:hn.slice(or*Kn,or*Kn+Kn),namespace:Gn,type:"array",parent_type:"array_group",theme:Gt},er)):st.a.createElement("span",Object.assign({},Bt(Gt,"brace"),{onClick:function(yr){Wt.toggleCollapsed(or)},className:"array-group-brace"}),"[",st.a.createElement("div",Object.assign({},Bt(Gt,"array-group-meta-data"),{className:"array-group-meta-data"}),st.a.createElement("span",Object.assign({className:"object-size"},Bt(Gt,"object-size")),or*Kn," - ",or*Kn+Kn>hn.length?hn.length:or*Kn+Kn)),"]")))}))}}]),Rt}(st.a.PureComponent),Zr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;nt(this,Rt),(Pt=Nt.call(this,Wt)).toggleCollapsed=function(){Pt.setState({expanded:!Pt.state.expanded},function(){dn.set(Pt.props.rjvId,Pt.props.namespace,"expanded",Pt.state.expanded)})},Pt.getObjectContent=function(un,tn,Gt){return st.a.createElement("div",{className:"pushed-content object-container"},st.a.createElement("div",Object.assign({className:"object-content"},Bt(Pt.props.theme,"pushed-content")),Pt.renderObjectContents(tn,Gt)))},Pt.getEllipsis=function(){return Pt.state.size===0?null:st.a.createElement("div",Object.assign({},Bt(Pt.props.theme,"ellipsis"),{className:"node-ellipsis",onClick:Pt.toggleCollapsed}),"...")},Pt.getObjectMetaData=function(un){var tn=Pt.props,Gt=(tn.rjvId,tn.theme,Pt.state),xn=Gt.size,Gn=Gt.hovered;return st.a.createElement(Tr,Object.assign({rowHovered:Gn,size:xn},Pt.props))},Pt.renderObjectContents=function(un,tn){var Gt,xn=Pt.props,Gn=xn.depth,er=xn.parent_type,tr=xn.index_offset,ir=xn.groupArraysAfterLength,Kn=xn.namespace,rr=Pt.state.object_type,ur=[],or=Object.keys(un||{});return Pt.props.sortKeys&&rr!=="array"&&(or=or.sort()),or.forEach(function(yr){if(Gt=new mo(yr,un[yr]),er==="array_group"&&tr&&(Gt.name=parseInt(Gt.name)+tr),un.hasOwnProperty(yr))if(Gt.type==="object")ur.push(st.a.createElement(St,Object.assign({key:Gt.name,depth:Gn+1,name:Gt.name,src:Gt.value,namespace:Kn.concat(Gt.name),parent_type:rr},tn)));else if(Gt.type==="array"){var mr=St;ir&&Gt.value.length>ir&&(mr=Qr),ur.push(st.a.createElement(mr,Object.assign({key:Gt.name,depth:Gn+1,name:Gt.name,src:Gt.value,namespace:Kn.concat(Gt.name),type:"array",parent_type:rr},tn)))}else ur.push(st.a.createElement(kr,Object.assign({key:Gt.name+"_"+Kn,variable:Gt,singleIndent:5,namespace:Kn,type:Pt.props.type},tn)))}),ur};var hn=Rt.getState(Wt);return Pt.state=rt(rt({},hn),{},{prevProps:{}}),Pt}return at(Rt,[{key:"getBraceStart",value:function(Wt,Pt){var hn=this,un=this.props,tn=un.src,Gt=un.theme,xn=un.iconStyle;if(un.parent_type==="array_group")return st.a.createElement("span",null,st.a.createElement("span",Bt(Gt,"brace"),Wt==="array"?"[":"{"),Pt?this.getObjectMetaData(tn):null);var Gn=Pt?Rr:Ur;return st.a.createElement("span",null,st.a.createElement("span",Object.assign({onClick:function(er){hn.toggleCollapsed()}},Bt(Gt,"brace-row")),st.a.createElement("div",Object.assign({className:"icon-container"},Bt(Gt,"icon-container")),st.a.createElement(Gn,{theme:Gt,iconStyle:xn})),st.a.createElement(Br,this.props),st.a.createElement("span",Bt(Gt,"brace"),Wt==="array"?"[":"{")),Pt?this.getObjectMetaData(tn):null)}},{key:"render",value:function(){var Wt=this,Pt=this.props,hn=Pt.depth,un=Pt.src,tn=(Pt.namespace,Pt.name,Pt.type,Pt.parent_type),Gt=Pt.theme,xn=Pt.jsvRoot,Gn=Pt.iconStyle,er=kt(Pt,["depth","src","namespace","name","type","parent_type","theme","jsvRoot","iconStyle"]),tr=this.state,ir=tr.object_type,Kn=tr.expanded,rr={};return xn||tn==="array_group"?tn==="array_group"&&(rr.borderLeft=0,rr.display="inline"):rr.paddingLeft=5*this.props.indentWidth,st.a.createElement("div",Object.assign({className:"object-key-val",onMouseEnter:function(){return Wt.setState(rt(rt({},Wt.state),{},{hovered:!0}))},onMouseLeave:function(){return Wt.setState(rt(rt({},Wt.state),{},{hovered:!1}))}},Bt(Gt,xn?"jsv-root":"objectKeyVal",rr)),this.getBraceStart(ir,Kn),Kn?this.getObjectContent(hn,un,rt({theme:Gt,iconStyle:Gn},er)):this.getEllipsis(),st.a.createElement("span",{className:"brace-row"},st.a.createElement("span",{style:rt(rt({},Bt(Gt,"brace").style),{},{paddingLeft:Kn?"3px":"0px"})},ir==="array"?"]":"}"),Kn?null:this.getObjectMetaData(un)))}}],[{key:"getDerivedStateFromProps",value:function(Wt,Pt){var hn=Pt.prevProps;return Wt.src!==hn.src||Wt.collapsed!==hn.collapsed||Wt.name!==hn.name||Wt.namespace!==hn.namespace||Wt.rjvId!==hn.rjvId?rt(rt({},Rt.getState(Wt)),{},{prevProps:Wt}):null}}]),Rt}(st.a.PureComponent);Zr.getState=function(jt){var Nt=Object.keys(jt.src).length,Rt=(jt.collapsed===!1||jt.collapsed!==!0&&jt.collapsed>jt.depth)&&(!jt.shouldCollapse||jt.shouldCollapse({name:jt.name,src:jt.src,type:Ct(jt.src),namespace:jt.namespace})===!1)&&Nt!==0;return{expanded:dn.get(jt.rjvId,jt.namespace,"expanded",Rt),object_type:jt.type==="array"?"array":"object",parent_type:jt.type==="array"?"array":"object",size:Nt,hovered:!1}};var mo=function jt(Nt,Rt){nt(this,jt),this.name=Nt,this.value=Rt,this.type=Ct(Rt)};Mt(Zr);var St=Zr,Dt=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){var Wt;nt(this,Rt);for(var Pt=arguments.length,hn=new Array(Pt),un=0;untn.groupArraysAfterLength&&(xn=Qr),st.a.createElement("div",{className:"pretty-json-container object-container"},st.a.createElement("div",{className:"object-content"},st.a.createElement(xn,Object.assign({namespace:Gt,depth:0,jsvRoot:!0},tn))))},Wt}return Rt}(st.a.PureComponent),$t=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;return nt(this,Rt),(Pt=Nt.call(this,Wt)).closeModal=function(){Bn.dispatch({rjvId:Pt.props.rjvId,name:"RESET"})},Pt.submit=function(){Pt.props.submit(Pt.state.input)},Pt.state={input:Wt.input?Wt.input:""},Pt}return at(Rt,[{key:"render",value:function(){var Wt=this,Pt=this.props,hn=Pt.theme,un=Pt.rjvId,tn=Pt.isValid,Gt=this.state.input,xn=tn(Gt);return st.a.createElement("div",Object.assign({className:"key-modal-request"},Bt(hn,"key-modal-request"),{onClick:this.closeModal}),st.a.createElement("div",Object.assign({},Bt(hn,"key-modal"),{onClick:function(Gn){Gn.stopPropagation()}}),st.a.createElement("div",Bt(hn,"key-modal-label"),"Key Name:"),st.a.createElement("div",{style:{position:"relative"}},st.a.createElement("input",Object.assign({},Bt(hn,"key-modal-input"),{className:"key-modal-input",ref:function(Gn){return Gn&&Gn.focus()},spellCheck:!1,value:Gt,placeholder:"...",onChange:function(Gn){Wt.setState({input:Gn.target.value})},onKeyPress:function(Gn){xn&&Gn.key==="Enter"?Wt.submit():Gn.key==="Escape"&&Wt.closeModal()}})),xn?st.a.createElement(cr,Object.assign({},Bt(hn,"key-modal-submit"),{className:"key-modal-submit",onClick:function(Gn){return Wt.submit()}})):null),st.a.createElement("span",Bt(hn,"key-modal-cancel"),st.a.createElement(qn,Object.assign({},Bt(hn,"key-modal-cancel-icon"),{className:"key-modal-cancel",onClick:function(){Bn.dispatch({rjvId:un,name:"RESET"})}})))))}}]),Rt}(st.a.PureComponent),mt=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){var Wt;nt(this,Rt);for(var Pt=arguments.length,hn=new Array(Pt),un=0;un{_($.updated_src)},[]);return jsxs("div",{className:"send-tx-form",children:[jsx$1("h3",{children:"Configure and send transaction"}),jsx$1(ReactJson,{theme:"ocean",src:defaultTx,onEdit:j,onAdd:j,onDelete:j}),d?jsx$1("button",{onClick:()=>k.sendTransaction(b),children:"Send transaction"}):jsx$1("button",{onClick:()=>k.openModal(),children:"Connect wallet to send the transaction"})]})}const footer="",style$3="",defaultColors={[THEME.LIGHT]:{constant:{black:"#000000",white:"#FFFFFF"},connectButton:{background:"#0098EA",foreground:"#FFFFFF"},accent:"#0098EA",telegramButton:"#0098EA",icon:{primary:"#0F0F0F",secondary:"#7A8999",tertiary:"#C1CAD2",success:"#29CC6A",error:"#F5A73B"},background:{primary:"#FFFFFF",secondary:"#F1F3F5",segment:"#FFFFFF",tint:"#F1F3F5",qr:"#F1F3F5"},text:{primary:"#0F0F0F",secondary:"#6A7785"}},[THEME.DARK]:{constant:{black:"#000000",white:"#FFFFFF"},connectButton:{background:"#0098EA",foreground:"#FFFFFF"},accent:"#E5E5EA",telegramButton:"#31A6F5",icon:{primary:"#E5E5EA",secondary:"#909099",tertiary:"#434347",success:"#29CC6A",error:"#F5A73B"},background:{primary:"#121214",secondary:"#18181A",segment:"#262629",tint:"#222224",qr:"#F1F3F5"},text:{primary:"#E5E5EA",secondary:"#7D7D85"}}},ColorsSelect=({theme:b})=>{const[_,d]=useTonConnectUI(),[k,j]=reactExports.useState(defaultColors[b]);reactExports.useEffect(()=>{j(defaultColors[b])},[b]);const $=(et,tt,rt)=>{d({uiPreferences:{colorsSet:{[b]:{[tt]:rt?{...k[tt],[rt]:et}:et}}}}),j(nt=>({...nt,[tt]:rt?{...nt[tt],[rt]:et}:et})),defaultColors[b]={...defaultColors[b],[tt]:rt?{...k[tt],[rt]:et}:et}};return jsx$1("div",{className:"colors-container",children:Object.entries(k).map(([et,tt])=>typeof tt=="object"?jsxs("div",{children:[jsxs("span",{children:[et,":"]}),Object.entries(tt).map(([rt,nt])=>jsxs("label",{children:[rt,jsx$1("input",{type:"color",value:k[et][rt],onChange:ot=>$(ot.target.value,et,rt)})]},et+rt))]},et):jsxs("div",{children:[jsxs("span",{children:[et,":"]}),jsx$1("label",{children:jsx$1("input",{type:"color",value:k[et],onChange:rt=>$(rt.target.value,et)})})]}))})},style$2="",ColorsModal=()=>{const[b,_]=reactExports.useState(!1),[d,k]=reactExports.useState(THEME.LIGHT);return jsxs(Fragment,{children:[jsx$1("button",{onClick:()=>_(!0),children:"change colors"}),b&&jsxs("div",{className:"modal",children:[jsx$1("button",{onClick:()=>_(!1),children:"close"}),jsxs("div",{className:"modal__toggle",children:[jsx$1("a",{href:"#",style:{color:d===THEME.LIGHT?"blue":"white"},onClick:()=>k(THEME.LIGHT),children:"LIGHT"}),jsx$1("a",{href:"#",style:{color:d===THEME.DARK?"blue":"white"},onClick:()=>k(THEME.DARK),children:"DARK"})]}),jsx$1(ColorsSelect,{theme:d})]})]})},Footer=()=>{const[b,_]=reactExports.useState([!0,!1,!1,!0,!0,!0]),[d,k]=reactExports.useState("back"),[j,$]=reactExports.useState("ios"),[et,tt]=reactExports.useState(!0),[rt,nt]=useTonConnectUI(),ot=lt=>{nt({language:lt})},at=lt=>{nt({uiPreferences:{theme:lt}})},it=lt=>{nt({uiPreferences:{borderRadius:lt}})},dt=lt=>{_(ct=>ct.map((gt,st)=>st===lt?!gt:gt))},ut=lt=>{tt(lt)},ht=()=>{if(!d){k("back");return}nt({actionsConfiguration:{returnStrategy:d}})},ft=()=>{if(!j){$("ios");return}nt({actionsConfiguration:{skipRedirectToWallet:j}})};return reactExports.useEffect(()=>{const lt=["before","success","error"],ct=lt.map((st,_t)=>b[_t]?st:void 0).filter(st=>st),gt=lt.map((st,_t)=>b[_t+3]?st:void 0).filter(st=>st);nt({actionsConfiguration:{modals:ct,notifications:gt}})},[b]),reactExports.useEffect(()=>{nt({enableAndroidBackHandler:et})},[et]),jsxs("footer",{className:"footer",children:[jsxs("div",{children:[jsx$1("label",{children:"language"}),jsxs("select",{onChange:lt=>ot(lt.target.value),children:[jsx$1("option",{value:"en",children:"en"}),jsx$1("option",{value:"ru",children:"ru"})]})]}),jsxs("div",{children:[jsx$1("label",{children:"theme"}),jsxs("select",{onChange:lt=>at(lt.target.value),children:[jsx$1("option",{value:THEME.DARK,children:"dark"}),jsx$1("option",{value:THEME.LIGHT,children:"light"}),jsx$1("option",{value:"SYSTEM",children:"system"})]})]}),jsxs("div",{children:[jsx$1("label",{children:"borders"}),jsxs("select",{onChange:lt=>it(lt.target.value),children:[jsx$1("option",{value:"m",children:"m"}),jsx$1("option",{value:"s",children:"s"}),jsx$1("option",{value:"none",children:"none"})]})]}),jsxs("div",{children:[jsx$1("label",{children:"enable android back handler"}),jsxs("select",{onChange:lt=>ut(lt.target.value==="true"),value:et.toString(),children:[jsx$1("option",{value:"true",children:"true"}),jsx$1("option",{value:"false",children:"false"})]})]}),jsxs("div",{className:"footer-checkbox-container",children:[jsx$1("span",{children:"modals"}),jsxs("label",{children:["before",jsx$1("input",{type:"checkbox",checked:b[0],onChange:()=>dt(0)})]}),jsxs("label",{children:["success",jsx$1("input",{type:"checkbox",checked:b[1],onChange:()=>dt(1)})]}),jsxs("label",{children:["error",jsx$1("input",{type:"checkbox",checked:b[2],onChange:()=>dt(2)})]})]}),jsxs("div",{className:"footer-checkbox-container",children:[jsx$1("span",{children:"notifications"}),jsxs("label",{children:["before",jsx$1("input",{type:"checkbox",checked:b[3],onChange:()=>dt(3)})]}),jsxs("label",{children:["success",jsx$1("input",{type:"checkbox",checked:b[4],onChange:()=>dt(4)})]}),jsxs("label",{children:["error",jsx$1("input",{type:"checkbox",checked:b[5],onChange:()=>dt(5)})]})]}),jsx$1("div",{children:jsx$1(ColorsModal,{})}),jsx$1("div",{children:jsxs("label",{children:["return strategy:",jsx$1("input",{style:{width:"200px"},value:d,onChange:lt=>k(lt.target.value),onBlur:ht})]})}),jsx$1("div",{children:jsxs("label",{children:[jsx$1("div",{children:"skip redirect to wallet:"}),jsx$1("div",{children:"('ios', 'never', 'always')"}),jsx$1("input",{style:{width:"200px"},value:j,onChange:lt=>$(lt.target.value),onBlur:ft})]})})]})},style$1="";class TonProofDemoApiService{constructor(){Jo(this,"localStorageKey","demo-api-access-token");Jo(this,"host",document.baseURI.replace(/\/$/,""));Jo(this,"accessToken",null);Jo(this,"refreshIntervalMs",9*60*1e3);this.accessToken=localStorage.getItem(this.localStorageKey),this.accessToken||this.generatePayload()}async generatePayload(){try{return{tonProof:(await(await fetch(`${this.host}/api/generate_payload`,{method:"POST"})).json()).payload}}catch{return null}}async checkProof(_,d){try{const k={address:d.address,network:d.chain,public_key:d.publicKey,proof:{..._,state_init:d.walletStateInit}},j=await(await fetch(`${this.host}/api/check_proof`,{method:"POST",body:JSON.stringify(k)})).json();j!=null&&j.token&&(localStorage.setItem(this.localStorageKey,j.token),this.accessToken=j.token)}catch(k){console.log("checkProof error:",k)}}async getAccountInfo(_){return await(await fetch(`${this.host}/api/get_account_info`,{headers:{Authorization:`Bearer ${this.accessToken}`,"Content-Type":"application/json"}})).json()}async createJetton(_){return await(await fetch(`${this.host}/api/create_jetton`,{body:JSON.stringify(_),headers:{Authorization:`Bearer ${this.accessToken}`,"Content-Type":"application/json"},method:"POST"})).json()}reset(){this.accessToken=null,localStorage.removeItem(this.localStorageKey),this.generatePayload()}}const TonProofDemoApi=new TonProofDemoApiService;function useInterval(b,_){const d=reactExports.useRef(b);reactExports.useLayoutEffect(()=>{d.current=b},[b]),reactExports.useEffect(()=>{if(!_&&_!==0)return;const k=setInterval(()=>d.current(),_);return()=>clearInterval(k)},[_])}const TonProofDemo=()=>{const b=reactExports.useRef(!0),[_,d]=reactExports.useState({}),k=useTonWallet(),[j,$]=reactExports.useState(!1),[et]=useTonConnectUI(),tt=reactExports.useCallback(async()=>{b.current&&(et.setConnectRequestParameters({state:"loading"}),b.current=!1);const nt=await TonProofDemoApi.generatePayload();nt?et.setConnectRequestParameters({state:"ready",value:nt}):et.setConnectRequestParameters(null)},[et,b]);b.current&&tt(),useInterval(tt,TonProofDemoApi.refreshIntervalMs),reactExports.useEffect(()=>et.onStatusChange(async nt=>{var ot;if(!nt){TonProofDemoApi.reset(),$(!1);return}if((ot=nt.connectItems)!=null&&ot.tonProof&&"proof"in nt.connectItems.tonProof&&await TonProofDemoApi.checkProof(nt.connectItems.tonProof.proof,nt.account),!TonProofDemoApi.accessToken){et.disconnect(),$(!1);return}$(!0)}),[et]);const rt=reactExports.useCallback(async()=>{if(!k)return;const nt=await TonProofDemoApi.getAccountInfo(k.account);d(nt)},[k]);return j?jsxs("div",{className:"ton-proof-demo",children:[jsx$1("h3",{children:"Demo backend API with ton_proof verification"}),j?jsx$1("button",{onClick:rt,children:"Call backend getAccountInfo()"}):jsx$1("div",{className:"ton-proof-demo__error",children:"Connect wallet to call API"}),jsx$1(ReactJson,{src:_,name:"response",theme:"ocean"})]}):null},style="",jetton={name:"Joint Photographic Experts Group",description:"JPEG is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality.",image_data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAdVBMVEX///8rKytSUlITExPT09Pm5uYcHBzKysqXl5cZGRmnp6cnJydISEjr6+tOTk5LS0swMDAhISHa2tq3t7fg4OBra2sKCgrw8PB3d3dCQkJeXl49PT29vb2goKCvr68AAADOzs5jY2ODg4ONjY1wcHA2NjaSkpJ0yRZUAAAFXklEQVR4nO3de3eaMBgGcCEIxkgVCiiIVG3t9/+IS8LFS+1ERy665/ljZwW3k99yeV9x5zgaIQiCIAiCIAiCIAiCIAhiLGFQTf85iWnF7wkKQui/Z2Yt8TuLnCEyn1tKnGSD+BznzbVzFuOPgYBc6Fo5i1/DLNFa+PZmIZEMBRRC152NTYMuMx5YaN9e9IYWurYtVAVCy46b4YW27UUVQrv2ohKhVUVDidCqhapIaNFCVSW0p4FTJrSmaCgTWrMXFQot2YsqhXY0cGqFNuxFpUIrFqpioQVFQ7XQfAOnWmi+aKgXmt6LGoSG96IOodmioUNodi/qEZrci5qEBhs4bUJjs6hLaG6h6hOaKhoahYYaOI1CQ0VDq9DIXtQrNFE0dAv1HzeahQb2onah9r2oX6i7aOgX8gZO60I1INS8UI0ItTZwZoQ696IZoc6iYUqoby8aE2pr4AwKNR03Awrn9wl1LdQBhbN7hXqIAwrXdwu1FI0BhYu7hVqKxoDCByZRx0IdUsjyB4jKT9QhhY/Nouq9OKzQcQ757N4cwqcS3h+WBS8udAiEEEJoGgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQWCJmM3cIFz/F34gdCaMROb5/llEejfO6689whfb+Uz4CQlHEczyQoiD2ZIKj2efNSWjUXm8QTv/ORYrpNxstwnHhVyvoZTQi34TicS2EcjuuEYTiu6rVH3tuLza1NKyRFEHb3wtBbZX0WqwlhwAfYCGtcKAcexmvWCsNjlo2Q0c2yvtP8Ml4Ghx7TaF64X61WmyoR4962cxhWk2NS+VLmlJIWTNKiSPel/AOxe5toXpj7UeSTw7cY8affCHfE71IvRSqnNiiIHzEWRWQ9FT8nhycQ1mcOIxM+4rgVppdzQ8XtcEO76/zU4dPY42tObRE6bCF2Vs6uC9laAs++edefe4Xv3Iw1QifzuCH9RSgvBvSC3avw2yaMrgpZLia4eOibd+0RMoGYX5/DaCWm8LEO0Boh+eQ7LaHtSUOjLk5zbdJj01kpzIXCJ6u2fak1qy7iuCRbPr+7O9ptq4SrNE33E08W8AP70dMsY3GAij0664R+1uX2yjUvPOnaZu2KPG1LvYzXikRMdiv0N8su3s3Tx7ywa73LtRytFB7fXsT8gLkUTo7/BsGTCJO43BTNO8T6pHHO3x6erdJ2DsMnEYqBM+bTdvzXqoU4aY7X2KyQSZPnEZ7dviIUbTdvStsf6wcZ0fqFhKLij7cXfxfLX0jI1qLh+dHKvZDQIRWfRM85e+lrCdlBtAHv9PS17JX2Ia8Q8hlAuTj2pkw2ek8r3GW0S42ilezrVhnvyZloZNfywrMKx+W06rKpr0fvdWs33afu12ojHyyG2/xmO26p8ORpYui1NyZ1+8q78bB5pvje412+YSEf6FXhWevd3qFFuTx5Irws+zymMSwsgyC4XGf+Zhuc5b27xWix8Zq3IsG3S29PoBlhtO3WJuH5MUyfnOf0+ROj2drdpUXuE7/nG2ITnz3xNwrJ7RPit4iO1O5P1+Rzs3hxZSxqolkY+X72yetdqe+zYb3CaL/5rMRBuH/o0ecTCOl0KQuZ98toXkPIK1n9QeFLCtmuCoLyM9II1H3SMMoLnL49aEBoIBBC+N8LEwuEnlLhKLs9BMXJlmqFO72l4WfYTC1wtP0wLPwoFQtHe7M7kaaqgaPRV6//X6cmjOzUA0ej6pBR30RotpjqAPJ404mJTLeKj1EEQRAEQRAEQRAEQRAEQf6SP4jPv7WHGoGuAAAAAElFTkSuQmCC",symbol:"JPEG",decimals:9,amount:"1000000000000000"},CreateJettonDemo=()=>{const[b,_]=reactExports.useState({}),[d]=useTonConnectUI(),k=useTonWallet();return jsxs("div",{className:"create-jetton-demo",children:[jsx$1("h3",{children:"Create Jetton"}),k?jsx$1("button",{onClick:async()=>{const $=await TonProofDemoApi.createJetton(jetton);_($),"error"in $||await d.sendTransaction($)},children:"Send create jetton"}):jsx$1("div",{className:"ton-proof-demo__error",children:"Connect wallet to send transaction"}),jsx$1(ReactJson,{src:b,name:"response",theme:"ocean"})]})};function App(){return jsx$1(TonConnectUIProvider$1,{manifestUrl:"https://ton-connect.github.io/demo-dapp-with-react-ui/tonconnect-manifest.json",uiPreferences:{theme:THEME.DARK},walletsListConfiguration:{includeWallets:[{appName:"telegram-wallet",name:"Wallet",imageUrl:"https://wallet.tg/images/logo-288.png",aboutUrl:"https://wallet.tg/",universalLink:"https://t.me/wallet?attach=wallet",bridgeUrl:"https://bridge.ton.space/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"tonwallet",name:"TON Wallet",imageUrl:"https://wallet.ton.org/assets/ui/qr-logo.png",aboutUrl:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",universalLink:"https://wallet.ton.org/ton-connect",jsBridgeKey:"tonwallet",bridgeUrl:"https://bridge.tonapi.io/bridge",platforms:["chrome","android"]},{appName:"nicegramWallet",name:"Nicegram Wallet",imageUrl:"https://static.nicegram.app/icon.png",aboutUrl:"https://nicegram.app",universalLink:"https://nicegram.app/tc",deepLink:"nicegram-tc://",jsBridgeKey:"nicegramWallet",bridgeUrl:"https://tc.nicegram.app/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"tokenpocket",name:"TokenPocket",imageUrl:"https://hk.tpstatic.net/logo/tokenpocket.png",aboutUrl:"https://www.tokenpocket.pro",universalLink:"https://tp-lab.tptool.pro/ton-connect/",jsBridgeKey:"tokenpocket",bridgeUrl:"https://ton-connect.mytokenpocket.vip/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"dewallet",name:"DeWallet",imageUrl:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",aboutUrl:"https://delabwallet.com",universalLink:"https://t.me/dewallet?attach=wallet",bridgeUrl:"https://bridge.dewallet.pro/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"cdcTonWallet",name:"Crypto.com DeFi Wallet",imageUrl:"https://apro-ncw-api-file.crypto.com/wallet/logo",aboutUrl:"https://crypto.com/defi-wallet",universalLink:"https://wallet.crypto.com/deeplink/ton-connect",deepLink:"dfw://",jsBridgeKey:"cdcTonWallet",bridgeUrl:"https://wallet.crypto.com/sse/tonbridge",platforms:["ios","android","chrome"]},{appName:"tobi",name:"Tobi",imageUrl:"https://app.tobiwallet.app/icons/logo.png",aboutUrl:"https://tobi.fun",universalLink:"https://t.me/TobiCopilotBot?attach=wallet",bridgeUrl:"https://ton-bridge.tobiwallet.app/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"trustwalletTon",name:"Trust",imageUrl:"https://assets-cdn.trustwallet.com/dapps/trust.logo.png",aboutUrl:"https://trustwallet.com/about-us",bridgeUrl:"https://tonconnect.trustwallet.com/bridge",jsBridgeKey:"trustwalletTon",platforms:["chrome","ios","android"]},{appName:"bitgetWalletLite",name:"Bitget Wallet Lite",imageUrl:"https://raw.githubusercontent.com/bitgetwallet/download/main/logo/png/bitget_wallet_lite_logo.png",aboutUrl:"https://web3.bitget.com",universalLink:"https://t.me/BitgetWallet_TGBot?attach=wallet",bridgeUrl:"https://ton-connect-bridge.bgwapi.io/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"onekey",name:"OneKey",imageUrl:"https://common.onekey-asset.com/logo/onekey-x288.png",aboutUrl:"https://onekey.so",jsBridgeKey:"onekeyTonWallet",platforms:["chrome"]},{appName:"tomoWallet",name:"Tomo Wallet",imageUrl:"https://pub.tomo.inc/logo.png",aboutUrl:"https://www.tomo.inc/",universalLink:"https://t.me/tomowalletbot?attach=wallet",bridgeUrl:"https://go-bridge.tomo.inc/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"hpyTonWallet",name:"HyperPay Wallet",imageUrl:"https://onchain-oss.hyperpay.online/images/logo.png",aboutUrl:"https://www.hyperpay.tech",universalLink:"https://www.hyperpay.tech/download&deeplink=hyperpay://web3/wallet/tonconnect",jsBridgeKey:"hpyTonWallet",bridgeUrl:"https://onchain-wallet.hyperpay.online/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"unstoppable",name:"Unstoppable Wallet",imageUrl:"https://unstoppable.money/logo288.png",aboutUrl:"https://unstoppable.money/",universalLink:"https://unstoppable.money/ton-connect",bridgeUrl:"https://bridge.unstoppable.money/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"foxwallet",name:"FoxWallet",imageUrl:"https://hc.foxwallet.com/img/logo.png",aboutUrl:"https://foxwallet.com/",jsBridgeKey:"foxwallet",platforms:["ios","android","macos","windows","linux"]},{appName:"jambo",name:"Jambo",imageUrl:"https://cdn-prod.jambotechnology.xyz/content/jambo_288x288_02da416a6c.png",aboutUrl:"https://www.jambo.technology/",deepLink:"jambotc://",universalLink:"https://jambophone.xyz/",bridgeUrl:"https://bridge.tonapi.io/bridge",jsBridgeKey:"jambowallet",platforms:["android","macos","windows","linux"]}]},actionsConfiguration:{twaReturnUrl:"https://t.me/DemoDappWithTonConnectBot/demo"},children:jsxs("div",{className:"app",children:[jsx$1(Header,{}),jsx$1(TxForm,{}),jsx$1(CreateJettonDemo,{}),jsx$1(TonProofDemo,{}),jsx$1(Footer,{})]})})}const index="";function runSingleInstance(b){let _=!1;return async()=>{if(!_){_=!0;try{await b()}catch(d){console.error(d)}finally{_=!1}}}}eruda.init();async function enableMocking(){const b=document.baseURI.replace(/\/$/,"");return new Promise(async _=>{const{worker:d}=await __vitePreload(()=>import("./worker-fdebfe2a.js"),[]),k=()=>d.start({onUnhandledRequest:"bypass",quiet:!1,serviceWorker:{url:"/demo-dapp-with-react-ui/mockServiceWorker.js"}});let j=await k();_(j);const $=runSingleInstance(async()=>{var et;try{const rt=(await((et=navigator.serviceWorker)==null?void 0:et.getRegistrations())||[]).length>0,nt=await fetch(`${b}/api/healthz`).then(ot=>ot.status===200?ot.json().then(at=>at.ok).catch(()=>!1):!1).catch(()=>!1);(!rt||!nt)&&(await(j==null?void 0:j.unregister().catch(()=>{})),j=await k().catch(()=>null))}catch(tt){console.error("Error in verifyAndRestartWorker:",tt),j=await k().catch(()=>null)}});setInterval($,1e3)})}enableMocking().then(()=>reactDomExports.render(jsx$1(reactExports.StrictMode,{children:jsx$1(App,{})}),document.getElementById("root")));export{CHAIN as C,buffer as b,commonjsGlobal as c,getAugmentedNamespace as g,naclFastExports as n,require$$4 as r}; +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}var _n=$(46),Bn=new($(47)).Dispatcher,Yn=new(function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){var Wt;nt(this,Rt);for(var Pt=arguments.length,hn=new Array(Pt),un=0;unPt&&(tn.style.cursor="pointer",this.state.collapsed&&(un=st.a.createElement("span",null,un.substring(0,Pt),st.a.createElement("span",Bt(hn,"ellipsis")," ...")))),st.a.createElement("div",Bt(hn,"string"),st.a.createElement(Zt,Object.assign({type_name:"string"},Wt)),st.a.createElement("span",Object.assign({className:"string-value"},tn,{onClick:this.toggleCollapsed}),'"',un,'"'))}}]),Rt}(st.a.PureComponent),gn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){return st.a.createElement("div",Bt(this.props.theme,"undefined"),"undefined")}}]),Rt}(st.a.PureComponent);function Ln(){return(Ln=Object.assign||function(jt){for(var Nt=1;Nt=0||(Hn[mr]=or[mr]);return Hn}(jt,["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"]),Gn,er=xn.value!==void 0,tr=Object(gt.useRef)(null),ir=Zn(tr,Nt),Kn=Object(gt.useRef)(0),rr=Object(gt.useRef)(),ur=function(){var or=tr.current,yr=Rt&&rr.current?rr.current:function(hr){var lr=window.getComputedStyle(hr);if(lr===null)return null;var sr,dr=(sr=lr,Tn.reduce(function(Mr,Ir){return Mr[Ir]=sr[Ir],Mr},{})),Ar=dr.boxSizing;return Ar===""?null:(Kt&&Ar==="border-box"&&(dr.width=parseFloat(dr.width)+parseFloat(dr.borderRightWidth)+parseFloat(dr.borderLeftWidth)+parseFloat(dr.paddingRight)+parseFloat(dr.paddingLeft)+"px"),{sizingStyle:dr,paddingSize:parseFloat(dr.paddingBottom)+parseFloat(dr.paddingTop),borderSize:parseFloat(dr.borderBottomWidth)+parseFloat(dr.borderTopWidth)})}(or);if(yr){rr.current=yr;var mr=function(hr,lr,sr,dr){sr===void 0&&(sr=1),dr===void 0&&(dr=1/0),Fn||((Fn=document.createElement("textarea")).setAttribute("tab-index","-1"),Fn.setAttribute("aria-hidden","true"),Wn(Fn)),Fn.parentNode===null&&document.body.appendChild(Fn);var Ar=hr.paddingSize,Mr=hr.borderSize,Ir=hr.sizingStyle,jr=Ir.boxSizing;Object.keys(Ir).forEach(function(Pr){var $r=Pr;Fn.style[$r]=Ir[$r]}),Wn(Fn),Fn.value=lr;var pn=function(Pr,$r){var Wr=Pr.scrollHeight;return $r.sizingStyle.boxSizing==="border-box"?Wr+$r.borderSize:Wr-$r.paddingSize}(Fn,hr);Fn.value="x";var Lr=Fn.scrollHeight-Ar,Fr=Lr*sr;jr==="border-box"&&(Fr=Fr+Ar+Mr),pn=Math.max(Fr,pn);var Dr=Lr*dr;return jr==="border-box"&&(Dr=Dr+Ar+Mr),[pn=Math.min(Dr,pn),Lr]}(yr,or.value||or.placeholder||"x",Pt,Wt),Pn=mr[0],Hn=mr[1];Kn.current!==Pn&&(Kn.current=Pn,or.style.setProperty("height",Pn+"px","important"),Gt(Pn,{rowHeight:Hn}))}};return Object(gt.useLayoutEffect)(ur),Gn=Un(ur),Object(gt.useLayoutEffect)(function(){var or=function(yr){Gn.current(yr)};return window.addEventListener("resize",or),function(){window.removeEventListener("resize",or)}},[]),Object(gt.createElement)("textarea",Ln({},xn,{onChange:function(or){er||ur(),un(or)},ref:ir}))},pt=Object(gt.forwardRef)(bt);function yt(jt){jt=jt.trim();try{if((jt=JSON.stringify(JSON.parse(jt)))[0]==="[")return Ut("array",JSON.parse(jt));if(jt[0]==="{")return Ut("object",JSON.parse(jt));if(jt.match(/\-?\d+\.\d+/)&&jt.match(/\-?\d+\.\d+/)[0]===jt)return Ut("float",parseFloat(jt));if(jt.match(/\-?\d+e-\d+/)&&jt.match(/\-?\d+e-\d+/)[0]===jt)return Ut("float",Number(jt));if(jt.match(/\-?\d+/)&&jt.match(/\-?\d+/)[0]===jt)return Ut("integer",parseInt(jt));if(jt.match(/\-?\d+e\+\d+/)&&jt.match(/\-?\d+e\+\d+/)[0]===jt)return Ut("integer",Number(jt))}catch{}switch(jt=jt.toLowerCase()){case"undefined":return Ut("undefined",void 0);case"nan":return Ut("nan",NaN);case"null":return Ut("null",null);case"true":return Ut("boolean",!0);case"false":return Ut("boolean",!1);default:if(jt=Date.parse(jt))return Ut("date",new Date(jt))}return Ut(!1,null)}function Ut(jt,Nt){return{type:jt,value:Nt}}var sn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 24 24",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("path",{d:"M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M7,13H17V11H7"})))}}]),Rt}(st.a.PureComponent),ln=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 24 24",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("path",{d:"M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M13,7H11V11H7V13H11V17H13V13H17V11H13V7Z"})))}}]),Rt}(st.a.PureComponent),mn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]),un=pr(Pt).style;return st.a.createElement("span",hn,st.a.createElement("svg",{fill:un.color,width:un.height,height:un.width,style:un,viewBox:"0 0 1792 1792"},st.a.createElement("path",{d:"M1344 800v64q0 14-9 23t-23 9h-832q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h832q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"})))}}]),Rt}(st.a.PureComponent),Qn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]),un=pr(Pt).style;return st.a.createElement("span",hn,st.a.createElement("svg",{fill:un.color,width:un.height,height:un.width,style:un,viewBox:"0 0 1792 1792"},st.a.createElement("path",{d:"M1344 800v64q0 14-9 23t-23 9h-352v352q0 14-9 23t-23 9h-64q-14 0-23-9t-9-23v-352h-352q-14 0-23-9t-9-23v-64q0-14 9-23t23-9h352v-352q0-14 9-23t23-9h64q14 0 23 9t9 23v352h352q14 0 23 9t9 23zm128 448v-832q0-66-47-113t-113-47h-832q-66 0-113 47t-47 113v832q0 66 47 113t113 47h832q66 0 113-47t47-113zm128-832v832q0 119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119 84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z"})))}}]),Rt}(st.a.PureComponent),Rn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",{style:rt(rt({},pr(Pt).style),{},{paddingLeft:"2px",verticalAlign:"top"}),viewBox:"0 0 15 15",fill:"currentColor"},st.a.createElement("path",{d:"M0 14l6-6-6-6z"})))}}]),Rt}(st.a.PureComponent),Jn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",{style:rt(rt({},pr(Pt).style),{},{paddingLeft:"2px",verticalAlign:"top"}),viewBox:"0 0 15 15",fill:"currentColor"},st.a.createElement("path",{d:"M0 5l6 6 6-6z"})))}}]),Rt}(st.a.PureComponent),Nn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m30 35h-25v-22.5h25v7.5h2.5v-12.5c0-1.4-1.1-2.5-2.5-2.5h-7.5c0-2.8-2.2-5-5-5s-5 2.2-5 5h-7.5c-1.4 0-2.5 1.1-2.5 2.5v27.5c0 1.4 1.1 2.5 2.5 2.5h25c1.4 0 2.5-1.1 2.5-2.5v-5h-2.5v5z m-20-27.5h2.5s2.5-1.1 2.5-2.5 1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5 1.3 2.5 2.5 2.5h2.5s2.5 1.1 2.5 2.5h-20c0-1.5 1.1-2.5 2.5-2.5z m-2.5 20h5v-2.5h-5v2.5z m17.5-5v-5l-10 7.5 10 7.5v-5h12.5v-5h-12.5z m-17.5 10h7.5v-2.5h-7.5v2.5z m12.5-17.5h-12.5v2.5h12.5v-2.5z m-7.5 5h-5v2.5h5v-2.5z"}))))}}]),Rt}(st.a.PureComponent),ar=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m28.6 25q0-0.5-0.4-1l-4-4 4-4q0.4-0.5 0.4-1 0-0.6-0.4-1.1l-2-2q-0.4-0.4-1-0.4-0.6 0-1 0.4l-4.1 4.1-4-4.1q-0.4-0.4-1-0.4-0.6 0-1 0.4l-2 2q-0.5 0.5-0.5 1.1 0 0.5 0.5 1l4 4-4 4q-0.5 0.5-0.5 1 0 0.7 0.5 1.1l2 2q0.4 0.4 1 0.4 0.6 0 1-0.4l4-4.1 4.1 4.1q0.4 0.4 1 0.4 0.6 0 1-0.4l2-2q0.4-0.4 0.4-1z m8.7-5q0 4.7-2.3 8.6t-6.3 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3 8.6 2.3 6.3 6.2 2.3 8.6z"}))))}}]),Rt}(st.a.PureComponent),Xn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m30.1 21.4v-2.8q0-0.6-0.4-1t-1-0.5h-5.7v-5.7q0-0.6-0.4-1t-1-0.4h-2.9q-0.6 0-1 0.4t-0.4 1v5.7h-5.7q-0.6 0-1 0.5t-0.5 1v2.8q0 0.6 0.5 1t1 0.5h5.7v5.7q0 0.5 0.4 1t1 0.4h2.9q0.6 0 1-0.4t0.4-1v-5.7h5.7q0.6 0 1-0.5t0.4-1z m7.2-1.4q0 4.7-2.3 8.6t-6.3 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3 8.6 2.3 6.3 6.2 2.3 8.6z"}))))}}]),Rt}(st.a.PureComponent),qn=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m31.6 21.6h-10v10h-3.2v-10h-10v-3.2h10v-10h3.2v10h10v3.2z"}))))}}]),Rt}(st.a.PureComponent),fr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m19.8 26.4l2.6-2.6-3.4-3.4-2.6 2.6v1.3h2.2v2.1h1.2z m9.8-16q-0.3-0.4-0.7 0l-7.8 7.8q-0.4 0.4 0 0.7t0.7 0l7.8-7.8q0.4-0.4 0-0.7z m1.8 13.2v4.3q0 2.6-1.9 4.5t-4.5 1.9h-18.6q-2.6 0-4.5-1.9t-1.9-4.5v-18.6q0-2.7 1.9-4.6t4.5-1.8h18.6q1.4 0 2.6 0.5 0.3 0.2 0.4 0.5 0.1 0.4-0.2 0.7l-1.1 1.1q-0.3 0.3-0.7 0.1-0.5-0.1-1-0.1h-18.6q-1.4 0-2.5 1.1t-1 2.5v18.6q0 1.4 1 2.5t2.5 1h18.6q1.5 0 2.5-1t1.1-2.5v-2.9q0-0.2 0.2-0.4l1.4-1.5q0.3-0.3 0.8-0.1t0.4 0.6z m-2.1-16.5l6.4 6.5-15 15h-6.4v-6.5z m9.9 3l-2.1 2-6.4-6.4 2.1-2q0.6-0.7 1.5-0.7t1.5 0.7l3.4 3.4q0.6 0.6 0.6 1.5t-0.6 1.5z"}))))}}]),Rt}(st.a.PureComponent),cr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){return nt(this,Rt),Nt.apply(this,arguments)}return at(Rt,[{key:"render",value:function(){var Wt=this.props,Pt=Wt.style,hn=kt(Wt,["style"]);return st.a.createElement("span",hn,st.a.createElement("svg",Object.assign({},pr(Pt),{viewBox:"0 0 40 40",fill:"currentColor",preserveAspectRatio:"xMidYMid meet"}),st.a.createElement("g",null,st.a.createElement("path",{d:"m31.7 16.4q0-0.6-0.4-1l-2.1-2.1q-0.4-0.4-1-0.4t-1 0.4l-9.1 9.1-5-5q-0.5-0.4-1-0.4t-1 0.4l-2.1 2q-0.4 0.4-0.4 1 0 0.6 0.4 1l8.1 8.1q0.4 0.4 1 0.4 0.6 0 1-0.4l12.2-12.1q0.4-0.4 0.4-1z m5.6 3.6q0 4.7-2.3 8.6t-6.3 6.2-8.6 2.3-8.6-2.3-6.2-6.2-2.3-8.6 2.3-8.6 6.2-6.2 8.6-2.3 8.6 2.3 6.3 6.2 2.3 8.6z"}))))}}]),Rt}(st.a.PureComponent);function pr(jt){return jt||(jt={}),{style:rt(rt({verticalAlign:"middle"},jt),{},{color:jt.color?jt.color:"#000000",height:"1em",width:"1em"})}}var xr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;return nt(this,Rt),(Pt=Nt.call(this,Wt)).copiedTimer=null,Pt.handleCopy=function(){var hn=document.createElement("textarea"),un=Pt.props,tn=un.clickCallback,Gt=un.src,xn=un.namespace;hn.innerHTML=JSON.stringify(Pt.clipboardValue(Gt),null," "),document.body.appendChild(hn),hn.select(),document.execCommand("copy"),document.body.removeChild(hn),Pt.copiedTimer=setTimeout(function(){Pt.setState({copied:!1})},5500),Pt.setState({copied:!0},function(){typeof tn=="function"&&tn({src:Gt,namespace:xn,name:xn[xn.length-1]})})},Pt.getClippyIcon=function(){var hn=Pt.props.theme;return Pt.state.copied?st.a.createElement("span",null,st.a.createElement(Nn,Object.assign({className:"copy-icon"},Bt(hn,"copy-icon"))),st.a.createElement("span",Bt(hn,"copy-icon-copied"),"✔")):st.a.createElement(Nn,Object.assign({className:"copy-icon"},Bt(hn,"copy-icon")))},Pt.clipboardValue=function(hn){switch(Ct(hn)){case"function":case"regexp":return hn.toString();default:return hn}},Pt.state={copied:!1},Pt}return at(Rt,[{key:"componentWillUnmount",value:function(){this.copiedTimer&&(clearTimeout(this.copiedTimer),this.copiedTimer=null)}},{key:"render",value:function(){var Wt=this.props,Pt=(Wt.src,Wt.theme),hn=Wt.hidden,un=Wt.rowHovered,tn=Bt(Pt,"copy-to-clipboard").style,Gt="inline";return hn&&(Gt="none"),st.a.createElement("span",{className:"copy-to-clipboard-container",title:"Copy to clipboard",style:{verticalAlign:"top",display:un?"inline-block":"none"}},st.a.createElement("span",{style:rt(rt({},tn),{},{display:Gt}),onClick:this.handleCopy},this.getClippyIcon()))}}]),Rt}(st.a.PureComponent),kr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;return nt(this,Rt),(Pt=Nt.call(this,Wt)).getEditIcon=function(){var hn=Pt.props,un=hn.variable,tn=hn.theme;return st.a.createElement("div",{className:"click-to-edit",style:{verticalAlign:"top",display:Pt.state.hovered?"inline-block":"none"}},st.a.createElement(fr,Object.assign({className:"click-to-edit-icon"},Bt(tn,"editVarIcon"),{onClick:function(){Pt.prepopInput(un)}})))},Pt.prepopInput=function(hn){if(Pt.props.onEdit!==!1){var un=function(Gt){var xn;switch(Ct(Gt)){case"undefined":xn="undefined";break;case"nan":xn="NaN";break;case"string":xn=Gt;break;case"date":case"function":case"regexp":xn=Gt.toString();break;default:try{xn=JSON.stringify(Gt,null," ")}catch{xn=""}}return xn}(hn.value),tn=yt(un);Pt.setState({editMode:!0,editValue:un,parsedInput:{type:tn.type,value:tn.value}})}},Pt.getRemoveIcon=function(){var hn=Pt.props,un=hn.variable,tn=hn.namespace,Gt=hn.theme,xn=hn.rjvId;return st.a.createElement("div",{className:"click-to-remove",style:{verticalAlign:"top",display:Pt.state.hovered?"inline-block":"none"}},st.a.createElement(ar,Object.assign({className:"click-to-remove-icon"},Bt(Gt,"removeVarIcon"),{onClick:function(){Bn.dispatch({name:"VARIABLE_REMOVED",rjvId:xn,data:{name:un.name,namespace:tn,existing_value:un.value,variable_removed:!0}})}})))},Pt.getValue=function(hn,un){var tn=!un&&hn.type,Gt=ft(Pt).props;switch(tn){case!1:return Pt.getEditInput();case"string":return st.a.createElement(En,Object.assign({value:hn.value},Gt));case"integer":return st.a.createElement(kn,Object.assign({value:hn.value},Gt));case"float":return st.a.createElement(Qt,Object.assign({value:hn.value},Gt));case"boolean":return st.a.createElement(rn,Object.assign({value:hn.value},Gt));case"function":return st.a.createElement(An,Object.assign({value:hn.value},Gt));case"null":return st.a.createElement(In,Gt);case"nan":return st.a.createElement(yn,Gt);case"undefined":return st.a.createElement(gn,Gt);case"date":return st.a.createElement(nn,Object.assign({value:hn.value},Gt));case"regexp":return st.a.createElement(vn,Object.assign({value:hn.value},Gt));default:return st.a.createElement("div",{className:"object-value"},JSON.stringify(hn.value))}},Pt.getEditInput=function(){var hn=Pt.props.theme,un=Pt.state.editValue;return st.a.createElement("div",null,st.a.createElement(pt,Object.assign({type:"text",inputRef:function(tn){return tn&&tn.focus()},value:un,className:"variable-editor",onChange:function(tn){var Gt=tn.target.value,xn=yt(Gt);Pt.setState({editValue:Gt,parsedInput:{type:xn.type,value:xn.value}})},onKeyDown:function(tn){switch(tn.key){case"Escape":Pt.setState({editMode:!1,editValue:""});break;case"Enter":(tn.ctrlKey||tn.metaKey)&&Pt.submitEdit(!0)}tn.stopPropagation()},placeholder:"update this value",minRows:2},Bt(hn,"edit-input"))),st.a.createElement("div",Bt(hn,"edit-icon-container"),st.a.createElement(ar,Object.assign({className:"edit-cancel"},Bt(hn,"cancel-icon"),{onClick:function(){Pt.setState({editMode:!1,editValue:""})}})),st.a.createElement(cr,Object.assign({className:"edit-check string-value"},Bt(hn,"check-icon"),{onClick:function(){Pt.submitEdit()}})),st.a.createElement("div",null,Pt.showDetected())))},Pt.submitEdit=function(hn){var un=Pt.props,tn=un.variable,Gt=un.namespace,xn=un.rjvId,Gn=Pt.state,er=Gn.editValue,tr=Gn.parsedInput,ir=er;hn&&tr.type&&(ir=tr.value),Pt.setState({editMode:!1}),Bn.dispatch({name:"VARIABLE_UPDATED",rjvId:xn,data:{name:tn.name,namespace:Gt,existing_value:tn.value,new_value:ir,variable_removed:!1}})},Pt.showDetected=function(){var hn=Pt.props,un=hn.theme,tn=(hn.variable,hn.namespace,hn.rjvId,Pt.state.parsedInput),Gt=(tn.type,tn.value,Pt.getDetectedInput());if(Gt)return st.a.createElement("div",null,st.a.createElement("div",Bt(un,"detected-row"),Gt,st.a.createElement(cr,{className:"edit-check detected",style:rt({verticalAlign:"top",paddingLeft:"3px"},Bt(un,"check-icon").style),onClick:function(){Pt.submitEdit(!0)}})))},Pt.getDetectedInput=function(){var hn=Pt.state.parsedInput,un=hn.type,tn=hn.value,Gt=ft(Pt).props,xn=Gt.theme;if(un!==!1)switch(un.toLowerCase()){case"object":return st.a.createElement("span",null,st.a.createElement("span",{style:rt(rt({},Bt(xn,"brace").style),{},{cursor:"default"})},"{"),st.a.createElement("span",{style:rt(rt({},Bt(xn,"ellipsis").style),{},{cursor:"default"})},"..."),st.a.createElement("span",{style:rt(rt({},Bt(xn,"brace").style),{},{cursor:"default"})},"}"));case"array":return st.a.createElement("span",null,st.a.createElement("span",{style:rt(rt({},Bt(xn,"brace").style),{},{cursor:"default"})},"["),st.a.createElement("span",{style:rt(rt({},Bt(xn,"ellipsis").style),{},{cursor:"default"})},"..."),st.a.createElement("span",{style:rt(rt({},Bt(xn,"brace").style),{},{cursor:"default"})},"]"));case"string":return st.a.createElement(En,Object.assign({value:tn},Gt));case"integer":return st.a.createElement(kn,Object.assign({value:tn},Gt));case"float":return st.a.createElement(Qt,Object.assign({value:tn},Gt));case"boolean":return st.a.createElement(rn,Object.assign({value:tn},Gt));case"function":return st.a.createElement(An,Object.assign({value:tn},Gt));case"null":return st.a.createElement(In,Gt);case"nan":return st.a.createElement(yn,Gt);case"undefined":return st.a.createElement(gn,Gt);case"date":return st.a.createElement(nn,Object.assign({value:new Date(tn)},Gt))}},Pt.state={editMode:!1,editValue:"",hovered:!1,renameKey:!1,parsedInput:{type:!1,value:null}},Pt}return at(Rt,[{key:"render",value:function(){var Wt=this,Pt=this.props,hn=Pt.variable,un=Pt.singleIndent,tn=Pt.type,Gt=Pt.theme,xn=Pt.namespace,Gn=Pt.indentWidth,er=Pt.enableClipboard,tr=Pt.onEdit,ir=Pt.onDelete,Kn=Pt.onSelect,rr=Pt.displayArrayKey,ur=Pt.quotesOnKeys,or=this.state.editMode;return st.a.createElement("div",Object.assign({},Bt(Gt,"objectKeyVal",{paddingLeft:Gn*un}),{onMouseEnter:function(){return Wt.setState(rt(rt({},Wt.state),{},{hovered:!0}))},onMouseLeave:function(){return Wt.setState(rt(rt({},Wt.state),{},{hovered:!1}))},className:"variable-row",key:hn.name}),tn=="array"?rr?st.a.createElement("span",Object.assign({},Bt(Gt,"array-key"),{key:hn.name+"_"+xn}),hn.name,st.a.createElement("div",Bt(Gt,"colon"),":")):null:st.a.createElement("span",null,st.a.createElement("span",Object.assign({},Bt(Gt,"object-name"),{className:"object-key",key:hn.name+"_"+xn}),!!ur&&st.a.createElement("span",{style:{verticalAlign:"top"}},'"'),st.a.createElement("span",{style:{display:"inline-block"}},hn.name),!!ur&&st.a.createElement("span",{style:{verticalAlign:"top"}},'"')),st.a.createElement("span",Bt(Gt,"colon"),":")),st.a.createElement("div",Object.assign({className:"variable-value",onClick:Kn===!1&&tr===!1?null:function(yr){var mr=On(xn);(yr.ctrlKey||yr.metaKey)&&tr!==!1?Wt.prepopInput(hn):Kn!==!1&&(mr.shift(),Kn(rt(rt({},hn),{},{namespace:mr})))}},Bt(Gt,"variableValue",{cursor:Kn===!1?"default":"pointer"})),this.getValue(hn,or)),er?st.a.createElement(xr,{rowHovered:this.state.hovered,hidden:or,src:hn.value,clickCallback:er,theme:Gt,namespace:[].concat(On(xn),[hn.name])}):null,tr!==!1&&or==0?this.getEditIcon():null,ir!==!1&&or==0?this.getRemoveIcon():null)}}]),Rt}(st.a.PureComponent),Tr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){var Wt;nt(this,Rt);for(var Pt=arguments.length,hn=new Array(Pt),un=0;un0?er:null,namespace:Gn.splice(0,Gn.length-1),existing_value:tr,variable_removed:!1,key_name:null};Ct(tr)==="object"?Bn.dispatch({name:"ADD_VARIABLE_KEY_REQUEST",rjvId:ir,data:rr}):Bn.dispatch({name:"VARIABLE_ADDED",rjvId:ir,data:rt(rt({},rr),{},{new_value:[].concat(On(tr),[null])})})}})))},Wt.getRemoveObject=function(tn){var Gt=Wt.props,xn=Gt.theme,Gn=(Gt.hover,Gt.namespace),er=Gt.name,tr=Gt.src,ir=Gt.rjvId;if(Gn.length!==1)return st.a.createElement("span",{className:"click-to-remove",style:{display:tn?"inline-block":"none"}},st.a.createElement(ar,Object.assign({className:"click-to-remove-icon"},Bt(xn,"removeVarIcon"),{onClick:function(){Bn.dispatch({name:"VARIABLE_REMOVED",rjvId:ir,data:{name:er,namespace:Gn.splice(0,Gn.length-1),existing_value:tr,variable_removed:!0}})}})))},Wt.render=function(){var tn=Wt.props,Gt=tn.theme,xn=tn.onDelete,Gn=tn.onAdd,er=tn.enableClipboard,tr=tn.src,ir=tn.namespace,Kn=tn.rowHovered;return st.a.createElement("div",Object.assign({},Bt(Gt,"object-meta-data"),{className:"object-meta-data",onClick:function(rr){rr.stopPropagation()}}),Wt.getObjectSize(),er?st.a.createElement(xr,{rowHovered:Kn,clickCallback:er,src:tr,theme:Gt,namespace:ir}):null,Gn!==!1?Wt.getAddAttribute(Kn):null,xn!==!1?Wt.getRemoveObject(Kn):null)},Wt}return Rt}(st.a.PureComponent);function Br(jt){var Nt=jt.parent_type,Rt=jt.namespace,Wt=jt.quotesOnKeys,Pt=jt.theme,hn=jt.jsvRoot,un=jt.name,tn=jt.displayArrayKey,Gt=jt.name?jt.name:"";return!hn||un!==!1&&un!==null?Nt=="array"?tn?st.a.createElement("span",Object.assign({},Bt(Pt,"array-key"),{key:Rt}),st.a.createElement("span",{className:"array-key"},Gt),st.a.createElement("span",Bt(Pt,"colon"),":")):st.a.createElement("span",null):st.a.createElement("span",Object.assign({},Bt(Pt,"object-name"),{key:Rt}),st.a.createElement("span",{className:"object-key"},Wt&&st.a.createElement("span",{style:{verticalAlign:"top"}},'"'),st.a.createElement("span",null,Gt),Wt&&st.a.createElement("span",{style:{verticalAlign:"top"}},'"')),st.a.createElement("span",Bt(Pt,"colon"),":")):st.a.createElement("span",null)}function Rr(jt){var Nt=jt.theme;switch(jt.iconStyle){case"triangle":return st.a.createElement(Jn,Object.assign({},Bt(Nt,"expanded-icon"),{className:"expanded-icon"}));case"square":return st.a.createElement(mn,Object.assign({},Bt(Nt,"expanded-icon"),{className:"expanded-icon"}));default:return st.a.createElement(sn,Object.assign({},Bt(Nt,"expanded-icon"),{className:"expanded-icon"}))}}function Ur(jt){var Nt=jt.theme;switch(jt.iconStyle){case"triangle":return st.a.createElement(Rn,Object.assign({},Bt(Nt,"collapsed-icon"),{className:"collapsed-icon"}));case"square":return st.a.createElement(Qn,Object.assign({},Bt(Nt,"collapsed-icon"),{className:"collapsed-icon"}));default:return st.a.createElement(ln,Object.assign({},Bt(Nt,"collapsed-icon"),{className:"collapsed-icon"}))}}var Qr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;return nt(this,Rt),(Pt=Nt.call(this,Wt)).toggleCollapsed=function(hn){var un=[];for(var tn in Pt.state.expanded)un.push(Pt.state.expanded[tn]);un[hn]=!un[hn],Pt.setState({expanded:un})},Pt.state={expanded:[]},Pt}return at(Rt,[{key:"getExpandedIcon",value:function(Wt){var Pt=this.props,hn=Pt.theme,un=Pt.iconStyle;return this.state.expanded[Wt]?st.a.createElement(Rr,{theme:hn,iconStyle:un}):st.a.createElement(Ur,{theme:hn,iconStyle:un})}},{key:"render",value:function(){var Wt=this,Pt=this.props,hn=Pt.src,un=Pt.groupArraysAfterLength,tn=(Pt.depth,Pt.name),Gt=Pt.theme,xn=Pt.jsvRoot,Gn=Pt.namespace,er=(Pt.parent_type,kt(Pt,["src","groupArraysAfterLength","depth","name","theme","jsvRoot","namespace","parent_type"])),tr=0,ir=5*this.props.indentWidth;xn||(tr=5*this.props.indentWidth);var Kn=un,rr=Math.ceil(hn.length/Kn);return st.a.createElement("div",Object.assign({className:"object-key-val"},Bt(Gt,xn?"jsv-root":"objectKeyVal",{paddingLeft:tr})),st.a.createElement(Br,this.props),st.a.createElement("span",null,st.a.createElement(Tr,Object.assign({size:hn.length},this.props))),On(Array(rr)).map(function(ur,or){return st.a.createElement("div",Object.assign({key:or,className:"object-key-val array-group"},Bt(Gt,"objectKeyVal",{marginLeft:6,paddingLeft:ir})),st.a.createElement("span",Bt(Gt,"brace-row"),st.a.createElement("div",Object.assign({className:"icon-container"},Bt(Gt,"icon-container"),{onClick:function(yr){Wt.toggleCollapsed(or)}}),Wt.getExpandedIcon(or)),Wt.state.expanded[or]?st.a.createElement(St,Object.assign({key:tn+or,depth:0,name:!1,collapsed:!1,groupArraysAfterLength:Kn,index_offset:or*Kn,src:hn.slice(or*Kn,or*Kn+Kn),namespace:Gn,type:"array",parent_type:"array_group",theme:Gt},er)):st.a.createElement("span",Object.assign({},Bt(Gt,"brace"),{onClick:function(yr){Wt.toggleCollapsed(or)},className:"array-group-brace"}),"[",st.a.createElement("div",Object.assign({},Bt(Gt,"array-group-meta-data"),{className:"array-group-meta-data"}),st.a.createElement("span",Object.assign({className:"object-size"},Bt(Gt,"object-size")),or*Kn," - ",or*Kn+Kn>hn.length?hn.length:or*Kn+Kn)),"]")))}))}}]),Rt}(st.a.PureComponent),Zr=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;nt(this,Rt),(Pt=Nt.call(this,Wt)).toggleCollapsed=function(){Pt.setState({expanded:!Pt.state.expanded},function(){dn.set(Pt.props.rjvId,Pt.props.namespace,"expanded",Pt.state.expanded)})},Pt.getObjectContent=function(un,tn,Gt){return st.a.createElement("div",{className:"pushed-content object-container"},st.a.createElement("div",Object.assign({className:"object-content"},Bt(Pt.props.theme,"pushed-content")),Pt.renderObjectContents(tn,Gt)))},Pt.getEllipsis=function(){return Pt.state.size===0?null:st.a.createElement("div",Object.assign({},Bt(Pt.props.theme,"ellipsis"),{className:"node-ellipsis",onClick:Pt.toggleCollapsed}),"...")},Pt.getObjectMetaData=function(un){var tn=Pt.props,Gt=(tn.rjvId,tn.theme,Pt.state),xn=Gt.size,Gn=Gt.hovered;return st.a.createElement(Tr,Object.assign({rowHovered:Gn,size:xn},Pt.props))},Pt.renderObjectContents=function(un,tn){var Gt,xn=Pt.props,Gn=xn.depth,er=xn.parent_type,tr=xn.index_offset,ir=xn.groupArraysAfterLength,Kn=xn.namespace,rr=Pt.state.object_type,ur=[],or=Object.keys(un||{});return Pt.props.sortKeys&&rr!=="array"&&(or=or.sort()),or.forEach(function(yr){if(Gt=new mo(yr,un[yr]),er==="array_group"&&tr&&(Gt.name=parseInt(Gt.name)+tr),un.hasOwnProperty(yr))if(Gt.type==="object")ur.push(st.a.createElement(St,Object.assign({key:Gt.name,depth:Gn+1,name:Gt.name,src:Gt.value,namespace:Kn.concat(Gt.name),parent_type:rr},tn)));else if(Gt.type==="array"){var mr=St;ir&&Gt.value.length>ir&&(mr=Qr),ur.push(st.a.createElement(mr,Object.assign({key:Gt.name,depth:Gn+1,name:Gt.name,src:Gt.value,namespace:Kn.concat(Gt.name),type:"array",parent_type:rr},tn)))}else ur.push(st.a.createElement(kr,Object.assign({key:Gt.name+"_"+Kn,variable:Gt,singleIndent:5,namespace:Kn,type:Pt.props.type},tn)))}),ur};var hn=Rt.getState(Wt);return Pt.state=rt(rt({},hn),{},{prevProps:{}}),Pt}return at(Rt,[{key:"getBraceStart",value:function(Wt,Pt){var hn=this,un=this.props,tn=un.src,Gt=un.theme,xn=un.iconStyle;if(un.parent_type==="array_group")return st.a.createElement("span",null,st.a.createElement("span",Bt(Gt,"brace"),Wt==="array"?"[":"{"),Pt?this.getObjectMetaData(tn):null);var Gn=Pt?Rr:Ur;return st.a.createElement("span",null,st.a.createElement("span",Object.assign({onClick:function(er){hn.toggleCollapsed()}},Bt(Gt,"brace-row")),st.a.createElement("div",Object.assign({className:"icon-container"},Bt(Gt,"icon-container")),st.a.createElement(Gn,{theme:Gt,iconStyle:xn})),st.a.createElement(Br,this.props),st.a.createElement("span",Bt(Gt,"brace"),Wt==="array"?"[":"{")),Pt?this.getObjectMetaData(tn):null)}},{key:"render",value:function(){var Wt=this,Pt=this.props,hn=Pt.depth,un=Pt.src,tn=(Pt.namespace,Pt.name,Pt.type,Pt.parent_type),Gt=Pt.theme,xn=Pt.jsvRoot,Gn=Pt.iconStyle,er=kt(Pt,["depth","src","namespace","name","type","parent_type","theme","jsvRoot","iconStyle"]),tr=this.state,ir=tr.object_type,Kn=tr.expanded,rr={};return xn||tn==="array_group"?tn==="array_group"&&(rr.borderLeft=0,rr.display="inline"):rr.paddingLeft=5*this.props.indentWidth,st.a.createElement("div",Object.assign({className:"object-key-val",onMouseEnter:function(){return Wt.setState(rt(rt({},Wt.state),{},{hovered:!0}))},onMouseLeave:function(){return Wt.setState(rt(rt({},Wt.state),{},{hovered:!1}))}},Bt(Gt,xn?"jsv-root":"objectKeyVal",rr)),this.getBraceStart(ir,Kn),Kn?this.getObjectContent(hn,un,rt({theme:Gt,iconStyle:Gn},er)):this.getEllipsis(),st.a.createElement("span",{className:"brace-row"},st.a.createElement("span",{style:rt(rt({},Bt(Gt,"brace").style),{},{paddingLeft:Kn?"3px":"0px"})},ir==="array"?"]":"}"),Kn?null:this.getObjectMetaData(un)))}}],[{key:"getDerivedStateFromProps",value:function(Wt,Pt){var hn=Pt.prevProps;return Wt.src!==hn.src||Wt.collapsed!==hn.collapsed||Wt.name!==hn.name||Wt.namespace!==hn.namespace||Wt.rjvId!==hn.rjvId?rt(rt({},Rt.getState(Wt)),{},{prevProps:Wt}):null}}]),Rt}(st.a.PureComponent);Zr.getState=function(jt){var Nt=Object.keys(jt.src).length,Rt=(jt.collapsed===!1||jt.collapsed!==!0&&jt.collapsed>jt.depth)&&(!jt.shouldCollapse||jt.shouldCollapse({name:jt.name,src:jt.src,type:Ct(jt.src),namespace:jt.namespace})===!1)&&Nt!==0;return{expanded:dn.get(jt.rjvId,jt.namespace,"expanded",Rt),object_type:jt.type==="array"?"array":"object",parent_type:jt.type==="array"?"array":"object",size:Nt,hovered:!1}};var mo=function jt(Nt,Rt){nt(this,jt),this.name=Nt,this.value=Rt,this.type=Ct(Rt)};Mt(Zr);var St=Zr,Dt=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){var Wt;nt(this,Rt);for(var Pt=arguments.length,hn=new Array(Pt),un=0;untn.groupArraysAfterLength&&(xn=Qr),st.a.createElement("div",{className:"pretty-json-container object-container"},st.a.createElement("div",{className:"object-content"},st.a.createElement(xn,Object.assign({namespace:Gt,depth:0,jsvRoot:!0},tn))))},Wt}return Rt}(st.a.PureComponent),$t=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(Wt){var Pt;return nt(this,Rt),(Pt=Nt.call(this,Wt)).closeModal=function(){Bn.dispatch({rjvId:Pt.props.rjvId,name:"RESET"})},Pt.submit=function(){Pt.props.submit(Pt.state.input)},Pt.state={input:Wt.input?Wt.input:""},Pt}return at(Rt,[{key:"render",value:function(){var Wt=this,Pt=this.props,hn=Pt.theme,un=Pt.rjvId,tn=Pt.isValid,Gt=this.state.input,xn=tn(Gt);return st.a.createElement("div",Object.assign({className:"key-modal-request"},Bt(hn,"key-modal-request"),{onClick:this.closeModal}),st.a.createElement("div",Object.assign({},Bt(hn,"key-modal"),{onClick:function(Gn){Gn.stopPropagation()}}),st.a.createElement("div",Bt(hn,"key-modal-label"),"Key Name:"),st.a.createElement("div",{style:{position:"relative"}},st.a.createElement("input",Object.assign({},Bt(hn,"key-modal-input"),{className:"key-modal-input",ref:function(Gn){return Gn&&Gn.focus()},spellCheck:!1,value:Gt,placeholder:"...",onChange:function(Gn){Wt.setState({input:Gn.target.value})},onKeyPress:function(Gn){xn&&Gn.key==="Enter"?Wt.submit():Gn.key==="Escape"&&Wt.closeModal()}})),xn?st.a.createElement(cr,Object.assign({},Bt(hn,"key-modal-submit"),{className:"key-modal-submit",onClick:function(Gn){return Wt.submit()}})):null),st.a.createElement("span",Bt(hn,"key-modal-cancel"),st.a.createElement(qn,Object.assign({},Bt(hn,"key-modal-cancel-icon"),{className:"key-modal-cancel",onClick:function(){Bn.dispatch({rjvId:un,name:"RESET"})}})))))}}]),Rt}(st.a.PureComponent),mt=function(jt){dt(Rt,jt);var Nt=ct(Rt);function Rt(){var Wt;nt(this,Rt);for(var Pt=arguments.length,hn=new Array(Pt),un=0;un{_($.updated_src)},[]);return jsxs("div",{className:"send-tx-form",children:[jsx$1("h3",{children:"Configure and send transaction"}),jsx$1(ReactJson,{theme:"ocean",src:defaultTx,onEdit:j,onAdd:j,onDelete:j}),d?jsx$1("button",{onClick:()=>k.sendTransaction(b),children:"Send transaction"}):jsx$1("button",{onClick:()=>k.openModal(),children:"Connect wallet to send the transaction"})]})}const footer="",style$3="",defaultColors={[THEME.LIGHT]:{constant:{black:"#000000",white:"#FFFFFF"},connectButton:{background:"#0098EA",foreground:"#FFFFFF"},accent:"#0098EA",telegramButton:"#0098EA",icon:{primary:"#0F0F0F",secondary:"#7A8999",tertiary:"#C1CAD2",success:"#29CC6A",error:"#F5A73B"},background:{primary:"#FFFFFF",secondary:"#F1F3F5",segment:"#FFFFFF",tint:"#F1F3F5",qr:"#F1F3F5"},text:{primary:"#0F0F0F",secondary:"#6A7785"}},[THEME.DARK]:{constant:{black:"#000000",white:"#FFFFFF"},connectButton:{background:"#0098EA",foreground:"#FFFFFF"},accent:"#E5E5EA",telegramButton:"#31A6F5",icon:{primary:"#E5E5EA",secondary:"#909099",tertiary:"#434347",success:"#29CC6A",error:"#F5A73B"},background:{primary:"#121214",secondary:"#18181A",segment:"#262629",tint:"#222224",qr:"#F1F3F5"},text:{primary:"#E5E5EA",secondary:"#7D7D85"}}},ColorsSelect=({theme:b})=>{const[_,d]=useTonConnectUI(),[k,j]=reactExports.useState(defaultColors[b]);reactExports.useEffect(()=>{j(defaultColors[b])},[b]);const $=(et,tt,rt)=>{d({uiPreferences:{colorsSet:{[b]:{[tt]:rt?{...k[tt],[rt]:et}:et}}}}),j(nt=>({...nt,[tt]:rt?{...nt[tt],[rt]:et}:et})),defaultColors[b]={...defaultColors[b],[tt]:rt?{...k[tt],[rt]:et}:et}};return jsx$1("div",{className:"colors-container",children:Object.entries(k).map(([et,tt])=>typeof tt=="object"?jsxs("div",{children:[jsxs("span",{children:[et,":"]}),Object.entries(tt).map(([rt,nt])=>jsxs("label",{children:[rt,jsx$1("input",{type:"color",value:k[et][rt],onChange:ot=>$(ot.target.value,et,rt)})]},et+rt))]},et):jsxs("div",{children:[jsxs("span",{children:[et,":"]}),jsx$1("label",{children:jsx$1("input",{type:"color",value:k[et],onChange:rt=>$(rt.target.value,et)})})]}))})},style$2="",ColorsModal=()=>{const[b,_]=reactExports.useState(!1),[d,k]=reactExports.useState(THEME.LIGHT);return jsxs(Fragment,{children:[jsx$1("button",{onClick:()=>_(!0),children:"change colors"}),b&&jsxs("div",{className:"modal",children:[jsx$1("button",{onClick:()=>_(!1),children:"close"}),jsxs("div",{className:"modal__toggle",children:[jsx$1("a",{href:"#",style:{color:d===THEME.LIGHT?"blue":"white"},onClick:()=>k(THEME.LIGHT),children:"LIGHT"}),jsx$1("a",{href:"#",style:{color:d===THEME.DARK?"blue":"white"},onClick:()=>k(THEME.DARK),children:"DARK"})]}),jsx$1(ColorsSelect,{theme:d})]})]})},Footer=()=>{const[b,_]=reactExports.useState([!0,!1,!1,!0,!0,!0]),[d,k]=reactExports.useState("back"),[j,$]=reactExports.useState("ios"),[et,tt]=reactExports.useState(!0),[rt,nt]=useTonConnectUI(),ot=lt=>{nt({language:lt})},at=lt=>{nt({uiPreferences:{theme:lt}})},it=lt=>{nt({uiPreferences:{borderRadius:lt}})},dt=lt=>{_(ct=>ct.map((gt,st)=>st===lt?!gt:gt))},ut=lt=>{tt(lt)},ht=()=>{if(!d){k("back");return}nt({actionsConfiguration:{returnStrategy:d}})},ft=()=>{if(!j){$("ios");return}nt({actionsConfiguration:{skipRedirectToWallet:j}})};return reactExports.useEffect(()=>{const lt=["before","success","error"],ct=lt.map((st,_t)=>b[_t]?st:void 0).filter(st=>st),gt=lt.map((st,_t)=>b[_t+3]?st:void 0).filter(st=>st);nt({actionsConfiguration:{modals:ct,notifications:gt}})},[b]),reactExports.useEffect(()=>{nt({enableAndroidBackHandler:et})},[et]),jsxs("footer",{className:"footer",children:[jsxs("div",{children:[jsx$1("label",{children:"language"}),jsxs("select",{onChange:lt=>ot(lt.target.value),children:[jsx$1("option",{value:"en",children:"en"}),jsx$1("option",{value:"ru",children:"ru"})]})]}),jsxs("div",{children:[jsx$1("label",{children:"theme"}),jsxs("select",{onChange:lt=>at(lt.target.value),children:[jsx$1("option",{value:THEME.DARK,children:"dark"}),jsx$1("option",{value:THEME.LIGHT,children:"light"}),jsx$1("option",{value:"SYSTEM",children:"system"})]})]}),jsxs("div",{children:[jsx$1("label",{children:"borders"}),jsxs("select",{onChange:lt=>it(lt.target.value),children:[jsx$1("option",{value:"m",children:"m"}),jsx$1("option",{value:"s",children:"s"}),jsx$1("option",{value:"none",children:"none"})]})]}),jsxs("div",{children:[jsx$1("label",{children:"enable android back handler"}),jsxs("select",{onChange:lt=>ut(lt.target.value==="true"),value:et.toString(),children:[jsx$1("option",{value:"true",children:"true"}),jsx$1("option",{value:"false",children:"false"})]})]}),jsxs("div",{className:"footer-checkbox-container",children:[jsx$1("span",{children:"modals"}),jsxs("label",{children:["before",jsx$1("input",{type:"checkbox",checked:b[0],onChange:()=>dt(0)})]}),jsxs("label",{children:["success",jsx$1("input",{type:"checkbox",checked:b[1],onChange:()=>dt(1)})]}),jsxs("label",{children:["error",jsx$1("input",{type:"checkbox",checked:b[2],onChange:()=>dt(2)})]})]}),jsxs("div",{className:"footer-checkbox-container",children:[jsx$1("span",{children:"notifications"}),jsxs("label",{children:["before",jsx$1("input",{type:"checkbox",checked:b[3],onChange:()=>dt(3)})]}),jsxs("label",{children:["success",jsx$1("input",{type:"checkbox",checked:b[4],onChange:()=>dt(4)})]}),jsxs("label",{children:["error",jsx$1("input",{type:"checkbox",checked:b[5],onChange:()=>dt(5)})]})]}),jsx$1("div",{children:jsx$1(ColorsModal,{})}),jsx$1("div",{children:jsxs("label",{children:["return strategy:",jsx$1("input",{style:{width:"200px"},value:d,onChange:lt=>k(lt.target.value),onBlur:ht})]})}),jsx$1("div",{children:jsxs("label",{children:[jsx$1("div",{children:"skip redirect to wallet:"}),jsx$1("div",{children:"('ios', 'never', 'always')"}),jsx$1("input",{style:{width:"200px"},value:j,onChange:lt=>$(lt.target.value),onBlur:ft})]})})]})},style$1="";class TonProofDemoApiService{constructor(){Jo(this,"localStorageKey","demo-api-access-token");Jo(this,"host",document.baseURI.replace(/\/$/,""));Jo(this,"accessToken",null);Jo(this,"refreshIntervalMs",9*60*1e3);this.accessToken=localStorage.getItem(this.localStorageKey),this.accessToken||this.generatePayload()}async generatePayload(){try{return{tonProof:(await(await fetch(`${this.host}/api/generate_payload`,{method:"POST"})).json()).payload}}catch{return null}}async checkProof(_,d){try{const k={address:d.address,network:d.chain,public_key:d.publicKey,proof:{..._,state_init:d.walletStateInit}},j=await(await fetch(`${this.host}/api/check_proof`,{method:"POST",body:JSON.stringify(k)})).json();j!=null&&j.token&&(localStorage.setItem(this.localStorageKey,j.token),this.accessToken=j.token)}catch(k){console.log("checkProof error:",k)}}async getAccountInfo(_){return await(await fetch(`${this.host}/api/get_account_info`,{headers:{Authorization:`Bearer ${this.accessToken}`,"Content-Type":"application/json"}})).json()}async createJetton(_){return await(await fetch(`${this.host}/api/create_jetton`,{body:JSON.stringify(_),headers:{Authorization:`Bearer ${this.accessToken}`,"Content-Type":"application/json"},method:"POST"})).json()}reset(){this.accessToken=null,localStorage.removeItem(this.localStorageKey),this.generatePayload()}}const TonProofDemoApi=new TonProofDemoApiService;function useInterval(b,_){const d=reactExports.useRef(b);reactExports.useLayoutEffect(()=>{d.current=b},[b]),reactExports.useEffect(()=>{if(!_&&_!==0)return;const k=setInterval(()=>d.current(),_);return()=>clearInterval(k)},[_])}const TonProofDemo=()=>{const b=reactExports.useRef(!0),[_,d]=reactExports.useState({}),k=useTonWallet(),[j,$]=reactExports.useState(!1),[et]=useTonConnectUI(),tt=reactExports.useCallback(async()=>{b.current&&(et.setConnectRequestParameters({state:"loading"}),b.current=!1);const nt=await TonProofDemoApi.generatePayload();nt?et.setConnectRequestParameters({state:"ready",value:nt}):et.setConnectRequestParameters(null)},[et,b]);b.current&&tt(),useInterval(tt,TonProofDemoApi.refreshIntervalMs),reactExports.useEffect(()=>et.onStatusChange(async nt=>{var ot;if(!nt){TonProofDemoApi.reset(),$(!1);return}if((ot=nt.connectItems)!=null&&ot.tonProof&&"proof"in nt.connectItems.tonProof&&await TonProofDemoApi.checkProof(nt.connectItems.tonProof.proof,nt.account),!TonProofDemoApi.accessToken){et.disconnect(),$(!1);return}$(!0)}),[et]);const rt=reactExports.useCallback(async()=>{if(!k)return;const nt=await TonProofDemoApi.getAccountInfo(k.account);d(nt)},[k]);return j?jsxs("div",{className:"ton-proof-demo",children:[jsx$1("h3",{children:"Demo backend API with ton_proof verification"}),j?jsx$1("button",{onClick:rt,children:"Call backend getAccountInfo()"}):jsx$1("div",{className:"ton-proof-demo__error",children:"Connect wallet to call API"}),jsx$1(ReactJson,{src:_,name:"response",theme:"ocean"})]}):null},style="",jetton={name:"Joint Photographic Experts Group",description:"JPEG is a commonly used method of lossy compression for digital images, particularly for those images produced by digital photography. The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality.",image_data:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAdVBMVEX///8rKytSUlITExPT09Pm5uYcHBzKysqXl5cZGRmnp6cnJydISEjr6+tOTk5LS0swMDAhISHa2tq3t7fg4OBra2sKCgrw8PB3d3dCQkJeXl49PT29vb2goKCvr68AAADOzs5jY2ODg4ONjY1wcHA2NjaSkpJ0yRZUAAAFXklEQVR4nO3de3eaMBgGcCEIxkgVCiiIVG3t9/+IS8LFS+1ERy665/ljZwW3k99yeV9x5zgaIQiCIAiCIAiCIAiCIAhiLGFQTf85iWnF7wkKQui/Z2Yt8TuLnCEyn1tKnGSD+BznzbVzFuOPgYBc6Fo5i1/DLNFa+PZmIZEMBRRC152NTYMuMx5YaN9e9IYWurYtVAVCy46b4YW27UUVQrv2ohKhVUVDidCqhapIaNFCVSW0p4FTJrSmaCgTWrMXFQot2YsqhXY0cGqFNuxFpUIrFqpioQVFQ7XQfAOnWmi+aKgXmt6LGoSG96IOodmioUNodi/qEZrci5qEBhs4bUJjs6hLaG6h6hOaKhoahYYaOI1CQ0VDq9DIXtQrNFE0dAv1HzeahQb2onah9r2oX6i7aOgX8gZO60I1INS8UI0ItTZwZoQ696IZoc6iYUqoby8aE2pr4AwKNR03Awrn9wl1LdQBhbN7hXqIAwrXdwu1FI0BhYu7hVqKxoDCByZRx0IdUsjyB4jKT9QhhY/Nouq9OKzQcQ757N4cwqcS3h+WBS8udAiEEEJoGgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQWCJmM3cIFz/F34gdCaMROb5/llEejfO6689whfb+Uz4CQlHEczyQoiD2ZIKj2efNSWjUXm8QTv/ORYrpNxstwnHhVyvoZTQi34TicS2EcjuuEYTiu6rVH3tuLza1NKyRFEHb3wtBbZX0WqwlhwAfYCGtcKAcexmvWCsNjlo2Q0c2yvtP8Ml4Ghx7TaF64X61WmyoR4962cxhWk2NS+VLmlJIWTNKiSPel/AOxe5toXpj7UeSTw7cY8affCHfE71IvRSqnNiiIHzEWRWQ9FT8nhycQ1mcOIxM+4rgVppdzQ8XtcEO76/zU4dPY42tObRE6bCF2Vs6uC9laAs++edefe4Xv3Iw1QifzuCH9RSgvBvSC3avw2yaMrgpZLia4eOibd+0RMoGYX5/DaCWm8LEO0Boh+eQ7LaHtSUOjLk5zbdJj01kpzIXCJ6u2fak1qy7iuCRbPr+7O9ptq4SrNE33E08W8AP70dMsY3GAij0664R+1uX2yjUvPOnaZu2KPG1LvYzXikRMdiv0N8su3s3Tx7ywa73LtRytFB7fXsT8gLkUTo7/BsGTCJO43BTNO8T6pHHO3x6erdJ2DsMnEYqBM+bTdvzXqoU4aY7X2KyQSZPnEZ7dviIUbTdvStsf6wcZ0fqFhKLij7cXfxfLX0jI1qLh+dHKvZDQIRWfRM85e+lrCdlBtAHv9PS17JX2Ia8Q8hlAuTj2pkw2ek8r3GW0S42ilezrVhnvyZloZNfywrMKx+W06rKpr0fvdWs33afu12ojHyyG2/xmO26p8ORpYui1NyZ1+8q78bB5pvje412+YSEf6FXhWevd3qFFuTx5Irws+zymMSwsgyC4XGf+Zhuc5b27xWix8Zq3IsG3S29PoBlhtO3WJuH5MUyfnOf0+ROj2drdpUXuE7/nG2ITnz3xNwrJ7RPit4iO1O5P1+Rzs3hxZSxqolkY+X72yetdqe+zYb3CaL/5rMRBuH/o0ecTCOl0KQuZ98toXkPIK1n9QeFLCtmuCoLyM9II1H3SMMoLnL49aEBoIBBC+N8LEwuEnlLhKLs9BMXJlmqFO72l4WfYTC1wtP0wLPwoFQtHe7M7kaaqgaPRV6//X6cmjOzUA0ej6pBR30RotpjqAPJ404mJTLeKj1EEQRAEQRAEQRAEQRAEQf6SP4jPv7WHGoGuAAAAAElFTkSuQmCC",symbol:"JPEG",decimals:9,amount:"1000000000000000"},CreateJettonDemo=()=>{const[b,_]=reactExports.useState({}),[d]=useTonConnectUI(),k=useTonWallet();return jsxs("div",{className:"create-jetton-demo",children:[jsx$1("h3",{children:"Create Jetton"}),k?jsx$1("button",{onClick:async()=>{const $=await TonProofDemoApi.createJetton(jetton);_($),"error"in $||await d.sendTransaction($)},children:"Send create jetton"}):jsx$1("div",{className:"ton-proof-demo__error",children:"Connect wallet to send transaction"}),jsx$1(ReactJson,{src:b,name:"response",theme:"ocean"})]})};function App(){return jsx$1(TonConnectUIProvider$1,{manifestUrl:"https://ton-connect.github.io/demo-dapp-with-react-ui/tonconnect-manifest.json",uiPreferences:{theme:THEME.DARK},walletsListConfiguration:{includeWallets:[{appName:"telegram-wallet",name:"Wallet",imageUrl:"https://wallet.tg/images/logo-288.png",aboutUrl:"https://wallet.tg/",universalLink:"https://t.me/wallet?attach=wallet",bridgeUrl:"https://bridge.ton.space/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"tonwallet",name:"TON Wallet",imageUrl:"https://wallet.ton.org/assets/ui/qr-logo.png",aboutUrl:"https://chrome.google.com/webstore/detail/ton-wallet/nphplpgoakhhjchkkhmiggakijnkhfnd",universalLink:"https://wallet.ton.org/ton-connect",jsBridgeKey:"tonwallet",bridgeUrl:"https://bridge.tonapi.io/bridge",platforms:["chrome","android"]},{appName:"nicegramWallet",name:"Nicegram Wallet",imageUrl:"https://static.nicegram.app/icon.png",aboutUrl:"https://nicegram.app",universalLink:"https://nicegram.app/tc",deepLink:"nicegram-tc://",jsBridgeKey:"nicegramWallet",bridgeUrl:"https://tc.nicegram.app/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"tokenpocket",name:"TokenPocket",imageUrl:"https://hk.tpstatic.net/logo/tokenpocket.png",aboutUrl:"https://www.tokenpocket.pro",universalLink:"https://tp-lab.tptool.pro/ton-connect/",jsBridgeKey:"tokenpocket",bridgeUrl:"https://ton-connect.mytokenpocket.vip/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"dewallet",name:"DeWallet",imageUrl:"https://raw.githubusercontent.com/delab-team/manifests-images/main/WalletAvatar.png",aboutUrl:"https://delabwallet.com",universalLink:"https://t.me/dewallet?attach=wallet",bridgeUrl:"https://bridge.dewallet.pro/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"cdcTonWallet",name:"Crypto.com DeFi Wallet",imageUrl:"https://apro-ncw-api-file.crypto.com/wallet/logo",aboutUrl:"https://crypto.com/defi-wallet",universalLink:"https://wallet.crypto.com/deeplink/ton-connect",deepLink:"dfw://",jsBridgeKey:"cdcTonWallet",bridgeUrl:"https://wallet.crypto.com/sse/tonbridge",platforms:["ios","android","chrome"]},{appName:"tobi",name:"Tobi",imageUrl:"https://app.tobiwallet.app/icons/logo.png",aboutUrl:"https://tobi.fun",universalLink:"https://t.me/TobiCopilotBot?attach=wallet",bridgeUrl:"https://ton-bridge.tobiwallet.app/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"trustwalletTon",name:"Trust",imageUrl:"https://assets-cdn.trustwallet.com/dapps/trust.logo.png",aboutUrl:"https://trustwallet.com/about-us",bridgeUrl:"https://tonconnect.trustwallet.com/bridge",jsBridgeKey:"trustwalletTon",platforms:["chrome","ios","android"]},{appName:"bitgetWalletLite",name:"Bitget Wallet Lite",imageUrl:"https://raw.githubusercontent.com/bitgetwallet/download/main/logo/png/bitget_wallet_lite_logo.png",aboutUrl:"https://web3.bitget.com",universalLink:"https://t.me/BitgetWallet_TGBot?attach=wallet",bridgeUrl:"https://ton-connect-bridge.bgwapi.io/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"onekey",name:"OneKey",imageUrl:"https://common.onekey-asset.com/logo/onekey-x288.png",aboutUrl:"https://onekey.so",jsBridgeKey:"onekeyTonWallet",platforms:["chrome"]},{appName:"tomoWallet",name:"Tomo Wallet",imageUrl:"https://pub.tomo.inc/logo.png",aboutUrl:"https://www.tomo.inc/",universalLink:"https://t.me/tomowalletbot?attach=wallet",bridgeUrl:"https://go-bridge.tomo.inc/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"hpyTonWallet",name:"HyperPay Wallet",imageUrl:"https://onchain-oss.hyperpay.online/images/logo.png",aboutUrl:"https://www.hyperpay.tech",universalLink:"https://www.hyperpay.tech/download&deeplink=hyperpay://web3/wallet/tonconnect",jsBridgeKey:"hpyTonWallet",bridgeUrl:"https://onchain-wallet.hyperpay.online/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"unstoppable",name:"Unstoppable Wallet",imageUrl:"https://unstoppable.money/logo288.png",aboutUrl:"https://unstoppable.money/",universalLink:"https://unstoppable.money/ton-connect",bridgeUrl:"https://bridge.unstoppable.money/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"foxwallet",name:"FoxWallet",imageUrl:"https://hc.foxwallet.com/img/logo.png",aboutUrl:"https://foxwallet.com/",universalLink:"https://link.foxwallet.com/tc",jsBridgeKey:"foxwallet",bridgeUrl:"https://connect.foxwallet.com/ton/bridge",platforms:["ios","android","macos","windows","linux"]},{appName:"jambo",name:"Jambo",imageUrl:"https://cdn-prod.jambotechnology.xyz/content/jambo_288x288_02da416a6c.png",aboutUrl:"https://www.jambo.technology/",deepLink:"jambotc://",universalLink:"https://jambophone.xyz/",bridgeUrl:"https://bridge.tonapi.io/bridge",jsBridgeKey:"jambowallet",platforms:["android","macos","windows","linux"]}]},actionsConfiguration:{twaReturnUrl:"https://t.me/DemoDappWithTonConnectBot/demo"},children:jsxs("div",{className:"app",children:[jsx$1(Header,{}),jsx$1(TxForm,{}),jsx$1(CreateJettonDemo,{}),jsx$1(TonProofDemo,{}),jsx$1(Footer,{})]})})}const index="";function runSingleInstance(b){let _=!1;return async()=>{if(!_){_=!0;try{await b()}catch(d){console.error(d)}finally{_=!1}}}}eruda.init();async function enableMocking(){const b=document.baseURI.replace(/\/$/,"");return new Promise(async _=>{const{worker:d}=await __vitePreload(()=>import("./worker-0830765a.js"),[]),k=()=>d.start({onUnhandledRequest:"bypass",quiet:!1,serviceWorker:{url:"/demo-dapp-with-react-ui/mockServiceWorker.js"}});let j=await k();_(j);const $=runSingleInstance(async()=>{var et;try{const rt=(await((et=navigator.serviceWorker)==null?void 0:et.getRegistrations())||[]).length>0,nt=await fetch(`${b}/api/healthz`).then(ot=>ot.status===200?ot.json().then(at=>at.ok).catch(()=>!1):!1).catch(()=>!1);(!rt||!nt)&&(await(j==null?void 0:j.unregister().catch(()=>{})),j=await k().catch(()=>null))}catch(tt){console.error("Error in verifyAndRestartWorker:",tt),j=await k().catch(()=>null)}});setInterval($,1e3)})}enableMocking().then(()=>reactDomExports.render(jsx$1(reactExports.StrictMode,{children:jsx$1(App,{})}),document.getElementById("root")));export{CHAIN as C,buffer as b,commonjsGlobal as c,getAugmentedNamespace as g,naclFastExports as n,require$$4 as r}; diff --git a/docs/assets/worker-fdebfe2a.js b/docs/assets/worker-0830765a.js similarity index 98% rename from docs/assets/worker-fdebfe2a.js rename to docs/assets/worker-0830765a.js index b75ac6c..28c77ea 100644 --- a/docs/assets/worker-fdebfe2a.js +++ b/docs/assets/worker-0830765a.js @@ -1,4 +1,4 @@ -var Mk=Object.defineProperty;var xk=(e,t,n)=>t in e?Mk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ae=(e,t,n)=>(xk(e,typeof t!="symbol"?t+"":t,n),n),Iu=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var En=(e,t,n)=>(Iu(e,t,"read from private field"),n?n.call(e):t.get(e)),Xo=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Ru=(e,t,n,r)=>(Iu(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);var Hr=(e,t,n)=>(Iu(e,t,"access private method"),n);import{C as Li,c as re,n as Gs,g as Ok,b as Xe,r as qi}from"./index-66f84df3.js";var Ik=/(%?)(%([sdijo]))/g;function Rk(e,t){switch(t){case"s":return e;case"d":case"i":return Number(e);case"j":return JSON.stringify(e);case"o":{if(typeof e=="string")return e;const n=JSON.stringify(e);return n==="{}"||n==="[]"||/^\[object .+?\]$/.test(n)?e:n}}}function Oo(e,...t){if(t.length===0)return e;let n=0,r=e.replace(Ik,(a,o,i,s)=>{const l=t[n],u=Rk(l,s);return o?a:(n++,u)});return nt in e?Mk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ae=(e,t,n)=>(xk(e,typeof t!="symbol"?t+"":t,n),n),Iu=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var En=(e,t,n)=>(Iu(e,t,"read from private field"),n?n.call(e):t.get(e)),Xo=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},Ru=(e,t,n,r)=>(Iu(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);var Hr=(e,t,n)=>(Iu(e,t,"access private method"),n);import{C as Li,c as re,n as Gs,g as Ok,b as Xe,r as qi}from"./index-c5d69010.js";var Ik=/(%?)(%([sdijo]))/g;function Rk(e,t){switch(t){case"s":return e;case"d":case"i":return Number(e);case"j":return JSON.stringify(e);case"o":{if(typeof e=="string")return e;const n=JSON.stringify(e);return n==="{}"||n==="[]"||/^\[object .+?\]$/.test(n)?e:n}}}function Oo(e,...t){if(t.length===0)return e;let n=0,r=e.replace(Ik,(a,o,i,s)=>{const l=t[n],u=Rk(l,s);return o?a:(n++,u)});return n{if(!e)throw new Dk(t,...n)};Kt.as=(e,t,n,...r)=>{if(!t){const a=r.length===0?n:Oo(n,...r);let o;try{o=Reflect.construct(e,[a])}catch{o=e(a)}throw o}};const Uk="[MSW]";function Kc(e,...t){const n=Oo(e,...t);return`${Uk} ${n}`}function Fk(e,...t){console.warn(Kc(e,...t))}function Lk(e,...t){console.error(Kc(e,...t))}const xe={formatMessage:Kc,warn:Fk,error:Lk};class Qd extends Error{constructor(t){super(t),this.name="InternalError"}}function qk(){Kt(typeof URL<"u",xe.formatMessage(`Global "URL" class is not defined. This likely means that you're running MSW in an environment that doesn't support all Node.js standard API (e.g. React Native). If that's the case, please use an appropriate polyfill for the "URL" class, like "react-native-url-polyfill".`))}var $k=class extends Error{constructor(t,n,r){super(`Possible EventEmitter memory leak detected. ${r} ${n.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=t,this.type=n,this.count=r,this.name="MaxListenersExceededWarning"}},Yh=class{static listenerCount(t,n){return t.listenerCount(n)}constructor(){this.events=new Map,this.maxListeners=Yh.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(t,n,r){this.emit(t,n,r)}_getListeners(t){return Array.prototype.concat.apply([],this.events.get(t))||[]}_removeListener(t,n){const r=t.indexOf(n);return r>-1&&t.splice(r,1),[]}_wrapOnceListener(t,n){const r=(...a)=>(this.removeListener(t,r),n.apply(this,a));return Object.defineProperty(r,"name",{value:n.name}),r}setMaxListeners(t){return this.maxListeners=t,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(t,...n){const r=this._getListeners(t);return r.forEach(a=>{a.apply(this,n)}),r.length>0}addListener(t,n){this._emitInternalEvent("newListener",t,n);const r=this._getListeners(t).concat(n);if(this.events.set(t,r),this.maxListeners>0&&this.listenerCount(t)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const a=new $k(this,t,this.listenerCount(t));console.warn(a)}return this}on(t,n){return this.addListener(t,n)}once(t,n){return this.addListener(t,this._wrapOnceListener(t,n))}prependListener(t,n){const r=this._getListeners(t);if(r.length>0){const a=[n].concat(r);this.events.set(t,a)}else this.events.set(t,r.concat(n));return this}prependOnceListener(t,n){return this.prependListener(t,this._wrapOnceListener(t,n))}removeListener(t,n){const r=this._getListeners(t);return r.length>0&&(this._removeListener(r,n),this.events.set(t,r),this._emitInternalEvent("removeListener",t,n)),this}off(t,n){return this.removeListener(t,n)}removeAllListeners(t){return t?this.events.delete(t):this.events.clear(),this}listeners(t){return Array.from(this._getListeners(t))}listenerCount(t){return this._getListeners(t).length}rawListeners(t){return this.listeners(t)}},Ys=Yh;Ys.defaultMaxListeners=10;function Wk(e,t){const n=e.emit;if(n._isPiped)return;const r=function(o,...i){return t.emit(o,...i),n.call(this,o,...i)};r._isPiped=!0,e.emit=r}function Hk(e){const t=[...e];return Object.freeze(t),t}class Vk{constructor(){Ae(this,"subscriptions",[])}dispose(){let t;for(;t=this.subscriptions.shift();)t()}}class Jk{constructor(t){Ae(this,"handlers");this.initialHandlers=t,this.handlers=[...t]}prepend(t){this.handlers.unshift(...t)}reset(t){this.handlers=t.length>0?[...t]:[...this.initialHandlers]}currentHandlers(){return this.handlers}}class Kk extends Vk{constructor(...n){super();Ae(this,"handlersController");Ae(this,"emitter");Ae(this,"publicEmitter");Ae(this,"events");Kt(this.validateHandlers(n),xe.formatMessage("Failed to apply given request handlers: invalid input. Did you forget to spread the request handlers Array?")),this.handlersController=new Jk(n),this.emitter=new Ys,this.publicEmitter=new Ys,Wk(this.emitter,this.publicEmitter),this.events=this.createLifeCycleEvents(),this.subscriptions.push(()=>{this.emitter.removeAllListeners(),this.publicEmitter.removeAllListeners()})}validateHandlers(n){return n.every(r=>!Array.isArray(r))}use(...n){Kt(this.validateHandlers(n),xe.formatMessage('Failed to call "use()" with the given request handlers: invalid input. Did you forget to spread the array of request handlers?')),this.handlersController.prepend(n)}restoreHandlers(){this.handlersController.currentHandlers().forEach(n=>{"isUsed"in n&&(n.isUsed=!1)})}resetHandlers(...n){this.handlersController.reset(n)}listHandlers(){return Hk(this.handlersController.currentHandlers())}createLifeCycleEvents(){return{on:(...n)=>this.publicEmitter.on(...n),removeListener:(...n)=>this.publicEmitter.removeListener(...n),removeAllListeners:(...n)=>this.publicEmitter.removeAllListeners(...n)}}}const Gk=/[\/\\]msw[\/\\]src[\/\\](.+)/,Yk=/(node_modules)?[\/\\]lib[\/\\](core|browser|node|native|iife)[\/\\]|^[^\/\\]*$/;function Qk(e){const t=e.stack;if(!t)return;const r=t.split(` `).slice(1).find(o=>!(Gk.test(o)||Yk.test(o)));return r?r.replace(/\s*at [^()]*\(([^)]+)\)/,"$1").replace(/^@/,""):void 0}function Zk(e){return e?Reflect.has(e,Symbol.iterator)||Reflect.has(e,Symbol.asyncIterator):!1}const Fi=class Fi{constructor(t){Ae(this,"__kind");Ae(this,"info");Ae(this,"isUsed");Ae(this,"resolver");Ae(this,"resolverIterator");Ae(this,"resolverIteratorResult");Ae(this,"options");this.resolver=t.resolver,this.options=t.options;const n=Qk(new Error);this.info={...t.info,callFrame:n},this.isUsed=!1,this.__kind="RequestHandler"}async parse(t){return{}}async test(t){const n=await this.parse({request:t.request,resolutionContext:t.resolutionContext});return this.predicate({request:t.request,parsedResult:n,resolutionContext:t.resolutionContext})}extendResolverArgs(t){return{}}cloneRequestOrGetFromCache(t){const n=Fi.cache.get(t);if(typeof n<"u")return n;const r=t.clone();return Fi.cache.set(t,r),r}async run(t){var c,d;if(this.isUsed&&((c=this.options)!=null&&c.once))return null;const n=this.cloneRequestOrGetFromCache(t.request),r=await this.parse({request:t.request,resolutionContext:t.resolutionContext});if(!this.predicate({request:t.request,parsedResult:r,resolutionContext:t.resolutionContext})||this.isUsed&&((d=this.options)!=null&&d.once))return null;this.isUsed=!0;const o=this.wrapResolver(this.resolver),i=this.extendResolverArgs({request:t.request,parsedResult:r}),l=await o({...i,requestId:t.requestId,request:t.request}).catch(y=>{if(y instanceof Response)return y;throw y});return this.createExecutionResult({request:n,requestId:t.requestId,response:l,parsedResult:r})}wrapResolver(t){return async n=>{var i;if(!this.resolverIterator){const s=await t(n);if(!Zk(s))return s;this.resolverIterator=Symbol.iterator in s?s[Symbol.iterator]():s[Symbol.asyncIterator]()}this.isUsed=!1;const{done:r,value:a}=await this.resolverIterator.next(),o=await a;return o&&(this.resolverIteratorResult=o.clone()),r?(this.isUsed=!0,(i=this.resolverIteratorResult)==null?void 0:i.clone()):o}}createExecutionResult(t){return{handler:this,request:t.request,requestId:t.requestId,response:t.response,parsedResult:t.parsedResult}}};Ae(Fi,"cache",new WeakMap);let Qs=Fi;function Xk(e,t){return e.toLowerCase()===t.toLowerCase()}function ew(e){return e<300?"#69AB32":e<400?"#F0BB4B":"#E95F5D"}function Lr(e){const t=new Date,n=`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}`;return e!=null&&e.milliseconds?`${n}.${t.getMilliseconds().toString().padStart(3,"0")}`:n}async function tw(e){const n=await e.clone().text();return{url:new URL(e.url),method:e.method,headers:Object.fromEntries(e.headers.entries()),body:n}}var nw=Object.create,Qh=Object.defineProperty,rw=Object.getOwnPropertyDescriptor,Zh=Object.getOwnPropertyNames,aw=Object.getPrototypeOf,ow=Object.prototype.hasOwnProperty,Xh=(e,t)=>function(){return t||(0,e[Zh(e)[0]])((t={exports:{}}).exports,t),t.exports},iw=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Zh(t))!ow.call(e,a)&&a!==n&&Qh(e,a,{get:()=>t[a],enumerable:!(r=rw(t,a))||r.enumerable});return e},sw=(e,t,n)=>(n=e!=null?nw(aw(e)):{},iw(t||!e||!e.__esModule?Qh(n,"default",{value:e,enumerable:!0}):n,e)),lw=Xh({"node_modules/statuses/codes.json"(e,t){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a Teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}}}),uw=Xh({"node_modules/statuses/index.js"(e,t){var n=lw();t.exports=s,s.message=n,s.code=r(n),s.codes=a(n),s.redirect={300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0},s.empty={204:!0,205:!0,304:!0},s.retry={502:!0,503:!0,504:!0};function r(l){var u={};return Object.keys(l).forEach(function(d){var y=l[d],m=Number(d);u[y.toLowerCase()]=m}),u}function a(l){return Object.keys(l).map(function(c){return Number(c)})}function o(l){var u=l.toLowerCase();if(!Object.prototype.hasOwnProperty.call(s.code,u))throw new Error('invalid status message: "'+l+'"');return s.code[u]}function i(l){if(!Object.prototype.hasOwnProperty.call(s.message,l))throw new Error("invalid status code: "+l);return s.message[l]}function s(l){if(typeof l=="number")return i(l);if(typeof l!="string")throw new TypeError("code must be a number or string");var u=parseInt(l,10);return isNaN(u)?o(l):i(u)}}}),cw=sw(uw(),1),em=cw.default;/*! Bundled license information: @@ -240,7 +240,7 @@ tough-cookie/lib/cookie.js: ${a?` • Request body: ${a} `:""}`}If you still wish to intercept this unhandled request, please create a request handler for it. -Read more: https://mswjs.io/docs/getting-started/mocks`;function s(l){switch(l){case"error":throw xe.error("Error: %s",i),new Qd(xe.formatMessage('Cannot bypass a request when using the "error" strategy for the "onUnhandledRequest" option.'));case"warn":{xe.warn("Warning: %s",i);break}case"bypass":break;default:throw new Qd(xe.formatMessage('Failed to react to an unhandled request: unknown strategy "%s". Please provide one of the supported strategies ("bypass", "warn", "error") or a custom callback function as the value of the "onUnhandledRequest" option.',l))}}if(typeof t=="function"){t(e,{warning:s.bind(null,"warn"),error:s.bind(null,"error")});return}n.protocol!=="file:"&&s(t)}const{message:Hv}=em,Em=Symbol("kSetCookie");function Vr(e={}){const t=(e==null?void 0:e.status)||200,n=(e==null?void 0:e.statusText)||Hv[t]||"",r=new Headers(e==null?void 0:e.headers);return{...e,headers:r,status:t,statusText:n}}function Vv(e,t){t.type&&Object.defineProperty(e,"type",{value:t.type,enumerable:!0,writable:!1});const n=t.headers.get("set-cookie");if(n&&(Object.defineProperty(e,Em,{value:n,enumerable:!1,writable:!1}),typeof document<"u")){const r=Uv.prototype.getSetCookie.call(t.headers);for(const a of r)document.cookie=a}return e}function Jv(e,t){const n=Reflect.get(t,Em);n&&km.setCookie(n,e.url)}async function Am(e,t,n,r,a,o){var u,c,d,y,m,p;if(a.emit("request:start",{request:e,requestId:t}),(u=e.headers.get("accept"))!=null&&u.includes("msw/passthrough")){a.emit("request:end",{request:e,requestId:t}),(c=o==null?void 0:o.onPassthroughResponse)==null||c.call(o,e);return}const i=await $v(()=>Wv({request:e,requestId:t,handlers:n,resolutionContext:o==null?void 0:o.resolutionContext}));if(i.error)throw a.emit("unhandledException",{error:i.error,request:e,requestId:t}),i.error;if(!i.data){await Cm(e,r.onUnhandledRequest),a.emit("request:unhandled",{request:e,requestId:t}),a.emit("request:end",{request:e,requestId:t}),(d=o==null?void 0:o.onPassthroughResponse)==null||d.call(o,e);return}const{response:s}=i.data;if(!s){a.emit("request:end",{request:e,requestId:t}),(y=o==null?void 0:o.onPassthroughResponse)==null||y.call(o,e);return}if(s.status===302&&s.headers.get("x-msw-intention")==="passthrough"){a.emit("request:end",{request:e,requestId:t}),(m=o==null?void 0:o.onPassthroughResponse)==null||m.call(o,e);return}Jv(e,s),a.emit("request:match",{request:e,requestId:t});const l=i.data;return(p=o==null?void 0:o.onMockedResponse)==null||p.call(o,s,l),a.emit("request:end",{request:e,requestId:t}),s}class dn extends Response{constructor(t,n){const r=Vr(n);super(t,r),Vv(this,r)}static text(t,n){const r=Vr(n);return r.headers.has("Content-Type")||r.headers.set("Content-Type","text/plain"),r.headers.has("Content-Length")||r.headers.set("Content-Length",t?new Blob([t]).size.toString():"0"),new dn(t,r)}static json(t,n){const r=Vr(n);r.headers.has("Content-Type")||r.headers.set("Content-Type","application/json");const a=JSON.stringify(t);return r.headers.has("Content-Length")||r.headers.set("Content-Length",a?new Blob([a]).size.toString():"0"),new dn(a,r)}static xml(t,n){const r=Vr(n);return r.headers.has("Content-Type")||r.headers.set("Content-Type","text/xml"),new dn(t,r)}static html(t,n){const r=Vr(n);return r.headers.has("Content-Type")||r.headers.set("Content-Type","text/html"),new dn(t,r)}static arrayBuffer(t,n){const r=Vr(n);return t&&!r.headers.has("Content-Length")&&r.headers.set("Content-Length",t.byteLength.toString()),new dn(t,r)}static formData(t,n){return new dn(t,Vr(n))}}qk();function Kv(e){return{status:e.status,statusText:e.statusText,headers:Object.fromEntries(e.headers.entries())}}function Gc(e){return t=>t!=null&&typeof t=="object"&&"__kind"in t&&t.__kind===e}function uf(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Sm(e,t){return Object.entries(t).reduce((n,[r,a])=>{const o=n[r];return Array.isArray(o)&&Array.isArray(a)?(n[r]=o.concat(a),n):uf(o)&&uf(a)?(n[r]=Sm(o,a),n):(n[r]=a,n)},Object.assign({},e))}function Gv(e){const t=Object.getOwnPropertyDescriptor(globalThis,e);return typeof t>"u"||typeof t.get=="function"&&typeof t.get()>"u"||typeof t.get>"u"&&t.value==null?!1:typeof t.set>"u"&&!t.configurable?(console.error(`[MSW] Failed to apply interceptor: the global \`${e}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`),!1):!0}function st(e,t){return Object.defineProperties(t,{target:{value:e,enumerable:!0,writable:!0},currentTarget:{value:e,enumerable:!0,writable:!0}}),t}var oo=Symbol("kCancelable"),hn=Symbol("kDefaultPrevented"),Yc=class extends MessageEvent{constructor(e,t){super(e,t),this[oo]=!!t.cancelable,this[hn]=!1}get cancelable(){return this[oo]}set cancelable(e){this[oo]=e}get defaultPrevented(){return this[hn]}set defaultPrevented(e){this[hn]=e}preventDefault(){this.cancelable&&!this[hn]&&(this[hn]=!0)}},kl=class extends Event{constructor(e,t={}){super(e,t),this.code=t.code===void 0?0:t.code,this.reason=t.reason===void 0?"":t.reason,this.wasClean=t.wasClean===void 0?!1:t.wasClean}},cf=class extends kl{constructor(e,t={}){super(e,t),this[oo]=!!t.cancelable,this[hn]=!1}get cancelable(){return this[oo]}set cancelable(e){this[oo]=e}get defaultPrevented(){return this[hn]}set defaultPrevented(e){this[hn]=e}preventDefault(){this.cancelable&&!this[hn]&&(this[hn]=!0)}},ai=Symbol("kEmitter"),Bs=Symbol("kBoundListener"),Yv=class{constructor(e,t){this.socket=e,this.transport=t,this.id=Iw(),this.url=new URL(e.url),this[ai]=new EventTarget,this.transport.addEventListener("outgoing",n=>{const r=st(this.socket,new Yc("message",{data:n.data,origin:n.origin,cancelable:!0}));this[ai].dispatchEvent(r),r.defaultPrevented&&n.preventDefault()}),this.transport.addEventListener("close",n=>{this[ai].dispatchEvent(st(this.socket,new kl("close",n)))})}addEventListener(e,t,n){if(!Reflect.has(t,Bs)){const r=t.bind(this.socket);Object.defineProperty(t,Bs,{value:r,enumerable:!1,configurable:!1})}this[ai].addEventListener(e,Reflect.get(t,Bs),n)}removeEventListener(e,t,n){this[ai].removeEventListener(e,Reflect.get(t,Bs),n)}send(e){this.transport.send(e)}close(e,t){this.transport.close(e,t)}},df="InvalidAccessError: close code out of user configurable range",Zs=Symbol("kPassthroughPromise"),Tm=Symbol("kOnSend"),$i=Symbol("kClose"),es=class extends EventTarget{constructor(e,t){super(),this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this._onopen=null,this._onmessage=null,this._onerror=null,this._onclose=null,this.url=e.toString(),this.protocol="",this.extensions="",this.binaryType="blob",this.readyState=this.CONNECTING,this.bufferedAmount=0,this[Zs]=new qv,queueMicrotask(async()=>{await this[Zs]||(this.protocol=typeof t=="string"?t:Array.isArray(t)&&t.length>0?t[0]:"",this.readyState===this.CONNECTING&&(this.readyState=this.OPEN,this.dispatchEvent(st(this,new Event("open")))))})}set onopen(e){this.removeEventListener("open",this._onopen),this._onopen=e,e!==null&&this.addEventListener("open",e)}get onopen(){return this._onopen}set onmessage(e){this.removeEventListener("message",this._onmessage),this._onmessage=e,e!==null&&this.addEventListener("message",e)}get onmessage(){return this._onmessage}set onerror(e){this.removeEventListener("error",this._onerror),this._onerror=e,e!==null&&this.addEventListener("error",e)}get onerror(){return this._onerror}set onclose(e){this.removeEventListener("close",this._onclose),this._onclose=e,e!==null&&this.addEventListener("close",e)}get onclose(){return this._onclose}send(e){if(this.readyState===this.CONNECTING)throw this.close(),new DOMException("InvalidStateError");this.readyState===this.CLOSING||this.readyState===this.CLOSED||(this.bufferedAmount+=Qv(e),queueMicrotask(()=>{var t;this.bufferedAmount=0,(t=this[Tm])==null||t.call(this,e)}))}close(e=1e3,t){Kt(e,df),Kt(e===1e3||e>=3e3&&e<=4999,df),this[$i](e,t)}[$i](e=1e3,t,n=!0){this.readyState===this.CLOSING||this.readyState===this.CLOSED||(this.readyState=this.CLOSING,queueMicrotask(()=>{this.readyState=this.CLOSED,this.dispatchEvent(st(this,new kl("close",{code:e,reason:t,wasClean:n}))),this._onopen=null,this._onmessage=null,this._onerror=null,this._onclose=null}))}addEventListener(e,t,n){return super.addEventListener(e,t,n)}removeEventListener(e,t,n){return super.removeEventListener(e,t,n)}};es.CONNECTING=0;es.OPEN=1;es.CLOSING=2;es.CLOSED=3;function Qv(e){return typeof e=="string"?e.length:e instanceof Blob?e.size:e.byteLength}var nr=Symbol("kEmitter"),Ms=Symbol("kBoundListener"),Du=Symbol("kSend"),Zv=class{constructor(e,t,n){this.client=e,this.transport=t,this.createConnection=n,this[nr]=new EventTarget,this.mockCloseController=new AbortController,this.realCloseController=new AbortController,this.transport.addEventListener("outgoing",r=>{typeof this.realWebSocket>"u"||queueMicrotask(()=>{r.defaultPrevented||this[Du](r.data)})}),this.transport.addEventListener("incoming",this.handleIncomingMessage.bind(this))}get socket(){return Kt(this.realWebSocket,'Cannot access "socket" on the original WebSocket server object: the connection is not open. Did you forget to call `server.connect()`?'),this.realWebSocket}connect(){Kt(!this.realWebSocket||this.realWebSocket.readyState!==WebSocket.OPEN,'Failed to call "connect()" on the original WebSocket instance: the connection already open');const e=this.createConnection();e.binaryType=this.client.binaryType,e.addEventListener("open",t=>{this[nr].dispatchEvent(st(this.realWebSocket,new Event("open",t)))},{once:!0}),e.addEventListener("message",t=>{this.transport.dispatchEvent(st(this.realWebSocket,new MessageEvent("incoming",{data:t.data,origin:t.origin})))}),this.client.addEventListener("close",t=>{this.handleMockClose(t)},{signal:this.mockCloseController.signal}),e.addEventListener("close",t=>{this.handleRealClose(t)},{signal:this.realCloseController.signal}),e.addEventListener("error",()=>{const t=st(e,new Event("error",{cancelable:!0}));this[nr].dispatchEvent(t),t.defaultPrevented||this.client.dispatchEvent(st(this.client,new Event("error")))}),this.realWebSocket=e}addEventListener(e,t,n){if(!Reflect.has(t,Ms)){const r=t.bind(this.client);Object.defineProperty(t,Ms,{value:r,enumerable:!1})}this[nr].addEventListener(e,Reflect.get(t,Ms),n)}removeEventListener(e,t,n){this[nr].removeEventListener(e,Reflect.get(t,Ms),n)}send(e){this[Du](e)}[Du](e){const{realWebSocket:t}=this;if(Kt(t,'Failed to call "server.send()" for "%s": the connection is not open. Did you forget to call "server.connect()"?',this.client.url),!(t.readyState===WebSocket.CLOSING||t.readyState===WebSocket.CLOSED)){if(t.readyState===WebSocket.CONNECTING){t.addEventListener("open",()=>{t.send(e)},{once:!0});return}t.send(e)}}close(){const{realWebSocket:e}=this;Kt(e,'Failed to close server connection for "%s": the connection is not open. Did you forget to call "server.connect()"?',this.client.url),this.realCloseController.abort(),!(e.readyState===WebSocket.CLOSING||e.readyState===WebSocket.CLOSED)&&(e.close(),queueMicrotask(()=>{this[nr].dispatchEvent(st(this.realWebSocket,new cf("close",{code:1e3,cancelable:!0})))}))}handleIncomingMessage(e){const t=st(e.target,new Yc("message",{data:e.data,origin:e.origin,cancelable:!0}));this[nr].dispatchEvent(t),t.defaultPrevented||this.client.dispatchEvent(st(this.client,new MessageEvent("message",{data:e.data,origin:e.origin})))}handleMockClose(e){this.realWebSocket&&this.realWebSocket.close()}handleRealClose(e){this.mockCloseController.abort();const t=st(this.realWebSocket,new cf("close",{code:e.code,reason:e.reason,wasClean:e.wasClean,cancelable:!0}));this[nr].dispatchEvent(t),t.defaultPrevented||this.client[$i](e.code,e.reason)}},Xv=class extends EventTarget{constructor(e){super(),this.socket=e,this.socket.addEventListener("close",t=>{this.dispatchEvent(st(this.socket,new kl("close",t)))}),this.socket[Tm]=t=>{this.dispatchEvent(st(this.socket,new Yc("outgoing",{data:t,origin:this.socket.url,cancelable:!0})))}}addEventListener(e,t,n){return super.addEventListener(e,t,n)}dispatchEvent(e){return super.dispatchEvent(e)}send(e){queueMicrotask(()=>{if(this.socket.readyState===this.socket.CLOSING||this.socket.readyState===this.socket.CLOSED)return;const t=()=>{this.socket.dispatchEvent(st(this.socket,new MessageEvent("message",{data:e,origin:this.socket.url})))};this.socket.readyState===this.socket.CONNECTING?this.socket.addEventListener("open",()=>{t()},{once:!0}):t()})}close(e,t){this.socket[$i](e,t)}},Pm=class extends Ow{constructor(){super(Pm.symbol)}checkEnvironment(){return Gv("WebSocket")}setup(){const e=Object.getOwnPropertyDescriptor(globalThis,"WebSocket"),t=new Proxy(globalThis.WebSocket,{construct:(n,r,a)=>{const[o,i]=r,s=()=>Reflect.construct(n,r,a),l=new es(o,i),u=new Xv(l);return queueMicrotask(()=>{try{const c=new Zv(l,u,s);this.emitter.emit("connection",{client:new Yv(l,u),server:c,info:{protocols:i}})?l[Zs].resolve(!1):(l[Zs].resolve(!0),c.connect(),c.addEventListener("open",()=>{l.dispatchEvent(st(l,new Event("open"))),c.realWebSocket&&(l.protocol=c.realWebSocket.protocol)}))}catch(c){c instanceof Error&&(l.dispatchEvent(new Event("error")),l.readyState!==WebSocket.CLOSING&&l.readyState!==WebSocket.CLOSED&&l[$i](1011,c.message,!1),console.error(c))}}),l}});Object.defineProperty(globalThis,"WebSocket",{value:t,configurable:!0}),this.subscriptions.push(()=>{Object.defineProperty(globalThis,"WebSocket",e)})}},Bm=Pm;Bm.symbol=Symbol("websocket");const pc=new Bm;function e0(e){pc.on("connection",async t=>{const n=e.getHandlers(),r=new MessageEvent("connection",{data:t}),a=[];for(const o of n)Gc("EventHandler")(o)&&o.predicate({event:r,parsedResult:o.parse({event:r})})&&a.push(o);if(a.length>0){e==null||e.onMockedConnection(t);for(const o of a)o[Fv](r)}else{const o=new Request(t.client.url,{headers:{upgrade:"websocket",connection:"upgrade"}});await Cm(o,e.getUnhandledRequestStrategy()).catch(i=>{const s=new Event("error");Object.defineProperty(s,"cause",{enumerable:!0,configurable:!1,value:i}),t.client.socket.dispatchEvent(s)}),e==null||e.onPassthroughConnection(t),t.server.connect()}})}function wl(e){return e instanceof Blob?e.size:e instanceof ArrayBuffer?e.byteLength:new Blob([e]).size}const ff=24;function Uu(e){return e.length<=ff?e:`${e.slice(0,ff)}…`}async function vl(e){if(e instanceof Blob){const t=await e.text();return`Blob(${Uu(t)})`}if(typeof e=="object"&&"byteLength"in e){const t=new TextDecoder().decode(e);return`ArrayBuffer(${Uu(t)})`}return Uu(e)}const $a={system:"#3b82f6",outgoing:"#22c55e",incoming:"#ef4444",mocked:"#ff6a33"};function t0(e){const{client:t,server:n}=e;n0(t),t.addEventListener("message",r=>{o0(r)}),t.addEventListener("close",r=>{r0(r)}),t.socket.addEventListener("error",r=>{a0(r)}),t.send=new Proxy(t.send,{apply(r,a,o){const[i]=o,s=new MessageEvent("message",{data:i});return Object.defineProperties(s,{currentTarget:{enumerable:!0,writable:!1,value:t.socket},target:{enumerable:!0,writable:!1,value:t.socket}}),queueMicrotask(()=>{s0(s)}),Reflect.apply(r,a,o)}}),n.addEventListener("open",()=>{n.addEventListener("message",r=>{l0(r)})},{once:!0}),n.send=new Proxy(n.send,{apply(r,a,o){const[i]=o,s=new MessageEvent("message",{data:i});return Object.defineProperties(s,{currentTarget:{enumerable:!0,writable:!1,value:n.socket},target:{enumerable:!0,writable:!1,value:n.socket}}),i0(s),Reflect.apply(r,a,o)}})}function n0(e){const t=Xi(e.url);console.groupCollapsed(xe.formatMessage(`${Lr()} %c▶%c ${t}`),`color:${$a.system}`,"color:inherit"),console.log("Client:",e.socket),console.groupEnd()}function r0(e){const t=e.target,n=Xi(t.url);console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c■%c ${n}`),`color:${$a.system}`,"color:inherit"),console.log(e),console.groupEnd()}function a0(e){const t=e.target,n=Xi(t.url);console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c×%c ${n}`),`color:${$a.system}`,"color:inherit"),console.log(e),console.groupEnd()}async function o0(e){const t=wl(e.data),n=await vl(e.data),r=e.defaultPrevented?"⇡":"⬆";console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c${r}%c ${n} %c${t}%c`),`color:${$a.outgoing}`,"color:inherit","color:gray;font-weight:normal","color:inherit;font-weight:inherit"),console.log(e),console.groupEnd()}async function i0(e){const t=wl(e.data),n=await vl(e.data);console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c⬆%c ${n} %c${t}%c`),`color:${$a.mocked}`,"color:inherit","color:gray;font-weight:normal","color:inherit;font-weight:inherit"),console.log(e),console.groupEnd()}async function s0(e){const t=wl(e.data),n=await vl(e.data);console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c⬇%c ${n} %c${t}%c`),`color:${$a.mocked}`,"color:inherit","color:gray;font-weight:normal","color:inherit;font-weight:inherit"),console.log(e),console.groupEnd()}async function l0(e){const t=wl(e.data),n=await vl(e.data),r=e.defaultPrevented?"⇣":"⬇";console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c${r}%c ${n} %c${t}%c`),`color:${$a.incoming}`,"color:inherit","color:gray;font-weight:normal","color:inherit;font-weight:inherit"),console.log(e),console.groupEnd()}var u0=/(%?)(%([sdijo]))/g;function c0(e,t){switch(t){case"s":return e;case"d":case"i":return Number(e);case"j":return JSON.stringify(e);case"o":{if(typeof e=="string")return e;const n=JSON.stringify(e);return n==="{}"||n==="[]"||/^\[object .+?\]$/.test(n)?e:n}}}function ts(e,...t){if(t.length===0)return e;let n=0,r=e.replace(u0,(a,o,i,s)=>{const l=t[n],u=c0(l,s);return o?a:(n++,u)});return nWv({request:e,requestId:t,handlers:n,resolutionContext:o==null?void 0:o.resolutionContext}));if(i.error)throw a.emit("unhandledException",{error:i.error,request:e,requestId:t}),i.error;if(!i.data){await Cm(e,r.onUnhandledRequest),a.emit("request:unhandled",{request:e,requestId:t}),a.emit("request:end",{request:e,requestId:t}),(d=o==null?void 0:o.onPassthroughResponse)==null||d.call(o,e);return}const{response:s}=i.data;if(!s){a.emit("request:end",{request:e,requestId:t}),(y=o==null?void 0:o.onPassthroughResponse)==null||y.call(o,e);return}if(s.status===302&&s.headers.get("x-msw-intention")==="passthrough"){a.emit("request:end",{request:e,requestId:t}),(m=o==null?void 0:o.onPassthroughResponse)==null||m.call(o,e);return}Jv(e,s),a.emit("request:match",{request:e,requestId:t});const l=i.data;return(p=o==null?void 0:o.onMockedResponse)==null||p.call(o,s,l),a.emit("request:end",{request:e,requestId:t}),s}class dn extends Response{constructor(t,n){const r=Vr(n);super(t,r),Vv(this,r)}static text(t,n){const r=Vr(n);return r.headers.has("Content-Type")||r.headers.set("Content-Type","text/plain"),r.headers.has("Content-Length")||r.headers.set("Content-Length",t?new Blob([t]).size.toString():"0"),new dn(t,r)}static json(t,n){const r=Vr(n);r.headers.has("Content-Type")||r.headers.set("Content-Type","application/json");const a=JSON.stringify(t);return r.headers.has("Content-Length")||r.headers.set("Content-Length",a?new Blob([a]).size.toString():"0"),new dn(a,r)}static xml(t,n){const r=Vr(n);return r.headers.has("Content-Type")||r.headers.set("Content-Type","text/xml"),new dn(t,r)}static html(t,n){const r=Vr(n);return r.headers.has("Content-Type")||r.headers.set("Content-Type","text/html"),new dn(t,r)}static arrayBuffer(t,n){const r=Vr(n);return r.headers.has("Content-Type")||r.headers.set("Content-Type","application/octet-stream"),t&&!r.headers.has("Content-Length")&&r.headers.set("Content-Length",t.byteLength.toString()),new dn(t,r)}static formData(t,n){return new dn(t,Vr(n))}}qk();function Kv(e){return{status:e.status,statusText:e.statusText,headers:Object.fromEntries(e.headers.entries())}}function Gc(e){return t=>t!=null&&typeof t=="object"&&"__kind"in t&&t.__kind===e}function uf(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Sm(e,t){return Object.entries(t).reduce((n,[r,a])=>{const o=n[r];return Array.isArray(o)&&Array.isArray(a)?(n[r]=o.concat(a),n):uf(o)&&uf(a)?(n[r]=Sm(o,a),n):(n[r]=a,n)},Object.assign({},e))}function Gv(e){const t=Object.getOwnPropertyDescriptor(globalThis,e);return typeof t>"u"||typeof t.get=="function"&&typeof t.get()>"u"||typeof t.get>"u"&&t.value==null?!1:typeof t.set>"u"&&!t.configurable?(console.error(`[MSW] Failed to apply interceptor: the global \`${e}\` property is non-configurable. This is likely an issue with your environment. If you are using a framework, please open an issue about this in their repository.`),!1):!0}function st(e,t){return Object.defineProperties(t,{target:{value:e,enumerable:!0,writable:!0},currentTarget:{value:e,enumerable:!0,writable:!0}}),t}var oo=Symbol("kCancelable"),hn=Symbol("kDefaultPrevented"),Yc=class extends MessageEvent{constructor(e,t){super(e,t),this[oo]=!!t.cancelable,this[hn]=!1}get cancelable(){return this[oo]}set cancelable(e){this[oo]=e}get defaultPrevented(){return this[hn]}set defaultPrevented(e){this[hn]=e}preventDefault(){this.cancelable&&!this[hn]&&(this[hn]=!0)}},kl=class extends Event{constructor(e,t={}){super(e,t),this.code=t.code===void 0?0:t.code,this.reason=t.reason===void 0?"":t.reason,this.wasClean=t.wasClean===void 0?!1:t.wasClean}},cf=class extends kl{constructor(e,t={}){super(e,t),this[oo]=!!t.cancelable,this[hn]=!1}get cancelable(){return this[oo]}set cancelable(e){this[oo]=e}get defaultPrevented(){return this[hn]}set defaultPrevented(e){this[hn]=e}preventDefault(){this.cancelable&&!this[hn]&&(this[hn]=!0)}},ai=Symbol("kEmitter"),Bs=Symbol("kBoundListener"),Yv=class{constructor(e,t){this.socket=e,this.transport=t,this.id=Iw(),this.url=new URL(e.url),this[ai]=new EventTarget,this.transport.addEventListener("outgoing",n=>{const r=st(this.socket,new Yc("message",{data:n.data,origin:n.origin,cancelable:!0}));this[ai].dispatchEvent(r),r.defaultPrevented&&n.preventDefault()}),this.transport.addEventListener("close",n=>{this[ai].dispatchEvent(st(this.socket,new kl("close",n)))})}addEventListener(e,t,n){if(!Reflect.has(t,Bs)){const r=t.bind(this.socket);Object.defineProperty(t,Bs,{value:r,enumerable:!1,configurable:!1})}this[ai].addEventListener(e,Reflect.get(t,Bs),n)}removeEventListener(e,t,n){this[ai].removeEventListener(e,Reflect.get(t,Bs),n)}send(e){this.transport.send(e)}close(e,t){this.transport.close(e,t)}},df="InvalidAccessError: close code out of user configurable range",Zs=Symbol("kPassthroughPromise"),Tm=Symbol("kOnSend"),$i=Symbol("kClose"),es=class extends EventTarget{constructor(e,t){super(),this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this._onopen=null,this._onmessage=null,this._onerror=null,this._onclose=null,this.url=e.toString(),this.protocol="",this.extensions="",this.binaryType="blob",this.readyState=this.CONNECTING,this.bufferedAmount=0,this[Zs]=new qv,queueMicrotask(async()=>{await this[Zs]||(this.protocol=typeof t=="string"?t:Array.isArray(t)&&t.length>0?t[0]:"",this.readyState===this.CONNECTING&&(this.readyState=this.OPEN,this.dispatchEvent(st(this,new Event("open")))))})}set onopen(e){this.removeEventListener("open",this._onopen),this._onopen=e,e!==null&&this.addEventListener("open",e)}get onopen(){return this._onopen}set onmessage(e){this.removeEventListener("message",this._onmessage),this._onmessage=e,e!==null&&this.addEventListener("message",e)}get onmessage(){return this._onmessage}set onerror(e){this.removeEventListener("error",this._onerror),this._onerror=e,e!==null&&this.addEventListener("error",e)}get onerror(){return this._onerror}set onclose(e){this.removeEventListener("close",this._onclose),this._onclose=e,e!==null&&this.addEventListener("close",e)}get onclose(){return this._onclose}send(e){if(this.readyState===this.CONNECTING)throw this.close(),new DOMException("InvalidStateError");this.readyState===this.CLOSING||this.readyState===this.CLOSED||(this.bufferedAmount+=Qv(e),queueMicrotask(()=>{var t;this.bufferedAmount=0,(t=this[Tm])==null||t.call(this,e)}))}close(e=1e3,t){Kt(e,df),Kt(e===1e3||e>=3e3&&e<=4999,df),this[$i](e,t)}[$i](e=1e3,t,n=!0){this.readyState===this.CLOSING||this.readyState===this.CLOSED||(this.readyState=this.CLOSING,queueMicrotask(()=>{this.readyState=this.CLOSED,this.dispatchEvent(st(this,new kl("close",{code:e,reason:t,wasClean:n}))),this._onopen=null,this._onmessage=null,this._onerror=null,this._onclose=null}))}addEventListener(e,t,n){return super.addEventListener(e,t,n)}removeEventListener(e,t,n){return super.removeEventListener(e,t,n)}};es.CONNECTING=0;es.OPEN=1;es.CLOSING=2;es.CLOSED=3;function Qv(e){return typeof e=="string"?e.length:e instanceof Blob?e.size:e.byteLength}var nr=Symbol("kEmitter"),Ms=Symbol("kBoundListener"),Du=Symbol("kSend"),Zv=class{constructor(e,t,n){this.client=e,this.transport=t,this.createConnection=n,this[nr]=new EventTarget,this.mockCloseController=new AbortController,this.realCloseController=new AbortController,this.transport.addEventListener("outgoing",r=>{typeof this.realWebSocket>"u"||queueMicrotask(()=>{r.defaultPrevented||this[Du](r.data)})}),this.transport.addEventListener("incoming",this.handleIncomingMessage.bind(this))}get socket(){return Kt(this.realWebSocket,'Cannot access "socket" on the original WebSocket server object: the connection is not open. Did you forget to call `server.connect()`?'),this.realWebSocket}connect(){Kt(!this.realWebSocket||this.realWebSocket.readyState!==WebSocket.OPEN,'Failed to call "connect()" on the original WebSocket instance: the connection already open');const e=this.createConnection();e.binaryType=this.client.binaryType,e.addEventListener("open",t=>{this[nr].dispatchEvent(st(this.realWebSocket,new Event("open",t)))},{once:!0}),e.addEventListener("message",t=>{this.transport.dispatchEvent(st(this.realWebSocket,new MessageEvent("incoming",{data:t.data,origin:t.origin})))}),this.client.addEventListener("close",t=>{this.handleMockClose(t)},{signal:this.mockCloseController.signal}),e.addEventListener("close",t=>{this.handleRealClose(t)},{signal:this.realCloseController.signal}),e.addEventListener("error",()=>{const t=st(e,new Event("error",{cancelable:!0}));this[nr].dispatchEvent(t),t.defaultPrevented||this.client.dispatchEvent(st(this.client,new Event("error")))}),this.realWebSocket=e}addEventListener(e,t,n){if(!Reflect.has(t,Ms)){const r=t.bind(this.client);Object.defineProperty(t,Ms,{value:r,enumerable:!1})}this[nr].addEventListener(e,Reflect.get(t,Ms),n)}removeEventListener(e,t,n){this[nr].removeEventListener(e,Reflect.get(t,Ms),n)}send(e){this[Du](e)}[Du](e){const{realWebSocket:t}=this;if(Kt(t,'Failed to call "server.send()" for "%s": the connection is not open. Did you forget to call "server.connect()"?',this.client.url),!(t.readyState===WebSocket.CLOSING||t.readyState===WebSocket.CLOSED)){if(t.readyState===WebSocket.CONNECTING){t.addEventListener("open",()=>{t.send(e)},{once:!0});return}t.send(e)}}close(){const{realWebSocket:e}=this;Kt(e,'Failed to close server connection for "%s": the connection is not open. Did you forget to call "server.connect()"?',this.client.url),this.realCloseController.abort(),!(e.readyState===WebSocket.CLOSING||e.readyState===WebSocket.CLOSED)&&(e.close(),queueMicrotask(()=>{this[nr].dispatchEvent(st(this.realWebSocket,new cf("close",{code:1e3,cancelable:!0})))}))}handleIncomingMessage(e){const t=st(e.target,new Yc("message",{data:e.data,origin:e.origin,cancelable:!0}));this[nr].dispatchEvent(t),t.defaultPrevented||this.client.dispatchEvent(st(this.client,new MessageEvent("message",{data:e.data,origin:e.origin})))}handleMockClose(e){this.realWebSocket&&this.realWebSocket.close()}handleRealClose(e){this.mockCloseController.abort();const t=st(this.realWebSocket,new cf("close",{code:e.code,reason:e.reason,wasClean:e.wasClean,cancelable:!0}));this[nr].dispatchEvent(t),t.defaultPrevented||this.client[$i](e.code,e.reason)}},Xv=class extends EventTarget{constructor(e){super(),this.socket=e,this.socket.addEventListener("close",t=>{this.dispatchEvent(st(this.socket,new kl("close",t)))}),this.socket[Tm]=t=>{this.dispatchEvent(st(this.socket,new Yc("outgoing",{data:t,origin:this.socket.url,cancelable:!0})))}}addEventListener(e,t,n){return super.addEventListener(e,t,n)}dispatchEvent(e){return super.dispatchEvent(e)}send(e){queueMicrotask(()=>{if(this.socket.readyState===this.socket.CLOSING||this.socket.readyState===this.socket.CLOSED)return;const t=()=>{this.socket.dispatchEvent(st(this.socket,new MessageEvent("message",{data:e,origin:this.socket.url})))};this.socket.readyState===this.socket.CONNECTING?this.socket.addEventListener("open",()=>{t()},{once:!0}):t()})}close(e,t){this.socket[$i](e,t)}},Pm=class extends Ow{constructor(){super(Pm.symbol)}checkEnvironment(){return Gv("WebSocket")}setup(){const e=Object.getOwnPropertyDescriptor(globalThis,"WebSocket"),t=new Proxy(globalThis.WebSocket,{construct:(n,r,a)=>{const[o,i]=r,s=()=>Reflect.construct(n,r,a),l=new es(o,i),u=new Xv(l);return queueMicrotask(()=>{try{const c=new Zv(l,u,s);this.emitter.emit("connection",{client:new Yv(l,u),server:c,info:{protocols:i}})?l[Zs].resolve(!1):(l[Zs].resolve(!0),c.connect(),c.addEventListener("open",()=>{l.dispatchEvent(st(l,new Event("open"))),c.realWebSocket&&(l.protocol=c.realWebSocket.protocol)}))}catch(c){c instanceof Error&&(l.dispatchEvent(new Event("error")),l.readyState!==WebSocket.CLOSING&&l.readyState!==WebSocket.CLOSED&&l[$i](1011,c.message,!1),console.error(c))}}),l}});Object.defineProperty(globalThis,"WebSocket",{value:t,configurable:!0}),this.subscriptions.push(()=>{Object.defineProperty(globalThis,"WebSocket",e)})}},Bm=Pm;Bm.symbol=Symbol("websocket");const pc=new Bm;function e0(e){pc.on("connection",async t=>{const n=e.getHandlers(),r=new MessageEvent("connection",{data:t}),a=[];for(const o of n)Gc("EventHandler")(o)&&o.predicate({event:r,parsedResult:o.parse({event:r})})&&a.push(o);if(a.length>0){e==null||e.onMockedConnection(t);for(const o of a)o[Fv](r)}else{const o=new Request(t.client.url,{headers:{upgrade:"websocket",connection:"upgrade"}});await Cm(o,e.getUnhandledRequestStrategy()).catch(i=>{const s=new Event("error");Object.defineProperty(s,"cause",{enumerable:!0,configurable:!1,value:i}),t.client.socket.dispatchEvent(s)}),e==null||e.onPassthroughConnection(t),t.server.connect()}})}function wl(e){return e instanceof Blob?e.size:e instanceof ArrayBuffer?e.byteLength:new Blob([e]).size}const ff=24;function Uu(e){return e.length<=ff?e:`${e.slice(0,ff)}…`}async function vl(e){if(e instanceof Blob){const t=await e.text();return`Blob(${Uu(t)})`}if(typeof e=="object"&&"byteLength"in e){const t=new TextDecoder().decode(e);return`ArrayBuffer(${Uu(t)})`}return Uu(e)}const $a={system:"#3b82f6",outgoing:"#22c55e",incoming:"#ef4444",mocked:"#ff6a33"};function t0(e){const{client:t,server:n}=e;n0(t),t.addEventListener("message",r=>{o0(r)}),t.addEventListener("close",r=>{r0(r)}),t.socket.addEventListener("error",r=>{a0(r)}),t.send=new Proxy(t.send,{apply(r,a,o){const[i]=o,s=new MessageEvent("message",{data:i});return Object.defineProperties(s,{currentTarget:{enumerable:!0,writable:!1,value:t.socket},target:{enumerable:!0,writable:!1,value:t.socket}}),queueMicrotask(()=>{s0(s)}),Reflect.apply(r,a,o)}}),n.addEventListener("open",()=>{n.addEventListener("message",r=>{l0(r)})},{once:!0}),n.send=new Proxy(n.send,{apply(r,a,o){const[i]=o,s=new MessageEvent("message",{data:i});return Object.defineProperties(s,{currentTarget:{enumerable:!0,writable:!1,value:n.socket},target:{enumerable:!0,writable:!1,value:n.socket}}),i0(s),Reflect.apply(r,a,o)}})}function n0(e){const t=Xi(e.url);console.groupCollapsed(xe.formatMessage(`${Lr()} %c▶%c ${t}`),`color:${$a.system}`,"color:inherit"),console.log("Client:",e.socket),console.groupEnd()}function r0(e){const t=e.target,n=Xi(t.url);console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c■%c ${n}`),`color:${$a.system}`,"color:inherit"),console.log(e),console.groupEnd()}function a0(e){const t=e.target,n=Xi(t.url);console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c×%c ${n}`),`color:${$a.system}`,"color:inherit"),console.log(e),console.groupEnd()}async function o0(e){const t=wl(e.data),n=await vl(e.data),r=e.defaultPrevented?"⇡":"⬆";console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c${r}%c ${n} %c${t}%c`),`color:${$a.outgoing}`,"color:inherit","color:gray;font-weight:normal","color:inherit;font-weight:inherit"),console.log(e),console.groupEnd()}async function i0(e){const t=wl(e.data),n=await vl(e.data);console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c⬆%c ${n} %c${t}%c`),`color:${$a.mocked}`,"color:inherit","color:gray;font-weight:normal","color:inherit;font-weight:inherit"),console.log(e),console.groupEnd()}async function s0(e){const t=wl(e.data),n=await vl(e.data);console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c⬇%c ${n} %c${t}%c`),`color:${$a.mocked}`,"color:inherit","color:gray;font-weight:normal","color:inherit;font-weight:inherit"),console.log(e),console.groupEnd()}async function l0(e){const t=wl(e.data),n=await vl(e.data),r=e.defaultPrevented?"⇣":"⬇";console.groupCollapsed(xe.formatMessage(`${Lr({milliseconds:!0})} %c${r}%c ${n} %c${t}%c`),`color:${$a.incoming}`,"color:inherit","color:gray;font-weight:normal","color:inherit;font-weight:inherit"),console.log(e),console.groupEnd()}var u0=/(%?)(%([sdijo]))/g;function c0(e,t){switch(t){case"s":return e;case"d":case"i":return Number(e);case"j":return JSON.stringify(e);case"o":{if(typeof e=="string")return e;const n=JSON.stringify(e);return n==="{}"||n==="[]"||/^\[object .+?\]$/.test(n)?e:n}}}function ts(e,...t){if(t.length===0)return e;let n=0,r=e.replace(u0,(a,o,i,s)=>{const l=t[n],u=c0(l,s);return o?a:(n++,u)});return n{if(!e)throw new h0(t,...n)};Cr.as=(e,t,n,...r)=>{if(!t){const a=r.length===0?n:ts(n,...r);let o;try{o=Reflect.construct(e,[a])}catch{o=e(a)}throw o}};function Qc(){if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof process<"u"){const e=process.type;return e==="renderer"||e==="worker"?!1:!!(process.versions&&process.versions.node)}return!1}var gc=async e=>{try{return{error:null,data:await e().catch(n=>{throw n})}}catch(t){return{error:t,data:null}}};function m0(e){return new URL(e,location.href).href}function Fu(e,t,n){return[e.active,e.installing,e.waiting].filter(i=>i!=null).find(i=>n(i.scriptURL,t))||null}var p0=async(e,t={},n)=>{const r=m0(e),a=await navigator.serviceWorker.getRegistrations().then(s=>s.filter(l=>Fu(l,r,n)));!navigator.serviceWorker.controller&&a.length>0&&location.reload();const[o]=a;if(o)return o.update(),[Fu(o,r,n),o];const i=await gc(async()=>{const s=await navigator.serviceWorker.register(e,t);return[Fu(s,r,n),s]});if(i.error){if(i.error.message.includes("(404)")){const l=new URL((t==null?void 0:t.scope)||"/",location.href);throw new Error(xe.formatMessage(`Failed to register a Service Worker for scope ('${l.href}') with script ('${r}'): Service Worker script does not exist at the given path. diff --git a/docs/index.html b/docs/index.html index 7c01baa..572122f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -9,7 +9,7 @@ Demo Dapp with @tonconnect/ui-react - +