reslib 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/auth/index.js +1 -1
- package/build/countries/index.js +1 -1
- package/build/currency/index.js +1 -1
- package/build/currency/session.js +2 -2
- package/build/i18n/index.js +1 -1
- package/build/inputFormatter/index.js +1 -1
- package/build/logger/index.js +1 -1
- package/build/resources/index.js +1 -1
- package/build/translations/index.d.ts +4 -0
- package/build/translations/index.js +1 -1
- package/build/translations/validator.en.d.ts +4 -0
- package/build/translations/validator.en.js +1 -1
- package/build/utils/date/dateHelper.js +1 -1
- package/build/utils/date/index.js +1 -1
- package/build/utils/index.js +2 -2
- package/build/utils/numbers.js +1 -1
- package/build/validator/index.js +3 -3
- package/build/validator/rules/array.js +1 -1
- package/build/validator/rules/boolean.js +1 -1
- package/build/validator/rules/date.js +1 -1
- package/build/validator/rules/default.js +1 -1
- package/build/validator/rules/enum.js +1 -1
- package/build/validator/rules/file.js +2 -2
- package/build/validator/rules/format.d.ts +169 -0
- package/build/validator/rules/format.js +3 -3
- package/build/validator/rules/index.d.ts +1 -0
- package/build/validator/rules/index.js +3 -3
- package/build/validator/rules/multiRules.js +1 -1
- package/build/validator/rules/numeric.js +1 -1
- package/build/validator/rules/object.d.ts +71 -0
- package/build/validator/rules/object.js +5 -0
- package/build/validator/rules/string.js +1 -1
- package/build/validator/rules/target.js +1 -1
- package/build/validator/validator.js +1 -1
- package/package.json +249 -244
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
%{failedRulesErrors}`,oneOf:`The field %{fieldName} must match at least one of the following validation rules:
|
|
3
3
|
%{failedRulesErrors}`,allOf:`The field %{fieldName} must match all of the following validation rules:
|
|
4
4
|
%{failedRulesErrors}`,validateNested:`The field %{fieldName} must be a valid nested object. Errors:
|
|
5
|
-
%{nestedErrors}`,validateNestedInvalidType:"The field %{fieldName} must be an object, but received %{receivedType}",dateAfter:"This field must be after %{date}",dateBefore:"This field must be before %{date}",dateBetween:"This field must be between %{startDate} and %{endDate}",dateEquals:"This field must be equal to %{date}",futureDate:"This field must be a date in the future",pastDate:"This field must be a date in the past",file:"This field must be a valid file",fileSize:"This field must not exceed %{maxSize} bytes",fileType:"This field must be one of the following types: %{allowedTypes}",image:"This field must be a valid image file",fileExtension:"This field must have one of the following extensions: %{allowedExtensions}",minFileSize:"This field must be at least %{minSize} bytes",uuid:"This field must be a valid UUID",json:"This field must be valid JSON",base64:"This field must be valid Base64 encoded data",hexColor:"This field must be a valid hexadecimal color code",creditCard:"This field must be a valid credit card number",ip:"This field must be a valid IP address (version %{version})",macAddress:"This field must be a valid MAC address",matches:"This field must match the pattern %{pattern}",tests:{entity:{name:"Name",id:"Id",email:"Email",aString:"A String",url:"Url",note:"Note",createdAt:"Created At",updatedAt:"Updated At"}}};exports.validator=e;
|
|
5
|
+
%{nestedErrors}`,validateNestedInvalidType:"The field %{fieldName} must be an object, but received %{receivedType}",dateAfter:"This field must be after %{date}",dateBefore:"This field must be before %{date}",dateBetween:"This field must be between %{startDate} and %{endDate}",dateEquals:"This field must be equal to %{date}",futureDate:"This field must be a date in the future",pastDate:"This field must be a date in the past",file:"This field must be a valid file",fileSize:"This field must not exceed %{maxSize} bytes",fileType:"This field must be one of the following types: %{allowedTypes}",image:"This field must be a valid image file",fileExtension:"This field must have one of the following extensions: %{allowedExtensions}",minFileSize:"This field must be at least %{minSize} bytes",uuid:"This field must be a valid UUID",json:"This field must be valid JSON",base64:"This field must be valid Base64 encoded data",hexColor:"This field must be a valid hexadecimal color code",creditCard:"This field must be a valid credit card number",ip:"This field must be a valid IP address (version %{version})",macAddress:"This field must be a valid MAC address",matches:"This field must match the pattern %{pattern}",mongoId:"This field must be a valid MongoDB ObjectId",hexadecimal:"This field must be a valid hexadecimal value",object:"This field must be an object",isObject:"This field must be an object",tests:{entity:{name:"Name",id:"Id",email:"Email",aString:"A String",url:"Url",note:"Note",createdAt:"Created At",updatedAt:"Updated At"}}};exports.validator=e;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
%{failedRulesErrors}`,oneOf:`The field %{fieldName} must match at least one of the following validation rules:
|
|
3
3
|
%{failedRulesErrors}`,allOf:`The field %{fieldName} must match all of the following validation rules:
|
|
4
4
|
%{failedRulesErrors}`,validateNested:`The field %{fieldName} must be a valid nested object. Errors:
|
|
5
|
-
%{nestedErrors}`,validateNestedInvalidType:"The field %{fieldName} must be an object, but received %{receivedType}",dateAfter:"This field must be after %{date}",dateBefore:"This field must be before %{date}",dateBetween:"This field must be between %{startDate} and %{endDate}",dateEquals:"This field must be equal to %{date}",futureDate:"This field must be a date in the future",pastDate:"This field must be a date in the past",file:"This field must be a valid file",fileSize:"This field must not exceed %{maxSize} bytes",fileType:"This field must be one of the following types: %{allowedTypes}",image:"This field must be a valid image file",fileExtension:"This field must have one of the following extensions: %{allowedExtensions}",minFileSize:"This field must be at least %{minSize} bytes",uuid:"This field must be a valid UUID",json:"This field must be valid JSON",base64:"This field must be valid Base64 encoded data",hexColor:"This field must be a valid hexadecimal color code",creditCard:"This field must be a valid credit card number",ip:"This field must be a valid IP address (version %{version})",macAddress:"This field must be a valid MAC address",matches:"This field must match the pattern %{pattern}",tests:{entity:{name:"Name",id:"Id",email:"Email",aString:"A String",url:"Url",note:"Note",createdAt:"Created At",updatedAt:"Updated At"}}};var Ee={auth:ne,currencies:oe,countries:ie,dates:se,resources:de,validator:le};Date.prototype.toSQLDateTimeFormat=function(){return g.toSQLDateTimeFormat(this)};Date.prototype.toSQLDateFormat=function(){return g.toSQLDateFormat(this)};Date.prototype.toSQLTimeFormat=function(){return g.toSQLTimeFormat(this)};Date.prototype.resetHours=function(){return this.setHours(0),this};Date.prototype.resetMinutes=function(){return this.setMinutes(0),this};Date.prototype.resetSeconds=function(){return this.setSeconds(0),this};Date.prototype.resetMilliseconds=function(){return this.setMilliseconds(0),this};Date.prototype.resetHours2Minutes2Seconds=function(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this};Date.prototype.toFormat=function(e){return g.formatDate(this,e)};Date.prototype.addYears=function(e){return g.addYears(e,this)};Date.prototype.addMonths=function(e){return g.addMonths(e,this)};Date.prototype.addMinutes=function(e){return g.addMinutes(e,this)};Date.prototype.addSeconds=function(e){return g.addSeconds(e,this)};Date.prototype.addDays=function(e){return g.addDays(e,this)};Date.prototype.addWeeks=function(e){return g.addWeeks(e,this)};Date.prototype.addHours=function(e){return g.addHours(e,this)};function u(e){return !!(e&&typeof e=="string")}function f(...e){for(var r in e){let t=e[r];if(u(t))return t}return ""}var C=class C{static get logger(){let r=Reflect.getMetadata(C.loggerMetaData,C);return ce(r)&&(this._logger=r),this._logger?this._logger:console}static set logger(r){ce(r)&&Reflect.defineMetadata(C.loggerMetaData,r,C);}static _log(r,...t){let a=C.logger;r=f(r),r&&typeof a[r]=="function"?a[r](C.getDateTimeString(),...t):console.log("Logger level not found : [",r,"]",...t);}static getDateTimeString(){let{day:r,year:t,hours:a,minutes:i,seconds:n,dayNameShort:o,monthName:d}=g.getUTCDateTimeDetails(),c=r<10?"0"+r:r,l=a<10?"0"+a:a,y=i<10?"0"+i:i,h=n<10?"0"+n:n;return "["+[o,c,d,t].join(" ")+" "+[l,y,h].join(":")+"]"}static log(...r){this._log("log",...r);}static info(...r){this._log("info",...r);}static debug(...r){this._log("debug",...r);}static warn(...r){this._log("warn",...r);}static error(...r){this._log("error",...r);}};C.loggerMetaData=Symbol("logger-meta-data");var N=C,ce=e=>{if(!e)return false;try{return ["warn","info","error"].every(r=>typeof e[r]=="function")}catch(r){return false}};function Ie(e){return typeof e=="boolean"||!e||typeof e=="number"||typeof e=="string"||typeof e=="symbol"?false:Object(e).constructor===Promise||e.constructor&&(e.constructor.name==="Promise"||e.constructor.name==="AsyncFunction")||e instanceof Promise||typeof(e==null?void 0:e.then)=="function"&&typeof(e==null?void 0:e.catch)=="function"&&typeof(e==null?void 0:e.finally)=="function"?true:e&&typeof e.constructor=="function"&&Function.prototype.toString.call(e.constructor).replace(/\(.*\)/,"()")===Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()")}function ue(e){return e&&Object.prototype.toString.call(e)==="[object Promise]"?true:Ie(e)}function me(){return typeof window!="undefined"&&(window==null?void 0:window.document)!==void 0&&typeof document!="undefined"&&typeof navigator!="undefined"}var x=()=>{var e;try{if(typeof process!="undefined"&&(process!=null&&process.versions)&&((e=process==null?void 0:process.versions)!=null&&e.node)||typeof global=="object"&&(global==null?void 0:global.toString.call(global))==="[object global]")return !0}catch(r){}return false},Le=()=>{var e,r;return !!(typeof window!="undefined"&&window&&typeof(window==null?void 0:window.process)=="object"&&((e=window==null?void 0:window.process)==null?void 0:e.type)==="renderer"||typeof process!="undefined"&&typeof(process==null?void 0:process.versions)=="object"&&((r=process.versions)!=null&&r.electron)||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&String(navigator==null?void 0:navigator.userAgent).toLowerCase().indexOf("electron")>=0)},Pe=()=>{if(typeof document!="undefined"&&document)try{return document.createEvent("TouchEvent"),!0}catch(e){try{return "ontouchstart"in window||"onmsgesturechange"in window}catch(r){}}return false},Re=()=>typeof window=="undefined"&&typeof process!="undefined",fe=()=>!!(typeof window!="undefined"&&typeof window=="object"&&window),xe=()=>{if(!me()||typeof navigator!="object"||!navigator||typeof navigator.userAgent!="string")return false;let e=navigator.userAgent.toLowerCase();return /android/i.test(e)},He=()=>{var e;return !fe()||!(window!=null&&window.ReactNativeWebView)?false:typeof((e=window==null?void 0:window.ReactNativeWebView)==null?void 0:e.postMessage)=="function"},Fe=()=>x()&&process.platform==="darwin",ke=()=>x()&&process.platform==="win32",Be=()=>x()&&process.platform==="linux",ye={isWeb:me,isLinux:Be,isDarwin:Fe,isWin32:ke,isNode:x,isElectron:Le,isTouchDevice:Pe,isServerSide:Re,isClientSide:fe,isAndroidMobileBrowser:xe,isReactNativeWebview:He};var O=class e{static decycle(r,t=[]){if(typeof r=="function")return;if(!r||typeof r!="object")return r;if(t.includes(r))return null;let a=t.concat([r]);return Array.isArray(r)?r.map(i=>e.decycle(i,a)):Object.fromEntries(Object.entries(r).map(([i,n])=>[i,e.decycle(n,a)]))}static stringify(r,t=false){return typeof r=="string"?r:JSON.stringify(t!==false?e.decycle(r):r)}static isJSON(r){if(typeof r!="string")return false;let t=r.trim();if(t.length===0)return false;let a=t[0];if(a!=="{"&&a!=="[")return false;try{let i=JSON.parse(t);return i!==null&&typeof i=="object"}catch(i){return false}}static parse(r,t){if(typeof r=="string")try{r=JSON.parse(r,t);}catch(a){return r}if(r&&typeof r=="object")for(let a in r){let i=r[a];e.isJSON(i)&&(r[a]=e.parse(i,t));}return r}};var D=class D{static get storage(){var t;let r=Reflect.getMetadata(D.sessionStorageMetaData,D);if(V(r)&&(this._storage=r),this._storage)return this._storage;if(ye.isClientSide()&&typeof window!="undefined"&&window.localStorage&&((t=window.localStorage)!=null&&t.getItem))this._storage={get:a=>window.localStorage.getItem(a),set:(a,i)=>window.localStorage.setItem(a,i),remove:a=>window.localStorage.removeItem(a),removeAll:()=>window.localStorage.clear()};else {let a={};this._storage={get:i=>a[i],set:(i,n)=>a[i]=n,remove:i=>{delete a[i];},removeAll:()=>a={}};}return this._storage}static set storage(r){V(r)&&Reflect.defineMetadata(D.sessionStorageMetaData,r,D);}static get keyNamespace(){return u(this._keyNamespace)?this._keyNamespace:""}static set keyNamespace(r){u(r)&&(this._keyNamespace=r.trim().replace(/\s+/g,"-"));}static sanitizeKey(r){if(!r||!u(r))return "";r=r.trim().replace(/\s+/g,"-");let t=this.keyNamespace;return t?`${t}-${r}`:r}};D.sessionStorageMetaData=Symbol("sessionStorage"),D._keyNamespace=void 0;var b=D;function H(e){return b.sanitizeKey(e)}var pe=(e,r)=>(e=e&&O.stringify(e,r),e==null&&(e=""),e),ge=e=>{if(ue(e))return new Promise((r,t)=>{e.then(a=>{r(O.parse(a));}).catch(a=>{t(a);});});if(e!=null)return O.parse(e)},Ge=e=>{if(e=H(e),b.storage&&e&&typeof e=="string"){let r=b.storage.get(e);return ge(r)}},Ke=e=>{if(e=H(e),b.storage&&e&&typeof e=="string")return b.storage.remove(e)},Ve=()=>{if(b.storage)return b.storage.removeAll()},V=e=>{if(!e)return false;try{return ["get","set","remove","removeAll"].every(r=>typeof e[r]=="function")}catch(r){return false}},W={get:Ge,set:(e,r,t=true)=>(e=H(e),b.storage.set(e,pe(r,t))),remove:Ke,handleGetValue:ge,sanitizeKey:H,handleSetValue:pe,isValidStorage:V,Manager:b,removeAll:Ve};function S(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function w(e){if(e instanceof RegExp)return true;if(!e||typeof e!="object"||!Object.prototype.toString.call(e).includes("RegExp"))return false;try{return new RegExp(e),!0}catch(r){return false}}function E(e){return !e||typeof e!="object"?false:e instanceof Date?true:typeof e.getTime!="function"?false:!(Object.prototype.toString.call(e)!=="[object Date]"||isNaN(e.getTime()))}function U(e){return typeof window!="object"||!window||typeof document=="undefined"||typeof HTMLElement=="undefined"||!HTMLElement?false:e===document?true:"HTMLElement"in window?!!e&&e instanceof HTMLElement:!!e&&typeof e=="object"&&e.nodeType===1&&!!e.nodeName}function m(e){if(e===null||typeof e!="object"||U(e)||E(e)||w(e)||S(e))return false;let r=Object.getPrototypeOf(e);if(r===null)return true;let t=r.constructor;if(typeof t!="function")return false;if(t===Object)return true;let a=t.prototype;return typeof a!="object"?false:a===Object.prototype?true:typeof r.hasOwnProperty=="function"&&Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")&&typeof r.isPrototypeOf=="function"}function Z(e){if(Array.isArray(e)){let a=[];for(var r=0;r<e.length;r++)a[r]=Z(e[r]);return a}else if(m(e)&&e){let a={};for(var t in e)e.hasOwnProperty(t)&&(a[t]=Z(e[t]));return a}else return e}Object.getSize=function(e,r=false){if(!e||typeof e!="object")return 0;if(Array.isArray(e))return e.length;typeof r!="boolean"&&(r=false);let t=0;for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&(t++,r===true))return t;return t};function I(e,...r){let t=Array.isArray(e),a=m(e);(e==null||!t&&!a)&&(e={});for(let i=0;i<r.length;i++){let n=r[i];if(n==null)continue;let o=m(n),d=Array.isArray(n);if(!(!o&&!d)){if(t){d&&he(e,n);continue}else if(d)continue;for(let c in n){let l=n[c];if(l==null)continue;if(l===n){e[c]=e;continue}let y=e[c],h=Array.isArray(y),M=Array.isArray(l);if(h){M?he(e[c],l):e[c]=l;continue}else if(!m(y)){e[c]=l;continue}if(M||!m(l)){e[c]=l;continue}e[c]=I({},y,l);}}}return e}var he=(e,r)=>{let t=r.length,a=0;for(let i=0;i<e.length;i++){let n=e[i],o=r[i];if(i<t){let d=Array.isArray(n),c=Array.isArray(o),l=m(n),y=m(o);d&&c||l&&y?(e[a]=I(d?[]:{},n,o),a++):o!=null?(e[a]=o,a++):n!=null&&(e[a]=n,a++);}}for(let i=e.length;i<t;i++)r[i]!==void 0&&r[i]!==null&&e.push(r[i]);return e};function We(e,r){return F(e,"",{},r)}function F(e,r="",t={},a){if(t=m(t)?t:{},S(e)||E(e)||w(e)||Array.isArray(e)&&(a!=null&&a.skipArrays))return r&&(t[r]=e),t;if(typeof e=="function"||typeof e=="object"&&!m(e)&&!Ue(e))return t;if(e instanceof Map||e instanceof WeakMap)return Array.from(e.entries()).forEach(([i,n])=>{let o=r?`${r}[${String(i)}]`:String(i);F(n,o,t,a);}),t;if(Array.isArray(e)||e instanceof Set||e instanceof WeakSet)return (Array.isArray(e)?e:Array.from(e)).forEach((n,o)=>{let d=r?`${r}[${o}]`:String(o);F(n,d,t,a);}),t;if(m(e))for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let n=e[i],o=r?r.endsWith("]")?`${r}.${i}`:`${r}.${i}`:i;F(n,o,t,a);}return t}function Ue(e){return Array.isArray(e)||e instanceof Set||e instanceof Map||e instanceof WeakMap||e instanceof WeakSet}function Ze(e){return Object.entries(e)}Object.typedEntries=Ze;Object.flatten=We;Object.clone=Z;function L(e,r){if(e==null)return "";if(typeof e=="string")return e;if((typeof e=="number"||typeof e=="object"&&e instanceof Number)&&typeof e.formatNumber=="function")return e.formatNumber();if(e instanceof Date||typeof e=="object"&&e!==null&&e.constructor===Date)return typeof e.toFormat=="function"?e.toFormat():e.toISOString();if(e instanceof Error)return `Error: ${e.message}`;if(w(e))return e.toString();if(S(e))return String(e);if(Array.isArray(e))return JSON.stringify(e);if(typeof e=="object"&&e!==null){if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString)return e.toString();if(typeof e.toString=="function"){let t=e.toString();if(t!=="[object Object]")return t}return JSON.stringify(e)}return typeof(e==null?void 0:e.toString)=="function"?e.toString():String(e)}function be(e,r,t){let a=L,i=f(e);if(!m(r)||!r)return i;let n=/%\{([^}]+)\}/g,o=new Set,d,c=f(e);for(;(d=n.exec(c))!==null;){let l=d[1];l!==void 0&&o.add(l);}return o.forEach(l=>{let y;y=`%{${l}}`;let h=Object.prototype.hasOwnProperty.call(r,l)?r[l]:void 0,M=h===void 0?"":(()=>{try{return a(h,l,L)}catch($){return L(h)}})(),Se=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i=i.replace(new RegExp(Se,"g"),M);}),i}function z(e){return !!(e==null||typeof e=="number"&&isNaN(e)||typeof e=="string"&&e.trim()==="")}function T(e){return typeof e=="number"&&!isNaN(e)&&isFinite(e)}function ze(e){return f(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f")}function k(e,r){var t=Object.prototype.toString.call(e);return t==="[object "+r+"]"}function A(e,r){if(["boolean","undefined"].includes(typeof e)||e===null)return String(e);if(T(e))return e.formatNumber();if(e instanceof Date)return e.toFormat();if(e instanceof Error)return e==null?void 0:e.toString();r=Object.assign({},r);let{parenthesis:t}=r,a=t?"(":"",i=t?")":"";return typeof e=="string"?(r==null?void 0:r.escapeString)!==false?"'"+ze(e)+"'":e:k(e,"RegExp")||k(e,"Number")||k(e,"Boolean")?e.toString():k(e,"Date")?"new Date("+e.getTime()+")":Array.isArray(e)?"["+e.map(n=>A(n,r)).join(",")+"]":typeof e=="object"?a+"{"+Object.keys(e).map(n=>{var o=e[n];return A(n,r)+":"+A(o,r)}).join(",")+"}"+i:e&&typeof(e==null?void 0:e.toString)=="function"?e==null?void 0:e.toString():String(e)}var Ce=Symbol("TRANSLATION_KEY");var p=class p extends i18nJs.I18n{constructor(t={},a={}){super({},a);this._isLoading=false;this._locales=[];this.namespaceResolvers={};this._observableFactory=re();this._____isObservable=true;this.hasRegisteredDefaultTranslations=false;this._namespacesLoaded={};this.hasRegisteredDefaultTranslations||(this.registerTranslations(K),this.hasRegisteredDefaultTranslations=true),this.registerTranslations(t),this.loadNamespaces();}static[Symbol.hasInstance](t){return this.isI18nInstance(t)}static isI18nInstance(t){if(!t||typeof t!="object")return false;try{if(t instanceof i18nJs.I18n)return !0}catch(a){}return typeof t.getLocale=="function"&&typeof t.translate=="function"&&typeof t.translateTarget=="function"}translate(t,a){return this.isPluralizeOptions(a)&&this.canPluralize(t)?(typeof a.count=="number"&&(a.countStr=a.count.formatNumber()),this.pluralize(a.count,t,a)):super.translate(t,a)}translateTarget(t,a){let i=p.getTargetTanslationKeys(t);for(let n in i)u(i[n])&&(i[n]=this.translate(i[n],a));return i}translateObject(t,a){if(!m(t))return {};let i={};for(let n in t){let o=t[n];u(o)&&(i[n]=Me.translate(o,a));}return i}static getTargetTanslationKeys(t){return ae(t,Ce)}on(t,a){return this._observableFactory.on.call(this,t,a)}finally(t,a){return this._observableFactory.finally.call(this,t,a)}off(t,a){var i;return (i=this._observableFactory)==null?void 0:i.off.call(this,t,a)}trigger(t,...a){var i;return (i=this._observableFactory)==null?void 0:i.trigger.call(this,t,...a)}offAll(){var t;return (t=this._observableFactory)==null?void 0:t.offAll.call(this)}once(t,a){var i;return (i=this._observableFactory)==null?void 0:i.once.call(this,t,a)}getEventCallBacks(){var t;return (t=this._observableFactory)==null?void 0:t.getEventCallBacks.call(this)}static getInstance(t){if(!this.isI18nInstance(p.instance)){let a=p.getLocaleFromSession();p.instance=this.createInstance({},Object.assign({},a?{locale:a}:{},t));}return p.instance}isDefaultInstance(){return this===p.instance}static setLocaleToSession(t){W.set("i18n.locale",t);}static getLocaleFromSession(){let t=W.get("i18n.locale");return u(t)?t:""}canPluralize(t,a){a=f(a,this.getLocale());let i=this.getNestedTranslation(t,a);return !m(i)||!i?false:u(i==null?void 0:i.one)&&u(i==null?void 0:i.other)}getNestedTranslation(t,a){a=f(a,this.getLocale());let i=(u(t)?t.trim().split("."):Array.isArray(t)?t:[]).filter(u);if(!i.length)return;let n=this.getTranslations(a);for(let o of i)if(m(n))n=n[o];else return;return n}isPluralizeOptions(t){return !!(m(t)&&t&&typeof t.count=="number")}static RegisterTranslations(t){return p.getInstance().registerTranslations(t)}static createInstance(t={},a={}){let d=Object.assign({},a),{interpolate:i}=d,n=te(d,["interpolate"]),o=new p(t,n);return o.interpolate=(c,l,y)=>{let h=p.flattenObject(y),M=this.defaultInterpolator(c,l,h);return u(M)&&M!==l&&(l=M),typeof i=="function"?i(c,l,y):be(l,y)},o}getTranslations(t){let a=m(this.translations)?this.translations:{};return u(t)?m(a[t])?a[t]:{}:a}static registerMomentLocale(t,a){return u(t)&&m(a)&&Array.isArray(a.months)&&(this.momentLocales[t]=I({},this.momentLocales[t],a)),this.momentLocales}static getMomentLocale(t){return this.momentLocales[t]}static setMomentLocale(t){try{return v__default.default.updateLocale(t,this.getMomentLocale(t)),!0}catch(a){console.error(a," setting moment locale : ",t);}return false}registerTranslations(t){return this.store(t),this.getTranslations()}store(t){super.store(t),this.trigger("translations-changed",this.getLocale(),this.getTranslations());}resolveTranslations(t){try{let a=Object.getOwnPropertyNames(t);for(let i of a){let n=Reflect.getMetadata(Ce,t,i);if(n)try{t[i]=this.translate(n);}catch(o){N.error(o," resolving translation for key : ",n);}}}catch(a){N.error(a," resolving translations for target : ",t);}}getMissingPlaceholderString(t,a,i){return typeof this.missingPlaceholder=="function"?this.missingPlaceholder(this,t,f(a),Object.assign({},i)):t}getLocale(){return super.locale}setLocales(t){return this._locales=Array.isArray(t)?t:["en"],this._locales.includes("en")||this._locales.push("en"),this.getLocales()}hasLocale(t){return u(t)&&this.getLocales().includes(t)}getLocales(){let t=Object.keys(this.getTranslations()),a=Array.isArray(this._locales)?this._locales:["en"],i=[...t,...a.filter(n=>!t.includes(n))];return i.includes("en")||i.push("en"),i}isLocaleSupported(t){return u(t)?this.getLocales().includes(t):false}isLoading(){return this._isLoading}setLocale(t,a=false){return super.locale===t&&a!==true&&this._namespacesLoaded[t]?Promise.resolve(this.getLocale()):new Promise((i,n)=>(this._isLoading=true,this.trigger("namespaces-before-load",t),this.loadNamespaces(t).then(o=>{this.isDefaultInstance()&&(p.instance=this,this.isLocaleSupported(t)&&p.setLocaleToSession(t)),super.locale=t,p.setMomentLocale(t),this.trigger("locale-changed",t,o),i(t);}).catch(n).finally(()=>{this._isLoading=false;})))}registerNamespaceResolver(t,a){if(!u(t)||typeof a!="function"){console.warn("Invalid arguments for registerNamespaceResolver.",t,a);return}this.namespaceResolvers[t]=a;}static RegisterNamespaceResolver(t,a){return p.getInstance().registerNamespaceResolver(t,a)}loadNamespace(t,a,i=true){return !u(t)||!this.namespaceResolvers[t]?Promise.reject(new Error(`Invalid namespace or resolver for namespace "${t}".`)):(a=f(a,this.getLocale()),u(a)?this.namespaceResolvers[t](a).then(n=>{let o={};return o[a]=Object.assign({},n),m(n)&&(i!==false&&this.store(o),this.trigger("namespace-loaded",t,a,o)),o}):Promise.reject(new Error(`Locale is not set. Cannot load namespace "${t}".`)))}static LoadNamespace(t,a,i=true){return p.getInstance().loadNamespace(t,a,i)}loadNamespaces(t,a=true){let i=[],n={};t=f(t,this.getLocale()),this._isLoading=true;for(let o in this.namespaceResolvers)Object.prototype.hasOwnProperty.call(this.namespaceResolvers,o)&&typeof this.namespaceResolvers[o]=="function"&&i.push(new Promise(d=>{this.namespaceResolvers[o](t).then(c=>{I(n,c);}).finally(()=>{d(true);});}));return Promise.all(i).then(()=>{let o={};return o[t]=n,a!==false&&this.store(o),setTimeout(()=>{this.trigger("namespaces-loaded",t,o);},100),o}).finally(()=>{this._isLoading=false;})}static LoadNamespaces(t,a=true){return p.getInstance().loadNamespaces(t,a)}static flattenObject(t){return m(t)?Object.flatten(t):t}static defaultInterpolator(t,a,i){return z(a)?"":S(a)?(a=String(a),!m(i)||!i||!m(i)||!i?a:a.replace(/%{(.*?)}/g,(n,o)=>z(i[o])?"":S(i[o])?String(i[o]):A(i[o],{escapeString:false}))):A(a,{escapeString:false})}};p.momentLocales={};var Y=p,Me=Y.getInstance();try{Object.setPrototypeOf(Me,Y.prototype);}catch(e){}function J(e){return !!(e==null||typeof e=="undefined"||typeof e=="string"&&e===""||Array.isArray(e)&&!e.length)}var s=class s{static parseString(r,t){if(u(r)&&u(t))try{let a=v__default.default(r,t,!0);if(a.isValid())return {date:a.toDate(),matchedFormat:t,isValid:!0}}catch(a){}try{if(Array.isArray(t)&&(t!=null&&t.length))for(let a of t){let i=De(r,a);if(i)return i}for(let a of s.DATE_FORMATS){let i=De(r,a);if(i)return i}return {date:null,matchedFormat:null,isValid:!1,error:"Unable to parse date string with any known format"}}catch(a){return {date:null,matchedFormat:null,isValid:false,error:a instanceof Error?a.message:"Unknown error occurred while parsing date"}}}static toIsoString(r){let t=r?s.parseDate(r):new Date;return t?t.toISOString():""}static isoStringToDate(r){return new Date(r)}static parseDate(r,t){if(s.isDateObj(r))return r;if(!u(t)){let a=s.parseString(r);return a!=null&&a.isValid?a.date:null}if(J(r))return null;try{let a=v__default.default(r,t,!0);if(a!=null&&a.isValid())return a.toDate()}catch(a){console.error(a," parsing date with moment : ",r," format is : ",t);}return null}static toSQLDateTimeFormat(r){if(!s.isDateObj(r))return "";let t=r.getFullYear(),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0"),n=String(r.getHours()).padStart(2,"0"),o=String(r.getMinutes()).padStart(2,"0"),d=String(r.getSeconds()).padStart(2,"0");return `${t}-${a}-${i} ${n}:${o}:${d}`}static getI18n(r){return Y.isI18nInstance(r)?r:Y.getInstance()}static getDefaultDateTimeFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultDateTimeFormat"),"YYYY-MM-DD HH:mm")}static getDefaultDateFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultDateFormat"),"YYYY-MM-DD")}static toSQLDateFormat(r){if(!s.isDateObj(r))return "";let t=r.getFullYear(),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0");return `${t}-${a}-${i}`}static toSQLTimeFormat(r){if(!s.isDateObj(r))return "";let t=String(r.getHours()).padStart(2,"0"),a=String(r.getMinutes()).padStart(2,"0"),i=String(r.getSeconds()).padStart(2,"0");return `${t}:${a}:${i}`}static getDefaultTimeFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultTimeFormat"),"HH:mm")}static isValidDate(r,t){if(r==null||typeof r=="boolean")return false;if(s.isDateObj(r))return true;if(T(r)){let i=new Date(r);return i&&!isNaN(i.getTime())}if(u(r))return !!s.parseDate(r,t);if(r!=null&&r.toString&&(r==null?void 0:r.toString())==parseInt(r).toString())return false;let a=new Date(r);return s.isDateObj(a)}static addToDate(r,t,a){if(T(r)||(r=0),J(t)&&(t=new Date),s.isValidDate(t)&&u(t)&&(t=new Date(t)),s.isValidDate(t)||(t=u(t)?new Date(t):new Date),u(a)&&typeof t["set"+a]=="function"&&typeof t["get"+a]=="function"){let i="set"+a,n="get"+a;t=new Date(t[i](t[n]()+r));}return t}static addDays(r,t){return s.addToDate(r,t,"Date")}static addMilliseconds(r,t){return T(r)||(r=0),s.isDateObj(t)||(t=new Date),t=t||new Date,new Date(t.getTime()+r)}static addSeconds(r,t){return T(r)||(r=0),s.addMilliseconds(r*1e3,t)}static addMinutes(r,t){return T(r)||(r=0),s.addMilliseconds(r*6e4,t)}static addHours(r,t){return T(r)||(r=0),s.addMilliseconds(r*36e5,t)}static addMonths(r,t,a){return s.addToDate(r,t,"Month")}static addWeeks(r,t){return r=(T(r)?r:0)*7,s.addToDate(r,t,"Date")}static addYears(r,t){T(r)||(r=0);let a=new Date(s.addToDate(0,t)),i=a.getFullYear();return i+r<0?r=0:r+=i,a.setFullYear(r),new Date(a)}static formatDate(r,t){try{let a=v__default.default(r);if(a.isValid())return a.format(f(t,s.getDefaultDateTimeFormat()))}catch(a){}return f(s.isValidDate(r)?r==null?void 0:r.toString():"")}static getUTCDateTimeDetails(r){let t=r?v__default.default.utc(r):v__default.default.utc();return {year:t.year(),day:t.day(),month:t.month(),monthString:t.format("MM"),hours:t.hours(),date:t.date(),minutes:t.minutes(),seconds:t.seconds(),monthName:t.format("MMMM"),dayName:t.format("dddd"),dayNameShort:t.format("ddd")}}};s.DATE_FORMATS=["YYYY-MM-DD","YYYY-MM-DDTHH:mm:ss","YYYY-MM-DDTHH:mm:ssZ","YYYY-MM-DDTHH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss[Z]","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DDTHH:mm:ss.SSSZ ","YYYY-MM-DDTHH:mm:ss.SSS","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DD HH:mm:ssZ","YYYY-MM-DD HH:mmZ","MM/DD/YYYY","MM-DD-YYYY","MM.DD.YYYY","MM/DD/YY","MMMM DD, YYYY","MMM DD, YYYY","DD/MM/YYYY","DD-MM-YYYY","DD.MM.YYYY","DD/MM/YY","DD MMMM YYYY","DD MMM YYYY","HH:mm:ss.SSSZ","HH:mm:ssZ","HH:mmZ","YYYYMMDD","YYYYMMDDTHHMM","YYYYMMDDTHHMMSS","HH:mm:ss","HH:mm","hh:mm A","h:mm A","HH:mm:ss.SSS","YYYY-DDD","YYYY-Www","YYYY-Www-D","YYYY/MM/DD","YYYY.MM.DD","MMM D, YYYY","MMMM D, YYYY","D MMM YYYY","D MMMM YYYY","MMM D YYYY","ddd, DD MMM YYYY HH:mm:ss ZZ","ddd, DD MMM YYYY HH:mm:ss","dddd, MMMM D, YYYY","dddd, D MMMM YYYY","hh:mm:ss A","H:mm:ss","YYYY-[W]WW","YYYY-[W]WW-E","YYYY-MM-DDTHH:mm:ss.SSS","DD-MM-YYYY HH:mm:ss","YYYY/MM/DD HH:mm:ss","YYYY.MM.DD HH:mm:ss","DD/MM/YYYY HH:mm:ss","MMM D YYYY, h:mm a","MMMM D YYYY, h:mm a","h:mm A MMM D, YYYY","MMMM D, YYYY","YY-MM-DD","DD-MM-YY","MM/DD/YY","MMM DD, YY","D MMM YY","D MMMM YY","YYYY MMM D","YYYY-MM-DD HH:mm","YYYY-MM-DD HH:mm:ss.SSS"],s.SQL_DATE_FORMAT="YYYY-MM-DD",s.SQL_DATE_TIME_FORMAT="YYYY-MM-DD HH:mm:ss",s.SQL_TIME_FORMAT="HH:mm:ss",s.getCurrentMonthDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=new Date(t.getFullYear(),t.getMonth(),1),i=new Date(t.getFullYear(),t.getMonth()+1,0);return {first:a,last:i}},s.getPreviousWeekDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=new Date(t.getTime()-3600*24*7*1e3),i=new Date(a),n=a.getDay(),o=a.getDate()-n+(n===0?-6:1),d=new Date(a.setDate(o)),c=new Date(i.setDate(o+6));return {first:d,last:c}},s.getCurrentWeekDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=t.getDay(),i=t.getDate()-a+(a==0?-6:1),n=new Date(t),o=new Date(t.setDate(i));return n.setDate(n.getDate()+6),{first:o,last:n}},s.isDateObj=E;var g=s,De=(e,r)=>{let t=v__default.default(e,r,true);try{if(t.isValid()&&t.format(r)===e||v__default.default.utc(t,!0).format(r)===e)return {date:t.toDate(),matchedFormat:r,isValid:!0}}catch(a){}return null};exports.DateHelper=g;
|
|
5
|
+
%{nestedErrors}`,validateNestedInvalidType:"The field %{fieldName} must be an object, but received %{receivedType}",dateAfter:"This field must be after %{date}",dateBefore:"This field must be before %{date}",dateBetween:"This field must be between %{startDate} and %{endDate}",dateEquals:"This field must be equal to %{date}",futureDate:"This field must be a date in the future",pastDate:"This field must be a date in the past",file:"This field must be a valid file",fileSize:"This field must not exceed %{maxSize} bytes",fileType:"This field must be one of the following types: %{allowedTypes}",image:"This field must be a valid image file",fileExtension:"This field must have one of the following extensions: %{allowedExtensions}",minFileSize:"This field must be at least %{minSize} bytes",uuid:"This field must be a valid UUID",json:"This field must be valid JSON",base64:"This field must be valid Base64 encoded data",hexColor:"This field must be a valid hexadecimal color code",creditCard:"This field must be a valid credit card number",ip:"This field must be a valid IP address (version %{version})",macAddress:"This field must be a valid MAC address",matches:"This field must match the pattern %{pattern}",mongoId:"This field must be a valid MongoDB ObjectId",hexadecimal:"This field must be a valid hexadecimal value",object:"This field must be an object",isObject:"This field must be an object",tests:{entity:{name:"Name",id:"Id",email:"Email",aString:"A String",url:"Url",note:"Note",createdAt:"Created At",updatedAt:"Updated At"}}};var Ee={auth:ne,currencies:oe,countries:ie,dates:se,resources:de,validator:le};Date.prototype.toSQLDateTimeFormat=function(){return g.toSQLDateTimeFormat(this)};Date.prototype.toSQLDateFormat=function(){return g.toSQLDateFormat(this)};Date.prototype.toSQLTimeFormat=function(){return g.toSQLTimeFormat(this)};Date.prototype.resetHours=function(){return this.setHours(0),this};Date.prototype.resetMinutes=function(){return this.setMinutes(0),this};Date.prototype.resetSeconds=function(){return this.setSeconds(0),this};Date.prototype.resetMilliseconds=function(){return this.setMilliseconds(0),this};Date.prototype.resetHours2Minutes2Seconds=function(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this};Date.prototype.toFormat=function(e){return g.formatDate(this,e)};Date.prototype.addYears=function(e){return g.addYears(e,this)};Date.prototype.addMonths=function(e){return g.addMonths(e,this)};Date.prototype.addMinutes=function(e){return g.addMinutes(e,this)};Date.prototype.addSeconds=function(e){return g.addSeconds(e,this)};Date.prototype.addDays=function(e){return g.addDays(e,this)};Date.prototype.addWeeks=function(e){return g.addWeeks(e,this)};Date.prototype.addHours=function(e){return g.addHours(e,this)};function u(e){return !!(e&&typeof e=="string")}function f(...e){for(var r in e){let t=e[r];if(u(t))return t}return ""}var C=class C{static get logger(){let r=Reflect.getMetadata(C.loggerMetaData,C);return ce(r)&&(this._logger=r),this._logger?this._logger:console}static set logger(r){ce(r)&&Reflect.defineMetadata(C.loggerMetaData,r,C);}static _log(r,...t){let a=C.logger;r=f(r),r&&typeof a[r]=="function"?a[r](C.getDateTimeString(),...t):console.log("Logger level not found : [",r,"]",...t);}static getDateTimeString(){let{day:r,year:t,hours:a,minutes:i,seconds:n,dayNameShort:o,monthName:d}=g.getUTCDateTimeDetails(),c=r<10?"0"+r:r,l=a<10?"0"+a:a,y=i<10?"0"+i:i,h=n<10?"0"+n:n;return "["+[o,c,d,t].join(" ")+" "+[l,y,h].join(":")+"]"}static log(...r){this._log("log",...r);}static info(...r){this._log("info",...r);}static debug(...r){this._log("debug",...r);}static warn(...r){this._log("warn",...r);}static error(...r){this._log("error",...r);}};C.loggerMetaData=Symbol("logger-meta-data");var N=C,ce=e=>{if(!e)return false;try{return ["warn","info","error"].every(r=>typeof e[r]=="function")}catch(r){return false}};function Ie(e){return typeof e=="boolean"||!e||typeof e=="number"||typeof e=="string"||typeof e=="symbol"?false:Object(e).constructor===Promise||e.constructor&&(e.constructor.name==="Promise"||e.constructor.name==="AsyncFunction")||e instanceof Promise||typeof(e==null?void 0:e.then)=="function"&&typeof(e==null?void 0:e.catch)=="function"&&typeof(e==null?void 0:e.finally)=="function"?true:e&&typeof e.constructor=="function"&&Function.prototype.toString.call(e.constructor).replace(/\(.*\)/,"()")===Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()")}function ue(e){return e&&Object.prototype.toString.call(e)==="[object Promise]"?true:Ie(e)}function me(){return typeof window!="undefined"&&(window==null?void 0:window.document)!==void 0&&typeof document!="undefined"&&typeof navigator!="undefined"}var x=()=>{var e;try{if(typeof process!="undefined"&&(process!=null&&process.versions)&&((e=process==null?void 0:process.versions)!=null&&e.node)||typeof global=="object"&&(global==null?void 0:global.toString.call(global))==="[object global]")return !0}catch(r){}return false},Le=()=>{var e,r;return !!(typeof window!="undefined"&&window&&typeof(window==null?void 0:window.process)=="object"&&((e=window==null?void 0:window.process)==null?void 0:e.type)==="renderer"||typeof process!="undefined"&&typeof(process==null?void 0:process.versions)=="object"&&((r=process.versions)!=null&&r.electron)||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&String(navigator==null?void 0:navigator.userAgent).toLowerCase().indexOf("electron")>=0)},Pe=()=>{if(typeof document!="undefined"&&document)try{return document.createEvent("TouchEvent"),!0}catch(e){try{return "ontouchstart"in window||"onmsgesturechange"in window}catch(r){}}return false},Re=()=>typeof window=="undefined"&&typeof process!="undefined",fe=()=>!!(typeof window!="undefined"&&typeof window=="object"&&window),xe=()=>{if(!me()||typeof navigator!="object"||!navigator||typeof navigator.userAgent!="string")return false;let e=navigator.userAgent.toLowerCase();return /android/i.test(e)},He=()=>{var e;return !fe()||!(window!=null&&window.ReactNativeWebView)?false:typeof((e=window==null?void 0:window.ReactNativeWebView)==null?void 0:e.postMessage)=="function"},Fe=()=>x()&&process.platform==="darwin",ke=()=>x()&&process.platform==="win32",Be=()=>x()&&process.platform==="linux",ye={isWeb:me,isLinux:Be,isDarwin:Fe,isWin32:ke,isNode:x,isElectron:Le,isTouchDevice:Pe,isServerSide:Re,isClientSide:fe,isAndroidMobileBrowser:xe,isReactNativeWebview:He};var O=class e{static decycle(r,t=[]){if(typeof r=="function")return;if(!r||typeof r!="object")return r;if(t.includes(r))return null;let a=t.concat([r]);return Array.isArray(r)?r.map(i=>e.decycle(i,a)):Object.fromEntries(Object.entries(r).map(([i,n])=>[i,e.decycle(n,a)]))}static stringify(r,t=false){return typeof r=="string"?r:JSON.stringify(t!==false?e.decycle(r):r)}static isJSON(r){if(typeof r!="string")return false;let t=r.trim();if(t.length===0)return false;let a=t[0];if(a!=="{"&&a!=="[")return false;try{let i=JSON.parse(t);return i!==null&&typeof i=="object"}catch(i){return false}}static parse(r,t){if(typeof r=="string")try{r=JSON.parse(r,t);}catch(a){return r}if(r&&typeof r=="object")for(let a in r){let i=r[a];e.isJSON(i)&&(r[a]=e.parse(i,t));}return r}};var D=class D{static get storage(){var t;let r=Reflect.getMetadata(D.sessionStorageMetaData,D);if(V(r)&&(this._storage=r),this._storage)return this._storage;if(ye.isClientSide()&&typeof window!="undefined"&&window.localStorage&&((t=window.localStorage)!=null&&t.getItem))this._storage={get:a=>window.localStorage.getItem(a),set:(a,i)=>window.localStorage.setItem(a,i),remove:a=>window.localStorage.removeItem(a),removeAll:()=>window.localStorage.clear()};else {let a={};this._storage={get:i=>a[i],set:(i,n)=>a[i]=n,remove:i=>{delete a[i];},removeAll:()=>a={}};}return this._storage}static set storage(r){V(r)&&Reflect.defineMetadata(D.sessionStorageMetaData,r,D);}static get keyNamespace(){return u(this._keyNamespace)?this._keyNamespace:""}static set keyNamespace(r){u(r)&&(this._keyNamespace=r.trim().replace(/\s+/g,"-"));}static sanitizeKey(r){if(!r||!u(r))return "";r=r.trim().replace(/\s+/g,"-");let t=this.keyNamespace;return t?`${t}-${r}`:r}};D.sessionStorageMetaData=Symbol("sessionStorage"),D._keyNamespace=void 0;var b=D;function H(e){return b.sanitizeKey(e)}var pe=(e,r)=>(e=e&&O.stringify(e,r),e==null&&(e=""),e),ge=e=>{if(ue(e))return new Promise((r,t)=>{e.then(a=>{r(O.parse(a));}).catch(a=>{t(a);});});if(e!=null)return O.parse(e)},Ge=e=>{if(e=H(e),b.storage&&e&&typeof e=="string"){let r=b.storage.get(e);return ge(r)}},Ke=e=>{if(e=H(e),b.storage&&e&&typeof e=="string")return b.storage.remove(e)},Ve=()=>{if(b.storage)return b.storage.removeAll()},V=e=>{if(!e)return false;try{return ["get","set","remove","removeAll"].every(r=>typeof e[r]=="function")}catch(r){return false}},W={get:Ge,set:(e,r,t=true)=>(e=H(e),b.storage.set(e,pe(r,t))),remove:Ke,handleGetValue:ge,sanitizeKey:H,handleSetValue:pe,isValidStorage:V,Manager:b,removeAll:Ve};function S(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function w(e){if(e instanceof RegExp)return true;if(!e||typeof e!="object"||!Object.prototype.toString.call(e).includes("RegExp"))return false;try{return new RegExp(e),!0}catch(r){return false}}function E(e){return !e||typeof e!="object"?false:e instanceof Date?true:typeof e.getTime!="function"?false:!(Object.prototype.toString.call(e)!=="[object Date]"||isNaN(e.getTime()))}function U(e){return typeof window!="object"||!window||typeof document=="undefined"||typeof HTMLElement=="undefined"||!HTMLElement?false:e===document?true:"HTMLElement"in window?!!e&&e instanceof HTMLElement:!!e&&typeof e=="object"&&e.nodeType===1&&!!e.nodeName}function m(e){if(e===null||typeof e!="object"||U(e)||E(e)||w(e)||S(e))return false;let r=Object.getPrototypeOf(e);if(r===null)return true;let t=r.constructor;if(typeof t!="function")return false;if(t===Object)return true;let a=t.prototype;return typeof a!="object"?false:a===Object.prototype?true:typeof r.hasOwnProperty=="function"&&Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")&&typeof r.isPrototypeOf=="function"}function Z(e){if(Array.isArray(e)){let a=[];for(var r=0;r<e.length;r++)a[r]=Z(e[r]);return a}else if(m(e)&&e){let a={};for(var t in e)e.hasOwnProperty(t)&&(a[t]=Z(e[t]));return a}else return e}Object.getSize=function(e,r=false){if(!e||typeof e!="object")return 0;if(Array.isArray(e))return e.length;typeof r!="boolean"&&(r=false);let t=0;for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&(t++,r===true))return t;return t};function I(e,...r){let t=Array.isArray(e),a=m(e);(e==null||!t&&!a)&&(e={});for(let i=0;i<r.length;i++){let n=r[i];if(n==null)continue;let o=m(n),d=Array.isArray(n);if(!(!o&&!d)){if(t){d&&he(e,n);continue}else if(d)continue;for(let c in n){let l=n[c];if(l==null)continue;if(l===n){e[c]=e;continue}let y=e[c],h=Array.isArray(y),M=Array.isArray(l);if(h){M?he(e[c],l):e[c]=l;continue}else if(!m(y)){e[c]=l;continue}if(M||!m(l)){e[c]=l;continue}e[c]=I({},y,l);}}}return e}var he=(e,r)=>{let t=r.length,a=0;for(let i=0;i<e.length;i++){let n=e[i],o=r[i];if(i<t){let d=Array.isArray(n),c=Array.isArray(o),l=m(n),y=m(o);d&&c||l&&y?(e[a]=I(d?[]:{},n,o),a++):o!=null?(e[a]=o,a++):n!=null&&(e[a]=n,a++);}}for(let i=e.length;i<t;i++)r[i]!==void 0&&r[i]!==null&&e.push(r[i]);return e};function We(e,r){return F(e,"",{},r)}function F(e,r="",t={},a){if(t=m(t)?t:{},S(e)||E(e)||w(e)||Array.isArray(e)&&(a!=null&&a.skipArrays))return r&&(t[r]=e),t;if(typeof e=="function"||typeof e=="object"&&!m(e)&&!Ue(e))return t;if(e instanceof Map||e instanceof WeakMap)return Array.from(e.entries()).forEach(([i,n])=>{let o=r?`${r}[${String(i)}]`:String(i);F(n,o,t,a);}),t;if(Array.isArray(e)||e instanceof Set||e instanceof WeakSet)return (Array.isArray(e)?e:Array.from(e)).forEach((n,o)=>{let d=r?`${r}[${o}]`:String(o);F(n,d,t,a);}),t;if(m(e))for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let n=e[i],o=r?r.endsWith("]")?`${r}.${i}`:`${r}.${i}`:i;F(n,o,t,a);}return t}function Ue(e){return Array.isArray(e)||e instanceof Set||e instanceof Map||e instanceof WeakMap||e instanceof WeakSet}function Ze(e){return Object.entries(e)}Object.typedEntries=Ze;Object.flatten=We;Object.clone=Z;function L(e,r){if(e==null)return "";if(typeof e=="string")return e;if((typeof e=="number"||typeof e=="object"&&e instanceof Number)&&typeof e.formatNumber=="function")return e.formatNumber();if(e instanceof Date||typeof e=="object"&&e!==null&&e.constructor===Date)return typeof e.toFormat=="function"?e.toFormat():e.toISOString();if(e instanceof Error)return `Error: ${e.message}`;if(w(e))return e.toString();if(S(e))return String(e);if(Array.isArray(e))return JSON.stringify(e);if(typeof e=="object"&&e!==null){if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString)return e.toString();if(typeof e.toString=="function"){let t=e.toString();if(t!=="[object Object]")return t}return JSON.stringify(e)}return typeof(e==null?void 0:e.toString)=="function"?e.toString():String(e)}function be(e,r,t){let a=L,i=f(e);if(!m(r)||!r)return i;let n=/%\{([^}]+)\}/g,o=new Set,d,c=f(e);for(;(d=n.exec(c))!==null;){let l=d[1];l!==void 0&&o.add(l);}return o.forEach(l=>{let y;y=`%{${l}}`;let h=Object.prototype.hasOwnProperty.call(r,l)?r[l]:void 0,M=h===void 0?"":(()=>{try{return a(h,l,L)}catch($){return L(h)}})(),Se=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i=i.replace(new RegExp(Se,"g"),M);}),i}function z(e){return !!(e==null||typeof e=="number"&&isNaN(e)||typeof e=="string"&&e.trim()==="")}function T(e){return typeof e=="number"&&!isNaN(e)&&isFinite(e)}function ze(e){return f(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f")}function k(e,r){var t=Object.prototype.toString.call(e);return t==="[object "+r+"]"}function A(e,r){if(["boolean","undefined"].includes(typeof e)||e===null)return String(e);if(T(e))return e.formatNumber();if(e instanceof Date)return e.toFormat();if(e instanceof Error)return e==null?void 0:e.toString();r=Object.assign({},r);let{parenthesis:t}=r,a=t?"(":"",i=t?")":"";return typeof e=="string"?(r==null?void 0:r.escapeString)!==false?"'"+ze(e)+"'":e:k(e,"RegExp")||k(e,"Number")||k(e,"Boolean")?e.toString():k(e,"Date")?"new Date("+e.getTime()+")":Array.isArray(e)?"["+e.map(n=>A(n,r)).join(",")+"]":typeof e=="object"?a+"{"+Object.keys(e).map(n=>{var o=e[n];return A(n,r)+":"+A(o,r)}).join(",")+"}"+i:e&&typeof(e==null?void 0:e.toString)=="function"?e==null?void 0:e.toString():String(e)}var Ce=Symbol("TRANSLATION_KEY");var p=class p extends i18nJs.I18n{constructor(t={},a={}){super({},a);this._isLoading=false;this._locales=[];this.namespaceResolvers={};this._observableFactory=re();this._____isObservable=true;this.hasRegisteredDefaultTranslations=false;this._namespacesLoaded={};this.hasRegisteredDefaultTranslations||(this.registerTranslations(K),this.hasRegisteredDefaultTranslations=true),this.registerTranslations(t),this.loadNamespaces();}static[Symbol.hasInstance](t){return this.isI18nInstance(t)}static isI18nInstance(t){if(!t||typeof t!="object")return false;try{if(t instanceof i18nJs.I18n)return !0}catch(a){}return typeof t.getLocale=="function"&&typeof t.translate=="function"&&typeof t.translateTarget=="function"}translate(t,a){return this.isPluralizeOptions(a)&&this.canPluralize(t)?(typeof a.count=="number"&&(a.countStr=a.count.formatNumber()),this.pluralize(a.count,t,a)):super.translate(t,a)}translateTarget(t,a){let i=p.getTargetTanslationKeys(t);for(let n in i)u(i[n])&&(i[n]=this.translate(i[n],a));return i}translateObject(t,a){if(!m(t))return {};let i={};for(let n in t){let o=t[n];u(o)&&(i[n]=Me.translate(o,a));}return i}static getTargetTanslationKeys(t){return ae(t,Ce)}on(t,a){return this._observableFactory.on.call(this,t,a)}finally(t,a){return this._observableFactory.finally.call(this,t,a)}off(t,a){var i;return (i=this._observableFactory)==null?void 0:i.off.call(this,t,a)}trigger(t,...a){var i;return (i=this._observableFactory)==null?void 0:i.trigger.call(this,t,...a)}offAll(){var t;return (t=this._observableFactory)==null?void 0:t.offAll.call(this)}once(t,a){var i;return (i=this._observableFactory)==null?void 0:i.once.call(this,t,a)}getEventCallBacks(){var t;return (t=this._observableFactory)==null?void 0:t.getEventCallBacks.call(this)}static getInstance(t){if(!this.isI18nInstance(p.instance)){let a=p.getLocaleFromSession();p.instance=this.createInstance({},Object.assign({},a?{locale:a}:{},t));}return p.instance}isDefaultInstance(){return this===p.instance}static setLocaleToSession(t){W.set("i18n.locale",t);}static getLocaleFromSession(){let t=W.get("i18n.locale");return u(t)?t:""}canPluralize(t,a){a=f(a,this.getLocale());let i=this.getNestedTranslation(t,a);return !m(i)||!i?false:u(i==null?void 0:i.one)&&u(i==null?void 0:i.other)}getNestedTranslation(t,a){a=f(a,this.getLocale());let i=(u(t)?t.trim().split("."):Array.isArray(t)?t:[]).filter(u);if(!i.length)return;let n=this.getTranslations(a);for(let o of i)if(m(n))n=n[o];else return;return n}isPluralizeOptions(t){return !!(m(t)&&t&&typeof t.count=="number")}static RegisterTranslations(t){return p.getInstance().registerTranslations(t)}static createInstance(t={},a={}){let d=Object.assign({},a),{interpolate:i}=d,n=te(d,["interpolate"]),o=new p(t,n);return o.interpolate=(c,l,y)=>{let h=p.flattenObject(y),M=this.defaultInterpolator(c,l,h);return u(M)&&M!==l&&(l=M),typeof i=="function"?i(c,l,y):be(l,y)},o}getTranslations(t){let a=m(this.translations)?this.translations:{};return u(t)?m(a[t])?a[t]:{}:a}static registerMomentLocale(t,a){return u(t)&&m(a)&&Array.isArray(a.months)&&(this.momentLocales[t]=I({},this.momentLocales[t],a)),this.momentLocales}static getMomentLocale(t){return this.momentLocales[t]}static setMomentLocale(t){try{return v__default.default.updateLocale(t,this.getMomentLocale(t)),!0}catch(a){console.error(a," setting moment locale : ",t);}return false}registerTranslations(t){return this.store(t),this.getTranslations()}store(t){super.store(t),this.trigger("translations-changed",this.getLocale(),this.getTranslations());}resolveTranslations(t){try{let a=Object.getOwnPropertyNames(t);for(let i of a){let n=Reflect.getMetadata(Ce,t,i);if(n)try{t[i]=this.translate(n);}catch(o){N.error(o," resolving translation for key : ",n);}}}catch(a){N.error(a," resolving translations for target : ",t);}}getMissingPlaceholderString(t,a,i){return typeof this.missingPlaceholder=="function"?this.missingPlaceholder(this,t,f(a),Object.assign({},i)):t}getLocale(){return super.locale}setLocales(t){return this._locales=Array.isArray(t)?t:["en"],this._locales.includes("en")||this._locales.push("en"),this.getLocales()}hasLocale(t){return u(t)&&this.getLocales().includes(t)}getLocales(){let t=Object.keys(this.getTranslations()),a=Array.isArray(this._locales)?this._locales:["en"],i=[...t,...a.filter(n=>!t.includes(n))];return i.includes("en")||i.push("en"),i}isLocaleSupported(t){return u(t)?this.getLocales().includes(t):false}isLoading(){return this._isLoading}setLocale(t,a=false){return super.locale===t&&a!==true&&this._namespacesLoaded[t]?Promise.resolve(this.getLocale()):new Promise((i,n)=>(this._isLoading=true,this.trigger("namespaces-before-load",t),this.loadNamespaces(t).then(o=>{this.isDefaultInstance()&&(p.instance=this,this.isLocaleSupported(t)&&p.setLocaleToSession(t)),super.locale=t,p.setMomentLocale(t),this.trigger("locale-changed",t,o),i(t);}).catch(n).finally(()=>{this._isLoading=false;})))}registerNamespaceResolver(t,a){if(!u(t)||typeof a!="function"){console.warn("Invalid arguments for registerNamespaceResolver.",t,a);return}this.namespaceResolvers[t]=a;}static RegisterNamespaceResolver(t,a){return p.getInstance().registerNamespaceResolver(t,a)}loadNamespace(t,a,i=true){return !u(t)||!this.namespaceResolvers[t]?Promise.reject(new Error(`Invalid namespace or resolver for namespace "${t}".`)):(a=f(a,this.getLocale()),u(a)?this.namespaceResolvers[t](a).then(n=>{let o={};return o[a]=Object.assign({},n),m(n)&&(i!==false&&this.store(o),this.trigger("namespace-loaded",t,a,o)),o}):Promise.reject(new Error(`Locale is not set. Cannot load namespace "${t}".`)))}static LoadNamespace(t,a,i=true){return p.getInstance().loadNamespace(t,a,i)}loadNamespaces(t,a=true){let i=[],n={};t=f(t,this.getLocale()),this._isLoading=true;for(let o in this.namespaceResolvers)Object.prototype.hasOwnProperty.call(this.namespaceResolvers,o)&&typeof this.namespaceResolvers[o]=="function"&&i.push(new Promise(d=>{this.namespaceResolvers[o](t).then(c=>{I(n,c);}).finally(()=>{d(true);});}));return Promise.all(i).then(()=>{let o={};return o[t]=n,a!==false&&this.store(o),setTimeout(()=>{this.trigger("namespaces-loaded",t,o);},100),o}).finally(()=>{this._isLoading=false;})}static LoadNamespaces(t,a=true){return p.getInstance().loadNamespaces(t,a)}static flattenObject(t){return m(t)?Object.flatten(t):t}static defaultInterpolator(t,a,i){return z(a)?"":S(a)?(a=String(a),!m(i)||!i||!m(i)||!i?a:a.replace(/%{(.*?)}/g,(n,o)=>z(i[o])?"":S(i[o])?String(i[o]):A(i[o],{escapeString:false}))):A(a,{escapeString:false})}};p.momentLocales={};var Y=p,Me=Y.getInstance();try{Object.setPrototypeOf(Me,Y.prototype);}catch(e){}function J(e){return !!(e==null||typeof e=="undefined"||typeof e=="string"&&e===""||Array.isArray(e)&&!e.length)}var s=class s{static parseString(r,t){if(u(r)&&u(t))try{let a=v__default.default(r,t,!0);if(a.isValid())return {date:a.toDate(),matchedFormat:t,isValid:!0}}catch(a){}try{if(Array.isArray(t)&&(t!=null&&t.length))for(let a of t){let i=De(r,a);if(i)return i}for(let a of s.DATE_FORMATS){let i=De(r,a);if(i)return i}return {date:null,matchedFormat:null,isValid:!1,error:"Unable to parse date string with any known format"}}catch(a){return {date:null,matchedFormat:null,isValid:false,error:a instanceof Error?a.message:"Unknown error occurred while parsing date"}}}static toIsoString(r){let t=r?s.parseDate(r):new Date;return t?t.toISOString():""}static isoStringToDate(r){return new Date(r)}static parseDate(r,t){if(s.isDateObj(r))return r;if(!u(t)){let a=s.parseString(r);return a!=null&&a.isValid?a.date:null}if(J(r))return null;try{let a=v__default.default(r,t,!0);if(a!=null&&a.isValid())return a.toDate()}catch(a){console.error(a," parsing date with moment : ",r," format is : ",t);}return null}static toSQLDateTimeFormat(r){if(!s.isDateObj(r))return "";let t=r.getFullYear(),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0"),n=String(r.getHours()).padStart(2,"0"),o=String(r.getMinutes()).padStart(2,"0"),d=String(r.getSeconds()).padStart(2,"0");return `${t}-${a}-${i} ${n}:${o}:${d}`}static getI18n(r){return Y.isI18nInstance(r)?r:Y.getInstance()}static getDefaultDateTimeFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultDateTimeFormat"),"YYYY-MM-DD HH:mm")}static getDefaultDateFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultDateFormat"),"YYYY-MM-DD")}static toSQLDateFormat(r){if(!s.isDateObj(r))return "";let t=r.getFullYear(),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0");return `${t}-${a}-${i}`}static toSQLTimeFormat(r){if(!s.isDateObj(r))return "";let t=String(r.getHours()).padStart(2,"0"),a=String(r.getMinutes()).padStart(2,"0"),i=String(r.getSeconds()).padStart(2,"0");return `${t}:${a}:${i}`}static getDefaultTimeFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultTimeFormat"),"HH:mm")}static isValidDate(r,t){if(r==null||typeof r=="boolean")return false;if(s.isDateObj(r))return true;if(T(r)){let i=new Date(r);return i&&!isNaN(i.getTime())}if(u(r))return !!s.parseDate(r,t);if(r!=null&&r.toString&&(r==null?void 0:r.toString())==parseInt(r).toString())return false;let a=new Date(r);return s.isDateObj(a)}static addToDate(r,t,a){if(T(r)||(r=0),J(t)&&(t=new Date),s.isValidDate(t)&&u(t)&&(t=new Date(t)),s.isValidDate(t)||(t=u(t)?new Date(t):new Date),u(a)&&typeof t["set"+a]=="function"&&typeof t["get"+a]=="function"){let i="set"+a,n="get"+a;t=new Date(t[i](t[n]()+r));}return t}static addDays(r,t){return s.addToDate(r,t,"Date")}static addMilliseconds(r,t){return T(r)||(r=0),s.isDateObj(t)||(t=new Date),t=t||new Date,new Date(t.getTime()+r)}static addSeconds(r,t){return T(r)||(r=0),s.addMilliseconds(r*1e3,t)}static addMinutes(r,t){return T(r)||(r=0),s.addMilliseconds(r*6e4,t)}static addHours(r,t){return T(r)||(r=0),s.addMilliseconds(r*36e5,t)}static addMonths(r,t,a){return s.addToDate(r,t,"Month")}static addWeeks(r,t){return r=(T(r)?r:0)*7,s.addToDate(r,t,"Date")}static addYears(r,t){T(r)||(r=0);let a=new Date(s.addToDate(0,t)),i=a.getFullYear();return i+r<0?r=0:r+=i,a.setFullYear(r),new Date(a)}static formatDate(r,t){try{let a=v__default.default(r);if(a.isValid())return a.format(f(t,s.getDefaultDateTimeFormat()))}catch(a){}return f(s.isValidDate(r)?r==null?void 0:r.toString():"")}static getUTCDateTimeDetails(r){let t=r?v__default.default.utc(r):v__default.default.utc();return {year:t.year(),day:t.day(),month:t.month(),monthString:t.format("MM"),hours:t.hours(),date:t.date(),minutes:t.minutes(),seconds:t.seconds(),monthName:t.format("MMMM"),dayName:t.format("dddd"),dayNameShort:t.format("ddd")}}};s.DATE_FORMATS=["YYYY-MM-DD","YYYY-MM-DDTHH:mm:ss","YYYY-MM-DDTHH:mm:ssZ","YYYY-MM-DDTHH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss[Z]","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DDTHH:mm:ss.SSSZ ","YYYY-MM-DDTHH:mm:ss.SSS","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DD HH:mm:ssZ","YYYY-MM-DD HH:mmZ","MM/DD/YYYY","MM-DD-YYYY","MM.DD.YYYY","MM/DD/YY","MMMM DD, YYYY","MMM DD, YYYY","DD/MM/YYYY","DD-MM-YYYY","DD.MM.YYYY","DD/MM/YY","DD MMMM YYYY","DD MMM YYYY","HH:mm:ss.SSSZ","HH:mm:ssZ","HH:mmZ","YYYYMMDD","YYYYMMDDTHHMM","YYYYMMDDTHHMMSS","HH:mm:ss","HH:mm","hh:mm A","h:mm A","HH:mm:ss.SSS","YYYY-DDD","YYYY-Www","YYYY-Www-D","YYYY/MM/DD","YYYY.MM.DD","MMM D, YYYY","MMMM D, YYYY","D MMM YYYY","D MMMM YYYY","MMM D YYYY","ddd, DD MMM YYYY HH:mm:ss ZZ","ddd, DD MMM YYYY HH:mm:ss","dddd, MMMM D, YYYY","dddd, D MMMM YYYY","hh:mm:ss A","H:mm:ss","YYYY-[W]WW","YYYY-[W]WW-E","YYYY-MM-DDTHH:mm:ss.SSS","DD-MM-YYYY HH:mm:ss","YYYY/MM/DD HH:mm:ss","YYYY.MM.DD HH:mm:ss","DD/MM/YYYY HH:mm:ss","MMM D YYYY, h:mm a","MMMM D YYYY, h:mm a","h:mm A MMM D, YYYY","MMMM D, YYYY","YY-MM-DD","DD-MM-YY","MM/DD/YY","MMM DD, YY","D MMM YY","D MMMM YY","YYYY MMM D","YYYY-MM-DD HH:mm","YYYY-MM-DD HH:mm:ss.SSS"],s.SQL_DATE_FORMAT="YYYY-MM-DD",s.SQL_DATE_TIME_FORMAT="YYYY-MM-DD HH:mm:ss",s.SQL_TIME_FORMAT="HH:mm:ss",s.getCurrentMonthDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=new Date(t.getFullYear(),t.getMonth(),1),i=new Date(t.getFullYear(),t.getMonth()+1,0);return {first:a,last:i}},s.getPreviousWeekDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=new Date(t.getTime()-3600*24*7*1e3),i=new Date(a),n=a.getDay(),o=a.getDate()-n+(n===0?-6:1),d=new Date(a.setDate(o)),c=new Date(i.setDate(o+6));return {first:d,last:c}},s.getCurrentWeekDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=t.getDay(),i=t.getDate()-a+(a==0?-6:1),n=new Date(t),o=new Date(t.setDate(i));return n.setDate(n.getDate()+6),{first:o,last:n}},s.isDateObj=E;var g=s,De=(e,r)=>{let t=v__default.default(e,r,true);try{if(t.isValid()&&t.format(r)===e||v__default.default.utc(t,!0).format(r)===e)return {date:t.toDate(),matchedFormat:r,isValid:!0}}catch(a){}return null};exports.DateHelper=g;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
%{failedRulesErrors}`,oneOf:`The field %{fieldName} must match at least one of the following validation rules:
|
|
3
3
|
%{failedRulesErrors}`,allOf:`The field %{fieldName} must match all of the following validation rules:
|
|
4
4
|
%{failedRulesErrors}`,validateNested:`The field %{fieldName} must be a valid nested object. Errors:
|
|
5
|
-
%{nestedErrors}`,validateNestedInvalidType:"The field %{fieldName} must be an object, but received %{receivedType}",dateAfter:"This field must be after %{date}",dateBefore:"This field must be before %{date}",dateBetween:"This field must be between %{startDate} and %{endDate}",dateEquals:"This field must be equal to %{date}",futureDate:"This field must be a date in the future",pastDate:"This field must be a date in the past",file:"This field must be a valid file",fileSize:"This field must not exceed %{maxSize} bytes",fileType:"This field must be one of the following types: %{allowedTypes}",image:"This field must be a valid image file",fileExtension:"This field must have one of the following extensions: %{allowedExtensions}",minFileSize:"This field must be at least %{minSize} bytes",uuid:"This field must be a valid UUID",json:"This field must be valid JSON",base64:"This field must be valid Base64 encoded data",hexColor:"This field must be a valid hexadecimal color code",creditCard:"This field must be a valid credit card number",ip:"This field must be a valid IP address (version %{version})",macAddress:"This field must be a valid MAC address",matches:"This field must match the pattern %{pattern}",tests:{entity:{name:"Name",id:"Id",email:"Email",aString:"A String",url:"Url",note:"Note",createdAt:"Created At",updatedAt:"Updated At"}}};var Ee={auth:ne,currencies:oe,countries:ie,dates:se,resources:de,validator:le};function u(e){return !!(e&&typeof e=="string")}function f(...e){for(var r in e){let t=e[r];if(u(t))return t}return ""}var C=class C{static get logger(){let r=Reflect.getMetadata(C.loggerMetaData,C);return ce(r)&&(this._logger=r),this._logger?this._logger:console}static set logger(r){ce(r)&&Reflect.defineMetadata(C.loggerMetaData,r,C);}static _log(r,...t){let a=C.logger;r=f(r),r&&typeof a[r]=="function"?a[r](C.getDateTimeString(),...t):console.log("Logger level not found : [",r,"]",...t);}static getDateTimeString(){let{day:r,year:t,hours:a,minutes:i,seconds:n,dayNameShort:o,monthName:d}=g.getUTCDateTimeDetails(),c=r<10?"0"+r:r,l=a<10?"0"+a:a,y=i<10?"0"+i:i,h=n<10?"0"+n:n;return "["+[o,c,d,t].join(" ")+" "+[l,y,h].join(":")+"]"}static log(...r){this._log("log",...r);}static info(...r){this._log("info",...r);}static debug(...r){this._log("debug",...r);}static warn(...r){this._log("warn",...r);}static error(...r){this._log("error",...r);}};C.loggerMetaData=Symbol("logger-meta-data");var N=C,ce=e=>{if(!e)return false;try{return ["warn","info","error"].every(r=>typeof e[r]=="function")}catch(r){return false}};function Ie(e){return typeof e=="boolean"||!e||typeof e=="number"||typeof e=="string"||typeof e=="symbol"?false:Object(e).constructor===Promise||e.constructor&&(e.constructor.name==="Promise"||e.constructor.name==="AsyncFunction")||e instanceof Promise||typeof(e==null?void 0:e.then)=="function"&&typeof(e==null?void 0:e.catch)=="function"&&typeof(e==null?void 0:e.finally)=="function"?true:e&&typeof e.constructor=="function"&&Function.prototype.toString.call(e.constructor).replace(/\(.*\)/,"()")===Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()")}function ue(e){return e&&Object.prototype.toString.call(e)==="[object Promise]"?true:Ie(e)}function me(){return typeof window!="undefined"&&(window==null?void 0:window.document)!==void 0&&typeof document!="undefined"&&typeof navigator!="undefined"}var x=()=>{var e;try{if(typeof process!="undefined"&&(process!=null&&process.versions)&&((e=process==null?void 0:process.versions)!=null&&e.node)||typeof global=="object"&&(global==null?void 0:global.toString.call(global))==="[object global]")return !0}catch(r){}return false},Le=()=>{var e,r;return !!(typeof window!="undefined"&&window&&typeof(window==null?void 0:window.process)=="object"&&((e=window==null?void 0:window.process)==null?void 0:e.type)==="renderer"||typeof process!="undefined"&&typeof(process==null?void 0:process.versions)=="object"&&((r=process.versions)!=null&&r.electron)||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&String(navigator==null?void 0:navigator.userAgent).toLowerCase().indexOf("electron")>=0)},Pe=()=>{if(typeof document!="undefined"&&document)try{return document.createEvent("TouchEvent"),!0}catch(e){try{return "ontouchstart"in window||"onmsgesturechange"in window}catch(r){}}return false},Re=()=>typeof window=="undefined"&&typeof process!="undefined",fe=()=>!!(typeof window!="undefined"&&typeof window=="object"&&window),xe=()=>{if(!me()||typeof navigator!="object"||!navigator||typeof navigator.userAgent!="string")return false;let e=navigator.userAgent.toLowerCase();return /android/i.test(e)},He=()=>{var e;return !fe()||!(window!=null&&window.ReactNativeWebView)?false:typeof((e=window==null?void 0:window.ReactNativeWebView)==null?void 0:e.postMessage)=="function"},Fe=()=>x()&&process.platform==="darwin",ke=()=>x()&&process.platform==="win32",Be=()=>x()&&process.platform==="linux",ye={isWeb:me,isLinux:Be,isDarwin:Fe,isWin32:ke,isNode:x,isElectron:Le,isTouchDevice:Pe,isServerSide:Re,isClientSide:fe,isAndroidMobileBrowser:xe,isReactNativeWebview:He};var O=class e{static decycle(r,t=[]){if(typeof r=="function")return;if(!r||typeof r!="object")return r;if(t.includes(r))return null;let a=t.concat([r]);return Array.isArray(r)?r.map(i=>e.decycle(i,a)):Object.fromEntries(Object.entries(r).map(([i,n])=>[i,e.decycle(n,a)]))}static stringify(r,t=false){return typeof r=="string"?r:JSON.stringify(t!==false?e.decycle(r):r)}static isJSON(r){if(typeof r!="string")return false;let t=r.trim();if(t.length===0)return false;let a=t[0];if(a!=="{"&&a!=="[")return false;try{let i=JSON.parse(t);return i!==null&&typeof i=="object"}catch(i){return false}}static parse(r,t){if(typeof r=="string")try{r=JSON.parse(r,t);}catch(a){return r}if(r&&typeof r=="object")for(let a in r){let i=r[a];e.isJSON(i)&&(r[a]=e.parse(i,t));}return r}};var D=class D{static get storage(){var t;let r=Reflect.getMetadata(D.sessionStorageMetaData,D);if(V(r)&&(this._storage=r),this._storage)return this._storage;if(ye.isClientSide()&&typeof window!="undefined"&&window.localStorage&&((t=window.localStorage)!=null&&t.getItem))this._storage={get:a=>window.localStorage.getItem(a),set:(a,i)=>window.localStorage.setItem(a,i),remove:a=>window.localStorage.removeItem(a),removeAll:()=>window.localStorage.clear()};else {let a={};this._storage={get:i=>a[i],set:(i,n)=>a[i]=n,remove:i=>{delete a[i];},removeAll:()=>a={}};}return this._storage}static set storage(r){V(r)&&Reflect.defineMetadata(D.sessionStorageMetaData,r,D);}static get keyNamespace(){return u(this._keyNamespace)?this._keyNamespace:""}static set keyNamespace(r){u(r)&&(this._keyNamespace=r.trim().replace(/\s+/g,"-"));}static sanitizeKey(r){if(!r||!u(r))return "";r=r.trim().replace(/\s+/g,"-");let t=this.keyNamespace;return t?`${t}-${r}`:r}};D.sessionStorageMetaData=Symbol("sessionStorage"),D._keyNamespace=void 0;var b=D;function H(e){return b.sanitizeKey(e)}var pe=(e,r)=>(e=e&&O.stringify(e,r),e==null&&(e=""),e),ge=e=>{if(ue(e))return new Promise((r,t)=>{e.then(a=>{r(O.parse(a));}).catch(a=>{t(a);});});if(e!=null)return O.parse(e)},Ge=e=>{if(e=H(e),b.storage&&e&&typeof e=="string"){let r=b.storage.get(e);return ge(r)}},Ke=e=>{if(e=H(e),b.storage&&e&&typeof e=="string")return b.storage.remove(e)},Ve=()=>{if(b.storage)return b.storage.removeAll()},V=e=>{if(!e)return false;try{return ["get","set","remove","removeAll"].every(r=>typeof e[r]=="function")}catch(r){return false}},W={get:Ge,set:(e,r,t=true)=>(e=H(e),b.storage.set(e,pe(r,t))),remove:Ke,handleGetValue:ge,sanitizeKey:H,handleSetValue:pe,isValidStorage:V,Manager:b,removeAll:Ve};function S(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function w(e){if(e instanceof RegExp)return true;if(!e||typeof e!="object"||!Object.prototype.toString.call(e).includes("RegExp"))return false;try{return new RegExp(e),!0}catch(r){return false}}function E(e){return !e||typeof e!="object"?false:e instanceof Date?true:typeof e.getTime!="function"?false:!(Object.prototype.toString.call(e)!=="[object Date]"||isNaN(e.getTime()))}function U(e){return typeof window!="object"||!window||typeof document=="undefined"||typeof HTMLElement=="undefined"||!HTMLElement?false:e===document?true:"HTMLElement"in window?!!e&&e instanceof HTMLElement:!!e&&typeof e=="object"&&e.nodeType===1&&!!e.nodeName}function m(e){if(e===null||typeof e!="object"||U(e)||E(e)||w(e)||S(e))return false;let r=Object.getPrototypeOf(e);if(r===null)return true;let t=r.constructor;if(typeof t!="function")return false;if(t===Object)return true;let a=t.prototype;return typeof a!="object"?false:a===Object.prototype?true:typeof r.hasOwnProperty=="function"&&Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")&&typeof r.isPrototypeOf=="function"}function Z(e){if(Array.isArray(e)){let a=[];for(var r=0;r<e.length;r++)a[r]=Z(e[r]);return a}else if(m(e)&&e){let a={};for(var t in e)e.hasOwnProperty(t)&&(a[t]=Z(e[t]));return a}else return e}Object.getSize=function(e,r=false){if(!e||typeof e!="object")return 0;if(Array.isArray(e))return e.length;typeof r!="boolean"&&(r=false);let t=0;for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&(t++,r===true))return t;return t};function I(e,...r){let t=Array.isArray(e),a=m(e);(e==null||!t&&!a)&&(e={});for(let i=0;i<r.length;i++){let n=r[i];if(n==null)continue;let o=m(n),d=Array.isArray(n);if(!(!o&&!d)){if(t){d&&he(e,n);continue}else if(d)continue;for(let c in n){let l=n[c];if(l==null)continue;if(l===n){e[c]=e;continue}let y=e[c],h=Array.isArray(y),M=Array.isArray(l);if(h){M?he(e[c],l):e[c]=l;continue}else if(!m(y)){e[c]=l;continue}if(M||!m(l)){e[c]=l;continue}e[c]=I({},y,l);}}}return e}var he=(e,r)=>{let t=r.length,a=0;for(let i=0;i<e.length;i++){let n=e[i],o=r[i];if(i<t){let d=Array.isArray(n),c=Array.isArray(o),l=m(n),y=m(o);d&&c||l&&y?(e[a]=I(d?[]:{},n,o),a++):o!=null?(e[a]=o,a++):n!=null&&(e[a]=n,a++);}}for(let i=e.length;i<t;i++)r[i]!==void 0&&r[i]!==null&&e.push(r[i]);return e};function We(e,r){return F(e,"",{},r)}function F(e,r="",t={},a){if(t=m(t)?t:{},S(e)||E(e)||w(e)||Array.isArray(e)&&(a!=null&&a.skipArrays))return r&&(t[r]=e),t;if(typeof e=="function"||typeof e=="object"&&!m(e)&&!Ue(e))return t;if(e instanceof Map||e instanceof WeakMap)return Array.from(e.entries()).forEach(([i,n])=>{let o=r?`${r}[${String(i)}]`:String(i);F(n,o,t,a);}),t;if(Array.isArray(e)||e instanceof Set||e instanceof WeakSet)return (Array.isArray(e)?e:Array.from(e)).forEach((n,o)=>{let d=r?`${r}[${o}]`:String(o);F(n,d,t,a);}),t;if(m(e))for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let n=e[i],o=r?r.endsWith("]")?`${r}.${i}`:`${r}.${i}`:i;F(n,o,t,a);}return t}function Ue(e){return Array.isArray(e)||e instanceof Set||e instanceof Map||e instanceof WeakMap||e instanceof WeakSet}function Ze(e){return Object.entries(e)}Object.typedEntries=Ze;Object.flatten=We;Object.clone=Z;function L(e,r){if(e==null)return "";if(typeof e=="string")return e;if((typeof e=="number"||typeof e=="object"&&e instanceof Number)&&typeof e.formatNumber=="function")return e.formatNumber();if(e instanceof Date||typeof e=="object"&&e!==null&&e.constructor===Date)return typeof e.toFormat=="function"?e.toFormat():e.toISOString();if(e instanceof Error)return `Error: ${e.message}`;if(w(e))return e.toString();if(S(e))return String(e);if(Array.isArray(e))return JSON.stringify(e);if(typeof e=="object"&&e!==null){if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString)return e.toString();if(typeof e.toString=="function"){let t=e.toString();if(t!=="[object Object]")return t}return JSON.stringify(e)}return typeof(e==null?void 0:e.toString)=="function"?e.toString():String(e)}function be(e,r,t){let a=L,i=f(e);if(!m(r)||!r)return i;let n=/%\{([^}]+)\}/g,o=new Set,d,c=f(e);for(;(d=n.exec(c))!==null;){let l=d[1];l!==void 0&&o.add(l);}return o.forEach(l=>{let y;y=`%{${l}}`;let h=Object.prototype.hasOwnProperty.call(r,l)?r[l]:void 0,M=h===void 0?"":(()=>{try{return a(h,l,L)}catch($){return L(h)}})(),Se=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i=i.replace(new RegExp(Se,"g"),M);}),i}function z(e){return !!(e==null||typeof e=="number"&&isNaN(e)||typeof e=="string"&&e.trim()==="")}function T(e){return typeof e=="number"&&!isNaN(e)&&isFinite(e)}function ze(e){return f(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f")}function k(e,r){var t=Object.prototype.toString.call(e);return t==="[object "+r+"]"}function A(e,r){if(["boolean","undefined"].includes(typeof e)||e===null)return String(e);if(T(e))return e.formatNumber();if(e instanceof Date)return e.toFormat();if(e instanceof Error)return e==null?void 0:e.toString();r=Object.assign({},r);let{parenthesis:t}=r,a=t?"(":"",i=t?")":"";return typeof e=="string"?(r==null?void 0:r.escapeString)!==false?"'"+ze(e)+"'":e:k(e,"RegExp")||k(e,"Number")||k(e,"Boolean")?e.toString():k(e,"Date")?"new Date("+e.getTime()+")":Array.isArray(e)?"["+e.map(n=>A(n,r)).join(",")+"]":typeof e=="object"?a+"{"+Object.keys(e).map(n=>{var o=e[n];return A(n,r)+":"+A(o,r)}).join(",")+"}"+i:e&&typeof(e==null?void 0:e.toString)=="function"?e==null?void 0:e.toString():String(e)}var Ce=Symbol("TRANSLATION_KEY");var p=class p extends i18nJs.I18n{constructor(t={},a={}){super({},a);this._isLoading=false;this._locales=[];this.namespaceResolvers={};this._observableFactory=re();this._____isObservable=true;this.hasRegisteredDefaultTranslations=false;this._namespacesLoaded={};this.hasRegisteredDefaultTranslations||(this.registerTranslations(K),this.hasRegisteredDefaultTranslations=true),this.registerTranslations(t),this.loadNamespaces();}static[Symbol.hasInstance](t){return this.isI18nInstance(t)}static isI18nInstance(t){if(!t||typeof t!="object")return false;try{if(t instanceof i18nJs.I18n)return !0}catch(a){}return typeof t.getLocale=="function"&&typeof t.translate=="function"&&typeof t.translateTarget=="function"}translate(t,a){return this.isPluralizeOptions(a)&&this.canPluralize(t)?(typeof a.count=="number"&&(a.countStr=a.count.formatNumber()),this.pluralize(a.count,t,a)):super.translate(t,a)}translateTarget(t,a){let i=p.getTargetTanslationKeys(t);for(let n in i)u(i[n])&&(i[n]=this.translate(i[n],a));return i}translateObject(t,a){if(!m(t))return {};let i={};for(let n in t){let o=t[n];u(o)&&(i[n]=Me.translate(o,a));}return i}static getTargetTanslationKeys(t){return ae(t,Ce)}on(t,a){return this._observableFactory.on.call(this,t,a)}finally(t,a){return this._observableFactory.finally.call(this,t,a)}off(t,a){var i;return (i=this._observableFactory)==null?void 0:i.off.call(this,t,a)}trigger(t,...a){var i;return (i=this._observableFactory)==null?void 0:i.trigger.call(this,t,...a)}offAll(){var t;return (t=this._observableFactory)==null?void 0:t.offAll.call(this)}once(t,a){var i;return (i=this._observableFactory)==null?void 0:i.once.call(this,t,a)}getEventCallBacks(){var t;return (t=this._observableFactory)==null?void 0:t.getEventCallBacks.call(this)}static getInstance(t){if(!this.isI18nInstance(p.instance)){let a=p.getLocaleFromSession();p.instance=this.createInstance({},Object.assign({},a?{locale:a}:{},t));}return p.instance}isDefaultInstance(){return this===p.instance}static setLocaleToSession(t){W.set("i18n.locale",t);}static getLocaleFromSession(){let t=W.get("i18n.locale");return u(t)?t:""}canPluralize(t,a){a=f(a,this.getLocale());let i=this.getNestedTranslation(t,a);return !m(i)||!i?false:u(i==null?void 0:i.one)&&u(i==null?void 0:i.other)}getNestedTranslation(t,a){a=f(a,this.getLocale());let i=(u(t)?t.trim().split("."):Array.isArray(t)?t:[]).filter(u);if(!i.length)return;let n=this.getTranslations(a);for(let o of i)if(m(n))n=n[o];else return;return n}isPluralizeOptions(t){return !!(m(t)&&t&&typeof t.count=="number")}static RegisterTranslations(t){return p.getInstance().registerTranslations(t)}static createInstance(t={},a={}){let d=Object.assign({},a),{interpolate:i}=d,n=te(d,["interpolate"]),o=new p(t,n);return o.interpolate=(c,l,y)=>{let h=p.flattenObject(y),M=this.defaultInterpolator(c,l,h);return u(M)&&M!==l&&(l=M),typeof i=="function"?i(c,l,y):be(l,y)},o}getTranslations(t){let a=m(this.translations)?this.translations:{};return u(t)?m(a[t])?a[t]:{}:a}static registerMomentLocale(t,a){return u(t)&&m(a)&&Array.isArray(a.months)&&(this.momentLocales[t]=I({},this.momentLocales[t],a)),this.momentLocales}static getMomentLocale(t){return this.momentLocales[t]}static setMomentLocale(t){try{return v__default.default.updateLocale(t,this.getMomentLocale(t)),!0}catch(a){console.error(a," setting moment locale : ",t);}return false}registerTranslations(t){return this.store(t),this.getTranslations()}store(t){super.store(t),this.trigger("translations-changed",this.getLocale(),this.getTranslations());}resolveTranslations(t){try{let a=Object.getOwnPropertyNames(t);for(let i of a){let n=Reflect.getMetadata(Ce,t,i);if(n)try{t[i]=this.translate(n);}catch(o){N.error(o," resolving translation for key : ",n);}}}catch(a){N.error(a," resolving translations for target : ",t);}}getMissingPlaceholderString(t,a,i){return typeof this.missingPlaceholder=="function"?this.missingPlaceholder(this,t,f(a),Object.assign({},i)):t}getLocale(){return super.locale}setLocales(t){return this._locales=Array.isArray(t)?t:["en"],this._locales.includes("en")||this._locales.push("en"),this.getLocales()}hasLocale(t){return u(t)&&this.getLocales().includes(t)}getLocales(){let t=Object.keys(this.getTranslations()),a=Array.isArray(this._locales)?this._locales:["en"],i=[...t,...a.filter(n=>!t.includes(n))];return i.includes("en")||i.push("en"),i}isLocaleSupported(t){return u(t)?this.getLocales().includes(t):false}isLoading(){return this._isLoading}setLocale(t,a=false){return super.locale===t&&a!==true&&this._namespacesLoaded[t]?Promise.resolve(this.getLocale()):new Promise((i,n)=>(this._isLoading=true,this.trigger("namespaces-before-load",t),this.loadNamespaces(t).then(o=>{this.isDefaultInstance()&&(p.instance=this,this.isLocaleSupported(t)&&p.setLocaleToSession(t)),super.locale=t,p.setMomentLocale(t),this.trigger("locale-changed",t,o),i(t);}).catch(n).finally(()=>{this._isLoading=false;})))}registerNamespaceResolver(t,a){if(!u(t)||typeof a!="function"){console.warn("Invalid arguments for registerNamespaceResolver.",t,a);return}this.namespaceResolvers[t]=a;}static RegisterNamespaceResolver(t,a){return p.getInstance().registerNamespaceResolver(t,a)}loadNamespace(t,a,i=true){return !u(t)||!this.namespaceResolvers[t]?Promise.reject(new Error(`Invalid namespace or resolver for namespace "${t}".`)):(a=f(a,this.getLocale()),u(a)?this.namespaceResolvers[t](a).then(n=>{let o={};return o[a]=Object.assign({},n),m(n)&&(i!==false&&this.store(o),this.trigger("namespace-loaded",t,a,o)),o}):Promise.reject(new Error(`Locale is not set. Cannot load namespace "${t}".`)))}static LoadNamespace(t,a,i=true){return p.getInstance().loadNamespace(t,a,i)}loadNamespaces(t,a=true){let i=[],n={};t=f(t,this.getLocale()),this._isLoading=true;for(let o in this.namespaceResolvers)Object.prototype.hasOwnProperty.call(this.namespaceResolvers,o)&&typeof this.namespaceResolvers[o]=="function"&&i.push(new Promise(d=>{this.namespaceResolvers[o](t).then(c=>{I(n,c);}).finally(()=>{d(true);});}));return Promise.all(i).then(()=>{let o={};return o[t]=n,a!==false&&this.store(o),setTimeout(()=>{this.trigger("namespaces-loaded",t,o);},100),o}).finally(()=>{this._isLoading=false;})}static LoadNamespaces(t,a=true){return p.getInstance().loadNamespaces(t,a)}static flattenObject(t){return m(t)?Object.flatten(t):t}static defaultInterpolator(t,a,i){return z(a)?"":S(a)?(a=String(a),!m(i)||!i||!m(i)||!i?a:a.replace(/%{(.*?)}/g,(n,o)=>z(i[o])?"":S(i[o])?String(i[o]):A(i[o],{escapeString:false}))):A(a,{escapeString:false})}};p.momentLocales={};var Y=p,Me=Y.getInstance();try{Object.setPrototypeOf(Me,Y.prototype);}catch(e){}function J(e){return !!(e==null||typeof e=="undefined"||typeof e=="string"&&e===""||Array.isArray(e)&&!e.length)}var s=class s{static parseString(r,t){if(u(r)&&u(t))try{let a=v__default.default(r,t,!0);if(a.isValid())return {date:a.toDate(),matchedFormat:t,isValid:!0}}catch(a){}try{if(Array.isArray(t)&&(t!=null&&t.length))for(let a of t){let i=De(r,a);if(i)return i}for(let a of s.DATE_FORMATS){let i=De(r,a);if(i)return i}return {date:null,matchedFormat:null,isValid:!1,error:"Unable to parse date string with any known format"}}catch(a){return {date:null,matchedFormat:null,isValid:false,error:a instanceof Error?a.message:"Unknown error occurred while parsing date"}}}static toIsoString(r){let t=r?s.parseDate(r):new Date;return t?t.toISOString():""}static isoStringToDate(r){return new Date(r)}static parseDate(r,t){if(s.isDateObj(r))return r;if(!u(t)){let a=s.parseString(r);return a!=null&&a.isValid?a.date:null}if(J(r))return null;try{let a=v__default.default(r,t,!0);if(a!=null&&a.isValid())return a.toDate()}catch(a){console.error(a," parsing date with moment : ",r," format is : ",t);}return null}static toSQLDateTimeFormat(r){if(!s.isDateObj(r))return "";let t=r.getFullYear(),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0"),n=String(r.getHours()).padStart(2,"0"),o=String(r.getMinutes()).padStart(2,"0"),d=String(r.getSeconds()).padStart(2,"0");return `${t}-${a}-${i} ${n}:${o}:${d}`}static getI18n(r){return Y.isI18nInstance(r)?r:Y.getInstance()}static getDefaultDateTimeFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultDateTimeFormat"),"YYYY-MM-DD HH:mm")}static getDefaultDateFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultDateFormat"),"YYYY-MM-DD")}static toSQLDateFormat(r){if(!s.isDateObj(r))return "";let t=r.getFullYear(),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0");return `${t}-${a}-${i}`}static toSQLTimeFormat(r){if(!s.isDateObj(r))return "";let t=String(r.getHours()).padStart(2,"0"),a=String(r.getMinutes()).padStart(2,"0"),i=String(r.getSeconds()).padStart(2,"0");return `${t}:${a}:${i}`}static getDefaultTimeFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultTimeFormat"),"HH:mm")}static isValidDate(r,t){if(r==null||typeof r=="boolean")return false;if(s.isDateObj(r))return true;if(T(r)){let i=new Date(r);return i&&!isNaN(i.getTime())}if(u(r))return !!s.parseDate(r,t);if(r!=null&&r.toString&&(r==null?void 0:r.toString())==parseInt(r).toString())return false;let a=new Date(r);return s.isDateObj(a)}static addToDate(r,t,a){if(T(r)||(r=0),J(t)&&(t=new Date),s.isValidDate(t)&&u(t)&&(t=new Date(t)),s.isValidDate(t)||(t=u(t)?new Date(t):new Date),u(a)&&typeof t["set"+a]=="function"&&typeof t["get"+a]=="function"){let i="set"+a,n="get"+a;t=new Date(t[i](t[n]()+r));}return t}static addDays(r,t){return s.addToDate(r,t,"Date")}static addMilliseconds(r,t){return T(r)||(r=0),s.isDateObj(t)||(t=new Date),t=t||new Date,new Date(t.getTime()+r)}static addSeconds(r,t){return T(r)||(r=0),s.addMilliseconds(r*1e3,t)}static addMinutes(r,t){return T(r)||(r=0),s.addMilliseconds(r*6e4,t)}static addHours(r,t){return T(r)||(r=0),s.addMilliseconds(r*36e5,t)}static addMonths(r,t,a){return s.addToDate(r,t,"Month")}static addWeeks(r,t){return r=(T(r)?r:0)*7,s.addToDate(r,t,"Date")}static addYears(r,t){T(r)||(r=0);let a=new Date(s.addToDate(0,t)),i=a.getFullYear();return i+r<0?r=0:r+=i,a.setFullYear(r),new Date(a)}static formatDate(r,t){try{let a=v__default.default(r);if(a.isValid())return a.format(f(t,s.getDefaultDateTimeFormat()))}catch(a){}return f(s.isValidDate(r)?r==null?void 0:r.toString():"")}static getUTCDateTimeDetails(r){let t=r?v__default.default.utc(r):v__default.default.utc();return {year:t.year(),day:t.day(),month:t.month(),monthString:t.format("MM"),hours:t.hours(),date:t.date(),minutes:t.minutes(),seconds:t.seconds(),monthName:t.format("MMMM"),dayName:t.format("dddd"),dayNameShort:t.format("ddd")}}};s.DATE_FORMATS=["YYYY-MM-DD","YYYY-MM-DDTHH:mm:ss","YYYY-MM-DDTHH:mm:ssZ","YYYY-MM-DDTHH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss[Z]","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DDTHH:mm:ss.SSSZ ","YYYY-MM-DDTHH:mm:ss.SSS","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DD HH:mm:ssZ","YYYY-MM-DD HH:mmZ","MM/DD/YYYY","MM-DD-YYYY","MM.DD.YYYY","MM/DD/YY","MMMM DD, YYYY","MMM DD, YYYY","DD/MM/YYYY","DD-MM-YYYY","DD.MM.YYYY","DD/MM/YY","DD MMMM YYYY","DD MMM YYYY","HH:mm:ss.SSSZ","HH:mm:ssZ","HH:mmZ","YYYYMMDD","YYYYMMDDTHHMM","YYYYMMDDTHHMMSS","HH:mm:ss","HH:mm","hh:mm A","h:mm A","HH:mm:ss.SSS","YYYY-DDD","YYYY-Www","YYYY-Www-D","YYYY/MM/DD","YYYY.MM.DD","MMM D, YYYY","MMMM D, YYYY","D MMM YYYY","D MMMM YYYY","MMM D YYYY","ddd, DD MMM YYYY HH:mm:ss ZZ","ddd, DD MMM YYYY HH:mm:ss","dddd, MMMM D, YYYY","dddd, D MMMM YYYY","hh:mm:ss A","H:mm:ss","YYYY-[W]WW","YYYY-[W]WW-E","YYYY-MM-DDTHH:mm:ss.SSS","DD-MM-YYYY HH:mm:ss","YYYY/MM/DD HH:mm:ss","YYYY.MM.DD HH:mm:ss","DD/MM/YYYY HH:mm:ss","MMM D YYYY, h:mm a","MMMM D YYYY, h:mm a","h:mm A MMM D, YYYY","MMMM D, YYYY","YY-MM-DD","DD-MM-YY","MM/DD/YY","MMM DD, YY","D MMM YY","D MMMM YY","YYYY MMM D","YYYY-MM-DD HH:mm","YYYY-MM-DD HH:mm:ss.SSS"],s.SQL_DATE_FORMAT="YYYY-MM-DD",s.SQL_DATE_TIME_FORMAT="YYYY-MM-DD HH:mm:ss",s.SQL_TIME_FORMAT="HH:mm:ss",s.getCurrentMonthDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=new Date(t.getFullYear(),t.getMonth(),1),i=new Date(t.getFullYear(),t.getMonth()+1,0);return {first:a,last:i}},s.getPreviousWeekDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=new Date(t.getTime()-3600*24*7*1e3),i=new Date(a),n=a.getDay(),o=a.getDate()-n+(n===0?-6:1),d=new Date(a.setDate(o)),c=new Date(i.setDate(o+6));return {first:d,last:c}},s.getCurrentWeekDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=t.getDay(),i=t.getDate()-a+(a==0?-6:1),n=new Date(t),o=new Date(t.setDate(i));return n.setDate(n.getDate()+6),{first:o,last:n}},s.isDateObj=E;var g=s,De=(e,r)=>{let t=v__default.default(e,r,true);try{if(t.isValid()&&t.format(r)===e||v__default.default.utc(t,!0).format(r)===e)return {date:t.toDate(),matchedFormat:r,isValid:!0}}catch(a){}return null};Date.prototype.toSQLDateTimeFormat=function(){return g.toSQLDateTimeFormat(this)};Date.prototype.toSQLDateFormat=function(){return g.toSQLDateFormat(this)};Date.prototype.toSQLTimeFormat=function(){return g.toSQLTimeFormat(this)};Date.prototype.resetHours=function(){return this.setHours(0),this};Date.prototype.resetMinutes=function(){return this.setMinutes(0),this};Date.prototype.resetSeconds=function(){return this.setSeconds(0),this};Date.prototype.resetMilliseconds=function(){return this.setMilliseconds(0),this};Date.prototype.resetHours2Minutes2Seconds=function(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this};Date.prototype.toFormat=function(e){return g.formatDate(this,e)};Date.prototype.addYears=function(e){return g.addYears(e,this)};Date.prototype.addMonths=function(e){return g.addMonths(e,this)};Date.prototype.addMinutes=function(e){return g.addMinutes(e,this)};Date.prototype.addSeconds=function(e){return g.addSeconds(e,this)};Date.prototype.addDays=function(e){return g.addDays(e,this)};Date.prototype.addWeeks=function(e){return g.addWeeks(e,this)};Date.prototype.addHours=function(e){return g.addHours(e,this)};exports.DateHelper=g;
|
|
5
|
+
%{nestedErrors}`,validateNestedInvalidType:"The field %{fieldName} must be an object, but received %{receivedType}",dateAfter:"This field must be after %{date}",dateBefore:"This field must be before %{date}",dateBetween:"This field must be between %{startDate} and %{endDate}",dateEquals:"This field must be equal to %{date}",futureDate:"This field must be a date in the future",pastDate:"This field must be a date in the past",file:"This field must be a valid file",fileSize:"This field must not exceed %{maxSize} bytes",fileType:"This field must be one of the following types: %{allowedTypes}",image:"This field must be a valid image file",fileExtension:"This field must have one of the following extensions: %{allowedExtensions}",minFileSize:"This field must be at least %{minSize} bytes",uuid:"This field must be a valid UUID",json:"This field must be valid JSON",base64:"This field must be valid Base64 encoded data",hexColor:"This field must be a valid hexadecimal color code",creditCard:"This field must be a valid credit card number",ip:"This field must be a valid IP address (version %{version})",macAddress:"This field must be a valid MAC address",matches:"This field must match the pattern %{pattern}",mongoId:"This field must be a valid MongoDB ObjectId",hexadecimal:"This field must be a valid hexadecimal value",object:"This field must be an object",isObject:"This field must be an object",tests:{entity:{name:"Name",id:"Id",email:"Email",aString:"A String",url:"Url",note:"Note",createdAt:"Created At",updatedAt:"Updated At"}}};var Ee={auth:ne,currencies:oe,countries:ie,dates:se,resources:de,validator:le};function u(e){return !!(e&&typeof e=="string")}function f(...e){for(var r in e){let t=e[r];if(u(t))return t}return ""}var C=class C{static get logger(){let r=Reflect.getMetadata(C.loggerMetaData,C);return ce(r)&&(this._logger=r),this._logger?this._logger:console}static set logger(r){ce(r)&&Reflect.defineMetadata(C.loggerMetaData,r,C);}static _log(r,...t){let a=C.logger;r=f(r),r&&typeof a[r]=="function"?a[r](C.getDateTimeString(),...t):console.log("Logger level not found : [",r,"]",...t);}static getDateTimeString(){let{day:r,year:t,hours:a,minutes:i,seconds:n,dayNameShort:o,monthName:d}=g.getUTCDateTimeDetails(),c=r<10?"0"+r:r,l=a<10?"0"+a:a,y=i<10?"0"+i:i,h=n<10?"0"+n:n;return "["+[o,c,d,t].join(" ")+" "+[l,y,h].join(":")+"]"}static log(...r){this._log("log",...r);}static info(...r){this._log("info",...r);}static debug(...r){this._log("debug",...r);}static warn(...r){this._log("warn",...r);}static error(...r){this._log("error",...r);}};C.loggerMetaData=Symbol("logger-meta-data");var N=C,ce=e=>{if(!e)return false;try{return ["warn","info","error"].every(r=>typeof e[r]=="function")}catch(r){return false}};function Ie(e){return typeof e=="boolean"||!e||typeof e=="number"||typeof e=="string"||typeof e=="symbol"?false:Object(e).constructor===Promise||e.constructor&&(e.constructor.name==="Promise"||e.constructor.name==="AsyncFunction")||e instanceof Promise||typeof(e==null?void 0:e.then)=="function"&&typeof(e==null?void 0:e.catch)=="function"&&typeof(e==null?void 0:e.finally)=="function"?true:e&&typeof e.constructor=="function"&&Function.prototype.toString.call(e.constructor).replace(/\(.*\)/,"()")===Function.prototype.toString.call(Function).replace("Function","Promise").replace(/\(.*\)/,"()")}function ue(e){return e&&Object.prototype.toString.call(e)==="[object Promise]"?true:Ie(e)}function me(){return typeof window!="undefined"&&(window==null?void 0:window.document)!==void 0&&typeof document!="undefined"&&typeof navigator!="undefined"}var x=()=>{var e;try{if(typeof process!="undefined"&&(process!=null&&process.versions)&&((e=process==null?void 0:process.versions)!=null&&e.node)||typeof global=="object"&&(global==null?void 0:global.toString.call(global))==="[object global]")return !0}catch(r){}return false},Le=()=>{var e,r;return !!(typeof window!="undefined"&&window&&typeof(window==null?void 0:window.process)=="object"&&((e=window==null?void 0:window.process)==null?void 0:e.type)==="renderer"||typeof process!="undefined"&&typeof(process==null?void 0:process.versions)=="object"&&((r=process.versions)!=null&&r.electron)||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&String(navigator==null?void 0:navigator.userAgent).toLowerCase().indexOf("electron")>=0)},Pe=()=>{if(typeof document!="undefined"&&document)try{return document.createEvent("TouchEvent"),!0}catch(e){try{return "ontouchstart"in window||"onmsgesturechange"in window}catch(r){}}return false},Re=()=>typeof window=="undefined"&&typeof process!="undefined",fe=()=>!!(typeof window!="undefined"&&typeof window=="object"&&window),xe=()=>{if(!me()||typeof navigator!="object"||!navigator||typeof navigator.userAgent!="string")return false;let e=navigator.userAgent.toLowerCase();return /android/i.test(e)},He=()=>{var e;return !fe()||!(window!=null&&window.ReactNativeWebView)?false:typeof((e=window==null?void 0:window.ReactNativeWebView)==null?void 0:e.postMessage)=="function"},Fe=()=>x()&&process.platform==="darwin",ke=()=>x()&&process.platform==="win32",Be=()=>x()&&process.platform==="linux",ye={isWeb:me,isLinux:Be,isDarwin:Fe,isWin32:ke,isNode:x,isElectron:Le,isTouchDevice:Pe,isServerSide:Re,isClientSide:fe,isAndroidMobileBrowser:xe,isReactNativeWebview:He};var O=class e{static decycle(r,t=[]){if(typeof r=="function")return;if(!r||typeof r!="object")return r;if(t.includes(r))return null;let a=t.concat([r]);return Array.isArray(r)?r.map(i=>e.decycle(i,a)):Object.fromEntries(Object.entries(r).map(([i,n])=>[i,e.decycle(n,a)]))}static stringify(r,t=false){return typeof r=="string"?r:JSON.stringify(t!==false?e.decycle(r):r)}static isJSON(r){if(typeof r!="string")return false;let t=r.trim();if(t.length===0)return false;let a=t[0];if(a!=="{"&&a!=="[")return false;try{let i=JSON.parse(t);return i!==null&&typeof i=="object"}catch(i){return false}}static parse(r,t){if(typeof r=="string")try{r=JSON.parse(r,t);}catch(a){return r}if(r&&typeof r=="object")for(let a in r){let i=r[a];e.isJSON(i)&&(r[a]=e.parse(i,t));}return r}};var D=class D{static get storage(){var t;let r=Reflect.getMetadata(D.sessionStorageMetaData,D);if(V(r)&&(this._storage=r),this._storage)return this._storage;if(ye.isClientSide()&&typeof window!="undefined"&&window.localStorage&&((t=window.localStorage)!=null&&t.getItem))this._storage={get:a=>window.localStorage.getItem(a),set:(a,i)=>window.localStorage.setItem(a,i),remove:a=>window.localStorage.removeItem(a),removeAll:()=>window.localStorage.clear()};else {let a={};this._storage={get:i=>a[i],set:(i,n)=>a[i]=n,remove:i=>{delete a[i];},removeAll:()=>a={}};}return this._storage}static set storage(r){V(r)&&Reflect.defineMetadata(D.sessionStorageMetaData,r,D);}static get keyNamespace(){return u(this._keyNamespace)?this._keyNamespace:""}static set keyNamespace(r){u(r)&&(this._keyNamespace=r.trim().replace(/\s+/g,"-"));}static sanitizeKey(r){if(!r||!u(r))return "";r=r.trim().replace(/\s+/g,"-");let t=this.keyNamespace;return t?`${t}-${r}`:r}};D.sessionStorageMetaData=Symbol("sessionStorage"),D._keyNamespace=void 0;var b=D;function H(e){return b.sanitizeKey(e)}var pe=(e,r)=>(e=e&&O.stringify(e,r),e==null&&(e=""),e),ge=e=>{if(ue(e))return new Promise((r,t)=>{e.then(a=>{r(O.parse(a));}).catch(a=>{t(a);});});if(e!=null)return O.parse(e)},Ge=e=>{if(e=H(e),b.storage&&e&&typeof e=="string"){let r=b.storage.get(e);return ge(r)}},Ke=e=>{if(e=H(e),b.storage&&e&&typeof e=="string")return b.storage.remove(e)},Ve=()=>{if(b.storage)return b.storage.removeAll()},V=e=>{if(!e)return false;try{return ["get","set","remove","removeAll"].every(r=>typeof e[r]=="function")}catch(r){return false}},W={get:Ge,set:(e,r,t=true)=>(e=H(e),b.storage.set(e,pe(r,t))),remove:Ke,handleGetValue:ge,sanitizeKey:H,handleSetValue:pe,isValidStorage:V,Manager:b,removeAll:Ve};function S(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function w(e){if(e instanceof RegExp)return true;if(!e||typeof e!="object"||!Object.prototype.toString.call(e).includes("RegExp"))return false;try{return new RegExp(e),!0}catch(r){return false}}function E(e){return !e||typeof e!="object"?false:e instanceof Date?true:typeof e.getTime!="function"?false:!(Object.prototype.toString.call(e)!=="[object Date]"||isNaN(e.getTime()))}function U(e){return typeof window!="object"||!window||typeof document=="undefined"||typeof HTMLElement=="undefined"||!HTMLElement?false:e===document?true:"HTMLElement"in window?!!e&&e instanceof HTMLElement:!!e&&typeof e=="object"&&e.nodeType===1&&!!e.nodeName}function m(e){if(e===null||typeof e!="object"||U(e)||E(e)||w(e)||S(e))return false;let r=Object.getPrototypeOf(e);if(r===null)return true;let t=r.constructor;if(typeof t!="function")return false;if(t===Object)return true;let a=t.prototype;return typeof a!="object"?false:a===Object.prototype?true:typeof r.hasOwnProperty=="function"&&Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")&&typeof r.isPrototypeOf=="function"}function Z(e){if(Array.isArray(e)){let a=[];for(var r=0;r<e.length;r++)a[r]=Z(e[r]);return a}else if(m(e)&&e){let a={};for(var t in e)e.hasOwnProperty(t)&&(a[t]=Z(e[t]));return a}else return e}Object.getSize=function(e,r=false){if(!e||typeof e!="object")return 0;if(Array.isArray(e))return e.length;typeof r!="boolean"&&(r=false);let t=0;for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&(t++,r===true))return t;return t};function I(e,...r){let t=Array.isArray(e),a=m(e);(e==null||!t&&!a)&&(e={});for(let i=0;i<r.length;i++){let n=r[i];if(n==null)continue;let o=m(n),d=Array.isArray(n);if(!(!o&&!d)){if(t){d&&he(e,n);continue}else if(d)continue;for(let c in n){let l=n[c];if(l==null)continue;if(l===n){e[c]=e;continue}let y=e[c],h=Array.isArray(y),M=Array.isArray(l);if(h){M?he(e[c],l):e[c]=l;continue}else if(!m(y)){e[c]=l;continue}if(M||!m(l)){e[c]=l;continue}e[c]=I({},y,l);}}}return e}var he=(e,r)=>{let t=r.length,a=0;for(let i=0;i<e.length;i++){let n=e[i],o=r[i];if(i<t){let d=Array.isArray(n),c=Array.isArray(o),l=m(n),y=m(o);d&&c||l&&y?(e[a]=I(d?[]:{},n,o),a++):o!=null?(e[a]=o,a++):n!=null&&(e[a]=n,a++);}}for(let i=e.length;i<t;i++)r[i]!==void 0&&r[i]!==null&&e.push(r[i]);return e};function We(e,r){return F(e,"",{},r)}function F(e,r="",t={},a){if(t=m(t)?t:{},S(e)||E(e)||w(e)||Array.isArray(e)&&(a!=null&&a.skipArrays))return r&&(t[r]=e),t;if(typeof e=="function"||typeof e=="object"&&!m(e)&&!Ue(e))return t;if(e instanceof Map||e instanceof WeakMap)return Array.from(e.entries()).forEach(([i,n])=>{let o=r?`${r}[${String(i)}]`:String(i);F(n,o,t,a);}),t;if(Array.isArray(e)||e instanceof Set||e instanceof WeakSet)return (Array.isArray(e)?e:Array.from(e)).forEach((n,o)=>{let d=r?`${r}[${o}]`:String(o);F(n,d,t,a);}),t;if(m(e))for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let n=e[i],o=r?r.endsWith("]")?`${r}.${i}`:`${r}.${i}`:i;F(n,o,t,a);}return t}function Ue(e){return Array.isArray(e)||e instanceof Set||e instanceof Map||e instanceof WeakMap||e instanceof WeakSet}function Ze(e){return Object.entries(e)}Object.typedEntries=Ze;Object.flatten=We;Object.clone=Z;function L(e,r){if(e==null)return "";if(typeof e=="string")return e;if((typeof e=="number"||typeof e=="object"&&e instanceof Number)&&typeof e.formatNumber=="function")return e.formatNumber();if(e instanceof Date||typeof e=="object"&&e!==null&&e.constructor===Date)return typeof e.toFormat=="function"?e.toFormat():e.toISOString();if(e instanceof Error)return `Error: ${e.message}`;if(w(e))return e.toString();if(S(e))return String(e);if(Array.isArray(e))return JSON.stringify(e);if(typeof e=="object"&&e!==null){if(typeof e.toString=="function"&&e.toString!==Object.prototype.toString)return e.toString();if(typeof e.toString=="function"){let t=e.toString();if(t!=="[object Object]")return t}return JSON.stringify(e)}return typeof(e==null?void 0:e.toString)=="function"?e.toString():String(e)}function be(e,r,t){let a=L,i=f(e);if(!m(r)||!r)return i;let n=/%\{([^}]+)\}/g,o=new Set,d,c=f(e);for(;(d=n.exec(c))!==null;){let l=d[1];l!==void 0&&o.add(l);}return o.forEach(l=>{let y;y=`%{${l}}`;let h=Object.prototype.hasOwnProperty.call(r,l)?r[l]:void 0,M=h===void 0?"":(()=>{try{return a(h,l,L)}catch($){return L(h)}})(),Se=y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");i=i.replace(new RegExp(Se,"g"),M);}),i}function z(e){return !!(e==null||typeof e=="number"&&isNaN(e)||typeof e=="string"&&e.trim()==="")}function T(e){return typeof e=="number"&&!isNaN(e)&&isFinite(e)}function ze(e){return f(e).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f")}function k(e,r){var t=Object.prototype.toString.call(e);return t==="[object "+r+"]"}function A(e,r){if(["boolean","undefined"].includes(typeof e)||e===null)return String(e);if(T(e))return e.formatNumber();if(e instanceof Date)return e.toFormat();if(e instanceof Error)return e==null?void 0:e.toString();r=Object.assign({},r);let{parenthesis:t}=r,a=t?"(":"",i=t?")":"";return typeof e=="string"?(r==null?void 0:r.escapeString)!==false?"'"+ze(e)+"'":e:k(e,"RegExp")||k(e,"Number")||k(e,"Boolean")?e.toString():k(e,"Date")?"new Date("+e.getTime()+")":Array.isArray(e)?"["+e.map(n=>A(n,r)).join(",")+"]":typeof e=="object"?a+"{"+Object.keys(e).map(n=>{var o=e[n];return A(n,r)+":"+A(o,r)}).join(",")+"}"+i:e&&typeof(e==null?void 0:e.toString)=="function"?e==null?void 0:e.toString():String(e)}var Ce=Symbol("TRANSLATION_KEY");var p=class p extends i18nJs.I18n{constructor(t={},a={}){super({},a);this._isLoading=false;this._locales=[];this.namespaceResolvers={};this._observableFactory=re();this._____isObservable=true;this.hasRegisteredDefaultTranslations=false;this._namespacesLoaded={};this.hasRegisteredDefaultTranslations||(this.registerTranslations(K),this.hasRegisteredDefaultTranslations=true),this.registerTranslations(t),this.loadNamespaces();}static[Symbol.hasInstance](t){return this.isI18nInstance(t)}static isI18nInstance(t){if(!t||typeof t!="object")return false;try{if(t instanceof i18nJs.I18n)return !0}catch(a){}return typeof t.getLocale=="function"&&typeof t.translate=="function"&&typeof t.translateTarget=="function"}translate(t,a){return this.isPluralizeOptions(a)&&this.canPluralize(t)?(typeof a.count=="number"&&(a.countStr=a.count.formatNumber()),this.pluralize(a.count,t,a)):super.translate(t,a)}translateTarget(t,a){let i=p.getTargetTanslationKeys(t);for(let n in i)u(i[n])&&(i[n]=this.translate(i[n],a));return i}translateObject(t,a){if(!m(t))return {};let i={};for(let n in t){let o=t[n];u(o)&&(i[n]=Me.translate(o,a));}return i}static getTargetTanslationKeys(t){return ae(t,Ce)}on(t,a){return this._observableFactory.on.call(this,t,a)}finally(t,a){return this._observableFactory.finally.call(this,t,a)}off(t,a){var i;return (i=this._observableFactory)==null?void 0:i.off.call(this,t,a)}trigger(t,...a){var i;return (i=this._observableFactory)==null?void 0:i.trigger.call(this,t,...a)}offAll(){var t;return (t=this._observableFactory)==null?void 0:t.offAll.call(this)}once(t,a){var i;return (i=this._observableFactory)==null?void 0:i.once.call(this,t,a)}getEventCallBacks(){var t;return (t=this._observableFactory)==null?void 0:t.getEventCallBacks.call(this)}static getInstance(t){if(!this.isI18nInstance(p.instance)){let a=p.getLocaleFromSession();p.instance=this.createInstance({},Object.assign({},a?{locale:a}:{},t));}return p.instance}isDefaultInstance(){return this===p.instance}static setLocaleToSession(t){W.set("i18n.locale",t);}static getLocaleFromSession(){let t=W.get("i18n.locale");return u(t)?t:""}canPluralize(t,a){a=f(a,this.getLocale());let i=this.getNestedTranslation(t,a);return !m(i)||!i?false:u(i==null?void 0:i.one)&&u(i==null?void 0:i.other)}getNestedTranslation(t,a){a=f(a,this.getLocale());let i=(u(t)?t.trim().split("."):Array.isArray(t)?t:[]).filter(u);if(!i.length)return;let n=this.getTranslations(a);for(let o of i)if(m(n))n=n[o];else return;return n}isPluralizeOptions(t){return !!(m(t)&&t&&typeof t.count=="number")}static RegisterTranslations(t){return p.getInstance().registerTranslations(t)}static createInstance(t={},a={}){let d=Object.assign({},a),{interpolate:i}=d,n=te(d,["interpolate"]),o=new p(t,n);return o.interpolate=(c,l,y)=>{let h=p.flattenObject(y),M=this.defaultInterpolator(c,l,h);return u(M)&&M!==l&&(l=M),typeof i=="function"?i(c,l,y):be(l,y)},o}getTranslations(t){let a=m(this.translations)?this.translations:{};return u(t)?m(a[t])?a[t]:{}:a}static registerMomentLocale(t,a){return u(t)&&m(a)&&Array.isArray(a.months)&&(this.momentLocales[t]=I({},this.momentLocales[t],a)),this.momentLocales}static getMomentLocale(t){return this.momentLocales[t]}static setMomentLocale(t){try{return v__default.default.updateLocale(t,this.getMomentLocale(t)),!0}catch(a){console.error(a," setting moment locale : ",t);}return false}registerTranslations(t){return this.store(t),this.getTranslations()}store(t){super.store(t),this.trigger("translations-changed",this.getLocale(),this.getTranslations());}resolveTranslations(t){try{let a=Object.getOwnPropertyNames(t);for(let i of a){let n=Reflect.getMetadata(Ce,t,i);if(n)try{t[i]=this.translate(n);}catch(o){N.error(o," resolving translation for key : ",n);}}}catch(a){N.error(a," resolving translations for target : ",t);}}getMissingPlaceholderString(t,a,i){return typeof this.missingPlaceholder=="function"?this.missingPlaceholder(this,t,f(a),Object.assign({},i)):t}getLocale(){return super.locale}setLocales(t){return this._locales=Array.isArray(t)?t:["en"],this._locales.includes("en")||this._locales.push("en"),this.getLocales()}hasLocale(t){return u(t)&&this.getLocales().includes(t)}getLocales(){let t=Object.keys(this.getTranslations()),a=Array.isArray(this._locales)?this._locales:["en"],i=[...t,...a.filter(n=>!t.includes(n))];return i.includes("en")||i.push("en"),i}isLocaleSupported(t){return u(t)?this.getLocales().includes(t):false}isLoading(){return this._isLoading}setLocale(t,a=false){return super.locale===t&&a!==true&&this._namespacesLoaded[t]?Promise.resolve(this.getLocale()):new Promise((i,n)=>(this._isLoading=true,this.trigger("namespaces-before-load",t),this.loadNamespaces(t).then(o=>{this.isDefaultInstance()&&(p.instance=this,this.isLocaleSupported(t)&&p.setLocaleToSession(t)),super.locale=t,p.setMomentLocale(t),this.trigger("locale-changed",t,o),i(t);}).catch(n).finally(()=>{this._isLoading=false;})))}registerNamespaceResolver(t,a){if(!u(t)||typeof a!="function"){console.warn("Invalid arguments for registerNamespaceResolver.",t,a);return}this.namespaceResolvers[t]=a;}static RegisterNamespaceResolver(t,a){return p.getInstance().registerNamespaceResolver(t,a)}loadNamespace(t,a,i=true){return !u(t)||!this.namespaceResolvers[t]?Promise.reject(new Error(`Invalid namespace or resolver for namespace "${t}".`)):(a=f(a,this.getLocale()),u(a)?this.namespaceResolvers[t](a).then(n=>{let o={};return o[a]=Object.assign({},n),m(n)&&(i!==false&&this.store(o),this.trigger("namespace-loaded",t,a,o)),o}):Promise.reject(new Error(`Locale is not set. Cannot load namespace "${t}".`)))}static LoadNamespace(t,a,i=true){return p.getInstance().loadNamespace(t,a,i)}loadNamespaces(t,a=true){let i=[],n={};t=f(t,this.getLocale()),this._isLoading=true;for(let o in this.namespaceResolvers)Object.prototype.hasOwnProperty.call(this.namespaceResolvers,o)&&typeof this.namespaceResolvers[o]=="function"&&i.push(new Promise(d=>{this.namespaceResolvers[o](t).then(c=>{I(n,c);}).finally(()=>{d(true);});}));return Promise.all(i).then(()=>{let o={};return o[t]=n,a!==false&&this.store(o),setTimeout(()=>{this.trigger("namespaces-loaded",t,o);},100),o}).finally(()=>{this._isLoading=false;})}static LoadNamespaces(t,a=true){return p.getInstance().loadNamespaces(t,a)}static flattenObject(t){return m(t)?Object.flatten(t):t}static defaultInterpolator(t,a,i){return z(a)?"":S(a)?(a=String(a),!m(i)||!i||!m(i)||!i?a:a.replace(/%{(.*?)}/g,(n,o)=>z(i[o])?"":S(i[o])?String(i[o]):A(i[o],{escapeString:false}))):A(a,{escapeString:false})}};p.momentLocales={};var Y=p,Me=Y.getInstance();try{Object.setPrototypeOf(Me,Y.prototype);}catch(e){}function J(e){return !!(e==null||typeof e=="undefined"||typeof e=="string"&&e===""||Array.isArray(e)&&!e.length)}var s=class s{static parseString(r,t){if(u(r)&&u(t))try{let a=v__default.default(r,t,!0);if(a.isValid())return {date:a.toDate(),matchedFormat:t,isValid:!0}}catch(a){}try{if(Array.isArray(t)&&(t!=null&&t.length))for(let a of t){let i=De(r,a);if(i)return i}for(let a of s.DATE_FORMATS){let i=De(r,a);if(i)return i}return {date:null,matchedFormat:null,isValid:!1,error:"Unable to parse date string with any known format"}}catch(a){return {date:null,matchedFormat:null,isValid:false,error:a instanceof Error?a.message:"Unknown error occurred while parsing date"}}}static toIsoString(r){let t=r?s.parseDate(r):new Date;return t?t.toISOString():""}static isoStringToDate(r){return new Date(r)}static parseDate(r,t){if(s.isDateObj(r))return r;if(!u(t)){let a=s.parseString(r);return a!=null&&a.isValid?a.date:null}if(J(r))return null;try{let a=v__default.default(r,t,!0);if(a!=null&&a.isValid())return a.toDate()}catch(a){console.error(a," parsing date with moment : ",r," format is : ",t);}return null}static toSQLDateTimeFormat(r){if(!s.isDateObj(r))return "";let t=r.getFullYear(),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0"),n=String(r.getHours()).padStart(2,"0"),o=String(r.getMinutes()).padStart(2,"0"),d=String(r.getSeconds()).padStart(2,"0");return `${t}-${a}-${i} ${n}:${o}:${d}`}static getI18n(r){return Y.isI18nInstance(r)?r:Y.getInstance()}static getDefaultDateTimeFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultDateTimeFormat"),"YYYY-MM-DD HH:mm")}static getDefaultDateFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultDateFormat"),"YYYY-MM-DD")}static toSQLDateFormat(r){if(!s.isDateObj(r))return "";let t=r.getFullYear(),a=String(r.getMonth()+1).padStart(2,"0"),i=String(r.getDate()).padStart(2,"0");return `${t}-${a}-${i}`}static toSQLTimeFormat(r){if(!s.isDateObj(r))return "";let t=String(r.getHours()).padStart(2,"0"),a=String(r.getMinutes()).padStart(2,"0"),i=String(r.getSeconds()).padStart(2,"0");return `${t}:${a}:${i}`}static getDefaultTimeFormat(r){return f(this.getI18n(r).getNestedTranslation("dates.defaultTimeFormat"),"HH:mm")}static isValidDate(r,t){if(r==null||typeof r=="boolean")return false;if(s.isDateObj(r))return true;if(T(r)){let i=new Date(r);return i&&!isNaN(i.getTime())}if(u(r))return !!s.parseDate(r,t);if(r!=null&&r.toString&&(r==null?void 0:r.toString())==parseInt(r).toString())return false;let a=new Date(r);return s.isDateObj(a)}static addToDate(r,t,a){if(T(r)||(r=0),J(t)&&(t=new Date),s.isValidDate(t)&&u(t)&&(t=new Date(t)),s.isValidDate(t)||(t=u(t)?new Date(t):new Date),u(a)&&typeof t["set"+a]=="function"&&typeof t["get"+a]=="function"){let i="set"+a,n="get"+a;t=new Date(t[i](t[n]()+r));}return t}static addDays(r,t){return s.addToDate(r,t,"Date")}static addMilliseconds(r,t){return T(r)||(r=0),s.isDateObj(t)||(t=new Date),t=t||new Date,new Date(t.getTime()+r)}static addSeconds(r,t){return T(r)||(r=0),s.addMilliseconds(r*1e3,t)}static addMinutes(r,t){return T(r)||(r=0),s.addMilliseconds(r*6e4,t)}static addHours(r,t){return T(r)||(r=0),s.addMilliseconds(r*36e5,t)}static addMonths(r,t,a){return s.addToDate(r,t,"Month")}static addWeeks(r,t){return r=(T(r)?r:0)*7,s.addToDate(r,t,"Date")}static addYears(r,t){T(r)||(r=0);let a=new Date(s.addToDate(0,t)),i=a.getFullYear();return i+r<0?r=0:r+=i,a.setFullYear(r),new Date(a)}static formatDate(r,t){try{let a=v__default.default(r);if(a.isValid())return a.format(f(t,s.getDefaultDateTimeFormat()))}catch(a){}return f(s.isValidDate(r)?r==null?void 0:r.toString():"")}static getUTCDateTimeDetails(r){let t=r?v__default.default.utc(r):v__default.default.utc();return {year:t.year(),day:t.day(),month:t.month(),monthString:t.format("MM"),hours:t.hours(),date:t.date(),minutes:t.minutes(),seconds:t.seconds(),monthName:t.format("MMMM"),dayName:t.format("dddd"),dayNameShort:t.format("ddd")}}};s.DATE_FORMATS=["YYYY-MM-DD","YYYY-MM-DDTHH:mm:ss","YYYY-MM-DDTHH:mm:ssZ","YYYY-MM-DDTHH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss[Z]","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DDTHH:mm:ss.SSSZ ","YYYY-MM-DDTHH:mm:ss.SSS","YYYY-MM-DD HH:mm:ss","YYYY-MM-DD HH:mm:ss.SSSZ","YYYY-MM-DDTHH:mm:ss.SSS[Z]","YYYY-MM-DD HH:mm:ssZ","YYYY-MM-DD HH:mmZ","MM/DD/YYYY","MM-DD-YYYY","MM.DD.YYYY","MM/DD/YY","MMMM DD, YYYY","MMM DD, YYYY","DD/MM/YYYY","DD-MM-YYYY","DD.MM.YYYY","DD/MM/YY","DD MMMM YYYY","DD MMM YYYY","HH:mm:ss.SSSZ","HH:mm:ssZ","HH:mmZ","YYYYMMDD","YYYYMMDDTHHMM","YYYYMMDDTHHMMSS","HH:mm:ss","HH:mm","hh:mm A","h:mm A","HH:mm:ss.SSS","YYYY-DDD","YYYY-Www","YYYY-Www-D","YYYY/MM/DD","YYYY.MM.DD","MMM D, YYYY","MMMM D, YYYY","D MMM YYYY","D MMMM YYYY","MMM D YYYY","ddd, DD MMM YYYY HH:mm:ss ZZ","ddd, DD MMM YYYY HH:mm:ss","dddd, MMMM D, YYYY","dddd, D MMMM YYYY","hh:mm:ss A","H:mm:ss","YYYY-[W]WW","YYYY-[W]WW-E","YYYY-MM-DDTHH:mm:ss.SSS","DD-MM-YYYY HH:mm:ss","YYYY/MM/DD HH:mm:ss","YYYY.MM.DD HH:mm:ss","DD/MM/YYYY HH:mm:ss","MMM D YYYY, h:mm a","MMMM D YYYY, h:mm a","h:mm A MMM D, YYYY","MMMM D, YYYY","YY-MM-DD","DD-MM-YY","MM/DD/YY","MMM DD, YY","D MMM YY","D MMMM YY","YYYY MMM D","YYYY-MM-DD HH:mm","YYYY-MM-DD HH:mm:ss.SSS"],s.SQL_DATE_FORMAT="YYYY-MM-DD",s.SQL_DATE_TIME_FORMAT="YYYY-MM-DD HH:mm:ss",s.SQL_TIME_FORMAT="HH:mm:ss",s.getCurrentMonthDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=new Date(t.getFullYear(),t.getMonth(),1),i=new Date(t.getFullYear(),t.getMonth()+1,0);return {first:a,last:i}},s.getPreviousWeekDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=new Date(t.getTime()-3600*24*7*1e3),i=new Date(a),n=a.getDay(),o=a.getDate()-n+(n===0?-6:1),d=new Date(a.setDate(o)),c=new Date(i.setDate(o+6));return {first:d,last:c}},s.getCurrentWeekDaysRange=r=>{let t=s.isValidDate(r)?new Date(r):new Date().resetHours2Minutes2Seconds(),a=t.getDay(),i=t.getDate()-a+(a==0?-6:1),n=new Date(t),o=new Date(t.setDate(i));return n.setDate(n.getDate()+6),{first:o,last:n}},s.isDateObj=E;var g=s,De=(e,r)=>{let t=v__default.default(e,r,true);try{if(t.isValid()&&t.format(r)===e||v__default.default.utc(t,!0).format(r)===e)return {date:t.toDate(),matchedFormat:r,isValid:!0}}catch(a){}return null};Date.prototype.toSQLDateTimeFormat=function(){return g.toSQLDateTimeFormat(this)};Date.prototype.toSQLDateFormat=function(){return g.toSQLDateFormat(this)};Date.prototype.toSQLTimeFormat=function(){return g.toSQLTimeFormat(this)};Date.prototype.resetHours=function(){return this.setHours(0),this};Date.prototype.resetMinutes=function(){return this.setMinutes(0),this};Date.prototype.resetSeconds=function(){return this.setSeconds(0),this};Date.prototype.resetMilliseconds=function(){return this.setMilliseconds(0),this};Date.prototype.resetHours2Minutes2Seconds=function(){return this.setHours(0),this.setMinutes(0),this.setSeconds(0),this.setMilliseconds(0),this};Date.prototype.toFormat=function(e){return g.formatDate(this,e)};Date.prototype.addYears=function(e){return g.addYears(e,this)};Date.prototype.addMonths=function(e){return g.addMonths(e,this)};Date.prototype.addMinutes=function(e){return g.addMinutes(e,this)};Date.prototype.addSeconds=function(e){return g.addSeconds(e,this)};Date.prototype.addDays=function(e){return g.addDays(e,this)};Date.prototype.addWeeks=function(e){return g.addWeeks(e,this)};Date.prototype.addHours=function(e){return g.addHours(e,this)};exports.DateHelper=g;
|