'use strict';

var React = require('react');
var SendbirdChat = require('@sendbird/chat');
var useSendbirdStateContext = require('../useSendbirdStateContext.js');
var uuid = require('../chunks/bundle-D_L8wtf_.js');
require('../withSendbird.js');
require('../chunks/bundle-Dwj4MFbu.js');

var useConnectionState = function () {
    var stores = useSendbirdStateContext.useSendbirdStateContext().stores;
    var sdkStore = stores.sdkStore;
    var sdk = sdkStore.sdk;
    var _a = React.useState(sdk.connectionState), connectionState = _a[0], setConnectionState = _a[1];
    sdk.addConnectionHandler(uuid.uuidv4(), new SendbirdChat.ConnectionHandler({
        onConnected: function () { return setConnectionState(SendbirdChat.ConnectionState.OPEN); },
        onDisconnected: function () { return setConnectionState(SendbirdChat.ConnectionState.CLOSED); },
        onReconnectStarted: function () { return setConnectionState(SendbirdChat.ConnectionState.CONNECTING); },
        onReconnectSucceeded: function () { return setConnectionState(SendbirdChat.ConnectionState.OPEN); },
        onReconnectFailed: function () { return setConnectionState(SendbirdChat.ConnectionState.CLOSED); },
    }));
    return connectionState;
};

exports.useConnectionState = useConnectionState;
//# sourceMappingURL=useConnectionState.js.map
