@monkvision/inspection-capture-web 5.0.21 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/lib/PhotoCapture/PhotoCapture.d.ts +2 -2
  3. package/lib/PhotoCapture/PhotoCapture.js +15 -6
  4. package/lib/PhotoCapture/PhotoCapture.styles.js +1 -1
  5. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.d.ts +10 -2
  6. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.js +3 -2
  7. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.d.ts +5 -1
  8. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.js +1 -1
  9. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.d.ts +1 -1
  10. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.js +7 -3
  11. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.styles.js +1 -0
  12. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/hooks.d.ts +5 -1
  13. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.d.ts +23 -0
  14. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.js +65 -0
  15. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.styles.d.ts +7308 -0
  16. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/PhotoCaptureHUDSightTutorial.styles.js +170 -0
  17. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/index.d.ts +1 -0
  18. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDSightTutorial/index.js +5 -0
  19. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.d.ts +5 -1
  20. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.js +3 -2
  21. package/lib/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDTutorial/PhotoCaptureHUDTutorial.styles.js +9 -3
  22. package/lib/PhotoCapture/hooks/index.d.ts +1 -0
  23. package/lib/PhotoCapture/hooks/index.js +1 -0
  24. package/lib/PhotoCapture/hooks/useInspectionComplete.d.ts +5 -1
  25. package/lib/PhotoCapture/hooks/useInspectionComplete.js +64 -16
  26. package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.d.ts +3 -7
  27. package/lib/PhotoCapture/hooks/usePhotoCaptureSightState.js +2 -2
  28. package/lib/PhotoCapture/hooks/usePhotoCaptureSightTutorial.d.ts +14 -0
  29. package/lib/PhotoCapture/hooks/usePhotoCaptureSightTutorial.js +16 -0
  30. package/lib/PhotoCapture/hooks/usePhotoCaptureTutorial.js +1 -1
  31. package/lib/components/SightTutorialButton/SightTutorialButton.d.ts +14 -0
  32. package/lib/components/SightTutorialButton/SightTutorialButton.js +36 -0
  33. package/lib/components/SightTutorialButton/SightTutorialButton.styles.d.ts +2 -0
  34. package/lib/components/SightTutorialButton/SightTutorialButton.styles.js +6 -0
  35. package/lib/components/SightTutorialButton/index.d.ts +1 -0
  36. package/lib/components/SightTutorialButton/index.js +5 -0
  37. package/lib/components/index.d.ts +1 -0
  38. package/lib/components/index.js +1 -0
  39. package/lib/hooks/index.d.ts +1 -0
  40. package/lib/hooks/index.js +1 -0
  41. package/lib/hooks/useCaptureDuration.d.ts +39 -0
  42. package/lib/hooks/useCaptureDuration.js +208 -0
  43. package/lib/hooks/useTracking.js +6 -0
  44. package/lib/translations/de.json +4 -0
  45. package/lib/translations/en.json +4 -0
  46. package/lib/translations/fr.json +4 -0
  47. package/lib/translations/nl.json +4 -0
  48. package/package.json +15 -15
