@jsarc/cooks 0.0.1-beta.0.2 → 0.0.1-beta.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -65,8 +65,6 @@ const globalFunct = (function() {
65
65
  };
66
66
 
67
67
  public static set<T extends Serializable>(key: string, value: T, options: CooksOptions = {}): void {
68
- if (!this.isBrowser()) return;
69
-
70
68
  try {
71
69
  const serializedValue = this.serialize(value);
72
70
  const encodedValue = encodeURIComponent(serializedValue);
@@ -79,8 +77,6 @@ const globalFunct = (function() {
79
77
  }
80
78
 
81
79
  public static get<T extends Serializable>(key: string): T | null {
82
- if (!this.isBrowser()) return null;
83
-
84
80
  try {
85
81
  const cookies = this.getAllCookies();
86
82
  const encodedValue = cookies[key];
@@ -96,8 +92,6 @@ const globalFunct = (function() {
96
92
  }
97
93
 
98
94
  public static remove(key: string, path: string = '/', domain?: string): void {
99
- if (!this.isBrowser()) return;
100
-
101
95
  const options: CooksOptions = {
102
96
  expires: new Date(0),
103
97
  path,
@@ -112,15 +106,11 @@ const globalFunct = (function() {
112
106
  }
113
107
 
114
108
  public static keys(): string[] {
115
- if (!this.isBrowser()) return [];
116
-
117
109
  const cookies = this.getAllCookies();
118
110
  return Object.keys(cookies);
119
111
  }
120
112
 
121
113
  public static clear(): void {
122
- if (!this.isBrowser()) return;
123
-
124
114
  const cookies = this.getAllCookies();
125
115
  Object.keys(cookies).forEach(key => {
126
116
  this.remove(key);
@@ -208,10 +198,6 @@ const globalFunct = (function() {
208
198
 
209
199
  const __bundledModules = globalFunctModule;
210
200
 
211
- if (typeof exports !== 'undefined') {
212
- exports.default = Cooks;
213
- exports.Cooks = Cooks;
214
- }
215
201
  return globalFunctModule;
216
202
 
217
203
  })();
package/js/index.js CHANGED
@@ -33,8 +33,6 @@ const globalFunct = (function () {
33
33
  sameSite: 'lax'
34
34
  };
35
35
  static set(key, value, options = {}) {
36
- if (!this.isBrowser())
37
- return;
38
36
  try {
39
37
  const serializedValue = this.serialize(value);
40
38
  const encodedValue = encodeURIComponent(serializedValue);
@@ -46,8 +44,6 @@ const globalFunct = (function () {
46
44
  }
47
45
  }
48
46
  static get(key) {
49
- if (!this.isBrowser())
50
- return null;
51
47
  try {
52
48
  const cookies = this.getAllCookies();
53
49
  const encodedValue = cookies[key];
@@ -62,8 +58,6 @@ const globalFunct = (function () {
62
58
  }
63
59
  }
64
60
  static remove(key, path = '/', domain) {
65
- if (!this.isBrowser())
66
- return;
67
61
  const options = {
68
62
  expires: new Date(0),
69
63
  path,
@@ -75,14 +69,10 @@ const globalFunct = (function () {
75
69
  return this.get(key) !== null;
76
70
  }
77
71
  static keys() {
78
- if (!this.isBrowser())
79
- return [];
80
72
  const cookies = this.getAllCookies();
81
73
  return Object.keys(cookies);
82
74
  }
83
75
  static clear() {
84
- if (!this.isBrowser())
85
- return;
86
76
  const cookies = this.getAllCookies();
87
77
  Object.keys(cookies).forEach(key => {
88
78
  this.remove(key);
@@ -153,10 +143,6 @@ const globalFunct = (function () {
153
143
  Cooks: Cooks,
154
144
  };
155
145
  const __bundledModules = globalFunctModule;
156
- if (typeof exports !== 'undefined') {
157
- exports.default = Cooks;
158
- exports.Cooks = Cooks;
159
- }
160
146
  return globalFunctModule;
161
147
  })();
162
148
  const CooksElementGF = globalFunct.Cooks;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.0.1-beta.0.2",
6
+ "version": "0.0.1-beta.0.4",
7
7
  "description": "Cooks est une bibliothèque TypeScript/JavaScript légère et type-safe pour la gestion des cookies dans les navigateurs web. Elle offre une API simple et intuitive pour stocker, récupérer et manipuler des cookies avec support des types complexes et des options avancées.",
8
8
  "main": "index.ts",
9
9
  "keywords": [],
@@ -15,6 +15,6 @@
15
15
  },
16
16
  "devDependencies": {},
17
17
  "dependencies": {
18
- "@jsarc/timez": "^0.0.1-beta.0.2"
18
+ "@jsarc/timez": "^0.0.1-beta.0.3"
19
19
  }
20
20
  }
package/web/cooks.js CHANGED
@@ -888,10 +888,6 @@ const globalFunct = (function () {
888
888
  Cooks: Cooks,
889
889
  };
890
890
  const __bundledModules = globalFunctModule;
891
- if (typeof exports !== 'undefined') {
892
- exports.default = Cooks;
893
- exports.Cooks = Cooks;
894
- }
895
891
  return globalFunctModule;
896
892
  })();
897
893
  const CooksElementGF = globalFunct.Cooks;
package/web/cooks.min.js CHANGED
@@ -1 +1 @@
1
- let globalFunct=(()=>{var e=["0","1","2","3","4","5","6","7","8","9"],t=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],a=[...t,...t.map(e=>e.toUpperCase())];[...e,...t],[...e,...a];class f{_date;static FORMAT_TOKENS={"%Y":e=>e.year()?.toString().padStart(4,"0"),"%y":e=>e.year()?.toString().slice(-2).padStart(2,"0"),"%m":e=>e.month()?.toString().padStart(2,"0"),"%d":e=>e.date()?.toString().padStart(2,"0"),"%H":e=>e.hour()?.toString().padStart(2,"0"),"%M":e=>e.minute()?.toString().padStart(2,"0"),"%S":e=>e.second()?.toString().padStart(2,"0"),"%f":e=>e.millisecond()?.toString().padStart(3,"0"),"%z":e=>{e=e.utcOffset();if(e)return(0<=e?"+":"-")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")+(Math.abs(e)%60).toString().padStart(2,"0")},"%s":e=>{e=e.valueOf();return e?Math.floor(e/1e3).toString():void 0}};static PREDEFINED_FORMATS={ISO:"%Y-%m-%dT%H:%M:%S.%fZ",ISO_DATE:"%Y-%m-%d",ISO_TIME:"%H:%M:%S.%fZ",COMPACT:"%Y%m%d%H%M%S",SLASH_DATETIME:"%Y/%m/%d %H:%M:%S.%fZ",SLASH_DATETIME_SEC:"%Y/%m/%d %H:%M:%S",SLASH_DATETIME_MIN:"%Y/%m/%d %H:%M",EUROPEAN:"%d/%m/%Y %H:%M:%S GMT%z",SLASH_DATE:"%Y/%m/%d",TIME_MICRO:"%H:%M:%S.%fZ",TIME_SEC:"%H:%M:%S",CUSTOM_GREETING:"[Bonjour celestin, ][la date actuelle est:: le] %d/%m/%Y [à] %H:%M:%S.%f[Z]"};constructor(e,t=!1){!1===this.dateChecker(e)?this._date=void 0:e instanceof f&&e&&e?._date?this._date=new Date(e?._date):e instanceof Date?this._date=new Date(e):"string"==typeof e?this._date=f.parseString(e,t):"number"==typeof e?this._date=new Date(e):null==e||"number"==typeof e&&isNaN(e)?this._date=new Date:this._date=void 0}static now(){return new f}static parse(e,t){return"string"==typeof t&&0<t.length&&(e instanceof f&&e&&e?._date||e instanceof Date||"string"==typeof e||"number"==typeof e||null==e||"number"==typeof e&&isNaN(e))&&f.parseWithFormat(e,t)||new f(e)}static unix(e){return new f(1e3*e)}static utc(){var e=new Date;return new f(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()))}year(){return this._date?.getFullYear()}month(){return this._date?this._date.getMonth()+1:void 0}date(){return this._date?.getDate()}hour(){return this._date?.getHours()}minute(){return this._date?.getMinutes()}second(){return this._date?.getSeconds()}millisecond(){return this._date?.getMilliseconds()}day(){return this._date?.getDay()}add(e,t){if(!this._date)return new f(void 0);var a=new Date(this._date);switch(t){case"years":a.setFullYear(a.getFullYear()+e);break;case"months":a.setMonth(a.getMonth()+e);break;case"days":a.setDate(a.getDate()+e);break;case"hours":a.setHours(a.getHours()+e);break;case"minutes":a.setMinutes(a.getMinutes()+e);break;case"seconds":a.setSeconds(a.getSeconds()+e);break;case"milliseconds":a.setMilliseconds(a.getMilliseconds()+e)}return new f(a)}subtract(e,t){return this.add(-e,t)}startOf(e){if(!this._date)return new f(void 0);var t=new Date(this._date);switch(e){case"year":t.setMonth(0,1),t.setHours(0,0,0,0);break;case"month":t.setDate(1),t.setHours(0,0,0,0);break;case"day":t.setHours(0,0,0,0);break;case"hour":t.setMinutes(0,0,0);break;case"minute":t.setSeconds(0,0);break;case"second":t.setMilliseconds(0)}return new f(t)}endOf(e){var t=this.startOf(e);switch(e){case"year":return t.add(1,"years").subtract(1,"milliseconds");case"month":return t.add(1,"months").subtract(1,"milliseconds");case"day":return t.add(1,"days").subtract(1,"milliseconds");case"hour":return t.add(1,"hours").subtract(1,"milliseconds");case"minute":return t.add(1,"minutes").subtract(1,"milliseconds");case"second":return t.add(1,"seconds").subtract(1,"milliseconds");default:return t}}isBefore(e,t="()"){t="]"===t[1],e=e instanceof f?e:new f(e);return!(!this._date||!e._date)&&(!t&&this._date<e._date||!!t&&this._date<=e._date)}isAfter(e,t="()"){t="["===t[0],e=e instanceof f?e:new f(e);return!(!this._date||!e._date)&&(!t&&this._date>e._date||!!t&&this._date>=e._date)}isSame(e,t){var a,e=e instanceof f?e:new f(e);return!t&&this._date&&e._date?this._date.getTime()===e._date.getTime():(a=t?this.startOf(t):void 0,e=t?e.startOf(t):void 0,!!(a&&a?._date&&e&&e?._date)&&a._date.getTime()===e._date.getTime())}isBetween(e,t,a="()"){var e=e instanceof f?e:new f(e),t=t instanceof f?t:new f(t),r="["===a[0],a="]"===a[1],r=r&&this.isSame(e)||this.isAfter(e),e=a&&this.isSame(t)||this.isBefore(t);return r&&e}format(e){if(!e)return this.toISOString();var t,a,r=f.PREDEFINED_FORMATS[e];if(r)return this.format(r);let i="",s=0;for(;s<e.length;)"["===e[s]?-1===(a=e.indexOf("]",s))?(i+=e[s],s++):(t=e.substring(s+1,a),i+=t,s=a+1):"%"===e[s]&&s+1<e.length?(t="%"+e[s+1],a=f.FORMAT_TOKENS[t],i+=a?a(this):t,s+=2):(i+=e[s],s++);return i}setTimezone(e){var t;return this._date?(t=this._date.getTimezoneOffset(),e=this.parseTimezoneOffset(e),e=new Date(this._date.getTime()+6e4*(e-t)),new f(e)):new f(void 0)}utc(){return this._date?new f(new Date(Date.UTC(this._date.getUTCFullYear(),this._date.getUTCMonth(),this._date.getUTCDate(),this._date.getUTCHours(),this._date.getUTCMinutes(),this._date.getUTCSeconds(),this._date.getUTCMilliseconds()))):new f(void 0)}local(){return this._date?new f(new Date(this._date.getFullYear(),this._date.getMonth(),this._date.getDate(),this._date.getHours(),this._date.getMinutes(),this._date.getSeconds(),this._date.getMilliseconds())):new f(void 0)}toString(){return this._date?.toString()}toISOString(){return this._date?.toISOString()}toDate(){return this._date?new Date(this._date):void 0}valueOf(){return this._date?.getTime()}unix(){return this._date?Math.floor(this._date.getTime()/1e3):void 0}utcOffset(){return this._date?-this._date.getTimezoneOffset():void 0}isCorrect(){return!!this._date&&!isNaN(this._date.getTime())}timezone(){if(this._date)try{return(new Intl.DateTimeFormat).resolvedOptions().timeZone||void 0}catch(e){return this.timezoneFromOffset()}}timezoneAbbr(){if(this._date)try{return new Intl.DateTimeFormat("en",{timeZoneName:"short"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type)?.value||void 0}catch(e){return this.timezoneAbbrFromOffset()}}timezoneName(){if(this._date)try{return new Intl.DateTimeFormat("en",{timeZoneName:"long"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type)?.value||void 0}catch(e){return this.timezoneNameFromOffset()}}timezoneOffsetString(){var e=this.utcOffset();if(void 0!==e)return(0<=e?"+":"-")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")+":"+(Math.abs(e)%60).toString().padStart(2,"0")}dateChecker(e){return e instanceof f&&!!e&&!!e?._date||e instanceof Date||"string"==typeof e||"number"==typeof e||null==e||"number"==typeof e&&isNaN(e)}timezoneFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"Etc/UTC",60:"Europe/Paris",120:"Europe/Athens",180:"Europe/Moscow",240:"Asia/Dubai",270:"Asia/Tehran",300:"Asia/Karachi",330:"Asia/Kolkata",345:"Asia/Rangoon",360:"Asia/Dhaka",390:"Asia/Yangon",420:"Asia/Bangkok",480:"Asia/Shanghai",525:"Asia/Kathmandu",540:"Asia/Tokyo",570:"Australia/Adelaide",600:"Australia/Sydney",630:"Australia/Lord_Howe",660:"Pacific/Noumea",675:"Australia/Eucla",720:"Pacific/Auckland",780:"Pacific/Chatham","-60":"Atlantic/Azores","-120":"America/Noronha","-180":"America/Argentina/Buenos_Aires","-210":"America/St_Johns","-240":"America/Halifax","-270":"America/Caracas","-300":"America/New_York","-360":"America/Chicago","-420":"America/Denver","-480":"America/Los_Angeles","-540":"America/Anchorage","-600":"Pacific/Honolulu","-660":"Pacific/Pago_Pago","-720":"Pacific/Kiritimati"}[e]||"Etc/GMT"+(0<=e?"-":"+")+Math.abs(e)/60}timezoneAbbrFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"GMT",60:"CET","-300":"EST","-360":"CST","-420":"MST","-480":"PST"}[e]||"GMT"+(0<=e?"+":"")+e/60}timezoneNameFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"Greenwich Mean Time",60:"Central European Time","-300":"Eastern Standard Time","-360":"Central Standard Time","-420":"Mountain Standard Time","-480":"Pacific Standard Time"}[e]||"GMT"+(0<=e?"+":"")+e/60}isDST(){if(this._date)try{var e=new Date(this._date.getFullYear(),0,1),t=new Date(this._date.getFullYear(),6,1),a=Math.max(e.getTimezoneOffset(),t.getTimezoneOffset());return this._date.getTimezoneOffset()<a}catch(e){}}static parseString(e,t=!1){var a=new Date(e);if(!isNaN(a.getTime()))return a;var r,i=[/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.(\d{3})Z$/,/^(\d{4})-(\d{2})-(\d{2})$/,/^(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/];for(r of i){var s=e.match(r);if(s){s=s.slice(1).map(Number);if(r===i[0])return new Date(Date.UTC(s[0],s[1]-1,s[2],s[3],s[4],s[5],s[6]));if(r===i[1])return new Date(s[0],s[1]-1,s[2]);if(r===i[2])return new Date(s[0],s[1]-1,s[2],s[3],s[4],s[5]);if(r===i[3])return new Date(s[0],s[1]-1,s[2],s[3],s[4],s[5])}}a=new Date(e);if(!isNaN(a.getTime()))return a;if(t)throw new Error("Unable to parse date string: "+e)}static parseWithFormat(e,i){if(e&&i){var s=String(e).trim();if(s){var n={Y:{regex:/\d{4}/,extract:e=>parseInt(e,10)},y:{regex:/\d{2}/,extract:e=>{e=parseInt(e,10);return 70<=e?1900+e:2e3+e}},m:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},d:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},H:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},M:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},S:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},f:{regex:/\d{1,3}/,extract:e=>parseInt(e,10)}},o={year:(new Date).getFullYear(),month:1,day:1,hour:0,minute:0,second:0,millisecond:0};let e=0,t=0,a=!1,r="";for(;t<i.length&&e<s.length;){var d=i[t];if("["===d)a=!0,r="",t++;else if("]"===d&&a){if(s.substring(e,e+r.length)!==r)return;e+=r.length,a=!1,r="",t++}else if(a)r+=d,t++;else if("%"===d&&t+1<i.length){var c=i[t+1],u=n[c];if(u){var h=s.substring(e).match(u.regex);if(!h||0!==h.index)return;var h=h[0],l=u.extract(h);switch(c){case"Y":case"y":o.year=l;break;case"m":o.month=l;break;case"d":o.day=l;break;case"H":o.hour=l;break;case"M":o.minute=l;break;case"S":o.second=l;break;case"f":o.millisecond=l}e+=h.length}else e++;t+=2}else{if(d!==s[e])return;e++,t++}}if(!(o.month<1||12<o.month||o.day<1||31<o.day||o.hour<0||23<o.hour||o.minute<0||59<o.minute||o.second<0||59<o.second||o.millisecond<0||999<o.millisecond))try{var m=new Date(o.year,o.month-1,o.day,o.hour,o.minute,o.second,o.millisecond);if(!isNaN(m.getTime()))return new f(m)}catch(e){}}}}static getTokenLength(e){return{Y:4,y:2,m:2,d:2,H:2,M:2,S:2,f:3,z:5}[e]||1}parseTimezoneOffset(e){var t={UTC:0,EST:-300,EDT:-240,CST:-360,CDT:-300,PST:-480,PDT:-420};return void 0!==t[e.toUpperCase()]?t[e.toUpperCase()]:(t=e.match(/^([+-])(\d{1,2}):?(\d{2})?$/))?("+"===t[1]?1:-1)*(60*parseInt(t[2],10)+(t[3]?parseInt(t[3],10):0)):this._date?-this._date.getTimezoneOffset():0}static get FORMATS(){return{...f.PREDEFINED_FORMATS}}}class r{static DEFAULT_OPTIONS={path:"/",secure:!0,sameSite:"lax"};static set(t,e,a={}){if(this.isBrowser())try{var r=this.serialize(e),i=encodeURIComponent(r),s=this.buildCookieString(t,i,a);document.cookie=s}catch(e){console.error(`Cooks: Error setting cookie "${t}":`,e)}}static get(t){if(!this.isBrowser())return null;try{var e,a=this.getAllCookies()[t];return a?(e=decodeURIComponent(a),this.deserialize(e)):null}catch(e){return console.error(`Cooks: Error getting cookie "${t}":`,e),null}}static remove(e,t="/",a){this.isBrowser()&&(t={expires:new Date(0),path:t,domain:a},this.set(e,"",t))}static has(e){return null!==this.get(e)}static keys(){var e;return this.isBrowser()?(e=this.getAllCookies(),Object.keys(e)):[]}static clear(){var e;this.isBrowser()&&(e=this.getAllCookies(),Object.keys(e).forEach(e=>{this.remove(e)}))}static serialize(e){return e instanceof Date?JSON.stringify({__type:"Date",__value:e.toISOString()}):JSON.stringify(e)}static deserialize(e){e=JSON.parse(e);return e&&"object"==typeof e&&"Date"===e.__type?new Date(e.__value):e}static buildCookieString(e,t,a){a={...this.DEFAULT_OPTIONS,...a};let r=e+"="+t;if(void 0!==a.expires){let e;e="number"==typeof a.expires?(new f).add(a.expires,"seconds").toDate()||new Date:a.expires,r+="; expires="+e.toUTCString()}return a.path&&(r+="; path="+a.path),a.domain&&(r+="; domain="+a.domain),a.secure&&(r+="; secure"),a.sameSite&&(r+="; samesite="+a.sameSite),console.log("Cooks - buildCookieString | cookieString:: ",r),r}static getAllCookies(){return document.cookie.split(";").reduce((e,t)=>{var[t,a]=t.split("=").map(e=>e.trim());return t&&(e[t]=a||""),e},{})}static isBrowser(){return"undefined"!=typeof window&&"undefined"!=typeof document}static exposeToGlobal(){"undefined"!=typeof window&&(window.Cooks=r)}}return"undefined"!=typeof window&&(window.Cooks=r),t={default:r,Cooks:r},"undefined"!=typeof exports&&(exports.default=r,exports.Cooks=r),t})(),CooksElementGF=globalFunct.Cooks,defaultElementGF=globalFunct.default;
1
+ let globalFunct=(()=>{var e=["0","1","2","3","4","5","6","7","8","9"],t=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],a=[...t,...t.map(e=>e.toUpperCase())];[...e,...t],[...e,...a];class f{_date;static FORMAT_TOKENS={"%Y":e=>e.year()?.toString().padStart(4,"0"),"%y":e=>e.year()?.toString().slice(-2).padStart(2,"0"),"%m":e=>e.month()?.toString().padStart(2,"0"),"%d":e=>e.date()?.toString().padStart(2,"0"),"%H":e=>e.hour()?.toString().padStart(2,"0"),"%M":e=>e.minute()?.toString().padStart(2,"0"),"%S":e=>e.second()?.toString().padStart(2,"0"),"%f":e=>e.millisecond()?.toString().padStart(3,"0"),"%z":e=>{e=e.utcOffset();if(e)return(0<=e?"+":"-")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")+(Math.abs(e)%60).toString().padStart(2,"0")},"%s":e=>{e=e.valueOf();return e?Math.floor(e/1e3).toString():void 0}};static PREDEFINED_FORMATS={ISO:"%Y-%m-%dT%H:%M:%S.%fZ",ISO_DATE:"%Y-%m-%d",ISO_TIME:"%H:%M:%S.%fZ",COMPACT:"%Y%m%d%H%M%S",SLASH_DATETIME:"%Y/%m/%d %H:%M:%S.%fZ",SLASH_DATETIME_SEC:"%Y/%m/%d %H:%M:%S",SLASH_DATETIME_MIN:"%Y/%m/%d %H:%M",EUROPEAN:"%d/%m/%Y %H:%M:%S GMT%z",SLASH_DATE:"%Y/%m/%d",TIME_MICRO:"%H:%M:%S.%fZ",TIME_SEC:"%H:%M:%S",CUSTOM_GREETING:"[Bonjour celestin, ][la date actuelle est:: le] %d/%m/%Y [à] %H:%M:%S.%f[Z]"};constructor(e,t=!1){!1===this.dateChecker(e)?this._date=void 0:e instanceof f&&e&&e?._date?this._date=new Date(e?._date):e instanceof Date?this._date=new Date(e):"string"==typeof e?this._date=f.parseString(e,t):"number"==typeof e?this._date=new Date(e):null==e||"number"==typeof e&&isNaN(e)?this._date=new Date:this._date=void 0}static now(){return new f}static parse(e,t){return"string"==typeof t&&0<t.length&&(e instanceof f&&e&&e?._date||e instanceof Date||"string"==typeof e||"number"==typeof e||null==e||"number"==typeof e&&isNaN(e))&&f.parseWithFormat(e,t)||new f(e)}static unix(e){return new f(1e3*e)}static utc(){var e=new Date;return new f(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()))}year(){return this._date?.getFullYear()}month(){return this._date?this._date.getMonth()+1:void 0}date(){return this._date?.getDate()}hour(){return this._date?.getHours()}minute(){return this._date?.getMinutes()}second(){return this._date?.getSeconds()}millisecond(){return this._date?.getMilliseconds()}day(){return this._date?.getDay()}add(e,t){if(!this._date)return new f(void 0);var a=new Date(this._date);switch(t){case"years":a.setFullYear(a.getFullYear()+e);break;case"months":a.setMonth(a.getMonth()+e);break;case"days":a.setDate(a.getDate()+e);break;case"hours":a.setHours(a.getHours()+e);break;case"minutes":a.setMinutes(a.getMinutes()+e);break;case"seconds":a.setSeconds(a.getSeconds()+e);break;case"milliseconds":a.setMilliseconds(a.getMilliseconds()+e)}return new f(a)}subtract(e,t){return this.add(-e,t)}startOf(e){if(!this._date)return new f(void 0);var t=new Date(this._date);switch(e){case"year":t.setMonth(0,1),t.setHours(0,0,0,0);break;case"month":t.setDate(1),t.setHours(0,0,0,0);break;case"day":t.setHours(0,0,0,0);break;case"hour":t.setMinutes(0,0,0);break;case"minute":t.setSeconds(0,0);break;case"second":t.setMilliseconds(0)}return new f(t)}endOf(e){var t=this.startOf(e);switch(e){case"year":return t.add(1,"years").subtract(1,"milliseconds");case"month":return t.add(1,"months").subtract(1,"milliseconds");case"day":return t.add(1,"days").subtract(1,"milliseconds");case"hour":return t.add(1,"hours").subtract(1,"milliseconds");case"minute":return t.add(1,"minutes").subtract(1,"milliseconds");case"second":return t.add(1,"seconds").subtract(1,"milliseconds");default:return t}}isBefore(e,t="()"){t="]"===t[1],e=e instanceof f?e:new f(e);return!(!this._date||!e._date)&&(!t&&this._date<e._date||!!t&&this._date<=e._date)}isAfter(e,t="()"){t="["===t[0],e=e instanceof f?e:new f(e);return!(!this._date||!e._date)&&(!t&&this._date>e._date||!!t&&this._date>=e._date)}isSame(e,t){var a,e=e instanceof f?e:new f(e);return!t&&this._date&&e._date?this._date.getTime()===e._date.getTime():(a=t?this.startOf(t):void 0,e=t?e.startOf(t):void 0,!!(a&&a?._date&&e&&e?._date)&&a._date.getTime()===e._date.getTime())}isBetween(e,t,a="()"){var e=e instanceof f?e:new f(e),t=t instanceof f?t:new f(t),r="["===a[0],a="]"===a[1],r=r&&this.isSame(e)||this.isAfter(e),e=a&&this.isSame(t)||this.isBefore(t);return r&&e}format(e){if(!e)return this.toISOString();var t,a,r=f.PREDEFINED_FORMATS[e];if(r)return this.format(r);let i="",s=0;for(;s<e.length;)"["===e[s]?-1===(a=e.indexOf("]",s))?(i+=e[s],s++):(t=e.substring(s+1,a),i+=t,s=a+1):"%"===e[s]&&s+1<e.length?(t="%"+e[s+1],a=f.FORMAT_TOKENS[t],i+=a?a(this):t,s+=2):(i+=e[s],s++);return i}setTimezone(e){var t;return this._date?(t=this._date.getTimezoneOffset(),e=this.parseTimezoneOffset(e),e=new Date(this._date.getTime()+6e4*(e-t)),new f(e)):new f(void 0)}utc(){return this._date?new f(new Date(Date.UTC(this._date.getUTCFullYear(),this._date.getUTCMonth(),this._date.getUTCDate(),this._date.getUTCHours(),this._date.getUTCMinutes(),this._date.getUTCSeconds(),this._date.getUTCMilliseconds()))):new f(void 0)}local(){return this._date?new f(new Date(this._date.getFullYear(),this._date.getMonth(),this._date.getDate(),this._date.getHours(),this._date.getMinutes(),this._date.getSeconds(),this._date.getMilliseconds())):new f(void 0)}toString(){return this._date?.toString()}toISOString(){return this._date?.toISOString()}toDate(){return this._date?new Date(this._date):void 0}valueOf(){return this._date?.getTime()}unix(){return this._date?Math.floor(this._date.getTime()/1e3):void 0}utcOffset(){return this._date?-this._date.getTimezoneOffset():void 0}isCorrect(){return!!this._date&&!isNaN(this._date.getTime())}timezone(){if(this._date)try{return(new Intl.DateTimeFormat).resolvedOptions().timeZone||void 0}catch(e){return this.timezoneFromOffset()}}timezoneAbbr(){if(this._date)try{return new Intl.DateTimeFormat("en",{timeZoneName:"short"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type)?.value||void 0}catch(e){return this.timezoneAbbrFromOffset()}}timezoneName(){if(this._date)try{return new Intl.DateTimeFormat("en",{timeZoneName:"long"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type)?.value||void 0}catch(e){return this.timezoneNameFromOffset()}}timezoneOffsetString(){var e=this.utcOffset();if(void 0!==e)return(0<=e?"+":"-")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")+":"+(Math.abs(e)%60).toString().padStart(2,"0")}dateChecker(e){return e instanceof f&&!!e&&!!e?._date||e instanceof Date||"string"==typeof e||"number"==typeof e||null==e||"number"==typeof e&&isNaN(e)}timezoneFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"Etc/UTC",60:"Europe/Paris",120:"Europe/Athens",180:"Europe/Moscow",240:"Asia/Dubai",270:"Asia/Tehran",300:"Asia/Karachi",330:"Asia/Kolkata",345:"Asia/Rangoon",360:"Asia/Dhaka",390:"Asia/Yangon",420:"Asia/Bangkok",480:"Asia/Shanghai",525:"Asia/Kathmandu",540:"Asia/Tokyo",570:"Australia/Adelaide",600:"Australia/Sydney",630:"Australia/Lord_Howe",660:"Pacific/Noumea",675:"Australia/Eucla",720:"Pacific/Auckland",780:"Pacific/Chatham","-60":"Atlantic/Azores","-120":"America/Noronha","-180":"America/Argentina/Buenos_Aires","-210":"America/St_Johns","-240":"America/Halifax","-270":"America/Caracas","-300":"America/New_York","-360":"America/Chicago","-420":"America/Denver","-480":"America/Los_Angeles","-540":"America/Anchorage","-600":"Pacific/Honolulu","-660":"Pacific/Pago_Pago","-720":"Pacific/Kiritimati"}[e]||"Etc/GMT"+(0<=e?"-":"+")+Math.abs(e)/60}timezoneAbbrFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"GMT",60:"CET","-300":"EST","-360":"CST","-420":"MST","-480":"PST"}[e]||"GMT"+(0<=e?"+":"")+e/60}timezoneNameFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"Greenwich Mean Time",60:"Central European Time","-300":"Eastern Standard Time","-360":"Central Standard Time","-420":"Mountain Standard Time","-480":"Pacific Standard Time"}[e]||"GMT"+(0<=e?"+":"")+e/60}isDST(){if(this._date)try{var e=new Date(this._date.getFullYear(),0,1),t=new Date(this._date.getFullYear(),6,1),a=Math.max(e.getTimezoneOffset(),t.getTimezoneOffset());return this._date.getTimezoneOffset()<a}catch(e){}}static parseString(e,t=!1){var a=new Date(e);if(!isNaN(a.getTime()))return a;var r,i=[/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.(\d{3})Z$/,/^(\d{4})-(\d{2})-(\d{2})$/,/^(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/];for(r of i){var s=e.match(r);if(s){s=s.slice(1).map(Number);if(r===i[0])return new Date(Date.UTC(s[0],s[1]-1,s[2],s[3],s[4],s[5],s[6]));if(r===i[1])return new Date(s[0],s[1]-1,s[2]);if(r===i[2])return new Date(s[0],s[1]-1,s[2],s[3],s[4],s[5]);if(r===i[3])return new Date(s[0],s[1]-1,s[2],s[3],s[4],s[5])}}a=new Date(e);if(!isNaN(a.getTime()))return a;if(t)throw new Error("Unable to parse date string: "+e)}static parseWithFormat(e,i){if(e&&i){var s=String(e).trim();if(s){var n={Y:{regex:/\d{4}/,extract:e=>parseInt(e,10)},y:{regex:/\d{2}/,extract:e=>{e=parseInt(e,10);return 70<=e?1900+e:2e3+e}},m:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},d:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},H:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},M:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},S:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},f:{regex:/\d{1,3}/,extract:e=>parseInt(e,10)}},o={year:(new Date).getFullYear(),month:1,day:1,hour:0,minute:0,second:0,millisecond:0};let e=0,t=0,a=!1,r="";for(;t<i.length&&e<s.length;){var d=i[t];if("["===d)a=!0,r="",t++;else if("]"===d&&a){if(s.substring(e,e+r.length)!==r)return;e+=r.length,a=!1,r="",t++}else if(a)r+=d,t++;else if("%"===d&&t+1<i.length){var c=i[t+1],u=n[c];if(u){var h=s.substring(e).match(u.regex);if(!h||0!==h.index)return;var h=h[0],l=u.extract(h);switch(c){case"Y":case"y":o.year=l;break;case"m":o.month=l;break;case"d":o.day=l;break;case"H":o.hour=l;break;case"M":o.minute=l;break;case"S":o.second=l;break;case"f":o.millisecond=l}e+=h.length}else e++;t+=2}else{if(d!==s[e])return;e++,t++}}if(!(o.month<1||12<o.month||o.day<1||31<o.day||o.hour<0||23<o.hour||o.minute<0||59<o.minute||o.second<0||59<o.second||o.millisecond<0||999<o.millisecond))try{var m=new Date(o.year,o.month-1,o.day,o.hour,o.minute,o.second,o.millisecond);if(!isNaN(m.getTime()))return new f(m)}catch(e){}}}}static getTokenLength(e){return{Y:4,y:2,m:2,d:2,H:2,M:2,S:2,f:3,z:5}[e]||1}parseTimezoneOffset(e){var t={UTC:0,EST:-300,EDT:-240,CST:-360,CDT:-300,PST:-480,PDT:-420};return void 0!==t[e.toUpperCase()]?t[e.toUpperCase()]:(t=e.match(/^([+-])(\d{1,2}):?(\d{2})?$/))?("+"===t[1]?1:-1)*(60*parseInt(t[2],10)+(t[3]?parseInt(t[3],10):0)):this._date?-this._date.getTimezoneOffset():0}static get FORMATS(){return{...f.PREDEFINED_FORMATS}}}class r{static DEFAULT_OPTIONS={path:"/",secure:!0,sameSite:"lax"};static set(t,e,a={}){if(this.isBrowser())try{var r=this.serialize(e),i=encodeURIComponent(r),s=this.buildCookieString(t,i,a);document.cookie=s}catch(e){console.error(`Cooks: Error setting cookie "${t}":`,e)}}static get(t){if(!this.isBrowser())return null;try{var e,a=this.getAllCookies()[t];return a?(e=decodeURIComponent(a),this.deserialize(e)):null}catch(e){return console.error(`Cooks: Error getting cookie "${t}":`,e),null}}static remove(e,t="/",a){this.isBrowser()&&(t={expires:new Date(0),path:t,domain:a},this.set(e,"",t))}static has(e){return null!==this.get(e)}static keys(){var e;return this.isBrowser()?(e=this.getAllCookies(),Object.keys(e)):[]}static clear(){var e;this.isBrowser()&&(e=this.getAllCookies(),Object.keys(e).forEach(e=>{this.remove(e)}))}static serialize(e){return e instanceof Date?JSON.stringify({__type:"Date",__value:e.toISOString()}):JSON.stringify(e)}static deserialize(e){e=JSON.parse(e);return e&&"object"==typeof e&&"Date"===e.__type?new Date(e.__value):e}static buildCookieString(e,t,a){a={...this.DEFAULT_OPTIONS,...a};let r=e+"="+t;if(void 0!==a.expires){let e;e="number"==typeof a.expires?(new f).add(a.expires,"seconds").toDate()||new Date:a.expires,r+="; expires="+e.toUTCString()}return a.path&&(r+="; path="+a.path),a.domain&&(r+="; domain="+a.domain),a.secure&&(r+="; secure"),a.sameSite&&(r+="; samesite="+a.sameSite),console.log("Cooks - buildCookieString | cookieString:: ",r),r}static getAllCookies(){return document.cookie.split(";").reduce((e,t)=>{var[t,a]=t.split("=").map(e=>e.trim());return t&&(e[t]=a||""),e},{})}static isBrowser(){return"undefined"!=typeof window&&"undefined"!=typeof document}static exposeToGlobal(){"undefined"!=typeof window&&(window.Cooks=r)}}return"undefined"!=typeof window&&(window.Cooks=r),t={default:r,Cooks:r}})(),CooksElementGF=globalFunct.Cooks,defaultElementGF=globalFunct.default;