@onylab/common-api 1.1.1 → 1.1.4

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.
@@ -318,18 +318,31 @@ declare module "templating/view/email/ViewEmailElementBaseContract" {
318
318
  shop: {
319
319
  name: string;
320
320
  url: string;
321
+ textUrl: string;
321
322
  logo: string;
323
+ phone: {
324
+ display: string;
325
+ int: string;
326
+ };
322
327
  email: string;
323
328
  social: {
324
- facebook: {
329
+ facebook?: {
330
+ url: string;
331
+ logo: string;
332
+ };
333
+ instagram?: {
334
+ url: string;
335
+ logo: string;
336
+ };
337
+ tiktok?: {
325
338
  url: string;
326
339
  logo: string;
327
340
  };
328
- instagram: {
341
+ twitter?: {
329
342
  url: string;
330
343
  logo: string;
331
344
  };
332
- twitter: {
345
+ whatsapp?: {
333
346
  url: string;
334
347
  logo: string;
335
348
  };
@@ -667,8 +680,6 @@ declare module "util/FormatterUtil" {
667
680
  }
668
681
  declare module "util/AddressUtil" {
669
682
  export class AddressUtil {
670
- private static readonly ZIPCODES;
671
- private static readonly CITIES;
672
683
  private static readonly ZIPCODE_CITY;
673
684
  private static readonly REGIONS;
674
685
  private static readonly COUNTRIES;
@@ -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,(()=>(()=>{"use strict";var t={16:t=>{t.exports=require("emoji-regex")}},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={};n.r(r),n.d(r,{Constant:()=>o,Exception:()=>i,Http:()=>a,Service:()=>u,Template:()=>s,Tool:()=>c,Util:()=>l});var o={};n.r(o),n.d(o,{Path:()=>p});var i={};n.r(i),n.d(i,{BadParameterException:()=>v,BadRequestException:()=>b,ConflictException:()=>w,DuplicateException:()=>S,ExternalApiException:()=>O,InternalException:()=>_,MainException:()=>d,NotImplementedException:()=>P,ObjectNotFoundException:()=>I,PageNotFoundException:()=>A,UnauthorizedException:()=>N});var a={};n.r(a),n.d(a,{AuthenticationMiddleware:()=>z,AuthorizationMiddleware:()=>G,HandlerController:()=>H,Server:()=>X});var u={};n.r(u),n.d(u,{EmailSenderService:()=>At,SmsSenderService:()=>ct});var s={};n.r(s),n.d(s,{TemplateEngine:()=>Pt});var c={};n.r(c),n.d(c,{Configuration:()=>Lt,Database:()=>Ut,Displayer:()=>Ht,Downloader:()=>zt,Env:()=>R,Environment:()=>F,FileSystem:()=>wt,Logger:()=>q,Retry:()=>rt});var l={};n.r(l),n.d(l,{AddressUtil:()=>Bt,DateUtil:()=>Vt,ExtractorUtil:()=>Jt,FormatterUtil:()=>Zt,GeneratorUtil:()=>mt,MathUtil:()=>$t,ObjectUtil:()=>Yt,PriceUtil:()=>Xt,StringUtil:()=>Wt,ValidatorUtil:()=>ot,asyncForEach:()=>dt,isNullOrUndefined:()=>U,wait:()=>yt});var f,p=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}(),h=(f=function(t,e){return f=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])},f(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}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),d=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 h(e,t),e}(Error),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="BadParameterException",r}return y(e,t),e}(d),m=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)}}(),b=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadRequestException",r}return m(e,t),e}(d),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)}}(),w=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="ConflictException",r}return g(e,t),e}(d),E=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,409,n)||this;return r.name="DuplicateException",r}return E(e,t),e}(d),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)}}(),O=function(t){function e(e,n){var r=t.call(this,e,502,n)||this;return r.name="ExternalApiException",r}return x(e,t),e}(d),T=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,500,n)||this;return r.name="InternalException",r}return T(e,t),e}(d),C=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)}}(),P=function(t){function e(e,n){var r=t.call(this,e,501,n)||this;return r.name="NotImplementedException",r}return C(e,t),e}(d),j=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)}}(),I=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="ObjectNotFoundException",r}return j(e,t),e}(d),M=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)}}(),A=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="PageNotFoundException",r}return M(e,t),e}(d),D=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 D(e,t),e.ERROR_CODE=401,e}(d);const L=require("@sentry/node"),k=require("@sentry/profiling-node");var R;!function(t){t.PRODUCTION="prod",t.DEVELOPMENT="dev",t.TEST="test"}(R||(R={}));var F=function(){function t(){}return t.getMode=function(){switch(process.env.NODE_ENV){case"dev":case"development":return R.DEVELOPMENT;case"prod":case"production":return R.PRODUCTION;case"test":return R.TEST}return void 0===process.env.APP_ID?R.DEVELOPMENT:R.PRODUCTION},t}(),U=function(t){return null==t},q=function(){function t(){}return t.init=function(t,e){F.getMode()===R.PRODUCTION&&(L.init({dsn:t,integrations:[L.captureConsoleIntegration({levels:["error","warn","log"]}),(0,k.nodeProfilingIntegration)()],environment:F.getMode(),maxBreadcrumbs:50,tracesSampleRate:0,profilesSampleRate:0}),L.setupExpressErrorHandler(e))},t.trace=function(t,e){[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.info(t):console.info(t,e):L.addBreadcrumb({category:"info",message:t,data:e,level:"info"})},t.debug=function(t,e){[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.log(t):console.log(t,e):L.addBreadcrumb({category:"debug",message:t,data:e,level:"debug"})},t.info=function(t,e){[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.info(t):console.info(t,e):L.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),L.captureMessage(t)}))},t.warning=function(t,e){U(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.warn(t):console.warn(t,e):L.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),L.captureException(t)}))},t.error=function(t,e){[N.ERROR_CODE].includes(t.code)||(U(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[R.DEVELOPMENT,R.TEST].includes(F.getMode())?void 0===e?console.error(t):console.error(t,e):L.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),L.captureException(t)})))},t}(),H=function(){function t(){}return t.error=function(t,e,n){q.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}(),z=function(){function t(t){this.configuration=t}return t.prototype.handler=function(){var t=this;return function(e,n,r){try{var o=!1;if(o||void 0===t.configuration.jwt||(e.session={},o=!0),o||void 0===t.configuration.key||(o=t.authApiKey(e)),!o&&void 0!==t.configuration.session){var i=Object.keys(e.session);if(!Array.isArray(t.configuration.session.required))throw new N("session is not well formatted");t.configuration.session.required.forEach((function(t){if(!i.includes(t))throw new N("session is incomplete")})),o=!0}if(o||void 0===t.configuration.none||(o=t.authNone(e)),!o)throw new N("request is not authenticate");r()}catch(t){H.error(e,n,t)}}},t.prototype.authApiKey=function(t){if("string"!=typeof t.headers.Authorization||!t.headers.Authorization.startsWith("apiKey"))return!1;var e=t.headers.Authorization.split(" ");if(2!==e.length)throw new N("api key is not well formatted");if(e[1]!==this.configuration.key.secret)throw new N("api key is not valid");return t.session={},!0},t.prototype.authNone=function(t){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find((function(e){var n;return null===(n=t.originalUrl)||void 0===n?void 0:n.startsWith(e)}))||(t.session={},0))},t}(),G=function(){function t(){}return t.prototype.can=function(t,e){},t}();const W=require("crypto"),Z=require("express"),B=require("cors"),V=require("compression"),J=require("helmet");var $=n.n(J);const Y=require("connect-timeout");var X=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={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(i){return void 0===this.app&&(r=n||t.DEFAULT_PORT,o="http://localhost:"+String(r),q.debug("start server on "+o),this.app=Z(),this.app.set("trust proxy",!0),this.app.use(V({level:-1})),this.app.use(Y("300s")),this.app.use(Z.json({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(Z.urlencoded({limit:"10mb"})),this.app.use(B({origin:[o].concat(e),credentials:!0})),this.app.use($()()),this.app.use(Z.json()),this.app.listen(r,(function(){q.debug("server is running on "+o)}))),[2,this.app]}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{s(a.next(t))}catch(t){e(t)}}function u(t){try{s(a.throw(t))}catch(t){e(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}s((a=a.apply(r,o||[])).next())}));var r,o,i,a},t.prototype.getSessionSecret=function(e){return W.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}();const K=require("axios");var Q=n.n(K);const tt=require("luxon"),et=require("querystring"),nt=require("retry");var rt=function(){function t(){}return t.request=function(t){return e=this,n=arguments,o=function(t,e,n){var r;return void 0===e&&(e=2),function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(o){return r=nt.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,o){r.attempt((function(){t().then(e).catch((function(t){r.retry(t)?"function"==typeof n&&n(t):o(t)}))}))}))]}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{s(o.next(t))}catch(t){i(t)}}function u(t){try{s(o.throw(t))}catch(t){i(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,u)}s((o=o.apply(e,n||[])).next())}));var e,n,r,o},t}(),ot=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.isIntMobilePhone=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 e.test(t)||n.test(t)||r.test(t)},t.isNumber=function(t){return"number"==typeof t||"string"==typeof t&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(t)},t}();const it=require("iconv-lite");var at=function(){function t(){}return t.isUTF8=function(t){return!t||"utf8"===(t=t.toLowerCase())||"utf-8"===t},t.urlencode=function(e,n){if(!n||t.isUTF8(n))return encodeURIComponent(e);for(var r=(0,it.encode)(e,n),o="",i="",a=0;a<r.length;a++)1===(i=r[a].toString(16)).length&&(i="0"+i),o+="%"+i;return o.toUpperCase()},t}(),ut=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},st=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},ct=function(){function t(t,e){this.token=t,this.mode=e}return t.prototype.send=function(e,n,r){return ut(this,arguments,void 0,(function(e,n,r,o,i){var a,u=this;return void 0===o&&(o=!0),st(this,(function(s){switch(s.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(q.warning(new v("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,rt.request((function(){return ut(u,void 0,void 0,(function(){var r,u,s;return st(this,(function(c){switch(c.label){case 0:return r={accessToken:this.token,emetteur:e,message:at.urlencode(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=tt.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),u=tt.DateTime.fromISO(null!=i?i:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),o?u.hour>=21?r.date_envoi=u.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):u.hour<9&&(r.date_envoi=u.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):u.hour<8&&(r.date_envoi=u.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode!==R.TEST?[3,1]:(q.info("Simulation Mode: SMS has been sent",{params:r}),[3,3]);case 1:return this.mode===R.DEVELOPMENT&&(a=["+15145705214"]),[4,Q().post(t.BASE_API_URL+"sendSMS.do",et.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((s=c.sent()).data.length>0&&"0"!==s.data.trim().substring(0,1))throw new O("Error: "+s.data,r);c.label=3;case 3:return[2]}}))}))}),0,q.error.bind(q))]);case 1:return s.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){return t.filter((function(t){return ot.isIntMobilePhone(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const lt=require("path"),ft=require("mustache"),pt=require("lodash"),ht=require("fs");var dt=function(t,e){return n=void 0,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(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{s(i.next(t))}catch(t){e(t)}}function u(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,u)}s((i=i.apply(n,r||[])).next())}));var n,r,o,i},yt=function(t){return new Promise((function(e){return setTimeout(e,t)}))};const vt=require("color-name");var mt=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.color=function(e){void 0===e&&(e=1);var n=t.rgbToHex(Math.round(255*e)),r="#000000"+n,o=Object.values(vt);if(0===o.length)return r;var i=o[t.int(0,o.length-1)];return 3!==i.length?r:"#"+t.rgbToHex(i[0])+t.rgbToHex(i[1])+t.rgbToHex(i[2])+n},t.rgbToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},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}(),bt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},gt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},wt=function(){function t(){}return t.prototype.dirPath=function(t){var e=lt.resolve(t).lastIndexOf(lt.sep);return e<0?t:lt.resolve(lt.resolve(t).substr(0,e+1))+lt.sep},t.prototype.listFiles=function(t){return bt(this,void 0,void 0,(function(){var e,n,r,o=this;return gt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new v(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=ht.readdirSync(t),r=[],[4,dt(n,(function(n){return bt(o,void 0,void 0,(function(){return gt(this,(function(o){return this.isFile(t+e+n)&&r.push(t+e+n),[2]}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.randomFile=function(t,e){return bt(this,void 0,void 0,(function(){var n,r;return gt(this,(function(o){switch(o.label){case 0:return[4,this.listFiles(t)];case 1:return 0===(n=o.sent()).length?[2,void 0]:(r=void 0!==e?Math.max(e,0)%n.length:mt.int(0,n.length-1),[2,n[r]])}}))}))},t.prototype.move=function(t,e){return bt(this,void 0,void 0,(function(){return gt(this,(function(n){if(!this.isFile(t))throw new v(String(t)+" does not exist or is not a file");if(ht.mkdirSync(e,{recursive:!0}),!this.isDir(e))throw new v(String(e)+" does not exist or is not a directory");return[2,ht.renameSync(t,e+lt.basename(t))]}))}))},t.prototype.read=function(t){return bt(this,void 0,void 0,(function(){return gt(this,(function(e){if(!this.isFile(t))throw new v(String(t)+" does not exist or is not a file");return[2,ht.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return bt(this,void 0,void 0,(function(){var e;return gt(this,(function(n){switch(n.label){case 0:return[4,this.read(t)];case 1:if(e=n.sent(),!this.isJson(e))throw new v(String(t)+" does not contain JSON");return[2,JSON.parse(e)]}}))}))},t.prototype.readJsonFiles=function(t){return bt(this,void 0,void 0,(function(){var e,n,r,o=this;return gt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new v(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=ht.readdirSync(t),r=[],[4,dt(n,(function(n){return bt(o,void 0,void 0,(function(){var o,i,a;return gt(this,(function(u){switch(u.label){case 0:return this.isFile(t+e+n)&&n.endsWith(".json")?(i=(o=r).push,a={name:n},[4,this.readJson(t+e+n)]):[3,2];case 1:i.apply(o,[(a.data=u.sent(),a)]),u.label=2;case 2:return[2]}}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.write=function(t,e){return bt(this,void 0,void 0,(function(){var n;return gt(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),ht.mkdirSync(this.dirPath(t),{recursive:!0}),ht.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return bt(this,void 0,void 0,(function(){return gt(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isDir=function(t){return ht.existsSync(t)&&ht.statSync(t).isDirectory()},t.prototype.isFile=function(t){return ht.existsSync(t)&&ht.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}();const Et=require("clean-css"),St=require("html-minifier-terser");var xt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Ot=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Tt=function(){function t(){}return t.prototype.css=function(t){return xt(this,void 0,void 0,(function(){return Ot(this,(function(e){return[2,new Et({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(t).styles]}))}))},t.prototype.html=function(t){return xt(this,void 0,void 0,(function(){return Ot(this,(function(e){switch(e.label){case 0:return[4,(0,St.minify)(t,{collapseBooleanAttributes:!0,collapseInlineTagWhitespace:!0,collapseWhitespace:!0,continueOnParseError:!1,decodeEntities:!1,html5:!0,minifyCSS:!0,minifyJS:!0,noNewlinesBeforeTagClose:!0,preserveLineBreaks:!1,preventAttributesEscaping:!1,processConditionalComments:!1,quoteCharacter:'"',removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeEmptyElements:!0,removeOptionalTags:!1,removeRedundantAttributes:!0,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeTagWhitespace:!1})];case 1:return[2,e.sent()]}}))}))},t}(),_t=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Ct=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Pt=function(){function t(){this.minifier=new Tt}return t.prototype.render=function(t,e,n){return _t(this,void 0,void 0,(function(){var r,o,i,a,u,s=this;return Ct(this,(function(c){switch(c.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,pt.cloneDeep)(e),o=lt.isAbsolute(t)?"":__dirname+lt.sep,[4,(new wt).read(o+t)];case 1:return i=c.sent(),a=[],(0,ft.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=lt.dirname(o+t)+lt.sep:lt.isAbsolute(n)||(n=o+n),[4,dt(a,(function(t){return _t(s,void 0,void 0,(function(){var e,o,i,a;return Ct(this,(function(u){switch(u.label){case 0:return 3!==(e=t.split(":")).length||void 0===r[t]?[3,2]:(o=e[2],n.includes("/html")&&Object.keys(r[t]).forEach((function(e){r[t][e]=Array.isArray(r[t][e])?r[t][e].map((function(t){return t.replace(/(?:\r\n|\r|\n)/g,"<br>")})):r[t][e].replace(/(?:\r\n|\r|\n)/g,"<br>")})),i=r,a=t,[4,this.render(lt.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:if((u=(0,ft.render)(i,r)).includes("{{")||u.includes("}}"))throw new w("template: missing data to render template",{templatePath:t,data:e});return[2,t.includes("html")?this.minifier.html(u):u]}}))}))},t}();const jt=require("node-mailjet");var It=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Mt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},At=function(){function t(t,e,n){this.templateEngine=new Pt,this.mailjet=new jt.Client({apiKey:t,apiSecret:e}),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return It(this,void 0,void 0,(function(){var r=this;return Mt(this,(function(o){switch(o.label){case 0:return[4,rt.request((function(){return It(r,void 0,void 0,(function(){var r,o;return Mt(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,[{recipient:e,subject:n.base.subject,text:r,html:o}],!1)];case 3:return[2,i.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return It(this,void 0,void 0,(function(){var r=this;return Mt(this,(function(o){switch(o.label){case 0:return[4,rt.request((function(){return It(r,void 0,void 0,(function(){var r,o,i,a;return Mt(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,[{recipient:e,subject:n.base.subject,text:o,html:a}],!1)];case 5:return[2,u.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return It(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),Mt(this,(function(a){switch(a.label){case 0:return[4,rt.request((function(){return It(i,void 0,void 0,(function(){var i,a,u,s;return Mt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return u=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return s=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:s}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendUsersNotifications=function(t,e,n,r){return It(this,void 0,void 0,(function(){var o=this;return Mt(this,(function(i){switch(i.label){case 0:return[4,rt.request((function(){return It(o,void 0,void 0,(function(){var o,i=this;return Mt(this,(function(a){switch(a.label){case 0:return o=[],[4,dt(e,(function(t){return It(i,void 0,void 0,(function(){var e,r,i,a;return Mt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendDiscount=function(t,e,n){return It(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),Mt(this,(function(a){switch(a.label){case 0:return[4,rt.request((function(){return It(i,void 0,void 0,(function(){var i,a,u,s;return Mt(this,(function(c){switch(c.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return i=c.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=c.sent(),[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/html")];case 3:return u=c.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return s=c.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:s}],r,o)];case 5:return[2,c.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendDiscounts=function(t,e){return It(this,arguments,void 0,(function(t,e,n,r){var o=this;return void 0===n&&(n=!0),Mt(this,(function(i){switch(i.label){case 0:return[4,rt.request((function(){return It(o,void 0,void 0,(function(){var o,i=this;return Mt(this,(function(a){switch(a.label){case 0:return o=[],[4,dt(e,(function(t){return It(i,void 0,void 0,(function(){var e,r,i,a;return Mt(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendNotification=function(t,e){return It(this,arguments,void 0,(function(t,e,n,r){var o,i,a=this;return void 0===n&&(n=!1),Mt(this,(function(u){switch(u.label){case 0:if(0===e.length)throw new v("email: missing messages");u.label=1;case 1:return u.trys.push([1,6,,7]),this.mode!==R.TEST?[3,2]:(q.info("Simulation Mode: Email has been sent",{sender:t,recipients:e.map((function(t){return t.recipient}))}),[3,5]);case 2:return o=[],[4,dt(e,(function(e){return It(a,void 0,void 0,(function(){return Mt(this,(function(i){return this.mode===R.DEVELOPMENT&&(e.recipient.contact="developer@onylab.com"),o.push({From:{Name:t.name,Email:t.contact},To:[{Name:e.recipient.name,Email:e.recipient.contact}],Subject:e.subject,TextPart:e.text,HTMLPart:e.html,Priority:n?0:2,customID:void 0===r?void 0:String(r)}),[2]}))}))}))];case 3:return u.sent(),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:o})];case 4:u.sent(),u.label=5;case 5:return[3,7];case 6:throw i=u.sent(),new d(i.message,Number(i.statusCode));case 7:return[2]}}))}))},t}(),Dt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Nt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Lt=function(){function t(e,n){this.filesystem=new wt,void 0!==t.root&&t.root===e||(t.root=e,t.config=void 0);var r=void 0===n?F.getMode():n;void 0!==t.environment&&t.environment===r||(t.environment=void 0===n?F.getMode():n,t.config=void 0)}return t.prototype.full=function(){return Dt(this,void 0,void 0,(function(){return Nt(this,(function(e){switch(e.label){case 0:return[4,this.init()];case 1:return e.sent(),[2,t.config]}}))}))},t.prototype.init=function(){return Dt(this,void 0,void 0,(function(){var e,n,r,o;return Nt(this,(function(i){switch(i.label){case 0:return void 0!==t.config?[3,6]:void 0!==t.root?[3,1]:(t.config={},[3,6]);case 1:return e=t,[4,this.filesystem.readJson(t.root+"data/config.json")];case 2:if(e.config=i.sent(),![R.DEVELOPMENT,R.TEST].includes(t.environment))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),n=t,r=pt.merge,o=[t.config],[4,this.filesystem.readJson(t.root+"data/config_"+String(t.environment)+".json")];case 4:return n.config=r.apply(void 0,o.concat([i.sent()])),[3,6];case 5:return i.sent(),[3,6];case 6:return[2]}}))}))},t}();const kt=require("typeorm");var Rt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Ft=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Ut=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return Rt(this,void 0,void 0,(function(){var n,r;return Ft(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,kt.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:q.error(new v("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return Rt(this,void 0,void 0,(function(){return Ft(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 Rt(this,void 0,void 0,(function(){return Ft(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return Rt(this,void 0,void 0,(function(){var t,e;return Ft(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new wt,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 qt=require("prettyjson");var Ht=function(){function t(){}return t.prototype.error=function(t){q.error(t)},t.prototype.info=function(t){q.trace(t)},t.prototype.json=function(t){q.trace(qt.render(t,{}))},t.prototype.success=function(t){q.trace(t)},t}(),zt=function(){function t(){this.fileSystem=new wt}return t.prototype.image=function(t,e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(i){switch(i.label){case 0:return void 0===n&&(n=W.randomBytes(20).toString("hex")+lt.extname(t)),[4,this.fileSystem.write(e+lt.sep+n,"")];case 1:return i.sent(),r=lt.resolve(e+lt.sep+n),o=ht.createWriteStream(r),[4,Q()({url:t,method:"GET",responseType:"stream"})];case 2:return i.sent().data.pipe(o),[2,new Promise((function(t,e){o.on("finish",(function(){return t(r)})),o.on("error",e)}))]}}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{s(a.next(t))}catch(t){e(t)}}function u(t){try{s(a.throw(t))}catch(t){e(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}s((a=a.apply(r,o||[])).next())}));var r,o,i,a},t}();const Gt=require("fast-diff");var Wt=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.hash=function(t,e){void 0===e&&(e=0);for(var n=3735928559^e,r=1103547991^e,o=0,i=void 0;o<t.length;o++)i=t.charCodeAt(o),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),((r^=Math.imul(n^n>>>13,3266489909))>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")},t.nullable=function(t){return U(t)||"string"==typeof t&&0===t.length?null:t},t.removeMultiSpaces=function(t){return"string"!=typeof t?t:t.replace(/\s{2,}/g," ")},t.removeText=function(e,n){if("string"!=typeof e||"string"!=typeof n||0===n.length)return e;try{e=(e=e.replace(new RegExp(t.escapeRegExp(n),"ig"),"")).replace(new RegExp(t.escapeRegExp(n).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(t){}return e},t.replace=function(e,n,r){if("string"!=typeof e)return e;if(n.length!==r.length)return e;var o=e;return n.forEach((function(e,n){o=o.replace(new RegExp(t.escapeRegExp(e),"ig"),r[n])})),o},t.slugify=function(t,e){return void 0===e&&(e=""),void 0===t?"":(0,pt.toLower)((0,pt.trim)((0,pt.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t.truncate=function(t,e){return U(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t}(),Zt=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.ucfirst=function(e){var n=t.lower(e);return"string"==typeof n?n.charAt(0).toUpperCase()+n.slice(1):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(16),o=void 0;null!==(o=r().exec(e));)try{e=(e=(e=e.replace(new RegExp(Wt.escapeRegExp(o[0]),"g"),"")).replace(new RegExp("\\s+","g")," ")).trim()}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.substring(3):t.startsWith("+33")?t="0"+t.substring(3):t.startsWith("0033")?t="0"+t.substring(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substring(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.substring(1)),"+33"+t):t},t}(),Bt=function(){function t(){}return t.autoCorrectCity=function(e){if(U(e)||"string"!=typeof e||0===e.length)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.autoCorrectStreet=function(e){if(U(e)||"string"!=typeof e||0===e.length)return e;t.STREET_TYPE.forEach((function(t){t.short.length<t.long.length&&(e=(e=e.replace(new RegExp("(\\s"+String(t.short)+"\\.?\\s)","ig")," "+String(t.long)+" ")).replace(new RegExp("(\\s"+String(t.short)+"\\.\\s)","ig")," "+String(t.long)+" "))}));var n=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(e);return null!==n&&2===n.length&&(e=e.substring(n[1].length)),t.STREET_TYPE.forEach((function(t){e=(e=e.replace(new RegExp("([0-9]+)("+String(t.long)+"\\s)","ig"),"$1 $2")).replace(new RegExp("([0-9]+)("+String(t.short)+"\\.?\\s)","ig"),"$1 "+String(t.long)+" ")})),e},t.getZipCodeFromCity=function(e){if(!U(e))return Object.keys(t.ZIPCODE_CITY).reduce((function(n,r){return void 0!==t.ZIPCODE_CITY[r].find((function(t){return t.toLowerCase()===e.toLowerCase()}))?r:n}),void 0)},t.getCityFromZipCode=function(e,n){if(void 0!==e&&void 0!==n){var r,o=t.ZIPCODE_CITY[e];if(void 0!==o)return 1===o.length?o[0]:(n.split(",").forEach((function(t){r=o.find((function(e){return t.trim().toLowerCase()===e.trim().toLowerCase()}))})),void 0!==r?r:o[0])}},t.isZipCode=function(e){return"string"==typeof e&&(!!t.ZIPCODES.includes(e)||ot.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e,n){void 0===n&&(n=!0);var r={};if(!U(e)){var o=e.split(",");if(o.length>=3&&n){void 0===t.COUNTRIES.find((function(t){return e.toLowerCase().includes(" "+t.toLowerCase())}))&&o.push("France");var i=o.length-1;if(r.country=o[i].trim(),o.splice(i--,1),void 0!==o[i]&&o[i].trim().includes(" ")){var a=o[i].trim().split(" ");r.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),r.city=a.join(" ").trim(),o.splice(i--,1)}else isNaN(Number(o[i].trim()))?isNaN(Number(o[i-1].trim()))?(r.city=o[i].trim(),o.splice(i--,1)):(r.city=o[i].trim(),o.splice(i--,1),r.zip=o[i].trim(),o.splice(i--,1)):(r.zip=o[i].trim(),o.splice(i--,1),i>=2&&(r.city=o[i].trim(),o.splice(i--,1)));r.street=o.map((function(t){return t.trim()})).join(" ").trim()}else{var u=e.toLowerCase();t.ZIPCODES.forEach((function(t){if(u.includes(t)){r.zip=t;try{u=u.replace(new RegExp(Wt.escapeRegExp(t),"ig"),"")}catch(t){}}})),t.CITIES.forEach((function(e){var n;if(u.includes(e.toLowerCase())&&(void 0===r.zip||(null===(n=t.ZIPCODE_CITY[r.zip])||void 0===n?void 0:n.find((function(t){return t.toLowerCase()===e.toLowerCase()}))))){r.city=e;try{u=u.replace(new RegExp(Wt.escapeRegExp(e),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(u.includes(" "+t.toLowerCase())&&!u.includes("de "+t.toLowerCase())&&!u.includes("de la "+t.toLowerCase())){r.country=t;try{u=u.replace(new RegExp(Wt.escapeRegExp(" "+t),"ig"),"")}catch(t){}}})),void 0===r.street&&(r.street=(0,pt.trim)(u.split(",").map((function(t){return t.trim()})).join(" "),"-").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=Zt.lower(Zt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=Zt.upper(Zt.trim(String(r.zip)))),void 0!==r.city&&(r.city=t.autoCorrectCity(Zt.capitalize(Zt.trim(String(r.city))))),void 0!==r.country&&(r.country=Zt.capitalize(Zt.trim(String(r.country)))),t.complete(r)},t.complete=function(e){if(void 0===e.city||0===e.city.length){var n=t.getCityFromZipCode(e.zip,e.street);void 0!==n&&(e.city=n)}return"string"==typeof e.street&&t.REGIONS.forEach((function(t){e.street=Wt.removeText(e.street,t).trim()})),"fr"===Zt.lower(e.country)&&(e.country="France"),e},t.removeDuplicates=function(t){if("string"!=typeof t)return t;var e=[];return t.split(",").forEach((function(t){void 0===e.find((function(e){return e.trim().toLowerCase().includes(t.trim().toLowerCase())}))&&e.push(t)})),e.join(",")},t.countDiff=function(t,e){var n={add:0,remove:0};return Gt(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","78955","78260","95150","95250","95480","95320","95550","95370","95740","95220","95870","78420","78400","78110","78360","78290","78230","78540","78920","95600"],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","Carrières-sous-Poissy","Achères","Taverny","Beauchamp","Pierrelaye","Saint-Leu-la-Forêt","Bessancourt","Montigny-lès-Cormeilles","Herblay","Méry-sur-Oise","Carrières-sur-Seine","Bezons","Chatou","Le Vésinet","Montesson","Croissy","Croissy-sur-Seine","Le Pecq","Vernouillet","Ecquevilly"],t.ZIPCODE_CITY={78500:["Sartrouville"],78600:["Maisons-Laffitte","Le Mesnil-le-Roi"],78800:["Houilles"],95240:["Cormeilles-en-Parisis"],95530:["La Frette-sur-Seine"],78100:["Saint-Germain-en-Laye"],95100:["Argenteuil"],78630:["Orgeval","Morainvilliers"],78670:["Villennes-sur-Seine","Medan"],78240:["Chambourcy","Aigremont"],78300:["Poissy"],78955:["Carrières-sous-Poissy"],78260:["Achères"],78540:["Vernouillet"],78920:["Ecquevilly"],95150:["Taverny"],95250:["Beauchamp"],95480:["Pierrelaye"],95320:["Saint-Leu-la-Forêt"],95550:["Bessancourt"],95370:["Montigny-les-Cormeilles"],95220:["Herblay"],95740:["Frépillon"],95540:["Méry-sur-Oise"],95870:["Bezons"],78420:["Carrières-sur-Seine"],78400:["Chatou"],78110:["Le Vésinet"],78360:["Montesson"],78290:["Croissy-sur-Seine"],78230:["Le Pecq"],95600:["Eaubonne"]},t.REGIONS=["île-de-france"],t.COUNTRIES=["France","FR"],t.STREET_TYPE=[{short:"av",long:"avenue"},{short:"rue",long:"rue"},{short:"bd",long:"boulevard"},{short:"chau",long:"chaussée"},{short:"trav",long:"traverse"},{short:"pl",long:"place"},{short:"pass",long:"passage"},{short:"sent",long:"sentier"},{short:"imp",long:"impasse"},{short:"all",long:"allée"},{short:"chem",long:"chemin"},{short:"ham",long:"hameau"},{short:"dom",long:"domaine"}],t}(),Vt=function(){function t(){}return t.getCycleDateFromFullDate=function(t,e){if("weekly"===e){var n=tt.DateTime.fromISO(t.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===n)return t;var r=n.split("-");return r.length>2?r[0]+"-"+r[1]:r.join("-")}return"monthly"===e?tt.DateTime.fromISO(t).toFormat("yyyy-LL"):tt.DateTime.fromISO(t).toISODate()},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,a){void 0===o&&(o=!0),void 0===i&&(i=t.PERIOD_MAX_DATES),void 0===a&&(a="daily");for(var u={daily:{day:1},weekly:{week:1},monthly:{month:1}}[a],s=tt.DateTime.fromISO(e,{setZone:!0}).toISODate(),c=tt.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};s<=c&&l<i;){var p=t.getCycleDateFromFullDate(s,a);f[p]=(0,pt.cloneDeep)(r),o&&(f[p].date=p),s=tt.DateTime.fromISO(s,{setZone:!0}).plus(u).toISODate(),l++}return f},t.getOpenPeriods=function(t,e){var n=[];return t.forEach((function(t){for(var r=[t],o=function(){var t=r[0];if(void 0===e.find((function(e){return e.from<=t.from&&t.to<=e.to}))){var o=e.find((function(e){return e.from<=t.from&&t.from<e.to&&e.to<t.to}));if(void 0!==o)r.push({from:o.to,to:t.to});else{var i=e.find((function(e){return t.from<e.from&&t.to>e.from&&t.to<=e.to}));if(void 0!==i)r.push({from:t.from,to:i.from});else{var a=e.find((function(e){return t.from<e.from&&e.to<t.to}));void 0!==a?(r.push({from:t.from,to:a.from}),r.push({from:a.to,to:t.to})):n.push(t)}}}r.shift()};r.length>0;)o()})),n},t.limitDate=function(t,e,n){if(void 0===n&&(n=0),void 0!==t&&void 0!==e){var r=tt.DateTime.fromISO(t,{setZone:!0}).toISO(),o=tt.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.delay=function(t,e,n){return U(t)||U(e)?0:Math.round(Math.abs(tt.DateTime.fromISO(t,{setZone:!0}).toUTC().diff(tt.DateTime.fromISO(e,{setZone:!0}).toUTC(),[n])[n]))},t.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=tt.DateTime.fromISO(t,{setZone:!0});return tt.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.min=function(t){return t.reduce((function(t,e){return"string"!=typeof t||t>e?e:t}),void 0)},t.max=function(t){return t.reduce((function(t,e){return void 0===t||t<e?e:t}),void 0)},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),Jt=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}(),$t=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){if("number"==typeof t&&"number"==typeof e)return 0===e?0:t/e*100},t.round=function(t,e){return"number"!=typeof t?t:0===e?Math.round(t):Math.round(t*Math.pow(10,e))/Math.pow(10,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}(),Yt=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,pt.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,pt.isArray)(e)&&e.length>0||(0,pt.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,pt.isArray)(e)&&!(0,pt.isObject)(e))&&r.push(e)})),r}if((0,pt.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,pt.isArray)(i)||(0,pt.isObject)(i)?(i=t.compact(i,n),((0,pt.isArray)(i)&&i.length>0||(0,pt.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,pt.isArray)(i)&&!(0,pt.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}(),Xt=function(){function t(){}return t.applyTaxes=function(t,e,n){void 0===n&&(n=2);var r=Number(t);return e.forEach((function(e){r+=Number(t)*e})),String($t.round(r,n))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),$t.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.round=function(t,e){void 0===e&&(e=.1);var n=100*Number(t),r=100*e,o=n%r;return String($t.round(n-o+(o<Math.ceil(r/2)?0:r),2)/100)},t.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},t}();return 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,(()=>(()=>{"use strict";var t={16:t=>{t.exports=require("emoji-regex")}},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={};n.r(r),n.d(r,{Constant:()=>o,Exception:()=>i,Http:()=>a,Service:()=>u,Template:()=>c,Tool:()=>s,Util:()=>l});var o={};n.r(o),n.d(o,{Path:()=>p});var i={};n.r(i),n.d(i,{BadParameterException:()=>v,BadRequestException:()=>b,ConflictException:()=>w,DuplicateException:()=>S,ExternalApiException:()=>O,InternalException:()=>_,MainException:()=>d,NotImplementedException:()=>j,ObjectNotFoundException:()=>M,PageNotFoundException:()=>D,UnauthorizedException:()=>N});var a={};n.r(a),n.d(a,{AuthenticationMiddleware:()=>G,AuthorizationMiddleware:()=>z,HandlerController:()=>H,Server:()=>X});var u={};n.r(u),n.d(u,{EmailSenderService:()=>Dt,SmsSenderService:()=>st});var c={};n.r(c),n.d(c,{TemplateEngine:()=>jt});var s={};n.r(s),n.d(s,{Configuration:()=>kt,Database:()=>Ut,Displayer:()=>Ht,Downloader:()=>Gt,Env:()=>L,Environment:()=>F,FileSystem:()=>wt,Logger:()=>q,Retry:()=>rt});var l={};n.r(l),n.d(l,{AddressUtil:()=>Bt,DateUtil:()=>Vt,ExtractorUtil:()=>Jt,FormatterUtil:()=>Zt,GeneratorUtil:()=>mt,MathUtil:()=>Yt,ObjectUtil:()=>$t,PriceUtil:()=>Xt,StringUtil:()=>Wt,ValidatorUtil:()=>ot,asyncForEach:()=>dt,isNullOrUndefined:()=>U,wait:()=>yt});var f,p=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}(),h=(f=function(t,e){return f=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])},f(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}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),d=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 h(e,t),e}(Error),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="BadParameterException",r}return y(e,t),e}(d),m=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)}}(),b=function(t){function e(e,n){var r=t.call(this,e,400,n)||this;return r.name="BadRequestException",r}return m(e,t),e}(d),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)}}(),w=function(t){function e(e,n){var r=t.call(this,e,409,n)||this;return r.name="ConflictException",r}return g(e,t),e}(d),E=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,409,n)||this;return r.name="DuplicateException",r}return E(e,t),e}(d),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)}}(),O=function(t){function e(e,n){var r=t.call(this,e,502,n)||this;return r.name="ExternalApiException",r}return x(e,t),e}(d),T=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,500,n)||this;return r.name="InternalException",r}return T(e,t),e}(d),C=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)}}(),j=function(t){function e(e,n){var r=t.call(this,e,501,n)||this;return r.name="NotImplementedException",r}return C(e,t),e}(d),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)}}(),M=function(t){function e(e,n){var r=t.call(this,e,404,n)||this;return r.name="ObjectNotFoundException",r}return P(e,t),e}(d),A=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,404,n)||this;return r.name="PageNotFoundException",r}return A(e,t),e}(d),I=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 I(e,t),e.ERROR_CODE=401,e}(d);const k=require("@sentry/node"),R=require("@sentry/profiling-node");var L;!function(t){t.PRODUCTION="prod",t.DEVELOPMENT="dev",t.TEST="test"}(L||(L={}));var F=function(){function t(){}return t.getMode=function(){switch(process.env.NODE_ENV){case"dev":case"development":return L.DEVELOPMENT;case"prod":case"production":return L.PRODUCTION;case"test":return L.TEST}return void 0===process.env.APP_ID?L.DEVELOPMENT:L.PRODUCTION},t}(),U=function(t){return null==t},q=function(){function t(){}return t.init=function(t,e){F.getMode()===L.PRODUCTION&&(k.init({dsn:t,integrations:[k.captureConsoleIntegration({levels:["error","warn","log"]}),(0,R.nodeProfilingIntegration)()],environment:F.getMode(),maxBreadcrumbs:50,tracesSampleRate:0,profilesSampleRate:0}),k.setupExpressErrorHandler(e))},t.trace=function(t,e){[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.info(t):console.info(t,e):k.addBreadcrumb({category:"info",message:t,data:e,level:"info"})},t.debug=function(t,e){[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.log(t):console.log(t,e):k.addBreadcrumb({category:"debug",message:t,data:e,level:"debug"})},t.info=function(t,e){[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.info(t):console.info(t,e):k.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),k.captureMessage(t)}))},t.warning=function(t,e){U(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.warn(t):console.warn(t,e):k.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),k.captureException(t)}))},t.error=function(t,e){[N.ERROR_CODE].includes(t.code)||(U(t.response)||("object"!=typeof e&&(e={}),e.requestErrorData=t.response.data),[L.DEVELOPMENT,L.TEST].includes(F.getMode())?void 0===e?console.error(t):console.error(t,e):k.withScope((function(n){void 0!==e&&n.setExtra("extra",JSON.stringify(e)),void 0!==t.data&&n.setExtra("data",JSON.stringify(t.data)),k.captureException(t)})))},t}(),H=function(){function t(){}return t.error=function(t,e,n){q.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}(),G=function(){function t(t){this.configuration=t}return t.prototype.handler=function(){var t=this;return function(e,n,r){try{var o=!1;if(o||void 0===t.configuration.jwt||(e.session={},o=!0),o||void 0===t.configuration.key||(o=t.authApiKey(e)),!o&&void 0!==t.configuration.session){var i=Object.keys(e.session);if(!Array.isArray(t.configuration.session.required))throw new N("session is not well formatted");t.configuration.session.required.forEach((function(t){if(!i.includes(t))throw new N("session is incomplete")})),o=!0}if(o||void 0===t.configuration.none||(o=t.authNone(e)),!o)throw new N("request is not authenticate");r()}catch(t){H.error(e,n,t)}}},t.prototype.authApiKey=function(t){if("string"!=typeof t.headers.Authorization||!t.headers.Authorization.startsWith("apiKey"))return!1;var e=t.headers.Authorization.split(" ");if(2!==e.length)throw new N("api key is not well formatted");if(e[1]!==this.configuration.key.secret)throw new N("api key is not valid");return t.session={},!0},t.prototype.authNone=function(t){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find((function(e){var n;return null===(n=t.originalUrl)||void 0===n?void 0:n.startsWith(e)}))||(t.session={},0))},t}(),z=function(){function t(){}return t.prototype.can=function(t,e){},t}();const W=require("crypto"),Z=require("express"),B=require("cors"),V=require("compression"),J=require("helmet");var Y=n.n(J);const $=require("connect-timeout");var X=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={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}(this,(function(i){return void 0===this.app&&(r=n||t.DEFAULT_PORT,o="http://localhost:"+String(r),q.debug("start server on "+o),this.app=Z(),this.app.set("trust proxy",!0),this.app.use(V({level:-1})),this.app.use($("300s")),this.app.use(Z.json({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use(Z.urlencoded({limit:"10mb"})),this.app.use(B({origin:[o].concat(e),credentials:!0})),this.app.use(Y()()),this.app.use(Z.json()),this.app.listen(r,(function(){q.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 W.createHash("sha1").update(e+t.SALT).digest("hex")},t.DEFAULT_PORT=8080,t.SALT="03561b4a0fe7f125025",t}();const K=require("axios");var Q=n.n(K);const tt=require("luxon"),et=require("querystring"),nt=require("retry");var rt=function(){function t(){}return t.request=function(t){return e=this,n=arguments,o=function(t,e,n){var r;return void 0===e&&(e=2),function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}(this,(function(o){return r=nt.operation({retries:e,factor:1,minTimeout:0,maxTimeout:0,randomize:!1}),[2,new Promise((function(e,o){r.attempt((function(){t().then(e).catch((function(t){r.retry(t)?"function"==typeof n&&n(t):o(t)}))}))}))]}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function u(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,u)}c((o=o.apply(e,n||[])).next())}));var e,n,r,o},t}(),ot=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.isIntMobilePhone=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 e.test(t)||n.test(t)||r.test(t)},t.isNumber=function(t){return"number"==typeof t||"string"==typeof t&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(t)},t}();const it=require("iconv-lite");var at=function(){function t(){}return t.isUTF8=function(t){return!t||"utf8"===(t=t.toLowerCase())||"utf-8"===t},t.urlencode=function(e,n){if(!n||t.isUTF8(n))return encodeURIComponent(e);for(var r=(0,it.encode)(e,n),o="",i="",a=0;a<r.length;a++)1===(i=r[a].toString(16)).length&&(i="0"+i),o+="%"+i;return o.toUpperCase()},t}(),ut=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())}))},ct=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},st=function(){function t(t,e){this.token=t,this.mode=e}return t.prototype.send=function(e,n,r){return ut(this,arguments,void 0,(function(e,n,r,o,i){var a,u=this;return void 0===o&&(o=!0),ct(this,(function(c){switch(c.label){case 0:return 0===(a=this.checkPhoneFormat(r)).length?(q.warning(new v("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,rt.request((function(){return ut(u,void 0,void 0,(function(){var r,u,c;return ct(this,(function(s){switch(s.label){case 0:return r={accessToken:this.token,emetteur:e,message:at.urlencode(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=tt.DateTime.fromISO(i,{setZone:!0}).toFormat("ddMMyyyy-HH:mm")),u=tt.DateTime.fromISO(null!=i?i:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris"),o?u.hour>=21?r.date_envoi=u.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):u.hour<9&&(r.date_envoi=u.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):u.hour<8&&(r.date_envoi=u.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode!==L.TEST?[3,1]:(q.info("Simulation Mode: SMS has been sent",{params:r}),[3,3]);case 1:return this.mode===L.DEVELOPMENT&&(a=["+15145705214"]),[4,Q().post(t.BASE_API_URL+"sendSMS.do",et.stringify(r,"&","=",{encodeURIComponent:function(t){return t}}),{timeout:3e4})];case 2:if((c=s.sent()).data.length>0&&"0"!==c.data.trim().substring(0,1))throw new O("Error: "+c.data,r);s.label=3;case 3:return[2]}}))}))}),0,q.error.bind(q))]);case 1:return c.sent(),[2]}}))}))},t.prototype.checkPhoneFormat=function(t){return t.filter((function(t){return ot.isIntMobilePhone(t)}))},t.BASE_API_URL="https://api.smsmode.com/http/1.6/",t.MESSAGE_MAX_LENGTH=150,t}();const lt=require("path"),ft=require("mustache"),pt=require("lodash"),ht=require("fs");var dt=function(t,e){return n=void 0,r=void 0,i=function(){var n;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}(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},yt=function(t){return new Promise((function(e){return setTimeout(e,t)}))};const vt=require("color-name");var mt=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.color=function(e){void 0===e&&(e=1);var n=t.rgbToHex(Math.round(255*e)),r="#000000"+n,o=Object.values(vt);if(0===o.length)return r;var i=o[t.int(0,o.length-1)];return 3!==i.length?r:"#"+t.rgbToHex(i[0])+t.rgbToHex(i[1])+t.rgbToHex(i[2])+n},t.rgbToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},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}(),bt=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())}))},gt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},wt=function(){function t(){}return t.prototype.dirPath=function(t){var e=lt.resolve(t).lastIndexOf(lt.sep);return e<0?t:lt.resolve(lt.resolve(t).substr(0,e+1))+lt.sep},t.prototype.listFiles=function(t){return bt(this,void 0,void 0,(function(){var e,n,r,o=this;return gt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new v(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=ht.readdirSync(t),r=[],[4,dt(n,(function(n){return bt(o,void 0,void 0,(function(){return gt(this,(function(o){return this.isFile(t+e+n)&&r.push(t+e+n),[2]}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.randomFile=function(t,e){return bt(this,void 0,void 0,(function(){var n,r;return gt(this,(function(o){switch(o.label){case 0:return[4,this.listFiles(t)];case 1:return 0===(n=o.sent()).length?[2,void 0]:(r=void 0!==e?Math.max(e,0)%n.length:mt.int(0,n.length-1),[2,n[r]])}}))}))},t.prototype.move=function(t,e){return bt(this,void 0,void 0,(function(){return gt(this,(function(n){if(!this.isFile(t))throw new v(String(t)+" does not exist or is not a file");if(ht.mkdirSync(e,{recursive:!0}),!this.isDir(e))throw new v(String(e)+" does not exist or is not a directory");return[2,ht.renameSync(t,e+lt.basename(t))]}))}))},t.prototype.read=function(t){return bt(this,void 0,void 0,(function(){return gt(this,(function(e){if(!this.isFile(t))throw new v(String(t)+" does not exist or is not a file");return[2,ht.readFileSync(t,"utf8")]}))}))},t.prototype.readJson=function(t){return bt(this,void 0,void 0,(function(){var e;return gt(this,(function(n){switch(n.label){case 0:return[4,this.read(t)];case 1:if(e=n.sent(),!this.isJson(e))throw new v(String(t)+" does not contain JSON");return[2,JSON.parse(e)]}}))}))},t.prototype.readJsonFiles=function(t){return bt(this,void 0,void 0,(function(){var e,n,r,o=this;return gt(this,(function(i){switch(i.label){case 0:if(!this.isDir(t))throw new v(String(t)+" does not exist or is not a directory");return e=t.endsWith("/")?"":"/",n=ht.readdirSync(t),r=[],[4,dt(n,(function(n){return bt(o,void 0,void 0,(function(){var o,i,a;return gt(this,(function(u){switch(u.label){case 0:return this.isFile(t+e+n)&&n.endsWith(".json")?(i=(o=r).push,a={name:n},[4,this.readJson(t+e+n)]):[3,2];case 1:i.apply(o,[(a.data=u.sent(),a)]),u.label=2;case 2:return[2]}}))}))}))];case 1:return i.sent(),[2,r]}}))}))},t.prototype.write=function(t,e){return bt(this,void 0,void 0,(function(){var n;return gt(this,(function(r){return"",n="string"==typeof e||"number"==typeof e?String(e):JSON.stringify(e),ht.mkdirSync(this.dirPath(t),{recursive:!0}),ht.writeFileSync(t,n,{encoding:"utf8"}),[2,Promise.resolve()]}))}))},t.prototype.writeJson=function(t,e){return bt(this,void 0,void 0,(function(){return gt(this,(function(n){return[2,this.write(t,JSON.stringify(e))]}))}))},t.prototype.isDir=function(t){return ht.existsSync(t)&&ht.statSync(t).isDirectory()},t.prototype.isFile=function(t){return ht.existsSync(t)&&ht.statSync(t).isFile()},t.prototype.isJson=function(t){try{return JSON.parse(t),!0}catch(t){return!1}},t}();const Et=require("clean-css"),St=require("html-minifier-terser");var xt=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())}))},Ot=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},Tt=function(){function t(){}return t.prototype.css=function(t){return xt(this,void 0,void 0,(function(){return Ot(this,(function(e){return[2,new Et({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(t).styles]}))}))},t.prototype.html=function(t){return xt(this,void 0,void 0,(function(){return Ot(this,(function(e){switch(e.label){case 0:return[4,(0,St.minify)(t,{collapseBooleanAttributes:!0,collapseInlineTagWhitespace:!0,collapseWhitespace:!0,continueOnParseError:!1,decodeEntities:!1,html5:!0,minifyCSS:!0,minifyJS:!0,noNewlinesBeforeTagClose:!0,preserveLineBreaks:!1,preventAttributesEscaping:!1,processConditionalComments:!1,quoteCharacter:'"',removeAttributeQuotes:!1,removeComments:!0,removeEmptyAttributes:!0,removeEmptyElements:!0,removeOptionalTags:!1,removeRedundantAttributes:!0,removeScriptTypeAttributes:!1,removeStyleLinkTypeAttributes:!1,removeTagWhitespace:!1})];case 1:return[2,e.sent()]}}))}))},t}(),_t=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())}))},Ct=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},jt=function(){function t(){this.minifier=new Tt}return t.prototype.render=function(t,e,n){return _t(this,void 0,void 0,(function(){var r,o,i,a,u,c=this;return Ct(this,(function(s){switch(s.label){case 0:return t.endsWith(".template")||(t+=".template"),r=(0,pt.cloneDeep)(e),o=lt.isAbsolute(t)?"":__dirname+lt.sep,[4,(new wt).read(o+t)];case 1:return i=s.sent(),a=[],(0,ft.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=lt.dirname(o+t)+lt.sep:lt.isAbsolute(n)||(n=o+n),[4,dt(a,(function(t){return _t(c,void 0,void 0,(function(){var e,o,i,a;return Ct(this,(function(u){switch(u.label){case 0:return 3!==(e=t.split(":")).length||void 0===r[t]?[3,2]:(o=e[2],n.includes("/html")&&Object.keys(r[t]).forEach((function(e){r[t][e]=Array.isArray(r[t][e])?r[t][e].map((function(t){return t.replace(/(?:\r\n|\r|\n)/g,"<br>")})):r[t][e].replace(/(?:\r\n|\r|\n)/g,"<br>")})),i=r,a=t,[4,this.render(lt.resolve(n,o),r[t])]);case 1:i[a]=u.sent(),u.label=2;case 2:return[2]}}))}))}))]):[3,3];case 2:s.sent(),s.label=3;case 3:if((u=(0,ft.render)(i,r)).includes("{{")||u.includes("}}"))throw new w("template: missing data to render template",{templatePath:t,data:e});return[2,t.includes("html")?this.minifier.html(u):u]}}))}))},t}();const Pt=require("node-mailjet");var Mt=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={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},Dt=function(){function t(t,e,n){this.templateEngine=new jt,this.mailjet=new Pt.Client({apiKey:t,apiSecret:e}),this.mode=n}return t.prototype.sendDeliveryDelay=function(t,e,n){return Mt(this,void 0,void 0,(function(){var r=this;return At(this,(function(o){switch(o.label){case 0:return[4,rt.request((function(){return Mt(r,void 0,void 0,(function(){var r,o;return At(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,[{recipient:e,subject:n.base.subject,text:r,html:o}],!1)];case 3:return[2,i.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendTrackDelivery=function(t,e,n){return Mt(this,void 0,void 0,(function(){var r=this;return At(this,(function(o){switch(o.label){case 0:return[4,rt.request((function(){return Mt(r,void 0,void 0,(function(){var r,o,i,a;return At(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,[{recipient:e,subject:n.base.subject,text:o,html:a}],!1)];case 5:return[2,u.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,o.sent()]}}))}))},t.prototype.sendUserNotification=function(t,e,n){return Mt(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),At(this,(function(a){switch(a.label){case 0:return[4,rt.request((function(){return Mt(i,void 0,void 0,(function(){var i,a,u,c;return At(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/text")];case 1:return i=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=s.sent(),[4,this.templateEngine.render("data/email/template/userNotification",n,"data/email/element/html")];case 3:return u=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return c=s.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:c}],r,o)];case 5:return[2,s.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendUsersNotifications=function(t,e,n,r){return Mt(this,void 0,void 0,(function(){var o=this;return At(this,(function(i){switch(i.label){case 0:return[4,rt.request((function(){return Mt(o,void 0,void 0,(function(){var o,i=this;return At(this,(function(a){switch(a.label){case 0:return o=[],[4,dt(e,(function(t){return Mt(i,void 0,void 0,(function(){var e,r,i,a;return At(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/userNotification",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendDiscount=function(t,e,n){return Mt(this,arguments,void 0,(function(t,e,n,r,o){var i=this;return void 0===r&&(r=!0),At(this,(function(a){switch(a.label){case 0:return[4,rt.request((function(){return Mt(i,void 0,void 0,(function(){var i,a,u,c;return At(this,(function(s){switch(s.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/text")];case 1:return i=s.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:i,base:n.base,isCommercial:r})];case 2:return a=s.sent(),[4,this.templateEngine.render("data/email/template/discount",n,"data/email/element/html")];case 3:return u=s.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:u,base:n.base,isCommercial:r})];case 4:return c=s.sent(),[4,this.sendNotification(t,[{recipient:e,subject:n.base.subject,text:a,html:c}],r,o)];case 5:return[2,s.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,a.sent()]}}))}))},t.prototype.sendDiscounts=function(t,e){return Mt(this,arguments,void 0,(function(t,e,n,r){var o=this;return void 0===n&&(n=!0),At(this,(function(i){switch(i.label){case 0:return[4,rt.request((function(){return Mt(o,void 0,void 0,(function(){var o,i=this;return At(this,(function(a){switch(a.label){case 0:return o=[],[4,dt(e,(function(t){return Mt(i,void 0,void 0,(function(){var e,r,i,a;return At(this,(function(u){switch(u.label){case 0:return[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/text")];case 1:return e=u.sent(),[4,this.templateEngine.render("data/email/element/text/index",{content:e,base:t.data.base,isCommercial:n})];case 2:return r=u.sent(),[4,this.templateEngine.render("data/email/template/discount",t.data,"data/email/element/html")];case 3:return i=u.sent(),[4,this.templateEngine.render("data/email/element/html/index",{content:i,base:t.data.base,isCommercial:n})];case 4:return a=u.sent(),o.push({recipient:t.recipient,subject:t.data.base.subject,text:r,html:a}),[2]}}))}))}))];case 1:return a.sent(),[4,this.sendNotification(t,o,n,r)];case 2:return[2,a.sent()]}}))}))}),0,q.error.bind(q))];case 1:return[2,i.sent()]}}))}))},t.prototype.sendNotification=function(t,e){return Mt(this,arguments,void 0,(function(t,e,n,r){var o,i,a=this;return void 0===n&&(n=!1),At(this,(function(u){switch(u.label){case 0:if(0===e.length)throw new v("email: missing messages");u.label=1;case 1:return u.trys.push([1,6,,7]),this.mode!==L.TEST?[3,2]:(q.info("Simulation Mode: Email has been sent",{sender:t,recipients:e.map((function(t){return t.recipient}))}),[3,5]);case 2:return o=[],[4,dt(e,(function(e){return Mt(a,void 0,void 0,(function(){return At(this,(function(i){return this.mode===L.DEVELOPMENT&&(e.recipient.contact="developer@onylab.com"),o.push({From:{Name:t.name,Email:t.contact},To:[{Name:e.recipient.name,Email:e.recipient.contact}],Subject:e.subject,TextPart:e.text,HTMLPart:e.html,Priority:n?0:2,customID:void 0===r?void 0:String(r)}),[2]}))}))}))];case 3:return u.sent(),[4,this.mailjet.post("send",{version:"v3.1"}).request({Messages:o})];case 4:u.sent(),u.label=5;case 5:return[3,7];case 6:throw i=u.sent(),new d(i.message,Number(i.statusCode));case 7:return[2]}}))}))},t}(),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())}))},Nt=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},kt=function(){function t(e,n){this.filesystem=new wt,void 0!==t.root&&t.root===e||(t.root=e,t.config=void 0);var r=void 0===n?F.getMode():n;void 0!==t.environment&&t.environment===r||(t.environment=void 0===n?F.getMode():n,t.config=void 0)}return t.prototype.full=function(){return It(this,void 0,void 0,(function(){return Nt(this,(function(e){switch(e.label){case 0:return[4,this.init()];case 1:return e.sent(),[2,t.config]}}))}))},t.prototype.init=function(){return It(this,void 0,void 0,(function(){var e,n,r,o;return Nt(this,(function(i){switch(i.label){case 0:return void 0!==t.config?[3,6]:void 0!==t.root?[3,1]:(t.config={},[3,6]);case 1:return e=t,[4,this.filesystem.readJson(t.root+"data/config.json")];case 2:if(e.config=i.sent(),![L.DEVELOPMENT,L.TEST].includes(t.environment))return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),n=t,r=pt.merge,o=[t.config],[4,this.filesystem.readJson(t.root+"data/config_"+String(t.environment)+".json")];case 4:return n.config=r.apply(void 0,o.concat([i.sent()])),[3,6];case 5:return i.sent(),[3,6];case 6:return[2]}}))}))},t}();const Rt=require("typeorm");var Lt=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())}))},Ft=function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},Ut=function(){function t(t){this.root=t}return t.prototype.connect=function(t,e){return Lt(this,void 0,void 0,(function(){var n,r;return Ft(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,Rt.createConnection)(n)]);case 3:return r.connection=o.sent(),[3,5];case 4:q.error(new v("bad connection name")),o.label=5;case 5:return[2]}}))}))},t.prototype.synchronize=function(){return Lt(this,void 0,void 0,(function(){return Ft(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 Lt(this,void 0,void 0,(function(){return Ft(this,(function(t){return[2,this.connection.close()]}))}))},t.prototype.init=function(){return Lt(this,void 0,void 0,(function(){var t,e;return Ft(this,(function(n){switch(n.label){case 0:return void 0!==this.root?[3,1]:(this.db={},[3,3]);case 1:return t=new wt,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 qt=require("prettyjson");var Ht=function(){function t(){}return t.prototype.error=function(t){q.error(t)},t.prototype.info=function(t){q.trace(t)},t.prototype.json=function(t){q.trace(qt.render(t,{}))},t.prototype.success=function(t){q.trace(t)},t}(),Gt=function(){function t(){this.fileSystem=new wt}return t.prototype.image=function(t,e,n){return r=this,o=void 0,a=function(){var r,o;return function(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=e.call(t,i)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}(this,(function(i){switch(i.label){case 0:return void 0===n&&(n=W.randomBytes(20).toString("hex")+lt.extname(t)),[4,this.fileSystem.write(e+lt.sep+n,"")];case 1:return i.sent(),r=lt.resolve(e+lt.sep+n),o=ht.createWriteStream(r),[4,Q()({url:t,method:"GET",responseType:"stream"})];case 2:return i.sent().data.pipe(o),[2,new Promise((function(t,e){o.on("finish",(function(){return t(r)})),o.on("error",e)}))]}}))},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}();const zt=require("fast-diff");var Wt=function(){function t(){}return t.escapeRegExp=function(t){return"string"!=typeof t?t:t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},t.hash=function(t,e){void 0===e&&(e=0);for(var n=3735928559^e,r=1103547991^e,o=0,i=void 0;o<t.length;o++)i=t.charCodeAt(o),n=Math.imul(n^i,2654435761),r=Math.imul(r^i,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),((r^=Math.imul(n^n>>>13,3266489909))>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")},t.nullable=function(t){return U(t)||"string"==typeof t&&0===t.length?null:t},t.removeMultiSpaces=function(t){return"string"!=typeof t?t:t.replace(/\s{2,}/g," ")},t.removeText=function(e,n){if("string"!=typeof e||"string"!=typeof n||0===n.length)return e;try{e=(e=e.replace(new RegExp(t.escapeRegExp(n),"ig"),"")).replace(new RegExp(t.escapeRegExp(n).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(t){}return e},t.replace=function(e,n,r){if("string"!=typeof e)return e;if(n.length!==r.length)return e;var o=e;return n.forEach((function(e,n){o=o.replace(new RegExp(t.escapeRegExp(e),"ig"),r[n])})),o},t.slugify=function(t,e){return void 0===e&&(e=""),void 0===t?"":(0,pt.toLower)((0,pt.trim)((0,pt.deburr)(t)).replace(/[^0-9a-z\-\_]/gi,e))},t.truncate=function(t,e){return U(t)||t.length<=e?t:e<=3?"":t.slice(0,e-3)+"..."},t}(),Zt=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.ucfirst=function(e){var n=t.lower(e);return"string"==typeof n?n.charAt(0).toUpperCase()+n.slice(1):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(16),o=void 0;null!==(o=r().exec(e));)try{e=(e=(e=e.replace(new RegExp(Wt.escapeRegExp(o[0]),"g"),"")).replace(new RegExp("\\s+","g")," ")).trim()}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.substring(3):t.startsWith("+33")?t="0"+t.substring(3):t.startsWith("0033")?t="0"+t.substring(4):t.startsWith("33")&&11===t.length&&(t="0"+t.substring(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.substring(1)),"+33"+t):t},t}(),Bt=function(){function t(){}return t.autoCorrectCity=function(e){if(U(e)||"string"!=typeof e||0===e.length)return e;(e.toLowerCase().startsWith("st-")||e.toLowerCase().startsWith("st "))&&(e="Saint "+e.substring(3));var n=Object.values(t.ZIPCODE_CITY).flat(),r=n.find((function(t){return t.toLowerCase()===e.toLowerCase()}));if(void 0!==r)return r;var o=n.find((function(n){var r=t.countDiff(e,n);return r.add<=2&&r.remove<=2}));if(void 0!==o)return o;var i=n.find((function(t){return t.replace(/-/g," ").toLowerCase()===e.toLowerCase()}));if(void 0!==i)return i;var a=n.find((function(n){var r=t.countDiff(e,n.replace(/-/g," "));return r.add<=2&&r.remove<=2}));if(void 0!==a)return a;var u=n.find((function(t){return t.toLowerCase().startsWith(e.toLowerCase())}));if(void 0!==u)return u;var c=n.find((function(t){return e.toLowerCase().includes(t.toLowerCase())}));return void 0!==c?c:e},t.autoCorrectStreet=function(e){if(U(e)||"string"!=typeof e||0===e.length)return e;t.STREET_TYPE.forEach((function(t){t.short.length<t.long.length&&(e=(e=e.replace(new RegExp("(\\s"+String(t.short)+"\\.?\\s)","ig")," "+String(t.long)+" ")).replace(new RegExp("(\\s"+String(t.short)+"\\.\\s)","ig")," "+String(t.long)+" "))}));var n=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(e);return null!==n&&2===n.length&&(e=e.substring(n[1].length)),t.STREET_TYPE.forEach((function(t){e=(e=e.replace(new RegExp("([0-9]+)("+String(t.long)+"\\s)","ig"),"$1 $2")).replace(new RegExp("([0-9]+)("+String(t.short)+"\\.?\\s)","ig"),"$1 "+String(t.long)+" ")})),e},t.getZipCodeFromCity=function(e){if(!U(e))return Object.keys(t.ZIPCODE_CITY).reduce((function(n,r){return void 0!==t.ZIPCODE_CITY[r].find((function(t){return t.toLowerCase()===e.toLowerCase()}))?r:n}),void 0)},t.getCityFromZipCode=function(e,n){if(void 0!==e&&void 0!==n){var r,o=t.ZIPCODE_CITY[e];if(void 0!==o)return 1===o.length?o[0]:(n.split(",").forEach((function(t){r=o.find((function(e){return t.trim().toLowerCase()===e.trim().toLowerCase()}))})),void 0!==r?r:o[0])}},t.isZipCode=function(e){return"string"==typeof e&&(!!Object.keys(t.ZIPCODE_CITY).includes(e)||ot.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))},t.parse=function(e,n){void 0===n&&(n=!0);var r={};if(!U(e)){var o=e.split(",");if(o.length>=3&&n){void 0===t.COUNTRIES.find((function(t){return e.toLowerCase().includes(" "+t.toLowerCase())}))&&o.push("France");var i=o.length-1;if(r.country=o[i].trim(),o.splice(i--,1),void 0!==o[i]&&o[i].trim().includes(" ")){var a=o[i].trim().split(" ");r.zip=void 0===a[0]?void 0:a[0].trim(),a.splice(0,1),r.city=a.join(" ").trim(),o.splice(i--,1)}else isNaN(Number(o[i].trim()))?isNaN(Number(o[i-1].trim()))?(r.city=o[i].trim(),o.splice(i--,1)):(r.city=o[i].trim(),o.splice(i--,1),r.zip=o[i].trim(),o.splice(i--,1)):(r.zip=o[i].trim(),o.splice(i--,1),i>=2&&(r.city=o[i].trim(),o.splice(i--,1)));r.street=o.map((function(t){return t.trim()})).join(" ").trim()}else{var u=e.toLowerCase();Object.keys(t.ZIPCODE_CITY).forEach((function(t){if(u.includes(t)){r.zip=t;try{u=u.replace(new RegExp(Wt.escapeRegExp(t),"ig"),"")}catch(t){}}})),Object.values(t.ZIPCODE_CITY).flat().forEach((function(e){var n;if(u.includes(e.toLowerCase())&&(void 0===r.zip||(null===(n=t.ZIPCODE_CITY[r.zip])||void 0===n?void 0:n.find((function(t){return t.toLowerCase()===e.toLowerCase()}))))){r.city=e;try{u=u.replace(new RegExp(Wt.escapeRegExp(e),"ig"),"")}catch(t){}}})),t.COUNTRIES.forEach((function(t){if(u.includes(" "+t.toLowerCase())&&!u.includes("de "+t.toLowerCase())&&!u.includes("de la "+t.toLowerCase())){r.country=t;try{u=u.replace(new RegExp(Wt.escapeRegExp(" "+t),"ig"),"")}catch(t){}}})),void 0===r.street&&(r.street=(0,pt.trim)(u.split(",").map((function(t){return t.trim()})).join(" "),"-").trim())}void 0===r.country&&(r.country="France")}return void 0!==r.street&&(r.street=Zt.lower(Zt.trim(String(r.street)))),void 0!==r.zip&&(r.zip=Zt.upper(Zt.trim(String(r.zip)))),void 0!==r.city&&(r.city=t.autoCorrectCity(Zt.capitalize(Zt.trim(String(r.city))))),void 0!==r.country&&(r.country=Zt.capitalize(Zt.trim(String(r.country)))),t.complete(r)},t.complete=function(e){if(void 0===e.city||0===e.city.length){var n=t.getCityFromZipCode(e.zip,e.street);void 0!==n&&(e.city=n)}return"string"==typeof e.street&&t.REGIONS.forEach((function(t){e.street=Wt.removeText(e.street,t).trim()})),"fr"===Zt.lower(e.country)&&(e.country="France"),e},t.removeDuplicates=function(t){if("string"!=typeof t)return t;var e=[];return t.split(",").forEach((function(t){void 0===e.find((function(e){return e.trim().toLowerCase().includes(t.trim().toLowerCase())}))&&e.push(t)})),e.join(",")},t.countDiff=function(t,e){var n={add:0,remove:0};return zt(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.ZIPCODE_CITY={78500:["Sartrouville"],78600:["Maisons-Laffitte","Le Mesnil-le-Roi"],78800:["Houilles"],95240:["Cormeilles-en-Parisis"],95530:["La Frette-sur-Seine"],78100:["Saint-Germain-en-Laye"],95100:["Argenteuil"],78630:["Orgeval","Morainvilliers"],78670:["Villennes-sur-Seine","Medan"],78240:["Chambourcy","Aigremont"],78300:["Poissy"],78510:["Triel-sur-Seine"],78570:["Andrésy","Chanteloup-les-Vignes"],78700:["Conflans-Sainte-Honorine"],78480:["Verneuil-sur-Seine"],78750:["Mareil-Marly"],78620:["L'Étang-la-Ville"],78160:["Marly-le-Roi"],78580:["Les Alluets-le-Roi"],78955:["Carrières-sous-Poissy"],78260:["Achères"],78540:["Vernouillet"],78920:["Ecquevilly"],95150:["Taverny"],95250:["Beauchamp"],95480:["Pierrelaye"],95320:["Saint-Leu-la-Forêt"],95550:["Bessancourt"],95370:["Montigny-lès-Cormeilles"],95220:["Herblay"],95740:["Frépillon"],95540:["Méry-sur-Oise"],95870:["Bezons"],78420:["Carrières-sur-Seine"],78400:["Chatou"],78110:["Le Vésinet"],78360:["Montesson"],78290:["Croissy-sur-Seine","Croissy"],78230:["Le Pecq"],95600:["Eaubonne"]},t.REGIONS=["île-de-france"],t.COUNTRIES=["France","FR"],t.STREET_TYPE=[{short:"av",long:"avenue"},{short:"rue",long:"rue"},{short:"bd",long:"boulevard"},{short:"chau",long:"chaussée"},{short:"trav",long:"traverse"},{short:"pl",long:"place"},{short:"pass",long:"passage"},{short:"sent",long:"sentier"},{short:"imp",long:"impasse"},{short:"all",long:"allée"},{short:"chem",long:"chemin"},{short:"ham",long:"hameau"},{short:"dom",long:"domaine"}],t}(),Vt=function(){function t(){}return t.getCycleDateFromFullDate=function(t,e){if("weekly"===e){var n=tt.DateTime.fromISO(t.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===n)return t;var r=n.split("-");return r.length>2?r[0]+"-"+r[1]:r.join("-")}return"monthly"===e?tt.DateTime.fromISO(t).toFormat("yyyy-LL"):tt.DateTime.fromISO(t).toISODate()},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,a){void 0===o&&(o=!0),void 0===i&&(i=t.PERIOD_MAX_DATES),void 0===a&&(a="daily");for(var u={daily:{day:1},weekly:{week:1},monthly:{month:1}}[a],c=tt.DateTime.fromISO(e,{setZone:!0}).toISODate(),s=tt.DateTime.fromISO(n,{setZone:!0}).toISODate(),l=0,f={};c<=s&&l<i;){var p=t.getCycleDateFromFullDate(c,a);f[p]=(0,pt.cloneDeep)(r),o&&(f[p].date=p),c=tt.DateTime.fromISO(c,{setZone:!0}).plus(u).toISODate(),l++}return f},t.getOpenPeriods=function(t,e){var n=[];return t.forEach((function(t){for(var r=[t],o=function(){var t=r[0];if(void 0===e.find((function(e){return e.from<=t.from&&t.to<=e.to}))){var o=e.find((function(e){return e.from<=t.from&&t.from<e.to&&e.to<t.to}));if(void 0!==o)r.push({from:o.to,to:t.to});else{var i=e.find((function(e){return t.from<e.from&&t.to>e.from&&t.to<=e.to}));if(void 0!==i)r.push({from:t.from,to:i.from});else{var a=e.find((function(e){return t.from<e.from&&e.to<t.to}));void 0!==a?(r.push({from:t.from,to:a.from}),r.push({from:a.to,to:t.to})):n.push(t)}}}r.shift()};r.length>0;)o()})),n},t.limitDate=function(t,e,n){if(void 0===n&&(n=0),void 0!==t&&void 0!==e){var r=tt.DateTime.fromISO(t,{setZone:!0}).toISO(),o=tt.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.delay=function(t,e,n){return U(t)||U(e)?0:Math.round(Math.abs(tt.DateTime.fromISO(t,{setZone:!0}).toUTC().diff(tt.DateTime.fromISO(e,{setZone:!0}).toUTC(),[n])[n]))},t.round=function(t,e){if(void 0===e&&(e=0),"string"!=typeof t)return t;var n=tt.DateTime.fromISO(t,{setZone:!0});return tt.DateTime.fromMillis(Math.round(+n.toMillis()/e)*e).setZone(n.zone).toISO()},t.min=function(t){return t.reduce((function(t,e){return"string"!=typeof t||t>e?e:t}),void 0)},t.max=function(t){return t.reduce((function(t,e){return void 0===t||t<e?e:t}),void 0)},t.PERIOD_MAX_DATES=90,t.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"},t}(),Jt=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}(),Yt=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){if("number"==typeof t&&"number"==typeof e)return 0===e?0:t/e*100},t.round=function(t,e){return"number"!=typeof t?t:0===e?Math.round(t):Math.round(t*Math.pow(10,e))/Math.pow(10,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}(),$t=function(){function t(){}return t.compact=function(e,n){if(void 0===n&&(n={}),(0,pt.isArray)(e)){var r=[];return e.forEach((function(e){e=t.compact(e,n),((0,pt.isArray)(e)&&e.length>0||(0,pt.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,pt.isArray)(e)&&!(0,pt.isObject)(e))&&r.push(e)})),r}if((0,pt.isObject)(e)){var o={};return Object.keys(e).forEach((function(r){var i=e[r];(0,pt.isArray)(i)||(0,pt.isObject)(i)?(i=t.compact(i,n),((0,pt.isArray)(i)&&i.length>0||(0,pt.isObject)(i)&&Object.keys(i).length>0||null!=i&&!(0,pt.isArray)(i)&&!(0,pt.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}(),Xt=function(){function t(){}return t.applyTaxes=function(t,e,n){void 0===n&&(n=2);var r=Number(t);return e.forEach((function(e){r+=Number(t)*e})),String(Yt.round(r,n))},t.calculateTaxes=function(t,e){var n=0;return e.forEach((function(e){n+=t*e})),Yt.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.round=function(t,e){void 0===e&&(e=.1);var n=100*Number(t),r=100*e,o=n%r;return String(Yt.round(n-o+(o<Math.ceil(r/2)?0:r),2)/100)},t.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},t}();return r})()));
2
2
  //# sourceMappingURL=common-api.node.min.js.map