@pose-tracker/pose-estimation-web 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -2
- package/dist/index.d.cts +34 -4
- package/dist/index.d.ts +34 -4
- package/dist/index.js +6 -2
- package/dist/pose-tracker.global.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var jsSha256 = require('js-sha256');
|
|
4
4
|
|
|
5
5
|
// src/version.ts
|
|
6
|
-
var SDK_VERSION = "0.3.
|
|
6
|
+
var SDK_VERSION = "0.3.4";
|
|
7
7
|
var SDK_NAME = "posetracker-web";
|
|
8
8
|
|
|
9
9
|
// src/api/configure.ts
|
|
@@ -624,7 +624,8 @@ var V4_ONLY_EXERCISE_IDS = [
|
|
|
624
624
|
"shoulder_roll",
|
|
625
625
|
"shoulder_deep_breath",
|
|
626
626
|
"chair_forward_fold",
|
|
627
|
-
"chair_side_stretch"
|
|
627
|
+
"chair_side_stretch",
|
|
628
|
+
"back_flexibility_test"
|
|
628
629
|
];
|
|
629
630
|
var PRODUCTION_SQUAT_IDS = ["squat", "face_squat"];
|
|
630
631
|
function isProductionSquatId(exerciseId) {
|
|
@@ -742,6 +743,7 @@ function toClassicNativeMessage(event) {
|
|
|
742
743
|
}
|
|
743
744
|
} : {},
|
|
744
745
|
...event.referenceScore != null ? { reference_score: { overallScore: event.referenceScore } } : {},
|
|
746
|
+
...event.analysis != null ? { analysis: event.analysis } : {},
|
|
745
747
|
timestampMs: event.timestampMs
|
|
746
748
|
};
|
|
747
749
|
case "posture":
|
|
@@ -783,6 +785,8 @@ function toClassicNativeMessage(event) {
|
|
|
783
785
|
grade: event.grade,
|
|
784
786
|
history: event.history,
|
|
785
787
|
durationMs: event.durationMs,
|
|
788
|
+
...event.disclaimer != null ? { disclaimer: event.disclaimer } : {},
|
|
789
|
+
...event.method != null ? { method: event.method } : {},
|
|
786
790
|
timestampMs: event.timestampMs
|
|
787
791
|
};
|
|
788
792
|
// Custom jump exercises: the classic contract already uses these exact
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _tensorflow_tfjs from '@tensorflow/tfjs';
|
|
2
2
|
|
|
3
3
|
/** Bumped with package.json version (keep in sync). */
|
|
4
|
-
declare const SDK_VERSION = "0.3.
|
|
4
|
+
declare const SDK_VERSION = "0.3.4";
|
|
5
5
|
declare const SDK_NAME: "posetracker-web";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -219,7 +219,7 @@ interface SdkManifest {
|
|
|
219
219
|
*/
|
|
220
220
|
type EngineChannel = 'v3' | 'v4';
|
|
221
221
|
/** Movements that exist only in the V4 catalog (not in V3 FSM / Strapi). */
|
|
222
|
-
declare const V4_ONLY_EXERCISE_IDS: readonly ["shoulder_roll", "shoulder_deep_breath", "chair_forward_fold", "chair_side_stretch"];
|
|
222
|
+
declare const V4_ONLY_EXERCISE_IDS: readonly ["shoulder_roll", "shoulder_deep_breath", "chair_forward_fold", "chair_side_stretch", "back_flexibility_test"];
|
|
223
223
|
declare const PRODUCTION_SQUAT_IDS: readonly ["squat", "face_squat"];
|
|
224
224
|
declare function isProductionSquatId(exerciseId?: string | null): boolean;
|
|
225
225
|
/** Handshake default is V4. Pass `'v3'` to force the V3 bundle. */
|
|
@@ -447,7 +447,7 @@ interface AnglesEvent {
|
|
|
447
447
|
* Letter grade for a 0–100 form score (GitBook / Front BaseExercise):
|
|
448
448
|
* A ≥ 90, B ≥ 80, C ≥ 70, D ≥ 60, F < 60.
|
|
449
449
|
*/
|
|
450
|
-
type FormGrade = 'A' | 'B' | 'C' | 'D' | 'F';
|
|
450
|
+
type FormGrade = 'A' | 'B' | 'C' | 'D' | 'E' | 'F';
|
|
451
451
|
/** Valid `minGrade` filter values (F is not a valid minGrade config). */
|
|
452
452
|
type MinGrade = 'A' | 'B' | 'C' | 'D';
|
|
453
453
|
/**
|
|
@@ -461,6 +461,30 @@ interface CounterFormScore {
|
|
|
461
461
|
average: number;
|
|
462
462
|
grade: FormGrade;
|
|
463
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Per-rep report for a physical test (back flexibility). Present only when the
|
|
466
|
+
* movement declares `report`. Disclaimer stays in this object, not in `interpretation.text`.
|
|
467
|
+
*/
|
|
468
|
+
interface MovementAnalysis {
|
|
469
|
+
opinion?: boolean;
|
|
470
|
+
method?: string;
|
|
471
|
+
disclaimer?: string;
|
|
472
|
+
peaks?: Record<string, number>;
|
|
473
|
+
camera?: {
|
|
474
|
+
placement?: string;
|
|
475
|
+
bias?: number;
|
|
476
|
+
ratio?: number;
|
|
477
|
+
};
|
|
478
|
+
ankle_above_sole?: number;
|
|
479
|
+
knee_locked?: boolean;
|
|
480
|
+
leg_straight?: boolean;
|
|
481
|
+
shank_vertical?: boolean;
|
|
482
|
+
interpretation?: {
|
|
483
|
+
tone: 'strong' | 'partial' | 'limited';
|
|
484
|
+
title: string;
|
|
485
|
+
text: string;
|
|
486
|
+
};
|
|
487
|
+
}
|
|
464
488
|
interface CounterEvent {
|
|
465
489
|
type: 'counter';
|
|
466
490
|
count: number;
|
|
@@ -472,6 +496,8 @@ interface CounterEvent {
|
|
|
472
496
|
formScore?: CounterFormScore;
|
|
473
497
|
/** Similarity score vs. reference movement for the last rep, when a reference is active. */
|
|
474
498
|
referenceScore?: number;
|
|
499
|
+
/** Physical-test report: peaks, camera, flags, interpretation, disclaimer. */
|
|
500
|
+
analysis?: MovementAnalysis;
|
|
475
501
|
timestampMs: number;
|
|
476
502
|
}
|
|
477
503
|
interface PostureEvent {
|
|
@@ -511,6 +537,7 @@ interface RepSummary {
|
|
|
511
537
|
formScore: number;
|
|
512
538
|
durationMs: number;
|
|
513
539
|
referenceScore?: number;
|
|
540
|
+
analysis?: MovementAnalysis;
|
|
514
541
|
}
|
|
515
542
|
interface ExerciseSummaryEvent {
|
|
516
543
|
type: 'exercise_summary';
|
|
@@ -521,6 +548,9 @@ interface ExerciseSummaryEvent {
|
|
|
521
548
|
grade: FormGrade;
|
|
522
549
|
history: RepSummary[];
|
|
523
550
|
durationMs: number;
|
|
551
|
+
/** Set when the movement emits a report. Kept out of interpretation text. */
|
|
552
|
+
disclaimer?: string;
|
|
553
|
+
method?: string;
|
|
524
554
|
timestampMs: number;
|
|
525
555
|
}
|
|
526
556
|
interface VisibleHipsInfo {
|
|
@@ -1487,4 +1517,4 @@ declare function findExerciseByIdOrAlias<T extends {
|
|
|
1487
1517
|
id: string;
|
|
1488
1518
|
}>(exerciseId: string, exercises: readonly T[]): T | undefined;
|
|
1489
1519
|
|
|
1490
|
-
export { type AccelerationDiagnostics, type AccelerationState, type AngleValue, type AnglesEvent, BRAND_COLORS, BlazePoseAdapter, type BlazePoseModelType, COCO_KEYPOINT_NAMES, COMBINED_REFERENCE_EXERCISE_MESSAGE, type CameraFacingMode, type CameraOptions, type CameraPoseSource, type ClassicMessageListener, type ClassicNativeMessage, type CocoKeypointName, type ColdStartMode, ConfigureError, type ConfigureOptions, type ConfigureRequest, type CounterEvent, type CounterFormScore, type CustomExerciseDescriptor, type CustomSessionOptions, DEFAULT_BASE_URL, DEFAULT_FEATURES, DEFAULT_LOADING_TEXT, DEFAULT_MOVENET_LIGHTNING_URL, DEFAULT_SKELETON, DEFAULT_SKELETON_DEFINITION, type DetectorFrameResult, type DiagnosticListener, EXERCISE_ALIASES, type EngineBundleDescriptor, type EngineChannel, type EngineLoadResult, EngineLoader, type EngineLoaderOptions, type EngineSession, type EngineSessionFeatures, type EngineSessionOptions, type ErrorEvent, type EventSink, type ExerciseConfig, type ExerciseSummaryEvent, FREE_PLAN_FEATURES_MESSAGE, type FetchSkeletonOptions, type FileStore, type FormGrade, type FormScoreEvent, INVALID_TOKEN_MESSAGE, type ImagePoseSource, type InferenceRuntime, type InitialPosture, type InitializationEvent, type InitializationStep, type JumpCalibrationEvent, type JumpDiscardedEvent, type JumpHeightEvent, type JumpResultEvent, type JumpStartedEvent, type JumpSummaryEntry, type JumpSummaryEvent, type KeyValueStore, type Keypoint, type KeypointName, type KeypointsEvent, type MinGrade, type ModelDescriptor, type ModelFormat, type ModelsByProfile, MoveNetGraphAdapter, type MovementDefinition, type MovementRecommendation, type MovementStep, type MovementStepParameter, ONLINE_POSE_DETECTION_VERSION, ONLINE_TFJS_VERSION, POSETRACKER_LOGO_URL, PRODUCTION_SQUAT_IDS, type PerformanceWarningEvent, type PlanInfo, type Pose, PoseCamera, PoseCamera_mount, type PoseDetectionModule, type PoseDetectorAdapter, type PoseEstimateInput, type PoseModelAlias, type PoseModelKind, type PoseModelProfile, type PoseRuntimeDescriptor, type PoseRuntimePartDescriptor, type PoseSource, type PoseSourceProps, type PoseSourceType, type PoseTracker, type PoseTrackerCallbacks, PoseTrackerClient, type PoseTrackerClientOptions, type PoseTrackerEngine, type PoseTrackerEvent, type PoseTrackerEventListener, type PoseTrackerEventType, type PoseTrackerFeatures, type PoseTrackerMode, type PoseTrackerOptions, type PoseTrackerStatus, type PostureEvent, type PreloadOptions, type ProgressionEvent, type QualityChangedEvent, type RecommendationsEvent, type ReferenceMovementDescriptor, type RepSummary, type ResolvePoseModelOptions, type ResolvedFeatures, type ResolvedPoseModel, type RuntimeDownloadProgressEvent, SDK_NAME, SDK_VERSION, type SdkManifest, type SkeletonAnglesStyle, type SkeletonCirclesStyle, type SkeletonDefinition, SkeletonFetchError, type SkeletonLinesStyle, type StartExerciseOptions, type StatsEvent, type TfModule, type TfjsCdnUrls, TrackError, type TrackRequest, type TrackResponse, UsageTracker, type UsageTrackerOptions, V4_ONLY_EXERCISE_IDS, type VideoPoseSource, type VisibleHipsInfo, type WarningEvent, configure, createLocalFileStore, createLocalKeyValueStore, createMemoryFileStore, createPoseAdapter, createPoseTracker, createWebFileStore, defaultPoseDetectionCdnUrl, defaultTfjsCdnUrls, drawSkeleton, featureNotSupportedMessage, fetchSkeletonDefinition, findExerciseByIdOrAlias, freeBlockedFeatures, initWebGlBackend, isPaidPlan, isProductionSquatId, mapVideoKeypointsToDisplay, mountDomShell, normalizeEngineChannel, normalizePoseSource, openCameraStream, requiresEngineV4, resolveExerciseName, resolveFeatures, resolveMovementEngine, resolvePoseDetection, resolvePoseModel, resolveTf, shouldShowWatermark, stopMediaStream, toClassicNativeMessage };
|
|
1520
|
+
export { type AccelerationDiagnostics, type AccelerationState, type AngleValue, type AnglesEvent, BRAND_COLORS, BlazePoseAdapter, type BlazePoseModelType, COCO_KEYPOINT_NAMES, COMBINED_REFERENCE_EXERCISE_MESSAGE, type CameraFacingMode, type CameraOptions, type CameraPoseSource, type ClassicMessageListener, type ClassicNativeMessage, type CocoKeypointName, type ColdStartMode, ConfigureError, type ConfigureOptions, type ConfigureRequest, type CounterEvent, type CounterFormScore, type CustomExerciseDescriptor, type CustomSessionOptions, DEFAULT_BASE_URL, DEFAULT_FEATURES, DEFAULT_LOADING_TEXT, DEFAULT_MOVENET_LIGHTNING_URL, DEFAULT_SKELETON, DEFAULT_SKELETON_DEFINITION, type DetectorFrameResult, type DiagnosticListener, EXERCISE_ALIASES, type EngineBundleDescriptor, type EngineChannel, type EngineLoadResult, EngineLoader, type EngineLoaderOptions, type EngineSession, type EngineSessionFeatures, type EngineSessionOptions, type ErrorEvent, type EventSink, type ExerciseConfig, type ExerciseSummaryEvent, FREE_PLAN_FEATURES_MESSAGE, type FetchSkeletonOptions, type FileStore, type FormGrade, type FormScoreEvent, INVALID_TOKEN_MESSAGE, type ImagePoseSource, type InferenceRuntime, type InitialPosture, type InitializationEvent, type InitializationStep, type JumpCalibrationEvent, type JumpDiscardedEvent, type JumpHeightEvent, type JumpResultEvent, type JumpStartedEvent, type JumpSummaryEntry, type JumpSummaryEvent, type KeyValueStore, type Keypoint, type KeypointName, type KeypointsEvent, type MinGrade, type ModelDescriptor, type ModelFormat, type ModelsByProfile, MoveNetGraphAdapter, type MovementAnalysis, type MovementDefinition, type MovementRecommendation, type MovementStep, type MovementStepParameter, ONLINE_POSE_DETECTION_VERSION, ONLINE_TFJS_VERSION, POSETRACKER_LOGO_URL, PRODUCTION_SQUAT_IDS, type PerformanceWarningEvent, type PlanInfo, type Pose, PoseCamera, PoseCamera_mount, type PoseDetectionModule, type PoseDetectorAdapter, type PoseEstimateInput, type PoseModelAlias, type PoseModelKind, type PoseModelProfile, type PoseRuntimeDescriptor, type PoseRuntimePartDescriptor, type PoseSource, type PoseSourceProps, type PoseSourceType, type PoseTracker, type PoseTrackerCallbacks, PoseTrackerClient, type PoseTrackerClientOptions, type PoseTrackerEngine, type PoseTrackerEvent, type PoseTrackerEventListener, type PoseTrackerEventType, type PoseTrackerFeatures, type PoseTrackerMode, type PoseTrackerOptions, type PoseTrackerStatus, type PostureEvent, type PreloadOptions, type ProgressionEvent, type QualityChangedEvent, type RecommendationsEvent, type ReferenceMovementDescriptor, type RepSummary, type ResolvePoseModelOptions, type ResolvedFeatures, type ResolvedPoseModel, type RuntimeDownloadProgressEvent, SDK_NAME, SDK_VERSION, type SdkManifest, type SkeletonAnglesStyle, type SkeletonCirclesStyle, type SkeletonDefinition, SkeletonFetchError, type SkeletonLinesStyle, type StartExerciseOptions, type StatsEvent, type TfModule, type TfjsCdnUrls, TrackError, type TrackRequest, type TrackResponse, UsageTracker, type UsageTrackerOptions, V4_ONLY_EXERCISE_IDS, type VideoPoseSource, type VisibleHipsInfo, type WarningEvent, configure, createLocalFileStore, createLocalKeyValueStore, createMemoryFileStore, createPoseAdapter, createPoseTracker, createWebFileStore, defaultPoseDetectionCdnUrl, defaultTfjsCdnUrls, drawSkeleton, featureNotSupportedMessage, fetchSkeletonDefinition, findExerciseByIdOrAlias, freeBlockedFeatures, initWebGlBackend, isPaidPlan, isProductionSquatId, mapVideoKeypointsToDisplay, mountDomShell, normalizeEngineChannel, normalizePoseSource, openCameraStream, requiresEngineV4, resolveExerciseName, resolveFeatures, resolveMovementEngine, resolvePoseDetection, resolvePoseModel, resolveTf, shouldShowWatermark, stopMediaStream, toClassicNativeMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _tensorflow_tfjs from '@tensorflow/tfjs';
|
|
2
2
|
|
|
3
3
|
/** Bumped with package.json version (keep in sync). */
|
|
4
|
-
declare const SDK_VERSION = "0.3.
|
|
4
|
+
declare const SDK_VERSION = "0.3.4";
|
|
5
5
|
declare const SDK_NAME: "posetracker-web";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -219,7 +219,7 @@ interface SdkManifest {
|
|
|
219
219
|
*/
|
|
220
220
|
type EngineChannel = 'v3' | 'v4';
|
|
221
221
|
/** Movements that exist only in the V4 catalog (not in V3 FSM / Strapi). */
|
|
222
|
-
declare const V4_ONLY_EXERCISE_IDS: readonly ["shoulder_roll", "shoulder_deep_breath", "chair_forward_fold", "chair_side_stretch"];
|
|
222
|
+
declare const V4_ONLY_EXERCISE_IDS: readonly ["shoulder_roll", "shoulder_deep_breath", "chair_forward_fold", "chair_side_stretch", "back_flexibility_test"];
|
|
223
223
|
declare const PRODUCTION_SQUAT_IDS: readonly ["squat", "face_squat"];
|
|
224
224
|
declare function isProductionSquatId(exerciseId?: string | null): boolean;
|
|
225
225
|
/** Handshake default is V4. Pass `'v3'` to force the V3 bundle. */
|
|
@@ -447,7 +447,7 @@ interface AnglesEvent {
|
|
|
447
447
|
* Letter grade for a 0–100 form score (GitBook / Front BaseExercise):
|
|
448
448
|
* A ≥ 90, B ≥ 80, C ≥ 70, D ≥ 60, F < 60.
|
|
449
449
|
*/
|
|
450
|
-
type FormGrade = 'A' | 'B' | 'C' | 'D' | 'F';
|
|
450
|
+
type FormGrade = 'A' | 'B' | 'C' | 'D' | 'E' | 'F';
|
|
451
451
|
/** Valid `minGrade` filter values (F is not a valid minGrade config). */
|
|
452
452
|
type MinGrade = 'A' | 'B' | 'C' | 'D';
|
|
453
453
|
/**
|
|
@@ -461,6 +461,30 @@ interface CounterFormScore {
|
|
|
461
461
|
average: number;
|
|
462
462
|
grade: FormGrade;
|
|
463
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Per-rep report for a physical test (back flexibility). Present only when the
|
|
466
|
+
* movement declares `report`. Disclaimer stays in this object, not in `interpretation.text`.
|
|
467
|
+
*/
|
|
468
|
+
interface MovementAnalysis {
|
|
469
|
+
opinion?: boolean;
|
|
470
|
+
method?: string;
|
|
471
|
+
disclaimer?: string;
|
|
472
|
+
peaks?: Record<string, number>;
|
|
473
|
+
camera?: {
|
|
474
|
+
placement?: string;
|
|
475
|
+
bias?: number;
|
|
476
|
+
ratio?: number;
|
|
477
|
+
};
|
|
478
|
+
ankle_above_sole?: number;
|
|
479
|
+
knee_locked?: boolean;
|
|
480
|
+
leg_straight?: boolean;
|
|
481
|
+
shank_vertical?: boolean;
|
|
482
|
+
interpretation?: {
|
|
483
|
+
tone: 'strong' | 'partial' | 'limited';
|
|
484
|
+
title: string;
|
|
485
|
+
text: string;
|
|
486
|
+
};
|
|
487
|
+
}
|
|
464
488
|
interface CounterEvent {
|
|
465
489
|
type: 'counter';
|
|
466
490
|
count: number;
|
|
@@ -472,6 +496,8 @@ interface CounterEvent {
|
|
|
472
496
|
formScore?: CounterFormScore;
|
|
473
497
|
/** Similarity score vs. reference movement for the last rep, when a reference is active. */
|
|
474
498
|
referenceScore?: number;
|
|
499
|
+
/** Physical-test report: peaks, camera, flags, interpretation, disclaimer. */
|
|
500
|
+
analysis?: MovementAnalysis;
|
|
475
501
|
timestampMs: number;
|
|
476
502
|
}
|
|
477
503
|
interface PostureEvent {
|
|
@@ -511,6 +537,7 @@ interface RepSummary {
|
|
|
511
537
|
formScore: number;
|
|
512
538
|
durationMs: number;
|
|
513
539
|
referenceScore?: number;
|
|
540
|
+
analysis?: MovementAnalysis;
|
|
514
541
|
}
|
|
515
542
|
interface ExerciseSummaryEvent {
|
|
516
543
|
type: 'exercise_summary';
|
|
@@ -521,6 +548,9 @@ interface ExerciseSummaryEvent {
|
|
|
521
548
|
grade: FormGrade;
|
|
522
549
|
history: RepSummary[];
|
|
523
550
|
durationMs: number;
|
|
551
|
+
/** Set when the movement emits a report. Kept out of interpretation text. */
|
|
552
|
+
disclaimer?: string;
|
|
553
|
+
method?: string;
|
|
524
554
|
timestampMs: number;
|
|
525
555
|
}
|
|
526
556
|
interface VisibleHipsInfo {
|
|
@@ -1487,4 +1517,4 @@ declare function findExerciseByIdOrAlias<T extends {
|
|
|
1487
1517
|
id: string;
|
|
1488
1518
|
}>(exerciseId: string, exercises: readonly T[]): T | undefined;
|
|
1489
1519
|
|
|
1490
|
-
export { type AccelerationDiagnostics, type AccelerationState, type AngleValue, type AnglesEvent, BRAND_COLORS, BlazePoseAdapter, type BlazePoseModelType, COCO_KEYPOINT_NAMES, COMBINED_REFERENCE_EXERCISE_MESSAGE, type CameraFacingMode, type CameraOptions, type CameraPoseSource, type ClassicMessageListener, type ClassicNativeMessage, type CocoKeypointName, type ColdStartMode, ConfigureError, type ConfigureOptions, type ConfigureRequest, type CounterEvent, type CounterFormScore, type CustomExerciseDescriptor, type CustomSessionOptions, DEFAULT_BASE_URL, DEFAULT_FEATURES, DEFAULT_LOADING_TEXT, DEFAULT_MOVENET_LIGHTNING_URL, DEFAULT_SKELETON, DEFAULT_SKELETON_DEFINITION, type DetectorFrameResult, type DiagnosticListener, EXERCISE_ALIASES, type EngineBundleDescriptor, type EngineChannel, type EngineLoadResult, EngineLoader, type EngineLoaderOptions, type EngineSession, type EngineSessionFeatures, type EngineSessionOptions, type ErrorEvent, type EventSink, type ExerciseConfig, type ExerciseSummaryEvent, FREE_PLAN_FEATURES_MESSAGE, type FetchSkeletonOptions, type FileStore, type FormGrade, type FormScoreEvent, INVALID_TOKEN_MESSAGE, type ImagePoseSource, type InferenceRuntime, type InitialPosture, type InitializationEvent, type InitializationStep, type JumpCalibrationEvent, type JumpDiscardedEvent, type JumpHeightEvent, type JumpResultEvent, type JumpStartedEvent, type JumpSummaryEntry, type JumpSummaryEvent, type KeyValueStore, type Keypoint, type KeypointName, type KeypointsEvent, type MinGrade, type ModelDescriptor, type ModelFormat, type ModelsByProfile, MoveNetGraphAdapter, type MovementDefinition, type MovementRecommendation, type MovementStep, type MovementStepParameter, ONLINE_POSE_DETECTION_VERSION, ONLINE_TFJS_VERSION, POSETRACKER_LOGO_URL, PRODUCTION_SQUAT_IDS, type PerformanceWarningEvent, type PlanInfo, type Pose, PoseCamera, PoseCamera_mount, type PoseDetectionModule, type PoseDetectorAdapter, type PoseEstimateInput, type PoseModelAlias, type PoseModelKind, type PoseModelProfile, type PoseRuntimeDescriptor, type PoseRuntimePartDescriptor, type PoseSource, type PoseSourceProps, type PoseSourceType, type PoseTracker, type PoseTrackerCallbacks, PoseTrackerClient, type PoseTrackerClientOptions, type PoseTrackerEngine, type PoseTrackerEvent, type PoseTrackerEventListener, type PoseTrackerEventType, type PoseTrackerFeatures, type PoseTrackerMode, type PoseTrackerOptions, type PoseTrackerStatus, type PostureEvent, type PreloadOptions, type ProgressionEvent, type QualityChangedEvent, type RecommendationsEvent, type ReferenceMovementDescriptor, type RepSummary, type ResolvePoseModelOptions, type ResolvedFeatures, type ResolvedPoseModel, type RuntimeDownloadProgressEvent, SDK_NAME, SDK_VERSION, type SdkManifest, type SkeletonAnglesStyle, type SkeletonCirclesStyle, type SkeletonDefinition, SkeletonFetchError, type SkeletonLinesStyle, type StartExerciseOptions, type StatsEvent, type TfModule, type TfjsCdnUrls, TrackError, type TrackRequest, type TrackResponse, UsageTracker, type UsageTrackerOptions, V4_ONLY_EXERCISE_IDS, type VideoPoseSource, type VisibleHipsInfo, type WarningEvent, configure, createLocalFileStore, createLocalKeyValueStore, createMemoryFileStore, createPoseAdapter, createPoseTracker, createWebFileStore, defaultPoseDetectionCdnUrl, defaultTfjsCdnUrls, drawSkeleton, featureNotSupportedMessage, fetchSkeletonDefinition, findExerciseByIdOrAlias, freeBlockedFeatures, initWebGlBackend, isPaidPlan, isProductionSquatId, mapVideoKeypointsToDisplay, mountDomShell, normalizeEngineChannel, normalizePoseSource, openCameraStream, requiresEngineV4, resolveExerciseName, resolveFeatures, resolveMovementEngine, resolvePoseDetection, resolvePoseModel, resolveTf, shouldShowWatermark, stopMediaStream, toClassicNativeMessage };
|
|
1520
|
+
export { type AccelerationDiagnostics, type AccelerationState, type AngleValue, type AnglesEvent, BRAND_COLORS, BlazePoseAdapter, type BlazePoseModelType, COCO_KEYPOINT_NAMES, COMBINED_REFERENCE_EXERCISE_MESSAGE, type CameraFacingMode, type CameraOptions, type CameraPoseSource, type ClassicMessageListener, type ClassicNativeMessage, type CocoKeypointName, type ColdStartMode, ConfigureError, type ConfigureOptions, type ConfigureRequest, type CounterEvent, type CounterFormScore, type CustomExerciseDescriptor, type CustomSessionOptions, DEFAULT_BASE_URL, DEFAULT_FEATURES, DEFAULT_LOADING_TEXT, DEFAULT_MOVENET_LIGHTNING_URL, DEFAULT_SKELETON, DEFAULT_SKELETON_DEFINITION, type DetectorFrameResult, type DiagnosticListener, EXERCISE_ALIASES, type EngineBundleDescriptor, type EngineChannel, type EngineLoadResult, EngineLoader, type EngineLoaderOptions, type EngineSession, type EngineSessionFeatures, type EngineSessionOptions, type ErrorEvent, type EventSink, type ExerciseConfig, type ExerciseSummaryEvent, FREE_PLAN_FEATURES_MESSAGE, type FetchSkeletonOptions, type FileStore, type FormGrade, type FormScoreEvent, INVALID_TOKEN_MESSAGE, type ImagePoseSource, type InferenceRuntime, type InitialPosture, type InitializationEvent, type InitializationStep, type JumpCalibrationEvent, type JumpDiscardedEvent, type JumpHeightEvent, type JumpResultEvent, type JumpStartedEvent, type JumpSummaryEntry, type JumpSummaryEvent, type KeyValueStore, type Keypoint, type KeypointName, type KeypointsEvent, type MinGrade, type ModelDescriptor, type ModelFormat, type ModelsByProfile, MoveNetGraphAdapter, type MovementAnalysis, type MovementDefinition, type MovementRecommendation, type MovementStep, type MovementStepParameter, ONLINE_POSE_DETECTION_VERSION, ONLINE_TFJS_VERSION, POSETRACKER_LOGO_URL, PRODUCTION_SQUAT_IDS, type PerformanceWarningEvent, type PlanInfo, type Pose, PoseCamera, PoseCamera_mount, type PoseDetectionModule, type PoseDetectorAdapter, type PoseEstimateInput, type PoseModelAlias, type PoseModelKind, type PoseModelProfile, type PoseRuntimeDescriptor, type PoseRuntimePartDescriptor, type PoseSource, type PoseSourceProps, type PoseSourceType, type PoseTracker, type PoseTrackerCallbacks, PoseTrackerClient, type PoseTrackerClientOptions, type PoseTrackerEngine, type PoseTrackerEvent, type PoseTrackerEventListener, type PoseTrackerEventType, type PoseTrackerFeatures, type PoseTrackerMode, type PoseTrackerOptions, type PoseTrackerStatus, type PostureEvent, type PreloadOptions, type ProgressionEvent, type QualityChangedEvent, type RecommendationsEvent, type ReferenceMovementDescriptor, type RepSummary, type ResolvePoseModelOptions, type ResolvedFeatures, type ResolvedPoseModel, type RuntimeDownloadProgressEvent, SDK_NAME, SDK_VERSION, type SdkManifest, type SkeletonAnglesStyle, type SkeletonCirclesStyle, type SkeletonDefinition, SkeletonFetchError, type SkeletonLinesStyle, type StartExerciseOptions, type StatsEvent, type TfModule, type TfjsCdnUrls, TrackError, type TrackRequest, type TrackResponse, UsageTracker, type UsageTrackerOptions, V4_ONLY_EXERCISE_IDS, type VideoPoseSource, type VisibleHipsInfo, type WarningEvent, configure, createLocalFileStore, createLocalKeyValueStore, createMemoryFileStore, createPoseAdapter, createPoseTracker, createWebFileStore, defaultPoseDetectionCdnUrl, defaultTfjsCdnUrls, drawSkeleton, featureNotSupportedMessage, fetchSkeletonDefinition, findExerciseByIdOrAlias, freeBlockedFeatures, initWebGlBackend, isPaidPlan, isProductionSquatId, mapVideoKeypointsToDisplay, mountDomShell, normalizeEngineChannel, normalizePoseSource, openCameraStream, requiresEngineV4, resolveExerciseName, resolveFeatures, resolveMovementEngine, resolvePoseDetection, resolvePoseModel, resolveTf, shouldShowWatermark, stopMediaStream, toClassicNativeMessage };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sha256 } from 'js-sha256';
|
|
2
2
|
|
|
3
3
|
// src/version.ts
|
|
4
|
-
var SDK_VERSION = "0.3.
|
|
4
|
+
var SDK_VERSION = "0.3.4";
|
|
5
5
|
var SDK_NAME = "posetracker-web";
|
|
6
6
|
|
|
7
7
|
// src/api/configure.ts
|
|
@@ -622,7 +622,8 @@ var V4_ONLY_EXERCISE_IDS = [
|
|
|
622
622
|
"shoulder_roll",
|
|
623
623
|
"shoulder_deep_breath",
|
|
624
624
|
"chair_forward_fold",
|
|
625
|
-
"chair_side_stretch"
|
|
625
|
+
"chair_side_stretch",
|
|
626
|
+
"back_flexibility_test"
|
|
626
627
|
];
|
|
627
628
|
var PRODUCTION_SQUAT_IDS = ["squat", "face_squat"];
|
|
628
629
|
function isProductionSquatId(exerciseId) {
|
|
@@ -740,6 +741,7 @@ function toClassicNativeMessage(event) {
|
|
|
740
741
|
}
|
|
741
742
|
} : {},
|
|
742
743
|
...event.referenceScore != null ? { reference_score: { overallScore: event.referenceScore } } : {},
|
|
744
|
+
...event.analysis != null ? { analysis: event.analysis } : {},
|
|
743
745
|
timestampMs: event.timestampMs
|
|
744
746
|
};
|
|
745
747
|
case "posture":
|
|
@@ -781,6 +783,8 @@ function toClassicNativeMessage(event) {
|
|
|
781
783
|
grade: event.grade,
|
|
782
784
|
history: event.history,
|
|
783
785
|
durationMs: event.durationMs,
|
|
786
|
+
...event.disclaimer != null ? { disclaimer: event.disclaimer } : {},
|
|
787
|
+
...event.method != null ? { method: event.method } : {},
|
|
784
788
|
timestampMs: event.timestampMs
|
|
785
789
|
};
|
|
786
790
|
// Custom jump exercises: the classic contract already uses these exact
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var PoseTracker=(()=>{var Ft=Object.create;var me=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var dt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Rt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Dt=(t,e)=>{for(var r in e)me(t,r,{get:e[r],enumerable:!0})},ht=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of It(e))!At.call(t,i)&&i!==r&&me(t,i,{get:()=>e[i],enumerable:!(s=Ct(e,i))||s.enumerable});return t};var ut=(t,e,r)=>(r=t!=null?Ft(Lt(t)):{},ht(e||!t||!t.__esModule?me(r,"default",{value:t,enumerable:!0}):r,t)),Ot=t=>ht(me({},"__esModule",{value:!0}),t);var De=Rt((yr,fe)=>{"use strict";(function(){"use strict";var t="input is invalid type",e=typeof window=="object",r=e?window:{};r.JS_SHA256_NO_WINDOW&&(e=!1);var s=!e&&typeof self=="object",i=!r.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";i?r=global:s&&(r=self);var n=!r.JS_SHA256_NO_COMMON_JS&&typeof fe=="object"&&fe.exports,u=typeof define=="function"&&define.amd,p=!r.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",l="0123456789abcdef".split(""),x=[-2147483648,8388608,32768,128],v=[24,16,8,0],_=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],w=["hex","array","digest","arrayBuffer"],g=[];(r.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(o){return Object.prototype.toString.call(o)==="[object Array]"}),p&&(r.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(o){return typeof o=="object"&&o.buffer&&o.buffer.constructor===ArrayBuffer});var b=function(o,d){return function(f){return new k(d,!0).update(f)[o]()}},E=function(o){var d=b("hex",o);i&&(d=T(d,o)),d.create=function(){return new k(o)},d.update=function(m){return d.create().update(m)};for(var f=0;f<w.length;++f){var a=w[f];d[a]=b(a,o)}return d},T=function(o,d){var f=dt("crypto"),a=dt("buffer").Buffer,m=d?"sha224":"sha256",h;a.from&&!r.JS_SHA256_NO_BUFFER_FROM?h=a.from:h=function(c){return new a(c)};var y=function(c){if(typeof c=="string")return f.createHash(m).update(c,"utf8").digest("hex");if(c==null)throw new Error(t);return c.constructor===ArrayBuffer&&(c=new Uint8Array(c)),Array.isArray(c)||ArrayBuffer.isView(c)||c.constructor===a?f.createHash(m).update(h(c)).digest("hex"):o(c)};return y},C=function(o,d){return function(f,a){return new L(f,d,!0).update(a)[o]()}},F=function(o){var d=C("hex",o);d.create=function(m){return new L(m,o)},d.update=function(m,h){return d.create(m).update(h)};for(var f=0;f<w.length;++f){var a=w[f];d[a]=C(a,o)}return d};function k(o,d){d?(g[0]=g[16]=g[1]=g[2]=g[3]=g[4]=g[5]=g[6]=g[7]=g[8]=g[9]=g[10]=g[11]=g[12]=g[13]=g[14]=g[15]=0,this.blocks=g):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=o}k.prototype.update=function(o){if(!this.finalized){var d,f=typeof o;if(f!=="string"){if(f==="object"){if(o===null)throw new Error(t);if(p&&o.constructor===ArrayBuffer)o=new Uint8Array(o);else if(!Array.isArray(o)&&(!p||!ArrayBuffer.isView(o)))throw new Error(t)}else throw new Error(t);d=!0}for(var a,m=0,h,y=o.length,c=this.blocks;m<y;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,this.block=c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),d)for(h=this.start;m<y&&h<64;++m)c[h>>>2]|=o[m]<<v[h++&3];else for(h=this.start;m<y&&h<64;++m)a=o.charCodeAt(m),a<128?c[h>>>2]|=a<<v[h++&3]:a<2048?(c[h>>>2]|=(192|a>>>6)<<v[h++&3],c[h>>>2]|=(128|a&63)<<v[h++&3]):a<55296||a>=57344?(c[h>>>2]|=(224|a>>>12)<<v[h++&3],c[h>>>2]|=(128|a>>>6&63)<<v[h++&3],c[h>>>2]|=(128|a&63)<<v[h++&3]):(a=65536+((a&1023)<<10|o.charCodeAt(++m)&1023),c[h>>>2]|=(240|a>>>18)<<v[h++&3],c[h>>>2]|=(128|a>>>12&63)<<v[h++&3],c[h>>>2]|=(128|a>>>6&63)<<v[h++&3],c[h>>>2]|=(128|a&63)<<v[h++&3]);this.lastByteIndex=h,this.bytes+=h-this.start,h>=64?(this.block=c[16],this.start=h-64,this.hash(),this.hashed=!0):this.start=h}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},k.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var o=this.blocks,d=this.lastByteIndex;o[16]=this.block,o[d>>>2]|=x[d&3],this.block=o[16],d>=56&&(this.hashed||this.hash(),o[0]=this.block,o[16]=o[1]=o[2]=o[3]=o[4]=o[5]=o[6]=o[7]=o[8]=o[9]=o[10]=o[11]=o[12]=o[13]=o[14]=o[15]=0),o[14]=this.hBytes<<3|this.bytes>>>29,o[15]=this.bytes<<3,this.hash()}},k.prototype.hash=function(){var o=this.h0,d=this.h1,f=this.h2,a=this.h3,m=this.h4,h=this.h5,y=this.h6,c=this.h7,S=this.blocks,P,R,D,H,M,B,V,Y,Ae,Re,pe;for(P=16;P<64;++P)M=S[P-15],R=(M>>>7|M<<25)^(M>>>18|M<<14)^M>>>3,M=S[P-2],D=(M>>>17|M<<15)^(M>>>19|M<<13)^M>>>10,S[P]=S[P-16]+R+S[P-7]+D<<0;for(pe=d&f,P=0;P<64;P+=4)this.first?(this.is224?(Y=300032,M=S[0]-1413257819,c=M-150054599<<0,a=M+24177077<<0):(Y=704751109,M=S[0]-210244248,c=M-1521486534<<0,a=M+143694565<<0),this.first=!1):(R=(o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10),D=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),Y=o&d,H=Y^o&f^pe,V=m&h^~m&y,M=c+D+V+_[P]+S[P],B=R+H,c=a+M<<0,a=M+B<<0),R=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),D=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),Ae=a&o,H=Ae^a&d^Y,V=c&m^~c&h,M=y+D+V+_[P+1]+S[P+1],B=R+H,y=f+M<<0,f=M+B<<0,R=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),D=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),Re=f&a,H=Re^f&o^Ae,V=y&c^~y&m,M=h+D+V+_[P+2]+S[P+2],B=R+H,h=d+M<<0,d=M+B<<0,R=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),D=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),pe=d&f,H=pe^d&a^Re,V=h&y^~h&c,M=m+D+V+_[P+3]+S[P+3],B=R+H,m=o+M<<0,o=M+B<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+o<<0,this.h1=this.h1+d<<0,this.h2=this.h2+f<<0,this.h3=this.h3+a<<0,this.h4=this.h4+m<<0,this.h5=this.h5+h<<0,this.h6=this.h6+y<<0,this.h7=this.h7+c<<0},k.prototype.hex=function(){this.finalize();var o=this.h0,d=this.h1,f=this.h2,a=this.h3,m=this.h4,h=this.h5,y=this.h6,c=this.h7,S=l[o>>>28&15]+l[o>>>24&15]+l[o>>>20&15]+l[o>>>16&15]+l[o>>>12&15]+l[o>>>8&15]+l[o>>>4&15]+l[o&15]+l[d>>>28&15]+l[d>>>24&15]+l[d>>>20&15]+l[d>>>16&15]+l[d>>>12&15]+l[d>>>8&15]+l[d>>>4&15]+l[d&15]+l[f>>>28&15]+l[f>>>24&15]+l[f>>>20&15]+l[f>>>16&15]+l[f>>>12&15]+l[f>>>8&15]+l[f>>>4&15]+l[f&15]+l[a>>>28&15]+l[a>>>24&15]+l[a>>>20&15]+l[a>>>16&15]+l[a>>>12&15]+l[a>>>8&15]+l[a>>>4&15]+l[a&15]+l[m>>>28&15]+l[m>>>24&15]+l[m>>>20&15]+l[m>>>16&15]+l[m>>>12&15]+l[m>>>8&15]+l[m>>>4&15]+l[m&15]+l[h>>>28&15]+l[h>>>24&15]+l[h>>>20&15]+l[h>>>16&15]+l[h>>>12&15]+l[h>>>8&15]+l[h>>>4&15]+l[h&15]+l[y>>>28&15]+l[y>>>24&15]+l[y>>>20&15]+l[y>>>16&15]+l[y>>>12&15]+l[y>>>8&15]+l[y>>>4&15]+l[y&15];return this.is224||(S+=l[c>>>28&15]+l[c>>>24&15]+l[c>>>20&15]+l[c>>>16&15]+l[c>>>12&15]+l[c>>>8&15]+l[c>>>4&15]+l[c&15]),S},k.prototype.toString=k.prototype.hex,k.prototype.digest=function(){this.finalize();var o=this.h0,d=this.h1,f=this.h2,a=this.h3,m=this.h4,h=this.h5,y=this.h6,c=this.h7,S=[o>>>24&255,o>>>16&255,o>>>8&255,o&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,y>>>24&255,y>>>16&255,y>>>8&255,y&255];return this.is224||S.push(c>>>24&255,c>>>16&255,c>>>8&255,c&255),S},k.prototype.array=k.prototype.digest,k.prototype.arrayBuffer=function(){this.finalize();var o=new ArrayBuffer(this.is224?28:32),d=new DataView(o);return d.setUint32(0,this.h0),d.setUint32(4,this.h1),d.setUint32(8,this.h2),d.setUint32(12,this.h3),d.setUint32(16,this.h4),d.setUint32(20,this.h5),d.setUint32(24,this.h6),this.is224||d.setUint32(28,this.h7),o};function L(o,d,f){var a,m=typeof o;if(m==="string"){var h=[],y=o.length,c=0,S;for(a=0;a<y;++a)S=o.charCodeAt(a),S<128?h[c++]=S:S<2048?(h[c++]=192|S>>>6,h[c++]=128|S&63):S<55296||S>=57344?(h[c++]=224|S>>>12,h[c++]=128|S>>>6&63,h[c++]=128|S&63):(S=65536+((S&1023)<<10|o.charCodeAt(++a)&1023),h[c++]=240|S>>>18,h[c++]=128|S>>>12&63,h[c++]=128|S>>>6&63,h[c++]=128|S&63);o=h}else if(m==="object"){if(o===null)throw new Error(t);if(p&&o.constructor===ArrayBuffer)o=new Uint8Array(o);else if(!Array.isArray(o)&&(!p||!ArrayBuffer.isView(o)))throw new Error(t)}else throw new Error(t);o.length>64&&(o=new k(d,!0).update(o).array());var P=[],R=[];for(a=0;a<64;++a){var D=o[a]||0;P[a]=92^D,R[a]=54^D}k.call(this,d,f),this.update(R),this.oKeyPad=P,this.inner=!0,this.sharedMemory=f}L.prototype=new k,L.prototype.finalize=function(){if(k.prototype.finalize.call(this),this.inner){this.inner=!1;var o=this.array();k.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(o),k.prototype.finalize.call(this)}};var I=E();I.sha256=I,I.sha224=E(!0),I.sha256.hmac=F(),I.sha224.hmac=F(!0),n?fe.exports=I:(r.sha256=I.sha256,r.sha224=I.sha224,u&&define(function(){return I}))})()});var ur={};Dt(ur,{COCO_KEYPOINT_NAMES:()=>N,DEFAULT_MOVENET_LIGHTNING_URL:()=>Me,ONLINE_TFJS_VERSION:()=>be,PoseCamera:()=>ct,SDK_NAME:()=>X,SDK_VERSION:()=>K,configure:()=>G,createPoseTracker:()=>Le,defaultTfjsCdnUrls:()=>Je,resolvePoseModel:()=>z,shouldShowWatermark:()=>ue});var K="0.3.1",X="posetracker-web";var q="https://movelytics-strapi-c78a339b7070.herokuapp.com",U=class extends Error{constructor(r,s){super(s);this.code=r;this.name="ConfigureError"}};async function G(t,e={}){let r=(e.baseUrl??q).replace(/\/$/,""),s={...t?{apiToken:t}:{},sdkName:X,sdkVersion:K,targetPlatform:"web",poseModelProfile:e.poseModelProfile??"AdaptiveChoice",locale:e.locale,localVersions:e.localVersions,engineChannel:e.engine==="v3"?"v3":"v4"},i;try{i=await fetch(`${r}/api/sdk/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch(n){throw new U("network",`Handshake request failed: ${String(n)}`)}if(i.status===401||i.status===403)throw new U("invalid_token","Invalid, revoked or unauthorized API token.");if(i.status===429)throw new U("quota_exceeded","API call quota exceeded for the current plan.");if(!i.ok)throw new U("internal",`Handshake failed with HTTP ${i.status}.`);return await i.json()}var Be=ut(De(),1);var Ue=ut(De(),1),Oe="ptc1:";function Ne(t){return(0,Ue.sha256)(`posetracker-sdk-cache:${t}`)}function Ut(t){let e=unescape(encodeURIComponent(t)),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r}function Nt(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return decodeURIComponent(escape(e))}function Ht(t){let e="";for(let r=0;r<t.length;r++)e+=t[r].toString(16).padStart(2,"0");return e}function Bt(t){if(t.length%2!==0||/[^0-9a-f]/.test(t))return null;let e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++)e[r]=parseInt(t.slice(r*2,r*2+2),16);return e}function pt(t,e){let r=new Uint8Array(t.length),s=0,i=0;for(;i<t.length;){let n=Ue.sha256.array(`${e}:${s++}`);for(let u=0;u<n.length&&i<t.length;u++,i++)r[i]=t[i]^n[u]}return r}function ge(t,e){return Oe+Ht(pt(Ut(t),e))}function ye(t,e){if(!t.startsWith(Oe))return null;let r=Bt(t.slice(Oe.length));if(!r)return null;try{return Nt(pt(r,e))}catch{return null}}var He="posetracker.web.";function Q(){return typeof localStorage>"u"?null:{async getItem(t){try{return localStorage.getItem(He+t)}catch{return null}},async setItem(t,e){try{localStorage.setItem(He+t,e)}catch{}},async removeItem(t){try{localStorage.removeItem(He+t)}catch{}}}}function ft(){let t=Q();return t?{read:e=>t.getItem(`file.${e}`),write:(e,r)=>t.setItem(`file.${e}`,r),remove:e=>t.removeItem(`file.${e}`)}:null}function gt(){let t=new Map;return{async read(e){return t.has(e)?t.get(e):null},async write(e,r){t.set(e,r)},async remove(e){t.delete(e)}}}function ve(){return ft()??gt()}var mt="posetracker.engine.guard.",J=class{constructor(e={}){this.lastError=null;this.files=e.fileStore!==void 0?e.fileStore:ve(),this.kv=e.keyValueStore!==void 0?e.keyValueStore:Q(),this.fetchFn=e.fetchFn??fetch,this.onDiagnostic=e.onDiagnostic,this.onDiagnostic?.(`[posetracker-web] EngineLoader fileStore=${this.files?"yes":"none"} kv=${this.kv?"localStorage":"none"}`)}async clearGuard(e){if(!e||!this.kv)return;let r=`${mt}${e.version}.${e.sha256}`;await this.kv.removeItem(r).catch(()=>{})}async load(e,r,s){if(this.lastError=null,!e)return this.lastError="manifest has no engine descriptor",null;let i=`${mt}${e.version}.${e.sha256}`;s?.forceRetry&&await this.kv?.removeItem(i).catch(()=>{});let n=await this.kv?.getItem(i);if(n==="probing"||n==="failed")return await this.kv?.setItem(i,"failed"),this.lastError=`engine crash-guard blocked version=${e.version} (state=${n}) \u2014 call configure() again to force retry`,this.onDiagnostic?.(`[posetracker-web] ${this.lastError}`),null;let u=`engine-${e.version}.sealed`,p=await this.files?.read(u);if(p!=null){let l=ye(p,r);if(l!==null&&(0,Be.sha256)(l)===e.sha256){let x=await this.evaluate(l,i);if(x)return this.onDiagnostic?.(`[posetracker-web] engine loaded from cache version=${e.version}`),{engine:x,source:"remote-cache"}}else this.onDiagnostic?.(`[posetracker-web] engine cache purged (unseal/integrity mismatch) key=${u}`),await this.files?.remove(u)}try{this.onDiagnostic?.(`[posetracker-web] downloading engine version=${e.version}\u2026`);let l=await this.fetchFn(e.signedUrl);if(!l.ok)throw new Error(`HTTP ${l.status}`);let x=await l.text(),v=(0,Be.sha256)(x);if(v!==e.sha256)throw new Error(`integrity check failed (got ${v.slice(0,12)}\u2026 expected ${e.sha256.slice(0,12)}\u2026, bytes=${x.length})`);let _=await this.evaluate(x,i);if(_){try{await this.files?.write(u,ge(x,r))}catch(w){this.onDiagnostic?.("[posetracker-web] engine cache write failed (non-fatal): "+(w instanceof Error?w.message:String(w)))}return this.onDiagnostic?.(`[posetracker-web] engine loaded from download version=${e.version} bytes=${x.length}`),{engine:_,source:"remote-download"}}}catch(l){this.lastError=l instanceof Error?l.message:String(l),this.onDiagnostic?.(`[posetracker-web] engine download/load failed: ${this.lastError}`)}return this.lastError||(this.lastError="engine evaluate returned null"),null}async evaluate(e,r){await this.kv?.setItem(r,"probing");try{let s={exports:{}};new Function("module","exports",e)(s,s.exports);let n=s.exports.createEngine;if(typeof n!="function")throw new Error(`engine bundle does not export createEngine() (got ${typeof n}, keys=${Object.keys(s.exports).join(",")})`);let u=n();return await this.kv?.setItem(r,"passed"),u}catch(s){return this.lastError="engine evaluate failed: "+(s instanceof Error?s.message:String(s)),this.onDiagnostic?.(`[posetracker-web] ${this.lastError}`),await this.kv?.setItem(r,"failed"),null}}};var Ve="posetracker.track.queue",Vt=100,O=class extends Error{constructor(r,s){super(s);this.code=r;this.name="TrackError"}},Z=class{constructor(e={}){this.baseUrl=(e.baseUrl??q).replace(/\/$/,""),this.kv=e.keyValueStore!==void 0?e.keyValueStore:Q(),this.fetchFn=e.fetchFn??fetch}async trackMetered(e){return this.post({event:e.event??"camera_start",apiToken:e.apiToken,platform:"web",sdkVersion:K,params:e.params})}async trackAnonymous(e={}){let r={event:e.event??"camera_start",platform:"web",sdkVersion:K,params:e.params,queuedAtMs:Date.now()};try{await this.post({...r}),this.flushQueue()}catch{await this.enqueue(r)}}async flushQueue(){let e=await this.readQueue();if(e.length===0)return;let r=[];for(let s of e)try{await this.post({...s,params:{...s.params??{},queuedAtMs:s.queuedAtMs}})}catch{r.push(s)}await this.writeQueue(r)}async post(e){let r;try{r=await this.fetchFn(`${this.baseUrl}/api/sdk/track`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(s){throw new O("network",`Usage tracking request failed: ${String(s)}`)}if(r.status===401||r.status===403)throw new O("invalid_token","Invalid, revoked or unauthorized API token.");if(r.status===429)throw new O("quota_exceeded","API call quota exceeded for the current plan.");if(!r.ok)throw new O("internal",`Usage tracking failed with HTTP ${r.status}.`);return await r.json()}async readQueue(){try{let e=await this.kv?.getItem(Ve);if(!e)return[];let r=JSON.parse(e);return Array.isArray(r)?r:[]}catch{return[]}}async writeQueue(e){try{e.length===0?await this.kv?.removeItem(Ve):await this.kv?.setItem(Ve,JSON.stringify(e.slice(-Vt)))}catch{}}async enqueue(e){let r=await this.readQueue();r.push(e),await this.writeQueue(r)}};var $=class extends Error{constructor(r,s){super(s);this.code=r;this.name="SkeletonFetchError"}};async function Ke(t,e={}){let r=t.trim();if(!r||r==="true"||r==="false")throw new $("invalid","skeleton uuid is required");let s=(e.baseUrl??q).replace(/\/$/,""),i;try{i=await fetch(`${s}/api/sdk/skeleton?uuid=${encodeURIComponent(r)}`)}catch(u){throw new $("network",`Skeleton fetch failed: ${String(u)}`)}if(i.status===404)throw new $("not_found",`Skeleton '${r}' not found`);if(!i.ok)throw new $("network",`Skeleton fetch HTTP ${i.status}`);let n=await i.json();if(!n?.keypoints||!n?.keypoint_lines||!n?.circles||!n?.lines)throw new $("invalid","Skeleton payload incomplete");return{keypoints:n.keypoints,keypoint_lines:n.keypoint_lines,keypoint_angles:n.keypoint_angles??[],circles:n.circles,lines:n.lines,angles:n.angles}}async function $e(t={}){if(typeof navigator>"u"||!navigator.mediaDevices?.getUserMedia)throw new Error("getUserMedia is not available in this environment");let e=t.facingMode??"user",r={audio:!1,video:{facingMode:e,width:t.idealWidth?{ideal:t.idealWidth}:void 0,height:t.idealHeight?{ideal:t.idealHeight}:void 0,frameRate:t.idealFrameRate?{ideal:t.idealFrameRate}:void 0}};try{return await navigator.mediaDevices.getUserMedia(r)}catch{return navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:e}})}}function We(t){if(t)for(let e of t.getTracks())try{e.stop()}catch{}}function ee(t){return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement}function yt(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement}function ze(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap}function te(t){return ze(t)?{width:t.width||0,height:t.height||0}:ee(t)?{width:t.videoWidth||0,height:t.videoHeight||0}:{width:t.naturalWidth||t.width||0,height:t.naturalHeight||t.height||0}}async function xe(t){if(typeof t=="string")return{url:t,revoke:()=>{}};let e=URL.createObjectURL(t);return{url:e,revoke:()=>{try{URL.revokeObjectURL(e)}catch{}}}}function je(t,e=15e3){return new Promise((r,s)=>{if(t.readyState>=2&&t.videoWidth>0){r();return}let i=()=>{p(),r()},n=()=>{p(),s(new Error("Failed to load video source"))},u=setTimeout(()=>{p(),s(new Error("Timed out waiting for video metadata"))},e),p=()=>{clearTimeout(u),t.removeEventListener("loadeddata",i),t.removeEventListener("error",n)};t.addEventListener("loadeddata",i),t.addEventListener("error",n)})}function we(t,e=15e3){return new Promise((r,s)=>{if(t.complete&&t.naturalWidth>0){r();return}if(t.complete){s(new Error("Image failed to decode (naturalWidth=0)"));return}let i=()=>{p(),r()},n=()=>{p(),s(new Error("Failed to load image source"))},u=setTimeout(()=>{p(),s(new Error("Timed out waiting for image"))},e),p=()=>{clearTimeout(u),t.removeEventListener("load",i),t.removeEventListener("error",n)};t.addEventListener("load",i),t.addEventListener("error",n)})}async function vt(t){let e=document.createElement("canvas");e.width=t.width,e.height=t.height;let r=e.getContext("2d");if(!r)throw new Error("2d context unavailable");r.drawImage(t,0,0);let s=await new Promise((i,n)=>{e.toBlob(u=>u?i(u):n(new Error("toBlob failed")),"image/png")});return xe(s)}function Ee(t,e){if(t&&typeof t=="object"&&"type"in t)return t;let r=t==="video"||t==="image"||t==="camera"?t:"camera";if(r==="camera")return{type:"camera",facingMode:e?.facingMode};let s=e?.sourceFile??e?.sourceUrl;if(!s)throw new Error(`PoseSource type "${r}" requires sourceUrl or sourceFile (or pass a full PoseSource object)`);return r==="video"?{type:"video",src:s}:{type:"image",src:s}}var qe={face_squat:"squat",face_pushup:"push_up",face_plank:"plank",face_lunge:"lunge",face_jumping_jack:"jumping_jack",face_low_impact_jack:"low_impact_jack",face_balance_leg:"balance_leg",face_balance_leg_left:"balance_leg_left",face_balance_leg_right:"balance_leg_right",jump:"air_time_jump"};function re(t){return qe[t]??t}function se(t,e){let r=e.find(n=>n.id===t);if(r)return r;let s=re(t),i=Object.entries(qe).filter(([,n])=>n===s).map(([n])=>n);for(let n of i){let u=e.find(p=>p.id===n);if(u)return u}return e.find(n=>re(n.id)===s)}var xt=["shoulder_roll","shoulder_deep_breath","chair_forward_fold","chair_side_stretch"];function Se(t){let e=String(t||"").trim().toLowerCase();return e==="squat"||e==="face_squat"}function W(t){return t==="v3"?"v3":"v4"}function Ge(t={}){if(t.userExercise)return"v4";let e=String(t.engine||"").trim().toLowerCase();return Se(t.exercise)&&e!=="v4"?"v3":W(t.engine)}function Ye(t){return xt.includes(t)}var Kt={left_knee:"from_hip_to_ankle",right_knee:"from_hip_to_ankle",left_hip:"from_knee_to_shoulder",right_hip:"from_knee_to_shoulder",left_shoulder:"from_hip_to_elbow",right_shoulder:"from_hip_to_elbow",left_elbow:"from_shoulder_to_wrist",right_elbow:"from_shoulder_to_wrist"};function $t(t){let e={left_side:{},right_side:{}};for(let r of t){if(r.side!=="left"&&r.side!=="right")continue;let s=r.side==="left"?e.left_side:e.right_side,n=`${r.id.replace(/^(left_|right_)/,"")}_angle`,u=Kt[r.id]??"value";s[n]||(s[n]={}),s[n][u]=r.degrees,s[n][`score_${u}`]=r.score}return e}function Xe(t){switch(t.type){case"initialization":return{type:"initialization",message:t.step==="configuring"?"checking you plan and access":t.message??Wt(t.step),ready:t.ready,step:t.step,...t.mode!=null?{mode:t.mode}:{},...t.acceleration!=null?{acceleration:t.acceleration}:{}};case"error":return{type:"error",error:t.code,message:t.message};case"warning":return{type:"warning",error:t.code,message:t.message};case"keypoints":return{type:"keypoints",data:t.keypoints.map(e=>({name:e.name,x:e.x,y:e.y,...e.z!=null?{z:e.z}:{},score:e.score})),score:t.score,timestampMs:t.timestampMs};case"stats":return{type:"stats",fps:t.fps,medianInferenceMs:t.medianInferenceMs,backend:t.backend,keypointsAbove03:t.keypointsAbove03,meanScore:t.meanScore,videoSize:t.videoSize,timestampMs:t.timestampMs};case"angles":return{type:"angles",data:$t(t.angles),timestampMs:t.timestampMs};case"counter":return{type:"counter",current_count:t.count,...t.formScore!=null?{form_score:{score:t.formScore.score,avg_score:t.formScore.average,grade:t.formScore.grade}}:{},...t.referenceScore!=null?{reference_score:{overallScore:t.referenceScore}}:{},timestampMs:t.timestampMs};case"posture":return{type:"posture",message:t.hint,ready:t.ready,direction:t.direction??"",requirements:{missingKeypoints:t.missingKeypoints},timestampMs:t.timestampMs};case"progression":return{type:"progression",value:t.value,timestampMs:t.timestampMs};case"recommendations":return{type:"recommendations",data:t.recommendations,timestampMs:t.timestampMs};case"form_score":return{type:"form_score",score:t.score,avg_score:t.average,grade:t.grade,timestampMs:t.timestampMs};case"exercise_summary":return{type:"exercise_summary",exercise:t.exercise,counter:t.counter,avg_rep_score:t.averageFormScore,avg_similarity:t.averageSimilarity,grade:t.grade,history:t.history,durationMs:t.durationMs,timestampMs:t.timestampMs};case"jump_calibration":return{type:"jump_calibration",calibrated:t.calibrated,cmPerPixel:t.cmPerPixel,baselineY:t.baselineY,visibleHips:t.visibleHips,message:t.message,timestampMs:t.timestampMs};case"jump_started":return{type:"jump_started",message:t.message,timestampMs:t.timestampMs};case"jump_height":{let{type:e,timestampMs:r,...s}=t;return{type:e,...s,timestampMs:r}}case"jump_discarded":return{type:"jump_discarded",reason:t.reason,userMessage:t.userMessage,timestampMs:t.timestampMs};case"jump_result":{let{type:e,timestampMs:r,...s}=t;return{type:e,...s,timestampMs:r}}case"jump_summary":{let{type:e,timestampMs:r,...s}=t;return{type:e,...s,timestampMs:r}}case"performance_warning":return{type:"error",error:t.code,message:t.message,meanFps:t.meanFps,thresholdFps:t.thresholdFps,activeProfile:t.activeProfile,medianInferenceMs:t.medianInferenceMs,videoSize:t.videoSize,timestampMs:t.timestampMs};case"quality_changed":return{type:"warning",error:"quality_downgraded",message:t.detail,previousProfile:t.previousProfile,activeProfile:t.activeProfile,reason:t.reason,timestampMs:t.timestampMs};case"runtime_download_progress":return{type:"initialization",message:`downloading pose runtime ${t.completedParts+1}/${t.totalParts}`,ready:!1,step:"downloading",part:t.part,completedParts:t.completedParts,totalParts:t.totalParts,timestampMs:t.timestampMs};default:return{type:"unknown",event:t}}}function Wt(t){switch(t){case"configuring":return"checking you plan and access";case"downloading":return"downloading engine";case"warming":return"loading pose model";case"ready":return"running";default:return t}}var N=["nose","left_eye","right_eye","left_ear","right_ear","left_shoulder","right_shoulder","left_elbow","right_elbow","left_wrist","right_wrist","left_hip","right_hip","left_knee","right_knee","left_ankle","right_ankle"];var be="4.22.0",zt="https://cdn.jsdelivr.net/npm";function Je(t=zt,e=be){let r=t.replace(/\/$/,"");return{scriptUrls:[`${r}/@tensorflow/tfjs-core@${e}/dist/tf-core.min.js`,`${r}/@tensorflow/tfjs-converter@${e}/dist/tf-converter.min.js`,`${r}/@tensorflow/tfjs-backend-webgl@${e}/dist/tf-backend-webgl.min.js`,`${r}/@tensorflow/tfjs-backend-wasm@${e}/dist/tf-backend-wasm.min.js`],wasmPath:`${r}/@tensorflow/tfjs-backend-wasm@${e}/dist/`}}var ke=null;function jt(t){try{t.env().set("WEBGL_CPU_FORWARD",!1)}catch{}try{t.env().set("WEBGL_PACK",!1)}catch{}try{t.env().set("WEBGL_FORCE_F16_TEXTURES",!1)}catch{}try{t.env().set("WEBGL_RENDER_FLOAT32_ENABLED",!1)}catch{}try{t.env().set("WEBGL_FLUSH_THRESHOLD",1.75)}catch{}}function qt(){return new Function("s","return import(s)")("@tensorflow/tfjs")}async function oe(){if(ke)return ke;if(typeof window<"u"&&window.tf)return ke=window.tf,window.tf;try{let t=await qt();return ke=t,t}catch{}throw new Error("TensorFlow.js not found. Install peer `@tensorflow/tfjs` or load CDN scripts (see README) so `window.tf` is available.")}async function ie(t){jt(t);try{let e=await t.setBackend("webgl");if(await t.ready(),e!==!1&&t.getBackend()==="webgl")return"webgl"}catch{}return await t.setBackend("cpu"),await t.ready(),"cpu"}var wt="2.1.3",Gt="https://cdn.jsdelivr.net/npm",ne=null,ae=null;function Et(t=Gt,e=wt){return`${t.replace(/\/$/,"")}/@tensorflow-models/pose-detection@${e}/dist/pose-detection.min.js`}function Yt(){return new Function("s","return import(s)")("@tensorflow-models/pose-detection")}function Qe(){if(typeof window>"u")return null;let t=window.poseDetection;return t&&typeof t.createDetector=="function"&&t.SupportedModels?.BlazePose?t:null}function Xt(t){if(typeof document>"u")return Promise.reject(new Error("Cannot inject pose-detection outside a browser document"));let e=Qe();return e?Promise.resolve(e):ae||(ae=new Promise((r,s)=>{let n=document.querySelector('script[data-pt-pose-detection="1"]'),u=()=>{let l=Qe();if(l){r(l);return}s(new Error("pose-detection CDN script loaded but `window.poseDetection` is missing. Check script order (TF.js first) and network."))};if(n){if(n.dataset.ptLoaded==="1"){u();return}n.addEventListener("load",u,{once:!0}),n.addEventListener("error",()=>s(new Error(`Failed to load pose-detection from ${n.src}`)),{once:!0});return}let p=document.createElement("script");p.src=t,p.async=!0,p.dataset.ptPoseDetection="1",p.onload=()=>{p.dataset.ptLoaded="1",u()},p.onerror=()=>{ae=null,s(new Error(`Failed to load pose-detection from ${t}`))},document.head.appendChild(p)}),ae)}async function Ze(t){if(ne)return ne;let e=Qe();if(e)return ne=e,e;try{let s=await Yt();return ne=s,s}catch{}if(t?.allowCdn!==!1&&typeof window<"u"&&typeof document<"u"){let s=Et(t?.cdnBase,t?.version),i=await Xt(s);return ne=i,i}throw new Error('BlazePose requires optional peer `@tensorflow-models/pose-detection`. Install it, load the CDN script so `window.poseDetection` exists, or use model="movenet" / pass a TF.js modelUrl.')}function Jt(t){return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?{vw:t.videoWidth||0,vh:t.videoHeight||0}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?{vw:t.naturalWidth||t.width||0,vh:t.naturalHeight||t.height||0}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?{vw:t.width||0,vh:t.height||0}:{vw:t.width||0,vh:t.height||0}}var Qt={nose:"nose",left_eye:"left_eye",right_eye:"right_eye",left_ear:"left_ear",right_ear:"right_ear",left_shoulder:"left_shoulder",right_shoulder:"right_shoulder",left_elbow:"left_elbow",right_elbow:"right_elbow",left_wrist:"left_wrist",right_wrist:"right_wrist",left_hip:"left_hip",right_hip:"right_hip",left_knee:"left_knee",right_knee:"right_knee",left_ankle:"left_ankle",right_ankle:"right_ankle"},Zt=new Set(["left_eye_inner","left_eye_outer","right_eye_inner","right_eye_outer","mouth_left","mouth_right"]),er=1280,tr=640;function rr(){return typeof navigator<"u"&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?tr:er}function sr(t,e,r,s,i,n,u){if(u<=1.5&&r>2)return{x:t*i,y:e*n};let p=r/i,l=s/n;return{x:p>0?t/p:t,y:l>0?e/l:e}}var le=class{constructor(e){this.modelId="blazepose";this.detector=null;this.backend=null;this.modelType="lite"}getBackend(){return this.backend}async load(){let e=await oe();this.backend=await ie(e);let r=await Ze();this.detector=await r.createDetector(r.SupportedModels.BlazePose,{runtime:"tfjs",modelType:this.modelType,enableSmoothing:!1})}async estimate(e,r){if(!this.detector)throw new Error("BlazePose adapter not loaded");let s=Jt(e);if(!(s.vw>0&&s.vh>0))return null;r.temporalSmooth===!1&&this.resetTemporal();let i=e,n=null,u=s.vw,p=s.vh;if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement){let a=Math.min(1,rr()/Math.max(s.vw,s.vh));u=Math.max(1,Math.round(s.vw*a)),p=Math.max(1,Math.round(s.vh*a)),n=document.createElement("canvas"),n.width=u,n.height=p;let m=n.getContext("2d");m&&(m.drawImage(e,0,0,u,p),i=n)}let l=performance.now(),x=await this.detector.estimatePoses(i,{flipHorizontal:!1,maxPoses:1}),v=performance.now()-l,_=x[0];if(!_?.keypoints?.length)return{keypoints:N.map(a=>({name:a,x:0,y:0,score:0})),score:0,inferenceMs:v,videoKeypoints:N.map(a=>({name:a,xPx:0,yPx:0,score:0})),letterbox:{offsetX:0,offsetY:0,drawW:s.vw,drawH:s.vh,vw:s.vw,vh:s.vh}};let w=s.vw||1,g=s.vh||1,b=r.displayWidth||1,E=r.displayHeight||1,T=0;for(let a of _.keypoints)T=Math.max(T,Math.abs(a.x||0),Math.abs(a.y||0));let C=new Map,F=[];for(let a of _.keypoints){let m=String(a.name||"").toLowerCase(),h=typeof a.score=="number"?a.score:0,y=sr(a.x,a.y,u,p,w,g,T),c=Qt[m];c?C.set(c,{x:y.x,y:y.y,score:h}):Zt.has(m)&&F.push({name:m,x:y.x,y:y.y,score:h})}let k=N.map(a=>{let m=C.get(a);return{name:a,xPx:m?.x??0,yPx:m?.y??0,score:m?.score??0}}),L=Math.max(b/w,E/g),I=(b-w*L)/2,o=(E-g*L)/2,d=0,f=k.map(a=>{let m=a.xPx*L+I,h=a.yPx*L+o,y=b>0?m/b:0,c=E>0?h/E:0;return r.facingMode==="user"&&(y=1-y),d+=a.score,{name:a.name,x:Math.min(1,Math.max(0,y)),y:Math.min(1,Math.max(0,c)),score:a.score}});for(let a of F){let m=a.x*L+I,h=a.y*L+o,y=b>0?m/b:0,c=E>0?h/E:0;r.facingMode==="user"&&(y=1-y),f.push({name:a.name,x:Math.min(1,Math.max(0,y)),y:Math.min(1,Math.max(0,c)),score:a.score})}return{keypoints:f,score:d/17,inferenceMs:v,videoKeypoints:k,letterbox:{offsetX:0,offsetY:0,drawW:w,drawH:g,vw:w,vh:g}}}resetTemporal(){try{this.detector?.reset?.()}catch{}}dispose(){try{this.detector?.dispose?.()}catch{}this.detector=null}};function St(t){return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?{vw:t.videoWidth||0,vh:t.videoHeight||0}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?{vw:t.naturalWidth||t.width||0,vh:t.naturalHeight||t.height||0}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?{vw:t.width||0,vh:t.height||0}:{vw:t.width||0,vh:t.height||0}}var A=192,_e=.45,kt=.52;function or(t,e,r){let s=t*A,i=e*A;return{x:(s-r.offsetX)*(r.vw/r.drawW)+(r.originX??0),y:(i-r.offsetY)*(r.vh/r.drawH)+(r.originY??0)}}function bt(t,e,r,s,i){let n=Math.max(r/i.vw,s/i.vh),u=(r-i.vw*n)/2,p=(s-i.vh*n)/2;return{x:t*n+u,y:e*n+p}}var ce=class{constructor(e){this.tf=null;this.model=null;this.backend=null;this.offscreen=null;this.offCtx=null;this.smoothed=null;this.lastVideoKps=null;this.stillPass=0;this.inferLb={offsetX:0,offsetY:0,drawW:A,drawH:A,vw:1,vh:1,originX:0,originY:0};this.letterbox={offsetX:0,offsetY:0,drawW:A,drawH:A,vw:1,vh:1};if(!e.resolved.modelUrl)throw new Error(e.resolved.unsupportedReason??"MoveNet requires a modelUrl");this.modelId=e.resolved.modelId,this.modelUrl=e.resolved.modelUrl}getBackend(){return this.backend}async load(){this.tf=await oe(),this.backend=await ie(this.tf),this.model=await this.tf.loadGraphModel(this.modelUrl);let e=this.tf.zeros([1,A,A,3],"int32"),r=this.model.execute(e);(Array.isArray(r)?r[0]:r).dataSync(),e.dispose(),Array.isArray(r)?r.forEach(i=>i.dispose()):r.dispose()}poseCanvasCtx(){if(this.offscreen||(this.offscreen=document.createElement("canvas"),this.offscreen.width=A,this.offscreen.height=A,this.offCtx=this.offscreen.getContext("2d",{willReadFrequently:!0})),!this.offCtx)throw new Error("2d context unavailable");return this.offCtx}prepareInput(e,r){let{vw:s,vh:i}=St(e),n=s||1,u=i||1,p=0,l=0,x=n,v=u;if(r&&this.lastVideoKps&&this.stillPass>0){let I=this.lastVideoKps.filter(o=>o.score>=.15);if(I.length>=4){let o=1/0,d=1/0,f=-1/0,a=-1/0;for(let P of I)o=Math.min(o,P.xPx),d=Math.min(d,P.yPx),f=Math.max(f,P.xPx),a=Math.max(a,P.yPx);let m=Math.max(8,f-o),h=Math.max(8,a-d),y=(o+f)/2,c=(d+a)/2;x=Math.max(m/kt,n*.35),v=Math.max(h/kt,u*.35);let S=n/u;x/v<S?x=v*S:v=x/S,p=y-x/2,l=c-v/2}}let _=Math.min(A/x,A/v),w=x*_,g=v*_,b=(A-w)/2,E=(A-g)/2;this.inferLb={offsetX:b,offsetY:E,drawW:w,drawH:g,vw:x,vh:v,originX:p,originY:l},this.letterbox={offsetX:0,offsetY:0,drawW:n,drawH:u,vw:n,vh:u};let T=this.poseCanvasCtx();T.fillStyle="#000",T.fillRect(0,0,A,A);let C=Math.max(0,p),F=Math.max(0,l),k=Math.min(n,p+x),L=Math.min(u,l+v);if(k>C&&L>F){let I=b+(C-p)*(w/x),o=E+(F-l)*(g/v),d=(k-C)*(w/x),f=(L-F)*(g/v);T.drawImage(e,C,F,k-C,L-F,I,o,d,f)}return this.stillPass+=1,this.offscreen}smooth(e){if(!this.smoothed)return this.smoothed=e.map(r=>({...r})),this.smoothed;for(let r=0;r<e.length;r++)e[r].score<.1||(this.smoothed[r].xPx=_e*e[r].xPx+(1-_e)*this.smoothed[r].xPx,this.smoothed[r].yPx=_e*e[r].yPx+(1-_e)*this.smoothed[r].yPx,this.smoothed[r].score=e[r].score);return this.smoothed}async estimate(e,r){if(!this.tf||!this.model)throw new Error("MoveNet adapter not loaded");let s=St(e);if(!(s.vw>0&&s.vh>0))return null;let i=performance.now(),n=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,u=r.temporalSmooth!==!1&&n,p=this.prepareInput(e,u),l=this.tf.tidy(()=>this.tf.expandDims(this.tf.browser.fromPixels(p),0)),x=this.model.execute(l),_=(Array.isArray(x)?x[0]:x).dataSync();l.dispose(),Array.isArray(x)?x.forEach(o=>o.dispose()):x.dispose();let w=performance.now()-i,g=this.inferLb,b=this.letterbox,E=r.displayWidth||1,T=r.displayHeight||1,C=[],F=0;for(let o=0;o<17;o++){let d=Math.min(1,Math.max(0,_[o*3])),f=Math.min(1,Math.max(0,_[o*3+1])),a=_[o*3+2],m=or(f,d,g);C.push({name:N[o],xPx:m.x,yPx:m.y,score:a}),F+=a}let k=r.temporalSmooth===!1?C:this.smooth(C);this.lastVideoKps=k.map(o=>({xPx:o.xPx,yPx:o.yPx,score:o.score}));let L=k.map((o,d)=>({name:N[d],xPx:o.xPx,yPx:o.yPx,score:o.score})),I=L.map(o=>{let d=bt(o.xPx,o.yPx,E,T,b),f=E>0?d.x/E:0,a=T>0?d.y/T:0;return r.facingMode==="user"&&(f=1-f),{name:o.name,x:Math.min(1,Math.max(0,f)),y:Math.min(1,Math.max(0,a)),score:o.score}});return{raw:_,keypoints:I,score:F/17,inferenceMs:w,videoKeypoints:L,letterbox:b}}resetTemporal(){this.smoothed=null,this.lastVideoKps=null,this.stillPass=0}dispose(){try{this.model?.dispose()}catch{}this.model=null,this.smoothed=null,this.lastVideoKps=null,this.stillPass=0,this.offscreen=null,this.offCtx=null}};function et(t,e,r,s){return t.map(i=>{let n=bt(i.xPx,i.yPx,r,s,e);return{name:i.name,dx:n.x,dy:n.y,score:i.score}})}function tt(t){let{resolved:e}=t;if(e.kind==="unsupported"||!e.modelUrl&&e.kind!=="blazepose")throw new Error(e.unsupportedReason??`Model "${e.modelId}" is unavailable.`);return e.kind==="blazepose"?new le(t):new ce(t)}var Me="https://app.posetracker.com/scripts/tmp_model_to_remove.json";function z(t={}){let e=typeof t.modelUrl=="string"&&t.modelUrl.trim().length>0?t.modelUrl.trim():null;if(e)return{modelId:typeof t.model=="string"&&t.model.trim().length>0?t.model.trim():"custom",kind:"custom-graph",modelUrl:e};let r=(t.model??"movenet").trim().toLowerCase();return r==="movenet"||r==="movenet-singlepose-lightning"||r==="lightning"?{modelId:"movenet-singlepose-lightning",kind:"movenet-graph",modelUrl:Me}:r==="blazepose"?{modelId:"blazepose",kind:"blazepose",modelUrl:null}:{modelId:r,kind:"unsupported",modelUrl:null,unsupportedReason:`Unknown model "${t.model}". Use "movenet" (default), "blazepose", or pass modelUrl.`}}var de="AI Loading",rt="https://docs.posetracker.com/logo/light.png";var ir=`
|
|
1
|
+
"use strict";var PoseTracker=(()=>{var Ft=Object.create;var me=Object.defineProperty;var Ct=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var dt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Rt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Dt=(t,e)=>{for(var r in e)me(t,r,{get:e[r],enumerable:!0})},ht=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of It(e))!At.call(t,i)&&i!==r&&me(t,i,{get:()=>e[i],enumerable:!(s=Ct(e,i))||s.enumerable});return t};var ut=(t,e,r)=>(r=t!=null?Ft(Lt(t)):{},ht(e||!t||!t.__esModule?me(r,"default",{value:t,enumerable:!0}):r,t)),Ot=t=>ht(me({},"__esModule",{value:!0}),t);var De=Rt((yr,fe)=>{"use strict";(function(){"use strict";var t="input is invalid type",e=typeof window=="object",r=e?window:{};r.JS_SHA256_NO_WINDOW&&(e=!1);var s=!e&&typeof self=="object",i=!r.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";i?r=global:s&&(r=self);var n=!r.JS_SHA256_NO_COMMON_JS&&typeof fe=="object"&&fe.exports,u=typeof define=="function"&&define.amd,p=!r.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",l="0123456789abcdef".split(""),x=[-2147483648,8388608,32768,128],v=[24,16,8,0],_=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],w=["hex","array","digest","arrayBuffer"],g=[];(r.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(o){return Object.prototype.toString.call(o)==="[object Array]"}),p&&(r.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(o){return typeof o=="object"&&o.buffer&&o.buffer.constructor===ArrayBuffer});var b=function(o,d){return function(f){return new k(d,!0).update(f)[o]()}},E=function(o){var d=b("hex",o);i&&(d=T(d,o)),d.create=function(){return new k(o)},d.update=function(m){return d.create().update(m)};for(var f=0;f<w.length;++f){var a=w[f];d[a]=b(a,o)}return d},T=function(o,d){var f=dt("crypto"),a=dt("buffer").Buffer,m=d?"sha224":"sha256",h;a.from&&!r.JS_SHA256_NO_BUFFER_FROM?h=a.from:h=function(c){return new a(c)};var y=function(c){if(typeof c=="string")return f.createHash(m).update(c,"utf8").digest("hex");if(c==null)throw new Error(t);return c.constructor===ArrayBuffer&&(c=new Uint8Array(c)),Array.isArray(c)||ArrayBuffer.isView(c)||c.constructor===a?f.createHash(m).update(h(c)).digest("hex"):o(c)};return y},C=function(o,d){return function(f,a){return new L(f,d,!0).update(a)[o]()}},F=function(o){var d=C("hex",o);d.create=function(m){return new L(m,o)},d.update=function(m,h){return d.create(m).update(h)};for(var f=0;f<w.length;++f){var a=w[f];d[a]=C(a,o)}return d};function k(o,d){d?(g[0]=g[16]=g[1]=g[2]=g[3]=g[4]=g[5]=g[6]=g[7]=g[8]=g[9]=g[10]=g[11]=g[12]=g[13]=g[14]=g[15]=0,this.blocks=g):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=o}k.prototype.update=function(o){if(!this.finalized){var d,f=typeof o;if(f!=="string"){if(f==="object"){if(o===null)throw new Error(t);if(p&&o.constructor===ArrayBuffer)o=new Uint8Array(o);else if(!Array.isArray(o)&&(!p||!ArrayBuffer.isView(o)))throw new Error(t)}else throw new Error(t);d=!0}for(var a,m=0,h,y=o.length,c=this.blocks;m<y;){if(this.hashed&&(this.hashed=!1,c[0]=this.block,this.block=c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0),d)for(h=this.start;m<y&&h<64;++m)c[h>>>2]|=o[m]<<v[h++&3];else for(h=this.start;m<y&&h<64;++m)a=o.charCodeAt(m),a<128?c[h>>>2]|=a<<v[h++&3]:a<2048?(c[h>>>2]|=(192|a>>>6)<<v[h++&3],c[h>>>2]|=(128|a&63)<<v[h++&3]):a<55296||a>=57344?(c[h>>>2]|=(224|a>>>12)<<v[h++&3],c[h>>>2]|=(128|a>>>6&63)<<v[h++&3],c[h>>>2]|=(128|a&63)<<v[h++&3]):(a=65536+((a&1023)<<10|o.charCodeAt(++m)&1023),c[h>>>2]|=(240|a>>>18)<<v[h++&3],c[h>>>2]|=(128|a>>>12&63)<<v[h++&3],c[h>>>2]|=(128|a>>>6&63)<<v[h++&3],c[h>>>2]|=(128|a&63)<<v[h++&3]);this.lastByteIndex=h,this.bytes+=h-this.start,h>=64?(this.block=c[16],this.start=h-64,this.hash(),this.hashed=!0):this.start=h}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},k.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var o=this.blocks,d=this.lastByteIndex;o[16]=this.block,o[d>>>2]|=x[d&3],this.block=o[16],d>=56&&(this.hashed||this.hash(),o[0]=this.block,o[16]=o[1]=o[2]=o[3]=o[4]=o[5]=o[6]=o[7]=o[8]=o[9]=o[10]=o[11]=o[12]=o[13]=o[14]=o[15]=0),o[14]=this.hBytes<<3|this.bytes>>>29,o[15]=this.bytes<<3,this.hash()}},k.prototype.hash=function(){var o=this.h0,d=this.h1,f=this.h2,a=this.h3,m=this.h4,h=this.h5,y=this.h6,c=this.h7,S=this.blocks,P,R,D,H,M,B,V,Y,Ae,Re,pe;for(P=16;P<64;++P)M=S[P-15],R=(M>>>7|M<<25)^(M>>>18|M<<14)^M>>>3,M=S[P-2],D=(M>>>17|M<<15)^(M>>>19|M<<13)^M>>>10,S[P]=S[P-16]+R+S[P-7]+D<<0;for(pe=d&f,P=0;P<64;P+=4)this.first?(this.is224?(Y=300032,M=S[0]-1413257819,c=M-150054599<<0,a=M+24177077<<0):(Y=704751109,M=S[0]-210244248,c=M-1521486534<<0,a=M+143694565<<0),this.first=!1):(R=(o>>>2|o<<30)^(o>>>13|o<<19)^(o>>>22|o<<10),D=(m>>>6|m<<26)^(m>>>11|m<<21)^(m>>>25|m<<7),Y=o&d,H=Y^o&f^pe,V=m&h^~m&y,M=c+D+V+_[P]+S[P],B=R+H,c=a+M<<0,a=M+B<<0),R=(a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10),D=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),Ae=a&o,H=Ae^a&d^Y,V=c&m^~c&h,M=y+D+V+_[P+1]+S[P+1],B=R+H,y=f+M<<0,f=M+B<<0,R=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),D=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),Re=f&a,H=Re^f&o^Ae,V=y&c^~y&m,M=h+D+V+_[P+2]+S[P+2],B=R+H,h=d+M<<0,d=M+B<<0,R=(d>>>2|d<<30)^(d>>>13|d<<19)^(d>>>22|d<<10),D=(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7),pe=d&f,H=pe^d&a^Re,V=h&y^~h&c,M=m+D+V+_[P+3]+S[P+3],B=R+H,m=o+M<<0,o=M+B<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+o<<0,this.h1=this.h1+d<<0,this.h2=this.h2+f<<0,this.h3=this.h3+a<<0,this.h4=this.h4+m<<0,this.h5=this.h5+h<<0,this.h6=this.h6+y<<0,this.h7=this.h7+c<<0},k.prototype.hex=function(){this.finalize();var o=this.h0,d=this.h1,f=this.h2,a=this.h3,m=this.h4,h=this.h5,y=this.h6,c=this.h7,S=l[o>>>28&15]+l[o>>>24&15]+l[o>>>20&15]+l[o>>>16&15]+l[o>>>12&15]+l[o>>>8&15]+l[o>>>4&15]+l[o&15]+l[d>>>28&15]+l[d>>>24&15]+l[d>>>20&15]+l[d>>>16&15]+l[d>>>12&15]+l[d>>>8&15]+l[d>>>4&15]+l[d&15]+l[f>>>28&15]+l[f>>>24&15]+l[f>>>20&15]+l[f>>>16&15]+l[f>>>12&15]+l[f>>>8&15]+l[f>>>4&15]+l[f&15]+l[a>>>28&15]+l[a>>>24&15]+l[a>>>20&15]+l[a>>>16&15]+l[a>>>12&15]+l[a>>>8&15]+l[a>>>4&15]+l[a&15]+l[m>>>28&15]+l[m>>>24&15]+l[m>>>20&15]+l[m>>>16&15]+l[m>>>12&15]+l[m>>>8&15]+l[m>>>4&15]+l[m&15]+l[h>>>28&15]+l[h>>>24&15]+l[h>>>20&15]+l[h>>>16&15]+l[h>>>12&15]+l[h>>>8&15]+l[h>>>4&15]+l[h&15]+l[y>>>28&15]+l[y>>>24&15]+l[y>>>20&15]+l[y>>>16&15]+l[y>>>12&15]+l[y>>>8&15]+l[y>>>4&15]+l[y&15];return this.is224||(S+=l[c>>>28&15]+l[c>>>24&15]+l[c>>>20&15]+l[c>>>16&15]+l[c>>>12&15]+l[c>>>8&15]+l[c>>>4&15]+l[c&15]),S},k.prototype.toString=k.prototype.hex,k.prototype.digest=function(){this.finalize();var o=this.h0,d=this.h1,f=this.h2,a=this.h3,m=this.h4,h=this.h5,y=this.h6,c=this.h7,S=[o>>>24&255,o>>>16&255,o>>>8&255,o&255,d>>>24&255,d>>>16&255,d>>>8&255,d&255,f>>>24&255,f>>>16&255,f>>>8&255,f&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255,h>>>24&255,h>>>16&255,h>>>8&255,h&255,y>>>24&255,y>>>16&255,y>>>8&255,y&255];return this.is224||S.push(c>>>24&255,c>>>16&255,c>>>8&255,c&255),S},k.prototype.array=k.prototype.digest,k.prototype.arrayBuffer=function(){this.finalize();var o=new ArrayBuffer(this.is224?28:32),d=new DataView(o);return d.setUint32(0,this.h0),d.setUint32(4,this.h1),d.setUint32(8,this.h2),d.setUint32(12,this.h3),d.setUint32(16,this.h4),d.setUint32(20,this.h5),d.setUint32(24,this.h6),this.is224||d.setUint32(28,this.h7),o};function L(o,d,f){var a,m=typeof o;if(m==="string"){var h=[],y=o.length,c=0,S;for(a=0;a<y;++a)S=o.charCodeAt(a),S<128?h[c++]=S:S<2048?(h[c++]=192|S>>>6,h[c++]=128|S&63):S<55296||S>=57344?(h[c++]=224|S>>>12,h[c++]=128|S>>>6&63,h[c++]=128|S&63):(S=65536+((S&1023)<<10|o.charCodeAt(++a)&1023),h[c++]=240|S>>>18,h[c++]=128|S>>>12&63,h[c++]=128|S>>>6&63,h[c++]=128|S&63);o=h}else if(m==="object"){if(o===null)throw new Error(t);if(p&&o.constructor===ArrayBuffer)o=new Uint8Array(o);else if(!Array.isArray(o)&&(!p||!ArrayBuffer.isView(o)))throw new Error(t)}else throw new Error(t);o.length>64&&(o=new k(d,!0).update(o).array());var P=[],R=[];for(a=0;a<64;++a){var D=o[a]||0;P[a]=92^D,R[a]=54^D}k.call(this,d,f),this.update(R),this.oKeyPad=P,this.inner=!0,this.sharedMemory=f}L.prototype=new k,L.prototype.finalize=function(){if(k.prototype.finalize.call(this),this.inner){this.inner=!1;var o=this.array();k.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(o),k.prototype.finalize.call(this)}};var I=E();I.sha256=I,I.sha224=E(!0),I.sha256.hmac=F(),I.sha224.hmac=F(!0),n?fe.exports=I:(r.sha256=I.sha256,r.sha224=I.sha224,u&&define(function(){return I}))})()});var ur={};Dt(ur,{COCO_KEYPOINT_NAMES:()=>N,DEFAULT_MOVENET_LIGHTNING_URL:()=>Me,ONLINE_TFJS_VERSION:()=>be,PoseCamera:()=>ct,SDK_NAME:()=>X,SDK_VERSION:()=>K,configure:()=>G,createPoseTracker:()=>Le,defaultTfjsCdnUrls:()=>Je,resolvePoseModel:()=>z,shouldShowWatermark:()=>ue});var K="0.3.4",X="posetracker-web";var q="https://movelytics-strapi-c78a339b7070.herokuapp.com",U=class extends Error{constructor(r,s){super(s);this.code=r;this.name="ConfigureError"}};async function G(t,e={}){let r=(e.baseUrl??q).replace(/\/$/,""),s={...t?{apiToken:t}:{},sdkName:X,sdkVersion:K,targetPlatform:"web",poseModelProfile:e.poseModelProfile??"AdaptiveChoice",locale:e.locale,localVersions:e.localVersions,engineChannel:e.engine==="v3"?"v3":"v4"},i;try{i=await fetch(`${r}/api/sdk/configure`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})}catch(n){throw new U("network",`Handshake request failed: ${String(n)}`)}if(i.status===401||i.status===403)throw new U("invalid_token","Invalid, revoked or unauthorized API token.");if(i.status===429)throw new U("quota_exceeded","API call quota exceeded for the current plan.");if(!i.ok)throw new U("internal",`Handshake failed with HTTP ${i.status}.`);return await i.json()}var Be=ut(De(),1);var Ue=ut(De(),1),Oe="ptc1:";function Ne(t){return(0,Ue.sha256)(`posetracker-sdk-cache:${t}`)}function Ut(t){let e=unescape(encodeURIComponent(t)),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r}function Nt(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return decodeURIComponent(escape(e))}function Ht(t){let e="";for(let r=0;r<t.length;r++)e+=t[r].toString(16).padStart(2,"0");return e}function Bt(t){if(t.length%2!==0||/[^0-9a-f]/.test(t))return null;let e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++)e[r]=parseInt(t.slice(r*2,r*2+2),16);return e}function pt(t,e){let r=new Uint8Array(t.length),s=0,i=0;for(;i<t.length;){let n=Ue.sha256.array(`${e}:${s++}`);for(let u=0;u<n.length&&i<t.length;u++,i++)r[i]=t[i]^n[u]}return r}function ge(t,e){return Oe+Ht(pt(Ut(t),e))}function ye(t,e){if(!t.startsWith(Oe))return null;let r=Bt(t.slice(Oe.length));if(!r)return null;try{return Nt(pt(r,e))}catch{return null}}var He="posetracker.web.";function Q(){return typeof localStorage>"u"?null:{async getItem(t){try{return localStorage.getItem(He+t)}catch{return null}},async setItem(t,e){try{localStorage.setItem(He+t,e)}catch{}},async removeItem(t){try{localStorage.removeItem(He+t)}catch{}}}}function ft(){let t=Q();return t?{read:e=>t.getItem(`file.${e}`),write:(e,r)=>t.setItem(`file.${e}`,r),remove:e=>t.removeItem(`file.${e}`)}:null}function gt(){let t=new Map;return{async read(e){return t.has(e)?t.get(e):null},async write(e,r){t.set(e,r)},async remove(e){t.delete(e)}}}function ve(){return ft()??gt()}var mt="posetracker.engine.guard.",J=class{constructor(e={}){this.lastError=null;this.files=e.fileStore!==void 0?e.fileStore:ve(),this.kv=e.keyValueStore!==void 0?e.keyValueStore:Q(),this.fetchFn=e.fetchFn??fetch,this.onDiagnostic=e.onDiagnostic,this.onDiagnostic?.(`[posetracker-web] EngineLoader fileStore=${this.files?"yes":"none"} kv=${this.kv?"localStorage":"none"}`)}async clearGuard(e){if(!e||!this.kv)return;let r=`${mt}${e.version}.${e.sha256}`;await this.kv.removeItem(r).catch(()=>{})}async load(e,r,s){if(this.lastError=null,!e)return this.lastError="manifest has no engine descriptor",null;let i=`${mt}${e.version}.${e.sha256}`;s?.forceRetry&&await this.kv?.removeItem(i).catch(()=>{});let n=await this.kv?.getItem(i);if(n==="probing"||n==="failed")return await this.kv?.setItem(i,"failed"),this.lastError=`engine crash-guard blocked version=${e.version} (state=${n}) \u2014 call configure() again to force retry`,this.onDiagnostic?.(`[posetracker-web] ${this.lastError}`),null;let u=`engine-${e.version}.sealed`,p=await this.files?.read(u);if(p!=null){let l=ye(p,r);if(l!==null&&(0,Be.sha256)(l)===e.sha256){let x=await this.evaluate(l,i);if(x)return this.onDiagnostic?.(`[posetracker-web] engine loaded from cache version=${e.version}`),{engine:x,source:"remote-cache"}}else this.onDiagnostic?.(`[posetracker-web] engine cache purged (unseal/integrity mismatch) key=${u}`),await this.files?.remove(u)}try{this.onDiagnostic?.(`[posetracker-web] downloading engine version=${e.version}\u2026`);let l=await this.fetchFn(e.signedUrl);if(!l.ok)throw new Error(`HTTP ${l.status}`);let x=await l.text(),v=(0,Be.sha256)(x);if(v!==e.sha256)throw new Error(`integrity check failed (got ${v.slice(0,12)}\u2026 expected ${e.sha256.slice(0,12)}\u2026, bytes=${x.length})`);let _=await this.evaluate(x,i);if(_){try{await this.files?.write(u,ge(x,r))}catch(w){this.onDiagnostic?.("[posetracker-web] engine cache write failed (non-fatal): "+(w instanceof Error?w.message:String(w)))}return this.onDiagnostic?.(`[posetracker-web] engine loaded from download version=${e.version} bytes=${x.length}`),{engine:_,source:"remote-download"}}}catch(l){this.lastError=l instanceof Error?l.message:String(l),this.onDiagnostic?.(`[posetracker-web] engine download/load failed: ${this.lastError}`)}return this.lastError||(this.lastError="engine evaluate returned null"),null}async evaluate(e,r){await this.kv?.setItem(r,"probing");try{let s={exports:{}};new Function("module","exports",e)(s,s.exports);let n=s.exports.createEngine;if(typeof n!="function")throw new Error(`engine bundle does not export createEngine() (got ${typeof n}, keys=${Object.keys(s.exports).join(",")})`);let u=n();return await this.kv?.setItem(r,"passed"),u}catch(s){return this.lastError="engine evaluate failed: "+(s instanceof Error?s.message:String(s)),this.onDiagnostic?.(`[posetracker-web] ${this.lastError}`),await this.kv?.setItem(r,"failed"),null}}};var Ve="posetracker.track.queue",Vt=100,O=class extends Error{constructor(r,s){super(s);this.code=r;this.name="TrackError"}},Z=class{constructor(e={}){this.baseUrl=(e.baseUrl??q).replace(/\/$/,""),this.kv=e.keyValueStore!==void 0?e.keyValueStore:Q(),this.fetchFn=e.fetchFn??fetch}async trackMetered(e){return this.post({event:e.event??"camera_start",apiToken:e.apiToken,platform:"web",sdkVersion:K,params:e.params})}async trackAnonymous(e={}){let r={event:e.event??"camera_start",platform:"web",sdkVersion:K,params:e.params,queuedAtMs:Date.now()};try{await this.post({...r}),this.flushQueue()}catch{await this.enqueue(r)}}async flushQueue(){let e=await this.readQueue();if(e.length===0)return;let r=[];for(let s of e)try{await this.post({...s,params:{...s.params??{},queuedAtMs:s.queuedAtMs}})}catch{r.push(s)}await this.writeQueue(r)}async post(e){let r;try{r=await this.fetchFn(`${this.baseUrl}/api/sdk/track`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch(s){throw new O("network",`Usage tracking request failed: ${String(s)}`)}if(r.status===401||r.status===403)throw new O("invalid_token","Invalid, revoked or unauthorized API token.");if(r.status===429)throw new O("quota_exceeded","API call quota exceeded for the current plan.");if(!r.ok)throw new O("internal",`Usage tracking failed with HTTP ${r.status}.`);return await r.json()}async readQueue(){try{let e=await this.kv?.getItem(Ve);if(!e)return[];let r=JSON.parse(e);return Array.isArray(r)?r:[]}catch{return[]}}async writeQueue(e){try{e.length===0?await this.kv?.removeItem(Ve):await this.kv?.setItem(Ve,JSON.stringify(e.slice(-Vt)))}catch{}}async enqueue(e){let r=await this.readQueue();r.push(e),await this.writeQueue(r)}};var $=class extends Error{constructor(r,s){super(s);this.code=r;this.name="SkeletonFetchError"}};async function Ke(t,e={}){let r=t.trim();if(!r||r==="true"||r==="false")throw new $("invalid","skeleton uuid is required");let s=(e.baseUrl??q).replace(/\/$/,""),i;try{i=await fetch(`${s}/api/sdk/skeleton?uuid=${encodeURIComponent(r)}`)}catch(u){throw new $("network",`Skeleton fetch failed: ${String(u)}`)}if(i.status===404)throw new $("not_found",`Skeleton '${r}' not found`);if(!i.ok)throw new $("network",`Skeleton fetch HTTP ${i.status}`);let n=await i.json();if(!n?.keypoints||!n?.keypoint_lines||!n?.circles||!n?.lines)throw new $("invalid","Skeleton payload incomplete");return{keypoints:n.keypoints,keypoint_lines:n.keypoint_lines,keypoint_angles:n.keypoint_angles??[],circles:n.circles,lines:n.lines,angles:n.angles}}async function $e(t={}){if(typeof navigator>"u"||!navigator.mediaDevices?.getUserMedia)throw new Error("getUserMedia is not available in this environment");let e=t.facingMode??"user",r={audio:!1,video:{facingMode:e,width:t.idealWidth?{ideal:t.idealWidth}:void 0,height:t.idealHeight?{ideal:t.idealHeight}:void 0,frameRate:t.idealFrameRate?{ideal:t.idealFrameRate}:void 0}};try{return await navigator.mediaDevices.getUserMedia(r)}catch{return navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:e}})}}function We(t){if(t)for(let e of t.getTracks())try{e.stop()}catch{}}function ee(t){return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement}function yt(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement}function ze(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap}function te(t){return ze(t)?{width:t.width||0,height:t.height||0}:ee(t)?{width:t.videoWidth||0,height:t.videoHeight||0}:{width:t.naturalWidth||t.width||0,height:t.naturalHeight||t.height||0}}async function xe(t){if(typeof t=="string")return{url:t,revoke:()=>{}};let e=URL.createObjectURL(t);return{url:e,revoke:()=>{try{URL.revokeObjectURL(e)}catch{}}}}function je(t,e=15e3){return new Promise((r,s)=>{if(t.readyState>=2&&t.videoWidth>0){r();return}let i=()=>{p(),r()},n=()=>{p(),s(new Error("Failed to load video source"))},u=setTimeout(()=>{p(),s(new Error("Timed out waiting for video metadata"))},e),p=()=>{clearTimeout(u),t.removeEventListener("loadeddata",i),t.removeEventListener("error",n)};t.addEventListener("loadeddata",i),t.addEventListener("error",n)})}function we(t,e=15e3){return new Promise((r,s)=>{if(t.complete&&t.naturalWidth>0){r();return}if(t.complete){s(new Error("Image failed to decode (naturalWidth=0)"));return}let i=()=>{p(),r()},n=()=>{p(),s(new Error("Failed to load image source"))},u=setTimeout(()=>{p(),s(new Error("Timed out waiting for image"))},e),p=()=>{clearTimeout(u),t.removeEventListener("load",i),t.removeEventListener("error",n)};t.addEventListener("load",i),t.addEventListener("error",n)})}async function vt(t){let e=document.createElement("canvas");e.width=t.width,e.height=t.height;let r=e.getContext("2d");if(!r)throw new Error("2d context unavailable");r.drawImage(t,0,0);let s=await new Promise((i,n)=>{e.toBlob(u=>u?i(u):n(new Error("toBlob failed")),"image/png")});return xe(s)}function Ee(t,e){if(t&&typeof t=="object"&&"type"in t)return t;let r=t==="video"||t==="image"||t==="camera"?t:"camera";if(r==="camera")return{type:"camera",facingMode:e?.facingMode};let s=e?.sourceFile??e?.sourceUrl;if(!s)throw new Error(`PoseSource type "${r}" requires sourceUrl or sourceFile (or pass a full PoseSource object)`);return r==="video"?{type:"video",src:s}:{type:"image",src:s}}var qe={face_squat:"squat",face_pushup:"push_up",face_plank:"plank",face_lunge:"lunge",face_jumping_jack:"jumping_jack",face_low_impact_jack:"low_impact_jack",face_balance_leg:"balance_leg",face_balance_leg_left:"balance_leg_left",face_balance_leg_right:"balance_leg_right",jump:"air_time_jump"};function re(t){return qe[t]??t}function se(t,e){let r=e.find(n=>n.id===t);if(r)return r;let s=re(t),i=Object.entries(qe).filter(([,n])=>n===s).map(([n])=>n);for(let n of i){let u=e.find(p=>p.id===n);if(u)return u}return e.find(n=>re(n.id)===s)}var xt=["shoulder_roll","shoulder_deep_breath","chair_forward_fold","chair_side_stretch","back_flexibility_test"];function Se(t){let e=String(t||"").trim().toLowerCase();return e==="squat"||e==="face_squat"}function W(t){return t==="v3"?"v3":"v4"}function Ge(t={}){if(t.userExercise)return"v4";let e=String(t.engine||"").trim().toLowerCase();return Se(t.exercise)&&e!=="v4"?"v3":W(t.engine)}function Ye(t){return xt.includes(t)}var Kt={left_knee:"from_hip_to_ankle",right_knee:"from_hip_to_ankle",left_hip:"from_knee_to_shoulder",right_hip:"from_knee_to_shoulder",left_shoulder:"from_hip_to_elbow",right_shoulder:"from_hip_to_elbow",left_elbow:"from_shoulder_to_wrist",right_elbow:"from_shoulder_to_wrist"};function $t(t){let e={left_side:{},right_side:{}};for(let r of t){if(r.side!=="left"&&r.side!=="right")continue;let s=r.side==="left"?e.left_side:e.right_side,n=`${r.id.replace(/^(left_|right_)/,"")}_angle`,u=Kt[r.id]??"value";s[n]||(s[n]={}),s[n][u]=r.degrees,s[n][`score_${u}`]=r.score}return e}function Xe(t){switch(t.type){case"initialization":return{type:"initialization",message:t.step==="configuring"?"checking you plan and access":t.message??Wt(t.step),ready:t.ready,step:t.step,...t.mode!=null?{mode:t.mode}:{},...t.acceleration!=null?{acceleration:t.acceleration}:{}};case"error":return{type:"error",error:t.code,message:t.message};case"warning":return{type:"warning",error:t.code,message:t.message};case"keypoints":return{type:"keypoints",data:t.keypoints.map(e=>({name:e.name,x:e.x,y:e.y,...e.z!=null?{z:e.z}:{},score:e.score})),score:t.score,timestampMs:t.timestampMs};case"stats":return{type:"stats",fps:t.fps,medianInferenceMs:t.medianInferenceMs,backend:t.backend,keypointsAbove03:t.keypointsAbove03,meanScore:t.meanScore,videoSize:t.videoSize,timestampMs:t.timestampMs};case"angles":return{type:"angles",data:$t(t.angles),timestampMs:t.timestampMs};case"counter":return{type:"counter",current_count:t.count,...t.formScore!=null?{form_score:{score:t.formScore.score,avg_score:t.formScore.average,grade:t.formScore.grade}}:{},...t.referenceScore!=null?{reference_score:{overallScore:t.referenceScore}}:{},...t.analysis!=null?{analysis:t.analysis}:{},timestampMs:t.timestampMs};case"posture":return{type:"posture",message:t.hint,ready:t.ready,direction:t.direction??"",requirements:{missingKeypoints:t.missingKeypoints},timestampMs:t.timestampMs};case"progression":return{type:"progression",value:t.value,timestampMs:t.timestampMs};case"recommendations":return{type:"recommendations",data:t.recommendations,timestampMs:t.timestampMs};case"form_score":return{type:"form_score",score:t.score,avg_score:t.average,grade:t.grade,timestampMs:t.timestampMs};case"exercise_summary":return{type:"exercise_summary",exercise:t.exercise,counter:t.counter,avg_rep_score:t.averageFormScore,avg_similarity:t.averageSimilarity,grade:t.grade,history:t.history,durationMs:t.durationMs,...t.disclaimer!=null?{disclaimer:t.disclaimer}:{},...t.method!=null?{method:t.method}:{},timestampMs:t.timestampMs};case"jump_calibration":return{type:"jump_calibration",calibrated:t.calibrated,cmPerPixel:t.cmPerPixel,baselineY:t.baselineY,visibleHips:t.visibleHips,message:t.message,timestampMs:t.timestampMs};case"jump_started":return{type:"jump_started",message:t.message,timestampMs:t.timestampMs};case"jump_height":{let{type:e,timestampMs:r,...s}=t;return{type:e,...s,timestampMs:r}}case"jump_discarded":return{type:"jump_discarded",reason:t.reason,userMessage:t.userMessage,timestampMs:t.timestampMs};case"jump_result":{let{type:e,timestampMs:r,...s}=t;return{type:e,...s,timestampMs:r}}case"jump_summary":{let{type:e,timestampMs:r,...s}=t;return{type:e,...s,timestampMs:r}}case"performance_warning":return{type:"error",error:t.code,message:t.message,meanFps:t.meanFps,thresholdFps:t.thresholdFps,activeProfile:t.activeProfile,medianInferenceMs:t.medianInferenceMs,videoSize:t.videoSize,timestampMs:t.timestampMs};case"quality_changed":return{type:"warning",error:"quality_downgraded",message:t.detail,previousProfile:t.previousProfile,activeProfile:t.activeProfile,reason:t.reason,timestampMs:t.timestampMs};case"runtime_download_progress":return{type:"initialization",message:`downloading pose runtime ${t.completedParts+1}/${t.totalParts}`,ready:!1,step:"downloading",part:t.part,completedParts:t.completedParts,totalParts:t.totalParts,timestampMs:t.timestampMs};default:return{type:"unknown",event:t}}}function Wt(t){switch(t){case"configuring":return"checking you plan and access";case"downloading":return"downloading engine";case"warming":return"loading pose model";case"ready":return"running";default:return t}}var N=["nose","left_eye","right_eye","left_ear","right_ear","left_shoulder","right_shoulder","left_elbow","right_elbow","left_wrist","right_wrist","left_hip","right_hip","left_knee","right_knee","left_ankle","right_ankle"];var be="4.22.0",zt="https://cdn.jsdelivr.net/npm";function Je(t=zt,e=be){let r=t.replace(/\/$/,"");return{scriptUrls:[`${r}/@tensorflow/tfjs-core@${e}/dist/tf-core.min.js`,`${r}/@tensorflow/tfjs-converter@${e}/dist/tf-converter.min.js`,`${r}/@tensorflow/tfjs-backend-webgl@${e}/dist/tf-backend-webgl.min.js`,`${r}/@tensorflow/tfjs-backend-wasm@${e}/dist/tf-backend-wasm.min.js`],wasmPath:`${r}/@tensorflow/tfjs-backend-wasm@${e}/dist/`}}var ke=null;function jt(t){try{t.env().set("WEBGL_CPU_FORWARD",!1)}catch{}try{t.env().set("WEBGL_PACK",!1)}catch{}try{t.env().set("WEBGL_FORCE_F16_TEXTURES",!1)}catch{}try{t.env().set("WEBGL_RENDER_FLOAT32_ENABLED",!1)}catch{}try{t.env().set("WEBGL_FLUSH_THRESHOLD",1.75)}catch{}}function qt(){return new Function("s","return import(s)")("@tensorflow/tfjs")}async function oe(){if(ke)return ke;if(typeof window<"u"&&window.tf)return ke=window.tf,window.tf;try{let t=await qt();return ke=t,t}catch{}throw new Error("TensorFlow.js not found. Install peer `@tensorflow/tfjs` or load CDN scripts (see README) so `window.tf` is available.")}async function ie(t){jt(t);try{let e=await t.setBackend("webgl");if(await t.ready(),e!==!1&&t.getBackend()==="webgl")return"webgl"}catch{}return await t.setBackend("cpu"),await t.ready(),"cpu"}var wt="2.1.3",Gt="https://cdn.jsdelivr.net/npm",ne=null,ae=null;function Et(t=Gt,e=wt){return`${t.replace(/\/$/,"")}/@tensorflow-models/pose-detection@${e}/dist/pose-detection.min.js`}function Yt(){return new Function("s","return import(s)")("@tensorflow-models/pose-detection")}function Qe(){if(typeof window>"u")return null;let t=window.poseDetection;return t&&typeof t.createDetector=="function"&&t.SupportedModels?.BlazePose?t:null}function Xt(t){if(typeof document>"u")return Promise.reject(new Error("Cannot inject pose-detection outside a browser document"));let e=Qe();return e?Promise.resolve(e):ae||(ae=new Promise((r,s)=>{let n=document.querySelector('script[data-pt-pose-detection="1"]'),u=()=>{let l=Qe();if(l){r(l);return}s(new Error("pose-detection CDN script loaded but `window.poseDetection` is missing. Check script order (TF.js first) and network."))};if(n){if(n.dataset.ptLoaded==="1"){u();return}n.addEventListener("load",u,{once:!0}),n.addEventListener("error",()=>s(new Error(`Failed to load pose-detection from ${n.src}`)),{once:!0});return}let p=document.createElement("script");p.src=t,p.async=!0,p.dataset.ptPoseDetection="1",p.onload=()=>{p.dataset.ptLoaded="1",u()},p.onerror=()=>{ae=null,s(new Error(`Failed to load pose-detection from ${t}`))},document.head.appendChild(p)}),ae)}async function Ze(t){if(ne)return ne;let e=Qe();if(e)return ne=e,e;try{let s=await Yt();return ne=s,s}catch{}if(t?.allowCdn!==!1&&typeof window<"u"&&typeof document<"u"){let s=Et(t?.cdnBase,t?.version),i=await Xt(s);return ne=i,i}throw new Error('BlazePose requires optional peer `@tensorflow-models/pose-detection`. Install it, load the CDN script so `window.poseDetection` exists, or use model="movenet" / pass a TF.js modelUrl.')}function Jt(t){return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?{vw:t.videoWidth||0,vh:t.videoHeight||0}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?{vw:t.naturalWidth||t.width||0,vh:t.naturalHeight||t.height||0}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?{vw:t.width||0,vh:t.height||0}:{vw:t.width||0,vh:t.height||0}}var Qt={nose:"nose",left_eye:"left_eye",right_eye:"right_eye",left_ear:"left_ear",right_ear:"right_ear",left_shoulder:"left_shoulder",right_shoulder:"right_shoulder",left_elbow:"left_elbow",right_elbow:"right_elbow",left_wrist:"left_wrist",right_wrist:"right_wrist",left_hip:"left_hip",right_hip:"right_hip",left_knee:"left_knee",right_knee:"right_knee",left_ankle:"left_ankle",right_ankle:"right_ankle"},Zt=new Set(["left_eye_inner","left_eye_outer","right_eye_inner","right_eye_outer","mouth_left","mouth_right"]),er=1280,tr=640;function rr(){return typeof navigator<"u"&&/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)?tr:er}function sr(t,e,r,s,i,n,u){if(u<=1.5&&r>2)return{x:t*i,y:e*n};let p=r/i,l=s/n;return{x:p>0?t/p:t,y:l>0?e/l:e}}var le=class{constructor(e){this.modelId="blazepose";this.detector=null;this.backend=null;this.modelType="lite"}getBackend(){return this.backend}async load(){let e=await oe();this.backend=await ie(e);let r=await Ze();this.detector=await r.createDetector(r.SupportedModels.BlazePose,{runtime:"tfjs",modelType:this.modelType,enableSmoothing:!1})}async estimate(e,r){if(!this.detector)throw new Error("BlazePose adapter not loaded");let s=Jt(e);if(!(s.vw>0&&s.vh>0))return null;r.temporalSmooth===!1&&this.resetTemporal();let i=e,n=null,u=s.vw,p=s.vh;if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement){let a=Math.min(1,rr()/Math.max(s.vw,s.vh));u=Math.max(1,Math.round(s.vw*a)),p=Math.max(1,Math.round(s.vh*a)),n=document.createElement("canvas"),n.width=u,n.height=p;let m=n.getContext("2d");m&&(m.drawImage(e,0,0,u,p),i=n)}let l=performance.now(),x=await this.detector.estimatePoses(i,{flipHorizontal:!1,maxPoses:1}),v=performance.now()-l,_=x[0];if(!_?.keypoints?.length)return{keypoints:N.map(a=>({name:a,x:0,y:0,score:0})),score:0,inferenceMs:v,videoKeypoints:N.map(a=>({name:a,xPx:0,yPx:0,score:0})),letterbox:{offsetX:0,offsetY:0,drawW:s.vw,drawH:s.vh,vw:s.vw,vh:s.vh}};let w=s.vw||1,g=s.vh||1,b=r.displayWidth||1,E=r.displayHeight||1,T=0;for(let a of _.keypoints)T=Math.max(T,Math.abs(a.x||0),Math.abs(a.y||0));let C=new Map,F=[];for(let a of _.keypoints){let m=String(a.name||"").toLowerCase(),h=typeof a.score=="number"?a.score:0,y=sr(a.x,a.y,u,p,w,g,T),c=Qt[m];c?C.set(c,{x:y.x,y:y.y,score:h}):Zt.has(m)&&F.push({name:m,x:y.x,y:y.y,score:h})}let k=N.map(a=>{let m=C.get(a);return{name:a,xPx:m?.x??0,yPx:m?.y??0,score:m?.score??0}}),L=Math.max(b/w,E/g),I=(b-w*L)/2,o=(E-g*L)/2,d=0,f=k.map(a=>{let m=a.xPx*L+I,h=a.yPx*L+o,y=b>0?m/b:0,c=E>0?h/E:0;return r.facingMode==="user"&&(y=1-y),d+=a.score,{name:a.name,x:Math.min(1,Math.max(0,y)),y:Math.min(1,Math.max(0,c)),score:a.score}});for(let a of F){let m=a.x*L+I,h=a.y*L+o,y=b>0?m/b:0,c=E>0?h/E:0;r.facingMode==="user"&&(y=1-y),f.push({name:a.name,x:Math.min(1,Math.max(0,y)),y:Math.min(1,Math.max(0,c)),score:a.score})}return{keypoints:f,score:d/17,inferenceMs:v,videoKeypoints:k,letterbox:{offsetX:0,offsetY:0,drawW:w,drawH:g,vw:w,vh:g}}}resetTemporal(){try{this.detector?.reset?.()}catch{}}dispose(){try{this.detector?.dispose?.()}catch{}this.detector=null}};function St(t){return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?{vw:t.videoWidth||0,vh:t.videoHeight||0}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?{vw:t.naturalWidth||t.width||0,vh:t.naturalHeight||t.height||0}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?{vw:t.width||0,vh:t.height||0}:{vw:t.width||0,vh:t.height||0}}var A=192,_e=.45,kt=.52;function or(t,e,r){let s=t*A,i=e*A;return{x:(s-r.offsetX)*(r.vw/r.drawW)+(r.originX??0),y:(i-r.offsetY)*(r.vh/r.drawH)+(r.originY??0)}}function bt(t,e,r,s,i){let n=Math.max(r/i.vw,s/i.vh),u=(r-i.vw*n)/2,p=(s-i.vh*n)/2;return{x:t*n+u,y:e*n+p}}var ce=class{constructor(e){this.tf=null;this.model=null;this.backend=null;this.offscreen=null;this.offCtx=null;this.smoothed=null;this.lastVideoKps=null;this.stillPass=0;this.inferLb={offsetX:0,offsetY:0,drawW:A,drawH:A,vw:1,vh:1,originX:0,originY:0};this.letterbox={offsetX:0,offsetY:0,drawW:A,drawH:A,vw:1,vh:1};if(!e.resolved.modelUrl)throw new Error(e.resolved.unsupportedReason??"MoveNet requires a modelUrl");this.modelId=e.resolved.modelId,this.modelUrl=e.resolved.modelUrl}getBackend(){return this.backend}async load(){this.tf=await oe(),this.backend=await ie(this.tf),this.model=await this.tf.loadGraphModel(this.modelUrl);let e=this.tf.zeros([1,A,A,3],"int32"),r=this.model.execute(e);(Array.isArray(r)?r[0]:r).dataSync(),e.dispose(),Array.isArray(r)?r.forEach(i=>i.dispose()):r.dispose()}poseCanvasCtx(){if(this.offscreen||(this.offscreen=document.createElement("canvas"),this.offscreen.width=A,this.offscreen.height=A,this.offCtx=this.offscreen.getContext("2d",{willReadFrequently:!0})),!this.offCtx)throw new Error("2d context unavailable");return this.offCtx}prepareInput(e,r){let{vw:s,vh:i}=St(e),n=s||1,u=i||1,p=0,l=0,x=n,v=u;if(r&&this.lastVideoKps&&this.stillPass>0){let I=this.lastVideoKps.filter(o=>o.score>=.15);if(I.length>=4){let o=1/0,d=1/0,f=-1/0,a=-1/0;for(let P of I)o=Math.min(o,P.xPx),d=Math.min(d,P.yPx),f=Math.max(f,P.xPx),a=Math.max(a,P.yPx);let m=Math.max(8,f-o),h=Math.max(8,a-d),y=(o+f)/2,c=(d+a)/2;x=Math.max(m/kt,n*.35),v=Math.max(h/kt,u*.35);let S=n/u;x/v<S?x=v*S:v=x/S,p=y-x/2,l=c-v/2}}let _=Math.min(A/x,A/v),w=x*_,g=v*_,b=(A-w)/2,E=(A-g)/2;this.inferLb={offsetX:b,offsetY:E,drawW:w,drawH:g,vw:x,vh:v,originX:p,originY:l},this.letterbox={offsetX:0,offsetY:0,drawW:n,drawH:u,vw:n,vh:u};let T=this.poseCanvasCtx();T.fillStyle="#000",T.fillRect(0,0,A,A);let C=Math.max(0,p),F=Math.max(0,l),k=Math.min(n,p+x),L=Math.min(u,l+v);if(k>C&&L>F){let I=b+(C-p)*(w/x),o=E+(F-l)*(g/v),d=(k-C)*(w/x),f=(L-F)*(g/v);T.drawImage(e,C,F,k-C,L-F,I,o,d,f)}return this.stillPass+=1,this.offscreen}smooth(e){if(!this.smoothed)return this.smoothed=e.map(r=>({...r})),this.smoothed;for(let r=0;r<e.length;r++)e[r].score<.1||(this.smoothed[r].xPx=_e*e[r].xPx+(1-_e)*this.smoothed[r].xPx,this.smoothed[r].yPx=_e*e[r].yPx+(1-_e)*this.smoothed[r].yPx,this.smoothed[r].score=e[r].score);return this.smoothed}async estimate(e,r){if(!this.tf||!this.model)throw new Error("MoveNet adapter not loaded");let s=St(e);if(!(s.vw>0&&s.vh>0))return null;let i=performance.now(),n=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,u=r.temporalSmooth!==!1&&n,p=this.prepareInput(e,u),l=this.tf.tidy(()=>this.tf.expandDims(this.tf.browser.fromPixels(p),0)),x=this.model.execute(l),_=(Array.isArray(x)?x[0]:x).dataSync();l.dispose(),Array.isArray(x)?x.forEach(o=>o.dispose()):x.dispose();let w=performance.now()-i,g=this.inferLb,b=this.letterbox,E=r.displayWidth||1,T=r.displayHeight||1,C=[],F=0;for(let o=0;o<17;o++){let d=Math.min(1,Math.max(0,_[o*3])),f=Math.min(1,Math.max(0,_[o*3+1])),a=_[o*3+2],m=or(f,d,g);C.push({name:N[o],xPx:m.x,yPx:m.y,score:a}),F+=a}let k=r.temporalSmooth===!1?C:this.smooth(C);this.lastVideoKps=k.map(o=>({xPx:o.xPx,yPx:o.yPx,score:o.score}));let L=k.map((o,d)=>({name:N[d],xPx:o.xPx,yPx:o.yPx,score:o.score})),I=L.map(o=>{let d=bt(o.xPx,o.yPx,E,T,b),f=E>0?d.x/E:0,a=T>0?d.y/T:0;return r.facingMode==="user"&&(f=1-f),{name:o.name,x:Math.min(1,Math.max(0,f)),y:Math.min(1,Math.max(0,a)),score:o.score}});return{raw:_,keypoints:I,score:F/17,inferenceMs:w,videoKeypoints:L,letterbox:b}}resetTemporal(){this.smoothed=null,this.lastVideoKps=null,this.stillPass=0}dispose(){try{this.model?.dispose()}catch{}this.model=null,this.smoothed=null,this.lastVideoKps=null,this.stillPass=0,this.offscreen=null,this.offCtx=null}};function et(t,e,r,s){return t.map(i=>{let n=bt(i.xPx,i.yPx,r,s,e);return{name:i.name,dx:n.x,dy:n.y,score:i.score}})}function tt(t){let{resolved:e}=t;if(e.kind==="unsupported"||!e.modelUrl&&e.kind!=="blazepose")throw new Error(e.unsupportedReason??`Model "${e.modelId}" is unavailable.`);return e.kind==="blazepose"?new le(t):new ce(t)}var Me="https://app.posetracker.com/scripts/tmp_model_to_remove.json";function z(t={}){let e=typeof t.modelUrl=="string"&&t.modelUrl.trim().length>0?t.modelUrl.trim():null;if(e)return{modelId:typeof t.model=="string"&&t.model.trim().length>0?t.model.trim():"custom",kind:"custom-graph",modelUrl:e};let r=(t.model??"movenet").trim().toLowerCase();return r==="movenet"||r==="movenet-singlepose-lightning"||r==="lightning"?{modelId:"movenet-singlepose-lightning",kind:"movenet-graph",modelUrl:Me}:r==="blazepose"?{modelId:"blazepose",kind:"blazepose",modelUrl:null}:{modelId:r,kind:"unsupported",modelUrl:null,unsupportedReason:`Unknown model "${t.model}". Use "movenet" (default), "blazepose", or pass modelUrl.`}}var de="AI Loading",rt="https://docs.posetracker.com/logo/light.png";var ir=`
|
|
2
2
|
.pt-root {
|
|
3
3
|
position: relative; width: 100%; height: 100%; min-height: 240px;
|
|
4
4
|
background: #000; overflow: hidden; isolation: isolate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pose-tracker/pose-estimation-web",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "PoseTracker web pose estimation SDK (vanilla) — MoveNet via TensorFlow.js + remote model URL. Exercise engine via API token. No bundled weights.",
|
|
6
6
|
"type": "module",
|