package/README.md CHANGED
@@ -85,6 +85,7 @@ export function MonkPhotoCapturePage({ authToken }) {
85
85
  | enableSightGuideline | `boolean` | Boolean indicating whether the sight guideline feature is enabled. If disabled, the guideline text will be hidden. | | `true` |
86
86
  | enableTutorial | `PhotoCaptureTutorialOption` | Options for displaying the photo capture tutorial. | | `PhotoCaptureTutorialOption.FIRST_TIME_ONLY` |
87
87
  | allowSkipTutorial | `boolean` | Boolean indicating if the user can skip the PhotoCapture tutorial. | | `true` |
88
+ | sightTutorial | `sightTutorial[]` | A collection of sight tutorial in different language with a list of sightIds associate to it. | | |
88
89
  | enableSightTutorial | `boolean` | Boolean indicating whether the sight tutorial feature is enabled. | | `true` |
89
90
  | enableCompliance | `boolean` | Indicates if compliance checks should be enabled or not. | | `true` |
90
91
  | enableCompliancePerSight | `string[]` | Array of Sight IDs that indicates for which sight IDs the compliance should be enabled. | | |
@@ -4,7 +4,7 @@ import { CameraConfig, ComplianceOptions, MonkPicture, PhotoCaptureAppConfig, Si
4
4
  /**
5
5
  * Props of the PhotoCapture component.
6
6
  */
7
- export interface PhotoCaptureProps extends Pick<PhotoCaptureAppConfig, keyof CameraConfig | 'maxUploadDurationWarning' | 'useAdaptiveImageQuality' | 'additionalTasks' | 'tasksBySight' | 'startTasksOnComplete' | 'showCloseButton' | 'enforceOrientation' | 'allowSkipRetake' | 'addDamage' | 'sightGuidelines' | 'enableSightGuidelines' | 'enableTutorial' | 'allowSkipTutorial' | 'enableSightTutorial'>, Partial<ComplianceOptions> {
7
+ export interface PhotoCaptureProps extends Pick<PhotoCaptureAppConfig, keyof CameraConfig | 'maxUploadDurationWarning' | 'useAdaptiveImageQuality' | 'additionalTasks' | 'tasksBySight' | 'startTasksOnComplete' | 'showCloseButton' | 'enforceOrientation' | 'allowSkipRetake' | 'addDamage' | 'sightGuidelines' | 'enableSightGuidelines' | 'enableTutorial' | 'allowSkipTutorial' | 'enableSightTutorial' | 'sightTutorial'>, Partial<ComplianceOptions> {
8
8
  /**
9
9
  * The list of sights to take pictures of. The values in this array should be retreived from the `@monkvision/sights`
10
10
  * package.
@@ -48,4 +48,4 @@ export interface PhotoCaptureProps extends Pick<PhotoCaptureAppConfig, keyof Cam
48
48
  */
49
49
  validateButtonLabel?: string;
50
50
  }
51
- export declare function PhotoCapture({ sights, inspectionId, apiConfig, additionalTasks, tasksBySight, startTasksOnComplete, onClose, onComplete, onPictureTaken, maxUploadDurationWarning, showCloseButton, enableCompliance, enableCompliancePerSight, complianceIssues, complianceIssuesPerSight, customComplianceThresholds, customComplianceThresholdsPerSight, useLiveCompliance, allowSkipRetake, addDamage, sightGuidelines, enableTutorial, allowSkipTutorial, enableSightTutorial, enableSightGuidelines, useAdaptiveImageQuality, lang, enforceOrientation, validateButtonLabel, vehicleType, ...initialCameraConfig }: PhotoCaptureProps): JSX.Element;
51
+ export declare function PhotoCapture({ sights, inspectionId, apiConfig, additionalTasks, tasksBySight, startTasksOnComplete, onClose, onComplete, onPictureTaken, maxUploadDurationWarning, showCloseButton, enableCompliance, enableCompliancePerSight, complianceIssues, complianceIssuesPerSight, customComplianceThresholds, customComplianceThresholdsPerSight, useLiveCompliance, allowSkipRetake, addDamage, sightGuidelines, enableTutorial, allowSkipTutorial, enableSightTutorial, sightTutorial, enableSightGuidelines, useAdaptiveImageQuality, lang, enforceOrientation, validateButtonLabel, vehicleType, ...initialCameraConfig }: PhotoCaptureProps): JSX.Element;
@@ -42,7 +42,7 @@ var PhotoCaptureScreen;
42
42
  })(PhotoCaptureScreen || (PhotoCaptureScreen = {}));
43
43
  // No ts-doc for this component : the component exported is PhotoCaptureHOC
44
44
  function PhotoCapture(_a) {
45
- var sights = _a.sights, inspectionId = _a.inspectionId, apiConfig = _a.apiConfig, additionalTasks = _a.additionalTasks, tasksBySight = _a.tasksBySight, _b = _a.startTasksOnComplete, startTasksOnComplete = _b === void 0 ? true : _b, onClose = _a.onClose, onComplete = _a.onComplete, onPictureTaken = _a.onPictureTaken, _c = _a.maxUploadDurationWarning, maxUploadDurationWarning = _c === void 0 ? 15000 : _c, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.enableCompliance, enableCompliance = _e === void 0 ? true : _e, enableCompliancePerSight = _a.enableCompliancePerSight, complianceIssues = _a.complianceIssues, complianceIssuesPerSight = _a.complianceIssuesPerSight, customComplianceThresholds = _a.customComplianceThresholds, customComplianceThresholdsPerSight = _a.customComplianceThresholdsPerSight, _f = _a.useLiveCompliance, useLiveCompliance = _f === void 0 ? false : _f, _g = _a.allowSkipRetake, allowSkipRetake = _g === void 0 ? false : _g, _h = _a.addDamage, addDamage = _h === void 0 ? types_1.AddDamage.PART_SELECT : _h, sightGuidelines = _a.sightGuidelines, _j = _a.enableTutorial, enableTutorial = _j === void 0 ? types_1.PhotoCaptureTutorialOption.FIRST_TIME_ONLY : _j, _k = _a.allowSkipTutorial, allowSkipTutorial = _k === void 0 ? true : _k, _l = _a.enableSightTutorial, enableSightTutorial = _l === void 0 ? true : _l, _m = _a.enableSightGuidelines, enableSightGuidelines = _m === void 0 ? types_1.PhotoCaptureSightGuidelinesOption.EPHEMERAL : _m, _o = _a.useAdaptiveImageQuality, useAdaptiveImageQuality = _o === void 0 ? true : _o, lang = _a.lang, enforceOrientation = _a.enforceOrientation, validateButtonLabel = _a.validateButtonLabel, _p = _a.vehicleType, vehicleType = _p === void 0 ? types_1.VehicleType.SEDAN : _p, initialCameraConfig = __rest(_a, ["sights", "inspectionId", "apiConfig", "additionalTasks", "tasksBySight", "startTasksOnComplete", "onClose", "onComplete", "onPictureTaken", "maxUploadDurationWarning", "showCloseButton", "enableCompliance", "enableCompliancePerSight", "complianceIssues", "complianceIssuesPerSight", "customComplianceThresholds", "customComplianceThresholdsPerSight", "useLiveCompliance", "allowSkipRetake", "addDamage", "sightGuidelines", "enableTutorial", "allowSkipTutorial", "enableSightTutorial", "enableSightGuidelines", "useAdaptiveImageQuality", "lang", "enforceOrientation", "validateButtonLabel", "vehicleType"]);
45
+ var sights = _a.sights, inspectionId = _a.inspectionId, apiConfig = _a.apiConfig, additionalTasks = _a.additionalTasks, tasksBySight = _a.tasksBySight, _b = _a.startTasksOnComplete, startTasksOnComplete = _b === void 0 ? true : _b, onClose = _a.onClose, onComplete = _a.onComplete, onPictureTaken = _a.onPictureTaken, _c = _a.maxUploadDurationWarning, maxUploadDurationWarning = _c === void 0 ? 15000 : _c, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.enableCompliance, enableCompliance = _e === void 0 ? true : _e, enableCompliancePerSight = _a.enableCompliancePerSight, complianceIssues = _a.complianceIssues, complianceIssuesPerSight = _a.complianceIssuesPerSight, customComplianceThresholds = _a.customComplianceThresholds, customComplianceThresholdsPerSight = _a.customComplianceThresholdsPerSight, _f = _a.useLiveCompliance, useLiveCompliance = _f === void 0 ? false : _f, _g = _a.allowSkipRetake, allowSkipRetake = _g === void 0 ? false : _g, _h = _a.addDamage, addDamage = _h === void 0 ? types_1.AddDamage.PART_SELECT : _h, sightGuidelines = _a.sightGuidelines, _j = _a.enableTutorial, enableTutorial = _j === void 0 ? types_1.PhotoCaptureTutorialOption.FIRST_TIME_ONLY : _j, _k = _a.allowSkipTutorial, allowSkipTutorial = _k === void 0 ? true : _k, _l = _a.enableSightTutorial, enableSightTutorial = _l === void 0 ? types_1.PhotoCaptureSightTutorialOption.DISABLED : _l, sightTutorial = _a.sightTutorial, _m = _a.enableSightGuidelines, enableSightGuidelines = _m === void 0 ? types_1.PhotoCaptureSightGuidelinesOption.EPHEMERAL : _m, _o = _a.useAdaptiveImageQuality, useAdaptiveImageQuality = _o === void 0 ? true : _o, lang = _a.lang, enforceOrientation = _a.enforceOrientation, validateButtonLabel = _a.validateButtonLabel, _p = _a.vehicleType, vehicleType = _p === void 0 ? types_1.VehicleType.SEDAN : _p, initialCameraConfig = __rest(_a, ["sights", "inspectionId", "apiConfig", "additionalTasks", "tasksBySight", "startTasksOnComplete", "onClose", "onComplete", "onPictureTaken", "maxUploadDurationWarning", "showCloseButton", "enableCompliance", "enableCompliancePerSight", "complianceIssues", "complianceIssuesPerSight", "customComplianceThresholds", "customComplianceThresholdsPerSight", "useLiveCompliance", "allowSkipRetake", "addDamage", "sightGuidelines", "enableTutorial", "allowSkipTutorial", "enableSightTutorial", "sightTutorial", "enableSightGuidelines", "useAdaptiveImageQuality", "lang", "enforceOrientation", "validateButtonLabel", "vehicleType"]);
46
46
  (0, common_1.useI18nSync)(lang);
47
47
  var complianceOptions = (0, common_1.useObjectMemo)({
48
48
  enableCompliance: enableCompliance,
@@ -92,18 +92,17 @@ function PhotoCapture(_a) {
92
92
  tasksBySight: tasksBySight,
93
93
  complianceOptions: complianceOptions,
94
94
  setIsInitialInspectionFetched: setIsInitialInspectionFetched,
95
- startTasksOnComplete: startTasksOnComplete,
96
- onComplete: onComplete,
97
95
  });
98
96
  var _s = (0, hooks_2.usePhotoCaptureTutorial)({
99
97
  enableTutorial: enableTutorial,
100
98
  enableSightGuidelines: enableSightGuidelines,
101
99
  enableSightTutorial: enableSightTutorial,
102
100
  }), currentTutorialStep = _s.currentTutorialStep, goToNextTutorialStep = _s.goToNextTutorialStep, closeTutorial = _s.closeTutorial;
103
- var _t = (0, hooks_2.usePhotoCaptureSightGuidelines)({
101
+ var _t = (0, hooks_2.usePhotoCaptureSightTutorial)(), showSightTutorial = _t.showSightTutorial, toggleSightTutorial = _t.toggleSightTutorial;
102
+ var _u = (0, hooks_2.usePhotoCaptureSightGuidelines)({
104
103
  enableSightGuidelines: enableSightGuidelines,
105
- }), showSightGuidelines = _t.showSightGuidelines, handleDisableSightGuidelines = _t.handleDisableSightGuidelines;
106
- var _u = (0, hooks_1.useBadConnectionWarning)({ maxUploadDurationWarning: maxUploadDurationWarning }), isBadConnectionWarningDialogDisplayed = _u.isBadConnectionWarningDialogDisplayed, closeBadConnectionWarningDialog = _u.closeBadConnectionWarningDialog, badConnectionWarningUploadEventHandlers = _u.uploadEventHandlers;
104
+ }), showSightGuidelines = _u.showSightGuidelines, handleDisableSightGuidelines = _u.handleDisableSightGuidelines;
105
+ var _v = (0, hooks_1.useBadConnectionWarning)({ maxUploadDurationWarning: maxUploadDurationWarning }), isBadConnectionWarningDialogDisplayed = _v.isBadConnectionWarningDialogDisplayed, closeBadConnectionWarningDialog = _v.closeBadConnectionWarningDialog, badConnectionWarningUploadEventHandlers = _v.uploadEventHandlers;
107
106
  var uploadQueue = (0, hooks_1.useUploadQueue)({
108
107
  inspectionId: inspectionId,
109
108
  apiConfig: apiConfig,
@@ -119,11 +118,17 @@ function PhotoCapture(_a) {
119
118
  tasksBySight: tasksBySight,
120
119
  onPictureTaken: onPictureTaken,
121
120
  });
121
+ var updateDuration = (0, hooks_1.useCaptureDuration)({
122
+ inspectionId: inspectionId,
123
+ apiConfig: apiConfig,
124
+ isInspectionCompleted: sightState.isInspectionCompleted,
125
+ }).updateDuration;
122
126
  var handleInspectionCompleted = (0, hooks_2.useInspectionComplete)({
123
127
  startTasks: startTasks,
124
128
  sightState: sightState,
125
129
  loading: loading,
126
130
  startTasksOnComplete: startTasksOnComplete,
131
+ onUpdateDuration: updateDuration,
127
132
  onComplete: onComplete,
128
133
  }).handleInspectionCompleted;
129
134
  var handleGalleryBack = function () { return setCurrentScreen(PhotoCaptureScreen.CAMERA); };
@@ -173,6 +178,10 @@ function PhotoCapture(_a) {
173
178
  allowSkipTutorial: allowSkipTutorial,
174
179
  enforceOrientation: enforceOrientation,
175
180
  vehicleType: vehicleType,
181
+ sightTutorial: sightTutorial,
182
+ enableSightTutorial: enableSightTutorial,
183
+ showSightTutorial: showSightTutorial,
184
+ toggleSightTutorial: toggleSightTutorial,
176
185
  };
177
186
  return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCapture_styles_1.styles['container'] }, { children: [currentScreen === PhotoCaptureScreen.CAMERA && ((0, jsx_runtime_1.jsx)(camera_web_1.Camera, __assign({ HUDComponent: PhotoCaptureHUD_1.PhotoCaptureHUD, onPictureTaken: handlePictureTaken, hudProps: hudProps }, adaptiveCameraConfig))), currentScreen === PhotoCaptureScreen.GALLERY && ((0, jsx_runtime_1.jsx)(common_ui_web_1.InspectionGallery, __assign({ inspectionId: inspectionId, apiConfig: apiConfig, captureMode: true, lang: lang, showBackButton: true, sights: sights, allowSkipRetake: allowSkipRetake, onBack: handleGalleryBack, onNavigateToCapture: handleNavigateToCapture, onValidate: handleInspectionCompleted, addDamage: addDamage, validateButtonLabel: validateButtonLabel, isInspectionCompleted: sightState.isInspectionCompleted }, complianceOptions))), (0, jsx_runtime_1.jsx)(common_ui_web_1.BackdropDialog, { show: isBadConnectionWarningDialogDisplayed, showCancelButton: false, dialogIcon: 'warning-outline', dialogIconPrimaryColor: 'caution-base', message: t('photo.badConnectionWarning.message'), confirmLabel: t('photo.badConnectionWarning.confirm'), onConfirm: closeBadConnectionWarningDialog })] })));
