import { __awaiter, __decorate } from "tslib";
import { customElement } from '@microsoft/fast-element';
import { BaseRoute } from '../base';
import { commonLoginRouteStyles } from '../../styles';
import { ForgotPasswordTemplate as template } from './forgot-password.template';
import { logger } from '../../utils';
import { hostEnv } from '../../main/config';
let ForgotPassword = class ForgotPassword extends BaseRoute {
    connectedCallback() {
        const _super = Object.create(null, {
            connectedCallback: { get: () => super.connectedCallback }
        });
        return __awaiter(this, void 0, void 0, function* () {
            _super.connectedCallback.call(this);
            yield this.autofill();
        });
    }
    onSubmit() {
        const _super = Object.create(null, {
            onSubmit: { get: () => super.onSubmit }
        });
        return __awaiter(this, void 0, void 0, function* () {
            logger.debug('forgot password submission');
            yield _super.onSubmit.call(this);
            /**
             * Example url from email: https://public-foundation.genesislab.global/reset-password?password=nc_cbGrlgCkZeJHAF043oqEidnk
             */
            const returnUrl = `${location.protocol}//${hostEnv}/reset-password`;
            const message = this.messageBuilder.createForgotPasswordMessage(this.orgUsername, returnUrl);
            yield this.sendMessage(message, 'Please check your inbox for reset instructions.');
        });
    }
};
ForgotPassword = __decorate([
    customElement({
        name: 'foundation-login-forgot-password',
        template,
        styles: commonLoginRouteStyles,
    })
], ForgotPassword);
export { ForgotPassword };
//# sourceMappingURL=forgot-password.js.map