UNPKG

@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.

388 lines (387 loc) 14.8 kB
var dt = (e) => { throw TypeError(e); }; var J = (e, t, s) => t.has(e) || dt("Cannot " + s); var r = (e, t, s) => (J(e, t, "read from private field"), s ? s.call(e) : t.get(e)), y = (e, t, s) => t.has(e) ? dt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, s), c = (e, t, s, i) => (J(e, t, "write to private field"), i ? i.call(e, s) : t.set(e, s), s), d = (e, t, s) => (J(e, t, "access private method"), s); import { b as wt, w as ft, x as O, s as X, y as B, c as Y, z as Z, A as pt, C as St, D as Et, E as It, F as yt, n as Rt, d as Qt, u as xt } from "./index-BbjzUPso.mjs"; import * as w from "react"; var g, n, H, b, x, U, S, E, N, M, _, T, F, I, P, a, j, tt, et, st, rt, it, nt, at, Ct, vt, Tt = (vt = class extends wt { constructor(t, s) { super(); y(this, a); y(this, g); y(this, n); y(this, H); y(this, b); y(this, x); y(this, U); y(this, S); y(this, E); y(this, N); y(this, M); // This property keeps track of the last query with defined data. // It will be used to pass the previous data and query to the placeholder function between renders. y(this, _); y(this, T); y(this, F); y(this, I); y(this, P, /* @__PURE__ */ new Set()); this.options = s, c(this, g, t), c(this, E, null), c(this, S, ft()), this.options.experimental_prefetchInRender || r(this, S).reject( new Error("experimental_prefetchInRender feature flag is not enabled") ), this.bindMethods(), this.setOptions(s); } bindMethods() { this.refetch = this.refetch.bind(this); } onSubscribe() { this.listeners.size === 1 && (r(this, n).addObserver(this), bt(r(this, n), this.options) ? d(this, a, j).call(this) : this.updateResult(), d(this, a, rt).call(this)); } onUnsubscribe() { this.hasListeners() || this.destroy(); } shouldFetchOnReconnect() { return ot( r(this, n), this.options, this.options.refetchOnReconnect ); } shouldFetchOnWindowFocus() { return ot( r(this, n), this.options, this.options.refetchOnWindowFocus ); } destroy() { this.listeners = /* @__PURE__ */ new Set(), d(this, a, it).call(this), d(this, a, nt).call(this), r(this, n).removeObserver(this); } setOptions(t) { const s = this.options, i = r(this, n); if (this.options = r(this, g).defaultQueryOptions(t), this.options.enabled !== void 0 && typeof this.options.enabled != "boolean" && typeof this.options.enabled != "function" && typeof O(this.options.enabled, r(this, n)) != "boolean") throw new Error( "Expected enabled to be a boolean or a callback that returns a boolean" ); d(this, a, at).call(this), r(this, n).setOptions(this.options), s._defaulted && !X(this.options, s) && r(this, g).getQueryCache().notify({ type: "observerOptionsUpdated", query: r(this, n), observer: this }); const u = this.hasListeners(); u && gt( r(this, n), i, this.options, s ) && d(this, a, j).call(this), this.updateResult(), u && (r(this, n) !== i || O(this.options.enabled, r(this, n)) !== O(s.enabled, r(this, n)) || B(this.options.staleTime, r(this, n)) !== B(s.staleTime, r(this, n))) && d(this, a, tt).call(this); const h = d(this, a, et).call(this); u && (r(this, n) !== i || O(this.options.enabled, r(this, n)) !== O(s.enabled, r(this, n)) || h !== r(this, I)) && d(this, a, st).call(this, h); } getOptimisticResult(t) { const s = r(this, g).getQueryCache().build(r(this, g), t), i = this.createResult(s, t); return Dt(this, i) && (c(this, b, i), c(this, U, this.options), c(this, x, r(this, n).state)), i; } getCurrentResult() { return r(this, b); } trackResult(t, s) { return new Proxy(t, { get: (i, u) => (this.trackProp(u), s == null || s(u), Reflect.get(i, u)) }); } trackProp(t) { r(this, P).add(t); } getCurrentQuery() { return r(this, n); } refetch({ ...t } = {}) { return this.fetch({ ...t }); } fetchOptimistic(t) { const s = r(this, g).defaultQueryOptions(t), i = r(this, g).getQueryCache().build(r(this, g), s); return i.fetch().then(() => this.createResult(i, s)); } fetch(t) { return d(this, a, j).call(this, { ...t, cancelRefetch: t.cancelRefetch ?? !0 }).then(() => (this.updateResult(), r(this, b))); } createResult(t, s) { var lt; const i = r(this, n), u = this.options, h = r(this, b), o = r(this, x), Q = r(this, U), R = t !== i ? t.state : r(this, H), { state: k } = t; let l = { ...k }, L = !1, f; if (s._optimisticResults) { const v = this.hasListeners(), z = !v && bt(t, s), D = v && gt(t, i, s, u); (z || D) && (l = { ...l, ...It(k.data, t.options) }), s._optimisticResults === "isRestoring" && (l.fetchStatus = "idle"); } let { error: q, errorUpdatedAt: A, status: m } = l; f = l.data; let V = !1; if (s.placeholderData !== void 0 && f === void 0 && m === "pending") { let v; h != null && h.isPlaceholderData && s.placeholderData === (Q == null ? void 0 : Q.placeholderData) ? (v = h.data, V = !0) : v = typeof s.placeholderData == "function" ? s.placeholderData( (lt = r(this, _)) == null ? void 0 : lt.state.data, r(this, _) ) : s.placeholderData, v !== void 0 && (m = "success", f = yt( h == null ? void 0 : h.data, v, s ), L = !0); } if (s.select && f !== void 0 && !V) if (h && f === (o == null ? void 0 : o.data) && s.select === r(this, N)) f = r(this, M); else try { c(this, N, s.select), f = s.select(f), f = yt(h == null ? void 0 : h.data, f, s), c(this, M, f), c(this, E, null); } catch (v) { c(this, E, v); } r(this, E) && (q = r(this, E), f = r(this, M), A = Date.now(), m = "error"); const K = l.fetchStatus === "fetching", $ = m === "pending", G = m === "error", ct = $ && K, ut = f !== void 0, C = { status: m, fetchStatus: l.fetchStatus, isPending: $, isSuccess: m === "success", isError: G, isInitialLoading: ct, isLoading: ct, data: f, dataUpdatedAt: l.dataUpdatedAt, error: q, errorUpdatedAt: A, failureCount: l.fetchFailureCount, failureReason: l.fetchFailureReason, errorUpdateCount: l.errorUpdateCount, isFetched: l.dataUpdateCount > 0 || l.errorUpdateCount > 0, isFetchedAfterMount: l.dataUpdateCount > R.dataUpdateCount || l.errorUpdateCount > R.errorUpdateCount, isFetching: K, isRefetching: K && !$, isLoadingError: G && !ut, isPaused: l.fetchStatus === "paused", isPlaceholderData: L, isRefetchError: G && ut, isStale: ht(t, s), refetch: this.refetch, promise: r(this, S) }; if (this.options.experimental_prefetchInRender) { const v = (W) => { C.status === "error" ? W.reject(C.error) : C.data !== void 0 && W.resolve(C.data); }, z = () => { const W = c(this, S, C.promise = ft()); v(W); }, D = r(this, S); switch (D.status) { case "pending": t.queryHash === i.queryHash && v(D); break; case "fulfilled": (C.status === "error" || C.data !== D.value) && z(); break; case "rejected": (C.status !== "error" || C.error !== D.reason) && z(); break; } } return C; } updateResult() { const t = r(this, b), s = this.createResult(r(this, n), this.options); if (c(this, x, r(this, n).state), c(this, U, this.options), r(this, x).data !== void 0 && c(this, _, r(this, n)), X(s, t)) return; c(this, b, s); const i = () => { if (!t) return !0; const { notifyOnChangeProps: u } = this.options, h = typeof u == "function" ? u() : u; if (h === "all" || !h && !r(this, P).size) return !0; const o = new Set( h ?? r(this, P) ); return this.options.throwOnError && o.add("error"), Object.keys(r(this, b)).some((Q) => { const p = Q; return r(this, b)[p] !== t[p] && o.has(p); }); }; d(this, a, Ct).call(this, { listeners: i() }); } onQueryUpdate() { this.updateResult(), this.hasListeners() && d(this, a, rt).call(this); } }, g = new WeakMap(), n = new WeakMap(), H = new WeakMap(), b = new WeakMap(), x = new WeakMap(), U = new WeakMap(), S = new WeakMap(), E = new WeakMap(), N = new WeakMap(), M = new WeakMap(), _ = new WeakMap(), T = new WeakMap(), F = new WeakMap(), I = new WeakMap(), P = new WeakMap(), a = new WeakSet(), j = function(t) { d(this, a, at).call(this); let s = r(this, n).fetch( this.options, t ); return t != null && t.throwOnError || (s = s.catch(Y)), s; }, tt = function() { d(this, a, it).call(this); const t = B( this.options.staleTime, r(this, n) ); if (Z || r(this, b).isStale || !pt(t)) return; const i = St(r(this, b).dataUpdatedAt, t) + 1; c(this, T, setTimeout(() => { r(this, b).isStale || this.updateResult(); }, i)); }, et = function() { return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(r(this, n)) : this.options.refetchInterval) ?? !1; }, st = function(t) { d(this, a, nt).call(this), c(this, I, t), !(Z || O(this.options.enabled, r(this, n)) === !1 || !pt(r(this, I)) || r(this, I) === 0) && c(this, F, setInterval(() => { (this.options.refetchIntervalInBackground || Et.isFocused()) && d(this, a, j).call(this); }, r(this, I))); }, rt = function() { d(this, a, tt).call(this), d(this, a, st).call(this, d(this, a, et).call(this)); }, it = function() { r(this, T) && (clearTimeout(r(this, T)), c(this, T, void 0)); }, nt = function() { r(this, F) && (clearInterval(r(this, F)), c(this, F, void 0)); }, at = function() { const t = r(this, g).getQueryCache().build(r(this, g), this.options); if (t === r(this, n)) return; const s = r(this, n); c(this, n, t), c(this, H, t.state), this.hasListeners() && (s == null || s.removeObserver(this), t.addObserver(this)); }, Ct = function(t) { Rt.batch(() => { t.listeners && this.listeners.forEach((s) => { s(r(this, b)); }), r(this, g).getQueryCache().notify({ query: r(this, n), type: "observerResultsUpdated" }); }); }, vt); function Ft(e, t) { return O(t.enabled, e) !== !1 && e.state.data === void 0 && !(e.state.status === "error" && t.retryOnMount === !1); } function bt(e, t) { return Ft(e, t) || e.state.data !== void 0 && ot(e, t, t.refetchOnMount); } function ot(e, t, s) { if (O(t.enabled, e) !== !1 && B(t.staleTime, e) !== "static") { const i = typeof s == "function" ? s(e) : s; return i === "always" || i !== !1 && ht(e, t); } return !1; } function gt(e, t, s, i) { return (e !== t || O(i.enabled, e) === !1) && (!s.suspense || e.state.status !== "error") && ht(e, s); } function ht(e, t) { return O(t.enabled, e) !== !1 && e.isStaleByTime(B(t.staleTime, e)); } function Dt(e, t) { return !X(e.getCurrentResult(), t); } var Ot = w.createContext(!1), Ut = () => w.useContext(Ot); Ot.Provider; function Mt() { let e = !1; return { clearReset: () => { e = !1; }, reset: () => { e = !0; }, isReset: () => e }; } var _t = w.createContext(Mt()), Pt = () => w.useContext(_t), kt = (e, t) => { (e.suspense || e.throwOnError || e.experimental_prefetchInRender) && (t.isReset() || (e.retryOnMount = !1)); }, Lt = (e) => { w.useEffect(() => { e.clearReset(); }, [e]); }, qt = ({ result: e, errorResetBoundary: t, throwOnError: s, query: i, suspense: u }) => e.isError && !t.isReset() && !e.isFetching && i && (u && e.data === void 0 || Qt(s, [e.error, i])), At = (e) => { if (e.suspense) { const t = (i) => i === "static" ? i : Math.max(i ?? 1e3, 1e3), s = e.staleTime; e.staleTime = typeof s == "function" ? (...i) => t(s(...i)) : t(s), typeof e.gcTime == "number" && (e.gcTime = Math.max(e.gcTime, 1e3)); } }, jt = (e, t) => e.isLoading && e.isFetching && !t, Bt = (e, t) => (e == null ? void 0 : e.suspense) && t.isPending, mt = (e, t, s) => t.fetchOptimistic(e).catch(() => { s.clearReset(); }); function Ht(e, t, s) { var l, L, f, q, A; if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e))) throw new Error( 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object' ); const i = Ut(), u = Pt(), h = xt(), o = h.defaultQueryOptions(e); (L = (l = h.getDefaultOptions().queries) == null ? void 0 : l._experimental_beforeQuery) == null || L.call( l, o ), process.env.NODE_ENV !== "production" && (o.queryFn || console.error( `[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function` )), o._optimisticResults = i ? "isRestoring" : "optimistic", At(o), kt(o, u), Lt(u); const Q = !h.getQueryCache().get(o.queryHash), [p] = w.useState( () => new t( h, o ) ), R = p.getOptimisticResult(o), k = !i && e.subscribed !== !1; if (w.useSyncExternalStore( w.useCallback( (m) => { const V = k ? p.subscribe(Rt.batchCalls(m)) : Y; return p.updateResult(), V; }, [p, k] ), () => p.getCurrentResult(), () => p.getCurrentResult() ), w.useEffect(() => { p.setOptions(o); }, [o, p]), Bt(o, R)) throw mt(o, p, u); if (qt({ result: R, errorResetBoundary: u, throwOnError: o.throwOnError, query: h.getQueryCache().get(o.queryHash), suspense: o.suspense })) throw R.error; if ((q = (f = h.getDefaultOptions().queries) == null ? void 0 : f._experimental_afterQuery) == null || q.call( f, o, R ), o.experimental_prefetchInRender && !Z && jt(R, i)) { const m = Q ? ( // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted mt(o, p, u) ) : ( // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in (A = h.getQueryCache().get(o.queryHash)) == null ? void 0 : A.promise ); m == null || m.catch(Y).finally(() => { p.updateResult(); }); } return o.notifyOnChangeProps ? R : p.trackResult(R); } function Wt(e, t) { return Ht(e, Tt); } export { Wt as u };