178
187
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.styles = void 0;
4
4
  exports.styles = {
5
5
  container: {
6
- height: '100%',
6
+ height: '100dvh',
7
7
  width: '100%',
8
8
  },
9
9
  };
@@ -7,7 +7,7 @@ import { CaptureMode } from '../../types';
7
7
  /**
8
8
  * Props of the PhotoCaptureHUD component.
9
9
  */
10
- export interface PhotoCaptureHUDProps extends CameraHUDProps, Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage' | 'showCloseButton' | 'allowSkipTutorial' | 'enforceOrientation'> {
10
+ export interface PhotoCaptureHUDProps extends CameraHUDProps, Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage' | 'showCloseButton' | 'allowSkipTutorial' | 'enforceOrientation' | 'enableSightTutorial' | 'sightTutorial'> {
11
11
  /**
12
12
  * The inspection ID.
13
13
  */
@@ -105,10 +105,18 @@ export interface PhotoCaptureHUDProps extends CameraHUDProps, Pick<PhotoCaptureA
105
105
  * Boolean indicating whether the sight guidelines should be displayed.
106
106
  */
107
107
  showSightGuidelines: boolean;
108
+ /**
109
+ * Boolean indicating whether the sight tutorial should be displayed.
110
+ */
111
+ showSightTutorial: boolean;
112
+ /**
113
+ * Callback called when the user clicks on the "help" button in PhotoCapture.
114
+ */
115
+ toggleSightTutorial: () => void;
108
116
  }
