@onylab/common-api 2.1.9 → 2.1.10

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.
@@ -1288,11 +1288,11 @@ declare module "api/hubrise/service/HubriseApiContract" {
1288
1288
  getToken(clientId: string, clientSecret: string, code: string): Promise<HubriseAuthContract>;
1289
1289
  getUser(): Promise<HubriseUserContract>;
1290
1290
  getLocations(): Promise<HubriseLocationContract[]>;
1291
- createCustomer(hubriseCustomerListId: string, hubriseCustomer: HubriseCustomerContract): Promise<void>;
1291
+ createCustomer(hubriseCustomerListId: string, hubriseCustomer: HubriseCustomerContract): Promise<HubriseCustomerContract>;
1292
1292
  getCustomer(hubriseCustomerListId: string, hubriseCustomerId: string): Promise<HubriseCustomerContract>;
1293
1293
  getCustomers(hubriseCustomerListId: string, reference?: string, email?: string, phone?: string): Promise<HubriseCustomerContract[]>;
1294
1294
  getCustomerLists(hubriseLocationId: string): Promise<HubriseCustomerListContract[]>;
1295
- createOrder(hubriseLocationId: string, hubriseOrder: HubriseOrderContract): Promise<void>;
1295
+ createOrder(hubriseLocationId: string, hubriseOrder: HubriseOrderContract): Promise<HubriseOrderContract>;
1296
1296
  getOrder(hubriseLocationId: string, hubriseOrderId: string): Promise<HubriseOrderContract>;
1297
1297
  getOrders(hubriseLocationId: string, limit?: number): Promise<HubriseOrderContract[]>;
1298
1298
  setOrderStatus(hubriseLocationId: string, hubriseOrderId: string, status: HubriseOrderStatus): Promise<void>;
@@ -1400,11 +1400,11 @@ declare module "api/hubrise/service/HubriseApi" {
1400
1400
  getToken(clientId: string, clientSecret: string, code: string): Promise<HubriseAuthContract>;
1401
1401
  getUser(): Promise<HubriseUserContract>;
1402
1402
  getLocations(): Promise<HubriseLocationContract[]>;
1403
- createCustomer(hubriseCustomerListId: string, hubriseCustomer: HubriseCustomerContract): Promise<void>;
1403
+ createCustomer(hubriseCustomerListId: string, hubriseCustomer: HubriseCustomerContract): Promise<HubriseCustomerContract>;
1404
1404
  getCustomer(hubriseCustomerListId: string, hubriseCustomerId: string): Promise<HubriseCustomerContract>;
1405
1405
  getCustomers(hubriseCustomerListId: string, reference?: string, email?: string, phone?: string): Promise<HubriseCustomerContract[]>;
1406
1406
  getCustomerLists(hubriseLocationId: string): Promise<HubriseCustomerListContract[]>;
1407
- createOrder(hubriseLocationId: string, hubriseOrder: HubriseOrderContract): Promise<void>;
1407
+ createOrder(hubriseLocationId: string, hubriseOrder: HubriseOrderContract): Promise<HubriseOrderContract>;
1408
1408
  getOrder(hubriseLocationId: string, hubriseOrderId: string): Promise<HubriseOrderContract>;
1409
1409
  getOrders(hubriseLocationId: string, limit?: number): Promise<HubriseOrderContract[]>;
1410
1410
  setOrderStatus(hubriseLocationId: string, hubriseOrderId: string, status: HubriseOrderStatus): Promise<void>;
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SmilePlayerCommon=t():e.SmilePlayerCommon=t()}(global,()=>(()=>{"use strict";var e={69:e=>{e.exports=JSON.parse('[{"id":"3r4s3-1","name":"Paris","account":{"id":"3r4s3","name":"Bella Pizza","currency":"EUR"},"preparation_time":15,"order_acceptance":{"mode":"normal"}}]')},133:e=>{e.exports=JSON.parse('{"status":"new","private_ref":"fr:1679f128-4ff6-4a60-9fc2-7fe38af4f84d","service_type":"delivery","service_type_ref":null,"expected_time":"2021-11-07T17:17:22Z","customer_notes":"PAS DE COUVERTS","collection_code":"5645","items":[{"product_name":"LIP15","sku_ref":"LIP15","price":"3.50 EUR","quantity":1,"options":[]},{"product_name":"5VANI","sku_ref":"5VANI","price":"6.90 EUR","quantity":1,"options":[]},{"product_name":"TSQ2","sku_ref":"TSQ2","price":"13.50 EUR","quantity":1,"options":[{"option_list_name":"Options","name":"SUPP RACLETTE","ref":"SUPP RACLETTE","price":"1.00 EUR"}]},{"product_name":"SCES","sku_ref":"SCES","price":"10.50 EUR","quantity":1,"options":[]}],"deals":{},"discounts":[],"charges":[{"type":"delivery","name":"Delivery charge","ref":null,"price":"0.99 EUR"}],"payments":[{"type":"online","name":"Paid online","ref":null,"amount":"36.39 EUR"}],"customer":{"address_1":"6a Rue du Tire Pesseau, 21000 Dijon, France","city":"Dijon","postal_code":"21000","phone":"+33175858334","delivery_notes":"Phone access code: 151081499","first_name":"Benoit","last_name":"B.","email":"orders@deliveroo.com","latitude":"47.3166297697847","longitude":"5.00251594930887"}}')},270:e=>{e.exports=JSON.parse('{"id":"87yu4","location_id":"3r4s3-1","name":"Web","created_at":"2020-06-25T11:43:51+02:00","data":{"variants":[],"categories":[],"products":[],"options_lists":[],"deals":[],"discounts":[],"charges":[]}}')},329:e=>{e.exports=JSON.parse('[{"id":"apm3s","name":"Online customers","created_at":"2020-06-25T11:43:51+02:00"},{"id":"s7ma5","name":"POS customers","created_at":"2020-05-19T13:23:10+02:00"}]')},616:e=>{e.exports=JSON.parse('[{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}},{"id":"asdf2","customer_list_id":"ag8u4","anonymised":false,"email":"charles.moore@dummy-mail.org","first_name":"Charles","last_name":"Moore","phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}]')},660:e=>{e.exports=JSON.parse('{"id":"v6ap7","first_name":"Tom","last_name":"Jones","email":"tom.jones@dummy-mail.org","timezone":{"name":"Europe/Paris"},"locales":["fr-FR","en-US"]}')},762:e=>{e.exports=JSON.parse('[{"status":"new","private_ref":"fr:1679f128-4ff6-4a60-9fc2-7fe38af4f84d","service_type":"delivery","service_type_ref":null,"expected_time":"2021-11-07T17:17:22Z","customer_notes":"PAS DE COUVERTS","collection_code":"5645","items":[{"product_name":"LIP15","sku_ref":"LIP15","price":"3.50 EUR","quantity":1,"options":[]},{"product_name":"5VANI","sku_ref":"5VANI","price":"6.90 EUR","quantity":1,"options":[]},{"product_name":"TSQ2","sku_ref":"TSQ2","price":"13.50 EUR","quantity":1,"options":[{"option_list_name":"Options","name":"SUPP RACLETTE","ref":"SUPP RACLETTE","price":"1.00 EUR"}]},{"product_name":"SCES","sku_ref":"SCES","price":"10.50 EUR","quantity":1,"options":[]}],"deals":{},"discounts":[],"charges":[{"type":"delivery","name":"Delivery charge","ref":null,"price":"0.99 EUR"}],"payments":[{"type":"online","name":"Paid online","ref":null,"amount":"36.39 EUR"}],"customer":{"address_1":"6a Rue du Tire Pesseau, 21000 Dijon, France","city":"Dijon","postal_code":"21000","phone":"+33175858334","delivery_notes":"Phone access code: 151081499","first_name":"Benoit","last_name":"B.","email":"orders@deliveroo.com","latitude":"47.3166297697847","longitude":"5.00251594930887"}}]')},835:e=>{e.exports=JSON.parse('[{"id":"87yu4","name":"Web","created_at":"2020-06-25T11:43:51+02:00"},{"id":"sdm3b","name":"Common menu","created_at":"2020-05-19T13:23:10+02:00"}]')},851:e=>{e.exports=JSON.parse('{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}')}},t={};function i(r){var a=t[r];if(void 0!==a)return a.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,i),n.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};i.r(r),i.d(r,{Api:()=>a,Constant:()=>n,Exception:()=>o,Http:()=>s,Mockup:()=>c,Service:()=>l,Template:()=>u,Tool:()=>d,Util:()=>m});var a={};i.r(a),i.d(a,{HubriseApi:()=>x,HubriseAuthResource:()=>b,HubriseCatalogConverter:()=>F,HubriseCountryCode:()=>D,HubriseCurrencyCode:()=>N,HubriseEventType:()=>k,HubriseLanguageCode:()=>w,HubriseLocale:()=>L,HubriseOrderConverter:()=>q,HubriseOrderStatus:()=>U,HubrisePriceUtil:()=>K,HubriseResourceType:()=>B,HubriseRightAccess:()=>R,HubriseServiceType:()=>I,HubriseTimezoneId:()=>O,TotalHubriseCalculator:()=>Z});var n={};i.r(n),i.d(n,{Path:()=>W});var o={};i.r(o),i.d(o,{BadParameterException:()=>J,BadRequestException:()=>Y,ConflictException:()=>z,DuplicateException:()=>X,ExternalApiException:()=>h,InternalException:()=>Q,MainException:()=>p,NotImplementedException:()=>$,ObjectNotFoundException:()=>ee,PageNotFoundException:()=>te,UnauthorizedException:()=>v});var s={};i.r(s),i.d(s,{AuthenticationMiddleware:()=>re,AuthorizationMiddleware:()=>ae,HandlerController:()=>ie,Server:()=>he});var c={};i.r(c),i.d(c,{ApiMockup:()=>Ee,HubriseApiMockup:()=>ye});var l={};i.r(l),i.d(l,{EmailSenderService:()=>qe,SmsSenderService:()=>Ce});var u={};i.r(u),i.d(u,{TemplateEngine:()=>Fe});var d={};i.r(d),i.d(d,{Configuration:()=>We,Database:()=>ze,Displayer:()=>Qe,Downloader:()=>$e,Env:()=>E,Environment:()=>y,FileSystem:()=>Be,Logger:()=>T,Retry:()=>P});var m={};i.r(m),i.d(m,{AddressUtil:()=>ot,DateUtil:()=>st,ExtractorUtil:()=>ct,FormatterUtil:()=>nt,GeneratorUtil:()=>Oe,MathUtil:()=>H,ObjectUtil:()=>V,PriceUtil:()=>lt,StringUtil:()=>it,ValidatorUtil:()=>Se,asyncForEach:()=>Ne,isNullOrUndefined:()=>S,wait:()=>we});const _=require("axios");var A=i.n(_);class p extends Error{constructor(e,t,i){super(e),this.code=t,this.data=i,this.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,p):this.stack=new Error(e).stack}}class h extends p{constructor(e,t){super(e,502,t),this.name="ExternalApiException"}}const f=require("@sentry/node"),g=require("@sentry/profiling-node");var E;!function(e){e.PRODUCTION="prod",e.DEVELOPMENT="dev",e.TEST="test"}(E||(E={}));class y{static getMode(){switch(process.env.NODE_ENV){case"dev":case"development":return E.DEVELOPMENT;case"prod":case"production":return E.PRODUCTION;case"test":return E.TEST}return void 0===process.env.APP_ID?E.DEVELOPMENT:E.PRODUCTION}}class v extends p{constructor(e,t){super(e,v.ERROR_CODE,t),this.name="UnauthorizedException"}}v.ERROR_CODE=401;const S=e=>null==e;class T{static init(e,t){if(y.getMode()===E.PRODUCTION){const i=0;f.init({dsn:e,integrations:[f.captureConsoleIntegration({levels:["error","warn","log"]}),(0,g.nodeProfilingIntegration)()],environment:y.getMode(),maxBreadcrumbs:50,tracesSampleRate:i,profilesSampleRate:i}),f.setupExpressErrorHandler(t)}}static trace(e,t){[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.info(e):console.info(e,JSON.stringify(t,null,2)):f.addBreadcrumb({category:"info",message:e,data:t,level:"info"})}static debug(e,t){[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.log(e):console.log(e,JSON.stringify(t,null,2)):f.addBreadcrumb({category:"debug",message:e,data:t,level:"debug"})}static info(e,t){[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.info(e):console.info(e,JSON.stringify(t,null,2)):f.withScope(i=>{void 0!==t&&i.setExtra("extra",JSON.stringify(t)),f.captureMessage(e)})}static warning(e,t){S(e.response)||("object"!=typeof t&&(t={}),t.requestErrorData=e.response.data),[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.warn(e):console.warn(e,JSON.stringify(t,null,2)):f.withScope(i=>{void 0!==t&&i.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&i.setExtra("data",JSON.stringify(e.data)),f.captureException(e)})}static error(e,t){[v.ERROR_CODE].includes(e.code)||(S(e.response)||("object"!=typeof t&&(t={}),t.requestErrorData=e.response.data),[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.error(e):console.error(e,JSON.stringify(t,null,2)):f.withScope(i=>{void 0!==t&&i.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&i.setExtra("data",JSON.stringify(e.data)),f.captureException(e)}))}}const M=require("retry");class P{static request(e){return t=this,i=arguments,a=function*(e,t=2,i){const r=M.operation({retries:t,factor:1,minTimeout:0,maxTimeout:0,randomize:!1});return new Promise((t,a)=>{r.attempt(()=>{e().then(t).catch(e=>{r.retry(e)?"function"==typeof i&&i(e):a(e)})})})},new((r=void 0)||(r=Promise))(function(e,n){function o(e){try{c(a.next(e))}catch(e){n(e)}}function s(e){try{c(a.throw(e))}catch(e){n(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r(function(e){e(i)})).then(o,s)}c((a=a.apply(t,i||[])).next())});var t,i,r,a}}const C=require("querystring");var b,R,D,N,w,L,O,k,B,U,I,G=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class x{constructor(e){this.token=e}authorize(e,t,i,r,a){return G(this,void 0,void 0,function*(){return x.BASE_AUTH_URL+"authorize?"+(void 0!==e?"name="+String(e)+"&":"")+"redirect_uri="+String(a)+"&client_id="+t+"&scope="+String(i)+"["+String(Object.keys(r).reduce((e,t)=>e.concat(t+"."+String(r[t])),[]).join(","))+"],profile_with_email"})}getToken(e,t,i){return G(this,void 0,void 0,function*(){let r;return yield P.request(()=>G(this,void 0,void 0,function*(){const a=yield A().post(x.BASE_AUTH_URL+"token",C.stringify({code:i,client_id:e,client_secret:t}),{headers:{"Content-Type":"application/x-www-form-urlencoded"},timeout:x.TIMEOUT});if(void 0===a||void 0===a.data)throw new h("failed to get hubrise token");r=a.data}),1,T.error.bind(T)),r})}getUser(){return G(this,void 0,void 0,function*(){let e;return yield P.request(()=>G(this,void 0,void 0,function*(){const t=yield A().get(x.BASE_URL+"user",{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===t||void 0===t.data)throw new h("failed to retrieve hubrise user");e=t.data}),1,T.error.bind(T)),e})}getLocations(){return G(this,void 0,void 0,function*(){let e;return yield P.request(()=>G(this,void 0,void 0,function*(){const t=yield A().get(x.BASE_URL+"locations",{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===t||void 0===t.data)throw new h("failed to retrieve hubrise locations");e=t.data}),1,T.error.bind(T)),e})}createCustomer(e,t){return G(this,void 0,void 0,function*(){yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().post(x.BASE_URL+"customer_lists/"+String(e)+"/customers",t,{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to create hubrise customer")}),1,T.error.bind(T))})}getCustomer(e,t){return G(this,void 0,void 0,function*(){let i;return yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().get(x.BASE_URL+"customer_lists/"+String(e)+"/customers/"+String(t),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to retrieve hubrise customer");i=r.data}),1,T.error.bind(T)),i})}getCustomers(e,t,i,r){return G(this,void 0,void 0,function*(){const a=new URLSearchParams;let n;return a.append("private_ref",t),a.append("email",i),a.append("phone",r),yield P.request(()=>G(this,void 0,void 0,function*(){const t=yield A().get(x.BASE_URL+"customer_lists/"+String(e)+"/customers?"+a.toString(),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===t||void 0===t.data)throw new h("failed to retrieve hubrise customers");n=t.data}),1,T.error.bind(T)),n})}getCustomerLists(e){return G(this,void 0,void 0,function*(){let t;return yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().get(x.BASE_URL+"locations/"+String(e)+"/customer_lists",{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to retrieve hubrise customer lists");t=i.data}),1,T.error.bind(T)),t})}createOrder(e,t){return G(this,void 0,void 0,function*(){yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().post(x.BASE_URL+"locations/"+String(e)+"/orders",t,{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to create hubrise order")}),1,T.error.bind(T))})}getOrder(e,t){return G(this,void 0,void 0,function*(){let i;return yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().get(x.BASE_URL+"locations/"+String(e)+"/orders/"+String(t),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to retrieve hubrise order");i=r.data}),1,T.error.bind(T)),i})}getOrders(e){return G(this,arguments,void 0,function*(e,t=30){let i=[];return yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().get(x.BASE_URL+"locations/"+String(e)+"/orders?count="+String(t),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to retrieve hubrise orders");i=r.data}),1,T.error.bind(T)),i})}setOrderStatus(e,t,i){return G(this,void 0,void 0,function*(){yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().patch(x.BASE_URL+"locations/"+String(e)+"/orders/"+String(t),{status:i},{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to update hubrise order status")}),1,T.error.bind(T))})}getCatalog(e){return G(this,void 0,void 0,function*(){let t;return yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().get(x.BASE_URL+"catalogs/"+String(e),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to retrieve hubrise catalogs");t=i.data}),1,T.error.bind(T)),t})}getCatalogs(e){return G(this,void 0,void 0,function*(){let t=[];return yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().get(x.BASE_URL+"locations/"+String(e)+"/catalogs",{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to retrieve hubrise catalogs");t=i.data}),1,T.error.bind(T)),t})}createWebhook(e,t){return G(this,void 0,void 0,function*(){yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().post(x.BASE_URL+"/callback",{url:e,events:t},{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to create hubrise webhook")}),1,T.error.bind(T))})}}x.BASE_URL="http://api.hubrise.com/v1/",x.BASE_AUTH_URL="https://manager.hubrise.com/oauth2/v1/",x.TIMEOUT=15e3,function(e){e.ORDERS="orders",e.CUSTOMER_LIST="customer_list",e.CATALOG="catalog",e.INVENTORY="inventory",e.ALL_CUSTOMER_LISTS="all_customer_lists",e.ALL_CATALOG_LISTS="all_catalogs"}(b||(b={})),function(e){e.READ="read",e.WRITE="write"}(R||(R={})),function(e){e.AF="AF",e.AL="AL",e.DZ="DZ",e.AD="AD",e.AO="AO",e.AG="AG",e.AR="AR",e.AM="AM",e.AU="AU",e.AT="AT",e.AZ="AZ",e.BS="BS",e.BH="BH",e.BD="BD",e.BB="BB",e.BY="BY",e.BE="BE",e.BZ="BZ",e.BJ="BJ",e.BT="BT",e.BO="BO",e.BA="BA",e.BW="BW",e.BR="BR",e.BN="BN",e.BG="BG",e.BF="BF",e.BI="BI",e.CV="CV",e.KH="KH",e.CM="CM",e.CA="CA",e.CF="CF",e.TD="TD",e.CL="CL",e.CN="CN",e.CO="CO",e.KM="KM",e.CG="CG",e.CD="CD",e.CR="CR",e.CI="CI",e.HR="HR",e.CU="CU",e.CY="CY",e.CZ="CZ",e.DK="DK",e.DJ="DJ",e.DM="DM",e.DO="DO",e.TL="TL",e.EC="EC",e.EG="EG",e.SV="SV",e.GQ="GQ",e.ER="ER",e.EE="EE",e.SZ="SZ",e.ET="ET",e.FJ="FJ",e.FI="FI",e.FR="FR",e.GA="GA",e.GM="GM",e.GE="GE",e.DE="DE",e.GH="GH",e.GR="GR",e.GD="GD",e.GT="GT",e.GN="GN",e.GW="GW",e.GY="GY",e.HT="HT",e.VA="VA",e.HN="HN",e.HU="HU",e.IS="IS",e.IN="IN",e.ID="ID",e.IR="IR",e.IQ="IQ",e.IE="IE",e.IL="IL",e.IT="IT",e.JM="JM",e.JP="JP",e.JO="JO",e.KZ="KZ",e.KE="KE",e.KI="KI",e.XK="XK",e.KW="KW",e.KG="KG",e.LA="LA",e.LV="LV",e.LB="LB",e.LS="LS",e.LR="LR",e.LY="LY",e.LI="LI",e.LT="LT",e.LU="LU",e.MG="MG",e.MW="MW",e.MY="MY",e.MV="MV",e.ML="ML",e.MT="MT",e.MH="MH",e.MR="MR",e.MU="MU",e.MX="MX",e.FM="FM",e.MD="MD",e.MC="MC",e.MN="MN",e.ME="ME",e.MA="MA",e.MZ="MZ",e.MM="MM",e.NA="NA",e.NR="NR",e.NP="NP",e.NL="NL",e.NZ="NZ",e.NI="NI",e.NE="NE",e.NG="NG",e.KP="KP",e.MK="MK",e.NO="NO",e.OM="OM",e.PK="PK",e.PW="PW",e.PS="PS",e.PA="PA",e.PG="PG",e.PY="PY",e.PE="PE",e.PH="PH",e.PL="PL",e.PT="PT",e.QA="QA",e.RO="RO",e.RU="RU",e.RW="RW",e.KN="KN",e.LC="LC",e.VC="VC",e.WS="WS",e.SM="SM",e.ST="ST",e.SA="SA",e.SN="SN",e.RS="RS",e.SC="SC",e.SL="SL",e.SG="SG",e.SK="SK",e.SI="SI",e.SB="SB",e.SO="SO",e.ZA="ZA",e.KR="KR",e.SS="SS",e.ES="ES",e.LK="LK",e.SD="SD",e.SR="SR",e.SE="SE",e.CH="CH",e.SY="SY",e.TW="TW",e.TJ="TJ",e.TZ="TZ",e.TH="TH",e.TG="TG",e.TO="TO",e.TT="TT",e.TN="TN",e.TR="TR",e.TM="TM",e.TV="TV",e.UG="UG",e.UA="UA",e.AE="AE",e.GB="GB",e.US="US",e.UY="UY",e.UZ="UZ",e.VU="VU",e.VE="VE",e.VN="VN",e.YE="YE",e.ZM="ZM",e.ZW="ZW"}(D||(D={})),function(e){e.AED="AED",e.AFN="AFN",e.ALL="ALL",e.AMD="AMD",e.ANG="ANG",e.AOA="AOA",e.ARS="ARS",e.AUD="AUD",e.AWG="AWG",e.AZN="AZN",e.BAM="BAM",e.BBD="BBD",e.BDT="BDT",e.BGN="BGN",e.BHD="BHD",e.BIF="BIF",e.BMD="BMD",e.BND="BND",e.BOB="BOB",e.BOV="BOV",e.BRL="BRL",e.BSD="BSD",e.BTN="BTN",e.BWP="BWP",e.BYN="BYN",e.BZD="BZD",e.CAD="CAD",e.CDF="CDF",e.CHE="CHE",e.CHF="CHF",e.CHW="CHW",e.CLF="CLF",e.CLP="CLP",e.CNY="CNY",e.COP="COP",e.COU="COU",e.CRC="CRC",e.CUC="CUC",e.CUP="CUP",e.CVE="CVE",e.CZK="CZK",e.DJF="DJF",e.DKK="DKK",e.DOP="DOP",e.DZD="DZD",e.EGP="EGP",e.ERN="ERN",e.ETB="ETB",e.EUR="EUR",e.FJD="FJD",e.FKP="FKP",e.GBP="GBP",e.GEL="GEL",e.GHS="GHS",e.GIP="GIP",e.GMD="GMD",e.GNF="GNF",e.GTQ="GTQ",e.GYD="GYD",e.HKD="HKD",e.HNL="HNL",e.HRK="HRK",e.HTG="HTG",e.HUF="HUF",e.IDR="IDR",e.ILS="ILS",e.INR="INR",e.IQD="IQD",e.IRR="IRR",e.ISK="ISK",e.JMD="JMD",e.JOD="JOD",e.JPY="JPY",e.KES="KES",e.KGS="KGS",e.KHR="KHR",e.KMF="KMF",e.KPW="KPW",e.KRW="KRW",e.KWD="KWD",e.KYD="KYD",e.KZT="KZT",e.LAK="LAK",e.LBP="LBP",e.LKR="LKR",e.LRD="LRD",e.LSL="LSL",e.LYD="LYD",e.MAD="MAD",e.MDL="MDL",e.MGA="MGA",e.MKD="MKD",e.MMK="MMK",e.MNT="MNT",e.MOP="MOP",e.MRU="MRU",e.MUR="MUR",e.MVR="MVR",e.MWK="MWK",e.MXN="MXN",e.MXV="MXV",e.MYR="MYR",e.MZN="MZN",e.NAD="NAD",e.NGN="NGN",e.NIO="NIO",e.NOK="NOK",e.NPR="NPR",e.NZD="NZD",e.OMR="OMR",e.PAB="PAB",e.PEN="PEN",e.PGK="PGK",e.PHP="PHP",e.PKR="PKR",e.PLN="PLN",e.PYG="PYG",e.QAR="QAR",e.RON="RON",e.RSD="RSD",e.RUB="RUB",e.RWF="RWF",e.SAR="SAR",e.SBD="SBD",e.SCR="SCR",e.SDG="SDG",e.SEK="SEK",e.SGD="SGD",e.SHP="SHP",e.SLE="SLE",e.SOS="SOS",e.SRD="SRD",e.SSP="SSP",e.STN="STN",e.SVC="SVC",e.SYP="SYP",e.SZL="SZL",e.THB="THB",e.TJS="TJS",e.TMT="TMT",e.TND="TND",e.TOP="TOP",e.TRY="TRY",e.TTD="TTD",e.TWD="TWD",e.TZS="TZS",e.UAH="UAH",e.UGX="UGX",e.USD="USD",e.USN="USN",e.UYI="UYI",e.UYU="UYU",e.UZS="UZS",e.VED="VED",e.VEF="VEF",e.VND="VND",e.VUV="VUV",e.WST="WST",e.XAF="XAF",e.XCD="XCD",e.XDR="XDR",e.XOF="XOF",e.XPF="XPF",e.XSU="XSU",e.XUA="XUA",e.YER="YER",e.ZAR="ZAR",e.ZMW="ZMW",e.ZWL="ZWL"}(N||(N={})),function(e){e.AR="ar",e.DE="de",e.EN="en",e.ES="es",e.FR="fr",e.PT="pt"}(w||(w={})),function(e){e.EN_US="en-US",e.EN_GB="en-GB",e.EN_CA="en-CA",e.EN_AU="en-AU",e.EN_NZ="en-NZ",e.EN_ZA="en-ZA",e.FR_FR="fr-FR",e.FR_CA="fr-CA",e.FR_BE="fr-BE",e.FR_CH="fr-CH",e.ES_ES="es-ES",e.ES_MX="es-MX",e.ES_AR="es-AR",e.ES_CO="es-CO",e.ES_CL="es-CL",e.DE_DE="de-DE",e.DE_AT="de-AT",e.DE_CH="de-CH",e.IT_IT="it-IT",e.IT_CH="it-CH",e.PT_PT="pt-PT",e.PT_BR="pt-BR",e.NL_NL="nl-NL",e.NL_BE="nl-BE",e.SV_SE="sv-SE",e.NO_NO="no-NO",e.DA_DK="da-DK",e.FI_FI="fi-FI",e.IS_IS="is-IS",e.RU_RU="ru-RU",e.PL_PL="pl-PL",e.CS_CZ="cs-CZ",e.SK_SK="sk-SK",e.HR_HR="hr-HR",e.SR_RS="sr-RS",e.BG_BG="bg-BG",e.UK_UA="uk-UA",e.JA_JP="ja-JP",e.KO_KR="ko-KR",e.ZH_CN="zh-CN",e.ZH_TW="zh-TW",e.ZH_HK="zh-HK",e.TH_TH="th-TH",e.VI_VN="vi-VN",e.ID_ID="id-ID",e.MS_MY="ms-MY",e.AR_SA="ar-SA",e.AR_EG="ar-EG",e.AR_AE="ar-AE",e.HE_IL="he-IL",e.FA_IR="fa-IR",e.TR_TR="tr-TR",e.HI_IN="hi-IN",e.BN_BD="bn-BD",e.TA_IN="ta-IN",e.TE_IN="te-IN",e.UR_PK="ur-PK",e.EL_GR="el-GR",e.HU_HU="hu-HU",e.RO_RO="ro-RO",e.LT_LT="lt-LT",e.LV_LV="lv-LV",e.ET_EE="et-EE",e.SL_SI="sl-SI",e.MT_MT="mt-MT",e.SW_KE="sw-KE",e.AF_ZA="af-ZA",e.AM_ET="am-ET"}(L||(L={})),function(e){e.Africa_Abidjan="Africa/Abidjan",e.Africa_Algiers="Africa/Algiers",e.Africa_Bissau="Africa/Bissau",e.Africa_Cairo="Africa/Cairo",e.Africa_Casablanca="Africa/Casablanca",e.Africa_Ceuta="Africa/Ceuta",e.Africa_El_Aaiun="Africa/El_Aaiun",e.Africa_Johannesburg="Africa/Johannesburg",e.Africa_Juba="Africa/Juba",e.Africa_Khartoum="Africa/Khartoum",e.Africa_Lagos="Africa/Lagos",e.Africa_Maputo="Africa/Maputo",e.Africa_Monrovia="Africa/Monrovia",e.Africa_Nairobi="Africa/Nairobi",e.Africa_Ndjamena="Africa/Ndjamena",e.Africa_Sao_Tome="Africa/Sao_Tome",e.Africa_Tripoli="Africa/Tripoli",e.Africa_Tunis="Africa/Tunis",e.Africa_Windhoek="Africa/Windhoek",e.America_Adak="America/Adak",e.America_Anchorage="America/Anchorage",e.America_Araguaina="America/Araguaina",e.America_Argentina_Buenos_Aires="America/Argentina/Buenos_Aires",e.America_Argentina_Catamarca="America/Argentina/Catamarca",e.America_Argentina_Cordoba="America/Argentina/Cordoba",e.America_Argentina_Jujuy="America/Argentina/Jujuy",e.America_Argentina_La_Rioja="America/Argentina/La_Rioja",e.America_Argentina_Mendoza="America/Argentina/Mendoza",e.America_Argentina_Rio_Gallegos="America/Argentina/Rio_Gallegos",e.America_Argentina_Salta="America/Argentina/Salta",e.America_Argentina_San_Juan="America/Argentina/San_Juan",e.America_Argentina_San_Luis="America/Argentina/San_Luis",e.America_Argentina_Tucuman="America/Argentina/Tucuman",e.America_Argentina_Ushuaia="America/Argentina/Ushuaia",e.America_Asuncion="America/Asuncion",e.America_Bahia="America/Bahia",e.America_Bahia_Banderas="America/Bahia_Banderas",e.America_Barbados="America/Barbados",e.America_Belem="America/Belem",e.America_Belize="America/Belize",e.America_Boa_Vista="America/Boa_Vista",e.America_Bogota="America/Bogota",e.America_Boise="America/Boise",e.America_Cambridge_Bay="America/Cambridge_Bay",e.America_Campo_Grande="America/Campo_Grande",e.America_Cancun="America/Cancun",e.America_Caracas="America/Caracas",e.America_Cayenne="America/Cayenne",e.America_Chicago="America/Chicago",e.America_Chihuahua="America/Chihuahua",e.America_Ciudad_Juarez="America/Ciudad_Juarez",e.America_Costa_Rica="America/Costa_Rica",e.America_Coyhaique="America/Coyhaique",e.America_Cuiaba="America/Cuiaba",e.America_Danmarkshavn="America/Danmarkshavn",e.America_Dawson="America/Dawson",e.America_Dawson_Creek="America/Dawson_Creek",e.America_Denver="America/Denver",e.America_Detroit="America/Detroit",e.America_Edmonton="America/Edmonton",e.America_Eirunepe="America/Eirunepe",e.America_El_Salvador="America/El_Salvador",e.America_Fort_Nelson="America/Fort_Nelson",e.America_Fortaleza="America/Fortaleza",e.America_Glace_Bay="America/Glace_Bay",e.America_Goose_Bay="America/Goose_Bay",e.America_Grand_Turk="America/Grand_Turk",e.America_Guatemala="America/Guatemala",e.America_Guayaquil="America/Guayaquil",e.America_Guyana="America/Guyana",e.America_Halifax="America/Halifax",e.America_Havana="America/Havana",e.America_Hermosillo="America/Hermosillo",e.America_Indiana_Indianapolis="America/Indiana/Indianapolis",e.America_Indiana_Knox="America/Indiana/Knox",e.America_Indiana_Marengo="America/Indiana/Marengo",e.America_Indiana_Petersburg="America/Indiana/Petersburg",e.America_Indiana_Tell_City="America/Indiana/Tell_City",e.America_Indiana_Vevay="America/Indiana/Vevay",e.America_Indiana_Vincennes="America/Indiana/Vincennes",e.America_Indiana_Winamac="America/Indiana/Winamac",e.America_Inuvik="America/Inuvik",e.America_Iqaluit="America/Iqaluit",e.America_Jamaica="America/Jamaica",e.America_Juneau="America/Juneau",e.America_Kentucky_Louisville="America/Kentucky/Louisville",e.America_Kentucky_Monticello="America/Kentucky/Monticello",e.America_La_Paz="America/La_Paz",e.America_Lima="America/Lima",e.America_Los_Angeles="America/Los_Angeles",e.America_Maceio="America/Maceio",e.America_Managua="America/Managua",e.America_Manaus="America/Manaus",e.America_Martinique="America/Martinique",e.America_Matamoros="America/Matamoros",e.America_Mazatlan="America/Mazatlan",e.America_Menominee="America/Menominee",e.America_Merida="America/Merida",e.America_Metlakatla="America/Metlakatla",e.America_Mexico_City="America/Mexico_City",e.America_Miquelon="America/Miquelon",e.America_Moncton="America/Moncton",e.America_Monterrey="America/Monterrey",e.America_Montevideo="America/Montevideo",e.America_New_York="America/New_York",e.America_Nome="America/Nome",e.America_Noronha="America/Noronha",e.America_North_Dakota_Beulah="America/North_Dakota/Beulah",e.America_North_Dakota_Center="America/North_Dakota/Center",e.America_North_Dakota_New_Salem="America/North_Dakota/New_Salem",e.America_Nuuk="America/Nuuk",e.America_Ojinaga="America/Ojinaga",e.America_Panama="America/Panama",e.America_Paramaribo="America/Paramaribo",e.America_Phoenix="America/Phoenix",e.America_Port_au_Prince="America/Port-au-Prince",e.America_Porto_Velho="America/Porto_Velho",e.America_Puerto_Rico="America/Puerto_Rico",e.America_Punta_Arenas="America/Punta_Arenas",e.America_Rankin_Inlet="America/Rankin_Inlet",e.America_Recife="America/Recife",e.America_Regina="America/Regina",e.America_Resolute="America/Resolute",e.America_Rio_Branco="America/Rio_Branco",e.America_Santarem="America/Santarem",e.America_Santiago="America/Santiago",e.America_Santo_Domingo="America/Santo_Domingo",e.America_Sao_Paulo="America/Sao_Paulo",e.America_Scoresbysund="America/Scoresbysund",e.America_Sitka="America/Sitka",e.America_St_Johns="America/St_Johns",e.America_Swift_Current="America/Swift_Current",e.America_Tegucigalpa="America/Tegucigalpa",e.America_Thule="America/Thule",e.America_Tijuana="America/Tijuana",e.America_Toronto="America/Toronto",e.America_Vancouver="America/Vancouver",e.America_Whitehorse="America/Whitehorse",e.America_Winnipeg="America/Winnipeg",e.America_Yakutat="America/Yakutat",e.Antarctica_Casey="Antarctica/Casey",e.Antarctica_Davis="Antarctica/Davis",e.Antarctica_Macquarie="Antarctica/Macquarie",e.Antarctica_Mawson="Antarctica/Mawson",e.Antarctica_Palmer="Antarctica/Palmer",e.Antarctica_Rothera="Antarctica/Rothera",e.Antarctica_Troll="Antarctica/Troll",e.Antarctica_Vostok="Antarctica/Vostok",e.Asia_Almaty="Asia/Almaty",e.Asia_Amman="Asia/Amman",e.Asia_Anadyr="Asia/Anadyr",e.Asia_Aqtau="Asia/Aqtau",e.Asia_Aqtobe="Asia/Aqtobe",e.Asia_Ashgabat="Asia/Ashgabat",e.Asia_Atyrau="Asia/Atyrau",e.Asia_Baghdad="Asia/Baghdad",e.Asia_Baku="Asia/Baku",e.Asia_Bangkok="Asia/Bangkok",e.Asia_Barnaul="Asia/Barnaul",e.Asia_Beirut="Asia/Beirut",e.Asia_Bishkek="Asia/Bishkek",e.Asia_Chita="Asia/Chita",e.Asia_Colombo="Asia/Colombo",e.Asia_Damascus="Asia/Damascus",e.Asia_Dhaka="Asia/Dhaka",e.Asia_Dili="Asia/Dili",e.Asia_Dubai="Asia/Dubai",e.Asia_Dushanbe="Asia/Dushanbe",e.Asia_Famagusta="Asia/Famagusta",e.Asia_Gaza="Asia/Gaza",e.Asia_Hebron="Asia/Hebron",e.Asia_Ho_Chi_Minh="Asia/Ho_Chi_Minh",e.Asia_Hong_Kong="Asia/Hong_Kong",e.Asia_Hovd="Asia/Hovd",e.Asia_Irkutsk="Asia/Irkutsk",e.Asia_Jakarta="Asia/Jakarta",e.Asia_Jayapura="Asia/Jayapura",e.Asia_Jerusalem="Asia/Jerusalem",e.Asia_Kabul="Asia/Kabul",e.Asia_Kamchatka="Asia/Kamchatka",e.Asia_Karachi="Asia/Karachi",e.Asia_Kathmandu="Asia/Kathmandu",e.Asia_Khandyga="Asia/Khandyga",e.Asia_Kolkata="Asia/Kolkata",e.Asia_Krasnoyarsk="Asia/Krasnoyarsk",e.Asia_Kuching="Asia/Kuching",e.Asia_Macau="Asia/Macau",e.Asia_Magadan="Asia/Magadan",e.Asia_Makassar="Asia/Makassar",e.Asia_Manila="Asia/Manila",e.Asia_Nicosia="Asia/Nicosia",e.Asia_Novokuznetsk="Asia/Novokuznetsk",e.Asia_Novosibirsk="Asia/Novosibirsk",e.Asia_Omsk="Asia/Omsk",e.Asia_Oral="Asia/Oral",e.Asia_Pontianak="Asia/Pontianak",e.Asia_Pyongyang="Asia/Pyongyang",e.Asia_Qatar="Asia/Qatar",e.Asia_Qostanay="Asia/Qostanay",e.Asia_Qyzylorda="Asia/Qyzylorda",e.Asia_Riyadh="Asia/Riyadh",e.Asia_Sakhalin="Asia/Sakhalin",e.Asia_Samarkand="Asia/Samarkand",e.Asia_Seoul="Asia/Seoul",e.Asia_Shanghai="Asia/Shanghai",e.Asia_Singapore="Asia/Singapore",e.Asia_Srednekolymsk="Asia/Srednekolymsk",e.Asia_Taipei="Asia/Taipei",e.Asia_Tashkent="Asia/Tashkent",e.Asia_Tbilisi="Asia/Tbilisi",e.Asia_Tehran="Asia/Tehran",e.Asia_Thimphu="Asia/Thimphu",e.Asia_Tokyo="Asia/Tokyo",e.Asia_Tomsk="Asia/Tomsk",e.Asia_Ulaanbaatar="Asia/Ulaanbaatar",e.Asia_Urumqi="Asia/Urumqi",e.Asia_Ust_Nera="Asia/Ust-Nera",e.Asia_Vladivostok="Asia/Vladivostok",e.Asia_Yakutsk="Asia/Yakutsk",e.Asia_Yangon="Asia/Yangon",e.Asia_Yekaterinburg="Asia/Yekaterinburg",e.Asia_Yerevan="Asia/Yerevan",e.Atlantic_Azores="Atlantic/Azores",e.Atlantic_Bermuda="Atlantic/Bermuda",e.Atlantic_Canary="Atlantic/Canary",e.Atlantic_Cape_Verde="Atlantic/Cape_Verde",e.Atlantic_Faroe="Atlantic/Faroe",e.Atlantic_Madeira="Atlantic/Madeira",e.Atlantic_South_Georgia="Atlantic/South_Georgia",e.Atlantic_Stanley="Atlantic/Stanley",e.Australia_Adelaide="Australia/Adelaide",e.Australia_Brisbane="Australia/Brisbane",e.Australia_Broken_Hill="Australia/Broken_Hill",e.Australia_Darwin="Australia/Darwin",e.Australia_Eucla="Australia/Eucla",e.Australia_Hobart="Australia/Hobart",e.Australia_Lindeman="Australia/Lindeman",e.Australia_Lord_Howe="Australia/Lord_Howe",e.Australia_Melbourne="Australia/Melbourne",e.Australia_Perth="Australia/Perth",e.Australia_Sydney="Australia/Sydney",e.Etc_GMT="Etc/GMT",e.Etc_GMT_Minus_1="Etc/GMT-1",e.Etc_GMT_Minus_10="Etc/GMT-10",e.Etc_GMT_Minus_11="Etc/GMT-11",e.Etc_GMT_Minus_12="Etc/GMT-12",e.Etc_GMT_Minus_13="Etc/GMT-13",e.Etc_GMT_Minus_14="Etc/GMT-14",e.Etc_GMT_Minus_2="Etc/GMT-2",e.Etc_GMT_Minus_3="Etc/GMT-3",e.Etc_GMT_Minus_4="Etc/GMT-4",e.Etc_GMT_Minus_5="Etc/GMT-5",e.Etc_GMT_Minus_6="Etc/GMT-6",e.Etc_GMT_Minus_7="Etc/GMT-7",e.Etc_GMT_Minus_8="Etc/GMT-8",e.Etc_GMT_Minus_9="Etc/GMT-9",e.Etc_GMT_Plus_1="Etc/GMT+1",e.Etc_GMT_Plus_10="Etc/GMT+10",e.Etc_GMT_Plus_11="Etc/GMT+11",e.Etc_GMT_Plus_12="Etc/GMT+12",e.Etc_GMT_Plus_2="Etc/GMT+2",e.Etc_GMT_Plus_3="Etc/GMT+3",e.Etc_GMT_Plus_4="Etc/GMT+4",e.Etc_GMT_Plus_5="Etc/GMT+5",e.Etc_GMT_Plus_6="Etc/GMT+6",e.Etc_GMT_Plus_7="Etc/GMT+7",e.Etc_GMT_Plus_8="Etc/GMT+8",e.Etc_GMT_Plus_9="Etc/GMT+9",e.Etc_UTC="Etc/UTC",e.Europe_Andorra="Europe/Andorra",e.Europe_Astrakhan="Europe/Astrakhan",e.Europe_Athens="Europe/Athens",e.Europe_Belgrade="Europe/Belgrade",e.Europe_Berlin="Europe/Berlin",e.Europe_Brussels="Europe/Brussels",e.Europe_Bucharest="Europe/Bucharest",e.Europe_Budapest="Europe/Budapest",e.Europe_Chisinau="Europe/Chisinau",e.Europe_Dublin="Europe/Dublin",e.Europe_Gibraltar="Europe/Gibraltar",e.Europe_Helsinki="Europe/Helsinki",e.Europe_Istanbul="Europe/Istanbul",e.Europe_Kaliningrad="Europe/Kaliningrad",e.Europe_Kirov="Europe/Kirov",e.Europe_Kyiv="Europe/Kyiv",e.Europe_Lisbon="Europe/Lisbon",e.Europe_London="Europe/London",e.Europe_Madrid="Europe/Madrid",e.Europe_Malta="Europe/Malta",e.Europe_Minsk="Europe/Minsk",e.Europe_Moscow="Europe/Moscow",e.Europe_Paris="Europe/Paris",e.Europe_Prague="Europe/Prague",e.Europe_Riga="Europe/Riga",e.Europe_Rome="Europe/Rome",e.Europe_Samara="Europe/Samara",e.Europe_Saratov="Europe/Saratov",e.Europe_Simferopol="Europe/Simferopol",e.Europe_Sofia="Europe/Sofia",e.Europe_Tallinn="Europe/Tallinn",e.Europe_Tirane="Europe/Tirane",e.Europe_Ulyanovsk="Europe/Ulyanovsk",e.Europe_Vienna="Europe/Vienna",e.Europe_Vilnius="Europe/Vilnius",e.Europe_Volgograd="Europe/Volgograd",e.Europe_Warsaw="Europe/Warsaw",e.Europe_Zurich="Europe/Zurich",e.Indian_Chagos="Indian/Chagos",e.Indian_Maldives="Indian/Maldives",e.Indian_Mauritius="Indian/Mauritius",e.Pacific_Apia="Pacific/Apia",e.Pacific_Auckland="Pacific/Auckland",e.Pacific_Bougainville="Pacific/Bougainville",e.Pacific_Chatham="Pacific/Chatham",e.Pacific_Easter="Pacific/Easter",e.Pacific_Efate="Pacific/Efate",e.Pacific_Fakaofo="Pacific/Fakaofo",e.Pacific_Fiji="Pacific/Fiji",e.Pacific_Galapagos="Pacific/Galapagos",e.Pacific_Gambier="Pacific/Gambier",e.Pacific_Guadalcanal="Pacific/Guadalcanal",e.Pacific_Guam="Pacific/Guam",e.Pacific_Honolulu="Pacific/Honolulu",e.Pacific_Kanton="Pacific/Kanton",e.Pacific_Kiritimati="Pacific/Kiritimati",e.Pacific_Kosrae="Pacific/Kosrae",e.Pacific_Kwajalein="Pacific/Kwajalein",e.Pacific_Marquesas="Pacific/Marquesas",e.Pacific_Nauru="Pacific/Nauru",e.Pacific_Niue="Pacific/Niue",e.Pacific_Norfolk="Pacific/Norfolk",e.Pacific_Noumea="Pacific/Noumea",e.Pacific_Pago_Pago="Pacific/Pago_Pago",e.Pacific_Palau="Pacific/Palau",e.Pacific_Pitcairn="Pacific/Pitcairn",e.Pacific_Port_Moresby="Pacific/Port_Moresby",e.Pacific_Rarotonga="Pacific/Rarotonga",e.Pacific_Tahiti="Pacific/Tahiti",e.Pacific_Tarawa="Pacific/Tarawa",e.Pacific_Tongatapu="Pacific/Tongatapu"}(O||(O={})),function(e){e.CREATE="create",e.DELETE="delete",e.PATCH="patch",e.UPDATE="update"}(k||(k={})),function(e){e.CATALOG="catalog",e.CUSTOMER="customer",e.DELIVERY="delivery",e.INVENTORY="inventory",e.LOCATION="location",e.ORDER="order"}(B||(B={})),function(e){e.new="new",e.received="received",e.accepted="accepted",e.in_preparation="in_preparation",e.awaiting_shipment="awaiting_shipment",e.awaiting_collection="awaiting_collection",e.in_delivery="in_delivery",e.completed="completed",e.rejected="rejected",e.cancelled="cancelled",e.delivery_failed="delivery_failed"}(U||(U={})),function(e){e.DELIVERY="delivery",e.COLLECTION="collection",e.EAT_IN="eat_in"}(I||(I={}));class H{static sum(e){return 0===e.length?0:e.reduce((e,t)=>e+t,0)}static avg(e){const t=H.sum(e);return 0===t?0:H.round(t/e.length,2)}static applyVariation(e,t){let i;return i=e>=0?1+t/100:1-t/100,e*i}static median(e){if(0===e.length)return 0;if(1===e.length)return e[0];const t=e.sort((e,t)=>e-t);return t.length%2==0?H.avg([t[t.length/2-1],t[t.length/2]]):t[Math.floor(t.length/2)]}static percentage(e,t){if("number"==typeof e&&"number"==typeof t)return 0===t?0:e/t*100}static round(e,t){return"number"!=typeof e?e:0===t?Math.round(e):Math.round(e*Math.pow(10,t))/Math.pow(10,t)}static variation(e,t){let i=0;return 0!==t?i=0!==e?(t-e)/Math.abs(e)*100:100*(t>0?1:-1):0!==e&&(i=-100*(e>0?1:-1)),Math.floor(i)}}class K{static sum(e,t=N.EUR){var i;if(!Array.isArray(e)||0===e.length)return"0.00 "+String(t);if(1===e.length)return e[0];const r=e.map(e=>K.priceToAmount(e)).filter(e=>void 0!==e);if(0===r.length)return"0.00 "+String(t);const a=H.sum(r.map(e=>e.amount));return K.amountToPrice(a,null!==(i=r[0].currency)&&void 0!==i?i:t)}static multiply(e,t){if(S(e)||S(t))return;if(1===t)return e;const i=K.priceToAmount(e);return void 0!==i?K.amountToPrice(i.amount*t,i.currency):void 0}static priceToAmount(e){if(S(e))return;const t=e.split(" ");return 2===t.length?{amount:Number(t.slice(0,t.length-1).join("")),currency:t[t.length-1]}:void 0}static amountToPrice(e,t){return String(H.round(e,2).toFixed(2))+" "+String(t)}}class F{editableItems(e){var t;if(!Array.isArray(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.products))return{withRef:[],withName:[]};const i={};Array.isArray(e.data.categories)&&e.data.categories.forEach(e=>{i[e.id]=e.name});const r=e.data.products.map(e=>{var t,r,a;const n=null!==(t=e.ref)&&void 0!==t?t:1!==(null===(r=e.skus)||void 0===r?void 0:r.length)||Array.isArray(e.skus[0].option_list_ids)&&0!==e.skus[0].option_list_ids.length?null:e.skus[0].ref,o=1!==(null===(a=e.skus)||void 0===a?void 0:a.length)||Array.isArray(e.skus[0].option_list_ids)&&0!==e.skus[0].option_list_ids.length?K.multiply(e.skus[0].price,0):e.skus[0].price;return{id:e.id,sku_ref:n,category_name:i[e.category_id],product_name:e.name,quantity:1,tax_rate:e.tax_rate,price:o}}).sort((e,t)=>{var i,r,a,n;return(null===(i=e.category_name)||void 0===i?void 0:i.localeCompare(null!==(r=t.category_name)&&void 0!==r?r:""))||(null===(a=e.name)||void 0===a?void 0:a.localeCompare(null!==(n=t.name)&&void 0!==n?n:""))});return{withRef:r.filter(e=>void 0!==e.sku_ref&&null!==e.sku_ref),withName:r}}editableItemOptions(e){var t;if(!Array.isArray(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.products))return{withRef:{},withName:{}};const i={};Array.isArray(e.data.option_lists)&&e.data.option_lists.forEach(e=>{i[e.id]=e});const r={};e.data.products.forEach(e=>{r[e.id]=[],Array.isArray(e.skus)&&0!==e.skus.length&&Array.isArray(e.skus[0].option_list_ids)&&0!==e.skus[0].option_list_ids.length&&(e.skus.forEach(t=>{var a,n;if(Array.isArray(t.option_list_ids)&&t.option_list_ids.length>0)t.option_list_ids.forEach(a=>{const n=i[a];void 0!==n&&Array.isArray(n.options)&&0!==n.options.length&&n.options.forEach(i=>{var a,o,s;const c=K.sum([null!==(a=t.price)&&void 0!==a?a:null,null!==(o=i.price)&&void 0!==o?o:null]);r[e.id].push({id:String(t.id)+"-"+String(n.id)+"-"+String(i.id),ref:null!==(s=i.ref)&&void 0!==s?s:null,option_list_name:n.name,name:i.name,quantity:1,price:c})})});else{const i=null!==(a=t.price)&&void 0!==a?a:null;r[e.id].push({id:t.id,ref:null!==(n=t.ref)&&void 0!==n?n:null,option_list_name:"",name:t.name,quantity:1,price:i})}}),r[e.id].sort((e,t)=>{var i,r;return null===(i=e.name)||void 0===i?void 0:i.localeCompare(null!==(r=t.name)&&void 0!==r?r:"")}))});const a={};return Object.keys(r).forEach(e=>{var t,i;a[e]=null!==(i=null===(t=r[e])||void 0===t?void 0:t.filter(e=>void 0!==e.ref&&null!==e.ref))&&void 0!==i?i:[]}),{withRef:a,withName:r}}}const j=require("lodash");class V{static compact(e,t={}){if((0,j.isArray)(e)){const i=[];return e.forEach(e=>{e=V.compact(e,t),((0,j.isArray)(e)&&e.length>0||(0,j.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,j.isArray)(e)&&!(0,j.isObject)(e))&&i.push(e)}),i}if((0,j.isObject)(e)){const i={};return Object.keys(e).forEach(r=>{let a=e[r];(0,j.isArray)(a)||(0,j.isObject)(a)?(a=V.compact(a,t),((0,j.isArray)(a)&&a.length>0||(0,j.isObject)(a)&&Object.keys(a).length>0||null!=a&&!(0,j.isArray)(a)&&!(0,j.isObject)(a))&&(i[r]=a)):null!=a&&("string"!=typeof a||!1===t.removeEmptyString||a.length>0)&&(i[r]=a)}),i}return"string"!=typeof e||!1===t.removeEmptyString||e.length>0?e:void 0}static update(e,t){if("object"==typeof e&&null!==e&&"object"==typeof t&&null!==t){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];Object.assign(e,t)}}}class q{items(e,t){return Array.isArray(e)?e.map(e=>{const i=[];return Array.isArray(e.options)&&e.options.forEach(e=>{i.push({ref:e.ref,option_list_name:e.option_list_name,name:e.name,quantity:e.quantity,price:e.price})}),V.compact({sku_ref:e.sku_ref,sku_name:e.sku_name,product_name:e.product_name,quantity:e.quantity,price:e.price,subtotal:"",tax_rate:void 0===t||void 0===e.tax_rate||null===e.tax_rate?void 0:e.tax_rate[t],customer_notes:e.customer_notes,options:i})}):[]}}class Z{calculateTotals(e,t){if(!Array.isArray(e.items))return;const i=this.findCurrency(e.items,t),r=K.sum(e.items.map(e=>K.sum([K.multiply(e.price,Number(e.quantity))].concat(K.sum((e.options||[]).map(e=>K.multiply(e.price,Number(e.quantity)))))))),a="0.00 "+String(i),n="0.00 "+String(i),o="0.00 "+String(i);return{subtotal:r,minimumOrderFee:a,deliveryFee:n,totalDiscount:o,total:K.sum([r,a,n,K.multiply(o,-1)])}}findCurrency(e,t){return e.reduce((e,t)=>{const i=K.priceToAmount(t.price);return"string"==typeof(null==i?void 0:i.currency)&&i.currency!==e?i.currency:"options"in t&&Array.isArray(t.options)?this.findCurrency(t.options,e):e},t)}}class W{static registerBasePath(e){void 0!==process.env.APP_HOME?W.BASE_PATH=process.env.APP_HOME+"/":W.BASE_PATH=e+(e.endsWith("/")?"":"/")}static data(){return W.BASE_PATH+"data/"}static db(){return W.storage()+"db/"}static root(){return W.BASE_PATH}static session(){return W.storage()+"session/"}static storage(){return W.BASE_PATH+"storage/"}}W.BASE_PATH="./";class J extends p{constructor(e,t){super(e,400,t),this.name="BadParameterException"}}class Y extends p{constructor(e,t){super(e,400,t),this.name="BadRequestException"}}class z extends p{constructor(e,t){super(e,409,t),this.name="ConflictException"}}class X extends p{constructor(e,t){super(e,409,t),this.name="DuplicateException"}}class Q extends p{constructor(e,t){super(e,500,t),this.name="InternalException"}}class $ extends p{constructor(e,t){super(e,501,t),this.name="NotImplementedException"}}class ee extends p{constructor(e,t){super(e,404,t),this.name="ObjectNotFoundException"}}class te extends p{constructor(e,t){super(e,404,t),this.name="PageNotFoundException"}}class ie{static error(e,t,i){T.error(i);const r=void 0!==i.code&&null!==i.code?Number(i.code):500;t.status(!isNaN(r)&&Number(i.code)>=400&&Number(i.code)<=599?Number(i.code):500),t.json({code:i.code,message:i.message})}}class re{constructor(e){this.configuration=e}handler(){return(e,t,i)=>{try{let t=!1;if(t||void 0===this.configuration.jwt||(e.session={},t=!0),t||void 0===this.configuration.key||(t=this.authApiKey(e)),!t&&void 0!==this.configuration.session){const i=Object.keys(e.session);if(!Array.isArray(this.configuration.session.required))throw new v("session is not well formatted");this.configuration.session.required.forEach(e=>{if(!i.includes(e))throw new v("session is incomplete")}),t=!0}if(t||void 0===this.configuration.none||(t=this.authNone(e)),!t)throw new v("request is not authenticate");i()}catch(i){ie.error(e,t,i)}}}authApiKey(e){if("string"!=typeof e.headers.Authorization||!e.headers.Authorization.startsWith("apiKey"))return!1;const t=e.headers.Authorization.split(" ");if(2!==t.length)throw new v("api key is not well formatted");if(t[1]!==this.configuration.key.secret)throw new v("api key is not valid");return e.session={},!0}authNone(e){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find(t=>{var i;return null===(i=e.originalUrl)||void 0===i?void 0:i.startsWith(t)})||(e.session={},0))}}class ae{can(e,t){}}const ne=require("crypto"),oe=require("express");var se=i.n(oe);const ce=require("cors");var le=i.n(ce);const ue=require("compression");var de=i.n(ue);const me=require("helmet");var _e=i.n(me);const Ae=require("connect-timeout");var pe=i.n(Ae);class he{create(e,t){return i=this,r=void 0,n=function*(){if(void 0===this.app){const i=t||he.DEFAULT_PORT,r="http://localhost:"+String(i);T.debug("start server on "+r),this.app=se()(),this.app.set("trust proxy",!0),this.app.disable("x-powered-by"),this.app.use(de()({level:-1})),this.app.use(pe()("300s")),this.app.use((0,oe.json)({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use((0,oe.urlencoded)({limit:"10mb"})),this.app.use(le()({origin:[r].concat(e),credentials:!0})),this.app.use(_e()()),this.app.use((0,oe.json)()),this.app.listen(i,()=>{T.debug("server is running on "+r)})}return this.app},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{c(n.next(e))}catch(e){t(e)}}function s(e){try{c(n.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(o,s)}c((n=n.apply(i,r||[])).next())});var i,r,a,n}getSessionSecret(e){return ne.createHash("sha1").update(e+he.SALT).digest("hex")}}he.DEFAULT_PORT=8080,he.SALT="03561b4a0fe7f125025";const fe=require("nock");var ge=i.n(fe);class Ee{static isDone(){return(0,fe.isActive)()&&(0,fe.isDone)()}static pending(){return"pending: "+JSON.stringify((0,fe.pendingMocks)())}static reset(){(0,fe.cleanAll)()}}class ye extends Ee{static getUser(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/user")?"/user":e).get("/user").times(e).reply(200,(0,j.cloneDeep)(i(660)))}static getLocations(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/locations")?"/locations":e).get("/locations").times(e).reply(200,(0,j.cloneDeep)(i(69)))}static createCustomer(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/customer")?"/customer":e).post("/customer").times(e).reply(200,(0,j.cloneDeep)(i(851)))}static getCustomer(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/customer_lists")&&e.includes("/customers")?"/customer":e).get("/customer").times(e).reply(200,(0,j.cloneDeep)(i(851)))}static getCustomers(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/customers")?"/customers":e).get("/customers").times(e).reply(200,(0,j.cloneDeep)(i(616)))}static getCustomerLists(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/customer_lists")?"/customerLists":e).get("/customerLists").times(e).reply(200,(0,j.cloneDeep)(i(329)))}static createOrder(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/order")?"/order":e).post("/order").times(e).reply(200,(0,j.cloneDeep)(i(133)))}static getOrder(e=1,t=!1){const r=(0,j.cloneDeep)(i(133));t&&(r.id=String(Date.now())),ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/orders/")?"/order":e).get("/order").times(e).reply(200,r)}static getOrders(e=1,t=!1){const r=(0,j.cloneDeep)(i(762));t&&r.forEach(e=>e.id=String(Date.now())),ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/orders")&&!e.includes("/orders/")?"/orders":e).get("/orders").times(e).reply(200,r)}static setOrderStatus(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/orders/")?"/status":e).patch("/status").times(e).reply(204)}static getCatalog(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/catalog")?"/catalog":e).get("/catalog").times(e).reply(200,(0,j.cloneDeep)(i(270)))}static getCatalogs(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/catalogs")?"/catalogs":e).get("/catalogs").times(e).reply(200,(0,j.cloneDeep)(i(835)))}static createWebhook(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/callback")?"/webhook":e).post("/webhook").times(e).reply(200)}}ye.BASE_URL="http://api.hubrise.com";const ve=require("luxon");class Se{static isEmail(e){return"string"==typeof e&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(e)}static isPhone(e){return"string"==typeof e&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(e)}static isIntMobilePhone(e){const t=new RegExp("^\\+1[0-9]{10}$","i"),i=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return t.test(e)||i.test(e)||r.test(e)}static isNumber(e){return"number"==typeof e||"string"==typeof e&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(e)}static isISODate(e){return!!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?([+-]\d{2}:\d{2}|Z)$/.test(e)&&!isNaN(new Date(e).getTime())}}const Te=require("iconv-lite");class Me{static isUTF8(e){return!e||"utf8"===(e=e.toLowerCase())||"utf-8"===e}static urlencode(e,t){if(!t||Me.isUTF8(t))return encodeURIComponent(e);const i=(0,Te.encode)(e,t);let r="",a="";for(let e=0;e<i.length;e++)a=i[e].toString(16),1===a.length&&(a="0"+a),r+="%"+a;return r=r.toUpperCase(),r}}var Pe=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class Ce{constructor(e,t){this.token=e,this.mode=t}send(e,t,i){return Pe(this,arguments,void 0,function*(e,t,i,r=!0,a){let n=this.checkPhoneFormat(i);if(0===n.length)return T.warning(new J("no valid phone",{phones:i})),Promise.resolve();n.length>1&&(t.length>2*Ce.MESSAGE_MAX_LENGTH?t=t.substring(0,2*Ce.MESSAGE_MAX_LENGTH):t.length>Ce.MESSAGE_MAX_LENGTH&&t.length<=1.33*Ce.MESSAGE_MAX_LENGTH&&(t=t.substring(0,Ce.MESSAGE_MAX_LENGTH))),yield P.request(()=>Pe(this,void 0,void 0,function*(){const i={accessToken:this.token,emetteur:e,message:Me.urlencode(t,"ISO-8859-15"),numero:n.map(e=>e.replace("+","")).join(","),classe_msg:2,nbr_msg:Math.ceil(t.length/Ce.MESSAGE_MAX_LENGTH)};r&&(i.stop=1),void 0!==a&&(i.date_envoi=ve.DateTime.fromISO(a,{setZone:!0}).toFormat("ddMMyyyy-HH:mm"));const o=ve.DateTime.fromISO(null!=a?a:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris");if(r?o.hour>=21?i.date_envoi=o.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):o.hour<9&&(i.date_envoi=o.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):o.hour<8&&(i.date_envoi=o.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode===E.TEST)T.info("Simulation Mode: SMS has been sent",{params:i});else{this.mode===E.DEVELOPMENT&&(n=["+15145705214"]);const e=yield A().post(Ce.BASE_API_URL+"sendSMS.do",C.stringify(i,"&","=",{encodeURIComponent:e=>e}),{timeout:3e4});if(e.data.length>0&&"0"!==e.data.trim().substring(0,1))throw new h("Error: "+e.data,i)}}),0,T.error.bind(T))})}checkPhoneFormat(e){return e.filter(e=>Se.isIntMobilePhone(e))}}Ce.BASE_API_URL="https://api.smsmode.com/http/1.6/",Ce.MESSAGE_MAX_LENGTH=150;const be=require("path"),Re=require("mustache"),De=require("fs");const Ne=(e,t)=>{return i=void 0,r=void 0,n=function*(){for(let i=0;i<e.length;i++)yield t(e[i])},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{c(n.next(e))}catch(e){t(e)}}function s(e){try{c(n.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(o,s)}c((n=n.apply(i,r||[])).next())});var i,r,a,n},we=e=>new Promise(t=>setTimeout(t,e)),Le=require("color-name");class Oe{static code(e){null==e&&(e=6);let t="";for(;t.length<e;)t+=Oe.symbolUpperCases[Oe.int(0,Oe.symbolUpperCases.length-1)];return t}static color(e=1){const t=Oe.rgbToHex(Math.round(255*e)),i="#000000"+t,r=Object.values(Le);if(0===r.length)return i;const a=r[Oe.int(0,r.length-1)];return 3!==a.length?i:"#"+Oe.rgbToHex(a[0])+Oe.rgbToHex(a[1])+Oe.rgbToHex(a[2])+t}static rgbToHex(e){const t=e.toString(16);return 1===t.length?"0"+t:t}static int(e,t){return null==e&&(e=0),null==t&&(t=Number.POSITIVE_INFINITY),e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}static password(e){null==e&&(e=8);let t="";for(;t.length<e;)switch(Oe.int(1,3)){case 1:t+=Oe.symbolUpperCases[Oe.int(0,Oe.symbolUpperCases.length-1)];break;case 2:t+=Oe.symbolLowerCases[Oe.int(0,Oe.symbolLowerCases.length-1)];break;default:t+=String(Oe.int(0,9))}return t}}Oe.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],Oe.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"];var ke=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class Be{dirPath(e){const t=be.resolve(e).lastIndexOf(be.sep);return t<0?e:be.resolve(be.resolve(e).substr(0,t+1))+be.sep}listFiles(e){return ke(this,void 0,void 0,function*(){if(!this.isDir(e))throw new J(String(e)+" does not exist or is not a directory");const t=e.endsWith("/")?"":"/",i=De.readdirSync(e),r=[];return yield Ne(i,i=>ke(this,void 0,void 0,function*(){this.isFile(e+t+i)&&r.push(e+t+i)})),r})}randomFile(e,t){return ke(this,void 0,void 0,function*(){const i=yield this.listFiles(e);if(0===i.length)return;let r;return r=void 0!==t?Math.max(t,0)%i.length:Oe.int(0,i.length-1),i[r]})}move(e,t){return ke(this,void 0,void 0,function*(){if(!this.isFile(e))throw new J(String(e)+" does not exist or is not a file");if(De.mkdirSync(t,{recursive:!0}),!this.isDir(t))throw new J(String(t)+" does not exist or is not a directory");return De.renameSync(e,t+be.basename(e))})}read(e){return ke(this,void 0,void 0,function*(){if(!this.isFile(e))throw new J(String(e)+" does not exist or is not a file");return De.readFileSync(e,"utf8")})}readJson(e){return ke(this,void 0,void 0,function*(){const t=yield this.read(e);if(!this.isJson(t))throw new J(String(e)+" does not contain JSON");return JSON.parse(t)})}readJsonFiles(e){return ke(this,void 0,void 0,function*(){if(!this.isDir(e))throw new J(String(e)+" does not exist or is not a directory");const t=e.endsWith("/")?"":"/",i=De.readdirSync(e),r=[];return yield Ne(i,i=>ke(this,void 0,void 0,function*(){this.isFile(e+t+i)&&i.endsWith(".json")&&r.push({name:i,data:yield this.readJson(e+t+i)})})),r})}write(e,t){return ke(this,void 0,void 0,function*(){let i="";return i="string"==typeof t||"number"==typeof t?String(t):JSON.stringify(t),De.mkdirSync(this.dirPath(e),{recursive:!0}),De.writeFileSync(e,i,{encoding:"utf8"}),Promise.resolve()})}writeJson(e,t){return ke(this,void 0,void 0,function*(){return this.write(e,JSON.stringify(t))})}isDir(e){return De.existsSync(e)&&De.statSync(e).isDirectory()}isFile(e){return De.existsSync(e)&&De.statSync(e).isFile()}isJson(e){try{return JSON.parse(e),!0}catch(e){return!1}}}const Ue=require("clean-css");var Ie=i.n(Ue);const Ge=require("html-minifier-terser");var xe=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class He{css(e){return xe(this,void 0,void 0,function*(){return new(Ie())({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(e).styles})}html(e){return xe(this,void 0,void 0,function*(){return yield(0,Ge.minify)(e,{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})})}}var Ke=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class Fe{constructor(){this.minifier=new He}render(e,t,i){return Ke(this,void 0,void 0,function*(){e.endsWith(".template")||(e+=".template");const r=(0,j.cloneDeep)(t),a=be.isAbsolute(e)?"":__dirname+be.sep,n=new Be,o=yield n.read(a+e),s=[];(0,Re.parse)(o).forEach(e=>{e.length>=4&&"&"===e[0]&&e[1].startsWith("include:")&&s.push(e[1])}),s.length>0&&(void 0===i?i=be.dirname(a+e)+be.sep:be.isAbsolute(i)||(i=a+i),yield Ne(s,e=>Ke(this,void 0,void 0,function*(){const t=e.split(":");if(3===t.length&&void 0!==r[e]){const a=t[2];i.includes("/html")&&Object.keys(r[e]).forEach(t=>{r[e][t]=Array.isArray(r[e][t])?r[e][t].map(e=>e.replace(/(?:\r\n|\r|\n)/g,"<br>")):r[e][t].replace(/(?:\r\n|\r|\n)/g,"<br>")}),r[e]=yield this.render(be.resolve(i,a),r[e])}})));const c=(0,Re.render)(o,r);if(c.includes("{{")||c.includes("}}"))throw new z("template: missing data to render template",{templatePath:e,data:t});return e.includes("html")?this.minifier.html(c):c})}}const je=require("node-mailjet");var Ve=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class qe{constructor(e,t,i){this.templateEngine=new Fe,this.mailjet=new je.Client({apiKey:e,apiSecret:t}),this.mode=i}sendDeliveryDelay(e,t,i){return Ve(this,void 0,void 0,function*(){return yield P.request(()=>Ve(this,void 0,void 0,function*(){void 0===i.base.copyright&&(i.base.copyright={year:String((new Date).getUTCFullYear())});const r=yield this.templateEngine.render("data/email/template/deliveryDelay",i,"data/email/element/text"),a=yield this.templateEngine.render("data/email/template/deliveryDelay",i,"data/email/element/html");return yield this.sendNotification(e,[{recipient:t,subject:i.base.subject,text:r,html:a}],!1)}),0,T.error.bind(T))})}sendTrackDelivery(e,t,i){return Ve(this,void 0,void 0,function*(){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const r=yield this.templateEngine.render("data/email/template/trackDelivery",i,"data/email/element/text"),a=yield this.templateEngine.render("data/email/element/text/index",{content:r,base:i.base}),n=yield this.templateEngine.render("data/email/template/trackDelivery",i,"data/email/element/html"),o=yield this.templateEngine.render("data/email/element/html/index",{content:n,base:i.base});return yield this.sendNotification(e,[{recipient:t,subject:i.base.subject,text:a,html:o}],!1)}),0,T.error.bind(T))})}sendUserNotification(e,t,i){return Ve(this,arguments,void 0,function*(e,t,i,r=!0,a){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const n=yield this.templateEngine.render("data/email/template/userNotification",i,"data/email/element/text"),o=yield this.templateEngine.render("data/email/element/text/index",{content:n,base:i.base,isCommercial:r}),s=yield this.templateEngine.render("data/email/template/userNotification",i,"data/email/element/html"),c=yield this.templateEngine.render("data/email/element/html/index",{content:s,base:i.base,isCommercial:r});return yield this.sendNotification(e,[{recipient:t,subject:i.base.subject,text:o,html:c}],r,a)}),0,T.error.bind(T))})}sendUsersNotifications(e,t,i,r){return Ve(this,void 0,void 0,function*(){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const a=[];return yield Ne(t,e=>Ve(this,void 0,void 0,function*(){const t=yield this.templateEngine.render("data/email/template/userNotification",e.data,"data/email/element/text"),r=yield this.templateEngine.render("data/email/element/text/index",{content:t,base:e.data.base,isCommercial:i}),n=yield this.templateEngine.render("data/email/template/userNotification",e.data,"data/email/element/html"),o=yield this.templateEngine.render("data/email/element/html/index",{content:n,base:e.data.base,isCommercial:i});a.push({recipient:e.recipient,subject:e.data.base.subject,text:r,html:o})})),yield this.sendNotification(e,a,i,r)}),0,T.error.bind(T))})}sendDiscount(e,t,i){return Ve(this,arguments,void 0,function*(e,t,i,r=!0,a){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const n=yield this.templateEngine.render("data/email/template/discount",i,"data/email/element/text"),o=yield this.templateEngine.render("data/email/element/text/index",{content:n,base:i.base,isCommercial:r}),s=yield this.templateEngine.render("data/email/template/discount",i,"data/email/element/html"),c=yield this.templateEngine.render("data/email/element/html/index",{content:s,base:i.base,isCommercial:r});return yield this.sendNotification(e,[{recipient:t,subject:i.base.subject,text:o,html:c}],r,a)}),0,T.error.bind(T))})}sendDiscounts(e,t){return Ve(this,arguments,void 0,function*(e,t,i=!0,r){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const a=[];return yield Ne(t,e=>Ve(this,void 0,void 0,function*(){const t=yield this.templateEngine.render("data/email/template/discount",e.data,"data/email/element/text"),r=yield this.templateEngine.render("data/email/element/text/index",{content:t,base:e.data.base,isCommercial:i}),n=yield this.templateEngine.render("data/email/template/discount",e.data,"data/email/element/html"),o=yield this.templateEngine.render("data/email/element/html/index",{content:n,base:e.data.base,isCommercial:i});a.push({recipient:e.recipient,subject:e.data.base.subject,text:r,html:o})})),yield this.sendNotification(e,a,i,r)}),0,T.error.bind(T))})}sendNotification(e,t){return Ve(this,arguments,void 0,function*(e,t,i=!1,r){if(0===t.length)throw new J("email: missing messages");try{if(this.mode===E.TEST)T.info("Simulation Mode: Email has been sent",{sender:e,recipients:t.map(e=>e.recipient)});else{const a=[];yield Ne(t,t=>Ve(this,void 0,void 0,function*(){this.mode===E.DEVELOPMENT&&(t.recipient.contact="developer@onylab.com"),a.push({From:{Name:e.name,Email:e.contact},To:[{Name:t.recipient.name,Email:t.recipient.contact}],Subject:t.subject,TextPart:t.text,HTMLPart:t.html,Priority:i?0:2,customID:void 0===r?void 0:String(r)})})),yield this.mailjet.post("send",{version:"v3.1"}).request({Messages:a})}}catch(e){throw new p(e.message,Number(e.statusCode))}})}}var Ze=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class We{constructor(e,t){this.filesystem=new Be,void 0!==We.root&&We.root===e||(We.root=e,We.config=void 0);const i=void 0===t?y.getMode():t;void 0!==We.environment&&We.environment===i||(We.environment=void 0===t?y.getMode():t,We.config=void 0)}full(){return Ze(this,void 0,void 0,function*(){return yield this.init(),We.config})}init(){return Ze(this,void 0,void 0,function*(){if(void 0===We.config)if(void 0===We.root)We.config={};else if(We.config=yield this.filesystem.readJson(We.root+"data/config.json"),[E.DEVELOPMENT,E.TEST].includes(We.environment))try{We.config=(0,j.merge)(We.config,yield this.filesystem.readJson(We.root+"data/config_"+String(We.environment)+".json"))}catch(e){}})}}const Je=require("typeorm");var Ye=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class ze{constructor(e){this.root=e}connect(e,t){return Ye(this,void 0,void 0,function*(){void 0===this.db&&(yield this.init());const i=this.db[e];void 0!==i?(i.entities=t,i.logging=["error"],i.logger=!0,i.bigNumberStrings=!1,void 0===i.timezone&&(i.timezone="Z"),void 0===i.charset&&(i.charset="UTF8_GENERAL_CI"),this.connection=yield(0,Je.createConnection)(i)):T.error(new J("bad connection name"))})}synchronize(){return Ye(this,void 0,void 0,function*(){void 0!==this.connection&&(yield this.connection.synchronize())})}close(){return Ye(this,void 0,void 0,function*(){return this.connection.close()})}init(){return Ye(this,void 0,void 0,function*(){if(void 0===this.root)this.db={};else{const e=new Be;this.db=yield e.readJson(this.root+"data/db.json")}})}}const Xe=require("prettyjson");class Qe{error(e){T.error(e)}info(e){T.trace(e)}json(e){T.trace(Xe.render(e,{}))}success(e){T.trace(e)}}class $e{constructor(){this.fileSystem=new Be}image(e,t,i){return r=this,a=void 0,o=function*(){void 0===i&&(i=ne.randomBytes(20).toString("hex")+be.extname(e)),yield this.fileSystem.write(t+be.sep+i,"");const r=be.resolve(t+be.sep+i),a=De.createWriteStream(r);return(yield A()({url:e,method:"GET",responseType:"stream"})).data.pipe(a),new Promise((e,t)=>{a.on("finish",()=>e(r)),a.on("error",t)})},new((n=void 0)||(n=Promise))(function(e,t){function i(e){try{c(o.next(e))}catch(e){t(e)}}function s(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n(function(e){e(r)})).then(i,s)}c((o=o.apply(r,a||[])).next())});var r,a,n,o}}const et=require("fast-diff");var tt=i.n(et);class it{static escapeRegExp(e){return"string"!=typeof e?e:e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}static hash(e,t=0){let i=3735928559^t,r=1103547991^t;for(let t,a=0;a<e.length;a++)t=e.charCodeAt(a),i=Math.imul(i^t,2654435761),r=Math.imul(r^t,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),(r>>>0).toString(16).padStart(8,"0")+(i>>>0).toString(16).padStart(8,"0")}static nullable(e){return S(e)||"string"==typeof e&&0===e.length?null:e}static removeMultiSpaces(e){return"string"!=typeof e?e:e.replace(/\s{2,}/g," ")}static removeText(e,t){if("string"!=typeof e||"string"!=typeof t||0===t.length)return e;try{e=(e=e.replace(new RegExp(it.escapeRegExp(t),"ig"),"")).replace(new RegExp(it.escapeRegExp(t).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(e){}return e}static replace(e,t,i){if("string"!=typeof e)return e;if(t.length!==i.length)return e;let r=e;return t.forEach((e,t)=>{r=r.replace(new RegExp(it.escapeRegExp(e),"ig"),i[t])}),r}static slugify(e,t=""){return void 0===e?"":(0,j.toLower)((0,j.trim)((0,j.deburr)(e)).replace(/[^0-9a-z\-\_]/gi,t))}static truncate(e,t){return S(e)||e.length<=t?e:t<=3?"":e.slice(0,t-3)+"..."}}const rt=require("emoji-regex");var at=i.n(rt);class nt{static trim(e){return"string"==typeof e?e.trim():e}static capitalize(e){const t=nt.lower(e);return"string"==typeof t?t.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):e}static ucfirst(e){const t=nt.lower(e);return"string"==typeof t?t.charAt(0).toUpperCase()+t.slice(1):e}static lower(e){return"string"==typeof e?e.toLocaleLowerCase():e}static upper(e){return"string"==typeof e?e.toLocaleUpperCase():e}static phone(e,t,i="int"){if("string"==typeof e)switch(e=nt.preformatPhone(e,t),i){case"nat":return nt.phoneNat(e,t);case"int":return nt.phoneInt(e,t)}return e}static stripEmoji(e){let t=e;if("string"==typeof t){let e;for(;null!==(e=at()().exec(t));)try{t=t.replace(new RegExp(it.escapeRegExp(e[0]),"g"),""),t=t.replace(new RegExp("\\s+","g")," "),t=t.trim()}catch(e){}}return t}static stripExoticCharacters(e){return"string"==typeof e?e.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):e}static preformatPhone(e,t){return e=e.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===t&&new RegExp("^[1-9]").test(e)&&9===e.length?"0"+e:e}static phoneNat(e,t){if("fr"===t){if(e.startsWith("+330")?e=e.substring(3):e.startsWith("+33")?e="0"+e.substring(3):e.startsWith("0033")?e="0"+e.substring(4):e.startsWith("33")&&11===e.length&&(e="0"+e.substring(2)),10===e.length){let t=0;e=e.split("").map(e=>(t++,e+(t%2==0?" ":""))).join("").trim()}return e}return e}static phoneInt(e,t){return e.startsWith("+")?e:"fr"===t?(e.startsWith("0")&&(e=e.substring(1)),"+33"+e):e}}class ot{static autoCorrectCity(e){if(S(e)||"string"!=typeof e||0===e.length)return e;(e.toLowerCase().startsWith("st-")||e.toLowerCase().startsWith("st "))&&(e="Saint "+e.substring(3));const t=Object.values(ot.ZIPCODE_CITY).flat(),i=t.find(t=>t.toLowerCase()===e.toLowerCase());if(void 0!==i)return i;const r=t.find(t=>{const i=ot.countDiff(e,t);return i.add<=2&&i.remove<=2});if(void 0!==r)return r;const a=t.find(t=>t.replace(/-/g," ").toLowerCase()===e.toLowerCase());if(void 0!==a)return a;const n=t.find(t=>{const i=ot.countDiff(e,t.replace(/-/g," "));return i.add<=2&&i.remove<=2});if(void 0!==n)return n;const o=t.find(t=>t.toLowerCase().startsWith(e.toLowerCase()));if(void 0!==o)return o;const s=t.find(t=>e.toLowerCase().includes(t.toLowerCase()));return void 0!==s?s:e}static autoCorrectStreet(e){if(S(e)||"string"!=typeof e||0===e.length)return e;ot.STREET_TYPE.forEach(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)+" "))});const t=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(e);return null!==t&&2===t.length&&(e=e.substring(t[1].length)),ot.STREET_TYPE.forEach(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}static getZipCodeFromCity(e){if(!S(e))return Object.keys(ot.ZIPCODE_CITY).reduce((t,i)=>void 0!==ot.ZIPCODE_CITY[i].find(t=>t.toLowerCase()===e.toLowerCase())?i:t,void 0)}static getCityFromZipCode(e,t){if(void 0===e||void 0===t)return;const i=ot.ZIPCODE_CITY[e];if(void 0===i)return;if(1===i.length)return i[0];let r;return t.split(",").forEach(e=>{r=i.find(t=>e.trim().toLowerCase()===t.trim().toLowerCase())}),void 0!==r?r:i[0]}static isZipCode(e){return"string"==typeof e&&(!!Object.keys(ot.ZIPCODE_CITY).includes(e)||Se.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))}static parse(e,t=!0){const i={};if(!S(e)){const r=e.split(",");if(r.length>=3&&t){void 0===ot.COUNTRIES.find(t=>e.toLowerCase().includes(" "+t.toLowerCase()))&&r.push("France");let t=r.length-1;if(i.country=r[t].trim(),r.splice(t--,1),void 0!==r[t]&&r[t].trim().includes(" ")){const e=r[t].trim().split(" ");i.zip=void 0===e[0]?void 0:e[0].trim(),e.splice(0,1),i.city=e.join(" ").trim(),r.splice(t--,1)}else isNaN(Number(r[t].trim()))?isNaN(Number(r[t-1].trim()))?(i.city=r[t].trim(),r.splice(t--,1)):(i.city=r[t].trim(),r.splice(t--,1),i.zip=r[t].trim(),r.splice(t--,1)):(i.zip=r[t].trim(),r.splice(t--,1),t>=2&&(i.city=r[t].trim(),r.splice(t--,1)));i.street=r.map(e=>e.trim()).join(" ").trim()}else{let t=e.toLowerCase();Object.keys(ot.ZIPCODE_CITY).forEach(e=>{if(t.includes(e)){i.zip=e;try{t=t.replace(new RegExp(it.escapeRegExp(e),"ig"),"")}catch(e){}}}),Object.values(ot.ZIPCODE_CITY).flat().forEach(e=>{var r;if(t.includes(e.toLowerCase())&&(void 0===i.zip||(null===(r=ot.ZIPCODE_CITY[i.zip])||void 0===r?void 0:r.find(t=>t.toLowerCase()===e.toLowerCase())))){i.city=e;try{t=t.replace(new RegExp(it.escapeRegExp(e),"ig"),"")}catch(e){}}}),ot.COUNTRIES.forEach(e=>{if(t.includes(" "+e.toLowerCase())&&!t.includes("de "+e.toLowerCase())&&!t.includes("de la "+e.toLowerCase())){i.country=e;try{t=t.replace(new RegExp(it.escapeRegExp(" "+e),"ig"),"")}catch(e){}}}),void 0===i.street&&(i.street=(0,j.trim)(t.split(",").map(e=>e.trim()).join(" "),"-").trim())}void 0===i.country&&(i.country="France")}return void 0!==i.street&&(i.street=nt.lower(nt.trim(String(i.street)))),void 0!==i.zip&&(i.zip=nt.upper(nt.trim(String(i.zip)))),void 0!==i.city&&(i.city=ot.autoCorrectCity(nt.capitalize(nt.trim(String(i.city))))),void 0!==i.country&&(i.country=nt.capitalize(nt.trim(String(i.country)))),ot.complete(i)}static complete(e){if(void 0===e.city||0===e.city.length){const t=ot.getCityFromZipCode(e.zip,e.street);void 0!==t&&(e.city=t)}return"string"==typeof e.street&&ot.REGIONS.forEach(t=>{e.street=it.removeText(e.street,t).trim()}),"fr"===nt.lower(e.country)&&(e.country="France"),e}static removeDuplicates(e){if("string"!=typeof e)return e;const t=[];return e.split(",").forEach(e=>{void 0===t.find(t=>t.trim().toLowerCase().includes(e.trim().toLowerCase()))&&t.push(e)}),t.join(",")}static countDiff(e,t){const i={add:0,remove:0};return tt()(e.toLowerCase(),t.toLowerCase()).forEach(e=>{switch(e[0]){case-1:i.remove+=e[1].length;break;case 1:i.add+=e[1].length}}),i}}ot.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"]},ot.REGIONS=["île-de-france"],ot.COUNTRIES=["France","FR"],ot.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"}];class st{static getCycleDateFromFullDate(e,t){if("weekly"===t){const t=ve.DateTime.fromISO(e.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===t)return e;const i=t.split("-");return i.length>2?i[0]+"-"+i[1]:i.join("-")}return"monthly"===t?ve.DateTime.fromISO(e).toFormat("yyyy-LL"):ve.DateTime.fromISO(e).toISODate()}static displayWeekDay(e){let t="";return void 0!==st.WEEK_DAYS[e]&&(t=st.WEEK_DAYS[e]),t}static generatePeriod(e,t,i,r=!0,a=st.PERIOD_MAX_DATES,n="daily"){const o={daily:{day:1},weekly:{week:1},monthly:{month:1}}[n];let s=ve.DateTime.fromISO(e,{setZone:!0}).toISODate();const c=ve.DateTime.fromISO(t,{setZone:!0}).toISODate();let l=0;const u={};for(;s<=c&&l<a;){const e=st.getCycleDateFromFullDate(s,n);u[e]=(0,j.cloneDeep)(i),r&&(u[e].date=e),s=ve.DateTime.fromISO(s,{setZone:!0}).plus(o).toISODate(),l++}return u}static getOpenPeriods(e,t){const i=[];return e.forEach(e=>{const r=[e];for(;r.length>0;){const e=r[0];if(void 0===t.find(t=>t.from<=e.from&&e.to<=t.to)){const a=t.find(t=>t.from<=e.from&&e.from<t.to&&t.to<e.to);if(void 0!==a)r.push({from:a.to,to:e.to});else{const a=t.find(t=>e.from<t.from&&e.to>t.from&&e.to<=t.to);if(void 0!==a)r.push({from:e.from,to:a.from});else{const a=t.find(t=>e.from<t.from&&t.to<e.to);void 0!==a?(r.push({from:e.from,to:a.from}),r.push({from:a.to,to:e.to})):i.push(e)}}}r.shift()}}),i}static limitDate(e,t,i=0){if(void 0===e||void 0===t)return;const r=ve.DateTime.fromISO(e,{setZone:!0}).toISO(),a=ve.DateTime.fromISO(t,{setZone:!0}).plus({seconds:i}).toISO();return r>a?a:r}static localeToISO(e){const t=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),i=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),r=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");let a;if(t.test(e)){const t=e.split("/");a=t[2]+"-"+t[1]+"-"+t[0]}else if(i.test(e)){const t=e.split("-");a=t[2]+"-"+t[1]+"-"+t[0]}else r.test(e)&&(a=e);return a}static slotToTime(e){const t=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),i=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");let r;return e=e.trim(),t.test(e)?r=e.trim()+":00":i.test(e)&&(r=e.split("-")[0].trim()+":00"),r}static delay(e,t,i){return S(e)||S(t)?0:Math.round(Math.abs(ve.DateTime.fromISO(e,{setZone:!0}).toUTC().diff(ve.DateTime.fromISO(t,{setZone:!0}).toUTC(),[i])[i]))}static round(e,t=0){if("string"!=typeof e)return e;const i=ve.DateTime.fromISO(e,{setZone:!0});return ve.DateTime.fromMillis(Math.round(+i.toMillis()/t)*t).setZone(i.zone).toISO()}static min(e){return e.reduce((e,t)=>"string"!=typeof e||e>t?t:e,void 0)}static max(e){return e.reduce((e,t)=>void 0===e||e<t?t:e,void 0)}}st.PERIOD_MAX_DATES=90,st.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"};class ct{static phone(e,t){if("string"==typeof e&&(e=e.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===t)){const t=new RegExp("(0[6-7][0-9]{8})","i").exec(e);if(null!==t&&t.length>0&&null!==t[0])return t[0]}}}class lt{static applyTaxes(e,t,i=2){let r=Number(e);return t.forEach(t=>{r+=Number(e)*t}),String(H.round(r,i))}static calculateTaxes(e,t){let i=0;return t.forEach(t=>{i+=e*t}),H.round(i,2)}static displayWithCurrency(e,t){if(null==e)return e;const i=lt.currencies[t];let r=e+" "+t;if(void 0!==i)switch(i.position){case"before":r=i.symbol+e;break;case"after":r=e+i.symbol}return r}static format(e,t,i=2){if(null==e)return e;const r=Number(e.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:i,maximumFractionDigits:i});switch(t){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}}static round(e,t=.1){const i=100*Number(e),r=100*t,a=i%r;return String(H.round(i-a+(a<Math.ceil(r/2)?0:r),2)/100)}}return lt.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},r})());
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.SmilePlayerCommon=t():e.SmilePlayerCommon=t()}(global,()=>(()=>{"use strict";var e={69:e=>{e.exports=JSON.parse('[{"id":"3r4s3-1","name":"Paris","account":{"id":"3r4s3","name":"Bella Pizza","currency":"EUR"},"preparation_time":15,"order_acceptance":{"mode":"normal"}}]')},133:e=>{e.exports=JSON.parse('{"status":"new","private_ref":"fr:1679f128-4ff6-4a60-9fc2-7fe38af4f84d","service_type":"delivery","service_type_ref":null,"expected_time":"2021-11-07T17:17:22Z","customer_notes":"PAS DE COUVERTS","collection_code":"5645","items":[{"product_name":"LIP15","sku_ref":"LIP15","price":"3.50 EUR","quantity":1,"options":[]},{"product_name":"5VANI","sku_ref":"5VANI","price":"6.90 EUR","quantity":1,"options":[]},{"product_name":"TSQ2","sku_ref":"TSQ2","price":"13.50 EUR","quantity":1,"options":[{"option_list_name":"Options","name":"SUPP RACLETTE","ref":"SUPP RACLETTE","price":"1.00 EUR"}]},{"product_name":"SCES","sku_ref":"SCES","price":"10.50 EUR","quantity":1,"options":[]}],"deals":{},"discounts":[],"charges":[{"type":"delivery","name":"Delivery charge","ref":null,"price":"0.99 EUR"}],"payments":[{"type":"online","name":"Paid online","ref":null,"amount":"36.39 EUR"}],"customer":{"address_1":"6a Rue du Tire Pesseau, 21000 Dijon, France","city":"Dijon","postal_code":"21000","phone":"+33175858334","delivery_notes":"Phone access code: 151081499","first_name":"Benoit","last_name":"B.","email":"orders@deliveroo.com","latitude":"47.3166297697847","longitude":"5.00251594930887"}}')},270:e=>{e.exports=JSON.parse('{"id":"87yu4","location_id":"3r4s3-1","name":"Web","created_at":"2020-06-25T11:43:51+02:00","data":{"variants":[],"categories":[],"products":[],"options_lists":[],"deals":[],"discounts":[],"charges":[]}}')},329:e=>{e.exports=JSON.parse('[{"id":"apm3s","name":"Online customers","created_at":"2020-06-25T11:43:51+02:00"},{"id":"s7ma5","name":"POS customers","created_at":"2020-05-19T13:23:10+02:00"}]')},616:e=>{e.exports=JSON.parse('[{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}},{"id":"asdf2","customer_list_id":"ag8u4","anonymised":false,"email":"charles.moore@dummy-mail.org","first_name":"Charles","last_name":"Moore","phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}]')},660:e=>{e.exports=JSON.parse('{"id":"v6ap7","first_name":"Tom","last_name":"Jones","email":"tom.jones@dummy-mail.org","timezone":{"name":"Europe/Paris"},"locales":["fr-FR","en-US"]}')},762:e=>{e.exports=JSON.parse('[{"status":"new","private_ref":"fr:1679f128-4ff6-4a60-9fc2-7fe38af4f84d","service_type":"delivery","service_type_ref":null,"expected_time":"2021-11-07T17:17:22Z","customer_notes":"PAS DE COUVERTS","collection_code":"5645","items":[{"product_name":"LIP15","sku_ref":"LIP15","price":"3.50 EUR","quantity":1,"options":[]},{"product_name":"5VANI","sku_ref":"5VANI","price":"6.90 EUR","quantity":1,"options":[]},{"product_name":"TSQ2","sku_ref":"TSQ2","price":"13.50 EUR","quantity":1,"options":[{"option_list_name":"Options","name":"SUPP RACLETTE","ref":"SUPP RACLETTE","price":"1.00 EUR"}]},{"product_name":"SCES","sku_ref":"SCES","price":"10.50 EUR","quantity":1,"options":[]}],"deals":{},"discounts":[],"charges":[{"type":"delivery","name":"Delivery charge","ref":null,"price":"0.99 EUR"}],"payments":[{"type":"online","name":"Paid online","ref":null,"amount":"36.39 EUR"}],"customer":{"address_1":"6a Rue du Tire Pesseau, 21000 Dijon, France","city":"Dijon","postal_code":"21000","phone":"+33175858334","delivery_notes":"Phone access code: 151081499","first_name":"Benoit","last_name":"B.","email":"orders@deliveroo.com","latitude":"47.3166297697847","longitude":"5.00251594930887"}}]')},835:e=>{e.exports=JSON.parse('[{"id":"87yu4","name":"Web","created_at":"2020-06-25T11:43:51+02:00"},{"id":"sdm3b","name":"Common menu","created_at":"2020-05-19T13:23:10+02:00"}]')},851:e=>{e.exports=JSON.parse('{"id":"jdj9v","customer_list_id":"smpse3","anonymised":false,"private_ref":null,"email":"jimmy.watson@dummy-mail.org","first_name":"Jimmy","last_name":"Watson","gender":"male","birth_date":null,"created_at":"2020-01-18T17:12:02+02:00","company_name":null,"phone":"+44123456789","phone_access_code":"8888","address_1":"1 Town Road","address_2":null,"postal_code":"N9 0HL","city":"London","state":null,"country":"GB","latitude":"45.7571206","longitude":"4.8307575","delivery_notes":null,"sms_marketing":false,"email_marketing":true,"nb_orders":2,"order_total":"28.40 GBP","first_order_date":"2020-01-18T17:15:11+02:00","last_order_date":"2020-01-23T10:13:21+02:00","loyalty_cards":[{"id":"slp8q","ref":null,"name":null,"balance":"13.5"}],"custom_fields":{}}')}},t={};function i(r){var a=t[r];if(void 0!==a)return a.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,i),n.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};i.r(r),i.d(r,{Api:()=>a,Constant:()=>n,Exception:()=>o,Http:()=>s,Mockup:()=>c,Service:()=>l,Template:()=>u,Tool:()=>d,Util:()=>m});var a={};i.r(a),i.d(a,{HubriseApi:()=>x,HubriseAuthResource:()=>b,HubriseCatalogConverter:()=>F,HubriseCountryCode:()=>D,HubriseCurrencyCode:()=>N,HubriseEventType:()=>k,HubriseLanguageCode:()=>w,HubriseLocale:()=>L,HubriseOrderConverter:()=>q,HubriseOrderStatus:()=>U,HubrisePriceUtil:()=>K,HubriseResourceType:()=>B,HubriseRightAccess:()=>R,HubriseServiceType:()=>I,HubriseTimezoneId:()=>O,TotalHubriseCalculator:()=>Z});var n={};i.r(n),i.d(n,{Path:()=>W});var o={};i.r(o),i.d(o,{BadParameterException:()=>J,BadRequestException:()=>Y,ConflictException:()=>z,DuplicateException:()=>X,ExternalApiException:()=>h,InternalException:()=>Q,MainException:()=>p,NotImplementedException:()=>$,ObjectNotFoundException:()=>ee,PageNotFoundException:()=>te,UnauthorizedException:()=>v});var s={};i.r(s),i.d(s,{AuthenticationMiddleware:()=>re,AuthorizationMiddleware:()=>ae,HandlerController:()=>ie,Server:()=>he});var c={};i.r(c),i.d(c,{ApiMockup:()=>Ee,HubriseApiMockup:()=>ye});var l={};i.r(l),i.d(l,{EmailSenderService:()=>qe,SmsSenderService:()=>Ce});var u={};i.r(u),i.d(u,{TemplateEngine:()=>Fe});var d={};i.r(d),i.d(d,{Configuration:()=>We,Database:()=>ze,Displayer:()=>Qe,Downloader:()=>$e,Env:()=>E,Environment:()=>y,FileSystem:()=>Be,Logger:()=>T,Retry:()=>P});var m={};i.r(m),i.d(m,{AddressUtil:()=>ot,DateUtil:()=>st,ExtractorUtil:()=>ct,FormatterUtil:()=>nt,GeneratorUtil:()=>Oe,MathUtil:()=>H,ObjectUtil:()=>V,PriceUtil:()=>lt,StringUtil:()=>it,ValidatorUtil:()=>Se,asyncForEach:()=>Ne,isNullOrUndefined:()=>S,wait:()=>we});const _=require("axios");var A=i.n(_);class p extends Error{constructor(e,t,i){super(e),this.code=t,this.data=i,this.name="MainException","function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,p):this.stack=new Error(e).stack}}class h extends p{constructor(e,t){super(e,502,t),this.name="ExternalApiException"}}const f=require("@sentry/node"),g=require("@sentry/profiling-node");var E;!function(e){e.PRODUCTION="prod",e.DEVELOPMENT="dev",e.TEST="test"}(E||(E={}));class y{static getMode(){switch(process.env.NODE_ENV){case"dev":case"development":return E.DEVELOPMENT;case"prod":case"production":return E.PRODUCTION;case"test":return E.TEST}return void 0===process.env.APP_ID?E.DEVELOPMENT:E.PRODUCTION}}class v extends p{constructor(e,t){super(e,v.ERROR_CODE,t),this.name="UnauthorizedException"}}v.ERROR_CODE=401;const S=e=>null==e;class T{static init(e,t){if(y.getMode()===E.PRODUCTION){const i=0;f.init({dsn:e,integrations:[f.captureConsoleIntegration({levels:["error","warn","log"]}),(0,g.nodeProfilingIntegration)()],environment:y.getMode(),maxBreadcrumbs:50,tracesSampleRate:i,profilesSampleRate:i}),f.setupExpressErrorHandler(t)}}static trace(e,t){[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.info(e):console.info(e,JSON.stringify(t,null,2)):f.addBreadcrumb({category:"info",message:e,data:t,level:"info"})}static debug(e,t){[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.log(e):console.log(e,JSON.stringify(t,null,2)):f.addBreadcrumb({category:"debug",message:e,data:t,level:"debug"})}static info(e,t){[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.info(e):console.info(e,JSON.stringify(t,null,2)):f.withScope(i=>{void 0!==t&&i.setExtra("extra",JSON.stringify(t)),f.captureMessage(e)})}static warning(e,t){S(e.response)||("object"!=typeof t&&(t={}),t.requestErrorData=e.response.data),[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.warn(e):console.warn(e,JSON.stringify(t,null,2)):f.withScope(i=>{void 0!==t&&i.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&i.setExtra("data",JSON.stringify(e.data)),f.captureException(e)})}static error(e,t){[v.ERROR_CODE].includes(e.code)||(S(e.response)||("object"!=typeof t&&(t={}),t.requestErrorData=e.response.data),[E.DEVELOPMENT,E.TEST].includes(y.getMode())?void 0===t?console.error(e):console.error(e,JSON.stringify(t,null,2)):f.withScope(i=>{void 0!==t&&i.setExtra("extra",JSON.stringify(t)),void 0!==e.data&&i.setExtra("data",JSON.stringify(e.data)),f.captureException(e)}))}}const M=require("retry");class P{static request(e){return t=this,i=arguments,a=function*(e,t=2,i){const r=M.operation({retries:t,factor:1,minTimeout:0,maxTimeout:0,randomize:!1});return new Promise((t,a)=>{r.attempt(()=>{e().then(t).catch(e=>{r.retry(e)?"function"==typeof i&&i(e):a(e)})})})},new((r=void 0)||(r=Promise))(function(e,n){function o(e){try{c(a.next(e))}catch(e){n(e)}}function s(e){try{c(a.throw(e))}catch(e){n(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof r?i:new r(function(e){e(i)})).then(o,s)}c((a=a.apply(t,i||[])).next())});var t,i,r,a}}const C=require("querystring");var b,R,D,N,w,L,O,k,B,U,I,G=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class x{constructor(e){this.token=e}authorize(e,t,i,r,a){return G(this,void 0,void 0,function*(){return x.BASE_AUTH_URL+"authorize?"+(void 0!==e?"name="+String(e)+"&":"")+"redirect_uri="+String(a)+"&client_id="+t+"&scope="+String(i)+"["+String(Object.keys(r).reduce((e,t)=>e.concat(t+"."+String(r[t])),[]).join(","))+"],profile_with_email"})}getToken(e,t,i){return G(this,void 0,void 0,function*(){let r;return yield P.request(()=>G(this,void 0,void 0,function*(){const a=yield A().post(x.BASE_AUTH_URL+"token",C.stringify({code:i,client_id:e,client_secret:t}),{headers:{"Content-Type":"application/x-www-form-urlencoded"},timeout:x.TIMEOUT});if(void 0===a||void 0===a.data)throw new h("failed to get hubrise token");r=a.data}),1,T.error.bind(T)),r})}getUser(){return G(this,void 0,void 0,function*(){let e;return yield P.request(()=>G(this,void 0,void 0,function*(){const t=yield A().get(x.BASE_URL+"user",{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===t||void 0===t.data)throw new h("failed to retrieve hubrise user");e=t.data}),1,T.error.bind(T)),e})}getLocations(){return G(this,void 0,void 0,function*(){let e;return yield P.request(()=>G(this,void 0,void 0,function*(){const t=yield A().get(x.BASE_URL+"locations",{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===t||void 0===t.data)throw new h("failed to retrieve hubrise locations");e=t.data}),1,T.error.bind(T)),e})}createCustomer(e,t){return G(this,void 0,void 0,function*(){let i;return yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().post(x.BASE_URL+"customer_lists/"+String(e)+"/customers",t,{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to create hubrise customer");i=r.data}),1,T.error.bind(T)),i})}getCustomer(e,t){return G(this,void 0,void 0,function*(){let i;return yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().get(x.BASE_URL+"customer_lists/"+String(e)+"/customers/"+String(t),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to retrieve hubrise customer");i=r.data}),1,T.error.bind(T)),i})}getCustomers(e,t,i,r){return G(this,void 0,void 0,function*(){const a=new URLSearchParams;let n;return a.append("private_ref",t),a.append("email",i),a.append("phone",r),yield P.request(()=>G(this,void 0,void 0,function*(){const t=yield A().get(x.BASE_URL+"customer_lists/"+String(e)+"/customers?"+a.toString(),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===t||void 0===t.data)throw new h("failed to retrieve hubrise customers");n=t.data}),1,T.error.bind(T)),n})}getCustomerLists(e){return G(this,void 0,void 0,function*(){let t;return yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().get(x.BASE_URL+"locations/"+String(e)+"/customer_lists",{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to retrieve hubrise customer lists");t=i.data}),1,T.error.bind(T)),t})}createOrder(e,t){return G(this,void 0,void 0,function*(){let i;return yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().post(x.BASE_URL+"locations/"+String(e)+"/orders",t,{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to create hubrise order");i=r.data}),1,T.error.bind(T)),i})}getOrder(e,t){return G(this,void 0,void 0,function*(){let i;return yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().get(x.BASE_URL+"locations/"+String(e)+"/orders/"+String(t),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to retrieve hubrise order");i=r.data}),1,T.error.bind(T)),i})}getOrders(e){return G(this,arguments,void 0,function*(e,t=30){let i=[];return yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().get(x.BASE_URL+"locations/"+String(e)+"/orders?count="+String(t),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to retrieve hubrise orders");i=r.data}),1,T.error.bind(T)),i})}setOrderStatus(e,t,i){return G(this,void 0,void 0,function*(){yield P.request(()=>G(this,void 0,void 0,function*(){const r=yield A().patch(x.BASE_URL+"locations/"+String(e)+"/orders/"+String(t),{status:i},{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===r||void 0===r.data)throw new h("failed to update hubrise order status")}),1,T.error.bind(T))})}getCatalog(e){return G(this,void 0,void 0,function*(){let t;return yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().get(x.BASE_URL+"catalogs/"+String(e),{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to retrieve hubrise catalogs");t=i.data}),1,T.error.bind(T)),t})}getCatalogs(e){return G(this,void 0,void 0,function*(){let t=[];return yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().get(x.BASE_URL+"locations/"+String(e)+"/catalogs",{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to retrieve hubrise catalogs");t=i.data}),1,T.error.bind(T)),t})}createWebhook(e,t){return G(this,void 0,void 0,function*(){yield P.request(()=>G(this,void 0,void 0,function*(){const i=yield A().post(x.BASE_URL+"/callback",{url:e,events:t},{headers:{"X-Access-Token":this.token},timeout:x.TIMEOUT});if(void 0===i||void 0===i.data)throw new h("failed to create hubrise webhook")}),1,T.error.bind(T))})}}x.BASE_URL="http://api.hubrise.com/v1/",x.BASE_AUTH_URL="https://manager.hubrise.com/oauth2/v1/",x.TIMEOUT=15e3,function(e){e.ORDERS="orders",e.CUSTOMER_LIST="customer_list",e.CATALOG="catalog",e.INVENTORY="inventory",e.ALL_CUSTOMER_LISTS="all_customer_lists",e.ALL_CATALOG_LISTS="all_catalogs"}(b||(b={})),function(e){e.READ="read",e.WRITE="write"}(R||(R={})),function(e){e.AF="AF",e.AL="AL",e.DZ="DZ",e.AD="AD",e.AO="AO",e.AG="AG",e.AR="AR",e.AM="AM",e.AU="AU",e.AT="AT",e.AZ="AZ",e.BS="BS",e.BH="BH",e.BD="BD",e.BB="BB",e.BY="BY",e.BE="BE",e.BZ="BZ",e.BJ="BJ",e.BT="BT",e.BO="BO",e.BA="BA",e.BW="BW",e.BR="BR",e.BN="BN",e.BG="BG",e.BF="BF",e.BI="BI",e.CV="CV",e.KH="KH",e.CM="CM",e.CA="CA",e.CF="CF",e.TD="TD",e.CL="CL",e.CN="CN",e.CO="CO",e.KM="KM",e.CG="CG",e.CD="CD",e.CR="CR",e.CI="CI",e.HR="HR",e.CU="CU",e.CY="CY",e.CZ="CZ",e.DK="DK",e.DJ="DJ",e.DM="DM",e.DO="DO",e.TL="TL",e.EC="EC",e.EG="EG",e.SV="SV",e.GQ="GQ",e.ER="ER",e.EE="EE",e.SZ="SZ",e.ET="ET",e.FJ="FJ",e.FI="FI",e.FR="FR",e.GA="GA",e.GM="GM",e.GE="GE",e.DE="DE",e.GH="GH",e.GR="GR",e.GD="GD",e.GT="GT",e.GN="GN",e.GW="GW",e.GY="GY",e.HT="HT",e.VA="VA",e.HN="HN",e.HU="HU",e.IS="IS",e.IN="IN",e.ID="ID",e.IR="IR",e.IQ="IQ",e.IE="IE",e.IL="IL",e.IT="IT",e.JM="JM",e.JP="JP",e.JO="JO",e.KZ="KZ",e.KE="KE",e.KI="KI",e.XK="XK",e.KW="KW",e.KG="KG",e.LA="LA",e.LV="LV",e.LB="LB",e.LS="LS",e.LR="LR",e.LY="LY",e.LI="LI",e.LT="LT",e.LU="LU",e.MG="MG",e.MW="MW",e.MY="MY",e.MV="MV",e.ML="ML",e.MT="MT",e.MH="MH",e.MR="MR",e.MU="MU",e.MX="MX",e.FM="FM",e.MD="MD",e.MC="MC",e.MN="MN",e.ME="ME",e.MA="MA",e.MZ="MZ",e.MM="MM",e.NA="NA",e.NR="NR",e.NP="NP",e.NL="NL",e.NZ="NZ",e.NI="NI",e.NE="NE",e.NG="NG",e.KP="KP",e.MK="MK",e.NO="NO",e.OM="OM",e.PK="PK",e.PW="PW",e.PS="PS",e.PA="PA",e.PG="PG",e.PY="PY",e.PE="PE",e.PH="PH",e.PL="PL",e.PT="PT",e.QA="QA",e.RO="RO",e.RU="RU",e.RW="RW",e.KN="KN",e.LC="LC",e.VC="VC",e.WS="WS",e.SM="SM",e.ST="ST",e.SA="SA",e.SN="SN",e.RS="RS",e.SC="SC",e.SL="SL",e.SG="SG",e.SK="SK",e.SI="SI",e.SB="SB",e.SO="SO",e.ZA="ZA",e.KR="KR",e.SS="SS",e.ES="ES",e.LK="LK",e.SD="SD",e.SR="SR",e.SE="SE",e.CH="CH",e.SY="SY",e.TW="TW",e.TJ="TJ",e.TZ="TZ",e.TH="TH",e.TG="TG",e.TO="TO",e.TT="TT",e.TN="TN",e.TR="TR",e.TM="TM",e.TV="TV",e.UG="UG",e.UA="UA",e.AE="AE",e.GB="GB",e.US="US",e.UY="UY",e.UZ="UZ",e.VU="VU",e.VE="VE",e.VN="VN",e.YE="YE",e.ZM="ZM",e.ZW="ZW"}(D||(D={})),function(e){e.AED="AED",e.AFN="AFN",e.ALL="ALL",e.AMD="AMD",e.ANG="ANG",e.AOA="AOA",e.ARS="ARS",e.AUD="AUD",e.AWG="AWG",e.AZN="AZN",e.BAM="BAM",e.BBD="BBD",e.BDT="BDT",e.BGN="BGN",e.BHD="BHD",e.BIF="BIF",e.BMD="BMD",e.BND="BND",e.BOB="BOB",e.BOV="BOV",e.BRL="BRL",e.BSD="BSD",e.BTN="BTN",e.BWP="BWP",e.BYN="BYN",e.BZD="BZD",e.CAD="CAD",e.CDF="CDF",e.CHE="CHE",e.CHF="CHF",e.CHW="CHW",e.CLF="CLF",e.CLP="CLP",e.CNY="CNY",e.COP="COP",e.COU="COU",e.CRC="CRC",e.CUC="CUC",e.CUP="CUP",e.CVE="CVE",e.CZK="CZK",e.DJF="DJF",e.DKK="DKK",e.DOP="DOP",e.DZD="DZD",e.EGP="EGP",e.ERN="ERN",e.ETB="ETB",e.EUR="EUR",e.FJD="FJD",e.FKP="FKP",e.GBP="GBP",e.GEL="GEL",e.GHS="GHS",e.GIP="GIP",e.GMD="GMD",e.GNF="GNF",e.GTQ="GTQ",e.GYD="GYD",e.HKD="HKD",e.HNL="HNL",e.HRK="HRK",e.HTG="HTG",e.HUF="HUF",e.IDR="IDR",e.ILS="ILS",e.INR="INR",e.IQD="IQD",e.IRR="IRR",e.ISK="ISK",e.JMD="JMD",e.JOD="JOD",e.JPY="JPY",e.KES="KES",e.KGS="KGS",e.KHR="KHR",e.KMF="KMF",e.KPW="KPW",e.KRW="KRW",e.KWD="KWD",e.KYD="KYD",e.KZT="KZT",e.LAK="LAK",e.LBP="LBP",e.LKR="LKR",e.LRD="LRD",e.LSL="LSL",e.LYD="LYD",e.MAD="MAD",e.MDL="MDL",e.MGA="MGA",e.MKD="MKD",e.MMK="MMK",e.MNT="MNT",e.MOP="MOP",e.MRU="MRU",e.MUR="MUR",e.MVR="MVR",e.MWK="MWK",e.MXN="MXN",e.MXV="MXV",e.MYR="MYR",e.MZN="MZN",e.NAD="NAD",e.NGN="NGN",e.NIO="NIO",e.NOK="NOK",e.NPR="NPR",e.NZD="NZD",e.OMR="OMR",e.PAB="PAB",e.PEN="PEN",e.PGK="PGK",e.PHP="PHP",e.PKR="PKR",e.PLN="PLN",e.PYG="PYG",e.QAR="QAR",e.RON="RON",e.RSD="RSD",e.RUB="RUB",e.RWF="RWF",e.SAR="SAR",e.SBD="SBD",e.SCR="SCR",e.SDG="SDG",e.SEK="SEK",e.SGD="SGD",e.SHP="SHP",e.SLE="SLE",e.SOS="SOS",e.SRD="SRD",e.SSP="SSP",e.STN="STN",e.SVC="SVC",e.SYP="SYP",e.SZL="SZL",e.THB="THB",e.TJS="TJS",e.TMT="TMT",e.TND="TND",e.TOP="TOP",e.TRY="TRY",e.TTD="TTD",e.TWD="TWD",e.TZS="TZS",e.UAH="UAH",e.UGX="UGX",e.USD="USD",e.USN="USN",e.UYI="UYI",e.UYU="UYU",e.UZS="UZS",e.VED="VED",e.VEF="VEF",e.VND="VND",e.VUV="VUV",e.WST="WST",e.XAF="XAF",e.XCD="XCD",e.XDR="XDR",e.XOF="XOF",e.XPF="XPF",e.XSU="XSU",e.XUA="XUA",e.YER="YER",e.ZAR="ZAR",e.ZMW="ZMW",e.ZWL="ZWL"}(N||(N={})),function(e){e.AR="ar",e.DE="de",e.EN="en",e.ES="es",e.FR="fr",e.PT="pt"}(w||(w={})),function(e){e.EN_US="en-US",e.EN_GB="en-GB",e.EN_CA="en-CA",e.EN_AU="en-AU",e.EN_NZ="en-NZ",e.EN_ZA="en-ZA",e.FR_FR="fr-FR",e.FR_CA="fr-CA",e.FR_BE="fr-BE",e.FR_CH="fr-CH",e.ES_ES="es-ES",e.ES_MX="es-MX",e.ES_AR="es-AR",e.ES_CO="es-CO",e.ES_CL="es-CL",e.DE_DE="de-DE",e.DE_AT="de-AT",e.DE_CH="de-CH",e.IT_IT="it-IT",e.IT_CH="it-CH",e.PT_PT="pt-PT",e.PT_BR="pt-BR",e.NL_NL="nl-NL",e.NL_BE="nl-BE",e.SV_SE="sv-SE",e.NO_NO="no-NO",e.DA_DK="da-DK",e.FI_FI="fi-FI",e.IS_IS="is-IS",e.RU_RU="ru-RU",e.PL_PL="pl-PL",e.CS_CZ="cs-CZ",e.SK_SK="sk-SK",e.HR_HR="hr-HR",e.SR_RS="sr-RS",e.BG_BG="bg-BG",e.UK_UA="uk-UA",e.JA_JP="ja-JP",e.KO_KR="ko-KR",e.ZH_CN="zh-CN",e.ZH_TW="zh-TW",e.ZH_HK="zh-HK",e.TH_TH="th-TH",e.VI_VN="vi-VN",e.ID_ID="id-ID",e.MS_MY="ms-MY",e.AR_SA="ar-SA",e.AR_EG="ar-EG",e.AR_AE="ar-AE",e.HE_IL="he-IL",e.FA_IR="fa-IR",e.TR_TR="tr-TR",e.HI_IN="hi-IN",e.BN_BD="bn-BD",e.TA_IN="ta-IN",e.TE_IN="te-IN",e.UR_PK="ur-PK",e.EL_GR="el-GR",e.HU_HU="hu-HU",e.RO_RO="ro-RO",e.LT_LT="lt-LT",e.LV_LV="lv-LV",e.ET_EE="et-EE",e.SL_SI="sl-SI",e.MT_MT="mt-MT",e.SW_KE="sw-KE",e.AF_ZA="af-ZA",e.AM_ET="am-ET"}(L||(L={})),function(e){e.Africa_Abidjan="Africa/Abidjan",e.Africa_Algiers="Africa/Algiers",e.Africa_Bissau="Africa/Bissau",e.Africa_Cairo="Africa/Cairo",e.Africa_Casablanca="Africa/Casablanca",e.Africa_Ceuta="Africa/Ceuta",e.Africa_El_Aaiun="Africa/El_Aaiun",e.Africa_Johannesburg="Africa/Johannesburg",e.Africa_Juba="Africa/Juba",e.Africa_Khartoum="Africa/Khartoum",e.Africa_Lagos="Africa/Lagos",e.Africa_Maputo="Africa/Maputo",e.Africa_Monrovia="Africa/Monrovia",e.Africa_Nairobi="Africa/Nairobi",e.Africa_Ndjamena="Africa/Ndjamena",e.Africa_Sao_Tome="Africa/Sao_Tome",e.Africa_Tripoli="Africa/Tripoli",e.Africa_Tunis="Africa/Tunis",e.Africa_Windhoek="Africa/Windhoek",e.America_Adak="America/Adak",e.America_Anchorage="America/Anchorage",e.America_Araguaina="America/Araguaina",e.America_Argentina_Buenos_Aires="America/Argentina/Buenos_Aires",e.America_Argentina_Catamarca="America/Argentina/Catamarca",e.America_Argentina_Cordoba="America/Argentina/Cordoba",e.America_Argentina_Jujuy="America/Argentina/Jujuy",e.America_Argentina_La_Rioja="America/Argentina/La_Rioja",e.America_Argentina_Mendoza="America/Argentina/Mendoza",e.America_Argentina_Rio_Gallegos="America/Argentina/Rio_Gallegos",e.America_Argentina_Salta="America/Argentina/Salta",e.America_Argentina_San_Juan="America/Argentina/San_Juan",e.America_Argentina_San_Luis="America/Argentina/San_Luis",e.America_Argentina_Tucuman="America/Argentina/Tucuman",e.America_Argentina_Ushuaia="America/Argentina/Ushuaia",e.America_Asuncion="America/Asuncion",e.America_Bahia="America/Bahia",e.America_Bahia_Banderas="America/Bahia_Banderas",e.America_Barbados="America/Barbados",e.America_Belem="America/Belem",e.America_Belize="America/Belize",e.America_Boa_Vista="America/Boa_Vista",e.America_Bogota="America/Bogota",e.America_Boise="America/Boise",e.America_Cambridge_Bay="America/Cambridge_Bay",e.America_Campo_Grande="America/Campo_Grande",e.America_Cancun="America/Cancun",e.America_Caracas="America/Caracas",e.America_Cayenne="America/Cayenne",e.America_Chicago="America/Chicago",e.America_Chihuahua="America/Chihuahua",e.America_Ciudad_Juarez="America/Ciudad_Juarez",e.America_Costa_Rica="America/Costa_Rica",e.America_Coyhaique="America/Coyhaique",e.America_Cuiaba="America/Cuiaba",e.America_Danmarkshavn="America/Danmarkshavn",e.America_Dawson="America/Dawson",e.America_Dawson_Creek="America/Dawson_Creek",e.America_Denver="America/Denver",e.America_Detroit="America/Detroit",e.America_Edmonton="America/Edmonton",e.America_Eirunepe="America/Eirunepe",e.America_El_Salvador="America/El_Salvador",e.America_Fort_Nelson="America/Fort_Nelson",e.America_Fortaleza="America/Fortaleza",e.America_Glace_Bay="America/Glace_Bay",e.America_Goose_Bay="America/Goose_Bay",e.America_Grand_Turk="America/Grand_Turk",e.America_Guatemala="America/Guatemala",e.America_Guayaquil="America/Guayaquil",e.America_Guyana="America/Guyana",e.America_Halifax="America/Halifax",e.America_Havana="America/Havana",e.America_Hermosillo="America/Hermosillo",e.America_Indiana_Indianapolis="America/Indiana/Indianapolis",e.America_Indiana_Knox="America/Indiana/Knox",e.America_Indiana_Marengo="America/Indiana/Marengo",e.America_Indiana_Petersburg="America/Indiana/Petersburg",e.America_Indiana_Tell_City="America/Indiana/Tell_City",e.America_Indiana_Vevay="America/Indiana/Vevay",e.America_Indiana_Vincennes="America/Indiana/Vincennes",e.America_Indiana_Winamac="America/Indiana/Winamac",e.America_Inuvik="America/Inuvik",e.America_Iqaluit="America/Iqaluit",e.America_Jamaica="America/Jamaica",e.America_Juneau="America/Juneau",e.America_Kentucky_Louisville="America/Kentucky/Louisville",e.America_Kentucky_Monticello="America/Kentucky/Monticello",e.America_La_Paz="America/La_Paz",e.America_Lima="America/Lima",e.America_Los_Angeles="America/Los_Angeles",e.America_Maceio="America/Maceio",e.America_Managua="America/Managua",e.America_Manaus="America/Manaus",e.America_Martinique="America/Martinique",e.America_Matamoros="America/Matamoros",e.America_Mazatlan="America/Mazatlan",e.America_Menominee="America/Menominee",e.America_Merida="America/Merida",e.America_Metlakatla="America/Metlakatla",e.America_Mexico_City="America/Mexico_City",e.America_Miquelon="America/Miquelon",e.America_Moncton="America/Moncton",e.America_Monterrey="America/Monterrey",e.America_Montevideo="America/Montevideo",e.America_New_York="America/New_York",e.America_Nome="America/Nome",e.America_Noronha="America/Noronha",e.America_North_Dakota_Beulah="America/North_Dakota/Beulah",e.America_North_Dakota_Center="America/North_Dakota/Center",e.America_North_Dakota_New_Salem="America/North_Dakota/New_Salem",e.America_Nuuk="America/Nuuk",e.America_Ojinaga="America/Ojinaga",e.America_Panama="America/Panama",e.America_Paramaribo="America/Paramaribo",e.America_Phoenix="America/Phoenix",e.America_Port_au_Prince="America/Port-au-Prince",e.America_Porto_Velho="America/Porto_Velho",e.America_Puerto_Rico="America/Puerto_Rico",e.America_Punta_Arenas="America/Punta_Arenas",e.America_Rankin_Inlet="America/Rankin_Inlet",e.America_Recife="America/Recife",e.America_Regina="America/Regina",e.America_Resolute="America/Resolute",e.America_Rio_Branco="America/Rio_Branco",e.America_Santarem="America/Santarem",e.America_Santiago="America/Santiago",e.America_Santo_Domingo="America/Santo_Domingo",e.America_Sao_Paulo="America/Sao_Paulo",e.America_Scoresbysund="America/Scoresbysund",e.America_Sitka="America/Sitka",e.America_St_Johns="America/St_Johns",e.America_Swift_Current="America/Swift_Current",e.America_Tegucigalpa="America/Tegucigalpa",e.America_Thule="America/Thule",e.America_Tijuana="America/Tijuana",e.America_Toronto="America/Toronto",e.America_Vancouver="America/Vancouver",e.America_Whitehorse="America/Whitehorse",e.America_Winnipeg="America/Winnipeg",e.America_Yakutat="America/Yakutat",e.Antarctica_Casey="Antarctica/Casey",e.Antarctica_Davis="Antarctica/Davis",e.Antarctica_Macquarie="Antarctica/Macquarie",e.Antarctica_Mawson="Antarctica/Mawson",e.Antarctica_Palmer="Antarctica/Palmer",e.Antarctica_Rothera="Antarctica/Rothera",e.Antarctica_Troll="Antarctica/Troll",e.Antarctica_Vostok="Antarctica/Vostok",e.Asia_Almaty="Asia/Almaty",e.Asia_Amman="Asia/Amman",e.Asia_Anadyr="Asia/Anadyr",e.Asia_Aqtau="Asia/Aqtau",e.Asia_Aqtobe="Asia/Aqtobe",e.Asia_Ashgabat="Asia/Ashgabat",e.Asia_Atyrau="Asia/Atyrau",e.Asia_Baghdad="Asia/Baghdad",e.Asia_Baku="Asia/Baku",e.Asia_Bangkok="Asia/Bangkok",e.Asia_Barnaul="Asia/Barnaul",e.Asia_Beirut="Asia/Beirut",e.Asia_Bishkek="Asia/Bishkek",e.Asia_Chita="Asia/Chita",e.Asia_Colombo="Asia/Colombo",e.Asia_Damascus="Asia/Damascus",e.Asia_Dhaka="Asia/Dhaka",e.Asia_Dili="Asia/Dili",e.Asia_Dubai="Asia/Dubai",e.Asia_Dushanbe="Asia/Dushanbe",e.Asia_Famagusta="Asia/Famagusta",e.Asia_Gaza="Asia/Gaza",e.Asia_Hebron="Asia/Hebron",e.Asia_Ho_Chi_Minh="Asia/Ho_Chi_Minh",e.Asia_Hong_Kong="Asia/Hong_Kong",e.Asia_Hovd="Asia/Hovd",e.Asia_Irkutsk="Asia/Irkutsk",e.Asia_Jakarta="Asia/Jakarta",e.Asia_Jayapura="Asia/Jayapura",e.Asia_Jerusalem="Asia/Jerusalem",e.Asia_Kabul="Asia/Kabul",e.Asia_Kamchatka="Asia/Kamchatka",e.Asia_Karachi="Asia/Karachi",e.Asia_Kathmandu="Asia/Kathmandu",e.Asia_Khandyga="Asia/Khandyga",e.Asia_Kolkata="Asia/Kolkata",e.Asia_Krasnoyarsk="Asia/Krasnoyarsk",e.Asia_Kuching="Asia/Kuching",e.Asia_Macau="Asia/Macau",e.Asia_Magadan="Asia/Magadan",e.Asia_Makassar="Asia/Makassar",e.Asia_Manila="Asia/Manila",e.Asia_Nicosia="Asia/Nicosia",e.Asia_Novokuznetsk="Asia/Novokuznetsk",e.Asia_Novosibirsk="Asia/Novosibirsk",e.Asia_Omsk="Asia/Omsk",e.Asia_Oral="Asia/Oral",e.Asia_Pontianak="Asia/Pontianak",e.Asia_Pyongyang="Asia/Pyongyang",e.Asia_Qatar="Asia/Qatar",e.Asia_Qostanay="Asia/Qostanay",e.Asia_Qyzylorda="Asia/Qyzylorda",e.Asia_Riyadh="Asia/Riyadh",e.Asia_Sakhalin="Asia/Sakhalin",e.Asia_Samarkand="Asia/Samarkand",e.Asia_Seoul="Asia/Seoul",e.Asia_Shanghai="Asia/Shanghai",e.Asia_Singapore="Asia/Singapore",e.Asia_Srednekolymsk="Asia/Srednekolymsk",e.Asia_Taipei="Asia/Taipei",e.Asia_Tashkent="Asia/Tashkent",e.Asia_Tbilisi="Asia/Tbilisi",e.Asia_Tehran="Asia/Tehran",e.Asia_Thimphu="Asia/Thimphu",e.Asia_Tokyo="Asia/Tokyo",e.Asia_Tomsk="Asia/Tomsk",e.Asia_Ulaanbaatar="Asia/Ulaanbaatar",e.Asia_Urumqi="Asia/Urumqi",e.Asia_Ust_Nera="Asia/Ust-Nera",e.Asia_Vladivostok="Asia/Vladivostok",e.Asia_Yakutsk="Asia/Yakutsk",e.Asia_Yangon="Asia/Yangon",e.Asia_Yekaterinburg="Asia/Yekaterinburg",e.Asia_Yerevan="Asia/Yerevan",e.Atlantic_Azores="Atlantic/Azores",e.Atlantic_Bermuda="Atlantic/Bermuda",e.Atlantic_Canary="Atlantic/Canary",e.Atlantic_Cape_Verde="Atlantic/Cape_Verde",e.Atlantic_Faroe="Atlantic/Faroe",e.Atlantic_Madeira="Atlantic/Madeira",e.Atlantic_South_Georgia="Atlantic/South_Georgia",e.Atlantic_Stanley="Atlantic/Stanley",e.Australia_Adelaide="Australia/Adelaide",e.Australia_Brisbane="Australia/Brisbane",e.Australia_Broken_Hill="Australia/Broken_Hill",e.Australia_Darwin="Australia/Darwin",e.Australia_Eucla="Australia/Eucla",e.Australia_Hobart="Australia/Hobart",e.Australia_Lindeman="Australia/Lindeman",e.Australia_Lord_Howe="Australia/Lord_Howe",e.Australia_Melbourne="Australia/Melbourne",e.Australia_Perth="Australia/Perth",e.Australia_Sydney="Australia/Sydney",e.Etc_GMT="Etc/GMT",e.Etc_GMT_Minus_1="Etc/GMT-1",e.Etc_GMT_Minus_10="Etc/GMT-10",e.Etc_GMT_Minus_11="Etc/GMT-11",e.Etc_GMT_Minus_12="Etc/GMT-12",e.Etc_GMT_Minus_13="Etc/GMT-13",e.Etc_GMT_Minus_14="Etc/GMT-14",e.Etc_GMT_Minus_2="Etc/GMT-2",e.Etc_GMT_Minus_3="Etc/GMT-3",e.Etc_GMT_Minus_4="Etc/GMT-4",e.Etc_GMT_Minus_5="Etc/GMT-5",e.Etc_GMT_Minus_6="Etc/GMT-6",e.Etc_GMT_Minus_7="Etc/GMT-7",e.Etc_GMT_Minus_8="Etc/GMT-8",e.Etc_GMT_Minus_9="Etc/GMT-9",e.Etc_GMT_Plus_1="Etc/GMT+1",e.Etc_GMT_Plus_10="Etc/GMT+10",e.Etc_GMT_Plus_11="Etc/GMT+11",e.Etc_GMT_Plus_12="Etc/GMT+12",e.Etc_GMT_Plus_2="Etc/GMT+2",e.Etc_GMT_Plus_3="Etc/GMT+3",e.Etc_GMT_Plus_4="Etc/GMT+4",e.Etc_GMT_Plus_5="Etc/GMT+5",e.Etc_GMT_Plus_6="Etc/GMT+6",e.Etc_GMT_Plus_7="Etc/GMT+7",e.Etc_GMT_Plus_8="Etc/GMT+8",e.Etc_GMT_Plus_9="Etc/GMT+9",e.Etc_UTC="Etc/UTC",e.Europe_Andorra="Europe/Andorra",e.Europe_Astrakhan="Europe/Astrakhan",e.Europe_Athens="Europe/Athens",e.Europe_Belgrade="Europe/Belgrade",e.Europe_Berlin="Europe/Berlin",e.Europe_Brussels="Europe/Brussels",e.Europe_Bucharest="Europe/Bucharest",e.Europe_Budapest="Europe/Budapest",e.Europe_Chisinau="Europe/Chisinau",e.Europe_Dublin="Europe/Dublin",e.Europe_Gibraltar="Europe/Gibraltar",e.Europe_Helsinki="Europe/Helsinki",e.Europe_Istanbul="Europe/Istanbul",e.Europe_Kaliningrad="Europe/Kaliningrad",e.Europe_Kirov="Europe/Kirov",e.Europe_Kyiv="Europe/Kyiv",e.Europe_Lisbon="Europe/Lisbon",e.Europe_London="Europe/London",e.Europe_Madrid="Europe/Madrid",e.Europe_Malta="Europe/Malta",e.Europe_Minsk="Europe/Minsk",e.Europe_Moscow="Europe/Moscow",e.Europe_Paris="Europe/Paris",e.Europe_Prague="Europe/Prague",e.Europe_Riga="Europe/Riga",e.Europe_Rome="Europe/Rome",e.Europe_Samara="Europe/Samara",e.Europe_Saratov="Europe/Saratov",e.Europe_Simferopol="Europe/Simferopol",e.Europe_Sofia="Europe/Sofia",e.Europe_Tallinn="Europe/Tallinn",e.Europe_Tirane="Europe/Tirane",e.Europe_Ulyanovsk="Europe/Ulyanovsk",e.Europe_Vienna="Europe/Vienna",e.Europe_Vilnius="Europe/Vilnius",e.Europe_Volgograd="Europe/Volgograd",e.Europe_Warsaw="Europe/Warsaw",e.Europe_Zurich="Europe/Zurich",e.Indian_Chagos="Indian/Chagos",e.Indian_Maldives="Indian/Maldives",e.Indian_Mauritius="Indian/Mauritius",e.Pacific_Apia="Pacific/Apia",e.Pacific_Auckland="Pacific/Auckland",e.Pacific_Bougainville="Pacific/Bougainville",e.Pacific_Chatham="Pacific/Chatham",e.Pacific_Easter="Pacific/Easter",e.Pacific_Efate="Pacific/Efate",e.Pacific_Fakaofo="Pacific/Fakaofo",e.Pacific_Fiji="Pacific/Fiji",e.Pacific_Galapagos="Pacific/Galapagos",e.Pacific_Gambier="Pacific/Gambier",e.Pacific_Guadalcanal="Pacific/Guadalcanal",e.Pacific_Guam="Pacific/Guam",e.Pacific_Honolulu="Pacific/Honolulu",e.Pacific_Kanton="Pacific/Kanton",e.Pacific_Kiritimati="Pacific/Kiritimati",e.Pacific_Kosrae="Pacific/Kosrae",e.Pacific_Kwajalein="Pacific/Kwajalein",e.Pacific_Marquesas="Pacific/Marquesas",e.Pacific_Nauru="Pacific/Nauru",e.Pacific_Niue="Pacific/Niue",e.Pacific_Norfolk="Pacific/Norfolk",e.Pacific_Noumea="Pacific/Noumea",e.Pacific_Pago_Pago="Pacific/Pago_Pago",e.Pacific_Palau="Pacific/Palau",e.Pacific_Pitcairn="Pacific/Pitcairn",e.Pacific_Port_Moresby="Pacific/Port_Moresby",e.Pacific_Rarotonga="Pacific/Rarotonga",e.Pacific_Tahiti="Pacific/Tahiti",e.Pacific_Tarawa="Pacific/Tarawa",e.Pacific_Tongatapu="Pacific/Tongatapu"}(O||(O={})),function(e){e.CREATE="create",e.DELETE="delete",e.PATCH="patch",e.UPDATE="update"}(k||(k={})),function(e){e.CATALOG="catalog",e.CUSTOMER="customer",e.DELIVERY="delivery",e.INVENTORY="inventory",e.LOCATION="location",e.ORDER="order"}(B||(B={})),function(e){e.new="new",e.received="received",e.accepted="accepted",e.in_preparation="in_preparation",e.awaiting_shipment="awaiting_shipment",e.awaiting_collection="awaiting_collection",e.in_delivery="in_delivery",e.completed="completed",e.rejected="rejected",e.cancelled="cancelled",e.delivery_failed="delivery_failed"}(U||(U={})),function(e){e.DELIVERY="delivery",e.COLLECTION="collection",e.EAT_IN="eat_in"}(I||(I={}));class H{static sum(e){return 0===e.length?0:e.reduce((e,t)=>e+t,0)}static avg(e){const t=H.sum(e);return 0===t?0:H.round(t/e.length,2)}static applyVariation(e,t){let i;return i=e>=0?1+t/100:1-t/100,e*i}static median(e){if(0===e.length)return 0;if(1===e.length)return e[0];const t=e.sort((e,t)=>e-t);return t.length%2==0?H.avg([t[t.length/2-1],t[t.length/2]]):t[Math.floor(t.length/2)]}static percentage(e,t){if("number"==typeof e&&"number"==typeof t)return 0===t?0:e/t*100}static round(e,t){return"number"!=typeof e?e:0===t?Math.round(e):Math.round(e*Math.pow(10,t))/Math.pow(10,t)}static variation(e,t){let i=0;return 0!==t?i=0!==e?(t-e)/Math.abs(e)*100:100*(t>0?1:-1):0!==e&&(i=-100*(e>0?1:-1)),Math.floor(i)}}class K{static sum(e,t=N.EUR){var i;if(!Array.isArray(e)||0===e.length)return"0.00 "+String(t);if(1===e.length)return e[0];const r=e.map(e=>K.priceToAmount(e)).filter(e=>void 0!==e);if(0===r.length)return"0.00 "+String(t);const a=H.sum(r.map(e=>e.amount));return K.amountToPrice(a,null!==(i=r[0].currency)&&void 0!==i?i:t)}static multiply(e,t){if(S(e)||S(t))return;if(1===t)return e;const i=K.priceToAmount(e);return void 0!==i?K.amountToPrice(i.amount*t,i.currency):void 0}static priceToAmount(e){if(S(e))return;const t=e.split(" ");return 2===t.length?{amount:Number(t.slice(0,t.length-1).join("")),currency:t[t.length-1]}:void 0}static amountToPrice(e,t){return String(H.round(e,2).toFixed(2))+" "+String(t)}}class F{editableItems(e){var t;if(!Array.isArray(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.products))return{withRef:[],withName:[]};const i={};Array.isArray(e.data.categories)&&e.data.categories.forEach(e=>{i[e.id]=e.name});const r=e.data.products.map(e=>{var t,r,a;const n=null!==(t=e.ref)&&void 0!==t?t:1!==(null===(r=e.skus)||void 0===r?void 0:r.length)||Array.isArray(e.skus[0].option_list_ids)&&0!==e.skus[0].option_list_ids.length?null:e.skus[0].ref,o=1!==(null===(a=e.skus)||void 0===a?void 0:a.length)||Array.isArray(e.skus[0].option_list_ids)&&0!==e.skus[0].option_list_ids.length?K.multiply(e.skus[0].price,0):e.skus[0].price;return{id:e.id,sku_ref:n,category_name:i[e.category_id],product_name:e.name,quantity:1,tax_rate:e.tax_rate,price:o}}).sort((e,t)=>{var i,r,a,n;return(null===(i=e.category_name)||void 0===i?void 0:i.localeCompare(null!==(r=t.category_name)&&void 0!==r?r:""))||(null===(a=e.name)||void 0===a?void 0:a.localeCompare(null!==(n=t.name)&&void 0!==n?n:""))});return{withRef:r.filter(e=>void 0!==e.sku_ref&&null!==e.sku_ref),withName:r}}editableItemOptions(e){var t;if(!Array.isArray(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.products))return{withRef:{},withName:{}};const i={};Array.isArray(e.data.option_lists)&&e.data.option_lists.forEach(e=>{i[e.id]=e});const r={};e.data.products.forEach(e=>{r[e.id]=[],Array.isArray(e.skus)&&0!==e.skus.length&&Array.isArray(e.skus[0].option_list_ids)&&0!==e.skus[0].option_list_ids.length&&(e.skus.forEach(t=>{var a,n;if(Array.isArray(t.option_list_ids)&&t.option_list_ids.length>0)t.option_list_ids.forEach(a=>{const n=i[a];void 0!==n&&Array.isArray(n.options)&&0!==n.options.length&&n.options.forEach(i=>{var a,o,s;const c=K.sum([null!==(a=t.price)&&void 0!==a?a:null,null!==(o=i.price)&&void 0!==o?o:null]);r[e.id].push({id:String(t.id)+"-"+String(n.id)+"-"+String(i.id),ref:null!==(s=i.ref)&&void 0!==s?s:null,option_list_name:n.name,name:i.name,quantity:1,price:c})})});else{const i=null!==(a=t.price)&&void 0!==a?a:null;r[e.id].push({id:t.id,ref:null!==(n=t.ref)&&void 0!==n?n:null,option_list_name:"",name:t.name,quantity:1,price:i})}}),r[e.id].sort((e,t)=>{var i,r;return null===(i=e.name)||void 0===i?void 0:i.localeCompare(null!==(r=t.name)&&void 0!==r?r:"")}))});const a={};return Object.keys(r).forEach(e=>{var t,i;a[e]=null!==(i=null===(t=r[e])||void 0===t?void 0:t.filter(e=>void 0!==e.ref&&null!==e.ref))&&void 0!==i?i:[]}),{withRef:a,withName:r}}}const j=require("lodash");class V{static compact(e,t={}){if((0,j.isArray)(e)){const i=[];return e.forEach(e=>{e=V.compact(e,t),((0,j.isArray)(e)&&e.length>0||(0,j.isObject)(e)&&Object.keys(e).length>0||null!=e&&!(0,j.isArray)(e)&&!(0,j.isObject)(e))&&i.push(e)}),i}if((0,j.isObject)(e)){const i={};return Object.keys(e).forEach(r=>{let a=e[r];(0,j.isArray)(a)||(0,j.isObject)(a)?(a=V.compact(a,t),((0,j.isArray)(a)&&a.length>0||(0,j.isObject)(a)&&Object.keys(a).length>0||null!=a&&!(0,j.isArray)(a)&&!(0,j.isObject)(a))&&(i[r]=a)):null!=a&&("string"!=typeof a||!1===t.removeEmptyString||a.length>0)&&(i[r]=a)}),i}return"string"!=typeof e||!1===t.removeEmptyString||e.length>0?e:void 0}static update(e,t){if("object"==typeof e&&null!==e&&"object"==typeof t&&null!==t){for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&delete e[t];Object.assign(e,t)}}}class q{items(e,t){return Array.isArray(e)?e.map(e=>{const i=[];return Array.isArray(e.options)&&e.options.forEach(e=>{i.push({ref:e.ref,option_list_name:e.option_list_name,name:e.name,quantity:e.quantity,price:e.price})}),V.compact({sku_ref:e.sku_ref,sku_name:e.sku_name,product_name:e.product_name,quantity:e.quantity,price:e.price,subtotal:"",tax_rate:void 0===t||void 0===e.tax_rate||null===e.tax_rate?void 0:e.tax_rate[t],customer_notes:e.customer_notes,options:i})}):[]}}class Z{calculateTotals(e,t){if(!Array.isArray(e.items))return;const i=this.findCurrency(e.items,t),r=K.sum(e.items.map(e=>K.sum([K.multiply(e.price,Number(e.quantity))].concat(K.sum((e.options||[]).map(e=>K.multiply(e.price,Number(e.quantity)))))))),a="0.00 "+String(i),n="0.00 "+String(i),o="0.00 "+String(i);return{subtotal:r,minimumOrderFee:a,deliveryFee:n,totalDiscount:o,total:K.sum([r,a,n,K.multiply(o,-1)])}}findCurrency(e,t){return e.reduce((e,t)=>{const i=K.priceToAmount(t.price);return"string"==typeof(null==i?void 0:i.currency)&&i.currency!==e?i.currency:"options"in t&&Array.isArray(t.options)?this.findCurrency(t.options,e):e},t)}}class W{static registerBasePath(e){void 0!==process.env.APP_HOME?W.BASE_PATH=process.env.APP_HOME+"/":W.BASE_PATH=e+(e.endsWith("/")?"":"/")}static data(){return W.BASE_PATH+"data/"}static db(){return W.storage()+"db/"}static root(){return W.BASE_PATH}static session(){return W.storage()+"session/"}static storage(){return W.BASE_PATH+"storage/"}}W.BASE_PATH="./";class J extends p{constructor(e,t){super(e,400,t),this.name="BadParameterException"}}class Y extends p{constructor(e,t){super(e,400,t),this.name="BadRequestException"}}class z extends p{constructor(e,t){super(e,409,t),this.name="ConflictException"}}class X extends p{constructor(e,t){super(e,409,t),this.name="DuplicateException"}}class Q extends p{constructor(e,t){super(e,500,t),this.name="InternalException"}}class $ extends p{constructor(e,t){super(e,501,t),this.name="NotImplementedException"}}class ee extends p{constructor(e,t){super(e,404,t),this.name="ObjectNotFoundException"}}class te extends p{constructor(e,t){super(e,404,t),this.name="PageNotFoundException"}}class ie{static error(e,t,i){T.error(i);const r=void 0!==i.code&&null!==i.code?Number(i.code):500;t.status(!isNaN(r)&&Number(i.code)>=400&&Number(i.code)<=599?Number(i.code):500),t.json({code:i.code,message:i.message})}}class re{constructor(e){this.configuration=e}handler(){return(e,t,i)=>{try{let t=!1;if(t||void 0===this.configuration.jwt||(e.session={},t=!0),t||void 0===this.configuration.key||(t=this.authApiKey(e)),!t&&void 0!==this.configuration.session){const i=Object.keys(e.session);if(!Array.isArray(this.configuration.session.required))throw new v("session is not well formatted");this.configuration.session.required.forEach(e=>{if(!i.includes(e))throw new v("session is incomplete")}),t=!0}if(t||void 0===this.configuration.none||(t=this.authNone(e)),!t)throw new v("request is not authenticate");i()}catch(i){ie.error(e,t,i)}}}authApiKey(e){if("string"!=typeof e.headers.Authorization||!e.headers.Authorization.startsWith("apiKey"))return!1;const t=e.headers.Authorization.split(" ");if(2!==t.length)throw new v("api key is not well formatted");if(t[1]!==this.configuration.key.secret)throw new v("api key is not valid");return e.session={},!0}authNone(e){return!(!Array.isArray(this.configuration.none.urlStartsWith)||void 0===this.configuration.none.urlStartsWith.find(t=>{var i;return null===(i=e.originalUrl)||void 0===i?void 0:i.startsWith(t)})||(e.session={},0))}}class ae{can(e,t){}}const ne=require("crypto"),oe=require("express");var se=i.n(oe);const ce=require("cors");var le=i.n(ce);const ue=require("compression");var de=i.n(ue);const me=require("helmet");var _e=i.n(me);const Ae=require("connect-timeout");var pe=i.n(Ae);class he{create(e,t){return i=this,r=void 0,n=function*(){if(void 0===this.app){const i=t||he.DEFAULT_PORT,r="http://localhost:"+String(i);T.debug("start server on "+r),this.app=se()(),this.app.set("trust proxy",!0),this.app.disable("x-powered-by"),this.app.use(de()({level:-1})),this.app.use(pe()("300s")),this.app.use((0,oe.json)({inflate:!0,limit:"10mb",reviver:null,strict:!0,type:"application/json",verify:void 0})),this.app.use((0,oe.urlencoded)({limit:"10mb"})),this.app.use(le()({origin:[r].concat(e),credentials:!0})),this.app.use(_e()()),this.app.use((0,oe.json)()),this.app.listen(i,()=>{T.debug("server is running on "+r)})}return this.app},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{c(n.next(e))}catch(e){t(e)}}function s(e){try{c(n.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(o,s)}c((n=n.apply(i,r||[])).next())});var i,r,a,n}getSessionSecret(e){return ne.createHash("sha1").update(e+he.SALT).digest("hex")}}he.DEFAULT_PORT=8080,he.SALT="03561b4a0fe7f125025";const fe=require("nock");var ge=i.n(fe);class Ee{static isDone(){return(0,fe.isActive)()&&(0,fe.isDone)()}static pending(){return"pending: "+JSON.stringify((0,fe.pendingMocks)())}static reset(){(0,fe.cleanAll)()}}class ye extends Ee{static getUser(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/user")?"/user":e).get("/user").times(e).reply(200,(0,j.cloneDeep)(i(660)))}static getLocations(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/locations")?"/locations":e).get("/locations").times(e).reply(200,(0,j.cloneDeep)(i(69)))}static createCustomer(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/customer")?"/customer":e).post("/customer").times(e).reply(200,(0,j.cloneDeep)(i(851)))}static getCustomer(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/customer_lists")&&e.includes("/customers")?"/customer":e).get("/customer").times(e).reply(200,(0,j.cloneDeep)(i(851)))}static getCustomers(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/customers")?"/customers":e).get("/customers").times(e).reply(200,(0,j.cloneDeep)(i(616)))}static getCustomerLists(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/customer_lists")?"/customerLists":e).get("/customerLists").times(e).reply(200,(0,j.cloneDeep)(i(329)))}static createOrder(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/order")?"/order":e).post("/order").times(e).reply(200,(0,j.cloneDeep)(i(133)))}static getOrder(e=1,t=!1){const r=(0,j.cloneDeep)(i(133));t&&(r.id=String(Date.now())),ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/orders/")?"/order":e).get("/order").times(e).reply(200,r)}static getOrders(e=1,t=!1){const r=(0,j.cloneDeep)(i(762));t&&r.forEach(e=>e.id=String(Date.now())),ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/orders")&&!e.includes("/orders/")?"/orders":e).get("/orders").times(e).reply(200,r)}static setOrderStatus(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/orders/")?"/status":e).patch("/status").times(e).reply(204)}static getCatalog(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/catalog")?"/catalog":e).get("/catalog").times(e).reply(200,(0,j.cloneDeep)(i(270)))}static getCatalogs(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/catalogs")?"/catalogs":e).get("/catalogs").times(e).reply(200,(0,j.cloneDeep)(i(835)))}static createWebhook(e=1){ge()(ye.BASE_URL,{allowUnmocked:!1}).filteringPath(e=>e.includes("/callback")?"/webhook":e).post("/webhook").times(e).reply(200)}}ye.BASE_URL="http://api.hubrise.com";const ve=require("luxon");class Se{static isEmail(e){return"string"==typeof e&&new RegExp("^[a-zA-Z0-9\\.!#$%&*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$","i").test(e)}static isPhone(e){return"string"==typeof e&&new RegExp("^([+\\s0-9]{10,}(#[0-9]+)?)$").test(e)}static isIntMobilePhone(e){const t=new RegExp("^\\+1[0-9]{10}$","i"),i=new RegExp("^\\+33(6|7)[0-9]{8}$","i"),r=new RegExp("^\\+1[0-9]{10}$","i");return t.test(e)||i.test(e)||r.test(e)}static isNumber(e){return"number"==typeof e||"string"==typeof e&&new RegExp("^-?[0-9]+\\.?[0-9]*$").test(e)}static isISODate(e){return!!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?([+-]\d{2}:\d{2}|Z)$/.test(e)&&!isNaN(new Date(e).getTime())}}const Te=require("iconv-lite");class Me{static isUTF8(e){return!e||"utf8"===(e=e.toLowerCase())||"utf-8"===e}static urlencode(e,t){if(!t||Me.isUTF8(t))return encodeURIComponent(e);const i=(0,Te.encode)(e,t);let r="",a="";for(let e=0;e<i.length;e++)a=i[e].toString(16),1===a.length&&(a="0"+a),r+="%"+a;return r=r.toUpperCase(),r}}var Pe=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class Ce{constructor(e,t){this.token=e,this.mode=t}send(e,t,i){return Pe(this,arguments,void 0,function*(e,t,i,r=!0,a){let n=this.checkPhoneFormat(i);if(0===n.length)return T.warning(new J("no valid phone",{phones:i})),Promise.resolve();n.length>1&&(t.length>2*Ce.MESSAGE_MAX_LENGTH?t=t.substring(0,2*Ce.MESSAGE_MAX_LENGTH):t.length>Ce.MESSAGE_MAX_LENGTH&&t.length<=1.33*Ce.MESSAGE_MAX_LENGTH&&(t=t.substring(0,Ce.MESSAGE_MAX_LENGTH))),yield P.request(()=>Pe(this,void 0,void 0,function*(){const i={accessToken:this.token,emetteur:e,message:Me.urlencode(t,"ISO-8859-15"),numero:n.map(e=>e.replace("+","")).join(","),classe_msg:2,nbr_msg:Math.ceil(t.length/Ce.MESSAGE_MAX_LENGTH)};r&&(i.stop=1),void 0!==a&&(i.date_envoi=ve.DateTime.fromISO(a,{setZone:!0}).toFormat("ddMMyyyy-HH:mm"));const o=ve.DateTime.fromISO(null!=a?a:(new Date).toISOString(),{setZone:!0}).setZone("Europe/Paris");if(r?o.hour>=21?i.date_envoi=o.plus({day:1}).set({hour:9}).toFormat("ddMMyyyy-HH:mm"):o.hour<9&&(i.date_envoi=o.set({hour:9}).toFormat("ddMMyyyy-HH:mm")):o.hour<8&&(i.date_envoi=o.set({hour:8}).toFormat("ddMMyyyy-HH:mm")),this.mode===E.TEST)T.info("Simulation Mode: SMS has been sent",{params:i});else{this.mode===E.DEVELOPMENT&&(n=["+15145705214"]);const e=yield A().post(Ce.BASE_API_URL+"sendSMS.do",C.stringify(i,"&","=",{encodeURIComponent:e=>e}),{timeout:3e4});if(e.data.length>0&&"0"!==e.data.trim().substring(0,1))throw new h("Error: "+e.data,i)}}),0,T.error.bind(T))})}checkPhoneFormat(e){return e.filter(e=>Se.isIntMobilePhone(e))}}Ce.BASE_API_URL="https://api.smsmode.com/http/1.6/",Ce.MESSAGE_MAX_LENGTH=150;const be=require("path"),Re=require("mustache"),De=require("fs");const Ne=(e,t)=>{return i=void 0,r=void 0,n=function*(){for(let i=0;i<e.length;i++)yield t(e[i])},new((a=void 0)||(a=Promise))(function(e,t){function o(e){try{c(n.next(e))}catch(e){t(e)}}function s(e){try{c(n.throw(e))}catch(e){t(e)}}function c(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(o,s)}c((n=n.apply(i,r||[])).next())});var i,r,a,n},we=e=>new Promise(t=>setTimeout(t,e)),Le=require("color-name");class Oe{static code(e){null==e&&(e=6);let t="";for(;t.length<e;)t+=Oe.symbolUpperCases[Oe.int(0,Oe.symbolUpperCases.length-1)];return t}static color(e=1){const t=Oe.rgbToHex(Math.round(255*e)),i="#000000"+t,r=Object.values(Le);if(0===r.length)return i;const a=r[Oe.int(0,r.length-1)];return 3!==a.length?i:"#"+Oe.rgbToHex(a[0])+Oe.rgbToHex(a[1])+Oe.rgbToHex(a[2])+t}static rgbToHex(e){const t=e.toString(16);return 1===t.length?"0"+t:t}static int(e,t){return null==e&&(e=0),null==t&&(t=Number.POSITIVE_INFINITY),e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}static password(e){null==e&&(e=8);let t="";for(;t.length<e;)switch(Oe.int(1,3)){case 1:t+=Oe.symbolUpperCases[Oe.int(0,Oe.symbolUpperCases.length-1)];break;case 2:t+=Oe.symbolLowerCases[Oe.int(0,Oe.symbolLowerCases.length-1)];break;default:t+=String(Oe.int(0,9))}return t}}Oe.symbolUpperCases=["A","B","C","D","E","F","G","H","K","M","N","P","R","S","T","U","V","W","X","Y","Z"],Oe.symbolLowerCases=["a","b","c","d","e","f","g","h","k","m","n","p","r","s","t","u","v","w","x","y","z"];var ke=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class Be{dirPath(e){const t=be.resolve(e).lastIndexOf(be.sep);return t<0?e:be.resolve(be.resolve(e).substr(0,t+1))+be.sep}listFiles(e){return ke(this,void 0,void 0,function*(){if(!this.isDir(e))throw new J(String(e)+" does not exist or is not a directory");const t=e.endsWith("/")?"":"/",i=De.readdirSync(e),r=[];return yield Ne(i,i=>ke(this,void 0,void 0,function*(){this.isFile(e+t+i)&&r.push(e+t+i)})),r})}randomFile(e,t){return ke(this,void 0,void 0,function*(){const i=yield this.listFiles(e);if(0===i.length)return;let r;return r=void 0!==t?Math.max(t,0)%i.length:Oe.int(0,i.length-1),i[r]})}move(e,t){return ke(this,void 0,void 0,function*(){if(!this.isFile(e))throw new J(String(e)+" does not exist or is not a file");if(De.mkdirSync(t,{recursive:!0}),!this.isDir(t))throw new J(String(t)+" does not exist or is not a directory");return De.renameSync(e,t+be.basename(e))})}read(e){return ke(this,void 0,void 0,function*(){if(!this.isFile(e))throw new J(String(e)+" does not exist or is not a file");return De.readFileSync(e,"utf8")})}readJson(e){return ke(this,void 0,void 0,function*(){const t=yield this.read(e);if(!this.isJson(t))throw new J(String(e)+" does not contain JSON");return JSON.parse(t)})}readJsonFiles(e){return ke(this,void 0,void 0,function*(){if(!this.isDir(e))throw new J(String(e)+" does not exist or is not a directory");const t=e.endsWith("/")?"":"/",i=De.readdirSync(e),r=[];return yield Ne(i,i=>ke(this,void 0,void 0,function*(){this.isFile(e+t+i)&&i.endsWith(".json")&&r.push({name:i,data:yield this.readJson(e+t+i)})})),r})}write(e,t){return ke(this,void 0,void 0,function*(){let i="";return i="string"==typeof t||"number"==typeof t?String(t):JSON.stringify(t),De.mkdirSync(this.dirPath(e),{recursive:!0}),De.writeFileSync(e,i,{encoding:"utf8"}),Promise.resolve()})}writeJson(e,t){return ke(this,void 0,void 0,function*(){return this.write(e,JSON.stringify(t))})}isDir(e){return De.existsSync(e)&&De.statSync(e).isDirectory()}isFile(e){return De.existsSync(e)&&De.statSync(e).isFile()}isJson(e){try{return JSON.parse(e),!0}catch(e){return!1}}}const Ue=require("clean-css");var Ie=i.n(Ue);const Ge=require("html-minifier-terser");var xe=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class He{css(e){return xe(this,void 0,void 0,function*(){return new(Ie())({compatibility:"ie7",format:!1,level:1,sourceMap:!1}).minify(e).styles})}html(e){return xe(this,void 0,void 0,function*(){return yield(0,Ge.minify)(e,{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})})}}var Ke=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class Fe{constructor(){this.minifier=new He}render(e,t,i){return Ke(this,void 0,void 0,function*(){e.endsWith(".template")||(e+=".template");const r=(0,j.cloneDeep)(t),a=be.isAbsolute(e)?"":__dirname+be.sep,n=new Be,o=yield n.read(a+e),s=[];(0,Re.parse)(o).forEach(e=>{e.length>=4&&"&"===e[0]&&e[1].startsWith("include:")&&s.push(e[1])}),s.length>0&&(void 0===i?i=be.dirname(a+e)+be.sep:be.isAbsolute(i)||(i=a+i),yield Ne(s,e=>Ke(this,void 0,void 0,function*(){const t=e.split(":");if(3===t.length&&void 0!==r[e]){const a=t[2];i.includes("/html")&&Object.keys(r[e]).forEach(t=>{r[e][t]=Array.isArray(r[e][t])?r[e][t].map(e=>e.replace(/(?:\r\n|\r|\n)/g,"<br>")):r[e][t].replace(/(?:\r\n|\r|\n)/g,"<br>")}),r[e]=yield this.render(be.resolve(i,a),r[e])}})));const c=(0,Re.render)(o,r);if(c.includes("{{")||c.includes("}}"))throw new z("template: missing data to render template",{templatePath:e,data:t});return e.includes("html")?this.minifier.html(c):c})}}const je=require("node-mailjet");var Ve=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class qe{constructor(e,t,i){this.templateEngine=new Fe,this.mailjet=new je.Client({apiKey:e,apiSecret:t}),this.mode=i}sendDeliveryDelay(e,t,i){return Ve(this,void 0,void 0,function*(){return yield P.request(()=>Ve(this,void 0,void 0,function*(){void 0===i.base.copyright&&(i.base.copyright={year:String((new Date).getUTCFullYear())});const r=yield this.templateEngine.render("data/email/template/deliveryDelay",i,"data/email/element/text"),a=yield this.templateEngine.render("data/email/template/deliveryDelay",i,"data/email/element/html");return yield this.sendNotification(e,[{recipient:t,subject:i.base.subject,text:r,html:a}],!1)}),0,T.error.bind(T))})}sendTrackDelivery(e,t,i){return Ve(this,void 0,void 0,function*(){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const r=yield this.templateEngine.render("data/email/template/trackDelivery",i,"data/email/element/text"),a=yield this.templateEngine.render("data/email/element/text/index",{content:r,base:i.base}),n=yield this.templateEngine.render("data/email/template/trackDelivery",i,"data/email/element/html"),o=yield this.templateEngine.render("data/email/element/html/index",{content:n,base:i.base});return yield this.sendNotification(e,[{recipient:t,subject:i.base.subject,text:a,html:o}],!1)}),0,T.error.bind(T))})}sendUserNotification(e,t,i){return Ve(this,arguments,void 0,function*(e,t,i,r=!0,a){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const n=yield this.templateEngine.render("data/email/template/userNotification",i,"data/email/element/text"),o=yield this.templateEngine.render("data/email/element/text/index",{content:n,base:i.base,isCommercial:r}),s=yield this.templateEngine.render("data/email/template/userNotification",i,"data/email/element/html"),c=yield this.templateEngine.render("data/email/element/html/index",{content:s,base:i.base,isCommercial:r});return yield this.sendNotification(e,[{recipient:t,subject:i.base.subject,text:o,html:c}],r,a)}),0,T.error.bind(T))})}sendUsersNotifications(e,t,i,r){return Ve(this,void 0,void 0,function*(){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const a=[];return yield Ne(t,e=>Ve(this,void 0,void 0,function*(){const t=yield this.templateEngine.render("data/email/template/userNotification",e.data,"data/email/element/text"),r=yield this.templateEngine.render("data/email/element/text/index",{content:t,base:e.data.base,isCommercial:i}),n=yield this.templateEngine.render("data/email/template/userNotification",e.data,"data/email/element/html"),o=yield this.templateEngine.render("data/email/element/html/index",{content:n,base:e.data.base,isCommercial:i});a.push({recipient:e.recipient,subject:e.data.base.subject,text:r,html:o})})),yield this.sendNotification(e,a,i,r)}),0,T.error.bind(T))})}sendDiscount(e,t,i){return Ve(this,arguments,void 0,function*(e,t,i,r=!0,a){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const n=yield this.templateEngine.render("data/email/template/discount",i,"data/email/element/text"),o=yield this.templateEngine.render("data/email/element/text/index",{content:n,base:i.base,isCommercial:r}),s=yield this.templateEngine.render("data/email/template/discount",i,"data/email/element/html"),c=yield this.templateEngine.render("data/email/element/html/index",{content:s,base:i.base,isCommercial:r});return yield this.sendNotification(e,[{recipient:t,subject:i.base.subject,text:o,html:c}],r,a)}),0,T.error.bind(T))})}sendDiscounts(e,t){return Ve(this,arguments,void 0,function*(e,t,i=!0,r){return yield P.request(()=>Ve(this,void 0,void 0,function*(){const a=[];return yield Ne(t,e=>Ve(this,void 0,void 0,function*(){const t=yield this.templateEngine.render("data/email/template/discount",e.data,"data/email/element/text"),r=yield this.templateEngine.render("data/email/element/text/index",{content:t,base:e.data.base,isCommercial:i}),n=yield this.templateEngine.render("data/email/template/discount",e.data,"data/email/element/html"),o=yield this.templateEngine.render("data/email/element/html/index",{content:n,base:e.data.base,isCommercial:i});a.push({recipient:e.recipient,subject:e.data.base.subject,text:r,html:o})})),yield this.sendNotification(e,a,i,r)}),0,T.error.bind(T))})}sendNotification(e,t){return Ve(this,arguments,void 0,function*(e,t,i=!1,r){if(0===t.length)throw new J("email: missing messages");try{if(this.mode===E.TEST)T.info("Simulation Mode: Email has been sent",{sender:e,recipients:t.map(e=>e.recipient)});else{const a=[];yield Ne(t,t=>Ve(this,void 0,void 0,function*(){this.mode===E.DEVELOPMENT&&(t.recipient.contact="developer@onylab.com"),a.push({From:{Name:e.name,Email:e.contact},To:[{Name:t.recipient.name,Email:t.recipient.contact}],Subject:t.subject,TextPart:t.text,HTMLPart:t.html,Priority:i?0:2,customID:void 0===r?void 0:String(r)})})),yield this.mailjet.post("send",{version:"v3.1"}).request({Messages:a})}}catch(e){throw new p(e.message,Number(e.statusCode))}})}}var Ze=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class We{constructor(e,t){this.filesystem=new Be,void 0!==We.root&&We.root===e||(We.root=e,We.config=void 0);const i=void 0===t?y.getMode():t;void 0!==We.environment&&We.environment===i||(We.environment=void 0===t?y.getMode():t,We.config=void 0)}full(){return Ze(this,void 0,void 0,function*(){return yield this.init(),We.config})}init(){return Ze(this,void 0,void 0,function*(){if(void 0===We.config)if(void 0===We.root)We.config={};else if(We.config=yield this.filesystem.readJson(We.root+"data/config.json"),[E.DEVELOPMENT,E.TEST].includes(We.environment))try{We.config=(0,j.merge)(We.config,yield this.filesystem.readJson(We.root+"data/config_"+String(We.environment)+".json"))}catch(e){}})}}const Je=require("typeorm");var Ye=function(e,t,i,r){return new(i||(i=Promise))(function(a,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function s(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(o,s)}c((r=r.apply(e,t||[])).next())})};class ze{constructor(e){this.root=e}connect(e,t){return Ye(this,void 0,void 0,function*(){void 0===this.db&&(yield this.init());const i=this.db[e];void 0!==i?(i.entities=t,i.logging=["error"],i.logger=!0,i.bigNumberStrings=!1,void 0===i.timezone&&(i.timezone="Z"),void 0===i.charset&&(i.charset="UTF8_GENERAL_CI"),this.connection=yield(0,Je.createConnection)(i)):T.error(new J("bad connection name"))})}synchronize(){return Ye(this,void 0,void 0,function*(){void 0!==this.connection&&(yield this.connection.synchronize())})}close(){return Ye(this,void 0,void 0,function*(){return this.connection.close()})}init(){return Ye(this,void 0,void 0,function*(){if(void 0===this.root)this.db={};else{const e=new Be;this.db=yield e.readJson(this.root+"data/db.json")}})}}const Xe=require("prettyjson");class Qe{error(e){T.error(e)}info(e){T.trace(e)}json(e){T.trace(Xe.render(e,{}))}success(e){T.trace(e)}}class $e{constructor(){this.fileSystem=new Be}image(e,t,i){return r=this,a=void 0,o=function*(){void 0===i&&(i=ne.randomBytes(20).toString("hex")+be.extname(e)),yield this.fileSystem.write(t+be.sep+i,"");const r=be.resolve(t+be.sep+i),a=De.createWriteStream(r);return(yield A()({url:e,method:"GET",responseType:"stream"})).data.pipe(a),new Promise((e,t)=>{a.on("finish",()=>e(r)),a.on("error",t)})},new((n=void 0)||(n=Promise))(function(e,t){function i(e){try{c(o.next(e))}catch(e){t(e)}}function s(e){try{c(o.throw(e))}catch(e){t(e)}}function c(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n(function(e){e(r)})).then(i,s)}c((o=o.apply(r,a||[])).next())});var r,a,n,o}}const et=require("fast-diff");var tt=i.n(et);class it{static escapeRegExp(e){return"string"!=typeof e?e:e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}static hash(e,t=0){let i=3735928559^t,r=1103547991^t;for(let t,a=0;a<e.length;a++)t=e.charCodeAt(a),i=Math.imul(i^t,2654435761),r=Math.imul(r^t,1597334677);return i=Math.imul(i^i>>>16,2246822507),i^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(i^i>>>13,3266489909),(r>>>0).toString(16).padStart(8,"0")+(i>>>0).toString(16).padStart(8,"0")}static nullable(e){return S(e)||"string"==typeof e&&0===e.length?null:e}static removeMultiSpaces(e){return"string"!=typeof e?e:e.replace(/\s{2,}/g," ")}static removeText(e,t){if("string"!=typeof e||"string"!=typeof t||0===t.length)return e;try{e=(e=e.replace(new RegExp(it.escapeRegExp(t),"ig"),"")).replace(new RegExp(it.escapeRegExp(t).replace(new RegExp("\\s","g"),"-"),"ig"),"")}catch(e){}return e}static replace(e,t,i){if("string"!=typeof e)return e;if(t.length!==i.length)return e;let r=e;return t.forEach((e,t)=>{r=r.replace(new RegExp(it.escapeRegExp(e),"ig"),i[t])}),r}static slugify(e,t=""){return void 0===e?"":(0,j.toLower)((0,j.trim)((0,j.deburr)(e)).replace(/[^0-9a-z\-\_]/gi,t))}static truncate(e,t){return S(e)||e.length<=t?e:t<=3?"":e.slice(0,t-3)+"..."}}const rt=require("emoji-regex");var at=i.n(rt);class nt{static trim(e){return"string"==typeof e?e.trim():e}static capitalize(e){const t=nt.lower(e);return"string"==typeof t?t.split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):e}static ucfirst(e){const t=nt.lower(e);return"string"==typeof t?t.charAt(0).toUpperCase()+t.slice(1):e}static lower(e){return"string"==typeof e?e.toLocaleLowerCase():e}static upper(e){return"string"==typeof e?e.toLocaleUpperCase():e}static phone(e,t,i="int"){if("string"==typeof e)switch(e=nt.preformatPhone(e,t),i){case"nat":return nt.phoneNat(e,t);case"int":return nt.phoneInt(e,t)}return e}static stripEmoji(e){let t=e;if("string"==typeof t){let e;for(;null!==(e=at()().exec(t));)try{t=t.replace(new RegExp(it.escapeRegExp(e[0]),"g"),""),t=t.replace(new RegExp("\\s+","g")," "),t=t.trim()}catch(e){}}return t}static stripExoticCharacters(e){return"string"==typeof e?e.replace("’","'").replace(/[\u0250-\ue007]+/g,"*"):e}static preformatPhone(e,t){return e=e.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===t&&new RegExp("^[1-9]").test(e)&&9===e.length?"0"+e:e}static phoneNat(e,t){if("fr"===t){if(e.startsWith("+330")?e=e.substring(3):e.startsWith("+33")?e="0"+e.substring(3):e.startsWith("0033")?e="0"+e.substring(4):e.startsWith("33")&&11===e.length&&(e="0"+e.substring(2)),10===e.length){let t=0;e=e.split("").map(e=>(t++,e+(t%2==0?" ":""))).join("").trim()}return e}return e}static phoneInt(e,t){return e.startsWith("+")?e:"fr"===t?(e.startsWith("0")&&(e=e.substring(1)),"+33"+e):e}}class ot{static autoCorrectCity(e){if(S(e)||"string"!=typeof e||0===e.length)return e;(e.toLowerCase().startsWith("st-")||e.toLowerCase().startsWith("st "))&&(e="Saint "+e.substring(3));const t=Object.values(ot.ZIPCODE_CITY).flat(),i=t.find(t=>t.toLowerCase()===e.toLowerCase());if(void 0!==i)return i;const r=t.find(t=>{const i=ot.countDiff(e,t);return i.add<=2&&i.remove<=2});if(void 0!==r)return r;const a=t.find(t=>t.replace(/-/g," ").toLowerCase()===e.toLowerCase());if(void 0!==a)return a;const n=t.find(t=>{const i=ot.countDiff(e,t.replace(/-/g," "));return i.add<=2&&i.remove<=2});if(void 0!==n)return n;const o=t.find(t=>t.toLowerCase().startsWith(e.toLowerCase()));if(void 0!==o)return o;const s=t.find(t=>e.toLowerCase().includes(t.toLowerCase()));return void 0!==s?s:e}static autoCorrectStreet(e){if(S(e)||"string"!=typeof e||0===e.length)return e;ot.STREET_TYPE.forEach(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)+" "))});const t=new RegExp("^(0+)[0-9]+,?\\s[a-zA-Z]+").exec(e);return null!==t&&2===t.length&&(e=e.substring(t[1].length)),ot.STREET_TYPE.forEach(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}static getZipCodeFromCity(e){if(!S(e))return Object.keys(ot.ZIPCODE_CITY).reduce((t,i)=>void 0!==ot.ZIPCODE_CITY[i].find(t=>t.toLowerCase()===e.toLowerCase())?i:t,void 0)}static getCityFromZipCode(e,t){if(void 0===e||void 0===t)return;const i=ot.ZIPCODE_CITY[e];if(void 0===i)return;if(1===i.length)return i[0];let r;return t.split(",").forEach(e=>{r=i.find(t=>e.trim().toLowerCase()===t.trim().toLowerCase())}),void 0!==r?r:i[0]}static isZipCode(e){return"string"==typeof e&&(!!Object.keys(ot.ZIPCODE_CITY).includes(e)||Se.isNumber(e)&&5===e.length&&!e.includes(".")&&!e.includes("-"))}static parse(e,t=!0){const i={};if(!S(e)){const r=e.split(",");if(r.length>=3&&t){void 0===ot.COUNTRIES.find(t=>e.toLowerCase().includes(" "+t.toLowerCase()))&&r.push("France");let t=r.length-1;if(i.country=r[t].trim(),r.splice(t--,1),void 0!==r[t]&&r[t].trim().includes(" ")){const e=r[t].trim().split(" ");i.zip=void 0===e[0]?void 0:e[0].trim(),e.splice(0,1),i.city=e.join(" ").trim(),r.splice(t--,1)}else isNaN(Number(r[t].trim()))?isNaN(Number(r[t-1].trim()))?(i.city=r[t].trim(),r.splice(t--,1)):(i.city=r[t].trim(),r.splice(t--,1),i.zip=r[t].trim(),r.splice(t--,1)):(i.zip=r[t].trim(),r.splice(t--,1),t>=2&&(i.city=r[t].trim(),r.splice(t--,1)));i.street=r.map(e=>e.trim()).join(" ").trim()}else{let t=e.toLowerCase();Object.keys(ot.ZIPCODE_CITY).forEach(e=>{if(t.includes(e)){i.zip=e;try{t=t.replace(new RegExp(it.escapeRegExp(e),"ig"),"")}catch(e){}}}),Object.values(ot.ZIPCODE_CITY).flat().forEach(e=>{var r;if(t.includes(e.toLowerCase())&&(void 0===i.zip||(null===(r=ot.ZIPCODE_CITY[i.zip])||void 0===r?void 0:r.find(t=>t.toLowerCase()===e.toLowerCase())))){i.city=e;try{t=t.replace(new RegExp(it.escapeRegExp(e),"ig"),"")}catch(e){}}}),ot.COUNTRIES.forEach(e=>{if(t.includes(" "+e.toLowerCase())&&!t.includes("de "+e.toLowerCase())&&!t.includes("de la "+e.toLowerCase())){i.country=e;try{t=t.replace(new RegExp(it.escapeRegExp(" "+e),"ig"),"")}catch(e){}}}),void 0===i.street&&(i.street=(0,j.trim)(t.split(",").map(e=>e.trim()).join(" "),"-").trim())}void 0===i.country&&(i.country="France")}return void 0!==i.street&&(i.street=nt.lower(nt.trim(String(i.street)))),void 0!==i.zip&&(i.zip=nt.upper(nt.trim(String(i.zip)))),void 0!==i.city&&(i.city=ot.autoCorrectCity(nt.capitalize(nt.trim(String(i.city))))),void 0!==i.country&&(i.country=nt.capitalize(nt.trim(String(i.country)))),ot.complete(i)}static complete(e){if(void 0===e.city||0===e.city.length){const t=ot.getCityFromZipCode(e.zip,e.street);void 0!==t&&(e.city=t)}return"string"==typeof e.street&&ot.REGIONS.forEach(t=>{e.street=it.removeText(e.street,t).trim()}),"fr"===nt.lower(e.country)&&(e.country="France"),e}static removeDuplicates(e){if("string"!=typeof e)return e;const t=[];return e.split(",").forEach(e=>{void 0===t.find(t=>t.trim().toLowerCase().includes(e.trim().toLowerCase()))&&t.push(e)}),t.join(",")}static countDiff(e,t){const i={add:0,remove:0};return tt()(e.toLowerCase(),t.toLowerCase()).forEach(e=>{switch(e[0]){case-1:i.remove+=e[1].length;break;case 1:i.add+=e[1].length}}),i}}ot.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"]},ot.REGIONS=["île-de-france"],ot.COUNTRIES=["France","FR"],ot.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"}];class st{static getCycleDateFromFullDate(e,t){if("weekly"===t){const t=ve.DateTime.fromISO(e.replace(/-W([0-9])$/i,"-W0$1")).toISOWeekDate();if(null===t)return e;const i=t.split("-");return i.length>2?i[0]+"-"+i[1]:i.join("-")}return"monthly"===t?ve.DateTime.fromISO(e).toFormat("yyyy-LL"):ve.DateTime.fromISO(e).toISODate()}static displayWeekDay(e){let t="";return void 0!==st.WEEK_DAYS[e]&&(t=st.WEEK_DAYS[e]),t}static generatePeriod(e,t,i,r=!0,a=st.PERIOD_MAX_DATES,n="daily"){const o={daily:{day:1},weekly:{week:1},monthly:{month:1}}[n];let s=ve.DateTime.fromISO(e,{setZone:!0}).toISODate();const c=ve.DateTime.fromISO(t,{setZone:!0}).toISODate();let l=0;const u={};for(;s<=c&&l<a;){const e=st.getCycleDateFromFullDate(s,n);u[e]=(0,j.cloneDeep)(i),r&&(u[e].date=e),s=ve.DateTime.fromISO(s,{setZone:!0}).plus(o).toISODate(),l++}return u}static getOpenPeriods(e,t){const i=[];return e.forEach(e=>{const r=[e];for(;r.length>0;){const e=r[0];if(void 0===t.find(t=>t.from<=e.from&&e.to<=t.to)){const a=t.find(t=>t.from<=e.from&&e.from<t.to&&t.to<e.to);if(void 0!==a)r.push({from:a.to,to:e.to});else{const a=t.find(t=>e.from<t.from&&e.to>t.from&&e.to<=t.to);if(void 0!==a)r.push({from:e.from,to:a.from});else{const a=t.find(t=>e.from<t.from&&t.to<e.to);void 0!==a?(r.push({from:e.from,to:a.from}),r.push({from:a.to,to:e.to})):i.push(e)}}}r.shift()}}),i}static limitDate(e,t,i=0){if(void 0===e||void 0===t)return;const r=ve.DateTime.fromISO(e,{setZone:!0}).toISO(),a=ve.DateTime.fromISO(t,{setZone:!0}).plus({seconds:i}).toISO();return r>a?a:r}static localeToISO(e){const t=new RegExp("[0-9]{2}/[0-9]{2}/[0-9]{4}"),i=new RegExp("[0-9]{2}-[0-9]{2}-[0-9]{4}"),r=new RegExp("[0-9]{4}-[0-9]{2}-[0-9]{2}");let a;if(t.test(e)){const t=e.split("/");a=t[2]+"-"+t[1]+"-"+t[0]}else if(i.test(e)){const t=e.split("-");a=t[2]+"-"+t[1]+"-"+t[0]}else r.test(e)&&(a=e);return a}static slotToTime(e){const t=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$"),i=new RegExp("^(\\s)?[0-9]{2}:[0-9]{2}(\\s)?-(\\s)?[0-9]{2}:[0-9]{2}(\\s)?$");let r;return e=e.trim(),t.test(e)?r=e.trim()+":00":i.test(e)&&(r=e.split("-")[0].trim()+":00"),r}static delay(e,t,i){return S(e)||S(t)?0:Math.round(Math.abs(ve.DateTime.fromISO(e,{setZone:!0}).toUTC().diff(ve.DateTime.fromISO(t,{setZone:!0}).toUTC(),[i])[i]))}static round(e,t=0){if("string"!=typeof e)return e;const i=ve.DateTime.fromISO(e,{setZone:!0});return ve.DateTime.fromMillis(Math.round(+i.toMillis()/t)*t).setZone(i.zone).toISO()}static min(e){return e.reduce((e,t)=>"string"!=typeof e||e>t?t:e,void 0)}static max(e){return e.reduce((e,t)=>void 0===e||e<t?t:e,void 0)}}st.PERIOD_MAX_DATES=90,st.WEEK_DAYS={1:"lundi",2:"mardi",3:"mercredi",4:"jeudi",5:"vendredi",6:"samedi",7:"dimanche"};class ct{static phone(e,t){if("string"==typeof e&&(e=e.trim().replace(/\s?\.?\-?\(?\)?/g,""),"fr"===t)){const t=new RegExp("(0[6-7][0-9]{8})","i").exec(e);if(null!==t&&t.length>0&&null!==t[0])return t[0]}}}class lt{static applyTaxes(e,t,i=2){let r=Number(e);return t.forEach(t=>{r+=Number(e)*t}),String(H.round(r,i))}static calculateTaxes(e,t){let i=0;return t.forEach(t=>{i+=e*t}),H.round(i,2)}static displayWithCurrency(e,t){if(null==e)return e;const i=lt.currencies[t];let r=e+" "+t;if(void 0!==i)switch(i.position){case"before":r=i.symbol+e;break;case"after":r=e+i.symbol}return r}static format(e,t,i=2){if(null==e)return e;const r=Number(e.replace(/\,/gi,"")).toLocaleString("en-US",{style:"decimal",useGrouping:!0,minimumFractionDigits:i,maximumFractionDigits:i});switch(t){case"fr":return r.replace(/\,/gi," ").replace(/\./gi,",");case"us":return r}}static round(e,t=.1){const i=100*Number(e),r=100*t,a=i%r;return String(H.round(i-a+(a<Math.ceil(r/2)?0:r),2)/100)}}return lt.currencies={CAD:{symbol:"$",position:"before"},EUR:{symbol:"€",position:"after"},USD:{symbol:"$",position:"before"}},r})());
2
2
  //# sourceMappingURL=common-api.node.min.js.map