kaafil-react-uikit 0.4.1 → 0.5.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/CHANGELOG.md +44 -5
- package/dist/admin/index.cjs +355 -353
- package/dist/admin/index.cjs.map +1 -1
- package/dist/admin/index.js +16 -14
- package/dist/admin/index.js.map +1 -1
- package/dist/{chunk-EP4VCID7.js → chunk-3E2FN5JJ.js} +3 -3
- package/dist/{chunk-EP4VCID7.js.map → chunk-3E2FN5JJ.js.map} +1 -1
- package/dist/{chunk-TPBKRXEB.cjs → chunk-3RZDHDEY.cjs} +17 -17
- package/dist/{chunk-TPBKRXEB.cjs.map → chunk-3RZDHDEY.cjs.map} +1 -1
- package/dist/chunk-62HCQWZL.cjs +12 -0
- package/dist/chunk-62HCQWZL.cjs.map +1 -0
- package/dist/{chunk-ABWNV4N4.js → chunk-6FUVFVYY.js} +97 -4
- package/dist/chunk-6FUVFVYY.js.map +1 -0
- package/dist/{chunk-BUE2GJDN.js → chunk-762SWUEG.js} +3 -3
- package/dist/{chunk-BUE2GJDN.js.map → chunk-762SWUEG.js.map} +1 -1
- package/dist/{chunk-CCJ5XNWY.cjs → chunk-CK3L6Y43.cjs} +98 -2
- package/dist/chunk-CK3L6Y43.cjs.map +1 -0
- package/dist/{chunk-XBYLSJOS.cjs → chunk-DI77H7ED.cjs} +83 -83
- package/dist/{chunk-XBYLSJOS.cjs.map → chunk-DI77H7ED.cjs.map} +1 -1
- package/dist/{chunk-5DVTAEQC.js → chunk-EDLIJSMR.js} +5 -5
- package/dist/{chunk-5DVTAEQC.js.map → chunk-EDLIJSMR.js.map} +1 -1
- package/dist/{chunk-VAJ4D7EF.js → chunk-FEJL6GKJ.js} +513 -20
- package/dist/chunk-FEJL6GKJ.js.map +1 -0
- package/dist/{chunk-2D4Y4LOT.cjs → chunk-IBVCH6GC.cjs} +553 -51
- package/dist/chunk-IBVCH6GC.cjs.map +1 -0
- package/dist/{chunk-DABF4PUI.js → chunk-ITGVRN2S.js} +3 -3
- package/dist/{chunk-DABF4PUI.js.map → chunk-ITGVRN2S.js.map} +1 -1
- package/dist/{chunk-DUZG6A22.cjs → chunk-LO3GQFQ6.cjs} +4 -4
- package/dist/{chunk-DUZG6A22.cjs.map → chunk-LO3GQFQ6.cjs.map} +1 -1
- package/dist/{chunk-4LZXDRAD.cjs → chunk-QD4Z5DRT.cjs} +12 -12
- package/dist/{chunk-4LZXDRAD.cjs.map → chunk-QD4Z5DRT.cjs.map} +1 -1
- package/dist/{chunk-TV5QTT44.js → chunk-RW6TJMRK.js} +3 -3
- package/dist/{chunk-TV5QTT44.js.map → chunk-RW6TJMRK.js.map} +1 -1
- package/dist/chunk-XU7GP53M.js +10 -0
- package/dist/chunk-XU7GP53M.js.map +1 -0
- package/dist/{chunk-DDSNXKFN.cjs → chunk-XYIOM75D.cjs} +9 -9
- package/dist/{chunk-DDSNXKFN.cjs.map → chunk-XYIOM75D.cjs.map} +1 -1
- package/dist/core/index.cjs +153 -613
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +36 -1
- package/dist/core/index.d.ts +36 -1
- package/dist/core/index.js +21 -511
- package/dist/core/index.js.map +1 -1
- package/dist/index.css +1 -1
- package/dist/manager/index.cjs +239 -239
- package/dist/manager/index.js +6 -6
- package/dist/traveller/index.cjs +35 -35
- package/dist/traveller/index.js +5 -5
- package/package.json +2 -2
- package/dist/chunk-2D4Y4LOT.cjs.map +0 -1
- package/dist/chunk-2JABR4FF.js +0 -105
- package/dist/chunk-2JABR4FF.js.map +0 -1
- package/dist/chunk-ABWNV4N4.js.map +0 -1
- package/dist/chunk-CCJ5XNWY.cjs.map +0 -1
- package/dist/chunk-KDGBJPPZ.cjs +0 -110
- package/dist/chunk-KDGBJPPZ.cjs.map +0 -1
- package/dist/chunk-VAJ4D7EF.js.map +0 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkDI77H7ED_cjs = require('./chunk-DI77H7ED.cjs');
|
|
4
|
+
var chunkLO3GQFQ6_cjs = require('./chunk-LO3GQFQ6.cjs');
|
|
5
|
+
var chunkCK3L6Y43_cjs = require('./chunk-CK3L6Y43.cjs');
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var client = require('kaafil-js/client');
|
|
8
|
+
var reactDom = require('react-dom');
|
|
9
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
10
|
|
|
9
11
|
function useAgencyAdminMe() {
|
|
10
|
-
const client =
|
|
12
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
11
13
|
const [result, setResult] = react.useState({ status: "loading" });
|
|
12
14
|
react.useEffect(() => {
|
|
13
15
|
let cancelled = false;
|
|
@@ -29,7 +31,7 @@ function useAgencyAdminMe() {
|
|
|
29
31
|
return result;
|
|
30
32
|
}
|
|
31
33
|
function useAgencyChecklistTemplates() {
|
|
32
|
-
const client =
|
|
34
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
33
35
|
const [templates, setTemplates] = react.useState([]);
|
|
34
36
|
const [loaded, setLoaded] = react.useState(false);
|
|
35
37
|
const [lastFetchFailed, setLastFetchFailed] = react.useState(false);
|
|
@@ -89,7 +91,7 @@ function useAgencyChecklistTemplates() {
|
|
|
89
91
|
};
|
|
90
92
|
}
|
|
91
93
|
function useAgencyForms() {
|
|
92
|
-
const client =
|
|
94
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
93
95
|
const [forms, setForms] = react.useState([]);
|
|
94
96
|
const [loaded, setLoaded] = react.useState(false);
|
|
95
97
|
const [lastFetchFailed, setLastFetchFailed] = react.useState(false);
|
|
@@ -245,7 +247,7 @@ function useAgencyForms() {
|
|
|
245
247
|
};
|
|
246
248
|
}
|
|
247
249
|
function useAgencyJourneyTriggers() {
|
|
248
|
-
const client =
|
|
250
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
249
251
|
const [triggers, setTriggers] = react.useState([]);
|
|
250
252
|
const [loaded, setLoaded] = react.useState(false);
|
|
251
253
|
const [lastFetchFailed, setLastFetchFailed] = react.useState(false);
|
|
@@ -273,7 +275,7 @@ function useAgencyJourneyTriggers() {
|
|
|
273
275
|
return { triggers, loaded, lastFetchFailed, refresh, patchTrigger };
|
|
274
276
|
}
|
|
275
277
|
function useAgencyManagerProfile(managerRef) {
|
|
276
|
-
const client =
|
|
278
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
277
279
|
const [read, setRead] = react.useState(void 0);
|
|
278
280
|
const [readFailed, setReadFailed] = react.useState(false);
|
|
279
281
|
const refresh = react.useCallback(async () => {
|
|
@@ -291,8 +293,8 @@ function useAgencyManagerProfile(managerRef) {
|
|
|
291
293
|
return { read, readFailed, refresh };
|
|
292
294
|
}
|
|
293
295
|
function useAgencySettings() {
|
|
294
|
-
const client =
|
|
295
|
-
const [
|
|
296
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
297
|
+
const [document2, setDocument] = react.useState(void 0);
|
|
296
298
|
const [loaded, setLoaded] = react.useState(false);
|
|
297
299
|
const [lastFetchFailed, setLastFetchFailed] = react.useState(false);
|
|
298
300
|
const refresh = react.useCallback(async () => {
|
|
@@ -316,10 +318,10 @@ function useAgencySettings() {
|
|
|
316
318
|
},
|
|
317
319
|
[client, refresh]
|
|
318
320
|
);
|
|
319
|
-
return { document, loaded, lastFetchFailed, refresh, patchSettings };
|
|
321
|
+
return { document: document2, loaded, lastFetchFailed, refresh, patchSettings };
|
|
320
322
|
}
|
|
321
323
|
function useAgencyTrip(tripRef) {
|
|
322
|
-
const client =
|
|
324
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
323
325
|
const [read, setRead] = react.useState(void 0);
|
|
324
326
|
const [readFailed, setReadFailed] = react.useState(false);
|
|
325
327
|
const refresh = react.useCallback(async () => {
|
|
@@ -339,7 +341,7 @@ function useAgencyTrip(tripRef) {
|
|
|
339
341
|
var DEFAULT_PAGE_LIMIT = 20;
|
|
340
342
|
var GROUPED_PAGE_LIMIT = 100;
|
|
341
343
|
function useAgencyTripManifest(tripRef) {
|
|
342
|
-
const client =
|
|
344
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
343
345
|
const [facets, setFacets] = react.useState(void 0);
|
|
344
346
|
const mountedRef = react.useRef(true);
|
|
345
347
|
react.useEffect(() => {
|
|
@@ -370,7 +372,7 @@ function useAgencyTripManifest(tripRef) {
|
|
|
370
372
|
}
|
|
371
373
|
var DEFAULT_PAGE_LIMIT2 = 20;
|
|
372
374
|
function useAgencyTrips() {
|
|
373
|
-
const client =
|
|
375
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
374
376
|
const [segmentCounts, setSegmentCounts] = react.useState(
|
|
375
377
|
void 0
|
|
376
378
|
);
|
|
@@ -400,18 +402,18 @@ function useAgencyTrips() {
|
|
|
400
402
|
);
|
|
401
403
|
return { makeTripsFetch, segmentCounts };
|
|
402
404
|
}
|
|
403
|
-
var useBookingsInternal =
|
|
405
|
+
var useBookingsInternal = chunkDI77H7ED_cjs.createDomainHook("bookings", (tripRef) => {
|
|
404
406
|
const {
|
|
405
407
|
rows: bookings,
|
|
406
408
|
syncedAt,
|
|
407
409
|
refreshLive
|
|
408
|
-
} =
|
|
410
|
+
} = chunkDI77H7ED_cjs.useSnapshotList(tripRef, "bookings", {
|
|
409
411
|
live: async (liveClient, ref) => {
|
|
410
412
|
const response = await liveClient.bookings.list({ tripRef: ref });
|
|
411
413
|
return { rows: [...response], syncedAt: response.meta.serverTime };
|
|
412
414
|
}
|
|
413
415
|
});
|
|
414
|
-
const vouchersMutation =
|
|
416
|
+
const vouchersMutation = chunkCK3L6Y43_cjs.useOfflineMutation({
|
|
415
417
|
tripRef,
|
|
416
418
|
enqueue: (engine, input) => engine.enqueue({
|
|
417
419
|
tripRef,
|
|
@@ -448,10 +450,10 @@ function useBookings(tripRef) {
|
|
|
448
450
|
return useBookingsInternal(tripRef);
|
|
449
451
|
}
|
|
450
452
|
function useCapabilityStatuses(tripRef) {
|
|
451
|
-
const { rows, loaded } =
|
|
453
|
+
const { rows, loaded } = chunkCK3L6Y43_cjs.useCapabilityRows(tripRef);
|
|
452
454
|
const statuses = react.useMemo(() => {
|
|
453
455
|
const map = /* @__PURE__ */ new Map();
|
|
454
|
-
for (const row of rows) map.set(row.capability,
|
|
456
|
+
for (const row of rows) map.set(row.capability, chunkCK3L6Y43_cjs.deriveCapabilityTriple(row).status);
|
|
455
457
|
return map;
|
|
456
458
|
}, [rows]);
|
|
457
459
|
return { statuses, loaded };
|
|
@@ -469,8 +471,8 @@ var DirectoriesWriteError = class _DirectoriesWriteError extends Error {
|
|
|
469
471
|
}
|
|
470
472
|
};
|
|
471
473
|
function useDirectories(agencyRef) {
|
|
472
|
-
const client =
|
|
473
|
-
|
|
474
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
475
|
+
chunkLO3GQFQ6_cjs.useServerTime();
|
|
474
476
|
const makeManagersFetch = react.useCallback(
|
|
475
477
|
(filters) => async (cursor) => {
|
|
476
478
|
const page = await client.agencies.managers.listPage({
|
|
@@ -517,7 +519,7 @@ function useDirectories(agencyRef) {
|
|
|
517
519
|
isLead: input.isLead
|
|
518
520
|
});
|
|
519
521
|
} catch (error) {
|
|
520
|
-
throw new DirectoriesWriteError(
|
|
522
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
521
523
|
}
|
|
522
524
|
},
|
|
523
525
|
[client]
|
|
@@ -532,7 +534,7 @@ function useDirectories(agencyRef) {
|
|
|
532
534
|
...input.isLead === void 0 ? {} : { isLead: input.isLead }
|
|
533
535
|
});
|
|
534
536
|
} catch (error) {
|
|
535
|
-
throw new DirectoriesWriteError(
|
|
537
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
536
538
|
}
|
|
537
539
|
},
|
|
538
540
|
[client]
|
|
@@ -545,7 +547,7 @@ function useDirectories(agencyRef) {
|
|
|
545
547
|
managerRef: input.managerRef
|
|
546
548
|
});
|
|
547
549
|
} catch (error) {
|
|
548
|
-
throw new DirectoriesWriteError(
|
|
550
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
549
551
|
}
|
|
550
552
|
},
|
|
551
553
|
[client]
|
|
@@ -559,8 +561,7 @@ function useDirectories(agencyRef) {
|
|
|
559
561
|
{
|
|
560
562
|
externalTravellerId: input.externalTravellerId,
|
|
561
563
|
fullName: input.fullName,
|
|
562
|
-
phone: input.phone
|
|
563
|
-
sourceUpdatedAt: serverTime.now()
|
|
564
|
+
phone: input.phone
|
|
564
565
|
}
|
|
565
566
|
]
|
|
566
567
|
});
|
|
@@ -581,10 +582,10 @@ function useDirectories(agencyRef) {
|
|
|
581
582
|
if (error instanceof DirectoriesWriteError) {
|
|
582
583
|
throw error;
|
|
583
584
|
}
|
|
584
|
-
throw new DirectoriesWriteError(
|
|
585
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
585
586
|
}
|
|
586
587
|
},
|
|
587
|
-
[client
|
|
588
|
+
[client]
|
|
588
589
|
);
|
|
589
590
|
const createAgencyTraveller = react.useCallback(
|
|
590
591
|
async (input) => {
|
|
@@ -597,7 +598,7 @@ function useDirectories(agencyRef) {
|
|
|
597
598
|
externalTravellerId: input.externalTravellerId
|
|
598
599
|
});
|
|
599
600
|
} catch (error) {
|
|
600
|
-
throw new DirectoriesWriteError(
|
|
601
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
601
602
|
}
|
|
602
603
|
},
|
|
603
604
|
[client]
|
|
@@ -610,7 +611,7 @@ function useDirectories(agencyRef) {
|
|
|
610
611
|
travellerRef: input.travellerRef
|
|
611
612
|
});
|
|
612
613
|
} catch (error) {
|
|
613
|
-
throw new DirectoriesWriteError(
|
|
614
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
614
615
|
}
|
|
615
616
|
},
|
|
616
617
|
[client]
|
|
@@ -625,7 +626,7 @@ function useDirectories(agencyRef) {
|
|
|
625
626
|
travellerRefs: [...input.travellerRefs]
|
|
626
627
|
});
|
|
627
628
|
} catch (error) {
|
|
628
|
-
throw new DirectoriesWriteError(
|
|
629
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
629
630
|
}
|
|
630
631
|
},
|
|
631
632
|
[client]
|
|
@@ -642,7 +643,7 @@ function useDirectories(agencyRef) {
|
|
|
642
643
|
...input.travellerRefs !== void 0 ? { travellerRefs: [...input.travellerRefs] } : {}
|
|
643
644
|
});
|
|
644
645
|
} catch (error) {
|
|
645
|
-
throw new DirectoriesWriteError(
|
|
646
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
646
647
|
}
|
|
647
648
|
},
|
|
648
649
|
[client]
|
|
@@ -652,7 +653,7 @@ function useDirectories(agencyRef) {
|
|
|
652
653
|
try {
|
|
653
654
|
await client.trips.parties.remove({ tripRef: input.tripRef, partyId: input.partyId });
|
|
654
655
|
} catch (error) {
|
|
655
|
-
throw new DirectoriesWriteError(
|
|
656
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
656
657
|
}
|
|
657
658
|
},
|
|
658
659
|
[client]
|
|
@@ -666,7 +667,7 @@ function useDirectories(agencyRef) {
|
|
|
666
667
|
body: input.body
|
|
667
668
|
});
|
|
668
669
|
} catch (error) {
|
|
669
|
-
throw new DirectoriesWriteError(
|
|
670
|
+
throw new DirectoriesWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
670
671
|
}
|
|
671
672
|
},
|
|
672
673
|
[client]
|
|
@@ -713,7 +714,7 @@ function usePaginatedList(fetch, options) {
|
|
|
713
714
|
setPageIndex(index);
|
|
714
715
|
setError(void 0);
|
|
715
716
|
} catch (caught) {
|
|
716
|
-
setError(
|
|
717
|
+
setError(chunkDI77H7ED_cjs.classifyError(caught));
|
|
717
718
|
setHasNext(false);
|
|
718
719
|
} finally {
|
|
719
720
|
setSettled(true);
|
|
@@ -744,12 +745,6 @@ function usePaginatedList(fetch, options) {
|
|
|
744
745
|
loadPrev
|
|
745
746
|
};
|
|
746
747
|
}
|
|
747
|
-
|
|
748
|
-
// src/core/hooks/useResolvedSetting.ts
|
|
749
|
-
function useResolvedSetting(key) {
|
|
750
|
-
const config = chunkCCJ5XNWY_cjs.useRequiredContext(chunkCCJ5XNWY_cjs.ConfigContext, "useResolvedSetting", "ConfigShell");
|
|
751
|
-
return config.resolveSetting(key);
|
|
752
|
-
}
|
|
753
748
|
var SHARE_SECTION_KEYS = [
|
|
754
749
|
"itinerary",
|
|
755
750
|
"rooming",
|
|
@@ -778,7 +773,7 @@ var ShareLinkWriteError = class extends Error {
|
|
|
778
773
|
}
|
|
779
774
|
};
|
|
780
775
|
function useShareLinks(tripRef, travellerRef) {
|
|
781
|
-
const client =
|
|
776
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
782
777
|
const [links, setLinks] = react.useState(void 0);
|
|
783
778
|
const [readFailed, setReadFailed] = react.useState(false);
|
|
784
779
|
const refresh = react.useCallback(async () => {
|
|
@@ -809,7 +804,7 @@ function useShareLinks(tripRef, travellerRef) {
|
|
|
809
804
|
await refresh();
|
|
810
805
|
return minted;
|
|
811
806
|
} catch (error) {
|
|
812
|
-
throw new ShareLinkWriteError(
|
|
807
|
+
throw new ShareLinkWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
813
808
|
}
|
|
814
809
|
},
|
|
815
810
|
[client, tripRef, refresh]
|
|
@@ -820,7 +815,7 @@ function useShareLinks(tripRef, travellerRef) {
|
|
|
820
815
|
await client.shareTokens.revoke({ id });
|
|
821
816
|
await refresh();
|
|
822
817
|
} catch (error) {
|
|
823
|
-
throw new ShareLinkWriteError(
|
|
818
|
+
throw new ShareLinkWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
824
819
|
}
|
|
825
820
|
},
|
|
826
821
|
[client, refresh]
|
|
@@ -836,7 +831,7 @@ function useShareLinks(tripRef, travellerRef) {
|
|
|
836
831
|
});
|
|
837
832
|
await refresh();
|
|
838
833
|
} catch (error) {
|
|
839
|
-
throw new ShareLinkWriteError(
|
|
834
|
+
throw new ShareLinkWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
840
835
|
}
|
|
841
836
|
},
|
|
842
837
|
[client, refresh]
|
|
@@ -848,7 +843,7 @@ function useShareLinks(tripRef, travellerRef) {
|
|
|
848
843
|
await refresh();
|
|
849
844
|
return minted;
|
|
850
845
|
} catch (error) {
|
|
851
|
-
throw new ShareLinkWriteError(
|
|
846
|
+
throw new ShareLinkWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
852
847
|
}
|
|
853
848
|
},
|
|
854
849
|
[client, refresh]
|
|
@@ -859,7 +854,7 @@ function useShareLinks(tripRef, travellerRef) {
|
|
|
859
854
|
const response = await client.shareTokens.reveal({ id });
|
|
860
855
|
return response.token;
|
|
861
856
|
} catch (error) {
|
|
862
|
-
throw new ShareLinkWriteError(
|
|
857
|
+
throw new ShareLinkWriteError(chunkDI77H7ED_cjs.classifyError(error));
|
|
863
858
|
}
|
|
864
859
|
},
|
|
865
860
|
[client]
|
|
@@ -867,7 +862,7 @@ function useShareLinks(tripRef, travellerRef) {
|
|
|
867
862
|
return { links, readFailed, refresh, mint, revoke, patch, regenerate, reveal };
|
|
868
863
|
}
|
|
869
864
|
function useTravellerFormResponses(tripRef, travellerRef) {
|
|
870
|
-
const client =
|
|
865
|
+
const client = chunkCK3L6Y43_cjs.useKaafilClient();
|
|
871
866
|
const [responses, setResponses] = react.useState(
|
|
872
867
|
void 0
|
|
873
868
|
);
|
|
@@ -891,6 +886,504 @@ function useTravellerFormResponses(tripRef, travellerRef) {
|
|
|
891
886
|
}, [refresh]);
|
|
892
887
|
return { responses, readFailed, refresh };
|
|
893
888
|
}
|
|
889
|
+
var ThemeAttributesContext = react.createContext(null);
|
|
890
|
+
var FAMILY_DEFAULT_FRAME = {
|
|
891
|
+
admin: "desk",
|
|
892
|
+
manager: "field",
|
|
893
|
+
traveller: "document"
|
|
894
|
+
};
|
|
895
|
+
var DESK_MINIMUM_CONTAINER_WIDTH_PX = 640;
|
|
896
|
+
function ShadowIsolationBoundary({
|
|
897
|
+
className,
|
|
898
|
+
children
|
|
899
|
+
}) {
|
|
900
|
+
const hostRef = react.useRef(null);
|
|
901
|
+
const [shadowContainer, setShadowContainer] = react.useState(null);
|
|
902
|
+
react.useEffect(() => {
|
|
903
|
+
const host = hostRef.current;
|
|
904
|
+
if (host === null) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
const shadow = host.shadowRoot ?? host.attachShadow({ mode: "open" });
|
|
908
|
+
let container = shadow.querySelector("div[data-kf-shadow-content]");
|
|
909
|
+
if (container === null) {
|
|
910
|
+
container = document.createElement("div");
|
|
911
|
+
container.setAttribute("data-kf-shadow-content", "");
|
|
912
|
+
shadow.appendChild(container);
|
|
913
|
+
}
|
|
914
|
+
setShadowContainer(container);
|
|
915
|
+
}, []);
|
|
916
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: hostRef, className, "data-kf-isolation": "shadow", children: shadowContainer !== null ? reactDom.createPortal(children, shadowContainer) : null });
|
|
917
|
+
}
|
|
918
|
+
function useDeskMinimumWidthWarning(rootRef, frame) {
|
|
919
|
+
react.useEffect(() => {
|
|
920
|
+
if (frame !== "desk" || !chunkCK3L6Y43_cjs.isDevelopment() || typeof ResizeObserver === "undefined") {
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
const node = rootRef.current;
|
|
924
|
+
if (node === null) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
let warned = false;
|
|
928
|
+
const observer = new ResizeObserver((entries) => {
|
|
929
|
+
const entry = entries[0];
|
|
930
|
+
if (entry === void 0 || warned) {
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
if (entry.contentRect.width < DESK_MINIMUM_CONTAINER_WIDTH_PX) {
|
|
934
|
+
warned = true;
|
|
935
|
+
console.warn(
|
|
936
|
+
`kaafil-react-uikit: the 'desk' frame's .kf-root is narrower than the stated minimum container width (05-theming-and-branding.md \xA74.4). AppShell never auto-swaps frames \u2014 mount the manager family, or pass frame="field" explicitly, for this container.`
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
observer.observe(node);
|
|
941
|
+
return () => observer.disconnect();
|
|
942
|
+
}, [rootRef, frame]);
|
|
943
|
+
}
|
|
944
|
+
function useUnfilledConnectivitySlotWarning(frame, connectivitySlot) {
|
|
945
|
+
react.useEffect(() => {
|
|
946
|
+
if (frame === "field" && connectivitySlot === void 0 && chunkCK3L6Y43_cjs.isDevelopment()) {
|
|
947
|
+
console.warn(
|
|
948
|
+
`kaafil-react-uikit: AppShell's "field" frame has no connectivitySlot filled \u2014 the permanently-visible connectivity/sync region this frame reserves is empty (01-app-shell.md, briefing \xA727.2).`
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
}, [frame, connectivitySlot]);
|
|
952
|
+
}
|
|
953
|
+
function AppShell({
|
|
954
|
+
frame,
|
|
955
|
+
family,
|
|
956
|
+
isolation = "scoped",
|
|
957
|
+
navSlot,
|
|
958
|
+
actionBarSlot,
|
|
959
|
+
connectivitySlot,
|
|
960
|
+
children,
|
|
961
|
+
style
|
|
962
|
+
}) {
|
|
963
|
+
const themeAttributes = react.useContext(ThemeAttributesContext);
|
|
964
|
+
const rootRef = react.useRef(null);
|
|
965
|
+
const resolvedFrame = frame ?? (family !== void 0 ? FAMILY_DEFAULT_FRAME[family] : "document");
|
|
966
|
+
useDeskMinimumWidthWarning(rootRef, resolvedFrame);
|
|
967
|
+
useUnfilledConnectivitySlotWarning(resolvedFrame, connectivitySlot);
|
|
968
|
+
const dataAttributes = {
|
|
969
|
+
"data-kf-frame": resolvedFrame
|
|
970
|
+
};
|
|
971
|
+
if (family !== void 0) {
|
|
972
|
+
dataAttributes["data-kf-family"] = family;
|
|
973
|
+
}
|
|
974
|
+
if (themeAttributes !== null) {
|
|
975
|
+
dataAttributes["data-kf-theme"] = themeAttributes.theme;
|
|
976
|
+
if (themeAttributes.density !== void 0) {
|
|
977
|
+
dataAttributes["data-kf-density"] = themeAttributes.density;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
981
|
+
resolvedFrame === "desk" && navSlot !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "kf-app-shell__nav", children: navSlot }) : null,
|
|
982
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "kf-app-shell__content", children }),
|
|
983
|
+
resolvedFrame === "field" && actionBarSlot !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "kf-app-shell__action-bar", children: actionBarSlot }) : null,
|
|
984
|
+
resolvedFrame === "field" && connectivitySlot !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "kf-app-shell__connectivity", children: connectivitySlot }) : null,
|
|
985
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "kf-app-shell__live-region", role: "status", "aria-live": "polite" })
|
|
986
|
+
] });
|
|
987
|
+
if (isolation === "shadow") {
|
|
988
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
989
|
+
"div",
|
|
990
|
+
{
|
|
991
|
+
ref: rootRef,
|
|
992
|
+
className: "kf-root",
|
|
993
|
+
"data-kf-isolation": "shadow",
|
|
994
|
+
...dataAttributes,
|
|
995
|
+
style: chunkCK3L6Y43_cjs.tokenStyle(style),
|
|
996
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ShadowIsolationBoundary, { className: "kf-app-shell__shadow-host", children: content })
|
|
997
|
+
}
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1001
|
+
"div",
|
|
1002
|
+
{
|
|
1003
|
+
ref: rootRef,
|
|
1004
|
+
className: "kf-root",
|
|
1005
|
+
"data-kf-isolation": "scoped",
|
|
1006
|
+
...dataAttributes,
|
|
1007
|
+
style: chunkCK3L6Y43_cjs.tokenStyle(style),
|
|
1008
|
+
children: content
|
|
1009
|
+
}
|
|
1010
|
+
);
|
|
1011
|
+
}
|
|
1012
|
+
function ConfigShell({ seedConfig = {}, children }) {
|
|
1013
|
+
const value = react.useMemo(
|
|
1014
|
+
() => ({
|
|
1015
|
+
resolveSetting(key) {
|
|
1016
|
+
const agencyValue = seedConfig.agency?.[key];
|
|
1017
|
+
if (agencyValue !== void 0) {
|
|
1018
|
+
return agencyValue;
|
|
1019
|
+
}
|
|
1020
|
+
const tenantValue = seedConfig.tenant?.[key];
|
|
1021
|
+
return tenantValue === void 0 ? void 0 : tenantValue;
|
|
1022
|
+
}
|
|
1023
|
+
}),
|
|
1024
|
+
[seedConfig.agency, seedConfig.tenant]
|
|
1025
|
+
);
|
|
1026
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkCK3L6Y43_cjs.ConfigContext.Provider, { value, children });
|
|
1027
|
+
}
|
|
1028
|
+
function classifyForFallback(error) {
|
|
1029
|
+
const classification = chunkDI77H7ED_cjs.classifyError(error);
|
|
1030
|
+
if (classification.code === "RESOURCE_NOT_FOUND") {
|
|
1031
|
+
return { classification: "isolation", code: classification.code };
|
|
1032
|
+
}
|
|
1033
|
+
if (classification.path === "parked" || classification.unsatisfiableScheme) {
|
|
1034
|
+
return { classification: "parked", code: classification.code };
|
|
1035
|
+
}
|
|
1036
|
+
return { classification: "retryable", code: classification.code };
|
|
1037
|
+
}
|
|
1038
|
+
var FALLBACK_STYLE = {
|
|
1039
|
+
fontFamily: "system-ui, sans-serif",
|
|
1040
|
+
padding: "1.5rem",
|
|
1041
|
+
border: "1px solid #999",
|
|
1042
|
+
borderRadius: "4px",
|
|
1043
|
+
color: "#1a1a1a",
|
|
1044
|
+
background: "#fff"
|
|
1045
|
+
};
|
|
1046
|
+
function DefaultFallback({
|
|
1047
|
+
ctx,
|
|
1048
|
+
onRetry
|
|
1049
|
+
}) {
|
|
1050
|
+
const role = ctx.classification === "retryable" ? "status" : "alert";
|
|
1051
|
+
const ariaLive = ctx.classification === "retryable" ? "polite" : "assertive";
|
|
1052
|
+
const message = ctx.classification === "isolation" ? "Not found." : ctx.classification === "parked" ? "This action can't be completed right now." : "Something went wrong.";
|
|
1053
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: FALLBACK_STYLE, role, "aria-live": ariaLive, children: [
|
|
1054
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0 }, children: message }),
|
|
1055
|
+
ctx.classification === "retryable" ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onRetry, style: { marginTop: "0.75rem" }, children: "Try again" }) : null
|
|
1056
|
+
] });
|
|
1057
|
+
}
|
|
1058
|
+
var ErrorShell = class extends react.Component {
|
|
1059
|
+
state = { caught: null, retryKey: 0 };
|
|
1060
|
+
static getDerivedStateFromError(error) {
|
|
1061
|
+
return { caught: { error } };
|
|
1062
|
+
}
|
|
1063
|
+
handleRetry = () => {
|
|
1064
|
+
this.setState((current) => ({ caught: null, retryKey: current.retryKey + 1 }));
|
|
1065
|
+
};
|
|
1066
|
+
render() {
|
|
1067
|
+
if (this.state.caught !== null) {
|
|
1068
|
+
const ctx = classifyForFallback(this.state.caught.error);
|
|
1069
|
+
if (this.props.fallbackSlot !== void 0) {
|
|
1070
|
+
return this.props.fallbackSlot(ctx);
|
|
1071
|
+
}
|
|
1072
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DefaultFallback, { ctx, onRetry: this.handleRetry });
|
|
1073
|
+
}
|
|
1074
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: this.props.children }, this.state.retryKey);
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
var SessionExpiryBridgeContext = react.createContext(void 0);
|
|
1078
|
+
function OfflineShell({
|
|
1079
|
+
storage,
|
|
1080
|
+
blob,
|
|
1081
|
+
conflictResolver,
|
|
1082
|
+
readEntity,
|
|
1083
|
+
scope,
|
|
1084
|
+
children
|
|
1085
|
+
}) {
|
|
1086
|
+
const client = react.useContext(chunkCK3L6Y43_cjs.KaafilClientContext);
|
|
1087
|
+
const persona = chunkCK3L6Y43_cjs.usePersona();
|
|
1088
|
+
const session = chunkCK3L6Y43_cjs.useSession();
|
|
1089
|
+
const reportExpired = react.useContext(SessionExpiryBridgeContext);
|
|
1090
|
+
const [engine, setEngine] = react.useState(null);
|
|
1091
|
+
const engineRef = react.useRef(null);
|
|
1092
|
+
const derivedScope = scope ?? `${persona}:${session.agencyRef ?? "share"}`;
|
|
1093
|
+
react.useEffect(() => {
|
|
1094
|
+
if (session.status !== "authenticated" || client === null) {
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
const newEngine = client.openOffline({
|
|
1098
|
+
storage,
|
|
1099
|
+
scope: derivedScope,
|
|
1100
|
+
...readEntity !== void 0 ? { readEntity } : {},
|
|
1101
|
+
...conflictResolver !== void 0 ? { conflictResolver } : {},
|
|
1102
|
+
...blob !== void 0 ? { blob } : {}
|
|
1103
|
+
// GAP flagged in this phase's report: a share session's local
|
|
1104
|
+
// `expiresAt` enforcement (`OpenOfflineOptions.share`,
|
|
1105
|
+
// `07-offline-and-sync.md §8`) needs an `expiresAt` this shell has no
|
|
1106
|
+
// source for yet — it is not on `useSession()`'s derived shape and no
|
|
1107
|
+
// prop carries it. Omitted here rather than guessed; a share engine
|
|
1108
|
+
// opens without the local expiry/grace/purge enforcement until that
|
|
1109
|
+
// value has a wire source.
|
|
1110
|
+
});
|
|
1111
|
+
engineRef.current = newEngine;
|
|
1112
|
+
let opened = false;
|
|
1113
|
+
let disposed = false;
|
|
1114
|
+
void newEngine.open().then(() => {
|
|
1115
|
+
opened = true;
|
|
1116
|
+
if (disposed) {
|
|
1117
|
+
newEngine.close();
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
if (engineRef.current === newEngine) setEngine(newEngine);
|
|
1121
|
+
}).catch(() => {
|
|
1122
|
+
if (!disposed && engineRef.current === newEngine) setEngine(null);
|
|
1123
|
+
});
|
|
1124
|
+
const unsubscribeSessionExpired = persona !== "share" ? newEngine.events.on("session.expired", () => reportExpired?.("session")) : void 0;
|
|
1125
|
+
const unsubscribeShareExpired = persona === "share" ? newEngine.events.on("share.expired", () => reportExpired?.("share")) : void 0;
|
|
1126
|
+
const unsubscribeShareRevoked = persona === "share" ? newEngine.events.on("share.revoked", () => reportExpired?.("share")) : void 0;
|
|
1127
|
+
return () => {
|
|
1128
|
+
unsubscribeSessionExpired?.();
|
|
1129
|
+
unsubscribeShareExpired?.();
|
|
1130
|
+
unsubscribeShareRevoked?.();
|
|
1131
|
+
disposed = true;
|
|
1132
|
+
if (opened) newEngine.close();
|
|
1133
|
+
if (engineRef.current === newEngine) {
|
|
1134
|
+
engineRef.current = null;
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
}, [client, derivedScope, session.status, persona, reportExpired]);
|
|
1138
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkCK3L6Y43_cjs.OfflineEngineContext.Provider, { value: engine, children });
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
// src/core/shells/internal/jwtKind.ts
|
|
1142
|
+
function base64UrlDecode(segment) {
|
|
1143
|
+
const padded = segment.replace(/-/g, "+").replace(/_/g, "/");
|
|
1144
|
+
const withPadding = padded + "=".repeat((4 - padded.length % 4) % 4);
|
|
1145
|
+
return atob(withPadding);
|
|
1146
|
+
}
|
|
1147
|
+
function decodeManagerOrAgencyAdminKind(accessToken) {
|
|
1148
|
+
const segments = accessToken.split(".");
|
|
1149
|
+
const payloadSegment = segments[1];
|
|
1150
|
+
if (segments.length !== 3 || payloadSegment === void 0) {
|
|
1151
|
+
throw new Error(
|
|
1152
|
+
'SessionShell could not parse "accessToken" as a JWT \u2014 it does not have the three dot-separated segments every manager/agencyAdmin session token has.'
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
let claim;
|
|
1156
|
+
try {
|
|
1157
|
+
claim = JSON.parse(base64UrlDecode(payloadSegment));
|
|
1158
|
+
} catch {
|
|
1159
|
+
throw new Error(
|
|
1160
|
+
`SessionShell could not decode "accessToken"'s payload segment as JSON \u2014 the value handed to <KaafilUIKitProvider accessToken> is not a well-formed JWT.`
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
const kind = claim.kind;
|
|
1164
|
+
if (kind === "agencyAdmin") {
|
|
1165
|
+
return "agencyAdmin";
|
|
1166
|
+
}
|
|
1167
|
+
if (kind === "managerSession" || kind === "manager") {
|
|
1168
|
+
return "managerSession";
|
|
1169
|
+
}
|
|
1170
|
+
throw new Error(
|
|
1171
|
+
`SessionShell read an unrecognised "kind" claim ("${String(kind)}") off "accessToken" \u2014 expected the manager or agencyAdmin session JWT shape (00-decisions.md U-003).`
|
|
1172
|
+
);
|
|
1173
|
+
}
|
|
1174
|
+
async function resolveCredential(props) {
|
|
1175
|
+
if (props.credentialResolver !== void 0) {
|
|
1176
|
+
const resolved = await props.credentialResolver();
|
|
1177
|
+
if ("shareToken" in resolved) {
|
|
1178
|
+
return { kind: "share", shareToken: resolved.shareToken };
|
|
1179
|
+
}
|
|
1180
|
+
const kind2 = decodeManagerOrAgencyAdminKind(resolved.accessToken) === "agencyAdmin" ? "agencyAdmin" : "manager";
|
|
1181
|
+
return { kind: kind2, ...resolved };
|
|
1182
|
+
}
|
|
1183
|
+
if (props.shareToken !== void 0) {
|
|
1184
|
+
return { kind: "share", shareToken: props.shareToken };
|
|
1185
|
+
}
|
|
1186
|
+
const kind = decodeManagerOrAgencyAdminKind(props.accessToken) === "agencyAdmin" ? "agencyAdmin" : "manager";
|
|
1187
|
+
return {
|
|
1188
|
+
kind,
|
|
1189
|
+
accessToken: props.accessToken,
|
|
1190
|
+
refreshToken: props.refreshToken,
|
|
1191
|
+
agencyRef: props.agencyRef
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
function SessionShell(props) {
|
|
1195
|
+
const { environment = "live", onRefresh, onSessionExpired, children } = props;
|
|
1196
|
+
const [state, setState] = react.useState(null);
|
|
1197
|
+
const expiredCallbackFiredRef = react.useRef(false);
|
|
1198
|
+
const currentPersonaRef = react.useRef("manager");
|
|
1199
|
+
const reportExpired = react.useCallback(() => {
|
|
1200
|
+
if (expiredCallbackFiredRef.current) {
|
|
1201
|
+
return;
|
|
1202
|
+
}
|
|
1203
|
+
expiredCallbackFiredRef.current = true;
|
|
1204
|
+
onSessionExpired?.(currentPersonaRef.current);
|
|
1205
|
+
setState(
|
|
1206
|
+
(current) => current === null ? current : { ...current, session: { ...current.session, status: "expired" } }
|
|
1207
|
+
);
|
|
1208
|
+
}, [onSessionExpired]);
|
|
1209
|
+
const accessTokenDep = "accessToken" in props ? props.accessToken : void 0;
|
|
1210
|
+
const refreshTokenDep = "refreshToken" in props ? props.refreshToken : void 0;
|
|
1211
|
+
const agencyRefDep = "agencyRef" in props ? props.agencyRef : void 0;
|
|
1212
|
+
const shareTokenDep = "shareToken" in props ? props.shareToken : void 0;
|
|
1213
|
+
react.useEffect(() => {
|
|
1214
|
+
let cancelled = false;
|
|
1215
|
+
const client$1 = new client.KaafilClient({ environment });
|
|
1216
|
+
expiredCallbackFiredRef.current = false;
|
|
1217
|
+
async function open() {
|
|
1218
|
+
const credential = await resolveCredential(props);
|
|
1219
|
+
if (cancelled) {
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
currentPersonaRef.current = credential.kind;
|
|
1223
|
+
if (credential.kind === "share") {
|
|
1224
|
+
client$1.share.open({ token: credential.shareToken });
|
|
1225
|
+
} else if (credential.kind === "agencyAdmin") {
|
|
1226
|
+
client$1.admin.open({
|
|
1227
|
+
accessToken: credential.accessToken,
|
|
1228
|
+
refreshToken: credential.refreshToken,
|
|
1229
|
+
agencyRef: credential.agencyRef,
|
|
1230
|
+
...onRefresh !== void 0 ? { onRefresh } : {}
|
|
1231
|
+
});
|
|
1232
|
+
} else {
|
|
1233
|
+
client$1.session.open({
|
|
1234
|
+
accessToken: credential.accessToken,
|
|
1235
|
+
refreshToken: credential.refreshToken,
|
|
1236
|
+
agencyRef: credential.agencyRef,
|
|
1237
|
+
...onRefresh !== void 0 ? { onRefresh } : {}
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
setState({
|
|
1241
|
+
client: client$1,
|
|
1242
|
+
session: {
|
|
1243
|
+
status: "authenticated",
|
|
1244
|
+
persona: credential.kind,
|
|
1245
|
+
agencyRef: credential.agencyRef,
|
|
1246
|
+
environment
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
void open();
|
|
1251
|
+
return () => {
|
|
1252
|
+
cancelled = true;
|
|
1253
|
+
client$1.close();
|
|
1254
|
+
};
|
|
1255
|
+
}, [environment, accessTokenDep, refreshTokenDep, agencyRefDep, shareTokenDep]);
|
|
1256
|
+
if (state === null) {
|
|
1257
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SessionExpiryBridgeContext.Provider, { value: reportExpired, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1258
|
+
chunkCK3L6Y43_cjs.SessionContext.Provider,
|
|
1259
|
+
{
|
|
1260
|
+
value: { status: "opening", persona: "manager", agencyRef: void 0, environment },
|
|
1261
|
+
children
|
|
1262
|
+
}
|
|
1263
|
+
) });
|
|
1264
|
+
}
|
|
1265
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SessionExpiryBridgeContext.Provider, { value: reportExpired, children: /* @__PURE__ */ jsxRuntime.jsx(chunkCK3L6Y43_cjs.KaafilClientContext.Provider, { value: state.client, children: /* @__PURE__ */ jsxRuntime.jsx(chunkCK3L6Y43_cjs.SessionContext.Provider, { value: state.session, children }) }) });
|
|
1266
|
+
}
|
|
1267
|
+
function emit(onEvent, event) {
|
|
1268
|
+
if (onEvent === void 0) {
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
try {
|
|
1272
|
+
onEvent(event);
|
|
1273
|
+
} catch {
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
function TelemetryShell({ onEvent, children }) {
|
|
1277
|
+
const session = chunkCK3L6Y43_cjs.useSession();
|
|
1278
|
+
const serverTime = chunkLO3GQFQ6_cjs.useServerTime();
|
|
1279
|
+
const previousStatusRef = react.useRef(void 0);
|
|
1280
|
+
react.useEffect(() => {
|
|
1281
|
+
const previousStatus = previousStatusRef.current;
|
|
1282
|
+
if (serverTime.sinceLastSync !== void 0) {
|
|
1283
|
+
if (session.status === "authenticated" && previousStatus !== "authenticated") {
|
|
1284
|
+
emit(onEvent, {
|
|
1285
|
+
type: "session.opened",
|
|
1286
|
+
timestamp: serverTime.now(),
|
|
1287
|
+
persona: session.persona
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
if (session.status === "expired" && previousStatus !== "expired") {
|
|
1291
|
+
emit(onEvent, {
|
|
1292
|
+
type: "session.expired",
|
|
1293
|
+
timestamp: serverTime.now(),
|
|
1294
|
+
persona: session.persona
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
previousStatusRef.current = session.status;
|
|
1299
|
+
}, [session.status, serverTime.sinceLastSync]);
|
|
1300
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
1301
|
+
}
|
|
1302
|
+
function resolveSystemTheme() {
|
|
1303
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
1304
|
+
return "light";
|
|
1305
|
+
}
|
|
1306
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1307
|
+
}
|
|
1308
|
+
function ThemeShell({ theme = "system", density, children }) {
|
|
1309
|
+
const [systemTheme, setSystemTheme] = react.useState(
|
|
1310
|
+
() => theme === "system" ? resolveSystemTheme() : theme
|
|
1311
|
+
);
|
|
1312
|
+
react.useEffect(() => {
|
|
1313
|
+
if (theme !== "system" || typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
1314
|
+
return;
|
|
1315
|
+
}
|
|
1316
|
+
const query = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1317
|
+
const listener = (event) => {
|
|
1318
|
+
setSystemTheme(event.matches ? "dark" : "light");
|
|
1319
|
+
};
|
|
1320
|
+
query.addEventListener("change", listener);
|
|
1321
|
+
return () => query.removeEventListener("change", listener);
|
|
1322
|
+
}, [theme]);
|
|
1323
|
+
const resolvedTheme = theme === "system" ? systemTheme : theme;
|
|
1324
|
+
const value = react.useMemo(() => ({ theme: resolvedTheme, density }), [resolvedTheme, density]);
|
|
1325
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeAttributesContext.Provider, { value, children });
|
|
1326
|
+
}
|
|
1327
|
+
var DefaultCapabilityViewsContext = react.createContext({});
|
|
1328
|
+
function useDefaultCapabilityViews() {
|
|
1329
|
+
return react.useContext(DefaultCapabilityViewsContext);
|
|
1330
|
+
}
|
|
1331
|
+
var BuildShareUrlContext = react.createContext(null);
|
|
1332
|
+
function useBuildShareUrl() {
|
|
1333
|
+
return react.useContext(BuildShareUrlContext);
|
|
1334
|
+
}
|
|
1335
|
+
function KaafilUIKitProvider(props) {
|
|
1336
|
+
const {
|
|
1337
|
+
environment,
|
|
1338
|
+
onSessionExpired,
|
|
1339
|
+
density,
|
|
1340
|
+
theme,
|
|
1341
|
+
brand,
|
|
1342
|
+
locale,
|
|
1343
|
+
isolation,
|
|
1344
|
+
onEvent,
|
|
1345
|
+
storage,
|
|
1346
|
+
blob,
|
|
1347
|
+
conflictResolver,
|
|
1348
|
+
readEntity,
|
|
1349
|
+
offlineScope,
|
|
1350
|
+
seedConfig,
|
|
1351
|
+
defaultCapabilityViews,
|
|
1352
|
+
buildShareUrl,
|
|
1353
|
+
children,
|
|
1354
|
+
...credential
|
|
1355
|
+
} = props;
|
|
1356
|
+
const inner = /* @__PURE__ */ jsxRuntime.jsx(BuildShareUrlContext.Provider, { value: buildShareUrl ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(DefaultCapabilityViewsContext.Provider, { value: defaultCapabilityViews ?? {}, children: /* @__PURE__ */ jsxRuntime.jsx(ConfigShell, { seedConfig, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1357
|
+
chunkCK3L6Y43_cjs.BrandShell,
|
|
1358
|
+
{
|
|
1359
|
+
appName: brand?.appName,
|
|
1360
|
+
logo: brand?.logo,
|
|
1361
|
+
logoMark: brand?.logoMark,
|
|
1362
|
+
favicon: brand?.favicon,
|
|
1363
|
+
headStrategy: brand?.headStrategy,
|
|
1364
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(TelemetryShell, { onEvent, children })
|
|
1365
|
+
}
|
|
1366
|
+
) }) }) });
|
|
1367
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ErrorShell, { children: /* @__PURE__ */ jsxRuntime.jsx(ThemeShell, { theme, density, children: /* @__PURE__ */ jsxRuntime.jsx(chunkCK3L6Y43_cjs.I18nShell, { locale, children: /* @__PURE__ */ jsxRuntime.jsx(AppShell, { isolation, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1368
|
+
SessionShell,
|
|
1369
|
+
{
|
|
1370
|
+
...credential,
|
|
1371
|
+
environment,
|
|
1372
|
+
onSessionExpired,
|
|
1373
|
+
children: storage !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1374
|
+
OfflineShell,
|
|
1375
|
+
{
|
|
1376
|
+
storage,
|
|
1377
|
+
blob,
|
|
1378
|
+
conflictResolver,
|
|
1379
|
+
readEntity,
|
|
1380
|
+
scope: offlineScope,
|
|
1381
|
+
children: inner
|
|
1382
|
+
}
|
|
1383
|
+
) : inner
|
|
1384
|
+
}
|
|
1385
|
+
) }) }) }) });
|
|
1386
|
+
}
|
|
894
1387
|
|
|
895
1388
|
// src/core/routing/deepLinks.ts
|
|
896
1389
|
var CLOSEOUT_ACTION_TAB = {
|
|
@@ -972,7 +1465,15 @@ var TRIP_TAB_KEY_SET = {
|
|
|
972
1465
|
forms: true
|
|
973
1466
|
};
|
|
974
1467
|
|
|
1468
|
+
exports.AppShell = AppShell;
|
|
975
1469
|
exports.CLOSEOUT_ACTION_TAB = CLOSEOUT_ACTION_TAB;
|
|
1470
|
+
exports.ConfigShell = ConfigShell;
|
|
1471
|
+
exports.ErrorShell = ErrorShell;
|
|
1472
|
+
exports.KaafilUIKitProvider = KaafilUIKitProvider;
|
|
1473
|
+
exports.OfflineShell = OfflineShell;
|
|
1474
|
+
exports.SessionShell = SessionShell;
|
|
1475
|
+
exports.TelemetryShell = TelemetryShell;
|
|
1476
|
+
exports.ThemeShell = ThemeShell;
|
|
976
1477
|
exports.familySafeSections = familySafeSections;
|
|
977
1478
|
exports.fromSearchParams = fromSearchParams;
|
|
978
1479
|
exports.isTripTabKey = isTripTabKey;
|
|
@@ -988,11 +1489,12 @@ exports.useAgencyTrip = useAgencyTrip;
|
|
|
988
1489
|
exports.useAgencyTripManifest = useAgencyTripManifest;
|
|
989
1490
|
exports.useAgencyTrips = useAgencyTrips;
|
|
990
1491
|
exports.useBookings = useBookings;
|
|
1492
|
+
exports.useBuildShareUrl = useBuildShareUrl;
|
|
991
1493
|
exports.useCapabilityStatuses = useCapabilityStatuses;
|
|
1494
|
+
exports.useDefaultCapabilityViews = useDefaultCapabilityViews;
|
|
992
1495
|
exports.useDirectories = useDirectories;
|
|
993
1496
|
exports.usePaginatedList = usePaginatedList;
|
|
994
|
-
exports.useResolvedSetting = useResolvedSetting;
|
|
995
1497
|
exports.useShareLinks = useShareLinks;
|
|
996
1498
|
exports.useTravellerFormResponses = useTravellerFormResponses;
|
|
997
|
-
//# sourceMappingURL=chunk-
|
|
998
|
-
//# sourceMappingURL=chunk-
|
|
1499
|
+
//# sourceMappingURL=chunk-IBVCH6GC.cjs.map
|
|
1500
|
+
//# sourceMappingURL=chunk-IBVCH6GC.cjs.map
|