"use strict";var distUrl="/dist/app/views/",distUrlControllers="/dist/app/views/controllers/",distUrlComponents="/dist/app/views/components/",app=angular.module("correctApp",["ngRoute","ngFileUpload"]);app.config(["$routeProvider","$locationProvider",function(t,e){t.when("/",{templateUrl:distUrlControllers+"index.html",controller:"indexController",controllerAs:"$ctrl"}),t.when("/index",{templateUrl:distUrlControllers+"index.html",controller:"indexController",controllerAs:"$ctrl"}),t.when("/ru/fix",{templateUrl:distUrlControllers+"index.html",controller:"indexController",controllerAs:"$ctrl"}),t.when("/ua/fix",{templateUrl:distUrlControllers+"index.html",controller:"indexController",controllerAs:"$ctrl"}),t.when("/by/fix",{templateUrl:distUrlControllers+"index.html",controller:"indexController",controllerAs:"$ctrl"}),t.when("/kz/fix",{templateUrl:distUrlControllers+"index.html",controller:"indexController",controllerAs:"$ctrl"}),t.when("/fix",{templateUrl:distUrlControllers+"index.html",controller:"indexController",controllerAs:"$ctrl"}),t.otherwise({redirectTo:"/"}),e.html5Mode({enabled:!0,requireBase:!1})}]),app.run(["$rootScope",function(t){t.correctStep="main",t.error=null}]),app.run(["$http",function(t){t.defaults.timeout=12e4,t.defaults.headers.common["X-Requested-With"]="XMLHttpRequest",t.defaults.headers.common["Content-Type"]="application/json; charset=utf-8"}]),app.directive("maxlines",function(){return{restrict:"A",require:"ngModel",link:function(t,e,o,r){var n=1;function l(){e.off(".maxlines")}o.$observe("maxlines",function(t){n=parseInt(t)}),r.$validators.maxlines=function(t,e){return(t||"").split("\n").length<=n},o.$observe("maxlinesPreventEnter",function(t){(t=0!==(t||"").toLocaleLowerCase().indexOf("f"))?e.on("keypress",function(t){13!=t.keyCode||r.$validators.maxlines(r.$modelValue+"\n",r.$viewValue+"\n")||t.preventDefault()}):l()}),t.$on("$destroy",l)}}}),app.component("textResult",{templateUrl:distUrlComponents+"text_result.html",bindings:{self:"=",preview:"=",resetData:"&"},controllerAs:"$ctrl",controller:[function(){this.$onInit=function(){}}]}),app.controller("indexController",["$scope","$rootScope","sendService",function(t,e,o){var r=this,n={0:null,error_500:"Ошибка на сервере. Попробуйте через 15 минут",error_413:"Не удалось загрузить данные. Слишком большой размер файла. Ограничение - 20 мб",empty_sheet:"Ошибка в исходном файле. Пересохраните в другом формате.",big_sheet:"Слишком много данных для обработки. До {limit} строк за раз.",unsupported:"Не удалось обработать файл данного формата. Допустимые форматы: CSV/XLS/XLSX/TXT",limit:"Слишком много данных для обработки. До {limit} строк за раз.",size:"Не удалось загрузить данные. Слишком большой размер файла. Ограничение - 20 мб",upload:"Не удалось загрузить данные",preview:"Невозможно получить предпросмотр",no_data:"Нет данных для отображения",correct:"Не удалось сформировать результат",recaptcha:"Ошибка проверки пользователя"};r.error=null,r.recaptcha=null,r.recaptchaCallback=null,r.uploadForm={form:null,file:null,isUploading:!1,isUploaded:!1,uploadPrc:0,isDisabled:!1},r.textForm={form:null,text:"",isDisabled:!1},r.canSend=!1,r.isSending=!1,r.previewData={},r.correctData={},r.$onInit=function(){void 0,r.resetData()},r.checkForms=function(t){return r.textForm.isDisabled=!1,r.uploadForm.isDisabled=!1,r.canSend=!1,r.textForm.text?(r.uploadForm.isDisabled=!0,r.uploadForm.file=null,r.canSend=!0):!!(r.uploadForm.file&&r.uploadForm.file.name&&(r.textForm.isDisabled=!0,r.textForm.text="",r.uploadForm.form.file.$valid))&&(r.canSend=!0)},r.resetData=function(){r.uploadForm.file=null,r.uploadForm.isUploading=!1,r.uploadForm.isUploaded=!1,r.uploadForm.uploadPrc=0,r.uploadForm.isDisabled=!1,r.textForm.text="",r.textForm.isDisabled=!1,r.setStep("main"),r.setError(0),r.canSend=!1,r.isSending=!1,r.recaptchaReset()},r.sendData=function(){r.canSend&&(r.isSending=!0,r.textForm.text?r.actionSendText():r.uploadForm.file&&r.actionSendUpload())},r.actionSendUpload=function(){r.canSend&&!r.uploadForm.isDisabled&&o.upload(r.uploadForm.file).then(function(t){e.error=null,r.uploadForm.isUploading=!1,void 0,void 0,t.data.result&&t.data.file?(r.uploadForm.isUploaded=!0,r.actionPreview(t.data.file)):(r.setError("upload"),t.data.error&&r.setError(t.data.error,t.data.hasOwnProperty("limit")?t.data.limit:null))},function(t){switch(void 0,t.status){case 500:case-1:r.setError("error_500");break;case 413:r.setError("error_413",t.data.limit);break;default:r.setError("upload")}},function(t){r.uploadForm.isUploading=!0;var e=parseInt(100*t.loaded/t.total);r.uploadForm.uploadPrc=e,void 0})},r.actionSendText=function(){r.canSend&&o.sendForm({data:r.textForm.text}).then(function(t){t.result&&t.file?(r.setError(0),r.actionPreview(t.file)):(r.setError("upload"),t.error&&r.setError(t.error,t.hasOwnProperty("limit")?t.limit:null))},function(t){500==t.status?r.setError("error_500"):r.setError("upload"),void 0})},r.actionPreview=function(t){r.isSending=!1,r.setStep("load_preview"),o.getPreview({file:t}).then(function(t){r.setError(0),void 0,void 0,t.data.join("").length?(r.setStep("preview"),r.previewData=t,r.previewData.user_info={email:"",subscribe:!0,isValid:!1},r.recaptchaRender()):r.setError("no_data")},function(t){500==t.status?r.setError("error_500"):r.setError("preview"),void 0,void 0})},r.recaptchaRender=function(){if(void 0,null===r.recaptcha)try{r.recaptcha=grecaptcha.render("recaptcha",{sitekey:r.previewData.recaptcha_key,callback:r.onSubmitReCaptcha,theme:"light",size:"invisible"})}catch(t){}void 0},r.recaptchaReset=function(){if((r.recaptchaCallback=null)!==r.recaptcha){void 0;try{grecaptcha.reset()}catch(t){}r.recaptcha=null}},r.actionCorrectReCaptcha=function(){void 0,grecaptcha.execute()},r.actionCorrect=function(){r.setStep("load_result"),o.getCorrect({data:r.previewData,recaptcha:r.recaptchaCallback}).then(function(t){r.setError(0),r.setStep("result"),r.correctData=t},function(t){500==t.status?r.setError("error_500"):r.setError("correct"),void 0})},r.onSubmitReCaptcha=function(t){void 0,void 0,t&&(r.recaptchaCallback=t,r.actionCorrect())},t.$watch("correctStep",function(t,e){var o=new CustomEvent("changeStepEvent",{detail:{step:t,prev:e}});document.dispatchEvent(o)}),r.setError=function(t,e){return n.hasOwnProperty(t)&&(r.error=n[t],e&&(r.error=r.error.replace("{limit}",e))),r.error},r.setStep=function(t){e.correctStep=t},r.isCurStep=function(t){return e.correctStep==t}}]),app.service("sendService",["$http","Upload",function(e,o){var r="/upload",n="/form",l="/preview",a="/correct",t={upload:function(t){return o.upload({url:r,data:{file:t}})},sendForm:function(t){return e.post(n,t).then(function(t){return t.data})},getPreview:function(t){return e.post(l,t).then(function(t){return t.data})},getCorrect:function(t){return e.post(a,t).then(function(t){return t.data})}};return t}]),app.component("bottomColumnOptions",{templateUrl:distUrlComponents+"preview/bottom_column_options.html",bindings:{self:"="},controllerAs:"$ctrl",controller:[function(){this.$onInit=function(){}}]}),app.component("moreOptionsBottom",{templateUrl:distUrlComponents+"preview/more_options_bottom.html",bindings:{self:"="},controllerAs:"$ctrl",controller:[function(){this.$onInit=function(){}}]}),app.component("previewTable",{templateUrl:distUrlComponents+"preview/preview_table.html",bindings:{self:"=",actionCorrect:"&"},controllerAs:"$ctrl",controller:[function(){var r=this;r.show_options=0,r.$onInit=function(){},r.blockColumnType=function(t,e){if(t&&"disabled"!==t)for(var o in r.self.column_options)o!=e&&r.self.column_options[o].type===t&&(r.self.column_options[o].type="")},r.showOptions=function(){r.show_options?r.show_options=0:r.show_options=1}}]}),app.component("topColumnOptions",{templateUrl:distUrlComponents+"preview/top_column_options.html",bindings:{self:"=",onChangeType:"&"},controllerAs:"$ctrl",controller:[function(){var t=this;t.$onInit=function(){t.onChangeType({$type:t.self.type})}}]}),app.component("userInfo",{templateUrl:distUrlComponents+"preview/user_info.html",bindings:{self:"=",onChng:"&"},controllerAs:"$ctrl",controller:[function(){var t=this;t.$onInit=function(){},t.validateEmail=function(){t.self.isValid=!!t.self.email}}]}),app.component("textForm",{templateUrl:distUrlComponents+"upload/text_form.html",bindings:{self:"=",onChng:"&"},controllerAs:"$ctrl",controller:[function(){this.$onInit=function(){}}]}),app.component("uploadForm",{templateUrl:distUrlComponents+"upload/upload_form.html",bindings:{self:"=",onChng:"&"},controllerAs:"$ctrl",controller:[function(){this.$onInit=function(){}}]});