/**
 * Copyright (C) 2020 to the present, Crestron Electronics, Inc.
 * All rights reserved.
 * No part of this software may be reproduced in any form, machine
 * or natural, without the express written consent of Crestron Electronics.
 * Use of this source code is subject to the terms of the Crestron Software License Agreement 
 * under which you licensed this source code.  
 *
 * This code was automatically generated by Crestron's code generation tool.
 */
/* jslint es6 */

const configuringModule = (function () {
    'use strict';

    let subConfiguringSystemState = null

    /**
     * On Init
     */
    function onInit() {
        invokeUnsubscriptions();
        initializeVariables();
        invokeSubscriptions();
    }

    /**
     * Invoke subscriptions related to module
     */
    function invokeSubscriptions() {
        subConfiguringSystemState = CrComLib.subscribeState('s', 'Room[0].SystemInfo.SystemState', (response) => {
            avfUtility.log('Room[0].SystemInfo.SystemState', response);
            if (response === "Configuring") {
                appModule.setSystemReady(false);
                navigationModule.openPopup(navigationModule.popupPages.configuringImportPage);
            } else {
                navigationModule.closePopup(navigationModule.popupPages.configuringImportPage);
            }
        });
    }

    /**
     * Invoke unsubscriptions related to module
     */
    function invokeUnsubscriptions() {
        if (subConfiguringSystemState) {
            CrComLib.unsubscribeState('s', 'Room[0].SystemInfo.SystemState', subConfiguringSystemState);
        }
    }

    /**
     * Initialize all the variables used in this module
     */
    function initializeVariables() {
        subConfiguringSystemState = null;
    }

    /**
     * All public method and properties are exported here
     */
    return {
        onInit
    };

}());