109
117
  /**
110
118
  * This component implements the Camera HUD (head-up display) displayed in the PhotoCapture component over the Camera
111
119
  * preview. It implements elements such as buttons to interact with the camera, PhotoCapture indicators, error messages,
112
120
  * loaders etc.
113
121
  */
114
- export declare function PhotoCaptureHUD({ inspectionId, sights, selectedSight, sightsTaken, lastPictureTakenUri, mode, vehicleParts, onSelectSight, onRetakeSight, onAddDamage, onAddDamagePartsSelected, onValidateVehicleParts, onCancelAddDamage, onOpenGallery, onRetry, onClose, showCloseButton, loading, handle, cameraPreview, images, addDamage, sightGuidelines, showSightGuidelines, currentTutorialStep, allowSkipTutorial, onNextTutorialStep, onCloseTutorial, enforceOrientation, vehicleType, onDisableSightGuidelines, }: PhotoCaptureHUDProps): JSX.Element;
122
+ export declare function PhotoCaptureHUD({ inspectionId, sights, selectedSight, sightsTaken, lastPictureTakenUri, mode, vehicleParts, onSelectSight, onRetakeSight, onAddDamage, onAddDamagePartsSelected, onValidateVehicleParts, onCancelAddDamage, onOpenGallery, onRetry, onClose, showCloseButton, loading, handle, cameraPreview, images, addDamage, sightGuidelines, showSightGuidelines, currentTutorialStep, allowSkipTutorial, onNextTutorialStep, onCloseTutorial, enforceOrientation, vehicleType, onDisableSightGuidelines, sightTutorial, enableSightTutorial, showSightTutorial, toggleSightTutorial, }: PhotoCaptureHUDProps): JSX.Element;
@@ -23,6 +23,7 @@ var PhotoCaptureHUDElements_1 = require("./PhotoCaptureHUDElements");
23
23
  var PhotoCaptureHUDTutorial_1 = require("./PhotoCaptureHUDTutorial");
24
24
  var types_2 = require("../../types");
25
25
  var components_1 = require("../../components");
26
+ var PhotoCaptureHUDSightTutorial_1 = require("./PhotoCaptureHUDSightTutorial");
26
27
  /**
27
28
  * This component implements the Camera HUD (head-up display) displayed in the PhotoCapture component over the Camera
28
29
  * preview. It implements elements such as buttons to interact with the camera, PhotoCapture indicators, error messages,
@@ -30,7 +31,7 @@ var components_1 = require("../../components");
30
31
  */
