{
  "version": 3,
  "sources": ["../../../../../../Modules/Membership/Account/Login/LoginPage.tsx"],
  "sourcesContent": ["import { LoginForm, LoginRequest } from \"@/ServerTypes/Membership\";\nimport { Texts } from \"@/ServerTypes/Texts\";\nimport { ErrorHandling, PropertyPanel, WidgetProps, notifyError, parseQueryString, resolveUrl, serviceCall } from \"@serenity-is/corelib\";\nimport { AccountPanelTitle } from \"../AccountPanelTitle\";\n\nexport default function pageInit(opt?: { activated: string }) {\n    var loginPanel = new LoginPanel({ element: '#LoginPanel' });\n\n    if (opt?.activated) {\n        loginPanel.form.Username.value = opt.activated;\n        loginPanel.form.Password.element.getNode().focus();\n    }\n}\n\nclass LoginPanel extends PropertyPanel<LoginRequest, any> {\n\n    public readonly form = new LoginForm(this.idPrefix);\n\n    protected getFormKey() { return LoginForm.formKey; }\n\n    constructor(props?: WidgetProps<any>) {\n        super(props);\n    }\n\n    protected loginClick() {\n        if (!this.validateForm())\n            return;\n\n        var request = this.getSaveEntity();\n\n        serviceCall({\n            url: resolveUrl('~/Account/Login'),\n            request: request,\n            onSuccess: () => {\n                this.redirectToReturnUrl();\n            },\n            onError: response => {\n\n                if (response?.Error?.Code === \"RedirectUserTo\") {\n                    window.location.href = response.Error.Arguments;\n                    return;\n                }\n\n                if (response?.Error?.Message?.length) {\n                    notifyError(response.Error.Message);\n                    this.form.Password.element.getNode().focus();\n\n                    return;\n                }\n\n                ErrorHandling.showServiceError(response.Error);\n            }\n        });\n\n    }\n\n    protected getReturnUrl() {\n        var q = parseQueryString();\n        return q['returnUrl'] || q['ReturnUrl'];\n    }\n\n    protected redirectToReturnUrl() {\n        var returnUrl = this.getReturnUrl();\n        if (returnUrl && /^\\//.test(returnUrl)) {\n            var hash = window.location.hash;\n            if (hash != null && hash != '#')\n                returnUrl += hash;\n            window.location.href = returnUrl;\n        }\n        else {\n            window.location.href = resolveUrl('~/');\n        }\n    }\n\n    protected renderContents() {\n        const id = this.useIdPrefix();\n        const myTexts = Texts.Forms.Membership.Login;\n        this.element.empty().append(<>\n            <AccountPanelTitle />\n            <div class=\"s-Panel p-4\">\n                <h5 class=\"text-center my-4\">{myTexts.LoginToYourAccount}</h5>\n                <form id={id.Form} action=\"\">\n                    <div id={id.PropertyGrid}></div>\n                    <div class=\"px-field\">\n                        <a class=\"float-end text-decoration-none\" href={resolveUrl('~/Account/ForgotPassword')}>\n                            {myTexts.ForgotPassword}\n                        </a>\n                    </div>\n                    <div class=\"px-field\">\n                        <button id={id.LoginButton} type=\"submit\" class=\"btn btn-primary my-3 w-100\"\n                            onClick={e => {\n                                e.preventDefault();\n                                this.loginClick();\n                            }}>\n                            {myTexts.SignInButton}\n                        </button>\n                    </div>\n                </form>\n            </div>\n            <div class=\"text-center mt-2\">\n                <a class=\"text-decoration-none\" href={resolveUrl('~/Account/SignUp')}>{myTexts.SignUpButton}</a>\n            </div>\n        </>);\n    }\n}"],
  "mappings": "iNAEA,IAAAA,EAAkH,SAGnG,SAARC,EAA0BC,EAA6B,CAC1D,IAAIC,EAAa,IAAIC,EAAW,CAAE,QAAS,aAAc,CAAC,EAEtDF,GAAA,MAAAA,EAAK,YACLC,EAAW,KAAK,SAAS,MAAQD,EAAI,UACrCC,EAAW,KAAK,SAAS,QAAQ,QAAQ,EAAE,MAAM,EAEzD,CAPwBE,EAAAJ,EAAA,YASxB,IAAMK,EAAN,MAAMA,UAAmB,eAAiC,CAMtD,YAAYC,EAA0B,CAClC,MAAMA,CAAK,EALf,KAAgB,KAAO,IAAIC,EAAU,KAAK,QAAQ,CAMlD,CAJU,YAAa,CAAE,OAAOA,EAAU,OAAS,CAMzC,YAAa,CACnB,GAAK,KAAK,aAAa,EAGvB,KAAIC,EAAU,KAAK,cAAc,KAEjC,eAAY,CACR,OAAK,cAAW,iBAAiB,EACjC,QAASA,EACT,UAAWJ,EAAA,IAAM,CACb,KAAK,oBAAoB,CAC7B,EAFW,aAGX,QAASA,EAAAK,GAAY,CApCjC,IAAAC,EAAAC,EAAAC,EAsCgB,KAAIF,EA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5C,QAASM,GAAK,CACVA,EAAE,eAAe,EACjB,KAAK,WAAW,CACpB,EACC,SAAAL,EAAQ,aACb,EACJ,GACJ,GACJ,EACAE,EAAC,OAAI,MAAM,mBACP,SAAAA,EAAC,KAAE,MAAM,uBAAuB,QAAM,cAAW,kBAAkB,EAAI,SAAAF,EAAQ,aAAa,EAChG,GACJ,CAAG,CACP,CACJ,EA1F0Db,EAAAC,EAAA,cAA1D,IAAMF,EAANE",
  "names": ["import_corelib", "pageInit", "opt", "loginPanel", "LoginPanel", "__name", "_LoginPanel", "props", "LoginForm", "request", "response", "_a", "_b", "_c", "q", "returnUrl", "hash", "id", "myTexts", "Texts", "jsx", "Fragment", "AccountPanelTitle", "e"]
}