/* Minification failed. Returning unminified contents.
(1,1): run-time error CSS1019: Unexpected token, found '$'
(1,2): run-time error CSS1019: Unexpected token, found '('
(1,12): run-time error CSS1031: Expected selector, found '('
(1,12): run-time error CSS1025: Expected comma or open brace, found '('
(51,2): run-time error CSS1019: Unexpected token, found ')'
 */
$(function () {
    rarabuy.vuemodel = new Vue({
        el: '#my-app',
        data: {
            mailAddress: '',
            password: '',
            companyType: 3
        },
        mounted: function () {
            rarabuy.vuemodel = this;
            if ($.cookie('email')) {
                rarabuy.vuemodel.$data.email = $.cookie('email');
            }
            if ($.cookie('password')) {
                rarabuy.vuemodel.$data.password = $.cookie('password');
            }
        },
        methods: {
            doSubmit: async function (event) {
                $('#result').empty();
                this.$validator.validateAll()
                    .then((result) => {
                        if (result) {
                            // 二重クリック防止
                            rarabuy.loading(true);
                            rarabuy.post(rarabuy.apiUrls.login, rarabuy.vuemodel.$data)
                                .done(function (data) {
                                    $.cookie('accessToken', data.Token, { expires: 30, path: "/"/*, secure: true */ });
                                    $.cookie('expiration', data.Expiration, { expires: 30, path: "/"/*, secure: true */ });
                                    $.cookie('id', data.Id, { expires: 30, path: "/"/*, secure: true */ });
                                    $.cookie('name', data.Name, { expires: 30, path: "/"/*, secure: true */ });
                                    $.cookie('companyType', data.CompanyType, { expires: 30, path: "/"/*, secure: true */ });
                                    $.cookie('mailAddress', data.MailAddress, { expires: 30, path: "/"/*, secure: true */ });
                                    $.cookie('imageUrl', data.ImageUrl, { expires: 30, path: "/"/*, secure: true */ });
                                    console.log(data);
                                    rarabuy.redirect(rarabuy.urls.home);
                                })
                                .fail(function (error) {
                                    console.log(error);
                                    rarabuy.handleError(error);
                                });
                        }
                    });
            },
            onInput: async function (event) {
                $('#result').empty();
            }

        }
    });
});