31
32
  function PhotoCaptureHUD(_a) {
32
33
  var _b;
33
- var inspectionId = _a.inspectionId, sights = _a.sights, selectedSight = _a.selectedSight, sightsTaken = _a.sightsTaken, lastPictureTakenUri = _a.lastPictureTakenUri, mode = _a.mode, vehicleParts = _a.vehicleParts, onSelectSight = _a.onSelectSight, onRetakeSight = _a.onRetakeSight, onAddDamage = _a.onAddDamage, onAddDamagePartsSelected = _a.onAddDamagePartsSelected, onValidateVehicleParts = _a.onValidateVehicleParts, onCancelAddDamage = _a.onCancelAddDamage, onOpenGallery = _a.onOpenGallery, onRetry = _a.onRetry, onClose = _a.onClose, showCloseButton = _a.showCloseButton, loading = _a.loading, handle = _a.handle, cameraPreview = _a.cameraPreview, images = _a.images, addDamage = _a.addDamage, sightGuidelines = _a.sightGuidelines, showSightGuidelines = _a.showSightGuidelines, currentTutorialStep = _a.currentTutorialStep, allowSkipTutorial = _a.allowSkipTutorial, onNextTutorialStep = _a.onNextTutorialStep, onCloseTutorial = _a.onCloseTutorial, enforceOrientation = _a.enforceOrientation, vehicleType = _a.vehicleType, onDisableSightGuidelines = _a.onDisableSightGuidelines;
34
+ var inspectionId = _a.inspectionId, sights = _a.sights, selectedSight = _a.selectedSight, sightsTaken = _a.sightsTaken, lastPictureTakenUri = _a.lastPictureTakenUri, mode = _a.mode, vehicleParts = _a.vehicleParts, onSelectSight = _a.onSelectSight, onRetakeSight = _a.onRetakeSight, onAddDamage = _a.onAddDamage, onAddDamagePartsSelected = _a.onAddDamagePartsSelected, onValidateVehicleParts = _a.onValidateVehicleParts, onCancelAddDamage = _a.onCancelAddDamage, onOpenGallery = _a.onOpenGallery, onRetry = _a.onRetry, onClose = _a.onClose, showCloseButton = _a.showCloseButton, loading = _a.loading, handle = _a.handle, cameraPreview = _a.cameraPreview, images = _a.images, addDamage = _a.addDamage, sightGuidelines = _a.sightGuidelines, showSightGuidelines = _a.showSightGuidelines, currentTutorialStep = _a.currentTutorialStep, allowSkipTutorial = _a.allowSkipTutorial, onNextTutorialStep = _a.onNextTutorialStep, onCloseTutorial = _a.onCloseTutorial, enforceOrientation = _a.enforceOrientation, vehicleType = _a.vehicleType, onDisableSightGuidelines = _a.onDisableSightGuidelines, sightTutorial = _a.sightTutorial, enableSightTutorial = _a.enableSightTutorial, showSightTutorial = _a.showSightTutorial, toggleSightTutorial = _a.toggleSightTutorial;
34
35
  var t = (0, react_i18next_1.useTranslation)().t;
35
36
  var _c = (0, react_1.useState)(false), showCloseModal = _c[0], setShowCloseModal = _c[1];
36
37
  var style = (0, hooks_1.usePhotoCaptureHUDStyle)();
@@ -45,6 +46,6 @@ function PhotoCaptureHUD(_a) {
45
46
  trackEvent('Capture Closed');
46
47
  onClose === null || onClose === void 0 ? void 0 : onClose();
47
48
  };
48
- return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.container }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: style.previewContainer, "data-testid": 'camera-preview' }, { children: [cameraPreview, (0, jsx_runtime_1.jsx)(PhotoCaptureHUDElements_1.PhotoCaptureHUDElements, { selectedSight: selectedSight, sights: sights, sightsTaken: sightsTaken, mode: mode, vehicleParts: vehicleParts, onAddDamage: onAddDamage, onCancelAddDamage: onCancelAddDamage, onAddDamagePartsSelected: onAddDamagePartsSelected, onSelectSight: onSelectSight, onRetakeSight: onRetakeSight, onValidateVehicleParts: onValidateVehicleParts, error: (_b = loading.error) !== null && _b !== void 0 ? _b : handle.error, previewDimensions: handle.previewDimensions, images: images, addDamage: addDamage, sightGuidelines: sightGuidelines, showSightGuidelines: showSightGuidelines, tutorialStep: currentTutorialStep, vehicleType: vehicleType, onDisableSightGuidelines: onDisableSightGuidelines })] })), mode !== types_2.CaptureMode.ADD_DAMAGE_PART_SELECT && ((0, jsx_runtime_1.jsx)(components_1.HUDButtons, { onOpenGallery: onOpenGallery, onTakePicture: handle === null || handle === void 0 ? void 0 : handle.takePicture, onClose: function () { return setShowCloseModal(true); }, galleryPreview: lastPictureTakenUri !== null && lastPictureTakenUri !== void 0 ? lastPictureTakenUri : undefined, closeDisabled: !!loading.error || !!handle.error, galleryDisabled: !!loading.error || !!handle.error, takePictureDisabled: !!loading.error || !!handle.error || handle.isLoading || loading.isLoading, showCloseButton: showCloseButton, showGalleryBadge: retakeCount > 0, retakeCount: retakeCount })), (0, jsx_runtime_1.jsx)(components_1.HUDOverlay, { inspectionId: inspectionId, handle: handle, isCaptureLoading: loading.isLoading, captureError: loading.error, onRetry: onRetry }), (0, jsx_runtime_1.jsx)(common_ui_web_1.BackdropDialog, { show: showCloseModal, message: t('photo.hud.closeConfirm.message'), cancelLabel: t('photo.hud.closeConfirm.cancel'), confirmLabel: t('photo.hud.closeConfirm.confirm'), onCancel: function () { return setShowCloseModal(false); }, onConfirm: handleCloseConfirm }), (0, jsx_runtime_1.jsx)(PhotoCaptureHUDTutorial_1.PhotoCaptureHUDTutorial, { currentTutorialStep: handle.error || loading.error ? null : currentTutorialStep, onNextTutorialStep: onNextTutorialStep, onCloseTutorial: onCloseTutorial, allowSkipTutorial: allowSkipTutorial, sightId: selectedSight.id, sightGuidelines: sightGuidelines, addDamage: addDamage }), (0, jsx_runtime_1.jsx)(components_1.OrientationEnforcer, { orientation: enforceOrientation })] })));
49
+ return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.container }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: style.previewContainer, "data-testid": 'camera-preview' }, { children: [cameraPreview, (0, jsx_runtime_1.jsx)(PhotoCaptureHUDElements_1.PhotoCaptureHUDElements, { selectedSight: selectedSight, sights: sights, sightsTaken: sightsTaken, mode: mode, vehicleParts: vehicleParts, onAddDamage: onAddDamage, onCancelAddDamage: onCancelAddDamage, onAddDamagePartsSelected: onAddDamagePartsSelected, onSelectSight: onSelectSight, onRetakeSight: onRetakeSight, onValidateVehicleParts: onValidateVehicleParts, error: (_b = loading.error) !== null && _b !== void 0 ? _b : handle.error, previewDimensions: handle.previewDimensions, images: images, addDamage: addDamage, sightGuidelines: sightGuidelines, showSightGuidelines: showSightGuidelines, tutorialStep: currentTutorialStep, vehicleType: vehicleType, onDisableSightGuidelines: onDisableSightGuidelines, enableSightTutorial: enableSightTutorial, toggleSightTutorial: toggleSightTutorial })] })), mode !== types_2.CaptureMode.ADD_DAMAGE_PART_SELECT && ((0, jsx_runtime_1.jsx)(components_1.HUDButtons, { onOpenGallery: onOpenGallery, onTakePicture: handle === null || handle === void 0 ? void 0 : handle.takePicture, onClose: function () { return setShowCloseModal(true); }, galleryPreview: lastPictureTakenUri !== null && lastPictureTakenUri !== void 0 ? lastPictureTakenUri : undefined, closeDisabled: !!loading.error || !!handle.error, galleryDisabled: !!loading.error || !!handle.error, takePictureDisabled: !!loading.error || !!handle.error || handle.isLoading || loading.isLoading, showCloseButton: showCloseButton, showGalleryBadge: retakeCount > 0, retakeCount: retakeCount })), (0, jsx_runtime_1.jsx)(components_1.HUDOverlay, { inspectionId: inspectionId, handle: handle, isCaptureLoading: loading.isLoading, captureError: loading.error, onRetry: onRetry }), (0, jsx_runtime_1.jsx)(common_ui_web_1.BackdropDialog, { show: showCloseModal, message: t('photo.hud.closeConfirm.message'), cancelLabel: t('photo.hud.closeConfirm.cancel'), confirmLabel: t('photo.hud.closeConfirm.confirm'), onCancel: function () { return setShowCloseModal(false); }, onConfirm: handleCloseConfirm }), (0, jsx_runtime_1.jsx)(PhotoCaptureHUDTutorial_1.PhotoCaptureHUDTutorial, { currentTutorialStep: handle.error || loading.error ? null : currentTutorialStep, onNextTutorialStep: onNextTutorialStep, onCloseTutorial: onCloseTutorial, allowSkipTutorial: allowSkipTutorial, sightId: selectedSight.id, sightGuidelines: sightGuidelines, addDamage: addDamage, toggleSightTutorial: toggleSightTutorial }), (0, jsx_runtime_1.jsx)(PhotoCaptureHUDSightTutorial_1.PhotoCaptureHUDSightTutorial, { show: showSightTutorial, sightTutorial: sightTutorial, selectedSight: selectedSight, onClose: toggleSightTutorial, enableSightTutorial: enableSightTutorial }), (0, jsx_runtime_1.jsx)(components_1.OrientationEnforcer, { orientation: enforceOrientation })] })));
49
50
  }
50
51
  exports.PhotoCaptureHUD = PhotoCaptureHUD;
@@ -5,7 +5,7 @@ import { CaptureMode } from '../../../types';
5
5
  /**
6
6
  * Props of the PhotoCaptureHUDElements component.
7
7
  */
