sf-reglanegociom3 1.0.12-beta98 → 1.0.12-beta99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/http"),require("@angular/common/http"),require("rxjs/add/operator/map"),require("@angular/core"),require("rxjs/operators"),require("pouchdb"),require("moment"),require("lodash"),require("sf-reglanegocio-grl")):"function"==typeof define&&define.amd?define("sf-reglanegociom3",["exports","@angular/http","@angular/common/http","rxjs/add/operator/map","@angular/core","rxjs/operators","pouchdb","moment","lodash","sf-reglanegocio-grl"],t):t(o["sf-reglanegociom3"]={},o.ng.http,o.ng.common.http,o.rxjs["add/operator/map"],o.ng.core,o.rxjs.operators,o.PouchDB,o.moment_,o._,o.i1$1)}(this,function(o,i,t,e,r,n,a,s,h,c){"use strict";a=a&&a.hasOwnProperty("default")?a["default"]:a;var C=function(){return(C=Object.assign||function(o){for(var t,e=1,r=arguments.length;e<r;e++)for(var n in t=arguments[e])Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n]);return o}).apply(this,arguments)};function u(o,t,e,r){var n,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,e):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(o,t,e,r);else for(var s=o.length-1;0<=s;s--)(n=o[s])&&(a=(i<3?n(a):3<i?n(t,e,a):n(t,e))||a);return 3<i&&a&&Object.defineProperty(t,e,a),a}function l(e,r){return function(o,t){r(o,t,e)}}function d(o,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(o,t)}function O(t,a,s,c){return new(s||(s=Promise))(function(o,e){function r(o){try{i(c.next(o))}catch(t){e(t)}}function n(o){try{i(c["throw"](o))}catch(t){e(t)}}function i(t){t.done?o(t.value):new s(function(o){o(t.value)}).then(r,n)}i((c=c.apply(t,a||[])).next())})}function S(r,n){var i,a,s,o,c={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:t(0),"throw":t(1),"return":t(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function t(t){return function(o){return function e(o){if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,a&&(s=2&o[0]?a["return"]:o[0]?a["throw"]||((s=a["return"])&&s.call(a),0):a.next)&&!(s=s.call(a,o[1])).done)return s;switch(a=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return c.label++,{value:o[1],done:!1};case 5:c.label++,a=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(s=0<(s=c.trys).length&&s[s.length-1])&&(6===o[0]||2===o[0])){c=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){c.label=o[1];break}if(6===o[0]&&c.label<s[1]){c.label=s[1],s=o;break}if(s&&c.label<s[2]){c.label=s[2],c.ops.push(o);break}s[2]&&c.ops.pop(),c.trys.pop();continue}o=n.call(r,c)}catch(t){o=[6,t],a=0}finally{i=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([t,o])}}}function v(o){var t="function"==typeof Symbol&&o[Symbol.iterator],e=0;return t?t.call(o):{next:function(){return o&&e>=o.length&&(o=void 0),{value:o&&o[e++],done:!o}}}}var f=function(){function o(o,t){this.http=o,this.httpClient=t,this.cargaInicial()}return o.prototype.cargaInicial=function(){var o,t=sessionStorage.getItem("ConfigJSON");if(t){var e=JSON.parse(t);e.ServidorPersonas&&(o=e)}else o=require("G:/Desarrollo/BD/WE8/config.json");this.servidorPersonas=o.ServidorPersonas,this.servidor=o.Servidor,this.servidorGenerales=o.ServidorGenerales,this.servidorM3=o.ServidorM3,this.servidorFEMX=o.ServidorFEMX,this.servidorDocumentos=o.ServidorDocumentos,this.servidorContable=o.ServidorContable,this.servidorPrestamo=o.ServidorPrestamo,this.WebBase=o.WebBase},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.getConfigJson=function(n){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getWithBodyGenerales("Generales/getConfigJson/"+n,null).toPromise()];case 1:return t=o.sent(),e=JSON.parse(t.toString()),this.respOk_getConfigJson(e),[3,3];case 2:return r=o.sent(),console.log(r),[3,3];case 3:return[2]}})})},o.prototype.respOk_getConfigJson=function(o){this.servidorPersonas=o.ServidorPersonas,this.servidor=o.Servidor,this.servidorGenerales=o.ServidorGenerales,this.servidorM3=o.ServidorM3,this.servidorFEMX=o.ServidorFEMX,this.servidorDocumentos=o.ServidorDocumentos,this.servidorContable=o.ServidorContable,this.servidorPrestamo=o.ServidorPrestamo,this.WebBase=o.WebBase},o.prototype.getURLServer=function(){return this.servidor},o.prototype.getURLServerDocs=function(){return this.servidorDocumentos},o.prototype.httpGet=function(o,t){return this.http.get(t+o).map(function(o){return o.json()})},o.prototype.httpGetWithTimeOut=function(o,t,e){return this.http.get(t+o).pipe(n.timeout(e)).map(function(o){return o.json()})},o.prototype.httpGetWithBody=function(o,t,e){return(new i.Headers).append("Content-Type","application/json"),this.httpClient.get(t+o,{params:e}).map(function(o){return o})},o.prototype.httpGetWithBodyTimeOut=function(o,t,e,r){return(new i.Headers).append("Content-Type","application/json"),this.httpClient.get(t+o,{params:e}).pipe(n.timeout(r)).map(function(o){return o})},o.prototype.http_get_blob=function(o,t,e){new i.Headers;return this.httpClient.get(t+o,{responseType:"blob",params:e}).map(function(o){return o})},o.prototype.http_get_arraybuffer=function(o,t,e){new i.Headers;return this.httpClient.get(t+o,{responseType:"arraybuffer",params:e}).map(function(o){return o})},o.prototype.getPrestamo=function(o){return this.httpGet(o,this.servidorPrestamo)},o.prototype.getWithBodyM3TimeOut=function(o,t,e){return this.httpGetWithBodyTimeOut(o,this.servidorM3,t,e)},o.prototype.getWithBodyPrestamo=function(o,t){return this.httpGetWithBody(o,this.servidorPrestamo,t)},o.prototype.getWithBodyM3=function(o,t){return this.httpGetWithBody(o,this.servidorM3,t)},o.prototype.getWithBodyPersonas=function(o,t){return this.httpGetWithBody(o,this.servidorPersonas,t)},o.prototype.getWithBodyGenerales=function(o,t){return this.httpGetWithBody(o,this.servidorGenerales,t)},o.prototype.getWithBodyDocumento=function(o,t){return(new i.Headers).append("responseType","ResponseContentType.Blob"),this.httpClient.get(this.servidorDocumentos+o,{params:t}).map(function(o){return o})},o.prototype.get_blob_Documentos=function(o,t){return this.http_get_blob(o,this.servidorDocumentos,t)},o.prototype.get_arraybuffer_Documentos=function(o,t){return this.http_get_arraybuffer(o,this.servidorDocumentos,t)},o.prototype.getPosts=function(o){return this.httpGet(o,this.servidor)},o.prototype.getPersonas=function(o){return this.httpGet(o,this.servidorPersonas)},o.prototype.getGenerales=function(o){return this.httpGet(o,this.servidorGenerales)},o.prototype.getM3=function(o){return this.httpGet(o,this.servidorM3)},o.prototype.getM3WithTimeOut=function(o,t){return this.httpGetWithTimeOut(o,this.servidorM3,t)},o.prototype.getDocumentos=function(o){return this.httpGet(o,this.servidorDocumentos)},o.prototype.getContable=function(o){return this.httpGet(o,this.servidorContable)},o.prototype.getPostsWithOutJson=function(o){return this.http.get(this.servidor+o).map(function(o){return o})},o.prototype.postServiceHttp=function(o,t){return this.http.post(this.servidor+o,t).map(function(o){return o.statusText})},o.prototype.postServiceResponseHttp=function(o,t){return this.http.post(this.servidor+o,t).map(function(o){return o.json()})},o.prototype.postServiceResponseHttpCallService=function(o,t,e){return this.http.post(e+o,t).map(function(o){return o.json()})},o.prototype.postServiceResponseHttpPrestamos=function(o,t){return this.postServiceResponseHttpCallService(o,t,this.servidorPrestamo)},o.prototype.postServiceHttpOptionsCallService=function(o,t,e,r){var n=new i.RequestOptions({headers:e});return this.http.post(r+o,t,n).map(function(o){return o})},o.prototype.postServiceHttpOptions=function(o,t,e){return this.postServiceHttpOptionsCallService(o,t,e,this.servidor)},o.prototype.postServiceHttpOptionsM3=function(o,t,e){return this.postServiceHttpOptionsCallService(o,t,e,this.servidorM3)},o.prototype.postServiceHttpOptionsDocs=function(o,t,e){return this.postServiceHttpOptionsCallService(o,t,e,this.servidorDocumentos)},o.prototype.postServiceHttpResFullCallService=function(o,t,e){return this.http.post(e+o,t).map(function(o){return o})},o.prototype.postServiceHttpResFull=function(o,t){return this.postServiceHttpResFullCallService(o,t,this.servidor)},o.prototype.postServiceHttpResFullPersonas=function(o,t){return this.postServiceWebApi(o,t,this.servidorPersonas)},o.prototype.postServiceHttpResFullM3=function(o,t){return this.postServiceWebApi(o,t,this.servidorM3)},o.prototype.postServiceHttpResFullFEMX=function(o,t){return this.postServiceWebApi(o,t,this.servidorFEMX)},o.prototype.postServiceHttpResFullGenerales=function(o,t){return this.postServiceHttpResFullCallService(o,t,this.servidorGenerales)},o.prototype.postServiceHttpResFullPrestamos=function(o,t){return this.postServiceHttpResFullCallService(o,t,this.servidorPrestamo)},o.prototype.postServiceWebApi=function(o,t,e){var r=new i.Headers;r.append("Content-Type","application/json");var n=new i.RequestOptions({headers:r});return this.http.post(e+o,t,n).map(function(o){return o})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:i.Http},{type:t.HttpClient}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(i.Http),r.inject(t.HttpClient))},token:o,providedIn:"root"}),o}(),m=function(){function o(){}return o.prototype.convertXmlToJson=function(o){var e;return(0,require("xml2js").parseString)(o,function(o,t){e=t}),e},o.prototype.replaceCharXml=function(o){var t=o.replace(/&gt;/gi,">");return t=(t=t.replace(/&lt;/gi,"<")).replace(/&quot;/gi,"'")},o}(),p=function(){function o(){var o,t;(this.listener=new r.EventEmitter,this.isInstantiated)||(o=this.GetIdKatiosLVL1FromSession(),t=this.GetTipoHubFromSession(),o&&(t&&"WEB"==t.toUpperCase().trim()?(this.database=new a("infomEcc_"+o.toLowerCase().trim(),{auto_compaction:!0}),this.sync(this.GetServer()+"infomEcc_"+o.toLowerCase().trim()),this.isInstantiated=!0,console.log("INSTANCEECC!!¡")):(this.database=new a("infom_"+o.toLowerCase().trim(),{auto_compaction:!0}),this.sync(this.GetServer()+"infom_"+o.toLowerCase().trim()),this.isInstantiated=!0,console.log("INSTANCE!!¡"))))}return o.prototype.GetTipoHubFromSession=function(){var o,t=sessionStorage.getItem("SUbicacion");return t&&(o=JSON.parse(t)).M3HUBS&&o.M3HUBS[0]&&o.M3HUBS[0].Tipo?o.M3HUBS[0].Tipo:null},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.get=function(o){return this.database.get(o)},o.prototype.GetDataPouchBD=function(o){return this.database.get(o)},o.prototype.getChangeListener=function(){return this.listener},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!0,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PROMOCIONES *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.GetKeyDocumentoDB=function(o,t){return o+"?"+t},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),P=function(){function o(){this.listener=new r.EventEmitter,this.isInstantiated||(this.database=new a("CarritoCompras",{auto_compaction:!0}),this.isInstantiated=!0)}return o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.get=function(o){return this.database.get(o)},o.prototype.AddToPouchBDCarritoCompras=function(o,t){var r=this;return t._id=o,this.get(o).then(function(o){return t._rev=o._rev,r.database.put(t)},function(e){return"404"==e.status?r.database.put(t):new Promise(function(o,t){t(e)})})},o.prototype.AddToPouchBDCarritoComprasAsync=function(r,n){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:n._id=r,o.label=1;case 1:return o.trys.push([1,4,,8]),[4,this.get(r)];case 2:return t=o.sent(),n._rev=t._rev,[4,this.database.put(n)];case 3:return o.sent(),[3,8];case 4:return"404"!=(e=o.sent()).status?[3,6]:[4,this.database.put(n)];case 5:return o.sent(),[3,7];case 6:return[2,new Promise(function(o,t){t(e)})];case 7:return[3,8];case 8:return[2]}})})},o.prototype.GetDataPouchBD=function(o){return this.database.get(o)},o.prototype.Delete=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0}),r={live:!0,retry:!0};this.database.sync(e,{options:{retry:!0}}).on("complete",function(o){t.database.sync(e,r)}).on("change",function(o){t.listener.emit(o)}).on("error",function(o){t.database.sync(e,r)})},o.prototype.GetKeyCarritoCompras=function(o,t,e,r,n){return"CC?"+o+"?"+r+"?"+n+"?"+t+"?"+e},o.prototype.ReserBD=function(){var t=this;this.database.destroy().then(function(o){t.database=new a("CarritoCompras",{auto_compaction:!0})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),M=function jo(o,t){this.Atributo=o,this.Valor=t},g=function Ho(){},I=function ko(){this.M3Presentaciones=new Array},y=function xo(){this.M3PACK=null,this.M3PackReglas=null,this.LoM3ListaPrecio=new Array,this.LoM3PrdLista=new I,this.M3Cods=new Array,this.Impuestos=new Array},b=function Wo(){},D=function qo(){this.LoM3PrdGeneral=new Array,this.LoM3PrdAdicionales=new Array,this.M3PACKBYTIPO=new Array,this.M3PrdGrpAsociado=null,this.listImagenes=new Array,this.Impuestos=new Array,this.encontradoLocal=!0},E=function Yo(){},A=function Xo(){},T=function zo(){},N=function Qo(){this.BisProductoPromo=!1,this.BisObsequio=!1,this.Unidad="",this.ClavePrdSRV="",this.ClavePrdUnidad="",this.IdProceso="",this.observacion="",this.SubEstado_o="",this.Estado_o="",this.PathImagen="",this.IDEncRepetido=-1,this.IDEncProcesado=-1,this.IDEncPadre=-1,this.TipoAgrupacion="",this.CodigoBarras="",this.CamposAdicionales=[]},L=function $o(){},R=function Zo(){},U=function ot(){this.ValOtraClasi=0,this.M3PDinamByActividad=new Array,this.dejar_borrar=!0},V=function(){function o(){this.DISPONIBLE=0,this.M3DET=new Array,this.M3DetCupones=new Array,this.M3PImpuestos=new Array,this.M3PDinamByActividad=new Array,this.PromoCombinadas=new Array,this.TipoAgrupacion=""}return o.prototype.GetPriceUnit=function(){return this.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor},o.prototype.GetPriceUnitNeto=function(){return this.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor},o.prototype.SetPriceUnitNeto=function(o){this.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor=o},o.prototype.GetPriceTotal=function(){return this.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor},o}(),_=function tt(){this.M3PDinamByActividad=new Array},B=function et(){},G=s,w=function rt(){this.ValorNeto=0,this.Valor=0,this.ValOtraClasi=0,this.M3ENC=new Array,this.M3OtClasificaciones=new Array,this.lM3PDinamicas=new Array,this.M3PerXProceso=new Array,this.lM3PEncFP=new Array,this.M3FTrabajo=new B,this.M3PEnvios=new Array,this.M3PRecepcion=new Array,this.lM3RegistroTrx=new Array,this.PromosCombinadas=new Array,this.AplPagoEnLinea=!1,this.AplDesdeServer=!1,this.Fecha=G(new Date).format("YYYY-MM-DD")},F=function nt(){this.M3PDinamByActividad=new Array},K=function it(){},J=function at(){},j=function(){function o(){}return o.prototype.add_proceso_generarFE=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3FE/add_proceso_generarFE/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.add_proceso_generarNC=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3FE/add_proceso_generarNC/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.addProcesoGenerarFEAsync=function(r,n,i){return O(this,void 0,void 0,function(){var e;return S(this,function(o){try{return e=r.postServiceHttpResFullM3("M3FE/add_proceso_generarFE/"+n,i).toPromise(),[2,JSON.parse(e)]}catch(t){return[2,null]}return[2]})})},o.prototype.generarCartaPorte=function(o,t,e,r,n,i){o.postServiceHttpResFullFEMX("FEMX/generarCartaPorte/"+t+"/"+e,r).subscribe(function(o){n(o)},function(o){console.error(o.json().Message),i(o.json().Message)})},o.prototype.generarFEAnticipos=function(o,t,e,r,n){o.postServiceHttpResFullFEMX("FEMX/generarFEAnticipos/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.generarNCAnticipos=function(o,t,e,r,n){o.postServiceHttpResFullFEMX("FEMX/generarNCAnticipos/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.getInfoFacturaElectronica=function(r,n){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return e={idKatios:n.trim()},[4,r.getWithBodyM3("M3FE/getInfoFacturaElectronica",e).toPromise()];case 1:return t=o.sent(),[2,JSON.parse(t)]}})})},o.prototype.getHtmlFromFE=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idM3:n},[4,e.getWithBodyM3("M3FE/getHtmlFromFE/"+r,t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.IU_InfoFacturaElectronica=function(e,r,n,i,a){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idKatios:r.trim(),oFactura:n,uTActivo:i,uNActivo:a},[4,e.postServiceHttpResFullM3("M3FE/IU_InfoFacturaElectronica",t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.delInsSeriesxUbic=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3FE/delInsSeriesxUbic/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(JSON.parse(o._body).Message).RESPUESTA[0])})},o}(),H=function(){function o(){}return o.prototype.add_procesoEA=function(o,t,e,r,n){o.postServiceHttpResFullM3("ProcesosM3/add_procesoEA/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.M3Get_ProcesosPorCantidad=function(o,t,e,r){o.getM3("ProcesosM3/M3Get_ProcesosPorCantidad/"+t).subscribe(function(o){var t;(t=JSON.parse(o)).RESPUESTA.TP.length===undefined&&(t.RESPUESTA.TP=new Array(t.RESPUESTA.TP)),e(t)},function(o){r(o.error.Message)})},o.prototype.M3Get_ActividadesYProcesos=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/M3Get_ActividadesYProcesos/"+t,e).subscribe(function(o){var t;(t=JSON.parse(o.toString())).RESPUESTA.ACTIVIDADES.length===undefined&&(t.RESPUESTA.ACTIVIDADES=new Array(t.RESPUESTA.ACTIVIDADES)),t.RESPUESTA.ACTIVIDADES.forEach(function(o){o.PROCESOS!==undefined&&o.PROCESOS.length===undefined&&(o.PROCESOS=new Array(o.PROCESOS))}),r(t)},function(o){console.log(o),n(o.error.Message)})},o.prototype.M3Get_M3ProcesosByIdProceso=function(o,t,e,r,n,i){o.getWithBodyM3("ProcesosM3/M3Get_M3ProcesosByIdProceso/"+t+"/"+r,e).subscribe(function(o){var t;(t=JSON.parse(o.toString())).RESPUESTA.SUBESTADOS.length===undefined&&(t.RESPUESTA.SUBESTADOS=new Array(t.RESPUESTA.SUBESTADOS)),t.RESPUESTA.SUBESTADOS.forEach(function(o){o.M3PROCESOS!==undefined&&o.M3PROCESOS.length===undefined&&(o.M3PROCESOS=new Array(o.M3PROCESOS))}),n(t)},function(o){i(JSON.parse(o._body).Message)})},o.prototype.GetM3ProcesosByIdDiario=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={IdDiario:n},[4,e.getWithBodyM3("ProcesosM3/GetM3ProcesosByIdDiario/"+r,t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.M3Get_M3ProcesosByIdM3=function(o,t,e,r,n,i,a,s,c){var u;void 0===s&&(s=!1),void 0===c&&(c=!1),u={IdM3:e,IdProceso:r},c&&(u.bAPLPagosPD=!0),o.getWithBodyM3("ProcesosM3/GetProcesoM3ByIdM3/"+t,u).subscribe(function(o){var t;"0"!=(t=o).M3FTrabajo.IdUbicPre.toString()&&t.M3FTrabajo.IdUbicPre.toString()!=n.toString()&&(s||(t=null)),i(t)},function(o){a(o.error.Message)})},o.prototype.getM3ProcesosByIdM3Retomado=function(o,t,e,r,n){var i;i={idM3Retomado:e},o.getWithBodyM3("ProcesosM3/getM3ProcesosByIdM3Retomado/"+t,i).subscribe(function(o){r(o)},function(o){n(o.error.Message)})},o.prototype.M3Get_M3ProcesosByIdM3Async=function(e,r,n,i,o,a){return void 0===a&&(a=!1),O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={IdM3:n,IdProceso:i},a&&(t.bAPLPagosPD=!0),[4,e.getWithBodyM3("ProcesosM3/GetProcesoM3ByIdM3/"+r,t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.m3_getProcesoM3ByIdDiarioAsync=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idDiario:n},[4,e.getWithBodyM3("ProcesosM3/m3_getProcesoM3ByIdDiario/"+r,t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.m3_get_data_capt_dinam=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/m3_get_data_capt_dinam/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.M3GetProcesoByPersona=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/M3GetProcesoByPersona/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.M3GetProcesoByIdDiarioCierre=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/M3GetProcesoByIdDiarioCierre/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.M3GetProcesosOffLine=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/M3GetProcesosOffLine/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.m3_detalleProcesoByProceso=function(o,t,e,r,n){o.getWithBodyM3("M3/m3_detalleProcesoByProceso/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()).RESPUESTA.Detalle)},function(o){n(o)})},o.prototype.validarExistenciaProceso=function(o,t,e,r,n){o.getWithBodyM3("M3/validarExistenciaProceso/"+t,e).subscribe(function(o){var t=JSON.parse(o.toString());r(t)},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o}(),k=function st(){this.ValorTotalMonedero=0,this.ListPromocionesAsociadas=new Array},x=function ct(){this.ValorPorcentaje=0,this.ListObsSKU=new Array,this.PromocionCombinada=null,this.ValorMonedero=0,this.IdCupon=null,this.flags={formaPago:!1}},W=function ut(){},q=function(){function o(){}return o.prototype.round=function(o,t){var e=Math.pow(10,t);return Math.round(+o*e)/e},o.prototype.roundV2=function(o,t){return parseFloat((+(Math.round(+(o+"e"+t))+"e"+-t)).toFixed(t))},o.prototype.toFixed=function(o,t){var e=Math.pow(10,Number(t)+1);return(Number(o)+1/e).toFixed(t)},o}(),Y=s,X=function(){function o(o,t){this.oMathTF=new q,this.operators={"<":function(o,t){return o<t},">":function(o,t){return t<o},"<=":function(o,t){return o<=t},">=":function(o,t){return t<=o},IGUAL:function(o,t){return o==t},DIFF:function(o,t){return o!=t},EN:function(o,t){return o===t},AND:function(o,t){return o&&t},OR:function(o,t){return o||t},"*":function(o,t){return!0},MOD:function(o,t){return o%t==0}},this.goDataUser=o,this.goDataAdicional=t}return o.prototype.VerificarPromociones=function(r,n,i,o,e){var a,s=this,c=new Array,u=new Array,l=new Date;return(this.goM3ENCPROMO=o)?(o.filter(function(t){return e.find(function(o){return t.Tipo==o})}).forEach(function(t){var o=new Date(t.Vigencia),e=new Date(t.Inicio);s.validarEstadosEncPromo(t)&&t.Estado&&l<=o&&e<=l&&(c=new Array,t.M3CONDIAGRUPACION.forEach(function(o){(a=s.VerificarAgrupacionPromo(r,n,i,o,t))&&c.push(a)}),(a=s.GetJRespFromArray(c,t.Tipo,t.Tipo2)).APLCondicion&&(s.ValidarAccion(a,t.JAdicionales),s.RetomarValoresPromocion(t,a),u.push(a)))}),u):null},o.prototype.validarEstadosEncPromo=function(o){var t=!0;return o.EsManual&&!o.EstadoManuales&&(t=!1),o.EsAplCupon&&!o.EstadoAplCupon&&(t=!1),t},o.prototype.VerificarAgrupacionPromo=function(o,t,e,r,n){for(var i,a=new Array,s=0;s<r.M3CONDIPROMO.length;s++){var c,u;if(c=r.M3CONDIPROMO[s],(u=JSON.parse(c.JAdicionales)).ROOT.ACTIVIDAD&&"REGISTRO"!=u.ROOT.ACTIVIDAD)return null;if(i=this.VerificarCondicionesPromo(o,t,e,c),"COMBINADA"==n.Tipo&&"COMBO"==n.Tipo2&&i.APLCondicion&&"OR"==r.Operador.trim().toUpperCase())a.push(i);else{if("AND"==r.Operador.trim().toUpperCase()&&!i.APLCondicion)return i=this.ValidarRespuesta(null);if("OR"==r.Operador.trim().toUpperCase()&&i.APLCondicion)return i;a.push(i)}}return this.GetJRespFromArray(a,n.Tipo,n.Tipo2)},o.prototype.VerificarCondicionesPromo=function(o,t,e,r){var n,i;return n=JSON.parse(r.JAdicionales),i=this.VerificarCondicionContraData(o,t,e,r,n),this.ValidarAccion(i,r.JAdicionales),this.AgregarCondicionOK(i,r),i},o.prototype.AgregarCondicionOK=function(o,t){o.APLCondicion&&(o.IDCondicion=t.IdCondicion)},o.prototype.VerificarCondicionContraData=function(o,t,e,r,n){var i,a,s=this;try{switch(n.ROOT.Estructura.Est){case"LoM3PrdAdicionales":(i=t.LoM3PrdAdicionales.find(function(o){return o.ATRIBUTO.trim()==r.Concepto.trim()&&s.operators[n.ROOT.Estructura.Operacion](o.VALOR.trim(),r.Valor.trim())})).JAdicionales=JSON.stringify(n),a=this.ValidarRespuesta(i);break;case"PRDTO":a=this.VerificarInfoProducto(t.LoM3PrdGeneral[0],r,n);break;case"PRDGRP":a=this.VerificarInfoProductoPRDGRP(t,r,n);break;case"M3DETCONDIPROMO":a=this.VerificacionM3DetalleCondicion(o,t,e,r.M3DETCONDIPROMO,r.Concepto,n);break;case"PROCESO":a=this.VerificarInfoProceso(o,r,n);break;case"ID_PAGO":a=this.VerificarProcesoFormaPago(o,r,n);break;case"ID_LISTAP":a=this.verificarProcesoListaPrecio(t.LoM3PrdGeneral[0].LoM3PrdLista,r,n);break;case"USER":a=this.VerificarInfoUserData(r,n);break;case"ADICIONAL":a=this.VerificarInfoAdicional(r,n);break;default:console.log("No Entro por Detalle!"),a=this.GenerarRespuesta(!1,null)}}catch(c){a=this.GenerarRespuesta(!1,null)}return a},o.prototype.GetJRespFromArray=function(o,t,e){var r,n;if(0<o.length){if(r=o.filter(function(o){return o.APLCondicion})){if("COMBINADA"==t&&"COMBO"==e){var i=[];return r.forEach(function(t){0<=t.IDCondicion.length?t.IDCondicion.forEach(function(t){i.find(function(o){return o==t})||i.push(t)}):i.find(function(o){return o==t.IDCondicion})||i.push(t.IDCondicion)}),{APLCondicion:!0,Accion:null,IDCondicion:i}}var a=new Array;n=0<(a=o.filter(function(o){return null!=o.Accion})).length?a[a.length-1]:o[o.length-1]}else n=this.ValidarRespuesta(null);o.find(function(o){return o.FormaPago})&&(n.FormaPago=!0)}else n=this.ValidarRespuesta(null);return n},o.prototype.GenerarRespuesta=function(o,t){var e;return e={APLCondicion:o,Accion:null},null!=t&&t.ROOT.Accion!==undefined&&(e.Accion=t.ROOT.Accion),e},o.prototype.VerificarClasificacionesProceso=function(o,t,e,r){var n=null;try{var i=t.Accion.Valores;i=i.sort(function(o,t){return o.Cantidad<t.Cantidad?1:t.Cantidad<o.Cantidad?-1:0}),this.AplicarPromoByValores(i,e,e.length),0<e.length&&e.find(function(o){return 1==o.Aplicado})&&this.CalculateTotalPriceFromList(e,o,t,!1,r)}catch(a){n=this.GenerarRespuesta(!1,null),console.log("VerificarClasificacionesProceso"),console.log(a)}return n},o.prototype.procesarCaracteristicaParcial=function(o,t,e,r){var n=null;try{var i=t.Accion.Valores;i=i.sort(function(o,t){return o.Cantidad-t.Cantidad});for(var a=0;a<e.length;a++){var s=a<i.length?i[a].Valor:0;e[a].PUNITNETO=+e[a].PUNITNETO-+e[a].PUNITNETO*(+s/100),e[a].Aplicado=!0}0<e.length&&e.find(function(o){return 1==o.Aplicado})&&this.CalculateTotalPriceFromList(e,o,t,!1,r)}catch(c){n=this.GenerarRespuesta(!1,null),console.log("VerificarClasificacionesProceso"),console.log(c)}return n},o.prototype.AplicarPromoByValores=function(o,t,e){for(var r=e,n=0;n<o.length;n++){var i=o[n].Cantidad,a=o[n].Valor;if(i<=r){var s=0;r%i==0||(s=r%i,this.AplicarPromoByValores(o,t,s),r-=s);for(n=+t.length-+e;n<+t.length-+s;n++)t[n].PUNITNETO=+t[n].PUNITNETO-+t[n].PUNITNETO*(+a/100),t[n].Aplicado=!0;break}}},o.prototype.ArmarNuevoArrayDesdeResiduo=function(o,t){var e=new Array;try{for(var r=o.length-1;t<r;r--)e.push(o[r])}catch(n){console.log("ArmarNuevoArratDesdeResiduo"),console.log(n)}return e},o.prototype.VerificarInfoProceso=function(o,t,e){return o[t.Concepto]&&this.operators[e.ROOT.Estructura.Operacion](o[t.Concepto],t.Valor.trim())?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)},o.prototype.VerificarProcesoFormaPago=function(o,t,e){var r=this.GenerarRespuesta(!0,e);return r.FormaPago=!0,r},o.prototype.verificarProcesoListaPrecio=function(o,t,e){try{var r;r=this.operators[e.ROOT.Estructura.Operacion](o[t.Concepto],t.Valor.trim())?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)}catch(n){r=this.GenerarRespuesta(!1,null)}return r},o.prototype.VerificarInfoProducto=function(o,t,e){try{var r;r=this.operators[e.ROOT.Estructura.Operacion](o[t.Concepto],t.Valor.trim())?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)}catch(n){r=this.GenerarRespuesta(!1,null)}return r},o.prototype.VerificarInfoProductoPRDGRP=function(o,t,e){try{var r;r=this.operators[e.ROOT.Estructura.Operacion](o[t.Concepto],t.Valor.trim())?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)}catch(n){r=this.GenerarRespuesta(!1,null)}return r},o.prototype.VerificarInfoAdicional=function(o,t){return this.goDataAdicional[o.Concepto]!==undefined&&this.operators[t.ROOT.Estructura.Operacion](this.goDataAdicional[o.Concepto],o.Valor.trim())?this.GenerarRespuesta(!0,t):"MOD"==t.ROOT.Estructura.Operacion&&+this.goDataAdicional[o.Concepto]>+o.Valor?this.GenerarRespuesta(!0,t):this.GenerarRespuesta(!1,null)},o.prototype.VerificarInfoUserData=function(o,t){var e,r,n;if(this.goDataUser.UsuarioSistema[o.Concepto]!==undefined&&this.operators[t.ROOT.Estructura.Operacion](this.goDataUser.UsuarioSistema[o.Concepto],o.Valor.trim()))n=this.GenerarRespuesta(!0,t);else{if(this.goDataUser.UsuarioSistema[o.Concepto]&&this.goDataUser.UsuarioSistema[o.Concepto].includes(",")){try{for(var i=v(this.goDataUser.UsuarioSistema[o.Concepto].split(",")),a=i.next();!a.done;a=i.next()){var s=a.value;if(this.operators[t.ROOT.Estructura.Operacion](s,o.Valor.trim()))return this.GenerarRespuesta(!0,t)}}catch(c){e={error:c}}finally{try{a&&!a.done&&(r=i["return"])&&r.call(i)}finally{if(e)throw e.error}}return this.GenerarRespuesta(!1,null)}n=this.GenerarRespuesta(!1,null)}return n},o.prototype.VerificacionM3DetalleCondicion=function(t,e,r,n,o,i){var a,s,c=this;switch(o.trim()){case"PRD_SKP1":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor,e.SKP1)}),a=this.ValidarRespuesta(s);break;case"PRD_SKP1+2":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor,e.SKP1+e.LoM3PrdGeneral[0].SKP2)}),a=this.ValidarRespuesta(s);break;case"PRD_SKU":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),e.LoM3PrdGeneral[0].SKU.toString())}),a=this.ValidarRespuesta(s);break;case"PRD_DISP":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](e.LoM3PrdGeneral[0].DISPONIBLE.toString(),o.Valor.toString())}),a=this.ValidarRespuesta(s);break;case"PRD_TIPO":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),e.TIPO.toString())}),a=this.ValidarRespuesta(s);case"PER_PROCESO":var u;s=undefined,u=t.M3PerXProceso.find(function(o){return o.TipoPersona==n[0].Valor.toString()}),"EN"==i.ROOT.Estructura.Operacion&&u?s=n[0]:"DIFF"!=i.ROOT.Estructura.Operacion||u||(s=n[0]),a=this.ValidarRespuesta(s);break;case"ALMACEN":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),r.IDUbicacion.toString())}),a=this.ValidarRespuesta(s);break;case"HORARIO_HORA":var l=new Date;s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),l.getHours().toString())}),a=this.ValidarRespuesta(s);break;case"LoM3PrdAdicionales":if(i.ROOT.Estructura.Concepto!==undefined)try{var d=e.LoM3PrdAdicionales.find(function(o){return o.ATRIBUTO==i.ROOT.Estructura.Concepto}).VALOR;s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),d.toString())}),a=this.ValidarRespuesta(s)}catch(p){a=this.ValidarRespuesta(null)}else a=this.ValidarRespuesta(null);break;default:switch(o.split("_")[0].trim()){case"PROC":var f=o.split("_")[1].trim();s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor,t[f])}),a=this.ValidarRespuesta(s);break;case"USER":f=o.split("_")[1].trim();s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor,c.goDataUser.UsuarioSistema[f])}),a=this.ValidarRespuesta(s);break;default:console.log("No Entro por Detalle!"),a=this.GenerarRespuesta(!1,null)}}return a},o.prototype.ValidarRespuesta=function(o){var t,e;o?(e=JSON.parse(o.JAdicionales),t=this.ValidacionesByJAdicionales(e)?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)):t=this.GenerarRespuesta(!1,null);return t},o.prototype.ValidacionesByJAdicionales=function(o){var t=!0;try{if(o.ROOT.VALIDACIONES&&o.ROOT.VALIDACIONES.TIPO)switch(o.ROOT.VALIDACIONES.TIPO){case"VIGENCIA":t=this.ValidarVigencia(o.ROOT.VALIDACIONES.VAL1,o.ROOT.VALIDACIONES.VAL2)}}catch(e){console.log("***********************************Error"),console.log(e)}return t},o.prototype.ValidarVigencia=function(o,t){var e=new Date,r=+this.GetFechaNumber(e),n=+this.GetFechaNumber(o),i=+this.GetFechaNumber(t);return n<=r&&r<=i},o.prototype.GetFechaNumber=function(o){return Y(o).format("YYYYMMDD")},o.prototype.ValidarAccion=function(o,t){var e=JSON.parse(t);null==o.Accion&&e.ROOT.Accion!==undefined&&(o.Accion=e.ROOT.Accion)},o.prototype.RetomarValoresPromocion=function(o,t){t.Promocion={},t.Promocion.Nombre=o.Nombre,t.Promocion.ID=o.IdPromocion,null==t.Accion?t.Accion={Tipo2:o.Tipo2,Tipo:o.Tipo}:(t.Accion.Tipo2||(t.Accion.Tipo2=o.Tipo2),t.Accion.Tipo||(t.Accion.Tipo=o.Tipo))},o.prototype.ProcesarPromocion=function(o,t,e,r){void 0===r&&(r=null);var n=new k,i=this.goDataUser.UsuarioSistema.IDLPrecio.split("-"),a=t.LoM3PrdGeneral[0].LoM3ListaPrecio.find(function(o){return o.IDLISTA==i[0]}),s=0,c="Valor";if(a&&i&&1<i.length)switch(i[1]){case"LB":c="LB",t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=a.LB;break;case"LC":c="LC",t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=a.LC;break;case"LD":c="LD",t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=a.LD}return n.PrecioTotal=t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO,n.PrecioTotalPromocion=0,null!=r&&"CTN"==r&&(s=t.LoM3PrdGeneral[0].LoM3ListaPrecio.find(function(o){return"2"==o.IDLISTA}).PRECIO),this.ProcesarPromoGeneral(o,t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO,n,e,s,c)},o.prototype.ProcesarPromoAfter=function(o,t,e){try{var r=new k;return r.PrecioTotal=t.ValorNeto,r.PrecioTotalPromocion=0,this.ProcesarPromoGeneral(o,t.ValorNeto,r,e)}catch(n){return null}},o.prototype.ProcesarPromoGeneral=function(o,t,e,r,n,i){var a;void 0===n&&(n=0),void 0===i&&(i="Valor");for(var s=new Array,c=t,u=0;u<o.length;u++){var l=o[u];(a=this.ProcesarPromoByTipo(l,c,e,r,i))&&s.push(a)}return this.ValidarMejorPromocion(s,e,n),e.PrecioTotal<0&&(e.PrecioTotal=0),e},o.prototype.ValidarMejorPromocion=function(o,t,e){var r,n,i=o.find(function(o){return"RESTRICCION"==o.Tipo});if(i)t.ListPromocionesAsociadas=new Array(i),t.PrecioTotal=0,t.PrecioTotalPromocion=0,t.ValorTotalMonedero=0;else{var a=this.GetMaxXRegla(o,"EXC",t),s=this.GetMaxXRegla(o,"ACMDIN",t);s<a?this.aplicaPromoEXC(o,t,a):this.aplicaPromoACMDIN(o,t,s),t.ListPromocionesAsociadas=o;try{for(var c=v(o.filter(function(o){return"ACM"==o.Regla.trim().toUpperCase()&&!o.flags.formaPago})),u=c.next();!u.done;u=c.next()){var l=u.value;if(l.Aplicada=!0,0<l.ValorPorcentaje)if(0!=e&&"MONEDERO"==l.Tipo){var d=+e*l.ValorPorcentaje/100;t.PrecioTotal=+e-d,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+d}else{d=+t.PrecioTotal*l.ValorPorcentaje/100;t.PrecioTotal=+t.PrecioTotal-d,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+d}else t.PrecioTotal=+t.PrecioTotal-l.Valor,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+l.Valor;t.ValorTotalMonedero+=l.ValorMonedero}}catch(f){r={error:f}}finally{try{u&&!u.done&&(n=c["return"])&&n.call(c)}finally{if(r)throw r.error}}}return t},o.prototype.aplicaPromoEXC=function(o,t,e){var r;0<e&&((r=o.find(function(o){return o.Valor==e||o.ValorMonedero==e})).Aplicada=!0,t.PrecioTotal=+t.PrecioTotal-r.Valor,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+r.Valor,t.ValorTotalMonedero+=r.ValorMonedero)},o.prototype.aplicaPromoACMDIN=function(o,t,e){var r,n;if(0<e){try{for(var i=v(o.filter(function(o){return"ACMDIN"==o.Regla})),a=i.next();!a.done;a=i.next()){var s=a.value;s.Aplicada=!0,t.ValorTotalMonedero+=s.ValorMonedero}}catch(c){r={error:c}}finally{try{a&&!a.done&&(n=i["return"])&&n.call(i)}finally{if(r)throw r.error}}t.PrecioTotal=+t.PrecioTotal-e,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+e}},o.prototype.GetMaxXRegla=function(o,t,e){var r,n,i=0;try{switch(t){case"ACMDIN":var a=e.PrecioTotal,s=0;try{for(var c=v(o.filter(function(o){return"ACMDIN"==o.Regla.trim().toUpperCase()&&(!o.flags.formaPago||"MONEDERO"==o.Tipo)})),u=c.next();!u.done;u=c.next()){var l=u.value;if(0<l.ValorPorcentaje){var d=a*l.ValorPorcentaje/100;a-=d,s+=d}else a-=l.Valor,s+=l.Valor}}catch(f){r={error:f}}finally{try{u&&!u.done&&(n=c["return"])&&n.call(c)}finally{if(r)throw r.error}}i=s;break;case"EXC":i=Math.max.apply(Math,o.filter(function(o){return o.Regla.trim().toUpperCase()==t&&(!o.flags.formaPago||"MONEDERO"==o.Tipo)}).map(function(o){return o.Valor>o.ValorMonedero?o.Valor:o.ValorMonedero}))}}catch(p){}return i},o.prototype.ProcesarPromoByTipo=function(o,t,e,r,n){void 0===n&&(n="Valor");try{var i,a=new x;if(null==o.Accion||o.Promocion==undefined)return null;a.IDPromocion=o.Promocion.ID,a.Nombre=o.Promocion.Nombre,(i=o.Accion).Regla?a.Regla=i.Regla:a.Regla="EXC",a.Tipo=i.Tipo2;var s=i.Valor;switch(i[n]&&(s=i[n]),i.Tipo2.trim().toUpperCase()){case"DTO_%":a.ListObsSKU=null,a.ValorPorcentaje=+s,a.Valor=+s/100*+t;break;case"DTO_VALOR":a.ListObsSKU=null,a.Valor=s;break;case"DTO_EXACT":a.ListObsSKU=null,a.Valor=+t-+s;break;case"OBSEQ":a.Valor=0,a.ListObsSKU=i.OBSEQUIOS,a.ReglaObseq=i.ReglaObseq,this.ValidarCantidadObsequios(r,i.OBSEQUIOS,a);break;case"MONEDERO":a.ListObsSKU=null,a.Valor=0,a.ValorMonedero=+i.Valor;break;case"CUPON":a.Valor=0,a.ListObsSKU=null,a.IdCupon=i.Valor;break;case"ACTIVA_PROMO":a.Valor=0,a.ListObsSKU=null,a.lIdActivaPromo=i.Valor.split(",");break;case"RESTRICCION_PAGO":case"RESTRICCION":a.Valor=0,a.ListObsSKU=null,a.Tipo=i.Tipo2.trim().toUpperCase();break;default:"COMBINADA"==i.Tipo?(a.Valor=0,a.ListObsSKU=null,a.PromocionCombinada=new W,a.PromocionCombinada.IdPromocionCombinada=a.IDPromocion,a.PromocionCombinada.Tipo2=i.Tipo2.trim().toUpperCase(),a.PromocionCombinada.Nombre=a.Nombre,a.PromocionCombinada.Accion=i,this.ValidarCamposAdicionales(r,a.PromocionCombinada,o)):a=null}return o.FormaPago&&(a.flags.formaPago=!0),a}catch(c){return console.log(c),null}},o.prototype.ValidarCantidadObsequios=function(o,t,e){try{var r=-1;this.goDataAdicional.dCantidad;o.find(function(o){return o.IdPromocion==e.IDPromocion}).M3CONDIAGRUPACION.forEach(function(o){var t=o.M3CONDIPROMO.find(function(o){return"dCantidad"==o.Concepto});r=t?+t.Valor:1}),e.CantidadObseq=r}catch(n){console.log(n)}},o.prototype.ValidarCamposAdicionales=function(o,t,e){switch(t.Tipo2){case"OBSEQ_CIERRE":var r="1";(n=o.find(function(o){return o.IdPromocion==t.IdPromocionCombinada})).M3CONDIAGRUPACION.forEach(function(o){var t=o.M3CONDIPROMO.find(function(o){return"dCantidad"==o.Concepto});r=t?t.Valor:"1"}),t.Accion.CantidadObsq=r;break;case"XCARACTERISTICA":break;case"COMBO":var n;n=o.find(function(o){return o.IdPromocion==t.IdPromocionCombinada}),t.Accion.NumCondiciones||(t.Accion.NumCondiciones=n.M3CONDIAGRUPACION[0].M3CONDIPROMO.length),e.IDCondicion&&(t.Accion.IdCondicion=e.IDCondicion)}},o.prototype.ProcesarCombinada=function(o){try{return this.PromoCombinadasV2(o),o}catch(t){return console.log("ProcesarCombinada"),console.log(t),o}},o.prototype.PromoCombinadasV2=function(e){var o,t,r,n=h.cloneDeep(e.M3ENC);e.PromosCombinadas===undefined&&this.GetCombinadasFromDinamicas(e);for(var i=0;i<e.PromosCombinadas.length;i++){this.AddDinamicaProcesoCombinadas(e);var a=e.PromosCombinadas[i],s=this.GetEsAcumulablePromo(a);switch(r=this.GetEncabezadoByCombi(a,e),a.Tipo2){case"MOD_CANTIDAD":var c=this.ProcesarPromoCombyByListEnc(r,s);this.AplicarReglaModCantidad(c,r,a,s);break;case"OBSEQ_CIERRE":c=this.ProcesarPromoCombyByListEnc(r,s);this.ProcesarPromoObsqCierre(c,a,e,s);break;case"OBSEQ_SUMTOTAL":this.procesarObseqSumTotal(r,a,e);break;case"XCARACTERISTICA":c=this.ProcesarPromoCombyByListEnc(r,s);this.VerificarClasificacionesProceso(r,a,c,s);break;case"XCARACTERISTICAPARCIAL":this.ordenarListaEnc(r,s);c=this.ProcesarPromoCombyByListEnc(r,s);this.procesarCaracteristicaParcial(r,a,c,s);break;case"COMBO":for(var u=!0;u;){c=this.ProcesarPromoCombyByListEnc(r,s);u=this.PromocionCombinadaCombo(c,r,a,s,e)}break;case"DTO_VALORTOTAL":c=this.ProcesarPromoCombyByListEnc(r,s);this.AplReglaCombValorTotal(c,r,a,s);break;case"PROD_APLDESC":this.procesarProductoAplDesc(r,a,e,s);break;default:if(r&&0<r.length){c=this.ProcesarPromoCombyByListEnc(r,s);this.CalcularPromocionesByListaPrec(c,r,a,s)}}}var l=function(t){var o=t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor;e.M3ENC.find(function(o){return o.ID==t.ID}).M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor=o};try{for(var d=v(n),f=d.next();!f.done;f=d.next()){l(f.value)}}catch(p){o={error:p}}finally{try{f&&!f.done&&(t=d["return"])&&t.call(d)}finally{if(o)throw o.error}}return e},o.prototype.ordenarListaEnc=function(o,t){t?o.sort(function(o,t){return+t.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor-+o.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor}):o.sort(function(o,t){return+t.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor-+o.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor})},o.prototype.AplReglaCombValorTotal=function(o,t,e,r){var n=+e.Accion.Valor,i=o.reduce(function(o,t){return o+Number(t.PUNITNETO)},0);console.debug(i);for(var a,s=0,c=0;c<o.length;c++)s+=a=o[c].PUNITNETO/i*n,o[c].Aplicado=!0,o[c].PUNITNETO=o[c].PUNITNETO-a;(s<n||n<s)&&(console.debug("Encontre diferencia en promos combinadas: "+n+" vs "+s),o[o.length-1].PUNITNETO=o[o.length-1].PUNITNETO-(n-s)),o.find(function(o){return o.Aplicado})&&(console.debug("AplicarReglaModCantidad"),this.CalculateTotalPriceFromList(o,t,e,!0,r))},o.prototype.procesarObseqSumTotal=function(o,t,n){var e,r,i=+t.Accion.Valor,a=0,s=0,c=1,u=[],l=[],d=new to(null,null,null),f=0,p=0,h=function(t){c=1;for(var o=+t.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor,e=+t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor;c<=e;){a+=o,c++;var r=l.find(function(o){return o.Id==t.ID});r?r.Cantidad++:l.push({Id:t.ID,Cantidad:1}),i<=a+p&&(f+=a,P.agregarProductoAProductosHijosSumTotal(u,n,l),s++,l=[],p=a-i,a=0)}},P=this;try{for(var M=v(o),m=M.next();!m.done;m=M.next()){h(m.value)}}catch(g){e={error:g}}finally{try{m&&!m.done&&(r=M["return"])&&r.call(M)}finally{if(e)throw e.error}}if(0<u.length){var C=d.loadM3PEncItemsFromPromocionCombo(n,u,t.Accion.Codigo,f,1);d.armarListaObsequiosCombiSKU(t,C,s),n.oM3RegService=d}},o.prototype.agregarProductoAProductosHijosSumTotal=function(e,r,o){var t,n,i,a,s=new to(null,null,null),c=function(t){if(t){var o=r.M3ENC.find(function(o){return o.ID==t.Id});o&&0<+(a=o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto})).Valor&&(a.Valor=(+a.Valor-t.Cantidad).toString(),i=h.cloneDeep(o),s.ValoresCalculadosProceso(i,t.Cantidad),e.push(i),u.agregarAProductosQuitarCombi(r,i,t.Cantidad))}},u=this;try{for(var l=v(o),d=l.next();!d.done;d=l.next()){c(d.value)}}catch(f){t={error:f}}finally{try{d&&!d.done&&(n=l["return"])&&n.call(l)}finally{if(t)throw t.error}}},o.prototype.getProdutoPromoComboSumTotal=function(o,t){var e,r=o.find(function(o){return o.ID==t.ID});if(r&&0<+(e=r.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto})).Valor)return e.Valor=(+e.Valor-1).toString(),h.cloneDeep(r);return null},o.prototype.GetListaPrecios=function(o,t){for(var e=new Array,r=0;r<t.length;r++)o.filter(function(o){return o.ID==t[r].ID}).forEach(function(o){e.push(o)});return e},o.prototype.PromocionCombinadaCombo=function(o,t,e,r,n){var i=this,a=!1;try{for(var s=+e.Accion.NumCondiciones,c=+e.Accion.Valor,u=new Array,l=0,d=0,f=0,p=new Array,h=void 0,P=1;P<=s;P++){var M=this.BuscarEncByPromoYCond(t,P.toString(),e.IdPromocionCombinada.toString());u.push(this.GetListaPrecios(o,M))}if(this.filtrarListaCondicionesCombo(u,t),0<u.length){l=u[0].length;for(var m=1;m<u.length;m++){var C=u[m].length;C<l&&(l=C)}1<l&&(l=1);for(var g=0;g<u.length;g++)for(var I=u[g],y=0;y<l;y++){var O=I[y];f+=+o.find(function(o){return o.ID==O.ID&&o.Indice==O.Indice}).PUNITNETO}d=100-100*+c/f;for(g=0;g<u.length;g++)for(I=u[g],y=0;y<l;y++){O=I[y];o.filter(function(o){return o.ID==O.ID}).forEach(function(o){if(o.Indice==O.Indice){if(!o.PromoAplicada){var t=o.PUNITNETO;o.PUNITNETO=t-t*d/100,o.PromoAplicada=!0}i.agregarProductoAProductosHijos(p,n,o)}else o.PUNITNETO=0}),a=!0}a&&(h=new to(null,null,null),this.CalculateTotalPriceFromList(o,p,e,!0,r),h.loadM3PEncItemsFromPromocionCombo(n,p,e.Accion.Codigo,e.Accion.Valor,1))}this.limpiarEncItemPrdCondi(t)}catch(S){console.log("PromocionCombinadaCombo"),console.log(S)}return a},o.prototype.filtrarListaCondicionesCombo=function(o,r){for(var t,e,n=0;n<o.length;n++){var i=[],a=function(t){var o=r.find(function(o){return o.ID==t.ID});if(o){var e=o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor;if(o.PrdCondi=o.PrdCondi?o.PrdCondi:0,e>o.PrdCondi)return i=[t],o.PrdCondi++,"break"}};try{for(var s=v(o[n]),c=s.next();!c.done;c=s.next()){if("break"===a(c.value))break}}catch(u){t={error:u}}finally{try{c&&!c.done&&(e=s["return"])&&e.call(s)}finally{if(t)throw t.error}}o[n]=i}},o.prototype.limpiarEncItemPrdCondi=function(o){o.forEach(function(o){delete o.PrdCondi})},o.prototype.agregarAProductosQuitarCombi=function(o,t,e){var r;void 0===e&&(e=1),o.ProductosCombi||(o.ProductosCombi=[]),(r=o.ProductosCombi.find(function(o){return o.ID==t.IdProducto}))?r.Cantidad+=-1*e:o.ProductosCombi.push({ID:t.IdProducto,Cantidad:-1*e})},o.prototype.agregarProductoAProductosHijos=function(o,t,e){var r=this.getProdutoPromoCombo(t.M3ENC,e);r&&(new to(null,null,null).ValoresCalculadosProceso(r,1),o.push(r),this.agregarAProductosQuitarCombi(t,r))},o.prototype.getProdutoPromoCombo=function(o,t){var e,r=o.find(function(o){return o.ID==t.ID});if(r&&0<+(e=r.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto})).Valor)return e.Valor=(+e.Valor-1).toString(),h.cloneDeep(r);return null},o.prototype.AddtoHmPrecios=function(o,t){var e=o.find(function(o){return o.ID==t});return e?e.Indice=+e.Indice+1:(e={ID:t,Indice:0},o.push(e)),e.Indice},o.prototype.BuscarEncByPromoYCond=function(o,t,e){for(var r=new Array,n=0;n<o.length;n++)try{var i=o[n];if(console.debug(i.IdEncPadre),!(i.IdEncPadre&&0<i.IdEncPadre)){var a=i.M3DET.find(function(o){return"PROMOCOMBI"==o.NombreConcepto}),s=i.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto});if(a&&s&&0<+s.Valor){var c=JSON.parse(a.Valor).find(function(o){return o.IdPromocionCombinada==e});if(c){var u=c.Accion.IdCondicion;u&&(u.length?u.find(function(o){return o==t})&&r.push(i):u==t&&r.push(i))}}}}catch(l){}return r},o.prototype.GetEsAcumulablePromo=function(o){try{if(o.Accion.Regla&&"ACM"==o.Accion.Regla)return!0}catch(t){console.log("Error GetEsAcumulable"),console.log(t)}return!1},o.prototype.procesarProductoAplDesc=function(o,e,t,r){var n=this,i=new Array,a=[],s=e.Accion.skuAplDesc,c=+e.Accion.maxNumDesc,u=0;try{if(c){for(c=o.reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},0)*c,t.M3ENC.forEach(function(t){s.find(function(o){return o.SKU==t.IdProducto})&&a.push(t)}),i=this.ProcesarPromoCombyByListEnc(a,r);u<c&&u<i.length;)i[u].PUNITNETO-=+i[u].PUNITNETO*(+e.Accion.Valor/100),u++;this.CalculateTotalPriceFromList(i,a,e,!0,r)}else o.forEach(function(t){u=0;var o=s.find(function(o){return o.SKU==t.IdProducto});if(o)for(a.push(t),c=+t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor*o.Cantidad,n.ProcesarPromoCombyByListEncByPrd(t,r,i);u<c;)i[u].PUNITNETO-=+i[u].PUNITNETO*(+e.Accion.Valor/100),u++}),this.CalculateTotalPriceFromList(i,a,e,!0,r)}catch(l){}},o.prototype.ProcesarPromoObsqCierre=function(o,t,e,r){var n,i;e.ProductosCombi=[];var a=+t.Accion.CantidadObsq,s=0,c=0,u=0,l=0,d=[],f=[],p=new to(null,null,null);p.obsequiosExc=!0,p.oListaObsequios=t.Accion.OBSEQUIOS,p.obsequiosCantidad=0;var h=function(t){c+=t.PUNITNETO,s++;var o=d.find(function(o){return o.Id==t.ID});o?o.Cantidad++:d.push({Id:t.ID,Cantidad:1}),s===a&&(l+=c,P.agregarProductoAProductosHijosSumTotal(f,e,d),u++,d=[],s=0)},P=this;try{for(var M=v(o),m=M.next();!m.done;m=M.next()){h(m.value)}}catch(g){n={error:g}}finally{try{m&&!m.done&&(i=M["return"])&&i.call(M)}finally{if(n)throw n.error}}if(t.Accion.Codigo||console.error("El código del combo no esta configurado en M3DETCONDIPROMO"),0<f.length&&t.Accion.Codigo){var C=p.loadM3PEncItemsFromPromocionCombo(e,f,t.Accion.Codigo,l,1);p.armarListaObsequiosCombiSKU(t,C,u),e.oM3RegService=p}},o.prototype.AplicarReglaModCantidad=function(o,t,e,r){var n,i=e.Accion,a=i.Cantidad,s=+i.Valor/+a;if(a<=(n=o.length)){if(n%a==0);else n-=n%a;for(var c=0;c<n;c++)o[c].PUNITNETO>s&&(o[c].PUNITNETO=s,o[c].Aplicado=!0);o.find(function(o){return o.Aplicado})&&(console.debug("AplicarReglaModCantidad"),this.CalculateTotalPriceFromList(o,t,e,!0,r))}},o.prototype.GetCombinadasFromDinamicas=function(o){try{var t=o.lM3PDinamicas.find(function(o){return"COMBINADA"==o.Nombre}).Valor,e=JSON.parse(t);o.PromosCombinadas=e}catch(r){}},o.prototype.AddDinamicaProcesoCombinadas=function(o){var t;if(t=o.lM3PDinamicas.find(function(o){return"COMBINADA"==o.Nombre})){for(var e=JSON.parse(t.Valor),r=0;r<e.length;r++){o.PromosCombinadas.find(function(o){return o.IdPromocionCombinada==e[r].IdPromocionCombinada})||o.PromosCombinadas.push(e[r])}t.Valor=JSON.stringify(o.PromosCombinadas)}else{var n=new R;n.Nombre="COMBINADA",n.Valor=JSON.stringify(o.PromosCombinadas),o.lM3PDinamicas.push(n)}},o.prototype.CalcularPromocionesByListaPrec=function(o,t,e,r){var n=e.Tipo2,i=0,a=0,s=+n.split("X")[1],c=+n.split("X")[0]-+s,u=0,l=!1;1<s.toString().split(".").length&&(u=+s.toString().split(".")[1],s=+s.toString().split(".")[0]);var d=0;if(0<(o=o.sort(function(o,t){return o.PUNITNETO<t.PUNITNETO?1:o.PUNITNETO>t.PUNITNETO?-1:0})).length){for(var f=+o.length-1;d<o.length&&d<=f;){for(a=i=0;i<s;)i++,d++;for(;a<c&&d<=f;)o[f].PUNITNETO=0==u?(l=!0,.01):(l=!0,+o[f].PUNITNETO*(+u/10)),a++,f--}l&&this.CalculateTotalPriceFromList(o,t,e,!1,r)}},o.prototype.CalculateTotalPriceFromList=function(o,t,e,r,n){for(var i=0,a=0,s=0;s<t.length;s++){var c,u=t[s],l=o.filter(function(o){return o.ID==u.ID}).reduce(function(o,t){return+o+ +t.PUNITNETO},0);c=u.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor,u.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor=l,!this.ValidarSiTodosAPLPromoCombinada(o,u)&&r||n?(i=this.GetValorPromoAnterior(o,u),a=this.GetValorPromoACt(u,i,l,c,n),n?i=+u.M3DET.find(function(o){return"PRECIOTOTALSINDTO"==o.NombreConcepto}).Valor-c:u.M3DET.find(function(o){return"VAL_PROMOC"==o.NombreConcepto}).Valor=i.toString()):(u.M3DET.find(function(o){return"NOMB_PROMOC"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"NOMB_PROMOC"==o.NombreConcepto}).Valor=""),u.M3DET.find(function(o){return"VAL_PROMOC"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"VAL_PROMOC"==o.NombreConcepto}).Valor=""),u.M3DET.find(function(o){return"NOMB_PRO_COMBI"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"NOMB_PRO_COMBI"==o.NombreConcepto}).Valor=""),u.M3DET.find(function(o){return"VAL_PRO_COMBI"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"VAL_PRO_COMBI"==o.NombreConcepto}).Valor=""),u.M3DET.find(function(o){return"ID_PRO_COMBI"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"ID_PRO_COMBI"==o.NombreConcepto}).Valor=""),this.QuitarLasPromosDirectas(u),this.QuitarLasPromosCombinadas(u),a=+u.M3DET.find(function(o){return"PRECIOTOTALSINDTO"==o.NombreConcepto}).Valor-+u.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor),this.SetValorPromociones(u,a+i),this.AgregarListaPromo(u,e,a),this.RecalcularPrecioUnitFromTotal(u,l)}},o.prototype.QuitarLasPromosDirectas=function(o){try{o.M3DET.filter(function(o){return o.NombreConcepto.toUpperCase().startsWith("VAL_PROMOC_")}).forEach(function(o){o.Valor="0"})}catch(t){}},o.prototype.QuitarLasPromosCombinadas=function(o){try{o.M3DET.filter(function(o){return o.NombreConcepto.toUpperCase().startsWith("VAL_PRO_COMBI_")}).forEach(function(o){o.Valor="0"})}catch(t){}},o.prototype.RecalcularPrecioUnitFromTotal=function(o,t){o.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor=(+t/+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor).toString()},o.prototype.ValidarSiTodosAPLPromoCombinada=function(o,t){return!o.filter(function(o){return o.ID==t.ID}).find(function(o){return o.PUNITNETO==t.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor})},o.prototype.GetValorPromoAnterior=function(o,t){try{var e=t.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor;return+o.filter(function(o){return o.ID==t.ID&&o.PUNITNETO==e}).length*+t.M3DET.find(function(o){return"VUNITPROMO"==o.NombreConcepto}).Valor}catch(r){return 0}},o.prototype.GetValorPromoACt=function(o,t,e,r,n){try{return n?+r-+e:+ +o.M3DET.find(function(o){return"PRECIOTOTALSINDTO"==o.NombreConcepto}).Valor-+t-+e}catch(i){console.log("Error GetValorPromoACt: "),console.log(i)}},o.prototype.SetValorPromociones=function(o,t){try{o.M3DET.find(function(o){return"TOTALPROMO"==o.NombreConcepto}).Valor=(Math.round(100*t)/100).toString(),o.M3DET.find(function(o){return"VUNITPROMO"==o.NombreConcepto}).Valor=(+Math.round(100*t)/100/+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor).toString()}catch(e){}},o.prototype.AgregarListaPromo=function(o,t,e){var r,n,i;r=o.M3DET.find(function(o){return"NOMB_PRO_COMBI"==o.NombreConcepto}),n=o.M3DET.find(function(o){return"VAL_PRO_COMBI"==o.NombreConcepto}),i=o.M3DET.find(function(o){return"ID_PRO_COMBI"==o.NombreConcepto}),r||(r=new T,n=new T,i=new T,r.NombreConcepto="NOMB_PRO_COMBI",n.NombreConcepto="VAL_PRO_COMBI",i.NombreConcepto="ID_PRO_COMBI",r.Valor="",n.Valor="",i.Valor="",o.M3DET.push(r),o.M3DET.push(n),o.M3DET.push(i)),r.Valor=r.Valor+t.Nombre+",",i.Valor=i.Valor+t.IdPromocionCombinada+",",n.Valor=n.Valor+e.toString()+",";for(var a=r.Valor.replace(/.$/,"").split(","),s=i.Valor.replace(/.$/,"").split(","),c=(n.Valor.replace(/.$/,"").split(","),0);c<s.length;c++)this.actualizarOCrearPDinamica(o.M3DET,a[c],"NOMB_PRO_COMBI_"+c),this.actualizarOCrearPDinamica(o.M3DET,a[c],"ID_PRO_COMBI_"+c),this.actualizarOCrearPDinamica(o.M3DET,a[c],"VAL_PRO_COMBI_"+c)},o.prototype.actualizarOCrearPDinamica=function(o,t,e){var r=o.find(function(o){return o.NombreConcepto==t});r?r.Valor=e:((r=new T).NombreConcepto=t,r.Valor=e,o.push(r))},o.prototype.GetEncabezadoByCombi=function(t,o){var e=this;try{return o.M3ENC.filter(function(o){return o.PromoCombinadas===undefined&&e.SetPromoCombinadaENC(o),!(0<o.IdEncPadre)&&(!!(o.PromoCombinadas&&0<+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor)&&(0<o.PromoCombinadas.length&&o.PromoCombinadas.find(function(o){return o.IdPromocionCombinada==t.IdPromocionCombinada})))})}catch(r){return null}},o.prototype.SetPromoCombinadaENC=function(o){try{var t;(t=o.M3DET.find(function(o){return"PROMOCOMBI"==o.NombreConcepto}))&&(o.PromoCombinadas=JSON.parse(t.Valor))}catch(e){}},o.prototype.ProcesarPromoCombyByListEnc=function(o,t){for(var e=new Array,r=0;r<o.length;r++){var n,i,a=o[r];n=+a.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor,i=t?+a.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor:+a.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor;for(var s=0;s<n;s++)e.push({Indice:s,PUNITNETO:i,ID:a.ID,IDPRODUCTO:a.IdProducto})}return e},o.prototype.ProcesarPromoCombyByListEncByPrd=function(o,t,e){var r,n;e=new Array;r=+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor,n=t?+o.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor:+o.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor;for(var i=0;i<r;i++)e.push({Indice:i,PUNITNETO:n,ID:o.ID,IDPRODUCTO:o.IdProducto})},o.prototype.ProcesarCombinadaXporY=function(o,t){},o.prototype.get_total_fidelizacion=function(o){var t=0;return o!==undefined&&o.M3ENC!==undefined&&(t=o.M3ENC.filter(function(o){return 0<+o.M3DET.find(function(o){return"FIDELIZACION"==o.NombreConcepto}).Valor}).reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"FIDELIZACION"==o.NombreConcepto}).Valor/100*+t.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor},0)),t},o.prototype.get_value_fidelizacion_by_proceso=function(o,t){var e=o.ValorNeto,r=0,n=this.get_list_condi_promo_by_actividad(t,"PAGO","MONEDERO");if(o.lM3PEncFP)for(var i=0;i<o.lM3PEncFP.length;i++){var a=o.lM3PEncFP[i],s=this.validate_condi_by_forma_pago(a,n);if(0<s.length){var c=a.Valor-a.ValCambio;r+=this.calculate_fidelizacion_by_forma_pago(e,o.M3ENC,c,s,t)}}return r=this.oMathTF.round(r,2)},o.prototype.getRestriccionesTipoPagoActivas=function(r,o){var n=new Array;if(0<r.length)for(var t=0;t<o.length;t++){var e=o[t].M3DET;if(0<+o[t].M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor){var i=e.find(function(o){return"ID_PROMOC"==o.NombreConcepto});if(i)for(var a=i.Valor.split(","),s=function(o){var t=+a[o],e=r.find(function(o){return o.IdPromocion==t});e&&!n.find(function(o){return o.IdPromocion==t})&&n.push(e)},c=0;c<a.length;c++)s(c)}}return n},o.prototype.getRestriccionesTipoPagoActivasFromEncPromo=function(o,t){var e=this.get_list_condi_promo_by_actividad(o,"PAGO","RESTRICCION_PAGO");return this.getRestriccionesTipoPagoActivas(e,t)},o.prototype.m3_get_movimientos_fidelizacion=function(o,t,e,r,n){o.getWithBodyM3("M3/m3_get_movimientos_fidelizacion/"+t,e).subscribe(function(o){var t,e=JSON.parse(o.toString());e.MOVS.MOV.length?t=e.MOVS.MOV:(t=new Array).push(e.MOVS.MOV),r(t)},function(o){n(o.error.Message)})},o.prototype.validate_condi_by_forma_pago=function(o,t){for(var e=new Array,r=0;r<t.length;r++){var n=t[r],i=JSON.parse(n.JAdicionales);switch(n.Concepto.trim()){case"ID_PAGO":i.ROOT.Estructura&&i.ROOT.Estructura.Operacion&&"DIFF"==i.ROOT.Estructura.Operacion?n.Valor="^(?!("+n.Valor+")\\b)\\w+$":n.Valor="^("+n.Valor+")$",new RegExp(n.Valor,"i").test(o.IdTipoPago.toString())&&e.push(n)}}return e},o.prototype.get_list_condi_promo_by_actividad=function(o,t,e){var r=new Array,n=new Date;if(o)for(var i=0;i<o.length;i++){var a=o[i],s=new Date(a.Vigencia),c=new Date(a.Inicio);if(a.Estado&&n<=s&&c<=n&&a.Tipo2==e)for(var u=0;u<a.M3CONDIAGRUPACION.length;u++)for(var l=a.M3CONDIAGRUPACION[u],d=0;d<l.M3CONDIPROMO.length;d++){var f=l.M3CONDIPROMO[d];if(f.JAdicionales){var p=JSON.parse(f.JAdicionales);p.ROOT.ACTIVIDAD&&p.ROOT.ACTIVIDAD==t&&r.push(f)}}}return r},o.prototype.calculate_fidelizacion_by_forma_pago=function(o,t,e,r,n){var i,a,s,c,u,l,d=0,f=e/o,p=0;try{for(var h=v(t),P=h.next();!P.done;P=h.next()){var M=P.value;u=[],l=M.M3DET.find(function(o){return"ID_PROMOC"==o.NombreConcepto}),p=+M.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor;var m=M.M3DET.find(function(o){return"PRECIOSR"==o.NombreConcepto});null!=m&&null!=m.Valor&&(p=+m.Valor),l&&l.Valor&&(u=l.Valor.split(","));var C=function(t){if(u.find(function(o){return+o==t.IdPromocion})){var o=n.find(function(o){return o.IdPromocion==t.IdPromocion}),e=g.validarRedondeo(o,p*g.getPorcentajeFidelizacionFromEncPromo(o)/100)*f;return d+=e,"break"}},g=this;try{for(var I=v(r),y=I.next();!y.done;y=I.next()){if("break"===C(y.value))break}}catch(O){s={error:O}}finally{try{y&&!y.done&&(c=I["return"])&&c.call(I)}finally{if(s)throw s.error}}}}catch(S){i={error:S}}finally{try{P&&!P.done&&(a=h["return"])&&a.call(h)}finally{if(i)throw i.error}}return d},o.prototype.getPorcentajeFidelizacionFromEncPromo=function(o){try{var t=JSON.parse(o.JAdicionales);if(t.ROOT&&t.ROOT.Accion&&t.ROOT.Accion.Valor)return t.ROOT.Accion.Valor}catch(e){}return 0},o.prototype.validarRedondeo=function(o,t){try{var e=JSON.parse(o.JAdicionales);if(e.ROOT&&e.ROOT.Accion&&e.ROOT.Accion.Redondeo)return this.oMathTF.round(t,+e.ROOT.Accion.Redondeo)}catch(r){return t}return t},o.prototype.add_dinamica_fidelizacion_to_proceso=function(o,t){var e=0;if(t&&(e=this.get_value_fidelizacion_by_proceso(o,t)),0<e){var r=new R;r.Nombre="FIDELIZACION",r.Valor=e.toString(),o.lM3PDinamicas.push(r)}return o},o.prototype.validate_doc_fidelizacion=function(o,t,e,r,n){o.getWithBodyM3("M3/validate_doc_fidelizacion/"+t,e).subscribe(function(o){var t;t=JSON.parse(o.toString()).RESPUESTA.M3SaldosXCuenta,r(t)},function(o){n(o.error.Message)})},o.prototype.actualizar_saldo_fidelizacion=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/actualizar_saldo_fidelizacion/"+t,e).subscribe(function(o){e.pago.idDiario=o._body.replace('"',"").replace('"',""),r(e.pago)},function(o){n(o)})},o.prototype.m3_generar_bono_devolucion=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/m3_generar_bono_devolucion/"+t,e).subscribe(function(o){r(o)},function(o){n(o)})},o.prototype.m3InsertSaldoXCuenta=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/m3InsertSaldoXCuenta/"+t,e).subscribe(function(o){r()},function(o){n(o)})},o.prototype.getCantidadTotal=function(o){if(o){var t=o.filter(function(o){return 0<+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor}).reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},0);return 0==t?0:t}return 0},o}(),z=function(){function o(){this.listener=new r.EventEmitter,this.aplSyncCouchAuto=!0,this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.getFlagSyncCouch=function(){var o,t,e=sessionStorage.getItem("SUbicacion"),r=!0;return e&&(o=JSON.parse(e)).M3HUBS&&o.M3HUBS[0]&&o.M3HUBS[0].Configuracion&&null!=(t=JSON.parse(o.M3HUBS[0].Configuracion)).SyncCouchAuto&&t.SyncCouchAuto!=undefined&&(r=t.SyncCouchAuto),r},o.prototype.CrearPouchSincronizacion=function(){this.idkatios=this.GetIdKatiosLVL1FromSession(),this.database=new a("ConfigLP_"+this.idkatios,{auto_compaction:!0}),console.debug("adapter"),console.debug(this.database.adapter),this.syncCouch(),this.isInstantiated=!0,console.log("********************************** INSTANCE CONFIGLP *****************************************")},o.prototype.syncCouch=function(){this.idkatios?this.sync(this.GetServer()+"configlp_"+this.idkatios.toLowerCase()):this.CrearPouchSincronizacion()},o.prototype.getUbicacion=function(){var o,t=sessionStorage.getItem("SUbicacion");return t&&(o=JSON.parse(t)).IDUbicacion?o.IDUbicacion:null},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.Destroy=function(o){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.prototype.sync=function(o){var t=this;this.aplSyncCouchAuto=this.getFlagSyncCouch();var e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:this.aplSyncCouchAuto,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO CONFIGLP *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO CONFIGLP *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getInfo=function(){return this.database.info()},o.prototype.getChangeListener=function(){return this.listener},o.prototype.deleteLp=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.prototype.DeleteAllDocs=function(){var t=this;this.database.allDocs({include_docs:!0}).then(function(o){return o.rows.map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return t.database.bulkDocs(o)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Q=function(){function o(o){this.oMathTF=new q,this.aplPreciosDinamicos=!1,this.gsidkatios=o,this.GetKatiosM3FromSession()}return o.prototype.GetKatiosM3FromSession=function(){var o=localStorage.getItem("ConfigKatios"+this.gsidkatios.toUpperCase());if(o!==undefined&&null!=o){var t=JSON.parse(o);if(t&&t.Katios&&t.Katios.KatiosM3){var e=t.Katios.KatiosM3.find(function(o){return"APLLPDINAMICOS"==o.Llave.toUpperCase()});e&&"1"==e.Valor&&(this.aplPreciosDinamicos=!0)}}},o.prototype.AsignarListaPrecioM3Pack=function(g,I,y){return O(this,void 0,void 0,function(){var t,e,r,n,i,a,s,c,u,l,d,f,p,h,P,M,m,C;return S(this,function(o){switch(o.label){case 0:o.trys.push([0,5,6,7]),s=v(g.M3PrdGrpAsociado),c=s.next(),o.label=1;case 1:return c.done?[3,4]:(u=c.value,[4,this.AsignarListaPrecio(u.M3GRP,I,y)]);case 2:o.sent(),o.label=3;case 3:return c=s.next(),[3,1];case 4:return[3,7];case 5:return l=o.sent(),t={error:l},[3,7];case 6:try{c&&!c.done&&(e=s["return"])&&e.call(s)}finally{if(t)throw t.error}return[7];case 7:o.trys.push([7,18,19,20]),d=v(g.LoM3PrdGeneral),f=d.next(),o.label=8;case 8:if(f.done)return[3,17];p=f.value,o.label=9;case 9:o.trys.push([9,14,15,16]),h=v(p.M3PACK),P=h.next(),o.label=10;case 10:return P.done?[3,13]:(M=P.value,[4,this.AsignarListaPrecio(M.M3GRP,I,y)]);case 11:o.sent(),o.label=12;case 12:return P=h.next(),[3,10];case 13:return[3,16];case 14:return m=o.sent(),i={error:m},[3,16];case 15:try{P&&!P.done&&(a=h["return"])&&a.call(h)}finally{if(i)throw i.error}return[7];case 16:return f=d.next(),[3,8];case 17:return[3,20];case 18:return C=o.sent(),r={error:C},[3,20];case 19:try{f&&!f.done&&(n=d["return"])&&n.call(d)}finally{if(r)throw r.error}return[7];case 20:return[2,""]}})})},o.prototype.AsignarListaPrecio=function(d,f,p){return O(this,void 0,void 0,function(){var t,a,s,c,u,e,l=this;return S(this,function(o){switch(o.label){case 0:if(this.GetKatiosM3FromSession(),null==f||!f.UsuarioSistema||f.UsuarioSistema.IDLPrecio===undefined||-1==f.UsuarioSistema.IDLPrecio||!d)return[3,5];t=function(){var t,e,r,n,i;return S(this,function(o){switch(o.label){case 0:if(s=d.LoM3PrdGeneral[u],t=f.UsuarioSistema.IDLPrecio.split("-"),!((c=s.LoM3ListaPrecio.find(function(o){return o.IDLISTA==t[0]}))&&t&&1<t.length))return[3,4];if(a.aplPreciosDinamicos)return[3,1];switch(t[1]){case"LB":c.PRECIO=c.LB;break;case"LC":c.PRECIO=c.LC;break;case"LD":c.PRECIO=c.LD}return[3,4];case 1:return o.trys.push([1,3,,4]),[4,(new z).get(t[0])];case 2:return e=o.sent(),(r=JSON.parse(e.JConfiguracion))&&r.Factores&&0<r.Factores.length&&(n=parseFloat(r.Factores.find(function(o){return o.Nombre==t[1]}).Factor),c.PRECIO=a.oMathTF.round(c.PRECIO*n,2),c.M3Presentaciones.forEach(function(o){o.VALOR=l.oMathTF.round(o.VALOR*n,2)})),[3,4];case 3:return i=o.sent(),console.log("error en asignarlistaprecio: "+i.message+" - "+t[0]),[3,4];case 4:return c===undefined?[3,5]:(s.LoM3PrdLista=c,[3,7]);case 5:return[4,a.ValidarDataFromInventario(s,f,p)];case 6:o.sent(),o.label=7;case 7:return[2]}})},a=this,u=0,o.label=1;case 1:return u<d.LoM3PrdGeneral.length?[5,t()]:[3,4];case 2:o.sent(),o.label=3;case 3:return u++,[3,1];case 4:(e=new g).ATRIBUTO="LISTAPRECIO",e.VALOR=f.UsuarioSistema.IDLPrecio,d.LoM3PrdAdicionales.push(e),o.label=5;case 5:return d?[4,this.AsignarListaPrecioM3Pack(d,f,p)]:[3,7];case 6:o.sent(),o.label=7;case 7:return[2,""]}})})},o.prototype.AsignarListaPrecioAGeneral=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return null==r||r.UsuarioSistema.IDLPrecio===undefined||-1==r.UsuarioSistema.IDLPrecio?[3,3]:(t=e.LoM3ListaPrecio.find(function(o){return o.IDLISTA==r.UsuarioSistema.IDLPrecio}))===undefined?[3,1]:(e.LoM3PrdLista=t,[3,3]);case 1:return[4,this.ValidarDataFromInventario(e,r,n)];case 2:o.sent(),o.label=3;case 3:return[2,""]}})})},o.prototype.ValidarDataFromInventario=function(a,s,c){return O(this,void 0,void 0,function(){var t,e,r,n,i;return S(this,function(o){switch(o.label){case 0:return t=s.UsuarioSistema.IDLPrecio,e=new to(null,null,null),"INV"!=t.split("_")[0]?[3,2]:(r={ubicacion:s.UsuarioSistema.UBICACION,sku:a.SKU,lote:a.LOTE,concepto:t.split("_")[1]},[4,e.GetConceptoM3SaldosItemUb(c,this.gsidkatios,r)]);case 1:(n=o.sent())&&0!=n&&((i=new I).IDLISTA=s.UsuarioSistema.IDLPrecio,i.LOTE=a.LOTE,i.PRECIO=n,i.SKU=a.SKU,a.LoM3PrdLista=i),o.label=2;case 2:return[2]}})})},o}(),$=function(){function o(){}return o.prototype.getM3ProcesosPorCredito=function(o,t,e,r,n){var i;i={idProceso:e},o.getWithBodyM3("M3/getM3ProcesosPorCredito/"+t,i).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o.error.Message)})},o.prototype.getM3ProcesoByIdPrestamo=function(o,t,e,r,n){o.getM3("M3/getM3ProcesoByIdPrestamo/"+t+"/"+e).subscribe(function(o){r(o)},function(o){n(o)})},o.prototype.m3GetPRDGRP=function(o,t,e,r){o.getM3("M3Maestro/getM3PRDGRP/"+t).subscribe(function(o){var t=JSON.parse(o);e(t)},function(o){r(o)})},o.prototype.M3GetCantidadBySKP1=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/M3GetCantidadBySKP1/"+t,e).subscribe(function(o){var t,e=JSON.parse(o.toString());t=e.RESPUESTA.DISPONIBILIDAD.length===undefined?new Array(e.RESPUESTA.DISPONIBILIDAD):e.RESPUESTA.DISPONIBILIDAD,console.log(t),r(t)},function(o){n(o.error.Message)})},o.prototype.GetListaPrdXFiltros=function(o,t,e,r,n,i,a,s,c,u){var l;void 0===a&&(a="-1"),void 0===s&&(s=!0),void 0===c&&(c="0"),void 0===u&&(u="0"),l={Filtros:JSON.stringify(t),IdLista:e,IdUbicacion:a,aplUltimoFiltro:s,topLimit:c,filtrarInvUbic:u},null!=t?o.getWithBodyM3("M3Maestro/Get_ListPRDFiltros/"+r,l).subscribe(function(o){n(o,t)},function(o){i(o.error.Message)}):i("No hay filtros para la busqueda")},o.prototype.GetListaPrdXCategoria=function(o,t,e,r,n,i,a,s,c){var u,l;void 0===s&&(s="-1"),void 0===c&&(c="0"),u=this.FindFilterInClasificacion(t,n,e),l={Filtros:JSON.stringify(u),IdLista:r,IdUbicacion:s,filtrarInvUbic:c},null!=u?o.getWithBodyM3("M3Maestro/Get_ListPRDFiltros/"+n,l).subscribe(function(o){i(o,u)},function(o){console.log(o.error.Message),a(o.error.Message)}):a("No hay filtros para la busqueda")},o.prototype.GetListaPrdXCategoriaWithOutFilters=function(o,t,e,r,n){o.getM3("M3Maestro/M3GetListaProdByClasificacion/"+e+"/"+t).subscribe(function(o){r(o,null)},function(o){n(o)})},o.prototype.GetListaPrdXNombre=function(o,t,e,r,n,i,a,s){void 0===s&&(s="0");var c={IdLista:n,idUbicacion:e,filtrarInvUbic:s};o.getWithBodyM3("M3Maestro/M3GetListaProdByNombre/"+r+"/"+t,c).subscribe(function(o){i(o)},function(o){console.log(o),a(JSON.parse(o._body).Message)})},o.prototype.cargarListPrdByGeneric=function(o,t,e,r,n,i,a,s){void 0===s&&(s="0");var c={IdLista:n,idUbicacion:e,filtrarInvUbic:s};o.getWithBodyM3("M3Maestro/cargarListPrdByGeneric/"+r+"/"+t,c).subscribe(function(o){i(o)},function(o){console.log(o.error),a(o.error)})},o.prototype.cargarInfoClasificacion=function(o,t,e,r,n){var i=this;e===undefined||null==e?o.getM3("M3Maestro/M3GetClasificacion/"+t).subscribe(function(o){e=JSON.parse(o),i.ValidarArrayClasificacion(e),r(e)},function(o){n(o)}):r(e)},o.prototype.ValidarArrayClasificacion=function(o){this.RecursiveConvertArray(o.RESPUESTA.CLASIFICACIONES)},o.prototype.FindFilterInClasificacion=function(o,t,e){var r,n,i="",a=new Array;if(r=e.RESPUESTA.CLASIFICACIONES,o.length%3!=0)return null;for(;""!=o;)i+=o.substring(0,3),o=o.substring(3),(r=r.CATEGORIA.find(function(o){return o.CLASIFICACION.toString()==i.toString()})).ATRIBUTO.toUpperCase().includes("ROOT")||(n=new M(r.ATRIBUTO,r.Descripcion),a.push(n));return a},o.prototype.RecursiveConvertArray=function(o){var t=this;o.CATEGORIA!==undefined&&(o.CATEGORIA.length===undefined?(o.CATEGORIA=new Array(o.CATEGORIA),this.RecursiveConvertArray(o.CATEGORIA[0])):o.CATEGORIA.forEach(function(o){t.RecursiveConvertArray(o)}))},o.prototype.m3AddProducto=function(o,t,e,r,n,i,a,s){var c;void 0===s&&(s=!1),c={sTdocUsuario:e,sNdocUsuario:r,oM3PrdGrp:n,disabledWeb:s},o.postServiceHttpResFullM3("M3Maestro/addProducto/"+t.trim(),c).subscribe(function(o){i(o)},function(o){a()})},o.prototype.M3GetProductoBySKP1=function(e,r,o,n,t,i){e.getWithBodyM3("M3Maestro/M3GetProductoBySKP1/"+r,o).subscribe(function(o){var t=o;new Q(r).AsignarListaPrecio(t,i,e).then(function(o){n(t)})},function(o){t()})},o.prototype.M3GetProductoRandomBySKP1=function(o,t,e,r,n,i){o.getWithBodyM3("M3Maestro/M3GetProductoRandomBySKP1/"+t,e).subscribe(function(o){r(o)},function(o){n()})},o.prototype.M3GetCatAsociadasBySKP1=function(o,t,e,r,n){o.getM3("M3Maestro/M3GetCatAsociadasBySKP1/"+t+"/"+e).subscribe(function(o){r(o)},function(o){n()})},o.prototype.M3GetImagenesByPath=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/Get_M3MultimediaByPath/"+t,e).subscribe(function(o){r(o)},function(o){console.log(o),n(o.error.Message)})},o.prototype.Get_M3SKPlantillaBySKUID=function(o,t,e,r,n){o.getM3("M3Maestro/Get_M3SKPlantillaBySKUID/"+t+"/"+e).subscribe(function(o){r(o)},function(o){n()})},o.prototype.GetInfoByFilterCode=function(o,t,e,r,n){var i={FILTERCODE:e};o.getWithBodyM3("M3Maestro/M3GetSKP1PrdsByFiltersCode/"+t,i).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){console.log(o),n(o.error.Message)})},o.prototype.get_M3Ubicaciones=function(o,t,e,r,n){o.getM3("M3Maestro/get_M3Ubicaciones/"+t+"/"+e).subscribe(function(o){r(o)},function(o){console.log(o),n(o)})},o.prototype.get_M3UbicacionesCompleta=function(o,t,e,r,n,i){o.getM3WithTimeOut("M3Maestro/get_M3UbicacionesCompleta/"+t+"/"+e+"/"+r,1e4).subscribe(function(o){n(o)},function(o){console.log(o),i(o)})},o.prototype.M3GetProductoBySKU=function(e,o,t,r,n,i){var a=new Q(o);i.UsuarioSistema.FechaPrecio&&(t.fechaLPrecio=i.UsuarioSistema.FechaPrecio),console.log(e),e.getWithBodyM3("M3Maestro/M3GetProductoBySKU/"+o,t).subscribe(function(o){var t=o;a.AsignarListaPrecio(t,i,e).then(function(o){r(t)})},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o.prototype.M3GetProductoBySKUAsync=function(n,i,a,s,c,u){return void 0===c&&(c="-1"),void 0===u&&(u="1"),O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return r=new Q(i),t={SKU:a,UBICACION:"-1"==c?s.UsuarioSistema.UBICACION:c,AplExc:u},s.UsuarioSistema.FechaPrecio&&(t.fechaLPrecio=s.UsuarioSistema.FechaPrecio),[4,n.getWithBodyM3("M3Maestro/M3GetProductoBySKU/"+i,t).toPromise()];case 1:return e=o.sent(),[4,r.AsignarListaPrecio(e,s,n)];case 2:return o.sent(),[2,e]}})})},o.prototype.Get_M3ProductoEspecByCodeAsync=function(r,n,i,a){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return t=new Q(n),a.UsuarioSistema.FechaPrecio&&(i.fechaLPrecio=a.UsuarioSistema.FechaPrecio),[4,r.getWithBodyM3("M3Maestro/Get_M3ProductoEspecByCode/"+n,i).toPromise()];case 1:return e=o.sent(),[4,t.AsignarListaPrecio(e,a,r)];case 2:return o.sent(),[2,e]}})})},o.prototype.M3getRegistrosEnProceso=function(o,t,e,r,n){var i;i={idProceso:e},o.getWithBodyM3("M3/get_RegistrosEnProceso/"+t,i).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){console.log(o),n(o._bSody)})},o.prototype.get_M3PrdGrpByNombre=function(o,t,e,r,n){o.getM3("M3Maestro/get_M3PrdGrpByNombre/"+t+"/"+e).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.M3GRP;t.length===undefined?(o=new Array(t),r(o)):r(t)},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o.prototype.GetM3PrdAgrupadoByNombre=function(o,t,e,r,n){o.getM3("M3Maestro/get_m3_prd_by_nombre_agrupado/"+t+"/"+e).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.M3GRP;t.length===undefined?(o=new Array(t),r(o)):r(t)},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o.prototype.get_m3_prd_by_nombre_agrupado=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/get_m3_prd_by_nombre_agrupado/"+t,e).subscribe(function(o){var t=JSON.parse(String(o)).RESPUESTA.M3GRP;t.length===undefined?(o=new Array(t),r(o)):r(t)},function(o){console.log(o),o._body?n(JSON.parse(o._body).Message):o.error&&o.error.Message?n(o.error.Message):n(o)})},o.prototype.get_PathServidorImagenes=function(o,t,e,r){o.getM3("M3Maestro/get_PathServidorImagenes/"+t).subscribe(function(o){console.log(o),e(o)},function(o){r()})},o.prototype.Get_M3ProductoEspecByCode=function(e,o,t,r,n,i){var a=new Q(o);i.UsuarioSistema.FechaPrecio&&(t.fechaLPrecio=i.UsuarioSistema.FechaPrecio),e.getWithBodyM3("M3Maestro/Get_M3ProductoEspecByCode/"+o,t).subscribe(function(t){var o=t;a.AsignarListaPrecio(o,i,e).then(function(o){r(t)})},function(o){console.log(o),n(o.error.Message)})},o.prototype.Get_M3ProductoEspecByCodeTimeOut=function(e,o,t,r,n,i,a){var s=new Q(o);0!=a?(i&&i.UsuarioSistema&&i.UsuarioSistema.FechaPrecio&&(t.fechaLPrecio=i.UsuarioSistema.FechaPrecio),e.getWithBodyM3TimeOut("M3Maestro/Get_M3ProductoEspecByCode/"+o,t,a).subscribe(function(t){var o=t;s.AsignarListaPrecio(o,i,e).then(function(o){r(t)})},function(o){console.log(o),o.error?n(o.error.Message):n("404")})):n("404")},o.prototype.get_DocsFromCouchMaestro=function(o,t,e,r,n){console.log("get_DocsFromCouchMaestro");var i=o.GetKeyDocumentoDB(t,e);console.log(i),o.GetDataPouchBD(i).then(function(o){r(o)},function(o){n(o)})},o.prototype.GetProductoEspecByCodeFromCouch=function(o,t,e,r){var n=o.find(function(o){return o.LoM3PrdGeneral!=undefined&&o.LoM3PrdGeneral.find(function(o){return o.M3Cods!=undefined&&o.M3Cods.find(function(o){return String(o.Valor)==String(t)})!=undefined})!=undefined}),i=h.cloneDeep(n);if(n!=undefined){var a=n.LoM3PrdGeneral.find(function(o){return o.M3Cods.find(function(o){return String(o.Valor)==String(t)})!=undefined});i.LoM3PrdGeneral=[],i.LoM3PrdGeneral.push(a),console.log("product_clone"),console.log(i),e(i)}else r("No se encontró nungún registro.")},o.prototype.get_TiposProceso=function(o,t,e,r,n){void 0===n&&(n="Ventas"),o.getM3("M3Maestro/get_TiposProceso/"+t+"/"+n).subscribe(function(o){e(JSON.parse(o).RESPUESTA)},function(o){r(o)})},o.prototype.get_InfoPersona_Proceso=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/get_InfoPersona_Proceso/"+t,e).subscribe(function(o){r(JSON.parse(String(o)).RESPUESTA)},function(o){n(o)})},o.prototype.get_InfoPersona_Proceso_async=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e.getWithBodyM3("M3Maestro/get_InfoPersona_Proceso/"+r,n).toPromise()];case 1:return t=o.sent(),[2,JSON.parse(t)];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.GetM3PrdGrpFromList=function(o,e){try{var t;return(t=o.find(function(o){var t=!1;return o.LoM3PrdGeneral.forEach(function(o){o.SKU===e&&(t=!0)}),t})).LoM3PrdGeneral=t.LoM3PrdGeneral.filter(function(o){return o.SKU==e}),t}catch(r){return console.log(r),null}},o.prototype.GetUbicacionFromList=function(o,t){return o.find(function(o){return o.IDUbicacion==t})},o.prototype.getDatosFacturacionFromRFC=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/getDatosFacturacionFromRFC/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o)})},o.prototype.actualizarRFC=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Maestro/actualizarRFC/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.get_XmlConfig_x_IdUbicacion=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/get_XmlConfig_x_IdUbicacion/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o)})},o.prototype.getCFDIsXProceso=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/getCFDIsXProceso/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o)})},o.prototype.get_clasification_attributes=function(o,t,e,r){o.getM3("M3Maestro/get_clasification_attributes/"+t).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.ATTRIBUTES;t.length===undefined&&(t=new Array(t)),e(t)},function(o){r()})},o.prototype.get_clasification_categories=function(o,t,e,r,n){o.getM3("M3Maestro/get_clasification_categories/"+t+"/"+e).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.CATEGORIES;t.length===undefined&&(t=new Array(t)),r(t)},function(o){console.log(o),n()})},o.prototype.getOpcionesAdicionales=function(o,t,e,r){o.getM3("M3Maestro/getOpcionesAdicionales/"+t).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.ATTRIBUTES;t.length===undefined&&(t=new Array(t)),e(t)},function(o){r()})},o.prototype.getAtributosAdicionales=function(o,t,e,r,n){o.getM3("M3Maestro/getAtributosAdicionales/"+t+"/"+e).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.CATEGORIES;t.length===undefined&&(t=new Array(t)),r(t)},function(o){n()})},o.prototype.M3GetFormasEnvio=function(o,t,e,r){o.getM3("M3Maestro/M3GetFormasEnvio/"+t).subscribe(function(o){var t;t=JSON.parse(o),e(t)},function(o){console.log(o),r()})},o.prototype.get_ubicaciones_complete=function(o,t,e,r){o.getM3("M3Maestro/get_ubicaciones_complete/"+t).subscribe(function(o){e(o)},function(o){console.log(o),r()})},o.prototype.get_ubicaciones_simple=function(o,t,e,r){o.getM3("M3Maestro/get_ubicaciones_simple/"+t).subscribe(function(o){e(o)},function(o){console.log(o),r()})},o.prototype.M3GET_LISTAPRECIOS_ASync=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.getM3("M3Maestro/M3GET_LISTAPRECIOS/"+e).toPromise()];case 1:return[2,o.sent()[0]]}})})},o.prototype.GetEncabezadoListasPrecio=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t.getM3("M3/GetConfigLP/"+e).toPromise()];case 1:return[2,o.sent()];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.registrarColonia=function(o,t,e,r,n,i,a,s,c,u){var l;l={sColonia:e,sCodPostal:r,sTelefono:n,ndoc:i,sLinea1:a,sCodestado:s},o.postServiceHttpResFullM3("M3Maestro/registrarColonia/"+t,l).subscribe(function(o){c()},function(o){u(JSON.parse(o._body).Message)})},o.prototype.M3_GetPromocionesMaestroAsync=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.getM3("M3Maestro/M3_GetPromocionesMaestro/"+e).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.M3GetDinByActividad=function(t,e,r,n,i){return O(this,void 0,void 0,function(){return S(this,function(o){return t.getWithBodyM3("M3Maestro/M3GetDinByActividad/"+e,r).subscribe(function(o){n(o)},function(o){console.log(o),i()}),[2]})})},o.prototype.getUbicacionesWeb=function(o,t,e,r){o.getM3("M3Maestro/getUbicacionesWeb/"+t).subscribe(function(o){e(JSON.parse(o))},function(o){r(o)})},o.prototype.getUbicacionesByCodPostal=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/getUbicacionesByCodPostal/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o)})},o.prototype.getPathFEFromDiario=function(o,t,e,r,n,i){o.getWithBodyM3("M3/getPathFEFromDiario/"+t+"/"+e,r).subscribe(function(o){var t=JSON.parse(o.toString());n(t)},function(o){console.log(o),i(o)})},o.prototype.getDiarioAdicionalesxDiario=function(o,t,e,r,n){o.getWithBodyGenerales("Diario/getDiarioAdicionalesxDiario/"+t,e).subscribe(function(o){var t=JSON.parse(o.toString());r(t)},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o.prototype.IU_Hub=function(e,r,n,i,a){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idKatios:r.trim(),oHub:n,uTActivo:i,uNActivo:a},[4,e.postServiceHttpResFullM3("M3Maestro/IU_Hub",t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.GetCtivoBYProceso=function(e,r,n,i,a){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idproceso:n,ubicacion:i,hub:a},[4,e.getWithBodyM3("M3/GetCtivoBYProceso/"+r.trim(),t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.ValidarCtivosVSLocal=function(t,e,r,n,i,a){return O(this,void 0,void 0,function(){return S(this,function(o){return t.postServiceHttpResFullM3("M3/ValidarCtivosVSLocal/"+e+"/"+n+"/"+i,r).subscribe(function(o){a(o)},function(o){a({error:o})}),[2]})})},o.prototype.GenerarAutorizacionCuentas=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.postServiceHttpResFullM3("M3/GenerarAutorizacionCuentas",e).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.validacionAutorizacionM3Cuentas=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.postServiceHttpResFullM3("M3/validacionAutorizacionM3Cuentas",e).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.VerificarPagoTarjetaBBVA=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={Idkatios:r,idKey:n},[4,e.getWithBodyM3("M3/VerificarPagoTarjetaBBVA",t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.getDescripcionSKPs=function(o,t,e,r,n){t.getWithBodyM3("M3Consultas/getDescripcionSKPs/"+o,e).subscribe(function(o){r(e.SKP1,JSON.parse(o.toString()))},function(o){n(o.error.Message)})},o.prototype.getTotalesCierreCaja=function(r,n,i,a,s,c,u){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return e={idKatios:n,ubicacion:i,hub:a,usuario:s,FechaI:c,FechaF:u},[4,r.getWithBodyM3("M3/getTotalesCierreCaja",e).toPromise()];case 1:return t=o.sent(),[2,t=JSON.parse(t)]}})})},o.prototype.getCierresxUbicacion=function(r,n,i,a,s){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return e={idKatios:n,ubicacion:i,idProceso:a,Fecha:s},[4,r.getWithBodyM3("M3/getCierresxUbicacion",e).toPromise()];case 1:return t=o.sent(),[2,t=JSON.parse(t)]}})})},o.prototype.getCierresxEmpresa=function(r,n,i,a){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return e={idKatios:n,idProceso:i,Fecha:a},[4,r.getWithBodyM3("M3/getCierresxEmpresa",e).toPromise()];case 1:return t=o.sent(),[2,t=JSON.parse(t)]}})})},o.prototype.simularpagoEnlinea=function(o,t,e,r,n,i){o.getM3("M3/ValidacionPagoIntegracionTest/"+t+"/"+e+"/"+r).subscribe(function(o){n()},function(o){i()})},o.prototype.validarPrdsMismoProveedor=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Maestro/validarPrdsMismoProveedor/"+t+"/"+e,r).subscribe(function(o){n(JSON.parse(JSON.parse(o._body).toString()))},function(o){console.error("Error validarPrdsMismoProveedor"),console.error(o),n(JSON.parse(JSON.parse(o._body).Message))})},o.prototype.validarRestriccionInvNegativo=function(o,t,e,r){o.postServiceHttpResFullM3("M3Maestro/validarRestriccionInvNegativo/"+t,e).subscribe(function(o){r(JSON.parse(JSON.parse(o._body).toString()))},function(o){console.error("Error validarRestriccionInvNegativo"),console.error(o),r(JSON.parse(JSON.parse(o._body).Message))})},o.prototype.validarRestriccionInvNegativoV2=function(o,t,e,r){o.postServiceHttpResFullM3("M3Maestro/validarRestriccionInvNegativoV2/"+t,e).subscribe(function(o){try{r(JSON.parse(JSON.parse(o._body).toString()))}catch(t){console.error(o),console.error(t),r(t)}},function(o){console.error("Error validarRestriccionInvNegativoV2"),console.error(o),r(JSON.parse(JSON.parse(o._body).Message))})},o.prototype.validarEfectivoEnCaja=function(o,t,e,r){o.postServiceHttpResFullM3("M3Maestro/validarEfectivoEnCaja/"+t,e).subscribe(function(o){try{r(JSON.parse(JSON.parse(o._body).toString()))}catch(t){console.error(o),console.error(t),r(t)}},function(o){console.error("Error validarEfectivoEnCaja"),console.error(o),r(JSON.parse(JSON.parse(o._body).Message))})},o.prototype.getInfoPrdGastosEnvio=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return[4,e.postServiceHttpResFullM3("M3Maestro/getInfoPrdGastosEnvio/"+r,n).toPromise()];case 1:return t=o.sent(),[2,JSON.parse(JSON.parse(t._body).toString()).RESPUESTA]}})})},o.prototype.m3_generar_M3SXC_aleatorio=function(r,n,i){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,r.postServiceHttpResFullM3("M3/m3_generar_M3SXC_aleatorio/"+n,i).toPromise()];case 1:return t=o.sent(),[2,JSON.parse(JSON.parse(t._body).toString()).RESPUESTA];case 2:return e=o.sent(),console.error(e),[2,null];case 3:return[2]}})})},o.prototype.M3_actualizarConceptoSIU=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/M3_actualizarConceptoSIU/"+t,e).subscribe(function(o){r(o)},function(o){n(o)})},o.prototype.procesoAlCierreUbic=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/procesoAlCierreUbic/"+t,e).subscribe(function(o){r(o)},function(o){console.error("Error procesoAlCierreUbic"),console.error(o),n(o)})},o.prototype.get_ProcesosAbiertos=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/get_ProcesosAbiertos/"+t,e).subscribe(function(o){r(JSON.parse(String(o)).RESPUESTA)},function(o){console.error("Error get_ProcesosAbiertos"),console.error(o),n(o)})},u([l(6,r.Optional()),l(7,r.Optional()),l(8,r.Optional()),l(9,r.Optional()),d("design:type",Function),d("design:paramtypes",[f,Array,String,String,Function,Function,Object,Object,Object,Object]),d("design:returntype",void 0)],o.prototype,"GetListaPrdXFiltros",null),u([l(7,r.Optional()),l(8,r.Optional()),d("design:type",Function),d("design:paramtypes",[f,String,Object,String,String,Function,Function,Object,String]),d("design:returntype",void 0)],o.prototype,"GetListaPrdXCategoria",null),u([l(7,r.Optional()),d("design:type",Function),d("design:paramtypes",[f,String,String,String,String,Function,Function,String]),d("design:returntype",void 0)],o.prototype,"GetListaPrdXNombre",null),u([l(7,r.Optional()),d("design:type",Function),d("design:paramtypes",[f,String,String,String,String,Function,Function,String]),d("design:returntype",void 0)],o.prototype,"cargarListPrdByGeneric",null),o}(),Z=s,oo=require("js-big-decimal"),to=function(){function o(o,t,e){this.oMathTF=new q,this.oListaObsequios=null,this.obsequiosExc=!1,this.obsequioOPromo=-1,this.obsequiosCantidad=0,this.lIdActivaPromo=[],this.oM3CouchMaestro=o,this.GoPostServiceM3=t,this.gsIdkatios=e}return o.prototype.ValidarNumeroItems=function(o){1e3<o.M3ENC.length&&(o.AplDesdeServer=!0,o.M3ENC=new Array)},o.prototype.ProcesamientoService=function(o,t,e,r,n,i,a){void 0===a&&(a=!0),this.ValidarNumeroItems(e),this.RetomarInformacion(r,e,a),t.postServiceHttpResFullM3("M3/RegistroEventoM3/"+o+"/"+r.UsuarioSistema.NDOC+"/"+r.UsuarioSistema.TDOC,e).subscribe(function(o){var t=JSON.parse(o.json());e.IdM3=t.RESPUESTA.IDM3,e.IDDiario=t.RESPUESTA.IDDIARIO,e.IDDiarioCierre=t.RESPUESTA.IDDIARIOCIERRE,e.SubEstadoAnt=e.SubEstadoDes,e.EstadoAnt=e.EstadoDes,n(e,t.RESPUESTA)},function(o){console.error(o.json().Message),i(o.json().Message)})},o.prototype.procesamiento_service_async=function(r,n,i,a,s){return void 0===s&&(s=!0),O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.RetomarInformacion(a,i,s),[4,n.postServiceHttpResFullM3("M3/RegistroEventoM3/"+r+"/"+a.UsuarioSistema.NDOC+"/"+a.UsuarioSistema.TDOC,i).toPromise()];case 1:return t=o.sent(),e=JSON.parse(t.json()),i.IdM3=e.RESPUESTA.IDM3,i.IDDiario=e.RESPUESTA.IDDIARIO,i.SubEstadoAnt=i.SubEstadoDes,i.EstadoAnt=i.EstadoDes,[2,i];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.RegistroEventoM3OffLine=function(t,e,r,n){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e.postServiceHttpResFullM3("M3/RegistroEventoM3OffLine/"+t+"/"+n.UsuarioSistema.NDOC+"/"+n.UsuarioSistema.TDOC,r).toPromise()];case 1:return o.sent(),[2,!0];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.RetomarInformacion=function(o,t,e){null!=o&&t.IdM3!==undefined&&null!=t.IdM3&&(e?(t.M3FTrabajo.IdHub=o.UsuarioSistema.IDHUB,t.M3FTrabajo.IdUbic!=undefined&&0!=t.M3FTrabajo.IdUbic||(t.M3FTrabajo.IdUbic=o.UsuarioSistema.UBICACION)):(t.M3FTrabajo.IdUbic=t.M3FTrabajo.IdUbicPre,t.M3FTrabajo.IdHub=t.M3FTrabajo.IdHubPre))},o.prototype.ProcesamientoServicePouchDB=function(r,n,i,a,e,s,o,c,u,l,d){var f,p,h,P=this;void 0===d&&(d=null),h=i.LoM3PrdGeneral[0],p=r.GetKeyCarritoCompras(o,s.UsuarioSistema.TDOC,s.UsuarioSistema.NDOC,s.UsuarioSistema.UBICACION,s.UsuarioSistema.IDHUB),r.GetDataPouchBD(p).then(function(e){return O(P,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return f=e,0==(t=this.validarExistaProducto(f.M3ENC,h,n))?[3,2]:(n.dCantidad=+t+ +n.dCantidad,f.M3ENC=f.M3ENC.filter(function(o){return!(o.IdProducto==h.SKU&&o.Lote==h.LOTE&&!(0<o.IdEncPadre))}),this.RecalcularPrecios(f),f=this.LoadM3ProcesoFromData(f,i,n,c,u,s,d),[4,r.AddToPouchBDCarritoCompras(p,f)]);case 1:return o.sent(),a(f,n),[3,4];case 2:return f=this.LoadM3ProcesoFromData(f,i,n,c,u,s,d),[4,r.AddToPouchBDCarritoCompras(p,f)];case 3:o.sent(),a(f,n),o.label=4;case 4:return[2]}})})},function(t){return O(P,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return"404"!=t.status?[3,2]:(f=this.LoadM3ProcesoEmptyPDB(i,n,s,c,u,l,d),[4,r.AddToPouchBDCarritoCompras(p,f)]);case 1:return o.sent(),a(f,n),[3,3];case 2:console.log("Error no controlado"),console.log(t),e(),o.label=3;case 3:return[2]}})})})},o.prototype.addtocart=function(o,t,e,r,n,i,a,s,c,u,l){void 0===u&&(u=null),void 0===l&&(l=0);var d,f=c;if(d=t.LoM3PrdGeneral[0],0==f.M3ENC.length){if(f=this.LoadM3ProcesoEmptyPDB(t,o,n,a,s,c,u),!e)return f;e(f,o)}else{var p=this.validarExistaProducto(f.M3ENC,d,o);if(0!=p){if(o.dCantidad=+p+o.dCantidad,f.M3ENC=f.M3ENC.filter(function(o){return!(o.IdProducto==d.SKU&&o.Lote==d.LOTE&&!(0<o.IdEncPadre))}),this.RecalcularPrecios(f),f=this.LoadM3ProcesoFromData(f,t,o,a,s,n,u,l),!e)return f;e(f,o)}else{if(f=this.LoadM3ProcesoFromData(f,t,o,a,s,n,u,l),!e)return f;e(f,o)}}},o.prototype.validarExistaProducto=function(o,t,e){var r=this,n=null,i=0;return e.IDEncRepetido=-1,o!==undefined&&t!==undefined&&0<o.length&&(n=o.find(function(o){return o.IdProducto==t.SKU&&!o.IdEncPadre&&r.getCantidadPositiva(o)}))!==undefined&&null!=n&&(this.VerificarPrecioByNivelesGeneral(t,+n.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor),this.ValidarPreciosPrds(n,t.LoM3PrdLista)&&!this.ValidarEstaPaquete(n,o)&&(e.IDEncRepetido=n.ID,i=+n.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor)),i},o.prototype.getCantidadPositiva=function(o){var t=0,e=o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto});return e&&(t=+e.Valor),0<t},o.prototype.ValidarEstaPaquete=function(t,o){var e=!1;try{o.find(function(o){return o.IdEncPadre==t.ID})&&(e=!0)}catch(r){}return e},o.prototype.ValidarPreciosPrds=function(o,t){var e=!1;try{var r=+o.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor;t.PRECIO==r&&(e=!0)}catch(n){console.log("Error ValidarPreciosPrds"),console.log(n)}return e},o.prototype.UpdateM3ProcesosWithData=function(t,e,r,o,n,i,a,s,c){var u,l=this;void 0===s&&(s=null),void 0===c&&(c=null),this.RecalcularPrecios(t),"WEB"==n.toUpperCase()&&(u=e.GetKeyCarritoCompras(o,r.UsuarioSistema.TDOC,r.UsuarioSistema.NDOC,r.UsuarioSistema.UBICACION,r.UsuarioSistema.IDHUB),e.GetDataPouchBD(u).then(function(o){e.AddToPouchBDCarritoCompras(u,t),l.procesarPromoAfterCarritoOk(t,e,r,s,i,a,c)},function(o){"404"==o.status?(e.AddToPouchBDCarritoCompras(u,t),l.procesarPromoAfterCarritoOk(t,e,r,s,i,a,c)):(console.log("Error no controlado"),a())}))},o.prototype.procesarPromoAfterCarritoOk=function(t,e,o,r,n,i,a){if(r){var s;a?s=a:(s=new N).dCantidad=1;var c=e.GetKeyCarritoCompras(this.gsIdkatios,o.UsuarioSistema.TDOC,o.UsuarioSistema.NDOC,o.UsuarioSistema.UBICACION,o.UsuarioSistema.IDHUB);this.ProcPromoAfterAddToCart(t,o,s,r,!0).then(function(o){e.AddToPouchBDCarritoComprasAsync(c,t).then(function(o){n()})["catch"](function(o){n()})})["catch"](function(o){console.log(o),console.log("Error no controlado en procesarPromoAfterCarritoOk"),n()})}else n()},o.prototype.updateAPouch=function(t,e,o,r,n,i,a){var s;"WEB"==n.toUpperCase()&&(s=e.GetKeyCarritoCompras(r,o.UsuarioSistema.TDOC,o.UsuarioSistema.NDOC,o.UsuarioSistema.UBICACION,o.UsuarioSistema.IDHUB),e.GetDataPouchBD(s).then(function(o){e.AddToPouchBDCarritoCompras(s,t),i()},function(o){"404"==o.status?(e.AddToPouchBDCarritoCompras(s,t),i()):(console.log("Error no controlado"),a())}))},o.prototype.DeleteM3Proceso=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t=e.GetKeyCarritoCompras(n,r.UsuarioSistema.TDOC,r.UsuarioSistema.NDOC,r.UsuarioSistema.UBICACION,r.UsuarioSistema.IDHUB),[4,e.Delete(t)];case 1:return o.sent(),[2]}})})},o.prototype.DelDocsStartAndCurrent=function(o,t,e,r,n){if(e.IDDiarioCierre!==undefined&&null!=e.IDDiarioCierre){var i={UsuarioSistema:{TDOC:e.TDoc,NDOC:e.NDoc,UBICACION:e.Ubic1.toString(),IDHUB:e.IDHub}};this.DeleteM3Proceso(o,i,t).then(function(o){console.log("Delete start")}),i={UsuarioSistema:{TDOC:e.TDoc,NDOC:e.NDoc,UBICACION:r.toString(),IDHUB:n}},this.DeleteM3Proceso(o,i,t).then(function(o){console.log("Delete current")})}},o.prototype.GetCarritoComprasPouchDB=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t=e.GetKeyCarritoCompras(n,r.UsuarioSistema.TDOC,r.UsuarioSistema.NDOC,r.UsuarioSistema.UBICACION,r.UsuarioSistema.IDHUB),[4,e.GetDataPouchBD(t)];case 1:return[2,o.sent()]}})})},o.prototype.MoveCartIntoUser=function(n,i,a,s,c){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),t=i.GetKeyCarritoCompras(n,a.UsuarioSistema.TDOC,a.UsuarioSistema.NDOC,a.UsuarioSistema.UBICACION,a.UsuarioSistema.IDHUB),e=i.GetKeyCarritoCompras(n,s.UsuarioSistema.TDOC,s.UsuarioSistema.NDOC,s.UsuarioSistema.UBICACION,s.UsuarioSistema.IDHUB),[4,i.GetDataPouchBD(t)];case 1:return(r=o.sent()).TDoc=s.UsuarioSistema.TDOC,r.NDoc=s.UsuarioSistema.NDOC,delete r._rev,[4,i.AddToPouchBDCarritoCompras(e,r)];case 2:return o.sent(),c(),[3,4];case 3:return o.sent(),c(),[3,4];case 4:return[2]}})})},o.prototype.RecalcularPreciosPromoCombinada=function(o){this.RecalcularPrecios(o)},o.prototype.RecalcularPrecios=function(o){var e=this;o.M3ENC.forEach(function(o){var t=e.CalculatePrecioBase(o.M3DET.find(function(o){return"CTBLDIMPPRD"==o.NombreConcepto}).Valor,e.oMathTF.round(o.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor,2));0!=+ +o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor?o.M3DET.find(function(o){return"PRECIOUNITBASE"==o.NombreConcepto}).Valor=(+t/+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor).toString():o.M3DET.find(function(o){return"PRECIOUNITBASE"==o.NombreConcepto}).Valor="0",e.ValoresCalculadosProceso(o,+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor)}),this.recalcularM3Proceso(o)},o.prototype.CalcularPrecioBaseFromProceso=function(o,t){var e=1;try{o.M3PImpuestos.forEach(function(o){e=+e+ +o.Porcentaje})}catch(r){}return+t/+e},o.prototype.CreateM3NewProcesoEmpty=function(o,t,e,r,n,i,a){o.TMIdProceso=t,o.EstadoAnt="",o.SubEstadoAnt="",o.EstadoDes=n[0].E_Destino,o.SubEstadoDes=n[0].SE_Destino,o.M3FTrabajo.IdHub=+i,o.M3FTrabajo.IdUbic=+a,o.IDHub=+i,o.Ubic1=+a,o.TDoc=e,o.NDoc=r,o.TipoTercero=1,o.Ubic2=-1,o.M3FTrabajo.IdHubPre=-1,o.M3FTrabajo.IdUbicPre=-1},o.prototype.LoadM3ProcesoEmptyPDB=function(o,t,e,r,n,i,a){var s;return void 0===a&&(a=null),(s=null!=i?i:new w).Fecha=Z(new Date).format("YYYY-MM-DD"),s.TipoTercero=1,s.TDoc=e.UsuarioSistema.TDOC,s.NDoc=e.UsuarioSistema.NDOC,s.Ubic1=e.UsuarioSistema.UBICACION,s.Ubic2=-1,s.IDHub=e.UsuarioSistema.IDHUB,s.M3FTrabajo.IdHub=s.IDHub,s.M3FTrabajo.IdUbic=s.Ubic1,s.M3FTrabajo.IdHubPre=-1,s.M3FTrabajo.IdUbicPre=-1,""==s.SubEstadoDes&&null==i&&(s.SubEstadoDes="Registro",s.EstadoDes="Activo"),""!=t.SubEstado_o&&""!=t.Estado_o&&(s.SubEstadoDes=t.SubEstado_o,s.EstadoDes=t.Estado_o),""==t.IdProceso&&null==i?s.TMIdProceso="M3ECC":""!=t.IdProceso&&(s.TMIdProceso=t.IdProceso),this.LoadM3PEncItemsFromPrdGrl(s,o,s.M3ENC,t,r,n,e,null,0,a),s},o.prototype.LoadAdicionales=function(o,t){try{o.ClavePrdSRV=t.LoM3PrdAdicionales.find(function(o){return"CLAVEPRODSERV"==o.ATRIBUTO}).VALOR,o.ClavePrdUnidad=t.LoM3PrdAdicionales.find(function(o){return"CLAVEUNIDAD"==o.ATRIBUTO}).VALOR,o.Unidad=t.LoM3PrdAdicionales.find(function(o){return"UNIDAD"==o.ATRIBUTO}).VALOR}catch(e){}return o},o.prototype.LoadM3ProcesoFromData=function(o,t,e,r,n,i,a,s){return void 0===a&&(a=null),void 0===s&&(s=0),o.Fecha=Z(new Date).format("YYYY-MM-DD"),""==o.TMIdProceso&&""!=e.IdProceso&&(o.TMIdProceso=e.IdProceso),this.LoadM3PEncItemsFromPrdGrl(o,t,o.M3ENC,e,r,n,i,null,s,a),o},o.prototype.LoadM3PEncItemsFromPrdGrl=function(o,t,e,r,n,i,a,s,c,u){void 0===c&&(c=0),void 0===u&&(u=null);var l=t.LoM3PrdAdicionales.find(function(o){return"VENTANEG"==o.ATRIBUTO});o.InventarioError&&delete o.InventarioError,!("M3ECC"==o.TMIdProceso.toUpperCase()&&t.LoM3PrdGeneral[0].DISPONIBLE<r.dCantidad&&"WEB"==n.M3HUBS[0].Tipo)||l&&l.VALOR||(o.InventarioError="No hay inventario para agregar "+r.dCantidad+" Items",r.dCantidad=t.LoM3PrdGeneral[0].DISPONIBLE);var d=new V;if(o.Fecha=Z(new Date).format("YYYY-MM-DD"),d=this.LoadM3PEncItemsFromPrdGrlItem(o,t,o.M3ENC,r,n,i,a,s,c),o.MensajeError&&delete o.MensajeError,s&&(d.IdEncPadre=s.ID),d.MensajeError)o.MensajeError=d.MensajeError;else{var f;if((f=t.LoM3PrdGeneral[0].M3PACK)&&0<f.length)for(var p=0;p<f.length;p++){var h,P=f[p];P.oM3PItemsWEB?h=P.oM3PItemsWEB:(h=Object.assign({},r)).dCantidad=P.Cantidad,h.PathImagen=P.gsPathImagen,h.dCantidad=h.dCantidad*r.dCantidad,h.IDEncRepetido=+this.GetMaxAtributoFromLista(o.M3ENC,"ID")+p+2,P.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=0;try{var M=P.M3GRP.LoM3PrdGeneral[0].M3Cods.find(function(o){return"UPC"==o.IdCodigo});M&&M.Valor&&(h.CodigoBarras=M.Valor)}catch(m){console.warn("no añadi codigo de barras a producto hijo: "+P.SKUHIJO)}this.LoadM3PEncItemsFromPrdGrl(o,P.M3GRP,o.M3ENC,h,n,i,a,d,0,u)}-1!=r.IDEncRepetido&&(d.ID=r.IDEncRepetido),-1!=r.IDEncPadre&&(d.IdEncPadre=r.IDEncPadre,d.TipoAgrupacion=r.TipoAgrupacion),u&&0<u.length&&u.forEach(function(o){d.M3PDinamByActividad.push(C({},o))}),o.M3ENC.push(d)}r.IDEncProcesado=d.ID},o.prototype.calcularPorcentajeDescuentoCombo=function(o){var e=this,t=0,r=0,n=o.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO;return o.LoM3PrdGeneral[0].M3PACK.forEach(function(o){var t=o.M3GRP.Cantidad?o.M3GRP.Cantidad:1;e.VerificarPrecioByNiveles(o.M3GRP,t);console.debug(o.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.IDLISTA),console.debug(o.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO),r+=o.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO*t}),n<r&&(t=100-100*n/r),console.debug(t),t},o.prototype.CalcularPreciosPCKG=function(o){o.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=0},o.prototype.loadM3PEncItemsFromPromocionCombo=function(t,o,e,r,n){var i=this,a=new V;return a.IdProducto=e,a.Lote="1",a.ID=+this.GetMaxAtributoFromLista(t.M3ENC,"ID")+1,a.Orden=+this.GetMaxAtributoFromLista(t.M3ENC,"Orden")+1,a.Nombre="Combo - "+o.map(function(o){return o.IdProducto}).join("-"),a.M3DET.push(this.LoadM3PDetalle(Z(new Date).format("YYYY-MM-DDTHH:mm:ss"),"FECHAIN")),a.M3DET.push(this.LoadM3PDetalle("true","ESPRODPROMOCOMBO")),a.M3DET.push(this.LoadM3PDetalle("true","ESPRODPROMO")),a.M3DET.push(this.LoadM3PDetalle("ENCPROMO","TIPO_PRD")),a.M3DET.push(this.LoadM3PDetalle(r,"PRECIOUNITBASE")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALIMPUESTOS")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALIMPUNIT")),a.M3DET.push(this.LoadM3PDetalle(r,"PUNITSINIMPUESTO")),a.M3DET.push(this.LoadM3PDetalle(r,"PUNIT")),a.M3DET.push(this.LoadM3PDetalle(r,"PUNITNETO")),a.M3DET.push(this.LoadM3PDetalle("0","VUNITPROMO")),a.M3DET.push(this.LoadM3PDetalle("0","UNITFIDEL")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALIMPUNIT")),a.M3DET.push(this.LoadM3PDetalle(n.toString(),"CANTIDAD")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALIMPUESTOS")),a.M3DET.push(this.LoadM3PDetalle("0","FIDELIZACION")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALPROMO")),a.M3DET.push(this.LoadM3PDetalle(r,"CTBLDIMPPRD")),a.M3DET.push(this.LoadM3PDetalle((+r*n).toString(),"PRECIOTOTALSINDTO")),a.M3DET.push(this.LoadM3PDetalle((+r*n).toString(),"SUBTOTAL")),a.M3DET.push(this.LoadM3PDetalle((+r*n).toString(),"PRECIOTOTALBASE")),a.M3DET.push(this.LoadM3PDetalle((+r*n).toString(),"PRECIOTOTAL")),t.M3ENC.push(a),o.forEach(function(o){o.ID=+i.GetMaxAtributoFromLista(t.M3ENC,"ID")+1,o.IdEncPadre=a.ID,t.M3ENC.push(o)}),this.recalcularM3Proceso(t),a},o.prototype.recalcularM3Proceso=function(o){var t,e,r=o.M3ENC.filter(function(o){var t=o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}),e=o.M3DET.find(function(o){return"ESPRODPROMOCOMBO"==o.NombreConcepto});return t&&0<+t.Valor&&!(e&&"true"==e.Valor)});o.ValorNeto=0,o.Valor=0;try{for(var n=v(r),i=n.next();!i.done;i=n.next()){var a=i.value;o.ValorNeto+=+a.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor,o.Valor+=+a.M3DET.find(function(o){return"SUBTOTAL"==o.NombreConcepto}).Valor}}catch(s){t={error:s}}finally{try{i&&!i.done&&(e=n["return"])&&e.call(n)}finally{if(t)throw t.error}}},o.prototype.LoadM3PEncItemsFromPrdGrlItem=function(o,t,e,r,n,i,a,s,c){void 0===s&&(s=undefined),void 0===c&&(c=0);var u,l,d,f=new V,p=0,h=0,P=0,M=0;if(l=this.VerificarPrecioByNiveles(t,r.dCantidad),0<c?((d=new k).PrecioTotalPromocion=t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO*c/100,d.PrecioTotal=t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO-d.PrecioTotalPromocion,d.ListPromocionesAsociadas=[]):d=this.CalcularPromociones(o,t,n,i,a,r),this.validarProductoRestringido(d))f.MensajeError="Producto Restringido";else{if(this.AsignarPromocionesCombinadas(o,d,f),P=d.ValorTotalMonedero,d.ValorTotalMonedero=+oo.multiply(d.ValorTotalMonedero,r.dCantidad),M=d.PrecioTotalPromocion,d.PrecioTotalPromocion=+oo.multiply(d.PrecioTotalPromocion,r.dCantidad),f.M3DetCupones=this.get_list_cupones_from_promo(d,+r.dCantidad),r.dPrecioTotal=+oo.multiply(d.PrecioTotal,r.dCantidad),u=t.LoM3PrdGeneral[0],f.IdProducto=u.SKU,f.Lote=u.LOTE,f.ID=+this.GetMaxAtributoFromLista(e,"ID")+1,f.Orden=+this.GetMaxAtributoFromLista(e,"Orden")+1,f.Nombre=u.NOMBRE1,f.DISPONIBLE=u.DISPONIBLE,f.PathImage=r.PathImagen,f.CodigoBarras=r.CodigoBarras,n&&n.M3UbiAdicionales){var m=n.M3UbiAdicionales.find(function(o){return"IMPFIJO"==o.Atributo});m&&""!=m.Valor&&(u.CTBLDIMPPRD=m.Valor)}var C=this.CalculatePrecioBase(u.CTBLDIMPPRD,this.oMathTF.round(oo.multiply(d.PrecioTotal,r.dCantidad),2));if(p=0!=r.dCantidad?C/r.dCantidad:0,h=this.LoadM3PImpuestosFromPrdGrl(u.CTBLDIMPPRD,f,C,r.dCantidad,d.PrecioTotal),f.M3DET.push(this.LoadM3PDetalle(Z(new Date).format("YYYY-MM-DDTHH:mm:ss"),"FECHAIN")),f.M3DET.push(this.LoadM3PDetalle(u.CTBLDPRD,"CTBLDPRD")),f.M3DET.push(this.LoadM3PDetalle(r.BisObsequio.toString(),"ESOBSEQUIO")),f.M3DET.push(this.LoadM3PDetalle(u.SKP1,"PRD_ESTILO")),f.M3DET.push(this.LoadM3PDetalle(u.CTBLDIMPPRD,"CTBLDIMPPRD")),f.M3DET.push(this.LoadM3PDetalle(r.observacion.toString(),"OBSERVACION")),r.PathImagen&&f.M3DET.push(this.LoadM3PDetalle(r.PathImagen,"PATHIMAGEN")),f.M3DET.push(this.LoadM3PDetalle(r.BisProductoPromo.toString(),"ESPRODPROMO")),f.M3DET.push(this.LoadM3PDetalle(t.TIPO,"TIPO_PRD")),f.M3DET.push(this.LoadM3PDetalle(r.Unidad,"UNIDAD")),f.M3DET.push(this.LoadM3PDetalle(r.ClavePrdSRV,"CLAVEPRODSERV")),f.M3DET.push(this.LoadM3PDetalle(r.ClavePrdUnidad,"CLAVEUNIDAD")),this.AddItemsInterfaz(f,t.LoM3PrdAdicionales),this.AdicionalesToDetalles(f,t.LoM3PrdAdicionales),this.camposAdicionalesToDetalles(f,r),this.LoadDetalleNivelesPrecio(l,f),this.AddInfoPromocionesADetalle(d,f,r.dCantidad),f.M3DET.push(this.LoadM3PDetalle(p.toString(),"PRECIOUNITBASE")),f.M3DET.push(this.LoadM3PDetalle(h.toString(),"TOTALIMPUESTOS")),f.M3DET.push(this.LoadM3PDetalle(this.oMathTF.round(this.GetUnitarioByTotal(r.dCantidad,f,"TOTALIMPUESTOS"),2).toString(),"TOTALIMPUNIT")),f.M3DET.push(this.LoadM3PDetalle((+p+ +M).toString(),"PUNITSINIMPUESTO")),f.M3DET.push(this.LoadM3PDetalle(u.LoM3PrdLista.PRECIO.toString(),"PUNIT")),f.M3DET.push(this.LoadM3PDetalle(d.PrecioTotal.toString(),"PUNITNETO")),f.M3DET.push(this.LoadM3PDetalle(P.toString(),"UNITFIDEL")),f.M3DET.push(this.LoadM3PDetalle(M.toString(),"VUNITPROMO")),"CTN"==this.gsIdkatios)t.LoM3PrdGeneral[0].LoM3ListaPrecio.find(function(o){return"2"==o.IDLISTA})&&f.M3DET.push(this.LoadM3PDetalle(t.LoM3PrdGeneral[0].LoM3ListaPrecio.find(function(o){return"2"==o.IDLISTA}).PRECIO.toString(),"PRECIOSR"));t.encontradoLocal?f.M3DET.push(this.LoadM3PDetalle("LOCAL","CONSULTOEN")):f.M3DET.push(this.LoadM3PDetalle("SERVIDOR","CONSULTOEN")),this.ValoresCalculadosProceso(f,r.dCantidad),o.Valor=+o.Valor+ +f.M3DET.find(function(o){return"SUBTOTAL"==o.NombreConcepto}).Valor,o.ValorNeto=+o.ValorNeto+ +f.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor,this.VerificarObsequios(d,r.dCantidad,f),this.turnOnPromos(d)}return f},o.prototype.validarProductoRestringido=function(o){if(o.ListPromocionesAsociadas&&o.ListPromocionesAsociadas.find(function(o){return"RESTRICCION"==o.Tipo}))return!0;return!1},o.prototype.GetMaxAtributoFromLista=function(o,t){if(0<o.length){var e=o.map(function(o){return o[t]});return Math.max.apply(Math,e)}return 0},o.prototype.ValoresCalculadosProceso=function(o,t){var e,r=0,n=0;e=this.agregarImpuesto(o,t),0<o.M3PImpuestos.length?n=(r=this.oMathTF.round(this.oMathTF.round(+this.GetTotalByUnitario(t,o,"PRECIOUNITBASE"),2)+ +this.GetTotalByUnitario(t,o,"VUNITPROMO"),2))+(e=this.getValorTotalFromImpuestos(o,"Valor")):r=n=this.oMathTF.round(this.GetTotalByUnitario(t,o,"PUNIT"),2),this.InsUpdDetItem(o,t.toString(),"CANTIDAD"),this.InsUpdDetItem(o,this.oMathTF.round(e,2).toString(),"TOTALIMPUESTOS"),this.InsUpdDetItem(o,this.oMathTF.round(+this.GetUnitarioByTotal(t,o,"TOTALIMPUESTOS"),2).toString(),"TOTALIMPUNIT"),this.InsUpdDetItem(o,o.M3DET.find(function(o){return"UNITFIDEL"==o.NombreConcepto}).Valor,"FIDELIZACION"),this.InsUpdDetItem(o,n.toString(),"PRECIOTOTALSINDTO"),this.InsUpdDetItem(o,r.toString(),"SUBTOTAL"),this.InsUpdDetItem(o,Z(new Date).format("YYYY-MM-DD"),"FUT"),this.InsUpdDetItem(o,this.oMathTF.round(+this.GetTotalByUnitario(t,o,"VUNITPROMO"),2).toString(),"TOTALPROMO"),this.InsUpdDetItem(o,this.oMathTF.round(+this.GetTotalByUnitario(t,o,"PRECIOUNITBASE"),2).toString(),"PRECIOTOTALBASE"),this.InsUpdDetItem(o,this.oMathTF.round(r+ +o.M3DET.find(function(o){return"TOTALIMPUESTOS"==o.NombreConcepto}).Valor-+o.M3DET.find(function(o){return"TOTALPROMO"==o.NombreConcepto}).Valor,2).toString(),"PRECIOTOTAL"),0<o.M3PImpuestos.length&&0==t&&(o.M3PImpuestos=[])},o.prototype.getValorTotalFromImpuestos=function(o,t){for(var e=0,r=0;r<o.M3PImpuestos.length;r++){e+=+o.M3PImpuestos[r][t]}return this.oMathTF.round(e,2)},o.prototype.agregarImpuesto=function(o,t){var e=o.M3DET.find(function(o){return"CTBLDIMPPRD"==o.NombreConcepto}),r=o.M3DET.find(function(o){return"PRECIOUNITBASE"==o.NombreConcepto}),n=0;return e&&r&&(n=this.LoadM3PImpuestosFromPrdGrl(e.Valor,o,+oo.multiply(r.Valor,t),t,+o.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor)),this.oMathTF.round(n,2)},o.prototype.InsUpdDetItem=function(o,t,e){var r;(r=o.M3DET.find(function(o){return o.NombreConcepto==e}))?r.Valor=t:o.M3DET.push(this.LoadM3PDetalle(t.toString(),e))},o.prototype.GetTotalByUnitario=function(o,t,e){try{var r=t.M3DET.find(function(o){return o.NombreConcepto==e}).Valor;return+oo.multiply(r,o)}catch(n){return 0}},o.prototype.GetUnitarioByTotal=function(o,t,e){try{return 0==+o?0:+t.M3DET.find(function(o){return o.NombreConcepto==e}).Valor/+o}catch(r){return 0}},o.prototype.AddItemsInterfaz=function(o,t){try{var e;e=t.filter(function(o){return o.ATRIBUTO.startsWith("CSIA_")});for(var r=0;r<e.length;r++)o.M3DET.push(this.LoadM3PDetalle(e[r].VALOR,e[r].ATRIBUTO))}catch(n){}},o.prototype.AdicionalesToDetalles=function(o,t){try{for(var e=0;e<t.length;e++)o.M3DET.push(this.LoadM3PDetalle(t[e].VALOR,"ADC_"+t[e].ATRIBUTO))}catch(r){}},o.prototype.camposAdicionalesToDetalles=function(o,t){try{for(var e=0;e<t.CamposAdicionales.length;e++)o.M3DET.push(this.LoadM3PDetalle(t.CamposAdicionales[e].VALOR,"CAMADC_"+t.CamposAdicionales[e].ATRIBUTO))}catch(r){}},o.prototype.GenerarInfoPromocionesProcesadas=function(o,t,e){void 0===e&&(e=!0);var r="",n="",i="";return o&&o.ListPromocionesAsociadas&&0<o.ListPromocionesAsociadas.length?(e?o.ListPromocionesAsociadas.filter(function(o){return o.Aplicada}).filter(function(o){return null==o.PromocionCombinada}).forEach(function(o){r=r+o.Nombre+",",n=n+o.IDPromocion+",",i=i+oo.multiply(o.Valor,t)+","}):o.ListPromocionesAsociadas.filter(function(o){return!o.Aplicada}).filter(function(o){return null==o.PromocionCombinada}).forEach(function(o){r=r+o.Nombre+",",n=n+o.IDPromocion+",",i=i+oo.multiply(o.Valor,t)+","}),{NOMBRES:r,ID:n,VALORES:i}):null},o.prototype.AddInfoPromocionesADetalle=function(o,t,e){var r=this.GenerarInfoPromocionesProcesadas(o,e);if(r){t.M3DET.push(this.LoadM3PDetalle(r.NOMBRES,"NOMB_PROMOC")),t.M3DET.push(this.LoadM3PDetalle(r.ID,"ID_PROMOC")),t.M3DET.push(this.LoadM3PDetalle(r.VALORES,"VAL_PROMOC"));for(var n=r.NOMBRES.replace(/.$/,"").split(","),i=r.ID.replace(/.$/,"").split(","),a=r.VALORES.replace(/.$/,"").split(","),s=0;s<i.length;s++)t.M3DET.push(this.LoadM3PDetalle(n[s],"NOMB_PROMOC_"+s)),t.M3DET.push(this.LoadM3PDetalle(i[s],"ID_PROMOC_"+s)),t.M3DET.push(this.LoadM3PDetalle(a[s],"VAL_PROMOC_"+s))}(r=this.GenerarInfoPromocionesProcesadas(o,e,!1))&&(t.M3DET.push(this.LoadM3PDetalle(r.NOMBRES,"NOMB_PROMOC_NOPRO")),t.M3DET.push(this.LoadM3PDetalle(r.ID,"ID_PROMOC_NOPRO")),t.M3DET.push(this.LoadM3PDetalle(r.VALORES,"VAL_PROMOC_NOPRO")))},o.prototype.LoadDetalleNivelesPrecio=function(o,t){o&&o.NIVEL!==undefined&&t.M3DET.push(this.LoadM3PDetalle(o.NIVEL,"NIVELPRECIO"))},o.prototype.VerificarPrecioByNiveles=function(o,t){try{var e,r={};return o.LoM3PrdGeneral[0].LoM3PrdLista.M3Presentaciones&&0<o.LoM3PrdGeneral[0].LoM3PrdLista.M3Presentaciones.length&&(e=o.LoM3PrdGeneral[0].LoM3PrdLista.M3Presentaciones.find(function(o){return t>=o.TOPE}))&&(o.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=e.VALOR,r={PRECIO:e.VALOR,NIVEL:e.NIVELPRS}),r}catch(n){return null}},o.prototype.VerificarPrecioByNivelesGeneral=function(o,t){try{var e,r={};return o.LoM3PrdLista.M3Presentaciones&&0<o.LoM3PrdLista.M3Presentaciones.length&&(e=o.LoM3PrdLista.M3Presentaciones.find(function(o){return t>=o.TOPE}))&&(o.LoM3PrdLista.PRECIO=e.VALOR,r={PRECIO:e.VALOR,NIVEL:e.NIVELPRS}),r}catch(n){return null}},o.prototype.get_list_cupones_from_promo=function(o,t){var e=Array();if(o.ListPromocionesAsociadas)for(var r=0;r<o.ListPromocionesAsociadas.length;r++){var n=o.ListPromocionesAsociadas[r];if(n.IdCupon){var i=new L;i.IdCupon=n.IdCupon,i.Cantidad=t,e.push(i)}}return e},o.prototype.AsignarPromocionesCombinadas=function(e,o,r){var n=this;null!=o&&null!=o.ListPromocionesAsociadas&&o.ListPromocionesAsociadas.forEach(function(o){var t;null!=o.PromocionCombinada&&(r.PromoCombinadas.push(o.PromocionCombinada),(t=r.M3DET.find(function(o){return"PROMOCOMBI"==o.NombreConcepto}))?t.Valor=JSON.stringify(r.PromoCombinadas):r.M3DET.push(n.LoadM3PDetalle(JSON.stringify(r.PromoCombinadas),"PROMOCOMBI")),n.AsignarPromocionesCombinadasAM3Proceso(e,o.PromocionCombinada))})},o.prototype.AsignarPromocionesCombinadasAM3Proceso=function(o,t){o.PromosCombinadas||(o.PromosCombinadas=new Array),o.PromosCombinadas.find(function(o){return o.IdPromocionCombinada==t.IdPromocionCombinada})||o.PromosCombinadas.push(t),o.PromosCombinadas&&this.AddDinamicaProcesoCombinadas(o)},o.prototype.AddDinamicaProcesoCombinadas=function(o){var t;if(t=o.lM3PDinamicas.find(function(o){return"COMBINADA"==o.Nombre})){for(var e=JSON.parse(t.Valor),r=0;r<e.length;r++){o.PromosCombinadas.find(function(o){return o.IdPromocionCombinada==e[r].IdPromocionCombinada})||o.PromosCombinadas.push(e[r])}t.Valor=JSON.stringify(o.PromosCombinadas)}else{var n=new R;n.Nombre="COMBINADA",n.Valor=JSON.stringify(o.PromosCombinadas),o.lM3PDinamicas.push(n)}},o.prototype.CalcularPromociones=function(o,t,e,r,n,i){var a=new k,s=new Array;s.push("DIRECTA"),s.push("COMBINADA"),s.push("MONEDERO"),s.push("MANUAL");try{if(null==r)throw new Error("No hay informacion de promociones");var c,u=new X(n,i);return c=u.VerificarPromociones(o,t,e,r,s),a=u.ProcesarPromocion(c,t,r,this.gsIdkatios)}catch(l){return(a=new k).PrecioTotal=t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO,a.PrecioTotalPromocion=0,a.ListPromocionesAsociadas=null,a}},o.prototype.VerificarObsequios=function(t,e,r){var n=this;try{var o;this.obsequiosCantidad=0,null!=t.ListPromocionesAsociadas&&null!=(o=t.ListPromocionesAsociadas.filter(function(o){return null!=o.ListObsSKU}))&&0<o.length&&o.forEach(function(o){n.obsequioOPromo,o.ListObsSKU.length||(o.ListObsSKU=[o.ListObsSKU]),n.validaSiTieneOtraPromo(o,t.ListPromocionesAsociadas)&&(n.obsequioOPromo=o.IDPromocion),n.armarListaObsequiosSKU(o,r,e)})}catch(i){console.log(i)}},o.prototype.turnOnPromos=function(o){var t=this;try{var e;null!=o.ListPromocionesAsociadas&&(e=o.ListPromocionesAsociadas.filter(function(o){return o.lIdActivaPromo&&0<o.lIdActivaPromo.length}))&&0<e.length&&(e.forEach(function(o){t.lIdActivaPromo=t.lIdActivaPromo.concat(o.lIdActivaPromo)}),this.removeDuplicates(this.lIdActivaPromo))}catch(r){console.log(r)}},o.prototype.removeDuplicates=function(o){for(var t=[],e=0;e<o.length;e++)-1===t.indexOf(o[e])&&t.push(o[e])},o.prototype.armarListaObsequiosSKU=function(o,t,e){var r=Math.floor(e/o.CantidadObseq);"EXC"==o.ReglaObseq?(this.asignarIdEncPadreObsequio(o,t),this.obsequiosExc=!0,this.obsequiosCantidad=r):(this.asignarIdEncPadreObsequio(o,t),o.ListObsSKU.forEach(function(o){o.Cantidad=r*+o.Cantidad}),this.obsequiosExc=!1),this.oListaObsequios=o.ListObsSKU},o.prototype.asignarIdEncPadreObsequio=function(o,t){0<o.ListObsSKU.length&&o.ListObsSKU.forEach(function(o){o.idEncPadre=t.ID})},o.prototype.armarListaObsequiosCombiSKU=function(o,t,e){"EXC"==o.Accion.ReglaObseq?(this.asignarIdEncPadreObsequioCombinado(o.Accion.OBSEQUIOS,t),this.obsequiosExc=!0,this.obsequiosCantidad=e):(this.asignarIdEncPadreObsequioCombinado(o.Accion.OBSEQUIOS,t),o.Accion.OBSEQUIOS.forEach(function(o){o.Cantidad=e*+o.Cantidad}),this.obsequiosExc=!1),this.oListaObsequios=o.Accion.OBSEQUIOS},o.prototype.asignarIdEncPadreObsequioCombinado=function(o,t){0<o.length&&o.forEach(function(o){o.idEncPadre=t.ID})},o.prototype.validaSiTieneOtraPromo=function(t,o){var e,r;if("ACM"!=t.Regla){var n=o.filter(function(o){return o.IDPromocion!=t.IDPromocion});try{for(var i=v(n),a=i.next();!a.done;a=i.next()){var s=a.value;if("ACM"!=s.Regla&&s.Aplicada&&("EXC"==s.Regla||"EXC"==t.Regla))return!0}}catch(c){e={error:c}}finally{try{a&&!a.done&&(r=i["return"])&&r.call(i)}finally{if(e)throw e.error}}}return!1},o.prototype.ProcesarObsequios=function(r,n,i,a,s){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:if(o.trys.push([0,5,,6]),this.obsequiosExc=!1,this.obsequioOPromo=-1,!(null!=this.oListaObsequios&&0<this.oListaObsequios.length))return[3,4];t=0,o.label=1;case 1:return t<this.oListaObsequios.length?this.oListaObsequios[t].SKU?(this.oListaObsequios[t].Cantidad&&(n.dCantidad=this.oListaObsequios[t].Cantidad),n.BisObsequio=!0,n.IDEncPadre=this.oListaObsequios[t].idEncPadre,n.TipoAgrupacion="OBSQ",[4,this.GuardarPromocion(this.oListaObsequios[t],r,n,i,a,s)]):[3,3]:[3,4];case 2:o.sent(),o.label=3;case 3:return t++,[3,1];case 4:return[3,6];case 5:return e=o.sent(),console.log(e),[3,6];case 6:return this.oListaObsequios=null,[2]}})})},o.prototype.GuardarPromocion=function(t,e,r,n,i,a){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.AdicionarPromocionAProceso(t,a,r,n,i,e)];case 1:return o.sent(),[2]}})})},o.prototype.AdicionarPromocionAProceso=function(e,r,n,i,a,s){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t=null,[4,this.GetProductoBySKU(e.SKU,a,r,s)];case 1:return t=o.sent(),console.debug(t),null!=t&&(r=this.addtocart(n,t,null,null,s,this.gsIdkatios,i,null,r,null,100)),[2,r]}})})},o.prototype.GetProductoBySKU=function(a,s,c,u,l){return void 0===l&&(l=null),O(this,void 0,void 0,function(){var t,e,r,n,i;return S(this,function(o){switch(o.label){case 0:return t=new $,r=null,n=new Q(this.gsIdkatios),s||u.UsuarioSistema.FechaPrecio?[3,2]:(i=this.gsIdkatios+"?PRD",[4,this.oM3CouchMaestro.get(i)]);case 1:return e=o.sent(),r=t.GetM3PrdGrpFromList(e.M3ListProductos.M3GRP,a),[3,4];case 2:return[4,t.M3GetProductoBySKUAsync(this.GoPostServiceM3,this.gsIdkatios,a,u,c.Ubic1.toString())];case 3:r=o.sent(),o.label=4;case 4:return r.LoM3PrdGeneral[0].DISPONIBLE<=0&&l&&(r.LoM3PrdGeneral[0].DISPONIBLE=l),[4,n.AsignarListaPrecio(r,u,this.GoPostServiceM3)];case 5:return o.sent(),[2,r]}})})},o.prototype.CalculatePrecioBase=function(o,t){var e=t;try{var r=new m;""!=o&&r.convertXmlToJson(o).IMPUESTOS.IMPUESTO.forEach(function(o){e="PORCENTAJE"==o.$.Metodologia?+e/(+o.$.Valor+1):+e-+o.$.Valor})}catch(n){console.log("Catch")}return e},o.prototype.LoadM3PImpuestosFromPrdGrl=function(o,t,e,r,n){try{var i,a,s=new m,c=this.oMathTF.round(e,4),u=c,l=+oo.multiply(n,r),d=0;if(""!=o)for(var f=(a=s.convertXmlToJson(o)).IMPUESTOS.IMPUESTO.length-1;0<=f;f--){var p=0,h=a.IMPUESTOS.IMPUESTO[f];(i=new A).CodImpuesto=h.$.CodImp,i.Porcentaje=h.$.Valor,"PORCENTAJE"==h.$.Metodologia?(p=+oo.multiply(h.$.Valor,u),i.Valor=this.oMathTF.round(p,2),i.Valor<p?i.LimiteOpuesto=+Math.ceil(+oo.multiply(p,100))/100:i.LimiteOpuesto=+Math.floor(+oo.multiply(p,100))/100):(p=+h.$.Valor,i.Valor=this.oMathTF.round(p,2)),i.Base=this.oMathTF.round(u,2),d=this.oMathTF.round(+d,2)+this.oMathTF.round(+i.Valor,2),u=this.oMathTF.round(+this.oMathTF.round(u,2)+this.oMathTF.round(+i.Valor,2),2),t.M3PImpuestos.find(function(o){return o.CodImpuesto==i.CodImpuesto})&&(t.M3PImpuestos=t.M3PImpuestos.filter(function(o){return o.CodImpuesto!=i.CodImpuesto})),t.M3PImpuestos.push(i)}if(0==d)return 0;d=this.oMathTF.round(d,2);var P=this.oMathTF.round(+l-+this.oMathTF.round(c,2)-+d,2);return isNaN(P)&&(P=this.oMathTF.round(+(+l-+this.oMathTF.round(c,2)-+d).toFixed(4),2)),0!=P&&this.ajustadorDeImpuestos(t,P),this.oMathTF.round(l-this.oMathTF.round(c,2),2)}catch(M){return console.log("Catch"),0}},o.prototype.ajustadorDeImpuestos=function(o,t){for(var e=0;e<o.M3PImpuestos.length;e++){var r=o.M3PImpuestos[e];if(0<t?r.Valor<r.LimiteOpuesto&&(r.Valor=r.LimiteOpuesto,r.Base=this.oMathTF.round(r.Valor/r.Porcentaje,2),t-=.01):r.Valor>r.LimiteOpuesto&&(r.Valor=r.LimiteOpuesto,r.Base=this.oMathTF.round(r.Valor/r.Porcentaje,2),t+=.01),0==t)break}},o.prototype.LoadM3PDetalle=function(o,t){var e=new T;return e.NombreConcepto=t,e.Valor=o,e},o.prototype.GenerarPromoCombinada=function(e,r){return O(this,void 0,void 0,function(){var t;return S(this,function(o){return(!e.lM3PDinamicas||e.lM3PDinamicas&&!e.lM3PDinamicas.find(function(o){return"PUENTE_DIARIO"==o.Nombre}))&&(t=new X(r,null),e=t.ProcesarCombinada(e),this.RecalcularPrecios(e)),[2]})})},o.prototype.CompareM3Proceso=function(c,u,l,d){return O(this,void 0,void 0,function(){var t,e,r,n,i,a,s;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=["ValorNeto","Valor"],n=!0,e=u.GetKeyCarritoCompras(c,l.UsuarioSistema.TDOC,l.UsuarioSistema.NDOC,l.UsuarioSistema.UBICACION,l.UsuarioSistema.IDHUB),[4,u.GetDataPouchBD(e)];case 1:for(r=o.sent(),i=0;i<t.length;i++)if(d[t[i]]!=r[t[i]]){n=!1;break}if(n)for(a=0;a<d.M3ENC.length;a++)if(r.M3ENC[a].ID!=d.M3ENC[a].ID||r.M3ENC[a].IdProducto!=d.M3ENC[a].IdProducto||r.M3ENC[a].M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor!=d.M3ENC[a].M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor){n=!1;break}return[2,{bResp:n,M3Procesos:r}];case 2:return s=o.sent(),console.log("Error CompareM3Proceso"),console.log(s),[2,{bResp:!0,M3Procesos:null}];case 3:return[2]}})})},o.prototype.AddComercialToM3Proceso=function(o,t,e){o.lM3PDinamicas.push(this.CreateTuplaDinamica("TCOMERCIAL",t)),o.lM3PDinamicas.push(this.CreateTuplaDinamica("NCOMERCIAL",e))},o.prototype.CreateTuplaDinamica=function(o,t){var e=new R;return e.Nombre=o,e.Valor=t,e},o.prototype.setCantidadALLYUPDCouch=function(t,e,r,n,i,o,a){var s=this;0==a&&t.IDDiario===undefined?(t.M3ENC=new Array,this.UpdateM3ProcesosWithData(t,e,r,n,"WEB",i,o)):0==a?this.DeleteM3Proceso(e,r,n).then(function(o){s.GetCarritoComprasPouchDB(e,r,n).then(function(o){t=new w,i(t)})}):(t.M3ENC.forEach(function(o){o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor=a}),this.UpdateM3ProcesosWithData(t,e,r,n,"WEB",i,o))},o.prototype.setCantidadYUPDCouch=function(t,e,r,n,i,a,s,c,u,l,d,f,o,p){var h=this;(void 0===p&&(p=!1),0==u&&t.IDDiario===undefined&&"WEB"==l||p)?(t.M3ENC=t.M3ENC.filter(function(o){return!(o.IdProducto==s&&o.ID==d||o.IdEncPadre==d)}),(new N).dCantidad=0,this.UpdateM3ProcesosWithData(t,e,r,n,l,i,a,f)):0==u?(t.M3ENC.filter(function(o){return o.IdProducto==s&&o.Lote==c&&o.ID==d||o.IdEncPadre==d}).forEach(function(o){o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor=u}),this.UpdateM3ProcesosWithData(t,e,r,n,l,i,a,f)):this.setCantidadV2(t,s,c,u,d,r,n,f,o).then(function(o){h.UpdateM3ProcesosWithData(t,e,r,n,l,i,a,f,o.M3PItemsWEB)})},o.prototype.setCantidadV2=function(n,i,a,s,c,u,l,d,f){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return t=null,(e=new N).dCantidad=s,(r=n.M3ENC.find(function(o){return o.IdProducto==i&&o.Lote==a&&o.ID==c}))&&(e.PathImagen=r.PathImage),n.M3ENC=n.M3ENC.filter(function(o){return!(o.IdProducto==i&&o.Lote==a&&(o.ID==c||o.IdEncPadre==c))}),[4,this.GetProductoBySKU(i,!0,n,u,r.DISPONIBLE)];case 1:return t=o.sent(),e=this.LoadAdicionales(e,t),[2,{M3Proceso:n=this.addtocart(e,t,null,null,u,l,d,f,n),M3PItemsWEB:e}]}})})},o.prototype.get_M3ENC_by_idprd_lote=function(o,t,e){return o.M3ENC.find(function(o){return o.IdProducto==t&&o.Lote==e})},o.prototype.getCantidad=function(o,t){return o.M3ENC.find(function(o){return o.IdProducto==t.SKU&&o.Lote==t.LOTE}).M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},o.prototype.getCantidadTotal=function(o){if(o===undefined||o.M3ENC===undefined)return 0;o.M3ENC.filter(function(o){return 0<+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor}).reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},0)},o.prototype.MergeRecepYEnc=function(o,t){var e=this;0<o.M3PRecepcion.length&&o.M3PRecepcion.filter(function(o){return o.IdRecepcion==t}).forEach(function(t){o.M3ENC.find(function(o){return o.ID==t.IdEnc}).M3DET.push(e.LoadM3PDetalle(t.Cantidad.toString(),"CURCREC"))})},o.prototype.RemoveCurCRec=function(o){o!==undefined&&null!=o&&o.M3ENC!==undefined&&null!=o.M3ENC&&o.M3ENC.forEach(function(o){var t;(t=o.M3DET.find(function(o){return"CURCREC"==o.NombreConcepto}))!==undefined&&null!=t&&(t.Valor="0")})},o.prototype.MergeEntpYEnc=function(e){var r=this;0<e.M3PEnvios.length&&e.M3PEnvios.forEach(function(t){var o;(o=e.M3ENC.filter(function(o){return o.IdEnvio==t.IdEnvio}))!==undefined&&null!=o&&o.forEach(function(o){o.M3DET.push(r.LoadM3PDetalle(o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor,"CURCENT"))})})},o.prototype.RemoveCurCEnt=function(o){o!==undefined&&null!=o&&o.M3ENC!==undefined&&null!=o.M3ENC&&o.M3ENC.forEach(function(o){var t;(t=o.M3DET.find(function(o){return"CURCENT"==o.NombreConcepto}))!==undefined&&null!=t&&(t.Valor="0")})},o.prototype.ProcPromoAfterAddToCart=function(t,e,r,n,i){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.ProcesarObsequios(e,r,n,i,t)];case 1:return o.sent(),[2]}})})},o.prototype.ProcPromoAfterFinalizar=function(o,t,e,r){this.GenerarPromoCombinada(o,r),this.PromoAfterProceso(o,t,e,r)},o.prototype.PromoAfterProceso=function(o,t,e,r){try{var n,i=new X(r,null),a=new Array,s=new k;a.push("AFTER"),n=i.VerificarPromociones(o,null,t,e,a),null!=(s=i.ProcesarPromoAfter(n,o,e))&&(o.ValorNeto=s.PrecioTotal,this.AddInfoPromocionesADinamicas(o,s))}catch(c){}},o.prototype.AddInfoPromocionesADinamicas=function(o,t){var e=this.GenerarInfoPromocionesProcesadas(t,0);if(null!=e){var r=new R;r=this.CreateTuplaDinamica("VAL_PROMOC",t.PrecioTotalPromocion.toString()),o.lM3PDinamicas.push(r),r=this.CreateTuplaDinamica("NOMB_PROMOC",e.NOMBRES),o.lM3PDinamicas.push(r),r=this.CreateTuplaDinamica("ID_PROMOC",e.ID),o.lM3PDinamicas.push(r)}},o.prototype.get_m3_proceso_by_id_prestamo_async=function(t,e,r){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.getM3("M3/getM3ProcesoByIdPrestamo/"+e+"/"+r).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.GetConceptoM3SaldosItemUb=function(t,e,r){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t.getWithBodyM3("M3/GetConceptoM3SaldosItemUb/"+e,r).toPromise()];case 1:return[2,o.sent()];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.addProductoToOtrasClas=function(o,t,e,r){var n,i,a=e;i=o.LoM3PrdGeneral[0];var s=this.validarExistaOtraClasif(a.M3OtClasificaciones,o);s?(s.Cantidad=s.Cantidad+t,s.Valor=+oo.multiply(i.LoM3PrdLista.PRECIO,s.Cantidad),s.Orden=this.GetMaxAtributoFromLista(a.M3OtClasificaciones,"Orden")+1):((n=new J).Cantidad=t,n.IdProducto=i.SKU,n.Nombre=i.NOMBRE1,n.Valor=+oo.multiply(i.LoM3PrdLista.PRECIO,t),n.ID=this.GetMaxAtributoFromLista(a.M3OtClasificaciones,"ID")+1,n.Orden=this.GetMaxAtributoFromLista(a.M3OtClasificaciones,"Orden")+1,a.M3OtClasificaciones.push(n)),e=this.recalcularValOtraClasiM3Procesos(e),r(a)},o.prototype.deleteProductoFromOtrasClas=function(t,o){var e=o.M3OtClasificaciones.find(function(o){return o.IdProducto==t.IdProducto});return e&&(e.Cantidad=0,e.Valor=0),o=this.recalcularValOtraClasiM3Procesos(o)},o.prototype.recalcularValOtraClasiM3Procesos=function(o){return o.ValOtraClasi=o.M3OtClasificaciones.reduce(function(o,t){return o+t.Valor},0),o},o.prototype.validarExistaOtraClasif=function(o,t){return o.find(function(o){return o.IdProducto==t.LoM3PrdGeneral[0].SKU})},o.prototype.deletePrdDevolucion=function(t,o){var e=o.M3ENC.find(function(o){return o.IdProducto==t.IdProducto});e&&(e.M3DET.forEach(function(o){isNaN(+o.Valor)||(o.Valor="0")}),e.M3PImpuestos.forEach(function(o){o.Valor=0,o.Base=0}))},o.prototype.ajustadorValoresCFDIFront=function(o){var t,e=this.getValorTotalDescuentos(o),r=this.getValorTotalImporteImpuestos(o);return 0!=(t=this.oMathTF.round(o.ValorNeto-(o.Valor+r-e),3))&&(0<r?this.ajustadorImpuestosCFDI(t,o):this.ajustadorDescuentosCFDI(t,o)),o},o.prototype.getValorTotalDescuentos=function(o){var e=0;return o.M3ENC.forEach(function(o){var t=o.M3DET.find(function(o){return"TOTALPROMO"==o.NombreConcepto});t&&(e+=+t.Valor)}),e},o.prototype.getValorTotalImporteImpuestos=function(o){var t=0;return o.M3ENC.forEach(function(o){o.M3PImpuestos.forEach(function(o){t+=+o.Valor})}),t},o.prototype.ajustadorImpuestosCFDI=function(o,t){var e,r,n,i,a=!1;try{for(var s=v(t.M3ENC),c=s.next();!c.done;c=s.next()){var u=c.value;try{for(var l=v(u.M3PImpuestos),d=l.next();!d.done;d=l.next()){var f=d.value;f.Valor=0<o?f.Valor+.01:f.Valor-.01,f.Base=f.Valor/f.Porcentaje,a=!0;break}}catch(p){n={error:p}}finally{try{d&&!d.done&&(i=l["return"])&&i.call(l)}finally{if(n)throw n.error}}if(a)break}}catch(h){e={error:h}}finally{try{c&&!c.done&&(r=s["return"])&&r.call(s)}finally{if(e)throw e.error}}},o.prototype.ajustadorDescuentosCFDI=function(o,t){var e,r,n;try{for(var i=v(t.M3ENC),a=i.next();!a.done;a=i.next()){if((n=a.value.M3DET.find(function(o){return"TOTALPROMO"==o.NombreConcepto}))&&0<+n.Valor){n.Valor=0<o?(+n.Valor-.01).toString():(+n.Valor+.01).toString();break}}}catch(s){e={error:s}}finally{try{a&&!a.done&&(r=i["return"])&&r.call(i)}finally{if(e)throw e.error}}},o.prototype.getPrdsGeneralFromM3Proceso=function(o,t,e,r,n){o.getWithBodyM3("M3/getPrdsGeneralFromM3Proceso/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o.error.Message))})},o}(),eo=function(){function o(){}return o.prototype.M3_GetDiario=function(o,t,e,r,n){o.getWithBodyM3("M3Trx/M3_GetDiario/"+t,e).subscribe(function(o){var t;(t=o).RESPUESTA.data.length===undefined&&(t.RESPUESTA.data=new Array(t.RESPUESTA.data)),r(o)},function(o){n(o.error.Message)})},o.prototype.m3_getDiarioTrx=function(o,t,e,r,n){o.getWithBodyM3("M3Trx/m3_getDiarioTrx/"+t,e).subscribe(function(o){var t;(t=o).RESPUESTA.Diario.length===undefined&&(t.RESPUESTA.Diario=new Array(t.RESPUESTA.Diario)),r(o)},function(o){n(o.error.Message)})},o.prototype.M3_GetInfoTRX=function(o,t,e,r,n){o.getWithBodyM3("M3Trx/M3_GetInfoTRX/"+t,e).subscribe(function(o){var t;(t=o).RESPUESTA.TIPOS.length===undefined&&(t.RESPUESTA.TIPOS=new Array(t.RESPUESTA.TIPOS)),t.RESPUESTA.TIPOS.forEach(function(o){o.TRX.length===undefined&&(o.TRX=new Array(o.TRX))}),r(t)},function(o){n(o.error.Message)})},o.prototype.CambioEstadoUbicacion=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Trx/CambioEstadoUbicacion/"+t,e).subscribe(function(o){r(o)},function(o){console.log(o._body),n(o._body)})},o.prototype.CambioEstadoHub=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Trx/CambioEstadoHub/"+t,e).subscribe(function(o){r(o)},function(o){console.log(o._body),n(o._body)})},o.prototype.CambioNDocActivoHub=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Trx/CambioNDocActivoHub/"+t,e).subscribe(function(o){r(o)},function(o){console.log(o._body),n(o._body)})},o}(),ro=function(){function o(o,t){this.lPreciosSelected="-1";var e={USER:o,Proceso:t};this.goData=e}return o.prototype.GetListaPrecios=function(n,i){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.gsIdKatios=i,t=new $,(e=this.GetLPreciosInStorage(i))?[3,2]:[4,t.M3GET_LISTAPRECIOS_ASync(n,i)];case 1:e=o.sent(),this.SaveLPreciosInStorage(e,i),o.label=2;case 2:return this.ValidarAPLRegla(e),[2,this.lPreciosSelected];case 3:return r=o.sent(),console.log(r),[3,4];case 4:return[2]}})})},o.prototype.SaveLPreciosInStorage=function(o,t){localStorage.setItem("RegPrecio"+t,JSON.stringify(o))},o.prototype.SaveConfigLPreciosInStorage=function(o,t){console.debug(o),sessionStorage.setItem("ConfigLP"+t,o)},o.prototype.GetLPreciosInStorage=function(o){var t=localStorage.getItem("RegPrecio"+o);return t?JSON.parse(t):null},o.prototype.GetConfigLPreciosInStorage=function(o){var t=sessionStorage.getItem("ConfigLP"+o);return t?JSON.parse(t):null},o.prototype.FindLPrecio=function(o){var t,e;if(o!==undefined&&null!=o&&o.ID!==undefined&&null!=o.ID&&o.PRECEDENCIA!==undefined&&null!=o.PRECEDENCIA&&o.PRECEDENCIA.length!==undefined)try{for(var r=v(o.PRECEDENCIA),n=r.next();!n.done;n=r.next()){var i=n.value;this.ValidarAPLRegla(i)}}catch(a){t={error:a}}finally{try{n&&!n.done&&(e=r["return"])&&e.call(r)}finally{if(t)throw t.error}}},o.prototype.ValidarAPLRegla=function(o){var t=!1;if(o!==undefined)try{switch(console.debug(o.Propiedad),o.Propiedad.toUpperCase().trim()){case"EMPRESA":t=this.Compare(o.Valor.toString(),this.gsIdKatios.toString());break;case"UBICACION":t=this.Compare(o.Valor.toString(),this.goData.USER.UsuarioSistema.UBICACION.toString());break;case"PROCESO":t=this.Compare(o.Valor.toString(),this.goData.Proceso.toString());break;case"HUB":t=this.Compare(o.Valor.toString(),this.goData.USER.UsuarioSistema.IDHUB.toString());break;default:t=this.Compare(o.Valor.toString(),this.goData.USER.UsuarioSistema[o.Propiedad.toUpperCase().trim()].toString())}}catch(e){console.error("error: "+e)}return t&&(this.lPreciosSelected=o.ListaPrecios,this.FindLPrecio(o)),t},o.prototype.Compare=function(o,t){return o==t},o.prototype.GetConfigListaPrecios=function(n,i){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.gsIdKatios=i,t=new $,(e=this.GetConfigLPreciosInStorage(i))?[3,2]:[4,t.GetEncabezadoListasPrecio(n,i)];case 1:e=o.sent(),this.SaveConfigLPreciosInStorage(e,i),o.label=2;case 2:return[2,e];case 3:return r=o.sent(),console.log(r),[3,4];case 4:return[2]}})})},o}(),no=function lt(){},io=function dt(){this.M3GRP=new D},ao=function ft(){},so=function pt(){this.M3HUBS=new Array},co=function ht(){},uo=function Pt(){},lo=function Mt(){},fo=function mt(){this.EstadoManuales=!1,this.EsManual=!1,this.EstadoAplCupon=!1,this.EsAplCupon=!1},po=function(){function o(o){this.goM3Ubicacion=o}return o.prototype.GetDireccion=function(){return this.GetAdicionarByAtribute("DIRECCION")},o.prototype.GetTelefono=function(){return this.GetAdicionarByAtribute("TELEFONO")},o.prototype.GetLong=function(){return this.GetAdicionarByAtribute("LONG")},o.prototype.GetLat=function(){return this.GetAdicionarByAtribute("LAT")},o.prototype.GetAdicionarByAtribute=function(t){try{var o=this.goM3Ubicacion.M3UbiAdicionales.find(function(o){return o.Atributo==t});return o!==undefined&&null!=o?o.Valor:"N/A"}catch(e){return"N/A"}},o}(),ho=function(){function o(o,t,e,r,n){this.oCouchPRDSService=n,this.separador=",",this.oM3Proceso=new w,this.gbBarCode=!1,this.oM3Proceso=t,this.gsIdKatios=o,this.ConfMasiva=e,this.gbBarCode=r}return o.prototype.get_rounded_progress=function(){return this.rounded_progress},o.prototype.AdicionarMasivo=function(r,n,i,a,s){return void 0===s&&(s=null),O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return this.GetReader(a),t=this.reader?this.reader.result.toString():a.Text,e=t.split("\n"),[4,this.adicionar_masivo_from_array(r,n,i,e,s)];case 1:return[2,o.sent()]}})})},o.prototype.adicionar_masivo_from_array=function(p,h,P,M,m,C){return void 0===m&&(m=null),void 0===C&&(C="0"),O(this,void 0,void 0,function(){var t,e,a,s,r,c,u,n,i,l,d,f=this;return S(this,function(o){switch(o.label){case 0:t=M.length,e=0,s=new $,r=new to(p,h,this.gsIdKatios),c="",u=!1,this.progress=0,n=[this.oM3Proceso,""],i=0,o.label=1;case 1:return i<t?(u=!1,(l=M[i])?(d=this.SetEstructCSV(l),this.gbBarCode?(console.debug("fue local: "+d.sku),[4,this.oCouchPRDSService.get(d.sku).then(function(t){return O(f,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return console.debug("obtuvo local"),console.debug(t),[4,new Q(this.gsIdKatios).AsignarListaPrecio(t.ListCods,P,h).then(function(o){console.debug("asigno lp local"),console.debug(t.ListCods),a=t.ListCods})];case 1:return o.sent(),[2]}})})},function(i){return O(f,void 0,void 0,function(){var t,e,r,n;return S(this,function(o){switch(o.label){case 0:console.error("error lp - intento server: "+d.sku+": "+i),t={id_ubicacion:P.UsuarioSistema.UBICACION,Codigo:d.sku},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s.Get_M3ProductoEspecByCodeAsync(h,this.gsIdKatios,t,P)];case 2:return a=o.sent(),[3,4];case 3:return e=o.sent(),console.error("error catch lp: "+d.sku+": "+e),r=e.url,n=r.substring(r.indexOf("Codigo")+7),c+=n+",",u=!0,[3,4];case 4:return[2]}})})})]):[3,3]):[3,8]):[3,10];case 2:return o.sent(),[3,7];case 3:return console.debug(m),console.debug(m&&m.IDUbicacion),m&&m.IDUbicacion?[4,s.M3GetProductoBySKUAsync(h,this.gsIdKatios,d.sku,P,m.IDUbicacion,C)]:[3,5];case 4:return a=o.sent(),[3,7];case 5:return[4,s.M3GetProductoBySKUAsync(h,this.gsIdKatios,d.sku,P,"-1",C)];case 6:a=o.sent(),o.label=7;case 7:console.debug(a),!u&&a?(this.setPrecioSiAPlica(a,d),this.AddPrdToM3Proceso(a,d,r,P,m)):console.error("error product no se lleno: "+d.sku),o.label=8;case 8:e++,this.progress=100*e/t,this.rounded_progress=Math.round(100*this.progress)/100,o.label=9;case 9:return i++,[3,1];case 10:return n[0]=this.oM3Proceso,n[1]=c,[2,n]}})})},o.prototype.setPrecioSiAPlica=function(o,t){t.precio!==NaN&&null!=t.precio&&(o.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=t.precio,o.LoM3PrdGeneral[0].LoM3PrdLista.M3Presentaciones.forEach(function(o){o.VALOR=t.precio}))},o.prototype.AddPrdToM3Proceso=function(o,t,e,r,n){void 0===n&&(n=null);var i=new N;i.dCantidad=t.cantidad,t.PathImagen&&(i.PathImagen=t.PathImagen),i=e.LoadAdicionales(i,o),0==this.oM3Proceso.M3ENC.length?(this.oM3Proceso=e.LoadM3ProcesoEmptyPDB(o,i,r,n,null,this.oM3Proceso),this.AdicionarDinamica(t),this.AdicionarPersonasAProceso(t)):e.LoadM3ProcesoFromData(this.oM3Proceso,o,i,n,null,r),this.AdicionarDetalle(t)},o.prototype.AdicionarDinamica=function(o){try{for(var t=o.Dinamicas,e=0;e<t.length;e++){var r=new R;this.oM3Proceso.lM3PDinamicas||(this.oM3Proceso.lM3PDinamicas=new Array),r.Nombre=t[e].Atributo,r.Valor=t[e].Valor,this.oM3Proceso.lM3PDinamicas.push(r)}}catch(n){console.log("Error adicionar dinamica"),console.log(n)}},o.prototype.AdicionarPersonasAProceso=function(o){try{for(var t=o.Personas,e=0;e<t.length;e++){var r=new K;this.oM3Proceso.M3PerXProceso||(this.oM3Proceso.M3PerXProceso=new Array),r.Tdoc=t[e].Tdoc,r.Ndoc=t[e].Ndoc,r.TipoPersona=t[e].Atributo,this.oM3Proceso.M3PerXProceso.push(r)}}catch(n){console.log("Error adicionar personas"),console.log(n)}},o.prototype.AdicionarDetalle=function(o){try{for(var t=o.M3Det,e=0;e<t.length;e++){var r=new T;r.NombreConcepto=t[e].Atributo,r.Valor=t[e].Valor,this.oM3Proceso.M3ENC[this.oM3Proceso.M3ENC.length-1].M3DET.push(r)}}catch(n){console.log("Error adicionar detalle"),console.log(n)}},o.prototype.GetReader=function(o){this.reader=o.CSV,this.separador=o.Separador},o.prototype.SetEstructCSV=function(o){try{var t=o.split(this.separador);return this.ConfMasiva&&this.ConfMasiva.Columnas?this.EstructDynamic(t):this.EstructDefault(t)}catch(e){return console.log("Error creando estructura. Revisar lineas"),console.log(e),null}},o.prototype.EstructDynamic=function(o){for(var t=this.ConfMasiva.Columnas,e={cantidad:null,precio:null,sku:null,PathImagen:null,Dinamicas:[],Personas:[],M3Det:[]},r=0;r<t.length;r++)switch(t[r].Estructura){case"Cantidad":e.cantidad=+o[t[r].Posicion];break;case"Precio":e.precio=+o[t[r].Posicion];break;case"SKU":e.sku=o[t[r].Posicion];break;case"DINAMICA":var n={Atributo:t[r].Atributo,Valor:o[t[r].Posicion]};e.Dinamicas.push(n);break;case"M3DET":var i={Atributo:t[r].Atributo,Valor:o[t[r].Posicion]};e.M3Det.push(i);break;case"TIPOPERSONA":var a,s=o[t[r].Posicion],c="5";a=2<=s.split("-").length?(c=s.split("-")[0],s.split("-")[0]):s;var u={Atributo:t[r].Atributo,Tdoc:c,Ndoc:a};e.Personas.push(u)}return e},o.prototype.EstructDefault=function(o){var t={cantidad:null,precio:null,sku:null,PathImagen:null,Dinamicas:[],Personas:[],M3Det:[]};return 1<=o.length&&(t.sku=o[0]),2<=o.length&&(t.cantidad=+o[1]),3<=o.length&&(t.precio=+o[2]),4<=o.length&&(t.PathImagen=o[3]),t},o}(),Po=function(){function o(){}return o.prototype.add_dinamica_idprestamo_to_proceso=function(n,i,a,s,c,u){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:(e=new R).Nombre="IdPrestamo",e.Valor=a,o.label=1;case 1:return o.trys.push([1,4,,6]),[4,new to(null,null,i).get_m3_proceso_by_id_prestamo_async(n,i,a)];case 2:return(r=o.sent()).EstadoDes=r.EstadoAnt,r.SubEstadoDes=r.SubEstadoAnt,[4,this.add_pdinamica_to_existing_proceso(n,r,i,s,c,e,u)];case 3:return t=o.sent(),[3,6];case 4:return o.sent(),[4,this.add_pdinamica_to_new_proceso(n,i,s,c,e,u)];case 5:return t=o.sent(),[3,6];case 6:return[2,t]}})})},o.prototype.add_pdinamica_to_new_proceso=function(n,i,a,s,c,u){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return t=this.GetM3PItemsWEB(u),e=new to(null,null,i),(r=e.LoadM3ProcesoEmptyPDB(a,t,s,null,null,null)).lM3PDinamicas.push(c),r.EstadoDes="Activo",r.SubEstadoDes="Registro",[4,e.procesamiento_service_async(i,n,r,s)];case 1:return[2,o.sent()]}})})},o.prototype.add_pdinamica_to_existing_proceso=function(n,i,a,s,c,u,l){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return t=this.GetM3PItemsWEB(l),e=new to(null,null,a),(r=e.LoadM3ProcesoFromData(i,s,t,null,null,c)).lM3PDinamicas.push(u),[4,e.procesamiento_service_async(a,n,r,c)];case 1:return[2,i=o.sent()]}})})},o.prototype.GetM3PItemsWEB=function(o){var t=new N;return t.dCantidad=1,t.IdProceso="M3VENTA",o.forEach(function(o){t[o.Nombre]=o.Valor}),t},o}(),Mo=function(){function o(){}return o.prototype.ProcesarReverso=function(o,t,e,r,n,i,a){o.postServiceHttpResFullM3("M3Reverso/Reversar/"+t+"/"+r+"/"+e,n).subscribe(function(o){i(o)},function(o){a(o)})},o}(),mo=function Ct(){},Co=function gt(){},go=function It(){},Io=function yt(){this.M3PDinamByActividad=new Array,this.Actual=undefined},yo=function(){function o(){}return o.prototype.m3_get_cupones_generados_by_proceso=function(o,t,e,r,n){o.getWithBodyM3("M3/m3_get_cupones_generados_by_proceso/"+t,e).subscribe(function(o){var t,e=JSON.parse(o.toString());e.CUPONES.CUPON.length?t=e.CUPONES.CUPON:(t=new Array).push(e.CUPONES.CUPON),r(t)},function(o){n(o.error.Message)})},o.prototype.getCuponByIdDet=function(o,t,e,r,n){o.getWithBodyM3("M3/getCuponByIdDet/"+t,e).subscribe(function(o){r(o)},function(o){n(o)})},o}(),Oo=function(){function o(){if(this.listener=new r.EventEmitter,!this.isInstantiated){var o=this.GetIdKatiosLVL1FromSession();this.database=new a("Offline"+o,{auto_compaction:!0}),this.isInstantiated=!0}}return o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.get=function(o){return this.database.get(o)},o.prototype.AddDocument=function(o,t){var r=this;return t._id=o,console.log("AddDocument"),this.get(o).then(function(o){return console.log("AddDocument enconrtro document"),t._rev=o._rev,r.database.put(t)},function(e){return console.log(e.status),"404"==e.status?(delete t._rev,r.database.put(t)):new Promise(function(o,t){t(e)})})},o.prototype.DestroyTotal=function(){this.database.destroy()},o.prototype.GetAllDocsDeleted=function(){return this.database.allDocs({include_docs:!0,deleted:!0})},o.prototype.GetAllDocs=function(){return this.database.allDocs({include_docs:!0})},o.prototype.GetAllDocsOffLineSinDocs=function(){return this.database.allDocs({include_docs:!1})},o.prototype.Destroy=function(t){var e=this;this.database.destroy().then(function(o){setTimeout(function(){var o=e.GetIdKatiosLVL1FromSession();e.database=new a("OfflineLog"+o,{auto_compaction:!0}),t({Resp:"OK"})},2e3)})["catch"](function(o){t({Resp:"Error",Desc:o}),console.log(o)})},o.prototype.DeleteAllDocs=function(){var t=this;this.database.allDocs({include_docs:!0}).then(function(o){return o.rows.filter(function(o){return!o.id.startsWith("CTIVOS")}).map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return t.database.bulkDocs(o)})},o.prototype.Delete=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),So=function(){function o(o){if(this.oM3DevicesService=o,this.listener=new r.EventEmitter,this.AddLogSocketOK=function(){},!this.isInstantiated){var t=this.GetIdKatiosLVL1FromSession();this.database=new a("OfflineLog"+t,{auto_compaction:!0}),this.isInstantiated=!0}}return o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.get=function(o){return this.database.get(o)},o.prototype.AddDocument=function(o,t){var r=this;return t._id=o,this.get(o).then(function(o){return t._rev=o._rev,r.database.put(t)},function(e){return"404"==e.status?r.database.put(t,{force:!0}):new Promise(function(o,t){t(e)})})},o.prototype.Destroy=function(t){var e=this;this.database.destroy().then(function(o){setTimeout(function(){var o=e.GetIdKatiosLVL1FromSession();e.database=new a("OfflineLog"+o,{auto_compaction:!0}),t({Resp:"OK"})},2e3)})["catch"](function(o){t({Resp:"Error",Desc:o}),console.log(o)})},o.prototype.closeInstance=function(){this.database.close()},o.prototype.InstanceAgain=function(){try{var o=this.GetIdKatiosLVL1FromSession();this.database=new a("OfflineLog"+o,{auto_compaction:!0})}catch(t){}},o.prototype.GetAllDocsDeleted=function(){return this.database.allDocs({include_docs:!0,deleted:!0})},o.prototype.GetAllDocs=function(){return this.database.allDocs({include_docs:!0})},o.prototype.DeleteAllDocs=function(){var t=this;this.database.allDocs({include_docs:!0}).then(function(o){return o.rows.filter(function(o){return!o.id.startsWith("CTIVOS")}).map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return t.database.bulkDocs(o)})},o.prototype.DeleteOldDocs=function(t){var e=this;console.debug("DeleteOldDocs"),this.database.allDocs({include_docs:!0}).then(function(o){return console.debug(o),e.AddLogSocket(o),o.rows.forEach(function(o){console.debug(o.doc.Fecha),console.debug(o.doc.Fecha.substring(0,10)+" 00:00"),console.debug(new Date(o.doc.Fecha.substring(0,10)+" 00:00")),console.debug(Date.now()-new Date(o.doc.Fecha.substring(0,10)+" 00:00").getTime()),console.debug((Date.now()-new Date(o.doc.Fecha.substring(0,10)+" 00:00").getTime())/864e5)}),o.rows.filter(function(o){return Math.floor((Date.now()-new Date(o.doc.Fecha.substring(0,10)+" 00:00").getTime())/864e5)>=t}).map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return e.database.bulkDocs(o)})},o.prototype.AddLogSocket=function(o){try{var t;t=[{nombre:"M3Proceso",valor:JSON.stringify(o)}],this.oM3DevicesService.Device_MPos(this.AddLogSocketOK,t,"LOGM3Procesos",null)}catch(e){console.log(e)}},o.prototype.Delete=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:c.M3DevicesService}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(c.M3DevicesService))},token:o,providedIn:"root"}),o}(),vo=function(){function o(o){this.oM3CouchMaestro=o}return o.prototype.GetFormasPago=function(o,t,e,r){var n=this;this.oM3CouchMaestro.get("FormasPago").then(function(o){console.log(o),e(n.FiltrarByProceso(t,o.FormasPago))},function(o){r(o),console.log(o)})},o.prototype.FiltrarByProceso=function(t,o){try{console.log(o),""!=t&&(o=o.filter(function(o){return console.log(o),!!o.PROCESOS&&(o.PROCESOS.length||(o.PROCESOS=new Array(o.PROCESOS)),null!=o.PROCESOS.find(function(o){return o.IdProceso==t}))}),console.log(o))}catch(e){return console.log("Error FiltrarByProceso"),console.log(e),o}return o},o.prototype.GetEstructura=function(o){return this.oM3CouchMaestro.get(o)},o.prototype.GetDinamicasByACtividad=function(o,e,r,t){var n;this.oM3CouchMaestro.get("DINBYACT").then(function(o){try{n=(n=o.M3DinByActividad).filter(function(o){return o.Actividad==e.Actividad&&o.IDActividad==e.idActividad&&o.IdProceso==e.idProceso}),r(n)}catch(t){n=new Array,r(n)}},function(o){t(o),console.log(o)})},o.prototype.GetUbicaciones=function(o,t,e,r){var n,i=o.trim().toUpperCase()+"?UBIC";this.oM3CouchMaestro.get(i).then(function(o){n=e.GetUbicacionFromList(o.ListUbicaciones.M3UBICACION,t),r(n)},function(o){console.log(o)})},o.prototype.Asyncget_template_reporte=function(o,e){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),"TEMPLATES",[4,this.oM3CouchMaestro.get("TEMPLATES")];case 1:return t=(t=o.sent()).RESPUESTA.RPTemplate.length==undefined?new Array(t.RESPUESTA.RPTemplate):t.RESPUESTA.RPTemplate,[2,{RESPUESTA:{RPTemplate:t.find(function(o){return o.IdRep==e})}}];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:p}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(p))},token:o,providedIn:"root"}),o}(),bo=s,Do=function(){function o(o,t,e){this.oServiceOffLine=o,this.oPostServiceM3=t,this.obdOffLineLog=e,this.AddLogSocketOK=function(){}}return o.prototype.GetProcesoById=function(t,e,r){var n=this;this.oServiceOffLine.get(t).then(function(o){e(o)},function(o){n.GetProcesoByIdFromLog(t,e,r)})},o.prototype.GetProcesoByIdFromLog=function(o,t,e){this.obdOffLineLog.get(o).then(function(o){t(o)},function(o){e(o)})},o.prototype.AddProceso=function(o,t,e){var r=this;t.IdM3?this.AddToDocOffline(t,e):this.GetIdM3Offline(o,t.TMIdProceso,t.Ubic1.toString(),t.IDHub.toString()).then(function(o){t.IdM3=o,r.AddToDocOffline(t,e)})},o.prototype.AddToDocOffline=function(e,r,n){var i=this;void 0===n&&(n=0),this.oServiceOffLine.AddDocument(e.IdM3.toString(),e).then(function(o){i.SaveIdM3(e.IdM3,e.TMIdProceso,e.Ubic1.toString(),e.IDHub.toString()),i.AddLogOffline(e,r)},function(o){console.log(o);var t=bo(new Date).format("YYYYMMDDTHHmmss");localStorage.setItem("errorLog"+t,JSON.stringify({error:o,olM3Procesos:e,Intento:n,"function":"AddToDocOffline"})),0==n?(i.obdOffLineLog.InstanceAgain(),i.AddToDocOffline(e,r,1)):r({Error:"Error en guardar en base de datos pcpal."})})},o.prototype.AddLogOffline=function(e,r,n){var i=this;void 0===n&&(n=0),this.obdOffLineLog.AddDocument(e.IdM3.toString(),e).then(function(o){console.log(o),r(e.IdM3)},function(o){console.log(o);var t=bo(new Date).format("YYYYMMDDTHHmmss");localStorage.setItem("errorLog"+t,JSON.stringify({error:o,olM3Procesos:e,Intento:n,"function":"AddLogOffline"})),0==n?(i.obdOffLineLog.InstanceAgain(),i.AddLogOffline(e,r,1)):r({Error:"Error en guardar en base de datos local."})})},o.prototype.closeInstanceLogOff=function(){this.obdOffLineLog.closeInstance()},o.prototype.GetOffLineLog=function(){return this.obdOffLineLog.GetAllDocs()},o.prototype.Get1DocOffLineLog=function(o){return this.obdOffLineLog.get(o)},o.prototype.ReversarEnLog=function(o){var r=this;this.Get1DocOffLineLog(o).then(function(o){for(var t=o,e=0;e<t.lM3PEncFP.length;e++)t.lM3PEncFP[e].ValCambio=0,t.lM3PEncFP[e].Valor=0,t.lM3PEncFP[e].ValOtraClasi=0;t.IdEstado="RV",r.AddLogOffline(t,null)})},o.prototype.DestruirBDLog=function(o){return this.obdOffLineLog.Destroy(o)},o.prototype.DestruirBDOff=function(o){return this.oServiceOffLine.Destroy(o)},o.prototype.SumarCtivo=function(o){return o=o.substring(0,9)+""+(+o.substring(9)+1)},o.prototype.updProceso=function(e,r,n,i){var a=this;void 0===i&&(i=0),this.oServiceOffLine.AddDocument(e.toString(),r).then(function(o){a.AddLogOffline(r,n)},function(o){var t=bo(new Date).format("YYYYMMDDTHHmmss");localStorage.setItem("errorLog"+t,JSON.stringify({error:o,olM3Procesos:r,Intento:i,"function":"updProceso"})),0==i?(a.obdOffLineLog.InstanceAgain(),a.updProceso(e,r,n,1)):n({Error:"Error en guardar en base de datos pcpal."})})},o.prototype.updProcesoAsync=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.oServiceOffLine.AddDocument(t.toString(),e)];case 1:return o.sent(),this.AddLogOffline(e,null),[2]}})})},o.prototype.GetAllDocsOffLineSinDocs=function(){return this.oServiceOffLine.GetAllDocsOffLineSinDocs()},o.prototype.procesarTicketOffline=function(o,t,e,r){var n=new Array,i=new to(null,null,o);this.ValidarTicketCerrado(t)&&(n.push(t),i.RegistroEventoM3OffLine(o,this.oPostServiceM3,n,e).then(function(o){r(!!o,"OK")})["catch"](function(o){r(!1,o)}))},o.prototype.ValidarProcesosAgregadosOffLine=function(r,n,i){var a=this,s=new Array,c=new to(null,null,r);this.oServiceOffLine.GetAllDocs().then(function(o){for(var t=0;t<o.rows.length;t++)if(o.rows[t].id&&!o.rows[t].id.startsWith("CTIVOS")){var e=o.rows[t].doc;a.ValidarTicketCerrado(e)&&s.push(o.rows[t].doc)}c.RegistroEventoM3OffLine(r,a.oPostServiceM3,s,n).then(function(o){o?(a.oServiceOffLine.DeleteAllDocs(),i(!0,"OK")):i(!1,"OK")})["catch"](function(o){i(!1,o)})})["catch"](function(o){console.log(o),i(!1,o)})},o.prototype.ValidarTicketCerrado=function(o){var t=!0;return null!=o.M3ENC&&null!=o.lM3PEncFP?o&&"Declinado"!=o.SubEstadoAnt&&0<o.M3ENC.length&&0==o.lM3PEncFP.length&&0<this.getCantidadTotalByM3Proceso(o)&&(t=!1):t=!1,t},o.prototype.getCantidadTotalByM3Proceso=function(o){if(o&&o.M3ENC){var t=o.M3ENC.filter(function(o){return 0<+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor}).reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},0);return 0==t?0:t}return 0},o.prototype.GetAllDocsOffline=function(){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=new Array,[4,this.oServiceOffLine.GetAllDocs()];case 1:for(e=o.sent(),r=0;r<e.rows.length;r++)"CTIVOS"!=e.rows[r].id&&t.push(e.rows[r].doc);return[2,t];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.GetAllDocsOfflineDeleted=function(){return this.oServiceOffLine.GetAllDocsDeleted()},o.prototype.deleteCtivos=function(o,t){return this.oServiceOffLine.Delete(this.GetKey(o,t))},o.prototype.getAllCtivos=function(o,t){return this.oServiceOffLine.get(this.GetKey(o,t))},o.prototype.ValidacionCtivosVSServer=function(t,e,r,n){var i=this;this.getAllCtivos(e,r).then(function(o){o&&(new $).ValidarCtivosVSLocal(i.oPostServiceM3,t,JSON.stringify(o),e,r,n)})},o.prototype.GetCtivoOffLine=function(n,i,a){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:t="0",o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.oServiceOffLine.get(this.GetKey(n,i))];case 2:return(e=o.sent())&&(r=e.Ctivos.find(function(o){return o.IdProceso==a})).Ctivo&&(t=r.Ctivo.substring(9)),[3,4];case 3:return o.sent(),[3,4];case 4:return[2,t]}})})},o.prototype.SaveIdM3=function(r,n,i,a){var s=this;this.oServiceOffLine.get(this.GetKey(i,a)).then(function(o){var t=o.Ctivos,e=t.find(function(o){return o.IdProceso==n});e?+e.Ctivo.substring(9)<+r.substring(9)&&(e.Ctivo=r):t.push({IdProceso:n,Ctivo:r});s.SaveCtivos(t,i,a),"TICKETVENTA"==n.toUpperCase()&&localStorage.setItem("CtivoTicketVenta",r)},function(o){var t=new Array;t.push({IdProceso:n,Ctivo:r}),s.SaveCtivos(t,i,a),"TICKETVENTA"==n.toUpperCase()&&localStorage.setItem("CtivoTicketVenta",r)})},o.prototype.SaveCtivos=function(e,r,n,i){var a=this;void 0===i&&(i=0);var s={Ctivos:e};this.oServiceOffLine.AddDocument(this.GetKey(r,n),s).then(function(o){console.log("OK")},function(o){var t=bo(new Date).format("YYYYMMDDTHHmmss");localStorage.setItem("errorLogCtivos"+t,JSON.stringify({error:o,Ctivos:s,"function":"SaveCtivos"})),console.log(o),0==i&&a.SaveCtivos(e,r,n,1)})},o.prototype.DeleteOldDocs=function(o){this.obdOffLineLog.DeleteOldDocs(o)},o.prototype.GetIdM3Offline=function(n,i,a,s){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oServiceOffLine.get(this.GetKey(a,s))];case 1:return t=o.sent(),r=t.Ctivos.find(function(o){return o.IdProceso==i}),e=r?(e=r.Ctivo,e=this.SumarCtivo(e),this.validarAumentoCtivo(e,i)):this.GetCtivo(n,i,a,s),[3,3];case 2:return o.sent(),e=this.GetCtivo(n,i,a,s),[3,3];case 3:return[2,e]}})})},o.prototype.validarAumentoCtivo=function(o,t){if("TICKETVENTA"==t.toUpperCase()&&localStorage.getItem("CtivoTicketVenta")==o){var e=bo(new Date).format("YYYYMMDDTHHmmss");o=this.SumarCtivo(o),localStorage.setItem("errorLogCtivos"+e,JSON.stringify({idM3:o,"function":"validarAumentoCtivo"}))}return o},o.prototype.GetCtivo=function(t,e,r,n){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,(new $).GetCtivoBYProceso(this.oPostServiceM3,t,e,r,n)];case 1:return[2,o.sent()]}})})},o.prototype.GetKey=function(o,t){return"CTIVOS_"+o+t},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:Oo},{type:f},{type:So}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(Oo),r.inject(f),r.inject(So))},token:o,providedIn:"root"}),o}(),Eo=function(){function o(o){this.oPostServiceM3=o}return o.prototype.M3GetM3NotificacionesXHubObject=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oPostServiceM3.getWithBodyM3("M3NotifController/M3GetM3NotificacionesXHubObject/"+t,e).toPromise()];case 1:return[2,o.sent()];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.M3GetM3NotificacionesXHubObjectWithTimeOut=function(t,e,r){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oPostServiceM3.getWithBodyM3TimeOut("M3NotifController/M3GetM3NotificacionesXHubObject/"+t,e,r).toPromise()];case 1:return[2,o.sent()];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.m3_get_notificacion_x_hub_object=function(e,r){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oPostServiceM3.getWithBodyM3("M3NotifController/m3_get_notificacion_x_hub_object/"+e,r).toPromise()];case 1:return t=o.sent(),[2,r=JSON.parse(JSON.stringify(t))];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.guardarCambiosConfiguracionImpresion=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3NotifController/guardarCambiosConfiguracionImpresion/"+t.trim(),e).subscribe(function(o){r()},function(o){n(o._body)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:f}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(f))},token:o,providedIn:"root"}),o}(),Ao=function Ot(){},To=function St(){},No=function(){function o(o){this.PostServiceM3=o}return o.prototype.M3_GETINVENTARIOBYPACK=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.PostServiceM3.getWithBodyM3("M3Consultas/M3_GETINVENTARIOBYPACK/"+t,e).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.validarInventarioNegativoProducto=function(o,t,e,r,n){o.getWithBodyM3("M3/validarInventarioNegativoProducto/"+t,e).subscribe(function(o){r()},function(o){n(JSON.parse(o.error.Message))})},o.prototype.BuscarConceptoEnM3SIU=function(o,t,e,r,n){o.getWithBodyM3("M3Consultas/M3_GETConceptoFromSIU/"+t+"/"+e.sUbicacion+"/"+e.sConcepto,{}).subscribe(function(o){r(o)},function(o){n(JSON.parse(o.error.Message))})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:f}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(f))},token:o,providedIn:"root"}),o}(),Lo=function vt(){},Ro=function(){function o(){this.listener=new r.EventEmitter,this.aplSyncCouchAuto=!0,this.aplPaquetes=!1,this.idkatios=this.GetIdKatiosLVL1FromSession(),this.GetKatiosM3FromSession(),this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.getFlagSyncCouch=function(){var o,t,e=sessionStorage.getItem("SUbicacion"),r=!0;return e&&(o=JSON.parse(e)).M3HUBS&&o.M3HUBS[0]&&o.M3HUBS[0].Configuracion&&null!=(t=JSON.parse(o.M3HUBS[0].Configuracion)).SyncCouchAuto&&t.SyncCouchAuto!=undefined&&(r=t.SyncCouchAuto),r},o.prototype.CrearPouchSincronizacion=function(){this.idkatios=this.GetIdKatiosLVL1FromSession(),this.idkatios&&this.GetKatiosM3FromSession(),this.database=new a("PRD"+this.idkatios,{auto_compaction:!0}),console.debug("adapter"),console.debug(this.database.adapter),this.validarPaquetes(),this.isInstantiated=!0,console.log("********************************** INSTANCE PRODUCTOS *****************************************")},o.prototype.validarPaquetes=function(){if(this.aplPaquetes){var o=this.getUbicacion();o?this.sync(this.GetServer()+"prdsa"+o+"_"+this.idkatios.toLowerCase()):this.sync(this.GetServer()+"prds_"+this.idkatios.toLowerCase())}else this.sync(this.GetServer()+"prds_"+this.idkatios.toLowerCase())},o.prototype.syncCouch=function(){this.idkatios?this.validarPaquetes():this.CrearPouchSincronizacion()},o.prototype.getUbicacion=function(){var o,t=sessionStorage.getItem("SUbicacion");return t&&(o=JSON.parse(t)).IDUbicacion?o.IDUbicacion:null},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.GetKatiosM3FromSession=function(){var o=localStorage.getItem("ConfigKatios"+this.idkatios.toUpperCase());if(o!==undefined&&null!=o){var t=JSON.parse(o);if(t&&t.Katios&&t.Katios.KatiosM3){var e=t.Katios.KatiosM3.find(function(o){return"APLPAQS"==o.Llave.toUpperCase()});e&&"1"==e.Valor&&(this.aplPaquetes=!0)}}},o.prototype.Destroy=function(o){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.prototype.sync=function(o){var t=this;this.aplSyncCouchAuto=this.getFlagSyncCouch();var e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:this.aplSyncCouchAuto,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO PRODUCTOS *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PRODUCTOS *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getInfo=function(){return this.database.info()},o.prototype.getChangeListener=function(){return this.listener},o.prototype.deletePrd=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.prototype.DeleteAllDocs=function(){var t=this;this.database.allDocs({include_docs:!0}).then(function(o){return o.rows.map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return t.database.bulkDocs(o)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Uo=function(){function o(){this.listener=new r.EventEmitter,this.aplSyncCouchAuto=!0,this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.getFlagSyncCouch=function(){var o,t,e=sessionStorage.getItem("SUbicacion"),r=!0;return e&&(o=JSON.parse(e)).M3HUBS&&o.M3HUBS[0]&&o.M3HUBS[0].Configuracion&&null!=(t=JSON.parse(o.M3HUBS[0].Configuracion)).SyncCouchAuto&&t.SyncCouchAuto!=undefined&&(r=t.SyncCouchAuto),r},o.prototype.CrearPouchSincronizacion=function(){this.idkatios=this.GetIdKatiosLVL1FromSession(),this.database=new a("codsprd_"+this.idkatios,{auto_compaction:!0}),console.debug("adapter"),console.debug(this.database.adapter),this.sync(this.GetServer()+"codsprd_"+this.idkatios.toLowerCase()),this.isInstantiated=!0,console.log("********************************** INSTANCE PRODUCTOS *****************************************")},o.prototype.syncCouch=function(){this.idkatios?this.sync(this.GetServer()+"codsprd_"+this.idkatios.toLowerCase()):this.CrearPouchSincronizacion()},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this;this.aplSyncCouchAuto=this.getFlagSyncCouch();var e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:this.aplSyncCouchAuto,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO CODS PRODUCTOS *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO CODS PRODUCTOS *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.Destroy=function(){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Vo=function(){function o(){var o;(this.listener=new r.EventEmitter,this.elementRem=new r.EventEmitter,this.isInstantiated)||(o=this.GetIdKatiosLVL1FromSession(),this.database=new a("promociones_"+o,{auto_compaction:!0}),this.isInstantiated=!0,console.log("********************************** INSTANCE PROMOCIONES *****************************************"))}return o.prototype.GetServer=function(o){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3+"promociones_"+o.toLowerCase()},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!0,retry:!0}).on("complete",function(o){console.log(o),console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************")}).on("change",function(o){console.log(o),t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PROMOCIONES *****************************************")}).on("error",function(o){console.log("Error"),console.log(o)})},o.prototype.syncWithDB=function(o){var t=this;this.database.replicate.from(o,{live:!0,retry:!0}).on("complete",function(o){console.log(o),console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************")}).on("change",function(o){console.log(o),t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PROMOCIONES *****************************************")}).on("error",function(o){console.log("Error"),console.log(o)})},o.prototype.syncAwait=function(r){return O(this,void 0,void 0,function(){var t,e=this;return S(this,function(o){switch(o.label){case 0:return t=new a(r,{auto_compaction:!0}),[4,this.database.replicate.from(t,{}).on("complete",function(o){console.log(o),console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************"),e.syncWithDB(t)}).on("error",function(o){console.log("Error"),console.log(o)})];case 1:return o.sent(),[4,this.database.compact()];case 2:return o.sent(),[2]}})})},o.prototype.get=function(o){return this.database.get(o)},o.prototype["delete"]=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.elementRemoved=function(){var t=this;this.database.changes({live:!0,since:"now",include_docs:!0}).on("change",function(o){o.deleted&&(console.log(o),t.elementRem.emit(o))}).on("error",console.log.bind(console))},o.prototype.getRemoveListener=function(){return this.elementRem},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),_o=function(){function o(){var o;(this.listener=new r.EventEmitter,this.change=new r.EventEmitter,this.isInstantiated)||(o=this.GetIdKatiosLVL1FromSession(),this.database=new a("ubicaciones_"+o,{auto_compaction:!0}),this.sync(this.GetServer()+"ubicaciones_"+o.toLowerCase()),this.isInstantiated=!0,console.log("********************************** INSTANCE UBICACIONES *****************************************"))}return o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!0,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO UBICACIONES *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO UBICACIONES *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.ChangeItem=function(){var t=this;this.database.changes({live:!0,since:"now",include_docs:!0}).on("change",function(o){console.log(o),t.change.emit(o)}).on("error",console.log.bind(console))},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.getChange=function(){return this.change},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Bo=function(){function o(){var o;(this.listener=new r.EventEmitter,this.isInstantiated)||(o=this.GetIdKatiosLVL1FromSession(),this.database=new a("notificaciones_"+o.toLowerCase().trim(),{auto_compaction:!0}),this.sync(this.GetServer()+"notificaciones_"+o.toLowerCase().trim()),this.isInstantiated=!0)}return o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.get=function(o){return this.database.get(o)},o.prototype.GetDataPouchBD=function(o){return this.database.get(o)},o.prototype.getChangeListener=function(){return this.listener},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!0,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PROMOCIONES *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.GetKeyDocumentoDB=function(o,t){return o+"?"+t},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Go=function(){function o(){this.operators={"<":function(o,t){return+o<+t},">":function(o,t){return+t<+o},"<=":function(o,t){return+o<=+t},">=":function(o,t){return+t<=+o},IGUAL:function(o,t){return o==t},DIFF:function(o,t){return o!=t},EN:function(o,t){return o===t},AND:function(o,t){return o&&t},OR:function(o,t){return o||t},"*":function(o,t){return!0},MOD:function(o,t){return+o%+t==0}}}return o.prototype.ValidarSiEsTipo=function(o,t){try{return!!o.M3PACKBYTIPO.find(function(o){return o.DESTINO==t.TIPO})}catch(e){return!1}},o.prototype.GeneraValidaciones=function(o,t,e){try{var r=!0,n=o.M3PACKBYTIPO.find(function(o){return o.DESTINO==t.TIPO});if(n)for(var i=0;n.M3PACKREGLAS.length;i++){var a=n.M3PACKREGLAS[i];this.operators[a.Operacion](this.GetParametros(a.Param1,o),this.GetParametros(a.Param2,o))?this.ValidacionAccion(a.Accion,e):r=!1}}catch(s){}return r},o.prototype.ValidacionAccion=function(o,t){try{if(""!=o){var e=JSON.parse(o);if(e.Accion)switch(e.Accion){case"Cantidad":t.dCantidad=e.Valor}}}catch(r){}},o.prototype.GetParametros=function(t,o){var e="";try{var r=t.split("_")[0];switch(r.toUpperCase()){case"ADI":e=o.LoM3PrdAdicionales.find(function(o){return o.ATRIBUTO==t.split("_")[1]}).VALOR;break;case"CONST":e=t.split("_")[1];break;default:r.toUpperCase().startsWith("SKP")&&(e=o.LoM3PrdGeneral[0][r])}}catch(n){}return e},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),wo=s,Fo=function(){function o(){}return o.prototype.FiltrarByFechasOff=function(o,t){try{var e,r=sessionStorage.getItem("FechaItCOFF"),n=sessionStorage.getItem("FechaFtCOFF");if(e=o.rows,n&&r){var i=this.GetFechaNumber(r),a=this.GetFechaNumber(n);console.log(i),console.log(a);for(var s=0;s<e.length;s++){var c=e[s].doc;if(c){var u=this.GetFechaNumber(c.Fecha);console.log(u),+i<=+u&&+u<=+a&&t(c)}}}}catch(l){console.log("FiltrarByFechasOff"),console.log(l)}},o.prototype.FiltrarByTexto=function(o,t,e){try{var r;r=o.rows;for(var n=0;n<r.length;n++){var i=r[n].doc;i&&(i.IdM3.includes(t)||i.ndocUActivo&&i.ndocUActivo.includes(t))&&e(i)}}catch(a){console.log("FiltrarByFechasOff"),console.log(a)}},o.prototype.GetFechaNumber=function(o){return wo(o).format("YYYYMMDD")},o}(),Ko=function(){function o(){this.listener=new r.EventEmitter,this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.CrearPouchSincronizacion=function(){var o;o=this.GetIdKatiosLVL1FromSession(),this.database=new a("perxtipo_"+o,{auto_compaction:!0}),this.sync(this.GetServer()+"perxtipo_"+o.toLowerCase()),this.isInstantiated=!0,console.log("********************************** INSTANCE perxtipo *****************************************")},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!1,retry:!1}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO perxtipo *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO perxtipo *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.Destroy=function(){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Jo=function(){function o(){this.listener=new r.EventEmitter,this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.CrearPouchSincronizacion=function(){var o;o=this.GetIdKatiosLVL1FromSession(),this.database=new a("dinamxproc_"+o,{auto_compaction:!0}),this.sync(this.GetServer()+"dinamxproc_"+o.toLowerCase()),this.isInstantiated=!0,console.log("********************************** INSTANCE dinamxproc_ *****************************************")},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!1,retry:!1}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO dinamxproc_ *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO dinamxproc_ *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.Destroy=function(){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}();o.PostServiceM3=f,o.xmlToJsonTF=m,o.M3CouchMaestro=p,o.M3Data=P,o.Filtros=M,o.M3PrdAdicionales=g,o.M3PrdGeneral=y,o.M3PRDImpuestos=b,o.TypeM3PrdGrp=D,o.TypeImpuestosPRD=E,o.M3PrdLista=I,o.M3PImpuestos=A,o.M3PDetalleItems=T,o.M3PItemsWEB=N,o.M3PDetalleCupon=L,o.M3PDinamicas=R,o.M3PEncFP=U,o.M3PEncItems=V,o.M3PEnvios=_,o.M3Procesos=w,o.M3PRecepcion=F,o.M3PerXProceso=K,o.M3OtClasificaciones=J,o.ServiceM3FE=j,o.M3ProcesoService=H,o.M3RegService=to,o.M3Trx=eo,o.ServiceM3Maestro=$,o.ServiceListaPrecio=ro,o.ServiceLoadListaPrecio=Q,o.M3DinProcesos=no,o.M3PrdPackDet=io,o.M3UbiAdicionales=ao,o.M3Ubicacion=so,o.promocionesService=X,o.M3CONDIAGRUPACION=co,o.M3CONDIPROMO=uo,o.M3DETCONDIPROMO=lo,o.M3ENCPROMO=fo,o.PromocionProcesada=k,o.PromocionesAsociadas=x,o.PromocionCombinada=W,o.M3UbicacionService=po,o.M3RegMasivo=ho,o.M3RegMasivoAKZService=Po,o.M3ReversoServ=Mo,o.M3PDinamByActividad=mo,o.M3DinByActividad=Co,o.M3SaldosXCuenta=go,o.M3RegistroTrx=Io,o.cuponesService=yo,o.ServiceOffLine=Oo,o.bdOffLineLog=So,o.M3MaestroOffline=vo,o.M3ProcesosOffline=Do,o.M3NotifService=Eo,o.ModelM3Notif=Ao,o.M3Presentaciones=To,o.M3Consultas=No,o.TECLASRAPIDAS=Lo,o.CouchPRDSService=Ro,o.CouchConfigLPService=z,o.CouchCodsPRDSService=Uo,o.CouchPromocionesService=Vo,o.CouchUbicacionesService=_o,o.M3NotificacionesAPP=Bo,o.MathTF=q,o.ServiceM3PackByipo=Go,o.FiltrosDiarioOffLine=Fo,o.CouchPerxipo=Ko,o.CouchDinamByProcesos=Jo,Object.defineProperty(o,"__esModule",{value:!0})});
1
+ !function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/http"),require("@angular/common/http"),require("rxjs/add/operator/map"),require("@angular/core"),require("rxjs/operators"),require("pouchdb"),require("moment"),require("lodash"),require("sf-reglanegocio-grl")):"function"==typeof define&&define.amd?define("sf-reglanegociom3",["exports","@angular/http","@angular/common/http","rxjs/add/operator/map","@angular/core","rxjs/operators","pouchdb","moment","lodash","sf-reglanegocio-grl"],t):t(o["sf-reglanegociom3"]={},o.ng.http,o.ng.common.http,o.rxjs["add/operator/map"],o.ng.core,o.rxjs.operators,o.PouchDB,o.moment_,o._,o.i1$1)}(this,function(o,i,t,e,r,n,a,s,h,c){"use strict";a=a&&a.hasOwnProperty("default")?a["default"]:a;var C=function(){return(C=Object.assign||function(o){for(var t,e=1,r=arguments.length;e<r;e++)for(var n in t=arguments[e])Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n]);return o}).apply(this,arguments)};function u(o,t,e,r){var n,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,e):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(o,t,e,r);else for(var s=o.length-1;0<=s;s--)(n=o[s])&&(a=(i<3?n(a):3<i?n(t,e,a):n(t,e))||a);return 3<i&&a&&Object.defineProperty(t,e,a),a}function l(e,r){return function(o,t){r(o,t,e)}}function d(o,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(o,t)}function O(t,a,s,c){return new(s||(s=Promise))(function(o,e){function r(o){try{i(c.next(o))}catch(t){e(t)}}function n(o){try{i(c["throw"](o))}catch(t){e(t)}}function i(t){t.done?o(t.value):new s(function(o){o(t.value)}).then(r,n)}i((c=c.apply(t,a||[])).next())})}function S(r,n){var i,a,s,o,c={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return o={next:t(0),"throw":t(1),"return":t(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function t(t){return function(o){return function e(o){if(i)throw new TypeError("Generator is already executing.");for(;c;)try{if(i=1,a&&(s=2&o[0]?a["return"]:o[0]?a["throw"]||((s=a["return"])&&s.call(a),0):a.next)&&!(s=s.call(a,o[1])).done)return s;switch(a=0,s&&(o=[2&o[0],s.value]),o[0]){case 0:case 1:s=o;break;case 4:return c.label++,{value:o[1],done:!1};case 5:c.label++,a=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(s=0<(s=c.trys).length&&s[s.length-1])&&(6===o[0]||2===o[0])){c=0;continue}if(3===o[0]&&(!s||o[1]>s[0]&&o[1]<s[3])){c.label=o[1];break}if(6===o[0]&&c.label<s[1]){c.label=s[1],s=o;break}if(s&&c.label<s[2]){c.label=s[2],c.ops.push(o);break}s[2]&&c.ops.pop(),c.trys.pop();continue}o=n.call(r,c)}catch(t){o=[6,t],a=0}finally{i=s=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([t,o])}}}function v(o){var t="function"==typeof Symbol&&o[Symbol.iterator],e=0;return t?t.call(o):{next:function(){return o&&e>=o.length&&(o=void 0),{value:o&&o[e++],done:!o}}}}var f=function(){function o(o,t){this.http=o,this.httpClient=t,this.cargaInicial()}return o.prototype.cargaInicial=function(){var o,t=sessionStorage.getItem("ConfigJSON");if(t){var e=JSON.parse(t);e.ServidorPersonas&&(o=e)}else o=require("G:/Desarrollo/BD/WE8/config.json");this.servidorPersonas=o.ServidorPersonas,this.servidor=o.Servidor,this.servidorGenerales=o.ServidorGenerales,this.servidorM3=o.ServidorM3,this.servidorFEMX=o.ServidorFEMX,this.servidorDocumentos=o.ServidorDocumentos,this.servidorContable=o.ServidorContable,this.servidorPrestamo=o.ServidorPrestamo,this.WebBase=o.WebBase},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.getConfigJson=function(n){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getWithBodyGenerales("Generales/getConfigJson/"+n,null).toPromise()];case 1:return t=o.sent(),e=JSON.parse(t.toString()),this.respOk_getConfigJson(e),[3,3];case 2:return r=o.sent(),console.log(r),[3,3];case 3:return[2]}})})},o.prototype.respOk_getConfigJson=function(o){this.servidorPersonas=o.ServidorPersonas,this.servidor=o.Servidor,this.servidorGenerales=o.ServidorGenerales,this.servidorM3=o.ServidorM3,this.servidorFEMX=o.ServidorFEMX,this.servidorDocumentos=o.ServidorDocumentos,this.servidorContable=o.ServidorContable,this.servidorPrestamo=o.ServidorPrestamo,this.WebBase=o.WebBase},o.prototype.getURLServer=function(){return this.servidor},o.prototype.getURLServerDocs=function(){return this.servidorDocumentos},o.prototype.httpGet=function(o,t){return this.http.get(t+o).map(function(o){return o.json()})},o.prototype.httpGetWithTimeOut=function(o,t,e){return this.http.get(t+o).pipe(n.timeout(e)).map(function(o){return o.json()})},o.prototype.httpGetWithBody=function(o,t,e){return(new i.Headers).append("Content-Type","application/json"),this.httpClient.get(t+o,{params:e}).map(function(o){return o})},o.prototype.httpGetWithBodyTimeOut=function(o,t,e,r){return(new i.Headers).append("Content-Type","application/json"),this.httpClient.get(t+o,{params:e}).pipe(n.timeout(r)).map(function(o){return o})},o.prototype.http_get_blob=function(o,t,e){new i.Headers;return this.httpClient.get(t+o,{responseType:"blob",params:e}).map(function(o){return o})},o.prototype.http_get_arraybuffer=function(o,t,e){new i.Headers;return this.httpClient.get(t+o,{responseType:"arraybuffer",params:e}).map(function(o){return o})},o.prototype.getPrestamo=function(o){return this.httpGet(o,this.servidorPrestamo)},o.prototype.getWithBodyM3TimeOut=function(o,t,e){return this.httpGetWithBodyTimeOut(o,this.servidorM3,t,e)},o.prototype.getWithBodyPrestamo=function(o,t){return this.httpGetWithBody(o,this.servidorPrestamo,t)},o.prototype.getWithBodyM3=function(o,t){return this.httpGetWithBody(o,this.servidorM3,t)},o.prototype.getWithBodyPersonas=function(o,t){return this.httpGetWithBody(o,this.servidorPersonas,t)},o.prototype.getWithBodyGenerales=function(o,t){return this.httpGetWithBody(o,this.servidorGenerales,t)},o.prototype.getWithBodyDocumento=function(o,t){return(new i.Headers).append("responseType","ResponseContentType.Blob"),this.httpClient.get(this.servidorDocumentos+o,{params:t}).map(function(o){return o})},o.prototype.get_blob_Documentos=function(o,t){return this.http_get_blob(o,this.servidorDocumentos,t)},o.prototype.get_arraybuffer_Documentos=function(o,t){return this.http_get_arraybuffer(o,this.servidorDocumentos,t)},o.prototype.getPosts=function(o){return this.httpGet(o,this.servidor)},o.prototype.getPersonas=function(o){return this.httpGet(o,this.servidorPersonas)},o.prototype.getGenerales=function(o){return this.httpGet(o,this.servidorGenerales)},o.prototype.getM3=function(o){return this.httpGet(o,this.servidorM3)},o.prototype.getM3WithTimeOut=function(o,t){return this.httpGetWithTimeOut(o,this.servidorM3,t)},o.prototype.getDocumentos=function(o){return this.httpGet(o,this.servidorDocumentos)},o.prototype.getContable=function(o){return this.httpGet(o,this.servidorContable)},o.prototype.getPostsWithOutJson=function(o){return this.http.get(this.servidor+o).map(function(o){return o})},o.prototype.postServiceHttp=function(o,t){return this.http.post(this.servidor+o,t).map(function(o){return o.statusText})},o.prototype.postServiceResponseHttp=function(o,t){return this.http.post(this.servidor+o,t).map(function(o){return o.json()})},o.prototype.postServiceResponseHttpCallService=function(o,t,e){return this.http.post(e+o,t).map(function(o){return o.json()})},o.prototype.postServiceResponseHttpPrestamos=function(o,t){return this.postServiceResponseHttpCallService(o,t,this.servidorPrestamo)},o.prototype.postServiceHttpOptionsCallService=function(o,t,e,r){var n=new i.RequestOptions({headers:e});return this.http.post(r+o,t,n).map(function(o){return o})},o.prototype.postServiceHttpOptions=function(o,t,e){return this.postServiceHttpOptionsCallService(o,t,e,this.servidor)},o.prototype.postServiceHttpOptionsM3=function(o,t,e){return this.postServiceHttpOptionsCallService(o,t,e,this.servidorM3)},o.prototype.postServiceHttpOptionsDocs=function(o,t,e){return this.postServiceHttpOptionsCallService(o,t,e,this.servidorDocumentos)},o.prototype.postServiceHttpResFullCallService=function(o,t,e){return this.http.post(e+o,t).map(function(o){return o})},o.prototype.postServiceHttpResFull=function(o,t){return this.postServiceHttpResFullCallService(o,t,this.servidor)},o.prototype.postServiceHttpResFullPersonas=function(o,t){return this.postServiceWebApi(o,t,this.servidorPersonas)},o.prototype.postServiceHttpResFullM3=function(o,t){return this.postServiceWebApi(o,t,this.servidorM3)},o.prototype.postServiceHttpResFullFEMX=function(o,t){return this.postServiceWebApi(o,t,this.servidorFEMX)},o.prototype.postServiceHttpResFullGenerales=function(o,t){return this.postServiceHttpResFullCallService(o,t,this.servidorGenerales)},o.prototype.postServiceHttpResFullPrestamos=function(o,t){return this.postServiceHttpResFullCallService(o,t,this.servidorPrestamo)},o.prototype.postServiceWebApi=function(o,t,e){var r=new i.Headers;r.append("Content-Type","application/json");var n=new i.RequestOptions({headers:r});return this.http.post(e+o,t,n).map(function(o){return o})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:i.Http},{type:t.HttpClient}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(i.Http),r.inject(t.HttpClient))},token:o,providedIn:"root"}),o}(),m=function(){function o(){}return o.prototype.convertXmlToJson=function(o){var e;return(0,require("xml2js").parseString)(o,function(o,t){e=t}),e},o.prototype.replaceCharXml=function(o){var t=o.replace(/&gt;/gi,">");return t=(t=t.replace(/&lt;/gi,"<")).replace(/&quot;/gi,"'")},o}(),p=function(){function o(){var o,t;(this.listener=new r.EventEmitter,this.isInstantiated)||(o=this.GetIdKatiosLVL1FromSession(),t=this.GetTipoHubFromSession(),o&&(t&&"WEB"==t.toUpperCase().trim()?(this.database=new a("infomEcc_"+o.toLowerCase().trim(),{auto_compaction:!0}),this.sync(this.GetServer()+"infomEcc_"+o.toLowerCase().trim()),this.isInstantiated=!0,console.log("INSTANCEECC!!¡")):(this.database=new a("infom_"+o.toLowerCase().trim(),{auto_compaction:!0}),this.sync(this.GetServer()+"infom_"+o.toLowerCase().trim()),this.isInstantiated=!0,console.log("INSTANCE!!¡"))))}return o.prototype.GetTipoHubFromSession=function(){var o,t=sessionStorage.getItem("SUbicacion");return t&&(o=JSON.parse(t)).M3HUBS&&o.M3HUBS[0]&&o.M3HUBS[0].Tipo?o.M3HUBS[0].Tipo:null},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.get=function(o){return this.database.get(o)},o.prototype.GetDataPouchBD=function(o){return this.database.get(o)},o.prototype.getChangeListener=function(){return this.listener},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!0,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PROMOCIONES *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.GetKeyDocumentoDB=function(o,t){return o+"?"+t},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),P=function(){function o(){this.listener=new r.EventEmitter,this.isInstantiated||(this.database=new a("CarritoCompras",{auto_compaction:!0}),this.isInstantiated=!0)}return o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.get=function(o){return this.database.get(o)},o.prototype.AddToPouchBDCarritoCompras=function(o,t){var r=this;return t._id=o,this.get(o).then(function(o){return t._rev=o._rev,r.database.put(t)},function(e){return"404"==e.status?r.database.put(t):new Promise(function(o,t){t(e)})})},o.prototype.AddToPouchBDCarritoComprasAsync=function(r,n){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:n._id=r,o.label=1;case 1:return o.trys.push([1,4,,8]),[4,this.get(r)];case 2:return t=o.sent(),n._rev=t._rev,[4,this.database.put(n)];case 3:return o.sent(),[3,8];case 4:return"404"!=(e=o.sent()).status?[3,6]:[4,this.database.put(n)];case 5:return o.sent(),[3,7];case 6:return[2,new Promise(function(o,t){t(e)})];case 7:return[3,8];case 8:return[2]}})})},o.prototype.GetDataPouchBD=function(o){return this.database.get(o)},o.prototype.Delete=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0}),r={live:!0,retry:!0};this.database.sync(e,{options:{retry:!0}}).on("complete",function(o){t.database.sync(e,r)}).on("change",function(o){t.listener.emit(o)}).on("error",function(o){t.database.sync(e,r)})},o.prototype.GetKeyCarritoCompras=function(o,t,e,r,n){return"CC?"+o+"?"+r+"?"+n+"?"+t+"?"+e},o.prototype.ReserBD=function(){var t=this;this.database.destroy().then(function(o){t.database=new a("CarritoCompras",{auto_compaction:!0})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),M=function jo(o,t){this.Atributo=o,this.Valor=t},g=function Ho(){},I=function ko(){this.M3Presentaciones=new Array},y=function xo(){this.M3PACK=null,this.M3PackReglas=null,this.LoM3ListaPrecio=new Array,this.LoM3PrdLista=new I,this.M3Cods=new Array,this.Impuestos=new Array},b=function Wo(){},D=function qo(){this.LoM3PrdGeneral=new Array,this.LoM3PrdAdicionales=new Array,this.M3PACKBYTIPO=new Array,this.M3PrdGrpAsociado=null,this.listImagenes=new Array,this.Impuestos=new Array,this.encontradoLocal=!0},E=function Yo(){},A=function Xo(){},T=function zo(){},N=function Qo(){this.BisProductoPromo=!1,this.BisObsequio=!1,this.Unidad="",this.ClavePrdSRV="",this.ClavePrdUnidad="",this.IdProceso="",this.observacion="",this.SubEstado_o="",this.Estado_o="",this.PathImagen="",this.IDEncRepetido=-1,this.IDEncProcesado=-1,this.IDEncPadre=-1,this.TipoAgrupacion="",this.CodigoBarras="",this.CamposAdicionales=[]},L=function $o(){},R=function Zo(){},U=function ot(){this.ValOtraClasi=0,this.M3PDinamByActividad=new Array,this.dejar_borrar=!0},V=function(){function o(){this.DISPONIBLE=0,this.M3DET=new Array,this.M3DetCupones=new Array,this.M3PImpuestos=new Array,this.M3PDinamByActividad=new Array,this.PromoCombinadas=new Array,this.TipoAgrupacion=""}return o.prototype.GetPriceUnit=function(){return this.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor},o.prototype.GetPriceUnitNeto=function(){return this.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor},o.prototype.SetPriceUnitNeto=function(o){this.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor=o},o.prototype.GetPriceTotal=function(){return this.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor},o}(),_=function tt(){this.M3PDinamByActividad=new Array},B=function et(){},G=s,w=function rt(){this.ValorNeto=0,this.Valor=0,this.ValOtraClasi=0,this.M3ENC=new Array,this.M3OtClasificaciones=new Array,this.lM3PDinamicas=new Array,this.M3PerXProceso=new Array,this.lM3PEncFP=new Array,this.M3FTrabajo=new B,this.M3PEnvios=new Array,this.M3PRecepcion=new Array,this.lM3RegistroTrx=new Array,this.PromosCombinadas=new Array,this.AplPagoEnLinea=!1,this.AplDesdeServer=!1,this.Fecha=G(new Date).format("YYYY-MM-DD")},F=function nt(){this.M3PDinamByActividad=new Array},K=function it(){},J=function at(){},j=function(){function o(){}return o.prototype.add_proceso_generarFE=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3FE/add_proceso_generarFE/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.add_proceso_generarNC=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3FE/add_proceso_generarNC/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.addProcesoGenerarFEAsync=function(r,n,i){return O(this,void 0,void 0,function(){var e;return S(this,function(o){try{return e=r.postServiceHttpResFullM3("M3FE/add_proceso_generarFE/"+n,i).toPromise(),[2,JSON.parse(e)]}catch(t){return[2,null]}return[2]})})},o.prototype.generarCartaPorte=function(o,t,e,r,n,i){o.postServiceHttpResFullFEMX("FEMX/generarCartaPorte/"+t+"/"+e,r).subscribe(function(o){n(o)},function(o){console.error(o.json().Message),i(o.json().Message)})},o.prototype.generarFEAnticipos=function(o,t,e,r,n){o.postServiceHttpResFullFEMX("FEMX/generarFEAnticipos/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.generarNCAnticipos=function(o,t,e,r,n){o.postServiceHttpResFullFEMX("FEMX/generarNCAnticipos/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.getInfoFacturaElectronica=function(r,n){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return e={idKatios:n.trim()},[4,r.getWithBodyM3("M3FE/getInfoFacturaElectronica",e).toPromise()];case 1:return t=o.sent(),[2,JSON.parse(t)]}})})},o.prototype.getHtmlFromFE=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idM3:n},[4,e.getWithBodyM3("M3FE/getHtmlFromFE/"+r,t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.IU_InfoFacturaElectronica=function(e,r,n,i,a){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idKatios:r.trim(),oFactura:n,uTActivo:i,uNActivo:a},[4,e.postServiceHttpResFullM3("M3FE/IU_InfoFacturaElectronica",t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.delInsSeriesxUbic=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3FE/delInsSeriesxUbic/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(JSON.parse(o._body).Message).RESPUESTA[0])})},o}(),H=function(){function o(){}return o.prototype.add_procesoEA=function(o,t,e,r,n){o.postServiceHttpResFullM3("ProcesosM3/add_procesoEA/"+t,e).subscribe(function(o){r(o)},function(o){console.error(o.json().Message),n(o.json().Message)})},o.prototype.M3Get_ProcesosPorCantidad=function(o,t,e,r){o.getM3("ProcesosM3/M3Get_ProcesosPorCantidad/"+t).subscribe(function(o){var t;(t=JSON.parse(o)).RESPUESTA.TP.length===undefined&&(t.RESPUESTA.TP=new Array(t.RESPUESTA.TP)),e(t)},function(o){r(o.error.Message)})},o.prototype.M3Get_ActividadesYProcesos=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/M3Get_ActividadesYProcesos/"+t,e).subscribe(function(o){var t;(t=JSON.parse(o.toString())).RESPUESTA.ACTIVIDADES.length===undefined&&(t.RESPUESTA.ACTIVIDADES=new Array(t.RESPUESTA.ACTIVIDADES)),t.RESPUESTA.ACTIVIDADES.forEach(function(o){o.PROCESOS!==undefined&&o.PROCESOS.length===undefined&&(o.PROCESOS=new Array(o.PROCESOS))}),r(t)},function(o){console.log(o),n(o.error.Message)})},o.prototype.M3Get_M3ProcesosByIdProceso=function(o,t,e,r,n,i){o.getWithBodyM3("ProcesosM3/M3Get_M3ProcesosByIdProceso/"+t+"/"+r,e).subscribe(function(o){var t;(t=JSON.parse(o.toString())).RESPUESTA.SUBESTADOS.length===undefined&&(t.RESPUESTA.SUBESTADOS=new Array(t.RESPUESTA.SUBESTADOS)),t.RESPUESTA.SUBESTADOS.forEach(function(o){o.M3PROCESOS!==undefined&&o.M3PROCESOS.length===undefined&&(o.M3PROCESOS=new Array(o.M3PROCESOS))}),n(t)},function(o){i(JSON.parse(o._body).Message)})},o.prototype.GetM3ProcesosByIdDiario=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={IdDiario:n},[4,e.getWithBodyM3("ProcesosM3/GetM3ProcesosByIdDiario/"+r,t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.M3Get_M3ProcesosByIdM3=function(o,t,e,r,n,i,a,s,c){var u;void 0===s&&(s=!1),void 0===c&&(c=!1),u={IdM3:e,IdProceso:r},c&&(u.bAPLPagosPD=!0),o.getWithBodyM3("ProcesosM3/GetProcesoM3ByIdM3/"+t,u).subscribe(function(o){var t;"0"!=(t=o).M3FTrabajo.IdUbicPre.toString()&&t.M3FTrabajo.IdUbicPre.toString()!=n.toString()&&(s||(t=null)),i(t)},function(o){a(o.error.Message)})},o.prototype.getM3ProcesosByIdM3Retomado=function(o,t,e,r,n){var i;i={idM3Retomado:e},o.getWithBodyM3("ProcesosM3/getM3ProcesosByIdM3Retomado/"+t,i).subscribe(function(o){r(o)},function(o){n(o.error.Message)})},o.prototype.M3Get_M3ProcesosByIdM3Async=function(e,r,n,i,o,a){return void 0===a&&(a=!1),O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={IdM3:n,IdProceso:i},a&&(t.bAPLPagosPD=!0),[4,e.getWithBodyM3("ProcesosM3/GetProcesoM3ByIdM3/"+r,t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.m3_getProcesoM3ByIdDiarioAsync=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idDiario:n},[4,e.getWithBodyM3("ProcesosM3/m3_getProcesoM3ByIdDiario/"+r,t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.m3_get_data_capt_dinam=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/m3_get_data_capt_dinam/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.M3GetProcesoByPersona=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/M3GetProcesoByPersona/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.M3GetProcesoByIdDiarioCierre=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/M3GetProcesoByIdDiarioCierre/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.M3GetProcesosOffLine=function(o,t,e,r,n){o.getWithBodyM3("ProcesosM3/M3GetProcesosOffLine/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.m3_detalleProcesoByProceso=function(o,t,e,r,n){o.getWithBodyM3("M3/m3_detalleProcesoByProceso/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()).RESPUESTA.Detalle)},function(o){n(o)})},o.prototype.validarExistenciaProceso=function(o,t,e,r,n){o.getWithBodyM3("M3/validarExistenciaProceso/"+t,e).subscribe(function(o){var t=JSON.parse(o.toString());r(t)},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o}(),k=function st(){this.ValorTotalMonedero=0,this.ListPromocionesAsociadas=new Array},x=function ct(){this.ValorPorcentaje=0,this.ListObsSKU=new Array,this.PromocionCombinada=null,this.ValorMonedero=0,this.IdCupon=null,this.flags={formaPago:!1}},W=function ut(){},q=function(){function o(){}return o.prototype.round=function(o,t){var e=Math.pow(10,t);return Math.round(+o*e)/e},o.prototype.roundV2=function(o,t){return parseFloat((+(Math.round(+(o+"e"+t))+"e"+-t)).toFixed(t))},o.prototype.toFixed=function(o,t){var e=Math.pow(10,Number(t)+1);return(Number(o)+1/e).toFixed(t)},o}(),Y=s,X=function(){function o(o,t){this.oMathTF=new q,this.operators={"<":function(o,t){return o<t},">":function(o,t){return t<o},"<=":function(o,t){return o<=t},">=":function(o,t){return t<=o},IGUAL:function(o,t){return o==t},DIFF:function(o,t){return o!=t},EN:function(o,t){return o===t},AND:function(o,t){return o&&t},OR:function(o,t){return o||t},"*":function(o,t){return!0},MOD:function(o,t){return o%t==0}},this.goDataUser=o,this.goDataAdicional=t}return o.prototype.VerificarPromociones=function(r,n,i,o,e){var a,s=this,c=new Array,u=new Array,l=new Date;return(this.goM3ENCPROMO=o)?(o.filter(function(t){return e.find(function(o){return t.Tipo==o})}).forEach(function(t){var o=new Date(t.Vigencia),e=new Date(t.Inicio);s.validarEstadosEncPromo(t)&&t.Estado&&l<=o&&e<=l&&(c=new Array,t.M3CONDIAGRUPACION.forEach(function(o){(a=s.VerificarAgrupacionPromo(r,n,i,o,t))&&c.push(a)}),(a=s.GetJRespFromArray(c,t.Tipo,t.Tipo2)).APLCondicion&&(s.ValidarAccion(a,t.JAdicionales),s.RetomarValoresPromocion(t,a),u.push(a)))}),u):null},o.prototype.validarEstadosEncPromo=function(o){var t=!0;return o.EsManual&&!o.EstadoManuales&&(t=!1),o.EsAplCupon&&!o.EstadoAplCupon&&(t=!1),t},o.prototype.VerificarAgrupacionPromo=function(o,t,e,r,n){for(var i,a=new Array,s=0;s<r.M3CONDIPROMO.length;s++){var c,u;if(c=r.M3CONDIPROMO[s],(u=JSON.parse(c.JAdicionales)).ROOT.ACTIVIDAD&&"REGISTRO"!=u.ROOT.ACTIVIDAD)return null;if(i=this.VerificarCondicionesPromo(o,t,e,c),"COMBINADA"==n.Tipo&&"COMBO"==n.Tipo2&&i.APLCondicion&&"OR"==r.Operador.trim().toUpperCase())a.push(i);else{if("AND"==r.Operador.trim().toUpperCase()&&!i.APLCondicion)return i=this.ValidarRespuesta(null);if("OR"==r.Operador.trim().toUpperCase()&&i.APLCondicion)return i;a.push(i)}}return this.GetJRespFromArray(a,n.Tipo,n.Tipo2)},o.prototype.VerificarCondicionesPromo=function(o,t,e,r){var n,i;return n=JSON.parse(r.JAdicionales),i=this.VerificarCondicionContraData(o,t,e,r,n),this.ValidarAccion(i,r.JAdicionales),this.AgregarCondicionOK(i,r),i},o.prototype.AgregarCondicionOK=function(o,t){o.APLCondicion&&(o.IDCondicion=t.IdCondicion)},o.prototype.VerificarCondicionContraData=function(o,t,e,r,n){var i,a,s=this;try{switch(n.ROOT.Estructura.Est){case"LoM3PrdAdicionales":(i=t.LoM3PrdAdicionales.find(function(o){return o.ATRIBUTO.trim()==r.Concepto.trim()&&s.operators[n.ROOT.Estructura.Operacion](o.VALOR.trim(),r.Valor.trim())})).JAdicionales=JSON.stringify(n),a=this.ValidarRespuesta(i);break;case"PRDTO":a=this.VerificarInfoProducto(t.LoM3PrdGeneral[0],r,n);break;case"PRDGRP":a=this.VerificarInfoProductoPRDGRP(t,r,n);break;case"M3DETCONDIPROMO":a=this.VerificacionM3DetalleCondicion(o,t,e,r.M3DETCONDIPROMO,r.Concepto,n);break;case"PROCESO":a=this.VerificarInfoProceso(o,r,n);break;case"ID_PAGO":a=this.VerificarProcesoFormaPago(o,r,n);break;case"ID_LISTAP":a=this.verificarProcesoListaPrecio(t.LoM3PrdGeneral[0].LoM3PrdLista,r,n);break;case"USER":a=this.VerificarInfoUserData(r,n);break;case"ADICIONAL":a=this.VerificarInfoAdicional(r,n);break;default:console.log("No Entro por Detalle!"),a=this.GenerarRespuesta(!1,null)}}catch(c){a=this.GenerarRespuesta(!1,null)}return a},o.prototype.GetJRespFromArray=function(o,t,e){var r,n;if(0<o.length){if(r=o.filter(function(o){return o.APLCondicion})){if("COMBINADA"==t&&"COMBO"==e){var i=[];return r.forEach(function(t){0<=t.IDCondicion.length?t.IDCondicion.forEach(function(t){i.find(function(o){return o==t})||i.push(t)}):i.find(function(o){return o==t.IDCondicion})||i.push(t.IDCondicion)}),{APLCondicion:!0,Accion:null,IDCondicion:i}}var a=new Array;n=0<(a=o.filter(function(o){return null!=o.Accion})).length?a[a.length-1]:o[o.length-1]}else n=this.ValidarRespuesta(null);o.find(function(o){return o.FormaPago})&&(n.FormaPago=!0)}else n=this.ValidarRespuesta(null);return n},o.prototype.GenerarRespuesta=function(o,t){var e;return e={APLCondicion:o,Accion:null},null!=t&&t.ROOT.Accion!==undefined&&(e.Accion=t.ROOT.Accion),e},o.prototype.VerificarClasificacionesProceso=function(o,t,e,r){var n=null;try{var i=t.Accion.Valores;i=i.sort(function(o,t){return o.Cantidad<t.Cantidad?1:t.Cantidad<o.Cantidad?-1:0}),this.AplicarPromoByValores(i,e,e.length),0<e.length&&e.find(function(o){return 1==o.Aplicado})&&this.CalculateTotalPriceFromList(e,o,t,!1,r)}catch(a){n=this.GenerarRespuesta(!1,null),console.log("VerificarClasificacionesProceso"),console.log(a)}return n},o.prototype.procesarCaracteristicaParcial=function(o,t,e,r){var n=null;try{var i=t.Accion.Valores;i=i.sort(function(o,t){return o.Cantidad-t.Cantidad});for(var a=0;a<e.length;a++){var s=a<i.length?i[a].Valor:0;e[a].PUNITNETO=+e[a].PUNITNETO-+e[a].PUNITNETO*(+s/100),e[a].Aplicado=!0}0<e.length&&e.find(function(o){return 1==o.Aplicado})&&this.CalculateTotalPriceFromList(e,o,t,!1,r)}catch(c){n=this.GenerarRespuesta(!1,null),console.log("VerificarClasificacionesProceso"),console.log(c)}return n},o.prototype.AplicarPromoByValores=function(o,t,e){for(var r=e,n=0;n<o.length;n++){var i=o[n].Cantidad,a=o[n].Valor;if(i<=r){var s=0;r%i==0||(s=r%i,this.AplicarPromoByValores(o,t,s),r-=s);for(n=+t.length-+e;n<+t.length-+s;n++)t[n].PUNITNETO=+t[n].PUNITNETO-+t[n].PUNITNETO*(+a/100),t[n].Aplicado=!0;break}}},o.prototype.ArmarNuevoArrayDesdeResiduo=function(o,t){var e=new Array;try{for(var r=o.length-1;t<r;r--)e.push(o[r])}catch(n){console.log("ArmarNuevoArratDesdeResiduo"),console.log(n)}return e},o.prototype.VerificarInfoProceso=function(o,t,e){return o[t.Concepto]&&this.operators[e.ROOT.Estructura.Operacion](o[t.Concepto],t.Valor.trim())?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)},o.prototype.VerificarProcesoFormaPago=function(o,t,e){var r=this.GenerarRespuesta(!0,e);return r.FormaPago=!0,r},o.prototype.verificarProcesoListaPrecio=function(o,t,e){try{var r;r=this.operators[e.ROOT.Estructura.Operacion](o[t.Concepto],t.Valor.trim())?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)}catch(n){r=this.GenerarRespuesta(!1,null)}return r},o.prototype.VerificarInfoProducto=function(o,t,e){try{var r;r=this.operators[e.ROOT.Estructura.Operacion](o[t.Concepto],t.Valor.trim())?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)}catch(n){r=this.GenerarRespuesta(!1,null)}return r},o.prototype.VerificarInfoProductoPRDGRP=function(o,t,e){try{var r;r=this.operators[e.ROOT.Estructura.Operacion](o[t.Concepto],t.Valor.trim())?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)}catch(n){r=this.GenerarRespuesta(!1,null)}return r},o.prototype.VerificarInfoAdicional=function(o,t){return this.goDataAdicional[o.Concepto]!==undefined&&this.operators[t.ROOT.Estructura.Operacion](this.goDataAdicional[o.Concepto],o.Valor.trim())?this.GenerarRespuesta(!0,t):"MOD"==t.ROOT.Estructura.Operacion&&+this.goDataAdicional[o.Concepto]>+o.Valor?this.GenerarRespuesta(!0,t):this.GenerarRespuesta(!1,null)},o.prototype.VerificarInfoUserData=function(o,t){var e,r,n;if(this.goDataUser.UsuarioSistema[o.Concepto]!==undefined&&this.operators[t.ROOT.Estructura.Operacion](this.goDataUser.UsuarioSistema[o.Concepto],o.Valor.trim()))n=this.GenerarRespuesta(!0,t);else{if(this.goDataUser.UsuarioSistema[o.Concepto]&&this.goDataUser.UsuarioSistema[o.Concepto].includes(",")){try{for(var i=v(this.goDataUser.UsuarioSistema[o.Concepto].split(",")),a=i.next();!a.done;a=i.next()){var s=a.value;if(this.operators[t.ROOT.Estructura.Operacion](s,o.Valor.trim()))return this.GenerarRespuesta(!0,t)}}catch(c){e={error:c}}finally{try{a&&!a.done&&(r=i["return"])&&r.call(i)}finally{if(e)throw e.error}}return this.GenerarRespuesta(!1,null)}n=this.GenerarRespuesta(!1,null)}return n},o.prototype.VerificacionM3DetalleCondicion=function(t,e,r,n,o,i){var a,s,c=this;switch(o.trim()){case"PRD_SKP1":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor,e.SKP1)}),a=this.ValidarRespuesta(s);break;case"PRD_SKP1+2":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor,e.SKP1+e.LoM3PrdGeneral[0].SKP2)}),a=this.ValidarRespuesta(s);break;case"PRD_SKU":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),e.LoM3PrdGeneral[0].SKU.toString())}),a=this.ValidarRespuesta(s);break;case"PRD_DISP":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](e.LoM3PrdGeneral[0].DISPONIBLE.toString(),o.Valor.toString())}),a=this.ValidarRespuesta(s);break;case"PRD_TIPO":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),e.TIPO.toString())}),a=this.ValidarRespuesta(s);case"PER_PROCESO":var u;s=undefined,u=t.M3PerXProceso.find(function(o){return o.TipoPersona==n[0].Valor.toString()}),"EN"==i.ROOT.Estructura.Operacion&&u?s=n[0]:"DIFF"!=i.ROOT.Estructura.Operacion||u||(s=n[0]),a=this.ValidarRespuesta(s);break;case"ALMACEN":s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),r.IDUbicacion.toString())}),a=this.ValidarRespuesta(s);break;case"HORARIO_HORA":var l=new Date;s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),l.getHours().toString())}),a=this.ValidarRespuesta(s);break;case"LoM3PrdAdicionales":if(i.ROOT.Estructura.Concepto!==undefined)try{var d=e.LoM3PrdAdicionales.find(function(o){return o.ATRIBUTO==i.ROOT.Estructura.Concepto}).VALOR;s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor.toString(),d.toString())}),a=this.ValidarRespuesta(s)}catch(p){a=this.ValidarRespuesta(null)}else a=this.ValidarRespuesta(null);break;default:switch(o.split("_")[0].trim()){case"PROC":var f=o.split("_")[1].trim();s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor,t[f])}),a=this.ValidarRespuesta(s);break;case"USER":f=o.split("_")[1].trim();s=n.find(function(o){return c.operators[i.ROOT.Estructura.Operacion](o.Valor,c.goDataUser.UsuarioSistema[f])}),a=this.ValidarRespuesta(s);break;default:console.log("No Entro por Detalle!"),a=this.GenerarRespuesta(!1,null)}}return a},o.prototype.ValidarRespuesta=function(o){var t,e;o?(e=JSON.parse(o.JAdicionales),t=this.ValidacionesByJAdicionales(e)?this.GenerarRespuesta(!0,e):this.GenerarRespuesta(!1,null)):t=this.GenerarRespuesta(!1,null);return t},o.prototype.ValidacionesByJAdicionales=function(o){var t=!0;try{if(o.ROOT.VALIDACIONES&&o.ROOT.VALIDACIONES.TIPO)switch(o.ROOT.VALIDACIONES.TIPO){case"VIGENCIA":t=this.ValidarVigencia(o.ROOT.VALIDACIONES.VAL1,o.ROOT.VALIDACIONES.VAL2)}}catch(e){console.log("***********************************Error"),console.log(e)}return t},o.prototype.ValidarVigencia=function(o,t){var e=new Date,r=+this.GetFechaNumber(e),n=+this.GetFechaNumber(o),i=+this.GetFechaNumber(t);return n<=r&&r<=i},o.prototype.GetFechaNumber=function(o){return Y(o).format("YYYYMMDD")},o.prototype.ValidarAccion=function(o,t){var e=JSON.parse(t);null==o.Accion&&e.ROOT.Accion!==undefined&&(o.Accion=e.ROOT.Accion)},o.prototype.RetomarValoresPromocion=function(o,t){t.Promocion={},t.Promocion.Nombre=o.Nombre,t.Promocion.ID=o.IdPromocion,null==t.Accion?t.Accion={Tipo2:o.Tipo2,Tipo:o.Tipo}:(t.Accion.Tipo2||(t.Accion.Tipo2=o.Tipo2),t.Accion.Tipo||(t.Accion.Tipo=o.Tipo))},o.prototype.ProcesarPromocion=function(o,t,e,r){void 0===r&&(r=null);var n=new k,i=this.goDataUser.UsuarioSistema.IDLPrecio.split("-"),a=t.LoM3PrdGeneral[0].LoM3ListaPrecio.find(function(o){return o.IDLISTA==i[0]}),s=0,c="Valor";if(a&&i&&1<i.length)switch(i[1]){case"LB":c="LB",t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=a.LB;break;case"LC":c="LC",t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=a.LC;break;case"LD":c="LD",t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=a.LD}return n.PrecioTotal=t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO,n.PrecioTotalPromocion=0,null!=r&&"CTN"==r&&(s=t.LoM3PrdGeneral[0].LoM3ListaPrecio.find(function(o){return"2"==o.IDLISTA}).PRECIO),this.ProcesarPromoGeneral(o,t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO,n,e,s,c)},o.prototype.ProcesarPromoAfter=function(o,t,e){try{var r=new k;return r.PrecioTotal=t.ValorNeto,r.PrecioTotalPromocion=0,this.ProcesarPromoGeneral(o,t.ValorNeto,r,e)}catch(n){return null}},o.prototype.ProcesarPromoGeneral=function(o,t,e,r,n,i){var a;void 0===n&&(n=0),void 0===i&&(i="Valor");for(var s=new Array,c=t,u=0;u<o.length;u++){var l=o[u];(a=this.ProcesarPromoByTipo(l,c,e,r,i))&&s.push(a)}return this.ValidarMejorPromocion(s,e,n),e.PrecioTotal<0&&(e.PrecioTotal=0),e},o.prototype.ValidarMejorPromocion=function(o,t,e){var r,n,i=o.find(function(o){return"RESTRICCION"==o.Tipo});if(i)t.ListPromocionesAsociadas=new Array(i),t.PrecioTotal=0,t.PrecioTotalPromocion=0,t.ValorTotalMonedero=0;else{var a=this.GetMaxXRegla(o,"EXC",t),s=this.GetMaxXRegla(o,"ACMDIN",t);s<a?this.aplicaPromoEXC(o,t,a):this.aplicaPromoACMDIN(o,t,s),t.ListPromocionesAsociadas=o;try{for(var c=v(o.filter(function(o){return"ACM"==o.Regla.trim().toUpperCase()&&!o.flags.formaPago})),u=c.next();!u.done;u=c.next()){var l=u.value;if(l.Aplicada=!0,0<l.ValorPorcentaje)if(0!=e&&"MONEDERO"==l.Tipo){var d=+e*l.ValorPorcentaje/100;t.PrecioTotal=+e-d,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+d}else{d=+t.PrecioTotal*l.ValorPorcentaje/100;t.PrecioTotal=+t.PrecioTotal-d,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+d}else t.PrecioTotal=+t.PrecioTotal-l.Valor,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+l.Valor;t.ValorTotalMonedero+=l.ValorMonedero}}catch(f){r={error:f}}finally{try{u&&!u.done&&(n=c["return"])&&n.call(c)}finally{if(r)throw r.error}}}return t},o.prototype.aplicaPromoEXC=function(o,t,e){var r;0<e&&((r=o.find(function(o){return o.Valor==e||o.ValorMonedero==e})).Aplicada=!0,t.PrecioTotal=+t.PrecioTotal-r.Valor,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+r.Valor,t.ValorTotalMonedero+=r.ValorMonedero)},o.prototype.aplicaPromoACMDIN=function(o,t,e){var r,n;if(0<e){try{for(var i=v(o.filter(function(o){return"ACMDIN"==o.Regla})),a=i.next();!a.done;a=i.next()){var s=a.value;s.Aplicada=!0,t.ValorTotalMonedero+=s.ValorMonedero}}catch(c){r={error:c}}finally{try{a&&!a.done&&(n=i["return"])&&n.call(i)}finally{if(r)throw r.error}}t.PrecioTotal=+t.PrecioTotal-e,t.PrecioTotalPromocion=+t.PrecioTotalPromocion+e}},o.prototype.GetMaxXRegla=function(o,t,e){var r,n,i=0;try{switch(t){case"ACMDIN":var a=e.PrecioTotal,s=0;try{for(var c=v(o.filter(function(o){return"ACMDIN"==o.Regla.trim().toUpperCase()&&(!o.flags.formaPago||"MONEDERO"==o.Tipo)})),u=c.next();!u.done;u=c.next()){var l=u.value;if(0<l.ValorPorcentaje){var d=a*l.ValorPorcentaje/100;a-=d,s+=d}else a-=l.Valor,s+=l.Valor}}catch(f){r={error:f}}finally{try{u&&!u.done&&(n=c["return"])&&n.call(c)}finally{if(r)throw r.error}}i=s;break;case"EXC":i=Math.max.apply(Math,o.filter(function(o){return o.Regla.trim().toUpperCase()==t&&(!o.flags.formaPago||"MONEDERO"==o.Tipo)}).map(function(o){return o.Valor>o.ValorMonedero?o.Valor:o.ValorMonedero}))}}catch(p){}return i},o.prototype.ProcesarPromoByTipo=function(o,t,e,r,n){void 0===n&&(n="Valor");try{var i,a=new x;if(null==o.Accion||o.Promocion==undefined)return null;a.IDPromocion=o.Promocion.ID,a.Nombre=o.Promocion.Nombre,(i=o.Accion).Regla?a.Regla=i.Regla:a.Regla="EXC",a.Tipo=i.Tipo2;var s=i.Valor;switch(i[n]&&(s=i[n]),i.Tipo2.trim().toUpperCase()){case"DTO_%":a.ListObsSKU=null,a.ValorPorcentaje=+s,a.Valor=+s/100*+t;break;case"DTO_VALOR":a.ListObsSKU=null,a.Valor=s;break;case"DTO_EXACT":a.ListObsSKU=null,a.Valor=+t-+s;break;case"OBSEQ":a.Valor=0,a.ListObsSKU=i.OBSEQUIOS,a.ReglaObseq=i.ReglaObseq,this.ValidarCantidadObsequios(r,i.OBSEQUIOS,a);break;case"MONEDERO":a.ListObsSKU=null,a.Valor=0,a.ValorMonedero=+i.Valor;break;case"CUPON":a.Valor=0,a.ListObsSKU=null,a.IdCupon=i.Valor;break;case"ACTIVA_PROMO":a.Valor=0,a.ListObsSKU=null,a.lIdActivaPromo=i.Valor.split(",");break;case"RESTRICCION_PAGO":case"RESTRICCION":a.Valor=0,a.ListObsSKU=null,a.Tipo=i.Tipo2.trim().toUpperCase();break;default:"COMBINADA"==i.Tipo?(a.Valor=0,a.ListObsSKU=null,a.PromocionCombinada=new W,a.PromocionCombinada.IdPromocionCombinada=a.IDPromocion,a.PromocionCombinada.Tipo2=i.Tipo2.trim().toUpperCase(),a.PromocionCombinada.Nombre=a.Nombre,a.PromocionCombinada.Accion=i,this.ValidarCamposAdicionales(r,a.PromocionCombinada,o)):a=null}return o.FormaPago&&(a.flags.formaPago=!0),a}catch(c){return console.log(c),null}},o.prototype.ValidarCantidadObsequios=function(o,t,e){try{var r=-1;this.goDataAdicional.dCantidad;o.find(function(o){return o.IdPromocion==e.IDPromocion}).M3CONDIAGRUPACION.forEach(function(o){var t=o.M3CONDIPROMO.find(function(o){return"dCantidad"==o.Concepto});r=t?+t.Valor:1}),e.CantidadObseq=r}catch(n){console.log(n)}},o.prototype.ValidarCamposAdicionales=function(o,t,e){switch(t.Tipo2){case"OBSEQ_CIERRE":var r="1";(n=o.find(function(o){return o.IdPromocion==t.IdPromocionCombinada})).M3CONDIAGRUPACION.forEach(function(o){var t=o.M3CONDIPROMO.find(function(o){return"dCantidad"==o.Concepto});r=t?t.Valor:"1"}),t.Accion.CantidadObsq=r;break;case"XCARACTERISTICA":break;case"COMBO":var n;n=o.find(function(o){return o.IdPromocion==t.IdPromocionCombinada}),t.Accion.NumCondiciones||(t.Accion.NumCondiciones=n.M3CONDIAGRUPACION[0].M3CONDIPROMO.length),e.IDCondicion&&(t.Accion.IdCondicion=e.IDCondicion)}},o.prototype.ProcesarCombinada=function(o){try{return this.PromoCombinadasV2(o),o}catch(t){return console.log("ProcesarCombinada"),console.log(t),o}},o.prototype.PromoCombinadasV2=function(e){var o,t,r,n=h.cloneDeep(e.M3ENC);e.PromosCombinadas===undefined&&this.GetCombinadasFromDinamicas(e);for(var i=0;i<e.PromosCombinadas.length;i++){this.AddDinamicaProcesoCombinadas(e);var a=e.PromosCombinadas[i],s=this.GetEsAcumulablePromo(a);switch(r=this.GetEncabezadoByCombi(a,e),a.Tipo2){case"MOD_CANTIDAD":var c=this.ProcesarPromoCombyByListEnc(r,s);this.AplicarReglaModCantidad(c,r,a,s);break;case"OBSEQ_CIERRE":c=this.ProcesarPromoCombyByListEnc(r,s);this.ProcesarPromoObsqCierre(c,a,e,s);break;case"OBSEQ_SUMTOTAL":this.procesarObseqSumTotal(r,a,e);break;case"XCARACTERISTICA":c=this.ProcesarPromoCombyByListEnc(r,s);this.VerificarClasificacionesProceso(r,a,c,s);break;case"XCARACTERISTICAPARCIAL":this.ordenarListaEnc(r,s);c=this.ProcesarPromoCombyByListEnc(r,s);this.procesarCaracteristicaParcial(r,a,c,s);break;case"COMBO":for(var u=!0;u;){c=this.ProcesarPromoCombyByListEnc(r,s);u=this.PromocionCombinadaCombo(c,r,a,s,e)}break;case"DTO_VALORTOTAL":c=this.ProcesarPromoCombyByListEnc(r,s);this.AplReglaCombValorTotal(c,r,a,s);break;case"PROD_APLDESC":this.procesarProductoAplDesc(r,a,e,s);break;default:if(r&&0<r.length){c=this.ProcesarPromoCombyByListEnc(r,s);this.CalcularPromocionesByListaPrec(c,r,a,s)}}}var l=function(t){var o=t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor;e.M3ENC.find(function(o){return o.ID==t.ID}).M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor=o};try{for(var d=v(n),f=d.next();!f.done;f=d.next()){l(f.value)}}catch(p){o={error:p}}finally{try{f&&!f.done&&(t=d["return"])&&t.call(d)}finally{if(o)throw o.error}}return e},o.prototype.ordenarListaEnc=function(o,t){t?o.sort(function(o,t){return+t.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor-+o.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor}):o.sort(function(o,t){return+t.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor-+o.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor})},o.prototype.AplReglaCombValorTotal=function(o,t,e,r){var n=+e.Accion.Valor,i=o.reduce(function(o,t){return o+Number(t.PUNITNETO)},0);console.debug(i);for(var a,s=0,c=0;c<o.length;c++)s+=a=o[c].PUNITNETO/i*n,o[c].Aplicado=!0,o[c].PUNITNETO=o[c].PUNITNETO-a;(s<n||n<s)&&(console.debug("Encontre diferencia en promos combinadas: "+n+" vs "+s),o[o.length-1].PUNITNETO=o[o.length-1].PUNITNETO-(n-s)),o.find(function(o){return o.Aplicado})&&(console.debug("AplicarReglaModCantidad"),this.CalculateTotalPriceFromList(o,t,e,!0,r))},o.prototype.procesarObseqSumTotal=function(o,t,n){var e,r,i=+t.Accion.Valor,a=0,s=0,c=1,u=[],l=[],d=new to(null,null,null),f=0,p=0,h=function(t){c=1;for(var o=+t.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor,e=+t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor;c<=e;){a+=o,c++;var r=l.find(function(o){return o.Id==t.ID});r?r.Cantidad++:l.push({Id:t.ID,Cantidad:1}),i<=a+p&&(f+=a,P.agregarProductoAProductosHijosSumTotal(u,n,l),s++,l=[],p=a-i,a=0)}},P=this;try{for(var M=v(o),m=M.next();!m.done;m=M.next()){h(m.value)}}catch(g){e={error:g}}finally{try{m&&!m.done&&(r=M["return"])&&r.call(M)}finally{if(e)throw e.error}}if(0<u.length){var C=d.loadM3PEncItemsFromPromocionCombo(n,u,t.Accion.Codigo,f,1);d.armarListaObsequiosCombiSKU(t,C,s),n.oM3RegService=d}},o.prototype.agregarProductoAProductosHijosSumTotal=function(e,r,o){var t,n,i,a,s=new to(null,null,null),c=function(t){if(t){var o=r.M3ENC.find(function(o){return o.ID==t.Id});o&&0<+(a=o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto})).Valor&&(a.Valor=(+a.Valor-t.Cantidad).toString(),i=h.cloneDeep(o),s.ValoresCalculadosProceso(i,t.Cantidad),e.push(i),u.agregarAProductosQuitarCombi(r,i,t.Cantidad))}},u=this;try{for(var l=v(o),d=l.next();!d.done;d=l.next()){c(d.value)}}catch(f){t={error:f}}finally{try{d&&!d.done&&(n=l["return"])&&n.call(l)}finally{if(t)throw t.error}}},o.prototype.getProdutoPromoComboSumTotal=function(o,t){var e,r=o.find(function(o){return o.ID==t.ID});if(r&&0<+(e=r.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto})).Valor)return e.Valor=(+e.Valor-1).toString(),h.cloneDeep(r);return null},o.prototype.GetListaPrecios=function(o,t){for(var e=new Array,r=0;r<t.length;r++)o.filter(function(o){return o.ID==t[r].ID}).forEach(function(o){e.push(o)});return e},o.prototype.PromocionCombinadaCombo=function(o,t,e,r,n){var i=this,a=!1;try{for(var s=+e.Accion.NumCondiciones,c=+e.Accion.Valor,u=new Array,l=0,d=0,f=0,p=new Array,h=void 0,P=1;P<=s;P++){var M=this.BuscarEncByPromoYCond(t,P.toString(),e.IdPromocionCombinada.toString());u.push(this.GetListaPrecios(o,M))}if(this.filtrarListaCondicionesCombo(u,t),0<u.length){l=u[0].length;for(var m=1;m<u.length;m++){var C=u[m].length;C<l&&(l=C)}1<l&&(l=1);for(var g=0;g<u.length;g++)for(var I=u[g],y=0;y<l;y++){var O=I[y];f+=+o.find(function(o){return o.ID==O.ID&&o.Indice==O.Indice}).PUNITNETO}d=100-100*+c/f;for(g=0;g<u.length;g++)for(I=u[g],y=0;y<l;y++){O=I[y];o.filter(function(o){return o.ID==O.ID}).forEach(function(o){if(o.Indice==O.Indice){if(!o.PromoAplicada){var t=o.PUNITNETO;o.PUNITNETO=t-t*d/100,o.PromoAplicada=!0}i.agregarProductoAProductosHijos(p,n,o)}else o.PUNITNETO=0}),a=!0}a&&(h=new to(null,null,null),this.CalculateTotalPriceFromList(o,p,e,!0,r),h.loadM3PEncItemsFromPromocionCombo(n,p,e.Accion.Codigo,e.Accion.Valor,1))}this.limpiarEncItemPrdCondi(t)}catch(S){console.log("PromocionCombinadaCombo"),console.log(S)}return a},o.prototype.filtrarListaCondicionesCombo=function(o,r){for(var t,e,n=0;n<o.length;n++){var i=[],a=function(t){var o=r.find(function(o){return o.ID==t.ID});if(o){var e=o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor;if(o.PrdCondi=o.PrdCondi?o.PrdCondi:0,e>o.PrdCondi)return i=[t],o.PrdCondi++,"break"}};try{for(var s=v(o[n]),c=s.next();!c.done;c=s.next()){if("break"===a(c.value))break}}catch(u){t={error:u}}finally{try{c&&!c.done&&(e=s["return"])&&e.call(s)}finally{if(t)throw t.error}}o[n]=i}},o.prototype.limpiarEncItemPrdCondi=function(o){o.forEach(function(o){delete o.PrdCondi})},o.prototype.agregarAProductosQuitarCombi=function(o,t,e){var r;void 0===e&&(e=1),o.ProductosCombi||(o.ProductosCombi=[]),(r=o.ProductosCombi.find(function(o){return o.ID==t.IdProducto}))?r.Cantidad+=-1*e:o.ProductosCombi.push({ID:t.IdProducto,Cantidad:-1*e})},o.prototype.agregarProductoAProductosHijos=function(o,t,e){var r=this.getProdutoPromoCombo(t.M3ENC,e);r&&(new to(null,null,null).ValoresCalculadosProceso(r,1),o.push(r),this.agregarAProductosQuitarCombi(t,r))},o.prototype.getProdutoPromoCombo=function(o,t){var e,r=o.find(function(o){return o.ID==t.ID});if(r&&0<+(e=r.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto})).Valor)return e.Valor=(+e.Valor-1).toString(),h.cloneDeep(r);return null},o.prototype.AddtoHmPrecios=function(o,t){var e=o.find(function(o){return o.ID==t});return e?e.Indice=+e.Indice+1:(e={ID:t,Indice:0},o.push(e)),e.Indice},o.prototype.BuscarEncByPromoYCond=function(o,t,e){for(var r=new Array,n=0;n<o.length;n++)try{var i=o[n];if(console.debug(i.IdEncPadre),!(i.IdEncPadre&&0<i.IdEncPadre)){var a=i.M3DET.find(function(o){return"PROMOCOMBI"==o.NombreConcepto}),s=i.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto});if(a&&s&&0<+s.Valor){var c=JSON.parse(a.Valor).find(function(o){return o.IdPromocionCombinada==e});if(c){var u=c.Accion.IdCondicion;u&&(u.length?u.find(function(o){return o==t})&&r.push(i):u==t&&r.push(i))}}}}catch(l){}return r},o.prototype.GetEsAcumulablePromo=function(o){try{if(o.Accion.Regla&&"ACM"==o.Accion.Regla)return!0}catch(t){console.log("Error GetEsAcumulable"),console.log(t)}return!1},o.prototype.procesarProductoAplDesc=function(o,e,t,r){var n=this,i=new Array,a=[],s=e.Accion.skuAplDesc,c=+e.Accion.maxNumDesc,u=0;try{if(c){for(c=o.reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},0)*c,t.M3ENC.forEach(function(t){s.find(function(o){return o.SKU==t.IdProducto})&&a.push(t)}),i=this.ProcesarPromoCombyByListEnc(a,r);u<c&&u<i.length;)i[u].PUNITNETO-=+i[u].PUNITNETO*(+e.Accion.Valor/100),u++;this.CalculateTotalPriceFromList(i,a,e,!0,r)}else o.forEach(function(t){u=0;var o=s.find(function(o){return o.SKU==t.IdProducto});if(o)for(a.push(t),c=+t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor*o.Cantidad,n.ProcesarPromoCombyByListEncByPrd(t,r,i);u<c;)i[u].PUNITNETO-=+i[u].PUNITNETO*(+e.Accion.Valor/100),u++}),this.CalculateTotalPriceFromList(i,a,e,!0,r)}catch(l){}},o.prototype.ProcesarPromoObsqCierre=function(o,t,e,r){var n,i;e.ProductosCombi=[];var a=+t.Accion.CantidadObsq,s=0,c=0,u=0,l=0,d=[],f=[],p=new to(null,null,null);p.obsequiosExc=!0,p.oListaObsequios=t.Accion.OBSEQUIOS,p.obsequiosCantidad=0;var h=function(t){c+=t.PUNITNETO,s++;var o=d.find(function(o){return o.Id==t.ID});o?o.Cantidad++:d.push({Id:t.ID,Cantidad:1}),s===a&&(l+=c,P.agregarProductoAProductosHijosSumTotal(f,e,d),u++,d=[],s=0)},P=this;try{for(var M=v(o),m=M.next();!m.done;m=M.next()){h(m.value)}}catch(g){n={error:g}}finally{try{m&&!m.done&&(i=M["return"])&&i.call(M)}finally{if(n)throw n.error}}if(t.Accion.Codigo||console.error("El código del combo no esta configurado en M3DETCONDIPROMO"),0<f.length&&t.Accion.Codigo){var C=p.loadM3PEncItemsFromPromocionCombo(e,f,t.Accion.Codigo,l,1);p.armarListaObsequiosCombiSKU(t,C,u),e.oM3RegService=p}},o.prototype.AplicarReglaModCantidad=function(o,t,e,r){var n,i=e.Accion,a=i.Cantidad,s=+i.Valor/+a;if(a<=(n=o.length)){if(n%a==0);else n-=n%a;for(var c=0;c<n;c++)o[c].PUNITNETO>s&&(o[c].PUNITNETO=s,o[c].Aplicado=!0);o.find(function(o){return o.Aplicado})&&(console.debug("AplicarReglaModCantidad"),this.CalculateTotalPriceFromList(o,t,e,!0,r))}},o.prototype.GetCombinadasFromDinamicas=function(o){try{var t=o.lM3PDinamicas.find(function(o){return"COMBINADA"==o.Nombre}).Valor,e=JSON.parse(t);o.PromosCombinadas=e}catch(r){}},o.prototype.AddDinamicaProcesoCombinadas=function(o){var t;if(t=o.lM3PDinamicas.find(function(o){return"COMBINADA"==o.Nombre})){for(var e=JSON.parse(t.Valor),r=0;r<e.length;r++){o.PromosCombinadas.find(function(o){return o.IdPromocionCombinada==e[r].IdPromocionCombinada})||o.PromosCombinadas.push(e[r])}t.Valor=JSON.stringify(o.PromosCombinadas)}else{var n=new R;n.Nombre="COMBINADA",n.Valor=JSON.stringify(o.PromosCombinadas),o.lM3PDinamicas.push(n)}},o.prototype.CalcularPromocionesByListaPrec=function(o,t,e,r){var n=e.Tipo2,i=0,a=0,s=+n.split("X")[1],c=+n.split("X")[0]-+s,u=0,l=!1;1<s.toString().split(".").length&&(u=+s.toString().split(".")[1],s=+s.toString().split(".")[0]);var d=0;if(0<(o=o.sort(function(o,t){return o.PUNITNETO<t.PUNITNETO?1:o.PUNITNETO>t.PUNITNETO?-1:0})).length){for(var f=+o.length-1;d<o.length&&d<=f;){for(a=i=0;i<s;)i++,d++;for(;a<c&&d<=f;)o[f].PUNITNETO=0==u?(l=!0,.01):(l=!0,+o[f].PUNITNETO*(+u/10)),a++,f--}l&&this.CalculateTotalPriceFromList(o,t,e,!1,r)}},o.prototype.CalculateTotalPriceFromList=function(o,t,e,r,n){for(var i=0,a=0,s=0;s<t.length;s++){var c,u=t[s],l=o.filter(function(o){return o.ID==u.ID}).reduce(function(o,t){return+o+ +t.PUNITNETO},0);c=u.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor,u.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor=l,!this.ValidarSiTodosAPLPromoCombinada(o,u)&&r||n?(i=this.GetValorPromoAnterior(o,u),a=this.GetValorPromoACt(u,i,l,c,n),n?i=+u.M3DET.find(function(o){return"PRECIOTOTALSINDTO"==o.NombreConcepto}).Valor-c:u.M3DET.find(function(o){return"VAL_PROMOC"==o.NombreConcepto}).Valor=i.toString()):(u.M3DET.find(function(o){return"NOMB_PROMOC"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"NOMB_PROMOC"==o.NombreConcepto}).Valor=""),u.M3DET.find(function(o){return"VAL_PROMOC"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"VAL_PROMOC"==o.NombreConcepto}).Valor=""),u.M3DET.find(function(o){return"NOMB_PRO_COMBI"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"NOMB_PRO_COMBI"==o.NombreConcepto}).Valor=""),u.M3DET.find(function(o){return"VAL_PRO_COMBI"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"VAL_PRO_COMBI"==o.NombreConcepto}).Valor=""),u.M3DET.find(function(o){return"ID_PRO_COMBI"==o.NombreConcepto})&&(u.M3DET.find(function(o){return"ID_PRO_COMBI"==o.NombreConcepto}).Valor=""),this.QuitarLasPromosDirectas(u),this.QuitarLasPromosCombinadas(u),a=+u.M3DET.find(function(o){return"PRECIOTOTALSINDTO"==o.NombreConcepto}).Valor-+u.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor),this.SetValorPromociones(u,a+i),this.AgregarListaPromo(u,e,a),this.RecalcularPrecioUnitFromTotal(u,l)}},o.prototype.QuitarLasPromosDirectas=function(o){try{o.M3DET.filter(function(o){return o.NombreConcepto.toUpperCase().startsWith("VAL_PROMOC_")}).forEach(function(o){o.Valor="0"})}catch(t){}},o.prototype.QuitarLasPromosCombinadas=function(o){try{o.M3DET.filter(function(o){return o.NombreConcepto.toUpperCase().startsWith("VAL_PRO_COMBI_")}).forEach(function(o){o.Valor="0"})}catch(t){}},o.prototype.RecalcularPrecioUnitFromTotal=function(o,t){o.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor=(+t/+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor).toString()},o.prototype.ValidarSiTodosAPLPromoCombinada=function(o,t){return!o.filter(function(o){return o.ID==t.ID}).find(function(o){return o.PUNITNETO==t.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor})},o.prototype.GetValorPromoAnterior=function(o,t){try{var e=t.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor;return+o.filter(function(o){return o.ID==t.ID&&o.PUNITNETO==e}).length*+t.M3DET.find(function(o){return"VUNITPROMO"==o.NombreConcepto}).Valor}catch(r){return 0}},o.prototype.GetValorPromoACt=function(o,t,e,r,n){try{return n?+r-+e:+ +o.M3DET.find(function(o){return"PRECIOTOTALSINDTO"==o.NombreConcepto}).Valor-+t-+e}catch(i){console.log("Error GetValorPromoACt: "),console.log(i)}},o.prototype.SetValorPromociones=function(o,t){try{o.M3DET.find(function(o){return"TOTALPROMO"==o.NombreConcepto}).Valor=(Math.round(100*t)/100).toString(),o.M3DET.find(function(o){return"VUNITPROMO"==o.NombreConcepto}).Valor=(+Math.round(100*t)/100/+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor).toString()}catch(e){}},o.prototype.AgregarListaPromo=function(o,t,e){var r,n,i;r=o.M3DET.find(function(o){return"NOMB_PRO_COMBI"==o.NombreConcepto}),n=o.M3DET.find(function(o){return"VAL_PRO_COMBI"==o.NombreConcepto}),i=o.M3DET.find(function(o){return"ID_PRO_COMBI"==o.NombreConcepto}),r||(r=new T,n=new T,i=new T,r.NombreConcepto="NOMB_PRO_COMBI",n.NombreConcepto="VAL_PRO_COMBI",i.NombreConcepto="ID_PRO_COMBI",r.Valor="",n.Valor="",i.Valor="",o.M3DET.push(r),o.M3DET.push(n),o.M3DET.push(i)),r.Valor=r.Valor+t.Nombre+",",i.Valor=i.Valor+t.IdPromocionCombinada+",",n.Valor=n.Valor+e.toString()+",";for(var a=r.Valor.replace(/.$/,"").split(","),s=i.Valor.replace(/.$/,"").split(","),c=(n.Valor.replace(/.$/,"").split(","),0);c<s.length;c++)this.actualizarOCrearPDinamica(o.M3DET,a[c],"NOMB_PRO_COMBI_"+c),this.actualizarOCrearPDinamica(o.M3DET,a[c],"ID_PRO_COMBI_"+c),this.actualizarOCrearPDinamica(o.M3DET,a[c],"VAL_PRO_COMBI_"+c)},o.prototype.actualizarOCrearPDinamica=function(o,t,e){var r=o.find(function(o){return o.NombreConcepto==t});r?r.Valor=e:((r=new T).NombreConcepto=t,r.Valor=e,o.push(r))},o.prototype.GetEncabezadoByCombi=function(t,o){var e=this;try{return o.M3ENC.filter(function(o){return o.PromoCombinadas===undefined&&e.SetPromoCombinadaENC(o),!(0<o.IdEncPadre)&&(!!(o.PromoCombinadas&&0<+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor)&&(0<o.PromoCombinadas.length&&o.PromoCombinadas.find(function(o){return o.IdPromocionCombinada==t.IdPromocionCombinada})))})}catch(r){return null}},o.prototype.SetPromoCombinadaENC=function(o){try{var t;(t=o.M3DET.find(function(o){return"PROMOCOMBI"==o.NombreConcepto}))&&(o.PromoCombinadas=JSON.parse(t.Valor))}catch(e){}},o.prototype.ProcesarPromoCombyByListEnc=function(o,t){for(var e=new Array,r=0;r<o.length;r++){var n,i,a=o[r];n=+a.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor,i=t?+a.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor:+a.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor;for(var s=0;s<n;s++)e.push({Indice:s,PUNITNETO:i,ID:a.ID})}return e},o.prototype.ProcesarPromoCombyByListEncByPrd=function(o,t,e){var r,n;e=new Array;r=+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor,n=t?+o.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor:+o.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor;for(var i=0;i<r;i++)e.push({Indice:i,PUNITNETO:n,ID:o.ID,IDPRODUCTO:o.IdProducto})},o.prototype.ProcesarCombinadaXporY=function(o,t){},o.prototype.get_total_fidelizacion=function(o){var t=0;return o!==undefined&&o.M3ENC!==undefined&&(t=o.M3ENC.filter(function(o){return 0<+o.M3DET.find(function(o){return"FIDELIZACION"==o.NombreConcepto}).Valor}).reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"FIDELIZACION"==o.NombreConcepto}).Valor/100*+t.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor},0)),t},o.prototype.get_value_fidelizacion_by_proceso=function(o,t){var e=o.ValorNeto,r=0,n=this.get_list_condi_promo_by_actividad(t,"PAGO","MONEDERO");if(o.lM3PEncFP)for(var i=0;i<o.lM3PEncFP.length;i++){var a=o.lM3PEncFP[i],s=this.validate_condi_by_forma_pago(a,n);if(0<s.length){var c=a.Valor-a.ValCambio;r+=this.calculate_fidelizacion_by_forma_pago(e,o.M3ENC,c,s,t)}}return r=this.oMathTF.round(r,2)},o.prototype.getRestriccionesTipoPagoActivas=function(r,o){var n=new Array;if(0<r.length)for(var t=0;t<o.length;t++){var e=o[t].M3DET;if(0<+o[t].M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor){var i=e.find(function(o){return"ID_PROMOC"==o.NombreConcepto});if(i)for(var a=i.Valor.split(","),s=function(o){var t=+a[o],e=r.find(function(o){return o.IdPromocion==t});e&&!n.find(function(o){return o.IdPromocion==t})&&n.push(e)},c=0;c<a.length;c++)s(c)}}return n},o.prototype.getRestriccionesTipoPagoActivasFromEncPromo=function(o,t){var e=this.get_list_condi_promo_by_actividad(o,"PAGO","RESTRICCION_PAGO");return this.getRestriccionesTipoPagoActivas(e,t)},o.prototype.m3_get_movimientos_fidelizacion=function(o,t,e,r,n){o.getWithBodyM3("M3/m3_get_movimientos_fidelizacion/"+t,e).subscribe(function(o){var t,e=JSON.parse(o.toString());e.MOVS.MOV.length?t=e.MOVS.MOV:(t=new Array).push(e.MOVS.MOV),r(t)},function(o){n(o.error.Message)})},o.prototype.validate_condi_by_forma_pago=function(o,t){for(var e=new Array,r=0;r<t.length;r++){var n=t[r],i=JSON.parse(n.JAdicionales);switch(n.Concepto.trim()){case"ID_PAGO":i.ROOT.Estructura&&i.ROOT.Estructura.Operacion&&"DIFF"==i.ROOT.Estructura.Operacion?n.Valor="^(?!("+n.Valor+")\\b)\\w+$":n.Valor="^("+n.Valor+")$",new RegExp(n.Valor,"i").test(o.IdTipoPago.toString())&&e.push(n)}}return e},o.prototype.get_list_condi_promo_by_actividad=function(o,t,e){var r=new Array,n=new Date;if(o)for(var i=0;i<o.length;i++){var a=o[i],s=new Date(a.Vigencia),c=new Date(a.Inicio);if(a.Estado&&n<=s&&c<=n&&a.Tipo2==e)for(var u=0;u<a.M3CONDIAGRUPACION.length;u++)for(var l=a.M3CONDIAGRUPACION[u],d=0;d<l.M3CONDIPROMO.length;d++){var f=l.M3CONDIPROMO[d];if(f.JAdicionales){var p=JSON.parse(f.JAdicionales);p.ROOT.ACTIVIDAD&&p.ROOT.ACTIVIDAD==t&&r.push(f)}}}return r},o.prototype.calculate_fidelizacion_by_forma_pago=function(o,t,e,r,n){var i,a,s,c,u,l,d=0,f=e/o,p=0;try{for(var h=v(t),P=h.next();!P.done;P=h.next()){var M=P.value;u=[],l=M.M3DET.find(function(o){return"ID_PROMOC"==o.NombreConcepto}),p=+M.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor;var m=M.M3DET.find(function(o){return"PRECIOSR"==o.NombreConcepto});null!=m&&null!=m.Valor&&(p=+m.Valor),l&&l.Valor&&(u=l.Valor.split(","));var C=function(t){if(u.find(function(o){return+o==t.IdPromocion})){var o=n.find(function(o){return o.IdPromocion==t.IdPromocion}),e=g.validarRedondeo(o,p*g.getPorcentajeFidelizacionFromEncPromo(o)/100)*f;return d+=e,"break"}},g=this;try{for(var I=v(r),y=I.next();!y.done;y=I.next()){if("break"===C(y.value))break}}catch(O){s={error:O}}finally{try{y&&!y.done&&(c=I["return"])&&c.call(I)}finally{if(s)throw s.error}}}}catch(S){i={error:S}}finally{try{P&&!P.done&&(a=h["return"])&&a.call(h)}finally{if(i)throw i.error}}return d},o.prototype.getPorcentajeFidelizacionFromEncPromo=function(o){try{var t=JSON.parse(o.JAdicionales);if(t.ROOT&&t.ROOT.Accion&&t.ROOT.Accion.Valor)return t.ROOT.Accion.Valor}catch(e){}return 0},o.prototype.validarRedondeo=function(o,t){try{var e=JSON.parse(o.JAdicionales);if(e.ROOT&&e.ROOT.Accion&&e.ROOT.Accion.Redondeo)return this.oMathTF.round(t,+e.ROOT.Accion.Redondeo)}catch(r){return t}return t},o.prototype.add_dinamica_fidelizacion_to_proceso=function(o,t){var e=0;if(t&&(e=this.get_value_fidelizacion_by_proceso(o,t)),0<e){var r=new R;r.Nombre="FIDELIZACION",r.Valor=e.toString(),o.lM3PDinamicas.push(r)}return o},o.prototype.validate_doc_fidelizacion=function(o,t,e,r,n){o.getWithBodyM3("M3/validate_doc_fidelizacion/"+t,e).subscribe(function(o){var t;t=JSON.parse(o.toString()).RESPUESTA.M3SaldosXCuenta,r(t)},function(o){n(o.error.Message)})},o.prototype.actualizar_saldo_fidelizacion=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/actualizar_saldo_fidelizacion/"+t,e).subscribe(function(o){e.pago.idDiario=o._body.replace('"',"").replace('"',""),r(e.pago)},function(o){n(o)})},o.prototype.m3_generar_bono_devolucion=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/m3_generar_bono_devolucion/"+t,e).subscribe(function(o){r(o)},function(o){n(o)})},o.prototype.m3InsertSaldoXCuenta=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/m3InsertSaldoXCuenta/"+t,e).subscribe(function(o){r()},function(o){n(o)})},o.prototype.getCantidadTotal=function(o){if(o){var t=o.filter(function(o){return 0<+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor}).reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},0);return 0==t?0:t}return 0},o}(),z=function(){function o(){this.listener=new r.EventEmitter,this.aplSyncCouchAuto=!0,this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.getFlagSyncCouch=function(){var o,t,e=sessionStorage.getItem("SUbicacion"),r=!0;return e&&(o=JSON.parse(e)).M3HUBS&&o.M3HUBS[0]&&o.M3HUBS[0].Configuracion&&null!=(t=JSON.parse(o.M3HUBS[0].Configuracion)).SyncCouchAuto&&t.SyncCouchAuto!=undefined&&(r=t.SyncCouchAuto),r},o.prototype.CrearPouchSincronizacion=function(){this.idkatios=this.GetIdKatiosLVL1FromSession(),this.database=new a("ConfigLP_"+this.idkatios,{auto_compaction:!0}),console.debug("adapter"),console.debug(this.database.adapter),this.syncCouch(),this.isInstantiated=!0,console.log("********************************** INSTANCE CONFIGLP *****************************************")},o.prototype.syncCouch=function(){this.idkatios?this.sync(this.GetServer()+"configlp_"+this.idkatios.toLowerCase()):this.CrearPouchSincronizacion()},o.prototype.getUbicacion=function(){var o,t=sessionStorage.getItem("SUbicacion");return t&&(o=JSON.parse(t)).IDUbicacion?o.IDUbicacion:null},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.Destroy=function(o){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.prototype.sync=function(o){var t=this;this.aplSyncCouchAuto=this.getFlagSyncCouch();var e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:this.aplSyncCouchAuto,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO CONFIGLP *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO CONFIGLP *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getInfo=function(){return this.database.info()},o.prototype.getChangeListener=function(){return this.listener},o.prototype.deleteLp=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.prototype.DeleteAllDocs=function(){var t=this;this.database.allDocs({include_docs:!0}).then(function(o){return o.rows.map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return t.database.bulkDocs(o)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Q=function(){function o(o){this.oMathTF=new q,this.aplPreciosDinamicos=!1,this.gsidkatios=o,this.GetKatiosM3FromSession()}return o.prototype.GetKatiosM3FromSession=function(){var o=localStorage.getItem("ConfigKatios"+this.gsidkatios.toUpperCase());if(o!==undefined&&null!=o){var t=JSON.parse(o);if(t&&t.Katios&&t.Katios.KatiosM3){var e=t.Katios.KatiosM3.find(function(o){return"APLLPDINAMICOS"==o.Llave.toUpperCase()});e&&"1"==e.Valor&&(this.aplPreciosDinamicos=!0)}}},o.prototype.AsignarListaPrecioM3Pack=function(g,I,y){return O(this,void 0,void 0,function(){var t,e,r,n,i,a,s,c,u,l,d,f,p,h,P,M,m,C;return S(this,function(o){switch(o.label){case 0:o.trys.push([0,5,6,7]),s=v(g.M3PrdGrpAsociado),c=s.next(),o.label=1;case 1:return c.done?[3,4]:(u=c.value,[4,this.AsignarListaPrecio(u.M3GRP,I,y)]);case 2:o.sent(),o.label=3;case 3:return c=s.next(),[3,1];case 4:return[3,7];case 5:return l=o.sent(),t={error:l},[3,7];case 6:try{c&&!c.done&&(e=s["return"])&&e.call(s)}finally{if(t)throw t.error}return[7];case 7:o.trys.push([7,18,19,20]),d=v(g.LoM3PrdGeneral),f=d.next(),o.label=8;case 8:if(f.done)return[3,17];p=f.value,o.label=9;case 9:o.trys.push([9,14,15,16]),h=v(p.M3PACK),P=h.next(),o.label=10;case 10:return P.done?[3,13]:(M=P.value,[4,this.AsignarListaPrecio(M.M3GRP,I,y)]);case 11:o.sent(),o.label=12;case 12:return P=h.next(),[3,10];case 13:return[3,16];case 14:return m=o.sent(),i={error:m},[3,16];case 15:try{P&&!P.done&&(a=h["return"])&&a.call(h)}finally{if(i)throw i.error}return[7];case 16:return f=d.next(),[3,8];case 17:return[3,20];case 18:return C=o.sent(),r={error:C},[3,20];case 19:try{f&&!f.done&&(n=d["return"])&&n.call(d)}finally{if(r)throw r.error}return[7];case 20:return[2,""]}})})},o.prototype.AsignarListaPrecio=function(d,f,p){return O(this,void 0,void 0,function(){var t,a,s,c,u,e,l=this;return S(this,function(o){switch(o.label){case 0:if(this.GetKatiosM3FromSession(),null==f||!f.UsuarioSistema||f.UsuarioSistema.IDLPrecio===undefined||-1==f.UsuarioSistema.IDLPrecio||!d)return[3,5];t=function(){var t,e,r,n,i;return S(this,function(o){switch(o.label){case 0:if(s=d.LoM3PrdGeneral[u],t=f.UsuarioSistema.IDLPrecio.split("-"),!((c=s.LoM3ListaPrecio.find(function(o){return o.IDLISTA==t[0]}))&&t&&1<t.length))return[3,4];if(a.aplPreciosDinamicos)return[3,1];switch(t[1]){case"LB":c.PRECIO=c.LB;break;case"LC":c.PRECIO=c.LC;break;case"LD":c.PRECIO=c.LD}return[3,4];case 1:return o.trys.push([1,3,,4]),[4,(new z).get(t[0])];case 2:return e=o.sent(),(r=JSON.parse(e.JConfiguracion))&&r.Factores&&0<r.Factores.length&&(n=parseFloat(r.Factores.find(function(o){return o.Nombre==t[1]}).Factor),c.PRECIO=a.oMathTF.round(c.PRECIO*n,2),c.M3Presentaciones.forEach(function(o){o.VALOR=l.oMathTF.round(o.VALOR*n,2)})),[3,4];case 3:return i=o.sent(),console.log("error en asignarlistaprecio: "+i.message+" - "+t[0]),[3,4];case 4:return c===undefined?[3,5]:(s.LoM3PrdLista=c,[3,7]);case 5:return[4,a.ValidarDataFromInventario(s,f,p)];case 6:o.sent(),o.label=7;case 7:return[2]}})},a=this,u=0,o.label=1;case 1:return u<d.LoM3PrdGeneral.length?[5,t()]:[3,4];case 2:o.sent(),o.label=3;case 3:return u++,[3,1];case 4:(e=new g).ATRIBUTO="LISTAPRECIO",e.VALOR=f.UsuarioSistema.IDLPrecio,d.LoM3PrdAdicionales.push(e),o.label=5;case 5:return d?[4,this.AsignarListaPrecioM3Pack(d,f,p)]:[3,7];case 6:o.sent(),o.label=7;case 7:return[2,""]}})})},o.prototype.AsignarListaPrecioAGeneral=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return null==r||r.UsuarioSistema.IDLPrecio===undefined||-1==r.UsuarioSistema.IDLPrecio?[3,3]:(t=e.LoM3ListaPrecio.find(function(o){return o.IDLISTA==r.UsuarioSistema.IDLPrecio}))===undefined?[3,1]:(e.LoM3PrdLista=t,[3,3]);case 1:return[4,this.ValidarDataFromInventario(e,r,n)];case 2:o.sent(),o.label=3;case 3:return[2,""]}})})},o.prototype.ValidarDataFromInventario=function(a,s,c){return O(this,void 0,void 0,function(){var t,e,r,n,i;return S(this,function(o){switch(o.label){case 0:return t=s.UsuarioSistema.IDLPrecio,e=new to(null,null,null),"INV"!=t.split("_")[0]?[3,2]:(r={ubicacion:s.UsuarioSistema.UBICACION,sku:a.SKU,lote:a.LOTE,concepto:t.split("_")[1]},[4,e.GetConceptoM3SaldosItemUb(c,this.gsidkatios,r)]);case 1:(n=o.sent())&&0!=n&&((i=new I).IDLISTA=s.UsuarioSistema.IDLPrecio,i.LOTE=a.LOTE,i.PRECIO=n,i.SKU=a.SKU,a.LoM3PrdLista=i),o.label=2;case 2:return[2]}})})},o}(),$=function(){function o(){}return o.prototype.getM3ProcesosPorCredito=function(o,t,e,r,n){var i;i={idProceso:e},o.getWithBodyM3("M3/getM3ProcesosPorCredito/"+t,i).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o.error.Message)})},o.prototype.getM3ProcesoByIdPrestamo=function(o,t,e,r,n){o.getM3("M3/getM3ProcesoByIdPrestamo/"+t+"/"+e).subscribe(function(o){r(o)},function(o){n(o)})},o.prototype.m3GetPRDGRP=function(o,t,e,r){o.getM3("M3Maestro/getM3PRDGRP/"+t).subscribe(function(o){var t=JSON.parse(o);e(t)},function(o){r(o)})},o.prototype.M3GetCantidadBySKP1=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/M3GetCantidadBySKP1/"+t,e).subscribe(function(o){var t,e=JSON.parse(o.toString());t=e.RESPUESTA.DISPONIBILIDAD.length===undefined?new Array(e.RESPUESTA.DISPONIBILIDAD):e.RESPUESTA.DISPONIBILIDAD,console.log(t),r(t)},function(o){n(o.error.Message)})},o.prototype.GetListaPrdXFiltros=function(o,t,e,r,n,i,a,s,c,u){var l;void 0===a&&(a="-1"),void 0===s&&(s=!0),void 0===c&&(c="0"),void 0===u&&(u="0"),l={Filtros:JSON.stringify(t),IdLista:e,IdUbicacion:a,aplUltimoFiltro:s,topLimit:c,filtrarInvUbic:u},null!=t?o.getWithBodyM3("M3Maestro/Get_ListPRDFiltros/"+r,l).subscribe(function(o){n(o,t)},function(o){i(o.error.Message)}):i("No hay filtros para la busqueda")},o.prototype.GetListaPrdXCategoria=function(o,t,e,r,n,i,a,s,c){var u,l;void 0===s&&(s="-1"),void 0===c&&(c="0"),u=this.FindFilterInClasificacion(t,n,e),l={Filtros:JSON.stringify(u),IdLista:r,IdUbicacion:s,filtrarInvUbic:c},null!=u?o.getWithBodyM3("M3Maestro/Get_ListPRDFiltros/"+n,l).subscribe(function(o){i(o,u)},function(o){console.log(o.error.Message),a(o.error.Message)}):a("No hay filtros para la busqueda")},o.prototype.GetListaPrdXCategoriaWithOutFilters=function(o,t,e,r,n){o.getM3("M3Maestro/M3GetListaProdByClasificacion/"+e+"/"+t).subscribe(function(o){r(o,null)},function(o){n(o)})},o.prototype.GetListaPrdXNombre=function(o,t,e,r,n,i,a,s){void 0===s&&(s="0");var c={IdLista:n,idUbicacion:e,filtrarInvUbic:s};o.getWithBodyM3("M3Maestro/M3GetListaProdByNombre/"+r+"/"+t,c).subscribe(function(o){i(o)},function(o){console.log(o),a(JSON.parse(o._body).Message)})},o.prototype.cargarListPrdByGeneric=function(o,t,e,r,n,i,a,s){void 0===s&&(s="0");var c={IdLista:n,idUbicacion:e,filtrarInvUbic:s};o.getWithBodyM3("M3Maestro/cargarListPrdByGeneric/"+r+"/"+t,c).subscribe(function(o){i(o)},function(o){console.log(o.error),a(o.error)})},o.prototype.cargarInfoClasificacion=function(o,t,e,r,n){var i=this;e===undefined||null==e?o.getM3("M3Maestro/M3GetClasificacion/"+t).subscribe(function(o){e=JSON.parse(o),i.ValidarArrayClasificacion(e),r(e)},function(o){n(o)}):r(e)},o.prototype.ValidarArrayClasificacion=function(o){this.RecursiveConvertArray(o.RESPUESTA.CLASIFICACIONES)},o.prototype.FindFilterInClasificacion=function(o,t,e){var r,n,i="",a=new Array;if(r=e.RESPUESTA.CLASIFICACIONES,o.length%3!=0)return null;for(;""!=o;)i+=o.substring(0,3),o=o.substring(3),(r=r.CATEGORIA.find(function(o){return o.CLASIFICACION.toString()==i.toString()})).ATRIBUTO.toUpperCase().includes("ROOT")||(n=new M(r.ATRIBUTO,r.Descripcion),a.push(n));return a},o.prototype.RecursiveConvertArray=function(o){var t=this;o.CATEGORIA!==undefined&&(o.CATEGORIA.length===undefined?(o.CATEGORIA=new Array(o.CATEGORIA),this.RecursiveConvertArray(o.CATEGORIA[0])):o.CATEGORIA.forEach(function(o){t.RecursiveConvertArray(o)}))},o.prototype.m3AddProducto=function(o,t,e,r,n,i,a,s){var c;void 0===s&&(s=!1),c={sTdocUsuario:e,sNdocUsuario:r,oM3PrdGrp:n,disabledWeb:s},o.postServiceHttpResFullM3("M3Maestro/addProducto/"+t.trim(),c).subscribe(function(o){i(o)},function(o){a()})},o.prototype.M3GetProductoBySKP1=function(e,r,o,n,t,i){e.getWithBodyM3("M3Maestro/M3GetProductoBySKP1/"+r,o).subscribe(function(o){var t=o;new Q(r).AsignarListaPrecio(t,i,e).then(function(o){n(t)})},function(o){t()})},o.prototype.M3GetProductoRandomBySKP1=function(o,t,e,r,n,i){o.getWithBodyM3("M3Maestro/M3GetProductoRandomBySKP1/"+t,e).subscribe(function(o){r(o)},function(o){n()})},o.prototype.M3GetCatAsociadasBySKP1=function(o,t,e,r,n){o.getM3("M3Maestro/M3GetCatAsociadasBySKP1/"+t+"/"+e).subscribe(function(o){r(o)},function(o){n()})},o.prototype.M3GetImagenesByPath=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/Get_M3MultimediaByPath/"+t,e).subscribe(function(o){r(o)},function(o){console.log(o),n(o.error.Message)})},o.prototype.Get_M3SKPlantillaBySKUID=function(o,t,e,r,n){o.getM3("M3Maestro/Get_M3SKPlantillaBySKUID/"+t+"/"+e).subscribe(function(o){r(o)},function(o){n()})},o.prototype.GetInfoByFilterCode=function(o,t,e,r,n){var i={FILTERCODE:e};o.getWithBodyM3("M3Maestro/M3GetSKP1PrdsByFiltersCode/"+t,i).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){console.log(o),n(o.error.Message)})},o.prototype.get_M3Ubicaciones=function(o,t,e,r,n){o.getM3("M3Maestro/get_M3Ubicaciones/"+t+"/"+e).subscribe(function(o){r(o)},function(o){console.log(o),n(o)})},o.prototype.get_M3UbicacionesCompleta=function(o,t,e,r,n,i){o.getM3WithTimeOut("M3Maestro/get_M3UbicacionesCompleta/"+t+"/"+e+"/"+r,1e4).subscribe(function(o){n(o)},function(o){console.log(o),i(o)})},o.prototype.M3GetProductoBySKU=function(e,o,t,r,n,i){var a=new Q(o);i.UsuarioSistema.FechaPrecio&&(t.fechaLPrecio=i.UsuarioSistema.FechaPrecio),console.log(e),e.getWithBodyM3("M3Maestro/M3GetProductoBySKU/"+o,t).subscribe(function(o){var t=o;a.AsignarListaPrecio(t,i,e).then(function(o){r(t)})},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o.prototype.M3GetProductoBySKUAsync=function(n,i,a,s,c,u){return void 0===c&&(c="-1"),void 0===u&&(u="1"),O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return r=new Q(i),t={SKU:a,UBICACION:"-1"==c?s.UsuarioSistema.UBICACION:c,AplExc:u},s.UsuarioSistema.FechaPrecio&&(t.fechaLPrecio=s.UsuarioSistema.FechaPrecio),[4,n.getWithBodyM3("M3Maestro/M3GetProductoBySKU/"+i,t).toPromise()];case 1:return e=o.sent(),[4,r.AsignarListaPrecio(e,s,n)];case 2:return o.sent(),[2,e]}})})},o.prototype.Get_M3ProductoEspecByCodeAsync=function(r,n,i,a){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return t=new Q(n),a.UsuarioSistema.FechaPrecio&&(i.fechaLPrecio=a.UsuarioSistema.FechaPrecio),[4,r.getWithBodyM3("M3Maestro/Get_M3ProductoEspecByCode/"+n,i).toPromise()];case 1:return e=o.sent(),[4,t.AsignarListaPrecio(e,a,r)];case 2:return o.sent(),[2,e]}})})},o.prototype.M3getRegistrosEnProceso=function(o,t,e,r,n){var i;i={idProceso:e},o.getWithBodyM3("M3/get_RegistrosEnProceso/"+t,i).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){console.log(o),n(o._bSody)})},o.prototype.get_M3PrdGrpByNombre=function(o,t,e,r,n){o.getM3("M3Maestro/get_M3PrdGrpByNombre/"+t+"/"+e).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.M3GRP;t.length===undefined?(o=new Array(t),r(o)):r(t)},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o.prototype.GetM3PrdAgrupadoByNombre=function(o,t,e,r,n){o.getM3("M3Maestro/get_m3_prd_by_nombre_agrupado/"+t+"/"+e).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.M3GRP;t.length===undefined?(o=new Array(t),r(o)):r(t)},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o.prototype.get_m3_prd_by_nombre_agrupado=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/get_m3_prd_by_nombre_agrupado/"+t,e).subscribe(function(o){var t=JSON.parse(String(o)).RESPUESTA.M3GRP;t.length===undefined?(o=new Array(t),r(o)):r(t)},function(o){console.log(o),o._body?n(JSON.parse(o._body).Message):o.error&&o.error.Message?n(o.error.Message):n(o)})},o.prototype.get_PathServidorImagenes=function(o,t,e,r){o.getM3("M3Maestro/get_PathServidorImagenes/"+t).subscribe(function(o){console.log(o),e(o)},function(o){r()})},o.prototype.Get_M3ProductoEspecByCode=function(e,o,t,r,n,i){var a=new Q(o);i.UsuarioSistema.FechaPrecio&&(t.fechaLPrecio=i.UsuarioSistema.FechaPrecio),e.getWithBodyM3("M3Maestro/Get_M3ProductoEspecByCode/"+o,t).subscribe(function(t){var o=t;a.AsignarListaPrecio(o,i,e).then(function(o){r(t)})},function(o){console.log(o),n(o.error.Message)})},o.prototype.Get_M3ProductoEspecByCodeTimeOut=function(e,o,t,r,n,i,a){var s=new Q(o);0!=a?(i&&i.UsuarioSistema&&i.UsuarioSistema.FechaPrecio&&(t.fechaLPrecio=i.UsuarioSistema.FechaPrecio),e.getWithBodyM3TimeOut("M3Maestro/Get_M3ProductoEspecByCode/"+o,t,a).subscribe(function(t){var o=t;s.AsignarListaPrecio(o,i,e).then(function(o){r(t)})},function(o){console.log(o),o.error?n(o.error.Message):n("404")})):n("404")},o.prototype.get_DocsFromCouchMaestro=function(o,t,e,r,n){console.log("get_DocsFromCouchMaestro");var i=o.GetKeyDocumentoDB(t,e);console.log(i),o.GetDataPouchBD(i).then(function(o){r(o)},function(o){n(o)})},o.prototype.GetProductoEspecByCodeFromCouch=function(o,t,e,r){var n=o.find(function(o){return o.LoM3PrdGeneral!=undefined&&o.LoM3PrdGeneral.find(function(o){return o.M3Cods!=undefined&&o.M3Cods.find(function(o){return String(o.Valor)==String(t)})!=undefined})!=undefined}),i=h.cloneDeep(n);if(n!=undefined){var a=n.LoM3PrdGeneral.find(function(o){return o.M3Cods.find(function(o){return String(o.Valor)==String(t)})!=undefined});i.LoM3PrdGeneral=[],i.LoM3PrdGeneral.push(a),console.log("product_clone"),console.log(i),e(i)}else r("No se encontró nungún registro.")},o.prototype.get_TiposProceso=function(o,t,e,r,n){void 0===n&&(n="Ventas"),o.getM3("M3Maestro/get_TiposProceso/"+t+"/"+n).subscribe(function(o){e(JSON.parse(o).RESPUESTA)},function(o){r(o)})},o.prototype.get_InfoPersona_Proceso=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/get_InfoPersona_Proceso/"+t,e).subscribe(function(o){r(JSON.parse(String(o)).RESPUESTA)},function(o){n(o)})},o.prototype.get_InfoPersona_Proceso_async=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e.getWithBodyM3("M3Maestro/get_InfoPersona_Proceso/"+r,n).toPromise()];case 1:return t=o.sent(),[2,JSON.parse(t)];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.GetM3PrdGrpFromList=function(o,e){try{var t;return(t=o.find(function(o){var t=!1;return o.LoM3PrdGeneral.forEach(function(o){o.SKU===e&&(t=!0)}),t})).LoM3PrdGeneral=t.LoM3PrdGeneral.filter(function(o){return o.SKU==e}),t}catch(r){return console.log(r),null}},o.prototype.GetUbicacionFromList=function(o,t){return o.find(function(o){return o.IDUbicacion==t})},o.prototype.getDatosFacturacionFromRFC=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/getDatosFacturacionFromRFC/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o)})},o.prototype.actualizarRFC=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Maestro/actualizarRFC/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o._body).Message)})},o.prototype.get_XmlConfig_x_IdUbicacion=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/get_XmlConfig_x_IdUbicacion/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o)})},o.prototype.getCFDIsXProceso=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/getCFDIsXProceso/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o)})},o.prototype.get_clasification_attributes=function(o,t,e,r){o.getM3("M3Maestro/get_clasification_attributes/"+t).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.ATTRIBUTES;t.length===undefined&&(t=new Array(t)),e(t)},function(o){r()})},o.prototype.get_clasification_categories=function(o,t,e,r,n){o.getM3("M3Maestro/get_clasification_categories/"+t+"/"+e).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.CATEGORIES;t.length===undefined&&(t=new Array(t)),r(t)},function(o){console.log(o),n()})},o.prototype.getOpcionesAdicionales=function(o,t,e,r){o.getM3("M3Maestro/getOpcionesAdicionales/"+t).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.ATTRIBUTES;t.length===undefined&&(t=new Array(t)),e(t)},function(o){r()})},o.prototype.getAtributosAdicionales=function(o,t,e,r,n){o.getM3("M3Maestro/getAtributosAdicionales/"+t+"/"+e).subscribe(function(o){var t=JSON.parse(o).RESPUESTA.CATEGORIES;t.length===undefined&&(t=new Array(t)),r(t)},function(o){n()})},o.prototype.M3GetFormasEnvio=function(o,t,e,r){o.getM3("M3Maestro/M3GetFormasEnvio/"+t).subscribe(function(o){var t;t=JSON.parse(o),e(t)},function(o){console.log(o),r()})},o.prototype.get_ubicaciones_complete=function(o,t,e,r){o.getM3("M3Maestro/get_ubicaciones_complete/"+t).subscribe(function(o){e(o)},function(o){console.log(o),r()})},o.prototype.get_ubicaciones_simple=function(o,t,e,r){o.getM3("M3Maestro/get_ubicaciones_simple/"+t).subscribe(function(o){e(o)},function(o){console.log(o),r()})},o.prototype.M3GET_LISTAPRECIOS_ASync=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.getM3("M3Maestro/M3GET_LISTAPRECIOS/"+e).toPromise()];case 1:return[2,o.sent()[0]]}})})},o.prototype.GetEncabezadoListasPrecio=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t.getM3("M3/GetConfigLP/"+e).toPromise()];case 1:return[2,o.sent()];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.registrarColonia=function(o,t,e,r,n,i,a,s,c,u){var l;l={sColonia:e,sCodPostal:r,sTelefono:n,ndoc:i,sLinea1:a,sCodestado:s},o.postServiceHttpResFullM3("M3Maestro/registrarColonia/"+t,l).subscribe(function(o){c()},function(o){u(JSON.parse(o._body).Message)})},o.prototype.M3_GetPromocionesMaestroAsync=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.getM3("M3Maestro/M3_GetPromocionesMaestro/"+e).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.M3GetDinByActividad=function(t,e,r,n,i){return O(this,void 0,void 0,function(){return S(this,function(o){return t.getWithBodyM3("M3Maestro/M3GetDinByActividad/"+e,r).subscribe(function(o){n(o)},function(o){console.log(o),i()}),[2]})})},o.prototype.getUbicacionesWeb=function(o,t,e,r){o.getM3("M3Maestro/getUbicacionesWeb/"+t).subscribe(function(o){e(JSON.parse(o))},function(o){r(o)})},o.prototype.getUbicacionesByCodPostal=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/getUbicacionesByCodPostal/"+t,e).subscribe(function(o){r(JSON.parse(o.toString()))},function(o){n(o)})},o.prototype.getPathFEFromDiario=function(o,t,e,r,n,i){o.getWithBodyM3("M3/getPathFEFromDiario/"+t+"/"+e,r).subscribe(function(o){var t=JSON.parse(o.toString());n(t)},function(o){console.log(o),i(o)})},o.prototype.getDiarioAdicionalesxDiario=function(o,t,e,r,n){o.getWithBodyGenerales("Diario/getDiarioAdicionalesxDiario/"+t,e).subscribe(function(o){var t=JSON.parse(o.toString());r(t)},function(o){console.log(o),n(JSON.parse(o._body).Message)})},o.prototype.IU_Hub=function(e,r,n,i,a){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idKatios:r.trim(),oHub:n,uTActivo:i,uNActivo:a},[4,e.postServiceHttpResFullM3("M3Maestro/IU_Hub",t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.GetCtivoBYProceso=function(e,r,n,i,a){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={idproceso:n,ubicacion:i,hub:a},[4,e.getWithBodyM3("M3/GetCtivoBYProceso/"+r.trim(),t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.ValidarCtivosVSLocal=function(t,e,r,n,i,a){return O(this,void 0,void 0,function(){return S(this,function(o){return t.postServiceHttpResFullM3("M3/ValidarCtivosVSLocal/"+e+"/"+n+"/"+i,r).subscribe(function(o){a(o)},function(o){a({error:o})}),[2]})})},o.prototype.GenerarAutorizacionCuentas=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.postServiceHttpResFullM3("M3/GenerarAutorizacionCuentas",e).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.validacionAutorizacionM3Cuentas=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.postServiceHttpResFullM3("M3/validacionAutorizacionM3Cuentas",e).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.VerificarPagoTarjetaBBVA=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t={Idkatios:r,idKey:n},[4,e.getWithBodyM3("M3/VerificarPagoTarjetaBBVA",t).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.getDescripcionSKPs=function(o,t,e,r,n){t.getWithBodyM3("M3Consultas/getDescripcionSKPs/"+o,e).subscribe(function(o){r(e.SKP1,JSON.parse(o.toString()))},function(o){n(o.error.Message)})},o.prototype.getTotalesCierreCaja=function(r,n,i,a,s,c,u){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return e={idKatios:n,ubicacion:i,hub:a,usuario:s,FechaI:c,FechaF:u},[4,r.getWithBodyM3("M3/getTotalesCierreCaja",e).toPromise()];case 1:return t=o.sent(),[2,t=JSON.parse(t)]}})})},o.prototype.getCierresxUbicacion=function(r,n,i,a,s){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return e={idKatios:n,ubicacion:i,idProceso:a,Fecha:s},[4,r.getWithBodyM3("M3/getCierresxUbicacion",e).toPromise()];case 1:return t=o.sent(),[2,t=JSON.parse(t)]}})})},o.prototype.getCierresxEmpresa=function(r,n,i,a){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return e={idKatios:n,idProceso:i,Fecha:a},[4,r.getWithBodyM3("M3/getCierresxEmpresa",e).toPromise()];case 1:return t=o.sent(),[2,t=JSON.parse(t)]}})})},o.prototype.simularpagoEnlinea=function(o,t,e,r,n,i){o.getM3("M3/ValidacionPagoIntegracionTest/"+t+"/"+e+"/"+r).subscribe(function(o){n()},function(o){i()})},o.prototype.validarPrdsMismoProveedor=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Maestro/validarPrdsMismoProveedor/"+t+"/"+e,r).subscribe(function(o){n(JSON.parse(JSON.parse(o._body).toString()))},function(o){console.error("Error validarPrdsMismoProveedor"),console.error(o),n(JSON.parse(JSON.parse(o._body).Message))})},o.prototype.validarRestriccionInvNegativo=function(o,t,e,r){o.postServiceHttpResFullM3("M3Maestro/validarRestriccionInvNegativo/"+t,e).subscribe(function(o){r(JSON.parse(JSON.parse(o._body).toString()))},function(o){console.error("Error validarRestriccionInvNegativo"),console.error(o),r(JSON.parse(JSON.parse(o._body).Message))})},o.prototype.validarRestriccionInvNegativoV2=function(o,t,e,r){o.postServiceHttpResFullM3("M3Maestro/validarRestriccionInvNegativoV2/"+t,e).subscribe(function(o){try{r(JSON.parse(JSON.parse(o._body).toString()))}catch(t){console.error(o),console.error(t),r(t)}},function(o){console.error("Error validarRestriccionInvNegativoV2"),console.error(o),r(JSON.parse(JSON.parse(o._body).Message))})},o.prototype.validarEfectivoEnCaja=function(o,t,e,r){o.postServiceHttpResFullM3("M3Maestro/validarEfectivoEnCaja/"+t,e).subscribe(function(o){try{r(JSON.parse(JSON.parse(o._body).toString()))}catch(t){console.error(o),console.error(t),r(t)}},function(o){console.error("Error validarEfectivoEnCaja"),console.error(o),r(JSON.parse(JSON.parse(o._body).Message))})},o.prototype.getInfoPrdGastosEnvio=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return[4,e.postServiceHttpResFullM3("M3Maestro/getInfoPrdGastosEnvio/"+r,n).toPromise()];case 1:return t=o.sent(),[2,JSON.parse(JSON.parse(t._body).toString()).RESPUESTA]}})})},o.prototype.m3_generar_M3SXC_aleatorio=function(r,n,i){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,r.postServiceHttpResFullM3("M3/m3_generar_M3SXC_aleatorio/"+n,i).toPromise()];case 1:return t=o.sent(),[2,JSON.parse(JSON.parse(t._body).toString()).RESPUESTA];case 2:return e=o.sent(),console.error(e),[2,null];case 3:return[2]}})})},o.prototype.M3_actualizarConceptoSIU=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/M3_actualizarConceptoSIU/"+t,e).subscribe(function(o){r(o)},function(o){n(o)})},o.prototype.procesoAlCierreUbic=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3/procesoAlCierreUbic/"+t,e).subscribe(function(o){r(o)},function(o){console.error("Error procesoAlCierreUbic"),console.error(o),n(o)})},o.prototype.get_ProcesosAbiertos=function(o,t,e,r,n){o.getWithBodyM3("M3Maestro/get_ProcesosAbiertos/"+t,e).subscribe(function(o){r(JSON.parse(String(o)).RESPUESTA)},function(o){console.error("Error get_ProcesosAbiertos"),console.error(o),n(o)})},u([l(6,r.Optional()),l(7,r.Optional()),l(8,r.Optional()),l(9,r.Optional()),d("design:type",Function),d("design:paramtypes",[f,Array,String,String,Function,Function,Object,Object,Object,Object]),d("design:returntype",void 0)],o.prototype,"GetListaPrdXFiltros",null),u([l(7,r.Optional()),l(8,r.Optional()),d("design:type",Function),d("design:paramtypes",[f,String,Object,String,String,Function,Function,Object,String]),d("design:returntype",void 0)],o.prototype,"GetListaPrdXCategoria",null),u([l(7,r.Optional()),d("design:type",Function),d("design:paramtypes",[f,String,String,String,String,Function,Function,String]),d("design:returntype",void 0)],o.prototype,"GetListaPrdXNombre",null),u([l(7,r.Optional()),d("design:type",Function),d("design:paramtypes",[f,String,String,String,String,Function,Function,String]),d("design:returntype",void 0)],o.prototype,"cargarListPrdByGeneric",null),o}(),Z=s,oo=require("js-big-decimal"),to=function(){function o(o,t,e){this.oMathTF=new q,this.oListaObsequios=null,this.obsequiosExc=!1,this.obsequioOPromo=-1,this.obsequiosCantidad=0,this.lIdActivaPromo=[],this.oM3CouchMaestro=o,this.GoPostServiceM3=t,this.gsIdkatios=e}return o.prototype.ValidarNumeroItems=function(o){1e3<o.M3ENC.length&&(o.AplDesdeServer=!0,o.M3ENC=new Array)},o.prototype.ProcesamientoService=function(o,t,e,r,n,i,a){void 0===a&&(a=!0),this.ValidarNumeroItems(e),this.RetomarInformacion(r,e,a),t.postServiceHttpResFullM3("M3/RegistroEventoM3/"+o+"/"+r.UsuarioSistema.NDOC+"/"+r.UsuarioSistema.TDOC,e).subscribe(function(o){var t=JSON.parse(o.json());e.IdM3=t.RESPUESTA.IDM3,e.IDDiario=t.RESPUESTA.IDDIARIO,e.IDDiarioCierre=t.RESPUESTA.IDDIARIOCIERRE,e.SubEstadoAnt=e.SubEstadoDes,e.EstadoAnt=e.EstadoDes,n(e,t.RESPUESTA)},function(o){console.error(o.json().Message),i(o.json().Message)})},o.prototype.procesamiento_service_async=function(r,n,i,a,s){return void 0===s&&(s=!0),O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.RetomarInformacion(a,i,s),[4,n.postServiceHttpResFullM3("M3/RegistroEventoM3/"+r+"/"+a.UsuarioSistema.NDOC+"/"+a.UsuarioSistema.TDOC,i).toPromise()];case 1:return t=o.sent(),e=JSON.parse(t.json()),i.IdM3=e.RESPUESTA.IDM3,i.IDDiario=e.RESPUESTA.IDDIARIO,i.SubEstadoAnt=i.SubEstadoDes,i.EstadoAnt=i.EstadoDes,[2,i];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.RegistroEventoM3OffLine=function(t,e,r,n){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,e.postServiceHttpResFullM3("M3/RegistroEventoM3OffLine/"+t+"/"+n.UsuarioSistema.NDOC+"/"+n.UsuarioSistema.TDOC,r).toPromise()];case 1:return o.sent(),[2,!0];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.RetomarInformacion=function(o,t,e){null!=o&&t.IdM3!==undefined&&null!=t.IdM3&&(e?(t.M3FTrabajo.IdHub=o.UsuarioSistema.IDHUB,t.M3FTrabajo.IdUbic!=undefined&&0!=t.M3FTrabajo.IdUbic||(t.M3FTrabajo.IdUbic=o.UsuarioSistema.UBICACION)):(t.M3FTrabajo.IdUbic=t.M3FTrabajo.IdUbicPre,t.M3FTrabajo.IdHub=t.M3FTrabajo.IdHubPre))},o.prototype.ProcesamientoServicePouchDB=function(r,n,i,a,e,s,o,c,u,l,d){var f,p,h,P=this;void 0===d&&(d=null),h=i.LoM3PrdGeneral[0],p=r.GetKeyCarritoCompras(o,s.UsuarioSistema.TDOC,s.UsuarioSistema.NDOC,s.UsuarioSistema.UBICACION,s.UsuarioSistema.IDHUB),r.GetDataPouchBD(p).then(function(e){return O(P,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return f=e,0==(t=this.validarExistaProducto(f.M3ENC,h,n))?[3,2]:(n.dCantidad=+t+ +n.dCantidad,f.M3ENC=f.M3ENC.filter(function(o){return!(o.IdProducto==h.SKU&&o.Lote==h.LOTE&&!(0<o.IdEncPadre))}),this.RecalcularPrecios(f),f=this.LoadM3ProcesoFromData(f,i,n,c,u,s,d),[4,r.AddToPouchBDCarritoCompras(p,f)]);case 1:return o.sent(),a(f,n),[3,4];case 2:return f=this.LoadM3ProcesoFromData(f,i,n,c,u,s,d),[4,r.AddToPouchBDCarritoCompras(p,f)];case 3:o.sent(),a(f,n),o.label=4;case 4:return[2]}})})},function(t){return O(P,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return"404"!=t.status?[3,2]:(f=this.LoadM3ProcesoEmptyPDB(i,n,s,c,u,l,d),[4,r.AddToPouchBDCarritoCompras(p,f)]);case 1:return o.sent(),a(f,n),[3,3];case 2:console.log("Error no controlado"),console.log(t),e(),o.label=3;case 3:return[2]}})})})},o.prototype.addtocart=function(o,t,e,r,n,i,a,s,c,u,l){void 0===u&&(u=null),void 0===l&&(l=0);var d,f=c;if(d=t.LoM3PrdGeneral[0],0==f.M3ENC.length){if(f=this.LoadM3ProcesoEmptyPDB(t,o,n,a,s,c,u),!e)return f;e(f,o)}else{var p=this.validarExistaProducto(f.M3ENC,d,o);if(0!=p){if(o.dCantidad=+p+o.dCantidad,f.M3ENC=f.M3ENC.filter(function(o){return!(o.IdProducto==d.SKU&&o.Lote==d.LOTE&&!(0<o.IdEncPadre))}),this.RecalcularPrecios(f),f=this.LoadM3ProcesoFromData(f,t,o,a,s,n,u,l),!e)return f;e(f,o)}else{if(f=this.LoadM3ProcesoFromData(f,t,o,a,s,n,u,l),!e)return f;e(f,o)}}},o.prototype.validarExistaProducto=function(o,t,e){var r=this,n=null,i=0;return e.IDEncRepetido=-1,o!==undefined&&t!==undefined&&0<o.length&&(n=o.find(function(o){return o.IdProducto==t.SKU&&!o.IdEncPadre&&r.getCantidadPositiva(o)}))!==undefined&&null!=n&&(this.VerificarPrecioByNivelesGeneral(t,+n.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor),this.ValidarPreciosPrds(n,t.LoM3PrdLista)&&!this.ValidarEstaPaquete(n,o)&&(e.IDEncRepetido=n.ID,i=+n.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor)),i},o.prototype.getCantidadPositiva=function(o){var t=0,e=o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto});return e&&(t=+e.Valor),0<t},o.prototype.ValidarEstaPaquete=function(t,o){var e=!1;try{o.find(function(o){return o.IdEncPadre==t.ID})&&(e=!0)}catch(r){}return e},o.prototype.ValidarPreciosPrds=function(o,t){var e=!1;try{var r=+o.M3DET.find(function(o){return"PUNIT"==o.NombreConcepto}).Valor;t.PRECIO==r&&(e=!0)}catch(n){console.log("Error ValidarPreciosPrds"),console.log(n)}return e},o.prototype.UpdateM3ProcesosWithData=function(t,e,r,o,n,i,a,s,c){var u,l=this;void 0===s&&(s=null),void 0===c&&(c=null),this.RecalcularPrecios(t),"WEB"==n.toUpperCase()&&(u=e.GetKeyCarritoCompras(o,r.UsuarioSistema.TDOC,r.UsuarioSistema.NDOC,r.UsuarioSistema.UBICACION,r.UsuarioSistema.IDHUB),e.GetDataPouchBD(u).then(function(o){e.AddToPouchBDCarritoCompras(u,t),l.procesarPromoAfterCarritoOk(t,e,r,s,i,a,c)},function(o){"404"==o.status?(e.AddToPouchBDCarritoCompras(u,t),l.procesarPromoAfterCarritoOk(t,e,r,s,i,a,c)):(console.log("Error no controlado"),a())}))},o.prototype.procesarPromoAfterCarritoOk=function(t,e,o,r,n,i,a){if(r){var s;a?s=a:(s=new N).dCantidad=1;var c=e.GetKeyCarritoCompras(this.gsIdkatios,o.UsuarioSistema.TDOC,o.UsuarioSistema.NDOC,o.UsuarioSistema.UBICACION,o.UsuarioSistema.IDHUB);this.ProcPromoAfterAddToCart(t,o,s,r,!0).then(function(o){e.AddToPouchBDCarritoComprasAsync(c,t).then(function(o){n()})["catch"](function(o){n()})})["catch"](function(o){console.log(o),console.log("Error no controlado en procesarPromoAfterCarritoOk"),n()})}else n()},o.prototype.updateAPouch=function(t,e,o,r,n,i,a){var s;"WEB"==n.toUpperCase()&&(s=e.GetKeyCarritoCompras(r,o.UsuarioSistema.TDOC,o.UsuarioSistema.NDOC,o.UsuarioSistema.UBICACION,o.UsuarioSistema.IDHUB),e.GetDataPouchBD(s).then(function(o){e.AddToPouchBDCarritoCompras(s,t),i()},function(o){"404"==o.status?(e.AddToPouchBDCarritoCompras(s,t),i()):(console.log("Error no controlado"),a())}))},o.prototype.DeleteM3Proceso=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t=e.GetKeyCarritoCompras(n,r.UsuarioSistema.TDOC,r.UsuarioSistema.NDOC,r.UsuarioSistema.UBICACION,r.UsuarioSistema.IDHUB),[4,e.Delete(t)];case 1:return o.sent(),[2]}})})},o.prototype.DelDocsStartAndCurrent=function(o,t,e,r,n){if(e.IDDiarioCierre!==undefined&&null!=e.IDDiarioCierre){var i={UsuarioSistema:{TDOC:e.TDoc,NDOC:e.NDoc,UBICACION:e.Ubic1.toString(),IDHUB:e.IDHub}};this.DeleteM3Proceso(o,i,t).then(function(o){console.log("Delete start")}),i={UsuarioSistema:{TDOC:e.TDoc,NDOC:e.NDoc,UBICACION:r.toString(),IDHUB:n}},this.DeleteM3Proceso(o,i,t).then(function(o){console.log("Delete current")})}},o.prototype.GetCarritoComprasPouchDB=function(e,r,n){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t=e.GetKeyCarritoCompras(n,r.UsuarioSistema.TDOC,r.UsuarioSistema.NDOC,r.UsuarioSistema.UBICACION,r.UsuarioSistema.IDHUB),[4,e.GetDataPouchBD(t)];case 1:return[2,o.sent()]}})})},o.prototype.MoveCartIntoUser=function(n,i,a,s,c){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),t=i.GetKeyCarritoCompras(n,a.UsuarioSistema.TDOC,a.UsuarioSistema.NDOC,a.UsuarioSistema.UBICACION,a.UsuarioSistema.IDHUB),e=i.GetKeyCarritoCompras(n,s.UsuarioSistema.TDOC,s.UsuarioSistema.NDOC,s.UsuarioSistema.UBICACION,s.UsuarioSistema.IDHUB),[4,i.GetDataPouchBD(t)];case 1:return(r=o.sent()).TDoc=s.UsuarioSistema.TDOC,r.NDoc=s.UsuarioSistema.NDOC,delete r._rev,[4,i.AddToPouchBDCarritoCompras(e,r)];case 2:return o.sent(),c(),[3,4];case 3:return o.sent(),c(),[3,4];case 4:return[2]}})})},o.prototype.RecalcularPreciosPromoCombinada=function(o){this.RecalcularPrecios(o)},o.prototype.RecalcularPrecios=function(o){var e=this;o.M3ENC.forEach(function(o){var t=e.CalculatePrecioBase(o.M3DET.find(function(o){return"CTBLDIMPPRD"==o.NombreConcepto}).Valor,e.oMathTF.round(o.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor,2));0!=+ +o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor?o.M3DET.find(function(o){return"PRECIOUNITBASE"==o.NombreConcepto}).Valor=(+t/+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor).toString():o.M3DET.find(function(o){return"PRECIOUNITBASE"==o.NombreConcepto}).Valor="0",e.ValoresCalculadosProceso(o,+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor)}),this.recalcularM3Proceso(o)},o.prototype.CalcularPrecioBaseFromProceso=function(o,t){var e=1;try{o.M3PImpuestos.forEach(function(o){e=+e+ +o.Porcentaje})}catch(r){}return+t/+e},o.prototype.CreateM3NewProcesoEmpty=function(o,t,e,r,n,i,a){o.TMIdProceso=t,o.EstadoAnt="",o.SubEstadoAnt="",o.EstadoDes=n[0].E_Destino,o.SubEstadoDes=n[0].SE_Destino,o.M3FTrabajo.IdHub=+i,o.M3FTrabajo.IdUbic=+a,o.IDHub=+i,o.Ubic1=+a,o.TDoc=e,o.NDoc=r,o.TipoTercero=1,o.Ubic2=-1,o.M3FTrabajo.IdHubPre=-1,o.M3FTrabajo.IdUbicPre=-1},o.prototype.LoadM3ProcesoEmptyPDB=function(o,t,e,r,n,i,a){var s;return void 0===a&&(a=null),(s=null!=i?i:new w).Fecha=Z(new Date).format("YYYY-MM-DD"),s.TipoTercero=1,s.TDoc=e.UsuarioSistema.TDOC,s.NDoc=e.UsuarioSistema.NDOC,s.Ubic1=e.UsuarioSistema.UBICACION,s.Ubic2=-1,s.IDHub=e.UsuarioSistema.IDHUB,s.M3FTrabajo.IdHub=s.IDHub,s.M3FTrabajo.IdUbic=s.Ubic1,s.M3FTrabajo.IdHubPre=-1,s.M3FTrabajo.IdUbicPre=-1,""==s.SubEstadoDes&&null==i&&(s.SubEstadoDes="Registro",s.EstadoDes="Activo"),""!=t.SubEstado_o&&""!=t.Estado_o&&(s.SubEstadoDes=t.SubEstado_o,s.EstadoDes=t.Estado_o),""==t.IdProceso&&null==i?s.TMIdProceso="M3ECC":""!=t.IdProceso&&(s.TMIdProceso=t.IdProceso),this.LoadM3PEncItemsFromPrdGrl(s,o,s.M3ENC,t,r,n,e,null,0,a),s},o.prototype.LoadAdicionales=function(o,t){try{o.ClavePrdSRV=t.LoM3PrdAdicionales.find(function(o){return"CLAVEPRODSERV"==o.ATRIBUTO}).VALOR,o.ClavePrdUnidad=t.LoM3PrdAdicionales.find(function(o){return"CLAVEUNIDAD"==o.ATRIBUTO}).VALOR,o.Unidad=t.LoM3PrdAdicionales.find(function(o){return"UNIDAD"==o.ATRIBUTO}).VALOR}catch(e){}return o},o.prototype.LoadM3ProcesoFromData=function(o,t,e,r,n,i,a,s){return void 0===a&&(a=null),void 0===s&&(s=0),o.Fecha=Z(new Date).format("YYYY-MM-DD"),""==o.TMIdProceso&&""!=e.IdProceso&&(o.TMIdProceso=e.IdProceso),this.LoadM3PEncItemsFromPrdGrl(o,t,o.M3ENC,e,r,n,i,null,s,a),o},o.prototype.LoadM3PEncItemsFromPrdGrl=function(o,t,e,r,n,i,a,s,c,u){void 0===c&&(c=0),void 0===u&&(u=null);var l=t.LoM3PrdAdicionales.find(function(o){return"VENTANEG"==o.ATRIBUTO});o.InventarioError&&delete o.InventarioError,!("M3ECC"==o.TMIdProceso.toUpperCase()&&t.LoM3PrdGeneral[0].DISPONIBLE<r.dCantidad&&"WEB"==n.M3HUBS[0].Tipo)||l&&l.VALOR||(o.InventarioError="No hay inventario para agregar "+r.dCantidad+" Items",r.dCantidad=t.LoM3PrdGeneral[0].DISPONIBLE);var d=new V;if(o.Fecha=Z(new Date).format("YYYY-MM-DD"),d=this.LoadM3PEncItemsFromPrdGrlItem(o,t,o.M3ENC,r,n,i,a,s,c),o.MensajeError&&delete o.MensajeError,s&&(d.IdEncPadre=s.ID),d.MensajeError)o.MensajeError=d.MensajeError;else{var f;if((f=t.LoM3PrdGeneral[0].M3PACK)&&0<f.length)for(var p=0;p<f.length;p++){var h,P=f[p];P.oM3PItemsWEB?h=P.oM3PItemsWEB:(h=Object.assign({},r)).dCantidad=P.Cantidad,h.PathImagen=P.gsPathImagen,h.dCantidad=h.dCantidad*r.dCantidad,h.IDEncRepetido=+this.GetMaxAtributoFromLista(o.M3ENC,"ID")+p+2,P.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=0;try{var M=P.M3GRP.LoM3PrdGeneral[0].M3Cods.find(function(o){return"UPC"==o.IdCodigo});M&&M.Valor&&(h.CodigoBarras=M.Valor)}catch(m){console.warn("no añadi codigo de barras a producto hijo: "+P.SKUHIJO)}this.LoadM3PEncItemsFromPrdGrl(o,P.M3GRP,o.M3ENC,h,n,i,a,d,0,u)}-1!=r.IDEncRepetido&&(d.ID=r.IDEncRepetido),-1!=r.IDEncPadre&&(d.IdEncPadre=r.IDEncPadre,d.TipoAgrupacion=r.TipoAgrupacion),u&&0<u.length&&u.forEach(function(o){d.M3PDinamByActividad.push(C({},o))}),o.M3ENC.push(d)}r.IDEncProcesado=d.ID},o.prototype.calcularPorcentajeDescuentoCombo=function(o){var e=this,t=0,r=0,n=o.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO;return o.LoM3PrdGeneral[0].M3PACK.forEach(function(o){var t=o.M3GRP.Cantidad?o.M3GRP.Cantidad:1;e.VerificarPrecioByNiveles(o.M3GRP,t);console.debug(o.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.IDLISTA),console.debug(o.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO),r+=o.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO*t}),n<r&&(t=100-100*n/r),console.debug(t),t},o.prototype.CalcularPreciosPCKG=function(o){o.M3GRP.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=0},o.prototype.loadM3PEncItemsFromPromocionCombo=function(t,o,e,r,n){var i=this,a=new V;return a.IdProducto=e,a.Lote="1",a.ID=+this.GetMaxAtributoFromLista(t.M3ENC,"ID")+1,a.Orden=+this.GetMaxAtributoFromLista(t.M3ENC,"Orden")+1,a.Nombre="Combo - "+o.map(function(o){return o.IdProducto}).join("-"),a.M3DET.push(this.LoadM3PDetalle(Z(new Date).format("YYYY-MM-DDTHH:mm:ss"),"FECHAIN")),a.M3DET.push(this.LoadM3PDetalle("true","ESPRODPROMOCOMBO")),a.M3DET.push(this.LoadM3PDetalle("true","ESPRODPROMO")),a.M3DET.push(this.LoadM3PDetalle("ENCPROMO","TIPO_PRD")),a.M3DET.push(this.LoadM3PDetalle(r,"PRECIOUNITBASE")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALIMPUESTOS")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALIMPUNIT")),a.M3DET.push(this.LoadM3PDetalle(r,"PUNITSINIMPUESTO")),a.M3DET.push(this.LoadM3PDetalle(r,"PUNIT")),a.M3DET.push(this.LoadM3PDetalle(r,"PUNITNETO")),a.M3DET.push(this.LoadM3PDetalle("0","VUNITPROMO")),a.M3DET.push(this.LoadM3PDetalle("0","UNITFIDEL")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALIMPUNIT")),a.M3DET.push(this.LoadM3PDetalle(n.toString(),"CANTIDAD")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALIMPUESTOS")),a.M3DET.push(this.LoadM3PDetalle("0","FIDELIZACION")),a.M3DET.push(this.LoadM3PDetalle("0","TOTALPROMO")),a.M3DET.push(this.LoadM3PDetalle(r,"CTBLDIMPPRD")),a.M3DET.push(this.LoadM3PDetalle((+r*n).toString(),"PRECIOTOTALSINDTO")),a.M3DET.push(this.LoadM3PDetalle((+r*n).toString(),"SUBTOTAL")),a.M3DET.push(this.LoadM3PDetalle((+r*n).toString(),"PRECIOTOTALBASE")),a.M3DET.push(this.LoadM3PDetalle((+r*n).toString(),"PRECIOTOTAL")),t.M3ENC.push(a),o.forEach(function(o){o.ID=+i.GetMaxAtributoFromLista(t.M3ENC,"ID")+1,o.IdEncPadre=a.ID,t.M3ENC.push(o)}),this.recalcularM3Proceso(t),a},o.prototype.recalcularM3Proceso=function(o){var t,e,r=o.M3ENC.filter(function(o){var t=o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}),e=o.M3DET.find(function(o){return"ESPRODPROMOCOMBO"==o.NombreConcepto});return t&&0<+t.Valor&&!(e&&"true"==e.Valor)});o.ValorNeto=0,o.Valor=0;try{for(var n=v(r),i=n.next();!i.done;i=n.next()){var a=i.value;o.ValorNeto+=+a.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor,o.Valor+=+a.M3DET.find(function(o){return"SUBTOTAL"==o.NombreConcepto}).Valor}}catch(s){t={error:s}}finally{try{i&&!i.done&&(e=n["return"])&&e.call(n)}finally{if(t)throw t.error}}},o.prototype.LoadM3PEncItemsFromPrdGrlItem=function(o,t,e,r,n,i,a,s,c){void 0===s&&(s=undefined),void 0===c&&(c=0);var u,l,d,f=new V,p=0,h=0,P=0,M=0;if(l=this.VerificarPrecioByNiveles(t,r.dCantidad),0<c?((d=new k).PrecioTotalPromocion=t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO*c/100,d.PrecioTotal=t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO-d.PrecioTotalPromocion,d.ListPromocionesAsociadas=[]):d=this.CalcularPromociones(o,t,n,i,a,r),this.validarProductoRestringido(d))f.MensajeError="Producto Restringido";else{if(this.AsignarPromocionesCombinadas(o,d,f),P=d.ValorTotalMonedero,d.ValorTotalMonedero=+oo.multiply(d.ValorTotalMonedero,r.dCantidad),M=d.PrecioTotalPromocion,d.PrecioTotalPromocion=+oo.multiply(d.PrecioTotalPromocion,r.dCantidad),f.M3DetCupones=this.get_list_cupones_from_promo(d,+r.dCantidad),r.dPrecioTotal=+oo.multiply(d.PrecioTotal,r.dCantidad),u=t.LoM3PrdGeneral[0],f.IdProducto=u.SKU,f.Lote=u.LOTE,f.ID=+this.GetMaxAtributoFromLista(e,"ID")+1,f.Orden=+this.GetMaxAtributoFromLista(e,"Orden")+1,f.Nombre=u.NOMBRE1,f.DISPONIBLE=u.DISPONIBLE,f.PathImage=r.PathImagen,f.CodigoBarras=r.CodigoBarras,n&&n.M3UbiAdicionales){var m=n.M3UbiAdicionales.find(function(o){return"IMPFIJO"==o.Atributo});m&&""!=m.Valor&&(u.CTBLDIMPPRD=m.Valor)}var C=this.CalculatePrecioBase(u.CTBLDIMPPRD,this.oMathTF.round(oo.multiply(d.PrecioTotal,r.dCantidad),2));if(p=0!=r.dCantidad?C/r.dCantidad:0,h=this.LoadM3PImpuestosFromPrdGrl(u.CTBLDIMPPRD,f,C,r.dCantidad,d.PrecioTotal),f.M3DET.push(this.LoadM3PDetalle(Z(new Date).format("YYYY-MM-DDTHH:mm:ss"),"FECHAIN")),f.M3DET.push(this.LoadM3PDetalle(u.CTBLDPRD,"CTBLDPRD")),f.M3DET.push(this.LoadM3PDetalle(r.BisObsequio.toString(),"ESOBSEQUIO")),f.M3DET.push(this.LoadM3PDetalle(u.SKP1,"PRD_ESTILO")),f.M3DET.push(this.LoadM3PDetalle(u.CTBLDIMPPRD,"CTBLDIMPPRD")),f.M3DET.push(this.LoadM3PDetalle(r.observacion.toString(),"OBSERVACION")),r.PathImagen&&f.M3DET.push(this.LoadM3PDetalle(r.PathImagen,"PATHIMAGEN")),f.M3DET.push(this.LoadM3PDetalle(r.BisProductoPromo.toString(),"ESPRODPROMO")),f.M3DET.push(this.LoadM3PDetalle(t.TIPO,"TIPO_PRD")),f.M3DET.push(this.LoadM3PDetalle(r.Unidad,"UNIDAD")),f.M3DET.push(this.LoadM3PDetalle(r.ClavePrdSRV,"CLAVEPRODSERV")),f.M3DET.push(this.LoadM3PDetalle(r.ClavePrdUnidad,"CLAVEUNIDAD")),this.AddItemsInterfaz(f,t.LoM3PrdAdicionales),this.AdicionalesToDetalles(f,t.LoM3PrdAdicionales),this.camposAdicionalesToDetalles(f,r),this.LoadDetalleNivelesPrecio(l,f),this.AddInfoPromocionesADetalle(d,f,r.dCantidad),f.M3DET.push(this.LoadM3PDetalle(p.toString(),"PRECIOUNITBASE")),f.M3DET.push(this.LoadM3PDetalle(h.toString(),"TOTALIMPUESTOS")),f.M3DET.push(this.LoadM3PDetalle(this.oMathTF.round(this.GetUnitarioByTotal(r.dCantidad,f,"TOTALIMPUESTOS"),2).toString(),"TOTALIMPUNIT")),f.M3DET.push(this.LoadM3PDetalle((+p+ +M).toString(),"PUNITSINIMPUESTO")),f.M3DET.push(this.LoadM3PDetalle(u.LoM3PrdLista.PRECIO.toString(),"PUNIT")),f.M3DET.push(this.LoadM3PDetalle(d.PrecioTotal.toString(),"PUNITNETO")),f.M3DET.push(this.LoadM3PDetalle(P.toString(),"UNITFIDEL")),f.M3DET.push(this.LoadM3PDetalle(M.toString(),"VUNITPROMO")),"CTN"==this.gsIdkatios)t.LoM3PrdGeneral[0].LoM3ListaPrecio.find(function(o){return"2"==o.IDLISTA})&&f.M3DET.push(this.LoadM3PDetalle(t.LoM3PrdGeneral[0].LoM3ListaPrecio.find(function(o){return"2"==o.IDLISTA}).PRECIO.toString(),"PRECIOSR"));t.encontradoLocal?f.M3DET.push(this.LoadM3PDetalle("LOCAL","CONSULTOEN")):f.M3DET.push(this.LoadM3PDetalle("SERVIDOR","CONSULTOEN")),this.ValoresCalculadosProceso(f,r.dCantidad),o.Valor=+o.Valor+ +f.M3DET.find(function(o){return"SUBTOTAL"==o.NombreConcepto}).Valor,o.ValorNeto=+o.ValorNeto+ +f.M3DET.find(function(o){return"PRECIOTOTAL"==o.NombreConcepto}).Valor,this.VerificarObsequios(d,r.dCantidad,f),this.turnOnPromos(d)}return f},o.prototype.validarProductoRestringido=function(o){if(o.ListPromocionesAsociadas&&o.ListPromocionesAsociadas.find(function(o){return"RESTRICCION"==o.Tipo}))return!0;return!1},o.prototype.GetMaxAtributoFromLista=function(o,t){if(0<o.length){var e=o.map(function(o){return o[t]});return Math.max.apply(Math,e)}return 0},o.prototype.ValoresCalculadosProceso=function(o,t){var e,r=0,n=0;e=this.agregarImpuesto(o,t),0<o.M3PImpuestos.length?n=(r=this.oMathTF.round(this.oMathTF.round(+this.GetTotalByUnitario(t,o,"PRECIOUNITBASE"),2)+ +this.GetTotalByUnitario(t,o,"VUNITPROMO"),2))+(e=this.getValorTotalFromImpuestos(o,"Valor")):r=n=this.oMathTF.round(this.GetTotalByUnitario(t,o,"PUNIT"),2),this.InsUpdDetItem(o,t.toString(),"CANTIDAD"),this.InsUpdDetItem(o,this.oMathTF.round(e,2).toString(),"TOTALIMPUESTOS"),this.InsUpdDetItem(o,this.oMathTF.round(+this.GetUnitarioByTotal(t,o,"TOTALIMPUESTOS"),2).toString(),"TOTALIMPUNIT"),this.InsUpdDetItem(o,o.M3DET.find(function(o){return"UNITFIDEL"==o.NombreConcepto}).Valor,"FIDELIZACION"),this.InsUpdDetItem(o,n.toString(),"PRECIOTOTALSINDTO"),this.InsUpdDetItem(o,r.toString(),"SUBTOTAL"),this.InsUpdDetItem(o,Z(new Date).format("YYYY-MM-DD"),"FUT"),this.InsUpdDetItem(o,this.oMathTF.round(+this.GetTotalByUnitario(t,o,"VUNITPROMO"),2).toString(),"TOTALPROMO"),this.InsUpdDetItem(o,this.oMathTF.round(+this.GetTotalByUnitario(t,o,"PRECIOUNITBASE"),2).toString(),"PRECIOTOTALBASE"),this.InsUpdDetItem(o,this.oMathTF.round(r+ +o.M3DET.find(function(o){return"TOTALIMPUESTOS"==o.NombreConcepto}).Valor-+o.M3DET.find(function(o){return"TOTALPROMO"==o.NombreConcepto}).Valor,2).toString(),"PRECIOTOTAL"),0<o.M3PImpuestos.length&&0==t&&(o.M3PImpuestos=[])},o.prototype.getValorTotalFromImpuestos=function(o,t){for(var e=0,r=0;r<o.M3PImpuestos.length;r++){e+=+o.M3PImpuestos[r][t]}return this.oMathTF.round(e,2)},o.prototype.agregarImpuesto=function(o,t){var e=o.M3DET.find(function(o){return"CTBLDIMPPRD"==o.NombreConcepto}),r=o.M3DET.find(function(o){return"PRECIOUNITBASE"==o.NombreConcepto}),n=0;return e&&r&&(n=this.LoadM3PImpuestosFromPrdGrl(e.Valor,o,+oo.multiply(r.Valor,t),t,+o.M3DET.find(function(o){return"PUNITNETO"==o.NombreConcepto}).Valor)),this.oMathTF.round(n,2)},o.prototype.InsUpdDetItem=function(o,t,e){var r;(r=o.M3DET.find(function(o){return o.NombreConcepto==e}))?r.Valor=t:o.M3DET.push(this.LoadM3PDetalle(t.toString(),e))},o.prototype.GetTotalByUnitario=function(o,t,e){try{var r=t.M3DET.find(function(o){return o.NombreConcepto==e}).Valor;return+oo.multiply(r,o)}catch(n){return 0}},o.prototype.GetUnitarioByTotal=function(o,t,e){try{return 0==+o?0:+t.M3DET.find(function(o){return o.NombreConcepto==e}).Valor/+o}catch(r){return 0}},o.prototype.AddItemsInterfaz=function(o,t){try{var e;e=t.filter(function(o){return o.ATRIBUTO.startsWith("CSIA_")});for(var r=0;r<e.length;r++)o.M3DET.push(this.LoadM3PDetalle(e[r].VALOR,e[r].ATRIBUTO))}catch(n){}},o.prototype.AdicionalesToDetalles=function(o,t){try{for(var e=0;e<t.length;e++)o.M3DET.push(this.LoadM3PDetalle(t[e].VALOR,"ADC_"+t[e].ATRIBUTO))}catch(r){}},o.prototype.camposAdicionalesToDetalles=function(o,t){try{for(var e=0;e<t.CamposAdicionales.length;e++)o.M3DET.push(this.LoadM3PDetalle(t.CamposAdicionales[e].VALOR,"CAMADC_"+t.CamposAdicionales[e].ATRIBUTO))}catch(r){}},o.prototype.GenerarInfoPromocionesProcesadas=function(o,t,e){void 0===e&&(e=!0);var r="",n="",i="";return o&&o.ListPromocionesAsociadas&&0<o.ListPromocionesAsociadas.length?(e?o.ListPromocionesAsociadas.filter(function(o){return o.Aplicada}).filter(function(o){return null==o.PromocionCombinada}).forEach(function(o){r=r+o.Nombre+",",n=n+o.IDPromocion+",",i=i+oo.multiply(o.Valor,t)+","}):o.ListPromocionesAsociadas.filter(function(o){return!o.Aplicada}).filter(function(o){return null==o.PromocionCombinada}).forEach(function(o){r=r+o.Nombre+",",n=n+o.IDPromocion+",",i=i+oo.multiply(o.Valor,t)+","}),{NOMBRES:r,ID:n,VALORES:i}):null},o.prototype.AddInfoPromocionesADetalle=function(o,t,e){var r=this.GenerarInfoPromocionesProcesadas(o,e);if(r){t.M3DET.push(this.LoadM3PDetalle(r.NOMBRES,"NOMB_PROMOC")),t.M3DET.push(this.LoadM3PDetalle(r.ID,"ID_PROMOC")),t.M3DET.push(this.LoadM3PDetalle(r.VALORES,"VAL_PROMOC"));for(var n=r.NOMBRES.replace(/.$/,"").split(","),i=r.ID.replace(/.$/,"").split(","),a=r.VALORES.replace(/.$/,"").split(","),s=0;s<i.length;s++)t.M3DET.push(this.LoadM3PDetalle(n[s],"NOMB_PROMOC_"+s)),t.M3DET.push(this.LoadM3PDetalle(i[s],"ID_PROMOC_"+s)),t.M3DET.push(this.LoadM3PDetalle(a[s],"VAL_PROMOC_"+s))}(r=this.GenerarInfoPromocionesProcesadas(o,e,!1))&&(t.M3DET.push(this.LoadM3PDetalle(r.NOMBRES,"NOMB_PROMOC_NOPRO")),t.M3DET.push(this.LoadM3PDetalle(r.ID,"ID_PROMOC_NOPRO")),t.M3DET.push(this.LoadM3PDetalle(r.VALORES,"VAL_PROMOC_NOPRO")))},o.prototype.LoadDetalleNivelesPrecio=function(o,t){o&&o.NIVEL!==undefined&&t.M3DET.push(this.LoadM3PDetalle(o.NIVEL,"NIVELPRECIO"))},o.prototype.VerificarPrecioByNiveles=function(o,t){try{var e,r={};return o.LoM3PrdGeneral[0].LoM3PrdLista.M3Presentaciones&&0<o.LoM3PrdGeneral[0].LoM3PrdLista.M3Presentaciones.length&&(e=o.LoM3PrdGeneral[0].LoM3PrdLista.M3Presentaciones.find(function(o){return t>=o.TOPE}))&&(o.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=e.VALOR,r={PRECIO:e.VALOR,NIVEL:e.NIVELPRS}),r}catch(n){return null}},o.prototype.VerificarPrecioByNivelesGeneral=function(o,t){try{var e,r={};return o.LoM3PrdLista.M3Presentaciones&&0<o.LoM3PrdLista.M3Presentaciones.length&&(e=o.LoM3PrdLista.M3Presentaciones.find(function(o){return t>=o.TOPE}))&&(o.LoM3PrdLista.PRECIO=e.VALOR,r={PRECIO:e.VALOR,NIVEL:e.NIVELPRS}),r}catch(n){return null}},o.prototype.get_list_cupones_from_promo=function(o,t){var e=Array();if(o.ListPromocionesAsociadas)for(var r=0;r<o.ListPromocionesAsociadas.length;r++){var n=o.ListPromocionesAsociadas[r];if(n.IdCupon){var i=new L;i.IdCupon=n.IdCupon,i.Cantidad=t,e.push(i)}}return e},o.prototype.AsignarPromocionesCombinadas=function(e,o,r){var n=this;null!=o&&null!=o.ListPromocionesAsociadas&&o.ListPromocionesAsociadas.forEach(function(o){var t;null!=o.PromocionCombinada&&(r.PromoCombinadas.push(o.PromocionCombinada),(t=r.M3DET.find(function(o){return"PROMOCOMBI"==o.NombreConcepto}))?t.Valor=JSON.stringify(r.PromoCombinadas):r.M3DET.push(n.LoadM3PDetalle(JSON.stringify(r.PromoCombinadas),"PROMOCOMBI")),n.AsignarPromocionesCombinadasAM3Proceso(e,o.PromocionCombinada))})},o.prototype.AsignarPromocionesCombinadasAM3Proceso=function(o,t){o.PromosCombinadas||(o.PromosCombinadas=new Array),o.PromosCombinadas.find(function(o){return o.IdPromocionCombinada==t.IdPromocionCombinada})||o.PromosCombinadas.push(t),o.PromosCombinadas&&this.AddDinamicaProcesoCombinadas(o)},o.prototype.AddDinamicaProcesoCombinadas=function(o){var t;if(t=o.lM3PDinamicas.find(function(o){return"COMBINADA"==o.Nombre})){for(var e=JSON.parse(t.Valor),r=0;r<e.length;r++){o.PromosCombinadas.find(function(o){return o.IdPromocionCombinada==e[r].IdPromocionCombinada})||o.PromosCombinadas.push(e[r])}t.Valor=JSON.stringify(o.PromosCombinadas)}else{var n=new R;n.Nombre="COMBINADA",n.Valor=JSON.stringify(o.PromosCombinadas),o.lM3PDinamicas.push(n)}},o.prototype.CalcularPromociones=function(o,t,e,r,n,i){var a=new k,s=new Array;s.push("DIRECTA"),s.push("COMBINADA"),s.push("MONEDERO"),s.push("MANUAL");try{if(null==r)throw new Error("No hay informacion de promociones");var c,u=new X(n,i);return c=u.VerificarPromociones(o,t,e,r,s),a=u.ProcesarPromocion(c,t,r,this.gsIdkatios)}catch(l){return(a=new k).PrecioTotal=t.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO,a.PrecioTotalPromocion=0,a.ListPromocionesAsociadas=null,a}},o.prototype.VerificarObsequios=function(t,e,r){var n=this;try{var o;this.obsequiosCantidad=0,null!=t.ListPromocionesAsociadas&&null!=(o=t.ListPromocionesAsociadas.filter(function(o){return null!=o.ListObsSKU}))&&0<o.length&&o.forEach(function(o){n.obsequioOPromo,o.ListObsSKU.length||(o.ListObsSKU=[o.ListObsSKU]),n.validaSiTieneOtraPromo(o,t.ListPromocionesAsociadas)&&(n.obsequioOPromo=o.IDPromocion),n.armarListaObsequiosSKU(o,r,e)})}catch(i){console.log(i)}},o.prototype.turnOnPromos=function(o){var t=this;try{var e;null!=o.ListPromocionesAsociadas&&(e=o.ListPromocionesAsociadas.filter(function(o){return o.lIdActivaPromo&&0<o.lIdActivaPromo.length}))&&0<e.length&&(e.forEach(function(o){t.lIdActivaPromo=t.lIdActivaPromo.concat(o.lIdActivaPromo)}),this.removeDuplicates(this.lIdActivaPromo))}catch(r){console.log(r)}},o.prototype.removeDuplicates=function(o){for(var t=[],e=0;e<o.length;e++)-1===t.indexOf(o[e])&&t.push(o[e])},o.prototype.armarListaObsequiosSKU=function(o,t,e){var r=Math.floor(e/o.CantidadObseq);"EXC"==o.ReglaObseq?(this.asignarIdEncPadreObsequio(o,t),this.obsequiosExc=!0,this.obsequiosCantidad=r):(this.asignarIdEncPadreObsequio(o,t),o.ListObsSKU.forEach(function(o){o.Cantidad=r*+o.Cantidad}),this.obsequiosExc=!1),this.oListaObsequios=o.ListObsSKU},o.prototype.asignarIdEncPadreObsequio=function(o,t){0<o.ListObsSKU.length&&o.ListObsSKU.forEach(function(o){o.idEncPadre=t.ID})},o.prototype.armarListaObsequiosCombiSKU=function(o,t,e){"EXC"==o.Accion.ReglaObseq?(this.asignarIdEncPadreObsequioCombinado(o.Accion.OBSEQUIOS,t),this.obsequiosExc=!0,this.obsequiosCantidad=e):(this.asignarIdEncPadreObsequioCombinado(o.Accion.OBSEQUIOS,t),o.Accion.OBSEQUIOS.forEach(function(o){o.Cantidad=e*+o.Cantidad}),this.obsequiosExc=!1),this.oListaObsequios=o.Accion.OBSEQUIOS},o.prototype.asignarIdEncPadreObsequioCombinado=function(o,t){0<o.length&&o.forEach(function(o){o.idEncPadre=t.ID})},o.prototype.validaSiTieneOtraPromo=function(t,o){var e,r;if("ACM"!=t.Regla){var n=o.filter(function(o){return o.IDPromocion!=t.IDPromocion});try{for(var i=v(n),a=i.next();!a.done;a=i.next()){var s=a.value;if("ACM"!=s.Regla&&s.Aplicada&&("EXC"==s.Regla||"EXC"==t.Regla))return!0}}catch(c){e={error:c}}finally{try{a&&!a.done&&(r=i["return"])&&r.call(i)}finally{if(e)throw e.error}}}return!1},o.prototype.ProcesarObsequios=function(r,n,i,a,s){return O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:if(o.trys.push([0,5,,6]),this.obsequiosExc=!1,this.obsequioOPromo=-1,!(null!=this.oListaObsequios&&0<this.oListaObsequios.length))return[3,4];t=0,o.label=1;case 1:return t<this.oListaObsequios.length?this.oListaObsequios[t].SKU?(this.oListaObsequios[t].Cantidad&&(n.dCantidad=this.oListaObsequios[t].Cantidad),n.BisObsequio=!0,n.IDEncPadre=this.oListaObsequios[t].idEncPadre,n.TipoAgrupacion="OBSQ",[4,this.GuardarPromocion(this.oListaObsequios[t],r,n,i,a,s)]):[3,3]:[3,4];case 2:o.sent(),o.label=3;case 3:return t++,[3,1];case 4:return[3,6];case 5:return e=o.sent(),console.log(e),[3,6];case 6:return this.oListaObsequios=null,[2]}})})},o.prototype.GuardarPromocion=function(t,e,r,n,i,a){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.AdicionarPromocionAProceso(t,a,r,n,i,e)];case 1:return o.sent(),[2]}})})},o.prototype.AdicionarPromocionAProceso=function(e,r,n,i,a,s){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return t=null,[4,this.GetProductoBySKU(e.SKU,a,r,s)];case 1:return t=o.sent(),console.debug(t),null!=t&&(r=this.addtocart(n,t,null,null,s,this.gsIdkatios,i,null,r,null,100)),[2,r]}})})},o.prototype.GetProductoBySKU=function(a,s,c,u,l){return void 0===l&&(l=null),O(this,void 0,void 0,function(){var t,e,r,n,i;return S(this,function(o){switch(o.label){case 0:return t=new $,r=null,n=new Q(this.gsIdkatios),s||u.UsuarioSistema.FechaPrecio?[3,2]:(i=this.gsIdkatios+"?PRD",[4,this.oM3CouchMaestro.get(i)]);case 1:return e=o.sent(),r=t.GetM3PrdGrpFromList(e.M3ListProductos.M3GRP,a),[3,4];case 2:return[4,t.M3GetProductoBySKUAsync(this.GoPostServiceM3,this.gsIdkatios,a,u,c.Ubic1.toString())];case 3:r=o.sent(),o.label=4;case 4:return r.LoM3PrdGeneral[0].DISPONIBLE<=0&&l&&(r.LoM3PrdGeneral[0].DISPONIBLE=l),[4,n.AsignarListaPrecio(r,u,this.GoPostServiceM3)];case 5:return o.sent(),[2,r]}})})},o.prototype.CalculatePrecioBase=function(o,t){var e=t;try{var r=new m;""!=o&&r.convertXmlToJson(o).IMPUESTOS.IMPUESTO.forEach(function(o){e="PORCENTAJE"==o.$.Metodologia?+e/(+o.$.Valor+1):+e-+o.$.Valor})}catch(n){console.log("Catch")}return e},o.prototype.LoadM3PImpuestosFromPrdGrl=function(o,t,e,r,n){try{var i,a,s=new m,c=this.oMathTF.round(e,4),u=c,l=+oo.multiply(n,r),d=0;if(""!=o)for(var f=(a=s.convertXmlToJson(o)).IMPUESTOS.IMPUESTO.length-1;0<=f;f--){var p=0,h=a.IMPUESTOS.IMPUESTO[f];(i=new A).CodImpuesto=h.$.CodImp,i.Porcentaje=h.$.Valor,"PORCENTAJE"==h.$.Metodologia?(p=+oo.multiply(h.$.Valor,u),i.Valor=this.oMathTF.round(p,2),i.Valor<p?i.LimiteOpuesto=+Math.ceil(+oo.multiply(p,100))/100:i.LimiteOpuesto=+Math.floor(+oo.multiply(p,100))/100):(p=+h.$.Valor,i.Valor=this.oMathTF.round(p,2)),i.Base=this.oMathTF.round(u,2),d=this.oMathTF.round(+d,2)+this.oMathTF.round(+i.Valor,2),u=this.oMathTF.round(+this.oMathTF.round(u,2)+this.oMathTF.round(+i.Valor,2),2),t.M3PImpuestos.find(function(o){return o.CodImpuesto==i.CodImpuesto})&&(t.M3PImpuestos=t.M3PImpuestos.filter(function(o){return o.CodImpuesto!=i.CodImpuesto})),t.M3PImpuestos.push(i)}if(0==d)return 0;d=this.oMathTF.round(d,2);var P=this.oMathTF.round(+l-+this.oMathTF.round(c,2)-+d,2);return isNaN(P)&&(P=this.oMathTF.round(+(+l-+this.oMathTF.round(c,2)-+d).toFixed(4),2)),0!=P&&this.ajustadorDeImpuestos(t,P),this.oMathTF.round(l-this.oMathTF.round(c,2),2)}catch(M){return console.log("Catch"),0}},o.prototype.ajustadorDeImpuestos=function(o,t){for(var e=0;e<o.M3PImpuestos.length;e++){var r=o.M3PImpuestos[e];if(0<t?r.Valor<r.LimiteOpuesto&&(r.Valor=r.LimiteOpuesto,r.Base=this.oMathTF.round(r.Valor/r.Porcentaje,2),t-=.01):r.Valor>r.LimiteOpuesto&&(r.Valor=r.LimiteOpuesto,r.Base=this.oMathTF.round(r.Valor/r.Porcentaje,2),t+=.01),0==t)break}},o.prototype.LoadM3PDetalle=function(o,t){var e=new T;return e.NombreConcepto=t,e.Valor=o,e},o.prototype.GenerarPromoCombinada=function(e,r){return O(this,void 0,void 0,function(){var t;return S(this,function(o){return(!e.lM3PDinamicas||e.lM3PDinamicas&&!e.lM3PDinamicas.find(function(o){return"PUENTE_DIARIO"==o.Nombre}))&&(t=new X(r,null),e=t.ProcesarCombinada(e),this.RecalcularPrecios(e)),[2]})})},o.prototype.CompareM3Proceso=function(c,u,l,d){return O(this,void 0,void 0,function(){var t,e,r,n,i,a,s;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=["ValorNeto","Valor"],n=!0,e=u.GetKeyCarritoCompras(c,l.UsuarioSistema.TDOC,l.UsuarioSistema.NDOC,l.UsuarioSistema.UBICACION,l.UsuarioSistema.IDHUB),[4,u.GetDataPouchBD(e)];case 1:for(r=o.sent(),i=0;i<t.length;i++)if(d[t[i]]!=r[t[i]]){n=!1;break}if(n)for(a=0;a<d.M3ENC.length;a++)if(r.M3ENC[a].ID!=d.M3ENC[a].ID||r.M3ENC[a].IdProducto!=d.M3ENC[a].IdProducto||r.M3ENC[a].M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor!=d.M3ENC[a].M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor){n=!1;break}return[2,{bResp:n,M3Procesos:r}];case 2:return s=o.sent(),console.log("Error CompareM3Proceso"),console.log(s),[2,{bResp:!0,M3Procesos:null}];case 3:return[2]}})})},o.prototype.AddComercialToM3Proceso=function(o,t,e){o.lM3PDinamicas.push(this.CreateTuplaDinamica("TCOMERCIAL",t)),o.lM3PDinamicas.push(this.CreateTuplaDinamica("NCOMERCIAL",e))},o.prototype.CreateTuplaDinamica=function(o,t){var e=new R;return e.Nombre=o,e.Valor=t,e},o.prototype.setCantidadALLYUPDCouch=function(t,e,r,n,i,o,a){var s=this;0==a&&t.IDDiario===undefined?(t.M3ENC=new Array,this.UpdateM3ProcesosWithData(t,e,r,n,"WEB",i,o)):0==a?this.DeleteM3Proceso(e,r,n).then(function(o){s.GetCarritoComprasPouchDB(e,r,n).then(function(o){t=new w,i(t)})}):(t.M3ENC.forEach(function(o){o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor=a}),this.UpdateM3ProcesosWithData(t,e,r,n,"WEB",i,o))},o.prototype.setCantidadYUPDCouch=function(t,e,r,n,i,a,s,c,u,l,d,f,o,p){var h=this;(void 0===p&&(p=!1),0==u&&t.IDDiario===undefined&&"WEB"==l||p)?(t.M3ENC=t.M3ENC.filter(function(o){return!(o.IdProducto==s&&o.ID==d||o.IdEncPadre==d)}),(new N).dCantidad=0,this.UpdateM3ProcesosWithData(t,e,r,n,l,i,a,f)):0==u?(t.M3ENC.filter(function(o){return o.IdProducto==s&&o.Lote==c&&o.ID==d||o.IdEncPadre==d}).forEach(function(o){o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor=u}),this.UpdateM3ProcesosWithData(t,e,r,n,l,i,a,f)):this.setCantidadV2(t,s,c,u,d,r,n,f,o).then(function(o){h.UpdateM3ProcesosWithData(t,e,r,n,l,i,a,f,o.M3PItemsWEB)})},o.prototype.setCantidadV2=function(n,i,a,s,c,u,l,d,f){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return t=null,(e=new N).dCantidad=s,(r=n.M3ENC.find(function(o){return o.IdProducto==i&&o.Lote==a&&o.ID==c}))&&(e.PathImagen=r.PathImage),n.M3ENC=n.M3ENC.filter(function(o){return!(o.IdProducto==i&&o.Lote==a&&(o.ID==c||o.IdEncPadre==c))}),[4,this.GetProductoBySKU(i,!0,n,u,r.DISPONIBLE)];case 1:return t=o.sent(),e=this.LoadAdicionales(e,t),[2,{M3Proceso:n=this.addtocart(e,t,null,null,u,l,d,f,n),M3PItemsWEB:e}]}})})},o.prototype.get_M3ENC_by_idprd_lote=function(o,t,e){return o.M3ENC.find(function(o){return o.IdProducto==t&&o.Lote==e})},o.prototype.getCantidad=function(o,t){return o.M3ENC.find(function(o){return o.IdProducto==t.SKU&&o.Lote==t.LOTE}).M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},o.prototype.getCantidadTotal=function(o){if(o===undefined||o.M3ENC===undefined)return 0;o.M3ENC.filter(function(o){return 0<+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor}).reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},0)},o.prototype.MergeRecepYEnc=function(o,t){var e=this;0<o.M3PRecepcion.length&&o.M3PRecepcion.filter(function(o){return o.IdRecepcion==t}).forEach(function(t){o.M3ENC.find(function(o){return o.ID==t.IdEnc}).M3DET.push(e.LoadM3PDetalle(t.Cantidad.toString(),"CURCREC"))})},o.prototype.RemoveCurCRec=function(o){o!==undefined&&null!=o&&o.M3ENC!==undefined&&null!=o.M3ENC&&o.M3ENC.forEach(function(o){var t;(t=o.M3DET.find(function(o){return"CURCREC"==o.NombreConcepto}))!==undefined&&null!=t&&(t.Valor="0")})},o.prototype.MergeEntpYEnc=function(e){var r=this;0<e.M3PEnvios.length&&e.M3PEnvios.forEach(function(t){var o;(o=e.M3ENC.filter(function(o){return o.IdEnvio==t.IdEnvio}))!==undefined&&null!=o&&o.forEach(function(o){o.M3DET.push(r.LoadM3PDetalle(o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor,"CURCENT"))})})},o.prototype.RemoveCurCEnt=function(o){o!==undefined&&null!=o&&o.M3ENC!==undefined&&null!=o.M3ENC&&o.M3ENC.forEach(function(o){var t;(t=o.M3DET.find(function(o){return"CURCENT"==o.NombreConcepto}))!==undefined&&null!=t&&(t.Valor="0")})},o.prototype.ProcPromoAfterAddToCart=function(t,e,r,n,i){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.ProcesarObsequios(e,r,n,i,t)];case 1:return o.sent(),[2]}})})},o.prototype.ProcPromoAfterFinalizar=function(o,t,e,r){this.GenerarPromoCombinada(o,r),this.PromoAfterProceso(o,t,e,r)},o.prototype.PromoAfterProceso=function(o,t,e,r){try{var n,i=new X(r,null),a=new Array,s=new k;a.push("AFTER"),n=i.VerificarPromociones(o,null,t,e,a),null!=(s=i.ProcesarPromoAfter(n,o,e))&&(o.ValorNeto=s.PrecioTotal,this.AddInfoPromocionesADinamicas(o,s))}catch(c){}},o.prototype.AddInfoPromocionesADinamicas=function(o,t){var e=this.GenerarInfoPromocionesProcesadas(t,0);if(null!=e){var r=new R;r=this.CreateTuplaDinamica("VAL_PROMOC",t.PrecioTotalPromocion.toString()),o.lM3PDinamicas.push(r),r=this.CreateTuplaDinamica("NOMB_PROMOC",e.NOMBRES),o.lM3PDinamicas.push(r),r=this.CreateTuplaDinamica("ID_PROMOC",e.ID),o.lM3PDinamicas.push(r)}},o.prototype.get_m3_proceso_by_id_prestamo_async=function(t,e,r){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,t.getM3("M3/getM3ProcesoByIdPrestamo/"+e+"/"+r).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.GetConceptoM3SaldosItemUb=function(t,e,r){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,t.getWithBodyM3("M3/GetConceptoM3SaldosItemUb/"+e,r).toPromise()];case 1:return[2,o.sent()];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.addProductoToOtrasClas=function(o,t,e,r){var n,i,a=e;i=o.LoM3PrdGeneral[0];var s=this.validarExistaOtraClasif(a.M3OtClasificaciones,o);s?(s.Cantidad=s.Cantidad+t,s.Valor=+oo.multiply(i.LoM3PrdLista.PRECIO,s.Cantidad),s.Orden=this.GetMaxAtributoFromLista(a.M3OtClasificaciones,"Orden")+1):((n=new J).Cantidad=t,n.IdProducto=i.SKU,n.Nombre=i.NOMBRE1,n.Valor=+oo.multiply(i.LoM3PrdLista.PRECIO,t),n.ID=this.GetMaxAtributoFromLista(a.M3OtClasificaciones,"ID")+1,n.Orden=this.GetMaxAtributoFromLista(a.M3OtClasificaciones,"Orden")+1,a.M3OtClasificaciones.push(n)),e=this.recalcularValOtraClasiM3Procesos(e),r(a)},o.prototype.deleteProductoFromOtrasClas=function(t,o){var e=o.M3OtClasificaciones.find(function(o){return o.IdProducto==t.IdProducto});return e&&(e.Cantidad=0,e.Valor=0),o=this.recalcularValOtraClasiM3Procesos(o)},o.prototype.recalcularValOtraClasiM3Procesos=function(o){return o.ValOtraClasi=o.M3OtClasificaciones.reduce(function(o,t){return o+t.Valor},0),o},o.prototype.validarExistaOtraClasif=function(o,t){return o.find(function(o){return o.IdProducto==t.LoM3PrdGeneral[0].SKU})},o.prototype.deletePrdDevolucion=function(t,o){var e=o.M3ENC.find(function(o){return o.IdProducto==t.IdProducto});e&&(e.M3DET.forEach(function(o){isNaN(+o.Valor)||(o.Valor="0")}),e.M3PImpuestos.forEach(function(o){o.Valor=0,o.Base=0}))},o.prototype.ajustadorValoresCFDIFront=function(o){var t,e=this.getValorTotalDescuentos(o),r=this.getValorTotalImporteImpuestos(o);return 0!=(t=this.oMathTF.round(o.ValorNeto-(o.Valor+r-e),3))&&(0<r?this.ajustadorImpuestosCFDI(t,o):this.ajustadorDescuentosCFDI(t,o)),o},o.prototype.getValorTotalDescuentos=function(o){var e=0;return o.M3ENC.forEach(function(o){var t=o.M3DET.find(function(o){return"TOTALPROMO"==o.NombreConcepto});t&&(e+=+t.Valor)}),e},o.prototype.getValorTotalImporteImpuestos=function(o){var t=0;return o.M3ENC.forEach(function(o){o.M3PImpuestos.forEach(function(o){t+=+o.Valor})}),t},o.prototype.ajustadorImpuestosCFDI=function(o,t){var e,r,n,i,a=!1;try{for(var s=v(t.M3ENC),c=s.next();!c.done;c=s.next()){var u=c.value;try{for(var l=v(u.M3PImpuestos),d=l.next();!d.done;d=l.next()){var f=d.value;f.Valor=0<o?f.Valor+.01:f.Valor-.01,f.Base=f.Valor/f.Porcentaje,a=!0;break}}catch(p){n={error:p}}finally{try{d&&!d.done&&(i=l["return"])&&i.call(l)}finally{if(n)throw n.error}}if(a)break}}catch(h){e={error:h}}finally{try{c&&!c.done&&(r=s["return"])&&r.call(s)}finally{if(e)throw e.error}}},o.prototype.ajustadorDescuentosCFDI=function(o,t){var e,r,n;try{for(var i=v(t.M3ENC),a=i.next();!a.done;a=i.next()){if((n=a.value.M3DET.find(function(o){return"TOTALPROMO"==o.NombreConcepto}))&&0<+n.Valor){n.Valor=0<o?(+n.Valor-.01).toString():(+n.Valor+.01).toString();break}}}catch(s){e={error:s}}finally{try{a&&!a.done&&(r=i["return"])&&r.call(i)}finally{if(e)throw e.error}}},o.prototype.getPrdsGeneralFromM3Proceso=function(o,t,e,r,n){o.getWithBodyM3("M3/getPrdsGeneralFromM3Proceso/"+t,e).subscribe(function(o){r(o)},function(o){n(JSON.parse(o.error.Message))})},o}(),eo=function(){function o(){}return o.prototype.M3_GetDiario=function(o,t,e,r,n){o.getWithBodyM3("M3Trx/M3_GetDiario/"+t,e).subscribe(function(o){var t;(t=o).RESPUESTA.data.length===undefined&&(t.RESPUESTA.data=new Array(t.RESPUESTA.data)),r(o)},function(o){n(o.error.Message)})},o.prototype.m3_getDiarioTrx=function(o,t,e,r,n){o.getWithBodyM3("M3Trx/m3_getDiarioTrx/"+t,e).subscribe(function(o){var t;(t=o).RESPUESTA.Diario.length===undefined&&(t.RESPUESTA.Diario=new Array(t.RESPUESTA.Diario)),r(o)},function(o){n(o.error.Message)})},o.prototype.M3_GetInfoTRX=function(o,t,e,r,n){o.getWithBodyM3("M3Trx/M3_GetInfoTRX/"+t,e).subscribe(function(o){var t;(t=o).RESPUESTA.TIPOS.length===undefined&&(t.RESPUESTA.TIPOS=new Array(t.RESPUESTA.TIPOS)),t.RESPUESTA.TIPOS.forEach(function(o){o.TRX.length===undefined&&(o.TRX=new Array(o.TRX))}),r(t)},function(o){n(o.error.Message)})},o.prototype.CambioEstadoUbicacion=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Trx/CambioEstadoUbicacion/"+t,e).subscribe(function(o){r(o)},function(o){console.log(o._body),n(o._body)})},o.prototype.CambioEstadoHub=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Trx/CambioEstadoHub/"+t,e).subscribe(function(o){r(o)},function(o){console.log(o._body),n(o._body)})},o.prototype.CambioNDocActivoHub=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3Trx/CambioNDocActivoHub/"+t,e).subscribe(function(o){r(o)},function(o){console.log(o._body),n(o._body)})},o}(),ro=function(){function o(o,t){this.lPreciosSelected="-1";var e={USER:o,Proceso:t};this.goData=e}return o.prototype.GetListaPrecios=function(n,i){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.gsIdKatios=i,t=new $,(e=this.GetLPreciosInStorage(i))?[3,2]:[4,t.M3GET_LISTAPRECIOS_ASync(n,i)];case 1:e=o.sent(),this.SaveLPreciosInStorage(e,i),o.label=2;case 2:return this.ValidarAPLRegla(e),[2,this.lPreciosSelected];case 3:return r=o.sent(),console.log(r),[3,4];case 4:return[2]}})})},o.prototype.SaveLPreciosInStorage=function(o,t){localStorage.setItem("RegPrecio"+t,JSON.stringify(o))},o.prototype.SaveConfigLPreciosInStorage=function(o,t){console.debug(o),sessionStorage.setItem("ConfigLP"+t,o)},o.prototype.GetLPreciosInStorage=function(o){var t=localStorage.getItem("RegPrecio"+o);return t?JSON.parse(t):null},o.prototype.GetConfigLPreciosInStorage=function(o){var t=sessionStorage.getItem("ConfigLP"+o);return t?JSON.parse(t):null},o.prototype.FindLPrecio=function(o){var t,e;if(o!==undefined&&null!=o&&o.ID!==undefined&&null!=o.ID&&o.PRECEDENCIA!==undefined&&null!=o.PRECEDENCIA&&o.PRECEDENCIA.length!==undefined)try{for(var r=v(o.PRECEDENCIA),n=r.next();!n.done;n=r.next()){var i=n.value;this.ValidarAPLRegla(i)}}catch(a){t={error:a}}finally{try{n&&!n.done&&(e=r["return"])&&e.call(r)}finally{if(t)throw t.error}}},o.prototype.ValidarAPLRegla=function(o){var t=!1;if(o!==undefined)try{switch(console.debug(o.Propiedad),o.Propiedad.toUpperCase().trim()){case"EMPRESA":t=this.Compare(o.Valor.toString(),this.gsIdKatios.toString());break;case"UBICACION":t=this.Compare(o.Valor.toString(),this.goData.USER.UsuarioSistema.UBICACION.toString());break;case"PROCESO":t=this.Compare(o.Valor.toString(),this.goData.Proceso.toString());break;case"HUB":t=this.Compare(o.Valor.toString(),this.goData.USER.UsuarioSistema.IDHUB.toString());break;default:t=this.Compare(o.Valor.toString(),this.goData.USER.UsuarioSistema[o.Propiedad.toUpperCase().trim()].toString())}}catch(e){console.error("error: "+e)}return t&&(this.lPreciosSelected=o.ListaPrecios,this.FindLPrecio(o)),t},o.prototype.Compare=function(o,t){return o==t},o.prototype.GetConfigListaPrecios=function(n,i){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),this.gsIdKatios=i,t=new $,(e=this.GetConfigLPreciosInStorage(i))?[3,2]:[4,t.GetEncabezadoListasPrecio(n,i)];case 1:e=o.sent(),this.SaveConfigLPreciosInStorage(e,i),o.label=2;case 2:return[2,e];case 3:return r=o.sent(),console.log(r),[3,4];case 4:return[2]}})})},o}(),no=function lt(){},io=function dt(){this.M3GRP=new D},ao=function ft(){},so=function pt(){this.M3HUBS=new Array},co=function ht(){},uo=function Pt(){},lo=function Mt(){},fo=function mt(){this.EstadoManuales=!1,this.EsManual=!1,this.EstadoAplCupon=!1,this.EsAplCupon=!1},po=function(){function o(o){this.goM3Ubicacion=o}return o.prototype.GetDireccion=function(){return this.GetAdicionarByAtribute("DIRECCION")},o.prototype.GetTelefono=function(){return this.GetAdicionarByAtribute("TELEFONO")},o.prototype.GetLong=function(){return this.GetAdicionarByAtribute("LONG")},o.prototype.GetLat=function(){return this.GetAdicionarByAtribute("LAT")},o.prototype.GetAdicionarByAtribute=function(t){try{var o=this.goM3Ubicacion.M3UbiAdicionales.find(function(o){return o.Atributo==t});return o!==undefined&&null!=o?o.Valor:"N/A"}catch(e){return"N/A"}},o}(),ho=function(){function o(o,t,e,r,n){this.oCouchPRDSService=n,this.separador=",",this.oM3Proceso=new w,this.gbBarCode=!1,this.oM3Proceso=t,this.gsIdKatios=o,this.ConfMasiva=e,this.gbBarCode=r}return o.prototype.get_rounded_progress=function(){return this.rounded_progress},o.prototype.AdicionarMasivo=function(r,n,i,a,s){return void 0===s&&(s=null),O(this,void 0,void 0,function(){var t,e;return S(this,function(o){switch(o.label){case 0:return this.GetReader(a),t=this.reader?this.reader.result.toString():a.Text,e=t.split("\n"),[4,this.adicionar_masivo_from_array(r,n,i,e,s)];case 1:return[2,o.sent()]}})})},o.prototype.adicionar_masivo_from_array=function(p,h,P,M,m,C){return void 0===m&&(m=null),void 0===C&&(C="0"),O(this,void 0,void 0,function(){var t,e,a,s,r,c,u,n,i,l,d,f=this;return S(this,function(o){switch(o.label){case 0:t=M.length,e=0,s=new $,r=new to(p,h,this.gsIdKatios),c="",u=!1,this.progress=0,n=[this.oM3Proceso,""],i=0,o.label=1;case 1:return i<t?(u=!1,(l=M[i])?(d=this.SetEstructCSV(l),this.gbBarCode?(console.debug("fue local: "+d.sku),[4,this.oCouchPRDSService.get(d.sku).then(function(t){return O(f,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return console.debug("obtuvo local"),console.debug(t),[4,new Q(this.gsIdKatios).AsignarListaPrecio(t.ListCods,P,h).then(function(o){console.debug("asigno lp local"),console.debug(t.ListCods),a=t.ListCods})];case 1:return o.sent(),[2]}})})},function(i){return O(f,void 0,void 0,function(){var t,e,r,n;return S(this,function(o){switch(o.label){case 0:console.error("error lp - intento server: "+d.sku+": "+i),t={id_ubicacion:P.UsuarioSistema.UBICACION,Codigo:d.sku},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,s.Get_M3ProductoEspecByCodeAsync(h,this.gsIdKatios,t,P)];case 2:return a=o.sent(),[3,4];case 3:return e=o.sent(),console.error("error catch lp: "+d.sku+": "+e),r=e.url,n=r.substring(r.indexOf("Codigo")+7),c+=n+",",u=!0,[3,4];case 4:return[2]}})})})]):[3,3]):[3,8]):[3,10];case 2:return o.sent(),[3,7];case 3:return console.debug(m),console.debug(m&&m.IDUbicacion),m&&m.IDUbicacion?[4,s.M3GetProductoBySKUAsync(h,this.gsIdKatios,d.sku,P,m.IDUbicacion,C)]:[3,5];case 4:return a=o.sent(),[3,7];case 5:return[4,s.M3GetProductoBySKUAsync(h,this.gsIdKatios,d.sku,P,"-1",C)];case 6:a=o.sent(),o.label=7;case 7:console.debug(a),!u&&a?(this.setPrecioSiAPlica(a,d),this.AddPrdToM3Proceso(a,d,r,P,m)):console.error("error product no se lleno: "+d.sku),o.label=8;case 8:e++,this.progress=100*e/t,this.rounded_progress=Math.round(100*this.progress)/100,o.label=9;case 9:return i++,[3,1];case 10:return n[0]=this.oM3Proceso,n[1]=c,[2,n]}})})},o.prototype.setPrecioSiAPlica=function(o,t){t.precio!==NaN&&null!=t.precio&&(o.LoM3PrdGeneral[0].LoM3PrdLista.PRECIO=t.precio,o.LoM3PrdGeneral[0].LoM3PrdLista.M3Presentaciones.forEach(function(o){o.VALOR=t.precio}))},o.prototype.AddPrdToM3Proceso=function(o,t,e,r,n){void 0===n&&(n=null);var i=new N;i.dCantidad=t.cantidad,t.PathImagen&&(i.PathImagen=t.PathImagen),i=e.LoadAdicionales(i,o),0==this.oM3Proceso.M3ENC.length?(this.oM3Proceso=e.LoadM3ProcesoEmptyPDB(o,i,r,n,null,this.oM3Proceso),this.AdicionarDinamica(t),this.AdicionarPersonasAProceso(t)):e.LoadM3ProcesoFromData(this.oM3Proceso,o,i,n,null,r),this.AdicionarDetalle(t)},o.prototype.AdicionarDinamica=function(o){try{for(var t=o.Dinamicas,e=0;e<t.length;e++){var r=new R;this.oM3Proceso.lM3PDinamicas||(this.oM3Proceso.lM3PDinamicas=new Array),r.Nombre=t[e].Atributo,r.Valor=t[e].Valor,this.oM3Proceso.lM3PDinamicas.push(r)}}catch(n){console.log("Error adicionar dinamica"),console.log(n)}},o.prototype.AdicionarPersonasAProceso=function(o){try{for(var t=o.Personas,e=0;e<t.length;e++){var r=new K;this.oM3Proceso.M3PerXProceso||(this.oM3Proceso.M3PerXProceso=new Array),r.Tdoc=t[e].Tdoc,r.Ndoc=t[e].Ndoc,r.TipoPersona=t[e].Atributo,this.oM3Proceso.M3PerXProceso.push(r)}}catch(n){console.log("Error adicionar personas"),console.log(n)}},o.prototype.AdicionarDetalle=function(o){try{for(var t=o.M3Det,e=0;e<t.length;e++){var r=new T;r.NombreConcepto=t[e].Atributo,r.Valor=t[e].Valor,this.oM3Proceso.M3ENC[this.oM3Proceso.M3ENC.length-1].M3DET.push(r)}}catch(n){console.log("Error adicionar detalle"),console.log(n)}},o.prototype.GetReader=function(o){this.reader=o.CSV,this.separador=o.Separador},o.prototype.SetEstructCSV=function(o){try{var t=o.split(this.separador);return this.ConfMasiva&&this.ConfMasiva.Columnas?this.EstructDynamic(t):this.EstructDefault(t)}catch(e){return console.log("Error creando estructura. Revisar lineas"),console.log(e),null}},o.prototype.EstructDynamic=function(o){for(var t=this.ConfMasiva.Columnas,e={cantidad:null,precio:null,sku:null,PathImagen:null,Dinamicas:[],Personas:[],M3Det:[]},r=0;r<t.length;r++)switch(t[r].Estructura){case"Cantidad":e.cantidad=+o[t[r].Posicion];break;case"Precio":e.precio=+o[t[r].Posicion];break;case"SKU":e.sku=o[t[r].Posicion];break;case"DINAMICA":var n={Atributo:t[r].Atributo,Valor:o[t[r].Posicion]};e.Dinamicas.push(n);break;case"M3DET":var i={Atributo:t[r].Atributo,Valor:o[t[r].Posicion]};e.M3Det.push(i);break;case"TIPOPERSONA":var a,s=o[t[r].Posicion],c="5";a=2<=s.split("-").length?(c=s.split("-")[0],s.split("-")[0]):s;var u={Atributo:t[r].Atributo,Tdoc:c,Ndoc:a};e.Personas.push(u)}return e},o.prototype.EstructDefault=function(o){var t={cantidad:null,precio:null,sku:null,PathImagen:null,Dinamicas:[],Personas:[],M3Det:[]};return 1<=o.length&&(t.sku=o[0]),2<=o.length&&(t.cantidad=+o[1]),3<=o.length&&(t.precio=+o[2]),4<=o.length&&(t.PathImagen=o[3]),t},o}(),Po=function(){function o(){}return o.prototype.add_dinamica_idprestamo_to_proceso=function(n,i,a,s,c,u){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:(e=new R).Nombre="IdPrestamo",e.Valor=a,o.label=1;case 1:return o.trys.push([1,4,,6]),[4,new to(null,null,i).get_m3_proceso_by_id_prestamo_async(n,i,a)];case 2:return(r=o.sent()).EstadoDes=r.EstadoAnt,r.SubEstadoDes=r.SubEstadoAnt,[4,this.add_pdinamica_to_existing_proceso(n,r,i,s,c,e,u)];case 3:return t=o.sent(),[3,6];case 4:return o.sent(),[4,this.add_pdinamica_to_new_proceso(n,i,s,c,e,u)];case 5:return t=o.sent(),[3,6];case 6:return[2,t]}})})},o.prototype.add_pdinamica_to_new_proceso=function(n,i,a,s,c,u){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return t=this.GetM3PItemsWEB(u),e=new to(null,null,i),(r=e.LoadM3ProcesoEmptyPDB(a,t,s,null,null,null)).lM3PDinamicas.push(c),r.EstadoDes="Activo",r.SubEstadoDes="Registro",[4,e.procesamiento_service_async(i,n,r,s)];case 1:return[2,o.sent()]}})})},o.prototype.add_pdinamica_to_existing_proceso=function(n,i,a,s,c,u,l){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return t=this.GetM3PItemsWEB(l),e=new to(null,null,a),(r=e.LoadM3ProcesoFromData(i,s,t,null,null,c)).lM3PDinamicas.push(u),[4,e.procesamiento_service_async(a,n,r,c)];case 1:return[2,i=o.sent()]}})})},o.prototype.GetM3PItemsWEB=function(o){var t=new N;return t.dCantidad=1,t.IdProceso="M3VENTA",o.forEach(function(o){t[o.Nombre]=o.Valor}),t},o}(),Mo=function(){function o(){}return o.prototype.ProcesarReverso=function(o,t,e,r,n,i,a){o.postServiceHttpResFullM3("M3Reverso/Reversar/"+t+"/"+r+"/"+e,n).subscribe(function(o){i(o)},function(o){a(o)})},o}(),mo=function Ct(){},Co=function gt(){},go=function It(){},Io=function yt(){this.M3PDinamByActividad=new Array,this.Actual=undefined},yo=function(){function o(){}return o.prototype.m3_get_cupones_generados_by_proceso=function(o,t,e,r,n){o.getWithBodyM3("M3/m3_get_cupones_generados_by_proceso/"+t,e).subscribe(function(o){var t,e=JSON.parse(o.toString());e.CUPONES.CUPON.length?t=e.CUPONES.CUPON:(t=new Array).push(e.CUPONES.CUPON),r(t)},function(o){n(o.error.Message)})},o.prototype.getCuponByIdDet=function(o,t,e,r,n){o.getWithBodyM3("M3/getCuponByIdDet/"+t,e).subscribe(function(o){r(o)},function(o){n(o)})},o}(),Oo=function(){function o(){if(this.listener=new r.EventEmitter,!this.isInstantiated){var o=this.GetIdKatiosLVL1FromSession();this.database=new a("Offline"+o,{auto_compaction:!0}),this.isInstantiated=!0}}return o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.get=function(o){return this.database.get(o)},o.prototype.AddDocument=function(o,t){var r=this;return t._id=o,console.log("AddDocument"),this.get(o).then(function(o){return console.log("AddDocument enconrtro document"),t._rev=o._rev,r.database.put(t)},function(e){return console.log(e.status),"404"==e.status?(delete t._rev,r.database.put(t)):new Promise(function(o,t){t(e)})})},o.prototype.DestroyTotal=function(){this.database.destroy()},o.prototype.GetAllDocsDeleted=function(){return this.database.allDocs({include_docs:!0,deleted:!0})},o.prototype.GetAllDocs=function(){return this.database.allDocs({include_docs:!0})},o.prototype.GetAllDocsOffLineSinDocs=function(){return this.database.allDocs({include_docs:!1})},o.prototype.Destroy=function(t){var e=this;this.database.destroy().then(function(o){setTimeout(function(){var o=e.GetIdKatiosLVL1FromSession();e.database=new a("OfflineLog"+o,{auto_compaction:!0}),t({Resp:"OK"})},2e3)})["catch"](function(o){t({Resp:"Error",Desc:o}),console.log(o)})},o.prototype.DeleteAllDocs=function(){var t=this;this.database.allDocs({include_docs:!0}).then(function(o){return o.rows.filter(function(o){return!o.id.startsWith("CTIVOS")}).map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return t.database.bulkDocs(o)})},o.prototype.Delete=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),So=function(){function o(o){if(this.oM3DevicesService=o,this.listener=new r.EventEmitter,this.AddLogSocketOK=function(){},!this.isInstantiated){var t=this.GetIdKatiosLVL1FromSession();this.database=new a("OfflineLog"+t,{auto_compaction:!0}),this.isInstantiated=!0}}return o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.get=function(o){return this.database.get(o)},o.prototype.AddDocument=function(o,t){var r=this;return t._id=o,this.get(o).then(function(o){return t._rev=o._rev,r.database.put(t)},function(e){return"404"==e.status?r.database.put(t,{force:!0}):new Promise(function(o,t){t(e)})})},o.prototype.Destroy=function(t){var e=this;this.database.destroy().then(function(o){setTimeout(function(){var o=e.GetIdKatiosLVL1FromSession();e.database=new a("OfflineLog"+o,{auto_compaction:!0}),t({Resp:"OK"})},2e3)})["catch"](function(o){t({Resp:"Error",Desc:o}),console.log(o)})},o.prototype.closeInstance=function(){this.database.close()},o.prototype.InstanceAgain=function(){try{var o=this.GetIdKatiosLVL1FromSession();this.database=new a("OfflineLog"+o,{auto_compaction:!0})}catch(t){}},o.prototype.GetAllDocsDeleted=function(){return this.database.allDocs({include_docs:!0,deleted:!0})},o.prototype.GetAllDocs=function(){return this.database.allDocs({include_docs:!0})},o.prototype.DeleteAllDocs=function(){var t=this;this.database.allDocs({include_docs:!0}).then(function(o){return o.rows.filter(function(o){return!o.id.startsWith("CTIVOS")}).map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return t.database.bulkDocs(o)})},o.prototype.DeleteOldDocs=function(t){var e=this;console.debug("DeleteOldDocs"),this.database.allDocs({include_docs:!0}).then(function(o){return console.debug(o),e.AddLogSocket(o),o.rows.forEach(function(o){console.debug(o.doc.Fecha),console.debug(o.doc.Fecha.substring(0,10)+" 00:00"),console.debug(new Date(o.doc.Fecha.substring(0,10)+" 00:00")),console.debug(Date.now()-new Date(o.doc.Fecha.substring(0,10)+" 00:00").getTime()),console.debug((Date.now()-new Date(o.doc.Fecha.substring(0,10)+" 00:00").getTime())/864e5)}),o.rows.filter(function(o){return Math.floor((Date.now()-new Date(o.doc.Fecha.substring(0,10)+" 00:00").getTime())/864e5)>=t}).map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return e.database.bulkDocs(o)})},o.prototype.AddLogSocket=function(o){try{var t;t=[{nombre:"M3Proceso",valor:JSON.stringify(o)}],this.oM3DevicesService.Device_MPos(this.AddLogSocketOK,t,"LOGM3Procesos",null)}catch(e){console.log(e)}},o.prototype.Delete=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:c.M3DevicesService}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(c.M3DevicesService))},token:o,providedIn:"root"}),o}(),vo=function(){function o(o){this.oM3CouchMaestro=o}return o.prototype.GetFormasPago=function(o,t,e,r){var n=this;this.oM3CouchMaestro.get("FormasPago").then(function(o){console.log(o),e(n.FiltrarByProceso(t,o.FormasPago))},function(o){r(o),console.log(o)})},o.prototype.FiltrarByProceso=function(t,o){try{console.log(o),""!=t&&(o=o.filter(function(o){return console.log(o),!!o.PROCESOS&&(o.PROCESOS.length||(o.PROCESOS=new Array(o.PROCESOS)),null!=o.PROCESOS.find(function(o){return o.IdProceso==t}))}),console.log(o))}catch(e){return console.log("Error FiltrarByProceso"),console.log(e),o}return o},o.prototype.GetEstructura=function(o){return this.oM3CouchMaestro.get(o)},o.prototype.GetDinamicasByACtividad=function(o,e,r,t){var n;this.oM3CouchMaestro.get("DINBYACT").then(function(o){try{n=(n=o.M3DinByActividad).filter(function(o){return o.Actividad==e.Actividad&&o.IDActividad==e.idActividad&&o.IdProceso==e.idProceso}),r(n)}catch(t){n=new Array,r(n)}},function(o){t(o),console.log(o)})},o.prototype.GetUbicaciones=function(o,t,e,r){var n,i=o.trim().toUpperCase()+"?UBIC";this.oM3CouchMaestro.get(i).then(function(o){n=e.GetUbicacionFromList(o.ListUbicaciones.M3UBICACION,t),r(n)},function(o){console.log(o)})},o.prototype.Asyncget_template_reporte=function(o,e){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),"TEMPLATES",[4,this.oM3CouchMaestro.get("TEMPLATES")];case 1:return t=(t=o.sent()).RESPUESTA.RPTemplate.length==undefined?new Array(t.RESPUESTA.RPTemplate):t.RESPUESTA.RPTemplate,[2,{RESPUESTA:{RPTemplate:t.find(function(o){return o.IdRep==e})}}];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:p}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(p))},token:o,providedIn:"root"}),o}(),bo=s,Do=function(){function o(o,t,e){this.oServiceOffLine=o,this.oPostServiceM3=t,this.obdOffLineLog=e,this.AddLogSocketOK=function(){}}return o.prototype.GetProcesoById=function(t,e,r){var n=this;this.oServiceOffLine.get(t).then(function(o){e(o)},function(o){n.GetProcesoByIdFromLog(t,e,r)})},o.prototype.GetProcesoByIdFromLog=function(o,t,e){this.obdOffLineLog.get(o).then(function(o){t(o)},function(o){e(o)})},o.prototype.AddProceso=function(o,t,e){var r=this;t.IdM3?this.AddToDocOffline(t,e):this.GetIdM3Offline(o,t.TMIdProceso,t.Ubic1.toString(),t.IDHub.toString()).then(function(o){t.IdM3=o,r.AddToDocOffline(t,e)})},o.prototype.AddToDocOffline=function(e,r,n){var i=this;void 0===n&&(n=0),this.oServiceOffLine.AddDocument(e.IdM3.toString(),e).then(function(o){i.SaveIdM3(e.IdM3,e.TMIdProceso,e.Ubic1.toString(),e.IDHub.toString()),i.AddLogOffline(e,r)},function(o){console.log(o);var t=bo(new Date).format("YYYYMMDDTHHmmss");localStorage.setItem("errorLog"+t,JSON.stringify({error:o,olM3Procesos:e,Intento:n,"function":"AddToDocOffline"})),0==n?(i.obdOffLineLog.InstanceAgain(),i.AddToDocOffline(e,r,1)):r({Error:"Error en guardar en base de datos pcpal."})})},o.prototype.AddLogOffline=function(e,r,n){var i=this;void 0===n&&(n=0),this.obdOffLineLog.AddDocument(e.IdM3.toString(),e).then(function(o){console.log(o),r(e.IdM3)},function(o){console.log(o);var t=bo(new Date).format("YYYYMMDDTHHmmss");localStorage.setItem("errorLog"+t,JSON.stringify({error:o,olM3Procesos:e,Intento:n,"function":"AddLogOffline"})),0==n?(i.obdOffLineLog.InstanceAgain(),i.AddLogOffline(e,r,1)):r({Error:"Error en guardar en base de datos local."})})},o.prototype.closeInstanceLogOff=function(){this.obdOffLineLog.closeInstance()},o.prototype.GetOffLineLog=function(){return this.obdOffLineLog.GetAllDocs()},o.prototype.Get1DocOffLineLog=function(o){return this.obdOffLineLog.get(o)},o.prototype.ReversarEnLog=function(o){var r=this;this.Get1DocOffLineLog(o).then(function(o){for(var t=o,e=0;e<t.lM3PEncFP.length;e++)t.lM3PEncFP[e].ValCambio=0,t.lM3PEncFP[e].Valor=0,t.lM3PEncFP[e].ValOtraClasi=0;t.IdEstado="RV",r.AddLogOffline(t,null)})},o.prototype.DestruirBDLog=function(o){return this.obdOffLineLog.Destroy(o)},o.prototype.DestruirBDOff=function(o){return this.oServiceOffLine.Destroy(o)},o.prototype.SumarCtivo=function(o){return o=o.substring(0,9)+""+(+o.substring(9)+1)},o.prototype.updProceso=function(e,r,n,i){var a=this;void 0===i&&(i=0),this.oServiceOffLine.AddDocument(e.toString(),r).then(function(o){a.AddLogOffline(r,n)},function(o){var t=bo(new Date).format("YYYYMMDDTHHmmss");localStorage.setItem("errorLog"+t,JSON.stringify({error:o,olM3Procesos:r,Intento:i,"function":"updProceso"})),0==i?(a.obdOffLineLog.InstanceAgain(),a.updProceso(e,r,n,1)):n({Error:"Error en guardar en base de datos pcpal."})})},o.prototype.updProcesoAsync=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.oServiceOffLine.AddDocument(t.toString(),e)];case 1:return o.sent(),this.AddLogOffline(e,null),[2]}})})},o.prototype.GetAllDocsOffLineSinDocs=function(){return this.oServiceOffLine.GetAllDocsOffLineSinDocs()},o.prototype.procesarTicketOffline=function(o,t,e,r){var n=new Array,i=new to(null,null,o);this.ValidarTicketCerrado(t)&&(n.push(t),i.RegistroEventoM3OffLine(o,this.oPostServiceM3,n,e).then(function(o){r(!!o,"OK")})["catch"](function(o){r(!1,o)}))},o.prototype.ValidarProcesosAgregadosOffLine=function(r,n,i){var a=this,s=new Array,c=new to(null,null,r);this.oServiceOffLine.GetAllDocs().then(function(o){for(var t=0;t<o.rows.length;t++)if(o.rows[t].id&&!o.rows[t].id.startsWith("CTIVOS")){var e=o.rows[t].doc;a.ValidarTicketCerrado(e)&&s.push(o.rows[t].doc)}c.RegistroEventoM3OffLine(r,a.oPostServiceM3,s,n).then(function(o){o?(a.oServiceOffLine.DeleteAllDocs(),i(!0,"OK")):i(!1,"OK")})["catch"](function(o){i(!1,o)})})["catch"](function(o){console.log(o),i(!1,o)})},o.prototype.ValidarTicketCerrado=function(o){var t=!0;return null!=o.M3ENC&&null!=o.lM3PEncFP?o&&"Declinado"!=o.SubEstadoAnt&&0<o.M3ENC.length&&0==o.lM3PEncFP.length&&0<this.getCantidadTotalByM3Proceso(o)&&(t=!1):t=!1,t},o.prototype.getCantidadTotalByM3Proceso=function(o){if(o&&o.M3ENC){var t=o.M3ENC.filter(function(o){return 0<+o.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor}).reduce(function(o,t){return o+ +t.M3DET.find(function(o){return"CANTIDAD"==o.NombreConcepto}).Valor},0);return 0==t?0:t}return 0},o.prototype.GetAllDocsOffline=function(){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),t=new Array,[4,this.oServiceOffLine.GetAllDocs()];case 1:for(e=o.sent(),r=0;r<e.rows.length;r++)"CTIVOS"!=e.rows[r].id&&t.push(e.rows[r].doc);return[2,t];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.GetAllDocsOfflineDeleted=function(){return this.oServiceOffLine.GetAllDocsDeleted()},o.prototype.deleteCtivos=function(o,t){return this.oServiceOffLine.Delete(this.GetKey(o,t))},o.prototype.getAllCtivos=function(o,t){return this.oServiceOffLine.get(this.GetKey(o,t))},o.prototype.ValidacionCtivosVSServer=function(t,e,r,n){var i=this;this.getAllCtivos(e,r).then(function(o){o&&(new $).ValidarCtivosVSLocal(i.oPostServiceM3,t,JSON.stringify(o),e,r,n)})},o.prototype.GetCtivoOffLine=function(n,i,a){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:t="0",o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.oServiceOffLine.get(this.GetKey(n,i))];case 2:return(e=o.sent())&&(r=e.Ctivos.find(function(o){return o.IdProceso==a})).Ctivo&&(t=r.Ctivo.substring(9)),[3,4];case 3:return o.sent(),[3,4];case 4:return[2,t]}})})},o.prototype.SaveIdM3=function(r,n,i,a){var s=this;this.oServiceOffLine.get(this.GetKey(i,a)).then(function(o){var t=o.Ctivos,e=t.find(function(o){return o.IdProceso==n});e?+e.Ctivo.substring(9)<+r.substring(9)&&(e.Ctivo=r):t.push({IdProceso:n,Ctivo:r});s.SaveCtivos(t,i,a),"TICKETVENTA"==n.toUpperCase()&&localStorage.setItem("CtivoTicketVenta",r)},function(o){var t=new Array;t.push({IdProceso:n,Ctivo:r}),s.SaveCtivos(t,i,a),"TICKETVENTA"==n.toUpperCase()&&localStorage.setItem("CtivoTicketVenta",r)})},o.prototype.SaveCtivos=function(e,r,n,i){var a=this;void 0===i&&(i=0);var s={Ctivos:e};this.oServiceOffLine.AddDocument(this.GetKey(r,n),s).then(function(o){console.log("OK")},function(o){var t=bo(new Date).format("YYYYMMDDTHHmmss");localStorage.setItem("errorLogCtivos"+t,JSON.stringify({error:o,Ctivos:s,"function":"SaveCtivos"})),console.log(o),0==i&&a.SaveCtivos(e,r,n,1)})},o.prototype.DeleteOldDocs=function(o){this.obdOffLineLog.DeleteOldDocs(o)},o.prototype.GetIdM3Offline=function(n,i,a,s){return O(this,void 0,void 0,function(){var t,e,r;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oServiceOffLine.get(this.GetKey(a,s))];case 1:return t=o.sent(),r=t.Ctivos.find(function(o){return o.IdProceso==i}),e=r?(e=r.Ctivo,e=this.SumarCtivo(e),this.validarAumentoCtivo(e,i)):this.GetCtivo(n,i,a,s),[3,3];case 2:return o.sent(),e=this.GetCtivo(n,i,a,s),[3,3];case 3:return[2,e]}})})},o.prototype.validarAumentoCtivo=function(o,t){if("TICKETVENTA"==t.toUpperCase()&&localStorage.getItem("CtivoTicketVenta")==o){var e=bo(new Date).format("YYYYMMDDTHHmmss");o=this.SumarCtivo(o),localStorage.setItem("errorLogCtivos"+e,JSON.stringify({idM3:o,"function":"validarAumentoCtivo"}))}return o},o.prototype.GetCtivo=function(t,e,r,n){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,(new $).GetCtivoBYProceso(this.oPostServiceM3,t,e,r,n)];case 1:return[2,o.sent()]}})})},o.prototype.GetKey=function(o,t){return"CTIVOS_"+o+t},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:Oo},{type:f},{type:So}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(Oo),r.inject(f),r.inject(So))},token:o,providedIn:"root"}),o}(),Eo=function(){function o(o){this.oPostServiceM3=o}return o.prototype.M3GetM3NotificacionesXHubObject=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oPostServiceM3.getWithBodyM3("M3NotifController/M3GetM3NotificacionesXHubObject/"+t,e).toPromise()];case 1:return[2,o.sent()];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.M3GetM3NotificacionesXHubObjectWithTimeOut=function(t,e,r){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oPostServiceM3.getWithBodyM3TimeOut("M3NotifController/M3GetM3NotificacionesXHubObject/"+t,e,r).toPromise()];case 1:return[2,o.sent()];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.m3_get_notificacion_x_hub_object=function(e,r){return O(this,void 0,void 0,function(){var t;return S(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.oPostServiceM3.getWithBodyM3("M3NotifController/m3_get_notificacion_x_hub_object/"+e,r).toPromise()];case 1:return t=o.sent(),[2,r=JSON.parse(JSON.stringify(t))];case 2:return o.sent(),[2,null];case 3:return[2]}})})},o.prototype.guardarCambiosConfiguracionImpresion=function(o,t,e,r,n){o.postServiceHttpResFullM3("M3NotifController/guardarCambiosConfiguracionImpresion/"+t.trim(),e).subscribe(function(o){r()},function(o){n(o._body)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:f}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(f))},token:o,providedIn:"root"}),o}(),Ao=function Ot(){},To=function St(){},No=function(){function o(o){this.PostServiceM3=o}return o.prototype.M3_GETINVENTARIOBYPACK=function(t,e){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.PostServiceM3.getWithBodyM3("M3Consultas/M3_GETINVENTARIOBYPACK/"+t,e).toPromise()];case 1:return[2,o.sent()]}})})},o.prototype.validarInventarioNegativoProducto=function(o,t,e,r,n){o.getWithBodyM3("M3/validarInventarioNegativoProducto/"+t,e).subscribe(function(o){r()},function(o){n(JSON.parse(o.error.Message))})},o.prototype.BuscarConceptoEnM3SIU=function(o,t,e,r,n){o.getWithBodyM3("M3Consultas/M3_GETConceptoFromSIU/"+t+"/"+e.sUbicacion+"/"+e.sConcepto,{}).subscribe(function(o){r(o)},function(o){n(JSON.parse(o.error.Message))})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[{type:f}]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o(r.inject(f))},token:o,providedIn:"root"}),o}(),Lo=function vt(){},Ro=function(){function o(){this.listener=new r.EventEmitter,this.aplSyncCouchAuto=!0,this.aplPaquetes=!1,this.idkatios=this.GetIdKatiosLVL1FromSession(),this.GetKatiosM3FromSession(),this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.getFlagSyncCouch=function(){var o,t,e=sessionStorage.getItem("SUbicacion"),r=!0;return e&&(o=JSON.parse(e)).M3HUBS&&o.M3HUBS[0]&&o.M3HUBS[0].Configuracion&&null!=(t=JSON.parse(o.M3HUBS[0].Configuracion)).SyncCouchAuto&&t.SyncCouchAuto!=undefined&&(r=t.SyncCouchAuto),r},o.prototype.CrearPouchSincronizacion=function(){this.idkatios=this.GetIdKatiosLVL1FromSession(),this.idkatios&&this.GetKatiosM3FromSession(),this.database=new a("PRD"+this.idkatios,{auto_compaction:!0}),console.debug("adapter"),console.debug(this.database.adapter),this.validarPaquetes(),this.isInstantiated=!0,console.log("********************************** INSTANCE PRODUCTOS *****************************************")},o.prototype.validarPaquetes=function(){if(this.aplPaquetes){var o=this.getUbicacion();o?this.sync(this.GetServer()+"prdsa"+o+"_"+this.idkatios.toLowerCase()):this.sync(this.GetServer()+"prds_"+this.idkatios.toLowerCase())}else this.sync(this.GetServer()+"prds_"+this.idkatios.toLowerCase())},o.prototype.syncCouch=function(){this.idkatios?this.validarPaquetes():this.CrearPouchSincronizacion()},o.prototype.getUbicacion=function(){var o,t=sessionStorage.getItem("SUbicacion");return t&&(o=JSON.parse(t)).IDUbicacion?o.IDUbicacion:null},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.GetKatiosM3FromSession=function(){var o=localStorage.getItem("ConfigKatios"+this.idkatios.toUpperCase());if(o!==undefined&&null!=o){var t=JSON.parse(o);if(t&&t.Katios&&t.Katios.KatiosM3){var e=t.Katios.KatiosM3.find(function(o){return"APLPAQS"==o.Llave.toUpperCase()});e&&"1"==e.Valor&&(this.aplPaquetes=!0)}}},o.prototype.Destroy=function(o){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.prototype.sync=function(o){var t=this;this.aplSyncCouchAuto=this.getFlagSyncCouch();var e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:this.aplSyncCouchAuto,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO PRODUCTOS *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PRODUCTOS *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getInfo=function(){return this.database.info()},o.prototype.getChangeListener=function(){return this.listener},o.prototype.deletePrd=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.prototype.DeleteAllDocs=function(){var t=this;this.database.allDocs({include_docs:!0}).then(function(o){return o.rows.map(function(o){return{_id:o.id,_rev:o.doc._rev,_deleted:!0}})}).then(function(o){return t.database.bulkDocs(o)})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Uo=function(){function o(){this.listener=new r.EventEmitter,this.aplSyncCouchAuto=!0,this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.getFlagSyncCouch=function(){var o,t,e=sessionStorage.getItem("SUbicacion"),r=!0;return e&&(o=JSON.parse(e)).M3HUBS&&o.M3HUBS[0]&&o.M3HUBS[0].Configuracion&&null!=(t=JSON.parse(o.M3HUBS[0].Configuracion)).SyncCouchAuto&&t.SyncCouchAuto!=undefined&&(r=t.SyncCouchAuto),r},o.prototype.CrearPouchSincronizacion=function(){this.idkatios=this.GetIdKatiosLVL1FromSession(),this.database=new a("codsprd_"+this.idkatios,{auto_compaction:!0}),console.debug("adapter"),console.debug(this.database.adapter),this.sync(this.GetServer()+"codsprd_"+this.idkatios.toLowerCase()),this.isInstantiated=!0,console.log("********************************** INSTANCE PRODUCTOS *****************************************")},o.prototype.syncCouch=function(){this.idkatios?this.sync(this.GetServer()+"codsprd_"+this.idkatios.toLowerCase()):this.CrearPouchSincronizacion()},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this;this.aplSyncCouchAuto=this.getFlagSyncCouch();var e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:this.aplSyncCouchAuto,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO CODS PRODUCTOS *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO CODS PRODUCTOS *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.Destroy=function(){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Vo=function(){function o(){var o;(this.listener=new r.EventEmitter,this.elementRem=new r.EventEmitter,this.isInstantiated)||(o=this.GetIdKatiosLVL1FromSession(),this.database=new a("promociones_"+o,{auto_compaction:!0}),this.isInstantiated=!0,console.log("********************************** INSTANCE PROMOCIONES *****************************************"))}return o.prototype.GetServer=function(o){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3+"promociones_"+o.toLowerCase()},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!0,retry:!0}).on("complete",function(o){console.log(o),console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************")}).on("change",function(o){console.log(o),t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PROMOCIONES *****************************************")}).on("error",function(o){console.log("Error"),console.log(o)})},o.prototype.syncWithDB=function(o){var t=this;this.database.replicate.from(o,{live:!0,retry:!0}).on("complete",function(o){console.log(o),console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************")}).on("change",function(o){console.log(o),t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PROMOCIONES *****************************************")}).on("error",function(o){console.log("Error"),console.log(o)})},o.prototype.syncAwait=function(r){return O(this,void 0,void 0,function(){var t,e=this;return S(this,function(o){switch(o.label){case 0:return t=new a(r,{auto_compaction:!0}),[4,this.database.replicate.from(t,{}).on("complete",function(o){console.log(o),console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************"),e.syncWithDB(t)}).on("error",function(o){console.log("Error"),console.log(o)})];case 1:return o.sent(),[4,this.database.compact()];case 2:return o.sent(),[2]}})})},o.prototype.get=function(o){return this.database.get(o)},o.prototype["delete"]=function(o){var t=this;this.database.get(o).then(function(o){return t.database.remove(o)})},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.elementRemoved=function(){var t=this;this.database.changes({live:!0,since:"now",include_docs:!0}).on("change",function(o){o.deleted&&(console.log(o),t.elementRem.emit(o))}).on("error",console.log.bind(console))},o.prototype.getRemoveListener=function(){return this.elementRem},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),_o=function(){function o(){var o;(this.listener=new r.EventEmitter,this.change=new r.EventEmitter,this.isInstantiated)||(o=this.GetIdKatiosLVL1FromSession(),this.database=new a("ubicaciones_"+o,{auto_compaction:!0}),this.sync(this.GetServer()+"ubicaciones_"+o.toLowerCase()),this.isInstantiated=!0,console.log("********************************** INSTANCE UBICACIONES *****************************************"))}return o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!0,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO UBICACIONES *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO UBICACIONES *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.ChangeItem=function(){var t=this;this.database.changes({live:!0,since:"now",include_docs:!0}).on("change",function(o){console.log(o),t.change.emit(o)}).on("error",console.log.bind(console))},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.getChange=function(){return this.change},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Bo=function(){function o(){var o;(this.listener=new r.EventEmitter,this.isInstantiated)||(o=this.GetIdKatiosLVL1FromSession(),this.database=new a("notificaciones_"+o.toLowerCase().trim(),{auto_compaction:!0}),this.sync(this.GetServer()+"notificaciones_"+o.toLowerCase().trim()),this.isInstantiated=!0)}return o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.get=function(o){return this.database.get(o)},o.prototype.GetDataPouchBD=function(o){return this.database.get(o)},o.prototype.getChangeListener=function(){return this.listener},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!0,retry:!0}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO PROMOCIONES *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO PROMOCIONES *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.GetKeyDocumentoDB=function(o,t){return o+"?"+t},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Go=function(){function o(){this.operators={"<":function(o,t){return+o<+t},">":function(o,t){return+t<+o},"<=":function(o,t){return+o<=+t},">=":function(o,t){return+t<=+o},IGUAL:function(o,t){return o==t},DIFF:function(o,t){return o!=t},EN:function(o,t){return o===t},AND:function(o,t){return o&&t},OR:function(o,t){return o||t},"*":function(o,t){return!0},MOD:function(o,t){return+o%+t==0}}}return o.prototype.ValidarSiEsTipo=function(o,t){try{return!!o.M3PACKBYTIPO.find(function(o){return o.DESTINO==t.TIPO})}catch(e){return!1}},o.prototype.GeneraValidaciones=function(o,t,e){try{var r=!0,n=o.M3PACKBYTIPO.find(function(o){return o.DESTINO==t.TIPO});if(n)for(var i=0;n.M3PACKREGLAS.length;i++){var a=n.M3PACKREGLAS[i];this.operators[a.Operacion](this.GetParametros(a.Param1,o),this.GetParametros(a.Param2,o))?this.ValidacionAccion(a.Accion,e):r=!1}}catch(s){}return r},o.prototype.ValidacionAccion=function(o,t){try{if(""!=o){var e=JSON.parse(o);if(e.Accion)switch(e.Accion){case"Cantidad":t.dCantidad=e.Valor}}}catch(r){}},o.prototype.GetParametros=function(t,o){var e="";try{var r=t.split("_")[0];switch(r.toUpperCase()){case"ADI":e=o.LoM3PrdAdicionales.find(function(o){return o.ATRIBUTO==t.split("_")[1]}).VALOR;break;case"CONST":e=t.split("_")[1];break;default:r.toUpperCase().startsWith("SKP")&&(e=o.LoM3PrdGeneral[0][r])}}catch(n){}return e},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),wo=s,Fo=function(){function o(){}return o.prototype.FiltrarByFechasOff=function(o,t){try{var e,r=sessionStorage.getItem("FechaItCOFF"),n=sessionStorage.getItem("FechaFtCOFF");if(e=o.rows,n&&r){var i=this.GetFechaNumber(r),a=this.GetFechaNumber(n);console.log(i),console.log(a);for(var s=0;s<e.length;s++){var c=e[s].doc;if(c){var u=this.GetFechaNumber(c.Fecha);console.log(u),+i<=+u&&+u<=+a&&t(c)}}}}catch(l){console.log("FiltrarByFechasOff"),console.log(l)}},o.prototype.FiltrarByTexto=function(o,t,e){try{var r;r=o.rows;for(var n=0;n<r.length;n++){var i=r[n].doc;i&&(i.IdM3.includes(t)||i.ndocUActivo&&i.ndocUActivo.includes(t))&&e(i)}}catch(a){console.log("FiltrarByFechasOff"),console.log(a)}},o.prototype.GetFechaNumber=function(o){return wo(o).format("YYYYMMDD")},o}(),Ko=function(){function o(){this.listener=new r.EventEmitter,this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.CrearPouchSincronizacion=function(){var o;o=this.GetIdKatiosLVL1FromSession(),this.database=new a("perxtipo_"+o,{auto_compaction:!0}),this.sync(this.GetServer()+"perxtipo_"+o.toLowerCase()),this.isInstantiated=!0,console.log("********************************** INSTANCE perxtipo *****************************************")},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!1,retry:!1}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO perxtipo *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO perxtipo *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.Destroy=function(){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}(),Jo=function(){function o(){this.listener=new r.EventEmitter,this.isInstantiated||this.CrearPouchSincronizacion()}return o.prototype.CrearPouchSincronizacion=function(){var o;o=this.GetIdKatiosLVL1FromSession(),this.database=new a("dinamxproc_"+o,{auto_compaction:!0}),this.sync(this.GetServer()+"dinamxproc_"+o.toLowerCase()),this.isInstantiated=!0,console.log("********************************** INSTANCE dinamxproc_ *****************************************")},o.prototype.GetServer=function(){return JSON.parse(sessionStorage.getItem("ConfigJSON")).CouchDBM3},o.prototype.GetIdKatiosLVL1FromSession=function(){var o,t=sessionStorage.getItem("SessionLVL1M3");return t!==undefined&&null!=t&&(o=JSON.parse(t)).UsuarioSistema.IDKATIOS!==undefined&&null!=o.UsuarioSistema.IDKATIOS?o.UsuarioSistema.IDKATIOS:null},o.prototype.sync=function(o){var t=this,e=new a(o,{auto_compaction:!0});this.database.replicate.from(e,{live:!1,retry:!1}).on("complete",function(o){console.log("********************************** COMPLETO CAMBIO dinamxproc_ *****************************************")}).on("change",function(o){t.listener.emit(o),console.log("********************************** CHANGE CAMBIO dinamxproc_ *****************************************")}).on("error",function(o){console.log("Error")})},o.prototype.get=function(o){return this.database.get(o)},o.prototype.fetch=function(){return this.database.allDocs({include_docs:!0})},o.prototype.getEncabezado=function(){return this.database.allDocs({include_docs:!1})},o.prototype.getChangeListener=function(){return this.listener},o.prototype.Destroy=function(){return O(this,void 0,void 0,function(){return S(this,function(o){switch(o.label){case 0:return[4,this.database.destroy()];case 1:return[2,o.sent()]}})})},o.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],o.ctorParameters=function(){return[]},o.ngInjectableDef=r.defineInjectable({factory:function(){return new o},token:o,providedIn:"root"}),o}();o.PostServiceM3=f,o.xmlToJsonTF=m,o.M3CouchMaestro=p,o.M3Data=P,o.Filtros=M,o.M3PrdAdicionales=g,o.M3PrdGeneral=y,o.M3PRDImpuestos=b,o.TypeM3PrdGrp=D,o.TypeImpuestosPRD=E,o.M3PrdLista=I,o.M3PImpuestos=A,o.M3PDetalleItems=T,o.M3PItemsWEB=N,o.M3PDetalleCupon=L,o.M3PDinamicas=R,o.M3PEncFP=U,o.M3PEncItems=V,o.M3PEnvios=_,o.M3Procesos=w,o.M3PRecepcion=F,o.M3PerXProceso=K,o.M3OtClasificaciones=J,o.ServiceM3FE=j,o.M3ProcesoService=H,o.M3RegService=to,o.M3Trx=eo,o.ServiceM3Maestro=$,o.ServiceListaPrecio=ro,o.ServiceLoadListaPrecio=Q,o.M3DinProcesos=no,o.M3PrdPackDet=io,o.M3UbiAdicionales=ao,o.M3Ubicacion=so,o.promocionesService=X,o.M3CONDIAGRUPACION=co,o.M3CONDIPROMO=uo,o.M3DETCONDIPROMO=lo,o.M3ENCPROMO=fo,o.PromocionProcesada=k,o.PromocionesAsociadas=x,o.PromocionCombinada=W,o.M3UbicacionService=po,o.M3RegMasivo=ho,o.M3RegMasivoAKZService=Po,o.M3ReversoServ=Mo,o.M3PDinamByActividad=mo,o.M3DinByActividad=Co,o.M3SaldosXCuenta=go,o.M3RegistroTrx=Io,o.cuponesService=yo,o.ServiceOffLine=Oo,o.bdOffLineLog=So,o.M3MaestroOffline=vo,o.M3ProcesosOffline=Do,o.M3NotifService=Eo,o.ModelM3Notif=Ao,o.M3Presentaciones=To,o.M3Consultas=No,o.TECLASRAPIDAS=Lo,o.CouchPRDSService=Ro,o.CouchConfigLPService=z,o.CouchCodsPRDSService=Uo,o.CouchPromocionesService=Vo,o.CouchUbicacionesService=_o,o.M3NotificacionesAPP=Bo,o.MathTF=q,o.ServiceM3PackByipo=Go,o.FiltrosDiarioOffLine=Fo,o.CouchPerxipo=Ko,o.CouchDinamByProcesos=Jo,Object.defineProperty(o,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=sf-reglanegociom3.umd.min.js.map