@arc-js/intl 0.0.5 → 0.0.7
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/README.md +130 -109
- package/config.d.ts +14 -6
- package/config.js +1 -6
- package/config.min.js +1 -1
- package/core/TranslationService.js +57 -59
- package/core/TranslationService.min.js +1 -1
- package/hooks/useTranslation.jsx +30 -8
- package/hooks/useTranslation.tsx +34 -7
- package/package.json +1 -5
- package/providers/IntlProvider.jsx +69 -21
- package/providers/IntlProvider.tsx +87 -25
- package/utils/loaders.d.ts +15 -1
- package/utils/loaders.js +41 -918
- package/utils/loaders.min.js +1 -1
- package/utils.d.ts +1 -2
- package/utils.js +0 -900
- package/utils.min.js +1 -1
- package/vite.config.ts +0 -14
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ pnpm add @arc-js/intl @arc-js/cooks react
|
|
|
47
47
|
|
|
48
48
|
### Dépendances requises
|
|
49
49
|
- React 19+
|
|
50
|
-
- @arc-js/cooks 0.0
|
|
50
|
+
- @arc-js/cooks 1.0.0+
|
|
51
51
|
- TypeScript 5.0+ (recommandé)
|
|
52
52
|
- Vite (pour le chargement dynamique)
|
|
53
53
|
|
|
@@ -91,7 +91,15 @@ const App = () => {
|
|
|
91
91
|
|
|
92
92
|
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
93
93
|
<React.StrictMode>
|
|
94
|
-
<ArcIntlProvider
|
|
94
|
+
<ArcIntlProvider
|
|
95
|
+
translations={{
|
|
96
|
+
base: {
|
|
97
|
+
en: async () => (await import('./locales/en.json')).default,
|
|
98
|
+
fr: async () => (await import('./locales/fr.json')).default
|
|
99
|
+
}
|
|
100
|
+
}}
|
|
101
|
+
supportedLocales={['en', 'fr', 'es']}
|
|
102
|
+
>
|
|
95
103
|
<App />
|
|
96
104
|
</ArcIntlProvider>
|
|
97
105
|
</React.StrictMode>
|
|
@@ -139,7 +147,7 @@ const MyComponent = () => {
|
|
|
139
147
|
t, // Fonction de traduction principale
|
|
140
148
|
changeLocale, // Changer la locale
|
|
141
149
|
currentLocale, // Locale actuelle
|
|
142
|
-
isLoading
|
|
150
|
+
isLoading // État de chargement
|
|
143
151
|
} = useTranslation('admin'); // Optionnel: nom du module
|
|
144
152
|
|
|
145
153
|
// Exemple d'utilisation
|
|
@@ -152,7 +160,7 @@ const MyComponent = () => {
|
|
|
152
160
|
<h1>{t('admin.dashboard.title')}</h1>
|
|
153
161
|
<p>{t('common.welcome')}</p>
|
|
154
162
|
<button onClick={handleChangeLanguage}>
|
|
155
|
-
{
|
|
163
|
+
Switch to {currentLocale === 'en' ? 'French' : 'English'}
|
|
156
164
|
</button>
|
|
157
165
|
</div>
|
|
158
166
|
);
|
|
@@ -164,17 +172,28 @@ const MyComponent = () => {
|
|
|
164
172
|
```typescript
|
|
165
173
|
import { ArcIntlProvider } from '@arc-js/intl';
|
|
166
174
|
|
|
167
|
-
// Configuration avec
|
|
175
|
+
// Configuration complète avec modules
|
|
168
176
|
<ArcIntlProvider
|
|
169
|
-
|
|
177
|
+
translations={{
|
|
178
|
+
base: {
|
|
179
|
+
en: async () => (await import('./locales/en.json')).default,
|
|
180
|
+
fr: async () => (await import('./locales/fr.json')).default
|
|
181
|
+
},
|
|
182
|
+
modules: {
|
|
183
|
+
admin: {
|
|
184
|
+
en: async () => (await import('./modules/admin/locales/en.json')).default,
|
|
185
|
+
fr: async () => (await import('./modules/admin/locales/fr.json')).default
|
|
186
|
+
},
|
|
187
|
+
dashboard: {
|
|
188
|
+
en: async () => (await import('./modules/dashboard/locales/en.json')).default,
|
|
189
|
+
fr: async () => (await import('./modules/dashboard/locales/fr.json')).default
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}}
|
|
193
|
+
supportedLocales={['en', 'fr', 'es']}
|
|
170
194
|
>
|
|
171
195
|
{children}
|
|
172
196
|
</ArcIntlProvider>
|
|
173
|
-
|
|
174
|
-
// Configuration par défaut (en, fr)
|
|
175
|
-
<ArcIntlProvider>
|
|
176
|
-
{children}
|
|
177
|
-
</ArcIntlProvider>
|
|
178
197
|
```
|
|
179
198
|
|
|
180
199
|
## 🔧 Utilisation Avancée
|
|
@@ -211,13 +230,6 @@ const Greeting = ({ userName, itemCount }) => {
|
|
|
211
230
|
"one": "You have one unread message",
|
|
212
231
|
"other": "You have {count} unread messages"
|
|
213
232
|
}
|
|
214
|
-
},
|
|
215
|
-
"action": {
|
|
216
|
-
"save": "Save",
|
|
217
|
-
"save_context": {
|
|
218
|
-
"draft": "Save as draft",
|
|
219
|
-
"final": "Save and publish"
|
|
220
|
-
}
|
|
221
233
|
}
|
|
222
234
|
}
|
|
223
235
|
|
|
@@ -229,10 +241,6 @@ const Notification = ({ unreadCount }) => {
|
|
|
229
241
|
<div>
|
|
230
242
|
{/* Pluriel automatique */}
|
|
231
243
|
<p>{t('messages.unread', { count: unreadCount })}</p>
|
|
232
|
-
|
|
233
|
-
{/* Contexte spécifique */}
|
|
234
|
-
<button>{t('action.save', {}, { context: 'draft' })}</button>
|
|
235
|
-
<button>{t('action.save', {}, { context: 'final' })}</button>
|
|
236
244
|
</div>
|
|
237
245
|
);
|
|
238
246
|
};
|
|
@@ -242,19 +250,23 @@ const Notification = ({ unreadCount }) => {
|
|
|
242
250
|
|
|
243
251
|
```typescript
|
|
244
252
|
import { useEffect } from 'react';
|
|
245
|
-
import {
|
|
253
|
+
import { useTranslation } from '@arc-js/intl';
|
|
246
254
|
|
|
247
255
|
const AdminModule = () => {
|
|
248
|
-
const {
|
|
256
|
+
const { loadModule, t, isModuleLoaded } = useTranslation('admin');
|
|
249
257
|
|
|
250
258
|
useEffect(() => {
|
|
251
259
|
// Charger les traductions du module admin à la demande
|
|
252
|
-
|
|
260
|
+
if (!isModuleLoaded) {
|
|
261
|
+
loadModule('admin');
|
|
262
|
+
}
|
|
253
263
|
}, []);
|
|
254
264
|
|
|
265
|
+
if (!isModuleLoaded) return <div>Loading translations...</div>;
|
|
266
|
+
|
|
255
267
|
return (
|
|
256
268
|
<div>
|
|
257
|
-
<h1>{t('admin.dashboard.title'
|
|
269
|
+
<h1>{t('admin.dashboard.title')}</h1>
|
|
258
270
|
</div>
|
|
259
271
|
);
|
|
260
272
|
};
|
|
@@ -359,27 +371,29 @@ const ContactForm = () => {
|
|
|
359
371
|
### Exemple 3 : Dashboard avec modules multiples
|
|
360
372
|
|
|
361
373
|
```typescript
|
|
362
|
-
import {
|
|
374
|
+
import { useTranslation } from '@arc-js/intl';
|
|
363
375
|
import { useEffect } from 'react';
|
|
364
376
|
|
|
365
377
|
const Dashboard = () => {
|
|
366
|
-
const { t,
|
|
378
|
+
const { t, loadModule, currentLocale, isLoading } = useTranslation('admin');
|
|
367
379
|
|
|
368
380
|
// Charger les traductions de plusieurs modules
|
|
369
381
|
useEffect(() => {
|
|
370
382
|
const loadModules = async () => {
|
|
371
|
-
await
|
|
372
|
-
await
|
|
373
|
-
await
|
|
383
|
+
await loadModule('admin');
|
|
384
|
+
await loadModule('analytics');
|
|
385
|
+
await loadModule('reports');
|
|
374
386
|
};
|
|
375
387
|
loadModules();
|
|
376
388
|
}, [currentLocale]);
|
|
377
389
|
|
|
390
|
+
if (isLoading) return <div>Loading translations...</div>;
|
|
391
|
+
|
|
378
392
|
return (
|
|
379
393
|
<div className="dashboard">
|
|
380
394
|
<header>
|
|
381
|
-
<h1>{t('dashboard.title'
|
|
382
|
-
<p>{t('
|
|
395
|
+
<h1>{t('admin.dashboard.title')}</h1>
|
|
396
|
+
<p>{t('common.welcome', { user: 'John Doe' })}</p>
|
|
383
397
|
</header>
|
|
384
398
|
|
|
385
399
|
<section className="stats">
|
|
@@ -402,68 +416,62 @@ const Dashboard = () => {
|
|
|
402
416
|
};
|
|
403
417
|
```
|
|
404
418
|
|
|
405
|
-
##
|
|
419
|
+
## 📋 API Reference
|
|
406
420
|
|
|
407
|
-
###
|
|
421
|
+
### ArcIntlProvider
|
|
422
|
+
| Prop | Type | Description | Required |
|
|
423
|
+
|------|------|-------------|----------|
|
|
424
|
+
| `translations` | `TranslationsConfig` | Configuration des chargeurs de traductions | Oui |
|
|
425
|
+
| `supportedLocales` | `string[]` | Locales supportées (défaut: ['en', 'fr']) | Non |
|
|
426
|
+
| `children` | `React.ReactNode` | Composants enfants | Oui |
|
|
408
427
|
|
|
428
|
+
### Hook useTranslation
|
|
429
|
+
Retourne un objet avec:
|
|
430
|
+
- `t(key: string, params?: Record<string, any>, options?: TranslationOptions)`: Fonction de traduction
|
|
431
|
+
- `changeLocale(locale: string)`: Changer la locale actuelle
|
|
432
|
+
- `currentLocale`: Locale actuelle
|
|
433
|
+
- `isLoading`: État de chargement global
|
|
434
|
+
- `isModuleLoaded`: Indique si le module demandé est chargé
|
|
435
|
+
- `loadModule(moduleName: string)`: Charge un module spécifique
|
|
436
|
+
|
|
437
|
+
### Options de Traduction
|
|
409
438
|
```typescript
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
plugins: [react()],
|
|
416
|
-
resolve: {
|
|
417
|
-
alias: {
|
|
418
|
-
'@arc-js/intl': '@arc-js/intl/index.js'
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
### Configuration TypeScript
|
|
425
|
-
|
|
426
|
-
```json
|
|
427
|
-
{
|
|
428
|
-
"compilerOptions": {
|
|
429
|
-
"target": "ES2020",
|
|
430
|
-
"lib": ["DOM", "DOM.Iterable", "ES2020"],
|
|
431
|
-
"module": "ESNext",
|
|
432
|
-
"moduleResolution": "bundler",
|
|
433
|
-
"allowImportingTsExtensions": true,
|
|
434
|
-
"resolveJsonModule": true,
|
|
435
|
-
"strict": true,
|
|
436
|
-
"types": ["vite/client"]
|
|
437
|
-
},
|
|
438
|
-
"include": ["src", "node_modules/@arc-js/intl/**/*"]
|
|
439
|
+
interface TranslationOptions {
|
|
440
|
+
moduleName?: string; // Nom du module (défaut: 'core')
|
|
441
|
+
defaultValue?: string; // Valeur par défaut si clé non trouvée
|
|
442
|
+
count?: number; // Pour la gestion des pluriels
|
|
443
|
+
context?: string; // Contexte spécifique
|
|
439
444
|
}
|
|
440
445
|
```
|
|
441
446
|
|
|
442
|
-
###
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
447
|
+
### Structure de configuration
|
|
448
|
+
```typescript
|
|
449
|
+
interface TranslationsConfig {
|
|
450
|
+
base: {
|
|
451
|
+
[locale: string]: () => Promise<Record<string, any>>;
|
|
452
|
+
};
|
|
453
|
+
modules?: {
|
|
454
|
+
[moduleName: string]: {
|
|
455
|
+
[locale: string]: () => Promise<Record<string, any>>;
|
|
456
|
+
};
|
|
457
|
+
};
|
|
458
|
+
}
|
|
449
459
|
```
|
|
450
460
|
|
|
451
461
|
## 🛡️ Gestion des Erreurs
|
|
452
462
|
|
|
453
|
-
### Fallback
|
|
454
|
-
|
|
463
|
+
### Fallback sécurisé
|
|
455
464
|
```typescript
|
|
456
|
-
|
|
457
|
-
const MissingKeyHandler = () => {
|
|
465
|
+
const SafeComponent = () => {
|
|
458
466
|
const { t } = useTranslation();
|
|
459
467
|
|
|
460
|
-
//
|
|
461
|
-
const title = t('nonexistent.key'
|
|
468
|
+
// Utilisation sécurisée avec valeur par défaut
|
|
469
|
+
const title = t('nonexistent.key', {}, {
|
|
470
|
+
defaultValue: 'Default Title'
|
|
471
|
+
});
|
|
462
472
|
|
|
463
|
-
//
|
|
464
|
-
const subtitle = t('another.missing.key'
|
|
465
|
-
defaultValue: 'Default text'
|
|
466
|
-
}); // Retourne: "Default text"
|
|
473
|
+
// Si pas de valeur par défaut, retourne la clé
|
|
474
|
+
const subtitle = t('another.missing.key'); // Retourne: "another.missing.key"
|
|
467
475
|
|
|
468
476
|
return (
|
|
469
477
|
<div>
|
|
@@ -474,32 +482,40 @@ const MissingKeyHandler = () => {
|
|
|
474
482
|
};
|
|
475
483
|
```
|
|
476
484
|
|
|
477
|
-
###
|
|
478
|
-
|
|
485
|
+
### Logs en développement
|
|
479
486
|
```typescript
|
|
480
|
-
//
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
const validateTranslations = (locale: string) => {
|
|
485
|
-
const basePath = path.join(__dirname, 'locales', `\${locale}.json`);
|
|
486
|
-
const baseTranslations = JSON.parse(fs.readFileSync(basePath, 'utf-8'));
|
|
487
|
+
// En mode développement, les clés manquantes sont automatiquement loggées
|
|
488
|
+
const MissingTranslations = () => {
|
|
489
|
+
const { t } = useTranslation();
|
|
487
490
|
|
|
488
|
-
//
|
|
489
|
-
const
|
|
490
|
-
requiredKeys.forEach(key => {
|
|
491
|
-
if (!baseTranslations[key]) {
|
|
492
|
-
console.warn(`Missing required namespace "\${key}" in \${locale}`);
|
|
493
|
-
}
|
|
494
|
-
});
|
|
491
|
+
// Ceci loggue un avertissement en développement
|
|
492
|
+
const missingKey = t('non.existent.key');
|
|
495
493
|
|
|
496
|
-
|
|
497
|
-
Object.entries(baseTranslations).forEach(([namespace, translations]) => {
|
|
498
|
-
// Logique de validation spécifique
|
|
499
|
-
});
|
|
494
|
+
return <div>{missingKey}</div>;
|
|
500
495
|
};
|
|
501
496
|
```
|
|
502
497
|
|
|
498
|
+
## 🔧 Configuration TypeScript
|
|
499
|
+
|
|
500
|
+
```json
|
|
501
|
+
{
|
|
502
|
+
"compilerOptions": {
|
|
503
|
+
"target": "ES2020",
|
|
504
|
+
"lib": ["DOM", "DOM.Iterable", "ES2020"],
|
|
505
|
+
"module": "ESNext",
|
|
506
|
+
"moduleResolution": "bundler",
|
|
507
|
+
"allowImportingTsExtensions": true,
|
|
508
|
+
"resolveJsonModule": true,
|
|
509
|
+
"isolatedModules": true,
|
|
510
|
+
"noEmit": true,
|
|
511
|
+
"jsx": "react-jsx",
|
|
512
|
+
"strict": true,
|
|
513
|
+
"types": ["vite/client"]
|
|
514
|
+
},
|
|
515
|
+
"include": ["src", "node_modules/@arc-js/intl/**/*"]
|
|
516
|
+
}
|
|
517
|
+
```
|
|
518
|
+
|
|
503
519
|
## 📋 Table des Conventions
|
|
504
520
|
|
|
505
521
|
### Structure des fichiers JSON
|
|
@@ -517,7 +533,6 @@ const validateTranslations = (locale: string) => {
|
|
|
517
533
|
| `namespace.key` | Clé simple | `common.save` |
|
|
518
534
|
| `namespace.nested.key` | Clé imbriquée | `form.contact.email` |
|
|
519
535
|
| `key_{context}` | Avec contexte | `save_draft`, `save_final` |
|
|
520
|
-
| `key_{pluralForm}` | Forme plurielle | `item_one`, `item_other` |
|
|
521
536
|
|
|
522
537
|
### Paramètres supportés
|
|
523
538
|
|
|
@@ -545,15 +560,21 @@ const validateTranslations = (locale: string) => {
|
|
|
545
560
|
}
|
|
546
561
|
```
|
|
547
562
|
|
|
548
|
-
###
|
|
563
|
+
### Configuration Vite
|
|
549
564
|
|
|
550
|
-
```
|
|
551
|
-
//
|
|
552
|
-
import {
|
|
565
|
+
```typescript
|
|
566
|
+
// vite.config.ts
|
|
567
|
+
import { defineConfig } from 'vite';
|
|
568
|
+
import react from '@vitejs/plugin-react';
|
|
553
569
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
570
|
+
export default defineConfig({
|
|
571
|
+
plugins: [react()],
|
|
572
|
+
resolve: {
|
|
573
|
+
alias: {
|
|
574
|
+
'@arc-js/intl': '@arc-js/intl/index.js'
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
});
|
|
557
578
|
```
|
|
558
579
|
|
|
559
580
|
## 📄 Licence
|
package/config.d.ts
CHANGED
|
@@ -2,12 +2,20 @@ declare const DEFAULT_LOCALE = "en";
|
|
|
2
2
|
declare const SUPPORTED_LOCALES: string[];
|
|
3
3
|
declare const COOKIE_NAME = "app_locale";
|
|
4
4
|
type Locale = typeof SUPPORTED_LOCALES[number];
|
|
5
|
+
interface TranslationMap {
|
|
6
|
+
[locale: string]: () => Promise<Record<string, any>>;
|
|
7
|
+
}
|
|
8
|
+
interface ModuleTranslations {
|
|
9
|
+
[moduleName: string]: TranslationMap;
|
|
10
|
+
}
|
|
11
|
+
interface TranslationsConfig {
|
|
12
|
+
base: {
|
|
13
|
+
[locale: string]: () => Promise<Record<string, any>>;
|
|
14
|
+
};
|
|
15
|
+
modules?: ModuleTranslations;
|
|
16
|
+
}
|
|
5
17
|
declare const getSavedLocale: (supportedLocales?: string[]) => string;
|
|
6
18
|
declare const saveLocale: (locale: string) => void;
|
|
7
|
-
declare const PATH_CONFIG: {
|
|
8
|
-
SRC_DIR: string;
|
|
9
|
-
};
|
|
10
|
-
declare const SRC_DIR: string;
|
|
11
19
|
|
|
12
|
-
export { COOKIE_NAME, DEFAULT_LOCALE,
|
|
13
|
-
export type { Locale };
|
|
20
|
+
export { COOKIE_NAME, DEFAULT_LOCALE, SUPPORTED_LOCALES, getSavedLocale, saveLocale };
|
|
21
|
+
export type { Locale, ModuleTranslations, TranslationMap, TranslationsConfig };
|
package/config.js
CHANGED
|
@@ -891,7 +891,6 @@ function requireCooks () {
|
|
|
891
891
|
|
|
892
892
|
var cooksExports = requireCooks();
|
|
893
893
|
|
|
894
|
-
var _a;
|
|
895
894
|
const DEFAULT_LOCALE = 'en';
|
|
896
895
|
const SUPPORTED_LOCALES = ['en', 'fr'];
|
|
897
896
|
const COOKIE_NAME = 'app_locale';
|
|
@@ -905,9 +904,5 @@ const getSavedLocale = (supportedLocales = SUPPORTED_LOCALES) => {
|
|
|
905
904
|
const saveLocale = (locale) => {
|
|
906
905
|
cooksExports.Cooks.set(COOKIE_NAME, locale, { expires: 365 * 24 * 3600, sameSite: 'strict' });
|
|
907
906
|
};
|
|
908
|
-
const PATH_CONFIG = {
|
|
909
|
-
SRC_DIR: '/src',
|
|
910
|
-
};
|
|
911
|
-
const SRC_DIR = ((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.VITE_APP_SRC_DIR) || '/src';
|
|
912
907
|
|
|
913
|
-
export { COOKIE_NAME, DEFAULT_LOCALE,
|
|
908
|
+
export { COOKIE_NAME, DEFAULT_LOCALE, SUPPORTED_LOCALES, getSavedLocale, saveLocale };
|
package/config.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var hasRequiredTimez,hasRequiredCooks,cooks={},timez={};function requireTimez(){if(!hasRequiredTimez){hasRequiredTimez=1,Object.defineProperty(timez,"__esModule",{value:!0});class f{constructor(e,t=!1){!1===this.dateChecker(e)?this._date=void 0:e instanceof f&&e&&null!=e&&e._date?this._date=new Date(null==e?void 0: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&&null!=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(){var e;return null==(e=this._date)?void 0:e.getFullYear()}month(){return this._date?this._date.getMonth()+1:void 0}date(){var e;return null==(e=this._date)?void 0:e.getDate()}hour(){var e;return null==(e=this._date)?void 0:e.getHours()}minute(){var e;return null==(e=this._date)?void 0:e.getMinutes()}second(){var e;return null==(e=this._date)?void 0:e.getSeconds()}millisecond(){var e;return null==(e=this._date)?void 0:e.getMilliseconds()}day(){var e;return null==(e=this._date)?void 0:e.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&&null!=a&&a._date&&e&&null!=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),i="["===a[0],a="]"===a[1],i=i&&this.isSame(e)||this.isAfter(e),e=a&&this.isSame(t)||this.isBefore(t);return i&&e}format(e){if(!e)return this.toISOString();var t,a,i=f.PREDEFINED_FORMATS[e];if(i)return this.format(i);let r="",s=0;for(;s<e.length;)"["===e[s]?-1===(a=e.indexOf("]",s))?(r+=e[s],s++):(t=e.substring(s+1,a),r+=t,s=a+1):"%"===e[s]&&s+1<e.length?(t="%"+e[s+1],a=f.FORMAT_TOKENS[t],r+=a?a(this):t,s+=2):(r+=e[s],s++);return r}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(){var e;return null==(e=this._date)?void 0:e.toString()}toISOString(){var e;return null==(e=this._date)?void 0:e.toISOString()}toDate(){return this._date?new Date(this._date):void 0}valueOf(){var e;return null==(e=this._date)?void 0:e.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{var e=new Intl.DateTimeFormat("en",{timeZoneName:"short"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type);return(null==e?void 0:e.value)||void 0}catch(e){return this.timezoneAbbrFromOffset()}}timezoneName(){if(this._date)try{var e=new Intl.DateTimeFormat("en",{timeZoneName:"long"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type);return(null==e?void 0:e.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&&!(null==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 i,r=[/^(\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(i of r){var s=e.match(i);if(s){s=s.slice(1).map(Number);if(i===r[0])return new Date(Date.UTC(s[0],s[1]-1,s[2],s[3],s[4],s[5],s[6]));if(i===r[1])return new Date(s[0],s[1]-1,s[2]);if(i===r[2])return new Date(s[0],s[1]-1,s[2],s[3],s[4],s[5]);if(i===r[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,r){if(e&&r){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,i="";for(;t<r.length&&e<s.length;){var d=r[t];if("["===d)a=!0,i="",t++;else if("]"===d&&a){if(s.substring(e,e+i.length)!==i)return;e+=i.length,a=!1,i="",t++}else if(a)i+=d,t++;else if("%"===d&&t+1<r.length){var u=r[t+1],c=n[u];if(c){var l=s.substring(e).match(c.regex);if(!l||0!==l.index)return;var l=l[0],h=c.extract(l);switch(u){case"Y":case"y":o.year=h;break;case"m":o.month=h;break;case"d":o.day=h;break;case"H":o.hour=h;break;case"M":o.minute=h;break;case"S":o.second=h;break;case"f":o.millisecond=h}e+=l.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 Object.assign({},f.PREDEFINED_FORMATS)}static exposeToGlobal(){"undefined"!=typeof window&&(window.Timez=f)}}f.FORMAT_TOKENS={"%Y":e=>null==(e=e.year())?void 0:e.toString().padStart(4,"0"),"%y":e=>null==(e=e.year())?void 0:e.toString().slice(-2).padStart(2,"0"),"%m":e=>null==(e=e.month())?void 0:e.toString().padStart(2,"0"),"%d":e=>null==(e=e.date())?void 0:e.toString().padStart(2,"0"),"%H":e=>null==(e=e.hour())?void 0:e.toString().padStart(2,"0"),"%M":e=>null==(e=e.minute())?void 0:e.toString().padStart(2,"0"),"%S":e=>null==(e=e.second())?void 0:e.toString().padStart(2,"0"),"%f":e=>null==(e=e.millisecond())?void 0:e.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}},f.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]"},"undefined"!=typeof window&&(window.Timez=f),timez.Timez=f,timez.default=f}return timez}function requireCooks(){if(!hasRequiredCooks){hasRequiredCooks=1,Object.defineProperty(cooks,"__esModule",{value:!0});var r=requireTimez(),e=["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"];[...e,...e.map(e=>e.toUpperCase())];class t{static set(e,t,a={}){if(this.isBrowser())try{var i=this.serialize(t),r=encodeURIComponent(i),s=this.buildCookieString(e,r,a);document.cookie=s}catch(e){}}static get(e){if(!this.isBrowser())return null;try{var t,a=this.getAllCookies()[e];return a?(t=decodeURIComponent(a),this.deserialize(t)):null}catch(e){return 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=Object.assign(Object.assign({},this.DEFAULT_OPTIONS),a);let i=e+"="+t;if(void 0!==a.expires){let e;e="number"==typeof a.expires?(new r.Timez).add(a.expires,"seconds").toDate()||new Date:a.expires,i+="; expires="+e.toUTCString()}return a.path&&(i+="; path="+a.path),a.domain&&(i+="; domain="+a.domain),a.secure&&(i+="; secure"),a.sameSite&&(i+="; samesite="+a.sameSite),i}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=t)}}t.DEFAULT_OPTIONS={path:"/",secure:!0,sameSite:"lax"},"undefined"!=typeof window&&(window.Cooks=t),cooks.Cooks=t,cooks.default=t}return cooks}var _a,cooksExports=requireCooks();let DEFAULT_LOCALE="en",SUPPORTED_LOCALES=["en","fr"],COOKIE_NAME="app_locale",getSavedLocale=(e=SUPPORTED_LOCALES)=>{var t=cooksExports.Cooks.get(COOKIE_NAME);return("object"==typeof e&&Array.isArray(e)&&0<e.length?e:SUPPORTED_LOCALES).includes(t)?t:DEFAULT_LOCALE},saveLocale=e=>{cooksExports.Cooks.set(COOKIE_NAME,e,{expires:31536e3,sameSite:"strict"})},PATH_CONFIG={SRC_DIR:"/src"},SRC_DIR=(null==(_a=null==process?void 0:process.env)?void 0:_a.VITE_APP_SRC_DIR)||"/src";export{COOKIE_NAME,DEFAULT_LOCALE,PATH_CONFIG,SRC_DIR,SUPPORTED_LOCALES,getSavedLocale,saveLocale};
|
|
1
|
+
var hasRequiredTimez,hasRequiredCooks,cooks={},timez={};function requireTimez(){if(!hasRequiredTimez){hasRequiredTimez=1,Object.defineProperty(timez,"__esModule",{value:!0});class f{constructor(e,t=!1){!1===this.dateChecker(e)?this._date=void 0:e instanceof f&&e&&null!=e&&e._date?this._date=new Date(null==e?void 0: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&&null!=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(){var e;return null==(e=this._date)?void 0:e.getFullYear()}month(){return this._date?this._date.getMonth()+1:void 0}date(){var e;return null==(e=this._date)?void 0:e.getDate()}hour(){var e;return null==(e=this._date)?void 0:e.getHours()}minute(){var e;return null==(e=this._date)?void 0:e.getMinutes()}second(){var e;return null==(e=this._date)?void 0:e.getSeconds()}millisecond(){var e;return null==(e=this._date)?void 0:e.getMilliseconds()}day(){var e;return null==(e=this._date)?void 0:e.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&&null!=a&&a._date&&e&&null!=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),i="["===a[0],a="]"===a[1],i=i&&this.isSame(e)||this.isAfter(e),e=a&&this.isSame(t)||this.isBefore(t);return i&&e}format(e){if(!e)return this.toISOString();var t,a,i=f.PREDEFINED_FORMATS[e];if(i)return this.format(i);let r="",s=0;for(;s<e.length;)"["===e[s]?-1===(a=e.indexOf("]",s))?(r+=e[s],s++):(t=e.substring(s+1,a),r+=t,s=a+1):"%"===e[s]&&s+1<e.length?(t="%"+e[s+1],a=f.FORMAT_TOKENS[t],r+=a?a(this):t,s+=2):(r+=e[s],s++);return r}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(){var e;return null==(e=this._date)?void 0:e.toString()}toISOString(){var e;return null==(e=this._date)?void 0:e.toISOString()}toDate(){return this._date?new Date(this._date):void 0}valueOf(){var e;return null==(e=this._date)?void 0:e.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{var e=new Intl.DateTimeFormat("en",{timeZoneName:"short"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type);return(null==e?void 0:e.value)||void 0}catch(e){return this.timezoneAbbrFromOffset()}}timezoneName(){if(this._date)try{var e=new Intl.DateTimeFormat("en",{timeZoneName:"long"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type);return(null==e?void 0:e.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&&!(null==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 i,r=[/^(\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(i of r){var s=e.match(i);if(s){s=s.slice(1).map(Number);if(i===r[0])return new Date(Date.UTC(s[0],s[1]-1,s[2],s[3],s[4],s[5],s[6]));if(i===r[1])return new Date(s[0],s[1]-1,s[2]);if(i===r[2])return new Date(s[0],s[1]-1,s[2],s[3],s[4],s[5]);if(i===r[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,r){if(e&&r){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,i="";for(;t<r.length&&e<s.length;){var d=r[t];if("["===d)a=!0,i="",t++;else if("]"===d&&a){if(s.substring(e,e+i.length)!==i)return;e+=i.length,a=!1,i="",t++}else if(a)i+=d,t++;else if("%"===d&&t+1<r.length){var u=r[t+1],c=n[u];if(c){var l=s.substring(e).match(c.regex);if(!l||0!==l.index)return;var l=l[0],h=c.extract(l);switch(u){case"Y":case"y":o.year=h;break;case"m":o.month=h;break;case"d":o.day=h;break;case"H":o.hour=h;break;case"M":o.minute=h;break;case"S":o.second=h;break;case"f":o.millisecond=h}e+=l.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 Object.assign({},f.PREDEFINED_FORMATS)}static exposeToGlobal(){"undefined"!=typeof window&&(window.Timez=f)}}f.FORMAT_TOKENS={"%Y":e=>null==(e=e.year())?void 0:e.toString().padStart(4,"0"),"%y":e=>null==(e=e.year())?void 0:e.toString().slice(-2).padStart(2,"0"),"%m":e=>null==(e=e.month())?void 0:e.toString().padStart(2,"0"),"%d":e=>null==(e=e.date())?void 0:e.toString().padStart(2,"0"),"%H":e=>null==(e=e.hour())?void 0:e.toString().padStart(2,"0"),"%M":e=>null==(e=e.minute())?void 0:e.toString().padStart(2,"0"),"%S":e=>null==(e=e.second())?void 0:e.toString().padStart(2,"0"),"%f":e=>null==(e=e.millisecond())?void 0:e.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}},f.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]"},"undefined"!=typeof window&&(window.Timez=f),timez.Timez=f,timez.default=f}return timez}function requireCooks(){if(!hasRequiredCooks){hasRequiredCooks=1,Object.defineProperty(cooks,"__esModule",{value:!0});var r=requireTimez(),e=["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"];[...e,...e.map(e=>e.toUpperCase())];class t{static set(e,t,a={}){if(this.isBrowser())try{var i=this.serialize(t),r=encodeURIComponent(i),s=this.buildCookieString(e,r,a);document.cookie=s}catch(e){}}static get(e){if(!this.isBrowser())return null;try{var t,a=this.getAllCookies()[e];return a?(t=decodeURIComponent(a),this.deserialize(t)):null}catch(e){return 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=Object.assign(Object.assign({},this.DEFAULT_OPTIONS),a);let i=e+"="+t;if(void 0!==a.expires){let e;e="number"==typeof a.expires?(new r.Timez).add(a.expires,"seconds").toDate()||new Date:a.expires,i+="; expires="+e.toUTCString()}return a.path&&(i+="; path="+a.path),a.domain&&(i+="; domain="+a.domain),a.secure&&(i+="; secure"),a.sameSite&&(i+="; samesite="+a.sameSite),i}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=t)}}t.DEFAULT_OPTIONS={path:"/",secure:!0,sameSite:"lax"},"undefined"!=typeof window&&(window.Cooks=t),cooks.Cooks=t,cooks.default=t}return cooks}var cooksExports=requireCooks();let DEFAULT_LOCALE="en",SUPPORTED_LOCALES=["en","fr"],COOKIE_NAME="app_locale",getSavedLocale=(e=SUPPORTED_LOCALES)=>{var t=cooksExports.Cooks.get(COOKIE_NAME);return("object"==typeof e&&Array.isArray(e)&&0<e.length?e:SUPPORTED_LOCALES).includes(t)?t:DEFAULT_LOCALE},saveLocale=e=>{cooksExports.Cooks.set(COOKIE_NAME,e,{expires:31536e3,sameSite:"strict"})};export{COOKIE_NAME,DEFAULT_LOCALE,SUPPORTED_LOCALES,getSavedLocale,saveLocale};
|
|
2
2
|
//# sourceMappingURL=config.min.js.map
|