8
- export interface PhotoCaptureHUDElementsProps extends Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage'> {
8
+ export interface PhotoCaptureHUDElementsProps extends Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage' | 'enableSightTutorial'> {
9
9
  /**
10
10
  * The currently selected sight in the PhotoCapture component : the sight that the user needs to capture.
11
11
  */
@@ -78,6 +78,10 @@ export interface PhotoCaptureHUDElementsProps extends Pick<PhotoCaptureAppConfig
78
78
  * Boolean indicating whether the sight guidelines should be displayed.
79
79
  */
80
80
  showSightGuidelines?: boolean;
81
+ /**
82
+ * Callback called when the user clicks on the "help" button in PhotoCapture.
83
+ */
84
+ toggleSightTutorial?: () => void;
81
85
  }
82
86
  /**
83
87
  * Component implementing an HUD displayed on top of the Camera preview during the PhotoCapture process.
@@ -13,7 +13,7 @@ function PhotoCaptureHUDElements(params) {
13
13
  return null;
14
14
  }
15
15
  if (params.mode === types_1.CaptureMode.SIGHT) {
16
- return ((0, jsx_runtime_1.jsx)(PhotoCaptureHUDElementsSight_1.PhotoCaptureHUDElementsSight, { sights: params.sights, selectedSight: params.selectedSight, onSelectedSight: params.onSelectSight, onRetakeSight: params.onRetakeSight, sightsTaken: params.sightsTaken, onAddDamage: params.onAddDamage, previewDimensions: params.previewDimensions, images: params.images, addDamage: params.addDamage, sightGuidelines: params.sightGuidelines, showSightGuidelines: params.showSightGuidelines, tutorialStep: params.tutorialStep, onDisableSightGuidelines: params.onDisableSightGuidelines }));
16
+ return ((0, jsx_runtime_1.jsx)(PhotoCaptureHUDElementsSight_1.PhotoCaptureHUDElementsSight, { sights: params.sights, selectedSight: params.selectedSight, onSelectedSight: params.onSelectSight, onRetakeSight: params.onRetakeSight, sightsTaken: params.sightsTaken, onAddDamage: params.onAddDamage, previewDimensions: params.previewDimensions, images: params.images, addDamage: params.addDamage, sightGuidelines: params.sightGuidelines, showSightGuidelines: params.showSightGuidelines, tutorialStep: params.tutorialStep, onDisableSightGuidelines: params.onDisableSightGuidelines, enableSightTutorial: params.enableSightTutorial, toggleSightTutorial: params.toggleSightTutorial }));
17
17
  }
18
18
  if (params.mode === types_1.CaptureMode.ADD_DAMAGE_1ST_SHOT) {
19
19
  return (0, jsx_runtime_1.jsx)(components_1.ZoomOutShot, { onCancel: params.onCancelAddDamage });
@@ -4,4 +4,4 @@ import { PhotoCaptureHUDElementsSightProps } from './hooks';
4
4
  * Component implementing an HUD displayed on top of the Camera preview during the PhotoCapture process when the current
5
5
  * mode is SIGHT.
6
6
  */
7
- export declare function PhotoCaptureHUDElementsSight({ sights, selectedSight, onSelectedSight, onRetakeSight, onAddDamage, onDisableSightGuidelines, sightsTaken, previewDimensions, images, addDamage, sightGuidelines, showSightGuidelines, tutorialStep, }: PhotoCaptureHUDElementsSightProps): JSX.Element;
7
+ export declare function PhotoCaptureHUDElementsSight({ sights, selectedSight, onSelectedSight, onRetakeSight, onAddDamage, onDisableSightGuidelines, sightsTaken, previewDimensions, images, addDamage, sightGuidelines, showSightGuidelines, tutorialStep, enableSightTutorial, toggleSightTutorial, }: PhotoCaptureHUDElementsSightProps): JSX.Element;
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.PhotoCaptureHUDElementsSight = void 0;
15
15
  var jsx_runtime_1 = require("react/jsx-runtime");
16
16
  var common_ui_web_1 = require("@monkvision/common-ui-web");
17
+ var types_1 = require("@monkvision/types");
17
18
  var SightSlider_1 = require("./SightSlider");
18
19
  var PhotoCaptureHUDElementsSight_styles_1 = require("./PhotoCaptureHUDElementsSight.styles");
19
20
  var AddDamageButton_1 = require("./AddDamageButton");
@@ -21,15 +22,18 @@ var hooks_1 = require("./hooks");
21
22
  var hooks_2 = require("../../hooks");
22
23
  var SightGuideline_1 = require("./SightGuideline");
23
24
  var components_1 = require("../../../components");
24
- var types_1 = require("../../../types");
25
+ var types_2 = require("../../../types");
25
26
  /**
26
27
  * Component implementing an HUD displayed on top of the Camera preview during the PhotoCapture process when the current
27
28
  * mode is SIGHT.
28
29
  */
