@seontechnologies/seon-id-verification
Version:
An advanced SDK featuring web components for natural person identification through document scanning, facial recognition, hand gesture, and face turning detection, designed for secure and efficient user verification.
220 lines (219 loc) • 25 kB
JavaScript
import { j as o, l, a as S, t as k } from "./index-oGnhSncZ.mjs";
import * as a from "react";
import { useState as Z, useRef as Y, useMemo as V2, useCallback as M, useEffect as $ } from "react";
import { C as w2, a as x2 } from "./CameraCard-DCtEAYmX.mjs";
import { s as L2, k as _2, S as M2, L as H2, a as d2 } from "./UploadLivenessVideo-ia7J-Ak0.mjs";
import { M as p2 } from "./MediaPipeVideo-BLVUgMdB.mjs";
import { I as Z2, f as v2, h as y2 } from "./InitLivenessCheck-skpuLOln.mjs";
import { R as b2 } from "./RetryLimitHandler-Bj2Rrg3E.mjs";
const E2 = (e) => /* @__PURE__ */ a.createElement("svg", { width: 56, height: 56, viewBox: "0 0 56 56", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ a.createElement("path", { d: "M40.625 22.969C39.349 22.969 38.164 23.508 37.435 24.406C36.797 22.699 35.156 21.531 33.333 21.531C32.148 21.531 31.146 21.98 30.325 22.699C30.234 20.453 28.32 18.656 26.041 18.656C24.856 18.656 23.853 19.105 23.124 19.824V9.312C23.124 6.976 21.119 5 18.749 5C16.288 5 14.374 6.977 14.374 9.312V28.449C11.822 29.258 9.99902 31.683 9.99902 34.469V37.344C9.99902 44.891 16.197 51 23.853 51H31.145C38.71 51 44.999 44.891 44.999 37.344V27.281C44.999 24.945 42.995 22.969 40.625 22.969ZM30.417 29.438V25.844C30.417 24.317 31.693 22.969 33.334 22.969C34.883 22.969 36.251 24.317 36.251 25.844V31.594C36.251 33.211 34.884 34.469 33.334 34.469C31.693 34.469 30.417 33.211 30.417 31.594V29.438ZM23.125 22.969C23.125 21.442 24.401 20.094 26.042 20.094C27.591 20.094 28.959 21.442 28.959 22.969V29.168C28.139 28.449 27.136 28 26.042 28H23.125V22.969ZM15.833 9.312C15.833 7.785 17.109 6.437 18.75 6.437C20.299 6.437 21.667 7.785 21.667 9.312V28H16.563C16.289 28 16.016 28.09 15.834 28.09L15.833 9.312ZM43.542 37.344C43.542 44.172 37.982 49.563 31.146 49.563H23.854C16.927 49.563 11.458 44.172 11.458 37.344V34.469C11.458 31.774 13.737 29.438 16.562 29.438H26.041C27.59 29.438 28.958 30.786 28.958 32.313C28.958 33.93 27.591 35.188 26.041 35.188H19.479C19.023 35.188 18.75 35.547 18.75 35.907C18.75 36.356 19.023 36.626 19.479 36.626H26.041C27.682 36.626 29.14 35.728 29.869 34.38C30.689 35.278 31.874 35.907 33.333 35.907C34.7 35.907 35.885 35.278 36.705 34.38C37.434 35.728 38.893 36.626 40.624 36.626C41.718 36.626 42.72 36.267 43.541 35.548V37.345L43.542 37.344ZM43.542 30.156V32.312C43.542 33.929 42.175 35.187 40.625 35.187C38.984 35.187 37.708 33.929 37.708 32.312V27.281C37.708 25.754 38.984 24.406 40.625 24.406C42.174 24.406 43.542 25.754 43.542 27.281V30.156Z", fill: "currentColor" })), A2 = (e) => /* @__PURE__ */ a.createElement("svg", { width: 56, height: 56, viewBox: "0 0 56 56", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ a.createElement("path", { d: "M41.7129 22.969C40.4629 22.969 39.3019 23.508 38.5869 24.406C37.9619 22.699 36.3539 21.531 34.5679 21.531C33.4069 21.531 32.3349 22.07 31.5319 22.789L32.2459 9.582C32.3349 7.066 30.3709 5 27.9599 5C25.6379 5 23.7629 6.887 23.6739 9.133L22.8699 24.766L16.7979 10.391C16.0839 8.864 14.6549 7.875 13.0469 7.875C10.1899 7.875 8.22485 10.84 9.29685 13.535L15.5479 28.539C13.2259 29.617 11.7079 31.863 11.7079 34.469V37.344C11.7079 44.891 17.7809 51 25.2819 51H32.4259C39.8379 51 45.9999 44.891 45.9999 37.344V27.281C45.9999 24.945 44.0339 22.969 41.7129 22.969ZM31.7119 25.844C31.7119 24.317 32.9619 22.969 34.5699 22.969C36.0879 22.969 37.4279 24.317 37.4279 25.844V31.594C37.4279 33.211 36.0879 34.469 34.5699 34.469C32.9629 34.469 31.7119 33.211 31.7119 31.594V25.844ZM25.1029 9.223C25.1919 7.696 26.4419 6.438 27.9609 6.438C29.5679 6.438 30.8189 7.876 30.8189 9.493L29.8369 28.809C29.1229 28.36 28.3189 28 27.4259 28H24.2999L24.2109 27.82L25.1039 9.222L25.1029 9.223ZM10.6359 12.996C9.92185 11.289 11.1719 9.312 13.0469 9.312C14.1189 9.312 15.0119 9.941 15.4579 10.929L22.6919 27.999H18.0479C17.6909 27.999 17.2439 28.089 16.8869 28.179L10.6359 12.996ZM44.5709 37.344C44.5709 44.172 39.1229 49.563 32.4259 49.563H25.2819C18.4949 49.563 13.1369 44.172 13.1369 37.344V34.469C13.1369 31.774 15.3699 29.438 18.1379 29.438H27.4249C28.9429 29.438 30.2829 30.786 30.2829 32.313C30.2829 33.93 28.9429 35.188 27.4249 35.188H20.9949C20.5479 35.188 20.2809 35.547 20.2809 35.907C20.2809 36.356 20.5489 36.626 20.9949 36.626H27.4249C29.0319 36.626 30.4609 35.728 31.1759 34.38C31.9799 35.278 33.1409 35.907 34.5689 35.907C35.9089 35.907 37.0689 35.278 37.8729 34.38C38.5869 35.728 40.0159 36.626 41.7129 36.626C42.7849 36.626 43.7669 36.267 44.5709 35.548V37.344ZM44.5709 30.156V32.312C44.5709 33.929 43.2309 35.187 41.7129 35.187C40.1059 35.187 38.8549 33.929 38.8549 32.312V27.281C38.8549 25.754 40.1049 24.406 41.7129 24.406C43.2309 24.406 44.5709 25.754 44.5709 27.281V30.156Z", fill: "currentColor" })), F2 = (e) => /* @__PURE__ */ a.createElement("svg", { width: 56, height: 56, viewBox: "0 0 56 56", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ a.createElement("path", { d: "M44.6582 24.538C43.5322 24.538 42.4652 24.977 41.6622 25.719C41.3422 24.277 40.3162 23.418 40.3162 23.418C39.5022 22.699 38.5072 22.25 37.4212 22.25C36.2452 22.25 35.2502 22.699 34.4362 23.418C34.3452 21.172 32.4462 19.375 30.1842 19.375C29.0082 19.375 28.0132 19.824 27.2892 20.543V9.312C27.2892 6.976 25.2992 5 22.9462 5C20.5032 5 18.6042 6.977 18.6042 9.312V33.48L14.4422 29.257C12.7232 27.64 9.91923 27.64 8.29023 29.257C6.57123 30.964 6.57123 33.749 8.29023 35.366L17.6082 44.71C21.6792 48.753 27.1982 50.999 32.9882 50.999H33.8022C41.8542 50.999 48.4582 44.8 48.9102 36.894L48.9802 32.684C48.9852 32.613 49.0002 32.547 49.0002 32.474V28.849C49.0002 26.423 47.1002 24.538 44.6582 24.538ZM34.5252 26.562C34.5252 25.035 35.7922 23.687 37.4202 23.687C38.9582 23.687 40.3152 25.035 40.3152 26.562V32.312C40.3152 33.929 38.9582 35.187 37.4202 35.187C35.7922 35.187 34.5252 33.929 34.5252 32.312V26.562ZM27.2882 23.688C27.2882 22.161 28.5552 20.813 30.1832 20.813C31.7212 20.813 33.0782 22.161 33.0782 23.688V32.313C33.0782 33.93 31.7212 35.188 30.1832 35.188C28.5552 35.188 27.2882 33.93 27.2882 32.313V23.688ZM33.8012 49.562H32.9872C27.6492 49.562 22.4932 47.496 18.6932 43.722L9.28423 34.379C8.10823 33.301 8.10823 31.414 9.28423 30.336C10.3702 29.168 12.2692 29.168 13.3552 30.336L18.7832 35.727C18.9642 35.907 19.3262 35.907 19.5972 35.817C19.8682 35.727 20.0492 35.458 20.0492 35.188V9.312C20.0492 7.785 21.3162 6.437 22.9442 6.437C24.4822 6.437 25.8392 7.785 25.8392 9.312V32.312C25.8392 34.738 27.7392 36.624 30.1812 36.624C31.6292 36.624 32.9862 35.905 33.8002 34.737C34.5242 35.905 35.8812 36.624 37.4192 36.624C38.8992 36.624 40.2332 35.876 41.0212 34.718C41.7712 35.951 43.1222 36.787 44.6562 36.787C45.7952 36.787 46.7592 36.36 47.4772 35.68L47.4612 36.625C47.0992 43.813 41.1282 49.563 33.8002 49.563L33.8012 49.562ZM47.5302 32.698C47.4132 34.13 46.2062 35.351 44.6582 35.351C43.1202 35.351 41.7632 34.003 41.7632 32.476V28.851C41.7632 27.234 43.1202 25.976 44.6582 25.976C46.2862 25.976 47.5532 27.234 47.5532 28.851V31.374L47.5302 32.698Z", fill: "currentColor" })), j2 = (e) => /* @__PURE__ */ a.createElement("svg", { width: 56, height: 56, viewBox: "0 0 56 56", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ a.createElement("path", { d: "M44.3972 24.493C43.2792 24.493 42.2192 24.932 41.4212 25.674C41.1032 24.232 40.0842 23.373 40.0842 23.373C39.2752 22.654 38.2872 22.205 37.2092 22.205C36.0822 22.205 35.1262 22.63 34.3342 23.305V9.312C34.3342 6.976 32.3572 5 30.0222 5C27.5962 5 25.7102 6.977 25.7102 9.312V20.881L25.6272 20.364L23.9652 9.985C23.5962 7.678 21.3312 6.039 19.0252 6.409C16.6302 6.793 15.0792 9.043 15.4492 11.349L19.6912 34.637L18.5242 33.435L14.3912 29.212C12.6842 27.595 9.8992 27.595 8.2822 29.212C6.5752 30.919 6.5752 33.704 8.2822 35.321L17.5362 44.665C21.5792 48.708 27.0592 50.954 32.8092 50.954H33.6182C41.6142 50.954 48.1732 44.755 48.6222 36.848L48.6922 32.638C48.6972 32.567 48.7122 32.501 48.7122 32.428V28.804C48.7122 26.378 46.8252 24.492 44.4002 24.492L44.3972 24.493ZM37.2102 23.643C38.7372 23.643 40.0852 24.991 40.0852 26.518V32.268C40.0852 33.885 38.7372 35.143 37.2102 35.143C35.5932 35.143 34.3352 33.885 34.3352 32.268V26.518C34.3352 24.991 35.5932 23.643 37.2102 23.643ZM33.6162 49.518H32.8072C27.5062 49.518 22.3852 47.452 18.6122 43.678L9.2692 34.334C8.1012 33.256 8.1012 31.369 9.2692 30.291C10.3472 29.123 12.2342 29.123 13.3122 30.291L20.3192 37.119C20.4992 37.299 20.8582 37.299 21.1282 37.209C21.3972 37.119 21.5772 36.85 21.5772 36.58L16.8682 11.122C16.6262 9.614 17.6552 8.084 19.2522 7.828C20.7602 7.586 22.3042 8.704 22.5452 10.212L24.7052 23.696L25.5012 28.664L25.7282 30.083H25.7362C25.7982 30.415 26.0772 30.673 26.4292 30.673C26.8262 30.673 27.1482 30.351 27.1482 29.954V9.312C27.1482 7.785 28.4062 6.437 30.0232 6.437C31.5502 6.437 32.8982 7.785 32.8982 9.312V32.267C32.8982 33.595 33.6172 34.693 33.6172 34.693C34.3362 35.861 35.6832 36.58 37.2112 36.58C38.6812 36.58 40.0062 35.832 40.7882 34.674C41.5322 35.907 42.8752 36.743 44.3982 36.743C45.5292 36.743 46.4872 36.316 47.1992 35.636L47.1832 36.581C46.8242 43.769 40.8942 49.518 33.6162 49.518ZM47.2502 32.653C47.1342 34.085 45.9352 35.306 44.3982 35.306C42.8712 35.306 41.5232 33.958 41.5232 32.431V28.807C41.5232 27.19 42.8712 25.932 44.3982 25.932C46.0152 25.932 47.2732 27.19 47.2732 28.807V31.33L47.2502 32.653Z", fill: "currentColor" })), k2 = (e) => /* @__PURE__ */ a.createElement("svg", { width: 56, height: 56, viewBox: "0 0 56 56", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ a.createElement("path", { d: "M44.3972 13.994C43.2752 13.994 42.2802 14.429 41.5222 15.115V11.306C41.5222 8.97 39.5452 6.994 37.2102 6.994C36.0082 6.994 34.9402 7.481 34.1672 8.255C33.6622 6.435 31.9772 5.045 30.0222 5.045C28.5022 5.045 27.1942 5.822 26.4292 6.977C25.6492 5.799 24.3172 5 22.8352 5C20.4092 5 18.5232 6.977 18.5232 9.312V33.48L14.3902 29.257C12.6832 27.64 9.89823 27.64 8.28123 29.257C6.57423 30.964 6.57423 33.749 8.28123 35.366L17.5352 44.71C21.5782 48.753 27.0582 50.999 32.8082 50.999H33.6162C41.6122 50.999 48.1712 44.8 48.6202 36.893L48.7052 31.798H48.7102V18.305C48.7102 15.969 46.7332 13.993 44.3982 13.993L44.3972 13.994ZM47.1832 36.625C46.8242 43.813 40.8942 49.563 33.6162 49.563H32.8082C27.5072 49.563 22.3862 47.497 18.6132 43.723L9.26923 34.379C8.10123 33.301 8.10123 31.414 9.26923 30.336C10.3472 29.168 12.2342 29.168 13.3122 30.336L18.7032 35.727C18.8832 35.907 19.2422 35.907 19.5122 35.817C19.7812 35.727 19.9612 35.458 19.9612 35.188V9.312C19.9612 7.785 21.2192 6.437 22.8362 6.437C24.3632 6.437 25.7112 7.785 25.7112 9.312V30C25.7112 30.397 26.0332 30.719 26.4302 30.719C26.8272 30.719 27.1492 30.397 27.1492 30V9.357C27.1492 7.83 28.4072 6.482 30.0242 6.482C31.5512 6.482 32.8992 7.83 32.8992 9.357V28.999C32.8992 29.396 33.2212 29.719 33.6182 29.719C34.0092 29.719 34.3242 29.406 34.3332 29.017H34.3362V28.483V11.306C34.3362 9.779 35.5942 8.431 37.2112 8.431C38.7382 8.431 40.0862 9.779 40.0862 11.306V30C40.0862 30.397 40.4082 30.72 40.8052 30.72C41.1962 30.72 41.5112 30.407 41.5202 30.018H41.5232V28.432V18.308C41.5232 16.781 42.7812 15.433 44.3982 15.433C45.9252 15.433 47.2732 16.781 47.2732 18.308V31.376L47.1832 36.627V36.625Z", fill: "currentColor" })), G2 = (e) => /* @__PURE__ */ a.createElement("svg", { width: 56, height: 56, viewBox: "0 0 56 56", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ a.createElement("path", { d: "M41.2364 14.968C40.0994 14.968 39.444 15.413 38.709 16.142V12.358C38.709 10.022 36.704 8.046 34.334 8.046C33.184 8.046 32.164 8.489 31.392 9.188C31.296 6.927 29.346 5.045 27.035 5.045C25.495 5.045 24.17 5.819 23.393 6.97C22.601 5.795 21.251 5 19.75 5C17.289 5 15.375 6.977 15.375 9.312V28.449C12.823 29.258 11 31.683 11 34.469V37.344C11 44.891 17.198 51 24.854 51H31.146C38.711 51 45 44.891 45 37.344V19.28C45 16.944 43.4479 14.968 41.2364 14.968ZM27.035 6.482C28.584 6.482 29.952 7.83 29.952 9.357V29.162C29.133 28.447 28.133 28 27.043 28H24.126V9.312C24.126 9.312 24.125 9.303 24.125 9.299C24.157 7.796 25.415 6.482 27.035 6.482ZM16.834 9.312C16.834 7.785 18.11 6.437 19.751 6.437C21.296 6.437 22.658 7.777 22.666 9.299C22.666 9.319 22.66 9.337 22.66 9.357V28H17.563C17.29 28 17.016 28.09 16.834 28.09V9.312ZM43.543 30.156V37.344C43.543 44.172 37.983 49.563 31.147 49.563H24.855C17.928 49.563 12.459 44.172 12.459 37.344V34.469C12.459 31.774 14.738 29.438 17.563 29.438H27.042C28.591 29.438 29.959 30.786 29.959 32.313C29.959 33.93 28.592 35.188 27.042 35.188H20.48C20.024 35.188 19.751 35.547 19.751 35.907C19.751 36.356 20.024 36.626 20.48 36.626H27.042C28.683 36.626 30.141 35.728 30.87 34.38C30.87 34.38 31.417 33.318 31.417 31.595V12.358C31.417 10.831 32.693 9.483 34.334 9.483C35.883 9.483 37.251 10.831 37.251 12.358V31.483C37.251 31.483 37.25 31.486 37.25 31.488C37.25 31.885 37.577 32.207 37.979 32.207C38.381 32.207 38.708 31.885 38.708 31.488C38.708 31.486 38.707 31.485 38.707 31.483H38.709V19.281C38.709 17.754 39.8291 16.5587 41.2364 16.5587C42.6436 16.5587 43.543 17.754 43.543 19.281V30.156Z", fill: "currentColor" })), S2 = (e) => /* @__PURE__ */ a.createElement("svg", { width: 56, height: 56, viewBox: "0 0 56 56", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ a.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M40.416 15.2764C42.786 15.2764 44.791 17.2524 44.791 19.5884H44.789V29.2444C44.789 33.2739 42.796 36.8953 39.7618 39.0915C38.2309 40.328 36.6407 41.1469 34.9936 41.6822C32.3821 42.5309 29.6631 42.654 26.9022 42.654C24.6568 42.654 21.7054 42.3997 18.8533 41.4963C18.4126 41.3567 17.9729 41.2011 17.5375 41.0281C15.0514 40.3088 12.9523 38.7478 11.5657 36.6815C11.4852 36.5746 11.4061 36.466 11.3287 36.3554C11.2827 36.2895 11.2495 36.2185 11.2287 36.1454C10.4008 34.7369 9.89074 33.1236 9.79004 31.4004V30.4124C10.155 27.6274 12.069 25.2914 14.53 24.2134C14.256 23.5844 14.165 22.9554 14.165 22.3264V16.7134C14.165 14.3784 16.079 12.4014 18.54 12.4014C19.634 12.4014 20.637 12.8504 21.457 13.5694C21.639 11.3234 23.462 9.52637 25.832 9.52637C28.111 9.52637 30.025 11.3234 30.116 13.5694C30.937 12.8504 31.939 12.4014 33.124 12.4014C35.403 12.4014 37.317 14.1984 37.408 16.4444C38.228 15.7254 39.231 15.2764 40.416 15.2764ZM18.0107 39.7096C16.24 39 14.6034 37.9961 13.3165 36.5973C12.0936 35.0911 11.3392 33.2014 11.248 31.1314C11.43 27.7174 14.256 24.9324 17.81 24.9324H25.102C26.651 24.9324 28.019 26.2804 28.019 27.8074C28.019 29.4244 26.652 30.6824 25.102 30.6824H19.269C18.813 30.6824 18.54 31.0414 18.54 31.4014C18.54 31.8504 18.813 32.1204 19.269 32.1204H25.102C27.472 32.1204 29.477 30.2334 29.477 27.8074C29.477 26.4594 28.839 25.2914 27.836 24.4834C28.383 24.2134 28.839 23.8544 29.203 23.4054C29.932 24.7534 31.391 25.6514 33.122 25.6514C34.307 25.6514 35.492 25.2024 36.312 24.3034C36.859 25.9204 38.5 27.0884 40.414 27.0884C41.508 27.0884 42.51 26.7294 43.331 26.0104V29.2444C43.331 31.9127 42.3737 34.312 40.7813 36.1871C40.4056 36.606 40.0271 36.9901 39.6457 37.3423C39.2844 37.6603 38.9017 37.9563 38.5 38.2284C38.2933 38.3447 38.1152 38.4988 37.9689 38.6816C36.8573 39.4398 35.7216 39.9735 34.5608 40.3507C32.1723 41.127 29.6413 41.254 26.9022 41.254C24.8001 41.254 22.085 41.0201 19.4717 40.2225C18.9886 40.0169 18.4848 39.8394 18.175 39.7564C18.12 39.7412 18.0653 39.7257 18.0107 39.7096ZM21.458 22.3274V20.6204H21.459V16.7144C21.459 15.1874 20.091 13.8394 18.542 13.8394C16.901 13.8394 15.625 15.1874 15.625 16.7144V22.3274C15.625 22.7774 15.717 23.3164 15.99 23.7654C16.537 23.5854 17.175 23.4954 17.813 23.4954H21.185C21.2124 23.3876 21.2479 23.2797 21.2842 23.1693C21.3689 22.9122 21.458 22.6416 21.458 22.3274ZM28.749 20.6204V13.8384C28.749 12.3114 27.381 10.9634 25.832 10.9634C24.191 10.9634 22.915 12.3114 22.915 13.8384V20.6204C22.915 22.2374 24.191 23.4954 25.832 23.4954C27.382 23.4954 28.749 22.2374 28.749 20.6204ZM36.041 21.3384V16.7144C36.041 15.1874 34.673 13.8394 33.124 13.8394C31.483 13.8394 30.207 15.1874 30.207 16.7144V21.3384C30.207 22.9554 31.483 24.2134 33.124 24.2134C34.674 24.2134 36.041 22.9554 36.041 21.3384ZM40.416 25.6514C41.966 25.6514 43.333 24.3934 43.333 22.7764V19.5884C43.333 18.0614 41.965 16.7134 40.416 16.7134C38.775 16.7134 37.499 18.0614 37.499 19.5884V22.7764C37.499 24.3934 38.775 25.6514 40.416 25.6514Z", fill: "currentColor" })), c2 = (e) => e.map((n, i) => {
let s = null;
switch (n) {
case "01000":
s = o.jsx(E2, { width: 48, hanging: 48 });
break;
case "01100":
s = o.jsx(A2, { width: 48, hanging: 48 });
break;
case "11000":
s = o.jsx(F2, { width: 48, hanging: 48 });
break;
case "11100":
s = o.jsx(j2, { width: 48, hanging: 48 });
break;
case "11111":
s = o.jsx(k2, { width: 48, hanging: 48 });
break;
case "01111":
s = o.jsx(G2, { width: 48, hanging: 48 });
break;
case "00000":
s = o.jsx(S2, { width: 48, hanging: 48 });
break;
}
let c = "";
return i === 0 ? c = l.liveness_check_action_show_gesture_first : i === e.length - 1 ? c = l.liveness_check_action_show_gesture_last : c = l.liveness_check_action_show_gesture_mid, {
instruction: {
icon: s,
text: c
},
outline: "countdown",
dimension: "interactive-face"
};
}), R = (e) => {
const n = T(e, 0);
let i = T2(e, n, 4, 2);
for (let s = 5; s < 18; s += 4)
i += O2(e, n, s + 3, s + 1);
return i;
}, T = (e, n) => ({
x: e[n].x,
y: e[n].y
}), T2 = (e, n, i, s) => {
const c = T(e, i), C = T(e, s), p = i2(n, C), v = i2(c, C);
return q2(p, v) * 180 / Math.PI > 140 ? "1" : "0";
}, O2 = (e, n, i, s) => {
const c = T(e, i), C = T(e, s), p = C2(c, n), v = C2(C, n);
return p > v ? "1" : "0";
}, C2 = (e, n) => {
const i = n.x - e.x, s = n.y - e.y;
return Math.sqrt(i * i + s * s);
}, i2 = (e, n) => ({
dx: n.x - e.x,
dy: n.y - e.y
}), q2 = (e, n) => {
const i = e.dx * n.dx + e.dy * n.dy, s = Math.sqrt(e.dx * e.dx + e.dy * e.dy), c = Math.sqrt(n.dx * n.dx + n.dy * n.dy);
return Math.acos(i / (s * c));
};
let d = 0, H = 0, G = 0, h = 0, z = c2(S.config.livenessCheckSettings.steps || []);
const N = new b2("error_code_6", "liveness"), B2 = ({ onNext: e, onBack: n }) => {
const [i, s] = Z(0), c = Y(null), C = Y(null), [p, v] = Z(!1), [I, y] = Z(!1), [b, J] = Z(!1), [m, l2] = Z(S.config.livenessCheckSettings.steps || []), [O, Q] = Z(!0), [U, q] = Z(!1), o2 = V2(() => S.config.promptLength, []), a2 = 24, W = Y([]), u2 = 1400, D = M(() => {
const t = new Z2();
t.fetchInitLivenessCheck().then(() => {
t.getInitLivenessCheck().then((r) => {
if (!(r != null && r.ok)) {
k({ ERROR: r });
return;
}
l2(r == null ? void 0 : r.gestures), z = c2((r == null ? void 0 : r.gestures) || []);
});
});
}, []);
$(() => {
p && s((t) => t + 1), !S.config.livenessCheckSettings.steps && D();
}, [D, p]), $(() => {
const t = setTimeout(() => {
b || k({
logo: "general-error",
title: l.error_timeout_title,
description: l.error_timeout_description,
btnText: l.restart_button,
ERROR: "timeout",
btnAction() {
N.handleRetry(() => n());
}
});
}, (S.config.livenessCheckSettings.recordingLength || 20) * 1e3);
return () => {
clearTimeout(t);
};
}, [b, n]);
const f2 = M((t) => {
J(t);
}, []), g2 = M(() => {
}, []), e2 = M((t) => typeof t == "number" && t > z.length || typeof t == "function" && t(i) > z.length ? !1 : (s(t), !0), [i]), h2 = M(async () => {
O ? await v2(C) : await y2(C);
}, [O]), K = M(async (t, r, u, V, g, w, x, L, _) => {
var j;
if (!((j = c.current) != null && j.srcObject) || !C.current || !(C.current instanceof L2))
return;
const E = performance.now();
let f = [];
c.current && C.current && (f = C.current.detectForVideo(c.current, E).detections), f.length > 0 && (t.current = t.current + 1), t.current === w && (r.current = E, t.current = 0, v(!0), Q(!1)), h = window.requestAnimationFrame(() => K(t, r, u, V, g, w, x, L, _));
}, []), F = M(async (t, r, u, V, g, w, x, L, _) => {
var t2, n2;
if (b) {
cancelAnimationFrame(h);
return;
}
if (!((t2 = c.current) != null && t2.srcObject) || !C.current || !(C.current instanceof _2) || u.current || !m || m.length === 0) {
h = window.requestAnimationFrame(() => F(t, r, u, V, g, w, x, L, _));
return;
}
const E = performance.now();
let f = [];
const j = 3;
if (G === 0 && (G = (/* @__PURE__ */ new Date()).getTime()), f = ((n2 = C.current) == null ? void 0 : n2.detectForVideo(c.current, E).landmarks[0]) || [], f.length > 0) {
if (m && R(f) === m[d]) {
if (u.current) {
t.current = 0, r.current = null, y(!1), h = window.requestAnimationFrame(() => F(t, r, u, V, g, w, x, L, _));
return;
}
t.current = t.current + 1, H = 0, t.current >= j && (t.current === j && (r.current = E, W.current.push((/* @__PURE__ */ new Date()).getTime() - G)), u.current = r.current && E - r.current > x * 1e3, y(!0), u.current && (q(!0), t.current = 0, setTimeout(async () => {
var s2, r2;
if (d < m.length - 1)
d++, e2((X) => X + 1), u.current = !1;
else {
for (L(!0), V.stop(); (((s2 = g.current) == null ? void 0 : s2.size) || 0) === 0; )
await new Promise((X) => setTimeout(X, 100));
(((r2 = g.current) == null ? void 0 : r2.size) || 0) > 0 ? (_(g.current, W.current), cancelAnimationFrame(h)) : k({
logo: "general-error",
title: l.error_liveness_upload_title,
description: l.error_document_upload_description,
btnText: l.restart_button,
ERROR: {
detections: f,
gestureSeen: R(f),
expected: m[d]
},
btnAction() {
cancelAnimationFrame(h), N.handleRetry(() => n());
}
});
}
}, u2)));
} else if (r.current = null, y(!1), q(!1), H <= 3 && t.current > 3 && H++, H > 3 && t.current > 3) {
k({
logo: "general-error",
title: l.error_unsuccessful_attempt_title,
description: l.error_unsuccessful_attempt_description,
btnText: l.restart_button,
ERROR: {
detections: f,
gestureSeen: R(f),
expected: m[d]
},
btnAction() {
var A;
cancelAnimationFrame(h), (A = C.current) == null || A.close(), C.current = null, N.handleRetry(() => n());
}
});
return;
}
} else if (r.current = null, y(!1), q(!1), H <= 3 && t.current > 3 && H++, H > 3 && t.current > 3) {
k({
logo: "general-error",
title: l.error_unsuccessful_attempt_title,
description: l.error_unsuccessful_attempt_description,
btnText: l.restart_button,
ERROR: {
detections: f,
gestureSeen: R(f),
expected: m[d]
},
btnAction() {
var A;
cancelAnimationFrame(h), (A = C.current) == null || A.close(), C.current = null, N.handleRetry(() => n());
}
});
return;
}
h = window.requestAnimationFrame(() => F(t, r, u, V, g, w, x, L, _));
}, [m, e2, b, n]), m2 = M(async ({ capturedInRow: t, videoDetectedChunkStartingTime: r, isDurationCompleted: u, mediaRecorder: V, capturedVideo: g, minFaceCapturedInRow: w, videoDurationS: x, setIsRecordingStopped: L, uploadVideo: _ }) => {
O ? K(t, r, u, V, g, w, x, L, _) : F(t, r, u, V, g, w, x, L, _);
}, [K, F, O]), P = [
{
instruction: {
icon: o.jsx(M2, { width: 48, hanging: 48 }),
text: l.liveness_check_action_position_face
},
animateTo: {
startAnimationTo: p,
strokeDasharray: "0",
strokeWidth: "4"
},
outline: "idle",
dimension: "interactive-face"
},
...z
], B = M(() => {
v(!1), y(!1), J(!1), s(0), d = 0, H = 0, G = 0, W.current = [], Q(!0), q(!1), window.cancelAnimationFrame(h);
}, []);
return $(() => () => {
var t;
(t = C.current) == null || t.close(), C.current = null, d = 0, H = 0, G = 0, h = 0, B();
}, [B]), o.jsxs(o.Fragment, { children: [o.jsx(w2, { className: `tw-w-full tw-h-full sm:tw-h-auto ${b && "tw-opacity-0"}`, children: o.jsx(x2, { idPrefix: "gesture-liveness-camera", onBack: n, title: l.liveness_check_selfie_flow_title, instructions: P[i].instruction, hideInstructions: U, children: o.jsx(H2, { dimension: P[i].dimension, outline: P[i].outline, startAnimation: I && !U, animateTo: P[i].animateTo, isSuccessful: U, children: o.jsx(p2, { initializeDetector: h2, videoRef: c, videoDurationS: o2, minFaceCapturedInRow: a2, detectorRef: C, handleIsUploading: f2, onNext: e, detectionLoop: m2, handleAnimationSteps: g2, resetStates: B }) }) }) }), o.jsx(d2, { isUploading: b })] });
};
export {
B2 as default
};