@onylab/common-api 0.1.130 → 0.1.134
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.
- package/dist/common-api.d.ts +13 -2
- package/dist/common-api.node.min.js +1 -1
- package/dist/common-api.node.min.js.map +1 -1
- package/dist/data/email/element/html/button.template +4 -4
- package/dist/data/email/element/html/h2.template +3 -3
- package/dist/data/email/element/html/index.template +70 -53
- package/dist/data/email/element/html/p.template +3 -3
- package/dist/data/email/full.html +3 -1
- package/package.json +2 -1
package/dist/common-api.d.ts
CHANGED
|
@@ -234,9 +234,20 @@ declare module "templating/view/email/ViewEmailElementBaseContract" {
|
|
|
234
234
|
shop: {
|
|
235
235
|
name: string;
|
|
236
236
|
url: string;
|
|
237
|
+
logo: string;
|
|
237
238
|
social: {
|
|
238
|
-
facebook:
|
|
239
|
-
|
|
239
|
+
facebook: {
|
|
240
|
+
url: string;
|
|
241
|
+
logo: string;
|
|
242
|
+
};
|
|
243
|
+
instagram: {
|
|
244
|
+
url: string;
|
|
245
|
+
logo: string;
|
|
246
|
+
};
|
|
247
|
+
twitter: {
|
|
248
|
+
url: string;
|
|
249
|
+
logo: string;
|
|
250
|
+
};
|
|
240
251
|
};
|
|
241
252
|
};
|
|
242
253
|
copyright?: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SmilePlayerCommon=e():t.SmilePlayerCommon=e()}(global,(function(){return(()=>{"use strict";var t={525:t=>{t.exports=require("emoji-regex/RGI_Emoji.js")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{Constant:()=>t,Exception:()=>e,Http:()=>o,Service:()=>i,Template:()=>a,Tool:()=>u,Util:()=>c});var t={};n.r(t),n.d(t,{Path:()=>l});var e={};n.r(e),n.d(e,{BadParameterException:()=>d,BadRequestException:()=>v,ConflictException:()=>m,ExternalApiException:()=>E,InternalException:()=>S,MainException:()=>p,ObjectNotFoundException:()=>_,PageNotFoundException:()=>T,UnauthorizedException:()=>N});var o={};n.r(o),n.d(o,{HandlerController:()=>F,Server:()=>q});var i={};n.r(i),n.d(i,{EmailSenderService:()=>ft,SmsSenderService:()=>X});var a={};n.r(a),n.d(a,{TemplateEngine:()=>ut});var u={};n.r(u),n.d(u,{Configuration:()=>dt,Database:()=>mt,Displayer:()=>Et,Env:()=>I,Environment:()=>L,FileSystem:()=>rt,Logger:()=>U,Retry:()=>V});var c={};n.r(c),n.d(c,{AddressUtil:()=>Ot,DateUtil:()=>Tt,ExtractorUtil:()=>Pt,FormatterUtil:()=>Nt,GeneratorUtil:()=>Ct,MathUtil:()=>At,ObjectUtil:()=>jt,PriceUtil:()=>Mt,StringUtil:()=>_t,ValidatorUtil:()=>St,asyncForEach:()=>ot,isNullOrUndefined:()=>wt});var s,l=function(){function t(){}return t.registerBasePath=function(e){void 0!==process.env.APP_HOME?t.BASE_PATH=process.env.APP_HOME+"/":t.BASE_PATH=e+(e.endsWith("/")?"":"/")},t.data=function(){return t.BASE_PATH+"data/"},t.db=function(){return t.storage()+"db/"},t.root=function(){return t.BASE_PATH},t.session=function(){return t.storage()+"session/"},t.storage=function(){return t.BASE_PATH+"storage/"},t.BASE_PATH="./",t}(),f=(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),p=function(t){function e(n,r,o){var i=t.call(this,n)||this;return i.code=r,i.data=o,i.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,e):i.stack=new Error(n).stack,i}return f(e,t),e}(Error),h=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),d=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadParameterException",r}return h(e,t),e}(p),y=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadRequestException",r}return y(e,t),e}(p),b=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),m=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="ConflictException",r}return b(e,t),e}(p),g=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),E=function(t){function e(e,n){var r=t.call(this,e,502,n)||this;return r.name="ExternalApiException",r}return g(e,t),e}(p),w=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e,n){var r=t.call(this,e,500,n)||this;return r.name="InternalException",r}return w(e,t),e}(p),x=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="ObjectNotFoundException",r}return x(e,t),e}(p),O=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),T=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="PageNotFoundException",r}return O(e,t),e}(p),P=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),N=function(t){function e(n,r){var o=t.call(this,n,e.ERROR_CODE,r)||this;return o.name="UnauthorizedException",o}return P(e,t),e.ERROR_CODE=401,e}(p);const C=require("crypto"),A=require("express"),j=require("cors"),M=require("helmet"),D=require("connect-timeout"),R=require("@sentry/node"),k=require("@sentry/integrations");var I;!function(t){t.PRODUCTION="prod",t.DEVELOPMENT="dev",t.TEST="test"}(I||(I={}));var L=function(){function t(){}return t.getMode=function(){switch(process.env.NODE_ENV){case"dev":case"development":return I.DEVELOPMENT;case"prod":case"production":return I.PRODUCTION;case"test":return I.TEST}return void 0===process.env.APP_ID?I.DEVELOPMENT:I.PRODUCTION},t}(),U=function(){function t(){}return t.init=function(t){L.getMode()===I.PRODUCTION&&R.init({dsn:t,integrations:[new k.CaptureConsole({levels:["error","warn","log"]})],environment:L.getMode(),maxBreadcrumbs:50})},t.trace=function(t,e){[I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.info(t):console.info(t,e)),R.addBreadcrumb({category:"info",message:t,data:e,level:R.Severity.Info})},t.debug=function(t,e){[I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.log(t):console.log(t,e)),R.addBreadcrumb({category:"debug",message:t,data:e,level:R.Severity.Debug})},t.info=function(t,e){[I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.info(t):console.info(t,e)),R.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),R.captureMessage(t)}))},t.warning=function(t,e){[I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.warn(t):console.warn(t,e)),R.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),R.captureException(t)}))},t.error=function(t,e){[N.ERROR_CODE].includes(t.code)||([I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.error(t):console.error(t,e)),R.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),R.captureException(t)})))},t.requestHandler=function(){return R.Handlers.requestHandler()},t.errorHandler=function(){return R.Handlers.errorHandler()},t}(),q=function(){function t(){}return t.prototype.create=function(e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(i){return void 0===this.app&&(r=n||t.DEFAULT_PORT,o="http://localhost:"+String(r),U.debug("start server on "+o),this.app=A(),this.app.use(D("60s")),this.app.use(A.json({inflate:!0,limit:"100kb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(j({origin:[o].concat(e),credentials:!0})),this.app.use(M()),this.app.use(A.json()),this.app.listen(r,(function(){U.debug("server is running on "+o)}))),[2,this.app]}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{c(a.next(t))}catch(t){e(t)}}function u(t){try{c(a.throw(t))}catch(t){e(t)}}function c(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}c((a=a.apply(r,o||[])).next())}));var r,o,i,a},t.prototype.getSessionSecret=function(e){return C.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}(),F=function(){function t(){}return t.error=function(t,e,n){U.error(n);var r=void 0!==n.code&&null!==n.code?Number(n.code):500;e.status(!isNaN(r)&&Number(n.code)>=400&&Number(n.code)<=599?Number(n.code):500),e.json({code:n.code,message:n.message})},t}();const H=require("axios");var G=n.n(H);const B=require("luxon"),z=require("querystring"),J=require("retry");var V=function(){function t(){}return t.request=function(t,e){return void 0===e&&(e=2),n=this,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(r){return n=J.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,r){n.attempt((function(){t().then(e).catch((function(t){n.retry(t)||(U.error(t),r(t))}))}))}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function u(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,u)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},t}();const Z=require("urlencode");var W=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},$=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},X=function(){function t(t,e){this.token=t,this.mode=e}return t.prototype.send=function(e,n,r,o,i){return void 0===o&&(o=!0),W(this,void 0,void 0,(function(){var a,u=this;return $(this,(function(c){switch(c.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(U.warning(new d("no valid phone",{phones:r})),[2,Promise.resolve()]):(a.length>1&&(n.length>2*t.MESSAGE_MAX_LENGTH?n=n.substring(0,2*t.MESSAGE_MAX_LENGTH):n.length>t.MESSAGE_MAX_LENGTH&&n.length<=1.33*t.MESSAGE_MAX_LENGTH&&(n=n.substring(0,t.MESSAGE_MAX_LENGTH))),[4,V.request((function(){return W(u,void 0,void 0,(function(){var r,u;return $(this,(function(c){switch(c.label){case 0:return r={accessToken:this.token,emetteur:e,message:Z(n,"ISO-8859-15"),numero:a.map((function(t){return t.replace("+","")})).join(","),classe_msg:2,nbr_msg:Math.ceil(n.length/t.MESSAGE_MAX_LENGTH)},o&&(r.stop=1),void 0!==i&&(r.date_envoi=B.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),this.mode!==I.TEST?[3,1]:(U.info("Simulation Mode: SMS has been sent",{params:r}),[3,3]);case 1:return this.mode===I.DEVELOPMENT&&(a=["+15145705214"]),[4,G().post(t.BASE_API_URL+"sendSMS.do",z.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((u=c.sent()).data.length>0&&"0"!==u.data.trim().substring(0,1))throw new E("Error: "+u.data,r);c.label=3;case 3:return[2]}}))}))}),1)]);case 1:return c.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){var e=new RegExp("^\\+1[0-9]{10}$","i"),n=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return t.filter((function(t){return e.test(t)||n.test(t)||r.test(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const Y=require("path"),K=require("mustache"),Q=require("lodash"),tt=require("fs");var et=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},nt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},rt=function(){function t(){}return t.prototype.read=function(t){return et(this,void 0,void 0,(function(){return nt(this,(function(e){if(!this.isFile(t))throw new d(t+" does not exist or is not a file");return[2,tt.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return et(this,void 0,void 0,(function(){var e;return nt(this,(function(n){switch(n.label){case 0:return[4,this.read(t)];case 1:if(e=n.sent(),!this.isJson(e))throw new d(t+" does not contain JSON");return[2,JSON.parse(e)]}}))}))},t.prototype.write=function(t,e){return et(this,void 0,void 0,(function(){var n;return nt(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),tt.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return et(this,void 0,void 0,(function(){return nt(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isFile=function(t){return tt.existsSync(t)&&tt.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}(),ot=function(t,e){return n=void 0,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(r){switch(r.label){case 0:n=0,r.label=1;case 1:return n<t.length?[4,e(t[n])]:[3,4];case 2:r.sent(),r.label=3;case 3:return n++,[3,1];case 4:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function u(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,u)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},it=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},at=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},ut=function(){function t(){}return t.prototype.render=function(t,e,n){return it(this,void 0,void 0,(function(){var r,o,i,a,u=this;return at(this,(function(c){switch(c.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,Q.cloneDeep)(e),o=Y.isAbsolute(t)?"":__dirname+Y.sep,[4,(new rt).read(o+t)];case 1:return i=c.sent(),a=[],(0,K.parse)(i).forEach((function(t){t.length>=4&&"&"===t[0]&&t[1].startsWith("include:")&&a.push(t[1])})),a.length>0?(void 0===n?n=Y.dirname(o+t)+Y.sep:Y.isAbsolute(n)||(n=o+n),[4,ot(a,(function(t){return it(u,void 0,void 0,(function(){var e,o,i,a;return at(this,(function(u){switch(u.label){case 0:return 3!==(e=t.split(":")).length?[3,2]:(o=e[2],i=r,a=t,[4,this.render(Y.resolve(n,o),r[t])]);case 1:i[a]=u.sent(),u.label=2;case 2:return[2]}}))}))}))]):[3,3];case 2:c.sent(),c.label=3;case 3:return[2,(0,K.render)(i,r)]}}))}))},t}();const ct=require("node-mailjet");var st=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},lt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},ft=function(){function t(t,e,n){this.templateEngine=new ut,this.mailjet=ct.connect(t,e),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return st(this,void 0,void 0,(function(){var r=this;return lt(this,(function(o){switch(o.label){case 0:return[4,V.request((function(){return st(r,void 0,void 0,(function(){var r,o;return lt(this,(function(i){switch(i.label){case 0:return void 0===n.base.copyright&&(n.base.copyright={year:String((new Date).getUTCFullYear())}),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/text")];case 1:return r=i.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/html")];case 2:return o=i.sent(),[4,this.sendNotification(t,e,n.base.subject,r,o)];case 3:return[2,i.sent()]}}))}))}),1)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return st(this,void 0,void 0,(function(){var r=this;return lt(this,(function(o){switch(o.label){case 0:return[4,V.request((function(){return st(r,void 0,void 0,(function(){var r,o,i,a;return lt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/text")];case 1:return r=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return o=u.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:n.base})];case 4:return a=u.sent(),[4,this.sendNotification(t,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),1)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return st(this,void 0,void 0,(function(){var r=this;return lt(this,(function(o){switch(o.label){case 0:return[4,V.request((function(){return st(r,void 0,void 0,(function(){var r,o,i,a;return lt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/UserNotification",n,"data/email/element/text")];case 1:return r=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return o=u.sent(),[4,this.templateEngine.render("data/email/template/UserNotification",n,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:n.base})];case 4:return a=u.sent(),[4,this.sendNotification(t,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),1)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendNotification=function(t,e,n,r,o){return st(this,void 0,void 0,(function(){var i;return lt(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),this.mode!==I.TEST?[3,1]:(U.info("Simulation Mode: Email has been sent",{sender:t,recipient:e}),[3,3]);case 1:return this.mode===I.DEVELOPMENT&&(e.contact="developer@onylab.com"),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:[{From:{Name:t.name,Email:t.contact},To:[{Name:e.name,Email:e.contact}],Subject:n,TextPart:r,HTMLPart:o}]})];case 2:a.sent(),a.label=3;case 3:return[3,5];case 4:throw i=a.sent(),new p(i.message,Number(i.statusCode));case 5:return[2]}}))}))},t}(),pt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},ht=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},dt=function(){function t(t,e){this.root=t,this.environment=e}return t.prototype.full=function(){return pt(this,void 0,void 0,(function(){return ht(this,(function(t){switch(t.label){case 0:return[4,this.init()];case 1:return t.sent(),[2,this.config]}}))}))},t.prototype.init=function(){return pt(this,void 0,void 0,(function(){var t,e,n;return ht(this,(function(r){switch(r.label){case 0:return void 0!==this.config?[3,7]:void 0!==this.root?[3,1]:(this.config={},[3,7]);case 1:if(t=new rt,![I.DEVELOPMENT,I.TEST].includes(this.environment))return[3,5];r.label=2;case 2:return r.trys.push([2,4,,5]),e=this,[4,t.readJson(this.root+"data/config_"+String(this.environment)+".json")];case 3:return e.config=r.sent(),[3,5];case 4:return r.sent(),[3,5];case 5:return void 0!==this.config?[3,7]:(n=this,[4,t.readJson(this.root+"data/config.json")]);case 6:n.config=r.sent(),r.label=7;case 7:return[2]}}))}))},t}();const yt=require("typeorm");var vt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},bt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},mt=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return vt(this,void 0,void 0,(function(){var n,r;return bt(this,(function(o){switch(o.label){case 0:return void 0!==this.db?[3,2]:[4,this.init()];case 1:o.sent(),o.label=2;case 2:return void 0===(n=this.db[t])?[3,4]:(n.entities=e,n.logging=["error"],n.logger=!0,n.bigNumberStrings=!1,void 0===n.timezone&&(n.timezone="Z"),void 0===n.charset&&(n.charset="UTF8_GENERAL_CI"),r=this,[4,(0,yt.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:U.error(new d("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return vt(this,void 0,void 0,(function(){return bt(this,(function(t){switch(t.label){case 0:return void 0===this.connection?[3,2]:[4,this.connection.synchronize()];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.close=function(){return vt(this,void 0,void 0,(function(){return bt(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return vt(this,void 0,void 0,(function(){var t,e;return bt(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new rt,e=this,[4,t.readJson(this.root+"data/db.json")];case 2:e.db=n.sent(),n.label=3;case 3:return[2]}}))}))},t}();const gt=require("prettyjson");var Et=function(){function t(){}return t.prototype.error=function(t){U.error(t)},t.prototype.info=function(t){U.trace(t)},t.prototype.json=function(t){U.trace(gt.render(t,{}))},t.prototype.success=function(t){U.trace(t)},t}(),wt=function(t){return null==t},St=function(){function t(){}return t.isEmail=function(t){return"string"==typeof t&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(t)},t.isPhone=function(t){return"string"==typeof t&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(t)},t.isNumber=function(t){return"number"==typeof t||"string"==typeof t&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(t)},t}();const xt=require("fast-diff");var _t=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.truncate=function(t,e){return wt(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t.slugify=function(t,e){return void 0===t?"":(0,Q.toLower)((0,Q.trim)((0,Q.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t}(),Ot=function(){function t(){}return t.autoCorrectCity=function(e){if(wt(e))return e;var n=t.CITIES.find((function(t){return t.toLowerCase()===e.toLowerCase()}));if(void 0!==n)return n;var r=t.CITIES.find((function(n){var r=t.countDiff(e,n);return r.add<=2&&r.remove<=2}));if(void 0!==r)return r;var o=t.CITIES.find((function(t){return t.replace(/-/g," ").toLowerCase()===e.toLowerCase()}));if(void 0!==o)return o;var i=t.CITIES.find((function(n){var r=t.countDiff(e,n.replace(/-/g," "));return r.add<=2&&r.remove<=2}));if(void 0!==i)return i;var a=t.CITIES.find((function(t){return t.toLowerCase().startsWith(e.toLowerCase())}));if(void 0!==a)return a;var u=t.CITIES.find((function(t){return e.toLowerCase().includes(t.toLowerCase())}));return void 0!==u?u:e},t.isZipCode=function(e){return"string"==typeof e&&(!!t.ZIPCODES.includes(e)||St.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e){var n={};if(!wt(e)){var r=e.split(",");if(r.length>=3){var o=r.length-1;if(n.country=r[o].trim(),r.splice(o--,1),void 0!==r[o]&&r[o].trim().includes(" ")){var i=r[o].trim().split(" ");n.zip=void 0===i[0]?void 0:i[0].trim(),i.splice(0,1),n.city=i.join(" ").trim(),r.splice(o--,1)}else isNaN(Number(r[o].trim()))?isNaN(Number(r[o-1].trim()))?(n.city=r[o].trim(),r.splice(o--,1)):(n.city=r[o].trim(),r.splice(o--,1),n.zip=r[o].trim(),r.splice(o--,1)):(n.zip=r[o].trim(),r.splice(o--,1),o>=2&&(n.city=r[o].trim(),r.splice(o--,1)));n.street=r.map((function(t){return t.trim()})).join(" ").trim()}else{var a=e.toLowerCase();t.ZIPCODES.forEach((function(t){if(a.includes(t)){n.zip=t;try{a=a.replace(new RegExp(_t.escapeRegExp(t),"ig"),"")}catch(t){}}})),t.CITIES.forEach((function(t){if(a.includes(t.toLowerCase())){n.city=t;try{a=a.replace(new RegExp(_t.escapeRegExp(t),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(a.includes(t.toLowerCase())){n.country=t;try{a=a.replace(new RegExp(_t.escapeRegExp(t),"ig"),"")}catch(t){}}})),void 0===n.street&&(n.street=a.split(",").map((function(t){return t.trim()})).join(" ").trim())}void 0===n.country&&(n.country="France")}return n},t.countDiff=function(t,e){var n={add:0,remove:0};return xt(t.toLowerCase(),e.toLowerCase()).forEach((function(t){switch(t[0]){case-1:n.remove+=t[1].length;break;case 1:n.add+=t[1].length}})),n},t.ZIPCODES=["78500","78600","78800","95240","95530","78630","78670","78240","78580","78300","95150","95250","95480","95320","95550"],t.CITIES=["Sartrouville","Cormeilles-en-Parisis","Houilles","Maisons-Laffitte","La Frette-sur-Seine","Argenteuil","Montesson","Le Mesnil-le-Roi","Bezons","Orgeval","Poissy","Morainvilliers","Villennes-sur-Seine","Medan","Chambourcy","Aigremont","Les Alluets-le-Roi","Taverny","Beauchamp","Pierrelaye","Saint-Leu-la-Forêt","Bessancourt"],t.COUNTRIES=["France"],t}(),Tt=function(){function t(){}return t.displayWeekDay=function(e){var n="";return void 0!==t.WEEK_DAYS[e]&&(n=t.WEEK_DAYS[e]),n},t.generatePeriod=function(e,n,r,o,i){void 0===o&&(o=!0),void 0===i&&(i=t.PERIOD_MAX_DATES);for(var a=B.DateTime.fromISO(e,{setZone:!0}).toISODate(),u=B.DateTime.fromISO(n,{setZone:!0}).toISODate(),c=0,s={};a<=u&&c<i;)s[a]=(0,Q.cloneDeep)(r),o&&(s[a].date=a),a=B.DateTime.fromISO(a,{setZone:!0}).plus({days:1}).toISODate(),c++;return s},t.limitDate=function(t,e,n){if(void 0===n&&(n=0),void 0!==t&&void 0!==e){var r=B.DateTime.fromISO(t,{setZone:!0}).toISO(),o=B.DateTime.fromISO(e,{setZone:!0}).plus({seconds:n}).toISO();return r>o?o:r}},t.localeToISO=function(t){var e,n=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),r=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),o=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(n.test(t))e=(i=t.split("/"))[2]+"-"+i[1]+"-"+i[0];else if(r.test(t)){var i;e=(i=t.split("-"))[2]+"-"+i[1]+"-"+i[0]}else o.test(t)&&(e=t);return e},t.slotToTime=function(t){var e,n=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),r=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");return t=t.trim(),n.test(t)?e=t.trim()+":00":r.test(t)&&(e=t.split("-")[0].trim()+":00"),e},t.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=B.DateTime.fromISO(t,{setZone:!0});return B.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),Pt=function(){function t(){}return t.phone=function(t,e){if("string"==typeof t&&(t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e)){var n=new RegExp("(0[6-7][0-9]{8})","i").exec(t);if(null!==n&&n.length>0&&null!==n[0])return n[0]}},t}(),Nt=function(){function t(){}return t.trim=function(t){return"string"==typeof t?t.trim():t},t.capitalize=function(e){var n=t.lower(e);return"string"==typeof n?n.split(" ").map((function(t){return t.charAt(0).toUpperCase()+t.slice(1)})).join(" "):e},t.lower=function(t){return"string"==typeof t?t.toLocaleLowerCase():t},t.upper=function(t){return"string"==typeof t?t.toLocaleUpperCase():t},t.phone=function(e,n,r){if(void 0===r&&(r="nat"),"string"==typeof e)switch(e=t.preformatPhone(e,n),r){case"nat":return t.phoneNat(e,n);case"int":return t.phoneInt(e,n)}return e},t.stripEmoji=function(t){var e=t;if("string"==typeof e){for(var r=n(525)(),o=void 0;null!==(o=r.exec(e));)try{e=(e=(e=e.replace(new RegExp("\\s"+_t.escapeRegExp(o[0]),"g"),"")).replace(new RegExp(_t.escapeRegExp(o[0])+"\\s","g"),"")).replace(new RegExp(_t.escapeRegExp(o[0]),"g"),"")}catch(t){}for(;null!==(o=r.exec(e));)try{e=(e=(e=e.replace(new RegExp("\\s"+_t.escapeRegExp(o[0]),"g"),"")).replace(new RegExp(_t.escapeRegExp(o[0])+"\\s","g"),"")).replace(new RegExp(_t.escapeRegExp(o[0]),"g"),"")}catch(t){}}return e},t.stripExoticCharacters=function(t){return"string"==typeof t?t.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):t},t.preformatPhone=function(t,e){return t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e&&new RegExp("^[1-9]").test(t)&&9===t.length?"0"+t:t},t.phoneNat=function(t,e){if("fr"===e){if(t.startsWith("+330")?t=t.substr(3):t.startsWith("+33")?t="0"+t.substr(3):t.startsWith("0033")?t="0"+t.substr(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substr(2)),10===t.length){var n=0;t=t.split("").map((function(t){return t+(++n%2==0?" ":"")})).join("").trim()}return t}return t},t.phoneInt=function(t,e){return t.startsWith("+")?t:"fr"===e?(t.startsWith("0")&&(t=t.substr(1)),"+33"+t):t},t}(),Ct=function(){function t(){}return t.code=function(e){null==e&&(e=6);for(var n="";n.length<e;)n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];return n},t.int=function(t,e){return null==t&&(t=0),null==e&&(e=Number.POSITIVE_INFINITY),t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},t.password=function(e){null==e&&(e=8);for(var n="";n.length<e;)switch(t.int(1,3)){case 1:n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];break;case 2:n+=t.symbolLowerCases[t.int(0,t.symbolLowerCases.length-1)];break;default:n+=String(t.int(0,9))}return n},t.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],t.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"],t}(),At=function(){function t(){}return t.avg=function(e){if(0===e.length)return 0;var n=e.reduce((function(t,e){return t+e}),0);return t.round(n/e.length,2)},t.applyVariation=function(t,e){return t*(t>=0?1+e/100:1-e/100)},t.median=function(e){if(0===e.length)return 0;if(1===e.length)return e[0];var n=e.sort((function(t,e){return t-e}));return n.length%2==0?t.avg([n[n.length/2-1],n[n.length/2]]):n[Math.floor(n.length/2)]},t.percentage=function(t,e){return 0===e?0:t/e*100},t.round=function(t,e){return 0===e?Math.round(t):Number(t.toFixed(e))},t.variation=function(t,e){var n=0;return 0!==e?n=0!==t?(e-t)/Math.abs(t)*100:100*(e>0?1:-1):0!==t&&(n=-100*(t>0?1:-1)),Math.floor(n)},t}(),jt=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,Q.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,Q.isArray)(e)&&e.length>0||(0,Q.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,Q.isArray)(e)&&!(0,Q.isObject)(e))&&r.push(e)})),r}if((0,Q.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,Q.isArray)(i)||(0,Q.isObject)(i)?(i=t.compact(i,n),((0,Q.isArray)(i)&&i.length>0||(0,Q.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,Q.isArray)(i)&&!(0,Q.isObject)(i))&&(o[r]=i)):null!=i&&("string"!=typeof i||!1===n.removeEmptyString||i.length>0)&&(o[r]=i)})),o}return"string"!=typeof e||!1===n.removeEmptyString||e.length>0?e:void 0},t}(),Mt=function(){function t(){}return t.applyTaxes=function(t,e){var n=Number(t);return e.forEach((function(e){n+=Number(t)*e})),String(At.round(n,2))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),At.round(n,2)},t.displayWithCurrency=function(e,n){if(null==e)return e;var r=t.currencies[n],o=e+" "+n;if(void 0!==r)switch(r.position){case"before":o=r.symbol+e;break;case"after":o=e+r.symbol}return o},t.format=function(t,e,n){if(void 0===n&&(n=2),null==t)return t;var r=Number(t.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:n,maximumFractionDigits:n});switch(e){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}},t.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},t}()})(),r})()}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SmilePlayerCommon=e():t.SmilePlayerCommon=e()}(global,(function(){return(()=>{"use strict";var t={525:t=>{t.exports=require("emoji-regex/RGI_Emoji.js")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{Constant:()=>t,Exception:()=>e,Http:()=>o,Service:()=>i,Template:()=>a,Tool:()=>u,Util:()=>c});var t={};n.r(t),n.d(t,{Path:()=>l});var e={};n.r(e),n.d(e,{BadParameterException:()=>d,BadRequestException:()=>v,ConflictException:()=>m,ExternalApiException:()=>E,InternalException:()=>S,MainException:()=>p,ObjectNotFoundException:()=>_,PageNotFoundException:()=>T,UnauthorizedException:()=>C});var o={};n.r(o),n.d(o,{HandlerController:()=>F,Server:()=>q});var i={};n.r(i),n.d(i,{EmailSenderService:()=>ft,SmsSenderService:()=>X});var a={};n.r(a),n.d(a,{TemplateEngine:()=>ut});var u={};n.r(u),n.d(u,{Configuration:()=>dt,Database:()=>mt,Displayer:()=>Et,Env:()=>I,Environment:()=>L,FileSystem:()=>rt,Logger:()=>U,Retry:()=>J});var c={};n.r(c),n.d(c,{AddressUtil:()=>Ot,DateUtil:()=>Tt,ExtractorUtil:()=>Pt,FormatterUtil:()=>Ct,GeneratorUtil:()=>Nt,MathUtil:()=>At,ObjectUtil:()=>jt,PriceUtil:()=>Mt,StringUtil:()=>_t,ValidatorUtil:()=>St,asyncForEach:()=>ot,isNullOrUndefined:()=>wt});var s,l=function(){function t(){}return t.registerBasePath=function(e){void 0!==process.env.APP_HOME?t.BASE_PATH=process.env.APP_HOME+"/":t.BASE_PATH=e+(e.endsWith("/")?"":"/")},t.data=function(){return t.BASE_PATH+"data/"},t.db=function(){return t.storage()+"db/"},t.root=function(){return t.BASE_PATH},t.session=function(){return t.storage()+"session/"},t.storage=function(){return t.BASE_PATH+"storage/"},t.BASE_PATH="./",t}(),f=(s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},s(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),p=function(t){function e(n,r,o){var i=t.call(this,n)||this;return i.code=r,i.data=o,i.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,e):i.stack=new Error(n).stack,i}return f(e,t),e}(Error),h=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),d=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadParameterException",r}return h(e,t),e}(p),y=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),v=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadRequestException",r}return y(e,t),e}(p),b=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),m=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="ConflictException",r}return b(e,t),e}(p),g=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),E=function(t){function e(e,n){var r=t.call(this,e,502,n)||this;return r.name="ExternalApiException",r}return g(e,t),e}(p),w=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),S=function(t){function e(e,n){var r=t.call(this,e,500,n)||this;return r.name="InternalException",r}return w(e,t),e}(p),x=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),_=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="ObjectNotFoundException",r}return x(e,t),e}(p),O=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),T=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="PageNotFoundException",r}return O(e,t),e}(p),P=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),C=function(t){function e(n,r){var o=t.call(this,n,e.ERROR_CODE,r)||this;return o.name="UnauthorizedException",o}return P(e,t),e.ERROR_CODE=401,e}(p);const N=require("crypto"),A=require("express"),j=require("cors"),M=require("helmet"),D=require("connect-timeout"),R=require("@sentry/node"),k=require("@sentry/integrations");var I;!function(t){t.PRODUCTION="prod",t.DEVELOPMENT="dev",t.TEST="test"}(I||(I={}));var L=function(){function t(){}return t.getMode=function(){switch(process.env.NODE_ENV){case"dev":case"development":return I.DEVELOPMENT;case"prod":case"production":return I.PRODUCTION;case"test":return I.TEST}return void 0===process.env.APP_ID?I.DEVELOPMENT:I.PRODUCTION},t}(),U=function(){function t(){}return t.init=function(t){L.getMode()===I.PRODUCTION&&R.init({dsn:t,integrations:[new k.CaptureConsole({levels:["error","warn","log"]})],environment:L.getMode(),maxBreadcrumbs:50})},t.trace=function(t,e){[I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.info(t):console.info(t,e)),R.addBreadcrumb({category:"info",message:t,data:e,level:R.Severity.Info})},t.debug=function(t,e){[I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.log(t):console.log(t,e)),R.addBreadcrumb({category:"debug",message:t,data:e,level:R.Severity.Debug})},t.info=function(t,e){[I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.info(t):console.info(t,e)),R.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),R.captureMessage(t)}))},t.warning=function(t,e){[I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.warn(t):console.warn(t,e)),R.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),R.captureException(t)}))},t.error=function(t,e){[C.ERROR_CODE].includes(t.code)||([I.DEVELOPMENT,I.TEST].includes(L.getMode())&&(void 0===e?console.error(t):console.error(t,e)),R.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),R.captureException(t)})))},t.requestHandler=function(){return R.Handlers.requestHandler()},t.errorHandler=function(){return R.Handlers.errorHandler()},t}(),q=function(){function t(){}return t.prototype.create=function(e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(i){return void 0===this.app&&(r=n||t.DEFAULT_PORT,o="http://localhost:"+String(r),U.debug("start server on "+o),this.app=A(),this.app.use(D("60s")),this.app.use(A.json({inflate:!0,limit:"100kb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(j({origin:[o].concat(e),credentials:!0})),this.app.use(M()),this.app.use(A.json()),this.app.listen(r,(function(){U.debug("server is running on "+o)}))),[2,this.app]}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{c(a.next(t))}catch(t){e(t)}}function u(t){try{c(a.throw(t))}catch(t){e(t)}}function c(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}c((a=a.apply(r,o||[])).next())}));var r,o,i,a},t.prototype.getSessionSecret=function(e){return N.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}(),F=function(){function t(){}return t.error=function(t,e,n){U.error(n);var r=void 0!==n.code&&null!==n.code?Number(n.code):500;e.status(!isNaN(r)&&Number(n.code)>=400&&Number(n.code)<=599?Number(n.code):500),e.json({code:n.code,message:n.message})},t}();const H=require("axios");var G=n.n(H);const B=require("luxon"),z=require("querystring"),W=require("retry");var J=function(){function t(){}return t.request=function(t,e){return void 0===e&&(e=2),n=this,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(r){return n=W.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,r){n.attempt((function(){t().then(e).catch((function(t){n.retry(t)||(U.error(t),r(t))}))}))}))]}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function u(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,u)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},t}();const V=require("urlencode");var Z=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},$=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},X=function(){function t(t,e){this.token=t,this.mode=e}return t.prototype.send=function(e,n,r,o,i){return void 0===o&&(o=!0),Z(this,void 0,void 0,(function(){var a,u=this;return $(this,(function(c){switch(c.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(U.warning(new d("no valid phone",{phones:r})),[2,Promise.resolve()]):(a.length>1&&(n.length>2*t.MESSAGE_MAX_LENGTH?n=n.substring(0,2*t.MESSAGE_MAX_LENGTH):n.length>t.MESSAGE_MAX_LENGTH&&n.length<=1.33*t.MESSAGE_MAX_LENGTH&&(n=n.substring(0,t.MESSAGE_MAX_LENGTH))),[4,J.request((function(){return Z(u,void 0,void 0,(function(){var r,u;return $(this,(function(c){switch(c.label){case 0:return r={accessToken:this.token,emetteur:e,message:V(n,"ISO-8859-15"),numero:a.map((function(t){return t.replace("+","")})).join(","),classe_msg:2,nbr_msg:Math.ceil(n.length/t.MESSAGE_MAX_LENGTH)},o&&(r.stop=1),void 0!==i&&(r.date_envoi=B.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),this.mode!==I.TEST?[3,1]:(U.info("Simulation Mode: SMS has been sent",{params:r}),[3,3]);case 1:return this.mode===I.DEVELOPMENT&&(a=["+15145705214"]),[4,G().post(t.BASE_API_URL+"sendSMS.do",z.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((u=c.sent()).data.length>0&&"0"!==u.data.trim().substring(0,1))throw new E("Error: "+u.data,r);c.label=3;case 3:return[2]}}))}))}),1)]);case 1:return c.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){var e=new RegExp("^\\+1[0-9]{10}$","i"),n=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return t.filter((function(t){return e.test(t)||n.test(t)||r.test(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const Y=require("path"),K=require("mustache"),Q=require("lodash"),tt=require("fs");var et=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},nt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},rt=function(){function t(){}return t.prototype.read=function(t){return et(this,void 0,void 0,(function(){return nt(this,(function(e){if(!this.isFile(t))throw new d(t+" does not exist or is not a file");return[2,tt.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return et(this,void 0,void 0,(function(){var e;return nt(this,(function(n){switch(n.label){case 0:return[4,this.read(t)];case 1:if(e=n.sent(),!this.isJson(e))throw new d(t+" does not contain JSON");return[2,JSON.parse(e)]}}))}))},t.prototype.write=function(t,e){return et(this,void 0,void 0,(function(){var n;return nt(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),tt.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return et(this,void 0,void 0,(function(){return nt(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isFile=function(t){return tt.existsSync(t)&&tt.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}(),ot=function(t,e){return n=void 0,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}(this,(function(r){switch(r.label){case 0:n=0,r.label=1;case 1:return n<t.length?[4,e(t[n])]:[3,4];case 2:r.sent(),r.label=3;case 3:return n++,[3,1];case 4:return[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function u(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,u)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},it=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},at=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},ut=function(){function t(){}return t.prototype.render=function(t,e,n){return it(this,void 0,void 0,(function(){var r,o,i,a,u=this;return at(this,(function(c){switch(c.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,Q.cloneDeep)(e),o=Y.isAbsolute(t)?"":__dirname+Y.sep,[4,(new rt).read(o+t)];case 1:return i=c.sent(),a=[],(0,K.parse)(i).forEach((function(t){t.length>=4&&"&"===t[0]&&t[1].startsWith("include:")&&a.push(t[1])})),a.length>0?(void 0===n?n=Y.dirname(o+t)+Y.sep:Y.isAbsolute(n)||(n=o+n),[4,ot(a,(function(t){return it(u,void 0,void 0,(function(){var e,o,i,a;return at(this,(function(u){switch(u.label){case 0:return 3!==(e=t.split(":")).length?[3,2]:(o=e[2],i=r,a=t,[4,this.render(Y.resolve(n,o),r[t])]);case 1:i[a]=u.sent(),u.label=2;case 2:return[2]}}))}))}))]):[3,3];case 2:c.sent(),c.label=3;case 3:return[2,(0,K.render)(i,r)]}}))}))},t}();const ct=require("node-mailjet");var st=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},lt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},ft=function(){function t(t,e,n){this.templateEngine=new ut,this.mailjet=ct.connect(t,e),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return st(this,void 0,void 0,(function(){var r=this;return lt(this,(function(o){switch(o.label){case 0:return[4,J.request((function(){return st(r,void 0,void 0,(function(){var r,o;return lt(this,(function(i){switch(i.label){case 0:return void 0===n.base.copyright&&(n.base.copyright={year:String((new Date).getUTCFullYear())}),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/text")];case 1:return r=i.sent(),[4,this.templateEngine.render("data/email/template/deliveryDelay",n,"data/email/element/html")];case 2:return o=i.sent(),[4,this.sendNotification(t,e,n.base.subject,r,o)];case 3:return[2,i.sent()]}}))}))}),1)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return st(this,void 0,void 0,(function(){var r=this;return lt(this,(function(o){switch(o.label){case 0:return[4,J.request((function(){return st(r,void 0,void 0,(function(){var r,o,i,a;return lt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/text")];case 1:return r=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return o=u.sent(),[4,this.templateEngine.render("data/email/template/trackDelivery",n,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:n.base})];case 4:return a=u.sent(),[4,this.sendNotification(t,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),1)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return st(this,void 0,void 0,(function(){var r=this;return lt(this,(function(o){switch(o.label){case 0:return[4,J.request((function(){return st(r,void 0,void 0,(function(){var r,o,i,a;return lt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return r=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:r,base:n.base})];case 2:return o=u.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:n.base})];case 4:return a=u.sent(),[4,this.sendNotification(t,e,n.base.subject,o,a)];case 5:return[2,u.sent()]}}))}))}),1)];case 1:return[2,o.sent()]}}))}))},t.prototype.sendNotification=function(t,e,n,r,o){return st(this,void 0,void 0,(function(){var i;return lt(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),this.mode!==I.TEST?[3,1]:(U.info("Simulation Mode: Email has been sent",{sender:t,recipient:e}),[3,3]);case 1:return this.mode===I.DEVELOPMENT&&(e.contact="developer@onylab.com"),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:[{From:{Name:t.name,Email:t.contact},To:[{Name:e.name,Email:e.contact}],Subject:n,TextPart:r,HTMLPart:o}]})];case 2:a.sent(),a.label=3;case 3:return[3,5];case 4:throw i=a.sent(),new p(i.message,Number(i.statusCode));case 5:return[2]}}))}))},t}(),pt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},ht=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},dt=function(){function t(t,e){this.root=t,this.environment=e}return t.prototype.full=function(){return pt(this,void 0,void 0,(function(){return ht(this,(function(t){switch(t.label){case 0:return[4,this.init()];case 1:return t.sent(),[2,this.config]}}))}))},t.prototype.init=function(){return pt(this,void 0,void 0,(function(){var t,e,n;return ht(this,(function(r){switch(r.label){case 0:return void 0!==this.config?[3,7]:void 0!==this.root?[3,1]:(this.config={},[3,7]);case 1:if(t=new rt,![I.DEVELOPMENT,I.TEST].includes(this.environment))return[3,5];r.label=2;case 2:return r.trys.push([2,4,,5]),e=this,[4,t.readJson(this.root+"data/config_"+String(this.environment)+".json")];case 3:return e.config=r.sent(),[3,5];case 4:return r.sent(),[3,5];case 5:return void 0!==this.config?[3,7]:(n=this,[4,t.readJson(this.root+"data/config.json")]);case 6:n.config=r.sent(),r.label=7;case 7:return[2]}}))}))},t}();const yt=require("typeorm");var vt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function u(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}c((r=r.apply(t,e||[])).next())}))},bt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},mt=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return vt(this,void 0,void 0,(function(){var n,r;return bt(this,(function(o){switch(o.label){case 0:return void 0!==this.db?[3,2]:[4,this.init()];case 1:o.sent(),o.label=2;case 2:return void 0===(n=this.db[t])?[3,4]:(n.entities=e,n.logging=["error"],n.logger=!0,n.bigNumberStrings=!1,void 0===n.timezone&&(n.timezone="Z"),void 0===n.charset&&(n.charset="UTF8_GENERAL_CI"),r=this,[4,(0,yt.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:U.error(new d("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return vt(this,void 0,void 0,(function(){return bt(this,(function(t){switch(t.label){case 0:return void 0===this.connection?[3,2]:[4,this.connection.synchronize()];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.close=function(){return vt(this,void 0,void 0,(function(){return bt(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return vt(this,void 0,void 0,(function(){var t,e;return bt(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new rt,e=this,[4,t.readJson(this.root+"data/db.json")];case 2:e.db=n.sent(),n.label=3;case 3:return[2]}}))}))},t}();const gt=require("prettyjson");var Et=function(){function t(){}return t.prototype.error=function(t){U.error(t)},t.prototype.info=function(t){U.trace(t)},t.prototype.json=function(t){U.trace(gt.render(t,{}))},t.prototype.success=function(t){U.trace(t)},t}(),wt=function(t){return null==t},St=function(){function t(){}return t.isEmail=function(t){return"string"==typeof t&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(t)},t.isPhone=function(t){return"string"==typeof t&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(t)},t.isNumber=function(t){return"number"==typeof t||"string"==typeof t&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(t)},t}();const xt=require("fast-diff");var _t=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.truncate=function(t,e){return wt(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t.slugify=function(t,e){return void 0===t?"":(0,Q.toLower)((0,Q.trim)((0,Q.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t}(),Ot=function(){function t(){}return t.autoCorrectCity=function(e){if(wt(e))return e;(e.toLowerCase().startsWith("st-")||e.toLowerCase().startsWith("st "))&&(e="Saint "+e.substring(3));var n=t.CITIES.find((function(t){return t.toLowerCase()===e.toLowerCase()}));if(void 0!==n)return n;var r=t.CITIES.find((function(n){var r=t.countDiff(e,n);return r.add<=2&&r.remove<=2}));if(void 0!==r)return r;var o=t.CITIES.find((function(t){return t.replace(/-/g," ").toLowerCase()===e.toLowerCase()}));if(void 0!==o)return o;var i=t.CITIES.find((function(n){var r=t.countDiff(e,n.replace(/-/g," "));return r.add<=2&&r.remove<=2}));if(void 0!==i)return i;var a=t.CITIES.find((function(t){return t.toLowerCase().startsWith(e.toLowerCase())}));if(void 0!==a)return a;var u=t.CITIES.find((function(t){return e.toLowerCase().includes(t.toLowerCase())}));return void 0!==u?u:e},t.isZipCode=function(e){return"string"==typeof e&&(!!t.ZIPCODES.includes(e)||St.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e){var n={};if(!wt(e)){var r=e.split(",");if(r.length>=3){var o=r.length-1;if(n.country=r[o].trim(),r.splice(o--,1),void 0!==r[o]&&r[o].trim().includes(" ")){var i=r[o].trim().split(" ");n.zip=void 0===i[0]?void 0:i[0].trim(),i.splice(0,1),n.city=i.join(" ").trim(),r.splice(o--,1)}else isNaN(Number(r[o].trim()))?isNaN(Number(r[o-1].trim()))?(n.city=r[o].trim(),r.splice(o--,1)):(n.city=r[o].trim(),r.splice(o--,1),n.zip=r[o].trim(),r.splice(o--,1)):(n.zip=r[o].trim(),r.splice(o--,1),o>=2&&(n.city=r[o].trim(),r.splice(o--,1)));n.street=r.map((function(t){return t.trim()})).join(" ").trim()}else{var a=e.toLowerCase();t.ZIPCODES.forEach((function(t){if(a.includes(t)){n.zip=t;try{a=a.replace(new RegExp(_t.escapeRegExp(t),"ig"),"")}catch(t){}}})),t.CITIES.forEach((function(t){if(a.includes(t.toLowerCase())){n.city=t;try{a=a.replace(new RegExp(_t.escapeRegExp(t),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(a.includes(t.toLowerCase())){n.country=t;try{a=a.replace(new RegExp(_t.escapeRegExp(t),"ig"),"")}catch(t){}}})),void 0===n.street&&(n.street=a.split(",").map((function(t){return t.trim()})).join(" ").trim())}void 0===n.country&&(n.country="France")}return n},t.countDiff=function(t,e){var n={add:0,remove:0};return xt(t.toLowerCase(),e.toLowerCase()).forEach((function(t){switch(t[0]){case-1:n.remove+=t[1].length;break;case 1:n.add+=t[1].length}})),n},t.ZIPCODES=["78500","78600","78800","95240","95530","78630","78670","78240","78580","78300","95150","95250","95480","95320","95550"],t.CITIES=["Sartrouville","Cormeilles-en-Parisis","Houilles","Maisons-Laffitte","La Frette-sur-Seine","Argenteuil","Montesson","Le Mesnil-le-Roi","Bezons","Orgeval","Poissy","Morainvilliers","Villennes-sur-Seine","Medan","Chambourcy","Aigremont","Les Alluets-le-Roi","Taverny","Beauchamp","Pierrelaye","Saint-Leu-la-Forêt","Bessancourt"],t.COUNTRIES=["France"],t}(),Tt=function(){function t(){}return t.displayWeekDay=function(e){var n="";return void 0!==t.WEEK_DAYS[e]&&(n=t.WEEK_DAYS[e]),n},t.generatePeriod=function(e,n,r,o,i){void 0===o&&(o=!0),void 0===i&&(i=t.PERIOD_MAX_DATES);for(var a=B.DateTime.fromISO(e,{setZone:!0}).toISODate(),u=B.DateTime.fromISO(n,{setZone:!0}).toISODate(),c=0,s={};a<=u&&c<i;)s[a]=(0,Q.cloneDeep)(r),o&&(s[a].date=a),a=B.DateTime.fromISO(a,{setZone:!0}).plus({days:1}).toISODate(),c++;return s},t.limitDate=function(t,e,n){if(void 0===n&&(n=0),void 0!==t&&void 0!==e){var r=B.DateTime.fromISO(t,{setZone:!0}).toISO(),o=B.DateTime.fromISO(e,{setZone:!0}).plus({seconds:n}).toISO();return r>o?o:r}},t.localeToISO=function(t){var e,n=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),r=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),o=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");if(n.test(t))e=(i=t.split("/"))[2]+"-"+i[1]+"-"+i[0];else if(r.test(t)){var i;e=(i=t.split("-"))[2]+"-"+i[1]+"-"+i[0]}else o.test(t)&&(e=t);return e},t.slotToTime=function(t){var e,n=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),r=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");return t=t.trim(),n.test(t)?e=t.trim()+":00":r.test(t)&&(e=t.split("-")[0].trim()+":00"),e},t.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=B.DateTime.fromISO(t,{setZone:!0});return B.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),Pt=function(){function t(){}return t.phone=function(t,e){if("string"==typeof t&&(t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e)){var n=new RegExp("(0[6-7][0-9]{8})","i").exec(t);if(null!==n&&n.length>0&&null!==n[0])return n[0]}},t}(),Ct=function(){function t(){}return t.trim=function(t){return"string"==typeof t?t.trim():t},t.capitalize=function(e){var n=t.lower(e);return"string"==typeof n?n.split(" ").map((function(t){return t.charAt(0).toUpperCase()+t.slice(1)})).join(" "):e},t.lower=function(t){return"string"==typeof t?t.toLocaleLowerCase():t},t.upper=function(t){return"string"==typeof t?t.toLocaleUpperCase():t},t.phone=function(e,n,r){if(void 0===r&&(r="nat"),"string"==typeof e)switch(e=t.preformatPhone(e,n),r){case"nat":return t.phoneNat(e,n);case"int":return t.phoneInt(e,n)}return e},t.stripEmoji=function(t){var e=t;if("string"==typeof e){for(var r=n(525)(),o=void 0;null!==(o=r.exec(e));)try{e=(e=(e=e.replace(new RegExp("\\s"+_t.escapeRegExp(o[0]),"g"),"")).replace(new RegExp(_t.escapeRegExp(o[0])+"\\s","g"),"")).replace(new RegExp(_t.escapeRegExp(o[0]),"g"),"")}catch(t){}for(;null!==(o=r.exec(e));)try{e=(e=(e=e.replace(new RegExp("\\s"+_t.escapeRegExp(o[0]),"g"),"")).replace(new RegExp(_t.escapeRegExp(o[0])+"\\s","g"),"")).replace(new RegExp(_t.escapeRegExp(o[0]),"g"),"")}catch(t){}}return e},t.stripExoticCharacters=function(t){return"string"==typeof t?t.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):t},t.preformatPhone=function(t,e){return t=t.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===e&&new RegExp("^[1-9]").test(t)&&9===t.length?"0"+t:t},t.phoneNat=function(t,e){if("fr"===e){if(t.startsWith("+330")?t=t.substr(3):t.startsWith("+33")?t="0"+t.substr(3):t.startsWith("0033")?t="0"+t.substr(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substr(2)),10===t.length){var n=0;t=t.split("").map((function(t){return t+(++n%2==0?" ":"")})).join("").trim()}return t}return t},t.phoneInt=function(t,e){return t.startsWith("+")?t:"fr"===e?(t.startsWith("0")&&(t=t.substr(1)),"+33"+t):t},t}(),Nt=function(){function t(){}return t.code=function(e){null==e&&(e=6);for(var n="";n.length<e;)n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];return n},t.int=function(t,e){return null==t&&(t=0),null==e&&(e=Number.POSITIVE_INFINITY),t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t},t.password=function(e){null==e&&(e=8);for(var n="";n.length<e;)switch(t.int(1,3)){case 1:n+=t.symbolUpperCases[t.int(0,t.symbolUpperCases.length-1)];break;case 2:n+=t.symbolLowerCases[t.int(0,t.symbolLowerCases.length-1)];break;default:n+=String(t.int(0,9))}return n},t.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],t.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"],t}(),At=function(){function t(){}return t.avg=function(e){if(0===e.length)return 0;var n=e.reduce((function(t,e){return t+e}),0);return t.round(n/e.length,2)},t.applyVariation=function(t,e){return t*(t>=0?1+e/100:1-e/100)},t.median=function(e){if(0===e.length)return 0;if(1===e.length)return e[0];var n=e.sort((function(t,e){return t-e}));return n.length%2==0?t.avg([n[n.length/2-1],n[n.length/2]]):n[Math.floor(n.length/2)]},t.percentage=function(t,e){return 0===e?0:t/e*100},t.round=function(t,e){return 0===e?Math.round(t):Number(t.toFixed(e))},t.variation=function(t,e){var n=0;return 0!==e?n=0!==t?(e-t)/Math.abs(t)*100:100*(e>0?1:-1):0!==t&&(n=-100*(t>0?1:-1)),Math.floor(n)},t}(),jt=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,Q.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,Q.isArray)(e)&&e.length>0||(0,Q.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,Q.isArray)(e)&&!(0,Q.isObject)(e))&&r.push(e)})),r}if((0,Q.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,Q.isArray)(i)||(0,Q.isObject)(i)?(i=t.compact(i,n),((0,Q.isArray)(i)&&i.length>0||(0,Q.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,Q.isArray)(i)&&!(0,Q.isObject)(i))&&(o[r]=i)):null!=i&&("string"!=typeof i||!1===n.removeEmptyString||i.length>0)&&(o[r]=i)})),o}return"string"!=typeof e||!1===n.removeEmptyString||e.length>0?e:void 0},t}(),Mt=function(){function t(){}return t.applyTaxes=function(t,e){var n=Number(t);return e.forEach((function(e){n+=Number(t)*e})),String(At.round(n,2))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),At.round(n,2)},t.displayWithCurrency=function(e,n){if(null==e)return e;var r=t.currencies[n],o=e+" "+n;if(void 0!==r)switch(r.position){case"before":o=r.symbol+e;break;case"after":o=e+r.symbol}return o},t.format=function(t,e,n){if(void 0===n&&(n=2),null==t)return t;var r=Number(t.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:n,maximumFractionDigits:n});switch(e){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}},t.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},t}()})(),r})()}));
|
|
2
2
|
//# sourceMappingURL=common-api.node.min.js.map
|