29
30
  function PhotoCaptureHUDElementsSight(_a) {
30
- var sights = _a.sights, selectedSight = _a.selectedSight, _b = _a.onSelectedSight, onSelectedSight = _b === void 0 ? function () { } : _b, _c = _a.onRetakeSight, onRetakeSight = _c === void 0 ? function () { } : _c, _d = _a.onAddDamage, onAddDamage = _d === void 0 ? function () { } : _d, _e = _a.onDisableSightGuidelines, onDisableSightGuidelines = _e === void 0 ? function () { } : _e, sightsTaken = _a.sightsTaken, previewDimensions = _a.previewDimensions, images = _a.images, addDamage = _a.addDamage, sightGuidelines = _a.sightGuidelines, showSightGuidelines = _a.showSightGuidelines, tutorialStep = _a.tutorialStep;
31
+ var sights = _a.sights, selectedSight = _a.selectedSight, _b = _a.onSelectedSight, onSelectedSight = _b === void 0 ? function () { } : _b, _c = _a.onRetakeSight, onRetakeSight = _c === void 0 ? function () { } : _c, _d = _a.onAddDamage, onAddDamage = _d === void 0 ? function () { } : _d, _e = _a.onDisableSightGuidelines, onDisableSightGuidelines = _e === void 0 ? function () { } : _e, sightsTaken = _a.sightsTaken, previewDimensions = _a.previewDimensions, images = _a.images, addDamage = _a.addDamage, sightGuidelines = _a.sightGuidelines, showSightGuidelines = _a.showSightGuidelines, tutorialStep = _a.tutorialStep, enableSightTutorial = _a.enableSightTutorial, toggleSightTutorial = _a.toggleSightTutorial;
31
32
  var style = (0, hooks_1.usePhotoCaptureHUDSightPreviewStyle)({ previewDimensions: previewDimensions });
32
33
  var showSight = previewDimensions && (!tutorialStep || tutorialStep === hooks_2.TutorialSteps.SIGHT);
33
- return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDElementsSight_styles_1.styles['container'] }, { children: [showSight && (0, jsx_runtime_1.jsx)(common_ui_web_1.SightOverlay, { style: style.overlay, sight: selectedSight }), !tutorialStep && ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.elementsContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: style.top }, { children: [(0, jsx_runtime_1.jsx)(SightGuideline_1.SightGuideline, { sightId: selectedSight.id, sightGuidelines: sightGuidelines, disabled: !showSightGuidelines, addDamage: addDamage, onDisableSightGuidelines: onDisableSightGuidelines }), (0, jsx_runtime_1.jsx)(AddDamageButton_1.AddDamageButton, { onAddDamage: onAddDamage, addDamage: addDamage })] })), (0, jsx_runtime_1.jsxs)("div", __assign({ style: style.bottom }, { children: [(0, jsx_runtime_1.jsx)(components_1.Counter, { mode: types_1.CaptureMode.SIGHT, totalSights: sights.length, sightsTaken: sightsTaken.length }), (0, jsx_runtime_1.jsx)(SightSlider_1.SightSlider, { sights: sights, selectedSight: selectedSight, sightsTaken: sightsTaken, onSelectedSight: onSelectedSight, onRetakeSight: onRetakeSight, images: images })] }))] })))] })));
34
+ return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDElementsSight_styles_1.styles['container'] }, { children: [showSight && (0, jsx_runtime_1.jsx)(common_ui_web_1.SightOverlay, { style: style.overlay, sight: selectedSight }), !tutorialStep && ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.elementsContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: style.top }, { children: [[
35
+ types_1.PhotoCaptureSightTutorialOption.CLASSIC,
36
+ types_1.PhotoCaptureSightTutorialOption.MODERN,
37
+ ].includes(enableSightTutorial) && ((0, jsx_runtime_1.jsx)(components_1.SightTutorialButton, { toggleSightTutorial: toggleSightTutorial })), (0, jsx_runtime_1.jsx)(SightGuideline_1.SightGuideline, { sightId: selectedSight.id, sightGuidelines: sightGuidelines, disabled: !showSightGuidelines, addDamage: addDamage, onDisableSightGuidelines: onDisableSightGuidelines }), (0, jsx_runtime_1.jsx)(AddDamageButton_1.AddDamageButton, { onAddDamage: onAddDamage, addDamage: addDamage })] })), (0, jsx_runtime_1.jsxs)("div", __assign({ style: style.bottom }, { children: [(0, jsx_runtime_1.jsx)(components_1.Counter, { mode: types_2.CaptureMode.SIGHT, totalSights: sights.length, sightsTaken: sightsTaken.length }), (0, jsx_runtime_1.jsx)(SightSlider_1.SightSlider, { sights: sights, selectedSight: selectedSight, sightsTaken: sightsTaken, onSelectedSight: onSelectedSight, onRetakeSight: onRetakeSight, images: images })] }))] })))] })));
34
38
  }
35
39
  exports.PhotoCaptureHUDElementsSight = PhotoCaptureHUDElementsSight;
@@ -37,4 +37,5 @@ exports.styles = {
37
37
  zIndex: 9,
38
38
  paddingBottom: '12px',
39
39
  },
40
+ sightTutorialButton: { padding: '8px' },
40
41
  };
@@ -4,7 +4,7 @@ import { TutorialSteps } from '../../hooks';
4
4
  /**
5
5
  * Props of the PhotoCaptureHUDElementsSight component.
6
6
  */
7
- export interface PhotoCaptureHUDElementsSightProps extends Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage'> {
7
+ export interface PhotoCaptureHUDElementsSightProps extends Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage' | 'enableSightTutorial'> {
8
8
  /**
9
9
  * The list of sights provided to the PhotoCapture component.
10
10
  */
@@ -49,6 +49,10 @@ export interface PhotoCaptureHUDElementsSightProps extends Pick<PhotoCaptureAppC
49
49
  * Boolean indicating whether the sight guidelines should be displayed.
50
50
  */
51
51
  showSightGuidelines?: boolean;
52
+ /**
53
+ * Callback called when the user clicks on the "help" button in PhotoCapture.
54
+ */
55
+ toggleSightTutorial?: () => void;
52
56
  }
