@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.
217 lines (216 loc) • 8.98 kB
JavaScript
import { j as e, B as g, t as b, c as y, G as j } from "./index-oGnhSncZ.mjs";
import { useState as v, useRef as x, useEffect as k } from "react";
import { S as f } from "./SelectInput-D_egVIuA.mjs";
const w = (t) => {
var d, i;
const n = document.querySelector(".tw-idverif-scope");
if (n === null)
throw new Error("Idv component not found");
const o = (i = (d = getComputedStyle(n)) == null ? void 0 : d.getPropertyValue(t)) == null ? void 0 : i.split(",");
return ((s, l, p) => "#" + [s, l, p].map((r) => r.toString(16).padStart(2, "0")).join(""))(parseInt(o[0]), parseInt(o[1]), parseInt(o[2]));
}, C = () => {
const [t, n] = v(() => [
{
name: "--idverif-light-base-text-on-light",
value: w("--idverif-light-base-text-on-light")
},
{
name: "--idverif-light-base-text-on-dark",
value: w("--idverif-light-base-text-on-dark")
},
{
name: "--idverif-light-base-accent",
value: w("--idverif-light-base-accent")
},
{
name: "--idverif-light-base-on-accent",
value: w("--idverif-light-base-on-accent")
},
{
name: "--idverif-dark-base-text-on-light",
value: w("--idverif-dark-base-text-on-light")
},
{
name: "--idverif-dark-base-text-on-dark",
value: w("--idverif-dark-base-text-on-dark")
},
{
name: "--idverif-dark-base-accent",
value: w("--idverif-dark-base-accent")
},
{
name: "--idverif-dark-base-on-accent",
value: w("--idverif-dark-base-on-accent")
}
]), [o, c] = v(!1), d = x(null), i = (r) => {
const a = t.map((u) => u.name === r.target.name ? { ...u, value: r.target.value } : u);
n(a);
}, s = (r) => {
const a = parseInt(r.slice(1, 3), 16), u = parseInt(r.slice(3, 5), 16), h = parseInt(r.slice(5, 7), 16);
return `${a}, ${u}, ${h}`;
}, l = () => {
const r = document.documentElement;
t.forEach((a) => {
r.style.setProperty(a.name, s(a.value));
});
}, p = () => {
const r = t.map((a) => `${a.name}: ${s(a.value)};`);
navigator.clipboard.writeText(r.join(`
`));
};
return e.jsxs("div", { className: "tw-flex", ref: d, children: [e.jsx(g, { onClick: () => c(!o), text: "Change colors", className: "tw-my-auto tw-min-w-[175px]" }), e.jsxs("div", { className: `${o ? "tw-max-h-96" : "tw-max-h-0"} tw-overflow-hidden tw-absolute tw-top-28 tw-bg-web-secondary tw-text-primary-on-light-100 dark:tw-text-primary-on-light-100-dark`, children: [t.map((r, a) => e.jsxs("div", { className: "tw-flex tw-justify-between tw-text-base tw-gap-2 tw-px-2 tw-py-1", children: [e.jsx("label", { htmlFor: `color-${a}`, children: r.name }, r.name + "l" + a), e.jsx("input", { id: `color-${a}`, type: "color", name: r.name, value: r.value, onChange: (u) => i(u) }, r.name)] }, `${r}-${a}`)), e.jsxs("div", { className: "tw-p-3 tw-flex tw-justify-between tw-gap-2", children: [e.jsx(g, { onClick: l, text: "Set colors" }), e.jsx(g, { onClick: p, text: "Copy var's" })] })] })] });
};
let m = !1;
const _ = (t) => {
if (typeof t == "string")
return t;
if (t instanceof Error)
return t.stack || t.message || t.toString();
if (typeof t == "object" && t !== null)
try {
return JSON.stringify(t, (n, o) => typeof o == "function" ? `[Function: ${o.name || "anonymous"}]` : o, 2);
} catch {
try {
return t.toString();
} catch {
return "[Unserializable Object]";
}
}
return String(t);
}, S = ({ enable: t }) => {
const n = x([]), o = x(null);
if (k(() => {
var r;
if (!t)
return;
const i = console.log, s = console.warn, l = console.error, p = console.info;
return console.log = c("log", i), console.warn = c("warn", s), console.error = c("error", l), console.info = c("info", p), m || (r = o.current) == null || r.click(), () => {
console.log = i, console.warn = s, console.error = l, console.info = p;
};
}, [t]), !t)
return null;
const c = (i, s) => (...l) => {
const p = l.map((r) => _(r)).join(" ");
n.current.push({ type: i, message: p }), s(...l);
}, d = async () => {
if (m) {
const i = n.current.map((s) => `[${s.type.toUpperCase()}] ${s.message}`).join(`
`);
try {
await navigator.clipboard.writeText(i), alert("Logs copied to clipboard!");
} catch (s) {
console.error("Failed to copy logs to clipboard: ", s);
}
}
m = !0;
};
return e.jsx("button", { className: "tw-inline tw-text-3xl tw-mx-auto tw-my-auto", onClick: d, ref: o, children: "💾" });
}, N = [
{
text: "general-error",
value: "general-error"
},
{
text: "camera-access",
value: "camera-access"
},
{
text: "country-not-supported",
value: "country-not-supported"
},
{
text: "document-not-supported",
value: "document-not-supported"
}
], E = [
{
title: "General Error",
description: "An error occurred. Please try again later.",
logo: "general-error"
},
{
title: "Camera Access Error",
description: "An error occurred while accessing the camera.",
logo: "camera-access"
},
{
title: "Country Not Supported Error",
description: "The country is not supported.",
logo: "country-not-supported"
},
{
title: "Document Not Supported Error",
description: "The document is not supported.",
logo: "document-not-supported"
}
], T = () => e.jsx(f, { idPrefix: "dev-error-trigger", onChange: (t) => {
const n = E.find((o) => o.logo === t.value);
b(n);
}, options: N, placeholder: {
value: "",
text: "Select error to trigger"
} }), $ = [
{
text: "start",
value: "start"
},
{
text: "completed",
value: "completed"
},
{
text: "error - error_code_1",
value: "error-error_code_1"
},
{
text: "error - error_code_2",
value: "error-error_code_2"
},
{
text: "error - error_code_3",
value: "error-error_code_3"
},
{
text: "error - error_code_4",
value: "error-error_code_4"
},
{
text: "error - error_code_5",
value: "error-error_code_5"
},
{
text: "error - error_code_6",
value: "error-error_code_6"
},
{
text: "completedSuccess",
value: "completedSuccess"
},
{
text: "Cancelled",
value: "cancelled"
},
{ text: "completedPending", value: "completedPending" },
{ text: "completedFailed", value: "completedFailed" }
], I = () => e.jsx(f, { idPrefix: "dev-event-trigger", onChange: (t) => {
const n = t.value.split("-")[0], o = t.value.split("-")[1];
y(n, o);
}, options: $, placeholder: {
value: "",
text: "Select event to trigger"
} }), D = ({ setCurrentScreen: t, screens: n }) => {
const o = n.map((c, d) => ({
value: d,
text: c.name
}));
return e.jsx(f, { idPrefix: "dev-event-trigger", onChange: (c) => t(c.value), options: o, placeholder: {
value: 0,
text: "Jump to screen"
} });
}, L = (t) => {
const { setCurrentScreen: n, screens: o } = t;
return e.jsxs(e.Fragment, { children: [e.jsx("div", { className: "tw-hidden sx:tw-flex tw-z-50 tw-fixed tw-left-0 tw-transition-all tw-duration-300 -tw-top-28 hover:tw-top-0 tw-w-full tw-h-[136px]", children: e.jsxs("div", { className: "tw-py-2 tw-px-4 tw-text-primary-on-light-100 dark:tw-text-primary-on-light-100-dark tw-w-full tw-h-28 tw-bg-web-secondary dark:tw-bg-web-secondary-dark tw-flex tw-justify-between tw-items-start tw-gap-4", children: [e.jsxs("div", { children: [e.jsx("h1", { children: "Devtools" }), e.jsx("p", { className: "tw-text-start tw-text-[10px] tw-opacity-70", children: e.jsxs("a", { href: "https://github.com/seontechnologies/id-verification-sdk-web/commit/96328f287ba8f2ca83231d816c72c12bb8e218e2", target: "_blank", rel: "noreferrer", children: ["Commit: ", "96328f287ba8f2ca83231d816c72c12bb8e218e2"] }) }), e.jsx("p", { className: "tw-text-start tw-text-[12px] tw-opacity-70 tw-font-semibold", title: "Click to copy version", onClick: () => navigator.clipboard.writeText("v1.3.0-96328f2"), style: { cursor: "pointer" }, children: "v1.3.0-96328f2" })] }), e.jsxs("div", { className: "tw-w-full tw-flex tw-flex-col tw-gap-2 tw-items-end", children: [e.jsxs("div", { className: "tw-w-full tw-flex tw-justify-end tw-items-center tw-gap-4", children: [e.jsx(D, { screens: o, setCurrentScreen: n }), e.jsx(T, {}), e.jsx(I, {})] }), e.jsxs("div", { className: "tw-w-min tw-flex tw-justify-end tw-items-center tw-gap-4", children: [e.jsx(C, {}), e.jsx(g, { className: "tw-h-1/2 tw-min-w-[175px]", text: "Change theme", onClick: () => j() })] })] })] }) }), e.jsx("div", { className: "tw-py-1 tw-pl-2 tw-pr-4 tw-z-40 tw-fixed tw-top-0 tw-left-0 tw-rounded-br-full tw-bg-web-secondary dark:tw-bg-web-secondary-dark tw-text-primary-on-light-100 dark:tw-text-primary-on-light-100-dark tw-font-light tw-text-xs", children: "show devtools" }), e.jsx("div", { className: "tw-absolute tw-bottom-4 tw-right-4 tw-w-8 tw-h-8 tw-z-50", children: e.jsx(S, { enable: !1 }) })] });
};
export {
L as default
};