53
57
  export declare function usePhotoCaptureHUDSightPreviewStyle({ previewDimensions, }: Pick<PhotoCaptureHUDElementsSightProps, 'previewDimensions'>): {
54
58
  container: import("@monkvision/types").ResponsiveStyleProperties;
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import { PhotoCaptureAppConfig, Sight } from '@monkvision/types';
3
+ /**
4
+ * The props for the PhotoCaptureHUDSightTutorial component.
5
+ */
6
+ export interface PhotoCaptureHUDSightTutorialProps extends Pick<PhotoCaptureAppConfig, 'sightTutorial' | 'enableSightTutorial'> {
7
+ /**
8
+ * The sight to display the tutorial for.
9
+ */
10
+ selectedSight: Sight;
11
+ /**
12
+ * Callback called when the user clicks on the "close" button in Sight Tutorial.
13
+ */
14
+ onClose?: () => void;
15
+ /**
16
+ * The current tutorial step in PhotoCapture component.
17
+ */
18
+ show?: boolean;
19
+ }
20
+ /**
21
+ * This component displays the sight tutorial for a specific sight.
22
+ */
23
+ export declare function PhotoCaptureHUDSightTutorial({ selectedSight, sightTutorial, onClose, show, enableSightTutorial, }: PhotoCaptureHUDSightTutorialProps): JSX.Element | null;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.PhotoCaptureHUDSightTutorial = void 0;
15
+ var jsx_runtime_1 = require("react/jsx-runtime");
16
+ var types_1 = require("@monkvision/types");
17
+ var common_ui_web_1 = require("@monkvision/common-ui-web");
18
+ var react_i18next_1 = require("react-i18next");
19
+ var common_1 = require("@monkvision/common");
20
+ var IconVerticalPosition_types_1 = require("@monkvision/common-ui-web/lib/components/IconVerticalPosition/IconVerticalPosition.types");
21
+ var react_1 = require("react");
22
+ var PhotoCaptureHUDSightTutorial_styles_1 = require("./PhotoCaptureHUDSightTutorial.styles");
23
+ /**
24
+ * This component displays the sight tutorial for a specific sight.
25
+ */
26
+ function PhotoCaptureHUDSightTutorial(_a) {
27
+ var _b, _c, _d, _e;
28
+ var selectedSight = _a.selectedSight, sightTutorial = _a.sightTutorial, _f = _a.onClose, onClose = _f === void 0 ? function () { } : _f, show = _a.show, enableSightTutorial = _a.enableSightTutorial;
29
+ var _g = (0, react_1.useState)(null), tutorialImage = _g[0], setTutorialImage = _g[1];
30
+ var i18n = (0, react_i18next_1.useTranslation)().i18n;
31
+ var t = (0, react_i18next_1.useTranslation)().t;
32
+ var style = (0, PhotoCaptureHUDSightTutorial_styles_1.usePhotoCaptureHUDSightTutorialStyles)(show, !!tutorialImage);
33
+ var sightTutorialFound = sightTutorial === null || sightTutorial === void 0 ? void 0 : sightTutorial.find(function (value) {
34
+ return Object.keys(value.imageReferenceBySightId).includes(selectedSight.id);
35
+ });
36
+ var tutorialGuideline = sightTutorialFound === null || sightTutorialFound === void 0 ? void 0 : sightTutorialFound[(0, common_1.getLanguage)(i18n.language)];
37
+ (0, react_1.useEffect)(function () {
38
+ if (sightTutorialFound === null || sightTutorialFound === void 0 ? void 0 : sightTutorialFound.imageReferenceBySightId[selectedSight.id]) {
39
+ setTutorialImage(sightTutorialFound.imageReferenceBySightId[selectedSight.id]);
40
+ }
41
+ else if (selectedSight.referencePicture) {
42
+ var img_1 = new Image();
43
+ img_1.src = selectedSight.referencePicture;
44
+ img_1.onload = function () {
45
+ if (img_1.width > 0) {
46
+ setTutorialImage(selectedSight.referencePicture);
47
+ }
48
+ else {
49
+ setTutorialImage(null);
50
+ }
51
+ };
52
+ img_1.onerror = function () {
53
+ setTutorialImage(null);
54
+ };
55
+ }
56
+ else {
57
+ setTutorialImage(null);
58
+ }
59
+ }, [sightTutorialFound, selectedSight]);
60
+ if (enableSightTutorial === types_1.PhotoCaptureSightTutorialOption.DISABLED) {
61
+ return null;
62
+ }
63
+ return ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.container }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDSightTutorial_styles_1.styles['iconsContainer'] }, { children: [(0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDSightTutorial_styles_1.styles['icon'] }, { children: (0, jsx_runtime_1.jsx)(common_ui_web_1.IconAroundVehicle, { size: 80, orientationAngle: (_b = selectedSight.positioning) === null || _b === void 0 ? void 0 : _b.orientation, positionAroundVehicle: (_c = selectedSight.positioning) === null || _c === void 0 ? void 0 : _c.position, distance: (_d = selectedSight.positioning) === null || _d === void 0 ? void 0 : _d.distance }) })), (0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDSightTutorial_styles_1.styles['icon'] }, { children: (0, jsx_runtime_1.jsx)(common_ui_web_1.IconVerticalPosition, { size: 67, position: (_e = selectedSight.positioning) === null || _e === void 0 ? void 0 : _e.height, variant: IconVerticalPosition_types_1.IconVerticalPositionVariant.SECONDARY }) })), (0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDSightTutorial_styles_1.styles['icon'] }, { children: (0, jsx_runtime_1.jsx)(common_ui_web_1.SightOverlay, { style: PhotoCaptureHUDSightTutorial_styles_1.styles['sightIcon'], sight: selectedSight, getAttributes: style.sightIcon.getAttributes }) }))] })), enableSightTutorial === types_1.PhotoCaptureSightTutorialOption.CLASSIC && ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.classicTutorialContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: style.classicTitleContainer }, { children: [(0, jsx_runtime_1.jsx)(common_ui_web_1.Button, { style: PhotoCaptureHUDSightTutorial_styles_1.styles['closeButtonFiller'], icon: 'close', variant: 'text' }), (0, jsx_runtime_1.jsx)("span", __assign({ style: PhotoCaptureHUDSightTutorial_styles_1.styles['classicTitle'] }, { children: t('photo.hud.sightTutorial.tip').toUpperCase() })), (0, jsx_runtime_1.jsx)(common_ui_web_1.Button, { style: style.closeButton, primaryColor: 'text-black', icon: 'close', variant: 'text', onClick: onClose })] })), (0, jsx_runtime_1.jsx)("div", __assign({ style: style.classicGuidelineContainer }, { children: (0, jsx_runtime_1.jsx)("span", __assign({ style: style.classicGuideline }, { children: tutorialGuideline !== null && tutorialGuideline !== void 0 ? tutorialGuideline : t('photo.hud.sightTutorial.defaultTutorial') })) })), tutorialImage && ((0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDSightTutorial_styles_1.styles['classicImageContainer'] }, { children: (0, jsx_runtime_1.jsx)("img", { style: PhotoCaptureHUDSightTutorial_styles_1.styles['image'], src: tutorialImage, alt: selectedSight.id }) })))] }))), enableSightTutorial === types_1.PhotoCaptureSightTutorialOption.MODERN && ((0, jsx_runtime_1.jsxs)("div", __assign({ style: style.tutorialContainer }, { children: [(0, jsx_runtime_1.jsxs)("div", __assign({ style: PhotoCaptureHUDSightTutorial_styles_1.styles['titleContainer'] }, { children: [(0, jsx_runtime_1.jsx)(common_ui_web_1.Button, { style: PhotoCaptureHUDSightTutorial_styles_1.styles['closeButtonFiller'], icon: 'close', variant: 'text' }), (0, jsx_runtime_1.jsx)("span", { children: t('photo.hud.sightTutorial.tip').toUpperCase() }), (0, jsx_runtime_1.jsx)(common_ui_web_1.Button, { style: style.closeButton, primaryColor: 'text-white', icon: 'close', variant: 'text', onClick: onClose })] })), (0, jsx_runtime_1.jsx)("div", __assign({ style: style.classicGuidelineContainer }, { children: (0, jsx_runtime_1.jsx)("span", __assign({ style: style.guideline }, { children: tutorialGuideline !== null && tutorialGuideline !== void 0 ? tutorialGuideline : t('photo.hud.sightTutorial.defaultTutorial') })) })), tutorialImage && ((0, jsx_runtime_1.jsx)("div", __assign({ style: PhotoCaptureHUDSightTutorial_styles_1.styles['imageContainer'] }, { children: (0, jsx_runtime_1.jsx)("img", { style: PhotoCaptureHUDSightTutorial_styles_1.styles['image'], src: tutorialImage, alt: selectedSight.id }) })))] })))] })));
64
+ }
65
+ exports.PhotoCaptureHUDSightTutorial = PhotoCaptureHUDSightTutorial;